@dyedurham/search-and-file-widget 2.0.71 → 2.0.72

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.
@@ -84177,7 +84177,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84177
84177
  });
84178
84178
 
84179
84179
  // src/app/constants/BritishColumbiaConstants.ts
84180
- var BCNameType, BCNameTypeLabel, BC_NUMBERED_NAME_PREVIEW, BC_DEFAULT_COUNTRY, BC_FUTURE_EFFECTIVE_DATE_FEE, BC_PASSWORD_MIN_LENGTH, BC_PASSWORD_MAX_LENGTH, BC_PASSWORD_PATTERN, BC_COMPANY_EMAIL_MAX_LENGTH, BC_NAME_RESERVATION_MAX_LENGTH, BC_NAME_RESERVATION_PATTERN, BC_COMPLETING_PARTY_COUNTRY_OPTIONS;
84180
+ var BCNameType, BCNameTypeLabel, BC_NUMBERED_NAME_PREVIEW, BC_DEFAULT_COUNTRY, BC_FUTURE_EFFECTIVE_DATE_FEE, BC_PASSWORD_MIN_LENGTH, BC_PASSWORD_MAX_LENGTH, BC_PASSWORD_PATTERN, BC_COMPANY_EMAIL_MAX_LENGTH, BC_CANADIAN_POSTAL_PATTERN, BC_NAME_RESERVATION_MAX_LENGTH, BC_NAME_RESERVATION_PATTERN, BC_COMPLETING_PARTY_COUNTRY_OPTIONS;
84181
84181
  var init_BritishColumbiaConstants = __esm({
84182
84182
  "src/app/constants/BritishColumbiaConstants.ts"() {
84183
84183
  init_common_constants();
@@ -84196,6 +84196,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84196
84196
  BC_PASSWORD_MAX_LENGTH = 15;
84197
84197
  BC_PASSWORD_PATTERN = /^[A-Za-z0-9]+$/;
84198
84198
  BC_COMPANY_EMAIL_MAX_LENGTH = 150;
84199
+ BC_CANADIAN_POSTAL_PATTERN = /^[A-Za-z]\d[A-Za-z][ -]?\d[A-Za-z]\d$/;
84199
84200
  BC_NAME_RESERVATION_MAX_LENGTH = 9;
84200
84201
  BC_NAME_RESERVATION_PATTERN = /^(NR)?\d{1,7}$/i;
84201
84202
  BC_COMPLETING_PARTY_COUNTRY_OPTIONS = [
@@ -84344,7 +84345,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84344
84345
  additionalStreetAddress: address?.addressLine2?.trim() || void 0,
84345
84346
  city: address?.city?.trim() ?? "",
84346
84347
  provinceOrState: toProvinceOrStateCode(address?.provinceState, country),
84347
- postalOrZipCode: address?.postalZip?.trim() ?? "",
84348
+ postalOrZipCode: normalizePostalCode(address?.postalZip, country),
84348
84349
  country
84349
84350
  }
84350
84351
  };
@@ -84377,10 +84378,18 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84377
84378
  additionalStreetAddress: padShortAddressLine(suite || address?.address2),
84378
84379
  city: address?.city ?? "",
84379
84380
  provinceOrState: toProvinceOrStateCode(address?.province_state, country),
84380
- postalOrZipCode: address?.postal_zip ?? "",
84381
+ postalOrZipCode: normalizePostalCode(address?.postal_zip, country),
84381
84382
  country
84382
84383
  };
84383
84384
  }
84385
+ function normalizePostalCode(value, countryCode) {
84386
+ const trimmed = (value ?? "").trim();
84387
+ if (countryCode !== "CA") {
84388
+ return trimmed;
84389
+ }
84390
+ const compact = trimmed.replace(/[\s-]+/g, "").toUpperCase();
84391
+ return /^[A-Z]\d[A-Z]\d[A-Z]\d$/.test(compact) ? `${compact.slice(0, 3)} ${compact.slice(3)}` : trimmed;
84392
+ }
84384
84393
  function toProvinceOrStateCode(value, countryCode) {
84385
84394
  const trimmed = (value ?? "").trim();
84386
84395
  if (!trimmed || trimmed.length === 2) {
@@ -84472,7 +84481,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84472
84481
  });
84473
84482
 
84474
84483
  // src/app/helpers/british-columbia/formation/british-columbia-formation-form.helper.ts
84475
- var ifNamed, BritishColumbiaFormationFormHelper;
84484
+ var ifNamed, ifCanada, BritishColumbiaFormationFormHelper;
84476
84485
  var init_british_columbia_formation_form_helper = __esm({
84477
84486
  "src/app/helpers/british-columbia/formation/british-columbia-formation-form.helper.ts"() {
84478
84487
  init_forms();
@@ -84483,6 +84492,7 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84483
84492
  init_custom_validators();
84484
84493
  init_BritishColumbiaConstants();
84485
84494
  ifNamed = (validator) => (control) => control.parent?.get(BCFormationFormControls.CorporationNameType)?.value === BCNameType.Named ? validator(control) : null;
84495
+ ifCanada = (validator) => (control) => control.parent?.get(BCFormationFormControls.Country)?.value === "Canada" ? validator(control) : null;
84486
84496
  BritishColumbiaFormationFormHelper = class {
84487
84497
  static generateConfig(task, translateFn, currentUser) {
84488
84498
  const t = translateFn ?? ((key) => key);
@@ -84677,8 +84687,9 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
84677
84687
  [BCFormationFormControls.AddressLine1]: new FormControl(mailAddress?.addressLine1 ?? prefill.mailingAddress.addressLine1, [Validators.required, Validators.minLength(3), Validators.maxLength(40)]),
84678
84688
  [BCFormationFormControls.AddressLine2]: new FormControl(mailAddress?.addressLine2 ?? prefill.mailingAddress.addressLine2, Validators.maxLength(40)),
84679
84689
  [BCFormationFormControls.City]: new FormControl(mailAddress?.city ?? prefill.mailingAddress.city, [Validators.required, Validators.maxLength(40)]),
84680
- [BCFormationFormControls.ProvinceState]: new FormControl(mailAddress?.provinceState ?? prefill.mailingAddress.provinceState),
84681
- [BCFormationFormControls.PostalZip]: new FormControl(mailAddress?.postalZip ?? prefill.mailingAddress.postalZip, [Validators.required, Validators.maxLength(10)]),
84690
+ // The API requires a province / state when the country is Canada or the United States.
84691
+ [BCFormationFormControls.ProvinceState]: new FormControl(mailAddress?.provinceState ?? prefill.mailingAddress.provinceState, requiredIfValueIn(BCFormationFormControls.Country, ["Canada", "United States"])),
84692
+ [BCFormationFormControls.PostalZip]: new FormControl(mailAddress?.postalZip ?? prefill.mailingAddress.postalZip, [Validators.required, Validators.maxLength(10), ifCanada(Validators.pattern(BC_CANADIAN_POSTAL_PATTERN))]),
84682
84693
  [BCFormationFormControls.Country]: new FormControl(mailAddress?.country ?? (prefill.mailingAddress.country || BC_DEFAULT_COUNTRY), Validators.required),
84683
84694
  [BCFormationFormControls.HasConfirmedCompletion]: new FormControl(deltaData?.hasConfirmedCompletion ?? false, Validators.requiredTrue),
84684
84695
  [BCFormationFormControls.HasRequiredDocuments]: new FormControl(deltaData?.hasRequiredDocuments ?? false, Validators.requiredTrue)
@@ -85004,6 +85015,8 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
85004
85015
  label: "Postal / Zip Code",
85005
85016
  formControlName: BCFormationFormControls.PostalZip,
85006
85017
  required: true,
85018
+ errorMessage: "Enter a valid Canadian postal code (for example V8W 1X4)",
85019
+ showRequiredMessage: true,
85007
85020
  class: "column-2"
85008
85021
  },
85009
85022
  {
@@ -85012,7 +85025,11 @@ Note: Recommended intrinsic image size is calculated assuming a maximum DPR of $
85012
85025
  formControlName: BCFormationFormControls.Country,
85013
85026
  required: true,
85014
85027
  options: BC_COMPLETING_PARTY_COUNTRY_OPTIONS,
85015
- class: "span-4"
85028
+ class: "span-4",
85029
+ // Province / State is required for Canada and the US, and the postal code format is Canada-only.
85030
+ onChange: (form) => {
85031
+ [BCFormationFormControls.ProvinceState, BCFormationFormControls.PostalZip].forEach((control) => form.get(control)?.updateValueAndValidity({ emitEvent: false }));
85032
+ }
85016
85033
  },
85017
85034
  {
85018
85035
  type: FormType.Checkbox,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dyedurham/search-and-file-widget",
3
- "version": "2.0.71",
3
+ "version": "2.0.72",
4
4
  "description": "",
5
5
  "main": "dnd-filing-shell.js",
6
6
  "scripts": {