@bpost/bp-address-auto-complete-by-component 1.1.25 → 1.1.26

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.
@@ -1755,7 +1755,7 @@ class StreetComponent {
1755
1755
  ngOnChanges(changes) {
1756
1756
  if (changes) {
1757
1757
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
1758
- this.searchText = this.autofillData.streetName;
1758
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
1759
1759
  this.setSelectedAddress(this.autofillData.selectedAddress);
1760
1760
  }
1761
1761
  else {
@@ -1983,6 +1983,21 @@ class StreetComponent {
1983
1983
  }
1984
1984
  return concatStr;
1985
1985
  }
1986
+ loadAutoFillParams(autoFillData) {
1987
+ let concatStr = '';
1988
+ if (autoFillData !== null) {
1989
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
1990
+ this.postalCode = autoFillData.postalCode;
1991
+ }
1992
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
1993
+ this.locality = autoFillData.municipalityName;
1994
+ }
1995
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
1996
+ concatStr = autoFillData.streetName;
1997
+ }
1998
+ }
1999
+ return concatStr;
2000
+ }
1986
2001
  isString(val) {
1987
2002
  if (val === null || val === undefined) {
1988
2003
  return false;
@@ -2613,8 +2628,7 @@ class StreetNumberComponent {
2613
2628
  ngOnChanges(changes) {
2614
2629
  if (changes) {
2615
2630
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
2616
- this.searchText = this.autofillData.streetNumber;
2617
- this.addressIsComplete = this.autofillData.isCompleteStreetNumber;
2631
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
2618
2632
  this.setSelectedAddress(this.autofillData.selectedAddress);
2619
2633
  }
2620
2634
  else {
@@ -2835,6 +2849,28 @@ class StreetNumberComponent {
2835
2849
  }
2836
2850
  return concatStr;
2837
2851
  }
2852
+ loadAutoFillParams(autoFillData) {
2853
+ let concatStr = '';
2854
+ if (autoFillData !== null) {
2855
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
2856
+ this.postalCode = autoFillData.postalCode;
2857
+ }
2858
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
2859
+ this.locality = autoFillData.municipalityName;
2860
+ }
2861
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
2862
+ this.streetName = autoFillData.streetName;
2863
+ }
2864
+ if (autoFillData.hasOwnProperty('streetNumber')
2865
+ && this.isString(autoFillData.streetNumber)) {
2866
+ concatStr = autoFillData.streetNumber;
2867
+ }
2868
+ if (autoFillData.hasOwnProperty('isCompleteStreetNumber')) {
2869
+ this.addressIsComplete = this.autofillData.isCompleteStreetNumber;
2870
+ }
2871
+ }
2872
+ return concatStr;
2873
+ }
2838
2874
  isString(val) {
2839
2875
  if (val === null || val === undefined) {
2840
2876
  return false;
@@ -3447,7 +3483,7 @@ class StreetNumberComponent {
3447
3483
  return this.searchText && this.searchText.length > 0;
3448
3484
  }
3449
3485
  onClearStreetNumberInput(focus, emit = true) {
3450
- console.warn('street number :: clearInput');
3486
+ // console.warn('street number :: clearInput');
3451
3487
  this.clearWidget();
3452
3488
  this.resetArrowSelectedIndex();
3453
3489
  this.previousIndex = -1;
@@ -3689,8 +3725,7 @@ class BoxNumberComponent {
3689
3725
  ngOnChanges(changes) {
3690
3726
  if (changes) {
3691
3727
  if (changes.hasOwnProperty('autofillData') && changes.autofillData.currentValue !== null && changes.autofillData.currentValue !== undefined) {
3692
- this.searchText = this.autofillData.boxNumber;
3693
- this.addressIsValidated = this.autofillData.isCompleteBoxNumber;
3728
+ this.searchText = this.loadAutoFillParams(changes.autofillData.currentValue);
3694
3729
  this.setSelectedAddress(this.autofillData.selectedAddress);
3695
3730
  }
3696
3731
  else {
@@ -3887,6 +3922,32 @@ class BoxNumberComponent {
3887
3922
  }
3888
3923
  return concatStr;
3889
3924
  }
3925
+ loadAutoFillParams(autoFillData) {
3926
+ let concatStr = '';
3927
+ if (autoFillData !== null) {
3928
+ if (autoFillData.hasOwnProperty('postalCode') && this.isString(autoFillData.postalCode)) {
3929
+ this.postalCode = autoFillData.postalCode;
3930
+ }
3931
+ if (autoFillData.hasOwnProperty('municipalityName') && this.isString(autoFillData.municipalityName)) {
3932
+ this.locality = autoFillData.municipalityName;
3933
+ }
3934
+ if (autoFillData.hasOwnProperty('streetName') && this.isString(autoFillData.streetName)) {
3935
+ this.streetName = autoFillData.streetName;
3936
+ }
3937
+ if (autoFillData.hasOwnProperty('streetNumber')
3938
+ && this.isString(autoFillData.streetNumber)) {
3939
+ this.streetNumber = autoFillData.streetNumber;
3940
+ }
3941
+ if (autoFillData.hasOwnProperty('boxNumber')
3942
+ && this.isString(autoFillData.boxNumber)) {
3943
+ concatStr = autoFillData.boxNumber;
3944
+ }
3945
+ if (autoFillData.hasOwnProperty('isCompleteBoxNumber')) {
3946
+ this.addressIsValidated = this.autofillData.isCompleteBoxNumber;
3947
+ }
3948
+ }
3949
+ return concatStr;
3950
+ }
3890
3951
  isString(val) {
3891
3952
  if (val === null || val === undefined) {
3892
3953
  return false;
@@ -4789,6 +4850,7 @@ class LibAddressAutocompleteByComponentComponent {
4789
4850
  console.log('lib::widget detected prefilling', this.addressParams);
4790
4851
  }
4791
4852
  this.addressParams.minLevel = /*4*/ ADDRESSLEVEL.LOCALITY;
4853
+ this.minLevel = this.addressParams.minLevel;
4792
4854
  // this.localityPrefillData = this.addressParams; // as any as PrefillData;
4793
4855
  this.localityPrefillData = new PrefillData(this.addressParams);
4794
4856
  // Object.assign(this.localityPrefillData, this.addressParams);
@@ -5038,7 +5100,7 @@ class LibAddressAutocompleteByComponentComponent {
5038
5100
  if (this.showDebugMessageToConsole) {
5039
5101
  console.log('notifyAddressComplete', this.selectedAddress, 'nis9InResponse:' + this.nis9InResponse, typeof this.nis9InResponse);
5040
5102
  }
5041
- if (this.selectedAddress && !this.autocompleteLocality.prefilling) {
5103
+ if (this.selectedAddress) {
5042
5104
  let isCompleteStreetNumber = false;
5043
5105
  let isCompleteBoxNumber = false;
5044
5106
  if (this.selectedAddress.hasOwnProperty('isComplete') && this.selectedAddress.isComplete) {
@@ -5110,6 +5172,7 @@ class LibAddressAutocompleteByComponentComponent {
5110
5172
  this.autocompleteBoxNb.searchText = '';
5111
5173
  this.autocompleteBoxNb.streetNumber = '';
5112
5174
  this.autocompleteBoxNb.clearInput(false, false);
5175
+ this.boxNumberAutofillData = null;
5113
5176
  }
5114
5177
  // Street number
5115
5178
  this.streetNumber = '';
@@ -5120,6 +5183,7 @@ class LibAddressAutocompleteByComponentComponent {
5120
5183
  this.autocompleteStreetNb.searchText = '';
5121
5184
  this.autocompleteStreetNb.streetName = '';
5122
5185
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5186
+ this.streetNumberAutofillData = null;
5123
5187
  }
5124
5188
  // Street name
5125
5189
  this.street = '';
@@ -5129,12 +5193,14 @@ class LibAddressAutocompleteByComponentComponent {
5129
5193
  }
5130
5194
  this.autocompleteStreet.searchText = '';
5131
5195
  this.autocompleteStreet.clearInput(false, false);
5196
+ this.streetNameAutofillData = null;
5132
5197
  }
5133
5198
  // Locality
5134
5199
  this.locality = '';
5135
5200
  if (this.autocompleteLocality) {
5136
5201
  this.autocompleteLocality.searchText = '';
5137
5202
  this.autocompleteLocality.clearInput(false, false);
5203
+ this.autofillData = null;
5138
5204
  }
5139
5205
  nextAddress = null;
5140
5206
  }
@@ -5145,6 +5211,7 @@ class LibAddressAutocompleteByComponentComponent {
5145
5211
  this.autocompleteBoxNb.searchText = '';
5146
5212
  this.autocompleteBoxNb.streetNumber = '';
5147
5213
  this.autocompleteBoxNb.clearInput(false, false);
5214
+ this.boxNumberAutofillData = null;
5148
5215
  }
5149
5216
  // Street number
5150
5217
  this.streetNumber = '';
@@ -5152,12 +5219,14 @@ class LibAddressAutocompleteByComponentComponent {
5152
5219
  this.autocompleteStreetNb.searchText = '';
5153
5220
  this.autocompleteStreetNb.streetName = '';
5154
5221
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5222
+ this.streetNumberAutofillData = null;
5155
5223
  }
5156
5224
  // Street name
5157
5225
  this.street = '';
5158
5226
  if (this.autocompleteStreet) {
5159
5227
  this.autocompleteStreet.searchText = '';
5160
5228
  this.autocompleteStreet.clearInput(false, false);
5229
+ this.streetNameAutofillData = null;
5161
5230
  }
5162
5231
  nextAddress = null;
5163
5232
  }
@@ -5168,6 +5237,7 @@ class LibAddressAutocompleteByComponentComponent {
5168
5237
  this.autocompleteBoxNb.searchText = '';
5169
5238
  this.autocompleteBoxNb.streetNumber = '';
5170
5239
  this.autocompleteBoxNb.clearInput(false, false);
5240
+ this.boxNumberAutofillData = null;
5171
5241
  }
5172
5242
  // Street number
5173
5243
  this.streetNumber = '';
@@ -5175,6 +5245,7 @@ class LibAddressAutocompleteByComponentComponent {
5175
5245
  this.autocompleteStreetNb.searchText = '';
5176
5246
  // this.autocompleteStreetNb.streetName = '';
5177
5247
  this.autocompleteStreetNb.onClearStreetNumberInput(false, false);
5248
+ this.streetNumberAutofillData = null;
5178
5249
  }
5179
5250
  nextAddress = null;
5180
5251
  }
@@ -5186,6 +5257,7 @@ class LibAddressAutocompleteByComponentComponent {
5186
5257
  // this.autocompleteBoxNb.streetNumber = '';
5187
5258
  this.autocompleteBoxNb.clearInput(false, false);
5188
5259
  }
5260
+ this.boxNumberAutofillData = null;
5189
5261
  // Attention: if not-in-list don't reset the address, just modify it
5190
5262
  const addressIsNotInList = nextAddress !== undefined && nextAddress !== null
5191
5263
  && nextAddress.hasOwnProperty('not-in-list') && nextAddress['not-in-list'] === true
@@ -5426,6 +5498,10 @@ class LibAddressAutocompleteByComponentComponent {
5426
5498
  this.autocompleteStreet.locality = '';
5427
5499
  this.autocompleteStreetNb.streetName = '';
5428
5500
  this.autocompleteBoxNb.streetNumber = '';
5501
+ this.autofillData = null;
5502
+ this.streetNameAutofillData = null;
5503
+ this.streetNumberAutofillData = null;
5504
+ this.boxNumberAutofillData = null;
5429
5505
  }
5430
5506
  }
5431
5507
  quitPrefillMode() {
@@ -5580,6 +5656,27 @@ class LibAddressAutocompleteByComponentComponent {
5580
5656
  this.selectedAddress.isCompleteNotificationDone = true;
5581
5657
  this.notifyAddressComplete();
5582
5658
  }
5659
+ if (address && level) {
5660
+ setTimeout(() => {
5661
+ switch (level) {
5662
+ case 4: // Locality filled -> focus street
5663
+ if (address.streetName && this.autocompleteStreet && this.autocompleteStreet.streetSearchInput) {
5664
+ this.autocompleteStreet.streetSearchInput.nativeElement.focus();
5665
+ }
5666
+ break;
5667
+ case 3: // Street filled -> focus street number
5668
+ if (address.houseNumber && this.autocompleteStreetNb && this.autocompleteStreetNb.streetNumberSearchInput) {
5669
+ this.autocompleteStreetNb.streetNumberSearchInput.nativeElement.focus();
5670
+ }
5671
+ break;
5672
+ case 2: // Street number filled -> focus box number
5673
+ if ((address.boxNumber || this.streetNumberAutofillData) && this.autocompleteBoxNb && this.autocompleteBoxNb.boxNumberSearchInput) {
5674
+ this.autocompleteBoxNb.boxNumberSearchInput.nativeElement.focus();
5675
+ }
5676
+ break;
5677
+ }
5678
+ }, 0);
5679
+ }
5583
5680
  }
5584
5681
  setAddressStreetNumber(streetNumber) {
5585
5682
  if (this.showDebugMessageToConsole) {
@@ -5676,6 +5773,9 @@ class LibAddressAutocompleteByComponentComponent {
5676
5773
  this.streetParams = this.addressParams;
5677
5774
  }
5678
5775
  */
5776
+ this.streetNameAutofillData = null;
5777
+ this.streetNumberAutofillData = null;
5778
+ this.boxNumberAutofillData = null;
5679
5779
  const data = event.prefillData;
5680
5780
  if (event.prefillData.prefillMunicipalityPerfectMatchFound === true) {
5681
5781
  const suggestion = data.prefillMunicipalityPerfectMatchSuggestion;
@@ -5714,7 +5814,19 @@ class LibAddressAutocompleteByComponentComponent {
5714
5814
  this.streetPrefillData = this.prefillData;
5715
5815
  }
5716
5816
  */
5717
- this.streetPrefillData = this.prefillData;
5817
+ if (address.streetName) {
5818
+ this.setAddress(address, ADDRESSLEVEL.LOCALITY);
5819
+ this.minLevel = ADDRESSLEVEL.STREET;
5820
+ const streetNumber = this.prefillData.parameters.streetNumber;
5821
+ const boxNumber = this.prefillData.parameters.boxNumber;
5822
+ if (boxNumber && !address.boxNumber) {
5823
+ this.prefillData.parameters.minLevel = ADDRESSLEVEL.BOX_NUMBER;
5824
+ this.boxNumberPrefillData = this.prefillData;
5825
+ }
5826
+ }
5827
+ else {
5828
+ this.streetPrefillData = this.prefillData;
5829
+ }
5718
5830
  }
5719
5831
  else {
5720
5832
  // const cpAndLocality = this.prefillData.parameters.postalCode + this.prefillData.parameters.municipalityName;
@@ -5749,7 +5861,7 @@ class LibAddressAutocompleteByComponentComponent {
5749
5861
  this.addressParams.minLevel = ADDRESSLEVEL.STREET_NUMBER;
5750
5862
  // this.localityPrefillData = this.addressParams; // as any as PrefillData;
5751
5863
  // this.localityPrefillData = new PrefillData(this.addressParams);
5752
- // Object.assign(this.localityPrefillData, this.addressParams);
5864
+ // Object.assign(this.localityPrefillData, this.addressParams);
5753
5865
  this.prefillData = event.prefillData;
5754
5866
  this.prefillData.ts = new Date();
5755
5867
  this.prefillData.parameters.minLevel = ADDRESSLEVEL.STREET_NUMBER;
@@ -5797,7 +5909,13 @@ class LibAddressAutocompleteByComponentComponent {
5797
5909
  if (this.showDebugMessageToConsole) {
5798
5910
  console.warn('lib::street: prefill - transmitting prefill data for streetNumber :', this.prefillData);
5799
5911
  }
5800
- this.streetNumberPrefillData = this.prefillData;
5912
+ if (address.houseNumber) {
5913
+ this.setAddress(address, ADDRESSLEVEL.STREET);
5914
+ this.minLevel = ADDRESSLEVEL.STREET_NUMBER;
5915
+ }
5916
+ else {
5917
+ this.streetNumberPrefillData = this.prefillData;
5918
+ }
5801
5919
  }
5802
5920
  else {
5803
5921
  const prefillStreetName = this.prefillData.parameters.streetName;
@@ -5928,7 +6046,7 @@ class LibAddressAutocompleteByComponentComponent {
5928
6046
  const address = suggestion.address;
5929
6047
  this.updateStreetNumber(address);
5930
6048
  this.autocompleteStreetNb.selectedAddress = address;
5931
- const addressIsComplete = address && address.hasOwnProperty('isComplete') && address.isComplete === true ? true : false;
6049
+ const addressIsComplete = address && address.hasOwnProperty('isComplete') && !address.hasOwnProperty('boxNumber') && address.isComplete === true ? true : false;
5932
6050
  const addressIsNotInList = address && address.hasOwnProperty('not-in-list') && address['not-in-list'] === true ? true : false;
5933
6051
  if (addressIsComplete && !addressIsNotInList) {
5934
6052
  // found address - perfect matchat street number level