@zag-js/slider 2.0.0-next.2 → 2.0.0-next.4

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