calcite-action-pad.entry.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133
  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 { t as toggleChildActionText, E as ExpandToggle } from './ExpandToggle-a4a9eace.js';
  8. import { f as focusElement, g as getSlotted } from './dom-8f0a9ff2.js';
  9. import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-a3e8c63a.js';
  10. import './resources-9a59d78c.js';
  11. import './resources-a75141ea.js';
  12. import './resources-9c476cb6.js';
  13. import './guid-9f15e57a.js';
  14. import './observers-9f44e9b3.js';
  15. const CSS = {
  16. actionGroupBottom: "action-group--bottom",
  17. container: "container"
  18. };
  19. const TEXT = {
  20. expand: "Expand",
  21. collapse: "Collapse"
  22. };
  23. const SLOTS = {
  24. expandTooltip: "expand-tooltip"
  25. };
  26. const actionPadCss = "@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{display:block}@keyframes in{0%{opacity:0}100%{opacity:1}}:host{animation:in var(--calcite-internal-animation-timing-slow) ease-in-out;border-radius:0.125rem;--calcite-action-pad-expanded-max-width:auto;background:transparent}:host([expanded][layout=vertical]) .container{max-inline-size:var(--calcite-action-pad-expanded-max-width)}::slotted(calcite-action-group){border-width:0px;border-block-end-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);padding-block:0px}.container{display:inline-flex;flex-direction:column;overflow-y:auto;border-radius:0.25rem;background-color:var(--calcite-ui-background);--tw-shadow:0 6px 20px -4px rgba(0, 0, 0, 0.1), 0 4px 12px -2px rgba(0, 0, 0, 0.08);--tw-shadow-colored:0 6px 20px -4px var(--tw-shadow-color), 0 4px 12px -2px var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}.action-group--bottom{flex-grow:1;justify-content:flex-end;padding-block-end:0px}:host([layout=horizontal]) .container{flex-direction:row}:host([layout=horizontal]) .container .action-group--bottom{padding:0px}:host([layout=horizontal]) .container ::slotted(calcite-action-group){border-width:0px;padding:0px;border-inline-end-width:1px}::slotted(calcite-action-group:last-child){border-block-end-width:0px}";
  27. const ActionPad = class {
  28. constructor(hostRef) {
  29. registerInstance(this, hostRef);
  30. this.calciteActionPadToggle = createEvent(this, "calciteActionPadToggle", 6);
  31. // --------------------------------------------------------------------------
  32. //
  33. // Properties
  34. //
  35. // --------------------------------------------------------------------------
  36. /**
  37. * When `true`, the expand-toggling behavior is disabled.
  38. */
  39. this.expandDisabled = false;
  40. /**
  41. * When `true`, the component is expanded.
  42. */
  43. this.expanded = false;
  44. /**
  45. * Indicates the layout of the component.
  46. */
  47. this.layout = "vertical";
  48. // --------------------------------------------------------------------------
  49. //
  50. // Private Methods
  51. //
  52. // --------------------------------------------------------------------------
  53. this.actionMenuOpenChangeHandler = (event) => {
  54. if (event.detail) {
  55. const composedPath = event.composedPath();
  56. Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
  57. if (!composedPath.includes(group)) {
  58. group.menuOpen = false;
  59. }
  60. });
  61. }
  62. };
  63. this.toggleExpand = () => {
  64. this.expanded = !this.expanded;
  65. this.calciteActionPadToggle.emit();
  66. };
  67. this.setExpandToggleRef = (el) => {
  68. this.expandToggleEl = el;
  69. };
  70. }
  71. expandedHandler(expanded) {
  72. toggleChildActionText({ parent: this.el, expanded });
  73. }
  74. // --------------------------------------------------------------------------
  75. //
  76. // Lifecycle
  77. //
  78. // --------------------------------------------------------------------------
  79. connectedCallback() {
  80. connectConditionalSlotComponent(this);
  81. }
  82. disconnectedCallback() {
  83. disconnectConditionalSlotComponent(this);
  84. }
  85. componentWillLoad() {
  86. const { el, expanded } = this;
  87. toggleChildActionText({ parent: el, expanded });
  88. }
  89. // --------------------------------------------------------------------------
  90. //
  91. // Methods
  92. //
  93. // --------------------------------------------------------------------------
  94. /**
  95. * Sets focus on the component.
  96. *
  97. * @param focusId
  98. */
  99. async setFocus(focusId) {
  100. var _a;
  101. if (focusId === "expand-toggle") {
  102. await focusElement(this.expandToggleEl);
  103. return;
  104. }
  105. (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
  106. }
  107. // --------------------------------------------------------------------------
  108. //
  109. // Component Methods
  110. //
  111. // --------------------------------------------------------------------------
  112. renderBottomActionGroup() {
  113. const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale, layout } = this;
  114. const tooltip = getSlotted(el, SLOTS.expandTooltip);
  115. const expandLabel = intlExpand || TEXT.expand;
  116. const collapseLabel = intlCollapse || TEXT.collapse;
  117. const expandToggleNode = !expandDisabled ? (h(ExpandToggle, { el: el, expanded: expanded, intlCollapse: collapseLabel, intlExpand: expandLabel, position: position, ref: this.setExpandToggleRef, scale: scale, toggle: toggleExpand, tooltip: tooltip })) : null;
  118. return expandToggleNode ? (h("calcite-action-group", { class: CSS.actionGroupBottom, layout: layout, scale: scale }, h("slot", { name: SLOTS.expandTooltip }), expandToggleNode)) : null;
  119. }
  120. render() {
  121. return (h(Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, h("div", { class: CSS.container }, h("slot", null), this.renderBottomActionGroup())));
  122. }
  123. get el() { return getElement(this); }
  124. static get watchers() { return {
  125. "expanded": ["expandedHandler"]
  126. }; }
  127. };
  128. ActionPad.style = actionPadCss;
  129. export { ActionPad as calcite_action_pad };