@envisiongroup/porygon 1.0.2 → 1.0.3

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.
@@ -1,18 +1,18 @@
1
- import { jsxs as ze, jsx as w } from "react/jsx-runtime";
2
- import { useMemo as L, useRef as o, useState as He, useEffect as oe, useCallback as p } from "react";
3
- import { useIsomorphicLayoutEffect as ce } from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
4
- import { makeStyles as Rt, mergeClasses as Lt, Subtitle2Stronger as Ye, Text as Je, tokens as Qe } from "@fluentui/react-components";
5
- import { generateGridTemplateColumns as wt, EFWFormFieldWrapper as xt } from "./EFWForm.utils.js";
6
- import { EFWMessageBarManager as It } from "../EFWMessageBarManager/EFWMessageBarManager.js";
1
+ import { jsxs as ze, jsx as L } from "react/jsx-runtime";
2
+ import { useMemo as D, useRef as o, useState as He, useEffect as ce, useCallback as p } from "react";
3
+ import { useIsomorphicLayoutEffect as le } from "../../hooks/useIsomorphicLayoutEffect/useIsomorphicLayoutEffect.js";
4
+ import { makeStyles as wt, mergeClasses as Lt, Subtitle2Stronger as Ye, Text as Je, tokens as Qe } from "@fluentui/react-components";
5
+ import { generateGridTemplateColumns as xt, EFWFormFieldWrapper as It } from "./EFWForm.utils.js";
6
+ import { EFWMessageBarManager as Pt } from "../EFWMessageBarManager/EFWMessageBarManager.js";
7
7
  import { isFieldEmptyForValidation as Xe } from "../../commons/valueNormalization.js";
8
- import { useFormLocaleText as Pt, PorygonI18nProvider as $t } from "../../i18n/PorygonI18nProvider.js";
9
- const Nt = Rt({
8
+ import { useFormLocaleText as Nt, PorygonI18nProvider as $t } from "../../i18n/PorygonI18nProvider.js";
9
+ const qt = wt({
10
10
  efwFormFieldWrapper: {
11
11
  "&:empty": {
12
12
  display: "none !important"
13
13
  }
14
14
  }
15
- }), qt = 900, Ut = 20, Bt = {}, _t = [
15
+ }), Ut = 900, Bt = 20, _t = {}, jt = [
16
16
  ".fui-Input",
17
17
  ".fui-Textarea",
18
18
  ".fui-DatePicker",
@@ -23,24 +23,24 @@ const Nt = Rt({
23
23
  'input:not([type="hidden"]):not([type="file"])',
24
24
  ".fui-Button",
25
25
  'button:not([aria-hidden="true"])'
26
- ], jt = (s) => {
27
- for (const S of _t) {
26
+ ], Kt = (s) => {
27
+ for (const S of jt) {
28
28
  const E = s.querySelector(S);
29
29
  if (E)
30
30
  return E;
31
31
  }
32
32
  return null;
33
- }, Kt = ({
33
+ }, kt = ({
34
34
  animationDelay: s = 0,
35
35
  animationToken: S,
36
36
  children: E,
37
- className: D
37
+ className: O
38
38
  }) => {
39
39
  const g = o(null), b = p(
40
40
  (y) => {
41
41
  if (g.current?.cancel(), g.current = null, !S || !y)
42
42
  return;
43
- const j = jt(y);
43
+ const j = Kt(y);
44
44
  !j || typeof j.animate != "function" || typeof window < "u" && window.matchMedia?.("(prefers-reduced-motion: reduce)").matches || (g.current = j.animate(
45
45
  [
46
46
  {
@@ -61,15 +61,15 @@ const Nt = Rt({
61
61
  ],
62
62
  {
63
63
  delay: s,
64
- duration: qt,
64
+ duration: Ut,
65
65
  easing: "ease-out"
66
66
  }
67
67
  ));
68
68
  },
69
69
  [s, S]
70
70
  );
71
- return /* @__PURE__ */ w("div", { ref: b, className: D, children: E });
72
- }, X = {
71
+ return /* @__PURE__ */ L("div", { ref: b, className: O, children: E });
72
+ }, Z = {
73
73
  Text: "",
74
74
  // String vacío para modo controlado
75
75
  Number: null,
@@ -85,12 +85,12 @@ const Nt = Rt({
85
85
  Attachments: [],
86
86
  MultiChoice: []
87
87
  // Default value for MultiChoice fields (array for multiple selections)
88
- }, kt = [
88
+ }, Wt = [
89
89
  "value",
90
90
  "selectedOptions",
91
91
  "selectedDates",
92
92
  "files"
93
- ], Wt = {
93
+ ], Gt = {
94
94
  Text: "value",
95
95
  Number: "value",
96
96
  Choice: "selectedOptions",
@@ -102,19 +102,19 @@ const Nt = Rt({
102
102
  }, Ve = (s, S) => (
103
103
  // biome-ignore lint/complexity/useObjectHasOwn: el target de tsconfig es < es2022 y Object.hasOwn no está disponible
104
104
  Object.prototype.hasOwnProperty.call(s, S)
105
- ), Gt = (s, S, E) => {
106
- const D = { ...S }, g = Wt[s], b = kt.filter(
107
- (y) => y !== g && y in D
105
+ ), zt = (s, S, E) => {
106
+ const O = { ...S }, g = Gt[s], b = Wt.filter(
107
+ (y) => y !== g && y in O
108
108
  );
109
109
  if (b.length > 0) {
110
110
  for (const y of b)
111
- delete D[y];
111
+ delete O[y];
112
112
  console.warn(
113
113
  `updateField recibió keys de valor incompatibles para '${E}' (${s}): ${b.join(", ")}. Se ignoraron y solo se permite '${g}'.`
114
114
  );
115
115
  }
116
- return D;
117
- }, zt = (s) => !(Ve(s, "validationState") || Ve(s, "validationMessage")) || Ve(s, "validationMessageIcon") ? s : {
116
+ return O;
117
+ }, Ht = (s) => !(Ve(s, "validationState") || Ve(s, "validationMessage")) || Ve(s, "validationMessageIcon") ? s : {
118
118
  ...s,
119
119
  validationMessageIcon: void 0
120
120
  }, Ze = (s) => {
@@ -123,34 +123,34 @@ const Nt = Rt({
123
123
  case "Note":
124
124
  case "Boolean":
125
125
  case "Number":
126
- return s.value !== void 0 ? s.value : "defaultValue" in s && s.defaultValue !== void 0 ? s.defaultValue : X[s.typeAsString];
126
+ return s.value !== void 0 ? s.value : "defaultValue" in s && s.defaultValue !== void 0 ? s.defaultValue : Z[s.typeAsString];
127
127
  case "Choice":
128
128
  case "MultiChoice":
129
- return "selectedOptions" in s && s.selectedOptions !== void 0 ? s.selectedOptions : "defaultSelectedOptions" in s && s.defaultSelectedOptions !== void 0 ? s.defaultSelectedOptions : X[s.typeAsString];
129
+ return "selectedOptions" in s && s.selectedOptions !== void 0 ? s.selectedOptions : "defaultSelectedOptions" in s && s.defaultSelectedOptions !== void 0 ? s.defaultSelectedOptions : Z[s.typeAsString];
130
130
  case "Date":
131
- return "selectedDates" in s && s.selectedDates !== void 0 ? s.selectedDates : "defaultSelectedDates" in s && s.defaultSelectedDates !== void 0 ? s.defaultSelectedDates : X[s.typeAsString];
131
+ return "selectedDates" in s && s.selectedDates !== void 0 ? s.selectedDates : "defaultSelectedDates" in s && s.defaultSelectedDates !== void 0 ? s.defaultSelectedDates : Z[s.typeAsString];
132
132
  case "Attachments":
133
- return "files" in s && s.files !== void 0 ? s.files : "defaultFiles" in s && s.defaultFiles !== void 0 ? s.defaultFiles : X[s.typeAsString];
133
+ return "files" in s && s.files !== void 0 ? s.files : "defaultFiles" in s && s.defaultFiles !== void 0 ? s.defaultFiles : Z[s.typeAsString];
134
134
  default: {
135
- const S = s.typeAsString, E = S ? X[S] : void 0;
135
+ const S = s.typeAsString, E = S ? Z[S] : void 0;
136
136
  return E !== void 0 ? E : void 0;
137
137
  }
138
138
  }
139
139
  }, et = (s, S, E) => {
140
- const D = S.current;
140
+ const O = S.current;
141
141
  let g = !1;
142
- const b = /* @__PURE__ */ new Set([...Object.keys(D), ...Object.keys(s)]);
142
+ const b = /* @__PURE__ */ new Set([...Object.keys(O), ...Object.keys(s)]);
143
143
  for (const y of b)
144
- if (!Object.is(D[y], s[y])) {
144
+ if (!Object.is(O[y], s[y])) {
145
145
  g = !0;
146
146
  break;
147
147
  }
148
148
  return g && (E.current += 1, S.current = { ...s }), E.current;
149
- }, rr = (s) => {
149
+ }, nr = (s) => {
150
150
  const {
151
151
  title: S,
152
152
  description: E,
153
- hidden: D = !1,
153
+ hidden: O = !1,
154
154
  editable: g = !0,
155
155
  disabled: b = !1,
156
156
  fields: y = [],
@@ -160,31 +160,31 @@ const Nt = Rt({
160
160
  className: rt = "",
161
161
  header: nt,
162
162
  footer: st,
163
- children: it,
164
- gridTemplateColumns: at = 1,
165
- gridTemplateGap: Z = 16,
166
- defaultValues: N = {},
167
- values: O,
163
+ children: at,
164
+ gridTemplateColumns: it = 1,
165
+ gridTemplateGap: ee = 16,
166
+ defaultValues: $ = {},
167
+ values: R,
168
168
  sections: x = [],
169
169
  messages: ot = [],
170
- fieldAnimationConfig: Ae = Bt,
171
- onInit: le,
170
+ fieldAnimationConfig: Ae = _t,
171
+ onInit: de,
172
172
  formRef: K,
173
173
  localeText: Te
174
- } = s, Ce = L(() => {
174
+ } = s, Ce = D(() => {
175
175
  const {
176
176
  fields: e,
177
177
  buttons: t,
178
178
  ...r
179
- } = Te ?? {}, i = Object.keys(r).length > 0 ? r : void 0, n = e || t ? {
179
+ } = Te ?? {}, a = Object.keys(r).length > 0 ? r : void 0, n = e || t ? {
180
180
  ...e ? { fields: e } : {},
181
181
  ...t ? { buttons: t } : {}
182
182
  } : void 0;
183
183
  return {
184
- formOverrides: i,
184
+ formOverrides: a,
185
185
  i18nProviderLocale: n
186
186
  };
187
- }, [Te]), Y = Pt(Ce.formOverrides), De = Ce.i18nProviderLocale;
187
+ }, [Te]), Y = Nt(Ce.formOverrides), De = Ce.i18nProviderLocale;
188
188
  if (y.length > 0 && x.length > 0)
189
189
  throw console.error(
190
190
  'EFWForm: No se pueden usar "fields" y "sections" al mismo tiempo. Use solo uno de ellos.'
@@ -194,13 +194,13 @@ const Nt = Rt({
194
194
  y.length === 0 && x.length === 0 && console.warn(
195
195
  'EFWForm: No se han proporcionado "fields" ni "sections". El formulario estará vacío.'
196
196
  );
197
- const ct = Nt(), c = L(() => y.length > 0 ? [...y] : x.length > 0 ? x.flatMap((e) => e.fields) : [], [y, x]), I = L(() => {
197
+ const ct = qt(), c = D(() => y.length > 0 ? [...y] : x.length > 0 ? x.flatMap((e) => e.fields) : [], [y, x]), I = D(() => {
198
198
  const e = /* @__PURE__ */ new Set(), t = /* @__PURE__ */ new Set();
199
199
  return c.forEach((r) => {
200
- const i = r.internalName;
201
- r.editable === void 0 && e.add(i), r.disabled === void 0 && t.add(i);
200
+ const a = r.internalName;
201
+ r.editable === void 0 && e.add(a), r.disabled === void 0 && t.add(a);
202
202
  }), { editable: e, disabled: t };
203
- }, [c]), de = L(
203
+ }, [c]), J = D(
204
204
  () => c.map((e) => {
205
205
  const t = e.editable === void 0 && g !== !0, r = e.disabled === void 0 && b !== !1;
206
206
  return !t && !r ? e : {
@@ -210,25 +210,30 @@ const Nt = Rt({
210
210
  };
211
211
  }),
212
212
  [c, g, b]
213
- ), ee = L(() => {
213
+ ), lt = D(() => {
214
+ const e = /* @__PURE__ */ new Map();
215
+ for (const t of J)
216
+ e.set(t.internalName, t);
217
+ return e;
218
+ }, [J]), te = D(() => {
214
219
  const e = {};
215
220
  for (const t of c)
216
221
  e[t.internalName] = Ze(t);
217
222
  return e;
218
- }, [c]), J = L(
223
+ }, [c]), Q = D(
219
224
  () => ({
220
- ...ee,
221
- ...N
225
+ ...te,
226
+ ...$
222
227
  }),
223
- [ee, N]
224
- ), q = O !== void 0, lt = L(() => q ? {
225
- ...J,
226
- ...O
227
- } : J, [q, J, O]), Oe = L(
228
+ [te, $]
229
+ ), q = R !== void 0, dt = D(() => q ? {
230
+ ...Q,
231
+ ...R
232
+ } : Q, [q, Q, R]), Oe = D(
228
233
  () => c.map((e) => `${e.internalName}::${e.id ?? "no-id"}`).join("|"),
229
234
  [c]
230
- ), U = o(null), [dt, Re] = He(!le), [ut, ft] = He({}), u = o(lt), m = o(null);
231
- m.current === null && (m.current = de.reduce(
235
+ ), U = o(null), [ut, Re] = He(!de), [ft, pt] = He({}), u = o(dt), m = o(null);
236
+ m.current === null && (m.current = J.reduce(
232
237
  (e, t) => (e[t.internalName] = {
233
238
  disabled: !1,
234
239
  editable: !0,
@@ -249,12 +254,12 @@ const Nt = Rt({
249
254
  required: t.required ?? !1
250
255
  }, e),
251
256
  {}
252
- )), oe(() => {
257
+ )), ce(() => {
253
258
  const e = new Set(Object.keys(m.current)), t = new Set(c.map((r) => r.internalName));
254
259
  e.forEach((r) => {
255
- t.has(r) || (delete m.current[r], delete B.current[r], delete R.current[r]);
260
+ t.has(r) || (delete m.current[r], delete B.current[r], delete w.current[r]);
256
261
  }), c.forEach((r) => {
257
- const i = r.editable ?? g, n = r.disabled ?? b, a = r.hidden ?? !1, f = r.required ?? !1, l = B.current[r.internalName];
262
+ const a = r.editable ?? g, n = r.disabled ?? b, i = r.hidden ?? !1, f = r.required ?? !1, l = B.current[r.internalName];
258
263
  if (!e.has(r.internalName)) {
259
264
  m.current[r.internalName] = {
260
265
  hidden: !1,
@@ -262,12 +267,12 @@ const Nt = Rt({
262
267
  validationState: "none",
263
268
  validationMessage: "",
264
269
  ...r,
265
- editable: i,
270
+ editable: a,
266
271
  disabled: n
267
272
  }, B.current[r.internalName] = {
268
- editable: i,
273
+ editable: a,
269
274
  disabled: n,
270
- hidden: a,
275
+ hidden: i,
271
276
  required: f
272
277
  };
273
278
  return;
@@ -275,52 +280,52 @@ const Nt = Rt({
275
280
  const V = m.current[r.internalName];
276
281
  if (!V) {
277
282
  B.current[r.internalName] = {
278
- editable: i,
283
+ editable: a,
279
284
  disabled: n,
280
- hidden: a,
285
+ hidden: i,
281
286
  required: f
282
287
  };
283
288
  return;
284
289
  }
285
- (!l || l.editable !== i || l.disabled !== n || l.hidden !== a || l.required !== f) && (m.current[r.internalName] = {
290
+ (!l || l.editable !== a || l.disabled !== n || l.hidden !== i || l.required !== f) && (m.current[r.internalName] = {
286
291
  ...V,
287
- editable: i,
292
+ editable: a,
288
293
  disabled: n,
289
- hidden: a,
294
+ hidden: i,
290
295
  required: f
291
296
  }), B.current[r.internalName] = {
292
- editable: i,
297
+ editable: a,
293
298
  disabled: n,
294
- hidden: a,
299
+ hidden: i,
295
300
  required: f
296
301
  };
297
302
  });
298
303
  }, [c, g, b]);
299
- const R = o({}), ue = o(!1), fe = o(/* @__PURE__ */ new Set()), pt = o({}), k = o(null);
300
- k.current === null && (k.current = de.reduce(
304
+ const w = o({}), ue = o(!1), fe = o(/* @__PURE__ */ new Set()), gt = o({}), k = o(null);
305
+ k.current === null && (k.current = J.reduce(
301
306
  (e, t) => (e[t.internalName] = {
302
307
  validationState: t.validationState || "none",
303
308
  validationMessage: t.validationMessage || ""
304
309
  }, e),
305
310
  {}
306
311
  ));
307
- const pe = o(""), te = o(!1), gt = o({
308
- ...ee
309
- }), mt = o(0), ge = et(
310
- ee,
311
- gt,
312
- mt
313
- ), Le = o(N), W = o(j), we = o(le), me = o(Ae), re = o({}), xe = o(!1);
314
- oe(() => {
315
- Le.current = N;
316
- }, [N]), W.current = j, we.current = le, me.current = Ae;
317
- const vt = o({
318
- ...N
319
- }), ht = o(0), ve = et(
320
- N,
321
- vt,
322
- ht
323
- ), he = `${ge}:${ve}`, be = o(""), G = L(
312
+ const pe = o(""), re = o(!1), mt = o({
313
+ ...te
314
+ }), vt = o(0), ge = et(
315
+ te,
316
+ mt,
317
+ vt
318
+ ), we = o($), W = o(j), Le = o(de), me = o(Ae), ne = o({}), xe = o(!1);
319
+ ce(() => {
320
+ we.current = $;
321
+ }, [$]), W.current = j, Le.current = de, me.current = Ae;
322
+ const ht = o({
323
+ ...$
324
+ }), bt = o(0), ve = et(
325
+ $,
326
+ ht,
327
+ bt
328
+ ), he = `${ge}:${ve}`, be = o(""), G = D(
324
329
  () => new Map(
325
330
  c.map((e) => [
326
331
  e.internalName,
@@ -330,7 +335,7 @@ const Nt = Rt({
330
335
  [c]
331
336
  ), Ie = o(G);
332
337
  Ie.current = G;
333
- const bt = p(
338
+ const St = p(
334
339
  (e, t) => {
335
340
  k.current[e] = {
336
341
  validationState: t.currentValidationState,
@@ -342,20 +347,20 @@ const Nt = Rt({
342
347
  };
343
348
  },
344
349
  []
345
- ), ne = p(
350
+ ), se = p(
346
351
  (e, t = "internal") => {
347
352
  U.current && U.current.addMessageBar(e, t);
348
353
  },
349
354
  []
350
- ), se = p((e) => {
355
+ ), ae = p((e) => {
351
356
  U.current && U.current.removeMessageBar(e);
352
357
  }, []), Pe = p(() => {
353
358
  U.current && U.current.removeAllMessagesBar();
354
- }, []), $e = o(Me);
355
- $e.current = Me;
359
+ }, []), Ne = o(Me);
360
+ Ne.current = Me;
356
361
  const ie = p(() => {
357
- $e.current?.({ ...u.current });
358
- }, []), Q = p(
362
+ Ne.current?.({ ...u.current });
363
+ }, []), X = p(
359
364
  (e, t) => {
360
365
  const r = Fe.current;
361
366
  r?.(e, t);
@@ -363,10 +368,10 @@ const Nt = Rt({
363
368
  []
364
369
  ), z = p(
365
370
  (e, t) => {
366
- const r = k.current[e], i = re.current[e];
367
- if (!(i !== void 0 && r?.validationState === "error" && r?.validationMessage === i)) return;
368
- const a = Ie.current.get(e);
369
- a && (Xe(t, a.typeAsString) || (Q(e, {
371
+ const r = k.current[e], a = ne.current[e];
372
+ if (!(a !== void 0 && r?.validationState === "error" && r?.validationMessage === a)) return;
373
+ const i = Ie.current.get(e);
374
+ i && (Xe(t, i.typeAsString) || (X(e, {
370
375
  validationState: "none",
371
376
  validationMessage: ""
372
377
  }), k.current[e] = {
@@ -376,29 +381,29 @@ const Nt = Rt({
376
381
  ...m.current[e],
377
382
  validationState: "none",
378
383
  validationMessage: ""
379
- }, delete re.current[e]));
384
+ }, delete ne.current[e]));
380
385
  },
381
- [Q]
382
- ), St = p(
386
+ [X]
387
+ ), Ft = p(
383
388
  (e, t, r) => {
384
389
  u.current[e] = t, !r?.silent && (z(e, t), ue.current || (ue.current = !0, ie(), ue.current = !1));
385
390
  },
386
391
  [ie, z]
387
- ), Ft = p(
392
+ ), yt = p(
388
393
  (e, t) => {
389
- R.current[e] = t;
394
+ w.current[e] = t;
390
395
  },
391
396
  []
392
- ), yt = p(
397
+ ), Et = p(
393
398
  (e, t) => {
394
- R.current[e] === t && delete R.current[e];
399
+ w.current[e] === t && delete w.current[e];
395
400
  },
396
401
  []
397
402
  ), A = p(
398
403
  (e, t) => {
399
- const r = Array.isArray(e) ? e : [e], i = (n) => {
400
- const a = R.current[n];
401
- if (!a) {
404
+ const r = Array.isArray(e) ? e : [e], a = (n) => {
405
+ const i = w.current[n];
406
+ if (!i) {
402
407
  console.warn(
403
408
  `No se encontró un campo registrado para '${String(n)}'`
404
409
  );
@@ -411,49 +416,49 @@ const Nt = Rt({
411
416
  );
412
417
  return;
413
418
  }
414
- const l = f.typeAsString, V = Gt(
419
+ const l = f.typeAsString, V = zt(
415
420
  l,
416
421
  t,
417
422
  String(n)
418
- ), F = zt(V);
419
- a(F);
423
+ ), F = Ht(V);
424
+ i(F);
420
425
  const {
421
426
  value: v,
422
427
  selectedOptions: M,
423
428
  selectedDates: d,
424
429
  files: h,
425
- ...$
430
+ ...N
426
431
  } = F;
427
- Object.keys($).length > 0 && (m.current[n] = {
432
+ Object.keys(N).length > 0 && (m.current[n] = {
428
433
  ...m.current[n],
429
- ...$
434
+ ...N
430
435
  });
431
- const H = W.current, T = (Ct, Dt, Ot = "change") => {
436
+ const H = W.current, T = (Dt, Ot, Rt = "change") => {
432
437
  const Ge = H?.[n];
433
438
  if (!Ge)
434
439
  return;
435
- const ae = String(n);
436
- if (fe.current.has(ae)) {
440
+ const oe = String(n);
441
+ if (fe.current.has(oe)) {
437
442
  console.warn(
438
- `Se detectó una actualización en cascada cíclica sobre el campo '${ae}'. Se omite la re-ejecución de su fieldLogic para evitar recursión infinita; revisa que la lógica del campo no se actualice a sí misma de forma indefinida.`
443
+ `Se detectó una actualización en cascada cíclica sobre el campo '${oe}'. Se omite la re-ejecución de su fieldLogic para evitar recursión infinita; revisa que la lógica del campo no se actualice a sí misma de forma indefinida.`
439
444
  );
440
445
  return;
441
446
  }
442
- fe.current.add(ae);
447
+ fe.current.add(oe);
443
448
  try {
444
449
  Ge(
445
- Ct,
450
+ Dt,
446
451
  A,
447
452
  {
448
453
  allValues: u.current,
449
- trigger: Ot,
454
+ trigger: Rt,
450
455
  fieldName: n,
451
- previousValue: Dt,
456
+ previousValue: Ot,
452
457
  isControlled: q
453
458
  }
454
459
  );
455
460
  } finally {
456
- fe.current.delete(ae);
461
+ fe.current.delete(oe);
457
462
  }
458
463
  }, C = u.current[n];
459
464
  switch (l) {
@@ -486,38 +491,38 @@ const Nt = Rt({
486
491
  default:
487
492
  console.warn(`Tipo de campo desconocido: ${l}`);
488
493
  }
489
- const At = v !== void 0 || M !== void 0 || d !== void 0 || h !== void 0, Tt = "validationState" in F || "validationMessage" in F;
490
- At && !Tt && z(
494
+ const Tt = v !== void 0 || M !== void 0 || d !== void 0 || h !== void 0, Ct = "validationState" in F || "validationMessage" in F;
495
+ Tt && !Ct && z(
491
496
  n,
492
497
  u.current[n]
493
498
  );
494
499
  };
495
500
  for (const n of r)
496
- i(n);
501
+ a(n);
497
502
  },
498
503
  [G, q, z]
499
- ), Se = L(() => {
504
+ ), Se = D(() => {
500
505
  const e = Array.from(I.editable).sort().join("|"), t = Array.from(I.disabled).sort().join("|");
501
506
  return `${e}::${t}`;
502
- }, [I]), Ne = o(
507
+ }, [I]), $e = o(
503
508
  `${g}::${b}::${Se}`
504
509
  );
505
- ce(() => {
510
+ le(() => {
506
511
  const e = `${g}::${b}::${Se}`;
507
- if (Ne.current === e)
512
+ if ($e.current === e)
508
513
  return;
509
- Ne.current = e, (/* @__PURE__ */ new Set([
514
+ $e.current = e, (/* @__PURE__ */ new Set([
510
515
  ...I.editable,
511
516
  ...I.disabled
512
517
  ])).forEach((r) => {
513
- const i = m.current[r];
514
- if (!i)
518
+ const a = m.current[r];
519
+ if (!a)
515
520
  return;
516
- let n = i.editable, a = i.disabled, f = !1;
517
- I.editable.has(r) && i.editable !== g && (n = g, f = !0), I.disabled.has(r) && i.disabled !== b && (a = b, f = !0), f && (m.current[r] = {
518
- ...i,
521
+ let n = a.editable, i = a.disabled, f = !1;
522
+ I.editable.has(r) && a.editable !== g && (n = g, f = !0), I.disabled.has(r) && a.disabled !== b && (i = b, f = !0), f && (m.current[r] = {
523
+ ...a,
519
524
  editable: n,
520
- disabled: a
525
+ disabled: i
521
526
  });
522
527
  });
523
528
  }, [
@@ -533,11 +538,11 @@ const Nt = Rt({
533
538
  const r = W.current;
534
539
  if (!r)
535
540
  return;
536
- const i = e && e.length > 0 ? e : Object.keys(r);
537
- if (i.length === 0)
541
+ const a = e && e.length > 0 ? e : Object.keys(r);
542
+ if (a.length === 0)
538
543
  return;
539
- const n = r, { trigger: a = "change", previousValues: f, allValuesOverride: l } = t, V = l ?? u.current;
540
- i.forEach((F) => {
544
+ const n = r, { trigger: i = "change", previousValues: f, allValuesOverride: l } = t, V = l ?? u.current;
545
+ a.forEach((F) => {
541
546
  const v = n[F];
542
547
  if (!v)
543
548
  return;
@@ -547,7 +552,7 @@ const Nt = Rt({
547
552
  A,
548
553
  {
549
554
  allValues: V,
550
- trigger: a,
555
+ trigger: i,
551
556
  fieldName: F,
552
557
  previousValue: M,
553
558
  isControlled: q
@@ -556,7 +561,7 @@ const Nt = Rt({
556
561
  });
557
562
  },
558
563
  [A, q]
559
- ), Et = p(
564
+ ), Vt = p(
560
565
  (e) => W.current?.[e],
561
566
  []
562
567
  ), ye = p(
@@ -569,9 +574,9 @@ const Nt = Rt({
569
574
  overwriteAll: !1
570
575
  }, r) => {
571
576
  const {
572
- triggerOnChange: i = !0,
577
+ triggerOnChange: a = !0,
573
578
  triggerFieldLogic: n = !0,
574
- overwriteAll: a = !1,
579
+ overwriteAll: i = !1,
575
580
  force: f = !1
576
581
  } = t, l = t.animateUpdatedFields ?? r ?? me.current.setValues ?? !1, V = Object.keys(e), F = {}, v = [], M = f ? V : V.filter(
577
582
  (d) => !Object.is(
@@ -581,8 +586,8 @@ const Nt = Rt({
581
586
  );
582
587
  if (M.forEach((d) => {
583
588
  F[d] = u.current[d];
584
- }), !(M.length === 0 && !a)) {
585
- if (a)
589
+ }), !(M.length === 0 && !i)) {
590
+ if (i)
586
591
  u.current = {
587
592
  ...u.current,
588
593
  ...e
@@ -594,11 +599,11 @@ const Nt = Rt({
594
599
  }), u.current = d;
595
600
  }
596
601
  M.forEach((d) => {
597
- const h = R.current[d];
602
+ const h = w.current[d];
598
603
  if (h) {
599
- const $ = G.get(d);
600
- if ($) {
601
- const H = $.typeAsString, T = e[d];
604
+ const N = G.get(d);
605
+ if (N) {
606
+ const H = N.typeAsString, T = e[d];
602
607
  let C;
603
608
  switch (H) {
604
609
  case "Text":
@@ -624,17 +629,17 @@ const Nt = Rt({
624
629
  } else
625
630
  console.warn(`No se encontró la definición del campo: ${d}`);
626
631
  }
627
- }), v.length > 0 && ft((d) => {
632
+ }), v.length > 0 && pt((d) => {
628
633
  const h = { ...d };
629
- return v.forEach(($, H) => {
630
- h[$] = {
631
- delay: H * Ut,
632
- token: (h[$]?.token ?? 0) + 1
634
+ return v.forEach((N, H) => {
635
+ h[N] = {
636
+ delay: H * Bt,
637
+ token: (h[N]?.token ?? 0) + 1
633
638
  };
634
639
  }), h;
635
640
  }), n && M.length > 0 && _(M, {
636
641
  previousValues: F
637
- }), i && ie();
642
+ }), a && ie();
638
643
  }
639
644
  },
640
645
  [
@@ -644,13 +649,13 @@ const Nt = Rt({
644
649
  z
645
650
  ]
646
651
  );
647
- ce(() => {
648
- if (O !== void 0) {
652
+ le(() => {
653
+ if (R !== void 0) {
649
654
  be.current = "";
650
655
  return;
651
656
  }
652
657
  be.current !== he && (be.current = he, P(
653
- J,
658
+ Q,
654
659
  {
655
660
  overwriteAll: !0,
656
661
  triggerOnChange: !1,
@@ -658,30 +663,30 @@ const Nt = Rt({
658
663
  },
659
664
  !1
660
665
  ));
661
- }, [O, he, P, J]), ce(() => {
666
+ }, [R, he, P, Q]), le(() => {
662
667
  if (!W.current)
663
668
  return;
664
- if (O !== void 0) {
669
+ if (R !== void 0) {
665
670
  pe.current = "";
666
671
  return;
667
672
  }
668
673
  const e = `uncontrolled::${Oe}::${ge}::${ve}`;
669
674
  pe.current !== e && (pe.current = e, _(void 0, { trigger: "init" }));
670
675
  }, [
671
- O,
676
+ R,
672
677
  Oe,
673
678
  ge,
674
679
  ve,
675
680
  _
676
- ]), ce(() => {
677
- if (O === void 0) {
678
- te.current = !1;
681
+ ]), le(() => {
682
+ if (R === void 0) {
683
+ re.current = !1;
679
684
  return;
680
685
  }
681
- const e = u.current, t = O, i = Object.keys(t).filter(
686
+ const e = u.current, t = R, a = Object.keys(t).filter(
682
687
  (n) => e[n] !== t[n]
683
688
  );
684
- if (i.length > 0 && P(
689
+ if (a.length > 0 && P(
685
690
  t,
686
691
  {
687
692
  triggerOnChange: !1,
@@ -690,19 +695,19 @@ const Nt = Rt({
690
695
  },
691
696
  !1
692
697
  ), !W.current) {
693
- te.current = !0;
698
+ re.current = !0;
694
699
  return;
695
700
  }
696
- i.length > 0 ? _(i, { previousValues: e }) : te.current || _(void 0, { trigger: "init" }), te.current = !0;
697
- }, [O, P, _]);
701
+ a.length > 0 ? _(a, { previousValues: e }) : re.current || _(void 0, { trigger: "init" }), re.current = !0;
702
+ }, [R, P, _]);
698
703
  const qe = p(
699
704
  (e = {}) => {
700
705
  const r = {
701
706
  ...c.reduce(
702
- (i, n) => (i[n.internalName] = Ze(n), i),
707
+ (a, n) => (a[n.internalName] = Ze(n), a),
703
708
  {}
704
709
  ),
705
- ...Le.current
710
+ ...we.current
706
711
  };
707
712
  P(
708
713
  r,
@@ -716,30 +721,30 @@ const Nt = Rt({
716
721
  [c, P]
717
722
  ), Ue = p(
718
723
  (e, t) => {
719
- const r = t || c.map((n) => n.internalName), i = [];
724
+ const r = t || c.map((n) => n.internalName), a = [];
720
725
  return r.forEach((n) => {
721
- const a = m.current[n];
722
- if (!a) {
726
+ const i = m.current[n];
727
+ if (!i) {
723
728
  console.warn(`Field state not found for ${n}`);
724
729
  return;
725
730
  }
726
- const f = a.disabled ?? !1;
727
- e !== f && R.current[n] ? (A(n, { disabled: e }), i.push(n)) : R.current[n] || console.warn(`Field ${n} not found in fieldUpdateRefs`);
728
- }), i;
731
+ const f = i.disabled ?? !1;
732
+ e !== f && w.current[n] ? (A(n, { disabled: e }), a.push(n)) : w.current[n] || console.warn(`Field ${n} not found in fieldUpdateRefs`);
733
+ }), a;
729
734
  },
730
735
  [c, A]
731
736
  ), Be = p(
732
737
  (e, t) => {
733
- const r = t || c.map((n) => n.internalName), i = [];
738
+ const r = t || c.map((n) => n.internalName), a = [];
734
739
  return r.forEach((n) => {
735
- const a = m.current[n];
736
- if (!a) {
740
+ const i = m.current[n];
741
+ if (!i) {
737
742
  console.warn(`Field state not found for ${n}`);
738
743
  return;
739
744
  }
740
- const f = a.editable ?? !0;
741
- e !== f && R.current[n] ? (A(n, { editable: e }), i.push(n)) : R.current[n] || console.warn(`Field ${n} not found in fieldUpdateRefs`);
742
- }), i;
745
+ const f = i.editable ?? !0;
746
+ e !== f && w.current[n] ? (A(n, { editable: e }), a.push(n)) : w.current[n] || console.warn(`Field ${n} not found in fieldUpdateRefs`);
747
+ }), a;
743
748
  },
744
749
  [c, A]
745
750
  ), _e = p(() => c.every(
@@ -748,8 +753,8 @@ const Nt = Rt({
748
753
  (e) => m.current[e.internalName]?.editable === !0
749
754
  ), [c]), Ke = p(
750
755
  (e = !0) => {
751
- const t = "validacion__10000001", r = "error", i = Y.requiredFieldError, n = pt.current;
752
- let a = !0;
756
+ const t = "validacion__10000001", r = "error", a = Y.requiredFieldError, n = gt.current;
757
+ let i = !0;
753
758
  return c.forEach((f) => {
754
759
  const l = f.internalName, V = u.current[l], F = m.current[l], v = k.current[l];
755
760
  if (F?.hidden === !0)
@@ -759,26 +764,26 @@ const Nt = Rt({
759
764
  f.typeAsString
760
765
  );
761
766
  if (!F?.required && v?.validationState === "error") {
762
- a = !1;
767
+ i = !1;
763
768
  return;
764
769
  }
765
770
  if (F?.required)
766
771
  if (d)
767
- re.current[l] = i, (v?.validationState !== "error" || v?.validationMessage !== i) && (n[l] = {
772
+ ne.current[l] = a, (v?.validationState !== "error" || v?.validationMessage !== a) && (n[l] = {
768
773
  validationState: v?.validationState || "none",
769
774
  validationMessage: v?.validationMessage || ""
770
- }, Q(l, {
775
+ }, X(l, {
771
776
  validationState: r,
772
- validationMessage: i
773
- })), a = !1;
774
- else if (delete re.current[l], v?.validationState === "error" && v?.validationMessage === i) {
777
+ validationMessage: a
778
+ })), i = !1;
779
+ else if (delete ne.current[l], v?.validationState === "error" && v?.validationMessage === a) {
775
780
  const h = n[l];
776
- h && (Q(l, {
781
+ h && (X(l, {
777
782
  validationState: h.validationState,
778
783
  validationMessage: h.validationMessage
779
- }), h.validationState === "error" && (a = !1));
780
- } else v?.validationState === "error" && (a = !1);
781
- }), e && !a ? ne(
784
+ }), h.validationState === "error" && (i = !1));
785
+ } else v?.validationState === "error" && (i = !1);
786
+ }), e && !i ? se(
782
787
  {
783
788
  id: t,
784
789
  intent: "error",
@@ -786,15 +791,15 @@ const Nt = Rt({
786
791
  actions: []
787
792
  },
788
793
  "internal"
789
- ) : se(t), a;
794
+ ) : ae(t), i;
790
795
  },
791
796
  [
792
- ne,
797
+ se,
793
798
  c,
794
799
  Y.requiredFieldError,
795
800
  Y.requiredFieldsNotification,
796
- se,
797
- Q
801
+ ae,
802
+ X
798
803
  ]
799
804
  ), Ee = o({
800
805
  getValues: () => u.current,
@@ -816,7 +821,7 @@ const Nt = Rt({
816
821
  updateField: () => {
817
822
  }
818
823
  });
819
- oe(() => (Ee.current = {
824
+ ce(() => (Ee.current = {
820
825
  getValues: ye,
821
826
  setValues: P,
822
827
  resetValues: qe,
@@ -825,8 +830,8 @@ const Nt = Rt({
825
830
  isDisabled: _e,
826
831
  isEditable: je,
827
832
  validateForm: Ke,
828
- addMessageBar: ne,
829
- removeMessageBar: se,
833
+ addMessageBar: se,
834
+ removeMessageBar: ae,
830
835
  removeAllMessagesBar: Pe,
831
836
  updateField: A
832
837
  }, K && (K.current = Ee.current), () => {
@@ -839,17 +844,17 @@ const Nt = Rt({
839
844
  _e,
840
845
  Ke,
841
846
  K,
842
- ne,
843
847
  se,
848
+ ae,
844
849
  Pe,
845
850
  Be,
846
851
  je,
847
852
  A
848
- ]), oe(() => {
853
+ ]), ce(() => {
849
854
  if (xe.current)
850
855
  return;
851
856
  xe.current = !0;
852
- const e = we.current;
857
+ const e = Le.current;
853
858
  if (e) {
854
859
  const t = e(
855
860
  u.current,
@@ -858,27 +863,27 @@ const Nt = Rt({
858
863
  t instanceof Promise ? t.catch((r) => console.error("Error en onInit:", r)).finally(() => Re(!0)) : Re(!0);
859
864
  }
860
865
  }, []);
861
- const Vt = (e) => {
862
- const t = e.internalName, r = u.current[t], i = ut[t];
863
- return /* @__PURE__ */ w(
864
- Kt,
866
+ const Mt = (e) => {
867
+ const t = e.internalName, r = u.current[t], a = ft[t];
868
+ return /* @__PURE__ */ L(
869
+ kt,
865
870
  {
866
871
  className: ct.efwFormFieldWrapper,
867
- animationDelay: i?.delay,
868
- animationToken: i?.token,
869
- children: /* @__PURE__ */ w(
870
- xt,
872
+ animationDelay: a?.delay,
873
+ animationToken: a?.token,
874
+ children: /* @__PURE__ */ L(
875
+ It,
871
876
  {
872
877
  field: e,
873
878
  initialValue: r,
874
- onValueChange: St,
875
- registerUpdateProps: Ft,
876
- unregisterUpdateProps: yt,
877
- getFieldLogicByName: Et,
879
+ onValueChange: Ft,
880
+ registerUpdateProps: yt,
881
+ unregisterUpdateProps: Et,
882
+ getFieldLogicByName: Vt,
878
883
  isControlled: q,
879
884
  getAllValues: ye,
880
885
  updateFieldProps: A,
881
- onValidationChange: bt,
886
+ onValidationChange: St,
882
887
  localeText: Y
883
888
  }
884
889
  )
@@ -886,68 +891,73 @@ const Nt = Rt({
886
891
  e.id
887
892
  );
888
893
  }, ke = (e, t = 1) => {
889
- const r = wt(t);
890
- return /* @__PURE__ */ w(
894
+ const r = xt(t);
895
+ return /* @__PURE__ */ L(
891
896
  "div",
892
897
  {
893
898
  style: {
894
899
  display: "grid",
895
900
  gridTemplateColumns: r,
896
- gap: Z,
897
- margin: `${Z}px 0px 0px`
901
+ gap: ee,
902
+ margin: `${ee}px 0px 0px`
898
903
  },
899
- children: e.map(Vt)
904
+ children: e.map(Mt)
900
905
  }
901
906
  );
902
- }, Mt = Lt(rt, "efw-form");
903
- if (D) return null;
907
+ }, At = Lt(rt, "efw-form");
908
+ if (O) return null;
904
909
  const We = /* @__PURE__ */ ze(
905
910
  "div",
906
911
  {
907
912
  style: {
908
913
  ...tt,
909
- ...dt ? {} : { visibility: "hidden" }
914
+ ...ut ? {} : { visibility: "hidden" }
910
915
  },
911
- className: Mt,
916
+ className: At,
912
917
  children: [
913
918
  nt,
914
- S && /* @__PURE__ */ w(Ye, { style: { marginTop: 12 }, block: !0, children: S }),
915
- E && /* @__PURE__ */ w(Je, { block: !0, as: "p", children: E }),
919
+ S && /* @__PURE__ */ L(Ye, { style: { marginTop: 12 }, block: !0, children: S }),
920
+ E && /* @__PURE__ */ L(Je, { block: !0, as: "p", children: E }),
916
921
  x && x.length > 0 ? x.map((e, t) => /* @__PURE__ */ ze("div", { children: [
917
- e.title && /* @__PURE__ */ w(
922
+ e.title && /* @__PURE__ */ L(
918
923
  Ye,
919
924
  {
920
- style: { marginTop: Z * (t > 0 ? 2 : 1) },
925
+ style: { marginTop: ee * (t > 0 ? 2 : 1) },
921
926
  block: !0,
922
927
  children: e.title
923
928
  }
924
929
  ),
925
- e.description && /* @__PURE__ */ w(
930
+ e.description && /* @__PURE__ */ L(
926
931
  Je,
927
932
  {
928
933
  block: !0,
929
934
  as: "p",
930
- style: e.title ? {} : { marginTop: Z * (t > 0 ? 2 : 1) },
935
+ style: e.title ? {} : { marginTop: ee * (t > 0 ? 2 : 1) },
931
936
  children: e.description
932
937
  }
933
938
  ),
934
- ke(e.fields, e.gridTemplateColumns)
935
- ] }, e.fields[0]?.internalName ?? `section-${t}`)) : ke(de, at),
936
- /* @__PURE__ */ w(
937
- It,
939
+ ke(
940
+ e.fields.map(
941
+ (r) => lt.get(r.internalName) ?? r
942
+ ),
943
+ e.gridTemplateColumns
944
+ )
945
+ ] }, e.fields[0]?.internalName ?? `section-${t}`)) : ke(J, it),
946
+ /* @__PURE__ */ L(
947
+ Pt,
938
948
  {
939
949
  style: { marginTop: "22px" },
940
950
  initialExternalMessages: ot,
941
951
  ref: U
942
952
  }
943
953
  ),
944
- it,
954
+ at,
945
955
  st
946
956
  ]
947
957
  }
948
958
  );
949
- return De ? /* @__PURE__ */ w($t, { localeText: De, children: We }) : We;
959
+ return De ? /* @__PURE__ */ L($t, { localeText: De, children: We }) : We;
950
960
  };
951
961
  export {
952
- rr as EFWForm
962
+ nr as EFWForm
953
963
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@envisiongroup/porygon",
3
- "version": "1.0.2",
3
+ "version": "1.0.3",
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",