@envisiongroup/porygon 1.0.0-rc.9 → 1.0.0
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/README.md +50 -14
- package/dist/index.d.ts +9 -15
- package/dist/index.js +95 -55
- package/dist/react-components/buttons/EFWButton/EFWButton.d.ts +1 -1
- package/dist/react-components/buttons/EFWButton/EFWButton.hooks.js +32 -31
- package/dist/react-components/buttons/EFWButton/EFWButton.js +158 -90
- package/dist/react-components/buttons/EFWButton/EFWButton.types.d.ts +32 -6
- package/dist/react-components/buttons/EFWButton/index.d.ts +1 -1
- package/dist/react-components/buttons/EFWDrawerButton/EFWDrawerButton.d.ts +1 -1
- package/dist/react-components/buttons/EFWDrawerButton/EFWDrawerButton.types.d.ts +1 -1
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.d.ts +1 -63
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.js +120 -85
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.types.d.ts +7 -1
- package/dist/react-components/buttons/EFWGroupButton/index.d.ts +1 -1
- package/dist/react-components/commons/caretPositioning.d.ts +35 -0
- package/dist/react-components/commons/caretPositioning.js +28 -0
- package/dist/react-components/commons/utils.d.ts +1 -1
- package/dist/react-components/commons/utils.js +1 -1
- package/dist/react-components/commons/valueNormalization.d.ts +28 -0
- package/dist/react-components/commons/valueNormalization.js +6 -0
- package/dist/react-components/fields/Attachments/EFWAttachments.js +205 -0
- package/dist/react-components/fields/{EFWAttachments → Attachments}/EFWAttachments.types.d.ts +32 -2
- package/dist/react-components/fields/Attachments/EFWAttachments.utils.d.ts +8 -0
- package/dist/react-components/fields/Attachments/EFWAttachments.utils.js +4 -0
- package/dist/react-components/fields/{EFWAttachments/EFWAttachmentsCard → Attachments}/EFWAttachmentsCard.d.ts +2 -11
- package/dist/react-components/fields/Attachments/EFWAttachmentsCard.js +164 -0
- package/dist/react-components/fields/{EFWAttachments/EFWAttachmentsCard → Attachments}/EFWAttachmentsCard.types.d.ts +21 -1
- package/dist/react-components/fields/Attachments/EFWAttachmentsField.js +70 -0
- package/dist/react-components/fields/{EFWAttachmentsField → Attachments}/EFWAttachmentsField.types.d.ts +2 -2
- package/dist/react-components/fields/Attachments/index.d.ts +5 -0
- package/dist/react-components/fields/Attachments/index.js +8 -0
- package/dist/react-components/fields/{EFWDatePicker → DatePicker}/EFWDatePicker.d.ts +1 -3
- package/dist/react-components/fields/DatePicker/EFWDatePicker.js +134 -0
- package/dist/react-components/fields/{EFWDatePicker → DatePicker}/EFWDatePicker.types.d.ts +19 -7
- package/dist/react-components/fields/DatePicker/EFWDatePicker.utils.d.ts +19 -0
- package/dist/react-components/fields/DatePicker/EFWDatePicker.utils.js +179 -0
- package/dist/react-components/fields/DatePicker/EFWDatePickerField.js +251 -0
- package/dist/react-components/fields/DatePicker/EFWDatePickerField.types.d.ts +15 -0
- package/dist/react-components/fields/DatePicker/index.d.ts +6 -0
- package/dist/react-components/fields/DatePicker/index.js +11 -0
- package/dist/react-components/fields/Input/EFWInput.d.ts +10 -0
- package/dist/react-components/fields/Input/EFWInput.js +260 -0
- package/dist/react-components/fields/{EFWInput → Input}/EFWInput.types.d.ts +120 -25
- package/dist/react-components/fields/Input/EFWInput.utils.d.ts +101 -0
- package/dist/react-components/fields/Input/EFWInput.utils.js +222 -0
- package/dist/react-components/fields/Input/EFWInput.validation.d.ts +20 -0
- package/dist/react-components/fields/Input/EFWInput.validation.js +72 -0
- package/dist/react-components/fields/Input/EFWInputField.js +86 -0
- package/dist/react-components/fields/{EFWInputField → Input}/EFWInputField.types.d.ts +2 -2
- package/dist/react-components/fields/Input/index.d.ts +5 -0
- package/dist/react-components/fields/Input/index.js +8 -0
- package/dist/react-components/fields/NumberInput/EFWNumberInput.js +339 -0
- package/dist/react-components/fields/{EFWNumberInput → NumberInput}/EFWNumberInput.types.d.ts +33 -14
- package/dist/react-components/fields/{EFWNumberInput → NumberInput}/EFWNumberInput.utils.d.ts +20 -14
- package/dist/react-components/fields/NumberInput/EFWNumberInput.utils.js +86 -0
- package/dist/react-components/fields/NumberInput/EFWNumberInputField.js +84 -0
- package/dist/react-components/fields/{EFWNumberInputField → NumberInput}/EFWNumberInputField.types.d.ts +2 -2
- package/dist/react-components/fields/NumberInput/index.d.ts +5 -0
- package/dist/react-components/fields/NumberInput/index.js +8 -0
- package/dist/react-components/fields/Switch/EFWSwitch.js +75 -0
- package/dist/react-components/fields/{EFWSwitch → Switch}/EFWSwitch.types.d.ts +18 -10
- package/dist/react-components/fields/Switch/EFWSwitch.utils.d.ts +9 -0
- package/dist/react-components/fields/Switch/EFWSwitch.utils.js +4 -0
- package/dist/react-components/fields/Switch/EFWSwitchField.js +62 -0
- package/dist/react-components/fields/{EFWSwitchField → Switch}/EFWSwitchField.types.d.ts +6 -2
- package/dist/react-components/fields/Switch/index.d.ts +5 -0
- package/dist/react-components/fields/Switch/index.js +8 -0
- package/dist/react-components/fields/TagPicker/EFWTagPicker.js +384 -0
- package/dist/react-components/fields/{EFWTagPicker → TagPicker}/EFWTagPicker.types.d.ts +30 -17
- package/dist/react-components/fields/TagPicker/EFWTagPicker.utils.d.ts +6 -0
- package/dist/react-components/fields/TagPicker/EFWTagPicker.utils.js +4 -0
- package/dist/react-components/fields/TagPicker/EFWTagPickerField.js +83 -0
- package/dist/react-components/fields/{EFWTagPickerField → TagPicker}/EFWTagPickerField.types.d.ts +2 -2
- package/dist/react-components/fields/TagPicker/index.d.ts +5 -0
- package/dist/react-components/fields/TagPicker/index.js +8 -0
- package/dist/react-components/fields/TextArea/EFWTextArea.js +153 -0
- package/dist/react-components/fields/{EFWTextArea → TextArea}/EFWTextArea.types.d.ts +26 -8
- package/dist/react-components/fields/TextArea/EFWTextArea.utils.d.ts +6 -0
- package/dist/react-components/fields/TextArea/EFWTextArea.utils.js +4 -0
- package/dist/react-components/fields/TextArea/EFWTextAreaField.js +80 -0
- package/dist/react-components/fields/{EFWTextAreaField → TextArea}/EFWTextAreaField.types.d.ts +2 -2
- package/dist/react-components/fields/TextArea/index.d.ts +5 -0
- package/dist/react-components/fields/TextArea/index.js +8 -0
- package/dist/react-components/fields/_shared/EFWField/EFWField.js +119 -0
- package/dist/react-components/fields/{EFWField → _shared/EFWField}/EFWField.types.d.ts +24 -13
- package/dist/react-components/fields/_shared/EFWField/EFWField.utils.js +20 -0
- package/dist/react-components/fields/_shared/EFWField/useSyncedValidationState.d.ts +50 -0
- package/dist/react-components/fields/_shared/EFWField/useSyncedValidationState.js +41 -0
- package/dist/react-components/fields/test-utils/testUtils.js +10 -0
- package/dist/react-components/forms/EFWForm/EFWForm.converter.d.ts +16 -1
- package/dist/react-components/forms/EFWForm/EFWForm.converter.js +51 -20
- package/dist/react-components/forms/EFWForm/EFWForm.flatConverter.d.ts +130 -0
- package/dist/react-components/forms/EFWForm/EFWForm.flatConverter.js +279 -0
- package/dist/react-components/forms/EFWForm/EFWForm.hooks.js +21 -18
- package/dist/react-components/forms/EFWForm/EFWForm.js +866 -403
- package/dist/react-components/forms/EFWForm/EFWForm.types.d.ts +213 -89
- package/dist/react-components/forms/EFWForm/EFWForm.utils.d.ts +10 -5
- package/dist/react-components/forms/EFWForm/EFWForm.utils.js +356 -229
- package/dist/react-components/forms/EFWForm/index.d.ts +5 -2
- package/dist/react-components/forms/EFWForm/index.js +10 -6
- package/dist/react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.js +55 -55
- package/dist/react-components/forms/EFWMessageBarManager/EFWMessageBarManager.js +38 -29
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/EFWDrawer.js +49 -47
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/EFWDrawer.types.d.ts +1 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/EFWDrawerLoader.d.ts +5 -3
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/EFWDrawerLoader.js +6 -6
- package/dist/react-components/hooks/useDrawer/index.d.ts +1 -1
- package/dist/react-components/hooks/useDrawer/useDrawer.d.ts +4 -2
- package/dist/react-components/hooks/useDrawer/useDrawer.js +216 -111
- package/dist/react-components/hooks/useDrawer/useDrawer.types.d.ts +15 -2
- package/dist/react-components/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.d.ts +42 -0
- package/dist/react-components/hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js +5 -0
- package/dist/react-components/i18n/PorygonI18nProvider.d.ts +13 -0
- package/dist/react-components/i18n/PorygonI18nProvider.js +145 -0
- package/dist/react-components/i18n/defaultLocaleText.d.ts +6 -0
- package/dist/react-components/i18n/defaultLocaleText.js +176 -0
- package/dist/react-components/i18n/index.d.ts +4 -0
- package/dist/react-components/i18n/index.js +19 -0
- package/dist/react-components/i18n/localePresets.d.ts +10 -0
- package/dist/react-components/i18n/localePresets.js +366 -0
- package/dist/react-components/i18n/porygonI18n.types.d.ts +169 -0
- package/dist/react-components/layout/MainNavItems/MainNavItems.js +13 -13
- package/dist/react-components/tables/EFWTable/EFWTable.d.ts +2 -5
- package/dist/react-components/tables/EFWTable/EFWTable.js +916 -525
- package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +256 -62
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.d.ts +5 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.js +97 -52
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.types.d.ts +4 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.d.ts +1 -12
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +47 -22
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.types.d.ts +13 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +94 -69
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.types.d.ts +7 -16
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/index.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.js +218 -83
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.types.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.js +90 -88
- package/dist/react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.types.d.ts +5 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableRow/EFWTableRow.d.ts +1 -18
- package/dist/react-components/tables/EFWTable/components/EFWTableRow/EFWTableRow.js +83 -45
- package/dist/react-components/tables/EFWTable/components/EFWTableRow/EFWTableRow.types.d.ts +23 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.d.ts +2 -1
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.js +65 -48
- package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.d.ts +2 -1
- package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.js +71 -48
- package/dist/react-components/tables/EFWTable/hooks/useDefaultFilterButton/useDefaultFilterButton.d.ts +17 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultFilterButton/useDefaultFilterButton.js +255 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.d.ts +2 -1
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +72 -52
- package/dist/react-components/tables/EFWTable/hooks/useStableColumnRenderers/useStableColumnRenderers.d.ts +10 -0
- package/dist/react-components/tables/EFWTable/hooks/useStableColumnRenderers/useStableColumnRenderers.js +28 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +151 -115
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.js +100 -53
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.types.d.ts +5 -1
- package/dist/react-components/tables/EFWTable/index.d.ts +4 -1
- package/dist/react-components/tables/EFWTable/index.js +7 -5
- package/dist/react-components/tables/EFWTable/utils/CellRenderer/CellRenderer.js +26 -23
- package/dist/react-components/tables/EFWTable/utils/cache.d.ts +1 -8
- package/dist/react-components/tables/EFWTable/utils/cache.js +40 -49
- package/dist/react-components/tables/EFWTable/utils/filterFunctions.d.ts +16 -0
- package/dist/react-components/tables/EFWTable/utils/filterFunctions.js +52 -0
- package/dist/react-components/tables/EFWTable/utils/hashing.d.ts +2 -2
- package/dist/react-components/tables/EFWTable/utils/hashing.js +2 -2
- package/package.json +49 -22
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.js +0 -125
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/EFWAttachmentsCard.js +0 -107
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/index.d.ts +0 -1
- package/dist/react-components/fields/EFWAttachments/index.d.ts +0 -2
- package/dist/react-components/fields/EFWAttachments/index.js +0 -4
- package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js +0 -57
- package/dist/react-components/fields/EFWAttachmentsField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWAttachmentsField/index.js +0 -4
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +0 -114
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.d.ts +0 -24
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.js +0 -90
- package/dist/react-components/fields/EFWDatePicker/index.d.ts +0 -2
- package/dist/react-components/fields/EFWDatePicker/index.js +0 -4
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.js +0 -65
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.types.d.ts +0 -7
- package/dist/react-components/fields/EFWDatePickerField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWDatePickerField/index.js +0 -4
- package/dist/react-components/fields/EFWField/EFWField.js +0 -96
- package/dist/react-components/fields/EFWField/EFWField.utils.js +0 -17
- package/dist/react-components/fields/EFWInput/EFWInput.d.ts +0 -26
- package/dist/react-components/fields/EFWInput/EFWInput.js +0 -119
- package/dist/react-components/fields/EFWInput/EFWInput.utils.d.ts +0 -20
- package/dist/react-components/fields/EFWInput/EFWInput.utils.js +0 -83
- package/dist/react-components/fields/EFWInput/index.d.ts +0 -2
- package/dist/react-components/fields/EFWInput/index.js +0 -4
- package/dist/react-components/fields/EFWInputField/EFWInputField.js +0 -73
- package/dist/react-components/fields/EFWInputField/EFWInputField.utils.d.ts +0 -1
- package/dist/react-components/fields/EFWInputField/EFWInputField.utils.js +0 -0
- package/dist/react-components/fields/EFWInputField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWInputField/index.js +0 -4
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.js +0 -198
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.utils.js +0 -76
- package/dist/react-components/fields/EFWNumberInput/index.d.ts +0 -2
- package/dist/react-components/fields/EFWNumberInput/index.js +0 -4
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.js +0 -67
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.utils.d.ts +0 -1
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.utils.js +0 -0
- package/dist/react-components/fields/EFWNumberInputField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWNumberInputField/index.js +0 -4
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.js +0 -55
- package/dist/react-components/fields/EFWSwitch/index.d.ts +0 -2
- package/dist/react-components/fields/EFWSwitch/index.js +0 -4
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.js +0 -55
- package/dist/react-components/fields/EFWSwitchField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWSwitchField/index.js +0 -4
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +0 -244
- package/dist/react-components/fields/EFWTagPicker/index.d.ts +0 -2
- package/dist/react-components/fields/EFWTagPicker/index.js +0 -4
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.js +0 -74
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.utils.d.ts +0 -1
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.utils.js +0 -0
- package/dist/react-components/fields/EFWTagPickerField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWTagPickerField/index.js +0 -4
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.js +0 -105
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.utils.d.ts +0 -1
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.utils.js +0 -0
- package/dist/react-components/fields/EFWTextArea/index.d.ts +0 -2
- package/dist/react-components/fields/EFWTextArea/index.js +0 -4
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.js +0 -71
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.utils.d.ts +0 -1
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.utils.js +0 -0
- package/dist/react-components/fields/EFWTextAreaField/index.d.ts +0 -2
- package/dist/react-components/fields/EFWTextAreaField/index.js +0 -4
- package/dist/react-components/fields/types.d.ts +0 -1
- package/dist/react-components/fields/types.js +0 -0
- package/dist/utils/htmlConverter.d.ts +0 -15
- package/dist/utils/htmlConverter.js +0 -12
- /package/dist/react-components/fields/{EFWAttachments → Attachments}/EFWAttachments.d.ts +0 -0
- /package/dist/react-components/fields/{EFWAttachmentsField → Attachments}/EFWAttachmentsField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWDatePickerField → DatePicker}/EFWDatePickerField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWInputField → Input}/EFWInputField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWNumberInput → NumberInput}/EFWNumberInput.d.ts +0 -0
- /package/dist/react-components/fields/{EFWNumberInputField → NumberInput}/EFWNumberInputField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWSwitch → Switch}/EFWSwitch.d.ts +0 -0
- /package/dist/react-components/fields/{EFWSwitchField → Switch}/EFWSwitchField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWTagPicker → TagPicker}/EFWTagPicker.d.ts +0 -0
- /package/dist/react-components/fields/{EFWTagPickerField → TagPicker}/EFWTagPickerField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWTextArea → TextArea}/EFWTextArea.d.ts +0 -0
- /package/dist/react-components/fields/{EFWTextAreaField → TextArea}/EFWTextAreaField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWField → _shared/EFWField}/EFWField.d.ts +0 -0
- /package/dist/react-components/fields/{EFWField → _shared/EFWField}/EFWField.utils.d.ts +0 -0
- /package/dist/react-components/fields/{EFWField → _shared/EFWField}/index.d.ts +0 -0
- /package/dist/react-components/fields/{EFWField → _shared/EFWField}/index.js +0 -0
- /package/dist/{react-components/fields/EFWAttachments/EFWAttachmentsCard/index.js → vite-raw.d.js} +0 -0
|
@@ -1,11 +1,12 @@
|
|
|
1
|
-
import { EFWInputFieldProps, EFWInputFieldValue } from '../../fields/
|
|
2
|
-
import { EFWTagPickerFieldProps, EFWTagPickerFieldValue } from '../../fields/
|
|
3
|
-
import { EFWDatePickerFieldProps, EFWDatePickerFieldValue } from '../../fields/
|
|
4
|
-
import { EFWTextAreaFieldProps, EFWTextAreaFieldValue } from '../../fields/
|
|
5
|
-
import { EFWSwitchFieldProps, EFWSwitchFieldValue } from '../../fields/
|
|
6
|
-
import { EFWAttachmentsFieldProps, EFWAttachmentsFieldValue } from '../../fields/
|
|
7
|
-
import { EFWNumberInputFieldProps, EFWNumberInputFieldValue } from '../../fields/
|
|
1
|
+
import { EFWInputFieldProps, EFWInputFieldValue } from '../../fields/Input';
|
|
2
|
+
import { EFWTagPickerFieldProps, EFWTagPickerFieldValue } from '../../fields/TagPicker';
|
|
3
|
+
import { EFWDatePickerFieldProps, EFWDatePickerFieldValue } from '../../fields/DatePicker';
|
|
4
|
+
import { EFWTextAreaFieldProps, EFWTextAreaFieldValue } from '../../fields/TextArea';
|
|
5
|
+
import { EFWSwitchFieldProps, EFWSwitchFieldValue } from '../../fields/Switch';
|
|
6
|
+
import { EFWAttachmentsFieldProps, EFWAttachmentsFieldValue } from '../../fields/Attachments';
|
|
7
|
+
import { EFWNumberInputFieldProps, EFWNumberInputFieldValue } from '../../fields/NumberInput';
|
|
8
8
|
import { EFWFormMessageBar } from '../EFWFormMessageBarGroup/EFWFormMessageBarGroup.types';
|
|
9
|
+
import { EFWFormExtendedLocaleText } from '../../i18n';
|
|
9
10
|
import { MutableRefObject } from 'react';
|
|
10
11
|
|
|
11
12
|
/**
|
|
@@ -19,7 +20,7 @@ import { MutableRefObject } from 'react';
|
|
|
19
20
|
* // El tipo es válido
|
|
20
21
|
* }
|
|
21
22
|
*/
|
|
22
|
-
|
|
23
|
+
declare const FORM_FIELD_TYPES: readonly ["Text", "Number", "Choice", "Note", "Boolean", "MultiChoice", "Date", "Attachments"];
|
|
23
24
|
/**
|
|
24
25
|
* Tipo union literal derivado de FORM_FIELD_TYPES.
|
|
25
26
|
* Representa todos los tipos de campos posibles en el sistema.
|
|
@@ -28,7 +29,7 @@ export declare const FORM_FIELD_TYPES: readonly ["Text", "Number", "Choice", "No
|
|
|
28
29
|
* const fieldType: EFWFormFieldType = 'Text'; // ✓ Válido
|
|
29
30
|
* const invalidType: EFWFormFieldType = 'Email'; // ✗ Error de TypeScript
|
|
30
31
|
*/
|
|
31
|
-
export type EFWFormFieldType = typeof FORM_FIELD_TYPES[number];
|
|
32
|
+
export type EFWFormFieldType = (typeof FORM_FIELD_TYPES)[number];
|
|
32
33
|
/**
|
|
33
34
|
* Mapeo que asocia cada tipo de campo con su tipo de valor correspondiente.
|
|
34
35
|
* Este mapeo es fundamental para el tipado estricto de los valores del formulario.
|
|
@@ -39,14 +40,14 @@ export type EFWFormFieldType = typeof FORM_FIELD_TYPES[number];
|
|
|
39
40
|
* type NumberFieldValue = EFWFormFieldValueMap['Number']; // EFWNumberInputFieldValue
|
|
40
41
|
*/
|
|
41
42
|
export type EFWFormFieldValueMap = {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
43
|
+
Text: EFWInputFieldValue;
|
|
44
|
+
Number: EFWNumberInputFieldValue;
|
|
45
|
+
Choice: EFWTagPickerFieldValue[];
|
|
46
|
+
Note: EFWTextAreaFieldValue;
|
|
47
|
+
Boolean: EFWSwitchFieldValue;
|
|
48
|
+
MultiChoice: EFWTagPickerFieldValue[];
|
|
49
|
+
Date: EFWDatePickerFieldValue[] | undefined;
|
|
50
|
+
Attachments: EFWAttachmentsFieldValue[] | undefined;
|
|
50
51
|
};
|
|
51
52
|
/**
|
|
52
53
|
* Tipo genérico que obtiene el tipo de valor para un campo específico.
|
|
@@ -73,7 +74,7 @@ export type EFWFormFieldValue<T extends EFWFormFieldType = EFWFormFieldType> = E
|
|
|
73
74
|
* value: 'John Doe'
|
|
74
75
|
* };
|
|
75
76
|
*/
|
|
76
|
-
|
|
77
|
+
interface EFWFormFieldBaseProps<T extends EFWFormFieldType = EFWFormFieldType> {
|
|
77
78
|
readonly id: string;
|
|
78
79
|
readonly typeAsString: T;
|
|
79
80
|
readonly internalName: string;
|
|
@@ -83,19 +84,19 @@ export interface EFWFormFieldBaseProps<T extends EFWFormFieldType = EFWFormField
|
|
|
83
84
|
* Propiedades para campos de entrada de texto.
|
|
84
85
|
* Combina las propiedades base con las específicas del componente de texto.
|
|
85
86
|
*/
|
|
86
|
-
export interface EFWFormInputFieldProps extends EFWFormFieldBaseProps<
|
|
87
|
+
export interface EFWFormInputFieldProps extends EFWFormFieldBaseProps<"Text">, EFWInputFieldProps {
|
|
87
88
|
}
|
|
88
89
|
/**
|
|
89
90
|
* Propiedades para campos de entrada numérica.
|
|
90
91
|
* Combina las propiedades base con las específicas del componente numérico.
|
|
91
92
|
*/
|
|
92
|
-
export interface EFWFormNumberInputFieldProps extends EFWFormFieldBaseProps<
|
|
93
|
+
export interface EFWFormNumberInputFieldProps extends EFWFormFieldBaseProps<"Number">, EFWNumberInputFieldProps {
|
|
93
94
|
}
|
|
94
95
|
/**
|
|
95
96
|
* Propiedades para campos de selección única.
|
|
96
97
|
* Utiliza el componente TagPicker pero limitado a una sola selección.
|
|
97
98
|
*/
|
|
98
|
-
export interface EFWFormTagPickerFieldProps extends EFWFormFieldBaseProps<
|
|
99
|
+
export interface EFWFormTagPickerFieldProps extends EFWFormFieldBaseProps<"Choice">, EFWTagPickerFieldProps {
|
|
99
100
|
}
|
|
100
101
|
/**
|
|
101
102
|
* Propiedades para campos de selección múltiple.
|
|
@@ -103,47 +104,47 @@ export interface EFWFormTagPickerFieldProps extends EFWFormFieldBaseProps<'Choic
|
|
|
103
104
|
*
|
|
104
105
|
* @property {true} multiple - Marca obligatoria que indica selección múltiple
|
|
105
106
|
*/
|
|
106
|
-
export interface EFWFormMultiChoiceFieldProps extends EFWFormFieldBaseProps<
|
|
107
|
+
export interface EFWFormMultiChoiceFieldProps extends EFWFormFieldBaseProps<"MultiChoice">, EFWTagPickerFieldProps {
|
|
107
108
|
multiple: true;
|
|
108
109
|
}
|
|
109
110
|
/**
|
|
110
111
|
* Propiedades para campos de selección de fecha.
|
|
111
112
|
* Puede manejar una o múltiples fechas dependiendo de la configuración.
|
|
112
113
|
*/
|
|
113
|
-
export interface EFWFormDatePickerFieldProps extends EFWFormFieldBaseProps<
|
|
114
|
+
export interface EFWFormDatePickerFieldProps extends EFWFormFieldBaseProps<"Date">, EFWDatePickerFieldProps {
|
|
114
115
|
}
|
|
115
116
|
/**
|
|
116
117
|
* Propiedades para campos de área de texto.
|
|
117
118
|
* Permite entrada de texto multilínea con mayor capacidad que los campos de texto simples.
|
|
118
119
|
*/
|
|
119
|
-
export interface EFWFormTextAreaFieldProps extends EFWFormFieldBaseProps<
|
|
120
|
+
export interface EFWFormTextAreaFieldProps extends EFWFormFieldBaseProps<"Note">, EFWTextAreaFieldProps {
|
|
120
121
|
}
|
|
121
122
|
/**
|
|
122
123
|
* Propiedades para campos de tipo switch/boolean.
|
|
123
124
|
* Representa valores de encendido/apagado, sí/no, habilitado/deshabilitado.
|
|
124
125
|
*/
|
|
125
|
-
export interface EFWFormSwitchFieldProps extends EFWFormFieldBaseProps<
|
|
126
|
+
export interface EFWFormSwitchFieldProps extends EFWFormFieldBaseProps<"Boolean">, EFWSwitchFieldProps {
|
|
126
127
|
}
|
|
127
128
|
/**
|
|
128
129
|
* Propiedades para campos de archivos adjuntos.
|
|
129
130
|
* Permite la carga y gestión de uno o múltiples archivos.
|
|
130
131
|
*/
|
|
131
|
-
export interface EFWFormAttachmentFieldProps extends EFWFormFieldBaseProps<
|
|
132
|
+
export interface EFWFormAttachmentFieldProps extends EFWFormFieldBaseProps<"Attachments">, EFWAttachmentsFieldProps {
|
|
132
133
|
}
|
|
133
134
|
/**
|
|
134
135
|
* Mapeo que asocia cada tipo de campo con su interfaz de propiedades correspondiente.
|
|
135
136
|
* Este mapeo permite la resolución automática del tipo correcto de propiedades
|
|
136
137
|
* basándose en el tipo de campo especificado.
|
|
137
138
|
*/
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
139
|
+
type EFWFormFieldPropsMap = {
|
|
140
|
+
Text: EFWFormInputFieldProps;
|
|
141
|
+
Number: EFWFormNumberInputFieldProps;
|
|
142
|
+
Choice: EFWFormTagPickerFieldProps;
|
|
143
|
+
Note: EFWFormTextAreaFieldProps;
|
|
144
|
+
Boolean: EFWFormSwitchFieldProps;
|
|
145
|
+
MultiChoice: EFWFormMultiChoiceFieldProps;
|
|
146
|
+
Date: EFWFormDatePickerFieldProps;
|
|
147
|
+
Attachments: EFWFormAttachmentFieldProps;
|
|
147
148
|
};
|
|
148
149
|
/**
|
|
149
150
|
* Tipo genérico que resuelve las propiedades correctas para un tipo de campo específico.
|
|
@@ -166,7 +167,7 @@ export type EFWFormFieldProps<T extends EFWFormFieldType = EFWFormFieldType> = E
|
|
|
166
167
|
* }
|
|
167
168
|
* };
|
|
168
169
|
*/
|
|
169
|
-
|
|
170
|
+
interface ResponsiveGridConfig {
|
|
170
171
|
autoFit: {
|
|
171
172
|
minColumnWidth: string;
|
|
172
173
|
maxColumns?: number;
|
|
@@ -209,7 +210,57 @@ export type GridTemplateColumnsType = number | ResponsiveGridConfig | string;
|
|
|
209
210
|
* @typedef {boolean} IsUnion
|
|
210
211
|
* @private
|
|
211
212
|
*/
|
|
212
|
-
type IsUnion<T, U = T> = (T extends any ?
|
|
213
|
+
type IsUnion<T, U = T> = (T extends any ? U extends T ? 0 : 1 : never) extends 0 ? false : true;
|
|
214
|
+
/**
|
|
215
|
+
* Convierte una unión de tipos en su intersección.
|
|
216
|
+
*
|
|
217
|
+
* @example
|
|
218
|
+
* type A = { x: string } | { y: number };
|
|
219
|
+
* type B = UnionToIntersection<A>; // { x: string } & { y: number }
|
|
220
|
+
*/
|
|
221
|
+
type UnionToIntersection<U> = (U extends unknown ? (value: U) => void : never) extends (value: infer I) => void ? I : never;
|
|
222
|
+
/**
|
|
223
|
+
* Obtiene todas las claves de una unión de objetos.
|
|
224
|
+
*/
|
|
225
|
+
type UnionKeys<U> = U extends unknown ? keyof U : never;
|
|
226
|
+
/**
|
|
227
|
+
* Obtiene la unión de tipos de una propiedad K en una unión de objetos U.
|
|
228
|
+
*/
|
|
229
|
+
type UnionProp<U, K extends PropertyKey> = U extends unknown ? K extends keyof U ? U[K] : never : never;
|
|
230
|
+
/**
|
|
231
|
+
* Obtiene la intersección de tipos de una propiedad K en una unión de objetos U.
|
|
232
|
+
*/
|
|
233
|
+
type IntersectionProp<U, K extends PropertyKey> = UnionToIntersection<U extends unknown ? {
|
|
234
|
+
__type: K extends keyof U ? U[K] : never;
|
|
235
|
+
} : never> extends {
|
|
236
|
+
__type: infer V;
|
|
237
|
+
} ? V : never;
|
|
238
|
+
/**
|
|
239
|
+
* Verifica si una clave K existe en todos los miembros de la unión U.
|
|
240
|
+
*/
|
|
241
|
+
type IsKeyInAllMembers<U, K extends PropertyKey> = Exclude<U extends unknown ? (K extends keyof U ? true : false) : never, true> extends never ? true : false;
|
|
242
|
+
/**
|
|
243
|
+
* Claves que nunca deben actualizarse en modo mixto.
|
|
244
|
+
* Evita el caso de "value" con tipos incompatibles entre campos.
|
|
245
|
+
*/
|
|
246
|
+
type DisallowedMixedUpdateKeys = "selectedOptions" | "selectedDates" | "files";
|
|
247
|
+
/**
|
|
248
|
+
* Permite "value" en modo mixto solo cuando todos los tipos involucrados son Text o Note.
|
|
249
|
+
*/
|
|
250
|
+
type SupportsMixedValueForFieldTypes<FT extends EFWFormFieldType> = Exclude<FT, "Text" | "Note"> extends never ? true : false;
|
|
251
|
+
/**
|
|
252
|
+
* Claves que existen en todos los miembros de U y cuyo tipo es compatible entre todos.
|
|
253
|
+
* "Compatible" se define como tener una intersección no vacía del tipo de la clave.
|
|
254
|
+
*/
|
|
255
|
+
type CompatibleCommonKeys<U, FT extends EFWFormFieldType = EFWFormFieldType> = {
|
|
256
|
+
[K in UnionKeys<U>]: K extends "value" ? SupportsMixedValueForFieldTypes<FT> extends true ? IsKeyInAllMembers<U, K> extends true ? [IntersectionProp<U, K>] extends [never] ? never : K : never : never : K extends DisallowedMixedUpdateKeys ? never : IsKeyInAllMembers<U, K> extends true ? [IntersectionProp<U, K>] extends [never] ? never : K : never;
|
|
257
|
+
}[UnionKeys<U>];
|
|
258
|
+
/**
|
|
259
|
+
* Props comunes compatibles para una unión de tipos de campos.
|
|
260
|
+
*/
|
|
261
|
+
type CompatibleCommonProps<U, FT extends EFWFormFieldType = EFWFormFieldType> = {
|
|
262
|
+
[K in CompatibleCommonKeys<U, FT>]?: UnionProp<U, K>;
|
|
263
|
+
};
|
|
213
264
|
/**
|
|
214
265
|
* Extrae los nombres de campos como tipos literales de un array de propiedades de campos.
|
|
215
266
|
*
|
|
@@ -221,7 +272,7 @@ type IsUnion<T, U = T> = (T extends any ? (U extends T ? 0 : 1) : never) extends
|
|
|
221
272
|
* ];
|
|
222
273
|
* type FieldNames = ExtractFieldNames<MyFields>; // 'name' | 'age'
|
|
223
274
|
*/
|
|
224
|
-
export type ExtractFieldNames<T extends readonly EFWFormFieldProps[]> = T[number][
|
|
275
|
+
export type ExtractFieldNames<T extends readonly EFWFormFieldProps[]> = T[number]["internalName"];
|
|
225
276
|
/**
|
|
226
277
|
* Extrae el tipo de campo basándose en el nombre interno (internalName).
|
|
227
278
|
*
|
|
@@ -232,9 +283,9 @@ export type ExtractFieldNames<T extends readonly EFWFormFieldProps[]> = T[number
|
|
|
232
283
|
* type NameFieldType = ExtractFieldType<MyFields, 'name'>; // 'Text'
|
|
233
284
|
* type AgeFieldType = ExtractFieldType<MyFields, 'age'>; // 'Number'
|
|
234
285
|
*/
|
|
235
|
-
|
|
286
|
+
type ExtractFieldType<T extends readonly EFWFormFieldProps[], K extends string> = Extract<T[number], {
|
|
236
287
|
internalName: K;
|
|
237
|
-
}>[
|
|
288
|
+
}>["typeAsString"];
|
|
238
289
|
/**
|
|
239
290
|
* Obtiene el tipo de valor correcto para un campo específico.
|
|
240
291
|
*
|
|
@@ -254,7 +305,7 @@ export type GetFieldValue<T extends readonly EFWFormFieldProps[], K extends stri
|
|
|
254
305
|
* type NameProps = GetFieldProps<MyFields, 'name'>; // EFWFormInputFieldProps
|
|
255
306
|
* type AgeProps = GetFieldProps<MyFields, 'age'>; // EFWFormNumberInputFieldProps
|
|
256
307
|
*/
|
|
257
|
-
|
|
308
|
+
type GetFieldProps<T extends readonly EFWFormFieldProps[], K extends string> = ExtractFieldType<T, K> extends keyof EFWFormFieldPropsMap ? EFWFormFieldPropsMap[ExtractFieldType<T, K>] : EFWFormFieldProps;
|
|
258
309
|
/**
|
|
259
310
|
* Crea un mapeo tipado de todos los valores del formulario.
|
|
260
311
|
* Las claves son los nombres internos de los campos y los valores son del tipo correcto para cada campo.
|
|
@@ -298,39 +349,56 @@ type IsGenericFields<T extends readonly EFWFormFieldProps[]> = string extends Ex
|
|
|
298
349
|
*/
|
|
299
350
|
export type EFWFormFieldUpdate<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> = {
|
|
300
351
|
[K in ExtractFieldNames<T>]: Partial<GetFieldProps<T, K>> & {
|
|
301
|
-
value?: GetFieldValue<T, K> extends EFWFormFieldValueMap[
|
|
302
|
-
selectedOptions?: GetFieldValue<T, K> extends EFWFormFieldValueMap[
|
|
303
|
-
selectedDates?: GetFieldValue<T, K> extends EFWFormFieldValueMap[
|
|
304
|
-
files?: GetFieldValue<T, K> extends EFWFormFieldValueMap[
|
|
352
|
+
value?: GetFieldValue<T, K> extends EFWFormFieldValueMap["Text" | "Number" | "Boolean" | "Note"] ? GetFieldValue<T, K> : never;
|
|
353
|
+
selectedOptions?: GetFieldValue<T, K> extends EFWFormFieldValueMap["Choice" | "MultiChoice"] ? GetFieldValue<T, K> : never;
|
|
354
|
+
selectedDates?: GetFieldValue<T, K> extends EFWFormFieldValueMap["Date"] ? GetFieldValue<T, K> : never;
|
|
355
|
+
files?: GetFieldValue<T, K> extends EFWFormFieldValueMap["Attachments"] ? GetFieldValue<T, K> : never;
|
|
305
356
|
};
|
|
306
357
|
}[ExtractFieldNames<T>];
|
|
307
358
|
/**
|
|
308
359
|
* Función genérica para actualizar campos cuando no hay tipado fuerte.
|
|
309
|
-
*
|
|
360
|
+
* Soporta dos modos de uso mediante overloads:
|
|
361
|
+
*
|
|
362
|
+
* 1. **Con tipo explícito**: Acceso completo a props del tipo especificado.
|
|
363
|
+
* 2. **Sin tipo explícito**: Solo propiedades comunes compatibles entre todos los tipos de campo.
|
|
310
364
|
*
|
|
311
|
-
* @template F - Tipo de campo específico (debe especificarse explícitamente)
|
|
312
365
|
* @example
|
|
313
|
-
* //
|
|
366
|
+
* // ✓ Con tipo explícito → acceso completo a props de Text
|
|
314
367
|
* updateField<'Text'>(['field1', 'field2'], { value: 'nuevo valor' });
|
|
368
|
+
*
|
|
369
|
+
* // ✓ Sin tipo explícito → solo props comunes compatibles
|
|
370
|
+
* updateField(['field1', 'field2'], { disabled: true, required: false });
|
|
371
|
+
*
|
|
372
|
+
* // ✗ Error: 'value' no es compatible entre todos los tipos de campo
|
|
373
|
+
* updateField(['field1', 'field2'], { value: 'algo' });
|
|
315
374
|
*/
|
|
316
|
-
|
|
375
|
+
type GenericUpdateFieldFunctionArray = {
|
|
376
|
+
<F extends EFWFormFieldType = never>(internalNames: readonly string[], updates: Partial<EFWFormFieldPropsMap[F]>): void;
|
|
377
|
+
(internalNames: readonly string[], updates: CompatibleCommonProps<EFWFormFieldProps>): void;
|
|
378
|
+
};
|
|
317
379
|
/**
|
|
318
380
|
* Función estricta para actualizar campos cuando hay tipado fuerte.
|
|
319
|
-
*
|
|
381
|
+
* Soporta dos modos de uso mediante overloads:
|
|
382
|
+
*
|
|
383
|
+
* 1. **Campos del mismo tipo**: Acceso completo a todas las propiedades del tipo.
|
|
384
|
+
* 2. **Campos de distintos tipos**: Solo propiedades comunes entre todos los tipos.
|
|
320
385
|
*
|
|
321
386
|
* @template T - Array readonly de propiedades de campos
|
|
322
|
-
* @template Arr - Array de nombres de campos (inferido)
|
|
323
|
-
* @template K - Nombres de campos específicos (inferido)
|
|
324
|
-
* @template FT - Tipo de campo (inferido)
|
|
325
387
|
*
|
|
326
388
|
* @example
|
|
327
|
-
* // ✓ Todos los campos son tipo 'Text'
|
|
328
|
-
* updateField(['name', 'description'], { value: 'nuevo texto' });
|
|
389
|
+
* // ✓ Todos los campos son tipo 'Text' → acceso completo a props de Text
|
|
390
|
+
* updateField(['name', 'description'], { value: 'nuevo texto', maxLength: 100 });
|
|
391
|
+
*
|
|
392
|
+
* // ✓ Campos de distintos tipos → solo props comunes compatibles
|
|
393
|
+
* updateField(['name', 'age'], { disabled: true, required: false });
|
|
329
394
|
*
|
|
330
|
-
* // ✗ Error: '
|
|
331
|
-
* updateField(['name', 'age'], {
|
|
395
|
+
* // ✗ Error: 'maxLength' no existe en Number (prop no común entre Text y Number)
|
|
396
|
+
* updateField(['name', 'age'], { maxLength: 5 });
|
|
332
397
|
*/
|
|
333
|
-
|
|
398
|
+
type StrictUpdateFieldFunctionArray<T extends readonly EFWFormFieldProps[]> = {
|
|
399
|
+
<Arr extends readonly ExtractFieldNames<T>[], K extends Arr[number], FT = ExtractFieldType<T, K>>(internalNames: Arr & (IsUnion<FT> extends true ? never : unknown), updates: Partial<GetFieldProps<T, K>>): void;
|
|
400
|
+
<Arr extends readonly ExtractFieldNames<T>[]>(internalNames: Arr, updates: CompatibleCommonProps<GetFieldProps<T, Arr[number]>, ExtractFieldType<T, Arr[number]>>): void;
|
|
401
|
+
};
|
|
334
402
|
/**
|
|
335
403
|
* Función de actualización tipada que se adapta según si los campos son genéricos o específicos.
|
|
336
404
|
*
|
|
@@ -348,7 +416,7 @@ export type EFWUpdateFieldFunction<T extends readonly EFWFormFieldProps[]> = IsG
|
|
|
348
416
|
* console.log('Campo cambió:', value);
|
|
349
417
|
* };
|
|
350
418
|
*/
|
|
351
|
-
export type EFWFieldLogicTrigger =
|
|
419
|
+
export type EFWFieldLogicTrigger = "init" | "change";
|
|
352
420
|
/**
|
|
353
421
|
* Contexto compartido para las funciones de lógica de campos.
|
|
354
422
|
*/
|
|
@@ -359,7 +427,7 @@ export type EFWFieldLogicContext<T extends readonly EFWFormFieldProps[], K exten
|
|
|
359
427
|
previousValue: GetFieldValue<T, K> | undefined;
|
|
360
428
|
isControlled: boolean;
|
|
361
429
|
};
|
|
362
|
-
|
|
430
|
+
type GenericFieldLogicFunction<T extends readonly EFWFormFieldProps[]> = (value: EFWFormFieldValue, updateField: EFWUpdateFieldFunction<T>, context: EFWFieldLogicContext<T>) => void;
|
|
363
431
|
/**
|
|
364
432
|
* Función de lógica específica tipada para un campo concreto.
|
|
365
433
|
* El valor está tipado específicamente según el tipo de campo.
|
|
@@ -409,9 +477,10 @@ export type EFWFieldLogic<T extends readonly EFWFormFieldProps[] = EFWFormFieldP
|
|
|
409
477
|
* @interface EFWFormSetValuesOptions
|
|
410
478
|
* @example
|
|
411
479
|
* const options: EFWFormSetValuesOptions = {
|
|
412
|
-
* triggerOnChange: false, // No disparar
|
|
480
|
+
* triggerOnChange: false, // No disparar onValuesChange
|
|
413
481
|
* triggerFieldLogic: true, // Pero sí ejecutar fieldLogic
|
|
414
|
-
* overwriteAll: false
|
|
482
|
+
* overwriteAll: false, // Solo actualizar campos especificados
|
|
483
|
+
* animateUpdatedFields: true // Resaltar campos modificados programáticamente
|
|
415
484
|
* };
|
|
416
485
|
* formRef.current?.setValues({ name: 'Nuevo nombre' }, options);
|
|
417
486
|
*/
|
|
@@ -419,6 +488,18 @@ export interface EFWFormSetValuesOptions {
|
|
|
419
488
|
triggerOnChange?: boolean;
|
|
420
489
|
triggerFieldLogic?: boolean;
|
|
421
490
|
overwriteAll?: boolean;
|
|
491
|
+
animateUpdatedFields?: boolean;
|
|
492
|
+
/**
|
|
493
|
+
* Fuerza la actualización incluso cuando el valor nuevo es idéntico al actual
|
|
494
|
+
* (comparado con `Object.is`). Por defecto `false`: `setValues` omite las keys
|
|
495
|
+
* que no cambiaron, evitando renders, `fieldLogic` y notificaciones innecesarias.
|
|
496
|
+
*/
|
|
497
|
+
force?: boolean;
|
|
498
|
+
}
|
|
499
|
+
export type EFWFormResetValuesOptions = Omit<EFWFormSetValuesOptions, "overwriteAll">;
|
|
500
|
+
export interface EFWFormFieldAnimationConfig {
|
|
501
|
+
setValues?: boolean;
|
|
502
|
+
resetValues?: boolean;
|
|
422
503
|
}
|
|
423
504
|
/**
|
|
424
505
|
* Interfaz que define todos los métodos expuestos por el componente EFWForm.
|
|
@@ -461,10 +542,10 @@ export interface EFWFormMethods<T extends readonly EFWFormFieldProps[] = EFWForm
|
|
|
461
542
|
* @example
|
|
462
543
|
* // Botón de limpiar formulario
|
|
463
544
|
* const handleReset = () => {
|
|
464
|
-
* formRef.current?.resetValues();
|
|
545
|
+
* formRef.current?.resetValues({ animateUpdatedFields: true });
|
|
465
546
|
* };
|
|
466
547
|
*/
|
|
467
|
-
resetValues: () => void;
|
|
548
|
+
resetValues: (options?: EFWFormResetValuesOptions) => void;
|
|
468
549
|
/**
|
|
469
550
|
* Controla el estado de deshabilitación de campos específicos o todos los campos.
|
|
470
551
|
*
|
|
@@ -535,31 +616,44 @@ export interface EFWFormMethods<T extends readonly EFWFormFieldProps[] = EFWForm
|
|
|
535
616
|
* Agrega un mensaje a la barra de mensajes del formulario.
|
|
536
617
|
* Útil para mostrar feedback, errores o información contextual.
|
|
537
618
|
*
|
|
538
|
-
* @param {EFWFormMessageBar} message - Objeto del mensaje a mostrar
|
|
539
|
-
*
|
|
619
|
+
* @param {EFWFormMessageBar} message - Objeto del mensaje a mostrar.
|
|
620
|
+
* Propiedades disponibles:
|
|
621
|
+
* - `id` (string | number) — Identificador único del mensaje.
|
|
622
|
+
* - `intent` ('info' | 'success' | 'warning' | 'error') — Nivel de importancia visual.
|
|
623
|
+
* - `title` (string) — Título opcional del mensaje.
|
|
624
|
+
* - `message` (ReactNode) — Contenido del mensaje.
|
|
625
|
+
* - `layout` (MessageBarProps['layout']) — Layout del MessageBar.
|
|
626
|
+
* - `actions` (EFWFormMessageBarAction[]) — Acciones interactivas del mensaje.
|
|
627
|
+
* - `dismissable` (boolean) — Si el usuario puede cerrar el mensaje.
|
|
628
|
+
* @param {'internal' | 'external'} [source='external'] - Origen del mensaje.
|
|
629
|
+
* Los mensajes 'internal' son generados por lógica interna del formulario (ej. validación),
|
|
630
|
+
* mientras que los 'external' provienen de la lógica de negocio de la aplicación.
|
|
540
631
|
* @example
|
|
541
|
-
* // Mostrar mensaje de éxito
|
|
632
|
+
* // Mostrar mensaje de éxito simple
|
|
542
633
|
* formRef.current?.addMessageBar({
|
|
543
634
|
* id: 'success-1',
|
|
544
|
-
*
|
|
635
|
+
* intent: 'success',
|
|
545
636
|
* message: 'Datos guardados correctamente'
|
|
546
637
|
* });
|
|
547
638
|
*
|
|
548
|
-
* // Mostrar error
|
|
639
|
+
* // Mostrar error con título y acción personalizada
|
|
549
640
|
* formRef.current?.addMessageBar({
|
|
550
641
|
* id: 'validation-error',
|
|
551
|
-
*
|
|
552
|
-
*
|
|
642
|
+
* intent: 'error',
|
|
643
|
+
* title: 'Error de validación',
|
|
644
|
+
* message: 'La edad debe ser mayor a 18 años',
|
|
645
|
+
* actions: [{ id: 'retry', content: 'Reintentar', onClick: () => handleRetry() }],
|
|
646
|
+
* dismissable: true
|
|
553
647
|
* }, 'internal');
|
|
554
648
|
*/
|
|
555
|
-
addMessageBar: (message: EFWFormMessageBar, source?:
|
|
649
|
+
addMessageBar: (message: EFWFormMessageBar, source?: "internal" | "external") => void;
|
|
556
650
|
/**
|
|
557
651
|
* Elimina un mensaje específico de la barra de mensajes.
|
|
558
652
|
*
|
|
559
653
|
* @param {string | number} messageId - ID del mensaje a eliminar
|
|
560
654
|
* @example
|
|
561
655
|
* // Eliminar mensaje después de 5 segundos
|
|
562
|
-
* formRef.current?.addMessageBar({ id: 'temp-msg',
|
|
656
|
+
* formRef.current?.addMessageBar({ id: 'temp-msg', intent: 'info', message: 'Guardando...' });
|
|
563
657
|
* setTimeout(() => {
|
|
564
658
|
* formRef.current?.removeMessageBar('temp-msg');
|
|
565
659
|
* }, 5000);
|
|
@@ -577,6 +671,29 @@ export interface EFWFormMethods<T extends readonly EFWFormFieldProps[] = EFWForm
|
|
|
577
671
|
* };
|
|
578
672
|
*/
|
|
579
673
|
removeAllMessagesBar: () => void;
|
|
674
|
+
/**
|
|
675
|
+
* Actualiza las propiedades y/o valores de uno o más campos del formulario.
|
|
676
|
+
* Permite control granular a nivel de campo, incluyendo cambiar valores,
|
|
677
|
+
* estados de validación, visibilidad, etc.
|
|
678
|
+
*
|
|
679
|
+
* Soporta dos modos de uso:
|
|
680
|
+
* 1. Con tipo explícito: acceso completo a todas las propiedades del tipo especificado.
|
|
681
|
+
* 2. Sin tipo explícito: solo propiedades comunes compatibles entre todos los campos seleccionados.
|
|
682
|
+
*
|
|
683
|
+
* @example
|
|
684
|
+
* // Actualizar un campo de texto con tipo explícito
|
|
685
|
+
* updateField<'Text'>(['name'], { value: 'Nuevo valor', disabled: true });
|
|
686
|
+
*
|
|
687
|
+
* // Actualizar propiedades comunes a varios campos de distintos tipos
|
|
688
|
+
* updateField(['name', 'age'], { disabled: true, required: false });
|
|
689
|
+
*
|
|
690
|
+
* // Actualizar opciones de un campo Choice
|
|
691
|
+
* updateField<'Choice'>(['category'], {
|
|
692
|
+
* selectedOptions: [{ key: '1', text: 'Option 1' }],
|
|
693
|
+
* options: newOptions
|
|
694
|
+
* });
|
|
695
|
+
*/
|
|
696
|
+
updateField: EFWUpdateFieldFunction<T>;
|
|
580
697
|
}
|
|
581
698
|
/**
|
|
582
699
|
* Tipo que representa la referencia al componente EFWForm.
|
|
@@ -716,7 +833,19 @@ export interface EFWFormSection<T extends EFWFormFieldProps = EFWFormFieldProps>
|
|
|
716
833
|
* @template T - Array de propiedades de campos
|
|
717
834
|
* @interface EFWFormBaseProps
|
|
718
835
|
*/
|
|
719
|
-
|
|
836
|
+
interface EFWFormBaseProps<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> {
|
|
837
|
+
/**
|
|
838
|
+
* Textos de localización para mensajes internos del formulario y, opcionalmente,
|
|
839
|
+
* para los campos (`fields`) y botones/drawers (`buttons`) hijos.
|
|
840
|
+
*
|
|
841
|
+
* Las claves base (`requiredFieldError`, `requiredFieldsNotification`, `unsupportedFieldType`)
|
|
842
|
+
* afectan solo al formulario. Si además se incluyen `fields` o `buttons`,
|
|
843
|
+
* `EFWForm` envuelve internamente su contenido con un `PorygonI18nProvider` local
|
|
844
|
+
* para que los campos hereden las traducciones sin necesidad de un provider externo.
|
|
845
|
+
*
|
|
846
|
+
* Si se omite, se usan los defaults del provider global (o defaults internos en español).
|
|
847
|
+
*/
|
|
848
|
+
localeText?: Partial<EFWFormExtendedLocaleText>;
|
|
720
849
|
/**
|
|
721
850
|
* Estilos CSS inline opcionales para el contenedor principal del formulario.
|
|
722
851
|
*
|
|
@@ -823,19 +952,7 @@ export interface EFWFormBaseProps<T extends readonly EFWFormFieldProps[] = EFWFo
|
|
|
823
952
|
fieldLogic?: EFWFieldLogic<T>;
|
|
824
953
|
/**
|
|
825
954
|
* Callback ejecutado cuando cualquier valor del formulario cambia.
|
|
826
|
-
* Recibe los valores completos actualizados.
|
|
827
|
-
*
|
|
828
|
-
* @type {(values: EFWFormValues<T>) => void}
|
|
829
|
-
* @deprecated Usar onValuesChange en su lugar
|
|
830
|
-
* @example
|
|
831
|
-
* onChange={(values) => {
|
|
832
|
-
* console.log('Formulario cambió:', values);
|
|
833
|
-
* }}
|
|
834
|
-
*/
|
|
835
|
-
onChange?: (values: EFWFormValues<T>) => void;
|
|
836
|
-
/**
|
|
837
|
-
* Callback ejecutado cuando cualquier valor del formulario cambia.
|
|
838
|
-
* Versión preferida y más clara que onChange.
|
|
955
|
+
* Recibe los valores completos actualizados como copia superficial.
|
|
839
956
|
*
|
|
840
957
|
* @type {(values: EFWFormValues<T>) => void}
|
|
841
958
|
* @example
|
|
@@ -852,8 +969,8 @@ export interface EFWFormBaseProps<T extends readonly EFWFormFieldProps[] = EFWFo
|
|
|
852
969
|
* @type {EFWFormMessageBar[]}
|
|
853
970
|
* @example
|
|
854
971
|
* messages={[
|
|
855
|
-
* { id: 'info',
|
|
856
|
-
* { id: 'warning',
|
|
972
|
+
* { id: 'info', intent: 'info', message: 'Los campos con * son obligatorios' },
|
|
973
|
+
* { id: 'warning', intent: 'warning', message: 'Revise los datos antes de enviar' }
|
|
857
974
|
* ]}
|
|
858
975
|
*/
|
|
859
976
|
messages?: EFWFormMessageBar[];
|
|
@@ -967,6 +1084,13 @@ export interface EFWFormProps<T extends readonly EFWFormFieldProps[] = EFWFormFi
|
|
|
967
1084
|
* ]}
|
|
968
1085
|
*/
|
|
969
1086
|
fields?: T;
|
|
1087
|
+
/**
|
|
1088
|
+
* Configuración default para animar campos actualizados programáticamente.
|
|
1089
|
+
*
|
|
1090
|
+
* La opción por llamada (`setValues(..., { animateUpdatedFields })`) tiene prioridad
|
|
1091
|
+
* sobre esta configuración global.
|
|
1092
|
+
*/
|
|
1093
|
+
fieldAnimationConfig?: EFWFormFieldAnimationConfig;
|
|
970
1094
|
/**
|
|
971
1095
|
* Configuración de columnas del grid cuando se usa la propiedad fields.
|
|
972
1096
|
* Solo disponible cuando NO se usan sections.
|
|
@@ -1,17 +1,22 @@
|
|
|
1
1
|
import { EFWFormFieldUpdate, EFWFormFieldProps, GetFieldValue, ExtractFieldNames, EFWFormValues, EFWUpdateFieldFunction, EFWFieldLogicContext, GridTemplateColumnsType } from './EFWForm.types';
|
|
2
|
-
import { ValidationMessage, ValidationState } from '../../fields/EFWField/EFWField.types';
|
|
2
|
+
import { ValidationMessage, ValidationState } from '../../fields/_shared/EFWField/EFWField.types';
|
|
3
|
+
import { EFWFormLocaleText } from '../../i18n';
|
|
3
4
|
|
|
4
5
|
export declare const generateGridTemplateColumns: (config: GridTemplateColumnsType) => string;
|
|
5
|
-
declare const EFWFormFieldWrapperInner: <T extends readonly EFWFormFieldProps[]>({ field, initialValue, onValueChange, registerUpdateProps,
|
|
6
|
+
declare const EFWFormFieldWrapperInner: <T extends readonly EFWFormFieldProps[]>({ field, initialValue, onValueChange, registerUpdateProps, unregisterUpdateProps, getFieldLogicByName, isControlled, getAllValues, updateFieldProps, localeText, onValidationChange, }: {
|
|
6
7
|
field: T[number];
|
|
7
8
|
initialValue: GetFieldValue<T, T[number]["internalName"]>;
|
|
8
|
-
onValueChange: (internalName: ExtractFieldNames<T>, value: GetFieldValue<T, T[number]["internalName"]
|
|
9
|
+
onValueChange: (internalName: ExtractFieldNames<T>, value: GetFieldValue<T, T[number]["internalName"]>, options?: {
|
|
10
|
+
silent?: boolean;
|
|
11
|
+
}) => void;
|
|
9
12
|
registerUpdateProps: (internalName: ExtractFieldNames<T>, updateFn: (updates: EFWFormFieldUpdate<T>) => void) => void;
|
|
10
|
-
|
|
13
|
+
unregisterUpdateProps: (internalName: ExtractFieldNames<T>, expectedUpdateFn: (updates: EFWFormFieldUpdate<T>) => void) => void;
|
|
14
|
+
getFieldLogicByName?: (internalName: ExtractFieldNames<T>) => ((value: GetFieldValue<T, T[number]["internalName"]>, updateField: EFWUpdateFieldFunction<T>, context: EFWFieldLogicContext<T, ExtractFieldNames<T>>) => void) | undefined;
|
|
11
15
|
isControlled?: boolean;
|
|
12
16
|
getAllValues: () => EFWFormValues<T>;
|
|
13
17
|
updateFieldProps: EFWUpdateFieldFunction<T>;
|
|
14
|
-
|
|
18
|
+
localeText: EFWFormLocaleText;
|
|
19
|
+
onValidationChange?: (internalName: ExtractFieldNames<T>, validation: {
|
|
15
20
|
currentValidationState: ValidationState;
|
|
16
21
|
currentValidationMessage: ValidationMessage;
|
|
17
22
|
}) => void;
|