@esri/solutions-components 0.8.7 → 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 (121) 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 +5 -1
  11. package/dist/cjs/crowdsource-reporter.cjs.entry.js +122 -23
  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-manager/crowdsource-manager.js +72 -0
  22. package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.css +16 -0
  23. package/dist/collection/components/crowdsource-reporter/crowdsource-reporter.js +155 -71
  24. package/dist/collection/components/feature-details/feature-details.css +18 -0
  25. package/dist/collection/components/feature-details/feature-details.js +500 -0
  26. package/dist/collection/components/feature-details/test/feature-details.e2e.js +14 -0
  27. package/dist/collection/components/feature-details/test/feature-details.spec.js +22 -0
  28. package/dist/collection/components/feature-list/feature-list.js +14 -1
  29. package/dist/collection/components/info-card/info-card.css +15 -5
  30. package/dist/collection/components/info-card/info-card.js +178 -5
  31. package/dist/collection/components/layer-table/layer-table.js +2 -2
  32. package/dist/collection/components/map-card/map-card.js +1 -1
  33. package/dist/collection/components/map-select-tools/map-select-tools.js +5 -5
  34. package/dist/collection/components/refine-selection/refine-selection.js +1 -1
  35. package/dist/collection/demos/crowdsource-reporter.html +115 -1
  36. package/dist/collection/utils/interfaces.ts +4 -4
  37. package/dist/collection/utils/mapViewUtils.js +11 -5
  38. package/dist/collection/utils/mapViewUtils.ts +13 -5
  39. package/dist/components/create-feature2.js +4 -0
  40. package/dist/components/crowdsource-manager.js +8 -0
  41. package/dist/components/crowdsource-reporter.js +270 -85
  42. package/dist/components/feature-details.d.ts +11 -0
  43. package/dist/components/feature-details.js +11 -0
  44. package/dist/components/feature-details2.js +449 -0
  45. package/dist/components/feature-list2.js +14 -1
  46. package/dist/components/info-card2.js +53 -5
  47. package/dist/components/layer-table2.js +2 -2
  48. package/dist/components/map-card2.js +1 -1
  49. package/dist/components/map-select-tools2.js +5 -5
  50. package/dist/components/mapViewUtils.js +11 -5
  51. package/dist/components/refine-selection2.js +1 -1
  52. package/dist/esm/{calcite-action-menu_2.entry.js → calcite-action-menu_3.entry.js} +118 -12
  53. package/dist/esm/calcite-alert_4.entry.js +46 -5
  54. package/dist/esm/{calcite-input-date-picker_3.entry.js → calcite-block_5.entry.js} +688 -12
  55. package/dist/esm/{calcite-combobox_5.entry.js → calcite-combobox_3.entry.js} +878 -844
  56. package/dist/esm/calcite-date-picker-day_3.entry.js +1 -1
  57. package/dist/esm/calcite-dropdown_4.entry.js +1016 -0
  58. package/dist/esm/{calcite-flow_5.entry.js → calcite-flow_6.entry.js} +327 -3
  59. package/dist/esm/card-manager_3.entry.js +5 -5
  60. package/dist/esm/crowdsource-manager.entry.js +5 -1
  61. package/dist/esm/crowdsource-reporter.entry.js +122 -23
  62. package/dist/esm/{date-5630530d.js → date-0c026a8b.js} +1 -1
  63. package/dist/esm/{downloadUtils-0c1e4d7b.js → downloadUtils-df4f21f6.js} +2 -2
  64. package/dist/esm/{index.es-286e3cfa.js → index.es-904fb846.js} +2 -2
  65. package/dist/esm/loader.js +1 -1
  66. package/dist/esm/map-select-tools_3.entry.js +8 -8
  67. package/dist/esm/{mapViewUtils-253178f1.js → mapViewUtils-2ec19fb0.js} +11 -5
  68. package/dist/esm/public-notification.entry.js +2 -2
  69. package/dist/esm/solutions-components.js +1 -1
  70. package/dist/solutions-components/demos/crowdsource-reporter.html +115 -1
  71. package/dist/solutions-components/{p-813fd8a4.entry.js → p-29f518fd.entry.js} +2 -2
  72. package/dist/solutions-components/p-452fd697.entry.js +6 -0
  73. package/dist/solutions-components/p-511b1c91.entry.js +23 -0
  74. package/dist/solutions-components/p-577efb16.js +36 -0
  75. package/dist/solutions-components/{p-94de9279.js → p-5817d78c.js} +1 -1
  76. package/dist/solutions-components/p-602cd811.entry.js +17 -0
  77. package/dist/solutions-components/{p-15f9624a.entry.js → p-6557b703.entry.js} +1 -1
  78. package/dist/solutions-components/p-7269c49b.entry.js +6 -0
  79. package/dist/solutions-components/p-760bd17e.entry.js +6 -0
  80. package/dist/solutions-components/p-95fea07a.entry.js +17 -0
  81. package/dist/solutions-components/{p-212b02e7.js → p-ae4d86e8.js} +1 -1
  82. package/dist/solutions-components/{p-038fcd93.entry.js → p-c273ab7a.entry.js} +1 -1
  83. package/dist/solutions-components/p-d742b915.entry.js +29 -0
  84. package/dist/solutions-components/p-dfad61a8.entry.js +24 -0
  85. package/dist/solutions-components/{p-331b5d1e.js → p-fca434c8.js} +2 -2
  86. package/dist/solutions-components/p-fd82a00f.entry.js +6 -0
  87. package/dist/solutions-components/solutions-components.esm.js +1 -1
  88. package/dist/solutions-components/utils/interfaces.ts +4 -4
  89. package/dist/solutions-components/utils/mapViewUtils.ts +13 -5
  90. package/dist/types/components/create-feature/create-feature.d.ts +4 -4
  91. package/dist/types/components/crowdsource-manager/crowdsource-manager.d.ts +16 -0
  92. package/dist/types/components/crowdsource-reporter/crowdsource-reporter.d.ts +91 -18
  93. package/dist/types/components/feature-details/feature-details.d.ts +151 -0
  94. package/dist/types/components/feature-list/feature-list.d.ts +6 -0
  95. package/dist/types/components/info-card/info-card.d.ts +33 -1
  96. package/dist/types/components.d.ts +161 -28
  97. package/dist/types/preact.d.ts +6 -1
  98. package/dist/types/utils/interfaces.d.ts +4 -4
  99. package/dist/types/utils/mapViewUtils.d.ts +5 -3
  100. package/package.json +1 -1
  101. package/dist/cjs/calcite-block_2.cjs.entry.js +0 -652
  102. package/dist/cjs/calcite-graph_2.cjs.entry.js +0 -1055
  103. package/dist/cjs/calcite-scrim.cjs.entry.js +0 -125
  104. package/dist/cjs/utils-7bc7f595.js +0 -64
  105. package/dist/esm/calcite-block_2.entry.js +0 -647
  106. package/dist/esm/calcite-graph_2.entry.js +0 -1050
  107. package/dist/esm/calcite-scrim.entry.js +0 -121
  108. package/dist/esm/utils-9fb4104a.js +0 -61
  109. package/dist/solutions-components/p-04c37d69.entry.js +0 -17
  110. package/dist/solutions-components/p-0b92e4b1.entry.js +0 -11
  111. package/dist/solutions-components/p-238d3b5f.entry.js +0 -6
  112. package/dist/solutions-components/p-3af79063.js +0 -36
  113. package/dist/solutions-components/p-6db185bf.entry.js +0 -6
  114. package/dist/solutions-components/p-80b11ec1.entry.js +0 -17
  115. package/dist/solutions-components/p-aec06ce4.entry.js +0 -18
  116. package/dist/solutions-components/p-bfdf89c2.js +0 -11
  117. package/dist/solutions-components/p-c4ff3b52.entry.js +0 -17
  118. package/dist/solutions-components/p-ced067bd.entry.js +0 -17
  119. package/dist/solutions-components/p-d136eab0.entry.js +0 -23
  120. package/dist/solutions-components/p-e0446d5b.entry.js +0 -6
  121. package/dist/solutions-components/p-e8f13354.entry.js +0 -6
@@ -3,16 +3,16 @@
3
3
  * Licensed under the Apache License, Version 2.0
4
4
  * http://www.apache.org/licenses/LICENSE-2.0
5
5
  */
6
- import { h, r as registerInstance, c as createEvent, H as Host, g as getElement } from './index-164d485a.js';
6
+ import { h, r as registerInstance, c as createEvent, H as Host, g as getElement, f as forceUpdate } from './index-164d485a.js';
7
7
  import { f as filter } from './filter-ce763acf.js';
8
- import { z as getElementWidth, A as getTextWidth, i as isPrimaryPointerButton, t as toAriaBoolean, d as focusElementInGroup, e as focusElement } from './dom-38c6f027.js';
8
+ import { z as getElementWidth, A as getTextWidth, i as isPrimaryPointerButton, t as toAriaBoolean, r as intersects } from './dom-38c6f027.js';
9
9
  import { d as defaultMenuPlacement, f as filterComputedPlacements, c as connectFloatingUI, r as reposition, a as disconnectFloatingUI, F as FloatingCSS } from './floating-ui-41dfe3f1.js';
10
10
  import { s as submitForm, c as connectForm, a as afterConnectDefaultValueSet, d as disconnectForm, H as HiddenFormInputSlot } from './form-50dcd52e.js';
11
11
  import { g as guid } from './guid-b75a5f7b.js';
12
12
  import { c as connectInteractive, u as updateHostInteraction, d as disconnectInteractive, I as InteractiveContainer } from './interactive-39bf5602.js';
13
13
  import { c as connectLabel, d as disconnectLabel, g as getLabelText } from './label-b4cea72e.js';
14
14
  import { b as componentLoaded, c as componentFocusable, s as setUpLoadableComponent, a as setComponentLoaded } from './loadable-37e7fbd6.js';
15
- import { c as connectLocalized, d as disconnectLocalized } from './locale-904407bf.js';
15
+ import { c as connectLocalized, d as disconnectLocalized, n as numberStringFormatter } from './locale-904407bf.js';
16
16
  import { c as createObserver } from './observers-d04d1da9.js';
17
17
  import { o as onToggleOpenCloseComponent } from './openCloseComponent-9f90f493.js';
18
18
  import { c as connectMessages, s as setUpMessages, d as disconnectMessages, u as updateMessages } from './t9n-436fb2b1.js';
@@ -21,15 +21,9 @@ import { g as getIconScale } from './component-edd2c3cd.js';
21
21
  import { V as Validation } from './Validation-ea480265.js';
22
22
  import { d as debounce } from './debounce-229b1a22.js';
23
23
  import { i as isActivationKey } from './key-c83d835f.js';
24
- import { g as getLocaleComponentStrings } from './locale-bcbea4ef.js';
25
- import { c as getMapLayerHash, o as getMapTableHash } from './mapViewUtils-253178f1.js';
26
- import { s as state } from './publicNotificationStore-223faed2.js';
24
+ import { d as decimalPlaces, c as clamp } from './math-efada7a9.js';
27
25
  import './resources-8834f920.js';
28
26
  import './browser-d60104bd.js';
29
- import './esri-loader-1b324844.js';
30
- import './_commonjsHelpers-0f74c230.js';
31
- import './interfaces-586e863c.js';
32
- import './index-477ea182.js';
33
27
 
34
28
  /*!
35
29
  * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
@@ -1125,200 +1119,391 @@ Combobox.style = comboboxCss;
1125
1119
  * See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
1126
1120
  * v2.4.0
1127
1121
  */
1128
- const SLOTS = {
1129
- dropdownTrigger: "trigger",
1122
+ /**
1123
+ * Calculate slope of the tangents
1124
+ * uses Steffen interpolation as it's monotonic
1125
+ * http://jrwalsh1.github.io/posts/interpolations/
1126
+ *
1127
+ * @param p0
1128
+ * @param p1
1129
+ * @param p2
1130
+ */
1131
+ function slope(p0, p1, p2) {
1132
+ const dx = p1[0] - p0[0];
1133
+ const dx1 = p2[0] - p1[0];
1134
+ const dy = p1[1] - p0[1];
1135
+ const dy1 = p2[1] - p1[1];
1136
+ const m = dy / (dx || (dx1 < 0 && 0));
1137
+ const m1 = dy1 / (dx1 || (dx < 0 && 0));
1138
+ const p = (m * dx1 + m1 * dx) / (dx + dx1);
1139
+ return (Math.sign(m) + Math.sign(m1)) * Math.min(Math.abs(m), Math.abs(m1), 0.5 * Math.abs(p)) || 0;
1140
+ }
1141
+ /**
1142
+ * Calculate slope for just one tangent (single-sided)
1143
+ *
1144
+ * @param p0
1145
+ * @param p1
1146
+ * @param m
1147
+ */
1148
+ function slopeSingle(p0, p1, m) {
1149
+ const dx = p1[0] - p0[0];
1150
+ const dy = p1[1] - p0[1];
1151
+ return dx ? ((3 * dy) / dx - m) / 2 : m;
1152
+ }
1153
+ /**
1154
+ * Given two points and their tangent slopes,
1155
+ * calculate the bezier handle coordinates and return draw command.
1156
+ *
1157
+ * Translates Hermite Spline to Bézier curve:
1158
+ * https://stackoverflow.com/questions/42574940/
1159
+ *
1160
+ * @param p0
1161
+ * @param p1
1162
+ * @param m0
1163
+ * @param m1
1164
+ * @param t
1165
+ */
1166
+ function bezier(p0, p1, m0, m1, t) {
1167
+ const [x0, y0] = p0;
1168
+ const [x1, y1] = p1;
1169
+ const dx = (x1 - x0) / 3;
1170
+ const h1 = t([x0 + dx, y0 + dx * m0]).join(",");
1171
+ const h2 = t([x1 - dx, y1 - dx * m1]).join(",");
1172
+ const p = t([x1, y1]).join(",");
1173
+ return `C ${h1} ${h2} ${p}`;
1174
+ }
1175
+ /**
1176
+ * Generate a function which will translate a point
1177
+ * from the data coordinate space to svg viewbox oriented pixels
1178
+ *
1179
+ * @param root0
1180
+ * @param root0.width
1181
+ * @param root0.height
1182
+ * @param root0.min
1183
+ * @param root0.max
1184
+ */
1185
+ function translate({ width, height, min, max }) {
1186
+ const rangeX = max[0] - min[0];
1187
+ const rangeY = max[1] - min[1];
1188
+ return (point) => {
1189
+ const x = ((point[0] - min[0]) / rangeX) * width;
1190
+ const y = height - (point[1] / rangeY) * height;
1191
+ return [x, y];
1192
+ };
1193
+ }
1194
+ /**
1195
+ * Get the min and max values from the dataset
1196
+ *
1197
+ * @param data
1198
+ */
1199
+ function range(data) {
1200
+ const [startX, startY] = data[0];
1201
+ const min = [startX, startY];
1202
+ const max = [startX, startY];
1203
+ return data.reduce(({ min, max }, [x, y]) => ({
1204
+ min: [Math.min(min[0], x), Math.min(min[1], y)],
1205
+ max: [Math.max(max[0], x), Math.max(max[1], y)],
1206
+ }), { min, max });
1207
+ }
1208
+ /**
1209
+ * Generate drawing commands for an area graph
1210
+ * returns a string can can be passed directly to a path element's `d` attribute
1211
+ *
1212
+ * @param root0
1213
+ * @param root0.data
1214
+ * @param root0.min
1215
+ * @param root0.max
1216
+ * @param root0.t
1217
+ */
1218
+ function area({ data, min, max, t }) {
1219
+ if (data.length === 0) {
1220
+ return "";
1221
+ }
1222
+ // important points for beginning and ending the path
1223
+ const [startX, startY] = t(data[0]);
1224
+ const [minX, minY] = t(min);
1225
+ const [maxX] = t(max);
1226
+ // keep track of previous slope/points
1227
+ let m;
1228
+ let p0;
1229
+ let p1;
1230
+ // iterate over data points, calculating command for each
1231
+ const commands = data.reduce((acc, point, i) => {
1232
+ p0 = data[i - 2];
1233
+ p1 = data[i - 1];
1234
+ if (i > 1) {
1235
+ const m1 = slope(p0, p1, point);
1236
+ const m0 = m === undefined ? slopeSingle(p0, p1, m1) : m;
1237
+ const command = bezier(p0, p1, m0, m1, t);
1238
+ m = m1;
1239
+ return `${acc} ${command}`;
1240
+ }
1241
+ return acc;
1242
+ }, `M ${minX},${minY} L ${minX},${startY} L ${startX},${startY}`);
1243
+ // close the path
1244
+ const last = data[data.length - 1];
1245
+ const end = bezier(p1, last, m, slopeSingle(p1, last, m), t);
1246
+ return `${commands} ${end} L ${maxX},${minY} Z`;
1247
+ }
1248
+
1249
+ const graphCss = ":host{display:block;block-size:100%}.svg{fill:currentColor;stroke:transparent;margin:0px;display:block;block-size:100%;inline-size:100%;padding:0px}.svg .graph-path--highlight{fill:var(--calcite-color-brand);opacity:0.5}:host([hidden]){display:none}[hidden]{display:none}";
1250
+
1251
+ const Graph = class {
1252
+ constructor(hostRef) {
1253
+ registerInstance(this, hostRef);
1254
+ this.graphId = `calcite-graph-${guid()}`;
1255
+ this.resizeObserver = createObserver("resize", () => forceUpdate(this));
1256
+ this.data = [];
1257
+ this.colorStops = undefined;
1258
+ this.highlightMin = undefined;
1259
+ this.highlightMax = undefined;
1260
+ this.min = undefined;
1261
+ this.max = undefined;
1262
+ }
1263
+ //--------------------------------------------------------------------------
1264
+ //
1265
+ // Lifecycle
1266
+ //
1267
+ //--------------------------------------------------------------------------
1268
+ connectedCallback() {
1269
+ var _a;
1270
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
1271
+ }
1272
+ disconnectedCallback() {
1273
+ var _a;
1274
+ (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1275
+ }
1276
+ render() {
1277
+ const { data, colorStops, el, highlightMax, highlightMin, min, max } = this;
1278
+ const id = this.graphId;
1279
+ const { clientHeight: height, clientWidth: width } = el;
1280
+ // if we have no data, return empty svg
1281
+ if (!data || data.length === 0) {
1282
+ return (h("svg", { "aria-hidden": "true", class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }));
1283
+ }
1284
+ const { min: rangeMin, max: rangeMax } = range(data);
1285
+ let currentMin = rangeMin;
1286
+ let currentMax = rangeMax;
1287
+ if (min < rangeMin[0] || min > rangeMin[0]) {
1288
+ currentMin = [min, 0];
1289
+ }
1290
+ if (max > rangeMax[0] || max < rangeMax[0]) {
1291
+ currentMax = [max, rangeMax[1]];
1292
+ }
1293
+ const t = translate({ min: currentMin, max: currentMax, width, height });
1294
+ const [hMinX] = t([highlightMin, currentMax[1]]);
1295
+ const [hMaxX] = t([highlightMax, currentMax[1]]);
1296
+ const areaPath = area({ data, min: rangeMin, max: rangeMax, t });
1297
+ const fill = colorStops ? `url(#linear-gradient-${id})` : undefined;
1298
+ return (h("svg", { "aria-hidden": "true", class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }, colorStops ? (h("defs", null, h("linearGradient", { id: `linear-gradient-${id}`, x1: "0", x2: "1", y1: "0", y2: "0" }, colorStops.map(({ offset, color, opacity }) => (h("stop", { offset: `${offset * 100}%`, "stop-color": color, "stop-opacity": opacity })))))) : null, highlightMin !== undefined ? ([
1299
+ h("mask", { height: "100%", id: `${id}1`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
1300
+ M 0,0
1301
+ L ${hMinX - 1},0
1302
+ L ${hMinX - 1},${height}
1303
+ L 0,${height}
1304
+ Z
1305
+ `, fill: "white" })),
1306
+ h("mask", { height: "100%", id: `${id}2`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
1307
+ M ${hMinX + 1},0
1308
+ L ${hMaxX - 1},0
1309
+ L ${hMaxX - 1},${height}
1310
+ L ${hMinX + 1}, ${height}
1311
+ Z
1312
+ `, fill: "white" })),
1313
+ h("mask", { height: "100%", id: `${id}3`, width: "100%", x: "0%", y: "0%" }, h("path", { d: `
1314
+ M ${hMaxX + 1},0
1315
+ L ${width},0
1316
+ L ${width},${height}
1317
+ L ${hMaxX + 1}, ${height}
1318
+ Z
1319
+ `, fill: "white" })),
1320
+ h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}1)` }),
1321
+ h("path", { class: "graph-path--highlight", d: areaPath, fill: fill, mask: `url(#${id}2)` }),
1322
+ h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}3)` }),
1323
+ ]) : (h("path", { class: "graph-path", d: areaPath, fill: fill }))));
1324
+ }
1325
+ get el() { return getElement(this); }
1130
1326
  };
1327
+ Graph.style = graphCss;
1131
1328
 
1132
- 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}";
1329
+ /*!
1330
+ * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
1331
+ * See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
1332
+ * v2.4.0
1333
+ */
1334
+ const CSS = {
1335
+ container: "container",
1336
+ containerRange: "container--range",
1337
+ graph: "graph",
1338
+ handle: "handle",
1339
+ handleExtension: "handle-extension",
1340
+ handleLabel: "handle__label",
1341
+ handleLabelMinValue: "handle__label--minValue",
1342
+ handleLabelValue: "handle__label--value",
1343
+ hyphen: "hyphen",
1344
+ hyphenWrap: "hyphen--wrap",
1345
+ static: "static",
1346
+ thumb: "thumb",
1347
+ thumbActive: "thumb--active",
1348
+ thumbContainer: "thumb-container",
1349
+ thumbMinValue: "thumb--minValue",
1350
+ thumbPrecise: "thumb--precise",
1351
+ thumbValue: "thumb--value",
1352
+ tick: "tick",
1353
+ tickActive: "tick--active",
1354
+ tickLabel: "tick__label",
1355
+ tickMax: "tick__label--max",
1356
+ tickMin: "tick__label--min",
1357
+ ticks: "ticks",
1358
+ track: "track",
1359
+ trackRange: "track__range",
1360
+ transformed: "transformed",
1361
+ };
1362
+ const maxTickElementThreshold = 250;
1133
1363
 
1134
- const Dropdown = class {
1364
+ const sliderCss = "@charset \"UTF-8\";: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}.scale--s{--calcite-slider-handle-size:0.625rem;--calcite-slider-handle-extension-height:0.4rem;--calcite-slider-container-font-size:var(--calcite-font-size--3)}.scale--s .handle__label,.scale--s .tick__label{line-height:.75rem}.scale--m{--calcite-slider-handle-size:0.875rem;--calcite-slider-handle-extension-height:0.5rem;--calcite-slider-container-font-size:var(--calcite-font-size--2)}.scale--m .handle__label,.scale--m .tick__label{line-height:1rem}.scale--l{--calcite-slider-handle-size:1rem;--calcite-slider-handle-extension-height:0.65rem;--calcite-slider-container-font-size:var(--calcite-font-size--1)}.scale--l .handle__label,.scale--l .tick__label{line-height:1rem}.handle__label,.tick__label{font-weight:var(--calcite-font-weight-medium);color:var(--calcite-color-text-2);font-size:var(--calcite-slider-container-font-size)}:host{display:block}.container{position:relative;display:block;overflow-wrap:normal;word-break:normal;padding-inline:calc(var(--calcite-slider-handle-size) * 0.5);padding-block:calc(var(--calcite-slider-handle-size) * 0.5);margin-block:calc(var(--calcite-slider-handle-size) * 0.5);margin-inline:0;--calcite-slider-full-handle-height:calc(\n var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height)\n );touch-action:none}:host([disabled]) .track__range,:host([disabled]) .tick--active{background-color:var(--calcite-color-text-3)}:host([disabled]) ::slotted([calcite-hydrated][disabled]),:host([disabled]) [calcite-hydrated][disabled]{opacity:1}.interaction-container{display:contents}.scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-0.375rem}.scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-0.5rem}.scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-0.55rem}:host([precise]:not([has-histogram])) .container .thumb--value{--calcite-slider-thumb-y-offset:calc(var(--calcite-slider-full-handle-height) * -1)}.thumb-container{position:relative;max-inline-size:100%}.thumb{--calcite-slider-thumb-x-offset:calc(var(--calcite-slider-handle-size) * 0.5);position:absolute;margin:0px;display:flex;cursor:pointer;flex-direction:column;align-items:center;border-style:none;background-color:transparent;padding:0px;font-family:inherit;outline:2px solid transparent;outline-offset:2px;transform:translate(var(--calcite-slider-thumb-x-offset), var(--calcite-slider-thumb-y-offset))}.thumb .handle__label.static,.thumb .handle__label.transformed{position:absolute;inset-block:0px;opacity:0}.thumb .handle__label.hyphen::after{content:\"—\";display:inline-block;inline-size:1em}.thumb .handle__label.hyphen--wrap{display:flex}.thumb .handle{box-sizing:border-box;border-radius:9999px;background-color:var(--calcite-color-foreground-1);outline-color:transparent;block-size:var(--calcite-slider-handle-size);inline-size:var(--calcite-slider-handle-size);box-shadow:0 0 0 2px var(--calcite-color-text-3) inset;transition:border var(--calcite-internal-animation-timing-medium) ease, background-color var(--calcite-internal-animation-timing-medium) ease, box-shadow var(--calcite-animation-timing) ease}.thumb .handle-extension{inline-size:0.125rem;block-size:var(--calcite-slider-handle-extension-height);background-color:var(--calcite-color-text-3)}.thumb:hover .handle{box-shadow:0 0 0 3px var(--calcite-color-brand) inset}.thumb:hover .handle-extension{background-color:var(--calcite-color-brand)}.thumb:focus .handle{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 )}.thumb:focus .handle-extension{background-color:var(--calcite-color-brand)}.thumb.thumb--minValue{transform:translate(calc(var(--calcite-slider-thumb-x-offset) * -1), var(--calcite-slider-thumb-y-offset))}.thumb.thumb--precise{--calcite-slider-thumb-y-offset:-0.125rem}:host([label-handles]) .thumb{--calcite-slider-thumb-x-offset:50%}:host([label-handles]):host(:not([has-histogram])) .scale--s .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-1.4375rem}:host([label-handles]):host(:not([has-histogram])) .scale--m .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-1.875rem}:host([label-handles]):host(:not([has-histogram])) .scale--l .thumb:not(.thumb--precise){--calcite-slider-thumb-y-offset:-2rem}:host([has-histogram][label-handles]) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--minValue.thumb--precise .handle__label{margin-block-start:0.5em}:host(:not([has-histogram]):not([precise])) .handle__label,:host([label-handles]:not([has-histogram])) .thumb--value .handle__label{margin-block-end:0.5em}:host([label-handles][precise]):host(:not([has-histogram])) .scale--s .thumb--value{--calcite-slider-thumb-y-offset:-2.075rem}:host([label-handles][precise]):host(:not([has-histogram])) .scale--m .thumb--value{--calcite-slider-thumb-y-offset:-2.75rem}:host([label-handles][precise]):host(:not([has-histogram])) .scale--l .thumb--value{--calcite-slider-thumb-y-offset:-3.0625rem}.thumb:focus .handle,.thumb--active .handle{background-color:var(--calcite-color-brand);box-shadow:0 0 8px 0 rgba(0, 0, 0, 0.16)}.thumb:hover.thumb--precise:after,.thumb:focus.thumb--precise:after,.thumb--active.thumb--precise:after{background-color:var(--calcite-color-brand)}.track{position:relative;block-size:0.125rem;border-radius:0px;background-color:var(--calcite-color-border-2);transition:all var(--calcite-internal-animation-timing-medium) ease-in}.track__range{position:absolute;inset-block-start:0px;block-size:0.125rem;background-color:var(--calcite-color-brand)}.container--range .track__range:hover{cursor:ew-resize}.container--range .track__range:after{position:absolute;inline-size:100%;content:\"\";inset-block-start:calc(var(--calcite-slider-full-handle-height) * 0.5 * -1);block-size:calc(var(--calcite-slider-handle-size) + var(--calcite-slider-handle-extension-height))}@media (forced-colors: active){.thumb{outline-width:0;outline-offset:0}.handle{outline:2px solid transparent;outline-offset:2px}.thumb:focus .handle,.thumb .handle-extension,.thumb:hover .handle-extension,.thumb:focus .handle-extension,.thumb:active .handle-extension{background-color:canvasText}.track{background-color:canvasText}.track__range{background-color:highlight}}.tick{position:absolute;block-size:0.25rem;inline-size:0.125rem;border-width:1px;border-style:solid;background-color:var(--calcite-color-border-input);border-color:var(--calcite-color-foreground-1);inset-block-start:-2px;pointer-events:none;margin-inline-start:calc(-1 * 0.125rem)}.tick--active{background-color:var(--calcite-color-brand)}.tick__label{pointer-events:none;margin-block-start:0.875rem;display:flex;justify-content:center}.tick__label--min{transition:opacity var(--calcite-animation-timing)}.tick__label--max{transition:opacity var(--calcite-internal-animation-timing-fast)}:host([has-histogram][label-handles]) .tick__label--min,:host([has-histogram][label-handles]) .tick__label--max,:host([has-histogram][precise]) .tick__label--min,:host([has-histogram][precise]) .tick__label--max{font-weight:var(--calcite-font-weight-normal);color:var(--calcite-color-text-3)}.graph{color:var(--calcite-color-foreground-3);block-size:48px}:host([label-ticks][ticks]) .container{padding-block-end:calc(0.875rem + var(--calcite-slider-container-font-size))}:host([has-histogram]):host([precise][label-handles]) .container{padding-block-end:calc(var(--calcite-slider-full-handle-height) + 1em)}:host([has-histogram]):host([label-handles]:not([precise])) .container{padding-block-end:calc(var(--calcite-slider-handle-size) * 0.5 + 1em)}:host([has-histogram]):host([precise]:not([label-handles])) .container{padding-block-end:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container{padding-block-start:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([precise]:not([label-handles])) .container--range{padding-block-end:var(--calcite-slider-full-handle-height)}:host(:not([has-histogram])):host([label-handles]:not([precise])) .container{padding-block-start:calc(var(--calcite-slider-full-handle-height) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container{padding-block-start:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}:host(:not([has-histogram])):host([label-handles][precise]) .container--range{padding-block-end:calc(var(--calcite-slider-full-handle-height) + var(--calcite-slider-container-font-size) + 4px)}::slotted(input[slot=hidden-form-input]){margin:0 !important;opacity:0 !important;outline:none !important;padding:0 !important;position:absolute !important;inset:0 !important;transform:none !important;-webkit-appearance:none !important;z-index:-1 !important}:host([hidden]){display:none}[hidden]{display:none}";
1365
+
1366
+ function isRange(value) {
1367
+ return Array.isArray(value);
1368
+ }
1369
+ const Slider = class {
1135
1370
  constructor(hostRef) {
1136
1371
  registerInstance(this, hostRef);
1137
- this.calciteDropdownSelect = createEvent(this, "calciteDropdownSelect", 6);
1138
- this.calciteDropdownBeforeClose = createEvent(this, "calciteDropdownBeforeClose", 6);
1139
- this.calciteDropdownClose = createEvent(this, "calciteDropdownClose", 6);
1140
- this.calciteDropdownBeforeOpen = createEvent(this, "calciteDropdownBeforeOpen", 6);
1141
- this.calciteDropdownOpen = createEvent(this, "calciteDropdownOpen", 6);
1142
- this.items = [];
1143
- this.groups = [];
1144
- this.mutationObserver = createObserver("mutation", () => this.updateItems());
1145
- this.resizeObserver = createObserver("resize", (entries) => this.resizeObserverCallback(entries));
1146
- this.openTransitionProp = "opacity";
1147
- this.guid = `calcite-dropdown-${guid()}`;
1148
- this.defaultAssignedElements = [];
1149
- //--------------------------------------------------------------------------
1150
- //
1151
- // Private Methods
1152
- //
1153
- //--------------------------------------------------------------------------
1154
- this.slotChangeHandler = (event) => {
1155
- this.defaultAssignedElements = event.target.assignedElements({
1156
- flatten: true,
1157
- });
1158
- this.updateItems();
1372
+ this.calciteSliderInput = createEvent(this, "calciteSliderInput", 6);
1373
+ this.calciteSliderChange = createEvent(this, "calciteSliderChange", 6);
1374
+ this.activeProp = "value";
1375
+ this.guid = `calcite-slider-${guid()}`;
1376
+ this.onThumbBlur = () => {
1377
+ this.activeProp = null;
1159
1378
  };
1160
- this.setFilteredPlacements = () => {
1161
- const { el, flipPlacements } = this;
1162
- this.filteredFlipPlacements = flipPlacements
1163
- ? filterComputedPlacements(flipPlacements, el)
1164
- : null;
1379
+ this.onThumbFocus = (event) => {
1380
+ const thumb = event.currentTarget;
1381
+ this.activeProp = thumb.getAttribute("data-value-prop");
1165
1382
  };
1166
- this.updateTriggers = (event) => {
1167
- this.triggers = event.target.assignedElements({
1168
- flatten: true,
1169
- });
1170
- this.reposition(true);
1171
- };
1172
- this.updateItems = () => {
1173
- this.items = this.groups
1174
- .map((group) => Array.from(group === null || group === void 0 ? void 0 : group.querySelectorAll("calcite-dropdown-item")))
1175
- .reduce((previousValue, currentValue) => [...previousValue, ...currentValue], []);
1176
- this.updateSelectedItems();
1177
- this.reposition(true);
1178
- this.items.forEach((item) => (item.scale = this.scale));
1383
+ this.onThumbPointerDown = (event) => {
1384
+ const thumb = event.currentTarget;
1385
+ this.pointerDownDragStart(event, thumb.getAttribute("data-value-prop"));
1179
1386
  };
1180
- this.updateGroups = (event) => {
1181
- const groups = event.target
1182
- .assignedElements({ flatten: true })
1183
- .filter((el) => el === null || el === void 0 ? void 0 : el.matches("calcite-dropdown-group"));
1184
- this.groups = groups;
1185
- this.updateItems();
1387
+ this.onTrackPointerDown = (event) => {
1388
+ this.pointerDownDragStart(event, "minMaxValue");
1186
1389
  };
1187
- this.resizeObserverCallback = (entries) => {
1188
- entries.forEach((entry) => {
1189
- const { target } = entry;
1190
- if (target === this.referenceEl) {
1191
- this.setDropdownWidth();
1390
+ this.dragUpdate = (event) => {
1391
+ if (this.disabled) {
1392
+ return;
1393
+ }
1394
+ event.preventDefault();
1395
+ if (this.dragProp) {
1396
+ const value = this.translate(event.clientX || event.pageX);
1397
+ if (isRange(this.value) && this.dragProp === "minMaxValue") {
1398
+ if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
1399
+ const newMinValue = value - this.minValueDragRange;
1400
+ const newMaxValue = value + this.maxValueDragRange;
1401
+ if (newMaxValue <= this.max &&
1402
+ newMinValue >= this.min &&
1403
+ newMaxValue - newMinValue === this.minMaxValueRange) {
1404
+ this.setValue({
1405
+ minValue: this.clamp(newMinValue, "minValue"),
1406
+ maxValue: this.clamp(newMaxValue, "maxValue"),
1407
+ });
1408
+ }
1409
+ }
1410
+ else {
1411
+ this.minValueDragRange = value - this.minValue;
1412
+ this.maxValueDragRange = this.maxValue - value;
1413
+ this.minMaxValueRange = this.maxValue - this.minValue;
1414
+ }
1192
1415
  }
1193
- else if (target === this.scrollerEl) {
1194
- this.setMaxScrollerHeight();
1416
+ else {
1417
+ this.setValue({ [this.dragProp]: this.clamp(value, this.dragProp) });
1195
1418
  }
1196
- });
1197
- };
1198
- this.setDropdownWidth = () => {
1199
- const { referenceEl, scrollerEl } = this;
1200
- const referenceElWidth = referenceEl === null || referenceEl === void 0 ? void 0 : referenceEl.clientWidth;
1201
- if (!referenceElWidth || !scrollerEl) {
1202
- return;
1203
1419
  }
1204
- scrollerEl.style.minWidth = `${referenceElWidth}px`;
1205
1420
  };
1206
- this.setMaxScrollerHeight = () => {
1207
- const { scrollerEl } = this;
1208
- if (!scrollerEl) {
1421
+ this.pointerUpDragEnd = (event) => {
1422
+ if (this.disabled || !isPrimaryPointerButton(event)) {
1209
1423
  return;
1210
1424
  }
1211
- this.reposition(true);
1212
- const maxScrollerHeight = this.getMaxScrollerHeight();
1213
- scrollerEl.style.maxHeight = maxScrollerHeight > 0 ? `${maxScrollerHeight}px` : "";
1214
- this.reposition(true);
1215
- };
1216
- this.setScrollerAndTransitionEl = (el) => {
1217
- this.resizeObserver.observe(el);
1218
- this.scrollerEl = el;
1219
- this.transitionEl = el;
1220
- };
1221
- this.setReferenceEl = (el) => {
1222
- this.referenceEl = el;
1223
- connectFloatingUI(this, this.referenceEl, this.floatingEl);
1224
- this.resizeObserver.observe(el);
1225
- };
1226
- this.setFloatingEl = (el) => {
1227
- this.floatingEl = el;
1228
- connectFloatingUI(this, this.referenceEl, this.floatingEl);
1425
+ this.dragEnd(event);
1229
1426
  };
1230
- this.keyDownHandler = (event) => {
1231
- if (!event.composedPath().includes(this.referenceEl)) {
1427
+ this.dragEnd = (event) => {
1428
+ if (this.disabled) {
1232
1429
  return;
1233
1430
  }
1234
- const { defaultPrevented, key } = event;
1235
- if (defaultPrevented) {
1236
- return;
1431
+ this.removeDragListeners();
1432
+ this.focusActiveHandle(event.clientX);
1433
+ if (this.lastDragPropValue != this[this.dragProp]) {
1434
+ this.emitChange();
1237
1435
  }
1238
- if (this.open) {
1239
- if (key === "Escape") {
1240
- this.closeCalciteDropdown();
1241
- event.preventDefault();
1242
- return;
1243
- }
1244
- else if (event.shiftKey && key === "Tab") {
1245
- this.closeCalciteDropdown();
1246
- event.preventDefault();
1247
- return;
1248
- }
1249
- }
1250
- if (isActivationKey(key)) {
1251
- this.openCalciteDropdown();
1252
- event.preventDefault();
1253
- }
1254
- else if (key === "Escape") {
1255
- this.closeCalciteDropdown();
1256
- event.preventDefault();
1257
- }
1258
- };
1259
- this.focusOnFirstActiveOrFirstItem = () => {
1260
- this.getFocusableElement(this.getTraversableItems().find((item) => item.selected) || this.items[0]);
1436
+ this.dragProp = null;
1437
+ this.lastDragPropValue = null;
1438
+ this.minValueDragRange = null;
1439
+ this.maxValueDragRange = null;
1440
+ this.minMaxValueRange = null;
1261
1441
  };
1262
- this.toggleOpenEnd = () => {
1263
- this.focusOnFirstActiveOrFirstItem();
1264
- this.el.removeEventListener("calciteDropdownOpen", this.toggleOpenEnd);
1442
+ this.storeTrackRef = (node) => {
1443
+ this.trackEl = node;
1265
1444
  };
1266
- this.openCalciteDropdown = () => {
1267
- this.open = !this.open;
1268
- if (this.open) {
1269
- this.el.addEventListener("calciteDropdownOpen", this.toggleOpenEnd);
1445
+ this.storeThumbRef = (el) => {
1446
+ if (!el) {
1447
+ return;
1270
1448
  }
1449
+ const valueProp = el.getAttribute("data-value-prop");
1450
+ valueProp === "minValue" ? (this.minHandle = el) : (this.maxHandle = el);
1451
+ };
1452
+ /**
1453
+ * Returns a string representing the localized label value based if the groupSeparator prop is parsed.
1454
+ *
1455
+ * @param value
1456
+ */
1457
+ this.formatValue = (value) => {
1458
+ numberStringFormatter.numberFormatOptions = {
1459
+ locale: this.effectiveLocale,
1460
+ numberingSystem: this.numberingSystem,
1461
+ useGrouping: this.groupSeparator,
1462
+ };
1463
+ return numberStringFormatter.localize(value.toString());
1271
1464
  };
1272
- this.open = false;
1273
- this.closeOnSelectDisabled = false;
1274
1465
  this.disabled = false;
1275
- this.flipPlacements = undefined;
1276
- this.maxItems = 0;
1277
- this.overlayPositioning = "absolute";
1278
- this.placement = defaultMenuPlacement;
1279
- this.selectedItems = [];
1280
- this.type = "click";
1281
- this.widthScale = undefined;
1466
+ this.form = undefined;
1467
+ this.groupSeparator = false;
1468
+ this.hasHistogram = false;
1469
+ this.histogram = undefined;
1470
+ this.histogramStops = undefined;
1471
+ this.labelHandles = false;
1472
+ this.labelTicks = false;
1473
+ this.max = 100;
1474
+ this.maxLabel = undefined;
1475
+ this.maxValue = undefined;
1476
+ this.min = 0;
1477
+ this.minLabel = undefined;
1478
+ this.minValue = undefined;
1479
+ this.mirrored = false;
1480
+ this.name = undefined;
1481
+ this.numberingSystem = undefined;
1482
+ this.pageStep = undefined;
1483
+ this.precise = false;
1484
+ this.required = false;
1485
+ this.snap = false;
1486
+ this.step = 1;
1487
+ this.ticks = undefined;
1488
+ this.value = 0;
1282
1489
  this.scale = "m";
1490
+ this.effectiveLocale = "";
1491
+ this.minMaxValueRange = null;
1492
+ this.minValueDragRange = null;
1493
+ this.maxValueDragRange = null;
1494
+ this.tickValues = [];
1283
1495
  }
1284
- openHandler() {
1285
- onToggleOpenCloseComponent(this);
1286
- if (this.disabled) {
1287
- this.open = false;
1288
- return;
1289
- }
1290
- this.reposition(true);
1496
+ histogramWatcher(newHistogram) {
1497
+ this.hasHistogram = !!newHistogram;
1291
1498
  }
1292
- handleDisabledChange(value) {
1293
- if (!value) {
1294
- this.open = false;
1295
- }
1499
+ ticksWatcher() {
1500
+ this.tickValues = this.generateTickValues();
1296
1501
  }
1297
- flipPlacementsHandler() {
1298
- this.setFilteredPlacements();
1299
- this.reposition(true);
1502
+ valueHandler() {
1503
+ this.setMinMaxFromValue();
1300
1504
  }
1301
- maxItemsHandler() {
1302
- this.setMaxScrollerHeight();
1303
- }
1304
- overlayPositioningHandler() {
1305
- this.reposition(true);
1306
- }
1307
- placementHandler() {
1308
- this.reposition(true);
1309
- }
1310
- handlePropsChange() {
1311
- this.updateItems();
1312
- }
1313
- //--------------------------------------------------------------------------
1314
- //
1315
- // Public Methods
1316
- //
1317
- //--------------------------------------------------------------------------
1318
- /** Sets focus on the component's first focusable element. */
1319
- async setFocus() {
1320
- await componentFocusable(this);
1321
- this.el.focus();
1505
+ minMaxValueHandler() {
1506
+ this.setValueFromMinMax();
1322
1507
  }
1323
1508
  //--------------------------------------------------------------------------
1324
1509
  //
@@ -1326,316 +1511,234 @@ const Dropdown = class {
1326
1511
  //
1327
1512
  //--------------------------------------------------------------------------
1328
1513
  connectedCallback() {
1329
- var _a;
1330
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true, subtree: true });
1331
- this.setFilteredPlacements();
1332
- this.reposition(true);
1333
- if (this.open) {
1334
- this.openHandler();
1335
- onToggleOpenCloseComponent(this);
1336
- }
1337
1514
  connectInteractive(this);
1338
- this.updateItems();
1339
- connectFloatingUI(this, this.referenceEl, this.floatingEl);
1515
+ connectLocalized(this);
1516
+ this.setMinMaxFromValue();
1517
+ this.setValueFromMinMax();
1518
+ connectLabel(this);
1519
+ connectForm(this);
1520
+ }
1521
+ disconnectedCallback() {
1522
+ disconnectInteractive(this);
1523
+ disconnectLabel(this);
1524
+ disconnectForm(this);
1525
+ disconnectLocalized(this);
1526
+ this.removeDragListeners();
1340
1527
  }
1341
1528
  componentWillLoad() {
1342
1529
  setUpLoadableComponent(this);
1530
+ if (!isRange(this.value)) {
1531
+ this.value = this.snap ? this.getClosestStep(this.value) : this.clamp(this.value);
1532
+ }
1533
+ this.ticksWatcher();
1534
+ this.histogramWatcher(this.histogram);
1535
+ afterConnectDefaultValueSet(this, this.value);
1343
1536
  }
1344
1537
  componentDidLoad() {
1345
1538
  setComponentLoaded(this);
1346
- this.reposition(true);
1347
1539
  }
1348
1540
  componentDidRender() {
1541
+ if (this.labelHandles) {
1542
+ this.adjustHostObscuredHandleLabel("value");
1543
+ if (isRange(this.value)) {
1544
+ this.adjustHostObscuredHandleLabel("minValue");
1545
+ if (!(this.precise && !this.hasHistogram)) {
1546
+ this.hyphenateCollidingRangeHandleLabels();
1547
+ }
1548
+ }
1549
+ }
1550
+ this.hideObscuredBoundingTickLabels();
1349
1551
  updateHostInteraction(this);
1350
1552
  }
1351
- disconnectedCallback() {
1352
- var _a, _b;
1353
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1354
- (_b = this.resizeObserver) === null || _b === void 0 ? void 0 : _b.disconnect();
1355
- disconnectInteractive(this);
1356
- disconnectFloatingUI(this, this.referenceEl, this.floatingEl);
1357
- }
1358
1553
  render() {
1359
- const { open, guid } = this;
1360
- return (h(Host, null, h(InteractiveContainer, { disabled: this.disabled }, h("div", { class: "calcite-trigger-container", id: `${guid}-menubutton`, onClick: this.openCalciteDropdown, onKeyDown: this.keyDownHandler,
1361
- // 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)
1362
- 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",
1554
+ const id = this.el.id || this.guid;
1555
+ const value = isRange(this.value) ? this.maxValue : this.value;
1556
+ const min = this.minValue || this.min;
1557
+ const useMinValue = this.shouldUseMinValue();
1558
+ const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
1559
+ const maxInterval = this.getUnitInterval(value) * 100;
1560
+ const mirror = this.shouldMirror();
1561
+ const valueIsRange = isRange(this.value);
1562
+ const thumbTypes = this.buildThumbType("max");
1563
+ const thumb = this.renderThumb({
1564
+ type: thumbTypes,
1565
+ thumbPlacement: thumbTypes.includes("histogram") ? "below" : "above",
1566
+ maxInterval,
1567
+ minInterval,
1568
+ mirror,
1569
+ });
1570
+ const minThumbTypes = this.buildThumbType("min");
1571
+ const minThumb = valueIsRange &&
1572
+ this.renderThumb({
1573
+ type: minThumbTypes,
1574
+ thumbPlacement: minThumbTypes.includes("histogram") || minThumbTypes.includes("precise")
1575
+ ? "below"
1576
+ : "above",
1577
+ maxInterval,
1578
+ minInterval,
1579
+ mirror,
1580
+ });
1581
+ return (h(Host, { id: id, onTouchStart: this.handleTouchStart }, h(InteractiveContainer, { disabled: this.disabled }, h("div", { "aria-label": getLabelText(this), class: {
1582
+ [CSS.container]: true,
1583
+ [CSS.containerRange]: valueIsRange,
1584
+ [`scale--${this.scale}`]: true,
1585
+ } }, this.renderGraph(), h("div", { class: CSS.track,
1363
1586
  // 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)
1364
- ref: this.setFloatingEl }, h("div", { "aria-labelledby": `${guid}-menubutton`, class: {
1365
- ["calcite-dropdown-content"]: true,
1366
- [FloatingCSS.animation]: true,
1367
- [FloatingCSS.animationActive]: open,
1368
- }, id: `${guid}-menu`, role: "menu",
1587
+ ref: this.storeTrackRef }, h("div", { class: CSS.trackRange, onPointerDown: this.onTrackPointerDown, style: {
1588
+ left: `${mirror ? 100 - maxInterval : minInterval}%`,
1589
+ right: `${mirror ? minInterval : 100 - maxInterval}%`,
1590
+ } }), h("div", { class: CSS.ticks }, this.tickValues.map((tick) => {
1591
+ const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
1592
+ let activeTicks = tick >= min && tick <= value;
1593
+ if (useMinValue) {
1594
+ activeTicks = tick >= this.minValue && tick <= this.maxValue;
1595
+ }
1596
+ return (h("span", { class: {
1597
+ [CSS.tick]: true,
1598
+ [CSS.tickActive]: activeTicks,
1599
+ }, style: {
1600
+ left: mirror ? "" : tickOffset,
1601
+ right: mirror ? tickOffset : "",
1602
+ } }, this.renderTickLabel(tick)));
1603
+ }))), h("div", { class: CSS.thumbContainer }, minThumb, thumb, h(HiddenFormInputSlot, { component: this }))))));
1604
+ }
1605
+ renderThumb({ type, mirror, thumbPlacement, minInterval, maxInterval, }) {
1606
+ const isLabeled = type.includes("labeled");
1607
+ const isPrecise = type.includes("precise");
1608
+ const isMinThumb = type.includes("min");
1609
+ const valueIsRange = isRange(this.value);
1610
+ const value = isMinThumb
1611
+ ? this.minValue
1612
+ : valueIsRange
1613
+ ? this.maxValue
1614
+ : this.value;
1615
+ const valueProp = isMinThumb ? "minValue" : valueIsRange ? "maxValue" : "value";
1616
+ const ariaLabel = isMinThumb ? this.minLabel : valueIsRange ? this.maxLabel : this.minLabel;
1617
+ const ariaValuenow = isMinThumb ? this.minValue : value;
1618
+ const displayedValue = isMinThumb ? this.formatValue(this.minValue) : this.formatValue(value);
1619
+ const thumbStyle = isMinThumb
1620
+ ? { left: `${mirror ? 100 - minInterval : minInterval}%` }
1621
+ : { right: `${mirror ? maxInterval : 100 - maxInterval}%` };
1622
+ const thumbLabelClasses = `${CSS.handleLabel} ${isMinThumb ? CSS.handleLabelMinValue : CSS.handleLabelValue}`;
1623
+ const labels = isLabeled
1624
+ ? [
1625
+ h("span", { "aria-hidden": "true", class: thumbLabelClasses }, displayedValue),
1626
+ h("span", { "aria-hidden": "true", class: `${thumbLabelClasses} ${CSS.static}` }, displayedValue),
1627
+ h("span", { "aria-hidden": "true", class: `${thumbLabelClasses} ${CSS.transformed}` }, displayedValue),
1628
+ ]
1629
+ : [];
1630
+ const thumbContent = [
1631
+ ...labels,
1632
+ h("div", { class: CSS.handle }),
1633
+ isPrecise && h("div", { class: CSS.handleExtension }),
1634
+ ];
1635
+ if (thumbPlacement === "below") {
1636
+ thumbContent.reverse();
1637
+ }
1638
+ return (h("div", { "aria-disabled": this.disabled, "aria-label": ariaLabel, "aria-orientation": "horizontal", "aria-valuemax": this.max, "aria-valuemin": this.min, "aria-valuenow": ariaValuenow, class: {
1639
+ [CSS.thumb]: true,
1640
+ [CSS.thumbValue]: !isMinThumb,
1641
+ [CSS.thumbActive]: this.lastDragProp !== "minMaxValue" && this.dragProp === valueProp,
1642
+ [CSS.thumbPrecise]: isPrecise,
1643
+ [CSS.thumbMinValue]: isMinThumb,
1644
+ }, "data-value-prop": valueProp, key: type, onBlur: this.onThumbBlur, onFocus: this.onThumbFocus, onPointerDown: this.onThumbPointerDown, role: "slider", style: thumbStyle, tabIndex: 0,
1369
1645
  // 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)
1370
- ref: this.setScrollerAndTransitionEl }, h("slot", { onSlotchange: this.updateGroups }))))));
1646
+ ref: this.storeThumbRef }, thumbContent));
1647
+ }
1648
+ renderGraph() {
1649
+ return this.histogram ? (h("calcite-graph", { class: CSS.graph, colorStops: this.histogramStops, data: this.histogram, highlightMax: isRange(this.value) ? this.maxValue : this.value, highlightMin: isRange(this.value) ? this.minValue : this.min, max: this.max, min: this.min })) : null;
1650
+ }
1651
+ renderTickLabel(tick) {
1652
+ const { hasHistogram, labelHandles, labelTicks, max, min, precise, value } = this;
1653
+ const valueIsRange = isRange(value);
1654
+ const isMinTickLabel = tick === min;
1655
+ const isMaxTickLabel = tick === max;
1656
+ const isAtEdge = isMinTickLabel || isMaxTickLabel;
1657
+ const shouldDisplayLabel = labelTicks &&
1658
+ ((!hasHistogram && (isAtEdge || !precise || !valueIsRange)) ||
1659
+ (hasHistogram && (isAtEdge || (!precise && !labelHandles))));
1660
+ return shouldDisplayLabel ? (h("span", { class: {
1661
+ [CSS.tickLabel]: true,
1662
+ [CSS.tickMin]: isMinTickLabel,
1663
+ [CSS.tickMax]: isMaxTickLabel,
1664
+ } }, this.formatValue(tick))) : null;
1371
1665
  }
1372
1666
  //--------------------------------------------------------------------------
1373
1667
  //
1374
- // Public Methods
1668
+ // Event Listeners
1375
1669
  //
1376
1670
  //--------------------------------------------------------------------------
1377
- /**
1378
- * Updates the position of the component.
1379
- *
1380
- * @param delayed
1381
- */
1382
- async reposition(delayed = false) {
1383
- const { floatingEl, referenceEl, placement, overlayPositioning, filteredFlipPlacements } = this;
1384
- return reposition(this, {
1385
- floatingEl,
1386
- referenceEl,
1387
- overlayPositioning,
1388
- placement,
1389
- flipPlacements: filteredFlipPlacements,
1390
- type: "menu",
1391
- }, delayed);
1392
- }
1393
- closeCalciteDropdownOnClick(event) {
1394
- if (this.disabled ||
1395
- !isPrimaryPointerButton(event) ||
1396
- !this.open ||
1397
- event.composedPath().includes(this.el)) {
1671
+ keyDownHandler(event) {
1672
+ const mirror = this.shouldMirror();
1673
+ const { activeProp, max, min, pageStep, step } = this;
1674
+ const value = this[activeProp];
1675
+ const { key } = event;
1676
+ if (isActivationKey(key)) {
1677
+ event.preventDefault();
1398
1678
  return;
1399
1679
  }
1400
- this.closeCalciteDropdown(false);
1401
- }
1402
- closeCalciteDropdownOnEvent(event) {
1403
- this.closeCalciteDropdown();
1404
- event.stopPropagation();
1405
- }
1406
- closeCalciteDropdownOnOpenEvent(event) {
1407
- if (event.composedPath().includes(this.el)) {
1408
- return;
1680
+ let adjustment;
1681
+ if (key === "ArrowUp" || key === "ArrowRight") {
1682
+ const directionFactor = mirror && key === "ArrowRight" ? -1 : 1;
1683
+ adjustment = value + step * directionFactor;
1409
1684
  }
1410
- this.open = false;
1411
- }
1412
- pointerEnterHandler() {
1413
- if (this.disabled || this.type !== "hover") {
1414
- return;
1685
+ else if (key === "ArrowDown" || key === "ArrowLeft") {
1686
+ const directionFactor = mirror && key === "ArrowLeft" ? -1 : 1;
1687
+ adjustment = value - step * directionFactor;
1415
1688
  }
1416
- this.openCalciteDropdown();
1417
- }
1418
- pointerLeaveHandler() {
1419
- if (this.disabled || this.type !== "hover") {
1420
- return;
1689
+ else if (key === "PageUp") {
1690
+ if (pageStep) {
1691
+ adjustment = value + pageStep;
1692
+ }
1421
1693
  }
1422
- this.closeCalciteDropdown();
1423
- }
1424
- getTraversableItems() {
1425
- return this.items.filter((item) => !item.disabled && !item.hidden);
1426
- }
1427
- calciteInternalDropdownItemKeyEvent(event) {
1428
- const { keyboardEvent } = event.detail;
1429
- const target = keyboardEvent.target;
1430
- const traversableItems = this.getTraversableItems();
1431
- switch (keyboardEvent.key) {
1432
- case "Tab":
1433
- this.open = false;
1434
- this.updateTabIndexOfItems(target);
1435
- break;
1436
- case "ArrowDown":
1437
- focusElementInGroup(traversableItems, target, "next");
1438
- break;
1439
- case "ArrowUp":
1440
- focusElementInGroup(traversableItems, target, "previous");
1441
- break;
1442
- case "Home":
1443
- focusElementInGroup(traversableItems, target, "first");
1444
- break;
1445
- case "End":
1446
- focusElementInGroup(traversableItems, target, "last");
1447
- break;
1694
+ else if (key === "PageDown") {
1695
+ if (pageStep) {
1696
+ adjustment = value - pageStep;
1697
+ }
1448
1698
  }
1449
- event.stopPropagation();
1450
- }
1451
- handleItemSelect(event) {
1452
- this.updateSelectedItems();
1453
- event.stopPropagation();
1454
- this.calciteDropdownSelect.emit();
1455
- if (!this.closeOnSelectDisabled ||
1456
- event.detail.requestedDropdownGroup.selectionMode === "none") {
1457
- this.closeCalciteDropdown();
1699
+ else if (key === "Home") {
1700
+ adjustment = min;
1458
1701
  }
1459
- event.stopPropagation();
1460
- }
1461
- onBeforeOpen() {
1462
- this.calciteDropdownBeforeOpen.emit();
1463
- }
1464
- onOpen() {
1465
- this.calciteDropdownOpen.emit();
1466
- }
1467
- onBeforeClose() {
1468
- this.calciteDropdownBeforeClose.emit();
1469
- }
1470
- onClose() {
1471
- this.calciteDropdownClose.emit();
1472
- }
1473
- updateSelectedItems() {
1474
- this.selectedItems = this.items.filter((item) => item.selected);
1475
- }
1476
- getMaxScrollerHeight() {
1477
- const { maxItems, items } = this;
1478
- let itemsToProcess = 0;
1479
- let maxScrollerHeight = 0;
1480
- let groupHeaderHeight;
1481
- this.groups.forEach((group) => {
1482
- if (maxItems > 0 && itemsToProcess < maxItems) {
1483
- Array.from(group.children).forEach((item, index) => {
1484
- if (index === 0) {
1485
- if (isNaN(groupHeaderHeight)) {
1486
- groupHeaderHeight = item.offsetTop;
1487
- }
1488
- maxScrollerHeight += groupHeaderHeight;
1489
- }
1490
- if (itemsToProcess < maxItems) {
1491
- maxScrollerHeight += item.offsetHeight;
1492
- itemsToProcess += 1;
1493
- }
1494
- });
1495
- }
1496
- });
1497
- return items.length > maxItems ? maxScrollerHeight : 0;
1498
- }
1499
- closeCalciteDropdown(focusTrigger = true) {
1500
- this.open = false;
1501
- if (focusTrigger) {
1502
- focusElement(this.triggers[0]);
1702
+ else if (key === "End") {
1703
+ adjustment = max;
1503
1704
  }
1504
- }
1505
- getFocusableElement(item) {
1506
- if (!item) {
1705
+ if (isNaN(adjustment)) {
1507
1706
  return;
1508
1707
  }
1509
- focusElement(item);
1510
- }
1511
- updateTabIndexOfItems(target) {
1512
- this.items.forEach((item) => {
1513
- item.tabIndex = target !== item ? -1 : 0;
1708
+ event.preventDefault();
1709
+ const fixedDecimalAdjustment = Number(adjustment.toFixed(decimalPlaces(step)));
1710
+ this.setValue({
1711
+ [activeProp]: this.clamp(fixedDecimalAdjustment, activeProp),
1514
1712
  });
1515
1713
  }
1516
- static get delegatesFocus() { return true; }
1517
- get el() { return getElement(this); }
1518
- static get watchers() { return {
1519
- "open": ["openHandler"],
1520
- "disabled": ["handleDisabledChange"],
1521
- "flipPlacements": ["flipPlacementsHandler"],
1522
- "maxItems": ["maxItemsHandler"],
1523
- "overlayPositioning": ["overlayPositioningHandler"],
1524
- "placement": ["placementHandler"],
1525
- "scale": ["handlePropsChange"]
1526
- }; }
1527
- };
1528
- Dropdown.style = dropdownCss;
1529
-
1530
- /*!
1531
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
1532
- * See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
1533
- * v2.4.0
1534
- */
1535
- const CSS = {
1536
- container: "container",
1537
- containerLink: "container--link",
1538
- containerMulti: "container--multi-selection",
1539
- containerSingle: "container--single-selection",
1540
- containerNone: "container--none-selection",
1541
- icon: "dropdown-item-icon",
1542
- iconEnd: "dropdown-item-icon-end",
1543
- iconStart: "dropdown-item-icon-start",
1544
- itemContent: "dropdown-item-content",
1545
- link: "dropdown-link",
1546
- };
1547
-
1548
- 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}";
1549
-
1550
- const DropdownGroup = class {
1551
- constructor(hostRef) {
1552
- registerInstance(this, hostRef);
1553
- this.calciteInternalDropdownItemChange = createEvent(this, "calciteInternalDropdownItemChange", 6);
1554
- this.updateItems = () => {
1555
- Array.from(this.el.querySelectorAll("calcite-dropdown-item")).forEach((item) => (item.selectionMode = this.selectionMode));
1556
- };
1557
- this.mutationObserver = createObserver("mutation", () => this.updateItems());
1558
- this.groupTitle = undefined;
1559
- this.scale = "m";
1560
- this.selectionMode = "single";
1561
- }
1562
- handlePropsChange() {
1563
- this.updateItems();
1564
- }
1565
- //--------------------------------------------------------------------------
1566
- //
1567
- // Lifecycle
1568
- //
1569
- //--------------------------------------------------------------------------
1570
- connectedCallback() {
1571
- var _a;
1572
- this.updateItems();
1573
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el, { childList: true });
1574
- }
1575
- componentWillLoad() {
1576
- this.groupPosition = this.getGroupPosition();
1577
- }
1578
- disconnectedCallback() {
1579
- var _a;
1580
- (_a = this.mutationObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
1581
- }
1582
- render() {
1583
- const groupTitle = this.groupTitle ? (h("span", { "aria-hidden": "true", class: "dropdown-title" }, this.groupTitle)) : null;
1584
- const dropdownSeparator = this.groupPosition > 0 ? h("div", { class: "dropdown-separator", role: "separator" }) : null;
1585
- return (h(Host, { "aria-label": this.groupTitle, role: "group" }, h("div", { class: {
1586
- [CSS.container]: true,
1587
- [`${CSS.container}--${this.scale}`]: true,
1588
- } }, dropdownSeparator, groupTitle, h("slot", null))));
1589
- }
1590
- //--------------------------------------------------------------------------
1591
- //
1592
- // Event Listeners
1593
- //
1594
- //--------------------------------------------------------------------------
1595
- updateActiveItemOnChange(event) {
1596
- this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
1597
- this.requestedDropdownItem = event.detail.requestedDropdownItem;
1598
- this.calciteInternalDropdownItemChange.emit({
1599
- requestedDropdownGroup: this.requestedDropdownGroup,
1600
- requestedDropdownItem: this.requestedDropdownItem,
1601
- });
1714
+ pointerDownHandler(event) {
1715
+ if (this.disabled || !isPrimaryPointerButton(event)) {
1716
+ return;
1717
+ }
1718
+ const x = event.clientX || event.pageX;
1719
+ const position = this.translate(x);
1720
+ let prop = "value";
1721
+ if (isRange(this.value)) {
1722
+ const inRange = position >= this.minValue && position <= this.maxValue;
1723
+ if (inRange && this.lastDragProp === "minMaxValue") {
1724
+ prop = "minMaxValue";
1725
+ }
1726
+ else {
1727
+ const closerToMax = Math.abs(this.maxValue - position) < Math.abs(this.minValue - position);
1728
+ prop = closerToMax || position > this.maxValue ? "maxValue" : "minValue";
1729
+ }
1730
+ }
1731
+ this.lastDragPropValue = this[prop];
1732
+ this.dragStart(prop);
1733
+ const isThumbActive = this.el.shadowRoot.querySelector(`.${CSS.thumb}:active`);
1734
+ if (!isThumbActive) {
1735
+ this.setValue({ [prop]: this.clamp(position, prop) });
1736
+ }
1737
+ this.focusActiveHandle(x);
1602
1738
  }
1603
- //--------------------------------------------------------------------------
1604
- //
1605
- // Private Methods
1606
- //
1607
- //--------------------------------------------------------------------------
1608
- getGroupPosition() {
1609
- return Array.prototype.indexOf.call(this.el.parentElement.querySelectorAll("calcite-dropdown-group"), this.el);
1610
- }
1611
- static get delegatesFocus() { return true; }
1612
- get el() { return getElement(this); }
1613
- static get watchers() { return {
1614
- "selectionMode": ["handlePropsChange"]
1615
- }; }
1616
- };
1617
- DropdownGroup.style = dropdownGroupCss;
1618
-
1619
- 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}";
1620
-
1621
- const DropdownItem = class {
1622
- constructor(hostRef) {
1623
- registerInstance(this, hostRef);
1624
- this.calciteDropdownItemSelect = createEvent(this, "calciteDropdownItemSelect", 6);
1625
- this.calciteInternalDropdownItemSelect = createEvent(this, "calciteInternalDropdownItemSelect", 6);
1626
- this.calciteInternalDropdownItemKeyEvent = createEvent(this, "calciteInternalDropdownItemKeyEvent", 6);
1627
- this.calciteInternalDropdownCloseRequest = createEvent(this, "calciteInternalDropdownCloseRequest", 6);
1628
- this.disabled = false;
1629
- this.href = undefined;
1630
- this.iconFlipRtl = undefined;
1631
- this.iconStart = undefined;
1632
- this.iconEnd = undefined;
1633
- this.label = undefined;
1634
- this.rel = undefined;
1635
- this.selected = false;
1636
- this.target = undefined;
1637
- this.selectionMode = "single";
1638
- this.scale = "m";
1739
+ handleTouchStart(event) {
1740
+ // needed to prevent extra click at the end of a handle drag
1741
+ event.preventDefault();
1639
1742
  }
1640
1743
  //--------------------------------------------------------------------------
1641
1744
  //
@@ -1644,469 +1747,400 @@ const DropdownItem = class {
1644
1747
  //--------------------------------------------------------------------------
1645
1748
  /** Sets focus on the component. */
1646
1749
  async setFocus() {
1647
- var _a;
1648
1750
  await componentFocusable(this);
1649
- (_a = this.el) === null || _a === void 0 ? void 0 : _a.focus();
1751
+ const handle = this.minHandle ? this.minHandle : this.maxHandle;
1752
+ handle === null || handle === void 0 ? void 0 : handle.focus();
1650
1753
  }
1651
1754
  //--------------------------------------------------------------------------
1652
1755
  //
1653
- // Lifecycle
1756
+ // Private Methods
1654
1757
  //
1655
1758
  //--------------------------------------------------------------------------
1656
- componentWillLoad() {
1657
- setUpLoadableComponent(this);
1658
- this.initialize();
1659
- }
1660
- componentDidLoad() {
1661
- setComponentLoaded(this);
1759
+ buildThumbType(type) {
1760
+ const thumbTypeParts = [type];
1761
+ if (this.labelHandles) {
1762
+ thumbTypeParts.push("labeled");
1763
+ }
1764
+ if (this.precise) {
1765
+ thumbTypeParts.push("precise");
1766
+ }
1767
+ if (this.hasHistogram) {
1768
+ thumbTypeParts.push("histogram");
1769
+ }
1770
+ return thumbTypeParts.join("-");
1662
1771
  }
1663
- connectedCallback() {
1664
- this.initialize();
1772
+ setValueFromMinMax() {
1773
+ const { minValue, maxValue } = this;
1774
+ if (typeof minValue === "number" && typeof maxValue === "number") {
1775
+ this.value = [minValue, maxValue];
1776
+ }
1665
1777
  }
1666
- componentDidRender() {
1667
- updateHostInteraction(this);
1778
+ setMinMaxFromValue() {
1779
+ const { value } = this;
1780
+ if (isRange(value)) {
1781
+ this.minValue = value[0];
1782
+ this.maxValue = value[1];
1783
+ }
1668
1784
  }
1669
- render() {
1670
- const { href, selectionMode, label, iconFlipRtl, scale } = this;
1671
- const iconStartEl = (h("calcite-icon", { class: CSS.iconStart, flipRtl: iconFlipRtl === "start" || iconFlipRtl === "both", icon: this.iconStart, scale: getIconScale(this.scale) }));
1672
- const contentNode = (h("span", { class: CSS.itemContent }, h("slot", null)));
1673
- const iconEndEl = (h("calcite-icon", { class: CSS.iconEnd, flipRtl: iconFlipRtl === "end" || iconFlipRtl === "both", icon: this.iconEnd, scale: getIconScale(this.scale) }));
1674
- const slottedContent = this.iconStart && this.iconEnd
1675
- ? [iconStartEl, contentNode, iconEndEl]
1676
- : this.iconStart
1677
- ? [iconStartEl, contentNode]
1678
- : this.iconEnd
1679
- ? [contentNode, iconEndEl]
1680
- : contentNode;
1681
- const contentEl = !href ? (slottedContent) : (h("a", { "aria-label": label, class: CSS.link, href: href, rel: this.rel, tabIndex: -1, target: this.target,
1682
- // 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)
1683
- ref: (el) => (this.childLink = el) }, slottedContent));
1684
- const itemRole = href
1685
- ? null
1686
- : selectionMode === "single"
1687
- ? "menuitemradio"
1688
- : selectionMode === "multiple"
1689
- ? "menuitemcheckbox"
1690
- : "menuitem";
1691
- const itemAria = selectionMode !== "none" ? toAriaBoolean(this.selected) : null;
1692
- const { disabled } = this;
1693
- return (h(Host, { "aria-checked": itemAria, "aria-label": !href ? label : "", role: itemRole, tabIndex: disabled ? -1 : 0 }, h(InteractiveContainer, { disabled: disabled }, h("div", { class: {
1694
- [CSS.container]: true,
1695
- [CSS.containerLink]: !!href,
1696
- [`${CSS.container}--${scale}`]: true,
1697
- [CSS.containerMulti]: selectionMode === "multiple",
1698
- [CSS.containerSingle]: selectionMode === "single",
1699
- [CSS.containerNone]: selectionMode === "none",
1700
- } }, selectionMode !== "none" ? (h("calcite-icon", { class: CSS.icon, icon: selectionMode === "multiple" ? "check" : "bullet-point", scale: getIconScale(this.scale) })) : null, contentEl))));
1785
+ onLabelClick() {
1786
+ this.setFocus();
1701
1787
  }
1702
- //--------------------------------------------------------------------------
1703
- //
1704
- // Event Listeners
1705
- //
1706
- //--------------------------------------------------------------------------
1707
- onClick() {
1708
- this.emitRequestedItem();
1788
+ shouldMirror() {
1789
+ return this.mirrored && !this.hasHistogram;
1709
1790
  }
1710
- keyDownHandler(event) {
1711
- switch (event.key) {
1712
- case " ":
1713
- case "Enter":
1714
- this.emitRequestedItem();
1715
- if (this.href) {
1716
- this.childLink.click();
1717
- }
1718
- event.preventDefault();
1719
- break;
1720
- case "Escape":
1721
- this.calciteInternalDropdownCloseRequest.emit();
1722
- event.preventDefault();
1723
- break;
1724
- case "Tab":
1725
- this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
1726
- break;
1727
- case "ArrowUp":
1728
- case "ArrowDown":
1729
- case "Home":
1730
- case "End":
1731
- event.preventDefault();
1732
- this.calciteInternalDropdownItemKeyEvent.emit({ keyboardEvent: event });
1733
- break;
1791
+ shouldUseMinValue() {
1792
+ if (!isRange(this.value)) {
1793
+ return false;
1734
1794
  }
1795
+ return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
1735
1796
  }
1736
- updateActiveItemOnChange(event) {
1737
- const parentEmittedChange = event.composedPath().includes(this.parentDropdownGroupEl);
1738
- if (parentEmittedChange) {
1739
- this.requestedDropdownGroup = event.detail.requestedDropdownGroup;
1740
- this.requestedDropdownItem = event.detail.requestedDropdownItem;
1741
- this.determineActiveItem();
1742
- }
1743
- event.stopPropagation();
1797
+ getTickDensity() {
1798
+ const density = (this.max - this.min) / this.ticks / maxTickElementThreshold;
1799
+ return density < 1 ? 1 : density;
1744
1800
  }
1745
- //--------------------------------------------------------------------------
1746
- //
1747
- // Private Methods
1748
- //
1749
- //--------------------------------------------------------------------------
1750
- initialize() {
1751
- this.parentDropdownGroupEl = this.el.closest("calcite-dropdown-group");
1752
- if (this.selectionMode === "none") {
1753
- this.selected = false;
1801
+ generateTickValues() {
1802
+ var _a;
1803
+ const tickInterval = (_a = this.ticks) !== null && _a !== void 0 ? _a : 0;
1804
+ if (tickInterval <= 0) {
1805
+ return [];
1806
+ }
1807
+ const ticks = [this.min];
1808
+ const density = this.getTickDensity();
1809
+ const tickOffset = tickInterval * density;
1810
+ let current = this.min;
1811
+ while (current < this.max) {
1812
+ current += tickOffset;
1813
+ ticks.push(Math.min(current, this.max));
1754
1814
  }
1815
+ if (!ticks.includes(this.max)) {
1816
+ ticks.push(this.max);
1817
+ }
1818
+ return ticks;
1755
1819
  }
1756
- determineActiveItem() {
1757
- switch (this.selectionMode) {
1758
- case "multiple":
1759
- if (this.el === this.requestedDropdownItem) {
1760
- this.selected = !this.selected;
1761
- }
1820
+ pointerDownDragStart(event, prop) {
1821
+ if (!isPrimaryPointerButton(event)) {
1822
+ return;
1823
+ }
1824
+ this.dragStart(prop);
1825
+ }
1826
+ dragStart(prop) {
1827
+ this.dragProp = prop;
1828
+ this.lastDragProp = this.dragProp;
1829
+ this.activeProp = prop;
1830
+ window.addEventListener("pointermove", this.dragUpdate);
1831
+ window.addEventListener("pointerup", this.pointerUpDragEnd);
1832
+ window.addEventListener("pointercancel", this.dragEnd);
1833
+ }
1834
+ focusActiveHandle(valueX) {
1835
+ switch (this.dragProp) {
1836
+ case "minValue":
1837
+ this.minHandle.focus();
1762
1838
  break;
1763
- case "single":
1764
- if (this.el === this.requestedDropdownItem) {
1765
- this.selected = true;
1766
- }
1767
- else if (this.requestedDropdownGroup === this.parentDropdownGroupEl) {
1768
- this.selected = false;
1769
- }
1839
+ case "maxValue":
1840
+ case "value":
1841
+ this.maxHandle.focus();
1770
1842
  break;
1771
- case "none":
1772
- this.selected = false;
1843
+ case "minMaxValue":
1844
+ this.getClosestHandle(valueX).focus();
1773
1845
  break;
1774
1846
  }
1775
1847
  }
1776
- emitRequestedItem() {
1777
- this.calciteDropdownItemSelect.emit();
1778
- this.calciteInternalDropdownItemSelect.emit({
1779
- requestedDropdownItem: this.el,
1780
- requestedDropdownGroup: this.parentDropdownGroupEl,
1781
- });
1782
- }
1783
- get el() { return getElement(this); }
1784
- };
1785
- DropdownItem.style = dropdownItemCss;
1786
-
1787
- 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}";
1788
-
1789
- const MapLayerPicker = class {
1790
- constructor(hostRef) {
1791
- registerInstance(this, hostRef);
1792
- this.idsFound = createEvent(this, "idsFound", 7);
1793
- this.noLayersFound = createEvent(this, "noLayersFound", 7);
1794
- this.layerSelectionChange = createEvent(this, "layerSelectionChange", 7);
1795
- //--------------------------------------------------------------------------
1796
- //
1797
- // Properties (protected)
1798
- //
1799
- //--------------------------------------------------------------------------
1800
- /**
1801
- * boolean: When true the default layer has been loaded once and should no longer be used
1802
- */
1803
- this.defaultLayerHonored = false;
1804
- this.appearance = "transparent";
1805
- this.defaultLayerId = "";
1806
- this.display = "inline-block";
1807
- this.enabledLayerIds = [];
1808
- this.enabledTableIds = [];
1809
- this.height = undefined;
1810
- this.isMobile = undefined;
1811
- this.mapView = undefined;
1812
- this.onlyShowUpdatableLayers = undefined;
1813
- this.placeholderIcon = "";
1814
- this.selectedIds = [];
1815
- this.scale = "m";
1816
- this.showTables = undefined;
1817
- this.showSingleLayerAsLabel = false;
1818
- this.type = "select";
1819
- this._hasMultipleLayers = true;
1820
- this._hasValidLayers = true;
1821
- this._isDropdownOpen = undefined;
1822
- this.ids = [];
1823
- this.selectedName = "";
1824
- this._translations = undefined;
1825
- }
1826
- //--------------------------------------------------------------------------
1827
- //
1828
- // Watch handlers
1829
- //
1830
- //--------------------------------------------------------------------------
1831
- /**
1832
- * Called each time the mapView prop is changed.
1833
- */
1834
- async mapViewWatchHandler() {
1835
- await this._setLayers();
1836
- if (this.ids.length > 0) {
1837
- this._hasValidLayers = true;
1838
- this._hasMultipleLayers = this.ids.length > 1;
1839
- this._setSelectedLayer(this.ids[0]);
1840
- }
1841
- else {
1842
- this._hasValidLayers = false;
1843
- this.noLayersFound.emit();
1844
- }
1848
+ emitInput() {
1849
+ this.calciteSliderInput.emit();
1845
1850
  }
1846
- //--------------------------------------------------------------------------
1847
- //
1848
- // Functions (lifecycle)
1849
- //
1850
- //--------------------------------------------------------------------------
1851
- /**
1852
- * StencilJS: Called once just after the component is first connected to the DOM.
1853
- */
1854
- async componentWillLoad() {
1855
- await this._getTranslations();
1856
- await this._setLayers();
1857
- if (this.ids.length > 0 || this.selectedIds.length === 1) {
1858
- this.layerSelectionChange.emit(this.selectedIds.length === 1 ? [this.selectedIds[0]] : [this.ids[0]]);
1859
- }
1851
+ emitChange() {
1852
+ this.calciteSliderChange.emit();
1860
1853
  }
1861
- /**
1862
- * Renders the component.
1863
- */
1864
- render() {
1865
- const id = "map-layer-picker";
1866
- let style = this.height > 0 ? { "height": `${this.height.toString()}px` } : {};
1867
- style = Object.assign(Object.assign({}, style), { "display": this.display });
1868
- 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() :
1869
- !this._hasMultipleLayers && this.showSingleLayerAsLabel ? this._getSingleLayerPlaceholder() :
1870
- this.type === "combobox" ? this._getCombobox(id) :
1871
- this.type === "select" ? this._getSelect(id) : this._getDropdown(id)))));
1854
+ removeDragListeners() {
1855
+ window.removeEventListener("pointermove", this.dragUpdate);
1856
+ window.removeEventListener("pointerup", this.pointerUpDragEnd);
1857
+ window.removeEventListener("pointercancel", this.dragEnd);
1872
1858
  }
1873
1859
  /**
1874
- * StencilJS: Called once just after the component is fully loaded and the first render() occurs.
1860
+ * Set prop value(s) if changed at the component level
1861
+ *
1862
+ * @param {object} values - a set of key/value pairs delineating what properties in the component to update
1875
1863
  */
1876
- async componentDidLoad() {
1877
- if (this.ids.length > 0 || this.selectedIds.length === 1) {
1878
- const id = this.selectedIds.length === 1 ? this.selectedIds[0] : this.ids[0];
1879
- if (this.type === "select") {
1880
- this._layerElement.value = id;
1881
- }
1882
- else if (this.type === "dropdown") {
1883
- this.selectedName = Object.keys(this._layerNameHash).indexOf(id) > -1 ?
1884
- this._layerNameHash[id].name : Object.keys(this._tableNameHash).indexOf(id) > -1 ?
1885
- this._tableNameHash[id].name : "";
1864
+ setValue(values) {
1865
+ let valueChanged;
1866
+ Object.keys(values).forEach((propName) => {
1867
+ const newValue = values[propName];
1868
+ if (!valueChanged) {
1869
+ const oldValue = this[propName];
1870
+ valueChanged = oldValue !== newValue;
1886
1871
  }
1872
+ this[propName] = newValue;
1873
+ });
1874
+ if (!valueChanged) {
1875
+ return;
1887
1876
  }
1888
- }
1889
- //--------------------------------------------------------------------------
1890
- //
1891
- // Functions (protected)
1892
- //
1893
- //--------------------------------------------------------------------------
1894
- /**
1895
- * Create a notice to inform the user that no layers were found
1896
- *
1897
- * @returns Calcite Notice component with the message
1898
- */
1899
- _getInvalidPlaceholder() {
1900
- 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))));
1877
+ const dragging = this.dragProp;
1878
+ if (!dragging) {
1879
+ this.emitChange();
1880
+ }
1881
+ this.emitInput();
1901
1882
  }
1902
1883
  /**
1903
- * Show layer name as a label with icon
1884
+ * If number is outside range, constrain to min or max
1904
1885
  *
1905
- * @returns Calcite label with the layer name and icon
1886
+ * @param value
1887
+ * @param prop
1888
+ * @internal
1906
1889
  */
1907
- _getSingleLayerPlaceholder() {
1908
- 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)));
1890
+ clamp(value, prop) {
1891
+ value = clamp(value, this.min, this.max);
1892
+ // ensure that maxValue and minValue don't swap positions
1893
+ if (prop === "maxValue") {
1894
+ value = Math.max(value, this.minValue);
1895
+ }
1896
+ if (prop === "minValue") {
1897
+ value = Math.min(value, this.maxValue);
1898
+ }
1899
+ return value;
1909
1900
  }
1910
1901
  /**
1911
- * Create a list of layers from the map
1912
- * Used for selecting a single layer.
1913
- *
1914
- * @param id the id for the select component used to support the tooltip
1902
+ * Translate a pixel position to value along the range
1915
1903
  *
1916
- * @returns Calcite Select component with the ids of the layers from the map
1904
+ * @param x
1905
+ * @internal
1917
1906
  */
1918
- _getSelect(id) {
1919
- return (h("calcite-select", { id: id, label: "", onCalciteSelectChange: () => this._layerSelectionChange(), ref: (el) => { this._layerElement = el; }, scale: this.scale }, this._getMapLayerOptions()));
1907
+ translate(x) {
1908
+ const range = this.max - this.min;
1909
+ const { left, width } = this.trackEl.getBoundingClientRect();
1910
+ const percent = (x - left) / width;
1911
+ const mirror = this.shouldMirror();
1912
+ const clampedValue = this.clamp(this.min + range * (mirror ? 1 - percent : percent));
1913
+ let value = Number(clampedValue.toFixed(decimalPlaces(this.step)));
1914
+ if (this.snap && this.step) {
1915
+ value = this.getClosestStep(value);
1916
+ }
1917
+ return value;
1920
1918
  }
1921
1919
  /**
1922
- * Create a list of layer ids from the map
1923
- * Used for selecting multiple layers
1924
- *
1925
- * @param id the id for the combobox component used to support the tooltip
1920
+ * Get closest allowed value along stepped values
1926
1921
  *
1927
- * @returns Calcite ComboBox component with the ids of the layers from the map
1922
+ * @param num
1923
+ * @internal
1928
1924
  */
1929
- _getCombobox(id) {
1930
- 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()));
1925
+ getClosestStep(num) {
1926
+ num = Number(this.clamp(num).toFixed(decimalPlaces(this.step)));
1927
+ if (this.step) {
1928
+ const step = Math.round(num / this.step) * this.step;
1929
+ num = Number(this.clamp(step).toFixed(decimalPlaces(this.step)));
1930
+ }
1931
+ return num;
1931
1932
  }
1932
- /**
1933
- * Hydrate a dropdown component with items to display the layer names
1934
- *
1935
- * @param id the id for the dropdown component used to support the tooltip
1936
- *
1937
- * @returns Array of Dropdown items with layer names
1938
- */
1939
- _getDropdown(id) {
1940
- 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())));
1933
+ getClosestHandle(valueX) {
1934
+ return this.getDistanceX(this.maxHandle, valueX) > this.getDistanceX(this.minHandle, valueX)
1935
+ ? this.minHandle
1936
+ : this.maxHandle;
1941
1937
  }
1942
- /**
1943
- * Get the button that will open the dropdown list wrapped in an action
1944
- *
1945
- * @returns the node for the action and button
1946
- */
1947
- _getActionDropdownButton(id) {
1948
- return (h("calcite-action", { id: id, slot: "trigger", text: "" }, this._getDropdownButton()));
1938
+ getDistanceX(el, valueX) {
1939
+ return Math.abs(el.getBoundingClientRect().left - valueX);
1949
1940
  }
1950
- /**
1951
- * Get the button that will open the dropdown list
1952
- *
1953
- * @returns the node for the button
1954
- */
1955
- _getDropdownButton() {
1956
- const buttonClass = this.isMobile ? "" : "max-width-350";
1957
- const buttonSlot = this.isMobile ? "trigger" : "";
1958
- const buttonIcon = this._isDropdownOpen ? "chevron-up" : "chevron-down";
1959
- 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)));
1941
+ getFontSizeForElement(element) {
1942
+ return Number(window.getComputedStyle(element).getPropertyValue("font-size").match(/\d+/)[0]);
1960
1943
  }
1961
1944
  /**
1962
- * Get the appropriate type of dom nodes for each valid layer or table
1945
+ * Get position of value along range as fractional value
1963
1946
  *
1964
- * @returns Array of dom nodes with the names of the layers and optionally of the tables
1947
+ * @param num
1948
+ * @return {number} number in the unit interval [0,1]
1949
+ * @internal
1965
1950
  */
1966
- _getMapLayerOptions() {
1967
- return this.ids.reduce((prev, cur) => {
1968
- if (this._validLayer(cur)) {
1969
- prev.push(this._getItem(cur, "layer"));
1951
+ getUnitInterval(num) {
1952
+ num = this.clamp(num);
1953
+ const range = this.max - this.min;
1954
+ return (num - this.min) / range;
1955
+ }
1956
+ adjustHostObscuredHandleLabel(name) {
1957
+ const label = this.el.shadowRoot.querySelector(`.handle__label--${name}`);
1958
+ const labelStatic = this.el.shadowRoot.querySelector(`.handle__label--${name}.static`);
1959
+ const labelTransformed = this.el.shadowRoot.querySelector(`.handle__label--${name}.transformed`);
1960
+ const labelStaticBounds = labelStatic.getBoundingClientRect();
1961
+ const labelStaticOffset = this.getHostOffset(labelStaticBounds.left, labelStaticBounds.right);
1962
+ label.style.transform = `translateX(${labelStaticOffset}px)`;
1963
+ labelTransformed.style.transform = `translateX(${labelStaticOffset}px)`;
1964
+ }
1965
+ hyphenateCollidingRangeHandleLabels() {
1966
+ const { shadowRoot } = this.el;
1967
+ const mirror = this.shouldMirror();
1968
+ const leftModifier = mirror ? "value" : "minValue";
1969
+ const rightModifier = mirror ? "minValue" : "value";
1970
+ const leftValueLabel = shadowRoot.querySelector(`.handle__label--${leftModifier}`);
1971
+ const leftValueLabelStatic = shadowRoot.querySelector(`.handle__label--${leftModifier}.static`);
1972
+ const leftValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${leftModifier}.transformed`);
1973
+ const leftValueLabelStaticHostOffset = this.getHostOffset(leftValueLabelStatic.getBoundingClientRect().left, leftValueLabelStatic.getBoundingClientRect().right);
1974
+ const rightValueLabel = shadowRoot.querySelector(`.handle__label--${rightModifier}`);
1975
+ const rightValueLabelStatic = shadowRoot.querySelector(`.handle__label--${rightModifier}.static`);
1976
+ const rightValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${rightModifier}.transformed`);
1977
+ const rightValueLabelStaticHostOffset = this.getHostOffset(rightValueLabelStatic.getBoundingClientRect().left, rightValueLabelStatic.getBoundingClientRect().right);
1978
+ const labelFontSize = this.getFontSizeForElement(leftValueLabel);
1979
+ const labelTransformedOverlap = this.getRangeLabelOverlap(leftValueLabelTransformed, rightValueLabelTransformed);
1980
+ const hyphenLabel = leftValueLabel;
1981
+ const labelOffset = labelFontSize / 2;
1982
+ if (labelTransformedOverlap > 0) {
1983
+ hyphenLabel.classList.add(CSS.hyphen, CSS.hyphenWrap);
1984
+ if (rightValueLabelStaticHostOffset === 0 && leftValueLabelStaticHostOffset === 0) {
1985
+ // Neither handle overlaps the host boundary
1986
+ let leftValueLabelTranslate = labelTransformedOverlap / 2 - labelOffset;
1987
+ leftValueLabelTranslate =
1988
+ Math.sign(leftValueLabelTranslate) === -1
1989
+ ? Math.abs(leftValueLabelTranslate)
1990
+ : -leftValueLabelTranslate;
1991
+ const leftValueLabelTransformedHostOffset = this.getHostOffset(leftValueLabelTransformed.getBoundingClientRect().left +
1992
+ leftValueLabelTranslate -
1993
+ labelOffset, leftValueLabelTransformed.getBoundingClientRect().right +
1994
+ leftValueLabelTranslate -
1995
+ labelOffset);
1996
+ let rightValueLabelTranslate = labelTransformedOverlap / 2;
1997
+ const rightValueLabelTransformedHostOffset = this.getHostOffset(rightValueLabelTransformed.getBoundingClientRect().left + rightValueLabelTranslate, rightValueLabelTransformed.getBoundingClientRect().right + rightValueLabelTranslate);
1998
+ if (leftValueLabelTransformedHostOffset !== 0) {
1999
+ leftValueLabelTranslate += leftValueLabelTransformedHostOffset;
2000
+ rightValueLabelTranslate += leftValueLabelTransformedHostOffset;
2001
+ }
2002
+ if (rightValueLabelTransformedHostOffset !== 0) {
2003
+ leftValueLabelTranslate += rightValueLabelTransformedHostOffset;
2004
+ rightValueLabelTranslate += rightValueLabelTransformedHostOffset;
2005
+ }
2006
+ leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
2007
+ leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
2008
+ rightValueLabel.style.transform = `translateX(${rightValueLabelTranslate}px)`;
2009
+ rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelTranslate}px)`;
1970
2010
  }
1971
- else if (this._validTable(cur)) {
1972
- prev.push(this._getItem(cur, "table"));
2011
+ else if (leftValueLabelStaticHostOffset > 0 || rightValueLabelStaticHostOffset > 0) {
2012
+ // labels overlap host boundary on the left side
2013
+ leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset + labelOffset}px)`;
2014
+ rightValueLabel.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
2015
+ rightValueLabelTransformed.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
1973
2016
  }
1974
- return prev;
1975
- }, []);
1976
- }
1977
- /**
1978
- * Get the appropriate type of dom node for the current layer or table id
1979
- *
1980
- * @returns A dom node with the name of the layer or table
1981
- */
1982
- _getItem(id, itemType) {
1983
- const item = itemType === "layer" ? this._layerNameHash[id] : this._tableNameHash[id];
1984
- const disabled = this.onlyShowUpdatableLayers ? !item.supportsUpdate : false;
1985
- const name = item.name;
1986
- const selected = this.selectedIds.indexOf(id) > -1;
1987
- return this.type === "combobox" ? (h("calcite-combobox-item", { disabled: disabled, selected: selected, textLabel: name, value: id })) :
1988
- 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)));
1989
- }
1990
- /**
1991
- * Store the layer name based on the user selection
1992
- */
1993
- _setSelectedLayer(id) {
1994
- let item;
1995
- const hasDefaultLayer = this.defaultLayerId && !this.defaultLayerHonored;
1996
- if (hasDefaultLayer) {
1997
- item = this._getLayerFromHash(this.defaultLayerId);
1998
- this.defaultLayerHonored = item !== undefined;
1999
- id = this.defaultLayerHonored ? this.defaultLayerId : id;
2000
- }
2001
- item = item ? item : this._getLayerFromHash(id);
2002
- this.selectedName = item === null || item === void 0 ? void 0 : item.name;
2003
- this.selectedIds = [id];
2004
- this.layerSelectionChange.emit(this.selectedIds);
2005
- }
2006
- /**
2007
- * Fetch layer hash info for the given id
2008
- *
2009
- * @returns ILayerHashInfo for the id
2010
- */
2011
- _getLayerFromHash(id) {
2012
- return Object.keys(this._layerNameHash).indexOf(id) > -1 ?
2013
- this._layerNameHash[id] : Object.keys(this._tableNameHash).indexOf(id) > -1 ?
2014
- this._tableNameHash[id] : undefined;
2015
- }
2016
- /**
2017
- * Fetch the ids of the layers from the map
2018
- *
2019
- * @returns Promise when the operation has completed
2020
- */
2021
- async _setLayers() {
2022
- if (this.mapView) {
2023
- await this._initLayerTableHash();
2024
- const layerIds = this.onlyShowUpdatableLayers ?
2025
- this._getEditableIds(this._layerNameHash) : Object.keys(this._layerNameHash);
2026
- const tableIds = this.showTables ? this.onlyShowUpdatableLayers ?
2027
- this._getEditableIds(this._tableNameHash) : Object.keys(this._tableNameHash) : [];
2028
- this.ids = [
2029
- ...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; }),
2030
- ...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; }),
2031
- ];
2032
- this.idsFound.emit({
2033
- layerIds,
2034
- tableIds
2035
- });
2017
+ else if (leftValueLabelStaticHostOffset < 0 || rightValueLabelStaticHostOffset < 0) {
2018
+ // labels overlap host boundary on the right side
2019
+ let leftValueLabelTranslate = Math.abs(leftValueLabelStaticHostOffset) + labelTransformedOverlap - labelOffset;
2020
+ leftValueLabelTranslate =
2021
+ Math.sign(leftValueLabelTranslate) === -1
2022
+ ? Math.abs(leftValueLabelTranslate)
2023
+ : -leftValueLabelTranslate;
2024
+ leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
2025
+ leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
2026
+ }
2027
+ }
2028
+ else {
2029
+ hyphenLabel.classList.remove(CSS.hyphen, CSS.hyphenWrap);
2030
+ leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
2031
+ leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
2032
+ rightValueLabel.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
2033
+ rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
2036
2034
  }
2037
2035
  }
2038
2036
  /**
2039
- * Fetch the ids of all layers that support edits with the update capability
2040
- *
2041
- * @returns array of layer ids
2037
+ * Hides bounding tick labels that are obscured by either handle.
2042
2038
  */
2043
- _getEditableIds(hash) {
2044
- return Object.keys(hash).reduce((prev, cur) => {
2045
- if (hash[cur].supportsUpdate) {
2046
- prev.push(cur);
2047
- }
2048
- return prev;
2049
- }, []);
2050
- }
2051
- /**
2052
- * Create a layer id:title hash for layer name display
2053
- *
2054
- * @returns Promise when the operation has completed
2055
- */
2056
- async _initLayerTableHash() {
2057
- this._layerNameHash = await getMapLayerHash(this.mapView, this.onlyShowUpdatableLayers);
2058
- this._tableNameHash = this.showTables ? await getMapTableHash(this.mapView, this.onlyShowUpdatableLayers) : {};
2039
+ hideObscuredBoundingTickLabels() {
2040
+ const valueIsRange = isRange(this.value);
2041
+ if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
2042
+ return;
2043
+ }
2044
+ if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
2045
+ return;
2046
+ }
2047
+ if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
2048
+ return;
2049
+ }
2050
+ if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
2051
+ return;
2052
+ }
2053
+ if (!this.hasHistogram && valueIsRange && !this.precise) {
2054
+ return;
2055
+ }
2056
+ if (this.hasHistogram && !this.precise && !this.labelHandles) {
2057
+ return;
2058
+ }
2059
+ const minHandle = this.el.shadowRoot.querySelector(`.${CSS.thumbMinValue}`);
2060
+ const maxHandle = this.el.shadowRoot.querySelector(`.${CSS.thumbValue}`);
2061
+ const minTickLabel = this.el.shadowRoot.querySelector(`.${CSS.tickMin}`);
2062
+ const maxTickLabel = this.el.shadowRoot.querySelector(`.${CSS.tickMax}`);
2063
+ if (!minHandle && maxHandle && minTickLabel && maxTickLabel) {
2064
+ minTickLabel.style.opacity = this.isMinTickLabelObscured(minTickLabel, maxHandle) ? "0" : "1";
2065
+ maxTickLabel.style.opacity = this.isMaxTickLabelObscured(maxTickLabel, maxHandle) ? "0" : "1";
2066
+ }
2067
+ if (minHandle && maxHandle && minTickLabel && maxTickLabel) {
2068
+ minTickLabel.style.opacity =
2069
+ this.isMinTickLabelObscured(minTickLabel, minHandle) ||
2070
+ this.isMinTickLabelObscured(minTickLabel, maxHandle)
2071
+ ? "0"
2072
+ : "1";
2073
+ maxTickLabel.style.opacity =
2074
+ this.isMaxTickLabelObscured(maxTickLabel, minHandle) ||
2075
+ (this.isMaxTickLabelObscured(maxTickLabel, maxHandle) && this.hasHistogram)
2076
+ ? "0"
2077
+ : "1";
2078
+ }
2059
2079
  }
2060
2080
  /**
2061
- * Evaluate if the id exists in the current hash and verify if it should be excluded
2081
+ * Returns an integer representing the number of pixels to offset on the left or right side based on desired position behavior.
2062
2082
  *
2063
- * @returns boolean when true the layer will be used in the current layer picker type
2083
+ * @param leftBounds
2084
+ * @param rightBounds
2085
+ * @internal
2064
2086
  */
2065
- _validLayer(id) {
2066
- var _a;
2067
- const name = (_a = this._layerNameHash[id]) === null || _a === void 0 ? void 0 : _a.name;
2068
- return name && Object.keys(state.managedLayers).indexOf(name) < 0 && (this.enabledLayerIds.length > 0 ?
2069
- this.enabledLayerIds.indexOf(id) > -1 : true);
2087
+ getHostOffset(leftBounds, rightBounds) {
2088
+ const hostBounds = this.el.getBoundingClientRect();
2089
+ const buffer = 7;
2090
+ if (leftBounds + buffer < hostBounds.left) {
2091
+ return hostBounds.left - leftBounds - buffer;
2092
+ }
2093
+ if (rightBounds - buffer > hostBounds.right) {
2094
+ return -(rightBounds - hostBounds.right) + buffer;
2095
+ }
2096
+ return 0;
2070
2097
  }
2071
2098
  /**
2072
- * Evaluate if the id exists in the current hash and verify if it should be excluded
2099
+ * Returns an integer representing the number of pixels that the two given span elements are overlapping, taking into account
2100
+ * a space in between the two spans equal to the font-size set on them to account for the space needed to render a hyphen.
2073
2101
  *
2074
- * @returns boolean when true the table will be used in the current layer picker type
2102
+ * @param leftLabel
2103
+ * @param rightLabel
2075
2104
  */
2076
- _validTable(id) {
2077
- var _a;
2078
- const name = (_a = this._tableNameHash[id]) === null || _a === void 0 ? void 0 : _a.name;
2079
- const validName = name && this.showTables;
2080
- return validName ? state.managedTables.indexOf(name) < 0 &&
2081
- (this.enabledTableIds.length > 0 ? this.enabledTableIds.indexOf(id) > -1 : true) : validName;
2105
+ getRangeLabelOverlap(leftLabel, rightLabel) {
2106
+ const leftLabelBounds = leftLabel.getBoundingClientRect();
2107
+ const rightLabelBounds = rightLabel.getBoundingClientRect();
2108
+ const leftLabelFontSize = this.getFontSizeForElement(leftLabel);
2109
+ const rangeLabelOverlap = leftLabelBounds.right + leftLabelFontSize - rightLabelBounds.left;
2110
+ return Math.max(rangeLabelOverlap, 0);
2082
2111
  }
2083
2112
  /**
2084
- * Fetch the ids of the layers from the map
2113
+ * Returns a boolean value representing if the minLabel span element is obscured (being overlapped) by the given handle div element.
2085
2114
  *
2086
- * @returns Promise when the operation has completed
2115
+ * @param minLabel
2116
+ * @param handle
2087
2117
  */
2088
- _layerSelectionChange() {
2089
- const ids = Array.isArray(this._layerElement.value) ? this._layerElement.value : [this._layerElement.value];
2090
- if (JSON.stringify(ids) !== JSON.stringify([""])) {
2091
- this.selectedIds = ids;
2092
- this.layerSelectionChange.emit(this.selectedIds);
2093
- }
2118
+ isMinTickLabelObscured(minLabel, handle) {
2119
+ const minLabelBounds = minLabel.getBoundingClientRect();
2120
+ const handleBounds = handle.getBoundingClientRect();
2121
+ return intersects(minLabelBounds, handleBounds);
2094
2122
  }
2095
2123
  /**
2096
- * Fetches the component's translations
2124
+ * Returns a boolean value representing if the maxLabel span element is obscured (being overlapped) by the given handle div element.
2097
2125
  *
2098
- * @returns Promise when complete
2099
- * @protected
2126
+ * @param maxLabel
2127
+ * @param handle
2100
2128
  */
2101
- async _getTranslations() {
2102
- const messages = await getLocaleComponentStrings(this.el);
2103
- this._translations = messages[0];
2129
+ isMaxTickLabelObscured(maxLabel, handle) {
2130
+ const maxLabelBounds = maxLabel.getBoundingClientRect();
2131
+ const handleBounds = handle.getBoundingClientRect();
2132
+ return intersects(maxLabelBounds, handleBounds);
2104
2133
  }
2134
+ static get delegatesFocus() { return true; }
2105
2135
  get el() { return getElement(this); }
2106
2136
  static get watchers() { return {
2107
- "mapView": ["mapViewWatchHandler"]
2137
+ "histogram": ["histogramWatcher"],
2138
+ "ticks": ["ticksWatcher"],
2139
+ "value": ["valueHandler"],
2140
+ "minValue": ["minMaxValueHandler"],
2141
+ "maxValue": ["minMaxValueHandler"]
2108
2142
  }; }
2109
2143
  };
2110
- MapLayerPicker.style = mapLayerPickerCss;
2144
+ Slider.style = sliderCss;
2111
2145
 
2112
- export { Combobox as calcite_combobox, Dropdown as calcite_dropdown, DropdownGroup as calcite_dropdown_group, DropdownItem as calcite_dropdown_item, MapLayerPicker as map_layer_picker };
2146
+ export { Combobox as calcite_combobox, Graph as calcite_graph, Slider as calcite_slider };