@chekinapp/ui 0.0.140 → 0.0.141

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>;
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>;
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,
@@ -14213,7 +14236,7 @@ var PhoneInput = React50.forwardRef(
14213
14236
  const errorMsgId = React50.useId();
14214
14237
  const numberInputRef = React50.useRef(null);
14215
14238
  const [codeSearchValue, setCodeSearchValue] = React50.useState("");
14216
- const safeValue = value ?? EMPTY_VALUE;
14239
+ const safeValue = toPhoneValue(value);
14217
14240
  const effectiveCode = safeValue.code || defaultCode || "";
14218
14241
  const resolvedLabel = label ?? "";
14219
14242
  const hasExternalError = Boolean(error);