@synerise/ds-slider 0.12.28 → 0.13.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +19 -0
- package/README.md +1 -0
- package/dist/Allocation/Allocation.d.ts +2 -2
- package/dist/Allocation/Allocation.js +40 -6
- package/dist/Allocation/Allocation.styles.d.ts +3 -1
- package/dist/Allocation/Allocation.styles.js +26 -1
- package/dist/Allocation/Allocation.types.d.ts +11 -5
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlerWthTooltip.styles.d.ts +4 -0
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlerWthTooltip.styles.js +12 -0
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlersWithTooltip.d.ts +8 -0
- package/dist/Allocation/BlockedHandlersWithTooltip/BlockedHandlersWithTooltip.js +21 -0
- package/dist/Allocation/BlockedHandlersWithTooltip/index.d.ts +1 -0
- package/dist/Allocation/BlockedHandlersWithTooltip/index.js +1 -0
- package/dist/Slider.types.d.ts +10 -4
- package/dist/utils/allocation.utils.d.ts +1 -1
- package/dist/utils/allocation.utils.js +6 -5
- package/dist/utils/allocationHandlers.utils.d.ts +6 -0
- package/dist/utils/allocationHandlers.utils.js +30 -0
- package/package.json +6 -5
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,25 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [0.13.1](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.13.0...@synerise/ds-slider@0.13.1) (2023-10-11)
|
|
7
|
+
|
|
8
|
+
**Note:** Version bump only for package @synerise/ds-slider
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
# [0.13.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.28...@synerise/ds-slider@0.13.0) (2023-10-06)
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
### Features
|
|
18
|
+
|
|
19
|
+
* **slider:** add possibility to block allocation handler ([7c8f33c](https://github.com/Synerise/synerise-design/commit/7c8f33c7b2ca2616a53f94370161030e350d16e4))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
6
25
|
## [0.12.28](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.27...@synerise/ds-slider@0.12.28) (2023-10-02)
|
|
7
26
|
|
|
8
27
|
**Note:** Version bump only for package @synerise/ds-slider
|
package/README.md
CHANGED
|
@@ -67,6 +67,7 @@ import Slider from '@synerise/ds-slider';
|
|
|
67
67
|
| inverted | Allow to use slider in inverted mode. Applies only when value is `number or [number, number]` | Boolean | `false` |
|
|
68
68
|
| useColorPalette | Allow the usage of predefined palette for slider tracks | Boolean | `false` |
|
|
69
69
|
| tracksColorMap | Allow to import your 10 colors color map. | Object | |
|
|
70
|
+
| handlers | Handlers config object for allocation slider. Allow to manipulate handlers e.g. enable to block handler. First handler index is 1. | HandlerConfig | - |
|
|
70
71
|
|
|
71
72
|
### AllocationConfig
|
|
72
73
|
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { SliderProps } from '../Slider.types';
|
|
2
|
-
declare const Allocation: ({ allocationConfig, tracksColorMap, description, tipFormatter, ...rest }: SliderProps) => JSX.Element;
|
|
1
|
+
import type { SliderProps } from '../Slider.types';
|
|
2
|
+
declare const Allocation: ({ allocationConfig, tracksColorMap, description, tipFormatter, handlers, ...rest }: SliderProps) => JSX.Element;
|
|
3
3
|
export default Allocation;
|
|
@@ -1,16 +1,18 @@
|
|
|
1
|
-
var _excluded = ["allocationConfig", "tracksColorMap", "description", "tipFormatter"];
|
|
1
|
+
var _excluded = ["allocationConfig", "tracksColorMap", "description", "tipFormatter", "handlers"];
|
|
2
2
|
|
|
3
3
|
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
|
|
7
|
-
import React, { useState, useEffect } from 'react';
|
|
8
|
-
import Tooltip from '@synerise/ds-tooltip';
|
|
7
|
+
import React, { useState, useEffect, useMemo } from 'react';
|
|
9
8
|
import { useIntl } from 'react-intl';
|
|
9
|
+
import Tooltip from '@synerise/ds-tooltip';
|
|
10
10
|
import { DescriptionWrapper, Description } from '../Slider.styles';
|
|
11
11
|
import { buildDefaultTracksColorMap } from '../Slider';
|
|
12
|
+
import { checkIsPercentageInBoundaries, countAllocation, mapSliderValueToVariants, mapUserAllocationToHandles, mapUserAllocationToMarks } from '../utils/allocation.utils';
|
|
13
|
+
import { BlockedHandlersWithTooltip } from './BlockedHandlersWithTooltip';
|
|
14
|
+
import { calculateHandlersPercentagePosition, checkIsBlockedHandlersConfigEnabled, checkIsBlockedVariantsChange, getBlockedHandlersKeys } from '../utils/allocationHandlers.utils';
|
|
12
15
|
import * as S from './Allocation.styles';
|
|
13
|
-
import { countAllocation, isLowerOrUpperBound, mapSliderValueToVariants, mapUserAllocationToHandles, mapUserAllocationToMarks } from '../utils/allocation.utils';
|
|
14
16
|
|
|
15
17
|
var Allocation = function Allocation(_ref) {
|
|
16
18
|
var allocationConfig = _ref.allocationConfig,
|
|
@@ -18,6 +20,7 @@ var Allocation = function Allocation(_ref) {
|
|
|
18
20
|
tracksColorMap = _ref$tracksColorMap === void 0 ? buildDefaultTracksColorMap() : _ref$tracksColorMap,
|
|
19
21
|
description = _ref.description,
|
|
20
22
|
_tipFormatter = _ref.tipFormatter,
|
|
23
|
+
handlers = _ref.handlers,
|
|
21
24
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
22
25
|
|
|
23
26
|
var _ref2 = allocationConfig,
|
|
@@ -57,13 +60,39 @@ var Allocation = function Allocation(_ref) {
|
|
|
57
60
|
}))));
|
|
58
61
|
};
|
|
59
62
|
|
|
63
|
+
var currentHandlersPercentagePositions = calculateHandlersPercentagePosition(variants);
|
|
64
|
+
|
|
65
|
+
var _useMemo = useMemo(function () {
|
|
66
|
+
return {
|
|
67
|
+
blockedHandlersKeys: getBlockedHandlersKeys(handlers),
|
|
68
|
+
isBlockedHandlersConfigEnabled: checkIsBlockedHandlersConfigEnabled(handlers)
|
|
69
|
+
};
|
|
70
|
+
}, [handlers]),
|
|
71
|
+
blockedHandlersKeys = _useMemo.blockedHandlersKeys,
|
|
72
|
+
isBlockedHandlersConfigEnabled = _useMemo.isBlockedHandlersConfigEnabled;
|
|
73
|
+
|
|
60
74
|
var handleChange = function handleChange(value) {
|
|
61
75
|
if (typeof value === 'number') {
|
|
62
76
|
return;
|
|
63
77
|
}
|
|
64
78
|
|
|
65
79
|
var calculatedVariants = mapSliderValueToVariants(value, variants);
|
|
66
|
-
|
|
80
|
+
|
|
81
|
+
if (!checkIsPercentageInBoundaries(calculatedVariants)) {
|
|
82
|
+
return;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
if (isBlockedHandlersConfigEnabled) {
|
|
86
|
+
var afterChangeHandlersPercentagePositions = calculateHandlersPercentagePosition(calculatedVariants);
|
|
87
|
+
var isBlockedVariantChanged = checkIsBlockedVariantsChange(blockedHandlersKeys, currentHandlersPercentagePositions, afterChangeHandlersPercentagePositions);
|
|
88
|
+
|
|
89
|
+
if (isBlockedVariantChanged) {
|
|
90
|
+
return;
|
|
91
|
+
}
|
|
92
|
+
} // eslint-disable-next-line no-unused-expressions
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
onAllocationChange == null ? void 0 : onAllocationChange(calculatedVariants);
|
|
67
96
|
};
|
|
68
97
|
|
|
69
98
|
return /*#__PURE__*/React.createElement(S.AllocationSlider, _extends({}, rest, {
|
|
@@ -79,7 +108,12 @@ var Allocation = function Allocation(_ref) {
|
|
|
79
108
|
step: 1,
|
|
80
109
|
tipFormatter: function tipFormatter(value) {
|
|
81
110
|
return /*#__PURE__*/React.createElement(DescriptionWrapper, null, description && /*#__PURE__*/React.createElement(Description, null, description), _tipFormatter && _tipFormatter(value));
|
|
82
|
-
}
|
|
111
|
+
},
|
|
112
|
+
blockedHandlersKeys: blockedHandlersKeys
|
|
113
|
+
}), /*#__PURE__*/React.createElement(BlockedHandlersWithTooltip, {
|
|
114
|
+
blockedHandlersKeys: blockedHandlersKeys,
|
|
115
|
+
handlersPosition: currentHandlersPercentagePositions,
|
|
116
|
+
handlers: handlers
|
|
83
117
|
}), /*#__PURE__*/React.createElement(S.TrackContainer, {
|
|
84
118
|
controlGroup: controlGroupEnabled
|
|
85
119
|
}, allocations.map(function (u, index) {
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import { SliderProps } from '../Slider.types';
|
|
3
|
-
import { TrackProps } from './Allocation.types';
|
|
3
|
+
import type { TrackProps } from './Allocation.types';
|
|
4
4
|
export declare const INDEX_MAP: {
|
|
5
5
|
'0': string;
|
|
6
6
|
'1': string;
|
|
@@ -16,6 +16,8 @@ export declare const INDEX_MAP: {
|
|
|
16
16
|
export declare const AllocationSlider: import("styled-components").StyledComponent<import("react").ComponentType<Omit<import("antd/lib/slider").SliderSingleProps | import("antd/lib/slider").SliderRangeProps, "value">>, any, SliderProps & {
|
|
17
17
|
reachedEnd?: boolean | undefined;
|
|
18
18
|
reachedStart?: boolean | undefined;
|
|
19
|
+
} & {
|
|
20
|
+
blockedHandlersKeys: number[];
|
|
19
21
|
}, never>;
|
|
20
22
|
export declare const Mark: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
21
23
|
export declare const MarkLetter: import("styled-components").StyledComponent<"div", any, {
|
|
@@ -1,6 +1,23 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
2
|
import { AntdSlider, createTracksStyles } from '../Slider.styles';
|
|
3
3
|
import { buildDefaultTracksColorMap } from '../Slider';
|
|
4
|
+
|
|
5
|
+
var defineCssSelectorWithRule = function defineCssSelectorWithRule(_ref) {
|
|
6
|
+
var indexes = _ref.indexes,
|
|
7
|
+
classConstPart = _ref.classConstPart,
|
|
8
|
+
cssRule = _ref.cssRule;
|
|
9
|
+
var variantsSize = indexes.length;
|
|
10
|
+
|
|
11
|
+
if (variantsSize === 0) {
|
|
12
|
+
return '';
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var definedClassSpecificity = indexes.reduce(function (result, item, index) {
|
|
16
|
+
return "" + result + classConstPart + item + (index + 1 === variantsSize ? '' : ', ');
|
|
17
|
+
}, '');
|
|
18
|
+
return definedClassSpecificity + " { " + cssRule + " }";
|
|
19
|
+
};
|
|
20
|
+
|
|
4
21
|
export var INDEX_MAP = {
|
|
5
22
|
'0': 'cyan-600',
|
|
6
23
|
'1': 'yellow-600',
|
|
@@ -16,10 +33,18 @@ export var INDEX_MAP = {
|
|
|
16
33
|
export var AllocationSlider = styled(AntdSlider).withConfig({
|
|
17
34
|
displayName: "Allocationstyles__AllocationSlider",
|
|
18
35
|
componentId: "y7ylxd-0"
|
|
19
|
-
})(["", " &.ant-slider:hover{", ";}.ant-slider-handle-value,.ant-slider-rail,.ant-slider-track,.ant-slider-dot{display:none;}&& .ant-slider-mark-text:last-of-type{padding-right:0;}&& .ant-slider-mark-text{user-select:none;}"], function (props) {
|
|
36
|
+
})(["", " &.ant-slider:hover{", ";}.ant-slider-handle-value,.ant-slider-rail,.ant-slider-track,.ant-slider-dot{display:none;}&& .ant-slider-mark-text:last-of-type{padding-right:0;}&& .ant-slider-mark-text{user-select:none;}&& ", ""], function (props) {
|
|
20
37
|
return createTracksStyles(props, props.tracksColorMap ? props.tracksColorMap : INDEX_MAP);
|
|
21
38
|
}, function (props) {
|
|
22
39
|
return createTracksStyles(props, props.tracksColorMap ? props.tracksColorMap : INDEX_MAP);
|
|
40
|
+
}, function (_ref2) {
|
|
41
|
+
var blockedHandlersKeys = _ref2.blockedHandlersKeys,
|
|
42
|
+
theme = _ref2.theme;
|
|
43
|
+
return defineCssSelectorWithRule({
|
|
44
|
+
indexes: blockedHandlersKeys,
|
|
45
|
+
classConstPart: '.ant-slider-handle-',
|
|
46
|
+
cssRule: "\n background-color: " + theme.palette['grey-300'] + ";\n box-shadow:none !important;\n pointer-events: none;\n z-index:97;\n border-color: " + theme.palette.white + " !important;\n "
|
|
47
|
+
});
|
|
23
48
|
});
|
|
24
49
|
export var Mark = styled.div.withConfig({
|
|
25
50
|
displayName: "Allocationstyles__Mark",
|
|
@@ -1,16 +1,17 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
2
2
|
export type AllocationConfig = {
|
|
3
3
|
controlGroupEnabled?: boolean;
|
|
4
|
-
controlGroupLabel?:
|
|
5
|
-
controlGroupTooltip?:
|
|
4
|
+
controlGroupLabel?: ReactNode;
|
|
5
|
+
controlGroupTooltip?: ReactNode;
|
|
6
6
|
variants?: AllocationVariant[];
|
|
7
7
|
onAllocationChange?: (variants?: AllocationVariant[]) => void;
|
|
8
8
|
};
|
|
9
9
|
export type AllocationVariant = {
|
|
10
|
-
name:
|
|
10
|
+
name: ReactNode;
|
|
11
11
|
percentage: number;
|
|
12
12
|
tabId: number;
|
|
13
|
-
tabLetter:
|
|
13
|
+
tabLetter: ReactNode;
|
|
14
|
+
minPercentage?: number;
|
|
14
15
|
};
|
|
15
16
|
export type AllocationMark = {
|
|
16
17
|
value: string;
|
|
@@ -22,3 +23,8 @@ export type TrackProps = {
|
|
|
22
23
|
isCustomColor?: boolean;
|
|
23
24
|
getColor?: (index: number) => string;
|
|
24
25
|
};
|
|
26
|
+
export type DefinedCssRuleParameters = {
|
|
27
|
+
indexes: number[];
|
|
28
|
+
classConstPart: string;
|
|
29
|
+
cssRule: string;
|
|
30
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
export var BlockedHandlerWithTooltipWrapper = styled.div.withConfig({
|
|
3
|
+
displayName: "BlockedHandlerWthTooltipstyles__BlockedHandlerWithTooltipWrapper",
|
|
4
|
+
componentId: "rkqwtm-0"
|
|
5
|
+
})(["position:relative;"]);
|
|
6
|
+
export var ElementOverHandler = styled.div.withConfig({
|
|
7
|
+
displayName: "BlockedHandlerWthTooltipstyles__ElementOverHandler",
|
|
8
|
+
componentId: "rkqwtm-1"
|
|
9
|
+
})(["width:20px;height:20px;z-index:98;cursor:not-allowed;border-radius:50%;border:3px solid transparent;background-color:transparent;position:absolute;top:-8px;left:", "%;transform:translateX(-50%);"], function (_ref) {
|
|
10
|
+
var position = _ref.position;
|
|
11
|
+
return position;
|
|
12
|
+
});
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { HandlerConfig } from '../../Slider.types';
|
|
2
|
+
type BlockedHandlersWithTooltipProps = {
|
|
3
|
+
blockedHandlersKeys: number[];
|
|
4
|
+
handlersPosition: number[];
|
|
5
|
+
handlers?: HandlerConfig;
|
|
6
|
+
};
|
|
7
|
+
export declare const BlockedHandlersWithTooltip: ({ blockedHandlersKeys, handlers, handlersPosition, }: BlockedHandlersWithTooltipProps) => JSX.Element;
|
|
8
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
2
|
+
|
|
3
|
+
import * as React from 'react';
|
|
4
|
+
import Tooltip from '@synerise/ds-tooltip';
|
|
5
|
+
import * as S from './BlockedHandlerWthTooltip.styles';
|
|
6
|
+
export var BlockedHandlersWithTooltip = function BlockedHandlersWithTooltip(_ref) {
|
|
7
|
+
var blockedHandlersKeys = _ref.blockedHandlersKeys,
|
|
8
|
+
handlers = _ref.handlers,
|
|
9
|
+
handlersPosition = _ref.handlersPosition;
|
|
10
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null, blockedHandlersKeys.map(function (blockedHandlerKey) {
|
|
11
|
+
return /*#__PURE__*/React.createElement(S.BlockedHandlerWithTooltipWrapper, {
|
|
12
|
+
key: blockedHandlerKey
|
|
13
|
+
}, /*#__PURE__*/React.createElement(Tooltip, _extends({}, handlers == null ? void 0 : handlers[blockedHandlerKey].blockedTooltipProps, {
|
|
14
|
+
overlayStyle: {
|
|
15
|
+
zIndex: 999999
|
|
16
|
+
}
|
|
17
|
+
}), /*#__PURE__*/React.createElement(S.ElementOverHandler, {
|
|
18
|
+
position: handlersPosition[blockedHandlerKey - 1]
|
|
19
|
+
})));
|
|
20
|
+
}));
|
|
21
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlockedHandlersWithTooltip';
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './BlockedHandlersWithTooltip';
|
package/dist/Slider.types.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import type { ReactNode } from 'react';
|
|
1
2
|
import { SliderSingleProps, SliderRangeProps } from 'antd/lib/slider';
|
|
2
|
-
import
|
|
3
|
-
import { AllocationConfig } from '
|
|
3
|
+
import type { TooltipProps } from '@synerise/ds-tooltip';
|
|
4
|
+
import { AllocationConfig } from 'Allocation/Allocation.types';
|
|
4
5
|
type AntSliderProps = SliderSingleProps | SliderRangeProps;
|
|
5
6
|
export type AntdSliderProps = Omit<AntSliderProps, 'value'>;
|
|
6
7
|
export declare enum SliderTypes {
|
|
@@ -10,18 +11,23 @@ export declare enum SliderTypes {
|
|
|
10
11
|
export declare type ColorMapProps = {
|
|
11
12
|
[key: string]: string;
|
|
12
13
|
};
|
|
14
|
+
export type HandlerConfig = Record<number, {
|
|
15
|
+
blocked: boolean;
|
|
16
|
+
blockedTooltipProps?: TooltipProps;
|
|
17
|
+
}>;
|
|
13
18
|
export interface SliderProps extends AntdSliderProps {
|
|
14
19
|
type?: 'allocation' | 'default';
|
|
15
20
|
allocationConfig?: AllocationConfig;
|
|
16
|
-
label?:
|
|
21
|
+
label?: ReactNode;
|
|
17
22
|
value?: number | number[];
|
|
18
23
|
inverted?: boolean;
|
|
19
24
|
useColorPalette?: boolean;
|
|
20
25
|
autoFocus?: boolean;
|
|
21
26
|
tracksColorMap?: ColorMapProps;
|
|
22
27
|
thickness?: number;
|
|
23
|
-
description?:
|
|
28
|
+
description?: ReactNode;
|
|
24
29
|
hideMinAndMaxMarks?: boolean;
|
|
25
30
|
disabled?: boolean;
|
|
31
|
+
handlers?: HandlerConfig;
|
|
26
32
|
}
|
|
27
33
|
export {};
|
|
@@ -6,4 +6,4 @@ export declare const recalculateVariantsAllocation: (variants: AllocationVariant
|
|
|
6
6
|
export declare const mapUserAllocationToHandles: (userAllocation: number[]) => number[];
|
|
7
7
|
export declare const mapUserAllocationToMarks: (userAllocation: number[], markRenderer: Function, variants?: AllocationVariant[]) => AllocationMark;
|
|
8
8
|
export declare const mapSliderValueToVariants: (value: number[], variants?: Partial<AllocationVariant>[]) => AllocationVariant[];
|
|
9
|
-
export declare const
|
|
9
|
+
export declare const checkIsPercentageInBoundaries: (variants: AllocationVariant[]) => boolean;
|
|
@@ -99,10 +99,11 @@ export var mapSliderValueToVariants = function mapSliderValueToVariants(value, v
|
|
|
99
99
|
allocation.push(countControlGroupAllocation(allocation));
|
|
100
100
|
return mergeAllocationWithVariants(variants, allocation);
|
|
101
101
|
};
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
102
|
+
var DEFAULT_MIN_PERCENTAGE = 1;
|
|
103
|
+
export var checkIsPercentageInBoundaries = function checkIsPercentageInBoundaries(variants) {
|
|
104
|
+
return !variants.some(function (variant) {
|
|
105
|
+
var _variant$minPercentag;
|
|
106
|
+
|
|
107
|
+
return variant.percentage < ((_variant$minPercentag = variant.minPercentage) != null ? _variant$minPercentag : DEFAULT_MIN_PERCENTAGE);
|
|
107
108
|
});
|
|
108
109
|
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import type { HandlerConfig } from '../Slider.types';
|
|
2
|
+
import type { AllocationVariant } from '../Allocation/Allocation.types';
|
|
3
|
+
export declare const calculateHandlersPercentagePosition: (variants?: AllocationVariant[]) => number[];
|
|
4
|
+
export declare const getBlockedHandlersKeys: (handlers?: HandlerConfig) => number[];
|
|
5
|
+
export declare const checkIsBlockedHandlersConfigEnabled: (handlers?: HandlerConfig) => boolean;
|
|
6
|
+
export declare const checkIsBlockedVariantsChange: (blockedHandlersKeys: number[], currentHandlersPercentagePositions: number[], afterChangeHandlersPercentagePositions: number[]) => boolean;
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
export var calculateHandlersPercentagePosition = function calculateHandlersPercentagePosition(variants) {
|
|
2
|
+
if (!variants) {
|
|
3
|
+
return [];
|
|
4
|
+
}
|
|
5
|
+
|
|
6
|
+
return variants == null ? void 0 : variants.reduce(function (prev, curr) {
|
|
7
|
+
return [].concat(prev, [curr.percentage + (prev.length ? prev[prev.length - 1] : 0)]);
|
|
8
|
+
}, []).slice(0, -1);
|
|
9
|
+
};
|
|
10
|
+
export var getBlockedHandlersKeys = function getBlockedHandlersKeys(handlers) {
|
|
11
|
+
if (!handlers) {
|
|
12
|
+
return [];
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
var blockedHandlersKeys = Object.keys(handlers).filter(function (handlerKey) {
|
|
16
|
+
return handlers[handlerKey].blocked;
|
|
17
|
+
});
|
|
18
|
+
return blockedHandlersKeys.map(Number);
|
|
19
|
+
};
|
|
20
|
+
export var checkIsBlockedHandlersConfigEnabled = function checkIsBlockedHandlersConfigEnabled(handlers) {
|
|
21
|
+
return !!handlers && Object.values(handlers).some(function (_ref) {
|
|
22
|
+
var blocked = _ref.blocked;
|
|
23
|
+
return blocked;
|
|
24
|
+
});
|
|
25
|
+
};
|
|
26
|
+
export var checkIsBlockedVariantsChange = function checkIsBlockedVariantsChange(blockedHandlersKeys, currentHandlersPercentagePositions, afterChangeHandlersPercentagePositions) {
|
|
27
|
+
return blockedHandlersKeys.some(function (blockedHandlerKey) {
|
|
28
|
+
return currentHandlersPercentagePositions[blockedHandlerKey - 1] !== afterChangeHandlersPercentagePositions[blockedHandlerKey - 1];
|
|
29
|
+
});
|
|
30
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-slider",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.13.1",
|
|
4
4
|
"description": "Slider UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
"build:js": "babel --root-mode upward src --out-dir dist --extensions '.js,.ts,.tsx'",
|
|
22
22
|
"build:watch": "npm run build:js -- --watch",
|
|
23
23
|
"defs": "tsc --declaration --outDir dist/ --emitDeclarationOnly",
|
|
24
|
+
"pack:ci": "npm pack --pack-destination ../../portal/storybook-static/static",
|
|
24
25
|
"prepublish": "npm run build",
|
|
25
26
|
"test": "jest",
|
|
26
27
|
"test:watch": "npm run test -- --watchAll",
|
|
@@ -32,8 +33,8 @@
|
|
|
32
33
|
],
|
|
33
34
|
"types": "dist/index.d.ts",
|
|
34
35
|
"dependencies": {
|
|
35
|
-
"@synerise/ds-tooltip": "^0.14.
|
|
36
|
-
"@synerise/ds-typography": "^0.13.
|
|
36
|
+
"@synerise/ds-tooltip": "^0.14.6",
|
|
37
|
+
"@synerise/ds-typography": "^0.13.2",
|
|
37
38
|
"react-intl": "3.12.0"
|
|
38
39
|
},
|
|
39
40
|
"peerDependencies": {
|
|
@@ -43,8 +44,8 @@
|
|
|
43
44
|
"styled-components": "5.0.1"
|
|
44
45
|
},
|
|
45
46
|
"devDependencies": {
|
|
46
|
-
"@synerise/ds-utils": "^0.24.
|
|
47
|
+
"@synerise/ds-utils": "^0.24.18",
|
|
47
48
|
"@testing-library/react": "10.0.1"
|
|
48
49
|
},
|
|
49
|
-
"gitHead": "
|
|
50
|
+
"gitHead": "8eb4a3e304406a8dbb9258803c48952461fc5a55"
|
|
50
51
|
}
|