@esri/solutions-components 0.8.8 → 0.8.9

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