progress.js 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960
  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 { proxyCustomElement, HTMLElement, h } from '@stencil/core/internal/client/index.js';
  7. const progressCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{position:relative;display:block;inline-size:100%}.track,.bar{position:absolute;inset-block-start:0px;block-size:2px}.track{z-index:1;inline-size:100%;overflow:hidden;background:var(--calcite-ui-border-3)}.bar{z-index:1;background-color:var(--calcite-ui-brand)}@media (forced-colors: active){.track{background-color:highlightText}.bar{background-color:linkText}}.indeterminate{inline-size:20%;animation:looping-progress-bar-ani calc(var(--calcite-internal-animation-timing-medium) * 11) linear infinite}.reversed{animation-direction:reverse}.text{padding-inline:0px;padding-block:1rem 0px;text-align:center;font-size:var(--calcite-font-size--2);line-height:1rem;font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-2)}@keyframes looping-progress-bar-ani{0%{transform:translate3d(-100%, 0, 0)}50%{inline-size:40%}100%{transform:translate3d(600%, 0, 0)}}";
  8. const Progress = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  9. constructor() {
  10. super();
  11. this.__registerHost();
  12. this.__attachShadow();
  13. /**
  14. * Specifies the component type.
  15. *
  16. * Use `"indeterminate"` if finding actual progress value is impossible.
  17. *
  18. */
  19. this.type = "determinate";
  20. /** The component's progress value, with a range of 0.0 - 1.0. */
  21. this.value = 0;
  22. /** When `true` and for `"indeterminate"` progress bars, reverses the animation direction. */
  23. this.reversed = false;
  24. }
  25. render() {
  26. const isDeterminate = this.type === "determinate";
  27. const barStyles = isDeterminate ? { width: `${this.value * 100}%` } : {};
  28. 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: {
  29. bar: true,
  30. indeterminate: this.type === "indeterminate",
  31. reversed: this.reversed
  32. }, style: barStyles })), this.text ? h("div", { class: "text" }, this.text) : null));
  33. }
  34. get el() { return this; }
  35. static get style() { return progressCss; }
  36. }, [1, "calcite-progress", {
  37. "type": [513],
  38. "value": [2],
  39. "label": [1],
  40. "text": [1],
  41. "reversed": [516]
  42. }]);
  43. function defineCustomElement() {
  44. if (typeof customElements === "undefined") {
  45. return;
  46. }
  47. const components = ["calcite-progress"];
  48. components.forEach(tagName => { switch (tagName) {
  49. case "calcite-progress":
  50. if (!customElements.get(tagName)) {
  51. customElements.define(tagName, Progress);
  52. }
  53. break;
  54. } });
  55. }
  56. defineCustomElement();
  57. export { Progress as P, defineCustomElement as d };