@yenio-pld/blocks 1.2.0-rc.13 → 1.2.0-rc.15

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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  "use client";
2
- import * as React3 from 'react';
2
+ import * as React6 from 'react';
3
3
  import { createContext, useContext, cloneElement, useRef, useEffect, useState, useId, useCallback, useLayoutEffect } from 'react';
4
4
  import { Skeleton } from './ui/skeleton.js';
5
5
  import { jsxs, jsx, Fragment } from 'react/jsx-runtime';
@@ -23,6 +23,7 @@ import { Combobox } from './ui/combobox.js';
23
23
  import { useDialogPortalContainer, DialogClose, Dialog, DialogContent, DialogHeader, DialogTitle, DialogFooter } from './ui/dialog.js';
24
24
  import { Drawer, DrawerContent, DrawerHeader, DrawerTitle, DrawerClose, DrawerFooter } from './ui/drawer.js';
25
25
  import { Input } from './ui/input.js';
26
+ import { getCountries, getCountryCallingCode, parsePhoneNumberFromString, AsYouType } from 'libphonenumber-js';
26
27
  import { Slider } from './ui/slider.js';
27
28
  import { Toggle } from './ui/toggle.js';
28
29
  import { AnimatePresence, motion, useReducedMotion } from 'framer-motion';
@@ -3064,8 +3065,8 @@ function CountryPicker({
3064
3065
  "aria-invalid": ariaInvalid
3065
3066
  }) {
3066
3067
  const labels = { ...defaultLabels2(purpose, locale), ...labelsProp };
3067
- const items = React3.useMemo(() => countryPickerItems(locale), [locale]);
3068
- const selected = React3.useMemo(() => findItem(items, value), [items, value]);
3068
+ const items = React6.useMemo(() => countryPickerItems(locale), [locale]);
3069
+ const selected = React6.useMemo(() => findItem(items, value), [items, value]);
3069
3070
  const dialogPortalContainer = useDialogPortalContainer();
3070
3071
  return /* @__PURE__ */ jsxs(Fragment, { children: [
3071
3072
  name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value.trim().toUpperCase() }) : null,
@@ -3165,6 +3166,293 @@ function CountryPicker({
3165
3166
  )
3166
3167
  ] });
3167
3168
  }
3169
+
3170
+ // src/data/sat-tax-regimes.json
3171
+ var sat_tax_regimes_default = {
3172
+ items: [
3173
+ {
3174
+ code: "601",
3175
+ labelEs: "General de Ley Personas Morales",
3176
+ labelEn: "General regime \u2014 legal entities"
3177
+ },
3178
+ {
3179
+ code: "603",
3180
+ labelEs: "Personas Morales con Fines no Lucrativos",
3181
+ labelEn: "Non-profit legal entities"
3182
+ },
3183
+ {
3184
+ code: "605",
3185
+ labelEs: "Sueldos y Salarios e Ingresos Asimilados a Salarios",
3186
+ labelEn: "Wages and salary-assimilated income"
3187
+ },
3188
+ {
3189
+ code: "606",
3190
+ labelEs: "Arrendamiento",
3191
+ labelEn: "Leasing"
3192
+ },
3193
+ {
3194
+ code: "607",
3195
+ labelEs: "R\xE9gimen de Enajenaci\xF3n o Adquisici\xF3n de Bienes",
3196
+ labelEn: "Transfer or acquisition of goods"
3197
+ },
3198
+ {
3199
+ code: "608",
3200
+ labelEs: "Dem\xE1s ingresos",
3201
+ labelEn: "Other income"
3202
+ },
3203
+ {
3204
+ code: "610",
3205
+ labelEs: "Residentes en el Extranjero sin Establecimiento Permanente en M\xE9xico",
3206
+ labelEn: "Foreign residents without permanent establishment in Mexico"
3207
+ },
3208
+ {
3209
+ code: "611",
3210
+ labelEs: "Ingresos por Dividendos (socios y accionistas)",
3211
+ labelEn: "Dividend income (partners and shareholders)"
3212
+ },
3213
+ {
3214
+ code: "612",
3215
+ labelEs: "Personas F\xEDsicas con Actividades Empresariales y Profesionales",
3216
+ labelEn: "Individuals with business and professional activities"
3217
+ },
3218
+ {
3219
+ code: "614",
3220
+ labelEs: "Ingresos por intereses",
3221
+ labelEn: "Interest income"
3222
+ },
3223
+ {
3224
+ code: "615",
3225
+ labelEs: "R\xE9gimen de los ingresos por obtenci\xF3n de premios",
3226
+ labelEn: "Prize income"
3227
+ },
3228
+ {
3229
+ code: "616",
3230
+ labelEs: "Sin obligaciones fiscales",
3231
+ labelEn: "No tax obligations"
3232
+ },
3233
+ {
3234
+ code: "620",
3235
+ labelEs: "Sociedades Cooperativas de Producci\xF3n que optan por diferir sus ingresos",
3236
+ labelEn: "Production cooperatives deferring income"
3237
+ },
3238
+ {
3239
+ code: "621",
3240
+ labelEs: "Incorporaci\xF3n Fiscal",
3241
+ labelEn: "Tax incorporation"
3242
+ },
3243
+ {
3244
+ code: "622",
3245
+ labelEs: "Actividades Agr\xEDcolas, Ganaderas, Silv\xEDcolas y Pesqueras",
3246
+ labelEn: "Agriculture, livestock, forestry, and fishing"
3247
+ },
3248
+ {
3249
+ code: "623",
3250
+ labelEs: "Opcional para Grupos de Sociedades",
3251
+ labelEn: "Optional regime for corporate groups"
3252
+ },
3253
+ {
3254
+ code: "624",
3255
+ labelEs: "Coordinados",
3256
+ labelEn: "Coordinated entities"
3257
+ },
3258
+ {
3259
+ code: "625",
3260
+ labelEs: "R\xE9gimen de las Actividades Empresariales con ingresos a trav\xE9s de Plataformas Tecnol\xF3gicas",
3261
+ labelEn: "Business income through digital platforms"
3262
+ },
3263
+ {
3264
+ code: "626",
3265
+ labelEs: "R\xE9gimen Simplificado de Confianza",
3266
+ labelEn: "Simplified trust regime (RESICO)"
3267
+ }
3268
+ ]
3269
+ };
3270
+
3271
+ // src/lib/tax-regimes.ts
3272
+ var ITEMS2 = sat_tax_regimes_default.items;
3273
+ var SAT_TAX_REGIME_CODES = Object.freeze(
3274
+ ITEMS2.map((item) => item.code)
3275
+ );
3276
+ var TAX_REGIME_OPTIONS = Object.freeze(
3277
+ [...ITEMS2].sort(
3278
+ (left, right) => left.labelEs.localeCompare(right.labelEs, "es")
3279
+ )
3280
+ );
3281
+ var CODE_SET2 = new Set(ITEMS2.map((item) => item.code));
3282
+ var BY_CODE2 = new Map(ITEMS2.map((item) => [item.code, item]));
3283
+ function titleCaseEs2(labelEs) {
3284
+ return labelEs.toLocaleLowerCase("es-MX").split(/\s+/).filter(Boolean).map((word) => word.charAt(0).toLocaleUpperCase("es-MX") + word.slice(1)).join(" ");
3285
+ }
3286
+ function normalizeCode(code) {
3287
+ return code.trim();
3288
+ }
3289
+ function isKnownTaxRegimeCode(code) {
3290
+ return CODE_SET2.has(normalizeCode(code));
3291
+ }
3292
+ function taxRegimeLabel(code, locale) {
3293
+ const normalized = normalizeCode(code);
3294
+ const record = BY_CODE2.get(normalized);
3295
+ if (!record) return normalized;
3296
+ if (locale === "es-MX") {
3297
+ return titleCaseEs2(record.labelEs);
3298
+ }
3299
+ return record.labelEn;
3300
+ }
3301
+ function formatTaxRegimeOptionLabel(code, locale) {
3302
+ const normalized = normalizeCode(code);
3303
+ return `${normalized} \u2014 ${taxRegimeLabel(normalized, locale)}`;
3304
+ }
3305
+ function taxRegimePickerItems(locale) {
3306
+ return TAX_REGIME_OPTIONS.map((item) => ({
3307
+ value: item.code,
3308
+ label: formatTaxRegimeOptionLabel(item.code, locale)
3309
+ }));
3310
+ }
3311
+ function foldForSearch2(text) {
3312
+ return text.normalize("NFD").replace(/\p{M}/gu, "").toLowerCase();
3313
+ }
3314
+ function filterTaxRegimes(query, locale) {
3315
+ const items = taxRegimePickerItems(locale);
3316
+ const trimmed = query.trim();
3317
+ if (!trimmed) return items;
3318
+ const needle = foldForSearch2(trimmed);
3319
+ return items.filter((item) => {
3320
+ const code = foldForSearch2(item.value);
3321
+ const label = foldForSearch2(item.label);
3322
+ return code.includes(needle) || label.includes(needle);
3323
+ });
3324
+ }
3325
+ var INPUT_CLASS2 = "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
3326
+ function defaultLabels3(locale) {
3327
+ const es = locale === "es-MX";
3328
+ return {
3329
+ placeholder: es ? "Buscar r\xE9gimen fiscal\u2026" : "Search tax regime\u2026",
3330
+ search: es ? "Buscar r\xE9gimen fiscal" : "Search tax regime",
3331
+ noResults: es ? "Sin resultados" : "No results",
3332
+ clear: es ? "Limpiar" : "Clear",
3333
+ open: es ? "Abrir lista" : "Open list"
3334
+ };
3335
+ }
3336
+ function findItem2(items, code) {
3337
+ const normalized = code.trim();
3338
+ if (!normalized) return null;
3339
+ return items.find((item) => item.value === normalized) ?? null;
3340
+ }
3341
+ function TaxRegimePicker({
3342
+ value,
3343
+ onValueChange,
3344
+ locale = "es-MX",
3345
+ id,
3346
+ name,
3347
+ disabled,
3348
+ required,
3349
+ allowEmpty = true,
3350
+ className,
3351
+ labels: labelsProp,
3352
+ "aria-invalid": ariaInvalid
3353
+ }) {
3354
+ const labels = { ...defaultLabels3(locale), ...labelsProp };
3355
+ const items = React6.useMemo(() => taxRegimePickerItems(locale), [locale]);
3356
+ const selected = React6.useMemo(() => findItem2(items, value), [items, value]);
3357
+ const dialogPortalContainer = useDialogPortalContainer();
3358
+ return /* @__PURE__ */ jsxs(Fragment, { children: [
3359
+ name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value: value.trim() }) : null,
3360
+ /* @__PURE__ */ jsxs(
3361
+ Combobox.Root,
3362
+ {
3363
+ items,
3364
+ value: selected,
3365
+ onValueChange: (item) => {
3366
+ onValueChange(item?.value ?? "");
3367
+ },
3368
+ disabled,
3369
+ itemToStringLabel: (item) => item.label,
3370
+ itemToStringValue: (item) => item.value,
3371
+ isItemEqualToValue: (item, current) => item.value === current.value,
3372
+ children: [
3373
+ /* @__PURE__ */ jsxs(
3374
+ Combobox.InputGroup,
3375
+ {
3376
+ className: cn("relative flex w-full items-center", className),
3377
+ children: [
3378
+ /* @__PURE__ */ jsx(
3379
+ Combobox.Input,
3380
+ {
3381
+ id,
3382
+ required,
3383
+ "aria-invalid": ariaInvalid,
3384
+ ...labels.ariaLabel ? { "aria-label": labels.ariaLabel } : {},
3385
+ placeholder: labels.placeholder,
3386
+ className: cn(INPUT_CLASS2, "pr-16")
3387
+ }
3388
+ ),
3389
+ /* @__PURE__ */ jsxs("div", { className: "absolute inset-y-0 right-0 flex items-center gap-0.5 pr-1.5", children: [
3390
+ allowEmpty ? /* @__PURE__ */ jsx(
3391
+ Combobox.Clear,
3392
+ {
3393
+ className: "inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",
3394
+ "aria-label": labels.clear,
3395
+ children: /* @__PURE__ */ jsx(XIcon, { className: "size-4", "aria-hidden": true })
3396
+ }
3397
+ ) : null,
3398
+ /* @__PURE__ */ jsx(
3399
+ Combobox.Trigger,
3400
+ {
3401
+ className: "inline-flex size-7 items-center justify-center rounded-md text-muted-foreground hover:bg-muted hover:text-foreground",
3402
+ "aria-label": labels.open,
3403
+ children: /* @__PURE__ */ jsx(ChevronDownIcon, { className: "size-4", "aria-hidden": true })
3404
+ }
3405
+ )
3406
+ ] })
3407
+ ]
3408
+ }
3409
+ ),
3410
+ /* @__PURE__ */ jsx(Combobox.Portal, { container: dialogPortalContainer ?? void 0, children: /* @__PURE__ */ jsx(
3411
+ Combobox.Positioner,
3412
+ {
3413
+ className: "pointer-events-auto isolate z-[60] outline-none",
3414
+ sideOffset: 4,
3415
+ children: /* @__PURE__ */ jsxs(
3416
+ Combobox.Popup,
3417
+ {
3418
+ className: cn(
3419
+ "pointer-events-auto z-[60] max-h-60 w-(--anchor-width) min-w-[16rem] overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10",
3420
+ "data-open:animate-in data-open:fade-in-0 data-open:zoom-in-95"
3421
+ ),
3422
+ children: [
3423
+ /* @__PURE__ */ jsx(Combobox.Empty, { className: "px-3 py-2 text-sm text-muted-foreground", children: labels.noResults }),
3424
+ /* @__PURE__ */ jsx(
3425
+ Combobox.List,
3426
+ {
3427
+ className: "max-h-60 overflow-y-auto p-1 outline-none",
3428
+ onWheel: (event) => event.stopPropagation(),
3429
+ children: (item) => /* @__PURE__ */ jsxs(
3430
+ Combobox.Item,
3431
+ {
3432
+ value: item,
3433
+ className: cn(
3434
+ "relative flex cursor-default items-center gap-2 rounded-md py-1.5 pr-2 pl-8 text-sm outline-none select-none",
3435
+ "data-highlighted:bg-accent data-highlighted:text-accent-foreground"
3436
+ ),
3437
+ children: [
3438
+ /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) }),
3439
+ /* @__PURE__ */ jsx("span", { children: item.label })
3440
+ ]
3441
+ },
3442
+ item.value
3443
+ )
3444
+ }
3445
+ )
3446
+ ]
3447
+ }
3448
+ )
3449
+ }
3450
+ ) })
3451
+ ]
3452
+ }
3453
+ )
3454
+ ] });
3455
+ }
3168
3456
  function useMediaQuery(query) {
3169
3457
  const [matches, setMatches] = useState(false);
3170
3458
  useEffect(() => {
@@ -3221,21 +3509,21 @@ function SearchablePicker({
3221
3509
  }) {
3222
3510
  const isMdUp = useMediaQuery(MD_UP);
3223
3511
  const dialogPortalContainer = useDialogPortalContainer();
3224
- const [open, setOpen] = React3.useState(false);
3225
- const searchRef = React3.useRef(null);
3512
+ const [open, setOpen] = React6.useState(false);
3513
+ const searchRef = React6.useRef(null);
3226
3514
  function setOpenState(next) {
3227
3515
  setOpen(next);
3228
3516
  onOpenChange?.(next);
3229
3517
  if (!next) onQueryChange("");
3230
3518
  }
3231
- const selected = React3.useMemo(() => {
3519
+ const selected = React6.useMemo(() => {
3232
3520
  if (!value) return null;
3233
3521
  return options.find((option) => option.id === value) ?? {
3234
3522
  id: value,
3235
3523
  label: selectedLabel || value
3236
3524
  };
3237
3525
  }, [options, selectedLabel, value]);
3238
- React3.useEffect(() => {
3526
+ React6.useEffect(() => {
3239
3527
  if (!open || isMdUp) return;
3240
3528
  const handle = window.setTimeout(() => searchRef.current?.focus(), 0);
3241
3529
  return () => window.clearTimeout(handle);
@@ -3518,7 +3806,7 @@ function SearchablePicker({
3518
3806
  ] }) })
3519
3807
  ] });
3520
3808
  }
3521
- var INPUT_CLASS2 = "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
3809
+ var INPUT_CLASS3 = "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 disabled:pointer-events-none disabled:cursor-not-allowed disabled:bg-input/50 disabled:opacity-50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 md:text-sm dark:bg-input/30 dark:disabled:bg-input/80 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
3522
3810
  var DEFAULT_LABELS = {
3523
3811
  placeholder: "Search\u2026",
3524
3812
  noResults: "No results",
@@ -3556,18 +3844,18 @@ function PaginatedCombobox({
3556
3844
  }) {
3557
3845
  const labels = { ...DEFAULT_LABELS, ...labelsProp };
3558
3846
  const dialogPortalContainer = useDialogPortalContainer();
3559
- const selected = React3.useMemo(
3847
+ const selected = React6.useMemo(
3560
3848
  () => resolveSelected(value, items, selectedItem),
3561
3849
  [value, items, selectedItem]
3562
3850
  );
3563
- const listItems = React3.useMemo(() => {
3851
+ const listItems = React6.useMemo(() => {
3564
3852
  if (!selected) return items;
3565
3853
  if (items.some((item) => item.value === selected.value)) return items;
3566
3854
  return [selected, ...items];
3567
3855
  }, [items, selected]);
3568
- const queryRef = React3.useRef("");
3569
- const debounceRef = React3.useRef(null);
3570
- React3.useEffect(() => {
3856
+ const queryRef = React6.useRef("");
3857
+ const debounceRef = React6.useRef(null);
3858
+ React6.useEffect(() => {
3571
3859
  return () => {
3572
3860
  if (debounceRef.current) clearTimeout(debounceRef.current);
3573
3861
  };
@@ -3624,7 +3912,7 @@ function PaginatedCombobox({
3624
3912
  "aria-invalid": ariaInvalid,
3625
3913
  ...labels.ariaLabel ? { "aria-label": labels.ariaLabel } : {},
3626
3914
  placeholder: labels.placeholder,
3627
- className: cn(INPUT_CLASS2, "pr-16")
3915
+ className: cn(INPUT_CLASS3, "pr-16")
3628
3916
  }
3629
3917
  ),
3630
3918
  /* @__PURE__ */ jsxs("div", { className: "absolute inset-y-0 right-0 flex items-center gap-0.5 pr-1.5", children: [
@@ -3840,7 +4128,7 @@ function PasswordInput({
3840
4128
  hideLabel = "Hide password",
3841
4129
  ...props
3842
4130
  }) {
3843
- const [visible, setVisible] = React3.useState(false);
4131
+ const [visible, setVisible] = React6.useState(false);
3844
4132
  return /* @__PURE__ */ jsxs("div", { className: "relative w-full", children: [
3845
4133
  /* @__PURE__ */ jsx(
3846
4134
  Input,
@@ -3867,6 +4155,345 @@ function PasswordInput({
3867
4155
  )
3868
4156
  ] });
3869
4157
  }
4158
+ var MD_UP2 = "(min-width: 768px)";
4159
+ var ROW_CLASS = "flex h-8 w-full min-w-0 items-stretch overflow-hidden rounded-lg border border-input bg-transparent transition-colors outline-none focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 dark:bg-input/30 dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40";
4160
+ var SEARCH_CLASS2 = "h-8 w-full min-w-0 rounded-lg border border-input bg-transparent px-2.5 py-1 text-base transition-colors outline-none placeholder:text-muted-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 md:text-sm dark:bg-input/30";
4161
+ function isCountryCode(value) {
4162
+ return getCountries().includes(value);
4163
+ }
4164
+ function resolveCountry(code, fallback) {
4165
+ const normalized = (code ?? "").trim().toUpperCase();
4166
+ return isCountryCode(normalized) ? normalized : fallback;
4167
+ }
4168
+ function flagEmoji(iso) {
4169
+ const code = iso.trim().toUpperCase();
4170
+ if (!/^[A-Z]{2}$/.test(code)) return "\u{1F3F3}\uFE0F";
4171
+ return String.fromCodePoint(
4172
+ ...code.split("").map((char) => 127397 + char.charCodeAt(0))
4173
+ );
4174
+ }
4175
+ var regionNames;
4176
+ function countryName(code) {
4177
+ try {
4178
+ regionNames ??= new Intl.DisplayNames(["en"], { type: "region" });
4179
+ return regionNames.of(code) ?? code;
4180
+ } catch {
4181
+ return code;
4182
+ }
4183
+ }
4184
+ function buildCountryOptions() {
4185
+ return getCountries().map((id) => {
4186
+ const dialCode = `+${getCountryCallingCode(id)}`;
4187
+ const name = countryName(id);
4188
+ return {
4189
+ id,
4190
+ dialCode,
4191
+ flag: flagEmoji(id),
4192
+ label: `${name} (${dialCode})`
4193
+ };
4194
+ }).sort((left, right) => left.label.localeCompare(right.label, "en"));
4195
+ }
4196
+ var COUNTRY_OPTIONS2 = buildCountryOptions();
4197
+ function nationalDigits(value) {
4198
+ return value.replace(/\D/g, "");
4199
+ }
4200
+ function formatNational(country, raw) {
4201
+ const digits = nationalDigits(raw);
4202
+ if (!digits) return "";
4203
+ return new AsYouType(country).input(digits);
4204
+ }
4205
+ function toE164(country, national) {
4206
+ const digits = nationalDigits(national);
4207
+ if (!digits) return "";
4208
+ const parsed = parsePhoneNumberFromString(digits, country);
4209
+ if (parsed?.number) return parsed.number;
4210
+ return `+${getCountryCallingCode(country)}${digits}`;
4211
+ }
4212
+ function parseIncoming(value, defaultCountry) {
4213
+ const trimmed = value.trim();
4214
+ if (!trimmed) {
4215
+ return { country: defaultCountry, national: "" };
4216
+ }
4217
+ const parsed = parsePhoneNumberFromString(trimmed, defaultCountry);
4218
+ if (parsed) {
4219
+ const country = parsed.country ?? defaultCountry;
4220
+ const national = parsed.formatNational();
4221
+ return { country, national };
4222
+ }
4223
+ return {
4224
+ country: defaultCountry,
4225
+ national: formatNational(defaultCountry, trimmed)
4226
+ };
4227
+ }
4228
+ function filterCountries2(options, query) {
4229
+ const needle = query.trim().toLowerCase();
4230
+ if (!needle) return options;
4231
+ return options.filter((option) => {
4232
+ const haystack = `${option.label} ${option.id} ${option.dialCode}`.toLowerCase();
4233
+ return haystack.includes(needle);
4234
+ });
4235
+ }
4236
+ function PhoneInput({
4237
+ value,
4238
+ onValueChange,
4239
+ defaultCountry = "MX",
4240
+ searchPlaceholder = "Search country or code\u2026",
4241
+ countryListLabel = "Country",
4242
+ countryTriggerLabel = "Select country",
4243
+ emptyLabel = "No matches",
4244
+ className,
4245
+ disabled,
4246
+ id,
4247
+ name,
4248
+ "aria-invalid": ariaInvalid,
4249
+ "aria-label": ariaLabel,
4250
+ placeholder,
4251
+ ...props
4252
+ }) {
4253
+ const resolvedDefault = resolveCountry(defaultCountry, "MX");
4254
+ const [country, setCountry] = React6.useState(
4255
+ () => parseIncoming(value, resolvedDefault).country
4256
+ );
4257
+ const [national, setNational] = React6.useState(
4258
+ () => parseIncoming(value, resolvedDefault).national
4259
+ );
4260
+ const [open, setOpen] = React6.useState(false);
4261
+ const [query, setQuery] = React6.useState("");
4262
+ const lastEmittedRef = React6.useRef(value);
4263
+ const isMdUp = useMediaQuery(MD_UP2);
4264
+ const dialogPortalContainer = useDialogPortalContainer();
4265
+ const searchRef = React6.useRef(null);
4266
+ React6.useEffect(() => {
4267
+ if (value === lastEmittedRef.current) return;
4268
+ lastEmittedRef.current = value;
4269
+ const next = parseIncoming(value, resolvedDefault);
4270
+ setCountry(next.country);
4271
+ setNational(next.national);
4272
+ }, [value, resolvedDefault]);
4273
+ React6.useEffect(() => {
4274
+ if (!open || isMdUp) return;
4275
+ const handle = window.setTimeout(() => searchRef.current?.focus(), 0);
4276
+ return () => window.clearTimeout(handle);
4277
+ }, [isMdUp, open]);
4278
+ const selected = COUNTRY_OPTIONS2.find((option) => option.id === country) ?? COUNTRY_OPTIONS2.find((option) => option.id === resolvedDefault);
4279
+ const filtered = React6.useMemo(
4280
+ () => filterCountries2(COUNTRY_OPTIONS2, query),
4281
+ [query]
4282
+ );
4283
+ function emit(nextCountry, nextNational) {
4284
+ const nextValue = toE164(nextCountry, nextNational);
4285
+ lastEmittedRef.current = nextValue;
4286
+ setCountry(nextCountry);
4287
+ setNational(nextNational);
4288
+ onValueChange(nextValue);
4289
+ }
4290
+ function setOpenState(next) {
4291
+ setOpen(next);
4292
+ if (!next) setQuery("");
4293
+ }
4294
+ function selectCountry(next) {
4295
+ const formatted = formatNational(next, national);
4296
+ emit(next, formatted);
4297
+ setOpenState(false);
4298
+ }
4299
+ function onNationalChange(nextRaw) {
4300
+ const formatted = formatNational(country, nextRaw);
4301
+ emit(country, formatted);
4302
+ }
4303
+ const dialDisplay = selected.dialCode;
4304
+ const countryTriggerClass = "inline-flex h-full shrink-0 items-center gap-1 border-r border-input px-2 text-sm outline-none disabled:pointer-events-none";
4305
+ const desktopPicker = /* @__PURE__ */ jsxs(
4306
+ Combobox.Root,
4307
+ {
4308
+ items: filtered,
4309
+ value: selected,
4310
+ open,
4311
+ onOpenChange: setOpenState,
4312
+ inputValue: query,
4313
+ onInputValueChange: setQuery,
4314
+ onValueChange: (item) => {
4315
+ if (item) selectCountry(item.id);
4316
+ },
4317
+ disabled,
4318
+ filter: null,
4319
+ autoComplete: "none",
4320
+ itemToStringLabel: (item) => item.label,
4321
+ itemToStringValue: (item) => item.id,
4322
+ isItemEqualToValue: (item, current) => item.id === current.id,
4323
+ children: [
4324
+ /* @__PURE__ */ jsxs(
4325
+ Combobox.Trigger,
4326
+ {
4327
+ "aria-invalid": ariaInvalid,
4328
+ "aria-label": countryTriggerLabel,
4329
+ className: countryTriggerClass,
4330
+ disabled,
4331
+ children: [
4332
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: selected.flag }),
4333
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums text-muted-foreground", children: dialDisplay }),
4334
+ /* @__PURE__ */ jsx(
4335
+ ChevronDownIcon,
4336
+ {
4337
+ "aria-hidden": true,
4338
+ className: "size-3.5 shrink-0 text-muted-foreground"
4339
+ }
4340
+ )
4341
+ ]
4342
+ }
4343
+ ),
4344
+ /* @__PURE__ */ jsx(Combobox.Portal, { container: dialogPortalContainer ?? void 0, children: /* @__PURE__ */ jsx(
4345
+ Combobox.Positioner,
4346
+ {
4347
+ className: "pointer-events-auto isolate z-[60] outline-none",
4348
+ sideOffset: 4,
4349
+ children: /* @__PURE__ */ jsxs(
4350
+ Combobox.Popup,
4351
+ {
4352
+ className: cn(
4353
+ "pointer-events-auto z-[60] flex w-[min(20rem,var(--anchor-width))] min-w-[16rem] flex-col overflow-hidden rounded-lg bg-popover text-popover-foreground shadow-md ring-1 ring-foreground/10",
4354
+ "motion-safe:data-open:animate-in motion-safe:data-open:fade-in-0 motion-safe:data-open:zoom-in-95"
4355
+ ),
4356
+ children: [
4357
+ /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 border-b border-border bg-popover p-2", children: /* @__PURE__ */ jsx(
4358
+ Combobox.Input,
4359
+ {
4360
+ "aria-label": searchPlaceholder,
4361
+ className: SEARCH_CLASS2,
4362
+ placeholder: searchPlaceholder
4363
+ }
4364
+ ) }),
4365
+ /* @__PURE__ */ jsx(Combobox.Empty, { className: "px-3 py-3 text-sm text-muted-foreground", children: emptyLabel }),
4366
+ /* @__PURE__ */ jsx(
4367
+ Combobox.List,
4368
+ {
4369
+ "aria-label": countryListLabel,
4370
+ className: "max-h-60 overflow-y-auto p-1 outline-none",
4371
+ onWheel: (event) => event.stopPropagation(),
4372
+ children: (item) => /* @__PURE__ */ jsxs(
4373
+ Combobox.Item,
4374
+ {
4375
+ value: item,
4376
+ className: cn(
4377
+ "relative flex cursor-default items-center gap-2 rounded-md py-2 pr-2 pl-8 text-sm outline-none select-none",
4378
+ "data-highlighted:bg-accent data-highlighted:text-accent-foreground"
4379
+ ),
4380
+ children: [
4381
+ /* @__PURE__ */ jsx(Combobox.ItemIndicator, { className: "absolute left-2 flex size-4 items-center justify-center", children: /* @__PURE__ */ jsx(CheckIcon, { className: "size-4", "aria-hidden": true }) }),
4382
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: item.flag }),
4383
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: item.label })
4384
+ ]
4385
+ },
4386
+ item.id
4387
+ )
4388
+ }
4389
+ )
4390
+ ]
4391
+ }
4392
+ )
4393
+ }
4394
+ ) })
4395
+ ]
4396
+ }
4397
+ );
4398
+ const mobileTrigger = /* @__PURE__ */ jsxs(
4399
+ "button",
4400
+ {
4401
+ "aria-expanded": open,
4402
+ "aria-haspopup": "dialog",
4403
+ "aria-invalid": ariaInvalid,
4404
+ "aria-label": countryTriggerLabel,
4405
+ className: countryTriggerClass,
4406
+ disabled,
4407
+ type: "button",
4408
+ onClick: () => setOpenState(true),
4409
+ children: [
4410
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: selected.flag }),
4411
+ /* @__PURE__ */ jsx("span", { className: "tabular-nums text-muted-foreground", children: dialDisplay }),
4412
+ /* @__PURE__ */ jsx(
4413
+ ChevronDownIcon,
4414
+ {
4415
+ "aria-hidden": true,
4416
+ className: "size-3.5 shrink-0 text-muted-foreground"
4417
+ }
4418
+ )
4419
+ ]
4420
+ }
4421
+ );
4422
+ return /* @__PURE__ */ jsxs(
4423
+ "div",
4424
+ {
4425
+ "aria-invalid": ariaInvalid,
4426
+ className: cn(
4427
+ ROW_CLASS,
4428
+ disabled ? "pointer-events-none cursor-not-allowed bg-input/50 opacity-50 dark:bg-input/80" : null,
4429
+ className
4430
+ ),
4431
+ children: [
4432
+ name ? /* @__PURE__ */ jsx("input", { type: "hidden", name, value }) : null,
4433
+ isMdUp ? desktopPicker : mobileTrigger,
4434
+ /* @__PURE__ */ jsx(
4435
+ "input",
4436
+ {
4437
+ ...props,
4438
+ "aria-invalid": ariaInvalid,
4439
+ "aria-label": ariaLabel,
4440
+ autoComplete: props.autoComplete ?? "tel-national",
4441
+ className: "h-full min-w-0 flex-1 border-0 bg-transparent px-2.5 py-1 text-base outline-none placeholder:text-muted-foreground md:text-sm",
4442
+ disabled,
4443
+ id,
4444
+ inputMode: "tel",
4445
+ placeholder,
4446
+ type: "tel",
4447
+ value: national,
4448
+ onChange: (event) => onNationalChange(event.target.value)
4449
+ }
4450
+ ),
4451
+ !isMdUp ? /* @__PURE__ */ jsx(Drawer, { open, onOpenChange: setOpenState, children: /* @__PURE__ */ jsxs(DrawerContent, { className: "max-h-[85vh]", children: [
4452
+ /* @__PURE__ */ jsx(DrawerHeader, { className: "text-left", children: /* @__PURE__ */ jsx(DrawerTitle, { children: countryListLabel }) }),
4453
+ /* @__PURE__ */ jsx("div", { className: "sticky top-0 z-10 border-b border-border bg-background px-4 pb-3", children: /* @__PURE__ */ jsx(
4454
+ Input,
4455
+ {
4456
+ ref: searchRef,
4457
+ "aria-label": searchPlaceholder,
4458
+ disabled,
4459
+ placeholder: searchPlaceholder,
4460
+ value: query,
4461
+ onChange: (event) => setQuery(event.target.value)
4462
+ }
4463
+ ) }),
4464
+ /* @__PURE__ */ jsx("div", { className: "overflow-y-auto px-2 pb-4", children: filtered.length === 0 ? /* @__PURE__ */ jsx("p", { className: "px-2 py-3 text-sm text-muted-foreground", children: emptyLabel }) : /* @__PURE__ */ jsx("ul", { className: "flex flex-col gap-1 p-1", role: "listbox", children: filtered.map((option) => {
4465
+ const isSelected = option.id === country;
4466
+ return /* @__PURE__ */ jsx("li", { children: /* @__PURE__ */ jsxs(
4467
+ "button",
4468
+ {
4469
+ "aria-selected": isSelected,
4470
+ className: cn(
4471
+ "flex w-full items-center gap-2 rounded-lg px-3 py-2 text-left text-sm outline-none transition-colors",
4472
+ "hover:bg-muted/60 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50",
4473
+ isSelected ? "bg-accent" : null
4474
+ ),
4475
+ role: "option",
4476
+ type: "button",
4477
+ onClick: () => selectCountry(option.id),
4478
+ children: [
4479
+ /* @__PURE__ */ jsx("span", { "aria-hidden": true, className: "text-base leading-none", children: option.flag }),
4480
+ /* @__PURE__ */ jsx("span", { className: "min-w-0 flex-1 truncate", children: option.label }),
4481
+ isSelected ? /* @__PURE__ */ jsx(
4482
+ CheckIcon,
4483
+ {
4484
+ "aria-hidden": true,
4485
+ className: "size-4 shrink-0"
4486
+ }
4487
+ ) : null
4488
+ ]
4489
+ }
4490
+ ) }, option.id);
4491
+ }) }) })
4492
+ ] }) }) : null
4493
+ ]
4494
+ }
4495
+ );
4496
+ }
3870
4497
  var DEFAULT_LABELS2 = {
3871
4498
  uploadAria: "Upload image",
3872
4499
  uploadHint: "Click to upload",
@@ -6921,6 +7548,6 @@ function MatchReview({
6921
7548
  );
6922
7549
  }
6923
7550
 
6924
- export { AccountMenu, AppShell, AuditTimeline, AvatarEditor, AvatarEditorDialog, COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, COUNTRY_OPTIONS, CURP_REGEX, ConfirmDestructiveDialog, CookieConsentBanner, CostBreakdownCard, CountryPicker, CurpInput, DATA_TABLE_BODY_MIN_CLASS, DATA_TABLE_DEFAULT_SKELETON_ROWS, DATA_TABLE_ROW_CLASS, DEFAULT_AUDIT_TIMELINE_LABELS, DEFAULT_COOKIE_CONSENT_BANNER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_ENTITY_GRAPH_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS, DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DEFAULT_RISK_BADGE_LABELS, DashboardSkeleton, DataList, DataListItem, DataTable, DataTableSkeleton, DetailHeader, DetailPageSkeleton, DimensionBreakdownTable, EditableSection, Empty2 as Empty, EmptyContent2 as EmptyContent, EmptyDescription2 as EmptyDescription, EmptyHeader2 as EmptyHeader, EmptyMedia2 as EmptyMedia, EmptyState, EmptyTitle2 as EmptyTitle, EntityGraph, ErrorState, Field, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, FormCardSkeleton, FormSection, LanguageContext, LanguageSwitcher, LegalAcceptCheckbox, LegalAcceptDialog, LegalMarkdown, ListSkeleton, LoadingState, MatchReview, MetricChartCard, MetricEmptyState, MetricSkeleton, NavTabs, NavigationProgress, NotificationBell, OptionRow, PageContainer, PageTitle, PageTitleSkeleton, PaginatedCombobox, PasswordInput, QueueLayout, RfcInput, RiskBadge, RouteLoading, SafeImage, SearchablePicker, SectionCard, SectionNav, SectionNavList, SectionSummary, SettingRow, SparklineStat, StatHighlightCard, StatusBadge, StepProgress, StickyActionBar, THEME_INIT_SCRIPT, THEME_INIT_SCRIPT_ID, THEME_STORAGE_KEY, TIME_RANGE_OPTIONS, TableSkeleton, ThemeSwitcher, TimeRangePicker, WizardLayout, avatarFallbackStyle, cn, cookieConsentAllowsReplay, cookieDomainFromHostname, countryLabel, countryPickerItems, createMultipartUploadController, curpCheckDigit, dataTableBodyMinClass, defaultLanguages, fileMatchesAccept, filterCountries, formatCountryOptionLabel, getAvatarColors, getInitials, isCookieConsentValue, isEmbeddedWindow, isKnownCountryCode, matchClaimIsUnverified, normalizeCurpInput, normalizeRfc, parseCookieConsent, partRanges, progressFromBytes, queueRowKeyDown, readCookieConsent, renderShellLink, rfcMaxLengthForPersonKind, serializeCookieConsent, signalNavigationStart, sourceUrlIsHttps, suppressNavigationProgress, useDirtyGuard, useEditableSection, useLanguageContext, useMediaQuery, useQueueKeys, useSectionNav, validateCurp, validateRfcForPersonKind, writeCookieConsent };
7551
+ export { AccountMenu, AppShell, AuditTimeline, AvatarEditor, AvatarEditorDialog, COOKIE_CONSENT_MAX_AGE, COOKIE_CONSENT_NAME, COOKIE_CONSENT_VALUES, COUNTRY_OPTIONS, CURP_REGEX, ConfirmDestructiveDialog, CookieConsentBanner, CostBreakdownCard, CountryPicker, CurpInput, DATA_TABLE_BODY_MIN_CLASS, DATA_TABLE_DEFAULT_SKELETON_ROWS, DATA_TABLE_ROW_CLASS, DEFAULT_AUDIT_TIMELINE_LABELS, DEFAULT_COOKIE_CONSENT_BANNER_LABELS, DEFAULT_EDITABLE_SECTION_LABELS, DEFAULT_ENTITY_GRAPH_LABELS, DEFAULT_FILE_DROPZONE_LABELS, DEFAULT_FILE_UPLOAD_LABELS, DEFAULT_FILE_UPLOAD_TRAY_LABELS, DEFAULT_LEGAL_ACCEPT_CHECKBOX_LABELS, DEFAULT_LEGAL_ACCEPT_DIALOG_LABELS, DEFAULT_MATCH_REVIEW_LABELS, DEFAULT_NOTIFICATION_BELL_LABELS, DEFAULT_RISK_BADGE_LABELS, DashboardSkeleton, DataList, DataListItem, DataTable, DataTableSkeleton, DetailHeader, DetailPageSkeleton, DimensionBreakdownTable, EditableSection, Empty2 as Empty, EmptyContent2 as EmptyContent, EmptyDescription2 as EmptyDescription, EmptyHeader2 as EmptyHeader, EmptyMedia2 as EmptyMedia, EmptyState, EmptyTitle2 as EmptyTitle, EntityGraph, ErrorState, Field, FieldMessage, FileDropzone, FileUploadMenu, FileUploadTray, FormCardSkeleton, FormSection, LanguageContext, LanguageSwitcher, LegalAcceptCheckbox, LegalAcceptDialog, LegalMarkdown, ListSkeleton, LoadingState, MatchReview, MetricChartCard, MetricEmptyState, MetricSkeleton, NavTabs, NavigationProgress, NotificationBell, OptionRow, PageContainer, PageTitle, PageTitleSkeleton, PaginatedCombobox, PasswordInput, PhoneInput, QueueLayout, RfcInput, RiskBadge, RouteLoading, SAT_TAX_REGIME_CODES, SafeImage, SearchablePicker, SectionCard, SectionNav, SectionNavList, SectionSummary, SettingRow, SparklineStat, StatHighlightCard, StatusBadge, StepProgress, StickyActionBar, TAX_REGIME_OPTIONS, THEME_INIT_SCRIPT, THEME_INIT_SCRIPT_ID, THEME_STORAGE_KEY, TIME_RANGE_OPTIONS, TableSkeleton, TaxRegimePicker, ThemeSwitcher, TimeRangePicker, WizardLayout, avatarFallbackStyle, cn, cookieConsentAllowsReplay, cookieDomainFromHostname, countryLabel, countryPickerItems, createMultipartUploadController, curpCheckDigit, dataTableBodyMinClass, defaultLanguages, fileMatchesAccept, filterCountries, filterTaxRegimes, formatCountryOptionLabel, formatTaxRegimeOptionLabel, getAvatarColors, getInitials, isCookieConsentValue, isEmbeddedWindow, isKnownCountryCode, isKnownTaxRegimeCode, matchClaimIsUnverified, normalizeCurpInput, normalizeRfc, parseCookieConsent, partRanges, progressFromBytes, queueRowKeyDown, readCookieConsent, renderShellLink, rfcMaxLengthForPersonKind, serializeCookieConsent, signalNavigationStart, sourceUrlIsHttps, suppressNavigationProgress, taxRegimeLabel, taxRegimePickerItems, useDirtyGuard, useEditableSection, useLanguageContext, useMediaQuery, useQueueKeys, useSectionNav, validateCurp, validateRfcForPersonKind, writeCookieConsent };
6925
7552
  //# sourceMappingURL=index.js.map
6926
7553
  //# sourceMappingURL=index.js.map