@everymatrix/general-registration 1.10.4 → 1.10.10

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.
Files changed (35) hide show
  1. package/dist/cjs/checkbox-input_11.cjs.entry.js +1118 -487
  2. package/dist/cjs/general-registration.cjs.js +2 -2
  3. package/dist/cjs/{index-9a07d1e9.js → index-68f93e1e.js} +9 -5
  4. package/dist/cjs/loader.cjs.js +2 -2
  5. package/dist/collection/components/general-registration/general-registration.css +40 -14
  6. package/dist/collection/components/general-registration/general-registration.js +153 -300
  7. package/dist/components/checkbox-input2.js +8 -2
  8. package/dist/components/date-input2.js +19 -1441
  9. package/dist/components/email-input2.js +28 -9
  10. package/dist/components/general-input2.js +6 -6
  11. package/dist/components/general-registration.js +112 -274
  12. package/dist/components/input-field-shared-styles.js +13776 -0
  13. package/dist/components/locale.utils.js +1 -1
  14. package/dist/components/number-input2.js +8 -2
  15. package/dist/components/password-input2.js +748 -9
  16. package/dist/components/pattern-mixin.js +84 -0
  17. package/dist/components/radio-input2.js +1 -1
  18. package/dist/components/select-input2.js +8 -4
  19. package/dist/components/tel-input2.js +22 -10
  20. package/dist/components/text-input2.js +27 -18
  21. package/dist/components/vaadin-button.js +1432 -0
  22. package/dist/components/vaadin-combo-box.js +3 -82
  23. package/dist/components/virtual-keyboard-controller.js +2136 -15909
  24. package/dist/esm/checkbox-input_11.entry.js +1118 -487
  25. package/dist/esm/general-registration.js +2 -2
  26. package/dist/esm/{index-0505440f.js → index-16916adb.js} +9 -5
  27. package/dist/esm/loader.js +2 -2
  28. package/dist/general-registration/general-registration.esm.js +1 -1
  29. package/dist/general-registration/p-8f644809.js +1 -0
  30. package/dist/general-registration/{p-6a27a1e0.entry.js → p-fb5bf415.entry.js} +210 -100
  31. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-registration/.stencil/packages/general-input/src/utils/types.d.ts +6 -4
  32. package/dist/types/components/general-registration/general-registration.d.ts +20 -284
  33. package/dist/types/components.d.ts +11 -17
  34. package/package.json +3 -2
  35. package/dist/general-registration/p-1a88a312.js +0 -1
@@ -0,0 +1,84 @@
1
+ import { I as InputConstraintsMixin, D as Debouncer, e as timeOut } from './input-field-shared-styles.js';
2
+
3
+ /**
4
+ * @license
5
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
6
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
7
+ */
8
+
9
+ /**
10
+ * A mixin to provide `pattern` and `preventInvalidInput` properties.
11
+ *
12
+ * @polymerMixin
13
+ * @mixes InputConstraintsMixin
14
+ */
15
+ const PatternMixin = (superclass) =>
16
+ class PatternMixinClass extends InputConstraintsMixin(superclass) {
17
+ static get properties() {
18
+ return {
19
+ /**
20
+ * A regular expression that the value is checked against.
21
+ * The pattern must match the entire value, not just some subset.
22
+ */
23
+ pattern: {
24
+ type: String,
25
+ },
26
+
27
+ /**
28
+ * When set to true, user is prevented from typing a value that
29
+ * conflicts with the given `pattern`.
30
+ * @attr {boolean} prevent-invalid-input
31
+ * @deprecated Please use `allowedCharPattern` instead.
32
+ */
33
+ preventInvalidInput: {
34
+ type: Boolean,
35
+ observer: '_preventInvalidInputChanged',
36
+ },
37
+ };
38
+ }
39
+
40
+ static get delegateAttrs() {
41
+ return [...super.delegateAttrs, 'pattern'];
42
+ }
43
+
44
+ static get constraints() {
45
+ return [...super.constraints, 'pattern'];
46
+ }
47
+
48
+ /** @private */
49
+ _checkInputValue() {
50
+ if (this.preventInvalidInput) {
51
+ const input = this.inputElement;
52
+ if (input && input.value.length > 0 && !this.checkValidity()) {
53
+ input.value = this.value || '';
54
+ // Add input-prevented attribute for 200ms
55
+ this.setAttribute('input-prevented', '');
56
+ this._inputDebouncer = Debouncer.debounce(this._inputDebouncer, timeOut.after(200), () => {
57
+ this.removeAttribute('input-prevented');
58
+ });
59
+ }
60
+ }
61
+ }
62
+
63
+ /**
64
+ * @param {Event} event
65
+ * @protected
66
+ * @override
67
+ */
68
+ _onInput(event) {
69
+ this._checkInputValue();
70
+
71
+ super._onInput(event);
72
+ }
73
+
74
+ /** @private */
75
+ _preventInvalidInputChanged(preventInvalidInput) {
76
+ if (preventInvalidInput) {
77
+ console.warn(
78
+ `WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
79
+ );
80
+ }
81
+ }
82
+ };
83
+
84
+ export { PatternMixin as P };
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { t as translate } from './locale.utils.js';
3
3
 
4
- const radioInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.radio__fieldset{border:none;position:relative}.radio__wrapper{display:flex;gap:5px}.radio__error-message{position:absolute;top:calc(100% + 5px);left:0;color:red}";
4
+ const radioInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.radio__fieldset{border:none;position:relative}.radio__wrapper{display:flex;gap:5px}.radio__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
5
5
 
6
6
  const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -1,9 +1,9 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { t as translate } from './locale.utils.js';
3
- import './virtual-keyboard-controller.js';
3
+ import './input-field-shared-styles.js';
4
4
  import './vaadin-combo-box.js';
5
5
 
6
- const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select__wrapper{position:relative;display:flex;padding-top:10px;width:100%}.select__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.select__label--hidden{opacity:0;visibility:hidden;transform:translateY(0)}.select__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.select__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.select__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
6
+ const selectInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.select{font-family:\"Roboto\";font-style:normal}.select__wrapper{position:relative;width:100%;padding-top:26px}.select__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.select__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.select__input{border:none;width:inherit;position:relative}.select__input[focused]::part(input-field){border-color:#3E3E3E}.select__input[invalid]::part(input-field){border-color:#cc0000b3}.select__input vaadin-date-picker-overlay-content>vaadin-button{color:#1F1F1F}.select__input vaadin-month-calendar::part(selected date){background-color:red}.select__input::part(input-field){border-radius:4px;background-color:#FFFFFF;border:2px solid #DEE1EE;color:#2A2E3F;border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.select__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
7
7
 
8
8
  const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
9
  constructor() {
@@ -54,6 +54,10 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
54
54
  }
55
55
  componentDidLoad() {
56
56
  this.inputReference = this.element.shadowRoot.querySelector('input');
57
+ if (this.defaultValue) {
58
+ this.value = this.defaultValue;
59
+ this.valueHandler({ name: this.name, value: this.value });
60
+ }
57
61
  }
58
62
  getOptions() {
59
63
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
@@ -75,7 +79,6 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
75
79
  this.isValid = this.setValidity();
76
80
  this.validityStateHandler({ valid: this.isValid, name: this.name });
77
81
  this.emitValueHandler(true);
78
- this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
79
82
  }
80
83
  setValidity() {
81
84
  return this.inputReference.validity.valid;
@@ -86,7 +89,8 @@ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
86
89
  }
87
90
  }
88
91
  render() {
89
- return h("div", { class: 'select__wrapper' }, h("label", { class: 'select__label select__label--hidden', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), h("vaadin-combo-box", { name: this.name, id: `${this.name}__input`, class: 'select__input', "item-label-path": "label", "item-value-path": "value", readOnly: this.autofilled, required: this.validation.mandatory, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, items: this.displayedOptions, onBlur: (e) => this.handleChange(e) }), h("small", { class: 'select__error-message' }, this.errorMessage));
92
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'select__input--invalid';
93
+ return h("div", { class: 'select__wrapper' }, h("label", { class: 'select__label', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), h("vaadin-combo-box", { name: this.name, id: `${this.name}__input`, class: `select__input ${invalidClass}`, "item-label-path": "label", "item-value-path": "value", readOnly: this.autofilled, required: this.validation.mandatory, value: this.defaultValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, items: this.displayedOptions, onBlur: (e) => this.handleChange(e) }), h("small", { class: 'select__error-message' }, this.errorMessage));
90
94
  }
91
95
  get element() { return this; }
92
96
  static get watchers() { return {
@@ -1,9 +1,9 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { t as translate } from './locale.utils.js';
3
- import './virtual-keyboard-controller.js';
3
+ import './input-field-shared-styles.js';
4
4
  import './vaadin-combo-box.js';
5
5
 
6
- const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px;border-bottom:3px solid #666666}.tel__wrapper--flex{display:flex}.tel__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.tel__label--required::after{content:\"*\";margin-left:5px;color:#666666}.tel vaadin-combo-box{flex-grow:1}.tel__input{width:inherit;padding:15px 6px;position:relative;border:none;background-color:transparent;color:#666666;font-size:16px;font-family:inherit;flex-grow:3;-moz-appearance:textfield;}.tel__input::-webkit-outer-spin-button,.tel__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.tel__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.tel__input::placeholder{color:#666666}.tel__input--invalid .tel__wrapper{border-bottom:3px solid #cc0000}.tel__input:placeholder-shown+.tel__label{opacity:0;visibility:hidden;transform:translateY(0)}.tel__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
6
+ const telInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.tel{font-family:\"Roboto\";font-style:normal}.tel__wrapper{position:relative;width:100%;padding-top:26px}.tel__wrapper--flex{width:inherit;display:flex;align-items:stretch;border-radius:4px;border:2px solid #DEE1EE}.tel__wrapper--flex:focus-within{border:2px solid #3E3E3E}.tel__wrapper--flex--invalid{border:2px solid #cc0000b3}.tel__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.tel__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.tel__prefix{width:120px}.tel__prefix[focus]{outline:none}.tel__prefix::part(input-field){border-radius:0 4px 4px 0;background-color:#DEE1EE;color:#1F1F1F;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px}.tel__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;border:none;padding:8px 20px;width:inherit;position:relative;-moz-appearance:textfield;}.tel__input:focus{outline:none}.tel__input::-webkit-outer-spin-button,.tel__input::-webkit-inner-spin-button{-webkit-appearance:none;margin:0}.tel__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
7
7
 
8
8
  const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
9
  constructor() {
@@ -33,18 +33,28 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
33
33
  }
34
34
  connectedCallback() {
35
35
  this.validationPattern = this.setPattern();
36
+ if (this.defaultValue) {
37
+ this.prefixValue = this.defaultValue.split('|')[0];
38
+ this.phoneValue = this.defaultValue.split('|')[1];
39
+ }
36
40
  }
37
41
  componentWillLoad() {
38
42
  if (this.action) {
39
43
  if (this.action.split(" ")[0] == 'GET') {
40
44
  return this.getPhoneCodes().then((options) => {
41
45
  this.phoneCodesOptions = options.phoneCodes.map(code => {
42
- return { label: code.Prefix, value: code.CountryID };
46
+ return { label: code.Prefix, value: code.Prefix };
43
47
  });
44
48
  });
45
49
  }
46
50
  }
47
51
  }
52
+ componentDidLoad() {
53
+ if (this.defaultValue) {
54
+ this.value = `${this.prefixValue}|${this.phoneValue}`;
55
+ this.valueHandler({ name: this.name, value: this.value });
56
+ }
57
+ }
48
58
  getPhoneCodes() {
49
59
  // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
50
60
  const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
@@ -60,7 +70,8 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
60
70
  });
61
71
  }
62
72
  handleInput(event) {
63
- this.value = event.target.value;
73
+ this.phoneValue = event.target.value;
74
+ this.value = `${this.prefixValue}|${this.phoneValue}`;
64
75
  this.errorMessage = this.setErrorMessage();
65
76
  this.isValid = this.setValidity();
66
77
  this.validityStateHandler({ valid: this.isValid, name: this.name });
@@ -70,14 +81,15 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
70
81
  return this.inputReference.validity.valid;
71
82
  }
72
83
  setPattern() {
73
- var _a;
84
+ var _a, _b;
74
85
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
75
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
86
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
76
87
  }
77
88
  }
78
89
  setErrorMessage() {
90
+ var _a;
79
91
  if (this.inputReference.validity.patternMismatch) {
80
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
92
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
81
93
  }
82
94
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
83
95
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -87,8 +99,8 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
87
99
  }
88
100
  }
89
101
  render() {
90
- const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__input--invalid';
91
- return h("div", { class: 'tel__wrapper' }, h("div", { class: 'tel__wrapper--flex' }, h("vaadin-combo-box", { items: this.phoneCodesOptions, value: this.defaultValue, readOnly: this.autofilled }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'tel__error-message' }, this.errorMessage));
102
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__wrapper--flex--invalid';
103
+ return h("div", { class: 'tel__wrapper' }, h("div", { class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onBlur: (e) => this.prefixValue = e.target.value }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'tel__error-message' }, this.errorMessage));
92
104
  }
93
105
  static get watchers() { return {
94
106
  "isValid": ["validityChanged"],
@@ -101,7 +113,7 @@ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
101
113
  "showLabels": [4, "show-labels"],
102
114
  "action": [1],
103
115
  "validation": [16],
104
- "defaultValue": [8, "default-value"],
116
+ "defaultValue": [1, "default-value"],
105
117
  "autofilled": [4],
106
118
  "language": [1],
107
119
  "emitValue": [4, "emit-value"],
@@ -1,7 +1,7 @@
1
1
  import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
2
  import { t as translate } from './locale.utils.js';
3
3
 
4
- const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.text__label{color:#474747;font-size:16px;position:absolute;bottom:15px;left:5px;transform:translateY(-25px);transition:all 0.3s cubic-bezier(0.5, 0, 0.5, 1)}.text__label--required::after{content:\"*\";margin-left:5px;color:#666666}.text__input{width:inherit;padding:15px 6px;position:relative;border:none;border-bottom:3px solid #666666;background-color:transparent;color:#666666;font-size:16px;font-family:inherit}.text__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.text__input::placeholder{color:#666666}.text__input--invalid{border-bottom:3px solid #cc0000}.text__input:placeholder-shown+.text__label{opacity:0;visibility:hidden;transform:translateY(0)}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
4
+ const textInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.text{font-family:\"Roboto\";font-style:normal}.text__wrapper{position:relative;width:100%;padding-top:26px}.text__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F;position:absolute;top:0;left:0}.text__label--required::after{content:\"*\";font-family:inherit;color:#1F1F1F;margin-left:2px}.text__input{border-radius:4px;background-color:transparent;font-family:inherit;font-style:normal;font-weight:300;font-size:16px;line-height:19px;color:#2A2E3F;padding:8px 20px;width:inherit;position:relative;border:2px solid #DEE1EE}.text__input:focus{outline-color:#3E3E3E}.text__input--invalid{border:2px solid #cc0000b3}.text__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000b3}";
5
5
 
6
6
  const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
7
  constructor() {
@@ -24,22 +24,33 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
24
24
  this.valueHandler({ name: this.name, value: this.value });
25
25
  }
26
26
  }
27
- validityStateHandler(inputStateEvent) {
28
- this.sendValidityState.emit(inputStateEvent);
29
- }
30
27
  emitValueHandler(newValue) {
31
28
  if (newValue == true && this.isValid) {
32
29
  this.valueHandler({ name: this.name, value: this.value });
33
30
  }
34
31
  }
32
+ validityStateHandler(inputStateEvent) {
33
+ this.sendValidityState.emit(inputStateEvent);
34
+ }
35
35
  valueHandler(inputValueEvent) {
36
36
  this.sendInputValue.emit(inputValueEvent);
37
37
  }
38
+ valueChangedHandler(event) {
39
+ if (this.isDuplicateInput) {
40
+ if (this.name === event.detail.name + 'Duplicate') {
41
+ this.duplicateInputValue = event.detail.value;
42
+ }
43
+ }
44
+ }
38
45
  connectedCallback() {
39
- // @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
- this.customRules = this.setCustomRules();
41
46
  this.validationPattern = this.setPattern();
42
47
  }
48
+ componentDidLoad() {
49
+ if (this.defaultValue) {
50
+ this.value = this.defaultValue;
51
+ this.valueHandler({ name: this.name, value: this.value });
52
+ }
53
+ }
43
54
  handleInput(event) {
44
55
  this.value = event.target.value;
45
56
  this.isValid = this.setValidity();
@@ -50,22 +61,16 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
50
61
  setValidity() {
51
62
  return this.inputReference.validity.valid;
52
63
  }
53
- // @TODO type here
54
- setCustomRules() {
55
- var _a;
56
- if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
57
- return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
58
- }
59
- }
60
64
  setPattern() {
61
- var _a;
65
+ var _a, _b;
62
66
  if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
63
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
67
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
64
68
  }
65
69
  }
66
70
  setErrorMessage() {
71
+ var _a;
67
72
  if (this.inputReference.validity.patternMismatch) {
68
- return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
73
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
69
74
  }
70
75
  if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
71
76
  return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
@@ -73,10 +78,13 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
73
78
  if (this.inputReference.validity.valueMissing) {
74
79
  return translate('requiredError', this.language);
75
80
  }
81
+ if (this.isDuplicateInput && this.duplicateInputValue !== this.value) {
82
+ return this.validation.custom.find(customRule => customRule.rule === 'duplicate-input').errorMessage;
83
+ }
76
84
  }
77
85
  render() {
78
86
  const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
79
- return h("div", { class: 'text__wrapper' }, h("input", { id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'text__error-message' }, this.errorMessage));
87
+ return h("div", { class: 'text__wrapper' }, h("label", { class: `text__label ${this.validation.mandatory ? 'text__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("input", { name: this.name, id: `${this.name}__input`, value: this.defaultValue, type: 'text', class: `text__input ${invalidClass}`, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, ref: (el) => this.inputReference = el, readOnly: this.autofilled, pattern: this.validationPattern, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, onBlur: (e) => { this.handleInput(e); } }), h("small", { class: 'text__error-message' }, this.errorMessage));
80
88
  }
81
89
  static get watchers() { return {
82
90
  "isValid": ["validityChanged"],
@@ -93,9 +101,10 @@ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
93
101
  "language": [1],
94
102
  "checkValidity": [4, "check-validity"],
95
103
  "emitValue": [4, "emit-value"],
104
+ "isDuplicateInput": [4, "is-duplicate-input"],
96
105
  "isValid": [32],
97
106
  "errorMessage": [32]
98
- }]);
107
+ }, [[16, "sendInputValue", "valueChangedHandler"]]]);
99
108
  function defineCustomElement() {
100
109
  if (typeof customElements === "undefined") {
101
110
  return;