@synerise/ds-slider 1.1.12 → 1.1.14
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/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 +8 -8
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.14](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.1.13...@synerise/ds-slider@1.1.14) (2026-04-01)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
## [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)
|
|
11
|
+
|
|
12
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
13
|
+
|
|
6
14
|
## [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
15
|
|
|
8
16
|
**Note:** Version bump only for package @synerise/ds-slider
|
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;
|
|
@@ -1,112 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
import
|
|
3
|
-
import { useRanger } from
|
|
4
|
-
import
|
|
5
|
-
import { SliderProvider } from
|
|
6
|
-
import { useColorMap } from
|
|
7
|
-
import { getClosestIndex } from
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { AllocationMarks } from
|
|
11
|
-
import { SliderAbove } from
|
|
12
|
-
import { SliderLine } from
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
onAllocationChange
|
|
28
|
-
controlGroupEnabled
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
useEffect(function () {
|
|
1
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useRef, useState, useEffect, useMemo, useCallback } from "react";
|
|
3
|
+
import { useRanger } from "@tanstack/react-ranger";
|
|
4
|
+
import { SliderWrapper } from "../Slider.styles.js";
|
|
5
|
+
import { SliderProvider } from "../context/SliderContext.js";
|
|
6
|
+
import { useColorMap } from "../hooks/useColorMap.js";
|
|
7
|
+
import { getClosestIndex } from "../utils/Slider.utils.js";
|
|
8
|
+
import { countAllocation, mapSliderValueToVariants, checkIsPercentageInBoundaries, mapUserAllocationToHandles } from "../utils/allocation.utils.js";
|
|
9
|
+
import { checkIsBlockedHandlersConfigEnabled, getBlockedHandlersKeys, calculateHandlersPercentagePosition, checkIsBlockedVariantsChange } from "../utils/allocationHandlers.utils.js";
|
|
10
|
+
import { AllocationMarks } from "./AllocationMarks.js";
|
|
11
|
+
import { SliderAbove } from "./SliderAbove.js";
|
|
12
|
+
import { SliderLine } from "./SliderLine.js";
|
|
13
|
+
const AllocationSlider = ({
|
|
14
|
+
allocationConfig,
|
|
15
|
+
tracksColorMap,
|
|
16
|
+
description,
|
|
17
|
+
handlers,
|
|
18
|
+
step = 1,
|
|
19
|
+
label,
|
|
20
|
+
thick,
|
|
21
|
+
disabled,
|
|
22
|
+
dots
|
|
23
|
+
}) => {
|
|
24
|
+
const rangerHandlesRef = useRef({});
|
|
25
|
+
const {
|
|
26
|
+
variants,
|
|
27
|
+
onAllocationChange,
|
|
28
|
+
controlGroupEnabled
|
|
29
|
+
} = allocationConfig;
|
|
30
|
+
const [allocations, setAllocations] = useState(countAllocation(variants, controlGroupEnabled));
|
|
31
|
+
useEffect(() => {
|
|
33
32
|
setAllocations(countAllocation(variants, controlGroupEnabled));
|
|
34
33
|
}, [variants, controlGroupEnabled]);
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
var calculatedVariants = mapSliderValueToVariants(value, variants);
|
|
34
|
+
const rangerRef = useRef(null);
|
|
35
|
+
const {
|
|
36
|
+
blockedHandlersKeys,
|
|
37
|
+
isBlockedHandlersConfigEnabled
|
|
38
|
+
} = useMemo(() => ({
|
|
39
|
+
blockedHandlersKeys: getBlockedHandlersKeys(handlers),
|
|
40
|
+
isBlockedHandlersConfigEnabled: checkIsBlockedHandlersConfigEnabled(handlers)
|
|
41
|
+
}), [handlers]);
|
|
42
|
+
const colorMap = useColorMap(variants?.length ?? 9, "allocation", tracksColorMap);
|
|
43
|
+
const currentHandlersPercentagePositions = calculateHandlersPercentagePosition(variants);
|
|
44
|
+
const handleChange = useCallback((value) => {
|
|
45
|
+
const calculatedVariants = mapSliderValueToVariants(value, variants);
|
|
48
46
|
if (!checkIsPercentageInBoundaries(calculatedVariants)) {
|
|
49
47
|
return;
|
|
50
48
|
}
|
|
51
49
|
if (isBlockedHandlersConfigEnabled) {
|
|
52
|
-
|
|
53
|
-
|
|
50
|
+
const afterChangeHandlersPercentagePositions = calculateHandlersPercentagePosition(calculatedVariants);
|
|
51
|
+
const isBlockedVariantChanged = checkIsBlockedVariantsChange(blockedHandlersKeys, currentHandlersPercentagePositions, afterChangeHandlersPercentagePositions);
|
|
54
52
|
if (isBlockedVariantChanged) {
|
|
55
53
|
return;
|
|
56
54
|
}
|
|
57
55
|
}
|
|
58
56
|
setAllocations(countAllocation(variants, controlGroupEnabled));
|
|
59
|
-
onAllocationChange
|
|
57
|
+
onAllocationChange?.(calculatedVariants);
|
|
60
58
|
}, [blockedHandlersKeys, controlGroupEnabled, currentHandlersPercentagePositions, isBlockedHandlersConfigEnabled, onAllocationChange, variants]);
|
|
61
|
-
|
|
62
|
-
getRangerElement:
|
|
63
|
-
return rangerRef.current;
|
|
64
|
-
},
|
|
59
|
+
const rangerInstance = useRanger({
|
|
60
|
+
getRangerElement: () => rangerRef.current,
|
|
65
61
|
values: mapUserAllocationToHandles(allocations),
|
|
66
62
|
min: 0,
|
|
67
63
|
max: 100,
|
|
68
64
|
stepSize: step,
|
|
69
65
|
tickSize: step,
|
|
70
|
-
onDrag:
|
|
66
|
+
onDrag: (instance) => {
|
|
71
67
|
handleChange(instance.sortedValues);
|
|
72
68
|
},
|
|
73
|
-
onChange:
|
|
69
|
+
onChange: (instance) => {
|
|
74
70
|
handleChange(instance.sortedValues);
|
|
75
71
|
}
|
|
76
72
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
return index === closestIndex ? newValue : item;
|
|
84
|
-
}).sort(function (a, b) {
|
|
85
|
-
return a - b;
|
|
86
|
-
});
|
|
73
|
+
const handleLineClick = (event) => {
|
|
74
|
+
const clicked = rangerInstance.getValueForClientX(event.clientX);
|
|
75
|
+
const newValue = rangerInstance.roundToStep(clicked);
|
|
76
|
+
const handleValues = mapUserAllocationToHandles(allocations);
|
|
77
|
+
const closestIndex = getClosestIndex(handleValues, clicked);
|
|
78
|
+
const updatedValues = handleValues.map((item, index) => index === closestIndex ? newValue : item).sort((a, b) => a - b);
|
|
87
79
|
handleChange(updatedValues);
|
|
88
80
|
};
|
|
89
|
-
return
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}), /*#__PURE__*/React.createElement(SliderLine, {
|
|
99
|
-
onLineClick: !disabled ? handleLineClick : undefined,
|
|
100
|
-
type: "allocation",
|
|
101
|
-
tracksColorMap: colorMap,
|
|
102
|
-
thick: thick,
|
|
103
|
-
disabled: disabled,
|
|
104
|
-
handlersConfig: handlers,
|
|
105
|
-
dots: dots
|
|
106
|
-
}), /*#__PURE__*/React.createElement(AllocationMarks, _extends({
|
|
107
|
-
variants: []
|
|
108
|
-
}, allocationConfig, {
|
|
109
|
-
tracksColorMap: colorMap,
|
|
110
|
-
allocations: allocations
|
|
111
|
-
}))));
|
|
112
|
-
};
|
|
81
|
+
return /* @__PURE__ */ jsx(SliderProvider, { rangerInstance, rangerHandles: rangerHandlesRef, children: /* @__PURE__ */ jsxs(SliderWrapper, { ref: rangerRef, $disabled: disabled, children: [
|
|
82
|
+
/* @__PURE__ */ jsx(SliderAbove, { label, description }),
|
|
83
|
+
/* @__PURE__ */ jsx(SliderLine, { onLineClick: !disabled ? handleLineClick : void 0, type: "allocation", tracksColorMap: colorMap, thick, disabled, handlersConfig: handlers, dots }),
|
|
84
|
+
/* @__PURE__ */ jsx(AllocationMarks, { variants: [], ...allocationConfig, tracksColorMap: colorMap, allocations })
|
|
85
|
+
] }) });
|
|
86
|
+
};
|
|
87
|
+
export {
|
|
88
|
+
AllocationSlider
|
|
89
|
+
};
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
import {
|
|
1
|
+
import { default as React } from 'react';
|
|
2
|
+
import { DefaultSliderProps } from '../Slider.types';
|
|
3
3
|
export declare const DefaultSlider: (props: DefaultSliderProps) => React.JSX.Element;
|