123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- /*!
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
- * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
- * v1.0.0-beta.97
- */
- import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client/index.js';
- import { I as ICON_TYPES } from './resources.js';
- import { m as mutationObserverCallback, d as deselectRemovedItems, a as deselectSiblingItems, s as selectSiblings, h as handleFilter, g as getItemData, k as keyDownHandler, i as initialize, b as initializeObserver, c as cleanUpObserver, r as removeItem, e as calciteListItemChangeHandler, f as calciteInternalListItemValueChangeHandler, j as calciteListFocusOutHandler, l as setUpItems, n as setFocus, L as List } from './shared-list-render.js';
- import { c as createObserver } from './observers.js';
- import { u as updateHostInteraction } from './interactive.js';
- import { d as defineCustomElement$7 } from './filter.js';
- import { d as defineCustomElement$6 } from './icon.js';
- import { d as defineCustomElement$5 } from './input.js';
- import { d as defineCustomElement$4 } from './loader.js';
- import { d as defineCustomElement$3 } from './progress.js';
- import { d as defineCustomElement$2 } from './scrim.js';
- const pickListCss = "@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}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{position:relative;box-sizing:border-box;display:flex;flex-shrink:0;flex-grow:1;flex-direction:column;align-items:stretch;background-color:transparent;font-size:var(--calcite-font-size--1);line-height:1rem;color:var(--calcite-ui-text-2)}:host *{box-sizing:border-box}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host([filter-enabled]) header{margin-block-end:0.25rem;display:flex;align-items:stretch;justify-content:flex-end;background-color:var(--calcite-ui-foreground-1);--tw-shadow:0 1px 0 var(--calcite-ui-border-3);--tw-shadow-colored:0 1px 0 var(--tw-shadow-color);box-shadow:var(--tw-ring-offset-shadow, 0 0 #0000), var(--tw-ring-shadow, 0 0 #0000), var(--tw-shadow)}:host([filter-enabled]) header.sticky-pos{position:sticky;inset-block-start:0px;z-index:1}calcite-filter{margin-block-end:0px}:host([loading][disabled]){min-block-size:2rem}";
- const PickList = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
- constructor() {
- super();
- this.__registerHost();
- this.__attachShadow();
- this.calciteListChange = createEvent(this, "calciteListChange", 6);
- // --------------------------------------------------------------------------
- //
- // Properties
- //
- // --------------------------------------------------------------------------
- /**
- * When `true`, interaction is prevented and the component is displayed with lower opacity.
- */
- this.disabled = false;
- /**
- * When `true`, an input appears at the top of the list that can be used by end users to filter items in the list.
- */
- this.filterEnabled = false;
- /**
- * When `true`, a busy indicator is displayed.
- */
- this.loading = false;
- /**
- * Similar to standard radio buttons and checkboxes.
- * When `true`, a user can select multiple `calcite-pick-list-item`s at a time.
- * When `false`, only a single `calcite-pick-list-item` can be selected at a time,
- * and a new selection will deselect previous selections.
- */
- this.multiple = false;
- /**
- * When `true` and single selection is enabled, the selection changes when navigating `calcite-pick-list-item`s via keyboard.
- */
- this.selectionFollowsFocus = false;
- // --------------------------------------------------------------------------
- //
- // Private Properties
- //
- // --------------------------------------------------------------------------
- this.selectedValues = new Map();
- this.dataForFilter = [];
- this.lastSelectedItem = null;
- this.mutationObserver = createObserver("mutation", mutationObserverCallback.bind(this));
- this.setFilterEl = (el) => {
- this.filterEl = el;
- };
- this.deselectRemovedItems = deselectRemovedItems.bind(this);
- this.deselectSiblingItems = deselectSiblingItems.bind(this);
- this.selectSiblings = selectSiblings.bind(this);
- this.handleFilter = handleFilter.bind(this);
- this.getItemData = getItemData.bind(this);
- this.keyDownHandler = keyDownHandler.bind(this);
- }
- // --------------------------------------------------------------------------
- //
- // Lifecycle
- //
- // --------------------------------------------------------------------------
- connectedCallback() {
- initialize.call(this);
- initializeObserver.call(this);
- }
- disconnectedCallback() {
- cleanUpObserver.call(this);
- }
- componentDidRender() {
- updateHostInteraction(this);
- }
- calciteListItemRemoveHandler(event) {
- removeItem.call(this, event);
- }
- calciteListItemChangeHandler(event) {
- calciteListItemChangeHandler.call(this, event);
- }
- calciteInternalListItemPropsChangeHandler(event) {
- event.stopPropagation();
- this.setUpFilter();
- }
- calciteInternalListItemValueChangeHandler(event) {
- calciteInternalListItemValueChangeHandler.call(this, event);
- event.stopPropagation();
- }
- calciteListFocusOutHandler(event) {
- calciteListFocusOutHandler.call(this, event);
- }
- // --------------------------------------------------------------------------
- //
- // Private Methods
- //
- // --------------------------------------------------------------------------
- setUpItems() {
- setUpItems.call(this, "calcite-pick-list-item");
- }
- setUpFilter() {
- if (this.filterEnabled) {
- this.dataForFilter = this.getItemData();
- }
- }
- // --------------------------------------------------------------------------
- //
- // Public Methods
- //
- // --------------------------------------------------------------------------
- /** Returns the component's selected `calcite-pick-list-item`s. */
- async getSelectedItems() {
- return this.selectedValues;
- }
- /**
- * Sets focus on the component.
- *
- * @param focusId
- */
- async setFocus(focusId) {
- return setFocus.call(this, focusId);
- }
- // --------------------------------------------------------------------------
- //
- // Render Methods
- //
- // --------------------------------------------------------------------------
- getIconType() {
- return this.multiple ? ICON_TYPES.square : ICON_TYPES.circle;
- }
- render() {
- return h(List, { onKeyDown: this.keyDownHandler, props: this });
- }
- get el() { return this; }
- static get style() { return pickListCss; }
- }, [1, "calcite-pick-list", {
- "disabled": [516],
- "filterEnabled": [516, "filter-enabled"],
- "filterPlaceholder": [513, "filter-placeholder"],
- "headingLevel": [514, "heading-level"],
- "loading": [516],
- "multiple": [516],
- "selectionFollowsFocus": [516, "selection-follows-focus"],
- "selectedValues": [32],
- "dataForFilter": [32],
- "getSelectedItems": [64],
- "setFocus": [64]
- }, [[0, "calciteListItemRemove", "calciteListItemRemoveHandler"], [0, "calciteListItemChange", "calciteListItemChangeHandler"], [0, "calciteInternalListItemPropsChange", "calciteInternalListItemPropsChangeHandler"], [0, "calciteInternalListItemValueChange", "calciteInternalListItemValueChangeHandler"], [0, "focusout", "calciteListFocusOutHandler"]]]);
- function defineCustomElement$1() {
- if (typeof customElements === "undefined") {
- return;
- }
- const components = ["calcite-pick-list", "calcite-filter", "calcite-icon", "calcite-input", "calcite-loader", "calcite-progress", "calcite-scrim"];
- components.forEach(tagName => { switch (tagName) {
- case "calcite-pick-list":
- if (!customElements.get(tagName)) {
- customElements.define(tagName, PickList);
- }
- break;
- case "calcite-filter":
- if (!customElements.get(tagName)) {
- defineCustomElement$7();
- }
- break;
- case "calcite-icon":
- if (!customElements.get(tagName)) {
- defineCustomElement$6();
- }
- break;
- case "calcite-input":
- if (!customElements.get(tagName)) {
- defineCustomElement$5();
- }
- break;
- case "calcite-loader":
- if (!customElements.get(tagName)) {
- defineCustomElement$4();
- }
- break;
- case "calcite-progress":
- if (!customElements.get(tagName)) {
- defineCustomElement$3();
- }
- break;
- case "calcite-scrim":
- if (!customElements.get(tagName)) {
- defineCustomElement$2();
- }
- break;
- } });
- }
- defineCustomElement$1();
- const CalcitePickList = PickList;
- const defineCustomElement = defineCustomElement$1;
- export { CalcitePickList, defineCustomElement };
|