intelicoreact 1.8.8 → 1.8.10
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/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.jsx +18 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.jsx +121 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.jsx +507 -1
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.jsx +46 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.jsx +337 -1
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.jsx +66 -1
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.jsx +78 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.jsx +54 -1
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.jsx +183 -1
- package/dist/Atomic/FormElements/RangeList/RangeList.jsx +181 -1
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.jsx +41 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.jsx +449 -1
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.jsx +865 -1
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.jsx +37 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.jsx +48 -1
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.jsx +62 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.jsx +175 -1
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.jsx +65 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.jsx +118 -1
- package/dist/Atomic/FormElements/Text/Text.jsx +126 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.jsx +61 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.jsx +181 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.jsx +60 -1
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.jsx +83 -1
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.jsx +80 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.jsx +103 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.jsx +115 -1
- package/dist/Atomic/Layout/Header/Header.jsx +86 -1
- package/dist/Atomic/Layout/MainMenu/MainMenu.jsx +164 -1
- package/dist/Atomic/UI/AccordionTable/AccordionTable.jsx +250 -1
- package/dist/Atomic/UI/AccordionText/AccordionText.jsx +68 -1
- package/dist/Atomic/UI/Arrow/Arrow.jsx +134 -1
- package/dist/Atomic/UI/Box/Box.jsx +53 -1
- package/dist/Atomic/UI/Chart/Chart.jsx +178 -1
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.jsx +78 -1
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.jsx +334 -1
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.jsx +111 -1
- package/dist/Atomic/UI/DateTime/DateTime.jsx +57 -1
- package/dist/Atomic/UI/DebugContainer/DebugContainer.jsx +44 -1
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.jsx +15 -1
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.jsx +223 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.jsx +75 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.jsx +86 -1
- package/dist/Atomic/UI/PieChart/PieChart.jsx +41 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.jsx +87 -1
- package/dist/Atomic/UI/Table/Partials/TdHeader.jsx +36 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.jsx +103 -1
- package/dist/Atomic/UI/Table/Partials/TdTitle.jsx +55 -1
- package/dist/Atomic/UI/Table/Table.jsx +63 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.jsx +80 -1
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.jsx +26 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.jsx +13 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.jsx +56 -1
- package/dist/Atomic/UI/TagList/TagList.jsx +256 -1
- package/dist/Atomic/UI/WizardStepper/constructor.jsx +86 -1
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.jsx +254 -1
- package/dist/Functions/customEventListener.jsx +96 -1
- package/dist/Functions/operations.jsx +138 -1
- package/dist/Functions/useFormTools/functions/RenderFields.jsx +108 -1
- package/dist/Functions/useFormTools/index.jsx +777 -1
- package/dist/Functions/usePasswordChecker.jsx +128 -1
- package/dist/Functions/utils.jsx +492 -1
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.jsx +22 -1
- package/dist/Molecular/CustomIcons/components/AlertCircle.jsx +24 -1
- package/dist/Molecular/CustomIcons/components/AppStore.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/Arrow.jsx +33 -1
- package/dist/Molecular/CustomIcons/components/ArrowDown.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/ArrowLeft.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/ArrowRight.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/ArrowUp.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/Bell.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Button.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/Campaigns.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Check.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Check2.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/ChevronDown.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronLeft.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronRight.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronUp.jsx +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.jsx +28 -1
- package/dist/Molecular/CustomIcons/components/Close.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.jsx +18 -1
- package/dist/Molecular/CustomIcons/components/Delete.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Edit.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Email.jsx +32 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo.jsx +19 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.jsx +36 -1
- package/dist/Molecular/CustomIcons/components/Flows.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Gift.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/GoogleAuth.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/GooglePlay.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle.jsx +20 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle2.jsx +21 -1
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.jsx +20 -1
- package/dist/Molecular/CustomIcons/components/Home.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Home2.jsx +23 -1
- package/dist/Molecular/CustomIcons/components/Key.jsx +24 -1
- package/dist/Molecular/CustomIcons/components/Landers.jsx +21 -1
- package/dist/Molecular/CustomIcons/components/Lock.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Mail.jsx +27 -1
- package/dist/Molecular/CustomIcons/components/Mastercard.jsx +74 -1
- package/dist/Molecular/CustomIcons/components/Minus.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Offers.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/Pause.jsx +29 -1
- package/dist/Molecular/CustomIcons/components/PayPal.jsx +42 -1
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.jsx +29 -1
- package/dist/Molecular/CustomIcons/components/Phone.jsx +31 -1
- package/dist/Molecular/CustomIcons/components/Play.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Plus.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Profile.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/QRCode.jsx +30 -1
- package/dist/Molecular/CustomIcons/components/Rectangle.jsx +13 -1
- package/dist/Molecular/CustomIcons/components/Revert.jsx +14 -1
- package/dist/Molecular/CustomIcons/components/Star.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Star2.jsx +17 -1
- package/dist/Molecular/CustomIcons/components/TrafficSources.jsx +15 -1
- package/dist/Molecular/CustomIcons/components/Trash.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/TrashRed.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/Triggers.jsx +16 -1
- package/dist/Molecular/CustomIcons/components/User.jsx +26 -1
- package/dist/Molecular/CustomIcons/components/Visa.jsx +32 -1
- package/dist/Molecular/CustomIcons/components/X.jsx +13 -1
- package/dist/Molecular/FormElement/FormElement.jsx +52 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.jsx +161 -1
- package/dist/Molecular/InputAddress/InputAddress.jsx +641 -1
- package/dist/Molecular/InputPassword/InputPassword.jsx +50 -1
- package/package.json +1 -1
|
@@ -1 +1,449 @@
|
|
|
1
|
-
|
|
1
|
+
import cn from 'classnames';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useLayoutEffect, useRef, useState } from 'react';
|
|
4
|
+
import { X } from 'react-feather';
|
|
5
|
+
|
|
6
|
+
import { formatToAddBitDepthPoints as addCommas } from '../../../Functions/fieldValueFormatters';
|
|
7
|
+
import { NUMERIC_KEYBOARD } from '../../../Functions/presets/mobileKeyboardTypesPresets';
|
|
8
|
+
import useIsMobile from '../../../Functions/useIsMobile/useIsMobile';
|
|
9
|
+
import Input from '../Input/Input';
|
|
10
|
+
|
|
11
|
+
import './RangeSlider.scss';
|
|
12
|
+
|
|
13
|
+
let timer;
|
|
14
|
+
|
|
15
|
+
const DEBOUNCE_TIME = 800;
|
|
16
|
+
|
|
17
|
+
function debounce(func, timeout = DEBOUNCE_TIME) {
|
|
18
|
+
return (...args) => {
|
|
19
|
+
clearTimeout(timer);
|
|
20
|
+
timer = setTimeout(() => {
|
|
21
|
+
func.apply(this, args);
|
|
22
|
+
}, timeout);
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
export default function RangeSlider({
|
|
27
|
+
required,
|
|
28
|
+
noTrack,
|
|
29
|
+
rangeSymbol,
|
|
30
|
+
min = 0,
|
|
31
|
+
max = 100,
|
|
32
|
+
decimalPlaces = 2,
|
|
33
|
+
minRange = 0,
|
|
34
|
+
precision = 0,
|
|
35
|
+
testId = 'range-slider',
|
|
36
|
+
value = {
|
|
37
|
+
from: min,
|
|
38
|
+
to: max,
|
|
39
|
+
},
|
|
40
|
+
unit = '',
|
|
41
|
+
label = '',
|
|
42
|
+
isUseBitPoints = true,
|
|
43
|
+
|
|
44
|
+
onChange = () => {},
|
|
45
|
+
}) {
|
|
46
|
+
const { isMobile } = useIsMobile();
|
|
47
|
+
const trackRef = useRef(0);
|
|
48
|
+
const [trackWidth, setTrackWidth] = useState(0);
|
|
49
|
+
const [trackPosition, setTrackPosition] = useState(0);
|
|
50
|
+
|
|
51
|
+
const fromTriggerRef = useRef(0);
|
|
52
|
+
const toTriggerRef = useRef(0);
|
|
53
|
+
|
|
54
|
+
const prepareValue = (value) => {
|
|
55
|
+
return Number.parseInt(Number.parseFloat(value) * 10 ** precision, 10) / 10 ** precision;
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
const [from, setFromValue] = useState(value?.from ?? min);
|
|
59
|
+
const setFrom = v => setFromValue(prepareValue(v));
|
|
60
|
+
const [to, setToValue] = useState(value?.to ?? max);
|
|
61
|
+
const setTo = v => setToValue(prepareValue(v));
|
|
62
|
+
|
|
63
|
+
const [focusedType, setFocusedType] = useState(null);
|
|
64
|
+
const [frezeedValues, setFrezeedValues] = useState(null);
|
|
65
|
+
|
|
66
|
+
const [isInputsFocused, setIsInputsFocused] = useState({
|
|
67
|
+
from: false,
|
|
68
|
+
to: false,
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
const setIsInputFocused = (input, value) =>
|
|
72
|
+
setIsInputsFocused(state => ({ ...state, [input]: value }));
|
|
73
|
+
|
|
74
|
+
const fromValue = frezeedValues ? frezeedValues?.from : from;
|
|
75
|
+
const toValue = frezeedValues ? frezeedValues?.to : to;
|
|
76
|
+
|
|
77
|
+
const [movingController, setMovingController] = useState(null);
|
|
78
|
+
|
|
79
|
+
const [movingTrigger, setMovingTrigger] = useState(null);
|
|
80
|
+
const [movingTriggerType, setMovingTriggerType] = useState(null);
|
|
81
|
+
const [isTriggerMoved, setIsTriggerMoved] = useState(false);
|
|
82
|
+
|
|
83
|
+
const [pointsPerPx, setPointsPerPx] = useState(0);
|
|
84
|
+
|
|
85
|
+
const [extremumRange, setExtremumRange] = useState(0);
|
|
86
|
+
const [extremumWidth, setExtremumWidth] = useState(0);
|
|
87
|
+
|
|
88
|
+
const countPointsPerPx = (width) => {
|
|
89
|
+
return (max - min) / width;
|
|
90
|
+
};
|
|
91
|
+
|
|
92
|
+
const resetRange = () => {
|
|
93
|
+
setFrom(min);
|
|
94
|
+
setTo(max);
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
const getTrackXByPoints = (pts) => {
|
|
98
|
+
return (pts - min) / pointsPerPx;
|
|
99
|
+
};
|
|
100
|
+
|
|
101
|
+
const getRangeWidth = () => {
|
|
102
|
+
return getTrackXByPoints(toValue) - getTrackXByPoints(fromValue);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
const getRangeOffset = () => {
|
|
106
|
+
return getTrackXByPoints(fromValue);
|
|
107
|
+
};
|
|
108
|
+
|
|
109
|
+
const getXByPoints = (pts) => {
|
|
110
|
+
return (pts - min) / pointsPerPx + trackPosition;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const getPointsByX = (x) => {
|
|
114
|
+
return (x - trackPosition) * pointsPerPx + min;
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
const onRangeChange = (type, value, validate = true, callOnChange = true) => {
|
|
118
|
+
if (validate) value = prepareValue(value);
|
|
119
|
+
|
|
120
|
+
if (isNaN(value)) value = 0;
|
|
121
|
+
|
|
122
|
+
switch (type) {
|
|
123
|
+
case 'from':
|
|
124
|
+
const getValidatedFromValue = (value) => {
|
|
125
|
+
if ((!value && value !== 0) || value < min) {
|
|
126
|
+
value = min;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
if (value > to - minRange) {
|
|
130
|
+
value = to - minRange;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
return value;
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
if (validate) {
|
|
137
|
+
value = getValidatedFromValue(value);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
validate ? setFrom(value) : setFromValue(value);
|
|
141
|
+
if (!isTriggerMoved && callOnChange) {
|
|
142
|
+
debounce(() => {
|
|
143
|
+
const values = {
|
|
144
|
+
from: prepareValue(getValidatedFromValue(value)),
|
|
145
|
+
to,
|
|
146
|
+
};
|
|
147
|
+
onChange(values);
|
|
148
|
+
setFrezeedValues(values);
|
|
149
|
+
}, DEBOUNCE_TIME)();
|
|
150
|
+
}
|
|
151
|
+
break;
|
|
152
|
+
case 'to':
|
|
153
|
+
const getValidatedToValue = (value) => {
|
|
154
|
+
if ((!value && value !== 0) || value > max) {
|
|
155
|
+
value = max;
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
if (value < from + minRange) {
|
|
159
|
+
value = from + minRange;
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
return value;
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
if (validate) {
|
|
166
|
+
value = getValidatedToValue(value);
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
validate ? setTo(value) : setToValue(value);
|
|
170
|
+
if (!isTriggerMoved && callOnChange) {
|
|
171
|
+
debounce(() => {
|
|
172
|
+
const values = {
|
|
173
|
+
from,
|
|
174
|
+
to: prepareValue(getValidatedToValue(value)),
|
|
175
|
+
};
|
|
176
|
+
onChange(values);
|
|
177
|
+
setFrezeedValues(values);
|
|
178
|
+
}, DEBOUNCE_TIME)();
|
|
179
|
+
}
|
|
180
|
+
break;
|
|
181
|
+
}
|
|
182
|
+
};
|
|
183
|
+
// MouseDown Event Controller
|
|
184
|
+
const onTriggerMouseDown = (e, type) => {
|
|
185
|
+
if (e.button !== 0 && !isMobile) return; // Отменить обработку, если нажата не левая кнопка мыши
|
|
186
|
+
setMovingTrigger(e.target);
|
|
187
|
+
setMovingTriggerType(type);
|
|
188
|
+
setIsTriggerMoved(true); // Установить флаг движения в true при клике
|
|
189
|
+
};
|
|
190
|
+
|
|
191
|
+
const onTriggerMove = (e) => {
|
|
192
|
+
if (!isMobile) {
|
|
193
|
+
e.preventDefault();
|
|
194
|
+
e.stopPropagation();
|
|
195
|
+
}
|
|
196
|
+
|
|
197
|
+
if (!isTriggerMoved) setIsTriggerMoved(true);
|
|
198
|
+
if (!movingTrigger) return false;
|
|
199
|
+
|
|
200
|
+
let { clientX: x } = isMobile ? e?.touches?.[0] : e;
|
|
201
|
+
const { width: triggerWidth = 16 }
|
|
202
|
+
= movingTrigger?.getBoundingClientRect() || {};
|
|
203
|
+
|
|
204
|
+
if (x < trackPosition || x > trackPosition + trackWidth + triggerWidth)
|
|
205
|
+
return false;
|
|
206
|
+
|
|
207
|
+
x -= triggerWidth / 2;
|
|
208
|
+
|
|
209
|
+
onRangeChange(movingTriggerType, getPointsByX(x));
|
|
210
|
+
};
|
|
211
|
+
const onTriggerMoveEnd = () => {
|
|
212
|
+
setMovingTrigger(null);
|
|
213
|
+
setMovingTriggerType(null);
|
|
214
|
+
setIsTriggerMoved(false);
|
|
215
|
+
};
|
|
216
|
+
const onRangeInputFocus = (e, type) => {
|
|
217
|
+
setTimeout(() => setIsInputFocused(type, true), 1);
|
|
218
|
+
};
|
|
219
|
+
|
|
220
|
+
const onRangeInputBlur = (e, type) => {
|
|
221
|
+
setIsInputFocused(type, false);
|
|
222
|
+
};
|
|
223
|
+
|
|
224
|
+
useEffect(() => {
|
|
225
|
+
onRangeChange('from', value?.from ?? max, true, false);
|
|
226
|
+
onRangeChange('to', value?.to ?? min, true, false);
|
|
227
|
+
}, []);
|
|
228
|
+
|
|
229
|
+
/// MouseUp Event Controller
|
|
230
|
+
useEffect(() => {
|
|
231
|
+
document.addEventListener('mouseup', onTriggerMoveEnd);
|
|
232
|
+
|
|
233
|
+
return () => {
|
|
234
|
+
document.removeEventListener('mouseup', onTriggerMoveEnd);
|
|
235
|
+
};
|
|
236
|
+
}, []);
|
|
237
|
+
|
|
238
|
+
// MouseMove Event Controller
|
|
239
|
+
useEffect(() => {
|
|
240
|
+
// Прекратить обработку, если нет активного триггера или не было движения
|
|
241
|
+
if (!movingTrigger || !isTriggerMoved) return;
|
|
242
|
+
const handleMouseMove = (e) => {
|
|
243
|
+
onTriggerMove(e);
|
|
244
|
+
};
|
|
245
|
+
|
|
246
|
+
document.addEventListener('mousemove', handleMouseMove);
|
|
247
|
+
|
|
248
|
+
return () => {
|
|
249
|
+
document.removeEventListener('mousemove', handleMouseMove);
|
|
250
|
+
};
|
|
251
|
+
}, [movingTrigger, isTriggerMoved]);
|
|
252
|
+
|
|
253
|
+
useEffect(() => {
|
|
254
|
+
if (movingController) {
|
|
255
|
+
document.addEventListener('mousemove', onTriggerMove, {
|
|
256
|
+
signal: movingController?.signal,
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
}, [movingController]);
|
|
260
|
+
|
|
261
|
+
useEffect(() => {
|
|
262
|
+
setFrezeedValues(null);
|
|
263
|
+
}, [isTriggerMoved]);
|
|
264
|
+
|
|
265
|
+
useEffect(() => {
|
|
266
|
+
if (
|
|
267
|
+
Object.values(isInputsFocused).every(v => !v)
|
|
268
|
+
&& !isTriggerMoved
|
|
269
|
+
&& (value.from !== from || value.to !== to)
|
|
270
|
+
) {
|
|
271
|
+
onChange({ from, to });
|
|
272
|
+
}
|
|
273
|
+
if (isTriggerMoved) setFrezeedValues({ from, to });
|
|
274
|
+
}, [from, to, isTriggerMoved]);
|
|
275
|
+
|
|
276
|
+
useLayoutEffect(() => {
|
|
277
|
+
setFrom(value.from);
|
|
278
|
+
setTo(value.to);
|
|
279
|
+
}, [value]);
|
|
280
|
+
|
|
281
|
+
useLayoutEffect(() => {
|
|
282
|
+
let { width, x } = trackRef?.current?.getBoundingClientRect() || {};
|
|
283
|
+
width
|
|
284
|
+
-= fromTriggerRef?.current?.getBoundingClientRect()?.width
|
|
285
|
+
|| toTriggerRef?.current?.getBoundingClientRect()?.width;
|
|
286
|
+
|
|
287
|
+
setPointsPerPx(countPointsPerPx(width));
|
|
288
|
+
setTrackWidth(width);
|
|
289
|
+
setTrackPosition(x);
|
|
290
|
+
}, [trackRef]);
|
|
291
|
+
|
|
292
|
+
useEffect(() => {
|
|
293
|
+
if (Object.values(isInputsFocused).every(v => !v)) {
|
|
294
|
+
setFrezeedValues(false);
|
|
295
|
+
}
|
|
296
|
+
else {
|
|
297
|
+
setFrezeedValues({ from, to });
|
|
298
|
+
}
|
|
299
|
+
}, [isInputsFocused]);
|
|
300
|
+
|
|
301
|
+
const renderLabel = () => {
|
|
302
|
+
return (
|
|
303
|
+
<div className="range-slider__header__label">
|
|
304
|
+
{label}
|
|
305
|
+
{required && <span className="label_isRequired">*</span>}
|
|
306
|
+
</div>
|
|
307
|
+
);
|
|
308
|
+
};
|
|
309
|
+
|
|
310
|
+
const renderSelectedRange = () => {
|
|
311
|
+
return (
|
|
312
|
+
<div className="range-slider__header__selected-range">
|
|
313
|
+
<div className="range-slider__header__selected-range--text">
|
|
314
|
+
from
|
|
315
|
+
{' '}
|
|
316
|
+
{isUseBitPoints ? addCommas(fromValue) : fromValue}
|
|
317
|
+
{' '}
|
|
318
|
+
to
|
|
319
|
+
{' '}
|
|
320
|
+
{isUseBitPoints ? addCommas(toValue) : toValue}
|
|
321
|
+
{rangeSymbol}
|
|
322
|
+
{unit}
|
|
323
|
+
</div>
|
|
324
|
+
<div
|
|
325
|
+
className="range-slider__header__selected-range--reset"
|
|
326
|
+
onClick={resetRange}
|
|
327
|
+
>
|
|
328
|
+
<X />
|
|
329
|
+
</div>
|
|
330
|
+
</div>
|
|
331
|
+
);
|
|
332
|
+
};
|
|
333
|
+
|
|
334
|
+
const renderHeader = () => {
|
|
335
|
+
return (
|
|
336
|
+
<div className="range-slider__header">
|
|
337
|
+
{renderLabel()}
|
|
338
|
+
{min !== fromValue || max !== toValue ? renderSelectedRange() : null}
|
|
339
|
+
</div>
|
|
340
|
+
);
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
const renderInputs = () => {
|
|
344
|
+
return (
|
|
345
|
+
<div className="range-slider__inputs">
|
|
346
|
+
<div className="range-slider__inputs--from">
|
|
347
|
+
<Input
|
|
348
|
+
data-testid={`${testId}-input-from`}
|
|
349
|
+
value={from.toString()}
|
|
350
|
+
onFocus={e => onRangeInputFocus(e, 'from')}
|
|
351
|
+
onBlur={e => onRangeInputBlur(e, 'from')}
|
|
352
|
+
onChange={value => onRangeChange('from', value, false)}
|
|
353
|
+
onlyNumbers={{ type: 'float', decimalPlaces, min, max }}
|
|
354
|
+
isPriceInput={isUseBitPoints}
|
|
355
|
+
{...NUMERIC_KEYBOARD}
|
|
356
|
+
/>
|
|
357
|
+
</div>
|
|
358
|
+
<div className="range-slider__inputs__input">
|
|
359
|
+
<Input
|
|
360
|
+
data-testid={`${testId}-input-to`}
|
|
361
|
+
value={to.toString()}
|
|
362
|
+
onFocus={e => onRangeInputFocus(e, 'to')}
|
|
363
|
+
onBlur={e => onRangeInputBlur(e, 'to')}
|
|
364
|
+
onChange={value => onRangeChange('to', value, false)}
|
|
365
|
+
onlyNumbers={{ type: 'float', decimalPlaces, min, max }}
|
|
366
|
+
isPriceInput={isUseBitPoints}
|
|
367
|
+
{...NUMERIC_KEYBOARD}
|
|
368
|
+
/>
|
|
369
|
+
</div>
|
|
370
|
+
</div>
|
|
371
|
+
);
|
|
372
|
+
};
|
|
373
|
+
|
|
374
|
+
const renderTrackRange = () => {
|
|
375
|
+
const style = {
|
|
376
|
+
width: `${getRangeWidth()}px`,
|
|
377
|
+
left: `${getRangeOffset()}px`,
|
|
378
|
+
};
|
|
379
|
+
return <div className="range-slider__track__range" style={style} />;
|
|
380
|
+
};
|
|
381
|
+
|
|
382
|
+
const renderTrackTriggers = () => {
|
|
383
|
+
const fromStyle = {
|
|
384
|
+
left: `${getTrackXByPoints(fromValue)}px`,
|
|
385
|
+
};
|
|
386
|
+
const toStyle = {
|
|
387
|
+
left: `${getTrackXByPoints(toValue)}px`,
|
|
388
|
+
};
|
|
389
|
+
const renderTrack = () => {
|
|
390
|
+
return (
|
|
391
|
+
<div
|
|
392
|
+
className={cn('range-slider__track', { hidden: noTrack })}
|
|
393
|
+
ref={trackRef}
|
|
394
|
+
>
|
|
395
|
+
<div className="range-slider__track__line" />
|
|
396
|
+
{renderTrackRange()}
|
|
397
|
+
{renderTrackTriggers()}
|
|
398
|
+
</div>
|
|
399
|
+
);
|
|
400
|
+
};
|
|
401
|
+
return (
|
|
402
|
+
<div className="range-slider__track__range-triggers">
|
|
403
|
+
<div
|
|
404
|
+
data-testid={`${testId}-track-from`}
|
|
405
|
+
ref={fromTriggerRef}
|
|
406
|
+
style={fromStyle}
|
|
407
|
+
className="range-slider__track__range-triggers--trigger range-slider__track__range-triggers--trigger-left"
|
|
408
|
+
onMouseDown={e => (!isMobile ? onTriggerMouseDown(e, 'from') : {})}
|
|
409
|
+
onTouchStart={e => onTriggerMouseDown(e, 'from')}
|
|
410
|
+
onTouchMove={onTriggerMove}
|
|
411
|
+
onTouchEnd={onTriggerMoveEnd}
|
|
412
|
+
onClick={() => {}} // DONT REMOVE! MOBILE WILL NOT WORK WITHOUT IT
|
|
413
|
+
/>
|
|
414
|
+
<div
|
|
415
|
+
data-testid={`${testId}-track-to`}
|
|
416
|
+
ref={toTriggerRef}
|
|
417
|
+
style={toStyle}
|
|
418
|
+
className="range-slider__track__range-triggers--trigger range-slider__track__range-triggers--trigger-right"
|
|
419
|
+
onMouseDown={e => (!isMobile ? onTriggerMouseDown(e, 'to') : {})}
|
|
420
|
+
onTouchStart={e => onTriggerMouseDown(e, 'to')}
|
|
421
|
+
onTouchMove={onTriggerMove}
|
|
422
|
+
onTouchEnd={onTriggerMoveEnd}
|
|
423
|
+
onClick={() => {}} // DONT REMOVE! MOBILE WILL NOT WORK WITHOUT IT
|
|
424
|
+
/>
|
|
425
|
+
</div>
|
|
426
|
+
);
|
|
427
|
+
};
|
|
428
|
+
|
|
429
|
+
const renderTrack = () => {
|
|
430
|
+
return (
|
|
431
|
+
<div
|
|
432
|
+
className={cn('range-slider__track', { hidden: noTrack })}
|
|
433
|
+
ref={trackRef}
|
|
434
|
+
>
|
|
435
|
+
<div className="range-slider__track__line" />
|
|
436
|
+
{renderTrackRange()}
|
|
437
|
+
{renderTrackTriggers()}
|
|
438
|
+
</div>
|
|
439
|
+
);
|
|
440
|
+
};
|
|
441
|
+
|
|
442
|
+
return (
|
|
443
|
+
<div data-testid={testId} className="range-slider">
|
|
444
|
+
{renderHeader()}
|
|
445
|
+
{renderInputs()}
|
|
446
|
+
{renderTrack()}
|
|
447
|
+
</div>
|
|
448
|
+
);
|
|
449
|
+
}
|