ingeniuscliq-core 0.5.37 → 0.5.39
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.
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { InputExtendedProps } from '../../ui/input';
|
|
2
|
+
import { Select } from '../../ui/select';
|
|
2
3
|
import { BaseStyleProps } from '../../../types/ui/main';
|
|
3
4
|
import { Control, FieldValues, Path, UseFormSetValue } from 'react-hook-form';
|
|
4
5
|
interface FormPhoneProps<T extends FieldValues = FieldValues> extends BaseStyleProps {
|
|
@@ -18,7 +19,8 @@ interface FormPhoneProps<T extends FieldValues = FieldValues> extends BaseStyleP
|
|
|
18
19
|
readonly countryCodeFieldName?: string;
|
|
19
20
|
readonly phoneNumberFieldName?: string;
|
|
20
21
|
readonly initialCountryCode?: string;
|
|
22
|
+
readonly selectProps?: React.ComponentProps<typeof Select>;
|
|
21
23
|
}
|
|
22
|
-
export declare function FormPhone<T extends FieldValues = FieldValues>({ control, name, label, customLabel, placeholder, className, inputProps, withinLabel, withinMessage, withinControl, required, withoutPlaceholder, setValue, watch, countryCodeFieldName, phoneNumberFieldName, initialCountryCode }: FormPhoneProps<T>): import("react").JSX.Element;
|
|
24
|
+
export declare function FormPhone<T extends FieldValues = FieldValues>({ control, name, label, customLabel, placeholder, className, inputProps, withinLabel, withinMessage, withinControl, required, withoutPlaceholder, setValue, watch, countryCodeFieldName, phoneNumberFieldName, initialCountryCode, selectProps }: FormPhoneProps<T>): import("react").JSX.Element;
|
|
23
25
|
export {};
|
|
24
26
|
//# sourceMappingURL=FormPhone.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FormPhone.d.ts","sourceRoot":"","sources":["../../../../src/components/common/form/FormPhone.tsx"],"names":[],"mappings":"AACA,OAAO,EAAS,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;
|
|
1
|
+
{"version":3,"file":"FormPhone.d.ts","sourceRoot":"","sources":["../../../../src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AC,EAAE,MAAM,CAAC;IACvC,QAAQ,CAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IACrC,QAAQ,CAAC,WAAW,CAAC,EAAE,KAAK,CAAC,cAAc,CAAC,OAAO,MAAM,CAAC,CAAC;CAC5D;AAED,wBAAgB,SAAS,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,EAAE,EAC7D,OAAO,EACP,IAAI,EACJ,KAAiB,EACjB,WAAuB,EACvB,WAAgB,EAChB,SAAc,EACd,UAAe,EACf,WAAmB,EACnB,aAAqB,EACrB,aAAqB,EACrB,QAAgB,EAChB,kBAA0B,EAC1B,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EAClB,WAAgB,EACjB,EAAE,cAAc,CAAC,CAAC,CAAC,+BAyJnB"}
|
|
@@ -30,7 +30,8 @@ function FormPhone({
|
|
|
30
30
|
watch,
|
|
31
31
|
countryCodeFieldName,
|
|
32
32
|
phoneNumberFieldName,
|
|
33
|
-
initialCountryCode
|
|
33
|
+
initialCountryCode,
|
|
34
|
+
selectProps = {}
|
|
34
35
|
}) {
|
|
35
36
|
const { t, language } = useLanguage();
|
|
36
37
|
const countryCodes = useMemo(() => {
|
|
@@ -110,7 +111,7 @@ function FormPhone({
|
|
|
110
111
|
withinLabel,
|
|
111
112
|
withinMessage,
|
|
112
113
|
withinControl,
|
|
113
|
-
render: () => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 w-full", children: [
|
|
114
|
+
render: (field) => /* @__PURE__ */ jsxs("div", { className: "flex gap-2 w-full", children: [
|
|
114
115
|
/* @__PURE__ */ jsxs(
|
|
115
116
|
Select,
|
|
116
117
|
{
|
|
@@ -123,6 +124,7 @@ function FormPhone({
|
|
|
123
124
|
// Usar el código ISO guardado para encontrar el país exacto seleccionado
|
|
124
125
|
watch(selectedCountryField) ? countryCodes.find((c) => c.countryCode === watch(selectedCountryField))?.value || "" : ""
|
|
125
126
|
),
|
|
127
|
+
...selectProps,
|
|
126
128
|
children: [
|
|
127
129
|
/* @__PURE__ */ jsx(SelectTrigger, { className: cn("!h-full", inputProps?.className), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "+53", children: watch(countryCodeField) || "+53" }) }),
|
|
128
130
|
/* @__PURE__ */ jsx(SelectContent, { children: countryCodes.map((option) => /* @__PURE__ */ jsx(
|
|
@@ -143,7 +145,18 @@ function FormPhone({
|
|
|
143
145
|
type: "tel",
|
|
144
146
|
required,
|
|
145
147
|
value: watch(phoneNumberField) || "",
|
|
146
|
-
onChange: (e) =>
|
|
148
|
+
onChange: (e) => {
|
|
149
|
+
const phoneNumber = e.target.value.replace(/[^\d]/g, "");
|
|
150
|
+
setValue(phoneNumberField, phoneNumber);
|
|
151
|
+
const countryCode = watch(countryCodeField);
|
|
152
|
+
if (countryCode) {
|
|
153
|
+
const fullNumber = phoneNumber ? `${countryCode}${phoneNumber}` : "";
|
|
154
|
+
field.onChange(fullNumber);
|
|
155
|
+
}
|
|
156
|
+
},
|
|
157
|
+
onBlur: field.onBlur,
|
|
158
|
+
name: field.name,
|
|
159
|
+
ref: field.ref,
|
|
147
160
|
className: cn("flex-1", inputProps?.className)
|
|
148
161
|
}
|
|
149
162
|
)
|