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,78 @@
|
|
|
1
|
-
|
|
1
|
+
import General from "../functions/General";
|
|
2
|
+
|
|
3
|
+
const noop = () => {};
|
|
4
|
+
|
|
5
|
+
export default function ObjectWithNamedKeyObjects({
|
|
6
|
+
form,
|
|
7
|
+
setForm = noop,
|
|
8
|
+
FormFields,
|
|
9
|
+
} = {}) {
|
|
10
|
+
const {
|
|
11
|
+
joinData,
|
|
12
|
+
getFieldData,
|
|
13
|
+
updateFormField,
|
|
14
|
+
getFormFields,
|
|
15
|
+
getFormFieldsAsArray,
|
|
16
|
+
getFormFieldsKeys,
|
|
17
|
+
} = General({
|
|
18
|
+
FormFields,
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
const getFormField = (key, argForm = form) => {
|
|
22
|
+
return (
|
|
23
|
+
Object.values(getFormFields(argForm))?.find(
|
|
24
|
+
(field) => field?.key === key,
|
|
25
|
+
) ||
|
|
26
|
+
Object.keys(getFormFields(argForm))?.reduce((result, field) => {
|
|
27
|
+
if (field === key) result = getFormFields(argForm)[field];
|
|
28
|
+
return result;
|
|
29
|
+
}, null)
|
|
30
|
+
);
|
|
31
|
+
};
|
|
32
|
+
const setFormFields = (data) => {
|
|
33
|
+
const isFunction = typeof data === "function";
|
|
34
|
+
|
|
35
|
+
setForm((state) => {
|
|
36
|
+
if (state.fields) {
|
|
37
|
+
return {
|
|
38
|
+
...state,
|
|
39
|
+
fields: isFunction ? data(state.fields) : data,
|
|
40
|
+
};
|
|
41
|
+
} else {
|
|
42
|
+
return isFunction ? data(state) : data;
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
};
|
|
46
|
+
const setFormField = (data, key = null) =>
|
|
47
|
+
setFormFields((fields) => updateFormField(fields, data, key));
|
|
48
|
+
|
|
49
|
+
const removeAllFormFields = () => setFormFields({});
|
|
50
|
+
const removeFormField = (key) =>
|
|
51
|
+
setFormFields((state) =>
|
|
52
|
+
Object.keys(state)
|
|
53
|
+
.filter((fKey) => fKey !== key)
|
|
54
|
+
.reduce((obj, key) => ({ ...obj, [key]: state[key] }), {}),
|
|
55
|
+
);
|
|
56
|
+
const removeFormFields = ([...keys]) =>
|
|
57
|
+
setFormFields((state) =>
|
|
58
|
+
Object.keys(state)
|
|
59
|
+
.filter((fKey) => !keys.includes(fKey))
|
|
60
|
+
.reduce((obj, key) => ({ ...obj, [key]: state[key] }), {}),
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
joinData,
|
|
65
|
+
getFieldData,
|
|
66
|
+
getFormFields,
|
|
67
|
+
getFormField,
|
|
68
|
+
setFormFields,
|
|
69
|
+
setFormField,
|
|
70
|
+
// eslint-disable-next-line no-dupe-keys
|
|
71
|
+
getFormFields: () => getFormFields(form),
|
|
72
|
+
getFormFieldsAsArray: () => getFormFieldsAsArray(getFormFields(form)),
|
|
73
|
+
getFormFieldsKeys: () => getFormFieldsKeys(getFormFields(form)),
|
|
74
|
+
removeAllFormFields,
|
|
75
|
+
removeFormField,
|
|
76
|
+
removeFormFields,
|
|
77
|
+
};
|
|
78
|
+
}
|
|
@@ -1 +1,134 @@
|
|
|
1
|
-
|
|
1
|
+
export default function General({ form, FormFields = [] } = {}) {
|
|
2
|
+
const joinData = (...args) => {
|
|
3
|
+
const [mainArg] = args;
|
|
4
|
+
const MainArgProto = Array.isArray(mainArg)
|
|
5
|
+
? "Array"
|
|
6
|
+
: typeof mainArg === "object"
|
|
7
|
+
? "Object"
|
|
8
|
+
: undefined;
|
|
9
|
+
const template = Array.isArray(mainArg)
|
|
10
|
+
? []
|
|
11
|
+
: typeof mainArg === "object"
|
|
12
|
+
? {}
|
|
13
|
+
: null;
|
|
14
|
+
|
|
15
|
+
if (!template) return undefined;
|
|
16
|
+
|
|
17
|
+
return args.reduce((result, item) => {
|
|
18
|
+
if (MainArgProto === "Array") {
|
|
19
|
+
if (Array.isArray(item)) {
|
|
20
|
+
return [...result, ...item];
|
|
21
|
+
} else {
|
|
22
|
+
return [...result, item];
|
|
23
|
+
}
|
|
24
|
+
} else if (MainArgProto === "Object") {
|
|
25
|
+
return { ...result, ...item };
|
|
26
|
+
} else {
|
|
27
|
+
return template;
|
|
28
|
+
}
|
|
29
|
+
}, template);
|
|
30
|
+
};
|
|
31
|
+
const getFieldData = (key) => {
|
|
32
|
+
if (Array.isArray(FormFields)) {
|
|
33
|
+
if (FormFields[key]) {
|
|
34
|
+
return { ...FormFields[key] };
|
|
35
|
+
} else {
|
|
36
|
+
return { ...FormFields.find((f) => f.key === key) };
|
|
37
|
+
}
|
|
38
|
+
} else if (typeof FormFields === "object") {
|
|
39
|
+
return (
|
|
40
|
+
{ ...FormFields[key] } || {
|
|
41
|
+
...Object.values(FormFields).find((f) => f.key === key),
|
|
42
|
+
}
|
|
43
|
+
);
|
|
44
|
+
} else {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
};
|
|
48
|
+
const getFormFields = (argForm = form) => {
|
|
49
|
+
return argForm?.fields || argForm;
|
|
50
|
+
};
|
|
51
|
+
const getFormFieldsAsArray = (fields) => {
|
|
52
|
+
if (Array.isArray(fields)) return fields;
|
|
53
|
+
|
|
54
|
+
if (typeof fields === "object") {
|
|
55
|
+
return Object.values(fields);
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return fields;
|
|
59
|
+
};
|
|
60
|
+
const getFormFieldsKeys = (fields = getFormFields()) => {
|
|
61
|
+
if (Array.isArray(fields)) return fields.map(({ key }) => key);
|
|
62
|
+
|
|
63
|
+
if (typeof fields === "object") {
|
|
64
|
+
return Object.values(fields).map(({ key }) => key);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return fields;
|
|
68
|
+
};
|
|
69
|
+
const popFormField = (fields, key) => {
|
|
70
|
+
const result = { item: undefined, itemIndex: undefined };
|
|
71
|
+
|
|
72
|
+
if (Array.isArray(fields)) {
|
|
73
|
+
result.item = fields?.find((f) => f.key === key);
|
|
74
|
+
result.itemIndex = result.item
|
|
75
|
+
? fields.findIndex((f) => f.key === key)
|
|
76
|
+
: fields.length;
|
|
77
|
+
} else if (typeof fields === "object") {
|
|
78
|
+
result.item =
|
|
79
|
+
fields[key] || Object.values(fields).find((f) => f.key === key);
|
|
80
|
+
result.itemIndex = result.item
|
|
81
|
+
? fields[key]
|
|
82
|
+
? key
|
|
83
|
+
: Object.values(fields).findIndex((f) => f.key === key)
|
|
84
|
+
: key;
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
return result;
|
|
88
|
+
};
|
|
89
|
+
const updateFormField = (fields, data, key) => {
|
|
90
|
+
const isFunction = typeof data === "function";
|
|
91
|
+
//KEY is NULLable
|
|
92
|
+
if (!key) {
|
|
93
|
+
return data.key
|
|
94
|
+
? Object.values(fields).reduce((result, field, i) => {
|
|
95
|
+
const index = fields[field.key] ? field.key : i;
|
|
96
|
+
|
|
97
|
+
return {
|
|
98
|
+
...result,
|
|
99
|
+
[index]:
|
|
100
|
+
data.key === field.key
|
|
101
|
+
? isFunction
|
|
102
|
+
? data(field)
|
|
103
|
+
: data
|
|
104
|
+
: field,
|
|
105
|
+
};
|
|
106
|
+
}, {})
|
|
107
|
+
: {
|
|
108
|
+
...fields,
|
|
109
|
+
[fields.length || 0]: isFunction ? data({}) : data,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const { item: field = data, itemIndex } = popFormField(fields, key);
|
|
114
|
+
|
|
115
|
+
fields[itemIndex] = isFunction ? data(field || {}) : { ...field, ...data };
|
|
116
|
+
|
|
117
|
+
return fields;
|
|
118
|
+
};
|
|
119
|
+
|
|
120
|
+
const getFieldClassName = (key, type) => {
|
|
121
|
+
return `form-${type}_field-${key}`;
|
|
122
|
+
};
|
|
123
|
+
|
|
124
|
+
return {
|
|
125
|
+
joinData,
|
|
126
|
+
getFieldData,
|
|
127
|
+
popFormField,
|
|
128
|
+
updateFormField,
|
|
129
|
+
getFormFields,
|
|
130
|
+
getFormFieldsAsArray,
|
|
131
|
+
getFieldClassName,
|
|
132
|
+
getFormFieldsKeys,
|
|
133
|
+
};
|
|
134
|
+
}
|
|
@@ -1 +1,111 @@
|
|
|
1
|
-
|
|
1
|
+
const defaultRenderFieldComponent = () => {
|
|
2
|
+
// eslint-disable-next-line no-console
|
|
3
|
+
console.error("RenderFields: RenderFieldComponent Property is not recieved!");
|
|
4
|
+
return null;
|
|
5
|
+
};
|
|
6
|
+
|
|
7
|
+
const defaultFormDataDriver = () => {
|
|
8
|
+
// eslint-disable-next-line no-console
|
|
9
|
+
console.error("RenderFields: FormDataDriver Property is not recieved!");
|
|
10
|
+
return null;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
const defaultOnFieldChange = () => {
|
|
14
|
+
// eslint-disable-next-line no-console
|
|
15
|
+
console.warn(
|
|
16
|
+
"RenderFields: Be careful, onFieldChange handler is not recieved!",
|
|
17
|
+
);
|
|
18
|
+
return null;
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaultOnFieldBlur = () => {
|
|
22
|
+
// eslint-disable-next-line no-console
|
|
23
|
+
console.warn(
|
|
24
|
+
"RenderFields: Be careful, defaultOnFieldBlur handler is not recieved!",
|
|
25
|
+
);
|
|
26
|
+
return null;
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default function RenderFields({
|
|
30
|
+
form,
|
|
31
|
+
fields,
|
|
32
|
+
cols = 1,
|
|
33
|
+
FormDataDriver = defaultFormDataDriver,
|
|
34
|
+
RenderFieldComponent = defaultRenderFieldComponent,
|
|
35
|
+
onFieldChange = defaultOnFieldChange,
|
|
36
|
+
onFieldBlur = defaultOnFieldBlur,
|
|
37
|
+
} = {}) {
|
|
38
|
+
const maxColumns = 6;
|
|
39
|
+
const maxWidth = 12;
|
|
40
|
+
|
|
41
|
+
const { getFormField } = FormDataDriver({ form });
|
|
42
|
+
|
|
43
|
+
const getColumnsQty = () => {
|
|
44
|
+
return cols > maxColumns ? maxColumns : cols;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
const renderFormField = (key) => {
|
|
48
|
+
try {
|
|
49
|
+
const field = { ...getFormField(key), key };
|
|
50
|
+
const { wrapperRef } = field;
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
key={`render-field-wrapper-${key}`}
|
|
55
|
+
id={`render-field-wrapper-${key}`}
|
|
56
|
+
ref={
|
|
57
|
+
wrapperRef
|
|
58
|
+
? typeof wrapperRef === "function"
|
|
59
|
+
? (node) => wrapperRef(node, key)
|
|
60
|
+
: wrapperRef
|
|
61
|
+
: null
|
|
62
|
+
}
|
|
63
|
+
>
|
|
64
|
+
<RenderFieldComponent
|
|
65
|
+
key={key}
|
|
66
|
+
field={field}
|
|
67
|
+
onChange={(value) => onFieldChange(key, value)}
|
|
68
|
+
onBlur={(...args) => onFieldBlur(...args)}
|
|
69
|
+
/>
|
|
70
|
+
</div>
|
|
71
|
+
);
|
|
72
|
+
} catch (e) {
|
|
73
|
+
return null;
|
|
74
|
+
}
|
|
75
|
+
};
|
|
76
|
+
|
|
77
|
+
const renderSingleColumn = () => {
|
|
78
|
+
return fields.map(renderFormField);
|
|
79
|
+
};
|
|
80
|
+
const renderSplitColumns = () => {
|
|
81
|
+
const fieldsLen = fields?.length || 0;
|
|
82
|
+
const columnsQty =
|
|
83
|
+
getColumnsQty() > fieldsLen ? fieldsLen : getColumnsQty();
|
|
84
|
+
|
|
85
|
+
if (!columnsQty) return null;
|
|
86
|
+
|
|
87
|
+
const parts = new Array(columnsQty).fill([]).map((v, i) => {
|
|
88
|
+
const startIndex = (fieldsLen / columnsQty) * i;
|
|
89
|
+
const endIndex = startIndex + fieldsLen / columnsQty;
|
|
90
|
+
|
|
91
|
+
return fields.slice(startIndex, endIndex);
|
|
92
|
+
});
|
|
93
|
+
|
|
94
|
+
return (
|
|
95
|
+
<div className="row">
|
|
96
|
+
{parts.map((part, i) => (
|
|
97
|
+
<div
|
|
98
|
+
key={`render-fields-row-${i}`}
|
|
99
|
+
className={`col-12 col-lg-${parseInt(maxWidth / columnsQty, 10)}`}
|
|
100
|
+
>
|
|
101
|
+
{part.map(renderFormField)}
|
|
102
|
+
</div>
|
|
103
|
+
))}
|
|
104
|
+
</div>
|
|
105
|
+
);
|
|
106
|
+
};
|
|
107
|
+
|
|
108
|
+
const render = cols === 1 ? renderSingleColumn : renderSplitColumns;
|
|
109
|
+
|
|
110
|
+
return render();
|
|
111
|
+
}
|
|
@@ -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;
|