intelicoreact 1.6.22 → 1.6.24
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/Atomic/FormElements/ActionAlert/ActionAlert.js +98 -1
- package/dist/Atomic/FormElements/AdvancedStatus/AdvancedStatus.js +48 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.js +249 -1
- package/dist/Atomic/FormElements/Calendar/Calendar.props.js +4 -1
- package/dist/Atomic/FormElements/CheckboxInput/CheckboxInput.js +65 -1
- package/dist/Atomic/FormElements/CheckboxesLine/CheckboxesLine.js +52 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.js +424 -1
- package/dist/Atomic/FormElements/Datepicker/Datepicker.props.js +4 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.js +173 -1
- package/dist/Atomic/FormElements/Datepicker/components/DatepickerCalendar.props.js +4 -1
- package/dist/Atomic/FormElements/Dropdown/Dropdown.js +735 -1
- package/dist/Atomic/FormElements/Dropdown/components/DropdownLoader.js +20 -1
- package/dist/Atomic/FormElements/DropdownLiveSearch/DropdownLiveSearch.js +529 -1
- package/dist/Atomic/FormElements/FileLoader/FileLoader.js +94 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadZone.js +105 -1
- package/dist/Atomic/FormElements/FileLoader/partial/LoadedContent.js +67 -1
- package/dist/Atomic/FormElements/FileLoaderDescription/FileLoaderDescription.js +247 -1
- package/dist/Atomic/FormElements/FileLoaderLocal/FileLoaderLocal.js +160 -1
- package/dist/Atomic/FormElements/FileLoaderLocalGroup/FileLoaderLocalGroup.js +193 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN.js +135 -1
- package/dist/Atomic/FormElements/FormattedRawSSN/FormattedRawSSN_old.js +116 -1
- package/dist/Atomic/FormElements/Input/Input.js +467 -1
- package/dist/Atomic/FormElements/InputCalendar/InputCalendar.js +161 -1
- package/dist/Atomic/FormElements/InputColor/InputColor.js +64 -1
- package/dist/Atomic/FormElements/InputCurrency/InputCurrency.js +200 -1
- package/dist/Atomic/FormElements/InputDateRange/InputDateRange.js +354 -1
- package/dist/Atomic/FormElements/InputDateRange/components/DateInput.js +71 -1
- package/dist/Atomic/FormElements/InputDateRange/components/Datepicker.js +693 -1
- package/dist/Atomic/FormElements/InputDateRange/components/OpenedPart.js +254 -1
- package/dist/Atomic/FormElements/InputDateRange/components/SelectItem.js +32 -1
- package/dist/Atomic/FormElements/InputDateRange/dependencies.js +200 -1
- package/dist/Atomic/FormElements/InputLink/InputLink.js +99 -1
- package/dist/Atomic/FormElements/InputMask/InputCarretPosition.js +37 -1
- package/dist/Atomic/FormElements/InputMask/InputMask.js +1214 -1
- package/dist/Atomic/FormElements/InputMask/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask2/InputMask2.js +674 -1
- package/dist/Atomic/FormElements/InputMask2/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask2/functions.js +58 -1
- package/dist/Atomic/FormElements/InputMask3/InputMask3.js +766 -1
- package/dist/Atomic/FormElements/InputMask3/config.js +15 -1
- package/dist/Atomic/FormElements/InputMask3/functions.js +58 -1
- package/dist/Atomic/FormElements/InputWithAction/InputWithAction.js +114 -1
- package/dist/Atomic/FormElements/InputsRow/InputsRow.js +140 -1
- package/dist/Atomic/FormElements/Label/Label.js +87 -1
- package/dist/Atomic/FormElements/MobileCalendar/MobileCalendar.js +506 -1
- package/dist/Atomic/FormElements/MultiSelect/MultiSelect.js +45 -1
- package/dist/Atomic/FormElements/NumericInput/NumericInput.js +331 -1
- package/dist/Atomic/FormElements/RadioGroup/RadioGroup.js +66 -1
- package/dist/Atomic/FormElements/RadioGroupWithInput/RadioGroupWithInput.js +80 -1
- package/dist/Atomic/FormElements/RadioInput/RadioInput.js +57 -1
- package/dist/Atomic/FormElements/RadioRowSwitcher/RadioRowSwitcher.js +54 -1
- package/dist/Atomic/FormElements/RangeCalendar/RangeCalendar.js +183 -1
- package/dist/Atomic/FormElements/RangeInputs/RangeInputs.js +222 -1
- package/dist/Atomic/FormElements/RangeList/RangeList.js +175 -1
- package/dist/Atomic/FormElements/RangeList/partial/RangeListRow.js +43 -1
- package/dist/Atomic/FormElements/RangeSlider/RangeSlider.js +443 -1
- package/dist/Atomic/FormElements/RangeSlider2/RangeSlider2.js +858 -1
- package/dist/Atomic/FormElements/SwitchableRow/SwitchableRow.js +39 -1
- package/dist/Atomic/FormElements/Switcher/Switcher.js +59 -1
- package/dist/Atomic/FormElements/SwitcherCheckbox/SwitcherCheckbox.js +50 -1
- package/dist/Atomic/FormElements/SwitcherHide/SwitcherHide.js +44 -1
- package/dist/Atomic/FormElements/SwitcherRadio/SwitcherRadio.js +100 -1
- package/dist/Atomic/FormElements/SwitcherRange/SwitcherRange.js +52 -1
- package/dist/Atomic/FormElements/SwitcherRangeList/SwitcherRangeList.js +64 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/SwitcherTagsDropdown.js +170 -1
- package/dist/Atomic/FormElements/SwitcherTagsDropdown/partial/States.js +202 -1
- package/dist/Atomic/FormElements/SwitcherTextarea/SwitcherTextarea.js +67 -1
- package/dist/Atomic/FormElements/TagListToDropdown/TagListToDropdown.js +115 -1
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.interface.ts +2 -2
- package/dist/Atomic/FormElements/TagsDropdown/TagsDropdown.js +1110 -1
- package/dist/Atomic/FormElements/Text/Text.js +125 -1
- package/dist/Atomic/FormElements/TextSwitcher/TextSwitcher.js +49 -1
- package/dist/Atomic/FormElements/Textarea/Textarea.js +80 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/TieredCheckboxes.js +176 -1
- package/dist/Atomic/FormElements/TieredCheckboxes/partial/AccordionWithCheckbox.js +62 -1
- package/dist/Atomic/FormElements/TimeRange/TimeRange.js +119 -1
- package/dist/Atomic/FormElements/UserContacts/UserContacts.js +188 -1
- package/dist/Atomic/FormElements/VariantsListRadio/VariantsListRadio.js +83 -1
- package/dist/Atomic/FormElements/VariantsListRadio/partials/VariantsListRadioItem.js +82 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/WidgetPseudoTable.js +101 -1
- package/dist/Atomic/FormElements/WidgetPseudoTable/partial/constructor.js +29 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/WidgetWithSwitchableRows.js +113 -1
- package/dist/Atomic/FormElements/WidgetWithSwitchableRows/partial/constructor.js +30 -1
- package/dist/Atomic/Layout/Header/Header.js +85 -1
- package/dist/Atomic/Layout/Spinner/Spinner.js +44 -1
- package/dist/Atomic/UI/Accordion/Accordion.js +108 -1
- package/dist/Atomic/UI/Accordion/AccordionItem.js +176 -1
- package/dist/Atomic/UI/AccordionTable/AccordionTable.js +238 -1
- package/dist/Atomic/UI/AccordionText/AccordionText.js +69 -1
- package/dist/Atomic/UI/AdvancedTag/AdvTag.js +207 -1
- package/dist/Atomic/UI/AdvancedTag/AdvancedTags.js +56 -1
- package/dist/Atomic/UI/Alert/Alert.js +72 -1
- package/dist/Atomic/UI/Arrow/Arrow.js +132 -1
- package/dist/Atomic/UI/Box/Box.js +52 -1
- package/dist/Atomic/UI/Button/Button.js +47 -1
- package/dist/Atomic/UI/ButtonsBar/ButtonsBar.js +72 -1
- package/dist/Atomic/UI/Chart/Chart.js +172 -1
- package/dist/Atomic/UI/Chart/partial/Chart.constants.js +95 -1
- package/dist/Atomic/UI/Chart/partial/ChartTypeSwitcherIcon/ChartTypeSwitcherIcon.js +80 -1
- package/dist/Atomic/UI/Chart/partial/datasetSetters.js +188 -1
- package/dist/Atomic/UI/Chart/partial/optionsConstructor.js +335 -1
- package/dist/Atomic/UI/Chart/partial/optionsSetters.js +43 -1
- package/dist/Atomic/UI/Chart/partial/utils.js +60 -1
- package/dist/Atomic/UI/CircleProgressBar/CircleProgressBar.js +109 -1
- package/dist/Atomic/UI/DateTime/DateTime.js +57 -1
- package/dist/Atomic/UI/DebugContainer/DebugContainer.js +44 -1
- package/dist/Atomic/UI/DebugContainer/useDebugContainer.js +15 -1
- package/dist/Atomic/UI/DoubleString/DoubleString.js +102 -1
- package/dist/Atomic/UI/DynamicIcon/DynamicIcon.js +70 -1
- package/dist/Atomic/UI/ExampleChartIntegration/ExampleChartIntegration.js +221 -1
- package/dist/Atomic/UI/ExampleChartIntegration/partial/utils.js +106 -1
- package/dist/Atomic/UI/Hint/Hint.js +256 -1
- package/dist/Atomic/UI/Hint/partials/_utils.js +64 -1
- package/dist/Atomic/UI/Modal/Modal.js +179 -1
- package/dist/Atomic/UI/Modal/ModalHOC.js +97 -1
- package/dist/Atomic/UI/Modal/partials/ModalFooter.js +71 -1
- package/dist/Atomic/UI/Modal/partials/ModalTitle.js +110 -1
- package/dist/Atomic/UI/Modal/partials/useMobileModal.js +192 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion._test.js +75 -1
- package/dist/Atomic/UI/MonoAccordion/MonoAccordion.js +80 -1
- package/dist/Atomic/UI/NavLine/NavLine.js +317 -1
- package/dist/Atomic/UI/PageTitle/PageTitle.js +77 -1
- package/dist/Atomic/UI/PieChart/PieChart.js +42 -1
- package/dist/Atomic/UI/Price/Price.js +31 -1
- package/dist/Atomic/UI/PriceRange/PriceRange.js +44 -1
- package/dist/Atomic/UI/ProgressLine/ProgressLine.js +98 -1
- package/dist/Atomic/UI/Status/Status.js +67 -1
- package/dist/Atomic/UI/Table/Partials/TdCell.js +87 -1
- package/dist/Atomic/UI/Table/Partials/TdHeader.js +38 -1
- package/dist/Atomic/UI/Table/Partials/TdRow.js +99 -1
- package/dist/Atomic/UI/Table/Partials/TdTitle.js +52 -1
- package/dist/Atomic/UI/Table/Table.js +63 -1
- package/dist/Atomic/UI/Table/TdTypes/TdActions.js +80 -1
- package/dist/Atomic/UI/Table/TdTypes/TdPriority.js +28 -1
- package/dist/Atomic/UI/Table/TdTypes/TdRange.js +13 -1
- package/dist/Atomic/UI/Table/TdTypes/TdWeight.js +53 -1
- package/dist/Atomic/UI/Tag/Tag.js +167 -1
- package/dist/Atomic/UI/TagList/TagList.js +251 -1
- package/dist/Atomic/UI/UserBox/UserBox.js +86 -1
- package/dist/Atomic/UI/WizardStepper/constructor.js +84 -1
- package/dist/Atomic/UI/WizardStepper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/StateIcon.js +37 -1
- package/dist/Atomic/UI/WizardStepper/ui/StateIcon/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/StepRow.js +61 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepRow/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/StepWrapper.js +39 -1
- package/dist/Atomic/UI/WizardStepper/ui/StepWrapper/index.js +3 -1
- package/dist/Atomic/UI/WizardStepper/ui/icons.js +49 -1
- package/dist/Atomic/UI/WizardStepper/ui/index.js +3 -1
- package/dist/Classes/AbortableFetch.js +454 -1
- package/dist/Classes/AnimatedHandler.js +47 -1
- package/dist/Classes/RESTAPI/index.js +228 -1
- package/dist/Classes/RESTAPI/partials/AbortableFetch.js +457 -1
- package/dist/Classes/RESTAPI/partials/ApiBase.js +48 -1
- package/dist/Classes/RESTAPI/partials/ApiRequestCreators.js +112 -1
- package/dist/Classes/RESTAPI/partials/ApiUtils.js +189 -1
- package/dist/Classes/RESTAPI/partials/CredentialsProcessing.js +252 -1
- package/dist/Classes/RESTAPI/partials/Utils.js +92 -1
- package/dist/Classes/RESTAPI/partials/_outerDependencies.js +3 -1
- package/dist/Classes/RESTAPI/partials/_utils.js +197 -1
- package/dist/Constants/index.constants.js +78 -1
- package/dist/Functions/Portal.js +22 -1
- package/dist/Functions/customEventListener.js +96 -1
- package/dist/Functions/dateTime.js +149 -1
- package/dist/Functions/fieldValueFormatters.js +405 -1
- package/dist/Functions/guards/assertions.js +294 -1
- package/dist/Functions/guards/safeValue.js +75 -1
- package/dist/Functions/guards/typeGuards.js +373 -1
- package/dist/Functions/hooks/useFormFieldsChangesManager.js +95 -1
- package/dist/Functions/locale/createTranslator.js +32 -1
- package/dist/Functions/operations.js +130 -1
- package/dist/Functions/presets/inputMaskPresets.js +170 -1
- package/dist/Functions/presets/inputPresets.js +60 -1
- package/dist/Functions/presets/mobileKeyboardTypesPresets.js +45 -1
- package/dist/Functions/schemas.js +31 -1
- package/dist/Functions/useBodyScrollLock.js +17 -1
- package/dist/Functions/useClickOutside.js +15 -1
- package/dist/Functions/useDebounce.js +17 -1
- package/dist/Functions/useFieldFocus.js +84 -1
- package/dist/Functions/useFormTools/form-drivers/ArrayWithObjects.js +39 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithIterableObjects.js +159 -1
- package/dist/Functions/useFormTools/form-drivers/ObjectWithNamedKeyObjects.js +78 -1
- package/dist/Functions/useFormTools/functions/General.js +134 -1
- package/dist/Functions/useFormTools/functions/RenderFields.js +111 -1
- package/dist/Functions/useFormTools/functions/usePrevious.js +12 -1
- package/dist/Functions/useFormTools/index.js +778 -1
- package/dist/Functions/useInputHighlightError.js +67 -1
- package/dist/Functions/useIsMobile/useIsMobile.js +33 -1
- package/dist/Functions/useKeyPress/useHandleKeyPress.js +52 -1
- package/dist/Functions/useKeyPress/useKeyPress.js +52 -1
- package/dist/Functions/useLocalStorage.js +34 -1
- package/dist/Functions/useLocationParams.js +27 -1
- package/dist/Functions/useMediaQuery.js +17 -1
- package/dist/Functions/useMetaInfo.js +43 -1
- package/dist/Functions/useMouseUpOutside.js +16 -1
- package/dist/Functions/useOnlineStatus.js +29 -1
- package/dist/Functions/usePasswordChecker.js +110 -1
- package/dist/Functions/usePrevious.js +12 -1
- package/dist/Functions/useResize.js +31 -1
- package/dist/Functions/useScrollTo.js +17 -1
- package/dist/Functions/useToggle.js +17 -1
- package/dist/Functions/utils.js +522 -1
- package/dist/Langs.js +168 -1
- package/dist/Molecular/CustomIcons/components/AffiliateNetworks.js +21 -1
- package/dist/Molecular/CustomIcons/components/AlertCircle.js +23 -1
- package/dist/Molecular/CustomIcons/components/AppStore.js +29 -1
- package/dist/Molecular/CustomIcons/components/Arrow.js +32 -1
- package/dist/Molecular/CustomIcons/components/ArrowDown.js +17 -1
- package/dist/Molecular/CustomIcons/components/ArrowLeft.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowRight.js +22 -1
- package/dist/Molecular/CustomIcons/components/ArrowUp.js +17 -1
- package/dist/Molecular/CustomIcons/components/Bell.js +15 -1
- package/dist/Molecular/CustomIcons/components/Button.js +12 -1
- package/dist/Molecular/CustomIcons/components/Campaigns.js +16 -1
- package/dist/Molecular/CustomIcons/components/Check.js +14 -1
- package/dist/Molecular/CustomIcons/components/Check2.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDown.js +12 -1
- package/dist/Molecular/CustomIcons/components/ChevronDownDisabled.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronLeft.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronRight.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUp.js +11 -1
- package/dist/Molecular/CustomIcons/components/ChevronUpDown.js +27 -1
- package/dist/Molecular/CustomIcons/components/Close.js +14 -1
- package/dist/Molecular/CustomIcons/components/ColumnsOrder.js +17 -1
- package/dist/Molecular/CustomIcons/components/Delete.js +16 -1
- package/dist/Molecular/CustomIcons/components/Edit.js +15 -1
- package/dist/Molecular/CustomIcons/components/Email.js +31 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo.js +18 -1
- package/dist/Molecular/CustomIcons/components/FinturfLogo2.js +35 -1
- package/dist/Molecular/CustomIcons/components/Flows.js +15 -1
- package/dist/Molecular/CustomIcons/components/Gift.js +25 -1
- package/dist/Molecular/CustomIcons/components/GoogleAuth.js +29 -1
- package/dist/Molecular/CustomIcons/components/GooglePlay.js +29 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle.js +19 -1
- package/dist/Molecular/CustomIcons/components/HelpCircle2.js +20 -1
- package/dist/Molecular/CustomIcons/components/HelpCircleFilled.js +19 -1
- package/dist/Molecular/CustomIcons/components/Home.js +16 -1
- package/dist/Molecular/CustomIcons/components/Home2.js +22 -1
- package/dist/Molecular/CustomIcons/components/Key.js +23 -1
- package/dist/Molecular/CustomIcons/components/Landers.js +20 -1
- package/dist/Molecular/CustomIcons/components/Lock.js +15 -1
- package/dist/Molecular/CustomIcons/components/Mail.js +26 -1
- package/dist/Molecular/CustomIcons/components/Mastercard.js +73 -1
- package/dist/Molecular/CustomIcons/components/Minus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Offers.js +16 -1
- package/dist/Molecular/CustomIcons/components/Pause.js +28 -1
- package/dist/Molecular/CustomIcons/components/PayPal.js +41 -1
- package/dist/Molecular/CustomIcons/components/PayPalLightLarge.js +28 -1
- package/dist/Molecular/CustomIcons/components/Phone.js +30 -1
- package/dist/Molecular/CustomIcons/components/Play.js +25 -1
- package/dist/Molecular/CustomIcons/components/Plus.js +25 -1
- package/dist/Molecular/CustomIcons/components/Profile.js +16 -1
- package/dist/Molecular/CustomIcons/components/QRCode.js +29 -1
- package/dist/Molecular/CustomIcons/components/Rectangle.js +12 -1
- package/dist/Molecular/CustomIcons/components/Revert.js +13 -1
- package/dist/Molecular/CustomIcons/components/Star.js +14 -1
- package/dist/Molecular/CustomIcons/components/Star2.js +16 -1
- package/dist/Molecular/CustomIcons/components/TrafficSources.js +14 -1
- package/dist/Molecular/CustomIcons/components/Trash.js +15 -1
- package/dist/Molecular/CustomIcons/components/TrashRed.js +15 -1
- package/dist/Molecular/CustomIcons/components/Triggers.js +15 -1
- package/dist/Molecular/CustomIcons/components/User.js +25 -1
- package/dist/Molecular/CustomIcons/components/Visa.js +31 -1
- package/dist/Molecular/CustomIcons/components/X.js +12 -1
- package/dist/Molecular/CustomIcons/index.js +61 -1
- package/dist/Molecular/FormElement/FormElement.js +54 -1
- package/dist/Molecular/FormWithDependOn/FormWithDependOn.js +184 -1
- package/dist/Molecular/FormWithDependOn/partials/_utils.js +53 -1
- package/dist/Molecular/InputAddress/InputAddress.js +626 -1
- package/dist/Molecular/InputPassword/InputPassword.js +48 -1
- package/dist/index.js +104 -1
- package/package.json +1 -1
- package/dist/Molecular/InputAddress/InputAddress.d.ts +0 -26
- package/dist/Molecular/InputAddress/InputAddress.js.map +0 -1
|
@@ -1 +1,67 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
import { KEYBOARD_SERVICE_KEYS } from "../Constants/index.constants";
|
|
4
|
+
|
|
5
|
+
export const useInputHighlightError = ({
|
|
6
|
+
value,
|
|
7
|
+
blinkTime,
|
|
8
|
+
isUseErrorsBlink,
|
|
9
|
+
}) => {
|
|
10
|
+
const DEFAULT_BLINK_TIME = 100;
|
|
11
|
+
const [isToHighlightError, setIsToHighlightError] = useState(false);
|
|
12
|
+
const [isAttemptToChange, setIsAttemptToChange] = useState(false);
|
|
13
|
+
const [prevValue, setPreviousValue] = useState(value);
|
|
14
|
+
|
|
15
|
+
function hasHighlightError(e) {
|
|
16
|
+
const changedValue = `${value ?? ""}`;
|
|
17
|
+
const previousValue = `${prevValue ?? ""}`;
|
|
18
|
+
|
|
19
|
+
const short =
|
|
20
|
+
previousValue.length <= changedValue.length
|
|
21
|
+
? previousValue
|
|
22
|
+
: changedValue;
|
|
23
|
+
const long =
|
|
24
|
+
previousValue.length > changedValue.length ? previousValue : changedValue;
|
|
25
|
+
|
|
26
|
+
const infoAboutDifferencesSameness = short.split("").reduce(
|
|
27
|
+
(acc, symbol, idx) => {
|
|
28
|
+
if (acc.countOn && symbol === long[idx]) acc.same.push(symbol);
|
|
29
|
+
else {
|
|
30
|
+
acc.countOn = false;
|
|
31
|
+
acc.differences.push([idx, symbol]);
|
|
32
|
+
}
|
|
33
|
+
return acc;
|
|
34
|
+
},
|
|
35
|
+
{ same: [], countOn: true, differences: [] },
|
|
36
|
+
);
|
|
37
|
+
|
|
38
|
+
const samePart = infoAboutDifferencesSameness.same.join("");
|
|
39
|
+
const differencesLength = infoAboutDifferencesSameness.differences.length;
|
|
40
|
+
const currentSet = changedValue?.replace(samePart, "");
|
|
41
|
+
|
|
42
|
+
if (
|
|
43
|
+
!KEYBOARD_SERVICE_KEYS.includes(e.key) &&
|
|
44
|
+
changedValue === previousValue
|
|
45
|
+
)
|
|
46
|
+
setIsAttemptToChange(!(!differencesLength && e.key === currentSet));
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
useEffect(() => {
|
|
50
|
+
if (isUseErrorsBlink && isAttemptToChange) {
|
|
51
|
+
setIsAttemptToChange(null);
|
|
52
|
+
setIsToHighlightError(true);
|
|
53
|
+
setTimeout(() => {
|
|
54
|
+
setIsToHighlightError(false);
|
|
55
|
+
}, blinkTime || DEFAULT_BLINK_TIME);
|
|
56
|
+
}
|
|
57
|
+
}, [isAttemptToChange]);
|
|
58
|
+
|
|
59
|
+
return {
|
|
60
|
+
isToHighlightError,
|
|
61
|
+
setPreviousValue,
|
|
62
|
+
setIsToHighlightError,
|
|
63
|
+
hasHighlightError,
|
|
64
|
+
};
|
|
65
|
+
};
|
|
66
|
+
|
|
67
|
+
export default useInputHighlightError;
|
|
@@ -1 +1,33 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("react");
|
|
12
|
+
/**
|
|
13
|
+
* Hook to detect if the current device is a mobile device
|
|
14
|
+
* @param props - Configuration options
|
|
15
|
+
* @param props.isWithoutWidthCheck - If true, only checks user agent without width verification
|
|
16
|
+
* @returns Object containing isMobile flag
|
|
17
|
+
*/ function useIsMobile({ isWithoutWidthCheck = false } = {}) {
|
|
18
|
+
const getIsMobile = ()=>{
|
|
19
|
+
return /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent);
|
|
20
|
+
};
|
|
21
|
+
const [isMobile, setIsMobile] = (0, _react.useState)(getIsMobile());
|
|
22
|
+
(0, _react.useEffect)(()=>{
|
|
23
|
+
if (getIsMobile()) {
|
|
24
|
+
setIsMobile(true);
|
|
25
|
+
}
|
|
26
|
+
}, [
|
|
27
|
+
navigator.userAgent
|
|
28
|
+
]);
|
|
29
|
+
return {
|
|
30
|
+
isMobile: isMobile && (isWithoutWidthCheck || window.screen.width <= 768)
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
const _default = useIsMobile;
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("react");
|
|
12
|
+
const _useKeyPress = /*#__PURE__*/ _interop_require_default(require("./useKeyPress"));
|
|
13
|
+
function _interop_require_default(obj) {
|
|
14
|
+
return obj && obj.__esModule ? obj : {
|
|
15
|
+
default: obj
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* A hook that handles Enter and Escape key press events
|
|
20
|
+
*
|
|
21
|
+
* @param props - Configuration object for key press handling
|
|
22
|
+
* @param props.escCallback - Function to be called when Escape key is pressed
|
|
23
|
+
* @param props.enterCallback - Function to be called when Enter key is pressed
|
|
24
|
+
* @param props.withClamping - Whether to allow key repeat events (default: true)
|
|
25
|
+
*
|
|
26
|
+
* @example
|
|
27
|
+
* ```tsx
|
|
28
|
+
* function Component() {
|
|
29
|
+
* useHandleKeyPress({
|
|
30
|
+
* escCallback: () => console.log('Esc pressed'),
|
|
31
|
+
* enterCallback: () => console.log('Enter pressed'),
|
|
32
|
+
* });
|
|
33
|
+
* }
|
|
34
|
+
* ```
|
|
35
|
+
*/ function useHandleKeyPress({ escCallback, enterCallback, withClamping = true }) {
|
|
36
|
+
const isPressEnter = (0, _useKeyPress.default)('Enter', withClamping);
|
|
37
|
+
const isPressEscape = (0, _useKeyPress.default)('Escape', withClamping);
|
|
38
|
+
(0, _react.useEffect)(()=>{
|
|
39
|
+
if (isPressEnter && typeof enterCallback === 'function') {
|
|
40
|
+
enterCallback();
|
|
41
|
+
}
|
|
42
|
+
if (isPressEscape && typeof escCallback === 'function') {
|
|
43
|
+
escCallback();
|
|
44
|
+
}
|
|
45
|
+
}, [
|
|
46
|
+
enterCallback,
|
|
47
|
+
escCallback,
|
|
48
|
+
isPressEnter,
|
|
49
|
+
isPressEscape
|
|
50
|
+
]);
|
|
51
|
+
}
|
|
52
|
+
const _default = useHandleKeyPress;
|
|
@@ -1 +1,52 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", {
|
|
3
|
+
value: true
|
|
4
|
+
});
|
|
5
|
+
Object.defineProperty(exports, "default", {
|
|
6
|
+
enumerable: true,
|
|
7
|
+
get: function() {
|
|
8
|
+
return _default;
|
|
9
|
+
}
|
|
10
|
+
});
|
|
11
|
+
const _react = require("react");
|
|
12
|
+
/**
|
|
13
|
+
* A hook that detects when a specific key is pressed
|
|
14
|
+
* @param targetKey - The key to listen for
|
|
15
|
+
* @param clamping - Whether to allow key repeat events
|
|
16
|
+
* @returns boolean indicating if the target key is currently pressed
|
|
17
|
+
*/ function useKeyPress(targetKey, clamping = true) {
|
|
18
|
+
const [keyPressed, setKeyPressed] = (0, _react.useState)(false);
|
|
19
|
+
const downHandler = (0, _react.useCallback)(({ key, repeat })=>{
|
|
20
|
+
if (key === targetKey) {
|
|
21
|
+
if (!clamping && repeat) return;
|
|
22
|
+
setKeyPressed(true);
|
|
23
|
+
}
|
|
24
|
+
}, [
|
|
25
|
+
clamping,
|
|
26
|
+
targetKey
|
|
27
|
+
]);
|
|
28
|
+
const upHandler = (0, _react.useCallback)(({ key, repeat })=>{
|
|
29
|
+
if (key === targetKey) {
|
|
30
|
+
if (!clamping && repeat) return;
|
|
31
|
+
setKeyPressed(false);
|
|
32
|
+
}
|
|
33
|
+
}, [
|
|
34
|
+
clamping,
|
|
35
|
+
targetKey
|
|
36
|
+
]);
|
|
37
|
+
(0, _react.useEffect)(()=>{
|
|
38
|
+
const handleDown = (event)=>downHandler(event);
|
|
39
|
+
const handleUp = (event)=>upHandler(event);
|
|
40
|
+
window.addEventListener('keydown', handleDown);
|
|
41
|
+
window.addEventListener('keyup', handleUp);
|
|
42
|
+
return ()=>{
|
|
43
|
+
window.removeEventListener('keydown', handleDown);
|
|
44
|
+
window.removeEventListener('keyup', handleUp);
|
|
45
|
+
};
|
|
46
|
+
}, [
|
|
47
|
+
downHandler,
|
|
48
|
+
upHandler
|
|
49
|
+
]);
|
|
50
|
+
return keyPressed;
|
|
51
|
+
}
|
|
52
|
+
const _default = useKeyPress;
|
|
@@ -1 +1,34 @@
|
|
|
1
|
-
|
|
1
|
+
import { useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useLocalStorage = (key, initialValue) => {
|
|
4
|
+
const [storedValue, setStoredValue] = useState(() => {
|
|
5
|
+
if (typeof window === "undefined") {
|
|
6
|
+
return initialValue;
|
|
7
|
+
}
|
|
8
|
+
try {
|
|
9
|
+
const item = window.localStorage.getItem(key);
|
|
10
|
+
return item ? JSON.parse(item) : initialValue;
|
|
11
|
+
} catch (error) {
|
|
12
|
+
// eslint-disable-next-line no-console
|
|
13
|
+
console.log(error);
|
|
14
|
+
return initialValue;
|
|
15
|
+
}
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
const setValue = (value) => {
|
|
19
|
+
try {
|
|
20
|
+
const valueToStore =
|
|
21
|
+
value instanceof Function ? value(storedValue) : value;
|
|
22
|
+
setStoredValue(valueToStore);
|
|
23
|
+
if (typeof window !== "undefined") {
|
|
24
|
+
window.localStorage.setItem(key, JSON.stringify(valueToStore));
|
|
25
|
+
}
|
|
26
|
+
} catch (error) {
|
|
27
|
+
// eslint-disable-next-line no-console
|
|
28
|
+
console.log(error);
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
return [storedValue, setValue];
|
|
33
|
+
};
|
|
34
|
+
export default useLocalStorage;
|
|
@@ -1 +1,27 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export default function useLocationParams() {
|
|
4
|
+
const [params, setParams] = useState({});
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
setParams((state) => {
|
|
8
|
+
const arr = window.location.search?.replace("?", "").split("&");
|
|
9
|
+
|
|
10
|
+
return {
|
|
11
|
+
...state,
|
|
12
|
+
...arr.reduce((obj, item) => {
|
|
13
|
+
const keyVal = item.split("=");
|
|
14
|
+
const key = keyVal[0];
|
|
15
|
+
const value = keyVal[1];
|
|
16
|
+
|
|
17
|
+
return {
|
|
18
|
+
...obj,
|
|
19
|
+
[key]: value,
|
|
20
|
+
};
|
|
21
|
+
}, {}),
|
|
22
|
+
};
|
|
23
|
+
});
|
|
24
|
+
}, [window.location.search]);
|
|
25
|
+
|
|
26
|
+
return params;
|
|
27
|
+
}
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{useSyncExternalStore
|
|
1
|
+
import { useSyncExternalStore } from "react";
|
|
2
|
+
|
|
3
|
+
function subscribe(callback) {
|
|
4
|
+
const observer = new ResizeObserver(() => callback());
|
|
5
|
+
observer.observe(document.documentElement);
|
|
6
|
+
return () => observer.disconnect();
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const useMediaQuery = (query) => {
|
|
10
|
+
return useSyncExternalStore(
|
|
11
|
+
subscribe,
|
|
12
|
+
() => window.matchMedia(query).matches,
|
|
13
|
+
() => false,
|
|
14
|
+
);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default useMediaQuery;
|
|
@@ -1 +1,43 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useMetaInfo = () => {
|
|
4
|
+
const [browser, setBrowser] = useState("Other");
|
|
5
|
+
const [device, setDevice] = useState("desktop");
|
|
6
|
+
const [isiOS, setIsiOS] = useState(false);
|
|
7
|
+
const [chromeVersion, setChromeVersion] = useState(null);
|
|
8
|
+
const [iOSVersion, setiOSVersion] = useState(null);
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
const userAgent = navigator.userAgent;
|
|
12
|
+
|
|
13
|
+
if (userAgent.indexOf("Chrome") !== -1) {
|
|
14
|
+
setBrowser("Chrome");
|
|
15
|
+
|
|
16
|
+
// Извлечение версии Chrome
|
|
17
|
+
const version = userAgent.match(/Chrom(e|ium)\/([0-9\.]+)/)[2];
|
|
18
|
+
setChromeVersion(version);
|
|
19
|
+
} else if (userAgent.indexOf("Safari") !== -1) setBrowser("Safari");
|
|
20
|
+
|
|
21
|
+
const iOSV = (
|
|
22
|
+
(userAgent.match(/(CPU|iPhone).*OS (\d+_?\d*)|CPU like Mac OS X/i) ||
|
|
23
|
+
[])[2] || "0"
|
|
24
|
+
).replace("_", ".");
|
|
25
|
+
const iOSVersion = parseFloat(iOSV);
|
|
26
|
+
|
|
27
|
+
setIsiOS(!isNaN(iOSVersion));
|
|
28
|
+
if (!isNaN(iOSVersion)) {
|
|
29
|
+
setiOSVersion(iOSV); // Записываем версию iOS
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if (
|
|
33
|
+
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(
|
|
34
|
+
userAgent,
|
|
35
|
+
)
|
|
36
|
+
)
|
|
37
|
+
setDevice("mobile");
|
|
38
|
+
}, []);
|
|
39
|
+
|
|
40
|
+
return { browser, device, isiOS, chromeVersion, iOSVersion }; // Возврат версий Chrome и iOS
|
|
41
|
+
};
|
|
42
|
+
|
|
43
|
+
export default useMetaInfo;
|
|
@@ -1 +1,16 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export default function useMouseUpOutside(ref, setOut, open) {
|
|
4
|
+
function handleMouseUpOutside(event) {
|
|
5
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
6
|
+
setOut(open);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
useEffect(() => {
|
|
11
|
+
document.addEventListener("mouseup", handleMouseUpOutside);
|
|
12
|
+
return () => {
|
|
13
|
+
document.removeEventListener("mouseup", handleMouseUpOutside);
|
|
14
|
+
};
|
|
15
|
+
}, [ref]);
|
|
16
|
+
}
|
|
@@ -1 +1,29 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useOnlineStatus = () => {
|
|
4
|
+
function getOnlineStatus() {
|
|
5
|
+
return typeof navigator !== "undefined" &&
|
|
6
|
+
typeof navigator.onLine === "boolean"
|
|
7
|
+
? navigator.onLine
|
|
8
|
+
: true;
|
|
9
|
+
}
|
|
10
|
+
const [onlineStatus, setOnlineStatus] = useState(getOnlineStatus());
|
|
11
|
+
|
|
12
|
+
const goOnline = () => setOnlineStatus(true);
|
|
13
|
+
|
|
14
|
+
const goOffline = () => setOnlineStatus(false);
|
|
15
|
+
|
|
16
|
+
useEffect(() => {
|
|
17
|
+
window.addEventListener("online", goOnline);
|
|
18
|
+
window.addEventListener("offline", goOffline);
|
|
19
|
+
|
|
20
|
+
return () => {
|
|
21
|
+
window.removeEventListener("online", goOnline);
|
|
22
|
+
window.removeEventListener("offline", goOffline);
|
|
23
|
+
};
|
|
24
|
+
}, []);
|
|
25
|
+
|
|
26
|
+
return onlineStatus;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default useOnlineStatus;
|
|
@@ -1 +1,110 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
|
|
3
|
+
import cn from "classnames";
|
|
4
|
+
|
|
5
|
+
export default function usePasswordChecker({ label = "Password must:" } = {}) {
|
|
6
|
+
const [checkRules, setCheckRules] = useState([]);
|
|
7
|
+
const addCheckRule = (data) => setCheckRules((state) => [...state, data]);
|
|
8
|
+
const handleCheckRule = (type, props = {}, value = "") => {
|
|
9
|
+
const { min, max } = props;
|
|
10
|
+
|
|
11
|
+
switch (type) {
|
|
12
|
+
case "len":
|
|
13
|
+
if (min && value.length < min) return false;
|
|
14
|
+
if (max && value.length > max) return false;
|
|
15
|
+
return true;
|
|
16
|
+
|
|
17
|
+
case "lowerCaseContains": {
|
|
18
|
+
const toUpperCase = value.slice().toUpperCase().split("");
|
|
19
|
+
const original = value.slice().split("");
|
|
20
|
+
|
|
21
|
+
return original.reduce((isMatch, char, i) => {
|
|
22
|
+
if (char !== toUpperCase[i]) isMatch = true;
|
|
23
|
+
|
|
24
|
+
return isMatch;
|
|
25
|
+
}, false);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
case "upperCaseContains": {
|
|
29
|
+
const toLowerCase = value.slice().toLowerCase().split("");
|
|
30
|
+
const original = value.slice().split("");
|
|
31
|
+
|
|
32
|
+
return original.reduce((isMatch, char, i) => {
|
|
33
|
+
if (char !== toLowerCase[i]) isMatch = true;
|
|
34
|
+
|
|
35
|
+
return isMatch;
|
|
36
|
+
}, false);
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
case "numberContains": {
|
|
40
|
+
const original = value.slice().split("");
|
|
41
|
+
return original.reduce((isMatch, char) => {
|
|
42
|
+
if (Number.isInteger(parseInt(char, 10))) isMatch = true;
|
|
43
|
+
|
|
44
|
+
return isMatch;
|
|
45
|
+
}, false);
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
case "specialContains": {
|
|
49
|
+
const original = value.slice().split("");
|
|
50
|
+
return original.reduce((isMatch, char) => {
|
|
51
|
+
if (!Number.isInteger(parseInt(char, 10)) && !char.match(/[a-z]/i))
|
|
52
|
+
isMatch = true;
|
|
53
|
+
|
|
54
|
+
return isMatch;
|
|
55
|
+
}, false);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
default:
|
|
59
|
+
return false;
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
const testCheckRules = (value) => {
|
|
63
|
+
let result = true;
|
|
64
|
+
|
|
65
|
+
setCheckRules((state) => {
|
|
66
|
+
const rules = [...state];
|
|
67
|
+
return rules.map((rule) => {
|
|
68
|
+
const isMatch = handleCheckRule(rule.type, rule.props, value);
|
|
69
|
+
if (!isMatch) result = false;
|
|
70
|
+
|
|
71
|
+
return { ...rule, isMatch };
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
|
|
75
|
+
return result;
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
const renderPasswordChecker = () => {
|
|
79
|
+
return (
|
|
80
|
+
<div className="password-checker">
|
|
81
|
+
<div className="password-checker__header">
|
|
82
|
+
<label className="password-checker__header-label"> {label} </label>{" "}
|
|
83
|
+
</div>{" "}
|
|
84
|
+
<div className="password-checker__body">
|
|
85
|
+
{" "}
|
|
86
|
+
{checkRules.map(({ icon, text, isMatch, key }) => (
|
|
87
|
+
<div
|
|
88
|
+
key={key}
|
|
89
|
+
className={cn("password-checker__body-item", {
|
|
90
|
+
"password-checker__body-item--match":
|
|
91
|
+
isMatch && isMatch !== null,
|
|
92
|
+
"password-checker__body-item--dont-match":
|
|
93
|
+
!isMatch && isMatch !== null,
|
|
94
|
+
})}
|
|
95
|
+
>
|
|
96
|
+
<div className="password-checker__body-item__icon"> {icon} </div>{" "}
|
|
97
|
+
<div className="password-checker__body-item__text"> {text} </div>{" "}
|
|
98
|
+
</div>
|
|
99
|
+
))}{" "}
|
|
100
|
+
</div>{" "}
|
|
101
|
+
</div>
|
|
102
|
+
);
|
|
103
|
+
};
|
|
104
|
+
|
|
105
|
+
return {
|
|
106
|
+
addCheckRule,
|
|
107
|
+
testCheckRules,
|
|
108
|
+
renderPasswordChecker,
|
|
109
|
+
};
|
|
110
|
+
}
|
|
@@ -1 +1,12 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect, useRef } from "react";
|
|
2
|
+
|
|
3
|
+
function usePrevious(value) {
|
|
4
|
+
const ref = useRef();
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
ref.current = value;
|
|
8
|
+
}, [value]);
|
|
9
|
+
return ref.current;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export default usePrevious;
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useLayoutEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useResize = (element = null) => {
|
|
4
|
+
const [elemPosition, setElemPosition] = useState("");
|
|
5
|
+
|
|
6
|
+
const onResize = (elemRightPosition) => {
|
|
7
|
+
if (elemRightPosition > document.documentElement.clientWidth) {
|
|
8
|
+
return setElemPosition("left");
|
|
9
|
+
} else setElemPosition("");
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
useEffect(() => {
|
|
13
|
+
const elemRightPosition =
|
|
14
|
+
element?.current?.getBoundingClientRect().right + 20;
|
|
15
|
+
window.addEventListener("resize", () => onResize(elemRightPosition));
|
|
16
|
+
|
|
17
|
+
return () => {
|
|
18
|
+
window.removeEventListener("resize", () => setElemPosition(""));
|
|
19
|
+
};
|
|
20
|
+
}, []);
|
|
21
|
+
|
|
22
|
+
useLayoutEffect(() => {
|
|
23
|
+
const elemRightPosition =
|
|
24
|
+
element?.current?.getBoundingClientRect().right + 20;
|
|
25
|
+
if (elemRightPosition > document.documentElement.clientWidth) {
|
|
26
|
+
return setElemPosition("left");
|
|
27
|
+
}
|
|
28
|
+
}, []);
|
|
29
|
+
|
|
30
|
+
return { elemPosition };
|
|
31
|
+
};
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { useEffect, useRef, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useScrollTo = (reference) => {
|
|
4
|
+
const ref = useRef(reference);
|
|
5
|
+
const [shouldScrollTo, setShouldScrollTo] = useState(false);
|
|
6
|
+
|
|
7
|
+
useEffect(() => {
|
|
8
|
+
if (ref?.current && shouldScrollTo) {
|
|
9
|
+
ref?.current?.scrollIntoView?.({ behavior: "smooth" });
|
|
10
|
+
setShouldScrollTo(false);
|
|
11
|
+
}
|
|
12
|
+
}, [shouldScrollTo]);
|
|
13
|
+
|
|
14
|
+
return [ref, setShouldScrollTo];
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default useScrollTo;
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import { useCallback, useState } from "react";
|
|
2
|
+
|
|
3
|
+
const useToggle = (initialState) => {
|
|
4
|
+
const [isToggled, setToggle] = useState(Boolean(initialState));
|
|
5
|
+
const toggle = useCallback(() => setToggle((isOn) => !isOn), []);
|
|
6
|
+
const toggleOn = useCallback(() => setToggle(true), []);
|
|
7
|
+
const toggleOff = useCallback(() => setToggle(false), []);
|
|
8
|
+
|
|
9
|
+
return {
|
|
10
|
+
isToggled,
|
|
11
|
+
toggle,
|
|
12
|
+
toggleOn,
|
|
13
|
+
toggleOff,
|
|
14
|
+
};
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default useToggle;
|