sit-onyx 1.3.0-dev-20251028122841 → 1.3.0-dev-20251028164321

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.
@@ -356,6 +356,7 @@ const fileUpload = { "select": "Select", "clickToUpload": "Click to select", "or
356
356
  const globalFAB = { "label": "Global actions" };
357
357
  const calendar = { "todayButton": { "label": "Today", "tooltip": "Jump to today" }, "calenderWeek": "CW", "previousMonthButton": "Previous month", "nextMonthButton": "Next month" };
358
358
  const flyoutMenu = { "moreActions": "More actions", "toggleActions": { "click": "Click to toggle action visibility", "hover": "Hover/Focus to toggle action visibility" } };
359
+ const slider = { "decreaseValue": "Decrease value by {n}", "increaseValue": "Increase value by {n}" };
359
360
  const enUS = {
360
361
  yes,
361
362
  no,
@@ -388,7 +389,8 @@ const enUS = {
388
389
  fileUpload,
389
390
  globalFAB,
390
391
  calendar,
391
- flyoutMenu
392
+ flyoutMenu,
393
+ slider
392
394
  };
393
395
  const NUMBER_FORMATS = {
394
396
  decimal: { style: "decimal" }
@@ -1421,19 +1423,8 @@ const NAVIGATION_KEYS = /* @__PURE__ */ new Set([
1421
1423
  ]);
1422
1424
  const INCREMENT_KEYS = /* @__PURE__ */ new Set([KEY.Right, KEY.Up, KEY.PageUp]);
1423
1425
  const DECREMENT_KEYS = /* @__PURE__ */ new Set([KEY.Left, KEY.Down, KEY.PageDown]);
1424
- const TRACK_CALCULATION_STRATEGIES = {
1425
- horizontal: (rect, coords) => MathUtils.clamp((coords.x - rect.left) / rect.width, 0, 1),
1426
- vertical: (rect, coords) => MathUtils.clamp((rect.bottom - coords.y) / rect.height, 0, 1)
1427
- };
1428
1426
  const readThumbIndex = (event) => Number(event.currentTarget?.dataset.index ?? -1);
1429
1427
  const roundToStep = (value, step, min) => Number((Math.round((value - min) / step) * step + min).toFixed(MathUtils.decimalsCount(step)));
1430
- const normalizeValues = (values, min, max, step) => {
1431
- if (!values.length) return [min];
1432
- return values.map((value) => {
1433
- const clamped = MathUtils.clamp(value, min, max);
1434
- return roundToStep(clamped, step, min);
1435
- }).sort((a, b) => a - b);
1436
- };
1437
1428
  const findClosestIndex = (values, currentValue) => {
1438
1429
  const result = values.reduce((acc, value, index) => {
1439
1430
  const distance = Math.abs(currentValue - value);
@@ -1445,7 +1436,7 @@ const findClosestIndex = (values, currentValue) => {
1445
1436
  }
1446
1437
  return acc;
1447
1438
  }, null);
1448
- return result.closestIndex;
1439
+ return result?.closestIndex ?? -1;
1449
1440
  };
1450
1441
  const adjustValueByIndex = ({
1451
1442
  values,
@@ -1460,32 +1451,27 @@ const _unstableCreateSlider = createBuilder(
1460
1451
  const min = computed(() => unref(options.min) ?? 0);
1461
1452
  const max = computed(() => unref(options.max) ?? 100);
1462
1453
  const step = computed(() => unref(options.step) ?? 1);
1463
- const values = computed(() => {
1454
+ const normalizedValues = computed(() => {
1464
1455
  const rawValues = unref(options.value);
1465
- if (Array.isArray(rawValues)) {
1466
- if (!rawValues?.length) {
1467
- return [min.value];
1468
- }
1469
- return normalizeValues(rawValues, min.value, max.value, step.value);
1470
- } else {
1471
- if (typeof rawValues !== "number") {
1472
- return [min.value];
1456
+ const arrayValues = Array.isArray(rawValues) ? rawValues.sort((a, b) => a - b) : [rawValues];
1457
+ if (!arrayValues.length) return [min.value];
1458
+ return arrayValues.map((value) => {
1459
+ const clamped = MathUtils.clamp(value, min.value, max.value);
1460
+ if (isDiscrete.value) {
1461
+ return roundToStep(clamped, step.value, min.value);
1473
1462
  }
1474
- return normalizeValues([rawValues], min.value, max.value, step.value);
1475
- }
1463
+ return clamped;
1464
+ });
1476
1465
  });
1477
1466
  const shiftStep = computed(() => {
1478
1467
  const shiftStep2 = unref(options.shiftStep);
1479
- if (typeof shiftStep2 !== "undefined") {
1480
- return shiftStep2;
1481
- }
1468
+ if (shiftStep2 != void 0) return shiftStep2;
1482
1469
  const stepMultiple = Math.max(1, Math.round((max.value - min.value) * 0.1 / step.value));
1483
1470
  return stepMultiple * step.value;
1484
1471
  });
1485
1472
  const isDisabled = computed(() => unref(options.disabled) ?? false);
1486
1473
  const marks = computed(() => unref(options.marks) ?? false);
1487
1474
  const label = computed(() => unref(options.label));
1488
- const orientation = computed(() => unref(options.orientation) ?? "horizontal");
1489
1475
  const isDiscrete = computed(() => unref(options.discrete) ?? false);
1490
1476
  let touchId = null;
1491
1477
  let movesSinceStart = 0;
@@ -1493,7 +1479,6 @@ const _unstableCreateSlider = createBuilder(
1493
1479
  let previousActiveIndex = null;
1494
1480
  const isDragging = ref(false);
1495
1481
  const activeThumbIndex = ref(-1);
1496
- const focusedThumbIndex = ref(-1);
1497
1482
  const isRange = computed(() => {
1498
1483
  const unrefValues = unref(options.value);
1499
1484
  return Array.isArray(unrefValues) && unrefValues.length > 1;
@@ -1510,12 +1495,9 @@ const _unstableCreateSlider = createBuilder(
1510
1495
  }
1511
1496
  return [];
1512
1497
  });
1513
- const axis = computed(
1514
- () => orientation.value === "vertical" ? { position: "bottom", size: "height", cross: "width" } : { position: "left", size: "width", cross: "height" }
1515
- );
1516
1498
  const marksValues = computed(() => marksList.value.map((mark) => mark.value));
1517
1499
  const emitChange = (next) => {
1518
- if (!areArraysEqual(values.value, next)) {
1500
+ if (!areArraysEqual(normalizedValues.value, next)) {
1519
1501
  const nextValue = isRange.value ? next : next[0];
1520
1502
  if (typeof nextValue !== "undefined") {
1521
1503
  options.onChange?.(nextValue);
@@ -1532,10 +1514,10 @@ const _unstableCreateSlider = createBuilder(
1532
1514
  };
1533
1515
  const ensureFocusOnThumb = (options2) => {
1534
1516
  const { index, shouldSetActive = false } = options2;
1535
- const slider = sliderRef.value;
1536
- if (!slider) return;
1537
- if (slider.contains(document.activeElement) && Number(document.activeElement?.getAttribute("data-index")) !== index) {
1538
- slider.querySelector(`[type="range"][data-index="${index}"]`)?.focus();
1517
+ const slider2 = sliderRef.value;
1518
+ if (!slider2) return;
1519
+ if (slider2.contains(document.activeElement) && Number(document.activeElement?.getAttribute("data-index")) !== index) {
1520
+ slider2.querySelector(`[type="range"][data-index="${index}"]`)?.focus();
1539
1521
  }
1540
1522
  if (shouldSetActive) {
1541
1523
  activeThumbIndex.value = index;
@@ -1562,12 +1544,11 @@ const _unstableCreateSlider = createBuilder(
1562
1544
  };
1563
1545
  const getNextFromCoords = (opts) => {
1564
1546
  const { coords, isMoving = false } = opts;
1565
- const slider = sliderRef.value;
1566
- if (!slider) return null;
1567
- const rect = slider.getBoundingClientRect();
1568
- const mainSize = orientation.value === "vertical" ? rect.height : rect.width;
1569
- if (mainSize <= 0) return null;
1570
- const percent = TRACK_CALCULATION_STRATEGIES[orientation.value](rect, coords);
1547
+ const slider2 = sliderRef.value;
1548
+ if (!slider2) return null;
1549
+ const rect = slider2.getBoundingClientRect();
1550
+ if (rect.width <= 0) return null;
1551
+ const percent = MathUtils.clamp((coords.x - rect.left) / rect.width, 0, 1);
1571
1552
  const raw = MathUtils.percentToValue(percent, min.value, max.value);
1572
1553
  const snapped = !isDiscrete.value ? roundToStep(raw, step.value, min.value) : marksValues.value[findClosestIndex(marksValues.value, raw)];
1573
1554
  if (typeof snapped !== "number") return null;
@@ -1575,10 +1556,10 @@ const _unstableCreateSlider = createBuilder(
1575
1556
  if (!isRange.value) {
1576
1557
  return { newValue: candidate, activeIndex: 0 };
1577
1558
  }
1578
- const closestIndex = findClosestIndex(values.value, candidate);
1559
+ const closestIndex = findClosestIndex(normalizedValues.value, candidate);
1579
1560
  const index = isMoving && previousActiveIndex != null ? previousActiveIndex : closestIndex;
1580
1561
  const adjustedValues = adjustValueByIndex({
1581
- values: values.value,
1562
+ values: normalizedValues.value,
1582
1563
  newValue: candidate,
1583
1564
  index
1584
1565
  });
@@ -1588,7 +1569,7 @@ const _unstableCreateSlider = createBuilder(
1588
1569
  };
1589
1570
  const commitValueFromEvent = (event, input2) => {
1590
1571
  const index = readThumbIndex(event);
1591
- const current = values.value[index];
1572
+ const current = normalizedValues.value[index];
1592
1573
  if (typeof current !== "number") {
1593
1574
  return;
1594
1575
  }
@@ -1611,13 +1592,12 @@ const _unstableCreateSlider = createBuilder(
1611
1592
  return neighbor?.value ?? current;
1612
1593
  };
1613
1594
  const scalar = MathUtils.clamp(useMarks ? snapByMarks(input2) : input2, min.value, max.value);
1614
- const nextValues = isRange.value ? adjustValueByIndex({ values: values.value, newValue: scalar, index }) : [scalar];
1595
+ const nextValues = isRange.value ? adjustValueByIndex({ values: normalizedValues.value, newValue: scalar, index }) : [scalar];
1615
1596
  if (isRange.value) {
1616
1597
  const activeIndex = nextValues.indexOf(scalar);
1617
1598
  ensureFocusOnThumb({ index: activeIndex, shouldSetActive: true });
1618
1599
  }
1619
- focusedThumbIndex.value = index;
1620
- if (!areArraysEqual(values.value, nextValues)) {
1600
+ if (!areArraysEqual(normalizedValues.value, nextValues)) {
1621
1601
  emitChange(nextValues);
1622
1602
  }
1623
1603
  emitCommit(nextValues);
@@ -1725,13 +1705,11 @@ const _unstableCreateSlider = createBuilder(
1725
1705
  const handleHiddenInputFocus = (event) => {
1726
1706
  const index = readThumbIndex(event);
1727
1707
  if (isFocusVisible(event.target)) {
1728
- focusedThumbIndex.value = index;
1729
1708
  activeThumbIndex.value = index;
1730
1709
  }
1731
1710
  };
1732
1711
  const handleHiddenInputBlur = (event) => {
1733
1712
  if (!isFocusVisible(event.target)) {
1734
- focusedThumbIndex.value = -1;
1735
1713
  activeThumbIndex.value = -1;
1736
1714
  }
1737
1715
  };
@@ -1739,7 +1717,7 @@ const _unstableCreateSlider = createBuilder(
1739
1717
  if (!NAVIGATION_KEYS.has(event.key)) return;
1740
1718
  event.preventDefault();
1741
1719
  const index = readThumbIndex(event);
1742
- const value = values.value[index];
1720
+ const value = normalizedValues.value[index];
1743
1721
  if (typeof value !== "number") {
1744
1722
  return;
1745
1723
  }
@@ -1759,24 +1737,24 @@ const _unstableCreateSlider = createBuilder(
1759
1737
  }
1760
1738
  return;
1761
1739
  } else {
1762
- const values2 = marksValues.value;
1763
- const lastIndex = values2.length - 1;
1764
- const currentIndex = values2.indexOf(value);
1765
- const first = values2[0];
1766
- const last = values2[lastIndex];
1740
+ const values = marksValues.value;
1741
+ const lastIndex = values.length - 1;
1742
+ const currentIndex = values.indexOf(value);
1743
+ const first = values[0];
1744
+ const last = values[lastIndex];
1767
1745
  if (event.key === "Home" && typeof first === "number")
1768
1746
  return commitValueFromEvent(event, first);
1769
1747
  if (event.key === "End" && typeof last === "number")
1770
1748
  return commitValueFromEvent(event, last);
1771
1749
  if (INCREMENT_KEYS.has(event.key)) {
1772
1750
  const nextIdx = currentIndex < 0 ? 0 : Math.min(lastIndex, currentIndex + 1);
1773
- const next = values2[nextIdx];
1751
+ const next = values[nextIdx];
1774
1752
  if (next !== value && typeof next === "number") commitValueFromEvent(event, next);
1775
1753
  return;
1776
1754
  }
1777
1755
  if (DECREMENT_KEYS.has(event.key)) {
1778
1756
  const nextIdx = currentIndex < 0 ? 0 : Math.max(0, currentIndex - 1);
1779
- const next = values2[nextIdx];
1757
+ const next = values[nextIdx];
1780
1758
  if (next !== value && typeof next === "number") commitValueFromEvent(event, next);
1781
1759
  return;
1782
1760
  }
@@ -1784,27 +1762,18 @@ const _unstableCreateSlider = createBuilder(
1784
1762
  };
1785
1763
  const trackOffset = computed(
1786
1764
  () => MathUtils.valueToPercent(
1787
- isRange.value && values.value[0] ? values.value[0] : min.value,
1765
+ isRange.value && normalizedValues.value[0] ? normalizedValues.value[0] : min.value,
1788
1766
  min.value,
1789
1767
  max.value
1790
1768
  )
1791
1769
  );
1792
1770
  const trackLength = computed(
1793
- () => MathUtils.valueToPercent(values.value.at(-1) ?? 0, min.value, max.value) - trackOffset.value
1771
+ () => MathUtils.valueToPercent(normalizedValues.value.at(-1) ?? 0, min.value, max.value) - trackOffset.value
1794
1772
  );
1795
1773
  const trackStyle = computed(() => ({
1796
- [axis.value.position]: `${trackOffset.value}%`,
1797
- [axis.value.size]: `${trackLength.value}%`
1774
+ left: `${trackOffset.value}%`,
1775
+ width: `${trackLength.value}%`
1798
1776
  }));
1799
- const isMarkActive = computed(() => (markValue) => {
1800
- if (isRange.value) {
1801
- const minValue = Math.min(...values.value);
1802
- const maxValue = Math.max(...values.value);
1803
- return markValue >= minValue && markValue <= maxValue;
1804
- }
1805
- const currentValue = values.value[0];
1806
- return markValue <= currentValue;
1807
- });
1808
1777
  onBeforeUnmount(stopPointerListening);
1809
1778
  watch(
1810
1779
  () => isDisabled.value,
@@ -1812,11 +1781,15 @@ const _unstableCreateSlider = createBuilder(
1812
1781
  if (isDisabled.value) {
1813
1782
  isDragging.value = false;
1814
1783
  activeThumbIndex.value = -1;
1815
- focusedThumbIndex.value = -1;
1816
1784
  stopPointerListening();
1817
1785
  }
1818
1786
  }
1819
1787
  );
1788
+ const adjustMarkPosition = (percentage, offset) => {
1789
+ if (offset && percentage <= 0) return offset;
1790
+ if (offset && percentage >= 100) return `calc(100% - ${offset})`;
1791
+ return `${percentage}%`;
1792
+ };
1820
1793
  return {
1821
1794
  elements: {
1822
1795
  /**
@@ -1824,7 +1797,7 @@ const _unstableCreateSlider = createBuilder(
1824
1797
  */
1825
1798
  root: computed(() => ({
1826
1799
  ref: sliderRef,
1827
- style: { touchAction: orientation.value === "vertical" ? "pan-x" : "pan-y" },
1800
+ style: { touchAction: "pan-y" },
1828
1801
  onMousedown: handleRootMousedown,
1829
1802
  onTouchstart: handlePointerStart
1830
1803
  })),
@@ -1834,7 +1807,7 @@ const _unstableCreateSlider = createBuilder(
1834
1807
  thumbContainer: computed(() => (data) => ({
1835
1808
  "data-index": data.index,
1836
1809
  style: {
1837
- [axis.value.position]: `${MathUtils.valueToPercent(data.value, min.value, max.value)}%`
1810
+ left: `${MathUtils.valueToPercent(data.value, min.value, max.value)}%`
1838
1811
  }
1839
1812
  })),
1840
1813
  /**
@@ -1850,7 +1823,7 @@ const _unstableCreateSlider = createBuilder(
1850
1823
  "aria-valuemin": min.value,
1851
1824
  "aria-valuemax": max.value,
1852
1825
  "aria-valuenow": data.value,
1853
- "aria-orientation": orientation.value,
1826
+ "aria-orientation": "horizontal",
1854
1827
  "data-index": data.index,
1855
1828
  tabIndex: isDisabled.value ? -1 : 0,
1856
1829
  step: isDiscrete.value && marks.value ? "any" : step.value ?? void 0,
@@ -1863,20 +1836,26 @@ const _unstableCreateSlider = createBuilder(
1863
1836
  /**
1864
1837
  * Mark elements
1865
1838
  */
1866
- mark: computed(() => (data) => ({
1867
- "data-value": data.value,
1868
- "aria-hidden": true,
1869
- style: {
1870
- [axis.value.position]: `${MathUtils.clamp(MathUtils.valueToPercent(data.value, min.value, max.value), 0, 100)}%`
1871
- }
1872
- })),
1839
+ mark: computed(() => (data) => {
1840
+ const percentage = MathUtils.clamp(
1841
+ MathUtils.valueToPercent(data.value, min.value, max.value),
1842
+ 0,
1843
+ 100
1844
+ );
1845
+ const position = adjustMarkPosition(percentage, data.positionOffset);
1846
+ return {
1847
+ "data-value": data.value,
1848
+ "aria-hidden": true,
1849
+ style: { left: position }
1850
+ };
1851
+ }),
1873
1852
  /**
1874
1853
  * Label for each mark
1875
1854
  */
1876
1855
  markLabel: computed(() => (data) => ({
1877
1856
  "data-value": data.value,
1878
1857
  style: {
1879
- [axis.value.position]: `${MathUtils.valueToPercent(data.value, min.value, max.value)}%`
1858
+ left: `${MathUtils.valueToPercent(data.value, min.value, max.value)}%`
1880
1859
  },
1881
1860
  "aria-hidden": true
1882
1861
  })),
@@ -1907,11 +1886,6 @@ const _unstableCreateSlider = createBuilder(
1907
1886
  * `-1` if no thumb is active.
1908
1887
  */
1909
1888
  activeThumbIndex,
1910
- /**
1911
- * Index of the thumb that is currently focused.
1912
- * `-1` if no thumb is focused.
1913
- */
1914
- focusedThumbIndex,
1915
1889
  /**
1916
1890
  * `true` if the slider is a range slider (with two or more thumbs).
1917
1891
  */
@@ -1930,35 +1904,17 @@ const _unstableCreateSlider = createBuilder(
1930
1904
  * - If marks option is an array of numbers or objects, it is used as provided (filtered to be within range).
1931
1905
  * - If marks option is `false`, no marks are shown.
1932
1906
  */
1933
- marksList
1907
+ marksList,
1908
+ shiftStep,
1909
+ normalizedValues
1934
1910
  },
1935
1911
  internals: {
1936
- /**
1937
- * Converts a value from the slider's range to a percentage (0-100).
1938
- * @param value - value to convert
1939
- * @returns percentage representation of the value
1940
- */
1941
- valueToPercent: computed(
1942
- () => (value) => MathUtils.valueToPercent(value, min.value, max.value)
1943
- ),
1944
- /**
1945
- * Checks if a given mark value is active (i.e., within the selected range).
1946
- * Use case: when rendering marks, to determine if a mark is covered by the selected range.
1947
- *
1948
- * @param markValue - value of the mark to check
1949
- * @returns `true` if the mark is active, `false` otherwise
1950
- */
1951
- isMarkActive,
1952
1912
  /**
1953
1913
  * Clamps a value to the slider's range.
1954
1914
  * @param value - value to clamp
1955
1915
  * @returns clamped value
1956
1916
  */
1957
1917
  clampValue: computed(() => (value) => MathUtils.clamp(value, min.value, max.value)),
1958
- /**
1959
- * Main axis properties based on orientation.
1960
- */
1961
- axis,
1962
1918
  /**
1963
1919
  * Rounds a value to the nearest valid step.
1964
1920
  * @param value - value to round
@@ -1966,12 +1922,6 @@ const _unstableCreateSlider = createBuilder(
1966
1922
  */
1967
1923
  roundToStep: computed(
1968
1924
  () => (value) => !isDiscrete.value ? roundToStep(value, step.value, min.value) : marksValues.value[findClosestIndex(marksValues.value, value)]
1969
- ),
1970
- /**
1971
- * Normalizes an array of values to ensure they are within min/max bounds,
1972
- */
1973
- normalizeValues: computed(
1974
- () => (values2) => normalizeValues(values2, min.value, max.value, step.value)
1975
1925
  )
1976
1926
  }
1977
1927
  };
@@ -13045,31 +12995,15 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13045
12995
  min: { type: Number, required: false, default: 0 },
13046
12996
  max: { type: Number, required: false, default: 100 },
13047
12997
  step: { type: Number, required: false, default: 1 },
13048
- shiftStep: { type: Number, required: false, default: (props) => {
13049
- const min = props.min ?? 0;
13050
- const max = props.max ?? 100;
13051
- const step = props.step ?? 1;
13052
- const stepMultiple = Math.max(1, Math.round((max - min) * 0.1 / step));
13053
- return stepMultiple * step;
13054
- } },
12998
+ shiftStep: { type: Number, required: false },
13055
12999
  marks: { type: [Array, Boolean], required: false, default: false },
13056
13000
  control: { type: null, required: false },
13057
- orientation: { type: null, required: false, default: "horizontal" },
13058
13001
  disableTooltip: { type: Boolean, required: false },
13059
13002
  discrete: { type: Boolean, required: false }
13060
13003
  },
13061
- emits: ["validityChange", "update:modelValue"],
13004
+ emits: ["update:modelValue", "validityChange"],
13062
13005
  setup(__props, { expose: __expose, emit: __emit }) {
13063
13006
  __expose();
13064
- const adjustMarkPosition = (percentage) => {
13065
- if (percentage <= 0) {
13066
- return "calc(0.25rem)";
13067
- }
13068
- if (percentage >= 100) {
13069
- return "calc(100% - 0.25rem)";
13070
- }
13071
- return `${percentage}%`;
13072
- };
13073
13007
  const props = __props;
13074
13008
  const emit = __emit;
13075
13009
  const modelValue = useVModel({
@@ -13077,6 +13011,7 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13077
13011
  emit,
13078
13012
  key: "modelValue"
13079
13013
  });
13014
+ const { t } = injectI18n();
13080
13015
  const { vCustomValidity, errorMessages } = useFormElementError({ props, emit });
13081
13016
  const formElementProps = useForwardProps(props, OnyxFormElement);
13082
13017
  const messages = computed(() => getFormMessages(props.message));
@@ -13084,35 +13019,10 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13084
13019
  const { disabled, showError } = useFormContext(props);
13085
13020
  const errorClass = useErrorClass(showError);
13086
13021
  const skeleton = useSkeletonContext(props);
13087
- const handleChange = (values) => {
13088
- emit("update:modelValue", values);
13089
- };
13090
- const handleDecreaseByIcon = () => {
13091
- if (disabled.value) return;
13092
- if (props.mode === "single") {
13093
- const currentValue = Number(modelValue.value ?? props.min);
13094
- const stepValue = props.shiftStep ?? props.step ?? 1;
13095
- const newValue = Math.max(currentValue - stepValue, props.min);
13096
- handleChange(newValue);
13097
- }
13098
- };
13099
- const handleIncreaseByIcon = () => {
13100
- if (disabled.value) return;
13101
- if (props.mode === "single") {
13102
- const currentValue = Number(modelValue.value ?? props.min);
13103
- const stepValue = props.shiftStep ?? props.step ?? 1;
13104
- const newValue = Math.min(currentValue + stepValue, props.max);
13105
- handleChange(newValue);
13106
- }
13107
- };
13108
- const { min, max, step, marks, orientation, label, discrete, shiftStep } = toRefs(props);
13109
- const thumbs = computed(
13110
- () => Array.isArray(modelValue.value) ? modelValue.value : [modelValue.value]
13111
- );
13022
+ const { min, max, step, marks, label, discrete } = toRefs(props);
13112
13023
  const {
13113
13024
  elements: { root, rail, track, thumbContainer, thumbInput, mark, markLabel },
13114
- state: { focusedThumbIndex, activeThumbIndex, marksList },
13115
- internals: { isMarkActive, valueToPercent, axis, normalizeValues: normalizeValues2 }
13025
+ state: { activeThumbIndex, marksList, shiftStep, normalizedValues }
13116
13026
  } = _unstableCreateSlider({
13117
13027
  value: modelValue,
13118
13028
  min,
@@ -13120,29 +13030,35 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13120
13030
  step,
13121
13031
  label,
13122
13032
  marks,
13123
- orientation,
13124
13033
  discrete,
13125
13034
  disabled,
13126
- shiftStep,
13127
- onChange: handleChange
13035
+ shiftStep: toRef(props, "shiftStep"),
13036
+ onChange: (newValue) => modelValue.value = newValue
13128
13037
  });
13129
- watch(
13130
- () => [props.min, props.max, props.step, props.mode],
13131
- () => {
13132
- const normalized = normalizeValues2.value(
13133
- props.mode === "range" ? [Number(modelValue.value)] : modelValue.value
13134
- );
13135
- handleChange(props.mode === "range" ? normalized : normalized[0]);
13038
+ const handleDecreaseByIcon = () => {
13039
+ if (disabled.value) return;
13040
+ const currentValue = normalizedValues.value[0];
13041
+ if (props.mode === "single" && currentValue != void 0) {
13042
+ const stepValue = shiftStep.value ?? props.step ?? 1;
13043
+ const newValue = Math.max(currentValue - stepValue, props.min);
13044
+ modelValue.value = newValue;
13136
13045
  }
13137
- );
13046
+ };
13047
+ const handleIncreaseByIcon = () => {
13048
+ if (disabled.value) return;
13049
+ const currentValue = normalizedValues.value[0];
13050
+ if (props.mode === "single" && currentValue != void 0) {
13051
+ const stepValue = shiftStep.value ?? props.step ?? 1;
13052
+ const newValue = Math.min(currentValue + stepValue, props.max);
13053
+ modelValue.value = newValue;
13054
+ }
13055
+ };
13138
13056
  const isValueControl = computed(() => props.control === "value");
13139
13057
  const isIconControl = computed(() => props.control === "icon" && props.mode === "single");
13140
- const __returned__ = { adjustMarkPosition, props, emit, modelValue, vCustomValidity, errorMessages, formElementProps, messages, densityClass, disabled, showError, errorClass, skeleton, handleChange, handleDecreaseByIcon, handleIncreaseByIcon, min, max, step, marks, orientation, label, discrete, shiftStep, thumbs, root, rail, track, thumbContainer, thumbInput, mark, markLabel, focusedThumbIndex, activeThumbIndex, marksList, isMarkActive, valueToPercent, axis, normalizeValues: normalizeValues2, isValueControl, isIconControl, get iconMinusSmall() {
13058
+ const __returned__ = { props, emit, modelValue, t, vCustomValidity, errorMessages, formElementProps, messages, densityClass, disabled, showError, errorClass, skeleton, min, max, step, marks, label, discrete, root, rail, track, thumbContainer, thumbInput, mark, markLabel, activeThumbIndex, marksList, shiftStep, normalizedValues, handleDecreaseByIcon, handleIncreaseByIcon, isValueControl, isIconControl, get iconMinusSmall() {
13141
13059
  return iconMinusSmall;
13142
13060
  }, get iconPlusSmall() {
13143
13061
  return iconPlusSmall;
13144
- }, get applyLimits() {
13145
- return applyLimits;
13146
13062
  }, OnyxFormElement, OnyxIconButton, OnyxSkeleton, OnyxTooltip, OnyxVisuallyHidden };
13147
13063
  Object.defineProperty(__returned__, "__isScriptSetup", { enumerable: false, value: true });
13148
13064
  return __returned__;
@@ -13151,38 +13067,29 @@ const _sfc_main$c = /* @__PURE__ */ defineComponent({
13151
13067
  const _hoisted_1$8 = { class: "onyx-slider__container" };
13152
13068
  const _hoisted_2$7 = {
13153
13069
  key: 0,
13154
- class: "onyx-slider__value-control-container",
13155
- role: "img",
13156
- tabindex: "-1"
13070
+ class: "onyx-slider__control",
13071
+ "aria-hidden": "true"
13157
13072
  };
13158
13073
  const _hoisted_3$5 = {
13159
13074
  key: 1,
13160
- class: "onyx-slider__icon-control-container"
13075
+ class: "onyx-slider__control"
13161
13076
  };
13162
13077
  const _hoisted_4$5 = ["disabled", "aria-label", "autofocus"];
13163
13078
  const _hoisted_5$5 = {
13164
13079
  key: 2,
13165
- class: "onyx-slider__value-control-container",
13166
- role: "img",
13167
- tabindex: "-1"
13080
+ class: "onyx-slider__control",
13081
+ "aria-hidden": "true"
13168
13082
  };
13169
13083
  const _hoisted_6$4 = {
13170
13084
  key: 3,
13171
- class: "onyx-slider__icon-control-container"
13085
+ class: "onyx-slider__control"
13172
13086
  };
13173
13087
  function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13174
13088
  return $setup.skeleton ? (openBlock(), createElementBlock(
13175
13089
  "div",
13176
13090
  {
13177
13091
  key: 0,
13178
- class: normalizeClass([
13179
- "onyx-component",
13180
- "onyx-slider-skeleton",
13181
- $setup.densityClass,
13182
- {
13183
- "onyx-slider-skeleton--vertical": $setup.props.orientation === "vertical"
13184
- }
13185
- ])
13092
+ class: normalizeClass(["onyx-component", "onyx-slider-skeleton", $setup.densityClass])
13186
13093
  },
13187
13094
  [
13188
13095
  !$setup.props.hideLabel ? (openBlock(), createBlock($setup["OnyxSkeleton"], {
@@ -13197,15 +13104,13 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13197
13104
  "div",
13198
13105
  {
13199
13106
  key: 1,
13200
- class: normalizeClass(["onyx-component onyx-slider", [
13201
- {
13202
- "onyx-slider--vertical": $setup.props.orientation === "vertical",
13203
- "onyx-slider--disabled": $setup.disabled,
13204
- "onyx-slider--is-active": $setup.activeThumbIndex !== -1
13205
- },
13107
+ class: normalizeClass([
13108
+ "onyx-component",
13109
+ "onyx-slider",
13110
+ { "onyx-slider--active": $setup.activeThumbIndex !== -1 },
13206
13111
  $setup.densityClass,
13207
13112
  $setup.errorClass
13208
- ]])
13113
+ ])
13209
13114
  },
13210
13115
  [
13211
13116
  createVNode($setup["OnyxFormElement"], mergeProps({
@@ -13226,8 +13131,8 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13226
13131
  )) : createCommentVNode("v-if", true),
13227
13132
  $setup.isIconControl ? (openBlock(), createElementBlock("div", _hoisted_3$5, [
13228
13133
  createVNode($setup["OnyxIconButton"], {
13229
- disabled: $setup.disabled || Number($setup.modelValue ?? $setup.props.min) <= $setup.props.min,
13230
- label: $setup.props.label || inputId,
13134
+ disabled: $setup.disabled || ($setup.normalizedValues[0] ?? $setup.props.min) <= $setup.props.min,
13135
+ label: $setup.t("slider.decreaseValue", { n: $setup.shiftStep }),
13231
13136
  color: "neutral",
13232
13137
  icon: $setup.iconMinusSmall,
13233
13138
  tabindex: "0",
@@ -13266,13 +13171,11 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13266
13171
  [
13267
13172
  createElementVNode(
13268
13173
  "span",
13269
- mergeProps({
13270
- class: ["onyx-slider__mark", { "onyx-slider__mark--active": $setup.isMarkActive(markItem.value) }]
13271
- }, { ref_for: true }, $setup.mark({ value: markItem.value, label: markItem.label }), {
13272
- style: {
13273
- [$setup.axis.position]: `${$setup.adjustMarkPosition($setup.applyLimits($setup.valueToPercent(markItem.value), 0, 100))}`
13274
- }
13275
- }),
13174
+ mergeProps(
13175
+ { class: "onyx-slider__mark" },
13176
+ { ref_for: true },
13177
+ $setup.mark({ value: markItem.value, label: markItem.label, positionOffset: "0.25rem" })
13178
+ ),
13276
13179
  null,
13277
13180
  16
13278
13181
  /* FULL_PROPS */
@@ -13298,21 +13201,20 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13298
13201
  (openBlock(true), createElementBlock(
13299
13202
  Fragment,
13300
13203
  null,
13301
- renderList($setup.thumbs, (value, index) => {
13204
+ renderList($setup.normalizedValues, (value, index) => {
13302
13205
  return openBlock(), createElementBlock(
13303
13206
  "span",
13304
13207
  mergeProps({ key: index }, { ref_for: true }, $setup.thumbContainer({ value, index }), {
13305
- class: ["onyx-slider__thumb", {
13306
- "is-focus": $setup.focusedThumbIndex === index,
13307
- "is-active": $setup.activeThumbIndex === index
13308
- }]
13208
+ class: [
13209
+ "onyx-slider__thumb",
13210
+ { "onyx-slider__thumb--active": $setup.activeThumbIndex === index }
13211
+ ]
13309
13212
  }),
13310
13213
  [
13311
13214
  createVNode($setup["OnyxTooltip"], {
13312
13215
  open: !$setup.props.disableTooltip && $setup.activeThumbIndex === index,
13313
13216
  text: String(value),
13314
- position: $setup.props.orientation === "vertical" ? "right" : "bottom",
13315
- alignment: "auto",
13217
+ position: "bottom",
13316
13218
  class: "onyx-slider__thumb-tooltip"
13317
13219
  }, {
13318
13220
  default: withCtx(({ trigger }) => [
@@ -13346,7 +13248,7 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13346
13248
  ]),
13347
13249
  _: 2
13348
13250
  /* DYNAMIC */
13349
- }, 1032, ["open", "text", "position"])
13251
+ }, 1032, ["open", "text"])
13350
13252
  ],
13351
13253
  16
13352
13254
  /* FULL_PROPS */
@@ -13368,13 +13270,13 @@ function _sfc_render$c(_ctx, _cache, $props, $setup, $data, $options) {
13368
13270
  )) : createCommentVNode("v-if", true),
13369
13271
  $setup.isIconControl ? (openBlock(), createElementBlock("div", _hoisted_6$4, [
13370
13272
  createVNode($setup["OnyxIconButton"], {
13371
- disabled: $setup.disabled || Number($setup.modelValue ?? $setup.props.min) >= $setup.props.max,
13372
- label: "Increase",
13273
+ disabled: $setup.disabled || ($setup.normalizedValues[0] ?? $setup.props.min) >= $setup.props.max,
13274
+ label: $setup.t("slider.increaseValue", { n: $setup.shiftStep }),
13373
13275
  color: "neutral",
13374
13276
  icon: $setup.iconPlusSmall,
13375
13277
  tabindex: "0",
13376
13278
  onClick: $setup.handleIncreaseByIcon
13377
- }, null, 8, ["disabled", "icon"])
13279
+ }, null, 8, ["disabled", "label", "icon"])
13378
13280
  ])) : createCommentVNode("v-if", true)
13379
13281
  ])
13380
13282
  ]),