@synerise/ds-slider 0.12.23 → 0.12.24
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 +13 -0
- package/dist/Allocation/Allocation.d.ts +2 -2
- package/dist/Allocation/Allocation.js +18 -11
- package/dist/Allocation/Allocation.styles.d.ts +1 -1
- package/dist/Allocation/Allocation.styles.js +8 -4
- package/dist/Slider.d.ts +5 -0
- package/dist/Slider.js +6 -0
- package/dist/Slider.styles.d.ts +2 -1
- package/dist/Slider.styles.js +2 -4
- package/dist/index.d.ts +1 -0
- package/dist/{Allocation/utils.d.ts → utils/allocation.utils.d.ts} +1 -1
- package/package.json +2 -2
- /package/dist/{Allocation/utils.js → utils/allocation.utils.js} +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,19 @@
|
|
|
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.12.24](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.23...@synerise/ds-slider@0.12.24) (2023-08-30)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **slider:** code review feedback + story fixes ([d06667c](https://github.com/Synerise/synerise-design/commit/d06667ce841b4c1ce2af0cb4cfd58fe81ec2a1ea))
|
|
12
|
+
* **slider:** fixed styles in allocation slider ([3c515ea](https://github.com/Synerise/synerise-design/commit/3c515eada4001013b3b37a44dbd8d44bbb89f64a))
|
|
13
|
+
* **slider:** style segments in segmented multivalue slider ([45704a7](https://github.com/Synerise/synerise-design/commit/45704a7feb04fcf0e74acc14d49cdd95953f6834))
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
6
19
|
## [0.12.23](https://github.com/Synerise/synerise-design/compare/@synerise/ds-slider@0.12.22...@synerise/ds-slider@0.12.23) (2023-08-22)
|
|
7
20
|
|
|
8
21
|
**Note:** Version bump only for package @synerise/ds-slider
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="react" />
|
|
2
2
|
import { SliderProps } from '../Slider.types';
|
|
3
|
-
declare const Allocation:
|
|
3
|
+
declare const Allocation: ({ allocationConfig, tracksColorMap, description, tipFormatter, ...rest }: SliderProps) => JSX.Element;
|
|
4
4
|
export default Allocation;
|
|
@@ -4,16 +4,18 @@ function _extends() { _extends = Object.assign || function (target) { for (var i
|
|
|
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
|
|
7
|
+
import React, { useState, useEffect } from 'react';
|
|
8
8
|
import Tooltip from '@synerise/ds-tooltip';
|
|
9
9
|
import { useIntl } from 'react-intl';
|
|
10
10
|
import { DescriptionWrapper, Description } from '../Slider.styles';
|
|
11
|
+
import { buildDefaultTracksColorMap } from '../Slider';
|
|
11
12
|
import * as S from './Allocation.styles';
|
|
12
|
-
import { countAllocation, isLowerOrUpperBound, mapSliderValueToVariants, mapUserAllocationToHandles, mapUserAllocationToMarks } from '
|
|
13
|
+
import { countAllocation, isLowerOrUpperBound, mapSliderValueToVariants, mapUserAllocationToHandles, mapUserAllocationToMarks } from '../utils/allocation.utils';
|
|
13
14
|
|
|
14
15
|
var Allocation = function Allocation(_ref) {
|
|
15
16
|
var allocationConfig = _ref.allocationConfig,
|
|
16
|
-
tracksColorMap = _ref.tracksColorMap,
|
|
17
|
+
_ref$tracksColorMap = _ref.tracksColorMap,
|
|
18
|
+
tracksColorMap = _ref$tracksColorMap === void 0 ? buildDefaultTracksColorMap() : _ref$tracksColorMap,
|
|
17
19
|
description = _ref.description,
|
|
18
20
|
_tipFormatter = _ref.tipFormatter,
|
|
19
21
|
rest = _objectWithoutPropertiesLoose(_ref, _excluded);
|
|
@@ -25,20 +27,22 @@ var Allocation = function Allocation(_ref) {
|
|
|
25
27
|
controlGroupLabel = _ref2.controlGroupLabel,
|
|
26
28
|
controlGroupTooltip = _ref2.controlGroupTooltip;
|
|
27
29
|
|
|
28
|
-
var
|
|
29
|
-
allocations =
|
|
30
|
-
setAllocations =
|
|
30
|
+
var _useState = useState(countAllocation(variants, controlGroupEnabled)),
|
|
31
|
+
allocations = _useState[0],
|
|
32
|
+
setAllocations = _useState[1];
|
|
31
33
|
|
|
32
34
|
var intl = useIntl();
|
|
33
|
-
|
|
35
|
+
useEffect(function () {
|
|
34
36
|
setAllocations(countAllocation(variants, controlGroupEnabled));
|
|
35
37
|
}, [variants, controlGroupEnabled]);
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
var markRenderer = function markRenderer(value, index, allocationVariants) {
|
|
37
40
|
return /*#__PURE__*/React.createElement(S.Mark, {
|
|
38
41
|
className: "slider-mark"
|
|
39
42
|
}, /*#__PURE__*/React.createElement(S.MarkValue, null, value), allocationVariants[index] && /*#__PURE__*/React.createElement(Tooltip, {
|
|
40
43
|
title: /*#__PURE__*/React.createElement(S.MarkTooltipWrapper, null, allocationVariants[index].tabLetter)
|
|
41
44
|
}, /*#__PURE__*/React.createElement(S.MarkLetter, {
|
|
45
|
+
className: "ant-slider-segment-letter-" + index,
|
|
42
46
|
index: index
|
|
43
47
|
}, allocationVariants[index].tabLetter)), !allocationVariants[index] && /*#__PURE__*/React.createElement(Tooltip, {
|
|
44
48
|
title: controlGroupTooltip || intl.formatMessage({
|
|
@@ -51,15 +55,17 @@ var Allocation = function Allocation(_ref) {
|
|
|
51
55
|
id: 'DS.SLIDER.CONTROL-GROUP-TOOLTIP',
|
|
52
56
|
defaultMessage: 'CG'
|
|
53
57
|
}))));
|
|
54
|
-
}
|
|
55
|
-
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var handleChange = function handleChange(value) {
|
|
56
61
|
if (typeof value === 'number') {
|
|
57
62
|
return;
|
|
58
63
|
}
|
|
59
64
|
|
|
60
65
|
var calculatedVariants = mapSliderValueToVariants(value, variants);
|
|
61
66
|
!isLowerOrUpperBound(value, calculatedVariants) && onAllocationChange && onAllocationChange(calculatedVariants);
|
|
62
|
-
}
|
|
67
|
+
};
|
|
68
|
+
|
|
63
69
|
return /*#__PURE__*/React.createElement(S.AllocationSlider, _extends({}, rest, {
|
|
64
70
|
useColorPalette: true,
|
|
65
71
|
tracksColorMap: tracksColorMap,
|
|
@@ -82,6 +88,7 @@ var Allocation = function Allocation(_ref) {
|
|
|
82
88
|
// eslint-disable-next-line react/no-array-index-key
|
|
83
89
|
React.createElement(S.Track, {
|
|
84
90
|
key: u + "-" + index,
|
|
91
|
+
className: "ant-slider-segment-" + index,
|
|
85
92
|
index: index,
|
|
86
93
|
width: u
|
|
87
94
|
})
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import styled, { css } from 'styled-components';
|
|
2
|
-
import { AntdSlider } from '../Slider.styles';
|
|
2
|
+
import { AntdSlider, createTracksStyles } from '../Slider.styles';
|
|
3
3
|
import { buildDefaultTracksColorMap } from '../Slider';
|
|
4
|
-
export var
|
|
4
|
+
export var INDEX_MAP = {
|
|
5
5
|
'0': 'cyan-600',
|
|
6
6
|
'1': 'yellow-600',
|
|
7
7
|
'2': 'mars-600',
|
|
@@ -16,7 +16,11 @@ export var indexMap = {
|
|
|
16
16
|
export var AllocationSlider = styled(AntdSlider).withConfig({
|
|
17
17
|
displayName: "Allocationstyles__AllocationSlider",
|
|
18
18
|
componentId: "y7ylxd-0"
|
|
19
|
-
})([".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;}"])
|
|
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) {
|
|
20
|
+
return createTracksStyles(props, props.tracksColorMap ? props.tracksColorMap : INDEX_MAP);
|
|
21
|
+
}, function (props) {
|
|
22
|
+
return createTracksStyles(props, props.tracksColorMap ? props.tracksColorMap : INDEX_MAP);
|
|
23
|
+
});
|
|
20
24
|
export var Mark = styled.div.withConfig({
|
|
21
25
|
displayName: "Allocationstyles__Mark",
|
|
22
26
|
componentId: "y7ylxd-1"
|
|
@@ -33,7 +37,7 @@ var getColor = function getColor(props, defaultColor) {
|
|
|
33
37
|
return props.getColor && props.getColor(props.index) || defaultColor;
|
|
34
38
|
}
|
|
35
39
|
|
|
36
|
-
return props.theme.palette[(colors ||
|
|
40
|
+
return props.theme.palette[(colors || INDEX_MAP)[props.index] || defaultColor];
|
|
37
41
|
};
|
|
38
42
|
|
|
39
43
|
export var MarkLetter = styled.div.withConfig({
|
package/dist/Slider.d.ts
CHANGED
|
@@ -2,6 +2,11 @@
|
|
|
2
2
|
import '@synerise/ds-core/dist/js/style';
|
|
3
3
|
import './style/index.less';
|
|
4
4
|
import { ColorMapProps, SliderProps } from './Slider.types';
|
|
5
|
+
/**
|
|
6
|
+
* Converts an array of strings (e.g. colors) `["blue-600", "yellow-600"]`
|
|
7
|
+
* into `{"0": "blue-600", "1": "yellow-600"}`.
|
|
8
|
+
* @returns Object Record<string, string>
|
|
9
|
+
*/
|
|
5
10
|
export declare const buildDefaultTracksColorMap: () => ColorMapProps;
|
|
6
11
|
declare const Slider: (props: SliderProps) => JSX.Element;
|
|
7
12
|
export default Slider;
|
package/dist/Slider.js
CHANGED
|
@@ -26,6 +26,12 @@ var mapToColor = function mapToColor(_, idx) {
|
|
|
26
26
|
|
|
27
27
|
return _ref = {}, _ref[idx] = defaultColorsOrder[idx], _ref;
|
|
28
28
|
};
|
|
29
|
+
/**
|
|
30
|
+
* Converts an array of strings (e.g. colors) `["blue-600", "yellow-600"]`
|
|
31
|
+
* into `{"0": "blue-600", "1": "yellow-600"}`.
|
|
32
|
+
* @returns Object Record<string, string>
|
|
33
|
+
*/
|
|
34
|
+
|
|
29
35
|
|
|
30
36
|
export var buildDefaultTracksColorMap = function buildDefaultTracksColorMap() {
|
|
31
37
|
return Object.assign.apply(Object, [{}].concat(defaultColorsOrder.map(mapToColor)));
|
package/dist/Slider.styles.d.ts
CHANGED
|
@@ -2,13 +2,14 @@ import { FlattenSimpleInterpolation } from 'styled-components';
|
|
|
2
2
|
import { SliderSingleProps, SliderRangeProps } from 'antd/lib/slider';
|
|
3
3
|
import { ThemeProps } from '@synerise/ds-core';
|
|
4
4
|
import { ComponentType } from 'react';
|
|
5
|
-
import { SliderProps as DsSliderProps } from './Slider.types';
|
|
5
|
+
import { ColorMapProps, SliderProps as DsSliderProps } from './Slider.types';
|
|
6
6
|
export declare const Description: import("styled-components").StyledComponent<"div", any, {
|
|
7
7
|
range?: boolean | undefined;
|
|
8
8
|
}, never>;
|
|
9
9
|
export declare const LabelWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
10
10
|
export declare const DescriptionWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
11
11
|
export declare const applyTooltipStyles: (props: ThemeProps & DsSliderProps & SliderStyles) => FlattenSimpleInterpolation;
|
|
12
|
+
export declare const createTracksStyles: (props: ThemeProps & DsSliderProps, colorsMap: ColorMapProps) => FlattenSimpleInterpolation;
|
|
12
13
|
declare type SliderStyles = {
|
|
13
14
|
reachedEnd?: boolean;
|
|
14
15
|
reachedStart?: boolean;
|
package/dist/Slider.styles.js
CHANGED
|
@@ -31,15 +31,13 @@ export var DescriptionWrapper = styled.div.withConfig({
|
|
|
31
31
|
export var applyTooltipStyles = function applyTooltipStyles(props) {
|
|
32
32
|
return css([".ant-tooltip-inner{font-size:13px;padding:3px 7px;user-select:none;}", " ", " &&&.ant-slider-disabled{.ant-slider-dot-active{background-color:", ";}.ant-slider-rail{background-color:", ";}}.ant-slider-handle:hover,.ant-slider-handle:focus{", "}.ant-slider-handle:focus{", " .ant-slider-handle:hover:not(:focus){background-color:", ";}.ant-slider-handle:not(:focus){.ant-tooltip-content:hover{background-color:transparent !important;border-radius:3px;}.ant-tooltip-inner:hover{color:", " !important;}}.ant-slider-dot[style*='left: 100%;'],.ant-slider-dot:first-of-type{visibility:", ";}.ant-slider-mark-text:last-of-type{padding-right:30px;}.ant-slider-mark-text:last-of-type{", "}.ant-slider-mark-text:first-of-type{", "}.ant-slider-handle-dragging{border-color:", " !important;box-shadow:0 0 0 3px rgba(35,138,254,0.25) !important;}"], props.disabled && ".ant-tooltip-inner {\n color: " + props.theme.palette['grey-400'] + ";\n }\n ", props.disabled && ".ant-slider-dot {\n background-color: " + props.theme.palette.white + ";\n }\n ", props.theme.palette.white, props.theme.palette['grey-200'], !props.disabled && "\n .ant-tooltip-content {\n background-color: " + props.theme.palette['grey-900'] + ";\n border-radius: 3px;\n }\n " + Description + " {\n color: " + (!props.disabled && props.theme.palette['grey-600']) + ";\n }\n .ant-tooltip-inner {\n color: " + props.theme.palette['grey-050'] + ";\n }\n ", !props.disabled && "\n " + Description + " {\n " + (props.range && "opacity: 1") + ";\n }\n }\n ", !props.disabled && props.theme.palette['grey-500'], !props.disabled && props.theme.palette['grey-600'], props.hideMinAndMaxMarks ? 'hidden' : 'visible', props.reachedEnd && "opacity: 0", props.reachedStart && "opacity: 0", props.theme.palette['grey-050']);
|
|
33
33
|
};
|
|
34
|
-
|
|
35
|
-
var createTracksStyles = function createTracksStyles(props, colorsMap) {
|
|
34
|
+
export var createTracksStyles = function createTracksStyles(props, colorsMap) {
|
|
36
35
|
var styles = Object.values(colorsMap).map(function (color, index) {
|
|
37
|
-
return "\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 ";
|
|
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 ";
|
|
38
37
|
});
|
|
39
38
|
var style = styles.join('');
|
|
40
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);
|
|
41
40
|
};
|
|
42
|
-
|
|
43
41
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
44
42
|
export var AntdSlider = styled(Slider).withConfig({
|
|
45
43
|
displayName: "Sliderstyles__AntdSlider",
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AllocationMark, AllocationVariant } from '
|
|
1
|
+
import { AllocationMark, AllocationVariant } from '../Allocation/Allocation.types';
|
|
2
2
|
export declare const countControlGroupAllocation: (userAllocation: number[]) => number;
|
|
3
3
|
export declare const countAllocation: (variants?: AllocationVariant[] | undefined, controlGroup?: boolean, recalculate?: boolean) => number[];
|
|
4
4
|
export declare const mergeAllocationWithVariants: (variants: Partial<AllocationVariant>[] | undefined, allocation: number[]) => AllocationVariant[];
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@synerise/ds-slider",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.24",
|
|
4
4
|
"description": "Slider UI Component for the Synerise Design System",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"repository": "Synerise/synerise-design",
|
|
@@ -43,5 +43,5 @@
|
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@synerise/ds-utils": "^0.19.0"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "291e114ff38d1a8e9d5ad8d9e499add6c6f25ee5"
|
|
47
47
|
}
|
|
File without changes
|