@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
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { computeCaretAfterReformat as p } from "../../commons/caretPositioning.js";
|
|
2
|
+
const P = (t) => {
|
|
3
|
+
const r = (t || "").toString(), e = r.replace(/^0+/, "");
|
|
4
|
+
let n = "";
|
|
5
|
+
if (e != "" && e.length > 1) {
|
|
6
|
+
const s = e.replace(/\./g, "").replace(/-/g, ""), a = s.substring(0, s.length - 1);
|
|
7
|
+
let c = 0, o = 1;
|
|
8
|
+
for (c = a.length - 1; c >= 0; c--)
|
|
9
|
+
n = a.charAt(c) + n, o % 3 == 0 && o <= a.length - 1 && (n = "." + n), o++;
|
|
10
|
+
const h = s.substring(s.length - 1);
|
|
11
|
+
return n = n + "-" + h, n;
|
|
12
|
+
} else
|
|
13
|
+
return r;
|
|
14
|
+
}, w = (t) => {
|
|
15
|
+
const r = (t || "").replace(/\./g, "").replace(/‐/g, "-");
|
|
16
|
+
if (!/^[0-9]+-?[0-9kK]{1}$/.test(r)) return !1;
|
|
17
|
+
const e = r.includes("-") ? r.split("-") : [r.slice(0, -1), r.slice(-1)];
|
|
18
|
+
let n = e[1];
|
|
19
|
+
const i = e[0];
|
|
20
|
+
if (!i || !n) return !1;
|
|
21
|
+
const s = (a) => {
|
|
22
|
+
let c = 0, o = 1;
|
|
23
|
+
for (; a; a = Math.floor(a / 10))
|
|
24
|
+
o = (o + a % 10 * (9 - c++ % 6)) % 11;
|
|
25
|
+
return o ? o - 1 : "k";
|
|
26
|
+
};
|
|
27
|
+
return n == "K" && (n = "k"), s(i) == n;
|
|
28
|
+
}, E = (t) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t), b = (t) => /^([01]?[0-9]|2[0-3]):[0-5][0-9]$/.test(t), l = (t) => {
|
|
29
|
+
if (t instanceof RegExp)
|
|
30
|
+
return t;
|
|
31
|
+
try {
|
|
32
|
+
return new RegExp(t);
|
|
33
|
+
} catch {
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
}, f = {
|
|
37
|
+
none: /^.*$/,
|
|
38
|
+
email: /^.*$/,
|
|
39
|
+
creditCard: /^\d*$/,
|
|
40
|
+
chileanRut: /^[\dkK-]*$/i,
|
|
41
|
+
date: /^\d*$/,
|
|
42
|
+
time: /^\d*$/,
|
|
43
|
+
custom: /^.*$/
|
|
44
|
+
}, R = (t, r) => (f[r] ?? f.none).test(
|
|
45
|
+
t
|
|
46
|
+
), u = {
|
|
47
|
+
none: (t) => t,
|
|
48
|
+
email: (t) => t,
|
|
49
|
+
creditCard: (t) => t.replace(/ /g, ""),
|
|
50
|
+
chileanRut: (t) => {
|
|
51
|
+
const r = t.replace(/\./g, "");
|
|
52
|
+
if (!f.chileanRut.test(r))
|
|
53
|
+
return r;
|
|
54
|
+
const e = r.includes("-"), n = r.replace(/-/g, "");
|
|
55
|
+
if (e && n.length >= 2) {
|
|
56
|
+
const i = n.length - 1;
|
|
57
|
+
return n.slice(0, i) + "-" + n.slice(i);
|
|
58
|
+
}
|
|
59
|
+
return n;
|
|
60
|
+
},
|
|
61
|
+
date: (t) => t.replace(/\//g, ""),
|
|
62
|
+
custom: (t) => t,
|
|
63
|
+
time: (t) => t.replace(/:/g, "")
|
|
64
|
+
}, $ = (t, r) => {
|
|
65
|
+
if (!t || !r) return "";
|
|
66
|
+
let e = "", n = 0;
|
|
67
|
+
for (let i = 0; i < r.length && n < t.length; i++) {
|
|
68
|
+
const s = r[i], a = t[n];
|
|
69
|
+
if (s === "#") {
|
|
70
|
+
e += a, n++;
|
|
71
|
+
continue;
|
|
72
|
+
}
|
|
73
|
+
e += s, a === s && n++;
|
|
74
|
+
}
|
|
75
|
+
return n === t.length ? e : t;
|
|
76
|
+
}, m = (t, r, e) => {
|
|
77
|
+
if (!t || !e) return !1;
|
|
78
|
+
const n = /* @__PURE__ */ new Set();
|
|
79
|
+
for (const s of e)
|
|
80
|
+
s !== "#" && n.add(s);
|
|
81
|
+
const i = new RegExp(
|
|
82
|
+
r.source,
|
|
83
|
+
r.flags.replace(/[gy]/g, "")
|
|
84
|
+
);
|
|
85
|
+
for (const s of t)
|
|
86
|
+
if (i.test(s) && !n.has(s))
|
|
87
|
+
return !0;
|
|
88
|
+
return !1;
|
|
89
|
+
}, F = (t, r, e) => {
|
|
90
|
+
if (!t) return "";
|
|
91
|
+
if (e?.stripPattern) {
|
|
92
|
+
const i = l(e.stripPattern);
|
|
93
|
+
return !i || e.mask && m(t, i, e.mask) ? t : t.replace(i, "");
|
|
94
|
+
}
|
|
95
|
+
return (u[r] || u.none)(t);
|
|
96
|
+
}, d = {
|
|
97
|
+
none: (t) => t,
|
|
98
|
+
email: (t) => t,
|
|
99
|
+
creditCard: (t) => t.length > 19 ? t : t.replace(/(\d{4})(?=\d)/g, "$1 ").trim(),
|
|
100
|
+
chileanRut: (t) => P(t),
|
|
101
|
+
date: (t) => t.length > 8 || t.length <= 2 ? t : t.length <= 4 ? `${t.slice(0, 2)}/${t.slice(2)}` : `${t.slice(0, 2)}/${t.slice(2, 4)}/${t.slice(4)}`,
|
|
102
|
+
// number: (value) => {
|
|
103
|
+
// if (isNaN(Number(value))) return value; // Si no es un número válido, retornar el valor original
|
|
104
|
+
// return formatNumber(value)
|
|
105
|
+
// },
|
|
106
|
+
time: (t) => t.length > 4 || t.length <= 2 ? t : `${t.slice(0, 2)}:${t.slice(2)}`,
|
|
107
|
+
custom: (t, r = {}) => {
|
|
108
|
+
if (r.formatFunction)
|
|
109
|
+
return r.formatFunction(t) || t;
|
|
110
|
+
if (r.formatPattern) {
|
|
111
|
+
let e = "", n = 0;
|
|
112
|
+
for (let i = 0; i < r.formatPattern.length && n < t.length; i++)
|
|
113
|
+
r.formatPattern[i] === "#" ? (e += t[n], n++) : (e += r.formatPattern[i], r.formatPattern[i] === t[n] && n++);
|
|
114
|
+
return n === t.length ? e : t;
|
|
115
|
+
}
|
|
116
|
+
return t;
|
|
117
|
+
}
|
|
118
|
+
}, k = (t, r, e = {}) => {
|
|
119
|
+
if (!t) return "";
|
|
120
|
+
if (e.formatConfig?.mask) {
|
|
121
|
+
const i = e.formatConfig.stripPattern ? l(e.formatConfig.stripPattern) : void 0;
|
|
122
|
+
return i && m(t, i, e.formatConfig.mask) ? t : $(t, e.formatConfig.mask);
|
|
123
|
+
}
|
|
124
|
+
return R(t, r) ? (d[r] || d.none)(t, e) : t;
|
|
125
|
+
}, x = (t, r, e) => F(t, r, e), y = (t, r, e = {}) => k(t, r, e), A = ({
|
|
126
|
+
rawValue: t,
|
|
127
|
+
formattedValue: r,
|
|
128
|
+
formatConfig: e,
|
|
129
|
+
defaultMessage: n
|
|
130
|
+
}) => {
|
|
131
|
+
if (!e || t.length === 0)
|
|
132
|
+
return { valid: !0 };
|
|
133
|
+
const i = e.validationTarget === "formatted" ? r : t, s = e.invalidMessage ?? n;
|
|
134
|
+
if (e.validate) {
|
|
135
|
+
const a = e.validate(i, {
|
|
136
|
+
rawValue: t,
|
|
137
|
+
formattedValue: r
|
|
138
|
+
});
|
|
139
|
+
return typeof a == "string" ? { valid: !1, message: a } : a ? { valid: !0 } : { valid: !1, message: s };
|
|
140
|
+
}
|
|
141
|
+
if (e.validationPattern) {
|
|
142
|
+
const a = l(e.validationPattern);
|
|
143
|
+
return a ? a.test(i) ? { valid: !0 } : { valid: !1, message: s } : { valid: !1, message: s };
|
|
144
|
+
}
|
|
145
|
+
return { valid: !0 };
|
|
146
|
+
}, g = (t) => {
|
|
147
|
+
const r = /* @__PURE__ */ new Set();
|
|
148
|
+
for (const e of t)
|
|
149
|
+
e !== "#" && r.add(e);
|
|
150
|
+
return r;
|
|
151
|
+
}, C = (t, r = {}) => {
|
|
152
|
+
const { formatConfig: e, formatPattern: n, formatFunction: i } = r;
|
|
153
|
+
if (e?.stripPattern) {
|
|
154
|
+
const s = l(e.stripPattern);
|
|
155
|
+
if (!s) return null;
|
|
156
|
+
const a = new RegExp(
|
|
157
|
+
s.source,
|
|
158
|
+
s.flags.replace(/[gy]/g, "")
|
|
159
|
+
);
|
|
160
|
+
return (c) => !a.test(c);
|
|
161
|
+
}
|
|
162
|
+
if (e?.mask) {
|
|
163
|
+
const s = g(e.mask);
|
|
164
|
+
return (a) => !s.has(a);
|
|
165
|
+
}
|
|
166
|
+
switch (t) {
|
|
167
|
+
case "creditCard":
|
|
168
|
+
return (s) => s !== " ";
|
|
169
|
+
case "date":
|
|
170
|
+
return (s) => s !== "/";
|
|
171
|
+
case "time":
|
|
172
|
+
return (s) => s !== ":";
|
|
173
|
+
case "chileanRut":
|
|
174
|
+
return (s) => s !== "." && s !== "-";
|
|
175
|
+
case "custom":
|
|
176
|
+
if (i) return null;
|
|
177
|
+
if (n) {
|
|
178
|
+
const s = g(n);
|
|
179
|
+
return (a) => !s.has(a);
|
|
180
|
+
}
|
|
181
|
+
return null;
|
|
182
|
+
default:
|
|
183
|
+
return null;
|
|
184
|
+
}
|
|
185
|
+
}, S = ({
|
|
186
|
+
previousCaret: t,
|
|
187
|
+
typedValue: r,
|
|
188
|
+
nextFormatted: e,
|
|
189
|
+
formatType: n,
|
|
190
|
+
formatOptions: i
|
|
191
|
+
}) => {
|
|
192
|
+
const s = C(
|
|
193
|
+
n,
|
|
194
|
+
i ?? {}
|
|
195
|
+
);
|
|
196
|
+
return s ? p({
|
|
197
|
+
previousCaret: t,
|
|
198
|
+
typedValue: r,
|
|
199
|
+
nextFormatted: e,
|
|
200
|
+
isPayloadChar: s
|
|
201
|
+
}) : null;
|
|
202
|
+
}, z = (t, r = "none", e) => {
|
|
203
|
+
const n = x(t ?? "", r, e?.formatConfig);
|
|
204
|
+
return y(n, r, e ?? {});
|
|
205
|
+
};
|
|
206
|
+
export {
|
|
207
|
+
y as applyFormatting,
|
|
208
|
+
k as applyInputFormatting,
|
|
209
|
+
$ as applyMask,
|
|
210
|
+
S as computeFormattedCaretPosition,
|
|
211
|
+
C as createPayloadCharTester,
|
|
212
|
+
z as getInputFormattedValue,
|
|
213
|
+
m as hasInvalidMaskCharacters,
|
|
214
|
+
R as isFormattableValue,
|
|
215
|
+
x as stripFormatting,
|
|
216
|
+
F as stripInputValue,
|
|
217
|
+
l as toRegExp,
|
|
218
|
+
w as validateChileanRut,
|
|
219
|
+
E as validateEmail,
|
|
220
|
+
A as validateInputFormat,
|
|
221
|
+
b as validateTime
|
|
222
|
+
};
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EFWInputFormatConfig, EFWInputValidationMessages, FormatType } from './EFWInput.types';
|
|
2
|
+
import { FormatOptions } from './EFWInput.utils';
|
|
3
|
+
|
|
4
|
+
export interface InputValidationResult {
|
|
5
|
+
hasError: boolean;
|
|
6
|
+
message: string;
|
|
7
|
+
}
|
|
8
|
+
interface ResolveInputValidationStateOptions {
|
|
9
|
+
rawValue: string;
|
|
10
|
+
formatType: FormatType;
|
|
11
|
+
formatPattern?: string;
|
|
12
|
+
formatConfig?: EFWInputFormatConfig;
|
|
13
|
+
minLength: number;
|
|
14
|
+
maxLength: number;
|
|
15
|
+
messages: Required<EFWInputValidationMessages>;
|
|
16
|
+
formatOptions?: FormatOptions;
|
|
17
|
+
}
|
|
18
|
+
export declare const validateLegacyFormatPattern: (value: string, formatPattern?: string) => boolean;
|
|
19
|
+
export declare const resolveInputValidationState: ({ rawValue, formatType, formatPattern, formatConfig, minLength, maxLength, messages, formatOptions, }: ResolveInputValidationStateOptions) => InputValidationResult;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { isFormattableValue as m, applyFormatting as h, validateInputFormat as u, hasInvalidMaskCharacters as I, validateTime as E, validateEmail as p, validateChileanRut as F, toRegExp as v } from "./EFWInput.utils.js";
|
|
2
|
+
const R = (t, r) => {
|
|
3
|
+
if (!r) return !0;
|
|
4
|
+
const e = v(r);
|
|
5
|
+
return e ? e.test(t) : !1;
|
|
6
|
+
}, f = (t, r) => ({
|
|
7
|
+
creditCard: r.creditCardInvalid,
|
|
8
|
+
chileanRut: r.chileanRutInvalid,
|
|
9
|
+
date: r.dateInvalid,
|
|
10
|
+
time: r.timeInvalid
|
|
11
|
+
})[t] ?? r.formatInvalid, M = {
|
|
12
|
+
chileanRut: (t, r) => t.length > 0 && !F(t) ? { hasError: !0, message: r.chileanRutInvalid } : void 0,
|
|
13
|
+
creditCard: (t, r) => t.length > 0 && (t.length < 13 || t.length > 19) ? { hasError: !0, message: r.creditCardInvalid } : void 0,
|
|
14
|
+
date: (t, r) => t.length > 0 && t.length !== 8 ? { hasError: !0, message: r.dateInvalidWithFormat } : void 0,
|
|
15
|
+
email: (t, r) => t.length > 0 && !p(t) ? { hasError: !0, message: r.emailInvalid } : void 0,
|
|
16
|
+
time: (t, r) => {
|
|
17
|
+
const e = h(t, "time", {});
|
|
18
|
+
return t.length > 0 && (t.length !== 4 || !E(e)) ? { hasError: !0, message: r.timeInvalid } : void 0;
|
|
19
|
+
}
|
|
20
|
+
}, b = (t, r, e) => M[r]?.(t, e), k = ({
|
|
21
|
+
rawValue: t,
|
|
22
|
+
formatType: r,
|
|
23
|
+
formatPattern: e,
|
|
24
|
+
formatConfig: a,
|
|
25
|
+
minLength: n,
|
|
26
|
+
maxLength: d,
|
|
27
|
+
messages: i,
|
|
28
|
+
formatOptions: c = {}
|
|
29
|
+
}) => {
|
|
30
|
+
if (n > 0 && t.length > 0 && t.length < n)
|
|
31
|
+
return { hasError: !0, message: i.minLength(n) };
|
|
32
|
+
if (t.length > d)
|
|
33
|
+
return { hasError: !0, message: i.maxLength(d) };
|
|
34
|
+
if (t.length > 0 && !a?.stripPattern && !m(t, r))
|
|
35
|
+
return {
|
|
36
|
+
hasError: !0,
|
|
37
|
+
message: f(r, i)
|
|
38
|
+
};
|
|
39
|
+
const g = h(t, r, c), l = u({
|
|
40
|
+
rawValue: t,
|
|
41
|
+
formattedValue: g,
|
|
42
|
+
formatConfig: a,
|
|
43
|
+
defaultMessage: i.formatInvalid
|
|
44
|
+
});
|
|
45
|
+
if (!l.valid)
|
|
46
|
+
return {
|
|
47
|
+
hasError: !0,
|
|
48
|
+
message: l.message ?? i.formatInvalid
|
|
49
|
+
};
|
|
50
|
+
const s = b(
|
|
51
|
+
t,
|
|
52
|
+
r,
|
|
53
|
+
i
|
|
54
|
+
);
|
|
55
|
+
if (s)
|
|
56
|
+
return s;
|
|
57
|
+
if (!R(t, e))
|
|
58
|
+
return { hasError: !0, message: i.formatInvalid };
|
|
59
|
+
if (t.length > 0 && a?.mask && a?.stripPattern) {
|
|
60
|
+
const o = v(a.stripPattern);
|
|
61
|
+
if (o && I(t, o, a.mask))
|
|
62
|
+
return {
|
|
63
|
+
hasError: !0,
|
|
64
|
+
message: a.invalidMessage ?? i.formatInvalid
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
return { hasError: !1, message: "" };
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
k as resolveInputValidationState,
|
|
71
|
+
R as validateLegacyFormatPattern
|
|
72
|
+
};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { EFWField as O } from "../_shared/EFWField/EFWField.js";
|
|
3
|
+
import { EFWInput as R } from "./EFWInput.js";
|
|
4
|
+
import { mergeClasses as S } from "@griffel/react";
|
|
5
|
+
const H = (a) => {
|
|
6
|
+
const {
|
|
7
|
+
title: n,
|
|
8
|
+
infoLabel: o,
|
|
9
|
+
hint: i,
|
|
10
|
+
style: l = {},
|
|
11
|
+
size: s,
|
|
12
|
+
className: r,
|
|
13
|
+
required: d = !1,
|
|
14
|
+
contentBefore: f,
|
|
15
|
+
contentAfter: m,
|
|
16
|
+
minLength: g = 0,
|
|
17
|
+
maxLength: p = 250,
|
|
18
|
+
validationState: u,
|
|
19
|
+
validationMessage: c,
|
|
20
|
+
validationMessageIcon: h,
|
|
21
|
+
value: C,
|
|
22
|
+
defaultValue: b,
|
|
23
|
+
editable: e = !0,
|
|
24
|
+
disabled: F = !1,
|
|
25
|
+
hidden: v = !1,
|
|
26
|
+
onChange: x,
|
|
27
|
+
autoComplete: y = "off",
|
|
28
|
+
type: L = "text",
|
|
29
|
+
formatType: E = "none",
|
|
30
|
+
formatPattern: I,
|
|
31
|
+
formatFunction: M,
|
|
32
|
+
formatConfig: N,
|
|
33
|
+
labels: W,
|
|
34
|
+
readOnlyRenderer: w,
|
|
35
|
+
validationMessages: P,
|
|
36
|
+
onValidationChange: V,
|
|
37
|
+
...j
|
|
38
|
+
} = a, q = (A, B) => {
|
|
39
|
+
x?.(A, B);
|
|
40
|
+
}, z = S(r, "efw-input-field");
|
|
41
|
+
return /* @__PURE__ */ t(
|
|
42
|
+
O,
|
|
43
|
+
{
|
|
44
|
+
className: z,
|
|
45
|
+
style: l,
|
|
46
|
+
title: n,
|
|
47
|
+
infoLabel: o,
|
|
48
|
+
weightLabel: e ? "regular" : "semibold",
|
|
49
|
+
hint: i,
|
|
50
|
+
size: s,
|
|
51
|
+
required: d,
|
|
52
|
+
validationState: u,
|
|
53
|
+
validationMessage: c,
|
|
54
|
+
validationMessageIcon: h,
|
|
55
|
+
onValidationChange: V,
|
|
56
|
+
hidden: v,
|
|
57
|
+
...j,
|
|
58
|
+
children: /* @__PURE__ */ t(
|
|
59
|
+
R,
|
|
60
|
+
{
|
|
61
|
+
value: C,
|
|
62
|
+
defaultValue: b,
|
|
63
|
+
editable: e,
|
|
64
|
+
onChange: q,
|
|
65
|
+
minLength: g,
|
|
66
|
+
maxLength: p,
|
|
67
|
+
disabled: F,
|
|
68
|
+
autoComplete: y,
|
|
69
|
+
type: L,
|
|
70
|
+
contentBefore: f,
|
|
71
|
+
contentAfter: m,
|
|
72
|
+
formatType: E,
|
|
73
|
+
formatPattern: I,
|
|
74
|
+
formatFunction: M,
|
|
75
|
+
formatConfig: N,
|
|
76
|
+
labels: W,
|
|
77
|
+
readOnlyRenderer: w,
|
|
78
|
+
validationMessages: P
|
|
79
|
+
}
|
|
80
|
+
)
|
|
81
|
+
}
|
|
82
|
+
);
|
|
83
|
+
};
|
|
84
|
+
export {
|
|
85
|
+
H as EFWInputField
|
|
86
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EFWFieldProps } from '../EFWField/EFWField.types';
|
|
2
|
-
import { EFWInputProps, EFWInputValue } from '
|
|
1
|
+
import { EFWFieldProps } from '../_shared/EFWField/EFWField.types';
|
|
2
|
+
import { EFWInputProps, EFWInputValue } from './EFWInput.types';
|
|
3
3
|
|
|
4
4
|
export type EFWInputFieldValue = EFWInputValue;
|
|
5
5
|
export interface EFWInputFieldProps extends Omit<EFWFieldProps, 'children'>, EFWInputProps {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EFWInput } from './EFWInput';
|
|
2
|
+
export { getInputFormattedValue } from './EFWInput.utils';
|
|
3
|
+
export type { EFWInputProps, EFWInputValue, EFWInputNonEditableRenderer, EFWInputFormatConfig, EFWInputFormatValidationContext, EFWInputValidationTarget, } from './EFWInput.types';
|
|
4
|
+
export { EFWInputField } from './EFWInputField';
|
|
5
|
+
export type { EFWInputFieldProps, EFWInputFieldValue, } from './EFWInputField.types';
|