@bcrs-shared-components/base-address 2.0.61 → 2.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.
Files changed (2) hide show
  1. package/BaseAddress.vue +21 -19
  2. package/package.json +2 -2
package/BaseAddress.vue CHANGED
@@ -46,6 +46,7 @@
46
46
  <v-form
47
47
  v-if="editing"
48
48
  ref="addressForm"
49
+ v-model="addressFormValid"
49
50
  name="address-form"
50
51
  lazy-validation
51
52
  >
@@ -260,7 +261,10 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
260
261
  /** A unique id for this instance of this component. */
261
262
  uniqueId = uniqueId()
262
263
 
263
- /** Whether postal code validation rules are enabled (after first blur). */
264
+ /** Whether address form is valid. */
265
+ addressFormValid = false
266
+
267
+ /** Whether postal code validation rules are enabled (ie, after first blur or validate call). */
264
268
  postalCodeRulesEnabled = false
265
269
 
266
270
  /** Called when component is created. */
@@ -372,18 +376,8 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
372
376
  return this.createVuetifyRulesObject('addressLocal')
373
377
  }
374
378
 
375
- /** Emits an update message for the address prop, so that the caller can ".sync" with it. */
376
- @Emit('update:address')
377
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
378
- emitAddress (address: object): void { }
379
-
380
- /** Emits the validity of the address entered by the user. */
381
- @Emit('valid')
382
- // eslint-disable-next-line @typescript-eslint/no-unused-vars
383
- emitValid (valid: boolean): void { }
384
-
385
379
  /**
386
- * Watches changes to the Schema object, so that if the parent changes the data, then
380
+ * Watches for changes to the Schema object, so that if the parent changes the data then
387
381
  * the working copy of it is updated.
388
382
  */
389
383
  @Watch('schema', { deep: true, immediate: true })
@@ -392,7 +386,7 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
392
386
  }
393
387
 
394
388
  /**
395
- * Watches changes to the Address object, so that if the parent changes the data, then
389
+ * Watches for changes to the Address object, so that if the parent changes the data then
396
390
  * the working copy of it is updated.
397
391
  */
398
392
  @Watch('address', { deep: true, immediate: true })
@@ -401,7 +395,7 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
401
395
  }
402
396
 
403
397
  /**
404
- * Watches changes to the Address Country and updates the schema accordingly.
398
+ * Watches for changes to the Address Country and updates the schema accordingly.
405
399
  */
406
400
  @Watch('addressCountry')
407
401
  onAddressCountryChanged (): void {
@@ -423,14 +417,22 @@ export default class BaseAddress extends Mixins(ValidationMixin, CountriesProvin
423
417
  }
424
418
 
425
419
  /**
426
- * Watches changes to the Address Local object, to catch any changes to the fields within the address.
427
- * Will notify the parent object with the new address and whether or not the address is valid.
420
+ * Watches for changes to the local address object, to catch any changes to the fields within the address.
421
+ * Emits an update message for the address prop, so that the caller can ".sync" with it.
422
+ * If this causes the form to become valid or invalid then another watcher will handle that.
428
423
  */
429
424
  @Watch('addressLocal', { deep: true, immediate: true })
430
- onAddressLocalChanged (): void {
431
- this.emitAddress(this.addressLocal)
425
+ @Emit('update:address')
426
+ onAddressLocalChanged (): any {
427
+ return this.addressLocal
428
+ }
429
+
430
+ /** Watches for changes to the address form validity and emits the updated state. */
431
+ @Watch('addressFormValid')
432
+ @Emit('valid')
433
+ onAddressFormValidChanged (): boolean {
432
434
  // form is valid only if postal code rules are enabled
433
- this.emitValid(!this.$v.$invalid && this.postalCodeRulesEnabled)
435
+ return (!this.$v.$invalid && this.postalCodeRulesEnabled)
434
436
  }
435
437
 
436
438
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@bcrs-shared-components/base-address",
3
- "version": "2.0.61",
3
+ "version": "2.1.0",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },
@@ -14,5 +14,5 @@
14
14
  "vue-property-decorator": "^9.1.2",
15
15
  "vuelidate-property-decorators": "1.0.28"
16
16
  },
17
- "gitHead": "338d5c109363f2f5d55b914baf2eb24d396ddf15"
17
+ "gitHead": "b76f47d6b97b9caf02baa98461dfcf5dc9526f7c"
18
18
  }