@envisiongroup/porygon 0.1.0-rc.2 → 0.1.0-rc.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.
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,11 +1,11 @@
1
- import { jsxs as x, jsx as r } from "react/jsx-runtime";
2
- import { makeStyles as k, mergeClasses as B, CardFooter as N, Button as j, Text as M } from "@fluentui/react-components";
3
- import { useId as V, useRef as $, useState as T, useEffect as F, useCallback as m } from "react";
4
- import { EFWAttachmentsContainer as q } from "./EFWAttachmentsCard/EFWAttachmentsCard.js";
5
- import { Attach20Regular as D } from "@fluentui/react-icons";
6
- import { formatFileSize as I } from "../../commons/utils.js";
7
- import { v4 as P } from "uuid";
8
- const G = k({
1
+ import { jsxs as C, jsx as r } from "react/jsx-runtime";
2
+ import { makeStyles as j, mergeClasses as $, CardFooter as V, Button as D, Text as T } from "@fluentui/react-components";
3
+ import { useId as q, useRef as I, useMemo as P, useState as U, useEffect as S, useCallback as d } from "react";
4
+ import { EFWAttachmentsContainer as G } from "./EFWAttachmentsCard/EFWAttachmentsCard.js";
5
+ import { Attach20Regular as H } from "@fluentui/react-icons";
6
+ import { formatFileSize as J } from "../../commons/utils.js";
7
+ import { v4 as K } from "uuid";
8
+ const L = j({
9
9
  efwAttachmentError: {
10
10
  //...
11
11
  },
@@ -18,101 +18,102 @@ const G = k({
18
18
  efwAttachmentsContainer: {
19
19
  display: "flex"
20
20
  }
21
- }), X = (g) => {
21
+ }), te = (w) => {
22
22
  const {
23
- editable: d = !0,
24
- disabled: o = !1,
25
- files: f = [],
26
- className: S = "",
27
- validationState: w = "none",
28
- setParentComponentState: l,
29
- multiple: u = !0,
30
- acceptedTypes: C = "*/*",
31
- maxFileSize: c = 100 * 1024 * 1024,
23
+ editable: f = !0,
24
+ disabled: i = !1,
25
+ files: y,
26
+ defaultFiles: u,
27
+ className: z = "",
28
+ validationState: E = "none",
29
+ setParentComponentState: c,
30
+ multiple: h = !0,
31
+ acceptedTypes: R = "*/*",
32
+ maxFileSize: m = 100 * 1024 * 1024,
32
33
  // 100MB por defecto
33
34
  onChange: a,
34
- onRemoveAttachment: h
35
- } = g, z = V(), p = G(), i = $(null), [t, A] = T(f);
36
- F(() => {
37
- A(f);
38
- }, [f]);
39
- const y = m((n) => {
40
- for (const s of n)
41
- if (s.size !== void 0 && s.size > c)
35
+ onRemoveAttachment: p
36
+ } = w, b = q(), A = L(), l = I(null), s = y !== void 0, F = P(() => u ?? [], [u]), [W, v] = U(() => u ?? []), t = s ? y ?? [] : W;
37
+ S(() => {
38
+ s || v(F);
39
+ }, [s, F]);
40
+ const x = d((n) => {
41
+ for (const o of n)
42
+ if (o.size !== void 0 && o.size > m)
42
43
  return !1;
43
44
  return !0;
44
- }, [c]);
45
- F(() => {
46
- t.length > 0 ? y(t) ? l?.("none") : l?.("error", `Existe un adjunto que excede el peso máximo de ${I(c)}.`) : l?.("none");
47
- }, [t, y, l, c]);
48
- const E = m(() => {
49
- i.current && !o && i.current.click();
50
- }, [o]), R = m(async (n) => {
51
- const s = t.find((e) => e.id === n);
52
- if (!s) {
45
+ }, [m]);
46
+ S(() => {
47
+ t.length > 0 ? x(t) ? c?.("none") : c?.("error", `Existe un adjunto que excede el peso máximo de ${J(m)}.`) : c?.("none");
48
+ }, [t, x, c, m]);
49
+ const k = d(() => {
50
+ l.current && !i && l.current.click();
51
+ }, [i]), B = d(async (n) => {
52
+ const o = t.find((e) => e.id === n);
53
+ if (!o) {
53
54
  console.warn(`[EFWAttachment]: Attachment with id ${n} not found`);
54
55
  return;
55
56
  }
56
57
  try {
57
- if (h && !await h(s)) {
58
+ if (p && !await p(o)) {
58
59
  console.log(`[EFWAttachment]: Removal of file ${n} was cancelled`);
59
60
  return;
60
61
  }
61
- const e = t.filter((v) => v.id !== n);
62
- A(e), a && a(e), console.log(`[EFWAttachment]: File ${n} removed successfully`);
62
+ const e = t.filter((g) => g.id !== n);
63
+ s || v(e), a && a(e), console.log(`[EFWAttachment]: File ${n} removed successfully`);
63
64
  } catch (e) {
64
65
  console.error("[EFWAttachment]: Detele file error:", e);
65
66
  }
66
- }, [t, h, a]), b = m((n) => {
67
- const s = Array.from(n.target.files || []).map((e) => ({
68
- id: P(),
67
+ }, [t, p, a, s]), M = d((n) => {
68
+ const o = Array.from(n.target.files || []).map((e) => ({
69
+ id: K(),
69
70
  name: e.name,
70
71
  size: e.size,
71
72
  type: e.type,
72
73
  lastModified: e.lastModified,
73
74
  file: e
74
75
  }));
75
- if (s.length > 0) {
76
- const e = u ? [...t, ...s] : s;
77
- A(e), a?.(e);
76
+ if (o.length > 0) {
77
+ const e = h ? [...t, ...o] : o;
78
+ s || v(e), a?.(e);
78
79
  }
79
- i.current && (i.current.value = "");
80
- }, [t, u, a]), W = B(
81
- S,
82
- w === "error" && p.efwAttachmentError
80
+ l.current && (l.current.value = "");
81
+ }, [t, h, a, s]), N = $(
82
+ z,
83
+ E === "error" && A.efwAttachmentError
83
84
  );
84
- return /* @__PURE__ */ x("div", { className: W, children: [
85
- d && /* @__PURE__ */ x(N, { style: { display: "disabled" }, children: [
85
+ return /* @__PURE__ */ C("div", { className: N, children: [
86
+ f && /* @__PURE__ */ C(V, { style: { display: "disabled" }, children: [
86
87
  /* @__PURE__ */ r(
87
88
  "input",
88
89
  {
89
- ref: i,
90
- id: z,
90
+ ref: l,
91
+ id: b,
91
92
  type: "file",
92
- className: p.efwAttachmentInput,
93
- accept: C,
94
- multiple: u,
95
- onChange: b,
96
- disabled: o
93
+ className: A.efwAttachmentInput,
94
+ accept: R,
95
+ multiple: h,
96
+ onChange: M,
97
+ disabled: i
97
98
  }
98
99
  ),
99
100
  /* @__PURE__ */ r(
100
- j,
101
+ D,
101
102
  {
102
103
  size: "medium",
103
- onClick: E,
104
- icon: /* @__PURE__ */ r(D, {}),
105
- disabled: o,
106
- className: p.efwAttachmentsButton,
104
+ onClick: k,
105
+ icon: /* @__PURE__ */ r(H, {}),
106
+ disabled: i,
107
+ className: A.efwAttachmentsButton,
107
108
  children: "Adjuntar archivos"
108
109
  }
109
110
  )
110
111
  ] }),
111
- !d && t.length === 0 ? /* @__PURE__ */ r(M, { style: { opacity: 0.7 }, children: "Sin archivos disponibles" }) : /* @__PURE__ */ r(
112
- q,
112
+ !f && t.length === 0 ? /* @__PURE__ */ r(T, { style: { opacity: 0.7 }, children: "Sin archivos disponibles" }) : /* @__PURE__ */ r(
113
+ G,
113
114
  {
114
- enableRemoveButtons: d && !o,
115
- onRemoveAttachment: R,
115
+ enableRemoveButtons: f && !i,
116
+ onRemoveAttachment: B,
116
117
  attachments: t,
117
118
  emptyMessage: "Sin archivos disponibles"
118
119
  }
@@ -120,5 +121,5 @@ const G = k({
120
121
  ] });
121
122
  };
122
123
  export {
123
- X as EFWAttachment
124
+ te as EFWAttachment
124
125
  };
@@ -33,10 +33,16 @@ export type EFWAttachmentsOnChange = (values: EFWAttachmentsValue[], displayValu
33
33
  */
34
34
  export interface EFWAttachmentsProps extends EFWFieldChildrenProps {
35
35
  /**
36
- * Lista inicial de archivos adjuntos
37
- * @default []
36
+ * Lista de archivos adjuntos controlada desde el componente padre.
37
+ * Cuando se define, el componente opera en modo controlled y renderiza exactamente
38
+ * los archivos proporcionados en esta propiedad.
38
39
  */
39
40
  files?: EFWAttachmentsValue[];
41
+ /**
42
+ * Lista inicial de archivos adjuntos en modo uncontrolled.
43
+ * Solo se usa durante el montaje cuando `files` no está definido.
44
+ */
45
+ defaultFiles?: EFWAttachmentsValue[];
40
46
  /**
41
47
  * Indica si el componente permite cargar o eliminar adjuntos
42
48
  * @default true
@@ -1,7 +1,7 @@
1
1
  import { jsx as t } from "react/jsx-runtime";
2
- import { EFWField as v } from "../EFWField/EFWField.js";
3
- import { EFWAttachment as A } from "../EFWAttachments/EFWAttachments.js";
4
- const L = (a) => {
2
+ import { EFWField as A } from "../EFWField/EFWField.js";
3
+ import { EFWAttachment as E } from "../EFWAttachments/EFWAttachments.js";
4
+ const j = (a) => {
5
5
  const {
6
6
  title: n,
7
7
  infoLabel: i,
@@ -13,15 +13,16 @@ const L = (a) => {
13
13
  disabled: h = !1,
14
14
  editable: e = !0,
15
15
  hidden: m = !1,
16
- files: c = [],
17
- multiple: f = !0,
18
- acceptedTypes: g = "*/*",
19
- onRemoveAttachment: p,
20
- onChange: u,
16
+ files: c,
17
+ defaultFiles: f,
18
+ multiple: g = !0,
19
+ acceptedTypes: p = "*/*",
20
+ onRemoveAttachment: u,
21
+ onChange: F,
21
22
  onValidationChange: b
22
23
  } = a;
23
24
  return /* @__PURE__ */ t(
24
- v,
25
+ A,
25
26
  {
26
27
  style: o,
27
28
  title: n,
@@ -34,22 +35,23 @@ const L = (a) => {
34
35
  validationMessage: s,
35
36
  onValidationChange: b,
36
37
  children: /* @__PURE__ */ t(
37
- A,
38
+ E,
38
39
  {
39
40
  files: c,
41
+ defaultFiles: f,
40
42
  editable: e,
41
- onChange: (C, F) => {
42
- u?.(C, F);
43
+ onChange: (C, v) => {
44
+ F?.(C, v);
43
45
  },
44
46
  disabled: h,
45
- multiple: f,
46
- acceptedTypes: g,
47
- onRemoveAttachment: p
47
+ multiple: g,
48
+ acceptedTypes: p,
49
+ onRemoveAttachment: u
48
50
  }
49
51
  )
50
52
  }
51
53
  );
52
54
  };
53
55
  export {
54
- L as EFWAttachmentsField
56
+ j as EFWAttachmentsField
55
57
  };
@@ -1,135 +1,114 @@
1
- import { jsx as D, Fragment as W } from "react/jsx-runtime";
2
- import { makeStyles as j, tokens as u, mergeClasses as q, Text as G } from "@fluentui/react-components";
3
- import { useId as U, useState as H, useRef as b, useEffect as J, useCallback as h } from "react";
4
- import { DatePicker as K } from "@fluentui/react-datepicker-compat";
5
- import { arraysAreEqual as O, esLocalizedStrings as F } from "./EFWDatePicker.utils.js";
6
- const Q = j({
1
+ import { jsx as h, Fragment as H } from "react/jsx-runtime";
2
+ import { makeStyles as J, tokens as l, mergeClasses as K, Text as O } from "@fluentui/react-components";
3
+ import { useId as Q, useMemo as y, useState as X, useRef as M, useCallback as D, useEffect as Z } from "react";
4
+ import { DatePicker as ee } from "@fluentui/react-datepicker-compat";
5
+ import { mapToValidDates as p, esLocalizedStrings as F } from "./EFWDatePicker.utils.js";
6
+ const C = [], te = J({
7
7
  efwDatePickerControl: {
8
8
  "& [disabled]": {
9
- backgroundColor: u.colorNeutralBackground3,
10
- color: u.colorNeutralForeground2,
9
+ backgroundColor: l.colorNeutralBackground3,
10
+ color: l.colorNeutralForeground2,
11
11
  "&::placeholder": {
12
12
  color: "transparent"
13
13
  }
14
14
  },
15
15
  // Afectar el span que contiene el input disabled
16
16
  "&:has([disabled])": {
17
- backgroundColor: u.colorNeutralBackground3
17
+ backgroundColor: l.colorNeutralBackground3
18
18
  }
19
19
  },
20
20
  efwDatePickerControlError: {
21
- backgroundColor: u.colorPaletteRedBackground1,
21
+ backgroundColor: l.colorPaletteRedBackground1,
22
22
  "::after": {
23
- borderBottomColor: u.colorPaletteRedBorder2,
23
+ borderBottomColor: l.colorPaletteRedBorder2,
24
24
  borderBottomStyle: "solid",
25
25
  borderBottomWidth: "2px"
26
26
  }
27
27
  }
28
- });
29
- function P(i) {
30
- return i.map((a) => {
31
- if (a instanceof Date)
32
- return p(a) ? a : null;
33
- if (typeof a == "string") {
34
- const l = new Date(a);
35
- return p(l) ? l : null;
36
- }
37
- if (typeof a == "number") {
38
- const l = new Date(a);
39
- return p(l) ? l : null;
40
- }
41
- return null;
42
- }).filter((a) => a !== null);
43
- }
44
- function p(i) {
45
- return i instanceof Date && !isNaN(i.getTime());
46
- }
47
- const ot = (i) => {
28
+ }), se = (x) => {
48
29
  const {
49
- editable: a = !0,
50
- disabled: l = !1,
51
- placeholder: M = "DD/MM/YYYY",
52
- className: x = "",
53
- selectedDates: r = [],
54
- allowTextInput: w = !0,
55
- localizedStrings: B = F,
56
- minDate: N,
57
- maxDate: T,
58
- showGoToToday: V = !0,
59
- showCloseButton: Y = !0,
60
- restrictedDates: $ = [],
61
- friendlyDateFormat: C = !1,
62
- onSelectDate: d,
63
- onChange: g,
64
- validationState: R = "none",
65
- setParentComponentState: m
66
- } = i, k = U(), y = Q(), [t, S] = H(P(r)), v = b(null), E = b(null);
67
- J(() => {
68
- const o = r.length === 0 && t.length > 0, n = t.length === 0 && r.length > 0, e = r.length > 0 && !O(r, t);
69
- console.log("useeffect initialValues", r);
70
- let s = P(r);
71
- (o || n || e) && (console.log("Actualizando valores:", {
72
- isReset: o,
73
- isFirstMount: n,
74
- isExternalUpdate: e,
75
- newValues: s
76
- }), S(s));
77
- }, [r]);
78
- const I = h((o) => {
30
+ editable: T = !0,
31
+ disabled: Y = !1,
32
+ placeholder: B = "DD/MM/YYYY",
33
+ className: V = "",
34
+ selectedDates: u = C,
35
+ defaultSelectedDates: d = C,
36
+ allowTextInput: $ = !0,
37
+ localizedStrings: w = F,
38
+ minDate: E,
39
+ maxDate: I,
40
+ showGoToToday: N = !0,
41
+ showCloseButton: R = !0,
42
+ restrictedDates: v = C,
43
+ friendlyDateFormat: S = !1,
44
+ onSelectDate: s,
45
+ onChange: m,
46
+ validationState: z = "none",
47
+ setParentComponentState: f
48
+ } = x, k = Q(), P = te(), n = u !== void 0, A = y(() => p(u ?? []), [u]), b = y(() => p(d), [d]), [L, g] = X(() => p(d)), e = n ? A : L, W = M(null), j = M(null), G = D((o) => {
79
49
  if (!o) return "";
80
- const n = o.getDate(), e = o.getMonth(), s = o.getFullYear();
81
- if (C)
82
- return `${F.months[e]} ${n}, ${s}`;
50
+ const a = o.getDate(), t = o.getMonth(), c = o.getFullYear();
51
+ if (S)
52
+ return `${F.months[t]} ${a}, ${c}`;
83
53
  {
84
- const f = n < 10 ? `0${n}` : n, c = e + 1 < 10 ? `0${e + 1}` : e + 1;
85
- return `${f}/${c}/${s}`;
54
+ const i = a < 10 ? `0${a}` : a, r = t + 1 < 10 ? `0${t + 1}` : t + 1;
55
+ return `${i}/${r}/${c}`;
56
+ }
57
+ }, [S]), U = D((o) => {
58
+ const a = e.length && e[0] instanceof Date ? e[0] : /* @__PURE__ */ new Date(), t = (o || "").trim().split("/"), c = t.length > 0 ? Math.max(1, Math.min(31, parseInt(t[0], 10))) : a.getDate(), i = t.length > 1 ? Math.max(1, Math.min(12, parseInt(t[1], 10))) - 1 : a.getMonth();
59
+ let r = t.length > 2 ? parseInt(t[2], 10) : a.getFullYear();
60
+ return r < 100 && (r += a.getFullYear() - a.getFullYear() % 100), new Date(r, i, c);
61
+ }, [e]), _ = D((o) => {
62
+ if (!(o instanceof Date)) {
63
+ !n && e.length > 0 && g([]), s?.(null), m?.([]), f?.("none", "");
64
+ return;
65
+ }
66
+ if (e.length > 0 && e[0] instanceof Date ? e[0].getTime() === o.getTime() : !1) {
67
+ s?.(o);
68
+ return;
86
69
  }
87
- }, [C]), z = h((o) => {
88
- const n = t.length && t[0] instanceof Date ? t[0] : /* @__PURE__ */ new Date(), e = (o || "").trim().split("/"), s = e.length > 0 ? Math.max(1, Math.min(31, parseInt(e[0], 10))) : n.getDate(), f = e.length > 1 ? Math.max(1, Math.min(12, parseInt(e[1], 10))) - 1 : n.getMonth();
89
- let c = e.length > 2 ? parseInt(e[2], 10) : n.getFullYear();
90
- return c < 100 && (c += n.getFullYear() - n.getFullYear() % 100), new Date(c, f, s);
91
- }, [t]), A = h((o) => {
92
- if ((t.length === 0 || (o instanceof Date && t[0] instanceof Date ? o.getTime() !== t[0].getTime() : o !== t[0])) && o instanceof Date) {
93
- const e = [o];
94
- S(e), d?.(o), g?.(e), m?.("none", "");
95
- } else
96
- d?.(null), g?.([]), m?.("none", "");
97
- }, [t, d, g, m]), L = q(
98
- x,
99
- y.efwDatePickerControl,
100
- R === "error" && y.efwDatePickerControlError
70
+ const t = [o];
71
+ n || g(t), s?.(o), m?.(t), f?.("none", "");
72
+ }, [e, n, s, m, f]);
73
+ Z(() => {
74
+ n || g(b);
75
+ }, [n, b]);
76
+ const q = K(
77
+ V,
78
+ P.efwDatePickerControl,
79
+ z === "error" && P.efwDatePickerControlError
101
80
  );
102
- return /* @__PURE__ */ D(W, { children: a ? /* @__PURE__ */ D(
103
- K,
81
+ return /* @__PURE__ */ h(H, { children: T ? /* @__PURE__ */ h(
82
+ ee,
104
83
  {
105
84
  calendar: {
106
- componentRef: E,
107
- restrictedDates: $
85
+ componentRef: j,
86
+ restrictedDates: v
108
87
  },
109
- strings: B,
110
- className: L,
111
- ref: v,
88
+ strings: w,
89
+ className: q,
90
+ ref: W,
112
91
  id: k,
113
92
  name: k,
114
93
  autoComplete: "off",
115
94
  autoCorrect: "off",
116
95
  autoCapitalize: "off",
117
96
  spellCheck: "false",
118
- allowTextInput: w,
97
+ allowTextInput: $,
119
98
  disableAutoFocus: !0,
120
- value: t.length > 0 ? t[0] : null,
121
- minDate: N,
122
- maxDate: T,
123
- disabled: l,
124
- onSelectDate: A,
125
- formatDate: I,
126
- parseDateFromString: z,
127
- placeholder: M,
128
- showGoToToday: V,
129
- showCloseButton: Y
99
+ value: e.length > 0 ? e[0] : null,
100
+ minDate: E,
101
+ maxDate: I,
102
+ disabled: Y,
103
+ onSelectDate: _,
104
+ formatDate: G,
105
+ parseDateFromString: U,
106
+ placeholder: B,
107
+ showGoToToday: N,
108
+ showCloseButton: R
130
109
  }
131
- ) : /* @__PURE__ */ D(G, { style: t.length ? void 0 : { opacity: 0.7 }, children: t.length > 0 && t[0] instanceof Date ? t[0].toLocaleDateString() : "Sin datos disponibles" }) });
110
+ ) : /* @__PURE__ */ h(O, { style: e.length ? void 0 : { opacity: 0.7 }, children: e.length > 0 && e[0] instanceof Date ? e[0].toLocaleDateString() : "Sin datos disponibles" }) });
132
111
  };
133
112
  export {
134
- ot as EFWDatePicker
113
+ se as EFWDatePicker
135
114
  };
@@ -10,9 +10,14 @@ export type EFWDatePickerOnChange = (value: EFWDatePickerValue[]) => void;
10
10
  export interface EFWDatePickerProps extends Omit<Partial<DatePickerProps>, 'onChange' | 'id' | 'value'>, EFWFieldChildrenProps {
11
11
  /**
12
12
  * Array de fechas seleccionadas iniciales. Puede contener objetos Date o strings que representen fechas.
13
- * @default []
13
+ * Si se proporciona, el componente opera en modo controlled.
14
14
  */
15
15
  selectedDates?: EFWDatePickerValue[];
16
+ /**
17
+ * Valor inicial para modo uncontrolled. Solo se usa cuando `selectedDates` no está definido.
18
+ * @default []
19
+ */
20
+ defaultSelectedDates?: EFWDatePickerValue[];
16
21
  /**
17
22
  * Permite la entrada de texto manual para introducir fechas directamente en el campo de entrada.
18
23
  * @default true
@@ -19,4 +19,6 @@ declare const esLocalizedStrings: CalendarStrings;
19
19
  declare const esOnFormatDate: (date?: Date, friendlyFormat?: boolean) => string;
20
20
  declare const normalizeToDate: (value: Date | string | null | undefined) => Date | null;
21
21
  declare const arraysAreEqual: (arr1: (Date | string)[], arr2: (Date | string)[]) => boolean;
22
+ export declare const mapToValidDates: (arr?: unknown[]) => Date[];
23
+ export declare const isValidDate: (date: Date) => boolean;
22
24
  export { esLocalizedStrings, esOnFormatDate, normalizeToDate, arraysAreEqual };
@@ -1,5 +1,5 @@
1
1
  import { defaultDatePickerStrings as l } from "@fluentui/react-datepicker-compat";
2
- const u = {
2
+ const c = {
3
3
  ...l,
4
4
  days: [
5
5
  "Domingo",
@@ -40,37 +40,51 @@ const u = {
40
40
  "Dic"
41
41
  ],
42
42
  goToToday: "Ir a hoy"
43
- }, f = (t, o = !1) => {
43
+ }, g = (t, n = !1) => {
44
44
  if (!t) return "";
45
- const e = t.getDate(), n = t.getMonth(), r = t.getFullYear();
46
- if (o)
47
- return `${u.months[n]} ${e}, ${r}`;
45
+ const e = t.getDate(), r = t.getMonth(), o = t.getFullYear();
46
+ if (n)
47
+ return `${c.months[r]} ${e}, ${o}`;
48
48
  {
49
- const s = e < 10 ? `0${e}` : e, a = n + 1 < 10 ? `0${n + 1}` : n + 1;
50
- return `${s}/${a}/${r}`;
49
+ const i = e < 10 ? `0${e}` : e, u = r + 1 < 10 ? `0${r + 1}` : r + 1;
50
+ return `${i}/${u}/${o}`;
51
51
  }
52
- }, i = (t) => {
52
+ }, a = (t) => {
53
53
  if (t instanceof Date) return t;
54
54
  if (typeof t == "string")
55
55
  try {
56
- const o = new Date(t);
57
- return isNaN(o.getTime()) ? null : o;
56
+ const n = new Date(t);
57
+ return isNaN(n.getTime()) ? null : n;
58
58
  } catch {
59
59
  return null;
60
60
  }
61
61
  return null;
62
- }, g = (t, o) => {
63
- if (t.length !== o.length) return !1;
62
+ }, D = (t, n) => {
63
+ if (t.length !== n.length) return !1;
64
64
  for (let e = 0; e < t.length; e++) {
65
- const n = i(t[e]), r = i(o[e]);
66
- if (!(n === null && r === null) && (n === null || r === null || n.getTime() !== r.getTime()))
65
+ const r = a(t[e]), o = a(n[e]);
66
+ if (!(r === null && o === null) && (r === null || o === null || r.getTime() !== o.getTime()))
67
67
  return !1;
68
68
  }
69
69
  return !0;
70
- };
70
+ }, h = (t = []) => t.map((n) => {
71
+ if (n instanceof Date)
72
+ return s(n) ? n : null;
73
+ if (typeof n == "string") {
74
+ const e = new Date(n);
75
+ return s(e) ? e : null;
76
+ }
77
+ if (typeof n == "number") {
78
+ const e = new Date(n);
79
+ return s(e) ? e : null;
80
+ }
81
+ return null;
82
+ }).filter((n) => n !== null), s = (t) => t instanceof Date && !isNaN(t.getTime());
71
83
  export {
72
- g as arraysAreEqual,
73
- u as esLocalizedStrings,
74
- f as esOnFormatDate,
75
- i as normalizeToDate
84
+ D as arraysAreEqual,
85
+ c as esLocalizedStrings,
86
+ g as esOnFormatDate,
87
+ s as isValidDate,
88
+ h as mapToValidDates,
89
+ a as normalizeToDate
76
90
  };