@esri/solutions-components 0.2.6 → 0.2.7
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/cjs/deduct-calculator.cjs.entry.js +1 -1
- package/dist/cjs/pci-calculator.cjs.entry.js +1 -1
- package/dist/cjs/{pciUtils-6a806ba4.js → pciUtils-423cfc68.js} +25 -7
- package/dist/collection/demos/deduct-calculator.html +2 -5
- package/dist/collection/demos/new-public-notification.html +6 -4
- package/dist/collection/utils/pciUtils.js +25 -7
- package/dist/collection/utils/pciUtils.ts +30 -7
- package/dist/components/ExpandToggle.js +110 -0
- package/dist/components/Heading.js +22 -0
- package/dist/components/_commonjsHelpers.js +22 -0
- package/dist/components/action-bar.js +276 -0
- package/dist/components/action-group.js +149 -0
- package/dist/components/action-menu.js +356 -0
- package/dist/components/action.js +214 -0
- package/dist/components/add-record-modal.d.ts +11 -0
- package/dist/components/add-record-modal.js +171 -0
- package/dist/components/array.js +15 -0
- package/dist/components/block.js +272 -0
- package/dist/components/buffer-tools.d.ts +11 -0
- package/dist/components/buffer-tools.js +11 -0
- package/dist/components/buffer-tools2.js +262 -0
- package/dist/components/button.js +263 -0
- package/dist/components/calcite-accordion-item.js +244 -0
- package/dist/components/calcite-accordion.js +180 -0
- package/dist/components/calcite-action-bar.js +11 -0
- package/dist/components/calcite-action-group.js +11 -0
- package/dist/components/calcite-action-menu.js +11 -0
- package/dist/components/calcite-action-pad.js +197 -0
- package/dist/components/calcite-action.js +11 -0
- package/dist/components/calcite-alert.js +297 -0
- package/dist/components/calcite-avatar.js +182 -0
- package/dist/components/calcite-block-section.js +155 -0
- package/dist/components/calcite-block.js +11 -0
- package/dist/components/calcite-button.js +11 -0
- package/dist/components/calcite-card.js +187 -0
- package/dist/components/calcite-checkbox.js +11 -0
- package/dist/components/calcite-chip.js +11 -0
- package/dist/components/calcite-color-picker-hex-input.js +11 -0
- package/dist/components/calcite-color-picker-swatch.js +11 -0
- package/dist/components/calcite-color-picker.js +1036 -0
- package/dist/components/calcite-combobox-item-group.js +75 -0
- package/dist/components/calcite-combobox-item.js +11 -0
- package/dist/components/calcite-combobox.js +11 -0
- package/dist/components/calcite-date-picker-day.js +11 -0
- package/dist/components/calcite-date-picker-month-header.js +11 -0
- package/dist/components/calcite-date-picker-month.js +11 -0
- package/dist/components/calcite-date-picker.js +11 -0
- package/dist/components/calcite-dropdown-group.js +11 -0
- package/dist/components/calcite-dropdown-item.js +11 -0
- package/dist/components/calcite-dropdown.js +11 -0
- package/dist/components/calcite-fab.js +144 -0
- package/dist/components/calcite-filter.js +195 -0
- package/dist/components/calcite-flow-item.js +243 -0
- package/dist/components/calcite-flow.js +147 -0
- package/dist/components/calcite-graph.js +11 -0
- package/dist/components/calcite-handle.js +11 -0
- package/dist/components/calcite-icon.js +11 -0
- package/dist/components/calcite-inline-editable.js +294 -0
- package/dist/components/calcite-input-date-picker.js +713 -0
- package/dist/components/calcite-input-message.js +11 -0
- package/dist/components/calcite-input-number.js +637 -0
- package/dist/components/calcite-input-text.js +400 -0
- package/dist/components/calcite-input-time-picker.js +434 -0
- package/dist/components/calcite-input.js +11 -0
- package/dist/components/calcite-label.js +11 -0
- package/dist/components/calcite-link.js +11 -0
- package/dist/components/calcite-list-item-group.js +65 -0
- package/dist/components/calcite-list-item.js +11 -0
- package/dist/components/calcite-list.js +11 -0
- package/dist/components/calcite-loader.js +11 -0
- package/dist/components/calcite-modal.js +11 -0
- package/dist/components/calcite-notice.js +11 -0
- package/dist/components/calcite-option-group.js +64 -0
- package/dist/components/calcite-option.js +11 -0
- package/dist/components/calcite-pagination.js +258 -0
- package/dist/components/calcite-panel.js +11 -0
- package/dist/components/calcite-pick-list-group.js +74 -0
- package/dist/components/calcite-pick-list-item.js +11 -0
- package/dist/components/calcite-pick-list.js +11 -0
- package/dist/components/calcite-popover-manager.js +94 -0
- package/dist/components/calcite-popover.js +11 -0
- package/dist/components/calcite-progress.js +11 -0
- package/dist/components/calcite-radio-button-group.js +132 -0
- package/dist/components/calcite-radio-button.js +310 -0
- package/dist/components/calcite-radio-group-item.js +11 -0
- package/dist/components/calcite-radio-group.js +11 -0
- package/dist/components/calcite-rating.js +201 -0
- package/dist/components/calcite-scrim.js +11 -0
- package/dist/components/calcite-select.js +11 -0
- package/dist/components/calcite-shell-center-row.js +100 -0
- package/dist/components/calcite-shell-panel.js +11 -0
- package/dist/components/calcite-shell.js +11 -0
- package/dist/components/calcite-slider.js +11 -0
- package/dist/components/calcite-sortable-list.js +202 -0
- package/dist/components/calcite-split-button.js +11 -0
- package/dist/components/calcite-stepper-item.js +271 -0
- package/dist/components/calcite-stepper.js +256 -0
- package/dist/components/calcite-switch.js +11 -0
- package/dist/components/calcite-tab-nav.js +11 -0
- package/dist/components/calcite-tab-title.js +11 -0
- package/dist/components/calcite-tab.js +11 -0
- package/dist/components/calcite-tabs.js +11 -0
- package/dist/components/calcite-tile-select-group.js +65 -0
- package/dist/components/calcite-tile-select.js +266 -0
- package/dist/components/calcite-tile.js +11 -0
- package/dist/components/calcite-time-picker.js +11 -0
- package/dist/components/calcite-tip-group.js +41 -0
- package/dist/components/calcite-tip-manager.js +223 -0
- package/dist/components/calcite-tip.js +162 -0
- package/dist/components/calcite-tooltip-manager.js +57 -0
- package/dist/components/calcite-tooltip.js +11 -0
- package/dist/components/calcite-tree-item.js +11 -0
- package/dist/components/calcite-tree.js +11 -0
- package/dist/components/calcite-value-list-item.js +11 -0
- package/dist/components/calcite-value-list.js +11 -0
- package/dist/components/card-manager.d.ts +11 -0
- package/dist/components/card-manager.js +143 -0
- package/dist/components/check-list.d.ts +11 -0
- package/dist/components/check-list.js +11 -0
- package/dist/components/check-list2.js +131 -0
- package/dist/components/checkbox.js +165 -0
- package/dist/components/chip.js +170 -0
- package/dist/components/color-picker-hex-input.js +363 -0
- package/dist/components/color-picker-swatch.js +2034 -0
- package/dist/components/combobox-item.js +182 -0
- package/dist/components/combobox.js +912 -0
- package/dist/components/comment-card.d.ts +11 -0
- package/dist/components/comment-card.js +90 -0
- package/dist/components/conditionalSlot.js +50 -0
- package/dist/components/config-buffer-tools.d.ts +11 -0
- package/dist/components/config-buffer-tools.js +187 -0
- package/dist/components/config-draw-tools.d.ts +11 -0
- package/dist/components/config-draw-tools.js +121 -0
- package/dist/components/config-layer-picker.d.ts +11 -0
- package/dist/components/config-layer-picker.js +163 -0
- package/dist/components/config-pdf-download.d.ts +11 -0
- package/dist/components/config-pdf-download.js +154 -0
- package/dist/components/crowdsource-manager.d.ts +11 -0
- package/dist/components/crowdsource-manager.js +90 -0
- package/dist/components/crowdsource-reporter.d.ts +11 -0
- package/dist/components/crowdsource-reporter.js +90 -0
- package/dist/components/csvUtils.js +74 -0
- package/dist/components/date-picker-day.js +111 -0
- package/dist/components/date-picker-month-header.js +224 -0
- package/dist/components/date-picker-month.js +344 -0
- package/dist/components/date-picker.js +575 -0
- package/dist/components/date.js +180 -0
- package/dist/components/debounce.js +487 -0
- package/dist/components/deduct-calculator.d.ts +11 -0
- package/dist/components/deduct-calculator.js +11 -0
- package/dist/components/deduct-calculator2.js +1002 -0
- package/dist/components/dom.js +231 -0
- package/dist/components/dropdown-group.js +96 -0
- package/dist/components/dropdown-item.js +232 -0
- package/dist/components/dropdown.js +505 -0
- package/dist/components/edit-record-modal.d.ts +11 -0
- package/dist/components/edit-record-modal.js +11 -0
- package/dist/components/edit-record-modal2.js +161 -0
- package/dist/components/filter.js +763 -0
- package/dist/components/floating-ui.js +1768 -0
- package/dist/components/form.js +228 -0
- package/dist/components/graph.js +254 -0
- package/dist/components/guid.js +24 -0
- package/dist/components/handle.js +119 -0
- package/dist/components/icon.js +202 -0
- package/dist/components/index.d.ts +61 -0
- package/dist/components/index.js +196 -0
- package/dist/components/index2.js +199 -0
- package/dist/components/info-card.d.ts +11 -0
- package/dist/components/info-card.js +11 -0
- package/dist/components/info-card2.js +97 -0
- package/dist/components/input-message.js +101 -0
- package/dist/components/input.js +740 -0
- package/dist/components/interactive.js +51 -0
- package/dist/components/interfaces.js +19 -0
- package/dist/components/interfaces2.js +21 -0
- package/dist/components/interfaces3.js +80 -0
- package/dist/components/json-editor.d.ts +11 -0
- package/dist/components/json-editor.js +11 -0
- package/dist/components/json-editor2.js +441 -0
- package/dist/components/key.js +16 -0
- package/dist/components/label.js +106 -0
- package/dist/components/label2.js +131 -0
- package/dist/components/labelFormats.js +210 -0
- package/dist/components/layer-table.d.ts +11 -0
- package/dist/components/layer-table.js +453 -0
- package/dist/components/link.js +123 -0
- package/dist/components/list-item.d.ts +11 -0
- package/dist/components/list-item.js +90 -0
- package/dist/components/list-item2.js +149 -0
- package/dist/components/list.js +83 -0
- package/dist/components/loadModules.js +28 -0
- package/dist/components/loader.js +116 -0
- package/dist/components/locale.js +412 -0
- package/dist/components/locale2.js +413 -0
- package/dist/components/map-card.d.ts +11 -0
- package/dist/components/map-card.js +354 -0
- package/dist/components/map-draw-tools.d.ts +11 -0
- package/dist/components/map-draw-tools.js +11 -0
- package/dist/components/map-draw-tools2.js +228 -0
- package/dist/components/map-layer-picker.d.ts +11 -0
- package/dist/components/map-layer-picker.js +11 -0
- package/dist/components/map-layer-picker2.js +188 -0
- package/dist/components/map-search.d.ts +11 -0
- package/dist/components/map-search.js +155 -0
- package/dist/components/map-select-tools.d.ts +11 -0
- package/dist/components/map-select-tools.js +11 -0
- package/dist/components/map-select-tools2.js +588 -0
- package/dist/components/mapViewUtils.js +129 -0
- package/dist/components/math.js +24 -0
- package/dist/components/media-card.d.ts +11 -0
- package/dist/components/media-card.js +11 -0
- package/dist/components/media-card2.js +177 -0
- package/dist/components/modal.js +495 -0
- package/dist/components/nonChromiumPlatformUtils.js +503 -0
- package/dist/components/notice.js +192 -0
- package/dist/components/observers.js +56 -0
- package/dist/components/openCloseComponent.js +56 -0
- package/dist/components/option.js +109 -0
- package/dist/components/panel.js +459 -0
- package/dist/components/pci-calculator.d.ts +11 -0
- package/dist/components/pci-calculator.js +193 -0
- package/dist/components/pdf-download.d.ts +11 -0
- package/dist/components/pdf-download.js +11 -0
- package/dist/components/pdf-download2.js +189 -0
- package/dist/components/pick-list-item.js +255 -0
- package/dist/components/pick-list.js +170 -0
- package/dist/components/popover.js +500 -0
- package/dist/components/progress.js +60 -0
- package/dist/components/public-notification.d.ts +11 -0
- package/dist/components/public-notification.js +825 -0
- package/dist/components/publicNotificationStore.js +38 -0
- package/dist/components/queryUtils.js +187 -0
- package/dist/components/radio-group-item.js +101 -0
- package/dist/components/radio-group.js +235 -0
- package/dist/components/refine-selection-tools.d.ts +11 -0
- package/dist/components/refine-selection-tools.js +11 -0
- package/dist/components/refine-selection-tools2.js +492 -0
- package/dist/components/refine-selection.d.ts +11 -0
- package/dist/components/refine-selection.js +11 -0
- package/dist/components/refine-selection2.js +376 -0
- package/dist/components/resources.js +24 -0
- package/dist/components/resources2.js +21 -0
- package/dist/components/resources3.js +38 -0
- package/dist/components/scrim.js +83 -0
- package/dist/components/select.js +259 -0
- package/dist/components/shared-list-render.js +319 -0
- package/dist/components/shell-panel.js +281 -0
- package/dist/components/shell.js +121 -0
- package/dist/components/slider.js +896 -0
- package/dist/components/solution-configuration.d.ts +11 -0
- package/dist/components/solution-configuration.js +2233 -0
- package/dist/components/solution-contents.d.ts +11 -0
- package/dist/components/solution-contents.js +11 -0
- package/dist/components/solution-contents2.js +128 -0
- package/dist/components/solution-item-details.d.ts +11 -0
- package/dist/components/solution-item-details.js +11 -0
- package/dist/components/solution-item-details2.js +234 -0
- package/dist/components/solution-item-icon.d.ts +11 -0
- package/dist/components/solution-item-icon.js +11 -0
- package/dist/components/solution-item-icon2.js +342 -0
- package/dist/components/solution-item-sharing.d.ts +11 -0
- package/dist/components/solution-item-sharing.js +11 -0
- package/dist/components/solution-item-sharing2.js +167 -0
- package/dist/components/solution-item.d.ts +11 -0
- package/dist/components/solution-item.js +11 -0
- package/dist/components/solution-item2.js +315 -0
- package/dist/components/solution-organization-variables.d.ts +11 -0
- package/dist/components/solution-organization-variables.js +11 -0
- package/dist/components/solution-organization-variables2.js +132 -0
- package/dist/components/solution-resource-item.d.ts +11 -0
- package/dist/components/solution-resource-item.js +11 -0
- package/dist/components/solution-resource-item2.js +356 -0
- package/dist/components/solution-spatial-ref.d.ts +11 -0
- package/dist/components/solution-spatial-ref.js +11 -0
- package/dist/components/solution-spatial-ref2.js +21446 -0
- package/dist/components/solution-store.js +4092 -0
- package/dist/components/solution-template-data.d.ts +11 -0
- package/dist/components/solution-template-data.js +11 -0
- package/dist/components/solution-template-data2.js +233 -0
- package/dist/components/solution-variables.d.ts +11 -0
- package/dist/components/solution-variables.js +11 -0
- package/dist/components/solution-variables2.js +150 -0
- package/dist/components/sortable.esm.js +3026 -0
- package/dist/components/split-button.js +165 -0
- package/dist/components/store-manager.d.ts +11 -0
- package/dist/components/store-manager.js +83 -0
- package/dist/components/switch.js +139 -0
- package/dist/components/tab-nav.js +241 -0
- package/dist/components/tab-title.js +276 -0
- package/dist/components/tab.js +154 -0
- package/dist/components/tabs.js +188 -0
- package/dist/components/tile.js +129 -0
- package/dist/components/time-picker.js +943 -0
- package/dist/components/tooltip.js +399 -0
- package/dist/components/tree-item.js +294 -0
- package/dist/components/tree.js +327 -0
- package/dist/components/utils.js +119 -0
- package/dist/components/utils2.js +51 -0
- package/dist/components/value-list-item.js +204 -0
- package/dist/components/value-list.js +333 -0
- package/dist/esm/deduct-calculator.entry.js +1 -1
- package/dist/esm/pci-calculator.entry.js +1 -1
- package/dist/esm/{pciUtils-e3007a1c.js → pciUtils-ecda46e5.js} +25 -7
- package/dist/solutions-components/demos/deduct-calculator.html +2 -5
- package/dist/solutions-components/demos/new-public-notification.html +6 -4
- package/dist/solutions-components/{p-ff80ffbb.entry.js → p-0512635b.entry.js} +1 -1
- package/dist/solutions-components/{p-5ec407c2.entry.js → p-0c088725.entry.js} +1 -1
- package/dist/solutions-components/p-cc815aca.js +21 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/pciUtils.ts +30 -7
- package/dist/types/utils/pciUtils.d.ts +2 -1
- package/package.json +4 -3
- package/dist/solutions-components/p-647bbd18.js +0 -21
@@ -0,0 +1,231 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { g as guid } from './guid.js';
|
7
|
+
|
8
|
+
/*!
|
9
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
10
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
11
|
+
* v1.0.0-beta.97
|
12
|
+
*/
|
13
|
+
const autoTheme = "calcite-theme-auto";
|
14
|
+
const darkTheme = "calcite-theme-dark";
|
15
|
+
const lightTheme = "calcite-theme-light";
|
16
|
+
const CSS_UTILITY = {
|
17
|
+
autoTheme,
|
18
|
+
darkTheme,
|
19
|
+
lightTheme,
|
20
|
+
rtl: "calcite--rtl"
|
21
|
+
};
|
22
|
+
const TEXT = {
|
23
|
+
loading: "Loading"
|
24
|
+
};
|
25
|
+
|
26
|
+
/*!
|
27
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
28
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
29
|
+
* v1.0.0-beta.97
|
30
|
+
*/
|
31
|
+
/**
|
32
|
+
* This helper will guarantee an ID on the provided element.
|
33
|
+
*
|
34
|
+
* If it already has an ID, it will be preserved, otherwise a unique one will be generated and assigned.
|
35
|
+
*
|
36
|
+
* @param el
|
37
|
+
* @returns {string} The element's ID.
|
38
|
+
*/
|
39
|
+
function ensureId(el) {
|
40
|
+
if (!el) {
|
41
|
+
return "";
|
42
|
+
}
|
43
|
+
return (el.id = el.id || `${el.tagName.toLowerCase()}-${guid()}`);
|
44
|
+
}
|
45
|
+
function nodeListToArray(nodeList) {
|
46
|
+
return Array.isArray(nodeList) ? nodeList : Array.from(nodeList);
|
47
|
+
}
|
48
|
+
function getThemeName(el) {
|
49
|
+
const closestElWithTheme = closestElementCrossShadowBoundary(el, `.${CSS_UTILITY.darkTheme}, .${CSS_UTILITY.lightTheme}`);
|
50
|
+
return (closestElWithTheme === null || closestElWithTheme === void 0 ? void 0 : closestElWithTheme.classList.contains("calcite-theme-dark")) ? "dark" : "light";
|
51
|
+
}
|
52
|
+
function getElementDir(el) {
|
53
|
+
const prop = "dir";
|
54
|
+
const selector = `[${prop}]`;
|
55
|
+
const closest = closestElementCrossShadowBoundary(el, selector);
|
56
|
+
return closest ? closest.getAttribute(prop) : "ltr";
|
57
|
+
}
|
58
|
+
function getElementProp(el, prop, fallbackValue) {
|
59
|
+
const selector = `[${prop}]`;
|
60
|
+
const closest = el.closest(selector);
|
61
|
+
return closest ? closest.getAttribute(prop) : fallbackValue;
|
62
|
+
}
|
63
|
+
function getRootNode(el) {
|
64
|
+
return el.getRootNode();
|
65
|
+
}
|
66
|
+
function getHost(root) {
|
67
|
+
return root.host || null;
|
68
|
+
}
|
69
|
+
/**
|
70
|
+
* This helper queries an element's rootNode and any ancestor rootNodes.
|
71
|
+
*
|
72
|
+
* If both an 'id' and 'selector' are supplied, 'id' will take precedence over 'selector'.
|
73
|
+
*
|
74
|
+
* @param element
|
75
|
+
* @param root0
|
76
|
+
* @param root0.selector
|
77
|
+
* @param root0.id
|
78
|
+
* @returns {Element} The element.
|
79
|
+
*/
|
80
|
+
function queryElementRoots(element, { selector, id }) {
|
81
|
+
// Gets the rootNode and any ancestor rootNodes (shadowRoot or document) of an element and queries them for a selector.
|
82
|
+
// Based on: https://stackoverflow.com/q/54520554/194216
|
83
|
+
function queryFrom(el) {
|
84
|
+
if (!el) {
|
85
|
+
return null;
|
86
|
+
}
|
87
|
+
if (el.assignedSlot) {
|
88
|
+
el = el.assignedSlot;
|
89
|
+
}
|
90
|
+
const rootNode = getRootNode(el);
|
91
|
+
const found = id
|
92
|
+
? "getElementById" in rootNode
|
93
|
+
? /*
|
94
|
+
Check to make sure 'getElementById' exists in cases where element is no longer connected to the DOM and getRootNode() returns the element.
|
95
|
+
https://github.com/Esri/calcite-components/pull/4280
|
96
|
+
*/
|
97
|
+
rootNode.getElementById(id)
|
98
|
+
: null
|
99
|
+
: selector
|
100
|
+
? rootNode.querySelector(selector)
|
101
|
+
: null;
|
102
|
+
const host = getHost(rootNode);
|
103
|
+
return found ? found : host ? queryFrom(host) : null;
|
104
|
+
}
|
105
|
+
return queryFrom(element);
|
106
|
+
}
|
107
|
+
function closestElementCrossShadowBoundary(element, selector) {
|
108
|
+
// based on https://stackoverflow.com/q/54520554/194216
|
109
|
+
function closestFrom(el) {
|
110
|
+
return el ? el.closest(selector) || closestFrom(getHost(getRootNode(el))) : null;
|
111
|
+
}
|
112
|
+
return closestFrom(element);
|
113
|
+
}
|
114
|
+
/**
|
115
|
+
* This utility helps invoke a callback as it traverses a node and its ancestors until reaching the root document.
|
116
|
+
*
|
117
|
+
* Returning early or undefined in `onVisit` will continue traversing up the DOM tree. Otherwise, traversal will halt with the returned value as the result of the function
|
118
|
+
*
|
119
|
+
* @param element
|
120
|
+
* @param onVisit
|
121
|
+
*/
|
122
|
+
function walkUpAncestry(element, onVisit) {
|
123
|
+
return visit(element, onVisit);
|
124
|
+
}
|
125
|
+
function visit(node, onVisit) {
|
126
|
+
if (!node) {
|
127
|
+
return;
|
128
|
+
}
|
129
|
+
const result = onVisit(node);
|
130
|
+
if (result !== undefined) {
|
131
|
+
return result;
|
132
|
+
}
|
133
|
+
const { parentNode } = node;
|
134
|
+
return visit(parentNode instanceof ShadowRoot ? parentNode.host : parentNode, onVisit);
|
135
|
+
}
|
136
|
+
function containsCrossShadowBoundary(element, maybeDescendant) {
|
137
|
+
return !!walkUpAncestry(maybeDescendant, (node) => (node === element ? true : undefined));
|
138
|
+
}
|
139
|
+
function isCalciteFocusable(el) {
|
140
|
+
return typeof (el === null || el === void 0 ? void 0 : el.setFocus) === "function";
|
141
|
+
}
|
142
|
+
async function focusElement(el) {
|
143
|
+
if (!el) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
return isCalciteFocusable(el) ? el.setFocus() : el.focus();
|
147
|
+
}
|
148
|
+
const defaultSlotSelector = ":not([slot])";
|
149
|
+
function getSlotted(element, slotName, options) {
|
150
|
+
if (slotName && !Array.isArray(slotName) && typeof slotName !== "string") {
|
151
|
+
options = slotName;
|
152
|
+
slotName = null;
|
153
|
+
}
|
154
|
+
const slotSelector = slotName
|
155
|
+
? Array.isArray(slotName)
|
156
|
+
? slotName.map((name) => `[slot="${name}"]`).join(",")
|
157
|
+
: `[slot="${slotName}"]`
|
158
|
+
: defaultSlotSelector;
|
159
|
+
if (options === null || options === void 0 ? void 0 : options.all) {
|
160
|
+
return queryMultiple(element, slotSelector, options);
|
161
|
+
}
|
162
|
+
return querySingle(element, slotSelector, options);
|
163
|
+
}
|
164
|
+
function getDirectChildren(el, selector) {
|
165
|
+
return el ? Array.from(el.children || []).filter((child) => child === null || child === void 0 ? void 0 : child.matches(selector)) : [];
|
166
|
+
}
|
167
|
+
function queryMultiple(element, slotSelector, options) {
|
168
|
+
let matches = slotSelector === defaultSlotSelector
|
169
|
+
? getDirectChildren(element, defaultSlotSelector)
|
170
|
+
: Array.from(element.querySelectorAll(slotSelector));
|
171
|
+
matches = options && options.direct === false ? matches : matches.filter((el) => el.parentElement === element);
|
172
|
+
matches = (options === null || options === void 0 ? void 0 : options.matches) ? matches.filter((el) => el === null || el === void 0 ? void 0 : el.matches(options.matches)) : matches;
|
173
|
+
const selector = options === null || options === void 0 ? void 0 : options.selector;
|
174
|
+
return selector
|
175
|
+
? matches
|
176
|
+
.map((item) => Array.from(item.querySelectorAll(selector)))
|
177
|
+
.reduce((previousValue, currentValue) => [...previousValue, ...currentValue], [])
|
178
|
+
.filter((match) => !!match)
|
179
|
+
: matches;
|
180
|
+
}
|
181
|
+
function querySingle(element, slotSelector, options) {
|
182
|
+
let match = slotSelector === defaultSlotSelector
|
183
|
+
? getDirectChildren(element, defaultSlotSelector)[0] || null
|
184
|
+
: element.querySelector(slotSelector);
|
185
|
+
match = options && options.direct === false ? match : (match === null || match === void 0 ? void 0 : match.parentElement) === element ? match : null;
|
186
|
+
match = (options === null || options === void 0 ? void 0 : options.matches) ? ((match === null || match === void 0 ? void 0 : match.matches(options.matches)) ? match : null) : match;
|
187
|
+
const selector = options === null || options === void 0 ? void 0 : options.selector;
|
188
|
+
return selector ? match === null || match === void 0 ? void 0 : match.querySelector(selector) : match;
|
189
|
+
}
|
190
|
+
function filterDirectChildren(el, selector) {
|
191
|
+
return Array.from(el.children).filter((child) => child.matches(selector));
|
192
|
+
}
|
193
|
+
// set a default icon from a defined set or allow an override with an icon name string
|
194
|
+
function setRequestedIcon(iconObject, iconValue, matchedValue) {
|
195
|
+
if (typeof iconValue === "string" && iconValue !== "") {
|
196
|
+
return iconValue;
|
197
|
+
}
|
198
|
+
else if (iconValue === "") {
|
199
|
+
return iconObject[matchedValue];
|
200
|
+
}
|
201
|
+
}
|
202
|
+
function intersects(rect1, rect2) {
|
203
|
+
return !(rect2.left > rect1.right ||
|
204
|
+
rect2.right < rect1.left ||
|
205
|
+
rect2.top > rect1.bottom ||
|
206
|
+
rect2.bottom < rect1.top);
|
207
|
+
}
|
208
|
+
/**
|
209
|
+
* This helper makes sure that boolean aria attributes are properly converted to a string.
|
210
|
+
*
|
211
|
+
* It should only be used for aria attributes that require a string value of "true" or "false".
|
212
|
+
*
|
213
|
+
* @param value
|
214
|
+
* @returns {string} The string conversion of a boolean value ("true" | "false").
|
215
|
+
*/
|
216
|
+
function toAriaBoolean(value) {
|
217
|
+
return Boolean(value).toString();
|
218
|
+
}
|
219
|
+
/**
|
220
|
+
* This helper returns true if the pointer event fired from the primary button of the device.
|
221
|
+
*
|
222
|
+
* See https://www.w3.org/TR/pointerevents/#the-button-property.
|
223
|
+
*
|
224
|
+
* @param event
|
225
|
+
* @returns {boolean}
|
226
|
+
*/
|
227
|
+
function isPrimaryPointerButton(event) {
|
228
|
+
return !!(event.isPrimary && event.button === 0);
|
229
|
+
}
|
230
|
+
|
231
|
+
export { CSS_UTILITY as C, TEXT as T, autoTheme as a, getSlotted as b, getElementDir as c, darkTheme as d, getThemeName as e, focusElement as f, getElementProp as g, closestElementCrossShadowBoundary as h, isPrimaryPointerButton as i, ensureId as j, isCalciteFocusable as k, intersects as l, filterDirectChildren as m, nodeListToArray as n, getRootNode as o, containsCrossShadowBoundary as p, queryElementRoots as q, setRequestedIcon as s, toAriaBoolean as t };
|
@@ -0,0 +1,96 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
7
|
+
import { g as getElementProp } from './dom.js';
|
8
|
+
|
9
|
+
/*!
|
10
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
11
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
12
|
+
* v1.0.0-beta.97
|
13
|
+
*/
|
14
|
+
const CSS = {
|
15
|
+
containerSmall: "container--s",
|
16
|
+
containerMedium: "container--m",
|
17
|
+
containerLarge: "container--l"
|
18
|
+
};
|
19
|
+
|
20
|
+
const dropdownGroupCss = "@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{display:block}.container{text-align:start}.container--s{font-size:var(--calcite-font-size--2);line-height:1rem}.container--s .dropdown-title{padding:0.5rem}.container--m{font-size:var(--calcite-font-size--1);line-height:1rem}.container--m .dropdown-title{padding:0.75rem}.container--l{font-size:var(--calcite-font-size-0);line-height:1.25rem}.container--l .dropdown-title{padding:1rem}.dropdown-title{-webkit-margin-after:-1px;margin-block-end:-1px;display:block;cursor:default;overflow-wrap:break-word;border-width:0px;border-block-end-width:1px;border-style:solid;border-color:var(--calcite-ui-border-3);font-weight:var(--calcite-font-weight-bold);color:var(--calcite-ui-text-2)}.dropdown-separator{display:block;block-size:1px;background-color:var(--calcite-ui-border-3)}";
|
21
|
+
|
22
|
+
const DropdownGroup = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
23
|
+
constructor() {
|
24
|
+
super();
|
25
|
+
this.__registerHost();
|
26
|
+
this.__attachShadow();
|
27
|
+
this.calciteInternalDropdownItemChange = createEvent(this, "calciteInternalDropdownItemChange", 6);
|
28
|
+
/**
|
29
|
+
specify the selection mode - multi (allow any number of (or no) active items), single (allow and require one active item),
|
30
|
+
none (no active items), defaults to single
|
31
|
+
*/
|
32
|
+
this.selectionMode = "single";
|
33
|
+
}
|
34
|
+
//--------------------------------------------------------------------------
|
35
|
+
//
|
36
|
+
// Lifecycle
|
37
|
+
//
|
38
|
+
//--------------------------------------------------------------------------
|
39
|
+
componentWillLoad() {
|
40
|
+
this.groupPosition = this.getGroupPosition();
|
41
|
+
}
|
42
|
+
render() {
|
43
|
+
const scale = this.scale || getElementProp(this.el, "scale", "m");
|
44
|
+
const groupTitle = this.groupTitle ? (h("span", { "aria-hidden": "true", class: "dropdown-title" }, this.groupTitle)) : null;
|
45
|
+
const dropdownSeparator = this.groupPosition > 0 ? h("div", { class: "dropdown-separator", role: "separator" }) : null;
|
46
|
+
return (h(Host, { "aria-label": this.groupTitle, role: "group" }, h("div", { class: {
|
47
|
+
container: true,
|
48
|
+
[CSS.containerSmall]: scale === "s",
|
49
|
+
[CSS.containerMedium]: scale === "m",
|
50
|
+
[CSS.containerLarge]: scale === "l"
|
51
|
+
}, title: this.groupTitle }, dropdownSeparator, groupTitle, h("slot", null))));
|
52
|
+
}
|
53
|
+
//--------------------------------------------------------------------------
|
54
|
+
//
|
55
|
+
// Event Listeners
|
56
|
+
//
|
57
|
+
//--------------------------------------------------------------------------
|
58
|
+
updateActiveItemOnChange(event) {
|
59
|
+
this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
|
60
|
+
this.requestedDropdownItem = event.detail.requestedDropdownItem;
|
61
|
+
this.calciteInternalDropdownItemChange.emit({
|
62
|
+
requestedDropdownGroup: this.requestedDropdownGroup,
|
63
|
+
requestedDropdownItem: this.requestedDropdownItem
|
64
|
+
});
|
65
|
+
}
|
66
|
+
//--------------------------------------------------------------------------
|
67
|
+
//
|
68
|
+
// Private Methods
|
69
|
+
//
|
70
|
+
//--------------------------------------------------------------------------
|
71
|
+
getGroupPosition() {
|
72
|
+
return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-dropdown-group"), this.el);
|
73
|
+
}
|
74
|
+
get el() { return this; }
|
75
|
+
static get style() { return dropdownGroupCss; }
|
76
|
+
}, [1, "calcite-dropdown-group", {
|
77
|
+
"groupTitle": [513, "group-title"],
|
78
|
+
"selectionMode": [513, "selection-mode"],
|
79
|
+
"scale": [513]
|
80
|
+
}, [[0, "calciteInternalDropdownItemSelect", "updateActiveItemOnChange"]]]);
|
81
|
+
function defineCustomElement() {
|
82
|
+
if (typeof customElements === "undefined") {
|
83
|
+
return;
|
84
|
+
}
|
85
|
+
const components = ["calcite-dropdown-group"];
|
86
|
+
components.forEach(tagName => { switch (tagName) {
|
87
|
+
case "calcite-dropdown-group":
|
88
|
+
if (!customElements.get(tagName)) {
|
89
|
+
customElements.define(tagName, DropdownGroup);
|
90
|
+
}
|
91
|
+
break;
|
92
|
+
} });
|
93
|
+
}
|
94
|
+
defineCustomElement();
|
95
|
+
|
96
|
+
export { DropdownGroup as D, defineCustomElement as d };
|
@@ -0,0 +1,232 @@
|
|
1
|
+
/*!
|
2
|
+
* Copyright 2022 Esri
|
3
|
+
* Licensed under the Apache License, Version 2.0
|
4
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
5
|
+
*/
|
6
|
+
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
7
|
+
import { g as getElementProp, t as toAriaBoolean } from './dom.js';
|
8
|
+
import { d as defineCustomElement$1 } from './icon.js';
|
9
|
+
|
10
|
+
/*!
|
11
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
12
|
+
* See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
|
13
|
+
* v1.0.0-beta.97
|
14
|
+
*/
|
15
|
+
const CSS = {
|
16
|
+
containerLink: "container--link",
|
17
|
+
containerSmall: "container--s",
|
18
|
+
containerMedium: "container--m",
|
19
|
+
containerLarge: "container--l",
|
20
|
+
containerMulti: "container--multi-selection",
|
21
|
+
containerSingle: "container--single-selection",
|
22
|
+
containerNone: "container--none-selection"
|
23
|
+
};
|
24
|
+
|
25
|
+
const dropdownItemCss = "@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}.container--s{padding-block:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem;-webkit-padding-end:0.5rem;padding-inline-end:0.5rem;-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}.container--m{padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-padding-end:0.75rem;padding-inline-end:0.75rem;-webkit-padding-start:2rem;padding-inline-start:2rem}.container--l{padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-padding-end:1rem;padding-inline-end:1rem;-webkit-padding-start:2.5rem;padding-inline-start:2.5rem}.container--s.container--none-selection{-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}.container--s.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}.container--m.container--none-selection{-webkit-padding-start:0.5rem;padding-inline-start:0.5rem}.container--m.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}.container--l.container--none-selection{-webkit-padding-start:0.75rem;padding-inline-start:0.75rem}.container--l.container--none-selection .dropdown-link{-webkit-padding-start:0px;padding-inline-start:0px}:host{position:relative;display:flex;flex-grow:1;align-items:center}.container{position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);text-align:start}.dropdown-item-content{flex:1 1 auto;-webkit-padding-end:auto;padding-inline-end:auto;-webkit-padding-start:0.25rem;padding-inline-start:0.25rem}:host,.container--link a{outline-color:transparent}:host(:focus){outline:2px solid transparent;outline:2px solid var(--calcite-ui-brand);outline-offset:-2px}.container--link{padding:0px}.container--link a{position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;color:var(--calcite-ui-text-3);-webkit-text-decoration-line:none;text-decoration-line:none;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1)}.container--s .dropdown-link{padding-block:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem;-webkit-padding-end:0.5rem;padding-inline-end:0.5rem;-webkit-padding-start:1.5rem;padding-inline-start:1.5rem}.container--m .dropdown-link{padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;-webkit-padding-end:0.75rem;padding-inline-end:0.75rem;-webkit-padding-start:2rem;padding-inline-start:2rem}.container--l .dropdown-link{padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;-webkit-padding-end:1rem;padding-inline-end:1rem;-webkit-padding-start:2.5rem;padding-inline-start:2.5rem}:host(:hover) .container,:host(:active) .container{background-color:var(--calcite-ui-foreground-2);color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host(:hover) .container--link .dropdown-link,:host(:active) .container--link .dropdown-link{color:var(--calcite-ui-text-1)}:host(:focus) .container{color:var(--calcite-ui-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host(:active) .container{background-color:var(--calcite-ui-foreground-3)}:host(:hover) .container:before,:host(:active) .container:before,:host(:focus) .container:before{opacity:1}:host([selected]) .container:not(.container--none-selection),:host([selected]) .container--link .dropdown-link{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-ui-text-1)}:host([selected]) .container:not(.container--none-selection):before,:host([selected]) .container--link .dropdown-link:before{opacity:1;color:var(--calcite-ui-brand)}:host([selected]) .container:not(.container--none-selection) calcite-icon,:host([selected]) .container--link .dropdown-link calcite-icon{color:var(--calcite-ui-brand)}.container--multi-selection:before,.container--none-selection:before{display:none}.container--s:before{inset-inline-start:0.5rem}.container--m:before{inset-inline-start:0.75rem}.container--l:before{inset-inline-start:1rem}.dropdown-item-icon{position:absolute;opacity:0;transition-duration:150ms;transition-timing-function:cubic-bezier(0.4, 0, 0.2, 1);transform:scale(0.9)}.container--s .dropdown-item-icon{inset-inline-start:0.25rem}.container--m .dropdown-item-icon{inset-inline-start:0.5rem}.container--l .dropdown-item-icon{inset-inline-start:0.75rem}:host(:hover) .dropdown-item-icon{color:var(--calcite-ui-border-1);opacity:1}:host([active]) .dropdown-item-icon{color:var(--calcite-ui-brand);opacity:1}.container--s .dropdown-item-icon-start{-webkit-margin-end:0.5rem;margin-inline-end:0.5rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--s .dropdown-item-icon-end{-webkit-margin-start:0.5rem;margin-inline-start:0.5rem}.container--m .dropdown-item-icon-start{-webkit-margin-end:0.75rem;margin-inline-end:0.75rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--m .dropdown-item-icon-end{-webkit-margin-start:0.75rem;margin-inline-start:0.75rem}.container--l .dropdown-item-icon-start{-webkit-margin-end:1rem;margin-inline-end:1rem;-webkit-margin-start:0.25rem;margin-inline-start:0.25rem}.container--l .dropdown-item-icon-end{-webkit-margin-start:1rem;margin-inline-start:1rem}";
|
26
|
+
|
27
|
+
const DropdownItem = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
|
28
|
+
constructor() {
|
29
|
+
super();
|
30
|
+
this.__registerHost();
|
31
|
+
this.__attachShadow();
|
32
|
+
this.calciteInternalDropdownItemSelect = createEvent(this, "calciteInternalDropdownItemSelect", 6);
|
33
|
+
this.calciteInternalDropdownItemKeyEvent = createEvent(this, "calciteInternalDropdownItemKeyEvent", 6);
|
34
|
+
this.calciteInternalDropdownCloseRequest = createEvent(this, "calciteInternalDropdownCloseRequest", 6);
|
35
|
+
//--------------------------------------------------------------------------
|
36
|
+
//
|
37
|
+
// Public Properties
|
38
|
+
//
|
39
|
+
//--------------------------------------------------------------------------
|
40
|
+
/**
|
41
|
+
* Indicates whether the item is active.
|
42
|
+
*
|
43
|
+
* @deprecated Use selected instead.
|
44
|
+
*/
|
45
|
+
this.active = false;
|
46
|
+
/** When true, item is selected */
|
47
|
+
this.selected = false;
|
48
|
+
}
|
49
|
+
activeHandler(value) {
|
50
|
+
this.selected = value;
|
51
|
+
}
|
52
|
+
selectedHandler(value) {
|
53
|
+
this.active = value;
|
54
|
+
}
|
55
|
+
//--------------------------------------------------------------------------
|
56
|
+
//
|
57
|
+
// Public Methods
|
58
|
+
//
|
59
|
+
//--------------------------------------------------------------------------
|
60
|
+
/** Sets focus on the component. */
|
61
|
+
async setFocus() {
|
62
|
+
var _a;
|
63
|
+
(_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
|
64
|
+
}
|
65
|
+
//--------------------------------------------------------------------------
|
66
|
+
//
|
67
|
+
// Lifecycle
|
68
|
+
//
|
69
|
+
//--------------------------------------------------------------------------
|
70
|
+
componentWillLoad() {
|
71
|
+
this.initialize();
|
72
|
+
}
|
73
|
+
connectedCallback() {
|
74
|
+
const isSelected = this.selected || this.active;
|
75
|
+
if (isSelected) {
|
76
|
+
this.activeHandler(isSelected);
|
77
|
+
this.selectedHandler(isSelected);
|
78
|
+
}
|
79
|
+
this.initialize();
|
80
|
+
}
|
81
|
+
render() {
|
82
|
+
const scale = getElementProp(this.el, "scale", "m");
|
83
|
+
const iconStartEl = (h("calcite-icon", { class: "dropdown-item-icon-start", flipRtl: this.iconFlipRtl === "start" || this.iconFlipRtl === "both", icon: this.iconStart, scale: "s" }));
|
84
|
+
const contentNode = (h("span", { class: "dropdown-item-content" }, h("slot", null)));
|
85
|
+
const iconEndEl = (h("calcite-icon", { class: "dropdown-item-icon-end", flipRtl: this.iconFlipRtl === "end" || this.iconFlipRtl === "both", icon: this.iconEnd, scale: "s" }));
|
86
|
+
const slottedContent = this.iconStart && this.iconEnd
|
87
|
+
? [iconStartEl, contentNode, iconEndEl]
|
88
|
+
: this.iconStart
|
89
|
+
? [iconStartEl, h("slot", null)]
|
90
|
+
: this.iconEnd
|
91
|
+
? [contentNode, iconEndEl]
|
92
|
+
: contentNode;
|
93
|
+
const contentEl = !this.href ? (slottedContent) : (h("a", { "aria-label": this.label, class: "dropdown-link", href: this.href, ref: (el) => (this.childLink = el), rel: this.rel, target: this.target }, slottedContent));
|
94
|
+
const itemRole = this.href
|
95
|
+
? null
|
96
|
+
: this.selectionMode === "single"
|
97
|
+
? "menuitemradio"
|
98
|
+
: this.selectionMode === "multi"
|
99
|
+
? "menuitemcheckbox"
|
100
|
+
: "menuitem";
|
101
|
+
const itemAria = this.selectionMode !== "none" ? toAriaBoolean(this.selected) : null;
|
102
|
+
return (h(Host, { "aria-checked": itemAria, role: itemRole, tabindex: "0" }, h("div", { class: {
|
103
|
+
container: true,
|
104
|
+
[CSS.containerLink]: !!this.href,
|
105
|
+
[CSS.containerSmall]: scale === "s",
|
106
|
+
[CSS.containerMedium]: scale === "m",
|
107
|
+
[CSS.containerLarge]: scale === "l",
|
108
|
+
[CSS.containerMulti]: this.selectionMode === "multi",
|
109
|
+
[CSS.containerSingle]: this.selectionMode === "single",
|
110
|
+
[CSS.containerNone]: this.selectionMode === "none"
|
111
|
+
} }, this.selectionMode !== "none" ? (h("calcite-icon", { class: "dropdown-item-icon", icon: this.selectionMode === "multi" ? "check" : "bullet-point", scale: "s" })) : null, contentEl)));
|
112
|
+
}
|
113
|
+
//--------------------------------------------------------------------------
|
114
|
+
//
|
115
|
+
// Event Listeners
|
116
|
+
//
|
117
|
+
//--------------------------------------------------------------------------
|
118
|
+
onClick() {
|
119
|
+
this.emitRequestedItem();
|
120
|
+
}
|
121
|
+
keyDownHandler(event) {
|
122
|
+
switch (event.key) {
|
123
|
+
case " ":
|
124
|
+
case "Enter":
|
125
|
+
this.emitRequestedItem();
|
126
|
+
if (this.href) {
|
127
|
+
this.childLink.click();
|
128
|
+
}
|
129
|
+
event.preventDefault();
|
130
|
+
break;
|
131
|
+
case "Escape":
|
132
|
+
this.calciteInternalDropdownCloseRequest.emit();
|
133
|
+
event.preventDefault();
|
134
|
+
break;
|
135
|
+
case "Tab":
|
136
|
+
this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
|
137
|
+
break;
|
138
|
+
case "ArrowUp":
|
139
|
+
case "ArrowDown":
|
140
|
+
case "Home":
|
141
|
+
case "End":
|
142
|
+
event.preventDefault();
|
143
|
+
this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
|
144
|
+
break;
|
145
|
+
}
|
146
|
+
}
|
147
|
+
updateActiveItemOnChange(event) {
|
148
|
+
const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
|
149
|
+
if (parentEmittedChange) {
|
150
|
+
this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
|
151
|
+
this.requestedDropdownItem = event.detail.requestedDropdownItem;
|
152
|
+
this.determineActiveItem();
|
153
|
+
}
|
154
|
+
event.stopPropagation();
|
155
|
+
}
|
156
|
+
//--------------------------------------------------------------------------
|
157
|
+
//
|
158
|
+
// Private Methods
|
159
|
+
//
|
160
|
+
//--------------------------------------------------------------------------
|
161
|
+
initialize() {
|
162
|
+
this.selectionMode = getElementProp(this.el, "selection-mode", "single");
|
163
|
+
this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
|
164
|
+
if (this.selectionMode === "none") {
|
165
|
+
this.selected = false;
|
166
|
+
}
|
167
|
+
}
|
168
|
+
determineActiveItem() {
|
169
|
+
switch (this.selectionMode) {
|
170
|
+
case "multi":
|
171
|
+
if (this.el === this.requestedDropdownItem) {
|
172
|
+
this.selected = !this.selected;
|
173
|
+
}
|
174
|
+
break;
|
175
|
+
case "single":
|
176
|
+
if (this.el === this.requestedDropdownItem) {
|
177
|
+
this.selected = true;
|
178
|
+
}
|
179
|
+
else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
|
180
|
+
this.selected = false;
|
181
|
+
}
|
182
|
+
break;
|
183
|
+
case "none":
|
184
|
+
this.selected = false;
|
185
|
+
break;
|
186
|
+
}
|
187
|
+
}
|
188
|
+
emitRequestedItem() {
|
189
|
+
this.calciteInternalDropdownItemSelect.emit({
|
190
|
+
requestedDropdownItem: this.el,
|
191
|
+
requestedDropdownGroup: this.parentDropdownGroupEl
|
192
|
+
});
|
193
|
+
}
|
194
|
+
get el() { return this; }
|
195
|
+
static get watchers() { return {
|
196
|
+
"active": ["activeHandler"],
|
197
|
+
"selected": ["selectedHandler"]
|
198
|
+
}; }
|
199
|
+
static get style() { return dropdownItemCss; }
|
200
|
+
}, [1, "calcite-dropdown-item", {
|
201
|
+
"active": [1540],
|
202
|
+
"selected": [1540],
|
203
|
+
"iconFlipRtl": [513, "icon-flip-rtl"],
|
204
|
+
"iconStart": [513, "icon-start"],
|
205
|
+
"iconEnd": [513, "icon-end"],
|
206
|
+
"href": [513],
|
207
|
+
"label": [1],
|
208
|
+
"rel": [513],
|
209
|
+
"target": [513],
|
210
|
+
"setFocus": [64]
|
211
|
+
}, [[0, "click", "onClick"], [0, "keydown", "keyDownHandler"], [16, "calciteInternalDropdownItemChange", "updateActiveItemOnChange"]]]);
|
212
|
+
function defineCustomElement() {
|
213
|
+
if (typeof customElements === "undefined") {
|
214
|
+
return;
|
215
|
+
}
|
216
|
+
const components = ["calcite-dropdown-item", "calcite-icon"];
|
217
|
+
components.forEach(tagName => { switch (tagName) {
|
218
|
+
case "calcite-dropdown-item":
|
219
|
+
if (!customElements.get(tagName)) {
|
220
|
+
customElements.define(tagName, DropdownItem);
|
221
|
+
}
|
222
|
+
break;
|
223
|
+
case "calcite-icon":
|
224
|
+
if (!customElements.get(tagName)) {
|
225
|
+
defineCustomElement$1();
|
226
|
+
}
|
227
|
+
break;
|
228
|
+
} });
|
229
|
+
}
|
230
|
+
defineCustomElement();
|
231
|
+
|
232
|
+
export { DropdownItem as D, defineCustomElement as d };
|