@everymatrix/general-registration-hsl 0.25.40 → 0.25.43

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.
@@ -5873,6 +5873,13 @@ const DateInput = class {
5873
5873
  };
5874
5874
  DateInput.style = DateInputStyle0;
5875
5875
 
5876
+ function getFailedRegexRule(value, custom) {
5877
+ return (custom || []).find(rule => rule.rule === 'regex' && !new RegExp(rule.pattern).test(value));
5878
+ }
5879
+ function getRuleErrorMessage(rule, language) {
5880
+ return translate(rule.errorKey, language) || rule.errorMessage;
5881
+ }
5882
+
5876
5883
  const emailInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.email{font-family:\"Roboto\";font-style:normal}.email__wrapper{position:relative;width:100%}.email__wrapper--autofilled{pointer-events:none}.email__wrapper--autofilled .email__label{color:var(--emw--registration-typography, var(--emw--color-black, #000000))}.email__wrapper--autofilled .email__input{color:var(--emw--color-black, #000000)}.email__wrapper--flex{display:flex;gap:5px}.email__wrapper--relative{position:relative}.email__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:var(--emw--registration-typography, var(--emw--color-black, #000000))}.email__label--required::after{content:\"*\";font-family:inherit;color:var(--emw--login-color-primary, var(--emw--color-primary, #22B04E));margin-left:2px}.email__input{font-family:inherit;border-radius:4px;width:100%;height:40px;border:2px solid var(--emw--color-gray-100, #E6E6E6);color:var(--emw--color-black, #000000);border-radius:5px;box-sizing:border-box;font-size:16px;font-weight:300;line-height:1.5;padding:10px}.email__input:focus{outline-color:var(--emw--login-color-primary, var(--emw--color-primary, #22B04E))}.email__input--invalid{border:1px solid var(--emw--color-error, var(--emw--color-red, #ed0909))}.email__input::placeholder{color:var(--emw--color-gray-150, #828282)}.email__error-message{position:absolute;top:calc(100% + 5px);left:0;color:var(--emw--color-error, var(--emw--color-red, #ed0909))}.email__tooltip-icon{width:16px;height:auto}.email__tooltip{position:absolute;top:0;left:20px;background-color:var(--emw--color-white, #FFFFFF);border:1px solid var(--emw--color-gray-100, #E6E6E6);color:var(--emw--registration-typography, var(--emw--color-black, #000000));padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.email__tooltip.visible{opacity:1}";
5877
5884
  const EmailInputStyle0 = emailInputCss;
5878
5885
 
@@ -5881,7 +5888,6 @@ const EmailInput = class {
5881
5888
  registerInstance(this, hostRef);
5882
5889
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
5883
5890
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
5884
- this.validationPattern = '';
5885
5891
  this.touched = false;
5886
5892
  this.handleInput = (event) => {
5887
5893
  this.value = event.target.value;
@@ -5890,14 +5896,12 @@ const EmailInput = class {
5890
5896
  clearTimeout(this.debounceTime);
5891
5897
  }
5892
5898
  this.debounceTime = setTimeout(() => {
5893
- this.isValid = this.setValidity();
5894
- this.errorMessage = this.setErrorMessage();
5899
+ this.updateValidity();
5895
5900
  this.emitValueHandler(true);
5896
5901
  }, 500);
5897
5902
  };
5898
5903
  this.handleBlur = () => {
5899
- this.isValid = this.setValidity();
5900
- this.errorMessage = this.setErrorMessage();
5904
+ this.updateValidity();
5901
5905
  this.touched = true;
5902
5906
  };
5903
5907
  this.setClientStyling = () => {
@@ -5955,9 +5959,6 @@ const EmailInput = class {
5955
5959
  }
5956
5960
  }
5957
5961
  }
5958
- connectedCallback() {
5959
- this.validationPattern = this.setPattern();
5960
- }
5961
5962
  componentDidRender() {
5962
5963
  // start custom styling area
5963
5964
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -5968,39 +5969,39 @@ const EmailInput = class {
5968
5969
  // end custom styling area
5969
5970
  }
5970
5971
  componentDidLoad() {
5971
- this.isValid = this.setValidity();
5972
+ this.isValid = this.validate().isValid;
5972
5973
  if (this.defaultValue) {
5973
5974
  this.value = this.defaultValue;
5974
5975
  this.valueHandler({ name: this.name, value: this.value });
5975
5976
  }
5976
5977
  }
5977
- setValidity() {
5978
- return this.inputReference.validity.valid;
5978
+ updateValidity() {
5979
+ const { isValid, errorMessage } = this.validate();
5980
+ this.isValid = isValid;
5981
+ this.errorMessage = errorMessage;
5979
5982
  }
5980
- setPattern() {
5983
+ validate() {
5981
5984
  var _a, _b;
5982
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
5983
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
5985
+ if (!this.inputReference) {
5986
+ return { isValid: false, errorMessage: '' };
5984
5987
  }
5985
- }
5986
- setErrorMessage() {
5987
- var _a, _b, _c, _d;
5988
5988
  if (this.inputReference.validity.valueMissing) {
5989
- return translate('requiredError', this.language);
5989
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
5990
5990
  }
5991
5991
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
5992
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
5992
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
5993
5993
  }
5994
- if (this.inputReference.validity.patternMismatch) {
5995
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
5996
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
5997
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
5994
+ const inputValue = this.inputReference.value;
5995
+ const failedRegexRule = inputValue ? getFailedRegexRule(inputValue, this.validation.custom) : undefined;
5996
+ if (failedRegexRule) {
5997
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRegexRule, this.language) };
5998
5998
  }
5999
5999
  if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
6000
- const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
6001
- const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
6002
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
6000
+ const errorCode = (_a = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _a === void 0 ? void 0 : _a.errorKey;
6001
+ const errorMessage = (_b = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _b === void 0 ? void 0 : _b.errorMessage;
6002
+ return { isValid: false, errorMessage: translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage };
6003
6003
  }
6004
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
6004
6005
  }
6005
6006
  renderTooltip() {
6006
6007
  if (this.showTooltip) {
@@ -6013,8 +6014,8 @@ const EmailInput = class {
6013
6014
  if (this.touched) {
6014
6015
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
6015
6016
  }
6016
- return h("div", { key: '45255f597fcc76fa5e99601d7c2dd59afca32dbe', class: `email__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '7e41609760d4cc0b5acb554749fce42e6bc88ef3', class: 'email__wrapper--flex' }, h("label", { key: '250a1656d714e8cbc943d153aa216a6322322534', class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '80db5747730aaac2c1d0efa3129dfa5463fe779c', class: 'email__wrapper--relative' }, this.tooltip &&
6017
- h("img", { key: 'f10990c70bb3de310d137fa120575ad3582adbd3', class: 'email__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: '9cf1a9fc4fdc3cb2604c6ad21573091cc1b173aa', id: `${this.name}__input`, type: 'email', class: `email__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.placeholder}`, ref: (el) => this.inputReference = el, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur }), h("small", { key: '1610834f1705f70bd1f2d4b0a6c37af3307cf77f', class: 'email__error-message' }, this.errorMessage));
6017
+ return h("div", { key: 'ff5657194151b872247fd966bc8dc7ab53f715de', class: `email__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '8dc84da8787a50232fda2c113cf838598525a550', class: 'email__wrapper--flex' }, h("label", { key: 'b42e56122de79d841d99e183c6ed818a74c22020', class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '7f09b2b675b28eebcd1e913b0cbdd43feb83b567', class: 'email__wrapper--relative' }, this.tooltip &&
6018
+ h("img", { key: '64c6c3565b60480d279a434f87efa36625da934b', class: 'email__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: '754ba4160c2633444064d334f451d0700815e8fc', id: `${this.name}__input`, type: 'email', class: `email__input ${invalidClass}`, value: this.defaultValue, readOnly: this.autofilled, placeholder: `${this.placeholder}`, ref: (el) => this.inputReference = el, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur }), h("small", { key: '2d72cdde55c1a6b041bb37a1b5a2f3e1c17b558a', class: 'email__error-message' }, this.errorMessage));
6018
6019
  }
6019
6020
  static get watchers() { return {
6020
6021
  "clientStyling": ["handleStylingChange"],
@@ -12770,7 +12771,6 @@ const NumberInput = class {
12770
12771
  registerInstance(this, hostRef);
12771
12772
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
12772
12773
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
12773
- this.validationPattern = '';
12774
12774
  this.touched = false;
12775
12775
  this.handleInput = (event) => {
12776
12776
  this.value = event.target.value;
@@ -12779,14 +12779,12 @@ const NumberInput = class {
12779
12779
  clearTimeout(this.debounceTime);
12780
12780
  }
12781
12781
  this.debounceTime = setTimeout(() => {
12782
- this.isValid = this.setValidity();
12783
- this.errorMessage = this.setErrorMessage();
12782
+ this.updateValidity();
12784
12783
  this.emitValueHandler(true);
12785
12784
  }, 500);
12786
12785
  };
12787
12786
  this.handleBlur = () => {
12788
- this.isValid = this.setValidity();
12789
- this.errorMessage = this.setErrorMessage();
12787
+ this.updateValidity();
12790
12788
  this.touched = true;
12791
12789
  };
12792
12790
  this.setClientStyling = () => {
@@ -12836,9 +12834,6 @@ const NumberInput = class {
12836
12834
  this.showTooltip = false;
12837
12835
  }
12838
12836
  }
12839
- connectedCallback() {
12840
- this.validationPattern = this.setPattern();
12841
- }
12842
12837
  componentDidRender() {
12843
12838
  // start custom styling area
12844
12839
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -12849,34 +12844,33 @@ const NumberInput = class {
12849
12844
  // end custom styling area
12850
12845
  }
12851
12846
  componentDidLoad() {
12852
- this.isValid = this.setValidity();
12847
+ this.isValid = this.validate().isValid;
12853
12848
  if (this.defaultValue) {
12854
12849
  this.value = this.defaultValue;
12855
12850
  this.valueHandler({ name: this.name, value: this.value });
12856
12851
  }
12857
12852
  }
12858
- setValidity() {
12859
- return this.inputReference.validity.valid;
12853
+ updateValidity() {
12854
+ const { isValid, errorMessage } = this.validate();
12855
+ this.isValid = isValid;
12856
+ this.errorMessage = errorMessage;
12860
12857
  }
12861
- setPattern() {
12862
- var _a, _b;
12863
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
12864
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
12858
+ validate() {
12859
+ if (!this.inputReference) {
12860
+ return { isValid: false, errorMessage: '' };
12865
12861
  }
12866
- }
12867
- setErrorMessage() {
12868
- var _a, _b;
12869
12862
  if (this.inputReference.validity.valueMissing) {
12870
- return translate('requiredError', this.language);
12863
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
12871
12864
  }
12872
12865
  if (this.inputReference.validity.rangeUnderflow || this.inputReference.validity.rangeOverflow) {
12873
- return translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } });
12866
+ return { isValid: false, errorMessage: translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } }) };
12874
12867
  }
12875
- if (this.inputReference.validity.patternMismatch) {
12876
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
12877
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
12878
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
12868
+ const value = this.inputReference.value;
12869
+ const failedRule = value ? getFailedRegexRule(value, this.validation.custom) : undefined;
12870
+ if (failedRule) {
12871
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRule, this.language) };
12879
12872
  }
12873
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
12880
12874
  }
12881
12875
  renderTooltip() {
12882
12876
  if (this.showTooltip) {
@@ -12889,8 +12883,8 @@ const NumberInput = class {
12889
12883
  if (this.touched) {
12890
12884
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
12891
12885
  }
12892
- return h("div", { key: 'f0e6e6edb5d8e3f509474ef5536cb7ef717a5ee9', class: `number__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: 'c991d1e6ed0f9910104b46105daad5332200ee21', class: 'number__wrapper--flex' }, h("label", { key: 'd6912229dac4712f4f8e77a90f7ba0ebb7dd5548', class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '5733806c60cad364e61fc66e25f89a44159e8ad9', class: 'number__wrapper--relative' }, this.tooltip &&
12893
- h("img", { key: '7ba9ca8048d04c41f800fccf03297e2db9a9115d', class: 'number__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: '4c4726f1ac0f3b3495ba6309f5fe4110b1ea5353', ref: (el) => this.inputReference = el, type: "number", inputMode: "numeric", value: this.defaultValue, readOnly: this.autofilled, id: `${this.name}__input`, class: `number__input ${invalidClass}`, pattern: this.validationPattern, placeholder: `${this.placeholder}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: this.handleInput, onBlur: this.handleBlur }), h("small", { key: '5217c1b0b4f4d9f741b5cdf6b7c3f01ef61fe180', class: 'number__error-message' }, this.errorMessage));
12886
+ return h("div", { key: 'edc8799baa52418673dcfccb82b1ff9d86159787', class: `number__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '9d6313a06ff4fcd1174879745d48d37ac63c64a5', class: 'number__wrapper--flex' }, h("label", { key: '404af2d79da04a3156ebce45aae6d06ea21b5dc1', class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '349120e9587af42941de2fd2405dc0b9b763372f', class: 'number__wrapper--relative' }, this.tooltip &&
12887
+ h("img", { key: '652d145a6a794f0e8370641d3f7fb28099603d62', class: 'number__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: 'e7908fe81f8afda735750cfe2bb7ac50d452c210', ref: (el) => this.inputReference = el, type: "number", inputMode: "numeric", value: this.defaultValue, readOnly: this.autofilled, id: `${this.name}__input`, class: `number__input ${invalidClass}`, placeholder: `${this.placeholder}`, required: this.validation.mandatory, max: this.validation.max, min: this.validation.min, onInput: this.handleInput, onBlur: this.handleBlur }), h("small", { key: '87e3e5afb6c790f9c57d79bdf0e12a897b10d799', class: 'number__error-message' }, this.errorMessage));
12894
12888
  }
12895
12889
  static get watchers() { return {
12896
12890
  "clientStyling": ["handleStylingChange"],
@@ -12911,7 +12905,6 @@ const PasswordInput = class {
12911
12905
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
12912
12906
  this.touched = false;
12913
12907
  this.originalValid = false;
12914
- this.validationPattern = '';
12915
12908
  this.duplicateInputValue = null;
12916
12909
  this.handleInput = (event) => {
12917
12910
  this.value = event.target.value;
@@ -12922,8 +12915,7 @@ const PasswordInput = class {
12922
12915
  clearTimeout(this.debounceTime);
12923
12916
  }
12924
12917
  this.debounceTime = setTimeout(() => {
12925
- this.isValid = this.setValidity();
12926
- this.errorMessage = this.setErrorMessage();
12918
+ this.updateValidity();
12927
12919
  this.emitValueHandler(true);
12928
12920
  }, 500);
12929
12921
  };
@@ -12935,8 +12927,7 @@ const PasswordInput = class {
12935
12927
  this.value = event.target.value;
12936
12928
  this.showPopup = false;
12937
12929
  this.touched = true;
12938
- this.isValid = this.setValidity();
12939
- this.errorMessage = this.setErrorMessage();
12930
+ this.updateValidity();
12940
12931
  };
12941
12932
  this.handleFocus = () => {
12942
12933
  this.showPopup = true;
@@ -12981,7 +12972,7 @@ const PasswordInput = class {
12981
12972
  if (!this.isDuplicateInput) {
12982
12973
  // recalculate complexity immediately in order to send the correct validity to the duplicate
12983
12974
  this.calculateComplexity(this.value);
12984
- this.sendOriginalValidityState.emit({ name: this.name, valid: this.setValidity() });
12975
+ this.sendOriginalValidityState.emit({ name: this.name, valid: this.validate().isValid });
12985
12976
  }
12986
12977
  }
12987
12978
  emitValueHandler(newValue) {
@@ -12999,13 +12990,13 @@ const PasswordInput = class {
12999
12990
  if (this.isDuplicateInput) {
13000
12991
  if (event.detail.valid) {
13001
12992
  this.originalValid = true;
13002
- this.isValid = this.setValidity();
12993
+ this.isValid = this.validate().isValid;
13003
12994
  }
13004
12995
  else {
13005
12996
  this.originalValid = false;
13006
12997
  this.isValid = false;
13007
12998
  // only show error if the user has touched the input, in order to not show errors on empty inputs
13008
- this.value !== '' && (this.errorMessage = this.setErrorMessage());
12999
+ this.value !== '' && (this.errorMessage = this.validate().errorMessage);
13009
13000
  }
13010
13001
  }
13011
13002
  }
@@ -13013,15 +13004,13 @@ const PasswordInput = class {
13013
13004
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
13014
13005
  this.duplicateInputValue = event.detail.value;
13015
13006
  if (this.touched) {
13016
- this.isValid = this.setValidity();
13017
- this.errorMessage = this.setErrorMessage();
13007
+ this.updateValidity();
13018
13008
  }
13019
13009
  }
13020
13010
  if (this.name === event.detail.name + 'Duplicate'
13021
13011
  && this.name.replace('Duplicate', '') === event.detail.name
13022
13012
  && this.touched === true) {
13023
- this.isValid = this.setValidity();
13024
- this.errorMessage = this.setErrorMessage();
13013
+ this.updateValidity();
13025
13014
  }
13026
13015
  }
13027
13016
  handleClickOutside(event) {
@@ -13055,7 +13044,7 @@ const PasswordInput = class {
13055
13044
  this.touched = true;
13056
13045
  }
13057
13046
  }
13058
- this.isValid = this.setValidity();
13047
+ this.isValid = this.validate().isValid;
13059
13048
  }
13060
13049
  disconnectedCallback() {
13061
13050
  this.passwordButton.removeEventListener('click', this.handleRevealField);
@@ -13069,48 +13058,36 @@ const PasswordInput = class {
13069
13058
  return { rule: rule.displayName, ruleKey: rule.errorKey, passed };
13070
13059
  });
13071
13060
  }
13072
- setValidity() {
13073
- var _a, _b;
13074
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13075
- return false;
13076
- }
13077
- else if (!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed))) {
13078
- return false;
13079
- }
13080
- else {
13081
- return (_b = this.inputReference) === null || _b === void 0 ? void 0 : _b.validity.valid;
13082
- }
13083
- }
13084
- setPattern() {
13061
+ validate() {
13085
13062
  var _a, _b;
13086
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
13087
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
13063
+ if (!this.inputReference) {
13064
+ return { isValid: false, errorMessage: '' };
13088
13065
  }
13089
- }
13090
- setErrorMessage() {
13091
- var _a, _b, _c, _d, _e;
13092
- if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
13093
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13066
+ const validity = this.inputReference.validity;
13067
+ const duplicateMismatch = this.isDuplicateInput && this.duplicateInputValue !== this.value;
13068
+ const complexityPassed = !!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed));
13069
+ if (validity.tooShort || validity.tooLong) {
13070
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
13094
13071
  }
13095
- if (this.inputReference.validity.valueMissing) {
13096
- return translate('requiredError', this.language);
13072
+ if (validity.valueMissing) {
13073
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13097
13074
  }
13098
13075
  if (this.isDuplicateInput && !this.originalValid) {
13099
- return translate('invalidOriginalPasswordError', this.language);
13100
- }
13101
- if (this.inputReference.validity.patternMismatch) {
13102
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
13103
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13104
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13076
+ return { isValid: false, errorMessage: translate('invalidOriginalPasswordError', this.language) };
13105
13077
  }
13106
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13107
- const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
13108
- const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
13109
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13078
+ if (duplicateMismatch) {
13079
+ const duplicateRule = (_b = this.validation.custom) === null || _b === void 0 ? void 0 : _b.find(customRule => customRule.rule === 'duplicate-input');
13080
+ return { isValid: false, errorMessage: duplicateRule ? getRuleErrorMessage(duplicateRule, this.language) : '' };
13110
13081
  }
13111
- if (!((_e = this.passwordComplexity) === null || _e === void 0 ? void 0 : _e.every(complexity => complexity.passed)) && !this.showPopup) {
13112
- return translate('invalidPassword', this.language);
13082
+ if (!complexityPassed) {
13083
+ return { isValid: false, errorMessage: this.showPopup ? '' : translate('invalidPassword', this.language) };
13113
13084
  }
13085
+ return { isValid: validity.valid, errorMessage: '' };
13086
+ }
13087
+ updateValidity() {
13088
+ const { isValid, errorMessage } = this.validate();
13089
+ this.isValid = isValid;
13090
+ this.errorMessage = errorMessage;
13114
13091
  }
13115
13092
  renderTooltip() {
13116
13093
  if (this.showTooltip) {
@@ -13132,8 +13109,8 @@ const PasswordInput = class {
13132
13109
  if (this.touched) {
13133
13110
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13134
13111
  }
13135
- return h("div", { key: 'e6a288d18a095de747c7eec28bcf117e5069cbc1', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: 'e2885669879d0b61473be48014975859d87b2478', class: 'password__wrapper--flex' }, h("label", { key: 'c12f0a0bfe91a9da9688ab0acd39f6a44eec5d0a', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: 'f501cb74b838d2c4a1a1fd38086203e4b1c98dfe', class: 'password__wrapper--relative' }, this.tooltip &&
13136
- h("img", { key: '68d71061fb6be2245298e521b511e57b4cb12cbb', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("vaadin-password-field", { key: 'c8e3ce65dc46599cffe9763621b271fc18243829', 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 }), h("small", { key: 'ca4aeae4893276dc96bd7187aef5ac2ed86d35c8', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13112
+ return h("div", { key: '9fd27b840b317bbb224f062c855c4b4a8b94a3a4', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '3d16837c2e10a490fd07ef1c294db1f5732da4ad', class: 'password__wrapper--flex' }, h("label", { key: '09d61fc66912e7a79b83842e4d6d89b851a92afa', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '23f4d60bc9f777d00fd16d2dc78cc7c105307e32', class: 'password__wrapper--relative' }, this.tooltip &&
13113
+ h("img", { key: 'db104e01e0f5d5d322b3394f8740cedaaa8b2199', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("vaadin-password-field", { key: '072309fd70e0af72bde2beb579e6d93abea8928a', 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, placeholder: `${this.placeholder}`, onInput: this.handleInput, onBlur: this.handleBlur, onFocus: this.handleFocus }), h("small", { key: '41336c3bd58eba953266b31980ce0677b27405f0', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13137
13114
  }
13138
13115
  get element() { return getElement(this); }
13139
13116
  static get watchers() { return {
@@ -13454,7 +13431,6 @@ const TelInput = class {
13454
13431
  registerInstance(this, hostRef);
13455
13432
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
13456
13433
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
13457
- this.validationPattern = '';
13458
13434
  this.touched = false;
13459
13435
  this.handleInput = (event) => {
13460
13436
  const inputElement = event.target;
@@ -13468,15 +13444,13 @@ const TelInput = class {
13468
13444
  clearTimeout(this.debounceTime);
13469
13445
  }
13470
13446
  this.debounceTime = setTimeout(() => {
13471
- this.isValid = this.setValidity();
13472
- this.errorMessage = this.setErrorMessage();
13447
+ this.updateValidity();
13473
13448
  this.emitValueHandler(true);
13474
13449
  }, 500);
13475
13450
  };
13476
13451
  this.handleBlur = () => {
13477
13452
  if (!this.touched) {
13478
- this.isValid = this.setValidity();
13479
- this.errorMessage = this.setErrorMessage();
13453
+ this.updateValidity();
13480
13454
  this.touched = true;
13481
13455
  }
13482
13456
  };
@@ -13531,7 +13505,6 @@ const TelInput = class {
13531
13505
  }
13532
13506
  }
13533
13507
  connectedCallback() {
13534
- this.validationPattern = this.setPattern();
13535
13508
  if (this.defaultValue) {
13536
13509
  this.prefixValue = this.defaultValue.prefix ? this.defaultValue.prefix : this.defaultValue;
13537
13510
  this.phoneValue = this.defaultValue.phone || null;
@@ -13561,7 +13534,7 @@ const TelInput = class {
13561
13534
  // end custom styling area
13562
13535
  }
13563
13536
  componentDidLoad() {
13564
- this.isValid = this.setValidity();
13537
+ this.isValid = this.validate().isValid;
13565
13538
  if (this.defaultValue) {
13566
13539
  this.value = this.defaultValue;
13567
13540
  this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
@@ -13585,28 +13558,27 @@ const TelInput = class {
13585
13558
  this.value = { prefix: this.prefixValue, phone: this.phoneValue };
13586
13559
  this.emitValueHandler(true);
13587
13560
  }
13588
- setValidity() {
13589
- return this.inputReference.validity.valid;
13590
- }
13591
- setPattern() {
13592
- var _a, _b;
13593
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
13594
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
13561
+ validate() {
13562
+ if (!this.inputReference) {
13563
+ return { isValid: false, errorMessage: '' };
13595
13564
  }
13596
- }
13597
- setErrorMessage() {
13598
- var _a, _b;
13599
- if (this.inputReference.validity.patternMismatch) {
13600
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
13601
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13602
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13565
+ const value = this.inputReference.value;
13566
+ const failedRule = value ? getFailedRegexRule(value, this.validation.custom) : undefined;
13567
+ if (failedRule) {
13568
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRule, this.language) };
13603
13569
  }
13604
13570
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
13605
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13571
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
13606
13572
  }
13607
13573
  if (this.inputReference.validity.valueMissing) {
13608
- return translate('requiredError', this.language);
13574
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13609
13575
  }
13576
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
13577
+ }
13578
+ updateValidity() {
13579
+ const { isValid, errorMessage } = this.validate();
13580
+ this.isValid = isValid;
13581
+ this.errorMessage = errorMessage;
13610
13582
  }
13611
13583
  renderTooltip() {
13612
13584
  if (this.showTooltip) {
@@ -13619,8 +13591,8 @@ const TelInput = class {
13619
13591
  if (this.touched) {
13620
13592
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13621
13593
  }
13622
- return h("div", { key: '8a75a1a66dae4a9f453487be42c8563fc94c9338', class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '01589400f59390352949240162a96874be011f03', class: 'tel__wrapper--flex-label' }, h("label", { key: '73beb8ce7ea80ea4fca24db633e021dbab04f9ba', class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '56eaf52390a9dd93342324a1bf87a1b7a9f04b97', class: 'tel__wrapper--relative' }, this.tooltip &&
13623
- h("img", { key: '198fc851fb3ea4763607cfe2b0e08414e07adfe5', class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("div", { key: '4cbf87d5e3be55ce0d23ec1ab223e168e4991a9f', class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { key: '3898ad1468b4f03d4ebaf24d0898e70988663f6d', class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), h("input", { key: '24794f3651771ffbb011ef2048b28b4bc7cba0c7', type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onInput: this.handleInput, onBlur: this.handleBlur })), h("small", { key: 'a33de6b2bec2b9dd79fa9960a7bbacc9845d8c51', class: 'tel__error-message' }, this.errorMessage));
13594
+ return h("div", { key: '78ddea111a011a7c75df7a6f7101aafccbaff4a1', class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, h("div", { key: '9dcd9723ed26de04630a8a174e902a629bc9347c', class: 'tel__wrapper--flex-label' }, h("label", { key: '597e8a28990f12e1183fdeb315e176af970d4104', class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '86c147c124468d06bffdf8359c7f404cbe897c15', class: 'tel__wrapper--relative' }, this.tooltip &&
13595
+ h("img", { key: '0d2b528570401361087bf0438493a96a3450e40c', class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("div", { key: 'd82808bbc28c720ae4cff45fd1d0df88ca320029', class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { key: '73805b42a6b40d901e6367e45e4d6d1ff2288082', class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), h("input", { key: '483f7fd3f8e71d3ab9161b66d6584bd141e56144', type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onInput: this.handleInput, onBlur: this.handleBlur })), h("small", { key: '296651863f2d6fcf31eb21f2d83b7df505d59833', class: 'tel__error-message' }, this.errorMessage));
13624
13596
  }
13625
13597
  static get watchers() { return {
13626
13598
  "clientStyling": ["handleStylingChange"],
@@ -13639,7 +13611,6 @@ const TextInput = class {
13639
13611
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
13640
13612
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
13641
13613
  this.value = '';
13642
- this.validationPattern = [];
13643
13614
  this.duplicateInputValue = null;
13644
13615
  this.handleInput = (event) => {
13645
13616
  const inputElement = event.target;
@@ -13653,8 +13624,7 @@ const TextInput = class {
13653
13624
  clearTimeout(this.debounceTime);
13654
13625
  }
13655
13626
  this.debounceTime = setTimeout(() => {
13656
- this.isValid = this.setValidity();
13657
- this.errorMessage = this.setErrorMessage();
13627
+ this.updateValidity();
13658
13628
  this.validityStateHandler({ valid: this.isValid, name: this.name });
13659
13629
  this.emitValueHandler(true);
13660
13630
  }, 500);
@@ -13662,8 +13632,7 @@ const TextInput = class {
13662
13632
  this.handleBlur = (event) => {
13663
13633
  this.value = event.target.value;
13664
13634
  this.touched = true;
13665
- this.isValid = this.setValidity();
13666
- this.errorMessage = this.setErrorMessage();
13635
+ this.updateValidity();
13667
13636
  this.validityStateHandler({ valid: this.isValid, name: this.name });
13668
13637
  };
13669
13638
  this.setClientStyling = () => {
@@ -13694,10 +13663,11 @@ const TextInput = class {
13694
13663
  if (newValue) {
13695
13664
  this.value = newValue;
13696
13665
  requestAnimationFrame(() => {
13697
- this.isValid = this.setValidity();
13698
- if (!this.isValid && !this.touched) {
13666
+ const { isValid, errorMessage } = this.validate();
13667
+ this.isValid = isValid;
13668
+ if (!isValid && !this.touched) {
13699
13669
  this.touched = true;
13700
- this.errorMessage = this.setErrorMessage();
13670
+ this.errorMessage = errorMessage;
13701
13671
  }
13702
13672
  });
13703
13673
  }
@@ -13733,15 +13703,13 @@ const TextInput = class {
13733
13703
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
13734
13704
  this.duplicateInputValue = event.detail.value;
13735
13705
  if (this.touched) {
13736
- this.isValid = this.setValidity();
13737
- this.errorMessage = this.setErrorMessage();
13706
+ this.updateValidity();
13738
13707
  }
13739
13708
  }
13740
13709
  if (this.name === event.detail.name + 'Duplicate'
13741
13710
  && this.name.replace('Duplicate', '') === event.detail.name
13742
13711
  && this.touched === true) {
13743
- this.isValid = this.setValidity();
13744
- this.errorMessage = this.setErrorMessage();
13712
+ this.updateValidity();
13745
13713
  }
13746
13714
  }
13747
13715
  handleValidationChange(event) {
@@ -13749,15 +13717,10 @@ const TextInput = class {
13749
13717
  return;
13750
13718
  }
13751
13719
  this.validation = event.detail.validation;
13752
- this.validationPattern = this.setPattern();
13753
13720
  if (this.touched) {
13754
- this.isValid = this.setValidity();
13755
- this.errorMessage = this.setErrorMessage();
13721
+ this.updateValidity();
13756
13722
  }
13757
13723
  }
13758
- connectedCallback() {
13759
- this.validationPattern = this.setPattern();
13760
- }
13761
13724
  componentDidRender() {
13762
13725
  // start custom styling area
13763
13726
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -13774,7 +13737,7 @@ const TextInput = class {
13774
13737
  this.validation.minLength &&
13775
13738
  this.inputReference.value.length < this.validation.minLength) {
13776
13739
  this.touched = true;
13777
- this.errorMessage = this.setErrorMessage();
13740
+ this.errorMessage = this.validate().errorMessage;
13778
13741
  }
13779
13742
  }
13780
13743
  componentDidLoad() {
@@ -13785,54 +13748,40 @@ const TextInput = class {
13785
13748
  this.touched = true;
13786
13749
  }
13787
13750
  }
13788
- this.isValid = this.setValidity();
13751
+ this.isValid = this.validate().isValid;
13789
13752
  }
13790
- setValidity() {
13791
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13792
- return false;
13793
- }
13753
+ updateValidity() {
13754
+ const { isValid, errorMessage } = this.validate();
13755
+ this.isValid = isValid;
13756
+ this.errorMessage = errorMessage;
13757
+ }
13758
+ validate() {
13759
+ var _a;
13794
13760
  if (!this.inputReference) {
13795
- return false;
13761
+ return { isValid: false, errorMessage: '' };
13796
13762
  }
13797
13763
  const inputValue = this.inputReference.value;
13798
- const inputIsValid = this.inputReference.validity.valid;
13799
- const inputMatchValidation = !inputValue
13800
- || (this.validationPattern.length > 0 ? this.validationPattern.some((pattern) => inputValue.match(pattern) !== null) : true);
13801
- // Fallback: if HTML5 says valid but minlength constraint not met, it's invalid
13802
- const isTooShort = this.validation.minLength && inputValue.length > 0 && inputValue.length < this.validation.minLength;
13803
- return !isTooShort && inputIsValid && inputMatchValidation;
13804
- }
13805
- setPattern() {
13806
- const custom = this.validation.custom;
13807
- if (!(custom === null || custom === void 0 ? void 0 : custom.length))
13808
- return [];
13809
- return custom
13810
- .filter(v => v.rule === 'regex')
13811
- .map(v => v.pattern);
13812
- }
13813
- setErrorMessage() {
13814
- var _a, _b;
13815
- const inputValue = this.inputReference.value;
13816
13764
  if (this.inputReference.validity.valueMissing) {
13817
- return translate('requiredError', this.language);
13765
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13818
13766
  }
13819
13767
  // Check length manually (fallback for HTML5 validation API issues)
13820
13768
  const isTooShort = this.validation.minLength && inputValue.length > 0 && inputValue.length < this.validation.minLength;
13821
13769
  const isTooLong = this.validation.maxLength && inputValue.length > this.validation.maxLength;
13822
13770
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong || isTooShort || isTooLong) {
13823
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13771
+ return {
13772
+ isValid: false,
13773
+ errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } })
13774
+ };
13824
13775
  }
13825
- const isCustomError = !(inputValue === '' && !this.validation.mandatory)
13826
- && (this.validationPattern.length > 0 ? this.validationPattern.some((pattern) => inputValue.match(pattern) == null) : false);
13827
- if (isCustomError) {
13828
- const { errorKey: errorCode, errorMessage } = this.validation.custom.find(customValidation => customValidation.rule === 'regex');
13829
- return translate(`${errorCode}`, this.language) || errorMessage;
13776
+ const failedRegexRule = inputValue ? getFailedRegexRule(inputValue, this.validation.custom) : undefined;
13777
+ if (failedRegexRule) {
13778
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRegexRule, this.language) };
13830
13779
  }
13831
13780
  if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13832
- const errorCode = (_a = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _a === void 0 ? void 0 : _a.errorKey;
13833
- const errorMessage = (_b = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13834
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13781
+ const duplicateRule = (_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.find(customRule => customRule.rule === 'duplicate-input');
13782
+ return { isValid: false, errorMessage: duplicateRule ? getRuleErrorMessage(duplicateRule, this.language) : '' };
13835
13783
  }
13784
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
13836
13785
  }
13837
13786
  renderTooltip() {
13838
13787
  if (this.showTooltip) {
@@ -13845,8 +13794,8 @@ const TextInput = class {
13845
13794
  if (this.touched) {
13846
13795
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13847
13796
  }
13848
- return h("div", { key: '045e3183bdb1c7279abbd045043d789387956de5', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, h("div", { key: '3534d1261f9ccb9c0942f01d0758d9fd65743e40', class: 'text__wrapper--flex' }, h("label", { key: '171155d911e2c1048b003be8541671f0cdeb1ce5', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '8a0b0abe15eaf77b5efc5fa6374a8faeea24cf94', class: 'text__wrapper--relative' }, this.tooltip &&
13849
- h("img", { key: 'aa0b0b33cdb370289db8444c3dba915ef8eb77be', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: 'cc47bb443384396eefd7bf61f767f8646f7e2639', name: this.name, id: `${this.name}__input`, value: this.defaultValue, 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: 'ce7b97e0a7db8eb87c608690bad3cf99a565ba9f', class: 'text__error-message' }, this.errorMessage));
13797
+ return h("div", { key: '206f2e3c3cf18b4405c07be422bb6173ac3a2ac2', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, h("div", { key: 'b6aa572d3f984a386a850b3f968a674eb94f7816', class: 'text__wrapper--flex' }, h("label", { key: '7fba5554aac3af6444225cb6da166276470dba50', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { key: '9677b43f2f5e185e4d7fcfe007dd73a16d50876b', class: 'text__wrapper--relative' }, this.tooltip &&
13798
+ h("img", { key: '69360ef5dd851cf64110f82189c2a27f99c843f8', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("input", { key: '46b8d857acfb2d4fdd874984f555fc4457b7d53f', name: this.name, id: `${this.name}__input`, value: this.defaultValue, 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: '5db72a6b2c969e3af37eaf03ce3a77524a5f25d2', class: 'text__error-message' }, this.errorMessage));
13850
13799
  }
13851
13800
  static get watchers() { return {
13852
13801
  "defaultValue": ["handleDefaultValueChange"],
@@ -13975,7 +13924,6 @@ const TwofaInput = class {
13975
13924
  this.sendValidityState = createEvent(this, "sendValidityState", 7);
13976
13925
  this.sendInputValue = createEvent(this, "sendInputValue", 7);
13977
13926
  this.resendCode = createEvent(this, "resendCode", 7);
13978
- this.validationPattern = '';
13979
13927
  this.stylingContainer = null;
13980
13928
  this.tooltipReference = null;
13981
13929
  this.tooltipIconReference = null;
@@ -14034,8 +13982,7 @@ const TwofaInput = class {
14034
13982
  if (nextInput) {
14035
13983
  nextInput.focus();
14036
13984
  }
14037
- this.setValidity();
14038
- this.setErrorMessage();
13985
+ this.updateValidity();
14039
13986
  };
14040
13987
  this.setClientStyling = () => {
14041
13988
  let sheet = document.createElement('style');
@@ -14088,7 +14035,6 @@ const TwofaInput = class {
14088
14035
  }
14089
14036
  }
14090
14037
  connectedCallback() {
14091
- this.validationPattern = this.setPattern();
14092
14038
  this.code = new Array(this.validation.maxLength).fill('');
14093
14039
  }
14094
14040
  componentDidRender() {
@@ -14100,7 +14046,7 @@ const TwofaInput = class {
14100
14046
  }
14101
14047
  }
14102
14048
  componentDidLoad() {
14103
- this.setValidity();
14049
+ this.isValid = this.validate().isValid;
14104
14050
  }
14105
14051
  handleKeyDown(e, idx) {
14106
14052
  if (e.key === 'Backspace') {
@@ -14113,8 +14059,7 @@ const TwofaInput = class {
14113
14059
  prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14114
14060
  }
14115
14061
  }
14116
- this.setValidity();
14117
- this.setErrorMessage();
14062
+ this.updateValidity();
14118
14063
  }
14119
14064
  handlePaste(e) {
14120
14065
  var _a;
@@ -14133,33 +14078,20 @@ const TwofaInput = class {
14133
14078
  if (lastInput) {
14134
14079
  lastInput.focus();
14135
14080
  }
14136
- this.setValidity();
14137
- this.setErrorMessage();
14081
+ this.updateValidity();
14138
14082
  }
14139
- setValidity() {
14083
+ validate() {
14140
14084
  const code = this.code.join('');
14141
- const inputMatchLength = code.length === this.validation.maxLength;
14142
- const inputMatchValidation = code.match(this.validationPattern) !== null;
14143
- this.isValid = inputMatchLength && inputMatchValidation;
14144
- }
14145
- setPattern() {
14146
- var _a, _b;
14147
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
14148
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
14149
- }
14085
+ const failedRule = getFailedRegexRule(code, this.validation.custom);
14086
+ return {
14087
+ isValid: code.length === this.validation.maxLength && !failedRule,
14088
+ errorMessage: failedRule ? getRuleErrorMessage(failedRule, this.language) : ''
14089
+ };
14150
14090
  }
14151
- setErrorMessage() {
14152
- var _a;
14153
- const inputMatchValidation = this.code.join('').match(this.validationPattern) !== null;
14154
- if (!inputMatchValidation) {
14155
- const errorKey = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
14156
- if (errorKey) {
14157
- this.errorMessage = translate(errorKey, this.language);
14158
- }
14159
- }
14160
- else {
14161
- this.errorMessage = '';
14162
- }
14091
+ updateValidity() {
14092
+ const { isValid, errorMessage } = this.validate();
14093
+ this.isValid = isValid;
14094
+ this.errorMessage = errorMessage;
14163
14095
  }
14164
14096
  renderTooltip() {
14165
14097
  if (this.showTooltip) {
@@ -14168,9 +14100,9 @@ const TwofaInput = class {
14168
14100
  return null;
14169
14101
  }
14170
14102
  render() {
14171
- return (h("div", { key: '5764336a8995a1ec0e7ff432ce85c8a317e3f01c', class: "twofa" }, h("div", { key: '8ea47ba6bb5f552afcde936f1de8c544f89e12a7', class: 'twofa__error-message' }, h("p", { key: '6930908b1f5df7030d96a442779203747aa938b2' }, this.errorMessage)), h("div", { key: '56f116fa0ac4883d1b225b7165b2d5271a661d9d', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), h("div", { key: 'b2ecadecbc8802c5b4dd09d81dc77e66f2108990', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14103
+ return (h("div", { key: '31164396a440bde033871a5cbf651546895d8c3d', class: "twofa" }, h("div", { key: 'cc50746fb709c3853cd11fd13c68be93efd811b4', class: 'twofa__error-message' }, h("p", { key: '4a34b178dd4b018daf81ee654f91f79813f801db' }, this.errorMessage)), h("div", { key: '0ac2a794fcb27deb3f40b87fe4758e19e35b53b2', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), h("div", { key: '69fdbfc5be1af6fab8b386179eaa25ea181aec3a', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14172
14104
  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) }));
14173
- })), h("div", { key: '76635a96eb73d77a3259f26d7d74f738e705acf1', class: "twofa__button-wrapper" }, h("p", { key: '66b15896c126c4c7e8d3ba6d22829992df4cfde9', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), h("button", { key: '7e81ec829cfeb48e911d7b88aa9ec7d6f1cbf4e2', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14105
+ })), h("div", { key: '9a9f50ed47da2204cd31a27939d18b42011a1114', class: "twofa__button-wrapper" }, h("p", { key: 'ad90ba428278f90a05f706c67452551f3c75a199', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), h("button", { key: 'cead0e523e873c20dd21982e318b1e37998480b8', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14174
14106
  ? translate('twofaResendButton', this.language)
14175
14107
  : this.formatTime()))));
14176
14108
  }