@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.
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.js +68 -67
- package/dist/react-components/fields/EFWAttachments/EFWAttachments.types.d.ts +8 -2
- package/dist/react-components/fields/EFWAttachmentsField/EFWAttachmentsField.js +18 -16
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.js +79 -100
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.types.d.ts +6 -1
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.d.ts +2 -0
- package/dist/react-components/fields/EFWDatePicker/EFWDatePicker.utils.js +33 -19
- package/dist/react-components/fields/EFWDatePickerField/EFWDatePickerField.js +35 -33
- package/dist/react-components/fields/EFWField/EFWField.d.ts +2 -1
- package/dist/react-components/fields/EFWField/EFWField.js +39 -33
- package/dist/react-components/fields/EFWInput/EFWInput.js +86 -67
- package/dist/react-components/fields/EFWInput/EFWInput.types.d.ts +13 -1
- package/dist/react-components/fields/EFWInput/EFWInput.utils.js +32 -33
- package/dist/react-components/fields/EFWInputField/EFWInputField.js +33 -31
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.js +136 -121
- package/dist/react-components/fields/EFWNumberInput/EFWNumberInput.types.d.ts +12 -0
- package/dist/react-components/fields/EFWNumberInputField/EFWNumberInputField.js +31 -29
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.js +36 -35
- package/dist/react-components/fields/EFWSwitch/EFWSwitch.types.d.ts +6 -0
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.js +24 -22
- package/dist/react-components/fields/EFWSwitchField/EFWSwitchField.types.d.ts +1 -1
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.js +122 -113
- package/dist/react-components/fields/EFWTagPicker/EFWTagPicker.types.d.ts +7 -2
- package/dist/react-components/fields/EFWTagPickerField/EFWTagPickerField.js +31 -29
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.js +59 -57
- package/dist/react-components/fields/EFWTextArea/EFWTextArea.types.d.ts +6 -2
- package/dist/react-components/fields/EFWTextAreaField/EFWTextAreaField.js +31 -29
- package/dist/react-components/forms/EFWForm/EFWForm.d.ts +2 -1
- package/dist/react-components/forms/EFWForm/EFWForm.js +245 -210
- package/dist/react-components/forms/EFWForm/EFWForm.types.d.ts +13 -8
- package/dist/react-components/forms/EFWForm/EFWForm.utils.js +212 -179
- package/dist/react-components/tables/EFWTable/EFWTable.d.ts +1 -1
- package/dist/react-components/tables/EFWTable/EFWTable.js +473 -392
- package/dist/react-components/tables/EFWTable/EFWTable.types.d.ts +21 -0
- package/dist/react-components/tables/EFWTable/components/EFWTableCell/EFWTableCell.js +1 -1
- package/dist/react-components/tables/EFWTable/components/EFWTableCommandBar/EFWTableCommandBar.js +68 -77
- package/dist/react-components/tables/EFWTable/components/EFWTableHeader/EFWTableHeader.js +4 -4
- package/dist/react-components/tables/EFWTable/hooks/useDefaultDeleteButton/useDefaultDeleteButton.js +33 -30
- package/dist/react-components/tables/EFWTable/hooks/useDefaultUpdateButton/useDefaultUpdateButton.js +1 -1
- package/dist/react-components/tables/EFWTable/hooks/useTableController/useTableController.js +1 -1
- package/package.json +1 -1
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { jsxs as
|
|
2
|
-
import { makeStyles as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { EFWAttachmentsContainer as
|
|
5
|
-
import { Attach20Regular as
|
|
6
|
-
import { formatFileSize as
|
|
7
|
-
import { v4 as
|
|
8
|
-
const
|
|
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
|
-
}),
|
|
21
|
+
}), te = (w) => {
|
|
22
22
|
const {
|
|
23
|
-
editable:
|
|
24
|
-
disabled:
|
|
25
|
-
files:
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
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:
|
|
35
|
-
} =
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
}, [
|
|
39
|
-
const
|
|
40
|
-
for (const
|
|
41
|
-
if (
|
|
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
|
-
}, [
|
|
45
|
-
|
|
46
|
-
t.length > 0 ?
|
|
47
|
-
}, [t,
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
}, [
|
|
51
|
-
const
|
|
52
|
-
if (!
|
|
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 (
|
|
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((
|
|
62
|
-
|
|
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,
|
|
67
|
-
const
|
|
68
|
-
id:
|
|
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 (
|
|
76
|
-
const e =
|
|
77
|
-
|
|
76
|
+
if (o.length > 0) {
|
|
77
|
+
const e = h ? [...t, ...o] : o;
|
|
78
|
+
s || v(e), a?.(e);
|
|
78
79
|
}
|
|
79
|
-
|
|
80
|
-
}, [t,
|
|
81
|
-
|
|
82
|
-
|
|
80
|
+
l.current && (l.current.value = "");
|
|
81
|
+
}, [t, h, a, s]), N = $(
|
|
82
|
+
z,
|
|
83
|
+
E === "error" && A.efwAttachmentError
|
|
83
84
|
);
|
|
84
|
-
return /* @__PURE__ */
|
|
85
|
-
|
|
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:
|
|
90
|
-
id:
|
|
90
|
+
ref: l,
|
|
91
|
+
id: b,
|
|
91
92
|
type: "file",
|
|
92
|
-
className:
|
|
93
|
-
accept:
|
|
94
|
-
multiple:
|
|
95
|
-
onChange:
|
|
96
|
-
disabled:
|
|
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
|
-
|
|
101
|
+
D,
|
|
101
102
|
{
|
|
102
103
|
size: "medium",
|
|
103
|
-
onClick:
|
|
104
|
-
icon: /* @__PURE__ */ r(
|
|
105
|
-
disabled:
|
|
106
|
-
className:
|
|
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
|
-
!
|
|
112
|
-
|
|
112
|
+
!f && t.length === 0 ? /* @__PURE__ */ r(T, { style: { opacity: 0.7 }, children: "Sin archivos disponibles" }) : /* @__PURE__ */ r(
|
|
113
|
+
G,
|
|
113
114
|
{
|
|
114
|
-
enableRemoveButtons:
|
|
115
|
-
onRemoveAttachment:
|
|
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
|
-
|
|
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
|
|
37
|
-
*
|
|
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
|
|
3
|
-
import { EFWAttachment as
|
|
4
|
-
const
|
|
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
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
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
|
-
|
|
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
|
-
|
|
38
|
+
E,
|
|
38
39
|
{
|
|
39
40
|
files: c,
|
|
41
|
+
defaultFiles: f,
|
|
40
42
|
editable: e,
|
|
41
|
-
onChange: (C,
|
|
42
|
-
|
|
43
|
+
onChange: (C, v) => {
|
|
44
|
+
F?.(C, v);
|
|
43
45
|
},
|
|
44
46
|
disabled: h,
|
|
45
|
-
multiple:
|
|
46
|
-
acceptedTypes:
|
|
47
|
-
onRemoveAttachment:
|
|
47
|
+
multiple: g,
|
|
48
|
+
acceptedTypes: p,
|
|
49
|
+
onRemoveAttachment: u
|
|
48
50
|
}
|
|
49
51
|
)
|
|
50
52
|
}
|
|
51
53
|
);
|
|
52
54
|
};
|
|
53
55
|
export {
|
|
54
|
-
|
|
56
|
+
j as EFWAttachmentsField
|
|
55
57
|
};
|
|
@@ -1,135 +1,114 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { makeStyles as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { DatePicker as
|
|
5
|
-
import {
|
|
6
|
-
const
|
|
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:
|
|
10
|
-
color:
|
|
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:
|
|
17
|
+
backgroundColor: l.colorNeutralBackground3
|
|
18
18
|
}
|
|
19
19
|
},
|
|
20
20
|
efwDatePickerControlError: {
|
|
21
|
-
backgroundColor:
|
|
21
|
+
backgroundColor: l.colorPaletteRedBackground1,
|
|
22
22
|
"::after": {
|
|
23
|
-
borderBottomColor:
|
|
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:
|
|
50
|
-
disabled:
|
|
51
|
-
placeholder:
|
|
52
|
-
className:
|
|
53
|
-
selectedDates:
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
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
|
|
81
|
-
if (
|
|
82
|
-
return `${F.months[
|
|
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
|
|
85
|
-
return `${
|
|
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
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
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__ */
|
|
103
|
-
|
|
81
|
+
return /* @__PURE__ */ h(H, { children: T ? /* @__PURE__ */ h(
|
|
82
|
+
ee,
|
|
104
83
|
{
|
|
105
84
|
calendar: {
|
|
106
|
-
componentRef:
|
|
107
|
-
restrictedDates:
|
|
85
|
+
componentRef: j,
|
|
86
|
+
restrictedDates: v
|
|
108
87
|
},
|
|
109
|
-
strings:
|
|
110
|
-
className:
|
|
111
|
-
ref:
|
|
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:
|
|
97
|
+
allowTextInput: $,
|
|
119
98
|
disableAutoFocus: !0,
|
|
120
|
-
value:
|
|
121
|
-
minDate:
|
|
122
|
-
maxDate:
|
|
123
|
-
disabled:
|
|
124
|
-
onSelectDate:
|
|
125
|
-
formatDate:
|
|
126
|
-
parseDateFromString:
|
|
127
|
-
placeholder:
|
|
128
|
-
showGoToToday:
|
|
129
|
-
showCloseButton:
|
|
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__ */
|
|
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
|
-
|
|
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
|
-
*
|
|
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
|
|
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
|
-
},
|
|
43
|
+
}, g = (t, n = !1) => {
|
|
44
44
|
if (!t) return "";
|
|
45
|
-
const e = t.getDate(),
|
|
46
|
-
if (
|
|
47
|
-
return `${
|
|
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
|
|
50
|
-
return `${
|
|
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
|
-
},
|
|
52
|
+
}, a = (t) => {
|
|
53
53
|
if (t instanceof Date) return t;
|
|
54
54
|
if (typeof t == "string")
|
|
55
55
|
try {
|
|
56
|
-
const
|
|
57
|
-
return isNaN(
|
|
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
|
-
},
|
|
63
|
-
if (t.length !==
|
|
62
|
+
}, D = (t, n) => {
|
|
63
|
+
if (t.length !== n.length) return !1;
|
|
64
64
|
for (let e = 0; e < t.length; e++) {
|
|
65
|
-
const
|
|
66
|
-
if (!(
|
|
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
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
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
|
};
|