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