@bcrs-shared-components/base-address 2.0.55 → 2.0.57

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 (2) hide show
  1. package/BaseAddress.vue +18 -4
  2. package/package.json +3 -3
package/BaseAddress.vue CHANGED
@@ -73,7 +73,7 @@
73
73
  item-value="code"
74
74
  :items="getCountriesList()"
75
75
  :rules="[...rules.addressCountry, ...spaceRules]"
76
- @change="resetRegion()"
76
+ @change="onCountryChange()"
77
77
  />
78
78
  <!-- special field to select AddressComplete country, separate from our model field -->
79
79
  <input
@@ -149,6 +149,7 @@
149
149
  class="item postal-code"
150
150
  :label="postalCodeLabel"
151
151
  :rules="[...rules.postalCode, ...spaceRules]"
152
+ @input="addressLocal.postalCode = addressLocal.postalCode.toUpperCase()"
152
153
  />
153
154
  </div>
154
155
  <div class="form__row">
@@ -185,6 +186,11 @@ import { ValidationMixin, CountriesProvincesMixin } from '@bcrs-shared-component
185
186
  mixins: [ValidationMixin, CountriesProvincesMixin]
186
187
  })
187
188
  export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvincesMixin) {
189
+ // Refs
190
+ $refs!: {
191
+ addressForm: HTMLFormElement
192
+ }
193
+
188
194
  /**
189
195
  * The validation object used by Vuelidate to compute address model validity.
190
196
  * @returns the Vuelidate validations object
@@ -231,12 +237,16 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
231
237
  @Prop({ default: false })
232
238
  readonly isInactive: boolean
233
239
 
234
- resetRegion () {
240
+ /** When country changes, resets fields. */
241
+ onCountryChange () {
235
242
  this.addressLocal['addressRegion'] = ''
243
+ this.addressLocal['postalCode'] = ''
244
+ // clear any existing validation errors
245
+ this.$refs.addressForm.resetValidation()
236
246
  }
237
247
 
238
248
  /** A local (working) copy of the address, to contain the fields edited by the component (ie, the model). */
239
- addressLocal: object = {}
249
+ addressLocal: any = {}
240
250
 
241
251
  /** A local (working) copy of the address schema. */
242
252
  schemaLocal: any = {}
@@ -350,14 +360,17 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
350
360
  * @returns the Vuetify validation rules object
351
361
  */
352
362
  get rules (): { [attr: string]: Array<() => boolean | string> } {
353
- return this.createVuetifyRulesObject('addressLocal') as { [attr: string]: Array<() => boolean | string> }
363
+ return this.createVuetifyRulesObject('addressLocal')
354
364
  }
365
+
355
366
  /** Emits an update message for the address prop, so that the caller can ".sync" with it. */
356
367
  @Emit('update:address')
368
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
357
369
  emitAddress (address: object): void { }
358
370
 
359
371
  /** Emits the validity of the address entered by the user. */
360
372
  @Emit('valid')
373
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
361
374
  emitValid (valid: boolean): void { }
362
375
 
363
376
  /**
@@ -392,6 +405,7 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
392
405
  this.schemaLocal = { ...this.schema, addressRegion }
393
406
  } else {
394
407
  // we are not using a region list for the current country so remove required property
408
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
395
409
  const { required, ...addressRegion } = this.schema.addressRegion
396
410
  // re-assign the local schema because Vue does not detect property deletion
397
411
  this.schemaLocal = { ...this.schema, addressRegion }
package/package.json CHANGED
@@ -1,11 +1,11 @@
1
1
  {
2
2
  "name": "@bcrs-shared-components/base-address",
3
- "version": "2.0.55",
3
+ "version": "2.0.57",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
7
7
  "dependencies": {
8
- "@bcrs-shared-components/mixins": "^1.1.67",
8
+ "@bcrs-shared-components/mixins": "^1.1.68",
9
9
  "lodash.uniqueid": "^4.0.1",
10
10
  "vue": "^2.7.14",
11
11
  "vuelidate": "0.6.2"
@@ -14,5 +14,5 @@
14
14
  "vue-property-decorator": "^9.1.2",
15
15
  "vuelidate-property-decorators": "1.0.28"
16
16
  },
17
- "gitHead": "3e3ac7dbc28c3624e7d839497dfd00580dc01b8e"
17
+ "gitHead": "29bec814809ed746a164080b6258e1a37642a776"
18
18
  }