@envisiongroup/porygon 1.0.0-rc.8 → 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,339 @@
|
|
|
1
|
+
import { jsx as O, Fragment as Re } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as Fe, tokens as P, mergeClasses as Pe, Text as Me, Input as De } from "@fluentui/react-components";
|
|
3
|
+
import { useId as ke, useRef as U, useMemo as E, useCallback as D, useState as j } from "react";
|
|
4
|
+
import { stripFormatting as k, getNumberInputFormattedValue as H, isValidNumber as pe, applyFormatting as $, createNumberPayloadCharTester as Te } from "./EFWNumberInput.utils.js";
|
|
5
|
+
import { computeCaretAfterReformat as Be } from "../../commons/caretPositioning.js";
|
|
6
|
+
import { useIsomorphicLayoutEffect as We } from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
|
|
7
|
+
import { useFieldsLocaleText as ze } from "../../i18n/PorygonI18nProvider.js";
|
|
8
|
+
const Le = Fe({
|
|
9
|
+
EFWNumberInputError: {
|
|
10
|
+
backgroundColor: P.colorPaletteRedBackground1,
|
|
11
|
+
"::after": {
|
|
12
|
+
borderBottomColor: P.colorPaletteRedBorder2,
|
|
13
|
+
borderBottomStyle: "solid",
|
|
14
|
+
borderBottomWidth: "2px"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
EFWNumberInput: {
|
|
18
|
+
"& [disabled]": {
|
|
19
|
+
backgroundColor: P.colorNeutralBackground3,
|
|
20
|
+
color: P.colorNeutralForeground2,
|
|
21
|
+
"&::placeholder": {
|
|
22
|
+
color: "transparent"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"&:has(span + [disabled])": {
|
|
26
|
+
backgroundColor: P.colorNeutralBackground3
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
}), Ae = () => {
|
|
30
|
+
const i = /* @__PURE__ */ new Map();
|
|
31
|
+
return (o, g) => {
|
|
32
|
+
const a = `${o}-${g}`;
|
|
33
|
+
if (!i.has(a)) {
|
|
34
|
+
const N = o.replace(
|
|
35
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
36
|
+
"\\$&"
|
|
37
|
+
), V = g.replace(
|
|
38
|
+
/[.*+?^${}()|[\]\\]/g,
|
|
39
|
+
"\\$&"
|
|
40
|
+
);
|
|
41
|
+
i.set(a, {
|
|
42
|
+
validation: new RegExp(
|
|
43
|
+
`^-?[\\d${N}]*${V}?\\d*$`
|
|
44
|
+
),
|
|
45
|
+
thousandSeparator: new RegExp(`^\\d+${N}0{1,2}$`),
|
|
46
|
+
progressPatterns: [
|
|
47
|
+
/^-?$/,
|
|
48
|
+
new RegExp(`^-?\\d+${V}$`),
|
|
49
|
+
new RegExp(`^-?\\d+${V}0+$`),
|
|
50
|
+
new RegExp(`^-?[\\d${N}]+${V}$`),
|
|
51
|
+
new RegExp(`^-?[\\d${N}]+${V}0+$`)
|
|
52
|
+
]
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
return i.get(a);
|
|
56
|
+
};
|
|
57
|
+
}, Oe = Ae(), fe = (i, o) => o.some((g) => g.test(i)), Ue = (i, o) => i.includes(o) && (i.endsWith("0") || i.endsWith(o) || /\.\d*0$/.test(i.replace(o, "."))), Ze = (i) => {
|
|
58
|
+
const {
|
|
59
|
+
value: o,
|
|
60
|
+
defaultValue: g,
|
|
61
|
+
onChange: a,
|
|
62
|
+
editable: N = !0,
|
|
63
|
+
disabled: V = !1,
|
|
64
|
+
className: be = "",
|
|
65
|
+
autoComplete: ge = "off",
|
|
66
|
+
contentBefore: Ve,
|
|
67
|
+
contentAfter: he,
|
|
68
|
+
formatType: c = "number",
|
|
69
|
+
maxValue: C,
|
|
70
|
+
minValue: I,
|
|
71
|
+
validationState: ve = "none",
|
|
72
|
+
setParentComponentState: m,
|
|
73
|
+
enableFormatting: q = !0,
|
|
74
|
+
thousandSeparator: y = ",",
|
|
75
|
+
decimalSeparator: p = ".",
|
|
76
|
+
labels: G,
|
|
77
|
+
readOnlyRenderer: Ne,
|
|
78
|
+
validationMessages: T
|
|
79
|
+
} = i, w = g ?? null, J = Le(), K = ke(), Q = U(null), B = U(
|
|
80
|
+
null
|
|
81
|
+
), W = o !== void 0, M = W ? o ?? null : g ?? null, l = E(
|
|
82
|
+
() => ({
|
|
83
|
+
enableFormatting: q,
|
|
84
|
+
thousandSeparator: y,
|
|
85
|
+
decimalSeparator: p
|
|
86
|
+
}),
|
|
87
|
+
[q, y, p]
|
|
88
|
+
), X = ze(), Y = X.numberInput.labels, z = X.numberInput.validationMessages, Z = Y.placeholder, _ = Y.emptyState, ee = G?.placeholder, te = G?.emptyState, re = E(() => ({
|
|
89
|
+
placeholder: ee ?? Z,
|
|
90
|
+
emptyState: te ?? _
|
|
91
|
+
}), [
|
|
92
|
+
ee,
|
|
93
|
+
te,
|
|
94
|
+
Z,
|
|
95
|
+
_
|
|
96
|
+
]), ae = z.invalidNumber, le = z.minValue, ne = z.maxValue, oe = T?.invalidNumber, se = T?.minValue, ue = T?.maxValue, S = E(() => ({
|
|
97
|
+
invalidNumber: oe ?? ae,
|
|
98
|
+
minValue: se ?? le,
|
|
99
|
+
maxValue: ue ?? ne
|
|
100
|
+
}), [
|
|
101
|
+
oe,
|
|
102
|
+
se,
|
|
103
|
+
ue,
|
|
104
|
+
ae,
|
|
105
|
+
le,
|
|
106
|
+
ne
|
|
107
|
+
]), R = D(
|
|
108
|
+
(t) => t === null ? "" : k(t.toString(), c, l),
|
|
109
|
+
[c, l]
|
|
110
|
+
), ye = E(
|
|
111
|
+
() => R(M),
|
|
112
|
+
[R, M]
|
|
113
|
+
), we = E(
|
|
114
|
+
() => R(w),
|
|
115
|
+
[R, w]
|
|
116
|
+
), xe = E(
|
|
117
|
+
() => H(w, l),
|
|
118
|
+
[w, l]
|
|
119
|
+
), [d, b] = j(() => H(M, l)), [L, h] = j(!1), [x, ce] = j(!1), n = U({
|
|
120
|
+
prevValue: M,
|
|
121
|
+
lastValidatedValue: "",
|
|
122
|
+
rawValue: ye
|
|
123
|
+
}), v = Oe(y, p), F = D(
|
|
124
|
+
(t) => {
|
|
125
|
+
if (n.current.lastValidatedValue === t)
|
|
126
|
+
return L;
|
|
127
|
+
if (n.current.lastValidatedValue = t, c !== "number" || t.length === 0)
|
|
128
|
+
return m?.("none", ""), !1;
|
|
129
|
+
if (!v.validation.test(t))
|
|
130
|
+
return m?.(
|
|
131
|
+
"error",
|
|
132
|
+
S.invalidNumber
|
|
133
|
+
), !0;
|
|
134
|
+
const r = k(t, c, l);
|
|
135
|
+
if (fe(t, v.progressPatterns))
|
|
136
|
+
return m?.("none", ""), !1;
|
|
137
|
+
if (r && !pe(r))
|
|
138
|
+
return m?.(
|
|
139
|
+
"error",
|
|
140
|
+
S.invalidNumber
|
|
141
|
+
), !0;
|
|
142
|
+
if (r) {
|
|
143
|
+
const e = Number(r);
|
|
144
|
+
if (I !== void 0 && e < I) {
|
|
145
|
+
const s = $(
|
|
146
|
+
I.toString(),
|
|
147
|
+
"number",
|
|
148
|
+
l
|
|
149
|
+
);
|
|
150
|
+
return m?.(
|
|
151
|
+
"error",
|
|
152
|
+
S.minValue(I, s)
|
|
153
|
+
), !0;
|
|
154
|
+
}
|
|
155
|
+
if (C !== void 0 && e > C) {
|
|
156
|
+
const s = $(
|
|
157
|
+
C.toString(),
|
|
158
|
+
"number",
|
|
159
|
+
l
|
|
160
|
+
);
|
|
161
|
+
return m?.(
|
|
162
|
+
"error",
|
|
163
|
+
S.maxValue(C, s)
|
|
164
|
+
), !0;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
return m?.("none", ""), !1;
|
|
168
|
+
},
|
|
169
|
+
[
|
|
170
|
+
c,
|
|
171
|
+
v,
|
|
172
|
+
m,
|
|
173
|
+
I,
|
|
174
|
+
C,
|
|
175
|
+
l,
|
|
176
|
+
L,
|
|
177
|
+
S
|
|
178
|
+
]
|
|
179
|
+
);
|
|
180
|
+
W ? o !== n.current.prevValue && !x && (n.current.rawValue = R(o ?? null), n.current.prevValue = o ?? null, b(
|
|
181
|
+
H(o ?? null, l)
|
|
182
|
+
), h(!1)) : !x && n.current.prevValue !== w && (n.current.rawValue = we, n.current.prevValue = w, b(xe), h(!1));
|
|
183
|
+
const Ee = D(() => {
|
|
184
|
+
if (c !== "number" || !x) return;
|
|
185
|
+
ce(!1);
|
|
186
|
+
let t = d;
|
|
187
|
+
if (t.endsWith(p) && (t = t.slice(0, -1)), t.includes(p)) {
|
|
188
|
+
const [e, s] = t.split(p);
|
|
189
|
+
s && /^0+$/.test(s) && (t = e);
|
|
190
|
+
}
|
|
191
|
+
const r = k(
|
|
192
|
+
t,
|
|
193
|
+
c,
|
|
194
|
+
l
|
|
195
|
+
);
|
|
196
|
+
if (r && pe(r)) {
|
|
197
|
+
const e = $(
|
|
198
|
+
r,
|
|
199
|
+
c,
|
|
200
|
+
l
|
|
201
|
+
);
|
|
202
|
+
n.current.rawValue = r, b(e), h(!1), a?.(Number(r), e);
|
|
203
|
+
} else d === "" || d === "-" ? (n.current.rawValue = "", b(""), h(!1), a?.(null, "")) : (F(d), h(!0), a?.(null, d));
|
|
204
|
+
}, [
|
|
205
|
+
d,
|
|
206
|
+
c,
|
|
207
|
+
l,
|
|
208
|
+
a,
|
|
209
|
+
p,
|
|
210
|
+
x,
|
|
211
|
+
F
|
|
212
|
+
]), $e = D(
|
|
213
|
+
(t, r) => {
|
|
214
|
+
if (typeof r.value != "string") return;
|
|
215
|
+
const e = r.value, s = t.currentTarget?.selectionStart;
|
|
216
|
+
if (B.current = typeof s == "number" ? { caret: s, typed: e } : null, x || ce(!0), b(e), e.length < d.length && d.startsWith(e) && v.thousandSeparator.test(e)) {
|
|
217
|
+
const u = e.replace(
|
|
218
|
+
new RegExp(
|
|
219
|
+
y.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"),
|
|
220
|
+
"g"
|
|
221
|
+
),
|
|
222
|
+
""
|
|
223
|
+
), A = $(
|
|
224
|
+
u,
|
|
225
|
+
c,
|
|
226
|
+
l
|
|
227
|
+
), me = F(A);
|
|
228
|
+
n.current.rawValue = u, b(A), h(me), a?.(
|
|
229
|
+
me || !u ? null : Number(u),
|
|
230
|
+
A
|
|
231
|
+
);
|
|
232
|
+
return;
|
|
233
|
+
}
|
|
234
|
+
const f = k(
|
|
235
|
+
e,
|
|
236
|
+
c,
|
|
237
|
+
l
|
|
238
|
+
), ie = F(e), de = Ue(
|
|
239
|
+
e,
|
|
240
|
+
p
|
|
241
|
+
), Se = fe(
|
|
242
|
+
e,
|
|
243
|
+
v.progressPatterns
|
|
244
|
+
);
|
|
245
|
+
if (n.current.rawValue = f, h(ie), ie)
|
|
246
|
+
if (f && v.validation.test(e))
|
|
247
|
+
if (de)
|
|
248
|
+
a?.(Number(f), e);
|
|
249
|
+
else {
|
|
250
|
+
const u = $(
|
|
251
|
+
f,
|
|
252
|
+
c,
|
|
253
|
+
l
|
|
254
|
+
);
|
|
255
|
+
b(u), a?.(Number(f), u);
|
|
256
|
+
}
|
|
257
|
+
else
|
|
258
|
+
a?.(null, e);
|
|
259
|
+
else if (f)
|
|
260
|
+
if (de)
|
|
261
|
+
a?.(Number(f), e);
|
|
262
|
+
else {
|
|
263
|
+
const u = $(
|
|
264
|
+
f,
|
|
265
|
+
c,
|
|
266
|
+
l
|
|
267
|
+
);
|
|
268
|
+
b(u), a?.(Number(f), u);
|
|
269
|
+
}
|
|
270
|
+
else if (Se) {
|
|
271
|
+
const u = e.replace(/[^\d-]/g, "");
|
|
272
|
+
u && u !== "-" ? (n.current.rawValue = u, a?.(Number(u), e)) : (n.current.rawValue = "", a?.(null, e));
|
|
273
|
+
} else
|
|
274
|
+
n.current.rawValue = "", a?.(null, "");
|
|
275
|
+
},
|
|
276
|
+
[
|
|
277
|
+
d,
|
|
278
|
+
x,
|
|
279
|
+
v,
|
|
280
|
+
y,
|
|
281
|
+
c,
|
|
282
|
+
l,
|
|
283
|
+
F,
|
|
284
|
+
p,
|
|
285
|
+
a
|
|
286
|
+
]
|
|
287
|
+
);
|
|
288
|
+
We(() => {
|
|
289
|
+
const t = B.current;
|
|
290
|
+
if (!t) return;
|
|
291
|
+
B.current = null;
|
|
292
|
+
const r = Q.current;
|
|
293
|
+
if (!r || document.activeElement !== r || r.value === t.typed) return;
|
|
294
|
+
const e = Be({
|
|
295
|
+
previousCaret: t.caret,
|
|
296
|
+
typedValue: t.typed,
|
|
297
|
+
nextFormatted: r.value,
|
|
298
|
+
isPayloadChar: Te(y)
|
|
299
|
+
}), s = Math.max(0, Math.min(e, r.value.length));
|
|
300
|
+
r.setSelectionRange(s, s);
|
|
301
|
+
});
|
|
302
|
+
const Ce = ve === "error" || L, Ie = Pe(
|
|
303
|
+
be,
|
|
304
|
+
J.EFWNumberInput,
|
|
305
|
+
Ce && J.EFWNumberInputError
|
|
306
|
+
);
|
|
307
|
+
if (!N) {
|
|
308
|
+
const t = n.current.rawValue === "" ? null : Number(n.current.rawValue), r = W ? o ?? null : t !== null && Number.isNaN(t) ? null : t, e = d || re.emptyState, s = Ne?.(
|
|
309
|
+
r,
|
|
310
|
+
e
|
|
311
|
+
);
|
|
312
|
+
return s != null ? /* @__PURE__ */ O(Re, { children: s }) : /* @__PURE__ */ O(Me, { style: d ? void 0 : { opacity: 0.7 }, children: e });
|
|
313
|
+
}
|
|
314
|
+
return /* @__PURE__ */ O(
|
|
315
|
+
De,
|
|
316
|
+
{
|
|
317
|
+
ref: Q,
|
|
318
|
+
className: Ie,
|
|
319
|
+
id: K,
|
|
320
|
+
name: K,
|
|
321
|
+
type: "text",
|
|
322
|
+
placeholder: re.placeholder,
|
|
323
|
+
contentBefore: Ve,
|
|
324
|
+
contentAfter: he,
|
|
325
|
+
disabled: V,
|
|
326
|
+
value: d,
|
|
327
|
+
"data-raw-value": n.current.rawValue,
|
|
328
|
+
autoComplete: ge,
|
|
329
|
+
autoCorrect: "off",
|
|
330
|
+
autoCapitalize: "off",
|
|
331
|
+
spellCheck: "false",
|
|
332
|
+
onChange: $e,
|
|
333
|
+
onBlur: Ee
|
|
334
|
+
}
|
|
335
|
+
);
|
|
336
|
+
};
|
|
337
|
+
export {
|
|
338
|
+
Ze as EFWNumberInput
|
|
339
|
+
};
|
package/dist/react-components/fields/{EFWNumberInput → NumberInput}/EFWNumberInput.types.d.ts
RENAMED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
-
import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
|
|
1
|
+
import { EFWFieldChildrenProps } from '../_shared/EFWField/EFWField.types';
|
|
2
|
+
import { ReactNode } from 'react';
|
|
2
3
|
|
|
3
4
|
export type EFWNumberInputValue = number | null;
|
|
4
5
|
export type FormatType = 'number';
|
|
6
|
+
export type EFWNumberInputNonEditableRenderer = (value: EFWNumberInputValue, displayValue: string) => ReactNode;
|
|
7
|
+
export interface EFWNumberInputLabels {
|
|
8
|
+
placeholder?: string;
|
|
9
|
+
emptyState?: string;
|
|
10
|
+
}
|
|
11
|
+
export interface EFWNumberInputValidationMessages {
|
|
12
|
+
invalidNumber?: string;
|
|
13
|
+
minValue?: (minValue: number, formattedMinValue: string) => string;
|
|
14
|
+
maxValue?: (maxValue: number, formattedMaxValue: string) => string;
|
|
15
|
+
}
|
|
5
16
|
export interface EFWNumberInputProps extends Partial<EFWFieldChildrenProps> {
|
|
6
17
|
/**
|
|
7
18
|
* Contenido mostrado antes del campo de entrada.
|
|
@@ -49,17 +60,6 @@ export interface EFWNumberInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
49
60
|
* className="campo-destacado campo-grande"
|
|
50
61
|
*/
|
|
51
62
|
className?: string;
|
|
52
|
-
/**
|
|
53
|
-
* Texto de sugerencia mostrado cuando el campo está vacío.
|
|
54
|
-
* Proporciona una pista visual sobre qué tipo de contenido se espera.
|
|
55
|
-
*
|
|
56
|
-
* @example
|
|
57
|
-
* placeholder="Ingrese su nombre completo"
|
|
58
|
-
*
|
|
59
|
-
* @example
|
|
60
|
-
* placeholder="ejemplo@correo.com"
|
|
61
|
-
*/
|
|
62
|
-
placeholder?: string;
|
|
63
63
|
/**
|
|
64
64
|
* Valor actual del campo de entrada.
|
|
65
65
|
* Puede ser un número o null para campos vacíos.
|
|
@@ -131,6 +131,25 @@ export interface EFWNumberInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
131
131
|
* @returns Valor formateado o el valor original si no se puede formatear
|
|
132
132
|
*/
|
|
133
133
|
formatFunction?: (value: EFWNumberInputValue) => EFWNumberInputValue;
|
|
134
|
+
/**
|
|
135
|
+
* Textos personalizables de la UI del campo.
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* labels={{ placeholder: "Ingrese un monto", emptyState: "Sin datos" }}
|
|
139
|
+
*/
|
|
140
|
+
labels?: EFWNumberInputLabels;
|
|
141
|
+
/**
|
|
142
|
+
* Renderiza contenido custom cuando `editable={false}`.
|
|
143
|
+
* Si retorna `null` o `undefined`, se utiliza el render no editable por defecto.
|
|
144
|
+
*/
|
|
145
|
+
readOnlyRenderer?: EFWNumberInputNonEditableRenderer;
|
|
146
|
+
/**
|
|
147
|
+
* Mensajes de validación personalizados para reglas numéricas.
|
|
148
|
+
*
|
|
149
|
+
* @example
|
|
150
|
+
* validationMessages={{ invalidNumber: "Número inválido", minValue: (min) => `Mínimo ${min}` }}
|
|
151
|
+
*/
|
|
152
|
+
validationMessages?: EFWNumberInputValidationMessages;
|
|
134
153
|
/**
|
|
135
154
|
* Callback ejecutado cuando el valor del campo cambia.
|
|
136
155
|
* Recibe tanto el valor sin formato como el valor mostrado al usuario.
|
|
@@ -147,8 +166,8 @@ export interface EFWNumberInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
147
166
|
*
|
|
148
167
|
* @example
|
|
149
168
|
* onChange={(value) => {
|
|
150
|
-
* if (value && value
|
|
151
|
-
*
|
|
169
|
+
* if (value !== null && value >= 100) {
|
|
170
|
+
* recalcularTotales(value);
|
|
152
171
|
* }
|
|
153
172
|
* }}
|
|
154
173
|
*/
|
package/dist/react-components/fields/{EFWNumberInput → NumberInput}/EFWNumberInput.utils.d.ts
RENAMED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { PayloadCharTester } from '../../commons/caretPositioning';
|
|
2
|
+
import { EFWNumberInputValue, FormatType } from './EFWNumberInput.types';
|
|
2
3
|
|
|
3
4
|
interface FormatOptions {
|
|
4
5
|
/** Habilita o deshabilita el formateo (por defecto: true) */
|
|
@@ -23,19 +24,6 @@ interface FormatOptions {
|
|
|
23
24
|
* formatNumber("-1234.56", undefined, ".", ",") // "-1.234,56"
|
|
24
25
|
*/
|
|
25
26
|
export declare const formatNumber: (input: string | number, prefix?: string, thousandSeparator?: string, decimalSeparator?: string) => string;
|
|
26
|
-
/**
|
|
27
|
-
* Elimina el formato numérico de una cadena, normalizando el separador decimal a ".".
|
|
28
|
-
* Maneja prefijos, paréntesis contables y separadores de miles.
|
|
29
|
-
*
|
|
30
|
-
* @param value Cadena con el número formateado (ej. "$1,234.56").
|
|
31
|
-
* @param decimalSeparator Separador decimal usado en la entrada (por defecto: ".").
|
|
32
|
-
* @param thousandSeparator Separador de miles usado en la entrada (por defecto: ",").
|
|
33
|
-
* @returns Cadena con dígitos, un punto decimal y un posible signo negativo; vacía si no es válida.
|
|
34
|
-
* @example
|
|
35
|
-
* stripFormatNumber("$1,234.56") // "1234.56"
|
|
36
|
-
* stripFormatNumber("(1.234,56)", ",", ".") // "-1234.56"
|
|
37
|
-
*/
|
|
38
|
-
export declare const stripFormatNumber: (value?: string, decimalSeparator?: string, thousandSeparator?: string) => string;
|
|
39
27
|
/**
|
|
40
28
|
* Elimina el formato de una cadena según el tipo de formato especificado.
|
|
41
29
|
*
|
|
@@ -71,4 +59,22 @@ export declare const applyFormatting: (value: string, formatType: FormatType, op
|
|
|
71
59
|
* isValidNumber("") // false
|
|
72
60
|
*/
|
|
73
61
|
export declare const isValidNumber: (str: string) => boolean;
|
|
62
|
+
/**
|
|
63
|
+
* Crea el predicado de "payload" para inputs numéricos: la única decoración que
|
|
64
|
+
* el formato inserta/remueve es el separador de miles, por lo que cualquier otro
|
|
65
|
+
* carácter (dígitos, signo `-`, separador decimal) cuenta como dato real escrito.
|
|
66
|
+
*
|
|
67
|
+
* Se usa junto con `computeCaretAfterReformat` (commons) para reubicar el caret
|
|
68
|
+
* tras un reflujo de separadores y evitar que salte al final del valor.
|
|
69
|
+
*/
|
|
70
|
+
export declare const createNumberPayloadCharTester: (thousandSeparator?: string) => PayloadCharTester;
|
|
71
|
+
/**
|
|
72
|
+
* Retorna el valor formateado que EFWNumberInput muestra cuando no está en modo editable.
|
|
73
|
+
* Combina stripFormatting + applyFormatting en una sola llamada.
|
|
74
|
+
*/
|
|
75
|
+
export declare const getNumberInputFormattedValue: (value: EFWNumberInputValue | undefined, options?: {
|
|
76
|
+
enableFormatting?: boolean;
|
|
77
|
+
thousandSeparator?: string;
|
|
78
|
+
decimalSeparator?: string;
|
|
79
|
+
}) => string;
|
|
74
80
|
export {};
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
const R = (e, n, i = ",", t = ".") => {
|
|
2
|
+
const p = (s) => s == null, m = (s) => s.length <= 3 ? s : s.replace(/\B(?=(\d{3})+(?!\d))/g, i), b = (s) => s.replace(/^0+(?=\d)/, "") || "0", d = (s) => /[^0]/.test(s) && s.replace(/0+$/, "") || "0";
|
|
3
|
+
if (p(e) || typeof e == "number" && !Number.isFinite(e)) return "";
|
|
4
|
+
if (typeof e == "number") {
|
|
5
|
+
const s = e < 0, c = Math.abs(e);
|
|
6
|
+
let [h, g = ""] = c.toString().split(".");
|
|
7
|
+
if (/[eE]/.test(g)) {
|
|
8
|
+
const M = c.toFixed(20).replace(/0+$/, "");
|
|
9
|
+
[h, g = ""] = M.split(".");
|
|
10
|
+
}
|
|
11
|
+
h = b(h), g = g && d(g);
|
|
12
|
+
let a = m(h);
|
|
13
|
+
return g && (a += t + g), s && (a = "-" + a), n && a && (a = n + a), a;
|
|
14
|
+
}
|
|
15
|
+
let r = e.trim();
|
|
16
|
+
if (!r) return "";
|
|
17
|
+
let u = !1;
|
|
18
|
+
/^\(.*\)$/.test(r) && (r = r.slice(1, -1));
|
|
19
|
+
const $ = r.match(/^-+/);
|
|
20
|
+
if ($ && (u = $[0].length === 1, r = r.slice($[0].length)), /^[+-]?\d*\.?\d+e[+-]?\d+$/i.test(r)) {
|
|
21
|
+
const s = Number(r);
|
|
22
|
+
let c = R(
|
|
23
|
+
s,
|
|
24
|
+
void 0,
|
|
25
|
+
i,
|
|
26
|
+
t
|
|
27
|
+
);
|
|
28
|
+
return /\.\d$/.test(c) && (c = c.replace(new RegExp(`\\${t}0$`), "")), u && (c = "-" + c), n && c && (c = n + c), c;
|
|
29
|
+
}
|
|
30
|
+
const l = r.replace(/[^\d.,]/g, "");
|
|
31
|
+
if (!/\d/.test(l)) return "";
|
|
32
|
+
const I = l.lastIndexOf(","), w = l.lastIndexOf(".");
|
|
33
|
+
let o = Math.max(I, w);
|
|
34
|
+
o > -1 && /^\d{3}$/.test(l.slice(o + 1)) && l.slice(0, o).includes(l[o]) && (o = -1);
|
|
35
|
+
const D = o === -1 ? l : l.slice(0, o), F = o === -1 ? "" : l.slice(o + 1), E = b(D.replace(/[.,]/g, "")), N = F ? d(F.replace(/[^\d]/g, "")) : "";
|
|
36
|
+
let f = m(E);
|
|
37
|
+
return N ? f += t + N : r.endsWith(t) && (f += t), u && (f = "-" + f), n && f && (f = n + f), f;
|
|
38
|
+
}, C = (e = "", n = ".", i = ",") => {
|
|
39
|
+
if (!e || typeof e != "string") return "";
|
|
40
|
+
let t = e.trim();
|
|
41
|
+
if (!t) return "";
|
|
42
|
+
let p = !1;
|
|
43
|
+
/^\(.*\)$/.test(t) && (p = !0, t = t.slice(1, -1));
|
|
44
|
+
const m = t.match(/^-+/);
|
|
45
|
+
m && (p = m[0].length % 2 === 1, t = t.slice(m[0].length)), t = t.replace(/^[^\d.,-]+|[^\d.,-]+$/g, "");
|
|
46
|
+
const b = (r) => r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
47
|
+
if (i) {
|
|
48
|
+
const r = new RegExp(b(i), "g");
|
|
49
|
+
t = t.replace(r, "");
|
|
50
|
+
}
|
|
51
|
+
if (n && n !== ".") {
|
|
52
|
+
const r = new RegExp(b(n), "g"), u = t.lastIndexOf(n);
|
|
53
|
+
u !== -1 && (t = t.slice(0, u).replace(r, "") + "." + t.slice(u + n.length));
|
|
54
|
+
}
|
|
55
|
+
t = t.replace(/[^\d.-]/g, "");
|
|
56
|
+
const d = t.split(".");
|
|
57
|
+
return d.length > 2 && (t = d.shift() + "." + d.join("")), t = t.replace(/^-+/, "-").replace(/(?!^)-/g, ""), /^\d+(\.\d+)?$/.test(t.replace(/^-/, "")) ? (t[t.length - 1] === n && (t = t.slice(0, -1)), p && (t = "-" + t), t) : "";
|
|
58
|
+
}, y = {
|
|
59
|
+
number: (e, n) => C(
|
|
60
|
+
e || "",
|
|
61
|
+
n?.decimalSeparator || ".",
|
|
62
|
+
n?.thousandSeparator || ","
|
|
63
|
+
)
|
|
64
|
+
}, x = {
|
|
65
|
+
number: (e, n) => n?.enableFormatting === !1 || isNaN(Number(e)) ? e : R(
|
|
66
|
+
e,
|
|
67
|
+
void 0,
|
|
68
|
+
n?.thousandSeparator || ",",
|
|
69
|
+
n?.decimalSeparator || "."
|
|
70
|
+
)
|
|
71
|
+
}, O = (e, n, i = {}) => e ? (y[n] || y.number)(e, i) : "", P = (e, n, i = {}) => e ? (x[n] || x.number)(e, i) : "", V = (e) => {
|
|
72
|
+
const n = e.trim();
|
|
73
|
+
return n === "" ? !1 : /^-?\d+(\.\d*)?$/.test(n);
|
|
74
|
+
}, j = (e = ",") => (n) => n !== e, z = (e, n) => {
|
|
75
|
+
if (e == null) return "";
|
|
76
|
+
const i = typeof e == "number" ? String(e) : O(String(e), "number", n ?? {});
|
|
77
|
+
return P(i, "number", n ?? {});
|
|
78
|
+
};
|
|
79
|
+
export {
|
|
80
|
+
P as applyFormatting,
|
|
81
|
+
j as createNumberPayloadCharTester,
|
|
82
|
+
R as formatNumber,
|
|
83
|
+
z as getNumberInputFormattedValue,
|
|
84
|
+
V as isValidNumber,
|
|
85
|
+
O as stripFormatting
|
|
86
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { jsx as a } from "react/jsx-runtime";
|
|
2
|
+
import { EFWField as O } from "../_shared/EFWField/EFWField.js";
|
|
3
|
+
import { EFWNumberInput as P } from "./EFWNumberInput.js";
|
|
4
|
+
import { mergeClasses as R } from "@griffel/react";
|
|
5
|
+
const G = (t) => {
|
|
6
|
+
const {
|
|
7
|
+
title: n,
|
|
8
|
+
infoLabel: o,
|
|
9
|
+
hint: l,
|
|
10
|
+
className: r,
|
|
11
|
+
style: i = {},
|
|
12
|
+
required: s = !1,
|
|
13
|
+
contentBefore: m,
|
|
14
|
+
contentAfter: d,
|
|
15
|
+
minValue: u,
|
|
16
|
+
maxValue: f,
|
|
17
|
+
validationState: p,
|
|
18
|
+
validationMessage: c,
|
|
19
|
+
validationMessageIcon: b,
|
|
20
|
+
value: g,
|
|
21
|
+
defaultValue: h,
|
|
22
|
+
editable: e = !0,
|
|
23
|
+
disabled: C = !1,
|
|
24
|
+
hidden: F = !1,
|
|
25
|
+
onChange: v,
|
|
26
|
+
autoComplete: N = "off",
|
|
27
|
+
formatType: I = "number",
|
|
28
|
+
formatFunction: V,
|
|
29
|
+
enableFormatting: x = !0,
|
|
30
|
+
thousandSeparator: y,
|
|
31
|
+
decimalSeparator: E,
|
|
32
|
+
labels: M,
|
|
33
|
+
readOnlyRenderer: S,
|
|
34
|
+
validationMessages: W,
|
|
35
|
+
onValidationChange: w,
|
|
36
|
+
...L
|
|
37
|
+
} = t, j = (A, B) => {
|
|
38
|
+
v?.(A, B);
|
|
39
|
+
}, q = R(r, "efw-numberInput-field");
|
|
40
|
+
return /* @__PURE__ */ a(
|
|
41
|
+
O,
|
|
42
|
+
{
|
|
43
|
+
className: q,
|
|
44
|
+
style: i,
|
|
45
|
+
title: n,
|
|
46
|
+
infoLabel: o,
|
|
47
|
+
weightLabel: e ? "regular" : "semibold",
|
|
48
|
+
hint: l,
|
|
49
|
+
required: s,
|
|
50
|
+
validationState: p,
|
|
51
|
+
validationMessage: c,
|
|
52
|
+
validationMessageIcon: b,
|
|
53
|
+
onValidationChange: w,
|
|
54
|
+
hidden: F,
|
|
55
|
+
...L,
|
|
56
|
+
children: /* @__PURE__ */ a(
|
|
57
|
+
P,
|
|
58
|
+
{
|
|
59
|
+
value: g,
|
|
60
|
+
defaultValue: h,
|
|
61
|
+
editable: e,
|
|
62
|
+
onChange: j,
|
|
63
|
+
disabled: C,
|
|
64
|
+
autoComplete: N,
|
|
65
|
+
contentBefore: m,
|
|
66
|
+
contentAfter: d,
|
|
67
|
+
formatType: I,
|
|
68
|
+
formatFunction: V,
|
|
69
|
+
enableFormatting: x,
|
|
70
|
+
minValue: u,
|
|
71
|
+
maxValue: f,
|
|
72
|
+
thousandSeparator: y,
|
|
73
|
+
decimalSeparator: E,
|
|
74
|
+
labels: M,
|
|
75
|
+
readOnlyRenderer: S,
|
|
76
|
+
validationMessages: W
|
|
77
|
+
}
|
|
78
|
+
)
|
|
79
|
+
}
|
|
80
|
+
);
|
|
81
|
+
};
|
|
82
|
+
export {
|
|
83
|
+
G as EFWNumberInputField
|
|
84
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { EFWFieldProps } from '../EFWField/EFWField.types';
|
|
2
|
-
import { EFWNumberInputProps, EFWNumberInputValue } from '
|
|
1
|
+
import { EFWFieldProps } from '../_shared/EFWField/EFWField.types';
|
|
2
|
+
import { EFWNumberInputProps, EFWNumberInputValue } from './EFWNumberInput.types';
|
|
3
3
|
|
|
4
4
|
export type EFWNumberInputFieldValue = EFWNumberInputValue;
|
|
5
5
|
export interface EFWNumberInputFieldProps extends Omit<EFWFieldProps, 'children'>, EFWNumberInputProps {
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
export { EFWNumberInput } from './EFWNumberInput';
|
|
2
|
+
export { getNumberInputFormattedValue } from './EFWNumberInput.utils';
|
|
3
|
+
export type { EFWNumberInputProps, EFWNumberInputValue, EFWNumberInputNonEditableRenderer } from './EFWNumberInput.types';
|
|
4
|
+
export { EFWNumberInputField } from './EFWNumberInputField';
|
|
5
|
+
export type { EFWNumberInputFieldProps, EFWNumberInputFieldValue } from './EFWNumberInputField.types';
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EFWNumberInput as t } from "./EFWNumberInput.js";
|
|
2
|
+
import { getNumberInputFormattedValue as o } from "./EFWNumberInput.utils.js";
|
|
3
|
+
import { EFWNumberInputField as p } from "./EFWNumberInputField.js";
|
|
4
|
+
export {
|
|
5
|
+
t as EFWNumberInput,
|
|
6
|
+
p as EFWNumberInputField,
|
|
7
|
+
o as getNumberInputFormattedValue
|
|
8
|
+
};
|