@elliemae/ds-slider 1.60.0 → 2.0.0-alpha.12
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 +17 -29
- package/cjs/components/SliderImp.js +125 -156
- package/cjs/components/Thumb.js +40 -53
- package/cjs/components/TickMarks.js +25 -36
- package/cjs/components/TickMarksValues.js +25 -36
- package/cjs/components/Track.js +51 -43
- package/cjs/components/context.js +1 -2
- package/cjs/components/styled.js +25 -40
- package/cjs/components/utils.js +18 -19
- package/cjs/index.js +1 -25
- package/cjs/prop-types.js +3 -4
- package/esm/DSSlider.js +14 -26
- package/esm/components/SliderImp.js +122 -152
- package/esm/components/Thumb.js +36 -46
- package/esm/components/TickMarks.js +23 -34
- package/esm/components/TickMarksValues.js +23 -34
- package/esm/components/Track.js +47 -39
- package/esm/components/context.js +1 -2
- package/esm/components/styled.js +25 -40
- package/esm/components/utils.js +18 -19
- package/esm/index.js +0 -24
- package/esm/prop-types.js +3 -4
- package/package.json +73 -16
- package/types/DSSlider.d.ts +107 -0
- package/types/components/SliderImp.d.ts +3 -0
- package/types/components/Thumb.d.ts +14 -0
- package/types/components/TickMarks.d.ts +3 -0
- package/types/components/TickMarksValues.d.ts +3 -0
- package/types/components/Track.d.ts +6 -0
- package/types/components/context.d.ts +2 -0
- package/types/components/styled.d.ts +8 -0
- package/types/components/utils.d.ts +2 -0
- package/types/index.d.ts +2 -0
- package/types/prop-types.d.ts +122 -0
- package/DSSlider/package.json +0 -10
- package/cjs/DSSlider.js.map +0 -1
- package/cjs/components/SliderImp.js.map +0 -1
- package/cjs/components/Thumb.js.map +0 -1
- package/cjs/components/TickMarks.js.map +0 -1
- package/cjs/components/TickMarksValues.js.map +0 -1
- package/cjs/components/Track.js.map +0 -1
- package/cjs/components/context.js.map +0 -1
- package/cjs/components/styled.js.map +0 -1
- package/cjs/components/utils.js.map +0 -1
- package/cjs/index.js.map +0 -1
- package/cjs/prop-types.js.map +0 -1
- package/components/SliderImp/package.json +0 -10
- package/components/Thumb/package.json +0 -10
- package/components/TickMarks/package.json +0 -10
- package/components/TickMarksValues/package.json +0 -10
- package/components/Track/package.json +0 -10
- package/components/context/package.json +0 -10
- package/components/styled/package.json +0 -10
- package/components/utils/package.json +0 -10
- package/esm/DSSlider.js.map +0 -1
- package/esm/components/SliderImp.js.map +0 -1
- package/esm/components/Thumb.js.map +0 -1
- package/esm/components/TickMarks.js.map +0 -1
- package/esm/components/TickMarksValues.js.map +0 -1
- package/esm/components/Track.js.map +0 -1
- package/esm/components/context.js.map +0 -1
- package/esm/components/styled.js.map +0 -1
- package/esm/components/utils.js.map +0 -1
- package/esm/index.js.map +0 -1
- package/esm/prop-types.js.map +0 -1
- package/prop-types/package.json +0 -10
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
3
|
+
import { useRef, useState, useMemo, useEffect } from 'react';
|
|
3
4
|
import { v4 } from 'uuid';
|
|
4
5
|
import { Range } from 'react-range';
|
|
5
6
|
import { usePrevious } from '@elliemae/ds-utilities';
|
|
@@ -7,35 +8,21 @@ import DSTruncatedTooltipText, { TooltipTextProvider } from '@elliemae/ds-trunca
|
|
|
7
8
|
import { Grid } from '@elliemae/ds-grid';
|
|
8
9
|
import Track from './Track.js';
|
|
9
10
|
import Thumb from './Thumb.js';
|
|
10
|
-
import {
|
|
11
|
+
import { LabelWrapper, StyledRangeWrapper, LabelText, ValueText } from './styled.js';
|
|
11
12
|
import { conformedLabel } from './utils.js';
|
|
12
13
|
import { SliderContext } from './context.js';
|
|
13
|
-
import '
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
import '@elliemae/ds-tooltip';
|
|
21
|
-
|
|
22
|
-
var getSubArrayFromRange = function getSubArrayFromRange(arr, _ref) {
|
|
23
|
-
var _ref2 = _slicedToArray(_ref, 2),
|
|
24
|
-
minVal = _ref2[0],
|
|
25
|
-
maxVal = _ref2[1];
|
|
26
|
-
|
|
27
|
-
var isCustomTickMarksValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
28
|
-
var trueMinVal = isCustomTickMarksValues ? arr[minVal] : minVal;
|
|
29
|
-
var minIndex = arr.findIndex(function (el) {
|
|
30
|
-
return el === trueMinVal;
|
|
31
|
-
});
|
|
14
|
+
import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
const getSubArrayFromRange = function (arr, _ref) {
|
|
17
|
+
let [minVal, maxVal] = _ref;
|
|
18
|
+
let isCustomTickMarksValues = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
|
|
19
|
+
const trueMinVal = isCustomTickMarksValues ? arr[minVal] : minVal;
|
|
20
|
+
const minIndex = arr.findIndex(el => el === trueMinVal);
|
|
32
21
|
|
|
33
22
|
if (maxVal !== undefined) {
|
|
34
23
|
// if two handlers, return the found slice
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
return el === trueMaxVal;
|
|
38
|
-
});
|
|
24
|
+
const trueMaxVal = isCustomTickMarksValues ? arr[maxVal] : maxVal;
|
|
25
|
+
const maxIndex = arr.findIndex(el => el === trueMaxVal);
|
|
39
26
|
if (minIndex >= 0 && maxIndex > minIndex) return arr.slice(minIndex, maxIndex + 1);
|
|
40
27
|
return [];
|
|
41
28
|
} // if only one handler, return the value in an array
|
|
@@ -44,179 +31,162 @@ var getSubArrayFromRange = function getSubArrayFromRange(arr, _ref) {
|
|
|
44
31
|
return [trueMinVal];
|
|
45
32
|
};
|
|
46
33
|
|
|
47
|
-
|
|
34
|
+
const SliderImp = props => {
|
|
48
35
|
var _ref$current3;
|
|
49
36
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
var sliderUUID = useMemo(function () {
|
|
71
|
-
return v4();
|
|
72
|
-
}, []);
|
|
73
|
-
var parsedMinValue = useMemo(function () {
|
|
37
|
+
const {
|
|
38
|
+
containerProps,
|
|
39
|
+
disabled,
|
|
40
|
+
label,
|
|
41
|
+
labelWithValue,
|
|
42
|
+
minValue,
|
|
43
|
+
maxValue,
|
|
44
|
+
step,
|
|
45
|
+
onChange,
|
|
46
|
+
withTickMarks,
|
|
47
|
+
withTickMarksValues,
|
|
48
|
+
withTwoHandles,
|
|
49
|
+
customTickMarksValues,
|
|
50
|
+
zIndex
|
|
51
|
+
} = props;
|
|
52
|
+
const ref = useRef();
|
|
53
|
+
const [width, setWidth] = useState(0);
|
|
54
|
+
const sliderUUID = useMemo(() => v4(), []);
|
|
55
|
+
const parsedMinValue = useMemo(() => {
|
|
74
56
|
// ensure this works correctly with customTickMarksValues array
|
|
75
57
|
if (customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length) return 0;
|
|
76
58
|
return minValue;
|
|
77
59
|
}, [customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length, minValue]);
|
|
78
|
-
|
|
60
|
+
const parsedMaxValue = useMemo(() => {
|
|
79
61
|
// ensure this works correctly with customTickMarksValues array
|
|
80
62
|
if (customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length) return (customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length) - 1;
|
|
81
63
|
return maxValue;
|
|
82
64
|
}, [customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length, maxValue]);
|
|
83
|
-
|
|
65
|
+
const parsedStep = useMemo(() => {
|
|
84
66
|
// ensure this works correctly with customTickMarksValues array
|
|
85
67
|
if (customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length) return 1;
|
|
86
68
|
return step;
|
|
87
69
|
}, [customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length, step]);
|
|
88
|
-
|
|
70
|
+
const parsedValuesArray = useMemo(() => {
|
|
89
71
|
// ensure this works correctly with customTickMarksValues array
|
|
90
72
|
if (customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length) return customTickMarksValues;
|
|
91
|
-
|
|
92
|
-
|
|
73
|
+
const newLength = Math.ceil(maxValue / step);
|
|
74
|
+
const valuesArray = [];
|
|
93
75
|
|
|
94
|
-
for (
|
|
76
|
+
for (let i = 0; i <= newLength; i += 1) {
|
|
95
77
|
valuesArray.push(step * i);
|
|
96
78
|
}
|
|
97
79
|
|
|
98
80
|
return valuesArray;
|
|
99
81
|
}, [customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length, minValue, maxValue, step]);
|
|
100
|
-
|
|
101
|
-
var _useState3 = useState(withTwoHandles ? [parsedMinValue, parsedMaxValue] : [parsedMinValue]),
|
|
102
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
103
|
-
rangeValues = _useState4[0],
|
|
104
|
-
setRangeValues = _useState4[1]; // track the full slice of values selected instead of only the limits
|
|
82
|
+
const [rangeValues, setRangeValues] = useState(withTwoHandles ? [parsedMinValue, parsedMaxValue] : [parsedMinValue]); // track the full slice of values selected instead of only the limits
|
|
105
83
|
// this is important to handle the selected range labels colors
|
|
106
84
|
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
fullSelectedValues = _useState6[0],
|
|
111
|
-
setFullSelectedValues = _useState6[1];
|
|
112
|
-
|
|
113
|
-
useEffect(function () {
|
|
114
|
-
var selectedRangeValues = getSubArrayFromRange(parsedValuesArray, rangeValues, !!(customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length));
|
|
85
|
+
const [fullSelectedValues, setFullSelectedValues] = useState([]);
|
|
86
|
+
useEffect(() => {
|
|
87
|
+
const selectedRangeValues = getSubArrayFromRange(parsedValuesArray, rangeValues, !!(customTickMarksValues !== null && customTickMarksValues !== void 0 && customTickMarksValues.length));
|
|
115
88
|
setFullSelectedValues(selectedRangeValues);
|
|
116
89
|
}, [parsedValuesArray, rangeValues, customTickMarksValues === null || customTickMarksValues === void 0 ? void 0 : customTickMarksValues.length]);
|
|
117
|
-
|
|
90
|
+
const prevWithTwoHandles = usePrevious(withTwoHandles);
|
|
118
91
|
|
|
119
|
-
|
|
92
|
+
const resizeHandler = () => {
|
|
120
93
|
var _ref$current;
|
|
121
94
|
|
|
122
95
|
setWidth(0);
|
|
123
96
|
setWidth((_ref$current = ref.current) === null || _ref$current === void 0 ? void 0 : _ref$current.clientWidth);
|
|
124
97
|
};
|
|
125
98
|
|
|
126
|
-
useEffect(
|
|
99
|
+
useEffect(() => {
|
|
127
100
|
window.addEventListener('resize', resizeHandler);
|
|
128
|
-
return
|
|
129
|
-
return window.removeEventListener('resize', resizeHandler);
|
|
130
|
-
};
|
|
101
|
+
return () => window.removeEventListener('resize', resizeHandler);
|
|
131
102
|
});
|
|
132
|
-
useEffect(
|
|
103
|
+
useEffect(() => {
|
|
133
104
|
if (!prevWithTwoHandles && withTwoHandles) {
|
|
134
105
|
setRangeValues([parsedMinValue, parsedMaxValue]);
|
|
135
106
|
} else if (prevWithTwoHandles && !withTwoHandles) {
|
|
136
107
|
setRangeValues([parsedMinValue]);
|
|
137
108
|
}
|
|
138
109
|
}, [withTwoHandles]);
|
|
139
|
-
useEffect(
|
|
110
|
+
useEffect(() => {
|
|
140
111
|
var _ref$current2;
|
|
141
112
|
|
|
142
113
|
setWidth((_ref$current2 = ref.current) === null || _ref$current2 === void 0 ? void 0 : _ref$current2.clientWidth);
|
|
143
114
|
}, [(_ref$current3 = ref.current) === null || _ref$current3 === void 0 ? void 0 : _ref$current3.clientWidth]);
|
|
115
|
+
const [finalLabelText, finalValueText] = useMemo(() => conformedLabel(rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep), [rangeValues, label, labelWithValue, withTwoHandles, customTickMarksValues, parsedStep]);
|
|
144
116
|
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
},
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
117
|
+
const SliderLabel = /*#__PURE__*/jsxs(Fragment, {
|
|
118
|
+
children: [/*#__PURE__*/_jsx(LabelText, {}, void 0, finalLabelText), finalLabelText && ' ', /*#__PURE__*/_jsx(ValueText, {
|
|
119
|
+
disabled: disabled
|
|
120
|
+
}, void 0, finalValueText)]
|
|
121
|
+
});
|
|
122
|
+
|
|
123
|
+
return /*#__PURE__*/_jsx(TooltipTextProvider, {}, void 0, /*#__PURE__*/jsx("div", {
|
|
124
|
+
ref: ref,
|
|
125
|
+
children: /*#__PURE__*/_jsx(Grid, {
|
|
126
|
+
width: "100%",
|
|
127
|
+
style: {
|
|
128
|
+
maxWidth: '100%'
|
|
129
|
+
},
|
|
130
|
+
containerProps: containerProps,
|
|
131
|
+
"data-testid": "slider",
|
|
132
|
+
rows: ['auto', 'auto']
|
|
133
|
+
}, void 0, /*#__PURE__*/_jsx(SliderContext.Provider, {
|
|
134
|
+
value: {
|
|
135
|
+
disabled,
|
|
136
|
+
sliderUUID,
|
|
137
|
+
label,
|
|
138
|
+
labelWithValue,
|
|
139
|
+
minValue: parsedMinValue,
|
|
140
|
+
maxValue: parsedMaxValue,
|
|
141
|
+
step: parsedStep,
|
|
142
|
+
parsedValuesArray,
|
|
143
|
+
withTickMarks,
|
|
144
|
+
withTickMarksValues,
|
|
145
|
+
withTwoHandles,
|
|
146
|
+
customTickMarksValues,
|
|
147
|
+
rangeValues,
|
|
148
|
+
fullSelectedValues,
|
|
149
|
+
zIndex
|
|
150
|
+
}
|
|
151
|
+
}, void 0, finalLabelText && /*#__PURE__*/_jsx(LabelWrapper, {
|
|
152
|
+
width: width
|
|
153
|
+
}, void 0, /*#__PURE__*/_jsx(DSTruncatedTooltipText, {
|
|
154
|
+
value: SliderLabel
|
|
155
|
+
})), /*#__PURE__*/_jsx(StyledRangeWrapper, {}, void 0, /*#__PURE__*/_jsx(Range, {
|
|
173
156
|
step: parsedStep,
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
}
|
|
206
|
-
|
|
207
|
-
var index = renderArgs.index,
|
|
208
|
-
thumbProps = renderArgs.props,
|
|
209
|
-
isDragged = renderArgs.isDragged;
|
|
210
|
-
return /*#__PURE__*/React.createElement(Thumb, {
|
|
211
|
-
key: "".concat(sliderUUID, "-").concat(thumbProps.key),
|
|
212
|
-
props: thumbProps,
|
|
213
|
-
isDragged: isDragged,
|
|
214
|
-
index: index
|
|
215
|
-
});
|
|
216
|
-
},
|
|
217
|
-
allowOverlap: false
|
|
218
|
-
}))))));
|
|
157
|
+
min: parsedMinValue,
|
|
158
|
+
max: parsedMaxValue,
|
|
159
|
+
values: rangeValues,
|
|
160
|
+
disabled: disabled,
|
|
161
|
+
onChange: values => {
|
|
162
|
+
if (withTwoHandles && values[0] === values[1]) return;
|
|
163
|
+
setRangeValues(values);
|
|
164
|
+
onChange(values);
|
|
165
|
+
},
|
|
166
|
+
renderTrack: _ref2 => {
|
|
167
|
+
let {
|
|
168
|
+
props: trackProps,
|
|
169
|
+
children
|
|
170
|
+
} = _ref2;
|
|
171
|
+
return /*#__PURE__*/_jsx(Track, {
|
|
172
|
+
props: trackProps
|
|
173
|
+
}, void 0, children);
|
|
174
|
+
},
|
|
175
|
+
renderThumb: renderArgs => {
|
|
176
|
+
const {
|
|
177
|
+
index,
|
|
178
|
+
props: thumbProps,
|
|
179
|
+
isDragged
|
|
180
|
+
} = renderArgs;
|
|
181
|
+
return /*#__PURE__*/_jsx(Thumb, {
|
|
182
|
+
props: thumbProps,
|
|
183
|
+
isDragged: isDragged,
|
|
184
|
+
index: index
|
|
185
|
+
}, "".concat(sliderUUID, "-").concat(thumbProps.key));
|
|
186
|
+
},
|
|
187
|
+
allowOverlap: false
|
|
188
|
+
}))))
|
|
189
|
+
}));
|
|
219
190
|
}; // SliderImp.propTypes = sliderPropTypes;
|
|
220
191
|
|
|
221
192
|
export { SliderImp as default };
|
|
222
|
-
//# sourceMappingURL=SliderImp.js.map
|
package/esm/components/Thumb.js
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import
|
|
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';
|
|
2
7
|
import _defineProperty from '@babel/runtime/helpers/esm/defineProperty';
|
|
3
|
-
import
|
|
4
|
-
import
|
|
5
|
-
import PropTypes from 'prop-types';
|
|
8
|
+
import 'core-js/modules/web.dom-collections.iterator.js';
|
|
9
|
+
import { useState, useContext } from 'react';
|
|
6
10
|
import { TooltipText } from '@elliemae/ds-tooltip';
|
|
7
11
|
import { SliderContext } from './context.js';
|
|
8
12
|
import { conformedThumbLabel } from './utils.js';
|
|
9
13
|
import { ThumbStyled, TooltipContainerStyled, TooltipArrow } from './styled.js';
|
|
10
|
-
import '
|
|
11
|
-
|
|
12
|
-
|
|
14
|
+
import { jsx } from 'react/jsx-runtime';
|
|
15
|
+
|
|
16
|
+
var _TooltipArrow;
|
|
13
17
|
|
|
14
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
|
|
15
19
|
|
|
16
20
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
|
|
17
21
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
step = _useContext.step,
|
|
34
|
-
minValue = _useContext.minValue;
|
|
22
|
+
const Thumb = _ref => {
|
|
23
|
+
let {
|
|
24
|
+
index,
|
|
25
|
+
props,
|
|
26
|
+
isDragged
|
|
27
|
+
} = _ref;
|
|
28
|
+
const [isHovered, setIsHovered] = useState(false);
|
|
29
|
+
const {
|
|
30
|
+
disabled,
|
|
31
|
+
rangeValues,
|
|
32
|
+
zIndex,
|
|
33
|
+
customTickMarksValues,
|
|
34
|
+
step,
|
|
35
|
+
minValue
|
|
36
|
+
} = useContext(SliderContext);
|
|
35
37
|
|
|
36
|
-
|
|
38
|
+
const cleanedProps = _objectSpread({}, props); // delete cleanedProps.key;
|
|
37
39
|
// delete cleanedProps.draggable;
|
|
38
40
|
|
|
39
41
|
|
|
@@ -41,34 +43,22 @@ var Thumb = function Thumb(_ref) {
|
|
|
41
43
|
/*#__PURE__*/
|
|
42
44
|
// ...props is needed because it's received from the library
|
|
43
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
|
|
44
|
-
|
|
46
|
+
jsx(ThumbStyled, _objectSpread(_objectSpread({}, cleanedProps), {}, {
|
|
45
47
|
"data-testid": "slider-thumb",
|
|
46
48
|
disabled: disabled // eslint-disable-next-line react/prop-types
|
|
47
49
|
,
|
|
48
50
|
style: _objectSpread(_objectSpread({}, cleanedProps.style), {}, {
|
|
49
|
-
zIndex
|
|
51
|
+
zIndex
|
|
50
52
|
}),
|
|
51
53
|
index: index,
|
|
52
|
-
onMouseEnter:
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
}
|
|
58
|
-
})
|
|
59
|
-
isDragged: isDragged,
|
|
60
|
-
isHovered: isHovered
|
|
61
|
-
}, /*#__PURE__*/React.createElement(TooltipText, null, conformedThumbLabel(rangeValues, customTickMarksValues, index, step, minValue)), /*#__PURE__*/React.createElement(TooltipArrow, null)))
|
|
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
|
+
}))
|
|
62
61
|
);
|
|
63
62
|
};
|
|
64
63
|
|
|
65
|
-
Thumb.propTypes = {
|
|
66
|
-
index: PropTypes.number,
|
|
67
|
-
props: PropTypes.shape({
|
|
68
|
-
style: PropTypes.shape({}).isRequired
|
|
69
|
-
}).isRequired,
|
|
70
|
-
isDragged: PropTypes.bool
|
|
71
|
-
};
|
|
72
|
-
|
|
73
64
|
export { Thumb as default };
|
|
74
|
-
//# sourceMappingURL=Thumb.js.map
|
|
@@ -1,50 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import _jsx from '@babel/runtime/helpers/esm/jsx';
|
|
2
|
+
import { useContext } from 'react';
|
|
2
3
|
import styled from 'styled-components';
|
|
3
4
|
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
4
5
|
import { SliderContext } from './context.js';
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const TickMarks = () => {
|
|
8
|
+
const {
|
|
9
|
+
minValue,
|
|
10
|
+
maxValue,
|
|
11
|
+
rangeValues,
|
|
12
|
+
step,
|
|
13
|
+
withTwoHandles,
|
|
14
|
+
zIndex
|
|
15
|
+
} = useContext(SliderContext);
|
|
16
|
+
const dots = [];
|
|
7
17
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
maxValue = _useContext.maxValue,
|
|
12
|
-
rangeValues = _useContext.rangeValues,
|
|
13
|
-
step = _useContext.step,
|
|
14
|
-
withTwoHandles = _useContext.withTwoHandles,
|
|
15
|
-
zIndex = _useContext.zIndex;
|
|
16
|
-
|
|
17
|
-
var dots = [];
|
|
18
|
-
|
|
19
|
-
for (var index = minValue || 0; index <= maxValue; index += step) {
|
|
20
|
-
var isActive = withTwoHandles ? rangeValues[0] <= index && index < rangeValues[1] : rangeValues[0] > index;
|
|
21
|
-
dots.push( /*#__PURE__*/React.createElement(Dot, {
|
|
18
|
+
for (let index = minValue || 0; index <= maxValue; index += step) {
|
|
19
|
+
const isActive = withTwoHandles ? rangeValues[0] <= index && index < rangeValues[1] : rangeValues[0] > index;
|
|
20
|
+
dots.push( /*#__PURE__*/_jsx(Dot, {
|
|
22
21
|
"data-testid": "slider-dot",
|
|
23
|
-
isActive: isActive
|
|
24
|
-
|
|
25
|
-
}));
|
|
22
|
+
isActive: isActive
|
|
23
|
+
}, index));
|
|
26
24
|
}
|
|
27
25
|
|
|
28
|
-
return /*#__PURE__*/
|
|
26
|
+
return /*#__PURE__*/_jsx(DotsContainer, {
|
|
29
27
|
"data-testid": "slider-tick-marks",
|
|
30
28
|
zIndex: zIndex
|
|
31
|
-
}, dots);
|
|
29
|
+
}, void 0, dots);
|
|
32
30
|
};
|
|
33
31
|
|
|
34
|
-
|
|
32
|
+
const Dot = /*#__PURE__*/styled.div.withConfig({
|
|
35
33
|
componentId: "sc-15z2sh4-0"
|
|
36
|
-
})(["&:after{content:'';background:", ";border-radius:", ";display:block;position:relative;width:2px;height:2px;}"],
|
|
37
|
-
|
|
38
|
-
}, function (props) {
|
|
39
|
-
return __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs);
|
|
40
|
-
});
|
|
41
|
-
var DotsContainer = /*#__PURE__*/styled.div.withConfig({
|
|
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({
|
|
42
36
|
componentId: "sc-15z2sh4-1"
|
|
43
|
-
})(["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:", ";"],
|
|
44
|
-
return __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs);
|
|
45
|
-
}, function (props) {
|
|
46
|
-
return props.zIndex - 1;
|
|
47
|
-
});
|
|
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);
|
|
48
38
|
|
|
49
39
|
export { TickMarks as default };
|
|
50
|
-
//# sourceMappingURL=TickMarks.js.map
|
|
@@ -1,47 +1,36 @@
|
|
|
1
|
-
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';
|
|
2
5
|
import styled from 'styled-components';
|
|
3
6
|
import { __UNSAFE_SPACE_TO_DIMSUM } from '@elliemae/ds-system';
|
|
4
7
|
import { SliderContext } from './context.js';
|
|
5
8
|
|
|
6
|
-
|
|
9
|
+
const TickMarks = () => {
|
|
10
|
+
var _TickMarksContainer;
|
|
7
11
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
return
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
}, value);
|
|
23
|
-
});
|
|
24
|
-
}, [parsedValuesArray, sliderUUID, fullSelectedValues]);
|
|
25
|
-
var PureTickMArksValues = useMemo(function () {
|
|
26
|
-
return /*#__PURE__*/React.createElement(TickMarksContainer, {
|
|
27
|
-
"data-testid": "slider-tick-marks-values"
|
|
28
|
-
}, TickMarksLabels);
|
|
29
|
-
}, [TickMarksLabels]);
|
|
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);
|
|
22
|
+
}), [parsedValuesArray, sliderUUID, fullSelectedValues]);
|
|
23
|
+
const PureTickMArksValues = useMemo(() => _TickMarksContainer || (_TickMarksContainer = /*#__PURE__*/_jsx(TickMarksContainer, {
|
|
24
|
+
"data-testid": "slider-tick-marks-values"
|
|
25
|
+
}, void 0, TickMarksLabels)), [TickMarksLabels]);
|
|
30
26
|
return PureTickMArksValues;
|
|
31
27
|
};
|
|
32
28
|
|
|
33
|
-
|
|
29
|
+
const TickMarkValue = /*#__PURE__*/styled.div.withConfig({
|
|
34
30
|
componentId: "sc-lq3yel-0"
|
|
35
|
-
})(["margin:", " 0;overflow:visible;transform:translateX(-100%);width:", ";color:", ";"],
|
|
36
|
-
|
|
37
|
-
}, function (props) {
|
|
38
|
-
return __UNSAFE_SPACE_TO_DIMSUM(props.theme.space.xxs);
|
|
39
|
-
}, function (props) {
|
|
40
|
-
return props.isSelected ? props.theme.colors.neutral[800] : props.theme.colors.neutral[500];
|
|
41
|
-
});
|
|
42
|
-
var TickMarksContainer = /*#__PURE__*/styled.div.withConfig({
|
|
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({
|
|
43
33
|
componentId: "sc-lq3yel-1"
|
|
44
34
|
})(["display:flex;justify-content:space-between;"]);
|
|
45
35
|
|
|
46
36
|
export { TickMarks as default };
|
|
47
|
-
//# sourceMappingURL=TickMarksValues.js.map
|