calcite-flow-item.cjs.entry.js 8.4 KB

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