@vtex/country-forms 0.0.1 → 1.1.0

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 (105) hide show
  1. package/CHANGELOG.md +120 -0
  2. package/README.md +29 -1
  3. package/dist/BRA-JUHEOV7J.mjs +96 -0
  4. package/dist/BRA-JUHEOV7J.mjs.map +1 -0
  5. package/dist/BRA-PMVV6KOM.js +119 -0
  6. package/dist/BRA-PMVV6KOM.js.map +1 -0
  7. package/dist/BRA-VIVRV7X7.js +98 -0
  8. package/dist/BRA-VIVRV7X7.js.map +1 -0
  9. package/dist/BRA-ZBZXE5II.mjs +117 -0
  10. package/dist/BRA-ZBZXE5II.mjs.map +1 -0
  11. package/dist/CAN-HUMAGSIC.mjs +67 -0
  12. package/dist/CAN-HUMAGSIC.mjs.map +1 -0
  13. package/dist/CAN-NGS6AUBG.js +69 -0
  14. package/dist/CAN-NGS6AUBG.js.map +1 -0
  15. package/dist/MEX-3PMZHDQP.js +89 -0
  16. package/dist/MEX-3PMZHDQP.js.map +1 -0
  17. package/dist/MEX-QFS4JTN6.mjs +87 -0
  18. package/dist/MEX-QFS4JTN6.mjs.map +1 -0
  19. package/dist/USA-E5AZRBXA.mjs +67 -0
  20. package/dist/USA-E5AZRBXA.mjs.map +1 -0
  21. package/dist/USA-UBWW5NQB.js +69 -0
  22. package/dist/USA-UBWW5NQB.js.map +1 -0
  23. package/dist/bra-I5DOHE34.mjs +57 -0
  24. package/dist/bra-I5DOHE34.mjs.map +1 -0
  25. package/dist/bra-ILOTR4AN.mjs +90 -0
  26. package/dist/bra-ILOTR4AN.mjs.map +1 -0
  27. package/dist/bra-KEBYAD75.js +66 -0
  28. package/dist/bra-KEBYAD75.js.map +1 -0
  29. package/dist/bra-MHTXSNLA.js +96 -0
  30. package/dist/bra-MHTXSNLA.js.map +1 -0
  31. package/dist/bra-states-Q4H2TVQZ.mjs +4 -0
  32. package/dist/bra-states-Q4H2TVQZ.mjs.map +1 -0
  33. package/dist/bra-states-SQMU4WTB.js +17 -0
  34. package/dist/bra-states-SQMU4WTB.js.map +1 -0
  35. package/dist/can-7TMYDEJF.mjs +17 -0
  36. package/dist/can-7TMYDEJF.mjs.map +1 -0
  37. package/dist/can-B5ME2ZFN.js +20 -0
  38. package/dist/can-B5ME2ZFN.js.map +1 -0
  39. package/dist/can-FGNN5MZS.mjs +19 -0
  40. package/dist/can-FGNN5MZS.mjs.map +1 -0
  41. package/dist/can-LLJ4A5Y5.js +21 -0
  42. package/dist/can-LLJ4A5Y5.js.map +1 -0
  43. package/dist/can-provinces-5S5FSO6H.mjs +23 -0
  44. package/dist/can-provinces-5S5FSO6H.mjs.map +1 -0
  45. package/dist/can-provinces-6NOHMW37.js +25 -0
  46. package/dist/can-provinces-6NOHMW37.js.map +1 -0
  47. package/dist/chunk-26GYXS7J.mjs +5622 -0
  48. package/dist/chunk-26GYXS7J.mjs.map +1 -0
  49. package/dist/chunk-2JC3GVFR.mjs +21 -0
  50. package/dist/chunk-2JC3GVFR.mjs.map +1 -0
  51. package/dist/chunk-BMZHOWIP.mjs +21 -0
  52. package/dist/chunk-BMZHOWIP.mjs.map +1 -0
  53. package/dist/chunk-BQPGLWMB.js +25 -0
  54. package/dist/chunk-BQPGLWMB.js.map +1 -0
  55. package/dist/chunk-CFX5EF4R.js +21 -0
  56. package/dist/chunk-CFX5EF4R.js.map +1 -0
  57. package/dist/chunk-KWESVZKV.mjs +18 -0
  58. package/dist/chunk-KWESVZKV.mjs.map +1 -0
  59. package/dist/chunk-LU6ZDUJ5.js +5625 -0
  60. package/dist/chunk-LU6ZDUJ5.js.map +1 -0
  61. package/dist/chunk-YB6VNXLI.js +25 -0
  62. package/dist/chunk-YB6VNXLI.js.map +1 -0
  63. package/dist/en-US-RLEM27ZZ.js +51 -0
  64. package/dist/en-US-RLEM27ZZ.js.map +1 -0
  65. package/dist/en-US-YW7UYXNB.mjs +49 -0
  66. package/dist/en-US-YW7UYXNB.mjs.map +1 -0
  67. package/dist/es-MX-AGRGVXRK.mjs +49 -0
  68. package/dist/es-MX-AGRGVXRK.mjs.map +1 -0
  69. package/dist/es-MX-K5MWKMJW.js +51 -0
  70. package/dist/es-MX-K5MWKMJW.js.map +1 -0
  71. package/dist/fr-FR-KWQ3MPP5.mjs +49 -0
  72. package/dist/fr-FR-KWQ3MPP5.mjs.map +1 -0
  73. package/dist/fr-FR-LJIPE6BH.js +51 -0
  74. package/dist/fr-FR-LJIPE6BH.js.map +1 -0
  75. package/dist/index.d.mts +50 -5
  76. package/dist/index.d.ts +50 -5
  77. package/dist/index.js +73 -6890
  78. package/dist/index.js.map +1 -1
  79. package/dist/index.mjs +66 -6883
  80. package/dist/index.mjs.map +1 -1
  81. package/dist/mex-5BKCF6LS.js +21 -0
  82. package/dist/mex-5BKCF6LS.js.map +1 -0
  83. package/dist/mex-G3HMNBBF.mjs +19 -0
  84. package/dist/mex-G3HMNBBF.mjs.map +1 -0
  85. package/dist/mex-states-GTCRN4NS.js +44 -0
  86. package/dist/mex-states-GTCRN4NS.js.map +1 -0
  87. package/dist/mex-states-KPEGWYKG.mjs +42 -0
  88. package/dist/mex-states-KPEGWYKG.mjs.map +1 -0
  89. package/dist/pt-BR-74IZNREP.js +51 -0
  90. package/dist/pt-BR-74IZNREP.js.map +1 -0
  91. package/dist/pt-BR-P2RZ3X3H.mjs +49 -0
  92. package/dist/pt-BR-P2RZ3X3H.mjs.map +1 -0
  93. package/dist/usa-3AM7UFVG.js +20 -0
  94. package/dist/usa-3AM7UFVG.js.map +1 -0
  95. package/dist/usa-I7DK2CTL.mjs +18 -0
  96. package/dist/usa-I7DK2CTL.mjs.map +1 -0
  97. package/dist/usa-LXT6WW64.js +21 -0
  98. package/dist/usa-LXT6WW64.js.map +1 -0
  99. package/dist/usa-ZD5OWGAD.mjs +18 -0
  100. package/dist/usa-ZD5OWGAD.mjs.map +1 -0
  101. package/dist/usa-states-EBFT4LUQ.js +63 -0
  102. package/dist/usa-states-EBFT4LUQ.js.map +1 -0
  103. package/dist/usa-states-FF5OQBEL.mjs +61 -0
  104. package/dist/usa-states-FF5OQBEL.mjs.map +1 -0
  105. package/package.json +3 -1
package/CHANGELOG.md ADDED
@@ -0,0 +1,120 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6
+ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7
+
8
+ ## [Unreleased]
9
+
10
+ ## [1.1.0] - 2026-05-21
11
+
12
+ ### Added
13
+
14
+ - `I18nParams` public type and a new optional **4th argument** on `resolveLabel(key, bundle, overrides?, params?)`. Every `{name}` placeholder in the resolved string is replaced by `String(params[name])` after the override → bundle → raw-key cascade. Missing entries leave the placeholder untouched so unfulfilled substitutions remain visible in development.
15
+
16
+ ### Changed
17
+
18
+ - Validation messages are now interpolation-ready. `country-forms.validation.required`, `country-forms.validation.invalid`, and `country-forms.validation.maxLength` ship with `{fieldName}` / `{maxLength}` placeholders in every bundle (`en-US`, `pt-BR`, `es-MX`, `fr-FR`). Consumers should pass the field name (and `maxLength` value when applicable) via the new `params` argument of `resolveLabel`.
19
+ - `country-forms.address.complement.label` now reads as "Complement (optional)" / "Complemento (opcional)" / "Complemento (opcional)" / "Complément (facultatif)" across the four bundles.
20
+
21
+ ### Removed
22
+
23
+ - Per-rule validation keys `country-forms.validation.{number.BRA,email,phone,cpf,cnpj}` were collapsed into the shared `country-forms.validation.invalid` key. The corresponding validators (`validateEmail`, `validatePhoneBRA`, `validateCPF`, `validateCNPJ`) and `address-BRA`'s `number` pattern now return that single key, which renders a localized "{fieldName} inválido…" message once interpolated.
24
+
25
+ ## [1.0.1] - 2026-05-07
26
+
27
+ ### Removed
28
+
29
+ - `--provenance` tag on npm publish flow
30
+
31
+ ## [1.0.0] - 2026-05-07
32
+
33
+ ### Added
34
+
35
+ - `coverageThreshold` enforced by Jest at ≥ 80% statements/branches/functions/lines, applied globally and per-directory for `src/engine/`, `src/rules/`, and `src/i18n/`.
36
+ - `__tests__/integration/quickstart.test.ts` — exercises the user-facing flow documented in `docs/quickstart.md` end-to-end. Breaks if the public API drifts away from the published quickstart.
37
+ - `__tests__/integration/tree-shake.test.ts` — verifies the published `dist/` keeps per-country/per-locale code-splitting. Asserts the entry bundle is < 50 KB and contains no inlined Brazilian cities, US states, locale messages, etc.
38
+ - `yarn verify` script — runs `typecheck + lint + build + test:coverage` in one command for pre-PR quality gating.
39
+
40
+ ### Changed
41
+
42
+ - `tsup` now builds with `splitting: true`. The previous `splitting: false` configuration silently inlined every country's schema, validators, and option lists into a single 419 KB bundle, defeating the per-country code-splitting contract. The entry now ships at ~9 KB and bundlers receive separate chunks per country and locale.
43
+ - `jest.config.js` excludes barrel files (`src/index.ts`, `src/**/index.ts`) from coverage so the threshold reflects executable code only.
44
+
45
+ ## [0.0.1] - 2026-04-28
46
+
47
+ ### Added
48
+
49
+ **Engine**
50
+ - `loadSchema(countryCode, formType)` — loads country-specific schemas via dynamic `import()` with generic fallback for unknown countries
51
+ - `createFormState(schema, defaults?)` — creates immutable form state from a schema
52
+ - `setValue(state, schema, fieldName, value)` — updates field value with automatic reset of dependent fields (conditional options)
53
+ - `validate(state, schema)` — synchronous validation that skips hidden fields
54
+ - `getVisibleFields(schema, values)` — evaluates `conditionalVisibility` rules
55
+ - `formatValue(ref, value)` / `unformatValue(ref, value)` — applies or strips display masks via registry references
56
+ - `resolveFieldOptions(field, values)` — resolves static or conditional options for select fields
57
+
58
+ **Address Schemas**
59
+ - Brazil (`BRA`) — street, number, complement, neighborhood, state (select), city (dependent select by state), postalCode (CEP mask + validator)
60
+ - United States (`USA`) — street, complement, city, state (select, 50 states + DC), postalCode (ZIP/ZIP+4 mask + validator)
61
+ - Canada (`CAN`) — street, complement, city, state (select, 13 provinces/territories), postalCode (postal code mask + validator)
62
+ - Mexico (`MEX`) — street, number, neighborhood, city, state (select, 32 states), postalCode (5-digit validator, no mask)
63
+
64
+ **Personal Data Schemas**
65
+ - Brazil (`BRA`) — personType (radio-group: individual/business), firstName (conditional label), lastName (conditional visibility), email (validator), phone (validator + mask), CPF (conditional visibility + validator + mask), CNPJ (conditional visibility + validator + mask)
66
+
67
+ **Validators**
68
+ - `validateCEP` — Brazilian postal code (8 digits, 00000-000 format)
69
+ - `validateCPF` — Brazilian individual taxpayer ID with check-digit algorithm
70
+ - `validateCNPJ` — Brazilian company taxpayer ID with check-digit algorithm
71
+ - `validateEmail` — Email address format validation
72
+ - `validatePhoneBRA` — Brazilian landline and mobile phone numbers
73
+ - `validateZIP` — US postal code (5-digit and ZIP+4)
74
+ - `validatePostalCodeCAN` — Canadian postal code (A1A 1A1 format with FSA restrictions)
75
+ - `validatePostalCodeMEX` — Mexican postal code (5-digit, 01000–99999 range)
76
+
77
+ **Masks (format/unformat)**
78
+ - `formatCEP` / `unformatCEP` — CEP postal code (99999-999)
79
+ - `formatCPF` / `unformatCPF` — CPF (999.999.999-99)
80
+ - `formatCNPJ` / `unformatCNPJ` — CNPJ (99.999.999/9999-99)
81
+ - `formatPhoneBRA` / `unformatPhoneBRA` — Brazilian phone ((99) 99999-9999)
82
+ - `formatZIP` / `unformatZIP` — US ZIP code (99999-9999)
83
+ - `formatPostalCodeCAN` / `unformatPostalCodeCAN` — Canadian postal code (A1A 1A1)
84
+
85
+ **Options**
86
+ - `BRA.states` — 27 Brazilian states (UF codes)
87
+ - `BRA.cities.<UF>` — Cities per state for dependent select
88
+ - `USA.states` — 50 US states + DC
89
+ - `CAN.provinces` — 13 Canadian provinces and territories
90
+ - `MEX.states` — 32 Mexican states
91
+
92
+ **i18n**
93
+ - `loadLocale(locale)` — on-demand locale loading with BCP 47 matching and `en-US` fallback
94
+ - `resolveLabel(key, bundle, overrides?)` — three-tier label resolution (override → bundle → raw key)
95
+ - Built-in bundles: `en-US`, `pt-BR`, `es-MX`, `fr-FR`
96
+ - `SUPPORTED_LOCALES` constant and `SupportedLocale` type
97
+
98
+ **Schema Features**
99
+ - `conditionalVisibility` — show/hide fields based on another field's value
100
+ - `conditionalLabel` / `conditionalPlaceholder` — context-dependent i18n keys
101
+ - `conditionalOptions` — dependent options resolved by controller field (e.g. city by state)
102
+ - `dependsOn` — declares field dependencies for conditional behavior
103
+
104
+ **Documentation**
105
+ - README with quick start, API reference, and consumer responsibilities
106
+ - Playbook for adding new countries (`docs/playbook-new-country.md`)
107
+ - CONTRIBUTING guide with setup, workflow, and code patterns
108
+ - Public API contract (`docs/public-api.md`)
109
+ - Quickstart integration guide (`docs/quickstart.md`)
110
+ - Data model (`docs/data-model.md`)
111
+ - RFC with full architecture rationale (`specs/001-dynamic-form-engine/rfc.md`)
112
+
113
+ **Examples**
114
+ - `examples/react-minimal/` — React example with country/locale selection, form rendering, validation, and i18n overrides
115
+
116
+
117
+ [Unreleased]: https://github.com/vtex/country-forms/compare/v1.1.0...HEAD
118
+ [1.1.0]: https://github.com/vtex/country-forms/compare/v1.0.1...v1.1.0
119
+ [1.0.1]: https://github.com/vtex/country-forms/compare/v1.0.0...v1.0.1
120
+ [1.0.0]: https://github.com/vtex/country-forms/compare/v0.0.1...v1.0.0
package/README.md CHANGED
@@ -82,7 +82,7 @@ Both `loadSchema` and `loadLocale` use dynamic `import()` internally — only th
82
82
  | `getVisibleFields` | `(schema, values) → FieldDefinition[]` | Returns fields visible for the current values (evaluates `conditionalVisibility`). |
83
83
  | `formatValue` | `(ref, value) → string` | Applies display mask (e.g. `"01001000"` → `"01001-000"`). Identity if `ref` is undefined. |
84
84
  | `unformatValue` | `(ref, value) → string` | Strips mask for submission (e.g. `"01001-000"` → `"01001000"`). Identity if `ref` is undefined. |
85
- | `resolveLabel` | `(key, bundle, overrides?) → string` | Resolves i18n label. Fallback: override → bundle → raw key. |
85
+ | `resolveLabel` | `(key, bundle, overrides?, params?) → string` | Resolves i18n label. Fallback: override → bundle → raw key. `params` interpolates `{name}` placeholders (e.g. `{ fieldName, maxLength }`). |
86
86
  | `resolveFieldOptions` | `(field, values) → SelectOption[] \| null` | Resolves static or conditional options for a field. |
87
87
 
88
88
  ### Constants
@@ -112,6 +112,7 @@ import type {
112
112
  FormState,
113
113
  I18nBundle,
114
114
  I18nOverrides,
115
+ I18nParams,
115
116
  SupportedLocale,
116
117
  ValidatorFn,
117
118
  FormatFn,
@@ -274,3 +275,30 @@ The library is designed for tree-shaking and code-splitting:
274
275
  - `loadSchema('BRA', 'address')` only loads the BRA address schema and its rules
275
276
  - `loadLocale('pt-BR')` only loads the Portuguese bundle
276
277
  - Unused schemas, rules, and locales are excluded by modern bundlers (Webpack, Vite, etc.)
278
+
279
+ ### Bundle layout
280
+
281
+ The published `dist/` ships an entry of about **9 KB** (engine + types + i18n
282
+ glue) and one chunk per country / locale. Modern bundlers consuming this
283
+ package will create separate chunks for each `import()`, so a consumer that
284
+ loads only `BRA` + `pt-BR` pays for **2 chunks**, not the entire library.
285
+
286
+ | Entry | Size (ESM) | Contents |
287
+ |-------|-----------:|----------|
288
+ | `index.mjs` | ~9 KB | Engine, types, registry shells, dynamic `import()` map |
289
+ | `BRA-*.mjs` | ~3 KB | Brazilian address schema |
290
+ | `bra-*.mjs` | ~2–4 KB | Brazilian validators / masks |
291
+ | `chunk-*.mjs` (BRA cities) | ~350 KB | Loaded only when `loadSchema('BRA', …)` resolves |
292
+ | `pt-BR-*.mjs` | ~4 KB | Portuguese locale bundle |
293
+
294
+ `package.json` declares `"sideEffects": false`, telling bundlers it is safe to
295
+ drop unreferenced re-exports. The published build is verified by an automated
296
+ tree-shake test in `__tests__/integration/tree-shake.test.ts`.
297
+
298
+ ### Quality gates
299
+
300
+ - `yarn verify` runs typecheck → lint → build → tests with coverage
301
+ - Jest enforces `coverageThreshold: 80%` per metric for `src/engine/`,
302
+ `src/rules/`, and `src/i18n/` (current coverage: ~99% lines, 100% functions)
303
+ - The quickstart in [`docs/quickstart.md`](./docs/quickstart.md) is exercised
304
+ end-to-end by `__tests__/integration/quickstart.test.ts`
@@ -0,0 +1,96 @@
1
+ import { BRA_STATES } from './chunk-26GYXS7J.mjs';
2
+ import './chunk-2JC3GVFR.mjs';
3
+
4
+ // src/schemas/address/BRA.ts
5
+ var schema = {
6
+ id: "address-BRA",
7
+ country: "BRA",
8
+ formType: "address",
9
+ fields: [
10
+ {
11
+ name: "postalCode",
12
+ type: "text",
13
+ label: "country-forms.address.postalCode.label",
14
+ placeholder: "country-forms.address.postalCode.placeholder.BRA",
15
+ required: true,
16
+ inputMode: "numeric",
17
+ maxLength: 9,
18
+ formatRef: "formatCEP",
19
+ unformatRef: "unformatCEP",
20
+ validation: {
21
+ customValidator: "validateCEP"
22
+ }
23
+ },
24
+ {
25
+ name: "street",
26
+ type: "text",
27
+ label: "country-forms.address.street.label",
28
+ required: true,
29
+ inputMode: "text",
30
+ maxLength: 750,
31
+ validation: {
32
+ maxLength: { value: 750, message: "country-forms.validation.maxLength" }
33
+ }
34
+ },
35
+ {
36
+ name: "number",
37
+ type: "text",
38
+ label: "country-forms.address.number.label",
39
+ required: true,
40
+ inputMode: "text",
41
+ maxLength: 10,
42
+ validation: {
43
+ maxLength: { value: 10, message: "country-forms.validation.maxLength" },
44
+ pattern: {
45
+ value: "^[a-zA-Z0-9-]+$",
46
+ message: "country-forms.validation.invalid"
47
+ }
48
+ }
49
+ },
50
+ {
51
+ name: "complement",
52
+ type: "text",
53
+ label: "country-forms.address.complement.label",
54
+ required: false,
55
+ inputMode: "text",
56
+ maxLength: 750,
57
+ validation: {
58
+ maxLength: { value: 750, message: "country-forms.validation.maxLength" }
59
+ }
60
+ },
61
+ {
62
+ name: "neighborhood",
63
+ type: "text",
64
+ label: "country-forms.address.neighborhood.label",
65
+ required: true,
66
+ inputMode: "text",
67
+ maxLength: 100,
68
+ validation: {
69
+ maxLength: { value: 100, message: "country-forms.validation.maxLength" }
70
+ }
71
+ },
72
+ {
73
+ name: "state",
74
+ type: "select",
75
+ label: "country-forms.address.state.label",
76
+ required: true,
77
+ options: "BRA.states"
78
+ },
79
+ {
80
+ name: "city",
81
+ type: "select",
82
+ label: "country-forms.address.city.label",
83
+ required: true,
84
+ dependsOn: "state",
85
+ conditionalOptions: Object.fromEntries(
86
+ BRA_STATES.map((s) => [s.value, `BRA.cities.${s.value}`])
87
+ ),
88
+ options: []
89
+ }
90
+ ]
91
+ };
92
+ var BRA_default = schema;
93
+
94
+ export { BRA_default as default };
95
+ //# sourceMappingURL=BRA-JUHEOV7J.mjs.map
96
+ //# sourceMappingURL=BRA-JUHEOV7J.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/address/BRA.ts"],"names":[],"mappings":";;;;AAgBA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,aAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,MAAA,EAAQ;AAAA,IACN;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,WAAA,EAAa,kDAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAW,CAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,oCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,GAAA;AAAA,MACX,UAAA,EAAY;AAAA,QACV,SAAA,EAAW,EAAE,KAAA,EAAO,GAAA,EAAK,SAAS,oCAAA;AAAqC;AACzE,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,oCAAA;AAAA,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CAAW,GAAA,CAAI,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,OAAO,CAAA,WAAA,EAAc,CAAA,CAAE,KAAK,CAAA,CAAE,CAAC;AAAA,OACxD;AAAA,MACA,SAAS;AAAC;AACZ;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-JUHEOV7J.mjs","sourcesContent":["/**\n * Address schema for Brazil (BRA).\n *\n * Field order follows VTEX checkout convention:\n * postalCode → street → number → complement → neighborhood → state → city\n *\n * Postal code: CEP (99999-999), validated by `validateCEP`, masked by `formatCEP`/`unformatCEP`.\n * Subdivision: 27 federative units — options ref `\"BRA.states\"`.\n * City is a dependent select: its options change based on the selected state\n * via `conditionalOptions` keyed by UF code (e.g. `\"SP\"` → `\"BRA.cities.SP\"`).\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`, `rules/options/bra-states`\n */\nimport { BRA_STATES } from '../../rules/options/bra-states'\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-BRA',\n country: 'BRA',\n formType: 'address',\n fields: [\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.BRA',\n required: true,\n inputMode: 'numeric',\n maxLength: 9,\n formatRef: 'formatCEP',\n unformatRef: 'unformatCEP',\n validation: {\n customValidator: 'validateCEP',\n },\n },\n {\n name: 'street',\n type: 'text',\n label: 'country-forms.address.street.label',\n required: true,\n inputMode: 'text',\n maxLength: 750,\n validation: {\n maxLength: { value: 750, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'number',\n type: 'text',\n label: 'country-forms.address.number.label',\n required: true,\n inputMode: 'text',\n maxLength: 10,\n validation: {\n maxLength: {value: 10, message: 'country-forms.validation.maxLength' },\n pattern: {\n value: '^[a-zA-Z0-9-]+$',\n message: 'country-forms.validation.invalid',\n },\n },\n },\n {\n name: 'complement',\n type: 'text',\n label: 'country-forms.address.complement.label',\n required: false,\n inputMode: 'text',\n maxLength: 750,\n validation: {\n maxLength: { value: 750, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'neighborhood',\n type: 'text',\n label: 'country-forms.address.neighborhood.label',\n required: true,\n inputMode: 'text',\n maxLength: 100,\n validation: {\n maxLength: { value: 100, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'state',\n type: 'select',\n label: 'country-forms.address.state.label',\n required: true,\n options: 'BRA.states',\n },\n {\n name: 'city',\n type: 'select',\n label: 'country-forms.address.city.label',\n required: true,\n dependsOn: 'state',\n conditionalOptions: Object.fromEntries(\n BRA_STATES.map(s => [s.value, `BRA.cities.${s.value}`])\n ),\n options: [],\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
@@ -0,0 +1,119 @@
1
+ 'use strict';
2
+
3
+ // src/schemas/personal-data/BRA.ts
4
+ var schema = {
5
+ id: "personal-data-BRA",
6
+ country: "BRA",
7
+ formType: "personal-data",
8
+ fields: [
9
+ {
10
+ name: "personType",
11
+ type: "radio-group",
12
+ label: "country-forms.personal-data.personType.label",
13
+ required: true,
14
+ options: [
15
+ { value: "individual", displayValue: "country-forms.personal-data.personType.individual" },
16
+ { value: "business", displayValue: "country-forms.personal-data.personType.business" }
17
+ ]
18
+ },
19
+ {
20
+ name: "firstName",
21
+ type: "text",
22
+ label: "country-forms.personal-data.firstName.label",
23
+ required: true,
24
+ inputMode: "text",
25
+ maxLength: 200,
26
+ dependsOn: "personType",
27
+ conditionalLabel: {
28
+ individual: "country-forms.personal-data.firstName.label.individual",
29
+ business: "country-forms.personal-data.firstName.label.business"
30
+ },
31
+ validation: {
32
+ maxLength: { value: 200, message: "country-forms.validation.maxLength" }
33
+ }
34
+ },
35
+ {
36
+ name: "lastName",
37
+ type: "text",
38
+ label: "country-forms.personal-data.lastName.label",
39
+ required: true,
40
+ inputMode: "text",
41
+ maxLength: 200,
42
+ conditionalVisibility: {
43
+ field: "personType",
44
+ operator: "equals",
45
+ value: "individual"
46
+ },
47
+ validation: {
48
+ maxLength: { value: 200, message: "country-forms.validation.maxLength" }
49
+ }
50
+ },
51
+ {
52
+ name: "email",
53
+ type: "email",
54
+ label: "country-forms.personal-data.email.label",
55
+ required: true,
56
+ inputMode: "email",
57
+ validation: {
58
+ customValidator: "validateEmail"
59
+ }
60
+ },
61
+ {
62
+ name: "phone",
63
+ type: "text",
64
+ label: "country-forms.personal-data.phone.label",
65
+ placeholder: "country-forms.personal-data.phone.placeholder.BRA",
66
+ required: true,
67
+ maxLength: 20,
68
+ inputMode: "tel",
69
+ formatRef: "formatPhoneBRA",
70
+ unformatRef: "unformatPhoneBRA",
71
+ validation: {
72
+ customValidator: "validatePhoneBRA"
73
+ }
74
+ },
75
+ {
76
+ name: "cpf",
77
+ type: "text",
78
+ label: "country-forms.personal-data.cpf.label",
79
+ placeholder: "country-forms.personal-data.cpf.placeholder",
80
+ required: true,
81
+ inputMode: "numeric",
82
+ maxLength: 14,
83
+ formatRef: "formatCPF",
84
+ unformatRef: "unformatCPF",
85
+ validation: {
86
+ customValidator: "validateCPF"
87
+ },
88
+ conditionalVisibility: {
89
+ field: "personType",
90
+ operator: "equals",
91
+ value: "individual"
92
+ }
93
+ },
94
+ {
95
+ name: "cnpj",
96
+ type: "text",
97
+ label: "country-forms.personal-data.cnpj.label",
98
+ placeholder: "country-forms.personal-data.cnpj.placeholder",
99
+ required: true,
100
+ inputMode: "text",
101
+ maxLength: 18,
102
+ formatRef: "formatCNPJ",
103
+ unformatRef: "unformatCNPJ",
104
+ validation: {
105
+ customValidator: "validateCNPJ"
106
+ },
107
+ conditionalVisibility: {
108
+ field: "personType",
109
+ operator: "equals",
110
+ value: "business"
111
+ }
112
+ }
113
+ ]
114
+ };
115
+ var BRA_default = schema;
116
+
117
+ module.exports = BRA_default;
118
+ //# sourceMappingURL=BRA-PMVV6KOM.js.map
119
+ //# sourceMappingURL=BRA-PMVV6KOM.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/personal-data/BRA.ts"],"names":[],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MAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAa,cAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-PMVV6KOM.js","sourcesContent":["/**\n * Personal-data schema for Brazil (BRA).\n *\n * Field order: personType → firstName → lastName → email → phone → cpf → cnpj\n *\n * `personType` drives conditional visibility:\n * - `\"individual\"` → `lastName`, `cpf` visible; `cnpj` hidden\n * - `\"business\"` → `cnpj` visible; `lastName`, `cpf` hidden\n *\n * `firstName` uses `conditionalLabel` keyed by `personType`:\n * - `\"individual\"` → \"First name\" / \"Nome\"\n * - `\"business\"` → \"Company name\" / \"Razão social\"\n *\n * `lastName` is only visible for individuals (hidden for businesses).\n *\n * Email: `joao.silva@example.com` -> validated by `validateEmail`.\n * Phone: `(11) 98888-7777` -> validated by `validatePhoneBRA`, masked by `formatPhoneBRA`/`unformatPhoneBRA`.\n * CPF: `999.999.999-99` — validated by `validateCPF`, masked by `formatCPF`/`unformatCPF`.\n * CNPJ: `99.999.999/9999-99` (numeric, legacy) or `AA.AAA.AAA/AAAA-99` (alphanumeric, SERPRO 2024+) —\n * validated by `validateCNPJ`, masked by `formatCNPJ`/`unformatCNPJ`. The first 12 characters can be\n * `[A-Z0-9]`; the last 2 (check digits) are always numeric.\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'personal-data-BRA',\n country: 'BRA',\n formType: 'personal-data',\n fields: [\n {\n name: 'personType',\n type: 'radio-group',\n label: 'country-forms.personal-data.personType.label',\n required: true,\n options: [\n { value: 'individual', displayValue: 'country-forms.personal-data.personType.individual' },\n { value: 'business', displayValue: 'country-forms.personal-data.personType.business' },\n ],\n },\n {\n name: 'firstName',\n type: 'text',\n label: 'country-forms.personal-data.firstName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n dependsOn: 'personType',\n conditionalLabel: {\n individual: 'country-forms.personal-data.firstName.label.individual',\n business: 'country-forms.personal-data.firstName.label.business',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'lastName',\n type: 'text',\n label: 'country-forms.personal-data.lastName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'email',\n type: 'email',\n label: 'country-forms.personal-data.email.label',\n required: true,\n inputMode: 'email',\n validation: {\n customValidator: 'validateEmail',\n },\n },\n {\n name: 'phone',\n type: 'text',\n label: 'country-forms.personal-data.phone.label',\n placeholder: 'country-forms.personal-data.phone.placeholder.BRA',\n required: true,\n maxLength: 20,\n inputMode: 'tel',\n formatRef: 'formatPhoneBRA',\n unformatRef: 'unformatPhoneBRA',\n validation: {\n customValidator: 'validatePhoneBRA',\n },\n },\n {\n name: 'cpf',\n type: 'text',\n label: 'country-forms.personal-data.cpf.label',\n placeholder: 'country-forms.personal-data.cpf.placeholder',\n required: true,\n inputMode: 'numeric',\n maxLength: 14,\n formatRef: 'formatCPF',\n unformatRef: 'unformatCPF',\n validation: {\n customValidator: 'validateCPF',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n },\n {\n name: 'cnpj',\n type: 'text',\n label: 'country-forms.personal-data.cnpj.label',\n placeholder: 'country-forms.personal-data.cnpj.placeholder',\n required: true,\n inputMode: 'text',\n maxLength: 18,\n formatRef: 'formatCNPJ',\n unformatRef: 'unformatCNPJ',\n validation: {\n customValidator: 'validateCNPJ',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'business',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
@@ -0,0 +1,98 @@
1
+ 'use strict';
2
+
3
+ var chunkLU6ZDUJ5_js = require('./chunk-LU6ZDUJ5.js');
4
+ require('./chunk-YB6VNXLI.js');
5
+
6
+ // src/schemas/address/BRA.ts
7
+ var schema = {
8
+ id: "address-BRA",
9
+ country: "BRA",
10
+ formType: "address",
11
+ fields: [
12
+ {
13
+ name: "postalCode",
14
+ type: "text",
15
+ label: "country-forms.address.postalCode.label",
16
+ placeholder: "country-forms.address.postalCode.placeholder.BRA",
17
+ required: true,
18
+ inputMode: "numeric",
19
+ maxLength: 9,
20
+ formatRef: "formatCEP",
21
+ unformatRef: "unformatCEP",
22
+ validation: {
23
+ customValidator: "validateCEP"
24
+ }
25
+ },
26
+ {
27
+ name: "street",
28
+ type: "text",
29
+ label: "country-forms.address.street.label",
30
+ required: true,
31
+ inputMode: "text",
32
+ maxLength: 750,
33
+ validation: {
34
+ maxLength: { value: 750, message: "country-forms.validation.maxLength" }
35
+ }
36
+ },
37
+ {
38
+ name: "number",
39
+ type: "text",
40
+ label: "country-forms.address.number.label",
41
+ required: true,
42
+ inputMode: "text",
43
+ maxLength: 10,
44
+ validation: {
45
+ maxLength: { value: 10, message: "country-forms.validation.maxLength" },
46
+ pattern: {
47
+ value: "^[a-zA-Z0-9-]+$",
48
+ message: "country-forms.validation.invalid"
49
+ }
50
+ }
51
+ },
52
+ {
53
+ name: "complement",
54
+ type: "text",
55
+ label: "country-forms.address.complement.label",
56
+ required: false,
57
+ inputMode: "text",
58
+ maxLength: 750,
59
+ validation: {
60
+ maxLength: { value: 750, message: "country-forms.validation.maxLength" }
61
+ }
62
+ },
63
+ {
64
+ name: "neighborhood",
65
+ type: "text",
66
+ label: "country-forms.address.neighborhood.label",
67
+ required: true,
68
+ inputMode: "text",
69
+ maxLength: 100,
70
+ validation: {
71
+ maxLength: { value: 100, message: "country-forms.validation.maxLength" }
72
+ }
73
+ },
74
+ {
75
+ name: "state",
76
+ type: "select",
77
+ label: "country-forms.address.state.label",
78
+ required: true,
79
+ options: "BRA.states"
80
+ },
81
+ {
82
+ name: "city",
83
+ type: "select",
84
+ label: "country-forms.address.city.label",
85
+ required: true,
86
+ dependsOn: "state",
87
+ conditionalOptions: Object.fromEntries(
88
+ chunkLU6ZDUJ5_js.BRA_STATES.map((s) => [s.value, `BRA.cities.${s.value}`])
89
+ ),
90
+ options: []
91
+ }
92
+ ]
93
+ };
94
+ var BRA_default = schema;
95
+
96
+ module.exports = BRA_default;
97
+ //# sourceMappingURL=BRA-VIVRV7X7.js.map
98
+ //# sourceMappingURL=BRA-VIVRV7X7.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/address/BRA.ts"],"names":["BRA_STATES"],"mappings":";;;;;;AAgBA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,aAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,MAAA,EAAQ;AAAA,IACN;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,WAAA,EAAa,kDAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAW,CAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,QAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,oCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,GAAA;AAAA,MACX,UAAA,EAAY;AAAA,QACV,SAAA,E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AAA,MACN,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,kCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,OAAA;AAAA,MACX,oBAAoB,MAAA,CAAO,WAAA;AAAA,QACzBA,2BAAA,CAAW,GAAA,CAAI,CAAA,CAAA,KAAK,CAAC,CAAA,CAAE,OAAO,CAAA,WAAA,EAAc,CAAA,CAAE,KAAK,CAAA,CAAE,CAAC;AAAA,OACxD;AAAA,MACA,SAAS;AAAC;AACZ;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-VIVRV7X7.js","sourcesContent":["/**\n * Address schema for Brazil (BRA).\n *\n * Field order follows VTEX checkout convention:\n * postalCode → street → number → complement → neighborhood → state → city\n *\n * Postal code: CEP (99999-999), validated by `validateCEP`, masked by `formatCEP`/`unformatCEP`.\n * Subdivision: 27 federative units — options ref `\"BRA.states\"`.\n * City is a dependent select: its options change based on the selected state\n * via `conditionalOptions` keyed by UF code (e.g. `\"SP\"` → `\"BRA.cities.SP\"`).\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`, `rules/options/bra-states`\n */\nimport { BRA_STATES } from '../../rules/options/bra-states'\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-BRA',\n country: 'BRA',\n formType: 'address',\n fields: [\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.BRA',\n required: true,\n inputMode: 'numeric',\n maxLength: 9,\n formatRef: 'formatCEP',\n unformatRef: 'unformatCEP',\n validation: {\n customValidator: 'validateCEP',\n },\n },\n {\n name: 'street',\n type: 'text',\n label: 'country-forms.address.street.label',\n required: true,\n inputMode: 'text',\n maxLength: 750,\n validation: {\n maxLength: { value: 750, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'number',\n type: 'text',\n label: 'country-forms.address.number.label',\n required: true,\n inputMode: 'text',\n maxLength: 10,\n validation: {\n maxLength: {value: 10, message: 'country-forms.validation.maxLength' },\n pattern: {\n value: '^[a-zA-Z0-9-]+$',\n message: 'country-forms.validation.invalid',\n },\n },\n },\n {\n name: 'complement',\n type: 'text',\n label: 'country-forms.address.complement.label',\n required: false,\n inputMode: 'text',\n maxLength: 750,\n validation: {\n maxLength: { value: 750, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'neighborhood',\n type: 'text',\n label: 'country-forms.address.neighborhood.label',\n required: true,\n inputMode: 'text',\n maxLength: 100,\n validation: {\n maxLength: { value: 100, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'state',\n type: 'select',\n label: 'country-forms.address.state.label',\n required: true,\n options: 'BRA.states',\n },\n {\n name: 'city',\n type: 'select',\n label: 'country-forms.address.city.label',\n required: true,\n dependsOn: 'state',\n conditionalOptions: Object.fromEntries(\n BRA_STATES.map(s => [s.value, `BRA.cities.${s.value}`])\n ),\n options: [],\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
@@ -0,0 +1,117 @@
1
+ // src/schemas/personal-data/BRA.ts
2
+ var schema = {
3
+ id: "personal-data-BRA",
4
+ country: "BRA",
5
+ formType: "personal-data",
6
+ fields: [
7
+ {
8
+ name: "personType",
9
+ type: "radio-group",
10
+ label: "country-forms.personal-data.personType.label",
11
+ required: true,
12
+ options: [
13
+ { value: "individual", displayValue: "country-forms.personal-data.personType.individual" },
14
+ { value: "business", displayValue: "country-forms.personal-data.personType.business" }
15
+ ]
16
+ },
17
+ {
18
+ name: "firstName",
19
+ type: "text",
20
+ label: "country-forms.personal-data.firstName.label",
21
+ required: true,
22
+ inputMode: "text",
23
+ maxLength: 200,
24
+ dependsOn: "personType",
25
+ conditionalLabel: {
26
+ individual: "country-forms.personal-data.firstName.label.individual",
27
+ business: "country-forms.personal-data.firstName.label.business"
28
+ },
29
+ validation: {
30
+ maxLength: { value: 200, message: "country-forms.validation.maxLength" }
31
+ }
32
+ },
33
+ {
34
+ name: "lastName",
35
+ type: "text",
36
+ label: "country-forms.personal-data.lastName.label",
37
+ required: true,
38
+ inputMode: "text",
39
+ maxLength: 200,
40
+ conditionalVisibility: {
41
+ field: "personType",
42
+ operator: "equals",
43
+ value: "individual"
44
+ },
45
+ validation: {
46
+ maxLength: { value: 200, message: "country-forms.validation.maxLength" }
47
+ }
48
+ },
49
+ {
50
+ name: "email",
51
+ type: "email",
52
+ label: "country-forms.personal-data.email.label",
53
+ required: true,
54
+ inputMode: "email",
55
+ validation: {
56
+ customValidator: "validateEmail"
57
+ }
58
+ },
59
+ {
60
+ name: "phone",
61
+ type: "text",
62
+ label: "country-forms.personal-data.phone.label",
63
+ placeholder: "country-forms.personal-data.phone.placeholder.BRA",
64
+ required: true,
65
+ maxLength: 20,
66
+ inputMode: "tel",
67
+ formatRef: "formatPhoneBRA",
68
+ unformatRef: "unformatPhoneBRA",
69
+ validation: {
70
+ customValidator: "validatePhoneBRA"
71
+ }
72
+ },
73
+ {
74
+ name: "cpf",
75
+ type: "text",
76
+ label: "country-forms.personal-data.cpf.label",
77
+ placeholder: "country-forms.personal-data.cpf.placeholder",
78
+ required: true,
79
+ inputMode: "numeric",
80
+ maxLength: 14,
81
+ formatRef: "formatCPF",
82
+ unformatRef: "unformatCPF",
83
+ validation: {
84
+ customValidator: "validateCPF"
85
+ },
86
+ conditionalVisibility: {
87
+ field: "personType",
88
+ operator: "equals",
89
+ value: "individual"
90
+ }
91
+ },
92
+ {
93
+ name: "cnpj",
94
+ type: "text",
95
+ label: "country-forms.personal-data.cnpj.label",
96
+ placeholder: "country-forms.personal-data.cnpj.placeholder",
97
+ required: true,
98
+ inputMode: "text",
99
+ maxLength: 18,
100
+ formatRef: "formatCNPJ",
101
+ unformatRef: "unformatCNPJ",
102
+ validation: {
103
+ customValidator: "validateCNPJ"
104
+ },
105
+ conditionalVisibility: {
106
+ field: "personType",
107
+ operator: "equals",
108
+ value: "business"
109
+ }
110
+ }
111
+ ]
112
+ };
113
+ var BRA_default = schema;
114
+
115
+ export { BRA_default as default };
116
+ //# sourceMappingURL=BRA-ZBZXE5II.mjs.map
117
+ //# sourceMappingURL=BRA-ZBZXE5II.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/schemas/personal-data/BRA.ts"],"names":[],"mappings":";AA0BA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,mBAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QAAA,EAAU,eAAA;AAAA,EACV,MAAA,EAAQ;AAAA,IACN;AAAA,MACE,IAAA,EAAM,YAAA;AAAA,MACN,IAAA,EAAM,aAAA;AAAA,MACN,KAAA,EAAO,8CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,QACP,EAAE,KAAA,EAAO,YAAA,EAAc,YAAA,EAAc,mDAAA,EAAoD;AAAA,QACzF,EAAE,KAAA,EAAO,UAAA,EAAY,YAAA,EAAc,iDAAA;AAAkD;AACvF,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,WAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,6CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,GAAA;AAAA,MACX,SAAA,EAAW,YAAA;AAAA,MACX,gBAAA,EAAkB;AAAA,QAChB,UAAA,EAAY,wDAAA;AAAA,QACZ,QAAA,EAAU;AAAA,OACZ;AAAA,MACA,UAAA,EAAY;AAAA,QACV,SAAA,EAAW,EAAE,KAAA,EAAO,GAAA,EAAK,SAAS,oCAAA;AAAqC;AACzE,KACF;AAAA,IACA;AAAA,MACE,IAAA,EAAM,UAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,4CAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,GAAA;AAAA,MACX,qBAAA,EAAuB;AAAA,QAC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,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,WAAA,EAAa,8CAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,YAAA;AAAA,MACX,WAAA,EAAa,cAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA,OACnB;AAAA,MACA,qBAAA,EAAuB;AAAA,QACrB,KAAA,EAAO,YAAA;AAAA,QACP,QAAA,EAAU,QAAA;AAAA,QACV,KAAA,EAAO;AAAA;AACT;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"BRA-ZBZXE5II.mjs","sourcesContent":["/**\n * Personal-data schema for Brazil (BRA).\n *\n * Field order: personType → firstName → lastName → email → phone → cpf → cnpj\n *\n * `personType` drives conditional visibility:\n * - `\"individual\"` → `lastName`, `cpf` visible; `cnpj` hidden\n * - `\"business\"` → `cnpj` visible; `lastName`, `cpf` hidden\n *\n * `firstName` uses `conditionalLabel` keyed by `personType`:\n * - `\"individual\"` → \"First name\" / \"Nome\"\n * - `\"business\"` → \"Company name\" / \"Razão social\"\n *\n * `lastName` is only visible for individuals (hidden for businesses).\n *\n * Email: `joao.silva@example.com` -> validated by `validateEmail`.\n * Phone: `(11) 98888-7777` -> validated by `validatePhoneBRA`, masked by `formatPhoneBRA`/`unformatPhoneBRA`.\n * CPF: `999.999.999-99` — validated by `validateCPF`, masked by `formatCPF`/`unformatCPF`.\n * CNPJ: `99.999.999/9999-99` (numeric, legacy) or `AA.AAA.AAA/AAAA-99` (alphanumeric, SERPRO 2024+) —\n * validated by `validateCNPJ`, masked by `formatCNPJ`/`unformatCNPJ`. The first 12 characters can be\n * `[A-Z0-9]`; the last 2 (check digits) are always numeric.\n *\n * Required rule modules: `rules/validators/bra`, `rules/masks/bra`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'personal-data-BRA',\n country: 'BRA',\n formType: 'personal-data',\n fields: [\n {\n name: 'personType',\n type: 'radio-group',\n label: 'country-forms.personal-data.personType.label',\n required: true,\n options: [\n { value: 'individual', displayValue: 'country-forms.personal-data.personType.individual' },\n { value: 'business', displayValue: 'country-forms.personal-data.personType.business' },\n ],\n },\n {\n name: 'firstName',\n type: 'text',\n label: 'country-forms.personal-data.firstName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n dependsOn: 'personType',\n conditionalLabel: {\n individual: 'country-forms.personal-data.firstName.label.individual',\n business: 'country-forms.personal-data.firstName.label.business',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'lastName',\n type: 'text',\n label: 'country-forms.personal-data.lastName.label',\n required: true,\n inputMode: 'text',\n maxLength: 200,\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n validation: {\n maxLength: { value: 200, message: 'country-forms.validation.maxLength' },\n },\n },\n {\n name: 'email',\n type: 'email',\n label: 'country-forms.personal-data.email.label',\n required: true,\n inputMode: 'email',\n validation: {\n customValidator: 'validateEmail',\n },\n },\n {\n name: 'phone',\n type: 'text',\n label: 'country-forms.personal-data.phone.label',\n placeholder: 'country-forms.personal-data.phone.placeholder.BRA',\n required: true,\n maxLength: 20,\n inputMode: 'tel',\n formatRef: 'formatPhoneBRA',\n unformatRef: 'unformatPhoneBRA',\n validation: {\n customValidator: 'validatePhoneBRA',\n },\n },\n {\n name: 'cpf',\n type: 'text',\n label: 'country-forms.personal-data.cpf.label',\n placeholder: 'country-forms.personal-data.cpf.placeholder',\n required: true,\n inputMode: 'numeric',\n maxLength: 14,\n formatRef: 'formatCPF',\n unformatRef: 'unformatCPF',\n validation: {\n customValidator: 'validateCPF',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'individual',\n },\n },\n {\n name: 'cnpj',\n type: 'text',\n label: 'country-forms.personal-data.cnpj.label',\n placeholder: 'country-forms.personal-data.cnpj.placeholder',\n required: true,\n inputMode: 'text',\n maxLength: 18,\n formatRef: 'formatCNPJ',\n unformatRef: 'unformatCNPJ',\n validation: {\n customValidator: 'validateCNPJ',\n },\n conditionalVisibility: {\n field: 'personType',\n operator: 'equals',\n value: 'business',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}