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,558 @@
|
|
|
1
|
+
# Accordion Components
|
|
2
|
+
|
|
3
|
+
The accordion components provide collapsible sections of content. An `<snice-accordion>` container manages multiple `<snice-accordion-item>` elements, supporting single or multiple open items with keyboard navigation.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Components](#components)
|
|
8
|
+
- [Properties](#properties)
|
|
9
|
+
- [Methods](#methods)
|
|
10
|
+
- [Events](#events)
|
|
11
|
+
- [Examples](#examples)
|
|
12
|
+
|
|
13
|
+
## Basic Usage
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<snice-accordion>
|
|
17
|
+
<snice-accordion-item item-id="item-1">
|
|
18
|
+
<span slot="header">Section 1</span>
|
|
19
|
+
<div>Content for section 1</div>
|
|
20
|
+
</snice-accordion-item>
|
|
21
|
+
|
|
22
|
+
<snice-accordion-item item-id="item-2">
|
|
23
|
+
<span slot="header">Section 2</span>
|
|
24
|
+
<div>Content for section 2</div>
|
|
25
|
+
</snice-accordion-item>
|
|
26
|
+
|
|
27
|
+
<snice-accordion-item item-id="item-3">
|
|
28
|
+
<span slot="header">Section 3</span>
|
|
29
|
+
<div>Content for section 3</div>
|
|
30
|
+
</snice-accordion-item>
|
|
31
|
+
</snice-accordion>
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
```typescript
|
|
35
|
+
import 'snice/components/accordion/snice-accordion';
|
|
36
|
+
import 'snice/components/accordion/snice-accordion-item';
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Components
|
|
40
|
+
|
|
41
|
+
### `<snice-accordion>`
|
|
42
|
+
Container element that manages accordion items.
|
|
43
|
+
|
|
44
|
+
### `<snice-accordion-item>`
|
|
45
|
+
Individual collapsible section within an accordion.
|
|
46
|
+
|
|
47
|
+
## Properties
|
|
48
|
+
|
|
49
|
+
### Accordion Container
|
|
50
|
+
|
|
51
|
+
| Property | Type | Default | Description |
|
|
52
|
+
|----------|------|---------|-------------|
|
|
53
|
+
| `multiple` | `boolean` | `false` | Allow multiple items open simultaneously |
|
|
54
|
+
|
|
55
|
+
### Accordion Item
|
|
56
|
+
|
|
57
|
+
| Property | Type | Default | Description |
|
|
58
|
+
|----------|------|---------|-------------|
|
|
59
|
+
| `itemId` | `string` | auto-generated | Unique identifier for the item |
|
|
60
|
+
| `open` | `boolean` | `false` | Whether the item is expanded |
|
|
61
|
+
| `disabled` | `boolean` | `false` | Disable interaction with the item |
|
|
62
|
+
|
|
63
|
+
## Methods
|
|
64
|
+
|
|
65
|
+
### Accordion Container Methods
|
|
66
|
+
|
|
67
|
+
#### `openItem(id: string): void`
|
|
68
|
+
Open a specific item by ID.
|
|
69
|
+
|
|
70
|
+
```typescript
|
|
71
|
+
accordion.openItem('item-1');
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
#### `closeItem(id: string): void`
|
|
75
|
+
Close a specific item by ID.
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
accordion.closeItem('item-1');
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
#### `toggleItem(id: string): void`
|
|
82
|
+
Toggle a specific item by ID.
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
accordion.toggleItem('item-1');
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
#### `openAll(): void`
|
|
89
|
+
Open all items (only works in `multiple` mode).
|
|
90
|
+
|
|
91
|
+
```typescript
|
|
92
|
+
accordion.openAll();
|
|
93
|
+
```
|
|
94
|
+
|
|
95
|
+
#### `closeAll(): void`
|
|
96
|
+
Close all items.
|
|
97
|
+
|
|
98
|
+
```typescript
|
|
99
|
+
accordion.closeAll();
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Accordion Item Methods
|
|
103
|
+
|
|
104
|
+
#### `toggle(): void`
|
|
105
|
+
Toggle the item's open/closed state.
|
|
106
|
+
|
|
107
|
+
```typescript
|
|
108
|
+
item.toggle();
|
|
109
|
+
```
|
|
110
|
+
|
|
111
|
+
#### `expand(animate = true): void`
|
|
112
|
+
Open the item with optional animation.
|
|
113
|
+
|
|
114
|
+
```typescript
|
|
115
|
+
item.expand();
|
|
116
|
+
item.expand(false); // Without animation
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
#### `collapse(animate = true): void`
|
|
120
|
+
Close the item with optional animation.
|
|
121
|
+
|
|
122
|
+
```typescript
|
|
123
|
+
item.collapse();
|
|
124
|
+
item.collapse(false); // Without animation
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
## Events
|
|
128
|
+
|
|
129
|
+
### Container Events
|
|
130
|
+
|
|
131
|
+
#### `@snice/accordion-open`
|
|
132
|
+
Fired when an item is opened.
|
|
133
|
+
|
|
134
|
+
**Event Detail:**
|
|
135
|
+
```typescript
|
|
136
|
+
{
|
|
137
|
+
itemId: string;
|
|
138
|
+
item: SniceAccordionItemElement;
|
|
139
|
+
}
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
**Usage:**
|
|
143
|
+
```typescript
|
|
144
|
+
accordion.addEventListener('@snice/accordion-open', (e) => {
|
|
145
|
+
console.log('Item opened:', e.detail.itemId);
|
|
146
|
+
});
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
#### `@snice/accordion-close`
|
|
150
|
+
Fired when an item is closed.
|
|
151
|
+
|
|
152
|
+
**Event Detail:**
|
|
153
|
+
```typescript
|
|
154
|
+
{
|
|
155
|
+
itemId: string;
|
|
156
|
+
item: SniceAccordionItemElement;
|
|
157
|
+
}
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
### Item Events
|
|
161
|
+
|
|
162
|
+
#### `accordion-item-toggle`
|
|
163
|
+
Fired when an item is toggled.
|
|
164
|
+
|
|
165
|
+
**Event Detail:**
|
|
166
|
+
```typescript
|
|
167
|
+
{
|
|
168
|
+
itemId: string;
|
|
169
|
+
open: boolean;
|
|
170
|
+
}
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
## Slots
|
|
174
|
+
|
|
175
|
+
### Accordion Item Slots
|
|
176
|
+
|
|
177
|
+
#### `header` (named slot)
|
|
178
|
+
Content for the clickable header/trigger.
|
|
179
|
+
|
|
180
|
+
```html
|
|
181
|
+
<snice-accordion-item>
|
|
182
|
+
<span slot="header">Click to expand</span>
|
|
183
|
+
<div>Panel content</div>
|
|
184
|
+
</snice-accordion-item>
|
|
185
|
+
```
|
|
186
|
+
|
|
187
|
+
#### Default slot
|
|
188
|
+
Content that appears when the item is expanded.
|
|
189
|
+
|
|
190
|
+
```html
|
|
191
|
+
<snice-accordion-item>
|
|
192
|
+
<span slot="header">Header</span>
|
|
193
|
+
<div>This content is collapsible</div>
|
|
194
|
+
</snice-accordion-item>
|
|
195
|
+
```
|
|
196
|
+
|
|
197
|
+
## Examples
|
|
198
|
+
|
|
199
|
+
### Basic Accordion
|
|
200
|
+
|
|
201
|
+
```html
|
|
202
|
+
<snice-accordion>
|
|
203
|
+
<snice-accordion-item item-id="general">
|
|
204
|
+
<span slot="header">General Information</span>
|
|
205
|
+
<p>This section contains general information about the product.</p>
|
|
206
|
+
</snice-accordion-item>
|
|
207
|
+
|
|
208
|
+
<snice-accordion-item item-id="specs">
|
|
209
|
+
<span slot="header">Technical Specifications</span>
|
|
210
|
+
<ul>
|
|
211
|
+
<li>Weight: 2.5 kg</li>
|
|
212
|
+
<li>Dimensions: 30x20x10 cm</li>
|
|
213
|
+
<li>Material: Aluminum</li>
|
|
214
|
+
</ul>
|
|
215
|
+
</snice-accordion-item>
|
|
216
|
+
|
|
217
|
+
<snice-accordion-item item-id="warranty">
|
|
218
|
+
<span slot="header">Warranty Information</span>
|
|
219
|
+
<p>This product comes with a 2-year manufacturer warranty.</p>
|
|
220
|
+
</snice-accordion-item>
|
|
221
|
+
</snice-accordion>
|
|
222
|
+
```
|
|
223
|
+
|
|
224
|
+
### Multiple Open Items
|
|
225
|
+
|
|
226
|
+
```html
|
|
227
|
+
<snice-accordion multiple>
|
|
228
|
+
<snice-accordion-item item-id="item-1">
|
|
229
|
+
<span slot="header">Section 1</span>
|
|
230
|
+
<p>Content 1</p>
|
|
231
|
+
</snice-accordion-item>
|
|
232
|
+
|
|
233
|
+
<snice-accordion-item item-id="item-2" open>
|
|
234
|
+
<span slot="header">Section 2</span>
|
|
235
|
+
<p>Content 2 (initially open)</p>
|
|
236
|
+
</snice-accordion-item>
|
|
237
|
+
|
|
238
|
+
<snice-accordion-item item-id="item-3" open>
|
|
239
|
+
<span slot="header">Section 3</span>
|
|
240
|
+
<p>Content 3 (initially open)</p>
|
|
241
|
+
</snice-accordion-item>
|
|
242
|
+
</snice-accordion>
|
|
243
|
+
```
|
|
244
|
+
|
|
245
|
+
### With Disabled Items
|
|
246
|
+
|
|
247
|
+
```html
|
|
248
|
+
<snice-accordion>
|
|
249
|
+
<snice-accordion-item item-id="active">
|
|
250
|
+
<span slot="header">Active Item</span>
|
|
251
|
+
<p>This item can be clicked.</p>
|
|
252
|
+
</snice-accordion-item>
|
|
253
|
+
|
|
254
|
+
<snice-accordion-item item-id="disabled" disabled>
|
|
255
|
+
<span slot="header">Disabled Item</span>
|
|
256
|
+
<p>This item cannot be opened.</p>
|
|
257
|
+
</snice-accordion-item>
|
|
258
|
+
</snice-accordion>
|
|
259
|
+
```
|
|
260
|
+
|
|
261
|
+
### FAQ Accordion
|
|
262
|
+
|
|
263
|
+
```html
|
|
264
|
+
<style>
|
|
265
|
+
snice-accordion-item::part(header) {
|
|
266
|
+
font-weight: 600;
|
|
267
|
+
padding: 1rem;
|
|
268
|
+
}
|
|
269
|
+
|
|
270
|
+
snice-accordion-item::part(content) {
|
|
271
|
+
padding: 1rem;
|
|
272
|
+
background: #f9fafb;
|
|
273
|
+
}
|
|
274
|
+
</style>
|
|
275
|
+
|
|
276
|
+
<snice-accordion id="faq">
|
|
277
|
+
<snice-accordion-item item-id="shipping">
|
|
278
|
+
<span slot="header">What are the shipping options?</span>
|
|
279
|
+
<p>We offer standard (5-7 days) and express (2-3 days) shipping options.</p>
|
|
280
|
+
</snice-accordion-item>
|
|
281
|
+
|
|
282
|
+
<snice-accordion-item item-id="returns">
|
|
283
|
+
<span slot="header">What is your return policy?</span>
|
|
284
|
+
<p>Items can be returned within 30 days of purchase for a full refund.</p>
|
|
285
|
+
</snice-accordion-item>
|
|
286
|
+
|
|
287
|
+
<snice-accordion-item item-id="warranty">
|
|
288
|
+
<span slot="header">Do products come with a warranty?</span>
|
|
289
|
+
<p>All products include a 1-year manufacturer warranty.</p>
|
|
290
|
+
</snice-accordion-item>
|
|
291
|
+
</snice-accordion>
|
|
292
|
+
```
|
|
293
|
+
|
|
294
|
+
### Programmatic Control
|
|
295
|
+
|
|
296
|
+
```html
|
|
297
|
+
<snice-accordion id="controlled">
|
|
298
|
+
<snice-accordion-item item-id="item-1">
|
|
299
|
+
<span slot="header">Item 1</span>
|
|
300
|
+
<p>Content 1</p>
|
|
301
|
+
</snice-accordion-item>
|
|
302
|
+
|
|
303
|
+
<snice-accordion-item item-id="item-2">
|
|
304
|
+
<span slot="header">Item 2</span>
|
|
305
|
+
<p>Content 2</p>
|
|
306
|
+
</snice-accordion-item>
|
|
307
|
+
|
|
308
|
+
<snice-accordion-item item-id="item-3">
|
|
309
|
+
<span slot="header">Item 3</span>
|
|
310
|
+
<p>Content 3</p>
|
|
311
|
+
</snice-accordion-item>
|
|
312
|
+
</snice-accordion>
|
|
313
|
+
|
|
314
|
+
<div style="display: flex; gap: 8px; margin-top: 1rem;">
|
|
315
|
+
<button onclick="document.querySelector('#controlled').openAll()">
|
|
316
|
+
Open All
|
|
317
|
+
</button>
|
|
318
|
+
<button onclick="document.querySelector('#controlled').closeAll()">
|
|
319
|
+
Close All
|
|
320
|
+
</button>
|
|
321
|
+
<button onclick="document.querySelector('#controlled').toggleItem('item-2')">
|
|
322
|
+
Toggle Item 2
|
|
323
|
+
</button>
|
|
324
|
+
</div>
|
|
325
|
+
```
|
|
326
|
+
|
|
327
|
+
### With Event Handling
|
|
328
|
+
|
|
329
|
+
```typescript
|
|
330
|
+
import type { SniceAccordionElement } from 'snice/components/accordion/snice-accordion.types';
|
|
331
|
+
|
|
332
|
+
const accordion = document.querySelector<SniceAccordionElement>('snice-accordion');
|
|
333
|
+
|
|
334
|
+
accordion.addEventListener('@snice/accordion-open', (e) => {
|
|
335
|
+
console.log('Opened item:', e.detail.itemId);
|
|
336
|
+
// Track analytics, load content, etc.
|
|
337
|
+
});
|
|
338
|
+
|
|
339
|
+
accordion.addEventListener('@snice/accordion-close', (e) => {
|
|
340
|
+
console.log('Closed item:', e.detail.itemId);
|
|
341
|
+
});
|
|
342
|
+
|
|
343
|
+
// Programmatic control
|
|
344
|
+
accordion.openItem('item-1');
|
|
345
|
+
accordion.closeItem('item-2');
|
|
346
|
+
accordion.toggleItem('item-3');
|
|
347
|
+
```
|
|
348
|
+
|
|
349
|
+
### Dynamic Content Loading
|
|
350
|
+
|
|
351
|
+
```html
|
|
352
|
+
<snice-accordion id="lazyAccordion">
|
|
353
|
+
<snice-accordion-item item-id="section-1">
|
|
354
|
+
<span slot="header">Section 1</span>
|
|
355
|
+
<div id="content-1">Loading...</div>
|
|
356
|
+
</snice-accordion-item>
|
|
357
|
+
|
|
358
|
+
<snice-accordion-item item-id="section-2">
|
|
359
|
+
<span slot="header">Section 2</span>
|
|
360
|
+
<div id="content-2">Loading...</div>
|
|
361
|
+
</snice-accordion-item>
|
|
362
|
+
</snice-accordion>
|
|
363
|
+
|
|
364
|
+
<script type="module">
|
|
365
|
+
import 'snice/components/accordion/snice-accordion';
|
|
366
|
+
import 'snice/components/accordion/snice-accordion-item';
|
|
367
|
+
|
|
368
|
+
const accordion = document.querySelector('#lazyAccordion');
|
|
369
|
+
|
|
370
|
+
accordion.addEventListener('@snice/accordion-open', async (e) => {
|
|
371
|
+
const contentId = `content-${e.detail.itemId.split('-')[1]}`;
|
|
372
|
+
const contentEl = document.querySelector(`#${contentId}`);
|
|
373
|
+
|
|
374
|
+
if (contentEl.textContent === 'Loading...') {
|
|
375
|
+
const response = await fetch(`/api/content/${e.detail.itemId}`);
|
|
376
|
+
const data = await response.json();
|
|
377
|
+
contentEl.innerHTML = data.html;
|
|
378
|
+
}
|
|
379
|
+
});
|
|
380
|
+
</script>
|
|
381
|
+
```
|
|
382
|
+
|
|
383
|
+
### Settings Accordion
|
|
384
|
+
|
|
385
|
+
```html
|
|
386
|
+
<style>
|
|
387
|
+
.setting-group {
|
|
388
|
+
display: flex;
|
|
389
|
+
flex-direction: column;
|
|
390
|
+
gap: 1rem;
|
|
391
|
+
padding: 1rem;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
.setting-item {
|
|
395
|
+
display: flex;
|
|
396
|
+
justify-content: space-between;
|
|
397
|
+
align-items: center;
|
|
398
|
+
}
|
|
399
|
+
</style>
|
|
400
|
+
|
|
401
|
+
<snice-accordion>
|
|
402
|
+
<snice-accordion-item item-id="general-settings">
|
|
403
|
+
<span slot="header">⚙️ General Settings</span>
|
|
404
|
+
<div class="setting-group">
|
|
405
|
+
<div class="setting-item">
|
|
406
|
+
<label>Language</label>
|
|
407
|
+
<select>
|
|
408
|
+
<option>English</option>
|
|
409
|
+
<option>Spanish</option>
|
|
410
|
+
<option>French</option>
|
|
411
|
+
</select>
|
|
412
|
+
</div>
|
|
413
|
+
<div class="setting-item">
|
|
414
|
+
<label>Timezone</label>
|
|
415
|
+
<select>
|
|
416
|
+
<option>UTC</option>
|
|
417
|
+
<option>EST</option>
|
|
418
|
+
<option>PST</option>
|
|
419
|
+
</select>
|
|
420
|
+
</div>
|
|
421
|
+
</div>
|
|
422
|
+
</snice-accordion-item>
|
|
423
|
+
|
|
424
|
+
<snice-accordion-item item-id="notification-settings">
|
|
425
|
+
<span slot="header">🔔 Notifications</span>
|
|
426
|
+
<div class="setting-group">
|
|
427
|
+
<div class="setting-item">
|
|
428
|
+
<label>Email notifications</label>
|
|
429
|
+
<input type="checkbox" checked>
|
|
430
|
+
</div>
|
|
431
|
+
<div class="setting-item">
|
|
432
|
+
<label>Push notifications</label>
|
|
433
|
+
<input type="checkbox">
|
|
434
|
+
</div>
|
|
435
|
+
</div>
|
|
436
|
+
</snice-accordion-item>
|
|
437
|
+
|
|
438
|
+
<snice-accordion-item item-id="privacy-settings">
|
|
439
|
+
<span slot="header">🔒 Privacy</span>
|
|
440
|
+
<div class="setting-group">
|
|
441
|
+
<div class="setting-item">
|
|
442
|
+
<label>Profile visibility</label>
|
|
443
|
+
<select>
|
|
444
|
+
<option>Public</option>
|
|
445
|
+
<option>Friends</option>
|
|
446
|
+
<option>Private</option>
|
|
447
|
+
</select>
|
|
448
|
+
</div>
|
|
449
|
+
</div>
|
|
450
|
+
</snice-accordion-item>
|
|
451
|
+
</snice-accordion>
|
|
452
|
+
```
|
|
453
|
+
|
|
454
|
+
### Nested Content
|
|
455
|
+
|
|
456
|
+
```html
|
|
457
|
+
<snice-accordion>
|
|
458
|
+
<snice-accordion-item item-id="products">
|
|
459
|
+
<span slot="header">Products</span>
|
|
460
|
+
<div style="padding: 1rem;">
|
|
461
|
+
<ul>
|
|
462
|
+
<li>Product A - $29.99</li>
|
|
463
|
+
<li>Product B - $39.99</li>
|
|
464
|
+
<li>Product C - $49.99</li>
|
|
465
|
+
</ul>
|
|
466
|
+
</div>
|
|
467
|
+
</snice-accordion-item>
|
|
468
|
+
|
|
469
|
+
<snice-accordion-item item-id="services">
|
|
470
|
+
<span slot="header">Services</span>
|
|
471
|
+
<div style="padding: 1rem;">
|
|
472
|
+
<table>
|
|
473
|
+
<thead>
|
|
474
|
+
<tr>
|
|
475
|
+
<th>Service</th>
|
|
476
|
+
<th>Price</th>
|
|
477
|
+
</tr>
|
|
478
|
+
</thead>
|
|
479
|
+
<tbody>
|
|
480
|
+
<tr>
|
|
481
|
+
<td>Consultation</td>
|
|
482
|
+
<td>$99/hr</td>
|
|
483
|
+
</tr>
|
|
484
|
+
<tr>
|
|
485
|
+
<td>Implementation</td>
|
|
486
|
+
<td>$149/hr</td>
|
|
487
|
+
</tr>
|
|
488
|
+
</tbody>
|
|
489
|
+
</table>
|
|
490
|
+
</div>
|
|
491
|
+
</snice-accordion-item>
|
|
492
|
+
</snice-accordion>
|
|
493
|
+
```
|
|
494
|
+
|
|
495
|
+
## Keyboard Navigation
|
|
496
|
+
|
|
497
|
+
The accordion supports comprehensive keyboard navigation:
|
|
498
|
+
|
|
499
|
+
- **Arrow Down**: Move focus to the next item
|
|
500
|
+
- **Arrow Up**: Move focus to the previous item
|
|
501
|
+
- **Home**: Move focus to the first item
|
|
502
|
+
- **End**: Move focus to the last item
|
|
503
|
+
- **Enter** or **Space**: Toggle the focused item
|
|
504
|
+
|
|
505
|
+
## Accessibility
|
|
506
|
+
|
|
507
|
+
- **ARIA roles**: `button` role on headers, proper aria-expanded states
|
|
508
|
+
- **Keyboard support**: Full keyboard navigation
|
|
509
|
+
- **Screen reader friendly**: Announces state changes
|
|
510
|
+
- **Focus management**: Visible focus indicators
|
|
511
|
+
- **Semantic HTML**: Uses button elements for interactivity
|
|
512
|
+
|
|
513
|
+
## Browser Support
|
|
514
|
+
|
|
515
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
516
|
+
- Requires Custom Elements v1 and Shadow DOM support
|
|
517
|
+
|
|
518
|
+
## Best Practices
|
|
519
|
+
|
|
520
|
+
1. **Use descriptive headers**: Make it clear what each section contains
|
|
521
|
+
2. **Keep content concise**: Accordion is best for moderate amounts of content
|
|
522
|
+
3. **Set appropriate IDs**: Provide meaningful `item-id` values for tracking
|
|
523
|
+
4. **Consider initial state**: Open important sections by default
|
|
524
|
+
5. **Use multiple mode sparingly**: Single-open mode is often clearer
|
|
525
|
+
6. **Avoid nesting accordions**: Can be confusing for users
|
|
526
|
+
7. **Test keyboard navigation**: Ensure all interactions work without a mouse
|
|
527
|
+
|
|
528
|
+
## Common Patterns
|
|
529
|
+
|
|
530
|
+
### FAQ Pattern
|
|
531
|
+
```html
|
|
532
|
+
<snice-accordion>
|
|
533
|
+
<snice-accordion-item item-id="q1">
|
|
534
|
+
<span slot="header">Question 1?</span>
|
|
535
|
+
<p>Answer to question 1.</p>
|
|
536
|
+
</snice-accordion-item>
|
|
537
|
+
</snice-accordion>
|
|
538
|
+
```
|
|
539
|
+
|
|
540
|
+
### Settings Pattern
|
|
541
|
+
```html
|
|
542
|
+
<snice-accordion multiple>
|
|
543
|
+
<snice-accordion-item item-id="general">
|
|
544
|
+
<span slot="header">General</span>
|
|
545
|
+
<!-- Settings form -->
|
|
546
|
+
</snice-accordion-item>
|
|
547
|
+
</snice-accordion>
|
|
548
|
+
```
|
|
549
|
+
|
|
550
|
+
### Table of Contents Pattern
|
|
551
|
+
```html
|
|
552
|
+
<snice-accordion>
|
|
553
|
+
<snice-accordion-item item-id="intro" open>
|
|
554
|
+
<span slot="header">Introduction</span>
|
|
555
|
+
<p>Content overview...</p>
|
|
556
|
+
</snice-accordion-item>
|
|
557
|
+
</snice-accordion>
|
|
558
|
+
```
|