ingeniuscliq-core 0.5.36 → 0.5.37

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.
@@ -17,7 +17,8 @@ interface FormPhoneProps<T extends FieldValues = FieldValues> extends BaseStyleP
17
17
  readonly watch: (name: Path<T>) => any;
18
18
  readonly countryCodeFieldName?: string;
19
19
  readonly phoneNumberFieldName?: string;
20
+ readonly initialCountryCode?: string;
20
21
  }
21
- export declare function FormPhone<T extends FieldValues = FieldValues>({ control, name, label, customLabel, placeholder, className, inputProps, withinLabel, withinMessage, withinControl, required, withoutPlaceholder, setValue, watch, countryCodeFieldName, phoneNumberFieldName }: FormPhoneProps<T>): import("react").JSX.Element;
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;
22
23
  export {};
23
24
  //# 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;AAGlE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,KAAK,EAAE,OAAO,EAAE,WAAW,EAAE,IAAI,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAC;AAWnF,UAAU,cAAc,CAAC,CAAC,SAAS,WAAW,GAAG,WAAW,CAAE,SAAQ,cAAc;IAClF,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC,CAAC,CAAC,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,IAAI,CAAC,CAAC,CAAC,CAAC;IACvB,QAAQ,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IACxB,QAA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EAChB,SAAc,EACd,UAAe,EACf,WAAmB,EACnB,aAAqB,EACrB,aAAqB,EACrB,QAAgB,EAChB,kBAA0B,EAC1B,QAAQ,EACR,KAAK,EACL,oBAAoB,EACpB,oBAAoB,EACpB,kBAAkB,EACnB,EAAE,cAAc,CAAC,CAAC,CAAC,+BA2InB"}
@@ -29,7 +29,8 @@ function FormPhone({
29
29
  setValue,
30
30
  watch,
31
31
  countryCodeFieldName,
32
- phoneNumberFieldName
32
+ phoneNumberFieldName,
33
+ initialCountryCode
33
34
  }) {
34
35
  const { t, language } = useLanguage();
35
36
  const countryCodes = useMemo(() => {
@@ -55,6 +56,15 @@ function FormPhone({
55
56
  const countryCodeField = countryCodeFieldName || "country_code";
56
57
  const phoneNumberField = phoneNumberFieldName || "phone_number";
57
58
  const selectedCountryField = "selected_country_iso";
59
+ useEffect(() => {
60
+ if (initialCountryCode && !watch(countryCodeField) && !watch(name)) {
61
+ const country = countryCodes.find((c) => c.countryCode === initialCountryCode);
62
+ if (country) {
63
+ setValue(countryCodeField, country.callingCode);
64
+ setValue(selectedCountryField, country.countryCode);
65
+ }
66
+ }
67
+ }, [initialCountryCode, countryCodes]);
58
68
  useEffect(() => {
59
69
  const countryCode = watch(countryCodeField);
60
70
  const phoneNumber = watch(phoneNumberField);
@@ -114,7 +124,7 @@ function FormPhone({
114
124
  watch(selectedCountryField) ? countryCodes.find((c) => c.countryCode === watch(selectedCountryField))?.value || "" : ""
115
125
  ),
116
126
  children: [
117
- /* @__PURE__ */ jsx(SelectTrigger, { className: cn("w-35 !h-full", inputProps?.className), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "+53" }) }),
127
+ /* @__PURE__ */ jsx(SelectTrigger, { className: cn("!h-full", inputProps?.className), children: /* @__PURE__ */ jsx(SelectValue, { placeholder: "+53", children: watch(countryCodeField) || "+53" }) }),
118
128
  /* @__PURE__ */ jsx(SelectContent, { children: countryCodes.map((option) => /* @__PURE__ */ jsx(
119
129
  SelectItem,
120
130
  {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "ingeniuscliq-core",
3
- "version": "0.5.36",
3
+ "version": "0.5.37",
4
4
  "description": "IngeniusCliq Core UI y lógica compartida",
5
5
  "license": "MIT",
6
6
  "type": "module",