@synerise/ds-slider 1.1.25 → 1.1.27
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 +8 -0
- package/CLAUDE.md +156 -0
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,14 @@
|
|
|
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.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.26...@synerise/ds-slider@1.1.27) (2026-07-23)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
## [1.1.26](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.25...@synerise/ds-slider@1.1.26) (2026-06-17)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
13
|
+
|
|
6
14
|
## [1.1.25](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.24...@synerise/ds-slider@1.1.25) (2026-06-11)
|
|
7
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-slider
|
package/CLAUDE.md
ADDED
|
@@ -0,0 +1,156 @@
|
|
|
1
|
+
# Slider (`@synerise/ds-slider`)
|
|
2
|
+
|
|
3
|
+
> A polymorphic slider component that renders a default single-value slider, a range (dual-thumb) slider, or an allocation slider based on discriminated union props. Built on `@tanstack/react-ranger` — **not** Ant Design Slider.
|
|
4
|
+
|
|
5
|
+
## Package structure
|
|
6
|
+
|
|
7
|
+
```
|
|
8
|
+
src/
|
|
9
|
+
Slider.tsx — dispatcher; picks DefaultSlider / RangeSlider / AllocationSlider
|
|
10
|
+
Slider.types.ts — all types (SliderProps union, AllocationConfig, etc.)
|
|
11
|
+
Slider.styles.ts — shared styled-components
|
|
12
|
+
Slider.spec.tsx — Vitest tests
|
|
13
|
+
context/
|
|
14
|
+
SliderContext.tsx — SliderContext providing rangerInstance + rangerHandles
|
|
15
|
+
components/
|
|
16
|
+
DefaultSlider.tsx — single-value slider
|
|
17
|
+
RangeSlider.tsx — dual-thumb range slider
|
|
18
|
+
AllocationSlider.tsx — allocation/percentage slider
|
|
19
|
+
SliderLine.tsx — track line
|
|
20
|
+
SliderAbove.tsx — label + description above the slider
|
|
21
|
+
SliderHandles.tsx — thumb handles with tooltips
|
|
22
|
+
SliderDots.tsx — step dots
|
|
23
|
+
SliderMarks.tsx — mark labels
|
|
24
|
+
SliderSections.tsx — coloured track sections
|
|
25
|
+
AllocationMarks.tsx — allocation variant marks
|
|
26
|
+
hooks/
|
|
27
|
+
useColorMap.ts — derives track colour from tracksColorMap
|
|
28
|
+
useInvertedColors.ts — computes inverted colour state
|
|
29
|
+
utils/
|
|
30
|
+
Slider.utils.ts
|
|
31
|
+
Slider.interpolators.ts
|
|
32
|
+
allocation.utils.tsx
|
|
33
|
+
allocationHandlers.utils.ts
|
|
34
|
+
index.ts — public exports (re-exports all from Slider.types)
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
## Public exports
|
|
38
|
+
|
|
39
|
+
### `Slider` (default export)
|
|
40
|
+
|
|
41
|
+
Discriminated union dispatcher. Choose mode by props:
|
|
42
|
+
|
|
43
|
+
| Mode | Discriminant | Props type |
|
|
44
|
+
|------|-------------|-----------|
|
|
45
|
+
| Default (single value) | neither `range` nor `type="allocation"` | `DefaultSliderProps` |
|
|
46
|
+
| Range (dual thumb) | `range: true` | `RangeSliderProps` |
|
|
47
|
+
| Allocation | `type: 'allocation'` | `AllocationSliderProps` |
|
|
48
|
+
|
|
49
|
+
#### Shared props (`SharedSliderProps`)
|
|
50
|
+
|
|
51
|
+
| Prop | Type | Default | Description |
|
|
52
|
+
|------|------|---------|-------------|
|
|
53
|
+
| `label` | `ReactNode` | — | Label above the slider |
|
|
54
|
+
| `description` | `ReactNode` | — | Description text |
|
|
55
|
+
| `disabled` | `boolean` | — | Disables interaction |
|
|
56
|
+
| `step` | `number` | — | Step increment |
|
|
57
|
+
| `dots` | `boolean` | — | Show dots at step positions (not recommended for small step values) |
|
|
58
|
+
| `thick` | `boolean` | — | Thicker track variant |
|
|
59
|
+
| `autoFocus` | `boolean` | — | Focus on mount |
|
|
60
|
+
| `tracksColorMap` | `ColorMap` (`Record<number, string>`) | — | Custom colour map for track sections |
|
|
61
|
+
|
|
62
|
+
#### Base props (`BaseSliderProps`) — for Default and Range modes
|
|
63
|
+
|
|
64
|
+
| Prop | Type | Default | Description |
|
|
65
|
+
|------|------|---------|-------------|
|
|
66
|
+
| `min` | `number` | — | Minimum value |
|
|
67
|
+
| `max` | `number` | — | Maximum value |
|
|
68
|
+
| `marks` | `SliderMarks` | — | Tick marks: `Record<string \| number, ReactNode \| MarkObj>` |
|
|
69
|
+
| `inverted` | `boolean` | — | Invert track fill direction |
|
|
70
|
+
| `reverse` | `boolean` | — | Render right-to-left |
|
|
71
|
+
| `tipFormatter` | `((value?: number) => ReactNode) \| false` | — | Custom tooltip formatter; `false` hides tooltip |
|
|
72
|
+
|
|
73
|
+
#### Default slider additional props
|
|
74
|
+
|
|
75
|
+
| Prop | Type | Description |
|
|
76
|
+
|------|------|-------------|
|
|
77
|
+
| `value` | `number` | Controlled value |
|
|
78
|
+
| `onChange` | `(value: number) => void` | Called on change |
|
|
79
|
+
| `onAfterChange` | `(value: number) => void` | Called on mouse/touch up |
|
|
80
|
+
|
|
81
|
+
#### Range slider additional props (requires `range: true`)
|
|
82
|
+
|
|
83
|
+
| Prop | Type | Description |
|
|
84
|
+
|------|------|-------------|
|
|
85
|
+
| `value` | `number[]` | Controlled range `[min, max]` |
|
|
86
|
+
| `onChange` | `(value: number[]) => void` | Called on change |
|
|
87
|
+
| `onAfterChange` | `(value: number[]) => void` | Called on mouse/touch up |
|
|
88
|
+
| `range` | `true` | **Required** discriminant |
|
|
89
|
+
|
|
90
|
+
#### Allocation slider props (requires `type: 'allocation'`)
|
|
91
|
+
|
|
92
|
+
| Prop | Type | Description |
|
|
93
|
+
|------|------|-------------|
|
|
94
|
+
| `type` | `'allocation'` | **Required** discriminant |
|
|
95
|
+
| `allocationConfig` | `AllocationConfig` | **Required** allocation configuration |
|
|
96
|
+
| `handlers` | `HandlerConfig` | Per-handle block config (`Record<number, { blocked, blockedTooltipProps? }>`) |
|
|
97
|
+
|
|
98
|
+
#### `AllocationConfig`
|
|
99
|
+
|
|
100
|
+
| Field | Type | Description |
|
|
101
|
+
|-------|------|-------------|
|
|
102
|
+
| `variants` | `AllocationVariant[]` | Allocation variants with `name`, `percentage`, `tabId`, `tabLetter`, `minPercentage?` |
|
|
103
|
+
| `onAllocationChange` | `(variants?: AllocationVariant[]) => void` | Called when percentages change |
|
|
104
|
+
| `controlGroupEnabled` | `boolean` | Treat remaining range as control group |
|
|
105
|
+
| `controlGroupLabel` | `ReactNode` | Label for control group |
|
|
106
|
+
| `controlGroupTooltip` | `ReactNode` | Tooltip for control group |
|
|
107
|
+
|
|
108
|
+
### Types exported
|
|
109
|
+
|
|
110
|
+
All types from `Slider.types.ts` are re-exported via `export * from './Slider.types'`:
|
|
111
|
+
`SliderProps`, `DefaultSliderProps`, `RangeSliderProps`, `AllocationSliderProps`, `BaseSliderProps`, `SharedSliderProps`, `AllocationConfig`, `AllocationVariant`, `ColorMap`, `ColorsOrder`, `HandlerConfig`, `SliderMarks`, `MarkObj`, `SliderType`, etc.
|
|
112
|
+
|
|
113
|
+
## Usage patterns
|
|
114
|
+
|
|
115
|
+
```tsx
|
|
116
|
+
import Slider from '@synerise/ds-slider';
|
|
117
|
+
|
|
118
|
+
// Default single-value
|
|
119
|
+
<Slider label="Volume" min={0} max={100} value={50} onChange={v => setValue(v)} />
|
|
120
|
+
|
|
121
|
+
// Range slider
|
|
122
|
+
<Slider range min={0} max={100} value={[20, 80]} onChange={v => setRange(v)} />
|
|
123
|
+
|
|
124
|
+
// Allocation slider
|
|
125
|
+
<Slider
|
|
126
|
+
type="allocation"
|
|
127
|
+
allocationConfig={{
|
|
128
|
+
variants: [
|
|
129
|
+
{ name: 'A', percentage: 50, tabId: 1, tabLetter: 'A' },
|
|
130
|
+
{ name: 'B', percentage: 50, tabId: 2, tabLetter: 'B' },
|
|
131
|
+
],
|
|
132
|
+
onAllocationChange: setVariants,
|
|
133
|
+
}}
|
|
134
|
+
/>
|
|
135
|
+
```
|
|
136
|
+
|
|
137
|
+
## Context / Provider
|
|
138
|
+
|
|
139
|
+
`SliderContext` provides `rangerInstance` (from `@tanstack/react-ranger`) and `rangerHandles` (ref map from index to DOM element) to child components (`SliderHandles`, `SliderSections`, etc.). The context is set up internally by each slider variant — no external Provider is needed.
|
|
140
|
+
|
|
141
|
+
## Key dependencies
|
|
142
|
+
|
|
143
|
+
- `@tanstack/react-ranger` — core ranger/slider logic (replaces Ant Design Slider)
|
|
144
|
+
- `@synerise/ds-form-field` — label/description wrapper
|
|
145
|
+
- `@synerise/ds-tooltip` — handle tooltips and blocked-handler tooltips
|
|
146
|
+
- `@synerise/ds-typography` — description text
|
|
147
|
+
- `@synerise/ds-utils` — resize observer utilities
|
|
148
|
+
|
|
149
|
+
## Implementation notes
|
|
150
|
+
|
|
151
|
+
- **Dispatch is by discriminated union**, not a `type` prop on a single component. TypeScript narrows the props type at the call site based on `range: true` or `type: 'allocation'`.
|
|
152
|
+
- **Not based on Ant Design Slider** — README references are outdated; the actual implementation uses `@tanstack/react-ranger`.
|
|
153
|
+
- **Uses Vitest** (`vitest.config.ts`) — migrated from Jest.
|
|
154
|
+
- `tracksColorMap` keys are numeric percentages/values; the hook `useColorMap` interpolates the colour for the current value.
|
|
155
|
+
- `inverted` only applies to `DefaultSliderProps` and `RangeSliderProps` (not allocation).
|
|
156
|
+
- `HandlerConfig` handler index starts at **1** (not 0).
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-slider",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.27",
|
|
4
4
|
"description": "Slider UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
"files": [
|
|
18
18
|
"/dist",
|
|
19
19
|
"CHANGELOG.md",
|
|
20
|
+
"CLAUDE.md",
|
|
20
21
|
"README.md",
|
|
21
22
|
"package.json",
|
|
22
23
|
"LICENSE.md"
|
|
@@ -41,10 +42,10 @@
|
|
|
41
42
|
],
|
|
42
43
|
"types": "dist/index.d.ts",
|
|
43
44
|
"dependencies": {
|
|
44
|
-
"@synerise/ds-form-field": "^1.3.
|
|
45
|
-
"@synerise/ds-tooltip": "^1.5.
|
|
46
|
-
"@synerise/ds-typography": "^1.1.
|
|
47
|
-
"@synerise/ds-utils": "^1.10.
|
|
45
|
+
"@synerise/ds-form-field": "^1.3.24",
|
|
46
|
+
"@synerise/ds-tooltip": "^1.5.4",
|
|
47
|
+
"@synerise/ds-typography": "^1.1.27",
|
|
48
|
+
"@synerise/ds-utils": "^1.10.2",
|
|
48
49
|
"@tanstack/react-ranger": "^0.0.5"
|
|
49
50
|
},
|
|
50
51
|
"devDependencies": {
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
58
59
|
"styled-components": "^5.3.3"
|
|
59
60
|
},
|
|
60
|
-
"gitHead": "
|
|
61
|
+
"gitHead": "d0a43cc43d8528a36f105aceea52ab470edb71d9"
|
|
61
62
|
}
|