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

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  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.82
  5. */
  6. 'use strict';
  7. Object.defineProperty(exports, '__esModule', { value: true });
  8. const index = require('./index-5c65e149.js');
  9. const resources = require('./resources-5da94c46.js');
  10. const dom = require('./dom-9ac0341c.js');
  11. const resources$1 = require('./resources-1a214670.js');
  12. const conditionalSlot = require('./conditionalSlot-ba5cd797.js');
  13. require('./guid-8b6d6cb4.js');
  14. require('./observers-d9fdf006.js');
  15. const actionGroupCss = "@-webkit-keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in{0%{opacity:0}100%{opacity:1}}@-webkit-keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-down{0%{opacity:0;-webkit-transform:translate3D(0, -5px, 0);transform:translate3D(0, -5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;-webkit-transform:translate3D(0, 5px, 0);transform:translate3D(0, 5px, 0)}100%{opacity:1;-webkit-transform:translate3D(0, 0, 0);transform:translate3D(0, 0, 0)}}@-webkit-keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 1);transform:scale3D(1, 1, 1)}}@keyframes in-scale{0%{opacity:0;-webkit-transform:scale3D(0.95, 0.95, 1);transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;-webkit-transform:scale3D(1, 1, 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;-webkit-animation-fill-mode:both;animation-fill-mode:both;-webkit-animation-duration:var(--calcite-animation-timing);animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{-webkit-animation-name:in;animation-name:in}.calcite-animate__in-down{-webkit-animation-name:in-down;animation-name:in-down}.calcite-animate__in-up{-webkit-animation-name:in-up;animation-name:in-up}.calcite-animate__in-scale{-webkit-animation-name:in-scale;animation-name:in-scale}:host{-webkit-box-sizing:border-box;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 *{-webkit-box-sizing:border-box;box-sizing:border-box}:root{--calcite-popper-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host{display:-ms-flexbox;display:flex;-ms-flex-direction:column;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-top:0px}:host([layout=horizontal]){-ms-flex-direction:row;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)}";
  16. const ActionGroup = class {
  17. constructor(hostRef) {
  18. index.registerInstance(this, hostRef);
  19. // --------------------------------------------------------------------------
  20. //
  21. // Properties
  22. //
  23. // --------------------------------------------------------------------------
  24. /**
  25. * Indicates whether widget is expanded.
  26. */
  27. this.expanded = false;
  28. /**
  29. * Indicates the horizontal, vertical, or grid layout of the component.
  30. */
  31. this.layout = "vertical";
  32. /**
  33. * Opens the action menu.
  34. */
  35. this.menuOpen = false;
  36. // --------------------------------------------------------------------------
  37. //
  38. // Private Methods
  39. //
  40. // --------------------------------------------------------------------------
  41. this.setMenuOpen = (event) => {
  42. this.menuOpen = !!event.detail;
  43. };
  44. }
  45. expandedHandler() {
  46. this.menuOpen = false;
  47. }
  48. // --------------------------------------------------------------------------
  49. //
  50. // Lifecycle
  51. //
  52. // --------------------------------------------------------------------------
  53. connectedCallback() {
  54. conditionalSlot.connectConditionalSlotComponent(this);
  55. }
  56. disconnectedCallback() {
  57. conditionalSlot.disconnectConditionalSlotComponent(this);
  58. }
  59. // --------------------------------------------------------------------------
  60. //
  61. // Component Methods
  62. //
  63. // --------------------------------------------------------------------------
  64. renderTooltip() {
  65. const { el } = this;
  66. const hasTooltip = dom.getSlotted(el, resources.SLOTS.menuTooltip);
  67. return hasTooltip ? index.h("slot", { name: resources.SLOTS.menuTooltip, slot: resources$1.SLOTS.tooltip }) : null;
  68. }
  69. renderMenu() {
  70. const { el, expanded, intlMore, menuOpen, scale } = this;
  71. const hasMenuItems = dom.getSlotted(el, resources.SLOTS.menuActions);
  72. return hasMenuItems ? (index.h("calcite-action-menu", { expanded: expanded, flipPlacements: ["left", "right"], label: intlMore || resources.TEXT.more, onCalciteActionMenuOpenChange: this.setMenuOpen, open: menuOpen, placement: "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;
  73. }
  74. render() {
  75. return (index.h(index.Fragment, null, index.h("slot", null), this.renderMenu()));
  76. }
  77. get el() { return index.getElement(this); }
  78. static get watchers() { return {
  79. "expanded": ["expandedHandler"]
  80. }; }
  81. };
  82. ActionGroup.style = actionGroupCss;
  83. exports.calcite_action_group = ActionGroup;