calcite-action-group.cjs.entry.js 5.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889
  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 resources = require('./resources-199140b3.js');
  10. const dom = require('./dom-2ec8c9ed.js');
  11. const resources$1 = require('./resources-bd2202e9.js');
  12. const conditionalSlot = require('./conditionalSlot-ef852d9d.js');
  13. require('./resources-b5a5f8a7.js');
  14. require('./guid-f4f03a7a.js');
  15. require('./observers-5706326b.js');
  16. 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)}";
  17. const ActionGroup = class {
  18. constructor(hostRef) {
  19. index.registerInstance(this, hostRef);
  20. // --------------------------------------------------------------------------
  21. //
  22. // Properties
  23. //
  24. // --------------------------------------------------------------------------
  25. /**
  26. * When `true`, the component is expanded.
  27. */
  28. this.expanded = false;
  29. /**
  30. * Indicates the layout of the component.
  31. */
  32. this.layout = "vertical";
  33. /**
  34. * When `true`, the `calcite-action-menu` is open.
  35. */
  36. this.menuOpen = false;
  37. // --------------------------------------------------------------------------
  38. //
  39. // Private Methods
  40. //
  41. // --------------------------------------------------------------------------
  42. this.setMenuOpen = (event) => {
  43. this.menuOpen = !!event.detail;
  44. };
  45. }
  46. expandedHandler() {
  47. this.menuOpen = false;
  48. }
  49. // --------------------------------------------------------------------------
  50. //
  51. // Lifecycle
  52. //
  53. // --------------------------------------------------------------------------
  54. connectedCallback() {
  55. conditionalSlot.connectConditionalSlotComponent(this);
  56. }
  57. disconnectedCallback() {
  58. conditionalSlot.disconnectConditionalSlotComponent(this);
  59. }
  60. // --------------------------------------------------------------------------
  61. //
  62. // Component Methods
  63. //
  64. // --------------------------------------------------------------------------
  65. renderTooltip() {
  66. const { el } = this;
  67. const hasTooltip = dom.getSlotted(el, resources.SLOTS.menuTooltip);
  68. return hasTooltip ? index.h("slot", { name: resources.SLOTS.menuTooltip, slot: resources$1.SLOTS.tooltip }) : null;
  69. }
  70. renderMenu() {
  71. const { el, expanded, intlMore, menuOpen, scale, layout } = this;
  72. const hasMenuItems = dom.getSlotted(el, resources.SLOTS.menuActions);
  73. return hasMenuItems ? (index.h("calcite-action-menu", { expanded: expanded, flipPlacements: ["left", "right"], label: intlMore || resources.TEXT.more, onCalciteActionMenuOpenChange: this.setMenuOpen, open: menuOpen, placement: layout === "horizontal" ? "bottom-leading" : "leading-start", scale: scale }, index.h("calcite-action", { icon: resources.ICONS.menu, scale: scale, slot: resources$1.SLOTS.trigger, text: intlMore || resources.TEXT.more, textEnabled: expanded }), index.h("slot", { name: resources.SLOTS.menuActions }), this.renderTooltip())) : null;
  74. }
  75. render() {
  76. return (index.h(index.Fragment, null, index.h("slot", null), this.renderMenu()));
  77. }
  78. get el() { return index.getElement(this); }
  79. static get watchers() { return {
  80. "expanded": ["expandedHandler"]
  81. }; }
  82. };
  83. ActionGroup.style = actionGroupCss;
  84. exports.calcite_action_group = ActionGroup;