@envisiongroup/porygon 1.0.0-rc.41 → 1.0.0-rc.42
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/DatePicker/EFWDatePicker.utils.js +1 -1
- package/dist/react-components/fields/Input/EFWInput.d.ts +5 -20
- package/dist/react-components/fields/Input/EFWInput.js +193 -151
- package/dist/react-components/fields/Input/EFWInput.types.d.ts +47 -3
- package/dist/react-components/fields/Input/EFWInput.utils.d.ts +24 -4
- package/dist/react-components/fields/Input/EFWInput.utils.js +103 -53
- package/dist/react-components/fields/Input/EFWInput.validation.d.ts +20 -0
- package/dist/react-components/fields/Input/EFWInput.validation.js +62 -0
- package/dist/react-components/fields/Input/EFWInputField.js +28 -26
- package/dist/react-components/fields/Input/index.d.ts +2 -2
- package/dist/react-components/fields/NumberInput/EFWNumberInput.utils.d.ts +1 -1
- package/dist/react-components/fields/NumberInput/EFWNumberInput.utils.js +52 -46
- package/dist/react-components/fields/TextArea/EFWTextArea.utils.d.ts +1 -1
- package/dist/react-components/fields/test-utils/testUtils.js +10 -0
- package/dist/react-components/forms/EFWForm/EFWForm.converter.js +19 -10
- package/dist/react-components/forms/EFWForm/EFWForm.utils.js +83 -43
- package/dist/vite-raw.d.js +0 -0
- package/package.json +21 -5
|
@@ -1,25 +1,10 @@
|
|
|
1
1
|
import { EFWInputProps } from './EFWInput.types';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
|
-
*
|
|
5
|
-
*
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
* @param {boolean} [props.editable=true] - Indica si el input es editable o de solo lectura.
|
|
10
|
-
* @param {boolean} [props.disabled=false] - Indica si el input está deshabilitado.
|
|
11
|
-
* @param {string} [props.autoComplete="off"] - Configuración de autocompletado del input.
|
|
12
|
-
* @param {string} [props.type="text"] - Tipo de input (por ejemplo, 'text', 'number').
|
|
13
|
-
* @param {React.ReactNode} [props.contentBefore] - Contenido renderizado antes del input.
|
|
14
|
-
* @param {React.ReactNode} [props.contentAfter] - Contenido renderizado después del input.
|
|
15
|
-
* @param {string} [props.formatType="none"] - Tipo de formateo aplicado al valor (por ejemplo, 'chileanRut', 'email', 'number').
|
|
16
|
-
* @param {string} [props.formatPattern] - Expresión regular para validar el formato del valor.
|
|
17
|
-
* @param {(value: string) => string} [props.formatFunction] - Función personalizada para formatear el valor.
|
|
18
|
-
* @param {number} [props.maxLength=250] - Longitud máxima del valor en caracteres.
|
|
19
|
-
* @param {number} [props.maxValue] - Valor numérico máximo permitido (para `formatType="number"`).
|
|
20
|
-
* @param {number} [props.minValue] - Valor numérico mínimo permitido (para `formatType="number"`).
|
|
21
|
-
* @param {string} [props.validationState="none"] - Estado de validación externo ('none', 'error').
|
|
22
|
-
* @param {(state: string, message: string) => void} [props.setParentComponentState] - Función para actualizar el estado de validación en el componente padre.
|
|
23
|
-
* @returns {JSX.Element} El componente de input o texto renderizado según la configuración.
|
|
4
|
+
* Campo de texto con soporte para modo controlled/uncontrolled, formato visual,
|
|
5
|
+
* normalización de valor crudo, validación y render de solo lectura.
|
|
6
|
+
*
|
|
7
|
+
* Los contratos públicos viven en `EFWInput.types.tsx`; este componente se
|
|
8
|
+
* encarga de orquestar estado, callbacks y render.
|
|
24
9
|
*/
|
|
25
10
|
export declare const EFWInput: (props: EFWInputProps) => import("react/jsx-runtime").JSX.Element;
|
|
@@ -1,199 +1,241 @@
|
|
|
1
|
-
import { jsx as
|
|
2
|
-
import { makeStyles as
|
|
3
|
-
import { useId as
|
|
4
|
-
import { stripFormatting as
|
|
5
|
-
import {
|
|
6
|
-
|
|
1
|
+
import { jsx as L, Fragment as ke } from "react/jsx-runtime";
|
|
2
|
+
import { makeStyles as Me, tokens as I, mergeClasses as ze, Text as Be, Input as Pe } from "@fluentui/react-components";
|
|
3
|
+
import { useId as De, useRef as Ne, useState as Ie, useMemo as u, useCallback as pe, useEffect as h } from "react";
|
|
4
|
+
import { stripFormatting as p, getInputFormattedValue as x, applyFormatting as fe } from "./EFWInput.utils.js";
|
|
5
|
+
import { resolveInputValidationState as We } from "./EFWInput.validation.js";
|
|
6
|
+
import { useFieldsLocaleText as Te } from "../../i18n/PorygonI18nProvider.js";
|
|
7
|
+
const Oe = Me({
|
|
7
8
|
efwInputError: {
|
|
8
|
-
backgroundColor:
|
|
9
|
+
backgroundColor: I.colorPaletteRedBackground1,
|
|
9
10
|
"::after": {
|
|
10
|
-
borderBottomColor:
|
|
11
|
+
borderBottomColor: I.colorPaletteRedBorder2,
|
|
11
12
|
borderBottomStyle: "solid",
|
|
12
13
|
borderBottomWidth: "2px"
|
|
13
14
|
}
|
|
14
15
|
},
|
|
15
16
|
efwInput: {
|
|
16
17
|
"& [disabled]": {
|
|
17
|
-
backgroundColor:
|
|
18
|
-
color:
|
|
18
|
+
backgroundColor: I.colorNeutralBackground3,
|
|
19
|
+
color: I.colorNeutralForeground2,
|
|
19
20
|
"&::placeholder": {
|
|
20
21
|
color: "transparent"
|
|
21
22
|
}
|
|
22
23
|
},
|
|
23
24
|
// Afectar el span que contiene el input disabled
|
|
24
25
|
"&:has(span + [disabled])": {
|
|
25
|
-
backgroundColor:
|
|
26
|
+
backgroundColor: I.colorNeutralBackground3
|
|
26
27
|
}
|
|
27
28
|
}
|
|
28
|
-
}),
|
|
29
|
+
}), Je = (ve) => {
|
|
29
30
|
const {
|
|
30
|
-
value:
|
|
31
|
-
defaultValue:
|
|
32
|
-
onChange:
|
|
33
|
-
editable:
|
|
31
|
+
value: d,
|
|
32
|
+
defaultValue: R,
|
|
33
|
+
onChange: S,
|
|
34
|
+
editable: he = !0,
|
|
34
35
|
disabled: ge = !1,
|
|
35
|
-
className:
|
|
36
|
-
autoComplete:
|
|
37
|
-
type:
|
|
38
|
-
contentBefore:
|
|
39
|
-
contentAfter:
|
|
40
|
-
formatType:
|
|
41
|
-
formatPattern:
|
|
42
|
-
formatFunction:
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
),
|
|
54
|
-
|
|
55
|
-
|
|
36
|
+
className: be = "",
|
|
37
|
+
autoComplete: Ce = "off",
|
|
38
|
+
type: Ve = "text",
|
|
39
|
+
contentBefore: Fe,
|
|
40
|
+
contentAfter: we,
|
|
41
|
+
formatType: e = "none",
|
|
42
|
+
formatPattern: m,
|
|
43
|
+
formatFunction: g,
|
|
44
|
+
formatConfig: o,
|
|
45
|
+
minLength: E = 0,
|
|
46
|
+
maxLength: k = 250,
|
|
47
|
+
labels: M,
|
|
48
|
+
readOnlyRenderer: ye,
|
|
49
|
+
validationMessages: l,
|
|
50
|
+
validationState: Le = "none",
|
|
51
|
+
setParentComponentState: z
|
|
52
|
+
} = ve, t = d !== void 0, B = (t ? d : R) ?? "", f = R ?? "", P = Oe(), D = De(), N = Ne(!1), [c, W] = Ie(
|
|
53
|
+
() => p(B, e, o)
|
|
54
|
+
), [xe, b] = Ie(
|
|
55
|
+
() => x(B, e, {
|
|
56
|
+
formatPattern: m,
|
|
57
|
+
formatFunction: g,
|
|
58
|
+
formatConfig: o
|
|
59
|
+
})
|
|
60
|
+
), r = u(
|
|
61
|
+
() => ({ formatPattern: m, formatFunction: g, formatConfig: o }),
|
|
62
|
+
[m, g, o]
|
|
63
|
+
), T = Te(), O = T.input.labels, i = T.input.validationMessages, j = O.placeholder, A = O.emptyState, _ = M?.placeholder, q = M?.emptyState, G = u(() => ({
|
|
64
|
+
placeholder: _ ?? j,
|
|
65
|
+
emptyState: q ?? A
|
|
56
66
|
}), [
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
]),
|
|
62
|
-
minLength:
|
|
63
|
-
maxLength:
|
|
64
|
-
phoneInvalid:
|
|
65
|
-
creditCardInvalid: oe ??
|
|
66
|
-
chileanRutInvalid:
|
|
67
|
-
dateInvalid:
|
|
68
|
-
dateInvalidWithFormat:
|
|
69
|
-
timeInvalid:
|
|
70
|
-
emailInvalid:
|
|
71
|
-
formatInvalid:
|
|
67
|
+
_,
|
|
68
|
+
q,
|
|
69
|
+
j,
|
|
70
|
+
A
|
|
71
|
+
]), H = i.minLength, J = i.maxLength, K = i.phoneInvalid, Q = i.creditCardInvalid, U = i.chileanRutInvalid, X = i.dateInvalid, Y = i.dateInvalidWithFormat, Z = i.timeInvalid, $ = i.emailInvalid, ee = i.formatInvalid, te = l?.minLength, ae = l?.maxLength, ne = l?.phoneInvalid, oe = l?.creditCardInvalid, le = l?.chileanRutInvalid, re = l?.dateInvalid, ie = l?.dateInvalidWithFormat, se = l?.timeInvalid, de = l?.emailInvalid, ce = l?.formatInvalid, ue = u(() => ({
|
|
72
|
+
minLength: te ?? H,
|
|
73
|
+
maxLength: ae ?? J,
|
|
74
|
+
phoneInvalid: ne ?? K,
|
|
75
|
+
creditCardInvalid: oe ?? Q,
|
|
76
|
+
chileanRutInvalid: le ?? U,
|
|
77
|
+
dateInvalid: re ?? X,
|
|
78
|
+
dateInvalidWithFormat: ie ?? Y,
|
|
79
|
+
timeInvalid: se ?? Z,
|
|
80
|
+
emailInvalid: de ?? $,
|
|
81
|
+
formatInvalid: ce ?? ee
|
|
72
82
|
}), [
|
|
83
|
+
te,
|
|
84
|
+
ae,
|
|
73
85
|
ne,
|
|
86
|
+
oe,
|
|
74
87
|
le,
|
|
75
88
|
re,
|
|
76
|
-
oe,
|
|
77
89
|
ie,
|
|
78
|
-
de,
|
|
79
90
|
se,
|
|
91
|
+
de,
|
|
80
92
|
ce,
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
93
|
+
H,
|
|
94
|
+
J,
|
|
95
|
+
K,
|
|
96
|
+
Q,
|
|
84
97
|
U,
|
|
85
98
|
X,
|
|
86
99
|
Y,
|
|
87
100
|
Z,
|
|
88
101
|
$,
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
() =>
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
102
|
+
ee
|
|
103
|
+
]), v = u(
|
|
104
|
+
() => p(f, e, o),
|
|
105
|
+
[f, e, o]
|
|
106
|
+
), C = u(
|
|
107
|
+
() => x(
|
|
108
|
+
f,
|
|
109
|
+
e,
|
|
110
|
+
r
|
|
111
|
+
),
|
|
112
|
+
[f, e, r]
|
|
113
|
+
), me = u(() => {
|
|
114
|
+
if (!t)
|
|
101
115
|
return { raw: "", formatted: "" };
|
|
102
|
-
const
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
};
|
|
124
|
-
return
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
116
|
+
const a = p(
|
|
117
|
+
d ?? "",
|
|
118
|
+
e,
|
|
119
|
+
o
|
|
120
|
+
), n = x(
|
|
121
|
+
d,
|
|
122
|
+
e,
|
|
123
|
+
r
|
|
124
|
+
);
|
|
125
|
+
return { raw: a, formatted: n };
|
|
126
|
+
}, [t, d, e, o, r]), V = t ? me.raw : c, F = t ? me.formatted : xe, s = pe(
|
|
127
|
+
(a) => {
|
|
128
|
+
const n = We({
|
|
129
|
+
rawValue: a,
|
|
130
|
+
formatType: e,
|
|
131
|
+
formatPattern: m,
|
|
132
|
+
formatConfig: o,
|
|
133
|
+
minLength: E,
|
|
134
|
+
maxLength: k,
|
|
135
|
+
messages: ue,
|
|
136
|
+
formatOptions: r
|
|
137
|
+
});
|
|
138
|
+
return z?.(
|
|
139
|
+
n.hasError ? "error" : "none",
|
|
140
|
+
n.message
|
|
141
|
+
), n.hasError;
|
|
142
|
+
},
|
|
143
|
+
[
|
|
144
|
+
E,
|
|
145
|
+
k,
|
|
146
|
+
e,
|
|
147
|
+
m,
|
|
148
|
+
o,
|
|
149
|
+
r,
|
|
150
|
+
z,
|
|
151
|
+
ue
|
|
152
|
+
]
|
|
153
|
+
);
|
|
154
|
+
h(() => {
|
|
155
|
+
t && s(V);
|
|
156
|
+
}, [t, V, s]), h(() => {
|
|
157
|
+
t || (W(
|
|
158
|
+
(a) => a === v ? a : v
|
|
159
|
+
), b(
|
|
160
|
+
(a) => a === C ? a : C
|
|
161
|
+
), s(v));
|
|
146
162
|
}, [
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
163
|
+
t,
|
|
164
|
+
v,
|
|
165
|
+
C,
|
|
150
166
|
s
|
|
151
|
-
]),
|
|
152
|
-
|
|
153
|
-
const
|
|
154
|
-
|
|
167
|
+
]), h(() => {
|
|
168
|
+
t || b((a) => {
|
|
169
|
+
const n = fe(
|
|
170
|
+
c,
|
|
171
|
+
e,
|
|
172
|
+
r
|
|
173
|
+
);
|
|
174
|
+
return n === a ? a : n;
|
|
155
175
|
});
|
|
156
|
-
}, [
|
|
157
|
-
|
|
158
|
-
}, [
|
|
159
|
-
const
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
176
|
+
}, [t, c, e, r]), h(() => {
|
|
177
|
+
t || N.current || (N.current = !0, s(c));
|
|
178
|
+
}, [t, c, s]);
|
|
179
|
+
const Re = pe(
|
|
180
|
+
(a, n) => {
|
|
181
|
+
if (typeof n.value == "string") {
|
|
182
|
+
const Ee = p(
|
|
183
|
+
n.value,
|
|
184
|
+
e,
|
|
185
|
+
o
|
|
186
|
+
), w = fe(
|
|
187
|
+
Ee,
|
|
188
|
+
e,
|
|
189
|
+
r
|
|
190
|
+
), y = p(
|
|
191
|
+
w,
|
|
192
|
+
e,
|
|
193
|
+
o
|
|
194
|
+
);
|
|
195
|
+
s(y), t || (W(y), b(w)), S?.(y, w);
|
|
196
|
+
}
|
|
197
|
+
},
|
|
198
|
+
[
|
|
199
|
+
e,
|
|
200
|
+
o,
|
|
201
|
+
r,
|
|
202
|
+
S,
|
|
203
|
+
s,
|
|
204
|
+
t
|
|
205
|
+
]
|
|
206
|
+
), Se = ze(
|
|
207
|
+
be,
|
|
208
|
+
P.efwInput,
|
|
209
|
+
Le === "error" && P.efwInputError
|
|
168
210
|
);
|
|
169
|
-
if (!
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
211
|
+
if (!he) {
|
|
212
|
+
const a = F || G.emptyState, n = ye?.(
|
|
213
|
+
t ? d : c,
|
|
214
|
+
a
|
|
173
215
|
);
|
|
174
|
-
return
|
|
216
|
+
return n != null ? /* @__PURE__ */ L(ke, { children: n }) : /* @__PURE__ */ L(Be, { style: F ? void 0 : { opacity: 0.7 }, children: a });
|
|
175
217
|
}
|
|
176
|
-
return /* @__PURE__ */
|
|
177
|
-
|
|
218
|
+
return /* @__PURE__ */ L(
|
|
219
|
+
Pe,
|
|
178
220
|
{
|
|
179
|
-
className:
|
|
180
|
-
id:
|
|
181
|
-
name:
|
|
182
|
-
type:
|
|
183
|
-
placeholder:
|
|
184
|
-
contentBefore:
|
|
185
|
-
contentAfter:
|
|
221
|
+
className: Se,
|
|
222
|
+
id: D,
|
|
223
|
+
name: D,
|
|
224
|
+
type: Ve,
|
|
225
|
+
placeholder: G.placeholder,
|
|
226
|
+
contentBefore: Fe,
|
|
227
|
+
contentAfter: we,
|
|
186
228
|
disabled: ge,
|
|
187
|
-
value:
|
|
188
|
-
"data-raw-value":
|
|
189
|
-
autoComplete:
|
|
229
|
+
value: F,
|
|
230
|
+
"data-raw-value": V,
|
|
231
|
+
autoComplete: Ce,
|
|
190
232
|
autoCorrect: "off",
|
|
191
233
|
autoCapitalize: "off",
|
|
192
234
|
spellCheck: "false",
|
|
193
|
-
onChange:
|
|
235
|
+
onChange: Re
|
|
194
236
|
}
|
|
195
237
|
);
|
|
196
238
|
};
|
|
197
239
|
export {
|
|
198
|
-
|
|
240
|
+
Je as EFWInput
|
|
199
241
|
};
|
|
@@ -75,7 +75,36 @@ export interface EFWInputValidationMessages {
|
|
|
75
75
|
* // Para RUT chileno
|
|
76
76
|
* const rutFormat: FormatType = 'chileanRut';
|
|
77
77
|
*/
|
|
78
|
-
export type FormatType =
|
|
78
|
+
export type FormatType = "none" | "phone" | "creditCard" | "chileanRut" | "date" | "custom" | "email" | "time";
|
|
79
|
+
export type EFWInputValidationTarget = "raw" | "formatted";
|
|
80
|
+
export interface EFWInputFormatValidationContext {
|
|
81
|
+
rawValue: string;
|
|
82
|
+
formattedValue: string;
|
|
83
|
+
}
|
|
84
|
+
export interface EFWInputFormatConfig {
|
|
85
|
+
/**
|
|
86
|
+
* Máscara visual. Usa `#` como placeholder de caracteres del valor crudo.
|
|
87
|
+
* Los caracteres estáticos se renderizan como decoración y se consumen del raw
|
|
88
|
+
* cuando coinciden, permitiendo máscaras como `+56 # #### ####` con raw `569...`.
|
|
89
|
+
*/
|
|
90
|
+
mask?: string;
|
|
91
|
+
/**
|
|
92
|
+
* Patrón usado para remover decoración y obtener el valor crudo.
|
|
93
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
94
|
+
*/
|
|
95
|
+
stripPattern?: RegExp | string;
|
|
96
|
+
/**
|
|
97
|
+
* Patrón usado para validar el valor crudo o formateado.
|
|
98
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
99
|
+
*/
|
|
100
|
+
validationPattern?: RegExp | string;
|
|
101
|
+
/** Valor sobre el que se aplican `validationPattern` y `validate`. Default: `raw`. */
|
|
102
|
+
validationTarget?: EFWInputValidationTarget;
|
|
103
|
+
/** Validador avanzado. Retornar string marca inválido y usa ese string como mensaje. */
|
|
104
|
+
validate?: (value: string, context: EFWInputFormatValidationContext) => boolean | string;
|
|
105
|
+
/** Mensaje de error usado cuando falla la validación de este formato. */
|
|
106
|
+
invalidMessage?: string;
|
|
107
|
+
}
|
|
79
108
|
/**
|
|
80
109
|
* Propiedades del componente EFWInput.
|
|
81
110
|
* Extiende las propiedades básicas de los campos EFW con funcionalidades específicas
|
|
@@ -141,7 +170,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
141
170
|
* @example
|
|
142
171
|
* autoComplete="off"
|
|
143
172
|
*/
|
|
144
|
-
autoComplete?:
|
|
173
|
+
autoComplete?: "on" | "off";
|
|
145
174
|
/**
|
|
146
175
|
* Valor actual del campo de entrada.
|
|
147
176
|
* Puede ser una cadena de texto o null para campos vacíos.
|
|
@@ -180,7 +209,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
180
209
|
* @example
|
|
181
210
|
* type="tel"
|
|
182
211
|
*/
|
|
183
|
-
type?:
|
|
212
|
+
type?: "text" | "password" | "email" | "number" | "tel";
|
|
184
213
|
/**
|
|
185
214
|
* Clases CSS adicionales aplicadas al componente.
|
|
186
215
|
* Permite personalizar la apariencia del campo de entrada.
|
|
@@ -211,6 +240,7 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
211
240
|
/**
|
|
212
241
|
* Patrón de expresión regular para validación personalizada.
|
|
213
242
|
* Se aplica cuando formatType es "custom" o para validaciones adicionales.
|
|
243
|
+
* Debe provenir de código/configuración confiable; no usar patrones editables por usuarios finales.
|
|
214
244
|
*
|
|
215
245
|
* @example
|
|
216
246
|
* formatPattern="^[A-Z]{2}[0-9]{6}$"
|
|
@@ -219,6 +249,20 @@ export interface EFWInputProps extends Partial<EFWFieldChildrenProps> {
|
|
|
219
249
|
* formatPattern="\\d{4}-\\d{4}-\\d{4}-\\d{4}"
|
|
220
250
|
*/
|
|
221
251
|
formatPattern?: string;
|
|
252
|
+
/**
|
|
253
|
+
* Configuración explícita de formato, normalización y validación.
|
|
254
|
+
* Es la API recomendada para formatos específicos de negocio.
|
|
255
|
+
*
|
|
256
|
+
* @example
|
|
257
|
+
* formatConfig={{
|
|
258
|
+
* mask: '+56 # #### ####',
|
|
259
|
+
* stripPattern: /\D/g,
|
|
260
|
+
* validationPattern: /^569\d{8}$/,
|
|
261
|
+
* validationTarget: 'raw',
|
|
262
|
+
* invalidMessage: 'Ingrese un teléfono móvil chileno válido.'
|
|
263
|
+
* }}
|
|
264
|
+
*/
|
|
265
|
+
formatConfig?: EFWInputFormatConfig;
|
|
222
266
|
/**
|
|
223
267
|
* Controla si el usuario puede editar el contenido del campo.
|
|
224
268
|
* Cuando es false, el campo se muestra como texto de solo lectura.
|
|
@@ -1,24 +1,44 @@
|
|
|
1
|
-
import { EFWInputValue, FormatType } from './EFWInput.types';
|
|
1
|
+
import { EFWInputFormatConfig, EFWInputValue, FormatType } from './EFWInput.types';
|
|
2
2
|
|
|
3
|
-
interface FormatOptions {
|
|
3
|
+
export interface FormatOptions {
|
|
4
4
|
formatPattern?: string;
|
|
5
5
|
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
6
|
+
formatConfig?: EFWInputFormatConfig;
|
|
7
|
+
}
|
|
8
|
+
export interface InputFormatValidationResult {
|
|
9
|
+
valid: boolean;
|
|
10
|
+
message?: string;
|
|
6
11
|
}
|
|
7
12
|
export declare const validateChileanRut: (rutCompleto: string) => boolean;
|
|
8
13
|
export declare const validateEmail: (email: string) => boolean;
|
|
9
14
|
export declare const validateTime: (time: string) => boolean;
|
|
15
|
+
export declare const toRegExp: (pattern: RegExp | string) => RegExp | undefined;
|
|
10
16
|
/**
|
|
11
17
|
* Verifica si un valor contiene solo caracteres válidos para aplicar formato visual.
|
|
12
18
|
*/
|
|
13
19
|
export declare const isFormattableValue: (value: string, formatType: FormatType) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Aplica una máscara visual usando `#` como placeholder de caracteres del raw.
|
|
22
|
+
* Los caracteres estáticos se consumen del raw si coinciden, lo que permite que
|
|
23
|
+
* una máscara con prefijo (`+56 # ...`) funcione con raw que incluye el prefijo (`569...`).
|
|
24
|
+
*/
|
|
25
|
+
export declare const applyMask: (rawValue: string, mask: string) => string;
|
|
26
|
+
export declare const stripInputValue: (value: string, formatType: FormatType, formatConfig?: EFWInputFormatConfig) => string;
|
|
27
|
+
export declare const applyInputFormatting: (value: string, formatType: FormatType, options?: FormatOptions) => string;
|
|
14
28
|
/**
|
|
15
29
|
* Quita el formato de un valor según el tipo especificado
|
|
16
30
|
*/
|
|
17
|
-
export declare const stripFormatting: (value: string, formatType: FormatType) => string;
|
|
31
|
+
export declare const stripFormatting: (value: string, formatType: FormatType, formatConfig?: EFWInputFormatConfig) => string;
|
|
18
32
|
/**
|
|
19
33
|
* Aplica formato a un valor según el tipo y opciones especificadas
|
|
20
34
|
*/
|
|
21
35
|
export declare const applyFormatting: (value: string, formatType: FormatType, options?: FormatOptions) => string;
|
|
36
|
+
export declare const validateInputFormat: ({ rawValue, formattedValue, formatConfig, defaultMessage, }: {
|
|
37
|
+
rawValue: string;
|
|
38
|
+
formattedValue: string;
|
|
39
|
+
formatConfig?: EFWInputFormatConfig;
|
|
40
|
+
defaultMessage: string;
|
|
41
|
+
}) => InputFormatValidationResult;
|
|
22
42
|
/**
|
|
23
43
|
* Retorna el valor formateado que EFWInput muestra cuando no está en modo editable.
|
|
24
44
|
* Combina stripFormatting + applyFormatting en una sola llamada.
|
|
@@ -26,5 +46,5 @@ export declare const applyFormatting: (value: string, formatType: FormatType, op
|
|
|
26
46
|
export declare const getInputFormattedValue: (value: EFWInputValue, formatType?: FormatType, options?: {
|
|
27
47
|
formatPattern?: string;
|
|
28
48
|
formatFunction?: (value: EFWInputValue) => EFWInputValue;
|
|
49
|
+
formatConfig?: EFWInputFormatConfig;
|
|
29
50
|
}) => string;
|
|
30
|
-
export {};
|