@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.cjs CHANGED
@@ -14501,6 +14501,30 @@ var Select = React49.forwardRef(SelectInternal);
14501
14501
 
14502
14502
  // src/dashboard/phone-input/utils.ts
14503
14503
  var PREFIX_REGEX = /^\+/;
14504
+ function isPhoneInputValue(value) {
14505
+ if (typeof value === "string" || typeof value === "number") {
14506
+ return false;
14507
+ }
14508
+ return Boolean(value && ("code" in value || "number" in value));
14509
+ }
14510
+ function getPhoneValuePart(value) {
14511
+ if (typeof value === "string" || typeof value === "number") {
14512
+ return String(value);
14513
+ }
14514
+ return void 0;
14515
+ }
14516
+ function toPhoneValue(value, fallbackCode, fallbackNumber) {
14517
+ if (value === null || value === void 0) {
14518
+ return { code: fallbackCode ?? "", number: fallbackNumber ?? "" };
14519
+ }
14520
+ if (isPhoneInputValue(value)) {
14521
+ return {
14522
+ code: getPhoneValuePart(value.code) ?? fallbackCode ?? "",
14523
+ number: getPhoneValuePart(value.number) ?? fallbackNumber ?? ""
14524
+ };
14525
+ }
14526
+ return { code: fallbackCode ?? "", number: fallbackNumber ?? String(value) };
14527
+ }
14504
14528
  function clearPhoneNumber(value) {
14505
14529
  return value.replace(/[^0-9]/g, "");
14506
14530
  }
@@ -14544,7 +14568,6 @@ function formatPhoneCodeOptionLabel(option) {
14544
14568
 
14545
14569
  // src/dashboard/phone-input/PhoneInput.tsx
14546
14570
  var import_jsx_runtime158 = require("react/jsx-runtime");
14547
- var EMPTY_VALUE = { code: "", number: "" };
14548
14571
  var PhoneInput = React50.forwardRef(
14549
14572
  function PhoneInput2({
14550
14573
  options,
@@ -14571,14 +14594,15 @@ var PhoneInput = React50.forwardRef(
14571
14594
  className,
14572
14595
  autoDetectCode = true,
14573
14596
  searchable = true,
14574
- defaultCode
14597
+ defaultCode,
14598
+ defaultNumber
14575
14599
  }, ref) {
14576
14600
  const { t } = (0, import_react_i18next33.useTranslation)();
14577
14601
  const groupLabelId = React50.useId();
14578
14602
  const errorMsgId = React50.useId();
14579
14603
  const numberInputRef = React50.useRef(null);
14580
14604
  const [codeSearchValue, setCodeSearchValue] = React50.useState("");
14581
- const safeValue = value ?? EMPTY_VALUE;
14605
+ const safeValue = toPhoneValue(value, defaultCode, defaultNumber);
14582
14606
  const effectiveCode = safeValue.code || defaultCode || "";
14583
14607
  const resolvedLabel = label ?? "";
14584
14608
  const hasExternalError = Boolean(error);