@esri/solutions-components 0.8.8 → 0.8.9
Sign up to get free protection for your applications and to get access to all the features.
- package/dist/assets/t9n/crowdsource-reporter/resources.json +3 -1
- package/dist/assets/t9n/crowdsource-reporter/resources_en.json +3 -1
- package/dist/cjs/{calcite-action-menu_2.cjs.entry.js → calcite-action-menu_3.cjs.entry.js} +114 -7
- package/dist/cjs/calcite-alert_4.cjs.entry.js +46 -5
- package/dist/cjs/{calcite-input-date-picker_3.cjs.entry.js → calcite-block_5.cjs.entry.js} +691 -13
- package/dist/cjs/{calcite-combobox_5.cjs.entry.js → calcite-combobox_3.cjs.entry.js} +876 -844
- package/dist/cjs/calcite-dropdown_4.cjs.entry.js +1023 -0
- package/dist/cjs/{calcite-flow_5.cjs.entry.js → calcite-flow_6.cjs.entry.js} +327 -2
- package/dist/cjs/card-manager_3.cjs.entry.js +5 -5
- package/dist/cjs/crowdsource-manager.cjs.entry.js +1 -1
- package/dist/cjs/crowdsource-reporter.cjs.entry.js +122 -21
- package/dist/cjs/{downloadUtils-8b05d7cc.js → downloadUtils-dc349b1a.js} +2 -2
- package/dist/cjs/{index.es-e7587227.js → index.es-1830a1e6.js} +2 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/cjs/map-select-tools_3.cjs.entry.js +8 -8
- package/dist/cjs/{mapViewUtils-3e0fa457.js → mapViewUtils-9dc05308.js} +11 -5
- package/dist/cjs/public-notification.cjs.entry.js +2 -2
- package/dist/cjs/solutions-components.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +1 -0
- package/dist/collection/components/create-feature/create-feature.js +18 -0
- package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.css +16 -0
- package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.js +155 -35
- package/dist/collection/components/feature-details/feature-details.css +18 -0
- package/dist/collection/components/feature-details/feature-details.js +500 -0
- package/dist/collection/components/feature-details/test/feature-details.e2e.js +14 -0
- package/dist/collection/components/feature-details/test/feature-details.spec.js +22 -0
- package/dist/collection/components/feature-list/feature-list.js +14 -1
- package/dist/collection/components/info-card/info-card.css +15 -5
- package/dist/collection/components/info-card/info-card.js +178 -5
- package/dist/collection/components/layer-table/layer-table.js +2 -2
- package/dist/collection/components/map-card/map-card.js +1 -1
- package/dist/collection/components/map-select-tools/map-select-tools.js +5 -5
- package/dist/collection/components/refine-selection/refine-selection.js +1 -1
- package/dist/collection/demos/crowdsource-reporter.html +115 -1
- package/dist/collection/utils/mapViewUtils.js +11 -5
- package/dist/collection/utils/mapViewUtils.ts +13 -5
- package/dist/components/create-feature2.js +4 -0
- package/dist/components/crowdsource-reporter.js +270 -81
- package/dist/components/feature-details.d.ts +11 -0
- package/dist/components/feature-details.js +11 -0
- package/dist/components/feature-details2.js +449 -0
- package/dist/components/feature-list2.js +14 -1
- package/dist/components/info-card2.js +53 -5
- package/dist/components/layer-table2.js +2 -2
- package/dist/components/map-card2.js +1 -1
- package/dist/components/map-select-tools2.js +5 -5
- package/dist/components/mapViewUtils.js +11 -5
- package/dist/components/refine-selection2.js +1 -1
- package/dist/esm/{calcite-action-menu_2.entry.js → calcite-action-menu_3.entry.js} +118 -12
- package/dist/esm/calcite-alert_4.entry.js +46 -5
- package/dist/esm/{calcite-input-date-picker_3.entry.js → calcite-block_5.entry.js} +688 -12
- package/dist/esm/{calcite-combobox_5.entry.js → calcite-combobox_3.entry.js} +878 -844
- package/dist/esm/calcite-date-picker-day_3.entry.js +1 -1
- package/dist/esm/calcite-dropdown_4.entry.js +1016 -0
- package/dist/esm/{calcite-flow_5.entry.js → calcite-flow_6.entry.js} +327 -3
- package/dist/esm/card-manager_3.entry.js +5 -5
- package/dist/esm/crowdsource-manager.entry.js +1 -1
- package/dist/esm/crowdsource-reporter.entry.js +122 -21
- package/dist/esm/{date-5630530d.js → date-0c026a8b.js} +1 -1
- package/dist/esm/{downloadUtils-0c1e4d7b.js → downloadUtils-df4f21f6.js} +2 -2
- package/dist/esm/{index.es-286e3cfa.js → index.es-904fb846.js} +2 -2
- package/dist/esm/loader.js +1 -1
- package/dist/esm/map-select-tools_3.entry.js +8 -8
- package/dist/esm/{mapViewUtils-253178f1.js → mapViewUtils-2ec19fb0.js} +11 -5
- package/dist/esm/public-notification.entry.js +2 -2
- package/dist/esm/solutions-components.js +1 -1
- package/dist/solutions-components/demos/crowdsource-reporter.html +115 -1
- package/dist/solutions-components/{p-813fd8a4.entry.js → p-29f518fd.entry.js} +2 -2
- package/dist/solutions-components/{p-13ca3b00.entry.js → p-452fd697.entry.js} +1 -1
- package/dist/solutions-components/p-511b1c91.entry.js +23 -0
- package/dist/solutions-components/p-577efb16.js +36 -0
- package/dist/solutions-components/{p-94de9279.js → p-5817d78c.js} +1 -1
- package/dist/solutions-components/p-602cd811.entry.js +17 -0
- package/dist/solutions-components/{p-15f9624a.entry.js → p-6557b703.entry.js} +1 -1
- package/dist/solutions-components/p-7269c49b.entry.js +6 -0
- package/dist/solutions-components/p-760bd17e.entry.js +6 -0
- package/dist/solutions-components/p-95fea07a.entry.js +17 -0
- package/dist/solutions-components/{p-212b02e7.js → p-ae4d86e8.js} +1 -1
- package/dist/solutions-components/{p-038fcd93.entry.js → p-c273ab7a.entry.js} +1 -1
- package/dist/solutions-components/p-d742b915.entry.js +29 -0
- package/dist/solutions-components/p-dfad61a8.entry.js +24 -0
- package/dist/solutions-components/{p-331b5d1e.js → p-fca434c8.js} +2 -2
- package/dist/solutions-components/p-fd82a00f.entry.js +6 -0
- package/dist/solutions-components/solutions-components.esm.js +1 -1
- package/dist/solutions-components/utils/mapViewUtils.ts +13 -5
- package/dist/types/components/create-feature/create-feature.d.ts +4 -4
- package/dist/types/components/crowdsource-reporter/crowdsource-reporter.d.ts +91 -10
- package/dist/types/components/feature-details/feature-details.d.ts +151 -0
- package/dist/types/components/feature-list/feature-list.d.ts +6 -0
- package/dist/types/components/info-card/info-card.d.ts +33 -1
- package/dist/types/components.d.ts +129 -12
- package/dist/types/preact.d.ts +6 -1
- package/dist/types/utils/mapViewUtils.d.ts +5 -3
- package/package.json +1 -1
- package/dist/cjs/calcite-block_2.cjs.entry.js +0 -652
- package/dist/cjs/calcite-graph_2.cjs.entry.js +0 -1055
- package/dist/cjs/calcite-scrim.cjs.entry.js +0 -125
- package/dist/cjs/utils-7bc7f595.js +0 -64
- package/dist/esm/calcite-block_2.entry.js +0 -647
- package/dist/esm/calcite-graph_2.entry.js +0 -1050
- package/dist/esm/calcite-scrim.entry.js +0 -121
- package/dist/esm/utils-9fb4104a.js +0 -61
- package/dist/solutions-components/p-04c37d69.entry.js +0 -17
- package/dist/solutions-components/p-0b92e4b1.entry.js +0 -11
- package/dist/solutions-components/p-238d3b5f.entry.js +0 -6
- package/dist/solutions-components/p-3af79063.js +0 -36
- package/dist/solutions-components/p-80b11ec1.entry.js +0 -17
- package/dist/solutions-components/p-a3a11749.entry.js +0 -6
- package/dist/solutions-components/p-aec06ce4.entry.js +0 -18
- package/dist/solutions-components/p-bfdf89c2.js +0 -11
- package/dist/solutions-components/p-c4ff3b52.entry.js +0 -17
- package/dist/solutions-components/p-ced067bd.entry.js +0 -17
- package/dist/solutions-components/p-d136eab0.entry.js +0 -23
- package/dist/solutions-components/p-e0446d5b.entry.js +0 -6
@@ -0,0 +1,1023 @@
|
|
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
|
+
'use strict';
|
7
|
+
|
8
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
9
|
+
|
10
|
+
const index = require('./index-105cf2b9.js');
|
11
|
+
const dom = require('./dom-c9c2c835.js');
|
12
|
+
const floatingUi = require('./floating-ui-984cc970.js');
|
13
|
+
const guid = require('./guid-ae73cd27.js');
|
14
|
+
const interactive = require('./interactive-3ab7044d.js');
|
15
|
+
const key = require('./key-c5504030.js');
|
16
|
+
const loadable = require('./loadable-5a794992.js');
|
17
|
+
const observers = require('./observers-db4527e4.js');
|
18
|
+
const openCloseComponent = require('./openCloseComponent-19a769d0.js');
|
19
|
+
const component = require('./component-ac7c3bd8.js');
|
20
|
+
const locale = require('./locale-3d0a4bc2.js');
|
21
|
+
const mapViewUtils = require('./mapViewUtils-9dc05308.js');
|
22
|
+
const publicNotificationStore = require('./publicNotificationStore-e790601d.js');
|
23
|
+
require('./resources-9447c777.js');
|
24
|
+
require('./debounce-30afab47.js');
|
25
|
+
require('./browser-d08a5f99.js');
|
26
|
+
require('./esri-loader-ce6c3d3d.js');
|
27
|
+
require('./_commonjsHelpers-480c2e77.js');
|
28
|
+
require('./interfaces-7cd0a48a.js');
|
29
|
+
require('./index-ae65e42f.js');
|
30
|
+
|
31
|
+
/*!
|
32
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
33
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
34
|
+
* v2.4.0
|
35
|
+
*/
|
36
|
+
const SLOTS = {
|
37
|
+
dropdownTrigger: "trigger",
|
38
|
+
};
|
39
|
+
|
40
|
+
const dropdownCss = ":host([disabled]){cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}:host{display:inline-block}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}:host .calcite-dropdown-wrapper{--calcite-floating-ui-z-index:var(--calcite-z-index-dropdown);display:block;position:absolute;z-index:var(--calcite-floating-ui-z-index);visibility:hidden}.calcite-dropdown-wrapper .calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:var(--calcite-z-index);border-radius:0.25rem}.calcite-dropdown-wrapper[data-placement^=bottom] .calcite-floating-ui-anim{transform:translateY(-5px)}.calcite-dropdown-wrapper[data-placement^=top] .calcite-floating-ui-anim{transform:translateY(5px)}.calcite-dropdown-wrapper[data-placement^=left] .calcite-floating-ui-anim{transform:translateX(5px)}.calcite-dropdown-wrapper[data-placement^=right] .calcite-floating-ui-anim{transform:translateX(-5px)}.calcite-dropdown-wrapper[data-placement] .calcite-floating-ui-anim--active{opacity:1;transform:translate(0)}:host([open]) .calcite-dropdown-wrapper{visibility:visible}:host .calcite-dropdown-content{max-block-size:45vh;inline-size:auto;overflow-y:auto;overflow-x:hidden;background-color:var(--calcite-color-foreground-1);inline-size:var(--calcite-dropdown-width)}.calcite-trigger-container{position:relative;display:flex;block-size:100%;flex:1 1 auto;word-wrap:break-word;word-break:break-word}@media (forced-colors: active){:host([open]) .calcite-dropdown-wrapper{border:1px solid canvasText}}:host([width-scale=s]){--calcite-dropdown-width:12rem}:host([width-scale=m]){--calcite-dropdown-width:14rem}:host([width-scale=l]){--calcite-dropdown-width:16rem}:host([hidden]){display:none}[hidden]{display:none}";
|
41
|
+
|
42
|
+
const Dropdown = class {
|
43
|
+
constructor(hostRef) {
|
44
|
+
index.registerInstance(this, hostRef);
|
45
|
+
this.calciteDropdownSelect = index.createEvent(this, "calciteDropdownSelect", 6);
|
46
|
+
this.calciteDropdownBeforeClose = index.createEvent(this, "calciteDropdownBeforeClose", 6);
|
47
|
+
this.calciteDropdownClose = index.createEvent(this, "calciteDropdownClose", 6);
|
48
|
+
this.calciteDropdownBeforeOpen = index.createEvent(this, "calciteDropdownBeforeOpen", 6);
|
49
|
+
this.calciteDropdownOpen = index.createEvent(this, "calciteDropdownOpen", 6);
|
50
|
+
this.items = [];
|
51
|
+
this.groups = [];
|
52
|
+
this.mutationObserver = observers.createObserver("mutation", () => this.updateItems());
|
53
|
+
this.resizeObserver = observers.createObserver("resize", (entries) => this.resizeObserverCallback(entries));
|
54
|
+
this.openTransitionProp = "opacity";
|
55
|
+
this.guid = `calcite-dropdown-${guid.guid()}`;
|
56
|
+
this.defaultAssignedElements = [];
|
57
|
+
//--------------------------------------------------------------------------
|
58
|
+
//
|
59
|
+
// Private Methods
|
60
|
+
//
|
61
|
+
//--------------------------------------------------------------------------
|
62
|
+
this.slotChangeHandler = (event) => {
|
63
|
+
this.defaultAssignedElements = event.target.assignedElements({
|
64
|
+
flatten: true,
|
65
|
+
});
|
66
|
+
this.updateItems();
|
67
|
+
};
|
68
|
+
this.setFilteredPlacements = () => {
|
69
|
+
const { el, flipPlacements } = this;
|
70
|
+
this.filteredFlipPlacements = flipPlacements
|
71
|
+
? floatingUi.filterComputedPlacements(flipPlacements, el)
|
72
|
+
: null;
|
73
|
+
};
|
74
|
+
this.updateTriggers = (event) => {
|
75
|
+
this.triggers = event.target.assignedElements({
|
76
|
+
flatten: true,
|
77
|
+
});
|
78
|
+
this.reposition(true);
|
79
|
+
};
|
80
|
+
this.updateItems = () => {
|
81
|
+
this.items = this.groups
|
82
|
+
.map((group) => Array.from(group === null || group === void 0 ? void 0 : group.querySelectorAll("calcite-dropdown-item")))
|
83
|
+
.reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
|
84
|
+
this.updateSelectedItems();
|
85
|
+
this.reposition(true);
|
86
|
+
this.items.forEach((item) => (item.scale = this.scale));
|
87
|
+
};
|
88
|
+
this.updateGroups = (event) => {
|
89
|
+
const groups = event.target
|
90
|
+
.assignedElements({ flatten: true })
|
91
|
+
.filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-dropdown-group"));
|
92
|
+
this.groups = groups;
|
93
|
+
this.updateItems();
|
94
|
+
};
|
95
|
+
this.resizeObserverCallback = (entries) => {
|
96
|
+
entries.forEach((entry) => {
|
97
|
+
const { target } = entry;
|
98
|
+
if (target === this.referenceEl) {
|
99
|
+
this.setDropdownWidth();
|
100
|
+
}
|
101
|
+
else if (target === this.scrollerEl) {
|
102
|
+
this.setMaxScrollerHeight();
|
103
|
+
}
|
104
|
+
});
|
105
|
+
};
|
106
|
+
this.setDropdownWidth = () => {
|
107
|
+
const { referenceEl, scrollerEl } = this;
|
108
|
+
const referenceElWidth = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.clientWidth;
|
109
|
+
if (!referenceElWidth || !scrollerEl) {
|
110
|
+
return;
|
111
|
+
}
|
112
|
+
scrollerEl.style.minWidth = `${referenceElWidth}px`;
|
113
|
+
};
|
114
|
+
this.setMaxScrollerHeight = () => {
|
115
|
+
const { scrollerEl } = this;
|
116
|
+
if (!scrollerEl) {
|
117
|
+
return;
|
118
|
+
}
|
119
|
+
this.reposition(true);
|
120
|
+
const maxScrollerHeight = this.getMaxScrollerHeight();
|
121
|
+
scrollerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
|
122
|
+
this.reposition(true);
|
123
|
+
};
|
124
|
+
this.setScrollerAndTransitionEl = (el) => {
|
125
|
+
this.resizeObserver.observe(el);
|
126
|
+
this.scrollerEl = el;
|
127
|
+
this.transitionEl = el;
|
128
|
+
};
|
129
|
+
this.setReferenceEl = (el) => {
|
130
|
+
this.referenceEl = el;
|
131
|
+
floatingUi.connectFloatingUI(this, this.referenceEl, this.floatingEl);
|
132
|
+
this.resizeObserver.observe(el);
|
133
|
+
};
|
134
|
+
this.setFloatingEl = (el) => {
|
135
|
+
this.floatingEl = el;
|
136
|
+
floatingUi.connectFloatingUI(this, this.referenceEl, this.floatingEl);
|
137
|
+
};
|
138
|
+
this.keyDownHandler = (event) => {
|
139
|
+
if (!event.composedPath().includes(this.referenceEl)) {
|
140
|
+
return;
|
141
|
+
}
|
142
|
+
const { defaultPrevented, key: key$1 } = event;
|
143
|
+
if (defaultPrevented) {
|
144
|
+
return;
|
145
|
+
}
|
146
|
+
if (this.open) {
|
147
|
+
if (key$1 === "Escape") {
|
148
|
+
this.closeCalciteDropdown();
|
149
|
+
event.preventDefault();
|
150
|
+
return;
|
151
|
+
}
|
152
|
+
else if (event.shiftKey && key$1 === "Tab") {
|
153
|
+
this.closeCalciteDropdown();
|
154
|
+
event.preventDefault();
|
155
|
+
return;
|
156
|
+
}
|
157
|
+
}
|
158
|
+
if (key.isActivationKey(key$1)) {
|
159
|
+
this.openCalciteDropdown();
|
160
|
+
event.preventDefault();
|
161
|
+
}
|
162
|
+
else if (key$1 === "Escape") {
|
163
|
+
this.closeCalciteDropdown();
|
164
|
+
event.preventDefault();
|
165
|
+
}
|
166
|
+
};
|
167
|
+
this.focusOnFirstActiveOrFirstItem = () => {
|
168
|
+
this.getFocusableElement(this.getTraversableItems().find((item) => item.selected) || this.items[0]);
|
169
|
+
};
|
170
|
+
this.toggleOpenEnd = () => {
|
171
|
+
this.focusOnFirstActiveOrFirstItem();
|
172
|
+
this.el.removeEventListener("calciteDropdownOpen", this.toggleOpenEnd);
|
173
|
+
};
|
174
|
+
this.openCalciteDropdown = () => {
|
175
|
+
this.open = !this.open;
|
176
|
+
if (this.open) {
|
177
|
+
this.el.addEventListener("calciteDropdownOpen", this.toggleOpenEnd);
|
178
|
+
}
|
179
|
+
};
|
180
|
+
this.open = false;
|
181
|
+
this.closeOnSelectDisabled = false;
|
182
|
+
this.disabled = false;
|
183
|
+
this.flipPlacements = undefined;
|
184
|
+
this.maxItems = 0;
|
185
|
+
this.overlayPositioning = "absolute";
|
186
|
+
this.placement = floatingUi.defaultMenuPlacement;
|
187
|
+
this.selectedItems = [];
|
188
|
+
this.type = "click";
|
189
|
+
this.widthScale = undefined;
|
190
|
+
this.scale = "m";
|
191
|
+
}
|
192
|
+
openHandler() {
|
193
|
+
openCloseComponent.onToggleOpenCloseComponent(this);
|
194
|
+
if (this.disabled) {
|
195
|
+
this.open = false;
|
196
|
+
return;
|
197
|
+
}
|
198
|
+
this.reposition(true);
|
199
|
+
}
|
200
|
+
handleDisabledChange(value) {
|
201
|
+
if (!value) {
|
202
|
+
this.open = false;
|
203
|
+
}
|
204
|
+
}
|
205
|
+
flipPlacementsHandler() {
|
206
|
+
this.setFilteredPlacements();
|
207
|
+
this.reposition(true);
|
208
|
+
}
|
209
|
+
maxItemsHandler() {
|
210
|
+
this.setMaxScrollerHeight();
|
211
|
+
}
|
212
|
+
overlayPositioningHandler() {
|
213
|
+
this.reposition(true);
|
214
|
+
}
|
215
|
+
placementHandler() {
|
216
|
+
this.reposition(true);
|
217
|
+
}
|
218
|
+
handlePropsChange() {
|
219
|
+
this.updateItems();
|
220
|
+
}
|
221
|
+
//--------------------------------------------------------------------------
|
222
|
+
//
|
223
|
+
// Public Methods
|
224
|
+
//
|
225
|
+
//--------------------------------------------------------------------------
|
226
|
+
/** Sets focus on the component's first focusable element. */
|
227
|
+
async setFocus() {
|
228
|
+
await loadable.componentFocusable(this);
|
229
|
+
this.el.focus();
|
230
|
+
}
|
231
|
+
//--------------------------------------------------------------------------
|
232
|
+
//
|
233
|
+
// Lifecycle
|
234
|
+
//
|
235
|
+
//--------------------------------------------------------------------------
|
236
|
+
connectedCallback() {
|
237
|
+
var _a;
|
238
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
|
239
|
+
this.setFilteredPlacements();
|
240
|
+
this.reposition(true);
|
241
|
+
if (this.open) {
|
242
|
+
this.openHandler();
|
243
|
+
openCloseComponent.onToggleOpenCloseComponent(this);
|
244
|
+
}
|
245
|
+
interactive.connectInteractive(this);
|
246
|
+
this.updateItems();
|
247
|
+
floatingUi.connectFloatingUI(this, this.referenceEl, this.floatingEl);
|
248
|
+
}
|
249
|
+
componentWillLoad() {
|
250
|
+
loadable.setUpLoadableComponent(this);
|
251
|
+
}
|
252
|
+
componentDidLoad() {
|
253
|
+
loadable.setComponentLoaded(this);
|
254
|
+
this.reposition(true);
|
255
|
+
}
|
256
|
+
componentDidRender() {
|
257
|
+
interactive.updateHostInteraction(this);
|
258
|
+
}
|
259
|
+
disconnectedCallback() {
|
260
|
+
var _a, _b;
|
261
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
262
|
+
(_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
|
263
|
+
interactive.disconnectInteractive(this);
|
264
|
+
floatingUi.disconnectFloatingUI(this, this.referenceEl, this.floatingEl);
|
265
|
+
}
|
266
|
+
render() {
|
267
|
+
const { open, guid } = this;
|
268
|
+
return (index.h(index.Host, null, index.h(interactive.InteractiveContainer, { disabled: this.disabled }, index.h("div", { class: "calcite-trigger-container", id: `${guid}-menubutton`, onClick: this.openCalciteDropdown, onKeyDown: this.keyDownHandler,
|
269
|
+
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
|
270
|
+
ref: this.setReferenceEl }, index.h("slot", { "aria-controls": `${guid}-menu`, "aria-expanded": dom.toAriaBoolean(open), "aria-haspopup": "menu", name: SLOTS.dropdownTrigger, onSlotchange: this.updateTriggers })), index.h("div", { "aria-hidden": dom.toAriaBoolean(!open), class: "calcite-dropdown-wrapper",
|
271
|
+
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
|
272
|
+
ref: this.setFloatingEl }, index.h("div", { "aria-labelledby": `${guid}-menubutton`, class: {
|
273
|
+
["calcite-dropdown-content"]: true,
|
274
|
+
[floatingUi.FloatingCSS.animation]: true,
|
275
|
+
[floatingUi.FloatingCSS.animationActive]: open,
|
276
|
+
}, id: `${guid}-menu`, role: "menu",
|
277
|
+
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
|
278
|
+
ref: this.setScrollerAndTransitionEl }, index.h("slot", { onSlotchange: this.updateGroups }))))));
|
279
|
+
}
|
280
|
+
//--------------------------------------------------------------------------
|
281
|
+
//
|
282
|
+
// Public Methods
|
283
|
+
//
|
284
|
+
//--------------------------------------------------------------------------
|
285
|
+
/**
|
286
|
+
* Updates the position of the component.
|
287
|
+
*
|
288
|
+
* @param delayed
|
289
|
+
*/
|
290
|
+
async reposition(delayed = false) {
|
291
|
+
const { floatingEl, referenceEl, placement, overlayPositioning, filteredFlipPlacements } = this;
|
292
|
+
return floatingUi.reposition(this, {
|
293
|
+
floatingEl,
|
294
|
+
referenceEl,
|
295
|
+
overlayPositioning,
|
296
|
+
placement,
|
297
|
+
flipPlacements: filteredFlipPlacements,
|
298
|
+
type: "menu",
|
299
|
+
}, delayed);
|
300
|
+
}
|
301
|
+
closeCalciteDropdownOnClick(event) {
|
302
|
+
if (this.disabled ||
|
303
|
+
!dom.isPrimaryPointerButton(event) ||
|
304
|
+
!this.open ||
|
305
|
+
event.composedPath().includes(this.el)) {
|
306
|
+
return;
|
307
|
+
}
|
308
|
+
this.closeCalciteDropdown(false);
|
309
|
+
}
|
310
|
+
closeCalciteDropdownOnEvent(event) {
|
311
|
+
this.closeCalciteDropdown();
|
312
|
+
event.stopPropagation();
|
313
|
+
}
|
314
|
+
closeCalciteDropdownOnOpenEvent(event) {
|
315
|
+
if (event.composedPath().includes(this.el)) {
|
316
|
+
return;
|
317
|
+
}
|
318
|
+
this.open = false;
|
319
|
+
}
|
320
|
+
pointerEnterHandler() {
|
321
|
+
if (this.disabled || this.type !== "hover") {
|
322
|
+
return;
|
323
|
+
}
|
324
|
+
this.openCalciteDropdown();
|
325
|
+
}
|
326
|
+
pointerLeaveHandler() {
|
327
|
+
if (this.disabled || this.type !== "hover") {
|
328
|
+
return;
|
329
|
+
}
|
330
|
+
this.closeCalciteDropdown();
|
331
|
+
}
|
332
|
+
getTraversableItems() {
|
333
|
+
return this.items.filter((item) => !item.disabled && !item.hidden);
|
334
|
+
}
|
335
|
+
calciteInternalDropdownItemKeyEvent(event) {
|
336
|
+
const { keyboardEvent } = event.detail;
|
337
|
+
const target = keyboardEvent.target;
|
338
|
+
const traversableItems = this.getTraversableItems();
|
339
|
+
switch (keyboardEvent.key) {
|
340
|
+
case "Tab":
|
341
|
+
this.open = false;
|
342
|
+
this.updateTabIndexOfItems(target);
|
343
|
+
break;
|
344
|
+
case "ArrowDown":
|
345
|
+
dom.focusElementInGroup(traversableItems, target, "next");
|
346
|
+
break;
|
347
|
+
case "ArrowUp":
|
348
|
+
dom.focusElementInGroup(traversableItems, target, "previous");
|
349
|
+
break;
|
350
|
+
case "Home":
|
351
|
+
dom.focusElementInGroup(traversableItems, target, "first");
|
352
|
+
break;
|
353
|
+
case "End":
|
354
|
+
dom.focusElementInGroup(traversableItems, target, "last");
|
355
|
+
break;
|
356
|
+
}
|
357
|
+
event.stopPropagation();
|
358
|
+
}
|
359
|
+
handleItemSelect(event) {
|
360
|
+
this.updateSelectedItems();
|
361
|
+
event.stopPropagation();
|
362
|
+
this.calciteDropdownSelect.emit();
|
363
|
+
if (!this.closeOnSelectDisabled ||
|
364
|
+
event.detail.requestedDropdownGroup.selectionMode === "none") {
|
365
|
+
this.closeCalciteDropdown();
|
366
|
+
}
|
367
|
+
event.stopPropagation();
|
368
|
+
}
|
369
|
+
onBeforeOpen() {
|
370
|
+
this.calciteDropdownBeforeOpen.emit();
|
371
|
+
}
|
372
|
+
onOpen() {
|
373
|
+
this.calciteDropdownOpen.emit();
|
374
|
+
}
|
375
|
+
onBeforeClose() {
|
376
|
+
this.calciteDropdownBeforeClose.emit();
|
377
|
+
}
|
378
|
+
onClose() {
|
379
|
+
this.calciteDropdownClose.emit();
|
380
|
+
}
|
381
|
+
updateSelectedItems() {
|
382
|
+
this.selectedItems = this.items.filter((item) => item.selected);
|
383
|
+
}
|
384
|
+
getMaxScrollerHeight() {
|
385
|
+
const { maxItems, items } = this;
|
386
|
+
let itemsToProcess = 0;
|
387
|
+
let maxScrollerHeight = 0;
|
388
|
+
let groupHeaderHeight;
|
389
|
+
this.groups.forEach((group) => {
|
390
|
+
if (maxItems > 0 && itemsToProcess < maxItems) {
|
391
|
+
Array.from(group.children).forEach((item, index) => {
|
392
|
+
if (index === 0) {
|
393
|
+
if (isNaN(groupHeaderHeight)) {
|
394
|
+
groupHeaderHeight = item.offsetTop;
|
395
|
+
}
|
396
|
+
maxScrollerHeight += groupHeaderHeight;
|
397
|
+
}
|
398
|
+
if (itemsToProcess < maxItems) {
|
399
|
+
maxScrollerHeight += item.offsetHeight;
|
400
|
+
itemsToProcess += 1;
|
401
|
+
}
|
402
|
+
});
|
403
|
+
}
|
404
|
+
});
|
405
|
+
return items.length > maxItems ? maxScrollerHeight : 0;
|
406
|
+
}
|
407
|
+
closeCalciteDropdown(focusTrigger = true) {
|
408
|
+
this.open = false;
|
409
|
+
if (focusTrigger) {
|
410
|
+
dom.focusElement(this.triggers[0]);
|
411
|
+
}
|
412
|
+
}
|
413
|
+
getFocusableElement(item) {
|
414
|
+
if (!item) {
|
415
|
+
return;
|
416
|
+
}
|
417
|
+
dom.focusElement(item);
|
418
|
+
}
|
419
|
+
updateTabIndexOfItems(target) {
|
420
|
+
this.items.forEach((item) => {
|
421
|
+
item.tabIndex = target !== item ? -1 : 0;
|
422
|
+
});
|
423
|
+
}
|
424
|
+
static get delegatesFocus() { return true; }
|
425
|
+
get el() { return index.getElement(this); }
|
426
|
+
static get watchers() { return {
|
427
|
+
"open": ["openHandler"],
|
428
|
+
"disabled": ["handleDisabledChange"],
|
429
|
+
"flipPlacements": ["flipPlacementsHandler"],
|
430
|
+
"maxItems": ["maxItemsHandler"],
|
431
|
+
"overlayPositioning": ["overlayPositioningHandler"],
|
432
|
+
"placement": ["placementHandler"],
|
433
|
+
"scale": ["handlePropsChange"]
|
434
|
+
}; }
|
435
|
+
};
|
436
|
+
Dropdown.style = dropdownCss;
|
437
|
+
|
438
|
+
/*!
|
439
|
+
* All material copyright ESRI, All Rights Reserved, unless otherwise specified.
|
440
|
+
* See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
|
441
|
+
* v2.4.0
|
442
|
+
*/
|
443
|
+
const CSS = {
|
444
|
+
container: "container",
|
445
|
+
containerLink: "container--link",
|
446
|
+
containerMulti: "container--multi-selection",
|
447
|
+
containerSingle: "container--single-selection",
|
448
|
+
containerNone: "container--none-selection",
|
449
|
+
icon: "dropdown-item-icon",
|
450
|
+
iconEnd: "dropdown-item-icon-end",
|
451
|
+
iconStart: "dropdown-item-icon-start",
|
452
|
+
itemContent: "dropdown-item-content",
|
453
|
+
link: "dropdown-link",
|
454
|
+
};
|
455
|
+
|
456
|
+
const dropdownGroupCss = ":host{position:relative;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{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-color-border-3);font-weight:var(--calcite-font-weight-bold);color:var(--calcite-color-text-2)}.dropdown-separator{display:block;block-size:1px;background-color:var(--calcite-color-border-3)}:host([hidden]){display:none}[hidden]{display:none}";
|
457
|
+
|
458
|
+
const DropdownGroup = class {
|
459
|
+
constructor(hostRef) {
|
460
|
+
index.registerInstance(this, hostRef);
|
461
|
+
this.calciteInternalDropdownItemChange = index.createEvent(this, "calciteInternalDropdownItemChange", 6);
|
462
|
+
this.updateItems = () => {
|
463
|
+
Array.from(this.el.querySelectorAll("calcite-dropdown-item")).forEach((item) => (item.selectionMode = this.selectionMode));
|
464
|
+
};
|
465
|
+
this.mutationObserver = observers.createObserver("mutation", () => this.updateItems());
|
466
|
+
this.groupTitle = undefined;
|
467
|
+
this.scale = "m";
|
468
|
+
this.selectionMode = "single";
|
469
|
+
}
|
470
|
+
handlePropsChange() {
|
471
|
+
this.updateItems();
|
472
|
+
}
|
473
|
+
//--------------------------------------------------------------------------
|
474
|
+
//
|
475
|
+
// Lifecycle
|
476
|
+
//
|
477
|
+
//--------------------------------------------------------------------------
|
478
|
+
connectedCallback() {
|
479
|
+
var _a;
|
480
|
+
this.updateItems();
|
481
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
|
482
|
+
}
|
483
|
+
componentWillLoad() {
|
484
|
+
this.groupPosition = this.getGroupPosition();
|
485
|
+
}
|
486
|
+
disconnectedCallback() {
|
487
|
+
var _a;
|
488
|
+
(_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
|
489
|
+
}
|
490
|
+
render() {
|
491
|
+
const groupTitle = this.groupTitle ? (index.h("span", { "aria-hidden": "true", class: "dropdown-title" }, this.groupTitle)) : null;
|
492
|
+
const dropdownSeparator = this.groupPosition > 0 ? index.h("div", { class: "dropdown-separator", role: "separator" }) : null;
|
493
|
+
return (index.h(index.Host, { "aria-label": this.groupTitle, role: "group" }, index.h("div", { class: {
|
494
|
+
[CSS.container]: true,
|
495
|
+
[`${CSS.container}--${this.scale}`]: true,
|
496
|
+
} }, dropdownSeparator, groupTitle, index.h("slot", null))));
|
497
|
+
}
|
498
|
+
//--------------------------------------------------------------------------
|
499
|
+
//
|
500
|
+
// Event Listeners
|
501
|
+
//
|
502
|
+
//--------------------------------------------------------------------------
|
503
|
+
updateActiveItemOnChange(event) {
|
504
|
+
this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
|
505
|
+
this.requestedDropdownItem = event.detail.requestedDropdownItem;
|
506
|
+
this.calciteInternalDropdownItemChange.emit({
|
507
|
+
requestedDropdownGroup: this.requestedDropdownGroup,
|
508
|
+
requestedDropdownItem: this.requestedDropdownItem,
|
509
|
+
});
|
510
|
+
}
|
511
|
+
//--------------------------------------------------------------------------
|
512
|
+
//
|
513
|
+
// Private Methods
|
514
|
+
//
|
515
|
+
//--------------------------------------------------------------------------
|
516
|
+
getGroupPosition() {
|
517
|
+
return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-dropdown-group"), this.el);
|
518
|
+
}
|
519
|
+
static get delegatesFocus() { return true; }
|
520
|
+
get el() { return index.getElement(this); }
|
521
|
+
static get watchers() { return {
|
522
|
+
"selectionMode": ["handlePropsChange"]
|
523
|
+
}; }
|
524
|
+
};
|
525
|
+
DropdownGroup.style = dropdownGroupCss;
|
526
|
+
|
527
|
+
const dropdownItemCss = ":host([disabled]){cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled)}:host([disabled]) *,:host([disabled]) ::slotted(*){pointer-events:none}.container--s{padding-block:0.25rem;font-size:var(--calcite-font-size--2);line-height:1rem;padding-inline-end:0.5rem;padding-inline-start:1.5rem}.container--m{padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;padding-inline-end:0.75rem;padding-inline-start:2rem}.container--l{padding-block:0.625rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;padding-inline-end:1rem;padding-inline-start:2.5rem}.container--s.container--none-selection{padding-inline-start:0.25rem}.container--s.container--none-selection .dropdown-link{padding-inline-start:0px}.container--m.container--none-selection{padding-inline-start:0.5rem}.container--m.container--none-selection .dropdown-link{padding-inline-start:0px}.container--l.container--none-selection{padding-inline-start:0.75rem}.container--l.container--none-selection .dropdown-link{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-color-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;padding-block:0.125rem;padding-inline-end:auto;padding-inline-start:0.25rem}:host,.container--link a{outline-color:transparent}:host(:focus){outline:2px solid transparent;outline-offset:2px;outline:2px solid var(--calcite-color-brand);outline-offset:calc(\n -2px *\n calc(\n 1 -\n 2 * clamp(\n 0,\n var(--calcite-offset-invert-focus),\n 1\n )\n )\n )}.container--link{padding:0px}.container--link a{position:relative;display:flex;flex-grow:1;cursor:pointer;align-items:center;color:var(--calcite-color-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;padding-inline-end:0.5rem;padding-inline-start:1.5rem}.container--m .dropdown-link{padding-block:0.5rem;font-size:var(--calcite-font-size--1);line-height:1rem;padding-inline-end:0.75rem;padding-inline-start:2rem}.container--l .dropdown-link{padding-block:0.75rem;font-size:var(--calcite-font-size-0);line-height:1.25rem;padding-inline-end:1rem;padding-inline-start:2.5rem}:host(:hover:not([disabled])) .container,:host(:active:not([disabled])) .container{background-color:var(--calcite-color-foreground-2);color:var(--calcite-color-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host(:hover:not([disabled])) .container--link .dropdown-link,:host(:active:not([disabled])) .container--link .dropdown-link{color:var(--calcite-color-text-1)}:host(:active:not([disabled])) .container{background-color:var(--calcite-color-foreground-3)}:host(:focus) .container{color:var(--calcite-color-text-1);-webkit-text-decoration-line:none;text-decoration-line:none}:host([selected]) .container:not(.container--none-selection),:host([selected]) .container--link .dropdown-link{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-1)}:host([selected]) .container:not(.container--none-selection) calcite-icon,:host([selected]) .container--link .dropdown-link calcite-icon{color:var(--calcite-color-brand)}.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:not([disabled])) .dropdown-item-icon{color:var(--calcite-color-border-1);opacity:1}:host([selected]) .dropdown-item-icon{color:var(--calcite-color-brand);opacity:1}.container--s .dropdown-item-icon-start{margin-inline-end:0.5rem;margin-inline-start:0.25rem}.container--s .dropdown-item-icon-end{margin-inline-start:0.5rem}.container--m .dropdown-item-icon-start{margin-inline-end:0.75rem;margin-inline-start:0.25rem}.container--m .dropdown-item-icon-end{margin-inline-start:0.75rem}.container--l .dropdown-item-icon-start{margin-inline-end:1rem;margin-inline-start:0.25rem}.container--l .dropdown-item-icon-end{margin-inline-start:1rem}:host([hidden]){display:none}[hidden]{display:none}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}";
|
528
|
+
|
529
|
+
const DropdownItem = class {
|
530
|
+
constructor(hostRef) {
|
531
|
+
index.registerInstance(this, hostRef);
|
532
|
+
this.calciteDropdownItemSelect = index.createEvent(this, "calciteDropdownItemSelect", 6);
|
533
|
+
this.calciteInternalDropdownItemSelect = index.createEvent(this, "calciteInternalDropdownItemSelect", 6);
|
534
|
+
this.calciteInternalDropdownItemKeyEvent = index.createEvent(this, "calciteInternalDropdownItemKeyEvent", 6);
|
535
|
+
this.calciteInternalDropdownCloseRequest = index.createEvent(this, "calciteInternalDropdownCloseRequest", 6);
|
536
|
+
this.disabled = false;
|
537
|
+
this.href = undefined;
|
538
|
+
this.iconFlipRtl = undefined;
|
539
|
+
this.iconStart = undefined;
|
540
|
+
this.iconEnd = undefined;
|
541
|
+
this.label = undefined;
|
542
|
+
this.rel = undefined;
|
543
|
+
this.selected = false;
|
544
|
+
this.target = undefined;
|
545
|
+
this.selectionMode = "single";
|
546
|
+
this.scale = "m";
|
547
|
+
}
|
548
|
+
//--------------------------------------------------------------------------
|
549
|
+
//
|
550
|
+
// Public Methods
|
551
|
+
//
|
552
|
+
//--------------------------------------------------------------------------
|
553
|
+
/** Sets focus on the component. */
|
554
|
+
async setFocus() {
|
555
|
+
var _a;
|
556
|
+
await loadable.componentFocusable(this);
|
557
|
+
(_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
|
558
|
+
}
|
559
|
+
//--------------------------------------------------------------------------
|
560
|
+
//
|
561
|
+
// Lifecycle
|
562
|
+
//
|
563
|
+
//--------------------------------------------------------------------------
|
564
|
+
componentWillLoad() {
|
565
|
+
loadable.setUpLoadableComponent(this);
|
566
|
+
this.initialize();
|
567
|
+
}
|
568
|
+
componentDidLoad() {
|
569
|
+
loadable.setComponentLoaded(this);
|
570
|
+
}
|
571
|
+
connectedCallback() {
|
572
|
+
this.initialize();
|
573
|
+
}
|
574
|
+
componentDidRender() {
|
575
|
+
interactive.updateHostInteraction(this);
|
576
|
+
}
|
577
|
+
render() {
|
578
|
+
const { href, selectionMode, label, iconFlipRtl, scale } = this;
|
579
|
+
const iconStartEl = (index.h("calcite-icon", { class: CSS.iconStart, flipRtl: iconFlipRtl === "start" || iconFlipRtl === "both", icon: this.iconStart, scale: component.getIconScale(this.scale) }));
|
580
|
+
const contentNode = (index.h("span", { class: CSS.itemContent }, index.h("slot", null)));
|
581
|
+
const iconEndEl = (index.h("calcite-icon", { class: CSS.iconEnd, flipRtl: iconFlipRtl === "end" || iconFlipRtl === "both", icon: this.iconEnd, scale: component.getIconScale(this.scale) }));
|
582
|
+
const slottedContent = this.iconStart && this.iconEnd
|
583
|
+
? [iconStartEl, contentNode, iconEndEl]
|
584
|
+
: this.iconStart
|
585
|
+
? [iconStartEl, contentNode]
|
586
|
+
: this.iconEnd
|
587
|
+
? [contentNode, iconEndEl]
|
588
|
+
: contentNode;
|
589
|
+
const contentEl = !href ? (slottedContent) : (index.h("a", { "aria-label": label, class: CSS.link, href: href, rel: this.rel, tabIndex: -1, target: this.target,
|
590
|
+
// eslint-disable-next-line react/jsx-sort-props -- ref should be last so node attrs/props are in sync (see https://github.com/Esri/calcite-design-system/pull/6530)
|
591
|
+
ref: (el) => (this.childLink = el) }, slottedContent));
|
592
|
+
const itemRole = href
|
593
|
+
? null
|
594
|
+
: selectionMode === "single"
|
595
|
+
? "menuitemradio"
|
596
|
+
: selectionMode === "multiple"
|
597
|
+
? "menuitemcheckbox"
|
598
|
+
: "menuitem";
|
599
|
+
const itemAria = selectionMode !== "none" ? dom.toAriaBoolean(this.selected) : null;
|
600
|
+
const { disabled } = this;
|
601
|
+
return (index.h(index.Host, { "aria-checked": itemAria, "aria-label": !href ? label : "", role: itemRole, tabIndex: disabled ? -1 : 0 }, index.h(interactive.InteractiveContainer, { disabled: disabled }, index.h("div", { class: {
|
602
|
+
[CSS.container]: true,
|
603
|
+
[CSS.containerLink]: !!href,
|
604
|
+
[`${CSS.container}--${scale}`]: true,
|
605
|
+
[CSS.containerMulti]: selectionMode === "multiple",
|
606
|
+
[CSS.containerSingle]: selectionMode === "single",
|
607
|
+
[CSS.containerNone]: selectionMode === "none",
|
608
|
+
} }, selectionMode !== "none" ? (index.h("calcite-icon", { class: CSS.icon, icon: selectionMode === "multiple" ? "check" : "bullet-point", scale: component.getIconScale(this.scale) })) : null, contentEl))));
|
609
|
+
}
|
610
|
+
//--------------------------------------------------------------------------
|
611
|
+
//
|
612
|
+
// Event Listeners
|
613
|
+
//
|
614
|
+
//--------------------------------------------------------------------------
|
615
|
+
onClick() {
|
616
|
+
this.emitRequestedItem();
|
617
|
+
}
|
618
|
+
keyDownHandler(event) {
|
619
|
+
switch (event.key) {
|
620
|
+
case " ":
|
621
|
+
case "Enter":
|
622
|
+
this.emitRequestedItem();
|
623
|
+
if (this.href) {
|
624
|
+
this.childLink.click();
|
625
|
+
}
|
626
|
+
event.preventDefault();
|
627
|
+
break;
|
628
|
+
case "Escape":
|
629
|
+
this.calciteInternalDropdownCloseRequest.emit();
|
630
|
+
event.preventDefault();
|
631
|
+
break;
|
632
|
+
case "Tab":
|
633
|
+
this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
|
634
|
+
break;
|
635
|
+
case "ArrowUp":
|
636
|
+
case "ArrowDown":
|
637
|
+
case "Home":
|
638
|
+
case "End":
|
639
|
+
event.preventDefault();
|
640
|
+
this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
|
641
|
+
break;
|
642
|
+
}
|
643
|
+
}
|
644
|
+
updateActiveItemOnChange(event) {
|
645
|
+
const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
|
646
|
+
if (parentEmittedChange) {
|
647
|
+
this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
|
648
|
+
this.requestedDropdownItem = event.detail.requestedDropdownItem;
|
649
|
+
this.determineActiveItem();
|
650
|
+
}
|
651
|
+
event.stopPropagation();
|
652
|
+
}
|
653
|
+
//--------------------------------------------------------------------------
|
654
|
+
//
|
655
|
+
// Private Methods
|
656
|
+
//
|
657
|
+
//--------------------------------------------------------------------------
|
658
|
+
initialize() {
|
659
|
+
this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
|
660
|
+
if (this.selectionMode === "none") {
|
661
|
+
this.selected = false;
|
662
|
+
}
|
663
|
+
}
|
664
|
+
determineActiveItem() {
|
665
|
+
switch (this.selectionMode) {
|
666
|
+
case "multiple":
|
667
|
+
if (this.el === this.requestedDropdownItem) {
|
668
|
+
this.selected = !this.selected;
|
669
|
+
}
|
670
|
+
break;
|
671
|
+
case "single":
|
672
|
+
if (this.el === this.requestedDropdownItem) {
|
673
|
+
this.selected = true;
|
674
|
+
}
|
675
|
+
else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
|
676
|
+
this.selected = false;
|
677
|
+
}
|
678
|
+
break;
|
679
|
+
case "none":
|
680
|
+
this.selected = false;
|
681
|
+
break;
|
682
|
+
}
|
683
|
+
}
|
684
|
+
emitRequestedItem() {
|
685
|
+
this.calciteDropdownItemSelect.emit();
|
686
|
+
this.calciteInternalDropdownItemSelect.emit({
|
687
|
+
requestedDropdownItem: this.el,
|
688
|
+
requestedDropdownGroup: this.parentDropdownGroupEl,
|
689
|
+
});
|
690
|
+
}
|
691
|
+
get el() { return index.getElement(this); }
|
692
|
+
};
|
693
|
+
DropdownItem.style = dropdownItemCss;
|
694
|
+
|
695
|
+
const mapLayerPickerCss = ":host{display:block}.map-layer-picker-container{width:100%;align-items:center}.map-layer-picker{position:relative;width:100%;display:inline-block}.padding-bottom-1{padding-bottom:1rem}.layer-picker-dropdown{height:100%;width:100%}.max-width-350{max-width:350px}.height-100{height:100%}.disabled{cursor:default !important;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-opacity-disabled);pointer-events:none}.no-bottom-margin{--calcite-label-margin-bottom:0px}.layer-picker-label-container{align-items:center;display:inline-flex;height:100%;padding-inline-start:1rem;padding-inline-end:1rem}.padding-start-1{padding-inline-start:1rem}.cursor-default{cursor:default}";
|
696
|
+
|
697
|
+
const MapLayerPicker = class {
|
698
|
+
constructor(hostRef) {
|
699
|
+
index.registerInstance(this, hostRef);
|
700
|
+
this.idsFound = index.createEvent(this, "idsFound", 7);
|
701
|
+
this.noLayersFound = index.createEvent(this, "noLayersFound", 7);
|
702
|
+
this.layerSelectionChange = index.createEvent(this, "layerSelectionChange", 7);
|
703
|
+
//--------------------------------------------------------------------------
|
704
|
+
//
|
705
|
+
// Properties (protected)
|
706
|
+
//
|
707
|
+
//--------------------------------------------------------------------------
|
708
|
+
/**
|
709
|
+
* boolean: When true the default layer has been loaded once and should no longer be used
|
710
|
+
*/
|
711
|
+
this.defaultLayerHonored = false;
|
712
|
+
this.appearance = "transparent";
|
713
|
+
this.defaultLayerId = "";
|
714
|
+
this.display = "inline-block";
|
715
|
+
this.enabledLayerIds = [];
|
716
|
+
this.enabledTableIds = [];
|
717
|
+
this.height = undefined;
|
718
|
+
this.isMobile = undefined;
|
719
|
+
this.mapView = undefined;
|
720
|
+
this.onlyShowUpdatableLayers = undefined;
|
721
|
+
this.placeholderIcon = "";
|
722
|
+
this.selectedIds = [];
|
723
|
+
this.scale = "m";
|
724
|
+
this.showTables = undefined;
|
725
|
+
this.showSingleLayerAsLabel = false;
|
726
|
+
this.type = "select";
|
727
|
+
this._hasMultipleLayers = true;
|
728
|
+
this._hasValidLayers = true;
|
729
|
+
this._isDropdownOpen = undefined;
|
730
|
+
this.ids = [];
|
731
|
+
this.selectedName = "";
|
732
|
+
this._translations = undefined;
|
733
|
+
}
|
734
|
+
//--------------------------------------------------------------------------
|
735
|
+
//
|
736
|
+
// Watch handlers
|
737
|
+
//
|
738
|
+
//--------------------------------------------------------------------------
|
739
|
+
/**
|
740
|
+
* Called each time the mapView prop is changed.
|
741
|
+
*/
|
742
|
+
async mapViewWatchHandler() {
|
743
|
+
await this._setLayers();
|
744
|
+
if (this.ids.length > 0) {
|
745
|
+
this._hasValidLayers = true;
|
746
|
+
this._hasMultipleLayers = this.ids.length > 1;
|
747
|
+
this._setSelectedLayer(this.ids[0]);
|
748
|
+
}
|
749
|
+
else {
|
750
|
+
this._hasValidLayers = false;
|
751
|
+
this.noLayersFound.emit();
|
752
|
+
}
|
753
|
+
}
|
754
|
+
//--------------------------------------------------------------------------
|
755
|
+
//
|
756
|
+
// Functions (lifecycle)
|
757
|
+
//
|
758
|
+
//--------------------------------------------------------------------------
|
759
|
+
/**
|
760
|
+
* StencilJS: Called once just after the component is first connected to the DOM.
|
761
|
+
*/
|
762
|
+
async componentWillLoad() {
|
763
|
+
await this._getTranslations();
|
764
|
+
await this._setLayers();
|
765
|
+
if (this.ids.length > 0 || this.selectedIds.length === 1) {
|
766
|
+
this.layerSelectionChange.emit(this.selectedIds.length === 1 ? [this.selectedIds[0]] : [this.ids[0]]);
|
767
|
+
}
|
768
|
+
}
|
769
|
+
/**
|
770
|
+
* Renders the component.
|
771
|
+
*/
|
772
|
+
render() {
|
773
|
+
const id = "map-layer-picker";
|
774
|
+
let style = this.height > 0 ? { "height": `${this.height.toString()}px` } : {};
|
775
|
+
style = Object.assign(Object.assign({}, style), { "display": this.display });
|
776
|
+
return (index.h(index.Host, null, index.h("div", { class: "map-layer-picker-container", style: style }, index.h("div", { class: "map-layer-picker", style: style }, !this._hasValidLayers ? this._getInvalidPlaceholder() :
|
777
|
+
!this._hasMultipleLayers && this.showSingleLayerAsLabel ? this._getSingleLayerPlaceholder() :
|
778
|
+
this.type === "combobox" ? this._getCombobox(id) :
|
779
|
+
this.type === "select" ? this._getSelect(id) : this._getDropdown(id)))));
|
780
|
+
}
|
781
|
+
/**
|
782
|
+
* StencilJS: Called once just after the component is fully loaded and the first render() occurs.
|
783
|
+
*/
|
784
|
+
async componentDidLoad() {
|
785
|
+
if (this.ids.length > 0 || this.selectedIds.length === 1) {
|
786
|
+
const id = this.selectedIds.length === 1 ? this.selectedIds[0] : this.ids[0];
|
787
|
+
if (this.type === "select") {
|
788
|
+
this._layerElement.value = id;
|
789
|
+
}
|
790
|
+
else if (this.type === "dropdown") {
|
791
|
+
this.selectedName = Object.keys(this._layerNameHash).indexOf(id) > -1 ?
|
792
|
+
this._layerNameHash[id].name : Object.keys(this._tableNameHash).indexOf(id) > -1 ?
|
793
|
+
this._tableNameHash[id].name : "";
|
794
|
+
}
|
795
|
+
}
|
796
|
+
}
|
797
|
+
//--------------------------------------------------------------------------
|
798
|
+
//
|
799
|
+
// Functions (protected)
|
800
|
+
//
|
801
|
+
//--------------------------------------------------------------------------
|
802
|
+
/**
|
803
|
+
* Create a notice to inform the user that no layers were found
|
804
|
+
*
|
805
|
+
* @returns Calcite Notice component with the message
|
806
|
+
*/
|
807
|
+
_getInvalidPlaceholder() {
|
808
|
+
return (index.h("div", null, index.h("calcite-notice", { class: "height-100", icon: "exclamation-mark-triangle", id: "no-valid-layers", kind: "danger", open: true }, index.h("div", { slot: "message" }, this._translations.noLayersFound)), index.h("calcite-tooltip", { label: this._translations.enableEditUpdate, placement: "bottom", "reference-element": "no-valid-layers" }, index.h("span", null, this._translations.enableEditUpdate))));
|
809
|
+
}
|
810
|
+
/**
|
811
|
+
* Show layer name as a label with icon
|
812
|
+
*
|
813
|
+
* @returns Calcite label with the layer name and icon
|
814
|
+
*/
|
815
|
+
_getSingleLayerPlaceholder() {
|
816
|
+
return (index.h("div", { class: "layer-picker-label-container cursor-default" }, index.h("calcite-icon", { icon: "layers", scale: "s" }), index.h("calcite-label", { class: "no-bottom-margin padding-start-1" }, this.selectedName)));
|
817
|
+
}
|
818
|
+
/**
|
819
|
+
* Create a list of layers from the map
|
820
|
+
* Used for selecting a single layer.
|
821
|
+
*
|
822
|
+
* @param id the id for the select component used to support the tooltip
|
823
|
+
*
|
824
|
+
* @returns Calcite Select component with the ids of the layers from the map
|
825
|
+
*/
|
826
|
+
_getSelect(id) {
|
827
|
+
return (index.h("calcite-select", { id: id, label: "", onCalciteSelectChange: () => this._layerSelectionChange(), ref: (el) => { this._layerElement = el; }, scale: this.scale }, this._getMapLayerOptions()));
|
828
|
+
}
|
829
|
+
/**
|
830
|
+
* Create a list of layer ids from the map
|
831
|
+
* Used for selecting multiple layers
|
832
|
+
*
|
833
|
+
* @param id the id for the combobox component used to support the tooltip
|
834
|
+
*
|
835
|
+
* @returns Calcite ComboBox component with the ids of the layers from the map
|
836
|
+
*/
|
837
|
+
_getCombobox(id) {
|
838
|
+
return (index.h("calcite-combobox", { clearDisabled: true, id: id, label: "", onCalciteComboboxChange: () => this._layerSelectionChange(), "placeholder-icon": this.placeholderIcon, ref: (el) => { this._layerElement = el; }, scale: this.scale, "selection-mode": "single" }, this._getMapLayerOptions()));
|
839
|
+
}
|
840
|
+
/**
|
841
|
+
* Hydrate a dropdown component with items to display the layer names
|
842
|
+
*
|
843
|
+
* @param id the id for the dropdown component used to support the tooltip
|
844
|
+
*
|
845
|
+
* @returns Array of Dropdown items with layer names
|
846
|
+
*/
|
847
|
+
_getDropdown(id) {
|
848
|
+
return (index.h("calcite-dropdown", { class: "layer-picker-dropdown", onCalciteDropdownBeforeClose: () => this._isDropdownOpen = false, onCalciteDropdownBeforeOpen: () => this._isDropdownOpen = true }, this.isMobile ? this._getDropdownButton() : this._getActionDropdownButton(id), index.h("calcite-dropdown-group", { "selection-mode": "single" }, this._getMapLayerOptions())));
|
849
|
+
}
|
850
|
+
/**
|
851
|
+
* Get the button that will open the dropdown list wrapped in an action
|
852
|
+
*
|
853
|
+
* @returns the node for the action and button
|
854
|
+
*/
|
855
|
+
_getActionDropdownButton(id) {
|
856
|
+
return (index.h("calcite-action", { id: id, slot: "trigger", text: "" }, this._getDropdownButton()));
|
857
|
+
}
|
858
|
+
/**
|
859
|
+
* Get the button that will open the dropdown list
|
860
|
+
*
|
861
|
+
* @returns the node for the button
|
862
|
+
*/
|
863
|
+
_getDropdownButton() {
|
864
|
+
const buttonClass = this.isMobile ? "" : "max-width-350";
|
865
|
+
const buttonSlot = this.isMobile ? "trigger" : "";
|
866
|
+
const buttonIcon = this._isDropdownOpen ? "chevron-up" : "chevron-down";
|
867
|
+
return (index.h("calcite-button", { alignment: "icon-end-space-between", appearance: this.appearance, class: buttonClass, iconEnd: buttonIcon, iconStart: "layers", kind: "neutral", slot: buttonSlot, width: "full" }, index.h("div", null, this.selectedName)));
|
868
|
+
}
|
869
|
+
/**
|
870
|
+
* Get the appropriate type of dom nodes for each valid layer or table
|
871
|
+
*
|
872
|
+
* @returns Array of dom nodes with the names of the layers and optionally of the tables
|
873
|
+
*/
|
874
|
+
_getMapLayerOptions() {
|
875
|
+
return this.ids.reduce((prev, cur) => {
|
876
|
+
if (this._validLayer(cur)) {
|
877
|
+
prev.push(this._getItem(cur, "layer"));
|
878
|
+
}
|
879
|
+
else if (this._validTable(cur)) {
|
880
|
+
prev.push(this._getItem(cur, "table"));
|
881
|
+
}
|
882
|
+
return prev;
|
883
|
+
}, []);
|
884
|
+
}
|
885
|
+
/**
|
886
|
+
* Get the appropriate type of dom node for the current layer or table id
|
887
|
+
*
|
888
|
+
* @returns A dom node with the name of the layer or table
|
889
|
+
*/
|
890
|
+
_getItem(id, itemType) {
|
891
|
+
const item = itemType === "layer" ? this._layerNameHash[id] : this._tableNameHash[id];
|
892
|
+
const disabled = this.onlyShowUpdatableLayers ? !item.supportsUpdate : false;
|
893
|
+
const name = item.name;
|
894
|
+
const selected = this.selectedIds.indexOf(id) > -1;
|
895
|
+
return this.type === "combobox" ? (index.h("calcite-combobox-item", { disabled: disabled, selected: selected, textLabel: name, value: id })) :
|
896
|
+
this.type === "select" ? (index.h("calcite-option", { disabled: disabled, label: name, selected: selected, value: id })) : (index.h("calcite-dropdown-group", { class: disabled ? "disabled" : "", selectionMode: disabled ? "none" : "single" }, index.h("calcite-dropdown-item", { onClick: disabled ? undefined : () => void this._setSelectedLayer(id), selected: selected }, name)));
|
897
|
+
}
|
898
|
+
/**
|
899
|
+
* Store the layer name based on the user selection
|
900
|
+
*/
|
901
|
+
_setSelectedLayer(id) {
|
902
|
+
let item;
|
903
|
+
const hasDefaultLayer = this.defaultLayerId && !this.defaultLayerHonored;
|
904
|
+
if (hasDefaultLayer) {
|
905
|
+
item = this._getLayerFromHash(this.defaultLayerId);
|
906
|
+
this.defaultLayerHonored = item !== undefined;
|
907
|
+
id = this.defaultLayerHonored ? this.defaultLayerId : id;
|
908
|
+
}
|
909
|
+
item = item ? item : this._getLayerFromHash(id);
|
910
|
+
this.selectedName = item === null || item === void 0 ? void 0 : item.name;
|
911
|
+
this.selectedIds = [id];
|
912
|
+
this.layerSelectionChange.emit(this.selectedIds);
|
913
|
+
}
|
914
|
+
/**
|
915
|
+
* Fetch layer hash info for the given id
|
916
|
+
*
|
917
|
+
* @returns ILayerHashInfo for the id
|
918
|
+
*/
|
919
|
+
_getLayerFromHash(id) {
|
920
|
+
return Object.keys(this._layerNameHash).indexOf(id) > -1 ?
|
921
|
+
this._layerNameHash[id] : Object.keys(this._tableNameHash).indexOf(id) > -1 ?
|
922
|
+
this._tableNameHash[id] : undefined;
|
923
|
+
}
|
924
|
+
/**
|
925
|
+
* Fetch the ids of the layers from the map
|
926
|
+
*
|
927
|
+
* @returns Promise when the operation has completed
|
928
|
+
*/
|
929
|
+
async _setLayers() {
|
930
|
+
if (this.mapView) {
|
931
|
+
await this._initLayerTableHash();
|
932
|
+
const layerIds = this.onlyShowUpdatableLayers ?
|
933
|
+
this._getEditableIds(this._layerNameHash) : Object.keys(this._layerNameHash);
|
934
|
+
const tableIds = this.showTables ? this.onlyShowUpdatableLayers ?
|
935
|
+
this._getEditableIds(this._tableNameHash) : Object.keys(this._tableNameHash) : [];
|
936
|
+
this.ids = [
|
937
|
+
...layerIds.reverse().filter(n => { var _a; return ((_a = this.enabledLayerIds) === null || _a === void 0 ? void 0 : _a.length) > 0 ? this.enabledLayerIds.reverse().indexOf(n) > -1 : true; }),
|
938
|
+
...tableIds.reverse().filter(n => { var _a; return ((_a = this.enabledTableIds) === null || _a === void 0 ? void 0 : _a.length) > 0 ? this.enabledTableIds.reverse().indexOf(n) > -1 : true; }),
|
939
|
+
];
|
940
|
+
this.idsFound.emit({
|
941
|
+
layerIds,
|
942
|
+
tableIds
|
943
|
+
});
|
944
|
+
}
|
945
|
+
}
|
946
|
+
/**
|
947
|
+
* Fetch the ids of all layers that support edits with the update capability
|
948
|
+
*
|
949
|
+
* @returns array of layer ids
|
950
|
+
*/
|
951
|
+
_getEditableIds(hash) {
|
952
|
+
return Object.keys(hash).reduce((prev, cur) => {
|
953
|
+
if (hash[cur].supportsUpdate) {
|
954
|
+
prev.push(cur);
|
955
|
+
}
|
956
|
+
return prev;
|
957
|
+
}, []);
|
958
|
+
}
|
959
|
+
/**
|
960
|
+
* Create a layer id:title hash for layer name display
|
961
|
+
*
|
962
|
+
* @returns Promise when the operation has completed
|
963
|
+
*/
|
964
|
+
async _initLayerTableHash() {
|
965
|
+
this._layerNameHash = await mapViewUtils.getMapLayerHash(this.mapView, this.onlyShowUpdatableLayers);
|
966
|
+
this._tableNameHash = this.showTables ? await mapViewUtils.getMapTableHash(this.mapView, this.onlyShowUpdatableLayers) : {};
|
967
|
+
}
|
968
|
+
/**
|
969
|
+
* Evaluate if the id exists in the current hash and verify if it should be excluded
|
970
|
+
*
|
971
|
+
* @returns boolean when true the layer will be used in the current layer picker type
|
972
|
+
*/
|
973
|
+
_validLayer(id) {
|
974
|
+
var _a;
|
975
|
+
const name = (_a = this._layerNameHash[id]) === null || _a === void 0 ? void 0 : _a.name;
|
976
|
+
return name && Object.keys(publicNotificationStore.state.managedLayers).indexOf(name) < 0 && (this.enabledLayerIds.length > 0 ?
|
977
|
+
this.enabledLayerIds.indexOf(id) > -1 : true);
|
978
|
+
}
|
979
|
+
/**
|
980
|
+
* Evaluate if the id exists in the current hash and verify if it should be excluded
|
981
|
+
*
|
982
|
+
* @returns boolean when true the table will be used in the current layer picker type
|
983
|
+
*/
|
984
|
+
_validTable(id) {
|
985
|
+
var _a;
|
986
|
+
const name = (_a = this._tableNameHash[id]) === null || _a === void 0 ? void 0 : _a.name;
|
987
|
+
const validName = name && this.showTables;
|
988
|
+
return validName ? publicNotificationStore.state.managedTables.indexOf(name) < 0 &&
|
989
|
+
(this.enabledTableIds.length > 0 ? this.enabledTableIds.indexOf(id) > -1 : true) : validName;
|
990
|
+
}
|
991
|
+
/**
|
992
|
+
* Fetch the ids of the layers from the map
|
993
|
+
*
|
994
|
+
* @returns Promise when the operation has completed
|
995
|
+
*/
|
996
|
+
_layerSelectionChange() {
|
997
|
+
const ids = Array.isArray(this._layerElement.value) ? this._layerElement.value : [this._layerElement.value];
|
998
|
+
if (JSON.stringify(ids) !== JSON.stringify([""])) {
|
999
|
+
this.selectedIds = ids;
|
1000
|
+
this.layerSelectionChange.emit(this.selectedIds);
|
1001
|
+
}
|
1002
|
+
}
|
1003
|
+
/**
|
1004
|
+
* Fetches the component's translations
|
1005
|
+
*
|
1006
|
+
* @returns Promise when complete
|
1007
|
+
* @protected
|
1008
|
+
*/
|
1009
|
+
async _getTranslations() {
|
1010
|
+
const messages = await locale.getLocaleComponentStrings(this.el);
|
1011
|
+
this._translations = messages[0];
|
1012
|
+
}
|
1013
|
+
get el() { return index.getElement(this); }
|
1014
|
+
static get watchers() { return {
|
1015
|
+
"mapView": ["mapViewWatchHandler"]
|
1016
|
+
}; }
|
1017
|
+
};
|
1018
|
+
MapLayerPicker.style = mapLayerPickerCss;
|
1019
|
+
|
1020
|
+
exports.calcite_dropdown = Dropdown;
|
1021
|
+
exports.calcite_dropdown_group = DropdownGroup;
|
1022
|
+
exports.calcite_dropdown_item = DropdownItem;
|
1023
|
+
exports.map_layer_picker = MapLayerPicker;
|