@cscfi/csc-ui 1.2.1 → 1.2.3
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-badge_12.cjs.entry.js → c-autocomplete_16.cjs.entry.js} +1172 -52
- package/dist/cjs/c-autocomplete_16.cjs.entry.js.map +1 -0
- package/dist/cjs/{c-checkbox_2.cjs.entry.js → c-checkbox_3.cjs.entry.js} +14 -1
- package/dist/cjs/c-checkbox_3.cjs.entry.js.map +1 -0
- package/dist/cjs/c-csc-logo.cjs.entry.js +23 -0
- package/dist/cjs/c-csc-logo.cjs.entry.js.map +1 -0
- package/dist/cjs/c-main.cjs.entry.js +21 -0
- package/dist/cjs/c-main.cjs.entry.js.map +1 -0
- package/dist/cjs/c-menu_2.cjs.entry.js +2 -23
- package/dist/cjs/c-menu_2.cjs.entry.js.map +1 -1
- package/dist/cjs/c-row.cjs.entry.js +35 -0
- package/dist/cjs/c-row.cjs.entry.js.map +1 -0
- package/dist/cjs/c-toolbar.cjs.entry.js +21 -0
- package/dist/cjs/c-toolbar.cjs.entry.js.map +1 -0
- package/dist/cjs/csc-ui.cjs.js +1 -1
- package/dist/cjs/getScrollParent-5d488045.js +28 -0
- package/dist/cjs/getScrollParent-5d488045.js.map +1 -0
- package/dist/cjs/index-91ba22ab.js +14 -30
- package/dist/cjs/loader.cjs.js +1 -1
- package/dist/collection/components/c-autocomplete/c-autocomplete.js +31 -14
- package/dist/collection/components/c-autocomplete/c-autocomplete.js.map +1 -1
- package/dist/collection/components/c-dropdown/c-dropdown.css +6 -1
- package/dist/collection/components/c-dropdown/c-dropdown.js +18 -20
- package/dist/collection/components/c-dropdown/c-dropdown.js.map +1 -1
- package/dist/collection/components/c-menu-items/c-menu-items.js +2 -23
- package/dist/collection/components/c-menu-items/c-menu-items.js.map +1 -1
- package/dist/collection/components/c-select/c-select.js +58 -23
- package/dist/collection/components/c-select/c-select.js.map +1 -1
- package/dist/collection/utils/getScrollParent.js +23 -0
- package/dist/collection/utils/getScrollParent.js.map +1 -0
- package/dist/collection/utils/index.js +2 -0
- package/dist/collection/utils/index.js.map +1 -0
- package/dist/components/c-autocomplete.js +33 -10
- package/dist/components/c-autocomplete.js.map +1 -1
- package/dist/components/c-dropdown2.js +19 -21
- package/dist/components/c-dropdown2.js.map +1 -1
- package/dist/components/c-menu-items2.js +2 -23
- package/dist/components/c-menu-items2.js.map +1 -1
- package/dist/components/c-select.js +59 -24
- package/dist/components/c-select.js.map +1 -1
- package/dist/components/getScrollParent.js +26 -0
- package/dist/components/getScrollParent.js.map +1 -0
- 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-040ed3e2.entry.js +2 -0
- package/dist/csc-ui/p-040ed3e2.entry.js.map +1 -0
- package/dist/csc-ui/{p-bf01d3ef.entry.js → p-1d6c84df.entry.js} +2 -2
- package/dist/csc-ui/p-39df362b.entry.js +2 -0
- package/dist/csc-ui/p-39df362b.entry.js.map +1 -0
- package/dist/csc-ui/{p-27904068.entry.js → p-3bb67f38.entry.js} +2 -2
- package/dist/csc-ui/p-3f0e51ff.js +2 -0
- package/dist/csc-ui/p-3f0e51ff.js.map +1 -0
- package/dist/csc-ui/{p-0569fc3e.entry.js → p-468d9583.entry.js} +2 -2
- package/dist/csc-ui/{p-16098e94.entry.js → p-56b1e1ea.entry.js} +2 -2
- package/dist/csc-ui/p-6062aaff.entry.js +2 -0
- package/dist/csc-ui/p-6062aaff.entry.js.map +1 -0
- package/dist/csc-ui/p-682782b1.entry.js +2 -0
- package/dist/csc-ui/p-682782b1.entry.js.map +1 -0
- package/dist/csc-ui/{p-958cf6ed.entry.js → p-6e046723.entry.js} +2 -2
- package/dist/csc-ui/p-9c5488fc.entry.js +2 -0
- package/dist/csc-ui/p-9c5488fc.entry.js.map +1 -0
- package/dist/csc-ui/{p-862486aa.entry.js → p-9c80f35e.entry.js} +2 -2
- package/dist/csc-ui/{p-873aa915.entry.js → p-ab62f9b5.entry.js} +2 -2
- package/dist/csc-ui/{p-45641e3d.entry.js → p-ae16b1f4.entry.js} +2 -2
- package/dist/csc-ui/{p-7af82ab9.entry.js → p-b0fa27b6.entry.js} +2 -2
- package/dist/csc-ui/{p-2a622e79.entry.js → p-b83651f8.entry.js} +2 -2
- package/dist/csc-ui/p-b83651f8.entry.js.map +1 -0
- package/dist/csc-ui/{p-64bcde03.entry.js → p-bda722d5.entry.js} +2 -2
- package/dist/csc-ui/{p-47ca0a95.entry.js → p-c8a7a751.entry.js} +2 -2
- package/dist/csc-ui/{p-c291cbe2.entry.js → p-ccef8a49.entry.js} +2 -2
- package/dist/csc-ui/{p-5461ca29.js → p-f24b9d97.js} +2 -2
- package/dist/csc-ui/p-fa83a615.entry.js +2 -0
- package/dist/csc-ui/p-fa83a615.entry.js.map +1 -0
- package/dist/esm/c-accordion-item.entry.js +1 -1
- package/dist/esm/c-alert.entry.js +1 -1
- package/dist/esm/{c-badge_12.entry.js → c-autocomplete_16.entry.js} +1166 -50
- package/dist/esm/c-autocomplete_16.entry.js.map +1 -0
- package/dist/esm/{c-checkbox_2.entry.js → c-checkbox_3.entry.js} +15 -3
- package/dist/esm/c-checkbox_3.entry.js.map +1 -0
- package/dist/esm/c-csc-logo.entry.js +19 -0
- package/dist/esm/c-csc-logo.entry.js.map +1 -0
- package/dist/esm/c-data-table.entry.js +1 -1
- package/dist/esm/c-main.entry.js +17 -0
- package/dist/esm/c-main.entry.js.map +1 -0
- package/dist/esm/c-menu_2.entry.js +3 -24
- package/dist/esm/c-menu_2.entry.js.map +1 -1
- package/dist/esm/c-navigation-button.entry.js +1 -1
- package/dist/esm/c-radio-group.entry.js +1 -1
- package/dist/esm/c-row.entry.js +31 -0
- package/dist/esm/c-row.entry.js.map +1 -0
- package/dist/esm/c-side-navigation-item.entry.js +1 -1
- package/dist/esm/c-side-navigation.entry.js +1 -1
- package/dist/esm/c-swiper.entry.js +1 -1
- package/dist/esm/c-tabs.entry.js +1 -1
- package/dist/esm/c-tag.entry.js +1 -1
- package/dist/esm/c-text-field.entry.js +1 -1
- package/dist/esm/c-toast.entry.js +1 -1
- package/dist/esm/c-toolbar.entry.js +17 -0
- package/dist/esm/c-toolbar.entry.js.map +1 -0
- package/dist/esm/csc-ui.js +1 -1
- package/dist/esm/getScrollParent-f876ad1b.js +26 -0
- package/dist/esm/getScrollParent-f876ad1b.js.map +1 -0
- package/dist/esm/index-47956d53.js +14 -30
- package/dist/esm/loader.js +1 -1
- package/dist/esm/{mdi-e92c0e44.js → mdi-8656e74a.js} +2 -2
- package/dist/esm/{mdi-e92c0e44.js.map → mdi-8656e74a.js.map} +1 -1
- package/dist/types/components/c-autocomplete/c-autocomplete.d.ts +2 -1
- package/dist/types/components/c-dropdown/c-dropdown.d.ts +2 -1
- package/dist/types/components/c-menu-items/c-menu-items.d.ts +0 -1
- package/dist/types/components/c-select/c-select.d.ts +3 -0
- package/dist/types/utils/getScrollParent.d.ts +1 -0
- package/dist/types/utils/index.d.ts +1 -0
- package/package.json +1 -1
- package/dist/cjs/c-autocomplete.cjs.entry.js +0 -251
- package/dist/cjs/c-autocomplete.cjs.entry.js.map +0 -1
- package/dist/cjs/c-badge_12.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-actions.cjs.entry.js +0 -28
- package/dist/cjs/c-card-actions.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-content.cjs.entry.js +0 -21
- package/dist/cjs/c-card-content.cjs.entry.js.map +0 -1
- package/dist/cjs/c-card-title.cjs.entry.js +0 -21
- package/dist/cjs/c-card-title.cjs.entry.js.map +0 -1
- package/dist/cjs/c-checkbox_2.cjs.entry.js.map +0 -1
- package/dist/cjs/c-dropdown_2.cjs.entry.js +0 -512
- package/dist/cjs/c-dropdown_2.cjs.entry.js.map +0 -1
- package/dist/cjs/c-message.cjs.entry.js +0 -67
- package/dist/cjs/c-message.cjs.entry.js.map +0 -1
- package/dist/cjs/c-option.cjs.entry.js +0 -25
- package/dist/cjs/c-option.cjs.entry.js.map +0 -1
- package/dist/cjs/c-select.cjs.entry.js +0 -276
- package/dist/cjs/c-select.cjs.entry.js.map +0 -1
- package/dist/csc-ui/p-019c6898.entry.js +0 -2
- package/dist/csc-ui/p-019c6898.entry.js.map +0 -1
- package/dist/csc-ui/p-0666f12d.entry.js +0 -2
- package/dist/csc-ui/p-0666f12d.entry.js.map +0 -1
- package/dist/csc-ui/p-2a622e79.entry.js.map +0 -1
- package/dist/csc-ui/p-4e1d8f5d.entry.js +0 -2
- package/dist/csc-ui/p-4e1d8f5d.entry.js.map +0 -1
- package/dist/csc-ui/p-6c5e538b.entry.js +0 -2
- package/dist/csc-ui/p-6c5e538b.entry.js.map +0 -1
- package/dist/csc-ui/p-bbe8423c.entry.js +0 -2
- package/dist/csc-ui/p-bbe8423c.entry.js.map +0 -1
- package/dist/csc-ui/p-bddd9153.entry.js +0 -2
- package/dist/csc-ui/p-bddd9153.entry.js.map +0 -1
- package/dist/csc-ui/p-d1089126.entry.js +0 -2
- package/dist/csc-ui/p-d1089126.entry.js.map +0 -1
- package/dist/csc-ui/p-d2fc8cb4.entry.js +0 -2
- package/dist/csc-ui/p-d2fc8cb4.entry.js.map +0 -1
- package/dist/csc-ui/p-ec167606.entry.js +0 -2
- package/dist/csc-ui/p-ec167606.entry.js.map +0 -1
- package/dist/csc-ui/p-f148aad1.entry.js +0 -2
- package/dist/csc-ui/p-f148aad1.entry.js.map +0 -1
- package/dist/esm/c-autocomplete.entry.js +0 -247
- package/dist/esm/c-autocomplete.entry.js.map +0 -1
- package/dist/esm/c-badge_12.entry.js.map +0 -1
- package/dist/esm/c-card-actions.entry.js +0 -24
- package/dist/esm/c-card-actions.entry.js.map +0 -1
- package/dist/esm/c-card-content.entry.js +0 -17
- package/dist/esm/c-card-content.entry.js.map +0 -1
- package/dist/esm/c-card-title.entry.js +0 -17
- package/dist/esm/c-card-title.entry.js.map +0 -1
- package/dist/esm/c-checkbox_2.entry.js.map +0 -1
- package/dist/esm/c-dropdown_2.entry.js +0 -507
- package/dist/esm/c-dropdown_2.entry.js.map +0 -1
- package/dist/esm/c-message.entry.js +0 -63
- package/dist/esm/c-message.entry.js.map +0 -1
- package/dist/esm/c-option.entry.js +0 -21
- package/dist/esm/c-option.entry.js.map +0 -1
- package/dist/esm/c-select.entry.js +0 -272
- package/dist/esm/c-select.entry.js.map +0 -1
- /package/dist/csc-ui/{p-bf01d3ef.entry.js.map → p-1d6c84df.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-27904068.entry.js.map → p-3bb67f38.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-0569fc3e.entry.js.map → p-468d9583.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-16098e94.entry.js.map → p-56b1e1ea.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-958cf6ed.entry.js.map → p-6e046723.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-862486aa.entry.js.map → p-9c80f35e.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-873aa915.entry.js.map → p-ab62f9b5.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-45641e3d.entry.js.map → p-ae16b1f4.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-7af82ab9.entry.js.map → p-b0fa27b6.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-64bcde03.entry.js.map → p-bda722d5.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-47ca0a95.entry.js.map → p-c8a7a751.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-c291cbe2.entry.js.map → p-ccef8a49.entry.js.map} +0 -0
- /package/dist/csc-ui/{p-5461ca29.js.map → p-f24b9d97.js.map} +0 -0
|
@@ -18,10 +18,20 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
18
18
|
this.__attachShadow();
|
|
19
19
|
this.changeQuery = createEvent(this, "changeQuery", 7);
|
|
20
20
|
this.changeValue = createEvent(this, "changeValue", 3);
|
|
21
|
+
this.internals = this.attachInternals();
|
|
21
22
|
this._preventDialogOpen = false;
|
|
22
23
|
this._debounce = null;
|
|
23
24
|
this._handleSlotChange = () => {
|
|
24
25
|
this.optionElements = this.el.querySelectorAll('c-option');
|
|
26
|
+
const selection = Array.from(this.optionElements).find((option) => option.selected);
|
|
27
|
+
if (selection) {
|
|
28
|
+
this.value = this.returnObject
|
|
29
|
+
? { name: selection.name, value: selection.value }
|
|
30
|
+
: selection.value;
|
|
31
|
+
this.changeValue.emit(this.value);
|
|
32
|
+
this.changeQuery.emit(this.query);
|
|
33
|
+
this.internals.setFormValue(selection.value.toString());
|
|
34
|
+
}
|
|
25
35
|
if (this.optionElements.length && !this.optionElementsExist) {
|
|
26
36
|
this.optionElementsExist = true;
|
|
27
37
|
}
|
|
@@ -51,7 +61,9 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
51
61
|
this._reset = (event) => {
|
|
52
62
|
event.stopPropagation();
|
|
53
63
|
this.query = '';
|
|
64
|
+
this.value = null;
|
|
54
65
|
this.changeValue.emit(null);
|
|
66
|
+
this.internals.setFormValue(null);
|
|
55
67
|
this.changeQuery.emit('');
|
|
56
68
|
this._preventDialogOpen = true;
|
|
57
69
|
this._cInputElement.reset();
|
|
@@ -96,10 +108,11 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
96
108
|
async reset() {
|
|
97
109
|
this.query = '';
|
|
98
110
|
this.changeValue.emit(null);
|
|
111
|
+
this.internals.setFormValue(null);
|
|
99
112
|
this.changeQuery.emit('');
|
|
100
113
|
this._dropdownElement.updateList();
|
|
101
114
|
}
|
|
102
|
-
|
|
115
|
+
_handleKeyDown(event) {
|
|
103
116
|
const alphanumeric = /^[0-9a-zA-Z ]+$/;
|
|
104
117
|
if (event.key.match(alphanumeric) && event.key.length === 1) {
|
|
105
118
|
if (!this.dropdownVisible) {
|
|
@@ -178,18 +191,27 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
178
191
|
}
|
|
179
192
|
onSelectOption(event) {
|
|
180
193
|
this._dropdownElement.close();
|
|
181
|
-
|
|
182
|
-
this.
|
|
183
|
-
this.
|
|
194
|
+
const { name, value } = event.detail;
|
|
195
|
+
this.value = this.returnObject ? event.detail : value;
|
|
196
|
+
this.changeValue.emit(this.value);
|
|
197
|
+
this.internals.setFormValue(value);
|
|
198
|
+
this.query = name;
|
|
199
|
+
this.changeQuery.emit(name);
|
|
184
200
|
this._preventDialogOpen = true;
|
|
201
|
+
if (this.optionElementsExist) {
|
|
202
|
+
Array.from(this.optionElements).forEach((item) => {
|
|
203
|
+
item.selected = item.value === value && item.name === name;
|
|
204
|
+
});
|
|
205
|
+
this._dropdownElement.updateList();
|
|
206
|
+
}
|
|
185
207
|
this._inputElement.focus();
|
|
186
208
|
}
|
|
187
209
|
handleQueryChange() {
|
|
188
210
|
this._updateStatusText();
|
|
189
211
|
}
|
|
190
|
-
_updateInput(
|
|
212
|
+
_updateInput() {
|
|
191
213
|
this._dropdownElement.open();
|
|
192
|
-
this.query =
|
|
214
|
+
this.query = this._inputElement.value;
|
|
193
215
|
this.changeQuery.emit(this.query);
|
|
194
216
|
this._dropdownElement.updateList();
|
|
195
217
|
}
|
|
@@ -208,7 +230,7 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
208
230
|
}
|
|
209
231
|
_renderInputElement() {
|
|
210
232
|
var _a;
|
|
211
|
-
return (h("div", { class: "c-input-menu__input" }, h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: (
|
|
233
|
+
return (h("div", { class: "c-input-menu__input" }, h("input", { type: "text", ref: (el) => (this._inputElement = el), "aria-expanded": this.dropdownVisible.toString(), "aria-owns": this._inputId + '-items', "aria-autocomplete": "list", autocomplete: "off", class: "c-input__input", role: "combobox", value: this.query, name: (_a = this.name) !== null && _a !== void 0 ? _a : null, onInput: () => this._updateInput(), onFocus: () => this._onInputFocus() })));
|
|
212
234
|
}
|
|
213
235
|
componentWillLoad() {
|
|
214
236
|
CAutocomplete._uniqueId += 1;
|
|
@@ -242,14 +264,15 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
242
264
|
}
|
|
243
265
|
render() {
|
|
244
266
|
const itemType = this.optionElementsExist ? 'option' : 'item';
|
|
245
|
-
return (h(Host, null, h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "autocomplete" }, h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, 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.query, variant: "select" }, h("slot", { name: "pre", slot: "pre" }), h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading && this.value && this._renderReset(), !this.loading && !this.value && this._renderChevron(), h("slot", { onSlotchange: () => this._handleSlotChange() })), h("slot", { name: "post", slot: "post" })))));
|
|
267
|
+
return (h(Host, null, h("c-dropdown", { ref: (el) => (this._dropdownElement = el), id: `${this._id}-dropdown`, index: this.currentIndex, "items-per-page": this.itemsPerPage, "item-type": itemType, items: this._items, parent: this.el, type: "autocomplete", onKeyDown: (event) => this._handleKeyDown(event) }, h("c-input", { slot: "default", ref: (el) => (this._cInputElement = el), active: this.dropdownVisible, disabled: this.disabled, "hide-details": this.hideDetails, hint: this.hint, id: this.hostId, "input-id": this._inputId, 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.query, variant: "select" }, h("slot", { name: "pre", slot: "pre" }), h("div", { class: "c-input__content" }, this._renderInputElement(), this.loading && this._renderLoader(), !this.loading && this.value && this._renderReset(), !this.loading && !this.value && this._renderChevron(), h("slot", { onSlotchange: () => this._handleSlotChange() })), h("slot", { name: "post", slot: "post" })))));
|
|
246
268
|
}
|
|
269
|
+
static get formAssociated() { return true; }
|
|
247
270
|
get el() { return this; }
|
|
248
271
|
static get watchers() { return {
|
|
249
272
|
"query": ["handleQueryChange"]
|
|
250
273
|
}; }
|
|
251
274
|
static get style() { return cAutocompleteCss; }
|
|
252
|
-
}, [
|
|
275
|
+
}, [65, "c-autocomplete", {
|
|
253
276
|
"items": [16],
|
|
254
277
|
"value": [8],
|
|
255
278
|
"query": [1],
|
|
@@ -275,7 +298,7 @@ const CAutocomplete$1 = proxyCustomElement(class CAutocomplete extends HTMLEleme
|
|
|
275
298
|
"statusText": [32],
|
|
276
299
|
"optionElementsExist": [32],
|
|
277
300
|
"reset": [64]
|
|
278
|
-
}, [[
|
|
301
|
+
}, [[0, "dropdownStateChange", "onDropdownStateChange"], [0, "selectOption", "onSelectOption"]], {
|
|
279
302
|
"query": ["handleQueryChange"]
|
|
280
303
|
}]);
|
|
281
304
|
CAutocomplete$1._uniqueId = 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-autocomplete.js","mappings":";;;;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,4tIAA4tI;;MCwBxuIA,eAAa;;;;;;;IAahB,uBAAkB,GAAG,KAAK,CAAC;IAE3B,cAAS,GAAG,IAAI,CAAC;IAwRjB,sBAAiB,GAAG;MAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;MAE3D,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,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,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE,EAEtD,YAAM,YAAY,EAAE,MAAM,IAAI,CAAC,iBAAiB,EAAE,GAAS,CACvD,EAEN,YAAM,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAQ,CAC7B,CACC,CACR,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA1gBcA,yBAAS,GAAG,CAAH,CAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CAutocomplete"],"sources":["src/components/c-autocomplete/c-autocomplete.scss?tag=c-autocomplete&encapsulation=shadow","src/components/c-autocomplete/c-autocomplete.tsx"],"sourcesContent":[":host(c-autocomplete) {\n /**\n * @prop --c-autocomplete-option-background-color: Autocomplete option background color\n * @prop --c-autocomplete-option-background-hover-color: Autocomplete option background hover color\n * @prop --c-autocomplete-active-color: Autocomplete active color\n * @prop --c-autocomplete-inactive-color: Autocomplete inactive color\n * @prop --c-autocomplete-background-color: Autocomplete background color\n * @prop --c-autocomplete-text-color: Autocomplete text color\n * @prop --c-autocomplete-option-text-color: Autocomplete option text color\n * @prop --c-autocomplete-placeholder-color: Autocomplete placeholder color\n */\n --_c-autocomplete-option-background-color: var(\n --c-autocomplete-option-background-color,\n var(--c-white)\n );\n --_c-autocomplete-option-background-hover-color: var(\n --c-autocomplete-option-background-hover-color,\n var(--c-primary-100)\n );\n --_c-autocomplete-active-color: var(\n --c-autocomplete-active-color,\n var(--c-primary-600)\n );\n --_c-autocomplete-inactive-color: var(\n --c-autocomplete-inactive-color,\n var(--c-tertiary-600)\n );\n --_c-autocomplete-background-color: var(\n --c-autocomplete-background-color,\n var(--c-transparent)\n );\n --_c-autocomplete-text-color: var(\n --c-autocomplete-text-color,\n var(--c-text-body)\n );\n --_c-autocomplete-option-text-color: var(\n --c-autocomplete-option-text-color,\n var(--c-text-body)\n );\n --_c-autocomplete-placeholder-color: var(\n --c-autocomplete-placeholder-color,\n var(--c-tertiary-500)\n );\n\n // c-select options\n --c-select-option-background-color: var(\n --_c-autocomplete-option-background-color\n );\n --c-select-option-background-color-hover: var(\n --_c-autocomplete-option-background-hover-color\n );\n --c-select-option-text-color: var(--_c-autocomplete-option-text-color);\n\n // c-input\n --_c-input-active-color: var(--_c-autocomplete-active-color);\n --_c-input-inactive-color: var(--_c-autocomplete-inactive-color);\n --_c-input-background-color: var(--_c-autocomplete-background-color);\n --_c-input-text-color: var(--_c-autocomplete-text-color);\n --_c-input-placeholder-color: var(--_c-autocomplete-placeholder-color);\n}\n\n@import '../c-input/c-input-menu';\n","import {\n Component,\n Host,\n h,\n Prop,\n State,\n Element,\n Event,\n EventEmitter,\n Listen,\n Watch,\n Method,\n} from '@stencil/core';\nimport { CAutocompleteItem } from '../../types';\nimport { mdiChevronDown, mdiClose } from '@mdi/js';\n\n/**\n * @group Form\n */\n@Component({\n tag: 'c-autocomplete',\n styleUrl: 'c-autocomplete.scss',\n shadow: true,\n})\nexport class CAutocomplete {\n @Element() el: HTMLCAutocompleteElement;\n\n private static _uniqueId = 0;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n private _inputElement: HTMLInputElement;\n\n private _cInputElement: HTMLCInputElement;\n\n private _inputId: string;\n\n private _preventDialogOpen = false;\n\n private _debounce = null;\n\n private get _id() {\n return this.hostId || `autocomplete_${CAutocomplete._uniqueId}`;\n }\n\n /**\n * Dropdown items\n */\n @Prop() items: CAutocompleteItem[] = [];\n\n /**\n * Selected item\n */\n @Prop() value: string | number | CAutocompleteItem = null;\n\n /**\n * Search string\n */\n @Prop() query: string = null;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\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 * Show loading state\n */\n @Prop() loading = false;\n\n /**\n * Show required validation\n */\n @Prop() required = false;\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 * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Return object instead of value\n */\n @Prop() returnObject = false;\n\n /**\n * Triggered when text is typed\n */\n @Event() changeQuery: EventEmitter;\n\n /**\n * Triggered when option is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n @State() optionElements: NodeListOf<HTMLCOptionElement>;\n\n @State() currentIndex: number = null;\n\n @State() dropdownVisible = false;\n\n @State() statusText = '';\n\n @State() optionElementsExist = false;\n\n /**\n * Reset autocomplete state\n */\n @Method()\n async reset() {\n this.query = '';\n\n this.changeValue.emit(null);\n\n this.changeQuery.emit('');\n\n this._dropdownElement.updateList();\n }\n\n @Listen('keydown', { passive: true })\n handleKeyDown(event: KeyboardEvent) {\n const alphanumeric = /^[0-9a-zA-Z ]+$/;\n\n if (event.key.match(alphanumeric) && event.key.length === 1) {\n if (!this.dropdownVisible) {\n this._dropdownElement.open();\n\n return;\n }\n\n this._inputElement.focus();\n\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n\n this._preventDialogOpen = true;\n this._dropdownElement.close();\n\n requestAnimationFrame(() => {\n this._inputElement.focus();\n });\n\n return;\n }\n\n if (event.key === 'Tab') {\n this._inputElement.focus();\n\n requestAnimationFrame(() => {\n this._dropdownElement.close();\n });\n\n return;\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (!this._items.length) return;\n\n if (!this.dropdownVisible || this.currentIndex === null) {\n this.currentIndex = 0;\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n this.currentIndex = Math.min(\n this.currentIndex + 1,\n this._items.length - 1,\n );\n\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (this.currentIndex === 0) {\n this._dropdownElement.close();\n this._inputElement.focus();\n }\n\n if (!this.dropdownVisible || this.currentIndex === null) {\n this.currentIndex = this._items.length - 1;\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n this.currentIndex = Math.max(this.currentIndex - 1, 0);\n\n this._dropdownElement.focusItem(this.currentIndex);\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (this.currentIndex === null) return;\n\n this._dropdownElement.selectItem(this.currentIndex);\n }\n\n if (event.key === 'Home' && this.dropdownVisible) {\n this.currentIndex = 0;\n }\n\n if (event.key === 'End' && this.dropdownVisible) {\n this.currentIndex = this._items.length - 1;\n }\n }\n\n @Listen('dropdownStateChange')\n onDropdownStateChange(event: CustomEvent<boolean>) {\n const isOpen = event.detail;\n\n this.dropdownVisible = isOpen;\n\n if (!isOpen) {\n requestAnimationFrame(() => {\n this.currentIndex = null;\n });\n }\n }\n\n @Listen('selectOption')\n onSelectOption(event: CustomEvent<{ name: string; value: string }>) {\n this._dropdownElement.close();\n\n this.changeValue.emit(\n this.returnObject ? event.detail : event.detail.value,\n );\n\n this.query = event.detail.name;\n\n this.changeQuery.emit(event.detail.name);\n\n this._preventDialogOpen = true;\n\n this._inputElement.focus();\n }\n\n @Watch('query')\n handleQueryChange() {\n this._updateStatusText();\n }\n\n private _updateInput(event: InputEvent) {\n this._dropdownElement.open();\n\n this.query = (event.target as HTMLInputElement).value;\n\n this.changeQuery.emit(this.query);\n\n this._dropdownElement.updateList();\n }\n\n private _handleSlotChange = () => {\n this.optionElements = this.el.querySelectorAll('c-option');\n\n if (this.optionElements.length && !this.optionElementsExist) {\n this.optionElementsExist = true;\n }\n };\n\n private _toggleDropdown = (event) => {\n event.stopPropagation();\n\n if (this.dropdownVisible) {\n this._dropdownElement.close();\n\n return;\n }\n\n this._dropdownElement.open();\n };\n\n private _onButtonKeyDown = (\n src: 'chevron' | 'reset',\n event: KeyboardEvent,\n ) => {\n event.stopPropagation();\n\n if (event.key !== 'Tab') event.preventDefault();\n\n if (['Enter', ' '].includes(event.key)) {\n if (src === 'chevron') {\n this._toggleDropdown(event);\n\n return;\n }\n\n this._reset(event);\n\n this._preventDialogOpen = true;\n\n this._inputElement.focus();\n }\n };\n\n private _renderLoader() {\n return <c-spinner color=\"var(--_c-autocomplete-active-color)\" size={20} />;\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.dropdownVisible,\n };\n\n return (\n <c-icon-button\n size=\"x-small\"\n class={classes}\n text\n onClick={(event) => this._toggleDropdown(event)}\n onKeyDown={(event) => this._onButtonKeyDown('chevron', event)}\n >\n <c-icon path={mdiChevronDown} size={24} />\n </c-icon-button>\n );\n }\n\n private _reset = (event) => {\n event.stopPropagation();\n\n this.query = '';\n\n this.changeValue.emit(null);\n\n this.changeQuery.emit('');\n\n this._preventDialogOpen = true;\n\n this._cInputElement.reset();\n\n this._inputElement.focus();\n\n this._dropdownElement.updateList();\n };\n\n private _renderReset() {\n return (\n <c-icon-button\n aria-label=\"\"\n size=\"x-small\"\n text\n onClick={(event) => this._reset(event)}\n onKeyDown={(event) => this._onButtonKeyDown('reset', event)}\n >\n <c-icon path={mdiClose} size={20} />\n </c-icon-button>\n );\n }\n\n private _onInputFocus = () => {\n if (!this._preventDialogOpen) {\n this._dropdownElement.open();\n }\n\n this._updateStatusText();\n\n this._preventDialogOpen = false;\n };\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n type=\"text\"\n ref={(el) => (this._inputElement = el)}\n aria-expanded={this.dropdownVisible.toString()}\n aria-owns={this._inputId + '-items'}\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n class=\"c-input__input\"\n role=\"combobox\"\n value={this.query}\n name={this.name ?? null}\n onInput={(event) => this._updateInput(event)}\n onFocus={() => this._onInputFocus()}\n />\n </div>\n );\n }\n\n componentWillLoad() {\n CAutocomplete._uniqueId += 1;\n\n this._inputId =\n 'input_' +\n (this.hostId || this.label || this.placeholder).replace(\n /[^a-zA-Z0-9-_]/g,\n '',\n );\n }\n\n private get _items() {\n return this.optionElementsExist ? this.optionElements : this.items;\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 ending = !!this._items.length\n ? ' or navigate using the up and down arrows'\n : '';\n\n if (this.currentIndex === null) {\n this.statusText = this._items.length\n ? `${this._items.length} result${\n this._items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n if (this.query !== null && this._items.length) {\n this.statusText += ', input a search query to filter the results';\n }\n\n this._dropdownElement.setStatusText(this.statusText + ending);\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n const itemType = this.optionElementsExist ? 'option' : 'item';\n\n return (\n <Host>\n <c-dropdown\n ref={(el) => (this._dropdownElement = el)}\n id={`${this._id}-dropdown`}\n index={this.currentIndex}\n items-per-page={this.itemsPerPage}\n item-type={itemType}\n items={\n this._items as NodeListOf<HTMLCOptionElement> & CAutocompleteItem[]\n }\n parent={this.el}\n type=\"autocomplete\"\n >\n <c-input\n slot=\"default\"\n ref={(el) => (this._cInputElement = el)}\n active={this.dropdownVisible}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\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.query}\n variant=\"select\"\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n\n {this.loading && this._renderLoader()}\n\n {!this.loading && this.value && this._renderReset()}\n\n {!this.loading && !this.value && this._renderChevron()}\n\n <slot onSlotchange={() => this._handleSlotChange()}></slot>\n </div>\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </c-dropdown>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-autocomplete.js","mappings":";;;;;;;;;;;AAAA,MAAM,gBAAgB,GAAG,4tIAA4tI;;MC0BxuIA,eAAa;;;;;;;;IAgBhB,uBAAkB,GAAG,KAAK,CAAC;IAE3B,cAAS,GAAG,IAAI,CAAC;IAqSjB,sBAAiB,GAAG;MAC1B,IAAI,CAAC,cAAc,GAAG,IAAI,CAAC,EAAE,CAAC,gBAAgB,CAAC,UAAU,CAAC,CAAC;MAE3D,MAAM,SAAS,GAAG,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,cAAc,CAAC,CAAC,IAAI,CACpD,CAAC,MAAM,KAAK,MAAM,CAAC,QAAQ,CAC5B,CAAC;MAEF,IAAI,SAAS,EAAE;QACb,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,YAAY;YAC1B,EAAE,IAAI,EAAE,SAAS,CAAC,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE;YAChD,SAAS,CAAC,KAAK,CAAC;QAEpB,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;QAElC,IAAI,CAAC,SAAS,CAAC,YAAY,CAAC,SAAS,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC;OACzD;MAED,IAAI,IAAI,CAAC,cAAc,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,mBAAmB,EAAE;QAC3D,IAAI,CAAC,mBAAmB,GAAG,IAAI,CAAC;OACjC;KACF,CAAC;IAE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vB,MAAM,EAAE,IAAI,CAAC,MAAM,EACnB,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,QAAQ,EAAE,IAAI,CAAC,QAAQ,sBACL,IAAI,CAAC,cAAc,EACrC,UAAU,EAAE,IAAI,CAAC,UAAU,EAC3B,KAAK,EAAE,IAAI,CAAC,KAAK,EACjB,OAAO,EAAC,QAAQ,IAEhB,YAAM,IAAI,EAAC,KAAK,EAAC,IAAI,EAAC,KAAK,GAAQ,EAEnC,WAAK,KAAK,EAAC,kBAAkB,IAC1B,IAAI,CAAC,mBAAmB,EAAE,EAE1B,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,aAAa,EAAE,EAEpC,CAAC,IAAI,CAAC,OAAO,IAAI,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,YAAY,EAAE,EAElD,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,cAAc,EAAE,EAEtD,YAAM,YAAY,EAAE,MAAM,IAAI,CAAC,iBAAiB,EAAE,GAAS,CACvD,EAEN,YAAM,IAAI,EAAC,MAAM,EAAC,IAAI,EAAC,MAAM,GAAQ,CAC7B,CACC,CACR,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA5iBcA,yBAAS,GAAG,CAAH,CAAK;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":["CAutocomplete"],"sources":["src/components/c-autocomplete/c-autocomplete.scss?tag=c-autocomplete&encapsulation=shadow","src/components/c-autocomplete/c-autocomplete.tsx"],"sourcesContent":[":host(c-autocomplete) {\n /**\n * @prop --c-autocomplete-option-background-color: Autocomplete option background color\n * @prop --c-autocomplete-option-background-hover-color: Autocomplete option background hover color\n * @prop --c-autocomplete-active-color: Autocomplete active color\n * @prop --c-autocomplete-inactive-color: Autocomplete inactive color\n * @prop --c-autocomplete-background-color: Autocomplete background color\n * @prop --c-autocomplete-text-color: Autocomplete text color\n * @prop --c-autocomplete-option-text-color: Autocomplete option text color\n * @prop --c-autocomplete-placeholder-color: Autocomplete placeholder color\n */\n --_c-autocomplete-option-background-color: var(\n --c-autocomplete-option-background-color,\n var(--c-white)\n );\n --_c-autocomplete-option-background-hover-color: var(\n --c-autocomplete-option-background-hover-color,\n var(--c-primary-100)\n );\n --_c-autocomplete-active-color: var(\n --c-autocomplete-active-color,\n var(--c-primary-600)\n );\n --_c-autocomplete-inactive-color: var(\n --c-autocomplete-inactive-color,\n var(--c-tertiary-600)\n );\n --_c-autocomplete-background-color: var(\n --c-autocomplete-background-color,\n var(--c-transparent)\n );\n --_c-autocomplete-text-color: var(\n --c-autocomplete-text-color,\n var(--c-text-body)\n );\n --_c-autocomplete-option-text-color: var(\n --c-autocomplete-option-text-color,\n var(--c-text-body)\n );\n --_c-autocomplete-placeholder-color: var(\n --c-autocomplete-placeholder-color,\n var(--c-tertiary-500)\n );\n\n // c-select options\n --c-select-option-background-color: var(\n --_c-autocomplete-option-background-color\n );\n --c-select-option-background-color-hover: var(\n --_c-autocomplete-option-background-hover-color\n );\n --c-select-option-text-color: var(--_c-autocomplete-option-text-color);\n\n // c-input\n --_c-input-active-color: var(--_c-autocomplete-active-color);\n --_c-input-inactive-color: var(--_c-autocomplete-inactive-color);\n --_c-input-background-color: var(--_c-autocomplete-background-color);\n --_c-input-text-color: var(--_c-autocomplete-text-color);\n --_c-input-placeholder-color: var(--_c-autocomplete-placeholder-color);\n}\n\n@import '../c-input/c-input-menu';\n","import {\n AttachInternals,\n Component,\n Host,\n h,\n Prop,\n State,\n Element,\n Event,\n EventEmitter,\n Listen,\n Watch,\n Method,\n} from '@stencil/core';\nimport { CAutocompleteItem } from '../../types';\nimport { mdiChevronDown, mdiClose } from '@mdi/js';\n\n/**\n * @group Form\n */\n@Component({\n tag: 'c-autocomplete',\n styleUrl: 'c-autocomplete.scss',\n shadow: true,\n formAssociated: true,\n})\nexport class CAutocomplete {\n @Element() el: HTMLCAutocompleteElement;\n\n // eslint-disable-next-line\n @AttachInternals() internals: ElementInternals;\n\n private static _uniqueId = 0;\n\n private _dropdownElement: HTMLCDropdownElement;\n\n private _inputElement: HTMLInputElement;\n\n private _cInputElement: HTMLCInputElement;\n\n private _inputId: string;\n\n private _preventDialogOpen = false;\n\n private _debounce = null;\n\n private get _id() {\n return this.hostId || `autocomplete_${CAutocomplete._uniqueId}`;\n }\n\n /**\n * Dropdown items\n */\n @Prop() items: CAutocompleteItem[] = [];\n\n /**\n * Selected item\n */\n @Prop() value: string | number | CAutocompleteItem = null;\n\n /**\n * Search string\n */\n @Prop() query: string = null;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Disable the input\n */\n @Prop() disabled = false;\n\n /**\n * Element label\n */\n @Prop() label: string;\n\n /**\n * Input field name\n */\n @Prop() name: string;\n\n /**\n * Placeholder text\n */\n @Prop() placeholder = '';\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 * Show loading state\n */\n @Prop() loading = false;\n\n /**\n * Show required validation\n */\n @Prop() required = false;\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 * Shadow variant\n */\n @Prop() shadow = false;\n\n /**\n * Return object instead of value\n */\n @Prop() returnObject = false;\n\n /**\n * Triggered when text is typed\n */\n @Event() changeQuery: EventEmitter;\n\n /**\n * Triggered when option is selected\n */\n @Event({ bubbles: false }) changeValue: EventEmitter;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage = 6;\n\n @State() optionElements: NodeListOf<HTMLCOptionElement>;\n\n @State() currentIndex: number = null;\n\n @State() dropdownVisible = false;\n\n @State() statusText = '';\n\n @State() optionElementsExist = false;\n\n /**\n * Reset autocomplete state\n */\n @Method()\n async reset() {\n this.query = '';\n\n this.changeValue.emit(null);\n\n this.internals.setFormValue(null);\n\n this.changeQuery.emit('');\n\n this._dropdownElement.updateList();\n }\n\n private _handleKeyDown(event: KeyboardEvent) {\n const alphanumeric = /^[0-9a-zA-Z ]+$/;\n\n if (event.key.match(alphanumeric) && event.key.length === 1) {\n if (!this.dropdownVisible) {\n this._dropdownElement.open();\n\n return;\n }\n\n this._inputElement.focus();\n\n return;\n }\n\n if (event.key === 'Escape') {\n event.preventDefault();\n\n this._preventDialogOpen = true;\n this._dropdownElement.close();\n\n requestAnimationFrame(() => {\n this._inputElement.focus();\n });\n\n return;\n }\n\n if (event.key === 'Tab') {\n this._inputElement.focus();\n\n requestAnimationFrame(() => {\n this._dropdownElement.close();\n });\n\n return;\n }\n\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (!this._items.length) return;\n\n if (!this.dropdownVisible || this.currentIndex === null) {\n this.currentIndex = 0;\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n this.currentIndex = Math.min(\n this.currentIndex + 1,\n this._items.length - 1,\n );\n\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (this.currentIndex === 0) {\n this._dropdownElement.close();\n this._inputElement.focus();\n }\n\n if (!this.dropdownVisible || this.currentIndex === null) {\n this.currentIndex = this._items.length - 1;\n this._dropdownElement.open();\n this._dropdownElement.focusItem(this.currentIndex);\n\n return;\n }\n\n this.currentIndex = Math.max(this.currentIndex - 1, 0);\n\n this._dropdownElement.focusItem(this.currentIndex);\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (this.currentIndex === null) return;\n\n this._dropdownElement.selectItem(this.currentIndex);\n }\n\n if (event.key === 'Home' && this.dropdownVisible) {\n this.currentIndex = 0;\n }\n\n if (event.key === 'End' && this.dropdownVisible) {\n this.currentIndex = this._items.length - 1;\n }\n }\n\n @Listen('dropdownStateChange')\n onDropdownStateChange(event: CustomEvent<boolean>) {\n const isOpen = event.detail;\n\n this.dropdownVisible = isOpen;\n\n if (!isOpen) {\n requestAnimationFrame(() => {\n this.currentIndex = null;\n });\n }\n }\n\n @Listen('selectOption')\n onSelectOption(event: CustomEvent<{ name: string; value: string }>) {\n this._dropdownElement.close();\n\n const { name, value } = event.detail;\n\n this.value = this.returnObject ? event.detail : value;\n\n this.changeValue.emit(this.value);\n\n this.internals.setFormValue(value);\n\n this.query = name;\n\n this.changeQuery.emit(name);\n\n this._preventDialogOpen = true;\n\n if (this.optionElementsExist) {\n Array.from(this.optionElements).forEach((item) => {\n item.selected = item.value === value && item.name === name;\n });\n\n this._dropdownElement.updateList();\n }\n\n this._inputElement.focus();\n }\n\n @Watch('query')\n handleQueryChange() {\n this._updateStatusText();\n }\n\n private _updateInput() {\n this._dropdownElement.open();\n\n this.query = this._inputElement.value;\n\n this.changeQuery.emit(this.query);\n\n this._dropdownElement.updateList();\n }\n\n private _handleSlotChange = () => {\n this.optionElements = this.el.querySelectorAll('c-option');\n\n const selection = Array.from(this.optionElements).find(\n (option) => option.selected,\n );\n\n if (selection) {\n this.value = this.returnObject\n ? { name: selection.name, value: selection.value }\n : selection.value;\n\n this.changeValue.emit(this.value);\n\n this.changeQuery.emit(this.query);\n\n this.internals.setFormValue(selection.value.toString());\n }\n\n if (this.optionElements.length && !this.optionElementsExist) {\n this.optionElementsExist = true;\n }\n };\n\n private _toggleDropdown = (event) => {\n event.stopPropagation();\n\n if (this.dropdownVisible) {\n this._dropdownElement.close();\n\n return;\n }\n\n this._dropdownElement.open();\n };\n\n private _onButtonKeyDown = (\n src: 'chevron' | 'reset',\n event: KeyboardEvent,\n ) => {\n event.stopPropagation();\n\n if (event.key !== 'Tab') event.preventDefault();\n\n if (['Enter', ' '].includes(event.key)) {\n if (src === 'chevron') {\n this._toggleDropdown(event);\n\n return;\n }\n\n this._reset(event);\n\n this._preventDialogOpen = true;\n\n this._inputElement.focus();\n }\n };\n\n private _renderLoader() {\n return <c-spinner color=\"var(--_c-autocomplete-active-color)\" size={20} />;\n }\n\n private _renderChevron() {\n const classes = {\n 'c-input-menu__chevron': true,\n 'c-input-menu__chevron--active': this.dropdownVisible,\n };\n\n return (\n <c-icon-button\n size=\"x-small\"\n class={classes}\n text\n onClick={(event) => this._toggleDropdown(event)}\n onKeyDown={(event) => this._onButtonKeyDown('chevron', event)}\n >\n <c-icon path={mdiChevronDown} size={24} />\n </c-icon-button>\n );\n }\n\n private _reset = (event) => {\n event.stopPropagation();\n\n this.query = '';\n\n this.value = null;\n\n this.changeValue.emit(null);\n\n this.internals.setFormValue(null);\n\n this.changeQuery.emit('');\n\n this._preventDialogOpen = true;\n\n this._cInputElement.reset();\n\n this._inputElement.focus();\n\n this._dropdownElement.updateList();\n };\n\n private _renderReset() {\n return (\n <c-icon-button\n aria-label=\"\"\n size=\"x-small\"\n text\n onClick={(event) => this._reset(event)}\n onKeyDown={(event) => this._onButtonKeyDown('reset', event)}\n >\n <c-icon path={mdiClose} size={20} />\n </c-icon-button>\n );\n }\n\n private _onInputFocus = () => {\n if (!this._preventDialogOpen) {\n this._dropdownElement.open();\n }\n\n this._updateStatusText();\n\n this._preventDialogOpen = false;\n };\n\n private _renderInputElement() {\n return (\n <div class=\"c-input-menu__input\">\n <input\n type=\"text\"\n ref={(el) => (this._inputElement = el)}\n aria-expanded={this.dropdownVisible.toString()}\n aria-owns={this._inputId + '-items'}\n aria-autocomplete=\"list\"\n autocomplete=\"off\"\n class=\"c-input__input\"\n role=\"combobox\"\n value={this.query}\n name={this.name ?? null}\n onInput={() => this._updateInput()}\n onFocus={() => this._onInputFocus()}\n />\n </div>\n );\n }\n\n componentWillLoad() {\n CAutocomplete._uniqueId += 1;\n\n this._inputId =\n 'input_' +\n (this.hostId || this.label || this.placeholder).replace(\n /[^a-zA-Z0-9-_]/g,\n '',\n );\n }\n\n private get _items() {\n return this.optionElementsExist ? this.optionElements : this.items;\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 ending = !!this._items.length\n ? ' or navigate using the up and down arrows'\n : '';\n\n if (this.currentIndex === null) {\n this.statusText = this._items.length\n ? `${this._items.length} result${\n this._items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n if (this.query !== null && this._items.length) {\n this.statusText += ', input a search query to filter the results';\n }\n\n this._dropdownElement.setStatusText(this.statusText + ending);\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n const itemType = this.optionElementsExist ? 'option' : 'item';\n\n return (\n <Host>\n <c-dropdown\n ref={(el) => (this._dropdownElement = el)}\n id={`${this._id}-dropdown`}\n index={this.currentIndex}\n items-per-page={this.itemsPerPage}\n item-type={itemType}\n items={\n this._items as NodeListOf<HTMLCOptionElement> & CAutocompleteItem[]\n }\n parent={this.el}\n type=\"autocomplete\"\n onKeyDown={(event) => this._handleKeyDown(event)}\n >\n <c-input\n slot=\"default\"\n ref={(el) => (this._cInputElement = el)}\n active={this.dropdownVisible}\n disabled={this.disabled}\n hide-details={this.hideDetails}\n hint={this.hint}\n id={this.hostId}\n input-id={this._inputId}\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.query}\n variant=\"select\"\n >\n <slot name=\"pre\" slot=\"pre\"></slot>\n\n <div class=\"c-input__content\">\n {this._renderInputElement()}\n\n {this.loading && this._renderLoader()}\n\n {!this.loading && this.value && this._renderReset()}\n\n {!this.loading && !this.value && this._renderChevron()}\n\n <slot onSlotchange={() => this._handleSlotChange()}></slot>\n </div>\n\n <slot name=\"post\" slot=\"post\"></slot>\n </c-input>\n </c-dropdown>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
2
|
import { a as mdiAlert } from './mdi.js';
|
|
3
|
+
import { g as getScrollParent } from './getScrollParent.js';
|
|
3
4
|
import { d as defineCustomElement$1 } from './c-icon2.js';
|
|
4
5
|
|
|
5
|
-
const cDropdownCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-dropdown){--_c-dropdown-background-color:var(\n --c-dropdown-background-color,\n var(--c-white)\n );--_c-dropdown-background-color-hover:var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );--_c-dropdown-text-color:var(--c-dropdown-text-color, var(--c-text-body));--_c-dropdown-text-color-active:var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );--_c-dropdown-font-size:14px;--_c-dropdown-height:42px;display:block;position:relative}:host(c-dropdown) mark{background-color:transparent;box-shadow:0 2px 0 0 var(--_c-dropdown-text-color-active);color:inherit}:host(c-dropdown) dialog{border-radius:4px;background-color:transparent;border:none;margin:-4px 0 0;overflow:visible;padding:4px 0 0;position:fixed}:host(c-dropdown) dialog::backdrop{display:none}:host(c-dropdown) dialog[open].mobile{background-color:var(--_c-dropdown-background-color);width:100vw;max-width:100vw;height:100vh;max-height:100svh;inset:0}:host(c-dropdown) dialog[open].mobile .input-top-wrapper{padding:8px}:host(c-dropdown) dialog .input-bottom-wrapper.active{padding-top:8px}:host(c-dropdown) .dummy{display:none}:host(c-dropdown) ul{background-color:var(--_c-dropdown-background-color);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);border-radius:4px;list-style:none;margin:0;outline:none;padding:0;pointer-events:auto;visibility:hidden;width:100%;height:max-content;overflow-y:scroll}:host(c-dropdown) ul.active{visibility:visible;animation:0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1)}:host(c-dropdown) ul.active.mobile{width:100vw;max-width:100vw;height:100vh;max-height:calc(100svh - 60px)}:host(c-dropdown) li{align-items:center;column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-dropdown-font-size);min-height:var(--_c-dropdown-height);outline:none;padding-left:10px;padding-right:10px;pointer-events:auto;white-space:nowrap;width:100%;border-radius:4px}:host(c-dropdown) li span,:host(c-dropdown) li c-option-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}:host(c-dropdown) li:
|
|
6
|
+
const cDropdownCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host(c-dropdown){--_c-dropdown-background-color:var(\n --c-dropdown-background-color,\n var(--c-white)\n );--_c-dropdown-background-color-hover:var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );--_c-dropdown-text-color:var(--c-dropdown-text-color, var(--c-text-body));--_c-dropdown-text-color-active:var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );--_c-dropdown-font-size:14px;--_c-dropdown-height:42px;display:block;position:relative}:host(c-dropdown) mark{background-color:transparent;box-shadow:0 2px 0 0 var(--_c-dropdown-text-color-active);color:inherit}:host(c-dropdown) dialog{border-radius:4px;background-color:transparent;border:none;margin:-4px 0 0;overflow:visible;padding:4px 0 0;position:fixed}:host(c-dropdown) dialog::backdrop{display:none}:host(c-dropdown) dialog[open].mobile{background-color:var(--_c-dropdown-background-color);width:100vw;max-width:100vw;height:100vh;max-height:100svh;inset:0}:host(c-dropdown) dialog[open].mobile .input-top-wrapper{padding:8px}:host(c-dropdown) dialog .input-bottom-wrapper.active{padding-top:8px}:host(c-dropdown) .dummy{display:none}:host(c-dropdown) ul{background-color:var(--_c-dropdown-background-color);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);border-radius:4px;list-style:none;margin:0;outline:none;padding:0;pointer-events:auto;visibility:hidden;width:100%;height:max-content;overflow-y:scroll}:host(c-dropdown) ul.active{visibility:visible;animation:0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1)}:host(c-dropdown) ul.active.mobile{width:100vw;max-width:100vw;height:100vh;max-height:calc(100svh - 60px)}:host(c-dropdown) li{align-items:center;column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-dropdown-font-size);min-height:var(--_c-dropdown-height);outline:none;padding-left:10px;padding-right:10px;pointer-events:auto;white-space:nowrap;width:100%;border-radius:4px}:host(c-dropdown) li span,:host(c-dropdown) li c-option-value{overflow:hidden;text-overflow:ellipsis;white-space:nowrap;width:100%}:host(c-dropdown) li:hover,:host(c-dropdown) li:focus,:host(c-dropdown) li.active{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);box-shadow:inset 0 0 0 1px var(--_c-dropdown-text-color-active)}:host(c-dropdown) li:not(.disabled,:hover,:focus)[aria-selected=true]{background:var(--_c-dropdown-background-color-hover);color:var(--_c-dropdown-text-color-active);border-radius:0}:host(c-dropdown) li.disabled{background-color:rgba(var(--c-tertiary-rgb), 0.05);cursor:default;filter:grayscale(1) opacity(0.75)}:host(c-dropdown) .visuallyhidden{border:0;clip:rect(1px, 1px, 1px, 1px);height:1px;overflow:hidden;padding:0;position:absolute;width:1px}@keyframes fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}";
|
|
6
7
|
|
|
7
8
|
const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
8
9
|
constructor() {
|
|
@@ -36,18 +37,16 @@ const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
|
36
37
|
this.renderedList = this._renderList();
|
|
37
38
|
});
|
|
38
39
|
}
|
|
39
|
-
stateWatcher() {
|
|
40
|
-
this.dropdownStateChange.emit(
|
|
40
|
+
async stateWatcher(isOpen) {
|
|
41
|
+
this.dropdownStateChange.emit(isOpen);
|
|
42
|
+
this._scrollParent = this._scrollParent || (await getScrollParent(this.el));
|
|
43
|
+
this._scrollParent.style.overflow = isOpen ? 'hidden' : null;
|
|
41
44
|
}
|
|
42
45
|
handleIndexChange(index) {
|
|
43
46
|
requestAnimationFrame(() => {
|
|
47
|
+
var _a;
|
|
44
48
|
this._updateStatusText();
|
|
45
|
-
this._listItems.
|
|
46
|
-
item === null || item === void 0 ? void 0 : item.classList.toggle('active', index === itemIndex);
|
|
47
|
-
if (index === itemIndex) {
|
|
48
|
-
item === null || item === void 0 ? void 0 : item.focus();
|
|
49
|
-
}
|
|
50
|
-
});
|
|
49
|
+
(_a = this._listItems[index]) === null || _a === void 0 ? void 0 : _a.focus();
|
|
51
50
|
});
|
|
52
51
|
}
|
|
53
52
|
async setStatusText(text) {
|
|
@@ -89,12 +88,12 @@ const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
|
89
88
|
this._hideDetails = this.parent.hideDetails;
|
|
90
89
|
this._inputElement = this.el.querySelector('c-input');
|
|
91
90
|
this._resizeObserver = new ResizeObserver((entries) => {
|
|
91
|
+
if (!this._dialog.open)
|
|
92
|
+
return;
|
|
92
93
|
requestAnimationFrame(() => {
|
|
93
94
|
if (!Array.isArray(entries) || !entries.length)
|
|
94
95
|
return;
|
|
95
96
|
this._setIsMobile();
|
|
96
|
-
if (!this._dialog.open)
|
|
97
|
-
return;
|
|
98
97
|
this.close();
|
|
99
98
|
});
|
|
100
99
|
});
|
|
@@ -145,13 +144,13 @@ const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
|
145
144
|
this._dialog.showModal();
|
|
146
145
|
requestAnimationFrame(() => {
|
|
147
146
|
let inputSlot = 'input-top';
|
|
147
|
+
const { top: parentTop, width } = this._getParentPosition();
|
|
148
|
+
const inputSize = this.el.getBoundingClientRect();
|
|
149
|
+
this._inputSize = {
|
|
150
|
+
height: inputSize.height,
|
|
151
|
+
width: inputSize.width,
|
|
152
|
+
};
|
|
148
153
|
if (!this._isMobile) {
|
|
149
|
-
const { top: parentTop, width } = this._getParentPosition();
|
|
150
|
-
const inputSize = this.el.getBoundingClientRect();
|
|
151
|
-
this._inputSize = {
|
|
152
|
-
height: inputSize.height,
|
|
153
|
-
width: inputSize.width,
|
|
154
|
-
};
|
|
155
154
|
this._dialog.style.width = `${width}px`;
|
|
156
155
|
this._dialog.style.top = `${inputSize.top}px`;
|
|
157
156
|
this._dialog.style.bottom = 'auto';
|
|
@@ -171,12 +170,11 @@ const CDropdown = proxyCustomElement(class CDropdown extends HTMLElement {
|
|
|
171
170
|
inputSlot = 'input-bottom';
|
|
172
171
|
this._dialog.style.top = 'auto';
|
|
173
172
|
this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;
|
|
174
|
-
this._inputElement.scrollIntoView();
|
|
175
173
|
}
|
|
176
|
-
this._dummyElement.style.width = `${this._getParentPosition().width}px`;
|
|
177
|
-
this._dummyElement.style.height = `${this._inputSize.height}px`;
|
|
178
|
-
this._dummyElement.style.display = 'block';
|
|
179
174
|
}
|
|
175
|
+
this._dummyElement.style.width = `${this._getParentPosition().width}px`;
|
|
176
|
+
this._dummyElement.style.height = `${this._inputSize.height}px`;
|
|
177
|
+
this._dummyElement.style.display = 'block';
|
|
180
178
|
this._dummyElement.slot = 'default';
|
|
181
179
|
this._inputElement.slot = inputSlot;
|
|
182
180
|
this._inputElement.hideDetails = true;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-dropdown2.js","mappings":";;;;AAAA,MAAM,YAAY,GAAG,6zFAA6zF;;MCoBr0F,SAAS;;;;;;;IAwDZ,cAAS,GAAG,IAAI,CAAC;IAYjB,cAAS,GAAG,KAAK,CAAC;IAElB,eAAU,GAAoB,EAAE,CAAC;IAgKjC,eAAU,GAAG;MACnB,MAAM,EAAE,CAAC;MACT,KAAK,EAAE,CAAC;KACT,CAAC;IAEM,iBAAY,GAAG,KAAK,CAAC;IAErB,iBAAY,GAAG,KAAK,CAAC;;;;;;;;wBArKL,IAAI;kBAEV,KAAK;sBAED,EAAE;;EAGxB,cAAc;IACZ,qBAAqB,CAAC;MACpB,IAAI,CAAC,YAAY,G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,EAAE,MAAM,IAAI,CAAC,KAAK,EAAE,IAE5B,WACE,EAAE,EAAE,WAAW,GAAG,IAAI,CAAC,MAAM,EAC7B,KAAK,EAAC,gBAAgB,eACZ,QAAQ,iBACN,MAAM,IAEjB,IAAI,CAAC,UAAU,CACZ,EAEN,WAAK,KAAK,EAAC,mBAAmB,IAC5B,YAAM,IAAI,EAAC,WAAW,GAAQ,CAC1B,EAEN,UACE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,KAAK,GAAG,EAAE,CAAC,EAC9B,EAAE,EAAE,GAAG,IAAI,CAAC,MAAM,WAAW,EAC7B,IAAI,EAAC,SAAS,mBACC,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,EACrC,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EACtD,QAAQ,EAAC,IAAI,IAEZ,IAAI,CAAC,YAAY,CACf,EAEL,WACE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,sBAAsB,EAAE,IAAI,EAAE,IAElE,YAAM,IAAI,EAAC,cAAc,GAAQ,CAC7B,CACC,CACJ,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/c-dropdown/c-dropdown.scss?tag=c-dropdown&encapsulation=shadow","src/components/c-dropdown/c-dropdown.tsx"],"sourcesContent":[":host(c-dropdown) {\n /**\n * @prop --c-dropdown-background-color: Menu background color\n * @prop --c-dropdown-background-color-hover: Menu item hover background color\n * @prop --c-dropdown-text-color: Menu item text color\n * @prop --c-dropdown-text-color-active: Active menu item text color\n */\n --_c-dropdown-background-color: var(\n --c-dropdown-background-color,\n var(--c-white)\n );\n --_c-dropdown-background-color-hover: var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );\n --_c-dropdown-text-color: var(--c-dropdown-text-color, var(--c-text-body));\n --_c-dropdown-text-color-active: var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );\n\n // private\n --_c-dropdown-font-size: 14px;\n --_c-dropdown-height: 42px;\n\n display: block;\n position: relative;\n\n mark {\n background-color: transparent;\n box-shadow: 0 2px 0 0 var(--_c-dropdown-text-color-active);\n color: inherit;\n }\n\n dialog {\n border-radius: 4px;\n background-color: transparent;\n border: none;\n margin: -4px 0 0;\n overflow: visible;\n padding: 4px 0 0;\n position: fixed;\n\n &::backdrop {\n display: none;\n }\n\n &[open].mobile {\n background-color: var(--_c-dropdown-background-color);\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100svh;\n inset: 0;\n\n .input-top-wrapper {\n padding: 8px;\n }\n }\n\n .input-bottom-wrapper.active {\n padding-top: 8px;\n }\n }\n\n .dummy {\n display: none;\n }\n\n ul {\n background-color: var(--_c-dropdown-background-color);\n box-shadow: 2px 4px 10px #00000029;\n border-radius: 4px;\n list-style: none;\n margin: 0;\n outline: none;\n padding: 0;\n pointer-events: auto;\n visibility: hidden;\n width: 100%;\n height: max-content;\n overflow-y: scroll;\n\n &.active {\n visibility: visible;\n animation: 0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n\n &.mobile {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: calc(100svh - 60px);\n }\n }\n }\n\n li {\n align-items: center;\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-dropdown-font-size);\n min-height: var(--_c-dropdown-height);\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n pointer-events: auto;\n white-space: nowrap;\n width: 100%;\n border-radius: 4px;\n\n span,\n c-option-value {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n }\n\n &:not(.disabled):hover,\n &:not(.disabled):focus,\n &.active {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n box-shadow: inset 0 0 0 1px var(--_c-dropdown-text-color-active);\n }\n\n &.disabled {\n background-color: rgba(var(--c-tertiary-rgb), 0.05);\n cursor: default;\n filter: grayscale(1) opacity(0.75);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n","import { mdiAlert } from '@mdi/js';\nimport {\n Component,\n Host,\n Prop,\n h,\n Element,\n Method,\n Watch,\n Event,\n EventEmitter,\n State,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\n\n@Component({\n tag: 'c-dropdown',\n styleUrl: 'c-dropdown.scss',\n shadow: true,\n})\nexport class CDropdown {\n @Element() el: HTMLCDropdownElement;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * Dropdown parent\n */\n @Prop() parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n /**\n * Dropdown options\n */\n @Prop() items:\n | NodeListOf<HTMLCOptionElement>\n | CAutocompleteItem[]\n | CSelectItem[];\n\n /**\n * Current index value\n */\n @Prop() index: number;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Triggered when option is selected\n */\n @Event() selectOption: EventEmitter;\n\n /**\n * Type of the parent element\n */\n @Prop() type: 'select' | 'autocomplete';\n\n /**\n * Type of items\n */\n @Prop() itemType: 'option' | 'item';\n\n /**\n * Triggered when dropdown opens or closes\n */\n @Event() dropdownStateChange: EventEmitter<boolean>;\n\n /**\n * Dropdown dialog element\n */\n private _dialog: HTMLDialogElement;\n\n private _debounce = null;\n\n private _list: HTMLUListElement;\n\n private _outsideClickFn: () => void;\n\n private _resizeObserver: ResizeObserver;\n\n private _inputElement: HTMLCInputElement;\n\n private _dummyElement: HTMLDivElement;\n\n private _isMobile = false;\n\n private _listItems: HTMLLIElement[] = [];\n\n @State() renderedList = null;\n\n @State() isOpen = false;\n\n @State() statusText = '';\n\n @Watch('items')\n optionsWatcher() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n @Watch('isOpen')\n stateWatcher() {\n this.dropdownStateChange.emit(this.isOpen);\n }\n\n @Watch('index')\n handleIndexChange(index) {\n requestAnimationFrame(() => {\n this._updateStatusText();\n\n this._listItems.forEach((item, itemIndex) => {\n item?.classList.toggle('active', index === itemIndex);\n\n if (index === itemIndex) {\n item?.focus();\n }\n });\n });\n }\n\n /**\n * @private\n */\n @Method()\n async setStatusText(text: string) {\n requestAnimationFrame(() => {\n this.statusText = text;\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(index: number) {\n requestAnimationFrame(() => {\n this._listItems[index]?.focus();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async open() {\n if (this._dialog.open) return;\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n window.addEventListener('click', this._outsideClickFn);\n\n requestAnimationFrame(() => {\n this.isOpen = true;\n\n this._positionMenu();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async close() {\n this._dialog.close();\n\n this.isOpen = false;\n\n this._inputElement.slot = 'default';\n\n this._inputElement.hideDetails = this._hideDetails;\n\n this._dummyElement.style.width = '0';\n this._dummyElement.style.display = 'none';\n this._dialog.style.width = '0';\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n private _setIsMobile() {\n this._isMobile = window.matchMedia(\n 'only screen and (max-width: 760px)',\n ).matches;\n }\n\n componentDidLoad() {\n this._setIsMobile();\n\n this._hideDetails = this.parent.hideDetails;\n\n this._inputElement = this.el.querySelector('c-input');\n\n this._resizeObserver = new ResizeObserver((entries) => {\n requestAnimationFrame(() => {\n if (!Array.isArray(entries) || !entries.length) return;\n\n this._setIsMobile();\n\n if (!this._dialog.open) return;\n\n this.close();\n });\n });\n\n this._resizeObserver.observe(window.document.body);\n\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n /**\n * Select item\n * @returns the disabled status of the input\n */\n @Method()\n async selectItem(index: number) {\n const item = this._listItems[index];\n\n if (item.classList.contains('disabled')) {\n return true;\n }\n\n this._listItems[index].click();\n\n return false;\n }\n\n /**\n * Update list items\n */\n @Method()\n async updateList() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n private _handleOutsideClick(event) {\n if (!this.isOpen) return;\n\n if (!event.composedPath().includes(this._dialog)) {\n this.close();\n }\n }\n\n private _inputSize = {\n height: 0,\n width: 0,\n };\n\n private _openedOnTop = false;\n\n private _hideDetails = false;\n\n private _highlightMatchingText(value: string) {\n const { query } = this.parent as HTMLCAutocompleteElement;\n\n if (this.parent.tagName === 'C-SELECT' || query === '') return value;\n\n const regex = new RegExp(query, 'gi');\n\n const highlighted = value\n .replace(/(<([^>]+)>)/gi, '')\n .replace(regex, (match) => `<mark>${match}</mark>`);\n\n return highlighted;\n }\n\n private _getParentPosition() {\n return this.parent.shadowRoot\n .querySelector('.c-input__slot')\n .getBoundingClientRect();\n }\n\n private _positionMenu() {\n const { innerWidth, innerHeight } = window;\n\n this._dialog.style.width = 'auto';\n this._dialog.style.opacity = '0';\n\n this._dialog.showModal();\n\n requestAnimationFrame(() => {\n let inputSlot = 'input-top';\n\n if (!this._isMobile) {\n const { top: parentTop, width } = this._getParentPosition();\n\n const inputSize = this.el.getBoundingClientRect();\n\n this._inputSize = {\n height: inputSize.height,\n width: inputSize.width,\n };\n\n this._dialog.style.width = `${width}px`;\n this._dialog.style.top = `${inputSize.top}px`;\n this._dialog.style.bottom = 'auto';\n this._dialog.style.left = `${inputSize.left}px`;\n\n const { bottom, right, height } = this._dialog.getBoundingClientRect();\n\n const isInView = {\n x: right < innerWidth,\n y: bottom < innerHeight,\n };\n\n const fitsOnTop = parentTop - height > 0;\n\n if (!fitsOnTop && !isInView.y) {\n this._dialog.style.maxHeight = `${parentTop}px`;\n }\n\n if (!isInView.y || this._openedOnTop) {\n this._openedOnTop = true;\n\n this._inputElement.hideDetails = true;\n inputSlot = 'input-bottom';\n\n this._dialog.style.top = 'auto';\n this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;\n this._inputElement.scrollIntoView();\n }\n\n this._dummyElement.style.width = `${this._getParentPosition().width}px`;\n this._dummyElement.style.height = `${this._inputSize.height}px`;\n this._dummyElement.style.display = 'block';\n }\n\n this._dummyElement.slot = 'default';\n\n this._inputElement.slot = inputSlot;\n\n this._inputElement.hideDetails = true;\n\n this._dialog.style.opacity = '1';\n\n const input = this.parent.shadowRoot.querySelector('input');\n\n input.focus();\n });\n }\n\n private _emptyItem() {\n const { query, loading } = this.parent as HTMLCAutocompleteElement;\n\n if (!query || loading) return;\n\n return (\n <li>\n <c-icon path={mdiAlert} size={18} color=\"var(--c-warning-600)\"></c-icon>\n No suggestions found\n </li>\n );\n }\n\n private _renderList() {\n return this.itemType === 'option'\n ? this._renderOptionsList()\n : this._renderItemsList();\n }\n\n private _renderOptionsList() {\n if (!this.items.length) return this._emptyItem();\n\n const options = Array.from(this.items) as HTMLCOptionElement[];\n\n this._listItems.length = 0;\n\n return options.map((option, index) => {\n const optionValue = option.querySelector('c-option-value');\n\n if (optionValue) {\n optionValue.innerHTML = this._highlightMatchingText(\n optionValue.textContent,\n );\n }\n\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${option.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(!!option.selected).toString()}\n class={{ disabled: !!option.disabled }}\n data-name={option.name}\n onClick={(event) => {\n if (option.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: option.name, value: option.value });\n }}\n innerHTML={option.outerHTML}\n ></li>\n );\n });\n }\n\n private _renderItemsList() {\n if (!this.items.length) return this._emptyItem();\n\n this._listItems.length = 0;\n\n return (this.items as unknown as CAutocompleteItem[]).map((item, index) => {\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${item.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(this.index === index).toString()}\n class={{ disabled: !!item.disabled }}\n data-name={item.name}\n onClick={(event) => {\n if (item.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: item.name, value: item.value });\n }}\n >\n <span innerHTML={this._highlightMatchingText(item.name)}></span>\n </li>\n );\n });\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._listItems[this.index];\n\n const ending = !!this.items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const total = this._listItems.length;\n\n const position = this.index + 1;\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n let selectionText = !!selection\n ? `${beginning}${selection.dataset.name} - ${position} of ${total} is highlighted`\n : null;\n\n if (this.index === null && this.type === 'autocomplete') {\n selectionText = this.items.length\n ? `${this.items.length} result${\n this.items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n if (\n !this._isMobile &&\n this._dialog &&\n this.itemsPerPage &&\n this.itemsPerPage > 0 &&\n this.items.length > this.itemsPerPage\n ) {\n this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';\n this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';\n }\n\n return (\n <Host>\n <slot name=\"default\"></slot>\n\n <div class=\"dummy\" ref={(el) => (this._dummyElement = el)}></div>\n\n <dialog\n tabindex=\"-1\"\n ref={(el) => (this._dialog = el)}\n class={{ mobile: this._isMobile }}\n onCancel={() => this.close()}\n >\n <div\n id={'announce-' + this.hostId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class=\"input-top-wrapper\">\n <slot name=\"input-top\"></slot>\n </div>\n\n <ul\n ref={(el) => (this._list = el)}\n id={`${this.hostId}--results`}\n role=\"listbox\"\n aria-expanded={this.isOpen.toString()}\n class={{ active: this.isOpen, mobile: this._isMobile }}\n tabindex=\"-1\"\n >\n {this.renderedList}\n </ul>\n\n <div\n class={{ active: this._openedOnTop, 'input-bottom-wrapper': true }}\n >\n <slot name=\"input-bottom\"></slot>\n </div>\n </dialog>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-dropdown2.js","mappings":";;;;;AAAA,MAAM,YAAY,GAAG,q9FAAq9F;;MCqB79F,SAAS;;;;;;;IAwDZ,cAAS,GAAG,IAAI,CAAC;IAcjB,cAAS,GAAG,KAAK,CAAC;IAElB,eAAU,GAAoB,EAAE,CAAC;IA8JjC,eAAU,GAAG;MACnB,MAAM,EAAE,CAAC;MACT,KAAK,EAAE,CAAC;KACT,CAAC;IAEM,iBAAY,GAAG,KAAK,CAAC;IAErB,iBAAY,GAAG,KAAK,CAAC;;;;;;;;wBAnKL,IAAI;kBAEV,KAAK;sBAED,EAAE;;EAGxB,cAAc;IACZ,qBAAqB,CAAC;MACpB,IAAI,CAAC,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;KACxC,CAAC,CAAC;GACJ;EAGD,MAAM,YAAY,CAAC,MAAM;IACvB,IAAI,CAAC,mBAAmB,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAEtC,IAAI,CAAC,aAAa,GAAG,IAAI,CAAC,aAAa,KAAK,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC,CAAC;IAE5E,IAAI,CAAC,aAAa,CAAC,KAAK,CAAC,QAAQ,GAAG,MAAM,GAAG,QAAQ,GAAG,IAAI,CAAC;GAC9D;EAGD,iBAAiB,CAAC,KAAK;IACrB,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K,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,IAAI,CAAC,SAAS,EAAE,EACtD,QAAQ,EAAC,IAAI,IAEZ,IAAI,CAAC,YAAY,CACf,EAEL,WACE,KAAK,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,YAAY,EAAE,sBAAsB,EAAE,IAAI,EAAE,IAElE,YAAM,IAAI,EAAC,cAAc,GAAQ,CAC7B,CACC,CACJ,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/c-dropdown/c-dropdown.scss?tag=c-dropdown&encapsulation=shadow","src/components/c-dropdown/c-dropdown.tsx"],"sourcesContent":[":host(c-dropdown) {\n /**\n * @prop --c-dropdown-background-color: Menu background color\n * @prop --c-dropdown-background-color-hover: Menu item hover background color\n * @prop --c-dropdown-text-color: Menu item text color\n * @prop --c-dropdown-text-color-active: Active menu item text color\n */\n --_c-dropdown-background-color: var(\n --c-dropdown-background-color,\n var(--c-white)\n );\n --_c-dropdown-background-color-hover: var(\n --c-dropdown-background-color-hover,\n var(--c-primary-200)\n );\n --_c-dropdown-text-color: var(--c-dropdown-text-color, var(--c-text-body));\n --_c-dropdown-text-color-active: var(\n --c-dropdown-text-color-active,\n var(--c-primary-600)\n );\n\n // private\n --_c-dropdown-font-size: 14px;\n --_c-dropdown-height: 42px;\n\n display: block;\n position: relative;\n\n mark {\n background-color: transparent;\n box-shadow: 0 2px 0 0 var(--_c-dropdown-text-color-active);\n color: inherit;\n }\n\n dialog {\n border-radius: 4px;\n background-color: transparent;\n border: none;\n margin: -4px 0 0;\n overflow: visible;\n padding: 4px 0 0;\n position: fixed;\n\n &::backdrop {\n display: none;\n }\n\n &[open].mobile {\n background-color: var(--_c-dropdown-background-color);\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: 100svh;\n inset: 0;\n\n .input-top-wrapper {\n padding: 8px;\n }\n }\n\n .input-bottom-wrapper.active {\n padding-top: 8px;\n }\n }\n\n .dummy {\n display: none;\n }\n\n ul {\n background-color: var(--_c-dropdown-background-color);\n box-shadow: 2px 4px 10px #00000029;\n border-radius: 4px;\n list-style: none;\n margin: 0;\n outline: none;\n padding: 0;\n pointer-events: auto;\n visibility: hidden;\n width: 100%;\n height: max-content;\n overflow-y: scroll;\n\n &.active {\n visibility: visible;\n animation: 0.2s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n\n &.mobile {\n width: 100vw;\n max-width: 100vw;\n height: 100vh;\n max-height: calc(100svh - 60px);\n }\n }\n }\n\n li {\n align-items: center;\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-dropdown-font-size);\n min-height: var(--_c-dropdown-height);\n outline: none;\n padding-left: 10px;\n padding-right: 10px;\n pointer-events: auto;\n white-space: nowrap;\n width: 100%;\n border-radius: 4px;\n\n span,\n c-option-value {\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n width: 100%;\n }\n\n &:hover,\n &:focus,\n &.active {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n box-shadow: inset 0 0 0 1px var(--_c-dropdown-text-color-active);\n }\n\n &:not(.disabled, :hover, :focus)[aria-selected=\"true\"] {\n background: var(--_c-dropdown-background-color-hover);\n color: var(--_c-dropdown-text-color-active);\n border-radius: 0;\n }\n\n &.disabled {\n background-color: rgba(var(--c-tertiary-rgb), 0.05);\n cursor: default;\n filter: grayscale(1) opacity(0.75);\n }\n }\n\n .visuallyhidden {\n border: 0;\n clip: rect(1px, 1px, 1px, 1px);\n height: 1px;\n overflow: hidden;\n padding: 0;\n position: absolute;\n width: 1px;\n }\n\n @keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n }\n}\n","import { mdiAlert } from '@mdi/js';\nimport {\n Component,\n Host,\n Prop,\n h,\n Element,\n Method,\n Watch,\n Event,\n EventEmitter,\n State,\n} from '@stencil/core';\nimport { CAutocompleteItem, CSelectItem } from '../../types';\nimport { getScrollParent } from '../../utils';\n\n@Component({\n tag: 'c-dropdown',\n styleUrl: 'c-dropdown.scss',\n shadow: true,\n})\nexport class CDropdown {\n @Element() el: HTMLCDropdownElement;\n\n /**\n * Items per page before adding scroll\n */\n @Prop() itemsPerPage: number;\n\n /**\n * Dropdown parent\n */\n @Prop() parent: HTMLCSelectElement | HTMLCAutocompleteElement;\n\n /**\n * Dropdown options\n */\n @Prop() items:\n | NodeListOf<HTMLCOptionElement>\n | CAutocompleteItem[]\n | CSelectItem[];\n\n /**\n * Current index value\n */\n @Prop() index: number;\n\n /**\n * Id of the element\n */\n @Prop({ attribute: 'id' }) hostId: string;\n\n /**\n * Triggered when option is selected\n */\n @Event() selectOption: EventEmitter;\n\n /**\n * Type of the parent element\n */\n @Prop() type: 'select' | 'autocomplete';\n\n /**\n * Type of items\n */\n @Prop() itemType: 'option' | 'item';\n\n /**\n * Triggered when dropdown opens or closes\n */\n @Event() dropdownStateChange: EventEmitter<boolean>;\n\n /**\n * Dropdown dialog element\n */\n private _dialog: HTMLDialogElement;\n\n private _debounce = null;\n\n private _list: HTMLUListElement;\n\n private _outsideClickFn: () => void;\n\n private _resizeObserver: ResizeObserver;\n\n private _inputElement: HTMLCInputElement;\n\n private _dummyElement: HTMLDivElement;\n\n private _scrollParent: HTMLElement;\n\n private _isMobile = false;\n\n private _listItems: HTMLLIElement[] = [];\n\n @State() renderedList = null;\n\n @State() isOpen = false;\n\n @State() statusText = '';\n\n @Watch('items')\n optionsWatcher() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n @Watch('isOpen')\n async stateWatcher(isOpen) {\n this.dropdownStateChange.emit(isOpen);\n\n this._scrollParent = this._scrollParent || (await getScrollParent(this.el));\n\n this._scrollParent.style.overflow = isOpen ? 'hidden' : null;\n }\n\n @Watch('index')\n handleIndexChange(index) {\n requestAnimationFrame(() => {\n this._updateStatusText();\n\n this._listItems[index]?.focus();\n });\n }\n\n /**\n * @private\n */\n @Method()\n async setStatusText(text: string) {\n requestAnimationFrame(() => {\n this.statusText = text;\n });\n }\n\n /**\n * @private\n */\n @Method()\n async focusItem(index: number) {\n requestAnimationFrame(() => {\n this._listItems[index]?.focus();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async open() {\n if (this._dialog.open) return;\n\n this._outsideClickFn = this._handleOutsideClick.bind(this);\n\n window.addEventListener('click', this._outsideClickFn);\n\n requestAnimationFrame(() => {\n this.isOpen = true;\n\n this._positionMenu();\n });\n }\n\n /**\n * Open dropdown\n */\n @Method()\n async close() {\n this._dialog.close();\n\n this.isOpen = false;\n\n this._inputElement.slot = 'default';\n\n this._inputElement.hideDetails = this._hideDetails;\n\n this._dummyElement.style.width = '0';\n this._dummyElement.style.display = 'none';\n this._dialog.style.width = '0';\n\n window.removeEventListener('click', this._outsideClickFn);\n }\n\n private _setIsMobile() {\n this._isMobile = window.matchMedia(\n 'only screen and (max-width: 760px)',\n ).matches;\n }\n\n componentDidLoad() {\n this._setIsMobile();\n\n this._hideDetails = this.parent.hideDetails;\n\n this._inputElement = this.el.querySelector('c-input');\n\n this._resizeObserver = new ResizeObserver((entries) => {\n if (!this._dialog.open) return;\n\n requestAnimationFrame(() => {\n if (!Array.isArray(entries) || !entries.length) return;\n\n this._setIsMobile();\n\n this.close();\n });\n });\n\n this._resizeObserver.observe(window.document.body);\n\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n /**\n * Select item\n * @returns the disabled status of the input\n */\n @Method()\n async selectItem(index: number) {\n const item = this._listItems[index];\n\n if (item.classList.contains('disabled')) {\n return true;\n }\n\n this._listItems[index].click();\n\n return false;\n }\n\n /**\n * Update list items\n */\n @Method()\n async updateList() {\n requestAnimationFrame(() => {\n this.renderedList = this._renderList();\n });\n }\n\n private _handleOutsideClick(event) {\n if (!this.isOpen) return;\n\n if (!event.composedPath().includes(this._dialog)) {\n this.close();\n }\n }\n\n private _inputSize = {\n height: 0,\n width: 0,\n };\n\n private _openedOnTop = false;\n\n private _hideDetails = false;\n\n private _highlightMatchingText(value: string) {\n const { query } = this.parent as HTMLCAutocompleteElement;\n\n if (this.parent.tagName === 'C-SELECT' || query === '') return value;\n\n const regex = new RegExp(query, 'gi');\n\n const highlighted = value\n .replace(/(<([^>]+)>)/gi, '')\n .replace(regex, (match) => `<mark>${match}</mark>`);\n\n return highlighted;\n }\n\n private _getParentPosition() {\n return this.parent.shadowRoot\n .querySelector('.c-input__slot')\n .getBoundingClientRect();\n }\n\n private _positionMenu() {\n const { innerWidth, innerHeight } = window;\n\n this._dialog.style.width = 'auto';\n this._dialog.style.opacity = '0';\n\n this._dialog.showModal();\n\n requestAnimationFrame(() => {\n let inputSlot = 'input-top';\n\n const { top: parentTop, width } = this._getParentPosition();\n\n const inputSize = this.el.getBoundingClientRect();\n\n this._inputSize = {\n height: inputSize.height,\n width: inputSize.width,\n };\n\n if (!this._isMobile) {\n this._dialog.style.width = `${width}px`;\n this._dialog.style.top = `${inputSize.top}px`;\n this._dialog.style.bottom = 'auto';\n this._dialog.style.left = `${inputSize.left}px`;\n\n const { bottom, right, height } = this._dialog.getBoundingClientRect();\n\n const isInView = {\n x: right < innerWidth,\n y: bottom < innerHeight,\n };\n\n const fitsOnTop = parentTop - height > 0;\n\n if (!fitsOnTop && !isInView.y) {\n this._dialog.style.maxHeight = `${parentTop}px`;\n }\n\n if (!isInView.y || this._openedOnTop) {\n this._openedOnTop = true;\n\n this._inputElement.hideDetails = true;\n inputSlot = 'input-bottom';\n\n this._dialog.style.top = 'auto';\n this._dialog.style.bottom = `${innerHeight - inputSize.top - 44}px`;\n }\n }\n\n this._dummyElement.style.width = `${this._getParentPosition().width}px`;\n this._dummyElement.style.height = `${this._inputSize.height}px`;\n this._dummyElement.style.display = 'block';\n this._dummyElement.slot = 'default';\n\n this._inputElement.slot = inputSlot;\n\n this._inputElement.hideDetails = true;\n\n this._dialog.style.opacity = '1';\n\n const input = this.parent.shadowRoot.querySelector('input');\n\n input.focus();\n });\n }\n\n private _emptyItem() {\n const { query, loading } = this.parent as HTMLCAutocompleteElement;\n\n if (!query || loading) return;\n\n return (\n <li>\n <c-icon path={mdiAlert} size={18} color=\"var(--c-warning-600)\"></c-icon>\n No suggestions found\n </li>\n );\n }\n\n private _renderList() {\n return this.itemType === 'option'\n ? this._renderOptionsList()\n : this._renderItemsList();\n }\n\n private _renderOptionsList() {\n if (!this.items.length) return this._emptyItem();\n\n const options = Array.from(this.items) as HTMLCOptionElement[];\n\n this._listItems.length = 0;\n\n return options.map((option, index) => {\n const optionValue = option.querySelector('c-option-value');\n\n if (optionValue) {\n optionValue.innerHTML = this._highlightMatchingText(\n optionValue.textContent,\n );\n }\n\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${option.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(!!option.selected).toString()}\n class={{ disabled: !!option.disabled }}\n data-name={option.name}\n onClick={(event) => {\n if (option.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: option.name, value: option.value });\n }}\n innerHTML={option.outerHTML}\n ></li>\n );\n });\n }\n\n private _renderItemsList() {\n if (!this.items.length) return this._emptyItem();\n\n this._listItems.length = 0;\n\n return (this.items as unknown as CAutocompleteItem[]).map((item, index) => {\n return (\n <li\n ref={(el) => this._listItems.push(el)}\n id={`${this.hostId}-option-${item.value}`}\n tabindex=\"-1\"\n role=\"option\"\n aria-set-size={this.items.length.toString()}\n aria-pos-in-set={(index + 1).toString()}\n aria-selected={(this.index === index).toString()}\n class={{ disabled: !!item.disabled }}\n data-name={item.name}\n onClick={(event) => {\n if (item.disabled) {\n event.preventDefault();\n\n return;\n }\n\n this.selectOption.emit({ name: item.name, value: item.value });\n }}\n >\n <span innerHTML={this._highlightMatchingText(item.name)}></span>\n </li>\n );\n });\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._listItems[this.index];\n\n const ending = !!this.items.length\n ? ', to navigate use up and down arrows'\n : '';\n\n const total = this._listItems.length;\n\n const position = this.index + 1;\n\n const isDisabled = !!selection?.classList?.contains('disabled');\n\n const beginning = isDisabled ? 'Disabled option - ' : '';\n\n let selectionText = !!selection\n ? `${beginning}${selection.dataset.name} - ${position} of ${total} is highlighted`\n : null;\n\n if (this.index === null && this.type === 'autocomplete') {\n selectionText = this.items.length\n ? `${this.items.length} result${\n this.items.length !== 1 ? 's' : ''\n } available`\n : 'No search results available';\n }\n\n this.statusText = `${selectionText || ending}`;\n\n this._debounce = null;\n }, 1400);\n }\n\n render() {\n if (\n !this._isMobile &&\n this._dialog &&\n this.itemsPerPage &&\n this.itemsPerPage > 0 &&\n this.items.length > this.itemsPerPage\n ) {\n this._dialog.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 60 + 'px';\n this._list.style.maxHeight = 42 * (this.itemsPerPage + 0.5) + 'px';\n }\n\n return (\n <Host>\n <slot name=\"default\"></slot>\n\n <div class=\"dummy\" ref={(el) => (this._dummyElement = el)}></div>\n\n <dialog\n tabindex=\"-1\"\n ref={(el) => (this._dialog = el)}\n class={{ mobile: this._isMobile }}\n onCancel={() => this.close()}\n >\n <div\n id={'announce-' + this.hostId}\n class=\"visuallyhidden\"\n aria-live=\"polite\"\n aria-atomic=\"true\"\n >\n {this.statusText}\n </div>\n\n <div class=\"input-top-wrapper\">\n <slot name=\"input-top\"></slot>\n </div>\n\n <ul\n ref={(el) => (this._list = el)}\n id={`${this.hostId}--results`}\n role=\"listbox\"\n aria-expanded={this.isOpen.toString()}\n class={{ active: this.isOpen, mobile: this._isMobile }}\n tabindex=\"-1\"\n >\n {this.renderedList}\n </ul>\n\n <div\n class={{ active: this._openedOnTop, 'input-bottom-wrapper': true }}\n >\n <slot name=\"input-bottom\"></slot>\n </div>\n </dialog>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { proxyCustomElement, HTMLElement, createEvent, h, Host } from '@stencil/core/internal/client';
|
|
2
|
+
import { g as getScrollParent } from './getScrollParent.js';
|
|
2
3
|
|
|
3
4
|
const cMenuItemsCss = "html{box-sizing:border-box}*,*:before,*:after{box-sizing:inherit;-webkit-tap-highlight-color:transparent}:host{font-family:var(--c-font-family)}::-ms-reveal{display:none}:host,:root{--_c-menu-items-background-color-hover:var(--c-menu-items-background-color-hover, var(--c-primary-200));--_c-menu-items-text-color:var(--c-menu-items-text-color, var(--c-text-body));--_c-menu-items-text-color-active:var(--c-menu-items-text-color-active, var(--c-primary-600));position:absolute;border-radius:inherit;display:flex;pointer-events:none;inset:inherit}ul.c-menu-items{--_c-menu-item-font-size:14px;margin:0;padding:0;background-color:var(--c-white);list-style:none;animation:0.1s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);box-shadow:2px 4px 10px rgba(0, 0, 0, 0.1607843137);width:100%;overflow-y:scroll;pointer-events:auto;border-radius:4px;visibility:hidden}ul.c-menu-items--small{--_c-menu-item-font-size:12px}ul.c-menu-items--active{visibility:visible}li{align-items:center;background:var(--c-white);column-gap:12px;cursor:pointer;display:flex;flex-wrap:nowrap;font-size:var(--_c-menu-item-font-size);height:var(--_c-menu-item-height);padding-left:10px;padding-right:10px;outline:none;white-space:nowrap;pointer-events:auto}li:not(.disabled):hover,li.active{background:var(--_c-menu-items-background-color-hover);color:var(--_c-menu-items-text-color-active)}li.icon-start{flex-direction:row-reverse;justify-content:flex-end}li.icon-end{justify-content:space-between}li.disabled{cursor:default;color:var(--c-tertiary-400)}@keyframes fade-in{from{opacity:0;transform:translateY(-8px)}to{opacity:1;transform:translateY(0)}}";
|
|
4
5
|
|
|
@@ -126,7 +127,7 @@ const CMenuItems = proxyCustomElement(class CMenuItems extends HTMLElement {
|
|
|
126
127
|
const { bottom, right, height, width } = this._listElement.getBoundingClientRect();
|
|
127
128
|
const { top: parentTop } = this.parent.getBoundingClientRect();
|
|
128
129
|
this._parentTop = parentTop;
|
|
129
|
-
this.scrollingParent = await
|
|
130
|
+
this.scrollingParent = await getScrollParent(this.parent);
|
|
130
131
|
this._boundFn = this._onScroll.bind(this);
|
|
131
132
|
this.scrollingParent.addEventListener('scroll', this._boundFn);
|
|
132
133
|
this.open.emit({
|
|
@@ -139,28 +140,6 @@ const CMenuItems = proxyCustomElement(class CMenuItems extends HTMLElement {
|
|
|
139
140
|
});
|
|
140
141
|
});
|
|
141
142
|
}
|
|
142
|
-
async _getScrollParent(element) {
|
|
143
|
-
return new Promise((resolve) => {
|
|
144
|
-
if (!element) {
|
|
145
|
-
resolve(undefined);
|
|
146
|
-
}
|
|
147
|
-
let parent = element.parentNode;
|
|
148
|
-
while (parent) {
|
|
149
|
-
if (parent.shadowRoot === undefined) {
|
|
150
|
-
parent = parent.host;
|
|
151
|
-
}
|
|
152
|
-
else {
|
|
153
|
-
const { overflow, overflowX } = window.getComputedStyle(parent);
|
|
154
|
-
if (overflowX !== 'scroll' &&
|
|
155
|
-
overflow.split(' ').every((o) => o === 'auto' || o === 'scroll')) {
|
|
156
|
-
resolve(parent);
|
|
157
|
-
}
|
|
158
|
-
parent = parent.parentNode;
|
|
159
|
-
}
|
|
160
|
-
}
|
|
161
|
-
resolve(document.documentElement);
|
|
162
|
-
});
|
|
163
|
-
}
|
|
164
143
|
_onScroll() {
|
|
165
144
|
const { top: parentTop } = this.parent.getBoundingClientRect();
|
|
166
145
|
const differenceY = this._parentTop - parentTop;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"file":"c-menu-items2.js","mappings":";;AAAA,MAAM,aAAa,GAAG,klDAAklD;;MCsB3lD,UAAU;;;;;;;IA+Kb,eAAU,GAAG,CAAC,CAAC;IAEf,gBAAW,GAAG,EAAE,CAAC;IAEjB,qBAAgB,GAAG,EAAE,CAAC;IAyHtB,gB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H,UAAI,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,IAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC9C,CACA,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/c-menu-items/c-menu-items.scss?tag=c-menu-items&encapsulation=shadow","src/components/c-menu-items/c-menu-items.tsx"],"sourcesContent":[":host,\n:root {\n /**\n * @prop --c-menu-items-background-color-hover: Menu item hover background color\n * @prop --c-menu-items-text-color: Menu item text color\n * @prop --c-menu-items-text-color-active: Active menu item text color\n */\n --_c-menu-items-background-color-hover: var(--c-menu-items-background-color-hover, var(--c-primary-200));\n --_c-menu-items-text-color: var(--c-menu-items-text-color, var(--c-text-body));\n --_c-menu-items-text-color-active: var(--c-menu-items-text-color-active, var(--c-primary-600));\n\n position: absolute;\n border-radius: inherit;\n display: flex;\n pointer-events: none;\n inset: inherit;\n}\n\nul.c-menu-items {\n --_c-menu-item-font-size: 14px;\n\n margin: 0;\n padding: 0;\n background-color: var(--c-white);\n list-style: none;\n animation: 0.1s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n box-shadow: 2px 4px 10px #00000029;\n width: 100%;\n overflow-y: scroll;\n pointer-events: auto;\n border-radius: 4px;\n visibility: hidden;\n\n &--small {\n --_c-menu-item-font-size: 12px;\n }\n\n &--active {\n visibility: visible;\n }\n}\n\nli {\n align-items: center;\n background: var(--c-white);\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-menu-item-font-size);\n height: var(--_c-menu-item-height);\n padding-left: 10px;\n padding-right: 10px;\n outline: none;\n white-space: nowrap;\n pointer-events: auto;\n\n &:not(.disabled):hover,\n &.active {\n background: var(--_c-menu-items-background-color-hover);\n color: var(--_c-menu-items-text-color-active);\n }\n\n &.icon-start {\n flex-direction: row-reverse;\n justify-content: flex-end;\n }\n\n &.icon-end {\n justify-content: space-between;\n }\n\n &.disabled {\n cursor: default;\n color: var(--c-tertiary-400);\n }\n}\n\n@keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n","import {\n Component,\n Host,\n h,\n Element,\n Event,\n EventEmitter,\n Prop,\n State,\n Listen,\n Watch,\n} from '@stencil/core';\nimport { CMenuOption } from '../../types';\n\n/**\n * @parent c-menu\n */\n@Component({\n tag: 'c-menu-items',\n styleUrl: 'c-menu-items.scss',\n shadow: true,\n})\nexport class CMenuItems {\n @Element() host: HTMLCMenuItemsElement;\n\n /**\n * Menu items\n * @private\n */\n @Prop() items: CMenuOption[] = [];\n\n /**\n * Small variant\n * @private\n */\n @Prop() small = false;\n\n /**\n * Menu is opened and positioned\n * @private\n */\n @Prop() active = false;\n\n /**\n * Type of parent\n * @private\n */\n @Prop() parentType = 'menu';\n\n /**\n * Menu parent\n * @private\n */\n @Prop() parent: HTMLCMenuElement;\n\n /**\n * Initial top position\n * @private\n */\n @Prop() top = 0;\n\n /**\n * is active\n * @private\n */\n @Prop() index: number | null = null;\n\n /**\n * Items per page before adding scroll\n * @private\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Triggered when the menu is closed\n * @private\n */\n @Event() close: EventEmitter;\n\n /**\n * Triggered when the menu is opened\n * @private\n */\n @Event() open: EventEmitter<{\n height: number;\n width: number;\n isInView: {\n x: boolean;\n y: boolean;\n };\n }>;\n\n @State() scrollingParent: Element;\n\n @State() isInView = true;\n\n @State() currentIndex: number = null;\n\n @Watch('currentIndex')\n onIndexChange(index: number) {\n this.listItems.forEach((item, i) => {\n item.classList.toggle('active', i === index);\n\n if (i === index) {\n item.focus();\n }\n });\n }\n\n @Listen('keydown', { capture: true })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (this.currentIndex === null) {\n this.currentIndex = 0;\n } else if (this.currentIndex + 1 < this.items.length) {\n this.currentIndex += 1;\n }\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (this.currentIndex === null) {\n this.currentIndex = this.items.length - 1;\n } else if (this.currentIndex > 0) {\n this.currentIndex -= 1;\n }\n }\n\n if (event.key === 'Escape') {\n this.close.emit();\n this.currentIndex = null;\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (!item.disabled) {\n item.action();\n this.close.emit();\n }\n\n return;\n }\n\n this.currentIndex = 0;\n }\n\n if (event.key === ' ') {\n event.preventDefault();\n\n if (this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (item?.disabled) return;\n\n item?.action();\n }\n\n this.close.emit();\n }\n\n if (event.key === 'Tab') {\n if (this.parentType !== 'menu' && this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (!item?.disabled) {\n item?.action();\n }\n }\n\n this.close.emit();\n }\n\n if (event.key === 'PageUp') {\n this.currentIndex = Math.max(0, this.currentIndex - this.itemsPerPage);\n }\n\n if (event.key === 'PageDown') {\n this.currentIndex = Math.min(\n this.items.length - 1,\n this.currentIndex + this.itemsPerPage,\n );\n }\n }\n\n private _listElement: HTMLUListElement;\n\n private _boundFn: () => void;\n\n private _boundClickFn: () => void;\n\n private _parentTop = 0;\n\n private _itemHeight = 42;\n\n private _itemHeightSmall = 36;\n\n get listItems(): HTMLLIElement[] {\n return Array.from(this.host?.shadowRoot?.querySelectorAll('li') || []);\n }\n\n private _handleItemsPerPage() {\n const itemHeight = this.small ? this._itemHeightSmall : this._itemHeight;\n\n const containerHeight = this.itemsPerPage * itemHeight + itemHeight / 2;\n\n this._listElement.style.maxHeight = `${containerHeight}px`;\n this._listElement.style.setProperty(\n '--_c-menu-item-height',\n `${itemHeight}px`,\n );\n }\n\n private _onOpen() {\n this._handleItemsPerPage();\n\n window.requestAnimationFrame(async () => {\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const { bottom, right, height, width } =\n this._listElement.getBoundingClientRect();\n\n const { top: parentTop } = this.parent.getBoundingClientRect();\n\n this._parentTop = parentTop;\n\n this.scrollingParent = await this._getScrollParent(this.parent);\n\n this._boundFn = this._onScroll.bind(this);\n\n this.scrollingParent.addEventListener('scroll', this._boundFn);\n\n this.open.emit({\n height,\n isInView: {\n x: right < viewportWidth,\n y: bottom < viewportHeight,\n },\n width,\n });\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 private _onScroll() {\n const { top: parentTop } = this.parent.getBoundingClientRect();\n\n const differenceY = this._parentTop - parentTop;\n\n this.host.style.top = `${this.top - differenceY}px`;\n }\n\n private _handleClick(event) {\n if (!event.composedPath().includes(this.host)) {\n this.close.emit();\n }\n }\n\n private _handleZIndex() {\n const styles = window.getComputedStyle(\n (this.parent.assignedSlot || this.parent).parentElement,\n );\n\n const zIndex = styles.getPropertyValue('z-index');\n\n this.host.style.zIndex = zIndex === 'auto' ? '1' : zIndex;\n }\n\n componentDidLoad() {\n this._boundClickFn = this._handleClick.bind(this);\n\n window.addEventListener('click', this._boundClickFn, {\n once: true,\n });\n\n this._handleZIndex();\n\n this._onOpen();\n\n this.currentIndex = this.index;\n }\n\n disconnectedCallback() {\n this.scrollingParent.removeEventListener('scroll', this._boundFn);\n window.removeEventListener('click', this._boundClickFn);\n }\n\n private _renderItem = (item) => {\n const classes = {\n disabled: item.disabled,\n 'icon-start': item.iconPosition === 'start',\n 'icon-end': item.iconPosition === 'end',\n };\n\n const onItemClick = (event, item) => {\n event.stopPropagation();\n\n if (!item.disabled) {\n item.action();\n\n this.close.emit();\n }\n };\n\n return (\n <li\n aria-disabled={(!!item.disabled).toString()}\n class={classes}\n tabindex=\"-1\"\n role=\"menuitem\"\n onClick={(event) => onItemClick(event, item)}\n >\n {item.name}\n\n {item.icon && (\n <svg class=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\">\n <path d={item.icon} />\n </svg>\n )}\n </li>\n );\n };\n\n render() {\n const listClasses = {\n 'c-menu-items': true,\n 'c-menu-items--small': this.small,\n 'c-menu-items--active': this.active,\n };\n\n return (\n <Host>\n <ul class={listClasses} ref={(el) => (this._listElement = el)}>\n {this.items.map((item) => this._renderItem(item))}\n </ul>\n </Host>\n );\n }\n}\n"],"version":3}
|
|
1
|
+
{"file":"c-menu-items2.js","mappings":";;;AAAA,MAAM,aAAa,GAAG,klDAAklD;;MCuB3lD,UAAU;;;;;;;IA+Kb,eAAU,GAAG,CAAC,CAAC;IAEf,gBAAW,GAAG,EAAE,CAAC;IAEjB,qBAAgB,GAAG,EAAE,CAAC;IA4FtB,gBAAW,GAAG,CAAC,IAAI;MACzB,MAAM,OAAO,GAAG;QACd,QAAQ,EAAE,IAAI,CAAC,QAAQ;QACvB,YAAY,EAAE,IAAI,CAAC,YAAY,KAAK,OAAO;QAC3C,UAAU,EAAE,IAAI,CAAC,YAAY,KAAK,KAAK;OACxC,CAAC;MAEF,MAAM,WAAW,GAAG,CAAC,KAAK,EAAE,IAAI;QAC9B,KAAK,CAAC,eAAe,EAAE,CAAC;QAExB,IAAI,CAAC,IAAI,CAAC,QAAQ,EAAE;UAClB,IAAI,CAAC,MAAM,EAAE,CAAC;UAEd,IAAI,CAAC,KAAK,CAAC,IAAI,EAAE,CAAC;SACnB;OACF,CAAC;MAEF,QACE,2BACiB,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,E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,KAAK,EAAE,WAAW,EAAE,GAAG,EAAE,CAAC,EAAE,MAAM,IAAI,CAAC,YAAY,GAAG,EAAE,CAAC,IAC1D,IAAI,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,KAAK,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC,CAAC,CAC9C,CACA,EACP;GACH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;","names":[],"sources":["src/components/c-menu-items/c-menu-items.scss?tag=c-menu-items&encapsulation=shadow","src/components/c-menu-items/c-menu-items.tsx"],"sourcesContent":[":host,\n:root {\n /**\n * @prop --c-menu-items-background-color-hover: Menu item hover background color\n * @prop --c-menu-items-text-color: Menu item text color\n * @prop --c-menu-items-text-color-active: Active menu item text color\n */\n --_c-menu-items-background-color-hover: var(--c-menu-items-background-color-hover, var(--c-primary-200));\n --_c-menu-items-text-color: var(--c-menu-items-text-color, var(--c-text-body));\n --_c-menu-items-text-color-active: var(--c-menu-items-text-color-active, var(--c-primary-600));\n\n position: absolute;\n border-radius: inherit;\n display: flex;\n pointer-events: none;\n inset: inherit;\n}\n\nul.c-menu-items {\n --_c-menu-item-font-size: 14px;\n\n margin: 0;\n padding: 0;\n background-color: var(--c-white);\n list-style: none;\n animation: 0.1s 1 fade-in cubic-bezier(0.25, 0.8, 0.5, 1);\n box-shadow: 2px 4px 10px #00000029;\n width: 100%;\n overflow-y: scroll;\n pointer-events: auto;\n border-radius: 4px;\n visibility: hidden;\n\n &--small {\n --_c-menu-item-font-size: 12px;\n }\n\n &--active {\n visibility: visible;\n }\n}\n\nli {\n align-items: center;\n background: var(--c-white);\n column-gap: 12px;\n cursor: pointer;\n display: flex;\n flex-wrap: nowrap;\n font-size: var(--_c-menu-item-font-size);\n height: var(--_c-menu-item-height);\n padding-left: 10px;\n padding-right: 10px;\n outline: none;\n white-space: nowrap;\n pointer-events: auto;\n\n &:not(.disabled):hover,\n &.active {\n background: var(--_c-menu-items-background-color-hover);\n color: var(--_c-menu-items-text-color-active);\n }\n\n &.icon-start {\n flex-direction: row-reverse;\n justify-content: flex-end;\n }\n\n &.icon-end {\n justify-content: space-between;\n }\n\n &.disabled {\n cursor: default;\n color: var(--c-tertiary-400);\n }\n}\n\n@keyframes fade-in {\n from {\n opacity: 0;\n transform: translateY(-8px);\n }\n\n to {\n opacity: 1;\n transform: translateY(0);\n }\n}\n","import {\n Component,\n Host,\n h,\n Element,\n Event,\n EventEmitter,\n Prop,\n State,\n Listen,\n Watch,\n} from '@stencil/core';\nimport { CMenuOption } from '../../types';\nimport { getScrollParent } from '../../utils';\n\n/**\n * @parent c-menu\n */\n@Component({\n tag: 'c-menu-items',\n styleUrl: 'c-menu-items.scss',\n shadow: true,\n})\nexport class CMenuItems {\n @Element() host: HTMLCMenuItemsElement;\n\n /**\n * Menu items\n * @private\n */\n @Prop() items: CMenuOption[] = [];\n\n /**\n * Small variant\n * @private\n */\n @Prop() small = false;\n\n /**\n * Menu is opened and positioned\n * @private\n */\n @Prop() active = false;\n\n /**\n * Type of parent\n * @private\n */\n @Prop() parentType = 'menu';\n\n /**\n * Menu parent\n * @private\n */\n @Prop() parent: HTMLCMenuElement;\n\n /**\n * Initial top position\n * @private\n */\n @Prop() top = 0;\n\n /**\n * is active\n * @private\n */\n @Prop() index: number | null = null;\n\n /**\n * Items per page before adding scroll\n * @private\n */\n @Prop() itemsPerPage = 6;\n\n /**\n * Triggered when the menu is closed\n * @private\n */\n @Event() close: EventEmitter;\n\n /**\n * Triggered when the menu is opened\n * @private\n */\n @Event() open: EventEmitter<{\n height: number;\n width: number;\n isInView: {\n x: boolean;\n y: boolean;\n };\n }>;\n\n @State() scrollingParent: Element;\n\n @State() isInView = true;\n\n @State() currentIndex: number = null;\n\n @Watch('currentIndex')\n onIndexChange(index: number) {\n this.listItems.forEach((item, i) => {\n item.classList.toggle('active', i === index);\n\n if (i === index) {\n item.focus();\n }\n });\n }\n\n @Listen('keydown', { capture: true })\n handleKeyDown(event: KeyboardEvent) {\n if (event.key === 'ArrowDown') {\n event.preventDefault();\n\n if (this.currentIndex === null) {\n this.currentIndex = 0;\n } else if (this.currentIndex + 1 < this.items.length) {\n this.currentIndex += 1;\n }\n }\n\n if (event.key === 'ArrowUp') {\n event.preventDefault();\n\n if (this.currentIndex === null) {\n this.currentIndex = this.items.length - 1;\n } else if (this.currentIndex > 0) {\n this.currentIndex -= 1;\n }\n }\n\n if (event.key === 'Escape') {\n this.close.emit();\n this.currentIndex = null;\n }\n\n if (event.key === 'Enter') {\n event.preventDefault();\n\n if (this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (!item.disabled) {\n item.action();\n this.close.emit();\n }\n\n return;\n }\n\n this.currentIndex = 0;\n }\n\n if (event.key === ' ') {\n event.preventDefault();\n\n if (this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (item?.disabled) return;\n\n item?.action();\n }\n\n this.close.emit();\n }\n\n if (event.key === 'Tab') {\n if (this.parentType !== 'menu' && this.currentIndex !== null) {\n const item = this.items[this.currentIndex];\n\n if (!item?.disabled) {\n item?.action();\n }\n }\n\n this.close.emit();\n }\n\n if (event.key === 'PageUp') {\n this.currentIndex = Math.max(0, this.currentIndex - this.itemsPerPage);\n }\n\n if (event.key === 'PageDown') {\n this.currentIndex = Math.min(\n this.items.length - 1,\n this.currentIndex + this.itemsPerPage,\n );\n }\n }\n\n private _listElement: HTMLUListElement;\n\n private _boundFn: () => void;\n\n private _boundClickFn: () => void;\n\n private _parentTop = 0;\n\n private _itemHeight = 42;\n\n private _itemHeightSmall = 36;\n\n get listItems(): HTMLLIElement[] {\n return Array.from(this.host?.shadowRoot?.querySelectorAll('li') || []);\n }\n\n private _handleItemsPerPage() {\n const itemHeight = this.small ? this._itemHeightSmall : this._itemHeight;\n\n const containerHeight = this.itemsPerPage * itemHeight + itemHeight / 2;\n\n this._listElement.style.maxHeight = `${containerHeight}px`;\n this._listElement.style.setProperty(\n '--_c-menu-item-height',\n `${itemHeight}px`,\n );\n }\n\n private _onOpen() {\n this._handleItemsPerPage();\n\n window.requestAnimationFrame(async () => {\n const viewportHeight = window.innerHeight;\n const viewportWidth = window.innerWidth;\n\n const { bottom, right, height, width } =\n this._listElement.getBoundingClientRect();\n\n const { top: parentTop } = this.parent.getBoundingClientRect();\n\n this._parentTop = parentTop;\n\n this.scrollingParent = await getScrollParent(this.parent);\n\n this._boundFn = this._onScroll.bind(this);\n\n this.scrollingParent.addEventListener('scroll', this._boundFn);\n\n this.open.emit({\n height,\n isInView: {\n x: right < viewportWidth,\n y: bottom < viewportHeight,\n },\n width,\n });\n });\n }\n\n private _onScroll() {\n const { top: parentTop } = this.parent.getBoundingClientRect();\n\n const differenceY = this._parentTop - parentTop;\n\n this.host.style.top = `${this.top - differenceY}px`;\n }\n\n private _handleClick(event) {\n if (!event.composedPath().includes(this.host)) {\n this.close.emit();\n }\n }\n\n private _handleZIndex() {\n const styles = window.getComputedStyle(\n (this.parent.assignedSlot || this.parent).parentElement,\n );\n\n const zIndex = styles.getPropertyValue('z-index');\n\n this.host.style.zIndex = zIndex === 'auto' ? '1' : zIndex;\n }\n\n componentDidLoad() {\n this._boundClickFn = this._handleClick.bind(this);\n\n window.addEventListener('click', this._boundClickFn, {\n once: true,\n });\n\n this._handleZIndex();\n\n this._onOpen();\n\n this.currentIndex = this.index;\n }\n\n disconnectedCallback() {\n this.scrollingParent.removeEventListener('scroll', this._boundFn);\n window.removeEventListener('click', this._boundClickFn);\n }\n\n private _renderItem = (item) => {\n const classes = {\n disabled: item.disabled,\n 'icon-start': item.iconPosition === 'start',\n 'icon-end': item.iconPosition === 'end',\n };\n\n const onItemClick = (event, item) => {\n event.stopPropagation();\n\n if (!item.disabled) {\n item.action();\n\n this.close.emit();\n }\n };\n\n return (\n <li\n aria-disabled={(!!item.disabled).toString()}\n class={classes}\n tabindex=\"-1\"\n role=\"menuitem\"\n onClick={(event) => onItemClick(event, item)}\n >\n {item.name}\n\n {item.icon && (\n <svg class=\"icon\" width=\"20\" height=\"20\" viewBox=\"0 0 24 24\">\n <path d={item.icon} />\n </svg>\n )}\n </li>\n );\n };\n\n render() {\n const listClasses = {\n 'c-menu-items': true,\n 'c-menu-items--small': this.small,\n 'c-menu-items--active': this.active,\n };\n\n return (\n <Host>\n <ul class={listClasses} ref={(el) => (this._listElement = el)}>\n {this.items.map((item) => this._renderItem(item))}\n </ul>\n </Host>\n );\n }\n}\n"],"version":3}
|