@everymatrix/general-input 1.87.0 → 1.87.2

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.
@@ -35,6 +35,10 @@ const TRANSLATIONS = {
35
35
  "enterIEAddressManually": "For IRE, enter the address manually",
36
36
  "postalLookUpNoAddressFound": "No addresses found for this postal code",
37
37
  "searchingForAddresses": "Searching for addresses...",
38
+ "SAIdLengthError": "SA ID must be 13 digits",
39
+ "SAIdInvalidError": "Invalid SA ID",
40
+ "PassportLengthError": "Passport number must be 8 or 9 digits.",
41
+ "PasswordMustContain": "Password must contain:"
38
42
  },
39
43
  "hu": {
40
44
  "dateError": "A választott dátumnak {min} és {max} között kell lennie",
@@ -61,7 +65,11 @@ const TRANSLATIONS = {
61
65
  "InvalidDocumentNumber": "Csak számjegyek engedélyezettek.",
62
66
  "twofaDescription": "<p> A megerősítő kódot elküldtük a következő címre: <p> {destination}. </p> </p> <p> Kérjük, írja be az alábbi PIN-kódot. </p>",
63
67
  "twofaResendMessage": "Nem kapta meg a megerősítő kódot?",
64
- "twofaResendButton": "Újraküldés"
68
+ "twofaResendButton": "Újraküldés",
69
+ "PassportLengthError": "Az útlevélszámnak 9 számjegyűnek kell lennie",
70
+ "SAIdLengthError": "A dél-afrikai személyi számnak 13 számjegyűnek kell lennie",
71
+ "SAIdInvalidError": "Érvénytelen dél-afrikai személyi szám",
72
+ "PasswordMustContain": "A jelszónak tartalmaznia kell:"
65
73
  },
66
74
  "hr": {
67
75
  "dateError": "Odabrani datum treba biti između {min} i {max}",
@@ -88,7 +96,11 @@ const TRANSLATIONS = {
88
96
  "InvalidDocumentNumber": "Dopušteni su samo numerički znakovi.",
89
97
  "twofaDescription": "<p> Poslali smo verifikacijski kod na: <p> {destination}. </p> </p> <p> Molimo unesite PIN ispod. </p>",
90
98
  "twofaResendMessage": "Niste primili verifikacijski kod?",
91
- "twofaResendButton": "Ponovno pošalji"
99
+ "twofaResendButton": "Ponovno pošalji",
100
+ "PassportLengthError": "Broj putovnice mora imati 9 znamenki",
101
+ "SAIdLengthError": "Južnoafrički osobni broj mora imati 13 znamenki",
102
+ "SAIdInvalidError": "Nevažeći južnoafrički osobni broj",
103
+ "PasswordMustContain": "Lozinka mora sadržavati:"
92
104
  },
93
105
  "tr": {
94
106
  "dateError": "Seçilen tarih {min} ve {max} arasında olmalıdır",
@@ -115,7 +127,11 @@ const TRANSLATIONS = {
115
127
  "InvalidDocumentNumber": "Sadece sayısal karakterlere izin verilir.",
116
128
  "twofaDescription": "<p> Doğrulama kodunu şu adrese gönderdik: <p> {destination}. </p> </p> <p> Lütfen aşağıya PIN kodunu girin. </p>",
117
129
  "twofaResendMessage": "Doğrulama kodunu almadınız mı?",
118
- "twofaResendButton": "Yeniden gönder"
130
+ "twofaResendButton": "Yeniden gönder",
131
+ "PassportLengthError": "Pasaport numarası 9 haneli olmalıdır",
132
+ "SAIdLengthError": "Güney Afrika kimlik numarası 13 haneli olmalıdır",
133
+ "SAIdInvalidError": "Geçersiz Güney Afrika kimlik numarası",
134
+ "PasswordMustContain": "Şifre şunları içermelidir:"
119
135
  },
120
136
  "pt-br": {
121
137
  "dateError": "A data selecionada deve estar entre {min} e {max}",
@@ -142,7 +158,11 @@ const TRANSLATIONS = {
142
158
  "InvalidDocumentNumber": "Apenas caracteres numéricos são permitidos.",
143
159
  "twofaDescription": "<p> Enviamos o código de verificação para: <p> {destination}. </p> </p> <p> Por favor, insira o PIN abaixo. </p>",
144
160
  "twofaResendMessage": "Não recebeu o código de verificação?",
145
- "twofaResendButton": "Reenviar"
161
+ "twofaResendButton": "Reenviar",
162
+ "PassportLengthError": "O número do passaporte deve ter 9 dígitos",
163
+ "SAIdLengthError": "O número de identificação da África do Sul deve ter 13 dígitos",
164
+ "SAIdInvalidError": "Número de identificação da África do Sul inválido",
165
+ "PasswordMustContain": "A senha deve conter:"
146
166
  },
147
167
  "es-mx": {
148
168
  "dateError": "La fecha seleccionada debe ser entre {min} y {max}",
@@ -169,9 +189,40 @@ const TRANSLATIONS = {
169
189
  "InvalidDocumentNumber": "Solo se permiten caracteres numéricos.",
170
190
  "twofaDescription": "<p> Hemos enviado el código de verificación a: <p> {destination}. </p> </p> <p> Por favor, ingrese el PIN a continuación. </p>",
171
191
  "twofaResendMessage": "¿No recibiste el código de verificación?",
172
- "twofaResendButton": "Reenviar"
192
+ "twofaResendButton": "Reenviar",
193
+ "PassportLengthError": "El número de pasaporte debe tener 9 dígitos",
194
+ "SAIdLengthError": "El número de identificación de Sudáfrica debe tener 13 dígitos",
195
+ "SAIdInvalidError": "Número de identificación de Sudáfrica inválido",
196
+ "PasswordMustContain": "La contraseña debe contener:"
173
197
  }
174
198
  };
199
+ const CONSTANTS = {
200
+ DOCUMENT_NUMBER: "DocumentNumber",
201
+ FIRSTNAME_ON_DOCUMENT: "FirstnameOnDocument",
202
+ LASTNAME_ON_DOCUMENT: "LastnameOnDocument",
203
+ PASSPORT: "Passport",
204
+ SOUTH_AFRICAN_ID: "SouthAfricanID",
205
+ BIRTHDATE: "BirthDate",
206
+ PASSPORT_NUMERIC_REGEX: /^\d{8,9}$/,
207
+ SA_ID_BASIC_REGEX: /^\d{13}$/,
208
+ SOUTH_AFRICAN_ID_LENGTH: 13,
209
+ NON_LETTERS_REGEX: /[^A-Za-z]/g,
210
+ DATE_FORMAT: "yyyy-MM-dd",
211
+ PASSWORD_COMPLEXITY_PASSED: "passed",
212
+ PASSWORD_COMPLEXITY_FAILED: "failed"
213
+ };
214
+ const ERROR_KEYS = {
215
+ PASSPORT_INVALID: 'PassportLengthError',
216
+ SA_ID_LENGTH: 'SAIdLengthError',
217
+ SA_ID_INVALID: 'SAIdInvalidError',
218
+ REQUIRED: 'requiredError',
219
+ LENGTH: 'lengthError',
220
+ DUPLICATE: 'duplicateInputError',
221
+ };
222
+ const STATUS_ICONS = {
223
+ PASSED: '✓',
224
+ FAILED: '✕',
225
+ };
175
226
  const translate = (key, customLang, values) => {
176
227
  const lang = customLang;
177
228
  let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
@@ -198,6 +249,27 @@ const getTranslations = (url) => {
198
249
  });
199
250
  });
200
251
  };
252
+ const validateID = (id) => {
253
+ if (!CONSTANTS.SA_ID_BASIC_REGEX.test(id))
254
+ return false;
255
+ const digits = id.split("").map(n => parseInt(n, 10));
256
+ let oddSum = 0;
257
+ for (let i = 0; i < 12; i += 2) {
258
+ oddSum += digits[i];
259
+ }
260
+ let evenConcat = "";
261
+ for (let i = 1; i < 12; i += 2) {
262
+ evenConcat += digits[i];
263
+ }
264
+ const evenNumber = parseInt(evenConcat, 10) * 2;
265
+ const evenSum = evenNumber
266
+ .toString()
267
+ .split("")
268
+ .reduce((s, n) => s + parseInt(n, 10), 0);
269
+ const total = oddSum + evenSum;
270
+ let checkDigit = (10 - (total % 10)) % 10;
271
+ return checkDigit === digits[12];
272
+ };
201
273
 
202
274
  const tooltipIconSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iNiIgY3k9IjYiIHI9IjUuNSIgc3Ryb2tlPSIjOTc5Nzk3Ii8+CjxyZWN0IHg9IjUiIHk9IjUiIHdpZHRoPSIyIiBoZWlnaHQ9IjUiIGZpbGw9IiM5Nzk3OTciLz4KPGNpcmNsZSBjeD0iNiIgY3k9IjMiIHI9IjEiIGZpbGw9IiM5Nzk3OTciLz4KPC9zdmc+Cg==';
203
275
 
@@ -5821,6 +5893,21 @@ const DateInput = class {
5821
5893
  sheet.innerHTML = this.clientStyling;
5822
5894
  this.stylingContainer.prepend(sheet);
5823
5895
  };
5896
+ this.handleDocumentIdUpdate = (e) => {
5897
+ if (this.name !== CONSTANTS.BIRTHDATE) {
5898
+ return;
5899
+ }
5900
+ const dateStr = e.detail;
5901
+ this.value = dateStr;
5902
+ this.valueAsDate = parse(this.value || '', CONSTANTS.DATE_FORMAT, new Date());
5903
+ this.touched = true;
5904
+ if (this.datePicker) {
5905
+ this.datePicker.value = this.value;
5906
+ }
5907
+ this.isValid = this.setValidity();
5908
+ this.errorMessage = this.setErrorMessage();
5909
+ this.valueHandler({ name: this.name, value: this.value });
5910
+ };
5824
5911
  this.name = undefined;
5825
5912
  this.displayName = undefined;
5826
5913
  this.placeholder = undefined;
@@ -5833,6 +5920,7 @@ const DateInput = class {
5833
5920
  this.clientStyling = '';
5834
5921
  this.dateFormat = 'yyyy-MM-dd';
5835
5922
  this.emitOnClick = false;
5923
+ this.enableSouthAfricanMode = undefined;
5836
5924
  this.errorMessage = undefined;
5837
5925
  this.isValid = undefined;
5838
5926
  this.limitStylingAppends = false;
@@ -5862,6 +5950,14 @@ const DateInput = class {
5862
5950
  this.valueHandler({ name: this.name, value: this.value });
5863
5951
  }
5864
5952
  }
5953
+ handleCustomRegistrationChange(newValue) {
5954
+ if (newValue) {
5955
+ window.addEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
5956
+ }
5957
+ else {
5958
+ window.removeEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
5959
+ }
5960
+ }
5865
5961
  valueHandler(inputValueEvent) {
5866
5962
  this.sendInputValue.emit(inputValueEvent);
5867
5963
  }
@@ -5905,6 +6001,9 @@ const DateInput = class {
5905
6001
  }
5906
6002
  });
5907
6003
  }
6004
+ if (this.enableSouthAfricanMode) {
6005
+ window.addEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
6006
+ }
5908
6007
  this.datePicker.i18n = Object.assign(Object.assign({}, this.datePicker.i18n), { formatDate: this.formatDate, parseDate: this.parseDate });
5909
6008
  if (this.defaultValue) {
5910
6009
  this.value = this.defaultValue;
@@ -5912,6 +6011,11 @@ const DateInput = class {
5912
6011
  }
5913
6012
  this.isValid = this.setValidity();
5914
6013
  }
6014
+ disconnectedCallback() {
6015
+ if (this.enableSouthAfricanMode) {
6016
+ window.removeEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
6017
+ }
6018
+ }
5915
6019
  handleCalendarIconClick() {
5916
6020
  if (this.datePicker.opened && this.emitOnClick) {
5917
6021
  window.postMessage({ type: `registration${this.name}Clicked` }, window.location.href);
@@ -5924,6 +6028,11 @@ const DateInput = class {
5924
6028
  this.isValid = this.setValidity();
5925
6029
  this.errorMessage = this.setErrorMessage();
5926
6030
  this.emitValueHandler(true);
6031
+ if (this.enableSouthAfricanMode) {
6032
+ window.dispatchEvent(new CustomEvent('birthDateUpdated', {
6033
+ detail: { birthDate: this.value }
6034
+ }));
6035
+ }
5927
6036
  }
5928
6037
  setValidity() {
5929
6038
  if (isBefore(this.valueAsDate, this.minDate) || isAfter(this.valueAsDate, this.maxDate) || !isMatch(this.formattedValue, this.dateFormat)) {
@@ -5958,14 +6067,15 @@ const DateInput = class {
5958
6067
  if (this.touched) {
5959
6068
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
5960
6069
  }
5961
- return index.h("div", { key: 'd9757eb7eea257167da12612f51f6665d6ac058e', class: `date__wrapper ${this.autofilled ? 'date__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("label", { key: '8339c9f27e74f2e1a98d11efea7eb05a9681e83e', class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("vaadin-date-picker", { key: '513692d0858a9f409e02bd515700e3e9e0eaa1fb', id: `${this.name}__input`, type: 'date', class: `date__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.placeholder}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onChange: (e) => this.handleInput(e) }), index.h("small", { key: '19be9854df1adc1c6581e00a3593bcf16d7e2146', class: 'date__error-message' }, this.errorMessage), this.tooltip &&
5962
- index.h("img", { key: 'f38abc61046c33c56a9efc3907dbd184b8e8352e', class: 'date__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
6070
+ return index.h("div", { key: '9399c1be2edcbe3ed5c0e133cad52b1917e77e96', class: `date__wrapper ${this.autofilled ? 'date__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("label", { key: '1094491a5fc441c4f704441d376ed965d6946637', class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), index.h("vaadin-date-picker", { key: '8c922586399999885841ede07e46b715b2f6760f', id: `${this.name}__input`, type: 'date', class: `date__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.placeholder}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onChange: (e) => this.handleInput(e) }), index.h("small", { key: '67c1b6a0daafee536ab7179d1fe90a2870bb12b1', class: 'date__error-message' }, this.errorMessage), this.tooltip &&
6071
+ index.h("img", { key: '4d02f23affc8ce9f5eb41a44fd2f346960c6d458', class: 'date__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
5963
6072
  }
5964
6073
  get element() { return index.getElement(this); }
5965
6074
  static get watchers() { return {
5966
6075
  "clientStyling": ["handleStylingChange"],
5967
6076
  "isValid": ["validityChanged"],
5968
- "emitValue": ["emitValueHandler"]
6077
+ "emitValue": ["emitValueHandler"],
6078
+ "enableSouthAfricanMode": ["handleCustomRegistrationChange"]
5969
6079
  }; }
5970
6080
  };
5971
6081
  DateInput.style = DateInputStyle0;
@@ -12846,6 +12956,8 @@ const GeneralInput = class {
12846
12956
  this.postalcodelength = undefined;
12847
12957
  this.addresses = [];
12848
12958
  this.ignoreCountry = false;
12959
+ this.enableSouthAfricanMode = undefined;
12960
+ this.pinAttemptsExceeded = undefined;
12849
12961
  this.mbSource = undefined;
12850
12962
  this.limitStylingAppends = false;
12851
12963
  }
@@ -12889,7 +13001,7 @@ const GeneralInput = class {
12889
13001
  return index.h("postalcode-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, postalcodelength: this.postalcodelength, addresses: this.addresses, ignoreCountry: this.ignoreCountry });
12890
13002
  }
12891
13003
  else {
12892
- return index.h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, haspostalcodelookup: this.haspostalcodelookup });
13004
+ return index.h("text-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, haspostalcodelookup: this.haspostalcodelookup, "enable-south-african-mode": this.enableSouthAfricanMode });
12893
13005
  }
12894
13006
  case 'email':
12895
13007
  return index.h("email-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
@@ -12902,9 +13014,9 @@ const GeneralInput = class {
12902
13014
  case 'togglecheckbox':
12903
13015
  return index.h("toggle-checkbox-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, options: this.options, "emit-on-click": this.emitOnClick });
12904
13016
  case 'datetime':
12905
- return index.h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, dateFormat: this.dateFormat, "emit-on-click": this.emitOnClick });
13017
+ return index.h("date-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, dateFormat: this.dateFormat, "emit-on-click": this.emitOnClick, "enable-south-african-mode": this.enableSouthAfricanMode });
12906
13018
  case 'password':
12907
- return index.h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, hidePasswordComplexity: this.hidePasswordComplexity, "no-validation": this.noValidation, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
13019
+ return index.h("password-input", { name: this.name, displayName: this.displayName, validation: this.validation, defaultValue: this.defaultValue, autofilled: this.autofilled, emitValue: this.emitValue, language: this.language, isDuplicateInput: this.isDuplicateInput, hidePasswordComplexity: this.hidePasswordComplexity, "no-validation": this.noValidation, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder, "enable-south-african-mode": this.enableSouthAfricanMode });
12908
13020
  case 'radio':
12909
13021
  return index.h("radio-input", { name: this.name, displayName: this.displayName, optionsGroup: this.options, validation: this.validation, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling });
12910
13022
  case 'tel':
@@ -12912,13 +13024,13 @@ const GeneralInput = class {
12912
13024
  case 'dropdown':
12913
13025
  return index.h("select-input", { name: this.name, action: this.action, defaultValue: this.defaultValue, displayName: this.displayName, options: this.options, validation: this.validation, emitValue: this.emitValue, autofilled: this.autofilled, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, placeholder: this.placeholder });
12914
13026
  case 'twofa':
12915
- return index.h("twofa-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, destination: this.twofaDestination, "resend-interval-seconds": this.twofaResendIntervalSeconds, "mb-source": this.mbSource });
13027
+ return index.h("twofa-input", { name: this.name, displayName: this.displayName, validation: this.validation, emitValue: this.emitValue, language: this.language, "client-styling": this.clientStyling, tooltip: this.tooltip, destination: this.twofaDestination, "resend-interval-seconds": this.twofaResendIntervalSeconds, "enable-south-african-mode": this.enableSouthAfricanMode, "pin-attempts-exceeded": this.pinAttemptsExceeded, "mb-source": this.mbSource });
12916
13028
  default:
12917
13029
  return index.h("p", null, "The ", this.type, " input type is not valid");
12918
13030
  }
12919
13031
  }
12920
13032
  render() {
12921
- return (index.h(index.Host, { key: '134ef4b9ef8814a9b77c5db5b5085b0fe4e79c92', class: `general-input--${this.name}`, onClick: this.handleClick }, this.renderInput()));
13033
+ return (index.h(index.Host, { key: '7d036183d9376203451d9805e76b608cfa63570b', class: `general-input--${this.name}`, onClick: this.handleClick }, this.renderInput()));
12922
13034
  }
12923
13035
  get host() { return index.getElement(this); }
12924
13036
  static get watchers() { return {
@@ -13066,7 +13178,7 @@ const NumberInput = class {
13066
13178
  };
13067
13179
  NumberInput.style = NumberInputStyle0;
13068
13180
 
13069
- const passwordInputCss = "*,\n*::before,\n*::after {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n}\n\n.password {\n font-family: \"Roboto\";\n font-style: normal;\n}\n.password__wrapper {\n position: relative;\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 5px;\n container-type: inline-size;\n}\n.password__wrapper--autofilled {\n pointer-events: none;\n}\n.password__wrapper--autofilled .password__label {\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__wrapper--autofilled .password__input::part(input-field) {\n color: var(--emw--color-black, #000000);\n}\n.password__wrapper--flex {\n display: flex;\n gap: 5px;\n}\n.password__wrapper--relative {\n position: relative;\n}\n.password__label {\n font-family: inherit;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 20px;\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__label--required::after {\n content: \"*\";\n font-family: inherit;\n color: var(--emw--login-color-primary, var(--emw--color-primary, #22B04E));\n margin-left: 2px;\n}\n.password__input {\n width: inherit;\n border: none;\n}\n.password__input[focused]::part(input-field) {\n border-color: var(--emw--login-color-primary, var(--emw--color-primary, #22B04E));\n}\n.password__input[invalid]::part(input-field) {\n border: 1px solid var(--emw--color-error, var(--emw--color-red, #ed0909));\n}\n.password__input::part(input-field) {\n border-radius: 4px;\n background-color: var(--emw--color-white, #FFFFFF);\n border: 1px solid var(--emw--color-gray-100, #E6E6E6);\n color: var(--emw--color-black, #000000);\n background-color: var(--emw--color-white, #FFFFFF);\n font-family: inherit;\n font-style: normal;\n font-weight: 300;\n font-size: 16px;\n line-height: 1.5;\n position: relative;\n margin-bottom: unset;\n height: 44px;\n padding: 0;\n width: 100%;\n}\n.password__input::part(reveal-button) {\n position: relative;\n right: 10px;\n}\n.password__input::part(reveal-button)::before {\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__input > input {\n padding: 5px 15px;\n}\n.password__input > input:placeholder-shown {\n color: var(--emw--color-gray-150, #828282);\n}\n.password__error-message {\n position: absolute;\n top: calc(100% + 5px);\n left: 0;\n color: var(--emw--color-error, var(--emw--color-red, #ed0909));\n}\n.password__complexity {\n height: 150px;\n position: relative;\n padding: 10px;\n display: flex;\n flex-direction: column;\n gap: 20px;\n justify-content: center;\n margin-top: 20px;\n font-weight: 300;\n background: var(--emw--color-white, #FFFFFF);\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n border: 1px solid #B0B0B0;\n box-sizing: content-box;\n /* works only in this order */\n}\n.password__complexity meter {\n border-color: transparent; /* Needed for Safari */\n}\n.password__complexity meter[value=\"1\"]::-moz-meter-bar {\n background-color: var(--emw--color-valid, #48952a);\n}\n.password__complexity meter[value=\"1\"]::-webkit-meter-optimum-value {\n background-color: var(--emw--color-valid, #48952a);\n}\n.password__complexity meter:not([value=\"1\"])::-moz-meter-bar {\n background-color: var(--emw--color-error, #FD2839);\n}\n.password__complexity meter:not([value=\"1\"])::-webkit-meter-optimum-value {\n background-color: var(--emw--color-error, #FD2839);\n}\n.password__complexity--strength {\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n}\n.password__complexity--strength meter::-moz-meter-bar { /* Firefox Pseudo Class */\n background: #B0B0B0;\n}\n.password__complexity--hidden {\n display: none;\n}\n.password__complexity--text-bold {\n font-weight: 500;\n}\n.password__complexity--checkbox {\n margin-right: 5px;\n}\n.password__complexity:after {\n content: \"\";\n position: absolute;\n width: 25px;\n height: 25px;\n border-top: 1px solid var(--emw--color-gray-150, #828282);\n border-right: 0 solid var(--emw--color-gray-150, #828282);\n border-left: 1px solid var(--emw--color-gray-150, #828282);\n border-bottom: 0 solid var(--emw--color-gray-150, #828282);\n bottom: 92%;\n left: 50%;\n margin-left: -25px;\n transform: rotate(45deg);\n margin-top: -25px;\n background-color: var(--emw--color-white, #FFFFFF);\n}\n@container (max-width: 300px) {\n .password__complexity {\n height: 190px;\n }\n .password__complexity:after {\n width: 14px;\n height: 14px;\n bottom: 96%;\n left: 57%;\n }\n}\n.password__tooltip-icon {\n width: 16px;\n height: auto;\n}\n.password__tooltip {\n position: absolute;\n top: 0;\n left: 20px;\n background-color: var(--emw--color-white, #FFFFFF);\n border: 1px solid var(--emw--color-gray-150, #828282);\n color: #2B2D3F;\n padding: 10px;\n border-radius: 5px;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n z-index: 10;\n}\n.password__tooltip.visible {\n opacity: 1;\n}";
13181
+ const passwordInputCss = "*,\n*::before,\n*::after {\n padding: 0;\n margin: 0;\n box-sizing: border-box;\n}\n\n.password {\n font-family: \"Roboto\";\n font-style: normal;\n}\n.password__wrapper {\n position: relative;\n width: 100%;\n display: flex;\n flex-direction: column;\n gap: 5px;\n container-type: inline-size;\n}\n.password__wrapper--autofilled {\n pointer-events: none;\n}\n.password__wrapper--autofilled .password__label {\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__wrapper--autofilled .password__input::part(input-field) {\n color: var(--emw--color-black, #000000);\n}\n.password__wrapper--flex {\n display: flex;\n gap: 5px;\n}\n.password__wrapper--relative {\n position: relative;\n}\n.password__label {\n font-family: inherit;\n font-style: normal;\n font-weight: 500;\n font-size: 16px;\n line-height: 20px;\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__label--required::after {\n content: \"*\";\n font-family: inherit;\n color: var(--emw--login-color-primary, var(--emw--color-primary, #22B04E));\n margin-left: 2px;\n}\n.password__input {\n width: inherit;\n border: none;\n}\n.password__input[focused]::part(input-field) {\n border-color: var(--emw--login-color-primary, var(--emw--color-primary, #22B04E));\n}\n.password__input[invalid]::part(input-field) {\n border: 1px solid var(--emw--color-error, var(--emw--color-red, #ed0909));\n}\n.password__input::part(input-field) {\n border-radius: 4px;\n background-color: var(--emw--color-white, #FFFFFF);\n border: 1px solid var(--emw--color-gray-100, #E6E6E6);\n color: var(--emw--color-black, #000000);\n background-color: var(--emw--color-white, #FFFFFF);\n font-family: inherit;\n font-style: normal;\n font-weight: 300;\n font-size: 16px;\n line-height: 1.5;\n position: relative;\n margin-bottom: unset;\n height: 44px;\n padding: 0;\n width: 100%;\n}\n.password__input::part(reveal-button) {\n position: relative;\n right: 10px;\n}\n.password__input::part(reveal-button)::before {\n color: var(--emw--registration-typography, var(--emw--color-black, #000000));\n}\n.password__input > input {\n padding: 5px 15px;\n}\n.password__input > input:placeholder-shown {\n color: var(--emw--color-gray-150, #828282);\n}\n.password__error-message {\n position: absolute;\n top: calc(100% + 5px);\n left: 0;\n color: var(--emw--color-error, var(--emw--color-red, #ed0909));\n}\n.password__complexity {\n height: 150px;\n position: relative;\n padding: 10px;\n display: flex;\n flex-direction: column;\n gap: 20px;\n justify-content: center;\n margin-top: 20px;\n font-weight: 300;\n background: var(--emw--color-white, #FFFFFF);\n -webkit-border-radius: 5px;\n -moz-border-radius: 5px;\n border-radius: 5px;\n border: 1px solid #B0B0B0;\n box-sizing: content-box;\n /* works only in this order */\n}\n.password__complexity meter {\n border-color: transparent; /* Needed for Safari */\n}\n.password__complexity meter[value=\"1\"]::-moz-meter-bar {\n background-color: var(--emw--color-valid, #48952a);\n}\n.password__complexity meter[value=\"1\"]::-webkit-meter-optimum-value {\n background-color: var(--emw--color-valid, #48952a);\n}\n.password__complexity meter:not([value=\"1\"])::-moz-meter-bar {\n background-color: var(--emw--color-error, #FD2839);\n}\n.password__complexity meter:not([value=\"1\"])::-webkit-meter-optimum-value {\n background-color: var(--emw--color-error, #FD2839);\n}\n.password__complexity--strength {\n display: flex;\n justify-content: space-evenly;\n align-items: center;\n}\n.password__complexity--strength meter::-moz-meter-bar { /* Firefox Pseudo Class */\n background: #B0B0B0;\n}\n.password__complexity--hidden {\n display: none;\n}\n.password__complexity--text-bold {\n font-weight: 500;\n}\n.password__complexity--checkbox {\n margin-right: 5px;\n}\n.password__complexity:after {\n content: \"\";\n position: absolute;\n width: 25px;\n height: 25px;\n border-top: 1px solid var(--emw--color-gray-150, #828282);\n border-right: 0 solid var(--emw--color-gray-150, #828282);\n border-left: 1px solid var(--emw--color-gray-150, #828282);\n border-bottom: 0 solid var(--emw--color-gray-150, #828282);\n bottom: 92%;\n left: 50%;\n margin-left: -25px;\n transform: rotate(45deg);\n margin-top: -25px;\n background-color: var(--emw--color-white, #FFFFFF);\n}\n@container (max-width: 300px) {\n .password__complexity {\n height: 190px;\n }\n .password__complexity:after {\n width: 14px;\n height: 14px;\n bottom: 96%;\n left: 57%;\n }\n}\n.password__tooltip-icon {\n width: 16px;\n height: auto;\n}\n.password__tooltip {\n position: absolute;\n top: 0;\n left: 20px;\n background-color: var(--emw--color-white, #FFFFFF);\n border: 1px solid var(--emw--color-gray-150, #828282);\n color: #2B2D3F;\n padding: 10px;\n border-radius: 5px;\n opacity: 0;\n transition: opacity 0.3s ease-in-out;\n z-index: 10;\n}\n.password__tooltip.visible {\n opacity: 1;\n}\n\n.customreg-password__complexity {\n background: var(--emw--color-white, #FFFFFF);\n border-radius: 6px;\n padding: 14px;\n}\n\n.customreg-password__complexity--title {\n font-size: var(--emw--font-size-small, 14px);\n color: var(--emw--color-black, #000000);\n margin-bottom: 12px;\n}\n\n.customreg-password__complexity--rules {\n display: flex;\n flex-direction: column;\n gap: 10px;\n font-size: var(--emw--font-size-small-xs, 12px);\n}\n\n.customreg-password__complexity--rule {\n display: flex;\n align-items: center;\n color: var(--emw--color-black, #000000);\n}\n\n.customreg-password__complexity--icon {\n width: 20px;\n height: 20px;\n min-width: 20px;\n display: flex;\n align-items: center;\n justify-content: center;\n font-size: 12px;\n font-weight: bold;\n border-radius: 50%;\n margin-right: 10px;\n}\n\n.customreg-password__complexity--icon.failed {\n background-color: var(--emw--color-error, #FD2839);\n color: var(--emw--color-white, #FFFFFF);\n}\n\n.customreg-password__complexity--icon.passed {\n background-color: var(--emw--color-lottoball-green, #01af15);\n color: var(--emw--color-white, #FFFFFF);\n}\n\n.customreg-password__complexity::after {\n display: none;\n}";
13070
13182
  const PasswordInputStyle0 = passwordInputCss;
13071
13183
 
13072
13184
  const PasswordInput = class {
@@ -13126,6 +13238,7 @@ const PasswordInput = class {
13126
13238
  this.isDuplicateInput = undefined;
13127
13239
  this.hidePasswordComplexity = false;
13128
13240
  this.clientStyling = '';
13241
+ this.enableSouthAfricanMode = undefined;
13129
13242
  this.isValid = undefined;
13130
13243
  this.errorMessage = undefined;
13131
13244
  this.limitStylingAppends = false;
@@ -13304,13 +13417,23 @@ const PasswordInput = class {
13304
13417
  return (index.h("div", { key: index$1 }, index.h("input", { class: 'password__complexity--checkbox', type: "checkbox", checked: complexity.passed, disabled: true }), index.h("span", null, translate(`${complexity.ruleKey}`, this.language) ? translate(`${complexity.ruleKey}`, this.language) : complexity.rule)));
13305
13418
  }))));
13306
13419
  }
13420
+ renderCustomComplexityPopup() {
13421
+ return (index.h("div", { class: `customreg-password__complexity ${!this.showPopup ? 'customreg-password__complexity--hidden' : ''}` }, index.h("p", { class: 'customreg-password__complexity--title' }, translate('PasswordMustContain', this.language)), index.h("div", { class: 'customreg-password__complexity--rules' }, this.passwordComplexity.map((complexity, index$1) => (index.h("div", { class: 'customreg-password__complexity--rule', key: index$1 }, index.h("span", { class: `customreg-password__complexity--icon ${complexity.passed
13422
+ ? CONSTANTS.PASSWORD_COMPLEXITY_PASSED : CONSTANTS.PASSWORD_COMPLEXITY_FAILED}` }, complexity.passed ? STATUS_ICONS.PASSED : STATUS_ICONS.FAILED), index.h("span", null, translate(complexity.ruleKey, this.language) || complexity.rule)))))));
13423
+ }
13307
13424
  render() {
13308
13425
  let invalidClass = '';
13309
13426
  if (this.touched) {
13310
13427
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13311
13428
  }
13312
- return index.h("div", { key: 'db7a6a87af3de451485c603a2f28f25806838d20', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '146ace196e1343f778232c0e2ff07556c0a09e1e', class: 'password__wrapper--flex' }, index.h("label", { key: '0d0cb672dfc7a43535a299b45752f43a87f73760', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '1eac72dfdadd0f50bd2db6b0fc44320dd2f287bf', class: 'password__wrapper--relative' }, this.tooltip &&
13313
- index.h("img", { key: 'bb327b9a403c1fc5628c4ba2da8d1a2b62888db5', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("vaadin-password-field", { key: '7962f122d1bfb0ac0a5176a743e1224dccba4910', type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder}`, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus }), !this.noValidation && index.h("small", { key: 'efadfea8911ba72161aef495d1fb5857f14a319b', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13429
+ return index.h("div", { key: 'c2dd473e71853ebb3d0b5b6245af606f75f8b479', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '4ba641a832be3b8efb1957af5f45eb7b7cc69adc', class: 'password__wrapper--flex' }, index.h("label", { key: 'a4440e8b59a743831fa833d8e1c680c01cfcb93e', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '2e194f2096a69bc691694be0ac49004a54aa3cde', class: 'password__wrapper--relative' }, this.tooltip &&
13430
+ index.h("img", { key: 'eafce2331ec867fcd8abc253d3605f5214557b8b', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("vaadin-password-field", { key: '0f1c9cd805fd9794de896c33a85abe12c9473d00', type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, readOnly: this.autofilled, value: this.defaultValue, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.placeholder}`, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus }), !this.noValidation && index.h("small", { key: 'd20a6946d4757da4311f33b2770079cc7f80bcfa', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity &&
13431
+ this.showPopup &&
13432
+ !this.hidePasswordComplexity &&
13433
+ !this.isDuplicateInput &&
13434
+ (this.enableSouthAfricanMode
13435
+ ? this.renderCustomComplexityPopup()
13436
+ : this.renderComplexityPopup()));
13314
13437
  }
13315
13438
  get element() { return index.getElement(this); }
13316
13439
  static get watchers() { return {
@@ -14180,24 +14303,28 @@ const TextInput = class {
14180
14303
  this.postalcodelength = 5;
14181
14304
  this.touched = false;
14182
14305
  this.handleInput = (event) => {
14183
- this.value = event.target.value;
14306
+ const input = event.target;
14307
+ const normalizedValue = this.enableSouthAfricanMode &&
14308
+ (this.name === CONSTANTS.FIRSTNAME_ON_DOCUMENT ||
14309
+ this.name === CONSTANTS.LASTNAME_ON_DOCUMENT)
14310
+ ? input.value.replace(CONSTANTS.NON_LETTERS_REGEX, '')
14311
+ : input.value;
14312
+ if (normalizedValue !== input.value) {
14313
+ input.value = normalizedValue;
14314
+ }
14315
+ this.value = normalizedValue;
14184
14316
  this.touched = true;
14185
- if (this.debounceTime) {
14317
+ if (this.debounceTime)
14186
14318
  clearTimeout(this.debounceTime);
14187
- }
14188
14319
  this.debounceTime = setTimeout(() => {
14189
- this.isValid = this.setValidity();
14190
- this.errorMessage = this.setErrorMessage();
14191
- this.validityStateHandler({ valid: this.isValid, name: this.name });
14320
+ this.updateValidationState();
14192
14321
  this.emitValueHandler(true);
14193
14322
  }, 500);
14194
14323
  };
14195
14324
  this.handleBlur = (event) => {
14196
14325
  this.value = event.target.value;
14197
14326
  this.touched = true;
14198
- this.isValid = this.setValidity();
14199
- this.errorMessage = this.setErrorMessage();
14200
- this.validityStateHandler({ valid: this.isValid, name: this.name });
14327
+ this.updateValidationState();
14201
14328
  };
14202
14329
  this.setClientStyling = () => {
14203
14330
  let sheet = document.createElement('style');
@@ -14217,6 +14344,7 @@ const TextInput = class {
14217
14344
  this.isDuplicateInput = undefined;
14218
14345
  this.clientStyling = '';
14219
14346
  this.haspostalcodelookup = undefined;
14347
+ this.enableSouthAfricanMode = undefined;
14220
14348
  this.isValid = undefined;
14221
14349
  this.errorMessage = '';
14222
14350
  this.limitStylingAppends = false;
@@ -14254,15 +14382,13 @@ const TextInput = class {
14254
14382
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
14255
14383
  this.duplicateInputValue = event.detail.value;
14256
14384
  if (this.touched) {
14257
- this.isValid = this.setValidity();
14258
- this.errorMessage = this.setErrorMessage();
14385
+ this.updateValidationState();
14259
14386
  }
14260
14387
  }
14261
- if (this.name === event.detail.name + 'Duplicate'
14262
- && this.name.replace('Duplicate', '') === event.detail.name
14263
- && this.touched === true) {
14264
- this.isValid = this.setValidity();
14265
- this.errorMessage = this.setErrorMessage();
14388
+ if (this.name === event.detail.name + 'Duplicate' &&
14389
+ this.name.replace('Duplicate', '') === event.detail.name &&
14390
+ this.touched) {
14391
+ this.updateValidationState();
14266
14392
  }
14267
14393
  }
14268
14394
  handleValidationChange(event) {
@@ -14272,7 +14398,7 @@ const TextInput = class {
14272
14398
  this.validation = event.detail.validation;
14273
14399
  this.validationPattern = this.setPattern();
14274
14400
  if (this.touched) {
14275
- this.isValid = this.setValidity();
14401
+ this.isValid = this.isValidValue();
14276
14402
  this.errorMessage = this.setErrorMessage();
14277
14403
  }
14278
14404
  }
@@ -14308,13 +14434,37 @@ const TextInput = class {
14308
14434
  }
14309
14435
  this.value = newValue;
14310
14436
  this.touched = true;
14311
- this.isValid = true;
14312
- this.valueHandler({ name: this.name, value: newValue });
14313
- this.validityStateHandler({ valid: true, name: this.name });
14437
+ this.updateValidationState();
14314
14438
  }
14315
14439
  connectedCallback() {
14316
14440
  this.validationPattern = this.setPattern();
14317
14441
  }
14442
+ handleExternalDocUpdate(event) {
14443
+ if (this.name !== CONSTANTS.DOCUMENT_NUMBER)
14444
+ return;
14445
+ this.value = event.detail || "";
14446
+ this.touched = true;
14447
+ if (this.inputReference) {
14448
+ this.inputReference.value = this.value;
14449
+ }
14450
+ this.sendInputValue.emit({
14451
+ name: this.name,
14452
+ value: this.value
14453
+ });
14454
+ this.updateValidationState();
14455
+ }
14456
+ handleDocReset() {
14457
+ if (this.name !== CONSTANTS.DOCUMENT_NUMBER)
14458
+ return;
14459
+ this.value = "";
14460
+ this.touched = false;
14461
+ this.isValid = false;
14462
+ this.errorMessage = "";
14463
+ if (this.inputReference) {
14464
+ this.inputReference.value = "";
14465
+ }
14466
+ this.validityStateHandler({ valid: false, name: this.name });
14467
+ }
14318
14468
  componentDidRender() {
14319
14469
  // start custom styling area
14320
14470
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -14331,6 +14481,7 @@ const TextInput = class {
14331
14481
  }
14332
14482
  componentDidLoad() {
14333
14483
  if (this.defaultValue) {
14484
+ this.value = this.defaultValue;
14334
14485
  this.valueHandler({ name: this.name, value: this.value });
14335
14486
  if (this.isDuplicateInput) {
14336
14487
  this.touched = true;
@@ -14342,18 +14493,49 @@ const TextInput = class {
14342
14493
  window.targetInputRefs[this.name] = this.inputReference;
14343
14494
  }
14344
14495
  }
14345
- this.isValid = this.setValidity();
14496
+ this.isValid = this.isValidValue();
14346
14497
  }
14347
- setValidity() {
14498
+ validateDocument(valueRaw, docType) {
14499
+ const value = valueRaw.trim();
14500
+ if (docType === CONSTANTS.PASSPORT) {
14501
+ const valid = CONSTANTS.PASSPORT_NUMERIC_REGEX.test(value);
14502
+ return valid
14503
+ ? { valid: true }
14504
+ : { valid: false, errorKey: ERROR_KEYS.PASSPORT_INVALID };
14505
+ }
14506
+ if (docType === CONSTANTS.SOUTH_AFRICAN_ID) {
14507
+ if (value.length !== CONSTANTS.SOUTH_AFRICAN_ID_LENGTH) {
14508
+ return { valid: false, errorKey: ERROR_KEYS.SA_ID_LENGTH };
14509
+ }
14510
+ const valid = validateID(value);
14511
+ return valid
14512
+ ? { valid: true }
14513
+ : { valid: false, errorKey: ERROR_KEYS.SA_ID_INVALID };
14514
+ }
14515
+ return { valid: true };
14516
+ }
14517
+ updateValidationState() {
14518
+ const nextValid = this.isValidValue();
14519
+ this.isValid = nextValid;
14520
+ if (!this.touched) {
14521
+ this.errorMessage = '';
14522
+ return;
14523
+ }
14524
+ this.errorMessage = nextValid ? '' : this.setErrorMessage();
14525
+ }
14526
+ isValidValue() {
14348
14527
  if (!this.inputReference) {
14349
14528
  return false;
14350
14529
  }
14351
- if (this.value.trim() === "" && !this.validation.mandatory) {
14352
- return true;
14530
+ if (this.enableSouthAfricanMode && this.name === CONSTANTS.DOCUMENT_NUMBER) {
14531
+ const docType = window.documentTypeValue;
14532
+ return this.validateDocument(this.value, docType).valid;
14353
14533
  }
14354
- const inputIsValid = this.inputReference.validity.valid;
14355
- const inputMatchValidation = !this.inputReference.value || this.inputReference.value.match(this.validationPattern) !== null;
14356
- return inputIsValid && inputMatchValidation;
14534
+ const fallbackResult = (this.value.trim() === "" && !this.validation.mandatory) ||
14535
+ (this.inputReference.validity.valid &&
14536
+ (!this.inputReference.value ||
14537
+ this.inputReference.value.match(this.validationPattern) !== null));
14538
+ return fallbackResult;
14357
14539
  }
14358
14540
  setPattern() {
14359
14541
  var _a, _b;
@@ -14363,14 +14545,25 @@ const TextInput = class {
14363
14545
  }
14364
14546
  setErrorMessage() {
14365
14547
  var _a, _b, _c, _d;
14366
- if (this.value.trim() === "" && !this.validation.mandatory) {
14548
+ const value = this.value.trim();
14549
+ if (this.enableSouthAfricanMode && this.name === CONSTANTS.DOCUMENT_NUMBER) {
14550
+ const docType = window.documentTypeValue;
14551
+ const res = this.validateDocument(this.value, docType);
14552
+ return res.valid ? '' : translate(res.errorKey, this.language);
14553
+ }
14554
+ if (value === "" && !this.validation.mandatory) {
14367
14555
  return "";
14368
14556
  }
14369
14557
  if (this.inputReference.validity.valueMissing) {
14370
- return translate('requiredError', this.language);
14558
+ return translate(ERROR_KEYS.REQUIRED, this.language);
14371
14559
  }
14372
14560
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
14373
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
14561
+ return translate(ERROR_KEYS.LENGTH, this.language, {
14562
+ values: {
14563
+ minLength: this.validation.minLength,
14564
+ maxLength: this.validation.maxLength
14565
+ }
14566
+ });
14374
14567
  }
14375
14568
  if (this.inputReference.value.match(this.validationPattern) == null) {
14376
14569
  const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
@@ -14382,6 +14575,7 @@ const TextInput = class {
14382
14575
  const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
14383
14576
  return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
14384
14577
  }
14578
+ return "";
14385
14579
  }
14386
14580
  renderTooltip() {
14387
14581
  if (this.showTooltip) {
@@ -14394,8 +14588,8 @@ const TextInput = class {
14394
14588
  if (this.touched) {
14395
14589
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
14396
14590
  }
14397
- return index.h("div", { key: '46152e946f6a45c2bb07ee07c43bcf356f3cfa29', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, index.h("div", { key: 'f584f23ee97b9a1d23862ec746366d5f00c56552', class: 'text__wrapper--flex' }, index.h("label", { key: 'ed9fe368bd00151d8b3e43daf148632cfe7d32ff', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '01cd5f7321d78422049c45b1816801eca74d2b4d', class: 'text__wrapper--relative' }, this.tooltip &&
14398
- index.h("img", { key: '403689aa01575770be4296aaef0c7846e496d6a7', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("input", { key: '5ec8443fd428ea00b9add243ea74e61fbd5b283a', name: this.name, id: `${this.name}__input`, value: this.value, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.placeholder}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur }), index.h("small", { key: 'd1eb4cf6ac28fff4664a56e27c9f2a21d72b0d61', class: 'text__error-message' }, this.errorMessage));
14591
+ return index.h("div", { key: '5b0bf10acadab5c3362d185cef10c5ed4f3a6a47', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, index.h("div", { key: '6d79cc845aac8d9b11737d35571680d7701c4b94', class: 'text__wrapper--flex' }, index.h("label", { key: 'de687661fa037d691fe1da1231b651f564bca010', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '4d9b12a587267eaf6fab4c4f3c38befb8d5c2b99', class: 'text__wrapper--relative' }, this.tooltip &&
14592
+ index.h("img", { key: '7f27a118124cd0407b6c2644137a79eaa0496164', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("input", { key: '94a614815155465dbfef2a7cc1cb788bb14d1498', name: this.name, id: `${this.name}__input`, value: this.value, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.placeholder}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, required: this.validation.mandatory, minlength: this.enableSouthAfricanMode ? '' : this.validation.minLength, maxlength: this.enableSouthAfricanMode ? '' : this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur }), index.h("small", { key: 'b9b3bdcd9cb81b56dc25a208b0c1d7784d06b5e0', class: 'text__error-message' }, this.errorMessage));
14399
14593
  }
14400
14594
  static get watchers() { return {
14401
14595
  "clientStyling": ["handleStylingChange"],
@@ -14580,20 +14774,24 @@ const TwofaInput = class {
14580
14774
  this.handleInput = (e, idx) => {
14581
14775
  const input = e.target;
14582
14776
  const value = input.value;
14583
- if (value.length > 1) {
14584
- input.value = value.charAt(1);
14585
- }
14586
- else {
14587
- input.value = value.charAt(0);
14588
- }
14589
- if (!value) {
14777
+ const char = value.slice(-1);
14778
+ input.value = char;
14779
+ if (!char)
14590
14780
  return;
14781
+ this.code[idx] = char;
14782
+ // --- Hide pin code --- //
14783
+ if (this.enableSouthAfricanMode) {
14784
+ // show character for 500ms
14785
+ this.revealedIndexes = [idx];
14786
+ if (this.revealTimeout)
14787
+ clearTimeout(this.revealTimeout);
14788
+ this.revealTimeout = setTimeout(() => {
14789
+ this.revealedIndexes = [];
14790
+ }, 500);
14591
14791
  }
14592
- this.code[idx] = input.value;
14593
14792
  const nextInput = this.inputRefs[idx + 1];
14594
- if (nextInput) {
14793
+ if (nextInput)
14595
14794
  nextInput.focus();
14596
- }
14597
14795
  this.setValidity();
14598
14796
  this.setErrorMessage();
14599
14797
  };
@@ -14622,6 +14820,8 @@ const TwofaInput = class {
14622
14820
  this.destination = '';
14623
14821
  this.resendIntervalSeconds = 60;
14624
14822
  this.clientStyling = '';
14823
+ this.enableSouthAfricanMode = undefined;
14824
+ this.pinAttemptsExceeded = undefined;
14625
14825
  this.clientStylingUrl = '';
14626
14826
  this.mbSource = undefined;
14627
14827
  this.limitStylingAppends = false;
@@ -14631,10 +14831,7 @@ const TwofaInput = class {
14631
14831
  this.errorMessage = '';
14632
14832
  this.code = [];
14633
14833
  this.resendIntervalSecondsLeft = this.resendIntervalSeconds;
14634
- }
14635
- handleStylingChange(newValue, oldValue) {
14636
- if (newValue !== oldValue)
14637
- this.setClientStyling();
14834
+ this.revealedIndexes = [];
14638
14835
  }
14639
14836
  validityChanged() {
14640
14837
  this.validityStateHandler({ valid: this.isValid, name: this.name });
@@ -14663,6 +14860,10 @@ const TwofaInput = class {
14663
14860
  this.showTooltip = false;
14664
14861
  }
14665
14862
  }
14863
+ handleStylingChange(newValue, oldValue) {
14864
+ if (newValue !== oldValue)
14865
+ this.setClientStyling();
14866
+ }
14666
14867
  connectedCallback() {
14667
14868
  this.validationPattern = this.setPattern();
14668
14869
  this.code = new Array(this.validation.maxLength).fill('');
@@ -14697,37 +14898,51 @@ const TwofaInput = class {
14697
14898
  }
14698
14899
  handleKeyDown(e, idx) {
14699
14900
  if (e.key === 'Backspace') {
14700
- this.code[idx] = '';
14701
- if (this.inputRefs[idx]) {
14702
- this.inputRefs[idx].value = '';
14703
- } // Clear input field
14704
- const prevInput = this.inputRefs[idx - 1];
14705
- if (prevInput) {
14706
- prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14901
+ const newCode = [...this.code];
14902
+ newCode[idx] = '';
14903
+ this.code = newCode;
14904
+ if (this.enableSouthAfricanMode) {
14905
+ this.revealedIndexes = this.revealedIndexes.filter(i => i !== idx);
14707
14906
  }
14907
+ const prevInput = this.inputRefs[idx - 1];
14908
+ prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14708
14909
  }
14709
14910
  this.setValidity();
14710
14911
  this.setErrorMessage();
14711
14912
  }
14712
14913
  handlePaste(e) {
14713
- var _a;
14914
+ var _a, _b;
14714
14915
  e.preventDefault();
14715
- const data = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text').trim();
14716
- if (!data) {
14916
+ const data = (_b = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text')) === null || _b === void 0 ? void 0 : _b.trim();
14917
+ if (!data)
14717
14918
  return;
14919
+ const value = data.slice(0, this.validation.maxLength).split('');
14920
+ this.code = [
14921
+ ...value,
14922
+ ...new Array(this.validation.maxLength - value.length).fill('')
14923
+ ];
14924
+ if (this.enableSouthAfricanMode) {
14925
+ this.revealedIndexes = value.map((_, i) => i);
14926
+ if (this.revealTimeout)
14927
+ clearTimeout(this.revealTimeout);
14928
+ this.revealTimeout = setTimeout(() => {
14929
+ this.revealedIndexes = [];
14930
+ }, 500);
14718
14931
  }
14719
- const value = data.slice(0, this.validation.maxLength).split(''); // Limit to OTP length
14720
- this.code = [...value, ...new Array(this.validation.maxLength - value.length).fill('')];
14721
- value.forEach((char, index) => {
14722
- this.inputRefs[index].value = char;
14723
- });
14724
- // Move focus to the last input or trigger submit
14725
14932
  const lastInput = this.inputRefs[Math.min(value.length, this.inputRefs.length - 1)];
14726
- if (lastInput) {
14727
- lastInput.focus();
14728
- }
14933
+ lastInput === null || lastInput === void 0 ? void 0 : lastInput.focus();
14729
14934
  this.setValidity();
14730
14935
  this.setErrorMessage();
14936
+ if (this.enableSouthAfricanMode) {
14937
+ this.valueHandler({
14938
+ name: this.name,
14939
+ value: this.code.join('')
14940
+ });
14941
+ this.validityStateHandler({
14942
+ valid: this.isValid,
14943
+ name: this.name
14944
+ });
14945
+ }
14731
14946
  }
14732
14947
  setValidity() {
14733
14948
  const code = this.code.join('');
@@ -14760,19 +14975,28 @@ const TwofaInput = class {
14760
14975
  }
14761
14976
  return null;
14762
14977
  }
14978
+ getInputDisplayValue(idx) {
14979
+ const current = this.code[idx];
14980
+ if (!current)
14981
+ return "";
14982
+ if (this.enableSouthAfricanMode) {
14983
+ return this.revealedIndexes.includes(idx) ? current : "*";
14984
+ }
14985
+ return current;
14986
+ }
14763
14987
  render() {
14764
- return (index.h("div", { key: '45f0c8c7d88898a5474bff460ce962e8bb1e8634', class: "twofa", ref: el => this.stylingContainer = el }, index.h("div", { key: 'b40e81587ad9c7b67c112c8867104e761db7e3bc', class: 'twofa__error-message' }, index.h("p", { key: '760c694f6f71f040e85f81a67d3d41524c23130f' }, this.errorMessage)), index.h("div", { key: '2b437a5108e3989d2ddf596dc4a97d2071448154', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), index.h("div", { key: '84df3ebbe4077ba8462c08cc7956349ec4a55b79', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14765
- return (index.h("input", { key: idx, ref: el => this.setInputRef(el, idx), id: `otp-input-${idx}`, type: "text", maxLength: 2, value: char, onInput: (event) => this.handleInput(event, idx), onKeyDown: (event) => this.handleKeyDown(event, idx), onPaste: (event) => this.handlePaste(event) }));
14766
- })), index.h("div", { key: 'abdf6e2a3ff7ef6436b59206c40ada5305543db3', class: "twofa__button-wrapper" }, index.h("p", { key: 'e0859c58e48741eb379fbcaf23519bb90404489b', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), index.h("button", { key: '89aa3a93a9b97029fd315450892cef5edd5d5294', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14988
+ return (index.h("div", { key: '56a639eb6e240482078fc7aaf688c75ae3de04c8', class: "twofa", ref: el => this.stylingContainer = el }, index.h("div", { key: 'a64039a3ed66556a0dc1bbac7b6fd6d60de23fa3', class: 'twofa__error-message' }, index.h("p", { key: '21adf57c840d51714ab097e9df3cc77e22be611f' }, this.errorMessage)), index.h("div", { key: '6653201178b40bc1eb5d6e7d881f2bbe150901f3', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), index.h("div", { key: 'ca7600034af473838b741d5be4fe72ded9937647', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((_, idx) => {
14989
+ return (index.h("input", { key: idx, ref: el => this.setInputRef(el, idx), id: `otp-input-${idx}`, type: "text", maxLength: 2, value: this.getInputDisplayValue(idx), onInput: (event) => this.handleInput(event, idx), onKeyDown: (event) => this.handleKeyDown(event, idx), onPaste: (event) => this.handlePaste(event) }));
14990
+ })), index.h("div", { key: '0ecd60dd5e6b3f6c3a86176e1937e7aeeffc0e92', class: "twofa__button-wrapper" }, index.h("p", { key: 'fa9608598580bb8628d0e7a208cc69e3ebe83264', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), index.h("button", { key: 'c70ea6e780eefc8fef0002fdcc10286ae0e66619', class: `twofa__resend-button ${this.pinAttemptsExceeded ? 'twofa__resend-button--disabled' : ''}`, onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable || this.pinAttemptsExceeded }, this.isResendButtonAvailable
14767
14991
  ? translate('twofaResendButton', this.language)
14768
14992
  : this.formatTime()))));
14769
14993
  }
14770
14994
  get host() { return index.getElement(this); }
14771
14995
  static get watchers() { return {
14772
- "clientStyling": ["handleStylingChange"],
14773
14996
  "isValid": ["validityChanged"],
14774
14997
  "emitValue": ["emitValueHandler"],
14775
- "clientStylingUrl": ["handleStylingUrlChange"]
14998
+ "clientStylingUrl": ["handleStylingUrlChange"],
14999
+ "clientStyling": ["handleStylingChange"]
14776
15000
  }; }
14777
15001
  };
14778
15002
  TwofaInput.style = TwofaInputStyle0;