@wow-two-beta/fe 0.0.37 → 0.0.39

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.
Files changed (73) hide show
  1. package/dist/auth/AuthSession.d.ts +25 -1
  2. package/dist/auth/AuthSession.js.map +1 -1
  3. package/dist/auth/BffSession.d.ts +55 -0
  4. package/dist/auth/BffSession.js +73 -0
  5. package/dist/auth/BffSession.js.map +1 -0
  6. package/dist/auth/BffSessionSync.d.ts +57 -0
  7. package/dist/auth/BffSessionSync.js +160 -0
  8. package/dist/auth/BffSessionSync.js.map +1 -0
  9. package/dist/auth/BffStrategy.d.ts +53 -0
  10. package/dist/auth/BffStrategy.js +95 -0
  11. package/dist/auth/BffStrategy.js.map +1 -0
  12. package/dist/auth/RedirectStrategy.js +3 -6
  13. package/dist/auth/RedirectStrategy.js.map +1 -1
  14. package/dist/auth/ReturnUrlExtensions.d.ts +7 -0
  15. package/dist/auth/ReturnUrlExtensions.js +15 -0
  16. package/dist/auth/ReturnUrlExtensions.js.map +1 -0
  17. package/dist/auth/UseBffAuth.d.ts +31 -0
  18. package/dist/auth/UseBffAuth.js +39 -0
  19. package/dist/auth/UseBffAuth.js.map +1 -0
  20. package/dist/auth/index.d.ts +5 -1
  21. package/dist/auth/index.js +11 -1
  22. package/dist/auth/index.js.map +1 -1
  23. package/dist/auth/providers/AuthProvider.vue.js +74 -5
  24. package/dist/auth/providers/AuthProvider.vue.js.map +1 -1
  25. package/dist/foundation/http/Antiforgery.d.ts +5 -0
  26. package/dist/foundation/http/Antiforgery.js.map +1 -1
  27. package/dist/foundation/http/CreateApiClient.js +1 -1
  28. package/dist/foundation/http/CreateApiClient.js.map +1 -1
  29. package/dist/foundation/phone/PhoneCountries.d.ts +13 -0
  30. package/dist/foundation/phone/PhoneCountries.js +62 -0
  31. package/dist/foundation/phone/PhoneCountries.js.map +1 -0
  32. package/dist/foundation/phone/PhoneFormats.d.ts +12 -0
  33. package/dist/foundation/phone/PhoneFormats.js +32 -0
  34. package/dist/foundation/phone/PhoneFormats.js.map +1 -0
  35. package/dist/foundation/phone/PhoneNumberExtensions.d.ts +94 -0
  36. package/dist/foundation/phone/PhoneNumberExtensions.js +137 -0
  37. package/dist/foundation/phone/PhoneNumberExtensions.js.map +1 -0
  38. package/dist/foundation/phone/index.d.ts +3 -0
  39. package/dist/foundation/phone/index.js +9 -0
  40. package/dist/foundation/phone/index.js.map +1 -0
  41. package/dist/foundation/validators/Formats.d.ts +15 -0
  42. package/dist/foundation/validators/Formats.js +32 -1
  43. package/dist/foundation/validators/Formats.js.map +1 -1
  44. package/dist/foundation/validators/Messages.d.ts +1 -1
  45. package/dist/foundation/validators/Messages.js +10 -0
  46. package/dist/foundation/validators/Messages.js.map +1 -1
  47. package/dist/foundation/validators/index.d.ts +1 -1
  48. package/dist/foundation/validators/index.js +2 -1
  49. package/dist/index.js +4 -2
  50. package/dist/index.js.map +1 -1
  51. package/dist/presentation/actions/refreshButton/RefreshButton.vue.js.map +1 -1
  52. package/dist/presentation/forms/field/Field.vue.js +10 -3
  53. package/dist/presentation/forms/field/Field.vue.js.map +1 -1
  54. package/dist/presentation/forms/index.js +2 -1
  55. package/dist/presentation/forms/index.js.map +1 -1
  56. package/dist/presentation/forms/labeledField/LabeledField.vue.js +2 -2
  57. package/dist/presentation/forms/labeledField/LabeledField.vue.js.map +1 -1
  58. package/dist/presentation/forms/phoneInput/PhoneInput.vue.d.ts +1 -9
  59. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js +85 -86
  60. package/dist/presentation/forms/phoneInput/PhoneInput.vue.js.map +1 -1
  61. package/dist/presentation/forms/phoneInput/PhoneInput2.vue.js +0 -2
  62. package/dist/presentation/forms/phoneInput/PhoneInput2.vue.js.map +1 -1
  63. package/dist/presentation/forms/phoneInput/index.d.ts +2 -1
  64. package/dist/presentation/layout/navbar/Navbar.vue.js.map +1 -1
  65. package/dist/presentation/overlays/alertModal/AlertModalContent.vue.js +1 -0
  66. package/dist/presentation/overlays/alertModal/AlertModalContent.vue.js.map +1 -1
  67. package/dist/presentation/overlays/index.js +2 -1
  68. package/dist/presentation/overlays/modal/ModalContent.vue.d.ts +17 -0
  69. package/dist/presentation/overlays/modal/ModalContent.vue.js +23 -2
  70. package/dist/presentation/overlays/modal/ModalContent.vue.js.map +1 -1
  71. package/dist/presentation/overlays/modal/ModalContent2.vue.js +2 -1
  72. package/dist/presentation/overlays/modal/index.d.ts +1 -1
  73. package/package.json +6 -1
@@ -1 +1 @@
1
- {"version":3,"file":"Messages.js","sources":["../../../src/foundation/validators/Messages.ts"],"sourcesContent":["// The shared rule-code vocabulary and the message catalogue that renders it. This slice's reason to\n// exist is NOT to save strings — it is to make the client and the server speak with ONE voice for one\n// rule. A user who reads \"Name is required\" from the client and \"'Name' must not be empty.\" from the\n// server is hearing two voices for the same failure, and that is the drift that actually shows.\n//\n// WHY A VOCABULARY, NOT A SHARED RULE SET: each layer validates its own scope and neither delegates\n// (`conventions/development/backend/foundation/validators.md` § Layer independence). Sharing rule\n// DEFINITIONS would break that; sharing the machine tag a rule reports does not — a tag is presentation\n// metadata, not authority. Client rules stay a latency optimisation; the server stays the authority.\n//\n// WHY THE SERVER MESSAGE IS THE FALLBACK, NEVER THE OVERRIDE: adoption has to be incremental. A code\n// this catalogue does not know renders the message the server already sent, so wiring the catalogue can\n// never make a form worse — the worst case is the behaviour that existed before it.\n//\n// WHY PARAMS EXIST: a catalogue entry that cannot reach the `50` in \"at most 50 characters\" can only\n// emit parameterless strings, which is a catalogue that cannot replace the messages it is meant to\n// replace. Every built-in refinement therefore reports its own limits alongside its code.\n//\n// TWO VOCABULARIES MEET HERE. The house validators report `min` / `max` / `pattern`; FluentValidation\n// reports `MinimumLengthValidator` / `MaximumLengthValidator` / `RegularExpressionValidator`. Neither is\n// wrong and neither wins by default — `FluentValidationCodes` normalizes the server's onto this one so\n// a single catalogue serves both. The alias pass lives on the CLIENT deliberately: it lets a form adopt\n// the catalogue before the backend normalizes anything, and it keeps working unchanged afterwards.\n\nimport { ExactNumber } from '../numbers';\n\n/** A field-level failure widened to carry its machine tag — the channel a catalogue can key on. */\nexport interface FieldIssue {\n /** The authoring or server message. Always present; used verbatim when no catalogue entry matches. */\n readonly message: string;\n /** The normalized rule code (`required`, `min`, `pattern`, …). Absent when the source reported none. */\n readonly code?: string;\n /** The rule's own operands (`{ max: 50 }`), normalized to the vocabulary's names. */\n readonly params?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * The rule codes this ecosystem speaks. The client's own validators report a subset (`type`, `min`,\n * `pattern`, …); the rest arrive from the server. Kept as one flat union because a catalogue keys on it\n * and a split would mean two lookups for one concept.\n */\nexport const ValidationCodes = [\n // shape / presence\n 'required',\n 'type',\n 'mustBeNull',\n 'mustBeEmpty',\n // size\n 'min',\n 'max',\n 'length',\n 'integer',\n 'precision',\n // comparison\n 'greaterThan',\n 'lessThan',\n 'between',\n 'betweenExclusive',\n 'equal',\n 'notEqual',\n // shape membership\n 'literal',\n 'oneOf',\n 'union',\n // format\n 'pattern',\n 'email',\n 'url',\n 'uuid',\n 'isoDate',\n 'creditCard',\n // escape hatches\n 'custom',\n 'transform',\n 'internal',\n] as const;\n\n/** A member of the shared rule-code vocabulary. */\nexport type ValidationCode = (typeof ValidationCodes)[number];\n\n/**\n * Maps FluentValidation's `ErrorCode` onto the shared vocabulary. Covers the built-in validators whose\n * failures reach a form; anything absent falls through with its raw code, which simply misses the\n * catalogue and renders the server's own message.\n */\nexport const FluentValidationCodes: Readonly<Record<string, ValidationCode>> = Object.freeze({\n NotEmptyValidator: 'required',\n NotNullValidator: 'required',\n NullValidator: 'mustBeNull',\n EmptyValidator: 'mustBeEmpty',\n MinimumLengthValidator: 'min',\n MaximumLengthValidator: 'max',\n ExactLengthValidator: 'length',\n LengthValidator: 'length',\n RegularExpressionValidator: 'pattern',\n EmailValidator: 'email',\n CreditCardValidator: 'creditCard',\n EnumValidator: 'oneOf',\n GreaterThanValidator: 'greaterThan',\n GreaterThanOrEqualValidator: 'min',\n LessThanValidator: 'lessThan',\n LessThanOrEqualValidator: 'max',\n InclusiveBetweenValidator: 'between',\n ExclusiveBetweenValidator: 'betweenExclusive',\n EqualValidator: 'equal',\n NotEqualValidator: 'notEqual',\n ScalePrecisionValidator: 'precision',\n PredicateValidator: 'custom',\n AsyncPredicateValidator: 'custom',\n});\n\n/**\n * Maps FluentValidation's message placeholders onto the vocabulary's param names, so one catalogue entry\n * reads the same operand whichever side reported it. Unlisted placeholders pass through unchanged —\n * `PropertyName` deliberately among them, since the label is resolved from the form, not the payload.\n */\nexport const FluentValidationParameters: Readonly<Record<string, string>> = Object.freeze({\n MinLength: 'min',\n MaxLength: 'max',\n TotalLength: 'length',\n ComparisonValue: 'comparison',\n ComparisonProperty: 'comparisonLabel',\n From: 'from',\n To: 'to',\n ExpectedPrecision: 'precision',\n ExpectedScale: 'scale',\n});\n\n/** What a catalogue entry renders from. */\nexport interface ValidationMessageContext {\n /** The normalized rule code that failed. */\n readonly code: string;\n /** The rule's operands, vocabulary-named. Empty when the source reported none. */\n readonly params: Readonly<Record<string, unknown>>;\n /** The form path the failure is filed under; `''` for a form-level failure. */\n readonly path: string;\n /** The field's display label, when the form named one. Absent means render label-free. */\n readonly label?: string;\n /** The originating message — return this to defer to the source. */\n readonly message: string;\n}\n\n/** Renders one rule code into user-facing text. */\nexport type ValidationMessageEntry = (context: ValidationMessageContext) => string;\n\n/** A code → renderer table. Partial by design: an unlisted code falls back to the source's message. */\nexport type ValidationMessageCatalogue = Readonly<Record<string, ValidationMessageEntry>>;\n\n/** Resolves one issue at one path into the string a field renders. */\nexport type ResolveValidationMessage = (issue: FieldIssue, path: string) => string;\n\n/** Reads a numeric operand, tolerating the string form a JSON payload may carry. */\nfunction operand(params: Readonly<Record<string, unknown>>, key: string): string | null {\n const value = Object.hasOwn(params, key) ? params[key] : undefined;\n if (ExactNumber.isExactNumber(value)) return value.toString();\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'string' && value.length > 0) return value;\n return null;\n}\n\n/** Pluralizes the character-count fragments the size rules share. */\nfunction characters(count: string): string {\n return `${count} character${count === '1' ? '' : 's'}`;\n}\n\n/** Pluralizes the item-count fragments the collection size rules share. */\nfunction items(count: string): string {\n return `${count} item${count === '1' ? '' : 's'}`;\n}\n\n/**\n * The English voice for the vocabulary. Entries are FRAGMENTS, not sentences — a field message renders\n * under its own labelled control, so \"must be at least 2 characters\" reads correctly and repeating the\n * label there is noise. A form that supplies `labels` gets the label prefixed by `createMessageResolver`,\n * which is the form-level and cross-field case where the fragment alone would be unaddressed.\n *\n * An entry that cannot render (its operand never arrived) returns `context.message`, so a half-populated\n * payload degrades to the source's wording instead of to \"must be at most undefined\".\n */\nexport const defaultValidationMessages: ValidationMessageCatalogue = Object.freeze({\n required: () => 'is required',\n type: (context) => context.message,\n mustBeNull: () => 'must be empty',\n mustBeEmpty: () => 'must be empty',\n\n min: (context) => {\n const limit = operand(context.params, 'min');\n if (limit === null) return context.message;\n switch (operand(context.params, 'unit')) {\n case 'characters':\n return `must be at least ${characters(limit)}`;\n case 'items':\n return `must have at least ${items(limit)}`;\n case 'instant':\n return `must be on or after ${limit}`;\n default:\n return `must be at least ${limit}`;\n }\n },\n max: (context) => {\n const limit = operand(context.params, 'max');\n if (limit === null) return context.message;\n switch (operand(context.params, 'unit')) {\n case 'characters':\n return `must be at most ${characters(limit)}`;\n case 'items':\n return `must have at most ${items(limit)}`;\n case 'instant':\n return `must be on or before ${limit}`;\n default:\n return `must be at most ${limit}`;\n }\n },\n length: (context) => {\n const exact = operand(context.params, 'length');\n if (exact === null) return context.message;\n if (operand(context.params, 'unit') === 'items') return `must have exactly ${items(exact)}`;\n return `must be exactly ${characters(exact)}`;\n },\n integer: () => 'must be a whole number',\n precision: (context) => {\n const scale = operand(context.params, 'scale');\n return scale === null ? context.message : `must have at most ${scale} decimal places`;\n },\n\n greaterThan: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must be greater than ${comparison}`;\n },\n lessThan: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must be less than ${comparison}`;\n },\n between: (context) => {\n const from = operand(context.params, 'from');\n const to = operand(context.params, 'to');\n return from === null || to === null ? context.message : `must be between ${from} and ${to}`;\n },\n betweenExclusive: (context) => {\n const from = operand(context.params, 'from');\n const to = operand(context.params, 'to');\n return from === null || to === null ? context.message : `must be between ${from} and ${to}, exclusive`;\n },\n equal: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must equal ${comparison}`;\n },\n notEqual: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must not equal ${comparison}`;\n },\n\n literal: (context) => context.message,\n oneOf: (context) => context.message,\n union: (context) => context.message,\n\n pattern: (context) => context.message,\n email: () => 'must be a valid email address',\n url: () => 'must be a valid URL',\n uuid: () => 'must be a valid UUID',\n isoDate: () => 'must be a valid ISO date (YYYY-MM-DD)',\n creditCard: () => 'must be a valid card number',\n\n custom: (context) => context.message,\n transform: (context) => context.message,\n internal: (context) => context.message,\n});\n\nconst EmptyParameters: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/**\n * Strips array indices so one label serves every row: `rules[0].destination` → `rules[].destination`.\n * Looked up only after the exact path misses, so a per-row override stays possible.\n */\nfunction toLabelKey(path: string): string {\n return path.replace(/\\[\\d+\\]/g, '[]');\n}\n\n/**\n * Builds the resolver the form engines call for every message they are about to render.\n *\n * Resolution order per issue: the caller's catalogue → {@link defaultValidationMessages} → the issue's\n * own message. A known label is prefixed to the rendered fragment; an unlabelled field renders the\n * fragment alone, which is what every message in this SDK did before a catalogue existed.\n *\n * `catalogue` is MERGED over the defaults rather than replacing them, so overriding one code's wording —\n * or translating a handful — never silently drops the rest of the vocabulary.\n */\nexport function createMessageResolver(\n catalogue?: ValidationMessageCatalogue,\n labels?: Readonly<Record<string, string>>,\n): ResolveValidationMessage {\n const table: ValidationMessageCatalogue = catalogue\n ? { ...defaultValidationMessages, ...catalogue }\n : defaultValidationMessages;\n\n return (issue, path) => {\n const code = issue.code;\n const entry = code !== undefined && Object.hasOwn(table, code) ? table[code] : undefined;\n const labelKey = toLabelKey(path);\n const label =\n labels === undefined\n ? undefined\n : Object.hasOwn(labels, path)\n ? labels[path]\n : Object.hasOwn(labels, labelKey)\n ? labels[labelKey]\n : undefined;\n if (entry === undefined) return issue.message;\n\n let rendered: string;\n try {\n rendered = entry({\n code: code as string,\n params: issue.params ?? EmptyParameters,\n path,\n label,\n message: issue.message,\n });\n } catch {\n // A caller-supplied entry threw. A message is never worth a second failure — defer to the source.\n return issue.message;\n }\n\n if (typeof rendered !== 'string' || rendered.length === 0) return issue.message;\n return label === undefined || rendered === issue.message ? rendered : `${label} ${rendered}`;\n };\n}\n"],"names":[],"mappings":";AAyCO,MAAM,kBAAkB;AAAA;AAAA,EAE7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AACF;AAUO,MAAM,wBAAkE,OAAO,OAAO;AAAA,EAC3F,mBAAmB;AAAA,EACnB,kBAAkB;AAAA,EAClB,eAAe;AAAA,EACf,gBAAgB;AAAA,EAChB,wBAAwB;AAAA,EACxB,wBAAwB;AAAA,EACxB,sBAAsB;AAAA,EACtB,iBAAiB;AAAA,EACjB,4BAA4B;AAAA,EAC5B,gBAAgB;AAAA,EAChB,qBAAqB;AAAA,EACrB,eAAe;AAAA,EACf,sBAAsB;AAAA,EACtB,6BAA6B;AAAA,EAC7B,mBAAmB;AAAA,EACnB,0BAA0B;AAAA,EAC1B,2BAA2B;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AG,2BAA2B,GAAG,cACnC;AAEJ,SAAO,CAAC,OAAO,SAAS;AACtB,UAAM,OAAO,MAAM;AACnB,UAAM,QAAQ,SAAS,UAAa,OAAO,OAAO,OAAO,IAAI,IAAI,MAAM,IAAI,IAAI;AAC/E,UAAM,WAAW,WAAW,IAAI;AAChC,UAAM,QACJ,WAAW,SACP,SACA,OAAO,OAAO,QAAQ,IAAI,IACxB,OAAO,IAAI,IACX,OAAO,OAAO,QAAQ,QAAQ,IAC5B,OAAO,QAAQ,IACf;AACV,QAAI,UAAU,OAAW,QAAO,MAAM;AAEtC,QAAI;AACJ,QAAI;AACF,iBAAW,MAAM;AAAA,QACf;AAAA,QACA,QAAQ,MAAM,UAAU;AAAA,QACxB;AAAA,QACA;AAAA,QACA,SAAS,MAAM;AAAA,MAAA,CAChB;AAAA,IACH,QAAQ;AAEN,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,OAAO,aAAa,YAAY,SAAS,WAAW,UAAU,MAAM;AACxE,WAAO,UAAU,UAAa,aAAa,MAAM,UAAU,WAAW,GAAG,KAAK,IAAI,QAAQ;AAAA,EAC5F;AACF;"}
1
+ {"version":3,"file":"Messages.js","sources":["../../../src/foundation/validators/Messages.ts"],"sourcesContent":["// The shared rule-code vocabulary and the message catalogue that renders it. This slice's reason to\n// exist is NOT to save strings — it is to make the client and the server speak with ONE voice for one\n// rule. A user who reads \"Name is required\" from the client and \"'Name' must not be empty.\" from the\n// server is hearing two voices for the same failure, and that is the drift that actually shows.\n//\n// WHY A VOCABULARY, NOT A SHARED RULE SET: each layer validates its own scope and neither delegates\n// (`conventions/development/backend/foundation/validators.md` § Layer independence). Sharing rule\n// DEFINITIONS would break that; sharing the machine tag a rule reports does not — a tag is presentation\n// metadata, not authority. Client rules stay a latency optimisation; the server stays the authority.\n//\n// WHY THE SERVER MESSAGE IS THE FALLBACK, NEVER THE OVERRIDE: adoption has to be incremental. A code\n// this catalogue does not know renders the message the server already sent, so wiring the catalogue can\n// never make a form worse — the worst case is the behaviour that existed before it.\n//\n// WHY PARAMS EXIST: a catalogue entry that cannot reach the `50` in \"at most 50 characters\" can only\n// emit parameterless strings, which is a catalogue that cannot replace the messages it is meant to\n// replace. Every built-in refinement therefore reports its own limits alongside its code.\n//\n// TWO VOCABULARIES MEET HERE. The house validators report `min` / `max` / `pattern`; FluentValidation\n// reports `MinimumLengthValidator` / `MaximumLengthValidator` / `RegularExpressionValidator`. Neither is\n// wrong and neither wins by default — `FluentValidationCodes` normalizes the server's onto this one so\n// a single catalogue serves both. The alias pass lives on the CLIENT deliberately: it lets a form adopt\n// the catalogue before the backend normalizes anything, and it keeps working unchanged afterwards.\n\nimport { ExactNumber } from '../numbers';\n\n/** A field-level failure widened to carry its machine tag — the channel a catalogue can key on. */\nexport interface FieldIssue {\n /** The authoring or server message. Always present; used verbatim when no catalogue entry matches. */\n readonly message: string;\n /** The normalized rule code (`required`, `min`, `pattern`, …). Absent when the source reported none. */\n readonly code?: string;\n /** The rule's own operands (`{ max: 50 }`), normalized to the vocabulary's names. */\n readonly params?: Readonly<Record<string, unknown>>;\n}\n\n/**\n * The rule codes this ecosystem speaks. The client's own validators report a subset (`type`, `min`,\n * `pattern`, …); the rest arrive from the server. Kept as one flat union because a catalogue keys on it\n * and a split would mean two lookups for one concept.\n */\nexport const ValidationCodes = [\n // shape / presence\n 'required',\n 'type',\n 'mustBeNull',\n 'mustBeEmpty',\n // size\n 'min',\n 'max',\n 'length',\n 'integer',\n 'precision',\n // comparison\n 'greaterThan',\n 'lessThan',\n 'between',\n 'betweenExclusive',\n 'equal',\n 'notEqual',\n // shape membership\n 'literal',\n 'oneOf',\n 'union',\n // format\n 'pattern',\n 'email',\n 'url',\n 'uuid',\n 'isoDate',\n 'creditCard',\n 'phone',\n // escape hatches\n 'custom',\n 'transform',\n 'internal',\n] as const;\n\n/** A member of the shared rule-code vocabulary. */\nexport type ValidationCode = (typeof ValidationCodes)[number];\n\n/**\n * Maps FluentValidation's `ErrorCode` onto the shared vocabulary. Covers the built-in validators whose\n * failures reach a form; anything absent falls through with its raw code, which simply misses the\n * catalogue and renders the server's own message.\n */\nexport const FluentValidationCodes: Readonly<Record<string, ValidationCode>> = Object.freeze({\n NotEmptyValidator: 'required',\n NotNullValidator: 'required',\n NullValidator: 'mustBeNull',\n EmptyValidator: 'mustBeEmpty',\n MinimumLengthValidator: 'min',\n MaximumLengthValidator: 'max',\n ExactLengthValidator: 'length',\n LengthValidator: 'length',\n RegularExpressionValidator: 'pattern',\n EmailValidator: 'email',\n CreditCardValidator: 'creditCard',\n EnumValidator: 'oneOf',\n GreaterThanValidator: 'greaterThan',\n GreaterThanOrEqualValidator: 'min',\n LessThanValidator: 'lessThan',\n LessThanOrEqualValidator: 'max',\n InclusiveBetweenValidator: 'between',\n ExclusiveBetweenValidator: 'betweenExclusive',\n EqualValidator: 'equal',\n NotEqualValidator: 'notEqual',\n ScalePrecisionValidator: 'precision',\n PredicateValidator: 'custom',\n AsyncPredicateValidator: 'custom',\n});\n\n/**\n * Maps FluentValidation's message placeholders onto the vocabulary's param names, so one catalogue entry\n * reads the same operand whichever side reported it. Unlisted placeholders pass through unchanged —\n * `PropertyName` deliberately among them, since the label is resolved from the form, not the payload.\n */\nexport const FluentValidationParameters: Readonly<Record<string, string>> = Object.freeze({\n MinLength: 'min',\n MaxLength: 'max',\n TotalLength: 'length',\n ComparisonValue: 'comparison',\n ComparisonProperty: 'comparisonLabel',\n From: 'from',\n To: 'to',\n ExpectedPrecision: 'precision',\n ExpectedScale: 'scale',\n});\n\n/** What a catalogue entry renders from. */\nexport interface ValidationMessageContext {\n /** The normalized rule code that failed. */\n readonly code: string;\n /** The rule's operands, vocabulary-named. Empty when the source reported none. */\n readonly params: Readonly<Record<string, unknown>>;\n /** The form path the failure is filed under; `''` for a form-level failure. */\n readonly path: string;\n /** The field's display label, when the form named one. Absent means render label-free. */\n readonly label?: string;\n /** The originating message — return this to defer to the source. */\n readonly message: string;\n}\n\n/** Renders one rule code into user-facing text. */\nexport type ValidationMessageEntry = (context: ValidationMessageContext) => string;\n\n/** A code → renderer table. Partial by design: an unlisted code falls back to the source's message. */\nexport type ValidationMessageCatalogue = Readonly<Record<string, ValidationMessageEntry>>;\n\n/** Resolves one issue at one path into the string a field renders. */\nexport type ResolveValidationMessage = (issue: FieldIssue, path: string) => string;\n\n/** Reads a numeric operand, tolerating the string form a JSON payload may carry. */\nfunction operand(params: Readonly<Record<string, unknown>>, key: string): string | null {\n const value = Object.hasOwn(params, key) ? params[key] : undefined;\n if (ExactNumber.isExactNumber(value)) return value.toString();\n if (typeof value === 'number' && Number.isFinite(value)) return String(value);\n if (typeof value === 'string' && value.length > 0) return value;\n return null;\n}\n\n/** Pluralizes the character-count fragments the size rules share. */\nfunction characters(count: string): string {\n return `${count} character${count === '1' ? '' : 's'}`;\n}\n\n/** Pluralizes the item-count fragments the collection size rules share. */\nfunction items(count: string): string {\n return `${count} item${count === '1' ? '' : 's'}`;\n}\n\n/**\n * The English voice for the vocabulary. Entries are FRAGMENTS, not sentences — a field message renders\n * under its own labelled control, so \"must be at least 2 characters\" reads correctly and repeating the\n * label there is noise. A form that supplies `labels` gets the label prefixed by `createMessageResolver`,\n * which is the form-level and cross-field case where the fragment alone would be unaddressed.\n *\n * An entry that cannot render (its operand never arrived) returns `context.message`, so a half-populated\n * payload degrades to the source's wording instead of to \"must be at most undefined\".\n */\nexport const defaultValidationMessages: ValidationMessageCatalogue = Object.freeze({\n required: () => 'is required',\n type: (context) => context.message,\n mustBeNull: () => 'must be empty',\n mustBeEmpty: () => 'must be empty',\n\n min: (context) => {\n const limit = operand(context.params, 'min');\n if (limit === null) return context.message;\n switch (operand(context.params, 'unit')) {\n case 'characters':\n return `must be at least ${characters(limit)}`;\n case 'items':\n return `must have at least ${items(limit)}`;\n case 'instant':\n return `must be on or after ${limit}`;\n default:\n return `must be at least ${limit}`;\n }\n },\n max: (context) => {\n const limit = operand(context.params, 'max');\n if (limit === null) return context.message;\n switch (operand(context.params, 'unit')) {\n case 'characters':\n return `must be at most ${characters(limit)}`;\n case 'items':\n return `must have at most ${items(limit)}`;\n case 'instant':\n return `must be on or before ${limit}`;\n default:\n return `must be at most ${limit}`;\n }\n },\n length: (context) => {\n const exact = operand(context.params, 'length');\n if (exact === null) return context.message;\n if (operand(context.params, 'unit') === 'items') return `must have exactly ${items(exact)}`;\n return `must be exactly ${characters(exact)}`;\n },\n integer: () => 'must be a whole number',\n precision: (context) => {\n const scale = operand(context.params, 'scale');\n return scale === null ? context.message : `must have at most ${scale} decimal places`;\n },\n\n greaterThan: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must be greater than ${comparison}`;\n },\n lessThan: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must be less than ${comparison}`;\n },\n between: (context) => {\n const from = operand(context.params, 'from');\n const to = operand(context.params, 'to');\n return from === null || to === null ? context.message : `must be between ${from} and ${to}`;\n },\n betweenExclusive: (context) => {\n const from = operand(context.params, 'from');\n const to = operand(context.params, 'to');\n return from === null || to === null ? context.message : `must be between ${from} and ${to}, exclusive`;\n },\n equal: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must equal ${comparison}`;\n },\n notEqual: (context) => {\n const comparison = operand(context.params, 'comparison');\n return comparison === null ? context.message : `must not equal ${comparison}`;\n },\n\n literal: (context) => context.message,\n oneOf: (context) => context.message,\n union: (context) => context.message,\n\n pattern: (context) => context.message,\n email: () => 'must be a valid email address',\n url: () => 'must be a valid URL',\n uuid: () => 'must be a valid UUID',\n isoDate: () => 'must be a valid ISO date (YYYY-MM-DD)',\n creditCard: () => 'must be a valid card number',\n phone: (context) => {\n const dial = operand(context.params, 'dial');\n const length = operand(context.params, 'length');\n if (dial !== null && length !== null) return `must have ${length} digits after ${dial}`;\n const min = operand(context.params, 'min');\n const max = operand(context.params, 'max');\n if (dial !== null && min !== null && max !== null) return `must have ${min} to ${max} digits after ${dial}`;\n return 'must be a valid phone number';\n },\n\n custom: (context) => context.message,\n transform: (context) => context.message,\n internal: (context) => context.message,\n});\n\nconst EmptyParameters: Readonly<Record<string, unknown>> = Object.freeze({});\n\n/**\n * Strips array indices so one label serves every row: `rules[0].destination` → `rules[].destination`.\n * Looked up only after the exact path misses, so a per-row override stays possible.\n */\nfunction toLabelKey(path: string): string {\n return path.replace(/\\[\\d+\\]/g, '[]');\n}\n\n/**\n * Builds the resolver the form engines call for every message they are about to render.\n *\n * Resolution order per issue: the caller's catalogue → {@link defaultValidationMessages} → the issue's\n * own message. A known label is prefixed to the rendered fragment; an unlabelled field renders the\n * fragment alone, which is what every message in this SDK did before a catalogue existed.\n *\n * `catalogue` is MERGED over the defaults rather than replacing them, so overriding one code's wording —\n * or translating a handful — never silently drops the rest of the vocabulary.\n */\nexport function createMessageResolver(\n catalogue?: ValidationMessageCatalogue,\n labels?: Readonly<Record<string, string>>,\n): ResolveValidationMessage {\n const table: ValidationMessageCatalogue = catalogue\n ? { ...defaultValidationMessages, ...catalogue }\n : defaultValidationMessages;\n\n return (issue, path) => {\n const code = issue.code;\n const entry = code !== undefined && Object.hasOwn(table, code) ? table[code] : undefined;\n const labelKey = toLabelKey(path);\n const label =\n labels === undefined\n ? undefined\n : Object.hasOwn(labels, path)\n ? labels[path]\n : Object.hasOwn(labels, labelKey)\n ? labels[labelKey]\n : undefined;\n if (entry === undefined) return issue.message;\n\n let rendered: string;\n try {\n rendered = entry({\n code: code as string,\n params: issue.params ?? EmptyParameters,\n path,\n label,\n message: issue.message,\n });\n } catch {\n // A caller-supplied entry threw. A message is never worth a second failure — defer to the source.\n return issue.message;\n }\n\n if (typeof rendered !== 'string' || rendered.length === 0) return issue.message;\n return label === undefined || rendered === issue.message ? rendered : `${label} ${rendered}`;\n };\n}\n"],"names":[],"mappings":";AAyCO,MAAM,kBAAkB;AAAA;AAAA,EAE7B;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA;AAAA,EAEA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA,EACA;AAAA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SACA,OAAO,OAAO,QAAQ,IAAI,IACxB,OAAO,IAAI,IACX,OAAO,OAAO,QAAQ,QAAQ,IAC5B,OAAO,QAAQ,IACf;AACV,QAAI,UAAU,OAAW,QAAO,MAAM;AAEtC,QAAI;AACJ,QAAI;AACF,iBAAW,MAAM;AAAA,QACf;AAAA,QACA,QAAQ,MAAM,UAAU;AAAA,QACxB;AAAA,QACA;AAAA,QACA,SAAS,MAAM;AAAA,MAAA,CAChB;AAAA,IACH,QAAQ;AAEN,aAAO,MAAM;AAAA,IACf;AAEA,QAAI,OAAO,aAAa,YAAY,SAAS,WAAW,UAAU,MAAM;AACxE,WAAO,UAAU,UAAa,aAAa,MAAM,UAAU,WAAW,GAAG,KAAK,IAAI,QAAQ;AAAA,EAC5F;AACF;"}
@@ -3,6 +3,6 @@ export { type StandardSchemaV1 } from './StandardSchema';
3
3
  export { type ParseFn, type Infer, type InferInput, Validator, ValidationVendor, toStandardResult, toStandardSchema, } from './Validator';
4
4
  export { StringValidator, NumberValidator, ExactNumberValidator, DateValidator, string, number, exactNumber, boolean, date, literal, oneOf, } from './Primitives';
5
5
  export { type ObjectShape, type InferObject, type InferTuple, ArrayValidator, object, array, record, union, tuple, } from './Composites';
6
- export { email, url, uuid, isoDate } from './Formats';
6
+ export { type PhoneRuleOptions, email, url, uuid, isoDate, phone } from './Formats';
7
7
  export { ValidationError, assertValid } from './ValidationError';
8
8
  export { type FieldIssue, type ValidationCode, type ValidationMessageContext, type ValidationMessageEntry, type ValidationMessageCatalogue, type ResolveValidationMessage, ValidationCodes, FluentValidationCodes, FluentValidationParameters, defaultValidationMessages, createMessageResolver, } from './Messages';
@@ -2,7 +2,7 @@ import { describeType, formatIssuePath, invalid, valid } from "./ValidationOutco
2
2
  import { ValidationVendor, Validator, toStandardResult, toStandardSchema } from "./Validator.js";
3
3
  import { DateValidator, ExactNumberValidator, NumberValidator, StringValidator, boolean, date, exactNumber, literal, number, oneOf, string } from "./Primitives.js";
4
4
  import { ArrayValidator, array, object, record, tuple, union } from "./Composites.js";
5
- import { email, isoDate, url, uuid } from "./Formats.js";
5
+ import { email, isoDate, phone, url, uuid } from "./Formats.js";
6
6
  import { ValidationError, assertValid } from "./ValidationError.js";
7
7
  import { FluentValidationCodes, FluentValidationParameters, ValidationCodes, createMessageResolver, defaultValidationMessages } from "./Messages.js";
8
8
  export {
@@ -33,6 +33,7 @@ export {
33
33
  number,
34
34
  object,
35
35
  oneOf,
36
+ phone,
36
37
  record,
37
38
  string,
38
39
  toStandardResult,
package/dist/index.js CHANGED
@@ -146,7 +146,7 @@ import { default as default142, DescriptionGroupDensity, DescriptionGroupLayout
146
146
  import { default as default143, default as default144, ModalRole } from "./presentation/overlays/modal/Modal.vue.js";
147
147
  import { default as default145, default as default146, default as default147 } from "./presentation/overlays/OverlayBody.vue.js";
148
148
  import { default as default148, default as default149, default as default150 } from "./presentation/overlays/OverlayCloseButton.vue.js";
149
- import { default as default151, default as default152, ModalPhoneLayout, ModalSize } from "./presentation/overlays/modal/ModalContent.vue.js";
149
+ import { default as default151, default as default152, ModalHeight, ModalPhoneLayout, ModalSize } from "./presentation/overlays/modal/ModalContent.vue.js";
150
150
  import { default as default153, default as default154, default as default155 } from "./presentation/overlays/OverlayFooter.vue.js";
151
151
  import { default as default156, default as default157, default as default158 } from "./presentation/overlays/OverlayHeader.vue.js";
152
152
  import { default as default159, default as default160 } from "./presentation/overlays/modal/ModalTrigger.vue.js";
@@ -291,7 +291,7 @@ import { default as default299 } from "./presentation/forms/passwordInput/Passwo
291
291
  import { default as default300 } from "./presentation/feedback/passwordStrengthCallout/PasswordStrengthCallout.vue.js";
292
292
  import { default as default301 } from "./presentation/display/pdfViewer/PdfViewer.vue.js";
293
293
  import { default as default302 } from "./presentation/forms/percentInput/PercentInput.vue.js";
294
- import { PhoneCountries, default as default303 } from "./presentation/forms/phoneInput/PhoneInput.vue.js";
294
+ import { default as default303 } from "./presentation/forms/phoneInput/PhoneInput.vue.js";
295
295
  import { default as default304, PinInputType } from "./presentation/forms/pinInput/PinInput.vue.js";
296
296
  import { default as default305 } from "./presentation/overlays/popover/Popover.vue.js";
297
297
  import { default as default306 } from "./presentation/overlays/popover/PopoverArrow.vue.js";
@@ -458,6 +458,7 @@ import { ListboxPickerItemState } from "./presentation/forms/listboxPicker/Listb
458
458
  import { MenuItemState, menuItemIndicatorVariants, menuItemVariants, menuLabelVariants, menuSeparatorVariants, menuSubIndicatorVariants, menuVariants } from "./presentation/nav/menu/Menu.variants.js";
459
459
  import { MenuKey, MenuRadioGroupKey, MenuSubKey, MenuSubOpenReason, MenuTreeKey, useMenuContext, useMenuRadioGroupContext, useMenuSubContext } from "./presentation/nav/menu/MenuContext.js";
460
460
  import { NavbarElement, NavbarHeight, NavbarOrientation, NavbarVariant, navbarVariants } from "./presentation/layout/navbar/Navbar.variants.js";
461
+ import { PhoneCountries } from "./foundation/phone/PhoneCountries.js";
461
462
  import { RadioGroupKey, useRadioGroup } from "./presentation/forms/radioGroup/RadioGroupContext.js";
462
463
  import { SectionPaddingY, sectionVariants } from "./presentation/layout/section/Section.variants.js";
463
464
  import { SelectPickerSize, selectTriggerVariants } from "./presentation/forms/selectPicker/SelectPicker.variants.js";
@@ -868,6 +869,7 @@ export {
868
869
  default54 as ModalDescription,
869
870
  default155 as ModalFooter,
870
871
  default158 as ModalHeader,
872
+ ModalHeight,
871
873
  ModalPhoneLayout,
872
874
  ModalRole,
873
875
  ModalSize,
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -1 +1 @@
1
- {"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;yBAClD,MAA+D;AAAA,UAA9C,CAAAA,MAAA,KAAA,EAAM,2BAAvBG,mBAA+DC,UAAA,EAAA,KAAA,KAAA;AAAA,YAAzBC,gBAAAC,gBAAAN,MAAA,KAAA,EAAM,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
1
+ {"version":3,"file":"RefreshButton.vue.js","sources":["../../../../src/presentation/actions/refreshButton/RefreshButton.vue"],"sourcesContent":["<script lang=\"ts\">\nimport type { ButtonProps } from '../button';\n\n/** @internal The `ButtonProps` this preset decides itself. */\ntype OwnedButtonProp = keyof Pick<ButtonProps, 'isLoading' | 'shape' | 'leadingSlot'>;\n\n/** Defines the forwarded `ButtonProps`, minus the ones the refresh preset sets. */\ntype RefreshButtonAttributes = Omit<ButtonProps, OwnedButtonProp>;\n\n/** Defines props for the one refresh control a region shows. */\nexport interface RefreshButtonProps extends /* @vue-ignore */ RefreshButtonAttributes {\n /** True from the click until the refresh settles — `useRefresh`'s `refreshing`; the icon spins and clicks wait. */\n readonly isRefreshing?: boolean;\n\n /** The visible label, or the accessible name of an icon-only button. Default `\"Refresh\"`, localized. */\n readonly label?: string;\n\n /** Renders the icon alone, square at its size, named by `label`. */\n readonly isIconOnly?: boolean;\n\n /** The visual surface style. Default `outline`; `ghost` inside a panel header. */\n readonly variant?: ButtonProps['variant'];\n\n /** The size step. Default `sm`; `md` beside page-level controls. */\n readonly size?: ButtonProps['size'];\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs } from 'vue';\nimport { RefreshCw } from 'lucide-vue-next';\nimport { useLocaleDefaults } from '../../../foundation/i18n';\nimport { Icon } from '../../../foundation/icons';\nimport Button from '../button/Button.vue';\n\n/**\n * Renders the refresh control a region reruns its reads with — a `Button` preset that swaps the refresh icon for the\n * spinner while `isRefreshing`, keeps its label and width, and swallows repeat clicks until the refresh settles. Pair\n * it with `useRefresh` from `@wow-two-beta/fe/query`, which also drives the region's placeholders.\n */\ndefineOptions({ name: 'RefreshButton', inheritAttrs: false });\n\nconst componentProps = withDefaults(defineProps<RefreshButtonProps>(), {\n isRefreshing: false,\n label: undefined,\n isIconOnly: false,\n variant: 'outline',\n size: 'sm',\n});\nconst props = useLocaleDefaults(componentProps, 'RefreshButton', { label: 'Refresh' });\n\nconst attrs = useAttrs();\n\n/** The icon-only form names itself through `aria-label`, and `title` shows the name on hover. */\nconst naming = computed(() =>\n props.isIconOnly ? { 'aria-label': props.label, title: props.label } : ({} as Record<string, string>),\n);\n</script>\n\n<template>\n <Button\n tone=\"neutral\"\n :variant=\"props.variant\"\n :size=\"props.size\"\n :shape=\"props.isIconOnly ? 'square' : 'default'\"\n :is-loading=\"props.isRefreshing\"\n v-bind=\"{ ...naming, ...attrs }\"\n >\n <template #leading><Icon :icon=\"RefreshCw\" :size=\"14\" /></template>\n <template v-if=\"!props.isIconOnly\">{{ props.label }}</template>\n </Button>\n</template>\n"],"names":["_openBlock","_createBlock","Button","_mergeProps","_unref","_createVNode","Icon","_createElementBlock","_Fragment","_createTextVNode","_toDisplayString"],"mappings":";;;;;;;;;;;;;;;;AA0CA,UAAM,iBAAiB;AAOvB,UAAM,QAAQ,kBAAkB,gBAAgB,iBAAiB,EAAE,OAAO,WAAW;AAErF,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS;AAAA,MAAS,MACtB,MAAM,aAAa,EAAE,cAAc,MAAM,OAAO,OAAO,MAAM,UAAW,CAAA;AAAA,IAAC;;AAKzE,aAAAA,UAAA,GAAAC,YAUSC,aAVTC,WAUS;AAAA,QATP,MAAK;AAAA,QACJ,SAASC,MAAA,KAAA,EAAM;AAAA,QACf,MAAMA,MAAA,KAAA,EAAM;AAAA,QACZ,OAAOA,MAAA,KAAA,EAAM,aAAU,WAAA;AAAA,QACvB,cAAYA,MAAA,KAAA,EAAM;AAAA,MAAA,GACN,EAAA,GAAA,OAAA,UAAWA,MAAA,KAAA,EAAA,CAAK,GAAA;AAAA,QAElB,iBAAQ,MAAqC;AAAA,UAArCC,YAAqCD,MAAAE,WAAA,GAAA;AAAA,YAA9B,MAAMF,MAAA,SAAA;AAAA,YAAY,MAAM;AAAA,UAAA;;yBATuC,MAGjF;AAAA,UAOS,CAAAA,MAAA,KAAA,EAAM,2BAAvBG,mBAA+DC,UAAA,EAAA,KAAA,KAAA;AAAA,YAAzBC,gBAAAC,gBAAAN,MAAA,KAAA,EAAM,KAAK,GAAA,CAAA;AAAA,UAAA;;;;;;;"}
@@ -42,7 +42,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
42
42
  const passthroughAttrs = computed(
43
43
  () => Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key)))
44
44
  );
45
- const rootClass = computed(() => cn("flex flex-col gap-1.5", attrs.class));
45
+ const rootClass = computed(() => cn("flex flex-col", attrs.class));
46
46
  const root = useTemplateRef("root");
47
47
  __expose({ el: root });
48
48
  return (_ctx, _cache) => {
@@ -62,7 +62,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
62
62
  "aria-busy": props.isSkeleton || void 0,
63
63
  class: rootClass.value
64
64
  }, passthroughAttrs.value), [
65
- hasLabel.value ? (openBlock(), createBlock(_sfc_main$2, { key: 0 }, {
65
+ hasLabel.value ? (openBlock(), createBlock(_sfc_main$2, {
66
+ key: 0,
67
+ class: "mb-1.5"
68
+ }, {
66
69
  default: withCtx(() => [
67
70
  renderSlot(_ctx.$slots, "label", {}, () => [
68
71
  createTextVNode(toDisplayString(__props.label), 1)
@@ -73,6 +76,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
73
76
  renderSlot(_ctx.$slots, "default"),
74
77
  showError.value ? (openBlock(), createBlock(_sfc_main$3, {
75
78
  key: 1,
79
+ class: "mt-1.5",
76
80
  message: hasOwnError.value ? __props.error : void 0
77
81
  }, createSlots({ _: 2 }, [
78
82
  hasOwnError.value && _ctx.$slots.error ? {
@@ -82,7 +86,10 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
82
86
  ]),
83
87
  key: "0"
84
88
  } : void 0
85
- ]), 1032, ["message"])) : hasHelper.value ? (openBlock(), createBlock(_sfc_main$4, { key: 2 }, {
89
+ ]), 1032, ["message"])) : hasHelper.value ? (openBlock(), createBlock(_sfc_main$4, {
90
+ key: 2,
91
+ class: "mt-1.5"
92
+ }, {
86
93
  default: withCtx(() => [
87
94
  renderSlot(_ctx.$slots, "helper", {}, () => [
88
95
  createTextVNode(toDisplayString(__props.helper), 1)
@@ -1 +1 @@
1
- {"version":3,"file":"Field.vue.js","sources":["../../../../src/presentation/forms/field/Field.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface FieldProps {\n /** The label text. Fill the `label` slot instead for richer content (e.g. label + tooltip). */\n readonly label?: string | number;\n\n /** The helper / hint shown beneath the control. Hidden while errors show. */\n readonly helper?: string | number;\n\n /**\n * The error text — renders only when truthy. Sets `isInvalid` on the form context.\n * Inside a forms-engine `Field` this is an OVERRIDE: leave it unset and the\n * field's own errors (client + server, all of them) render automatically.\n */\n readonly error?: string | number;\n\n /** The required state (also exposes `isRequired` to the control via context). */\n readonly isRequired?: boolean;\n\n /** The disabled state (also exposes `isDisabled` to the control). */\n readonly isDisabled?: boolean;\n\n /** The read-only state (also exposes `isReadOnly` to the control). */\n readonly isReadOnly?: boolean;\n\n /** Keeps the layout and draws the label, control and helper as skeletons; defaults to the nearest `DataRegion`. */\n readonly isSkeleton?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs, useSlots, useTemplateRef } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { cn } from '../../../foundation/styles';\nimport { FormControlProvider, useFormControl } from '../../../foundation/primitives';\nimport LabelText from '../../display/labelText/LabelText.vue';\nimport FieldHelperText from '../../display/fieldHelperText/FieldHelperText.vue';\nimport FieldErrorCallout from '../../feedback/fieldErrorCallout/FieldErrorCallout.vue';\nimport { provideSkeletonState, useSkeletonState } from '../../feedback/skeletonState/SkeletonStateContext';\n\n/**\n * Renders label, control, helper and error as one block, wiring the control through form-control context.\n *\n * Wraps the default slot in a `FormControlProvider` so the inner control auto-wires `id`,\n * `aria-describedby`, `aria-invalid`, `disabled`, `required`, `readOnly`.\n *\n * Form-aware: composed inside a forms-engine `Field` it ADOPTS the glue's context\n * instead of shadowing it — same ids, inherited `isInvalid`/flags, and the field's\n * errors render without hand-wiring (`error` stays as an override). Standalone (no\n * surrounding provider) it behaves exactly as before.\n *\n * Each of React's three `ReactNode` props keeps its scalar form and gains a\n * same-named slot for richer content; the prop stays the discriminator.\n */\n/* `inheritAttrs: false` so `class` folds into the component's own `cn()` call — plain fallthrough\n appends outside it and loses tailwind-merge conflict resolution. */\ndefineOptions({ name: 'Field', inheritAttrs: false });\n\nconst props = withDefaults(defineProps<FieldProps>(), {\n /* Explicit `undefined` defaults are load-bearing: each flag falls back to the PARENT\n context's value, and Vue's Boolean casting would turn an absent prop into an explicit\n `false` that shadows the parent instead of deferring to it. */\n isRequired: undefined,\n isDisabled: undefined,\n isReadOnly: undefined,\n isSkeleton: undefined,\n});\n\n/* One flag switches the label, the control and the helper; each draws its own skeleton in its own box. */\nconst skeleton = useSkeletonState(() => props.isSkeleton);\nprovideSkeletonState(skeleton);\n\n/** The single form control (TextInput, SelectPicker, …) — receives wired id/aria via context. */\ndefineSlots<{\n default(): unknown;\n label?(): unknown;\n helper?(): unknown;\n error?(): unknown;\n}>();\n\nconst attrs = useAttrs();\nconst slots = useSlots();\n\n/* `parent` is a live-getter object — read fields off it, never destructure. */\nconst parent = useFormControl();\n\nconst hasLabel = computed(() => Boolean(props.label) || Boolean(slots.label));\nconst hasHelper = computed(() => Boolean(props.helper) || Boolean(slots.helper));\nconst hasOwnError = computed(() => Boolean(props.error) || Boolean(slots.error));\n\n/* Mirrors FieldErrorCallout's visibility so the helper never hides behind an error\n that won't render. */\nconst showError = computed(\n () => hasOwnError.value || ((parent?.errors?.length ?? 0) > 0 && (parent?.isInvalid ?? false)),\n);\n\nconst parentId = computed(() => parent?.id);\nconst parentErrors = computed(() => parent?.errors);\nconst isInvalid = computed(() => hasOwnError.value || (parent?.isInvalid ?? false));\nconst isRequired = computed(() => props.isRequired ?? parent?.isRequired);\nconst isDisabled = computed(() => props.isDisabled ?? parent?.isDisabled);\nconst isReadOnly = computed(() => props.isReadOnly ?? parent?.isReadOnly);\n\nconst OwnedAttributes: ReadonlySet<string> = new Set(['class']);\nconst passthroughAttrs = computed(() =>\n Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key))),\n);\n\nconst rootClass = computed(() => cn('flex flex-col gap-1.5', attrs.class as ClassValue));\n\nconst root = useTemplateRef<HTMLDivElement>('root');\n\n/** The rendered element — the Vue stand-in for the React original's forwarded ref. */\ndefineExpose({ el: root });\n</script>\n\n<template>\n <FormControlProvider\n :id=\"parentId\"\n :errors=\"parentErrors\"\n :is-invalid=\"isInvalid\"\n :is-required=\"isRequired\"\n :is-disabled=\"isDisabled\"\n :is-read-only=\"isReadOnly\"\n >\n <div\n ref=\"root\"\n :data-skeleton=\"skeleton.isSkeleton.value || undefined\"\n :aria-busy=\"props.isSkeleton || undefined\"\n :class=\"rootClass\"\n v-bind=\"passthroughAttrs\"\n >\n <LabelText v-if=\"hasLabel\">\n <slot name=\"label\">{{ label }}</slot>\n </LabelText>\n\n <slot />\n\n <FieldErrorCallout v-if=\"showError\" :message=\"hasOwnError ? error : undefined\">\n <!-- Passed only when this Field owns the error: an always-present default slot\n would read as an override and suppress the context's own `errors`. -->\n <template v-if=\"hasOwnError && $slots.error\" #default>\n <slot name=\"error\" />\n </template>\n </FieldErrorCallout>\n <FieldHelperText v-else-if=\"hasHelper\">\n <slot name=\"helper\">{{ helper }}</slot>\n </FieldHelperText>\n </div>\n </FormControlProvider>\n</template>\n"],"names":["_createBlock","_unref","FormControlProvider","_createElementVNode","_mergeProps","LabelText","_renderSlot","FieldErrorCallout","$slots","FieldHelperText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDA,UAAM,QAAQ;AAWd,UAAM,WAAW,iBAAiB,MAAM,MAAM,UAAU;AACxD,yBAAqB,QAAQ;AAU7B,UAAM,QAAQ,SAAA;AACd,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS,eAAA;AAEf,UAAM,WAAW,SAAS,MAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC;AAC5E,UAAM,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,KAAK,QAAQ,MAAM,MAAM,CAAC;AAC/E,UAAM,cAAc,SAAS,MAAM,QAAQ,MAAM,KAAK,K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AAA,sBAAjBD,YAEYK,aAAA,EAAA,KAAA,KAAA;AAAA,+BADV,MAAqC;AAAA,gBAArCC,WAAqC,0BAArC,MAAqC;AAAA,kDAAf,QAAA,KAAK,GAAA,CAAA;AAAA,gBAAA;;;;YAG7BA,WAAQ,KAAA,QAAA,SAAA;AAAA,YAEiB,UAAA,sBAAzBN,YAMoBO,aAAA;AAAA;cANiB,SAAS,YAAA,QAAc,QAAA,QAAQ;AAAA,YAAA;cAGlD,YAAA,SAAeC,KAAAA,OAAO;sBAAQ;AAAA,4BAC5C,MAAqB;AAAA,kBAArBF,WAAqB,KAAA,QAAA,OAAA;AAAA,gBAAA;;;sCAGG,UAAA,sBAA5BN,YAEkBS,aAAA,EAAA,KAAA,KAAA;AAAA,+BADhB,MAAuC;AAAA,gBAAvCH,WAAuC,2BAAvC,MAAuC;AAAA,kDAAhB,QAAA,MAAM,GAAA,CAAA;AAAA,gBAAA;;;;;;;;;;;"}
1
+ {"version":3,"file":"Field.vue.js","sources":["../../../../src/presentation/forms/field/Field.vue"],"sourcesContent":["<script lang=\"ts\">\nexport interface FieldProps {\n /** The label text. Fill the `label` slot instead for richer content (e.g. label + tooltip). */\n readonly label?: string | number;\n\n /** The helper / hint shown beneath the control. Hidden while errors show. */\n readonly helper?: string | number;\n\n /**\n * The error text — renders only when truthy. Sets `isInvalid` on the form context.\n * Inside a forms-engine `Field` this is an OVERRIDE: leave it unset and the\n * field's own errors (client + server, all of them) render automatically.\n */\n readonly error?: string | number;\n\n /** The required state (also exposes `isRequired` to the control via context). */\n readonly isRequired?: boolean;\n\n /** The disabled state (also exposes `isDisabled` to the control). */\n readonly isDisabled?: boolean;\n\n /** The read-only state (also exposes `isReadOnly` to the control). */\n readonly isReadOnly?: boolean;\n\n /** Keeps the layout and draws the label, control and helper as skeletons; defaults to the nearest `DataRegion`. */\n readonly isSkeleton?: boolean;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs, useSlots, useTemplateRef } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { cn } from '../../../foundation/styles';\nimport { FormControlProvider, useFormControl } from '../../../foundation/primitives';\nimport LabelText from '../../display/labelText/LabelText.vue';\nimport FieldHelperText from '../../display/fieldHelperText/FieldHelperText.vue';\nimport FieldErrorCallout from '../../feedback/fieldErrorCallout/FieldErrorCallout.vue';\nimport { provideSkeletonState, useSkeletonState } from '../../feedback/skeletonState/SkeletonStateContext';\n\n/**\n * Renders label, control, helper and error as one block, wiring the control through form-control context.\n *\n * Wraps the default slot in a `FormControlProvider` so the inner control auto-wires `id`,\n * `aria-describedby`, `aria-invalid`, `disabled`, `required`, `readOnly`.\n *\n * Form-aware: composed inside a forms-engine `Field` it ADOPTS the glue's context\n * instead of shadowing it — same ids, inherited `isInvalid`/flags, and the field's\n * errors render without hand-wiring (`error` stays as an override). Standalone (no\n * surrounding provider) it behaves exactly as before.\n *\n * Each of React's three `ReactNode` props keeps its scalar form and gains a\n * same-named slot for richer content; the prop stays the discriminator.\n */\n/* `inheritAttrs: false` so `class` folds into the component's own `cn()` call — plain fallthrough\n appends outside it and loses tailwind-merge conflict resolution. */\ndefineOptions({ name: 'Field', inheritAttrs: false });\n\nconst props = withDefaults(defineProps<FieldProps>(), {\n /* Explicit `undefined` defaults are load-bearing: each flag falls back to the PARENT\n context's value, and Vue's Boolean casting would turn an absent prop into an explicit\n `false` that shadows the parent instead of deferring to it. */\n isRequired: undefined,\n isDisabled: undefined,\n isReadOnly: undefined,\n isSkeleton: undefined,\n});\n\n/* One flag switches the label, the control and the helper; each draws its own skeleton in its own box. */\nconst skeleton = useSkeletonState(() => props.isSkeleton);\nprovideSkeletonState(skeleton);\n\n/** The single form control (TextInput, SelectPicker, …) — receives wired id/aria via context. */\ndefineSlots<{\n default(): unknown;\n label?(): unknown;\n helper?(): unknown;\n error?(): unknown;\n}>();\n\nconst attrs = useAttrs();\nconst slots = useSlots();\n\n/* `parent` is a live-getter object — read fields off it, never destructure. */\nconst parent = useFormControl();\n\nconst hasLabel = computed(() => Boolean(props.label) || Boolean(slots.label));\nconst hasHelper = computed(() => Boolean(props.helper) || Boolean(slots.helper));\nconst hasOwnError = computed(() => Boolean(props.error) || Boolean(slots.error));\n\n/* Mirrors FieldErrorCallout's visibility so the helper never hides behind an error\n that won't render. */\nconst showError = computed(\n () => hasOwnError.value || ((parent?.errors?.length ?? 0) > 0 && (parent?.isInvalid ?? false)),\n);\n\nconst parentId = computed(() => parent?.id);\nconst parentErrors = computed(() => parent?.errors);\nconst isInvalid = computed(() => hasOwnError.value || (parent?.isInvalid ?? false));\nconst isRequired = computed(() => props.isRequired ?? parent?.isRequired);\nconst isDisabled = computed(() => props.isDisabled ?? parent?.isDisabled);\nconst isReadOnly = computed(() => props.isReadOnly ?? parent?.isReadOnly);\n\nconst OwnedAttributes: ReadonlySet<string> = new Set(['class']);\nconst passthroughAttrs = computed(() =>\n Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key))),\n);\n\n/* Spacing is the chrome's own margin, never a flex `gap`: a password manager (NordPass and others) inserts its icon\n element beside a focused `<input>`, and a gap would open around that element and push the block — and a page\n centred on it — by the gap's height. A zero-size or absolutely positioned insert now moves nothing. */\nconst rootClass = computed(() => cn('flex flex-col', attrs.class as ClassValue));\n\nconst root = useTemplateRef<HTMLDivElement>('root');\n\n/** The rendered element — the Vue stand-in for the React original's forwarded ref. */\ndefineExpose({ el: root });\n</script>\n\n<template>\n <FormControlProvider\n :id=\"parentId\"\n :errors=\"parentErrors\"\n :is-invalid=\"isInvalid\"\n :is-required=\"isRequired\"\n :is-disabled=\"isDisabled\"\n :is-read-only=\"isReadOnly\"\n >\n <div\n ref=\"root\"\n :data-skeleton=\"skeleton.isSkeleton.value || undefined\"\n :aria-busy=\"props.isSkeleton || undefined\"\n :class=\"rootClass\"\n v-bind=\"passthroughAttrs\"\n >\n <LabelText v-if=\"hasLabel\" class=\"mb-1.5\">\n <slot name=\"label\">{{ label }}</slot>\n </LabelText>\n\n <slot />\n\n <FieldErrorCallout v-if=\"showError\" class=\"mt-1.5\" :message=\"hasOwnError ? error : undefined\">\n <!-- Passed only when this Field owns the error: an always-present default slot\n would read as an override and suppress the context's own `errors`. -->\n <template v-if=\"hasOwnError && $slots.error\" #default>\n <slot name=\"error\" />\n </template>\n </FieldErrorCallout>\n <FieldHelperText v-else-if=\"hasHelper\" class=\"mt-1.5\">\n <slot name=\"helper\">{{ helper }}</slot>\n </FieldHelperText>\n </div>\n </FormControlProvider>\n</template>\n"],"names":["_createBlock","_unref","FormControlProvider","_createElementVNode","_mergeProps","LabelText","_renderSlot","FieldErrorCallout","$slots","FieldHelperText"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAyDA,UAAM,QAAQ;AAWd,UAAM,WAAW,iBAAiB,MAAM,MAAM,UAAU;AACxD,yBAAqB,QAAQ;AAU7B,UAAM,QAAQ,SAAA;AACd,UAAM,QAAQ,SAAA;AAGd,UAAM,SAAS,eAAA;AAEf,UAAM,WAAW,SAAS,MAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC;AAC5E,UAAM,YAAY,SAAS,MAAM,QAAQ,MAAM,MAAM,KAAK,QAAQ,MAAM,MAAM,CAAC;AAC/E,UAAM,cAAc,SAAS,MAAM,QAAQ,MAAM,KAAK,KAAK,QAAQ,MAAM,KAAK,CAAC;AAI/E,UAAM,YAAY;AAAA,MAChB,MAAM,YAAY,UAAW,QAAQ,QAAQ,UAAU,KAAK,MAAM,QAAQ,aAAa;AAAA,IAAA;AAGzF,UAAM,WAAW,SAAS,MAAM,QAAQ,EAAE;AAC1C,UAAM,eAAe,SAAS,MAAM,QAAQ,MAAM;AAClD,UAAM,YAAY,SAAS,MAAM,YAAY,UAAU,QAAQ,aAAa,MAAM;AAClF,UAAM,aAAa,SAAS,MAAM,MAAM,cAAc,QAAQ,UAAU;AACxE,UAAM,aAAa,SAAS,MAAM,MAAM,cAAc,QAAQ,UAAU;AACxE,UAAM,aAAa,SAAS,MAAM,MAAM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sCAGG,UAAA,sBAA5BN,YAEkBS,aAAA;AAAA;cAFqB,OAAM;AAAA,YAAA;+BAC3C,MAAuC;AAAA,gBAAvCH,WAAuC,2BAAvC,MAAuC;AAAA,kDAAhB,QAAA,MAAM,GAAA,CAAA;AAAA,gBAAA;;;;;;;;;;;"}
@@ -73,7 +73,7 @@ import { default as default73 } from "./optionTileGroupField/OptionTileGroupFiel
73
73
  import { default as default74 } from "./optionTilePicker/OptionTilePicker.vue.js";
74
74
  import { default as default75 } from "./passwordInput/PasswordInput.vue.js";
75
75
  import { default as default76 } from "./percentInput/PercentInput.vue.js";
76
- import { PhoneCountries, default as default77 } from "./phoneInput/PhoneInput.vue.js";
76
+ import { default as default77 } from "./phoneInput/PhoneInput.vue.js";
77
77
  import { default as default78, PinInputType } from "./pinInput/PinInput.vue.js";
78
78
  import { default as default79 } from "./radioField/RadioField.vue.js";
79
79
  import { default as default80 } from "./radioGroup/RadioGroup.vue.js";
@@ -126,6 +126,7 @@ import { ImageEditRecipeExtensions } from "../../domain/imageEditing/ImageEditRe
126
126
  import { JsonEditorMode } from "./jsonEditor/JsonEditorContext.js";
127
127
  import { ListboxPickerIndicator } from "./listboxPicker/ListboxPickerContext.js";
128
128
  import { ListboxPickerItemState } from "./listboxPicker/ListboxPicker.variants.js";
129
+ import { PhoneCountries } from "../../foundation/phone/PhoneCountries.js";
129
130
  import { RadioGroupKey, useRadioGroup } from "./radioGroup/RadioGroupContext.js";
130
131
  import { SelectPickerSize, selectTriggerVariants } from "./selectPicker/SelectPicker.variants.js";
131
132
  import { ToggleGroupKey } from "./toggleGroup/ToggleGroupContext.js";
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;"}
@@ -2,7 +2,7 @@ import { defineComponent, useAttrs, useSlots, computed, useTemplateRef, openBloc
2
2
  import { cn } from "../../../foundation/styles/Cn.js";
3
3
  import { useId } from "../../../foundation/identifiers/UseId.js";
4
4
  import _sfc_main$1 from "../../display/labelText/LabelText.vue.js";
5
- const _hoisted_1 = { class: "flex items-center justify-between" };
5
+ const _hoisted_1 = { class: "mb-1.5 flex items-center justify-between" };
6
6
  const _hoisted_2 = {
7
7
  key: 0,
8
8
  class: "text-xs text-muted-foreground"
@@ -24,7 +24,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
24
24
  const passthroughAttrs = computed(
25
25
  () => Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key)))
26
26
  );
27
- const rootClass = computed(() => cn("flex flex-col gap-1.5", attrs.class));
27
+ const rootClass = computed(() => cn("flex flex-col", attrs.class));
28
28
  const root = useTemplateRef("root");
29
29
  __expose({ el: root });
30
30
  return (_ctx, _cache) => {
@@ -1 +1 @@
1
- {"version":3,"file":"LabeledField.vue.js","sources":["../../../../src/presentation/forms/labeledField/LabeledField.vue"],"sourcesContent":["<script lang=\"ts\">\n/** @deprecated Prefer `Field` (was `FormField`) or compose `LabelText` + a control directly. */\nexport interface LabeledFieldProps {\n /** The label text. Fill the `label` slot instead for richer content. */\n readonly label?: string | number;\n\n /** The optional inline-end label (e.g. \"Optional\"). Fill the `trailing` slot for richer content. */\n readonly trailing?: string | number;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs, useSlots, useTemplateRef } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { cn } from '../../../foundation/styles';\nimport { useId } from '../../../foundation/identifiers';\nimport LabelText from '../../display/labelText/LabelText.vue';\n\n/**\n * Renders a `LabelText` above its control with no helper, error or context wiring — for compact inline forms.\n *\n * @deprecated Prefer `Field` (was `FormField`) for label + control + helper/error,\n * or compose `LabelText` + a control directly. Kept for one release.\n */\n/* `inheritAttrs: false` so `class` folds into the component's own `cn()` call — plain fallthrough\n appends outside it and loses tailwind-merge conflict resolution. */\ndefineOptions({ name: 'LabeledField', inheritAttrs: false });\n\nconst props = defineProps<LabeledFieldProps>();\n\n/*\n * React reached into `children.props.id` and re-cloned the element with a generated id.\n * Vue has no vnode-prop read at that point, so the default slot is SCOPED instead: the\n * generated id is handed to the consumer, who binds it on their control.\n */\ndefineSlots<{\n default(props: { id: string }): unknown;\n label?(): unknown;\n trailing?(): unknown;\n}>();\n\nconst attrs = useAttrs();\nconst slots = useSlots();\n\nconst generatedId = useId();\n\nconst hasTrailing = computed(() => Boolean(props.trailing) || Boolean(slots.trailing));\n\nconst OwnedAttributes: ReadonlySet<string> = new Set(['class']);\nconst passthroughAttrs = computed(() =>\n Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key))),\n);\n\nconst rootClass = computed(() => cn('flex flex-col gap-1.5', attrs.class as ClassValue));\n\nconst root = useTemplateRef<HTMLDivElement>('root');\n\n/** The rendered element — the Vue stand-in for the React original's forwarded ref. */\ndefineExpose({ el: root });\n</script>\n\n<template>\n <div ref=\"root\" :class=\"rootClass\" v-bind=\"passthroughAttrs\">\n <div class=\"flex items-center justify-between\">\n <LabelText :for=\"generatedId\">\n <slot name=\"label\">{{ label }}</slot>\n </LabelText>\n <span v-if=\"hasTrailing\" class=\"text-xs text-muted-foreground\">\n <slot name=\"trailing\">{{ trailing }}</slot>\n </span>\n </div>\n <slot :id=\"generatedId\" />\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_createElementVNode","_createVNode","LabelText","_unref","_renderSlot"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,UAAM,QAAQ;AAad,UAAM,QAAQ,SAAA;AACd,UAAM,QAAQ,SAAA;AAEd,UAAM,cAAc,MAAA;AAEpB,UAAM,cAAc,SAAS,MAAM,QAAQ,MAAM,QAAQ,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAErF,UAAM,kBAAuC,oBAAI,IAAI,CAAC,OAAO,CAAC;AAC9D,UAAM,mBAAmB;AAAA,MAAS,MAChC,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,IAAI,GAAG,CAAC,CAAC;AAAA,IAAA;AAGvF,UAAM,YAAY,SAAS,MAAM,GAAG,yBAAyB,MAAM,KAAmB,CAAC;AAEvF,UAAM,OAAO,eAA+B,MAAM;AAGlD,aAAa,EAAE,IAAI,MAAM;;AAIvB,aAAAA,UAAA,GAAAC,mBAUM,OAVNC,WAUM;AAAA,iBAVG;AAAA,QAAJ,KAAI;AAAA,QAAQ,OAAO,UAAA;AAAA,MAAA,GAAmB,iBAAA,KAAgB,GAAA;AAAA,QACzDC,mBAOM,OAPN,YAOM;AAAA,UANJC,YAEYC,aAAA,EAFA,KAAKC,MAAA,WAAA,KAAW;AAAA,6BAC1B,MAAqC;AAAA,cAArCC,WAAqC,0BAArC,MAAqC;AAAA,gDAAf,QAAA,KAAK,GAAA,CAAA;AAAA,cAAA;;;;UAEjB,YAAA,SAAZP,UAAA,GAAAC,mBAEO,QAFP,YAEO;AAAA,YADLM,WAA2C,6BAA3C,MAA2C;AAAA,8CAAlB,QAAA,QAAQ,GAAA,CAAA;AAAA,YAAA;;;QAGrCA,WAA0B,KAAA,QAAA,WAAA,EAAnB,IAAID,MAAA,WAAA,EAAA,CAAW;AAAA,MAAA;;;;"}
1
+ {"version":3,"file":"LabeledField.vue.js","sources":["../../../../src/presentation/forms/labeledField/LabeledField.vue"],"sourcesContent":["<script lang=\"ts\">\n/** @deprecated Prefer `Field` (was `FormField`) or compose `LabelText` + a control directly. */\nexport interface LabeledFieldProps {\n /** The label text. Fill the `label` slot instead for richer content. */\n readonly label?: string | number;\n\n /** The optional inline-end label (e.g. \"Optional\"). Fill the `trailing` slot for richer content. */\n readonly trailing?: string | number;\n}\n</script>\n\n<script setup lang=\"ts\">\nimport { computed, useAttrs, useSlots, useTemplateRef } from 'vue';\nimport type { ClassValue } from 'clsx';\nimport { cn } from '../../../foundation/styles';\nimport { useId } from '../../../foundation/identifiers';\nimport LabelText from '../../display/labelText/LabelText.vue';\n\n/**\n * Renders a `LabelText` above its control with no helper, error or context wiring — for compact inline forms.\n *\n * @deprecated Prefer `Field` (was `FormField`) for label + control + helper/error,\n * or compose `LabelText` + a control directly. Kept for one release.\n */\n/* `inheritAttrs: false` so `class` folds into the component's own `cn()` call — plain fallthrough\n appends outside it and loses tailwind-merge conflict resolution. */\ndefineOptions({ name: 'LabeledField', inheritAttrs: false });\n\nconst props = defineProps<LabeledFieldProps>();\n\n/*\n * React reached into `children.props.id` and re-cloned the element with a generated id.\n * Vue has no vnode-prop read at that point, so the default slot is SCOPED instead: the\n * generated id is handed to the consumer, who binds it on their control.\n */\ndefineSlots<{\n default(props: { id: string }): unknown;\n label?(): unknown;\n trailing?(): unknown;\n}>();\n\nconst attrs = useAttrs();\nconst slots = useSlots();\n\nconst generatedId = useId();\n\nconst hasTrailing = computed(() => Boolean(props.trailing) || Boolean(slots.trailing));\n\nconst OwnedAttributes: ReadonlySet<string> = new Set(['class']);\nconst passthroughAttrs = computed(() =>\n Object.fromEntries(Object.entries(attrs).filter(([key]) => !OwnedAttributes.has(key))),\n);\n\n/* Margin, not a flex `gap`, as in `Field`: an element a password manager inserts beside the input opens no gap. */\nconst rootClass = computed(() => cn('flex flex-col', attrs.class as ClassValue));\n\nconst root = useTemplateRef<HTMLDivElement>('root');\n\n/** The rendered element — the Vue stand-in for the React original's forwarded ref. */\ndefineExpose({ el: root });\n</script>\n\n<template>\n <div ref=\"root\" :class=\"rootClass\" v-bind=\"passthroughAttrs\">\n <div class=\"mb-1.5 flex items-center justify-between\">\n <LabelText :for=\"generatedId\">\n <slot name=\"label\">{{ label }}</slot>\n </LabelText>\n <span v-if=\"hasTrailing\" class=\"text-xs text-muted-foreground\">\n <slot name=\"trailing\">{{ trailing }}</slot>\n </span>\n </div>\n <slot :id=\"generatedId\" />\n </div>\n</template>\n"],"names":["_openBlock","_createElementBlock","_mergeProps","_createElementVNode","_createVNode","LabelText","_unref","_renderSlot"],"mappings":";;;;;;;;;;;;;;;;;AA4BA,UAAM,QAAQ;AAad,UAAM,QAAQ,SAAA;AACd,UAAM,QAAQ,SAAA;AAEd,UAAM,cAAc,MAAA;AAEpB,UAAM,cAAc,SAAS,MAAM,QAAQ,MAAM,QAAQ,KAAK,QAAQ,MAAM,QAAQ,CAAC;AAErF,UAAM,kBAAuC,oBAAI,IAAI,CAAC,OAAO,CAAC;AAC9D,UAAM,mBAAmB;AAAA,MAAS,MAChC,OAAO,YAAY,OAAO,QAAQ,KAAK,EAAE,OAAO,CAAC,CAAC,GAAG,MAAM,CAAC,gBAAgB,IAAI,GAAG,CAAC,CAAC;AAAA,IAAA;AAIvF,UAAM,YAAY,SAAS,MAAM,GAAG,iBAAiB,MAAM,KAAmB,CAAC;AAE/E,UAAM,OAAO,eAA+B,MAAM;AAGlD,aAAa,EAAE,IAAI,MAAM;;AAIvB,aAAAA,UAAA,GAAAC,mBAUM,OAVNC,WAUM;AAAA,iBAVG;AAAA,QAAJ,KAAI;AAAA,QAAQ,OAAO,UAAA;AAAA,MAAA,GAAmB,iBAAA,KAAgB,GAAA;AAAA,QACzDC,mBAOM,OAPN,YAOM;AAAA,UANJC,YAEYC,aAAA,EAFA,KAAKC,MAAA,WAAA,KAAW;AAAA,6BAC1B,MAAqC;AAAA,cAArCC,WAAqC,0BAArC,MAAqC;AAAA,gDAAf,QAAA,KAAK,GAAA,CAAA;AAAA,cAAA;;;;UAEjB,YAAA,SAAZP,UAAA,GAAAC,mBAEO,QAFP,YAEO;AAAA,YADLM,WAA2C,6BAA3C,MAA2C;AAAA,8CAAlB,QAAA,QAAQ,GAAA,CAAA;AAAA,YAAA;;;QAGrCA,WAA0B,KAAA,QAAA,WAAA,EAAnB,IAAID,MAAA,WAAA,EAAA,CAAW;AAAA,MAAA;;;;"}
@@ -1,12 +1,4 @@
1
1
  import { NativeInputAttributes } from '../NativeControlAttributes';
2
- /** Represents one selectable dialling country. */
3
- export interface PhoneCountry {
4
- iso: string;
5
- name: string;
6
- dial: string;
7
- flag: string;
8
- }
9
- export declare const PhoneCountries: ReadonlyArray<PhoneCountry>;
10
2
  export interface PhoneInputProps extends /* @vue-ignore */ NativeInputAttributes {
11
3
  /** The E.164 value, controlled. The `v-model` binding target. */
12
4
  readonly modelValue?: string;
@@ -22,7 +14,7 @@ export interface PhoneInputProps extends /* @vue-ignore */ NativeInputAttributes
22
14
  readonly isReadOnly?: boolean;
23
15
  /** The invalid surface override. Falls back to the surrounding form control's `isInvalid`. */
24
16
  readonly isInvalid?: boolean;
25
- /** The national-number placeholder. */
17
+ /** The national-number placeholder. Default the country's mask with zeros (`00-000-00-00`), none without a mask. */
26
18
  readonly placeholder?: string;
27
19
  /** The hidden input name; the hidden input emits the full E.164 value. */
28
20
  readonly name?: string;
@@ -1,9 +1,11 @@
1
1
  import { defineComponent, useAttrs, computed, ref, useTemplateRef, openBlock, createElementBlock, mergeProps, unref, normalizeClass, toDisplayString, Fragment, renderList, createElementVNode, createCommentVNode } from "vue";
2
2
  import { useLocale } from "../../../foundation/i18n/providers/LocaleContext.js";
3
- import { useNativeFormReset } from "../UseNativeFormReset.js";
4
- import { cn } from "../../../foundation/styles/Cn.js";
3
+ import { PhoneFormats } from "../../../foundation/phone/PhoneFormats.js";
4
+ import { PhoneNumberExtensions } from "../../../foundation/phone/PhoneNumberExtensions.js";
5
5
  import { useControlled } from "../../../foundation/state/hooks/UseControlled.js";
6
+ import { cn } from "../../../foundation/styles/Cn.js";
6
7
  import { inputBaseVariants, InputSize } from "../InputStyles.js";
8
+ import { useNativeFormReset } from "../UseNativeFormReset.js";
7
9
  import { useFormControl } from "../../../foundation/primitives/formControlContext/FormControlContext.js";
8
10
  const _hoisted_1 = ["data-readonly"];
9
11
  const _hoisted_2 = ["aria-label", "value", "disabled"];
@@ -11,79 +13,6 @@ const _hoisted_3 = ["value"];
11
13
  const _hoisted_4 = ["id", "value", "placeholder", "disabled", "readonly", "aria-invalid", "aria-describedby", "aria-required"];
12
14
  const _hoisted_5 = ["disabled", "form", "name", "value"];
13
15
  const _hoisted_6 = ["form"];
14
- const PhoneCountries = [
15
- { iso: "US", name: "United States", dial: "+1", flag: "🇺🇸" },
16
- { iso: "CA", name: "Canada", dial: "+1", flag: "🇨🇦" },
17
- { iso: "GB", name: "United Kingdom", dial: "+44", flag: "🇬🇧" },
18
- { iso: "AU", name: "Australia", dial: "+61", flag: "🇦🇺" },
19
- { iso: "DE", name: "Germany", dial: "+49", flag: "🇩🇪" },
20
- { iso: "FR", name: "France", dial: "+33", flag: "🇫🇷" },
21
- { iso: "ES", name: "Spain", dial: "+34", flag: "🇪🇸" },
22
- { iso: "IT", name: "Italy", dial: "+39", flag: "🇮🇹" },
23
- { iso: "NL", name: "Netherlands", dial: "+31", flag: "🇳🇱" },
24
- { iso: "BE", name: "Belgium", dial: "+32", flag: "🇧🇪" },
25
- { iso: "CH", name: "Switzerland", dial: "+41", flag: "🇨🇭" },
26
- { iso: "AT", name: "Austria", dial: "+43", flag: "🇦🇹" },
27
- { iso: "SE", name: "Sweden", dial: "+46", flag: "🇸🇪" },
28
- { iso: "NO", name: "Norway", dial: "+47", flag: "🇳🇴" },
29
- { iso: "DK", name: "Denmark", dial: "+45", flag: "🇩🇰" },
30
- { iso: "FI", name: "Finland", dial: "+358", flag: "🇫🇮" },
31
- { iso: "IE", name: "Ireland", dial: "+353", flag: "🇮🇪" },
32
- { iso: "PT", name: "Portugal", dial: "+351", flag: "🇵🇹" },
33
- { iso: "PL", name: "Poland", dial: "+48", flag: "🇵🇱" },
34
- { iso: "CZ", name: "Czechia", dial: "+420", flag: "🇨🇿" },
35
- { iso: "GR", name: "Greece", dial: "+30", flag: "🇬🇷" },
36
- { iso: "TR", name: "Türkiye", dial: "+90", flag: "🇹🇷" },
37
- { iso: "RU", name: "Russia", dial: "+7", flag: "🇷🇺" },
38
- { iso: "UA", name: "Ukraine", dial: "+380", flag: "🇺🇦" },
39
- { iso: "UZ", name: "Uzbekistan", dial: "+998", flag: "🇺🇿" },
40
- { iso: "KZ", name: "Kazakhstan", dial: "+7", flag: "🇰🇿" },
41
- { iso: "KG", name: "Kyrgyzstan", dial: "+996", flag: "🇰🇬" },
42
- { iso: "TJ", name: "Tajikistan", dial: "+992", flag: "🇹🇯" },
43
- { iso: "TM", name: "Turkmenistan", dial: "+993", flag: "🇹🇲" },
44
- { iso: "IL", name: "Israel", dial: "+972", flag: "🇮🇱" },
45
- { iso: "AE", name: "UAE", dial: "+971", flag: "🇦🇪" },
46
- { iso: "SA", name: "Saudi Arabia", dial: "+966", flag: "🇸🇦" },
47
- { iso: "EG", name: "Egypt", dial: "+20", flag: "🇪🇬" },
48
- { iso: "ZA", name: "South Africa", dial: "+27", flag: "🇿🇦" },
49
- { iso: "NG", name: "Nigeria", dial: "+234", flag: "🇳🇬" },
50
- { iso: "KE", name: "Kenya", dial: "+254", flag: "🇰🇪" },
51
- { iso: "IN", name: "India", dial: "+91", flag: "🇮🇳" },
52
- { iso: "PK", name: "Pakistan", dial: "+92", flag: "🇵🇰" },
53
- { iso: "BD", name: "Bangladesh", dial: "+880", flag: "🇧🇩" },
54
- { iso: "SG", name: "Singapore", dial: "+65", flag: "🇸🇬" },
55
- { iso: "MY", name: "Malaysia", dial: "+60", flag: "🇲🇾" },
56
- { iso: "TH", name: "Thailand", dial: "+66", flag: "🇹🇭" },
57
- { iso: "VN", name: "Vietnam", dial: "+84", flag: "🇻🇳" },
58
- { iso: "PH", name: "Philippines", dial: "+63", flag: "🇵🇭" },
59
- { iso: "ID", name: "Indonesia", dial: "+62", flag: "🇮🇩" },
60
- { iso: "JP", name: "Japan", dial: "+81", flag: "🇯🇵" },
61
- { iso: "KR", name: "South Korea", dial: "+82", flag: "🇰🇷" },
62
- { iso: "CN", name: "China", dial: "+86", flag: "🇨🇳" },
63
- { iso: "HK", name: "Hong Kong", dial: "+852", flag: "🇭🇰" },
64
- { iso: "TW", name: "Taiwan", dial: "+886", flag: "🇹🇼" },
65
- { iso: "NZ", name: "New Zealand", dial: "+64", flag: "🇳🇿" },
66
- { iso: "BR", name: "Brazil", dial: "+55", flag: "🇧🇷" },
67
- { iso: "AR", name: "Argentina", dial: "+54", flag: "🇦🇷" },
68
- { iso: "CL", name: "Chile", dial: "+56", flag: "🇨🇱" },
69
- { iso: "CO", name: "Colombia", dial: "+57", flag: "🇨🇴" },
70
- { iso: "MX", name: "Mexico", dial: "+52", flag: "🇲🇽" }
71
- ];
72
- function resolveCountries(isos) {
73
- if (!isos) return PhoneCountries;
74
- const known = [...new Set(isos)].map((iso) => PhoneCountries.find((c) => c.iso === iso)).filter((c) => c !== void 0);
75
- return known.length > 0 ? known : PhoneCountries;
76
- }
77
- function splitE164(value, countries, defaultIso) {
78
- if (!value) return { iso: defaultIso, national: "" };
79
- const sorted = [...countries].sort((a, b) => b.dial.length - a.dial.length);
80
- for (const c of sorted) {
81
- if (value.startsWith(c.dial)) {
82
- return { iso: c.iso, national: value.slice(c.dial.length).replace(/\D/g, "") };
83
- }
84
- }
85
- return { iso: defaultIso, national: value.replace(/\D/g, "") };
86
- }
87
16
  const _sfc_main = /* @__PURE__ */ defineComponent({
88
17
  ...{ name: "PhoneInput", inheritAttrs: false },
89
18
  __name: "PhoneInput",
@@ -95,7 +24,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
95
24
  isDisabled: { type: Boolean, default: void 0 },
96
25
  isReadOnly: { type: Boolean, default: void 0 },
97
26
  isInvalid: { type: Boolean, default: void 0 },
98
- placeholder: { default: "(555) 555-5555" },
27
+ placeholder: { default: void 0 },
99
28
  name: {}
100
29
  },
101
30
  emits: ["update:modelValue"],
@@ -115,7 +44,7 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
115
44
  const disabled = computed(() => props.isDisabled ?? ctx?.isDisabled);
116
45
  const readOnly = computed(() => props.isReadOnly ?? ctx?.isReadOnly);
117
46
  const invalid = computed(() => props.isInvalid ?? ctx?.isInvalid);
118
- const allowed = computed(() => resolveCountries(props.countries));
47
+ const allowed = computed(() => PhoneNumberExtensions.resolveCountries(props.countries));
119
48
  const fallbackIso = computed(
120
49
  () => allowed.value.find((c) => c.iso === props.defaultCountry)?.iso ?? allowed.value[0].iso
121
50
  );
@@ -125,14 +54,24 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
125
54
  if (selected && (!e164.value || e164.value.startsWith(selected.dial))) {
126
55
  return {
127
56
  iso: selected.iso,
128
- national: e164.value.slice(selected.dial.length).replace(/\D/g, "")
57
+ national: PhoneNumberExtensions.digitsOf(e164.value.slice(selected.dial.length))
129
58
  };
130
59
  }
131
- return splitE164(e164.value, allowed.value, fallbackIso.value);
60
+ return PhoneNumberExtensions.split(e164.value, allowed.value, fallbackIso.value);
132
61
  });
133
62
  const iso = computed(() => split.value.iso);
134
63
  const national = computed(() => split.value.national);
135
64
  const country = computed(() => allowed.value.find((c) => c.iso === iso.value) ?? allowed.value[0]);
65
+ const format = computed(() => PhoneNumberExtensions.formatOf(country.value));
66
+ const isForeign = computed(() => e164.value !== "" && !e164.value.startsWith(country.value.dial));
67
+ const displayed = computed(
68
+ () => isForeign.value ? national.value : PhoneNumberExtensions.formatNational(national.value, format.value)
69
+ );
70
+ const placeholderText = computed(() => {
71
+ if (props.placeholder !== void 0) return props.placeholder;
72
+ const mask = PhoneFormats[country.value.iso]?.mask;
73
+ return mask ? mask.replace(/X/g, "0") : void 0;
74
+ });
136
75
  function e164For(dial, digits) {
137
76
  return digits ? `${dial}${digits}` : "";
138
77
  }
@@ -143,10 +82,70 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
143
82
  const nextValue = e164For(next.dial, national.value);
144
83
  if (nextValue !== e164.value) controlled.setValue(nextValue);
145
84
  }
146
- function setNational(event) {
147
- const digits = event.target.value.replace(/\D/g, "");
85
+ function setDigits(digits) {
148
86
  selectedIso.value = country.value.iso;
149
- controlled.setValue(e164For(country.value.dial, digits));
87
+ const nextValue = e164For(country.value.dial, digits);
88
+ if (nextValue !== e164.value) controlled.setValue(nextValue);
89
+ }
90
+ function setInternational(text) {
91
+ const parsed = PhoneNumberExtensions.parseInternational(text, allowed.value, country.value.iso);
92
+ if (parsed.country) {
93
+ const max = PhoneNumberExtensions.lengthOf(parsed.country).max;
94
+ const digits = parsed.e164.slice(parsed.country.dial.length, parsed.country.dial.length + max);
95
+ selectedIso.value = parsed.country.iso;
96
+ const nextValue2 = e164For(parsed.country.dial, digits);
97
+ if (nextValue2 !== e164.value) controlled.setValue(nextValue2);
98
+ return PhoneNumberExtensions.formatNational(digits, PhoneNumberExtensions.formatOf(parsed.country));
99
+ }
100
+ const nextValue = parsed.e164.length > 1 ? parsed.e164 : "";
101
+ if (nextValue !== e164.value) controlled.setValue(nextValue);
102
+ return nextValue.slice(1);
103
+ }
104
+ const ReplacementInputTypes = /* @__PURE__ */ new Set([
105
+ void 0,
106
+ "insertReplacementText",
107
+ "insertFromDrop",
108
+ "insertFromPaste"
109
+ ]);
110
+ function setNational(event) {
111
+ const field = event.target;
112
+ const inputEvent = event;
113
+ if (inputEvent.isComposing) return;
114
+ if (ReplacementInputTypes.has(inputEvent.inputType) && field.value.trimStart().startsWith("+")) {
115
+ field.value = setInternational(field.value);
116
+ placeCaret(field, field.value.length);
117
+ return;
118
+ }
119
+ const edit = PhoneNumberExtensions.editNational({
120
+ text: field.value,
121
+ caret: field.selectionStart ?? field.value.length,
122
+ previousDigits: national.value,
123
+ inputType: inputEvent.inputType,
124
+ format: format.value
125
+ });
126
+ field.value = edit.text;
127
+ placeCaret(field, edit.caret);
128
+ setDigits(edit.digits);
129
+ }
130
+ function pasteNational(event) {
131
+ const text = event.clipboardData?.getData("text") ?? "";
132
+ const field = event.target;
133
+ if (text.trimStart().startsWith("+")) {
134
+ event.preventDefault();
135
+ field.value = setInternational(text);
136
+ placeCaret(field, field.value.length);
137
+ return;
138
+ }
139
+ const digits = PhoneNumberExtensions.digitsOf(text);
140
+ const stripped = PhoneNumberExtensions.withoutDialCode(digits, country.value);
141
+ if (stripped === digits) return;
142
+ event.preventDefault();
143
+ setDigits(stripped);
144
+ field.value = PhoneNumberExtensions.formatNational(stripped, format.value);
145
+ placeCaret(field, field.value.length);
146
+ }
147
+ function placeCaret(field, caret) {
148
+ if (field.ownerDocument.activeElement === field) field.setSelectionRange(caret, caret);
150
149
  }
151
150
  const OwnedAttributes = /* @__PURE__ */ new Set(["class"]);
152
151
  const passthroughAttrs = computed(
@@ -212,15 +211,16 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
212
211
  inputmode: "tel",
213
212
  autocomplete: "tel-national",
214
213
  id: unref(ctx)?.id,
215
- value: national.value,
216
- placeholder: __props.placeholder,
214
+ value: displayed.value,
215
+ placeholder: placeholderText.value,
217
216
  disabled: disabled.value,
218
217
  readonly: readOnly.value,
219
218
  "aria-invalid": invalid.value || void 0,
220
219
  "aria-describedby": unref(ctx)?.describedBy,
221
220
  "aria-required": unref(ctx)?.isRequired || void 0,
222
221
  class: normalizeClass(unref(inputClass)),
223
- onInput: setNational
222
+ onInput: setNational,
223
+ onPaste: pasteNational
224
224
  }, null, 42, _hoisted_4),
225
225
  __props.name ? (openBlock(), createElementBlock("input", {
226
226
  key: 2,
@@ -242,7 +242,6 @@ const _sfc_main = /* @__PURE__ */ defineComponent({
242
242
  }
243
243
  });
244
244
  export {
245
- PhoneCountries,
246
245
  _sfc_main as default
247
246
  };
248
247
  //# sourceMappingURL=PhoneInput.vue.js.map