UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

117 lines (111 loc) 6.91 kB
/*! * All material copyright ESRI, All Rights Reserved, unless otherwise specified. * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details. * v1.5.0-next.4 */ 'use strict'; Object.defineProperty(exports, '__esModule', { value: true }); const index = require('./index-55f8a3b7.js'); const conditionalSlot = require('./conditionalSlot-4472b3c1.js'); const dom = require('./dom-18ca68ff.js'); const loadable = require('./loadable-53f729bb.js'); const locale = require('./locale-fc347462.js'); const t9n = require('./t9n-14d528c4.js'); const resources$1 = require('./resources-92796e4d.js'); const resources = require('./resources-372c2745.js'); require('./observers-83b3999d.js'); require('./guid-db20443e.js'); require('./resources-45d84c94.js'); require('./key-2ce02f02.js'); 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-right{0%{opacity:0;transform:translate3D(-5px, 0, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-left{0%{opacity:0;transform:translate3D(5px, 0, 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-right{animation-name:in-right}.calcite-animate__in-left{animation-name:in-left}.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);--calcite-floating-ui-z-index:var(--calcite-app-z-index-dropdown)}: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)}"; const ActionGroup = class { constructor(hostRef) { index.registerInstance(this, hostRef); // -------------------------------------------------------------------------- // // Private Methods // // -------------------------------------------------------------------------- this.setMenuOpen = (event) => { this.menuOpen = !!event.target.open; }; this.expanded = false; this.layout = "vertical"; this.columns = undefined; this.menuOpen = false; this.scale = undefined; this.messages = undefined; this.messageOverrides = undefined; this.effectiveLocale = ""; this.defaultMessages = undefined; } expandedHandler() { this.menuOpen = false; } onMessagesChange() { /* wired up by t9n util */ } effectiveLocaleChange() { t9n.updateMessages(this, this.effectiveLocale); } //-------------------------------------------------------------------------- // // Public Methods // //-------------------------------------------------------------------------- /** Sets focus on the component's first focusable element. */ async setFocus() { await loadable.componentLoaded(this); this.el.focus(); } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { locale.connectLocalized(this); t9n.connectMessages(this); conditionalSlot.connectConditionalSlotComponent(this); } disconnectedCallback() { locale.disconnectLocalized(this); t9n.disconnectMessages(this); conditionalSlot.disconnectConditionalSlotComponent(this); } async componentWillLoad() { loadable.setUpLoadableComponent(this); await t9n.setUpMessages(this); } componentDidLoad() { loadable.setComponentLoaded(this); } // -------------------------------------------------------------------------- // // Component Methods // // -------------------------------------------------------------------------- renderTooltip() { const { el } = this; const hasTooltip = dom.getSlotted(el, resources.SLOTS.menuTooltip); return hasTooltip ? index.h("slot", { name: resources.SLOTS.menuTooltip, slot: resources$1.SLOTS.tooltip }) : null; } renderMenu() { const { el, expanded, menuOpen, scale, layout, messages } = this; const hasMenuItems = dom.getSlotted(el, resources.SLOTS.menuActions); return hasMenuItems ? (index.h("calcite-action-menu", { expanded: expanded, flipPlacements: ["left", "right"], label: messages.more, onCalciteActionMenuOpen: this.setMenuOpen, open: menuOpen, placement: layout === "horizontal" ? "bottom-start" : "leading-start", scale: scale }, index.h("calcite-action", { icon: resources.ICONS.menu, scale: scale, slot: resources$1.SLOTS.trigger, text: messages.more, textEnabled: expanded }), index.h("slot", { name: resources.SLOTS.menuActions }), this.renderTooltip())) : null; } render() { return (index.h(index.Fragment, null, index.h("slot", null), this.renderMenu())); } static get delegatesFocus() { return true; } static get assetsDirs() { return ["assets"]; } get el() { return index.getElement(this); } static get watchers() { return { "expanded": ["expandedHandler"], "messageOverrides": ["onMessagesChange"], "effectiveLocale": ["effectiveLocaleChange"] }; } }; ActionGroup.style = actionGroupCss; exports.calcite_action_group = ActionGroup;