@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
package/dist/index.d.ts
CHANGED
|
@@ -375,12 +375,31 @@ type I18nBundle = Record<string, string>;
|
|
|
375
375
|
* resolveLabel('country-forms.address.postalCode.label', bundle, overrides)
|
|
376
376
|
*/
|
|
377
377
|
type I18nOverrides = Record<string, string>;
|
|
378
|
+
/**
|
|
379
|
+
* Interpolation parameters for `resolveLabel`.
|
|
380
|
+
*
|
|
381
|
+
* Each entry replaces every `{key}` placeholder in the resolved message with
|
|
382
|
+
* the provided value. Numeric values are coerced via `String(value)`. Missing
|
|
383
|
+
* placeholders (i.e. a `{key}` appears in the message but no entry exists in
|
|
384
|
+
* `params`) are intentionally left untouched so the gap is visible at runtime.
|
|
385
|
+
*
|
|
386
|
+
* @example
|
|
387
|
+
* resolveLabel(
|
|
388
|
+
* 'country-forms.validation.maxLength',
|
|
389
|
+
* bundle,
|
|
390
|
+
* undefined,
|
|
391
|
+
* { fieldName: 'CEP', maxLength: 9 },
|
|
392
|
+
* )
|
|
393
|
+
* // bundle: "{fieldName} deve ter até {maxLength} caracteres"
|
|
394
|
+
* // → "CEP deve ter até 9 caracteres"
|
|
395
|
+
*/
|
|
396
|
+
type I18nParams = Record<string, string | number>;
|
|
378
397
|
|
|
379
398
|
/**
|
|
380
399
|
* A synchronous field validator function.
|
|
381
400
|
*
|
|
382
401
|
* - Returns `true` when the value is valid.
|
|
383
|
-
* - Returns an **i18n key** string (e.g. `"country-forms.validation.
|
|
402
|
+
* - Returns an **i18n key** string (e.g. `"country-forms.validation.invalid"`) when invalid.
|
|
384
403
|
* The engine passes this key to the error map; consumers resolve it via `resolveLabel`.
|
|
385
404
|
*
|
|
386
405
|
* Validators must be **pure** and **synchronous**.
|
|
@@ -779,7 +798,10 @@ declare function loadLocale(locale: string): Promise<I18nBundle>;
|
|
|
779
798
|
/**
|
|
780
799
|
* @module i18n/resolveLabel
|
|
781
800
|
*
|
|
782
|
-
* Resolves an i18n key to its display string using a three-level cascade
|
|
801
|
+
* Resolves an i18n key to its display string using a three-level cascade and,
|
|
802
|
+
* optionally, interpolates `{name}` placeholders found in the resolved string.
|
|
803
|
+
*
|
|
804
|
+
* ## Cascade
|
|
783
805
|
*
|
|
784
806
|
* 1. **Consumer override** — `overrides[key]` wins if present.
|
|
785
807
|
* 2. **Bundle value** — `bundle[key]` from `loadLocale()`.
|
|
@@ -789,10 +811,22 @@ declare function loadLocale(locale: string): Promise<I18nBundle>;
|
|
|
789
811
|
* This design lets consumers customize individual labels without forking the
|
|
790
812
|
* library or replacing the entire bundle.
|
|
791
813
|
*
|
|
814
|
+
* ## Interpolation
|
|
815
|
+
*
|
|
816
|
+
* When `params` is provided, every `{name}` placeholder in the resolved string
|
|
817
|
+
* is replaced with `String(params[name])`. Replacement is **global** — the same
|
|
818
|
+
* placeholder may appear more than once in a message and is replaced everywhere
|
|
819
|
+
* it occurs. Placeholders without a matching `params` entry are left untouched
|
|
820
|
+
* so unfulfilled substitutions remain visible to developers.
|
|
821
|
+
*
|
|
822
|
+
* Interpolation is applied after the cascade, so it works equally for override
|
|
823
|
+
* strings, bundle strings, and the raw-key fallback.
|
|
824
|
+
*
|
|
792
825
|
* @param key - i18n key (e.g. `"country-forms.address.postalCode.label"`)
|
|
793
826
|
* @param bundle - Locale bundle loaded via `loadLocale()`
|
|
794
827
|
* @param overrides - Optional consumer-supplied overrides
|
|
795
|
-
* @
|
|
828
|
+
* @param params - Optional interpolation parameters for `{name}` placeholders
|
|
829
|
+
* @returns Resolved (and optionally interpolated) display string
|
|
796
830
|
*
|
|
797
831
|
* @example
|
|
798
832
|
* const bundle = await loadLocale('pt-BR')
|
|
@@ -807,9 +841,20 @@ declare function loadLocale(locale: string): Promise<I18nBundle>;
|
|
|
807
841
|
* @example
|
|
808
842
|
* resolveLabel('country-forms.unknown.key', bundle)
|
|
809
843
|
* // → "country-forms.unknown.key" (raw key fallback)
|
|
844
|
+
*
|
|
845
|
+
* @example
|
|
846
|
+
* // bundle: { 'country-forms.validation.maxLength':
|
|
847
|
+
* // '{fieldName} deve ter até {maxLength} caracteres' }
|
|
848
|
+
* resolveLabel(
|
|
849
|
+
* 'country-forms.validation.maxLength',
|
|
850
|
+
* bundle,
|
|
851
|
+
* undefined,
|
|
852
|
+
* { fieldName: 'CEP', maxLength: 9 },
|
|
853
|
+
* )
|
|
854
|
+
* // → "CEP deve ter até 9 caracteres"
|
|
810
855
|
*/
|
|
811
856
|
|
|
812
|
-
declare function resolveLabel(key: string, bundle: I18nBundle, overrides?: I18nOverrides): string;
|
|
857
|
+
declare function resolveLabel(key: string, bundle: I18nBundle, overrides?: I18nOverrides, params?: I18nParams): string;
|
|
813
858
|
|
|
814
859
|
/**
|
|
815
860
|
* BCP 47 locale tags supported by the library's built-in translation bundles.
|
|
@@ -830,4 +875,4 @@ declare const SUPPORTED_LOCALES: readonly ["en-US", "es-MX", "fr-FR", "pt-BR"];
|
|
|
830
875
|
/** Union of BCP 47 tags with dedicated built-in bundles. */
|
|
831
876
|
type SupportedLocale = (typeof SUPPORTED_LOCALES)[number];
|
|
832
877
|
|
|
833
|
-
export { type ConditionalOperator, type ConditionalVisibility, type FieldDefinition, type FieldType, type FormErrors, type FormSchema, type FormState, type FormType, type FormValues, type FormatFn, type I18nBundle, type I18nOverrides, type InputMode, SUPPORTED_ADDRESS_COUNTRIES, SUPPORTED_LOCALES, SUPPORTED_PERSONAL_DATA_COUNTRIES, type SelectOption, type SupportedLocale, type UnformatFn, type ValidationErrors, type ValidationRules, type ValidatorFn, createFormState, formatValue, getVisibleFields, loadLocale, loadSchema, resolveFieldOptions, resolveLabel, setValue, unformatValue, validate };
|
|
878
|
+
export { type ConditionalOperator, type ConditionalVisibility, type FieldDefinition, type FieldType, type FormErrors, type FormSchema, type FormState, type FormType, type FormValues, type FormatFn, type I18nBundle, type I18nOverrides, type I18nParams, type InputMode, SUPPORTED_ADDRESS_COUNTRIES, SUPPORTED_LOCALES, SUPPORTED_PERSONAL_DATA_COUNTRIES, type SelectOption, type SupportedLocale, type UnformatFn, type ValidationErrors, type ValidationRules, type ValidatorFn, createFormState, formatValue, getVisibleFields, loadLocale, loadSchema, resolveFieldOptions, resolveLabel, setValue, unformatValue, validate };
|