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

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 +17 -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
@@ -185,6 +185,11 @@ import { ValidationMixin, CountriesProvincesMixin } from '@bcrs-shared-component
185
185
  mixins: [ValidationMixin, CountriesProvincesMixin]
186
186
  })
187
187
  export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvincesMixin) {
188
+ // Refs
189
+ $refs!: {
190
+ addressForm: HTMLFormElement
191
+ }
192
+
188
193
  /**
189
194
  * The validation object used by Vuelidate to compute address model validity.
190
195
  * @returns the Vuelidate validations object
@@ -231,12 +236,16 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
231
236
  @Prop({ default: false })
232
237
  readonly isInactive: boolean
233
238
 
234
- resetRegion () {
239
+ /** When country changes, resets fields. */
240
+ onCountryChange () {
235
241
  this.addressLocal['addressRegion'] = ''
242
+ this.addressLocal['postalCode'] = ''
243
+ // clear any existing validation errors
244
+ this.$refs.addressForm.resetValidation()
236
245
  }
237
246
 
238
247
  /** A local (working) copy of the address, to contain the fields edited by the component (ie, the model). */
239
- addressLocal: object = {}
248
+ addressLocal: any = {}
240
249
 
241
250
  /** A local (working) copy of the address schema. */
242
251
  schemaLocal: any = {}
@@ -350,14 +359,17 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
350
359
  * @returns the Vuetify validation rules object
351
360
  */
352
361
  get rules (): { [attr: string]: Array<() => boolean | string> } {
353
- return this.createVuetifyRulesObject('addressLocal') as { [attr: string]: Array<() => boolean | string> }
362
+ return this.createVuetifyRulesObject('addressLocal')
354
363
  }
364
+
355
365
  /** Emits an update message for the address prop, so that the caller can ".sync" with it. */
356
366
  @Emit('update:address')
367
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
357
368
  emitAddress (address: object): void { }
358
369
 
359
370
  /** Emits the validity of the address entered by the user. */
360
371
  @Emit('valid')
372
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
361
373
  emitValid (valid: boolean): void { }
362
374
 
363
375
  /**
@@ -392,6 +404,7 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
392
404
  this.schemaLocal = { ...this.schema, addressRegion }
393
405
  } else {
394
406
  // we are not using a region list for the current country so remove required property
407
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
395
408
  const { required, ...addressRegion } = this.schema.addressRegion
396
409
  // re-assign the local schema because Vue does not detect property deletion
397
410
  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.56",
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": "7d2e91f24c4664b49ef23b4f8a5a5b3a48698ab0"
18
18
  }