@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.
- package/CHANGELOG.md +120 -0
- package/README.md +29 -1
- package/dist/BRA-JUHEOV7J.mjs +96 -0
- package/dist/BRA-JUHEOV7J.mjs.map +1 -0
- package/dist/BRA-PMVV6KOM.js +119 -0
- package/dist/BRA-PMVV6KOM.js.map +1 -0
- package/dist/BRA-VIVRV7X7.js +98 -0
- package/dist/BRA-VIVRV7X7.js.map +1 -0
- package/dist/BRA-ZBZXE5II.mjs +117 -0
- package/dist/BRA-ZBZXE5II.mjs.map +1 -0
- package/dist/CAN-HUMAGSIC.mjs +67 -0
- package/dist/CAN-HUMAGSIC.mjs.map +1 -0
- package/dist/CAN-NGS6AUBG.js +69 -0
- package/dist/CAN-NGS6AUBG.js.map +1 -0
- package/dist/MEX-3PMZHDQP.js +89 -0
- package/dist/MEX-3PMZHDQP.js.map +1 -0
- package/dist/MEX-QFS4JTN6.mjs +87 -0
- package/dist/MEX-QFS4JTN6.mjs.map +1 -0
- package/dist/USA-E5AZRBXA.mjs +67 -0
- package/dist/USA-E5AZRBXA.mjs.map +1 -0
- package/dist/USA-UBWW5NQB.js +69 -0
- package/dist/USA-UBWW5NQB.js.map +1 -0
- package/dist/bra-I5DOHE34.mjs +57 -0
- package/dist/bra-I5DOHE34.mjs.map +1 -0
- package/dist/bra-ILOTR4AN.mjs +90 -0
- package/dist/bra-ILOTR4AN.mjs.map +1 -0
- package/dist/bra-KEBYAD75.js +66 -0
- package/dist/bra-KEBYAD75.js.map +1 -0
- package/dist/bra-MHTXSNLA.js +96 -0
- package/dist/bra-MHTXSNLA.js.map +1 -0
- package/dist/bra-states-Q4H2TVQZ.mjs +4 -0
- package/dist/bra-states-Q4H2TVQZ.mjs.map +1 -0
- package/dist/bra-states-SQMU4WTB.js +17 -0
- package/dist/bra-states-SQMU4WTB.js.map +1 -0
- package/dist/can-7TMYDEJF.mjs +17 -0
- package/dist/can-7TMYDEJF.mjs.map +1 -0
- package/dist/can-B5ME2ZFN.js +20 -0
- package/dist/can-B5ME2ZFN.js.map +1 -0
- package/dist/can-FGNN5MZS.mjs +19 -0
- package/dist/can-FGNN5MZS.mjs.map +1 -0
- package/dist/can-LLJ4A5Y5.js +21 -0
- package/dist/can-LLJ4A5Y5.js.map +1 -0
- package/dist/can-provinces-5S5FSO6H.mjs +23 -0
- package/dist/can-provinces-5S5FSO6H.mjs.map +1 -0
- package/dist/can-provinces-6NOHMW37.js +25 -0
- package/dist/can-provinces-6NOHMW37.js.map +1 -0
- package/dist/chunk-26GYXS7J.mjs +5622 -0
- package/dist/chunk-26GYXS7J.mjs.map +1 -0
- package/dist/chunk-2JC3GVFR.mjs +21 -0
- package/dist/chunk-2JC3GVFR.mjs.map +1 -0
- package/dist/chunk-BMZHOWIP.mjs +21 -0
- package/dist/chunk-BMZHOWIP.mjs.map +1 -0
- package/dist/chunk-BQPGLWMB.js +25 -0
- package/dist/chunk-BQPGLWMB.js.map +1 -0
- package/dist/chunk-CFX5EF4R.js +21 -0
- package/dist/chunk-CFX5EF4R.js.map +1 -0
- package/dist/chunk-KWESVZKV.mjs +18 -0
- package/dist/chunk-KWESVZKV.mjs.map +1 -0
- package/dist/chunk-LU6ZDUJ5.js +5625 -0
- package/dist/chunk-LU6ZDUJ5.js.map +1 -0
- package/dist/chunk-YB6VNXLI.js +25 -0
- package/dist/chunk-YB6VNXLI.js.map +1 -0
- package/dist/en-US-RLEM27ZZ.js +51 -0
- package/dist/en-US-RLEM27ZZ.js.map +1 -0
- package/dist/en-US-YW7UYXNB.mjs +49 -0
- package/dist/en-US-YW7UYXNB.mjs.map +1 -0
- package/dist/es-MX-AGRGVXRK.mjs +49 -0
- package/dist/es-MX-AGRGVXRK.mjs.map +1 -0
- package/dist/es-MX-K5MWKMJW.js +51 -0
- package/dist/es-MX-K5MWKMJW.js.map +1 -0
- package/dist/fr-FR-KWQ3MPP5.mjs +49 -0
- package/dist/fr-FR-KWQ3MPP5.mjs.map +1 -0
- package/dist/fr-FR-LJIPE6BH.js +51 -0
- package/dist/fr-FR-LJIPE6BH.js.map +1 -0
- package/dist/index.d.mts +50 -5
- package/dist/index.d.ts +50 -5
- package/dist/index.js +73 -6890
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +66 -6883
- package/dist/index.mjs.map +1 -1
- package/dist/mex-5BKCF6LS.js +21 -0
- package/dist/mex-5BKCF6LS.js.map +1 -0
- package/dist/mex-G3HMNBBF.mjs +19 -0
- package/dist/mex-G3HMNBBF.mjs.map +1 -0
- package/dist/mex-states-GTCRN4NS.js +44 -0
- package/dist/mex-states-GTCRN4NS.js.map +1 -0
- package/dist/mex-states-KPEGWYKG.mjs +42 -0
- package/dist/mex-states-KPEGWYKG.mjs.map +1 -0
- package/dist/pt-BR-74IZNREP.js +51 -0
- package/dist/pt-BR-74IZNREP.js.map +1 -0
- package/dist/pt-BR-P2RZ3X3H.mjs +49 -0
- package/dist/pt-BR-P2RZ3X3H.mjs.map +1 -0
- package/dist/usa-3AM7UFVG.js +20 -0
- package/dist/usa-3AM7UFVG.js.map +1 -0
- package/dist/usa-I7DK2CTL.mjs +18 -0
- package/dist/usa-I7DK2CTL.mjs.map +1 -0
- package/dist/usa-LXT6WW64.js +21 -0
- package/dist/usa-LXT6WW64.js.map +1 -0
- package/dist/usa-ZD5OWGAD.mjs +18 -0
- package/dist/usa-ZD5OWGAD.mjs.map +1 -0
- package/dist/usa-states-EBFT4LUQ.js +63 -0
- package/dist/usa-states-EBFT4LUQ.js.map +1 -0
- package/dist/usa-states-FF5OQBEL.mjs +61 -0
- package/dist/usa-states-FF5OQBEL.mjs.map +1 -0
- package/package.json +3 -1
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/schemas/address/CAN.ts
|
|
2
|
+
var schema = {
|
|
3
|
+
id: "address-CAN",
|
|
4
|
+
country: "CAN",
|
|
5
|
+
formType: "address",
|
|
6
|
+
fields: [
|
|
7
|
+
{
|
|
8
|
+
name: "street",
|
|
9
|
+
type: "text",
|
|
10
|
+
label: "country-forms.address.street.label",
|
|
11
|
+
required: true,
|
|
12
|
+
inputMode: "text",
|
|
13
|
+
maxLength: 750,
|
|
14
|
+
validation: {
|
|
15
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "complement",
|
|
20
|
+
type: "text",
|
|
21
|
+
label: "country-forms.address.complement.label",
|
|
22
|
+
required: false,
|
|
23
|
+
inputMode: "text",
|
|
24
|
+
maxLength: 750,
|
|
25
|
+
validation: {
|
|
26
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "city",
|
|
31
|
+
type: "text",
|
|
32
|
+
label: "country-forms.address.city.label",
|
|
33
|
+
required: true,
|
|
34
|
+
inputMode: "text",
|
|
35
|
+
maxLength: 100,
|
|
36
|
+
validation: {
|
|
37
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "state",
|
|
42
|
+
type: "select",
|
|
43
|
+
label: "country-forms.address.state.label",
|
|
44
|
+
required: true,
|
|
45
|
+
options: "CAN.provinces"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "postalCode",
|
|
49
|
+
type: "text",
|
|
50
|
+
label: "country-forms.address.postalCode.label",
|
|
51
|
+
placeholder: "country-forms.address.postalCode.placeholder.CAN",
|
|
52
|
+
required: true,
|
|
53
|
+
inputMode: "text",
|
|
54
|
+
maxLength: 7,
|
|
55
|
+
formatRef: "formatPostalCodeCAN",
|
|
56
|
+
unformatRef: "unformatPostalCodeCAN",
|
|
57
|
+
validation: {
|
|
58
|
+
customValidator: "validatePostalCodeCAN"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
var CAN_default = schema;
|
|
64
|
+
|
|
65
|
+
export { CAN_default as default };
|
|
66
|
+
//# sourceMappingURL=CAN-HUMAGSIC.mjs.map
|
|
67
|
+
//# sourceMappingURL=CAN-HUMAGSIC.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/CAN.ts"],"names":[],"mappings":";AAaA,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,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,YAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,QAAA,EAAU,KAAA;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,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,kCAAA;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,OAAA;AAAA,MACN,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,mCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,KACX;AAAA,IACA;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,MAAA;AAAA,MACX,SAAA,EAAW,CAAA;AAAA,MACX,SAAA,EAAW,qBAAA;AAAA,MACX,WAAA,EAAa,uBAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"CAN-HUMAGSIC.mjs","sourcesContent":["/**\n * Address schema for Canada (CAN).\n *\n * Field order: street → complement → city → state → postalCode\n *\n * Postal code: Canadian format A1A 1A1, validated by `validatePostalCodeCAN`,\n * masked by `formatPostalCodeCAN`/`unformatPostalCodeCAN`.\n * Subdivision: 13 provinces and territories — options ref `\"CAN.provinces\"`.\n *\n * Required rule modules: `rules/validators/can`, `rules/masks/can`, `rules/options/can-provinces`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-CAN',\n country: 'CAN',\n formType: 'address',\n fields: [\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: '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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'CAN.provinces',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.CAN',\n required: true,\n inputMode: 'text',\n maxLength: 7,\n formatRef: 'formatPostalCodeCAN',\n unformatRef: 'unformatPostalCodeCAN',\n validation: {\n customValidator: 'validatePostalCodeCAN',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/schemas/address/CAN.ts
|
|
4
|
+
var schema = {
|
|
5
|
+
id: "address-CAN",
|
|
6
|
+
country: "CAN",
|
|
7
|
+
formType: "address",
|
|
8
|
+
fields: [
|
|
9
|
+
{
|
|
10
|
+
name: "street",
|
|
11
|
+
type: "text",
|
|
12
|
+
label: "country-forms.address.street.label",
|
|
13
|
+
required: true,
|
|
14
|
+
inputMode: "text",
|
|
15
|
+
maxLength: 750,
|
|
16
|
+
validation: {
|
|
17
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "complement",
|
|
22
|
+
type: "text",
|
|
23
|
+
label: "country-forms.address.complement.label",
|
|
24
|
+
required: false,
|
|
25
|
+
inputMode: "text",
|
|
26
|
+
maxLength: 750,
|
|
27
|
+
validation: {
|
|
28
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "city",
|
|
33
|
+
type: "text",
|
|
34
|
+
label: "country-forms.address.city.label",
|
|
35
|
+
required: true,
|
|
36
|
+
inputMode: "text",
|
|
37
|
+
maxLength: 100,
|
|
38
|
+
validation: {
|
|
39
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "state",
|
|
44
|
+
type: "select",
|
|
45
|
+
label: "country-forms.address.state.label",
|
|
46
|
+
required: true,
|
|
47
|
+
options: "CAN.provinces"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "postalCode",
|
|
51
|
+
type: "text",
|
|
52
|
+
label: "country-forms.address.postalCode.label",
|
|
53
|
+
placeholder: "country-forms.address.postalCode.placeholder.CAN",
|
|
54
|
+
required: true,
|
|
55
|
+
inputMode: "text",
|
|
56
|
+
maxLength: 7,
|
|
57
|
+
formatRef: "formatPostalCodeCAN",
|
|
58
|
+
unformatRef: "unformatPostalCodeCAN",
|
|
59
|
+
validation: {
|
|
60
|
+
customValidator: "validatePostalCodeCAN"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
var CAN_default = schema;
|
|
66
|
+
|
|
67
|
+
module.exports = CAN_default;
|
|
68
|
+
//# sourceMappingURL=CAN-NGS6AUBG.js.map
|
|
69
|
+
//# sourceMappingURL=CAN-NGS6AUBG.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/CAN.ts"],"names":[],"mappings":";;;AAaA,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,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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n * Field order: street → complement → city → state → postalCode\n *\n * Postal code: Canadian format A1A 1A1, validated by `validatePostalCodeCAN`,\n * masked by `formatPostalCodeCAN`/`unformatPostalCodeCAN`.\n * Subdivision: 13 provinces and territories — options ref `\"CAN.provinces\"`.\n *\n * Required rule modules: `rules/validators/can`, `rules/masks/can`, `rules/options/can-provinces`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-CAN',\n country: 'CAN',\n formType: 'address',\n fields: [\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: '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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'CAN.provinces',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.CAN',\n required: true,\n inputMode: 'text',\n maxLength: 7,\n formatRef: 'formatPostalCodeCAN',\n unformatRef: 'unformatPostalCodeCAN',\n validation: {\n customValidator: 'validatePostalCodeCAN',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/schemas/address/MEX.ts
|
|
4
|
+
var schema = {
|
|
5
|
+
id: "address-MEX",
|
|
6
|
+
country: "MEX",
|
|
7
|
+
formType: "address",
|
|
8
|
+
fields: [
|
|
9
|
+
{
|
|
10
|
+
name: "street",
|
|
11
|
+
type: "text",
|
|
12
|
+
label: "country-forms.address.street.label",
|
|
13
|
+
required: true,
|
|
14
|
+
inputMode: "text",
|
|
15
|
+
maxLength: 750,
|
|
16
|
+
validation: {
|
|
17
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "number",
|
|
22
|
+
type: "text",
|
|
23
|
+
label: "country-forms.address.number.label",
|
|
24
|
+
required: true,
|
|
25
|
+
inputMode: "text",
|
|
26
|
+
maxLength: 10,
|
|
27
|
+
validation: {
|
|
28
|
+
maxLength: { value: 10, message: "country-forms.validation.maxLength" }
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "complement",
|
|
33
|
+
type: "text",
|
|
34
|
+
label: "country-forms.address.complement.label",
|
|
35
|
+
required: false,
|
|
36
|
+
inputMode: "text",
|
|
37
|
+
maxLength: 750,
|
|
38
|
+
validation: {
|
|
39
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "neighborhood",
|
|
44
|
+
type: "text",
|
|
45
|
+
label: "country-forms.address.neighborhood.label",
|
|
46
|
+
required: true,
|
|
47
|
+
inputMode: "text",
|
|
48
|
+
maxLength: 100,
|
|
49
|
+
validation: {
|
|
50
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
51
|
+
}
|
|
52
|
+
},
|
|
53
|
+
{
|
|
54
|
+
name: "city",
|
|
55
|
+
type: "text",
|
|
56
|
+
label: "country-forms.address.city.label",
|
|
57
|
+
required: true,
|
|
58
|
+
inputMode: "text",
|
|
59
|
+
maxLength: 100,
|
|
60
|
+
validation: {
|
|
61
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
62
|
+
}
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
name: "state",
|
|
66
|
+
type: "select",
|
|
67
|
+
label: "country-forms.address.state.label",
|
|
68
|
+
required: true,
|
|
69
|
+
options: "MEX.states"
|
|
70
|
+
},
|
|
71
|
+
{
|
|
72
|
+
name: "postalCode",
|
|
73
|
+
type: "text",
|
|
74
|
+
label: "country-forms.address.postalCode.label",
|
|
75
|
+
placeholder: "country-forms.address.postalCode.placeholder.MEX",
|
|
76
|
+
required: true,
|
|
77
|
+
inputMode: "numeric",
|
|
78
|
+
maxLength: 5,
|
|
79
|
+
validation: {
|
|
80
|
+
customValidator: "validatePostalCodeMEX"
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
]
|
|
84
|
+
};
|
|
85
|
+
var MEX_default = schema;
|
|
86
|
+
|
|
87
|
+
module.exports = MEX_default;
|
|
88
|
+
//# sourceMappingURL=MEX-3PMZHDQP.js.map
|
|
89
|
+
//# sourceMappingURL=MEX-3PMZHDQP.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/MEX.ts"],"names":[],"mappings":";;;AAcA,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,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,MACP,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,MAAA;AAAA,MACX,S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AAA,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,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"MEX-3PMZHDQP.js","sourcesContent":["/**\n * Address schema for Mexico (MEX).\n *\n * Field order: street → number → neighborhood → city → state → postalCode\n *\n * Postal code: Código Postal (5 digits, e.g. `\"06600\"`), validated by `validatePostalCodeMEX`.\n * No mask is applied — the raw value is always 5 digits with no formatting.\n * Subdivision: 32 states — options ref `\"MEX.states\"`.\n * Neighborhood (Colonia) is optional.\n *\n * Required rule modules: `rules/validators/mex`, `rules/options/mex-states`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-MEX',\n country: 'MEX',\n formType: 'address',\n fields: [\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 },\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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'MEX.states',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.MEX',\n required: true,\n inputMode: 'numeric',\n maxLength: 5,\n validation: {\n customValidator: 'validatePostalCodeMEX',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
// src/schemas/address/MEX.ts
|
|
2
|
+
var schema = {
|
|
3
|
+
id: "address-MEX",
|
|
4
|
+
country: "MEX",
|
|
5
|
+
formType: "address",
|
|
6
|
+
fields: [
|
|
7
|
+
{
|
|
8
|
+
name: "street",
|
|
9
|
+
type: "text",
|
|
10
|
+
label: "country-forms.address.street.label",
|
|
11
|
+
required: true,
|
|
12
|
+
inputMode: "text",
|
|
13
|
+
maxLength: 750,
|
|
14
|
+
validation: {
|
|
15
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "number",
|
|
20
|
+
type: "text",
|
|
21
|
+
label: "country-forms.address.number.label",
|
|
22
|
+
required: true,
|
|
23
|
+
inputMode: "text",
|
|
24
|
+
maxLength: 10,
|
|
25
|
+
validation: {
|
|
26
|
+
maxLength: { value: 10, message: "country-forms.validation.maxLength" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "complement",
|
|
31
|
+
type: "text",
|
|
32
|
+
label: "country-forms.address.complement.label",
|
|
33
|
+
required: false,
|
|
34
|
+
inputMode: "text",
|
|
35
|
+
maxLength: 750,
|
|
36
|
+
validation: {
|
|
37
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "neighborhood",
|
|
42
|
+
type: "text",
|
|
43
|
+
label: "country-forms.address.neighborhood.label",
|
|
44
|
+
required: true,
|
|
45
|
+
inputMode: "text",
|
|
46
|
+
maxLength: 100,
|
|
47
|
+
validation: {
|
|
48
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
49
|
+
}
|
|
50
|
+
},
|
|
51
|
+
{
|
|
52
|
+
name: "city",
|
|
53
|
+
type: "text",
|
|
54
|
+
label: "country-forms.address.city.label",
|
|
55
|
+
required: true,
|
|
56
|
+
inputMode: "text",
|
|
57
|
+
maxLength: 100,
|
|
58
|
+
validation: {
|
|
59
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
{
|
|
63
|
+
name: "state",
|
|
64
|
+
type: "select",
|
|
65
|
+
label: "country-forms.address.state.label",
|
|
66
|
+
required: true,
|
|
67
|
+
options: "MEX.states"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
name: "postalCode",
|
|
71
|
+
type: "text",
|
|
72
|
+
label: "country-forms.address.postalCode.label",
|
|
73
|
+
placeholder: "country-forms.address.postalCode.placeholder.MEX",
|
|
74
|
+
required: true,
|
|
75
|
+
inputMode: "numeric",
|
|
76
|
+
maxLength: 5,
|
|
77
|
+
validation: {
|
|
78
|
+
customValidator: "validatePostalCodeMEX"
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
]
|
|
82
|
+
};
|
|
83
|
+
var MEX_default = schema;
|
|
84
|
+
|
|
85
|
+
export { MEX_default as default };
|
|
86
|
+
//# sourceMappingURL=MEX-QFS4JTN6.mjs.map
|
|
87
|
+
//# sourceMappingURL=MEX-QFS4JTN6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/MEX.ts"],"names":[],"mappings":";AAcA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI,aAAA;AAAA,EACJ,OAAA,EAAS,KAAA;AAAA,EACT,QA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AAA,EAAM,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,kCAAA;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,OAAA;AAAA,MACN,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,mCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,KACX;AAAA,IACA;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,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"MEX-QFS4JTN6.mjs","sourcesContent":["/**\n * Address schema for Mexico (MEX).\n *\n * Field order: street → number → neighborhood → city → state → postalCode\n *\n * Postal code: Código Postal (5 digits, e.g. `\"06600\"`), validated by `validatePostalCodeMEX`.\n * No mask is applied — the raw value is always 5 digits with no formatting.\n * Subdivision: 32 states — options ref `\"MEX.states\"`.\n * Neighborhood (Colonia) is optional.\n *\n * Required rule modules: `rules/validators/mex`, `rules/options/mex-states`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-MEX',\n country: 'MEX',\n formType: 'address',\n fields: [\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 },\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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'MEX.states',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.MEX',\n required: true,\n inputMode: 'numeric',\n maxLength: 5,\n validation: {\n customValidator: 'validatePostalCodeMEX',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
// src/schemas/address/USA.ts
|
|
2
|
+
var schema = {
|
|
3
|
+
id: "address-USA",
|
|
4
|
+
country: "USA",
|
|
5
|
+
formType: "address",
|
|
6
|
+
fields: [
|
|
7
|
+
{
|
|
8
|
+
name: "street",
|
|
9
|
+
type: "text",
|
|
10
|
+
label: "country-forms.address.street.label",
|
|
11
|
+
required: true,
|
|
12
|
+
inputMode: "text",
|
|
13
|
+
maxLength: 750,
|
|
14
|
+
validation: {
|
|
15
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
{
|
|
19
|
+
name: "complement",
|
|
20
|
+
type: "text",
|
|
21
|
+
label: "country-forms.address.complement.label",
|
|
22
|
+
required: false,
|
|
23
|
+
inputMode: "text",
|
|
24
|
+
maxLength: 750,
|
|
25
|
+
validation: {
|
|
26
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
{
|
|
30
|
+
name: "city",
|
|
31
|
+
type: "text",
|
|
32
|
+
label: "country-forms.address.city.label",
|
|
33
|
+
required: true,
|
|
34
|
+
inputMode: "text",
|
|
35
|
+
maxLength: 100,
|
|
36
|
+
validation: {
|
|
37
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
38
|
+
}
|
|
39
|
+
},
|
|
40
|
+
{
|
|
41
|
+
name: "state",
|
|
42
|
+
type: "select",
|
|
43
|
+
label: "country-forms.address.state.label",
|
|
44
|
+
required: true,
|
|
45
|
+
options: "USA.states"
|
|
46
|
+
},
|
|
47
|
+
{
|
|
48
|
+
name: "postalCode",
|
|
49
|
+
type: "text",
|
|
50
|
+
label: "country-forms.address.postalCode.label",
|
|
51
|
+
placeholder: "country-forms.address.postalCode.placeholder.USA",
|
|
52
|
+
required: true,
|
|
53
|
+
inputMode: "numeric",
|
|
54
|
+
maxLength: 10,
|
|
55
|
+
formatRef: "formatZIP",
|
|
56
|
+
unformatRef: "unformatZIP",
|
|
57
|
+
validation: {
|
|
58
|
+
customValidator: "validateZIP"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
61
|
+
]
|
|
62
|
+
};
|
|
63
|
+
var USA_default = schema;
|
|
64
|
+
|
|
65
|
+
export { USA_default as default };
|
|
66
|
+
//# sourceMappingURL=USA-E5AZRBXA.mjs.map
|
|
67
|
+
//# sourceMappingURL=USA-E5AZRBXA.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/USA.ts"],"names":[],"mappings":";AAaA,IAAM,MAAA,GAAS;AAAA,EACb,EAAA,EAAI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,MACP,WAAA,EAAa,kDAAA;AAAA,MACb,QAAA,EAAU,IAAA;AAAA,MACV,SAAA,EAAW,SAAA;AAAA,MACX,SAAA,EAAW,EAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"USA-E5AZRBXA.mjs","sourcesContent":["/**\n * Address schema for United States (USA).\n *\n * Field order: address1 → address2 → city → state → postalCode\n *\n * Postal code: ZIP (99999) or ZIP+4 (99999-9999), validated by `validateZIP`,\n * masked by `formatZIP`/`unformatZIP`.\n * Subdivision: 50 states + DC — options ref `\"USA.states\"`.\n *\n * Required rule modules: `rules/validators/usa`, `rules/masks/usa`, `rules/options/usa-states`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-USA',\n country: 'USA',\n formType: 'address',\n fields: [\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: '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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'USA.states',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.USA',\n required: true,\n inputMode: 'numeric',\n maxLength: 10,\n formatRef: 'formatZIP',\n unformatRef: 'unformatZIP',\n validation: {\n customValidator: 'validateZIP',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
// src/schemas/address/USA.ts
|
|
4
|
+
var schema = {
|
|
5
|
+
id: "address-USA",
|
|
6
|
+
country: "USA",
|
|
7
|
+
formType: "address",
|
|
8
|
+
fields: [
|
|
9
|
+
{
|
|
10
|
+
name: "street",
|
|
11
|
+
type: "text",
|
|
12
|
+
label: "country-forms.address.street.label",
|
|
13
|
+
required: true,
|
|
14
|
+
inputMode: "text",
|
|
15
|
+
maxLength: 750,
|
|
16
|
+
validation: {
|
|
17
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
{
|
|
21
|
+
name: "complement",
|
|
22
|
+
type: "text",
|
|
23
|
+
label: "country-forms.address.complement.label",
|
|
24
|
+
required: false,
|
|
25
|
+
inputMode: "text",
|
|
26
|
+
maxLength: 750,
|
|
27
|
+
validation: {
|
|
28
|
+
maxLength: { value: 750, message: "country-forms.validation.maxLength" }
|
|
29
|
+
}
|
|
30
|
+
},
|
|
31
|
+
{
|
|
32
|
+
name: "city",
|
|
33
|
+
type: "text",
|
|
34
|
+
label: "country-forms.address.city.label",
|
|
35
|
+
required: true,
|
|
36
|
+
inputMode: "text",
|
|
37
|
+
maxLength: 100,
|
|
38
|
+
validation: {
|
|
39
|
+
maxLength: { value: 100, message: "country-forms.validation.maxLength" }
|
|
40
|
+
}
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
name: "state",
|
|
44
|
+
type: "select",
|
|
45
|
+
label: "country-forms.address.state.label",
|
|
46
|
+
required: true,
|
|
47
|
+
options: "USA.states"
|
|
48
|
+
},
|
|
49
|
+
{
|
|
50
|
+
name: "postalCode",
|
|
51
|
+
type: "text",
|
|
52
|
+
label: "country-forms.address.postalCode.label",
|
|
53
|
+
placeholder: "country-forms.address.postalCode.placeholder.USA",
|
|
54
|
+
required: true,
|
|
55
|
+
inputMode: "numeric",
|
|
56
|
+
maxLength: 10,
|
|
57
|
+
formatRef: "formatZIP",
|
|
58
|
+
unformatRef: "unformatZIP",
|
|
59
|
+
validation: {
|
|
60
|
+
customValidator: "validateZIP"
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
]
|
|
64
|
+
};
|
|
65
|
+
var USA_default = schema;
|
|
66
|
+
|
|
67
|
+
module.exports = USA_default;
|
|
68
|
+
//# sourceMappingURL=USA-UBWW5NQB.js.map
|
|
69
|
+
//# sourceMappingURL=USA-UBWW5NQB.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/schemas/address/USA.ts"],"names":[],"mappings":";;;AAaA,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,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,YAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,wCAAA;AAAA,MACP,QAAA,EAAU,KAAA;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,MAAA;AAAA,MACN,IAAA,EAAM,MAAA;AAAA,MACN,KAAA,EAAO,kCAAA;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,OAAA;AAAA,MACN,IAAA,EAAM,QAAA;AAAA,MACN,KAAA,EAAO,mCAAA;AAAA,MACP,QAAA,EAAU,IAAA;AAAA,MACV,OAAA,EAAS;AAAA,KACX;AAAA,IACA;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,EAAA;AAAA,MACX,SAAA,EAAW,WAAA;AAAA,MACX,WAAA,EAAa,aAAA;AAAA,MACb,UAAA,EAAY;AAAA,QACV,eAAA,EAAiB;AAAA;AACnB;AACF;AAEJ,CAAA;AAEA,IAAO,WAAA,GAAQ","file":"USA-UBWW5NQB.js","sourcesContent":["/**\n * Address schema for United States (USA).\n *\n * Field order: address1 → address2 → city → state → postalCode\n *\n * Postal code: ZIP (99999) or ZIP+4 (99999-9999), validated by `validateZIP`,\n * masked by `formatZIP`/`unformatZIP`.\n * Subdivision: 50 states + DC — options ref `\"USA.states\"`.\n *\n * Required rule modules: `rules/validators/usa`, `rules/masks/usa`, `rules/options/usa-states`\n */\nimport type { FormSchema } from '../../types'\n\nconst schema = {\n id: 'address-USA',\n country: 'USA',\n formType: 'address',\n fields: [\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: '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: 'city',\n type: 'text',\n label: 'country-forms.address.city.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: 'USA.states',\n },\n {\n name: 'postalCode',\n type: 'text',\n label: 'country-forms.address.postalCode.label',\n placeholder: 'country-forms.address.postalCode.placeholder.USA',\n required: true,\n inputMode: 'numeric',\n maxLength: 10,\n formatRef: 'formatZIP',\n unformatRef: 'unformatZIP',\n validation: {\n customValidator: 'validateZIP',\n },\n },\n ],\n} satisfies FormSchema\n\nexport default schema\n"]}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { registerMask } from './chunk-BMZHOWIP.mjs';
|
|
2
|
+
|
|
3
|
+
// src/rules/masks/bra.ts
|
|
4
|
+
function formatCEP(value) {
|
|
5
|
+
const digits = value.replace(/\D/g, "").slice(0, 8);
|
|
6
|
+
if (digits.length < 8) return digits;
|
|
7
|
+
return `${digits.slice(0, 5)}-${digits.slice(5)}`;
|
|
8
|
+
}
|
|
9
|
+
function unformatCEP(value) {
|
|
10
|
+
return value.replace(/\D/g, "");
|
|
11
|
+
}
|
|
12
|
+
function formatPhoneBRA(value) {
|
|
13
|
+
const phone = value.replace(/\D/g, "").slice(0, 11);
|
|
14
|
+
if (phone.length !== 10 && phone.length !== 11) return phone;
|
|
15
|
+
const splitAt = phone.length === 11 ? 7 : 6;
|
|
16
|
+
return `(${phone.slice(0, 2)}) ${phone.slice(2, splitAt)}-${phone.slice(splitAt)}`;
|
|
17
|
+
}
|
|
18
|
+
function unformatPhoneBRA(value) {
|
|
19
|
+
const phoneCountryCode = "55";
|
|
20
|
+
const minLocalLength = 10;
|
|
21
|
+
let phone = value.replace(/\D/g, "");
|
|
22
|
+
if (phone.startsWith(phoneCountryCode) && phone.length - phoneCountryCode.length >= minLocalLength) {
|
|
23
|
+
phone = phone.slice(phoneCountryCode.length);
|
|
24
|
+
}
|
|
25
|
+
if (phone.startsWith("0")) {
|
|
26
|
+
phone = phone.slice(1);
|
|
27
|
+
}
|
|
28
|
+
return phone;
|
|
29
|
+
}
|
|
30
|
+
function formatCPF(value) {
|
|
31
|
+
const digits = value.replace(/\D/g, "").slice(0, 11);
|
|
32
|
+
if (digits.length !== 11) return digits;
|
|
33
|
+
return `${digits.slice(0, 3)}.${digits.slice(3, 6)}.${digits.slice(6, 9)}-${digits.slice(9)}`;
|
|
34
|
+
}
|
|
35
|
+
function unformatCPF(value) {
|
|
36
|
+
return value.replace(/\D/g, "");
|
|
37
|
+
}
|
|
38
|
+
function formatCNPJ(value) {
|
|
39
|
+
const cleaned = value.toUpperCase().replace(/[^A-Z0-9]/g, "").slice(0, 14);
|
|
40
|
+
if (cleaned.length !== 14) return cleaned;
|
|
41
|
+
return `${cleaned.slice(0, 2)}.${cleaned.slice(2, 5)}.${cleaned.slice(5, 8)}/${cleaned.slice(8, 12)}-${cleaned.slice(12)}`;
|
|
42
|
+
}
|
|
43
|
+
function unformatCNPJ(value) {
|
|
44
|
+
return value.toUpperCase().replace(/[^A-Z0-9]/g, "");
|
|
45
|
+
}
|
|
46
|
+
registerMask("formatCEP", formatCEP);
|
|
47
|
+
registerMask("unformatCEP", unformatCEP);
|
|
48
|
+
registerMask("formatPhoneBRA", formatPhoneBRA);
|
|
49
|
+
registerMask("unformatPhoneBRA", unformatPhoneBRA);
|
|
50
|
+
registerMask("formatCPF", formatCPF);
|
|
51
|
+
registerMask("unformatCPF", unformatCPF);
|
|
52
|
+
registerMask("formatCNPJ", formatCNPJ);
|
|
53
|
+
registerMask("unformatCNPJ", unformatCNPJ);
|
|
54
|
+
|
|
55
|
+
export { formatCEP, formatCNPJ, formatCPF, formatPhoneBRA, unformatCEP, unformatCNPJ, unformatCPF, unformatPhoneBRA };
|
|
56
|
+
//# sourceMappingURL=bra-I5DOHE34.mjs.map
|
|
57
|
+
//# sourceMappingURL=bra-I5DOHE34.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/rules/masks/bra.ts"],"names":[],"mappings":";;;AAyBO,SAAS,UAAU,KAAA,EAAuB;AAC/C,EAAA,MAAM,MAAA,GAAS,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CAAE,KAAA,CAAM,GAAG,CAAC,CAAA;AAClD,EAAA,IAAI,MAAA,CAAO,MAAA,GAAS,CAAA,EAAG,OAAO,MAAA;AAC9B,EAAA,OAAO,CAAA,EAAG,MAAA,CAAO,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,MAAA,CAAO,KAAA,CAAM,CAAC,CAAC,CAAA,CAAA;AACjD;AAQO,SAAS,YAAY,KAAA,EAAuB;AACjD,EAAA,OAAO,KAAA,CAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA;AAChC;AAmBO,SAAS,eAAe,KAAA,EAAuB;AACpD,EAAA,MAAM,KAAA,GAAQ,MAAM,OAAA,CAAQ,KAAA,EAAO,EAAE,CAAA,CAAE,KAAA,CAAM,GAAG,EAAE,CAAA;AAClD,EAAA,IAAI,MAAM,MAAA,KAAW,EAAA,IAAM,KAAA,CAAM,MAAA,KAAW,IAAI,OAAO,KAAA;AACvD,EAAA,MAAM,OAAA,GAAU,KAAA,CAAM,MAAA,KAAW,EAAA,GAAK,CAAA,GAAI,CAAA;AAC1C,EAAA,OAAO,IAAI,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,EAAA,EAAK,KAAA,CAAM,KAAA,CAAM,CAAA,EAAG,OAAO,CAAC,CAAA,CAAA,EAAI,KAAA,CAAM,KAAA,CAAM,OAAO,CAAC,CAAA,CAAA;AACl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,cAAc,EAAE,CAAA,CAAE,KAAA,CAAM,CAAA,EAAG,EAAE,CAAA;AACzE,EAAA,IAAI,OAAA,CAAQ,MAAA,KAAW,EAAA,EAAI,OAAO,OAAA;AAClC,EAAA,OAAO,CAAA,EAAG,OAAA,CAAQ,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,OAAA,CAAQ,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,OAAA,CAAQ,KAAA,CAAM,CAAA,EAAG,CAAC,CAAC,CAAA,CAAA,EAAI,OAAA,CAAQ,KAAA,CAAM,CAAA,EAAG,EAAE,CAAC,CAAA,CAAA,EAAI,OAAA,CAAQ,KAAA,CAAM,EAAE,CAAC,CAAA,CAAA;AAC1H;AAcO,SAAS,aAAa,KAAA,EAAuB;AAClD,EAAA,OAAO,KAAA,CAAM,WAAA,EAAY,CAAE,OAAA,CAAQ,cAAc,EAAE,CAAA;AACrD;AAIA,YAAA,CAAa,aAAa,SAAS,CAAA;AACnC,YAAA,CAAa,eAAe,WAAW,CAAA;AACvC,YAAA,CAAa,kBAAkB,cAAc,CAAA;AAC7C,YAAA,CAAa,oBAAoB,gBAAgB,CAAA;AACjD,YAAA,CAAa,aAAa,SAAS,CAAA;AACnC,YAAA,CAAa,eAAe,WAAW,CAAA;AACvC,YAAA,CAAa,cAAc,UAAU,CAAA;AACrC,YAAA,CAAa,gBAAgB,YAAY,CAAA","file":"bra-I5DOHE34.mjs","sourcesContent":["/**\n * @module rules/masks/bra\n *\n * Format and unformat functions for Brazilian address and personal-data fields.\n * Importing this module registers all masks in the shared registry.\n *\n * Registered refs:\n * - `\"formatCEP\"` / `\"unformatCEP\"` — CEP postal code (99999-999)\n * - `\"formatPhoneBRA\"` / `\"unformatPhoneBRA\"` — Brazilian phone ((99) 99999-9999 mobile / (99) 9999-9999 landline)\n * - `\"formatCPF\"` / `\"unformatCPF\"` — CPF individual ID (999.999.999-99)\n * - `\"formatCNPJ\"` / `\"unformatCNPJ\"` — CNPJ company ID, numeric or alphanumeric (XX.XXX.XXX/XXXX-DD)\n */\n\nimport { registerMask } from './index'\n\n// ── CEP ───────────────────────────────────────────────────────────────────────\n\n/**\n * `\"01310100\"` → `\"01310-100\"`\n *\n * Truncates to at most 8 digits before formatting.\n *\n * @param value - Raw CEP string (e.g. `\"01310100\"`)\n * @returns Formatted CEP with hyphen (e.g. `\"01310-100\"`)\n */\nexport function formatCEP(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 8)\n if (digits.length < 8) return digits\n return `${digits.slice(0, 5)}-${digits.slice(5)}`\n}\n\n/**\n * `\"01310-100\"` → `\"01310100\"`\n *\n * @param value - Formatted CEP string\n * @returns Raw digits only\n */\nexport function unformatCEP(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── Phone ──────────────────────────────────────────────────────────────────────\n\n/**\n * Formats a raw Brazilian phone string for display.\n *\n * - 11-digit mobile: `\"11999998888\"` → `\"(11) 99999-8888\"`\n * - 10-digit landline: `\"1133339999\"` → `\"(11) 3333-9999\"`\n *\n * The DDD occupies the first 2 digits. The split position differs by length:\n * mobile (11 digits) splits at position 7 → 5+4; landline (10 digits) splits\n * at position 6 → 4+4. Inputs shorter than 10 digits are returned as-is\n * (partial input during typing). Inputs are truncated to at most 11 digits\n * before formatting.\n *\n * @param value - Raw or partially formatted Brazilian phone string\n * @returns Display string in `(DD) XXXXX-XXXX` (mobile) or `(DD) XXXX-XXXX` (landline) format\n */\nexport function formatPhoneBRA(value: string): string {\n const phone = value.replace(/\\D/g, '').slice(0, 11)\n if (phone.length !== 10 && phone.length !== 11) return phone\n const splitAt = phone.length === 11 ? 7 : 6\n return `(${phone.slice(0, 2)}) ${phone.slice(2, splitAt)}-${phone.slice(splitAt)}`\n}\n\n/**\n * `\"(11) 99999-8888\"` → `\"11999998888\"` (mobile) / `\"(11) 3333-9999\"` → `\"1133339999\"` (landline)\n *\n * Strips all non-digit characters. A leading trunk prefix `\"0\"` is always\n * stripped. A leading country code `\"55\"` is stripped **only when the\n * remainder still has at least 10 digits** (the minimum length of a valid\n * local Brazilian phone: 2-digit DDD + 8-digit landline). This prevents\n * wrongly stripping the DDD itself for area codes that start with `55` —\n * notably **DDD 55** (Santa Maria/RS and surrounding RS-noroeste region:\n * Cruz Alta, Santo Ângelo, Santa Rosa, etc.).\n *\n * Why the length guard works:\n * - Local number (DDD 55 as DDD): 10 or 11 digits total → after attempting\n * strip: 8 or 9 digits < 10 → do NOT strip.\n * - International prefix + DDD: 12 or 13 digits total → remainder: 10 or 11\n * digits ≥ 10 → strip.\n *\n * The trunk-prefix strip is unconditional because no valid DDD starts with `0`\n * (DDDs run 11–99), so a leading `0` is unambiguously a trunk prefix.\n *\n * @param value - Display-formatted Brazilian phone string\n * @returns Raw digit-only string without country code or trunk prefix\n */\nexport function unformatPhoneBRA(value: string): string {\n const phoneCountryCode = '55'\n const minLocalLength = 10\n let phone = value.replace(/\\D/g, '')\n if (\n phone.startsWith(phoneCountryCode) &&\n phone.length - phoneCountryCode.length >= minLocalLength\n ) {\n phone = phone.slice(phoneCountryCode.length)\n }\n if (phone.startsWith('0')) {\n phone = phone.slice(1)\n }\n return phone\n}\n\n// ── CPF ───────────────────────────────────────────────────────────────────────\n\n/**\n * `\"12345678909\"` → `\"123.456.789-09\"`\n *\n * Truncates to at most 11 digits before formatting.\n * Returns the digits-only string unchanged when fewer than 11 digits are present.\n *\n * @param value - Raw or partially formatted CPF string\n * @returns Display string in `999.999.999-99` format\n */\nexport function formatCPF(value: string): string {\n const digits = value.replace(/\\D/g, '').slice(0, 11)\n if (digits.length !== 11) return digits\n return `${digits.slice(0, 3)}.${digits.slice(3, 6)}.${digits.slice(6, 9)}-${digits.slice(9)}`\n}\n\n/**\n * `\"123.456.789-09\"` → `\"12345678909\"`\n *\n * @param value - Display-formatted CPF string\n * @returns Raw digit-only string suitable for API submission\n */\nexport function unformatCPF(value: string): string {\n return value.replace(/\\D/g, '')\n}\n\n// ── CNPJ ──────────────────────────────────────────────────────────────────────\n\n/**\n * `\"11222333000181\"` → `\"11.222.333/0001-81\"`\n *\n * `\"12ABC34501DE35\"` → `\"12.ABC.345/01DE-35\"`\n *\n * Supports both the legacy numeric CNPJ and the new alphanumeric format\n * (SERPRO/Receita Federal, IN RFB 2.229/2024). Lowercase letters are\n * normalized to uppercase. Truncates to at most 14 alphanumeric characters\n * before formatting. Returns the cleaned string unchanged when fewer than\n * 14 characters are present.\n *\n * @param value - Raw or partially formatted CNPJ (numeric or alphanumeric)\n * @returns Display string in `XX.XXX.XXX/XXXX-DD` format (`X` = `[A-Z0-9]`, `D` = `[0-9]`)\n */\nexport function formatCNPJ(value: string): string {\n const cleaned = value.toUpperCase().replace(/[^A-Z0-9]/g, '').slice(0, 14)\n if (cleaned.length !== 14) return cleaned\n return `${cleaned.slice(0, 2)}.${cleaned.slice(2, 5)}.${cleaned.slice(5, 8)}/${cleaned.slice(8, 12)}-${cleaned.slice(12)}`\n}\n\n/**\n * `\"11.222.333/0001-81\"` → `\"11222333000181\"`\n *\n * `\"12.ABC.345/01DE-35\"` → `\"12ABC34501DE35\"`\n *\n * Strips formatting separators (`.`, `/`, `-`, whitespace) while preserving\n * alphanumeric characters. Lowercase letters are normalized to uppercase so\n * the round-trip with `formatCNPJ` is canonical.\n *\n * @param value - Display-formatted CNPJ string (numeric or alphanumeric)\n * @returns Raw alphanumeric string suitable for API submission\n */\nexport function unformatCNPJ(value: string): string {\n return value.toUpperCase().replace(/[^A-Z0-9]/g, '')\n}\n\n// ── Registration ──────────────────────────────────────────────────────────────\n\nregisterMask('formatCEP', formatCEP)\nregisterMask('unformatCEP', unformatCEP)\nregisterMask('formatPhoneBRA', formatPhoneBRA)\nregisterMask('unformatPhoneBRA', unformatPhoneBRA)\nregisterMask('formatCPF', formatCPF)\nregisterMask('unformatCPF', unformatCPF)\nregisterMask('formatCNPJ', formatCNPJ)\nregisterMask('unformatCNPJ', unformatCNPJ)\n"]}
|