@envisiongroup/porygon 1.0.0-rc.9 → 1.0.1
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 +388 -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
|
@@ -0,0 +1,260 @@
|
|
|
1
|
+
import { jsx as x, Fragment as zt } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as Bt, tokens as p, mergeClasses as Dt, Text as Nt, Input as Pt } from "@fluentui/react-components";
|
|
3
|
+
import { useId as Tt, useRef as L, useState as It, useMemo as u, useCallback as ht, useEffect as C } from "react";
|
|
4
|
+
import { stripFormatting as v, getInputFormattedValue as E, applyFormatting as gt, computeFormattedCaretPosition as Wt } from "./EFWInput.utils.js";
|
|
5
|
+
import { useIsomorphicLayoutEffect as Ot } from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
|
|
6
|
+
import { resolveInputValidationState as jt } from "./EFWInput.validation.js";
|
|
7
|
+
import { useFieldsLocaleText as At } from "../../i18n/PorygonI18nProvider.js";
|
|
8
|
+
const qt = Bt({
|
|
9
|
+
efwInputError: {
|
|
10
|
+
backgroundColor: p.colorPaletteRedBackground1,
|
|
11
|
+
"::after": {
|
|
12
|
+
borderBottomColor: p.colorPaletteRedBorder2,
|
|
13
|
+
borderBottomStyle: "solid",
|
|
14
|
+
borderBottomWidth: "2px"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
efwInput: {
|
|
18
|
+
"& [disabled]": {
|
|
19
|
+
backgroundColor: p.colorNeutralBackground3,
|
|
20
|
+
color: p.colorNeutralForeground2,
|
|
21
|
+
"&::placeholder": {
|
|
22
|
+
color: "transparent"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
// Afectar el span que contiene el input disabled
|
|
26
|
+
"&:has(span + [disabled])": {
|
|
27
|
+
backgroundColor: p.colorNeutralBackground3
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
}), Yt = (Ct) => {
|
|
31
|
+
const {
|
|
32
|
+
value: c,
|
|
33
|
+
defaultValue: M,
|
|
34
|
+
onChange: k,
|
|
35
|
+
editable: bt = !0,
|
|
36
|
+
disabled: Vt = !1,
|
|
37
|
+
className: Ft = "",
|
|
38
|
+
autoComplete: yt = "off",
|
|
39
|
+
type: wt = "text",
|
|
40
|
+
contentBefore: Rt,
|
|
41
|
+
contentAfter: St,
|
|
42
|
+
formatType: a = "none",
|
|
43
|
+
formatPattern: m,
|
|
44
|
+
formatFunction: b,
|
|
45
|
+
formatConfig: o,
|
|
46
|
+
minLength: z = 0,
|
|
47
|
+
maxLength: B = 250,
|
|
48
|
+
labels: D,
|
|
49
|
+
readOnlyRenderer: xt,
|
|
50
|
+
validationMessages: r,
|
|
51
|
+
validationState: Lt = "none",
|
|
52
|
+
setParentComponentState: N
|
|
53
|
+
} = Ct, n = c !== void 0, P = (n ? c : M) ?? "", I = M ?? "", T = qt(), W = Tt(), O = L(!1), j = L(null), V = L(null), [d, A] = It(
|
|
54
|
+
() => v(P, a, o)
|
|
55
|
+
), [Et, F] = It(
|
|
56
|
+
() => E(P, a, {
|
|
57
|
+
formatPattern: m,
|
|
58
|
+
formatFunction: b,
|
|
59
|
+
formatConfig: o
|
|
60
|
+
})
|
|
61
|
+
), l = u(
|
|
62
|
+
() => ({ formatPattern: m, formatFunction: b, formatConfig: o }),
|
|
63
|
+
[m, b, o]
|
|
64
|
+
), q = At(), G = q.input.labels, i = q.input.validationMessages, H = G.placeholder, J = G.emptyState, K = D?.placeholder, Q = D?.emptyState, U = u(() => ({
|
|
65
|
+
placeholder: K ?? H,
|
|
66
|
+
emptyState: Q ?? J
|
|
67
|
+
}), [
|
|
68
|
+
K,
|
|
69
|
+
Q,
|
|
70
|
+
H,
|
|
71
|
+
J
|
|
72
|
+
]), X = i.minLength, Y = i.maxLength, Z = i.creditCardInvalid, _ = i.chileanRutInvalid, $ = i.dateInvalid, tt = i.dateInvalidWithFormat, et = i.timeInvalid, at = i.emailInvalid, nt = i.formatInvalid, ot = r?.minLength, lt = r?.maxLength, rt = r?.creditCardInvalid, it = r?.chileanRutInvalid, st = r?.dateInvalid, ct = r?.dateInvalidWithFormat, dt = r?.timeInvalid, ut = r?.emailInvalid, mt = r?.formatInvalid, ft = u(() => ({
|
|
73
|
+
minLength: ot ?? X,
|
|
74
|
+
maxLength: lt ?? Y,
|
|
75
|
+
creditCardInvalid: rt ?? Z,
|
|
76
|
+
chileanRutInvalid: it ?? _,
|
|
77
|
+
dateInvalid: st ?? $,
|
|
78
|
+
dateInvalidWithFormat: ct ?? tt,
|
|
79
|
+
timeInvalid: dt ?? et,
|
|
80
|
+
emailInvalid: ut ?? at,
|
|
81
|
+
formatInvalid: mt ?? nt
|
|
82
|
+
}), [
|
|
83
|
+
ot,
|
|
84
|
+
lt,
|
|
85
|
+
rt,
|
|
86
|
+
it,
|
|
87
|
+
st,
|
|
88
|
+
ct,
|
|
89
|
+
dt,
|
|
90
|
+
ut,
|
|
91
|
+
mt,
|
|
92
|
+
X,
|
|
93
|
+
Y,
|
|
94
|
+
Z,
|
|
95
|
+
_,
|
|
96
|
+
$,
|
|
97
|
+
tt,
|
|
98
|
+
et,
|
|
99
|
+
at,
|
|
100
|
+
nt
|
|
101
|
+
]), h = u(
|
|
102
|
+
() => v(I, a, o),
|
|
103
|
+
[I, a, o]
|
|
104
|
+
), y = u(
|
|
105
|
+
() => E(
|
|
106
|
+
I,
|
|
107
|
+
a,
|
|
108
|
+
l
|
|
109
|
+
),
|
|
110
|
+
[I, a, l]
|
|
111
|
+
), pt = u(() => {
|
|
112
|
+
if (!n)
|
|
113
|
+
return { raw: "", formatted: "" };
|
|
114
|
+
const e = v(
|
|
115
|
+
c ?? "",
|
|
116
|
+
a,
|
|
117
|
+
o
|
|
118
|
+
), t = E(
|
|
119
|
+
c,
|
|
120
|
+
a,
|
|
121
|
+
l
|
|
122
|
+
);
|
|
123
|
+
return { raw: e, formatted: t };
|
|
124
|
+
}, [n, c, a, o, l]), w = n ? pt.raw : d, R = n ? pt.formatted : Et, s = ht(
|
|
125
|
+
(e) => {
|
|
126
|
+
const t = jt({
|
|
127
|
+
rawValue: e,
|
|
128
|
+
formatType: a,
|
|
129
|
+
formatPattern: m,
|
|
130
|
+
formatConfig: o,
|
|
131
|
+
minLength: z,
|
|
132
|
+
maxLength: B,
|
|
133
|
+
messages: ft,
|
|
134
|
+
formatOptions: l
|
|
135
|
+
});
|
|
136
|
+
return N?.(
|
|
137
|
+
t.hasError ? "error" : "none",
|
|
138
|
+
t.message
|
|
139
|
+
), t.hasError;
|
|
140
|
+
},
|
|
141
|
+
[
|
|
142
|
+
z,
|
|
143
|
+
B,
|
|
144
|
+
a,
|
|
145
|
+
m,
|
|
146
|
+
o,
|
|
147
|
+
l,
|
|
148
|
+
N,
|
|
149
|
+
ft
|
|
150
|
+
]
|
|
151
|
+
);
|
|
152
|
+
C(() => {
|
|
153
|
+
n && s(w);
|
|
154
|
+
}, [n, w, s]), C(() => {
|
|
155
|
+
n || (A(
|
|
156
|
+
(e) => e === h ? e : h
|
|
157
|
+
), F(
|
|
158
|
+
(e) => e === y ? e : y
|
|
159
|
+
), s(h));
|
|
160
|
+
}, [
|
|
161
|
+
n,
|
|
162
|
+
h,
|
|
163
|
+
y,
|
|
164
|
+
s
|
|
165
|
+
]), C(() => {
|
|
166
|
+
n || F((e) => {
|
|
167
|
+
const t = gt(
|
|
168
|
+
d,
|
|
169
|
+
a,
|
|
170
|
+
l
|
|
171
|
+
);
|
|
172
|
+
return t === e ? e : t;
|
|
173
|
+
});
|
|
174
|
+
}, [n, d, a, l]), C(() => {
|
|
175
|
+
n || O.current || (O.current = !0, s(d));
|
|
176
|
+
}, [n, d, s]);
|
|
177
|
+
const Mt = ht(
|
|
178
|
+
(e, t) => {
|
|
179
|
+
if (typeof t.value == "string") {
|
|
180
|
+
const g = v(
|
|
181
|
+
t.value,
|
|
182
|
+
a,
|
|
183
|
+
o
|
|
184
|
+
), f = gt(
|
|
185
|
+
g,
|
|
186
|
+
a,
|
|
187
|
+
l
|
|
188
|
+
), S = v(
|
|
189
|
+
f,
|
|
190
|
+
a,
|
|
191
|
+
o
|
|
192
|
+
);
|
|
193
|
+
if (f !== t.value) {
|
|
194
|
+
const vt = e.currentTarget?.selectionStart;
|
|
195
|
+
typeof vt == "number" && (V.current = Wt({
|
|
196
|
+
previousCaret: vt,
|
|
197
|
+
typedValue: t.value,
|
|
198
|
+
nextFormatted: f,
|
|
199
|
+
formatType: a,
|
|
200
|
+
formatOptions: l
|
|
201
|
+
}));
|
|
202
|
+
}
|
|
203
|
+
s(S), n || (A(S), F(f)), k?.(S, f);
|
|
204
|
+
}
|
|
205
|
+
},
|
|
206
|
+
[
|
|
207
|
+
a,
|
|
208
|
+
o,
|
|
209
|
+
l,
|
|
210
|
+
k,
|
|
211
|
+
s,
|
|
212
|
+
n
|
|
213
|
+
]
|
|
214
|
+
);
|
|
215
|
+
Ot(() => {
|
|
216
|
+
const e = V.current;
|
|
217
|
+
if (e === null) return;
|
|
218
|
+
V.current = null;
|
|
219
|
+
const t = j.current;
|
|
220
|
+
if (!t || document.activeElement !== t) return;
|
|
221
|
+
const g = Math.max(0, Math.min(e, t.value.length));
|
|
222
|
+
t.setSelectionRange(g, g);
|
|
223
|
+
});
|
|
224
|
+
const kt = Dt(
|
|
225
|
+
Ft,
|
|
226
|
+
T.efwInput,
|
|
227
|
+
Lt === "error" && T.efwInputError
|
|
228
|
+
);
|
|
229
|
+
if (!bt) {
|
|
230
|
+
const e = R || U.emptyState, t = xt?.(
|
|
231
|
+
n ? c : d,
|
|
232
|
+
e
|
|
233
|
+
);
|
|
234
|
+
return t != null ? /* @__PURE__ */ x(zt, { children: t }) : /* @__PURE__ */ x(Nt, { style: R ? void 0 : { opacity: 0.7 }, children: e });
|
|
235
|
+
}
|
|
236
|
+
return /* @__PURE__ */ x(
|
|
237
|
+
Pt,
|
|
238
|
+
{
|
|
239
|
+
ref: j,
|
|
240
|
+
className: kt,
|
|
241
|
+
id: W,
|
|
242
|
+
name: W,
|
|
243
|
+
type: wt,
|
|
244
|
+
placeholder: U.placeholder,
|
|
245
|
+
contentBefore: Rt,
|
|
246
|
+
contentAfter: St,
|
|
247
|
+
disabled: Vt,
|
|
248
|
+
value: R,
|
|
249
|
+
"data-raw-value": w,
|
|
250
|
+
autoComplete: yt,
|
|
251
|
+
autoCorrect: "off",
|
|
252
|
+
autoCapitalize: "off",
|
|
253
|
+
spellCheck: "false",
|
|
254
|
+
onChange: Mt
|
|
255
|
+
}
|
|
256
|
+
);
|
|
257
|
+
};
|
|
258
|
+
export {
|
|
259
|
+
Yt as EFWInput
|
|
260
|
+
};
|
|
@@ -1,8 +1,15 @@
|
|
|
1
|
-
import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
|
|
1
|
+
import { EFWFieldChildrenProps } from '../_shared/EFWField/EFWField.types';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
/**
|
|
4
5
|
* Valor que puede contener un componente de entrada EFW.
|
|
5
|
-
*
|
|
6
|
+
* Semántica recomendada:
|
|
7
|
+
* - `undefined`: prop ausente (modo uncontrolled)
|
|
8
|
+
* - `null`: vacío explícito recibido desde integración externa
|
|
9
|
+
* - `string`: valor efectivo del campo
|
|
10
|
+
*
|
|
11
|
+
* Nota: el callback `onChange` emite siempre un `string` normalizado
|
|
12
|
+
* (incluyendo `""` cuando el valor está vacío).
|
|
6
13
|
*
|
|
7
14
|
* @example
|
|
8
15
|
* // Valor con texto
|
|
@@ -17,6 +24,39 @@ import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
|
|
|
17
24
|
* const [inputValue, setInputValue] = useState<EFWInputValue>("Valor inicial");
|
|
18
25
|
*/
|
|
19
26
|
export type EFWInputValue = string | null | undefined;
|
|
27
|
+
export type EFWInputNonEditableRenderer = (value: EFWInputValue, displayValue: string) => ReactNode;
|
|
28
|
+
/**
|
|
29
|
+
* Textos de la UI del componente EFWInput.
|
|
30
|
+
*/
|
|
31
|
+
export interface EFWInputLabels {
|
|
32
|
+
/** Texto de sugerencia mostrado cuando el campo está vacío. */
|
|
33
|
+
placeholder?: string;
|
|
34
|
+
/** Texto mostrado cuando el campo no tiene valor. */
|
|
35
|
+
emptyState?: string;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Mensajes de error para cada tipo de validación del componente EFWInput.
|
|
39
|
+
*/
|
|
40
|
+
export interface EFWInputValidationMessages {
|
|
41
|
+
/** Mensaje cuando el valor no alcanza la longitud mínima. */
|
|
42
|
+
minLength?: (minLength: number) => string;
|
|
43
|
+
/** Mensaje cuando el valor supera la longitud máxima. */
|
|
44
|
+
maxLength?: (maxLength: number) => string;
|
|
45
|
+
/** Mensaje cuando el número de tarjeta de crédito es inválido. */
|
|
46
|
+
creditCardInvalid?: string;
|
|
47
|
+
/** Mensaje cuando el RUT chileno es inválido. */
|
|
48
|
+
chileanRutInvalid?: string;
|
|
49
|
+
/** Mensaje cuando la fecha es inválida. */
|
|
50
|
+
dateInvalid?: string;
|
|
51
|
+
/** Mensaje cuando la fecha no cumple el formato esperado. */
|
|
52
|
+
dateInvalidWithFormat?: string;
|
|
53
|
+
/** Mensaje cuando la hora es inválida. */
|
|
54
|
+
timeInvalid?: string;
|
|
55
|
+
/** Mensaje cuando el correo electrónico es inválido. */
|
|
56
|
+
emailInvalid?: string;
|
|
57
|
+
/** Mensaje cuando el valor no cumple el formato personalizado. */
|
|
58
|
+
formatInvalid?: string;
|
|
59
|
+
}
|
|
20
60
|
/**
|
|
21
61
|
* Tipos de formato disponibles para el componente EFWInput.
|
|
22
62
|
* Determina cómo se formatea y valida el contenido del campo de entrada.
|
|
@@ -26,14 +66,46 @@ export type EFWInputValue = string | null | undefined;
|
|
|
26
66
|
* const basicFormat: FormatType = 'none';
|
|
27
67
|
*
|
|
28
68
|
* @example
|
|
29
|
-
* // Para números de teléfono
|
|
30
|
-
* const phoneFormat: FormatType = 'phone';
|
|
31
|
-
*
|
|
32
|
-
* @example
|
|
33
69
|
* // Para RUT chileno
|
|
34
70
|
* const rutFormat: FormatType = 'chileanRut';
|
|
35
71
|
*/
|
|
36
|
-
export type FormatType =
|
|
72
|
+
export type FormatType = "none" | "creditCard" | "chileanRut" | "date" | "custom" | "email" | "time";
|
|
73
|
+
export type EFWInputValidationTarget = "raw" | "formatted";
|
|
74
|
+
export interface EFWInputFormatValidationContext {
|
|
75
|
+
rawValue: string;
|
|
76
|
+
formattedValue: string;
|
|
77
|
+
}
|
|
78
|
+
export interface EFWInputFormatConfig {
|
|
79
|
+
/**
|
|
80
|
+
* Máscara visual. Usa `#` como placeholder de caracteres del valor crudo.
|
|
81
|
+
* Los caracteres estáticos se renderizan como decoración y se consumen del raw
|
|
82
|
+
* cuando coinciden, permitiendo máscaras como `+56 # #### ####` con raw `569...`.
|
|
83
|
+
*/
|
|
84
|
+
mask?: string;
|
|
85
|
+
/**
|
|
86
|
+
* Patrón usado para remover decoración y obtener el valor crudo.
|
|
87
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
88
|
+
*
|
|
89
|
+
* Manejo de entrada inválida: cuando además se define `mask`, un valor que
|
|
90
|
+
* contiene caracteres que `stripPattern` removería pero que NO son decoración
|
|
91
|
+
* de la máscara se considera inválido; en ese caso el texto se conserva tal
|
|
92
|
+
* cual (se refleja en el campo) y se marca como error en lugar de descartarse
|
|
93
|
+
* en silencio. Sin `mask`, `stripPattern` actúa solo como sanitizador y los
|
|
94
|
+
* caracteres que no calzan se eliminan sin feedback.
|
|
95
|
+
*/
|
|
96
|
+
stripPattern?: RegExp | string;
|
|
97
|
+
/**
|
|
98
|
+
* Patrón usado para validar el valor crudo o formateado.
|
|
99
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
100
|
+
*/
|
|
101
|
+
validationPattern?: RegExp | string;
|
|
102
|
+
/** Valor sobre el que se aplican `validationPattern` y `validate`. Default: `raw`. */
|
|
103
|
+
validationTarget?: EFWInputValidationTarget;
|
|
104
|
+
/** Validador avanzado. Retornar string marca inválido y usa ese string como mensaje. */
|
|
105
|
+
validate?: (value: string, context: EFWInputFormatValidationContext) => boolean | string;
|
|
106
|
+
/** Mensaje de error usado cuando falla la validación de este formato. */
|
|
107
|
+
invalidMessage?: string;
|
|
108
|
+
}
|
|
37
109
|
/**
|
|
38
110
|
* Propiedades del componente EFWInput.
|
|
39
111
|
* Extiende las propiedades básicas de los campos EFW con funcionalidades específicas
|
|
@@ -46,7 +118,7 @@ export type FormatType = 'none' | 'phone' | 'creditCard' | 'chileanRut' | 'date'
|
|
|
46
118
|
* // Uso básico
|
|
47
119
|
* const basicProps: EFWInputProps = {
|
|
48
120
|
* value: "ejemplo@email.com",
|
|
49
|
-
* placeholder: "Ingrese su email",
|
|
121
|
+
* labels: { placeholder: "Ingrese su email" },
|
|
50
122
|
* formatType: "email"
|
|
51
123
|
* };
|
|
52
124
|
*
|
|
@@ -99,7 +171,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
99
171
|
* @example
|
|
100
172
|
* autoComplete="off"
|
|
101
173
|
*/
|
|
102
|
-
autoComplete?:
|
|
174
|
+
autoComplete?: "on" | "off";
|
|
103
175
|
/**
|
|
104
176
|
* Valor actual del campo de entrada.
|
|
105
177
|
* Puede ser una cadena de texto o null para campos vacíos.
|
|
@@ -138,7 +210,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
138
210
|
* @example
|
|
139
211
|
* type="tel"
|
|
140
212
|
*/
|
|
141
|
-
type?:
|
|
213
|
+
type?: "text" | "password" | "email" | "number" | "tel";
|
|
142
214
|
/**
|
|
143
215
|
* Clases CSS adicionales aplicadas al componente.
|
|
144
216
|
* Permite personalizar la apariencia del campo de entrada.
|
|
@@ -150,17 +222,6 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
150
222
|
* className="campo-destacado campo-grande"
|
|
151
223
|
*/
|
|
152
224
|
className?: string;
|
|
153
|
-
/**
|
|
154
|
-
* Texto de sugerencia mostrado cuando el campo está vacío.
|
|
155
|
-
* Proporciona una pista visual sobre qué tipo de contenido se espera.
|
|
156
|
-
*
|
|
157
|
-
* @example
|
|
158
|
-
* placeholder="Ingrese su nombre completo"
|
|
159
|
-
*
|
|
160
|
-
* @example
|
|
161
|
-
* placeholder="ejemplo@correo.com"
|
|
162
|
-
*/
|
|
163
|
-
placeholder?: string;
|
|
164
225
|
/**
|
|
165
226
|
* Tipo de formato aplicado automáticamente al valor del campo.
|
|
166
227
|
* Determina cómo se muestra y valida el contenido ingresado.
|
|
@@ -171,15 +232,13 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
171
232
|
* formatType="chileanRut"
|
|
172
233
|
*
|
|
173
234
|
* @example
|
|
174
|
-
* formatType="phone"
|
|
175
|
-
*
|
|
176
|
-
* @example
|
|
177
235
|
* formatType="email"
|
|
178
236
|
*/
|
|
179
237
|
formatType?: FormatType;
|
|
180
238
|
/**
|
|
181
239
|
* Patrón de expresión regular para validación personalizada.
|
|
182
240
|
* Se aplica cuando formatType es "custom" o para validaciones adicionales.
|
|
241
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
183
242
|
*
|
|
184
243
|
* @example
|
|
185
244
|
* formatPattern="^[A-Z]{2}[0-9]{6}$"
|
|
@@ -188,6 +247,20 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
188
247
|
* formatPattern="\\d{4}-\\d{4}-\\d{4}-\\d{4}"
|
|
189
248
|
*/
|
|
190
249
|
formatPattern?: string;
|
|
250
|
+
/**
|
|
251
|
+
* Configuración explícita de formato, normalización y validación.
|
|
252
|
+
* Es la API recomendada para formatos específicos de negocio.
|
|
253
|
+
*
|
|
254
|
+
* @example
|
|
255
|
+
* formatConfig={{
|
|
256
|
+
* mask: '+56 # #### ####',
|
|
257
|
+
* stripPattern: /\D/g,
|
|
258
|
+
* validationPattern: /^569\d{8}$/,
|
|
259
|
+
* validationTarget: 'raw',
|
|
260
|
+
* invalidMessage: 'Ingrese un teléfono móvil chileno válido.'
|
|
261
|
+
* }}
|
|
262
|
+
*/
|
|
263
|
+
formatConfig?: EFWInputFormatConfig;
|
|
191
264
|
/**
|
|
192
265
|
* Controla si el usuario puede editar el contenido del campo.
|
|
193
266
|
* Cuando es false, el campo se muestra como texto de solo lectura.
|
|
@@ -244,11 +317,33 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
244
317
|
* }}
|
|
245
318
|
*/
|
|
246
319
|
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
320
|
+
/**
|
|
321
|
+
* Textos personalizables de la UI del campo.
|
|
322
|
+
*
|
|
323
|
+
* @example
|
|
324
|
+
* labels={{ placeholder: "Ingrese su nombre", emptyState: "Sin valor" }}
|
|
325
|
+
*/
|
|
326
|
+
labels?: EFWInputLabels;
|
|
327
|
+
/**
|
|
328
|
+
* Renderiza contenido custom cuando `editable={false}`.
|
|
329
|
+
* Si retorna `null` o `undefined`, se utiliza el render no editable por defecto.
|
|
330
|
+
*/
|
|
331
|
+
readOnlyRenderer?: EFWInputNonEditableRenderer;
|
|
332
|
+
/**
|
|
333
|
+
* Mensajes de error personalizados para cada tipo de validación.
|
|
334
|
+
*
|
|
335
|
+
* @example
|
|
336
|
+
* validationMessages={{ emailInvalid: "Correo no válido", minLength: (n) => `Mínimo ${n} caracteres` }}
|
|
337
|
+
*/
|
|
338
|
+
validationMessages?: EFWInputValidationMessages;
|
|
247
339
|
/**
|
|
248
340
|
* Callback ejecutado cuando el valor del campo cambia.
|
|
249
341
|
* Recibe tanto el valor sin formato como el valor mostrado al usuario.
|
|
250
342
|
*
|
|
251
|
-
* @param value - Valor crudo
|
|
343
|
+
* @param value - Valor crudo normalizado (emisión real: `string`).
|
|
344
|
+
* Nota: el valor crudo solo está garantizado sin decoración cuando es válido.
|
|
345
|
+
* Para entradas inválidas con `mask` + `stripPattern`, se emite el texto tal
|
|
346
|
+
* como se ingresó (puede incluir decoración) para reflejarlo y marcar el error.
|
|
252
347
|
* @param displayValue - Valor formateado mostrado en el campo
|
|
253
348
|
*
|
|
254
349
|
* @example
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { EFWInputFormatConfig, EFWInputValue, FormatType } from './EFWInput.types';
|
|
2
|
+
|
|
3
|
+
export interface FormatOptions {
|
|
4
|
+
formatPattern?: string;
|
|
5
|
+
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
6
|
+
formatConfig?: EFWInputFormatConfig;
|
|
7
|
+
}
|
|
8
|
+
export interface InputFormatValidationResult {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
message?: string;
|
|
11
|
+
}
|
|
12
|
+
export declare const validateChileanRut: (rutCompleto: string) => boolean;
|
|
13
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
14
|
+
export declare const validateTime: (time: string) => boolean;
|
|
15
|
+
export declare const toRegExp: (pattern: RegExp | string) => RegExp | undefined;
|
|
16
|
+
/**
|
|
17
|
+
* Verifica si un valor contiene solo caracteres válidos para aplicar formato visual.
|
|
18
|
+
*/
|
|
19
|
+
export declare const isFormattableValue: (value: string, formatType: FormatType) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Aplica una máscara visual usando `#` como placeholder de caracteres del raw.
|
|
22
|
+
* Los caracteres estáticos se consumen del raw si coinciden, lo que permite que
|
|
23
|
+
* una máscara con prefijo (`+56 # ...`) funcione con raw que incluye el prefijo (`569...`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const applyMask: (rawValue: string, mask: string) => string;
|
|
26
|
+
/**
|
|
27
|
+
* Determina si un valor contiene caracteres que `stripPattern` eliminaría pero
|
|
28
|
+
* que NO forman parte de la decoración estática de la máscara.
|
|
29
|
+
*
|
|
30
|
+
* Esos caracteres se consideran "inválidos": en lugar de descartarlos en
|
|
31
|
+
* silencio (lo que dejaba el campo vacío y sin feedback), deben conservarse y
|
|
32
|
+
* mostrarse tal como se ingresaron para que el campo pueda marcar el error.
|
|
33
|
+
*
|
|
34
|
+
* Solo se evalúan los caracteres que el `stripPattern` removería, por lo que el
|
|
35
|
+
* solapamiento entre dígitos de payload y dígitos usados como decoración en la
|
|
36
|
+
* máscara (p. ej. `+56`) no produce falsos positivos: esos dígitos válidos no
|
|
37
|
+
* son removidos por un `stripPattern` como `/\D/g` y por ende nunca se evalúan.
|
|
38
|
+
*
|
|
39
|
+
* La comparación contra la decoración es sensible a mayúsculas/minúsculas: con
|
|
40
|
+
* una máscara con letras (p. ej. `NV-####`) un carácter con distinta caja que el
|
|
41
|
+
* de la máscara se considera inválido. Es el comportamiento esperado para
|
|
42
|
+
* surfacing de errores de tipeo.
|
|
43
|
+
*/
|
|
44
|
+
export declare const hasInvalidMaskCharacters: (value: string, stripPattern: RegExp, mask: string) => boolean;
|
|
45
|
+
export declare const stripInputValue: (value: string, formatType: FormatType, formatConfig?: EFWInputFormatConfig) => string;
|
|
46
|
+
export declare const applyInputFormatting: (value: string, formatType: FormatType, options?: FormatOptions) => string;
|
|
47
|
+
/**
|
|
48
|
+
* Quita el formato de un valor según el tipo especificado
|
|
49
|
+
*/
|
|
50
|
+
export declare const stripFormatting: (value: string, formatType: FormatType, formatConfig?: EFWInputFormatConfig) => string;
|
|
51
|
+
/**
|
|
52
|
+
* Aplica formato a un valor según el tipo y opciones especificadas
|
|
53
|
+
*/
|
|
54
|
+
export declare const applyFormatting: (value: string, formatType: FormatType, options?: FormatOptions) => string;
|
|
55
|
+
export declare const validateInputFormat: ({ rawValue, formattedValue, formatConfig, defaultMessage, }: {
|
|
56
|
+
rawValue: string;
|
|
57
|
+
formattedValue: string;
|
|
58
|
+
formatConfig?: EFWInputFormatConfig;
|
|
59
|
+
defaultMessage: string;
|
|
60
|
+
}) => InputFormatValidationResult;
|
|
61
|
+
/**
|
|
62
|
+
* Crea un predicado que determina si un carácter forma parte del "payload"
|
|
63
|
+
* (los datos reales que escribe la persona) o si es decoración estática que el
|
|
64
|
+
* formato inserta.
|
|
65
|
+
*
|
|
66
|
+
* Devuelve `null` cuando el formato no permite un mapeo confiable de caret
|
|
67
|
+
* (p. ej. `formatType="custom"` con una `formatFunction` arbitraria), en cuyo
|
|
68
|
+
* caso el llamador debe abstenerse de reposicionar el caret.
|
|
69
|
+
*
|
|
70
|
+
* Notas sobre solapamiento decoración/payload: en máscaras como `+56 # #### ####`
|
|
71
|
+
* los dígitos del prefijo (`5`, `6`) se consideran payload por el `stripPattern`
|
|
72
|
+
* (`/\\D/g`). Esto es intencional y consistente: se cuentan igual en el texto
|
|
73
|
+
* tecleado y en el formateado, por lo que el mapeo de caret no se desbalancea.
|
|
74
|
+
*/
|
|
75
|
+
export declare const createPayloadCharTester: (formatType: FormatType, options?: FormatOptions) => ((char: string) => boolean) | null;
|
|
76
|
+
/**
|
|
77
|
+
* Calcula la posición de caret en `nextFormatted` tras una edición, preservando
|
|
78
|
+
* la posición lógica respecto al payload que la persona está editando.
|
|
79
|
+
*
|
|
80
|
+
* Delega el cálculo en `computeCaretAfterReformat` (core compartido en commons),
|
|
81
|
+
* resolviendo primero el predicado de payload propio del `formatType`.
|
|
82
|
+
*
|
|
83
|
+
* Devuelve `null` cuando el formato no permite un mapeo confiable; en ese caso
|
|
84
|
+
* el llamador debe dejar el comportamiento por defecto del navegador.
|
|
85
|
+
*/
|
|
86
|
+
export declare const computeFormattedCaretPosition: ({ previousCaret, typedValue, nextFormatted, formatType, formatOptions, }: {
|
|
87
|
+
previousCaret: number;
|
|
88
|
+
typedValue: string;
|
|
89
|
+
nextFormatted: string;
|
|
90
|
+
formatType: FormatType;
|
|
91
|
+
formatOptions?: FormatOptions;
|
|
92
|
+
}) => number | null;
|
|
93
|
+
/**
|
|
94
|
+
* Retorna el valor formateado que EFWInput muestra cuando no está en modo editable.
|
|
95
|
+
* Combina stripFormatting + applyFormatting en una sola llamada.
|
|
96
|
+
*/
|
|
97
|
+
export declare const getInputFormattedValue: (value: EFWInputValue, formatType?: FormatType, options?: {
|
|
98
|
+
formatPattern?: string;
|
|
99
|
+
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
100
|
+
formatConfig?: EFWInputFormatConfig;
|
|
101
|
+
}) => string;
|