Skip to content

Commit

Permalink
add new rule
Browse files Browse the repository at this point in the history
  • Loading branch information
beatrizmaselli committed Jul 12, 2024
1 parent c1afd3c commit f1497e5
Show file tree
Hide file tree
Showing 8 changed files with 329 additions and 3 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions react/country/GBR.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
postalCodeAPI: false,
size: 'small',
autoComplete: 'nope',
autoUpperCase: true,
},
{
name: 'street',
Expand Down
156 changes: 156 additions & 0 deletions react/country/GIB.js
Original file line number Diff line number Diff line change
@@ -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',
},
],
],
}
1 change: 1 addition & 0 deletions react/country/IRL.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default {
postalCodeAPI: true,
size: 'small',
autoComplete: 'nope',
autoUpperCase: true,
},
{
name: 'street',
Expand Down
156 changes: 156 additions & 0 deletions react/country/LTU.js
Original file line number Diff line number Diff line change
@@ -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',
},
],
],
}
5 changes: 3 additions & 2 deletions react/country/MLT.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
postalCodeAPI: false,
size: 'small',
autoComplete: 'nope',
autoUpperCase: true,
},
{
name: 'street',
Expand Down Expand Up @@ -139,8 +140,8 @@ export default {
'Żebbuġ (Zebbug)',
'Zebbug (Zebbug-Gozo)',
'Zejtun (Zejtun)',
'Zurrieq (Zurrieq)'
],
'Zurrieq (Zurrieq)',
],
},
{
name: 'receiverName',
Expand Down
1 change: 1 addition & 0 deletions react/country/NLD.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ export default {
postalCodeAPI: false,
size: 'small',
autoComplete: 'nope',
autoUpperCase: true,
},
{
name: 'street',
Expand Down
9 changes: 8 additions & 1 deletion react/inputs/StyleguideInput/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down

0 comments on commit f1497e5

Please sign in to comment.