@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.
Files changed (47) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/Slider.d.ts +2 -2
  3. package/dist/Slider.js +15 -13
  4. package/dist/Slider.styles.d.ts +12 -12
  5. package/dist/Slider.styles.js +37 -67
  6. package/dist/Slider.types.d.ts +2 -2
  7. package/dist/Slider.types.js +1 -1
  8. package/dist/components/AllocationMarks.d.ts +2 -2
  9. package/dist/components/AllocationMarks.js +37 -42
  10. package/dist/components/AllocationMarks.styles.d.ts +5 -5
  11. package/dist/components/AllocationMarks.styles.js +16 -17
  12. package/dist/components/AllocationSlider.d.ts +2 -2
  13. package/dist/components/AllocationSlider.js +65 -88
  14. package/dist/components/DefaultSlider.d.ts +2 -2
  15. package/dist/components/DefaultSlider.js +58 -79
  16. package/dist/components/RangeSlider.d.ts +2 -2
  17. package/dist/components/RangeSlider.js +63 -88
  18. package/dist/components/SliderAbove.d.ts +1 -1
  19. package/dist/components/SliderAbove.js +15 -14
  20. package/dist/components/SliderDots.d.ts +2 -2
  21. package/dist/components/SliderDots.js +28 -31
  22. package/dist/components/SliderHandles.d.ts +2 -2
  23. package/dist/components/SliderHandles.js +36 -54
  24. package/dist/components/SliderLine.d.ts +2 -2
  25. package/dist/components/SliderLine.js +34 -46
  26. package/dist/components/SliderMarks.d.ts +2 -2
  27. package/dist/components/SliderMarks.js +48 -64
  28. package/dist/components/SliderSections.d.ts +2 -2
  29. package/dist/components/SliderSections.js +24 -28
  30. package/dist/context/SliderContext.d.ts +2 -2
  31. package/dist/context/SliderContext.js +20 -16
  32. package/dist/hooks/useColorMap.d.ts +1 -1
  33. package/dist/hooks/useColorMap.js +8 -5
  34. package/dist/hooks/useInvertedColors.d.ts +1 -1
  35. package/dist/hooks/useInvertedColors.js +13 -9
  36. package/dist/index.js +4 -2
  37. package/dist/modules.d.js +1 -1
  38. package/dist/modules.d.ts +0 -0
  39. package/dist/utils/Slider.interpolators.d.ts +1 -1
  40. package/dist/utils/Slider.interpolators.js +10 -16
  41. package/dist/utils/Slider.utils.d.ts +2 -2
  42. package/dist/utils/Slider.utils.js +36 -33
  43. package/dist/utils/allocation.utils.d.ts +2 -2
  44. package/dist/utils/allocation.utils.js +30 -63
  45. package/dist/utils/allocationHandlers.utils.d.ts +1 -1
  46. package/dist/utils/allocationHandlers.utils.js +17 -18
  47. 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
@@ -1,4 +1,4 @@
1
- import React from 'react';
2
- import { type SliderProps } from './Slider.types';
1
+ import { default as React } from 'react';
2
+ import { SliderProps } from './Slider.types';
3
3
  declare const Slider: (props: SliderProps) => React.JSX.Element;
4
4
  export default Slider;
package/dist/Slider.js CHANGED
@@ -1,20 +1,22 @@
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;
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
- var isAllocationSlider = function isAllocationSlider(props) {
9
- return 'type' in props && props.type === 'allocation';
8
+ const isAllocationSlider = (props) => {
9
+ return "type" in props && props.type === "allocation";
10
10
  };
11
- var Slider = function Slider(props) {
11
+ const Slider = (props) => {
12
12
  if (isAllocationSlider(props)) {
13
- return /*#__PURE__*/React.createElement(AllocationSlider, props);
13
+ return /* @__PURE__ */ jsx(AllocationSlider, { ...props });
14
14
  }
15
15
  if (isRangeSlider(props)) {
16
- return /*#__PURE__*/React.createElement(RangeSlider, props);
16
+ return /* @__PURE__ */ jsx(RangeSlider, { ...props });
17
17
  }
18
- return /*#__PURE__*/React.createElement(DefaultSlider, props);
18
+ return /* @__PURE__ */ jsx(DefaultSlider, { ...props });
19
+ };
20
+ export {
21
+ Slider as default
19
22
  };
20
- export default Slider;
@@ -1,41 +1,41 @@
1
- export declare const SliderSection: import("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {}, never>;
11
- export declare const SliderMark: import("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {}, never>;
16
- export declare const SliderHandleWrapper: import("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {
22
+ export declare const SliderHandleValue: import('styled-components').StyledComponent<"div", any, {
23
23
  isActive?: boolean;
24
24
  }, never>;
25
- export declare const SliderHandle: import("styled-components").StyledComponent<"button", any, {
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("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {}, never>;
41
+ export declare const SliderLabel: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,93 +1,63 @@
1
- import styled, { css } from 'styled-components';
2
- export var SliderSection = styled.div.withConfig({
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:", ";"], function (props) {
6
- return props.$left;
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:", ";}"], 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({
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
- export var SliderMark = styled.div.withConfig({
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;"], function (props) {
32
- return props.$left;
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
- export var SliderHandleWrapper = styled.div.withConfig({
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;"], function (props) {
46
- return props.$left;
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;", ""], 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({
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;", ";", ";"], function (props) {
58
- return props.theme.palette.white;
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;", ""], function (props) {
70
- return props.$type === 'allocation' && css(["margin-top:48px;"]);
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;", " ", ""], function (props) {
76
- return props.withoutMarks && css(["padding-bottom:29px;"]);
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;"], function (props) {
84
- return props.theme.palette[props.$color || 'grey-200'];
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
+ };
@@ -1,5 +1,5 @@
1
- import type { ReactNode } from 'react';
2
- import type { TooltipProps } from '@synerise/ds-tooltip';
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>;
@@ -1 +1 @@
1
- export {};
1
+
@@ -1,5 +1,5 @@
1
- import React from 'react';
2
- import { type AllocationConfig, type AllocationVariant, type ColorMap } from '../Slider.types';
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 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
- };
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("styled-components").StyledComponent<"div", any, {}, never>;
2
- export declare const AllocationMark: import("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {}, never>;
7
- export declare const MarkLetter: import("styled-components").StyledComponent<"div", any, {
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("styled-components").StyledComponent<"div", any, {}, never>;
10
+ export declare const MarkTooltipWrapper: import('styled-components').StyledComponent<"div", any, {}, never>;
@@ -1,29 +1,28 @@
1
- import styled from 'styled-components';
2
- export var AllocationMarks = styled.div.withConfig({
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
- export var AllocationMark = styled.div.withConfig({
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;"], function (props) {
10
- return props.$left;
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
- export var MarkLetter = styled.div.withConfig({
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:", ";"], 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({
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 type { AllocationSliderProps } from '../Slider.types';
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
- function _extends() { return _extends = Object.assign ? Object.assign.bind() : function (n) { for (var e = 1; e < arguments.length; e++) { var t = arguments[e]; for (var r in t) ({}).hasOwnProperty.call(t, r) && (n[r] = t[r]); } return n; }, _extends.apply(null, arguments); }
2
- import React, { useCallback, useEffect, useMemo, useRef, useState } from 'react';
3
- import { useRanger } from '@tanstack/react-ranger';
4
- import * as S from '../Slider.styles';
5
- import { SliderProvider } from '../context/SliderContext';
6
- import { useColorMap } from '../hooks/useColorMap';
7
- import { getClosestIndex } from '../utils/Slider.utils';
8
- import { checkIsPercentageInBoundaries, countAllocation, mapSliderValueToVariants, mapUserAllocationToHandles } from '../utils/allocation.utils';
9
- import { calculateHandlersPercentagePosition, checkIsBlockedHandlersConfigEnabled, checkIsBlockedVariantsChange, getBlockedHandlersKeys } from '../utils/allocationHandlers.utils';
10
- import { AllocationMarks } from './AllocationMarks';
11
- import { SliderAbove } from './SliderAbove';
12
- import { SliderLine } from './SliderLine';
13
- export var AllocationSlider = function AllocationSlider(_ref) {
14
- var _variants$length;
15
- var allocationConfig = _ref.allocationConfig,
16
- tracksColorMap = _ref.tracksColorMap,
17
- description = _ref.description,
18
- handlers = _ref.handlers,
19
- _ref$step = _ref.step,
20
- step = _ref$step === void 0 ? 1 : _ref$step,
21
- label = _ref.label,
22
- thick = _ref.thick,
23
- disabled = _ref.disabled,
24
- dots = _ref.dots;
25
- var rangerHandlesRef = useRef({});
26
- var variants = allocationConfig.variants,
27
- onAllocationChange = allocationConfig.onAllocationChange,
28
- controlGroupEnabled = allocationConfig.controlGroupEnabled;
29
- var _useState = useState(countAllocation(variants, controlGroupEnabled)),
30
- allocations = _useState[0],
31
- setAllocations = _useState[1];
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
- var rangerRef = useRef(null);
36
- var _useMemo = useMemo(function () {
37
- return {
38
- blockedHandlersKeys: getBlockedHandlersKeys(handlers),
39
- isBlockedHandlersConfigEnabled: checkIsBlockedHandlersConfigEnabled(handlers)
40
- };
41
- }, [handlers]),
42
- blockedHandlersKeys = _useMemo.blockedHandlersKeys,
43
- isBlockedHandlersConfigEnabled = _useMemo.isBlockedHandlersConfigEnabled;
44
- var colorMap = useColorMap((_variants$length = variants == null ? void 0 : variants.length) != null ? _variants$length : 9, 'allocation', tracksColorMap);
45
- var currentHandlersPercentagePositions = calculateHandlersPercentagePosition(variants);
46
- var handleChange = useCallback(function (value) {
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
- var afterChangeHandlersPercentagePositions = calculateHandlersPercentagePosition(calculatedVariants);
53
- var isBlockedVariantChanged = checkIsBlockedVariantsChange(blockedHandlersKeys, currentHandlersPercentagePositions, afterChangeHandlersPercentagePositions);
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 == null || onAllocationChange(calculatedVariants);
57
+ onAllocationChange?.(calculatedVariants);
60
58
  }, [blockedHandlersKeys, controlGroupEnabled, currentHandlersPercentagePositions, isBlockedHandlersConfigEnabled, onAllocationChange, variants]);
61
- var rangerInstance = useRanger({
62
- getRangerElement: function 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: function onDrag(instance) {
66
+ onDrag: (instance) => {
71
67
  handleChange(instance.sortedValues);
72
68
  },
73
- onChange: function onChange(instance) {
69
+ onChange: (instance) => {
74
70
  handleChange(instance.sortedValues);
75
71
  }
76
72
  });
77
- var handleLineClick = function handleLineClick(event) {
78
- var clicked = rangerInstance.getValueForClientX(event.clientX);
79
- var newValue = rangerInstance.roundToStep(clicked);
80
- var handleValues = mapUserAllocationToHandles(allocations);
81
- var closestIndex = getClosestIndex(handleValues, clicked);
82
- var updatedValues = handleValues.map(function (item, index) {
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 /*#__PURE__*/React.createElement(SliderProvider, {
90
- rangerInstance: rangerInstance,
91
- rangerHandles: rangerHandlesRef
92
- }, /*#__PURE__*/React.createElement(S.SliderWrapper, {
93
- ref: rangerRef,
94
- $disabled: disabled
95
- }, /*#__PURE__*/React.createElement(SliderAbove, {
96
- label: label,
97
- description: description
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 { type DefaultSliderProps } from '../Slider.types';
1
+ import { default as React } from 'react';
2
+ import { DefaultSliderProps } from '../Slider.types';
3
3
  export declare const DefaultSlider: (props: DefaultSliderProps) => React.JSX.Element;