@everymatrix/general-input 1.10.0

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 (106) hide show
  1. package/dist/cjs/checkbox-input_9.cjs.entry.js +686 -0
  2. package/dist/cjs/general-input.cjs.entry.js +45 -0
  3. package/dist/cjs/general-input.cjs.js +19 -0
  4. package/dist/cjs/index-64a5cb7f.js +1214 -0
  5. package/dist/cjs/index.cjs.js +2 -0
  6. package/dist/cjs/loader.cjs.js +21 -0
  7. package/dist/collection/collection-manifest.json +21 -0
  8. package/dist/collection/components/checkbox-input/checkbox-input.css +20 -0
  9. package/dist/collection/components/checkbox-input/checkbox-input.js +196 -0
  10. package/dist/collection/components/date-input/date-input.css +60 -0
  11. package/dist/collection/components/date-input/date-input.js +242 -0
  12. package/dist/collection/components/email-input/email-input.css +60 -0
  13. package/dist/collection/components/email-input/email-input.js +259 -0
  14. package/dist/collection/components/general-input/general-input.css +3 -0
  15. package/dist/collection/components/general-input/general-input.js +204 -0
  16. package/dist/collection/components/number-input/number-input.css +67 -0
  17. package/dist/collection/components/number-input/number-input.js +245 -0
  18. package/dist/collection/components/password-input/password-input.css +60 -0
  19. package/dist/collection/components/password-input/password-input.js +210 -0
  20. package/dist/collection/components/radio-input/radio-input.css +22 -0
  21. package/dist/collection/components/radio-input/radio-input.js +245 -0
  22. package/dist/collection/components/select-input/select-input.css +49 -0
  23. package/dist/collection/components/select-input/select-input.js +308 -0
  24. package/dist/collection/components/tel-input/tel-input.css +67 -0
  25. package/dist/collection/components/tel-input/tel-input.js +294 -0
  26. package/dist/collection/components/text-input/text-input.css +60 -0
  27. package/dist/collection/components/text-input/text-input.js +278 -0
  28. package/dist/collection/index.js +1 -0
  29. package/dist/collection/utils/locale.utils.js +27 -0
  30. package/dist/collection/utils/types.js +1 -0
  31. package/dist/collection/utils/utils.js +5 -0
  32. package/dist/components/checkbox-input.d.ts +11 -0
  33. package/dist/components/checkbox-input.js +6 -0
  34. package/dist/components/checkbox-input2.js +78 -0
  35. package/dist/components/date-input.d.ts +11 -0
  36. package/dist/components/date-input.js +6 -0
  37. package/dist/components/date-input2.js +90 -0
  38. package/dist/components/email-input.d.ts +11 -0
  39. package/dist/components/email-input.js +6 -0
  40. package/dist/components/email-input2.js +108 -0
  41. package/dist/components/general-input.d.ts +11 -0
  42. package/dist/components/general-input.js +123 -0
  43. package/dist/components/index.d.ts +26 -0
  44. package/dist/components/index.js +1 -0
  45. package/dist/components/locale.utils.js +29 -0
  46. package/dist/components/number-input.d.ts +11 -0
  47. package/dist/components/number-input.js +6 -0
  48. package/dist/components/number-input2.js +96 -0
  49. package/dist/components/password-input.d.ts +11 -0
  50. package/dist/components/password-input.js +6 -0
  51. package/dist/components/password-input2.js +93 -0
  52. package/dist/components/radio-input.d.ts +11 -0
  53. package/dist/components/radio-input.js +6 -0
  54. package/dist/components/radio-input2.js +89 -0
  55. package/dist/components/select-input.d.ts +11 -0
  56. package/dist/components/select-input.js +6 -0
  57. package/dist/components/select-input2.js +127 -0
  58. package/dist/components/tel-input.d.ts +11 -0
  59. package/dist/components/tel-input.js +6 -0
  60. package/dist/components/tel-input2.js +111 -0
  61. package/dist/components/text-input.d.ts +11 -0
  62. package/dist/components/text-input.js +6 -0
  63. package/dist/components/text-input2.js +112 -0
  64. package/dist/esm/checkbox-input_9.entry.js +674 -0
  65. package/dist/esm/general-input.entry.js +41 -0
  66. package/dist/esm/general-input.js +17 -0
  67. package/dist/esm/index-df80f936.js +1188 -0
  68. package/dist/esm/index.js +1 -0
  69. package/dist/esm/loader.js +17 -0
  70. package/dist/esm/polyfills/core-js.js +11 -0
  71. package/dist/esm/polyfills/css-shim.js +1 -0
  72. package/dist/esm/polyfills/dom.js +79 -0
  73. package/dist/esm/polyfills/es5-html-element.js +1 -0
  74. package/dist/esm/polyfills/index.js +34 -0
  75. package/dist/esm/polyfills/system.js +6 -0
  76. package/dist/general-input/general-input.esm.js +1 -0
  77. package/dist/general-input/index.esm.js +0 -0
  78. package/dist/general-input/p-c9e79656.entry.js +1 -0
  79. package/dist/general-input/p-d9f7fa2e.js +1 -0
  80. package/dist/general-input/p-dea0a4ac.entry.js +1 -0
  81. package/dist/index.cjs.js +1 -0
  82. package/dist/index.js +1 -0
  83. package/dist/stencil.config.js +22 -0
  84. package/dist/types/Users/user/workspace/everymatrix/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
  85. package/dist/types/components/checkbox-input/checkbox-input.d.ts +39 -0
  86. package/dist/types/components/date-input/date-input.d.ts +47 -0
  87. package/dist/types/components/email-input/email-input.d.ts +51 -0
  88. package/dist/types/components/general-input/general-input.d.ts +40 -0
  89. package/dist/types/components/number-input/number-input.d.ts +48 -0
  90. package/dist/types/components/password-input/password-input.d.ts +42 -0
  91. package/dist/types/components/radio-input/radio-input.d.ts +48 -0
  92. package/dist/types/components/select-input/select-input.d.ts +55 -0
  93. package/dist/types/components/tel-input/tel-input.d.ts +59 -0
  94. package/dist/types/components.d.ts +749 -0
  95. package/dist/types/index.d.ts +1 -0
  96. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  97. package/dist/types/utils/locale.utils.d.ts +5 -0
  98. package/dist/types/utils/types.d.ts +55 -0
  99. package/dist/types/utils/utils.d.ts +1 -0
  100. package/loader/cdn.js +3 -0
  101. package/loader/index.cjs.js +3 -0
  102. package/loader/index.d.ts +12 -0
  103. package/loader/index.es2017.js +3 -0
  104. package/loader/index.js +4 -0
  105. package/loader/package.json +10 -0
  106. package/package.json +19 -0
@@ -0,0 +1,93 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate } from './locale.utils.js';
3
+
4
+ const passwordInputCss = "*,*::before,*::after{padding:0;margin:0;box-sizing:border-box}.password__wrapper{position:relative;display:flex;flex-direction:column-reverse;padding-top:10px}.password__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)}.password__label--required::after{content:\"*\";margin-left:5px;color:#666666}.password__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}.password__input:focus{outline:none;box-shadow:0 5px 5px rgba(16, 15, 15, 0.1)}.password__input::placeholder{color:#666666}.password__input--invalid{border-bottom:3px solid #cc0000}.password__input:placeholder-shown+.password__label{opacity:0;visibility:hidden;transform:translateY(0)}.password__error-message{position:absolute;top:calc(100% + 5px);left:0;color:#cc0000}";
5
+
6
+ const PasswordInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
12
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
13
+ this.validationPattern = '';
14
+ }
15
+ validityChanged() {
16
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
17
+ if (this.emitValue == true) {
18
+ this.valueHandler({ name: this.name, value: this.value });
19
+ }
20
+ }
21
+ validityStateHandler(inputStateEvent) {
22
+ this.sendValidityState.emit(inputStateEvent);
23
+ }
24
+ emitValueHandler(newValue) {
25
+ if (newValue == true && this.isValid) {
26
+ this.valueHandler({ name: this.name, value: this.value });
27
+ }
28
+ }
29
+ valueHandler(inputValueEvent) {
30
+ this.sendInputValue.emit(inputValueEvent);
31
+ }
32
+ connectedCallback() {
33
+ this.validationPattern = this.setPattern();
34
+ }
35
+ handleInput(event) {
36
+ this.value = event.target.value;
37
+ this.errorMessage = this.setErrorMessage();
38
+ this.isValid = this.setValidity();
39
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
40
+ }
41
+ setValidity() {
42
+ return this.inputReference.validity.valid;
43
+ }
44
+ setPattern() {
45
+ var _a;
46
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
47
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
48
+ }
49
+ }
50
+ setErrorMessage() {
51
+ if (this.inputReference.validity.patternMismatch) {
52
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
53
+ }
54
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
55
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
56
+ }
57
+ if (this.inputReference.validity.valueMissing) {
58
+ return translate('requiredError', this.language);
59
+ }
60
+ }
61
+ render() {
62
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'password__input--invalid';
63
+ return h("div", { class: 'password__wrapper' }, h("input", { type: "password", id: `${this.name}__input`, class: `password__input ${invalidClass}`, name: this.name, ref: (el) => this.inputReference = el, required: this.validation.mandatory, maxlength: this.validation.maxLength, minlength: this.validation.minLength, pattern: this.validationPattern, placeholder: `${this.displayName} ${this.validation.mandatory ? '*' : ''}`, onBlur: (e) => this.handleInput(e) }), h("label", { class: `password__label ${this.validation.mandatory ? 'password__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("small", { class: 'password__error-message' }, this.errorMessage));
64
+ }
65
+ static get watchers() { return {
66
+ "isValid": ["validityChanged"],
67
+ "emitValue": ["emitValueHandler"]
68
+ }; }
69
+ static get style() { return passwordInputCss; }
70
+ }, [1, "password-input", {
71
+ "name": [1],
72
+ "displayName": [1, "display-name"],
73
+ "validation": [16],
74
+ "language": [1],
75
+ "emitValue": [4, "emit-value"],
76
+ "isValid": [32],
77
+ "errorMessage": [32]
78
+ }]);
79
+ function defineCustomElement() {
80
+ if (typeof customElements === "undefined") {
81
+ return;
82
+ }
83
+ const components = ["password-input"];
84
+ components.forEach(tagName => { switch (tagName) {
85
+ case "password-input":
86
+ if (!customElements.get(tagName)) {
87
+ customElements.define(tagName, PasswordInput);
88
+ }
89
+ break;
90
+ } });
91
+ }
92
+
93
+ export { PasswordInput as P, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface RadioInput extends Components.RadioInput, HTMLElement {}
4
+ export const RadioInput: {
5
+ prototype: RadioInput;
6
+ new (): RadioInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { R as RadioInput$1, d as defineCustomElement$1 } from './radio-input2.js';
2
+
3
+ const RadioInput = RadioInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { RadioInput, defineCustomElement };
@@ -0,0 +1,89 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate } from './locale.utils.js';
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}";
5
+
6
+ const RadioInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
12
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
13
+ }
14
+ checkValidityHandler(newValue) {
15
+ if (newValue == true) {
16
+ this.isValid = this.setValidity();
17
+ this.errorMessage = this.setErrorMessage();
18
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
19
+ }
20
+ }
21
+ validityChanged() {
22
+ if (this.checkValidity == true) {
23
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
24
+ }
25
+ if (this.emitValue == true) {
26
+ this.valueHandler({ name: this.name, value: this.value });
27
+ }
28
+ }
29
+ emitValueHandler(newValue) {
30
+ if (newValue == true && this.isValid) {
31
+ this.valueHandler({ name: this.name, value: this.value });
32
+ }
33
+ }
34
+ valueHandler(inputValueEvent) {
35
+ this.sendInputValue.emit(inputValueEvent);
36
+ }
37
+ validityStateHandler(inputStateEvent) {
38
+ this.sendValidityState.emit(inputStateEvent);
39
+ }
40
+ connectedCallback() {
41
+ }
42
+ handleClick(event) {
43
+ this.value = event.target.value;
44
+ this.isValid = this.setValidity();
45
+ this.errorMessage = this.setErrorMessage();
46
+ }
47
+ setValidity() {
48
+ return this.inputReference.validity.valid;
49
+ }
50
+ setErrorMessage() {
51
+ if (this.inputReference.validity.valueMissing) {
52
+ return translate('requiredError', this.language);
53
+ }
54
+ }
55
+ render() {
56
+ return h("fieldset", { class: 'radio__fieldset' }, h("legend", { class: 'radio__legend' }, this.displayName, ":"), this.optionsGroup.map(option => h("div", { class: 'radio__wrapper' }, h("input", { type: "radio", class: 'radio__input', id: `${option.label}__input`, ref: (el) => this.inputReference = el, value: option.value, name: this.name, required: this.validation.mandatory, onClick: (e) => this.handleClick(e) }), h("label", { htmlFor: `${option.label}__input` }, option.label))), h("small", { class: 'radio__error-message' }, this.errorMessage));
57
+ }
58
+ static get watchers() { return {
59
+ "checkValidity": ["checkValidityHandler"],
60
+ "isValid": ["validityChanged"],
61
+ "emitValue": ["emitValueHandler"]
62
+ }; }
63
+ static get style() { return radioInputCss; }
64
+ }, [1, "radio-input", {
65
+ "name": [1],
66
+ "displayName": [1, "display-name"],
67
+ "optionsGroup": [16],
68
+ "validation": [16],
69
+ "language": [1],
70
+ "checkValidity": [4, "check-validity"],
71
+ "emitValue": [4, "emit-value"],
72
+ "errorMessage": [32],
73
+ "isValid": [32]
74
+ }]);
75
+ function defineCustomElement() {
76
+ if (typeof customElements === "undefined") {
77
+ return;
78
+ }
79
+ const components = ["radio-input"];
80
+ components.forEach(tagName => { switch (tagName) {
81
+ case "radio-input":
82
+ if (!customElements.get(tagName)) {
83
+ customElements.define(tagName, RadioInput);
84
+ }
85
+ break;
86
+ } });
87
+ }
88
+
89
+ export { RadioInput as R, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface SelectInput extends Components.SelectInput, HTMLElement {}
4
+ export const SelectInput: {
5
+ prototype: SelectInput;
6
+ new (): SelectInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { S as SelectInput$1, d as defineCustomElement$1 } from './select-input2.js';
2
+
3
+ const SelectInput = SelectInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { SelectInput, defineCustomElement };
@@ -0,0 +1,127 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate } from './locale.utils.js';
3
+
4
+ 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}";
5
+
6
+ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
12
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
13
+ /**
14
+ * Options of the input.
15
+ */
16
+ this.options = [];
17
+ }
18
+ checkValidityHandler(newValue) {
19
+ if (newValue == true) {
20
+ this.isValid = this.setValidity();
21
+ this.errorMessage = this.setErrorMessage();
22
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
23
+ }
24
+ }
25
+ validityChanged() {
26
+ if (this.checkValidity == true) {
27
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
28
+ }
29
+ if (this.emitValue == true) {
30
+ this.valueHandler({ name: this.name, value: this.value });
31
+ }
32
+ }
33
+ validityStateHandler(inputStateEvent) {
34
+ this.sendValidityState.emit(inputStateEvent);
35
+ }
36
+ emitValueHandler(newValue) {
37
+ if (newValue == true && this.isValid) {
38
+ this.valueHandler({ name: this.name, value: this.value });
39
+ }
40
+ }
41
+ valueHandler(inputValueEvent) {
42
+ this.sendInputValue.emit(inputValueEvent);
43
+ }
44
+ connectedCallback() {
45
+ this.displayedOptions = this.options;
46
+ console.log(this.displayedOptions);
47
+ }
48
+ componentWillLoad() {
49
+ console.log(this.action, this.options);
50
+ if (this.action && !this.options.length) {
51
+ if (this.action.split(" ")[0] == 'GET') {
52
+ return this.getOptions().then((options) => {
53
+ this.displayedOptions = options.countries.map(option => {
54
+ return { label: option.Name, value: option.Alpha2Code };
55
+ });
56
+ });
57
+ }
58
+ }
59
+ }
60
+ getOptions() {
61
+ // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
62
+ const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/countries");
63
+ return new Promise((resolve, reject) => {
64
+ fetch(url.href)
65
+ .then((res) => res.json())
66
+ .then((options) => {
67
+ resolve(options);
68
+ }).catch((err) => {
69
+ console.error(err);
70
+ reject(err);
71
+ });
72
+ });
73
+ }
74
+ handleChange(event) {
75
+ this.value = event.target.value;
76
+ this.errorMessage = this.setErrorMessage();
77
+ this.isValid = this.setValidity();
78
+ this.inputReference.previousElementSibling.classList.remove('select__label--hidden');
79
+ console.log(this.action, this.options);
80
+ }
81
+ setValidity() {
82
+ return this.inputReference.validity.valid;
83
+ }
84
+ setErrorMessage() {
85
+ if (this.inputReference.validity.valueMissing) {
86
+ return translate('requiredError', this.language);
87
+ }
88
+ }
89
+ render() {
90
+ console.log('RENDER');
91
+ return h("div", { class: 'select__wrapper' }, h("label", { class: 'select__label select__label--hidden', htmlFor: `${this.name}__input` }, this.displayName, ":"), h("select", { ref: (el) => this.inputReference = el, name: this.name, id: `${this.name}__input`, required: this.validation.mandatory, class: 'select__input', onChange: (e) => this.handleChange(e) }, h("option", { value: "", selected: true, disabled: true }, " ", this.displayName, " "), this.displayedOptions.map(option => {
92
+ return h("option", { value: option.value }, " ", option.label, " ");
93
+ })), h("small", { class: 'select__error-message' }, this.errorMessage));
94
+ }
95
+ static get watchers() { return {
96
+ "checkValidity": ["checkValidityHandler"],
97
+ "isValid": ["validityChanged"],
98
+ "emitValue": ["emitValueHandler"]
99
+ }; }
100
+ static get style() { return selectInputCss; }
101
+ }, [1, "select-input", {
102
+ "name": [1],
103
+ "displayName": [1, "display-name"],
104
+ "action": [1],
105
+ "options": [16],
106
+ "validation": [16],
107
+ "language": [1],
108
+ "checkValidity": [4, "check-validity"],
109
+ "emitValue": [4, "emit-value"],
110
+ "errorMessage": [32],
111
+ "isValid": [32]
112
+ }]);
113
+ function defineCustomElement() {
114
+ if (typeof customElements === "undefined") {
115
+ return;
116
+ }
117
+ const components = ["select-input"];
118
+ components.forEach(tagName => { switch (tagName) {
119
+ case "select-input":
120
+ if (!customElements.get(tagName)) {
121
+ customElements.define(tagName, SelectInput);
122
+ }
123
+ break;
124
+ } });
125
+ }
126
+
127
+ export { SelectInput as S, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface TelInput extends Components.TelInput, HTMLElement {}
4
+ export const TelInput: {
5
+ prototype: TelInput;
6
+ new (): TelInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { T as TelInput$1, d as defineCustomElement$1 } from './tel-input2.js';
2
+
3
+ const TelInput = TelInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { TelInput, defineCustomElement };
@@ -0,0 +1,111 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate } from './locale.utils.js';
3
+
4
+ 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}.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__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;-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{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}";
5
+
6
+ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
12
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
13
+ this.validationPattern = '';
14
+ }
15
+ checkValidityHandler(newValue) {
16
+ if (newValue == true) {
17
+ this.isValid = this.setValidity();
18
+ this.errorMessage = this.setErrorMessage();
19
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
20
+ }
21
+ }
22
+ validityChanged() {
23
+ if (this.checkValidity == true) {
24
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
25
+ }
26
+ if (this.emitValue == true) {
27
+ this.valueHandler({ name: this.name, value: this.value });
28
+ }
29
+ }
30
+ validityStateHandler(inputStateEvent) {
31
+ this.sendValidityState.emit(inputStateEvent);
32
+ }
33
+ emitValueHandler(newValue) {
34
+ if (newValue == true && this.isValid) {
35
+ this.valueHandler({ name: this.name, value: this.value });
36
+ }
37
+ }
38
+ valueHandler(inputValueEvent) {
39
+ this.sendInputValue.emit(inputValueEvent);
40
+ }
41
+ connectedCallback() {
42
+ this.validationPattern = this.setPattern();
43
+ }
44
+ handleInput(event) {
45
+ this.value = event.target.value;
46
+ if (this.debounceTime) {
47
+ clearTimeout(this.debounceTime);
48
+ }
49
+ this.debounceTime = setTimeout(() => {
50
+ this.errorMessage = this.setErrorMessage();
51
+ this.isValid = this.setValidity();
52
+ }, 500);
53
+ }
54
+ setValidity() {
55
+ return this.inputReference.validity.valid;
56
+ }
57
+ setPattern() {
58
+ var _a;
59
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
60
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
61
+ }
62
+ }
63
+ setErrorMessage() {
64
+ if (this.inputReference.validity.patternMismatch) {
65
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
66
+ }
67
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
68
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
69
+ }
70
+ if (this.inputReference.validity.valueMissing) {
71
+ return translate('requiredError', this.language);
72
+ }
73
+ }
74
+ render() {
75
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__input--invalid';
76
+ return h("div", { class: 'tel__wrapper' }, h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, value: this.defaultValue, 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, onInput: (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));
77
+ }
78
+ static get watchers() { return {
79
+ "checkValidity": ["checkValidityHandler"],
80
+ "isValid": ["validityChanged"],
81
+ "emitValue": ["emitValueHandler"]
82
+ }; }
83
+ static get style() { return telInputCss; }
84
+ }, [1, "tel-input", {
85
+ "name": [1],
86
+ "displayName": [1, "display-name"],
87
+ "showLabels": [4, "show-labels"],
88
+ "action": [1],
89
+ "validation": [16],
90
+ "defaultValue": [8, "default-value"],
91
+ "language": [1],
92
+ "checkValidity": [4, "check-validity"],
93
+ "emitValue": [4, "emit-value"],
94
+ "isValid": [32],
95
+ "errorMessage": [32]
96
+ }]);
97
+ function defineCustomElement() {
98
+ if (typeof customElements === "undefined") {
99
+ return;
100
+ }
101
+ const components = ["tel-input"];
102
+ components.forEach(tagName => { switch (tagName) {
103
+ case "tel-input":
104
+ if (!customElements.get(tagName)) {
105
+ customElements.define(tagName, TelInput);
106
+ }
107
+ break;
108
+ } });
109
+ }
110
+
111
+ export { TelInput as T, defineCustomElement as d };
@@ -0,0 +1,11 @@
1
+ import type { Components, JSX } from "../types/components";
2
+
3
+ interface TextInput extends Components.TextInput, HTMLElement {}
4
+ export const TextInput: {
5
+ prototype: TextInput;
6
+ new (): TextInput;
7
+ };
8
+ /**
9
+ * Used to define this component and all nested components recursively.
10
+ */
11
+ export const defineCustomElement: () => void;
@@ -0,0 +1,6 @@
1
+ import { T as TextInput$1, d as defineCustomElement$1 } from './text-input2.js';
2
+
3
+ const TextInput = TextInput$1;
4
+ const defineCustomElement = defineCustomElement$1;
5
+
6
+ export { TextInput, defineCustomElement };
@@ -0,0 +1,112 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate } from './locale.utils.js';
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}";
5
+
6
+ const TextInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
7
+ constructor() {
8
+ super();
9
+ this.__registerHost();
10
+ this.__attachShadow();
11
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
12
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
13
+ /**
14
+ * Default value for the input.
15
+ */
16
+ this.defaultValue = '';
17
+ this.errorMessage = '';
18
+ this.value = '';
19
+ this.customRules = [];
20
+ this.validationPattern = '';
21
+ }
22
+ validityChanged() {
23
+ if (this.emitValue == true) {
24
+ this.valueHandler({ name: this.name, value: this.value });
25
+ }
26
+ }
27
+ validityStateHandler(inputStateEvent) {
28
+ this.sendValidityState.emit(inputStateEvent);
29
+ }
30
+ emitValueHandler(newValue) {
31
+ if (newValue == true && this.isValid) {
32
+ this.valueHandler({ name: this.name, value: this.value });
33
+ }
34
+ }
35
+ valueHandler(inputValueEvent) {
36
+ this.sendInputValue.emit(inputValueEvent);
37
+ }
38
+ connectedCallback() {
39
+ // @TODO do something with customRules !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
40
+ this.customRules = this.setCustomRules();
41
+ this.validationPattern = this.setPattern();
42
+ }
43
+ handleInput(event) {
44
+ this.value = event.target.value;
45
+ this.isValid = this.setValidity();
46
+ this.errorMessage = this.setErrorMessage();
47
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
48
+ }
49
+ setValidity() {
50
+ return this.inputReference.validity.valid;
51
+ }
52
+ // @TODO type here
53
+ setCustomRules() {
54
+ var _a;
55
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
56
+ return this.validation.custom.filter(customValidation => customValidation.rule !== 'regex');
57
+ }
58
+ }
59
+ setPattern() {
60
+ var _a;
61
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
62
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').pattern;
63
+ }
64
+ }
65
+ setErrorMessage() {
66
+ if (this.inputReference.validity.patternMismatch) {
67
+ return this.validation.custom.find(customValidation => customValidation.rule === 'regex').errorMessage;
68
+ }
69
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
70
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
71
+ }
72
+ if (this.inputReference.validity.valueMissing) {
73
+ return translate('requiredError', this.language);
74
+ }
75
+ }
76
+ render() {
77
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'text__input--invalid';
78
+ console.log('this', this.name, this.defaultValue, this.displayName);
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, 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));
80
+ }
81
+ static get watchers() { return {
82
+ "isValid": ["validityChanged"],
83
+ "emitValue": ["emitValueHandler"]
84
+ }; }
85
+ static get style() { return textInputCss; }
86
+ }, [1, "text-input", {
87
+ "name": [1025],
88
+ "displayName": [1, "display-name"],
89
+ "validation": [16],
90
+ "defaultValue": [1025, "default-value"],
91
+ "rules": [1],
92
+ "language": [1],
93
+ "checkValidity": [4, "check-validity"],
94
+ "emitValue": [4, "emit-value"],
95
+ "isValid": [32],
96
+ "errorMessage": [32]
97
+ }]);
98
+ function defineCustomElement() {
99
+ if (typeof customElements === "undefined") {
100
+ return;
101
+ }
102
+ const components = ["text-input"];
103
+ components.forEach(tagName => { switch (tagName) {
104
+ case "text-input":
105
+ if (!customElements.get(tagName)) {
106
+ customElements.define(tagName, TextInput);
107
+ }
108
+ break;
109
+ } });
110
+ }
111
+
112
+ export { TextInput as T, defineCustomElement as d };