diff --git a/CHANGELOG.md b/CHANGELOG.md index 87d865f6..e94934e5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -7,6 +7,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0. ## [Unreleased] +### Added +- implemented autoUpperCase rule for countries with alphanumeric postal codes, ensuring consistent uppercase formatting. + ## [4.24.5] - 2024-07-05 ### Fixed diff --git a/react/country/GBR.js b/react/country/GBR.js index bfc15064..9923fc3f 100644 --- a/react/country/GBR.js +++ b/react/country/GBR.js @@ -22,6 +22,7 @@ export default { postalCodeAPI: false, size: 'small', autoComplete: 'nope', + autoUpperCase: true, }, { name: 'street', diff --git a/react/country/GIB.js b/react/country/GIB.js new file mode 100644 index 00000000..c027ddc4 --- /dev/null +++ b/react/country/GIB.js @@ -0,0 +1,156 @@ +import { POSTAL_CODE } from '../constants' + +export default { + country: null, + abbr: null, + postalCodeFrom: POSTAL_CODE, + fields: [ + { + hidden: true, + name: 'country', + maxLength: 100, + label: 'country', + size: 'medium', + }, + { + name: 'postalCode', + maxLength: 50, + label: 'postalCode', + size: 'small', + autoComplete: 'nope', + postalCodeAPI: false, + autoUpperCase: true, + }, + { + name: 'street', + label: 'addressLine1', + required: true, + size: 'xlarge', + }, + { + hidden: true, + name: 'number', + maxLength: 750, + label: 'number', + size: 'small', + autoComplete: 'nope', + }, + { + name: 'complement', + maxLength: 750, + label: 'addressLine2', + size: 'xlarge', + }, + { + hidden: true, + name: 'reference', + maxLength: 750, + label: 'reference', + size: 'xlarge', + }, + { + hidden: true, + name: 'neighborhood', + maxLength: 100, + label: 'neighborhood', + size: 'large', + }, + { + name: 'city', + maxLength: 100, + label: 'city', + required: true, + size: 'large', + }, + { + name: 'state', + maxLength: 100, + label: 'state', + required: true, + size: 'large', + }, + { + name: 'receiverName', + elementName: 'receiver', + maxLength: 750, + label: 'receiverName', + size: 'xlarge', + required: true, + }, + ], + geolocation: { + postalCode: { + valueIn: 'long_name', + types: ['postal_code'], + required: false, + }, + + number: { + valueIn: 'long_name', + types: ['street_number'], + required: false, + notApplicable: true, + }, + + street: { valueIn: 'long_name', types: ['route'] }, + + neighborhood: { + valueIn: 'long_name', + types: [ + 'neighborhood', + 'sublocality_level_1', + 'sublocality_level_2', + 'sublocality_level_3', + 'sublocality_level_4', + 'sublocality_level_5', + ], + }, + + state: { + valueIn: 'long_name', + types: ['administrative_area_level_1'], + }, + + city: { + valueIn: 'long_name', + types: ['administrative_area_level_2', 'locality'], + }, + + receiverName: { + required: true, + }, + }, + summary: [ + [ + { + name: 'street', + }, + { + delimiter: ' ', + name: 'number', + }, + { + delimiter: ', ', + name: 'complement', + }, + ], + [ + { + name: 'neighborhood', + delimiterAfter: ' - ', + }, + { + name: 'city', + }, + { + delimiter: ' - ', + name: 'state', + }, + ], + [ + { + name: 'postalCode', + }, + ], + ], +} diff --git a/react/country/IRL.js b/react/country/IRL.js index 0cec0c0c..68ebb7f6 100644 --- a/react/country/IRL.js +++ b/react/country/IRL.js @@ -23,6 +23,7 @@ export default { postalCodeAPI: true, size: 'small', autoComplete: 'nope', + autoUpperCase: true, }, { name: 'street', diff --git a/react/country/LTU.js b/react/country/LTU.js new file mode 100644 index 00000000..c027ddc4 --- /dev/null +++ b/react/country/LTU.js @@ -0,0 +1,156 @@ +import { POSTAL_CODE } from '../constants' + +export default { + country: null, + abbr: null, + postalCodeFrom: POSTAL_CODE, + fields: [ + { + hidden: true, + name: 'country', + maxLength: 100, + label: 'country', + size: 'medium', + }, + { + name: 'postalCode', + maxLength: 50, + label: 'postalCode', + size: 'small', + autoComplete: 'nope', + postalCodeAPI: false, + autoUpperCase: true, + }, + { + name: 'street', + label: 'addressLine1', + required: true, + size: 'xlarge', + }, + { + hidden: true, + name: 'number', + maxLength: 750, + label: 'number', + size: 'small', + autoComplete: 'nope', + }, + { + name: 'complement', + maxLength: 750, + label: 'addressLine2', + size: 'xlarge', + }, + { + hidden: true, + name: 'reference', + maxLength: 750, + label: 'reference', + size: 'xlarge', + }, + { + hidden: true, + name: 'neighborhood', + maxLength: 100, + label: 'neighborhood', + size: 'large', + }, + { + name: 'city', + maxLength: 100, + label: 'city', + required: true, + size: 'large', + }, + { + name: 'state', + maxLength: 100, + label: 'state', + required: true, + size: 'large', + }, + { + name: 'receiverName', + elementName: 'receiver', + maxLength: 750, + label: 'receiverName', + size: 'xlarge', + required: true, + }, + ], + geolocation: { + postalCode: { + valueIn: 'long_name', + types: ['postal_code'], + required: false, + }, + + number: { + valueIn: 'long_name', + types: ['street_number'], + required: false, + notApplicable: true, + }, + + street: { valueIn: 'long_name', types: ['route'] }, + + neighborhood: { + valueIn: 'long_name', + types: [ + 'neighborhood', + 'sublocality_level_1', + 'sublocality_level_2', + 'sublocality_level_3', + 'sublocality_level_4', + 'sublocality_level_5', + ], + }, + + state: { + valueIn: 'long_name', + types: ['administrative_area_level_1'], + }, + + city: { + valueIn: 'long_name', + types: ['administrative_area_level_2', 'locality'], + }, + + receiverName: { + required: true, + }, + }, + summary: [ + [ + { + name: 'street', + }, + { + delimiter: ' ', + name: 'number', + }, + { + delimiter: ', ', + name: 'complement', + }, + ], + [ + { + name: 'neighborhood', + delimiterAfter: ' - ', + }, + { + name: 'city', + }, + { + delimiter: ' - ', + name: 'state', + }, + ], + [ + { + name: 'postalCode', + }, + ], + ], +} diff --git a/react/country/MLT.js b/react/country/MLT.js index 4aa0d352..25e34b43 100644 --- a/react/country/MLT.js +++ b/react/country/MLT.js @@ -22,6 +22,7 @@ export default { postalCodeAPI: false, size: 'small', autoComplete: 'nope', + autoUpperCase: true, }, { name: 'street', @@ -139,8 +140,8 @@ export default { 'Żebbuġ (Zebbug)', 'Zebbug (Zebbug-Gozo)', 'Zejtun (Zejtun)', - 'Zurrieq (Zurrieq)' - ], + 'Zurrieq (Zurrieq)', + ], }, { name: 'receiverName', diff --git a/react/country/NLD.js b/react/country/NLD.js index 55cb13e0..1624aa12 100644 --- a/react/country/NLD.js +++ b/react/country/NLD.js @@ -22,6 +22,7 @@ export default { postalCodeAPI: false, size: 'small', autoComplete: 'nope', + autoUpperCase: true, }, { name: 'street', diff --git a/react/inputs/StyleguideInput/index.js b/react/inputs/StyleguideInput/index.js index 1d370f7f..fca9d470 100644 --- a/react/inputs/StyleguideInput/index.js +++ b/react/inputs/StyleguideInput/index.js @@ -27,8 +27,15 @@ class StyleguideInput extends Component { } handleChange = (e) => { + const { field } = this.props + let { value } = e.target + + if (field.autoUpperCase === true) { + value = value.toUpperCase() + } + this.setState({ showErrorMessage: false }) - this.props.onChange && this.props.onChange(e.target.value) + this.props.onChange && this.props.onChange(value) } componentDidUpdate(prevProps) {