@esri/solutions-components 0.8.8 → 0.8.9

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