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,131 @@
|
|
|
1
|
+
:host {
|
|
2
|
+
display: inline-block;
|
|
3
|
+
--avatar-size: 2.5rem; /* 40px */
|
|
4
|
+
--avatar-bg: #6b7280;
|
|
5
|
+
--avatar-color: #ffffff;
|
|
6
|
+
}
|
|
7
|
+
|
|
8
|
+
.avatar {
|
|
9
|
+
position: relative;
|
|
10
|
+
width: var(--avatar-size);
|
|
11
|
+
height: var(--avatar-size);
|
|
12
|
+
overflow: hidden;
|
|
13
|
+
background: var(--avatar-bg);
|
|
14
|
+
color: var(--avatar-color);
|
|
15
|
+
display: flex;
|
|
16
|
+
align-items: center;
|
|
17
|
+
justify-content: center;
|
|
18
|
+
font-weight: 600;
|
|
19
|
+
user-select: none;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/* Shapes */
|
|
23
|
+
:host([shape="circle"]) .avatar {
|
|
24
|
+
border-radius: 50%;
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
:host([shape="square"]) .avatar {
|
|
28
|
+
border-radius: 0;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
:host([shape="rounded"]) .avatar {
|
|
32
|
+
border-radius: 8px;
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/* Sizes */
|
|
36
|
+
:host([size="xs"]) {
|
|
37
|
+
--avatar-size: 1.5rem; /* 24px */
|
|
38
|
+
font-size: 0.625rem; /* 10px */
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
:host([size="small"]) {
|
|
42
|
+
--avatar-size: 2rem; /* 32px */
|
|
43
|
+
font-size: 0.75rem; /* 12px */
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
:host([size="medium"]) {
|
|
47
|
+
--avatar-size: 2.5rem; /* 40px */
|
|
48
|
+
font-size: 0.875rem; /* 14px */
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
:host([size="large"]) {
|
|
52
|
+
--avatar-size: 3rem; /* 48px */
|
|
53
|
+
font-size: 1rem; /* 16px */
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
:host([size="xl"]) {
|
|
57
|
+
--avatar-size: 4rem; /* 64px */
|
|
58
|
+
font-size: 1.25rem; /* 20px */
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
:host([size="xxl"]) {
|
|
62
|
+
--avatar-size: 6rem; /* 96px */
|
|
63
|
+
font-size: 2rem; /* 32px */
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/* Image */
|
|
67
|
+
.avatar-image {
|
|
68
|
+
width: 100%;
|
|
69
|
+
height: 100%;
|
|
70
|
+
object-fit: cover;
|
|
71
|
+
display: block;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
.avatar-image--error {
|
|
75
|
+
display: none;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/* Fallback */
|
|
79
|
+
.avatar-fallback {
|
|
80
|
+
position: absolute;
|
|
81
|
+
inset: 0;
|
|
82
|
+
display: flex;
|
|
83
|
+
align-items: center;
|
|
84
|
+
justify-content: center;
|
|
85
|
+
opacity: 0;
|
|
86
|
+
visibility: hidden;
|
|
87
|
+
transition: opacity 0.2s ease;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
.avatar-fallback--visible {
|
|
91
|
+
opacity: 1;
|
|
92
|
+
visibility: visible;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
.avatar-icon {
|
|
96
|
+
width: 60%;
|
|
97
|
+
height: 60%;
|
|
98
|
+
opacity: 0.9;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/* Avatar color classes for fallback backgrounds */
|
|
102
|
+
.avatar--red { background: rgb(var(--avatar-color-red, 239 68 68)); }
|
|
103
|
+
.avatar--orange { background: rgb(var(--avatar-color-orange, 251 146 60)); }
|
|
104
|
+
.avatar--yellow { background: rgb(var(--avatar-color-yellow, 234 179 8)); }
|
|
105
|
+
.avatar--lime { background: rgb(var(--avatar-color-lime, 163 230 53)); }
|
|
106
|
+
.avatar--green { background: rgb(var(--avatar-color-green, 34 197 94)); }
|
|
107
|
+
.avatar--teal { background: rgb(var(--avatar-color-teal, 20 184 166)); }
|
|
108
|
+
.avatar--cyan { background: rgb(var(--avatar-color-cyan, 6 182 212)); }
|
|
109
|
+
.avatar--sky { background: rgb(var(--avatar-color-sky, 14 165 233)); }
|
|
110
|
+
.avatar--blue { background: rgb(var(--avatar-color-blue, 59 130 246)); }
|
|
111
|
+
.avatar--indigo { background: rgb(var(--avatar-color-indigo, 99 102 241)); }
|
|
112
|
+
.avatar--violet { background: rgb(var(--avatar-color-violet, 139 92 246)); }
|
|
113
|
+
.avatar--purple { background: rgb(var(--avatar-color-purple, 168 85 247)); }
|
|
114
|
+
.avatar--fuchsia { background: rgb(var(--avatar-color-fuchsia, 217 70 239)); }
|
|
115
|
+
.avatar--pink { background: rgb(var(--avatar-color-pink, 236 72 153)); }
|
|
116
|
+
.avatar--rose { background: rgb(var(--avatar-color-rose, 244 63 94)); }
|
|
117
|
+
|
|
118
|
+
/* Group avatar support */
|
|
119
|
+
:host(.avatar-group-item) {
|
|
120
|
+
margin-left: -0.5rem; /* -8px */
|
|
121
|
+
border: 2px solid white; /* Keep px for crisp borders */
|
|
122
|
+
border-radius: 50%;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
:host(.avatar-group-item:first-child) {
|
|
126
|
+
margin-left: 0;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
:host(.avatar-group-item) .avatar {
|
|
130
|
+
border: 2px solid white;
|
|
131
|
+
}
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
import { element, property, watch, query, ready, on, part } from 'snice';
|
|
2
|
+
import css from './snice-avatar.css?inline';
|
|
3
|
+
import type { AvatarSize, AvatarShape, SniceAvatarElement } from './snice-avatar.types';
|
|
4
|
+
|
|
5
|
+
@element('snice-avatar')
|
|
6
|
+
export class SniceAvatar extends HTMLElement implements SniceAvatarElement {
|
|
7
|
+
@property({ reflect: true })
|
|
8
|
+
src = '';
|
|
9
|
+
|
|
10
|
+
@property({ reflect: true })
|
|
11
|
+
alt = '';
|
|
12
|
+
|
|
13
|
+
@property({ reflect: true })
|
|
14
|
+
name = '';
|
|
15
|
+
|
|
16
|
+
@property({ reflect: true })
|
|
17
|
+
size: AvatarSize = 'medium';
|
|
18
|
+
|
|
19
|
+
@property({ reflect: true })
|
|
20
|
+
shape: AvatarShape = 'circle';
|
|
21
|
+
|
|
22
|
+
@property({ attribute: 'fallback-color', reflect: true })
|
|
23
|
+
fallbackColor = '#ffffff';
|
|
24
|
+
|
|
25
|
+
@property({ attribute: 'fallback-background', reflect: true })
|
|
26
|
+
fallbackBackground = '';
|
|
27
|
+
|
|
28
|
+
@query('.avatar-image')
|
|
29
|
+
imageElement?: HTMLImageElement;
|
|
30
|
+
|
|
31
|
+
@query('.avatar-fallback')
|
|
32
|
+
fallbackElement?: HTMLElement;
|
|
33
|
+
|
|
34
|
+
private imageError = false;
|
|
35
|
+
|
|
36
|
+
html() {
|
|
37
|
+
const colorClass = this.fallbackBackground ? '' : this.getColorClass(this.name);
|
|
38
|
+
const bgStyle = this.fallbackBackground ? `style="--avatar-bg: ${this.fallbackBackground}; --avatar-color: ${this.fallbackColor}"` : '';
|
|
39
|
+
|
|
40
|
+
return /*html*/`
|
|
41
|
+
<div class="avatar ${colorClass}" ${bgStyle}>
|
|
42
|
+
<div part="image-section"></div>
|
|
43
|
+
<div part="fallback-section"></div>
|
|
44
|
+
</div>
|
|
45
|
+
`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
@watch('src')
|
|
49
|
+
@part('image-section')
|
|
50
|
+
renderImageSection() {
|
|
51
|
+
return this.src ? /*html*/`
|
|
52
|
+
<img class="avatar-image ${this.imageError ? 'avatar-image--error' : ''}"
|
|
53
|
+
src="${this.src}"
|
|
54
|
+
alt="${this.alt || this.name}"
|
|
55
|
+
loading="lazy">
|
|
56
|
+
` : '';
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
@watch('name')
|
|
60
|
+
@part('fallback-section')
|
|
61
|
+
renderFallbackSection() {
|
|
62
|
+
const initials = this.getInitials(this.name);
|
|
63
|
+
return /*html*/`
|
|
64
|
+
<div class="avatar-fallback ${!this.src || this.imageError ? 'avatar-fallback--visible' : ''}">
|
|
65
|
+
${initials || this.renderIcon()}
|
|
66
|
+
</div>
|
|
67
|
+
`;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
css() {
|
|
71
|
+
return css;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
@ready()
|
|
75
|
+
init() {
|
|
76
|
+
this.setupImageHandlers();
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
private setupImageHandlers() {
|
|
80
|
+
if (this.imageElement) {
|
|
81
|
+
this.imageElement.addEventListener('load', this.handleImageLoad.bind(this));
|
|
82
|
+
this.imageElement.addEventListener('error', this.handleImageError.bind(this));
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
@on('load', '.avatar-image')
|
|
87
|
+
handleImageLoad() {
|
|
88
|
+
this.imageError = false;
|
|
89
|
+
this.renderImageSection();
|
|
90
|
+
this.renderFallbackSection();
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
@on('error', '.avatar-image')
|
|
94
|
+
handleImageError() {
|
|
95
|
+
this.imageError = true;
|
|
96
|
+
this.renderImageSection();
|
|
97
|
+
this.renderFallbackSection();
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
getInitials(name: string): string {
|
|
102
|
+
if (!name) return '';
|
|
103
|
+
const words = name.trim().split(/\s+/);
|
|
104
|
+
if (words.length === 1) {
|
|
105
|
+
return words[0].substring(0, 2).toUpperCase();
|
|
106
|
+
}
|
|
107
|
+
return (words[0][0] + words[words.length - 1][0]).toUpperCase();
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
private getColorClass(name: string): string {
|
|
111
|
+
if (!name) return '';
|
|
112
|
+
|
|
113
|
+
const colors = [
|
|
114
|
+
'red', 'orange', 'yellow', 'lime', 'green',
|
|
115
|
+
'teal', 'cyan', 'sky', 'blue', 'indigo',
|
|
116
|
+
'violet', 'purple', 'fuchsia', 'pink', 'rose'
|
|
117
|
+
];
|
|
118
|
+
|
|
119
|
+
// Hash the name to get a consistent index
|
|
120
|
+
let hash = 0;
|
|
121
|
+
for (let i = 0; i < name.length; i++) {
|
|
122
|
+
hash = name.charCodeAt(i) + ((hash << 5) - hash);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
const colorIndex = Math.abs(hash) % colors.length;
|
|
126
|
+
return `avatar--${colors[colorIndex]}`;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
private renderIcon(): string {
|
|
130
|
+
return /*html*/`
|
|
131
|
+
<svg class="avatar-icon" viewBox="0 0 24 24" fill="currentColor">
|
|
132
|
+
<path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/>
|
|
133
|
+
</svg>
|
|
134
|
+
`;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
export type AvatarSize = 'xs' | 'small' | 'medium' | 'large' | 'xl' | 'xxl';
|
|
2
|
+
export type AvatarShape = 'circle' | 'square' | 'rounded';
|
|
3
|
+
|
|
4
|
+
export interface SniceAvatarElement extends HTMLElement {
|
|
5
|
+
src: string;
|
|
6
|
+
alt: string;
|
|
7
|
+
name: string;
|
|
8
|
+
size: AvatarSize;
|
|
9
|
+
shape: AvatarShape;
|
|
10
|
+
fallbackColor: string;
|
|
11
|
+
fallbackBackground: string;
|
|
12
|
+
getInitials(name: string): string;
|
|
13
|
+
}
|