@esri/solutions-components 0.8.7 → 0.8.9

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