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,287 @@
1
+ import { element, property, query, on, watch, dispatch, ready, dispose } from 'snice';
2
+ import css from './snice-drawer.css?inline';
3
+ import type { DrawerPosition, DrawerSize, SniceDrawerElement } from './snice-drawer.types';
4
+
5
+ @element('snice-drawer')
6
+ export class SniceDrawer extends HTMLElement implements SniceDrawerElement {
7
+ @property({ type: Boolean, reflect: true })
8
+ open = false;
9
+
10
+ @property({ reflect: true })
11
+ position: DrawerPosition = 'left';
12
+
13
+ @property({ reflect: true })
14
+ size: DrawerSize = 'medium';
15
+
16
+ @property({ type: Boolean, attribute: 'no-backdrop', reflect: true })
17
+ noBackdrop = false;
18
+
19
+ @property({ type: Boolean, attribute: 'no-backdrop-dismiss', reflect: true })
20
+ noBackdropDismiss = false;
21
+
22
+ @property({ type: Boolean, attribute: 'no-escape-dismiss', reflect: true })
23
+ noEscapeDismiss = false;
24
+
25
+ @property({ type: Boolean, attribute: 'no-focus-trap', reflect: true })
26
+ noFocusTrap = false;
27
+
28
+ @property({ type: Boolean, reflect: true })
29
+ persistent = false;
30
+
31
+ @property({ type: Boolean, attribute: 'push-content', reflect: true })
32
+ pushContent = false;
33
+
34
+ @query('.drawer')
35
+ drawerElement?: HTMLElement;
36
+
37
+ @query('.drawer-backdrop')
38
+ backdropElement?: HTMLElement;
39
+
40
+ @query('.drawer-close')
41
+ closeButton?: HTMLButtonElement;
42
+
43
+ @query('.focus-trap-start')
44
+ focusTrapStart?: HTMLElement;
45
+
46
+ @query('.focus-trap-end')
47
+ focusTrapEnd?: HTMLElement;
48
+
49
+ private previousFocus?: HTMLElement;
50
+ private boundHandleEscape?: (e: KeyboardEvent) => void;
51
+
52
+ html() {
53
+ return /*html*/`
54
+ <div class="drawer-backdrop" part="backdrop"></div>
55
+
56
+ <div class="drawer" role="dialog" aria-modal="true" tabindex="-1" part="base">
57
+ <span class="focus-trap-start" tabindex="0"></span>
58
+
59
+ <div class="drawer-header" part="header">
60
+ <h2 class="drawer-title" part="title">
61
+ <slot name="title"></slot>
62
+ </h2>
63
+ ${!this.persistent ? /*html*/`
64
+ <button class="drawer-close" type="button" aria-label="Close" part="close">
65
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
66
+ <path d="M18 6L6 18M6 6l12 12"/>
67
+ </svg>
68
+ </button>
69
+ ` : ''}
70
+ </div>
71
+
72
+ <div class="drawer-body" part="body">
73
+ <slot></slot>
74
+ </div>
75
+
76
+ <div class="drawer-footer" part="footer">
77
+ <slot name="footer"></slot>
78
+ </div>
79
+
80
+ <span class="focus-trap-end" tabindex="0"></span>
81
+ </div>
82
+ `;
83
+ }
84
+
85
+ css() {
86
+ return css;
87
+ }
88
+
89
+ @ready()
90
+ init() {
91
+ // Ensure default attributes are set
92
+ if (!this.hasAttribute('position')) {
93
+ this.setAttribute('position', this.position);
94
+ }
95
+ if (!this.hasAttribute('size')) {
96
+ this.setAttribute('size', this.size);
97
+ }
98
+
99
+ this.setAttribute('role', 'complementary');
100
+ this.setAttribute('aria-hidden', String(!this.open));
101
+
102
+ // Pre-set transition for push content mode to avoid jump on first use
103
+ if (this.pushContent) {
104
+ const mainContent = document.querySelector('main') || document.body;
105
+ if (mainContent && mainContent !== document.body) {
106
+ (mainContent as HTMLElement).style.transition = 'margin 0.3s cubic-bezier(0.4, 0, 0.2, 1)';
107
+ }
108
+ }
109
+
110
+ if (this.open) {
111
+ this.handleOpen();
112
+ }
113
+ }
114
+
115
+ @watch('open')
116
+ handleOpenChange() {
117
+ this.setAttribute('aria-hidden', String(!this.open));
118
+
119
+ if (this.open) {
120
+ this.handleOpen();
121
+ } else {
122
+ this.handleClose();
123
+ }
124
+ }
125
+
126
+ @on('click', '.drawer-backdrop')
127
+ handleBackdropClick(e: MouseEvent) {
128
+ if (!this.noBackdropDismiss && !this.persistent) {
129
+ e.stopPropagation();
130
+ this.hide();
131
+ }
132
+ }
133
+
134
+ @on('click', '.drawer-close')
135
+ handleCloseClick(e: MouseEvent) {
136
+ e.stopPropagation();
137
+ this.hide();
138
+ }
139
+
140
+ @on('focus', '.focus-trap-start')
141
+ handleFocusTrapStart() {
142
+ if (!this.noFocusTrap) {
143
+ // Focus the last focusable element in the drawer
144
+ const focusableElements = this.getFocusableElements();
145
+ if (focusableElements.length > 0) {
146
+ (focusableElements[focusableElements.length - 1] as HTMLElement).focus();
147
+ }
148
+ }
149
+ }
150
+
151
+ @on('focus', '.focus-trap-end')
152
+ handleFocusTrapEnd() {
153
+ if (!this.noFocusTrap) {
154
+ // Focus the first focusable element in the drawer
155
+ const focusableElements = this.getFocusableElements();
156
+ if (focusableElements.length > 0) {
157
+ (focusableElements[0] as HTMLElement).focus();
158
+ }
159
+ }
160
+ }
161
+
162
+ private handleOpen() {
163
+ // Store current focus
164
+ this.previousFocus = document.activeElement as HTMLElement;
165
+
166
+ // Add escape key handler
167
+ if (!this.noEscapeDismiss && !this.persistent) {
168
+ this.boundHandleEscape = (e: KeyboardEvent) => {
169
+ if (e.key === 'Escape') {
170
+ e.preventDefault();
171
+ this.hide();
172
+ }
173
+ };
174
+ document.addEventListener('keydown', this.boundHandleEscape);
175
+ }
176
+
177
+ // Prevent body scroll
178
+ document.body.style.overflow = 'hidden';
179
+
180
+ // Focus management
181
+ if (!this.noFocusTrap) {
182
+ requestAnimationFrame(() => {
183
+ if (this.drawerElement) {
184
+ this.drawerElement.focus();
185
+ }
186
+ });
187
+ }
188
+
189
+ // Push content if enabled
190
+ if (this.pushContent) {
191
+ this.updatePushContent();
192
+ }
193
+
194
+ this.dispatchOpenEvent();
195
+ }
196
+
197
+ private handleClose() {
198
+ // Remove escape key handler
199
+ if (this.boundHandleEscape) {
200
+ document.removeEventListener('keydown', this.boundHandleEscape);
201
+ this.boundHandleEscape = undefined;
202
+ }
203
+
204
+ // Restore body scroll
205
+ document.body.style.overflow = '';
206
+
207
+ // Restore focus
208
+ if (this.previousFocus && this.previousFocus.focus) {
209
+ this.previousFocus.focus();
210
+ this.previousFocus = undefined;
211
+ }
212
+
213
+ // Reset push content
214
+ if (this.pushContent) {
215
+ this.updatePushContent();
216
+ }
217
+
218
+ this.dispatchCloseEvent();
219
+ }
220
+
221
+ private updatePushContent() {
222
+ if (!this.pushContent) return;
223
+
224
+ // Apply to body or main content container
225
+ const mainContent = document.querySelector('main') || document.body;
226
+ if (mainContent && mainContent !== document.body) {
227
+ // Set transition first if not already set
228
+ if (!mainContent.style.transition) {
229
+ (mainContent as HTMLElement).style.transition = 'margin 0.3s cubic-bezier(0.4, 0, 0.2, 1)';
230
+ }
231
+
232
+ if (this.open) {
233
+ // Use CSS custom property that's calculated in CSS based on size/position
234
+ const amount = getComputedStyle(this).getPropertyValue('--drawer-push-amount');
235
+ const property = this.position === 'left' || this.position === 'right'
236
+ ? 'marginLeft'
237
+ : 'marginTop';
238
+ (mainContent as HTMLElement).style[property] = amount || '0px';
239
+ } else {
240
+ // Reset margins
241
+ (mainContent as HTMLElement).style.marginLeft = '';
242
+ (mainContent as HTMLElement).style.marginTop = '';
243
+ }
244
+ }
245
+ }
246
+
247
+ private getFocusableElements(): NodeListOf<Element> {
248
+ if (!this.drawerElement) return document.querySelectorAll('none');
249
+
250
+ return this.drawerElement.querySelectorAll(
251
+ 'a[href], button:not([disabled]), textarea:not([disabled]), ' +
252
+ 'input:not([disabled]), select:not([disabled]), ' +
253
+ '[tabindex]:not([tabindex="-1"])'
254
+ );
255
+ }
256
+
257
+ @dispatch('drawer-open', { bubbles: true, composed: true })
258
+ private dispatchOpenEvent() {
259
+ return { drawer: this };
260
+ }
261
+
262
+ @dispatch('drawer-close', { bubbles: true, composed: true })
263
+ private dispatchCloseEvent() {
264
+ return { drawer: this };
265
+ }
266
+
267
+ @dispose()
268
+ cleanup() {
269
+ if (this.boundHandleEscape) {
270
+ document.removeEventListener('keydown', this.boundHandleEscape);
271
+ }
272
+ document.body.style.overflow = '';
273
+ }
274
+
275
+ // Public API
276
+ show() {
277
+ this.open = true;
278
+ }
279
+
280
+ hide() {
281
+ this.open = false;
282
+ }
283
+
284
+ toggle() {
285
+ this.open = !this.open;
286
+ }
287
+ }
@@ -0,0 +1,17 @@
1
+ export type DrawerPosition = 'left' | 'right' | 'top' | 'bottom';
2
+ export type DrawerSize = 'small' | 'medium' | 'large' | 'xl' | 'xxl' | 'xxxl' | 'full';
3
+
4
+ export interface SniceDrawerElement extends HTMLElement {
5
+ open: boolean;
6
+ position: DrawerPosition;
7
+ size: DrawerSize;
8
+ noBackdrop: boolean;
9
+ noBackdropDismiss: boolean;
10
+ noEscapeDismiss: boolean;
11
+ noFocusTrap: boolean;
12
+ persistent: boolean;
13
+ pushContent: boolean;
14
+ show(): void;
15
+ hide(): void;
16
+ toggle(): void;
17
+ }
@@ -0,0 +1,14 @@
1
+ declare module '*.css' {
2
+ const content: string;
3
+ export default content;
4
+ }
5
+
6
+ declare module '*.css?inline' {
7
+ const content: string;
8
+ export default content;
9
+ }
10
+
11
+ declare module '*.html' {
12
+ const content: string;
13
+ export default content;
14
+ }
@@ -0,0 +1,303 @@
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>Input Demo</title>
7
+ <link rel="stylesheet" href="../theme/theme.css">
8
+ <style>
9
+ body {
10
+ padding: 40px;
11
+ font-family: var(--snice-font-family);
12
+ background: var(--snice-color-background);
13
+ color: var(--snice-color-text);
14
+ max-width: 800px;
15
+ margin: 0 auto;
16
+ }
17
+
18
+ .section {
19
+ margin-bottom: 40px;
20
+ }
21
+
22
+ h2 {
23
+ color: var(--snice-color-text);
24
+ margin-bottom: 20px;
25
+ font-size: var(--snice-font-size-2xl);
26
+ }
27
+
28
+ h3 {
29
+ color: var(--snice-color-text-secondary);
30
+ margin-bottom: 16px;
31
+ font-size: var(--snice-font-size-lg);
32
+ }
33
+
34
+ .input-group {
35
+ display: flex;
36
+ flex-direction: column;
37
+ gap: 20px;
38
+ margin-bottom: 20px;
39
+ }
40
+
41
+ .row {
42
+ display: flex;
43
+ gap: 20px;
44
+ align-items: flex-start;
45
+ }
46
+
47
+ .row > * {
48
+ flex: 1;
49
+ }
50
+
51
+ .output {
52
+ padding: 10px;
53
+ background: var(--snice-color-background-secondary);
54
+ border-radius: var(--snice-border-radius-md);
55
+ font-family: monospace;
56
+ font-size: var(--snice-font-size-sm);
57
+ margin-top: 10px;
58
+ }
59
+ </style>
60
+ </head>
61
+ <body>
62
+ <h2>Input Component Demo</h2>
63
+
64
+ <div class="section">
65
+ <h3>Basic Inputs</h3>
66
+ <div class="input-group">
67
+ <snice-input placeholder="Enter text..." label="Default Input"></snice-input>
68
+ <snice-input value="Pre-filled value" label="With Value"></snice-input>
69
+ <snice-input placeholder="Required field" label="Required Input" required></snice-input>
70
+ <snice-input placeholder="Disabled input" label="Disabled" disabled value="Can't edit this"></snice-input>
71
+ <snice-input placeholder="Read-only input" label="Read Only" readonly value="Read only value"></snice-input>
72
+ </div>
73
+ </div>
74
+
75
+ <div class="section">
76
+ <h3>Input Types</h3>
77
+ <div class="input-group">
78
+ <snice-input type="email" placeholder="email@example.com" label="Email" helper-text="Enter a valid email address"></snice-input>
79
+ <snice-input type="password" placeholder="Enter password" label="Password" password helper-text="Click the eye icon to toggle visibility"></snice-input>
80
+ <snice-input type="number" placeholder="0" label="Number" min="0" max="100" step="5" helper-text="Min: 0, Max: 100, Step: 5"></snice-input>
81
+ <snice-input type="tel" placeholder="+1 (555) 000-0000" label="Phone"></snice-input>
82
+ <snice-input type="url" placeholder="https://example.com" label="URL"></snice-input>
83
+ <snice-input type="search" placeholder="Search..." label="Search" clearable></snice-input>
84
+ <snice-input type="date" label="Date"></snice-input>
85
+ <snice-input type="time" label="Time"></snice-input>
86
+ </div>
87
+ </div>
88
+
89
+ <div class="section">
90
+ <h3>Sizes</h3>
91
+ <div class="input-group">
92
+ <snice-input size="small" placeholder="Small input" label="Small"></snice-input>
93
+ <snice-input size="medium" placeholder="Medium input" label="Medium (Default)"></snice-input>
94
+ <snice-input size="large" placeholder="Large input" label="Large"></snice-input>
95
+ </div>
96
+ </div>
97
+
98
+ <div class="section">
99
+ <h3>Variants</h3>
100
+ <div class="input-group">
101
+ <snice-input variant="outlined" placeholder="Outlined variant" label="Outlined (Default)"></snice-input>
102
+ <snice-input variant="filled" placeholder="Filled variant" label="Filled"></snice-input>
103
+ <snice-input variant="underlined" placeholder="Underlined variant" label="Underlined"></snice-input>
104
+ </div>
105
+ </div>
106
+
107
+ <div class="section">
108
+ <h3>With Icons</h3>
109
+ <div class="input-group">
110
+ <snice-input
111
+ placeholder="Search..."
112
+ label="With Prefix Icon"
113
+ prefix-icon="🔍">
114
+ </snice-input>
115
+ <snice-input
116
+ placeholder="Enter amount"
117
+ label="With Suffix Icon"
118
+ suffix-icon="💵">
119
+ </snice-input>
120
+ <snice-input
121
+ placeholder="Email address"
122
+ label="With Both Icons"
123
+ prefix-icon="📧"
124
+ suffix-icon="✓">
125
+ </snice-input>
126
+ </div>
127
+ </div>
128
+
129
+ <div class="section">
130
+ <h3>Clearable Inputs</h3>
131
+ <div class="input-group">
132
+ <snice-input
133
+ clearable
134
+ value="Clear me!"
135
+ label="Clearable Input"
136
+ helper-text="Hover to see clear button">
137
+ </snice-input>
138
+ <snice-input
139
+ clearable
140
+ value="With suffix icon"
141
+ label="Clearable with Icon"
142
+ suffix-icon="📝">
143
+ </snice-input>
144
+ </div>
145
+ </div>
146
+
147
+ <div class="section">
148
+ <h3>Validation States</h3>
149
+ <div class="input-group">
150
+ <snice-input
151
+ placeholder="Enter email"
152
+ label="Valid State"
153
+ helper-text="This looks good!">
154
+ </snice-input>
155
+ <snice-input
156
+ invalid
157
+ value="invalid@"
158
+ label="Invalid State"
159
+ error-text="Please enter a valid email address">
160
+ </snice-input>
161
+ <snice-input
162
+ type="email"
163
+ required
164
+ placeholder="email@example.com"
165
+ label="With Pattern Validation"
166
+ pattern="[a-z0-9._%+-]+@[a-z0-9.-]+\.[a-z]{2,}$"
167
+ helper-text="Must be a valid email format">
168
+ </snice-input>
169
+ </div>
170
+ </div>
171
+
172
+ <div class="section">
173
+ <h3>Text Length Constraints</h3>
174
+ <div class="input-group">
175
+ <snice-input
176
+ maxlength="10"
177
+ placeholder="Max 10 chars"
178
+ label="Max Length"
179
+ helper-text="Maximum 10 characters allowed">
180
+ </snice-input>
181
+ <snice-input
182
+ minlength="5"
183
+ placeholder="Min 5 chars"
184
+ label="Min Length"
185
+ helper-text="Minimum 5 characters required">
186
+ </snice-input>
187
+ </div>
188
+ </div>
189
+
190
+ <div class="section">
191
+ <h3>Interactive Example</h3>
192
+ <div class="input-group">
193
+ <snice-input
194
+ id="interactive-input"
195
+ clearable
196
+ placeholder="Type something..."
197
+ label="Interactive Input"
198
+ helper-text="Events will be logged below">
199
+ </snice-input>
200
+ <div id="output" class="output">
201
+ <div>Waiting for input...</div>
202
+ </div>
203
+ </div>
204
+ </div>
205
+
206
+ <div class="section">
207
+ <h3>Form Example</h3>
208
+ <form id="demo-form">
209
+ <div class="input-group">
210
+ <div class="row">
211
+ <snice-input
212
+ name="firstName"
213
+ required
214
+ placeholder="John"
215
+ label="First Name">
216
+ </snice-input>
217
+ <snice-input
218
+ name="lastName"
219
+ required
220
+ placeholder="Doe"
221
+ label="Last Name">
222
+ </snice-input>
223
+ </div>
224
+ <snice-input
225
+ type="email"
226
+ name="email"
227
+ required
228
+ placeholder="john.doe@example.com"
229
+ label="Email Address">
230
+ </snice-input>
231
+ <snice-input
232
+ type="password"
233
+ name="password"
234
+ required
235
+ password
236
+ minlength="8"
237
+ placeholder="Min 8 characters"
238
+ label="Password">
239
+ </snice-input>
240
+ <snice-input
241
+ type="tel"
242
+ name="phone"
243
+ placeholder="+1 (555) 000-0000"
244
+ label="Phone (Optional)">
245
+ </snice-input>
246
+ <button type="submit" style="
247
+ padding: 10px 20px;
248
+ background: var(--snice-color-primary);
249
+ color: white;
250
+ border: none;
251
+ border-radius: var(--snice-border-radius-md);
252
+ cursor: pointer;
253
+ font-size: var(--snice-font-size-md);
254
+ ">Submit Form</button>
255
+ </div>
256
+ </form>
257
+ </div>
258
+
259
+ <script type="module">
260
+ import './snice-input.ts';
261
+
262
+ // Interactive example
263
+ const input = document.getElementById('interactive-input');
264
+ const output = document.getElementById('output');
265
+
266
+ let eventLog = [];
267
+
268
+ function logEvent(type, detail) {
269
+ eventLog.unshift(`${type}: ${JSON.stringify(detail)}`);
270
+ eventLog = eventLog.slice(0, 5);
271
+ output.innerHTML = eventLog.map(log => `<div>${log}</div>`).join('');
272
+ }
273
+
274
+ input.addEventListener('@snice/input-input', (e) => {
275
+ logEvent('input', { value: e.detail.value });
276
+ });
277
+
278
+ input.addEventListener('@snice/input-change', (e) => {
279
+ logEvent('change', { value: e.detail.value });
280
+ });
281
+
282
+ input.addEventListener('@snice/input-focus', () => {
283
+ logEvent('focus', {});
284
+ });
285
+
286
+ input.addEventListener('@snice/input-blur', () => {
287
+ logEvent('blur', {});
288
+ });
289
+
290
+ input.addEventListener('@snice/input-clear', () => {
291
+ logEvent('clear', {});
292
+ });
293
+
294
+ // Form example
295
+ document.getElementById('demo-form').addEventListener('submit', (e) => {
296
+ e.preventDefault();
297
+ const formData = new FormData(e.target);
298
+ const data = Object.fromEntries(formData);
299
+ alert('Form submitted with: ' + JSON.stringify(data, null, 2));
300
+ });
301
+ </script>
302
+ </body>
303
+ </html>