@synerise/ds-slider 1.1.11 → 1.1.13
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/README.md +29 -49
- package/dist/Slider.d.ts +2 -2
- package/dist/Slider.js +15 -13
- package/dist/Slider.styles.d.ts +12 -12
- package/dist/Slider.styles.js +37 -67
- package/dist/Slider.types.d.ts +2 -2
- package/dist/Slider.types.js +1 -1
- package/dist/components/AllocationMarks.d.ts +2 -2
- package/dist/components/AllocationMarks.js +37 -42
- package/dist/components/AllocationMarks.styles.d.ts +5 -5
- package/dist/components/AllocationMarks.styles.js +16 -17
- package/dist/components/AllocationSlider.d.ts +2 -2
- package/dist/components/AllocationSlider.js +65 -88
- package/dist/components/DefaultSlider.d.ts +2 -2
- package/dist/components/DefaultSlider.js +58 -79
- package/dist/components/RangeSlider.d.ts +2 -2
- package/dist/components/RangeSlider.js +63 -88
- package/dist/components/SliderAbove.d.ts +1 -1
- package/dist/components/SliderAbove.js +15 -14
- package/dist/components/SliderDots.d.ts +2 -2
- package/dist/components/SliderDots.js +28 -31
- package/dist/components/SliderHandles.d.ts +2 -2
- package/dist/components/SliderHandles.js +36 -54
- package/dist/components/SliderLine.d.ts +2 -2
- package/dist/components/SliderLine.js +34 -46
- package/dist/components/SliderMarks.d.ts +2 -2
- package/dist/components/SliderMarks.js +48 -64
- package/dist/components/SliderSections.d.ts +2 -2
- package/dist/components/SliderSections.js +24 -28
- package/dist/context/SliderContext.d.ts +2 -2
- package/dist/context/SliderContext.js +20 -16
- package/dist/hooks/useColorMap.d.ts +1 -1
- package/dist/hooks/useColorMap.js +8 -5
- package/dist/hooks/useInvertedColors.d.ts +1 -1
- package/dist/hooks/useInvertedColors.js +13 -9
- package/dist/index.js +4 -2
- package/dist/modules.d.js +1 -1
- package/dist/modules.d.ts +0 -0
- package/dist/utils/Slider.interpolators.d.ts +1 -1
- package/dist/utils/Slider.interpolators.js +10 -16
- package/dist/utils/Slider.utils.d.ts +2 -2
- package/dist/utils/Slider.utils.js +36 -33
- package/dist/utils/allocation.utils.d.ts +2 -2
- package/dist/utils/allocation.utils.js +30 -63
- package/dist/utils/allocationHandlers.utils.d.ts +1 -1
- package/dist/utils/allocationHandlers.utils.js +17 -18
- package/package.json +10 -10
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.13](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.12...@synerise/ds-slider@1.1.13) (2026-03-24)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
## [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)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
13
|
+
|
|
6
14
|
## [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)
|
|
7
15
|
|
|
8
16
|
### Bug Fixes
|
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` |
|
package/dist/Slider.d.ts
CHANGED
package/dist/Slider.js
CHANGED
|
@@ -1,20 +1,22 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { AllocationSlider } from
|
|
3
|
-
import { DefaultSlider } from
|
|
4
|
-
import { RangeSlider } from
|
|
5
|
-
|
|
6
|
-
return
|
|
1
|
+
import { jsx } from "react/jsx-runtime";
|
|
2
|
+
import { AllocationSlider } from "./components/AllocationSlider.js";
|
|
3
|
+
import { DefaultSlider } from "./components/DefaultSlider.js";
|
|
4
|
+
import { RangeSlider } from "./components/RangeSlider.js";
|
|
5
|
+
const isRangeSlider = (props) => {
|
|
6
|
+
return "range" in props && props.range;
|
|
7
7
|
};
|
|
8
|
-
|
|
9
|
-
return
|
|
8
|
+
const isAllocationSlider = (props) => {
|
|
9
|
+
return "type" in props && props.type === "allocation";
|
|
10
10
|
};
|
|
11
|
-
|
|
11
|
+
const Slider = (props) => {
|
|
12
12
|
if (isAllocationSlider(props)) {
|
|
13
|
-
return
|
|
13
|
+
return /* @__PURE__ */ jsx(AllocationSlider, { ...props });
|
|
14
14
|
}
|
|
15
15
|
if (isRangeSlider(props)) {
|
|
16
|
-
return
|
|
16
|
+
return /* @__PURE__ */ jsx(RangeSlider, { ...props });
|
|
17
17
|
}
|
|
18
|
-
return
|
|
18
|
+
return /* @__PURE__ */ jsx(DefaultSlider, { ...props });
|
|
19
|
+
};
|
|
20
|
+
export {
|
|
21
|
+
Slider as default
|
|
19
22
|
};
|
|
20
|
-
export default Slider;
|
package/dist/Slider.styles.d.ts
CHANGED
|
@@ -1,41 +1,41 @@
|
|
|
1
|
-
export declare const SliderSection: import(
|
|
1
|
+
export declare const SliderSection: import('styled-components').StyledComponent<"div", any, {
|
|
2
2
|
$left: number;
|
|
3
3
|
$width: number;
|
|
4
4
|
$color: string;
|
|
5
5
|
}, never>;
|
|
6
|
-
export declare const SliderLine: import(
|
|
6
|
+
export declare const SliderLine: import('styled-components').StyledComponent<"div", any, {
|
|
7
7
|
thick?: boolean;
|
|
8
8
|
lineColor?: string;
|
|
9
9
|
}, never>;
|
|
10
|
-
export declare const SliderMarks: import(
|
|
11
|
-
export declare const SliderMark: import(
|
|
10
|
+
export declare const SliderMarks: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const SliderMark: import('styled-components').StyledComponent<"div", any, {
|
|
12
12
|
$left: number;
|
|
13
13
|
isNear: boolean;
|
|
14
14
|
}, never>;
|
|
15
|
-
export declare const EventTrap: import(
|
|
16
|
-
export declare const SliderHandleWrapper: import(
|
|
15
|
+
export declare const EventTrap: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const SliderHandleWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
17
17
|
$left: number;
|
|
18
18
|
isActive?: boolean;
|
|
19
19
|
$disabled?: boolean;
|
|
20
20
|
$blocked?: boolean;
|
|
21
21
|
}, never>;
|
|
22
|
-
export declare const SliderHandleValue: import(
|
|
22
|
+
export declare const SliderHandleValue: import('styled-components').StyledComponent<"div", any, {
|
|
23
23
|
isActive?: boolean;
|
|
24
24
|
}, never>;
|
|
25
|
-
export declare const SliderHandle: import(
|
|
25
|
+
export declare const SliderHandle: import('styled-components').StyledComponent<"button", any, {
|
|
26
26
|
isActive?: boolean;
|
|
27
27
|
$disabled?: boolean;
|
|
28
28
|
$blocked?: boolean;
|
|
29
29
|
}, never>;
|
|
30
|
-
export declare const SliderBar: import(
|
|
30
|
+
export declare const SliderBar: import('styled-components').StyledComponent<"div", any, {
|
|
31
31
|
$type: "allocation" | "default" | "range";
|
|
32
32
|
}, never>;
|
|
33
|
-
export declare const SliderWrapper: import(
|
|
33
|
+
export declare const SliderWrapper: import('styled-components').StyledComponent<"div", any, {
|
|
34
34
|
$disabled?: boolean;
|
|
35
35
|
withoutMarks?: boolean;
|
|
36
36
|
}, never>;
|
|
37
|
-
export declare const SliderDot: import(
|
|
37
|
+
export declare const SliderDot: import('styled-components').StyledComponent<"div", any, {
|
|
38
38
|
$left: number;
|
|
39
39
|
$color?: string;
|
|
40
40
|
}, never>;
|
|
41
|
-
export declare const SliderLabel: import(
|
|
41
|
+
export declare const SliderLabel: import('styled-components').StyledComponent<"div", any, {}, never>;
|
package/dist/Slider.styles.js
CHANGED
|
@@ -1,93 +1,63 @@
|
|
|
1
|
-
import styled, { css } from
|
|
2
|
-
|
|
1
|
+
import styled, { css } from "styled-components";
|
|
2
|
+
const SliderSection = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "Sliderstyles__SliderSection",
|
|
4
4
|
componentId: "sc-1gtvqj9-0"
|
|
5
|
-
})(["left:", "%;width:", "%;position:absolute;height:100%;background:", ";"],
|
|
6
|
-
|
|
7
|
-
}, function (props) {
|
|
8
|
-
return props.$width;
|
|
9
|
-
}, function (props) {
|
|
10
|
-
return props.$color;
|
|
11
|
-
});
|
|
12
|
-
export var SliderLine = styled.div.withConfig({
|
|
5
|
+
})(["left:", "%;width:", "%;position:absolute;height:100%;background:", ";"], (props) => props.$left, (props) => props.$width, (props) => props.$color);
|
|
6
|
+
const SliderLine = /* @__PURE__ */ styled.div.withConfig({
|
|
13
7
|
displayName: "Sliderstyles__SliderLine",
|
|
14
8
|
componentId: "sc-1gtvqj9-1"
|
|
15
|
-
})(["height:", ";background:", ";position:absolute;top:50%;width:100%;transform:translateY(-50%);z-index:10;border-radius:", ";", "{border-radius:", ";}"],
|
|
16
|
-
|
|
17
|
-
}, function (props) {
|
|
18
|
-
return props.theme.palette[props.lineColor || 'grey-200'];
|
|
19
|
-
}, function (props) {
|
|
20
|
-
return (props.thick ? '6' : '3') + "px";
|
|
21
|
-
}, SliderSection, function (props) {
|
|
22
|
-
return (props.thick ? '6' : '3') + "px";
|
|
23
|
-
});
|
|
24
|
-
export var SliderMarks = styled.div.withConfig({
|
|
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.theme.palette[props.lineColor || "grey-200"], (props) => `${props.thick ? "6" : "3"}px`, SliderSection, (props) => `${props.thick ? "6" : "3"}px`);
|
|
10
|
+
const SliderMarks = /* @__PURE__ */ styled.div.withConfig({
|
|
25
11
|
displayName: "Sliderstyles__SliderMarks",
|
|
26
12
|
componentId: "sc-1gtvqj9-2"
|
|
27
13
|
})(["position:relative;height:18px;margin-top:-5px;&:empty{display:none;}"]);
|
|
28
|
-
|
|
14
|
+
const SliderMark = /* @__PURE__ */ styled.div.withConfig({
|
|
29
15
|
displayName: "Sliderstyles__SliderMark",
|
|
30
16
|
componentId: "sc-1gtvqj9-3"
|
|
31
|
-
})(["position:absolute;bottom:0;left:", "%;transform:translateX( ", "% );z-index:10;", " width:max-content;max-width:100px;overflow-wrap:break-word;"],
|
|
32
|
-
|
|
33
|
-
}, function (props) {
|
|
34
|
-
return props.$left < 1 ? '0' : props.$left > 99 ? '-100' : '-50';
|
|
35
|
-
}, function (props) {
|
|
36
|
-
return props.isNear && "visibility: hidden;";
|
|
37
|
-
});
|
|
38
|
-
export var EventTrap = styled.div.withConfig({
|
|
17
|
+
})(["position:absolute;bottom:0;left:", "%;transform:translateX( ", "% );z-index:10;", " width:max-content;max-width:100px;overflow-wrap:break-word;"], (props) => props.$left, (props) => props.$left < 1 ? "0" : props.$left > 99 ? "-100" : "-50", (props) => props.isNear && `visibility: hidden;`);
|
|
18
|
+
const EventTrap = /* @__PURE__ */ styled.div.withConfig({
|
|
39
19
|
displayName: "Sliderstyles__EventTrap",
|
|
40
20
|
componentId: "sc-1gtvqj9-4"
|
|
41
21
|
})(["display:contents:"]);
|
|
42
|
-
|
|
22
|
+
const SliderHandleWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
43
23
|
displayName: "Sliderstyles__SliderHandleWrapper",
|
|
44
24
|
componentId: "sc-1gtvqj9-5"
|
|
45
|
-
})(["position:absolute;top:50%;left:", "%;z-index:20;"],
|
|
46
|
-
|
|
47
|
-
});
|
|
48
|
-
export var SliderHandleValue = styled.div.withConfig({
|
|
25
|
+
})(["position:absolute;top:50%;left:", "%;z-index:20;"], (props) => props.$left);
|
|
26
|
+
const SliderHandleValue = /* @__PURE__ */ styled.div.withConfig({
|
|
49
27
|
displayName: "Sliderstyles__SliderHandleValue",
|
|
50
28
|
componentId: "sc-1gtvqj9-6"
|
|
51
|
-
})(["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;", ""],
|
|
52
|
-
|
|
53
|
-
});
|
|
54
|
-
export var SliderHandle = styled.button.withConfig({
|
|
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:", ";background-color:rgba(56,67,80,0.9);color:", ";"], props.theme.variables["box-shadow-2"], props.theme.palette["white"]) : css(["color:", ";"], props.theme.palette["grey-800"]));
|
|
30
|
+
const SliderHandle = /* @__PURE__ */ styled.button.withConfig({
|
|
55
31
|
displayName: "Sliderstyles__SliderHandle",
|
|
56
32
|
componentId: "sc-1gtvqj9-7"
|
|
57
|
-
})(["border:3px solid ", ";background:", ";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;", ";", ";"],
|
|
58
|
-
|
|
59
|
-
}, function (props) {
|
|
60
|
-
return props.theme.palette['grey-400'];
|
|
61
|
-
}, function (props) {
|
|
62
|
-
return props.isActive && css(["&,&:hover{background:", ";cursor:grabbing;}box-shadow:0 0 0 3px rgba(35,138,254,0.25);"], props.theme.palette['blue-600']);
|
|
63
|
-
}, function (props) {
|
|
64
|
-
return (props.$disabled || props.$blocked) && css(["&,&:hover{background:", ";}box-shadow:none;"], props.theme.palette['grey-300']);
|
|
65
|
-
});
|
|
66
|
-
export var SliderBar = styled.div.withConfig({
|
|
33
|
+
})(["border:3px solid ", ";background:", ";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.theme.palette.white, (props) => props.theme.palette["grey-400"], (props) => props.isActive && css(["&,&:hover{background:", ";cursor:grabbing;}box-shadow:0 0 0 3px rgba(35,138,254,0.25);"], props.theme.palette["blue-600"]), (props) => (props.$disabled || props.$blocked) && css(["&,&:hover{background:", ";}box-shadow:none;"], props.theme.palette["grey-300"]));
|
|
34
|
+
const SliderBar = /* @__PURE__ */ styled.div.withConfig({
|
|
67
35
|
displayName: "Sliderstyles__SliderBar",
|
|
68
36
|
componentId: "sc-1gtvqj9-8"
|
|
69
|
-
})(["position:relative;user-select:none;height:20px;", ""],
|
|
70
|
-
|
|
71
|
-
});
|
|
72
|
-
export var SliderWrapper = styled.div.withConfig({
|
|
37
|
+
})(["position:relative;user-select:none;height:20px;", ""], (props) => props.$type === "allocation" && css(["margin-top:48px;"]));
|
|
38
|
+
const SliderWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
73
39
|
displayName: "Sliderstyles__SliderWrapper",
|
|
74
40
|
componentId: "sc-1gtvqj9-9"
|
|
75
|
-
})(["display:flex;flex:1 0 auto;flex-direction:column;gap:16px;", " ", ""],
|
|
76
|
-
|
|
77
|
-
}, function (props) {
|
|
78
|
-
return !props.$disabled && css(["", "{cursor:pointer;&:hover{background-color:", ";}}"], SliderLine, props.theme.palette['grey-300']);
|
|
79
|
-
});
|
|
80
|
-
export var SliderDot = styled.div.withConfig({
|
|
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:", ";}}"], SliderLine, props.theme.palette["grey-300"]));
|
|
42
|
+
const SliderDot = /* @__PURE__ */ styled.div.withConfig({
|
|
81
43
|
displayName: "Sliderstyles__SliderDot",
|
|
82
44
|
componentId: "sc-1gtvqj9-10"
|
|
83
|
-
})(["position:absolute;bottom:0;width:10px;height:10px;background:", ";border-radius:50%;border:3px solid ", ";left:", "%;top:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;"],
|
|
84
|
-
|
|
85
|
-
}, function (props) {
|
|
86
|
-
return props.theme.palette.white;
|
|
87
|
-
}, function (props) {
|
|
88
|
-
return props.$left;
|
|
89
|
-
});
|
|
90
|
-
export var SliderLabel = styled.div.withConfig({
|
|
45
|
+
})(["position:absolute;bottom:0;width:10px;height:10px;background:", ";border-radius:50%;border:3px solid ", ";left:", "%;top:50%;transform:translate(-50%,-50%);pointer-events:none;z-index:10;"], (props) => props.theme.palette[props.$color || "grey-200"], (props) => props.theme.palette.white, (props) => props.$left);
|
|
46
|
+
const SliderLabel = /* @__PURE__ */ styled.div.withConfig({
|
|
91
47
|
displayName: "Sliderstyles__SliderLabel",
|
|
92
48
|
componentId: "sc-1gtvqj9-11"
|
|
93
|
-
})(["display:flex;flex-direction:column;gap:8px;"]);
|
|
49
|
+
})(["display:flex;flex-direction:column;gap:8px;"]);
|
|
50
|
+
export {
|
|
51
|
+
EventTrap,
|
|
52
|
+
SliderBar,
|
|
53
|
+
SliderDot,
|
|
54
|
+
SliderHandle,
|
|
55
|
+
SliderHandleValue,
|
|
56
|
+
SliderHandleWrapper,
|
|
57
|
+
SliderLabel,
|
|
58
|
+
SliderLine,
|
|
59
|
+
SliderMark,
|
|
60
|
+
SliderMarks,
|
|
61
|
+
SliderSection,
|
|
62
|
+
SliderWrapper
|
|
63
|
+
};
|
package/dist/Slider.types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
import { TooltipProps } from '@synerise/ds-tooltip';
|
|
3
3
|
type AllocationType = 'allocation';
|
|
4
4
|
export type SliderType = AllocationType | 'default';
|
|
5
5
|
export type ColorMap = Record<number, string>;
|
package/dist/Slider.types.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AllocationConfig, AllocationVariant, ColorMap } from '../Slider.types';
|
|
3
3
|
type AllocationMarksProps = AllocationConfig & {
|
|
4
4
|
allocations: number[];
|
|
5
5
|
variants: AllocationVariant[];
|
|
@@ -1,42 +1,37 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { useIntl } from
|
|
3
|
-
import Tooltip from
|
|
4
|
-
import { useSliderContext } from
|
|
5
|
-
import
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
},
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
$left: section.left,
|
|
39
|
-
$width: section.width
|
|
40
|
-
}, renderMark(allocations[index], index, variants || []));
|
|
41
|
-
}));
|
|
42
|
-
};
|
|
1
|
+
import { jsx, jsxs, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import { useIntl } from "react-intl";
|
|
3
|
+
import Tooltip from "@synerise/ds-tooltip";
|
|
4
|
+
import { useSliderContext } from "../context/SliderContext.js";
|
|
5
|
+
import { AllocationMarks as AllocationMarks$1, AllocationMark, MarkLetter, MarkTooltipWrapper, MarkValue } from "./AllocationMarks.styles.js";
|
|
6
|
+
const AllocationMarks = ({
|
|
7
|
+
controlGroupTooltip,
|
|
8
|
+
controlGroupLabel,
|
|
9
|
+
allocations,
|
|
10
|
+
variants,
|
|
11
|
+
tracksColorMap
|
|
12
|
+
}) => {
|
|
13
|
+
const intl = useIntl();
|
|
14
|
+
const {
|
|
15
|
+
rangerInstance
|
|
16
|
+
} = useSliderContext();
|
|
17
|
+
const renderMark = (value, index, allocationVariants) => /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
18
|
+
allocationVariants[index] && /* @__PURE__ */ jsx(Tooltip, { title: /* @__PURE__ */ jsx(MarkTooltipWrapper, { children: allocationVariants[index].tabLetter }), children: /* @__PURE__ */ jsx(MarkLetter, { className: `ant-slider-segment-letter-${index}`, $color: tracksColorMap[index], children: allocationVariants[index].tabLetter }) }),
|
|
19
|
+
!allocationVariants[index] && /* @__PURE__ */ jsx(Tooltip, { title: controlGroupTooltip || intl.formatMessage({
|
|
20
|
+
id: "DS.SLIDER.CONTROL-GROUP",
|
|
21
|
+
defaultMessage: "Control group"
|
|
22
|
+
}), children: /* @__PURE__ */ jsx(MarkLetter, { $color: tracksColorMap[index], children: controlGroupLabel || intl.formatMessage({
|
|
23
|
+
id: "DS.SLIDER.CONTROL-GROUP-TOOLTIP",
|
|
24
|
+
defaultMessage: "CG"
|
|
25
|
+
}) }) }),
|
|
26
|
+
/* @__PURE__ */ jsxs(MarkValue, { children: [
|
|
27
|
+
value,
|
|
28
|
+
"%"
|
|
29
|
+
] })
|
|
30
|
+
] });
|
|
31
|
+
return /* @__PURE__ */ jsx(AllocationMarks$1, { "data-testid": "ds-allocation-marks", children: rangerInstance.getSteps().map((section, index) => {
|
|
32
|
+
return /* @__PURE__ */ jsx(AllocationMark, { $left: section.left, $width: section.width, children: renderMark(allocations[index], index, variants || []) }, `slider-allocation-mark-${index}`);
|
|
33
|
+
}) });
|
|
34
|
+
};
|
|
35
|
+
export {
|
|
36
|
+
AllocationMarks
|
|
37
|
+
};
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const AllocationMarks: import(
|
|
2
|
-
export declare const AllocationMark: import(
|
|
1
|
+
export declare const AllocationMarks: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const AllocationMark: import('styled-components').StyledComponent<"div", any, {
|
|
3
3
|
$left: number;
|
|
4
4
|
$width: number;
|
|
5
5
|
}, never>;
|
|
6
|
-
export declare const MarkValue: import(
|
|
7
|
-
export declare const MarkLetter: import(
|
|
6
|
+
export declare const MarkValue: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const MarkLetter: import('styled-components').StyledComponent<"div", any, {
|
|
8
8
|
$color?: string;
|
|
9
9
|
}, never>;
|
|
10
|
-
export declare const MarkTooltipWrapper: import(
|
|
10
|
+
export declare const MarkTooltipWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
|
|
@@ -1,29 +1,28 @@
|
|
|
1
|
-
import styled from
|
|
2
|
-
|
|
1
|
+
import styled from "styled-components";
|
|
2
|
+
const AllocationMarks = /* @__PURE__ */ styled.div.withConfig({
|
|
3
3
|
displayName: "AllocationMarksstyles__AllocationMarks",
|
|
4
4
|
componentId: "sc-k03cw7-0"
|
|
5
5
|
})(["height:40px;position:relative;margin-top:-16px;"]);
|
|
6
|
-
|
|
6
|
+
const AllocationMark = /* @__PURE__ */ styled.div.withConfig({
|
|
7
7
|
displayName: "AllocationMarksstyles__AllocationMark",
|
|
8
8
|
componentId: "sc-k03cw7-1"
|
|
9
|
-
})(["left:", "%;width:", "%;position:absolute;bottom:13px;height:80px;display:flex;flex-direction:column;justify-content:space-between;align-items:center;pointer-events:none;"],
|
|
10
|
-
|
|
11
|
-
}, function (props) {
|
|
12
|
-
return props.$width;
|
|
13
|
-
});
|
|
14
|
-
export var MarkValue = styled.div.withConfig({
|
|
9
|
+
})(["left:", "%;width:", "%;position:absolute;bottom:13px;height:80px;display:flex;flex-direction:column;justify-content:space-between;align-items:center;pointer-events:none;"], (props) => props.$left, (props) => props.$width);
|
|
10
|
+
const MarkValue = /* @__PURE__ */ styled.div.withConfig({
|
|
15
11
|
displayName: "AllocationMarksstyles__MarkValue",
|
|
16
12
|
componentId: "sc-k03cw7-2"
|
|
17
13
|
})([""]);
|
|
18
|
-
|
|
14
|
+
const MarkLetter = /* @__PURE__ */ styled.div.withConfig({
|
|
19
15
|
displayName: "AllocationMarksstyles__MarkLetter",
|
|
20
16
|
componentId: "sc-k03cw7-3"
|
|
21
|
-
})(["border-radius:", ";width:25px;height:25px;display:inline-block;position:relative;text-align:center;line-height:25px;color:white;background-color:", ";"],
|
|
22
|
-
|
|
23
|
-
}, function (props) {
|
|
24
|
-
return props.theme.palette[props.$color || 'grey-400'];
|
|
25
|
-
});
|
|
26
|
-
export var MarkTooltipWrapper = styled.div.withConfig({
|
|
17
|
+
})(["border-radius:", ";width:25px;height:25px;display:inline-block;position:relative;text-align:center;line-height:25px;color:white;background-color:", ";"], (props) => props.theme.variable("@border-radius-base"), (props) => props.theme.palette[props.$color || "grey-400"]);
|
|
18
|
+
const MarkTooltipWrapper = /* @__PURE__ */ styled.div.withConfig({
|
|
27
19
|
displayName: "AllocationMarksstyles__MarkTooltipWrapper",
|
|
28
20
|
componentId: "sc-k03cw7-4"
|
|
29
|
-
})(["display:block;width:100%;justify-content:center;text-align:center;min-width:14px;"]);
|
|
21
|
+
})(["display:block;width:100%;justify-content:center;text-align:center;min-width:14px;"]);
|
|
22
|
+
export {
|
|
23
|
+
AllocationMark,
|
|
24
|
+
AllocationMarks,
|
|
25
|
+
MarkLetter,
|
|
26
|
+
MarkTooltipWrapper,
|
|
27
|
+
MarkValue
|
|
28
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { AllocationSliderProps } from '../Slider.types';
|
|
3
3
|
export declare const AllocationSlider: ({ allocationConfig, tracksColorMap, description, handlers, step, label, thick, disabled, dots, }: Omit<AllocationSliderProps, "type">) => React.JSX.Element;
|