@envisiongroup/porygon 0.1.0-rc.2 → 0.1.0-rc.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.
Files changed (41) hide show
  1. package/dist/react-components/fields/EFWAttachments/EFWAttachments.js +68 -67
  2. package/dist/react-components/fields/EFWAttachments/EFWAttachments.types.d.ts +8 -2
  3. package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js +18 -16
  4. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +79 -100
  5. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.types.d.ts +6 -1
  6. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.d.ts +2 -0
  7. package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.js +33 -19
  8. package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.js +35 -33
  9. package/dist/react-components/fields/EFWField/EFWField.d.ts +2 -1
  10. package/dist/react-components/fields/EFWField/EFWField.js +39 -33
  11. package/dist/react-components/fields/EFWInput/EFWInput.js +86 -67
  12. package/dist/react-components/fields/EFWInput/EFWInput.types.d.ts +13 -1
  13. package/dist/react-components/fields/EFWInput/EFWInput.utils.js +32 -33
  14. package/dist/react-components/fields/EFWInputField/EFWInputField.js +33 -31
  15. package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.js +136 -121
  16. package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.types.d.ts +12 -0
  17. package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.js +31 -29
  18. package/dist/react-components/fields/EFWSwitch/EFWSwitch.js +36 -35
  19. package/dist/react-components/fields/EFWSwitch/EFWSwitch.types.d.ts +6 -0
  20. package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.js +24 -22
  21. package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.types.d.ts +1 -1
  22. package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +122 -113
  23. package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.types.d.ts +7 -2
  24. package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.js +31 -29
  25. package/dist/react-components/fields/EFWTextArea/EFWTextArea.js +59 -57
  26. package/dist/react-components/fields/EFWTextArea/EFWTextArea.types.d.ts +6 -2
  27. package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.js +31 -29
  28. package/dist/react-components/forms/EFWForm/EFWForm.d.ts +2 -1
  29. package/dist/react-components/forms/EFWForm/EFWForm.js +245 -210
  30. package/dist/react-components/forms/EFWForm/EFWForm.types.d.ts +13 -8
  31. package/dist/react-components/forms/EFWForm/EFWForm.utils.js +212 -179
  32. package/dist/react-components/tables/EFWTable/EFWTable.d.ts +1 -1
  33. package/dist/react-components/tables/EFWTable/EFWTable.js +473 -392
  34. package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +21 -0
  35. package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +1 -1
  36. package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +68 -77
  37. package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.js +4 -4
  38. package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.js +33 -30
  39. package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +1 -1
  40. package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +1 -1
  41. package/package.json +1 -1
@@ -1,8 +1,8 @@
1
- import { jsx as t, Fragment as ae, jsxs as j } from "react/jsx-runtime";
2
- import { useRef as y, useState as p, useCallback as u, useEffect as N } from "react";
3
- import { makeStyles as se, tokens as s, useTagPickerFilter as ie, TagPickerOption as R, Avatar as le, Spinner as ce, mergeClasses as de, TagPicker as pe, TagPickerControl as ue, TagPickerGroup as ge, Tag as fe, TagPickerInput as me, Button as he, TagPickerList as be, Text as Ce } from "@fluentui/react-components";
4
- import { CollectionsEmpty20Regular as ke, Eraser20Regular as Oe } from "@fluentui/react-icons";
5
- const ye = se({
1
+ import { jsx as o, Fragment as pe, jsxs as F } from "react/jsx-runtime";
2
+ import { useRef as y, useState as O, useMemo as V, useEffect as T, useCallback as u } from "react";
3
+ import { makeStyles as ue, tokens as s, useTagPickerFilter as fe, TagPickerOption as R, Avatar as ge, Spinner as me, mergeClasses as he, TagPicker as be, TagPickerControl as Oe, TagPickerGroup as Ce, Tag as Se, TagPickerInput as ke, Button as ye, TagPickerList as Te, Text as xe } from "@fluentui/react-components";
4
+ import { CollectionsEmpty20Regular as Pe, Eraser20Regular as ve } from "@fluentui/react-icons";
5
+ const w = [], Ne = ue({
6
6
  efwTagPickerControl: {
7
7
  "& [disabled]": {
8
8
  backgroundColor: s.colorNeutralBackground3,
@@ -35,99 +35,106 @@ const ye = se({
35
35
  borderBottomWidth: "2px"
36
36
  }
37
37
  }
38
- }), ve = (D) => {
38
+ }), Me = (q) => {
39
39
  const {
40
- placeholder: F = "Selecciona una opción",
41
- noMatchesMessage: I = "No se encontraron coincidencias",
42
- loadingMessage: V = "Buscando información...",
43
- className: _ = "",
44
- minQueryLength: g = 0,
45
- options: n = [],
46
- hidden: q = !1,
47
- disabled: w = !1,
48
- editable: Q = !0,
49
- selectedOptions: l = [],
50
- //values: initialSelectedOptions = [],
51
- noPopover: W = !1,
52
- tagSize: G = "medium",
53
- tagShape: J = "rounded",
54
- tagAppearance: H = "brand",
55
- onChange: k,
56
- beforeRenderOptions: f,
57
- multiple: E = !0,
58
- validationState: L = "none",
59
- validationMessage: U,
60
- setParentComponentState: S
61
- } = D, X = y(L), Y = y(U), [a, A] = p(""), [c, T] = p(l.map((e) => e.key)), [m, x] = p(l), [i, h] = p([]), [Z, P] = p(!1), [b, O] = p(!1), d = y(), v = y(
62
- Object.fromEntries(l.map((e) => [e.key, e]))
63
- ), M = ye(), $ = u((e) => (m.find((r) => r.key === e) || v.current[e])?.text || e, [m]);
64
- N(() => {
65
- T(l.map((e) => e.key)), x(l);
66
- }, [l]), N(() => {
67
- typeof n == "function" && a.length < g && b && O(!1);
68
- }, [a, g, n, b]), N(() => b ? (d.current?.abort(), d.current = new AbortController(), (async () => {
69
- if (typeof n != "function") {
70
- const o = f ? f(n) : n;
71
- h(o);
40
+ placeholder: Q = "Selecciona una opción",
41
+ noMatchesMessage: W = "No se encontraron coincidencias",
42
+ loadingMessage: G = "Buscando información...",
43
+ className: J = "",
44
+ minQueryLength: f = 0,
45
+ options: r = w,
46
+ hidden: Y = !1,
47
+ disabled: M = !1,
48
+ editable: H = !0,
49
+ selectedOptions: x = w,
50
+ defaultSelectedOptions: P = w,
51
+ noPopover: U = !1,
52
+ tagSize: X = "medium",
53
+ tagShape: Z = "rounded",
54
+ tagAppearance: $ = "brand",
55
+ onChange: C,
56
+ beforeRenderOptions: g,
57
+ multiple: L = !0,
58
+ validationState: z = "none",
59
+ validationMessage: K,
60
+ setParentComponentState: v
61
+ } = q, ee = y(z), te = y(K), [a, A] = O(""), i = x !== void 0, D = (i ? x : P) ?? [], [oe, N] = O(D), l = i ? x ?? [] : oe, d = V(() => l.map((e) => e.key), [l]), [c, m] = O([]), [ne, B] = O(!1), [h, S] = O(!1), p = y(), k = y(
62
+ Object.fromEntries(D.map((e) => [e.key, e]))
63
+ ), I = V(
64
+ () => P ?? [],
65
+ [P]
66
+ );
67
+ T(() => {
68
+ l.forEach((e) => {
69
+ k.current[e.key] = e;
70
+ });
71
+ }, [l]);
72
+ const _ = Ne(), re = u((e) => (l.find((n) => n.key === e) || k.current[e])?.text || e, [l]);
73
+ T(() => {
74
+ typeof r == "function" && a.length < f && h && S(!1);
75
+ }, [a, f, r, h]), T(() => h ? (p.current?.abort(), p.current = new AbortController(), (async () => {
76
+ if (typeof r != "function") {
77
+ const t = g ? g(r) : r;
78
+ m(t);
72
79
  return;
73
80
  }
74
- S?.(X.current, Y.current);
81
+ v?.(ee.current, te.current);
75
82
  try {
76
- P(!0), h([]);
77
- const o = await n(a, { signal: d.current.signal }), r = f ? f(o) : o;
78
- h(r);
79
- } catch (o) {
80
- d.current?.signal.aborted || (console.error("Error loading options:", o), h([]), S?.("error", JSON.stringify(o)));
83
+ B(!0), m([]);
84
+ const t = await r(a, { signal: p.current.signal }), n = g ? g(t) : t;
85
+ m(n);
86
+ } catch (t) {
87
+ p.current?.signal.aborted || (console.error("Error loading options:", t), m([]), v?.("error", JSON.stringify(t)));
81
88
  } finally {
82
- d.current?.signal.aborted || P(!1);
89
+ p.current?.signal.aborted || B(!1);
83
90
  }
84
- })(), () => d.current?.abort()) : void 0, [b, n, a, f, S, g]);
85
- const K = u(() => {
86
- T([]), x([]), k?.([]);
87
- }, [k]), ee = u((e, o) => {
88
- if (o.open && typeof n == "function" && a.length < g) {
89
- O(!1);
91
+ })(), () => p.current?.abort()) : void 0, [h, r, a, g, v, f]);
92
+ const ae = u(() => {
93
+ i || N([]), C?.([]);
94
+ }, [i, C]), le = u((e, t) => {
95
+ if (t.open && typeof r == "function" && a.length < f) {
96
+ S(!1);
90
97
  return;
91
98
  }
92
- o.open && typeof n == "function" && (P(!0), h([])), O(o.open);
93
- }, [n, a, g]), oe = u((e, o) => {
94
- if (o.value === "no-matches") return;
95
- let r;
96
- E ? r = o.selectedOptions : (r = o.selectedOptions.slice(-1), O(!1)), T(r), A("");
97
- const z = r.map((C) => {
98
- const B = i.find((ne) => ne.key === C) || v.current[C];
99
- return B && (v.current[C] = B), B || { key: C, text: C };
99
+ t.open && typeof r == "function" && (B(!0), m([])), S(t.open);
100
+ }, [r, a, f]), se = u((e, t) => {
101
+ if (t.value === "no-matches") return;
102
+ let n;
103
+ L ? n = t.selectedOptions : (n = t.selectedOptions.slice(-1), S(!1)), A("");
104
+ const j = n.map((b) => {
105
+ const E = c.find((de) => de.key === b) || k.current[b];
106
+ return E && (k.current[b] = E), E || { key: b, text: b };
100
107
  });
101
- x(z), k?.(z);
102
- }, [i, k, E]), te = ie({
108
+ i || N(j), C?.(j);
109
+ }, [c, C, L, i]), ie = fe({
103
110
  // La consulta actual ingresada por el usuario para filtrar opciones.
104
111
  query: a,
105
112
  // Lista de claves (como strings) de las opciones disponibles, obtenidas de 'availableOptions'.
106
- options: i.map((e) => e.key.toString()),
113
+ options: c.map((e) => e.key.toString()),
107
114
  // Elemento a mostrar cuando no hay opciones disponibles.
108
- noOptionsElement: Z ? (
115
+ noOptionsElement: ne ? (
109
116
  // Si está cargando ('isLoading' es true), muestra un spinner pequeño.
110
- /* @__PURE__ */ t(
111
- ce,
117
+ /* @__PURE__ */ o(
118
+ me,
112
119
  {
113
120
  style: { height: "30px" },
114
121
  size: "extra-tiny",
115
122
  appearance: "primary",
116
123
  label: {
117
124
  size: "small",
118
- children: V
125
+ children: G
119
126
  // Mensaje como "Buscando información...".
120
127
  }
121
128
  }
122
129
  )
123
130
  ) : (
124
131
  // Si no está cargando y no hay opciones, muestra un mensaje de "sin coincidencias".
125
- /* @__PURE__ */ t(
132
+ /* @__PURE__ */ o(
126
133
  R,
127
134
  {
128
135
  value: "no-matches",
129
- media: /* @__PURE__ */ t(ke, {}),
130
- children: I
136
+ media: /* @__PURE__ */ o(Pe, {}),
137
+ children: W
131
138
  }
132
139
  )
133
140
  ),
@@ -137,21 +144,21 @@ const ye = se({
137
144
  * @returns {JSX.Element} - Elemento JSX que representa la opción.
138
145
  */
139
146
  renderOption: u((e) => {
140
- const o = i.find((r) => r.key === e);
141
- return o ? /* @__PURE__ */ t(
147
+ const t = c.find((n) => n.key === e);
148
+ return t ? /* @__PURE__ */ o(
142
149
  R,
143
150
  {
144
- secondaryContent: o.secondaryContent || "",
145
- media: /* @__PURE__ */ t(le, { shape: "square", "aria-hidden": !0, name: o.text, color: "colorful" }),
146
- value: o.key,
147
- children: o.text
151
+ secondaryContent: t.secondaryContent || "",
152
+ media: /* @__PURE__ */ o(ge, { shape: "square", "aria-hidden": !0, name: t.text, color: "colorful" }),
153
+ value: t.key,
154
+ children: t.text
148
155
  },
149
- o.key
156
+ t.key
150
157
  ) : (
151
158
  // Si no se encuentra la opción, renderiza una versión básica con solo la clave.
152
- /* @__PURE__ */ t(R, { value: e, children: e }, e)
159
+ /* @__PURE__ */ o(R, { value: e, children: e }, e)
153
160
  );
154
- }, [i]),
161
+ }, [c]),
155
162
  // Dependencia: se recrea si 'availableOptions' cambia.
156
163
  /**
157
164
  * Función de filtrado para determinar qué opciones mostrar.
@@ -159,58 +166,60 @@ const ye = se({
159
166
  * @returns {boolean} - True si la opción debe mostrarse, false si no.
160
167
  */
161
168
  filter: u((e) => {
162
- const o = i.find((r) => r.key === e);
163
- return o ? !c.includes(e) && o.text.toLowerCase().includes(a.toLowerCase()) : !1;
164
- }, [i, c, a])
169
+ const t = c.find((n) => n.key === e);
170
+ return t ? !d.includes(e) && t.text.toLowerCase().includes(a.toLowerCase()) : !1;
171
+ }, [c, d, a])
165
172
  });
166
- if (q) return null;
167
- const re = de(
168
- _,
169
- M.efwTagPickerControl,
170
- L === "error" && M.efwTagPickerControlError
173
+ if (Y) return null;
174
+ const ce = he(
175
+ J,
176
+ _.efwTagPickerControl,
177
+ z === "error" && _.efwTagPickerControlError
171
178
  );
172
- return /* @__PURE__ */ t(ae, { children: Q ? /* @__PURE__ */ j(
173
- pe,
179
+ return T(() => {
180
+ i || N(I);
181
+ }, [i, I]), /* @__PURE__ */ o(pe, { children: H ? /* @__PURE__ */ F(
182
+ be,
174
183
  {
175
- open: b,
176
- size: G,
177
- disabled: w,
178
- onOptionSelect: oe,
179
- onOpenChange: ee,
180
- selectedOptions: c,
181
- noPopover: W,
184
+ open: h,
185
+ size: X,
186
+ disabled: M,
187
+ onOptionSelect: se,
188
+ onOpenChange: le,
189
+ selectedOptions: d,
190
+ noPopover: U,
182
191
  children: [
183
- /* @__PURE__ */ j(
184
- ue,
192
+ /* @__PURE__ */ F(
193
+ Oe,
185
194
  {
186
- className: re,
187
- secondaryAction: !w && c.length ? /* @__PURE__ */ t(
188
- he,
195
+ className: ce,
196
+ secondaryAction: !M && d.length ? /* @__PURE__ */ o(
197
+ ye,
189
198
  {
190
199
  appearance: "transparent",
191
200
  size: "small",
192
201
  shape: "rounded",
193
- onClick: K,
194
- icon: /* @__PURE__ */ t(Oe, {}),
202
+ onClick: ae,
203
+ icon: /* @__PURE__ */ o(ve, {}),
195
204
  iconPosition: "before"
196
205
  }
197
206
  ) : void 0,
198
207
  children: [
199
- /* @__PURE__ */ t(ge, { "aria-label": "Selected items", children: c.map((e) => /* @__PURE__ */ t(
200
- fe,
208
+ /* @__PURE__ */ o(Ce, { "aria-label": "Selected items", children: d.map((e) => /* @__PURE__ */ o(
209
+ Se,
201
210
  {
202
211
  style: { paddingTop: "0px", paddingBottom: "0px" },
203
- shape: J,
204
- appearance: H,
212
+ shape: Z,
213
+ appearance: $,
205
214
  value: e,
206
- children: $(e)
215
+ children: re(e)
207
216
  },
208
217
  e
209
218
  )) }),
210
- /* @__PURE__ */ t(
211
- me,
219
+ /* @__PURE__ */ o(
220
+ ke,
212
221
  {
213
- placeholder: c.length ? "" : F,
222
+ placeholder: d.length ? "" : Q,
214
223
  autoComplete: "off",
215
224
  "aria-label": "Select items",
216
225
  value: a,
@@ -220,11 +229,11 @@ const ye = se({
220
229
  ]
221
230
  }
222
231
  ),
223
- /* @__PURE__ */ t(be, { children: te })
232
+ /* @__PURE__ */ o(Te, { children: ie })
224
233
  ]
225
234
  }
226
- ) : /* @__PURE__ */ t(Ce, { style: m.length ? void 0 : { opacity: 0.7 }, children: m.length ? m.map((e) => e.text).join(", ") : "Sin datos disponibles" }) });
235
+ ) : /* @__PURE__ */ o(xe, { style: l.length ? void 0 : { opacity: 0.7 }, children: l.length ? l.map((e) => e.text).join(", ") : "Sin datos disponibles" }) });
227
236
  };
228
237
  export {
229
- ve as EFWTagPicker
238
+ Me as EFWTagPicker
230
239
  };
@@ -122,10 +122,15 @@ export interface EFWTagPickerProps extends EFWFieldChildrenProps {
122
122
  */
123
123
  options: EFWTagPickerOption[] | AsyncOptionsLoader;
124
124
  /**
125
- * Array de opciones actualmente seleccionadas en el componente
126
- * @default []
125
+ * Array de opciones actualmente seleccionadas. Cuando esta prop está presente,
126
+ * el componente funciona en modo controlled y se espera que los cambios se sincronicen desde el padre.
127
127
  */
128
128
  selectedOptions?: EFWTagPickerOption[];
129
+ /**
130
+ * Selección inicial utilizada en modo uncontrolled. Solo se aplica durante el montaje
131
+ * y permite que el componente administre su propio estado si no se proporciona `selectedOptions`.
132
+ */
133
+ defaultSelectedOptions?: EFWTagPickerOption[];
129
134
  /** Función callback ejecutada cuando cambian las opciones seleccionadas */
130
135
  onChange?: EFWTagPickerOnChange;
131
136
  /** Función para transformar o procesar las opciones antes de renderizarlas */
@@ -1,72 +1,74 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
- import { EFWField as v } from "../EFWField/EFWField.js";
3
- import { EFWTagPicker as L } from "../EFWTagPicker/EFWTagPicker.js";
4
- const j = (n) => {
2
+ import { EFWField as L } from "../EFWField/EFWField.js";
3
+ import { EFWTagPicker as O } from "../EFWTagPicker/EFWTagPicker.js";
4
+ const q = (n) => {
5
5
  const {
6
6
  title: i,
7
7
  // description,
8
8
  infoLabel: o,
9
9
  hint: t,
10
10
  style: l = {},
11
- required: r = !1,
12
- placeholder: d = "Selecciona una opción",
11
+ required: d = !1,
12
+ placeholder: r = "Selecciona una opción",
13
13
  noMatchesMessage: s = "No se encontraron coincidencias",
14
14
  loadingMessage: c = "Buscando información...",
15
15
  validationState: g = "none",
16
16
  validationMessage: h = "",
17
17
  minQueryLength: p = 0,
18
- options: m = [],
19
- selectedOptions: f = [],
18
+ options: f = [],
19
+ selectedOptions: m,
20
+ defaultSelectedOptions: u,
20
21
  editable: e = !0,
21
- disabled: u = !1,
22
- hidden: b = !1,
23
- noPopover: F = !1,
24
- multiple: C = !1,
22
+ disabled: b = !1,
23
+ hidden: F = !1,
24
+ noPopover: C = !1,
25
+ multiple: S = !1,
25
26
  tagSize: E = "medium",
26
27
  tagShape: M = "rounded",
27
28
  tagAppearance: P = "brand",
28
- onChange: S,
29
- beforeRenderOptions: W,
30
- onValidationChange: _
29
+ onChange: W,
30
+ beforeRenderOptions: _,
31
+ onValidationChange: k
31
32
  } = n;
32
33
  return /* @__PURE__ */ a(
33
- v,
34
+ L,
34
35
  {
35
36
  hint: t,
36
37
  style: l,
37
38
  title: i,
38
39
  infoLabel: o,
39
40
  weightLabel: e ? "regular" : "semibold",
40
- required: r,
41
+ required: d,
41
42
  validationState: g,
42
43
  validationMessage: h,
43
- onValidationChange: _,
44
- hidden: b,
44
+ onValidationChange: k,
45
+ hidden: F,
45
46
  children: /* @__PURE__ */ a(
46
- L,
47
+ O,
47
48
  {
48
49
  editable: e,
49
50
  noMatchesMessage: s,
50
51
  loadingMessage: c,
51
- placeholder: d,
52
- selectedOptions: f,
52
+ placeholder: r,
53
+ selectedOptions: m,
54
+ defaultSelectedOptions: u,
53
55
  minQueryLength: p,
54
- options: m,
55
- onChange: (k = []) => {
56
- S?.(k, "[EFWTagPickerField]: __handleChange__");
56
+ options: f,
57
+ onChange: (v = []) => {
58
+ W?.(v, "[EFWTagPickerField]: __handleChange__");
57
59
  },
58
- beforeRenderOptions: W,
59
- disabled: u,
60
- noPopover: F,
60
+ beforeRenderOptions: _,
61
+ disabled: b,
62
+ noPopover: C,
61
63
  tagSize: E,
62
64
  tagShape: M,
63
65
  tagAppearance: P,
64
- multiple: C
66
+ multiple: S
65
67
  }
66
68
  )
67
69
  }
68
70
  );
69
71
  };
70
72
  export {
71
- j as EFWTagPickerField
73
+ q as EFWTagPickerField
72
74
  };
@@ -1,7 +1,7 @@
1
- import { jsx as x, Fragment as H } from "react/jsx-runtime";
2
- import { makeStyles as B, tokens as l, mergeClasses as D, Textarea as F, Text as I } from "@fluentui/react-components";
3
- import { useId as K, useRef as v, useState as P, useCallback as s, useEffect as j, useLayoutEffect as L } from "react";
4
- const $ = B({
1
+ import { jsx as m, Fragment as j } from "react/jsx-runtime";
2
+ import { makeStyles as L, tokens as l, mergeClasses as $, Textarea as U, Text as W } from "@fluentui/react-components";
3
+ import { useId as _, useRef as z, useState as q, useCallback as s, useEffect as h, useLayoutEffect as G } from "react";
4
+ const J = L({
5
5
  efwTextArea: {
6
6
  "& textarea": {
7
7
  maxHeight: "none",
@@ -29,75 +29,77 @@ const $ = B({
29
29
  // borderBottom: "2px solid var(--colorPaletteRedBorder2) !important"
30
30
  // }
31
31
  }
32
- }), G = (k) => {
32
+ }), x = (i) => i ?? "", X = (i) => {
33
33
  const {
34
- value: o = "",
35
- onKeyDown: g,
36
- onChange: r,
37
- editable: b = !0,
38
- disabled: T = !1,
39
- autoComplete: w = "off",
40
- className: S = "",
41
- placeholder: N,
34
+ value: u,
35
+ defaultValue: p,
36
+ onKeyDown: C,
37
+ onChange: y,
38
+ editable: S = !0,
39
+ disabled: N = !1,
40
+ autoComplete: A = "off",
41
+ className: E = "",
42
+ placeholder: D,
42
43
  maxLength: c = 250,
43
- size: V,
44
- validationState: z = "none",
45
- setParentComponentState: i,
46
- autoResize: u = !0
44
+ size: H,
45
+ validationState: I = "none",
46
+ setParentComponentState: d,
47
+ autoResize: f = !0
47
48
  // Nuevo prop con valor por defecto true
48
- } = k, h = $(), m = K(), d = v(o || ""), f = v(null), [t, p] = P(o || ""), C = s(() => {
49
- if (!u || !f.current) return;
50
- const e = f.current;
49
+ } = i, t = u !== void 0, R = x(t ? u : p), r = x(p), k = J(), v = _(), g = z(null), [B, V] = q(R), b = z(!1), o = t ? x(u) : B, T = s(() => {
50
+ if (!f || !g.current) return;
51
+ const e = g.current;
51
52
  e.style.height = "auto", e.style.height = `${e.scrollHeight}px`;
52
- }, [u]), n = s((e) => {
53
- e.length > c ? i?.("error", `Por favor introduzca menos de ${c} caracteres.`) : i?.("none", "");
54
- }, [c, i]);
55
- j(() => {
56
- if (o !== d.current) {
57
- const e = o || "";
58
- n(e), p(e), d.current = e, r?.(e, e);
53
+ }, [f]), a = s((e) => {
54
+ e.length > c ? d?.("error", `Por favor introduzca menos de ${c} caracteres.`) : d?.("none", "");
55
+ }, [c, d]);
56
+ h(() => {
57
+ t && a(o);
58
+ }, [t, o, a]), h(() => {
59
+ t || b.current || (b.current = !0, a(o));
60
+ }, [t, o, a]), G(() => {
61
+ T();
62
+ }, [o, T]);
63
+ const F = s((e, w) => {
64
+ if (typeof w.value == "string") {
65
+ const n = w.value ?? "";
66
+ a(n), t || V(n), y?.(n, n);
59
67
  }
60
- }, [o, n, r]), L(() => {
61
- C();
62
- }, [t, C]);
63
- const A = s((e, y) => {
64
- if (typeof y.value == "string") {
65
- const a = y.value || "";
66
- n(a), p(a), d.current = a, r?.(a, a);
67
- }
68
- }, [n, r]), E = s((e) => {
69
- g?.(e, t);
70
- }, [g, t]), R = D(
71
- S,
72
- h.efwTextArea,
73
- z === "error" && h.efwTextAreaError
68
+ }, [a, t, y]), K = s((e) => {
69
+ C?.(e, o);
70
+ }, [C, o]), P = $(
71
+ E,
72
+ k.efwTextArea,
73
+ I === "error" && k.efwTextAreaError
74
74
  );
75
- return /* @__PURE__ */ x(H, { children: b ? /* @__PURE__ */ x(
76
- F,
75
+ return h(() => {
76
+ t || (V((e) => e === r ? e : r), a(r));
77
+ }, [t, r, a]), /* @__PURE__ */ m(j, { children: S ? /* @__PURE__ */ m(
78
+ U,
77
79
  {
78
- ref: f,
79
- className: R,
80
- id: m,
81
- name: m,
82
- placeholder: N,
83
- disabled: T,
84
- value: t,
85
- autoComplete: w,
80
+ ref: g,
81
+ className: P,
82
+ id: v,
83
+ name: v,
84
+ placeholder: D,
85
+ disabled: N,
86
+ value: o,
87
+ autoComplete: A,
86
88
  autoCorrect: "off",
87
89
  autoCapitalize: "off",
88
90
  spellCheck: "false",
89
- onChange: A,
90
- onKeyDown: E,
91
- size: V,
91
+ onChange: F,
92
+ onKeyDown: K,
93
+ size: H,
92
94
  style: {
93
- resize: u ? "none" : "vertical",
95
+ resize: f ? "none" : "vertical",
94
96
  overflow: "hidden",
95
97
  minHeight: "40px"
96
98
  // Altura mínima para mantener usabilidad
97
99
  }
98
100
  }
99
- ) : /* @__PURE__ */ x(I, { style: t ? void 0 : { opacity: 0.7 }, children: t || "Sin datos disponibles" }) });
101
+ ) : /* @__PURE__ */ m(W, { style: o ? void 0 : { opacity: 0.7 }, children: o || "Sin datos disponibles" }) });
100
102
  };
101
103
  export {
102
- G as EFWTextArea
104
+ X as EFWTextArea
103
105
  };
@@ -22,10 +22,14 @@ export interface EFWTextAreaProps extends Partial<EFWFieldChildrenProps> {
22
22
  */
23
23
  autoComplete?: 'on' | 'off';
24
24
  /**
25
- * Valor inicial o controlado del textarea
26
- * @default ""
25
+ * Valor controlado del textarea. Si se proporciona, el componente opera en modo controlled.
27
26
  */
28
27
  value?: EFWTextAreaValue;
28
+ /**
29
+ * Valor inicial usado cuando el componente funciona en modo uncontrolled.
30
+ * Solo se aplica durante el montaje.
31
+ */
32
+ defaultValue?: EFWTextAreaValue;
29
33
  /**
30
34
  * Tamaño visual del textarea
31
35
  */