@everymatrix/general-input 0.0.1

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 (121) hide show
  1. package/dist/cjs/checkbox-group-input_10.cjs.entry.js +34870 -0
  2. package/dist/cjs/general-input.cjs.entry.js +51 -0
  3. package/dist/cjs/general-input.cjs.js +19 -0
  4. package/dist/cjs/index-1768513d.js +1286 -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 +22 -0
  8. package/dist/collection/components/checkbox-group-input/checkbox-group-input.css +62 -0
  9. package/dist/collection/components/checkbox-group-input/checkbox-group-input.js +344 -0
  10. package/dist/collection/components/checkbox-input/checkbox-input.css +62 -0
  11. package/dist/collection/components/checkbox-input/checkbox-input.js +322 -0
  12. package/dist/collection/components/date-input/date-input.css +85 -0
  13. package/dist/collection/components/date-input/date-input.js +341 -0
  14. package/dist/collection/components/email-input/email-input.css +83 -0
  15. package/dist/collection/components/email-input/email-input.js +382 -0
  16. package/dist/collection/components/general-input/general-input.css +3 -0
  17. package/dist/collection/components/general-input/general-input.js +296 -0
  18. package/dist/collection/components/number-input/number-input.css +90 -0
  19. package/dist/collection/components/number-input/number-input.js +349 -0
  20. package/dist/collection/components/password-input/password-input.css +86 -0
  21. package/dist/collection/components/password-input/password-input.js +395 -0
  22. package/dist/collection/components/radio-input/radio-input.css +43 -0
  23. package/dist/collection/components/radio-input/radio-input.js +298 -0
  24. package/dist/collection/components/select-input/select-input.css +93 -0
  25. package/dist/collection/components/select-input/select-input.js +412 -0
  26. package/dist/collection/components/tel-input/tel-input.css +116 -0
  27. package/dist/collection/components/tel-input/tel-input.js +421 -0
  28. package/dist/collection/components/text-input/text-input.css +83 -0
  29. package/dist/collection/components/text-input/text-input.js +406 -0
  30. package/dist/collection/index.js +1 -0
  31. package/dist/collection/utils/locale.utils.js +26 -0
  32. package/dist/collection/utils/tooltipIcon.svg +5 -0
  33. package/dist/collection/utils/types.js +1 -0
  34. package/dist/collection/utils/utils.js +5 -0
  35. package/dist/components/active-mixin.js +975 -0
  36. package/dist/components/checkbox-group-input.d.ts +11 -0
  37. package/dist/components/checkbox-group-input.js +6 -0
  38. package/dist/components/checkbox-group-input2.js +5793 -0
  39. package/dist/components/checkbox-input.d.ts +11 -0
  40. package/dist/components/checkbox-input.js +6 -0
  41. package/dist/components/checkbox-input2.js +127 -0
  42. package/dist/components/date-input.d.ts +11 -0
  43. package/dist/components/date-input.js +6 -0
  44. package/dist/components/date-input2.js +5182 -0
  45. package/dist/components/email-input.d.ts +11 -0
  46. package/dist/components/email-input.js +6 -0
  47. package/dist/components/email-input2.js +150 -0
  48. package/dist/components/field-mixin.js +12712 -0
  49. package/dist/components/general-input.d.ts +11 -0
  50. package/dist/components/general-input.js +140 -0
  51. package/dist/components/index.d.ts +26 -0
  52. package/dist/components/index.js +1 -0
  53. package/dist/components/input-field-shared-styles.js +1067 -0
  54. package/dist/components/number-input.d.ts +11 -0
  55. package/dist/components/number-input.js +6 -0
  56. package/dist/components/number-input2.js +139 -0
  57. package/dist/components/password-input.d.ts +11 -0
  58. package/dist/components/password-input.js +6 -0
  59. package/dist/components/password-input2.js +879 -0
  60. package/dist/components/pattern-mixin.js +85 -0
  61. package/dist/components/radio-input.d.ts +11 -0
  62. package/dist/components/radio-input.js +6 -0
  63. package/dist/components/radio-input2.js +115 -0
  64. package/dist/components/select-input.d.ts +11 -0
  65. package/dist/components/select-input.js +6 -0
  66. package/dist/components/select-input2.js +166 -0
  67. package/dist/components/tel-input.d.ts +11 -0
  68. package/dist/components/tel-input.js +6 -0
  69. package/dist/components/tel-input2.js +178 -0
  70. package/dist/components/text-input.d.ts +11 -0
  71. package/dist/components/text-input.js +6 -0
  72. package/dist/components/text-input2.js +157 -0
  73. package/dist/components/tooltipIcon.js +30 -0
  74. package/dist/components/vaadin-button.js +461 -0
  75. package/dist/components/vaadin-combo-box.js +4329 -0
  76. package/dist/components/virtual-keyboard-controller.js +2693 -0
  77. package/dist/esm/checkbox-group-input_10.entry.js +34857 -0
  78. package/dist/esm/general-input.entry.js +47 -0
  79. package/dist/esm/general-input.js +17 -0
  80. package/dist/esm/index-7e24a6f1.js +1259 -0
  81. package/dist/esm/index.js +1 -0
  82. package/dist/esm/loader.js +17 -0
  83. package/dist/esm/polyfills/core-js.js +11 -0
  84. package/dist/esm/polyfills/css-shim.js +1 -0
  85. package/dist/esm/polyfills/dom.js +79 -0
  86. package/dist/esm/polyfills/es5-html-element.js +1 -0
  87. package/dist/esm/polyfills/index.js +34 -0
  88. package/dist/esm/polyfills/system.js +6 -0
  89. package/dist/general-input/general-input.esm.js +1 -0
  90. package/dist/general-input/index.esm.js +0 -0
  91. package/dist/general-input/p-61d76ec3.entry.js +1 -0
  92. package/dist/general-input/p-a79eb0a3.entry.js +4413 -0
  93. package/dist/general-input/p-fb647820.js +1 -0
  94. package/dist/index.cjs.js +1 -0
  95. package/dist/index.js +1 -0
  96. package/dist/stencil.config.js +22 -0
  97. package/dist/types/Users/adrian.pripon/Documents/Work/stencil/widgets-stencil/packages/general-input/.stencil/packages/general-input/stencil.config.d.ts +2 -0
  98. package/dist/types/components/checkbox-group-input/checkbox-group-input.d.ts +72 -0
  99. package/dist/types/components/checkbox-input/checkbox-input.d.ts +64 -0
  100. package/dist/types/components/date-input/date-input.d.ts +70 -0
  101. package/dist/types/components/email-input/email-input.d.ts +77 -0
  102. package/dist/types/components/general-input/general-input.d.ts +60 -0
  103. package/dist/types/components/number-input/number-input.d.ts +70 -0
  104. package/dist/types/components/password-input/password-input.d.ts +79 -0
  105. package/dist/types/components/radio-input/radio-input.d.ts +59 -0
  106. package/dist/types/components/select-input/select-input.d.ts +82 -0
  107. package/dist/types/components/tel-input/tel-input.d.ts +85 -0
  108. package/dist/types/components/text-input/text-input.d.ts +81 -0
  109. package/dist/types/components.d.ts +1140 -0
  110. package/dist/types/index.d.ts +1 -0
  111. package/dist/types/stencil-public-runtime.d.ts +1565 -0
  112. package/dist/types/utils/locale.utils.d.ts +5 -0
  113. package/dist/types/utils/types.d.ts +76 -0
  114. package/dist/types/utils/utils.d.ts +1 -0
  115. package/loader/cdn.js +3 -0
  116. package/loader/index.cjs.js +3 -0
  117. package/loader/index.d.ts +12 -0
  118. package/loader/index.es2017.js +3 -0
  119. package/loader/index.js +4 -0
  120. package/loader/package.json +10 -0
  121. package/package.json +26 -0
@@ -0,0 +1,85 @@
1
+ import { A as Debouncer, B as timeOut } from './field-mixin.js';
2
+ import { I as InputConstraintsMixin } from './input-field-shared-styles.js';
3
+
4
+ /**
5
+ * @license
6
+ * Copyright (c) 2021 - 2022 Vaadin Ltd.
7
+ * This program is available under Apache License Version 2.0, available at https://vaadin.com/license/
8
+ */
9
+
10
+ /**
11
+ * A mixin to provide `pattern` and `preventInvalidInput` properties.
12
+ *
13
+ * @polymerMixin
14
+ * @mixes InputConstraintsMixin
15
+ */
16
+ const PatternMixin = (superclass) =>
17
+ class PatternMixinClass extends InputConstraintsMixin(superclass) {
18
+ static get properties() {
19
+ return {
20
+ /**
21
+ * A regular expression that the value is checked against.
22
+ * The pattern must match the entire value, not just some subset.
23
+ */
24
+ pattern: {
25
+ type: String,
26
+ },
27
+
28
+ /**
29
+ * When set to true, user is prevented from typing a value that
30
+ * conflicts with the given `pattern`.
31
+ * @attr {boolean} prevent-invalid-input
32
+ * @deprecated Please use `allowedCharPattern` instead.
33
+ */
34
+ preventInvalidInput: {
35
+ type: Boolean,
36
+ observer: '_preventInvalidInputChanged',
37
+ },
38
+ };
39
+ }
40
+
41
+ static get delegateAttrs() {
42
+ return [...super.delegateAttrs, 'pattern'];
43
+ }
44
+
45
+ static get constraints() {
46
+ return [...super.constraints, 'pattern'];
47
+ }
48
+
49
+ /** @private */
50
+ _checkInputValue() {
51
+ if (this.preventInvalidInput) {
52
+ const input = this.inputElement;
53
+ if (input && input.value.length > 0 && !this.checkValidity()) {
54
+ input.value = this.value || '';
55
+ // Add input-prevented attribute for 200ms
56
+ this.setAttribute('input-prevented', '');
57
+ this._inputDebouncer = Debouncer.debounce(this._inputDebouncer, timeOut.after(200), () => {
58
+ this.removeAttribute('input-prevented');
59
+ });
60
+ }
61
+ }
62
+ }
63
+
64
+ /**
65
+ * @param {Event} event
66
+ * @protected
67
+ * @override
68
+ */
69
+ _onInput(event) {
70
+ this._checkInputValue();
71
+
72
+ super._onInput(event);
73
+ }
74
+
75
+ /** @private */
76
+ _preventInvalidInputChanged(preventInvalidInput) {
77
+ if (preventInvalidInput) {
78
+ console.warn(
79
+ `WARNING: Since Vaadin 23.2, "preventInvalidInput" is deprecated. Please use "allowedCharPattern" instead.`,
80
+ );
81
+ }
82
+ }
83
+ };
84
+
85
+ export { PatternMixin as P };
@@ -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,115 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate, a as tooltipIconSvg } from './tooltipIcon.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:#cc0000b3}.radio__tooltip-icon{position:absolute;right:0;bottom:10px}.radio__tooltip{position:absolute;bottom:35px;right:10px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.radio__tooltip.visible{opacity:1}";
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
+ * Client custom styling via inline style
15
+ */
16
+ this.clientStyling = '';
17
+ this.limitStylingAppends = false;
18
+ this.showTooltip = false;
19
+ this.setClientStyling = () => {
20
+ let sheet = document.createElement('style');
21
+ sheet.innerHTML = this.clientStyling;
22
+ this.stylingContainer.prepend(sheet);
23
+ };
24
+ }
25
+ validityChanged() {
26
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
27
+ if (this.emitValue == true) {
28
+ this.valueHandler({ name: this.name, value: this.value });
29
+ }
30
+ }
31
+ emitValueHandler(newValue) {
32
+ if (newValue == true && this.isValid) {
33
+ this.valueHandler({ name: this.name, value: this.value });
34
+ }
35
+ }
36
+ valueHandler(inputValueEvent) {
37
+ this.sendInputValue.emit(inputValueEvent);
38
+ }
39
+ validityStateHandler(inputStateEvent) {
40
+ this.sendValidityState.emit(inputStateEvent);
41
+ }
42
+ handleClickOutside(event) {
43
+ if (event.composedPath()[0] === this.tooltipIconReference)
44
+ return;
45
+ if (event.composedPath()[0] !== this.tooltipReference)
46
+ this.showTooltip = false;
47
+ }
48
+ componentDidRender() {
49
+ // start custom styling area
50
+ if (!this.limitStylingAppends && this.stylingContainer) {
51
+ if (this.clientStyling)
52
+ this.setClientStyling();
53
+ this.limitStylingAppends = true;
54
+ }
55
+ // end custom styling area
56
+ }
57
+ handleClick(event) {
58
+ this.value = event.target.value;
59
+ this.isValid = this.setValidity();
60
+ this.errorMessage = this.setErrorMessage();
61
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
62
+ this.emitValueHandler(true);
63
+ }
64
+ setValidity() {
65
+ return this.inputReference.validity.valid;
66
+ }
67
+ setErrorMessage() {
68
+ if (this.inputReference.validity.valueMissing) {
69
+ return translate('requiredError', this.language);
70
+ }
71
+ }
72
+ renderTooltip() {
73
+ if (this.showTooltip) {
74
+ return (h("div", { class: `radio__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
75
+ }
76
+ return null;
77
+ }
78
+ render() {
79
+ return h("fieldset", { class: 'radio__fieldset', ref: el => this.stylingContainer = el }, 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), this.tooltip &&
80
+ h("img", { class: 'radio__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip());
81
+ }
82
+ static get watchers() { return {
83
+ "isValid": ["validityChanged"],
84
+ "emitValue": ["emitValueHandler"]
85
+ }; }
86
+ static get style() { return radioInputCss; }
87
+ }, [1, "radio-input", {
88
+ "name": [513],
89
+ "displayName": [513, "display-name"],
90
+ "optionsGroup": [16],
91
+ "validation": [16],
92
+ "tooltip": [513],
93
+ "language": [513],
94
+ "emitValue": [516, "emit-value"],
95
+ "clientStyling": [513, "client-styling"],
96
+ "errorMessage": [32],
97
+ "isValid": [32],
98
+ "limitStylingAppends": [32],
99
+ "showTooltip": [32]
100
+ }, [[4, "click", "handleClickOutside"]]]);
101
+ function defineCustomElement() {
102
+ if (typeof customElements === "undefined") {
103
+ return;
104
+ }
105
+ const components = ["radio-input"];
106
+ components.forEach(tagName => { switch (tagName) {
107
+ case "radio-input":
108
+ if (!customElements.get(tagName)) {
109
+ customElements.define(tagName, RadioInput);
110
+ }
111
+ break;
112
+ } });
113
+ }
114
+
115
+ 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,166 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
3
+ import './input-field-shared-styles.js';
4
+ import './vaadin-combo-box.js';
5
+
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%}.select__wrapper--flex{display:flex;gap:5px}.select__wrapper--relative{position:relative}.select__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F}.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}.select__tooltip-icon{width:16px;height:auto}.select__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.select__tooltip.visible{opacity:1}";
7
+
8
+ const SelectInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ this.__attachShadow();
13
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
14
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
15
+ /**
16
+ * Default value for the input.
17
+ */
18
+ this.defaultValue = '';
19
+ /**
20
+ * Options of the input.
21
+ */
22
+ this.options = [];
23
+ /**
24
+ * Client custom styling via inline style
25
+ */
26
+ this.clientStyling = '';
27
+ this.limitStylingAppends = false;
28
+ this.showTooltip = false;
29
+ this.setClientStyling = () => {
30
+ let sheet = document.createElement('style');
31
+ sheet.innerHTML = this.clientStyling;
32
+ this.stylingContainer.prepend(sheet);
33
+ };
34
+ }
35
+ validityChanged() {
36
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
37
+ if (this.emitValue == true) {
38
+ this.valueHandler({ name: this.name, value: this.value });
39
+ }
40
+ }
41
+ validityStateHandler(inputStateEvent) {
42
+ this.sendValidityState.emit(inputStateEvent);
43
+ }
44
+ emitValueHandler(newValue) {
45
+ if (newValue == true && this.isValid) {
46
+ this.valueHandler({ name: this.name, value: this.value });
47
+ }
48
+ }
49
+ valueHandler(inputValueEvent) {
50
+ this.sendInputValue.emit(inputValueEvent);
51
+ }
52
+ handleClickOutside(event) {
53
+ if (event.composedPath()[0] === this.tooltipIconReference)
54
+ return;
55
+ if (event.composedPath()[0] !== this.tooltipReference)
56
+ this.showTooltip = false;
57
+ }
58
+ connectedCallback() {
59
+ this.displayedOptions = this.options;
60
+ }
61
+ componentWillLoad() {
62
+ if (this.action && !this.options.length) {
63
+ if (this.action.split(" ")[0] == 'GET') {
64
+ return this.getOptions().then((options) => {
65
+ this.displayedOptions = options.countries.map(option => {
66
+ return { label: option.Name, value: option.Alpha2Code };
67
+ });
68
+ });
69
+ }
70
+ }
71
+ }
72
+ componentDidRender() {
73
+ // start custom styling area
74
+ if (!this.limitStylingAppends && this.stylingContainer) {
75
+ if (this.clientStyling)
76
+ this.setClientStyling();
77
+ this.limitStylingAppends = true;
78
+ }
79
+ // end custom styling area
80
+ }
81
+ componentDidLoad() {
82
+ this.inputReference = this.element.shadowRoot.querySelector('input');
83
+ if (this.defaultValue) {
84
+ this.value = this.defaultValue;
85
+ this.valueHandler({ name: this.name, value: this.value });
86
+ }
87
+ }
88
+ getOptions() {
89
+ // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
90
+ const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/countries");
91
+ return new Promise((resolve, reject) => {
92
+ fetch(url.href)
93
+ .then((res) => res.json())
94
+ .then((options) => {
95
+ resolve(options);
96
+ }).catch((err) => {
97
+ console.error(err);
98
+ reject(err);
99
+ });
100
+ });
101
+ }
102
+ handleChange(event) {
103
+ this.value = event.target.value;
104
+ this.errorMessage = this.setErrorMessage();
105
+ this.isValid = this.setValidity();
106
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
107
+ this.emitValueHandler(true);
108
+ }
109
+ setValidity() {
110
+ return this.inputReference.validity.valid;
111
+ }
112
+ setErrorMessage() {
113
+ if (this.inputReference.validity.valueMissing) {
114
+ return translate('requiredError', this.language);
115
+ }
116
+ }
117
+ renderTooltip() {
118
+ if (this.showTooltip) {
119
+ return (h("div", { class: `select__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
120
+ }
121
+ return null;
122
+ }
123
+ render() {
124
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'select__input--invalid';
125
+ return h("div", { class: 'select__wrapper', ref: el => this.stylingContainer = el }, h("div", { class: 'select__wrapper--flex' }, h("label", { class: 'select__label', htmlFor: `${this.name}__input` }, `${this.displayName} ${this.validation.mandatory ? '*' : ''}`), h("div", { class: 'select__wrapper--relative' }, this.tooltip &&
126
+ h("img", { class: 'select__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), 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.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, items: this.displayedOptions, onChange: (e) => this.handleChange(e) }), h("small", { class: 'select__error-message' }, this.errorMessage));
127
+ }
128
+ get element() { return this; }
129
+ static get watchers() { return {
130
+ "isValid": ["validityChanged"],
131
+ "emitValue": ["emitValueHandler"]
132
+ }; }
133
+ static get style() { return selectInputCss; }
134
+ }, [1, "select-input", {
135
+ "name": [513],
136
+ "displayName": [513, "display-name"],
137
+ "placeholder": [513],
138
+ "action": [513],
139
+ "defaultValue": [513, "default-value"],
140
+ "autofilled": [516],
141
+ "tooltip": [513],
142
+ "options": [16],
143
+ "validation": [16],
144
+ "language": [513],
145
+ "emitValue": [516, "emit-value"],
146
+ "clientStyling": [513, "client-styling"],
147
+ "errorMessage": [32],
148
+ "isValid": [32],
149
+ "limitStylingAppends": [32],
150
+ "showTooltip": [32]
151
+ }, [[4, "click", "handleClickOutside"]]]);
152
+ function defineCustomElement() {
153
+ if (typeof customElements === "undefined") {
154
+ return;
155
+ }
156
+ const components = ["select-input"];
157
+ components.forEach(tagName => { switch (tagName) {
158
+ case "select-input":
159
+ if (!customElements.get(tagName)) {
160
+ customElements.define(tagName, SelectInput);
161
+ }
162
+ break;
163
+ } });
164
+ }
165
+
166
+ 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,178 @@
1
+ import { proxyCustomElement, HTMLElement, createEvent, h } from '@stencil/core/internal/client';
2
+ import { t as translate, a as tooltipIconSvg } from './tooltipIcon.js';
3
+ import './input-field-shared-styles.js';
4
+ import './vaadin-combo-box.js';
5
+
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%}.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__wrapper--flex-label{display:flex;gap:5px}.tel__wrapper--flex--relative{position:relative}.tel__label{font-family:inherit;font-style:normal;font-weight:500;font-size:16px;line-height:20px;color:#1F1F1F}.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}.tel__tooltip-icon{width:16px;height:auto}.tel__tooltip{position:absolute;top:0;left:20px;background-color:#FFFFFF;border:1px solid #B0B0B0;color:#2B2D3F;padding:10px;border-radius:5px;opacity:0;transition:opacity 0.3s ease-in-out;z-index:10}.tel__tooltip.visible{opacity:1}";
7
+
8
+ const TelInput = /*@__PURE__*/ proxyCustomElement(class extends HTMLElement {
9
+ constructor() {
10
+ super();
11
+ this.__registerHost();
12
+ this.__attachShadow();
13
+ this.sendValidityState = createEvent(this, "sendValidityState", 7);
14
+ this.sendInputValue = createEvent(this, "sendInputValue", 7);
15
+ /**
16
+ * Client custom styling via inline style
17
+ */
18
+ this.clientStyling = '';
19
+ this.limitStylingAppends = false;
20
+ this.showTooltip = false;
21
+ this.validationPattern = '';
22
+ this.setClientStyling = () => {
23
+ let sheet = document.createElement('style');
24
+ sheet.innerHTML = this.clientStyling;
25
+ this.stylingContainer.prepend(sheet);
26
+ };
27
+ }
28
+ validityChanged() {
29
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
30
+ if (this.emitValue == true) {
31
+ this.valueHandler({ name: this.name, value: this.value });
32
+ }
33
+ }
34
+ validityStateHandler(inputStateEvent) {
35
+ this.sendValidityState.emit(inputStateEvent);
36
+ }
37
+ emitValueHandler(newValue) {
38
+ if (newValue == true && this.isValid) {
39
+ this.valueHandler({ name: this.name, value: this.value });
40
+ }
41
+ }
42
+ valueHandler(inputValueEvent) {
43
+ this.sendInputValue.emit(inputValueEvent);
44
+ }
45
+ handleClickOutside(event) {
46
+ if (event.composedPath()[0] === this.tooltipIconReference)
47
+ return;
48
+ if (event.composedPath()[0] !== this.tooltipReference)
49
+ this.showTooltip = false;
50
+ }
51
+ connectedCallback() {
52
+ this.validationPattern = this.setPattern();
53
+ if (this.defaultValue) {
54
+ this.prefixValue = this.defaultValue.split('|')[0];
55
+ this.phoneValue = this.defaultValue.split('|')[1];
56
+ }
57
+ }
58
+ componentWillLoad() {
59
+ if (this.action) {
60
+ if (this.action.split(" ")[0] == 'GET') {
61
+ return this.getPhoneCodes().then((options) => {
62
+ this.phoneCodesOptions = options.phoneCodes.map(code => {
63
+ return { label: code.Prefix, value: code.Prefix };
64
+ });
65
+ });
66
+ }
67
+ }
68
+ }
69
+ componentDidRender() {
70
+ // start custom styling area
71
+ if (!this.limitStylingAppends && this.stylingContainer) {
72
+ if (this.clientStyling)
73
+ this.setClientStyling();
74
+ this.limitStylingAppends = true;
75
+ }
76
+ // end custom styling area
77
+ if (this.defaultValue) {
78
+ this.value = `${this.prefixValue}|${this.phoneValue}`;
79
+ this.valueHandler({ name: this.name, value: this.value });
80
+ }
81
+ }
82
+ getPhoneCodes() {
83
+ // TEMPORARY FOR DEMO PURPOSES UNTIL NORWAY CONFIGURES AN ACTUAL ENDPOINT...
84
+ const url = new URL("https://demo-api.stage.norway.everymatrix.com/v1/player/phonecodes");
85
+ return new Promise((resolve, reject) => {
86
+ fetch(url.href)
87
+ .then((res) => res.json())
88
+ .then((options) => {
89
+ resolve(options);
90
+ }).catch((err) => {
91
+ console.error(err);
92
+ reject(err);
93
+ });
94
+ });
95
+ }
96
+ handleInput(event) {
97
+ this.phoneValue = event.target.value;
98
+ this.value = `${this.prefixValue}|${this.phoneValue}`;
99
+ this.errorMessage = this.setErrorMessage();
100
+ this.isValid = this.setValidity();
101
+ this.validityStateHandler({ valid: this.isValid, name: this.name });
102
+ this.emitValueHandler(true);
103
+ }
104
+ handlePrefixInput(event) {
105
+ this.prefixValue = event.target.value;
106
+ this.value = `${this.prefixValue}|${this.phoneValue}`;
107
+ this.emitValueHandler(true);
108
+ }
109
+ setValidity() {
110
+ return this.inputReference.validity.valid;
111
+ }
112
+ setPattern() {
113
+ var _a, _b;
114
+ if (((_a = this.validation.custom) === null || _a === void 0 ? void 0 : _a.length) > 0) {
115
+ return (_b = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _b === void 0 ? void 0 : _b.pattern;
116
+ }
117
+ }
118
+ setErrorMessage() {
119
+ var _a;
120
+ if (this.inputReference.validity.patternMismatch) {
121
+ return (_a = this.validation.custom.find(customValidation => customValidation.rule === 'regex')) === null || _a === void 0 ? void 0 : _a.errorMessage;
122
+ }
123
+ if (this.inputReference.validity.tooShort || this.inputReference.validity.tooLong) {
124
+ return translate('lengthError', this.language, { values: { minLength: this.validation.minLength, maxLength: this.validation.maxLength } });
125
+ }
126
+ if (this.inputReference.validity.valueMissing) {
127
+ return translate('requiredError', this.language);
128
+ }
129
+ }
130
+ renderTooltip() {
131
+ if (this.showTooltip) {
132
+ return (h("div", { class: `tel__tooltip ${this.showTooltip ? 'visible' : ''}`, ref: (el) => this.tooltipReference = el, innerHTML: this.tooltip }));
133
+ }
134
+ return null;
135
+ }
136
+ render() {
137
+ const invalidClass = this.isValid == true || this.isValid == undefined ? '' : 'tel__wrapper--flex--invalid';
138
+ return h("div", { class: 'tel__wrapper', ref: el => this.stylingContainer = el }, h("div", { class: 'tel__wrapper--flex-label' }, h("label", { class: `tel__label ${this.validation.mandatory ? 'tel__label--required' : ''}`, htmlFor: `${this.name}__input` }, this.displayName), h("div", { class: 'tel__wrapper--relative' }, this.tooltip &&
139
+ h("img", { class: 'tel__tooltip-icon', src: tooltipIconSvg, alt: "", ref: (el) => this.tooltipIconReference = el, onClick: () => this.showTooltip = !this.showTooltip }), this.renderTooltip())), h("div", { class: `tel__wrapper--flex ${invalidClass}` }, h("vaadin-combo-box", { class: 'tel__prefix', items: this.phoneCodesOptions, value: this.prefixValue, readOnly: this.autofilled, onChange: (e) => this.handlePrefixInput(e) }), h("input", { type: "tel", ref: (el) => this.inputReference = el, id: `${this.name}__input`, readOnly: this.autofilled, class: `tel__input`, value: this.phoneValue, placeholder: `${this.placeholder} ${this.placeholder && this.validation.mandatory ? '*' : ''}`, required: this.validation.mandatory, minlength: this.validation.minLength, maxlength: this.validation.maxLength, pattern: this.validationPattern, onBlur: (e) => this.handleInput(e) })), h("small", { class: 'tel__error-message' }, this.errorMessage));
140
+ }
141
+ static get watchers() { return {
142
+ "isValid": ["validityChanged"],
143
+ "emitValue": ["emitValueHandler"]
144
+ }; }
145
+ static get style() { return telInputCss; }
146
+ }, [1, "tel-input", {
147
+ "name": [513],
148
+ "displayName": [513, "display-name"],
149
+ "placeholder": [513],
150
+ "showLabels": [516, "show-labels"],
151
+ "action": [513],
152
+ "validation": [16],
153
+ "defaultValue": [513, "default-value"],
154
+ "autofilled": [516],
155
+ "tooltip": [513],
156
+ "language": [513],
157
+ "emitValue": [516, "emit-value"],
158
+ "clientStyling": [513, "client-styling"],
159
+ "isValid": [32],
160
+ "errorMessage": [32],
161
+ "limitStylingAppends": [32],
162
+ "showTooltip": [32]
163
+ }, [[4, "click", "handleClickOutside"]]]);
164
+ function defineCustomElement() {
165
+ if (typeof customElements === "undefined") {
166
+ return;
167
+ }
168
+ const components = ["tel-input"];
169
+ components.forEach(tagName => { switch (tagName) {
170
+ case "tel-input":
171
+ if (!customElements.get(tagName)) {
172
+ customElements.define(tagName, TelInput);
173
+ }
174
+ break;
175
+ } });
176
+ }
177
+
178
+ 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 };