calcite-action-group.entry.js 5.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  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, h, F as Fragment, g as getElement } from './index-1f9b54dc.js';
  7. import { S as SLOTS, I as ICONS, T as TEXT } from './resources-a75141ea.js';
  8. import { g as getSlotted } from './dom-8f0a9ff2.js';
  9. import { S as SLOTS$1 } from './resources-9a59d78c.js';
  10. import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot-a3e8c63a.js';
  11. import './resources-9c476cb6.js';
  12. import './guid-9f15e57a.js';
  13. import './observers-9f44e9b3.js';
  14. const actionGroupCss = "@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:flex;flex-direction:column;padding:0px;--calcite-action-group-columns:3}:host([columns=\"1\"]){--calcite-action-group-columns:1}:host([columns=\"2\"]){--calcite-action-group-columns:2}:host([columns=\"3\"]){--calcite-action-group-columns:3}:host([columns=\"4\"]){--calcite-action-group-columns:4}:host([columns=\"5\"]){--calcite-action-group-columns:5}:host([columns=\"6\"]){--calcite-action-group-columns:6}:host(:first-child){padding-block-start:0px}:host([layout=horizontal]){flex-direction:row}:host([layout=grid]){display:grid;place-content:stretch;gap:1px;background-color:var(--calcite-ui-background);padding:1px;grid-template-columns:repeat(var(--calcite-action-group-columns), auto)}";
  15. const ActionGroup = class {
  16. constructor(hostRef) {
  17. registerInstance(this, hostRef);
  18. // --------------------------------------------------------------------------
  19. //
  20. // Properties
  21. //
  22. // --------------------------------------------------------------------------
  23. /**
  24. * When `true`, the component is expanded.
  25. */
  26. this.expanded = false;
  27. /**
  28. * Indicates the layout of the component.
  29. */
  30. this.layout = "vertical";
  31. /**
  32. * When `true`, the `calcite-action-menu` is open.
  33. */
  34. this.menuOpen = false;
  35. // --------------------------------------------------------------------------
  36. //
  37. // Private Methods
  38. //
  39. // --------------------------------------------------------------------------
  40. this.setMenuOpen = (event) => {
  41. this.menuOpen = !!event.detail;
  42. };
  43. }
  44. expandedHandler() {
  45. this.menuOpen = false;
  46. }
  47. // --------------------------------------------------------------------------
  48. //
  49. // Lifecycle
  50. //
  51. // --------------------------------------------------------------------------
  52. connectedCallback() {
  53. connectConditionalSlotComponent(this);
  54. }
  55. disconnectedCallback() {
  56. disconnectConditionalSlotComponent(this);
  57. }
  58. // --------------------------------------------------------------------------
  59. //
  60. // Component Methods
  61. //
  62. // --------------------------------------------------------------------------
  63. renderTooltip() {
  64. const { el } = this;
  65. const hasTooltip = getSlotted(el, SLOTS.menuTooltip);
  66. return hasTooltip ? h("slot", { name: SLOTS.menuTooltip, slot: SLOTS$1.tooltip }) : null;
  67. }
  68. renderMenu() {
  69. const { el, expanded, intlMore, menuOpen, scale, layout } = this;
  70. const hasMenuItems = getSlotted(el, SLOTS.menuActions);
  71. return hasMenuItems ? (h("calcite-action-menu", { expanded: expanded, flipPlacements: ["left", "right"], label: intlMore || TEXT.more, onCalciteActionMenuOpenChange: this.setMenuOpen, open: menuOpen, placement: layout === "horizontal" ? "bottom-leading" : "leading-start", scale: scale }, h("calcite-action", { icon: ICONS.menu, scale: scale, slot: SLOTS$1.trigger, text: intlMore || TEXT.more, textEnabled: expanded }), h("slot", { name: SLOTS.menuActions }), this.renderTooltip())) : null;
  72. }
  73. render() {
  74. return (h(Fragment, null, h("slot", null), this.renderMenu()));
  75. }
  76. get el() { return getElement(this); }
  77. static get watchers() { return {
  78. "expanded": ["expandedHandler"]
  79. }; }
  80. };
  81. ActionGroup.style = actionGroupCss;
  82. export { ActionGroup as calcite_action_group };