@esri/solutions-components 0.5.1 → 0.5.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (156) hide show
  1. package/dist/assets/arcgis-pdf-creator/PDFCreator.js +6 -3
  2. package/dist/assets/arcgis-pdf-creator/PDFCreator_jsPDF.js +1 -1
  3. package/dist/assets/arcgis-pdf-creator/PDFCreator_pdf_lib.js +1 -1
  4. package/dist/assets/arcgis-pdf-creator/PDFLabels.js +54 -3
  5. package/dist/assets/arcgis-pdf-creator/grid.js +1 -1
  6. package/dist/assets/data/images/grid.png +0 -0
  7. package/dist/assets/data/images/horizontal.png +0 -0
  8. package/dist/assets/data/images/vertical.png +0 -0
  9. package/dist/assets/t9n/crowdsource-manager/resources.json +7 -1
  10. package/dist/assets/t9n/crowdsource-manager/resources_en.json +7 -1
  11. package/dist/cjs/buffer-tools_6.cjs.entry.js +85 -85
  12. package/dist/cjs/{calcite-block_2.cjs.entry.js → calcite-action-bar_4.cjs.entry.js} +307 -18
  13. package/dist/cjs/{calcite-action.cjs.entry.js → calcite-action_2.cjs.entry.js} +84 -1
  14. package/dist/cjs/{calcite-combobox_3.cjs.entry.js → calcite-chip_4.cjs.entry.js} +187 -61
  15. package/dist/cjs/{calcite-dropdown-group_4.cjs.entry.js → calcite-dropdown_5.cjs.entry.js} +467 -1
  16. package/dist/cjs/calcite-input-message_5.cjs.entry.js +283 -283
  17. package/dist/cjs/calcite-shell-panel_14.cjs.entry.js +2 -2
  18. package/dist/cjs/{calcite-action-bar_2.cjs.entry.js → calcite-tooltip.cjs.entry.js} +2 -208
  19. package/dist/cjs/crowdsource-manager.cjs.entry.js +88 -14
  20. package/dist/cjs/{downloadUtils-b85476e8.js → downloadUtils-9359e9ff.js} +1218 -1127
  21. package/dist/cjs/{index.es-3ba50626.js → index.es-9c0d0ed6.js} +10682 -10682
  22. package/dist/cjs/{interfaces-17c631bf.js → interfaces-cac36920.js} +6 -0
  23. package/dist/cjs/layer-table_2.cjs.entry.js +512 -0
  24. package/dist/cjs/loader.cjs.js +30 -30
  25. package/dist/cjs/{mapViewUtils-df63bfa4.js → mapViewUtils-090f4d4d.js} +24 -24
  26. package/dist/cjs/public-notification.cjs.entry.js +69 -49
  27. package/dist/cjs/solution-configuration.cjs.entry.js +2 -2
  28. package/dist/cjs/solution-contents_3.cjs.entry.js +2 -2
  29. package/dist/cjs/{solution-store-b86759b2.js → solution-store-d28c332e.js} +1 -1
  30. package/dist/cjs/solutions-components.cjs.js +31 -31
  31. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator.js +6 -3
  32. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator_jsPDF.js +1 -1
  33. package/dist/collection/assets/arcgis-pdf-creator/PDFCreator_pdf_lib.js +1 -1
  34. package/dist/collection/assets/arcgis-pdf-creator/PDFLabels.js +54 -3
  35. package/dist/collection/assets/arcgis-pdf-creator/grid.js +1 -1
  36. package/dist/collection/components/crowdsource-manager/crowdsource-manager.css +122 -0
  37. package/dist/collection/components/crowdsource-manager/crowdsource-manager.js +130 -14
  38. package/dist/collection/components/layer-table/layer-table.css +2 -70
  39. package/dist/collection/components/layer-table/layer-table.js +66 -106
  40. package/dist/collection/components/map-card/map-card.css +4 -7
  41. package/dist/collection/components/map-card/map-card.js +44 -10
  42. package/dist/collection/components/map-draw-tools/map-draw-tools.js +1 -1
  43. package/dist/collection/components/map-select-tools/map-select-tools.js +1 -1
  44. package/dist/collection/components/public-notification/public-notification.js +45 -27
  45. package/dist/collection/components/refine-selection-tools/refine-selection-tools.js +1 -1
  46. package/dist/collection/demos/crowdsource-manager.html +14 -41
  47. package/dist/collection/utils/csvDownload.js +41 -0
  48. package/dist/collection/utils/csvDownload.ts +42 -0
  49. package/dist/collection/utils/csvUtils.js +6 -23
  50. package/dist/collection/utils/csvUtils.ts +8 -27
  51. package/dist/collection/utils/downloadUtils.js +30 -14
  52. package/dist/collection/utils/downloadUtils.ts +36 -14
  53. package/dist/collection/utils/interfaces.js +6 -0
  54. package/dist/collection/utils/interfaces.ts +6 -0
  55. package/dist/collection/utils/pdfUtils.js +9 -6
  56. package/dist/collection/utils/pdfUtils.ts +13 -8
  57. package/dist/collection/utils/test/csvUtils.spec.tsx +56 -0
  58. package/dist/collection/utils/test/downloadUtils.spec.tsx +133 -0
  59. package/dist/components/crowdsource-manager.js +293 -17
  60. package/dist/components/downloadUtils.js +133 -42
  61. package/dist/components/interfaces3.js +7 -1
  62. package/dist/components/layer-table.js +1 -443
  63. package/dist/components/layer-table2.js +429 -0
  64. package/dist/components/map-card.js +1 -339
  65. package/dist/{esm/map-card.entry.js → components/map-card2.js} +118 -22
  66. package/dist/components/map-draw-tools2.js +16 -16
  67. package/dist/components/map-layer-picker2.js +1 -1
  68. package/dist/components/map-select-tools2.js +38 -38
  69. package/dist/components/public-notification.js +102 -82
  70. package/dist/components/queryUtils.js +10 -10
  71. package/dist/components/refine-selection-tools2.js +3 -3
  72. package/dist/components/refine-selection2.js +1 -1
  73. package/dist/components/solution-resource-item2.js +1 -1
  74. package/dist/components/solution-store.js +1 -1
  75. package/dist/esm/buffer-tools_6.entry.js +76 -76
  76. package/dist/esm/{calcite-block_2.entry.js → calcite-action-bar_4.entry.js} +307 -20
  77. package/dist/esm/{calcite-action.entry.js → calcite-action_2.entry.js} +84 -2
  78. package/dist/esm/{calcite-combobox_3.entry.js → calcite-chip_4.entry.js} +181 -56
  79. package/dist/esm/{calcite-dropdown-group_4.entry.js → calcite-dropdown_5.entry.js} +468 -3
  80. package/dist/esm/calcite-input-message_5.entry.js +275 -275
  81. package/dist/esm/calcite-shell-panel_14.entry.js +2 -2
  82. package/dist/esm/{calcite-action-bar_2.entry.js → calcite-tooltip.entry.js} +4 -209
  83. package/dist/esm/crowdsource-manager.entry.js +88 -14
  84. package/dist/esm/{downloadUtils-f278742f.js → downloadUtils-a8f139c5.js} +1214 -1123
  85. package/dist/esm/{index.es-6f3a1143.js → index.es-a75412ff.js} +10596 -10596
  86. package/dist/esm/{interfaces-d0d83efa.js → interfaces-cd4054e5.js} +7 -1
  87. package/dist/esm/layer-table_2.entry.js +507 -0
  88. package/dist/esm/loader.js +26 -26
  89. package/dist/esm/{mapViewUtils-bd1809f0.js → mapViewUtils-8ffcd36d.js} +12 -12
  90. package/dist/esm/public-notification.entry.js +65 -45
  91. package/dist/esm/solution-configuration.entry.js +2 -2
  92. package/dist/esm/solution-contents_3.entry.js +2 -2
  93. package/dist/esm/{solution-store-477288ac.js → solution-store-1b67f2c8.js} +1 -1
  94. package/dist/esm/solutions-components.js +26 -26
  95. package/dist/solutions-components/demos/crowdsource-manager.html +14 -41
  96. package/dist/solutions-components/{p-dd11eeb2.js → p-1395b0ef.js} +1 -1
  97. package/dist/solutions-components/{p-cbac29fb.entry.js → p-1affd711.entry.js} +18 -18
  98. package/dist/solutions-components/p-30de8da1.entry.js +17 -0
  99. package/dist/solutions-components/{p-91cad71e.entry.js → p-439c878d.entry.js} +3 -9
  100. package/dist/solutions-components/{p-03e2c6fd.js → p-765a27f3.js} +60 -60
  101. package/dist/solutions-components/p-813a04c3.entry.js +6 -0
  102. package/dist/solutions-components/{p-9e8a371f.entry.js → p-874b39a7.entry.js} +3 -3
  103. package/dist/solutions-components/p-8cece97f.js +21 -0
  104. package/dist/solutions-components/{p-dd0241fb.entry.js → p-97aa7211.entry.js} +1 -1
  105. package/dist/solutions-components/{p-0e459cc7.entry.js → p-a955a3e6.entry.js} +10 -4
  106. package/dist/solutions-components/{p-40c12650.js → p-bb64bd47.js} +453 -437
  107. package/dist/solutions-components/{p-70e1d4d8.entry.js → p-c392dd95.entry.js} +17 -17
  108. package/dist/solutions-components/p-ca386a72.entry.js +6 -0
  109. package/dist/solutions-components/p-d47d74a6.entry.js +23 -0
  110. package/dist/solutions-components/p-db846ee2.entry.js +11 -0
  111. package/dist/solutions-components/{p-88e5a76d.js → p-dc53c9c1.js} +36 -36
  112. package/dist/solutions-components/p-e1c93241.entry.js +6 -0
  113. package/dist/solutions-components/{p-4cbaf0f1.entry.js → p-e6d235d6.entry.js} +1 -1
  114. package/dist/solutions-components/solutions-components.esm.js +6 -6
  115. package/dist/solutions-components/utils/csvDownload.ts +42 -0
  116. package/dist/solutions-components/utils/csvUtils.ts +8 -27
  117. package/dist/solutions-components/utils/downloadUtils.ts +36 -14
  118. package/dist/solutions-components/utils/interfaces.ts +6 -0
  119. package/dist/solutions-components/utils/pdfUtils.ts +13 -8
  120. package/dist/solutions-components/utils/test/csvUtils.spec.tsx +56 -0
  121. package/dist/solutions-components/utils/test/downloadUtils.spec.tsx +133 -0
  122. package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +39 -0
  123. package/dist/types/components/layer-table/layer-table.d.ts +35 -48
  124. package/dist/types/components/map-card/map-card.d.ts +10 -6
  125. package/dist/types/components/public-notification/public-notification.d.ts +18 -6
  126. package/dist/types/components.d.ts +1621 -1601
  127. package/dist/types/preact.d.ts +2 -1
  128. package/dist/types/utils/csvDownload.d.ts +24 -0
  129. package/dist/types/utils/csvUtils.d.ts +2 -1
  130. package/dist/types/utils/downloadUtils.d.ts +25 -0
  131. package/dist/types/utils/interfaces.d.ts +5 -0
  132. package/dist/types/utils/pdfUtils.d.ts +2 -1
  133. package/package.json +4 -4
  134. package/dist/cjs/calcite-chip.cjs.entry.js +0 -142
  135. package/dist/cjs/calcite-dropdown.cjs.entry.js +0 -481
  136. package/dist/cjs/calcite-handle.cjs.entry.js +0 -99
  137. package/dist/cjs/calcite-loader.cjs.entry.js +0 -95
  138. package/dist/cjs/layer-table.cjs.entry.js +0 -317
  139. package/dist/cjs/map-card.cjs.entry.js +0 -252
  140. package/dist/esm/calcite-chip.entry.js +0 -138
  141. package/dist/esm/calcite-dropdown.entry.js +0 -477
  142. package/dist/esm/calcite-handle.entry.js +0 -95
  143. package/dist/esm/calcite-loader.entry.js +0 -91
  144. package/dist/esm/layer-table.entry.js +0 -313
  145. package/dist/solutions-components/p-045d3988.entry.js +0 -12
  146. package/dist/solutions-components/p-11132485.entry.js +0 -11
  147. package/dist/solutions-components/p-15b43c29.entry.js +0 -11
  148. package/dist/solutions-components/p-5034aabc.entry.js +0 -11
  149. package/dist/solutions-components/p-6f012424.entry.js +0 -6
  150. package/dist/solutions-components/p-7fd10eb3.entry.js +0 -11
  151. package/dist/solutions-components/p-a57ef371.entry.js +0 -6
  152. package/dist/solutions-components/p-bc39f296.entry.js +0 -6
  153. package/dist/solutions-components/p-c93d8e80.entry.js +0 -6
  154. package/dist/solutions-components/p-dbc9a5a8.js +0 -21
  155. package/dist/solutions-components/p-f5c70be2.entry.js +0 -6
  156. package/dist/solutions-components/p-f6b17cc6.entry.js +0 -11
@@ -4,13 +4,478 @@
4
4
  * http://www.apache.org/licenses/LICENSE-2.0
5
5
  */
6
6
  import { r as registerInstance, c as createEvent, h, H as Host, g as getElement } from './index-c246d90e.js';
7
- import { g as getElementProp, t as toAriaBoolean } from './dom-3bdc69ee.js';
7
+ import { t as toAriaBoolean, i as isPrimaryPointerButton, f as focusElement, g as getElementProp } from './dom-3bdc69ee.js';
8
+ import { d as defaultMenuPlacement, f as filterComputedPlacements, c as connectFloatingUI, u as updateAfterClose, a as disconnectFloatingUI, F as FloatingCSS, r as reposition } from './floating-ui-63460291.js';
9
+ import { c as createObserver } from './observers-31601001.js';
8
10
  import { u as updateHostInteraction } from './interactive-822ffed6.js';
11
+ import { c as connectOpenCloseComponent, d as disconnectOpenCloseComponent } from './openCloseComponent-5caff873.js';
12
+ import { g as guid } from './guid-15fce7c0.js';
13
+ import { i as isActivationKey } from './key-acb660e7.js';
9
14
  import { g as getLocaleComponentStrings } from './locale-7bf10e0a.js';
10
15
  import './resources-436ae282.js';
11
- import './guid-15fce7c0.js';
16
+ import './debounce-4c884e5c.js';
12
17
  import './_commonjsHelpers-d5f9d613.js';
13
18
 
19
+ /*!
20
+ * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
21
+ * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
22
+ * v1.0.0-beta.97
23
+ */
24
+ const SLOTS = {
25
+ dropdownTrigger: "dropdown-trigger"
26
+ };
27
+
28
+ const dropdownCss = "@keyframes in{0%{opacity:0}100%{opacity:1}}@keyframes in-down{0%{opacity:0;transform:translate3D(0, -5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-up{0%{opacity:0;transform:translate3D(0, 5px, 0)}100%{opacity:1;transform:translate3D(0, 0, 0)}}@keyframes in-scale{0%{opacity:0;transform:scale3D(0.95, 0.95, 1)}100%{opacity:1;transform:scale3D(1, 1, 1)}}:root{--calcite-animation-timing:calc(150ms * var(--calcite-internal-duration-factor));--calcite-internal-duration-factor:var(--calcite-duration-factor, 1);--calcite-internal-animation-timing-fast:calc(100ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-medium:calc(200ms * var(--calcite-internal-duration-factor));--calcite-internal-animation-timing-slow:calc(300ms * var(--calcite-internal-duration-factor))}.calcite-animate{opacity:0;animation-fill-mode:both;animation-duration:var(--calcite-animation-timing)}.calcite-animate__in{animation-name:in}.calcite-animate__in-down{animation-name:in-down}.calcite-animate__in-up{animation-name:in-up}.calcite-animate__in-scale{animation-name:in-scale}@media (prefers-reduced-motion: reduce){:root{--calcite-internal-duration-factor:0.01}}:root{--calcite-floating-ui-transition:var(--calcite-animation-timing)}:host([hidden]){display:none}:host([disabled]){pointer-events:none;cursor:default;-webkit-user-select:none;-moz-user-select:none;user-select:none;opacity:var(--calcite-ui-opacity-disabled)}:host{display:inline-flex;flex:0 1 auto}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}:host .calcite-dropdown-wrapper{display:block;position:absolute;z-index:900;visibility:hidden;pointer-events:none;inline-size:0;block-size:0;overflow:hidden}.calcite-dropdown-wrapper .calcite-floating-ui-anim{position:relative;transition:var(--calcite-floating-ui-transition);visibility:hidden;transition-property:transform, visibility, opacity;opacity:0;box-shadow:0 0 16px 0 rgba(0, 0, 0, 0.16);z-index:1;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;visibility:visible;transform:translate(0)}:host([open]) .calcite-dropdown-wrapper{pointer-events:initial;visibility:visible;inline-size:unset;block-size:unset;overflow:unset}:host .calcite-dropdown-content{max-block-size:45vh;inline-size:auto;overflow-y:auto;overflow-x:hidden;background-color:var(--calcite-ui-foreground-1);inline-size:var(--calcite-dropdown-width)}.calcite-dropdown-trigger-container{position:relative;display:flex;flex:1 1 auto}@media (forced-colors: active){:host([open]) .calcite-dropdown-wrapper{border:1px solid canvasText}}:host([width=s]){--calcite-dropdown-width:12rem}:host([width=m]){--calcite-dropdown-width:14rem}:host([width=l]){--calcite-dropdown-width:16rem}";
29
+
30
+ const Dropdown = class {
31
+ constructor(hostRef) {
32
+ registerInstance(this, hostRef);
33
+ this.calciteDropdownSelect = createEvent(this, "calciteDropdownSelect", 6);
34
+ this.calciteDropdownBeforeClose = createEvent(this, "calciteDropdownBeforeClose", 6);
35
+ this.calciteDropdownClose = createEvent(this, "calciteDropdownClose", 6);
36
+ this.calciteDropdownBeforeOpen = createEvent(this, "calciteDropdownBeforeOpen", 6);
37
+ this.calciteDropdownOpen = createEvent(this, "calciteDropdownOpen", 6);
38
+ //--------------------------------------------------------------------------
39
+ //
40
+ // Public Properties
41
+ //
42
+ //--------------------------------------------------------------------------
43
+ /**
44
+ * Opens or closes the dropdown
45
+ *
46
+ * @deprecated use open instead.
47
+ */
48
+ this.active = false;
49
+ /** When true, opens the dropdown */
50
+ this.open = false;
51
+ /**
52
+ allow the dropdown to remain open after a selection is made
53
+ if the selection-mode of the selected item's containing group is "none", the dropdown will always close
54
+ */
55
+ this.disableCloseOnSelect = false;
56
+ /** is the dropdown disabled */
57
+ this.disabled = false;
58
+ /**
59
+ specify the maximum number of calcite-dropdown-items to display before showing the scroller, must be greater than 0 -
60
+ this value does not include groupTitles passed to calcite-dropdown-group
61
+ */
62
+ this.maxItems = 0;
63
+ /**
64
+ * Determines the type of positioning to use for the overlaid content.
65
+ *
66
+ * Using `"absolute"` will work for most cases. The component will be positioned inside of overflowing parent containers and will affect the container's layout.
67
+ *
68
+ * `"fixed"` should be used to escape an overflowing parent container, or when the reference element's `position` CSS property is `"fixed"`.
69
+ *
70
+ */
71
+ this.overlayPositioning = "absolute";
72
+ /**
73
+ * Determines where the dropdown will be positioned relative to the button.
74
+ *
75
+ * @default "bottom-start"
76
+ */
77
+ this.placement = defaultMenuPlacement;
78
+ /** specify the scale of dropdown, defaults to m */
79
+ this.scale = "m";
80
+ /**
81
+ * **read-only** The currently selected items
82
+ *
83
+ * @readonly
84
+ */
85
+ this.selectedItems = [];
86
+ /** specify whether the dropdown is opened by hover or click of a trigger element */
87
+ this.type = "click";
88
+ this.items = [];
89
+ this.groups = [];
90
+ this.mutationObserver = createObserver("mutation", () => this.updateItems());
91
+ this.resizeObserver = createObserver("resize", (entries) => this.resizeObserverCallback(entries));
92
+ this.openTransitionProp = "visibility";
93
+ this.guid = `calcite-dropdown-${guid()}`;
94
+ this.defaultAssignedElements = [];
95
+ //--------------------------------------------------------------------------
96
+ //
97
+ // Private Methods
98
+ //
99
+ //--------------------------------------------------------------------------
100
+ this.slotChangeHandler = (event) => {
101
+ this.defaultAssignedElements = event.target.assignedElements({
102
+ flatten: true
103
+ });
104
+ this.updateItems();
105
+ };
106
+ this.setFilteredPlacements = () => {
107
+ const { el, flipPlacements } = this;
108
+ this.filteredFlipPlacements = flipPlacements
109
+ ? filterComputedPlacements(flipPlacements, el)
110
+ : null;
111
+ };
112
+ this.updateTriggers = (event) => {
113
+ this.triggers = event.target.assignedElements({
114
+ flatten: true
115
+ });
116
+ this.reposition(true);
117
+ };
118
+ this.updateItems = () => {
119
+ this.items = this.groups
120
+ .map((group) => Array.from(group === null || group === void 0 ? void 0 : group.querySelectorAll("calcite-dropdown-item")))
121
+ .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
122
+ this.updateSelectedItems();
123
+ this.reposition(true);
124
+ };
125
+ this.updateGroups = (event) => {
126
+ const groups = event.target
127
+ .assignedElements({ flatten: true })
128
+ .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-dropdown-group"));
129
+ this.groups = groups;
130
+ this.updateItems();
131
+ };
132
+ this.resizeObserverCallback = (entries) => {
133
+ entries.forEach((entry) => {
134
+ const { target } = entry;
135
+ if (target === this.referenceEl) {
136
+ this.setDropdownWidth();
137
+ }
138
+ else if (target === this.scrollerEl) {
139
+ this.setMaxScrollerHeight();
140
+ }
141
+ });
142
+ };
143
+ this.setDropdownWidth = () => {
144
+ const { referenceEl, scrollerEl } = this;
145
+ const referenceElWidth = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.clientWidth;
146
+ if (!referenceElWidth || !scrollerEl) {
147
+ return;
148
+ }
149
+ scrollerEl.style.minWidth = `${referenceElWidth}px`;
150
+ };
151
+ this.setMaxScrollerHeight = () => {
152
+ const { scrollerEl } = this;
153
+ if (!scrollerEl) {
154
+ return;
155
+ }
156
+ this.reposition(true);
157
+ const maxScrollerHeight = this.getMaxScrollerHeight();
158
+ scrollerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
159
+ this.reposition(true);
160
+ };
161
+ this.setScrollerAndTransitionEl = (el) => {
162
+ this.resizeObserver.observe(el);
163
+ this.scrollerEl = el;
164
+ this.transitionEl = el;
165
+ connectOpenCloseComponent(this);
166
+ };
167
+ this.setReferenceEl = (el) => {
168
+ this.referenceEl = el;
169
+ connectFloatingUI(this, this.referenceEl, this.floatingEl);
170
+ this.resizeObserver.observe(el);
171
+ };
172
+ this.setFloatingEl = (el) => {
173
+ this.floatingEl = el;
174
+ connectFloatingUI(this, this.referenceEl, this.floatingEl);
175
+ };
176
+ this.keyDownHandler = (event) => {
177
+ const target = event.target;
178
+ if (target !== this.referenceEl) {
179
+ return;
180
+ }
181
+ const { defaultPrevented, key } = event;
182
+ if (defaultPrevented) {
183
+ return;
184
+ }
185
+ if (this.open) {
186
+ if (key === "Escape") {
187
+ this.closeCalciteDropdown();
188
+ event.preventDefault();
189
+ return;
190
+ }
191
+ else if (event.shiftKey && key === "Tab") {
192
+ this.closeCalciteDropdown();
193
+ event.preventDefault();
194
+ return;
195
+ }
196
+ }
197
+ if (isActivationKey(key)) {
198
+ this.openCalciteDropdown();
199
+ event.preventDefault();
200
+ }
201
+ else if (key === "Escape") {
202
+ this.closeCalciteDropdown();
203
+ event.preventDefault();
204
+ }
205
+ };
206
+ this.focusOnFirstActiveOrFirstItem = () => {
207
+ this.getFocusableElement(this.items.find((item) => item.selected) || this.items[0]);
208
+ };
209
+ this.toggleOpenEnd = () => {
210
+ this.focusOnFirstActiveOrFirstItem();
211
+ this.el.removeEventListener("calciteDropdownOpen", this.toggleOpenEnd);
212
+ };
213
+ this.openCalciteDropdown = () => {
214
+ this.open = !this.open;
215
+ if (this.open) {
216
+ this.el.addEventListener("calciteDropdownOpen", this.toggleOpenEnd);
217
+ }
218
+ };
219
+ }
220
+ activeHandler(value) {
221
+ this.open = value;
222
+ }
223
+ openHandler(value) {
224
+ if (!this.disabled) {
225
+ if (value) {
226
+ this.reposition(true);
227
+ }
228
+ else {
229
+ updateAfterClose(this.floatingEl);
230
+ }
231
+ this.active = value;
232
+ return;
233
+ }
234
+ if (!value) {
235
+ updateAfterClose(this.floatingEl);
236
+ }
237
+ this.open = false;
238
+ }
239
+ handleDisabledChange(value) {
240
+ if (!value) {
241
+ this.open = false;
242
+ }
243
+ }
244
+ flipPlacementsHandler() {
245
+ this.setFilteredPlacements();
246
+ this.reposition(true);
247
+ }
248
+ maxItemsHandler() {
249
+ this.setMaxScrollerHeight();
250
+ }
251
+ overlayPositioningHandler() {
252
+ this.reposition(true);
253
+ }
254
+ placementHandler() {
255
+ this.reposition(true);
256
+ }
257
+ //--------------------------------------------------------------------------
258
+ //
259
+ // Lifecycle
260
+ //
261
+ //--------------------------------------------------------------------------
262
+ connectedCallback() {
263
+ var _a;
264
+ (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
265
+ this.setFilteredPlacements();
266
+ this.reposition(true);
267
+ if (this.open) {
268
+ this.openHandler(this.open);
269
+ }
270
+ if (this.active) {
271
+ this.activeHandler(this.active);
272
+ }
273
+ connectOpenCloseComponent(this);
274
+ }
275
+ componentDidLoad() {
276
+ this.reposition(true);
277
+ }
278
+ componentDidRender() {
279
+ updateHostInteraction(this);
280
+ }
281
+ disconnectedCallback() {
282
+ var _a, _b;
283
+ (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
284
+ disconnectFloatingUI(this, this.referenceEl, this.floatingEl);
285
+ (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
286
+ disconnectOpenCloseComponent(this);
287
+ }
288
+ render() {
289
+ const { open, guid } = this;
290
+ return (h(Host, null, h("div", { class: "calcite-dropdown-trigger-container", id: `${guid}-menubutton`, onClick: this.openCalciteDropdown, onKeyDown: this.keyDownHandler, 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", ref: this.setFloatingEl }, h("div", { "aria-labelledby": `${guid}-menubutton`, class: {
291
+ ["calcite-dropdown-content"]: true,
292
+ [FloatingCSS.animation]: true,
293
+ [FloatingCSS.animationActive]: open
294
+ }, id: `${guid}-menu`, ref: this.setScrollerAndTransitionEl, role: "menu" }, h("slot", { onSlotchange: this.updateGroups })))));
295
+ }
296
+ //--------------------------------------------------------------------------
297
+ //
298
+ // Public Methods
299
+ //
300
+ //--------------------------------------------------------------------------
301
+ /**
302
+ * Updates the position of the component.
303
+ *
304
+ * @param delayed
305
+ */
306
+ async reposition(delayed = false) {
307
+ const { floatingEl, referenceEl, placement, overlayPositioning, filteredFlipPlacements } = this;
308
+ return reposition(this, {
309
+ floatingEl,
310
+ referenceEl,
311
+ overlayPositioning,
312
+ placement,
313
+ flipPlacements: filteredFlipPlacements,
314
+ type: "menu"
315
+ }, delayed);
316
+ }
317
+ closeCalciteDropdownOnClick(event) {
318
+ if (!isPrimaryPointerButton(event) || !this.open || event.composedPath().includes(this.el)) {
319
+ return;
320
+ }
321
+ this.closeCalciteDropdown(false);
322
+ }
323
+ closeCalciteDropdownOnEvent(event) {
324
+ this.closeCalciteDropdown();
325
+ event.stopPropagation();
326
+ }
327
+ closeCalciteDropdownOnOpenEvent(event) {
328
+ if (event.composedPath().includes(this.el)) {
329
+ return;
330
+ }
331
+ this.open = false;
332
+ }
333
+ mouseEnterHandler() {
334
+ if (this.type === "hover") {
335
+ this.openCalciteDropdown();
336
+ }
337
+ }
338
+ mouseLeaveHandler() {
339
+ if (this.type === "hover") {
340
+ this.closeCalciteDropdown();
341
+ }
342
+ }
343
+ calciteInternalDropdownItemKeyEvent(event) {
344
+ const { keyboardEvent } = event.detail;
345
+ // handle edge
346
+ const target = keyboardEvent.target;
347
+ const itemToFocus = target.nodeName !== "A" ? target : target.parentNode;
348
+ const isFirstItem = this.itemIndex(itemToFocus) === 0;
349
+ const isLastItem = this.itemIndex(itemToFocus) === this.items.length - 1;
350
+ switch (keyboardEvent.key) {
351
+ case "Tab":
352
+ if (isLastItem && !keyboardEvent.shiftKey) {
353
+ this.closeCalciteDropdown();
354
+ }
355
+ else if (isFirstItem && keyboardEvent.shiftKey) {
356
+ this.closeCalciteDropdown();
357
+ }
358
+ else if (keyboardEvent.shiftKey) {
359
+ this.focusPrevItem(itemToFocus);
360
+ }
361
+ else {
362
+ this.focusNextItem(itemToFocus);
363
+ }
364
+ break;
365
+ case "ArrowDown":
366
+ this.focusNextItem(itemToFocus);
367
+ break;
368
+ case "ArrowUp":
369
+ this.focusPrevItem(itemToFocus);
370
+ break;
371
+ case "Home":
372
+ this.focusFirstItem();
373
+ break;
374
+ case "End":
375
+ this.focusLastItem();
376
+ break;
377
+ }
378
+ event.stopPropagation();
379
+ }
380
+ handleItemSelect(event) {
381
+ this.updateSelectedItems();
382
+ event.stopPropagation();
383
+ this.calciteDropdownSelect.emit({
384
+ item: event.detail.requestedDropdownItem
385
+ });
386
+ if (!this.disableCloseOnSelect ||
387
+ event.detail.requestedDropdownGroup.selectionMode === "none") {
388
+ this.closeCalciteDropdown();
389
+ }
390
+ event.stopPropagation();
391
+ }
392
+ onBeforeOpen() {
393
+ this.calciteDropdownBeforeOpen.emit();
394
+ }
395
+ onOpen() {
396
+ this.calciteDropdownOpen.emit();
397
+ }
398
+ onBeforeClose() {
399
+ this.calciteDropdownBeforeClose.emit();
400
+ }
401
+ onClose() {
402
+ this.calciteDropdownClose.emit();
403
+ }
404
+ updateSelectedItems() {
405
+ this.selectedItems = this.items.filter((item) => item.selected);
406
+ }
407
+ getMaxScrollerHeight() {
408
+ const { maxItems, items } = this;
409
+ let itemsToProcess = 0;
410
+ let maxScrollerHeight = 0;
411
+ let groupHeaderHeight;
412
+ this.groups.forEach((group) => {
413
+ if (maxItems > 0 && itemsToProcess < maxItems) {
414
+ Array.from(group.children).forEach((item, index) => {
415
+ if (index === 0) {
416
+ if (isNaN(groupHeaderHeight)) {
417
+ groupHeaderHeight = item.offsetTop;
418
+ }
419
+ maxScrollerHeight += groupHeaderHeight;
420
+ }
421
+ if (itemsToProcess < maxItems) {
422
+ maxScrollerHeight += item.offsetHeight;
423
+ itemsToProcess += 1;
424
+ }
425
+ });
426
+ }
427
+ });
428
+ return items.length > maxItems ? maxScrollerHeight : 0;
429
+ }
430
+ closeCalciteDropdown(focusTrigger = true) {
431
+ this.open = false;
432
+ if (focusTrigger) {
433
+ focusElement(this.triggers[0]);
434
+ }
435
+ }
436
+ focusFirstItem() {
437
+ const firstItem = this.items[0];
438
+ this.getFocusableElement(firstItem);
439
+ }
440
+ focusLastItem() {
441
+ const lastItem = this.items[this.items.length - 1];
442
+ this.getFocusableElement(lastItem);
443
+ }
444
+ focusNextItem(el) {
445
+ const index = this.itemIndex(el);
446
+ const nextItem = this.items[index + 1] || this.items[0];
447
+ this.getFocusableElement(nextItem);
448
+ }
449
+ focusPrevItem(el) {
450
+ const index = this.itemIndex(el);
451
+ const prevItem = this.items[index - 1] || this.items[this.items.length - 1];
452
+ this.getFocusableElement(prevItem);
453
+ }
454
+ itemIndex(el) {
455
+ return this.items.indexOf(el);
456
+ }
457
+ getFocusableElement(item) {
458
+ if (!item) {
459
+ return;
460
+ }
461
+ const target = item.attributes.isLink
462
+ ? item.shadowRoot.querySelector("a")
463
+ : item;
464
+ focusElement(target);
465
+ }
466
+ get el() { return getElement(this); }
467
+ static get watchers() { return {
468
+ "active": ["activeHandler"],
469
+ "open": ["openHandler"],
470
+ "disabled": ["handleDisabledChange"],
471
+ "flipPlacements": ["flipPlacementsHandler"],
472
+ "maxItems": ["maxItemsHandler"],
473
+ "overlayPositioning": ["overlayPositioningHandler"],
474
+ "placement": ["placementHandler"]
475
+ }; }
476
+ };
477
+ Dropdown.style = dropdownCss;
478
+
14
479
  /*!
15
480
  * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
16
481
  * See https://github.com/Esri/calcite-components/blob/master/LICENSE.md for details.
@@ -453,4 +918,4 @@ const EditRecordModal = class {
453
918
  };
454
919
  EditRecordModal.style = editRecordModalCss;
455
920
 
456
- export { DropdownGroup as calcite_dropdown_group, DropdownItem as calcite_dropdown_item, SplitButton as calcite_split_button, EditRecordModal as edit_record_modal };
921
+ export { Dropdown as calcite_dropdown, DropdownGroup as calcite_dropdown_group, DropdownItem as calcite_dropdown_item, SplitButton as calcite_split_button, EditRecordModal as edit_record_modal };