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,239 @@
|
|
|
1
|
+
# Navigation Component
|
|
2
|
+
|
|
3
|
+
The `<snice-nav>` component renders navigation menus from placard configurations. It integrates with Snice's routing system and supports multiple display variants.
|
|
4
|
+
|
|
5
|
+
## Basic Usage
|
|
6
|
+
|
|
7
|
+
```html
|
|
8
|
+
<snice-nav id="mainNav" variant="flat" orientation="horizontal"></snice-nav>
|
|
9
|
+
|
|
10
|
+
<script type="module">
|
|
11
|
+
import 'snice/components/nav/snice-nav';
|
|
12
|
+
|
|
13
|
+
const nav = document.querySelector('#mainNav');
|
|
14
|
+
|
|
15
|
+
const placards = [
|
|
16
|
+
{ name: 'home', title: 'Home', icon: '🏠', order: 0 },
|
|
17
|
+
{ name: 'products', title: 'Products', icon: '📦', order: 1 },
|
|
18
|
+
{ name: 'about', title: 'About', icon: 'ℹ️', order: 2 },
|
|
19
|
+
];
|
|
20
|
+
|
|
21
|
+
nav.update(placards, undefined, 'home');
|
|
22
|
+
</script>
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Properties
|
|
26
|
+
|
|
27
|
+
| Property | Type | Default | Description |
|
|
28
|
+
|----------|------|---------|-------------|
|
|
29
|
+
| `variant` | `'flat' \| 'hierarchical' \| 'grouped'` | `'flat'` | Display style for navigation |
|
|
30
|
+
| `orientation` | `'horizontal' \| 'vertical'` | `'horizontal'` | Layout direction |
|
|
31
|
+
| `isTopLevel` | `boolean` | `false` | Whether to receive context updates |
|
|
32
|
+
|
|
33
|
+
## Methods
|
|
34
|
+
|
|
35
|
+
### `update(placards, appContext?, currentRoute?, routeParams?): void`
|
|
36
|
+
Update the navigation with new placard data and routing information.
|
|
37
|
+
|
|
38
|
+
```typescript
|
|
39
|
+
nav.update(
|
|
40
|
+
placards, // Array of placard objects
|
|
41
|
+
appContext, // Optional app context
|
|
42
|
+
'products', // Current route
|
|
43
|
+
{ id: '123' } // Route parameters
|
|
44
|
+
);
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Placard Structure
|
|
48
|
+
|
|
49
|
+
```typescript
|
|
50
|
+
interface Placard {
|
|
51
|
+
name: string; // Unique identifier and route
|
|
52
|
+
title: string; // Display text
|
|
53
|
+
icon?: string; // Icon character/emoji
|
|
54
|
+
order?: number; // Sort order
|
|
55
|
+
parent?: string; // Parent placard name (for hierarchical)
|
|
56
|
+
group?: string; // Group name (for grouped variant)
|
|
57
|
+
show?: boolean; // Whether to show the item
|
|
58
|
+
description?: string; // Accessible label and tooltip
|
|
59
|
+
tooltip?: string; // Hover tooltip
|
|
60
|
+
hotkeys?: string[]; // Keyboard shortcuts
|
|
61
|
+
helpUrl?: string; // Help documentation URL
|
|
62
|
+
searchTerms?: string[]; // Search keywords
|
|
63
|
+
attributes?: Record<string, any>; // Custom data attributes
|
|
64
|
+
visibleOn?: Function | Function[]; // Visibility guards
|
|
65
|
+
}
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## Variants
|
|
69
|
+
|
|
70
|
+
### Flat (Default)
|
|
71
|
+
Simple horizontal or vertical list of navigation items.
|
|
72
|
+
|
|
73
|
+
```html
|
|
74
|
+
<snice-nav variant="flat"></snice-nav>
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### Hierarchical
|
|
78
|
+
Nested navigation with parent-child relationships.
|
|
79
|
+
|
|
80
|
+
```html
|
|
81
|
+
<snice-nav variant="hierarchical"></snice-nav>
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
```javascript
|
|
85
|
+
const placards = [
|
|
86
|
+
{ name: 'products', title: 'Products', order: 0 },
|
|
87
|
+
{ name: 'electronics', title: 'Electronics', parent: 'products', order: 0 },
|
|
88
|
+
{ name: 'clothing', title: 'Clothing', parent: 'products', order: 1 },
|
|
89
|
+
];
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
### Grouped
|
|
93
|
+
Navigation items organized into labeled groups.
|
|
94
|
+
|
|
95
|
+
```html
|
|
96
|
+
<snice-nav variant="grouped"></snice-nav>
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
```javascript
|
|
100
|
+
const placards = [
|
|
101
|
+
{ name: 'home', title: 'Home', group: 'Main', order: 0 },
|
|
102
|
+
{ name: 'about', title: 'About', group: 'Main', order: 1 },
|
|
103
|
+
{ name: 'settings', title: 'Settings', group: 'Account', order: 2 },
|
|
104
|
+
];
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## Examples
|
|
108
|
+
|
|
109
|
+
### Basic Navigation
|
|
110
|
+
|
|
111
|
+
```html
|
|
112
|
+
<snice-nav id="nav"></snice-nav>
|
|
113
|
+
|
|
114
|
+
<script type="module">
|
|
115
|
+
import 'snice/components/nav/snice-nav';
|
|
116
|
+
|
|
117
|
+
const nav = document.querySelector('#nav');
|
|
118
|
+
|
|
119
|
+
const placards = [
|
|
120
|
+
{ name: 'home', title: 'Home', order: 0 },
|
|
121
|
+
{ name: 'products', title: 'Products', order: 1 },
|
|
122
|
+
{ name: 'services', title: 'Services', order: 2 },
|
|
123
|
+
{ name: 'contact', title: 'Contact', order: 3 },
|
|
124
|
+
];
|
|
125
|
+
|
|
126
|
+
nav.update(placards, undefined, 'home');
|
|
127
|
+
</script>
|
|
128
|
+
```
|
|
129
|
+
|
|
130
|
+
### With Icons
|
|
131
|
+
|
|
132
|
+
```javascript
|
|
133
|
+
const placards = [
|
|
134
|
+
{ name: 'dashboard', title: 'Dashboard', icon: '📊', order: 0 },
|
|
135
|
+
{ name: 'analytics', title: 'Analytics', icon: '📈', order: 1 },
|
|
136
|
+
{ name: 'reports', title: 'Reports', icon: '📋', order: 2 },
|
|
137
|
+
{ name: 'settings', title: 'Settings', icon: '⚙️', order: 3 },
|
|
138
|
+
];
|
|
139
|
+
|
|
140
|
+
nav.update(placards);
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### Hierarchical Menu
|
|
144
|
+
|
|
145
|
+
```javascript
|
|
146
|
+
const placards = [
|
|
147
|
+
{ name: 'products', title: 'Products', order: 0 },
|
|
148
|
+
{ name: 'electronics', title: 'Electronics', parent: 'products', order: 0 },
|
|
149
|
+
{ name: 'computers', title: 'Computers', parent: 'electronics', order: 0 },
|
|
150
|
+
{ name: 'phones', title: 'Phones', parent: 'electronics', order: 1 },
|
|
151
|
+
{ name: 'clothing', title: 'Clothing', parent: 'products', order: 1 },
|
|
152
|
+
];
|
|
153
|
+
|
|
154
|
+
const nav = document.querySelector('snice-nav');
|
|
155
|
+
nav.variant = 'hierarchical';
|
|
156
|
+
nav.update(placards);
|
|
157
|
+
```
|
|
158
|
+
|
|
159
|
+
### Grouped Navigation
|
|
160
|
+
|
|
161
|
+
```javascript
|
|
162
|
+
const placards = [
|
|
163
|
+
{ name: 'home', title: 'Home', group: 'Main', order: 0 },
|
|
164
|
+
{ name: 'dashboard', title: 'Dashboard', group: 'Main', order: 1 },
|
|
165
|
+
{ name: 'profile', title: 'Profile', group: 'Account', order: 0 },
|
|
166
|
+
{ name: 'settings', title: 'Settings', group: 'Account', order: 1 },
|
|
167
|
+
{ name: 'help', title: 'Help', group: 'Support', order: 0 },
|
|
168
|
+
];
|
|
169
|
+
|
|
170
|
+
const nav = document.querySelector('snice-nav');
|
|
171
|
+
nav.variant = 'grouped';
|
|
172
|
+
nav.update(placards);
|
|
173
|
+
```
|
|
174
|
+
|
|
175
|
+
### With Keyboard Shortcuts
|
|
176
|
+
|
|
177
|
+
```javascript
|
|
178
|
+
const placards = [
|
|
179
|
+
{ name: 'home', title: 'Home', hotkeys: ['h', 'Ctrl+H'], order: 0 },
|
|
180
|
+
{ name: 'search', title: 'Search', hotkeys: ['/', 'Ctrl+K'], order: 1 },
|
|
181
|
+
];
|
|
182
|
+
|
|
183
|
+
nav.update(placards);
|
|
184
|
+
|
|
185
|
+
// Access hotkeys via data attribute
|
|
186
|
+
const links = nav.shadowRoot.querySelectorAll('[data-hotkeys]');
|
|
187
|
+
```
|
|
188
|
+
|
|
189
|
+
### Conditional Visibility
|
|
190
|
+
|
|
191
|
+
```javascript
|
|
192
|
+
const placards = [
|
|
193
|
+
{ name: 'home', title: 'Home', order: 0 },
|
|
194
|
+
{
|
|
195
|
+
name: 'admin',
|
|
196
|
+
title: 'Admin',
|
|
197
|
+
order: 1,
|
|
198
|
+
visibleOn: (appContext) => appContext.user?.isAdmin
|
|
199
|
+
},
|
|
200
|
+
];
|
|
201
|
+
|
|
202
|
+
nav.update(placards, { user: { isAdmin: true } });
|
|
203
|
+
```
|
|
204
|
+
|
|
205
|
+
### Active Route Tracking
|
|
206
|
+
|
|
207
|
+
```javascript
|
|
208
|
+
// Update current route
|
|
209
|
+
nav.update(placards, undefined, 'products');
|
|
210
|
+
|
|
211
|
+
// The corresponding nav item will have 'nav__link--active' class
|
|
212
|
+
// and aria-current="page" attribute
|
|
213
|
+
```
|
|
214
|
+
|
|
215
|
+
## Accessibility
|
|
216
|
+
|
|
217
|
+
- `role="navigation"` on nav container
|
|
218
|
+
- `aria-current="page"` on active links
|
|
219
|
+
- `aria-label` from placard descriptions
|
|
220
|
+
- Keyboard navigation support
|
|
221
|
+
- Screen reader friendly
|
|
222
|
+
|
|
223
|
+
## Integration with Snice Context
|
|
224
|
+
|
|
225
|
+
When `isTopLevel` is true, the nav component automatically receives updates from the Snice context system:
|
|
226
|
+
|
|
227
|
+
```html
|
|
228
|
+
<snice-nav is-top-level></snice-nav>
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
The context provides:
|
|
232
|
+
- Placards from routing configuration
|
|
233
|
+
- Current route and parameters
|
|
234
|
+
- Application context for visibility guards
|
|
235
|
+
|
|
236
|
+
## Browser Support
|
|
237
|
+
|
|
238
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
239
|
+
- Requires Custom Elements v1 and Shadow DOM support
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
# Pagination Component
|
|
2
|
+
|
|
3
|
+
The `<snice-pagination>` component provides a flexible pagination interface for navigating through large datasets or multi-page content.
|
|
4
|
+
|
|
5
|
+
## Table of Contents
|
|
6
|
+
- [Basic Usage](#basic-usage)
|
|
7
|
+
- [Properties](#properties)
|
|
8
|
+
- [Methods](#methods)
|
|
9
|
+
- [Events](#events)
|
|
10
|
+
- [Variants](#variants)
|
|
11
|
+
- [Examples](#examples)
|
|
12
|
+
|
|
13
|
+
## Basic Usage
|
|
14
|
+
|
|
15
|
+
```html
|
|
16
|
+
<snice-pagination current="1" total="10"></snice-pagination>
|
|
17
|
+
```
|
|
18
|
+
|
|
19
|
+
```typescript
|
|
20
|
+
import 'snice/components/pagination/snice-pagination';
|
|
21
|
+
|
|
22
|
+
const pagination = document.querySelector('snice-pagination');
|
|
23
|
+
pagination.addEventListener('@snice/pagination-change', (e) => {
|
|
24
|
+
console.log('Page changed to:', e.detail.page);
|
|
25
|
+
});
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Properties
|
|
29
|
+
|
|
30
|
+
| Property | Type | Default | Description |
|
|
31
|
+
|----------|------|---------|-------------|
|
|
32
|
+
| `current` | `number` | `1` | The currently active page number |
|
|
33
|
+
| `total` | `number` | `1` | Total number of pages |
|
|
34
|
+
| `siblings` | `number` | `1` | Number of page buttons to show on each side of current page |
|
|
35
|
+
| `showFirst` | `boolean` | `true` | Whether to show the "First" button |
|
|
36
|
+
| `showLast` | `boolean` | `true` | Whether to show the "Last" button |
|
|
37
|
+
| `showPrev` | `boolean` | `true` | Whether to show the "Previous" button |
|
|
38
|
+
| `showNext` | `boolean` | `true` | Whether to show the "Next" button |
|
|
39
|
+
| `size` | `'small' \| 'medium' \| 'large'` | `'medium'` | Size variant of the pagination |
|
|
40
|
+
| `variant` | `'default' \| 'rounded' \| 'text'` | `'default'` | Visual style variant |
|
|
41
|
+
|
|
42
|
+
## Methods
|
|
43
|
+
|
|
44
|
+
### `goToPage(page: number): void`
|
|
45
|
+
Navigate to a specific page number.
|
|
46
|
+
|
|
47
|
+
```typescript
|
|
48
|
+
pagination.goToPage(5);
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
### `nextPage(): void`
|
|
52
|
+
Navigate to the next page (if not on last page).
|
|
53
|
+
|
|
54
|
+
```typescript
|
|
55
|
+
pagination.nextPage();
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
### `previousPage(): void`
|
|
59
|
+
Navigate to the previous page (if not on first page).
|
|
60
|
+
|
|
61
|
+
```typescript
|
|
62
|
+
pagination.previousPage();
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
### `firstPage(): void`
|
|
66
|
+
Navigate to the first page.
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
pagination.firstPage();
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
### `lastPage(): void`
|
|
73
|
+
Navigate to the last page.
|
|
74
|
+
|
|
75
|
+
```typescript
|
|
76
|
+
pagination.lastPage();
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Events
|
|
80
|
+
|
|
81
|
+
### `@snice/pagination-change`
|
|
82
|
+
Fired when the page changes.
|
|
83
|
+
|
|
84
|
+
**Event Detail:**
|
|
85
|
+
```typescript
|
|
86
|
+
{
|
|
87
|
+
page: number; // New page number
|
|
88
|
+
previousPage: number; // Previous page number
|
|
89
|
+
}
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
**Usage:**
|
|
93
|
+
```typescript
|
|
94
|
+
pagination.addEventListener('@snice/pagination-change', (e) => {
|
|
95
|
+
const { page, previousPage } = e.detail;
|
|
96
|
+
console.log(`Changed from page ${previousPage} to ${page}`);
|
|
97
|
+
});
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
## Variants
|
|
101
|
+
|
|
102
|
+
### Size Variants
|
|
103
|
+
|
|
104
|
+
```html
|
|
105
|
+
<!-- Small -->
|
|
106
|
+
<snice-pagination total="10" size="small"></snice-pagination>
|
|
107
|
+
|
|
108
|
+
<!-- Medium (default) -->
|
|
109
|
+
<snice-pagination total="10" size="medium"></snice-pagination>
|
|
110
|
+
|
|
111
|
+
<!-- Large -->
|
|
112
|
+
<snice-pagination total="10" size="large"></snice-pagination>
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
### Style Variants
|
|
116
|
+
|
|
117
|
+
```html
|
|
118
|
+
<!-- Default (squared corners) -->
|
|
119
|
+
<snice-pagination total="10" variant="default"></snice-pagination>
|
|
120
|
+
|
|
121
|
+
<!-- Rounded (circular buttons) -->
|
|
122
|
+
<snice-pagination total="10" variant="rounded"></snice-pagination>
|
|
123
|
+
|
|
124
|
+
<!-- Text (minimal styling) -->
|
|
125
|
+
<snice-pagination total="10" variant="text"></snice-pagination>
|
|
126
|
+
```
|
|
127
|
+
|
|
128
|
+
## Examples
|
|
129
|
+
|
|
130
|
+
### Basic Pagination
|
|
131
|
+
|
|
132
|
+
```html
|
|
133
|
+
<snice-pagination
|
|
134
|
+
current="1"
|
|
135
|
+
total="20">
|
|
136
|
+
</snice-pagination>
|
|
137
|
+
```
|
|
138
|
+
|
|
139
|
+
### Controlling Siblings
|
|
140
|
+
|
|
141
|
+
The `siblings` property controls how many page buttons appear on each side of the current page.
|
|
142
|
+
|
|
143
|
+
```html
|
|
144
|
+
<!-- Show 1 page on each side (default) -->
|
|
145
|
+
<!-- Current: 5 → Shows: [1] ... [4] [5] [6] ... [20] -->
|
|
146
|
+
<snice-pagination current="5" total="20" siblings="1"></snice-pagination>
|
|
147
|
+
|
|
148
|
+
<!-- Show 3 pages on each side -->
|
|
149
|
+
<!-- Current: 10 → Shows: [1] ... [7] [8] [9] [10] [11] [12] [13] ... [20] -->
|
|
150
|
+
<snice-pagination current="10" total="20" siblings="3"></snice-pagination>
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
### Without Navigation Buttons
|
|
154
|
+
|
|
155
|
+
```html
|
|
156
|
+
<!-- No first/last buttons -->
|
|
157
|
+
<snice-pagination
|
|
158
|
+
total="10"
|
|
159
|
+
show-first="false"
|
|
160
|
+
show-last="false">
|
|
161
|
+
</snice-pagination>
|
|
162
|
+
|
|
163
|
+
<!-- Only page numbers -->
|
|
164
|
+
<snice-pagination
|
|
165
|
+
total="10"
|
|
166
|
+
show-first="false"
|
|
167
|
+
show-last="false"
|
|
168
|
+
show-prev="false"
|
|
169
|
+
show-next="false">
|
|
170
|
+
</snice-pagination>
|
|
171
|
+
```
|
|
172
|
+
|
|
173
|
+
### Programmatic Navigation
|
|
174
|
+
|
|
175
|
+
```typescript
|
|
176
|
+
import type { SnicePaginationElement } from 'snice/components/pagination/snice-pagination.types';
|
|
177
|
+
|
|
178
|
+
const pagination = document.querySelector<SnicePaginationElement>('snice-pagination');
|
|
179
|
+
|
|
180
|
+
// Navigate to specific page
|
|
181
|
+
pagination.goToPage(7);
|
|
182
|
+
|
|
183
|
+
// Navigate step by step
|
|
184
|
+
pagination.nextPage();
|
|
185
|
+
pagination.previousPage();
|
|
186
|
+
|
|
187
|
+
// Jump to extremes
|
|
188
|
+
pagination.firstPage();
|
|
189
|
+
pagination.lastPage();
|
|
190
|
+
```
|
|
191
|
+
|
|
192
|
+
### With Event Handling
|
|
193
|
+
|
|
194
|
+
```typescript
|
|
195
|
+
const pagination = document.querySelector('snice-pagination');
|
|
196
|
+
|
|
197
|
+
pagination.addEventListener('@snice/pagination-change', (e) => {
|
|
198
|
+
const { page } = e.detail;
|
|
199
|
+
|
|
200
|
+
// Fetch data for the new page
|
|
201
|
+
fetchPageData(page);
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
async function fetchPageData(page: number) {
|
|
205
|
+
const response = await fetch(`/api/data?page=${page}`);
|
|
206
|
+
const data = await response.json();
|
|
207
|
+
renderData(data);
|
|
208
|
+
}
|
|
209
|
+
```
|
|
210
|
+
|
|
211
|
+
### Custom Styling with CSS Variables
|
|
212
|
+
|
|
213
|
+
```html
|
|
214
|
+
<style>
|
|
215
|
+
snice-pagination {
|
|
216
|
+
--pagination-gap: 8px;
|
|
217
|
+
--pagination-button-size: 40px;
|
|
218
|
+
--pagination-button-padding: 12px;
|
|
219
|
+
--pagination-font-size: 16px;
|
|
220
|
+
--pagination-border-radius: 8px;
|
|
221
|
+
}
|
|
222
|
+
</style>
|
|
223
|
+
|
|
224
|
+
<snice-pagination total="10"></snice-pagination>
|
|
225
|
+
```
|
|
226
|
+
|
|
227
|
+
### Complete Example
|
|
228
|
+
|
|
229
|
+
```html
|
|
230
|
+
<!DOCTYPE html>
|
|
231
|
+
<html>
|
|
232
|
+
<head>
|
|
233
|
+
<script type="module">
|
|
234
|
+
import 'snice/components/pagination/snice-pagination';
|
|
235
|
+
|
|
236
|
+
const pagination = document.querySelector('snice-pagination');
|
|
237
|
+
const dataContainer = document.querySelector('#data');
|
|
238
|
+
const itemsPerPage = 10;
|
|
239
|
+
|
|
240
|
+
// Sample data
|
|
241
|
+
const allData = Array.from({ length: 100 }, (_, i) => ({
|
|
242
|
+
id: i + 1,
|
|
243
|
+
name: `Item ${i + 1}`
|
|
244
|
+
}));
|
|
245
|
+
|
|
246
|
+
// Update total pages
|
|
247
|
+
pagination.total = Math.ceil(allData.length / itemsPerPage);
|
|
248
|
+
|
|
249
|
+
// Render data for current page
|
|
250
|
+
function renderPage(page) {
|
|
251
|
+
const start = (page - 1) * itemsPerPage;
|
|
252
|
+
const end = start + itemsPerPage;
|
|
253
|
+
const pageData = allData.slice(start, end);
|
|
254
|
+
|
|
255
|
+
dataContainer.innerHTML = pageData
|
|
256
|
+
.map(item => `<div>${item.id}. ${item.name}</div>`)
|
|
257
|
+
.join('');
|
|
258
|
+
}
|
|
259
|
+
|
|
260
|
+
// Listen for page changes
|
|
261
|
+
pagination.addEventListener('@snice/pagination-change', (e) => {
|
|
262
|
+
renderPage(e.detail.page);
|
|
263
|
+
});
|
|
264
|
+
|
|
265
|
+
// Render initial page
|
|
266
|
+
renderPage(1);
|
|
267
|
+
</script>
|
|
268
|
+
</head>
|
|
269
|
+
<body>
|
|
270
|
+
<div id="data"></div>
|
|
271
|
+
<snice-pagination current="1"></snice-pagination>
|
|
272
|
+
</body>
|
|
273
|
+
</html>
|
|
274
|
+
```
|
|
275
|
+
|
|
276
|
+
## Accessibility
|
|
277
|
+
|
|
278
|
+
The pagination component includes proper ARIA attributes:
|
|
279
|
+
|
|
280
|
+
- `role="navigation"` on the container
|
|
281
|
+
- `aria-label="Pagination"` on the nav element
|
|
282
|
+
- `aria-label` on each button describing its action
|
|
283
|
+
- `aria-current="page"` on the active page button
|
|
284
|
+
- `disabled` state for unavailable navigation buttons
|
|
285
|
+
|
|
286
|
+
## Browser Support
|
|
287
|
+
|
|
288
|
+
- Modern browsers (Chrome, Firefox, Safari, Edge)
|
|
289
|
+
- Requires Custom Elements v1 and Shadow DOM support
|