@zag-js/slider 1.46.0 → 1.48.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +6 -8
- package/dist/index.d.ts +6 -8
- package/dist/index.js +16 -38
- package/dist/index.mjs +2 -7
- package/dist/slider.anatomy.d.mts +2 -6
- package/dist/slider.anatomy.d.ts +2 -6
- package/dist/slider.anatomy.js +8 -44
- package/dist/slider.anatomy.mjs +4 -18
- package/dist/slider.connect.d.mts +3 -7
- package/dist/slider.connect.d.ts +3 -7
- package/dist/slider.connect.js +371 -351
- package/dist/slider.connect.mjs +366 -330
- package/dist/slider.dom.d.mts +27 -30
- package/dist/slider.dom.d.ts +27 -30
- package/dist/slider.dom.js +93 -137
- package/dist/slider.dom.mjs +70 -93
- package/dist/slider.machine.d.mts +2 -7
- package/dist/slider.machine.d.ts +2 -7
- package/dist/slider.machine.js +322 -367
- package/dist/slider.machine.mjs +318 -351
- package/dist/slider.props.d.mts +7 -12
- package/dist/slider.props.d.ts +7 -12
- package/dist/slider.props.js +45 -73
- package/dist/slider.props.mjs +36 -43
- package/dist/slider.style.d.mts +15 -17
- package/dist/slider.style.d.ts +15 -17
- package/dist/slider.style.js +126 -156
- package/dist/slider.style.mjs +114 -123
- package/dist/slider.types.d.mts +307 -309
- package/dist/slider.types.d.ts +307 -309
- package/dist/slider.types.js +4 -18
- package/dist/slider.types.mjs +1 -0
- package/dist/slider.utils.d.mts +18 -21
- package/dist/slider.utils.d.ts +18 -21
- package/dist/slider.utils.js +144 -168
- package/dist/slider.utils.mjs +132 -135
- package/package.json +8 -8
package/dist/slider.connect.mjs
CHANGED
|
@@ -1,334 +1,370 @@
|
|
|
1
|
-
// src/slider.connect.ts
|
|
2
|
-
import {
|
|
3
|
-
ariaAttr,
|
|
4
|
-
dataAttr,
|
|
5
|
-
getEventKey,
|
|
6
|
-
getEventPoint,
|
|
7
|
-
getEventStepValue,
|
|
8
|
-
isLeftClick,
|
|
9
|
-
isModifierKey
|
|
10
|
-
} from "@zag-js/dom-query";
|
|
11
|
-
import { first, getPercentValue, getValuePercent, last } from "@zag-js/utils";
|
|
12
1
|
import { parts } from "./slider.anatomy.mjs";
|
|
13
|
-
import
|
|
14
|
-
import {
|
|
15
|
-
getControlStyle,
|
|
16
|
-
getMarkerGroupStyle,
|
|
17
|
-
getMarkerStyle,
|
|
18
|
-
getRangeStyle,
|
|
19
|
-
getRootStyle,
|
|
20
|
-
getThumbStyle
|
|
21
|
-
} from "./slider.style.mjs";
|
|
2
|
+
import { getControlId, getFirstThumbEl, getHiddenInputId, getLabelId, getMarkerId, getRangeId, getRootId, getThumbId, getTrackId, getValueTextId } from "./slider.dom.mjs";
|
|
3
|
+
import { getControlStyle, getMarkerGroupStyle, getMarkerStyle, getRangeStyle, getRootStyle, getThumbStyle } from "./slider.style.mjs";
|
|
22
4
|
import { getRangeAtIndex } from "./slider.utils.mjs";
|
|
5
|
+
import { ariaAttr, dataAttr, getEventKey, getEventPoint, getEventStepValue, isLeftClick, isModifierKey } from "@zag-js/dom-query";
|
|
6
|
+
import { first, getPercentValue, getValuePercent, last } from "@zag-js/utils";
|
|
7
|
+
// src/slider.connect.ts
|
|
23
8
|
function connect(service, normalize) {
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
9
|
+
const { state, send, context, prop, computed, scope } = service;
|
|
10
|
+
const ariaLabel = prop("aria-label");
|
|
11
|
+
const ariaLabelledBy = prop("aria-labelledby");
|
|
12
|
+
const sliderValue = context.get("value");
|
|
13
|
+
const focusedIndex = context.get("focusedIndex");
|
|
14
|
+
const focused = state.matches("focus");
|
|
15
|
+
const dragging = state.matches("dragging");
|
|
16
|
+
const disabled = computed("isDisabled");
|
|
17
|
+
const invalid = prop("invalid");
|
|
18
|
+
const interactive = computed("isInteractive");
|
|
19
|
+
const isHorizontal = prop("orientation") === "horizontal";
|
|
20
|
+
const isVertical = prop("orientation") === "vertical";
|
|
21
|
+
function getValuePercentFn(value) {
|
|
22
|
+
return getValuePercent(value, prop("min"), prop("max"));
|
|
23
|
+
}
|
|
24
|
+
function getPercentValueFn(percent) {
|
|
25
|
+
return getPercentValue(percent, prop("min"), prop("max"), prop("step"));
|
|
26
|
+
}
|
|
27
|
+
return {
|
|
28
|
+
value: sliderValue,
|
|
29
|
+
dragging,
|
|
30
|
+
focused,
|
|
31
|
+
setValue(value) {
|
|
32
|
+
send({
|
|
33
|
+
type: "SET_VALUE",
|
|
34
|
+
value
|
|
35
|
+
});
|
|
36
|
+
},
|
|
37
|
+
getThumbValue(index) {
|
|
38
|
+
return sliderValue[index];
|
|
39
|
+
},
|
|
40
|
+
setThumbValue(index, value) {
|
|
41
|
+
send({
|
|
42
|
+
type: "SET_VALUE",
|
|
43
|
+
index,
|
|
44
|
+
value
|
|
45
|
+
});
|
|
46
|
+
},
|
|
47
|
+
getValuePercent: getValuePercentFn,
|
|
48
|
+
getPercentValue: getPercentValueFn,
|
|
49
|
+
getThumbPercent(index) {
|
|
50
|
+
return getValuePercentFn(sliderValue[index]);
|
|
51
|
+
},
|
|
52
|
+
setThumbPercent(index, percent) {
|
|
53
|
+
const value = getPercentValueFn(percent);
|
|
54
|
+
send({
|
|
55
|
+
type: "SET_VALUE",
|
|
56
|
+
index,
|
|
57
|
+
value
|
|
58
|
+
});
|
|
59
|
+
},
|
|
60
|
+
getThumbMin(index) {
|
|
61
|
+
return getRangeAtIndex(service, index).min;
|
|
62
|
+
},
|
|
63
|
+
getThumbMax(index) {
|
|
64
|
+
return getRangeAtIndex(service, index).max;
|
|
65
|
+
},
|
|
66
|
+
increment(index) {
|
|
67
|
+
send({
|
|
68
|
+
type: "INCREMENT",
|
|
69
|
+
index
|
|
70
|
+
});
|
|
71
|
+
},
|
|
72
|
+
decrement(index) {
|
|
73
|
+
send({
|
|
74
|
+
type: "DECREMENT",
|
|
75
|
+
index
|
|
76
|
+
});
|
|
77
|
+
},
|
|
78
|
+
focus() {
|
|
79
|
+
if (!interactive) return;
|
|
80
|
+
send({
|
|
81
|
+
type: "FOCUS",
|
|
82
|
+
index: 0
|
|
83
|
+
});
|
|
84
|
+
},
|
|
85
|
+
getLabelProps() {
|
|
86
|
+
return normalize.label({
|
|
87
|
+
...parts.label.attrs,
|
|
88
|
+
dir: prop("dir"),
|
|
89
|
+
"data-disabled": dataAttr(disabled),
|
|
90
|
+
"data-orientation": prop("orientation"),
|
|
91
|
+
"data-invalid": dataAttr(invalid),
|
|
92
|
+
"data-dragging": dataAttr(dragging),
|
|
93
|
+
"data-focus": dataAttr(focused),
|
|
94
|
+
id: getLabelId(scope),
|
|
95
|
+
htmlFor: getHiddenInputId(scope, 0),
|
|
96
|
+
onClick(event) {
|
|
97
|
+
if (!interactive) return;
|
|
98
|
+
event.preventDefault();
|
|
99
|
+
getFirstThumbEl(scope)?.focus();
|
|
100
|
+
},
|
|
101
|
+
style: {
|
|
102
|
+
userSelect: "none",
|
|
103
|
+
WebkitUserSelect: "none"
|
|
104
|
+
}
|
|
105
|
+
});
|
|
106
|
+
},
|
|
107
|
+
getRootProps() {
|
|
108
|
+
return normalize.element({
|
|
109
|
+
...parts.root.attrs,
|
|
110
|
+
"data-disabled": dataAttr(disabled),
|
|
111
|
+
"data-orientation": prop("orientation"),
|
|
112
|
+
"data-dragging": dataAttr(dragging),
|
|
113
|
+
"data-invalid": dataAttr(invalid),
|
|
114
|
+
"data-focus": dataAttr(focused),
|
|
115
|
+
id: getRootId(scope),
|
|
116
|
+
dir: prop("dir"),
|
|
117
|
+
style: getRootStyle(service)
|
|
118
|
+
});
|
|
119
|
+
},
|
|
120
|
+
getValueTextProps() {
|
|
121
|
+
return normalize.element({
|
|
122
|
+
...parts.valueText.attrs,
|
|
123
|
+
dir: prop("dir"),
|
|
124
|
+
"data-disabled": dataAttr(disabled),
|
|
125
|
+
"data-orientation": prop("orientation"),
|
|
126
|
+
"data-invalid": dataAttr(invalid),
|
|
127
|
+
"data-focus": dataAttr(focused),
|
|
128
|
+
id: getValueTextId(scope)
|
|
129
|
+
});
|
|
130
|
+
},
|
|
131
|
+
getTrackProps() {
|
|
132
|
+
return normalize.element({
|
|
133
|
+
...parts.track.attrs,
|
|
134
|
+
dir: prop("dir"),
|
|
135
|
+
id: getTrackId(scope),
|
|
136
|
+
"data-disabled": dataAttr(disabled),
|
|
137
|
+
"data-invalid": dataAttr(invalid),
|
|
138
|
+
"data-dragging": dataAttr(dragging),
|
|
139
|
+
"data-orientation": prop("orientation"),
|
|
140
|
+
"data-focus": dataAttr(focused),
|
|
141
|
+
style: { position: "relative" }
|
|
142
|
+
});
|
|
143
|
+
},
|
|
144
|
+
getThumbProps(props) {
|
|
145
|
+
const { index = 0, name } = props;
|
|
146
|
+
const value = sliderValue[index];
|
|
147
|
+
const range = getRangeAtIndex(service, index);
|
|
148
|
+
const valueText = prop("getAriaValueText")?.({
|
|
149
|
+
value,
|
|
150
|
+
index
|
|
151
|
+
});
|
|
152
|
+
const _ariaLabel = Array.isArray(ariaLabel) ? ariaLabel[index] : ariaLabel;
|
|
153
|
+
const _ariaLabelledBy = Array.isArray(ariaLabelledBy) ? ariaLabelledBy[index] : ariaLabelledBy;
|
|
154
|
+
return normalize.element({
|
|
155
|
+
...parts.thumb.attrs,
|
|
156
|
+
dir: prop("dir"),
|
|
157
|
+
"data-index": index,
|
|
158
|
+
"data-name": name,
|
|
159
|
+
id: getThumbId(scope, index),
|
|
160
|
+
"data-disabled": dataAttr(disabled),
|
|
161
|
+
"data-orientation": prop("orientation"),
|
|
162
|
+
"data-focus": dataAttr(focused && focusedIndex === index),
|
|
163
|
+
"data-dragging": dataAttr(dragging && focusedIndex === index),
|
|
164
|
+
draggable: false,
|
|
165
|
+
"aria-disabled": ariaAttr(disabled),
|
|
166
|
+
"aria-label": _ariaLabel,
|
|
167
|
+
"aria-labelledby": _ariaLabelledBy ?? getLabelId(scope),
|
|
168
|
+
"aria-orientation": prop("orientation"),
|
|
169
|
+
"aria-valuemax": range.max,
|
|
170
|
+
"aria-valuemin": range.min,
|
|
171
|
+
"aria-valuenow": sliderValue[index],
|
|
172
|
+
"aria-valuetext": valueText,
|
|
173
|
+
role: "slider",
|
|
174
|
+
tabIndex: disabled ? void 0 : 0,
|
|
175
|
+
style: getThumbStyle(service, index),
|
|
176
|
+
onPointerDown(event) {
|
|
177
|
+
if (!interactive) return;
|
|
178
|
+
if (!isLeftClick(event)) return;
|
|
179
|
+
const rect = event.currentTarget.getBoundingClientRect();
|
|
180
|
+
const midpoint = {
|
|
181
|
+
x: rect.left + rect.width / 2,
|
|
182
|
+
y: rect.top + rect.height / 2
|
|
183
|
+
};
|
|
184
|
+
const offset = {
|
|
185
|
+
x: event.clientX - midpoint.x,
|
|
186
|
+
y: event.clientY - midpoint.y
|
|
187
|
+
};
|
|
188
|
+
send({
|
|
189
|
+
type: "THUMB_POINTER_DOWN",
|
|
190
|
+
index,
|
|
191
|
+
offset
|
|
192
|
+
});
|
|
193
|
+
event.stopPropagation();
|
|
194
|
+
},
|
|
195
|
+
onBlur() {
|
|
196
|
+
if (!interactive) return;
|
|
197
|
+
send({ type: "BLUR" });
|
|
198
|
+
},
|
|
199
|
+
onFocus() {
|
|
200
|
+
if (!interactive) return;
|
|
201
|
+
send({
|
|
202
|
+
type: "FOCUS",
|
|
203
|
+
index
|
|
204
|
+
});
|
|
205
|
+
},
|
|
206
|
+
onKeyDown(event) {
|
|
207
|
+
if (event.defaultPrevented) return;
|
|
208
|
+
if (!interactive) return;
|
|
209
|
+
const step = getEventStepValue(event, {
|
|
210
|
+
step: prop("step"),
|
|
211
|
+
largeStep: prop("largeStep")
|
|
212
|
+
});
|
|
213
|
+
const exec = {
|
|
214
|
+
ArrowUp() {
|
|
215
|
+
if (isHorizontal) return;
|
|
216
|
+
send({
|
|
217
|
+
type: "ARROW_INC",
|
|
218
|
+
step,
|
|
219
|
+
src: "ArrowUp"
|
|
220
|
+
});
|
|
221
|
+
},
|
|
222
|
+
ArrowDown() {
|
|
223
|
+
if (isHorizontal) return;
|
|
224
|
+
send({
|
|
225
|
+
type: "ARROW_DEC",
|
|
226
|
+
step,
|
|
227
|
+
src: "ArrowDown"
|
|
228
|
+
});
|
|
229
|
+
},
|
|
230
|
+
ArrowLeft() {
|
|
231
|
+
if (isVertical) return;
|
|
232
|
+
send({
|
|
233
|
+
type: "ARROW_DEC",
|
|
234
|
+
step,
|
|
235
|
+
src: "ArrowLeft"
|
|
236
|
+
});
|
|
237
|
+
},
|
|
238
|
+
ArrowRight() {
|
|
239
|
+
if (isVertical) return;
|
|
240
|
+
send({
|
|
241
|
+
type: "ARROW_INC",
|
|
242
|
+
step,
|
|
243
|
+
src: "ArrowRight"
|
|
244
|
+
});
|
|
245
|
+
},
|
|
246
|
+
PageUp() {
|
|
247
|
+
send({
|
|
248
|
+
type: "ARROW_INC",
|
|
249
|
+
step,
|
|
250
|
+
src: "PageUp"
|
|
251
|
+
});
|
|
252
|
+
},
|
|
253
|
+
PageDown() {
|
|
254
|
+
send({
|
|
255
|
+
type: "ARROW_DEC",
|
|
256
|
+
step,
|
|
257
|
+
src: "PageDown"
|
|
258
|
+
});
|
|
259
|
+
},
|
|
260
|
+
Home() {
|
|
261
|
+
send({ type: "HOME" });
|
|
262
|
+
},
|
|
263
|
+
End() {
|
|
264
|
+
send({ type: "END" });
|
|
265
|
+
}
|
|
266
|
+
}[getEventKey(event, {
|
|
267
|
+
dir: prop("dir"),
|
|
268
|
+
orientation: prop("orientation")
|
|
269
|
+
})];
|
|
270
|
+
if (exec) {
|
|
271
|
+
exec(event);
|
|
272
|
+
event.preventDefault();
|
|
273
|
+
event.stopPropagation();
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
});
|
|
277
|
+
},
|
|
278
|
+
getHiddenInputProps(props) {
|
|
279
|
+
const { index = 0, name } = props;
|
|
280
|
+
return normalize.input({
|
|
281
|
+
name: name ?? (prop("name") ? prop("name") + (sliderValue.length > 1 ? "[]" : "") : void 0),
|
|
282
|
+
form: prop("form"),
|
|
283
|
+
type: "text",
|
|
284
|
+
hidden: true,
|
|
285
|
+
defaultValue: sliderValue[index],
|
|
286
|
+
id: getHiddenInputId(scope, index)
|
|
287
|
+
});
|
|
288
|
+
},
|
|
289
|
+
getRangeProps() {
|
|
290
|
+
return normalize.element({
|
|
291
|
+
id: getRangeId(scope),
|
|
292
|
+
...parts.range.attrs,
|
|
293
|
+
dir: prop("dir"),
|
|
294
|
+
"data-dragging": dataAttr(dragging),
|
|
295
|
+
"data-focus": dataAttr(focused),
|
|
296
|
+
"data-invalid": dataAttr(invalid),
|
|
297
|
+
"data-disabled": dataAttr(disabled),
|
|
298
|
+
"data-orientation": prop("orientation"),
|
|
299
|
+
style: getRangeStyle(service)
|
|
300
|
+
});
|
|
301
|
+
},
|
|
302
|
+
getControlProps() {
|
|
303
|
+
return normalize.element({
|
|
304
|
+
...parts.control.attrs,
|
|
305
|
+
dir: prop("dir"),
|
|
306
|
+
id: getControlId(scope),
|
|
307
|
+
"data-dragging": dataAttr(dragging),
|
|
308
|
+
"data-disabled": dataAttr(disabled),
|
|
309
|
+
"data-orientation": prop("orientation"),
|
|
310
|
+
"data-invalid": dataAttr(invalid),
|
|
311
|
+
"data-focus": dataAttr(focused),
|
|
312
|
+
style: getControlStyle(),
|
|
313
|
+
onPointerDown(event) {
|
|
314
|
+
if (!interactive) return;
|
|
315
|
+
if (!isLeftClick(event)) return;
|
|
316
|
+
if (isModifierKey(event)) return;
|
|
317
|
+
const point = getEventPoint(event);
|
|
318
|
+
send({
|
|
319
|
+
type: "POINTER_DOWN",
|
|
320
|
+
point
|
|
321
|
+
});
|
|
322
|
+
event.preventDefault();
|
|
323
|
+
event.stopPropagation();
|
|
324
|
+
}
|
|
325
|
+
});
|
|
326
|
+
},
|
|
327
|
+
getMarkerGroupProps() {
|
|
328
|
+
return normalize.element({
|
|
329
|
+
...parts.markerGroup.attrs,
|
|
330
|
+
role: "presentation",
|
|
331
|
+
dir: prop("dir"),
|
|
332
|
+
"aria-hidden": true,
|
|
333
|
+
"data-orientation": prop("orientation"),
|
|
334
|
+
style: getMarkerGroupStyle()
|
|
335
|
+
});
|
|
336
|
+
},
|
|
337
|
+
getMarkerProps(props) {
|
|
338
|
+
const style = getMarkerStyle(service, props.value);
|
|
339
|
+
let markerState;
|
|
340
|
+
if (props.value < first(sliderValue)) markerState = "under-value";
|
|
341
|
+
else if (props.value > last(sliderValue)) markerState = "over-value";
|
|
342
|
+
else markerState = "at-value";
|
|
343
|
+
return normalize.element({
|
|
344
|
+
...parts.marker.attrs,
|
|
345
|
+
id: getMarkerId(scope, props.value),
|
|
346
|
+
role: "presentation",
|
|
347
|
+
dir: prop("dir"),
|
|
348
|
+
"data-orientation": prop("orientation"),
|
|
349
|
+
"data-value": props.value,
|
|
350
|
+
"data-disabled": dataAttr(disabled),
|
|
351
|
+
"data-state": markerState,
|
|
352
|
+
style
|
|
353
|
+
});
|
|
354
|
+
},
|
|
355
|
+
getDraggingIndicatorProps(props) {
|
|
356
|
+
const { index = 0 } = props;
|
|
357
|
+
const isDragging = index === focusedIndex && dragging;
|
|
358
|
+
return normalize.element({
|
|
359
|
+
...parts.draggingIndicator.attrs,
|
|
360
|
+
role: "presentation",
|
|
361
|
+
dir: prop("dir"),
|
|
362
|
+
hidden: !isDragging,
|
|
363
|
+
"data-orientation": prop("orientation"),
|
|
364
|
+
"data-state": isDragging ? "open" : "closed",
|
|
365
|
+
style: getThumbStyle(service, index)
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
};
|
|
331
369
|
}
|
|
332
|
-
export {
|
|
333
|
-
connect
|
|
334
|
-
};
|
|
370
|
+
export { connect };
|