calcite-flow-item.js 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238
  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, createEvent, h, Host } from '@stencil/core/internal/client/index.js';
  7. import { c as getElementDir } from './dom.js';
  8. import { S as SLOTS$1, d as defineCustomElement$5 } from './panel.js';
  9. import { u as updateHostInteraction } from './interactive.js';
  10. import { d as defineCustomElement$9 } from './action.js';
  11. import { d as defineCustomElement$8 } from './action-menu.js';
  12. import { d as defineCustomElement$7 } from './icon.js';
  13. import { d as defineCustomElement$6 } from './loader.js';
  14. import { d as defineCustomElement$4 } from './popover.js';
  15. import { d as defineCustomElement$3 } from './scrim.js';
  16. import { d as defineCustomElement$2 } from './tooltip.js';
  17. const CSS = {
  18. backButton: "back-button"
  19. };
  20. const ICONS = {
  21. backLeft: "chevron-left",
  22. backRight: "chevron-right"
  23. };
  24. const TEXT = {
  25. back: "Back"
  26. };
  27. const SLOTS = {
  28. headerActionsStart: "header-actions-start",
  29. headerActionsEnd: "header-actions-end",
  30. headerMenuActions: "header-menu-actions",
  31. headerContent: "header-content",
  32. fab: "fab",
  33. footer: "footer",
  34. footerActions: "footer-actions"
  35. };
  36. const flowItemCss = "@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}}:host{box-sizing:border-box;background-color:var(--calcite-ui-foreground-1);color:var(--calcite-ui-text-2);font-size:var(--calcite-font-size--1)}:host *{box-sizing:border-box}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{position:relative;display:flex;inline-size:100%;flex:1 1 auto;overflow:hidden}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.back-button{border-width:0px;border-style:solid;border-color:var(--calcite-ui-border-3);border-inline-end-width:1px}";
  37. const FlowItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
  38. constructor() {
  39. super();
  40. this.__registerHost();
  41. this.__attachShadow();
  42. this.calciteFlowItemBack = createEvent(this, "calciteFlowItemBack", 6);
  43. this.calciteFlowItemBackClick = createEvent(this, "calciteFlowItemBackClick", 6);
  44. this.calciteFlowItemScroll = createEvent(this, "calciteFlowItemScroll", 6);
  45. this.calciteFlowItemClose = createEvent(this, "calciteFlowItemClose", 6);
  46. // --------------------------------------------------------------------------
  47. //
  48. // Properties
  49. //
  50. // --------------------------------------------------------------------------
  51. /** When true, displays a close button in the trailing side of the header */
  52. this.closable = false;
  53. /** When true, flow-item will be hidden */
  54. this.closed = false;
  55. /**
  56. * When true, interaction is prevented and the component is displayed with lower opacity.
  57. */
  58. this.disabled = false;
  59. /**
  60. * When true, a busy indicator is displayed.
  61. */
  62. this.loading = false;
  63. /**
  64. * When true, the action menu items in the `header-menu-actions` slot are open.
  65. */
  66. this.menuOpen = false;
  67. /**
  68. * When true, displays a back button in the header.
  69. */
  70. this.showBackButton = false;
  71. // --------------------------------------------------------------------------
  72. //
  73. // Private Methods
  74. //
  75. // --------------------------------------------------------------------------
  76. this.handlePanelScroll = (event) => {
  77. event.stopPropagation();
  78. this.calciteFlowItemScroll.emit();
  79. };
  80. this.handlePanelClose = (event) => {
  81. event.stopPropagation();
  82. this.calciteFlowItemClose.emit();
  83. };
  84. this.backButtonClick = () => {
  85. this.calciteFlowItemBackClick.emit();
  86. this.calciteFlowItemBack.emit();
  87. };
  88. this.setBackRef = (node) => {
  89. this.backButtonEl = node;
  90. };
  91. this.setContainerRef = (node) => {
  92. this.containerEl = node;
  93. };
  94. this.getBackLabel = () => {
  95. return this.intlBack || TEXT.back;
  96. };
  97. }
  98. //--------------------------------------------------------------------------
  99. //
  100. // Lifecycle
  101. //
  102. //--------------------------------------------------------------------------
  103. componentDidRender() {
  104. updateHostInteraction(this);
  105. }
  106. // --------------------------------------------------------------------------
  107. //
  108. // Methods
  109. //
  110. // --------------------------------------------------------------------------
  111. /**
  112. * Sets focus on the component.
  113. */
  114. async setFocus() {
  115. const { backButtonEl, containerEl } = this;
  116. if (backButtonEl) {
  117. backButtonEl.setFocus();
  118. return;
  119. }
  120. containerEl === null || containerEl === void 0 ? void 0 : containerEl.setFocus();
  121. }
  122. /**
  123. * Scrolls the component's content to a specified set of coordinates.
  124. *
  125. * @example
  126. * myCalciteFlowItem.scrollContentTo({
  127. * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.
  128. * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element
  129. * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).
  130. * });
  131. * @param options
  132. */
  133. async scrollContentTo(options) {
  134. var _a;
  135. await ((_a = this.containerEl) === null || _a === void 0 ? void 0 : _a.scrollContentTo(options));
  136. }
  137. // --------------------------------------------------------------------------
  138. //
  139. // Render Methods
  140. //
  141. // --------------------------------------------------------------------------
  142. renderBackButton() {
  143. const { el } = this;
  144. const rtl = getElementDir(el) === "rtl";
  145. const { showBackButton, backButtonClick } = this;
  146. const label = this.getBackLabel();
  147. const icon = rtl ? ICONS.backRight : ICONS.backLeft;
  148. return showBackButton ? (h("calcite-action", { "aria-label": label, class: CSS.backButton, icon: icon, key: "flow-back-button", onClick: backButtonClick, ref: this.setBackRef, scale: "s", slot: "header-actions-start", text: label })) : null;
  149. }
  150. render() {
  151. const { closable, closed, description, disabled, heading, headingLevel, heightScale, intlBack, intlClose, intlOptions, loading, menuOpen, widthScale, backButtonEl } = this;
  152. const label = this.getBackLabel();
  153. return (h(Host, null, h("calcite-panel", { closable: closable, closed: closed, description: description, disabled: disabled, heading: heading, headingLevel: headingLevel, heightScale: heightScale, intlBack: intlBack, intlClose: intlClose, intlOptions: intlOptions, loading: loading, menuOpen: menuOpen, onCalcitePanelClose: this.handlePanelClose, onCalcitePanelScroll: this.handlePanelScroll, ref: this.setContainerRef, widthScale: widthScale }, this.renderBackButton(), h("slot", { name: SLOTS.headerActionsStart, slot: SLOTS$1.headerActionsStart }), h("slot", { name: SLOTS.headerActionsEnd, slot: SLOTS$1.headerActionsEnd }), h("slot", { name: SLOTS.headerContent, slot: SLOTS$1.headerContent }), h("slot", { name: SLOTS.headerMenuActions, slot: SLOTS$1.headerMenuActions }), h("slot", { name: SLOTS.fab, slot: SLOTS$1.fab }), h("slot", { name: SLOTS.footerActions, slot: SLOTS$1.footerActions }), h("slot", { name: SLOTS.footer, slot: SLOTS$1.footer }), h("slot", null)), backButtonEl ? (h("calcite-tooltip", { label: label, placement: "auto", referenceElement: backButtonEl }, label)) : null));
  154. }
  155. get el() { return this; }
  156. static get style() { return flowItemCss; }
  157. }, [1, "calcite-flow-item", {
  158. "closable": [1540],
  159. "closed": [1540],
  160. "beforeBack": [16],
  161. "description": [1],
  162. "disabled": [516],
  163. "heading": [1],
  164. "headingLevel": [514, "heading-level"],
  165. "heightScale": [513, "height-scale"],
  166. "intlBack": [1, "intl-back"],
  167. "intlClose": [1, "intl-close"],
  168. "intlOptions": [1, "intl-options"],
  169. "loading": [516],
  170. "menuOpen": [516, "menu-open"],
  171. "showBackButton": [516, "show-back-button"],
  172. "widthScale": [513, "width-scale"],
  173. "backButtonEl": [32],
  174. "setFocus": [64],
  175. "scrollContentTo": [64]
  176. }]);
  177. function defineCustomElement$1() {
  178. if (typeof customElements === "undefined") {
  179. return;
  180. }
  181. const components = ["calcite-flow-item", "calcite-action", "calcite-action-menu", "calcite-icon", "calcite-loader", "calcite-panel", "calcite-popover", "calcite-scrim", "calcite-tooltip"];
  182. components.forEach(tagName => { switch (tagName) {
  183. case "calcite-flow-item":
  184. if (!customElements.get(tagName)) {
  185. customElements.define(tagName, FlowItem);
  186. }
  187. break;
  188. case "calcite-action":
  189. if (!customElements.get(tagName)) {
  190. defineCustomElement$9();
  191. }
  192. break;
  193. case "calcite-action-menu":
  194. if (!customElements.get(tagName)) {
  195. defineCustomElement$8();
  196. }
  197. break;
  198. case "calcite-icon":
  199. if (!customElements.get(tagName)) {
  200. defineCustomElement$7();
  201. }
  202. break;
  203. case "calcite-loader":
  204. if (!customElements.get(tagName)) {
  205. defineCustomElement$6();
  206. }
  207. break;
  208. case "calcite-panel":
  209. if (!customElements.get(tagName)) {
  210. defineCustomElement$5();
  211. }
  212. break;
  213. case "calcite-popover":
  214. if (!customElements.get(tagName)) {
  215. defineCustomElement$4();
  216. }
  217. break;
  218. case "calcite-scrim":
  219. if (!customElements.get(tagName)) {
  220. defineCustomElement$3();
  221. }
  222. break;
  223. case "calcite-tooltip":
  224. if (!customElements.get(tagName)) {
  225. defineCustomElement$2();
  226. }
  227. break;
  228. } });
  229. }
  230. defineCustomElement$1();
  231. const CalciteFlowItem = FlowItem;
  232. const defineCustomElement = defineCustomElement$1;
  233. export { CalciteFlowItem, defineCustomElement };