progress.js 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135
  1. /*!
  2. * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
  3. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
  4. * v1.0.0-beta.97
  5. */
  6. import { h } from "@stencil/core";
  7. export class Progress {
  8. constructor() {
  9. /**
  10. * Specifies the component type.
  11. *
  12. * Use `"indeterminate"` if finding actual progress value is impossible.
  13. *
  14. */
  15. this.type = "determinate";
  16. /** The component's progress value, with a range of 0.0 - 1.0. */
  17. this.value = 0;
  18. /** When `true` and for `"indeterminate"` progress bars, reverses the animation direction. */
  19. this.reversed = false;
  20. }
  21. render() {
  22. const isDeterminate = this.type === "determinate";
  23. const barStyles = isDeterminate ? { width: `${this.value * 100}%` } : {};
  24. return (h("div", { "aria-label": this.label || this.text, "aria-valuemax": 1, "aria-valuemin": 0, "aria-valuenow": this.value, role: "progressbar" }, h("div", { class: "track" }, h("div", { class: {
  25. bar: true,
  26. indeterminate: this.type === "indeterminate",
  27. reversed: this.reversed
  28. }, style: barStyles })), this.text ? h("div", { class: "text" }, this.text) : null));
  29. }
  30. static get is() { return "calcite-progress"; }
  31. static get encapsulation() { return "shadow"; }
  32. static get originalStyleUrls() {
  33. return {
  34. "$": ["progress.scss"]
  35. };
  36. }
  37. static get styleUrls() {
  38. return {
  39. "$": ["progress.css"]
  40. };
  41. }
  42. static get properties() {
  43. return {
  44. "type": {
  45. "type": "string",
  46. "mutable": false,
  47. "complexType": {
  48. "original": "\"indeterminate\" | \"determinate\"",
  49. "resolved": "\"determinate\" | \"indeterminate\"",
  50. "references": {}
  51. },
  52. "required": false,
  53. "optional": false,
  54. "docs": {
  55. "tags": [],
  56. "text": "Specifies the component type.\n\nUse `\"indeterminate\"` if finding actual progress value is impossible."
  57. },
  58. "attribute": "type",
  59. "reflect": true,
  60. "defaultValue": "\"determinate\""
  61. },
  62. "value": {
  63. "type": "number",
  64. "mutable": false,
  65. "complexType": {
  66. "original": "number",
  67. "resolved": "number",
  68. "references": {}
  69. },
  70. "required": false,
  71. "optional": false,
  72. "docs": {
  73. "tags": [],
  74. "text": "The component's progress value, with a range of 0.0 - 1.0."
  75. },
  76. "attribute": "value",
  77. "reflect": false,
  78. "defaultValue": "0"
  79. },
  80. "label": {
  81. "type": "string",
  82. "mutable": false,
  83. "complexType": {
  84. "original": "string",
  85. "resolved": "string",
  86. "references": {}
  87. },
  88. "required": false,
  89. "optional": false,
  90. "docs": {
  91. "tags": [],
  92. "text": "Accessible name for the component."
  93. },
  94. "attribute": "label",
  95. "reflect": false
  96. },
  97. "text": {
  98. "type": "string",
  99. "mutable": false,
  100. "complexType": {
  101. "original": "string",
  102. "resolved": "string",
  103. "references": {}
  104. },
  105. "required": false,
  106. "optional": false,
  107. "docs": {
  108. "tags": [],
  109. "text": "Text that displays under the component's indicator."
  110. },
  111. "attribute": "text",
  112. "reflect": false
  113. },
  114. "reversed": {
  115. "type": "boolean",
  116. "mutable": false,
  117. "complexType": {
  118. "original": "boolean",
  119. "resolved": "boolean",
  120. "references": {}
  121. },
  122. "required": false,
  123. "optional": false,
  124. "docs": {
  125. "tags": [],
  126. "text": "When `true` and for `\"indeterminate\"` progress bars, reverses the animation direction."
  127. },
  128. "attribute": "reversed",
  129. "reflect": true,
  130. "defaultValue": "false"
  131. }
  132. };
  133. }
  134. static get elementRef() { return "el"; }
  135. }