@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
@@ -1,1055 +0,0 @@
1
- /*!
2
- * Copyright 2022 Esri
3
- * Licensed under the Apache License, Version 2.0
4
- * http://www.apache.org/licenses/LICENSE-2.0
5
- */
6
- 'use strict';
7
-
8
- Object.defineProperty(exports, '__esModule', { value: true });
9
-
10
- const index = require('./index-105cf2b9.js');
11
- const guid = require('./guid-ae73cd27.js');
12
- const observers = require('./observers-db4527e4.js');
13
- const dom = require('./dom-c9c2c835.js');
14
- const form = require('./form-fed676d6.js');
15
- const interactive = require('./interactive-3ab7044d.js');
16
- const key = require('./key-c5504030.js');
17
- const label = require('./label-32573e1d.js');
18
- const loadable = require('./loadable-5a794992.js');
19
- const locale = require('./locale-d237c9d5.js');
20
- const math = require('./math-318a1646.js');
21
- require('./resources-9447c777.js');
22
- require('./browser-d08a5f99.js');
23
- require('./component-ac7c3bd8.js');
24
-
25
- /*!
26
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
27
- * See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
28
- * v2.4.0
29
- */
30
- /**
31
- * Calculate slope of the tangents
32
- * uses Steffen interpolation as it's monotonic
33
- * http://jrwalsh1.github.io/posts/interpolations/
34
- *
35
- * @param p0
36
- * @param p1
37
- * @param p2
38
- */
39
- function slope(p0, p1, p2) {
40
- const dx = p1[0] - p0[0];
41
- const dx1 = p2[0] - p1[0];
42
- const dy = p1[1] - p0[1];
43
- const dy1 = p2[1] - p1[1];
44
- const m = dy / (dx || (dx1 < 0 && 0));
45
- const m1 = dy1 / (dx1 || (dx < 0 && 0));
46
- const p = (m * dx1 + m1 * dx) / (dx + dx1);
47
- return (Math.sign(m) + Math.sign(m1)) * Math.min(Math.abs(m), Math.abs(m1), 0.5 * Math.abs(p)) || 0;
48
- }
49
- /**
50
- * Calculate slope for just one tangent (single-sided)
51
- *
52
- * @param p0
53
- * @param p1
54
- * @param m
55
- */
56
- function slopeSingle(p0, p1, m) {
57
- const dx = p1[0] - p0[0];
58
- const dy = p1[1] - p0[1];
59
- return dx ? ((3 * dy) / dx - m) / 2 : m;
60
- }
61
- /**
62
- * Given two points and their tangent slopes,
63
- * calculate the bezier handle coordinates and return draw command.
64
- *
65
- * Translates Hermite Spline to Bézier curve:
66
- * https://stackoverflow.com/questions/42574940/
67
- *
68
- * @param p0
69
- * @param p1
70
- * @param m0
71
- * @param m1
72
- * @param t
73
- */
74
- function bezier(p0, p1, m0, m1, t) {
75
- const [x0, y0] = p0;
76
- const [x1, y1] = p1;
77
- const dx = (x1 - x0) / 3;
78
- const h1 = t([x0 + dx, y0 + dx * m0]).join(",");
79
- const h2 = t([x1 - dx, y1 - dx * m1]).join(",");
80
- const p = t([x1, y1]).join(",");
81
- return `C ${h1} ${h2} ${p}`;
82
- }
83
- /**
84
- * Generate a function which will translate a point
85
- * from the data coordinate space to svg viewbox oriented pixels
86
- *
87
- * @param root0
88
- * @param root0.width
89
- * @param root0.height
90
- * @param root0.min
91
- * @param root0.max
92
- */
93
- function translate({ width, height, min, max }) {
94
- const rangeX = max[0] - min[0];
95
- const rangeY = max[1] - min[1];
96
- return (point) => {
97
- const x = ((point[0] - min[0]) / rangeX) * width;
98
- const y = height - (point[1] / rangeY) * height;
99
- return [x, y];
100
- };
101
- }
102
- /**
103
- * Get the min and max values from the dataset
104
- *
105
- * @param data
106
- */
107
- function range(data) {
108
- const [startX, startY] = data[0];
109
- const min = [startX, startY];
110
- const max = [startX, startY];
111
- return data.reduce(({ min, max }, [x, y]) => ({
112
- min: [Math.min(min[0], x), Math.min(min[1], y)],
113
- max: [Math.max(max[0], x), Math.max(max[1], y)],
114
- }), { min, max });
115
- }
116
- /**
117
- * Generate drawing commands for an area graph
118
- * returns a string can can be passed directly to a path element's `d` attribute
119
- *
120
- * @param root0
121
- * @param root0.data
122
- * @param root0.min
123
- * @param root0.max
124
- * @param root0.t
125
- */
126
- function area({ data, min, max, t }) {
127
- if (data.length === 0) {
128
- return "";
129
- }
130
- // important points for beginning and ending the path
131
- const [startX, startY] = t(data[0]);
132
- const [minX, minY] = t(min);
133
- const [maxX] = t(max);
134
- // keep track of previous slope/points
135
- let m;
136
- let p0;
137
- let p1;
138
- // iterate over data points, calculating command for each
139
- const commands = data.reduce((acc, point, i) => {
140
- p0 = data[i - 2];
141
- p1 = data[i - 1];
142
- if (i > 1) {
143
- const m1 = slope(p0, p1, point);
144
- const m0 = m === undefined ? slopeSingle(p0, p1, m1) : m;
145
- const command = bezier(p0, p1, m0, m1, t);
146
- m = m1;
147
- return `${acc} ${command}`;
148
- }
149
- return acc;
150
- }, `M ${minX},${minY} L ${minX},${startY} L ${startX},${startY}`);
151
- // close the path
152
- const last = data[data.length - 1];
153
- const end = bezier(p1, last, m, slopeSingle(p1, last, m), t);
154
- return `${commands} ${end} L ${maxX},${minY} Z`;
155
- }
156
-
157
- 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}";
158
-
159
- const Graph = class {
160
- constructor(hostRef) {
161
- index.registerInstance(this, hostRef);
162
- this.graphId = `calcite-graph-${guid.guid()}`;
163
- this.resizeObserver = observers.createObserver("resize", () => index.forceUpdate(this));
164
- this.data = [];
165
- this.colorStops = undefined;
166
- this.highlightMin = undefined;
167
- this.highlightMax = undefined;
168
- this.min = undefined;
169
- this.max = undefined;
170
- }
171
- //--------------------------------------------------------------------------
172
- //
173
- // Lifecycle
174
- //
175
- //--------------------------------------------------------------------------
176
- connectedCallback() {
177
- var _a;
178
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.observe(this.el);
179
- }
180
- disconnectedCallback() {
181
- var _a;
182
- (_a = this.resizeObserver) === null || _a === void 0 ? void 0 : _a.disconnect();
183
- }
184
- render() {
185
- const { data, colorStops, el, highlightMax, highlightMin, min, max } = this;
186
- const id = this.graphId;
187
- const { clientHeight: height, clientWidth: width } = el;
188
- // if we have no data, return empty svg
189
- if (!data || data.length === 0) {
190
- return (index.h("svg", { "aria-hidden": "true", class: "svg", height: height, preserveAspectRatio: "none", viewBox: `0 0 ${width} ${height}`, width: width }));
191
- }
192
- const { min: rangeMin, max: rangeMax } = range(data);
193
- let currentMin = rangeMin;
194
- let currentMax = rangeMax;
195
- if (min < rangeMin[0] || min > rangeMin[0]) {
196
- currentMin = [min, 0];
197
- }
198
- if (max > rangeMax[0] || max < rangeMax[0]) {
199
- currentMax = [max, rangeMax[1]];
200
- }
201
- const t = translate({ min: currentMin, max: currentMax, width, height });
202
- const [hMinX] = t([highlightMin, currentMax[1]]);
203
- const [hMaxX] = t([highlightMax, currentMax[1]]);
204
- const areaPath = area({ data, min: rangeMin, max: rangeMax, t });
205
- const fill = colorStops ? `url(#linear-gradient-${id})` : undefined;
206
- 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 ? ([
207
- index.h("mask", { height: "100%", id: `${id}1`, width: "100%", x: "0%", y: "0%" }, index.h("path", { d: `
208
- M 0,0
209
- L ${hMinX - 1},0
210
- L ${hMinX - 1},${height}
211
- L 0,${height}
212
- Z
213
- `, fill: "white" })),
214
- index.h("mask", { height: "100%", id: `${id}2`, width: "100%", x: "0%", y: "0%" }, index.h("path", { d: `
215
- M ${hMinX + 1},0
216
- L ${hMaxX - 1},0
217
- L ${hMaxX - 1},${height}
218
- L ${hMinX + 1}, ${height}
219
- Z
220
- `, fill: "white" })),
221
- index.h("mask", { height: "100%", id: `${id}3`, width: "100%", x: "0%", y: "0%" }, index.h("path", { d: `
222
- M ${hMaxX + 1},0
223
- L ${width},0
224
- L ${width},${height}
225
- L ${hMaxX + 1}, ${height}
226
- Z
227
- `, fill: "white" })),
228
- index.h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}1)` }),
229
- index.h("path", { class: "graph-path--highlight", d: areaPath, fill: fill, mask: `url(#${id}2)` }),
230
- index.h("path", { class: "graph-path", d: areaPath, fill: fill, mask: `url(#${id}3)` }),
231
- ]) : (index.h("path", { class: "graph-path", d: areaPath, fill: fill }))));
232
- }
233
- get el() { return index.getElement(this); }
234
- };
235
- Graph.style = graphCss;
236
-
237
- /*!
238
- * All material copyright ESRI, All Rights Reserved, unless otherwise specified.
239
- * See https://github.com/Esri/calcite-design-system/blob/main/LICENSE.md for details.
240
- * v2.4.0
241
- */
242
- const CSS = {
243
- container: "container",
244
- containerRange: "container--range",
245
- graph: "graph",
246
- handle: "handle",
247
- handleExtension: "handle-extension",
248
- handleLabel: "handle__label",
249
- handleLabelMinValue: "handle__label--minValue",
250
- handleLabelValue: "handle__label--value",
251
- hyphen: "hyphen",
252
- hyphenWrap: "hyphen--wrap",
253
- static: "static",
254
- thumb: "thumb",
255
- thumbActive: "thumb--active",
256
- thumbContainer: "thumb-container",
257
- thumbMinValue: "thumb--minValue",
258
- thumbPrecise: "thumb--precise",
259
- thumbValue: "thumb--value",
260
- tick: "tick",
261
- tickActive: "tick--active",
262
- tickLabel: "tick__label",
263
- tickMax: "tick__label--max",
264
- tickMin: "tick__label--min",
265
- ticks: "ticks",
266
- track: "track",
267
- trackRange: "track__range",
268
- transformed: "transformed",
269
- };
270
- const maxTickElementThreshold = 250;
271
-
272
- 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}";
273
-
274
- function isRange(value) {
275
- return Array.isArray(value);
276
- }
277
- const Slider = class {
278
- constructor(hostRef) {
279
- index.registerInstance(this, hostRef);
280
- this.calciteSliderInput = index.createEvent(this, "calciteSliderInput", 6);
281
- this.calciteSliderChange = index.createEvent(this, "calciteSliderChange", 6);
282
- this.activeProp = "value";
283
- this.guid = `calcite-slider-${guid.guid()}`;
284
- this.onThumbBlur = () => {
285
- this.activeProp = null;
286
- };
287
- this.onThumbFocus = (event) => {
288
- const thumb = event.currentTarget;
289
- this.activeProp = thumb.getAttribute("data-value-prop");
290
- };
291
- this.onThumbPointerDown = (event) => {
292
- const thumb = event.currentTarget;
293
- this.pointerDownDragStart(event, thumb.getAttribute("data-value-prop"));
294
- };
295
- this.onTrackPointerDown = (event) => {
296
- this.pointerDownDragStart(event, "minMaxValue");
297
- };
298
- this.dragUpdate = (event) => {
299
- if (this.disabled) {
300
- return;
301
- }
302
- event.preventDefault();
303
- if (this.dragProp) {
304
- const value = this.translate(event.clientX || event.pageX);
305
- if (isRange(this.value) && this.dragProp === "minMaxValue") {
306
- if (this.minValueDragRange && this.maxValueDragRange && this.minMaxValueRange) {
307
- const newMinValue = value - this.minValueDragRange;
308
- const newMaxValue = value + this.maxValueDragRange;
309
- if (newMaxValue <= this.max &&
310
- newMinValue >= this.min &&
311
- newMaxValue - newMinValue === this.minMaxValueRange) {
312
- this.setValue({
313
- minValue: this.clamp(newMinValue, "minValue"),
314
- maxValue: this.clamp(newMaxValue, "maxValue"),
315
- });
316
- }
317
- }
318
- else {
319
- this.minValueDragRange = value - this.minValue;
320
- this.maxValueDragRange = this.maxValue - value;
321
- this.minMaxValueRange = this.maxValue - this.minValue;
322
- }
323
- }
324
- else {
325
- this.setValue({ [this.dragProp]: this.clamp(value, this.dragProp) });
326
- }
327
- }
328
- };
329
- this.pointerUpDragEnd = (event) => {
330
- if (this.disabled || !dom.isPrimaryPointerButton(event)) {
331
- return;
332
- }
333
- this.dragEnd(event);
334
- };
335
- this.dragEnd = (event) => {
336
- if (this.disabled) {
337
- return;
338
- }
339
- this.removeDragListeners();
340
- this.focusActiveHandle(event.clientX);
341
- if (this.lastDragPropValue != this[this.dragProp]) {
342
- this.emitChange();
343
- }
344
- this.dragProp = null;
345
- this.lastDragPropValue = null;
346
- this.minValueDragRange = null;
347
- this.maxValueDragRange = null;
348
- this.minMaxValueRange = null;
349
- };
350
- this.storeTrackRef = (node) => {
351
- this.trackEl = node;
352
- };
353
- this.storeThumbRef = (el) => {
354
- if (!el) {
355
- return;
356
- }
357
- const valueProp = el.getAttribute("data-value-prop");
358
- valueProp === "minValue" ? (this.minHandle = el) : (this.maxHandle = el);
359
- };
360
- /**
361
- * Returns a string representing the localized label value based if the groupSeparator prop is parsed.
362
- *
363
- * @param value
364
- */
365
- this.formatValue = (value) => {
366
- locale.numberStringFormatter.numberFormatOptions = {
367
- locale: this.effectiveLocale,
368
- numberingSystem: this.numberingSystem,
369
- useGrouping: this.groupSeparator,
370
- };
371
- return locale.numberStringFormatter.localize(value.toString());
372
- };
373
- this.disabled = false;
374
- this.form = undefined;
375
- this.groupSeparator = false;
376
- this.hasHistogram = false;
377
- this.histogram = undefined;
378
- this.histogramStops = undefined;
379
- this.labelHandles = false;
380
- this.labelTicks = false;
381
- this.max = 100;
382
- this.maxLabel = undefined;
383
- this.maxValue = undefined;
384
- this.min = 0;
385
- this.minLabel = undefined;
386
- this.minValue = undefined;
387
- this.mirrored = false;
388
- this.name = undefined;
389
- this.numberingSystem = undefined;
390
- this.pageStep = undefined;
391
- this.precise = false;
392
- this.required = false;
393
- this.snap = false;
394
- this.step = 1;
395
- this.ticks = undefined;
396
- this.value = 0;
397
- this.scale = "m";
398
- this.effectiveLocale = "";
399
- this.minMaxValueRange = null;
400
- this.minValueDragRange = null;
401
- this.maxValueDragRange = null;
402
- this.tickValues = [];
403
- }
404
- histogramWatcher(newHistogram) {
405
- this.hasHistogram = !!newHistogram;
406
- }
407
- ticksWatcher() {
408
- this.tickValues = this.generateTickValues();
409
- }
410
- valueHandler() {
411
- this.setMinMaxFromValue();
412
- }
413
- minMaxValueHandler() {
414
- this.setValueFromMinMax();
415
- }
416
- //--------------------------------------------------------------------------
417
- //
418
- // Lifecycle
419
- //
420
- //--------------------------------------------------------------------------
421
- connectedCallback() {
422
- interactive.connectInteractive(this);
423
- locale.connectLocalized(this);
424
- this.setMinMaxFromValue();
425
- this.setValueFromMinMax();
426
- label.connectLabel(this);
427
- form.connectForm(this);
428
- }
429
- disconnectedCallback() {
430
- interactive.disconnectInteractive(this);
431
- label.disconnectLabel(this);
432
- form.disconnectForm(this);
433
- locale.disconnectLocalized(this);
434
- this.removeDragListeners();
435
- }
436
- componentWillLoad() {
437
- loadable.setUpLoadableComponent(this);
438
- if (!isRange(this.value)) {
439
- this.value = this.snap ? this.getClosestStep(this.value) : this.clamp(this.value);
440
- }
441
- this.ticksWatcher();
442
- this.histogramWatcher(this.histogram);
443
- form.afterConnectDefaultValueSet(this, this.value);
444
- }
445
- componentDidLoad() {
446
- loadable.setComponentLoaded(this);
447
- }
448
- componentDidRender() {
449
- if (this.labelHandles) {
450
- this.adjustHostObscuredHandleLabel("value");
451
- if (isRange(this.value)) {
452
- this.adjustHostObscuredHandleLabel("minValue");
453
- if (!(this.precise && !this.hasHistogram)) {
454
- this.hyphenateCollidingRangeHandleLabels();
455
- }
456
- }
457
- }
458
- this.hideObscuredBoundingTickLabels();
459
- interactive.updateHostInteraction(this);
460
- }
461
- render() {
462
- const id = this.el.id || this.guid;
463
- const value = isRange(this.value) ? this.maxValue : this.value;
464
- const min = this.minValue || this.min;
465
- const useMinValue = this.shouldUseMinValue();
466
- const minInterval = this.getUnitInterval(useMinValue ? this.minValue : min) * 100;
467
- const maxInterval = this.getUnitInterval(value) * 100;
468
- const mirror = this.shouldMirror();
469
- const valueIsRange = isRange(this.value);
470
- const thumbTypes = this.buildThumbType("max");
471
- const thumb = this.renderThumb({
472
- type: thumbTypes,
473
- thumbPlacement: thumbTypes.includes("histogram") ? "below" : "above",
474
- maxInterval,
475
- minInterval,
476
- mirror,
477
- });
478
- const minThumbTypes = this.buildThumbType("min");
479
- const minThumb = valueIsRange &&
480
- this.renderThumb({
481
- type: minThumbTypes,
482
- thumbPlacement: minThumbTypes.includes("histogram") || minThumbTypes.includes("precise")
483
- ? "below"
484
- : "above",
485
- maxInterval,
486
- minInterval,
487
- mirror,
488
- });
489
- 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: {
490
- [CSS.container]: true,
491
- [CSS.containerRange]: valueIsRange,
492
- [`scale--${this.scale}`]: true,
493
- } }, this.renderGraph(), index.h("div", { class: CSS.track,
494
- // 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)
495
- ref: this.storeTrackRef }, index.h("div", { class: CSS.trackRange, onPointerDown: this.onTrackPointerDown, style: {
496
- left: `${mirror ? 100 - maxInterval : minInterval}%`,
497
- right: `${mirror ? minInterval : 100 - maxInterval}%`,
498
- } }), index.h("div", { class: CSS.ticks }, this.tickValues.map((tick) => {
499
- const tickOffset = `${this.getUnitInterval(tick) * 100}%`;
500
- let activeTicks = tick >= min && tick <= value;
501
- if (useMinValue) {
502
- activeTicks = tick >= this.minValue && tick <= this.maxValue;
503
- }
504
- return (index.h("span", { class: {
505
- [CSS.tick]: true,
506
- [CSS.tickActive]: activeTicks,
507
- }, style: {
508
- left: mirror ? "" : tickOffset,
509
- right: mirror ? tickOffset : "",
510
- } }, this.renderTickLabel(tick)));
511
- }))), index.h("div", { class: CSS.thumbContainer }, minThumb, thumb, index.h(form.HiddenFormInputSlot, { component: this }))))));
512
- }
513
- renderThumb({ type, mirror, thumbPlacement, minInterval, maxInterval, }) {
514
- const isLabeled = type.includes("labeled");
515
- const isPrecise = type.includes("precise");
516
- const isMinThumb = type.includes("min");
517
- const valueIsRange = isRange(this.value);
518
- const value = isMinThumb
519
- ? this.minValue
520
- : valueIsRange
521
- ? this.maxValue
522
- : this.value;
523
- const valueProp = isMinThumb ? "minValue" : valueIsRange ? "maxValue" : "value";
524
- const ariaLabel = isMinThumb ? this.minLabel : valueIsRange ? this.maxLabel : this.minLabel;
525
- const ariaValuenow = isMinThumb ? this.minValue : value;
526
- const displayedValue = isMinThumb ? this.formatValue(this.minValue) : this.formatValue(value);
527
- const thumbStyle = isMinThumb
528
- ? { left: `${mirror ? 100 - minInterval : minInterval}%` }
529
- : { right: `${mirror ? maxInterval : 100 - maxInterval}%` };
530
- const thumbLabelClasses = `${CSS.handleLabel} ${isMinThumb ? CSS.handleLabelMinValue : CSS.handleLabelValue}`;
531
- const labels = isLabeled
532
- ? [
533
- index.h("span", { "aria-hidden": "true", class: thumbLabelClasses }, displayedValue),
534
- index.h("span", { "aria-hidden": "true", class: `${thumbLabelClasses} ${CSS.static}` }, displayedValue),
535
- index.h("span", { "aria-hidden": "true", class: `${thumbLabelClasses} ${CSS.transformed}` }, displayedValue),
536
- ]
537
- : [];
538
- const thumbContent = [
539
- ...labels,
540
- index.h("div", { class: CSS.handle }),
541
- isPrecise && index.h("div", { class: CSS.handleExtension }),
542
- ];
543
- if (thumbPlacement === "below") {
544
- thumbContent.reverse();
545
- }
546
- 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: {
547
- [CSS.thumb]: true,
548
- [CSS.thumbValue]: !isMinThumb,
549
- [CSS.thumbActive]: this.lastDragProp !== "minMaxValue" && this.dragProp === valueProp,
550
- [CSS.thumbPrecise]: isPrecise,
551
- [CSS.thumbMinValue]: isMinThumb,
552
- }, "data-value-prop": valueProp, key: type, onBlur: this.onThumbBlur, onFocus: this.onThumbFocus, onPointerDown: this.onThumbPointerDown, role: "slider", style: thumbStyle, tabIndex: 0,
553
- // 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)
554
- ref: this.storeThumbRef }, thumbContent));
555
- }
556
- renderGraph() {
557
- 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;
558
- }
559
- renderTickLabel(tick) {
560
- const { hasHistogram, labelHandles, labelTicks, max, min, precise, value } = this;
561
- const valueIsRange = isRange(value);
562
- const isMinTickLabel = tick === min;
563
- const isMaxTickLabel = tick === max;
564
- const isAtEdge = isMinTickLabel || isMaxTickLabel;
565
- const shouldDisplayLabel = labelTicks &&
566
- ((!hasHistogram && (isAtEdge || !precise || !valueIsRange)) ||
567
- (hasHistogram && (isAtEdge || (!precise && !labelHandles))));
568
- return shouldDisplayLabel ? (index.h("span", { class: {
569
- [CSS.tickLabel]: true,
570
- [CSS.tickMin]: isMinTickLabel,
571
- [CSS.tickMax]: isMaxTickLabel,
572
- } }, this.formatValue(tick))) : null;
573
- }
574
- //--------------------------------------------------------------------------
575
- //
576
- // Event Listeners
577
- //
578
- //--------------------------------------------------------------------------
579
- keyDownHandler(event) {
580
- const mirror = this.shouldMirror();
581
- const { activeProp, max, min, pageStep, step } = this;
582
- const value = this[activeProp];
583
- const { key: key$1 } = event;
584
- if (key.isActivationKey(key$1)) {
585
- event.preventDefault();
586
- return;
587
- }
588
- let adjustment;
589
- if (key$1 === "ArrowUp" || key$1 === "ArrowRight") {
590
- const directionFactor = mirror && key$1 === "ArrowRight" ? -1 : 1;
591
- adjustment = value + step * directionFactor;
592
- }
593
- else if (key$1 === "ArrowDown" || key$1 === "ArrowLeft") {
594
- const directionFactor = mirror && key$1 === "ArrowLeft" ? -1 : 1;
595
- adjustment = value - step * directionFactor;
596
- }
597
- else if (key$1 === "PageUp") {
598
- if (pageStep) {
599
- adjustment = value + pageStep;
600
- }
601
- }
602
- else if (key$1 === "PageDown") {
603
- if (pageStep) {
604
- adjustment = value - pageStep;
605
- }
606
- }
607
- else if (key$1 === "Home") {
608
- adjustment = min;
609
- }
610
- else if (key$1 === "End") {
611
- adjustment = max;
612
- }
613
- if (isNaN(adjustment)) {
614
- return;
615
- }
616
- event.preventDefault();
617
- const fixedDecimalAdjustment = Number(adjustment.toFixed(math.decimalPlaces(step)));
618
- this.setValue({
619
- [activeProp]: this.clamp(fixedDecimalAdjustment, activeProp),
620
- });
621
- }
622
- pointerDownHandler(event) {
623
- if (this.disabled || !dom.isPrimaryPointerButton(event)) {
624
- return;
625
- }
626
- const x = event.clientX || event.pageX;
627
- const position = this.translate(x);
628
- let prop = "value";
629
- if (isRange(this.value)) {
630
- const inRange = position >= this.minValue && position <= this.maxValue;
631
- if (inRange && this.lastDragProp === "minMaxValue") {
632
- prop = "minMaxValue";
633
- }
634
- else {
635
- const closerToMax = Math.abs(this.maxValue - position) < Math.abs(this.minValue - position);
636
- prop = closerToMax || position > this.maxValue ? "maxValue" : "minValue";
637
- }
638
- }
639
- this.lastDragPropValue = this[prop];
640
- this.dragStart(prop);
641
- const isThumbActive = this.el.shadowRoot.querySelector(`.${CSS.thumb}:active`);
642
- if (!isThumbActive) {
643
- this.setValue({ [prop]: this.clamp(position, prop) });
644
- }
645
- this.focusActiveHandle(x);
646
- }
647
- handleTouchStart(event) {
648
- // needed to prevent extra click at the end of a handle drag
649
- event.preventDefault();
650
- }
651
- //--------------------------------------------------------------------------
652
- //
653
- // Public Methods
654
- //
655
- //--------------------------------------------------------------------------
656
- /** Sets focus on the component. */
657
- async setFocus() {
658
- await loadable.componentFocusable(this);
659
- const handle = this.minHandle ? this.minHandle : this.maxHandle;
660
- handle === null || handle === void 0 ? void 0 : handle.focus();
661
- }
662
- //--------------------------------------------------------------------------
663
- //
664
- // Private Methods
665
- //
666
- //--------------------------------------------------------------------------
667
- buildThumbType(type) {
668
- const thumbTypeParts = [type];
669
- if (this.labelHandles) {
670
- thumbTypeParts.push("labeled");
671
- }
672
- if (this.precise) {
673
- thumbTypeParts.push("precise");
674
- }
675
- if (this.hasHistogram) {
676
- thumbTypeParts.push("histogram");
677
- }
678
- return thumbTypeParts.join("-");
679
- }
680
- setValueFromMinMax() {
681
- const { minValue, maxValue } = this;
682
- if (typeof minValue === "number" && typeof maxValue === "number") {
683
- this.value = [minValue, maxValue];
684
- }
685
- }
686
- setMinMaxFromValue() {
687
- const { value } = this;
688
- if (isRange(value)) {
689
- this.minValue = value[0];
690
- this.maxValue = value[1];
691
- }
692
- }
693
- onLabelClick() {
694
- this.setFocus();
695
- }
696
- shouldMirror() {
697
- return this.mirrored && !this.hasHistogram;
698
- }
699
- shouldUseMinValue() {
700
- if (!isRange(this.value)) {
701
- return false;
702
- }
703
- return ((this.hasHistogram && this.maxValue === 0) || (!this.hasHistogram && this.minValue === 0));
704
- }
705
- getTickDensity() {
706
- const density = (this.max - this.min) / this.ticks / maxTickElementThreshold;
707
- return density < 1 ? 1 : density;
708
- }
709
- generateTickValues() {
710
- var _a;
711
- const tickInterval = (_a = this.ticks) !== null && _a !== void 0 ? _a : 0;
712
- if (tickInterval <= 0) {
713
- return [];
714
- }
715
- const ticks = [this.min];
716
- const density = this.getTickDensity();
717
- const tickOffset = tickInterval * density;
718
- let current = this.min;
719
- while (current < this.max) {
720
- current += tickOffset;
721
- ticks.push(Math.min(current, this.max));
722
- }
723
- if (!ticks.includes(this.max)) {
724
- ticks.push(this.max);
725
- }
726
- return ticks;
727
- }
728
- pointerDownDragStart(event, prop) {
729
- if (!dom.isPrimaryPointerButton(event)) {
730
- return;
731
- }
732
- this.dragStart(prop);
733
- }
734
- dragStart(prop) {
735
- this.dragProp = prop;
736
- this.lastDragProp = this.dragProp;
737
- this.activeProp = prop;
738
- window.addEventListener("pointermove", this.dragUpdate);
739
- window.addEventListener("pointerup", this.pointerUpDragEnd);
740
- window.addEventListener("pointercancel", this.dragEnd);
741
- }
742
- focusActiveHandle(valueX) {
743
- switch (this.dragProp) {
744
- case "minValue":
745
- this.minHandle.focus();
746
- break;
747
- case "maxValue":
748
- case "value":
749
- this.maxHandle.focus();
750
- break;
751
- case "minMaxValue":
752
- this.getClosestHandle(valueX).focus();
753
- break;
754
- }
755
- }
756
- emitInput() {
757
- this.calciteSliderInput.emit();
758
- }
759
- emitChange() {
760
- this.calciteSliderChange.emit();
761
- }
762
- removeDragListeners() {
763
- window.removeEventListener("pointermove", this.dragUpdate);
764
- window.removeEventListener("pointerup", this.pointerUpDragEnd);
765
- window.removeEventListener("pointercancel", this.dragEnd);
766
- }
767
- /**
768
- * Set prop value(s) if changed at the component level
769
- *
770
- * @param {object} values - a set of key/value pairs delineating what properties in the component to update
771
- */
772
- setValue(values) {
773
- let valueChanged;
774
- Object.keys(values).forEach((propName) => {
775
- const newValue = values[propName];
776
- if (!valueChanged) {
777
- const oldValue = this[propName];
778
- valueChanged = oldValue !== newValue;
779
- }
780
- this[propName] = newValue;
781
- });
782
- if (!valueChanged) {
783
- return;
784
- }
785
- const dragging = this.dragProp;
786
- if (!dragging) {
787
- this.emitChange();
788
- }
789
- this.emitInput();
790
- }
791
- /**
792
- * If number is outside range, constrain to min or max
793
- *
794
- * @param value
795
- * @param prop
796
- * @internal
797
- */
798
- clamp(value, prop) {
799
- value = math.clamp(value, this.min, this.max);
800
- // ensure that maxValue and minValue don't swap positions
801
- if (prop === "maxValue") {
802
- value = Math.max(value, this.minValue);
803
- }
804
- if (prop === "minValue") {
805
- value = Math.min(value, this.maxValue);
806
- }
807
- return value;
808
- }
809
- /**
810
- * Translate a pixel position to value along the range
811
- *
812
- * @param x
813
- * @internal
814
- */
815
- translate(x) {
816
- const range = this.max - this.min;
817
- const { left, width } = this.trackEl.getBoundingClientRect();
818
- const percent = (x - left) / width;
819
- const mirror = this.shouldMirror();
820
- const clampedValue = this.clamp(this.min + range * (mirror ? 1 - percent : percent));
821
- let value = Number(clampedValue.toFixed(math.decimalPlaces(this.step)));
822
- if (this.snap && this.step) {
823
- value = this.getClosestStep(value);
824
- }
825
- return value;
826
- }
827
- /**
828
- * Get closest allowed value along stepped values
829
- *
830
- * @param num
831
- * @internal
832
- */
833
- getClosestStep(num) {
834
- num = Number(this.clamp(num).toFixed(math.decimalPlaces(this.step)));
835
- if (this.step) {
836
- const step = Math.round(num / this.step) * this.step;
837
- num = Number(this.clamp(step).toFixed(math.decimalPlaces(this.step)));
838
- }
839
- return num;
840
- }
841
- getClosestHandle(valueX) {
842
- return this.getDistanceX(this.maxHandle, valueX) > this.getDistanceX(this.minHandle, valueX)
843
- ? this.minHandle
844
- : this.maxHandle;
845
- }
846
- getDistanceX(el, valueX) {
847
- return Math.abs(el.getBoundingClientRect().left - valueX);
848
- }
849
- getFontSizeForElement(element) {
850
- return Number(window.getComputedStyle(element).getPropertyValue("font-size").match(/\d+/)[0]);
851
- }
852
- /**
853
- * Get position of value along range as fractional value
854
- *
855
- * @param num
856
- * @return {number} number in the unit interval [0,1]
857
- * @internal
858
- */
859
- getUnitInterval(num) {
860
- num = this.clamp(num);
861
- const range = this.max - this.min;
862
- return (num - this.min) / range;
863
- }
864
- adjustHostObscuredHandleLabel(name) {
865
- const label = this.el.shadowRoot.querySelector(`.handle__label--${name}`);
866
- const labelStatic = this.el.shadowRoot.querySelector(`.handle__label--${name}.static`);
867
- const labelTransformed = this.el.shadowRoot.querySelector(`.handle__label--${name}.transformed`);
868
- const labelStaticBounds = labelStatic.getBoundingClientRect();
869
- const labelStaticOffset = this.getHostOffset(labelStaticBounds.left, labelStaticBounds.right);
870
- label.style.transform = `translateX(${labelStaticOffset}px)`;
871
- labelTransformed.style.transform = `translateX(${labelStaticOffset}px)`;
872
- }
873
- hyphenateCollidingRangeHandleLabels() {
874
- const { shadowRoot } = this.el;
875
- const mirror = this.shouldMirror();
876
- const leftModifier = mirror ? "value" : "minValue";
877
- const rightModifier = mirror ? "minValue" : "value";
878
- const leftValueLabel = shadowRoot.querySelector(`.handle__label--${leftModifier}`);
879
- const leftValueLabelStatic = shadowRoot.querySelector(`.handle__label--${leftModifier}.static`);
880
- const leftValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${leftModifier}.transformed`);
881
- const leftValueLabelStaticHostOffset = this.getHostOffset(leftValueLabelStatic.getBoundingClientRect().left, leftValueLabelStatic.getBoundingClientRect().right);
882
- const rightValueLabel = shadowRoot.querySelector(`.handle__label--${rightModifier}`);
883
- const rightValueLabelStatic = shadowRoot.querySelector(`.handle__label--${rightModifier}.static`);
884
- const rightValueLabelTransformed = shadowRoot.querySelector(`.handle__label--${rightModifier}.transformed`);
885
- const rightValueLabelStaticHostOffset = this.getHostOffset(rightValueLabelStatic.getBoundingClientRect().left, rightValueLabelStatic.getBoundingClientRect().right);
886
- const labelFontSize = this.getFontSizeForElement(leftValueLabel);
887
- const labelTransformedOverlap = this.getRangeLabelOverlap(leftValueLabelTransformed, rightValueLabelTransformed);
888
- const hyphenLabel = leftValueLabel;
889
- const labelOffset = labelFontSize / 2;
890
- if (labelTransformedOverlap > 0) {
891
- hyphenLabel.classList.add(CSS.hyphen, CSS.hyphenWrap);
892
- if (rightValueLabelStaticHostOffset === 0 && leftValueLabelStaticHostOffset === 0) {
893
- // Neither handle overlaps the host boundary
894
- let leftValueLabelTranslate = labelTransformedOverlap / 2 - labelOffset;
895
- leftValueLabelTranslate =
896
- Math.sign(leftValueLabelTranslate) === -1
897
- ? Math.abs(leftValueLabelTranslate)
898
- : -leftValueLabelTranslate;
899
- const leftValueLabelTransformedHostOffset = this.getHostOffset(leftValueLabelTransformed.getBoundingClientRect().left +
900
- leftValueLabelTranslate -
901
- labelOffset, leftValueLabelTransformed.getBoundingClientRect().right +
902
- leftValueLabelTranslate -
903
- labelOffset);
904
- let rightValueLabelTranslate = labelTransformedOverlap / 2;
905
- const rightValueLabelTransformedHostOffset = this.getHostOffset(rightValueLabelTransformed.getBoundingClientRect().left + rightValueLabelTranslate, rightValueLabelTransformed.getBoundingClientRect().right + rightValueLabelTranslate);
906
- if (leftValueLabelTransformedHostOffset !== 0) {
907
- leftValueLabelTranslate += leftValueLabelTransformedHostOffset;
908
- rightValueLabelTranslate += leftValueLabelTransformedHostOffset;
909
- }
910
- if (rightValueLabelTransformedHostOffset !== 0) {
911
- leftValueLabelTranslate += rightValueLabelTransformedHostOffset;
912
- rightValueLabelTranslate += rightValueLabelTransformedHostOffset;
913
- }
914
- leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
915
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
916
- rightValueLabel.style.transform = `translateX(${rightValueLabelTranslate}px)`;
917
- rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelTranslate}px)`;
918
- }
919
- else if (leftValueLabelStaticHostOffset > 0 || rightValueLabelStaticHostOffset > 0) {
920
- // labels overlap host boundary on the left side
921
- leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset + labelOffset}px)`;
922
- rightValueLabel.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
923
- rightValueLabelTransformed.style.transform = `translateX(${labelTransformedOverlap + rightValueLabelStaticHostOffset}px)`;
924
- }
925
- else if (leftValueLabelStaticHostOffset < 0 || rightValueLabelStaticHostOffset < 0) {
926
- // labels overlap host boundary on the right side
927
- let leftValueLabelTranslate = Math.abs(leftValueLabelStaticHostOffset) + labelTransformedOverlap - labelOffset;
928
- leftValueLabelTranslate =
929
- Math.sign(leftValueLabelTranslate) === -1
930
- ? Math.abs(leftValueLabelTranslate)
931
- : -leftValueLabelTranslate;
932
- leftValueLabel.style.transform = `translateX(${leftValueLabelTranslate}px)`;
933
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelTranslate - labelOffset}px)`;
934
- }
935
- }
936
- else {
937
- hyphenLabel.classList.remove(CSS.hyphen, CSS.hyphenWrap);
938
- leftValueLabel.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
939
- leftValueLabelTransformed.style.transform = `translateX(${leftValueLabelStaticHostOffset}px)`;
940
- rightValueLabel.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
941
- rightValueLabelTransformed.style.transform = `translateX(${rightValueLabelStaticHostOffset}px)`;
942
- }
943
- }
944
- /**
945
- * Hides bounding tick labels that are obscured by either handle.
946
- */
947
- hideObscuredBoundingTickLabels() {
948
- const valueIsRange = isRange(this.value);
949
- if (!this.hasHistogram && !valueIsRange && !this.labelHandles && !this.precise) {
950
- return;
951
- }
952
- if (!this.hasHistogram && !valueIsRange && this.labelHandles && !this.precise) {
953
- return;
954
- }
955
- if (!this.hasHistogram && !valueIsRange && !this.labelHandles && this.precise) {
956
- return;
957
- }
958
- if (!this.hasHistogram && !valueIsRange && this.labelHandles && this.precise) {
959
- return;
960
- }
961
- if (!this.hasHistogram && valueIsRange && !this.precise) {
962
- return;
963
- }
964
- if (this.hasHistogram && !this.precise && !this.labelHandles) {
965
- return;
966
- }
967
- const minHandle = this.el.shadowRoot.querySelector(`.${CSS.thumbMinValue}`);
968
- const maxHandle = this.el.shadowRoot.querySelector(`.${CSS.thumbValue}`);
969
- const minTickLabel = this.el.shadowRoot.querySelector(`.${CSS.tickMin}`);
970
- const maxTickLabel = this.el.shadowRoot.querySelector(`.${CSS.tickMax}`);
971
- if (!minHandle && maxHandle && minTickLabel && maxTickLabel) {
972
- minTickLabel.style.opacity = this.isMinTickLabelObscured(minTickLabel, maxHandle) ? "0" : "1";
973
- maxTickLabel.style.opacity = this.isMaxTickLabelObscured(maxTickLabel, maxHandle) ? "0" : "1";
974
- }
975
- if (minHandle && maxHandle && minTickLabel && maxTickLabel) {
976
- minTickLabel.style.opacity =
977
- this.isMinTickLabelObscured(minTickLabel, minHandle) ||
978
- this.isMinTickLabelObscured(minTickLabel, maxHandle)
979
- ? "0"
980
- : "1";
981
- maxTickLabel.style.opacity =
982
- this.isMaxTickLabelObscured(maxTickLabel, minHandle) ||
983
- (this.isMaxTickLabelObscured(maxTickLabel, maxHandle) && this.hasHistogram)
984
- ? "0"
985
- : "1";
986
- }
987
- }
988
- /**
989
- * Returns an integer representing the number of pixels to offset on the left or right side based on desired position behavior.
990
- *
991
- * @param leftBounds
992
- * @param rightBounds
993
- * @internal
994
- */
995
- getHostOffset(leftBounds, rightBounds) {
996
- const hostBounds = this.el.getBoundingClientRect();
997
- const buffer = 7;
998
- if (leftBounds + buffer < hostBounds.left) {
999
- return hostBounds.left - leftBounds - buffer;
1000
- }
1001
- if (rightBounds - buffer > hostBounds.right) {
1002
- return -(rightBounds - hostBounds.right) + buffer;
1003
- }
1004
- return 0;
1005
- }
1006
- /**
1007
- * Returns an integer representing the number of pixels that the two given span elements are overlapping, taking into account
1008
- * 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.
1009
- *
1010
- * @param leftLabel
1011
- * @param rightLabel
1012
- */
1013
- getRangeLabelOverlap(leftLabel, rightLabel) {
1014
- const leftLabelBounds = leftLabel.getBoundingClientRect();
1015
- const rightLabelBounds = rightLabel.getBoundingClientRect();
1016
- const leftLabelFontSize = this.getFontSizeForElement(leftLabel);
1017
- const rangeLabelOverlap = leftLabelBounds.right + leftLabelFontSize - rightLabelBounds.left;
1018
- return Math.max(rangeLabelOverlap, 0);
1019
- }
1020
- /**
1021
- * Returns a boolean value representing if the minLabel span element is obscured (being overlapped) by the given handle div element.
1022
- *
1023
- * @param minLabel
1024
- * @param handle
1025
- */
1026
- isMinTickLabelObscured(minLabel, handle) {
1027
- const minLabelBounds = minLabel.getBoundingClientRect();
1028
- const handleBounds = handle.getBoundingClientRect();
1029
- return dom.intersects(minLabelBounds, handleBounds);
1030
- }
1031
- /**
1032
- * Returns a boolean value representing if the maxLabel span element is obscured (being overlapped) by the given handle div element.
1033
- *
1034
- * @param maxLabel
1035
- * @param handle
1036
- */
1037
- isMaxTickLabelObscured(maxLabel, handle) {
1038
- const maxLabelBounds = maxLabel.getBoundingClientRect();
1039
- const handleBounds = handle.getBoundingClientRect();
1040
- return dom.intersects(maxLabelBounds, handleBounds);
1041
- }
1042
- static get delegatesFocus() { return true; }
1043
- get el() { return index.getElement(this); }
1044
- static get watchers() { return {
1045
- "histogram": ["histogramWatcher"],
1046
- "ticks": ["ticksWatcher"],
1047
- "value": ["valueHandler"],
1048
- "minValue": ["minMaxValueHandler"],
1049
- "maxValue": ["minMaxValueHandler"]
1050
- }; }
1051
- };
1052
- Slider.style = sliderCss;
1053
-
1054
- exports.calcite_graph = Graph;
1055
- exports.calcite_slider = Slider;