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,170 @@
|
|
|
1
|
-
|
|
1
|
+
/**
|
|
2
|
+
* @param type: 'inputMask',
|
|
3
|
+
* @param maskPattern: 'DD.DD.DDDD',
|
|
4
|
+
* @param maskPatternPlaceholder: 'MM.DD.YYYY',
|
|
5
|
+
* @param usePatternPlaceholder: true,
|
|
6
|
+
* @param isNumericMobileKeyboard: true,
|
|
7
|
+
* @param blinkErrors: true,
|
|
8
|
+
* @param showErrors: false,
|
|
9
|
+
* @param autocomplete: 'bday',
|
|
10
|
+
* @param focusSelector: 'input',
|
|
11
|
+
*/
|
|
12
|
+
const DATE_PRESET = {
|
|
13
|
+
type: "inputMask",
|
|
14
|
+
maskPattern: "DD.DD.DDDD",
|
|
15
|
+
maskPatternPlaceholder: "MM.DD.YYYY",
|
|
16
|
+
usePatternPlaceholder: true,
|
|
17
|
+
isNumericMobileKeyboard: true,
|
|
18
|
+
blinkErrors: true,
|
|
19
|
+
showErrors: false,
|
|
20
|
+
autocomplete: "bday",
|
|
21
|
+
focusSelector: "input",
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* @param type: 'inputMask',
|
|
26
|
+
* @param maskPattern: 'DDDDD',
|
|
27
|
+
* @param maskPlaceholder: 'X',
|
|
28
|
+
* @param isNumericMobileKeyboard: true,
|
|
29
|
+
* @param blinkErrors: true,
|
|
30
|
+
* @param showErrors: false,
|
|
31
|
+
* @param focusSelector: 'input',
|
|
32
|
+
* @param autocomplete: 'postal-code',
|
|
33
|
+
* @param rules: 'fieldZip'
|
|
34
|
+
*/
|
|
35
|
+
const ZIP_PRESET = {
|
|
36
|
+
type: "inputMask",
|
|
37
|
+
focusSelector: "input",
|
|
38
|
+
maskPattern: "DDDDD",
|
|
39
|
+
maskPlaceholder: "X",
|
|
40
|
+
isNumericMobileKeyboard: true,
|
|
41
|
+
blinkErrors: true,
|
|
42
|
+
showErrors: false,
|
|
43
|
+
autocomplete: "postal-code",
|
|
44
|
+
rules: "fieldZip",
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
/**
|
|
48
|
+
* @param type: 'inputMask',
|
|
49
|
+
* @param maskPattern: 'DDDDDDDDD',
|
|
50
|
+
* @param maskPlaceholder: 'X',
|
|
51
|
+
* @param isNumericMobileKeyboard: true,
|
|
52
|
+
* @param blinkErrors: true,
|
|
53
|
+
* @param showErrors: false,
|
|
54
|
+
* @param focusSelector: 'input',
|
|
55
|
+
*/
|
|
56
|
+
const SSN_PRESET = {
|
|
57
|
+
type: "inputMask",
|
|
58
|
+
maskPattern: "DDDDDDDDD",
|
|
59
|
+
maskPlaceholder: "X",
|
|
60
|
+
focusSelector: "input",
|
|
61
|
+
isNumericMobileKeyboard: true,
|
|
62
|
+
blinkErrors: true,
|
|
63
|
+
showErrors: false,
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/**
|
|
67
|
+
* @param type: 'inputMask',
|
|
68
|
+
* @param maskPattern: 'DDD-DDD-DDDD',
|
|
69
|
+
* @param maskPlaceholder: 'X',
|
|
70
|
+
* @param isNumericMobileKeyboard: true,
|
|
71
|
+
* @param blinkErrors: true,
|
|
72
|
+
* @param showErrors: false,
|
|
73
|
+
* @param focusSelector: 'input',
|
|
74
|
+
* @param autocomplete: 'tel-national',
|
|
75
|
+
*/
|
|
76
|
+
const MOBILE_PHONE_PRESET = {
|
|
77
|
+
type: "inputMask",
|
|
78
|
+
// maskPattern: 'DDD-DDD-DDDD',
|
|
79
|
+
maskPattern: "(DDD) DDD-DDDD",
|
|
80
|
+
maskPlaceholder: "X",
|
|
81
|
+
focusSelector: "input",
|
|
82
|
+
isNumericMobileKeyboard: true,
|
|
83
|
+
blinkErrors: true,
|
|
84
|
+
showErrors: false,
|
|
85
|
+
autocomplete: "tel-national",
|
|
86
|
+
};
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* @param type: 'inputMask3',
|
|
90
|
+
* @param maskPattern: 'DDDD',
|
|
91
|
+
* @param maskPlaceholder: 'X',
|
|
92
|
+
* @param isNumericMobileKeyboard: true,
|
|
93
|
+
* @param blinkErrors: true,
|
|
94
|
+
* @param showErrors: false,
|
|
95
|
+
*/
|
|
96
|
+
const SHORT_SSN_PRESET = {
|
|
97
|
+
type: "inputMask3",
|
|
98
|
+
maskPattern: "DDDD",
|
|
99
|
+
maskPlaceholder: "X",
|
|
100
|
+
focusSelector: "input",
|
|
101
|
+
isNumericMobileKeyboard: true,
|
|
102
|
+
blinkErrors: true,
|
|
103
|
+
showErrors: false,
|
|
104
|
+
};
|
|
105
|
+
|
|
106
|
+
/**
|
|
107
|
+
* @param type: 'inputMask',
|
|
108
|
+
* @param maskPattern: 'DDDDDDDDD',
|
|
109
|
+
* @param maskPlaceholder: 'X',
|
|
110
|
+
* @param isNumericMobileKeyboard: true,
|
|
111
|
+
* @param blinkErrors: true,
|
|
112
|
+
* @param showErrors: false,
|
|
113
|
+
*/
|
|
114
|
+
const ABA_PRESET = {
|
|
115
|
+
type: "inputMask",
|
|
116
|
+
maskPattern: "DDDDDDDDD",
|
|
117
|
+
maskPlaceholder: "X",
|
|
118
|
+
isNumericMobileKeyboard: true,
|
|
119
|
+
blinkErrors: true,
|
|
120
|
+
showErrors: false,
|
|
121
|
+
};
|
|
122
|
+
|
|
123
|
+
/**
|
|
124
|
+
* @param type: 'inputMask',
|
|
125
|
+
* @param maskPattern: 'MM/YY',
|
|
126
|
+
* @param maskPatternPlaceholder: 'MM/YY',
|
|
127
|
+
* @param usePatternPlaceholder: true,
|
|
128
|
+
* @param isNumericMobileKeyboard: true,
|
|
129
|
+
* @param blinkErrors: true,
|
|
130
|
+
* @param showErrors: false,
|
|
131
|
+
* @param focusSelector: 'input',
|
|
132
|
+
*/
|
|
133
|
+
const CC_EXPIRATION_DATE = {
|
|
134
|
+
type: "inputMask",
|
|
135
|
+
maskPattern: "MM/YY",
|
|
136
|
+
maskPatternPlaceholder: "MM/YY",
|
|
137
|
+
usePatternPlaceholder: true,
|
|
138
|
+
isNumericMobileKeyboard: true,
|
|
139
|
+
blinkErrors: true,
|
|
140
|
+
showErrors: false,
|
|
141
|
+
focusSelector: "input",
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
/**
|
|
145
|
+
* @param type: 'inputMask',
|
|
146
|
+
* @param maskPattern: 'DDDDDDDDDD',
|
|
147
|
+
* @param maskPlaceholder: 'X',
|
|
148
|
+
* @param isNumericMobileKeyboard: true,
|
|
149
|
+
* @param blinkErrors: true,
|
|
150
|
+
* @param showErrors: false,
|
|
151
|
+
*/
|
|
152
|
+
const BANK_ACCOUNT = {
|
|
153
|
+
type: "inputMask",
|
|
154
|
+
maskPattern: "DDDDDDDDDD",
|
|
155
|
+
maskPlaceholder: "X",
|
|
156
|
+
isNumericMobileKeyboard: true,
|
|
157
|
+
blinkErrors: true,
|
|
158
|
+
showErrors: false,
|
|
159
|
+
};
|
|
160
|
+
|
|
161
|
+
export const MASK_PRESETS = {
|
|
162
|
+
BANK_ACCOUNT,
|
|
163
|
+
CC_EXPIRATION_DATE,
|
|
164
|
+
DATE_PRESET,
|
|
165
|
+
ZIP_PRESET,
|
|
166
|
+
SSN_PRESET,
|
|
167
|
+
MOBILE_PHONE_PRESET,
|
|
168
|
+
SHORT_SSN_PRESET,
|
|
169
|
+
ABA_PRESET,
|
|
170
|
+
};
|
|
@@ -1 +1,60 @@
|
|
|
1
|
-
import{getSafelyValue
|
|
1
|
+
import { getSafelyValue } from "../fieldValueFormatters";
|
|
2
|
+
|
|
3
|
+
export const NAME_SYMBOLS_EXCLUDER = {
|
|
4
|
+
/**
|
|
5
|
+
* @name fieldChangesMiddleware
|
|
6
|
+
* @description Обрабатывает входящую строку, удаляет все символы, которые не являются
|
|
7
|
+
* алфавитными, дефисами, апострофами или пробелами. Не дает ввести дубли символов дефиса или апострофа.
|
|
8
|
+
* Режет спецсимволы, если после них не идет буква.
|
|
9
|
+
*
|
|
10
|
+
* @param {string} value - Входная строка для обработки.
|
|
11
|
+
* @returns {string} - Обработанная строка.
|
|
12
|
+
*/
|
|
13
|
+
fieldChangesMiddleware: (value) => {
|
|
14
|
+
// remove invalid characters
|
|
15
|
+
const invalidCharacters = new RegExp(/[^a-zA-Z-\s']/g);
|
|
16
|
+
// handle any two '-' or ''' should not be side by side
|
|
17
|
+
const sideBySideHyphenOrApostrophe = new RegExp(/['-]{2,}/g);
|
|
18
|
+
// replace sequence of spaces with single space
|
|
19
|
+
const multipleSpaces = new RegExp(/\s{2,}/g);
|
|
20
|
+
// remove '-' or ''' if they are followed by a space
|
|
21
|
+
const beforeSpace = new RegExp(/['-](?=\s)/g);
|
|
22
|
+
|
|
23
|
+
const sanitizedValue = getSafelyValue(value)
|
|
24
|
+
.replace(invalidCharacters, "")
|
|
25
|
+
.replace(sideBySideHyphenOrApostrophe, "")
|
|
26
|
+
.replace(multipleSpaces, " ")
|
|
27
|
+
.replace(beforeSpace, "");
|
|
28
|
+
|
|
29
|
+
return sanitizedValue;
|
|
30
|
+
},
|
|
31
|
+
blurTrim: {
|
|
32
|
+
trimStart: true,
|
|
33
|
+
trimEnd: true,
|
|
34
|
+
characters: ["-", "'", " "],
|
|
35
|
+
},
|
|
36
|
+
};
|
|
37
|
+
|
|
38
|
+
export const ONLY_STRING_AND_DASH = {
|
|
39
|
+
/**
|
|
40
|
+
* @name fieldChangesMiddleware
|
|
41
|
+
* @description Обрабатывает входную строку, удаляет все неалфавитные символы, заменяет двойные дефисы на одинарные
|
|
42
|
+
* и удаляет все дефисы в начале или конце строки.
|
|
43
|
+
* @param {string} value - входная строка для обработки
|
|
44
|
+
* @returns {string} обработанная строка
|
|
45
|
+
*/
|
|
46
|
+
fieldChangesMiddleware: (value) => {
|
|
47
|
+
const nonAlphabeticAndNotSingleDash = new RegExp(/[^a-zA-Z-]|--/gi);
|
|
48
|
+
const consecutiveDashes = new RegExp(/-+/g);
|
|
49
|
+
|
|
50
|
+
const sanitizedInput = getSafelyValue(value);
|
|
51
|
+
|
|
52
|
+
return sanitizedInput
|
|
53
|
+
.replace(nonAlphabeticAndNotSingleDash, "")
|
|
54
|
+
.replace(consecutiveDashes, "-");
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
export const INPUT_PRESETS = {
|
|
58
|
+
NAME_SYMBOLS_EXCLUDER,
|
|
59
|
+
ONLY_STRING_AND_DASH,
|
|
60
|
+
};
|
|
@@ -1 +1,45 @@
|
|
|
1
|
-
|
|
1
|
+
//? Удобно использовать для расширения объекта атрибутов
|
|
2
|
+
export const ALL_KEYBOARD_TYPES = {
|
|
3
|
+
numeric: { inputMode: "decimal" },
|
|
4
|
+
email: { inputMode: "email" },
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
//? Например:
|
|
8
|
+
/*
|
|
9
|
+
const constructor = [
|
|
10
|
+
...
|
|
11
|
+
{
|
|
12
|
+
key: 'someField',
|
|
13
|
+
...
|
|
14
|
+
attributesOfNativeInput: {
|
|
15
|
+
'data-testId': `someFieldTestId-${someId}`,
|
|
16
|
+
...ALL_KEYBOARD_TYPES.numeric
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
...
|
|
20
|
+
];
|
|
21
|
+
|
|
22
|
+
*/
|
|
23
|
+
|
|
24
|
+
// *****************************
|
|
25
|
+
//? Удобно использовать для расширения объекта филда, если в филде более не добавляются другие атрибуты
|
|
26
|
+
//? Например:
|
|
27
|
+
/*
|
|
28
|
+
const constructor = [
|
|
29
|
+
...
|
|
30
|
+
{
|
|
31
|
+
key: 'someField',
|
|
32
|
+
...NUMERIC_KEYBOARD
|
|
33
|
+
...
|
|
34
|
+
}
|
|
35
|
+
...
|
|
36
|
+
];
|
|
37
|
+
|
|
38
|
+
*/
|
|
39
|
+
|
|
40
|
+
export const NUMERIC_KEYBOARD = {
|
|
41
|
+
attributesOfNativeInput: ALL_KEYBOARD_TYPES.numeric,
|
|
42
|
+
};
|
|
43
|
+
export const EMAIL_KEYBOARD = {
|
|
44
|
+
attributesOfNativeInput: ALL_KEYBOARD_TYPES.email,
|
|
45
|
+
};
|
|
@@ -1 +1,31 @@
|
|
|
1
|
-
import*as
|
|
1
|
+
import * as yup from "yup";
|
|
2
|
+
|
|
3
|
+
export const forgotSchema = yup.object().shape({
|
|
4
|
+
email: yup.string().email("Invalid email").required("E-mail is required"),
|
|
5
|
+
});
|
|
6
|
+
|
|
7
|
+
export const loginSchema = yup.object().shape({
|
|
8
|
+
email: yup.string().email("Invalid email").required("E-mail is required"),
|
|
9
|
+
password: yup
|
|
10
|
+
.string()
|
|
11
|
+
.required("No password provided")
|
|
12
|
+
.min(8, "Password is too short - should be 8 chars minimum")
|
|
13
|
+
.matches(/[a-zA-Z]/, "Password can only contain Latin letters"),
|
|
14
|
+
remember: yup.bool(),
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
export const registerSchema = yup.object().shape({
|
|
18
|
+
name: yup.string().required("Name is required"),
|
|
19
|
+
email: yup.string().email("Invalid email").required("E-mail is required"),
|
|
20
|
+
password: yup
|
|
21
|
+
.string()
|
|
22
|
+
.required("No password provided")
|
|
23
|
+
.min(8, "Password is too short - should be 8 chars minimum")
|
|
24
|
+
.matches(/[a-zA-Z]/, "Password can only contain Latin letters"),
|
|
25
|
+
confirmPassword: yup
|
|
26
|
+
.string()
|
|
27
|
+
.required("Confirm password")
|
|
28
|
+
.oneOf([yup.ref("password")], "Passwords must match"),
|
|
29
|
+
promo: yup.string(),
|
|
30
|
+
recaptcha: yup.bool().oneOf([true], "Field must be checked"),
|
|
31
|
+
});
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
const useBodyScrollLock = (isScrollBodyLocked) => {
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
if (isScrollBodyLocked) {
|
|
6
|
+
document.body.style.overflow = "hidden";
|
|
7
|
+
} else {
|
|
8
|
+
document.body.style.overflow = "auto";
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
return () => {
|
|
12
|
+
document.body.style.overflow = "auto";
|
|
13
|
+
};
|
|
14
|
+
}, [isScrollBodyLocked]);
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
export default useBodyScrollLock;
|
|
@@ -1 +1,15 @@
|
|
|
1
|
-
import{useEffect
|
|
1
|
+
import { useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export const useClickOutside = (ref, setOut, open) => {
|
|
4
|
+
function handleClickOutside(event) {
|
|
5
|
+
if (ref.current && !ref.current.contains(event.target)) {
|
|
6
|
+
setOut(open);
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
useEffect(() => {
|
|
10
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
11
|
+
return () => {
|
|
12
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
13
|
+
};
|
|
14
|
+
}, [ref]);
|
|
15
|
+
};
|
|
@@ -1 +1,17 @@
|
|
|
1
|
-
|
|
1
|
+
import React, { useEffect, useState } from "react";
|
|
2
|
+
|
|
3
|
+
export const useDebounce = ({ searchValue, delay }) => {
|
|
4
|
+
const [debouncedValue, setDebouncedValue] = useState(searchValue);
|
|
5
|
+
|
|
6
|
+
useEffect(() => {
|
|
7
|
+
const handler = setTimeout(() => {
|
|
8
|
+
setDebouncedValue(searchValue);
|
|
9
|
+
}, delay);
|
|
10
|
+
|
|
11
|
+
return () => {
|
|
12
|
+
clearTimeout(handler);
|
|
13
|
+
};
|
|
14
|
+
}, [searchValue, delay]);
|
|
15
|
+
|
|
16
|
+
return debouncedValue;
|
|
17
|
+
};
|
|
@@ -1 +1,84 @@
|
|
|
1
|
-
|
|
1
|
+
import { createRef, useEffect } from "react";
|
|
2
|
+
|
|
3
|
+
export default function useFieldsFocus({ form, setForm }) {
|
|
4
|
+
const isFormAsObject = Boolean(
|
|
5
|
+
typeof form === "object" && !Array.isArray(form),
|
|
6
|
+
);
|
|
7
|
+
|
|
8
|
+
const getField = (key) => {
|
|
9
|
+
if (isFormAsObject) {
|
|
10
|
+
return (
|
|
11
|
+
form?.[key] ?? Object.values(form)?.find((field) => field.key === key)
|
|
12
|
+
);
|
|
13
|
+
} else {
|
|
14
|
+
return form?.find((field) => field.key === key);
|
|
15
|
+
}
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
const getErroredFields = () => {
|
|
19
|
+
if (isFormAsObject) {
|
|
20
|
+
return Object.values(form)?.filter((field) => field.error);
|
|
21
|
+
} else {
|
|
22
|
+
return form?.filter((f) => f?.error);
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
const addRefsToFields = () => {
|
|
27
|
+
if (isFormAsObject) {
|
|
28
|
+
setForm((form) => {
|
|
29
|
+
return Object.keys(form)?.reduce((result, key) => {
|
|
30
|
+
const field = form[key];
|
|
31
|
+
return {
|
|
32
|
+
...result,
|
|
33
|
+
[key]: {
|
|
34
|
+
...field,
|
|
35
|
+
ref: createRef(),
|
|
36
|
+
wrapperRef: createRef(),
|
|
37
|
+
},
|
|
38
|
+
};
|
|
39
|
+
}, {});
|
|
40
|
+
});
|
|
41
|
+
} else {
|
|
42
|
+
setForm((form) => {
|
|
43
|
+
return form?.map((field) => {
|
|
44
|
+
field.ref = createRef();
|
|
45
|
+
field.wrapperRef = createRef();
|
|
46
|
+
|
|
47
|
+
return field;
|
|
48
|
+
});
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
const toggleFieldFocus = ({ field, action = "focus" }) => {
|
|
54
|
+
if (!field || !field?.ref) return null;
|
|
55
|
+
|
|
56
|
+
setTimeout(() => {
|
|
57
|
+
field.ref.current
|
|
58
|
+
?.querySelector(field?.focusSelector || "input")
|
|
59
|
+
?.[action]();
|
|
60
|
+
}, 50);
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
const setFocusTo = (key) => {
|
|
64
|
+
const field = getField(key);
|
|
65
|
+
if (!field) return false;
|
|
66
|
+
|
|
67
|
+
toggleFieldFocus({ field });
|
|
68
|
+
};
|
|
69
|
+
const setFocusToErroredField = () => {
|
|
70
|
+
const field = getErroredFields()?.[0];
|
|
71
|
+
if (!field) return false;
|
|
72
|
+
|
|
73
|
+
toggleFieldFocus({ field });
|
|
74
|
+
};
|
|
75
|
+
|
|
76
|
+
useEffect(() => {
|
|
77
|
+
addRefsToFields();
|
|
78
|
+
}, [form?.length]);
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
setFocusTo,
|
|
82
|
+
setFocusToErroredField,
|
|
83
|
+
};
|
|
84
|
+
}
|
|
@@ -1 +1,39 @@
|
|
|
1
|
-
import
|
|
1
|
+
import General from "../functions/General";
|
|
2
|
+
|
|
3
|
+
export default function ArrayWithObjects({ form, setForm, FormFields }) {
|
|
4
|
+
const {
|
|
5
|
+
joinData,
|
|
6
|
+
getFieldData,
|
|
7
|
+
updateFormField,
|
|
8
|
+
getFormFields,
|
|
9
|
+
getFormFieldsAsArray,
|
|
10
|
+
getFormFieldsKeys,
|
|
11
|
+
} = General({
|
|
12
|
+
FormFields,
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const getFormField = (key, argForm = form) => {
|
|
16
|
+
return getFormFields(argForm)?.find((f) => f.key === key);
|
|
17
|
+
};
|
|
18
|
+
const setFormFields = (data) => {
|
|
19
|
+
const isFunction = typeof data === "function";
|
|
20
|
+
setForm((state) => (isFunction ? data(state) : data));
|
|
21
|
+
};
|
|
22
|
+
const setFormField = (data, key = null) =>
|
|
23
|
+
setFormFields((fields) => updateFormField(fields, data, key));
|
|
24
|
+
|
|
25
|
+
const removeAllFormFields = () => setFormFields([]);
|
|
26
|
+
|
|
27
|
+
return {
|
|
28
|
+
joinData,
|
|
29
|
+
getFieldData,
|
|
30
|
+
getFormFields,
|
|
31
|
+
getFormField,
|
|
32
|
+
setFormFields,
|
|
33
|
+
setFormField,
|
|
34
|
+
getFormFieldsAsArray: (fields) =>
|
|
35
|
+
getFormFieldsAsArray(fields || getFormFields()),
|
|
36
|
+
getFormFieldsKeys: (fields) => getFormFieldsKeys(fields || getFormFields()),
|
|
37
|
+
removeAllFormFields,
|
|
38
|
+
};
|
|
39
|
+
}
|
|
@@ -1 +1,159 @@
|
|
|
1
|
-
|
|
1
|
+
export default function ObjectWithIterableObjects({
|
|
2
|
+
form,
|
|
3
|
+
setForm,
|
|
4
|
+
FormFields,
|
|
5
|
+
}) {
|
|
6
|
+
const joinData = (...args) => {
|
|
7
|
+
const [mainArg] = args;
|
|
8
|
+
const MainArgProto = Array.isArray(mainArg)
|
|
9
|
+
? "Array"
|
|
10
|
+
: typeof mainArg === "object"
|
|
11
|
+
? "Object"
|
|
12
|
+
: undefined;
|
|
13
|
+
const template = Array.isArray(mainArg)
|
|
14
|
+
? []
|
|
15
|
+
: typeof mainArg === "object"
|
|
16
|
+
? {}
|
|
17
|
+
: null;
|
|
18
|
+
|
|
19
|
+
if (!template) return undefined;
|
|
20
|
+
|
|
21
|
+
return args.reduce((result, item) => {
|
|
22
|
+
if (MainArgProto === "Array") {
|
|
23
|
+
if (Array.isArray(item)) {
|
|
24
|
+
return [...result, ...item];
|
|
25
|
+
} else {
|
|
26
|
+
return [...result, item];
|
|
27
|
+
}
|
|
28
|
+
} else if (MainArgProto === "Object") {
|
|
29
|
+
return { ...result, ...item };
|
|
30
|
+
} else {
|
|
31
|
+
return template;
|
|
32
|
+
}
|
|
33
|
+
}, template);
|
|
34
|
+
};
|
|
35
|
+
|
|
36
|
+
const getFieldData = (key) => {
|
|
37
|
+
if (Array.isArray(FormFields)) {
|
|
38
|
+
return FormFields[key] || FormFields.find((f) => f.key === key);
|
|
39
|
+
} else if (typeof FormFields === "object") {
|
|
40
|
+
return (
|
|
41
|
+
FormFields[key] || Object.values(FormFields).find((f) => f.key === key)
|
|
42
|
+
);
|
|
43
|
+
} else {
|
|
44
|
+
return undefined;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
const getFormFields = () => {
|
|
48
|
+
return form.fields || form;
|
|
49
|
+
};
|
|
50
|
+
const getFormField = (key) => {
|
|
51
|
+
// eslint-disable-next-line no-undef
|
|
52
|
+
if (FormProto === "Array") {
|
|
53
|
+
return getFormFields().find((field) => field.key === key);
|
|
54
|
+
// eslint-disable-next-line no-undef
|
|
55
|
+
} else if (FormProto === "Object") {
|
|
56
|
+
return (
|
|
57
|
+
Object.values(getFormFields()).find((field) => field.key === key) ||
|
|
58
|
+
Object.keys(getFormFields()).reduce((result, field) => {
|
|
59
|
+
if (field === key) result = getFormFields()[field];
|
|
60
|
+
return result;
|
|
61
|
+
}, {})
|
|
62
|
+
);
|
|
63
|
+
} else {
|
|
64
|
+
return undefined;
|
|
65
|
+
}
|
|
66
|
+
};
|
|
67
|
+
const setFormFields = (data) => {
|
|
68
|
+
const isFunction = typeof data === "function";
|
|
69
|
+
|
|
70
|
+
setForm((state) => {
|
|
71
|
+
if (state.fields) {
|
|
72
|
+
return {
|
|
73
|
+
...state,
|
|
74
|
+
fields: isFunction ? data(state.fields) : data,
|
|
75
|
+
};
|
|
76
|
+
} else {
|
|
77
|
+
return isFunction ? data(state) : data;
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
};
|
|
81
|
+
const setFormField = (data, key = null) => {
|
|
82
|
+
const isFunction = typeof data === "function";
|
|
83
|
+
|
|
84
|
+
setFormFields((fields) => {
|
|
85
|
+
const pop = (fields, key) => {
|
|
86
|
+
const result = { fields, item: undefined };
|
|
87
|
+
|
|
88
|
+
result.item = fields[key] || fields.find((f) => f.key === key);
|
|
89
|
+
|
|
90
|
+
if (!result.item) return result;
|
|
91
|
+
|
|
92
|
+
if (Array.isArray(fields)) {
|
|
93
|
+
const index = parseInt(key, 10);
|
|
94
|
+
if (!isNaN(index)) {
|
|
95
|
+
result.fields.splice(key, 1);
|
|
96
|
+
} else {
|
|
97
|
+
result.fields = result.fields.filter((f) => f.key !== key);
|
|
98
|
+
}
|
|
99
|
+
} else if (typeof fields === "object") {
|
|
100
|
+
result.fields = Object.values(fields).reduce(
|
|
101
|
+
(object, { key: fKey }) => {
|
|
102
|
+
if (key !== fKey) {
|
|
103
|
+
object[key] = fields[key];
|
|
104
|
+
}
|
|
105
|
+
return object;
|
|
106
|
+
},
|
|
107
|
+
{},
|
|
108
|
+
);
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
return result;
|
|
112
|
+
};
|
|
113
|
+
const update = (fields) => {
|
|
114
|
+
//KEY is NULLable
|
|
115
|
+
if (!key) {
|
|
116
|
+
return data.key
|
|
117
|
+
? Object.values(fields).reduce((result, field, i) => {
|
|
118
|
+
const index = fields[field.key] ? field.key : i;
|
|
119
|
+
|
|
120
|
+
return {
|
|
121
|
+
...result,
|
|
122
|
+
[index]:
|
|
123
|
+
data.key === field.key
|
|
124
|
+
? isFunction
|
|
125
|
+
? data(field)
|
|
126
|
+
: data
|
|
127
|
+
: field,
|
|
128
|
+
};
|
|
129
|
+
}, {})
|
|
130
|
+
: {
|
|
131
|
+
...fields,
|
|
132
|
+
[fields.length || 0]: isFunction ? data({}) : data,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
135
|
+
|
|
136
|
+
const { fields: filtered, item: field } = pop(fields, key);
|
|
137
|
+
|
|
138
|
+
const updatedField = isFunction
|
|
139
|
+
? data(field || {})
|
|
140
|
+
: { ...field, ...data };
|
|
141
|
+
return joinData(
|
|
142
|
+
filtered,
|
|
143
|
+
fields[key] ? { [key]: updatedField } : updatedField,
|
|
144
|
+
);
|
|
145
|
+
};
|
|
146
|
+
|
|
147
|
+
return update(fields);
|
|
148
|
+
});
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
joinData,
|
|
153
|
+
getFieldData,
|
|
154
|
+
getFormFields,
|
|
155
|
+
getFormField,
|
|
156
|
+
setFormFields,
|
|
157
|
+
setFormField,
|
|
158
|
+
};
|
|
159
|
+
}
|