UNPKG

@esri/calcite-components

Version:

Web Components for Esri's Calcite Design System.

172 lines (167 loc) • 8.55 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 */ import { proxyCustomElement, HTMLElement, h, Fragment } from '@stencil/core/internal/client'; import { c as connectConditionalSlotComponent, d as disconnectConditionalSlotComponent } from './conditionalSlot.js'; import { b as getSlotted } from './dom.js'; import { c as componentLoaded, a as setUpLoadableComponent, s as setComponentLoaded } from './loadable.js'; import { c as connectLocalized, d as disconnectLocalized } from './locale.js'; import { u as updateMessages, c as connectMessages, d as disconnectMessages, s as setUpMessages } from './t9n.js'; import { S as SLOTS$1, d as defineCustomElement$4 } from './action-menu.js'; import { d as defineCustomElement$5 } from './action.js'; import { d as defineCustomElement$3 } from './icon.js'; import { d as defineCustomElement$2 } from './loader.js'; import { d as defineCustomElement$1 } from './popover.js'; const SLOTS = { menuActions: "menu-actions", menuTooltip: "menu-tooltip" }; const ICONS = { menu: "ellipsis" }; 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 = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement { constructor() { super(); this.__registerHost(); this.__attachShadow(); // -------------------------------------------------------------------------- // // 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() { updateMessages(this, this.effectiveLocale); } //-------------------------------------------------------------------------- // // Public Methods // //-------------------------------------------------------------------------- /** Sets focus on the component's first focusable element. */ async setFocus() { await componentLoaded(this); this.el.focus(); } // -------------------------------------------------------------------------- // // Lifecycle // // -------------------------------------------------------------------------- connectedCallback() { connectLocalized(this); connectMessages(this); connectConditionalSlotComponent(this); } disconnectedCallback() { disconnectLocalized(this); disconnectMessages(this); disconnectConditionalSlotComponent(this); } async componentWillLoad() { setUpLoadableComponent(this); await setUpMessages(this); } componentDidLoad() { setComponentLoaded(this); } // -------------------------------------------------------------------------- // // Component Methods // // -------------------------------------------------------------------------- renderTooltip() { const { el } = this; const hasTooltip = getSlotted(el, SLOTS.menuTooltip); return hasTooltip ? h("slot", { name: SLOTS.menuTooltip, slot: SLOTS$1.tooltip }) : null; } renderMenu() { const { el, expanded, menuOpen, scale, layout, messages } = this; const hasMenuItems = getSlotted(el, SLOTS.menuActions); return hasMenuItems ? (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 }, h("calcite-action", { icon: ICONS.menu, scale: scale, slot: SLOTS$1.trigger, text: messages.more, textEnabled: expanded }), h("slot", { name: SLOTS.menuActions }), this.renderTooltip())) : null; } render() { return (h(Fragment, null, h("slot", null), this.renderMenu())); } static get delegatesFocus() { return true; } static get assetsDirs() { return ["assets"]; } get el() { return this; } static get watchers() { return { "expanded": ["expandedHandler"], "messageOverrides": ["onMessagesChange"], "effectiveLocale": ["effectiveLocaleChange"] }; } static get style() { return actionGroupCss; } }, [17, "calcite-action-group", { "expanded": [516], "layout": [513], "columns": [514], "menuOpen": [1540, "menu-open"], "scale": [513], "messages": [1040], "messageOverrides": [1040], "effectiveLocale": [32], "defaultMessages": [32], "setFocus": [64] }]); function defineCustomElement() { if (typeof customElements === "undefined") { return; } const components = ["calcite-action-group", "calcite-action", "calcite-action-menu", "calcite-icon", "calcite-loader", "calcite-popover"]; components.forEach(tagName => { switch (tagName) { case "calcite-action-group": if (!customElements.get(tagName)) { customElements.define(tagName, ActionGroup); } break; case "calcite-action": if (!customElements.get(tagName)) { defineCustomElement$5(); } break; case "calcite-action-menu": if (!customElements.get(tagName)) { defineCustomElement$4(); } break; case "calcite-icon": if (!customElements.get(tagName)) { defineCustomElement$3(); } break; case "calcite-loader": if (!customElements.get(tagName)) { defineCustomElement$2(); } break; case "calcite-popover": if (!customElements.get(tagName)) { defineCustomElement$1(); } break; } }); } defineCustomElement(); export { ActionGroup as A, SLOTS as S, defineCustomElement as d };