@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
package/LICENSE
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
Creative Commons Attribution-NoDerivatives 4.0 International (CC BY-ND 4.0)
|
|
2
|
+
|
|
3
|
+
El paquete de software "Porygon" es desarrollado y mantenido por Envision (https://envision.cl/).
|
|
4
|
+
|
|
5
|
+
Al utilizar este software, debe:
|
|
6
|
+
- Dar crédito apropiado mencionando que utiliza el paquete Porygon
|
|
7
|
+
- Incluir una atribución visible a Envision como autor original
|
|
8
|
+
|
|
9
|
+
No se permiten modificaciones ni la creación de obras derivadas basadas en este software.
|
|
10
|
+
|
|
11
|
+
Para más información sobre los términos de esta licencia, visite https://creativecommons.org/licenses/by-nd/4.0/
|
package/README.md
ADDED
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
# Porygon
|
|
2
|
+
Porygon es un paquete desarrollado por Envision, en el que se incluye varios componentes React diseñados inicialmente para gestionar la lógica y el manejo de formularios y tablas. Esto nos permite trabajar con un stack tecnológico moderno y sencillo.
|
|
3
|
+
Estos componentes cumplen con los siguientes criterios:
|
|
4
|
+
|
|
5
|
+
- **Personalizables**: Vienen con un estilo predeterminado, pero se pueden integrar fácilmente con otros estilos visuales. Esto se puede lograr mediante el uso de tokens, que permiten una customización flexible de colores, tamaños y otros atributos visuales sin alterar el código base.
|
|
6
|
+
|
|
7
|
+
- **Rendimiento**: Están optimizados para un renderizado eficiente y de alto rendimiento, lo que minimiza el tiempo de carga y el consumo de recursos en aplicaciones grandes. Por ejemplo, incorporan técnicas como la virtualización en tablas para manejar grandes conjuntos de datos sin ralentizar la interfaz, y evitan re-renderizados innecesarios mediante memoización y optimizaciones internas.
|
|
8
|
+
|
|
9
|
+
- **Accesibilidad**: Cumplen con las directrices **WCAG 2.1** (Web Content Accessibility Guidelines 2.1), que son un conjunto de estándares internacionales desarrollados por el W3C para hacer que el contenido web sea más accesible para personas con discapacidades. Un ejemplo es el soporte para lectores de pantalla, donde los componentes incluyen atributos ARIA adecuados para describir elementos como botones o campos de formulario, permitiendo una navegación por teclado intuitiva y alternativas textuales para imágenes.
|
|
10
|
+
|
|
11
|
+
## Instalación
|
|
12
|
+
|
|
13
|
+
Porygon es compatible con **React 17**, **18** y **19**. Instala el paquete con npm:
|
|
14
|
+
|
|
15
|
+
```bash
|
|
16
|
+
npm install @grupoenvision/porygon
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
## Configuración inicial
|
|
20
|
+
|
|
21
|
+
Los componentes de Porygon utilizan CSS-in-JS. Esta técnica requiere un renderizador de estilos que inserte CSS en el DOM cuando sea necesario. Se utiliza el contexto de React para proporcionar este renderizador de estilos.
|
|
22
|
+
Como los componentes se encuentran basados en Fluent 2, se debe utilzar el componente `<FluentProvider />` en la raíz de tu aplicación y pasar un tema al prop `theme`:
|
|
23
|
+
|
|
24
|
+
```jsx
|
|
25
|
+
import React from 'react';
|
|
26
|
+
import { createRoot } from 'react-dom/client';
|
|
27
|
+
import { FluentProvider, webLightTheme } from '@fluentui/react-components';
|
|
28
|
+
|
|
29
|
+
import App from './App';
|
|
30
|
+
|
|
31
|
+
const root = createRoot(document.getElementById('root'));
|
|
32
|
+
|
|
33
|
+
root.render(
|
|
34
|
+
<FluentProvider theme={webLightTheme}>
|
|
35
|
+
<App />
|
|
36
|
+
</FluentProvider>
|
|
37
|
+
);
|
|
38
|
+
```
|
|
39
|
+
|
|
40
|
+
Listo, ahora puedes utilizar cualquier componete de `@envisiongroup/porygon` dentro de tu componente `App`. Revisa la sección **react-components** del menú lateral de esta página.
|
|
41
|
+
Los componentes se encuentran organizados siguiendo la estructura jerárquica especificada.
|
|
42
|
+
|
|
43
|
+
### Opciones de tema y customización
|
|
44
|
+
|
|
45
|
+
Porygon soporta los temas que Fluent tiene por defecto:
|
|
46
|
+
|
|
47
|
+
- `webLightTheme` - Tema claro para aplicaciones web
|
|
48
|
+
- `webDarkTheme` - Tema oscuro para aplicaciones web
|
|
49
|
+
- `teamsLightTheme` - Tema claro compatible con Microsoft Teams
|
|
50
|
+
- `teamsDarkTheme` - Tema oscuro compatible with Microsoft Teams
|
|
51
|
+
|
|
52
|
+
Sin embargo, es probable que prefieras usar un tema personalizado. Para esto, puedes crear uno mediante el [generador de temas de Fluent](/docs/diseñador-de-temas--docs).
|
|
53
|
+
Una vez que lo hayas creado, se guarda en un archivo JSON, que luego puedes importar y utilizar en tu aplicación.
|
|
54
|
+
|
|
55
|
+
```jsx
|
|
56
|
+
import {
|
|
57
|
+
FluentProvider,
|
|
58
|
+
webLightTheme,
|
|
59
|
+
webDarkTheme
|
|
60
|
+
} from '@fluentui/react-components';
|
|
61
|
+
import customTheme from '../themes/customTheme.json';
|
|
62
|
+
|
|
63
|
+
// Ejemplo con tema customizado
|
|
64
|
+
root.render(
|
|
65
|
+
<FluentProvider theme={customTheme}>
|
|
66
|
+
<App />
|
|
67
|
+
</FluentProvider>
|
|
68
|
+
);
|
|
69
|
+
```
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
export * from './react-components/buttons/EFWButton';
|
|
2
|
+
export * from './react-components/buttons/EFWDrawerButton';
|
|
3
|
+
export * from './react-components/buttons/EFWGroupButton';
|
|
4
|
+
export * from './react-components/commons/utils';
|
|
5
|
+
export * from './react-components/fields/EFWAttachments';
|
|
6
|
+
export * from './react-components/fields/EFWAttachmentsField';
|
|
7
|
+
export * from './react-components/fields/EFWDatePicker';
|
|
8
|
+
export * from './react-components/fields/EFWDatePickerField';
|
|
9
|
+
export * from './react-components/fields/EFWField';
|
|
10
|
+
export * from './react-components/fields/EFWInput';
|
|
11
|
+
export * from './react-components/fields/EFWInputField';
|
|
12
|
+
export * from './react-components/fields/EFWNumberInput';
|
|
13
|
+
export * from './react-components/fields/EFWNumberInputField';
|
|
14
|
+
export * from './react-components/fields/EFWSwitch';
|
|
15
|
+
export * from './react-components/fields/EFWSwitchField';
|
|
16
|
+
export * from './react-components/fields/EFWTagPicker';
|
|
17
|
+
export * from './react-components/fields/EFWTagPickerField';
|
|
18
|
+
export * from './react-components/fields/EFWTextArea';
|
|
19
|
+
export * from './react-components/fields/EFWTextAreaField';
|
|
20
|
+
export * from './react-components/forms/EFWForm';
|
|
21
|
+
export * from './react-components/forms/EFWFormMessageBarGroup';
|
|
22
|
+
export * from './react-components/forms/EFWMessageBarManager/EFWMessageBarManager';
|
|
23
|
+
export * from './react-components/hooks/useDrawer';
|
|
24
|
+
export * from './react-components/tables/EFWTable';
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import { formatFileSize as o, getErrorMessage as t, getFileIconUrl as F } from "./react-components/commons/utils.js";
|
|
2
|
+
import { EFWMessageBarManager as p } from "./react-components/forms/EFWMessageBarManager/EFWMessageBarManager.js";
|
|
3
|
+
import { EFWButton as f } from "./react-components/buttons/EFWButton/EFWButton.js";
|
|
4
|
+
import { useEFWButton as W } from "./react-components/buttons/EFWButton/EFWButton.hooks.js";
|
|
5
|
+
import { EFWDrawerButton as i } from "./react-components/buttons/EFWDrawerButton/EFWDrawerButton.js";
|
|
6
|
+
import { EFWGroupButton as u } from "./react-components/buttons/EFWGroupButton/EFWGroupButton.js";
|
|
7
|
+
import { EFWAttachment as s } from "./react-components/fields/EFWAttachments/EFWAttachments.js";
|
|
8
|
+
import { EFWAttachmentsField as d } from "./react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js";
|
|
9
|
+
import { EFWDatePicker as T } from "./react-components/fields/EFWDatePicker/EFWDatePicker.js";
|
|
10
|
+
import { EFWDatePickerField as D } from "./react-components/fields/EFWDatePickerField/EFWDatePickerField.js";
|
|
11
|
+
import { EFWField as b } from "./react-components/fields/EFWField/EFWField.js";
|
|
12
|
+
import { EFWInput as k } from "./react-components/fields/EFWInput/EFWInput.js";
|
|
13
|
+
import { EFWInputField as A } from "./react-components/fields/EFWInputField/EFWInputField.js";
|
|
14
|
+
import { EFWNumberInput as P } from "./react-components/fields/EFWNumberInput/EFWNumberInput.js";
|
|
15
|
+
import { EFWNumberInputField as C } from "./react-components/fields/EFWNumberInputField/EFWNumberInputField.js";
|
|
16
|
+
import { EFWSwitch as N } from "./react-components/fields/EFWSwitch/EFWSwitch.js";
|
|
17
|
+
import { EFWSwitchField as z } from "./react-components/fields/EFWSwitchField/EFWSwitchField.js";
|
|
18
|
+
import { EFWTagPicker as j } from "./react-components/fields/EFWTagPicker/EFWTagPicker.js";
|
|
19
|
+
import { EFWTagPickerField as v } from "./react-components/fields/EFWTagPickerField/EFWTagPickerField.js";
|
|
20
|
+
import { EFWTextArea as J } from "./react-components/fields/EFWTextArea/EFWTextArea.js";
|
|
21
|
+
import { EFWTextAreaField as L } from "./react-components/fields/EFWTextAreaField/EFWTextAreaField.js";
|
|
22
|
+
import { getEFWFormFieldDisplayText as Q } from "./react-components/forms/EFWForm/EFWForm.converter.js";
|
|
23
|
+
import { useFormController as V } from "./react-components/forms/EFWForm/EFWForm.hooks.js";
|
|
24
|
+
import { EFWForm as Y } from "./react-components/forms/EFWForm/EFWForm.js";
|
|
25
|
+
import { EFWFormMessageBarGroup as _ } from "./react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.js";
|
|
26
|
+
import { useDrawer as rr } from "./react-components/hooks/useDrawer/useDrawer.js";
|
|
27
|
+
import { EFWTable as or } from "./react-components/tables/EFWTable/EFWTable.js";
|
|
28
|
+
import { useTableController as Fr } from "./react-components/tables/EFWTable/hooks/useTableController/useTableController.js";
|
|
29
|
+
export {
|
|
30
|
+
s as EFWAttachment,
|
|
31
|
+
d as EFWAttachmentsField,
|
|
32
|
+
f as EFWButton,
|
|
33
|
+
T as EFWDatePicker,
|
|
34
|
+
D as EFWDatePickerField,
|
|
35
|
+
i as EFWDrawerButton,
|
|
36
|
+
b as EFWField,
|
|
37
|
+
Y as EFWForm,
|
|
38
|
+
_ as EFWFormMessageBarGroup,
|
|
39
|
+
u as EFWGroupButton,
|
|
40
|
+
k as EFWInput,
|
|
41
|
+
A as EFWInputField,
|
|
42
|
+
p as EFWMessageBarManager,
|
|
43
|
+
P as EFWNumberInput,
|
|
44
|
+
C as EFWNumberInputField,
|
|
45
|
+
N as EFWSwitch,
|
|
46
|
+
z as EFWSwitchField,
|
|
47
|
+
or as EFWTable,
|
|
48
|
+
j as EFWTagPicker,
|
|
49
|
+
v as EFWTagPickerField,
|
|
50
|
+
J as EFWTextArea,
|
|
51
|
+
L as EFWTextAreaField,
|
|
52
|
+
o as formatFileSize,
|
|
53
|
+
Q as getEFWFormFieldDisplayText,
|
|
54
|
+
t as getErrorMessage,
|
|
55
|
+
F as getFileIconUrl,
|
|
56
|
+
rr as useDrawer,
|
|
57
|
+
W as useEFWButton,
|
|
58
|
+
V as useFormController,
|
|
59
|
+
Fr as useTableController
|
|
60
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { EFWButtonProps } from './EFWButton.types';
|
|
2
|
+
import * as React from "react";
|
|
3
|
+
/**
|
|
4
|
+
* Componente de botón mejorado con estados de carga, éxito y error.
|
|
5
|
+
*
|
|
6
|
+
* EFWButton extiende el componente Button de Fluent UI agregando:
|
|
7
|
+
* - Manejo automático de estados de carga
|
|
8
|
+
* - Visualización de estados de éxito y error
|
|
9
|
+
* - Iconos de estado opcionales
|
|
10
|
+
* - Tooltips configurables
|
|
11
|
+
* - Manejo robusto de errores
|
|
12
|
+
* - Callbacks personalizables
|
|
13
|
+
*
|
|
14
|
+
* @component
|
|
15
|
+
* @param {EFWButtonProps} props - Propiedades del componente
|
|
16
|
+
* @returns {React.ReactElement} Elemento JSX del botón con estados mejorados
|
|
17
|
+
*
|
|
18
|
+
* @example
|
|
19
|
+
* // Uso básico
|
|
20
|
+
* <EFWButton onClick={async () => await saveData()}>
|
|
21
|
+
* Guardar
|
|
22
|
+
* </EFWButton>
|
|
23
|
+
*
|
|
24
|
+
* @example
|
|
25
|
+
* // Uso avanzado con configuración completa
|
|
26
|
+
* <EFWButton
|
|
27
|
+
* onClick={async () => {
|
|
28
|
+
* try {
|
|
29
|
+
* await complexOperation();
|
|
30
|
+
* return { success: true };
|
|
31
|
+
* } catch (error) {
|
|
32
|
+
* return { success: false, error: error.message };
|
|
33
|
+
* }
|
|
34
|
+
* }}
|
|
35
|
+
* loadingText="Procesando datos..."
|
|
36
|
+
* autoLoading={true}
|
|
37
|
+
* successConfig={{
|
|
38
|
+
* text: "¡Completado!",
|
|
39
|
+
* timeout: 3000,
|
|
40
|
+
* onSuccess: () => showNotification("Operación exitosa")
|
|
41
|
+
* }}
|
|
42
|
+
* errorConfig={{
|
|
43
|
+
* text: "Error",
|
|
44
|
+
* timeout: 5000,
|
|
45
|
+
* onError: (error) => logError(error)
|
|
46
|
+
* }}
|
|
47
|
+
* tooltips={{
|
|
48
|
+
* idle: "Haz clic para procesar",
|
|
49
|
+
* loading: "Procesando...",
|
|
50
|
+
* success: "Operación completada",
|
|
51
|
+
* error: "Ocurrió un error"
|
|
52
|
+
* }}
|
|
53
|
+
* showStatusIcons={true}
|
|
54
|
+
* appearance="primary"
|
|
55
|
+
* >
|
|
56
|
+
* Procesar Datos
|
|
57
|
+
* </EFWButton>
|
|
58
|
+
*/
|
|
59
|
+
export declare const EFWButton: React.FC<EFWButtonProps>;
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { EFWButtonHandle, UseEFWButtonOptions } from './EFWButton.types';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Hook personalizado para manejar el estado y comportamiento de EFWButton.
|
|
5
|
+
*
|
|
6
|
+
* Proporciona un conjunto completo de funcionalidades para manejar estados de carga,
|
|
7
|
+
* éxito y error en botones con operaciones asíncronas. Incluye manejo automático
|
|
8
|
+
* de timeouts, callbacks y transiciones de estado.
|
|
9
|
+
*
|
|
10
|
+
* @param {UseEFWButtonOptions} options - Opciones de configuración para el hook
|
|
11
|
+
* @param {Function} [options.onError] - Callback ejecutado cuando ocurre un error
|
|
12
|
+
* @param {Function} [options.onSuccess] - Callback ejecutado en operación exitosa
|
|
13
|
+
* @param {number} [options.successTimeout=2000] - Timeout para estado de éxito (ms)
|
|
14
|
+
* @param {number} [options.errorTimeout=2000] - Timeout para estado de error (ms)
|
|
15
|
+
* @param {boolean} [options.autoReset=true] - Auto-reseteo después de éxito/error
|
|
16
|
+
*
|
|
17
|
+
* @returns {EFWButtonHandle} Objeto con estado actual y métodos de control
|
|
18
|
+
*
|
|
19
|
+
* @example
|
|
20
|
+
* // Uso básico
|
|
21
|
+
* const buttonHandle = useEFWButton();
|
|
22
|
+
*
|
|
23
|
+
* @example
|
|
24
|
+
* // Configuración avanzada
|
|
25
|
+
* const buttonHandle = useEFWButton({
|
|
26
|
+
* onSuccess: () => showNotification('¡Éxito!'),
|
|
27
|
+
* onError: (error) => logError(error),
|
|
28
|
+
* successTimeout: 3000,
|
|
29
|
+
* errorTimeout: 5000,
|
|
30
|
+
* autoReset: true
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* @example
|
|
34
|
+
* // Uso con executeAsync
|
|
35
|
+
* const handleSave = async () => {
|
|
36
|
+
* await buttonHandle.executeAsync(async () => {
|
|
37
|
+
* await saveData();
|
|
38
|
+
* return { success: true };
|
|
39
|
+
* });
|
|
40
|
+
* };
|
|
41
|
+
*
|
|
42
|
+
* @hook
|
|
43
|
+
* @since 1.0.0
|
|
44
|
+
*/
|
|
45
|
+
export declare const useEFWButton: (options?: UseEFWButtonOptions) => EFWButtonHandle;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
import * as t from "react";
|
|
2
|
+
const w = (T = {}) => {
|
|
3
|
+
const {
|
|
4
|
+
onError: k,
|
|
5
|
+
onSuccess: m,
|
|
6
|
+
successTimeout: i = 2e3,
|
|
7
|
+
errorTimeout: f = 2e3,
|
|
8
|
+
autoReset: a = !0
|
|
9
|
+
} = T, [E, s] = t.useState("idle"), [p, l] = t.useState(null), c = t.useRef(null), r = t.useCallback(() => {
|
|
10
|
+
c.current && (clearTimeout(c.current), c.current = null);
|
|
11
|
+
}, []), n = t.useCallback(() => {
|
|
12
|
+
s("idle"), l(null), r();
|
|
13
|
+
}, [r]), b = t.useCallback(() => {
|
|
14
|
+
s("loading"), l(null), r();
|
|
15
|
+
}, [r]), d = t.useCallback(() => {
|
|
16
|
+
s((e) => e === "loading" ? "idle" : e), r();
|
|
17
|
+
}, [r]), C = t.useCallback(() => {
|
|
18
|
+
s("success"), l(null), m?.(), a && i > 0 && (r(), c.current = setTimeout(n, i));
|
|
19
|
+
}, [m, a, i, n, r]), u = t.useCallback(
|
|
20
|
+
(e) => {
|
|
21
|
+
l(e), s("error"), k?.(e), a && f > 0 && (r(), c.current = setTimeout(n, f));
|
|
22
|
+
},
|
|
23
|
+
[k, a, f, n, r]
|
|
24
|
+
), S = t.useCallback(
|
|
25
|
+
(e) => {
|
|
26
|
+
if (!e)
|
|
27
|
+
d();
|
|
28
|
+
else if (typeof e == "object")
|
|
29
|
+
if (e.success)
|
|
30
|
+
C();
|
|
31
|
+
else {
|
|
32
|
+
const o = e.error instanceof Error ? e.error : new Error(String(e.error || "Operation failed"));
|
|
33
|
+
u(o);
|
|
34
|
+
}
|
|
35
|
+
},
|
|
36
|
+
[C, u, d]
|
|
37
|
+
), R = t.useCallback(
|
|
38
|
+
async (e) => {
|
|
39
|
+
try {
|
|
40
|
+
b();
|
|
41
|
+
const o = await e();
|
|
42
|
+
S(o);
|
|
43
|
+
} catch (o) {
|
|
44
|
+
const g = o instanceof Error ? o : new Error(String(o));
|
|
45
|
+
throw u(g), g;
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
[b, S, u]
|
|
49
|
+
);
|
|
50
|
+
return t.useEffect(() => () => {
|
|
51
|
+
r();
|
|
52
|
+
}, [r]), {
|
|
53
|
+
/** Estado actual del botón */
|
|
54
|
+
currentState: E,
|
|
55
|
+
/** Indica si el botón está en estado de carga */
|
|
56
|
+
isLoading: E === "loading",
|
|
57
|
+
/** Error actual o null */
|
|
58
|
+
error: p,
|
|
59
|
+
/** Función para resetear el estado */
|
|
60
|
+
reset: n,
|
|
61
|
+
/** Función para iniciar estado de carga */
|
|
62
|
+
setLoading: b,
|
|
63
|
+
/** Función para detener estado de carga */
|
|
64
|
+
stopLoading: d,
|
|
65
|
+
/** Función para establecer estado de éxito */
|
|
66
|
+
setSuccess: C,
|
|
67
|
+
/** Función para establecer estado de error */
|
|
68
|
+
setError: u,
|
|
69
|
+
/** Función para ejecutar operaciones asíncronas */
|
|
70
|
+
executeAsync: R
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
export {
|
|
74
|
+
w as useEFWButton
|
|
75
|
+
};
|
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
import { jsx as s } from "react/jsx-runtime";
|
|
2
|
+
import * as C from "react";
|
|
3
|
+
import { makeStyles as q, tokens as t, Tooltip as v, Spinner as K, Button as Q } from "@fluentui/react-components";
|
|
4
|
+
import { ErrorCircleRegular as U, CheckmarkRegular as V } from "@fluentui/react-icons";
|
|
5
|
+
import { useEFWButton as X } from "./EFWButton.hooks.js";
|
|
6
|
+
const Y = q({
|
|
7
|
+
/**
|
|
8
|
+
* Estilo para botón no interactivo (estado de carga con deshabilitación).
|
|
9
|
+
* Aplica opacidad reducida y deshabilita eventos de puntero.
|
|
10
|
+
*/
|
|
11
|
+
buttonNonInteractive: {
|
|
12
|
+
backgroundColor: t.colorNeutralBackground1,
|
|
13
|
+
border: `${t.strokeWidthThin} solid ${t.colorNeutralStroke1}`,
|
|
14
|
+
color: t.colorNeutralForeground1,
|
|
15
|
+
cursor: "default",
|
|
16
|
+
pointerEvents: "none",
|
|
17
|
+
opacity: 0.5,
|
|
18
|
+
"& .ms-Button-icon": {
|
|
19
|
+
color: t.colorStatusSuccessForeground1
|
|
20
|
+
}
|
|
21
|
+
},
|
|
22
|
+
/**
|
|
23
|
+
* Estilo para el estado de error del botón.
|
|
24
|
+
* Utiliza la paleta de colores rojos de Fluent UI.
|
|
25
|
+
*/
|
|
26
|
+
buttonError: {
|
|
27
|
+
backgroundColor: `${t.colorPaletteRedBackground1} !important`,
|
|
28
|
+
border: `${t.strokeWidthThin} solid ${t.colorPaletteRedBorder1} !important`,
|
|
29
|
+
color: `${t.colorPaletteRedForeground1} !important`
|
|
30
|
+
},
|
|
31
|
+
/**
|
|
32
|
+
* Estilo para el estado de éxito del botón.
|
|
33
|
+
* Utiliza la paleta de colores verdes de Fluent UI.
|
|
34
|
+
*/
|
|
35
|
+
buttonSuccess: {
|
|
36
|
+
backgroundColor: `${t.colorPaletteGreenBackground1} !important`,
|
|
37
|
+
border: `${t.strokeWidthThin} solid ${t.colorPaletteGreenBorder1} !important`,
|
|
38
|
+
color: `${t.colorPaletteGreenForeground1} !important`,
|
|
39
|
+
"& .ms-Button-icon": {
|
|
40
|
+
color: `${t.colorStatusSuccessForeground1} !important`
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
function Z(r) {
|
|
45
|
+
return r instanceof Error ? r : _(r) ? r === void 0 ? new Error("Operación fallida sin detalles (void)") : r.success ? new Error("Operación reportada como exitosa en un error") : r.error instanceof Error ? r.error : new Error(r.error || "Operación fallida sin mensaje") : new Error(String(r) || "Error desconocido");
|
|
46
|
+
}
|
|
47
|
+
function _(r) {
|
|
48
|
+
return r === void 0 ? !0 : typeof r == "object" && r !== null && "success" in r && typeof r.success == "boolean" && (r.error === void 0 || typeof r.error == "string" || r.error instanceof Error);
|
|
49
|
+
}
|
|
50
|
+
const L = (r) => {
|
|
51
|
+
if (!r) return "Ha ocurrido un error";
|
|
52
|
+
if (r instanceof Error) return r.message;
|
|
53
|
+
if (typeof r == "string") return r;
|
|
54
|
+
if (typeof r == "object" && r !== null) {
|
|
55
|
+
const n = r;
|
|
56
|
+
if (typeof n.message == "string") return n.message;
|
|
57
|
+
if (typeof n.error == "string") return n.error;
|
|
58
|
+
try {
|
|
59
|
+
return JSON.stringify(r);
|
|
60
|
+
} catch {
|
|
61
|
+
return "Error: No es posible parsear error";
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return String(r) || "Ha ocurrido un error";
|
|
65
|
+
}, sr = ({
|
|
66
|
+
onClick: r,
|
|
67
|
+
loadingText: n = "Procesando...",
|
|
68
|
+
disableOnLoading: u = !0,
|
|
69
|
+
autoLoading: l = !1,
|
|
70
|
+
successConfig: $ = {},
|
|
71
|
+
errorConfig: h = {},
|
|
72
|
+
tooltips: c,
|
|
73
|
+
showStatusIcons: d = !0,
|
|
74
|
+
autoReset: R = !0,
|
|
75
|
+
children: f,
|
|
76
|
+
disabled: m,
|
|
77
|
+
className: F,
|
|
78
|
+
appearance: P = "secondary",
|
|
79
|
+
icon: i,
|
|
80
|
+
...T
|
|
81
|
+
}) => {
|
|
82
|
+
const p = Y(), { onSuccess: x, timeout: w = 2e3, text: O } = $, { onError: W, timeout: G = 2e3, text: D } = h, { currentState: y, isLoading: g, error: H, setLoading: k, stopLoading: S, setSuccess: N, setError: a } = X({
|
|
83
|
+
onError: W,
|
|
84
|
+
onSuccess: x,
|
|
85
|
+
successTimeout: w,
|
|
86
|
+
errorTimeout: G,
|
|
87
|
+
autoReset: R
|
|
88
|
+
}), b = C.useCallback(
|
|
89
|
+
(o) => {
|
|
90
|
+
if (!o)
|
|
91
|
+
S();
|
|
92
|
+
else if (typeof o == "object")
|
|
93
|
+
if (o.success)
|
|
94
|
+
N();
|
|
95
|
+
else {
|
|
96
|
+
const e = o.error instanceof Error ? o.error : new Error(String(o.error || "Operación fallida"));
|
|
97
|
+
a(e);
|
|
98
|
+
}
|
|
99
|
+
},
|
|
100
|
+
[S, N, a]
|
|
101
|
+
), z = C.useCallback(async (o) => {
|
|
102
|
+
if (!(!r || g || m))
|
|
103
|
+
try {
|
|
104
|
+
const e = r(o);
|
|
105
|
+
if (e instanceof Promise) {
|
|
106
|
+
l && k();
|
|
107
|
+
const E = await e;
|
|
108
|
+
l && b(E);
|
|
109
|
+
} else
|
|
110
|
+
b(e);
|
|
111
|
+
} catch (e) {
|
|
112
|
+
const E = Z(e);
|
|
113
|
+
a(E);
|
|
114
|
+
}
|
|
115
|
+
}, [r, g, m, l, k, b, a]), A = () => {
|
|
116
|
+
const o = [F].filter(Boolean);
|
|
117
|
+
switch (y) {
|
|
118
|
+
case "loading":
|
|
119
|
+
return {
|
|
120
|
+
content: n,
|
|
121
|
+
icon: d ? /* @__PURE__ */ s(K, { size: "tiny" }) : i,
|
|
122
|
+
className: u ? [...o, p.buttonNonInteractive].join(" ") : o.join(" "),
|
|
123
|
+
tooltip: c?.loading
|
|
124
|
+
};
|
|
125
|
+
case "success":
|
|
126
|
+
return {
|
|
127
|
+
content: O ?? f,
|
|
128
|
+
icon: d ? /* @__PURE__ */ s(V, {}) : i,
|
|
129
|
+
className: [...o, p.buttonSuccess].join(" "),
|
|
130
|
+
tooltip: c?.success
|
|
131
|
+
};
|
|
132
|
+
case "error":
|
|
133
|
+
return {
|
|
134
|
+
content: D ?? f,
|
|
135
|
+
icon: d ? /* @__PURE__ */ s(U, {}) : i,
|
|
136
|
+
className: [...o, p.buttonError].join(" "),
|
|
137
|
+
tooltip: c?.error ?? L(H)
|
|
138
|
+
};
|
|
139
|
+
default:
|
|
140
|
+
return {
|
|
141
|
+
content: f,
|
|
142
|
+
icon: i,
|
|
143
|
+
className: o.join(" "),
|
|
144
|
+
tooltip: c?.idle
|
|
145
|
+
};
|
|
146
|
+
}
|
|
147
|
+
}, { content: I, icon: J, className: M, tooltip: B } = A(), j = /* @__PURE__ */ s(
|
|
148
|
+
Q,
|
|
149
|
+
{
|
|
150
|
+
...T,
|
|
151
|
+
appearance: P,
|
|
152
|
+
className: M,
|
|
153
|
+
disabled: m || u && g,
|
|
154
|
+
disabledFocusable: y === "loading" && u,
|
|
155
|
+
icon: J,
|
|
156
|
+
onClick: z,
|
|
157
|
+
children: I
|
|
158
|
+
}
|
|
159
|
+
);
|
|
160
|
+
return B ? /* @__PURE__ */ s(v, { content: B, relationship: "label", children: j }) : j;
|
|
161
|
+
};
|
|
162
|
+
export {
|
|
163
|
+
sr as EFWButton
|
|
164
|
+
};
|