@sit-onyx/headless 0.5.0-dev-20260112084701 → 0.5.0-dev-20260112110323

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.
@@ -60,11 +60,8 @@ export type CreateSliderOptions<TValue extends SliderValue = SliderValue> = {
60
60
  /**
61
61
  * Composable for creating an accessibility-compliant slider.
62
62
  * For supported keyboard shortcuts, see: https://www.w3.org/WAI/ARIA/apg/patterns/slider/
63
- *
64
- * * @experimental
65
- * @deprecated This component is still under active development and its API might change in patch releases.
66
63
  */
67
- export declare const _unstableCreateSlider: <TValue extends SliderValue>(options: CreateSliderOptions<TValue>) => import('../../utils/builder.js').HeadlessComposable<{
64
+ export declare const createSlider: <TValue extends SliderValue>(options: CreateSliderOptions<TValue>) => import('../../utils/builder.js').HeadlessComposable<{
68
65
  /**
69
66
  * Root slider container element
70
67
  */
@@ -469,6 +466,7 @@ export declare const _unstableCreateSlider: <TValue extends SliderValue>(options
469
466
  type: string;
470
467
  step: number;
471
468
  disabled: boolean | undefined;
469
+ ref: import('../../utils/builder.js').HeadlessElRef<HTMLElement | null> | undefined;
472
470
  }>;
473
471
  /**
474
472
  * Single Mark element inside the rail
@@ -510,5 +508,6 @@ export declare const _unstableCreateSlider: <TValue extends SliderValue>(options
510
508
  marks: import('vue').ComputedRef<SliderMark[]>;
511
509
  }, {
512
510
  updateValue: (value: number, index: number) => void;
511
+ updateValueByStep: (direction: "increase" | "decrease") => void;
513
512
  }>;
514
513
  export {};
package/dist/index.js CHANGED
@@ -976,17 +976,23 @@ const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
976
976
  ]);
977
977
  const INCREMENT_KEYS = /* @__PURE__ */ new Set(["ArrowRight", "ArrowUp", "PageUp"]);
978
978
  const DECREMENT_KEYS = /* @__PURE__ */ new Set(["ArrowLeft", "ArrowDown", "PageDown"]);
979
- const _unstableCreateSlider = createBuilder(
979
+ const createSlider = createBuilder(
980
980
  (options) => {
981
981
  const sliderRef = createElRef();
982
+ const firstThumbRef = createElRef();
983
+ const secondThumbRef = createElRef();
982
984
  const min = computed(() => toValue(options.min) ?? 0);
983
985
  const max = computed(() => toValue(options.max) ?? 100);
984
986
  const step = computed(() => toValue(options.step) ?? 1);
985
987
  const draggingThumbIndex = ref();
986
988
  watch(draggingThumbIndex, (newThumbIndex) => {
987
989
  if (newThumbIndex == void 0) return;
988
- Array.from(sliderRef.value?.querySelectorAll('[role="slider"]') ?? []).at(newThumbIndex)?.focus();
990
+ focusThumb(newThumbIndex);
989
991
  });
992
+ const focusThumb = (index) => {
993
+ if (index === 0) firstThumbRef.value?.focus();
994
+ else if (index === 1) secondThumbRef.value?.focus();
995
+ };
990
996
  const shiftStep = computed(() => {
991
997
  const shiftStep2 = toValue(options.shiftStep);
992
998
  if (shiftStep2 != void 0) return shiftStep2;
@@ -1041,6 +1047,13 @@ const _unstableCreateSlider = createBuilder(
1041
1047
  if (areArraysEqual(normalized, normalizedValue.value)) return;
1042
1048
  options.onChange?.(newValue);
1043
1049
  };
1050
+ const updateValueByStep = (direction) => {
1051
+ const index = 0;
1052
+ const stepValue = direction === "increase" ? step.value : -step.value;
1053
+ const currentValue = normalizedValue.value[index];
1054
+ updateValue(currentValue + stepValue, index);
1055
+ focusThumb(index);
1056
+ };
1044
1057
  const getValueInPercentage = computed(() => {
1045
1058
  return (value) => {
1046
1059
  const percentage = MathUtils.valueToPercent(value, min.value, max.value);
@@ -1146,6 +1159,7 @@ const _unstableCreateSlider = createBuilder(
1146
1159
  "aria-orientation": "horizontal",
1147
1160
  step: step.value,
1148
1161
  disabled: toValue(options.disabled),
1162
+ ref: data.index === 0 ? firstThumbRef : data.index === 1 ? secondThumbRef : void 0,
1149
1163
  ...toValue(options.disabled) ? void 0 : events
1150
1164
  };
1151
1165
  }),
@@ -1208,7 +1222,8 @@ const _unstableCreateSlider = createBuilder(
1208
1222
  marks
1209
1223
  },
1210
1224
  internals: {
1211
- updateValue
1225
+ updateValue,
1226
+ updateValueByStep
1212
1227
  }
1213
1228
  };
1214
1229
  }
@@ -1397,7 +1412,6 @@ export {
1397
1412
  CLOSING_KEYS,
1398
1413
  OPENING_KEYS,
1399
1414
  _unstableCreateCalendar,
1400
- _unstableCreateSlider,
1401
1415
  createBuilder,
1402
1416
  createComboBox,
1403
1417
  createElRef,
@@ -1405,6 +1419,7 @@ export {
1405
1419
  createMenuButton,
1406
1420
  createMenuItems,
1407
1421
  createNavigationMenu,
1422
+ createSlider,
1408
1423
  createTabs,
1409
1424
  createToggletip,
1410
1425
  createTooltip,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@sit-onyx/headless",
3
3
  "description": "Headless composables for Vue",
4
- "version": "0.5.0-dev-20260112084701",
4
+ "version": "0.5.0-dev-20260112110323",
5
5
  "type": "module",
6
6
  "author": "Schwarz IT KG",
7
7
  "license": "Apache-2.0",