@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.
- 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,58 +1,60 @@
|
|
|
1
1
|
import { jsx as t } from "react/jsx-runtime";
|
|
2
|
-
import { EFWField as
|
|
3
|
-
import { EFWDatePicker as
|
|
2
|
+
import { EFWField as E } from "../EFWField/EFWField.js";
|
|
3
|
+
import { EFWDatePicker as M } from "../EFWDatePicker/EFWDatePicker.js";
|
|
4
4
|
const k = (a) => {
|
|
5
5
|
const {
|
|
6
6
|
title: l,
|
|
7
7
|
infoLabel: o,
|
|
8
8
|
hint: i,
|
|
9
9
|
style: r = {},
|
|
10
|
-
required:
|
|
11
|
-
validationState:
|
|
12
|
-
validationMessage:
|
|
10
|
+
required: s = !1,
|
|
11
|
+
validationState: d,
|
|
12
|
+
validationMessage: n,
|
|
13
13
|
disabled: c = !1,
|
|
14
14
|
editable: e = !0,
|
|
15
|
-
hidden:
|
|
16
|
-
onChange:
|
|
17
|
-
placeholder:
|
|
18
|
-
selectedDates: D
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
15
|
+
hidden: f = !1,
|
|
16
|
+
onChange: h,
|
|
17
|
+
placeholder: m = "DD/MM/YYYY",
|
|
18
|
+
selectedDates: D,
|
|
19
|
+
defaultSelectedDates: u,
|
|
20
|
+
allowRangeSelection: g = !1,
|
|
21
|
+
restrictedDates: p = [],
|
|
22
|
+
allowTextInput: b = !0,
|
|
23
|
+
minDate: w,
|
|
24
|
+
maxDate: F,
|
|
25
|
+
showGoToToday: x,
|
|
26
|
+
showCloseButton: Y,
|
|
27
|
+
onValidationChange: C
|
|
27
28
|
} = a;
|
|
28
29
|
return /* @__PURE__ */ t(
|
|
29
|
-
|
|
30
|
+
E,
|
|
30
31
|
{
|
|
31
32
|
style: r,
|
|
32
33
|
title: l,
|
|
33
34
|
infoLabel: o,
|
|
34
35
|
weightLabel: e ? "regular" : "semibold",
|
|
35
36
|
hint: i,
|
|
36
|
-
hidden:
|
|
37
|
-
required:
|
|
38
|
-
validationState:
|
|
39
|
-
validationMessage:
|
|
40
|
-
onValidationChange:
|
|
37
|
+
hidden: f,
|
|
38
|
+
required: s,
|
|
39
|
+
validationState: d,
|
|
40
|
+
validationMessage: n,
|
|
41
|
+
onValidationChange: C,
|
|
41
42
|
children: /* @__PURE__ */ t(
|
|
42
|
-
|
|
43
|
+
M,
|
|
43
44
|
{
|
|
44
45
|
editable: e,
|
|
45
46
|
selectedDates: D,
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
defaultSelectedDates: u,
|
|
48
|
+
minDate: w,
|
|
49
|
+
maxDate: F,
|
|
50
|
+
onChange: h,
|
|
51
|
+
allowTextInput: b,
|
|
50
52
|
disabled: c,
|
|
51
|
-
placeholder:
|
|
52
|
-
restrictedDates:
|
|
53
|
-
allowRangeSelection:
|
|
54
|
-
showGoToToday:
|
|
55
|
-
showCloseButton:
|
|
53
|
+
placeholder: m,
|
|
54
|
+
restrictedDates: p,
|
|
55
|
+
allowRangeSelection: g,
|
|
56
|
+
showGoToToday: x,
|
|
57
|
+
showCloseButton: Y
|
|
56
58
|
}
|
|
57
59
|
)
|
|
58
60
|
}
|
|
@@ -3,7 +3,8 @@ import { EFWFieldProps } from './EFWField.types';
|
|
|
3
3
|
/**
|
|
4
4
|
* Componente de campo de formulario estilizado con soporte para validación y personalización.
|
|
5
5
|
*
|
|
6
|
-
* `EFWField` renderiza un campo de formulario con etiqueta, información adicional, mensajes
|
|
6
|
+
* `EFWField` renderiza un campo de formulario con etiqueta, información adicional, mensajes
|
|
7
|
+
* de validación
|
|
7
8
|
* y estilos personalizados. Gestiona el estado de validación internamente y notifica cambios de validación al componente padre si se proporciona
|
|
8
9
|
* `onValidationChange`. Puede ocultarse condicionalmente y permite la integración de componentes hijos
|
|
9
10
|
* con soporte para validación.
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { jsx as v } from "react/jsx-runtime";
|
|
2
|
-
import { makeStyles as
|
|
3
|
-
import
|
|
2
|
+
import { makeStyles as R, InfoLabel as D, mergeClasses as W, Field as $ } from "@fluentui/react-components";
|
|
3
|
+
import j, { useState as x, useMemo as M, useRef as p, useEffect as l, useCallback as q } from "react";
|
|
4
4
|
import { getValidationIcon as z } from "./EFWField.utils.js";
|
|
5
|
-
const
|
|
5
|
+
const G = R({
|
|
6
6
|
"efw-textField": {
|
|
7
7
|
"& .fui-Field__validationMessage:empty": {
|
|
8
8
|
display: "none !important"
|
|
@@ -23,62 +23,68 @@ const D = B({
|
|
|
23
23
|
borderBottom: "2px solid var(--colorPaletteRedBorder2) !important"
|
|
24
24
|
}
|
|
25
25
|
}
|
|
26
|
-
}),
|
|
26
|
+
}), K = (V) => {
|
|
27
27
|
const {
|
|
28
28
|
title: o,
|
|
29
|
-
hint:
|
|
30
|
-
className:
|
|
31
|
-
style:
|
|
32
|
-
infoLabel:
|
|
33
|
-
weightLabel:
|
|
29
|
+
hint: h,
|
|
30
|
+
className: y,
|
|
31
|
+
style: _ = {},
|
|
32
|
+
infoLabel: r,
|
|
33
|
+
weightLabel: s = "regular",
|
|
34
34
|
required: d = !1,
|
|
35
|
-
hidden:
|
|
36
|
-
orientation:
|
|
37
|
-
size:
|
|
35
|
+
hidden: b = !1,
|
|
36
|
+
orientation: C,
|
|
37
|
+
size: I,
|
|
38
38
|
children: c,
|
|
39
39
|
validationState: t = "none",
|
|
40
40
|
validationMessage: a = "",
|
|
41
41
|
onValidationChange: f
|
|
42
|
-
} =
|
|
42
|
+
} = V, n = G(), [e, u] = x(t), [i, g] = x(a), E = M(
|
|
43
43
|
() => z(e),
|
|
44
44
|
[e]
|
|
45
|
-
),
|
|
45
|
+
), L = M(() => /* @__PURE__ */ v(D, { weight: s, info: r || "", required: d, children: o }), [r, d, s, o]), m = p(0);
|
|
46
46
|
l(() => {
|
|
47
47
|
m.current += 1, console.log(`EFWField ${o} #${m.current}`);
|
|
48
|
-
})
|
|
49
|
-
|
|
48
|
+
});
|
|
49
|
+
const F = p(!1);
|
|
50
|
+
l(() => {
|
|
51
|
+
if (!F.current) {
|
|
52
|
+
F.current = !0;
|
|
53
|
+
return;
|
|
54
|
+
}
|
|
55
|
+
u(t), g(a);
|
|
50
56
|
}, [t, a]);
|
|
51
|
-
const
|
|
52
|
-
const
|
|
53
|
-
|
|
57
|
+
const P = q((w = "none", S = "") => {
|
|
58
|
+
const B = w !== "none" ? w : t, N = S !== "" ? S : a;
|
|
59
|
+
u(B), g(N);
|
|
54
60
|
}, [t, a]);
|
|
55
61
|
if (l(() => {
|
|
56
62
|
f?.({
|
|
57
63
|
currentValidationState: e,
|
|
58
64
|
currentValidationMessage: i
|
|
59
65
|
});
|
|
60
|
-
}, [e, i, f]),
|
|
61
|
-
const
|
|
62
|
-
|
|
66
|
+
}, [e, i, f]), b) return null;
|
|
67
|
+
const k = W(
|
|
68
|
+
y,
|
|
63
69
|
n["efw-textField"],
|
|
64
70
|
e === "success" && n["efw-textField-success"],
|
|
65
71
|
e === "warning" && n["efw-textField-warning"],
|
|
66
72
|
e === "error" && n["efw-textField-error"]
|
|
67
73
|
);
|
|
68
74
|
return /* @__PURE__ */ v(
|
|
69
|
-
|
|
75
|
+
$,
|
|
70
76
|
{
|
|
71
|
-
style: { ...
|
|
72
|
-
className:
|
|
73
|
-
label:
|
|
74
|
-
hint:
|
|
77
|
+
style: { ..._ },
|
|
78
|
+
className: k,
|
|
79
|
+
label: L,
|
|
80
|
+
hint: h,
|
|
75
81
|
validationState: e,
|
|
76
82
|
validationMessage: i,
|
|
77
|
-
validationMessageIcon:
|
|
78
|
-
orientation:
|
|
79
|
-
size:
|
|
80
|
-
children: c &&
|
|
81
|
-
setParentComponentState:
|
|
83
|
+
validationMessageIcon: E,
|
|
84
|
+
orientation: C,
|
|
85
|
+
size: I,
|
|
86
|
+
children: c && j.cloneElement(c, {
|
|
87
|
+
setParentComponentState: P,
|
|
82
88
|
validationState: e,
|
|
83
89
|
validationMessage: i
|
|
84
90
|
})
|
|
@@ -86,5 +92,5 @@ const D = B({
|
|
|
86
92
|
);
|
|
87
93
|
};
|
|
88
94
|
export {
|
|
89
|
-
|
|
95
|
+
K as EFWField
|
|
90
96
|
};
|
|
@@ -1,100 +1,119 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { makeStyles as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { stripFormatting as
|
|
5
|
-
const
|
|
1
|
+
import { jsx as k, Fragment as Y } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as Z, tokens as d, mergeClasses as ee, Input as te, Text as re } from "@fluentui/react-components";
|
|
3
|
+
import { useId as oe, useRef as ne, useState as W, useMemo as g, useCallback as z, useEffect as h } from "react";
|
|
4
|
+
import { stripFormatting as c, applyFormatting as f, validateChileanRut as ae, validateEmail as le } from "./EFWInput.utils.js";
|
|
5
|
+
const se = Z({
|
|
6
6
|
efwInputError: {
|
|
7
|
-
backgroundColor:
|
|
7
|
+
backgroundColor: d.colorPaletteRedBackground1,
|
|
8
8
|
"::after": {
|
|
9
|
-
borderBottomColor:
|
|
9
|
+
borderBottomColor: d.colorPaletteRedBorder2,
|
|
10
10
|
borderBottomStyle: "solid",
|
|
11
11
|
borderBottomWidth: "2px"
|
|
12
12
|
}
|
|
13
13
|
},
|
|
14
14
|
efwInput: {
|
|
15
15
|
"& [disabled]": {
|
|
16
|
-
backgroundColor:
|
|
17
|
-
color:
|
|
16
|
+
backgroundColor: d.colorNeutralBackground3,
|
|
17
|
+
color: d.colorNeutralForeground2,
|
|
18
18
|
"&::placeholder": {
|
|
19
19
|
color: "transparent"
|
|
20
20
|
}
|
|
21
21
|
},
|
|
22
22
|
// Afectar el span que contiene el input disabled
|
|
23
23
|
"&:has(span + [disabled])": {
|
|
24
|
-
backgroundColor:
|
|
24
|
+
backgroundColor: d.colorNeutralBackground3
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
}),
|
|
27
|
+
}), fe = ($) => {
|
|
28
28
|
const {
|
|
29
|
-
value:
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
29
|
+
value: m,
|
|
30
|
+
defaultValue: E,
|
|
31
|
+
onChange: S,
|
|
32
|
+
editable: j = !0,
|
|
33
|
+
disabled: A = !1,
|
|
34
|
+
className: M = "",
|
|
35
|
+
autoComplete: O = "off",
|
|
36
|
+
type: U = "text",
|
|
37
|
+
placeholder: _,
|
|
38
|
+
contentBefore: q,
|
|
39
|
+
contentAfter: G,
|
|
39
40
|
formatType: t = "none",
|
|
40
|
-
formatPattern:
|
|
41
|
-
formatFunction:
|
|
42
|
-
minLength:
|
|
43
|
-
maxLength:
|
|
44
|
-
validationState:
|
|
45
|
-
setParentComponentState:
|
|
46
|
-
} = N,
|
|
47
|
-
() => ({ formatPattern:
|
|
48
|
-
[
|
|
49
|
-
),
|
|
50
|
-
|
|
41
|
+
formatPattern: s,
|
|
42
|
+
formatFunction: C,
|
|
43
|
+
minLength: p = 0,
|
|
44
|
+
maxLength: v = 250,
|
|
45
|
+
validationState: H = "none",
|
|
46
|
+
setParentComponentState: l
|
|
47
|
+
} = $, r = m !== void 0, B = (r ? m : E) ?? "", N = E ?? "", P = se(), R = oe(), w = ne(!1), [u, D] = W(() => c(B, t)), [J, F] = W(() => f(B, t, { formatPattern: s, formatFunction: C })), o = g(
|
|
48
|
+
() => ({ formatPattern: s, formatFunction: C }),
|
|
49
|
+
[s, C]
|
|
50
|
+
), i = g(
|
|
51
|
+
() => c(N, t),
|
|
52
|
+
[N, t]
|
|
53
|
+
), b = g(
|
|
54
|
+
() => f(i, t, o),
|
|
55
|
+
[i, t, o]
|
|
56
|
+
), T = g(() => {
|
|
57
|
+
if (!r)
|
|
58
|
+
return { raw: "", formatted: "" };
|
|
59
|
+
const e = c(m ?? "", t), a = f(e, t, o);
|
|
60
|
+
return { raw: e, formatted: a };
|
|
61
|
+
}, [r, m, t, o]), x = r ? T.raw : u, y = r ? T.formatted : J, L = z((e) => {
|
|
62
|
+
if (t === "none" || !s) return !0;
|
|
51
63
|
try {
|
|
52
|
-
return new RegExp(
|
|
64
|
+
return new RegExp(s).test(e);
|
|
53
65
|
} catch {
|
|
54
66
|
return !1;
|
|
55
67
|
}
|
|
56
|
-
}, [t,
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
+
}, [t, s]), n = z((e) => p > 0 && e.length > 0 && e.length < p ? (l?.("error", `Por favor introduzca más de ${p} caracteres.`), !0) : e.length > v ? (l?.("error", `Por favor introduzca menos de ${v} caracteres.`), !0) : t === "chileanRut" && e.length > 0 && !ae(e) ? (l?.("error", "El R.U.T ingresado no es válido."), !0) : t === "email" && e.length > 0 && !le(e) ? (l?.("error", "El correo ingresado no es válido."), !0) : L(e) ? (l?.("none", ""), !1) : (l?.("error", "El formato del valor ingresado no es válido."), !0), [p, v, t, L, l]);
|
|
69
|
+
h(() => {
|
|
70
|
+
r && n(x);
|
|
71
|
+
}, [r, x, n]), h(() => {
|
|
72
|
+
r || (D((e) => e === i ? e : i), F((e) => e === b ? e : b), n(i));
|
|
73
|
+
}, [
|
|
74
|
+
r,
|
|
75
|
+
i,
|
|
76
|
+
b,
|
|
77
|
+
n
|
|
78
|
+
]), h(() => {
|
|
79
|
+
r || F((e) => {
|
|
80
|
+
const a = f(u, t, o);
|
|
81
|
+
return a === e ? e : a;
|
|
82
|
+
});
|
|
83
|
+
}, [r, u, t, o]), h(() => {
|
|
84
|
+
r || w.current || (w.current = !0, n(u));
|
|
85
|
+
}, [r, u, n]);
|
|
86
|
+
const K = z((e, a) => {
|
|
68
87
|
if (typeof a.value == "string") {
|
|
69
|
-
const
|
|
70
|
-
|
|
88
|
+
const X = c(a.value, t), I = f(X, t, o), V = c(I, t);
|
|
89
|
+
n(V), r || (D(V), F(I)), S?.(V, I);
|
|
71
90
|
}
|
|
72
|
-
}, [t,
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
91
|
+
}, [t, o, S, n, r]), Q = ee(
|
|
92
|
+
M,
|
|
93
|
+
P.efwInput,
|
|
94
|
+
H === "error" && P.efwInputError
|
|
76
95
|
);
|
|
77
|
-
return /* @__PURE__ */
|
|
78
|
-
|
|
96
|
+
return /* @__PURE__ */ k(Y, { children: j ? /* @__PURE__ */ k(
|
|
97
|
+
te,
|
|
79
98
|
{
|
|
80
|
-
className:
|
|
81
|
-
id:
|
|
82
|
-
name:
|
|
83
|
-
type:
|
|
84
|
-
placeholder:
|
|
85
|
-
contentBefore:
|
|
86
|
-
contentAfter:
|
|
87
|
-
disabled:
|
|
88
|
-
value:
|
|
89
|
-
"data-raw-value":
|
|
90
|
-
autoComplete:
|
|
99
|
+
className: Q,
|
|
100
|
+
id: R,
|
|
101
|
+
name: R,
|
|
102
|
+
type: U,
|
|
103
|
+
placeholder: _,
|
|
104
|
+
contentBefore: q,
|
|
105
|
+
contentAfter: G,
|
|
106
|
+
disabled: A,
|
|
107
|
+
value: y,
|
|
108
|
+
"data-raw-value": x,
|
|
109
|
+
autoComplete: O,
|
|
91
110
|
autoCorrect: "off",
|
|
92
111
|
autoCapitalize: "off",
|
|
93
112
|
spellCheck: "false",
|
|
94
|
-
onChange:
|
|
113
|
+
onChange: K
|
|
95
114
|
}
|
|
96
|
-
) : /* @__PURE__ */
|
|
115
|
+
) : /* @__PURE__ */ k(re, { style: y ? void 0 : { opacity: 0.7 }, children: y || "Sin datos disponibles" }) });
|
|
97
116
|
};
|
|
98
117
|
export {
|
|
99
|
-
|
|
118
|
+
fe as EFWInput
|
|
100
119
|
};
|
|
@@ -16,7 +16,7 @@ import { EFWFieldChildrenProps } from '../EFWField/EFWField.types';
|
|
|
16
16
|
* // En un componente React
|
|
17
17
|
* const [inputValue, setInputValue] = useState<EFWInputValue>("Valor inicial");
|
|
18
18
|
*/
|
|
19
|
-
export type EFWInputValue = string | null;
|
|
19
|
+
export type EFWInputValue = string | null | undefined;
|
|
20
20
|
/**
|
|
21
21
|
* Tipos de formato disponibles para el componente EFWInput.
|
|
22
22
|
* Determina cómo se formatea y valida el contenido del campo de entrada.
|
|
@@ -103,6 +103,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
103
103
|
/**
|
|
104
104
|
* Valor actual del campo de entrada.
|
|
105
105
|
* Puede ser una cadena de texto o null para campos vacíos.
|
|
106
|
+
* La presencia de esta propiedad activa el modo controlado del componente.
|
|
106
107
|
*
|
|
107
108
|
* @example
|
|
108
109
|
* value="Juan Pérez"
|
|
@@ -111,6 +112,17 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
111
112
|
* value={null}
|
|
112
113
|
*/
|
|
113
114
|
value?: EFWInputValue;
|
|
115
|
+
/**
|
|
116
|
+
* Valor inicial usado en modo uncontrolled.
|
|
117
|
+
* Solo se aplica durante el montaje; luego el estado se maneja internamente.
|
|
118
|
+
*
|
|
119
|
+
* @example
|
|
120
|
+
* defaultValue="Texto inicial"
|
|
121
|
+
*
|
|
122
|
+
* @example
|
|
123
|
+
* defaultValue={null}
|
|
124
|
+
*/
|
|
125
|
+
defaultValue?: EFWInputValue;
|
|
114
126
|
/**
|
|
115
127
|
* Tipo de input HTML que determina el comportamiento del campo.
|
|
116
128
|
* Afecta el teclado virtual en dispositivos móviles y la validación del navegador.
|
|
@@ -1,50 +1,49 @@
|
|
|
1
1
|
const p = (t) => {
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
if (
|
|
5
|
-
const l =
|
|
2
|
+
const r = (t || "").toString(), e = r.replace(/^0+/, "");
|
|
3
|
+
let n = "";
|
|
4
|
+
if (e != "" && e.length > 1) {
|
|
5
|
+
const l = e.replace(/\./g, "").replace(/-/g, ""), s = l.substring(0, l.length - 1);
|
|
6
6
|
let c = 0, o = 1;
|
|
7
7
|
for (c = s.length - 1; c >= 0; c--)
|
|
8
|
-
|
|
8
|
+
n = s.charAt(c) + n, o % 3 == 0 && o <= s.length - 1 && (n = "." + n), o++;
|
|
9
9
|
const g = l.substring(l.length - 1);
|
|
10
|
-
return
|
|
10
|
+
return n = n + "-" + g, n;
|
|
11
11
|
} else
|
|
12
|
-
return
|
|
12
|
+
return r;
|
|
13
13
|
}, u = (t) => {
|
|
14
14
|
if (t = t || "", t = t.replace(/\./g, ""), !/^[0-9]+[-|‐]{1}[0-9kK]{1}$/.test(t))
|
|
15
15
|
return !1;
|
|
16
|
-
const
|
|
17
|
-
let
|
|
18
|
-
const
|
|
16
|
+
const r = t.split("-");
|
|
17
|
+
let e = r[1];
|
|
18
|
+
const n = r[0], i = function(l) {
|
|
19
19
|
let s = 0, c = 1;
|
|
20
20
|
for (; l; l = Math.floor(l / 10))
|
|
21
21
|
c = (c + l % 10 * (9 - s++ % 6)) % 11;
|
|
22
22
|
return c ? c - 1 : "k";
|
|
23
23
|
};
|
|
24
|
-
return
|
|
25
|
-
}, d = (t) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t), m = (t,
|
|
24
|
+
return e == "K" && (e = "k"), i(n) == e;
|
|
25
|
+
}, d = (t) => /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/.test(t), m = (t, r, e = ",", n = ".") => {
|
|
26
26
|
if (t == null) return "";
|
|
27
|
-
typeof t == "number" && (t = t.toString(), Number.isInteger(t) || (t = t.replace(".",
|
|
28
|
-
const i = new RegExp("[^" +
|
|
27
|
+
typeof t == "number" && (t = t.toString(), Number.isInteger(t) || (t = t.replace(".", n))), e = e || ",", n = n || ".";
|
|
28
|
+
const i = new RegExp("[^" + n + "\\d]", "g"), s = t.replace(i, "").toString().split(n), c = s[0].length % 3;
|
|
29
29
|
let o = s[0].substr(0, c);
|
|
30
30
|
const g = s[0].substr(c).match(/\d{3}/g);
|
|
31
|
-
return g && (o += (c ?
|
|
31
|
+
return g && (o += (c ? e : "") + g.join(e)), o = s[1] != null ? o + n + s[1] : o, r == null ? o : o ? r + o : "";
|
|
32
32
|
}, $ = (t = "") => {
|
|
33
|
-
const
|
|
34
|
-
return isNaN(Number(
|
|
33
|
+
const r = t.toString().replace(/[^\d.]/g, "");
|
|
34
|
+
return isNaN(Number(r)) || r === "" ? "" : r;
|
|
35
35
|
}, f = {
|
|
36
36
|
none: (t) => t,
|
|
37
37
|
email: (t) => t,
|
|
38
38
|
phone: (t) => t.replace(/\D/g, ""),
|
|
39
39
|
creditCard: (t) => t.replace(/\D/g, ""),
|
|
40
40
|
chileanRut: (t) => {
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
return e.slice(0, i) + "-" + e.slice(i);
|
|
41
|
+
const r = t.replace(/[^\dkK-]/gi, ""), e = r.includes("-"), n = r.replace(/-/g, "");
|
|
42
|
+
if (e && n.length >= 2) {
|
|
43
|
+
const i = n.length - 1;
|
|
44
|
+
return n.slice(0, i) + "-" + n.slice(i);
|
|
46
45
|
}
|
|
47
|
-
return
|
|
46
|
+
return n;
|
|
48
47
|
},
|
|
49
48
|
date: (t) => t.replace(/\D/g, ""),
|
|
50
49
|
//number: (value) => stripFormatNumber(value || ''),
|
|
@@ -61,20 +60,20 @@ const p = (t) => {
|
|
|
61
60
|
// if (isNaN(Number(value))) return value; // Si no es un número válido, retornar el valor original
|
|
62
61
|
// return formatNumber(value)
|
|
63
62
|
// },
|
|
64
|
-
custom: (t,
|
|
65
|
-
if (
|
|
66
|
-
return
|
|
67
|
-
if (
|
|
68
|
-
let
|
|
69
|
-
for (let i = 0; i <
|
|
70
|
-
|
|
71
|
-
return
|
|
63
|
+
custom: (t, r = {}) => {
|
|
64
|
+
if (r.formatFunction)
|
|
65
|
+
return r.formatFunction(t) || t;
|
|
66
|
+
if (r.formatPattern) {
|
|
67
|
+
let e = "", n = 0;
|
|
68
|
+
for (let i = 0; i < r.formatPattern.length && n < t.length; i++)
|
|
69
|
+
r.formatPattern[i] === "#" ? (e += t[n], n++) : (e += r.formatPattern[i], r.formatPattern[i] === t[n] && n++);
|
|
70
|
+
return e;
|
|
72
71
|
}
|
|
73
72
|
return t;
|
|
74
73
|
}
|
|
75
|
-
}, F = (t,
|
|
74
|
+
}, F = (t, r) => t ? (f[r] || f.none)(t) : "", P = (t, r, e = {}) => t ? (a[r] || a.none)(t, e) : "";
|
|
76
75
|
export {
|
|
77
|
-
|
|
76
|
+
P as applyFormatting,
|
|
78
77
|
p as formatChileanRut,
|
|
79
78
|
m as formatNumber,
|
|
80
79
|
$ as stripFormatNumber,
|
|
@@ -5,62 +5,64 @@ const P = (n) => {
|
|
|
5
5
|
const {
|
|
6
6
|
title: a,
|
|
7
7
|
infoLabel: o,
|
|
8
|
-
hint:
|
|
9
|
-
style:
|
|
8
|
+
hint: l,
|
|
9
|
+
style: i = {},
|
|
10
10
|
size: r,
|
|
11
11
|
required: d = !1,
|
|
12
12
|
contentBefore: f,
|
|
13
13
|
contentAfter: h,
|
|
14
14
|
minLength: m = 0,
|
|
15
15
|
maxLength: s = 250,
|
|
16
|
-
validationState:
|
|
17
|
-
validationMessage:
|
|
18
|
-
value:
|
|
16
|
+
validationState: u,
|
|
17
|
+
validationMessage: g,
|
|
18
|
+
value: p,
|
|
19
|
+
defaultValue: c,
|
|
19
20
|
editable: e = !0,
|
|
20
|
-
disabled:
|
|
21
|
-
hidden:
|
|
22
|
-
onChange:
|
|
23
|
-
autoComplete:
|
|
24
|
-
type:
|
|
25
|
-
placeholder:
|
|
26
|
-
formatType:
|
|
27
|
-
formatPattern:
|
|
28
|
-
formatFunction:
|
|
29
|
-
onValidationChange:
|
|
21
|
+
disabled: C = !1,
|
|
22
|
+
hidden: F = !1,
|
|
23
|
+
onChange: b,
|
|
24
|
+
autoComplete: x = "off",
|
|
25
|
+
type: L = "text",
|
|
26
|
+
placeholder: v,
|
|
27
|
+
formatType: y = "none",
|
|
28
|
+
formatPattern: E,
|
|
29
|
+
formatFunction: W,
|
|
30
|
+
onValidationChange: I
|
|
30
31
|
} = n;
|
|
31
32
|
return /* @__PURE__ */ t(
|
|
32
33
|
q,
|
|
33
34
|
{
|
|
34
|
-
style:
|
|
35
|
+
style: i,
|
|
35
36
|
title: a,
|
|
36
37
|
infoLabel: o,
|
|
37
38
|
weightLabel: e ? "regular" : "semibold",
|
|
38
|
-
hint:
|
|
39
|
+
hint: l,
|
|
39
40
|
size: r,
|
|
40
41
|
required: d,
|
|
41
|
-
validationState:
|
|
42
|
-
validationMessage:
|
|
43
|
-
onValidationChange:
|
|
44
|
-
hidden:
|
|
42
|
+
validationState: u,
|
|
43
|
+
validationMessage: g,
|
|
44
|
+
onValidationChange: I,
|
|
45
|
+
hidden: F,
|
|
45
46
|
children: /* @__PURE__ */ t(
|
|
46
47
|
w,
|
|
47
48
|
{
|
|
48
|
-
value:
|
|
49
|
+
value: p,
|
|
50
|
+
defaultValue: c,
|
|
49
51
|
editable: e,
|
|
50
|
-
onChange: (
|
|
51
|
-
|
|
52
|
+
onChange: (V, j) => {
|
|
53
|
+
b?.(V, j);
|
|
52
54
|
},
|
|
53
55
|
minLength: m,
|
|
54
56
|
maxLength: s,
|
|
55
|
-
disabled:
|
|
56
|
-
autoComplete:
|
|
57
|
-
type:
|
|
58
|
-
placeholder:
|
|
57
|
+
disabled: C,
|
|
58
|
+
autoComplete: x,
|
|
59
|
+
type: L,
|
|
60
|
+
placeholder: v,
|
|
59
61
|
contentBefore: f,
|
|
60
62
|
contentAfter: h,
|
|
61
|
-
formatType:
|
|
62
|
-
formatPattern:
|
|
63
|
-
formatFunction:
|
|
63
|
+
formatType: y,
|
|
64
|
+
formatPattern: E,
|
|
65
|
+
formatFunction: W
|
|
64
66
|
}
|
|
65
67
|
)
|
|
66
68
|
}
|