@synerise/ds-slider 1.1.10 → 1.1.12
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/CHANGELOG.md +10 -0
- package/README.md +29 -49
- package/dist/components/SliderMarks.js +12 -5
- package/package.json +8 -7
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,16 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [1.1.12](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.11...@synerise/ds-slider@1.1.12) (2026-03-20)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
## [1.1.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.10...@synerise/ds-slider@1.1.11) (2026-03-09)
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
- **slider:** recalc slider dimensions on resize ([5ea3bc5](https://github.com/Synerise/synerise-design/commit/5ea3bc5a2aea2bb3f93f3779f639b83db99bf412))
|
|
15
|
+
|
|
6
16
|
## [1.1.10](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.9...@synerise/ds-slider@1.1.10) (2026-02-23)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @synerise/ds-slider
|
package/README.md
CHANGED
|
@@ -5,7 +5,7 @@ title: Slider
|
|
|
5
5
|
|
|
6
6
|
Slider UI Component
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
Built on `@tanstack/react-ranger`. Supports single-value, range (dual-thumb), and allocation modes.
|
|
9
9
|
|
|
10
10
|
## Installation
|
|
11
11
|
|
|
@@ -20,16 +20,11 @@ yarn add @synerise/ds-slider
|
|
|
20
20
|
```jsx
|
|
21
21
|
import Slider from '@synerise/ds-slider';
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
step={5}
|
|
29
|
-
onAfterChange={props.onAfterChange}
|
|
30
|
-
OnChange={props.onChange}
|
|
31
|
-
tooltipPlacement="topLeft"
|
|
32
|
-
/>;
|
|
23
|
+
// Single value
|
|
24
|
+
<Slider label="Label" max={100} min={0} step={5} value={50} onChange={v => setValue(v)} />;
|
|
25
|
+
|
|
26
|
+
// Range
|
|
27
|
+
<Slider range min={0} max={100} value={[20, 80]} onChange={v => setRange(v)} />;
|
|
33
28
|
```
|
|
34
29
|
|
|
35
30
|
## Slider Default
|
|
@@ -42,49 +37,34 @@ import Slider from '@synerise/ds-slider';
|
|
|
42
37
|
|
|
43
38
|
## API
|
|
44
39
|
|
|
45
|
-
| Property
|
|
46
|
-
|
|
|
47
|
-
|
|
|
48
|
-
|
|
|
49
|
-
|
|
|
50
|
-
|
|
|
51
|
-
|
|
|
52
|
-
| marks
|
|
53
|
-
| max
|
|
54
|
-
| min
|
|
55
|
-
| range
|
|
56
|
-
| step
|
|
57
|
-
| tipFormatter
|
|
58
|
-
| value
|
|
59
|
-
|
|
|
60
|
-
|
|
|
61
|
-
|
|
|
62
|
-
|
|
|
63
|
-
|
|
|
64
|
-
|
|
|
65
|
-
|
|
|
66
|
-
| getTooltipPopupContainer | The DOM container of the Tooltip, the default behavior is to create a div element in body. | () => React.HTMLElement | `() => document.body` |
|
|
67
|
-
| inverted | Allow to use slider in inverted mode. Applies only when value is `number or [number, number]` | Boolean | `false` |
|
|
68
|
-
| useColorPalette | Allow the usage of predefined palette for slider tracks | Boolean | `false` |
|
|
69
|
-
| tracksColorMap | Allow to import your 10 colors color map. | Object | |
|
|
70
|
-
| handlers | Handlers config object for allocation slider. Allow to manipulate handlers e.g. enable to block handler. First handler index is 1. | HandlerConfig | - |
|
|
71
|
-
|
|
72
|
-
### AllocationConfig
|
|
73
|
-
|
|
74
|
-
| Property | Description | Type | Default |
|
|
75
|
-
| ------------------- | --------------------------------------------------------- | ---------------------------------------- | --------------- |
|
|
76
|
-
| controlGroupEnabled | Enables treating the rest of the range as control group. | boolean | `false` |
|
|
77
|
-
| controlGroupLabel | Label displayed over control group range | string / React.ReactNode | `Control group` |
|
|
78
|
-
| controlGroupTooltip | Tooltip displayed when hovering over control group label. | string / React.ReactNode | `CG` |
|
|
79
|
-
| variants | Whether the thumb can drag over tick only. | AllocationVariant[] | `false` |
|
|
80
|
-
| onAllocationChange | Callback executed when user changes slider value. | (variants?: AllocationVariant[]) => void | `false` |
|
|
40
|
+
| Property | Description | Type | Default |
|
|
41
|
+
| -------------- | ---------------------------------------------------------------------------------------------- | ------------------------------------------------ | ------- |
|
|
42
|
+
| label | Label rendered above the slider | React.ReactNode | - |
|
|
43
|
+
| description | Description text rendered above the slider | React.ReactNode | - |
|
|
44
|
+
| autoFocus | get focus when component mounted | boolean | `false` |
|
|
45
|
+
| disabled | If true, the slider will not be interactable. | boolean | `false` |
|
|
46
|
+
| dots | Show dots at step positions | boolean | `false` |
|
|
47
|
+
| marks | Tick mark of Slider. Key must be a number in [min, max]. Each mark can have its own style. | `Record<string \| number, ReactNode \| MarkObj>` | - |
|
|
48
|
+
| max | The maximum value the slider can slide to | number | - |
|
|
49
|
+
| min | The minimum value the slider can slide to. | number | - |
|
|
50
|
+
| range | Dual thumb mode (activates RangeSlider) | boolean | - |
|
|
51
|
+
| step | The granularity the slider can step through values. | number | - |
|
|
52
|
+
| tipFormatter | Custom tooltip formatter; pass `false` to hide tooltip. | `((value?: number) => React.ReactNode) \| false` | - |
|
|
53
|
+
| value | The value of slider. When `range` is false, use number; otherwise, use `[number, number]` | `number \| number[]` | - |
|
|
54
|
+
| onAfterChange | Fire when mouse/touch up is fired. | `(value: number \| number[]) => void` | - |
|
|
55
|
+
| onChange | Callback function that is fired when the user changes the slider's value. | `(value: number \| number[]) => void` | - |
|
|
56
|
+
| thick | Set thickness of the slider | boolean | `false` |
|
|
57
|
+
| type | Defines a way of handling slider ranges | `'default'` / `'allocation'` | - |
|
|
58
|
+
| inverted | Allow to use slider in inverted mode. Applies only when `value` is `number` or `[number, number]` | boolean | `false` |
|
|
59
|
+
| tracksColorMap | Custom colour map for track sections (keys are numeric values) | `Record<number, string>` | - |
|
|
60
|
+
| handlers | Handlers config for allocation slider. Allows blocking handlers. First handler index is 1. | HandlerConfig | - |
|
|
81
61
|
|
|
82
62
|
### AllocationConfig
|
|
83
63
|
|
|
84
64
|
| Property | Description | Type | Default |
|
|
85
65
|
| ------------------- | --------------------------------------------------------- | ---------------------------------------- | --------------- |
|
|
66
|
+
| variants | Allocation variants with name, percentage and tab info | AllocationVariant[] | - |
|
|
67
|
+
| onAllocationChange | Callback executed when user changes slider value. | (variants?: AllocationVariant[]) => void | - |
|
|
86
68
|
| controlGroupEnabled | Enables treating the rest of the range as control group. | boolean | `false` |
|
|
87
69
|
| controlGroupLabel | Label displayed over control group range | string / React.ReactNode | `Control group` |
|
|
88
70
|
| controlGroupTooltip | Tooltip displayed when hovering over control group label. | string / React.ReactNode | `CG` |
|
|
89
|
-
| variants | Whether the thumb can drag over tick only. | AllocationVariant[] | `false` |
|
|
90
|
-
| onAllocationChange | Callback executed when user changes slider value. | (variants?: AllocationVariant[]) => void | `false` |
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useCallback, useEffect, useRef, useState } from 'react';
|
|
2
2
|
import { Text } from '@synerise/ds-typography';
|
|
3
|
+
import { useResizeObserver } from '@synerise/ds-utils';
|
|
3
4
|
import * as S from '../Slider.styles';
|
|
4
5
|
import { useSliderContext } from '../context/SliderContext';
|
|
5
6
|
import { getTranslateX, isMarksObjType } from '../utils/Slider.utils';
|
|
@@ -18,18 +19,16 @@ export var SliderMarks = function SliderMarks(_ref) {
|
|
|
18
19
|
markAreas = _useState2[0],
|
|
19
20
|
setMarkAreas = _useState2[1];
|
|
20
21
|
var markRefs = useRef({});
|
|
22
|
+
var sliderElementRef = useRef();
|
|
21
23
|
var marksData = Object.entries(marks);
|
|
22
24
|
var handles = rangerInstance.handles().map(function (handle) {
|
|
23
25
|
return handle.value;
|
|
24
26
|
});
|
|
25
|
-
|
|
26
|
-
var element =
|
|
27
|
+
var updateMeasurements = useCallback(function () {
|
|
28
|
+
var element = sliderElementRef.current;
|
|
27
29
|
if (element != null && element.clientWidth) {
|
|
28
30
|
setSliderWidth(element.clientWidth);
|
|
29
31
|
}
|
|
30
|
-
// eslint-disable-next-line react-hooks/exhaustive-deps
|
|
31
|
-
}, []);
|
|
32
|
-
useEffect(function () {
|
|
33
32
|
var areas = {};
|
|
34
33
|
Object.keys(markRefs.current).forEach(function (index) {
|
|
35
34
|
var markElement = markRefs.current[index];
|
|
@@ -40,6 +39,14 @@ export var SliderMarks = function SliderMarks(_ref) {
|
|
|
40
39
|
});
|
|
41
40
|
setMarkAreas(areas);
|
|
42
41
|
}, []);
|
|
42
|
+
useEffect(function () {
|
|
43
|
+
var element = rangerInstance.options.getRangerElement();
|
|
44
|
+
if (element) {
|
|
45
|
+
sliderElementRef.current = element;
|
|
46
|
+
}
|
|
47
|
+
updateMeasurements();
|
|
48
|
+
}, [rangerInstance, updateMeasurements]);
|
|
49
|
+
useResizeObserver(sliderElementRef, updateMeasurements);
|
|
43
50
|
var isNearHandle = useCallback(function (index) {
|
|
44
51
|
var markArea = markAreas[index];
|
|
45
52
|
if (!markArea || !sliderWidth) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-slider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.12",
|
|
4
4
|
"description": "Slider UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
24
|
"pack:ci": "pnpm pack --pack-destination ../../storybook/storybook-static/static",
|
|
25
25
|
"prepublish": "pnpm run build",
|
|
26
|
-
"test": "vitest",
|
|
27
|
-
"test:watch": "
|
|
26
|
+
"test": "vitest run",
|
|
27
|
+
"test:watch": "vitest",
|
|
28
28
|
"types": "tsc --noEmit",
|
|
29
29
|
"check:circular-dependencies": "madge --circular --extensions ts,tsx,js,jsx --ts-config tsconfig.json src/ --exclude '/dist/'",
|
|
30
30
|
"upgrade:ds": "ncu -f \"@synerise/ds-*\" -u"
|
|
@@ -35,9 +35,10 @@
|
|
|
35
35
|
],
|
|
36
36
|
"types": "dist/index.d.ts",
|
|
37
37
|
"dependencies": {
|
|
38
|
-
"@synerise/ds-form-field": "^1.3.
|
|
39
|
-
"@synerise/ds-tooltip": "^1.4.
|
|
40
|
-
"@synerise/ds-typography": "^1.1.
|
|
38
|
+
"@synerise/ds-form-field": "^1.3.9",
|
|
39
|
+
"@synerise/ds-tooltip": "^1.4.9",
|
|
40
|
+
"@synerise/ds-typography": "^1.1.12",
|
|
41
|
+
"@synerise/ds-utils": "^1.7.0",
|
|
41
42
|
"@tanstack/react-ranger": "^0.0.5"
|
|
42
43
|
},
|
|
43
44
|
"devDependencies": {
|
|
@@ -50,5 +51,5 @@
|
|
|
50
51
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
51
52
|
"styled-components": "^5.3.3"
|
|
52
53
|
},
|
|
53
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "8efc031fa688c0b87c7b3915bae93546bb63bcac"
|
|
54
55
|
}
|