calcite-action-pad.cjs.entry.js 7.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  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 ExpandToggle = require('./ExpandToggle-e41acdfc.js');
  10. const dom = require('./dom-2ec8c9ed.js');
  11. const conditionalSlot = require('./conditionalSlot-ef852d9d.js');
  12. require('./resources-bd2202e9.js');
  13. require('./resources-199140b3.js');
  14. require('./resources-b5a5f8a7.js');
  15. require('./guid-f4f03a7a.js');
  16. require('./observers-5706326b.js');
  17. const CSS = {
  18. actionGroupBottom: "action-group--bottom",
  19. container: "container"
  20. };
  21. const TEXT = {
  22. expand: "Expand",
  23. collapse: "Collapse"
  24. };
  25. const SLOTS = {
  26. expandTooltip: "expand-tooltip"
  27. };
  28. 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}";
  29. const ActionPad = class {
  30. constructor(hostRef) {
  31. index.registerInstance(this, hostRef);
  32. this.calciteActionPadToggle = index.createEvent(this, "calciteActionPadToggle", 6);
  33. // --------------------------------------------------------------------------
  34. //
  35. // Properties
  36. //
  37. // --------------------------------------------------------------------------
  38. /**
  39. * When `true`, the expand-toggling behavior is disabled.
  40. */
  41. this.expandDisabled = false;
  42. /**
  43. * When `true`, the component is expanded.
  44. */
  45. this.expanded = false;
  46. /**
  47. * Indicates the layout of the component.
  48. */
  49. this.layout = "vertical";
  50. // --------------------------------------------------------------------------
  51. //
  52. // Private Methods
  53. //
  54. // --------------------------------------------------------------------------
  55. this.actionMenuOpenChangeHandler = (event) => {
  56. if (event.detail) {
  57. const composedPath = event.composedPath();
  58. Array.from(this.el.querySelectorAll("calcite-action-group")).forEach((group) => {
  59. if (!composedPath.includes(group)) {
  60. group.menuOpen = false;
  61. }
  62. });
  63. }
  64. };
  65. this.toggleExpand = () => {
  66. this.expanded = !this.expanded;
  67. this.calciteActionPadToggle.emit();
  68. };
  69. this.setExpandToggleRef = (el) => {
  70. this.expandToggleEl = el;
  71. };
  72. }
  73. expandedHandler(expanded) {
  74. ExpandToggle.toggleChildActionText({ parent: this.el, expanded });
  75. }
  76. // --------------------------------------------------------------------------
  77. //
  78. // Lifecycle
  79. //
  80. // --------------------------------------------------------------------------
  81. connectedCallback() {
  82. conditionalSlot.connectConditionalSlotComponent(this);
  83. }
  84. disconnectedCallback() {
  85. conditionalSlot.disconnectConditionalSlotComponent(this);
  86. }
  87. componentWillLoad() {
  88. const { el, expanded } = this;
  89. ExpandToggle.toggleChildActionText({ parent: el, expanded });
  90. }
  91. // --------------------------------------------------------------------------
  92. //
  93. // Methods
  94. //
  95. // --------------------------------------------------------------------------
  96. /**
  97. * Sets focus on the component.
  98. *
  99. * @param focusId
  100. */
  101. async setFocus(focusId) {
  102. var _a;
  103. if (focusId === "expand-toggle") {
  104. await dom.focusElement(this.expandToggleEl);
  105. return;
  106. }
  107. (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
  108. }
  109. // --------------------------------------------------------------------------
  110. //
  111. // Component Methods
  112. //
  113. // --------------------------------------------------------------------------
  114. renderBottomActionGroup() {
  115. const { expanded, expandDisabled, intlExpand, intlCollapse, el, position, toggleExpand, scale, layout } = this;
  116. const tooltip = dom.getSlotted(el, SLOTS.expandTooltip);
  117. const expandLabel = intlExpand || TEXT.expand;
  118. const collapseLabel = intlCollapse || TEXT.collapse;
  119. const expandToggleNode = !expandDisabled ? (index.h(ExpandToggle.ExpandToggle, { el: el, expanded: expanded, intlCollapse: collapseLabel, intlExpand: expandLabel, position: position, ref: this.setExpandToggleRef, scale: scale, toggle: toggleExpand, tooltip: tooltip })) : null;
  120. return expandToggleNode ? (index.h("calcite-action-group", { class: CSS.actionGroupBottom, layout: layout, scale: scale }, index.h("slot", { name: SLOTS.expandTooltip }), expandToggleNode)) : null;
  121. }
  122. render() {
  123. return (index.h(index.Host, { onCalciteActionMenuOpenChange: this.actionMenuOpenChangeHandler }, index.h("div", { class: CSS.container }, index.h("slot", null), this.renderBottomActionGroup())));
  124. }
  125. get el() { return index.getElement(this); }
  126. static get watchers() { return {
  127. "expanded": ["expandedHandler"]
  128. }; }
  129. };
  130. ActionPad.style = actionPadCss;
  131. exports.calcite_action_pad = ActionPad;