@synerise/ds-slider 1.0.30 → 1.1.0
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/dist/Slider.d.ts +0 -2
- package/dist/Slider.js +16 -100
- package/dist/Slider.styles.d.ts +41 -33
- package/dist/Slider.styles.js +79 -46
- package/dist/Slider.types.d.ts +89 -22
- package/dist/Slider.types.js +1 -5
- package/dist/components/AllocationMarks.d.ts +9 -0
- package/dist/components/AllocationMarks.js +42 -0
- package/dist/components/AllocationMarks.styles.d.ts +10 -0
- package/dist/components/AllocationMarks.styles.js +29 -0
- package/dist/components/AllocationSlider.d.ts +3 -0
- package/dist/components/AllocationSlider.js +112 -0
- package/dist/components/DefaultSlider.d.ts +3 -0
- package/dist/components/DefaultSlider.js +91 -0
- package/dist/components/RangeSlider.d.ts +3 -0
- package/dist/components/RangeSlider.js +99 -0
- package/dist/components/SliderAbove.d.ts +7 -0
- package/dist/components/SliderAbove.js +14 -0
- package/dist/components/SliderDots.d.ts +8 -0
- package/dist/components/SliderDots.js +36 -0
- package/dist/components/SliderHandles.d.ts +9 -0
- package/dist/components/SliderHandles.js +54 -0
- package/dist/components/SliderLine.d.ts +10 -0
- package/dist/components/SliderLine.js +45 -0
- package/dist/components/SliderMarks.d.ts +3 -0
- package/dist/components/SliderMarks.js +78 -0
- package/dist/components/SliderSections.d.ts +9 -0
- package/dist/components/SliderSections.js +33 -0
- package/dist/context/SliderContext.d.ts +14 -0
- package/dist/context/SliderContext.js +20 -0
- package/dist/hooks/useColorMap.d.ts +2 -0
- package/dist/hooks/useColorMap.js +7 -0
- package/dist/hooks/useInvertedColors.d.ts +8 -0
- package/dist/hooks/useInvertedColors.js +13 -0
- package/dist/index.d.ts +1 -2
- package/dist/index.js +2 -1
- package/dist/utils/Slider.interpolators.d.ts +6 -0
- package/dist/utils/Slider.interpolators.js +23 -0
- package/dist/utils/Slider.utils.d.ts +8 -9
- package/dist/utils/Slider.utils.js +41 -12
- package/dist/utils/allocation.utils.d.ts +5 -5
- package/dist/utils/allocation.utils.js +1 -18
- package/dist/utils/allocationHandlers.utils.d.ts +1 -2
- package/package.json +12 -7
- package/dist/Allocation/Allocation.d.ts +0 -4
- package/dist/Allocation/Allocation.js +0 -112
- package/dist/Allocation/Allocation.styles.d.ts +0 -48
- package/dist/Allocation/Allocation.styles.js +0 -104
- package/dist/Allocation/Allocation.types.d.ts +0 -30
- package/dist/Allocation/Allocation.types.js +0 -1
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlerWthTooltip.styles.d.ts +0 -4
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlerWthTooltip.styles.js +0 -12
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlersWithTooltip.d.ts +0 -9
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlersWithTooltip.js +0 -20
- package/dist/Allocation/BlockedHandlersWithTooltip/index.d.ts +0 -1
- package/dist/Allocation/BlockedHandlersWithTooltip/index.js +0 -1
- package/dist/style/index.css +0 -1
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.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.0.31...@synerise/ds-slider@1.1.0) (2026-01-22)
|
|
7
|
+
|
|
8
|
+
### Features
|
|
9
|
+
|
|
10
|
+
- **slider:** migrated from antd to tanstack ranger lib ([0c287c1](https://github.com/Synerise/synerise-design/commit/0c287c135d91180a143221bc273821828ad7efdc))
|
|
11
|
+
|
|
12
|
+
## [1.0.31](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.0.30...@synerise/ds-slider@1.0.31) (2026-01-15)
|
|
13
|
+
|
|
14
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
15
|
+
|
|
6
16
|
## [1.0.30](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@1.0.29...@synerise/ds-slider@1.0.30) (2026-01-12)
|
|
7
17
|
|
|
8
18
|
**Note:** Version bump only for package @synerise/ds-slider
|
package/dist/Slider.d.ts
CHANGED
package/dist/Slider.js
CHANGED
|
@@ -1,104 +1,20 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
import
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
import { buildDefaultTracksColorMap, couldBeInverted, getDefaultTooltipPopupContainer } from './utils/Slider.utils';
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { AllocationSlider } from './components/AllocationSlider';
|
|
3
|
+
import { DefaultSlider } from './components/DefaultSlider';
|
|
4
|
+
import { RangeSlider } from './components/RangeSlider';
|
|
5
|
+
var isRangeSlider = function isRangeSlider(props) {
|
|
6
|
+
return 'range' in props && props.range;
|
|
7
|
+
};
|
|
8
|
+
var isAllocationSlider = function isAllocationSlider(props) {
|
|
9
|
+
return 'type' in props && props.type === 'allocation';
|
|
10
|
+
};
|
|
12
11
|
var Slider = function Slider(props) {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
tracksColorMap = _props$tracksColorMap === void 0 ? buildDefaultTracksColorMap() : _props$tracksColorMap,
|
|
19
|
-
type = props.type,
|
|
20
|
-
thickness = props.thickness,
|
|
21
|
-
description = props.description,
|
|
22
|
-
_tipFormatter = props.tipFormatter,
|
|
23
|
-
allocationConfig = props.allocationConfig,
|
|
24
|
-
hideMinAndMaxMarks = props.hideMinAndMaxMarks,
|
|
25
|
-
disabled = props.disabled,
|
|
26
|
-
max = props.max,
|
|
27
|
-
min = props.min,
|
|
28
|
-
value = props.value,
|
|
29
|
-
range = props.range,
|
|
30
|
-
tooltipVisible = props.tooltipVisible,
|
|
31
|
-
_props$tooltipPlaceme = props.tooltipPlacement,
|
|
32
|
-
tooltipPlacement = _props$tooltipPlaceme === void 0 ? 'bottom' : _props$tooltipPlaceme,
|
|
33
|
-
antdProps = _objectWithoutPropertiesLoose(props, _excluded);
|
|
34
|
-
var _useState = useState(false),
|
|
35
|
-
reachedEnd = _useState[0],
|
|
36
|
-
setReachedEnd = _useState[1];
|
|
37
|
-
var _useState2 = useState(false),
|
|
38
|
-
reachedStart = _useState2[0],
|
|
39
|
-
setReachedStart = _useState2[1];
|
|
40
|
-
var showValueTooltip = useMemo(function () {
|
|
41
|
-
return tooltipVisible !== false && (!antdProps.tooltip || antdProps.tooltip.open !== false);
|
|
42
|
-
}, [tooltipVisible, antdProps.tooltip]);
|
|
43
|
-
var calcHandlePosition = useCallback(function () {
|
|
44
|
-
var handler = document.querySelectorAll('.ant-slider-handle');
|
|
45
|
-
var markTexts = document.querySelectorAll('.ant-slider-mark-text');
|
|
46
|
-
if (handler && markTexts != null && markTexts.length && showValueTooltip) {
|
|
47
|
-
var firstMark = markTexts[0].getBoundingClientRect();
|
|
48
|
-
var lastMark = markTexts[markTexts.length - 1].getBoundingClientRect();
|
|
49
|
-
var firstHandler = handler[0].getBoundingClientRect();
|
|
50
|
-
var lastHandler = handler[handler.length - 1].getBoundingClientRect();
|
|
51
|
-
if (firstMark.x + 10 + firstMark.width > firstHandler.x || firstMark.x + 10 + firstMark.width > lastHandler.x) {
|
|
52
|
-
setReachedStart(true);
|
|
53
|
-
} else {
|
|
54
|
-
setReachedStart(false);
|
|
55
|
-
}
|
|
56
|
-
if (lastMark.x - 30 < firstHandler.x || lastMark.x - 30 < lastHandler.x) {
|
|
57
|
-
setReachedEnd(true);
|
|
58
|
-
} else {
|
|
59
|
-
setReachedEnd(false);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return {
|
|
63
|
-
reachedEnd: reachedEnd,
|
|
64
|
-
reachedStart: reachedStart
|
|
65
|
-
};
|
|
66
|
-
}, [reachedEnd, reachedStart, showValueTooltip]);
|
|
67
|
-
useEffect(function () {
|
|
68
|
-
setTimeout(function () {
|
|
69
|
-
calcHandlePosition();
|
|
70
|
-
}, 0);
|
|
71
|
-
}, [calcHandlePosition, value]);
|
|
72
|
-
var labelElement = useMemo(function () {
|
|
73
|
-
return label ? /*#__PURE__*/React.createElement(S.LabelWrapper, null, /*#__PURE__*/React.createElement(Label, null, label)) : null;
|
|
74
|
-
}, [label]);
|
|
75
|
-
if (type === SliderTypes.ALLOCATION && !!allocationConfig) {
|
|
76
|
-
return /*#__PURE__*/React.createElement(React.Fragment, null, labelElement, /*#__PURE__*/React.createElement(Allocation, props));
|
|
12
|
+
if (isAllocationSlider(props)) {
|
|
13
|
+
return /*#__PURE__*/React.createElement(AllocationSlider, props);
|
|
14
|
+
}
|
|
15
|
+
if (isRangeSlider(props)) {
|
|
16
|
+
return /*#__PURE__*/React.createElement(RangeSlider, props);
|
|
77
17
|
}
|
|
78
|
-
return /*#__PURE__*/React.createElement(
|
|
79
|
-
min: min,
|
|
80
|
-
max: max,
|
|
81
|
-
value: value,
|
|
82
|
-
reachedEnd: reachedEnd,
|
|
83
|
-
tooltip: _extends({}, antdProps.tooltip, {
|
|
84
|
-
placement: tooltipPlacement,
|
|
85
|
-
open: tooltipVisible
|
|
86
|
-
}),
|
|
87
|
-
range: range,
|
|
88
|
-
reachedStart: reachedStart,
|
|
89
|
-
className: value && couldBeInverted(value, !!inverted) ? 'ant-slider-inverted' : undefined,
|
|
90
|
-
useColorPalette: useColorPalette,
|
|
91
|
-
thickness: thickness,
|
|
92
|
-
disabled: disabled,
|
|
93
|
-
description: description,
|
|
94
|
-
hideMinAndMaxMarks: hideMinAndMaxMarks,
|
|
95
|
-
tipFormatter: function tipFormatter(tipValue) {
|
|
96
|
-
return /*#__PURE__*/React.createElement(S.DescriptionWrapper, null, description && /*#__PURE__*/React.createElement(S.Description, {
|
|
97
|
-
range: Boolean(range)
|
|
98
|
-
}, description), _tipFormatter && _tipFormatter(tipValue));
|
|
99
|
-
},
|
|
100
|
-
tracksColorMap: tracksColorMap,
|
|
101
|
-
getTooltipPopupContainer: getTooltipPopupContainer || getDefaultTooltipPopupContainer
|
|
102
|
-
})));
|
|
18
|
+
return /*#__PURE__*/React.createElement(DefaultSlider, props);
|
|
103
19
|
};
|
|
104
20
|
export default Slider;
|
package/dist/Slider.styles.d.ts
CHANGED
|
@@ -1,33 +1,41 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
export declare const
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
export declare const
|
|
11
|
-
export declare const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
}
|
|
33
|
-
export {
|
|
1
|
+
export declare const SliderSection: import("styled-components").StyledComponent<"div", any, {
|
|
2
|
+
$left: number;
|
|
3
|
+
$width: number;
|
|
4
|
+
$color: string;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const SliderLine: import("styled-components").StyledComponent<"div", any, {
|
|
7
|
+
thick?: boolean;
|
|
8
|
+
lineColor?: string;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const SliderMarks: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
|
+
export declare const SliderMark: import("styled-components").StyledComponent<"div", any, {
|
|
12
|
+
$left: number;
|
|
13
|
+
isNear: boolean;
|
|
14
|
+
}, never>;
|
|
15
|
+
export declare const EventTrap: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
16
|
+
export declare const SliderHandleWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
17
|
+
$left: number;
|
|
18
|
+
isActive?: boolean;
|
|
19
|
+
$disabled?: boolean;
|
|
20
|
+
$blocked?: boolean;
|
|
21
|
+
}, never>;
|
|
22
|
+
export declare const SliderHandleValue: import("styled-components").StyledComponent<"div", any, {
|
|
23
|
+
isActive?: boolean;
|
|
24
|
+
}, never>;
|
|
25
|
+
export declare const SliderHandle: import("styled-components").StyledComponent<"button", any, {
|
|
26
|
+
isActive?: boolean;
|
|
27
|
+
$disabled?: boolean;
|
|
28
|
+
$blocked?: boolean;
|
|
29
|
+
}, never>;
|
|
30
|
+
export declare const SliderBar: import("styled-components").StyledComponent<"div", any, {
|
|
31
|
+
$type: "allocation" | "default" | "range";
|
|
32
|
+
}, never>;
|
|
33
|
+
export declare const SliderWrapper: import("styled-components").StyledComponent<"div", any, {
|
|
34
|
+
$disabled?: boolean;
|
|
35
|
+
withoutMarks?: boolean;
|
|
36
|
+
}, never>;
|
|
37
|
+
export declare const SliderDot: import("styled-components").StyledComponent<"div", any, {
|
|
38
|
+
$left: number;
|
|
39
|
+
$color?: string;
|
|
40
|
+
}, never>;
|
|
41
|
+
export declare const SliderLabel: import("styled-components").StyledComponent<"div", any, {}, never>;
|
package/dist/Slider.styles.js
CHANGED
|
@@ -1,60 +1,93 @@
|
|
|
1
|
-
import Slider from 'antd/lib/slider';
|
|
2
1
|
import styled, { css } from 'styled-components';
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
'1': 'cyan-600',
|
|
6
|
-
'2': 'yellow-600',
|
|
7
|
-
'3': 'orange-600',
|
|
8
|
-
'4': 'mars-600',
|
|
9
|
-
'5': 'pink-600',
|
|
10
|
-
'6': 'purple-600',
|
|
11
|
-
'7': 'red-600',
|
|
12
|
-
'8': 'violet-600',
|
|
13
|
-
'9': 'fern-600'
|
|
14
|
-
};
|
|
15
|
-
export var Description = styled.div.withConfig({
|
|
16
|
-
displayName: "Sliderstyles__Description",
|
|
2
|
+
export var SliderSection = styled.div.withConfig({
|
|
3
|
+
displayName: "Sliderstyles__SliderSection",
|
|
17
4
|
componentId: "sc-1gtvqj9-0"
|
|
18
|
-
})(["
|
|
19
|
-
return props
|
|
5
|
+
})(["left:", "%;width:", "%;position:absolute;height:100%;background:", ";"], function (props) {
|
|
6
|
+
return props.$left;
|
|
20
7
|
}, function (props) {
|
|
21
|
-
return props
|
|
8
|
+
return props.$width;
|
|
9
|
+
}, function (props) {
|
|
10
|
+
return props.$color;
|
|
22
11
|
});
|
|
23
|
-
export var
|
|
24
|
-
displayName: "
|
|
12
|
+
export var SliderLine = styled.div.withConfig({
|
|
13
|
+
displayName: "Sliderstyles__SliderLine",
|
|
25
14
|
componentId: "sc-1gtvqj9-1"
|
|
26
|
-
})(["
|
|
27
|
-
|
|
28
|
-
|
|
15
|
+
})(["height:", ";background:", ";position:absolute;top:50%;width:100%;transform:translateY(-50%);z-index:10;border-radius:", ";", "{border-radius:", ";}"], function (props) {
|
|
16
|
+
return (props.thick ? '6' : '3') + "px";
|
|
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({
|
|
25
|
+
displayName: "Sliderstyles__SliderMarks",
|
|
29
26
|
componentId: "sc-1gtvqj9-2"
|
|
30
|
-
})(["
|
|
31
|
-
export var
|
|
32
|
-
|
|
33
|
-
};
|
|
34
|
-
export var createTracksStyles = function createTracksStyles(props, colorsMap) {
|
|
35
|
-
var styles = Object.values(colorsMap).map(function (color, index) {
|
|
36
|
-
return "\n .ant-slider-segment-" + index + ",\n .ant-slider-segment-letter-" + index + ",\n .ant-slider-track-" + (index + 1) + ",\n .ant-slider-track-" + (index + 11) + " {\n background-color: " + props.theme.palette[color] + ";\n }\n .ant-slider-dot-active" + (index + 1) + ",\n .ant-slider-dot-active" + (index + 11) + " {\n background-color: " + props.theme.palette[color] + ";\n }\n ";
|
|
37
|
-
});
|
|
38
|
-
var style = styles.join('');
|
|
39
|
-
return css([".ant-slider-track{background-color:", ";}.ant-slider-dot-active{background-color:", ";}&.ant-slider-inverted{.ant-slider-dot{background-color:", ";&.ant-slider-dot-active{background-color:", ";}}.ant-slider-rail{background-color:", ";}.ant-slider-track{background-color:", ";}&&&.ant-slider-disabled{.ant-slider-rail{background-color:", ";}.ant-slider-dot{background-color:", " !important;border-color:", " !important;}.ant-slider-track{background-color:", " !important;}.ant-slider-dot-active{border-color:", " !important;}}}", ""], props.theme.palette[colorsMap[0]], props.theme.palette[colorsMap[0]], props.theme.palette[colorsMap[0]], props.theme.palette['grey-300'], props.theme.palette[colorsMap[0]], props.theme.palette['grey-200'], props.theme.palette['grey-400'], props.theme.palette['grey-050'], props.theme.palette['grey-400'], props.theme.palette['grey-200'], props.theme.palette['grey-200'], style);
|
|
40
|
-
};
|
|
41
|
-
export var AntdSlider = styled(Slider).withConfig({
|
|
42
|
-
displayName: "Sliderstyles__AntdSlider",
|
|
27
|
+
})(["position:relative;height:18px;margin-top:-5px;&:empty{display:none;}"]);
|
|
28
|
+
export var SliderMark = styled.div.withConfig({
|
|
29
|
+
displayName: "Sliderstyles__SliderMark",
|
|
43
30
|
componentId: "sc-1gtvqj9-3"
|
|
44
|
-
})(["
|
|
45
|
-
return props
|
|
31
|
+
})(["position:absolute;bottom:0;left:", "%;transform:translateX( ", "% );z-index:10;", " width:max-content;max-width:100px;overflow-wrap:break-word;"], function (props) {
|
|
32
|
+
return props.$left;
|
|
33
|
+
}, function (props) {
|
|
34
|
+
return props.$left < 1 ? '0' : props.$left > 99 ? '-100' : '-50';
|
|
46
35
|
}, function (props) {
|
|
47
|
-
return props.
|
|
36
|
+
return props.isNear && "visibility: hidden;";
|
|
37
|
+
});
|
|
38
|
+
export var EventTrap = styled.div.withConfig({
|
|
39
|
+
displayName: "Sliderstyles__EventTrap",
|
|
40
|
+
componentId: "sc-1gtvqj9-4"
|
|
41
|
+
})(["display:contents:"]);
|
|
42
|
+
export var SliderHandleWrapper = styled.div.withConfig({
|
|
43
|
+
displayName: "Sliderstyles__SliderHandleWrapper",
|
|
44
|
+
componentId: "sc-1gtvqj9-5"
|
|
45
|
+
})(["position:absolute;top:50%;left:", "%;z-index:20;"], function (props) {
|
|
46
|
+
return props.$left;
|
|
47
|
+
});
|
|
48
|
+
export var SliderHandleValue = styled.div.withConfig({
|
|
49
|
+
displayName: "Sliderstyles__SliderHandleValue",
|
|
50
|
+
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;", ""], function (props) {
|
|
52
|
+
return 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']);
|
|
53
|
+
});
|
|
54
|
+
export var SliderHandle = styled.button.withConfig({
|
|
55
|
+
displayName: "Sliderstyles__SliderHandle",
|
|
56
|
+
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;", ";", ";"], function (props) {
|
|
58
|
+
return props.theme.palette.white;
|
|
48
59
|
}, function (props) {
|
|
49
|
-
return props.
|
|
60
|
+
return props.theme.palette['grey-400'];
|
|
50
61
|
}, function (props) {
|
|
51
|
-
return 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']);
|
|
52
63
|
}, function (props) {
|
|
53
|
-
return
|
|
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({
|
|
67
|
+
displayName: "Sliderstyles__SliderBar",
|
|
68
|
+
componentId: "sc-1gtvqj9-8"
|
|
69
|
+
})(["position:relative;user-select:none;height:20px;", ""], function (props) {
|
|
70
|
+
return props.$type === 'allocation' && css(["margin-top:48px;"]);
|
|
71
|
+
});
|
|
72
|
+
export var SliderWrapper = styled.div.withConfig({
|
|
73
|
+
displayName: "Sliderstyles__SliderWrapper",
|
|
74
|
+
componentId: "sc-1gtvqj9-9"
|
|
75
|
+
})(["display:flex;flex:1 0 auto;flex-direction:column;gap:16px;", " ", ""], function (props) {
|
|
76
|
+
return props.withoutMarks && css(["padding-bottom:29px;"]);
|
|
54
77
|
}, function (props) {
|
|
55
|
-
return 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({
|
|
81
|
+
displayName: "Sliderstyles__SliderDot",
|
|
82
|
+
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;"], function (props) {
|
|
84
|
+
return props.theme.palette[props.$color || 'grey-200'];
|
|
56
85
|
}, function (props) {
|
|
57
|
-
return props.
|
|
86
|
+
return props.theme.palette.white;
|
|
58
87
|
}, function (props) {
|
|
59
|
-
return props
|
|
60
|
-
});
|
|
88
|
+
return props.$left;
|
|
89
|
+
});
|
|
90
|
+
export var SliderLabel = styled.div.withConfig({
|
|
91
|
+
displayName: "Sliderstyles__SliderLabel",
|
|
92
|
+
componentId: "sc-1gtvqj9-11"
|
|
93
|
+
})(["display:flex;flex-direction:column;gap:8px;"]);
|
package/dist/Slider.types.d.ts
CHANGED
|
@@ -1,34 +1,101 @@
|
|
|
1
|
-
import type { SliderRangeProps, SliderSingleProps } from 'antd/lib/slider';
|
|
2
1
|
import type { ReactNode } from 'react';
|
|
3
2
|
import type { TooltipProps } from '@synerise/ds-tooltip';
|
|
4
|
-
|
|
5
|
-
type
|
|
6
|
-
export type
|
|
7
|
-
export
|
|
8
|
-
ALLOCATION = "allocation",
|
|
9
|
-
DEFAULT = "default"
|
|
10
|
-
}
|
|
11
|
-
export declare type ColorMapProps = {
|
|
12
|
-
[key: string]: string;
|
|
13
|
-
};
|
|
3
|
+
type AllocationType = 'allocation';
|
|
4
|
+
export type SliderType = AllocationType | 'default';
|
|
5
|
+
export type ColorMap = Record<number, string>;
|
|
6
|
+
export type ColorsOrder = string[];
|
|
14
7
|
export type HandlerConfig = Record<number, {
|
|
15
8
|
blocked: boolean;
|
|
16
9
|
blockedTooltipProps?: TooltipProps;
|
|
17
10
|
}>;
|
|
18
|
-
export type
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
11
|
+
export type MarkObj = {
|
|
12
|
+
style?: React.CSSProperties;
|
|
13
|
+
label?: React.ReactNode;
|
|
14
|
+
};
|
|
15
|
+
export type SliderMarks = Record<string | number, React.ReactNode | MarkObj>;
|
|
16
|
+
export type DefaultValue = number;
|
|
17
|
+
export type RangeValue = number[];
|
|
18
|
+
export type RangeSliderProps = BaseSliderProps & SharedSliderProps & {
|
|
19
|
+
value?: RangeValue;
|
|
20
|
+
onChange?: (value: RangeValue) => void;
|
|
21
|
+
onAfterChange?: (value: RangeValue) => void;
|
|
22
|
+
range: true;
|
|
23
|
+
};
|
|
24
|
+
export type DefaultSliderProps = BaseSliderProps & SharedSliderProps & {
|
|
25
|
+
value?: DefaultValue;
|
|
26
|
+
onChange?: (value: DefaultValue) => void;
|
|
27
|
+
onAfterChange?: (value: DefaultValue) => void;
|
|
28
|
+
};
|
|
29
|
+
export type AllocationSliderProps = SharedSliderProps & {
|
|
30
|
+
type: AllocationType;
|
|
31
|
+
allocationConfig: AllocationConfig;
|
|
32
|
+
handlers?: HandlerConfig;
|
|
33
|
+
};
|
|
34
|
+
export type BaseSliderProps = {
|
|
35
|
+
/**
|
|
36
|
+
* inverts coloring of the slider
|
|
37
|
+
* Applies only when value is number or [number, number]
|
|
38
|
+
*/
|
|
23
39
|
inverted?: boolean;
|
|
24
|
-
|
|
40
|
+
/**
|
|
41
|
+
* renders from right to left
|
|
42
|
+
*/
|
|
43
|
+
reverse?: boolean;
|
|
44
|
+
/**
|
|
45
|
+
* slider scale marks
|
|
46
|
+
*/
|
|
47
|
+
marks?: SliderMarks;
|
|
48
|
+
min?: number;
|
|
49
|
+
max?: number;
|
|
50
|
+
/**
|
|
51
|
+
* handle value formatter
|
|
52
|
+
*/
|
|
53
|
+
tipFormatter?: ((value?: number) => ReactNode) | false;
|
|
54
|
+
};
|
|
55
|
+
export type SharedSliderProps = {
|
|
56
|
+
label?: ReactNode;
|
|
25
57
|
autoFocus?: boolean;
|
|
26
|
-
tracksColorMap?:
|
|
27
|
-
|
|
58
|
+
tracksColorMap?: ColorMap;
|
|
59
|
+
thick?: boolean;
|
|
28
60
|
description?: ReactNode;
|
|
29
|
-
children?: ReactNode;
|
|
30
|
-
hideMinAndMaxMarks?: boolean;
|
|
31
61
|
disabled?: boolean;
|
|
32
|
-
|
|
62
|
+
step?: number;
|
|
63
|
+
/**
|
|
64
|
+
* renders dots for allowed handle positions (values)
|
|
65
|
+
* not recommended for low `step` prop values
|
|
66
|
+
*/
|
|
67
|
+
dots?: boolean;
|
|
68
|
+
};
|
|
69
|
+
export type SliderProps = DefaultSliderProps | RangeSliderProps | AllocationSliderProps;
|
|
70
|
+
export type AllocationConfig = {
|
|
71
|
+
controlGroupEnabled?: boolean;
|
|
72
|
+
controlGroupLabel?: ReactNode;
|
|
73
|
+
controlGroupTooltip?: ReactNode;
|
|
74
|
+
variants?: AllocationVariant[];
|
|
75
|
+
onAllocationChange?: (variants?: AllocationVariant[]) => void;
|
|
76
|
+
};
|
|
77
|
+
export type AllocationVariant = {
|
|
78
|
+
name: ReactNode;
|
|
79
|
+
percentage: number;
|
|
80
|
+
tabId: number;
|
|
81
|
+
tabLetter: ReactNode;
|
|
82
|
+
minPercentage?: number;
|
|
83
|
+
};
|
|
84
|
+
export type AllocationMark = {
|
|
85
|
+
value: string;
|
|
86
|
+
view: number;
|
|
87
|
+
};
|
|
88
|
+
export type DefinedCssRuleParameters = {
|
|
89
|
+
indexes: number[];
|
|
90
|
+
classConstPart: string;
|
|
91
|
+
cssRule: string;
|
|
92
|
+
};
|
|
93
|
+
export type SliderMarksProps = {
|
|
94
|
+
marks: SliderMarks;
|
|
95
|
+
handlesWithValue?: boolean;
|
|
96
|
+
};
|
|
97
|
+
export type MarkArea = {
|
|
98
|
+
left: number;
|
|
99
|
+
width: number;
|
|
33
100
|
};
|
|
34
101
|
export {};
|
package/dist/Slider.types.js
CHANGED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { type AllocationConfig, type AllocationVariant, type ColorMap } from '../Slider.types';
|
|
3
|
+
type AllocationMarksProps = AllocationConfig & {
|
|
4
|
+
allocations: number[];
|
|
5
|
+
variants: AllocationVariant[];
|
|
6
|
+
tracksColorMap: ColorMap;
|
|
7
|
+
};
|
|
8
|
+
export declare const AllocationMarks: ({ controlGroupTooltip, controlGroupLabel, allocations, variants, tracksColorMap, }: AllocationMarksProps) => React.JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import Tooltip from '@synerise/ds-tooltip';
|
|
4
|
+
import { useSliderContext } from '../context/SliderContext';
|
|
5
|
+
import * as S from './AllocationMarks.styles';
|
|
6
|
+
export var AllocationMarks = function AllocationMarks(_ref) {
|
|
7
|
+
var controlGroupTooltip = _ref.controlGroupTooltip,
|
|
8
|
+
controlGroupLabel = _ref.controlGroupLabel,
|
|
9
|
+
allocations = _ref.allocations,
|
|
10
|
+
variants = _ref.variants,
|
|
11
|
+
tracksColorMap = _ref.tracksColorMap;
|
|
12
|
+
var intl = useIntl();
|
|
13
|
+
var _useSliderContext = useSliderContext(),
|
|
14
|
+
rangerInstance = _useSliderContext.rangerInstance;
|
|
15
|
+
var renderMark = function renderMark(value, index, allocationVariants) {
|
|
16
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, allocationVariants[index] && /*#__PURE__*/React.createElement(Tooltip, {
|
|
17
|
+
title: /*#__PURE__*/React.createElement(S.MarkTooltipWrapper, null, allocationVariants[index].tabLetter)
|
|
18
|
+
}, /*#__PURE__*/React.createElement(S.MarkLetter, {
|
|
19
|
+
className: "ant-slider-segment-letter-" + index,
|
|
20
|
+
$color: tracksColorMap[index]
|
|
21
|
+
}, allocationVariants[index].tabLetter)), !allocationVariants[index] && /*#__PURE__*/React.createElement(Tooltip, {
|
|
22
|
+
title: controlGroupTooltip || intl.formatMessage({
|
|
23
|
+
id: 'DS.SLIDER.CONTROL-GROUP',
|
|
24
|
+
defaultMessage: 'Control group'
|
|
25
|
+
})
|
|
26
|
+
}, /*#__PURE__*/React.createElement(S.MarkLetter, {
|
|
27
|
+
$color: tracksColorMap[index]
|
|
28
|
+
}, controlGroupLabel || intl.formatMessage({
|
|
29
|
+
id: 'DS.SLIDER.CONTROL-GROUP-TOOLTIP',
|
|
30
|
+
defaultMessage: 'CG'
|
|
31
|
+
}))), /*#__PURE__*/React.createElement(S.MarkValue, null, value, "%"));
|
|
32
|
+
};
|
|
33
|
+
return /*#__PURE__*/React.createElement(S.AllocationMarks, {
|
|
34
|
+
"data-testid": "ds-allocation-marks"
|
|
35
|
+
}, rangerInstance.getSteps().map(function (section, index) {
|
|
36
|
+
return /*#__PURE__*/React.createElement(S.AllocationMark, {
|
|
37
|
+
key: "slider-allocation-mark-" + index,
|
|
38
|
+
$left: section.left,
|
|
39
|
+
$width: section.width
|
|
40
|
+
}, renderMark(allocations[index], index, variants || []));
|
|
41
|
+
}));
|
|
42
|
+
};
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export declare const AllocationMarks: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
2
|
+
export declare const AllocationMark: import("styled-components").StyledComponent<"div", any, {
|
|
3
|
+
$left: number;
|
|
4
|
+
$width: number;
|
|
5
|
+
}, never>;
|
|
6
|
+
export declare const MarkValue: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
|
+
export declare const MarkLetter: import("styled-components").StyledComponent<"div", any, {
|
|
8
|
+
$color?: string;
|
|
9
|
+
}, never>;
|
|
10
|
+
export declare const MarkTooltipWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export var AllocationMarks = styled.div.withConfig({
|
|
3
|
+
displayName: "AllocationMarksstyles__AllocationMarks",
|
|
4
|
+
componentId: "sc-k03cw7-0"
|
|
5
|
+
})(["height:40px;position:relative;margin-top:-16px;"]);
|
|
6
|
+
export var AllocationMark = styled.div.withConfig({
|
|
7
|
+
displayName: "AllocationMarksstyles__AllocationMark",
|
|
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;"], function (props) {
|
|
10
|
+
return props.$left;
|
|
11
|
+
}, function (props) {
|
|
12
|
+
return props.$width;
|
|
13
|
+
});
|
|
14
|
+
export var MarkValue = styled.div.withConfig({
|
|
15
|
+
displayName: "AllocationMarksstyles__MarkValue",
|
|
16
|
+
componentId: "sc-k03cw7-2"
|
|
17
|
+
})([""]);
|
|
18
|
+
export var MarkLetter = styled.div.withConfig({
|
|
19
|
+
displayName: "AllocationMarksstyles__MarkLetter",
|
|
20
|
+
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:", ";"], function (props) {
|
|
22
|
+
return props.theme.variable('@border-radius-base');
|
|
23
|
+
}, function (props) {
|
|
24
|
+
return props.theme.palette[props.$color || 'grey-400'];
|
|
25
|
+
});
|
|
26
|
+
export var MarkTooltipWrapper = styled.div.withConfig({
|
|
27
|
+
displayName: "AllocationMarksstyles__MarkTooltipWrapper",
|
|
28
|
+
componentId: "sc-k03cw7-4"
|
|
29
|
+
})(["display:block;width:100%;justify-content:center;text-align:center;min-width:14px;"]);
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import type { AllocationSliderProps } from '../Slider.types';
|
|
3
|
+
export declare const AllocationSlider: ({ allocationConfig, tracksColorMap, description, handlers, step, label, thick, disabled, dots, }: Omit<AllocationSliderProps, "type">) => React.JSX.Element;
|