@synerise/ds-slider 2.0.11 → 2.1.1
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 +19 -0
- package/CLAUDE.md +3 -0
- package/dist/Slider.styles.js +6 -5
- package/dist/Slider.types.d.ts +2 -1
- package/dist/components/AllocationMarks.styles.js +2 -1
- package/dist/components/SliderSections.js +2 -4
- package/dist/hooks/useInvertedColors.d.ts +1 -1
- package/dist/hooks/useInvertedColors.js +3 -3
- package/dist/utils/Slider.utils.d.ts +1 -0
- package/dist/utils/Slider.utils.js +10 -5
- package/package.json +7 -6
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
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
|
+
## [2.1.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@2.1.0...@synerise/ds-slider@2.1.1) (2026-11-03)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [2.1.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@2.0.11...@synerise/ds-slider@2.1.0) (2026-10-29)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* integrate Token Studio design tokens across the design system ([aabb447](https://github.com/Synerise/synerise-design/commit/aabb447edfb2d0c85e3de1f07e809ef84083453b))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [2.0.11](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@2.0.10...@synerise/ds-slider@2.0.11) (2026-10-28)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-slider
|
package/CLAUDE.md
CHANGED
|
@@ -145,6 +145,7 @@ import Slider from '@synerise/ds-slider';
|
|
|
145
145
|
- `@synerise/ds-tooltip` — handle tooltips and blocked-handler tooltips
|
|
146
146
|
- `@synerise/ds-typography` — description text
|
|
147
147
|
- `@synerise/ds-utils` — resize observer utilities
|
|
148
|
+
- `@synerise/ds-tokens` `orderedBase` (`/names` manifest) — the `ordered` categorical-colour queue used for allocation / 3+-handle track sections
|
|
148
149
|
|
|
149
150
|
## Implementation notes
|
|
150
151
|
|
|
@@ -152,5 +153,7 @@ import Slider from '@synerise/ds-slider';
|
|
|
152
153
|
- **Not based on Ant Design Slider** — README references are outdated; the actual implementation uses `@tanstack/react-ranger`.
|
|
153
154
|
- **Uses Vitest** (`vitest.config.ts`) — migrated from Jest.
|
|
154
155
|
- `tracksColorMap` keys are numeric percentages/values; the hook `useColorMap` interpolates the colour for the current value.
|
|
156
|
+
- **Chrome colours → `--ds-slider-*` module tokens** — rail (`track-bg-default/hover`), handle (`handle-bg-default/active/disabled`, `handle-border`), value tooltip (`value-bg-active`, `value-text-active/default`, `value-shadow-active`), allocation mark text (`tag-text`). The active-handle focus ring is `--ds-slider-handle-ring` (blue-500 at 25%).
|
|
157
|
+
- **Track fill colours** — `getDefaultColorMap` gives the default/2-handle track `var(--ds-slider-fill-default)` (success green), and allocation / 3+-handle tracks the `ordered` categorical slots (`orderedBase[i]`, opaque `var(--ds-color-ordered-<N>-base)` strings). A colour-map value is applied verbatim when it's already a token/hex (`isResolvedColor`); a palette key (`'blue-600'`) is mapped by `resolveTrackColor` to its **reversible custom-colour token** (`customColors[hue][shade]`, dark-mode aware) — **not** `theme.palette` (which is being retired). An unknown hue/shade or empty value falls back to a **predefined token** (never an undefined palette lookup). So a caller's custom `tracksColorMap` of palette keys still works and now flips in dark mode. `tracksColorMap` is the only prop that carries colour; the rail/inverted default is `--ds-slider-track-bg-default`.
|
|
155
158
|
- `inverted` only applies to `DefaultSliderProps` and `RangeSliderProps` (not allocation).
|
|
156
159
|
- `HandlerConfig` handler index starts at **1** (not 0).
|
package/dist/Slider.styles.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled, { css } from "styled-components";
|
|
2
|
+
import { resolveTrackColor } from "./utils/Slider.utils.js";
|
|
2
3
|
const SliderSection = /* @__PURE__ */ styled.div.withConfig({
|
|
3
4
|
displayName: "Sliderstyles__SliderSection",
|
|
4
5
|
componentId: "sc-1gtvqj9-0"
|
|
@@ -6,7 +7,7 @@ const SliderSection = /* @__PURE__ */ styled.div.withConfig({
|
|
|
6
7
|
const SliderLine = /* @__PURE__ */ styled.div.withConfig({
|
|
7
8
|
displayName: "Sliderstyles__SliderLine",
|
|
8
9
|
componentId: "sc-1gtvqj9-1"
|
|
9
|
-
})(["height:", ";background:", ";position:absolute;top:50%;width:100%;transform:translateY(-50%);z-index:10;border-radius:", ";", "{border-radius:", ";}"], (props) => `${props.thick ? "6" : "3"}px`, (props) => props.
|
|
10
|
+
})(["height:", ";background:", ";position:absolute;top:50%;width:100%;transform:translateY(-50%);z-index:10;border-radius:", ";", "{border-radius:", ";}"], (props) => `${props.thick ? "6" : "3"}px`, (props) => resolveTrackColor(props.lineColor, "var(--ds-slider-track-bg-default)"), (props) => `${props.thick ? "6" : "3"}px`, SliderSection, (props) => `${props.thick ? "6" : "3"}px`);
|
|
10
11
|
const SliderMarks = /* @__PURE__ */ styled.div.withConfig({
|
|
11
12
|
displayName: "Sliderstyles__SliderMarks",
|
|
12
13
|
componentId: "sc-1gtvqj9-2"
|
|
@@ -26,11 +27,11 @@ const SliderHandleWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
|
26
27
|
const SliderHandleValue = /* @__PURE__ */ styled.div.withConfig({
|
|
27
28
|
displayName: "Sliderstyles__SliderHandleValue",
|
|
28
29
|
componentId: "sc-1gtvqj9-6"
|
|
29
|
-
})(["position:absolute;top:16px;pointer-events:none;transform:translateX(-50%);padding:3px 8px;border-radius:3px;width:max-content;max-width:100px;overflow-wrap:break-word;", ""], (props) => props.isActive ? css(["box-shadow:
|
|
30
|
+
})(["position:absolute;top:16px;pointer-events:none;transform:translateX(-50%);padding:3px 8px;border-radius:3px;width:max-content;max-width:100px;overflow-wrap:break-word;", ""], (props) => props.isActive ? css(["box-shadow:var(--ds-slider-value-shadow-active);background-color:var(--ds-slider-value-bg-active);color:var(--ds-slider-value-text-active);"]) : css(["color:var(--ds-slider-value-text-default);"]));
|
|
30
31
|
const SliderHandle = /* @__PURE__ */ styled.button.withConfig({
|
|
31
32
|
displayName: "Sliderstyles__SliderHandle",
|
|
32
33
|
componentId: "sc-1gtvqj9-7"
|
|
33
|
-
})(["border:3px solid
|
|
34
|
+
})(["border:3px solid var(--ds-slider-handle-border);background:var(--ds-slider-handle-bg-default);position:absolute;transform:translate(-50%,-50%);width:20px;height:20px;outline:none;border-radius:100%;z-index:20;cursor:pointer;transition-property:background,box-shadow;transition-duration:0.3s;", ";", ";"], (props) => props.isActive && css(["&,&:hover{background:var(--ds-slider-handle-bg-active);cursor:grabbing;}box-shadow:0 0 0 3px var(--ds-slider-handle-ring);"]), (props) => (props.$disabled || props.$blocked) && css(["&,&:hover{background:var(--ds-slider-handle-bg-disabled);}box-shadow:none;"]));
|
|
34
35
|
const SliderBar = /* @__PURE__ */ styled.div.withConfig({
|
|
35
36
|
displayName: "Sliderstyles__SliderBar",
|
|
36
37
|
componentId: "sc-1gtvqj9-8"
|
|
@@ -38,11 +39,11 @@ const SliderBar = /* @__PURE__ */ styled.div.withConfig({
|
|
|
38
39
|
const SliderWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
39
40
|
displayName: "Sliderstyles__SliderWrapper",
|
|
40
41
|
componentId: "sc-1gtvqj9-9"
|
|
41
|
-
})(["display:flex;flex:1 0 auto;flex-direction:column;gap:16px;", " ", ""], (props) => props.withoutMarks && css(["padding-bottom:29px;"]), (props) => !props.$disabled && css(["", "{cursor:pointer;&:hover{background-color:
|
|
42
|
+
})(["display:flex;flex:1 0 auto;flex-direction:column;gap:16px;", " ", ""], (props) => props.withoutMarks && css(["padding-bottom:29px;"]), (props) => !props.$disabled && css(["", "{cursor:pointer;&:hover{background-color:var(--ds-slider-track-bg-hover);}}"], SliderLine));
|
|
42
43
|
const SliderDot = /* @__PURE__ */ styled.div.withConfig({
|
|
43
44
|
displayName: "Sliderstyles__SliderDot",
|
|
44
45
|
componentId: "sc-1gtvqj9-10"
|
|
45
|
-
})(["position:absolute;bottom:0;width:10px;height:10px;background:", ";border-radius:50%;border:3px solid
|
|
46
|
+
})(["position:absolute;bottom:0;width:10px;height:10px;background:", ";border-radius:50%;border:3px solid var(--ds-slider-handle-border);left:", "%;top:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;"], (props) => resolveTrackColor(props.$color, "var(--ds-slider-track-bg-default)"), (props) => props.$left);
|
|
46
47
|
const SliderLabel = /* @__PURE__ */ styled.div.withConfig({
|
|
47
48
|
displayName: "Sliderstyles__SliderLabel",
|
|
48
49
|
componentId: "sc-1gtvqj9-11"
|
package/dist/Slider.types.d.ts
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
|
+
import { CustomColorToken, LiteralStringUnion } from '@synerise/ds-utils';
|
|
3
4
|
type AllocationType = 'allocation';
|
|
4
5
|
export type SliderType = AllocationType | 'default';
|
|
5
|
-
export type ColorMap = Record<number,
|
|
6
|
+
export type ColorMap = Record<number, LiteralStringUnion<CustomColorToken>>;
|
|
6
7
|
export type ColorsOrder = string[];
|
|
7
8
|
export type HandlerConfig = Record<number, {
|
|
8
9
|
blocked: boolean;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import styled from "styled-components";
|
|
2
|
+
import { resolveTrackColor } from "../utils/Slider.utils.js";
|
|
2
3
|
const AllocationMarks = /* @__PURE__ */ styled.div.withConfig({
|
|
3
4
|
displayName: "AllocationMarksstyles__AllocationMarks",
|
|
4
5
|
componentId: "sc-k03cw7-0"
|
|
@@ -14,7 +15,7 @@ const MarkValue = /* @__PURE__ */ styled.div.withConfig({
|
|
|
14
15
|
const MarkLetter = /* @__PURE__ */ styled.div.withConfig({
|
|
15
16
|
displayName: "AllocationMarksstyles__MarkLetter",
|
|
16
17
|
componentId: "sc-k03cw7-3"
|
|
17
|
-
})(["border-radius:", ";width:25px;height:25px;display:inline-block;position:relative;text-align:center;line-height:25px;color:
|
|
18
|
+
})(["border-radius:", ";width:25px;height:25px;display:inline-block;position:relative;text-align:center;line-height:25px;color:var(--ds-slider-tag-text);background-color:", ";"], (props) => props.theme.variable("@border-radius-base"), (props) => resolveTrackColor(props.$color, "var(--ds-color-background-base-strong)"));
|
|
18
19
|
const MarkTooltipWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
19
20
|
displayName: "AllocationMarksstyles__MarkTooltipWrapper",
|
|
20
21
|
componentId: "sc-k03cw7-4"
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
-
import { useTheme } from "@synerise/ds-core";
|
|
3
2
|
import { useSliderContext } from "../context/SliderContext.js";
|
|
4
3
|
import { SliderSection } from "../Slider.styles.js";
|
|
5
|
-
import { getVisibleSectionsForType } from "../utils/Slider.utils.js";
|
|
4
|
+
import { getVisibleSectionsForType, resolveTrackColor } from "../utils/Slider.utils.js";
|
|
6
5
|
const normalizeReversed = (section, reverse) => {
|
|
7
6
|
return reverse ? {
|
|
8
7
|
width: -section.width,
|
|
@@ -14,14 +13,13 @@ const SliderSections = ({
|
|
|
14
13
|
type = "default",
|
|
15
14
|
reverse
|
|
16
15
|
}) => {
|
|
17
|
-
const theme = useTheme();
|
|
18
16
|
const {
|
|
19
17
|
rangerInstance
|
|
20
18
|
} = useSliderContext();
|
|
21
19
|
const steps = rangerInstance.getSteps();
|
|
22
20
|
return /* @__PURE__ */ jsx(Fragment, { children: steps.filter(getVisibleSectionsForType(type, steps.length)).map((section, index) => {
|
|
23
21
|
const normalisedSection = normalizeReversed(section, reverse);
|
|
24
|
-
return /* @__PURE__ */ jsx(SliderSection, { "data-testid": `ds-slider-section`, "data-index": index, $left: normalisedSection.left, $width: normalisedSection.width, "data-color": tracksColorMap[index], $color:
|
|
22
|
+
return /* @__PURE__ */ jsx(SliderSection, { "data-testid": `ds-slider-section`, "data-index": index, $left: normalisedSection.left, $width: normalisedSection.width, "data-color": tracksColorMap[index], $color: resolveTrackColor(tracksColorMap[index], "var(--ds-slider-fill-default)") }, `slider-section-${index}`);
|
|
25
23
|
}) });
|
|
26
24
|
};
|
|
27
25
|
export {
|
|
@@ -2,10 +2,10 @@ const useInvertedColors = ({
|
|
|
2
2
|
inverted,
|
|
3
3
|
colorMap
|
|
4
4
|
}) => {
|
|
5
|
-
const
|
|
6
|
-
const lineColor = inverted ? colorMap[0] :
|
|
5
|
+
const DEFAULT_RAIL_COLOR = "var(--ds-slider-track-bg-default)";
|
|
6
|
+
const lineColor = inverted ? colorMap[0] : DEFAULT_RAIL_COLOR;
|
|
7
7
|
const tracksColorMap = inverted ? {
|
|
8
|
-
0:
|
|
8
|
+
0: DEFAULT_RAIL_COLOR
|
|
9
9
|
} : colorMap;
|
|
10
10
|
return {
|
|
11
11
|
lineColor,
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { ReactNode } from 'react';
|
|
2
2
|
import { ColorMap, MarkObj } from '../Slider.types';
|
|
3
3
|
export declare const getDefaultTooltipPopupContainer: () => HTMLElement;
|
|
4
|
+
export declare const resolveTrackColor: (value: string | undefined, fallback: string) => string;
|
|
4
5
|
export declare const couldBeInverted: (value: number | readonly number[], inverted?: boolean) => boolean;
|
|
5
6
|
export declare const getDefaultColorMap: (handleCount: number, type: "default" | "allocation" | "range") => ColorMap;
|
|
6
7
|
export declare const isMarksObjType: (item: MarkObj | ReactNode) => item is MarkObj;
|
|
@@ -1,13 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { orderedBase } from "@synerise/ds-tokens/names";
|
|
2
|
+
import { resolveCustomColor } from "@synerise/ds-utils";
|
|
2
3
|
const getDefaultTooltipPopupContainer = () => document.querySelector(`.ant-slider`);
|
|
4
|
+
const resolveTrackColor = (value, fallback) => resolveCustomColor(value, fallback, {
|
|
5
|
+
passthroughResolved: true
|
|
6
|
+
});
|
|
3
7
|
const couldBeInverted = (value, inverted) => Boolean(inverted && (typeof value === "number" || value.length < 3));
|
|
4
8
|
const getDefaultColorMap = (handleCount, type) => {
|
|
5
9
|
const colorMap = {};
|
|
6
10
|
if (type !== "allocation" && handleCount <= 2) {
|
|
7
|
-
colorMap["0"] = "
|
|
11
|
+
colorMap["0"] = "var(--ds-slider-fill-default)";
|
|
8
12
|
} else {
|
|
9
|
-
|
|
10
|
-
colorMap[index] =
|
|
13
|
+
orderedBase.forEach((token, index) => {
|
|
14
|
+
colorMap[index] = token;
|
|
11
15
|
});
|
|
12
16
|
}
|
|
13
17
|
return colorMap;
|
|
@@ -48,5 +52,6 @@ export {
|
|
|
48
52
|
getDefaultTooltipPopupContainer,
|
|
49
53
|
getTranslateX,
|
|
50
54
|
getVisibleSectionsForType,
|
|
51
|
-
isMarksObjType
|
|
55
|
+
isMarksObjType,
|
|
56
|
+
resolveTrackColor
|
|
52
57
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-slider",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.1.1",
|
|
4
4
|
"description": "Slider UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -42,10 +42,11 @@
|
|
|
42
42
|
],
|
|
43
43
|
"types": "dist/index.d.ts",
|
|
44
44
|
"dependencies": {
|
|
45
|
-
"@synerise/ds-form-field": "^2.
|
|
46
|
-
"@synerise/ds-
|
|
47
|
-
"@synerise/ds-
|
|
48
|
-
"@synerise/ds-
|
|
45
|
+
"@synerise/ds-form-field": "^2.1.1",
|
|
46
|
+
"@synerise/ds-tokens": "^2.1.1",
|
|
47
|
+
"@synerise/ds-tooltip": "^2.1.1",
|
|
48
|
+
"@synerise/ds-typography": "^2.1.1",
|
|
49
|
+
"@synerise/ds-utils": "^2.3.1",
|
|
49
50
|
"@tanstack/react-ranger": "^0.0.5"
|
|
50
51
|
},
|
|
51
52
|
"devDependencies": {
|
|
@@ -58,5 +59,5 @@
|
|
|
58
59
|
"react-intl": ">=3.12.0 <= 6.8",
|
|
59
60
|
"styled-components": "^5.3.3"
|
|
60
61
|
},
|
|
61
|
-
"gitHead": "
|
|
62
|
+
"gitHead": "2d2a540b35fddf8855da45f0dec2f4612c6d87b6"
|
|
62
63
|
}
|