@envisiongroup/porygon 0.1.0-rc.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/LICENSE +11 -0
- package/README.md +69 -0
- package/dist/index.d.ts +24 -0
- package/dist/index.js +60 -0
- package/dist/react-components/buttons/EFWButton/EFWButton.d.ts +59 -0
- package/dist/react-components/buttons/EFWButton/EFWButton.hooks.d.ts +45 -0
- package/dist/react-components/buttons/EFWButton/EFWButton.hooks.js +75 -0
- package/dist/react-components/buttons/EFWButton/EFWButton.js +164 -0
- package/dist/react-components/buttons/EFWButton/EFWButton.types.d.ts +282 -0
- package/dist/react-components/buttons/EFWButton/index.d.ts +3 -0
- package/dist/react-components/buttons/EFWButton/index.js +6 -0
- package/dist/react-components/buttons/EFWDrawerButton/EFWDrawerButton.d.ts +36 -0
- package/dist/react-components/buttons/EFWDrawerButton/EFWDrawerButton.js +32 -0
- package/dist/react-components/buttons/EFWDrawerButton/EFWDrawerButton.types.d.ts +87 -0
- package/dist/react-components/buttons/EFWDrawerButton/index.d.ts +12 -0
- package/dist/react-components/buttons/EFWDrawerButton/index.js +4 -0
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.d.ts +65 -0
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.js +129 -0
- package/dist/react-components/buttons/EFWGroupButton/EFWGroupButton.types.d.ts +232 -0
- package/dist/react-components/buttons/EFWGroupButton/index.d.ts +2 -0
- package/dist/react-components/buttons/EFWGroupButton/index.js +4 -0
- package/dist/react-components/commons/utils.d.ts +55 -0
- package/dist/react-components/commons/utils.js +18 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.d.ts +18 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.js +124 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.types.d.ts +78 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/EFWAttachmentsCard.d.ts +23 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/EFWAttachmentsCard.js +107 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/EFWAttachmentsCard.types.d.ts +73 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/index.d.ts +1 -0
- package/dist/react-components/fields/EFWAttachments/EFWAttachmentsCard/index.js +0 -0
- package/dist/react-components/fields/EFWAttachments/index.d.ts +2 -0
- package/dist/react-components/fields/EFWAttachments/index.js +4 -0
- package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.d.ts +21 -0
- package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js +55 -0
- package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.types.d.ts +7 -0
- package/dist/react-components/fields/EFWAttachmentsField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWAttachmentsField/index.js +4 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.d.ts +34 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +135 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.types.d.ts +81 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.d.ts +22 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.js +76 -0
- package/dist/react-components/fields/EFWDatePicker/index.d.ts +2 -0
- package/dist/react-components/fields/EFWDatePicker/index.js +4 -0
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.d.ts +3 -0
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.js +63 -0
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.types.d.ts +7 -0
- package/dist/react-components/fields/EFWDatePickerField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWDatePickerField/index.js +4 -0
- package/dist/react-components/fields/EFWField/EFWField.d.ts +53 -0
- package/dist/react-components/fields/EFWField/EFWField.js +90 -0
- package/dist/react-components/fields/EFWField/EFWField.types.d.ts +294 -0
- package/dist/react-components/fields/EFWField/EFWField.utils.d.ts +3 -0
- package/dist/react-components/fields/EFWField/EFWField.utils.js +17 -0
- package/dist/react-components/fields/EFWField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWField/index.js +4 -0
- package/dist/react-components/fields/EFWInput/EFWInput.d.ts +26 -0
- package/dist/react-components/fields/EFWInput/EFWInput.js +100 -0
- package/dist/react-components/fields/EFWInput/EFWInput.types.d.ts +257 -0
- package/dist/react-components/fields/EFWInput/EFWInput.utils.d.ts +20 -0
- package/dist/react-components/fields/EFWInput/EFWInput.utils.js +84 -0
- package/dist/react-components/fields/EFWInput/index.d.ts +2 -0
- package/dist/react-components/fields/EFWInput/index.js +4 -0
- package/dist/react-components/fields/EFWInputField/EFWInputField.d.ts +3 -0
- package/dist/react-components/fields/EFWInputField/EFWInputField.js +71 -0
- package/dist/react-components/fields/EFWInputField/EFWInputField.types.d.ts +6 -0
- package/dist/react-components/fields/EFWInputField/EFWInputField.utils.d.ts +1 -0
- package/dist/react-components/fields/EFWInputField/EFWInputField.utils.js +0 -0
- package/dist/react-components/fields/EFWInputField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWInputField/index.js +4 -0
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.d.ts +8 -0
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.js +183 -0
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.types.d.ts +226 -0
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.utils.d.ts +74 -0
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.utils.js +76 -0
- package/dist/react-components/fields/EFWNumberInput/index.d.ts +2 -0
- package/dist/react-components/fields/EFWNumberInput/index.js +4 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.d.ts +3 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.js +65 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.types.d.ts +6 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.utils.d.ts +1 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.utils.js +0 -0
- package/dist/react-components/fields/EFWNumberInputField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWNumberInputField/index.js +4 -0
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.d.ts +3 -0
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.js +54 -0
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.types.d.ts +49 -0
- package/dist/react-components/fields/EFWSwitch/index.d.ts +2 -0
- package/dist/react-components/fields/EFWSwitch/index.js +4 -0
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.d.ts +3 -0
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.js +53 -0
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.types.d.ts +7 -0
- package/dist/react-components/fields/EFWSwitchField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWSwitchField/index.js +4 -0
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.d.ts +8 -0
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +230 -0
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.types.d.ts +136 -0
- package/dist/react-components/fields/EFWTagPicker/index.d.ts +2 -0
- package/dist/react-components/fields/EFWTagPicker/index.js +4 -0
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.d.ts +3 -0
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.js +72 -0
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.types.d.ts +8 -0
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.utils.d.ts +1 -0
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.utils.js +0 -0
- package/dist/react-components/fields/EFWTagPickerField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWTagPickerField/index.js +4 -0
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.d.ts +3 -0
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.js +103 -0
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.types.d.ts +79 -0
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.utils.d.ts +1 -0
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.utils.js +0 -0
- package/dist/react-components/fields/EFWTextArea/index.d.ts +2 -0
- package/dist/react-components/fields/EFWTextArea/index.js +4 -0
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.d.ts +3 -0
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.js +69 -0
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.types.d.ts +6 -0
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.utils.d.ts +1 -0
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.utils.js +0 -0
- package/dist/react-components/fields/EFWTextAreaField/index.d.ts +2 -0
- package/dist/react-components/fields/EFWTextAreaField/index.js +4 -0
- package/dist/react-components/fields/types.d.ts +1 -0
- package/dist/react-components/fields/types.js +0 -0
- package/dist/react-components/forms/EFWForm/EFWForm.converter.d.ts +3 -0
- package/dist/react-components/forms/EFWForm/EFWForm.converter.js +30 -0
- package/dist/react-components/forms/EFWForm/EFWForm.d.ts +96 -0
- package/dist/react-components/forms/EFWForm/EFWForm.hooks.d.ts +55 -0
- package/dist/react-components/forms/EFWForm/EFWForm.hooks.js +41 -0
- package/dist/react-components/forms/EFWForm/EFWForm.js +363 -0
- package/dist/react-components/forms/EFWForm/EFWForm.types.d.ts +981 -0
- package/dist/react-components/forms/EFWForm/EFWForm.utils.d.ts +19 -0
- package/dist/react-components/forms/EFWForm/EFWForm.utils.js +252 -0
- package/dist/react-components/forms/EFWForm/index.d.ts +4 -0
- package/dist/react-components/forms/EFWForm/index.js +8 -0
- package/dist/react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.d.ts +3 -0
- package/dist/react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.js +86 -0
- package/dist/react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.types.d.ts +34 -0
- package/dist/react-components/forms/EFWFormMessageBarGroup/index.d.ts +2 -0
- package/dist/react-components/forms/EFWFormMessageBarGroup/index.js +4 -0
- package/dist/react-components/forms/EFWMessageBarManager/EFWMessageBarManager.d.ts +3 -0
- package/dist/react-components/forms/EFWMessageBarManager/EFWMessageBarManager.js +32 -0
- package/dist/react-components/forms/EFWMessageBarManager/EFWMessageBarManager.types.d.ts +7 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/EFWDrawer.d.ts +3 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/EFWDrawer.js +96 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/EFWDrawer.types.d.ts +15 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/index.d.ts +2 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawer/index.js +4 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/EFWDrawerLoader.d.ts +5 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/EFWDrawerLoader.js +24 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/index.d.ts +1 -0
- package/dist/react-components/hooks/useDrawer/component/EFWDrawerLoader/index.js +4 -0
- package/dist/react-components/hooks/useDrawer/index.d.ts +2 -0
- package/dist/react-components/hooks/useDrawer/index.js +4 -0
- package/dist/react-components/hooks/useDrawer/useDrawer.d.ts +10 -0
- package/dist/react-components/hooks/useDrawer/useDrawer.js +158 -0
- package/dist/react-components/hooks/useDrawer/useDrawer.types.d.ts +72 -0
- package/dist/react-components/layout/MainNavBar/MainNavBar.js +81 -0
- package/dist/react-components/layout/MainNavBar/index.js +4 -0
- package/dist/react-components/layout/MainNavItems/MainNavItems.js +35 -0
- package/dist/react-components/layout/MainNavItems/MainNavItems.styles.js +0 -0
- package/dist/react-components/layout/MainNavItems/index.js +4 -0
- package/dist/react-components/layout/NavBarContext/NavBarContext.js +24 -0
- package/dist/react-components/tables/EFWTable/EFWTable.d.ts +8 -0
- package/dist/react-components/tables/EFWTable/EFWTable.js +585 -0
- package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +367 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.js +75 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/EFWTableBody.types.d.ts +18 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/index.d.ts +2 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableBody/index.js +4 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.d.ts +16 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +38 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.d.ts +17 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +105 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.types.d.ts +94 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.utils.d.ts +14 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.utils.js +26 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/index.d.ts +2 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/index.js +4 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.js +46 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/EFWTableEmpty.types.d.ts +6 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/index.d.ts +2 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableEmpty/index.js +4 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.js +87 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.types.d.ts +13 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/index.d.ts +2 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/index.js +4 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableRow/EFWTableRow.d.ts +22 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableRow/EFWTableRow.js +60 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.js +95 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.js +89 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +98 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController copy.d.ts +4 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController copy.js +178 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.d.ts +4 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +178 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.types copy.d.ts +16 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.types copy.js +0 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.types.d.ts +16 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.js +67 -0
- package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.types.d.ts +37 -0
- package/dist/react-components/tables/EFWTable/index.d.ts +3 -0
- package/dist/react-components/tables/EFWTable/index.js +6 -0
- package/dist/react-components/tables/EFWTable/utils/CellRenderer/CellRenderer.d.ts +7 -0
- package/dist/react-components/tables/EFWTable/utils/CellRenderer/CellRenderer.js +38 -0
- package/dist/react-components/tables/EFWTable/utils/CellRenderer/CellRenderer.types.d.ts +14 -0
- package/dist/react-components/tables/EFWTable/utils/cache.d.ts +37 -0
- package/dist/react-components/tables/EFWTable/utils/cache.js +127 -0
- package/dist/react-components/tables/EFWTable/utils/comparison.d.ts +6 -0
- package/dist/react-components/tables/EFWTable/utils/comparison.js +56 -0
- package/dist/react-components/tables/EFWTable/utils/constants.d.ts +8 -0
- package/dist/react-components/tables/EFWTable/utils/constants.js +9 -0
- package/dist/react-components/tables/EFWTable/utils/context.d.ts +8 -0
- package/dist/react-components/tables/EFWTable/utils/context.js +8 -0
- package/dist/react-components/tables/EFWTable/utils/general.d.ts +4 -0
- package/dist/react-components/tables/EFWTable/utils/general.js +4 -0
- package/dist/react-components/tables/EFWTable/utils/hashing.d.ts +18 -0
- package/dist/react-components/tables/EFWTable/utils/hashing.js +43 -0
- package/dist/react-components/tables/EFWTable/utils/index.d.ts +11 -0
- package/dist/react-components/tables/EFWTable/utils/index.js +24 -0
- package/dist/react-components/tables/EFWTable/utils/renderers.d.ts +8 -0
- package/dist/react-components/tables/EFWTable/utils/renderers.js +25 -0
- package/dist/react-components/tables/EFWTable/utils/types.d.ts +31 -0
- package/dist/react-components/tables/EFWTable/utils/types.js +0 -0
- package/dist/utils/htmlConverter.d.ts +15 -0
- package/dist/utils/htmlConverter.js +12 -0
- package/package.json +114 -0
|
@@ -0,0 +1,257 @@
|
|
|
1
|
+
import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Valor que puede contener un componente de entrada EFW.
|
|
5
|
+
* Representa el valor de texto o null cuando no hay contenido.
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* // Valor con texto
|
|
9
|
+
* const textValue: EFWInputValue = "Texto de ejemplo";
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* // Valor vacío
|
|
13
|
+
* const emptyValue: EFWInputValue = null;
|
|
14
|
+
*
|
|
15
|
+
* @example
|
|
16
|
+
* // En un componente React
|
|
17
|
+
* const [inputValue, setInputValue] = useState<EFWInputValue>("Valor inicial");
|
|
18
|
+
*/
|
|
19
|
+
export type EFWInputValue = string | null;
|
|
20
|
+
/**
|
|
21
|
+
* Tipos de formato disponibles para el componente EFWInput.
|
|
22
|
+
* Determina cómo se formatea y valida el contenido del campo de entrada.
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Sin formato específico
|
|
26
|
+
* const basicFormat: FormatType = 'none';
|
|
27
|
+
*
|
|
28
|
+
* @example
|
|
29
|
+
* // Para números de teléfono
|
|
30
|
+
* const phoneFormat: FormatType = 'phone';
|
|
31
|
+
*
|
|
32
|
+
* @example
|
|
33
|
+
* // Para RUT chileno
|
|
34
|
+
* const rutFormat: FormatType = 'chileanRut';
|
|
35
|
+
*/
|
|
36
|
+
export type FormatType = 'none' | 'phone' | 'creditCard' | 'chileanRut' | 'date' | 'custom' | 'email';
|
|
37
|
+
/**
|
|
38
|
+
* Propiedades del componente EFWInput.
|
|
39
|
+
* Extiende las propiedades básicas de los campos EFW con funcionalidades específicas
|
|
40
|
+
* para entrada de texto, formateo, validación y personalización visual.
|
|
41
|
+
*
|
|
42
|
+
* @interface EFWInputProps
|
|
43
|
+
* @extends {Partial<EFWFieldChildrenProps>}
|
|
44
|
+
*
|
|
45
|
+
* @example
|
|
46
|
+
* // Uso básico
|
|
47
|
+
* const basicProps: EFWInputProps = {
|
|
48
|
+
* value: "ejemplo@email.com",
|
|
49
|
+
* placeholder: "Ingrese su email",
|
|
50
|
+
* formatType: "email"
|
|
51
|
+
* };
|
|
52
|
+
*
|
|
53
|
+
* @example
|
|
54
|
+
* // Uso avanzado con validación personalizada
|
|
55
|
+
* const advancedProps: EFWInputProps = {
|
|
56
|
+
* value: "12345678-9",
|
|
57
|
+
* formatType: "chileanRut",
|
|
58
|
+
* minLength: 8,
|
|
59
|
+
* maxLength: 12,
|
|
60
|
+
* editable: true,
|
|
61
|
+
* onChange: (value, displayValue) => {
|
|
62
|
+
* console.log('Valor crudo:', value);
|
|
63
|
+
* console.log('Valor mostrado:', displayValue);
|
|
64
|
+
* }
|
|
65
|
+
* };
|
|
66
|
+
*/
|
|
67
|
+
export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
68
|
+
/**
|
|
69
|
+
* Contenido mostrado antes del campo de entrada.
|
|
70
|
+
* Útil para iconos, prefijos o elementos decorativos.
|
|
71
|
+
*
|
|
72
|
+
* @example
|
|
73
|
+
* contentBefore="$"
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* contentBefore="https://"
|
|
77
|
+
*/
|
|
78
|
+
contentBefore?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Contenido mostrado después del campo de entrada.
|
|
81
|
+
* Útil para unidades, sufijos o elementos adicionales.
|
|
82
|
+
*
|
|
83
|
+
* @example
|
|
84
|
+
* contentAfter="kg"
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* contentAfter=".com"
|
|
88
|
+
*/
|
|
89
|
+
contentAfter?: string;
|
|
90
|
+
/**
|
|
91
|
+
* Configuración de autocompletado del navegador.
|
|
92
|
+
* Controla si el navegador puede sugerir valores automáticamente.
|
|
93
|
+
*
|
|
94
|
+
* @default off
|
|
95
|
+
*
|
|
96
|
+
* @example
|
|
97
|
+
* autoComplete="on"
|
|
98
|
+
*
|
|
99
|
+
* @example
|
|
100
|
+
* autoComplete="off"
|
|
101
|
+
*/
|
|
102
|
+
autoComplete?: 'on' | 'off';
|
|
103
|
+
/**
|
|
104
|
+
* Valor actual del campo de entrada.
|
|
105
|
+
* Puede ser una cadena de texto o null para campos vacíos.
|
|
106
|
+
*
|
|
107
|
+
* @example
|
|
108
|
+
* value="Juan Pérez"
|
|
109
|
+
*
|
|
110
|
+
* @example
|
|
111
|
+
* value={null}
|
|
112
|
+
*/
|
|
113
|
+
value?: EFWInputValue;
|
|
114
|
+
/**
|
|
115
|
+
* Tipo de input HTML que determina el comportamiento del campo.
|
|
116
|
+
* Afecta el teclado virtual en dispositivos móviles y la validación del navegador.
|
|
117
|
+
*
|
|
118
|
+
* @default "text"
|
|
119
|
+
*
|
|
120
|
+
* @example
|
|
121
|
+
* type="email"
|
|
122
|
+
*
|
|
123
|
+
* @example
|
|
124
|
+
* type="password"
|
|
125
|
+
*
|
|
126
|
+
* @example
|
|
127
|
+
* type="tel"
|
|
128
|
+
*/
|
|
129
|
+
type?: 'text' | 'password' | 'email' | 'number' | 'tel';
|
|
130
|
+
/**
|
|
131
|
+
* Clases CSS adicionales aplicadas al componente.
|
|
132
|
+
* Permite personalizar la apariencia del campo de entrada.
|
|
133
|
+
*
|
|
134
|
+
* @example
|
|
135
|
+
* className="mi-input-personalizado"
|
|
136
|
+
*
|
|
137
|
+
* @example
|
|
138
|
+
* className="campo-destacado campo-grande"
|
|
139
|
+
*/
|
|
140
|
+
className?: string;
|
|
141
|
+
/**
|
|
142
|
+
* Texto de sugerencia mostrado cuando el campo está vacío.
|
|
143
|
+
* Proporciona una pista visual sobre qué tipo de contenido se espera.
|
|
144
|
+
*
|
|
145
|
+
* @example
|
|
146
|
+
* placeholder="Ingrese su nombre completo"
|
|
147
|
+
*
|
|
148
|
+
* @example
|
|
149
|
+
* placeholder="ejemplo@correo.com"
|
|
150
|
+
*/
|
|
151
|
+
placeholder?: string;
|
|
152
|
+
/**
|
|
153
|
+
* Tipo de formato aplicado automáticamente al valor del campo.
|
|
154
|
+
* Determina cómo se muestra y valida el contenido ingresado.
|
|
155
|
+
*
|
|
156
|
+
* @default none
|
|
157
|
+
*
|
|
158
|
+
* @example
|
|
159
|
+
* formatType="chileanRut"
|
|
160
|
+
*
|
|
161
|
+
* @example
|
|
162
|
+
* formatType="phone"
|
|
163
|
+
*
|
|
164
|
+
* @example
|
|
165
|
+
* formatType="email"
|
|
166
|
+
*/
|
|
167
|
+
formatType?: FormatType;
|
|
168
|
+
/**
|
|
169
|
+
* Patrón de expresión regular para validación personalizada.
|
|
170
|
+
* Se aplica cuando formatType es "custom" o para validaciones adicionales.
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* formatPattern="^[A-Z]{2}[0-9]{6}$"
|
|
174
|
+
*
|
|
175
|
+
* @example
|
|
176
|
+
* formatPattern="\\d{4}-\\d{4}-\\d{4}-\\d{4}"
|
|
177
|
+
*/
|
|
178
|
+
formatPattern?: string;
|
|
179
|
+
/**
|
|
180
|
+
* Controla si el usuario puede editar el contenido del campo.
|
|
181
|
+
* Cuando es false, el campo se muestra como texto de solo lectura.
|
|
182
|
+
*
|
|
183
|
+
* @default true
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* editable={false}
|
|
187
|
+
*
|
|
188
|
+
* @example
|
|
189
|
+
* editable={userRole === 'admin'}
|
|
190
|
+
*/
|
|
191
|
+
editable?: boolean;
|
|
192
|
+
/**
|
|
193
|
+
* Longitud mínima requerida para el valor del campo.
|
|
194
|
+
* Se usa para validación y puede mostrar mensajes de error si no se cumple.
|
|
195
|
+
*
|
|
196
|
+
* @default 0
|
|
197
|
+
*
|
|
198
|
+
* @example
|
|
199
|
+
* minLength={8}
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* minLength={3}
|
|
203
|
+
*/
|
|
204
|
+
minLength?: number;
|
|
205
|
+
/**
|
|
206
|
+
* Longitud máxima permitida para el valor del campo.
|
|
207
|
+
* Limita la cantidad de caracteres que el usuario puede ingresar.
|
|
208
|
+
*
|
|
209
|
+
* @default 250
|
|
210
|
+
*
|
|
211
|
+
* @example
|
|
212
|
+
* maxLength={100}
|
|
213
|
+
*
|
|
214
|
+
* @example
|
|
215
|
+
* maxLength={50}
|
|
216
|
+
*/
|
|
217
|
+
maxLength?: number;
|
|
218
|
+
/**
|
|
219
|
+
* Función personalizada para aplicar formato al valor del campo.
|
|
220
|
+
* Se ejecuta cuando formatType es "custom" o para lógica de formato específica.
|
|
221
|
+
*
|
|
222
|
+
* @param value - Valor actual del campo a formatear
|
|
223
|
+
* @returns Valor formateado o el valor original si no se puede formatear
|
|
224
|
+
*
|
|
225
|
+
* @example
|
|
226
|
+
* formatFunction={(value) => value?.toUpperCase() || ""}
|
|
227
|
+
*
|
|
228
|
+
* @example
|
|
229
|
+
* formatFunction={(value) => {
|
|
230
|
+
* if (!value) return "";
|
|
231
|
+
* return value.replace(/\s+/g, "-").toLowerCase();
|
|
232
|
+
* }}
|
|
233
|
+
*/
|
|
234
|
+
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
235
|
+
/**
|
|
236
|
+
* Callback ejecutado cuando el valor del campo cambia.
|
|
237
|
+
* Recibe tanto el valor sin formato como el valor mostrado al usuario.
|
|
238
|
+
*
|
|
239
|
+
* @param value - Valor crudo sin formato aplicado
|
|
240
|
+
* @param displayValue - Valor formateado mostrado en el campo
|
|
241
|
+
*
|
|
242
|
+
* @example
|
|
243
|
+
* onChange={(value, displayValue) => {
|
|
244
|
+
* console.log('Valor guardado:', value);
|
|
245
|
+
* console.log('Valor mostrado:', displayValue);
|
|
246
|
+
* setFormData(prev => ({ ...prev, campo: value }));
|
|
247
|
+
* }}
|
|
248
|
+
*
|
|
249
|
+
* @example
|
|
250
|
+
* onChange={(value) => {
|
|
251
|
+
* if (value && value.length >= 3) {
|
|
252
|
+
* buscarSugerencias(value);
|
|
253
|
+
* }
|
|
254
|
+
* }}
|
|
255
|
+
*/
|
|
256
|
+
onChange?: (value: EFWInputValue, displayValue?: string) => void;
|
|
257
|
+
}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
import { EFWInputValue, FormatType } from './EFWInput.types';
|
|
2
|
+
|
|
3
|
+
interface FormatOptions {
|
|
4
|
+
formatPattern?: string;
|
|
5
|
+
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
6
|
+
}
|
|
7
|
+
export declare const formatChileanRut: (rawValue: string) => string;
|
|
8
|
+
export declare const validateChileanRut: (rutCompleto: string) => boolean;
|
|
9
|
+
export declare const validateEmail: (email: string) => boolean;
|
|
10
|
+
export declare const formatNumber: (number: string | number, prefix?: string, thousand_separator?: string, decimal_separator?: string) => string;
|
|
11
|
+
export declare const stripFormatNumber: (value?: string) => string;
|
|
12
|
+
/**
|
|
13
|
+
* Quita el formato de un valor según el tipo especificado
|
|
14
|
+
*/
|
|
15
|
+
export declare const stripFormatting: (value: string, formatType: FormatType) => string;
|
|
16
|
+
/**
|
|
17
|
+
* Aplica formato a un valor según el tipo y opciones especificadas
|
|
18
|
+
*/
|
|
19
|
+
export declare const applyFormatting: (value: string, formatType: FormatType, options?: FormatOptions) => string;
|
|
20
|
+
export {};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
const p = (t) => {
|
|
2
|
+
const n = (t || "").toString(), r = n.replace(/^0+/, "");
|
|
3
|
+
let e = "";
|
|
4
|
+
if (r != "" && r.length > 1) {
|
|
5
|
+
const l = r.replace(/\./g, "").replace(/-/g, ""), s = l.substring(0, l.length - 1);
|
|
6
|
+
let c = 0, o = 1;
|
|
7
|
+
for (c = s.length - 1; c >= 0; c--)
|
|
8
|
+
e = s.charAt(c) + e, o % 3 == 0 && o <= s.length - 1 && (e = "." + e), o++;
|
|
9
|
+
const g = l.substring(l.length - 1);
|
|
10
|
+
return e = e + "-" + g, e;
|
|
11
|
+
} else
|
|
12
|
+
return n;
|
|
13
|
+
}, u = (t) => {
|
|
14
|
+
if (t = t || "", t = t.replace(/\./g, ""), !/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test(t))
|
|
15
|
+
return !1;
|
|
16
|
+
const n = t.split("-");
|
|
17
|
+
let r = n[1];
|
|
18
|
+
const e = n[0], i = function(l) {
|
|
19
|
+
let s = 0, c = 1;
|
|
20
|
+
for (; l; l = Math.floor(l / 10))
|
|
21
|
+
c = (c + l % 10 * (9 - s++ % 6)) % 11;
|
|
22
|
+
return c ? c - 1 : "k";
|
|
23
|
+
};
|
|
24
|
+
return r == "K" && (r = "k"), i(e) == r;
|
|
25
|
+
}, d = (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), m = (t, n, r = ",", e = ".") => {
|
|
26
|
+
if (t == null) return "";
|
|
27
|
+
typeof t == "number" && (t = t.toString(), Number.isInteger(t) || (t = t.replace(".", e))), r = r || ",", e = e || ".";
|
|
28
|
+
const i = new RegExp("[^" + e + "\\d]", "g"), s = t.replace(i, "").toString().split(e), c = s[0].length % 3;
|
|
29
|
+
let o = s[0].substr(0, c);
|
|
30
|
+
const g = s[0].substr(c).match(/\d{3}/g);
|
|
31
|
+
return g && (o += (c ? r : "") + g.join(r)), o = s[1] != null ? o + e + s[1] : o, n == null ? o : o ? n + o : "";
|
|
32
|
+
}, $ = (t = "") => {
|
|
33
|
+
const n = t.toString().replace(/[^\d.]/g, "");
|
|
34
|
+
return isNaN(Number(n)) || n === "" ? "" : n;
|
|
35
|
+
}, f = {
|
|
36
|
+
none: (t) => t,
|
|
37
|
+
email: (t) => t,
|
|
38
|
+
phone: (t) => t.replace(/\D/g, ""),
|
|
39
|
+
creditCard: (t) => t.replace(/\D/g, ""),
|
|
40
|
+
chileanRut: (t) => {
|
|
41
|
+
console.log("value", t, typeof t);
|
|
42
|
+
const n = t.replace(/[^\dkK-]/gi, ""), r = n.includes("-"), e = n.replace(/-/g, "");
|
|
43
|
+
if (r && e.length >= 2) {
|
|
44
|
+
const i = e.length - 1;
|
|
45
|
+
return e.slice(0, i) + "-" + e.slice(i);
|
|
46
|
+
}
|
|
47
|
+
return e;
|
|
48
|
+
},
|
|
49
|
+
date: (t) => t.replace(/\D/g, ""),
|
|
50
|
+
//number: (value) => stripFormatNumber(value || ''),
|
|
51
|
+
custom: (t) => t.replace(/\D/g, "")
|
|
52
|
+
// Por defecto, podría personalizarse
|
|
53
|
+
}, a = {
|
|
54
|
+
none: (t) => t,
|
|
55
|
+
email: (t) => t,
|
|
56
|
+
phone: (t) => t.length <= 3 ? t : t.length <= 6 ? `(${t.slice(0, 3)}) ${t.slice(3)}` : `(${t.slice(0, 3)}) ${t.slice(3, 6)}-${t.slice(6, 10)}`,
|
|
57
|
+
creditCard: (t) => t.replace(/(\d{4})(?=\d)/g, "$1 ").trim(),
|
|
58
|
+
chileanRut: (t) => p(t),
|
|
59
|
+
date: (t) => 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, 8)}`,
|
|
60
|
+
// number: (value) => {
|
|
61
|
+
// if (isNaN(Number(value))) return value; // Si no es un número válido, retornar el valor original
|
|
62
|
+
// return formatNumber(value)
|
|
63
|
+
// },
|
|
64
|
+
custom: (t, n = {}) => {
|
|
65
|
+
if (n.formatFunction)
|
|
66
|
+
return n.formatFunction(t) || t;
|
|
67
|
+
if (n.formatPattern) {
|
|
68
|
+
let r = "", e = 0;
|
|
69
|
+
for (let i = 0; i < n.formatPattern.length && e < t.length; i++)
|
|
70
|
+
n.formatPattern[i] === "#" ? (r += t[e], e++) : (r += n.formatPattern[i], n.formatPattern[i] === t[e] && e++);
|
|
71
|
+
return r;
|
|
72
|
+
}
|
|
73
|
+
return t;
|
|
74
|
+
}
|
|
75
|
+
}, F = (t, n) => t ? (console.log("FormatType", n), (f[n] || f.none)(t)) : "", y = (t, n, r = {}) => t ? (a[n] || a.none)(t, r) : "";
|
|
76
|
+
export {
|
|
77
|
+
y as applyFormatting,
|
|
78
|
+
p as formatChileanRut,
|
|
79
|
+
m as formatNumber,
|
|
80
|
+
$ as stripFormatNumber,
|
|
81
|
+
F as stripFormatting,
|
|
82
|
+
u as validateChileanRut,
|
|
83
|
+
d as validateEmail
|
|
84
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
+
import { EFWField as q } from "../EFWField/EFWField.js";
|
|
3
|
+
import { EFWInput as w } from "../EFWInput/EFWInput.js";
|
|
4
|
+
const P = (n) => {
|
|
5
|
+
const {
|
|
6
|
+
title: a,
|
|
7
|
+
infoLabel: o,
|
|
8
|
+
hint: i,
|
|
9
|
+
style: l = {},
|
|
10
|
+
size: r,
|
|
11
|
+
required: d = !1,
|
|
12
|
+
contentBefore: f,
|
|
13
|
+
contentAfter: h,
|
|
14
|
+
minLength: m = 0,
|
|
15
|
+
maxLength: s = 250,
|
|
16
|
+
validationState: g,
|
|
17
|
+
validationMessage: p,
|
|
18
|
+
value: u = "",
|
|
19
|
+
editable: e = !0,
|
|
20
|
+
disabled: c = !1,
|
|
21
|
+
hidden: C = !1,
|
|
22
|
+
onChange: F,
|
|
23
|
+
autoComplete: b = "off",
|
|
24
|
+
type: x = "text",
|
|
25
|
+
placeholder: L,
|
|
26
|
+
formatType: v = "none",
|
|
27
|
+
formatPattern: y,
|
|
28
|
+
formatFunction: E,
|
|
29
|
+
onValidationChange: W
|
|
30
|
+
} = n;
|
|
31
|
+
return /* @__PURE__ */ t(
|
|
32
|
+
q,
|
|
33
|
+
{
|
|
34
|
+
style: l,
|
|
35
|
+
title: a,
|
|
36
|
+
infoLabel: o,
|
|
37
|
+
weightLabel: e ? "regular" : "semibold",
|
|
38
|
+
hint: i,
|
|
39
|
+
size: r,
|
|
40
|
+
required: d,
|
|
41
|
+
validationState: g,
|
|
42
|
+
validationMessage: p,
|
|
43
|
+
onValidationChange: W,
|
|
44
|
+
hidden: C,
|
|
45
|
+
children: /* @__PURE__ */ t(
|
|
46
|
+
w,
|
|
47
|
+
{
|
|
48
|
+
value: u,
|
|
49
|
+
editable: e,
|
|
50
|
+
onChange: (I, j) => {
|
|
51
|
+
F?.(I, j);
|
|
52
|
+
},
|
|
53
|
+
minLength: m,
|
|
54
|
+
maxLength: s,
|
|
55
|
+
disabled: c,
|
|
56
|
+
autoComplete: b,
|
|
57
|
+
type: x,
|
|
58
|
+
placeholder: L,
|
|
59
|
+
contentBefore: f,
|
|
60
|
+
contentAfter: h,
|
|
61
|
+
formatType: v,
|
|
62
|
+
formatPattern: y,
|
|
63
|
+
formatFunction: E
|
|
64
|
+
}
|
|
65
|
+
)
|
|
66
|
+
}
|
|
67
|
+
);
|
|
68
|
+
};
|
|
69
|
+
export {
|
|
70
|
+
P as EFWInputField
|
|
71
|
+
};
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
import { EFWFieldProps } from '../EFWField/EFWField.types';
|
|
2
|
+
import { EFWInputProps, EFWInputValue } from '../EFWInput/EFWInput.types';
|
|
3
|
+
|
|
4
|
+
export type EFWInputFieldValue = EFWInputValue;
|
|
5
|
+
export interface EFWInputFieldProps extends Omit<EFWFieldProps, 'children'>, EFWInputProps {
|
|
6
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
File without changes
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { EFWNumberInputProps } from './EFWNumberInput.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Componente de entrada numérica personalizada con soporte para formateo y validación.
|
|
5
|
+
* @param props - Propiedades del componente.
|
|
6
|
+
* @returns Componente de entrada o texto según el modo editable.
|
|
7
|
+
*/
|
|
8
|
+
export declare const EFWNumberInput: (props: EFWNumberInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,183 @@
|
|
|
1
|
+
import { jsx as k, Fragment as Z } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as ee, tokens as N, mergeClasses as re, Input as te, Text as ne } from "@fluentui/react-components";
|
|
3
|
+
import { useId as ae, useMemo as oe, useState as P, useRef as se, useCallback as B, useEffect as le } from "react";
|
|
4
|
+
import { applyFormatting as p, stripFormatting as x, isValidNumber as H } from "./EFWNumberInput.utils.js";
|
|
5
|
+
const ue = ee({
|
|
6
|
+
EFWNumberInputError: {
|
|
7
|
+
backgroundColor: N.colorPaletteRedBackground1,
|
|
8
|
+
"::after": {
|
|
9
|
+
borderBottomColor: N.colorPaletteRedBorder2,
|
|
10
|
+
borderBottomStyle: "solid",
|
|
11
|
+
borderBottomWidth: "2px"
|
|
12
|
+
}
|
|
13
|
+
},
|
|
14
|
+
EFWNumberInput: {
|
|
15
|
+
"& [disabled]": {
|
|
16
|
+
backgroundColor: N.colorNeutralBackground3,
|
|
17
|
+
color: N.colorNeutralForeground2,
|
|
18
|
+
"&::placeholder": {
|
|
19
|
+
color: "transparent"
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
"&:has(span + [disabled])": {
|
|
23
|
+
backgroundColor: N.colorNeutralBackground3
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}), ie = () => {
|
|
27
|
+
const i = /* @__PURE__ */ new Map();
|
|
28
|
+
return (r, t) => {
|
|
29
|
+
const $ = `${r}-${t}`;
|
|
30
|
+
if (!i.has($)) {
|
|
31
|
+
const E = r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), g = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
32
|
+
i.set($, {
|
|
33
|
+
validation: new RegExp(`^-?[\\d${E}]*${g}?\\d*$`),
|
|
34
|
+
thousandSeparator: new RegExp(`^\\d+${E}0{1,2}$`),
|
|
35
|
+
progressPatterns: [
|
|
36
|
+
new RegExp("^-?$"),
|
|
37
|
+
new RegExp(`^-?\\d+${g}$`),
|
|
38
|
+
new RegExp(`^-?\\d+${g}0+$`),
|
|
39
|
+
new RegExp(`^-?[\\d${E}]+${g}$`),
|
|
40
|
+
new RegExp(`^-?[\\d${E}]+${g}0+$`)
|
|
41
|
+
]
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return i.get($);
|
|
45
|
+
};
|
|
46
|
+
}, ce = ie(), O = (i, r) => r.some((t) => t.test(i)), de = (i, r) => i.includes(r) && (i.endsWith("0") || i.endsWith(r) || /\.\d*0$/.test(i.replace(r, "."))), he = (i) => {
|
|
47
|
+
const {
|
|
48
|
+
value: r,
|
|
49
|
+
onChange: t,
|
|
50
|
+
editable: $ = !0,
|
|
51
|
+
disabled: E = !1,
|
|
52
|
+
className: g = "",
|
|
53
|
+
autoComplete: U = "off",
|
|
54
|
+
placeholder: _,
|
|
55
|
+
contentBefore: q,
|
|
56
|
+
contentAfter: G,
|
|
57
|
+
formatType: a = "number",
|
|
58
|
+
maxValue: y,
|
|
59
|
+
minValue: C,
|
|
60
|
+
validationState: J = "none",
|
|
61
|
+
setParentComponentState: d,
|
|
62
|
+
enableFormatting: W = !0,
|
|
63
|
+
thousandSeparator: v = ",",
|
|
64
|
+
decimalSeparator: f = "."
|
|
65
|
+
} = i, D = ue(), T = ae(), o = oe(() => ({
|
|
66
|
+
enableFormatting: W,
|
|
67
|
+
thousandSeparator: v,
|
|
68
|
+
decimalSeparator: f
|
|
69
|
+
}), [W, v, f]), [c, b] = P(() => p(r ? r.toString() : "", a, o)), [S, w] = P(!1), [V, M] = P(!1), u = se({
|
|
70
|
+
prevValue: r,
|
|
71
|
+
lastValidatedValue: "",
|
|
72
|
+
rawValue: r ? x(r.toString(), a, o) : ""
|
|
73
|
+
}), h = ce(v, f), F = B((n) => {
|
|
74
|
+
if (u.current.lastValidatedValue === n)
|
|
75
|
+
return S;
|
|
76
|
+
if (u.current.lastValidatedValue = n, a !== "number" || n.length === 0)
|
|
77
|
+
return d?.("none", ""), !1;
|
|
78
|
+
if (!h.validation.test(n))
|
|
79
|
+
return d?.("error", "El valor ingresado no es un número válido."), !0;
|
|
80
|
+
const s = x(n, a, o);
|
|
81
|
+
if (O(n, h.progressPatterns))
|
|
82
|
+
return d?.("none", ""), !1;
|
|
83
|
+
if (s && !H(s))
|
|
84
|
+
return d?.("error", "El valor ingresado no es un número válido."), !0;
|
|
85
|
+
if (s) {
|
|
86
|
+
const e = Number(s);
|
|
87
|
+
if (C !== void 0 && e < C)
|
|
88
|
+
return d?.("error", `El valor debe ser mayor o igual a ${p(C.toString(), "number", o)}.`), !0;
|
|
89
|
+
if (y !== void 0 && e > y)
|
|
90
|
+
return d?.("error", `El valor debe ser menor o igual a ${p(y.toString(), "number", o)}.`), !0;
|
|
91
|
+
}
|
|
92
|
+
return d?.("none", ""), !1;
|
|
93
|
+
}, [a, h, d, C, y, o, S]);
|
|
94
|
+
le(() => {
|
|
95
|
+
if (r !== u.current.prevValue && !V) {
|
|
96
|
+
const n = x(r ? r.toString() : "", a, o), s = p(n, a, o);
|
|
97
|
+
u.current.rawValue = n, u.current.prevValue = r, b(s), w(!1);
|
|
98
|
+
}
|
|
99
|
+
}, [r, a, o, V]);
|
|
100
|
+
const K = B(() => {
|
|
101
|
+
if (a !== "number" || !V) return;
|
|
102
|
+
M(!1);
|
|
103
|
+
let n = c;
|
|
104
|
+
if (n.endsWith(f) && (n = n.slice(0, -1)), n.includes(f)) {
|
|
105
|
+
const [e, I] = n.split(f);
|
|
106
|
+
I && /^0+$/.test(I) && (n = e);
|
|
107
|
+
}
|
|
108
|
+
const s = x(n, a, o);
|
|
109
|
+
if (s && H(s)) {
|
|
110
|
+
const e = p(s, a, o);
|
|
111
|
+
u.current.rawValue = s, b(e), w(!1), t?.(Number(s), e);
|
|
112
|
+
} else (c === "" || c === "-") && (u.current.rawValue = "", b(""), w(!1), t?.(null, ""));
|
|
113
|
+
}, [c, a, o, t, f, V]), L = B((n, s) => {
|
|
114
|
+
if (typeof s.value != "string") return;
|
|
115
|
+
const e = s.value;
|
|
116
|
+
if (V || M(!0), b(e), e.length < c.length && c.startsWith(e) && h.thousandSeparator.test(e)) {
|
|
117
|
+
const l = e.replace(new RegExp(v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), ""), R = p(l, a, o), A = F(R);
|
|
118
|
+
u.current.rawValue = l, b(R), w(A), t?.(A || !l ? null : Number(l), R);
|
|
119
|
+
return;
|
|
120
|
+
}
|
|
121
|
+
const m = x(e, a, o), j = F(e), z = de(e, f), Y = O(e, h.progressPatterns);
|
|
122
|
+
if (u.current.rawValue = m, w(j), j)
|
|
123
|
+
if (m && h.validation.test(e))
|
|
124
|
+
if (z)
|
|
125
|
+
t?.(Number(m), e);
|
|
126
|
+
else {
|
|
127
|
+
const l = p(m, a, o);
|
|
128
|
+
b(l), t?.(Number(m), l);
|
|
129
|
+
}
|
|
130
|
+
else
|
|
131
|
+
t?.(null, e);
|
|
132
|
+
else if (m)
|
|
133
|
+
if (z)
|
|
134
|
+
t?.(Number(m), e);
|
|
135
|
+
else {
|
|
136
|
+
const l = p(m, a, o);
|
|
137
|
+
b(l), t?.(Number(m), l);
|
|
138
|
+
}
|
|
139
|
+
else if (Y) {
|
|
140
|
+
const l = e.replace(/[^\d-]/g, "");
|
|
141
|
+
l && l !== "-" ? (u.current.rawValue = l, t?.(Number(l), e)) : (u.current.rawValue = "", t?.(null, e));
|
|
142
|
+
} else
|
|
143
|
+
u.current.rawValue = "", t?.(null, "");
|
|
144
|
+
}, [
|
|
145
|
+
c,
|
|
146
|
+
V,
|
|
147
|
+
h,
|
|
148
|
+
v,
|
|
149
|
+
a,
|
|
150
|
+
o,
|
|
151
|
+
F,
|
|
152
|
+
f,
|
|
153
|
+
t
|
|
154
|
+
]), Q = J === "error" || S, X = re(
|
|
155
|
+
g,
|
|
156
|
+
D.EFWNumberInput,
|
|
157
|
+
Q && D.EFWNumberInputError
|
|
158
|
+
);
|
|
159
|
+
return /* @__PURE__ */ k(Z, { children: $ ? /* @__PURE__ */ k(
|
|
160
|
+
te,
|
|
161
|
+
{
|
|
162
|
+
className: X,
|
|
163
|
+
id: T,
|
|
164
|
+
name: T,
|
|
165
|
+
type: "text",
|
|
166
|
+
placeholder: _,
|
|
167
|
+
contentBefore: q,
|
|
168
|
+
contentAfter: G,
|
|
169
|
+
disabled: E,
|
|
170
|
+
value: c,
|
|
171
|
+
"data-raw-value": u.current.rawValue,
|
|
172
|
+
autoComplete: U,
|
|
173
|
+
autoCorrect: "off",
|
|
174
|
+
autoCapitalize: "off",
|
|
175
|
+
spellCheck: "false",
|
|
176
|
+
onChange: L,
|
|
177
|
+
onBlur: K
|
|
178
|
+
}
|
|
179
|
+
) : /* @__PURE__ */ k(ne, { style: c ? void 0 : { opacity: 0.7 }, children: c || "Sin datos disponibles" }) });
|
|
180
|
+
};
|
|
181
|
+
export {
|
|
182
|
+
he as EFWNumberInput
|
|
183
|
+
};
|