@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.
@@ -31,6 +31,10 @@ const TRANSLATIONS = {
31
31
  "enterIEAddressManually": "For IRE, enter the address manually",
32
32
  "postalLookUpNoAddressFound": "No addresses found for this postal code",
33
33
  "searchingForAddresses": "Searching for addresses...",
34
+ "SAIdLengthError": "SA ID must be 13 digits",
35
+ "SAIdInvalidError": "Invalid SA ID",
36
+ "PassportLengthError": "Passport number must be 8 or 9 digits.",
37
+ "PasswordMustContain": "Password must contain:"
34
38
  },
35
39
  "hu": {
36
40
  "dateError": "A választott dátumnak {min} és {max} között kell lennie",
@@ -57,7 +61,11 @@ const TRANSLATIONS = {
57
61
  "InvalidDocumentNumber": "Csak számjegyek engedélyezettek.",
58
62
  "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>",
59
63
  "twofaResendMessage": "Nem kapta meg a megerősítő kódot?",
60
- "twofaResendButton": "Újraküldés"
64
+ "twofaResendButton": "Újraküldés",
65
+ "PassportLengthError": "Az útlevélszámnak 9 számjegyűnek kell lennie",
66
+ "SAIdLengthError": "A dél-afrikai személyi számnak 13 számjegyűnek kell lennie",
67
+ "SAIdInvalidError": "Érvénytelen dél-afrikai személyi szám",
68
+ "PasswordMustContain": "A jelszónak tartalmaznia kell:"
61
69
  },
62
70
  "hr": {
63
71
  "dateError": "Odabrani datum treba biti između {min} i {max}",
@@ -84,7 +92,11 @@ const TRANSLATIONS = {
84
92
  "InvalidDocumentNumber": "Dopušteni su samo numerički znakovi.",
85
93
  "twofaDescription": "<p> Poslali smo verifikacijski kod na: <p> {destination}. </p> </p> <p> Molimo unesite PIN ispod. </p>",
86
94
  "twofaResendMessage": "Niste primili verifikacijski kod?",
87
- "twofaResendButton": "Ponovno pošalji"
95
+ "twofaResendButton": "Ponovno pošalji",
96
+ "PassportLengthError": "Broj putovnice mora imati 9 znamenki",
97
+ "SAIdLengthError": "Južnoafrički osobni broj mora imati 13 znamenki",
98
+ "SAIdInvalidError": "Nevažeći južnoafrički osobni broj",
99
+ "PasswordMustContain": "Lozinka mora sadržavati:"
88
100
  },
89
101
  "tr": {
90
102
  "dateError": "Seçilen tarih {min} ve {max} arasında olmalıdır",
@@ -111,7 +123,11 @@ const TRANSLATIONS = {
111
123
  "InvalidDocumentNumber": "Sadece sayısal karakterlere izin verilir.",
112
124
  "twofaDescription": "<p> Doğrulama kodunu şu adrese gönderdik: <p> {destination}. </p> </p> <p> Lütfen aşağıya PIN kodunu girin. </p>",
113
125
  "twofaResendMessage": "Doğrulama kodunu almadınız mı?",
114
- "twofaResendButton": "Yeniden gönder"
126
+ "twofaResendButton": "Yeniden gönder",
127
+ "PassportLengthError": "Pasaport numarası 9 haneli olmalıdır",
128
+ "SAIdLengthError": "Güney Afrika kimlik numarası 13 haneli olmalıdır",
129
+ "SAIdInvalidError": "Geçersiz Güney Afrika kimlik numarası",
130
+ "PasswordMustContain": "Şifre şunları içermelidir:"
115
131
  },
116
132
  "pt-br": {
117
133
  "dateError": "A data selecionada deve estar entre {min} e {max}",
@@ -138,7 +154,11 @@ const TRANSLATIONS = {
138
154
  "InvalidDocumentNumber": "Apenas caracteres numéricos são permitidos.",
139
155
  "twofaDescription": "<p> Enviamos o código de verificação para: <p> {destination}. </p> </p> <p> Por favor, insira o PIN abaixo. </p>",
140
156
  "twofaResendMessage": "Não recebeu o código de verificação?",
141
- "twofaResendButton": "Reenviar"
157
+ "twofaResendButton": "Reenviar",
158
+ "PassportLengthError": "O número do passaporte deve ter 9 dígitos",
159
+ "SAIdLengthError": "O número de identificação da África do Sul deve ter 13 dígitos",
160
+ "SAIdInvalidError": "Número de identificação da África do Sul inválido",
161
+ "PasswordMustContain": "A senha deve conter:"
142
162
  },
143
163
  "es-mx": {
144
164
  "dateError": "La fecha seleccionada debe ser entre {min} y {max}",
@@ -165,9 +185,40 @@ const TRANSLATIONS = {
165
185
  "InvalidDocumentNumber": "Solo se permiten caracteres numéricos.",
166
186
  "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>",
167
187
  "twofaResendMessage": "¿No recibiste el código de verificación?",
168
- "twofaResendButton": "Reenviar"
188
+ "twofaResendButton": "Reenviar",
189
+ "PassportLengthError": "El número de pasaporte debe tener 9 dígitos",
190
+ "SAIdLengthError": "El número de identificación de Sudáfrica debe tener 13 dígitos",
191
+ "SAIdInvalidError": "Número de identificación de Sudáfrica inválido",
192
+ "PasswordMustContain": "La contraseña debe contener:"
169
193
  }
170
194
  };
195
+ const CONSTANTS = {
196
+ DOCUMENT_NUMBER: "DocumentNumber",
197
+ FIRSTNAME_ON_DOCUMENT: "FirstnameOnDocument",
198
+ LASTNAME_ON_DOCUMENT: "LastnameOnDocument",
199
+ PASSPORT: "Passport",
200
+ SOUTH_AFRICAN_ID: "SouthAfricanID",
201
+ BIRTHDATE: "BirthDate",
202
+ PASSPORT_NUMERIC_REGEX: /^\d{8,9}$/,
203
+ SA_ID_BASIC_REGEX: /^\d{13}$/,
204
+ SOUTH_AFRICAN_ID_LENGTH: 13,
205
+ NON_LETTERS_REGEX: /[^A-Za-z]/g,
206
+ DATE_FORMAT: "yyyy-MM-dd",
207
+ PASSWORD_COMPLEXITY_PASSED: "passed",
208
+ PASSWORD_COMPLEXITY_FAILED: "failed"
209
+ };
210
+ const ERROR_KEYS = {
211
+ PASSPORT_INVALID: 'PassportLengthError',
212
+ SA_ID_LENGTH: 'SAIdLengthError',
213
+ SA_ID_INVALID: 'SAIdInvalidError',
214
+ REQUIRED: 'requiredError',
215
+ LENGTH: 'lengthError',
216
+ DUPLICATE: 'duplicateInputError',
217
+ };
218
+ const STATUS_ICONS = {
219
+ PASSED: '✓',
220
+ FAILED: '✕',
221
+ };
171
222
  const translate = (key, customLang, values) => {
172
223
  const lang = customLang;
173
224
  let translation = TRANSLATIONS[lang !== undefined ? lang : DEFAULT_LANGUAGE][key];
@@ -194,6 +245,27 @@ const getTranslations = (url) => {
194
245
  });
195
246
  });
196
247
  };
248
+ const validateID = (id) => {
249
+ if (!CONSTANTS.SA_ID_BASIC_REGEX.test(id))
250
+ return false;
251
+ const digits = id.split("").map(n => parseInt(n, 10));
252
+ let oddSum = 0;
253
+ for (let i = 0; i < 12; i += 2) {
254
+ oddSum += digits[i];
255
+ }
256
+ let evenConcat = "";
257
+ for (let i = 1; i < 12; i += 2) {
258
+ evenConcat += digits[i];
259
+ }
260
+ const evenNumber = parseInt(evenConcat, 10) * 2;
261
+ const evenSum = evenNumber
262
+ .toString()
263
+ .split("")
264
+ .reduce((s, n) => s + parseInt(n, 10), 0);
265
+ const total = oddSum + evenSum;
266
+ let checkDigit = (10 - (total % 10)) % 10;
267
+ return checkDigit === digits[12];
268
+ };
197
269
 
198
270
  const tooltipIconSvg = 'data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iMTIiIGhlaWdodD0iMTIiIHZpZXdCb3g9IjAgMCAxMiAxMiIgZmlsbD0ibm9uZSIgeG1sbnM9Imh0dHA6Ly93d3cudzMub3JnLzIwMDAvc3ZnIj4KPGNpcmNsZSBjeD0iNiIgY3k9IjYiIHI9IjUuNSIgc3Ryb2tlPSIjOTc5Nzk3Ii8+CjxyZWN0IHg9IjUiIHk9IjUiIHdpZHRoPSIyIiBoZWlnaHQ9IjUiIGZpbGw9IiM5Nzk3OTciLz4KPGNpcmNsZSBjeD0iNiIgY3k9IjMiIHI9IjEiIGZpbGw9IiM5Nzk3OTciLz4KPC9zdmc+Cg==';
199
271
 
@@ -5817,6 +5889,21 @@ const DateInput = class {
5817
5889
  sheet.innerHTML = this.clientStyling;
5818
5890
  this.stylingContainer.prepend(sheet);
5819
5891
  };
5892
+ this.handleDocumentIdUpdate = (e) => {
5893
+ if (this.name !== CONSTANTS.BIRTHDATE) {
5894
+ return;
5895
+ }
5896
+ const dateStr = e.detail;
5897
+ this.value = dateStr;
5898
+ this.valueAsDate = parse(this.value || '', CONSTANTS.DATE_FORMAT, new Date());
5899
+ this.touched = true;
5900
+ if (this.datePicker) {
5901
+ this.datePicker.value = this.value;
5902
+ }
5903
+ this.isValid = this.setValidity();
5904
+ this.errorMessage = this.setErrorMessage();
5905
+ this.valueHandler({ name: this.name, value: this.value });
5906
+ };
5820
5907
  this.name = undefined;
5821
5908
  this.displayName = undefined;
5822
5909
  this.placeholder = undefined;
@@ -5829,6 +5916,7 @@ const DateInput = class {
5829
5916
  this.clientStyling = '';
5830
5917
  this.dateFormat = 'yyyy-MM-dd';
5831
5918
  this.emitOnClick = false;
5919
+ this.enableSouthAfricanMode = undefined;
5832
5920
  this.errorMessage = undefined;
5833
5921
  this.isValid = undefined;
5834
5922
  this.limitStylingAppends = false;
@@ -5858,6 +5946,14 @@ const DateInput = class {
5858
5946
  this.valueHandler({ name: this.name, value: this.value });
5859
5947
  }
5860
5948
  }
5949
+ handleCustomRegistrationChange(newValue) {
5950
+ if (newValue) {
5951
+ window.addEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
5952
+ }
5953
+ else {
5954
+ window.removeEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
5955
+ }
5956
+ }
5861
5957
  valueHandler(inputValueEvent) {
5862
5958
  this.sendInputValue.emit(inputValueEvent);
5863
5959
  }
@@ -5901,6 +5997,9 @@ const DateInput = class {
5901
5997
  }
5902
5998
  });
5903
5999
  }
6000
+ if (this.enableSouthAfricanMode) {
6001
+ window.addEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
6002
+ }
5904
6003
  this.datePicker.i18n = Object.assign(Object.assign({}, this.datePicker.i18n), { formatDate: this.formatDate, parseDate: this.parseDate });
5905
6004
  if (this.defaultValue) {
5906
6005
  this.value = this.defaultValue;
@@ -5908,6 +6007,11 @@ const DateInput = class {
5908
6007
  }
5909
6008
  this.isValid = this.setValidity();
5910
6009
  }
6010
+ disconnectedCallback() {
6011
+ if (this.enableSouthAfricanMode) {
6012
+ window.removeEventListener('documentIdUpdated', this.handleDocumentIdUpdate);
6013
+ }
6014
+ }
5911
6015
  handleCalendarIconClick() {
5912
6016
  if (this.datePicker.opened && this.emitOnClick) {
5913
6017
  window.postMessage({ type: `registration${this.name}Clicked` }, window.location.href);
@@ -5920,6 +6024,11 @@ const DateInput = class {
5920
6024
  this.isValid = this.setValidity();
5921
6025
  this.errorMessage = this.setErrorMessage();
5922
6026
  this.emitValueHandler(true);
6027
+ if (this.enableSouthAfricanMode) {
6028
+ window.dispatchEvent(new CustomEvent('birthDateUpdated', {
6029
+ detail: { birthDate: this.value }
6030
+ }));
6031
+ }
5923
6032
  }
5924
6033
  setValidity() {
5925
6034
  if (isBefore(this.valueAsDate, this.minDate) || isAfter(this.valueAsDate, this.maxDate) || !isMatch(this.formattedValue, this.dateFormat)) {
@@ -5954,14 +6063,15 @@ const DateInput = class {
5954
6063
  if (this.touched) {
5955
6064
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
5956
6065
  }
5957
- return h("div", { key: 'd9757eb7eea257167da12612f51f6665d6ac058e', class: `date__wrapper ${this.autofilled ? 'date__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("label", { key: '8339c9f27e74f2e1a98d11efea7eb05a9681e83e', class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), 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) }), h("small", { key: '19be9854df1adc1c6581e00a3593bcf16d7e2146', class: 'date__error-message' }, this.errorMessage), this.tooltip &&
5958
- h("img", { key: 'f38abc61046c33c56a9efc3907dbd184b8e8352e', class: 'date__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
6066
+ return h("div", { key: '9399c1be2edcbe3ed5c0e133cad52b1917e77e96', class: `date__wrapper ${this.autofilled ? 'date__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("label", { key: '1094491a5fc441c4f704441d376ed965d6946637', class: `date__label ${this.validation.mandatory ? 'date__label--required' : ''}}`, htmlFor: `${this.name}__input` }, this.displayName, " ", this.validation.mandatory ? '*' : ''), 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) }), h("small", { key: '67c1b6a0daafee536ab7179d1fe90a2870bb12b1', class: 'date__error-message' }, this.errorMessage), this.tooltip &&
6067
+ h("img", { key: '4d02f23affc8ce9f5eb41a44fd2f346960c6d458', class: 'date__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
5959
6068
  }
5960
6069
  get element() { return getElement(this); }
5961
6070
  static get watchers() { return {
5962
6071
  "clientStyling": ["handleStylingChange"],
5963
6072
  "isValid": ["validityChanged"],
5964
- "emitValue": ["emitValueHandler"]
6073
+ "emitValue": ["emitValueHandler"],
6074
+ "enableSouthAfricanMode": ["handleCustomRegistrationChange"]
5965
6075
  }; }
5966
6076
  };
5967
6077
  DateInput.style = DateInputStyle0;
@@ -12842,6 +12952,8 @@ const GeneralInput = class {
12842
12952
  this.postalcodelength = undefined;
12843
12953
  this.addresses = [];
12844
12954
  this.ignoreCountry = false;
12955
+ this.enableSouthAfricanMode = undefined;
12956
+ this.pinAttemptsExceeded = undefined;
12845
12957
  this.mbSource = undefined;
12846
12958
  this.limitStylingAppends = false;
12847
12959
  }
@@ -12885,7 +12997,7 @@ const GeneralInput = class {
12885
12997
  return 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 });
12886
12998
  }
12887
12999
  else {
12888
- return 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 });
13000
+ return 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 });
12889
13001
  }
12890
13002
  case 'email':
12891
13003
  return 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 });
@@ -12898,9 +13010,9 @@ const GeneralInput = class {
12898
13010
  case 'togglecheckbox':
12899
13011
  return 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 });
12900
13012
  case 'datetime':
12901
- return 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 });
13013
+ return 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 });
12902
13014
  case 'password':
12903
- return 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 });
13015
+ return 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 });
12904
13016
  case 'radio':
12905
13017
  return 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 });
12906
13018
  case 'tel':
@@ -12908,13 +13020,13 @@ const GeneralInput = class {
12908
13020
  case 'dropdown':
12909
13021
  return 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 });
12910
13022
  case 'twofa':
12911
- return 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 });
13023
+ return 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 });
12912
13024
  default:
12913
13025
  return h("p", null, "The ", this.type, " input type is not valid");
12914
13026
  }
12915
13027
  }
12916
13028
  render() {
12917
- return (h(Host, { key: '134ef4b9ef8814a9b77c5db5b5085b0fe4e79c92', class: `general-input--${this.name}`, onClick: this.handleClick }, this.renderInput()));
13029
+ return (h(Host, { key: '7d036183d9376203451d9805e76b608cfa63570b', class: `general-input--${this.name}`, onClick: this.handleClick }, this.renderInput()));
12918
13030
  }
12919
13031
  get host() { return getElement(this); }
12920
13032
  static get watchers() { return {
@@ -13062,7 +13174,7 @@ const NumberInput = class {
13062
13174
  };
13063
13175
  NumberInput.style = NumberInputStyle0;
13064
13176
 
13065
- 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}";
13177
+ 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}";
13066
13178
  const PasswordInputStyle0 = passwordInputCss;
13067
13179
 
13068
13180
  const PasswordInput = class {
@@ -13122,6 +13234,7 @@ const PasswordInput = class {
13122
13234
  this.isDuplicateInput = undefined;
13123
13235
  this.hidePasswordComplexity = false;
13124
13236
  this.clientStyling = '';
13237
+ this.enableSouthAfricanMode = undefined;
13125
13238
  this.isValid = undefined;
13126
13239
  this.errorMessage = undefined;
13127
13240
  this.limitStylingAppends = false;
@@ -13300,13 +13413,23 @@ const PasswordInput = class {
13300
13413
  return (h("div", { key: index }, h("input", { class: 'password__complexity--checkbox', type: "checkbox", checked: complexity.passed, disabled: true }), h("span", null, translate(`${complexity.ruleKey}`, this.language) ? translate(`${complexity.ruleKey}`, this.language) : complexity.rule)));
13301
13414
  }))));
13302
13415
  }
13416
+ renderCustomComplexityPopup() {
13417
+ return (h("div", { class: `customreg-password__complexity ${!this.showPopup ? 'customreg-password__complexity--hidden' : ''}` }, h("p", { class: 'customreg-password__complexity--title' }, translate('PasswordMustContain', this.language)), h("div", { class: 'customreg-password__complexity--rules' }, this.passwordComplexity.map((complexity, index) => (h("div", { class: 'customreg-password__complexity--rule', key: index }, h("span", { class: `customreg-password__complexity--icon ${complexity.passed
13418
+ ? CONSTANTS.PASSWORD_COMPLEXITY_PASSED : CONSTANTS.PASSWORD_COMPLEXITY_FAILED}` }, complexity.passed ? STATUS_ICONS.PASSED : STATUS_ICONS.FAILED), h("span", null, translate(complexity.ruleKey, this.language) || complexity.rule)))))));
13419
+ }
13303
13420
  render() {
13304
13421
  let invalidClass = '';
13305
13422
  if (this.touched) {
13306
13423
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13307
13424
  }
13308
- return h("div", { key: 'db7a6a87af3de451485c603a2f28f25806838d20', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '146ace196e1343f778232c0e2ff07556c0a09e1e', class: 'password__wrapper--flex' }, h("label", { key: '0d0cb672dfc7a43535a299b45752f43a87f73760', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '1eac72dfdadd0f50bd2db6b0fc44320dd2f287bf', class: 'password__wrapper--relative' }, this.tooltip &&
13309
- h("img", { key: 'bb327b9a403c1fc5628c4ba2da8d1a2b62888db5', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), 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 && h("small", { key: 'efadfea8911ba72161aef495d1fb5857f14a319b', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13425
+ return h("div", { key: 'c2dd473e71853ebb3d0b5b6245af606f75f8b479', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '4ba641a832be3b8efb1957af5f45eb7b7cc69adc', class: 'password__wrapper--flex' }, h("label", { key: 'a4440e8b59a743831fa833d8e1c680c01cfcb93e', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '2e194f2096a69bc691694be0ac49004a54aa3cde', class: 'password__wrapper--relative' }, this.tooltip &&
13426
+ h("img", { key: 'eafce2331ec867fcd8abc253d3605f5214557b8b', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), 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 && h("small", { key: 'd20a6946d4757da4311f33b2770079cc7f80bcfa', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity &&
13427
+ this.showPopup &&
13428
+ !this.hidePasswordComplexity &&
13429
+ !this.isDuplicateInput &&
13430
+ (this.enableSouthAfricanMode
13431
+ ? this.renderCustomComplexityPopup()
13432
+ : this.renderComplexityPopup()));
13310
13433
  }
13311
13434
  get element() { return getElement(this); }
13312
13435
  static get watchers() { return {
@@ -14176,24 +14299,28 @@ const TextInput = class {
14176
14299
  this.postalcodelength = 5;
14177
14300
  this.touched = false;
14178
14301
  this.handleInput = (event) => {
14179
- this.value = event.target.value;
14302
+ const input = event.target;
14303
+ const normalizedValue = this.enableSouthAfricanMode &&
14304
+ (this.name === CONSTANTS.FIRSTNAME_ON_DOCUMENT ||
14305
+ this.name === CONSTANTS.LASTNAME_ON_DOCUMENT)
14306
+ ? input.value.replace(CONSTANTS.NON_LETTERS_REGEX, '')
14307
+ : input.value;
14308
+ if (normalizedValue !== input.value) {
14309
+ input.value = normalizedValue;
14310
+ }
14311
+ this.value = normalizedValue;
14180
14312
  this.touched = true;
14181
- if (this.debounceTime) {
14313
+ if (this.debounceTime)
14182
14314
  clearTimeout(this.debounceTime);
14183
- }
14184
14315
  this.debounceTime = setTimeout(() => {
14185
- this.isValid = this.setValidity();
14186
- this.errorMessage = this.setErrorMessage();
14187
- this.validityStateHandler({ valid: this.isValid, name: this.name });
14316
+ this.updateValidationState();
14188
14317
  this.emitValueHandler(true);
14189
14318
  }, 500);
14190
14319
  };
14191
14320
  this.handleBlur = (event) => {
14192
14321
  this.value = event.target.value;
14193
14322
  this.touched = true;
14194
- this.isValid = this.setValidity();
14195
- this.errorMessage = this.setErrorMessage();
14196
- this.validityStateHandler({ valid: this.isValid, name: this.name });
14323
+ this.updateValidationState();
14197
14324
  };
14198
14325
  this.setClientStyling = () => {
14199
14326
  let sheet = document.createElement('style');
@@ -14213,6 +14340,7 @@ const TextInput = class {
14213
14340
  this.isDuplicateInput = undefined;
14214
14341
  this.clientStyling = '';
14215
14342
  this.haspostalcodelookup = undefined;
14343
+ this.enableSouthAfricanMode = undefined;
14216
14344
  this.isValid = undefined;
14217
14345
  this.errorMessage = '';
14218
14346
  this.limitStylingAppends = false;
@@ -14250,15 +14378,13 @@ const TextInput = class {
14250
14378
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
14251
14379
  this.duplicateInputValue = event.detail.value;
14252
14380
  if (this.touched) {
14253
- this.isValid = this.setValidity();
14254
- this.errorMessage = this.setErrorMessage();
14381
+ this.updateValidationState();
14255
14382
  }
14256
14383
  }
14257
- if (this.name === event.detail.name + 'Duplicate'
14258
- && this.name.replace('Duplicate', '') === event.detail.name
14259
- && this.touched === true) {
14260
- this.isValid = this.setValidity();
14261
- this.errorMessage = this.setErrorMessage();
14384
+ if (this.name === event.detail.name + 'Duplicate' &&
14385
+ this.name.replace('Duplicate', '') === event.detail.name &&
14386
+ this.touched) {
14387
+ this.updateValidationState();
14262
14388
  }
14263
14389
  }
14264
14390
  handleValidationChange(event) {
@@ -14268,7 +14394,7 @@ const TextInput = class {
14268
14394
  this.validation = event.detail.validation;
14269
14395
  this.validationPattern = this.setPattern();
14270
14396
  if (this.touched) {
14271
- this.isValid = this.setValidity();
14397
+ this.isValid = this.isValidValue();
14272
14398
  this.errorMessage = this.setErrorMessage();
14273
14399
  }
14274
14400
  }
@@ -14304,13 +14430,37 @@ const TextInput = class {
14304
14430
  }
14305
14431
  this.value = newValue;
14306
14432
  this.touched = true;
14307
- this.isValid = true;
14308
- this.valueHandler({ name: this.name, value: newValue });
14309
- this.validityStateHandler({ valid: true, name: this.name });
14433
+ this.updateValidationState();
14310
14434
  }
14311
14435
  connectedCallback() {
14312
14436
  this.validationPattern = this.setPattern();
14313
14437
  }
14438
+ handleExternalDocUpdate(event) {
14439
+ if (this.name !== CONSTANTS.DOCUMENT_NUMBER)
14440
+ return;
14441
+ this.value = event.detail || "";
14442
+ this.touched = true;
14443
+ if (this.inputReference) {
14444
+ this.inputReference.value = this.value;
14445
+ }
14446
+ this.sendInputValue.emit({
14447
+ name: this.name,
14448
+ value: this.value
14449
+ });
14450
+ this.updateValidationState();
14451
+ }
14452
+ handleDocReset() {
14453
+ if (this.name !== CONSTANTS.DOCUMENT_NUMBER)
14454
+ return;
14455
+ this.value = "";
14456
+ this.touched = false;
14457
+ this.isValid = false;
14458
+ this.errorMessage = "";
14459
+ if (this.inputReference) {
14460
+ this.inputReference.value = "";
14461
+ }
14462
+ this.validityStateHandler({ valid: false, name: this.name });
14463
+ }
14314
14464
  componentDidRender() {
14315
14465
  // start custom styling area
14316
14466
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -14327,6 +14477,7 @@ const TextInput = class {
14327
14477
  }
14328
14478
  componentDidLoad() {
14329
14479
  if (this.defaultValue) {
14480
+ this.value = this.defaultValue;
14330
14481
  this.valueHandler({ name: this.name, value: this.value });
14331
14482
  if (this.isDuplicateInput) {
14332
14483
  this.touched = true;
@@ -14338,18 +14489,49 @@ const TextInput = class {
14338
14489
  window.targetInputRefs[this.name] = this.inputReference;
14339
14490
  }
14340
14491
  }
14341
- this.isValid = this.setValidity();
14492
+ this.isValid = this.isValidValue();
14342
14493
  }
14343
- setValidity() {
14494
+ validateDocument(valueRaw, docType) {
14495
+ const value = valueRaw.trim();
14496
+ if (docType === CONSTANTS.PASSPORT) {
14497
+ const valid = CONSTANTS.PASSPORT_NUMERIC_REGEX.test(value);
14498
+ return valid
14499
+ ? { valid: true }
14500
+ : { valid: false, errorKey: ERROR_KEYS.PASSPORT_INVALID };
14501
+ }
14502
+ if (docType === CONSTANTS.SOUTH_AFRICAN_ID) {
14503
+ if (value.length !== CONSTANTS.SOUTH_AFRICAN_ID_LENGTH) {
14504
+ return { valid: false, errorKey: ERROR_KEYS.SA_ID_LENGTH };
14505
+ }
14506
+ const valid = validateID(value);
14507
+ return valid
14508
+ ? { valid: true }
14509
+ : { valid: false, errorKey: ERROR_KEYS.SA_ID_INVALID };
14510
+ }
14511
+ return { valid: true };
14512
+ }
14513
+ updateValidationState() {
14514
+ const nextValid = this.isValidValue();
14515
+ this.isValid = nextValid;
14516
+ if (!this.touched) {
14517
+ this.errorMessage = '';
14518
+ return;
14519
+ }
14520
+ this.errorMessage = nextValid ? '' : this.setErrorMessage();
14521
+ }
14522
+ isValidValue() {
14344
14523
  if (!this.inputReference) {
14345
14524
  return false;
14346
14525
  }
14347
- if (this.value.trim() === "" && !this.validation.mandatory) {
14348
- return true;
14526
+ if (this.enableSouthAfricanMode && this.name === CONSTANTS.DOCUMENT_NUMBER) {
14527
+ const docType = window.documentTypeValue;
14528
+ return this.validateDocument(this.value, docType).valid;
14349
14529
  }
14350
- const inputIsValid = this.inputReference.validity.valid;
14351
- const inputMatchValidation = !this.inputReference.value || this.inputReference.value.match(this.validationPattern) !== null;
14352
- return inputIsValid && inputMatchValidation;
14530
+ const fallbackResult = (this.value.trim() === "" && !this.validation.mandatory) ||
14531
+ (this.inputReference.validity.valid &&
14532
+ (!this.inputReference.value ||
14533
+ this.inputReference.value.match(this.validationPattern) !== null));
14534
+ return fallbackResult;
14353
14535
  }
14354
14536
  setPattern() {
14355
14537
  var _a, _b;
@@ -14359,14 +14541,25 @@ const TextInput = class {
14359
14541
  }
14360
14542
  setErrorMessage() {
14361
14543
  var _a, _b, _c, _d;
14362
- if (this.value.trim() === "" && !this.validation.mandatory) {
14544
+ const value = this.value.trim();
14545
+ if (this.enableSouthAfricanMode && this.name === CONSTANTS.DOCUMENT_NUMBER) {
14546
+ const docType = window.documentTypeValue;
14547
+ const res = this.validateDocument(this.value, docType);
14548
+ return res.valid ? '' : translate(res.errorKey, this.language);
14549
+ }
14550
+ if (value === "" && !this.validation.mandatory) {
14363
14551
  return "";
14364
14552
  }
14365
14553
  if (this.inputReference.validity.valueMissing) {
14366
- return translate('requiredError', this.language);
14554
+ return translate(ERROR_KEYS.REQUIRED, this.language);
14367
14555
  }
14368
14556
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
14369
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
14557
+ return translate(ERROR_KEYS.LENGTH, this.language, {
14558
+ values: {
14559
+ minLength: this.validation.minLength,
14560
+ maxLength: this.validation.maxLength
14561
+ }
14562
+ });
14370
14563
  }
14371
14564
  if (this.inputReference.value.match(this.validationPattern) == null) {
14372
14565
  const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
@@ -14378,6 +14571,7 @@ const TextInput = class {
14378
14571
  const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
14379
14572
  return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
14380
14573
  }
14574
+ return "";
14381
14575
  }
14382
14576
  renderTooltip() {
14383
14577
  if (this.showTooltip) {
@@ -14390,8 +14584,8 @@ const TextInput = class {
14390
14584
  if (this.touched) {
14391
14585
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
14392
14586
  }
14393
- return h("div", { key: '46152e946f6a45c2bb07ee07c43bcf356f3cfa29', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, h("div", { key: 'f584f23ee97b9a1d23862ec746366d5f00c56552', class: 'text__wrapper--flex' }, h("label", { key: 'ed9fe368bd00151d8b3e43daf148632cfe7d32ff', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '01cd5f7321d78422049c45b1816801eca74d2b4d', class: 'text__wrapper--relative' }, this.tooltip &&
14394
- h("img", { key: '403689aa01575770be4296aaef0c7846e496d6a7', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), 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 }), h("small", { key: 'd1eb4cf6ac28fff4664a56e27c9f2a21d72b0d61', class: 'text__error-message' }, this.errorMessage));
14587
+ return h("div", { key: '5b0bf10acadab5c3362d185cef10c5ed4f3a6a47', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, h("div", { key: '6d79cc845aac8d9b11737d35571680d7701c4b94', class: 'text__wrapper--flex' }, h("label", { key: 'de687661fa037d691fe1da1231b651f564bca010', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '4d9b12a587267eaf6fab4c4f3c38befb8d5c2b99', class: 'text__wrapper--relative' }, this.tooltip &&
14588
+ h("img", { key: '7f27a118124cd0407b6c2644137a79eaa0496164', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), 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 }), h("small", { key: 'b9b3bdcd9cb81b56dc25a208b0c1d7784d06b5e0', class: 'text__error-message' }, this.errorMessage));
14395
14589
  }
14396
14590
  static get watchers() { return {
14397
14591
  "clientStyling": ["handleStylingChange"],
@@ -14576,20 +14770,24 @@ const TwofaInput = class {
14576
14770
  this.handleInput = (e, idx) => {
14577
14771
  const input = e.target;
14578
14772
  const value = input.value;
14579
- if (value.length > 1) {
14580
- input.value = value.charAt(1);
14581
- }
14582
- else {
14583
- input.value = value.charAt(0);
14584
- }
14585
- if (!value) {
14773
+ const char = value.slice(-1);
14774
+ input.value = char;
14775
+ if (!char)
14586
14776
  return;
14777
+ this.code[idx] = char;
14778
+ // --- Hide pin code --- //
14779
+ if (this.enableSouthAfricanMode) {
14780
+ // show character for 500ms
14781
+ this.revealedIndexes = [idx];
14782
+ if (this.revealTimeout)
14783
+ clearTimeout(this.revealTimeout);
14784
+ this.revealTimeout = setTimeout(() => {
14785
+ this.revealedIndexes = [];
14786
+ }, 500);
14587
14787
  }
14588
- this.code[idx] = input.value;
14589
14788
  const nextInput = this.inputRefs[idx + 1];
14590
- if (nextInput) {
14789
+ if (nextInput)
14591
14790
  nextInput.focus();
14592
- }
14593
14791
  this.setValidity();
14594
14792
  this.setErrorMessage();
14595
14793
  };
@@ -14618,6 +14816,8 @@ const TwofaInput = class {
14618
14816
  this.destination = '';
14619
14817
  this.resendIntervalSeconds = 60;
14620
14818
  this.clientStyling = '';
14819
+ this.enableSouthAfricanMode = undefined;
14820
+ this.pinAttemptsExceeded = undefined;
14621
14821
  this.clientStylingUrl = '';
14622
14822
  this.mbSource = undefined;
14623
14823
  this.limitStylingAppends = false;
@@ -14627,10 +14827,7 @@ const TwofaInput = class {
14627
14827
  this.errorMessage = '';
14628
14828
  this.code = [];
14629
14829
  this.resendIntervalSecondsLeft = this.resendIntervalSeconds;
14630
- }
14631
- handleStylingChange(newValue, oldValue) {
14632
- if (newValue !== oldValue)
14633
- this.setClientStyling();
14830
+ this.revealedIndexes = [];
14634
14831
  }
14635
14832
  validityChanged() {
14636
14833
  this.validityStateHandler({ valid: this.isValid, name: this.name });
@@ -14659,6 +14856,10 @@ const TwofaInput = class {
14659
14856
  this.showTooltip = false;
14660
14857
  }
14661
14858
  }
14859
+ handleStylingChange(newValue, oldValue) {
14860
+ if (newValue !== oldValue)
14861
+ this.setClientStyling();
14862
+ }
14662
14863
  connectedCallback() {
14663
14864
  this.validationPattern = this.setPattern();
14664
14865
  this.code = new Array(this.validation.maxLength).fill('');
@@ -14693,37 +14894,51 @@ const TwofaInput = class {
14693
14894
  }
14694
14895
  handleKeyDown(e, idx) {
14695
14896
  if (e.key === 'Backspace') {
14696
- this.code[idx] = '';
14697
- if (this.inputRefs[idx]) {
14698
- this.inputRefs[idx].value = '';
14699
- } // Clear input field
14700
- const prevInput = this.inputRefs[idx - 1];
14701
- if (prevInput) {
14702
- prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14897
+ const newCode = [...this.code];
14898
+ newCode[idx] = '';
14899
+ this.code = newCode;
14900
+ if (this.enableSouthAfricanMode) {
14901
+ this.revealedIndexes = this.revealedIndexes.filter(i => i !== idx);
14703
14902
  }
14903
+ const prevInput = this.inputRefs[idx - 1];
14904
+ prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14704
14905
  }
14705
14906
  this.setValidity();
14706
14907
  this.setErrorMessage();
14707
14908
  }
14708
14909
  handlePaste(e) {
14709
- var _a;
14910
+ var _a, _b;
14710
14911
  e.preventDefault();
14711
- const data = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text').trim();
14712
- if (!data) {
14912
+ const data = (_b = (_a = e.clipboardData) === null || _a === void 0 ? void 0 : _a.getData('text')) === null || _b === void 0 ? void 0 : _b.trim();
14913
+ if (!data)
14713
14914
  return;
14915
+ const value = data.slice(0, this.validation.maxLength).split('');
14916
+ this.code = [
14917
+ ...value,
14918
+ ...new Array(this.validation.maxLength - value.length).fill('')
14919
+ ];
14920
+ if (this.enableSouthAfricanMode) {
14921
+ this.revealedIndexes = value.map((_, i) => i);
14922
+ if (this.revealTimeout)
14923
+ clearTimeout(this.revealTimeout);
14924
+ this.revealTimeout = setTimeout(() => {
14925
+ this.revealedIndexes = [];
14926
+ }, 500);
14714
14927
  }
14715
- const value = data.slice(0, this.validation.maxLength).split(''); // Limit to OTP length
14716
- this.code = [...value, ...new Array(this.validation.maxLength - value.length).fill('')];
14717
- value.forEach((char, index) => {
14718
- this.inputRefs[index].value = char;
14719
- });
14720
- // Move focus to the last input or trigger submit
14721
14928
  const lastInput = this.inputRefs[Math.min(value.length, this.inputRefs.length - 1)];
14722
- if (lastInput) {
14723
- lastInput.focus();
14724
- }
14929
+ lastInput === null || lastInput === void 0 ? void 0 : lastInput.focus();
14725
14930
  this.setValidity();
14726
14931
  this.setErrorMessage();
14932
+ if (this.enableSouthAfricanMode) {
14933
+ this.valueHandler({
14934
+ name: this.name,
14935
+ value: this.code.join('')
14936
+ });
14937
+ this.validityStateHandler({
14938
+ valid: this.isValid,
14939
+ name: this.name
14940
+ });
14941
+ }
14727
14942
  }
14728
14943
  setValidity() {
14729
14944
  const code = this.code.join('');
@@ -14756,19 +14971,28 @@ const TwofaInput = class {
14756
14971
  }
14757
14972
  return null;
14758
14973
  }
14974
+ getInputDisplayValue(idx) {
14975
+ const current = this.code[idx];
14976
+ if (!current)
14977
+ return "";
14978
+ if (this.enableSouthAfricanMode) {
14979
+ return this.revealedIndexes.includes(idx) ? current : "*";
14980
+ }
14981
+ return current;
14982
+ }
14759
14983
  render() {
14760
- return (h("div", { key: '45f0c8c7d88898a5474bff460ce962e8bb1e8634', class: "twofa", ref: el => this.stylingContainer = el }, h("div", { key: 'b40e81587ad9c7b67c112c8867104e761db7e3bc', class: 'twofa__error-message' }, h("p", { key: '760c694f6f71f040e85f81a67d3d41524c23130f' }, this.errorMessage)), h("div", { key: '2b437a5108e3989d2ddf596dc4a97d2071448154', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), h("div", { key: '84df3ebbe4077ba8462c08cc7956349ec4a55b79', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14761
- return (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) }));
14762
- })), h("div", { key: 'abdf6e2a3ff7ef6436b59206c40ada5305543db3', class: "twofa__button-wrapper" }, h("p", { key: 'e0859c58e48741eb379fbcaf23519bb90404489b', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), h("button", { key: '89aa3a93a9b97029fd315450892cef5edd5d5294', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14984
+ return (h("div", { key: '56a639eb6e240482078fc7aaf688c75ae3de04c8', class: "twofa", ref: el => this.stylingContainer = el }, h("div", { key: 'a64039a3ed66556a0dc1bbac7b6fd6d60de23fa3', class: 'twofa__error-message' }, h("p", { key: '21adf57c840d51714ab097e9df3cc77e22be611f' }, this.errorMessage)), h("div", { key: '6653201178b40bc1eb5d6e7d881f2bbe150901f3', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), h("div", { key: 'ca7600034af473838b741d5be4fe72ded9937647', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((_, idx) => {
14985
+ return (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) }));
14986
+ })), h("div", { key: '0ecd60dd5e6b3f6c3a86176e1937e7aeeffc0e92', class: "twofa__button-wrapper" }, h("p", { key: 'fa9608598580bb8628d0e7a208cc69e3ebe83264', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), h("button", { key: 'c70ea6e780eefc8fef0002fdcc10286ae0e66619', class: `twofa__resend-button ${this.pinAttemptsExceeded ? 'twofa__resend-button--disabled' : ''}`, onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable || this.pinAttemptsExceeded }, this.isResendButtonAvailable
14763
14987
  ? translate('twofaResendButton', this.language)
14764
14988
  : this.formatTime()))));
14765
14989
  }
14766
14990
  get host() { return getElement(this); }
14767
14991
  static get watchers() { return {
14768
- "clientStyling": ["handleStylingChange"],
14769
14992
  "isValid": ["validityChanged"],
14770
14993
  "emitValue": ["emitValueHandler"],
14771
- "clientStylingUrl": ["handleStylingUrlChange"]
14994
+ "clientStylingUrl": ["handleStylingUrlChange"],
14995
+ "clientStyling": ["handleStylingChange"]
14772
14996
  }; }
14773
14997
  };
14774
14998
  TwofaInput.style = TwofaInputStyle0;