@chekinapp/ui 0.0.140 → 0.0.142

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.d.cts CHANGED
@@ -2882,7 +2882,7 @@ type PhoneInputHandle = {
2882
2882
  };
2883
2883
  type PhoneInputProps = {
2884
2884
  options: PhoneInputOption[];
2885
- value?: PhoneInputValue | null;
2885
+ value?: string | number | PhoneInputValue | null;
2886
2886
  onChange?: (value: PhoneInputValue, name?: string) => void;
2887
2887
  onFocus?: React$1.FocusEventHandler<HTMLInputElement>;
2888
2888
  onBlur?: React$1.FocusEventHandler<HTMLInputElement>;
@@ -2906,6 +2906,7 @@ type PhoneInputProps = {
2906
2906
  autoDetectCode?: boolean;
2907
2907
  searchable?: boolean;
2908
2908
  defaultCode?: string;
2909
+ defaultNumber?: string;
2909
2910
  };
2910
2911
  declare const PhoneInput: React$1.ForwardRefExoticComponent<PhoneInputProps & React$1.RefAttributes<PhoneInputHandle>>;
2911
2912
 
package/dist/index.d.ts CHANGED
@@ -2882,7 +2882,7 @@ type PhoneInputHandle = {
2882
2882
  };
2883
2883
  type PhoneInputProps = {
2884
2884
  options: PhoneInputOption[];
2885
- value?: PhoneInputValue | null;
2885
+ value?: string | number | PhoneInputValue | null;
2886
2886
  onChange?: (value: PhoneInputValue, name?: string) => void;
2887
2887
  onFocus?: React$1.FocusEventHandler<HTMLInputElement>;
2888
2888
  onBlur?: React$1.FocusEventHandler<HTMLInputElement>;
@@ -2906,6 +2906,7 @@ type PhoneInputProps = {
2906
2906
  autoDetectCode?: boolean;
2907
2907
  searchable?: boolean;
2908
2908
  defaultCode?: string;
2909
+ defaultNumber?: string;
2909
2910
  };
2910
2911
  declare const PhoneInput: React$1.ForwardRefExoticComponent<PhoneInputProps & React$1.RefAttributes<PhoneInputHandle>>;
2911
2912
 
package/dist/index.js CHANGED
@@ -14136,6 +14136,30 @@ var Select = React49.forwardRef(SelectInternal);
14136
14136
 
14137
14137
  // src/dashboard/phone-input/utils.ts
14138
14138
  var PREFIX_REGEX = /^\+/;
14139
+ function isPhoneInputValue(value) {
14140
+ if (typeof value === "string" || typeof value === "number") {
14141
+ return false;
14142
+ }
14143
+ return Boolean(value && ("code" in value || "number" in value));
14144
+ }
14145
+ function getPhoneValuePart(value) {
14146
+ if (typeof value === "string" || typeof value === "number") {
14147
+ return String(value);
14148
+ }
14149
+ return void 0;
14150
+ }
14151
+ function toPhoneValue(value, fallbackCode, fallbackNumber) {
14152
+ if (value === null || value === void 0) {
14153
+ return { code: fallbackCode ?? "", number: fallbackNumber ?? "" };
14154
+ }
14155
+ if (isPhoneInputValue(value)) {
14156
+ return {
14157
+ code: getPhoneValuePart(value.code) ?? fallbackCode ?? "",
14158
+ number: getPhoneValuePart(value.number) ?? fallbackNumber ?? ""
14159
+ };
14160
+ }
14161
+ return { code: fallbackCode ?? "", number: fallbackNumber ?? String(value) };
14162
+ }
14139
14163
  function clearPhoneNumber(value) {
14140
14164
  return value.replace(/[^0-9]/g, "");
14141
14165
  }
@@ -14179,7 +14203,6 @@ function formatPhoneCodeOptionLabel(option) {
14179
14203
 
14180
14204
  // src/dashboard/phone-input/PhoneInput.tsx
14181
14205
  import { jsx as jsx156, jsxs as jsxs100 } from "react/jsx-runtime";
14182
- var EMPTY_VALUE = { code: "", number: "" };
14183
14206
  var PhoneInput = React50.forwardRef(
14184
14207
  function PhoneInput2({
14185
14208
  options,
@@ -14206,14 +14229,15 @@ var PhoneInput = React50.forwardRef(
14206
14229
  className,
14207
14230
  autoDetectCode = true,
14208
14231
  searchable = true,
14209
- defaultCode
14232
+ defaultCode,
14233
+ defaultNumber
14210
14234
  }, ref) {
14211
14235
  const { t } = useTranslation33();
14212
14236
  const groupLabelId = React50.useId();
14213
14237
  const errorMsgId = React50.useId();
14214
14238
  const numberInputRef = React50.useRef(null);
14215
14239
  const [codeSearchValue, setCodeSearchValue] = React50.useState("");
14216
- const safeValue = value ?? EMPTY_VALUE;
14240
+ const safeValue = toPhoneValue(value, defaultCode, defaultNumber);
14217
14241
  const effectiveCode = safeValue.code || defaultCode || "";
14218
14242
  const resolvedLabel = label ?? "";
14219
14243
  const hasExternalError = Boolean(error);