calcite-flow-item.entry.js 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  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 { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-1f9b54dc.js';
  7. import { a as getElementDir } from './dom-8f0a9ff2.js';
  8. import { S as SLOTS$1 } from './resources-ca31b4fd.js';
  9. import { u as updateHostInteraction } from './interactive-5db230e8.js';
  10. import './resources-9c476cb6.js';
  11. import './guid-9f15e57a.js';
  12. const CSS = {
  13. backButton: "back-button"
  14. };
  15. const ICONS = {
  16. backLeft: "chevron-left",
  17. backRight: "chevron-right"
  18. };
  19. const TEXT = {
  20. back: "Back"
  21. };
  22. const SLOTS = {
  23. headerActionsStart: "header-actions-start",
  24. headerActionsEnd: "header-actions-end",
  25. headerMenuActions: "header-menu-actions",
  26. headerContent: "header-content",
  27. fab: "fab",
  28. footer: "footer",
  29. footerActions: "footer-actions"
  30. };
  31. 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}";
  32. const FlowItem = class {
  33. constructor(hostRef) {
  34. registerInstance(this, hostRef);
  35. this.calciteFlowItemBack = createEvent(this, "calciteFlowItemBack", 6);
  36. this.calciteFlowItemBackClick = createEvent(this, "calciteFlowItemBackClick", 6);
  37. this.calciteFlowItemScroll = createEvent(this, "calciteFlowItemScroll", 6);
  38. this.calciteFlowItemClose = createEvent(this, "calciteFlowItemClose", 6);
  39. // --------------------------------------------------------------------------
  40. //
  41. // Properties
  42. //
  43. // --------------------------------------------------------------------------
  44. /** When true, displays a close button in the trailing side of the header */
  45. this.closable = false;
  46. /** When true, flow-item will be hidden */
  47. this.closed = false;
  48. /**
  49. * When true, interaction is prevented and the component is displayed with lower opacity.
  50. */
  51. this.disabled = false;
  52. /**
  53. * When true, a busy indicator is displayed.
  54. */
  55. this.loading = false;
  56. /**
  57. * When true, the action menu items in the `header-menu-actions` slot are open.
  58. */
  59. this.menuOpen = false;
  60. /**
  61. * When true, displays a back button in the header.
  62. */
  63. this.showBackButton = false;
  64. // --------------------------------------------------------------------------
  65. //
  66. // Private Methods
  67. //
  68. // --------------------------------------------------------------------------
  69. this.handlePanelScroll = (event) => {
  70. event.stopPropagation();
  71. this.calciteFlowItemScroll.emit();
  72. };
  73. this.handlePanelClose = (event) => {
  74. event.stopPropagation();
  75. this.calciteFlowItemClose.emit();
  76. };
  77. this.backButtonClick = () => {
  78. this.calciteFlowItemBackClick.emit();
  79. this.calciteFlowItemBack.emit();
  80. };
  81. this.setBackRef = (node) => {
  82. this.backButtonEl = node;
  83. };
  84. this.setContainerRef = (node) => {
  85. this.containerEl = node;
  86. };
  87. this.getBackLabel = () => {
  88. return this.intlBack || TEXT.back;
  89. };
  90. }
  91. //--------------------------------------------------------------------------
  92. //
  93. // Lifecycle
  94. //
  95. //--------------------------------------------------------------------------
  96. componentDidRender() {
  97. updateHostInteraction(this);
  98. }
  99. // --------------------------------------------------------------------------
  100. //
  101. // Methods
  102. //
  103. // --------------------------------------------------------------------------
  104. /**
  105. * Sets focus on the component.
  106. */
  107. async setFocus() {
  108. const { backButtonEl, containerEl } = this;
  109. if (backButtonEl) {
  110. backButtonEl.setFocus();
  111. return;
  112. }
  113. containerEl === null || containerEl === void 0 ? void 0 : containerEl.setFocus();
  114. }
  115. /**
  116. * Scrolls the component's content to a specified set of coordinates.
  117. *
  118. * @example
  119. * myCalciteFlowItem.scrollContentTo({
  120. * left: 0, // Specifies the number of pixels along the X axis to scroll the window or element.
  121. * top: 0, // Specifies the number of pixels along the Y axis to scroll the window or element
  122. * behavior: "auto" // Specifies whether the scrolling should animate smoothly (smooth), or happen instantly in a single jump (auto, the default value).
  123. * });
  124. * @param options
  125. */
  126. async scrollContentTo(options) {
  127. var _a;
  128. await ((_a = this.containerEl) === null || _a === void 0 ? void 0 : _a.scrollContentTo(options));
  129. }
  130. // --------------------------------------------------------------------------
  131. //
  132. // Render Methods
  133. //
  134. // --------------------------------------------------------------------------
  135. renderBackButton() {
  136. const { el } = this;
  137. const rtl = getElementDir(el) === "rtl";
  138. const { showBackButton, backButtonClick } = this;
  139. const label = this.getBackLabel();
  140. const icon = rtl ? ICONS.backRight : ICONS.backLeft;
  141. 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;
  142. }
  143. render() {
  144. const { closable, closed, description, disabled, heading, headingLevel, heightScale, intlBack, intlClose, intlOptions, loading, menuOpen, widthScale, backButtonEl } = this;
  145. const label = this.getBackLabel();
  146. 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));
  147. }
  148. get el() { return getElement(this); }
  149. };
  150. FlowItem.style = flowItemCss;
  151. export { FlowItem as calcite_flow_item };