@envisiongroup/porygon 1.0.0-rc.40 → 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.
Files changed (23) hide show
  1. package/dist/index.js +53 -49
  2. package/dist/react-components/fields/DatePicker/EFWDatePicker.utils.js +1 -1
  3. package/dist/react-components/fields/Input/EFWInput.d.ts +5 -20
  4. package/dist/react-components/fields/Input/EFWInput.js +193 -151
  5. package/dist/react-components/fields/Input/EFWInput.types.d.ts +47 -3
  6. package/dist/react-components/fields/Input/EFWInput.utils.d.ts +24 -4
  7. package/dist/react-components/fields/Input/EFWInput.utils.js +103 -53
  8. package/dist/react-components/fields/Input/EFWInput.validation.d.ts +20 -0
  9. package/dist/react-components/fields/Input/EFWInput.validation.js +62 -0
  10. package/dist/react-components/fields/Input/EFWInputField.js +28 -26
  11. package/dist/react-components/fields/Input/index.d.ts +2 -2
  12. package/dist/react-components/fields/NumberInput/EFWNumberInput.utils.d.ts +1 -1
  13. package/dist/react-components/fields/NumberInput/EFWNumberInput.utils.js +52 -46
  14. package/dist/react-components/fields/TextArea/EFWTextArea.utils.d.ts +1 -1
  15. package/dist/react-components/fields/test-utils/testUtils.js +10 -0
  16. package/dist/react-components/forms/EFWForm/EFWForm.converter.js +19 -10
  17. package/dist/react-components/forms/EFWForm/EFWForm.flatConverter.d.ts +130 -0
  18. package/dist/react-components/forms/EFWForm/EFWForm.flatConverter.js +279 -0
  19. package/dist/react-components/forms/EFWForm/EFWForm.utils.js +83 -43
  20. package/dist/react-components/forms/EFWForm/index.d.ts +2 -0
  21. package/dist/react-components/forms/EFWForm/index.js +8 -4
  22. package/dist/vite-raw.d.js +0 -0
  23. package/package.json +21 -5
package/dist/index.js CHANGED
@@ -1,17 +1,17 @@
1
- import { formatFileSize as o, getErrorMessage as t, getFileIconUrl as m } from "./react-components/commons/utils.js";
1
+ import { formatFileSize as o, getErrorMessage as t, getFileIconUrl as F } from "./react-components/commons/utils.js";
2
2
  import { EFWMessageBarManager as a } from "./react-components/forms/EFWMessageBarManager/EFWMessageBarManager.js";
3
- import { EFWButton as E } from "./react-components/buttons/EFWButton/EFWButton.js";
4
- import { useEFWButton as f } from "./react-components/buttons/EFWButton/EFWButton.hooks.js";
3
+ import { EFWButton as p } from "./react-components/buttons/EFWButton/EFWButton.js";
4
+ import { useEFWButton as l } from "./react-components/buttons/EFWButton/EFWButton.hooks.js";
5
5
  import { EFWDrawerButton as u } from "./react-components/buttons/EFWDrawerButton/EFWDrawerButton.js";
6
6
  import { EFWGroupButton as i } from "./react-components/buttons/EFWGroupButton/EFWGroupButton.js";
7
- import { EFWField as W } from "./react-components/fields/_shared/EFWField/EFWField.js";
7
+ import { EFWField as L } from "./react-components/fields/_shared/EFWField/EFWField.js";
8
8
  import { EFWAttachment as s } from "./react-components/fields/Attachments/EFWAttachments.js";
9
9
  import { getAttachmentsFormattedValue as g } from "./react-components/fields/Attachments/EFWAttachments.utils.js";
10
10
  import { EFWAttachmentsField as d } from "./react-components/fields/Attachments/EFWAttachmentsField.js";
11
11
  import { EFWDatePicker as O } from "./react-components/fields/DatePicker/EFWDatePicker.js";
12
- import { enLocalizedStrings as D, esLocalizedStrings as B, getDatePickerFormattedValue as S, ptLocalizedStrings as C } from "./react-components/fields/DatePicker/EFWDatePicker.utils.js";
12
+ import { enLocalizedStrings as D, esLocalizedStrings as B, getDatePickerFormattedValue as C, ptLocalizedStrings as S } from "./react-components/fields/DatePicker/EFWDatePicker.utils.js";
13
13
  import { EFWDatePickerField as N } from "./react-components/fields/DatePicker/EFWDatePickerField.js";
14
- import { EFWInput as V } from "./react-components/fields/Input/EFWInput.js";
14
+ import { EFWInput as b } from "./react-components/fields/Input/EFWInput.js";
15
15
  import { getInputFormattedValue as k } from "./react-components/fields/Input/EFWInput.utils.js";
16
16
  import { EFWInputField as R } from "./react-components/fields/Input/EFWInputField.js";
17
17
  import { EFWNumberInput as w } from "./react-components/fields/NumberInput/EFWNumberInput.js";
@@ -24,76 +24,80 @@ import { EFWTagPicker as Q } from "./react-components/fields/TagPicker/EFWTagPic
24
24
  import { getTagPickerFormattedValue as $ } from "./react-components/fields/TagPicker/EFWTagPicker.utils.js";
25
25
  import { EFWTagPickerField as re } from "./react-components/fields/TagPicker/EFWTagPickerField.js";
26
26
  import { EFWTextArea as te } from "./react-components/fields/TextArea/EFWTextArea.js";
27
- import { getTextAreaFormattedValue as Fe } from "./react-components/fields/TextArea/EFWTextArea.utils.js";
28
- import { EFWTextAreaField as pe } from "./react-components/fields/TextArea/EFWTextAreaField.js";
27
+ import { getTextAreaFormattedValue as me } from "./react-components/fields/TextArea/EFWTextArea.utils.js";
28
+ import { EFWTextAreaField as Ee } from "./react-components/fields/TextArea/EFWTextAreaField.js";
29
29
  import { getFormFieldDisplayText as xe } from "./react-components/forms/EFWForm/EFWForm.converter.js";
30
- import { useFormController as le } from "./react-components/forms/EFWForm/EFWForm.hooks.js";
30
+ import { useFormController as fe } from "./react-components/forms/EFWForm/EFWForm.hooks.js";
31
31
  import { EFWForm as Te } from "./react-components/forms/EFWForm/EFWForm.js";
32
- import { EFWFormMessageBarGroup as Le } from "./react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.js";
33
- import { useDrawer as ne } from "./react-components/hooks/useDrawer/useDrawer.js";
34
- import { PorygonI18nProvider as _e, useButtonsLocaleText as ge, useFieldsLocaleText as ce, useFormLocaleText as de, usePorygonLocaleText as Ae, useTableLocaleText as Oe } from "./react-components/i18n/PorygonI18nProvider.js";
35
- import { DEFAULT_EFW_BUTTONS_LOCALE_TEXT as De, DEFAULT_EFW_FIELDS_LOCALE_TEXT as Be, DEFAULT_EFW_FORM_LOCALE_TEXT as Se, DEFAULT_EFW_TABLE_LOCALE_TEXT as Ce } from "./react-components/i18n/defaultLocaleText.js";
36
- import { PORYGON_LOCALES as Ne, PORYGON_LOCALE_EN as be, PORYGON_LOCALE_ES as Ve, PORYGON_LOCALE_PT_BR as he } from "./react-components/i18n/localePresets.js";
37
- import { EFWTable as Ge } from "./react-components/tables/EFWTable/EFWTable.js";
38
- import { useTableController as Ue } from "./react-components/tables/EFWTable/hooks/useTableController/useTableController.js";
39
- import { useDefaultFilterButton as ye } from "./react-components/tables/EFWTable/hooks/useDefaultFilterButton/useDefaultFilterButton.js";
40
- import { EFWTableEmpty as ze, EFWTableOverlay as Xe } from "./react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.js";
32
+ import { EFWConversionError as We, EFWValuesToFlat as Le, flatToEFWValues as ne } from "./react-components/forms/EFWForm/EFWForm.flatConverter.js";
33
+ import { EFWFormMessageBarGroup as _e } from "./react-components/forms/EFWFormMessageBarGroup/EFWFormMessageBarGroup.js";
34
+ import { useDrawer as ce } from "./react-components/hooks/useDrawer/useDrawer.js";
35
+ import { PorygonI18nProvider as Ae, useButtonsLocaleText as Oe, useFieldsLocaleText as Pe, useFormLocaleText as De, usePorygonLocaleText as Be, useTableLocaleText as Ce } from "./react-components/i18n/PorygonI18nProvider.js";
36
+ import { DEFAULT_EFW_BUTTONS_LOCALE_TEXT as Ie, DEFAULT_EFW_FIELDS_LOCALE_TEXT as Ne, DEFAULT_EFW_FORM_LOCALE_TEXT as Ve, DEFAULT_EFW_TABLE_LOCALE_TEXT as be } from "./react-components/i18n/defaultLocaleText.js";
37
+ import { PORYGON_LOCALES as ke, PORYGON_LOCALE_EN as Ge, PORYGON_LOCALE_ES as Re, PORYGON_LOCALE_PT_BR as Ue } from "./react-components/i18n/localePresets.js";
38
+ import { EFWTable as ye } from "./react-components/tables/EFWTable/EFWTable.js";
39
+ import { useTableController as ze } from "./react-components/tables/EFWTable/hooks/useTableController/useTableController.js";
40
+ import { useDefaultFilterButton as Ye } from "./react-components/tables/EFWTable/hooks/useDefaultFilterButton/useDefaultFilterButton.js";
41
+ import { EFWTableEmpty as je, EFWTableOverlay as qe } from "./react-components/tables/EFWTable/components/EFWTableOverlay/EFWTableOverlay.js";
41
42
  export {
42
- De as DEFAULT_EFW_BUTTONS_LOCALE_TEXT,
43
- Be as DEFAULT_EFW_FIELDS_LOCALE_TEXT,
44
- Se as DEFAULT_EFW_FORM_LOCALE_TEXT,
45
- Ce as DEFAULT_EFW_TABLE_LOCALE_TEXT,
43
+ Ie as DEFAULT_EFW_BUTTONS_LOCALE_TEXT,
44
+ Ne as DEFAULT_EFW_FIELDS_LOCALE_TEXT,
45
+ Ve as DEFAULT_EFW_FORM_LOCALE_TEXT,
46
+ be as DEFAULT_EFW_TABLE_LOCALE_TEXT,
46
47
  s as EFWAttachment,
47
48
  d as EFWAttachmentsField,
48
- E as EFWButton,
49
+ p as EFWButton,
50
+ We as EFWConversionError,
49
51
  O as EFWDatePicker,
50
52
  N as EFWDatePickerField,
51
53
  u as EFWDrawerButton,
52
- W as EFWField,
54
+ L as EFWField,
53
55
  Te as EFWForm,
54
- Le as EFWFormMessageBarGroup,
56
+ _e as EFWFormMessageBarGroup,
55
57
  i as EFWGroupButton,
56
- V as EFWInput,
58
+ b as EFWInput,
57
59
  R as EFWInputField,
58
60
  a as EFWMessageBarManager,
59
61
  w as EFWNumberInput,
60
62
  X as EFWNumberInputField,
61
63
  v as EFWSwitch,
62
64
  J as EFWSwitchField,
63
- Ge as EFWTable,
64
- ze as EFWTableEmpty,
65
- Xe as EFWTableOverlay,
65
+ ye as EFWTable,
66
+ je as EFWTableEmpty,
67
+ qe as EFWTableOverlay,
66
68
  Q as EFWTagPicker,
67
69
  re as EFWTagPickerField,
68
70
  te as EFWTextArea,
69
- pe as EFWTextAreaField,
70
- Ne as PORYGON_LOCALES,
71
- be as PORYGON_LOCALE_EN,
72
- Ve as PORYGON_LOCALE_ES,
73
- he as PORYGON_LOCALE_PT_BR,
74
- _e as PorygonI18nProvider,
71
+ Ee as EFWTextAreaField,
72
+ Le as EFWValuesToFlat,
73
+ ke as PORYGON_LOCALES,
74
+ Ge as PORYGON_LOCALE_EN,
75
+ Re as PORYGON_LOCALE_ES,
76
+ Ue as PORYGON_LOCALE_PT_BR,
77
+ Ae as PorygonI18nProvider,
75
78
  D as enLocalizedStrings,
76
79
  B as esLocalizedStrings,
80
+ ne as flatToEFWValues,
77
81
  o as formatFileSize,
78
82
  g as getAttachmentsFormattedValue,
79
- S as getDatePickerFormattedValue,
83
+ C as getDatePickerFormattedValue,
80
84
  t as getErrorMessage,
81
- m as getFileIconUrl,
85
+ F as getFileIconUrl,
82
86
  xe as getFormFieldDisplayText,
83
87
  k as getInputFormattedValue,
84
88
  M as getNumberInputFormattedValue,
85
89
  q as getSwitchFormattedValue,
86
90
  $ as getTagPickerFormattedValue,
87
- Fe as getTextAreaFormattedValue,
88
- C as ptLocalizedStrings,
89
- ge as useButtonsLocaleText,
90
- ye as useDefaultFilterButton,
91
- ne as useDrawer,
92
- f as useEFWButton,
93
- ce as useFieldsLocaleText,
94
- le as useFormController,
95
- de as useFormLocaleText,
96
- Ae as usePorygonLocaleText,
97
- Ue as useTableController,
98
- Oe as useTableLocaleText
91
+ me as getTextAreaFormattedValue,
92
+ S as ptLocalizedStrings,
93
+ Oe as useButtonsLocaleText,
94
+ Ye as useDefaultFilterButton,
95
+ ce as useDrawer,
96
+ l as useEFWButton,
97
+ Pe as useFieldsLocaleText,
98
+ fe as useFormController,
99
+ De as useFormLocaleText,
100
+ Be as usePorygonLocaleText,
101
+ ze as useTableController,
102
+ Ce as useTableLocaleText
99
103
  };
@@ -138,7 +138,7 @@ const i = (t) => ({
138
138
  return `${a}/${u}/${n}`;
139
139
  }
140
140
  }, d = (t) => {
141
- if (t instanceof Date) return t;
141
+ if (t instanceof Date) return s(t) ? t : null;
142
142
  if (typeof t == "string")
143
143
  try {
144
144
  const e = new Date(t);
@@ -1,25 +1,10 @@
1
1
  import { EFWInputProps } from './EFWInput.types';
2
2
 
3
3
  /**
4
- * Componente de entrada de texto personalizado con soporte para formateo y validación.
5
- * Permite manejar valores con formatos específicos (como RUT chileno, correo electrónico, números) y valida la entrada del usuario.
6
- * @param {EFWInputProps} props - Propiedades del componente.
7
- * @param {string} [props.value=""] - Valor inicial del input.
8
- * @param {(rawValue: string, formattedValue: string) => void} [props.onChange] - Función llamada cuando cambia el valor del input.
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 M, Fragment as Be } from "react/jsx-runtime";
2
- import { makeStyles as Pe, tokens as v, mergeClasses as Te, Text as We, Input as De } from "@fluentui/react-components";
3
- import { useId as Ne, useRef as Ve, useState as fe, useMemo as h, useCallback as z, useEffect as C } from "react";
4
- import { stripFormatting as f, getInputFormattedValue as B, isFormattableValue as Oe, validateChileanRut as je, validateEmail as Ae, applyFormatting as P, validateTime as _e } from "./EFWInput.utils.js";
5
- import { useFieldsLocaleText as qe } from "../../i18n/PorygonI18nProvider.js";
6
- const Ge = Pe({
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: v.colorPaletteRedBackground1,
9
+ backgroundColor: I.colorPaletteRedBackground1,
9
10
  "::after": {
10
- borderBottomColor: v.colorPaletteRedBorder2,
11
+ borderBottomColor: I.colorPaletteRedBorder2,
11
12
  borderBottomStyle: "solid",
12
13
  borderBottomWidth: "2px"
13
14
  }
14
15
  },
15
16
  efwInput: {
16
17
  "& [disabled]": {
17
- backgroundColor: v.colorNeutralBackground3,
18
- color: v.colorNeutralForeground2,
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: v.colorNeutralBackground3
26
+ backgroundColor: I.colorNeutralBackground3
26
27
  }
27
28
  }
28
- }), Ue = (Ie) => {
29
+ }), Je = (ve) => {
29
30
  const {
30
- value: c,
31
- defaultValue: T,
32
- onChange: W,
33
- editable: pe = !0,
31
+ value: d,
32
+ defaultValue: R,
33
+ onChange: S,
34
+ editable: he = !0,
34
35
  disabled: ge = !1,
35
- className: Ce = "",
36
- autoComplete: be = "off",
37
- type: Fe = "text",
38
- contentBefore: xe,
39
- contentAfter: ye,
40
- formatType: t = "none",
41
- formatPattern: u,
42
- formatFunction: b,
43
- minLength: I = 0,
44
- maxLength: F = 250,
45
- labels: D,
46
- readOnlyRenderer: Le,
47
- validationMessages: o,
48
- validationState: Se = "none",
49
- setParentComponentState: r
50
- } = Ie, a = c !== void 0, N = (a ? c : T) ?? "", p = T ?? "", V = Ge(), O = Ne(), j = Ve(!1), [m, A] = fe(() => f(N, t)), [Ee, x] = fe(() => B(N, t, { formatPattern: u, formatFunction: b })), d = h(
51
- () => ({ formatPattern: u, formatFunction: b }),
52
- [u, b]
53
- ), _ = qe(), q = _.input.labels, i = _.input.validationMessages, G = q.placeholder, H = q.emptyState, J = D?.placeholder, K = D?.emptyState, Q = h(() => ({
54
- placeholder: J ?? G,
55
- emptyState: K ?? H
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
- J,
58
- K,
59
- G,
60
- H
61
- ]), R = i.minLength, U = i.maxLength, X = i.phoneInvalid, Y = i.creditCardInvalid, Z = i.chileanRutInvalid, $ = i.dateInvalid, w = i.dateInvalidWithFormat, ee = i.timeInvalid, te = i.emailInvalid, ae = i.formatInvalid, ne = o?.minLength, le = o?.maxLength, re = o?.phoneInvalid, oe = o?.creditCardInvalid, ie = o?.chileanRutInvalid, de = o?.dateInvalid, se = o?.dateInvalidWithFormat, ce = o?.timeInvalid, ue = o?.emailInvalid, me = o?.formatInvalid, n = h(() => ({
62
- minLength: ne ?? R,
63
- maxLength: le ?? U,
64
- phoneInvalid: re ?? X,
65
- creditCardInvalid: oe ?? Y,
66
- chileanRutInvalid: ie ?? Z,
67
- dateInvalid: de ?? $,
68
- dateInvalidWithFormat: se ?? w,
69
- timeInvalid: ce ?? ee,
70
- emailInvalid: ue ?? te,
71
- formatInvalid: me ?? ae
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
- ue,
82
- me,
83
- R,
93
+ H,
94
+ J,
95
+ K,
96
+ Q,
84
97
  U,
85
98
  X,
86
99
  Y,
87
100
  Z,
88
101
  $,
89
- w,
90
- ee,
91
- te,
92
- ae
93
- ]), g = h(
94
- () => f(p, t),
95
- [p, t]
96
- ), y = h(
97
- () => B(p, t, d),
98
- [p, t, d]
99
- ), he = h(() => {
100
- if (!a)
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 e = f(c ?? "", t), l = B(c, t, d);
103
- return { raw: e, formatted: l };
104
- }, [a, c, t, d]), L = a ? he.raw : m, S = a ? he.formatted : Ee, ve = z((e) => {
105
- if (t === "none" || !u) return !0;
106
- try {
107
- return new RegExp(u).test(e);
108
- } catch {
109
- return !1;
110
- }
111
- }, [t, u]), s = z((e) => {
112
- if (I > 0 && e.length > 0 && e.length < I)
113
- return r?.("error", n.minLength(I)), !0;
114
- if (e.length > F)
115
- return r?.("error", n.maxLength(F)), !0;
116
- if (e.length > 0 && !Oe(e, t)) {
117
- const l = {
118
- phone: n.phoneInvalid,
119
- creditCard: n.creditCardInvalid,
120
- chileanRut: n.chileanRutInvalid,
121
- date: n.dateInvalid,
122
- time: n.timeInvalid
123
- };
124
- return r?.("error", l[t] || n.formatInvalid), !0;
125
- } else {
126
- if (t === "chileanRut" && e.length > 0 && !je(e))
127
- return r?.("error", n.chileanRutInvalid), !0;
128
- if (t === "phone" && e.length > 0 && (e.length < 7 || e.length > 15))
129
- return r?.("error", n.phoneInvalid), !0;
130
- if (t === "creditCard" && e.length > 0 && (e.length < 13 || e.length > 19))
131
- return r?.("error", n.creditCardInvalid), !0;
132
- if (t === "date" && e.length > 0 && e.length !== 8)
133
- return r?.("error", n.dateInvalidWithFormat), !0;
134
- if (t === "email" && e.length > 0 && !Ae(e))
135
- return r?.("error", n.emailInvalid), !0;
136
- if (t === "time" && e.length > 0) {
137
- const l = P(e, t, {});
138
- return e.length !== 4 || !_e(l) ? (r?.("error", n.timeInvalid), !0) : (r?.("none", ""), !1);
139
- } else return ve(e) ? (r?.("none", ""), !1) : (r?.("error", n.formatInvalid), !0);
140
- }
141
- }, [I, F, t, ve, r, n]);
142
- C(() => {
143
- a && s(L);
144
- }, [a, L, s]), C(() => {
145
- a || (A((e) => e === g ? e : g), x((e) => e === y ? e : y), s(g));
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
- a,
148
- g,
149
- y,
163
+ t,
164
+ v,
165
+ C,
150
166
  s
151
- ]), C(() => {
152
- a || x((e) => {
153
- const l = P(m, t, d);
154
- return l === e ? e : l;
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
- }, [a, m, t, d]), C(() => {
157
- a || j.current || (j.current = !0, s(m));
158
- }, [a, m, s]);
159
- const ke = z((e, l) => {
160
- if (typeof l.value == "string") {
161
- const ze = f(l.value, t), E = P(ze, t, d), k = f(E, t);
162
- s(k), a || (A(k), x(E)), W?.(k, E);
163
- }
164
- }, [t, d, W, s, a]), Me = Te(
165
- Ce,
166
- V.efwInput,
167
- Se === "error" && V.efwInputError
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 (!pe) {
170
- const e = S || Q.emptyState, l = Le?.(
171
- a ? c : m,
172
- e
211
+ if (!he) {
212
+ const a = F || G.emptyState, n = ye?.(
213
+ t ? d : c,
214
+ a
173
215
  );
174
- return l != null ? /* @__PURE__ */ M(Be, { children: l }) : /* @__PURE__ */ M(We, { style: S ? void 0 : { opacity: 0.7 }, children: e });
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__ */ M(
177
- De,
218
+ return /* @__PURE__ */ L(
219
+ Pe,
178
220
  {
179
- className: Me,
180
- id: O,
181
- name: O,
182
- type: Fe,
183
- placeholder: Q.placeholder,
184
- contentBefore: xe,
185
- contentAfter: ye,
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: S,
188
- "data-raw-value": L,
189
- autoComplete: be,
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: ke
235
+ onChange: Re
194
236
  }
195
237
  );
196
238
  };
197
239
  export {
198
- Ue as EFWInput
240
+ Je as EFWInput
199
241
  };