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