@elliemae/ds-slider 2.2.0-alpha.5 → 2.2.0-beta.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/cjs/DSSlider.js +33 -48
- package/cjs/components/SliderImp.js +158 -154
- package/cjs/components/Thumb.js +63 -64
- package/cjs/components/TickMarks.js +31 -72
- package/cjs/components/TickMarksValues.js +38 -59
- package/cjs/components/Track.js +55 -66
- package/cjs/components/context.js +13 -36
- package/cjs/components/styled.js +58 -93
- package/cjs/components/utils.js +36 -46
- package/cjs/index.js +11 -36
- package/cjs/prop-types.js +49 -52
- package/esm/DSSlider.js +20 -16
- package/esm/components/SliderImp.js +139 -120
- package/esm/components/Thumb.js +54 -33
- package/esm/components/TickMarks.js +23 -42
- package/esm/components/TickMarksValues.js +31 -30
- package/esm/components/Track.js +46 -36
- package/esm/components/context.js +5 -7
- package/esm/components/styled.js +44 -64
- package/esm/components/utils.js +29 -15
- package/esm/index.js +1 -7
- package/esm/prop-types.js +44 -23
- package/package.json +6 -6
- package/types/DSSlider.d.ts +1 -1
- package/cjs/DSSlider.js.map +0 -7
- package/cjs/components/SliderImp.js.map +0 -7
- package/cjs/components/Thumb.js.map +0 -7
- package/cjs/components/TickMarks.js.map +0 -7
- package/cjs/components/TickMarksValues.js.map +0 -7
- package/cjs/components/Track.js.map +0 -7
- package/cjs/components/context.js.map +0 -7
- package/cjs/components/styled.js.map +0 -7
- package/cjs/components/utils.js.map +0 -7
- package/cjs/index.js.map +0 -7
- package/cjs/prop-types.js.map +0 -7
- package/esm/DSSlider.js.map +0 -7
- package/esm/components/SliderImp.js.map +0 -7
- package/esm/components/Thumb.js.map +0 -7
- package/esm/components/TickMarks.js.map +0 -7
- package/esm/components/TickMarksValues.js.map +0 -7
- package/esm/components/Track.js.map +0 -7
- package/esm/components/context.js.map +0 -7
- package/esm/components/styled.js.map +0 -7
- package/esm/components/utils.js.map +0 -7
- package/esm/index.js.map +0 -7
- package/esm/prop-types.js.map +0 -7
package/esm/components/Thumb.js
CHANGED
|
@@ -1,11 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
7
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import { useState, useContext } from 'react';
|
|
10
|
+
import { TooltipText } from '@elliemae/ds-tooltip';
|
|
11
|
+
import { SliderContext } from './context.js';
|
|
12
|
+
import { conformedThumbLabel } from './utils.js';
|
|
13
|
+
import { ThumbStyled, TooltipContainerStyled, TooltipArrow } from './styled.js';
|
|
14
|
+
import { jsx } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
var _TooltipArrow;
|
|
17
|
+
|
|
18
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
|
+
|
|
20
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
+
|
|
22
|
+
const Thumb = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
index,
|
|
25
|
+
props,
|
|
26
|
+
isDragged
|
|
27
|
+
} = _ref;
|
|
9
28
|
const [isHovered, setIsHovered] = useState(false);
|
|
10
29
|
const {
|
|
11
30
|
disabled,
|
|
@@ -15,29 +34,31 @@ const Thumb = ({ index, props, isDragged }) => {
|
|
|
15
34
|
step,
|
|
16
35
|
minValue
|
|
17
36
|
} = useContext(SliderContext);
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
37
|
+
|
|
38
|
+
const cleanedProps = _objectSpread({}, props); // delete cleanedProps.key;
|
|
39
|
+
// delete cleanedProps.draggable;
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
return (
|
|
43
|
+
/*#__PURE__*/
|
|
44
|
+
// ...props is needed because it's received from the library
|
|
45
|
+
// ...props.style has it own style from the library but has a bug with the zIndex for two thumbs, so that's why it has to be overwrite
|
|
46
|
+
jsx(ThumbStyled, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
|
47
|
+
"data-testid": "slider-thumb",
|
|
48
|
+
disabled: disabled // eslint-disable-next-line react/prop-types
|
|
49
|
+
,
|
|
50
|
+
style: _objectSpread(_objectSpread({}, cleanedProps.style), {}, {
|
|
51
|
+
zIndex
|
|
52
|
+
}),
|
|
53
|
+
index: index,
|
|
54
|
+
onMouseEnter: () => setIsHovered(true),
|
|
55
|
+
onMouseLeave: () => setIsHovered(false),
|
|
56
|
+
children: /*#__PURE__*/_jsx(TooltipContainerStyled, {
|
|
57
|
+
isDragged: isDragged,
|
|
58
|
+
isHovered: isHovered
|
|
59
|
+
}, void 0, /*#__PURE__*/_jsx(TooltipText, {}, void 0, conformedThumbLabel(rangeValues, customTickMarksValues, index, step, minValue)), _TooltipArrow || (_TooltipArrow = /*#__PURE__*/_jsx(TooltipArrow, {})))
|
|
60
|
+
}))
|
|
61
|
+
);
|
|
42
62
|
};
|
|
43
|
-
|
|
63
|
+
|
|
64
|
+
export { Thumb as default };
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import styled from
|
|
4
|
-
import { __UNSAFE_SPACE_TO_DIMSUM } from
|
|
5
|
-
import { SliderContext } from
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useContext } from 'react';
|
|
3
|
+
import styled from 'styled-components';
|
|
4
|
+
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
5
|
+
import { SliderContext } from './context.js';
|
|
6
|
+
|
|
6
7
|
const TickMarks = () => {
|
|
7
8
|
const {
|
|
8
9
|
minValue,
|
|
@@ -13,46 +14,26 @@ const TickMarks = () => {
|
|
|
13
14
|
zIndex
|
|
14
15
|
} = useContext(SliderContext);
|
|
15
16
|
const dots = [];
|
|
17
|
+
|
|
16
18
|
for (let index = minValue || 0; index <= maxValue; index += step) {
|
|
17
19
|
const isActive = withTwoHandles ? rangeValues[0] <= index && index < rangeValues[1] : rangeValues[0] > index;
|
|
18
|
-
dots.push(
|
|
20
|
+
dots.push( /*#__PURE__*/_jsx(Dot, {
|
|
19
21
|
"data-testid": "slider-dot",
|
|
20
|
-
isActive
|
|
21
|
-
|
|
22
|
-
}));
|
|
22
|
+
isActive: isActive
|
|
23
|
+
}, index));
|
|
23
24
|
}
|
|
24
|
-
|
|
25
|
+
|
|
26
|
+
return /*#__PURE__*/_jsx(DotsContainer, {
|
|
25
27
|
"data-testid": "slider-tick-marks",
|
|
26
|
-
zIndex
|
|
27
|
-
}, dots);
|
|
28
|
-
};
|
|
29
|
-
const Dot = styled.div`
|
|
30
|
-
&:after {
|
|
31
|
-
content: '';
|
|
32
|
-
background: ${(props) => props.isActive ? props.theme.colors.brand[300] : props.theme.colors.neutral[400]};
|
|
33
|
-
border-radius: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};
|
|
34
|
-
display: block;
|
|
35
|
-
position: relative;
|
|
36
|
-
width: 2px;
|
|
37
|
-
height: 2px;
|
|
38
|
-
}
|
|
39
|
-
`;
|
|
40
|
-
const DotsContainer = styled.div`
|
|
41
|
-
padding: 0
|
|
42
|
-
calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 0.5);
|
|
43
|
-
align-items: center;
|
|
44
|
-
display: flex;
|
|
45
|
-
justify-content: space-between;
|
|
46
|
-
pointer-events: none;
|
|
47
|
-
position: absolute;
|
|
48
|
-
top: 0;
|
|
49
|
-
left: 0;
|
|
50
|
-
right: 0;
|
|
51
|
-
bottom: 0;
|
|
52
|
-
z-index: ${(props) => props.zIndex - 1};
|
|
53
|
-
`;
|
|
54
|
-
var TickMarks_default = TickMarks;
|
|
55
|
-
export {
|
|
56
|
-
TickMarks_default as default
|
|
28
|
+
zIndex: zIndex
|
|
29
|
+
}, void 0, dots);
|
|
57
30
|
};
|
|
58
|
-
|
|
31
|
+
|
|
32
|
+
const Dot = /*#__PURE__*/styled.div.withConfig({
|
|
33
|
+
componentId: "sc-15z2sh4-0"
|
|
34
|
+
})(["&:after{content:'';background:", ";border-radius:", ";display:block;position:relative;width:2px;height:2px;}"], props => props.isActive ? props.theme.colors.brand[300] : props.theme.colors.neutral[400], props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs));
|
|
35
|
+
const DotsContainer = /*#__PURE__*/styled.div.withConfig({
|
|
36
|
+
componentId: "sc-15z2sh4-1"
|
|
37
|
+
})(["padding:0 calc(", " * 0.5);align-items:center;display:flex;justify-content:space-between;pointer-events:none;position:absolute;top:0;left:0;right:0;bottom:0;z-index:", ";"], props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => props.zIndex - 1);
|
|
38
|
+
|
|
39
|
+
export { TickMarks as default };
|
|
@@ -1,35 +1,36 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/esnext.async-iterator.map.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.map.js';
|
|
4
|
+
import { useContext, useMemo } from 'react';
|
|
5
|
+
import styled from 'styled-components';
|
|
6
|
+
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
7
|
+
import { SliderContext } from './context.js';
|
|
8
|
+
|
|
6
9
|
const TickMarks = () => {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
var _TickMarksContainer;
|
|
11
|
+
|
|
12
|
+
const {
|
|
13
|
+
parsedValuesArray,
|
|
14
|
+
fullSelectedValues,
|
|
15
|
+
sliderUUID
|
|
16
|
+
} = useContext(SliderContext);
|
|
17
|
+
const TickMarksLabels = useMemo(() => parsedValuesArray.map(value => {
|
|
18
|
+
const isSelected = fullSelectedValues.findIndex(selectedVal => selectedVal === value) >= 0;
|
|
19
|
+
return /*#__PURE__*/_jsx(TickMarkValue, {
|
|
20
|
+
isSelected: isSelected
|
|
21
|
+
}, "".concat(sliderUUID, "-").concat(value), value);
|
|
14
22
|
}), [parsedValuesArray, sliderUUID, fullSelectedValues]);
|
|
15
|
-
const PureTickMArksValues = useMemo(() =>
|
|
23
|
+
const PureTickMArksValues = useMemo(() => _TickMarksContainer || (_TickMarksContainer = /*#__PURE__*/_jsx(TickMarksContainer, {
|
|
16
24
|
"data-testid": "slider-tick-marks-values"
|
|
17
|
-
}, TickMarksLabels), [TickMarksLabels]);
|
|
25
|
+
}, void 0, TickMarksLabels)), [TickMarksLabels]);
|
|
18
26
|
return PureTickMArksValues;
|
|
19
27
|
};
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
justify-content: space-between;
|
|
30
|
-
`;
|
|
31
|
-
var TickMarksValues_default = TickMarks;
|
|
32
|
-
export {
|
|
33
|
-
TickMarksValues_default as default
|
|
34
|
-
};
|
|
35
|
-
//# sourceMappingURL=TickMarksValues.js.map
|
|
28
|
+
|
|
29
|
+
const TickMarkValue = /*#__PURE__*/styled.div.withConfig({
|
|
30
|
+
componentId: "sc-lq3yel-0"
|
|
31
|
+
})(["margin:", " 0;overflow:visible;transform:translateX(-100%);width:", ";color:", ";"], props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.s), props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => props.isSelected ? props.theme.colors.neutral[800] : props.theme.colors.neutral[500]);
|
|
32
|
+
const TickMarksContainer = /*#__PURE__*/styled.div.withConfig({
|
|
33
|
+
componentId: "sc-lq3yel-1"
|
|
34
|
+
})(["display:flex;justify-content:space-between;"]);
|
|
35
|
+
|
|
36
|
+
export { TickMarks as default };
|
package/esm/components/Track.js
CHANGED
|
@@ -1,12 +1,30 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import
|
|
6
|
-
import
|
|
7
|
-
import
|
|
8
|
-
import {
|
|
9
|
-
|
|
1
|
+
import 'core-js/modules/esnext.async-iterator.filter.js';
|
|
2
|
+
import 'core-js/modules/esnext.iterator.constructor.js';
|
|
3
|
+
import 'core-js/modules/esnext.iterator.filter.js';
|
|
4
|
+
import 'core-js/modules/esnext.async-iterator.for-each.js';
|
|
5
|
+
import 'core-js/modules/esnext.iterator.for-each.js';
|
|
6
|
+
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
7
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
8
|
+
import { useContext } from 'react';
|
|
9
|
+
import { getTrackBackground } from 'react-range';
|
|
10
|
+
import styled from 'styled-components';
|
|
11
|
+
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
12
|
+
import TickMarks$1 from './TickMarks.js';
|
|
13
|
+
import TickMarks from './TickMarksValues.js';
|
|
14
|
+
import { SliderContext } from './context.js';
|
|
15
|
+
import { jsxs, Fragment } from 'react/jsx-runtime';
|
|
16
|
+
|
|
17
|
+
var _TickMarks, _TickMarksValues;
|
|
18
|
+
|
|
19
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
|
+
|
|
21
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
22
|
+
|
|
23
|
+
const Track = _ref => {
|
|
24
|
+
let {
|
|
25
|
+
children,
|
|
26
|
+
props
|
|
27
|
+
} = _ref;
|
|
10
28
|
const {
|
|
11
29
|
disabled,
|
|
12
30
|
minValue,
|
|
@@ -16,34 +34,26 @@ const Track = ({ children, props }) => {
|
|
|
16
34
|
withTickMarksValues,
|
|
17
35
|
withTwoHandles
|
|
18
36
|
} = useContext(SliderContext);
|
|
19
|
-
return
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
37
|
+
return /*#__PURE__*/jsxs(Fragment, {
|
|
38
|
+
children: [/*#__PURE__*/jsxs(TrackStyled, _objectSpread(_objectSpread({}, props), {}, {
|
|
39
|
+
// This is needed because it's received from the library
|
|
40
|
+
disabled: disabled,
|
|
41
|
+
minValue: minValue,
|
|
42
|
+
maxValue: maxValue,
|
|
43
|
+
rangeValues: rangeValues,
|
|
44
|
+
withTwoHandles: withTwoHandles,
|
|
45
|
+
children: [children, withTickMarks && !disabled && (_TickMarks || (_TickMarks = /*#__PURE__*/_jsx(TickMarks$1, {})))]
|
|
46
|
+
})), withTickMarksValues && (_TickMarksValues || (_TickMarksValues = /*#__PURE__*/_jsx(TickMarks, {})))]
|
|
47
|
+
});
|
|
27
48
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
min-width: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxl)};
|
|
33
|
-
border-radius: ${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)};
|
|
34
|
-
background: ${(props) => props.disabled ? props.theme.colors.neutral[100] : getTrackBackground({
|
|
49
|
+
|
|
50
|
+
const TrackStyled = /*#__PURE__*/styled.div.withConfig({
|
|
51
|
+
componentId: "sc-13fbuj5-0"
|
|
52
|
+
})(["position:relative;height:", ";width:100%;min-width:", ";border-radius:", ";background:", ";"], props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxl), props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => props.disabled ? props.theme.colors.neutral[100] : getTrackBackground({
|
|
35
53
|
values: props.rangeValues,
|
|
36
|
-
colors: props.withTwoHandles ? [
|
|
37
|
-
props.theme.colors.neutral[100],
|
|
38
|
-
props.theme.colors.brand[600],
|
|
39
|
-
props.theme.colors.neutral[100]
|
|
40
|
-
] : [props.theme.colors.brand[600], props.theme.colors.neutral[100]],
|
|
54
|
+
colors: props.withTwoHandles ? [props.theme.colors.neutral[100], props.theme.colors.brand[600], props.theme.colors.neutral[100]] : [props.theme.colors.brand[600], props.theme.colors.neutral[100]],
|
|
41
55
|
min: props.minValue,
|
|
42
56
|
max: props.maxValue
|
|
43
|
-
})
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
export {
|
|
47
|
-
Track_default as default
|
|
48
|
-
};
|
|
49
|
-
//# sourceMappingURL=Track.js.map
|
|
57
|
+
}));
|
|
58
|
+
|
|
59
|
+
export { Track as default };
|
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
const SliderContext =
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=context.js.map
|
|
1
|
+
import React from 'react';
|
|
2
|
+
|
|
3
|
+
const SliderContext = /*#__PURE__*/React.createContext();
|
|
4
|
+
|
|
5
|
+
export { SliderContext };
|
package/esm/components/styled.js
CHANGED
|
@@ -1,67 +1,47 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
import {
|
|
4
|
-
import { TooltipContainer } from "@elliemae/ds-tooltip";
|
|
5
|
-
const ThumbStyled = styled.div`
|
|
6
|
-
height: 20px;
|
|
7
|
-
width: 20px;
|
|
8
|
-
background-color: ${(props) => props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral["000"]};
|
|
9
|
-
border-radius: 10px;
|
|
10
|
-
border: 1px solid ${(props) => props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral[400]};
|
|
1
|
+
import styled from 'styled-components';
|
|
2
|
+
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
3
|
+
import { TooltipContainer } from '@elliemae/ds-tooltip';
|
|
11
4
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
5
|
+
/* eslint-disable indent */
|
|
6
|
+
const ThumbStyled = /*#__PURE__*/styled.div.withConfig({
|
|
7
|
+
componentId: "sc-24in0j-0"
|
|
8
|
+
})(["height:20px;width:20px;background-color:", ";border-radius:10px;border:1px solid ", ";:focus{border:1px solid ", ";outline:unset;}:hover{background-color:", ";}"], props => props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral['000'], props => props.disabled ? props.theme.colors.neutral[100] : props.theme.colors.neutral[400], props => props.theme.colors.brand[600], _ref => {
|
|
9
|
+
let {
|
|
10
|
+
disabled,
|
|
11
|
+
theme
|
|
12
|
+
} = _ref;
|
|
13
|
+
return disabled ? theme.colors.neutral[100] : theme.colors.brand[200];
|
|
14
|
+
});
|
|
15
|
+
const TooltipContainerStyled = /*#__PURE__*/styled(TooltipContainer).withConfig({
|
|
16
|
+
componentId: "sc-24in0j-1"
|
|
17
|
+
})(["position:relative;display:flex;align-items:center;flex-direction:column;top:-35px;width:max-content;left:50%;transform:translateX(-50%);visibility:", ";"], _ref2 => {
|
|
18
|
+
let {
|
|
19
|
+
isDragged,
|
|
20
|
+
isHovered
|
|
21
|
+
} = _ref2;
|
|
22
|
+
return isDragged || isHovered ? 'visible' : 'hidden';
|
|
23
|
+
}); // TODO: didn't work with DSTooltip, see how to improve
|
|
16
24
|
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
border-right: calc(${(props) => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs)} * 2.5) solid transparent;
|
|
25
|
+
const TooltipArrow = /*#__PURE__*/styled.div.withConfig({
|
|
26
|
+
componentId: "sc-24in0j-2"
|
|
27
|
+
})(["position:absolute;width:0;height:0;top:20px;border-left:calc(", " * 2.5) solid transparent;border-right:calc(", " * 2.5) solid transparent;border-top:calc(", " * 2.5) solid ", ";"], props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs), props => props.theme.colors.neutral[0]);
|
|
28
|
+
const LabelWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
29
|
+
componentId: "sc-24in0j-3"
|
|
30
|
+
})(["margin-bottom:", ";max-width:100%;width:", ";"], props => props.theme.space.xxs, props => "".concat(props.width || 0, "px"));
|
|
31
|
+
const LabelText = /*#__PURE__*/styled.span.withConfig({
|
|
32
|
+
componentId: "sc-24in0j-4"
|
|
33
|
+
})(["color:", ";"], props => props.theme.colors.neutral[600]);
|
|
34
|
+
const ValueText = /*#__PURE__*/styled.span.withConfig({
|
|
35
|
+
componentId: "sc-24in0j-5"
|
|
36
|
+
})(["color:", ";"], _ref3 => {
|
|
37
|
+
let {
|
|
38
|
+
disabled,
|
|
39
|
+
theme
|
|
40
|
+
} = _ref3;
|
|
41
|
+
return theme.colors.neutral[disabled ? 500 : 800];
|
|
42
|
+
});
|
|
43
|
+
const StyledRangeWrapper = /*#__PURE__*/styled.div.withConfig({
|
|
44
|
+
componentId: "sc-24in0j-6"
|
|
45
|
+
})(["min-height:28px;margin:0 10px;"]);
|
|
39
46
|
|
|
40
|
-
|
|
41
|
-
${(props) => props.theme.colors.neutral[0]};
|
|
42
|
-
`;
|
|
43
|
-
const LabelWrapper = styled.div`
|
|
44
|
-
margin-bottom: ${(props) => props.theme.space.xxs};
|
|
45
|
-
max-width: 100%;
|
|
46
|
-
width: ${(props) => `${props.width || 0}px`};
|
|
47
|
-
`;
|
|
48
|
-
const LabelText = styled.span`
|
|
49
|
-
color: ${(props) => props.theme.colors.neutral[600]};
|
|
50
|
-
`;
|
|
51
|
-
const ValueText = styled.span`
|
|
52
|
-
color: ${({ disabled, theme }) => theme.colors.neutral[disabled ? 500 : 800]};
|
|
53
|
-
`;
|
|
54
|
-
const StyledRangeWrapper = styled.div`
|
|
55
|
-
min-height: 28px;
|
|
56
|
-
margin: 0 10px;
|
|
57
|
-
`;
|
|
58
|
-
export {
|
|
59
|
-
LabelText,
|
|
60
|
-
LabelWrapper,
|
|
61
|
-
StyledRangeWrapper,
|
|
62
|
-
ThumbStyled,
|
|
63
|
-
TooltipArrow,
|
|
64
|
-
TooltipContainerStyled,
|
|
65
|
-
ValueText
|
|
66
|
-
};
|
|
67
|
-
//# sourceMappingURL=styled.js.map
|
|
47
|
+
export { LabelText, LabelWrapper, StyledRangeWrapper, ThumbStyled, TooltipArrow, TooltipContainerStyled, ValueText };
|
package/esm/components/utils.js
CHANGED
|
@@ -1,30 +1,44 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
|
|
1
|
+
import { isEmpty } from '@elliemae/ds-utilities';
|
|
2
|
+
|
|
3
|
+
/* eslint-disable max-params */
|
|
4
|
+
const conformedLabel = function (rangeValues) {
|
|
5
|
+
let label = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
|
|
6
|
+
let labelWithValue = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
7
|
+
let withTwoHandles = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : false;
|
|
8
|
+
let customTickMarksValues = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : [];
|
|
9
|
+
let step = arguments.length > 5 && arguments[5] !== undefined ? arguments[5] : 1;
|
|
10
|
+
let minValue = arguments.length > 6 && arguments[6] !== undefined ? arguments[6] : 0;
|
|
4
11
|
const msg = label.trim();
|
|
5
|
-
let value =
|
|
12
|
+
let value = '';
|
|
13
|
+
|
|
6
14
|
if (!isEmpty(customTickMarksValues) && labelWithValue && label) {
|
|
7
15
|
const firstValue = customTickMarksValues[(rangeValues[0] - minValue) / step];
|
|
8
16
|
const secondValue = customTickMarksValues[(rangeValues[1] - minValue) / step];
|
|
9
|
-
value =
|
|
17
|
+
value = "".concat(firstValue || rangeValues[0].toFixed(1), " ").concat(withTwoHandles ? ", ".concat(secondValue || rangeValues[1].toFixed(1)) : '', " ");
|
|
10
18
|
} else if (labelWithValue && label) {
|
|
11
|
-
|
|
19
|
+
var _rangeValues$;
|
|
20
|
+
|
|
21
|
+
value = "".concat(rangeValues[0].toFixed(1), " ").concat(withTwoHandles ? ", ".concat((_rangeValues$ = rangeValues[1]) === null || _rangeValues$ === void 0 ? void 0 : _rangeValues$.toFixed(1)) : '', " ");
|
|
12
22
|
}
|
|
23
|
+
|
|
13
24
|
value = value.trim();
|
|
14
25
|
return [msg, value];
|
|
15
26
|
};
|
|
16
|
-
const conformedThumbLabel = (rangeValues
|
|
17
|
-
let
|
|
27
|
+
const conformedThumbLabel = function (rangeValues) {
|
|
28
|
+
let customTickMarksValues = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
|
|
29
|
+
let index = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : 0;
|
|
30
|
+
let step = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : 1;
|
|
31
|
+
let minValue = arguments.length > 4 && arguments[4] !== undefined ? arguments[4] : 0;
|
|
32
|
+
let msg = "Value: ";
|
|
33
|
+
|
|
18
34
|
if (!isEmpty(customTickMarksValues)) {
|
|
19
35
|
const foundValue = customTickMarksValues[(rangeValues[index] - minValue) / step];
|
|
20
|
-
msg +=
|
|
36
|
+
msg += "".concat(foundValue || rangeValues[index].toFixed(1));
|
|
21
37
|
} else {
|
|
22
|
-
msg +=
|
|
38
|
+
msg += "".concat(rangeValues[index].toFixed(1));
|
|
23
39
|
}
|
|
40
|
+
|
|
24
41
|
return msg;
|
|
25
42
|
};
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
conformedThumbLabel
|
|
29
|
-
};
|
|
30
|
-
//# sourceMappingURL=utils.js.map
|
|
43
|
+
|
|
44
|
+
export { conformedLabel, conformedThumbLabel };
|
package/esm/index.js
CHANGED
|
@@ -1,7 +1 @@
|
|
|
1
|
-
|
|
2
|
-
import { default as default2 } from "./DSSlider";
|
|
3
|
-
export * from "./DSSlider";
|
|
4
|
-
export {
|
|
5
|
-
default2 as default
|
|
6
|
-
};
|
|
7
|
-
//# sourceMappingURL=index.js.map
|
|
1
|
+
export { DSSlider, DSSliderWithSchema, DSSlider as default } from './DSSlider.js';
|
package/esm/prop-types.js
CHANGED
|
@@ -1,15 +1,14 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
1
|
+
import { PropTypes } from 'react-desc';
|
|
2
|
+
|
|
3
3
|
const defaultProps = {
|
|
4
4
|
containerProps: {},
|
|
5
5
|
disabled: false,
|
|
6
|
-
label:
|
|
6
|
+
label: '',
|
|
7
7
|
labelWithValue: false,
|
|
8
8
|
minValue: 0,
|
|
9
9
|
maxValue: 100,
|
|
10
10
|
step: 5,
|
|
11
|
-
onChange: () => {
|
|
12
|
-
},
|
|
11
|
+
onChange: () => {},
|
|
13
12
|
withTickMarks: false,
|
|
14
13
|
withTickMarksValues: false,
|
|
15
14
|
withTwoHandles: false,
|
|
@@ -17,22 +16,44 @@ const defaultProps = {
|
|
|
17
16
|
zIndex: 0
|
|
18
17
|
};
|
|
19
18
|
const sliderPropTypes = {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
19
|
+
/** props to inject to slider wrapper */
|
|
20
|
+
containerProps: PropTypes.shape({}).description('props to inject to slider wrapper'),
|
|
21
|
+
|
|
22
|
+
/** disable slider */
|
|
23
|
+
disabled: PropTypes.bool.description('disable slider'),
|
|
24
|
+
|
|
25
|
+
/** label for slider */
|
|
26
|
+
label: PropTypes.string.description('label for slider'),
|
|
27
|
+
|
|
28
|
+
/** if the label comes with value attached for slider or not */
|
|
29
|
+
labelWithValue: PropTypes.bool.description('if the label comes with value attached for slider or not'),
|
|
30
|
+
|
|
31
|
+
/** min value for slider */
|
|
32
|
+
minValue: PropTypes.number.description('min value for slider'),
|
|
33
|
+
|
|
34
|
+
/** max value for slider */
|
|
35
|
+
maxValue: PropTypes.number.description('max value for slider'),
|
|
36
|
+
|
|
37
|
+
/** steps of values from min to max */
|
|
38
|
+
step: PropTypes.number.description('steps of values from min to max'),
|
|
39
|
+
|
|
40
|
+
/** change handler */
|
|
41
|
+
onChange: PropTypes.func.description('change handler'),
|
|
42
|
+
|
|
43
|
+
/** add tick marks between steps */
|
|
44
|
+
withTickMarks: PropTypes.bool.description('add tick marks between steps'),
|
|
45
|
+
|
|
46
|
+
/** add step value to tickmark */
|
|
47
|
+
withTickMarksValues: PropTypes.bool.description('add step value to tickmark'),
|
|
48
|
+
|
|
49
|
+
/** add two handles */
|
|
50
|
+
withTwoHandles: PropTypes.bool.description('add two handles'),
|
|
51
|
+
|
|
52
|
+
/** change manually tickmark values */
|
|
53
|
+
customTickMarksValues: PropTypes.arrayOf(PropTypes.oneOfType([PropTypes.string, PropTypes.number])).description('change manually tickmark values'),
|
|
54
|
+
|
|
55
|
+
/** z index for thumb */
|
|
56
|
+
zIndex: PropTypes.number.description('z index for thumb')
|
|
33
57
|
};
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
sliderPropTypes
|
|
37
|
-
};
|
|
38
|
-
//# sourceMappingURL=prop-types.js.map
|
|
58
|
+
|
|
59
|
+
export { defaultProps, sliderPropTypes };
|