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,18 @@
|
|
|
1
|
-
import
|
|
1
|
+
import './DropdownLoader.scss';
|
|
2
|
+
|
|
3
|
+
function DropdownLoader({ variant = '' }) {
|
|
4
|
+
return (
|
|
5
|
+
<div className="dropdown-loader-box j5">
|
|
6
|
+
<div
|
|
7
|
+
className={`lds-ring${variant === 'little' ? ' lds-ring_little' : ''}`}
|
|
8
|
+
>
|
|
9
|
+
<div />
|
|
10
|
+
<div />
|
|
11
|
+
<div />
|
|
12
|
+
<div />
|
|
13
|
+
</div>
|
|
14
|
+
</div>
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default DropdownLoader;
|
|
@@ -1 +1,121 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useRef, useState } from 'react';
|
|
2
|
+
|
|
3
|
+
import { Eye, EyeOff } from 'react-feather';
|
|
4
|
+
|
|
5
|
+
import { setCarretToEnd } from '../../../Functions/utils';
|
|
6
|
+
import Input from '../Input/Input';
|
|
7
|
+
|
|
8
|
+
import './FormattedRawSSN.scss';
|
|
9
|
+
|
|
10
|
+
function FormattedRawSSN({
|
|
11
|
+
value = '',
|
|
12
|
+
postfix = '',
|
|
13
|
+
onChange: onChangeProp = () => {},
|
|
14
|
+
maskChar = '*',
|
|
15
|
+
testId = 'formatted-raw-ssn',
|
|
16
|
+
isHiddenDefault = true,
|
|
17
|
+
maxLen = 9,
|
|
18
|
+
...args
|
|
19
|
+
}) {
|
|
20
|
+
const [SSN, setSSN] = useState(value?.substring(0, maxLen) ?? '');
|
|
21
|
+
const [isHidden, setIsHidden] = useState(isHiddenDefault);
|
|
22
|
+
const wrapperRef = useRef(null);
|
|
23
|
+
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
setSSN(value?.toString()?.substring(0, maxLen) ?? '');
|
|
26
|
+
}, [value]);
|
|
27
|
+
|
|
28
|
+
const onChange = (value) => {
|
|
29
|
+
if (!value && value !== '') return '';
|
|
30
|
+
|
|
31
|
+
if (value.replace(/-/g, '').length < SSN.length) {
|
|
32
|
+
const last = SSN.length - 1;
|
|
33
|
+
setSSN(SSN.slice(0, last));
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const numValue = value.replace(/\D/g, '');
|
|
38
|
+
let newSSN = '';
|
|
39
|
+
|
|
40
|
+
if (isHidden) {
|
|
41
|
+
if (SSN.length > 5) {
|
|
42
|
+
newSSN = SSN.slice(0, 5) + numValue;
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
newSSN = SSN + numValue;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
else {
|
|
49
|
+
newSSN = numValue;
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
if (newSSN.length > maxLen) {
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
setSSN(newSSN);
|
|
56
|
+
};
|
|
57
|
+
const switchView = () => {
|
|
58
|
+
const input = wrapperRef?.current?.querySelector('input');
|
|
59
|
+
input?.focus();
|
|
60
|
+
setCarretToEnd(input);
|
|
61
|
+
setIsHidden(!isHidden);
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const getFormatedValue = (v) => {
|
|
65
|
+
if (!v) return '';
|
|
66
|
+
|
|
67
|
+
v = v.slice(0, 11).replace(/-/g, '');
|
|
68
|
+
if (v.length <= 3) {
|
|
69
|
+
return v;
|
|
70
|
+
}
|
|
71
|
+
if (v.length > 3 && v.length <= 5) {
|
|
72
|
+
return `${v.slice(0, 3)}-${v.slice(3)}`;
|
|
73
|
+
}
|
|
74
|
+
if (v.length > 5) {
|
|
75
|
+
return `${v.slice(0, 3)}-${v.slice(3, 5)}-${v.slice(5)}`;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
const getMaskedValue = (v) => {
|
|
79
|
+
return isHidden
|
|
80
|
+
? v.slice(0, 7).replace(/\d/g, maskChar).concat(v.slice(7))
|
|
81
|
+
: v;
|
|
82
|
+
};
|
|
83
|
+
|
|
84
|
+
useEffect(() => {
|
|
85
|
+
if (SSN) {
|
|
86
|
+
onChangeProp?.(
|
|
87
|
+
SSN.concat(SSN.length === maxLen ? postfix : '').replace(/-/g, ''),
|
|
88
|
+
);
|
|
89
|
+
}
|
|
90
|
+
}, [SSN]);
|
|
91
|
+
|
|
92
|
+
return (
|
|
93
|
+
<div data-testid={testId} className="formatted-raw-ssn" ref={wrapperRef}>
|
|
94
|
+
<Input
|
|
95
|
+
{...args}
|
|
96
|
+
value={getMaskedValue(getFormatedValue(SSN))}
|
|
97
|
+
onChange={onChange}
|
|
98
|
+
/>
|
|
99
|
+
{postfix && (
|
|
100
|
+
<span
|
|
101
|
+
className="formatted-raw-ssn-postfix"
|
|
102
|
+
onClick={() => wrapperRef?.current?.querySelector('input')?.focus()}
|
|
103
|
+
>
|
|
104
|
+
{postfix}
|
|
105
|
+
</span>
|
|
106
|
+
)}
|
|
107
|
+
<span className="formatted-raw-ssn-eye-holder" onClick={switchView}>
|
|
108
|
+
{' '}
|
|
109
|
+
{isHidden
|
|
110
|
+
? (
|
|
111
|
+
<Eye strokeWidth={1} className="password-icon" />
|
|
112
|
+
)
|
|
113
|
+
: (
|
|
114
|
+
<EyeOff strokeWidth={1} className="password-icon" />
|
|
115
|
+
)}
|
|
116
|
+
</span>
|
|
117
|
+
</div>
|
|
118
|
+
);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
export default FormattedRawSSN;
|
|
@@ -1 +1,507 @@
|
|
|
1
|
-
|
|
1
|
+
import moment from 'moment';
|
|
2
|
+
|
|
3
|
+
import { useEffect, useRef, useState } from 'react';
|
|
4
|
+
import { ChevronDown, ChevronUp } from 'react-feather';
|
|
5
|
+
|
|
6
|
+
import './MobileCalendar.scss';
|
|
7
|
+
|
|
8
|
+
require('../../../Functions/customEventListener');
|
|
9
|
+
|
|
10
|
+
function MobileCalendar({
|
|
11
|
+
min = moment().subtract('10', 'years'),
|
|
12
|
+
max = moment().add('10', 'years'),
|
|
13
|
+
value = moment(),
|
|
14
|
+
rows = 5,
|
|
15
|
+
label = '',
|
|
16
|
+
timeout = 75,
|
|
17
|
+
isMobile = true,
|
|
18
|
+
showSelectedDate = false,
|
|
19
|
+
listItemHeight = 32,
|
|
20
|
+
|
|
21
|
+
classes = {
|
|
22
|
+
wrapper: '',
|
|
23
|
+
label: '',
|
|
24
|
+
body: '',
|
|
25
|
+
|
|
26
|
+
yearsBlock: '',
|
|
27
|
+
yearsList: '',
|
|
28
|
+
yearsListItem: '',
|
|
29
|
+
|
|
30
|
+
monthsBlock: '',
|
|
31
|
+
monthsList: '',
|
|
32
|
+
monthsListItem: '',
|
|
33
|
+
|
|
34
|
+
daysBlock: '',
|
|
35
|
+
daysList: '',
|
|
36
|
+
daysListItem: '',
|
|
37
|
+
|
|
38
|
+
prevItem: '',
|
|
39
|
+
nextItem: '',
|
|
40
|
+
activeItem: '',
|
|
41
|
+
},
|
|
42
|
+
onChange = () => {},
|
|
43
|
+
onMinDateReached = () => {},
|
|
44
|
+
onMaxDateReached = () => {},
|
|
45
|
+
}) {
|
|
46
|
+
const Body = document.querySelector('body');
|
|
47
|
+
const listItem = document.querySelector(
|
|
48
|
+
'.mobile-calendar_wrapper_body_months-list--item',
|
|
49
|
+
);
|
|
50
|
+
|
|
51
|
+
const [date, setDate] = useState(value ? moment(value) : moment());
|
|
52
|
+
const [minDate, setMinDate] = useState(moment(min));
|
|
53
|
+
const [maxDate, setMaxDate] = useState(moment(max));
|
|
54
|
+
|
|
55
|
+
const [isMouseDown, setIsMouseDown] = useState(false);
|
|
56
|
+
const [mouseDownOn, setMouseDownOn] = useState(null);
|
|
57
|
+
const [changeInterval, setChangeInterval] = useState(null);
|
|
58
|
+
|
|
59
|
+
const [touchY, setTouchY] = useState(null);
|
|
60
|
+
const [touchType, setTouchType] = useState(null);
|
|
61
|
+
const [touchTimestamp, setTouchTimestamp] = useState(null);
|
|
62
|
+
|
|
63
|
+
const [scrollDirection, setScrollDirection] = useState(0);
|
|
64
|
+
|
|
65
|
+
const monthsListRef = useRef(null);
|
|
66
|
+
const daysListRef = useRef(null);
|
|
67
|
+
const yearsListRef = useRef(null);
|
|
68
|
+
|
|
69
|
+
const dateRef = useRef(null);
|
|
70
|
+
const intervalRef = useRef(null);
|
|
71
|
+
|
|
72
|
+
// --HANDLERS--//
|
|
73
|
+
const changeItem = (type, value) => {
|
|
74
|
+
setScrollDirection(value);
|
|
75
|
+
setDate((date) => {
|
|
76
|
+
const newDate = moment(date).add(value, type);
|
|
77
|
+
|
|
78
|
+
if (moment(newDate).isBefore(minDate)) return minDate;
|
|
79
|
+
if (moment(newDate).isAfter(maxDate)) return maxDate;
|
|
80
|
+
|
|
81
|
+
return newDate;
|
|
82
|
+
});
|
|
83
|
+
setTimeout(() => {
|
|
84
|
+
setScrollDirection(0);
|
|
85
|
+
}, 50);
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
const checkAvailability = (type, value) => {
|
|
89
|
+
if (!dateRef?.current) return false;
|
|
90
|
+
|
|
91
|
+
const newDate = moment(dateRef?.current).add(value, type);
|
|
92
|
+
|
|
93
|
+
if (moment(newDate).isBefore(minDate)) return false;
|
|
94
|
+
if (moment(newDate).isAfter(maxDate)) return false;
|
|
95
|
+
|
|
96
|
+
return true;
|
|
97
|
+
};
|
|
98
|
+
const onArrowMouseDown = (type, value) => {
|
|
99
|
+
setIsMouseDown(true);
|
|
100
|
+
setMouseDownOn({ type, value });
|
|
101
|
+
};
|
|
102
|
+
const onArrowMouseUp = () => {
|
|
103
|
+
setIsMouseDown(false);
|
|
104
|
+
setMouseDownOn(null);
|
|
105
|
+
};
|
|
106
|
+
const onWheel = (e, type) => {
|
|
107
|
+
e.preventDefault();
|
|
108
|
+
|
|
109
|
+
const { deltaY } = e;
|
|
110
|
+
const top = window.scrollX;
|
|
111
|
+
const left = window.scrollY;
|
|
112
|
+
|
|
113
|
+
window.scrollTo({ top, left });
|
|
114
|
+
|
|
115
|
+
changeItem(type, deltaY < 0 ? -1 : 1);
|
|
116
|
+
};
|
|
117
|
+
const onTouchStart = (e, type) => {
|
|
118
|
+
e.preventDefault();
|
|
119
|
+
|
|
120
|
+
if (intervalRef?.current) {
|
|
121
|
+
clearInterval(intervalRef?.current);
|
|
122
|
+
intervalRef.current = null;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const { timeStamp, changedTouches } = e;
|
|
126
|
+
const { pageY } = changedTouches[0];
|
|
127
|
+
|
|
128
|
+
setTouchY(pageY);
|
|
129
|
+
setTouchTimestamp(timeStamp);
|
|
130
|
+
setTouchType(type);
|
|
131
|
+
|
|
132
|
+
window.addEventListener(
|
|
133
|
+
'touchend',
|
|
134
|
+
e => onTouchEnd(e, pageY, timeStamp, type),
|
|
135
|
+
{ once: true },
|
|
136
|
+
);
|
|
137
|
+
};
|
|
138
|
+
const onTouchMove = (e) => {
|
|
139
|
+
if (!touchY || !touchType) return;
|
|
140
|
+
|
|
141
|
+
const { timeStamp, changedTouches } = e;
|
|
142
|
+
const { pageY } = changedTouches[0];
|
|
143
|
+
|
|
144
|
+
const deltaY = touchY - pageY;
|
|
145
|
+
|
|
146
|
+
if (Math.abs(deltaY) < listItemHeight) return;
|
|
147
|
+
|
|
148
|
+
const direction = deltaY < 0 ? -1 : 1;
|
|
149
|
+
|
|
150
|
+
setScrollDirection(direction);
|
|
151
|
+
|
|
152
|
+
changeItem(touchType, direction);
|
|
153
|
+
setTouchY(pageY);
|
|
154
|
+
setTouchTimestamp(timeStamp);
|
|
155
|
+
};
|
|
156
|
+
const onTouchEnd = (e, startY, startTime, touchType) => {
|
|
157
|
+
const { timeStamp, changedTouches } = e;
|
|
158
|
+
const { pageY } = changedTouches[0];
|
|
159
|
+
|
|
160
|
+
const path = Math.abs(startY - pageY); // in px
|
|
161
|
+
const time = timeStamp - startTime; // ms
|
|
162
|
+
const pxPerMs = path / time;
|
|
163
|
+
|
|
164
|
+
if (pxPerMs > 0.65)
|
|
165
|
+
innertionScroll({ startY, pageY, timeStamp, startTime, touchType });
|
|
166
|
+
else setTouchType(null);
|
|
167
|
+
|
|
168
|
+
setTouchY(null);
|
|
169
|
+
};
|
|
170
|
+
const innertionScroll = ({
|
|
171
|
+
startY,
|
|
172
|
+
pageY,
|
|
173
|
+
timeStamp,
|
|
174
|
+
startTime,
|
|
175
|
+
touchType,
|
|
176
|
+
}) => {
|
|
177
|
+
const path = Math.abs(startY - pageY); // in px
|
|
178
|
+
const time = timeStamp - startTime; // ms
|
|
179
|
+
const pxPerMs = Math.ceil(path / time); // speed
|
|
180
|
+
|
|
181
|
+
const S = (pxPerMs / 2) * time;
|
|
182
|
+
const blocks = Math.ceil((S / listItemHeight) * pxPerMs);
|
|
183
|
+
|
|
184
|
+
let i = 1;
|
|
185
|
+
|
|
186
|
+
intervalRef.current = setInterval(() => {
|
|
187
|
+
if (
|
|
188
|
+
checkAvailability(touchType, startY - pageY < 0 ? -1 : 1, date)
|
|
189
|
+
&& i <= blocks
|
|
190
|
+
) {
|
|
191
|
+
changeItem(touchType, startY - pageY < 0 ? -1 : 1);
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
setTouchType(null);
|
|
195
|
+
clearInterval(intervalRef?.current);
|
|
196
|
+
intervalRef.current = null;
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
++i;
|
|
200
|
+
}, timeout);
|
|
201
|
+
|
|
202
|
+
// for(let i = 1; i <= blocks; ++i){
|
|
203
|
+
// // timeout = i*pxPerMs+Math.pow(i,2)*10;
|
|
204
|
+
// timeout += 80;
|
|
205
|
+
// if(checkAvailability(touchType, startY-pageY < 0 ? -1 : 1, date)){
|
|
206
|
+
// setTimeout(() => {
|
|
207
|
+
// console.log({timeout})
|
|
208
|
+
// changeItem(touchType, startY-pageY < 0 ? -1 : 1);
|
|
209
|
+
// }, timeout)
|
|
210
|
+
// }
|
|
211
|
+
|
|
212
|
+
// }
|
|
213
|
+
};
|
|
214
|
+
|
|
215
|
+
// --FUNCTIONS--//
|
|
216
|
+
const intervalWorker = () => {
|
|
217
|
+
if (!mouseDownOn) return;
|
|
218
|
+
|
|
219
|
+
const { type, value } = mouseDownOn;
|
|
220
|
+
changeItem(type, value);
|
|
221
|
+
};
|
|
222
|
+
const getList = (type, format) => {
|
|
223
|
+
const list = [];
|
|
224
|
+
|
|
225
|
+
const renderRows = rows;
|
|
226
|
+
|
|
227
|
+
for (let i = (renderRows - 1) / 2; i >= ((renderRows - 1) / 2) * -1; --i) {
|
|
228
|
+
list.push(moment(date).subtract(i, type).format(format));
|
|
229
|
+
}
|
|
230
|
+
|
|
231
|
+
return list;
|
|
232
|
+
};
|
|
233
|
+
const getMonthList = () => getList('months', 'MMMM');
|
|
234
|
+
const getDaysList = () => getList('days', 'D');
|
|
235
|
+
const getYearsList = () => getList('years', 'YYYY');
|
|
236
|
+
|
|
237
|
+
// --OBSERVERS--//
|
|
238
|
+
useEffect(() => {
|
|
239
|
+
if (moment(date.format('L')).isBefore(minDate.format('L')))
|
|
240
|
+
setDate(minDate);
|
|
241
|
+
if (moment(date.format('L')).isAfter(maxDate.format('L'))) setDate(maxDate);
|
|
242
|
+
}, []);
|
|
243
|
+
|
|
244
|
+
// Events Observer
|
|
245
|
+
useEffect(() => {
|
|
246
|
+
document.addEventListener('mouseup', onArrowMouseUp);
|
|
247
|
+
return () => {
|
|
248
|
+
document.removeEventListener('mouseup', onArrowMouseUp);
|
|
249
|
+
};
|
|
250
|
+
}, []);
|
|
251
|
+
|
|
252
|
+
useEffect(() => {
|
|
253
|
+
onChange(date);
|
|
254
|
+
dateRef.current = date;
|
|
255
|
+
|
|
256
|
+
if (moment(date.format('L')).isSame(minDate.format('L')))
|
|
257
|
+
onMinDateReached(minDate);
|
|
258
|
+
if (moment(date.format('L')).isSame(maxDate.format('L')))
|
|
259
|
+
onMaxDateReached(maxDate);
|
|
260
|
+
}, [date]);
|
|
261
|
+
|
|
262
|
+
// monthList Events
|
|
263
|
+
useEffect(() => {
|
|
264
|
+
if (monthsListRef?.current) {
|
|
265
|
+
monthsListRef?.current?.addEventListener(
|
|
266
|
+
'mousewheel',
|
|
267
|
+
e => onWheel(e, 'months'),
|
|
268
|
+
{ passive: false },
|
|
269
|
+
);
|
|
270
|
+
monthsListRef?.current?.addEventListener(
|
|
271
|
+
'touchstart',
|
|
272
|
+
e => onTouchStart(e, 'months'),
|
|
273
|
+
{ passive: false },
|
|
274
|
+
);
|
|
275
|
+
}
|
|
276
|
+
|
|
277
|
+
return () => {
|
|
278
|
+
monthsListRef?.current?.clearEventListeners('mousewheel');
|
|
279
|
+
monthsListRef?.current?.clearEventListeners('touchstart');
|
|
280
|
+
};
|
|
281
|
+
}, [monthsListRef]);
|
|
282
|
+
|
|
283
|
+
// daysList Events
|
|
284
|
+
useEffect(() => {
|
|
285
|
+
if (daysListRef?.current) {
|
|
286
|
+
daysListRef?.current?.addEventListener(
|
|
287
|
+
'mousewheel',
|
|
288
|
+
e => onWheel(e, 'days'),
|
|
289
|
+
{ passive: false },
|
|
290
|
+
);
|
|
291
|
+
daysListRef?.current?.addEventListener(
|
|
292
|
+
'touchstart',
|
|
293
|
+
e => onTouchStart(e, 'days'),
|
|
294
|
+
{ passive: false },
|
|
295
|
+
);
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
return () => {
|
|
299
|
+
daysListRef?.current?.clearEventListeners('mousewheel');
|
|
300
|
+
daysListRef?.current?.clearEventListeners('touchstart');
|
|
301
|
+
};
|
|
302
|
+
}, [daysListRef]);
|
|
303
|
+
|
|
304
|
+
// yearsList Events
|
|
305
|
+
useEffect(() => {
|
|
306
|
+
if (yearsListRef?.current) {
|
|
307
|
+
yearsListRef?.current?.addEventListener(
|
|
308
|
+
'mousewheel',
|
|
309
|
+
e => onWheel(e, 'years'),
|
|
310
|
+
{ passive: false },
|
|
311
|
+
);
|
|
312
|
+
yearsListRef?.current?.addEventListener(
|
|
313
|
+
'touchstart',
|
|
314
|
+
e => onTouchStart(e, 'years'),
|
|
315
|
+
{ passive: false },
|
|
316
|
+
);
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
return () => {
|
|
320
|
+
yearsListRef?.current?.clearEventListeners('mousewheel');
|
|
321
|
+
yearsListRef?.current?.clearEventListeners('touchstart');
|
|
322
|
+
};
|
|
323
|
+
}, [yearsListRef]);
|
|
324
|
+
|
|
325
|
+
// --RENDER--//
|
|
326
|
+
const renderMonthsList = () => {
|
|
327
|
+
const half = (rows - 1) / 2;
|
|
328
|
+
return getMonthList().map((month, i) => (
|
|
329
|
+
<div
|
|
330
|
+
className={`mobile-calendar_wrapper_body_months-list--item ${i === half ? 'active' : ''} ${
|
|
331
|
+
i === 0 || i === rows - 1 ? 'transparent' : ''
|
|
332
|
+
} ${classes?.monthsListItem} ${i === half ? classes?.activeItem : ''}`}
|
|
333
|
+
key={`month-${month}`}
|
|
334
|
+
onClick={
|
|
335
|
+
touchY
|
|
336
|
+
? null
|
|
337
|
+
: () => (i - half === 0 ? {} : changeItem('months', i - half))
|
|
338
|
+
}
|
|
339
|
+
attr-scroll-direction={touchType === 'months' ? scrollDirection : 0}
|
|
340
|
+
attr-is-scrolling={touchType === 'months' ? 1 : 0}
|
|
341
|
+
>
|
|
342
|
+
{month}
|
|
343
|
+
</div>
|
|
344
|
+
));
|
|
345
|
+
};
|
|
346
|
+
const renderDaysList = () => {
|
|
347
|
+
const half = (rows - 1) / 2;
|
|
348
|
+
return getDaysList().map((day, i) => (
|
|
349
|
+
<div
|
|
350
|
+
className={`mobile-calendar_wrapper_body_days-list--item ${i === half ? 'active' : ''} ${
|
|
351
|
+
i === 0 || i === rows - 1 ? 'transparent' : ''
|
|
352
|
+
} ${classes?.daysListItem} ${i === half ? classes?.activeItem : ''}`}
|
|
353
|
+
key={`day-${day}`}
|
|
354
|
+
onClick={() => (i - half === 0 ? {} : changeItem('days', i - half))}
|
|
355
|
+
attr-scroll-direction={touchType === 'days' ? scrollDirection : 0}
|
|
356
|
+
attr-is-scrolling={touchType === 'days' ? 1 : 0}
|
|
357
|
+
>
|
|
358
|
+
{day}
|
|
359
|
+
</div>
|
|
360
|
+
));
|
|
361
|
+
};
|
|
362
|
+
const renderYearsList = () => {
|
|
363
|
+
const half = (rows - 1) / 2;
|
|
364
|
+
return getYearsList().map((year, i) => (
|
|
365
|
+
<div
|
|
366
|
+
className={`mobile-calendar_wrapper_body_years-list--item ${i === half ? 'active' : ''} ${
|
|
367
|
+
i === 0 || i === rows - 1 ? 'transparent' : ''
|
|
368
|
+
} ${classes?.yearsListItem} ${i === half ? classes?.activeItem : ''}`}
|
|
369
|
+
key={`year-${year}`}
|
|
370
|
+
onClick={() => (i - half === 0 ? {} : changeItem('years', i - half))}
|
|
371
|
+
attr-scroll-direction={touchType === 'years' ? scrollDirection : 0}
|
|
372
|
+
attr-is-scrolling={touchType === 'years' ? 1 : 0}
|
|
373
|
+
>
|
|
374
|
+
{year}
|
|
375
|
+
</div>
|
|
376
|
+
));
|
|
377
|
+
};
|
|
378
|
+
|
|
379
|
+
const renderMonthsBlock = () => {
|
|
380
|
+
return (
|
|
381
|
+
<div
|
|
382
|
+
className={`mobile-calendar_wrapper_body_months ${classes?.monthsBlock}`}
|
|
383
|
+
>
|
|
384
|
+
<div
|
|
385
|
+
className={`mobile-calendar_wrapper_body_months--prev ${classes?.prevItem}`}
|
|
386
|
+
>
|
|
387
|
+
<ChevronUp
|
|
388
|
+
onClick={() => changeItem('months', -1)}
|
|
389
|
+
onMouseDown={() => onArrowMouseDown('months', -1)}
|
|
390
|
+
onMouseUp={onArrowMouseUp}
|
|
391
|
+
/>
|
|
392
|
+
</div>
|
|
393
|
+
<div
|
|
394
|
+
className={`mobile-calendar_wrapper_body_months-list ${classes?.monthsList}`}
|
|
395
|
+
ref={monthsListRef}
|
|
396
|
+
>
|
|
397
|
+
{renderMonthsList()}
|
|
398
|
+
{isMobile && (
|
|
399
|
+
<div className="mobile-calendar_wrapper_body_months-list_touch-zone"></div>
|
|
400
|
+
)}
|
|
401
|
+
</div>
|
|
402
|
+
<div
|
|
403
|
+
className={`mobile-calendar_wrapper_body_months--next ${classes?.nextItem}`}
|
|
404
|
+
>
|
|
405
|
+
<ChevronDown
|
|
406
|
+
onClick={() => changeItem('months', 1)}
|
|
407
|
+
onMouseDown={() => onArrowMouseDown('months', 1)}
|
|
408
|
+
onMouseUp={onArrowMouseUp}
|
|
409
|
+
/>
|
|
410
|
+
</div>
|
|
411
|
+
</div>
|
|
412
|
+
);
|
|
413
|
+
};
|
|
414
|
+
const renderDaysBlock = () => {
|
|
415
|
+
return (
|
|
416
|
+
<div
|
|
417
|
+
className={`mobile-calendar_wrapper_body_days ${classes?.daysBlock}`}
|
|
418
|
+
>
|
|
419
|
+
<div
|
|
420
|
+
className={`mobile-calendar_wrapper_body_days--prev ${classes?.prevItem}`}
|
|
421
|
+
>
|
|
422
|
+
<ChevronUp
|
|
423
|
+
onClick={() => changeItem('days', -1)}
|
|
424
|
+
onMouseDown={() => onArrowMouseDown('days', -1)}
|
|
425
|
+
onMouseUp={onArrowMouseUp}
|
|
426
|
+
/>
|
|
427
|
+
</div>
|
|
428
|
+
<div
|
|
429
|
+
className={`mobile-calendar_wrapper_body_days-list ${classes?.daysList}`}
|
|
430
|
+
ref={daysListRef}
|
|
431
|
+
>
|
|
432
|
+
{renderDaysList()}
|
|
433
|
+
{isMobile && (
|
|
434
|
+
<div className="mobile-calendar_wrapper_body_days-list_touch-zone"></div>
|
|
435
|
+
)}
|
|
436
|
+
</div>
|
|
437
|
+
<div
|
|
438
|
+
className={`mobile-calendar_wrapper_body_days--next ${classes?.nextItem}`}
|
|
439
|
+
>
|
|
440
|
+
<ChevronDown
|
|
441
|
+
onClick={() => changeItem('days', 1)}
|
|
442
|
+
onMouseDown={() => onArrowMouseDown('days', 1)}
|
|
443
|
+
onMouseUp={onArrowMouseUp}
|
|
444
|
+
/>
|
|
445
|
+
</div>
|
|
446
|
+
</div>
|
|
447
|
+
);
|
|
448
|
+
};
|
|
449
|
+
const renderYearsBlock = () => {
|
|
450
|
+
return (
|
|
451
|
+
<div
|
|
452
|
+
className={`mobile-calendar_wrapper_body_years ${classes?.yearsBlock}`}
|
|
453
|
+
>
|
|
454
|
+
<div
|
|
455
|
+
className={`mobile-calendar_wrapper_body_years--prev ${classes?.prevItem}`}
|
|
456
|
+
>
|
|
457
|
+
<ChevronUp
|
|
458
|
+
onClick={() => changeItem('years', -1)}
|
|
459
|
+
onMouseDown={() => onArrowMouseDown('years', -1)}
|
|
460
|
+
onMouseUp={onArrowMouseUp}
|
|
461
|
+
/>
|
|
462
|
+
</div>
|
|
463
|
+
<div
|
|
464
|
+
className={`mobile-calendar_wrapper_body_years-list ${classes?.yearsList}`}
|
|
465
|
+
ref={yearsListRef}
|
|
466
|
+
>
|
|
467
|
+
{renderYearsList()}
|
|
468
|
+
{isMobile && (
|
|
469
|
+
<div className="mobile-calendar_wrapper_body_years-list_touch-zone"></div>
|
|
470
|
+
)}
|
|
471
|
+
</div>
|
|
472
|
+
<div
|
|
473
|
+
className={`mobile-calendar_wrapper_body_years--next ${classes?.nextItem}`}
|
|
474
|
+
>
|
|
475
|
+
<ChevronDown
|
|
476
|
+
onClick={() => changeItem('years', 1)}
|
|
477
|
+
onMouseDown={() => onArrowMouseDown('years', 1)}
|
|
478
|
+
onMouseUp={onArrowMouseUp}
|
|
479
|
+
/>
|
|
480
|
+
</div>
|
|
481
|
+
</div>
|
|
482
|
+
);
|
|
483
|
+
};
|
|
484
|
+
|
|
485
|
+
return (
|
|
486
|
+
<div
|
|
487
|
+
className={`mobile-calendar_wrapper ${classes?.wrapper}`}
|
|
488
|
+
onTouchMove={onTouchMove}
|
|
489
|
+
>
|
|
490
|
+
<div className={`mobile-calendar_wrapper_label ${classes?.label}`}>
|
|
491
|
+
{label}
|
|
492
|
+
</div>
|
|
493
|
+
{showSelectedDate && (
|
|
494
|
+
<div className={`mobile-calendar_wrapper_label ${classes?.label}`}>
|
|
495
|
+
{moment(date).format('LL')}
|
|
496
|
+
</div>
|
|
497
|
+
)}
|
|
498
|
+
<div className={`mobile-calendar_wrapper_body ${classes?.body}`}>
|
|
499
|
+
{renderMonthsBlock()}
|
|
500
|
+
{renderDaysBlock()}
|
|
501
|
+
{renderYearsBlock()}
|
|
502
|
+
</div>
|
|
503
|
+
</div>
|
|
504
|
+
);
|
|
505
|
+
}
|
|
506
|
+
|
|
507
|
+
export default MobileCalendar;
|