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
package/docs/ai/api.md
ADDED
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
# API Reference
|
|
2
|
+
|
|
3
|
+
## Class Decorators
|
|
4
|
+
|
|
5
|
+
```typescript
|
|
6
|
+
@element('tag-name') // Define custom element
|
|
7
|
+
@page({ tag, routes, guards?, placard? }) // Define routable page
|
|
8
|
+
@controller('name') // Define behavior module
|
|
9
|
+
@layout('name') // Define page wrapper
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
## Rendering
|
|
13
|
+
|
|
14
|
+
```typescript
|
|
15
|
+
@render(options?: { debounce?, throttle?, once?, sync?, differential? })
|
|
16
|
+
// Returns: TemplateResult from html`...` (or string if differential: false)
|
|
17
|
+
// Auto re-renders on property changes
|
|
18
|
+
// Supports differential updates by default
|
|
19
|
+
// differential: false - disables differential rendering, expects string return
|
|
20
|
+
// Clears shadow root and re-renders from scratch each time
|
|
21
|
+
// Still honors <if> and <switch>/<case> meta elements
|
|
22
|
+
|
|
23
|
+
@styles()
|
|
24
|
+
// Returns: CSSResult from css`...`
|
|
25
|
+
// Scoped to shadow DOM
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
## Properties
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
@property(options?: { type?, attribute?, reflect? })
|
|
32
|
+
// Syncs with attributes, triggers re-render
|
|
33
|
+
// Types: String (default), Number, Boolean, Object, Array
|
|
34
|
+
|
|
35
|
+
@watch(...propertyNames: string[])
|
|
36
|
+
// Called on property change: (oldVal, newVal) => void
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Lifecycle
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
@ready() // After initial render
|
|
43
|
+
@dispose() // On disconnectedCallback
|
|
44
|
+
@moved() // On adoptedCallback
|
|
45
|
+
@adopted() // On adoptedCallback
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
## DOM Queries
|
|
49
|
+
|
|
50
|
+
```typescript
|
|
51
|
+
@query(selector: string) // Single element
|
|
52
|
+
@queryAll(selector: string) // NodeListOf<Element>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Events
|
|
56
|
+
|
|
57
|
+
**Template syntax:**
|
|
58
|
+
```typescript
|
|
59
|
+
html`
|
|
60
|
+
<button @click=${handler}>...</button>
|
|
61
|
+
<input @keydown:Enter=${handler} />
|
|
62
|
+
<input @keydown.ctrl+s=${handler} />
|
|
63
|
+
<input .value=${val} ?disabled=${bool} />
|
|
64
|
+
`
|
|
65
|
+
```
|
|
66
|
+
|
|
67
|
+
**Decorator:**
|
|
68
|
+
```typescript
|
|
69
|
+
@on(event: string | string[], selector?: string, options?: OnOptions)
|
|
70
|
+
// Works in elements + controllers
|
|
71
|
+
// Options: { debounce?, throttle?, preventDefault?, stopPropagation?, once?, capture?, passive?, target? }
|
|
72
|
+
// target: CSS selector for shadow DOM event delegation
|
|
73
|
+
// Keyboard: 'keydown:Enter', 'keydown.escape', 'keydown:ctrl+s', 'keydown:~Space'
|
|
74
|
+
// Supports both ':' and '.' notation
|
|
75
|
+
|
|
76
|
+
@dispatch(eventName: string)
|
|
77
|
+
// Fires CustomEvent after method, detail = return value
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Communication
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
@request(channel: string)
|
|
84
|
+
// Send: this.methodName(data) → Promise<response>
|
|
85
|
+
|
|
86
|
+
@respond(channel: string)
|
|
87
|
+
// Receive: methodName(request, respond) → respond(data)
|
|
88
|
+
```
|
|
89
|
+
|
|
90
|
+
## Observers
|
|
91
|
+
|
|
92
|
+
```typescript
|
|
93
|
+
@observe(target: () => Node, options?: MutationObserverInit)
|
|
94
|
+
// Auto-cleanup on disconnect
|
|
95
|
+
// Method called with: (mutations: MutationRecord[])
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
## Context & Router
|
|
99
|
+
|
|
100
|
+
```typescript
|
|
101
|
+
@context(options?: { debounce?, throttle?, once? })
|
|
102
|
+
// Method decorator: receives Context object on router navigation
|
|
103
|
+
// Method signature: (ctx: Context) => void
|
|
104
|
+
// Context: { application, navigation: { placards, route, params }, update() }
|
|
105
|
+
// Call ctx.update() after modifying ctx.application to notify all subscribers
|
|
106
|
+
// Options:
|
|
107
|
+
// debounce (ms) - wait for quiet period before calling
|
|
108
|
+
// throttle (ms) - limit to at most once per period
|
|
109
|
+
// once - call only once then unregister
|
|
110
|
+
// Example:
|
|
111
|
+
// @context() handleContext(ctx) {
|
|
112
|
+
// this.ctx = ctx;
|
|
113
|
+
// ctx.application.user = user;
|
|
114
|
+
// ctx.update(); // notify all subscribers
|
|
115
|
+
// }
|
|
116
|
+
|
|
117
|
+
Router({ target, context?, layout? })
|
|
118
|
+
// Returns: { page, navigate, initialize }
|
|
119
|
+
// page() - decorator factory
|
|
120
|
+
// navigate(path) - programmatic navigation
|
|
121
|
+
// initialize() - start router
|
|
122
|
+
```
|
|
123
|
+
|
|
124
|
+
## Templates
|
|
125
|
+
|
|
126
|
+
```typescript
|
|
127
|
+
html`...` // TemplateResult
|
|
128
|
+
css`...` // CSSResult
|
|
129
|
+
|
|
130
|
+
// Conditionals
|
|
131
|
+
<if ${condition}>...</if>
|
|
132
|
+
<case ${value}>
|
|
133
|
+
<when value="x">...</when>
|
|
134
|
+
<default>...</default>
|
|
135
|
+
</case>
|
|
136
|
+
|
|
137
|
+
// Lists
|
|
138
|
+
${items.map(i => html`<li>${i}</li>`)}
|
|
139
|
+
|
|
140
|
+
// Bindings
|
|
141
|
+
attr="${val}" // Attribute
|
|
142
|
+
.prop="${val}" // Property
|
|
143
|
+
?attr="${bool}" // Boolean attribute
|
|
144
|
+
@event="${handler}" // Event listener
|
|
145
|
+
@event:modifier="${handler}" // With keyboard modifier
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Types
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
interface TemplateResult { readonly _$litType$: number; }
|
|
152
|
+
interface CSSResult { cssText: string; }
|
|
153
|
+
interface OnOptions { debounce?, throttle?, preventDefault?, stopPropagation?, once?, capture?, passive?, target? }
|
|
154
|
+
interface RenderOptions { debounce?, throttle?, once?, sync? }
|
|
155
|
+
interface Layout { update(context, placards, route, params) }
|
|
156
|
+
interface Placard { name, title, icon?, description?, order?, show?, visibleOn?, parent?, group?, searchTerms?, hotkeys?, breadcrumbs?, tooltip? }
|
|
157
|
+
type Guard<T> = (context: T) => boolean | Promise<boolean>
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Exports
|
|
161
|
+
|
|
162
|
+
```typescript
|
|
163
|
+
import {
|
|
164
|
+
element, page, controller, layout,
|
|
165
|
+
property, watch, context,
|
|
166
|
+
render, styles, html, css,
|
|
167
|
+
query, queryAll,
|
|
168
|
+
on, dispatch,
|
|
169
|
+
request, respond,
|
|
170
|
+
observe,
|
|
171
|
+
ready, dispose, moved, adopted,
|
|
172
|
+
Router,
|
|
173
|
+
debounce, throttle, once, memoize
|
|
174
|
+
} from 'snice';
|
|
175
|
+
```
|
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
# Architecture
|
|
2
|
+
|
|
3
|
+
## Core Principles
|
|
4
|
+
|
|
5
|
+
**Separation of concerns:**
|
|
6
|
+
- **Cross-cutting:** Router + global context
|
|
7
|
+
- **Pages:** Orchestrate elements, handle URLs
|
|
8
|
+
- **Elements:** Pure presentation, no business logic
|
|
9
|
+
- **Controllers:** Behavior, data fetching, swappable
|
|
10
|
+
|
|
11
|
+
**Data flow:**
|
|
12
|
+
- Down: Properties
|
|
13
|
+
- Up: Events
|
|
14
|
+
- Sideways: Request/Response channels
|
|
15
|
+
|
|
16
|
+
## Rendering System
|
|
17
|
+
|
|
18
|
+
**Template compilation:**
|
|
19
|
+
1. `html\`...\`` → TemplateResult
|
|
20
|
+
2. Parse template, identify dynamic parts
|
|
21
|
+
3. Create Template with Part instances
|
|
22
|
+
4. TemplateInstance tracks values
|
|
23
|
+
|
|
24
|
+
**Part types:**
|
|
25
|
+
- NodePart: Text content
|
|
26
|
+
- AttributePart: `attr="${val}"`
|
|
27
|
+
- PropertyPart: `.prop="${val}"`
|
|
28
|
+
- BooleanAttributePart: `?attr="${bool}"`
|
|
29
|
+
- EventPart: `@event="${handler}"`
|
|
30
|
+
- IfPart: `<if>` conditional
|
|
31
|
+
- CasePart: `<case>/<when>` branching
|
|
32
|
+
|
|
33
|
+
**Differential updates:**
|
|
34
|
+
- Only changed Parts re-render
|
|
35
|
+
- DOM nodes reused, not recreated
|
|
36
|
+
- Event listeners preserved
|
|
37
|
+
- Batched via microtask queue
|
|
38
|
+
|
|
39
|
+
**Auto-rendering:**
|
|
40
|
+
- Property setters trigger queueRender()
|
|
41
|
+
- Batches multiple changes
|
|
42
|
+
- Calls @render() method
|
|
43
|
+
- Updates TemplateInstance
|
|
44
|
+
|
|
45
|
+
## Decorator System
|
|
46
|
+
|
|
47
|
+
**Metadata storage:**
|
|
48
|
+
- Symbols prevent collisions
|
|
49
|
+
- Stored on prototype/class
|
|
50
|
+
- Retrieved during lifecycle
|
|
51
|
+
|
|
52
|
+
**Element lifecycle:**
|
|
53
|
+
1. Constructor
|
|
54
|
+
2. connectedCallback → setupEventHandlers, initial render
|
|
55
|
+
3. attributeChangedCallback → property sync
|
|
56
|
+
4. @ready() → after first render
|
|
57
|
+
5. Property changes → auto re-render
|
|
58
|
+
6. disconnectedCallback → cleanup
|
|
59
|
+
|
|
60
|
+
**Controller lifecycle:**
|
|
61
|
+
1. Element sets controller="name"
|
|
62
|
+
2. attributeChangedCallback detects change
|
|
63
|
+
3. Detach old controller (if any)
|
|
64
|
+
4. Attach new controller
|
|
65
|
+
5. setupEventHandlers for controller
|
|
66
|
+
6. On detach: cleanupEventHandlers
|
|
67
|
+
|
|
68
|
+
## Router System
|
|
69
|
+
|
|
70
|
+
**Registration:**
|
|
71
|
+
- @page() stores { tag, routes, guards, placard }
|
|
72
|
+
- Router.initialize() registers pages
|
|
73
|
+
- Path-to-RegExp for route matching
|
|
74
|
+
|
|
75
|
+
**Navigation:**
|
|
76
|
+
1. navigate(path) or URL change
|
|
77
|
+
2. Match route → page config
|
|
78
|
+
3. Run guards (abort if fail)
|
|
79
|
+
4. Update layout (if present)
|
|
80
|
+
5. Create/reuse page element
|
|
81
|
+
6. Extract params → page properties
|
|
82
|
+
7. Slot into layout or target
|
|
83
|
+
|
|
84
|
+
**Layouts:**
|
|
85
|
+
- Persistent wrapper around pages
|
|
86
|
+
- Receives placard metadata
|
|
87
|
+
- update() called on navigation
|
|
88
|
+
- `<slot name="page">` for content
|
|
89
|
+
|
|
90
|
+
## Event System
|
|
91
|
+
|
|
92
|
+
**Template events:**
|
|
93
|
+
- EventPart handles `@event="${handler}"`
|
|
94
|
+
- Supports keyboard modifiers via parseKeyboardFilter()
|
|
95
|
+
- Both `:` and `.` notation
|
|
96
|
+
- Listeners on actual elements
|
|
97
|
+
|
|
98
|
+
**@on decorator:**
|
|
99
|
+
- Stores handler metadata
|
|
100
|
+
- setupEventHandlers creates listeners
|
|
101
|
+
- Supports delegation with selectors
|
|
102
|
+
- Uses same parseKeyboardFilter() as templates
|
|
103
|
+
- Auto cleanup on disconnect
|
|
104
|
+
|
|
105
|
+
**Keyboard syntax:**
|
|
106
|
+
```
|
|
107
|
+
@keydown:Enter → { key: "Enter" }
|
|
108
|
+
@keydown:ctrl+s → { key: "s", ctrl: true }
|
|
109
|
+
@keydown:~Space → { key: " ", anyModifiers: true }
|
|
110
|
+
@keydown.escape → { key: "Escape" }
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
## Communication Patterns
|
|
114
|
+
|
|
115
|
+
**Parent → Child:** Properties
|
|
116
|
+
```typescript
|
|
117
|
+
html`<child-el .data=${this.data}></child-el>`
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
**Child → Parent:** Events
|
|
121
|
+
```typescript
|
|
122
|
+
@dispatch('changed')
|
|
123
|
+
onChange() { return { value: this.value }; }
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Element ↔ Controller:** Request/Response
|
|
127
|
+
```typescript
|
|
128
|
+
// Element requests, controller responds
|
|
129
|
+
@request('channel') method!: (data) => Promise<result>
|
|
130
|
+
@respond('channel') handler(req, respond) { respond(data); }
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
**Global State:** Context
|
|
134
|
+
```typescript
|
|
135
|
+
@context() handleContext(ctx: Context) {
|
|
136
|
+
this.app = ctx.application;
|
|
137
|
+
this.route = ctx.navigation.route;
|
|
138
|
+
}
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
## Shadow DOM
|
|
142
|
+
|
|
143
|
+
- All elements use shadow DOM (mode: 'open')
|
|
144
|
+
- Styles scoped automatically
|
|
145
|
+
- Events cross boundary with composed: true
|
|
146
|
+
- Query selectors work within shadowRoot
|
|
147
|
+
|
|
148
|
+
## Performance
|
|
149
|
+
|
|
150
|
+
**Optimizations:**
|
|
151
|
+
- Template caching (Map<TemplateStringsArray, Template>)
|
|
152
|
+
- Part reuse (no DOM recreation)
|
|
153
|
+
- Microtask batching (queueMicrotask)
|
|
154
|
+
- Debounce/throttle built-in
|
|
155
|
+
- Conditional rendering (IfPart, CasePart)
|
|
156
|
+
|
|
157
|
+
**Trade-offs:**
|
|
158
|
+
- Initial template parsing overhead
|
|
159
|
+
- Memory for TemplateInstance per element
|
|
160
|
+
- Benefit: Much faster updates
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
# snice-accordion & snice-accordion-item
|
|
2
|
+
|
|
3
|
+
Collapsible sections with single or multiple open mode and keyboard navigation.
|
|
4
|
+
|
|
5
|
+
## Components
|
|
6
|
+
|
|
7
|
+
### snice-accordion
|
|
8
|
+
|
|
9
|
+
Container managing accordion items.
|
|
10
|
+
|
|
11
|
+
```typescript
|
|
12
|
+
multiple: boolean = false; // Allow multiple items open
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
**Methods:**
|
|
16
|
+
- `openItem(id)` - Open specific item
|
|
17
|
+
- `closeItem(id)` - Close specific item
|
|
18
|
+
- `toggleItem(id)` - Toggle specific item
|
|
19
|
+
- `openAll()` - Open all (multiple mode only)
|
|
20
|
+
- `closeAll()` - Close all
|
|
21
|
+
|
|
22
|
+
**Events:**
|
|
23
|
+
- `@snice/accordion-open` - {itemId, item}
|
|
24
|
+
- `@snice/accordion-close` - {itemId, item}
|
|
25
|
+
|
|
26
|
+
### snice-accordion-item
|
|
27
|
+
|
|
28
|
+
Individual collapsible section.
|
|
29
|
+
|
|
30
|
+
```typescript
|
|
31
|
+
itemId: string; // Auto-generated if not provided
|
|
32
|
+
open: boolean = false;
|
|
33
|
+
disabled: boolean = false;
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
**Methods:**
|
|
37
|
+
- `toggle()` - Toggle open/closed
|
|
38
|
+
- `expand(animate = true)` - Open
|
|
39
|
+
- `collapse(animate = true)` - Close
|
|
40
|
+
|
|
41
|
+
**Events:**
|
|
42
|
+
- `accordion-item-toggle` - {itemId, open}
|
|
43
|
+
|
|
44
|
+
**Slots:**
|
|
45
|
+
- `header` - Clickable trigger content
|
|
46
|
+
- default - Collapsible content
|
|
47
|
+
|
|
48
|
+
## Usage
|
|
49
|
+
|
|
50
|
+
```html
|
|
51
|
+
<!-- Basic -->
|
|
52
|
+
<snice-accordion>
|
|
53
|
+
<snice-accordion-item item-id="item-1">
|
|
54
|
+
<span slot="header">Section 1</span>
|
|
55
|
+
<div>Content 1</div>
|
|
56
|
+
</snice-accordion-item>
|
|
57
|
+
|
|
58
|
+
<snice-accordion-item item-id="item-2">
|
|
59
|
+
<span slot="header">Section 2</span>
|
|
60
|
+
<div>Content 2</div>
|
|
61
|
+
</snice-accordion-item>
|
|
62
|
+
</snice-accordion>
|
|
63
|
+
|
|
64
|
+
<!-- Multiple open -->
|
|
65
|
+
<snice-accordion multiple>
|
|
66
|
+
<snice-accordion-item item-id="a" open>
|
|
67
|
+
<span slot="header">A</span>
|
|
68
|
+
<p>Content A</p>
|
|
69
|
+
</snice-accordion-item>
|
|
70
|
+
|
|
71
|
+
<snice-accordion-item item-id="b" open>
|
|
72
|
+
<span slot="header">B</span>
|
|
73
|
+
<p>Content B</p>
|
|
74
|
+
</snice-accordion-item>
|
|
75
|
+
</snice-accordion>
|
|
76
|
+
|
|
77
|
+
<!-- Disabled item -->
|
|
78
|
+
<snice-accordion>
|
|
79
|
+
<snice-accordion-item item-id="active">
|
|
80
|
+
<span slot="header">Active</span>
|
|
81
|
+
<p>Can open</p>
|
|
82
|
+
</snice-accordion-item>
|
|
83
|
+
|
|
84
|
+
<snice-accordion-item item-id="disabled" disabled>
|
|
85
|
+
<span slot="header">Disabled</span>
|
|
86
|
+
<p>Cannot open</p>
|
|
87
|
+
</snice-accordion-item>
|
|
88
|
+
</snice-accordion>
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Programmatic Control
|
|
92
|
+
|
|
93
|
+
```typescript
|
|
94
|
+
const accordion = document.querySelector('snice-accordion');
|
|
95
|
+
|
|
96
|
+
// Control items
|
|
97
|
+
accordion.openItem('item-1');
|
|
98
|
+
accordion.closeItem('item-2');
|
|
99
|
+
accordion.toggleItem('item-3');
|
|
100
|
+
accordion.openAll(); // Multiple mode only
|
|
101
|
+
accordion.closeAll();
|
|
102
|
+
|
|
103
|
+
// Listen for events
|
|
104
|
+
accordion.addEventListener('@snice/accordion-open', (e) => {
|
|
105
|
+
console.log('Opened:', e.detail.itemId);
|
|
106
|
+
});
|
|
107
|
+
|
|
108
|
+
// Control individual item
|
|
109
|
+
const item = document.querySelector('snice-accordion-item');
|
|
110
|
+
item.toggle();
|
|
111
|
+
item.expand();
|
|
112
|
+
item.collapse();
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Keyboard Navigation
|
|
116
|
+
|
|
117
|
+
- **↓** - Next item
|
|
118
|
+
- **↑** - Previous item
|
|
119
|
+
- **Home** - First item
|
|
120
|
+
- **End** - Last item
|
|
121
|
+
- **Enter/Space** - Toggle focused item
|
|
122
|
+
|
|
123
|
+
## Features
|
|
124
|
+
|
|
125
|
+
- Single or multiple open mode
|
|
126
|
+
- Keyboard navigation
|
|
127
|
+
- Click or keyboard to toggle
|
|
128
|
+
- Auto-generated item IDs
|
|
129
|
+
- Disabled state
|
|
130
|
+
- Open/close events
|
|
131
|
+
- Accessibility: aria-expanded, button roles
|
|
132
|
+
- Smooth animations
|
|
133
|
+
|
|
134
|
+
## Common Patterns
|
|
135
|
+
|
|
136
|
+
**FAQ:**
|
|
137
|
+
```html
|
|
138
|
+
<snice-accordion>
|
|
139
|
+
<snice-accordion-item item-id="q1">
|
|
140
|
+
<span slot="header">Question?</span>
|
|
141
|
+
<p>Answer.</p>
|
|
142
|
+
</snice-accordion-item>
|
|
143
|
+
</snice-accordion>
|
|
144
|
+
```
|
|
145
|
+
|
|
146
|
+
**Settings:**
|
|
147
|
+
```html
|
|
148
|
+
<snice-accordion multiple>
|
|
149
|
+
<snice-accordion-item item-id="general">
|
|
150
|
+
<span slot="header">General</span>
|
|
151
|
+
<!-- Settings form -->
|
|
152
|
+
</snice-accordion-item>
|
|
153
|
+
</snice-accordion>
|
|
154
|
+
```
|
|
155
|
+
|
|
156
|
+
**Lazy loading:**
|
|
157
|
+
```typescript
|
|
158
|
+
accordion.addEventListener('@snice/accordion-open', async (e) => {
|
|
159
|
+
if (!loaded[e.detail.itemId]) {
|
|
160
|
+
const data = await fetch(`/api/${e.detail.itemId}`);
|
|
161
|
+
// Update content
|
|
162
|
+
loaded[e.detail.itemId] = true;
|
|
163
|
+
}
|
|
164
|
+
});
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Notes
|
|
168
|
+
|
|
169
|
+
- Items are light DOM children (not slotted)
|
|
170
|
+
- Without `multiple`, opening one closes others
|
|
171
|
+
- Item IDs auto-generated if not provided
|
|
172
|
+
- Disabled items cannot be toggled
|
|
173
|
+
- Header slot required for trigger content
|
|
174
|
+
- Full ARIA support for screen readers
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
# snice-alert
|
|
2
|
+
|
|
3
|
+
Notification messages for user feedback.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
variant: 'info'|'success'|'warning'|'error' = 'info';
|
|
9
|
+
size: 'small'|'medium'|'large' = 'medium';
|
|
10
|
+
title: string = '';
|
|
11
|
+
dismissible: boolean = false;
|
|
12
|
+
icon: string = '';
|
|
13
|
+
```
|
|
14
|
+
|
|
15
|
+
## Methods
|
|
16
|
+
|
|
17
|
+
- `show()` - Show alert
|
|
18
|
+
- `hide()` - Hide alert
|
|
19
|
+
|
|
20
|
+
## Usage
|
|
21
|
+
|
|
22
|
+
```html
|
|
23
|
+
<!-- Basic -->
|
|
24
|
+
<snice-alert>Alert message</snice-alert>
|
|
25
|
+
|
|
26
|
+
<!-- Success -->
|
|
27
|
+
<snice-alert variant="success">
|
|
28
|
+
Operation completed successfully!
|
|
29
|
+
</snice-alert>
|
|
30
|
+
|
|
31
|
+
<!-- Error -->
|
|
32
|
+
<snice-alert variant="error">
|
|
33
|
+
An error occurred
|
|
34
|
+
</snice-alert>
|
|
35
|
+
|
|
36
|
+
<!-- Warning -->
|
|
37
|
+
<snice-alert variant="warning">
|
|
38
|
+
Please review your input
|
|
39
|
+
</snice-alert>
|
|
40
|
+
|
|
41
|
+
<!-- With title -->
|
|
42
|
+
<snice-alert variant="info" title="Information">
|
|
43
|
+
Additional details about the information.
|
|
44
|
+
</snice-alert>
|
|
45
|
+
|
|
46
|
+
<!-- Dismissible -->
|
|
47
|
+
<snice-alert variant="success" dismissible>
|
|
48
|
+
Can be closed by user
|
|
49
|
+
</snice-alert>
|
|
50
|
+
|
|
51
|
+
<!-- Custom icon -->
|
|
52
|
+
<snice-alert icon="🎉">
|
|
53
|
+
Custom icon alert
|
|
54
|
+
</snice-alert>
|
|
55
|
+
|
|
56
|
+
<!-- Sizes -->
|
|
57
|
+
<snice-alert size="small">Small</snice-alert>
|
|
58
|
+
<snice-alert size="medium">Medium</snice-alert>
|
|
59
|
+
<snice-alert size="large">Large</snice-alert>
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Features
|
|
63
|
+
|
|
64
|
+
- 4 variants with semantic colors
|
|
65
|
+
- 3 size options
|
|
66
|
+
- Optional title
|
|
67
|
+
- Optional dismiss button
|
|
68
|
+
- Custom icon support
|
|
69
|
+
- Show/hide methods
|
|
70
|
+
- Accessibility: role="alert"
|
|
71
|
+
|
|
72
|
+
## Variants
|
|
73
|
+
|
|
74
|
+
- `info` - Blue, informational
|
|
75
|
+
- `success` - Green, positive feedback
|
|
76
|
+
- `warning` - Orange, caution
|
|
77
|
+
- `error` - Red, errors/problems
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
# snice-avatar
|
|
2
|
+
|
|
3
|
+
User profile images with fallback initials.
|
|
4
|
+
|
|
5
|
+
## Properties
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
src: string = '';
|
|
9
|
+
alt: string = '';
|
|
10
|
+
name: string = '';
|
|
11
|
+
size: 'xs'|'small'|'medium'|'large'|'xl'|'xxl' = 'medium';
|
|
12
|
+
shape: 'circle'|'square'|'rounded' = 'circle';
|
|
13
|
+
fallbackColor: string = '';
|
|
14
|
+
fallbackBackground: string = '';
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
## Methods
|
|
18
|
+
|
|
19
|
+
- `getInitials(name)` - Extract initials from name
|
|
20
|
+
|
|
21
|
+
## Usage
|
|
22
|
+
|
|
23
|
+
```html
|
|
24
|
+
<!-- With image -->
|
|
25
|
+
<snice-avatar
|
|
26
|
+
src="/user.jpg"
|
|
27
|
+
alt="John Doe"
|
|
28
|
+
name="John Doe">
|
|
29
|
+
</snice-avatar>
|
|
30
|
+
|
|
31
|
+
<!-- Fallback to initials -->
|
|
32
|
+
<snice-avatar name="John Doe"></snice-avatar>
|
|
33
|
+
|
|
34
|
+
<!-- Sizes -->
|
|
35
|
+
<snice-avatar name="JD" size="xs"></snice-avatar>
|
|
36
|
+
<snice-avatar name="JD" size="small"></snice-avatar>
|
|
37
|
+
<snice-avatar name="JD" size="medium"></snice-avatar>
|
|
38
|
+
<snice-avatar name="JD" size="large"></snice-avatar>
|
|
39
|
+
<snice-avatar name="JD" size="xl"></snice-avatar>
|
|
40
|
+
<snice-avatar name="JD" size="xxl"></snice-avatar>
|
|
41
|
+
|
|
42
|
+
<!-- Shapes -->
|
|
43
|
+
<snice-avatar name="JD" shape="circle"></snice-avatar>
|
|
44
|
+
<snice-avatar name="JD" shape="square"></snice-avatar>
|
|
45
|
+
<snice-avatar name="JD" shape="rounded"></snice-avatar>
|
|
46
|
+
|
|
47
|
+
<!-- Custom colors -->
|
|
48
|
+
<snice-avatar
|
|
49
|
+
name="JD"
|
|
50
|
+
fallback-color="#fff"
|
|
51
|
+
fallback-background="#3b82f6">
|
|
52
|
+
</snice-avatar>
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
## Features
|
|
56
|
+
|
|
57
|
+
- 6 size options (xs to xxl)
|
|
58
|
+
- 3 shape options
|
|
59
|
+
- Image with fallback to initials
|
|
60
|
+
- Custom fallback colors
|
|
61
|
+
- Auto-extracts initials from name
|