@algorithm-shift/design-system 1.3.118 → 1.3.119

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/index.mjs CHANGED
@@ -2534,6 +2534,13 @@ import { useEffect as useEffect18, useRef as useRef6 } from "react";
2534
2534
  import { PhoneInput as PhoneInputField } from "react-international-phone";
2535
2535
  import "react-international-phone/style.css";
2536
2536
  import { Fragment as Fragment14, jsx as jsx40, jsxs as jsxs22 } from "react/jsx-runtime";
2537
+ var ensureDialcode = (val) => {
2538
+ if (!val) return "";
2539
+ const trimmed = val.trim();
2540
+ if (trimmed.startsWith("+")) return trimmed;
2541
+ const local = trimmed.replace(/^0+/, "");
2542
+ return `+91${local}`;
2543
+ };
2537
2544
  var PhoneInput = ({ className, style, ...props }) => {
2538
2545
  const ref = useRef6(null);
2539
2546
  const placeholder = props.placeholder ?? "Enter phone number";
@@ -2541,7 +2548,7 @@ var PhoneInput = ({ className, style, ...props }) => {
2541
2548
  const isDisabled = props.isDisabled ?? false;
2542
2549
  useEffect18(() => {
2543
2550
  if (props.value !== void 0) {
2544
- handleChange?.(props.value, ref.current?.state);
2551
+ handleChange?.(ensureDialcode(props.value), ref.current?.state);
2545
2552
  }
2546
2553
  }, []);
2547
2554
  const handleChange = (value, meta) => {
@@ -2559,9 +2566,9 @@ var PhoneInput = ({ className, style, ...props }) => {
2559
2566
  PhoneInputField,
2560
2567
  {
2561
2568
  ref,
2562
- defaultCountry: "in",
2569
+ defaultCountry: props.defaultCountry || "in",
2563
2570
  name: props.name,
2564
- value: props.value ? props.value : "",
2571
+ value: props.value ? ensureDialcode(props.value) : "",
2565
2572
  className: cn(
2566
2573
  "rounded-md border-1",
2567
2574
  className,