@everymatrix/general-registration-hsl 0.25.42 → 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.
@@ -5877,6 +5877,13 @@ const DateInput = class {
5877
5877
  };
5878
5878
  DateInput.style = DateInputStyle0;
5879
5879
 
5880
+ function getFailedRegexRule(value, custom) {
5881
+ return (custom || []).find(rule => rule.rule === 'regex' && !new RegExp(rule.pattern).test(value));
5882
+ }
5883
+ function getRuleErrorMessage(rule, language) {
5884
+ return translate(rule.errorKey, language) || rule.errorMessage;
5885
+ }
5886
+
5880
5887
  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}";
5881
5888
  const EmailInputStyle0 = emailInputCss;
5882
5889
 
@@ -5885,7 +5892,6 @@ const EmailInput = class {
5885
5892
  index.registerInstance(this, hostRef);
5886
5893
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
5887
5894
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
5888
- this.validationPattern = '';
5889
5895
  this.touched = false;
5890
5896
  this.handleInput = (event) => {
5891
5897
  this.value = event.target.value;
@@ -5894,14 +5900,12 @@ const EmailInput = class {
5894
5900
  clearTimeout(this.debounceTime);
5895
5901
  }
5896
5902
  this.debounceTime = setTimeout(() => {
5897
- this.isValid = this.setValidity();
5898
- this.errorMessage = this.setErrorMessage();
5903
+ this.updateValidity();
5899
5904
  this.emitValueHandler(true);
5900
5905
  }, 500);
5901
5906
  };
5902
5907
  this.handleBlur = () => {
5903
- this.isValid = this.setValidity();
5904
- this.errorMessage = this.setErrorMessage();
5908
+ this.updateValidity();
5905
5909
  this.touched = true;
5906
5910
  };
5907
5911
  this.setClientStyling = () => {
@@ -5959,9 +5963,6 @@ const EmailInput = class {
5959
5963
  }
5960
5964
  }
5961
5965
  }
5962
- connectedCallback() {
5963
- this.validationPattern = this.setPattern();
5964
- }
5965
5966
  componentDidRender() {
5966
5967
  // start custom styling area
5967
5968
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -5972,39 +5973,39 @@ const EmailInput = class {
5972
5973
  // end custom styling area
5973
5974
  }
5974
5975
  componentDidLoad() {
5975
- this.isValid = this.setValidity();
5976
+ this.isValid = this.validate().isValid;
5976
5977
  if (this.defaultValue) {
5977
5978
  this.value = this.defaultValue;
5978
5979
  this.valueHandler({ name: this.name, value: this.value });
5979
5980
  }
5980
5981
  }
5981
- setValidity() {
5982
- return this.inputReference.validity.valid;
5982
+ updateValidity() {
5983
+ const { isValid, errorMessage } = this.validate();
5984
+ this.isValid = isValid;
5985
+ this.errorMessage = errorMessage;
5983
5986
  }
5984
- setPattern() {
5987
+ validate() {
5985
5988
  var _a, _b;
5986
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
5987
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
5989
+ if (!this.inputReference) {
5990
+ return { isValid: false, errorMessage: '' };
5988
5991
  }
5989
- }
5990
- setErrorMessage() {
5991
- var _a, _b, _c, _d;
5992
5992
  if (this.inputReference.validity.valueMissing) {
5993
- return translate('requiredError', this.language);
5993
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
5994
5994
  }
5995
5995
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
5996
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
5996
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
5997
5997
  }
5998
- if (this.inputReference.validity.patternMismatch) {
5999
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
6000
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
6001
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
5998
+ const inputValue = this.inputReference.value;
5999
+ const failedRegexRule = inputValue ? getFailedRegexRule(inputValue, this.validation.custom) : undefined;
6000
+ if (failedRegexRule) {
6001
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRegexRule, this.language) };
6002
6002
  }
6003
6003
  if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
6004
- const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
6005
- const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
6006
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
6004
+ const errorCode = (_a = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _a === void 0 ? void 0 : _a.errorKey;
6005
+ const errorMessage = (_b = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _b === void 0 ? void 0 : _b.errorMessage;
6006
+ return { isValid: false, errorMessage: translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage };
6007
6007
  }
6008
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
6008
6009
  }
6009
6010
  renderTooltip() {
6010
6011
  if (this.showTooltip) {
@@ -6017,8 +6018,8 @@ const EmailInput = class {
6017
6018
  if (this.touched) {
6018
6019
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
6019
6020
  }
6020
- return index.h("div", { key: '45255f597fcc76fa5e99601d7c2dd59afca32dbe', class: `email__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '7e41609760d4cc0b5acb554749fce42e6bc88ef3', class: 'email__wrapper--flex' }, index.h("label", { key: '250a1656d714e8cbc943d153aa216a6322322534', class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '80db5747730aaac2c1d0efa3129dfa5463fe779c', class: 'email__wrapper--relative' }, this.tooltip &&
6021
- index.h("img", { key: 'f10990c70bb3de310d137fa120575ad3582adbd3', class: 'email__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: '1610834f1705f70bd1f2d4b0a6c37af3307cf77f', class: 'email__error-message' }, this.errorMessage));
6021
+ return index.h("div", { key: 'ff5657194151b872247fd966bc8dc7ab53f715de', class: `email__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '8dc84da8787a50232fda2c113cf838598525a550', class: 'email__wrapper--flex' }, index.h("label", { key: 'b42e56122de79d841d99e183c6ed818a74c22020', class: `email__label ${this.validation.mandatory ? 'email__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '7f09b2b675b28eebcd1e913b0cbdd43feb83b567', class: 'email__wrapper--relative' }, this.tooltip &&
6022
+ index.h("img", { key: '64c6c3565b60480d279a434f87efa36625da934b', class: 'email__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: '2d72cdde55c1a6b041bb37a1b5a2f3e1c17b558a', class: 'email__error-message' }, this.errorMessage));
6022
6023
  }
6023
6024
  static get watchers() { return {
6024
6025
  "clientStyling": ["handleStylingChange"],
@@ -12774,7 +12775,6 @@ const NumberInput = class {
12774
12775
  index.registerInstance(this, hostRef);
12775
12776
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
12776
12777
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
12777
- this.validationPattern = '';
12778
12778
  this.touched = false;
12779
12779
  this.handleInput = (event) => {
12780
12780
  this.value = event.target.value;
@@ -12783,14 +12783,12 @@ const NumberInput = class {
12783
12783
  clearTimeout(this.debounceTime);
12784
12784
  }
12785
12785
  this.debounceTime = setTimeout(() => {
12786
- this.isValid = this.setValidity();
12787
- this.errorMessage = this.setErrorMessage();
12786
+ this.updateValidity();
12788
12787
  this.emitValueHandler(true);
12789
12788
  }, 500);
12790
12789
  };
12791
12790
  this.handleBlur = () => {
12792
- this.isValid = this.setValidity();
12793
- this.errorMessage = this.setErrorMessage();
12791
+ this.updateValidity();
12794
12792
  this.touched = true;
12795
12793
  };
12796
12794
  this.setClientStyling = () => {
@@ -12840,9 +12838,6 @@ const NumberInput = class {
12840
12838
  this.showTooltip = false;
12841
12839
  }
12842
12840
  }
12843
- connectedCallback() {
12844
- this.validationPattern = this.setPattern();
12845
- }
12846
12841
  componentDidRender() {
12847
12842
  // start custom styling area
12848
12843
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -12853,34 +12848,33 @@ const NumberInput = class {
12853
12848
  // end custom styling area
12854
12849
  }
12855
12850
  componentDidLoad() {
12856
- this.isValid = this.setValidity();
12851
+ this.isValid = this.validate().isValid;
12857
12852
  if (this.defaultValue) {
12858
12853
  this.value = this.defaultValue;
12859
12854
  this.valueHandler({ name: this.name, value: this.value });
12860
12855
  }
12861
12856
  }
12862
- setValidity() {
12863
- return this.inputReference.validity.valid;
12857
+ updateValidity() {
12858
+ const { isValid, errorMessage } = this.validate();
12859
+ this.isValid = isValid;
12860
+ this.errorMessage = errorMessage;
12864
12861
  }
12865
- setPattern() {
12866
- var _a, _b;
12867
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
12868
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
12862
+ validate() {
12863
+ if (!this.inputReference) {
12864
+ return { isValid: false, errorMessage: '' };
12869
12865
  }
12870
- }
12871
- setErrorMessage() {
12872
- var _a, _b;
12873
12866
  if (this.inputReference.validity.valueMissing) {
12874
- return translate('requiredError', this.language);
12867
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
12875
12868
  }
12876
12869
  if (this.inputReference.validity.rangeUnderflow || this.inputReference.validity.rangeOverflow) {
12877
- return translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } });
12870
+ return { isValid: false, errorMessage: translate('numberLengthError', this.language, { values: { min: this.validation.min, max: this.validation.max } }) };
12878
12871
  }
12879
- if (this.inputReference.validity.patternMismatch) {
12880
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
12881
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
12882
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
12872
+ const value = this.inputReference.value;
12873
+ const failedRule = value ? getFailedRegexRule(value, this.validation.custom) : undefined;
12874
+ if (failedRule) {
12875
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRule, this.language) };
12883
12876
  }
12877
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
12884
12878
  }
12885
12879
  renderTooltip() {
12886
12880
  if (this.showTooltip) {
@@ -12893,8 +12887,8 @@ const NumberInput = class {
12893
12887
  if (this.touched) {
12894
12888
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
12895
12889
  }
12896
- return index.h("div", { key: 'f0e6e6edb5d8e3f509474ef5536cb7ef717a5ee9', class: `number__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: 'c991d1e6ed0f9910104b46105daad5332200ee21', class: 'number__wrapper--flex' }, index.h("label", { key: 'd6912229dac4712f4f8e77a90f7ba0ebb7dd5548', class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '5733806c60cad364e61fc66e25f89a44159e8ad9', class: 'number__wrapper--relative' }, this.tooltip &&
12897
- index.h("img", { key: '7ba9ca8048d04c41f800fccf03297e2db9a9115d', class: 'number__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: '5217c1b0b4f4d9f741b5cdf6b7c3f01ef61fe180', class: 'number__error-message' }, this.errorMessage));
12890
+ return index.h("div", { key: 'edc8799baa52418673dcfccb82b1ff9d86159787', class: `number__wrapper ${this.autofilled ? 'number__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '9d6313a06ff4fcd1174879745d48d37ac63c64a5', class: 'number__wrapper--flex' }, index.h("label", { key: '404af2d79da04a3156ebce45aae6d06ea21b5dc1', class: `number__label ${this.validation.mandatory ? 'number__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '349120e9587af42941de2fd2405dc0b9b763372f', class: 'number__wrapper--relative' }, this.tooltip &&
12891
+ index.h("img", { key: '652d145a6a794f0e8370641d3f7fb28099603d62', class: 'number__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: '87e3e5afb6c790f9c57d79bdf0e12a897b10d799', class: 'number__error-message' }, this.errorMessage));
12898
12892
  }
12899
12893
  static get watchers() { return {
12900
12894
  "clientStyling": ["handleStylingChange"],
@@ -12915,7 +12909,6 @@ const PasswordInput = class {
12915
12909
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
12916
12910
  this.touched = false;
12917
12911
  this.originalValid = false;
12918
- this.validationPattern = '';
12919
12912
  this.duplicateInputValue = null;
12920
12913
  this.handleInput = (event) => {
12921
12914
  this.value = event.target.value;
@@ -12926,8 +12919,7 @@ const PasswordInput = class {
12926
12919
  clearTimeout(this.debounceTime);
12927
12920
  }
12928
12921
  this.debounceTime = setTimeout(() => {
12929
- this.isValid = this.setValidity();
12930
- this.errorMessage = this.setErrorMessage();
12922
+ this.updateValidity();
12931
12923
  this.emitValueHandler(true);
12932
12924
  }, 500);
12933
12925
  };
@@ -12939,8 +12931,7 @@ const PasswordInput = class {
12939
12931
  this.value = event.target.value;
12940
12932
  this.showPopup = false;
12941
12933
  this.touched = true;
12942
- this.isValid = this.setValidity();
12943
- this.errorMessage = this.setErrorMessage();
12934
+ this.updateValidity();
12944
12935
  };
12945
12936
  this.handleFocus = () => {
12946
12937
  this.showPopup = true;
@@ -12985,7 +12976,7 @@ const PasswordInput = class {
12985
12976
  if (!this.isDuplicateInput) {
12986
12977
  // recalculate complexity immediately in order to send the correct validity to the duplicate
12987
12978
  this.calculateComplexity(this.value);
12988
- this.sendOriginalValidityState.emit({ name: this.name, valid: this.setValidity() });
12979
+ this.sendOriginalValidityState.emit({ name: this.name, valid: this.validate().isValid });
12989
12980
  }
12990
12981
  }
12991
12982
  emitValueHandler(newValue) {
@@ -13003,13 +12994,13 @@ const PasswordInput = class {
13003
12994
  if (this.isDuplicateInput) {
13004
12995
  if (event.detail.valid) {
13005
12996
  this.originalValid = true;
13006
- this.isValid = this.setValidity();
12997
+ this.isValid = this.validate().isValid;
13007
12998
  }
13008
12999
  else {
13009
13000
  this.originalValid = false;
13010
13001
  this.isValid = false;
13011
13002
  // only show error if the user has touched the input, in order to not show errors on empty inputs
13012
- this.value !== '' && (this.errorMessage = this.setErrorMessage());
13003
+ this.value !== '' && (this.errorMessage = this.validate().errorMessage);
13013
13004
  }
13014
13005
  }
13015
13006
  }
@@ -13017,15 +13008,13 @@ const PasswordInput = class {
13017
13008
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
13018
13009
  this.duplicateInputValue = event.detail.value;
13019
13010
  if (this.touched) {
13020
- this.isValid = this.setValidity();
13021
- this.errorMessage = this.setErrorMessage();
13011
+ this.updateValidity();
13022
13012
  }
13023
13013
  }
13024
13014
  if (this.name === event.detail.name + 'Duplicate'
13025
13015
  && this.name.replace('Duplicate', '') === event.detail.name
13026
13016
  && this.touched === true) {
13027
- this.isValid = this.setValidity();
13028
- this.errorMessage = this.setErrorMessage();
13017
+ this.updateValidity();
13029
13018
  }
13030
13019
  }
13031
13020
  handleClickOutside(event) {
@@ -13059,7 +13048,7 @@ const PasswordInput = class {
13059
13048
  this.touched = true;
13060
13049
  }
13061
13050
  }
13062
- this.isValid = this.setValidity();
13051
+ this.isValid = this.validate().isValid;
13063
13052
  }
13064
13053
  disconnectedCallback() {
13065
13054
  this.passwordButton.removeEventListener('click', this.handleRevealField);
@@ -13073,48 +13062,36 @@ const PasswordInput = class {
13073
13062
  return { rule: rule.displayName, ruleKey: rule.errorKey, passed };
13074
13063
  });
13075
13064
  }
13076
- setValidity() {
13077
- var _a, _b;
13078
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13079
- return false;
13080
- }
13081
- else if (!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed))) {
13082
- return false;
13083
- }
13084
- else {
13085
- return (_b = this.inputReference) === null || _b === void 0 ? void 0 : _b.validity.valid;
13086
- }
13087
- }
13088
- setPattern() {
13065
+ validate() {
13089
13066
  var _a, _b;
13090
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
13091
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
13067
+ if (!this.inputReference) {
13068
+ return { isValid: false, errorMessage: '' };
13092
13069
  }
13093
- }
13094
- setErrorMessage() {
13095
- var _a, _b, _c, _d, _e;
13096
- if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
13097
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13070
+ const validity = this.inputReference.validity;
13071
+ const duplicateMismatch = this.isDuplicateInput && this.duplicateInputValue !== this.value;
13072
+ const complexityPassed = !!((_a = this.passwordComplexity) === null || _a === void 0 ? void 0 : _a.every(complexity => complexity.passed));
13073
+ if (validity.tooShort || validity.tooLong) {
13074
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
13098
13075
  }
13099
- if (this.inputReference.validity.valueMissing) {
13100
- return translate('requiredError', this.language);
13076
+ if (validity.valueMissing) {
13077
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13101
13078
  }
13102
13079
  if (this.isDuplicateInput && !this.originalValid) {
13103
- return translate('invalidOriginalPasswordError', this.language);
13104
- }
13105
- if (this.inputReference.validity.patternMismatch) {
13106
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
13107
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13108
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13080
+ return { isValid: false, errorMessage: translate('invalidOriginalPasswordError', this.language) };
13109
13081
  }
13110
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13111
- const errorCode = (_c = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _c === void 0 ? void 0 : _c.errorKey;
13112
- const errorMessage = (_d = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _d === void 0 ? void 0 : _d.errorMessage;
13113
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13082
+ if (duplicateMismatch) {
13083
+ const duplicateRule = (_b = this.validation.custom) === null || _b === void 0 ? void 0 : _b.find(customRule => customRule.rule === 'duplicate-input');
13084
+ return { isValid: false, errorMessage: duplicateRule ? getRuleErrorMessage(duplicateRule, this.language) : '' };
13114
13085
  }
13115
- if (!((_e = this.passwordComplexity) === null || _e === void 0 ? void 0 : _e.every(complexity => complexity.passed)) && !this.showPopup) {
13116
- return translate('invalidPassword', this.language);
13086
+ if (!complexityPassed) {
13087
+ return { isValid: false, errorMessage: this.showPopup ? '' : translate('invalidPassword', this.language) };
13117
13088
  }
13089
+ return { isValid: validity.valid, errorMessage: '' };
13090
+ }
13091
+ updateValidity() {
13092
+ const { isValid, errorMessage } = this.validate();
13093
+ this.isValid = isValid;
13094
+ this.errorMessage = errorMessage;
13118
13095
  }
13119
13096
  renderTooltip() {
13120
13097
  if (this.showTooltip) {
@@ -13136,8 +13113,8 @@ const PasswordInput = class {
13136
13113
  if (this.touched) {
13137
13114
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13138
13115
  }
13139
- return index.h("div", { key: 'e6a288d18a095de747c7eec28bcf117e5069cbc1', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: 'e2885669879d0b61473be48014975859d87b2478', class: 'password__wrapper--flex' }, index.h("label", { key: 'c12f0a0bfe91a9da9688ab0acd39f6a44eec5d0a', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: 'f501cb74b838d2c4a1a1fd38086203e4b1c98dfe', class: 'password__wrapper--relative' }, this.tooltip &&
13140
- index.h("img", { key: '68d71061fb6be2245298e521b511e57b4cb12cbb', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("vaadin-password-field", { key: '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 }), index.h("small", { key: 'ca4aeae4893276dc96bd7187aef5ac2ed86d35c8', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13116
+ return index.h("div", { key: '9fd27b840b317bbb224f062c855c4b4a8b94a3a4', class: `password__wrapper ${this.autofilled ? 'password__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '3d16837c2e10a490fd07ef1c294db1f5732da4ad', class: 'password__wrapper--flex' }, index.h("label", { key: '09d61fc66912e7a79b83842e4d6d89b851a92afa', class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '23f4d60bc9f777d00fd16d2dc78cc7c105307e32', class: 'password__wrapper--relative' }, this.tooltip &&
13117
+ index.h("img", { key: 'db104e01e0f5d5d322b3394f8740cedaaa8b2199', class: 'password__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("vaadin-password-field", { key: '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 }), index.h("small", { key: '41336c3bd58eba953266b31980ce0677b27405f0', class: 'password__error-message' }, this.errorMessage), this.passwordComplexity && this.showPopup && !this.hidePasswordComplexity && !this.isDuplicateInput && this.renderComplexityPopup());
13141
13118
  }
13142
13119
  get element() { return index.getElement(this); }
13143
13120
  static get watchers() { return {
@@ -13458,7 +13435,6 @@ const TelInput = class {
13458
13435
  index.registerInstance(this, hostRef);
13459
13436
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
13460
13437
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
13461
- this.validationPattern = '';
13462
13438
  this.touched = false;
13463
13439
  this.handleInput = (event) => {
13464
13440
  const inputElement = event.target;
@@ -13472,15 +13448,13 @@ const TelInput = class {
13472
13448
  clearTimeout(this.debounceTime);
13473
13449
  }
13474
13450
  this.debounceTime = setTimeout(() => {
13475
- this.isValid = this.setValidity();
13476
- this.errorMessage = this.setErrorMessage();
13451
+ this.updateValidity();
13477
13452
  this.emitValueHandler(true);
13478
13453
  }, 500);
13479
13454
  };
13480
13455
  this.handleBlur = () => {
13481
13456
  if (!this.touched) {
13482
- this.isValid = this.setValidity();
13483
- this.errorMessage = this.setErrorMessage();
13457
+ this.updateValidity();
13484
13458
  this.touched = true;
13485
13459
  }
13486
13460
  };
@@ -13535,7 +13509,6 @@ const TelInput = class {
13535
13509
  }
13536
13510
  }
13537
13511
  connectedCallback() {
13538
- this.validationPattern = this.setPattern();
13539
13512
  if (this.defaultValue) {
13540
13513
  this.prefixValue = this.defaultValue.prefix ? this.defaultValue.prefix : this.defaultValue;
13541
13514
  this.phoneValue = this.defaultValue.phone || null;
@@ -13565,7 +13538,7 @@ const TelInput = class {
13565
13538
  // end custom styling area
13566
13539
  }
13567
13540
  componentDidLoad() {
13568
- this.isValid = this.setValidity();
13541
+ this.isValid = this.validate().isValid;
13569
13542
  if (this.defaultValue) {
13570
13543
  this.value = this.defaultValue;
13571
13544
  this.valueHandler({ name: this.name, value: this.value, type: 'tel' });
@@ -13589,28 +13562,27 @@ const TelInput = class {
13589
13562
  this.value = { prefix: this.prefixValue, phone: this.phoneValue };
13590
13563
  this.emitValueHandler(true);
13591
13564
  }
13592
- setValidity() {
13593
- return this.inputReference.validity.valid;
13594
- }
13595
- setPattern() {
13596
- var _a, _b;
13597
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
13598
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
13565
+ validate() {
13566
+ if (!this.inputReference) {
13567
+ return { isValid: false, errorMessage: '' };
13599
13568
  }
13600
- }
13601
- setErrorMessage() {
13602
- var _a, _b;
13603
- if (this.inputReference.validity.patternMismatch) {
13604
- const errorCode = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
13605
- const errorMessage = (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13606
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13569
+ const value = this.inputReference.value;
13570
+ const failedRule = value ? getFailedRegexRule(value, this.validation.custom) : undefined;
13571
+ if (failedRule) {
13572
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRule, this.language) };
13607
13573
  }
13608
13574
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
13609
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13575
+ return { isValid: false, errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } }) };
13610
13576
  }
13611
13577
  if (this.inputReference.validity.valueMissing) {
13612
- return translate('requiredError', this.language);
13578
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13613
13579
  }
13580
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
13581
+ }
13582
+ updateValidity() {
13583
+ const { isValid, errorMessage } = this.validate();
13584
+ this.isValid = isValid;
13585
+ this.errorMessage = errorMessage;
13614
13586
  }
13615
13587
  renderTooltip() {
13616
13588
  if (this.showTooltip) {
@@ -13623,8 +13595,8 @@ const TelInput = class {
13623
13595
  if (this.touched) {
13624
13596
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13625
13597
  }
13626
- return index.h("div", { key: '8a75a1a66dae4a9f453487be42c8563fc94c9338', class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '01589400f59390352949240162a96874be011f03', class: 'tel__wrapper--flex-label' }, index.h("label", { key: '73beb8ce7ea80ea4fca24db633e021dbab04f9ba', class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '56eaf52390a9dd93342324a1bf87a1b7a9f04b97', class: 'tel__wrapper--relative' }, this.tooltip &&
13627
- index.h("img", { key: '198fc851fb3ea4763607cfe2b0e08414e07adfe5', class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("div", { key: '4cbf87d5e3be55ce0d23ec1ab223e168e4991a9f', class: `tel__wrapper--flex ${invalidClass}` }, index.h("vaadin-combo-box", { key: '3898ad1468b4f03d4ebaf24d0898e70988663f6d', class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), index.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 })), index.h("small", { key: 'a33de6b2bec2b9dd79fa9960a7bbacc9845d8c51', class: 'tel__error-message' }, this.errorMessage));
13598
+ return index.h("div", { key: '78ddea111a011a7c75df7a6f7101aafccbaff4a1', class: `tel__wrapper ${this.autofilled ? 'tel__wrapper--autofilled' : ''} ${this.name}__input`, ref: el => this.stylingContainer = el }, index.h("div", { key: '9dcd9723ed26de04630a8a174e902a629bc9347c', class: 'tel__wrapper--flex-label' }, index.h("label", { key: '597e8a28990f12e1183fdeb315e176af970d4104', class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '86c147c124468d06bffdf8359c7f404cbe897c15', class: 'tel__wrapper--relative' }, this.tooltip &&
13599
+ index.h("img", { key: '0d2b528570401361087bf0438493a96a3450e40c', class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.h("div", { key: 'd82808bbc28c720ae4cff45fd1d0df88ca320029', class: `tel__wrapper--flex ${invalidClass}` }, index.h("vaadin-combo-box", { key: '73805b42a6b40d901e6367e45e4d6d1ff2288082', class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), index.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 })), index.h("small", { key: '296651863f2d6fcf31eb21f2d83b7df505d59833', class: 'tel__error-message' }, this.errorMessage));
13628
13600
  }
13629
13601
  static get watchers() { return {
13630
13602
  "clientStyling": ["handleStylingChange"],
@@ -13643,7 +13615,6 @@ const TextInput = class {
13643
13615
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
13644
13616
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
13645
13617
  this.value = '';
13646
- this.validationPattern = [];
13647
13618
  this.duplicateInputValue = null;
13648
13619
  this.handleInput = (event) => {
13649
13620
  const inputElement = event.target;
@@ -13657,8 +13628,7 @@ const TextInput = class {
13657
13628
  clearTimeout(this.debounceTime);
13658
13629
  }
13659
13630
  this.debounceTime = setTimeout(() => {
13660
- this.isValid = this.setValidity();
13661
- this.errorMessage = this.setErrorMessage();
13631
+ this.updateValidity();
13662
13632
  this.validityStateHandler({ valid: this.isValid, name: this.name });
13663
13633
  this.emitValueHandler(true);
13664
13634
  }, 500);
@@ -13666,8 +13636,7 @@ const TextInput = class {
13666
13636
  this.handleBlur = (event) => {
13667
13637
  this.value = event.target.value;
13668
13638
  this.touched = true;
13669
- this.isValid = this.setValidity();
13670
- this.errorMessage = this.setErrorMessage();
13639
+ this.updateValidity();
13671
13640
  this.validityStateHandler({ valid: this.isValid, name: this.name });
13672
13641
  };
13673
13642
  this.setClientStyling = () => {
@@ -13698,10 +13667,11 @@ const TextInput = class {
13698
13667
  if (newValue) {
13699
13668
  this.value = newValue;
13700
13669
  requestAnimationFrame(() => {
13701
- this.isValid = this.setValidity();
13702
- if (!this.isValid && !this.touched) {
13670
+ const { isValid, errorMessage } = this.validate();
13671
+ this.isValid = isValid;
13672
+ if (!isValid && !this.touched) {
13703
13673
  this.touched = true;
13704
- this.errorMessage = this.setErrorMessage();
13674
+ this.errorMessage = errorMessage;
13705
13675
  }
13706
13676
  });
13707
13677
  }
@@ -13737,15 +13707,13 @@ const TextInput = class {
13737
13707
  if (this.isDuplicateInput && this.name === event.detail.name + 'Duplicate') {
13738
13708
  this.duplicateInputValue = event.detail.value;
13739
13709
  if (this.touched) {
13740
- this.isValid = this.setValidity();
13741
- this.errorMessage = this.setErrorMessage();
13710
+ this.updateValidity();
13742
13711
  }
13743
13712
  }
13744
13713
  if (this.name === event.detail.name + 'Duplicate'
13745
13714
  && this.name.replace('Duplicate', '') === event.detail.name
13746
13715
  && this.touched === true) {
13747
- this.isValid = this.setValidity();
13748
- this.errorMessage = this.setErrorMessage();
13716
+ this.updateValidity();
13749
13717
  }
13750
13718
  }
13751
13719
  handleValidationChange(event) {
@@ -13753,15 +13721,10 @@ const TextInput = class {
13753
13721
  return;
13754
13722
  }
13755
13723
  this.validation = event.detail.validation;
13756
- this.validationPattern = this.setPattern();
13757
13724
  if (this.touched) {
13758
- this.isValid = this.setValidity();
13759
- this.errorMessage = this.setErrorMessage();
13725
+ this.updateValidity();
13760
13726
  }
13761
13727
  }
13762
- connectedCallback() {
13763
- this.validationPattern = this.setPattern();
13764
- }
13765
13728
  componentDidRender() {
13766
13729
  // start custom styling area
13767
13730
  if (!this.limitStylingAppends && this.stylingContainer) {
@@ -13778,7 +13741,7 @@ const TextInput = class {
13778
13741
  this.validation.minLength &&
13779
13742
  this.inputReference.value.length < this.validation.minLength) {
13780
13743
  this.touched = true;
13781
- this.errorMessage = this.setErrorMessage();
13744
+ this.errorMessage = this.validate().errorMessage;
13782
13745
  }
13783
13746
  }
13784
13747
  componentDidLoad() {
@@ -13789,54 +13752,40 @@ const TextInput = class {
13789
13752
  this.touched = true;
13790
13753
  }
13791
13754
  }
13792
- this.isValid = this.setValidity();
13755
+ this.isValid = this.validate().isValid;
13793
13756
  }
13794
- setValidity() {
13795
- if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13796
- return false;
13797
- }
13757
+ updateValidity() {
13758
+ const { isValid, errorMessage } = this.validate();
13759
+ this.isValid = isValid;
13760
+ this.errorMessage = errorMessage;
13761
+ }
13762
+ validate() {
13763
+ var _a;
13798
13764
  if (!this.inputReference) {
13799
- return false;
13765
+ return { isValid: false, errorMessage: '' };
13800
13766
  }
13801
13767
  const inputValue = this.inputReference.value;
13802
- const inputIsValid = this.inputReference.validity.valid;
13803
- const inputMatchValidation = !inputValue
13804
- || (this.validationPattern.length > 0 ? this.validationPattern.some((pattern) => inputValue.match(pattern) !== null) : true);
13805
- // Fallback: if HTML5 says valid but minlength constraint not met, it's invalid
13806
- const isTooShort = this.validation.minLength && inputValue.length > 0 && inputValue.length < this.validation.minLength;
13807
- return !isTooShort && inputIsValid && inputMatchValidation;
13808
- }
13809
- setPattern() {
13810
- const custom = this.validation.custom;
13811
- if (!(custom === null || custom === void 0 ? void 0 : custom.length))
13812
- return [];
13813
- return custom
13814
- .filter(v => v.rule === 'regex')
13815
- .map(v => v.pattern);
13816
- }
13817
- setErrorMessage() {
13818
- var _a, _b;
13819
- const inputValue = this.inputReference.value;
13820
13768
  if (this.inputReference.validity.valueMissing) {
13821
- return translate('requiredError', this.language);
13769
+ return { isValid: false, errorMessage: translate('requiredError', this.language) };
13822
13770
  }
13823
13771
  // Check length manually (fallback for HTML5 validation API issues)
13824
13772
  const isTooShort = this.validation.minLength && inputValue.length > 0 && inputValue.length < this.validation.minLength;
13825
13773
  const isTooLong = this.validation.maxLength && inputValue.length > this.validation.maxLength;
13826
13774
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong || isTooShort || isTooLong) {
13827
- return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
13775
+ return {
13776
+ isValid: false,
13777
+ errorMessage: translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } })
13778
+ };
13828
13779
  }
13829
- const isCustomError = !(inputValue === '' && !this.validation.mandatory)
13830
- && (this.validationPattern.length > 0 ? this.validationPattern.some((pattern) => inputValue.match(pattern) == null) : false);
13831
- if (isCustomError) {
13832
- const { errorKey: errorCode, errorMessage } = this.validation.custom.find(customValidation => customValidation.rule === 'regex');
13833
- return translate(`${errorCode}`, this.language) || errorMessage;
13780
+ const failedRegexRule = inputValue ? getFailedRegexRule(inputValue, this.validation.custom) : undefined;
13781
+ if (failedRegexRule) {
13782
+ return { isValid: false, errorMessage: getRuleErrorMessage(failedRegexRule, this.language) };
13834
13783
  }
13835
13784
  if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
13836
- const errorCode = (_a = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _a === void 0 ? void 0 : _a.errorKey;
13837
- const errorMessage = (_b = this.validation.custom.find(customRule => customRule.rule === 'duplicate-input')) === null || _b === void 0 ? void 0 : _b.errorMessage;
13838
- return translate(`${errorCode}`, this.language) ? translate(`${errorCode}`, this.language) : errorMessage;
13785
+ const duplicateRule = (_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.find(customRule => customRule.rule === 'duplicate-input');
13786
+ return { isValid: false, errorMessage: duplicateRule ? getRuleErrorMessage(duplicateRule, this.language) : '' };
13839
13787
  }
13788
+ return { isValid: this.inputReference.validity.valid, errorMessage: '' };
13840
13789
  }
13841
13790
  renderTooltip() {
13842
13791
  if (this.showTooltip) {
@@ -13849,8 +13798,8 @@ const TextInput = class {
13849
13798
  if (this.touched) {
13850
13799
  invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
13851
13800
  }
13852
- return index.h("div", { key: '045e3183bdb1c7279abbd045043d789387956de5', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, index.h("div", { key: '3534d1261f9ccb9c0942f01d0758d9fd65743e40', class: 'text__wrapper--flex' }, index.h("label", { key: '171155d911e2c1048b003be8541671f0cdeb1ce5', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '8a0b0abe15eaf77b5efc5fa6374a8faeea24cf94', class: 'text__wrapper--relative' }, this.tooltip &&
13853
- index.h("img", { key: 'aa0b0b33cdb370289db8444c3dba915ef8eb77be', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: 'ce7b97e0a7db8eb87c608690bad3cf99a565ba9f', class: 'text__error-message' }, this.errorMessage));
13801
+ return index.h("div", { key: '206f2e3c3cf18b4405c07be422bb6173ac3a2ac2', class: `text__wrapper ${this.name}__input ${this.autofilled ? 'text__wrapper--autofilled' : ''}`, ref: el => this.stylingContainer = el }, index.h("div", { key: 'b6aa572d3f984a386a850b3f968a674eb94f7816', class: 'text__wrapper--flex' }, index.h("label", { key: '7fba5554aac3af6444225cb6da166276470dba50', class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), index.h("div", { key: '9677b43f2f5e185e4d7fcfe007dd73a16d50876b', class: 'text__wrapper--relative' }, this.tooltip &&
13802
+ index.h("img", { key: '69360ef5dd851cf64110f82189c2a27f99c843f8', class: 'text__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), index.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 }), index.h("small", { key: '5db72a6b2c969e3af37eaf03ce3a77524a5f25d2', class: 'text__error-message' }, this.errorMessage));
13854
13803
  }
13855
13804
  static get watchers() { return {
13856
13805
  "defaultValue": ["handleDefaultValueChange"],
@@ -13979,7 +13928,6 @@ const TwofaInput = class {
13979
13928
  this.sendValidityState = index.createEvent(this, "sendValidityState", 7);
13980
13929
  this.sendInputValue = index.createEvent(this, "sendInputValue", 7);
13981
13930
  this.resendCode = index.createEvent(this, "resendCode", 7);
13982
- this.validationPattern = '';
13983
13931
  this.stylingContainer = null;
13984
13932
  this.tooltipReference = null;
13985
13933
  this.tooltipIconReference = null;
@@ -14038,8 +13986,7 @@ const TwofaInput = class {
14038
13986
  if (nextInput) {
14039
13987
  nextInput.focus();
14040
13988
  }
14041
- this.setValidity();
14042
- this.setErrorMessage();
13989
+ this.updateValidity();
14043
13990
  };
14044
13991
  this.setClientStyling = () => {
14045
13992
  let sheet = document.createElement('style');
@@ -14092,7 +14039,6 @@ const TwofaInput = class {
14092
14039
  }
14093
14040
  }
14094
14041
  connectedCallback() {
14095
- this.validationPattern = this.setPattern();
14096
14042
  this.code = new Array(this.validation.maxLength).fill('');
14097
14043
  }
14098
14044
  componentDidRender() {
@@ -14104,7 +14050,7 @@ const TwofaInput = class {
14104
14050
  }
14105
14051
  }
14106
14052
  componentDidLoad() {
14107
- this.setValidity();
14053
+ this.isValid = this.validate().isValid;
14108
14054
  }
14109
14055
  handleKeyDown(e, idx) {
14110
14056
  if (e.key === 'Backspace') {
@@ -14117,8 +14063,7 @@ const TwofaInput = class {
14117
14063
  prevInput === null || prevInput === void 0 ? void 0 : prevInput.focus();
14118
14064
  }
14119
14065
  }
14120
- this.setValidity();
14121
- this.setErrorMessage();
14066
+ this.updateValidity();
14122
14067
  }
14123
14068
  handlePaste(e) {
14124
14069
  var _a;
@@ -14137,33 +14082,20 @@ const TwofaInput = class {
14137
14082
  if (lastInput) {
14138
14083
  lastInput.focus();
14139
14084
  }
14140
- this.setValidity();
14141
- this.setErrorMessage();
14085
+ this.updateValidity();
14142
14086
  }
14143
- setValidity() {
14087
+ validate() {
14144
14088
  const code = this.code.join('');
14145
- const inputMatchLength = code.length === this.validation.maxLength;
14146
- const inputMatchValidation = code.match(this.validationPattern) !== null;
14147
- this.isValid = inputMatchLength && inputMatchValidation;
14148
- }
14149
- setPattern() {
14150
- var _a, _b;
14151
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
14152
- return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
14153
- }
14089
+ const failedRule = getFailedRegexRule(code, this.validation.custom);
14090
+ return {
14091
+ isValid: code.length === this.validation.maxLength && !failedRule,
14092
+ errorMessage: failedRule ? getRuleErrorMessage(failedRule, this.language) : ''
14093
+ };
14154
14094
  }
14155
- setErrorMessage() {
14156
- var _a;
14157
- const inputMatchValidation = this.code.join('').match(this.validationPattern) !== null;
14158
- if (!inputMatchValidation) {
14159
- const errorKey = (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorKey;
14160
- if (errorKey) {
14161
- this.errorMessage = translate(errorKey, this.language);
14162
- }
14163
- }
14164
- else {
14165
- this.errorMessage = '';
14166
- }
14095
+ updateValidity() {
14096
+ const { isValid, errorMessage } = this.validate();
14097
+ this.isValid = isValid;
14098
+ this.errorMessage = errorMessage;
14167
14099
  }
14168
14100
  renderTooltip() {
14169
14101
  if (this.showTooltip) {
@@ -14172,9 +14104,9 @@ const TwofaInput = class {
14172
14104
  return null;
14173
14105
  }
14174
14106
  render() {
14175
- return (index.h("div", { key: '5764336a8995a1ec0e7ff432ce85c8a317e3f01c', class: "twofa" }, index.h("div", { key: '8ea47ba6bb5f552afcde936f1de8c544f89e12a7', class: 'twofa__error-message' }, index.h("p", { key: '6930908b1f5df7030d96a442779203747aa938b2' }, this.errorMessage)), index.h("div", { key: '56f116fa0ac4883d1b225b7165b2d5271a661d9d', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), index.h("div", { key: 'b2ecadecbc8802c5b4dd09d81dc77e66f2108990', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14107
+ return (index.h("div", { key: '31164396a440bde033871a5cbf651546895d8c3d', class: "twofa" }, index.h("div", { key: 'cc50746fb709c3853cd11fd13c68be93efd811b4', class: 'twofa__error-message' }, index.h("p", { key: '4a34b178dd4b018daf81ee654f91f79813f801db' }, this.errorMessage)), index.h("div", { key: '0ac2a794fcb27deb3f40b87fe4758e19e35b53b2', class: "twofa__description", innerHTML: translate('twofaDescription', this.language, { values: { destination: this.destination } }) }), index.h("div", { key: '69fdbfc5be1af6fab8b386179eaa25ea181aec3a', class: "twofa__input-wrapper", ref: this.setContainerRef }, this.code.map((char, idx) => {
14176
14108
  return (index.h("input", { key: idx, ref: el => this.setInputRef(el, idx), id: `otp-input-${idx}`, type: "text", maxLength: 2, value: char, onInput: (event) => this.handleInput(event, idx), onKeyDown: (event) => this.handleKeyDown(event, idx), onPaste: (event) => this.handlePaste(event) }));
14177
- })), index.h("div", { key: '76635a96eb73d77a3259f26d7d74f738e705acf1', class: "twofa__button-wrapper" }, index.h("p", { key: '66b15896c126c4c7e8d3ba6d22829992df4cfde9', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), index.h("button", { key: '7e81ec829cfeb48e911d7b88aa9ec7d6f1cbf4e2', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14109
+ })), index.h("div", { key: '9a9f50ed47da2204cd31a27939d18b42011a1114', class: "twofa__button-wrapper" }, index.h("p", { key: 'ad90ba428278f90a05f706c67452551f3c75a199', class: "twofa__resend-message" }, translate('twofaResendMessage', this.language)), index.h("button", { key: 'cead0e523e873c20dd21982e318b1e37998480b8', class: "twofa__resend-button", onClick: this.resendCodeHandler, disabled: !this.isResendButtonAvailable }, this.isResendButtonAvailable
14178
14110
  ? translate('twofaResendButton', this.language)
14179
14111
  : this.formatTime()))));
14180
14112
  }