snice 2.5.4 → 3.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +501 -882
- package/bin/templates/base/src/components/counter-button.ts +13 -26
- package/bin/templates/base/src/controllers/counter-controller.ts +3 -3
- package/dist/components/accordion/snice-accordion-item.d.ts +4 -5
- package/dist/components/accordion/snice-accordion-item.js +37 -39
- package/dist/components/accordion/snice-accordion-item.js.map +1 -1
- package/dist/components/accordion/snice-accordion.d.ts +5 -11
- package/dist/components/accordion/snice-accordion.js +51 -52
- package/dist/components/accordion/snice-accordion.js.map +1 -1
- package/dist/components/alert/snice-alert.d.ts +2 -6
- package/dist/components/alert/snice-alert.js +41 -56
- package/dist/components/alert/snice-alert.js.map +1 -1
- package/dist/components/avatar/snice-avatar.d.ts +2 -6
- package/dist/components/avatar/snice-avatar.js +64 -71
- package/dist/components/avatar/snice-avatar.js.map +1 -1
- package/dist/components/badge/snice-badge.d.ts +2 -3
- package/dist/components/badge/snice-badge.js +22 -23
- package/dist/components/badge/snice-badge.js.map +1 -1
- package/dist/components/breadcrumbs/snice-breadcrumbs.d.ts +5 -12
- package/dist/components/breadcrumbs/snice-breadcrumbs.js +88 -89
- package/dist/components/breadcrumbs/snice-breadcrumbs.js.map +1 -1
- package/dist/components/button/snice-button.d.ts +3 -7
- package/dist/components/button/snice-button.js +37 -58
- package/dist/components/button/snice-button.js.map +1 -1
- package/dist/components/card/snice-card.d.ts +5 -8
- package/dist/components/card/snice-card.js +71 -56
- package/dist/components/card/snice-card.js.map +1 -1
- package/dist/components/checkbox/snice-checkbox.d.ts +4 -13
- package/dist/components/checkbox/snice-checkbox.js +66 -137
- package/dist/components/checkbox/snice-checkbox.js.map +1 -1
- package/dist/components/chip/snice-chip.d.ts +5 -11
- package/dist/components/chip/snice-chip.js +44 -47
- package/dist/components/chip/snice-chip.js.map +1 -1
- package/dist/components/date-picker/snice-date-picker.d.ts +11 -11
- package/dist/components/date-picker/snice-date-picker.js +134 -133
- package/dist/components/date-picker/snice-date-picker.js.map +1 -1
- package/dist/components/divider/snice-divider.d.ts +2 -4
- package/dist/components/divider/snice-divider.js +14 -22
- package/dist/components/divider/snice-divider.js.map +1 -1
- package/dist/components/drawer/snice-drawer.d.ts +4 -4
- package/dist/components/drawer/snice-drawer.js +25 -19
- package/dist/components/drawer/snice-drawer.js.map +1 -1
- package/dist/components/input/snice-input.d.ts +8 -6
- package/dist/components/input/snice-input.js +122 -105
- package/dist/components/input/snice-input.js.map +1 -1
- package/dist/components/layout/snice-layout-blog.d.ts +4 -4
- package/dist/components/layout/snice-layout-blog.js +21 -19
- package/dist/components/layout/snice-layout-blog.js.map +1 -1
- package/dist/components/layout/snice-layout-card.d.ts +2 -2
- package/dist/components/layout/snice-layout-card.js +16 -9
- package/dist/components/layout/snice-layout-card.js.map +1 -1
- package/dist/components/layout/snice-layout-centered.d.ts +2 -2
- package/dist/components/layout/snice-layout-centered.js +14 -7
- package/dist/components/layout/snice-layout-centered.js.map +1 -1
- package/dist/components/layout/snice-layout-dashboard.d.ts +5 -5
- package/dist/components/layout/snice-layout-dashboard.js +38 -30
- package/dist/components/layout/snice-layout-dashboard.js.map +1 -1
- package/dist/components/layout/snice-layout-fullscreen.d.ts +2 -2
- package/dist/components/layout/snice-layout-fullscreen.js +17 -10
- package/dist/components/layout/snice-layout-fullscreen.js.map +1 -1
- package/dist/components/layout/snice-layout-landing.d.ts +4 -4
- package/dist/components/layout/snice-layout-landing.js +21 -19
- package/dist/components/layout/snice-layout-landing.js.map +1 -1
- package/dist/components/layout/snice-layout-minimal.d.ts +2 -2
- package/dist/components/layout/snice-layout-minimal.js +17 -6
- package/dist/components/layout/snice-layout-minimal.js.map +1 -1
- package/dist/components/layout/snice-layout-sidebar.d.ts +5 -4
- package/dist/components/layout/snice-layout-sidebar.js +42 -20
- package/dist/components/layout/snice-layout-sidebar.js.map +1 -1
- package/dist/components/layout/snice-layout-split.d.ts +2 -2
- package/dist/components/layout/snice-layout-split.js +14 -7
- package/dist/components/layout/snice-layout-split.js.map +1 -1
- package/dist/components/layout/snice-layout.d.ts +4 -4
- package/dist/components/layout/snice-layout.js +16 -10
- package/dist/components/layout/snice-layout.js.map +1 -1
- package/dist/components/login/snice-login.d.ts +6 -11
- package/dist/components/login/snice-login.js +97 -71
- package/dist/components/login/snice-login.js.map +1 -1
- package/dist/components/modal/snice-modal.d.ts +5 -9
- package/dist/components/modal/snice-modal.js +47 -78
- package/dist/components/modal/snice-modal.js.map +1 -1
- package/dist/components/nav/snice-nav.d.ts +13 -7
- package/dist/components/nav/snice-nav.js +191 -100
- package/dist/components/nav/snice-nav.js.map +1 -1
- package/dist/components/nav/snice-nav.types.d.ts +3 -3
- package/dist/components/pagination/snice-pagination.d.ts +6 -7
- package/dist/components/pagination/snice-pagination.js +94 -81
- package/dist/components/pagination/snice-pagination.js.map +1 -1
- package/dist/components/progress/snice-progress.d.ts +2 -7
- package/dist/components/progress/snice-progress.js +41 -98
- package/dist/components/progress/snice-progress.js.map +1 -1
- package/dist/components/radio/snice-radio.d.ts +4 -4
- package/dist/components/radio/snice-radio.js +52 -44
- package/dist/components/radio/snice-radio.js.map +1 -1
- package/dist/components/select/snice-option.d.ts +2 -1
- package/dist/components/select/snice-option.js +12 -5
- package/dist/components/select/snice-option.js.map +1 -1
- package/dist/components/select/snice-select.d.ts +9 -21
- package/dist/components/select/snice-select.js +98 -170
- package/dist/components/select/snice-select.js.map +1 -1
- package/dist/components/skeleton/snice-skeleton.d.ts +2 -6
- package/dist/components/skeleton/snice-skeleton.js +18 -49
- package/dist/components/skeleton/snice-skeleton.js.map +1 -1
- package/dist/components/snice-cell-BLFVdxPp.js +4 -0
- package/dist/components/snice-cell-BLFVdxPp.js.map +1 -0
- package/dist/components/switch/snice-switch.d.ts +2 -2
- package/dist/components/switch/snice-switch.js +38 -26
- package/dist/components/switch/snice-switch.js.map +1 -1
- package/dist/components/table/snice-cell-actions.d.ts +24 -0
- package/dist/components/table/snice-cell-actions.js +149 -0
- package/dist/components/table/snice-cell-actions.js.map +1 -0
- package/dist/components/table/snice-cell-boolean.d.ts +2 -2
- package/dist/components/table/snice-cell-boolean.js +13 -7
- package/dist/components/table/snice-cell-boolean.js.map +1 -1
- package/dist/components/table/snice-cell-color.d.ts +18 -0
- package/dist/components/table/snice-cell-color.js +149 -0
- package/dist/components/table/snice-cell-color.js.map +1 -0
- package/dist/components/table/snice-cell-currency.d.ts +24 -0
- package/dist/components/table/snice-cell-currency.js +235 -0
- package/dist/components/table/snice-cell-currency.js.map +1 -0
- package/dist/components/table/snice-cell-date.d.ts +2 -2
- package/dist/components/table/snice-cell-date.js +14 -8
- package/dist/components/table/snice-cell-date.js.map +1 -1
- package/dist/components/table/snice-cell-duration.d.ts +2 -2
- package/dist/components/table/snice-cell-duration.js +12 -6
- package/dist/components/table/snice-cell-duration.js.map +1 -1
- package/dist/components/table/snice-cell-email.d.ts +15 -0
- package/dist/components/table/snice-cell-email.js +125 -0
- package/dist/components/table/snice-cell-email.js.map +1 -0
- package/dist/components/table/snice-cell-filesize.d.ts +2 -2
- package/dist/components/table/snice-cell-filesize.js +12 -6
- package/dist/components/table/snice-cell-filesize.js.map +1 -1
- package/dist/components/table/snice-cell-image.d.ts +20 -0
- package/dist/components/table/snice-cell-image.js +162 -0
- package/dist/components/table/snice-cell-image.js.map +1 -0
- package/dist/components/table/snice-cell-json.d.ts +20 -0
- package/dist/components/table/snice-cell-json.js +186 -0
- package/dist/components/table/snice-cell-json.js.map +1 -0
- package/dist/components/table/snice-cell-link.d.ts +17 -0
- package/dist/components/table/snice-cell-link.js +142 -0
- package/dist/components/table/snice-cell-link.js.map +1 -0
- package/dist/components/table/snice-cell-location.d.ts +19 -0
- package/dist/components/table/snice-cell-location.js +185 -0
- package/dist/components/table/snice-cell-location.js.map +1 -0
- package/dist/components/table/snice-cell-number.d.ts +2 -2
- package/dist/components/table/snice-cell-number.js +12 -6
- package/dist/components/table/snice-cell-number.js.map +1 -1
- package/dist/components/table/snice-cell-percentage.d.ts +22 -0
- package/dist/components/table/snice-cell-percentage.js +208 -0
- package/dist/components/table/snice-cell-percentage.js.map +1 -0
- package/dist/components/table/snice-cell-phone.d.ts +18 -0
- package/dist/components/table/snice-cell-phone.js +153 -0
- package/dist/components/table/snice-cell-phone.js.map +1 -0
- package/dist/components/table/snice-cell-progress.d.ts +2 -2
- package/dist/components/table/snice-cell-progress.js +12 -6
- package/dist/components/table/snice-cell-progress.js.map +1 -1
- package/dist/components/table/snice-cell-rating.d.ts +2 -2
- package/dist/components/table/snice-cell-rating.js +12 -6
- package/dist/components/table/snice-cell-rating.js.map +1 -1
- package/dist/components/table/snice-cell-sparkline.d.ts +2 -2
- package/dist/components/table/snice-cell-sparkline.js +13 -7
- package/dist/components/table/snice-cell-sparkline.js.map +1 -1
- package/dist/components/table/snice-cell-status.d.ts +17 -0
- package/dist/components/table/snice-cell-status.js +144 -0
- package/dist/components/table/snice-cell-status.js.map +1 -0
- package/dist/components/table/snice-cell-tag.d.ts +16 -0
- package/dist/components/table/snice-cell-tag.js +131 -0
- package/dist/components/table/snice-cell-tag.js.map +1 -0
- package/dist/components/table/snice-cell-text.d.ts +2 -2
- package/dist/components/table/snice-cell-text.js +14 -8
- package/dist/components/table/snice-cell-text.js.map +1 -1
- package/dist/components/table/snice-cell.d.ts +2 -2
- package/dist/components/table/snice-cell.js +12 -6
- package/dist/components/table/snice-cell.js.map +1 -1
- package/dist/components/table/snice-column.d.ts +1 -1
- package/dist/components/table/snice-column.js +6 -3
- package/dist/components/table/snice-column.js.map +1 -1
- package/dist/components/table/snice-header.d.ts +5 -5
- package/dist/components/table/snice-header.js +60 -50
- package/dist/components/table/snice-header.js.map +1 -1
- package/dist/components/table/snice-progress.d.ts +2 -2
- package/dist/components/table/snice-progress.js +18 -11
- package/dist/components/table/snice-progress.js.map +1 -1
- package/dist/components/table/snice-rating.d.ts +2 -2
- package/dist/components/table/snice-rating.js +15 -8
- package/dist/components/table/snice-rating.js.map +1 -1
- package/dist/components/table/snice-row.d.ts +17 -6
- package/dist/components/table/snice-row.js +95 -44
- package/dist/components/table/snice-row.js.map +1 -1
- package/dist/components/table/snice-table.d.ts +18 -10
- package/dist/components/table/snice-table.js +355 -173
- package/dist/components/table/snice-table.js.map +1 -1
- package/dist/components/table/snice-table.types.d.ts +101 -2
- package/dist/components/tabs/snice-tab-panel.d.ts +2 -2
- package/dist/components/tabs/snice-tab-panel.js +12 -6
- package/dist/components/tabs/snice-tab-panel.js.map +1 -1
- package/dist/components/tabs/snice-tab.d.ts +6 -5
- package/dist/components/tabs/snice-tab.js +36 -19
- package/dist/components/tabs/snice-tab.js.map +1 -1
- package/dist/components/tabs/snice-tabs.d.ts +5 -5
- package/dist/components/tabs/snice-tabs.js +38 -28
- package/dist/components/tabs/snice-tabs.js.map +1 -1
- package/dist/components/toast/snice-toast-container.d.ts +7 -7
- package/dist/components/toast/snice-toast-container.js +19 -12
- package/dist/components/toast/snice-toast-container.js.map +1 -1
- package/dist/components/toast/snice-toast.d.ts +3 -15
- package/dist/components/toast/snice-toast.js +49 -108
- package/dist/components/toast/snice-toast.js.map +1 -1
- package/dist/components/tooltip/snice-tooltip.d.ts +2 -2
- package/dist/components/tooltip/snice-tooltip.js +14 -7
- package/dist/components/tooltip/snice-tooltip.js.map +1 -1
- package/dist/context.d.ts +44 -0
- package/dist/element-ready.d.ts +40 -0
- package/dist/{types/element.d.ts → element.d.ts} +2 -8
- package/dist/{types/events.d.ts → events.d.ts} +0 -4
- package/dist/index.cjs +2589 -605
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +21 -0
- package/dist/index.esm.js +2568 -604
- package/dist/index.esm.js.map +1 -1
- package/dist/index.iife.js +2589 -605
- package/dist/index.iife.js.map +1 -1
- package/dist/method-decorators.d.ts +121 -0
- package/dist/on.d.ts +59 -0
- package/dist/parts.d.ts +159 -0
- package/dist/render-debug.d.ts +27 -0
- package/dist/render-tracker.d.ts +14 -0
- package/dist/render.d.ts +96 -0
- package/dist/symbols.cjs +163 -0
- package/dist/symbols.cjs.map +1 -1
- package/dist/{types/symbols.d.ts → symbols.d.ts} +22 -0
- package/dist/symbols.esm.js +27 -3
- package/dist/symbols.esm.js.map +1 -1
- package/dist/template.d.ts +100 -0
- package/dist/transitions.cjs +219 -0
- package/dist/transitions.esm.js +2 -2
- package/dist/types/context.d.ts +48 -0
- package/dist/types/element-options.d.ts +26 -0
- package/dist/types/index.d.ts +25 -9
- package/dist/types/nav-context.d.ts +19 -0
- package/dist/types/{types/on-options.d.ts → on-options.d.ts} +2 -0
- package/dist/types/{types/placard.d.ts → placard.d.ts} +0 -1
- package/docs/ai/README.md +17 -0
- package/docs/ai/api.md +175 -0
- package/docs/ai/architecture.md +160 -0
- package/docs/ai/components/accordion.md +174 -0
- package/docs/ai/components/alert.md +77 -0
- package/docs/ai/components/avatar.md +61 -0
- package/docs/ai/components/badge.md +69 -0
- package/docs/ai/components/breadcrumbs.md +74 -0
- package/docs/ai/components/button.md +75 -0
- package/docs/ai/components/card.md +61 -0
- package/docs/ai/components/checkbox.md +74 -0
- package/docs/ai/components/chip.md +73 -0
- package/docs/ai/components/date-picker.md +75 -0
- package/docs/ai/components/divider.md +66 -0
- package/docs/ai/components/drawer.md +80 -0
- package/docs/ai/components/input.md +111 -0
- package/docs/ai/components/login.md +109 -0
- package/docs/ai/components/modal.md +67 -0
- package/docs/ai/components/nav.md +76 -0
- package/docs/ai/components/pagination.md +55 -0
- package/docs/ai/components/progress.md +72 -0
- package/docs/ai/components/radio.md +79 -0
- package/docs/ai/components/select.md +92 -0
- package/docs/ai/components/skeleton.md +57 -0
- package/docs/ai/components/switch.md +53 -0
- package/docs/ai/components/table.md +227 -0
- package/docs/ai/components/tabs.md +83 -0
- package/docs/ai/components/toast.md +140 -0
- package/docs/ai/components/tooltip.md +146 -0
- package/docs/ai/patterns.md +244 -0
- package/docs/components/accordion.md +558 -0
- package/docs/components/drawer.md +602 -0
- package/docs/components/modal.md +558 -0
- package/docs/components/nav.md +239 -0
- package/docs/components/pagination.md +289 -0
- package/docs/components/select.md +599 -0
- package/docs/components/switch.md +354 -0
- package/docs/components/tabs.md +546 -0
- package/docs/components/toast.md +506 -0
- package/docs/components/tooltip.md +523 -0
- package/docs/controllers.md +744 -0
- package/docs/elements.md +855 -0
- package/docs/events.md +807 -0
- package/docs/migration-v2-to-v3.md +569 -0
- package/docs/observe.md +588 -0
- package/docs/placards.md +401 -0
- package/docs/request-response.md +852 -0
- package/docs/routing.md +1186 -0
- package/package.json +10 -11
- package/dist/components/snice-cell-C9N6yGxQ.js +0 -4
- package/dist/components/snice-cell-C9N6yGxQ.js.map +0 -1
- package/dist/types/types/index.d.ts +0 -23
- /package/dist/{types/controller.d.ts → controller.d.ts} +0 -0
- /package/dist/{types/global.d.ts → global.d.ts} +0 -0
- /package/dist/{types/observe.d.ts → observe.d.ts} +0 -0
- /package/dist/{types/request-response.d.ts → request-response.d.ts} +0 -0
- /package/dist/{types/router.d.ts → router.d.ts} +0 -0
- /package/dist/{types/testing.d.ts → testing.d.ts} +0 -0
- /package/dist/{types/transitions.d.ts → transitions.d.ts} +0 -0
- /package/dist/types/{types/adopted-options.d.ts → adopted-options.d.ts} +0 -0
- /package/dist/types/{types/app-context.d.ts → app-context.d.ts} +0 -0
- /package/dist/types/{types/dispatch-options.d.ts → dispatch-options.d.ts} +0 -0
- /package/dist/types/{types/guard.d.ts → guard.d.ts} +0 -0
- /package/dist/types/{types/i-controller.d.ts → i-controller.d.ts} +0 -0
- /package/dist/types/{types/moved-options.d.ts → moved-options.d.ts} +0 -0
- /package/dist/types/{types/observe-options.d.ts → observe-options.d.ts} +0 -0
- /package/dist/types/{types/page-options.d.ts → page-options.d.ts} +0 -0
- /package/dist/types/{types/part-options.d.ts → part-options.d.ts} +0 -0
- /package/dist/types/{types/property-converter.d.ts → property-converter.d.ts} +0 -0
- /package/dist/types/{types/property-options.d.ts → property-options.d.ts} +0 -0
- /package/dist/types/{types/query-options.d.ts → query-options.d.ts} +0 -0
- /package/dist/types/{types/request-options.d.ts → request-options.d.ts} +0 -0
- /package/dist/types/{types/respond-options.d.ts → respond-options.d.ts} +0 -0
- /package/dist/types/{types/route-params.d.ts → route-params.d.ts} +0 -0
- /package/dist/types/{types/router-instance.d.ts → router-instance.d.ts} +0 -0
- /package/dist/types/{types/router-options.d.ts → router-options.d.ts} +0 -0
- /package/dist/types/{types/simple-array.d.ts → simple-array.d.ts} +0 -0
- /package/dist/types/{types/snice-element.d.ts → snice-element.d.ts} +0 -0
- /package/dist/types/{types/snice-global.d.ts → snice-global.d.ts} +0 -0
- /package/dist/types/{types/transition.d.ts → transition.d.ts} +0 -0
- /package/dist/{types/utils.d.ts → utils.d.ts} +0 -0
|
@@ -0,0 +1,599 @@
|
|
|
1
|
+
# Select Components
|
|
2
|
+
|
|
3
|
+
The select components provide a customizable dropdown selection interface. The system consists of two components: `<snice-select>` (the select container) and `<snice-option>` (individual options).
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Components](#components)
|
|
8
|
+
- [snice-select](#snice-select)
|
|
9
|
+
- [snice-option](#snice-option)
|
|
10
|
+
- [Properties](#properties)
|
|
11
|
+
- [Methods](#methods)
|
|
12
|
+
- [Events](#events)
|
|
13
|
+
- [Features](#features)
|
|
14
|
+
- [Examples](#examples)
|
|
15
|
+
|
|
16
|
+
## Basic Usage
|
|
17
|
+
|
|
18
|
+
```html
|
|
19
|
+
<snice-select label="Choose a color" name="color">
|
|
20
|
+
<snice-option value="red">Red</snice-option>
|
|
21
|
+
<snice-option value="blue">Blue</snice-option>
|
|
22
|
+
<snice-option value="green">Green</snice-option>
|
|
23
|
+
</snice-select>
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
```typescript
|
|
27
|
+
import 'snice/components/select/snice-select';
|
|
28
|
+
import 'snice/components/select/snice-option';
|
|
29
|
+
|
|
30
|
+
const select = document.querySelector('snice-select');
|
|
31
|
+
select.addEventListener('@snice/select-change', (e) => {
|
|
32
|
+
console.log('Selected:', e.detail.value);
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
## Components
|
|
37
|
+
|
|
38
|
+
### snice-select
|
|
39
|
+
|
|
40
|
+
The main select component that manages the dropdown interface and selection state.
|
|
41
|
+
|
|
42
|
+
#### Properties
|
|
43
|
+
|
|
44
|
+
| Property | Type | Default | Description |
|
|
45
|
+
|----------|------|---------|-------------|
|
|
46
|
+
| `value` | `string` | `''` | The selected value (comma-separated for multiple) |
|
|
47
|
+
| `disabled` | `boolean` | `false` | Whether the select is disabled |
|
|
48
|
+
| `required` | `boolean` | `false` | Whether the select is required in a form |
|
|
49
|
+
| `invalid` | `boolean` | `false` | Whether to show invalid state styling |
|
|
50
|
+
| `readonly` | `boolean` | `false` | Whether the select is readonly |
|
|
51
|
+
| `multiple` | `boolean` | `false` | Whether multiple selection is allowed |
|
|
52
|
+
| `searchable` | `boolean` | `false` | Whether to show a search input |
|
|
53
|
+
| `clearable` | `boolean` | `false` | Whether to show a clear button |
|
|
54
|
+
| `open` | `boolean` | `false` | Whether the dropdown is open |
|
|
55
|
+
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Size variant |
|
|
56
|
+
| `name` | `string` | `''` | Form field name |
|
|
57
|
+
| `label` | `string` | `''` | Label text displayed above select |
|
|
58
|
+
| `placeholder` | `string` | `'Select an option'` | Placeholder text |
|
|
59
|
+
| `maxHeight` | `string` | `'200px'` | Maximum height of dropdown |
|
|
60
|
+
|
|
61
|
+
#### Methods
|
|
62
|
+
|
|
63
|
+
##### `selectOption(value: string): void`
|
|
64
|
+
Programmatically select an option by value.
|
|
65
|
+
|
|
66
|
+
```typescript
|
|
67
|
+
select.selectOption('red');
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
##### `clear(): void`
|
|
71
|
+
Clear the current selection.
|
|
72
|
+
|
|
73
|
+
```typescript
|
|
74
|
+
select.clear();
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
##### `openDropdown(): void`
|
|
78
|
+
Open the dropdown.
|
|
79
|
+
|
|
80
|
+
```typescript
|
|
81
|
+
select.openDropdown();
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
##### `closeDropdown(): void`
|
|
85
|
+
Close the dropdown.
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
select.closeDropdown();
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
##### `toggleDropdown(): void`
|
|
92
|
+
Toggle the dropdown open/closed state.
|
|
93
|
+
|
|
94
|
+
```typescript
|
|
95
|
+
select.toggleDropdown();
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
##### `focus(): void`
|
|
99
|
+
Give focus to the select trigger.
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
select.focus();
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
##### `blur(): void`
|
|
106
|
+
Remove focus from the select and close dropdown.
|
|
107
|
+
|
|
108
|
+
```typescript
|
|
109
|
+
select.blur();
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
#### Events
|
|
113
|
+
|
|
114
|
+
##### `@snice/select-change`
|
|
115
|
+
Fired when the selection changes.
|
|
116
|
+
|
|
117
|
+
**Event Detail:**
|
|
118
|
+
```typescript
|
|
119
|
+
{
|
|
120
|
+
value: string | string[]; // Selected value(s)
|
|
121
|
+
option?: SelectOption; // The selected option object
|
|
122
|
+
select: SniceSelectElement; // Reference to the select element
|
|
123
|
+
}
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Usage:**
|
|
127
|
+
```typescript
|
|
128
|
+
select.addEventListener('@snice/select-change', (e) => {
|
|
129
|
+
const { value, option } = e.detail;
|
|
130
|
+
console.log(`Selected ${option?.label} with value ${value}`);
|
|
131
|
+
});
|
|
132
|
+
```
|
|
133
|
+
|
|
134
|
+
##### `@snice/select-open`
|
|
135
|
+
Fired when the dropdown opens.
|
|
136
|
+
|
|
137
|
+
**Event Detail:**
|
|
138
|
+
```typescript
|
|
139
|
+
{
|
|
140
|
+
select: SniceSelectElement; // Reference to the select element
|
|
141
|
+
}
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
##### `@snice/select-close`
|
|
145
|
+
Fired when the dropdown closes.
|
|
146
|
+
|
|
147
|
+
**Event Detail:**
|
|
148
|
+
```typescript
|
|
149
|
+
{
|
|
150
|
+
select: SniceSelectElement; // Reference to the select element
|
|
151
|
+
}
|
|
152
|
+
```
|
|
153
|
+
|
|
154
|
+
### snice-option
|
|
155
|
+
|
|
156
|
+
Individual option component. Must be placed inside `<snice-select>`.
|
|
157
|
+
|
|
158
|
+
#### Properties
|
|
159
|
+
|
|
160
|
+
| Property | Type | Default | Description |
|
|
161
|
+
|----------|------|---------|-------------|
|
|
162
|
+
| `value` | `string` | `''` | Option value (uses label if not specified) |
|
|
163
|
+
| `label` | `string` | `''` | Option label (uses text content if not specified) |
|
|
164
|
+
| `disabled` | `boolean` | `false` | Whether the option is disabled |
|
|
165
|
+
| `selected` | `boolean` | `false` | Whether the option is initially selected |
|
|
166
|
+
| `icon` | `string` | `''` | URL of an icon to display |
|
|
167
|
+
|
|
168
|
+
#### Getter
|
|
169
|
+
|
|
170
|
+
##### `optionData`
|
|
171
|
+
Returns an object containing the option's data.
|
|
172
|
+
|
|
173
|
+
```typescript
|
|
174
|
+
const data = option.optionData;
|
|
175
|
+
// { value, label, disabled, selected, icon }
|
|
176
|
+
```
|
|
177
|
+
|
|
178
|
+
## Features
|
|
179
|
+
|
|
180
|
+
### Single Selection
|
|
181
|
+
|
|
182
|
+
```html
|
|
183
|
+
<snice-select label="Choose one">
|
|
184
|
+
<snice-option value="1">Option 1</snice-option>
|
|
185
|
+
<snice-option value="2">Option 2</snice-option>
|
|
186
|
+
<snice-option value="3">Option 3</snice-option>
|
|
187
|
+
</snice-select>
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
### Multiple Selection
|
|
191
|
+
|
|
192
|
+
```html
|
|
193
|
+
<snice-select label="Choose multiple" multiple>
|
|
194
|
+
<snice-option value="1">Option 1</snice-option>
|
|
195
|
+
<snice-option value="2">Option 2</snice-option>
|
|
196
|
+
<snice-option value="3">Option 3</snice-option>
|
|
197
|
+
</snice-select>
|
|
198
|
+
```
|
|
199
|
+
|
|
200
|
+
### Searchable
|
|
201
|
+
|
|
202
|
+
```html
|
|
203
|
+
<snice-select label="Search for option" searchable>
|
|
204
|
+
<snice-option value="apple">Apple</snice-option>
|
|
205
|
+
<snice-option value="banana">Banana</snice-option>
|
|
206
|
+
<snice-option value="cherry">Cherry</snice-option>
|
|
207
|
+
<snice-option value="date">Date</snice-option>
|
|
208
|
+
<snice-option value="elderberry">Elderberry</snice-option>
|
|
209
|
+
</snice-select>
|
|
210
|
+
```
|
|
211
|
+
|
|
212
|
+
### Clearable
|
|
213
|
+
|
|
214
|
+
```html
|
|
215
|
+
<snice-select label="Clearable select" clearable>
|
|
216
|
+
<snice-option value="1">Option 1</snice-option>
|
|
217
|
+
<snice-option value="2">Option 2</snice-option>
|
|
218
|
+
</snice-select>
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
### Disabled Options
|
|
222
|
+
|
|
223
|
+
```html
|
|
224
|
+
<snice-select label="With disabled options">
|
|
225
|
+
<snice-option value="1">Option 1</snice-option>
|
|
226
|
+
<snice-option value="2" disabled>Option 2 (disabled)</snice-option>
|
|
227
|
+
<snice-option value="3">Option 3</snice-option>
|
|
228
|
+
</snice-select>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
### With Icons
|
|
232
|
+
|
|
233
|
+
```html
|
|
234
|
+
<snice-select label="Select with icons">
|
|
235
|
+
<snice-option value="user" icon="/icons/user.svg">User</snice-option>
|
|
236
|
+
<snice-option value="admin" icon="/icons/admin.svg">Admin</snice-option>
|
|
237
|
+
<snice-option value="guest" icon="/icons/guest.svg">Guest</snice-option>
|
|
238
|
+
</snice-select>
|
|
239
|
+
```
|
|
240
|
+
|
|
241
|
+
## Examples
|
|
242
|
+
|
|
243
|
+
### Basic Select
|
|
244
|
+
|
|
245
|
+
```html
|
|
246
|
+
<snice-select
|
|
247
|
+
label="Favorite fruit"
|
|
248
|
+
name="fruit"
|
|
249
|
+
placeholder="Choose a fruit">
|
|
250
|
+
<snice-option value="apple">Apple</snice-option>
|
|
251
|
+
<snice-option value="banana">Banana</snice-option>
|
|
252
|
+
<snice-option value="orange">Orange</snice-option>
|
|
253
|
+
</snice-select>
|
|
254
|
+
```
|
|
255
|
+
|
|
256
|
+
### Size Variants
|
|
257
|
+
|
|
258
|
+
```html
|
|
259
|
+
<!-- Small -->
|
|
260
|
+
<snice-select size="small" label="Small select">
|
|
261
|
+
<snice-option value="1">Option 1</snice-option>
|
|
262
|
+
<snice-option value="2">Option 2</snice-option>
|
|
263
|
+
</snice-select>
|
|
264
|
+
|
|
265
|
+
<!-- Medium (default) -->
|
|
266
|
+
<snice-select size="medium" label="Medium select">
|
|
267
|
+
<snice-option value="1">Option 1</snice-option>
|
|
268
|
+
<snice-option value="2">Option 2</snice-option>
|
|
269
|
+
</snice-select>
|
|
270
|
+
|
|
271
|
+
<!-- Large -->
|
|
272
|
+
<snice-select size="large" label="Large select">
|
|
273
|
+
<snice-option value="1">Option 1</snice-option>
|
|
274
|
+
<snice-option value="2">Option 2</snice-option>
|
|
275
|
+
</snice-select>
|
|
276
|
+
```
|
|
277
|
+
|
|
278
|
+
### Form Integration
|
|
279
|
+
|
|
280
|
+
```html
|
|
281
|
+
<form id="userForm">
|
|
282
|
+
<snice-select
|
|
283
|
+
name="role"
|
|
284
|
+
label="User role"
|
|
285
|
+
required>
|
|
286
|
+
<snice-option value="user">User</snice-option>
|
|
287
|
+
<snice-option value="admin">Admin</snice-option>
|
|
288
|
+
<snice-option value="moderator">Moderator</snice-option>
|
|
289
|
+
</snice-select>
|
|
290
|
+
|
|
291
|
+
<snice-select
|
|
292
|
+
name="permissions"
|
|
293
|
+
label="Permissions"
|
|
294
|
+
multiple>
|
|
295
|
+
<snice-option value="read">Read</snice-option>
|
|
296
|
+
<snice-option value="write">Write</snice-option>
|
|
297
|
+
<snice-option value="delete">Delete</snice-option>
|
|
298
|
+
</snice-select>
|
|
299
|
+
|
|
300
|
+
<button type="submit">Submit</button>
|
|
301
|
+
</form>
|
|
302
|
+
|
|
303
|
+
<script type="module">
|
|
304
|
+
import 'snice/components/select/snice-select';
|
|
305
|
+
import 'snice/components/select/snice-option';
|
|
306
|
+
|
|
307
|
+
const form = document.querySelector('#userForm');
|
|
308
|
+
|
|
309
|
+
form.addEventListener('submit', (e) => {
|
|
310
|
+
e.preventDefault();
|
|
311
|
+
|
|
312
|
+
const formData = new FormData(form);
|
|
313
|
+
const data = Object.fromEntries(formData);
|
|
314
|
+
|
|
315
|
+
console.log('Form data:', data);
|
|
316
|
+
// { role: 'admin', permissions: 'read,write' }
|
|
317
|
+
});
|
|
318
|
+
</script>
|
|
319
|
+
```
|
|
320
|
+
|
|
321
|
+
### Programmatic Control
|
|
322
|
+
|
|
323
|
+
```typescript
|
|
324
|
+
import type { SniceSelectElement } from 'snice/components/select/snice-select.types';
|
|
325
|
+
|
|
326
|
+
const select = document.querySelector<SniceSelectElement>('snice-select');
|
|
327
|
+
|
|
328
|
+
// Select an option
|
|
329
|
+
select.selectOption('apple');
|
|
330
|
+
|
|
331
|
+
// Clear selection
|
|
332
|
+
select.clear();
|
|
333
|
+
|
|
334
|
+
// Open/close dropdown
|
|
335
|
+
select.openDropdown();
|
|
336
|
+
select.closeDropdown();
|
|
337
|
+
select.toggleDropdown();
|
|
338
|
+
|
|
339
|
+
// Get current value
|
|
340
|
+
console.log(select.value);
|
|
341
|
+
|
|
342
|
+
// Set value
|
|
343
|
+
select.value = 'banana';
|
|
344
|
+
```
|
|
345
|
+
|
|
346
|
+
### With Event Handling
|
|
347
|
+
|
|
348
|
+
```typescript
|
|
349
|
+
const select = document.querySelector('snice-select');
|
|
350
|
+
|
|
351
|
+
select.addEventListener('@snice/select-change', (e) => {
|
|
352
|
+
const { value, option } = e.detail;
|
|
353
|
+
|
|
354
|
+
if (option) {
|
|
355
|
+
console.log(`Selected: ${option.label} (${value})`);
|
|
356
|
+
}
|
|
357
|
+
|
|
358
|
+
// Trigger dependent logic
|
|
359
|
+
updateDependentFields(value);
|
|
360
|
+
});
|
|
361
|
+
|
|
362
|
+
select.addEventListener('@snice/select-open', () => {
|
|
363
|
+
console.log('Dropdown opened');
|
|
364
|
+
});
|
|
365
|
+
|
|
366
|
+
select.addEventListener('@snice/select-close', () => {
|
|
367
|
+
console.log('Dropdown closed');
|
|
368
|
+
});
|
|
369
|
+
```
|
|
370
|
+
|
|
371
|
+
### Dynamic Options
|
|
372
|
+
|
|
373
|
+
```html
|
|
374
|
+
<snice-select id="dynamicSelect" label="Dynamic options"></snice-select>
|
|
375
|
+
|
|
376
|
+
<button id="loadOptions">Load Options</button>
|
|
377
|
+
|
|
378
|
+
<script type="module">
|
|
379
|
+
import 'snice/components/select/snice-select';
|
|
380
|
+
import 'snice/components/select/snice-option';
|
|
381
|
+
|
|
382
|
+
const select = document.querySelector('#dynamicSelect');
|
|
383
|
+
const loadBtn = document.querySelector('#loadOptions');
|
|
384
|
+
|
|
385
|
+
loadBtn.addEventListener('click', async () => {
|
|
386
|
+
// Fetch options from API
|
|
387
|
+
const response = await fetch('/api/options');
|
|
388
|
+
const options = await response.json();
|
|
389
|
+
|
|
390
|
+
// Clear existing options
|
|
391
|
+
select.innerHTML = '';
|
|
392
|
+
|
|
393
|
+
// Add new options
|
|
394
|
+
options.forEach(opt => {
|
|
395
|
+
const option = document.createElement('snice-option');
|
|
396
|
+
option.value = opt.id;
|
|
397
|
+
option.label = opt.name;
|
|
398
|
+
if (opt.icon) option.icon = opt.icon;
|
|
399
|
+
if (opt.disabled) option.disabled = true;
|
|
400
|
+
select.appendChild(option);
|
|
401
|
+
});
|
|
402
|
+
});
|
|
403
|
+
</script>
|
|
404
|
+
```
|
|
405
|
+
|
|
406
|
+
### Multiple Selection with Tags
|
|
407
|
+
|
|
408
|
+
```html
|
|
409
|
+
<snice-select
|
|
410
|
+
label="Select tags"
|
|
411
|
+
name="tags"
|
|
412
|
+
multiple
|
|
413
|
+
clearable
|
|
414
|
+
placeholder="Choose tags">
|
|
415
|
+
<snice-option value="javascript">JavaScript</snice-option>
|
|
416
|
+
<snice-option value="typescript">TypeScript</snice-option>
|
|
417
|
+
<snice-option value="python">Python</snice-option>
|
|
418
|
+
<snice-option value="rust">Rust</snice-option>
|
|
419
|
+
<snice-option value="go">Go</snice-option>
|
|
420
|
+
</snice-select>
|
|
421
|
+
```
|
|
422
|
+
|
|
423
|
+
Selected options will display as removable tags. Click the × on a tag to remove it.
|
|
424
|
+
|
|
425
|
+
### Searchable with Many Options
|
|
426
|
+
|
|
427
|
+
```html
|
|
428
|
+
<snice-select
|
|
429
|
+
label="Choose a country"
|
|
430
|
+
name="country"
|
|
431
|
+
searchable
|
|
432
|
+
max-height="300px">
|
|
433
|
+
<snice-option value="us">United States</snice-option>
|
|
434
|
+
<snice-option value="uk">United Kingdom</snice-option>
|
|
435
|
+
<snice-option value="ca">Canada</snice-option>
|
|
436
|
+
<snice-option value="au">Australia</snice-option>
|
|
437
|
+
<snice-option value="de">Germany</snice-option>
|
|
438
|
+
<snice-option value="fr">France</snice-option>
|
|
439
|
+
<!-- Many more options... -->
|
|
440
|
+
</snice-select>
|
|
441
|
+
```
|
|
442
|
+
|
|
443
|
+
### Validation Example
|
|
444
|
+
|
|
445
|
+
```html
|
|
446
|
+
<form id="validationForm">
|
|
447
|
+
<snice-select
|
|
448
|
+
id="categorySelect"
|
|
449
|
+
name="category"
|
|
450
|
+
label="Category"
|
|
451
|
+
required
|
|
452
|
+
placeholder="Select a category">
|
|
453
|
+
<snice-option value="tech">Technology</snice-option>
|
|
454
|
+
<snice-option value="health">Health</snice-option>
|
|
455
|
+
<snice-option value="finance">Finance</snice-option>
|
|
456
|
+
</snice-select>
|
|
457
|
+
|
|
458
|
+
<button type="submit">Submit</button>
|
|
459
|
+
</form>
|
|
460
|
+
|
|
461
|
+
<script type="module">
|
|
462
|
+
import 'snice/components/select/snice-select';
|
|
463
|
+
import 'snice/components/select/snice-option';
|
|
464
|
+
|
|
465
|
+
const form = document.querySelector('#validationForm');
|
|
466
|
+
const select = document.querySelector('#categorySelect');
|
|
467
|
+
|
|
468
|
+
form.addEventListener('submit', (e) => {
|
|
469
|
+
e.preventDefault();
|
|
470
|
+
|
|
471
|
+
if (!select.value) {
|
|
472
|
+
select.invalid = true;
|
|
473
|
+
alert('Please select a category');
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
|
|
477
|
+
select.invalid = false;
|
|
478
|
+
// Submit form...
|
|
479
|
+
});
|
|
480
|
+
</script>
|
|
481
|
+
```
|
|
482
|
+
|
|
483
|
+
### Complete Example
|
|
484
|
+
|
|
485
|
+
```html
|
|
486
|
+
<!DOCTYPE html>
|
|
487
|
+
<html>
|
|
488
|
+
<head>
|
|
489
|
+
<style>
|
|
490
|
+
.select-demo {
|
|
491
|
+
max-width: 400px;
|
|
492
|
+
margin: 2rem auto;
|
|
493
|
+
display: flex;
|
|
494
|
+
flex-direction: column;
|
|
495
|
+
gap: 1rem;
|
|
496
|
+
}
|
|
497
|
+
</style>
|
|
498
|
+
|
|
499
|
+
<script type="module">
|
|
500
|
+
import 'snice/components/select/snice-select';
|
|
501
|
+
import 'snice/components/select/snice-option';
|
|
502
|
+
|
|
503
|
+
// Handle select changes
|
|
504
|
+
document.addEventListener('@snice/select-change', (e) => {
|
|
505
|
+
console.log('Selection changed:', e.detail);
|
|
506
|
+
});
|
|
507
|
+
</script>
|
|
508
|
+
</head>
|
|
509
|
+
<body>
|
|
510
|
+
<div class="select-demo">
|
|
511
|
+
<snice-select
|
|
512
|
+
label="Single selection"
|
|
513
|
+
name="single"
|
|
514
|
+
clearable>
|
|
515
|
+
<snice-option value="1">Option 1</snice-option>
|
|
516
|
+
<snice-option value="2">Option 2</snice-option>
|
|
517
|
+
<snice-option value="3">Option 3</snice-option>
|
|
518
|
+
</snice-select>
|
|
519
|
+
|
|
520
|
+
<snice-select
|
|
521
|
+
label="Multiple selection"
|
|
522
|
+
name="multiple"
|
|
523
|
+
multiple
|
|
524
|
+
clearable>
|
|
525
|
+
<snice-option value="a">Choice A</snice-option>
|
|
526
|
+
<snice-option value="b">Choice B</snice-option>
|
|
527
|
+
<snice-option value="c">Choice C</snice-option>
|
|
528
|
+
<snice-option value="d">Choice D</snice-option>
|
|
529
|
+
</snice-select>
|
|
530
|
+
|
|
531
|
+
<snice-select
|
|
532
|
+
label="Searchable"
|
|
533
|
+
name="searchable"
|
|
534
|
+
searchable>
|
|
535
|
+
<snice-option value="apple">Apple</snice-option>
|
|
536
|
+
<snice-option value="banana">Banana</snice-option>
|
|
537
|
+
<snice-option value="cherry">Cherry</snice-option>
|
|
538
|
+
<snice-option value="date">Date</snice-option>
|
|
539
|
+
<snice-option value="elderberry">Elderberry</snice-option>
|
|
540
|
+
<snice-option value="fig">Fig</snice-option>
|
|
541
|
+
<snice-option value="grape">Grape</snice-option>
|
|
542
|
+
</snice-select>
|
|
543
|
+
|
|
544
|
+
<snice-select
|
|
545
|
+
label="With disabled option"
|
|
546
|
+
name="disabled">
|
|
547
|
+
<snice-option value="1">Enabled</snice-option>
|
|
548
|
+
<snice-option value="2" disabled>Disabled</snice-option>
|
|
549
|
+
<snice-option value="3">Enabled</snice-option>
|
|
550
|
+
</snice-select>
|
|
551
|
+
|
|
552
|
+
<snice-select
|
|
553
|
+
label="Disabled select"
|
|
554
|
+
name="disabledSelect"
|
|
555
|
+
disabled>
|
|
556
|
+
<snice-option value="1">Option 1</snice-option>
|
|
557
|
+
<snice-option value="2">Option 2</snice-option>
|
|
558
|
+
</snice-select>
|
|
559
|
+
</div>
|
|
560
|
+
</body>
|
|
561
|
+
</html>
|
|
562
|
+
```
|
|
563
|
+
|
|
564
|
+
## Accessibility
|
|
565
|
+
|
|
566
|
+
The select components include proper ARIA attributes and keyboard support:
|
|
567
|
+
|
|
568
|
+
- `role="listbox"` on the dropdown
|
|
569
|
+
- `role="option"` on each option
|
|
570
|
+
- `aria-haspopup="listbox"` on the trigger
|
|
571
|
+
- `aria-expanded` reflects the dropdown state
|
|
572
|
+
- `aria-selected` on selected options
|
|
573
|
+
- `aria-disabled` on disabled options
|
|
574
|
+
- `aria-invalid` when invalid state is set
|
|
575
|
+
- Full keyboard navigation support
|
|
576
|
+
|
|
577
|
+
### Keyboard Support
|
|
578
|
+
|
|
579
|
+
- **Space/Enter**: Open dropdown (when trigger is focused)
|
|
580
|
+
- **Arrow Down/Up**: Navigate options
|
|
581
|
+
- **Enter/Space**: Select focused option
|
|
582
|
+
- **Escape**: Close dropdown
|
|
583
|
+
- **Type to search**: When searchable, type to filter options
|
|
584
|
+
|
|
585
|
+
## Form Behavior
|
|
586
|
+
|
|
587
|
+
The select component works seamlessly with HTML forms:
|
|
588
|
+
|
|
589
|
+
- Acts like a native `<select>` element
|
|
590
|
+
- Supports `name` and `value` attributes
|
|
591
|
+
- Supports `required` attribute for validation
|
|
592
|
+
- Compatible with FormData API
|
|
593
|
+
- Hidden native `<select>` for form submission
|
|
594
|
+
- Multiple selection values are comma-separated
|
|
595
|
+
|
|
596
|
+
## Browser Support
|
|
597
|
+
|
|
598
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
599
|
+
- Requires Custom Elements v1 and Shadow DOM support
|