@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/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { jsx as r, jsxs as L } from "react/jsx-runtime";
|
|
2
|
+
import { Text as V } from "@fluentui/react-components";
|
|
3
|
+
import { Edit20Regular as q } from "@fluentui/react-icons";
|
|
4
|
+
import { getErrorMessage as p } from "../../../../commons/utils.js";
|
|
5
|
+
import { mergeButtonProps as S, generateFormProps as U } from "../../components/EFWTableCommandBar/EFWTableCommandBar.utils.js";
|
|
6
|
+
import { useFormController as G } from "../../../../forms/EFWForm/EFWForm.hooks.js";
|
|
7
|
+
import { EFWForm as H } from "../../../../forms/EFWForm/EFWForm.js";
|
|
8
|
+
const ee = (m = {}) => {
|
|
9
|
+
const { formRef: f, getValues: g, validateForm: E, addMessageBar: a, setDisabled: i, removeAllMessagesBar: h } = G(), C = S({
|
|
10
|
+
enabled: !0,
|
|
11
|
+
props: {
|
|
12
|
+
children: "Editar",
|
|
13
|
+
icon: /* @__PURE__ */ r(q, {}),
|
|
14
|
+
drawerConfig: {
|
|
15
|
+
title: "Editar elemento",
|
|
16
|
+
size: "small",
|
|
17
|
+
position: "end"
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
}, m), { enabled: z, props: F, form: b } = C, { children: l, appearance: x, icon: c, drawerConfig: w } = F || {}, { title: v, size: B, position: k } = w || {};
|
|
21
|
+
return {
|
|
22
|
+
enabled: z,
|
|
23
|
+
kind: "EFWDrawerButton",
|
|
24
|
+
props: {
|
|
25
|
+
icon: c,
|
|
26
|
+
children: l,
|
|
27
|
+
appearance: x,
|
|
28
|
+
onClick: (J, M, P) => {
|
|
29
|
+
const { selectedRows: t, tableMethods: d } = P, R = d.getFields(), y = /* @__PURE__ */ L(V, { children: [
|
|
30
|
+
"Complete los campos requeridos para crear un nuevo elemento en la tabla. Los campos marcados con asterisco (",
|
|
31
|
+
/* @__PURE__ */ r("span", { style: { color: "#c00" }, children: "*" }),
|
|
32
|
+
") son obligatorios."
|
|
33
|
+
] }), u = t.length === 1 ? t[0].item : {}, T = t.map((o) => o.index), W = U(R, b);
|
|
34
|
+
M({
|
|
35
|
+
size: B,
|
|
36
|
+
title: v,
|
|
37
|
+
position: k,
|
|
38
|
+
deferContentRendering: !0,
|
|
39
|
+
content: /* @__PURE__ */ r(H, { initialValues: u, formRef: f, description: y, ...W }),
|
|
40
|
+
buttons: [
|
|
41
|
+
{
|
|
42
|
+
kind: "EFWButton",
|
|
43
|
+
props: {
|
|
44
|
+
icon: c,
|
|
45
|
+
children: l,
|
|
46
|
+
appearance: "primary",
|
|
47
|
+
autoLoading: !0,
|
|
48
|
+
loadingText: "Actualizando...",
|
|
49
|
+
successConfig: {
|
|
50
|
+
text: "¡Actualizado!"
|
|
51
|
+
},
|
|
52
|
+
onClick: async (o, s) => {
|
|
53
|
+
if (E()) {
|
|
54
|
+
const A = g(), D = i(!0);
|
|
55
|
+
h();
|
|
56
|
+
try {
|
|
57
|
+
const e = await d.updateItem(T[0], { ...u, ...A });
|
|
58
|
+
if (e.failed?.length) {
|
|
59
|
+
const I = e.failed.map((n) => p(n.error)), _ = e.failed.length > 1;
|
|
60
|
+
return a({
|
|
61
|
+
id: "update-operation-error",
|
|
62
|
+
intent: "error",
|
|
63
|
+
title: _ ? "Error al intentar actualizar elementos:" : "Error al intentar actualizar elemento:",
|
|
64
|
+
message: /* @__PURE__ */ r("ul", { children: I.map((n, j) => /* @__PURE__ */ r("li", { children: n }, j)) })
|
|
65
|
+
}), { success: !1 };
|
|
66
|
+
}
|
|
67
|
+
return setTimeout(s, 100), { success: !0 };
|
|
68
|
+
} catch (e) {
|
|
69
|
+
return i(!1, D), console.error("Error durante actualización:", e), a({
|
|
70
|
+
id: "update-unexpected-error",
|
|
71
|
+
intent: "error",
|
|
72
|
+
title: "Error al intentar actualizar elemento",
|
|
73
|
+
message: p(e)
|
|
74
|
+
}), { success: !1 };
|
|
75
|
+
}
|
|
76
|
+
} else
|
|
77
|
+
return { success: !1 };
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
kind: "EFWButton",
|
|
83
|
+
props: {
|
|
84
|
+
children: "Cancelar",
|
|
85
|
+
onClick: (o, s) => {
|
|
86
|
+
s();
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
]
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
};
|
|
95
|
+
};
|
|
96
|
+
export {
|
|
97
|
+
ee as useDefaultUpdateButton
|
|
98
|
+
};
|
package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController copy.js
ADDED
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useRef as G, useState as m, useCallback as u, useEffect as d } from "react";
|
|
2
|
+
const J = (I) => {
|
|
3
|
+
const c = G(null), [l, a] = m([]), [i, g] = m(I || []), h = u(() => c.current?.getFields?.() || i, [i]), p = u((t) => {
|
|
4
|
+
g(t);
|
|
5
|
+
}, []);
|
|
6
|
+
d(() => {
|
|
7
|
+
(() => {
|
|
8
|
+
const e = c.current?.getItems?.();
|
|
9
|
+
e && a(e);
|
|
10
|
+
})();
|
|
11
|
+
}, [c.current]);
|
|
12
|
+
const y = u(async (t) => {
|
|
13
|
+
try {
|
|
14
|
+
const e = await c.current?.addItem?.(t);
|
|
15
|
+
return e ? (e.successful.length > 0 && a((r) => [
|
|
16
|
+
...e.successful.map((s) => s.item),
|
|
17
|
+
...r
|
|
18
|
+
]), e) : {
|
|
19
|
+
successful: [],
|
|
20
|
+
failed: [{ index: -1, item: t, error: "Table reference not available" }]
|
|
21
|
+
};
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return {
|
|
24
|
+
successful: [],
|
|
25
|
+
failed: [{ index: -1, item: t, error: String(e) }]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}, []), b = u(async (t) => {
|
|
29
|
+
try {
|
|
30
|
+
const e = await c.current?.addItems?.(t);
|
|
31
|
+
return e ? (e.successful.length > 0 && a((r) => [
|
|
32
|
+
...e.successful.map((s) => s.item),
|
|
33
|
+
...r
|
|
34
|
+
]), e) : {
|
|
35
|
+
successful: [],
|
|
36
|
+
failed: t.map((r, s) => ({
|
|
37
|
+
index: s,
|
|
38
|
+
item: r,
|
|
39
|
+
error: "Table reference not available"
|
|
40
|
+
}))
|
|
41
|
+
};
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
successful: [],
|
|
45
|
+
failed: t.map((r, s) => ({
|
|
46
|
+
index: s,
|
|
47
|
+
item: r,
|
|
48
|
+
error: String(e)
|
|
49
|
+
}))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, []), w = u(async (t, e) => {
|
|
53
|
+
try {
|
|
54
|
+
const r = await c.current?.updateItem?.(t, e);
|
|
55
|
+
return r ? (r.successful.length > 0 && a((s) => {
|
|
56
|
+
const o = [...s];
|
|
57
|
+
return r.successful.forEach(({ index: n, item: f }) => {
|
|
58
|
+
n >= 0 && n < o.length && (o[n] = f);
|
|
59
|
+
}), o;
|
|
60
|
+
}), r) : {
|
|
61
|
+
successful: [],
|
|
62
|
+
failed: [{ index: t, item: e, error: "Table reference not available" }]
|
|
63
|
+
};
|
|
64
|
+
} catch (r) {
|
|
65
|
+
return {
|
|
66
|
+
successful: [],
|
|
67
|
+
failed: [{ index: t, item: e, error: String(r) }]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}, []), S = u(async (t) => {
|
|
71
|
+
try {
|
|
72
|
+
const e = await c.current?.updateItems?.(t);
|
|
73
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
74
|
+
const s = [...r];
|
|
75
|
+
return e.successful.forEach(({ index: o, item: n }) => {
|
|
76
|
+
o >= 0 && o < s.length && (s[o] = n);
|
|
77
|
+
}), s;
|
|
78
|
+
}), e) : {
|
|
79
|
+
successful: [],
|
|
80
|
+
failed: t.map(({ index: r, item: s }) => ({
|
|
81
|
+
index: r,
|
|
82
|
+
item: s,
|
|
83
|
+
error: "Table reference not available"
|
|
84
|
+
}))
|
|
85
|
+
};
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return {
|
|
88
|
+
successful: [],
|
|
89
|
+
failed: t.map(({ index: r, item: s }) => ({
|
|
90
|
+
index: r,
|
|
91
|
+
item: s,
|
|
92
|
+
error: String(e)
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, []), E = u(async (t) => {
|
|
97
|
+
try {
|
|
98
|
+
const e = await c.current?.deleteItem?.(t);
|
|
99
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
100
|
+
const s = [...r];
|
|
101
|
+
return e.successful.map((n) => n.index).sort((n, f) => f - n).forEach((n) => {
|
|
102
|
+
n >= 0 && n < s.length && s.splice(n, 1);
|
|
103
|
+
}), s;
|
|
104
|
+
}), e) : {
|
|
105
|
+
successful: [],
|
|
106
|
+
failed: [{ index: t, error: "Table reference not available" }]
|
|
107
|
+
};
|
|
108
|
+
} catch (e) {
|
|
109
|
+
return {
|
|
110
|
+
successful: [],
|
|
111
|
+
failed: [{ index: t, error: String(e) }]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, []), R = u(async (t) => {
|
|
115
|
+
try {
|
|
116
|
+
const e = await c.current?.deleteItems?.(t);
|
|
117
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
118
|
+
const s = [...r];
|
|
119
|
+
return e.successful.map((n) => n.index).sort((n, f) => f - n).forEach((n) => {
|
|
120
|
+
n >= 0 && n < s.length && s.splice(n, 1);
|
|
121
|
+
}), s;
|
|
122
|
+
}), e) : {
|
|
123
|
+
successful: [],
|
|
124
|
+
failed: t.map((r) => ({
|
|
125
|
+
index: r,
|
|
126
|
+
error: "Table reference not available"
|
|
127
|
+
}))
|
|
128
|
+
};
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return {
|
|
131
|
+
successful: [],
|
|
132
|
+
failed: t.map((r) => ({
|
|
133
|
+
index: r,
|
|
134
|
+
error: String(e)
|
|
135
|
+
}))
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}, []), v = u((t) => c.current?.getItem?.(t) || l.find((e) => e.id === t), [l]), T = u((t) => c.current?.getItemByIndex?.(t) || l[t], [l]), C = u((t) => {
|
|
139
|
+
c.current?.replaceAllItems?.(t), a(t);
|
|
140
|
+
}, []), x = u(() => {
|
|
141
|
+
c.current?.clearItems?.(), a([]);
|
|
142
|
+
}, []), A = u((t) => c.current?.getItemIndex?.(t) ?? l.findIndex((e) => e.id === t), [l]), F = u((t) => c.current?.itemExists?.(t) ?? l.some((e) => e.id === t), [l]), B = u(() => c.current?.getItemsCount?.() ?? l.length, [l.length]), k = u(() => c.current?.getItems?.() ?? l, [l]), j = u(() => {
|
|
143
|
+
c.current?.deselectAllRows?.();
|
|
144
|
+
}, []), q = u(() => c.current?.getSelectedItems?.() ?? { items: [], indexes: [] }, []), z = u(() => c.current?.getSelectedRows?.() ?? [], []), D = u(() => c.current !== null, []);
|
|
145
|
+
return d(() => () => {
|
|
146
|
+
c.current = null;
|
|
147
|
+
}, []), {
|
|
148
|
+
tableRef: c,
|
|
149
|
+
// Configuración
|
|
150
|
+
getFields: h,
|
|
151
|
+
setFieldsConfig: p,
|
|
152
|
+
isTableReady: D,
|
|
153
|
+
// Operaciones CRUD
|
|
154
|
+
addItem: y,
|
|
155
|
+
addItems: b,
|
|
156
|
+
updateItem: w,
|
|
157
|
+
updateItems: S,
|
|
158
|
+
deleteItem: E,
|
|
159
|
+
deleteItems: R,
|
|
160
|
+
// Consultas
|
|
161
|
+
getItem: v,
|
|
162
|
+
getItemByIndex: T,
|
|
163
|
+
getItems: k,
|
|
164
|
+
getItemsCount: B,
|
|
165
|
+
getItemIndex: A,
|
|
166
|
+
itemExists: F,
|
|
167
|
+
// Manipulación masiva
|
|
168
|
+
replaceAllItems: C,
|
|
169
|
+
clearItems: x,
|
|
170
|
+
// Selección
|
|
171
|
+
deselectAllRows: j,
|
|
172
|
+
getSelectedItems: q,
|
|
173
|
+
getSelectedRows: z
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
export {
|
|
177
|
+
J as useTableController
|
|
178
|
+
};
|
|
@@ -0,0 +1,178 @@
|
|
|
1
|
+
import { useRef as G, useState as m, useCallback as u, useEffect as d } from "react";
|
|
2
|
+
const J = (I) => {
|
|
3
|
+
const c = G(null), [l, a] = m([]), [i, g] = m(I || []), h = u(() => c.current?.getFields?.() || i, [i]), p = u((t) => {
|
|
4
|
+
g(t);
|
|
5
|
+
}, []);
|
|
6
|
+
d(() => {
|
|
7
|
+
(() => {
|
|
8
|
+
const e = c.current?.getItems?.();
|
|
9
|
+
e && a(e);
|
|
10
|
+
})();
|
|
11
|
+
}, [c.current]);
|
|
12
|
+
const y = u(async (t) => {
|
|
13
|
+
try {
|
|
14
|
+
const e = await c.current?.addItem?.(t);
|
|
15
|
+
return e ? (e.successful.length > 0 && a((r) => [
|
|
16
|
+
...e.successful.map((s) => s.item),
|
|
17
|
+
...r
|
|
18
|
+
]), e) : {
|
|
19
|
+
successful: [],
|
|
20
|
+
failed: [{ index: -1, item: t, error: "Table reference not available" }]
|
|
21
|
+
};
|
|
22
|
+
} catch (e) {
|
|
23
|
+
return {
|
|
24
|
+
successful: [],
|
|
25
|
+
failed: [{ index: -1, item: t, error: String(e) }]
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
}, []), b = u(async (t) => {
|
|
29
|
+
try {
|
|
30
|
+
const e = await c.current?.addItems?.(t);
|
|
31
|
+
return e ? (e.successful.length > 0 && a((r) => [
|
|
32
|
+
...e.successful.map((s) => s.item),
|
|
33
|
+
...r
|
|
34
|
+
]), e) : {
|
|
35
|
+
successful: [],
|
|
36
|
+
failed: t.map((r, s) => ({
|
|
37
|
+
index: s,
|
|
38
|
+
item: r,
|
|
39
|
+
error: "Table reference not available"
|
|
40
|
+
}))
|
|
41
|
+
};
|
|
42
|
+
} catch (e) {
|
|
43
|
+
return {
|
|
44
|
+
successful: [],
|
|
45
|
+
failed: t.map((r, s) => ({
|
|
46
|
+
index: s,
|
|
47
|
+
item: r,
|
|
48
|
+
error: String(e)
|
|
49
|
+
}))
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
}, []), w = u(async (t, e) => {
|
|
53
|
+
try {
|
|
54
|
+
const r = await c.current?.updateItem?.(t, e);
|
|
55
|
+
return r ? (r.successful.length > 0 && a((s) => {
|
|
56
|
+
const o = [...s];
|
|
57
|
+
return r.successful.forEach(({ index: n, item: f }) => {
|
|
58
|
+
n >= 0 && n < o.length && (o[n] = f);
|
|
59
|
+
}), o;
|
|
60
|
+
}), r) : {
|
|
61
|
+
successful: [],
|
|
62
|
+
failed: [{ index: t, item: e, error: "Table reference not available" }]
|
|
63
|
+
};
|
|
64
|
+
} catch (r) {
|
|
65
|
+
return {
|
|
66
|
+
successful: [],
|
|
67
|
+
failed: [{ index: t, item: e, error: String(r) }]
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
}, []), S = u(async (t) => {
|
|
71
|
+
try {
|
|
72
|
+
const e = await c.current?.updateItems?.(t);
|
|
73
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
74
|
+
const s = [...r];
|
|
75
|
+
return e.successful.forEach(({ index: o, item: n }) => {
|
|
76
|
+
o >= 0 && o < s.length && (s[o] = n);
|
|
77
|
+
}), s;
|
|
78
|
+
}), e) : {
|
|
79
|
+
successful: [],
|
|
80
|
+
failed: t.map(({ index: r, item: s }) => ({
|
|
81
|
+
index: r,
|
|
82
|
+
item: s,
|
|
83
|
+
error: "Table reference not available"
|
|
84
|
+
}))
|
|
85
|
+
};
|
|
86
|
+
} catch (e) {
|
|
87
|
+
return {
|
|
88
|
+
successful: [],
|
|
89
|
+
failed: t.map(({ index: r, item: s }) => ({
|
|
90
|
+
index: r,
|
|
91
|
+
item: s,
|
|
92
|
+
error: String(e)
|
|
93
|
+
}))
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
}, []), E = u(async (t) => {
|
|
97
|
+
try {
|
|
98
|
+
const e = await c.current?.deleteItem?.(t);
|
|
99
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
100
|
+
const s = [...r];
|
|
101
|
+
return e.successful.map((n) => n.index).sort((n, f) => f - n).forEach((n) => {
|
|
102
|
+
n >= 0 && n < s.length && s.splice(n, 1);
|
|
103
|
+
}), s;
|
|
104
|
+
}), e) : {
|
|
105
|
+
successful: [],
|
|
106
|
+
failed: [{ index: t, error: "Table reference not available" }]
|
|
107
|
+
};
|
|
108
|
+
} catch (e) {
|
|
109
|
+
return {
|
|
110
|
+
successful: [],
|
|
111
|
+
failed: [{ index: t, error: String(e) }]
|
|
112
|
+
};
|
|
113
|
+
}
|
|
114
|
+
}, []), R = u(async (t) => {
|
|
115
|
+
try {
|
|
116
|
+
const e = await c.current?.deleteItems?.(t);
|
|
117
|
+
return e ? (e.successful.length > 0 && a((r) => {
|
|
118
|
+
const s = [...r];
|
|
119
|
+
return e.successful.map((n) => n.index).sort((n, f) => f - n).forEach((n) => {
|
|
120
|
+
n >= 0 && n < s.length && s.splice(n, 1);
|
|
121
|
+
}), s;
|
|
122
|
+
}), e) : {
|
|
123
|
+
successful: [],
|
|
124
|
+
failed: t.map((r) => ({
|
|
125
|
+
index: r,
|
|
126
|
+
error: "Table reference not available"
|
|
127
|
+
}))
|
|
128
|
+
};
|
|
129
|
+
} catch (e) {
|
|
130
|
+
return {
|
|
131
|
+
successful: [],
|
|
132
|
+
failed: t.map((r) => ({
|
|
133
|
+
index: r,
|
|
134
|
+
error: String(e)
|
|
135
|
+
}))
|
|
136
|
+
};
|
|
137
|
+
}
|
|
138
|
+
}, []), v = u((t) => c.current?.getItem?.(t) || l.find((e) => e.id === t), [l]), T = u((t) => c.current?.getItemByIndex?.(t) || l[t], [l]), C = u((t) => {
|
|
139
|
+
c.current?.replaceAllItems?.(t), a(t);
|
|
140
|
+
}, []), x = u(() => {
|
|
141
|
+
c.current?.clearItems?.(), a([]);
|
|
142
|
+
}, []), A = u((t) => c.current?.getItemIndex?.(t) ?? l.findIndex((e) => e.id === t), [l]), F = u((t) => c.current?.itemExists?.(t) ?? l.some((e) => e.id === t), [l]), B = u(() => c.current?.getItemsCount?.() ?? l.length, [l.length]), k = u(() => c.current?.getItems?.() ?? l, [l]), j = u(() => {
|
|
143
|
+
c.current?.deselectAllRows?.();
|
|
144
|
+
}, []), q = u(() => c.current?.getSelectedItems?.() ?? { items: [], indexes: [] }, []), z = u(() => c.current?.getSelectedRows?.() ?? [], []), D = u(() => c.current !== null, []);
|
|
145
|
+
return d(() => () => {
|
|
146
|
+
c.current = null;
|
|
147
|
+
}, []), {
|
|
148
|
+
tableRef: c,
|
|
149
|
+
// Configuración
|
|
150
|
+
getFields: h,
|
|
151
|
+
setFieldsConfig: p,
|
|
152
|
+
isTableReady: D,
|
|
153
|
+
// Operaciones CRUD
|
|
154
|
+
addItem: y,
|
|
155
|
+
addItems: b,
|
|
156
|
+
updateItem: w,
|
|
157
|
+
updateItems: S,
|
|
158
|
+
deleteItem: E,
|
|
159
|
+
deleteItems: R,
|
|
160
|
+
// Consultas
|
|
161
|
+
getItem: v,
|
|
162
|
+
getItemByIndex: T,
|
|
163
|
+
getItems: k,
|
|
164
|
+
getItemsCount: B,
|
|
165
|
+
getItemIndex: A,
|
|
166
|
+
itemExists: F,
|
|
167
|
+
// Manipulación masiva
|
|
168
|
+
replaceAllItems: C,
|
|
169
|
+
clearItems: x,
|
|
170
|
+
// Selección
|
|
171
|
+
deselectAllRows: j,
|
|
172
|
+
getSelectedItems: q,
|
|
173
|
+
getSelectedRows: z
|
|
174
|
+
};
|
|
175
|
+
};
|
|
176
|
+
export {
|
|
177
|
+
J as useTableController
|
|
178
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EFWFormFieldProps } from '../../../../forms/EFWForm';
|
|
2
|
+
import { EFWTableMethods, EFWTableRef } from '../../EFWTable.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interfaz que extiende `EFWFormMethods` y agrega propiedades y métodos específicos para el hook `useFormController`.
|
|
6
|
+
* Proporciona una forma de interactuar con el componente EFWForm desde un componente React.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseTableController extends EFWTableMethods {
|
|
9
|
+
/**
|
|
10
|
+
* Referencia mutable que se pasa al componente EFWForm para exponer sus métodos.
|
|
11
|
+
* Debe asignarse a la prop `formRef` del componente EFWForm.
|
|
12
|
+
*/
|
|
13
|
+
tableRef: React.MutableRefObject<EFWTableRef>;
|
|
14
|
+
setFieldsConfig: (fields: EFWFormFieldProps[]) => void;
|
|
15
|
+
isTableReady: () => boolean;
|
|
16
|
+
}
|
|
File without changes
|
package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.types.d.ts
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { EFWFormFieldProps } from '../../../../forms/EFWForm';
|
|
2
|
+
import { EFWTableMethods, EFWTableRef } from '../../EFWTable.types';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Interfaz que extiende `EFWFormMethods` y agrega propiedades y métodos específicos para el hook `useFormController`.
|
|
6
|
+
* Proporciona una forma de interactuar con el componente EFWForm desde un componente React.
|
|
7
|
+
*/
|
|
8
|
+
export interface UseTableController extends EFWTableMethods {
|
|
9
|
+
/**
|
|
10
|
+
* Referencia mutable que se pasa al componente EFWForm para exponer sus métodos.
|
|
11
|
+
* Debe asignarse a la prop `formRef` del componente EFWForm.
|
|
12
|
+
*/
|
|
13
|
+
tableRef: React.MutableRefObject<EFWTableRef>;
|
|
14
|
+
setFieldsConfig: (fields: EFWFormFieldProps[]) => void;
|
|
15
|
+
isTableReady: () => boolean;
|
|
16
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import { useState as h, useRef as R, useMemo as x, useEffect as E, useCallback as o } from "react";
|
|
2
|
+
const M = ({
|
|
3
|
+
initialSelection: S = /* @__PURE__ */ new Set(),
|
|
4
|
+
onSelectionChange: f,
|
|
5
|
+
enableSelection: n = !0
|
|
6
|
+
} = {}) => {
|
|
7
|
+
const [u, c] = h(() => {
|
|
8
|
+
const e = {};
|
|
9
|
+
return S.forEach((t) => {
|
|
10
|
+
e[t.toString()] = !0;
|
|
11
|
+
}), e;
|
|
12
|
+
}), l = R(/* @__PURE__ */ new Set()), r = x(() => new Set(
|
|
13
|
+
Object.keys(u).filter((e) => u[e]).map((e) => parseInt(e))
|
|
14
|
+
), [u]);
|
|
15
|
+
E(() => {
|
|
16
|
+
(r.size !== l.current.size || [...r].some((t) => !l.current.has(t))) && (l.current = new Set(r), f?.(r));
|
|
17
|
+
}, [r, f]);
|
|
18
|
+
const m = o(() => {
|
|
19
|
+
c({});
|
|
20
|
+
}, []), a = o((e) => {
|
|
21
|
+
n && c({
|
|
22
|
+
[e.toString()]: !0
|
|
23
|
+
});
|
|
24
|
+
}, [n]), g = o((e) => {
|
|
25
|
+
n && c((t) => {
|
|
26
|
+
const s = e.toString();
|
|
27
|
+
if (t[s]) {
|
|
28
|
+
const i = { ...t };
|
|
29
|
+
return delete i[s], i;
|
|
30
|
+
} else
|
|
31
|
+
return {
|
|
32
|
+
...t,
|
|
33
|
+
[s]: !0
|
|
34
|
+
};
|
|
35
|
+
});
|
|
36
|
+
}, [n]), d = o((e) => {
|
|
37
|
+
n && c((t) => {
|
|
38
|
+
const s = { ...t };
|
|
39
|
+
return e.forEach((i) => {
|
|
40
|
+
s[i.toString()] = !0;
|
|
41
|
+
}), s;
|
|
42
|
+
});
|
|
43
|
+
}, [n]), w = o((e) => {
|
|
44
|
+
const t = [...r];
|
|
45
|
+
return {
|
|
46
|
+
items: t.map((s) => e[s]).filter(Boolean),
|
|
47
|
+
indexes: t
|
|
48
|
+
};
|
|
49
|
+
}, [r]), p = o((e) => [...r].map((t) => ({
|
|
50
|
+
index: t,
|
|
51
|
+
item: e[t]
|
|
52
|
+
})).filter((t) => t.item), [r]);
|
|
53
|
+
return {
|
|
54
|
+
rowSelection: u,
|
|
55
|
+
setRowSelection: c,
|
|
56
|
+
selectedIndexes: r,
|
|
57
|
+
deselectAll: m,
|
|
58
|
+
selectSingle: a,
|
|
59
|
+
toggleMultiple: g,
|
|
60
|
+
selectMultiple: d,
|
|
61
|
+
getSelectedItems: w,
|
|
62
|
+
getSelectedRows: p
|
|
63
|
+
};
|
|
64
|
+
};
|
|
65
|
+
export {
|
|
66
|
+
M as useTableSelection
|
|
67
|
+
};
|
package/dist/react-components/tables/EFWTable/hooks/useTableSelection/useTableSelection.types.d.ts
ADDED
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import { RowSelectionState } from '@tanstack/react-table';
|
|
2
|
+
import { EFWTableItem } from '../../EFWTable.types';
|
|
3
|
+
|
|
4
|
+
export interface UseTableSelectionOptions {
|
|
5
|
+
/** Elementos seleccionados inicialmente por índice */
|
|
6
|
+
initialSelection?: Set<number>;
|
|
7
|
+
/** Callback cuando cambia la selección */
|
|
8
|
+
onSelectionChange?: (selectedIndexes: Set<number>) => void;
|
|
9
|
+
/** Si se permite selección (para mostrar checkboxes) */
|
|
10
|
+
enableSelection?: boolean;
|
|
11
|
+
}
|
|
12
|
+
export interface UseTableSelection {
|
|
13
|
+
/** Estado de selección compatible con react-table */
|
|
14
|
+
rowSelection: RowSelectionState;
|
|
15
|
+
/** Función para actualizar la selección */
|
|
16
|
+
setRowSelection: React.Dispatch<React.SetStateAction<RowSelectionState>>;
|
|
17
|
+
/** Set con los índices seleccionados */
|
|
18
|
+
selectedIndexes: Set<number>;
|
|
19
|
+
/** Función para deseleccionar todo */
|
|
20
|
+
deselectAll: () => void;
|
|
21
|
+
/** Función para seleccionar SOLO un índice (deselecciona otros) - Para clicks en fila */
|
|
22
|
+
selectSingle: (index: number) => void;
|
|
23
|
+
/** Función para alternar selección manteniendo otros - Para clicks en checkbox */
|
|
24
|
+
toggleMultiple: (index: number) => void;
|
|
25
|
+
/** Función para seleccionar múltiples índices */
|
|
26
|
+
selectMultiple: (indexes: number[]) => void;
|
|
27
|
+
/** Función para obtener elementos seleccionados */
|
|
28
|
+
getSelectedItems: (allItems: EFWTableItem[]) => {
|
|
29
|
+
items: EFWTableItem[];
|
|
30
|
+
indexes: number[];
|
|
31
|
+
};
|
|
32
|
+
/** Función para obtener filas seleccionadas */
|
|
33
|
+
getSelectedRows: (allItems: EFWTableItem[]) => Array<{
|
|
34
|
+
index: number;
|
|
35
|
+
item: EFWTableItem;
|
|
36
|
+
}>;
|
|
37
|
+
}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import { EFWFormFieldType } from '../../../../forms/EFWForm';
|
|
2
|
+
import { CellRendererProps } from './CellRenderer.types';
|
|
3
|
+
import * as React from "react";
|
|
4
|
+
/**
|
|
5
|
+
* Componente memoizado para renderizar el contenido de una celda
|
|
6
|
+
*/
|
|
7
|
+
export declare const CellRenderer: <T extends EFWFormFieldType>(props: CellRendererProps<T>) => React.ReactElement;
|
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
import * as c from "react";
|
|
2
|
+
import { createCacheKey as f, getCachedResult as o, setCachedResult as s } from "../cache.js";
|
|
3
|
+
import { resolveRendererForField as R } from "../renderers.js";
|
|
4
|
+
import { areValuesEqual as F } from "../comparison.js";
|
|
5
|
+
import { getEFWFormFieldDisplayText as h } from "../../../../forms/EFWForm/EFWForm.converter.js";
|
|
6
|
+
const D = c.memo(
|
|
7
|
+
({
|
|
8
|
+
field: e,
|
|
9
|
+
value: l,
|
|
10
|
+
item: a,
|
|
11
|
+
rowIndex: d,
|
|
12
|
+
columnRenderers: i,
|
|
13
|
+
useDefaultAsFallback: u
|
|
14
|
+
}) => {
|
|
15
|
+
const m = f(e, l, a, d, i);
|
|
16
|
+
let t = o(m);
|
|
17
|
+
if (t === void 0) {
|
|
18
|
+
const r = R(e, i), n = {
|
|
19
|
+
field: e,
|
|
20
|
+
value: l,
|
|
21
|
+
item: a,
|
|
22
|
+
rowIndex: d,
|
|
23
|
+
columnId: e.internalName
|
|
24
|
+
};
|
|
25
|
+
r.fieldRenderer ? t = r.fieldRenderer(n) : r.defaultRenderer ? t = r.defaultRenderer(n) : u ? t = h(e, l) : t = null, s(m, t);
|
|
26
|
+
}
|
|
27
|
+
return t;
|
|
28
|
+
},
|
|
29
|
+
// Función de comparación para React.memo
|
|
30
|
+
(e, l) => e.field === l.field && e.item === l.item && e.rowIndex === l.rowIndex && e.columnRenderers === l.columnRenderers && e.useDefaultAsFallback === l.useDefaultAsFallback ? F(
|
|
31
|
+
e.value,
|
|
32
|
+
l.value,
|
|
33
|
+
e.field.typeAsString
|
|
34
|
+
) : !1
|
|
35
|
+
);
|
|
36
|
+
export {
|
|
37
|
+
D as CellRenderer
|
|
38
|
+
};
|