snice 1.14.3 → 2.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/bin/templates/base/tsconfig.json +5 -4
- package/components/accordion/demo.html +403 -0
- package/components/accordion/snice-accordion-item.css +85 -0
- package/components/accordion/snice-accordion-item.ts +226 -0
- package/components/accordion/snice-accordion.css +31 -0
- package/components/accordion/snice-accordion.ts +182 -0
- package/components/accordion/snice-accordion.types.ts +32 -0
- package/components/alert/demo.html +445 -0
- package/components/alert/snice-alert.css +195 -0
- package/components/alert/snice-alert.ts +141 -0
- package/components/alert/snice-alert.types.ts +12 -0
- package/components/avatar/demo.html +598 -0
- package/components/avatar/snice-avatar.css +131 -0
- package/components/avatar/snice-avatar.ts +136 -0
- package/components/avatar/snice-avatar.types.ts +13 -0
- package/components/badge/demo.html +523 -0
- package/components/badge/snice-badge.css +161 -0
- package/components/badge/snice-badge.ts +117 -0
- package/components/badge/snice-badge.types.ts +16 -0
- package/components/breadcrumbs/demo.html +404 -0
- package/components/breadcrumbs/snice-breadcrumbs.css +133 -0
- package/components/breadcrumbs/snice-breadcrumbs.ts +191 -0
- package/components/breadcrumbs/snice-breadcrumbs.types.ts +26 -0
- package/components/breadcrumbs/snice-crumb.ts +26 -0
- package/components/button/demo.html +42 -0
- package/components/button/snice-button.css +230 -0
- package/components/button/snice-button.ts +169 -0
- package/components/button/snice-button.types.ts +25 -0
- package/components/card/demo.html +525 -0
- package/components/card/snice-card.css +140 -0
- package/components/card/snice-card.ts +102 -0
- package/components/card/snice-card.types.ts +10 -0
- package/components/checkbox/demo.html +253 -0
- package/components/checkbox/snice-checkbox.css +164 -0
- package/components/checkbox/snice-checkbox.ts +223 -0
- package/components/checkbox/snice-checkbox.types.ts +22 -0
- package/components/chip/demo.html +383 -0
- package/components/chip/snice-chip.css +195 -0
- package/components/chip/snice-chip.ts +139 -0
- package/components/chip/snice-chip.types.ts +15 -0
- package/components/date-picker/README.md +233 -0
- package/components/date-picker/demo.html +191 -0
- package/components/date-picker/snice-date-picker.css +330 -0
- package/components/date-picker/snice-date-picker.ts +777 -0
- package/components/date-picker/snice-date-picker.types.ts +83 -0
- package/components/divider/demo.html +233 -0
- package/components/divider/snice-divider.css +155 -0
- package/components/divider/snice-divider.ts +69 -0
- package/components/divider/snice-divider.types.ts +15 -0
- package/components/drawer/demo.html +328 -0
- package/components/drawer/snice-drawer.css +476 -0
- package/components/drawer/snice-drawer.ts +287 -0
- package/components/drawer/snice-drawer.types.ts +17 -0
- package/components/global.d.ts +14 -0
- package/components/input/demo.html +303 -0
- package/components/input/snice-input.css +257 -0
- package/components/input/snice-input.ts +442 -0
- package/components/input/snice-input.types.ts +59 -0
- package/components/input/test.html +77 -0
- package/components/layout/README.md +260 -0
- package/components/layout/demo.html +538 -0
- package/components/layout/snice-layout-blog.css +129 -0
- package/components/layout/snice-layout-blog.ts +48 -0
- package/components/layout/snice-layout-card.css +104 -0
- package/components/layout/snice-layout-card.ts +35 -0
- package/components/layout/snice-layout-centered.css +51 -0
- package/components/layout/snice-layout-centered.ts +22 -0
- package/components/layout/snice-layout-dashboard.css +98 -0
- package/components/layout/snice-layout-dashboard.ts +45 -0
- package/components/layout/snice-layout-fullscreen.css +72 -0
- package/components/layout/snice-layout-fullscreen.ts +34 -0
- package/components/layout/snice-layout-landing.css +92 -0
- package/components/layout/snice-layout-landing.ts +47 -0
- package/components/layout/snice-layout-minimal.css +16 -0
- package/components/layout/snice-layout-minimal.ts +19 -0
- package/components/layout/snice-layout-sidebar.css +117 -0
- package/components/layout/snice-layout-sidebar.ts +48 -0
- package/components/layout/snice-layout-split.css +103 -0
- package/components/layout/snice-layout-split.ts +29 -0
- package/components/layout/snice-layout.css +72 -0
- package/components/layout/snice-layout.ts +35 -0
- package/components/layout/snice-layout.types.ts +5 -0
- package/components/login/demo-auth-controller.ts +185 -0
- package/components/login/demo.html +470 -0
- package/components/login/snice-login.css +204 -0
- package/components/login/snice-login.ts +337 -0
- package/components/login/snice-login.types.ts +34 -0
- package/components/modal/demo.html +291 -0
- package/components/modal/snice-modal.css +203 -0
- package/components/modal/snice-modal.ts +233 -0
- package/components/modal/snice-modal.types.ts +21 -0
- package/components/pagination/demo.html +395 -0
- package/components/pagination/snice-pagination.ts +333 -0
- package/components/pagination/snice-pagination.types.ts +21 -0
- package/components/progress/demo.html +510 -0
- package/components/progress/snice-progress.css +267 -0
- package/components/progress/snice-progress.ts +247 -0
- package/components/progress/snice-progress.types.ts +19 -0
- package/components/radio/demo.html +287 -0
- package/components/radio/snice-radio.css +171 -0
- package/components/radio/snice-radio.ts +218 -0
- package/components/radio/snice-radio.types.ts +21 -0
- package/components/select/demo.html +511 -0
- package/components/select/snice-option.ts +52 -0
- package/components/select/snice-option.types.ts +14 -0
- package/components/select/snice-select.css +392 -0
- package/components/select/snice-select.ts +796 -0
- package/components/select/snice-select.types.ts +55 -0
- package/components/skeleton/demo.html +514 -0
- package/components/skeleton/snice-skeleton.css +109 -0
- package/components/skeleton/snice-skeleton.ts +126 -0
- package/components/skeleton/snice-skeleton.types.ts +11 -0
- package/components/switch/demo.html +284 -0
- package/components/switch/snice-switch.css +221 -0
- package/components/switch/snice-switch.ts +229 -0
- package/components/switch/snice-switch.types.ts +23 -0
- package/components/symbols.ts +23 -0
- package/components/table/demo-table-controller.ts +100 -0
- package/components/table/demo.html +480 -0
- package/components/table/snice-cell-boolean.ts +112 -0
- package/components/table/snice-cell-date.ts +210 -0
- package/components/table/snice-cell-duration.ts +91 -0
- package/components/table/snice-cell-filesize.ts +90 -0
- package/components/table/snice-cell-number.ts +165 -0
- package/components/table/snice-cell-progress.ts +83 -0
- package/components/table/snice-cell-rating.ts +82 -0
- package/components/table/snice-cell-sparkline.ts +253 -0
- package/components/table/snice-cell-text.ts +125 -0
- package/components/table/snice-cell.css +296 -0
- package/components/table/snice-cell.ts +473 -0
- package/components/table/snice-column.ts +353 -0
- package/components/table/snice-header.css +243 -0
- package/components/table/snice-header.ts +261 -0
- package/components/table/snice-progress.ts +66 -0
- package/components/table/snice-rating.ts +45 -0
- package/components/table/snice-row.css +255 -0
- package/components/table/snice-row.ts +331 -0
- package/components/table/snice-table.css +241 -0
- package/components/table/snice-table.ts +737 -0
- package/components/table/snice-table.types.ts +158 -0
- package/components/tabs/demo.html +487 -0
- package/components/tabs/snice-tab-panel.css +264 -0
- package/components/tabs/snice-tab-panel.ts +47 -0
- package/components/tabs/snice-tab.css +96 -0
- package/components/tabs/snice-tab.ts +65 -0
- package/components/tabs/snice-tabs.css +189 -0
- package/components/tabs/snice-tabs.ts +332 -0
- package/components/tabs/snice-tabs.types.ts +28 -0
- package/components/theme/theme.css +234 -0
- package/components/toast/demo.html +329 -0
- package/components/toast/snice-toast-container.ts +256 -0
- package/components/toast/snice-toast.css +213 -0
- package/components/toast/snice-toast.ts +276 -0
- package/components/toast/snice-toast.types.ts +35 -0
- package/components/tooltip/demo.html +350 -0
- package/components/tooltip/snice-tooltip-portal.css +79 -0
- package/components/tooltip/snice-tooltip.css +117 -0
- package/components/tooltip/snice-tooltip.ts +612 -0
- package/components/tooltip/snice-tooltip.types.ts +32 -0
- package/components/transitions.ts +94 -0
- package/components/tsconfig.json +18 -0
- package/dist/index.cjs +441 -329
- package/dist/index.cjs.map +1 -1
- package/dist/index.cjs.min.map +1 -1
- package/dist/index.esm.js +441 -329
- package/dist/index.esm.js.map +1 -1
- package/dist/index.esm.min.js +3 -3
- package/dist/index.esm.min.js.map +1 -1
- package/dist/index.iife.js +441 -329
- package/dist/index.iife.js.map +1 -1
- package/dist/index.iife.min.js +3 -3
- package/dist/index.iife.min.js.map +1 -1
- package/dist/symbols.esm.js +1 -1
- package/dist/transitions.esm.js +1 -1
- package/dist/types/controller.d.ts +1 -1
- package/dist/types/element.d.ts +10 -10
- package/dist/types/events.d.ts +2 -2
- package/dist/types/index.d.ts +1 -1
- package/dist/types/observe.d.ts +1 -1
- package/dist/types/request-response.d.ts +2 -3
- package/dist/types/router.d.ts +1 -1
- package/package.json +9 -3
- package/dist/index.cjs.min +0 -15
- package/dist/symbols.cjs +0 -103
- package/dist/transitions.cjs +0 -219
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { element, property, watch, query, on, dispatch, part } from 'snice';
|
|
2
|
+
import css from './snice-alert.css?inline';
|
|
3
|
+
import type { AlertVariant, AlertSize, SniceAlertElement } from './snice-alert.types';
|
|
4
|
+
|
|
5
|
+
@element('snice-alert')
|
|
6
|
+
export class SniceAlert extends HTMLElement implements SniceAlertElement {
|
|
7
|
+
@property({ reflect: true })
|
|
8
|
+
variant: AlertVariant = 'info';
|
|
9
|
+
|
|
10
|
+
@property({ reflect: true })
|
|
11
|
+
size: AlertSize = 'medium';
|
|
12
|
+
|
|
13
|
+
@property({ reflect: true })
|
|
14
|
+
title = '';
|
|
15
|
+
|
|
16
|
+
@property({ type: Boolean, reflect: true })
|
|
17
|
+
dismissible = false;
|
|
18
|
+
|
|
19
|
+
@property({ reflect: true })
|
|
20
|
+
icon = '';
|
|
21
|
+
|
|
22
|
+
@query('.alert')
|
|
23
|
+
alertElement?: HTMLElement;
|
|
24
|
+
|
|
25
|
+
private isHidden = false;
|
|
26
|
+
|
|
27
|
+
html() {
|
|
28
|
+
return /*html*/`
|
|
29
|
+
<div class="alert ${this.isHidden ? 'alert--hidden' : ''}" role="alert" aria-live="polite">
|
|
30
|
+
<div part="icon-section"></div>
|
|
31
|
+
<div class="alert-content">
|
|
32
|
+
<div part="title-section"></div>
|
|
33
|
+
<div part="description-section"></div>
|
|
34
|
+
</div>
|
|
35
|
+
<div part="dismiss-section"></div>
|
|
36
|
+
</div>
|
|
37
|
+
`;
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
@part('icon-section')
|
|
41
|
+
renderIconSection() {
|
|
42
|
+
const hasIcon = this.icon || this.shouldShowDefaultIcon();
|
|
43
|
+
return hasIcon ? /*html*/`
|
|
44
|
+
<div class="alert-icon ${!this.icon ? 'alert-icon--default' : ''}">
|
|
45
|
+
${this.icon || ''}
|
|
46
|
+
</div>
|
|
47
|
+
` : '';
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
@watch('title')
|
|
51
|
+
@part('title-section')
|
|
52
|
+
renderTitleSection() {
|
|
53
|
+
return this.title ? /*html*/`
|
|
54
|
+
<div class="alert-title">${this.title}</div>
|
|
55
|
+
` : '';
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
@part('description-section')
|
|
59
|
+
renderDescriptionSection() {
|
|
60
|
+
return /*html*/`
|
|
61
|
+
<div class="alert-description">
|
|
62
|
+
<slot></slot>
|
|
63
|
+
</div>
|
|
64
|
+
`;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
@watch('dismissible')
|
|
68
|
+
@part('dismiss-section')
|
|
69
|
+
renderDismissSection() {
|
|
70
|
+
return this.dismissible ? /*html*/`
|
|
71
|
+
<button class="alert-dismiss" type="button" aria-label="Dismiss alert">
|
|
72
|
+
<svg viewBox="0 0 24 24" fill="currentColor">
|
|
73
|
+
<path d="M19 6.41L17.59 5L12 10.59L6.41 5L5 6.41L10.59 12L5 17.59L6.41 19L12 13.41L17.59 19L19 17.59L13.41 12L19 6.41Z"/>
|
|
74
|
+
</svg>
|
|
75
|
+
</button>
|
|
76
|
+
` : '';
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
css() {
|
|
80
|
+
return css;
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
private shouldShowDefaultIcon(): boolean {
|
|
84
|
+
// Show default icons for variants unless explicitly disabled
|
|
85
|
+
return this.icon !== 'none';
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
|
|
89
|
+
@on('click', '.alert-dismiss')
|
|
90
|
+
@dispatch('alert-dismiss')
|
|
91
|
+
handleDismiss() {
|
|
92
|
+
this.hide();
|
|
93
|
+
return {
|
|
94
|
+
variant: this.variant,
|
|
95
|
+
title: this.title
|
|
96
|
+
};
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
@on('animationend', '.alert')
|
|
100
|
+
handleAnimationEnd(event: AnimationEvent) {
|
|
101
|
+
if (event.animationName === 'slideOut') {
|
|
102
|
+
this.isHidden = true;
|
|
103
|
+
if (this.alertElement) {
|
|
104
|
+
this.alertElement.classList.add('alert--hidden');
|
|
105
|
+
this.alertElement.classList.remove('alert--hiding');
|
|
106
|
+
}
|
|
107
|
+
this.dispatchAlertHidden();
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
@dispatch('alert-hidden')
|
|
112
|
+
private dispatchAlertHidden() {
|
|
113
|
+
return {
|
|
114
|
+
variant: this.variant,
|
|
115
|
+
title: this.title
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
@dispatch('alert-shown')
|
|
120
|
+
private dispatchAlertShown() {
|
|
121
|
+
return {
|
|
122
|
+
variant: this.variant,
|
|
123
|
+
title: this.title
|
|
124
|
+
};
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
show() {
|
|
128
|
+
this.isHidden = false;
|
|
129
|
+
if (this.alertElement) {
|
|
130
|
+
this.alertElement.classList.remove('alert--hidden', 'alert--hiding');
|
|
131
|
+
}
|
|
132
|
+
this.dispatchAlertShown();
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
hide() {
|
|
136
|
+
if (this.alertElement && !this.isHidden) {
|
|
137
|
+
this.alertElement.classList.add('alert--hiding');
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export type AlertVariant = 'info' | 'success' | 'warning' | 'error';
|
|
2
|
+
export type AlertSize = 'small' | 'medium' | 'large';
|
|
3
|
+
|
|
4
|
+
export interface SniceAlertElement extends HTMLElement {
|
|
5
|
+
variant: AlertVariant;
|
|
6
|
+
size: AlertSize;
|
|
7
|
+
title: string;
|
|
8
|
+
dismissible: boolean;
|
|
9
|
+
icon: string;
|
|
10
|
+
show(): void;
|
|
11
|
+
hide(): void;
|
|
12
|
+
}
|