snice 1.13.2 → 1.13.4
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/bin/templates/base/README.md +1 -1
- package/dist/components/accordion/snice-accordion-item.d.ts +25 -0
- package/dist/components/accordion/snice-accordion-item.js +260 -0
- package/dist/components/accordion/snice-accordion-item.js.map +1 -0
- package/dist/components/accordion/snice-accordion.d.ts +28 -0
- package/dist/components/accordion/snice-accordion.js +221 -0
- package/dist/components/accordion/snice-accordion.js.map +1 -0
- package/dist/components/accordion/snice-accordion.types.d.ts +29 -0
- package/dist/components/accordion/snice-accordion.types.js +2 -0
- package/dist/components/accordion/snice-accordion.types.js.map +1 -0
- package/dist/components/alert/snice-alert.d.ts +26 -0
- package/dist/components/alert/snice-alert.js +191 -0
- package/dist/components/alert/snice-alert.js.map +1 -0
- package/dist/components/alert/snice-alert.types.d.ts +11 -0
- package/dist/components/alert/snice-alert.types.js +2 -0
- package/dist/components/alert/snice-alert.types.js.map +1 -0
- package/dist/components/avatar/snice-avatar.d.ts +24 -0
- package/dist/components/avatar/snice-avatar.js +177 -0
- package/dist/components/avatar/snice-avatar.js.map +1 -0
- package/dist/components/avatar/snice-avatar.types.d.ts +12 -0
- package/dist/components/avatar/snice-avatar.types.js +2 -0
- package/dist/components/avatar/snice-avatar.types.js.map +1 -0
- package/dist/components/badge/snice-badge.d.ts +25 -0
- package/dist/components/badge/snice-badge.js +157 -0
- package/dist/components/badge/snice-badge.js.map +1 -0
- package/dist/components/badge/snice-badge.types.d.ts +15 -0
- package/dist/components/badge/snice-badge.types.js +2 -0
- package/dist/components/badge/snice-badge.types.js.map +1 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.d.ts +27 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +212 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.types.d.ts +23 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.types.js +2 -0
- package/dist/components/breadcrumbs/snice-breadcrumbs.types.js.map +1 -0
- package/dist/components/breadcrumbs/snice-crumb.d.ts +9 -0
- package/dist/components/breadcrumbs/snice-crumb.js +50 -0
- package/dist/components/breadcrumbs/snice-crumb.js.map +1 -0
- package/dist/components/button/snice-button.d.ts +32 -0
- package/dist/components/button/snice-button.js +212 -0
- package/dist/components/button/snice-button.js.map +1 -0
- package/dist/components/button/snice-button.types.d.ts +23 -0
- package/dist/components/button/snice-button.types.js +2 -0
- package/dist/components/button/snice-button.types.js.map +1 -0
- package/dist/components/card/snice-card.d.ts +19 -0
- package/dist/components/card/snice-card.js +132 -0
- package/dist/components/card/snice-card.js.map +1 -0
- package/dist/components/card/snice-card.types.d.ts +9 -0
- package/dist/components/card/snice-card.types.js +2 -0
- package/dist/components/card/snice-card.types.js.map +1 -0
- package/dist/components/checkbox/snice-checkbox.d.ts +34 -0
- package/dist/components/checkbox/snice-checkbox.js +289 -0
- package/dist/components/checkbox/snice-checkbox.js.map +1 -0
- package/dist/components/checkbox/snice-checkbox.types.d.ts +20 -0
- package/dist/components/checkbox/snice-checkbox.types.js +2 -0
- package/dist/components/checkbox/snice-checkbox.types.js.map +1 -0
- package/dist/components/chip/snice-chip.d.ts +28 -0
- package/dist/components/chip/snice-chip.js +203 -0
- package/dist/components/chip/snice-chip.js.map +1 -0
- package/dist/components/chip/snice-chip.types.d.ts +14 -0
- package/dist/components/chip/snice-chip.types.js +2 -0
- package/dist/components/chip/snice-chip.types.js.map +1 -0
- package/dist/components/date-picker/snice-date-picker.d.ts +82 -0
- package/dist/components/date-picker/snice-date-picker.js +880 -0
- package/dist/components/date-picker/snice-date-picker.js.map +1 -0
- package/dist/components/date-picker/snice-date-picker.types.d.ts +71 -0
- package/dist/components/date-picker/snice-date-picker.types.js +2 -0
- package/dist/components/date-picker/snice-date-picker.types.js.map +1 -0
- package/dist/components/divider/snice-divider.d.ts +17 -0
- package/dist/components/divider/snice-divider.js +111 -0
- package/dist/components/divider/snice-divider.js.map +1 -0
- package/dist/components/divider/snice-divider.types.d.ts +14 -0
- package/dist/components/divider/snice-divider.types.js +2 -0
- package/dist/components/divider/snice-divider.types.js.map +1 -0
- package/dist/components/drawer/snice-drawer.d.ts +37 -0
- package/dist/components/drawer/snice-drawer.js +335 -0
- package/dist/components/drawer/snice-drawer.js.map +1 -0
- package/dist/components/drawer/snice-drawer.types.d.ts +16 -0
- package/dist/components/drawer/snice-drawer.types.js +2 -0
- package/dist/components/drawer/snice-drawer.types.js.map +1 -0
- package/dist/components/input/snice-input.d.ts +65 -0
- package/dist/components/input/snice-input.js +603 -0
- package/dist/components/input/snice-input.js.map +1 -0
- package/dist/components/input/snice-input.types.d.ts +53 -0
- package/dist/components/input/snice-input.types.js +2 -0
- package/dist/components/input/snice-input.types.js.map +1 -0
- package/dist/components/layout/snice-layout-blog.d.ts +4 -0
- package/dist/components/layout/snice-layout-blog.js +56 -0
- package/dist/components/layout/snice-layout-blog.js.map +1 -0
- package/dist/components/layout/snice-layout-card.d.ts +6 -0
- package/dist/components/layout/snice-layout-card.js +53 -0
- package/dist/components/layout/snice-layout-card.js.map +1 -0
- package/dist/components/layout/snice-layout-centered.d.ts +5 -0
- package/dist/components/layout/snice-layout-centered.js +38 -0
- package/dist/components/layout/snice-layout-centered.js.map +1 -0
- package/dist/components/layout/snice-layout-dashboard.d.ts +4 -0
- package/dist/components/layout/snice-layout-dashboard.js +53 -0
- package/dist/components/layout/snice-layout-dashboard.js.map +1 -0
- package/dist/components/layout/snice-layout-fullscreen.d.ts +5 -0
- package/dist/components/layout/snice-layout-fullscreen.js +50 -0
- package/dist/components/layout/snice-layout-fullscreen.js.map +1 -0
- package/dist/components/layout/snice-layout-landing.d.ts +4 -0
- package/dist/components/layout/snice-layout-landing.js +55 -0
- package/dist/components/layout/snice-layout-landing.js.map +1 -0
- package/dist/components/layout/snice-layout-minimal.d.ts +4 -0
- package/dist/components/layout/snice-layout-minimal.js +27 -0
- package/dist/components/layout/snice-layout-minimal.js.map +1 -0
- package/dist/components/layout/snice-layout-sidebar.d.ts +5 -0
- package/dist/components/layout/snice-layout-sidebar.js +64 -0
- package/dist/components/layout/snice-layout-sidebar.js.map +1 -0
- package/dist/components/layout/snice-layout-split.d.ts +6 -0
- package/dist/components/layout/snice-layout-split.js +47 -0
- package/dist/components/layout/snice-layout-split.js.map +1 -0
- package/dist/components/layout/snice-layout.d.ts +4 -0
- package/dist/components/layout/snice-layout.js +43 -0
- package/dist/components/layout/snice-layout.js.map +1 -0
- package/dist/components/layout/snice-layout.types.d.ts +3 -0
- package/dist/components/layout/snice-layout.types.js +2 -0
- package/dist/components/layout/snice-layout.types.js.map +1 -0
- package/dist/components/login/snice-login.d.ts +45 -0
- package/dist/components/login/snice-login.js +385 -0
- package/dist/components/login/snice-login.js.map +1 -0
- package/dist/components/login/snice-login.types.d.ts +31 -0
- package/dist/components/login/snice-login.types.js +2 -0
- package/dist/components/login/snice-login.types.js.map +1 -0
- package/dist/components/modal/snice-modal.d.ts +32 -0
- package/dist/components/modal/snice-modal.js +288 -0
- package/dist/components/modal/snice-modal.js.map +1 -0
- package/dist/components/modal/snice-modal.types.d.ts +18 -0
- package/dist/components/modal/snice-modal.types.js +2 -0
- package/dist/components/modal/snice-modal.types.js.map +1 -0
- package/dist/components/pagination/snice-pagination.d.ts +26 -0
- package/dist/components/pagination/snice-pagination.js +373 -0
- package/dist/components/pagination/snice-pagination.js.map +1 -0
- package/dist/components/pagination/snice-pagination.types.d.ts +18 -0
- package/dist/components/pagination/snice-pagination.types.js +2 -0
- package/dist/components/pagination/snice-pagination.types.js.map +1 -0
- package/dist/components/progress/snice-progress.d.ts +35 -0
- package/dist/components/progress/snice-progress.js +295 -0
- package/dist/components/progress/snice-progress.js.map +1 -0
- package/dist/components/progress/snice-progress.types.d.ts +18 -0
- package/dist/components/progress/snice-progress.types.js +2 -0
- package/dist/components/progress/snice-progress.types.js.map +1 -0
- package/dist/components/radio/snice-radio.d.ts +33 -0
- package/dist/components/radio/snice-radio.js +286 -0
- package/dist/components/radio/snice-radio.js.map +1 -0
- package/dist/components/radio/snice-radio.types.d.ts +19 -0
- package/dist/components/radio/snice-radio.types.js +2 -0
- package/dist/components/radio/snice-radio.types.js.map +1 -0
- package/dist/components/select/snice-option.d.ts +17 -0
- package/dist/components/select/snice-option.js +77 -0
- package/dist/components/select/snice-option.js.map +1 -0
- package/dist/components/select/snice-option.types.d.ts +14 -0
- package/dist/components/select/snice-option.types.js +2 -0
- package/dist/components/select/snice-option.types.js.map +1 -0
- package/dist/components/select/snice-select.d.ts +89 -0
- package/dist/components/select/snice-select.js +900 -0
- package/dist/components/select/snice-select.js.map +1 -0
- package/dist/components/select/snice-select.types.d.ts +49 -0
- package/dist/components/select/snice-select.types.js +2 -0
- package/dist/components/select/snice-select.types.js.map +1 -0
- package/dist/components/skeleton/snice-skeleton.d.ts +16 -0
- package/dist/components/skeleton/snice-skeleton.js +159 -0
- package/dist/components/skeleton/snice-skeleton.js.map +1 -0
- package/dist/components/skeleton/snice-skeleton.types.d.ts +10 -0
- package/dist/components/skeleton/snice-skeleton.types.js +2 -0
- package/dist/components/skeleton/snice-skeleton.types.js.map +1 -0
- package/dist/components/switch/snice-switch.d.ts +38 -0
- package/dist/components/switch/snice-switch.js +309 -0
- package/dist/components/switch/snice-switch.js.map +1 -0
- package/dist/components/switch/snice-switch.types.d.ts +21 -0
- package/dist/components/switch/snice-switch.types.js +2 -0
- package/dist/components/switch/snice-switch.types.js.map +1 -0
- package/dist/components/symbols.d.ts +1 -0
- package/dist/components/symbols.js +20 -0
- package/dist/components/symbols.js.map +1 -0
- package/dist/components/table/snice-cell-boolean.d.ts +21 -0
- package/dist/components/table/snice-cell-boolean.js +152 -0
- package/dist/components/table/snice-cell-boolean.js.map +1 -0
- package/dist/components/table/snice-cell-date.d.ts +24 -0
- package/dist/components/table/snice-cell-date.js +240 -0
- package/dist/components/table/snice-cell-date.js.map +1 -0
- package/dist/components/table/snice-cell-duration.d.ts +16 -0
- package/dist/components/table/snice-cell-duration.js +123 -0
- package/dist/components/table/snice-cell-duration.js.map +1 -0
- package/dist/components/table/snice-cell-filesize.d.ts +16 -0
- package/dist/components/table/snice-cell-filesize.js +119 -0
- package/dist/components/table/snice-cell-filesize.js.map +1 -0
- package/dist/components/table/snice-cell-number.d.ts +23 -0
- package/dist/components/table/snice-cell-number.js +202 -0
- package/dist/components/table/snice-cell-number.js.map +1 -0
- package/dist/components/table/snice-cell-progress.d.ts +17 -0
- package/dist/components/table/snice-cell-progress.js +114 -0
- package/dist/components/table/snice-cell-progress.js.map +1 -0
- package/dist/components/table/snice-cell-rating.d.ts +17 -0
- package/dist/components/table/snice-cell-rating.js +113 -0
- package/dist/components/table/snice-cell-rating.js.map +1 -0
- package/dist/components/table/snice-cell-sparkline.d.ts +29 -0
- package/dist/components/table/snice-cell-sparkline.js +290 -0
- package/dist/components/table/snice-cell-sparkline.js.map +1 -0
- package/dist/components/table/snice-cell-text.d.ts +19 -0
- package/dist/components/table/snice-cell-text.js +153 -0
- package/dist/components/table/snice-cell-text.js.map +1 -0
- package/dist/components/table/snice-cell.d.ts +32 -0
- package/dist/components/table/snice-cell.js +451 -0
- package/dist/components/table/snice-cell.js.map +1 -0
- package/dist/components/table/snice-column.d.ts +62 -0
- package/dist/components/table/snice-column.js +440 -0
- package/dist/components/table/snice-column.js.map +1 -0
- package/dist/components/table/snice-header.d.ts +33 -0
- package/dist/components/table/snice-header.js +303 -0
- package/dist/components/table/snice-header.js.map +1 -0
- package/dist/components/table/snice-progress.d.ts +10 -0
- package/dist/components/table/snice-progress.js +91 -0
- package/dist/components/table/snice-progress.js.map +1 -0
- package/dist/components/table/snice-rating.d.ts +9 -0
- package/dist/components/table/snice-rating.js +68 -0
- package/dist/components/table/snice-rating.js.map +1 -0
- package/dist/components/table/snice-row.d.ts +43 -0
- package/dist/components/table/snice-row.js +365 -0
- package/dist/components/table/snice-row.js.map +1 -0
- package/dist/components/table/snice-table.d.ts +69 -0
- package/dist/components/table/snice-table.js +814 -0
- package/dist/components/table/snice-table.js.map +1 -0
- package/dist/components/table/snice-table.types.d.ts +137 -0
- package/dist/components/table/snice-table.types.js +2 -0
- package/dist/components/table/snice-table.types.js.map +1 -0
- package/dist/components/tabs/snice-tab-panel.d.ts +12 -0
- package/dist/components/tabs/snice-tab-panel.js +78 -0
- package/dist/components/tabs/snice-tab-panel.js.map +1 -0
- package/dist/components/tabs/snice-tab.d.ts +13 -0
- package/dist/components/tabs/snice-tab.js +90 -0
- package/dist/components/tabs/snice-tab.js.map +1 -0
- package/dist/components/tabs/snice-tabs.d.ts +34 -0
- package/dist/components/tabs/snice-tabs.js +367 -0
- package/dist/components/tabs/snice-tabs.js.map +1 -0
- package/dist/components/tabs/snice-tabs.types.d.ts +23 -0
- package/dist/components/tabs/snice-tabs.types.js +2 -0
- package/dist/components/tabs/snice-tabs.types.js.map +1 -0
- package/dist/components/toast/snice-toast-container.d.ts +25 -0
- package/dist/components/toast/snice-toast-container.js +251 -0
- package/dist/components/toast/snice-toast-container.js.map +1 -0
- package/dist/components/toast/snice-toast.d.ts +23 -0
- package/dist/components/toast/snice-toast.js +316 -0
- package/dist/components/toast/snice-toast.js.map +1 -0
- package/dist/components/toast/snice-toast.types.d.ts +30 -0
- package/dist/components/toast/snice-toast.types.js +2 -0
- package/dist/components/toast/snice-toast.types.js.map +1 -0
- package/dist/components/tooltip/snice-tooltip.d.ts +50 -0
- package/dist/components/tooltip/snice-tooltip.js +656 -0
- package/dist/components/tooltip/snice-tooltip.js.map +1 -0
- package/dist/components/tooltip/snice-tooltip.types.d.ts +18 -0
- package/dist/components/tooltip/snice-tooltip.types.js +2 -0
- package/dist/components/tooltip/snice-tooltip.types.js.map +1 -0
- package/dist/components/transitions.d.ts +11 -0
- package/dist/components/transitions.js +69 -0
- package/dist/components/transitions.js.map +1 -0
- package/dist/src/controller.d.ts +61 -0
- package/dist/src/controller.js +297 -0
- package/dist/src/controller.js.map +1 -0
- package/dist/src/element.d.ts +77 -0
- package/dist/src/element.js +805 -0
- package/dist/src/element.js.map +1 -0
- package/dist/src/events.d.ts +37 -0
- package/dist/src/events.js +289 -0
- package/dist/src/events.js.map +1 -0
- package/dist/src/global.d.ts +7 -0
- package/dist/src/global.js +23 -0
- package/dist/src/global.js.map +1 -0
- package/{src/index.ts → dist/src/index.d.ts} +1 -1
- package/dist/src/index.js +8 -0
- package/dist/src/index.js.map +1 -0
- package/dist/src/observe.d.ts +26 -0
- package/dist/src/observe.js +329 -0
- package/dist/src/observe.js.map +1 -0
- package/dist/src/request-response.d.ts +46 -0
- package/dist/src/request-response.js +267 -0
- package/dist/src/request-response.js.map +1 -0
- package/dist/src/router.d.ts +87 -0
- package/dist/src/router.js +375 -0
- package/dist/src/router.js.map +1 -0
- package/dist/src/symbols.d.ts +29 -0
- package/{src/symbols.ts → dist/src/symbols.js} +2 -12
- package/dist/src/symbols.js.map +1 -0
- package/dist/src/transitions.d.ts +50 -0
- package/dist/src/transitions.js +199 -0
- package/dist/src/transitions.js.map +1 -0
- package/package.json +6 -8
- package/src/controller.ts +0 -347
- package/src/element.ts +0 -897
- package/src/events.ts +0 -349
- package/src/global.ts +0 -31
- package/src/observe.ts +0 -414
- package/src/request-response.ts +0 -336
- package/src/router.ts +0 -552
- package/src/transitions.ts +0 -264
|
@@ -0,0 +1,900 @@
|
|
|
1
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
2
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
3
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
4
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
|
+
};
|
|
7
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
8
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
|
+
};
|
|
10
|
+
import { element, property, query, queryAll, on, watch, dispatch, ready, dispose } from '../../src/index';
|
|
11
|
+
import css from './snice-select.css?inline';
|
|
12
|
+
import './snice-option';
|
|
13
|
+
let SniceSelect = class SniceSelect extends HTMLElement {
|
|
14
|
+
constructor() {
|
|
15
|
+
super(...arguments);
|
|
16
|
+
this.disabled = false;
|
|
17
|
+
this.required = false;
|
|
18
|
+
this.invalid = false;
|
|
19
|
+
this.readonly = false;
|
|
20
|
+
this.multiple = false;
|
|
21
|
+
this.searchable = false;
|
|
22
|
+
this.clearable = false;
|
|
23
|
+
this.open = false;
|
|
24
|
+
this.size = 'medium';
|
|
25
|
+
this.name = '';
|
|
26
|
+
this.value = '';
|
|
27
|
+
this.label = '';
|
|
28
|
+
this.placeholder = 'Select an option';
|
|
29
|
+
this.maxHeight = '200px';
|
|
30
|
+
// Options will be read from child snice-option elements
|
|
31
|
+
this.options = [];
|
|
32
|
+
this.filteredOptions = [];
|
|
33
|
+
this.selectedValues = new Set();
|
|
34
|
+
this.focusedIndex = -1;
|
|
35
|
+
}
|
|
36
|
+
html() {
|
|
37
|
+
// Initial render - options will be populated in @ready()
|
|
38
|
+
return /*html*/ `
|
|
39
|
+
<div class="select-wrapper">
|
|
40
|
+
<label class="select-label select-label--${this.size} ${this.required ? 'select-label--required' : ''}" part="label" ${!this.label ? 'hidden' : ''}>
|
|
41
|
+
${this.label}
|
|
42
|
+
</label>
|
|
43
|
+
|
|
44
|
+
<button
|
|
45
|
+
type="button"
|
|
46
|
+
class="select-trigger select-trigger--${this.size}"
|
|
47
|
+
aria-haspopup="listbox"
|
|
48
|
+
aria-expanded="false"
|
|
49
|
+
aria-label="${this.label || 'Select'}"
|
|
50
|
+
part="trigger">
|
|
51
|
+
|
|
52
|
+
<div class="select-value" part="value">
|
|
53
|
+
<span class="select-placeholder">${this.placeholder}</span>
|
|
54
|
+
</div>
|
|
55
|
+
|
|
56
|
+
<span class="select-icons">
|
|
57
|
+
<span class="select-clear" aria-label="Clear selection" style="display: none;">
|
|
58
|
+
<svg width="14" height="14" viewBox="0 0 14 14" fill="currentColor">
|
|
59
|
+
<path d="M14 1.41L12.59 0L7 5.59L1.41 0L0 1.41L5.59 7L0 12.59L1.41 14L7 8.41L12.59 14L14 12.59L8.41 7L14 1.41Z"/>
|
|
60
|
+
</svg>
|
|
61
|
+
</span>
|
|
62
|
+
<span class="select-arrow">
|
|
63
|
+
<svg width="12" height="12" viewBox="0 0 12 12" fill="currentColor">
|
|
64
|
+
<path d="M6 9L1 4h10L6 9z"/>
|
|
65
|
+
</svg>
|
|
66
|
+
</span>
|
|
67
|
+
</span>
|
|
68
|
+
</button>
|
|
69
|
+
|
|
70
|
+
<div class="select-dropdown"
|
|
71
|
+
role="listbox"
|
|
72
|
+
aria-label="${this.label || 'Options'}"
|
|
73
|
+
part="dropdown">
|
|
74
|
+
|
|
75
|
+
<div class="select-search" part="search" ${!this.searchable ? 'hidden' : ''}>
|
|
76
|
+
<input
|
|
77
|
+
type="text"
|
|
78
|
+
class="select-search-input"
|
|
79
|
+
placeholder="Search..."
|
|
80
|
+
aria-label="Search options"
|
|
81
|
+
part="search-input" />
|
|
82
|
+
</div>
|
|
83
|
+
|
|
84
|
+
<div class="select-options" part="options">
|
|
85
|
+
<!-- Options will be rendered in @ready() -->
|
|
86
|
+
</div>
|
|
87
|
+
</div>
|
|
88
|
+
|
|
89
|
+
<!-- Hidden native select for form submission -->
|
|
90
|
+
<select
|
|
91
|
+
class="select-native"
|
|
92
|
+
name="${this.name || ''}"
|
|
93
|
+
tabindex="-1"
|
|
94
|
+
aria-hidden="true">
|
|
95
|
+
<!-- Options will be added in @ready() -->
|
|
96
|
+
</select>
|
|
97
|
+
</div>
|
|
98
|
+
`;
|
|
99
|
+
}
|
|
100
|
+
renderOptions() {
|
|
101
|
+
const options = this.searchable ? this.filteredOptions : this.options;
|
|
102
|
+
if (options.length === 0) {
|
|
103
|
+
return /*html*/ `
|
|
104
|
+
<div class="select-no-options">
|
|
105
|
+
<span class="select-no-options-text" data-search="true" ${!this.searchable || this.filteredOptions.length > 0 ? 'hidden' : ''}>No matches found</span>
|
|
106
|
+
<span class="select-no-options-text" data-search="false" ${this.searchable && this.filteredOptions.length === 0 ? 'hidden' : ''}>No options available</span>
|
|
107
|
+
</div>
|
|
108
|
+
`;
|
|
109
|
+
}
|
|
110
|
+
return options.map((opt, index) => {
|
|
111
|
+
const isSelected = this.multiple ?
|
|
112
|
+
this.selectedValues.has(opt.value) :
|
|
113
|
+
opt.value === this.value;
|
|
114
|
+
return /*html*/ `
|
|
115
|
+
<div class="select-option
|
|
116
|
+
${isSelected ? 'select-option--selected' : ''}
|
|
117
|
+
${opt.disabled ? 'select-option--disabled' : ''}
|
|
118
|
+
${index === this.focusedIndex ? 'select-option--focused' : ''}
|
|
119
|
+
${opt.icon ? 'select-option--has-icon' : ''}"
|
|
120
|
+
data-value="${opt.value}"
|
|
121
|
+
role="option"
|
|
122
|
+
aria-selected="${isSelected}"
|
|
123
|
+
aria-disabled="${opt.disabled}"
|
|
124
|
+
part="option">
|
|
125
|
+
<span class="select-option-check" ${!this.multiple ? 'hidden' : ''}>
|
|
126
|
+
<span class="select-option-check-mark" ${!isSelected ? 'hidden' : ''}>✓</span>
|
|
127
|
+
</span>
|
|
128
|
+
<img class="select-option-icon" src="${opt.icon || ''}" alt="" ${!opt.icon ? 'hidden' : ''} />
|
|
129
|
+
<span class="select-option-label">${opt.label}</span>
|
|
130
|
+
</div>
|
|
131
|
+
`;
|
|
132
|
+
}).join('');
|
|
133
|
+
}
|
|
134
|
+
css() {
|
|
135
|
+
return css;
|
|
136
|
+
}
|
|
137
|
+
init() {
|
|
138
|
+
// Read options from child snice-option elements
|
|
139
|
+
this.readOptionsFromChildren();
|
|
140
|
+
// Initialize selected values
|
|
141
|
+
if (this.multiple && this.value) {
|
|
142
|
+
this.selectedValues = new Set(this.value.split(',').map(v => v.trim()));
|
|
143
|
+
}
|
|
144
|
+
// Initialize filtered options
|
|
145
|
+
this.filteredOptions = [...this.options];
|
|
146
|
+
// Set initial imperative state
|
|
147
|
+
this.updateTriggerState();
|
|
148
|
+
this.updateDropdownState();
|
|
149
|
+
this.updateNativeSelectAttributes();
|
|
150
|
+
// Now that we have options, update everything
|
|
151
|
+
this.updateDropdownContent();
|
|
152
|
+
this.updateNativeSelect();
|
|
153
|
+
this.updateValueDisplay();
|
|
154
|
+
this.updateClearButton();
|
|
155
|
+
// Watch for changes to child options
|
|
156
|
+
this.observeChildren();
|
|
157
|
+
// Setup global event listeners
|
|
158
|
+
this.setupGlobalListeners();
|
|
159
|
+
}
|
|
160
|
+
cleanup() {
|
|
161
|
+
this.removeGlobalListeners();
|
|
162
|
+
this.childObserver?.disconnect();
|
|
163
|
+
}
|
|
164
|
+
setupGlobalListeners() {
|
|
165
|
+
// Create bound handlers
|
|
166
|
+
this.outsideClickHandler = (e) => {
|
|
167
|
+
if (!this.contains(e.target) && this.open) {
|
|
168
|
+
this.closeDropdown();
|
|
169
|
+
}
|
|
170
|
+
};
|
|
171
|
+
this.globalKeyHandler = (e) => {
|
|
172
|
+
if (!this.open)
|
|
173
|
+
return;
|
|
174
|
+
switch (e.key) {
|
|
175
|
+
case 'Escape':
|
|
176
|
+
this.closeDropdown();
|
|
177
|
+
this.trigger?.focus();
|
|
178
|
+
break;
|
|
179
|
+
case 'ArrowDown':
|
|
180
|
+
e.preventDefault();
|
|
181
|
+
this.focusNextOption();
|
|
182
|
+
break;
|
|
183
|
+
case 'ArrowUp':
|
|
184
|
+
e.preventDefault();
|
|
185
|
+
this.focusPreviousOption();
|
|
186
|
+
break;
|
|
187
|
+
case 'Enter':
|
|
188
|
+
case ' ':
|
|
189
|
+
e.preventDefault();
|
|
190
|
+
if (this.focusedIndex >= 0) {
|
|
191
|
+
const options = this.searchable ? this.filteredOptions : this.options;
|
|
192
|
+
const option = options[this.focusedIndex];
|
|
193
|
+
if (option && !option.disabled) {
|
|
194
|
+
this.handleOptionSelect(option);
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
break;
|
|
198
|
+
}
|
|
199
|
+
};
|
|
200
|
+
// Add listeners
|
|
201
|
+
document.addEventListener('click', this.outsideClickHandler);
|
|
202
|
+
document.addEventListener('keydown', this.globalKeyHandler);
|
|
203
|
+
}
|
|
204
|
+
removeGlobalListeners() {
|
|
205
|
+
if (this.outsideClickHandler) {
|
|
206
|
+
document.removeEventListener('click', this.outsideClickHandler);
|
|
207
|
+
}
|
|
208
|
+
if (this.globalKeyHandler) {
|
|
209
|
+
document.removeEventListener('keydown', this.globalKeyHandler);
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
// Manual observation of light DOM children (snice-option elements)
|
|
213
|
+
observeChildren() {
|
|
214
|
+
const observer = new MutationObserver((mutations) => {
|
|
215
|
+
this.handleChildrenChange(mutations);
|
|
216
|
+
});
|
|
217
|
+
// Observe the host element (this) for changes to its light DOM children
|
|
218
|
+
observer.observe(this, {
|
|
219
|
+
childList: true,
|
|
220
|
+
subtree: true,
|
|
221
|
+
attributes: true,
|
|
222
|
+
attributeFilter: ['value', 'label', 'disabled', 'selected']
|
|
223
|
+
});
|
|
224
|
+
// Store for cleanup
|
|
225
|
+
this.childObserver = observer;
|
|
226
|
+
}
|
|
227
|
+
handleChildrenChange(mutations) {
|
|
228
|
+
// Check if any of the mutations are relevant (snice-option elements or their attributes)
|
|
229
|
+
const relevant = mutations.some(m => {
|
|
230
|
+
if (m.type === 'childList')
|
|
231
|
+
return true;
|
|
232
|
+
if (m.type === 'attributes' && ['value', 'label', 'disabled', 'selected'].includes(m.attributeName)) {
|
|
233
|
+
return m.target.nodeName === 'SNICE-OPTION';
|
|
234
|
+
}
|
|
235
|
+
return false;
|
|
236
|
+
});
|
|
237
|
+
if (relevant) {
|
|
238
|
+
this.readOptionsFromChildren();
|
|
239
|
+
this.filteredOptions = [...this.options];
|
|
240
|
+
this.updateNativeSelect();
|
|
241
|
+
this.updateValueDisplay();
|
|
242
|
+
this.updateClearButton();
|
|
243
|
+
this.updateDropdownContent();
|
|
244
|
+
}
|
|
245
|
+
}
|
|
246
|
+
readOptionsFromChildren() {
|
|
247
|
+
// Get all snice-option children from light DOM
|
|
248
|
+
const optionElements = Array.from(this.querySelectorAll('snice-option'));
|
|
249
|
+
this.options = optionElements.map(opt => {
|
|
250
|
+
const sniceOption = opt;
|
|
251
|
+
// Use the optionData getter if available, otherwise construct from properties
|
|
252
|
+
if (sniceOption.optionData) {
|
|
253
|
+
return sniceOption.optionData;
|
|
254
|
+
}
|
|
255
|
+
return {
|
|
256
|
+
value: opt.getAttribute('value') || '',
|
|
257
|
+
label: opt.getAttribute('label') || opt.textContent?.trim() || '',
|
|
258
|
+
disabled: opt.hasAttribute('disabled'),
|
|
259
|
+
selected: opt.hasAttribute('selected')
|
|
260
|
+
};
|
|
261
|
+
});
|
|
262
|
+
}
|
|
263
|
+
handleTriggerOpen(e) {
|
|
264
|
+
e.preventDefault();
|
|
265
|
+
if (!this.open) {
|
|
266
|
+
this.openDropdown();
|
|
267
|
+
}
|
|
268
|
+
}
|
|
269
|
+
handleSearchEscape() {
|
|
270
|
+
this.closeDropdown();
|
|
271
|
+
this.trigger?.focus();
|
|
272
|
+
}
|
|
273
|
+
handleSearchArrowDown(e) {
|
|
274
|
+
e.preventDefault();
|
|
275
|
+
this.focusNextOption();
|
|
276
|
+
}
|
|
277
|
+
handleSearchArrowUp(e) {
|
|
278
|
+
e.preventDefault();
|
|
279
|
+
this.focusPreviousOption();
|
|
280
|
+
}
|
|
281
|
+
handleSearchEnter(e) {
|
|
282
|
+
e.preventDefault();
|
|
283
|
+
if (this.focusedIndex >= 0) {
|
|
284
|
+
const options = this.searchable ? this.filteredOptions : this.options;
|
|
285
|
+
const option = options[this.focusedIndex];
|
|
286
|
+
if (option && !option.disabled) {
|
|
287
|
+
this.handleOptionSelect(option);
|
|
288
|
+
}
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
focusNextOption() {
|
|
292
|
+
const options = this.searchable ? this.filteredOptions : this.options;
|
|
293
|
+
const enabledOptions = options.filter(opt => !opt.disabled);
|
|
294
|
+
if (enabledOptions.length === 0)
|
|
295
|
+
return;
|
|
296
|
+
this.focusedIndex++;
|
|
297
|
+
if (this.focusedIndex >= options.length) {
|
|
298
|
+
this.focusedIndex = 0;
|
|
299
|
+
}
|
|
300
|
+
while (options[this.focusedIndex]?.disabled) {
|
|
301
|
+
this.focusedIndex++;
|
|
302
|
+
if (this.focusedIndex >= options.length) {
|
|
303
|
+
this.focusedIndex = 0;
|
|
304
|
+
}
|
|
305
|
+
}
|
|
306
|
+
this.updateOptionFocus();
|
|
307
|
+
}
|
|
308
|
+
focusPreviousOption() {
|
|
309
|
+
const options = this.searchable ? this.filteredOptions : this.options;
|
|
310
|
+
const enabledOptions = options.filter(opt => !opt.disabled);
|
|
311
|
+
if (enabledOptions.length === 0)
|
|
312
|
+
return;
|
|
313
|
+
this.focusedIndex--;
|
|
314
|
+
if (this.focusedIndex < 0) {
|
|
315
|
+
this.focusedIndex = options.length - 1;
|
|
316
|
+
}
|
|
317
|
+
while (options[this.focusedIndex]?.disabled) {
|
|
318
|
+
this.focusedIndex--;
|
|
319
|
+
if (this.focusedIndex < 0) {
|
|
320
|
+
this.focusedIndex = options.length - 1;
|
|
321
|
+
}
|
|
322
|
+
}
|
|
323
|
+
this.updateOptionFocus();
|
|
324
|
+
}
|
|
325
|
+
updateOptionFocus() {
|
|
326
|
+
if (this.optionElements) {
|
|
327
|
+
this.optionElements.forEach((el, index) => {
|
|
328
|
+
el.classList.toggle('select-option--focused', index === this.focusedIndex);
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
}
|
|
332
|
+
handleTriggerClick(e) {
|
|
333
|
+
e.stopPropagation();
|
|
334
|
+
// Don't toggle if clicking on the clear button or tag remove buttons
|
|
335
|
+
const target = e.target;
|
|
336
|
+
if (target.closest('.select-clear') || target.closest('.select-tag-remove')) {
|
|
337
|
+
return;
|
|
338
|
+
}
|
|
339
|
+
if (!this.disabled && !this.readonly) {
|
|
340
|
+
this.toggleDropdown();
|
|
341
|
+
}
|
|
342
|
+
}
|
|
343
|
+
handleClearClick(_e) {
|
|
344
|
+
this.clear();
|
|
345
|
+
}
|
|
346
|
+
handleTagRemove(e) {
|
|
347
|
+
e.stopPropagation();
|
|
348
|
+
const target = e.target;
|
|
349
|
+
const value = target.getAttribute('data-value');
|
|
350
|
+
if (value && this.multiple) {
|
|
351
|
+
this.selectedValues.delete(value);
|
|
352
|
+
this.value = Array.from(this.selectedValues).join(',');
|
|
353
|
+
this.updateNativeSelect();
|
|
354
|
+
this.updateValueDisplay();
|
|
355
|
+
this.updateClearButton();
|
|
356
|
+
this.dispatchChangeEvent();
|
|
357
|
+
}
|
|
358
|
+
}
|
|
359
|
+
handleOptionsClick(e) {
|
|
360
|
+
e.stopPropagation();
|
|
361
|
+
const target = e.target;
|
|
362
|
+
const optionEl = target.closest('.select-option');
|
|
363
|
+
if (!optionEl)
|
|
364
|
+
return;
|
|
365
|
+
const value = optionEl.getAttribute('data-value');
|
|
366
|
+
if (!value)
|
|
367
|
+
return;
|
|
368
|
+
const option = this.options.find(opt => opt.value === value);
|
|
369
|
+
if (option && !option.disabled) {
|
|
370
|
+
this.handleOptionSelect(option);
|
|
371
|
+
}
|
|
372
|
+
}
|
|
373
|
+
handleSearchInput(e) {
|
|
374
|
+
const target = e.target;
|
|
375
|
+
const searchTerm = target.value.toLowerCase();
|
|
376
|
+
if (searchTerm) {
|
|
377
|
+
this.filteredOptions = this.options.filter(opt => opt.label.toLowerCase().includes(searchTerm));
|
|
378
|
+
}
|
|
379
|
+
else {
|
|
380
|
+
this.filteredOptions = [...this.options];
|
|
381
|
+
}
|
|
382
|
+
this.focusedIndex = -1;
|
|
383
|
+
this.updateDropdownContent();
|
|
384
|
+
}
|
|
385
|
+
handleOptionSelect(option) {
|
|
386
|
+
if (this.multiple) {
|
|
387
|
+
if (this.selectedValues.has(option.value)) {
|
|
388
|
+
this.selectedValues.delete(option.value);
|
|
389
|
+
}
|
|
390
|
+
else {
|
|
391
|
+
this.selectedValues.add(option.value);
|
|
392
|
+
}
|
|
393
|
+
this.value = Array.from(this.selectedValues).join(',');
|
|
394
|
+
this.updateDropdownContent();
|
|
395
|
+
}
|
|
396
|
+
else {
|
|
397
|
+
this.value = option.value;
|
|
398
|
+
this.closeDropdown();
|
|
399
|
+
}
|
|
400
|
+
this.updateNativeSelect();
|
|
401
|
+
this.updateValueDisplay();
|
|
402
|
+
this.updateClearButton();
|
|
403
|
+
this.dispatchChangeEvent(option);
|
|
404
|
+
}
|
|
405
|
+
handleValueChange() {
|
|
406
|
+
if (this.multiple) {
|
|
407
|
+
this.selectedValues = new Set(this.value ? this.value.split(',').map(v => v.trim()) : []);
|
|
408
|
+
}
|
|
409
|
+
this.updateNativeSelect();
|
|
410
|
+
this.updateValueDisplay();
|
|
411
|
+
this.updateClearButton();
|
|
412
|
+
}
|
|
413
|
+
handleDisabledChange() {
|
|
414
|
+
this.updateTriggerState();
|
|
415
|
+
this.updateNativeSelectAttributes();
|
|
416
|
+
this.updateClearButton();
|
|
417
|
+
if (this.disabled && this.open) {
|
|
418
|
+
this.closeDropdown();
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
handleReadonlyChange() {
|
|
422
|
+
this.updateTriggerState();
|
|
423
|
+
this.updateClearButton();
|
|
424
|
+
}
|
|
425
|
+
handleInvalidChange() {
|
|
426
|
+
this.updateTriggerState();
|
|
427
|
+
}
|
|
428
|
+
// Remove the @watch('options') since options are now read from children
|
|
429
|
+
handleOpenChange() {
|
|
430
|
+
this.updateDropdownState();
|
|
431
|
+
this.updateTriggerState();
|
|
432
|
+
if (this.open && this.searchable && this.searchInput) {
|
|
433
|
+
setTimeout(() => this.searchInput?.focus(), 100);
|
|
434
|
+
}
|
|
435
|
+
if (!this.open) {
|
|
436
|
+
this.focusedIndex = -1;
|
|
437
|
+
if (this.searchInput) {
|
|
438
|
+
this.searchInput.value = '';
|
|
439
|
+
this.filteredOptions = [...this.options];
|
|
440
|
+
this.updateDropdownContent();
|
|
441
|
+
}
|
|
442
|
+
}
|
|
443
|
+
}
|
|
444
|
+
handleLabelChange() {
|
|
445
|
+
if (this.labelElement) {
|
|
446
|
+
this.labelElement.textContent = this.label;
|
|
447
|
+
if (this.label) {
|
|
448
|
+
this.labelElement.removeAttribute('hidden');
|
|
449
|
+
}
|
|
450
|
+
else {
|
|
451
|
+
this.labelElement.setAttribute('hidden', '');
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
}
|
|
455
|
+
handlePlaceholderChange() {
|
|
456
|
+
this.updateValueDisplay();
|
|
457
|
+
}
|
|
458
|
+
handleRequiredChange() {
|
|
459
|
+
if (this.labelElement) {
|
|
460
|
+
this.labelElement.classList.toggle('select-label--required', this.required);
|
|
461
|
+
}
|
|
462
|
+
this.updateNativeSelectAttributes();
|
|
463
|
+
}
|
|
464
|
+
handleMultipleChange() {
|
|
465
|
+
this.updateNativeSelectAttributes();
|
|
466
|
+
}
|
|
467
|
+
handleNameChange() {
|
|
468
|
+
this.updateNativeSelectAttributes();
|
|
469
|
+
}
|
|
470
|
+
handleClearableChange() {
|
|
471
|
+
this.updateClearButton();
|
|
472
|
+
}
|
|
473
|
+
handleSearchableChange() {
|
|
474
|
+
if (this.searchContainer) {
|
|
475
|
+
if (this.searchable) {
|
|
476
|
+
this.searchContainer.removeAttribute('hidden');
|
|
477
|
+
}
|
|
478
|
+
else {
|
|
479
|
+
this.searchContainer.setAttribute('hidden', '');
|
|
480
|
+
}
|
|
481
|
+
}
|
|
482
|
+
}
|
|
483
|
+
updateValueDisplay() {
|
|
484
|
+
if (!this.valueDisplay)
|
|
485
|
+
return;
|
|
486
|
+
const selectedOptions = this.options.filter(opt => this.multiple ? this.selectedValues.has(opt.value) : opt.value === this.value);
|
|
487
|
+
if (this.multiple && selectedOptions.length > 0) {
|
|
488
|
+
this.valueDisplay.innerHTML = /*html*/ `
|
|
489
|
+
<div class="select-value--multiple">
|
|
490
|
+
${selectedOptions.map(opt => /*html*/ `
|
|
491
|
+
<span class="select-tag">
|
|
492
|
+
<img class="select-tag-icon" src="${opt.icon || ''}" alt="" ${!opt.icon ? 'hidden' : ''} />
|
|
493
|
+
${opt.label}
|
|
494
|
+
<span class="select-tag-remove" data-value="${opt.value}" aria-label="Remove ${opt.label}" ${this.disabled || this.readonly ? 'hidden' : ''}>×</span>
|
|
495
|
+
</span>
|
|
496
|
+
`).join('')}
|
|
497
|
+
</div>
|
|
498
|
+
`;
|
|
499
|
+
}
|
|
500
|
+
else if (selectedOptions.length > 0) {
|
|
501
|
+
const selected = selectedOptions[0];
|
|
502
|
+
this.valueDisplay.innerHTML = /*html*/ `
|
|
503
|
+
<div class="select-value--single">
|
|
504
|
+
<img class="select-value-icon" src="${selected.icon || ''}" alt="" ${!selected.icon ? 'hidden' : ''} />
|
|
505
|
+
<span>${selected.label}</span>
|
|
506
|
+
</div>
|
|
507
|
+
`;
|
|
508
|
+
}
|
|
509
|
+
else {
|
|
510
|
+
this.valueDisplay.innerHTML = /*html*/ `<span class="select-placeholder">${this.placeholder}</span>`;
|
|
511
|
+
}
|
|
512
|
+
}
|
|
513
|
+
updateClearButton() {
|
|
514
|
+
if (!this.clearButton)
|
|
515
|
+
return;
|
|
516
|
+
const selectedOptions = this.options.filter(opt => this.multiple ? this.selectedValues.has(opt.value) : opt.value === this.value);
|
|
517
|
+
const shouldShow = this.clearable && selectedOptions.length > 0 && !this.disabled && !this.readonly;
|
|
518
|
+
this.clearButton.style.display = shouldShow ? '' : 'none';
|
|
519
|
+
}
|
|
520
|
+
updateDropdownContent() {
|
|
521
|
+
if (!this.optionsList)
|
|
522
|
+
return;
|
|
523
|
+
this.optionsList.innerHTML = this.renderOptions();
|
|
524
|
+
}
|
|
525
|
+
updateNativeSelect() {
|
|
526
|
+
if (!this.nativeSelect)
|
|
527
|
+
return;
|
|
528
|
+
// Clear and rebuild options
|
|
529
|
+
this.nativeSelect.innerHTML = '';
|
|
530
|
+
this.options.forEach(opt => {
|
|
531
|
+
const option = document.createElement('option');
|
|
532
|
+
option.value = opt.value;
|
|
533
|
+
option.textContent = opt.label;
|
|
534
|
+
option.selected = this.multiple ?
|
|
535
|
+
this.selectedValues.has(opt.value) :
|
|
536
|
+
opt.value === this.value;
|
|
537
|
+
this.nativeSelect.appendChild(option);
|
|
538
|
+
});
|
|
539
|
+
}
|
|
540
|
+
dispatchChangeEvent(option) {
|
|
541
|
+
return {
|
|
542
|
+
value: this.multiple ? Array.from(this.selectedValues) : this.value,
|
|
543
|
+
option,
|
|
544
|
+
select: this
|
|
545
|
+
};
|
|
546
|
+
}
|
|
547
|
+
dispatchOpenEvent() {
|
|
548
|
+
return { select: this };
|
|
549
|
+
}
|
|
550
|
+
dispatchCloseEvent() {
|
|
551
|
+
return { select: this };
|
|
552
|
+
}
|
|
553
|
+
// Public API
|
|
554
|
+
focus() {
|
|
555
|
+
this.trigger?.focus();
|
|
556
|
+
}
|
|
557
|
+
blur() {
|
|
558
|
+
this.trigger?.blur();
|
|
559
|
+
if (this.open) {
|
|
560
|
+
this.closeDropdown();
|
|
561
|
+
}
|
|
562
|
+
}
|
|
563
|
+
clear() {
|
|
564
|
+
if (this.multiple) {
|
|
565
|
+
this.selectedValues.clear();
|
|
566
|
+
this.value = '';
|
|
567
|
+
}
|
|
568
|
+
else {
|
|
569
|
+
this.value = '';
|
|
570
|
+
}
|
|
571
|
+
this.updateNativeSelect();
|
|
572
|
+
this.updateValueDisplay();
|
|
573
|
+
this.updateClearButton();
|
|
574
|
+
this.dispatchChangeEvent();
|
|
575
|
+
}
|
|
576
|
+
openDropdown() {
|
|
577
|
+
if (!this.open && !this.disabled && !this.readonly) {
|
|
578
|
+
this.open = true;
|
|
579
|
+
this.dispatchOpenEvent();
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
closeDropdown() {
|
|
583
|
+
if (this.open) {
|
|
584
|
+
this.open = false;
|
|
585
|
+
this.dispatchCloseEvent();
|
|
586
|
+
}
|
|
587
|
+
}
|
|
588
|
+
toggleDropdown() {
|
|
589
|
+
if (this.open) {
|
|
590
|
+
this.closeDropdown();
|
|
591
|
+
}
|
|
592
|
+
else {
|
|
593
|
+
this.openDropdown();
|
|
594
|
+
}
|
|
595
|
+
}
|
|
596
|
+
selectOption(value) {
|
|
597
|
+
const option = this.options.find(opt => opt.value === value);
|
|
598
|
+
if (option && !option.disabled) {
|
|
599
|
+
this.handleOptionSelect(option);
|
|
600
|
+
}
|
|
601
|
+
}
|
|
602
|
+
updateTriggerState() {
|
|
603
|
+
if (!this.trigger)
|
|
604
|
+
return;
|
|
605
|
+
this.trigger.classList.toggle('select-trigger--open', this.open);
|
|
606
|
+
this.trigger.classList.toggle('select-trigger--disabled', this.disabled);
|
|
607
|
+
this.trigger.classList.toggle('select-trigger--readonly', this.readonly);
|
|
608
|
+
this.trigger.classList.toggle('select-trigger--invalid', this.invalid);
|
|
609
|
+
this.trigger.setAttribute('aria-expanded', String(this.open));
|
|
610
|
+
this.trigger.disabled = this.disabled;
|
|
611
|
+
}
|
|
612
|
+
updateDropdownState() {
|
|
613
|
+
if (!this.dropdown)
|
|
614
|
+
return;
|
|
615
|
+
this.dropdown.classList.toggle('select-dropdown--open', this.open);
|
|
616
|
+
if (this.arrow) {
|
|
617
|
+
this.arrow.classList.toggle('select-arrow--open', this.open);
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
updateNativeSelectAttributes() {
|
|
621
|
+
if (!this.nativeSelect)
|
|
622
|
+
return;
|
|
623
|
+
this.nativeSelect.disabled = this.disabled;
|
|
624
|
+
this.nativeSelect.required = this.required;
|
|
625
|
+
this.nativeSelect.multiple = this.multiple;
|
|
626
|
+
if (this.name) {
|
|
627
|
+
this.nativeSelect.name = this.name;
|
|
628
|
+
}
|
|
629
|
+
else {
|
|
630
|
+
this.nativeSelect.removeAttribute('name');
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
__decorate([
|
|
635
|
+
property({ type: Boolean, reflect: true }),
|
|
636
|
+
__metadata("design:type", Object)
|
|
637
|
+
], SniceSelect.prototype, "disabled", void 0);
|
|
638
|
+
__decorate([
|
|
639
|
+
property({ type: Boolean, reflect: true }),
|
|
640
|
+
__metadata("design:type", Object)
|
|
641
|
+
], SniceSelect.prototype, "required", void 0);
|
|
642
|
+
__decorate([
|
|
643
|
+
property({ type: Boolean, reflect: true }),
|
|
644
|
+
__metadata("design:type", Object)
|
|
645
|
+
], SniceSelect.prototype, "invalid", void 0);
|
|
646
|
+
__decorate([
|
|
647
|
+
property({ type: Boolean, reflect: true }),
|
|
648
|
+
__metadata("design:type", Object)
|
|
649
|
+
], SniceSelect.prototype, "readonly", void 0);
|
|
650
|
+
__decorate([
|
|
651
|
+
property({ type: Boolean, reflect: true }),
|
|
652
|
+
__metadata("design:type", Object)
|
|
653
|
+
], SniceSelect.prototype, "multiple", void 0);
|
|
654
|
+
__decorate([
|
|
655
|
+
property({ type: Boolean, reflect: true }),
|
|
656
|
+
__metadata("design:type", Object)
|
|
657
|
+
], SniceSelect.prototype, "searchable", void 0);
|
|
658
|
+
__decorate([
|
|
659
|
+
property({ type: Boolean, reflect: true }),
|
|
660
|
+
__metadata("design:type", Object)
|
|
661
|
+
], SniceSelect.prototype, "clearable", void 0);
|
|
662
|
+
__decorate([
|
|
663
|
+
property({ type: Boolean, reflect: true }),
|
|
664
|
+
__metadata("design:type", Object)
|
|
665
|
+
], SniceSelect.prototype, "open", void 0);
|
|
666
|
+
__decorate([
|
|
667
|
+
property({ reflect: true }),
|
|
668
|
+
__metadata("design:type", String)
|
|
669
|
+
], SniceSelect.prototype, "size", void 0);
|
|
670
|
+
__decorate([
|
|
671
|
+
property({ reflect: true }),
|
|
672
|
+
__metadata("design:type", Object)
|
|
673
|
+
], SniceSelect.prototype, "name", void 0);
|
|
674
|
+
__decorate([
|
|
675
|
+
property({ reflect: true }),
|
|
676
|
+
__metadata("design:type", Object)
|
|
677
|
+
], SniceSelect.prototype, "value", void 0);
|
|
678
|
+
__decorate([
|
|
679
|
+
property({ reflect: true }),
|
|
680
|
+
__metadata("design:type", Object)
|
|
681
|
+
], SniceSelect.prototype, "label", void 0);
|
|
682
|
+
__decorate([
|
|
683
|
+
property({ reflect: true }),
|
|
684
|
+
__metadata("design:type", Object)
|
|
685
|
+
], SniceSelect.prototype, "placeholder", void 0);
|
|
686
|
+
__decorate([
|
|
687
|
+
property({ reflect: true, attribute: 'max-height' }),
|
|
688
|
+
__metadata("design:type", Object)
|
|
689
|
+
], SniceSelect.prototype, "maxHeight", void 0);
|
|
690
|
+
__decorate([
|
|
691
|
+
query('.select-trigger'),
|
|
692
|
+
__metadata("design:type", HTMLButtonElement)
|
|
693
|
+
], SniceSelect.prototype, "trigger", void 0);
|
|
694
|
+
__decorate([
|
|
695
|
+
query('.select-dropdown'),
|
|
696
|
+
__metadata("design:type", HTMLElement)
|
|
697
|
+
], SniceSelect.prototype, "dropdown", void 0);
|
|
698
|
+
__decorate([
|
|
699
|
+
query('.select-value'),
|
|
700
|
+
__metadata("design:type", HTMLElement)
|
|
701
|
+
], SniceSelect.prototype, "valueDisplay", void 0);
|
|
702
|
+
__decorate([
|
|
703
|
+
query('.select-label'),
|
|
704
|
+
__metadata("design:type", HTMLElement)
|
|
705
|
+
], SniceSelect.prototype, "labelElement", void 0);
|
|
706
|
+
__decorate([
|
|
707
|
+
query('.select-search-input'),
|
|
708
|
+
__metadata("design:type", HTMLInputElement)
|
|
709
|
+
], SniceSelect.prototype, "searchInput", void 0);
|
|
710
|
+
__decorate([
|
|
711
|
+
query('.select-options'),
|
|
712
|
+
__metadata("design:type", HTMLElement)
|
|
713
|
+
], SniceSelect.prototype, "optionsList", void 0);
|
|
714
|
+
__decorate([
|
|
715
|
+
query('.select-native'),
|
|
716
|
+
__metadata("design:type", HTMLSelectElement)
|
|
717
|
+
], SniceSelect.prototype, "nativeSelect", void 0);
|
|
718
|
+
__decorate([
|
|
719
|
+
query('.select-clear'),
|
|
720
|
+
__metadata("design:type", HTMLElement)
|
|
721
|
+
], SniceSelect.prototype, "clearButton", void 0);
|
|
722
|
+
__decorate([
|
|
723
|
+
query('.select-arrow'),
|
|
724
|
+
__metadata("design:type", HTMLElement)
|
|
725
|
+
], SniceSelect.prototype, "arrow", void 0);
|
|
726
|
+
__decorate([
|
|
727
|
+
query('.select-search'),
|
|
728
|
+
__metadata("design:type", HTMLElement)
|
|
729
|
+
], SniceSelect.prototype, "searchContainer", void 0);
|
|
730
|
+
__decorate([
|
|
731
|
+
queryAll('.select-option'),
|
|
732
|
+
__metadata("design:type", Array)
|
|
733
|
+
], SniceSelect.prototype, "optionElements", void 0);
|
|
734
|
+
__decorate([
|
|
735
|
+
ready(),
|
|
736
|
+
__metadata("design:type", Function),
|
|
737
|
+
__metadata("design:paramtypes", []),
|
|
738
|
+
__metadata("design:returntype", void 0)
|
|
739
|
+
], SniceSelect.prototype, "init", null);
|
|
740
|
+
__decorate([
|
|
741
|
+
dispose(),
|
|
742
|
+
__metadata("design:type", Function),
|
|
743
|
+
__metadata("design:paramtypes", []),
|
|
744
|
+
__metadata("design:returntype", void 0)
|
|
745
|
+
], SniceSelect.prototype, "cleanup", null);
|
|
746
|
+
__decorate([
|
|
747
|
+
on(['keydown:Enter', 'keydown:Space', 'keydown:ArrowDown', 'keydown:ArrowUp'], '.select-trigger'),
|
|
748
|
+
__metadata("design:type", Function),
|
|
749
|
+
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
750
|
+
__metadata("design:returntype", void 0)
|
|
751
|
+
], SniceSelect.prototype, "handleTriggerOpen", null);
|
|
752
|
+
__decorate([
|
|
753
|
+
on('keydown:Escape', '.select-search-input'),
|
|
754
|
+
__metadata("design:type", Function),
|
|
755
|
+
__metadata("design:paramtypes", []),
|
|
756
|
+
__metadata("design:returntype", void 0)
|
|
757
|
+
], SniceSelect.prototype, "handleSearchEscape", null);
|
|
758
|
+
__decorate([
|
|
759
|
+
on('keydown:ArrowDown', '.select-search-input'),
|
|
760
|
+
__metadata("design:type", Function),
|
|
761
|
+
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
762
|
+
__metadata("design:returntype", void 0)
|
|
763
|
+
], SniceSelect.prototype, "handleSearchArrowDown", null);
|
|
764
|
+
__decorate([
|
|
765
|
+
on('keydown:ArrowUp', '.select-search-input'),
|
|
766
|
+
__metadata("design:type", Function),
|
|
767
|
+
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
768
|
+
__metadata("design:returntype", void 0)
|
|
769
|
+
], SniceSelect.prototype, "handleSearchArrowUp", null);
|
|
770
|
+
__decorate([
|
|
771
|
+
on('keydown:Enter', '.select-search-input'),
|
|
772
|
+
__metadata("design:type", Function),
|
|
773
|
+
__metadata("design:paramtypes", [KeyboardEvent]),
|
|
774
|
+
__metadata("design:returntype", void 0)
|
|
775
|
+
], SniceSelect.prototype, "handleSearchEnter", null);
|
|
776
|
+
__decorate([
|
|
777
|
+
on('click', '.select-trigger'),
|
|
778
|
+
__metadata("design:type", Function),
|
|
779
|
+
__metadata("design:paramtypes", [Event]),
|
|
780
|
+
__metadata("design:returntype", void 0)
|
|
781
|
+
], SniceSelect.prototype, "handleTriggerClick", null);
|
|
782
|
+
__decorate([
|
|
783
|
+
on('click', '.select-clear', { preventDefault: true, stopPropagation: true }),
|
|
784
|
+
__metadata("design:type", Function),
|
|
785
|
+
__metadata("design:paramtypes", [Event]),
|
|
786
|
+
__metadata("design:returntype", void 0)
|
|
787
|
+
], SniceSelect.prototype, "handleClearClick", null);
|
|
788
|
+
__decorate([
|
|
789
|
+
on('click', '.select-tag-remove'),
|
|
790
|
+
__metadata("design:type", Function),
|
|
791
|
+
__metadata("design:paramtypes", [Event]),
|
|
792
|
+
__metadata("design:returntype", void 0)
|
|
793
|
+
], SniceSelect.prototype, "handleTagRemove", null);
|
|
794
|
+
__decorate([
|
|
795
|
+
on('click', '.select-options'),
|
|
796
|
+
__metadata("design:type", Function),
|
|
797
|
+
__metadata("design:paramtypes", [Event]),
|
|
798
|
+
__metadata("design:returntype", void 0)
|
|
799
|
+
], SniceSelect.prototype, "handleOptionsClick", null);
|
|
800
|
+
__decorate([
|
|
801
|
+
on('input', '.select-search-input'),
|
|
802
|
+
__metadata("design:type", Function),
|
|
803
|
+
__metadata("design:paramtypes", [Event]),
|
|
804
|
+
__metadata("design:returntype", void 0)
|
|
805
|
+
], SniceSelect.prototype, "handleSearchInput", null);
|
|
806
|
+
__decorate([
|
|
807
|
+
watch('value'),
|
|
808
|
+
__metadata("design:type", Function),
|
|
809
|
+
__metadata("design:paramtypes", []),
|
|
810
|
+
__metadata("design:returntype", void 0)
|
|
811
|
+
], SniceSelect.prototype, "handleValueChange", null);
|
|
812
|
+
__decorate([
|
|
813
|
+
watch('disabled'),
|
|
814
|
+
__metadata("design:type", Function),
|
|
815
|
+
__metadata("design:paramtypes", []),
|
|
816
|
+
__metadata("design:returntype", void 0)
|
|
817
|
+
], SniceSelect.prototype, "handleDisabledChange", null);
|
|
818
|
+
__decorate([
|
|
819
|
+
watch('readonly'),
|
|
820
|
+
__metadata("design:type", Function),
|
|
821
|
+
__metadata("design:paramtypes", []),
|
|
822
|
+
__metadata("design:returntype", void 0)
|
|
823
|
+
], SniceSelect.prototype, "handleReadonlyChange", null);
|
|
824
|
+
__decorate([
|
|
825
|
+
watch('invalid'),
|
|
826
|
+
__metadata("design:type", Function),
|
|
827
|
+
__metadata("design:paramtypes", []),
|
|
828
|
+
__metadata("design:returntype", void 0)
|
|
829
|
+
], SniceSelect.prototype, "handleInvalidChange", null);
|
|
830
|
+
__decorate([
|
|
831
|
+
watch('open'),
|
|
832
|
+
__metadata("design:type", Function),
|
|
833
|
+
__metadata("design:paramtypes", []),
|
|
834
|
+
__metadata("design:returntype", void 0)
|
|
835
|
+
], SniceSelect.prototype, "handleOpenChange", null);
|
|
836
|
+
__decorate([
|
|
837
|
+
watch('label'),
|
|
838
|
+
__metadata("design:type", Function),
|
|
839
|
+
__metadata("design:paramtypes", []),
|
|
840
|
+
__metadata("design:returntype", void 0)
|
|
841
|
+
], SniceSelect.prototype, "handleLabelChange", null);
|
|
842
|
+
__decorate([
|
|
843
|
+
watch('placeholder'),
|
|
844
|
+
__metadata("design:type", Function),
|
|
845
|
+
__metadata("design:paramtypes", []),
|
|
846
|
+
__metadata("design:returntype", void 0)
|
|
847
|
+
], SniceSelect.prototype, "handlePlaceholderChange", null);
|
|
848
|
+
__decorate([
|
|
849
|
+
watch('required'),
|
|
850
|
+
__metadata("design:type", Function),
|
|
851
|
+
__metadata("design:paramtypes", []),
|
|
852
|
+
__metadata("design:returntype", void 0)
|
|
853
|
+
], SniceSelect.prototype, "handleRequiredChange", null);
|
|
854
|
+
__decorate([
|
|
855
|
+
watch('multiple'),
|
|
856
|
+
__metadata("design:type", Function),
|
|
857
|
+
__metadata("design:paramtypes", []),
|
|
858
|
+
__metadata("design:returntype", void 0)
|
|
859
|
+
], SniceSelect.prototype, "handleMultipleChange", null);
|
|
860
|
+
__decorate([
|
|
861
|
+
watch('name'),
|
|
862
|
+
__metadata("design:type", Function),
|
|
863
|
+
__metadata("design:paramtypes", []),
|
|
864
|
+
__metadata("design:returntype", void 0)
|
|
865
|
+
], SniceSelect.prototype, "handleNameChange", null);
|
|
866
|
+
__decorate([
|
|
867
|
+
watch('clearable'),
|
|
868
|
+
__metadata("design:type", Function),
|
|
869
|
+
__metadata("design:paramtypes", []),
|
|
870
|
+
__metadata("design:returntype", void 0)
|
|
871
|
+
], SniceSelect.prototype, "handleClearableChange", null);
|
|
872
|
+
__decorate([
|
|
873
|
+
watch('searchable'),
|
|
874
|
+
__metadata("design:type", Function),
|
|
875
|
+
__metadata("design:paramtypes", []),
|
|
876
|
+
__metadata("design:returntype", void 0)
|
|
877
|
+
], SniceSelect.prototype, "handleSearchableChange", null);
|
|
878
|
+
__decorate([
|
|
879
|
+
dispatch('@snice/select-change', { bubbles: true, composed: true }),
|
|
880
|
+
__metadata("design:type", Function),
|
|
881
|
+
__metadata("design:paramtypes", [Object]),
|
|
882
|
+
__metadata("design:returntype", void 0)
|
|
883
|
+
], SniceSelect.prototype, "dispatchChangeEvent", null);
|
|
884
|
+
__decorate([
|
|
885
|
+
dispatch('@snice/select-open', { bubbles: true, composed: true }),
|
|
886
|
+
__metadata("design:type", Function),
|
|
887
|
+
__metadata("design:paramtypes", []),
|
|
888
|
+
__metadata("design:returntype", void 0)
|
|
889
|
+
], SniceSelect.prototype, "dispatchOpenEvent", null);
|
|
890
|
+
__decorate([
|
|
891
|
+
dispatch('@snice/select-close', { bubbles: true, composed: true }),
|
|
892
|
+
__metadata("design:type", Function),
|
|
893
|
+
__metadata("design:paramtypes", []),
|
|
894
|
+
__metadata("design:returntype", void 0)
|
|
895
|
+
], SniceSelect.prototype, "dispatchCloseEvent", null);
|
|
896
|
+
SniceSelect = __decorate([
|
|
897
|
+
element('snice-select')
|
|
898
|
+
], SniceSelect);
|
|
899
|
+
export { SniceSelect };
|
|
900
|
+
//# sourceMappingURL=snice-select.js.map
|