@cscfi/csc-ui 1.0.12 → 1.0.14
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.
- package/dist/cjs/c-autocomplete.cjs.entry.js +15 -23
- package/dist/cjs/c-autocomplete.cjs.entry.js.map +1 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js +0 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js.map +1 -1
- package/dist/cjs/{c-dropdown_4.cjs.entry.js → c-dropdown_2.cjs.entry.js} +70 -205
- package/dist/cjs/c-dropdown_2.cjs.entry.js.map +1 -0
- package/dist/cjs/c-message.cjs.entry.js +67 -0
- package/dist/cjs/c-message.cjs.entry.js.map +1 -0
- package/dist/cjs/c-select.cjs.entry.js +12 -18
- package/dist/cjs/c-select.cjs.entry.js.map +1 -1
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/index-3cad12b5.js +6 -2
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/collection-manifest.json +0 -1
- package/dist/collection/components/c-autocomplete/c-autocomplete.js +15 -23
- package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
- package/dist/collection/components/c-checkbox/c-checkbox.js +0 -1
- package/dist/collection/components/c-checkbox/c-checkbox.js.map +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +15 -16
- package/dist/collection/components/c-dropdown/c-dropdown.js +109 -65
- package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
- package/dist/collection/components/c-input/c-input.css +1 -0
- package/dist/collection/components/c-input/c-input.js +26 -214
- package/dist/collection/components/c-input/c-input.js.map +1 -1
- package/dist/collection/components/c-select/c-select.js +12 -18
- package/dist/collection/components/c-select/c-select.js.map +1 -1
- package/dist/components/c-autocomplete.js +17 -31
- package/dist/components/c-autocomplete.js.map +1 -1
- package/dist/components/c-checkbox2.js +0 -1
- package/dist/components/c-checkbox2.js.map +1 -1
- package/dist/components/c-dropdown2.js +67 -44
- package/dist/components/c-dropdown2.js.map +1 -1
- package/dist/components/c-input2.js +9 -104
- package/dist/components/c-input2.js.map +1 -1
- package/dist/components/c-select.js +14 -26
- package/dist/components/c-select.js.map +1 -1
- package/dist/components/c-text-field.js +1 -19
- package/dist/components/c-text-field.js.map +1 -1
- package/dist/csc-ui/csc-ui.esm.js +1 -1
- package/dist/csc-ui/csc-ui.esm.js.map +1 -1
- package/dist/csc-ui/{p-d94b9e92.entry.js → p-2ff8e8e2.entry.js} +2 -2
- package/dist/csc-ui/p-2ff8e8e2.entry.js.map +1 -0
- package/dist/csc-ui/p-32298609.entry.js +2 -0
- package/dist/csc-ui/p-32298609.entry.js.map +1 -0
- package/dist/csc-ui/p-50db6941.entry.js +2 -0
- package/dist/csc-ui/p-50db6941.entry.js.map +1 -0
- package/dist/csc-ui/{p-ae28ae3f.entry.js → p-7575c2c3.entry.js} +2 -2
- package/dist/csc-ui/p-7575c2c3.entry.js.map +1 -0
- package/dist/csc-ui/p-bf307cb4.entry.js +2 -0
- package/dist/csc-ui/p-bf307cb4.entry.js.map +1 -0
- package/dist/esm/c-autocomplete.entry.js +15 -23
- package/dist/esm/c-autocomplete.entry.js.map +1 -1
- package/dist/esm/c-checkbox_2.entry.js +0 -1
- package/dist/esm/c-checkbox_2.entry.js.map +1 -1
- package/dist/esm/{c-dropdown_4.entry.js → c-dropdown_2.entry.js} +72 -205
- package/dist/esm/c-dropdown_2.entry.js.map +1 -0
- package/dist/esm/c-message.entry.js +63 -0
- package/dist/esm/c-message.entry.js.map +1 -0
- package/dist/esm/c-select.entry.js +12 -18
- package/dist/esm/c-select.entry.js.map +1 -1
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/index-cdf029b7.js +6 -2
- package/dist/esm/loader.js +1 -1
- package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +2 -2
- package/dist/types/components/c-dropdown/c-dropdown.d.ts +7 -5
- package/dist/types/components/c-input/c-input.d.ts +2 -15
- package/dist/types/components/c-select/c-select.d.ts +2 -2
- package/dist/types/components.d.ts +17 -56
- package/package.json +1 -1
- package/vscode-data.json +0 -8
- package/dist/cjs/c-dropdown_4.cjs.entry.js.map +0 -1
- package/dist/collection/components/c-dropdowns/c-dropdowns.css +0 -25
- package/dist/collection/components/c-dropdowns/c-dropdowns.js +0 -66
- package/dist/collection/components/c-dropdowns/c-dropdowns.js.map +0 -1
- package/dist/components/c-dropdowns.d.ts +0 -11
- package/dist/components/c-dropdowns.js +0 -8
- package/dist/components/c-dropdowns.js.map +0 -1
- package/dist/components/c-dropdowns2.js +0 -60
- package/dist/components/c-dropdowns2.js.map +0 -1
- package/dist/csc-ui/p-0a423333.entry.js +0 -2
- package/dist/csc-ui/p-0a423333.entry.js.map +0 -1
- package/dist/csc-ui/p-79b90c60.entry.js +0 -2
- package/dist/csc-ui/p-79b90c60.entry.js.map +0 -1
- package/dist/csc-ui/p-ae28ae3f.entry.js.map +0 -1
- package/dist/csc-ui/p-d94b9e92.entry.js.map +0 -1
- package/dist/esm/c-dropdown_4.entry.js.map +0 -1
- package/dist/types/components/c-dropdowns/c-dropdowns.d.ts +0 -29
|
@@ -26,8 +26,7 @@ export class CInput {
|
|
|
26
26
|
(_a = this.inputField) === null || _a === void 0 ? void 0 : _a.focus();
|
|
27
27
|
if (click) {
|
|
28
28
|
(_b = this.inputField) === null || _b === void 0 ? void 0 : _b.click();
|
|
29
|
-
if (this.
|
|
30
|
-
this._dropdownElement.wasClicked = true;
|
|
29
|
+
if (this.variant === 'select') {
|
|
31
30
|
this.itemClick.emit();
|
|
32
31
|
}
|
|
33
32
|
}
|
|
@@ -43,6 +42,7 @@ export class CInput {
|
|
|
43
42
|
this.hint = '';
|
|
44
43
|
this.hostId = undefined;
|
|
45
44
|
this.inputId = undefined;
|
|
45
|
+
this.items = undefined;
|
|
46
46
|
this.itemsPerPage = 6;
|
|
47
47
|
this.label = undefined;
|
|
48
48
|
this.max = null;
|
|
@@ -84,11 +84,6 @@ export class CInput {
|
|
|
84
84
|
if (placeholder)
|
|
85
85
|
this._onReset();
|
|
86
86
|
}
|
|
87
|
-
componentWillLoad() {
|
|
88
|
-
if (this.variant === 'select') {
|
|
89
|
-
this._createDropdownWrapper();
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
87
|
componentDidLoad() {
|
|
93
88
|
var _a, _b, _c, _d;
|
|
94
89
|
if (this.autofocus) {
|
|
@@ -144,73 +139,6 @@ export class CInput {
|
|
|
144
139
|
this.labelWidth = !!this.label ? this._labelRef.scrollWidth * 0.75 + 6 : 0;
|
|
145
140
|
this.preSlotWidth = this.inputField.offsetLeft;
|
|
146
141
|
}
|
|
147
|
-
_handleOutsideClick(event) {
|
|
148
|
-
if (!event.composedPath().includes(this._dropdownElement)) {
|
|
149
|
-
this.closeDropdown();
|
|
150
|
-
}
|
|
151
|
-
}
|
|
152
|
-
async _getScrollParent(element) {
|
|
153
|
-
return new Promise((resolve) => {
|
|
154
|
-
if (!element) {
|
|
155
|
-
resolve(undefined);
|
|
156
|
-
}
|
|
157
|
-
let parent = element.parentNode;
|
|
158
|
-
while (parent) {
|
|
159
|
-
if (parent.shadowRoot === undefined) {
|
|
160
|
-
parent = parent.host;
|
|
161
|
-
}
|
|
162
|
-
else {
|
|
163
|
-
const { overflow, overflowX } = window.getComputedStyle(parent);
|
|
164
|
-
if (overflowX !== 'scroll' &&
|
|
165
|
-
overflow.split(' ').every((o) => o === 'auto' || o === 'scroll')) {
|
|
166
|
-
resolve(parent);
|
|
167
|
-
}
|
|
168
|
-
parent = parent.parentNode;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
resolve(document.documentElement);
|
|
172
|
-
});
|
|
173
|
-
}
|
|
174
|
-
async focusDropdown() {
|
|
175
|
-
this._dropdownElement.focusDropdown();
|
|
176
|
-
}
|
|
177
|
-
async focusItem(type) {
|
|
178
|
-
await this._dropdownElement.focusItem(type);
|
|
179
|
-
}
|
|
180
|
-
async createDropdown(params) {
|
|
181
|
-
const wrapper = await this._getScrollParent(this.hiddenEl);
|
|
182
|
-
this._dropdownElement = await this._dropdownsElement.createDropdown(Object.assign(Object.assign({}, params), { itemsPerPage: params.itemsPerPage || 6, wrapper }));
|
|
183
|
-
}
|
|
184
|
-
async openDropdown(focusList = true) {
|
|
185
|
-
this._dropdownElement.shadowRoot
|
|
186
|
-
.querySelector('ul')
|
|
187
|
-
.classList.add('active');
|
|
188
|
-
this._dropdownElement.isOpen = true;
|
|
189
|
-
this._dropdownElement.focusList = focusList;
|
|
190
|
-
this._outsideClickFn = this._handleOutsideClick.bind(this);
|
|
191
|
-
requestAnimationFrame(() => {
|
|
192
|
-
window.addEventListener('click', this._outsideClickFn);
|
|
193
|
-
});
|
|
194
|
-
}
|
|
195
|
-
async closeDropdown() {
|
|
196
|
-
this._dropdownElement.shadowRoot
|
|
197
|
-
.querySelector('ul')
|
|
198
|
-
.classList.remove('active');
|
|
199
|
-
this._dropdownElement.isOpen = false;
|
|
200
|
-
window.removeEventListener('click', this._outsideClickFn);
|
|
201
|
-
}
|
|
202
|
-
async updateDropdown(params) {
|
|
203
|
-
var _a;
|
|
204
|
-
(_a = this._dropdownElement) === null || _a === void 0 ? void 0 : _a.updateDropdown(params);
|
|
205
|
-
}
|
|
206
|
-
_createDropdownWrapper() {
|
|
207
|
-
const existingElement = document.querySelector('c-dropdowns');
|
|
208
|
-
const element = existingElement || document.createElement('c-dropdowns');
|
|
209
|
-
this._dropdownsElement = element;
|
|
210
|
-
if (existingElement)
|
|
211
|
-
return;
|
|
212
|
-
document.body.appendChild(element);
|
|
213
|
-
}
|
|
214
142
|
_onReset() {
|
|
215
143
|
if (this.inputField) {
|
|
216
144
|
this.inputField.placeholder =
|
|
@@ -245,7 +173,7 @@ export class CInput {
|
|
|
245
173
|
}
|
|
246
174
|
get inputField() {
|
|
247
175
|
var _a;
|
|
248
|
-
return (_a = this.
|
|
176
|
+
return (_a = this.el) === null || _a === void 0 ? void 0 : _a.querySelector('.c-input__input');
|
|
249
177
|
}
|
|
250
178
|
_updateStatusText() {
|
|
251
179
|
if (this._debounce !== null) {
|
|
@@ -269,7 +197,7 @@ export class CInput {
|
|
|
269
197
|
};
|
|
270
198
|
return (h(Host, { disabled: this.disabled }, h("div", { id: 'announce-' + this.inputId, class: "visuallyhidden", "aria-live": "polite", "aria-atomic": "true" }, this.statusText), h("div", { class: containerClasses }, h("div", { class: "c-input__control" }, h("div", { class: "c-input__slot", onClick: () => this._onFocus() }, this._renderBorders(), h("div", { class: "c-input__field", style: {
|
|
271
199
|
'--_c-input-label-position': this.preSlotWidth + 'px',
|
|
272
|
-
} }, h("slot", { name: "pre" }), this._renderLabel(), h("slot", null))), !this.hideDetails && (h("c-message", { hint: this.hint, inputId: this.inputId, valid: this.valid, validation: this.validation }))))));
|
|
200
|
+
} }, h("slot", { name: "pre" }), this._renderLabel(), h("slot", null))), this.variant === 'select' && h("slot", { name: "dropdown" }), !this.hideDetails && (h("c-message", { hint: this.hint, inputId: this.inputId, valid: this.valid, validation: this.validation }))))));
|
|
273
201
|
}
|
|
274
202
|
static get is() { return "c-input"; }
|
|
275
203
|
static get originalStyleUrls() {
|
|
@@ -408,6 +336,27 @@ export class CInput {
|
|
|
408
336
|
"attribute": "input-id",
|
|
409
337
|
"reflect": false
|
|
410
338
|
},
|
|
339
|
+
"items": {
|
|
340
|
+
"type": "unknown",
|
|
341
|
+
"mutable": false,
|
|
342
|
+
"complexType": {
|
|
343
|
+
"original": "CSelectItem[]",
|
|
344
|
+
"resolved": "CSelectItem[]",
|
|
345
|
+
"references": {
|
|
346
|
+
"CSelectItem": {
|
|
347
|
+
"location": "import",
|
|
348
|
+
"path": "../../types",
|
|
349
|
+
"id": "src/types/index.ts::CSelectItem"
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
},
|
|
353
|
+
"required": false,
|
|
354
|
+
"optional": false,
|
|
355
|
+
"docs": {
|
|
356
|
+
"tags": [],
|
|
357
|
+
"text": "Items for the dropdown"
|
|
358
|
+
}
|
|
359
|
+
},
|
|
411
360
|
"itemsPerPage": {
|
|
412
361
|
"type": "number",
|
|
413
362
|
"mutable": false,
|
|
@@ -803,144 +752,7 @@ export class CInput {
|
|
|
803
752
|
}
|
|
804
753
|
}];
|
|
805
754
|
}
|
|
806
|
-
static get
|
|
807
|
-
return {
|
|
808
|
-
"focusDropdown": {
|
|
809
|
-
"complexType": {
|
|
810
|
-
"signature": "() => Promise<void>",
|
|
811
|
-
"parameters": [],
|
|
812
|
-
"references": {
|
|
813
|
-
"Promise": {
|
|
814
|
-
"location": "global",
|
|
815
|
-
"id": "global::Promise"
|
|
816
|
-
}
|
|
817
|
-
},
|
|
818
|
-
"return": "Promise<void>"
|
|
819
|
-
},
|
|
820
|
-
"docs": {
|
|
821
|
-
"text": "",
|
|
822
|
-
"tags": [{
|
|
823
|
-
"name": "private",
|
|
824
|
-
"text": undefined
|
|
825
|
-
}]
|
|
826
|
-
}
|
|
827
|
-
},
|
|
828
|
-
"focusItem": {
|
|
829
|
-
"complexType": {
|
|
830
|
-
"signature": "(type: 'first' | 'last') => Promise<void>",
|
|
831
|
-
"parameters": [{
|
|
832
|
-
"tags": [],
|
|
833
|
-
"text": ""
|
|
834
|
-
}],
|
|
835
|
-
"references": {
|
|
836
|
-
"Promise": {
|
|
837
|
-
"location": "global",
|
|
838
|
-
"id": "global::Promise"
|
|
839
|
-
}
|
|
840
|
-
},
|
|
841
|
-
"return": "Promise<void>"
|
|
842
|
-
},
|
|
843
|
-
"docs": {
|
|
844
|
-
"text": "",
|
|
845
|
-
"tags": [{
|
|
846
|
-
"name": "private",
|
|
847
|
-
"text": undefined
|
|
848
|
-
}]
|
|
849
|
-
}
|
|
850
|
-
},
|
|
851
|
-
"createDropdown": {
|
|
852
|
-
"complexType": {
|
|
853
|
-
"signature": "(params: _CDropdownParams) => Promise<void>",
|
|
854
|
-
"parameters": [{
|
|
855
|
-
"tags": [],
|
|
856
|
-
"text": ""
|
|
857
|
-
}],
|
|
858
|
-
"references": {
|
|
859
|
-
"Promise": {
|
|
860
|
-
"location": "global",
|
|
861
|
-
"id": "global::Promise"
|
|
862
|
-
},
|
|
863
|
-
"_CDropdownParams": {
|
|
864
|
-
"location": "import",
|
|
865
|
-
"path": "../c-dropdowns/c-dropdowns",
|
|
866
|
-
"id": "src/components/c-dropdowns/c-dropdowns.tsx::_CDropdownParams"
|
|
867
|
-
}
|
|
868
|
-
},
|
|
869
|
-
"return": "Promise<void>"
|
|
870
|
-
},
|
|
871
|
-
"docs": {
|
|
872
|
-
"text": "Create a dropdown",
|
|
873
|
-
"tags": []
|
|
874
|
-
}
|
|
875
|
-
},
|
|
876
|
-
"openDropdown": {
|
|
877
|
-
"complexType": {
|
|
878
|
-
"signature": "(focusList?: boolean) => Promise<void>",
|
|
879
|
-
"parameters": [{
|
|
880
|
-
"tags": [],
|
|
881
|
-
"text": ""
|
|
882
|
-
}],
|
|
883
|
-
"references": {
|
|
884
|
-
"Promise": {
|
|
885
|
-
"location": "global",
|
|
886
|
-
"id": "global::Promise"
|
|
887
|
-
}
|
|
888
|
-
},
|
|
889
|
-
"return": "Promise<void>"
|
|
890
|
-
},
|
|
891
|
-
"docs": {
|
|
892
|
-
"text": "Opens the dropdown",
|
|
893
|
-
"tags": []
|
|
894
|
-
}
|
|
895
|
-
},
|
|
896
|
-
"closeDropdown": {
|
|
897
|
-
"complexType": {
|
|
898
|
-
"signature": "() => Promise<void>",
|
|
899
|
-
"parameters": [],
|
|
900
|
-
"references": {
|
|
901
|
-
"Promise": {
|
|
902
|
-
"location": "global",
|
|
903
|
-
"id": "global::Promise"
|
|
904
|
-
}
|
|
905
|
-
},
|
|
906
|
-
"return": "Promise<void>"
|
|
907
|
-
},
|
|
908
|
-
"docs": {
|
|
909
|
-
"text": "Closes the dropdown",
|
|
910
|
-
"tags": []
|
|
911
|
-
}
|
|
912
|
-
},
|
|
913
|
-
"updateDropdown": {
|
|
914
|
-
"complexType": {
|
|
915
|
-
"signature": "(params: _CDropdownUpdateParams) => Promise<void>",
|
|
916
|
-
"parameters": [{
|
|
917
|
-
"tags": [],
|
|
918
|
-
"text": ""
|
|
919
|
-
}],
|
|
920
|
-
"references": {
|
|
921
|
-
"Promise": {
|
|
922
|
-
"location": "global",
|
|
923
|
-
"id": "global::Promise"
|
|
924
|
-
},
|
|
925
|
-
"_CDropdownUpdateParams": {
|
|
926
|
-
"location": "import",
|
|
927
|
-
"path": "../c-dropdown/c-dropdown",
|
|
928
|
-
"id": "src/components/c-dropdown/c-dropdown.tsx::_CDropdownUpdateParams"
|
|
929
|
-
}
|
|
930
|
-
},
|
|
931
|
-
"return": "Promise<void>"
|
|
932
|
-
},
|
|
933
|
-
"docs": {
|
|
934
|
-
"text": "",
|
|
935
|
-
"tags": [{
|
|
936
|
-
"name": "private",
|
|
937
|
-
"text": undefined
|
|
938
|
-
}]
|
|
939
|
-
}
|
|
940
|
-
}
|
|
941
|
-
};
|
|
942
|
-
}
|
|
943
|
-
static get elementRef() { return "hiddenEl"; }
|
|
755
|
+
static get elementRef() { return "el"; }
|
|
944
756
|
static get watchers() {
|
|
945
757
|
return [{
|
|
946
758
|
"propName": "valid",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c-input.js","sourceRoot":"","sources":["../../../../src/components/c-input/c-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,CAAC,EACD,KAAK,EACL,IAAI,EACJ,KAAK,EAEL,OAAO,EACP,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AAavB,MAAM,OAAO,MAAM;;IAmLT,gBAAW,GAAG,KAAK,CAAC;IAIpB,cAAS,GAAG,IAAI,CAAC;IAkGjB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;MACpB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,KAAK,CAAC,cAAc,EAAE;UACxB,IAAI,CAAC,uBAAuB,EAAE,CAAC;UAC/B,QAAQ,CAAC,SAA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EpB,eAAa,CACT,CACF;UAEL,CAAC,IAAI,CAAC,WAAW,IAAI,CACpB,iBACE,IAAI,EAAE,IAAI,CAAC,IAAI,EACf,OAAO,EAAE,IAAI,CAAC,OAAO,EACrB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,UAAU,EAAE,IAAI,CAAC,UAAU,GAC3B,CACH,CACG,CACF,CACD,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Host,\n h,\n State,\n Prop,\n Event,\n EventEmitter,\n Element,\n Watch,\n Method,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\nimport { _CDropdownParams } from '../c-dropdowns/c-dropdowns';\nimport { _CDropdownUpdateParams } from '../c-dropdown/c-dropdown';\n\n/**\n * @parent None\n */\n@Component({\n tag: 'c-input',\n styleUrl: 'c-input.scss',\n shadow: false,\n})\nexport class CInput {\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Render a hidden input outside the shadow dom\n */\n @Prop() form = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the input\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Id of the input element\n */\n @Prop() inputId: string;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Label of the input\n */\n @Prop() label: string;\n\n /**\n * Maximum value on a numeric input\n */\n @Prop() max: number = null;\n\n /**\n * Minimum value on a numeric input\n */\n @Prop() min: number = null;\n\n /**\n * Name of the input\n */\n @Prop() name: string;\n\n /**\n * Placeholder of the input\n */\n @Prop() placeholder: string;\n\n /**\n * Mark as readonly\n */\n @Prop() readonly = false;\n\n /**\n * Set the input as required\n */\n @Prop() required = false;\n\n /**\n * Rows on the input\n */\n @Prop() rows = 1;\n\n /**\n * Shadow variant of the input\n */\n @Prop() shadow = false;\n\n /**\n * Step size on a numeric input\n */\n @Prop() step: number = null;\n\n /**\n * Type of the input\n */\n @Prop() type: string;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Value of the input\n */\n @Prop() value: string | number | boolean | CSelectItem | CAutocompleteItem;\n\n /**\n * Variant\n */\n @Prop() variant: 'text' | 'select' = 'text';\n\n /**\n * Emit changes to the parent\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Emit click to the parent\n * @private\n */\n @Event({ bubbles: false }) itemClick: EventEmitter;\n\n /**\n * Emit close to the parent\n * @private\n */\n @Event({ bubbles: false }) dropdownClose: EventEmitter;\n\n @State() isFocused = false;\n\n @State() labelWidth = 0;\n\n @State() preSlotWidth = 0;\n\n @State() statusText = '';\n\n @State() currentIndex: number = null;\n\n @Element() hiddenEl!: HTMLCInputElement;\n\n @Watch('valid')\n onValidChange() {\n if (this.validateOnBlur && !this._hasBlurred) return;\n\n this._setAriaDescriptionId();\n }\n\n @Watch('validation')\n onValidationMessageChange() {\n this._updateStatusText();\n }\n\n @Watch('value')\n onValueChange(value) {\n if (!value) {\n this._onReset();\n }\n }\n\n @Watch('placeholder')\n onPlaceholderChange(placeholder) {\n if (placeholder) this._onReset();\n }\n\n private _hasBlurred = false;\n\n private _labelRef: HTMLLabelElement;\n\n private _debounce = null;\n\n private _dropdownsElement: HTMLCDropdownsElement;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n private _outsideClickFn: () => void;\n\n // private _parentTop = 0;\n\n // private _listSize = 0;\n\n // private _parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n componentWillLoad() {\n if (this.variant === 'select') {\n this._createDropdownWrapper();\n }\n }\n\n componentDidLoad() {\n if (this.autofocus) {\n setTimeout(() => {\n this._onFocus(false);\n }, 500);\n }\n\n this._calculateElementWidths();\n this._setAriaDescriptionId();\n\n if (this.label) {\n this._observer.observe(this._labelRef);\n }\n\n this.inputField?.addEventListener('focus', () => this._onFocus(false));\n this.inputField?.addEventListener('blur', () => this._onBlur());\n this.inputField?.addEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n // hide the placeholder text initially if there is a label\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.label || !this.placeholder ? '' : this.placeholder;\n\n this.inputField.title = this.label ?? this.placeholder;\n\n requestAnimationFrame(() => {\n const container = this.inputField.closest(\n '.c-input-menu__input',\n ) as HTMLDivElement;\n\n if (!container) return;\n\n container.dataset.placeholder = this.placeholder;\n });\n }\n }\n\n disconnectedCallback() {\n this.inputField?.removeEventListener('focus', () => this._onFocus(false));\n this.inputField?.removeEventListener('blur', () => this._onBlur());\n this.inputField?.removeEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n this._observer.disconnect();\n\n this._dropdownElement?.remove();\n }\n\n get isActive() {\n return !!this.value || typeof this.value === 'boolean' || this.isFocused;\n }\n\n private _setAriaDescriptionId() {\n this.inputField.removeAttribute('aria-describedby');\n\n let type = null;\n\n if (this.valid && !this.value && this.hint) {\n type = 'hint';\n }\n\n if (!this.valid) {\n type = 'error';\n }\n\n if (type) {\n this.inputField.setAttribute(\n 'aria-describedby',\n `${type}-${this.inputId}`,\n );\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n this._calculateElementWidths();\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _calculateElementWidths() {\n this.labelWidth = !!this.label ? this._labelRef.scrollWidth * 0.75 + 6 : 0;\n this.preSlotWidth = this.inputField.offsetLeft;\n }\n\n private _handleOutsideClick(event) {\n if (!event.composedPath().includes(this._dropdownElement)) {\n this.closeDropdown();\n }\n }\n\n private async _getScrollParent(element): Promise<HTMLElement> {\n return new Promise((resolve) => {\n if (!element) {\n resolve(undefined);\n }\n\n let parent = element.parentNode;\n\n while (parent) {\n if (parent.shadowRoot === undefined) {\n parent = parent.host;\n } else {\n const { overflow, overflowX } = window.getComputedStyle(parent);\n\n if (\n overflowX !== 'scroll' &&\n overflow.split(' ').every((o) => o === 'auto' || o === 'scroll')\n ) {\n resolve(parent);\n }\n\n parent = parent.parentNode;\n }\n }\n\n resolve(document.documentElement);\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusDropdown() {\n this._dropdownElement.focusDropdown();\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(type: 'first' | 'last') {\n await this._dropdownElement.focusItem(type);\n }\n\n /**\n * Create a dropdown\n */\n @Method()\n async createDropdown(params: _CDropdownParams) {\n const wrapper = await this._getScrollParent(this.hiddenEl);\n\n // eslint-disable-next-line @typescript-eslint/ban-ts-comment\n // @ts-ignore\n this._dropdownElement = await this._dropdownsElement.createDropdown({\n ...params,\n itemsPerPage: params.itemsPerPage || 6,\n wrapper,\n });\n }\n\n /**\n * Opens the dropdown\n */\n @Method()\n async openDropdown(focusList = true) {\n this._dropdownElement.shadowRoot\n .querySelector('ul')\n .classList.add('active');\n\n this._dropdownElement.isOpen = true;\n this._dropdownElement.focusList = focusList;\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n requestAnimationFrame(() => {\n window.addEventListener('click', this._outsideClickFn);\n });\n }\n\n /**\n * Closes the dropdown\n */\n @Method()\n async closeDropdown() {\n this._dropdownElement.shadowRoot\n .querySelector('ul')\n .classList.remove('active');\n\n this._dropdownElement.isOpen = false;\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n /**\n * @private\n */\n @Method()\n async updateDropdown(params: _CDropdownUpdateParams) {\n this._dropdownElement?.updateDropdown(params);\n }\n\n private _createDropdownWrapper() {\n const existingElement = document.querySelector('c-dropdowns');\n const element = existingElement || document.createElement('c-dropdowns');\n\n this._dropdownsElement = element;\n // this._dropdownsElement.itemsPerPage = this.itemsPerPage;\n\n if (existingElement) return;\n\n document.body.appendChild(element);\n }\n\n private _onBlur = () => {\n // delay the blur event to prevent the label from 'flashing' on c-select selection\n setTimeout(() => {\n this.isFocused = false;\n this._hasBlurred = true;\n\n // show the label if there's no label or value\n this._onReset();\n }, 100);\n };\n\n private _onFocus = (click = true) => {\n if (this.disabled) return;\n\n this.isFocused = true;\n\n this.inputField?.focus();\n\n if (click) {\n this.inputField?.click();\n\n if (this._dropdownElement) {\n this._dropdownElement.wasClicked = true;\n this.itemClick.emit();\n }\n }\n\n // show the label if there's no value\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.value || !this.placeholder ? '' : this.placeholder;\n }\n };\n\n private _onReset() {\n if (this.inputField) {\n this.inputField.placeholder =\n !this.label && !this.value && !!this.placeholder\n ? this.placeholder\n : '';\n }\n }\n\n /**\n * Prevent non numeric values in the numeric fields\n */\n private _preventNonNumericalInput(event: KeyboardEvent) {\n if (this.type !== 'number') return;\n\n if (!event.key.match(/^[0-9,\\.]+$/)) event.preventDefault();\n }\n\n private _renderBorders() {\n if (this.shadow) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <fieldset aria-hidden=\"true\">\n <legend\n class={classes}\n style={{\n '--_c-input-legend-width': this.labelWidth + 'px',\n }}\n >\n <span class=\"notranslate\"></span>\n </legend>\n </fieldset>\n );\n }\n\n private _renderLabel() {\n if (!this.label) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <label\n htmlFor={this.inputId}\n ref={(el) => (this._labelRef = el as HTMLLabelElement)}\n class={classes}\n >\n {this.label}\n {this.required && <span> *</span>}\n </label>\n );\n }\n\n get inputField() {\n return this.hiddenEl?.querySelector('.c-input__input') as\n | HTMLInputElement\n | HTMLTextAreaElement;\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n this.statusText = this.valid ? '' : `Error: ${this.validation}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n const containerClasses = {\n 'c-input': true,\n 'c-input--disabled': this.disabled,\n 'c-input--shadow': this.shadow,\n 'c-input--textarea': this.rows > 1,\n 'c-input--error': !this.valid,\n filled: !!this.value,\n [`c-input--${this.variant}`]: true,\n };\n\n return (\n <Host disabled={this.disabled}>\n <div\n id={'announce-' + this.inputId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class={containerClasses}>\n <div class=\"c-input__control\">\n <div class=\"c-input__slot\" onClick={() => this._onFocus()}>\n {this._renderBorders()}\n\n <div\n class=\"c-input__field\"\n style={{\n '--_c-input-label-position': this.preSlotWidth + 'px',\n }}\n >\n <slot name=\"pre\"></slot>\n\n {this._renderLabel()}\n\n <slot></slot>\n </div>\n </div>\n\n {!this.hideDetails && (\n <c-message\n hint={this.hint}\n inputId={this.inputId}\n valid={this.valid}\n validation={this.validation}\n />\n )}\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"c-input.js","sourceRoot":"","sources":["../../../../src/components/c-input/c-input.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,SAAS,EACT,IAAI,EACJ,CAAC,EACD,KAAK,EACL,IAAI,EACJ,KAAK,EAEL,OAAO,EACP,KAAK,GACN,MAAM,eAAe,CAAC;AAWvB,MAAM,OAAO,MAAM;;IAwLT,gBAAW,GAAG,KAAK,CAAC;IAIpB,cAAS,GAAG,IAAI,CAAC;IAkFjB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;MACpB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,KAAK,CAAC,cAAc,EAAE;UACxB,IAAI,CAAC,uBAAuB,EAAE,CAAC;UAC/B,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC;SAClC;MACH,CAAC,CAAC,CAAC;IACL,CAAC,EACD,EAAE,SAAS,EAAE,CAAC,EAAE,CACjB,CAAC;IAOM,YAAO,GAAG,GAAG,EAAE;MAErB,UAAU,CAAC,GAAG,EAAE;QACd,IAAI,CAAC,SAAS,GAAG,KAAK,CAAC;QACvB,IAAI,CAAC,WAAW,GAAG,IAAI,CAAC;QAGxB,IAAI,CAAC,QAAQ,EAAE,CAAC;MAClB,CAAC,EAAE,GAAG,CAAC,CAAC;IACV,CAAC,CAAC;IAEM,aAAQ,GAAG,CAAC,KAAK,GAAG,IAAI,EAAE,EAAE;;MAClC,IAAI,IAAI,CAAC,QAAQ;QAAE,OAAO;MAE1B,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC;MAEtB,MAA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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CACF","sourcesContent":["import {\n Component,\n Host,\n h,\n State,\n Prop,\n Event,\n EventEmitter,\n Element,\n Watch,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\n\n/**\n * @parent None\n */\n@Component({\n tag: 'c-input',\n styleUrl: 'c-input.scss',\n shadow: false,\n})\nexport class CInput {\n @Element() el!: HTMLCInputElement;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Render a hidden input outside the shadow dom\n */\n @Prop() form = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the input\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Id of the input element\n */\n @Prop() inputId: string;\n\n /**\n * Items for the dropdown\n */\n @Prop() items: CSelectItem[];\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Label of the input\n */\n @Prop() label: string;\n\n /**\n * Maximum value on a numeric input\n */\n @Prop() max: number = null;\n\n /**\n * Minimum value on a numeric input\n */\n @Prop() min: number = null;\n\n /**\n * Name of the input\n */\n @Prop() name: string;\n\n /**\n * Placeholder of the input\n */\n @Prop() placeholder: string;\n\n /**\n * Mark as readonly\n */\n @Prop() readonly = false;\n\n /**\n * Set the input as required\n */\n @Prop() required = false;\n\n /**\n * Rows on the input\n */\n @Prop() rows = 1;\n\n /**\n * Shadow variant of the input\n */\n @Prop() shadow = false;\n\n /**\n * Step size on a numeric input\n */\n @Prop() step: number = null;\n\n /**\n * Type of the input\n */\n @Prop() type: string;\n\n /**\n * Set the validíty of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Value of the input\n */\n @Prop() value: string | number | boolean | CSelectItem | CAutocompleteItem;\n\n /**\n * Variant\n */\n @Prop() variant: 'text' | 'select' = 'text';\n\n /**\n * Emit changes to the parent\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Emit click to the parent\n * @private\n */\n @Event({ bubbles: false }) itemClick: EventEmitter;\n\n /**\n * Emit close to the parent\n * @private\n */\n @Event({ bubbles: false }) dropdownClose: EventEmitter;\n\n @State() isFocused = false;\n\n @State() labelWidth = 0;\n\n @State() preSlotWidth = 0;\n\n @State() statusText = '';\n\n @State() currentIndex: number = null;\n\n @Watch('valid')\n onValidChange() {\n if (this.validateOnBlur && !this._hasBlurred) return;\n\n this._setAriaDescriptionId();\n }\n\n @Watch('validation')\n onValidationMessageChange() {\n this._updateStatusText();\n }\n\n @Watch('value')\n onValueChange(value) {\n if (!value) {\n this._onReset();\n }\n }\n\n @Watch('placeholder')\n onPlaceholderChange(placeholder) {\n if (placeholder) this._onReset();\n }\n\n private _hasBlurred = false;\n\n private _labelRef: HTMLLabelElement;\n\n private _debounce = null;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n componentDidLoad() {\n if (this.autofocus) {\n setTimeout(() => {\n this._onFocus(false);\n }, 500);\n }\n\n this._calculateElementWidths();\n this._setAriaDescriptionId();\n\n if (this.label) {\n this._observer.observe(this._labelRef);\n }\n\n this.inputField?.addEventListener('focus', () => this._onFocus(false));\n this.inputField?.addEventListener('blur', () => this._onBlur());\n this.inputField?.addEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n // hide the placeholder text initially if there is a label\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.label || !this.placeholder ? '' : this.placeholder;\n\n this.inputField.title = this.label ?? this.placeholder;\n\n requestAnimationFrame(() => {\n const container = this.inputField.closest(\n '.c-input-menu__input',\n ) as HTMLDivElement;\n\n if (!container) return;\n\n container.dataset.placeholder = this.placeholder;\n });\n }\n }\n\n disconnectedCallback() {\n this.inputField?.removeEventListener('focus', () => this._onFocus(false));\n this.inputField?.removeEventListener('blur', () => this._onBlur());\n this.inputField?.removeEventListener(\n 'keypress',\n this._preventNonNumericalInput,\n );\n\n this._observer.disconnect();\n\n this._dropdownElement?.remove();\n }\n\n get isActive() {\n return !!this.value || typeof this.value === 'boolean' || this.isFocused;\n }\n\n private _setAriaDescriptionId() {\n this.inputField.removeAttribute('aria-describedby');\n\n let type = null;\n\n if (this.valid && !this.value && this.hint) {\n type = 'hint';\n }\n\n if (!this.valid) {\n type = 'error';\n }\n\n if (type) {\n this.inputField.setAttribute(\n 'aria-describedby',\n `${type}-${this.inputId}`,\n );\n }\n }\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (entry.isIntersecting) {\n this._calculateElementWidths();\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n private _calculateElementWidths() {\n this.labelWidth = !!this.label ? this._labelRef.scrollWidth * 0.75 + 6 : 0;\n this.preSlotWidth = this.inputField.offsetLeft;\n }\n\n private _onBlur = () => {\n // delay the blur event to prevent the label from 'flashing' on c-select selection\n setTimeout(() => {\n this.isFocused = false;\n this._hasBlurred = true;\n\n // show the label if there's no label or value\n this._onReset();\n }, 100);\n };\n\n private _onFocus = (click = true) => {\n if (this.disabled) return;\n\n this.isFocused = true;\n\n this.inputField?.focus();\n\n if (click) {\n this.inputField?.click();\n\n if (this.variant === 'select') {\n this.itemClick.emit();\n }\n }\n\n // show the label if there's no value\n if (this.inputField) {\n this.inputField.placeholder =\n !!this.value || !this.placeholder ? '' : this.placeholder;\n }\n };\n\n private _onReset() {\n if (this.inputField) {\n this.inputField.placeholder =\n !this.label && !this.value && !!this.placeholder\n ? this.placeholder\n : '';\n }\n }\n\n /**\n * Prevent non numeric values in the numeric fields\n */\n private _preventNonNumericalInput(event: KeyboardEvent) {\n if (this.type !== 'number') return;\n\n if (!event.key.match(/^[0-9,\\.]+$/)) event.preventDefault();\n }\n\n private _renderBorders() {\n if (this.shadow) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <fieldset aria-hidden=\"true\">\n <legend\n class={classes}\n style={{\n '--_c-input-legend-width': this.labelWidth + 'px',\n }}\n >\n <span class=\"notranslate\"></span>\n </legend>\n </fieldset>\n );\n }\n\n private _renderLabel() {\n if (!this.label) return;\n\n const classes = {\n active: this.isActive,\n };\n\n return (\n <label\n htmlFor={this.inputId}\n ref={(el) => (this._labelRef = el as HTMLLabelElement)}\n class={classes}\n >\n {this.label}\n {this.required && <span> *</span>}\n </label>\n );\n }\n\n get inputField() {\n return this.el?.querySelector('.c-input__input') as\n | HTMLInputElement\n | HTMLTextAreaElement;\n }\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n this.statusText = this.valid ? '' : `Error: ${this.validation}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n const containerClasses = {\n 'c-input': true,\n 'c-input--disabled': this.disabled,\n 'c-input--shadow': this.shadow,\n 'c-input--textarea': this.rows > 1,\n 'c-input--error': !this.valid,\n filled: !!this.value,\n [`c-input--${this.variant}`]: true,\n };\n\n return (\n <Host disabled={this.disabled}>\n <div\n id={'announce-' + this.inputId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class={containerClasses}>\n <div class=\"c-input__control\">\n <div class=\"c-input__slot\" onClick={() => this._onFocus()}>\n {this._renderBorders()}\n\n <div\n class=\"c-input__field\"\n style={{\n '--_c-input-label-position': this.preSlotWidth + 'px',\n }}\n >\n <slot name=\"pre\"></slot>\n\n {this._renderLabel()}\n\n <slot></slot>\n </div>\n </div>\n\n {this.variant === 'select' && <slot name=\"dropdown\"></slot>}\n\n {!this.hideDetails && (\n <c-message\n hint={this.hint}\n inputId={this.inputId}\n valid={this.valid}\n validation={this.validation}\n />\n )}\n </div>\n </div>\n </Host>\n );\n }\n}\n"]}
|
|
@@ -152,15 +152,21 @@ export class CSelect {
|
|
|
152
152
|
}
|
|
153
153
|
}
|
|
154
154
|
if (ev.key === 'Tab') {
|
|
155
|
-
this.
|
|
155
|
+
this._dropdownElement.close();
|
|
156
156
|
}
|
|
157
157
|
if (ev.key === 'ArrowDown') {
|
|
158
158
|
ev.preventDefault();
|
|
159
|
+
if (this._dropdownElement.isOpen)
|
|
160
|
+
return;
|
|
159
161
|
this._showMenu();
|
|
162
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
160
163
|
}
|
|
161
164
|
if (ev.key === 'ArrowUp') {
|
|
162
165
|
ev.preventDefault();
|
|
166
|
+
if (this._dropdownElement.isOpen)
|
|
167
|
+
return;
|
|
163
168
|
this._showMenu();
|
|
169
|
+
this._dropdownElement.focusItem(this.currentIndex);
|
|
164
170
|
}
|
|
165
171
|
if (ev.key === ' ') {
|
|
166
172
|
ev.preventDefault();
|
|
@@ -201,18 +207,6 @@ export class CSelect {
|
|
|
201
207
|
this.currentIndex !== 0) {
|
|
202
208
|
this.currentIndex = this._items.findIndex((item) => item.value === this.value);
|
|
203
209
|
}
|
|
204
|
-
requestAnimationFrame(() => {
|
|
205
|
-
this._cInput.createDropdown({
|
|
206
|
-
type: 'select',
|
|
207
|
-
items: this._items,
|
|
208
|
-
options: this._cOptionElements,
|
|
209
|
-
parent: this.host,
|
|
210
|
-
itemsPerPage: this.itemsPerPage,
|
|
211
|
-
index: this.currentIndex,
|
|
212
|
-
click: false,
|
|
213
|
-
id: this._inputId,
|
|
214
|
-
});
|
|
215
|
-
});
|
|
216
210
|
}
|
|
217
211
|
disconnectedCallback() {
|
|
218
212
|
this._observer.disconnect();
|
|
@@ -229,13 +223,13 @@ export class CSelect {
|
|
|
229
223
|
if (this.disabled)
|
|
230
224
|
return;
|
|
231
225
|
this.menuVisible = true;
|
|
232
|
-
this.
|
|
226
|
+
this._dropdownElement.open();
|
|
233
227
|
}
|
|
234
228
|
_getOptionItems() {
|
|
235
229
|
requestAnimationFrame(() => {
|
|
236
230
|
this._cOptionElements = {};
|
|
237
231
|
let selection = null;
|
|
238
|
-
this._optionItems = (this.
|
|
232
|
+
this._optionItems = (this.el ? Array.from(this.el.querySelectorAll('c-option')) : []).map((item, index) => {
|
|
239
233
|
const cSelectItem = {
|
|
240
234
|
value: item.value,
|
|
241
235
|
name: item.name || item.innerText,
|
|
@@ -284,7 +278,7 @@ export class CSelect {
|
|
|
284
278
|
}
|
|
285
279
|
this._debounce = window.setTimeout(() => {
|
|
286
280
|
var _a;
|
|
287
|
-
const selection = this.
|
|
281
|
+
const selection = this.el.shadowRoot.querySelector('li[aria-selected="true"]');
|
|
288
282
|
const ending = !!this._items.length
|
|
289
283
|
? ', to navigate use up and down arrows'
|
|
290
284
|
: '';
|
|
@@ -299,7 +293,7 @@ export class CSelect {
|
|
|
299
293
|
}
|
|
300
294
|
render() {
|
|
301
295
|
var _a;
|
|
302
|
-
return (h(Host, { title: (_a = this._getLabel()) !== null && _a !== void 0 ? _a : null }, h("div", { id: 'announce-' + this._id, class: "visuallyhidden", "aria-live": "polite", "aria-atomic": "true" }, this.statusText), h("c-input", {
|
|
296
|
+
return (h(Host, { title: (_a = this._getLabel()) !== null && _a !== void 0 ? _a : null }, h("div", { id: 'announce-' + this._id, class: "visuallyhidden", "aria-live": "polite", "aria-atomic": "true" }, this.statusText), h("c-input", { autofocus: this.autofocus, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, items: this._items, "items-per-page": this.itemsPerPage, label: this.label, name: this.name, placeholder: this.placeholder, required: this.required, shadow: this.shadow, valid: this.valid, validate: this.validate, "validate-on-blur": this.validateOnBlur, validation: this.validation, value: this.value, variant: "select", onItemClick: () => this._showMenu() }, h("slot", { name: "pre", slot: "pre" }), h("div", { class: "c-input__content" }, this._renderInputElement(), this._renderChevron(), h("slot", { onSlotchange: this._handleSlotChange })), h("c-dropdown", { ref: (el) => (this._dropdownElement = el), slot: "dropdown", items: this._items, options: this._cOptionElements, "items-per-page": this.itemsPerPage, parent: this.el, index: this.currentIndex, "input-id": this._inputId, type: "select" }), h("slot", { name: "post", slot: "post" }))));
|
|
303
297
|
}
|
|
304
298
|
static get is() { return "c-select"; }
|
|
305
299
|
static get encapsulation() { return "shadow"; }
|
|
@@ -760,7 +754,7 @@ export class CSelect {
|
|
|
760
754
|
}
|
|
761
755
|
};
|
|
762
756
|
}
|
|
763
|
-
static get elementRef() { return "
|
|
757
|
+
static get elementRef() { return "el"; }
|
|
764
758
|
static get watchers() {
|
|
765
759
|
return [{
|
|
766
760
|
"propName": "value",
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"c-select.js","sourceRoot":"","sources":["../../../../src/components/c-select/c-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,CAAC,EACD,MAAM,EACN,KAAK,EAEL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAazC,MAAM,OAAO,OAAO;;IAuHV,cAAS,GACf,EAAE,CAAC;IAIG,qBAAgB,GAAuC,EAAE,CAAC;IAM1D,yBAAoB,GAAG,CAAC,eAAe,CAAC,CAAC;IAIzC,uBAAkB,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAE5C,cAAS,GAAG,IAAI,CAAC;IAEjB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;MACpB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;UACzB,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;YAC1B,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;WAClB,C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,IAAI,CAAC,SAAS,EAAE;QAEnC,YAAM,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,GAAQ;QAEnC,WAAK,KAAK,EAAC,kBAAkB;UAC1B,IAAI,CAAC,mBAAmB,EAAE;UAC1B,IAAI,CAAC,cAAc,EAAE;UAEtB,YAAM,YAAY,EAAE,IAAI,CAAC,iBAAiB,GAAS,CAC/C;QAEN,YAAM,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAQ,CAC7B,CACL,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA5cc,iBAAS,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import {\n AttachInternals,\n Component,\n Element,\n Host,\n Prop,\n State,\n h,\n Listen,\n Event,\n EventEmitter,\n Watch,\n Method,\n} from '@stencil/core';\nimport { mdiChevronDown } from '@mdi/js';\nimport { CSelectItem } from '../../types';\n\n/**\n * @group Form\n * @slot Default slot - Use c-option elements only\n */\n@Component({\n tag: 'c-select',\n styleUrl: 'c-select.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CSelect {\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Set as required\n */\n @Prop() required = false;\n\n /**\n * Return only the item value rather than the whole item object\n */\n @Prop() returnValue: false;\n\n /**\n * Set the validity of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\n\n /**\n * Selected item\n */\n @Prop({ mutable: true }) value: string | number | boolean | CSelectItem =\n null;\n\n /**\n * selectable items\n */\n @Prop() items: CSelectItem[] = [];\n\n /**\n * display the option as selection (works only when c-option elements are used)\n */\n @Prop() optionAsSelection: false;\n\n /**\n * Triggered when an item is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n @Element() host: HTMLCSelectElement;\n\n @State() menuVisible = false;\n\n @State() currentIndex: number = null;\n\n @State() activeListItemId: string = null;\n\n @State() statusText = '';\n\n @State() hasOptionItems = false;\n\n @State() previousValue: CSelectItem = { value: '', name: '' };\n\n private _itemRefs: { value: string | number | boolean; ref: HTMLElement }[] =\n [];\n\n private _id: string;\n\n private _cOptionElements: Record<string, HTMLCOptionElement> = {};\n\n private _selectionElement: HTMLDivElement;\n\n private _cInput: HTMLCInputElement;\n\n private _outerWrapperClasses = ['outer-wrapper'];\n\n private static _uniqueId = 0;\n\n private _validationClasses = ['validation-message'];\n\n private _debounce = null;\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n @Watch('value')\n onValueChange() {\n if (!this.value) return;\n\n const realValue = !(this.value as CSelectItem)?.value\n ? this._items.find((item) => item.value === this.value)\n : this.value;\n\n this._valueChangedHandler(realValue as CSelectItem);\n }\n\n @Watch('validate')\n validateChange(newValue: boolean) {\n if (newValue) {\n this._runValidate();\n }\n }\n\n @Watch('currentIndex')\n onCurrentIndexChange(index: number) {\n this.activeListItemId = this._itemRefs[index]?.ref?.id ?? null;\n\n this._scrollToElement();\n\n this._updateStatusText();\n }\n\n private get _items() {\n return this.hasOptionItems ? this._optionItems : this.items;\n }\n\n private _setValue(item: CSelectItem) {\n return this.returnValue\n ? item?.value\n : {\n name: item?.name,\n value: item?.value,\n };\n }\n\n private _valueChangedHandler(item: CSelectItem) {\n if (!item) return;\n\n if (this.hasOptionItems && this.optionAsSelection) {\n const selection = this._cOptionElements[item.value.toString()];\n\n if (!selection) return;\n\n const clone = selection.cloneNode(true);\n\n this._selectionElement.classList.add('c-input-menu__selection--show');\n this._selectionElement.replaceChildren(clone);\n }\n\n this.currentIndex = this._items.findIndex(\n (element) => element.value === item?.value,\n );\n\n const value = this._setValue(item);\n\n if (this.previousValue && this.previousValue?.value === item?.value) return;\n\n this.previousValue = item;\n\n this.changeValue.emit(value);\n\n this.internals.setFormValue(item.value as string);\n }\n\n private _getLabel() {\n if (!this.value) return '';\n\n if (\n this.returnValue &&\n ['number', 'string', 'boolean'].includes(typeof this.value)\n ) {\n return this._items?.find((item) => item.value === this.value)?.name;\n }\n\n return this._items?.find(\n (item) => item.value === (this.value as CSelectItem).value,\n )?.name;\n }\n\n private _scrollToElement() {\n if (this._items.length > this.itemsPerPage) {\n const itemRef = this._itemRefs.find(\n (item) => item.value === this._items[this.currentIndex]?.value,\n )?.ref;\n\n if (!!itemRef) {\n this._observer.observe(itemRef);\n }\n }\n }\n\n @Listen('keydown', { capture: true })\n handleKeyDown(ev: KeyboardEvent) {\n if (this.disabled) return;\n\n const letterNumber = /^[0-9a-zA-Z]+$/;\n\n if (ev.key.match(letterNumber) && ev.key.length === 1) {\n if (\n Date.now() - this._lastKeyPressTime > 3000 ||\n this._searchString.length > 2\n ) {\n this._searchString = ev.key;\n } else {\n this._searchString = `${this._searchString}${ev.key}`;\n }\n\n this._lastKeyPressTime = Date.now();\n\n const selectedItem = this._items.find((i) =>\n i.name.toLowerCase().startsWith(this._searchString),\n );\n\n function isItem(element) {\n return element === selectedItem;\n }\n\n if (selectedItem) {\n if (this.menuVisible) {\n this.currentIndex = this._items.findIndex(isItem);\n this._scrollToElement();\n } else {\n this.value = selectedItem;\n }\n }\n }\n\n if (ev.key === 'Tab') {\n this._cInput.closeDropdown();\n }\n\n if (ev.key === 'ArrowDown') {\n ev.preventDefault();\n\n this._showMenu();\n }\n\n if (ev.key === 'ArrowUp') {\n ev.preventDefault();\n\n this._showMenu();\n }\n\n if (ev.key === ' ') {\n ev.preventDefault();\n\n this._showMenu();\n }\n }\n\n /**\n * Select item by index\n */\n @Method()\n async onItemSelection(index: number) {\n this.currentIndex = index;\n\n this._selectItem();\n }\n\n /**\n * Hide menu\n * @private\n */\n @Method()\n async onHideMenu() {\n this.menuVisible = false;\n }\n\n componentWillLoad() {\n CSelect._uniqueId += 1;\n\n this._id =\n this.hostId?.replace(/[^a-zA-Z0-9-_]/g, '') ??\n CSelect._uniqueId.toString();\n\n this._inputId =\n 'input-' +\n (this.hostId || this.label || this.placeholder)\n .replace(/[^a-zA-Z0-9-_]/g, '')\n .toLowerCase();\n\n this._setInitialValue();\n }\n\n private _setInitialValue() {\n if (!this.value) return;\n\n const value = this.returnValue\n ? this.value\n : (this.value as CSelectItem).value;\n\n this.internals.setFormValue(value as string);\n }\n\n componentDidLoad() {\n this._getOptionItems();\n\n if (\n (this.value || typeof this.value === 'boolean') &&\n !this.currentIndex &&\n this.currentIndex !== 0\n ) {\n this.currentIndex = this._items.findIndex(\n (item) => item.value === this.value,\n );\n }\n\n requestAnimationFrame(() => {\n this._cInput.createDropdown({\n type: 'select',\n items: this._items,\n options: this._cOptionElements,\n parent: this.host,\n itemsPerPage: this.itemsPerPage,\n index: this.currentIndex,\n click: false,\n id: this._inputId,\n });\n });\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n private _inputId: string;\n\n private _lastKeyPressTime = null;\n\n private _searchString = '';\n\n private _blurred = false;\n\n private _optionItems: CSelectItem[] = [];\n\n private _inputElement: HTMLInputElement;\n\n private _selectItem() {\n const selectedItem = this._items[this.currentIndex];\n\n this.value = selectedItem;\n\n this._scrollToElement();\n }\n\n /**\n * @private\n */\n @Method()\n async setActiveDescendant(id: string) {\n this._inputElement.setAttribute('aria-activedescendant', id);\n }\n\n private _showMenu() {\n if (this.disabled) return;\n\n this.menuVisible = true;\n this._cInput.openDropdown();\n }\n\n private _getOptionItems() {\n requestAnimationFrame(() => {\n this._cOptionElements = {};\n\n let selection: CSelectItem | null = null;\n\n this._optionItems = (\n this.host ? Array.from(this.host.querySelectorAll('c-option')) : []\n ).map((item, index) => {\n const cSelectItem = {\n value: item.value,\n name: item.name || item.innerText,\n disabled: !!item.disabled,\n } as CSelectItem;\n\n if (item.selected) {\n selection = cSelectItem;\n }\n\n item.slot = `option-${index}`;\n\n this._cOptionElements[item.value.toString()] = item;\n\n return cSelectItem;\n });\n\n this.hasOptionItems = !!this._optionItems.length;\n\n if (selection) {\n this._valueChangedHandler(selection);\n }\n });\n }\n\n private _runValidate() {\n if (\n this.required &&\n !this.value &&\n (this._blurred || !this.validateOnBlur)\n ) {\n this._outerWrapperClasses.push('required');\n this._validationClasses.push('show');\n } else {\n this._outerWrapperClasses = this._outerWrapperClasses.filter(\n (c) => c !== 'required',\n );\n this._validationClasses = this._validationClasses.filter(\n (c) => c !== 'show',\n );\n }\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.menuVisible,\n };\n\n return (\n <svg class={classes} viewBox=\"0 0 24 24\">\n <path d={mdiChevronDown} />\n </svg>\n );\n }\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n aria-controls={this._inputId + '-items'}\n aria-expanded={this.menuVisible.toString()}\n aria-readonly=\"true\"\n aria-haspopup=\"listbox\"\n ref={(el) => (this._inputElement = el)}\n id={this._inputId}\n autocomplete=\"off\"\n class=\"c-input__input\"\n type=\"text\"\n value={this._getLabel() ?? null}\n name={this.name ?? null}\n readonly=\"true\"\n />\n\n <div\n ref={(el) => (this._selectionElement = el)}\n class=\"c-input-menu__selection\"\n />\n </div>\n );\n }\n\n private _handleSlotChange = () => {\n this._getOptionItems();\n };\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n const selection = this.host.shadowRoot.querySelector(\n 'li[aria-selected=\"true\"]',\n ) as HTMLLIElement;\n\n const ending = !!this._items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n const selectionText = !!selection\n ? `${beginning}${selection.dataset.value} - ${selection.ariaPosInSet} of ${selection.ariaSetSize} is highlighted`\n : null;\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n return (\n <Host title={this._getLabel() ?? null}>\n <div\n id={'announce-' + this._id}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <c-input\n ref={(el) => (this._cInput = el)}\n autofocus={this.autofocus}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\n itemns-per-page={this.itemsPerPage}\n label={this.label}\n name={this.name}\n placeholder={this.placeholder}\n required={this.required}\n shadow={this.shadow}\n valid={this.valid}\n validate={this.validate}\n validate-on-blur={this.validateOnBlur}\n validation={this.validation}\n value={this.value}\n variant=\"select\"\n onItemClick={() => this._showMenu()}\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n {this._renderChevron()}\n\n <slot onSlotchange={this._handleSlotChange}></slot>\n </div>\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </Host>\n );\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"c-select.js","sourceRoot":"","sources":["../../../../src/components/c-select/c-select.tsx"],"names":[],"mappings":"AAAA,OAAO,EACL,eAAe,EACf,SAAS,EACT,OAAO,EACP,IAAI,EACJ,IAAI,EACJ,KAAK,EACL,CAAC,EACD,MAAM,EACN,KAAK,EAEL,KAAK,EACL,MAAM,GACP,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,cAAc,EAAE,MAAM,SAAS,CAAC;AAazC,MAAM,OAAO,OAAO;;IAuHV,cAAS,GACf,EAAE,CAAC;IAIG,qBAAgB,GAAuC,EAAE,CAAC;IAI1D,yBAAoB,GAAG,CAAC,eAAe,CAAC,CAAC;IAIzC,uBAAkB,GAAG,CAAC,oBAAoB,CAAC,CAAC;IAE5C,cAAS,GAAG,IAAI,CAAC;IAEjB,cAAS,GAAG,IAAI,oBAAoB,CAC1C,CAAC,OAAO,EAAE,QAAQ,EAAE,EAAE;MACpB,OAAO,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,EAAE;QACxB,IAAI,CAAC,KAAK,CAAC,cAAc,EAAE;UACzB,KAAK,CAAC,MAAM,CAAC,cAAc,CAAC;YAC1B,KAAK,EAAE,SAAS;YAChB,MAAM,EAAE,SAAS;WAClB,CAAC,CAAC;UACH,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,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C,iBAAiB,GAAS,CAC/C;QAEN,kBACE,GAAG,EAAE,CAAC,EAAE,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,gBAAgB,GAAG,EAAE,CAAC,EACzC,IAAI,EAAC,UAAU,EACf,KAAK,EAAE,IAAI,CAAC,MAAM,EAClB,OAAO,EAAE,IAAI,CAAC,gBAAgB,oBACd,IAAI,CAAC,YAAY,EACjC,MAAM,EAAE,IAAI,CAAC,EAAE,EACf,KAAK,EAAE,IAAI,CAAC,YAAY,cACd,IAAI,CAAC,QAAQ,EACvB,IAAI,EAAC,QAAQ,GACb;QAEF,YAAM,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAQ,CAC7B,CACL,CACR,CAAC;EACJ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAtdc,iBAAS,GAAG,CAAC,AAAJ,CAAK","sourcesContent":["import {\n AttachInternals,\n Component,\n Element,\n Host,\n Prop,\n State,\n h,\n Listen,\n Event,\n EventEmitter,\n Watch,\n Method,\n} from '@stencil/core';\nimport { mdiChevronDown } from '@mdi/js';\nimport { CSelectItem } from '../../types';\n\n/**\n * @group Form\n * @slot Default slot - Use c-option elements only\n */\n@Component({\n tag: 'c-select',\n styleUrl: 'c-select.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CSelect {\n @Element() el: HTMLCSelectElement;\n\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n /**\n * Auto focus the input\n */\n @Prop() autofocus = false;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Hide the hint and error messages\n */\n @Prop() hideDetails = false;\n\n /**\n * Hint text for the input\n */\n @Prop() hint = '';\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Set as required\n */\n @Prop() required = false;\n\n /**\n * Return only the item value rather than the whole item object\n */\n @Prop() returnValue: false;\n\n /**\n * Set the validity of the input\n */\n @Prop() valid = true;\n\n /**\n * Manual validation\n */\n @Prop() validate = false;\n\n /**\n * Validate the input on blur\n */\n @Prop() validateOnBlur = false;\n\n /**\n * Custom validation message\n */\n @Prop() validation = 'Required field';\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\n\n /**\n * Selected item\n */\n @Prop({ mutable: true }) value: string | number | boolean | CSelectItem =\n null;\n\n /**\n * selectable items\n */\n @Prop() items: CSelectItem[] = [];\n\n /**\n * display the option as selection (works only when c-option elements are used)\n */\n @Prop() optionAsSelection: false;\n\n /**\n * Triggered when an item is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n @State() menuVisible = false;\n\n @State() currentIndex: number = null;\n\n @State() activeListItemId: string = null;\n\n @State() statusText = '';\n\n @State() hasOptionItems = false;\n\n @State() previousValue: CSelectItem = { value: '', name: '' };\n\n private _itemRefs: { value: string | number | boolean; ref: HTMLElement }[] =\n [];\n\n private _id: string;\n\n private _cOptionElements: Record<string, HTMLCOptionElement> = {};\n\n private _selectionElement: HTMLDivElement;\n\n private _outerWrapperClasses = ['outer-wrapper'];\n\n private static _uniqueId = 0;\n\n private _validationClasses = ['validation-message'];\n\n private _debounce = null;\n\n private _observer = new IntersectionObserver(\n (entries, observer) => {\n entries.forEach((entry) => {\n if (!entry.isIntersecting) {\n entry.target.scrollIntoView({\n block: 'nearest',\n inline: 'nearest',\n });\n observer.unobserve(entry.target);\n } else {\n observer.unobserve(entry.target);\n }\n });\n },\n { threshold: 1 },\n );\n\n @Watch('value')\n onValueChange() {\n if (!this.value) return;\n\n const realValue = !(this.value as CSelectItem)?.value\n ? this._items.find((item) => item.value === this.value)\n : this.value;\n\n this._valueChangedHandler(realValue as CSelectItem);\n }\n\n @Watch('validate')\n validateChange(newValue: boolean) {\n if (newValue) {\n this._runValidate();\n }\n }\n\n @Watch('currentIndex')\n onCurrentIndexChange(index: number) {\n this.activeListItemId = this._itemRefs[index]?.ref?.id ?? null;\n\n this._scrollToElement();\n\n this._updateStatusText();\n }\n\n private get _items() {\n return this.hasOptionItems ? this._optionItems : this.items;\n }\n\n private _setValue(item: CSelectItem) {\n return this.returnValue\n ? item?.value\n : {\n name: item?.name,\n value: item?.value,\n };\n }\n\n private _valueChangedHandler(item: CSelectItem) {\n if (!item) return;\n\n if (this.hasOptionItems && this.optionAsSelection) {\n const selection = this._cOptionElements[item.value.toString()];\n\n if (!selection) return;\n\n const clone = selection.cloneNode(true);\n\n this._selectionElement.classList.add('c-input-menu__selection--show');\n this._selectionElement.replaceChildren(clone);\n }\n\n this.currentIndex = this._items.findIndex(\n (element) => element.value === item?.value,\n );\n\n const value = this._setValue(item);\n\n if (this.previousValue && this.previousValue?.value === item?.value) return;\n\n this.previousValue = item;\n\n this.changeValue.emit(value);\n\n this.internals.setFormValue(item.value as string);\n }\n\n private _getLabel() {\n if (!this.value) return '';\n\n if (\n this.returnValue &&\n ['number', 'string', 'boolean'].includes(typeof this.value)\n ) {\n return this._items?.find((item) => item.value === this.value)?.name;\n }\n\n return this._items?.find(\n (item) => item.value === (this.value as CSelectItem).value,\n )?.name;\n }\n\n private _scrollToElement() {\n if (this._items.length > this.itemsPerPage) {\n const itemRef = this._itemRefs.find(\n (item) => item.value === this._items[this.currentIndex]?.value,\n )?.ref;\n\n if (!!itemRef) {\n this._observer.observe(itemRef);\n }\n }\n }\n\n @Listen('keydown', { capture: true })\n handleKeyDown(ev: KeyboardEvent) {\n if (this.disabled) return;\n\n const letterNumber = /^[0-9a-zA-Z]+$/;\n\n if (ev.key.match(letterNumber) && ev.key.length === 1) {\n if (\n Date.now() - this._lastKeyPressTime > 3000 ||\n this._searchString.length > 2\n ) {\n this._searchString = ev.key;\n } else {\n this._searchString = `${this._searchString}${ev.key}`;\n }\n\n this._lastKeyPressTime = Date.now();\n\n const selectedItem = this._items.find((i) =>\n i.name.toLowerCase().startsWith(this._searchString),\n );\n\n function isItem(element) {\n return element === selectedItem;\n }\n\n if (selectedItem) {\n if (this.menuVisible) {\n this.currentIndex = this._items.findIndex(isItem);\n this._scrollToElement();\n } else {\n this.value = selectedItem;\n }\n }\n }\n\n if (ev.key === 'Tab') {\n this._dropdownElement.close();\n }\n\n if (ev.key === 'ArrowDown') {\n ev.preventDefault();\n\n if (this._dropdownElement.isOpen) return;\n\n this._showMenu();\n\n this._dropdownElement.focusItem(this.currentIndex);\n }\n\n if (ev.key === 'ArrowUp') {\n ev.preventDefault();\n\n if (this._dropdownElement.isOpen) return;\n\n this._showMenu();\n\n this._dropdownElement.focusItem(this.currentIndex);\n }\n\n if (ev.key === ' ') {\n ev.preventDefault();\n\n this._showMenu();\n }\n }\n\n /**\n * Select item by index\n */\n @Method()\n async onItemSelection(index: number) {\n this.currentIndex = index;\n\n this._selectItem();\n }\n\n /**\n * Hide menu\n * @private\n */\n @Method()\n async onHideMenu() {\n this.menuVisible = false;\n }\n\n componentWillLoad() {\n CSelect._uniqueId += 1;\n\n this._id =\n this.hostId?.replace(/[^a-zA-Z0-9-_]/g, '') ??\n CSelect._uniqueId.toString();\n\n this._inputId =\n 'input-' +\n (this.hostId || this.label || this.placeholder)\n .replace(/[^a-zA-Z0-9-_]/g, '')\n .toLowerCase();\n\n this._setInitialValue();\n }\n\n private _setInitialValue() {\n if (!this.value) return;\n\n const value = this.returnValue\n ? this.value\n : (this.value as CSelectItem).value;\n\n this.internals.setFormValue(value as string);\n }\n\n componentDidLoad() {\n this._getOptionItems();\n\n if (\n (this.value || typeof this.value === 'boolean') &&\n !this.currentIndex &&\n this.currentIndex !== 0\n ) {\n this.currentIndex = this._items.findIndex(\n (item) => item.value === this.value,\n );\n }\n }\n\n disconnectedCallback() {\n this._observer.disconnect();\n }\n\n private _inputId: string;\n\n private _lastKeyPressTime = null;\n\n private _searchString = '';\n\n private _blurred = false;\n\n private _optionItems: CSelectItem[] = [];\n\n private _inputElement: HTMLInputElement;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n private _selectItem() {\n const selectedItem = this._items[this.currentIndex];\n\n this.value = selectedItem;\n\n this._scrollToElement();\n }\n\n /**\n * @private\n */\n @Method()\n async setActiveDescendant(id: string) {\n this._inputElement.setAttribute('aria-activedescendant', id);\n }\n\n private _showMenu() {\n if (this.disabled) return;\n\n this.menuVisible = true;\n\n this._dropdownElement.open();\n }\n\n private _getOptionItems() {\n requestAnimationFrame(() => {\n this._cOptionElements = {};\n\n let selection: CSelectItem | null = null;\n\n this._optionItems = (\n this.el ? Array.from(this.el.querySelectorAll('c-option')) : []\n ).map((item, index) => {\n const cSelectItem = {\n value: item.value,\n name: item.name || item.innerText,\n disabled: !!item.disabled,\n } as CSelectItem;\n\n if (item.selected) {\n selection = cSelectItem;\n }\n\n item.slot = `option-${index}`;\n\n this._cOptionElements[item.value.toString()] = item;\n\n return cSelectItem;\n });\n\n this.hasOptionItems = !!this._optionItems.length;\n\n if (selection) {\n this._valueChangedHandler(selection);\n }\n });\n }\n\n private _runValidate() {\n if (\n this.required &&\n !this.value &&\n (this._blurred || !this.validateOnBlur)\n ) {\n this._outerWrapperClasses.push('required');\n this._validationClasses.push('show');\n } else {\n this._outerWrapperClasses = this._outerWrapperClasses.filter(\n (c) => c !== 'required',\n );\n this._validationClasses = this._validationClasses.filter(\n (c) => c !== 'show',\n );\n }\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.menuVisible,\n };\n\n return (\n <svg class={classes} viewBox=\"0 0 24 24\">\n <path d={mdiChevronDown} />\n </svg>\n );\n }\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n aria-controls={this._inputId + '-items'}\n aria-expanded={this.menuVisible.toString()}\n aria-readonly=\"true\"\n aria-haspopup=\"listbox\"\n ref={(el) => (this._inputElement = el)}\n id={this._inputId}\n autocomplete=\"off\"\n class=\"c-input__input\"\n type=\"text\"\n value={this._getLabel() ?? null}\n name={this.name ?? null}\n readonly=\"true\"\n />\n\n <div\n ref={(el) => (this._selectionElement = el)}\n class=\"c-input-menu__selection\"\n />\n </div>\n );\n }\n\n private _handleSlotChange = () => {\n this._getOptionItems();\n };\n\n private _updateStatusText() {\n if (this._debounce !== null) {\n clearTimeout(this._debounce);\n this._debounce = null;\n }\n\n this._debounce = window.setTimeout(() => {\n const selection = this.el.shadowRoot.querySelector(\n 'li[aria-selected=\"true\"]',\n ) as HTMLLIElement;\n\n const ending = !!this._items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n const selectionText = !!selection\n ? `${beginning}${selection.dataset.value} - ${selection.ariaPosInSet} of ${selection.ariaSetSize} is highlighted`\n : null;\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n return (\n <Host title={this._getLabel() ?? null}>\n <div\n id={'announce-' + this._id}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <c-input\n autofocus={this.autofocus}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\n items={this._items}\n items-per-page={this.itemsPerPage}\n label={this.label}\n name={this.name}\n placeholder={this.placeholder}\n required={this.required}\n shadow={this.shadow}\n valid={this.valid}\n validate={this.validate}\n validate-on-blur={this.validateOnBlur}\n validation={this.validation}\n value={this.value}\n variant=\"select\"\n onItemClick={() => this._showMenu()}\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n {this._renderChevron()}\n\n <slot onSlotchange={this._handleSlotChange}></slot>\n </div>\n\n <c-dropdown\n ref={(el) => (this._dropdownElement = el)}\n slot=\"dropdown\"\n items={this._items}\n options={this._cOptionElements}\n items-per-page={this.itemsPerPage}\n parent={this.el}\n index={this.currentIndex}\n input-id={this._inputId}\n type=\"select\"\n />\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </Host>\n );\n }\n}\n"]}
|