@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,183 +1,198 @@
1
- import { jsx as k, Fragment as Z } from "react/jsx-runtime";
2
- import { makeStyles as ee, tokens as N, mergeClasses as re, Input as te, Text as ne } from "@fluentui/react-components";
3
- import { useId as ae, useMemo as oe, useState as P, useRef as se, useCallback as B, useEffect as le } from "react";
4
- import { applyFormatting as p, stripFormatting as x, isValidNumber as H } from "./EFWNumberInput.utils.js";
5
- const ue = ee({
1
+ import { jsx as j, Fragment as ie } from "react/jsx-runtime";
2
+ import { makeStyles as ce, tokens as C, mergeClasses as de, Input as fe, Text as me } from "@fluentui/react-components";
3
+ import { useId as pe, useMemo as S, useCallback as k, useState as A, useRef as ge, useEffect as L } from "react";
4
+ import { stripFormatting as D, applyFormatting as p, isValidNumber as Q } from "./EFWNumberInput.utils.js";
5
+ const be = ce({
6
6
  EFWNumberInputError: {
7
- backgroundColor: N.colorPaletteRedBackground1,
7
+ backgroundColor: C.colorPaletteRedBackground1,
8
8
  "::after": {
9
- borderBottomColor: N.colorPaletteRedBorder2,
9
+ borderBottomColor: C.colorPaletteRedBorder2,
10
10
  borderBottomStyle: "solid",
11
11
  borderBottomWidth: "2px"
12
12
  }
13
13
  },
14
14
  EFWNumberInput: {
15
15
  "& [disabled]": {
16
- backgroundColor: N.colorNeutralBackground3,
17
- color: N.colorNeutralForeground2,
16
+ backgroundColor: C.colorNeutralBackground3,
17
+ color: C.colorNeutralForeground2,
18
18
  "&::placeholder": {
19
19
  color: "transparent"
20
20
  }
21
21
  },
22
22
  "&:has(span + [disabled])": {
23
- backgroundColor: N.colorNeutralBackground3
23
+ backgroundColor: C.colorNeutralBackground3
24
24
  }
25
25
  }
26
- }), ie = () => {
26
+ }), Ve = () => {
27
27
  const i = /* @__PURE__ */ new Map();
28
- return (r, t) => {
29
- const $ = `${r}-${t}`;
30
- if (!i.has($)) {
31
- const E = r.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), g = t.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32
- i.set($, {
33
- validation: new RegExp(`^-?[\\d${E}]*${g}?\\d*$`),
34
- thousandSeparator: new RegExp(`^\\d+${E}0{1,2}$`),
28
+ return (o, V) => {
29
+ const a = `${o}-${V}`;
30
+ if (!i.has(a)) {
31
+ const w = o.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), h = V.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
32
+ i.set(a, {
33
+ validation: new RegExp(`^-?[\\d${w}]*${h}?\\d*$`),
34
+ thousandSeparator: new RegExp(`^\\d+${w}0{1,2}$`),
35
35
  progressPatterns: [
36
36
  new RegExp("^-?$"),
37
- new RegExp(`^-?\\d+${g}$`),
38
- new RegExp(`^-?\\d+${g}0+$`),
39
- new RegExp(`^-?[\\d${E}]+${g}$`),
40
- new RegExp(`^-?[\\d${E}]+${g}0+$`)
37
+ new RegExp(`^-?\\d+${h}$`),
38
+ new RegExp(`^-?\\d+${h}0+$`),
39
+ new RegExp(`^-?[\\d${w}]+${h}$`),
40
+ new RegExp(`^-?[\\d${w}]+${h}0+$`)
41
41
  ]
42
42
  });
43
43
  }
44
- return i.get($);
44
+ return i.get(a);
45
45
  };
46
- }, ce = ie(), O = (i, r) => r.some((t) => t.test(i)), de = (i, r) => i.includes(r) && (i.endsWith("0") || i.endsWith(r) || /\.\d*0$/.test(i.replace(r, "."))), he = (i) => {
46
+ }, he = Ve(), X = (i, o) => o.some((V) => V.test(i)), Ee = (i, o) => i.includes(o) && (i.endsWith("0") || i.endsWith(o) || /\.\d*0$/.test(i.replace(o, "."))), ye = (i) => {
47
47
  const {
48
- value: r,
49
- onChange: t,
50
- editable: $ = !0,
51
- disabled: E = !1,
52
- className: g = "",
53
- autoComplete: U = "off",
54
- placeholder: _,
55
- contentBefore: q,
56
- contentAfter: G,
57
- formatType: a = "number",
58
- maxValue: y,
59
- minValue: C,
60
- validationState: J = "none",
48
+ value: o,
49
+ defaultValue: V,
50
+ onChange: a,
51
+ editable: w = !0,
52
+ disabled: h = !1,
53
+ className: Y = "",
54
+ autoComplete: Z = "off",
55
+ placeholder: ee,
56
+ contentBefore: re,
57
+ contentAfter: te,
58
+ formatType: t = "number",
59
+ maxValue: R,
60
+ minValue: F,
61
+ validationState: ne = "none",
61
62
  setParentComponentState: d,
62
- enableFormatting: W = !0,
63
- thousandSeparator: v = ",",
63
+ enableFormatting: H = !0,
64
+ thousandSeparator: N = ",",
64
65
  decimalSeparator: f = "."
65
- } = i, D = ue(), T = ae(), o = oe(() => ({
66
- enableFormatting: W,
67
- thousandSeparator: v,
66
+ } = i, I = V ?? null, O = be(), U = pe(), x = o !== void 0, P = x ? o ?? null : V ?? null, n = S(() => ({
67
+ enableFormatting: H,
68
+ thousandSeparator: N,
68
69
  decimalSeparator: f
69
- }), [W, v, f]), [c, b] = P(() => p(r ? r.toString() : "", a, o)), [S, w] = P(!1), [V, M] = P(!1), u = se({
70
- prevValue: r,
70
+ }), [H, N, f]), $ = k((r) => r === null ? "" : D(r.toString(), t, n), [t, n]), B = S(() => $(P), [$, P]), y = S(
71
+ () => $(I),
72
+ [$, I]
73
+ ), _ = S(
74
+ () => y ? p(y, t, n) : "",
75
+ [y, t, n]
76
+ ), [c, g] = A(() => B ? p(B, t, n) : ""), [W, v] = A(!1), [b, q] = A(!1), l = ge({
77
+ prevValue: P,
71
78
  lastValidatedValue: "",
72
- rawValue: r ? x(r.toString(), a, o) : ""
73
- }), h = ce(v, f), F = B((n) => {
74
- if (u.current.lastValidatedValue === n)
75
- return S;
76
- if (u.current.lastValidatedValue = n, a !== "number" || n.length === 0)
79
+ rawValue: B
80
+ }), E = he(N, f), T = k((r) => {
81
+ if (l.current.lastValidatedValue === r)
82
+ return W;
83
+ if (l.current.lastValidatedValue = r, t !== "number" || r.length === 0)
77
84
  return d?.("none", ""), !1;
78
- if (!h.validation.test(n))
85
+ if (!E.validation.test(r))
79
86
  return d?.("error", "El valor ingresado no es un número válido."), !0;
80
- const s = x(n, a, o);
81
- if (O(n, h.progressPatterns))
87
+ const s = D(r, t, n);
88
+ if (X(r, E.progressPatterns))
82
89
  return d?.("none", ""), !1;
83
- if (s && !H(s))
90
+ if (s && !Q(s))
84
91
  return d?.("error", "El valor ingresado no es un número válido."), !0;
85
92
  if (s) {
86
93
  const e = Number(s);
87
- if (C !== void 0 && e < C)
88
- return d?.("error", `El valor debe ser mayor o igual a ${p(C.toString(), "number", o)}.`), !0;
89
- if (y !== void 0 && e > y)
90
- return d?.("error", `El valor debe ser menor o igual a ${p(y.toString(), "number", o)}.`), !0;
94
+ if (F !== void 0 && e < F)
95
+ return d?.("error", `El valor debe ser mayor o igual a ${p(F.toString(), "number", n)}.`), !0;
96
+ if (R !== void 0 && e > R)
97
+ return d?.("error", `El valor debe ser menor o igual a ${p(R.toString(), "number", n)}.`), !0;
91
98
  }
92
99
  return d?.("none", ""), !1;
93
- }, [a, h, d, C, y, o, S]);
94
- le(() => {
95
- if (r !== u.current.prevValue && !V) {
96
- const n = x(r ? r.toString() : "", a, o), s = p(n, a, o);
97
- u.current.rawValue = n, u.current.prevValue = r, b(s), w(!1);
100
+ }, [t, E, d, F, R, n, W]);
101
+ L(() => {
102
+ if (x && o !== l.current.prevValue && !b) {
103
+ const r = $(o ?? null), s = r ? p(r, t, n) : "";
104
+ l.current.rawValue = r, l.current.prevValue = o ?? null, g(s), v(!1);
98
105
  }
99
- }, [r, a, o, V]);
100
- const K = B(() => {
101
- if (a !== "number" || !V) return;
102
- M(!1);
103
- let n = c;
104
- if (n.endsWith(f) && (n = n.slice(0, -1)), n.includes(f)) {
105
- const [e, I] = n.split(f);
106
- I && /^0+$/.test(I) && (n = e);
106
+ }, [o, t, n, b, x, $]), L(() => {
107
+ x || b || (l.current.rawValue = y, l.current.prevValue = I, g(_), v(!1));
108
+ }, [
109
+ x,
110
+ b,
111
+ y,
112
+ _,
113
+ I
114
+ ]);
115
+ const ae = k(() => {
116
+ if (t !== "number" || !b) return;
117
+ q(!1);
118
+ let r = c;
119
+ if (r.endsWith(f) && (r = r.slice(0, -1)), r.includes(f)) {
120
+ const [e, z] = r.split(f);
121
+ z && /^0+$/.test(z) && (r = e);
107
122
  }
108
- const s = x(n, a, o);
109
- if (s && H(s)) {
110
- const e = p(s, a, o);
111
- u.current.rawValue = s, b(e), w(!1), t?.(Number(s), e);
112
- } else (c === "" || c === "-") && (u.current.rawValue = "", b(""), w(!1), t?.(null, ""));
113
- }, [c, a, o, t, f, V]), L = B((n, s) => {
123
+ const s = D(r, t, n);
124
+ if (s && Q(s)) {
125
+ const e = p(s, t, n);
126
+ l.current.rawValue = s, g(e), v(!1), a?.(Number(s), e);
127
+ } else (c === "" || c === "-") && (l.current.rawValue = "", g(""), v(!1), a?.(null, ""));
128
+ }, [c, t, n, a, f, b]), oe = k((r, s) => {
114
129
  if (typeof s.value != "string") return;
115
130
  const e = s.value;
116
- if (V || M(!0), b(e), e.length < c.length && c.startsWith(e) && h.thousandSeparator.test(e)) {
117
- const l = e.replace(new RegExp(v.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), ""), R = p(l, a, o), A = F(R);
118
- u.current.rawValue = l, b(R), w(A), t?.(A || !l ? null : Number(l), R);
131
+ if (b || q(!0), g(e), e.length < c.length && c.startsWith(e) && E.thousandSeparator.test(e)) {
132
+ const u = e.replace(new RegExp(N.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"), "g"), ""), M = p(u, t, n), K = T(M);
133
+ l.current.rawValue = u, g(M), v(K), a?.(K || !u ? null : Number(u), M);
119
134
  return;
120
135
  }
121
- const m = x(e, a, o), j = F(e), z = de(e, f), Y = O(e, h.progressPatterns);
122
- if (u.current.rawValue = m, w(j), j)
123
- if (m && h.validation.test(e))
124
- if (z)
125
- t?.(Number(m), e);
136
+ const m = D(e, t, n), G = T(e), J = Ee(e, f), ue = X(e, E.progressPatterns);
137
+ if (l.current.rawValue = m, v(G), G)
138
+ if (m && E.validation.test(e))
139
+ if (J)
140
+ a?.(Number(m), e);
126
141
  else {
127
- const l = p(m, a, o);
128
- b(l), t?.(Number(m), l);
142
+ const u = p(m, t, n);
143
+ g(u), a?.(Number(m), u);
129
144
  }
130
145
  else
131
- t?.(null, e);
146
+ a?.(null, e);
132
147
  else if (m)
133
- if (z)
134
- t?.(Number(m), e);
148
+ if (J)
149
+ a?.(Number(m), e);
135
150
  else {
136
- const l = p(m, a, o);
137
- b(l), t?.(Number(m), l);
151
+ const u = p(m, t, n);
152
+ g(u), a?.(Number(m), u);
138
153
  }
139
- else if (Y) {
140
- const l = e.replace(/[^\d-]/g, "");
141
- l && l !== "-" ? (u.current.rawValue = l, t?.(Number(l), e)) : (u.current.rawValue = "", t?.(null, e));
154
+ else if (ue) {
155
+ const u = e.replace(/[^\d-]/g, "");
156
+ u && u !== "-" ? (l.current.rawValue = u, a?.(Number(u), e)) : (l.current.rawValue = "", a?.(null, e));
142
157
  } else
143
- u.current.rawValue = "", t?.(null, "");
158
+ l.current.rawValue = "", a?.(null, "");
144
159
  }, [
145
160
  c,
146
- V,
147
- h,
148
- v,
149
- a,
150
- o,
151
- F,
161
+ b,
162
+ E,
163
+ N,
164
+ t,
165
+ n,
166
+ T,
152
167
  f,
153
- t
154
- ]), Q = J === "error" || S, X = re(
155
- g,
156
- D.EFWNumberInput,
157
- Q && D.EFWNumberInputError
168
+ a
169
+ ]), le = ne === "error" || W, se = de(
170
+ Y,
171
+ O.EFWNumberInput,
172
+ le && O.EFWNumberInputError
158
173
  );
159
- return /* @__PURE__ */ k(Z, { children: $ ? /* @__PURE__ */ k(
160
- te,
174
+ return /* @__PURE__ */ j(ie, { children: w ? /* @__PURE__ */ j(
175
+ fe,
161
176
  {
162
- className: X,
163
- id: T,
164
- name: T,
177
+ className: se,
178
+ id: U,
179
+ name: U,
165
180
  type: "text",
166
- placeholder: _,
167
- contentBefore: q,
168
- contentAfter: G,
169
- disabled: E,
181
+ placeholder: ee,
182
+ contentBefore: re,
183
+ contentAfter: te,
184
+ disabled: h,
170
185
  value: c,
171
- "data-raw-value": u.current.rawValue,
172
- autoComplete: U,
186
+ "data-raw-value": l.current.rawValue,
187
+ autoComplete: Z,
173
188
  autoCorrect: "off",
174
189
  autoCapitalize: "off",
175
190
  spellCheck: "false",
176
- onChange: L,
177
- onBlur: K
191
+ onChange: oe,
192
+ onBlur: ae
178
193
  }
179
- ) : /* @__PURE__ */ k(ne, { style: c ? void 0 : { opacity: 0.7 }, children: c || "Sin datos disponibles" }) });
194
+ ) : /* @__PURE__ */ j(me, { style: c ? void 0 : { opacity: 0.7 }, children: c || "Sin datos disponibles" }) });
180
195
  };
181
196
  export {
182
- he as EFWNumberInput
197
+ ye as EFWNumberInput
183
198
  };
@@ -71,6 +71,18 @@ export interface EFWNumberInputProps extends Partial<EFWFieldChildrenProps> {
71
71
  * value={null}
72
72
  */
73
73
  value?: EFWNumberInputValue;
74
+ /**
75
+ * Valor inicial usado cuando el componente opera en modo uncontrolled.
76
+ * Solo se toma en cuenta durante el montaje o cuando cambia explícitamente
77
+ * mientras no se haya definido `value`.
78
+ *
79
+ * @example
80
+ * defaultValue={25000}
81
+ *
82
+ * @example
83
+ * defaultValue={null}
84
+ */
85
+ defaultValue?: EFWNumberInputValue;
74
86
  formatType?: FormatType;
75
87
  /**
76
88
  * Controla si el usuario puede editar el contenido del campo.
@@ -1,58 +1,60 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
- import { EFWField as W } from "../EFWField/EFWField.js";
3
- import { EFWNumberInput as I } from "../EFWNumberInput/EFWNumberInput.js";
4
- const w = (t) => {
2
+ import { EFWField as I } from "../EFWField/EFWField.js";
3
+ import { EFWNumberInput as L } from "../EFWNumberInput/EFWNumberInput.js";
4
+ const y = (t) => {
5
5
  const {
6
6
  title: n,
7
- infoLabel: o,
8
- hint: l,
7
+ infoLabel: l,
8
+ hint: o,
9
9
  style: r = {},
10
10
  required: i = !1,
11
11
  contentBefore: d,
12
- contentAfter: h,
13
- minValue: m,
14
- maxValue: s,
15
- validationState: u,
12
+ contentAfter: u,
13
+ minValue: h,
14
+ maxValue: m,
15
+ validationState: s,
16
16
  validationMessage: f,
17
17
  value: p,
18
+ defaultValue: c,
18
19
  editable: e = !0,
19
- disabled: c = !1,
20
- hidden: g = !1,
21
- onChange: b,
22
- autoComplete: C = "off",
23
- placeholder: F,
20
+ disabled: g = !1,
21
+ hidden: b = !1,
22
+ onChange: C,
23
+ autoComplete: F = "off",
24
+ placeholder: V,
24
25
  thousandSeparator: v,
25
26
  decimalSeparator: x,
26
27
  onValidationChange: E
27
28
  } = t;
28
29
  return /* @__PURE__ */ a(
29
- W,
30
+ I,
30
31
  {
31
32
  style: r,
32
33
  title: n,
33
- infoLabel: o,
34
+ infoLabel: l,
34
35
  weightLabel: e ? "regular" : "semibold",
35
- hint: l,
36
+ hint: o,
36
37
  required: i,
37
- validationState: u,
38
+ validationState: s,
38
39
  validationMessage: f,
39
40
  onValidationChange: E,
40
- hidden: g,
41
+ hidden: b,
41
42
  children: /* @__PURE__ */ a(
42
- I,
43
+ L,
43
44
  {
44
45
  value: p,
46
+ defaultValue: c,
45
47
  editable: e,
46
- onChange: (S, V) => {
47
- b?.(S, V || "");
48
+ onChange: (S, W) => {
49
+ C?.(S, W);
48
50
  },
49
- disabled: c,
50
- autoComplete: C,
51
- placeholder: F,
51
+ disabled: g,
52
+ autoComplete: F,
53
+ placeholder: V,
52
54
  contentBefore: d,
53
- contentAfter: h,
54
- minValue: m,
55
- maxValue: s,
55
+ contentAfter: u,
56
+ minValue: h,
57
+ maxValue: m,
56
58
  thousandSeparator: v,
57
59
  decimalSeparator: x
58
60
  }
@@ -61,5 +63,5 @@ const w = (t) => {
61
63
  );
62
64
  };
63
65
  export {
64
- w as EFWNumberInputField
66
+ y as EFWNumberInputField
65
67
  };
@@ -1,54 +1,55 @@
1
- import { jsx as c, Fragment as C } from "react/jsx-runtime";
2
- import { makeStyles as N, tokens as s, mergeClasses as x, Switch as y, Text as T } from "@fluentui/react-components";
3
- import { useId as F, useState as u, useEffect as V, useCallback as _ } from "react";
4
- const I = N({
1
+ import { jsx as r, Fragment as x } from "react/jsx-runtime";
2
+ import { makeStyles as y, tokens as c, mergeClasses as T, Switch as v, Text as F } from "@fluentui/react-components";
3
+ import { useId as V, useState as _, useEffect as I, useCallback as B } from "react";
4
+ const E = y({
5
5
  efwSwitch: {
6
6
  "& [disabled]": {
7
7
  "&~ .fui-Switch__indicator": {
8
- backgroundColor: s.colorNeutralBackground3,
9
- color: s.colorNeutralForeground4
8
+ backgroundColor: c.colorNeutralBackground3,
9
+ color: c.colorNeutralForeground4
10
10
  },
11
11
  "&~ .fui-Switch__label": {
12
- color: s.colorNeutralForeground2
12
+ color: c.colorNeutralForeground2
13
13
  }
14
14
  },
15
15
  // Afectar el span que contiene el input disabled
16
16
  "& :has(span + [disabled])": {
17
- backgroundColor: s.colorNeutralBackground3
17
+ backgroundColor: c.colorNeutralBackground3
18
18
  }
19
19
  }
20
- }), j = (h) => {
20
+ }), U = (f) => {
21
21
  const {
22
- value: o = !1,
23
- onChange: l,
24
- className: f = "",
22
+ value: d,
23
+ defaultValue: k,
24
+ onChange: i,
25
+ className: m = "",
25
26
  editable: g = !0,
26
- disabled: k = !1,
27
- checkedText: e = "Sí",
28
- uncheckedText: t = "No"
29
- } = h, m = I(), S = F(), [r, n] = u(o || !1), [i, d] = u(o ? e : t);
30
- V(() => {
31
- n(o || !1), d(o ? e : t);
32
- }, [o, e, t]);
33
- const b = _((p) => {
34
- const a = p.currentTarget.checked;
35
- n(a), d(a ? e : t), l?.(a, a ? e : t);
36
- }, [e, t, l]), w = x(
37
- m.efwSwitch,
38
- f
27
+ disabled: C = !1,
28
+ checkedText: l = "Sí",
29
+ uncheckedText: s = "No"
30
+ } = f, S = E(), b = V(), o = k ?? !1, e = d !== void 0, [w, u] = _(o);
31
+ I(() => {
32
+ e || u((t) => t === o ? t : o);
33
+ }, [e, o]);
34
+ const h = e ? !!d : w, a = h ? l : s, p = B((t) => {
35
+ const n = t.currentTarget.checked;
36
+ e || u(n), i?.(n, n ? l : s);
37
+ }, [l, s, i, e]), N = T(
38
+ S.efwSwitch,
39
+ m
39
40
  );
40
- return /* @__PURE__ */ c(C, { children: g ? /* @__PURE__ */ c(
41
- y,
41
+ return /* @__PURE__ */ r(x, { children: g ? /* @__PURE__ */ r(
42
+ v,
42
43
  {
43
- className: w,
44
- id: S,
45
- disabled: k,
46
- checked: r,
47
- onChange: b,
48
- label: r ? e : t
44
+ className: N,
45
+ id: b,
46
+ disabled: C,
47
+ checked: h,
48
+ onChange: p,
49
+ label: a
49
50
  }
50
- ) : /* @__PURE__ */ c(T, { style: i ? void 0 : { opacity: 0.7 }, children: i || "Sin datos disponibles" }) });
51
+ ) : /* @__PURE__ */ r(F, { style: a ? void 0 : { opacity: 0.7 }, children: a || "Sin datos disponibles" }) });
51
52
  };
52
53
  export {
53
- j as EFWSwitch
54
+ U as EFWSwitch
54
55
  };
@@ -23,6 +23,12 @@ export interface EFWSwitchProps extends Partial<EFWFieldChildrenProps> {
23
23
  * Valor inicial del switch.
24
24
  */
25
25
  value?: EFWSwitchValue;
26
+ /**
27
+ * Valor por defecto utilizado cuando el componente opera en modo uncontrolled.
28
+ * Este valor solo se usa durante la inicialización o cuando cambia la prop
29
+ * `defaultValue` mientras no exista una prop `value` controlando el campo.
30
+ */
31
+ defaultValue?: EFWSwitchValue;
26
32
  /**
27
33
  * Determina si el switch es editable por el usuario.
28
34
  * @default true
@@ -1,47 +1,49 @@
1
1
  import { jsx as a } from "react/jsx-runtime";
2
- import { EFWField as p } from "../EFWField/EFWField.js";
3
- import { EFWSwitch as x } from "../EFWSwitch/EFWSwitch.js";
4
- const W = (t) => {
2
+ import { EFWField as x } from "../EFWField/EFWField.js";
3
+ import { EFWSwitch as S } from "../EFWSwitch/EFWSwitch.js";
4
+ const k = (t) => {
5
5
  const {
6
6
  title: i,
7
- infoLabel: n,
8
- hint: l,
7
+ infoLabel: l,
8
+ hint: n,
9
9
  style: o = {},
10
10
  required: d = !1,
11
11
  validationState: h,
12
12
  validationMessage: r,
13
- value: s = !1,
13
+ value: s,
14
+ defaultValue: c,
14
15
  editable: e = !0,
15
- disabled: c = !1,
16
- hidden: f = !1,
17
- checkedText: g = "Sí",
16
+ disabled: f = !1,
17
+ hidden: g = !1,
18
+ checkedText: u = "Sí",
18
19
  uncheckedText: m = "No",
19
- onChange: u,
20
- onValidationChange: b
20
+ onChange: b,
21
+ onValidationChange: C
21
22
  } = t;
22
23
  return /* @__PURE__ */ a(
23
- p,
24
+ x,
24
25
  {
25
26
  style: o,
26
27
  title: i,
27
- infoLabel: n,
28
+ infoLabel: l,
28
29
  weightLabel: e ? "regular" : "semibold",
29
- hint: l,
30
+ hint: n,
30
31
  required: d,
31
32
  validationState: h,
32
33
  validationMessage: r,
33
- onValidationChange: b,
34
- hidden: f,
34
+ onValidationChange: C,
35
+ hidden: g,
35
36
  children: /* @__PURE__ */ a(
36
- x,
37
+ S,
37
38
  {
38
39
  value: s,
40
+ defaultValue: c,
39
41
  editable: e,
40
- onChange: (C, F) => {
41
- u?.(C, F);
42
+ onChange: (F, p) => {
43
+ b?.(F, p);
42
44
  },
43
- disabled: c,
44
- checkedText: g,
45
+ disabled: f,
46
+ checkedText: u,
45
47
  uncheckedText: m
46
48
  }
47
49
  )
@@ -49,5 +51,5 @@ const W = (t) => {
49
51
  );
50
52
  };
51
53
  export {
52
- W as EFWSwitchField
54
+ k as EFWSwitchField
53
55
  };
@@ -1,7 +1,7 @@
1
1
  import { EFWFieldProps } from '../EFWField/EFWField.types';
2
2
  import { EFWSwitchProps, EFWSwitchValue, EFWSwitchOnChange } from '../EFWSwitch/EFWSwitch.types';
3
3
 
4
- export type EFWSwitchFieldValue = EFWSwitchValue;
4
+ export type EFWSwitchFieldValue = EFWSwitchValue | undefined;
5
5
  export type EFWSwitchFieldOnChange = EFWSwitchOnChange;
6
6
  export interface EFWSwitchFieldProps extends Omit<EFWFieldProps, 'children'>, EFWSwitchProps {
7
7
  }