@envisiongroup/porygon 1.0.2 → 1.0.4
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/dist/index.js +72 -69
- package/dist/react-components/fields/TagPicker/EFWTagPicker.js +130 -126
- package/dist/react-components/fields/TagPicker/EFWTagPicker.types.d.ts +11 -6
- package/dist/react-components/forms/EFWForm/EFWForm.js +284 -290
- package/dist/react-components/forms/EFWForm/EFWForm.utils.d.ts +26 -1
- package/dist/react-components/forms/EFWForm/EFWForm.utils.js +94 -65
- package/dist/react-components/forms/EFWForm/index.d.ts +4 -3
- package/dist/react-components/forms/EFWForm/index.js +10 -7
- package/dist/react-components/tables/EFWTable/EFWTable.js +767 -747
- package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +10 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +31 -9
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.types.d.ts +39 -4
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.utils.d.ts +8 -3
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.utils.js +4 -1
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.js +47 -15
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +52 -21
- package/dist/react-components/tables/EFWTable/utils/index.d.ts +2 -1
- package/dist/react-components/tables/EFWTable/utils/index.js +19 -17
- package/dist/react-components/tables/EFWTable/utils/itemCompletion.d.ts +32 -0
- package/dist/react-components/tables/EFWTable/utils/itemCompletion.js +23 -0
- package/package.json +2 -2
|
@@ -433,7 +433,16 @@ export interface EFWTableProps<T extends readonly EFWFormFieldProps[] = EFWFormF
|
|
|
433
433
|
* Se ejecuta antes de que los elementos se agreguen a la tabla local. Útil para validaciones,
|
|
434
434
|
* persistencia en BD, transformaciones de datos o control de flujo.
|
|
435
435
|
*
|
|
436
|
-
*
|
|
436
|
+
* **Semántica de propiedad omitida**: los items llegan tal como los provee el
|
|
437
|
+
* usuario (payload parcial). Si el formulario de creación pide un subconjunto
|
|
438
|
+
* de fields, las columnas no renderizadas (típicamente las asignadas por el
|
|
439
|
+
* backend: `status`, `createdBy`, timestamps) **no estarán presentes** en el
|
|
440
|
+
* item, para que el backend pueda aplicar sus propios defaults. EFWTable
|
|
441
|
+
* completa los valores vacíos (`''`, `null`, `[]`, `false`) **solo** sobre
|
|
442
|
+
* los items que finalmente se guardan localmente, preservando esta semántica
|
|
443
|
+
* para el consumidor. Accede únicamente a las keys que tu formulario pide.
|
|
444
|
+
*
|
|
445
|
+
* @param {EFWTableItem[]} items - Elementos que se van a agregar (ya incluyen ID generado). Pueden ser parciales si el form de creación usa un subconjunto de fields.
|
|
437
446
|
* @param {EFWTableMethods} tableMethods - Métodos de la tabla para operaciones adicionales
|
|
438
447
|
* @returns {Promise<OperationResult<EFWTableItem> | void>}
|
|
439
448
|
* - `void`: Continúa con la operación normal de agregar
|
package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js
CHANGED
|
@@ -43,7 +43,10 @@ const s = [], A = [], Y = I({
|
|
|
43
43
|
className: E,
|
|
44
44
|
localeText: _
|
|
45
45
|
}) => {
|
|
46
|
-
const c = Y(), m = O(_), e = n.useMemo(
|
|
46
|
+
const c = Y(), m = O(_), e = n.useMemo(
|
|
47
|
+
() => r.length,
|
|
48
|
+
[r]
|
|
49
|
+
), a = n.useCallback(
|
|
47
50
|
(L, B) => L.map((o, N) => {
|
|
48
51
|
const W = o.enabled === void 0 ? !0 : typeof o.enabled == "boolean" ? o.enabled : o.enabled(r, i), T = B.active && W, l = o.props || {}, v = T ? l.style : { ...l.style, display: "none" }, P = {
|
|
49
52
|
...l,
|
|
@@ -63,25 +66,42 @@ const s = [], A = [], Y = I({
|
|
|
63
66
|
), k = M(() => {
|
|
64
67
|
i.deselectAllRows();
|
|
65
68
|
}, [i]), x = n.useMemo(
|
|
66
|
-
() => a(d, {
|
|
69
|
+
() => a(d, {
|
|
70
|
+
active: !0,
|
|
71
|
+
prefix: "always-button"
|
|
72
|
+
}),
|
|
67
73
|
[d, a]
|
|
68
74
|
), y = n.useMemo(
|
|
69
|
-
() => a(p, {
|
|
75
|
+
() => a(p, {
|
|
76
|
+
active: e === 0,
|
|
77
|
+
prefix: "no-selected-button"
|
|
78
|
+
}),
|
|
70
79
|
[a, p, e]
|
|
71
80
|
), b = n.useMemo(
|
|
72
|
-
() => a(u, {
|
|
81
|
+
() => a(u, {
|
|
82
|
+
active: e === 1,
|
|
83
|
+
prefix: "one-selected-button"
|
|
84
|
+
}),
|
|
73
85
|
[a, e, u]
|
|
74
86
|
), h = n.useMemo(
|
|
75
|
-
() => a(f, {
|
|
87
|
+
() => a(f, {
|
|
88
|
+
active: e > 1,
|
|
89
|
+
prefix: "many-selected-button"
|
|
90
|
+
}),
|
|
76
91
|
[a, f, e]
|
|
77
92
|
), C = n.useMemo(
|
|
78
93
|
() => [
|
|
79
|
-
...x,
|
|
80
94
|
...y,
|
|
81
95
|
...b,
|
|
82
|
-
...h
|
|
96
|
+
...h,
|
|
97
|
+
...x
|
|
83
98
|
],
|
|
84
|
-
[
|
|
99
|
+
[
|
|
100
|
+
x,
|
|
101
|
+
h,
|
|
102
|
+
y,
|
|
103
|
+
b
|
|
104
|
+
]
|
|
85
105
|
);
|
|
86
106
|
return /* @__PURE__ */ t(
|
|
87
107
|
D,
|
|
@@ -114,7 +134,9 @@ const s = [], A = [], Y = I({
|
|
|
114
134
|
) : null
|
|
115
135
|
}
|
|
116
136
|
);
|
|
117
|
-
}, z = n.memo(
|
|
137
|
+
}, z = n.memo(
|
|
138
|
+
w
|
|
139
|
+
);
|
|
118
140
|
z.displayName = "EFWTableCommandBar";
|
|
119
141
|
export {
|
|
120
142
|
z as EFWTableCommandBar
|
|
@@ -71,15 +71,50 @@ export interface EFWTableCommandBarProps<T extends readonly EFWFormFieldProps[]
|
|
|
71
71
|
/** Textos localizados para labels internos del command bar. */
|
|
72
72
|
localeText?: Partial<EFWTableLocaleText>;
|
|
73
73
|
}
|
|
74
|
-
|
|
74
|
+
/**
|
|
75
|
+
* Props del botón por defecto de un drawer (add/update/delete) de la tabla.
|
|
76
|
+
*
|
|
77
|
+
* @template T - Tupla/array de TODOS los fields de la tabla (esquema completo).
|
|
78
|
+
* @template TFormFields - Tupla/array de fields que renderiza el formulario del drawer.
|
|
79
|
+
*
|
|
80
|
+
* `TFormFields` por defecto es `readonly T[number][]` (todos los fields de la
|
|
81
|
+
* tabla), manteniendo el comportamiento histórico: los callbacks del form
|
|
82
|
+
* (`onValuesChange`, `fieldLogic`, `onInit`, `defaultValues`) se tipan contra
|
|
83
|
+
* el esquema completo de la tabla.
|
|
84
|
+
*
|
|
85
|
+
* Para que esos callbacks se tipen contra un **subconjunto** (lo habitual cuando
|
|
86
|
+
* algunas columnas las asigna el backend), anota el tipo explícitamente con la
|
|
87
|
+
* tupla del subconjunto:
|
|
88
|
+
*
|
|
89
|
+
* ```ts
|
|
90
|
+
* const cfg: DefaultDrawerButtonProps<TableFields, SubsetFields> = {
|
|
91
|
+
* form: { fields: subsetFields, onValuesChange: handleSubsetValues },
|
|
92
|
+
* };
|
|
93
|
+
* ```
|
|
94
|
+
*
|
|
95
|
+
* Nota: a través de `EFWTableProps<T>['addButtonConfig']` la inferencia de
|
|
96
|
+
* `TFormFields` no es posible (propiedad anidada); en ese punto los callbacks
|
|
97
|
+
* se tipan contra el esquema completo (backward compatible). Usa anotación
|
|
98
|
+
* explícita cuando necesites precisión por subconjunto.
|
|
99
|
+
*/
|
|
100
|
+
export type DefaultDrawerButtonProps<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[], TFormFields extends readonly EFWFormFieldProps[] = readonly T[number][]> = {
|
|
75
101
|
enabled?: boolean | ((selectedRows: EFWTableRow<EFWTableItem<T>>[], tableMethods: EFWTableMethods<T>) => boolean);
|
|
76
102
|
insertPosition?: EFWTableInsertPosition;
|
|
77
|
-
form?: Omit<EFWFormProps<
|
|
78
|
-
|
|
103
|
+
form?: Omit<EFWFormProps<TFormFields>, 'formRef'> & {
|
|
104
|
+
/**
|
|
105
|
+
* Subconjunto válido de los fields de la tabla.
|
|
106
|
+
*
|
|
107
|
+
* Permite que el formulario del drawer pida solo un subconjunto de campos
|
|
108
|
+
* (lo habitual cuando algunas columnas las asigna el backend). Cada
|
|
109
|
+
* elemento debe ser un field válido de la tabla (`T[number]`); un campo
|
|
110
|
+
* ajeno se rechaza con error de tipo. Pasar la tupla completa sigue siendo
|
|
111
|
+
* válido (backward compatible).
|
|
112
|
+
*/
|
|
113
|
+
fields?: TFormFields;
|
|
79
114
|
};
|
|
80
115
|
props?: EFWDrawerButtonProps & {
|
|
81
116
|
drawerConfig?: Omit<EFWDrawerButtonProps['drawerConfig'], 'buttons'>;
|
|
82
117
|
};
|
|
83
118
|
};
|
|
84
119
|
/** Configuración del botón de filtro. Igual que DefaultDrawerButtonProps sin `insertPosition`. */
|
|
85
|
-
export type DefaultFilterButtonProps<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]> = Omit<DefaultDrawerButtonProps<T>, 'insertPosition'>;
|
|
120
|
+
export type DefaultFilterButtonProps<T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[], TFormFields extends readonly EFWFormFieldProps[] = readonly T[number][]> = Omit<DefaultDrawerButtonProps<T, TFormFields>, 'insertPosition'>;
|
|
@@ -3,12 +3,17 @@ import { EFWFormProps, EFWFormFieldProps } from '../../../../forms/EFWForm';
|
|
|
3
3
|
import { EFWTableProps } from '../../EFWTable.types';
|
|
4
4
|
|
|
5
5
|
/**
|
|
6
|
-
* Crea la configuración del formulario basada en si tiene sections o fields
|
|
6
|
+
* Crea la configuración del formulario basada en si tiene sections o fields.
|
|
7
|
+
*
|
|
8
|
+
* El tipo de fields del formulario resultante es `TFormFields` (por defecto
|
|
9
|
+
* `readonly T[number][]`, es decir, todos los fields de la tabla), de modo que
|
|
10
|
+
* los callbacks internos del form se tipan contra el esquema que realmente se
|
|
11
|
+
* renderiza y NO se fuerza un cast al esquema completo `T`.
|
|
7
12
|
*/
|
|
8
|
-
export declare const generateFormProps: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]>(fields?: EFWTableProps<T>["fields"], formProps?: DefaultDrawerButtonProps<T>["form"]) => EFWFormProps<
|
|
13
|
+
export declare const generateFormProps: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[], TFormFields extends readonly EFWFormFieldProps[] = readonly T[number][]>(fields?: EFWTableProps<T>["fields"], formProps?: DefaultDrawerButtonProps<T, TFormFields>["form"]) => EFWFormProps<TFormFields>;
|
|
9
14
|
/**
|
|
10
15
|
* Fusiona de manera profunda la configuración predeterminada con la configuración proporcionada,
|
|
11
16
|
* priorizando la configuración proporcionada donde haya solapamientos. Maneja fusiones anidadas
|
|
12
17
|
* para 'props' y 'drawerConfig', y una fusión superficial para 'form' (o vacío si no se proporciona).
|
|
13
18
|
*/
|
|
14
|
-
export declare const mergeButtonProps: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]>(defaultConfig: DefaultDrawerButtonProps<T>, overrideConfig?: DefaultDrawerButtonProps<T>) => DefaultDrawerButtonProps<T>;
|
|
19
|
+
export declare const mergeButtonProps: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[], TFormFields extends readonly EFWFormFieldProps[] = readonly T[number][]>(defaultConfig: DefaultDrawerButtonProps<T, TFormFields>, overrideConfig?: DefaultDrawerButtonProps<T, TFormFields>) => DefaultDrawerButtonProps<T, TFormFields>;
|
|
@@ -4,9 +4,12 @@ const n = (s = [], e = {}) => e?.sections ? {
|
|
|
4
4
|
gridTemplateColumns: void 0,
|
|
5
5
|
fields: void 0
|
|
6
6
|
} : {
|
|
7
|
-
fields: e?.fields ?? s,
|
|
8
7
|
gridTemplateColumns: e?.gridTemplateColumns,
|
|
9
8
|
...e,
|
|
9
|
+
// `formProps.fields` puede ser un subconjunto de los fields de la tabla
|
|
10
|
+
// (ver DefaultDrawerButtonProps['form']['fields']). En runtime se usa el
|
|
11
|
+
// subconjunto provisto o, por defecto, todos los fields de la tabla.
|
|
12
|
+
fields: e?.fields ?? s,
|
|
10
13
|
sections: void 0
|
|
11
14
|
}, t = (s, e = {}) => ({
|
|
12
15
|
enabled: e.enabled ?? s.enabled,
|
package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.d.ts
CHANGED
|
@@ -2,4 +2,4 @@ import { EFWFormFieldProps } from '../../../../forms/EFWForm';
|
|
|
2
2
|
import { EFWTableCommandBarButton, DefaultDrawerButtonProps } from '../../components/EFWTableCommandBar/EFWTableCommandBar.types';
|
|
3
3
|
import { EFWTableLocaleText } from '../../../../i18n';
|
|
4
4
|
|
|
5
|
-
export declare const useDefaultAddButton: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[]>(addButtonConfig: DefaultDrawerButtonProps<T>, localeText: EFWTableLocaleText) => EFWTableCommandBarButton<T>;
|
|
5
|
+
export declare const useDefaultAddButton: <T extends readonly EFWFormFieldProps[] = EFWFormFieldProps[], TFormFields extends readonly EFWFormFieldProps[] = readonly T[number][]>(addButtonConfig: DefaultDrawerButtonProps<T, TFormFields>, localeText: EFWTableLocaleText) => EFWTableCommandBarButton<T>;
|
package/dist/react-components/tables/EFWTable/hooks/useDefaultAddButton/useDefaultAddButton.js
CHANGED
|
@@ -6,20 +6,43 @@ import { mergeButtonProps as q, generateFormProps as G } from "../../components/
|
|
|
6
6
|
import { useFormController as H } from "../../../../forms/EFWForm/EFWForm.hooks.js";
|
|
7
7
|
import { EFWForm as J } from "../../../../forms/EFWForm/EFWForm.js";
|
|
8
8
|
const te = (p, u) => {
|
|
9
|
-
const e = u, {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
9
|
+
const e = u, {
|
|
10
|
+
formRef: m,
|
|
11
|
+
getValues: f,
|
|
12
|
+
validateForm: g,
|
|
13
|
+
setDisabled: t,
|
|
14
|
+
addMessageBar: a,
|
|
15
|
+
removeAllMessagesBar: b
|
|
16
|
+
} = H(), w = q(
|
|
17
|
+
{
|
|
18
|
+
enabled: !0,
|
|
19
|
+
props: {
|
|
20
|
+
children: e.addButtonLabel,
|
|
21
|
+
appearance: "primary",
|
|
22
|
+
icon: /* @__PURE__ */ n($, {}),
|
|
23
|
+
collapseLabel: "xs",
|
|
24
|
+
drawerConfig: {
|
|
25
|
+
title: e.addDrawerTitle,
|
|
26
|
+
size: "small",
|
|
27
|
+
position: "end"
|
|
28
|
+
}
|
|
20
29
|
}
|
|
21
|
-
}
|
|
22
|
-
|
|
30
|
+
},
|
|
31
|
+
p
|
|
32
|
+
), {
|
|
33
|
+
enabled: C,
|
|
34
|
+
props: T,
|
|
35
|
+
form: x,
|
|
36
|
+
insertPosition: y = "start"
|
|
37
|
+
} = w, {
|
|
38
|
+
children: s,
|
|
39
|
+
appearance: B,
|
|
40
|
+
icon: i,
|
|
41
|
+
collapseLabel: D,
|
|
42
|
+
drawerConfig: F,
|
|
43
|
+
style: L,
|
|
44
|
+
className: R
|
|
45
|
+
} = T || {}, {
|
|
23
46
|
title: h,
|
|
24
47
|
size: E,
|
|
25
48
|
position: k,
|
|
@@ -52,7 +75,14 @@ const te = (p, u) => {
|
|
|
52
75
|
loadingContentText: e.drawerLoadingContentText,
|
|
53
76
|
...A ?? {}
|
|
54
77
|
},
|
|
55
|
-
content: /* @__PURE__ */ n(
|
|
78
|
+
content: /* @__PURE__ */ n(
|
|
79
|
+
J,
|
|
80
|
+
{
|
|
81
|
+
formRef: m,
|
|
82
|
+
description: S,
|
|
83
|
+
...j
|
|
84
|
+
}
|
|
85
|
+
),
|
|
56
86
|
buttons: [
|
|
57
87
|
{
|
|
58
88
|
kind: "EFWButton",
|
|
@@ -78,7 +108,9 @@ const te = (p, u) => {
|
|
|
78
108
|
id: "add-operation-error",
|
|
79
109
|
intent: "error",
|
|
80
110
|
title: `${e.addErrorTitle}:`,
|
|
81
|
-
message: c(
|
|
111
|
+
message: c(
|
|
112
|
+
r.failed[0].error
|
|
113
|
+
)
|
|
82
114
|
}), { success: !1 }) : (setTimeout(o, 100), { success: !0 });
|
|
83
115
|
} catch (r) {
|
|
84
116
|
return console.error(r), t(!1, l), a({
|
package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js
CHANGED
|
@@ -6,19 +6,37 @@ import { mergeButtonProps as O, generateFormProps as Q } from "../../components/
|
|
|
6
6
|
import { useFormController as X } from "../../../../forms/EFWForm/EFWForm.hooks.js";
|
|
7
7
|
import { EFWForm as Y } from "../../../../forms/EFWForm/EFWForm.js";
|
|
8
8
|
const le = (b = {}, w) => {
|
|
9
|
-
const e = w, {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
9
|
+
const e = w, {
|
|
10
|
+
formRef: T,
|
|
11
|
+
getValues: x,
|
|
12
|
+
validateForm: C,
|
|
13
|
+
addMessageBar: l,
|
|
14
|
+
setDisabled: n,
|
|
15
|
+
removeAllMessagesBar: h
|
|
16
|
+
} = X(), y = O(
|
|
17
|
+
{
|
|
18
|
+
enabled: !0,
|
|
19
|
+
props: {
|
|
20
|
+
children: e.updateButtonLabel,
|
|
21
|
+
icon: /* @__PURE__ */ o(K, {}),
|
|
22
|
+
collapseLabel: "xs",
|
|
23
|
+
drawerConfig: {
|
|
24
|
+
title: e.updateDrawerTitle,
|
|
25
|
+
size: "small",
|
|
26
|
+
position: "end"
|
|
27
|
+
}
|
|
19
28
|
}
|
|
20
|
-
}
|
|
21
|
-
|
|
29
|
+
},
|
|
30
|
+
b
|
|
31
|
+
), { enabled: B, props: E, form: D } = y, {
|
|
32
|
+
children: d,
|
|
33
|
+
appearance: F,
|
|
34
|
+
icon: c,
|
|
35
|
+
collapseLabel: L,
|
|
36
|
+
drawerConfig: R,
|
|
37
|
+
style: k,
|
|
38
|
+
className: M
|
|
39
|
+
} = E || {}, {
|
|
22
40
|
title: v,
|
|
23
41
|
size: z,
|
|
24
42
|
position: P,
|
|
@@ -51,7 +69,15 @@ const le = (b = {}, w) => {
|
|
|
51
69
|
loadingContentText: e.drawerLoadingContentText,
|
|
52
70
|
...S ?? {}
|
|
53
71
|
},
|
|
54
|
-
content: /* @__PURE__ */ o(
|
|
72
|
+
content: /* @__PURE__ */ o(
|
|
73
|
+
Y,
|
|
74
|
+
{
|
|
75
|
+
defaultValues: u,
|
|
76
|
+
formRef: T,
|
|
77
|
+
description: j,
|
|
78
|
+
...U
|
|
79
|
+
}
|
|
80
|
+
),
|
|
55
81
|
buttons: [
|
|
56
82
|
{
|
|
57
83
|
kind: "EFWButton",
|
|
@@ -69,16 +95,21 @@ const le = (b = {}, w) => {
|
|
|
69
95
|
const q = x(), m = n(!0);
|
|
70
96
|
h();
|
|
71
97
|
try {
|
|
72
|
-
const t = await p.updateItem(
|
|
98
|
+
const t = await p.updateItem(
|
|
99
|
+
N[0],
|
|
100
|
+
{ ...u, ...q }
|
|
101
|
+
);
|
|
73
102
|
if (t.failed?.length) {
|
|
74
103
|
n(!1, m);
|
|
75
|
-
const G = t.failed.map(
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
104
|
+
const G = t.failed.map(
|
|
105
|
+
(r) => {
|
|
106
|
+
const g = f(r.error);
|
|
107
|
+
return {
|
|
108
|
+
key: `update-error-${r.index}-${g}`,
|
|
109
|
+
message: g
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
), H = t.failed.length > 1;
|
|
82
113
|
return l({
|
|
83
114
|
id: "update-operation-error",
|
|
84
115
|
intent: "error",
|
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
import { EFWFormFieldType, EFWFormFieldProps, EFWFormFieldValue } from '../../../forms/EFWForm';
|
|
2
2
|
import { EFWTableItem, ColumnRenderers } from '../EFWTable.types';
|
|
3
|
-
import * as React from
|
|
3
|
+
import type * as React from 'react';
|
|
4
4
|
/**
|
|
5
5
|
* Renderiza el contenido de una celda con sistema de caché optimizado
|
|
6
6
|
*/
|
|
7
7
|
export declare const renderCellContent: <T extends EFWFormFieldType>(field: EFWFormFieldProps<T>, value: EFWFormFieldValue<T>, item: EFWTableItem, rowIndex: number, columnRenderers?: ColumnRenderers, useDefaultAsFallback?: boolean) => React.ReactNode;
|
|
8
8
|
export type { CacheEntry, ResolvedRenderer, CellRendererProps } from './types';
|
|
9
9
|
export { generateId } from './general';
|
|
10
|
+
export { completeItemWithEmptyValues } from './itemCompletion';
|
|
10
11
|
export { addRowId, ensureItemRowId } from './typeHelpers';
|
|
11
12
|
export { setRenderContextVersion, getRenderContextVersion } from './context';
|
|
12
13
|
export { clearRenderCache, getRenderCacheStats } from './cache';
|
|
@@ -1,27 +1,29 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { CellRenderer as
|
|
3
|
-
import { generateId as
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
import { jsx as d } from "react/jsx-runtime";
|
|
2
|
+
import { CellRenderer as p } from "./CellRenderer/CellRenderer.js";
|
|
3
|
+
import { generateId as C } from "./general.js";
|
|
4
|
+
import { completeItemWithEmptyValues as c } from "./itemCompletion.js";
|
|
5
|
+
import { addRowId as I, ensureItemRowId as u } from "./typeHelpers.js";
|
|
6
|
+
import { getRenderContextVersion as h, setRenderContextVersion as V } from "./context.js";
|
|
7
|
+
import { clearRenderCache as j, getRenderCacheStats as y } from "./cache.js";
|
|
8
|
+
const a = (e, r, t, o, n, m = !0) => /* @__PURE__ */ d(
|
|
9
|
+
p,
|
|
9
10
|
{
|
|
10
11
|
field: e,
|
|
11
12
|
value: r,
|
|
12
13
|
item: t,
|
|
13
14
|
rowIndex: o,
|
|
14
15
|
columnRenderers: n,
|
|
15
|
-
useDefaultAsFallback:
|
|
16
|
+
useDefaultAsFallback: m
|
|
16
17
|
}
|
|
17
18
|
);
|
|
18
19
|
export {
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
20
|
+
I as addRowId,
|
|
21
|
+
j as clearRenderCache,
|
|
22
|
+
c as completeItemWithEmptyValues,
|
|
23
|
+
u as ensureItemRowId,
|
|
24
|
+
C as generateId,
|
|
25
|
+
y as getRenderCacheStats,
|
|
26
|
+
h as getRenderContextVersion,
|
|
27
|
+
a as renderCellContent,
|
|
28
|
+
V as setRenderContextVersion
|
|
27
29
|
};
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import { EFWFormFieldProps } from '../../../forms/EFWForm';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Completa un item con los valores vacíos normalizados para toda field de la
|
|
5
|
+
* tabla que no esté presente en el item.
|
|
6
|
+
*
|
|
7
|
+
* Motivo: cuando el formulario de creación (drawer de add) pide un subconjunto
|
|
8
|
+
* de fields, `getValues()` solo contiene las keys renderizadas. El item que se
|
|
9
|
+
* guarda localmente queda entonces con keys ausentes, lo que contradice el tipo
|
|
10
|
+
* `EFWTableItem<T>` (todas las claves presentes) y puede romper en runtime en
|
|
11
|
+
* tipos que no toleran `undefined` (p. ej. `Choice`/`MultiChoice`, tipados como
|
|
12
|
+
* arrays).
|
|
13
|
+
*
|
|
14
|
+
* Esta función restaura la coherencia tipo/runtime rellenando las keys
|
|
15
|
+
* faltantes con el valor vacío correspondiente (`''`, `null`, `[]`, `false`),
|
|
16
|
+
* usando la misma fuente de verdad que `EFWForm` para los valores iniciales.
|
|
17
|
+
*
|
|
18
|
+
* - No sobrescribe keys presentes (respeta los valores que ya trae el item,
|
|
19
|
+
* incluido `undefined` explícito).
|
|
20
|
+
* - No toca `_rowId` (lo gestiona `addRowId` después).
|
|
21
|
+
* - **Fast-path**: si el item ya trae todas las keys de `fields`, se devuelve
|
|
22
|
+
* sin clonar ni recorrer de nuevo (solo el escaneo O(fields), sin
|
|
23
|
+
* asignaciones). Esto evita degradar `addItems` en importaciones masivas
|
|
24
|
+
* donde los items ya cumplen el contrato tipado.
|
|
25
|
+
* - Usa `hasOwnKey` (propiedad propia, no `in`) para no considerar claves
|
|
26
|
+
* heredadas de `Object.prototype` (`constructor`, `toString`, ...).
|
|
27
|
+
*
|
|
28
|
+
* @param fields - Fields de la tabla (esquema completo).
|
|
29
|
+
* @param item - Item a completar.
|
|
30
|
+
* @returns El item con todas las claves de `fields` presentes.
|
|
31
|
+
*/
|
|
32
|
+
export declare const completeItemWithEmptyValues: <T extends readonly EFWFormFieldProps[], Item extends Record<string, unknown>>(fields: T, item: Item) => Item;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { getEmptyValueForFieldType as l } from "../../../forms/EFWForm/EFWForm.utils.js";
|
|
2
|
+
const a = (t, e) => (
|
|
3
|
+
// biome-ignore lint/complexity/useObjectHasOwn: el target de tsconfig es < es2022 y Object.hasOwn no está disponible
|
|
4
|
+
Object.prototype.hasOwnProperty.call(t, e)
|
|
5
|
+
), c = (t, e) => {
|
|
6
|
+
let n = !1;
|
|
7
|
+
for (const o of t)
|
|
8
|
+
if (!a(e, o.internalName)) {
|
|
9
|
+
n = !0;
|
|
10
|
+
break;
|
|
11
|
+
}
|
|
12
|
+
if (!n)
|
|
13
|
+
return e;
|
|
14
|
+
const r = { ...e };
|
|
15
|
+
for (const o of t) {
|
|
16
|
+
const s = o.internalName;
|
|
17
|
+
a(r, s) || (r[s] = l(o.typeAsString));
|
|
18
|
+
}
|
|
19
|
+
return r;
|
|
20
|
+
};
|
|
21
|
+
export {
|
|
22
|
+
c as completeItemWithEmptyValues
|
|
23
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@envisiongroup/porygon",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.4",
|
|
4
4
|
"description": "Librerias de componentes de React creados por la empresa Envision",
|
|
5
5
|
"license": "CC-BY-ND-4.0",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -95,7 +95,7 @@
|
|
|
95
95
|
"@fluentui/react-datepicker-compat": "0.6.24",
|
|
96
96
|
"@fluentui/react-icons": "2.0.319",
|
|
97
97
|
"@griffel/react": "1.5.0",
|
|
98
|
-
"@storybook/react": "^10.
|
|
98
|
+
"@storybook/react": "^10.5.4",
|
|
99
99
|
"@tanstack/react-table": "8.21.3",
|
|
100
100
|
"@tanstack/react-virtual": "3.13.9",
|
|
101
101
|
"@testing-library/jest-dom": "^6.9.1",
|