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.
Files changed (185) hide show
  1. package/bin/templates/base/tsconfig.json +5 -4
  2. package/components/accordion/demo.html +403 -0
  3. package/components/accordion/snice-accordion-item.css +85 -0
  4. package/components/accordion/snice-accordion-item.ts +226 -0
  5. package/components/accordion/snice-accordion.css +31 -0
  6. package/components/accordion/snice-accordion.ts +182 -0
  7. package/components/accordion/snice-accordion.types.ts +32 -0
  8. package/components/alert/demo.html +445 -0
  9. package/components/alert/snice-alert.css +195 -0
  10. package/components/alert/snice-alert.ts +141 -0
  11. package/components/alert/snice-alert.types.ts +12 -0
  12. package/components/avatar/demo.html +598 -0
  13. package/components/avatar/snice-avatar.css +131 -0
  14. package/components/avatar/snice-avatar.ts +136 -0
  15. package/components/avatar/snice-avatar.types.ts +13 -0
  16. package/components/badge/demo.html +523 -0
  17. package/components/badge/snice-badge.css +161 -0
  18. package/components/badge/snice-badge.ts +117 -0
  19. package/components/badge/snice-badge.types.ts +16 -0
  20. package/components/breadcrumbs/demo.html +404 -0
  21. package/components/breadcrumbs/snice-breadcrumbs.css +133 -0
  22. package/components/breadcrumbs/snice-breadcrumbs.ts +191 -0
  23. package/components/breadcrumbs/snice-breadcrumbs.types.ts +26 -0
  24. package/components/breadcrumbs/snice-crumb.ts +26 -0
  25. package/components/button/demo.html +42 -0
  26. package/components/button/snice-button.css +230 -0
  27. package/components/button/snice-button.ts +169 -0
  28. package/components/button/snice-button.types.ts +25 -0
  29. package/components/card/demo.html +525 -0
  30. package/components/card/snice-card.css +140 -0
  31. package/components/card/snice-card.ts +102 -0
  32. package/components/card/snice-card.types.ts +10 -0
  33. package/components/checkbox/demo.html +253 -0
  34. package/components/checkbox/snice-checkbox.css +164 -0
  35. package/components/checkbox/snice-checkbox.ts +223 -0
  36. package/components/checkbox/snice-checkbox.types.ts +22 -0
  37. package/components/chip/demo.html +383 -0
  38. package/components/chip/snice-chip.css +195 -0
  39. package/components/chip/snice-chip.ts +139 -0
  40. package/components/chip/snice-chip.types.ts +15 -0
  41. package/components/date-picker/README.md +233 -0
  42. package/components/date-picker/demo.html +191 -0
  43. package/components/date-picker/snice-date-picker.css +330 -0
  44. package/components/date-picker/snice-date-picker.ts +777 -0
  45. package/components/date-picker/snice-date-picker.types.ts +83 -0
  46. package/components/divider/demo.html +233 -0
  47. package/components/divider/snice-divider.css +155 -0
  48. package/components/divider/snice-divider.ts +69 -0
  49. package/components/divider/snice-divider.types.ts +15 -0
  50. package/components/drawer/demo.html +328 -0
  51. package/components/drawer/snice-drawer.css +476 -0
  52. package/components/drawer/snice-drawer.ts +287 -0
  53. package/components/drawer/snice-drawer.types.ts +17 -0
  54. package/components/global.d.ts +14 -0
  55. package/components/input/demo.html +303 -0
  56. package/components/input/snice-input.css +257 -0
  57. package/components/input/snice-input.ts +442 -0
  58. package/components/input/snice-input.types.ts +59 -0
  59. package/components/input/test.html +77 -0
  60. package/components/layout/README.md +260 -0
  61. package/components/layout/demo.html +538 -0
  62. package/components/layout/snice-layout-blog.css +129 -0
  63. package/components/layout/snice-layout-blog.ts +48 -0
  64. package/components/layout/snice-layout-card.css +104 -0
  65. package/components/layout/snice-layout-card.ts +35 -0
  66. package/components/layout/snice-layout-centered.css +51 -0
  67. package/components/layout/snice-layout-centered.ts +22 -0
  68. package/components/layout/snice-layout-dashboard.css +98 -0
  69. package/components/layout/snice-layout-dashboard.ts +45 -0
  70. package/components/layout/snice-layout-fullscreen.css +72 -0
  71. package/components/layout/snice-layout-fullscreen.ts +34 -0
  72. package/components/layout/snice-layout-landing.css +92 -0
  73. package/components/layout/snice-layout-landing.ts +47 -0
  74. package/components/layout/snice-layout-minimal.css +16 -0
  75. package/components/layout/snice-layout-minimal.ts +19 -0
  76. package/components/layout/snice-layout-sidebar.css +117 -0
  77. package/components/layout/snice-layout-sidebar.ts +48 -0
  78. package/components/layout/snice-layout-split.css +103 -0
  79. package/components/layout/snice-layout-split.ts +29 -0
  80. package/components/layout/snice-layout.css +72 -0
  81. package/components/layout/snice-layout.ts +35 -0
  82. package/components/layout/snice-layout.types.ts +5 -0
  83. package/components/login/demo-auth-controller.ts +185 -0
  84. package/components/login/demo.html +470 -0
  85. package/components/login/snice-login.css +204 -0
  86. package/components/login/snice-login.ts +337 -0
  87. package/components/login/snice-login.types.ts +34 -0
  88. package/components/modal/demo.html +291 -0
  89. package/components/modal/snice-modal.css +203 -0
  90. package/components/modal/snice-modal.ts +233 -0
  91. package/components/modal/snice-modal.types.ts +21 -0
  92. package/components/pagination/demo.html +395 -0
  93. package/components/pagination/snice-pagination.ts +333 -0
  94. package/components/pagination/snice-pagination.types.ts +21 -0
  95. package/components/progress/demo.html +510 -0
  96. package/components/progress/snice-progress.css +267 -0
  97. package/components/progress/snice-progress.ts +247 -0
  98. package/components/progress/snice-progress.types.ts +19 -0
  99. package/components/radio/demo.html +287 -0
  100. package/components/radio/snice-radio.css +171 -0
  101. package/components/radio/snice-radio.ts +218 -0
  102. package/components/radio/snice-radio.types.ts +21 -0
  103. package/components/select/demo.html +511 -0
  104. package/components/select/snice-option.ts +52 -0
  105. package/components/select/snice-option.types.ts +14 -0
  106. package/components/select/snice-select.css +392 -0
  107. package/components/select/snice-select.ts +796 -0
  108. package/components/select/snice-select.types.ts +55 -0
  109. package/components/skeleton/demo.html +514 -0
  110. package/components/skeleton/snice-skeleton.css +109 -0
  111. package/components/skeleton/snice-skeleton.ts +126 -0
  112. package/components/skeleton/snice-skeleton.types.ts +11 -0
  113. package/components/switch/demo.html +284 -0
  114. package/components/switch/snice-switch.css +221 -0
  115. package/components/switch/snice-switch.ts +229 -0
  116. package/components/switch/snice-switch.types.ts +23 -0
  117. package/components/symbols.ts +23 -0
  118. package/components/table/demo-table-controller.ts +100 -0
  119. package/components/table/demo.html +480 -0
  120. package/components/table/snice-cell-boolean.ts +112 -0
  121. package/components/table/snice-cell-date.ts +210 -0
  122. package/components/table/snice-cell-duration.ts +91 -0
  123. package/components/table/snice-cell-filesize.ts +90 -0
  124. package/components/table/snice-cell-number.ts +165 -0
  125. package/components/table/snice-cell-progress.ts +83 -0
  126. package/components/table/snice-cell-rating.ts +82 -0
  127. package/components/table/snice-cell-sparkline.ts +253 -0
  128. package/components/table/snice-cell-text.ts +125 -0
  129. package/components/table/snice-cell.css +296 -0
  130. package/components/table/snice-cell.ts +473 -0
  131. package/components/table/snice-column.ts +353 -0
  132. package/components/table/snice-header.css +243 -0
  133. package/components/table/snice-header.ts +261 -0
  134. package/components/table/snice-progress.ts +66 -0
  135. package/components/table/snice-rating.ts +45 -0
  136. package/components/table/snice-row.css +255 -0
  137. package/components/table/snice-row.ts +331 -0
  138. package/components/table/snice-table.css +241 -0
  139. package/components/table/snice-table.ts +737 -0
  140. package/components/table/snice-table.types.ts +158 -0
  141. package/components/tabs/demo.html +487 -0
  142. package/components/tabs/snice-tab-panel.css +264 -0
  143. package/components/tabs/snice-tab-panel.ts +47 -0
  144. package/components/tabs/snice-tab.css +96 -0
  145. package/components/tabs/snice-tab.ts +65 -0
  146. package/components/tabs/snice-tabs.css +189 -0
  147. package/components/tabs/snice-tabs.ts +332 -0
  148. package/components/tabs/snice-tabs.types.ts +28 -0
  149. package/components/theme/theme.css +234 -0
  150. package/components/toast/demo.html +329 -0
  151. package/components/toast/snice-toast-container.ts +256 -0
  152. package/components/toast/snice-toast.css +213 -0
  153. package/components/toast/snice-toast.ts +276 -0
  154. package/components/toast/snice-toast.types.ts +35 -0
  155. package/components/tooltip/demo.html +350 -0
  156. package/components/tooltip/snice-tooltip-portal.css +79 -0
  157. package/components/tooltip/snice-tooltip.css +117 -0
  158. package/components/tooltip/snice-tooltip.ts +612 -0
  159. package/components/tooltip/snice-tooltip.types.ts +32 -0
  160. package/components/transitions.ts +94 -0
  161. package/components/tsconfig.json +18 -0
  162. package/dist/index.cjs +441 -329
  163. package/dist/index.cjs.map +1 -1
  164. package/dist/index.cjs.min.map +1 -1
  165. package/dist/index.esm.js +441 -329
  166. package/dist/index.esm.js.map +1 -1
  167. package/dist/index.esm.min.js +3 -3
  168. package/dist/index.esm.min.js.map +1 -1
  169. package/dist/index.iife.js +441 -329
  170. package/dist/index.iife.js.map +1 -1
  171. package/dist/index.iife.min.js +3 -3
  172. package/dist/index.iife.min.js.map +1 -1
  173. package/dist/symbols.esm.js +1 -1
  174. package/dist/transitions.esm.js +1 -1
  175. package/dist/types/controller.d.ts +1 -1
  176. package/dist/types/element.d.ts +10 -10
  177. package/dist/types/events.d.ts +2 -2
  178. package/dist/types/index.d.ts +1 -1
  179. package/dist/types/observe.d.ts +1 -1
  180. package/dist/types/request-response.d.ts +2 -3
  181. package/dist/types/router.d.ts +1 -1
  182. package/package.json +9 -3
  183. package/dist/index.cjs.min +0 -15
  184. package/dist/symbols.cjs +0 -103
  185. package/dist/transitions.cjs +0 -219
@@ -0,0 +1,223 @@
1
+ import { element, property, query, on, watch, dispatch, ready } from 'snice';
2
+ import css from './snice-checkbox.css?inline';
3
+ import type { CheckboxSize, SniceCheckboxElement } from './snice-checkbox.types';
4
+
5
+ @element('snice-checkbox')
6
+ export class SniceCheckbox extends HTMLElement implements SniceCheckboxElement {
7
+ @property({ type: Boolean, reflect: true })
8
+ checked = false;
9
+
10
+ @property({ type: Boolean, reflect: true })
11
+ indeterminate = false;
12
+
13
+ @property({ type: Boolean, reflect: true })
14
+ disabled = false;
15
+
16
+ @property({ type: Boolean, reflect: true })
17
+ required = false;
18
+
19
+ @property({ type: Boolean, reflect: true })
20
+ invalid = false;
21
+
22
+ @property({ reflect: true })
23
+ size: CheckboxSize = 'medium';
24
+
25
+ @property({ reflect: true })
26
+ name = '';
27
+
28
+ @property({ reflect: true })
29
+ value = 'on';
30
+
31
+ @property({ reflect: true })
32
+ label = '';
33
+
34
+ @query('.checkbox-input')
35
+ input?: HTMLInputElement;
36
+
37
+ @query('.checkbox')
38
+ checkbox?: HTMLElement;
39
+
40
+ @query('.checkbox-label')
41
+ labelElement?: HTMLElement;
42
+
43
+ @query('.checkbox-wrapper')
44
+ wrapper?: HTMLElement;
45
+
46
+ html() {
47
+ return /*html*/`
48
+ <label class="checkbox-wrapper ${this.disabled ? 'checkbox-wrapper--disabled' : ''}">
49
+ <input
50
+ type="checkbox"
51
+ class="checkbox-input"
52
+ ${this.checked ? 'checked' : ''}
53
+ ${this.disabled ? 'disabled' : ''}
54
+ ${this.required ? 'required' : ''}
55
+ ${this.name ? `name="${this.name}"` : ''}
56
+ ${this.value ? `value="${this.value}"` : ''}
57
+ aria-invalid="${this.invalid}"
58
+ aria-checked="${this.indeterminate ? 'mixed' : this.checked}"
59
+ part="input"
60
+ />
61
+
62
+ <span class="checkbox
63
+ checkbox--${this.size}
64
+ ${this.invalid ? 'checkbox--invalid' : ''}
65
+ ${this.indeterminate ? 'checkbox--indeterminate' : ''}"
66
+ part="checkbox">
67
+
68
+ <svg class="checkbox-icon checkbox-icon--check" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
69
+ <polyline points="20 6 9 17 4 12"></polyline>
70
+ </svg>
71
+
72
+ <svg class="checkbox-icon checkbox-icon--indeterminate" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="3">
73
+ <line x1="5" y1="12" x2="19" y2="12"></line>
74
+ </svg>
75
+ </span>
76
+
77
+ ${this.label ? /*html*/`
78
+ <span class="checkbox-label checkbox-label--${this.size} ${this.required ? 'checkbox-label--required' : ''}" part="label">
79
+ ${this.label}
80
+ </span>
81
+ ` : ''}
82
+ </label>
83
+ `;
84
+ }
85
+
86
+ css() {
87
+ return css;
88
+ }
89
+
90
+ @ready()
91
+ init() {
92
+ // Set initial states
93
+ if (this.input) {
94
+ this.input.checked = this.checked;
95
+ this.input.indeterminate = this.indeterminate;
96
+
97
+ // Set form value
98
+ if (this.name) {
99
+ this.input.name = this.name;
100
+ }
101
+ if (this.value) {
102
+ this.input.value = this.value;
103
+ }
104
+ }
105
+
106
+ // Update visual state
107
+ this.updateCheckboxState();
108
+ }
109
+
110
+ @on('change', '.checkbox-input')
111
+ handleChange(e: Event) {
112
+ const target = e.target as HTMLInputElement;
113
+ this.checked = target.checked;
114
+ this.indeterminate = false; // Clear indeterminate on user interaction
115
+ this.dispatchChangeEvent();
116
+ }
117
+
118
+ @on('click', '.checkbox-input')
119
+ handleClick(e: Event) {
120
+ // Allow click to propagate for label association
121
+ e.stopPropagation();
122
+ }
123
+
124
+ @watch('checked')
125
+ handleCheckedChange() {
126
+ if (this.input) {
127
+ this.input.checked = this.checked;
128
+ }
129
+ this.updateCheckboxState();
130
+ }
131
+
132
+ @watch('indeterminate')
133
+ handleIndeterminateChange() {
134
+ if (this.input) {
135
+ this.input.indeterminate = this.indeterminate;
136
+ }
137
+ this.updateCheckboxState();
138
+ }
139
+
140
+ @watch('disabled')
141
+ handleDisabledChange() {
142
+ if (this.input) {
143
+ this.input.disabled = this.disabled;
144
+ }
145
+ if (this.wrapper) {
146
+ this.wrapper.classList.toggle('checkbox-wrapper--disabled', this.disabled);
147
+ }
148
+ }
149
+
150
+ @watch('invalid')
151
+ handleInvalidChange() {
152
+ if (this.input) {
153
+ this.input.setAttribute('aria-invalid', String(this.invalid));
154
+ }
155
+ if (this.checkbox) {
156
+ this.checkbox.classList.toggle('checkbox--invalid', this.invalid);
157
+ }
158
+ }
159
+
160
+ @watch('required')
161
+ handleRequiredChange() {
162
+ if (this.input) {
163
+ this.input.required = this.required;
164
+ }
165
+ if (this.labelElement) {
166
+ this.labelElement.classList.toggle('checkbox-label--required', this.required);
167
+ }
168
+ }
169
+
170
+ @watch('label')
171
+ handleLabelChange() {
172
+ if (this.labelElement) {
173
+ this.labelElement.textContent = this.label;
174
+ this.labelElement.style.display = this.label ? '' : 'none';
175
+ }
176
+ }
177
+
178
+ private updateCheckboxState() {
179
+ if (this.checkbox) {
180
+ // Update indeterminate state
181
+ this.checkbox.classList.toggle('checkbox--indeterminate', this.indeterminate);
182
+
183
+ // Update aria-checked
184
+ if (this.input) {
185
+ this.input.setAttribute('aria-checked', this.indeterminate ? 'mixed' : String(this.checked));
186
+ }
187
+ }
188
+ }
189
+
190
+ @dispatch('@snice/checkbox-change', { bubbles: true, composed: true })
191
+ private dispatchChangeEvent() {
192
+ return {
193
+ checked: this.checked,
194
+ indeterminate: this.indeterminate,
195
+ checkbox: this
196
+ };
197
+ }
198
+
199
+ // Public API
200
+ focus() {
201
+ this.input?.focus();
202
+ }
203
+
204
+ blur() {
205
+ this.input?.blur();
206
+ }
207
+
208
+ click() {
209
+ this.input?.click();
210
+ }
211
+
212
+ toggle() {
213
+ this.checked = !this.checked;
214
+ this.indeterminate = false;
215
+ this.dispatchChangeEvent();
216
+ }
217
+
218
+ setIndeterminate() {
219
+ this.indeterminate = true;
220
+ this.checked = false;
221
+ this.dispatchChangeEvent();
222
+ }
223
+ }
@@ -0,0 +1,22 @@
1
+ export type CheckboxSize = 'small' | 'medium' | 'large';
2
+
3
+ export interface SniceCheckboxElement extends HTMLElement {
4
+ checked: boolean;
5
+ indeterminate: boolean;
6
+ disabled: boolean;
7
+ required: boolean;
8
+ invalid: boolean;
9
+ size: CheckboxSize;
10
+ name: string;
11
+ value: string;
12
+ label: string;
13
+ focus(): void;
14
+ blur(): void;
15
+ click(): void;
16
+ }
17
+
18
+ export interface CheckboxChangeDetail {
19
+ checked: boolean;
20
+ indeterminate: boolean;
21
+ checkbox: SniceCheckboxElement;
22
+ }
@@ -0,0 +1,383 @@
1
+ <!DOCTYPE html>
2
+ <html lang="en">
3
+ <head>
4
+ <meta charset="UTF-8">
5
+ <meta name="viewport" content="width=device-width, initial-scale=1.0">
6
+ <title>Snice Chip Demo</title>
7
+ <link rel="stylesheet" href="../theme/theme.css">
8
+ <style>
9
+ body {
10
+ font-family: system-ui, -apple-system, sans-serif;
11
+ padding: 40px;
12
+ line-height: 1.6;
13
+ background: #f5f5f5;
14
+ }
15
+
16
+ .container {
17
+ max-width: 900px;
18
+ margin: 0 auto;
19
+ background: white;
20
+ padding: 40px;
21
+ border-radius: 8px;
22
+ box-shadow: 0 2px 8px rgba(0,0,0,0.1);
23
+ }
24
+
25
+ h1 {
26
+ color: #333;
27
+ border-bottom: 2px solid #e0e0e0;
28
+ padding-bottom: 10px;
29
+ }
30
+
31
+ h2 {
32
+ color: #555;
33
+ margin-top: 30px;
34
+ }
35
+
36
+ .demo-section {
37
+ margin: 30px 0;
38
+ padding: 20px;
39
+ background: #fafafa;
40
+ border-radius: 4px;
41
+ }
42
+
43
+ .demo-label {
44
+ display: block;
45
+ margin-bottom: 12px;
46
+ font-weight: 500;
47
+ color: #666;
48
+ font-size: 14px;
49
+ }
50
+
51
+ .chip-group {
52
+ display: flex;
53
+ flex-wrap: wrap;
54
+ gap: 8px;
55
+ margin: 16px 0;
56
+ }
57
+
58
+ .controls {
59
+ display: flex;
60
+ gap: 10px;
61
+ margin: 20px 0;
62
+ flex-wrap: wrap;
63
+ }
64
+
65
+ button {
66
+ padding: 8px 16px;
67
+ background: #f3f4f6;
68
+ border: 1px solid #d1d5db;
69
+ border-radius: 4px;
70
+ cursor: pointer;
71
+ font-size: 14px;
72
+ transition: background 0.2s;
73
+ }
74
+
75
+ button:hover {
76
+ background: #e5e7eb;
77
+ }
78
+
79
+ .selected-chips {
80
+ margin-top: 16px;
81
+ padding: 12px;
82
+ background: #f0f9ff;
83
+ border: 1px solid #0ea5e9;
84
+ border-radius: 4px;
85
+ min-height: 40px;
86
+ }
87
+
88
+ .selected-chips:empty::after {
89
+ content: 'No chips selected';
90
+ color: #94a3b8;
91
+ }
92
+
93
+ code {
94
+ background: #f0f0f0;
95
+ padding: 2px 6px;
96
+ border-radius: 3px;
97
+ font-size: 0.9em;
98
+ }
99
+
100
+ .event-log {
101
+ margin-top: 16px;
102
+ padding: 12px;
103
+ background: #fef3c7;
104
+ border: 1px solid #fbbf24;
105
+ border-radius: 4px;
106
+ font-size: 14px;
107
+ font-family: monospace;
108
+ max-height: 200px;
109
+ overflow-y: auto;
110
+ }
111
+
112
+ .input-group {
113
+ display: flex;
114
+ gap: 8px;
115
+ margin: 16px 0;
116
+ }
117
+
118
+ input[type="text"] {
119
+ flex: 1;
120
+ padding: 8px 12px;
121
+ border: 1px solid #d1d5db;
122
+ border-radius: 4px;
123
+ font-size: 14px;
124
+ }
125
+
126
+ .avatar-chip {
127
+ width: 20px;
128
+ height: 20px;
129
+ border-radius: 50%;
130
+ object-fit: cover;
131
+ }
132
+ </style>
133
+ </head>
134
+ <body>
135
+ <div class="container">
136
+ <h1>Snice Chip Component Demo</h1>
137
+
138
+ <div class="demo-section">
139
+ <h2>Basic Chips</h2>
140
+
141
+ <span class="demo-label">Default Chips</span>
142
+ <div class="chip-group">
143
+ <snice-chip label="JavaScript"></snice-chip>
144
+ <snice-chip label="TypeScript"></snice-chip>
145
+ <snice-chip label="React"></snice-chip>
146
+ <snice-chip label="Vue"></snice-chip>
147
+ <snice-chip label="Angular"></snice-chip>
148
+ </div>
149
+
150
+ <span class="demo-label">Selectable Chips</span>
151
+ <div class="chip-group">
152
+ <snice-chip label="Apple" selected></snice-chip>
153
+ <snice-chip label="Banana"></snice-chip>
154
+ <snice-chip label="Cherry"></snice-chip>
155
+ <snice-chip label="Date"></snice-chip>
156
+ <snice-chip label="Elderberry"></snice-chip>
157
+ </div>
158
+ </div>
159
+
160
+ <div class="demo-section">
161
+ <h2>Chip Variants</h2>
162
+
163
+ <div class="chip-group">
164
+ <snice-chip label="Default" variant="default"></snice-chip>
165
+ <snice-chip label="Primary" variant="primary"></snice-chip>
166
+ <snice-chip label="Success" variant="success"></snice-chip>
167
+ <snice-chip label="Warning" variant="warning"></snice-chip>
168
+ <snice-chip label="Error" variant="error"></snice-chip>
169
+ <snice-chip label="Info" variant="info"></snice-chip>
170
+ </div>
171
+
172
+ <span class="demo-label">Selected State in Different Variants</span>
173
+ <div class="chip-group">
174
+ <snice-chip label="Default" variant="default" selected></snice-chip>
175
+ <snice-chip label="Primary" variant="primary" selected></snice-chip>
176
+ <snice-chip label="Success" variant="success" selected></snice-chip>
177
+ <snice-chip label="Warning" variant="warning" selected></snice-chip>
178
+ <snice-chip label="Error" variant="error" selected></snice-chip>
179
+ <snice-chip label="Info" variant="info" selected></snice-chip>
180
+ </div>
181
+ </div>
182
+
183
+ <div class="demo-section">
184
+ <h2>Chip Sizes</h2>
185
+
186
+ <div class="chip-group">
187
+ <snice-chip label="Small Chip" size="small"></snice-chip>
188
+ <snice-chip label="Medium Chip" size="medium"></snice-chip>
189
+ <snice-chip label="Large Chip" size="large"></snice-chip>
190
+ </div>
191
+ </div>
192
+
193
+ <div class="demo-section">
194
+ <h2>Removable Chips</h2>
195
+
196
+ <span class="demo-label">Click the X to remove</span>
197
+ <div class="chip-group" id="removable-chips">
198
+ <snice-chip label="Remove me" removable></snice-chip>
199
+ <snice-chip label="Delete this" removable variant="primary"></snice-chip>
200
+ <snice-chip label="Clear me" removable variant="success"></snice-chip>
201
+ <snice-chip label="Dismiss" removable variant="warning"></snice-chip>
202
+ <snice-chip label="Close" removable variant="error"></snice-chip>
203
+ </div>
204
+ </div>
205
+
206
+ <div class="demo-section">
207
+ <h2>Chips with Icons</h2>
208
+
209
+ <div class="chip-group">
210
+ <snice-chip label="Star" icon="⭐"></snice-chip>
211
+ <snice-chip label="Heart" icon="❤️" variant="error"></snice-chip>
212
+ <snice-chip label="Check" icon="✓" variant="success"></snice-chip>
213
+ <snice-chip label="Warning" icon="⚠️" variant="warning"></snice-chip>
214
+ <snice-chip label="Info" icon="ℹ️" variant="info"></snice-chip>
215
+ <snice-chip label="Removable" icon="📁" removable></snice-chip>
216
+ </div>
217
+ </div>
218
+
219
+ <div class="demo-section">
220
+ <h2>Chips with Avatars</h2>
221
+
222
+ <div class="chip-group">
223
+ <snice-chip label="John Doe" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%234f46e5'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJD%3C/text%3E%3C/svg%3E"></snice-chip>
224
+ <snice-chip label="Jane Smith" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23ec4899'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJS%3C/text%3E%3C/svg%3E" removable></snice-chip>
225
+ <snice-chip label="Alex Brown" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%2310b981'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EAB%3C/text%3E%3C/svg%3E"></snice-chip>
226
+ </div>
227
+ </div>
228
+
229
+ <div class="demo-section">
230
+ <h2>Disabled State</h2>
231
+
232
+ <div class="chip-group">
233
+ <snice-chip label="Disabled" disabled></snice-chip>
234
+ <snice-chip label="Disabled Primary" variant="primary" disabled></snice-chip>
235
+ <snice-chip label="Disabled Removable" removable disabled></snice-chip>
236
+ <snice-chip label="Disabled Selected" selected disabled></snice-chip>
237
+ </div>
238
+ </div>
239
+
240
+ <div class="demo-section">
241
+ <h2>Interactive Filter Example</h2>
242
+
243
+ <span class="demo-label">Select categories:</span>
244
+ <div class="chip-group" id="filter-chips">
245
+ <snice-chip label="Electronics"></snice-chip>
246
+ <snice-chip label="Clothing"></snice-chip>
247
+ <snice-chip label="Books"></snice-chip>
248
+ <snice-chip label="Home & Garden"></snice-chip>
249
+ <snice-chip label="Sports"></snice-chip>
250
+ <snice-chip label="Toys"></snice-chip>
251
+ <snice-chip label="Food"></snice-chip>
252
+ <snice-chip label="Beauty"></snice-chip>
253
+ </div>
254
+ <div class="selected-chips" id="selected-filters"></div>
255
+ </div>
256
+
257
+ <div class="demo-section">
258
+ <h2>Dynamic Chip Creation</h2>
259
+
260
+ <div class="input-group">
261
+ <input type="text" id="chip-input" placeholder="Type and press Enter to add chip">
262
+ <button onclick="addChip()">Add Chip</button>
263
+ </div>
264
+ <div class="chip-group" id="dynamic-chips"></div>
265
+ </div>
266
+
267
+ <div class="demo-section">
268
+ <h2>Events</h2>
269
+
270
+ <span class="demo-label">Interact with these chips and watch the event log:</span>
271
+ <div class="chip-group" id="event-chips">
272
+ <snice-chip label="Click me"></snice-chip>
273
+ <snice-chip label="Remove me" removable></snice-chip>
274
+ <snice-chip label="Select me"></snice-chip>
275
+ </div>
276
+ <div class="event-log" id="event-log">Event log will appear here...</div>
277
+ </div>
278
+
279
+ <div class="demo-section">
280
+ <h2>Real-world Examples</h2>
281
+
282
+ <span class="demo-label">Email Recipients</span>
283
+ <div class="chip-group">
284
+ <snice-chip label="john@example.com" removable variant="primary" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%234f46e5'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3EJ%3C/text%3E%3C/svg%3E"></snice-chip>
285
+ <snice-chip label="sarah@company.com" removable variant="primary" avatar="data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 100 100'%3E%3Ccircle cx='50' cy='50' r='50' fill='%23ec4899'/%3E%3Ctext x='50' y='50' text-anchor='middle' dy='0.35em' fill='white' font-size='40' font-family='sans-serif'%3ES%3C/text%3E%3C/svg%3E"></snice-chip>
286
+ <snice-chip label="team@startup.io" removable variant="primary" icon="👥"></snice-chip>
287
+ </div>
288
+
289
+ <span class="demo-label">Skills</span>
290
+ <div class="chip-group">
291
+ <snice-chip label="JavaScript" icon="💛" variant="warning"></snice-chip>
292
+ <snice-chip label="Python" icon="🐍" variant="info"></snice-chip>
293
+ <snice-chip label="React" icon="⚛️" variant="info"></snice-chip>
294
+ <snice-chip label="Node.js" icon="🟢" variant="success"></snice-chip>
295
+ <snice-chip label="Docker" icon="🐳" variant="primary"></snice-chip>
296
+ </div>
297
+
298
+ <span class="demo-label">Tags</span>
299
+ <div class="chip-group">
300
+ <snice-chip label="New" variant="success" size="small"></snice-chip>
301
+ <snice-chip label="Hot" variant="error" size="small"></snice-chip>
302
+ <snice-chip label="Sale" variant="warning" size="small"></snice-chip>
303
+ <snice-chip label="Limited" variant="info" size="small"></snice-chip>
304
+ </div>
305
+ </div>
306
+ </div>
307
+
308
+ <script type="module">
309
+ import './snice-chip.ts';
310
+
311
+ // Handle removable chips
312
+ document.getElementById('removable-chips').addEventListener('chip-remove', (e) => {
313
+ e.target.remove();
314
+ });
315
+
316
+ // Handle filter chips
317
+ const filterChips = document.querySelectorAll('#filter-chips snice-chip');
318
+ const selectedFilters = document.getElementById('selected-filters');
319
+
320
+ filterChips.forEach(chip => {
321
+ chip.addEventListener('chip-click', (e) => {
322
+ updateSelectedFilters();
323
+ });
324
+ });
325
+
326
+ function updateSelectedFilters() {
327
+ const selected = Array.from(filterChips)
328
+ .filter(chip => chip.selected)
329
+ .map(chip => chip.label);
330
+
331
+ selectedFilters.textContent = selected.length > 0
332
+ ? 'Selected: ' + selected.join(', ')
333
+ : '';
334
+ }
335
+
336
+ // Dynamic chip creation
337
+ const chipInput = document.getElementById('chip-input');
338
+ const dynamicChips = document.getElementById('dynamic-chips');
339
+
340
+ window.addChip = function() {
341
+ const value = chipInput.value.trim();
342
+ if (value) {
343
+ const chip = document.createElement('snice-chip');
344
+ chip.label = value;
345
+ chip.removable = true;
346
+ chip.variant = ['default', 'primary', 'success', 'warning', 'error', 'info'][Math.floor(Math.random() * 6)];
347
+ chip.addEventListener('chip-remove', (e) => {
348
+ e.target.remove();
349
+ });
350
+ dynamicChips.appendChild(chip);
351
+ chipInput.value = '';
352
+ }
353
+ };
354
+
355
+ chipInput.addEventListener('keypress', (e) => {
356
+ if (e.key === 'Enter') {
357
+ addChip();
358
+ }
359
+ });
360
+
361
+ // Event logging
362
+ const eventChips = document.getElementById('event-chips');
363
+ const eventLog = document.getElementById('event-log');
364
+ let logEntries = [];
365
+
366
+ eventChips.addEventListener('chip-click', (e) => {
367
+ addLogEntry(`Click: "${e.detail.label}" (selected: ${e.detail.selected})`);
368
+ });
369
+
370
+ eventChips.addEventListener('chip-remove', (e) => {
371
+ addLogEntry(`Remove: "${e.detail.label}"`);
372
+ e.target.remove();
373
+ });
374
+
375
+ function addLogEntry(message) {
376
+ const timestamp = new Date().toLocaleTimeString();
377
+ logEntries.unshift(`[${timestamp}] ${message}`);
378
+ logEntries = logEntries.slice(0, 10); // Keep last 10 entries
379
+ eventLog.innerHTML = logEntries.join('<br>');
380
+ }
381
+ </script>
382
+ </body>
383
+ </html>