@zag-js/slider 0.82.2 → 1.0.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.js CHANGED
@@ -21,26 +21,65 @@ var anatomy = anatomy$1.createAnatomy("slider").parts(
21
21
  "draggingIndicator"
22
22
  );
23
23
  var parts = anatomy.build();
24
+ var getRootId = (ctx) => ctx.ids?.root ?? `slider:${ctx.id}`;
25
+ var getThumbId = (ctx, index) => ctx.ids?.thumb?.(index) ?? `slider:${ctx.id}:thumb:${index}`;
26
+ var getHiddenInputId = (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `slider:${ctx.id}:input:${index}`;
27
+ var getControlId = (ctx) => ctx.ids?.control ?? `slider:${ctx.id}:control`;
28
+ var getTrackId = (ctx) => ctx.ids?.track ?? `slider:${ctx.id}:track`;
29
+ var getRangeId = (ctx) => ctx.ids?.range ?? `slider:${ctx.id}:range`;
30
+ var getLabelId = (ctx) => ctx.ids?.label ?? `slider:${ctx.id}:label`;
31
+ var getValueTextId = (ctx) => ctx.ids?.valueText ?? `slider:${ctx.id}:value-text`;
32
+ var getMarkerId = (ctx, value) => ctx.ids?.marker?.(value) ?? `slider:${ctx.id}:marker:${value}`;
33
+ var getRootEl = (ctx) => ctx.getById(getRootId(ctx));
34
+ var getThumbEl = (ctx, index) => ctx.getById(getThumbId(ctx, index));
35
+ var getHiddenInputEl = (ctx, index) => ctx.getById(getHiddenInputId(ctx, index));
36
+ var getControlEl = (ctx) => ctx.getById(getControlId(ctx));
37
+ var getElements = (ctx) => domQuery.queryAll(getControlEl(ctx), "[role=slider]");
38
+ var getFirstEl = (ctx) => getElements(ctx)[0];
39
+ var getValueFromPoint = (params, point) => {
40
+ const { prop, scope } = params;
41
+ const controlEl = getControlEl(scope);
42
+ if (!controlEl) return;
43
+ const relativePoint = domQuery.getRelativePoint(point, controlEl);
44
+ const percent = relativePoint.getPercentValue({
45
+ orientation: prop("orientation"),
46
+ dir: prop("dir"),
47
+ inverted: { y: true }
48
+ });
49
+ return utils.getPercentValue(percent, prop("min"), prop("max"), prop("step"));
50
+ };
51
+ var dispatchChangeEvent = (ctx, value) => {
52
+ value.forEach((value2, index) => {
53
+ const inputEl = getHiddenInputEl(ctx, index);
54
+ if (!inputEl) return;
55
+ domQuery.dispatchInputValueEvent(inputEl, { value: value2 });
56
+ });
57
+ };
24
58
  function getBounds(value) {
25
59
  const firstValue = value[0];
26
60
  const lastThumb = value[value.length - 1];
27
61
  return [firstValue, lastThumb];
28
62
  }
29
- function getRangeOffsets(ctx) {
30
- const [firstPercent, lastPercent] = getBounds(ctx.valuePercent);
31
- if (ctx.valuePercent.length === 1) {
32
- if (ctx.origin === "center") {
33
- const isNegative = ctx.valuePercent[0] < 50;
34
- const start = isNegative ? `${ctx.valuePercent[0]}%` : "50%";
35
- const end = isNegative ? "50%" : `${100 - ctx.valuePercent[0]}%`;
63
+ function getRangeOffsets(params) {
64
+ const { prop, computed } = params;
65
+ const valuePercent = computed("valuePercent");
66
+ const [firstPercent, lastPercent] = getBounds(valuePercent);
67
+ if (valuePercent.length === 1) {
68
+ if (prop("origin") === "center") {
69
+ const isNegative = valuePercent[0] < 50;
70
+ const start = isNegative ? `${valuePercent[0]}%` : "50%";
71
+ const end = isNegative ? "50%" : `${100 - valuePercent[0]}%`;
36
72
  return { start, end };
37
73
  }
38
74
  return { start: "0%", end: `${100 - lastPercent}%` };
39
75
  }
40
76
  return { start: `${firstPercent}%`, end: `${100 - lastPercent}%` };
41
77
  }
42
- function getRangeStyle(ctx) {
43
- if (ctx.isVertical) {
78
+ function getRangeStyle(params) {
79
+ const { computed } = params;
80
+ const isVertical = computed("isVertical");
81
+ const isRtl = computed("isRtl");
82
+ if (isVertical) {
44
83
  return {
45
84
  position: "absolute",
46
85
  bottom: "var(--slider-range-start)",
@@ -49,44 +88,51 @@ function getRangeStyle(ctx) {
49
88
  }
50
89
  return {
51
90
  position: "absolute",
52
- [ctx.isRtl ? "right" : "left"]: "var(--slider-range-start)",
53
- [ctx.isRtl ? "left" : "right"]: "var(--slider-range-end)"
91
+ [isRtl ? "right" : "left"]: "var(--slider-range-start)",
92
+ [isRtl ? "left" : "right"]: "var(--slider-range-end)"
54
93
  };
55
94
  }
56
- function getVerticalThumbOffset(ctx) {
57
- const { height = 0 } = ctx.thumbSize ?? {};
58
- const getValue = utils.getValueTransformer([ctx.min, ctx.max], [-height / 2, height / 2]);
59
- return parseFloat(getValue(ctx.value).toFixed(2));
95
+ function getVerticalThumbOffset(params, value) {
96
+ const { context, prop } = params;
97
+ const { height = 0 } = context.get("thumbSize") ?? {};
98
+ const getValue = utils.getValueTransformer([prop("min"), prop("max")], [-height / 2, height / 2]);
99
+ return parseFloat(getValue(value).toFixed(2));
60
100
  }
61
- function getHorizontalThumbOffset(ctx) {
62
- const { width = 0 } = ctx.thumbSize ?? {};
63
- if (ctx.isRtl) {
64
- const getValue2 = utils.getValueTransformer([ctx.max, ctx.min], [-width / 2, width / 2]);
65
- return -1 * parseFloat(getValue2(ctx.value).toFixed(2));
101
+ function getHorizontalThumbOffset(params, value) {
102
+ const { computed, context, prop } = params;
103
+ const { width = 0 } = context.get("thumbSize") ?? {};
104
+ const isRtl = computed("isRtl");
105
+ if (isRtl) {
106
+ const getValue2 = utils.getValueTransformer([prop("max"), prop("min")], [-width / 2, width / 2]);
107
+ return -1 * parseFloat(getValue2(value).toFixed(2));
66
108
  }
67
- const getValue = utils.getValueTransformer([ctx.min, ctx.max], [-width / 2, width / 2]);
68
- return parseFloat(getValue(ctx.value).toFixed(2));
109
+ const getValue = utils.getValueTransformer([prop("min"), prop("max")], [-width / 2, width / 2]);
110
+ return parseFloat(getValue(value).toFixed(2));
69
111
  }
70
- function getOffset(ctx, percent) {
71
- if (ctx.thumbAlignment === "center") return `${percent}%`;
72
- const offset = ctx.isVertical ? getVerticalThumbOffset(ctx) : getHorizontalThumbOffset(ctx);
112
+ function getOffset(params, percent, value) {
113
+ const { computed, prop } = params;
114
+ if (prop("thumbAlignment") === "center") return `${percent}%`;
115
+ const offset = computed("isVertical") ? getVerticalThumbOffset(params, value) : getHorizontalThumbOffset(params, value);
73
116
  return `calc(${percent}% - ${offset}px)`;
74
117
  }
75
- function getThumbOffset(ctx) {
76
- let percent = utils.getValuePercent(ctx.value, ctx.min, ctx.max) * 100;
77
- return getOffset(ctx, percent);
118
+ function getThumbOffset(params, value) {
119
+ const { prop } = params;
120
+ const percent = utils.getValuePercent(value, prop("min"), prop("max")) * 100;
121
+ return getOffset(params, percent, value);
78
122
  }
79
- function getVisibility(ctx) {
123
+ function getVisibility(params) {
124
+ const { computed, prop } = params;
80
125
  let visibility = "visible";
81
- if (ctx.thumbAlignment === "contain" && !ctx.hasMeasuredThumbSize) {
126
+ if (prop("thumbAlignment") === "contain" && !computed("hasMeasuredThumbSize")) {
82
127
  visibility = "hidden";
83
128
  }
84
129
  return visibility;
85
130
  }
86
- function getThumbStyle(ctx, index) {
87
- const placementProp = ctx.isVertical ? "bottom" : "insetInlineStart";
131
+ function getThumbStyle(params, index) {
132
+ const { computed } = params;
133
+ const placementProp = computed("isVertical") ? "bottom" : "insetInlineStart";
88
134
  return {
89
- visibility: getVisibility(ctx),
135
+ visibility: getVisibility(params),
90
136
  position: "absolute",
91
137
  transform: "var(--slider-thumb-transform)",
92
138
  [placementProp]: `var(--slider-thumb-offset-${index})`
@@ -100,30 +146,34 @@ function getControlStyle() {
100
146
  position: "relative"
101
147
  };
102
148
  }
103
- function getRootStyle(ctx) {
104
- const range = getRangeOffsets(ctx);
105
- const offsetStyles = ctx.value.reduce((styles, value, index) => {
106
- const offset = getThumbOffset({ ...ctx, value });
149
+ function getRootStyle(params) {
150
+ const { context, computed } = params;
151
+ const isVertical = computed("isVertical");
152
+ const isRtl = computed("isRtl");
153
+ const range = getRangeOffsets(params);
154
+ const offsetStyles = context.get("value").reduce((styles, value, index) => {
155
+ const offset = getThumbOffset(params, value);
107
156
  return { ...styles, [`--slider-thumb-offset-${index}`]: offset };
108
157
  }, {});
109
158
  return {
110
159
  ...offsetStyles,
111
- "--slider-thumb-transform": ctx.isVertical ? "translateY(50%)" : ctx.isRtl ? "translateX(50%)" : "translateX(-50%)",
160
+ "--slider-thumb-transform": isVertical ? "translateY(50%)" : isRtl ? "translateX(50%)" : "translateX(-50%)",
112
161
  "--slider-range-start": range.start,
113
162
  "--slider-range-end": range.end
114
163
  };
115
164
  }
116
- function getMarkerStyle(ctx, value) {
165
+ function getMarkerStyle(params, value) {
166
+ const { computed } = params;
167
+ const isHorizontal = computed("isHorizontal");
168
+ const isRtl = computed("isRtl");
117
169
  return {
118
- // @ts-expect-error
119
- visibility: getVisibility(ctx),
170
+ visibility: getVisibility(params),
120
171
  position: "absolute",
121
172
  pointerEvents: "none",
122
- // @ts-expect-error
123
- [ctx.isHorizontal ? "insetInlineStart" : "bottom"]: getThumbOffset({ ...ctx, value }),
173
+ [isHorizontal ? "insetInlineStart" : "bottom"]: getThumbOffset(params, value),
124
174
  translate: "var(--tx) var(--ty)",
125
- "--tx": ctx.isHorizontal ? ctx.isRtl ? "50%" : "-50%" : "0%",
126
- "--ty": !ctx.isHorizontal ? "50%" : "0%"
175
+ "--tx": isHorizontal ? isRtl ? "50%" : "-50%" : "0%",
176
+ "--ty": !isHorizontal ? "50%" : "0%"
127
177
  };
128
178
  }
129
179
  function getMarkerGroupStyle() {
@@ -134,119 +184,72 @@ function getMarkerGroupStyle() {
134
184
  position: "relative"
135
185
  };
136
186
  }
137
- var styleGetterFns = {
138
- getRootStyle,
139
- getControlStyle,
140
- getThumbStyle,
141
- getRangeStyle,
142
- getMarkerStyle,
143
- getMarkerGroupStyle
144
- };
145
-
146
- // src/slider.dom.ts
147
- var dom = domQuery.createScope({
148
- ...styleGetterFns,
149
- getRootId: (ctx) => ctx.ids?.root ?? `slider:${ctx.id}`,
150
- getThumbId: (ctx, index) => ctx.ids?.thumb?.(index) ?? `slider:${ctx.id}:thumb:${index}`,
151
- getHiddenInputId: (ctx, index) => ctx.ids?.hiddenInput?.(index) ?? `slider:${ctx.id}:input:${index}`,
152
- getControlId: (ctx) => ctx.ids?.control ?? `slider:${ctx.id}:control`,
153
- getTrackId: (ctx) => ctx.ids?.track ?? `slider:${ctx.id}:track`,
154
- getRangeId: (ctx) => ctx.ids?.range ?? `slider:${ctx.id}:range`,
155
- getLabelId: (ctx) => ctx.ids?.label ?? `slider:${ctx.id}:label`,
156
- getValueTextId: (ctx) => ctx.ids?.valueText ?? `slider:${ctx.id}:value-text`,
157
- getMarkerId: (ctx, value) => ctx.ids?.marker?.(value) ?? `slider:${ctx.id}:marker:${value}`,
158
- getRootEl: (ctx) => dom.getById(ctx, dom.getRootId(ctx)),
159
- getThumbEl: (ctx, index) => dom.getById(ctx, dom.getThumbId(ctx, index)),
160
- getHiddenInputEl: (ctx, index) => dom.getById(ctx, dom.getHiddenInputId(ctx, index)),
161
- getControlEl: (ctx) => dom.getById(ctx, dom.getControlId(ctx)),
162
- getElements: (ctx) => domQuery.queryAll(dom.getControlEl(ctx), "[role=slider]"),
163
- getFirstEl: (ctx) => dom.getElements(ctx)[0],
164
- getRangeEl: (ctx) => dom.getById(ctx, dom.getRangeId(ctx)),
165
- getValueFromPoint(ctx, point) {
166
- const controlEl = dom.getControlEl(ctx);
167
- if (!controlEl) return;
168
- const relativePoint = domQuery.getRelativePoint(point, controlEl);
169
- const percent = relativePoint.getPercentValue({
170
- orientation: ctx.orientation,
171
- dir: ctx.dir,
172
- inverted: { y: true }
173
- });
174
- return utils.getPercentValue(percent, ctx.min, ctx.max, ctx.step);
175
- },
176
- dispatchChangeEvent(ctx) {
177
- const valueArray = Array.from(ctx.value);
178
- valueArray.forEach((value, index) => {
179
- const inputEl = dom.getHiddenInputEl(ctx, index);
180
- if (!inputEl) return;
181
- domQuery.dispatchInputValueEvent(inputEl, { value });
182
- });
183
- }
184
- });
185
- function normalizeValues(ctx, nextValues) {
186
- return nextValues.map((value, index, values) => {
187
- return constrainValue({ ...ctx, value: values }, value, index);
187
+ function normalizeValues(params, nextValues) {
188
+ return nextValues.map((value, index) => {
189
+ return constrainValue(params, value, index);
188
190
  });
189
191
  }
190
- function getRangeAtIndex(ctx, index) {
191
- return utils.getValueRanges(ctx.value, ctx.min, ctx.max, ctx.minStepsBetweenThumbs)[index];
192
+ function getRangeAtIndex(params, index) {
193
+ const { context, prop } = params;
194
+ return utils.getValueRanges(context.get("value"), prop("min"), prop("max"), prop("minStepsBetweenThumbs"))[index];
192
195
  }
193
- function constrainValue(ctx, value, index) {
194
- const range = getRangeAtIndex(ctx, index);
195
- const snapValue = utils.snapValueToStep(value, ctx.min, ctx.max, ctx.step);
196
+ function constrainValue(params, value, index) {
197
+ const { prop } = params;
198
+ const range = getRangeAtIndex(params, index);
199
+ const snapValue = utils.snapValueToStep(value, prop("min"), prop("max"), prop("step"));
196
200
  return utils.clampValue(snapValue, range.min, range.max);
197
201
  }
198
- function decrement(ctx, index, step) {
199
- const idx = index ?? ctx.focusedIndex;
200
- const range = getRangeAtIndex(ctx, idx);
202
+ function decrement(params, index, step) {
203
+ const { context, prop } = params;
204
+ const idx = index ?? context.get("focusedIndex");
205
+ const range = getRangeAtIndex(params, idx);
201
206
  const nextValues = utils.getPreviousStepValue(idx, {
202
207
  ...range,
203
- step: step ?? ctx.step,
204
- values: ctx.value
208
+ step: step ?? prop("step"),
209
+ values: context.get("value")
205
210
  });
206
211
  nextValues[idx] = utils.clampValue(nextValues[idx], range.min, range.max);
207
212
  return nextValues;
208
213
  }
209
- function increment(ctx, index, step) {
210
- const idx = index ?? ctx.focusedIndex;
211
- const range = getRangeAtIndex(ctx, idx);
214
+ function increment(params, index, step) {
215
+ const { context, prop } = params;
216
+ const idx = index ?? context.get("focusedIndex");
217
+ const range = getRangeAtIndex(params, idx);
212
218
  const nextValues = utils.getNextStepValue(idx, {
213
219
  ...range,
214
- step: step ?? ctx.step,
215
- values: ctx.value
220
+ step: step ?? prop("step"),
221
+ values: context.get("value")
216
222
  });
217
223
  nextValues[idx] = utils.clampValue(nextValues[idx], range.min, range.max);
218
224
  return nextValues;
219
225
  }
220
- function getClosestIndex(ctx, pointValue) {
221
- return utils.getClosestValueIndex(ctx.value, pointValue);
222
- }
223
- function assignArray(current, next) {
224
- for (let i = 0; i < next.length; i++) {
225
- const value = next[i];
226
- current[i] = value;
227
- }
226
+ function getClosestIndex(params, pointValue) {
227
+ const { context } = params;
228
+ return utils.getClosestValueIndex(context.get("value"), pointValue);
228
229
  }
229
230
 
230
231
  // src/slider.connect.ts
231
- function connect(state, send, normalize) {
232
- const ariaLabel = state.context["aria-label"];
233
- const ariaLabelledBy = state.context["aria-labelledby"];
234
- const sliderValue = state.context.value;
232
+ function connect(service, normalize) {
233
+ const { state, send, context, prop, computed, scope } = service;
234
+ const ariaLabel = prop("aria-label");
235
+ const ariaLabelledBy = prop("aria-labelledby");
236
+ const sliderValue = context.get("value");
237
+ const focusedIndex = context.get("focusedIndex");
235
238
  const focused = state.matches("focus");
236
239
  const dragging = state.matches("dragging");
237
- const disabled = state.context.isDisabled;
238
- const invalid = state.context.invalid;
239
- const interactive = state.context.isInteractive;
240
- const isHorizontal = state.context.orientation === "horizontal";
241
- const isVertical = state.context.orientation === "vertical";
240
+ const disabled = computed("isDisabled");
241
+ const invalid = prop("invalid");
242
+ const interactive = computed("isInteractive");
243
+ const isHorizontal = prop("orientation") === "horizontal";
244
+ const isVertical = prop("orientation") === "vertical";
242
245
  function getValuePercentFn(value) {
243
- return utils.getValuePercent(value, state.context.min, state.context.max);
246
+ return utils.getValuePercent(value, prop("min"), prop("max"));
244
247
  }
245
248
  function getPercentValueFn(percent) {
246
- return utils.getPercentValue(percent, state.context.min, state.context.max, state.context.step);
249
+ return utils.getPercentValue(percent, prop("min"), prop("max"), prop("step"));
247
250
  }
248
251
  return {
249
- value: state.context.value,
252
+ value: sliderValue,
250
253
  dragging,
251
254
  focused,
252
255
  setValue(value) {
@@ -268,10 +271,10 @@ function connect(state, send, normalize) {
268
271
  send({ type: "SET_VALUE", index, value });
269
272
  },
270
273
  getThumbMin(index) {
271
- return getRangeAtIndex(state.context, index).min;
274
+ return getRangeAtIndex(service, index).min;
272
275
  },
273
276
  getThumbMax(index) {
274
- return getRangeAtIndex(state.context, index).max;
277
+ return getRangeAtIndex(service, index).max;
275
278
  },
276
279
  increment(index) {
277
280
  send({ type: "INCREMENT", index });
@@ -286,18 +289,18 @@ function connect(state, send, normalize) {
286
289
  getLabelProps() {
287
290
  return normalize.label({
288
291
  ...parts.label.attrs,
289
- dir: state.context.dir,
292
+ dir: prop("dir"),
290
293
  "data-disabled": domQuery.dataAttr(disabled),
291
- "data-orientation": state.context.orientation,
294
+ "data-orientation": prop("orientation"),
292
295
  "data-invalid": domQuery.dataAttr(invalid),
293
296
  "data-dragging": domQuery.dataAttr(dragging),
294
297
  "data-focus": domQuery.dataAttr(focused),
295
- id: dom.getLabelId(state.context),
296
- htmlFor: dom.getHiddenInputId(state.context, 0),
298
+ id: getLabelId(scope),
299
+ htmlFor: getHiddenInputId(scope, 0),
297
300
  onClick(event) {
298
301
  if (!interactive) return;
299
302
  event.preventDefault();
300
- dom.getFirstEl(state.context)?.focus();
303
+ getFirstEl(scope)?.focus();
301
304
  },
302
305
  style: {
303
306
  userSelect: "none",
@@ -309,35 +312,35 @@ function connect(state, send, normalize) {
309
312
  return normalize.element({
310
313
  ...parts.root.attrs,
311
314
  "data-disabled": domQuery.dataAttr(disabled),
312
- "data-orientation": state.context.orientation,
315
+ "data-orientation": prop("orientation"),
313
316
  "data-dragging": domQuery.dataAttr(dragging),
314
317
  "data-invalid": domQuery.dataAttr(invalid),
315
318
  "data-focus": domQuery.dataAttr(focused),
316
- id: dom.getRootId(state.context),
317
- dir: state.context.dir,
318
- style: dom.getRootStyle(state.context)
319
+ id: getRootId(scope),
320
+ dir: prop("dir"),
321
+ style: getRootStyle(service)
319
322
  });
320
323
  },
321
324
  getValueTextProps() {
322
325
  return normalize.element({
323
326
  ...parts.valueText.attrs,
324
- dir: state.context.dir,
327
+ dir: prop("dir"),
325
328
  "data-disabled": domQuery.dataAttr(disabled),
326
- "data-orientation": state.context.orientation,
329
+ "data-orientation": prop("orientation"),
327
330
  "data-invalid": domQuery.dataAttr(invalid),
328
331
  "data-focus": domQuery.dataAttr(focused),
329
- id: dom.getValueTextId(state.context)
332
+ id: getValueTextId(scope)
330
333
  });
331
334
  },
332
335
  getTrackProps() {
333
336
  return normalize.element({
334
337
  ...parts.track.attrs,
335
- dir: state.context.dir,
336
- id: dom.getTrackId(state.context),
338
+ dir: prop("dir"),
339
+ id: getTrackId(scope),
337
340
  "data-disabled": domQuery.dataAttr(disabled),
338
341
  "data-invalid": domQuery.dataAttr(invalid),
339
342
  "data-dragging": domQuery.dataAttr(dragging),
340
- "data-orientation": state.context.orientation,
343
+ "data-orientation": prop("orientation"),
341
344
  "data-focus": domQuery.dataAttr(focused),
342
345
  style: { position: "relative" }
343
346
  });
@@ -345,32 +348,32 @@ function connect(state, send, normalize) {
345
348
  getThumbProps(props2) {
346
349
  const { index = 0, name } = props2;
347
350
  const value = sliderValue[index];
348
- const range = getRangeAtIndex(state.context, index);
349
- const valueText = state.context.getAriaValueText?.({ value, index });
351
+ const range = getRangeAtIndex(service, index);
352
+ const valueText = prop("getAriaValueText")?.({ value, index });
350
353
  const _ariaLabel = Array.isArray(ariaLabel) ? ariaLabel[index] : ariaLabel;
351
354
  const _ariaLabelledBy = Array.isArray(ariaLabelledBy) ? ariaLabelledBy[index] : ariaLabelledBy;
352
355
  return normalize.element({
353
356
  ...parts.thumb.attrs,
354
- dir: state.context.dir,
357
+ dir: prop("dir"),
355
358
  "data-index": index,
356
359
  "data-name": name,
357
- id: dom.getThumbId(state.context, index),
360
+ id: getThumbId(scope, index),
358
361
  "data-disabled": domQuery.dataAttr(disabled),
359
- "data-orientation": state.context.orientation,
360
- "data-focus": domQuery.dataAttr(focused && state.context.focusedIndex === index),
361
- "data-dragging": domQuery.dataAttr(dragging && state.context.focusedIndex === index),
362
+ "data-orientation": prop("orientation"),
363
+ "data-focus": domQuery.dataAttr(focused && focusedIndex === index),
364
+ "data-dragging": domQuery.dataAttr(dragging && focusedIndex === index),
362
365
  draggable: false,
363
366
  "aria-disabled": domQuery.ariaAttr(disabled),
364
367
  "aria-label": _ariaLabel,
365
- "aria-labelledby": _ariaLabelledBy ?? dom.getLabelId(state.context),
366
- "aria-orientation": state.context.orientation,
368
+ "aria-labelledby": _ariaLabelledBy ?? getLabelId(scope),
369
+ "aria-orientation": prop("orientation"),
367
370
  "aria-valuemax": range.max,
368
371
  "aria-valuemin": range.min,
369
372
  "aria-valuenow": sliderValue[index],
370
373
  "aria-valuetext": valueText,
371
374
  role: "slider",
372
375
  tabIndex: disabled ? void 0 : 0,
373
- style: dom.getThumbStyle(state.context, index),
376
+ style: getThumbStyle(service, index),
374
377
  onPointerDown(event) {
375
378
  if (!interactive) return;
376
379
  send({ type: "THUMB_POINTER_DOWN", index });
@@ -378,7 +381,7 @@ function connect(state, send, normalize) {
378
381
  },
379
382
  onBlur() {
380
383
  if (!interactive) return;
381
- send("BLUR");
384
+ send({ type: "BLUR" });
382
385
  },
383
386
  onFocus() {
384
387
  if (!interactive) return;
@@ -387,7 +390,7 @@ function connect(state, send, normalize) {
387
390
  onKeyDown(event) {
388
391
  if (event.defaultPrevented) return;
389
392
  if (!interactive) return;
390
- const step = domQuery.getEventStep(event) * state.context.step;
393
+ const step = domQuery.getEventStep(event) * prop("step");
391
394
  const keyMap = {
392
395
  ArrowUp() {
393
396
  if (isHorizontal) return;
@@ -412,13 +415,16 @@ function connect(state, send, normalize) {
412
415
  send({ type: "ARROW_DEC", step, src: "PageDown" });
413
416
  },
414
417
  Home() {
415
- send("HOME");
418
+ send({ type: "HOME" });
416
419
  },
417
420
  End() {
418
- send("END");
421
+ send({ type: "END" });
419
422
  }
420
423
  };
421
- const key = domQuery.getEventKey(event, state.context);
424
+ const key = domQuery.getEventKey(event, {
425
+ dir: prop("dir"),
426
+ orientation: prop("orientation")
427
+ });
422
428
  const exec = keyMap[key];
423
429
  if (exec) {
424
430
  exec(event);
@@ -431,38 +437,38 @@ function connect(state, send, normalize) {
431
437
  getHiddenInputProps(props2) {
432
438
  const { index = 0, name } = props2;
433
439
  return normalize.input({
434
- name: name ?? (state.context.name ? state.context.name + (state.context.value.length > 1 ? "[]" : "") : void 0),
435
- form: state.context.form,
440
+ name: name ?? (prop("name") ? prop("name") + (sliderValue.length > 1 ? "[]" : "") : void 0),
441
+ form: prop("form"),
436
442
  type: "text",
437
443
  hidden: true,
438
- defaultValue: state.context.value[index],
439
- id: dom.getHiddenInputId(state.context, index)
444
+ defaultValue: sliderValue[index],
445
+ id: getHiddenInputId(scope, index)
440
446
  });
441
447
  },
442
448
  getRangeProps() {
443
449
  return normalize.element({
444
- id: dom.getRangeId(state.context),
450
+ id: getRangeId(scope),
445
451
  ...parts.range.attrs,
446
- dir: state.context.dir,
452
+ dir: prop("dir"),
447
453
  "data-dragging": domQuery.dataAttr(dragging),
448
454
  "data-focus": domQuery.dataAttr(focused),
449
455
  "data-invalid": domQuery.dataAttr(invalid),
450
456
  "data-disabled": domQuery.dataAttr(disabled),
451
- "data-orientation": state.context.orientation,
452
- style: dom.getRangeStyle(state.context)
457
+ "data-orientation": prop("orientation"),
458
+ style: getRangeStyle(service)
453
459
  });
454
460
  },
455
461
  getControlProps() {
456
462
  return normalize.element({
457
463
  ...parts.control.attrs,
458
- dir: state.context.dir,
459
- id: dom.getControlId(state.context),
464
+ dir: prop("dir"),
465
+ id: getControlId(scope),
460
466
  "data-dragging": domQuery.dataAttr(dragging),
461
467
  "data-disabled": domQuery.dataAttr(disabled),
462
- "data-orientation": state.context.orientation,
468
+ "data-orientation": prop("orientation"),
463
469
  "data-invalid": domQuery.dataAttr(invalid),
464
470
  "data-focus": domQuery.dataAttr(focused),
465
- style: dom.getControlStyle(),
471
+ style: getControlStyle(),
466
472
  onPointerDown(event) {
467
473
  if (!interactive) return;
468
474
  if (!domQuery.isLeftClick(event)) return;
@@ -478,30 +484,28 @@ function connect(state, send, normalize) {
478
484
  return normalize.element({
479
485
  ...parts.markerGroup.attrs,
480
486
  role: "presentation",
481
- dir: state.context.dir,
487
+ dir: prop("dir"),
482
488
  "aria-hidden": true,
483
- "data-orientation": state.context.orientation,
484
- style: dom.getMarkerGroupStyle()
489
+ "data-orientation": prop("orientation"),
490
+ style: getMarkerGroupStyle()
485
491
  });
486
492
  },
487
493
  getMarkerProps(props2) {
488
- const style = dom.getMarkerStyle(state.context, props2.value);
494
+ const style = getMarkerStyle(service, props2.value);
489
495
  let markerState;
490
- const first = state.context.value[0];
491
- const last = state.context.value[state.context.value.length - 1];
492
- if (props2.value < first) {
496
+ if (props2.value < utils.first(sliderValue)) {
493
497
  markerState = "under-value";
494
- } else if (props2.value > last) {
498
+ } else if (props2.value > utils.last(sliderValue)) {
495
499
  markerState = "over-value";
496
500
  } else {
497
501
  markerState = "at-value";
498
502
  }
499
503
  return normalize.element({
500
504
  ...parts.marker.attrs,
501
- id: dom.getMarkerId(state.context, props2.value),
505
+ id: getMarkerId(scope, props2.value),
502
506
  role: "presentation",
503
- dir: state.context.dir,
504
- "data-orientation": state.context.orientation,
507
+ dir: prop("dir"),
508
+ "data-orientation": prop("orientation"),
505
509
  "data-value": props2.value,
506
510
  "data-disabled": domQuery.dataAttr(disabled),
507
511
  "data-state": markerState,
@@ -510,15 +514,15 @@ function connect(state, send, normalize) {
510
514
  },
511
515
  getDraggingIndicatorProps(props2) {
512
516
  const { index = 0 } = props2;
513
- const isDragging = index === state.context.focusedIndex && dragging;
517
+ const isDragging = index === focusedIndex && dragging;
514
518
  return normalize.element({
515
519
  ...parts.draggingIndicator.attrs,
516
520
  role: "presentation",
517
- dir: state.context.dir,
521
+ dir: prop("dir"),
518
522
  hidden: !isDragging,
519
- "data-orientation": state.context.orientation,
523
+ "data-orientation": prop("orientation"),
520
524
  "data-state": isDragging ? "open" : "closed",
521
- style: dom.getThumbStyle(state.context, index)
525
+ style: getThumbStyle(service, index)
522
526
  });
523
527
  }
524
528
  };
@@ -526,260 +530,260 @@ function connect(state, send, normalize) {
526
530
  var isEqualSize = (a, b) => {
527
531
  return a?.width === b?.width && a?.height === b?.height;
528
532
  };
529
- function machine(userContext) {
530
- const ctx = utils.compact(userContext);
531
- return core.createMachine(
532
- {
533
- id: "slider",
534
- initial: "idle",
535
- context: {
536
- thumbSize: null,
537
- thumbAlignment: "contain",
538
- min: 0,
539
- max: 100,
540
- step: 1,
541
- value: [0],
542
- origin: "start",
543
- orientation: "horizontal",
544
- dir: "ltr",
545
- minStepsBetweenThumbs: 0,
546
- disabled: false,
547
- readOnly: false,
548
- ...ctx,
549
- focusedIndex: -1,
550
- fieldsetDisabled: false
551
- },
552
- computed: {
553
- isHorizontal: (ctx2) => ctx2.orientation === "horizontal",
554
- isVertical: (ctx2) => ctx2.orientation === "vertical",
555
- isRtl: (ctx2) => ctx2.orientation === "horizontal" && ctx2.dir === "rtl",
556
- isDisabled: (ctx2) => !!ctx2.disabled || ctx2.fieldsetDisabled,
557
- isInteractive: (ctx2) => !(ctx2.readOnly || ctx2.isDisabled),
558
- hasMeasuredThumbSize: (ctx2) => ctx2.thumbSize != null,
559
- valuePercent(ctx2) {
560
- return ctx2.value.map((value) => 100 * utils.getValuePercent(value, ctx2.min, ctx2.max));
533
+ var machine = core.createMachine({
534
+ props({ props: props2 }) {
535
+ return {
536
+ dir: "ltr",
537
+ thumbAlignment: "contain",
538
+ min: 0,
539
+ max: 100,
540
+ step: 1,
541
+ defaultValue: [0],
542
+ origin: "start",
543
+ orientation: "horizontal",
544
+ minStepsBetweenThumbs: 0,
545
+ ...utils.compact(props2)
546
+ };
547
+ },
548
+ initialState() {
549
+ return "idle";
550
+ },
551
+ context({ prop, bindable, getContext, scope }) {
552
+ return {
553
+ thumbSize: bindable(() => ({
554
+ defaultValue: prop("thumbSize") || null
555
+ })),
556
+ value: bindable(() => ({
557
+ defaultValue: prop("defaultValue"),
558
+ value: prop("value"),
559
+ onChange(value) {
560
+ prop("onValueChange")?.({ value });
561
+ dispatchChangeEvent(scope, value);
561
562
  }
562
- },
563
- watch: {
564
- value: ["syncInputElements"]
565
- },
566
- entry: ["coarseValue"],
567
- activities: ["trackFormControlState", "trackThumbsSize"],
568
- on: {
569
- SET_VALUE: [
570
- {
571
- guard: "hasIndex",
572
- actions: "setValueAtIndex"
573
- },
574
- { actions: "setValue" }
575
- ],
576
- INCREMENT: {
577
- actions: "incrementThumbAtIndex"
578
- },
579
- DECREMENT: {
580
- actions: "decrementThumbAtIndex"
563
+ })),
564
+ focusedIndex: bindable(() => ({
565
+ defaultValue: -1,
566
+ onChange(value) {
567
+ const ctx = getContext();
568
+ prop("onFocusChange")?.({ focusedIndex: value, value: ctx.get("value") });
581
569
  }
570
+ })),
571
+ fieldsetDisabled: bindable(() => ({
572
+ defaultValue: false
573
+ }))
574
+ };
575
+ },
576
+ computed: {
577
+ isHorizontal: ({ prop }) => prop("orientation") === "horizontal",
578
+ isVertical: ({ prop }) => prop("orientation") === "vertical",
579
+ isRtl: ({ prop }) => prop("orientation") === "horizontal" && prop("dir") === "rtl",
580
+ isDisabled: ({ context, prop }) => !!prop("disabled") || context.get("fieldsetDisabled"),
581
+ isInteractive: ({ prop, computed }) => !(prop("readOnly") || computed("isDisabled")),
582
+ hasMeasuredThumbSize: ({ context }) => context.get("thumbSize") != null,
583
+ valuePercent({ context, prop }) {
584
+ return context.get("value").map((value) => 100 * utils.getValuePercent(value, prop("min"), prop("max")));
585
+ }
586
+ },
587
+ watch({ track, action, context }) {
588
+ track([() => context.get("value").join(",")], () => {
589
+ action(["syncInputElements"]);
590
+ });
591
+ },
592
+ entry: ["coarseValue"],
593
+ effects: ["trackFormControlState", "trackThumbsSize"],
594
+ on: {
595
+ SET_VALUE: [
596
+ {
597
+ guard: "hasIndex",
598
+ actions: ["setValueAtIndex"]
582
599
  },
583
- states: {
584
- idle: {
585
- on: {
586
- POINTER_DOWN: {
587
- target: "dragging",
588
- actions: ["setClosestThumbIndex", "setPointerValue", "focusActiveThumb"]
589
- },
590
- FOCUS: {
591
- target: "focus",
592
- actions: "setFocusedIndex"
593
- },
594
- THUMB_POINTER_DOWN: {
595
- target: "dragging",
596
- actions: ["setFocusedIndex", "focusActiveThumb"]
597
- }
598
- }
599
- },
600
- focus: {
601
- entry: "focusActiveThumb",
602
- on: {
603
- POINTER_DOWN: {
604
- target: "dragging",
605
- actions: ["setClosestThumbIndex", "setPointerValue", "focusActiveThumb"]
606
- },
607
- THUMB_POINTER_DOWN: {
608
- target: "dragging",
609
- actions: ["setFocusedIndex", "focusActiveThumb"]
610
- },
611
- ARROW_DEC: {
612
- actions: ["decrementThumbAtIndex", "invokeOnChangeEnd"]
613
- },
614
- ARROW_INC: {
615
- actions: ["incrementThumbAtIndex", "invokeOnChangeEnd"]
616
- },
617
- HOME: {
618
- actions: ["setFocusedThumbToMin", "invokeOnChangeEnd"]
619
- },
620
- END: {
621
- actions: ["setFocusedThumbToMax", "invokeOnChangeEnd"]
622
- },
623
- BLUR: {
624
- target: "idle",
625
- actions: "clearFocusedIndex"
626
- }
627
- }
628
- },
629
- dragging: {
630
- entry: "focusActiveThumb",
631
- activities: "trackPointerMove",
632
- on: {
633
- POINTER_UP: {
634
- target: "focus",
635
- actions: "invokeOnChangeEnd"
636
- },
637
- POINTER_MOVE: {
638
- actions: "setPointerValue"
639
- }
640
- }
641
- }
600
+ {
601
+ actions: ["setValue"]
642
602
  }
603
+ ],
604
+ INCREMENT: {
605
+ actions: ["incrementThumbAtIndex"]
643
606
  },
644
- {
645
- guards: {
646
- hasIndex: (_ctx, evt) => evt.index != null
647
- },
648
- activities: {
649
- trackFormControlState(ctx2, _evt, { initialContext }) {
650
- return domQuery.trackFormControl(dom.getRootEl(ctx2), {
651
- onFieldsetDisabledChange(disabled) {
652
- ctx2.fieldsetDisabled = disabled;
653
- },
654
- onFormReset() {
655
- set.value(ctx2, initialContext.value);
656
- }
657
- });
607
+ DECREMENT: {
608
+ actions: ["decrementThumbAtIndex"]
609
+ }
610
+ },
611
+ states: {
612
+ idle: {
613
+ on: {
614
+ POINTER_DOWN: {
615
+ target: "dragging",
616
+ actions: ["setClosestThumbIndex", "setPointerValue", "focusActiveThumb"]
658
617
  },
659
- trackPointerMove(ctx2, _evt, { send }) {
660
- return domQuery.trackPointerMove(dom.getDoc(ctx2), {
661
- onPointerMove(info) {
662
- send({ type: "POINTER_MOVE", point: info.point });
663
- },
664
- onPointerUp() {
665
- send("POINTER_UP");
666
- }
667
- });
618
+ FOCUS: {
619
+ target: "focus",
620
+ actions: ["setFocusedIndex"]
668
621
  },
669
- trackThumbsSize(ctx2) {
670
- if (ctx2.thumbAlignment !== "contain" || ctx2.thumbSize) return;
671
- return elementSize.trackElementsSize({
672
- getNodes: () => dom.getElements(ctx2),
673
- observeMutation: true,
674
- callback(size) {
675
- if (!size || isEqualSize(ctx2.thumbSize, size)) return;
676
- ctx2.thumbSize = size;
677
- }
678
- });
622
+ THUMB_POINTER_DOWN: {
623
+ target: "dragging",
624
+ actions: ["setFocusedIndex", "focusActiveThumb"]
679
625
  }
680
- },
681
- actions: {
682
- syncInputElements(ctx2) {
683
- ctx2.value.forEach((value, index) => {
684
- const inputEl = dom.getHiddenInputEl(ctx2, index);
685
- dom.setValue(inputEl, value);
686
- });
687
- },
688
- invokeOnChangeEnd(ctx2) {
689
- invoke.valueChangeEnd(ctx2);
690
- },
691
- setClosestThumbIndex(ctx2, evt) {
692
- const pointValue = dom.getValueFromPoint(ctx2, evt.point);
693
- if (pointValue == null) return;
694
- const focusedIndex = getClosestIndex(ctx2, pointValue);
695
- set.focusedIndex(ctx2, focusedIndex);
696
- },
697
- setFocusedIndex(ctx2, evt) {
698
- set.focusedIndex(ctx2, evt.index);
699
- },
700
- clearFocusedIndex(ctx2) {
701
- set.focusedIndex(ctx2, -1);
702
- },
703
- setPointerValue(ctx2, evt) {
704
- const pointerValue = dom.getValueFromPoint(ctx2, evt.point);
705
- if (pointerValue == null) return;
706
- const value = constrainValue(ctx2, pointerValue, ctx2.focusedIndex);
707
- set.valueAtIndex(ctx2, ctx2.focusedIndex, value);
708
- },
709
- focusActiveThumb(ctx2) {
710
- domQuery.raf(() => {
711
- const thumbEl = dom.getThumbEl(ctx2, ctx2.focusedIndex);
712
- thumbEl?.focus({ preventScroll: true });
713
- });
626
+ }
627
+ },
628
+ focus: {
629
+ entry: ["focusActiveThumb"],
630
+ on: {
631
+ POINTER_DOWN: {
632
+ target: "dragging",
633
+ actions: ["setClosestThumbIndex", "setPointerValue", "focusActiveThumb"]
714
634
  },
715
- decrementThumbAtIndex(ctx2, evt) {
716
- const value = decrement(ctx2, evt.index, evt.step);
717
- set.value(ctx2, value);
635
+ THUMB_POINTER_DOWN: {
636
+ target: "dragging",
637
+ actions: ["setFocusedIndex", "focusActiveThumb"]
718
638
  },
719
- incrementThumbAtIndex(ctx2, evt) {
720
- const value = increment(ctx2, evt.index, evt.step);
721
- set.value(ctx2, value);
639
+ ARROW_DEC: {
640
+ actions: ["decrementThumbAtIndex", "invokeOnChangeEnd"]
722
641
  },
723
- setFocusedThumbToMin(ctx2) {
724
- const { min } = getRangeAtIndex(ctx2, ctx2.focusedIndex);
725
- set.valueAtIndex(ctx2, ctx2.focusedIndex, min);
642
+ ARROW_INC: {
643
+ actions: ["incrementThumbAtIndex", "invokeOnChangeEnd"]
726
644
  },
727
- setFocusedThumbToMax(ctx2) {
728
- const { max } = getRangeAtIndex(ctx2, ctx2.focusedIndex);
729
- set.valueAtIndex(ctx2, ctx2.focusedIndex, max);
645
+ HOME: {
646
+ actions: ["setFocusedThumbToMin", "invokeOnChangeEnd"]
730
647
  },
731
- coarseValue(ctx2) {
732
- const value = normalizeValues(ctx2, ctx2.value);
733
- set.value(ctx2, value);
648
+ END: {
649
+ actions: ["setFocusedThumbToMax", "invokeOnChangeEnd"]
734
650
  },
735
- setValueAtIndex(ctx2, evt) {
736
- const value = constrainValue(ctx2, evt.value, evt.index);
737
- set.valueAtIndex(ctx2, evt.index, value);
651
+ BLUR: {
652
+ target: "idle",
653
+ actions: ["clearFocusedIndex"]
654
+ }
655
+ }
656
+ },
657
+ dragging: {
658
+ entry: ["focusActiveThumb"],
659
+ effects: ["trackPointerMove"],
660
+ on: {
661
+ POINTER_UP: {
662
+ target: "focus",
663
+ actions: ["invokeOnChangeEnd"]
738
664
  },
739
- setValue(ctx2, evt) {
740
- const value = normalizeValues(ctx2, evt.value);
741
- set.value(ctx2, value);
665
+ POINTER_MOVE: {
666
+ actions: ["setPointerValue"]
742
667
  }
743
668
  }
744
669
  }
745
- );
746
- }
747
- var invoke = {
748
- valueChange(ctx) {
749
- ctx.onValueChange?.({
750
- value: Array.from(ctx.value)
751
- });
752
- dom.dispatchChangeEvent(ctx);
753
- },
754
- valueChangeEnd(ctx) {
755
- ctx.onValueChangeEnd?.({
756
- value: Array.from(ctx.value)
757
- });
758
- },
759
- focusChange(ctx) {
760
- ctx.onFocusChange?.({
761
- value: Array.from(ctx.value),
762
- focusedIndex: ctx.focusedIndex
763
- });
764
- }
765
- };
766
- var set = {
767
- valueAtIndex: (ctx, index, value) => {
768
- if (utils.isEqual(ctx.value[index], value)) return;
769
- ctx.value[index] = value;
770
- invoke.valueChange(ctx);
771
- },
772
- value: (ctx, value) => {
773
- if (utils.isEqual(ctx.value, value)) return;
774
- assignArray(ctx.value, value);
775
- invoke.valueChange(ctx);
776
670
  },
777
- focusedIndex: (ctx, index) => {
778
- if (utils.isEqual(ctx.focusedIndex, index)) return;
779
- ctx.focusedIndex = index;
780
- invoke.focusChange(ctx);
671
+ implementations: {
672
+ guards: {
673
+ hasIndex: ({ event }) => event.index != null
674
+ },
675
+ effects: {
676
+ trackFormControlState({ context, scope }) {
677
+ return domQuery.trackFormControl(getRootEl(scope), {
678
+ onFieldsetDisabledChange(disabled) {
679
+ context.set("fieldsetDisabled", disabled);
680
+ },
681
+ onFormReset() {
682
+ context.set("value", context.initial("value"));
683
+ }
684
+ });
685
+ },
686
+ trackPointerMove({ scope, send }) {
687
+ return domQuery.trackPointerMove(scope.getDoc(), {
688
+ onPointerMove(info) {
689
+ send({ type: "POINTER_MOVE", point: info.point });
690
+ },
691
+ onPointerUp() {
692
+ send({ type: "POINTER_UP" });
693
+ }
694
+ });
695
+ },
696
+ trackThumbsSize({ context, scope, prop }) {
697
+ if (prop("thumbAlignment") !== "contain" || context.get("thumbSize")) return;
698
+ return elementSize.trackElementsSize({
699
+ getNodes: () => getElements(scope),
700
+ observeMutation: true,
701
+ callback(size) {
702
+ if (!size || isEqualSize(context.get("thumbSize"), size)) return;
703
+ context.set("thumbSize", size);
704
+ }
705
+ });
706
+ }
707
+ },
708
+ actions: {
709
+ syncInputElements({ context, scope }) {
710
+ context.get("value").forEach((value, index) => {
711
+ const inputEl = getHiddenInputEl(scope, index);
712
+ domQuery.setElementValue(inputEl, value.toString());
713
+ });
714
+ },
715
+ invokeOnChangeEnd({ prop, context }) {
716
+ prop("onValueChangeEnd")?.({ value: context.get("value") });
717
+ },
718
+ setClosestThumbIndex(params) {
719
+ const { context, event } = params;
720
+ const pointValue = getValueFromPoint(params, event.point);
721
+ if (pointValue == null) return;
722
+ const focusedIndex = getClosestIndex(params, pointValue);
723
+ context.set("focusedIndex", focusedIndex);
724
+ },
725
+ setFocusedIndex({ context, event }) {
726
+ context.set("focusedIndex", event.index);
727
+ },
728
+ clearFocusedIndex({ context }) {
729
+ context.set("focusedIndex", -1);
730
+ },
731
+ setPointerValue(params) {
732
+ queueMicrotask(() => {
733
+ const { context, event } = params;
734
+ const pointValue = getValueFromPoint(params, event.point);
735
+ if (pointValue == null) return;
736
+ const focusedIndex = context.get("focusedIndex");
737
+ const value = constrainValue(params, pointValue, focusedIndex);
738
+ context.set("value", (prev) => utils.setValueAtIndex(prev, focusedIndex, value));
739
+ });
740
+ },
741
+ focusActiveThumb({ scope, context }) {
742
+ domQuery.raf(() => {
743
+ const thumbEl = getThumbEl(scope, context.get("focusedIndex"));
744
+ thumbEl?.focus({ preventScroll: true });
745
+ });
746
+ },
747
+ decrementThumbAtIndex(params) {
748
+ const { context, event } = params;
749
+ const value = decrement(params, event.index, event.step);
750
+ context.set("value", value);
751
+ },
752
+ incrementThumbAtIndex(params) {
753
+ const { context, event } = params;
754
+ const value = increment(params, event.index, event.step);
755
+ context.set("value", value);
756
+ },
757
+ setFocusedThumbToMin(params) {
758
+ const { context } = params;
759
+ const index = context.get("focusedIndex");
760
+ const { min } = getRangeAtIndex(params, index);
761
+ context.set("value", (prev) => utils.setValueAtIndex(prev, index, min));
762
+ },
763
+ setFocusedThumbToMax(params) {
764
+ const { context } = params;
765
+ const index = context.get("focusedIndex");
766
+ const { max } = getRangeAtIndex(params, index);
767
+ context.set("value", (prev) => utils.setValueAtIndex(prev, index, max));
768
+ },
769
+ coarseValue(params) {
770
+ const { context } = params;
771
+ const value = normalizeValues(params, context.get("value"));
772
+ context.set("value", value);
773
+ },
774
+ setValueAtIndex(params) {
775
+ const { context, event } = params;
776
+ const value = constrainValue(params, event.value, event.index);
777
+ context.set("value", (prev) => utils.setValueAtIndex(prev, event.index, value));
778
+ },
779
+ setValue(params) {
780
+ const { context, event } = params;
781
+ const value = normalizeValues(params, event.value);
782
+ context.set("value", value);
783
+ }
784
+ }
781
785
  }
782
- };
786
+ });
783
787
  var props = types.createProps()([
784
788
  "aria-label",
785
789
  "aria-labelledby",
@@ -805,7 +809,8 @@ var props = types.createProps()([
805
809
  "thumbAlignment",
806
810
  "thumbAlignment",
807
811
  "thumbSize",
808
- "value"
812
+ "value",
813
+ "defaultValue"
809
814
  ]);
810
815
  var splitProps = utils.createSplitProps(props);
811
816
  var thumbProps = types.createProps()(["index", "name"]);