@synerise/ds-slider 0.12.27 → 0.13.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 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.0](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.28...@synerise/ds-slider@0.13.0) (2023-10-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * **slider:** add possibility to block allocation handler ([7c8f33c](https://github.com/Synerise/synerise-design/commit/7c8f33c7b2ca2616a53f94370161030e350d16e4))
12
+
13
+
14
+
15
+
16
+
17
+ ## [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)
18
+
19
+ **Note:** Version bump only for package @synerise/ds-slider
20
+
21
+
22
+
23
+
24
+
6
25
  ## [0.12.27](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.26...@synerise/ds-slider@0.12.27) (2023-09-26)
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,4 +1,3 @@
1
- /// <reference types="react" />
2
- import { SliderProps } from '../Slider.types';
3
- 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;
4
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
- !isLowerOrUpperBound(value, calculatedVariants) && onAllocationChange && onAllocationChange(calculatedVariants);
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,21 +1,23 @@
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
- 0: string;
6
- 1: string;
7
- 2: string;
8
- 3: string;
9
- 4: string;
10
- 5: string;
11
- 6: string;
12
- 7: string;
13
- 8: string;
14
- 9: string;
5
+ '0': string;
6
+ '1': string;
7
+ '2': string;
8
+ '3': string;
9
+ '4': string;
10
+ '5': string;
11
+ '6': string;
12
+ '7': string;
13
+ '8': string;
14
+ '9': string;
15
15
  };
16
- export declare const AllocationSlider: import("styled-components").StyledComponent<import("react").ComponentType<Pick<import("antd/lib/slider").SliderSingleProps | import("antd/lib/slider").SliderRangeProps, "range" | "defaultValue" | "onChange" | "onAfterChange" | "handleStyle" | "trackStyle" | "prefixCls" | "tooltipPrefixCls" | "reverse" | "min" | "max" | "step" | "marks" | "dots" | "included" | "disabled" | "vertical" | "tipFormatter" | "className" | "id" | "style" | "tooltipVisible" | "tooltipPlacement" | "getTooltipPopupContainer" | "autoFocus">>, any, SliderProps & {
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,24 +1,30 @@
1
- import * as React from 'react';
2
- export declare type AllocationConfig = {
1
+ import type { ReactNode } from 'react';
2
+ export type AllocationConfig = {
3
3
  controlGroupEnabled?: boolean;
4
- controlGroupLabel?: string | React.ReactNode;
5
- controlGroupTooltip?: string | React.ReactNode;
4
+ controlGroupLabel?: ReactNode;
5
+ controlGroupTooltip?: ReactNode;
6
6
  variants?: AllocationVariant[];
7
7
  onAllocationChange?: (variants?: AllocationVariant[]) => void;
8
8
  };
9
- export declare type AllocationVariant = {
10
- name: string | React.ReactNode;
9
+ export type AllocationVariant = {
10
+ name: ReactNode;
11
11
  percentage: number;
12
12
  tabId: number;
13
- tabLetter: string | React.ReactNode;
13
+ tabLetter: ReactNode;
14
+ minPercentage?: number;
14
15
  };
15
- export declare type AllocationMark = {
16
+ export type AllocationMark = {
16
17
  value: string;
17
18
  view: number;
18
19
  };
19
- export declare type TrackProps = {
20
+ export type TrackProps = {
20
21
  width: number;
21
22
  index: number;
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,4 @@
1
+ export declare const BlockedHandlerWithTooltipWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
2
+ export declare const ElementOverHandler: import("styled-components").StyledComponent<"div", any, {
3
+ position: number;
4
+ }, never>;
@@ -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.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- /// <reference types="react" />
2
1
  import '@synerise/ds-core/dist/js/style';
3
2
  import './style/index.less';
4
3
  import { ColorMapProps, SliderProps } from './Slider.types';
@@ -3,6 +3,7 @@ import { SliderSingleProps, SliderRangeProps } from 'antd/lib/slider';
3
3
  import { ThemeProps } from '@synerise/ds-core';
4
4
  import { ComponentType } from 'react';
5
5
  import { ColorMapProps, SliderProps as DsSliderProps } from './Slider.types';
6
+ type SliderProps = SliderSingleProps | SliderRangeProps;
6
7
  export declare const Description: import("styled-components").StyledComponent<"div", any, {
7
8
  range?: boolean | undefined;
8
9
  }, never>;
@@ -10,9 +11,9 @@ export declare const LabelWrapper: import("styled-components").StyledComponent<"
10
11
  export declare const DescriptionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
11
12
  export declare const applyTooltipStyles: (props: ThemeProps & DsSliderProps & SliderStyles) => FlattenSimpleInterpolation;
12
13
  export declare const createTracksStyles: (props: ThemeProps & DsSliderProps, colorsMap: ColorMapProps) => FlattenSimpleInterpolation;
13
- declare type SliderStyles = {
14
+ type SliderStyles = {
14
15
  reachedEnd?: boolean;
15
16
  reachedStart?: boolean;
16
17
  };
17
- export declare const AntdSlider: import("styled-components").StyledComponent<ComponentType<Pick<SliderSingleProps | SliderRangeProps, "range" | "defaultValue" | "onChange" | "onAfterChange" | "handleStyle" | "trackStyle" | "prefixCls" | "tooltipPrefixCls" | "reverse" | "min" | "max" | "step" | "marks" | "dots" | "included" | "disabled" | "vertical" | "tipFormatter" | "className" | "id" | "style" | "tooltipVisible" | "tooltipPlacement" | "getTooltipPopupContainer" | "autoFocus">>, any, DsSliderProps & SliderStyles, never>;
18
+ export declare const AntdSlider: import("styled-components").StyledComponent<ComponentType<Omit<SliderProps, "value">>, any, DsSliderProps & SliderStyles, never>;
18
19
  export {};
@@ -1,8 +1,9 @@
1
+ import type { ReactNode } from 'react';
1
2
  import { SliderSingleProps, SliderRangeProps } from 'antd/lib/slider';
2
- import * as React from 'react';
3
- import { AllocationConfig } from './Allocation/Allocation.types';
4
- declare type AntSliderProps = SliderSingleProps | SliderRangeProps;
5
- export declare type AntdSliderProps = Omit<AntSliderProps, 'value'>;
3
+ import type { TooltipProps } from '@synerise/ds-tooltip';
4
+ import { AllocationConfig } from 'Allocation/Allocation.types';
5
+ type AntSliderProps = SliderSingleProps | SliderRangeProps;
6
+ export type AntdSliderProps = Omit<AntSliderProps, 'value'>;
6
7
  export declare enum SliderTypes {
7
8
  ALLOCATION = "allocation",
8
9
  DEFAULT = "default"
@@ -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?: React.ReactNode | string;
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?: React.ReactNode | string;
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 isLowerOrUpperBound: (sliderValue: number[], variants: AllocationVariant[]) => boolean;
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
- export var isLowerOrUpperBound = function isLowerOrUpperBound(sliderValue, variants) {
103
- return !!sliderValue.find(function (v) {
104
- return v === 100;
105
- }) || !!variants.find(function (v) {
106
- return v.percentage < 1;
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.12.27",
3
+ "version": "0.13.0",
4
4
  "description": "Slider UI Component for the Synerise Design System",
5
5
  "license": "ISC",
6
6
  "repository": "Synerise/synerise-design",
@@ -32,8 +32,8 @@
32
32
  ],
33
33
  "types": "dist/index.d.ts",
34
34
  "dependencies": {
35
- "@synerise/ds-tooltip": "^0.14.4",
36
- "@synerise/ds-typography": "^0.13.0",
35
+ "@synerise/ds-tooltip": "^0.14.5",
36
+ "@synerise/ds-typography": "^0.13.1",
37
37
  "react-intl": "3.12.0"
38
38
  },
39
39
  "peerDependencies": {
@@ -43,8 +43,8 @@
43
43
  "styled-components": "5.0.1"
44
44
  },
45
45
  "devDependencies": {
46
- "@synerise/ds-utils": "^0.24.16",
46
+ "@synerise/ds-utils": "^0.24.17",
47
47
  "@testing-library/react": "10.0.1"
48
48
  },
49
- "gitHead": "f1f520c4c5ef9f90bacb5d5e0b2e778ceb8fdf79"
49
+ "gitHead": "d944339a738211d8f74b27360481aafd7ef51ddd"
50
50
  }