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,480 @@
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 Table Demo</title>
7
+ <link rel="stylesheet" href="../theme/theme.css">
8
+ <style>
9
+ body {
10
+ font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
11
+ margin: 0;
12
+ padding: 2rem;
13
+ background: var(--snice-color-background-secondary);
14
+ }
15
+
16
+ .demo-container {
17
+ max-width: 1200px;
18
+ margin: 0 auto;
19
+ border-radius: 0.5rem;
20
+ padding: 2rem;
21
+ }
22
+
23
+ h1 {
24
+ color: #333;
25
+ margin-bottom: 2rem;
26
+ }
27
+
28
+ .demo-section {
29
+ margin-bottom: 3rem;
30
+ }
31
+
32
+ .demo-section h2 {
33
+ color: #555;
34
+ border-bottom: 2px solid #e9ecef;
35
+ padding-bottom: 0.5rem;
36
+ margin-bottom: 1.5rem;
37
+ }
38
+
39
+ .demo-controls {
40
+ margin-bottom: 1rem;
41
+ display: flex;
42
+ gap: 1rem;
43
+ flex-wrap: wrap;
44
+ }
45
+
46
+ .demo-controls button {
47
+ padding: 0.5rem 1rem;
48
+ border: 1px solid #007bff;
49
+ background: #007bff;
50
+ color: white;
51
+ border-radius: 0.25rem;
52
+ cursor: pointer;
53
+ font-size: 0.875rem;
54
+ }
55
+
56
+ .demo-controls button:hover {
57
+ background: #0056b3;
58
+ }
59
+
60
+ .demo-controls button.secondary {
61
+ background: white;
62
+ color: #007bff;
63
+ }
64
+
65
+ .demo-controls button.secondary:hover {
66
+ background: #f8f9fa;
67
+ }
68
+ </style>
69
+ </head>
70
+ <body>
71
+ <div class="demo-container">
72
+ <h1>🗂️ Snice Table Component Demo</h1>
73
+
74
+ <div class="demo-section">
75
+ <h2>Basic Table with Declarative Columns</h2>
76
+ <div class="demo-controls">
77
+ <button onclick="toggleSearch()">Toggle Search</button>
78
+ <button onclick="togglePagination()">Toggle Pagination</button>
79
+ <button onclick="toggleSorting()">Toggle Sorting</button>
80
+ <button onclick="toggleSelection()">Toggle Selection</button>
81
+ <button class="secondary" onclick="addRandomRow()">Add Random Row</button>
82
+ <button class="secondary" onclick="loadSampleData()">Load Sample Data</button>
83
+ </div>
84
+
85
+ <snice-table
86
+ id="demo-table"
87
+ searchable
88
+ sortable
89
+ selectable
90
+ controller="demo-table-controller">
91
+ </snice-table>
92
+ </div>
93
+
94
+ <div class="demo-section">
95
+ <h2>Advanced Table with Sparklines and Progress</h2>
96
+
97
+ <snice-table
98
+ id="analytics-table"
99
+ size="medium"
100
+ hoverable
101
+ sortable
102
+ striped>
103
+
104
+ <snice-column
105
+ slot="columns"
106
+ key="metric"
107
+ label="Metric"
108
+ type="text">
109
+ </snice-column>
110
+
111
+ <snice-column
112
+ slot="columns"
113
+ key="value"
114
+ label="Current Value"
115
+ type="number"
116
+ decimals="1"
117
+ thousands-separator="true">
118
+ </snice-column>
119
+
120
+ <snice-column
121
+ slot="columns"
122
+ key="progress"
123
+ label="Progress"
124
+ type="progress"
125
+ progress-max="100"
126
+ show-percentage="true">
127
+ </snice-column>
128
+
129
+ <snice-column
130
+ slot="columns"
131
+ key="trend"
132
+ label="Trend (7 days)"
133
+ type="sparkline"
134
+ sparkline-type="line"
135
+ sparkline-color="#007bff"
136
+ sparkline-width="80"
137
+ sparkline-height="30">
138
+ </snice-column>
139
+
140
+ <snice-row slot="rows"
141
+ data-metric="Revenue"
142
+ data-value="125340"
143
+ data-progress="78"
144
+ data-trend="[45000, 47000, 49000, 52000, 48000, 53000, 55000]">
145
+ </snice-row>
146
+ <snice-row slot="rows"
147
+ data-metric="Users"
148
+ data-value="8250"
149
+ data-progress="92"
150
+ data-trend="[7800, 7950, 8100, 8200, 8150, 8300, 8250]">
151
+ </snice-row>
152
+ <snice-row slot="rows"
153
+ data-metric="Conversion"
154
+ data-value="3.4"
155
+ data-progress="68"
156
+ data-trend="[3.1, 3.2, 3.3, 3.5, 3.3, 3.4, 3.4]">
157
+ </snice-row>
158
+ <snice-row slot="rows"
159
+ data-metric="Retention"
160
+ data-value="89.2"
161
+ data-progress="89"
162
+ data-trend="[87, 88, 89, 90, 89, 88, 89]">
163
+ </snice-row>
164
+ </snice-table>
165
+ </div>
166
+
167
+ <div class="demo-section">
168
+ <h2>Individual Cell Components</h2>
169
+
170
+ <div style="display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; margin-bottom: 2rem;">
171
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
172
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Text Cell</h3>
173
+ <snice-cell-text value="Hello World"></snice-cell-text>
174
+ </div>
175
+
176
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
177
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Number Cell (Basic)</h3>
178
+ <snice-cell-number value="1234.56" thousands-separator="true" decimals="2"></snice-cell-number>
179
+ </div>
180
+
181
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
182
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Number Cell (Currency)</h3>
183
+ <snice-cell-number value="1234.56" prefix="$" thousands-separator="true" decimals="2"></snice-cell-number>
184
+ </div>
185
+
186
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
187
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Number Cell (Negative)</h3>
188
+ <snice-cell-number value="-456.78" negative-style="parentheses" thousands-separator="true" decimals="2"></snice-cell-number>
189
+ </div>
190
+
191
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
192
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Date Cell (Short)</h3>
193
+ <snice-cell-date value="2023-12-25" date-format="short"></snice-cell-date>
194
+ </div>
195
+
196
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
197
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Date Cell (Long)</h3>
198
+ <snice-cell-date value="2023-12-25" date-format="long"></snice-cell-date>
199
+ </div>
200
+
201
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
202
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Date Cell (Custom)</h3>
203
+ <snice-cell-date value="2023-12-25" date-format="custom" custom-format="DD/MM/YYYY"></snice-cell-date>
204
+ </div>
205
+
206
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
207
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Sparkline (Line)</h3>
208
+ <snice-cell-sparkline data="10,20,15,25,30,18,22" chart-type="line" width="80" height="30" color="#3b82f6"></snice-cell-sparkline>
209
+ </div>
210
+
211
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
212
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Sparkline (Bar)</h3>
213
+ <snice-cell-sparkline data="10,20,15,25,30,18,22" chart-type="bar" width="80" height="30" color="#10b981"></snice-cell-sparkline>
214
+ </div>
215
+
216
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
217
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Sparkline (Area)</h3>
218
+ <snice-cell-sparkline data="10,20,15,25,30,18,22" chart-type="area" width="80" height="30" color="#f59e0b"></snice-cell-sparkline>
219
+ </div>
220
+
221
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
222
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Boolean (Symbols)</h3>
223
+ <snice-cell-boolean value="true" use-symbols="true" true-symbol="✅" false-symbol="❌"></snice-cell-boolean>
224
+ </div>
225
+
226
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
227
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Boolean (Text)</h3>
228
+ <snice-cell-boolean value="false" use-symbols="false" true-value="Yes" false-value="No"></snice-cell-boolean>
229
+ </div>
230
+
231
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
232
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Rating (4/5 Stars)</h3>
233
+ <snice-cell-rating value="4"></snice-cell-rating>
234
+ </div>
235
+
236
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
237
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Rating (3/10 Custom)</h3>
238
+ <snice-cell-rating value="3"></snice-cell-rating>
239
+ </div>
240
+
241
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
242
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Progress (75%)</h3>
243
+ <snice-cell-progress value="75"></snice-cell-progress>
244
+ </div>
245
+
246
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
247
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Progress w/ %</h3>
248
+ <snice-cell-progress id="progress-with-percent" value="45"></snice-cell-progress>
249
+ </div>
250
+
251
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
252
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Duration (1h 1m 1s)</h3>
253
+ <snice-cell-duration value="3661"></snice-cell-duration>
254
+ </div>
255
+
256
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
257
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">Duration (5m 30s)</h3>
258
+ <snice-cell-duration value="330"></snice-cell-duration>
259
+ </div>
260
+
261
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
262
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">FileSize (2.0 MB)</h3>
263
+ <snice-cell-filesize value="2048576"></snice-cell-filesize>
264
+ </div>
265
+
266
+ <div style="padding: 1rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;">
267
+ <h3 style="margin-top: 0; font-size: 0.875rem; color: #666;">FileSize (1.5 GB)</h3>
268
+ <snice-cell-filesize value="1610612736"></snice-cell-filesize>
269
+ </div>
270
+ </div>
271
+ </div>
272
+
273
+ <div class="demo-section">
274
+ <h2>Individual Row Components</h2>
275
+
276
+ <div style="margin-bottom: 1rem;">
277
+ <h3 style="font-size: 1rem; color: #666; margin-bottom: 0.5rem;">Employee Row (Text, Number, Date, Boolean)</h3>
278
+ <snice-row id="employee-row" style="display: block; padding: 0.5rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;"></snice-row>
279
+ </div>
280
+
281
+ <div style="margin-bottom: 1rem;">
282
+ <h3 style="font-size: 1rem; color: #666; margin-bottom: 0.5rem;">Analytics Row (Text, Numbers, Progress, Sparkline)</h3>
283
+ <snice-row id="analytics-row" style="display: block; padding: 0.5rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;"></snice-row>
284
+ </div>
285
+
286
+ <div style="margin-bottom: 1rem;">
287
+ <h3 style="font-size: 1rem; color: #666; margin-bottom: 0.5rem;">System Row (Text, FileSize, Duration, Rating)</h3>
288
+ <snice-row id="system-row" style="display: block; padding: 0.5rem; border: 1px solid #e9ecef; border-radius: 0.5rem; background: #f8f9fa;"></snice-row>
289
+ </div>
290
+ </div>
291
+ </div>
292
+
293
+ <script type="module">
294
+ // Import controller first to register it
295
+ import './demo-table-controller.ts';
296
+ // Then import the table component
297
+ import './snice-table.ts';
298
+
299
+ const table = document.getElementById('demo-table');
300
+
301
+ // Demo functions
302
+ window.toggleSearch = () => {
303
+ table.showSearch = !table.showSearch;
304
+ };
305
+
306
+ window.togglePagination = () => {
307
+ table.showPagination = !table.showPagination;
308
+ };
309
+
310
+ window.toggleSorting = () => {
311
+ table.sortable = !table.sortable;
312
+ };
313
+
314
+ window.toggleSelection = () => {
315
+ table.selectable = !table.selectable;
316
+ };
317
+
318
+ window.addRandomRow = () => {
319
+ const names = ['Mike Davis', 'Sarah Connor', 'Tom Brady', 'Lisa Simpson', 'Jack Ryan'];
320
+ const roles = ['Developer', 'Designer', 'Manager', 'QA Engineer', 'DevOps'];
321
+ const domains = ['tech.com', 'design.io', 'startup.co', 'corp.net'];
322
+
323
+ const randomName = names[Math.floor(Math.random() * names.length)];
324
+ const randomRole = roles[Math.floor(Math.random() * roles.length)];
325
+ const randomDomain = domains[Math.floor(Math.random() * domains.length)];
326
+ const randomEmail = `${randomName.toLowerCase().replace(' ', '.')}@${randomDomain}`;
327
+ const randomSalary = Math.floor(Math.random() * 50000) + 50000;
328
+ const randomRating = Math.floor(Math.random() * 5) + 1;
329
+
330
+ const newData = {
331
+ id: Date.now(),
332
+ name: randomName,
333
+ email: randomEmail,
334
+ role: randomRole,
335
+ salary: randomSalary,
336
+ joinDate: new Date().toISOString().split('T')[0],
337
+ active: Math.random() > 0.2,
338
+ rating: randomRating
339
+ };
340
+
341
+ // Add to table data
342
+ const currentData = table.data || [];
343
+ table.setData([...currentData, newData]);
344
+ };
345
+
346
+ window.loadSampleData = () => {
347
+ const sampleData = [
348
+ {"id": 1, "name": "John Doe", "email": "john.doe@example.com", "role": "Developer", "salary": 75000, "joinDate": "2023-01-15", "active": true, "rating": 4},
349
+ {"id": 2, "name": "Jane Smith", "email": "jane.smith@example.com", "role": "Designer", "salary": 68000, "joinDate": "2023-03-20", "active": true, "rating": 5},
350
+ {"id": 3, "name": "Bob Johnson", "email": "bob.johnson@example.com", "role": "Manager", "salary": 95000, "joinDate": "2022-11-10", "active": false, "rating": 3},
351
+ {"id": 4, "name": "Alice Brown", "email": "alice.brown@example.com", "role": "Developer", "salary": 72000, "joinDate": "2023-06-05", "active": true, "rating": 4},
352
+ {"id": 5, "name": "Charlie Wilson", "email": "charlie.wilson@example.com", "role": "QA Engineer", "salary": 65000, "joinDate": "2023-02-28", "active": true, "rating": 4},
353
+ {"id": 6, "name": "Diana Prince", "email": "diana.prince@example.com", "role": "Developer", "salary": 78000, "joinDate": "2023-04-12", "active": true, "rating": 5},
354
+ {"id": 7, "name": "Clark Kent", "email": "clark.kent@example.com", "role": "Manager", "salary": 92000, "joinDate": "2022-08-22", "active": true, "rating": 4},
355
+ {"id": 8, "name": "Bruce Wayne", "email": "bruce.wayne@example.com", "role": "CEO", "salary": 150000, "joinDate": "2020-01-01", "active": true, "rating": 5}
356
+ ];
357
+
358
+ table.setData(sampleData);
359
+ table.totalItems = sampleData.length;
360
+ };
361
+
362
+ // Event listeners
363
+ table.addEventListener('@snice/table-sort-change', (e) => {
364
+ console.log('Sort changed:', e.detail);
365
+ });
366
+
367
+ table.addEventListener('@snice/table-selection-change', (e) => {
368
+ console.log('Selection changed:', e.detail);
369
+ });
370
+
371
+ table.addEventListener('@snice/row-click', (e) => {
372
+ console.log('Row clicked:', e.detail);
373
+ });
374
+
375
+ // Configure individual row components
376
+ const configureIndividualRows = async () => {
377
+ // Wait for components to be defined
378
+ await Promise.all([
379
+ customElements.whenDefined('snice-row'),
380
+ customElements.whenDefined('snice-cell-text'),
381
+ customElements.whenDefined('snice-cell-number'),
382
+ customElements.whenDefined('snice-cell-date'),
383
+ customElements.whenDefined('snice-cell-sparkline')
384
+ ]);
385
+
386
+ // Configure employee row
387
+ const employeeRow = document.getElementById('employee-row');
388
+ if (employeeRow) {
389
+ employeeRow.columns = [
390
+ { key: 'name', label: 'Name', type: 'text', align: 'left' },
391
+ { key: 'salary', label: 'Salary', type: 'number', align: 'right', numberFormat: { prefix: '$', thousandsSeparator: true, decimals: 0 } },
392
+ { key: 'joinDate', label: 'Join Date', type: 'date', align: 'center', dateFormat: { format: 'medium' } },
393
+ { key: 'active', label: 'Active', type: 'boolean', align: 'center', booleanFormat: { useSymbols: true, trueSymbol: '✅', falseSymbol: '❌' } }
394
+ ];
395
+ employeeRow.data = {
396
+ name: 'John Doe',
397
+ salary: 75000,
398
+ joinDate: '2022-03-15',
399
+ active: true
400
+ };
401
+ // Trigger update manually
402
+ if (typeof employeeRow.updateCells === 'function') {
403
+ employeeRow.updateCells();
404
+ }
405
+ }
406
+
407
+ // Configure analytics row
408
+ const analyticsRow = document.getElementById('analytics-row');
409
+ if (analyticsRow) {
410
+ analyticsRow.columns = [
411
+ { key: 'metric', label: 'Metric', type: 'text', align: 'left' },
412
+ { key: 'current', label: 'Current', type: 'number', align: 'right', numberFormat: { prefix: '$', thousandsSeparator: true, decimals: 0 } },
413
+ { key: 'progress', label: 'Progress', type: 'progress', align: 'left', progressFormat: { showPercentage: true, color: '#10b981' } },
414
+ { key: 'trend', label: 'Trend', type: 'sparkline', align: 'center', sparklineFormat: { type: 'line', color: '#3b82f6', width: 80, height: 30 } }
415
+ ];
416
+ analyticsRow.data = {
417
+ metric: 'Revenue',
418
+ current: 125340,
419
+ progress: 78,
420
+ trend: [45000, 47000, 49000, 52000, 48000, 53000, 55000]
421
+ };
422
+ // Trigger update manually
423
+ if (typeof analyticsRow.updateCells === 'function') {
424
+ analyticsRow.updateCells();
425
+ }
426
+ }
427
+
428
+ // Configure system row
429
+ const systemRow = document.getElementById('system-row');
430
+ if (systemRow) {
431
+ systemRow.columns = [
432
+ { key: 'process', label: 'Process', type: 'text', align: 'left' },
433
+ { key: 'memory', label: 'Memory', type: 'filesize', align: 'right' },
434
+ { key: 'uptime', label: 'Uptime', type: 'duration', align: 'right' },
435
+ { key: 'rating', label: 'Health', type: 'rating', align: 'center', ratingFormat: { max: 5, symbol: '●', emptySymbol: '○', color: '#10b981' } }
436
+ ];
437
+ systemRow.data = {
438
+ process: 'nginx',
439
+ memory: 52428800, // 50MB
440
+ uptime: 86461, // 1 day 1 minute 1 second
441
+ rating: 4
442
+ };
443
+ // Trigger update manually
444
+ if (typeof systemRow.updateCells === 'function') {
445
+ systemRow.updateCells();
446
+ }
447
+ }
448
+ };
449
+
450
+ // Initialize individual rows
451
+ configureIndividualRows();
452
+
453
+ // Configure individual progress cell with percentage
454
+ const configureProgressCells = async () => {
455
+ await customElements.whenDefined('snice-cell-progress');
456
+
457
+ const progressWithPercent = document.getElementById('progress-with-percent');
458
+ if (progressWithPercent) {
459
+ progressWithPercent.column = {
460
+ key: 'progress',
461
+ label: 'Progress',
462
+ type: 'progress',
463
+ align: 'left',
464
+ progressFormat: {
465
+ showPercentage: true,
466
+ color: '#10b981'
467
+ }
468
+ };
469
+ }
470
+ };
471
+
472
+ configureProgressCells();
473
+
474
+ // Uncomment to load sample data programmatically:
475
+ // setTimeout(() => {
476
+ // window.loadSampleData();
477
+ // }, 100);
478
+ </script>
479
+ </body>
480
+ </html>
@@ -0,0 +1,112 @@
1
+ import { element, property, watch, ready, query } from 'snice';
2
+ import css from './snice-cell.css?inline';
3
+ import type { BooleanFormat, SniceCellElement, ColumnType, ColumnAlign, ColumnDefinition } from './snice-table.types';
4
+
5
+ @element('snice-cell-boolean')
6
+ export class SniceCellBoolean extends HTMLElement implements SniceCellElement {
7
+ @property({ reflect: true })
8
+ align: ColumnAlign = 'center';
9
+
10
+ @property({ reflect: true })
11
+ type: ColumnType = 'boolean';
12
+
13
+ @property({ reflect: true })
14
+ value: any = false;
15
+
16
+ @property({ type: Object })
17
+ column: ColumnDefinition = {
18
+ key: '',
19
+ label: '',
20
+ type: 'boolean',
21
+ align: 'center'
22
+ };
23
+
24
+ @property({ type: Object })
25
+ rowData: any = null;
26
+
27
+ @query('.cell-content')
28
+ contentElement?: HTMLElement;
29
+
30
+ @property({ reflect: true, attribute: 'true-value' })
31
+ trueValue: string = 'true';
32
+
33
+ @property({ reflect: true, attribute: 'false-value' })
34
+ falseValue: string = 'false';
35
+
36
+ @property({ type: Boolean, reflect: true, attribute: 'use-symbols' })
37
+ useSymbols: boolean = true;
38
+
39
+ @property({ reflect: true, attribute: 'true-symbol' })
40
+ trueSymbol: string = '✓';
41
+
42
+ @property({ reflect: true, attribute: 'false-symbol' })
43
+ falseSymbol: string = '✗';
44
+
45
+ html() {
46
+ const content = this.formatBooleanContent();
47
+
48
+ return `
49
+ <div class="cell-content cell-content--boolean" part="content">
50
+ ${content}
51
+ </div>
52
+ `;
53
+ }
54
+
55
+ css() {
56
+ return css;
57
+ }
58
+
59
+ @ready()
60
+ init() {
61
+ this.applyAlignment();
62
+ }
63
+
64
+ private applyAlignment() {
65
+ this.style.textAlign = this.align;
66
+ }
67
+
68
+ @watch('align')
69
+ updateAlignment() {
70
+ this.applyAlignment();
71
+ }
72
+
73
+ @watch('value', 'column')
74
+ updateContent() {
75
+ if (this.contentElement) {
76
+ const content = this.formatBooleanContent();
77
+ this.contentElement.innerHTML = content;
78
+ }
79
+ }
80
+
81
+ private formatBooleanContent(): string {
82
+ if (this.value === null || this.value === undefined) {
83
+ return '';
84
+ }
85
+
86
+ // Use custom formatter if provided
87
+ if (this.column.formatter) {
88
+ return this.column.formatter(this.value, this.rowData);
89
+ }
90
+
91
+ // Use column boolean format or component properties
92
+ const format: BooleanFormat = this.column.booleanFormat || {
93
+ trueValue: this.trueValue,
94
+ falseValue: this.falseValue,
95
+ useSymbols: this.useSymbols,
96
+ trueSymbol: this.trueSymbol,
97
+ falseSymbol: this.falseSymbol
98
+ };
99
+
100
+ const isTrue = Boolean(this.value);
101
+
102
+ if (format.useSymbols ?? this.useSymbols) {
103
+ const symbol = isTrue ? (format.trueSymbol ?? this.trueSymbol) : (format.falseSymbol ?? this.falseSymbol);
104
+ const colorClass = isTrue ? 'boolean--true' : 'boolean--false';
105
+ return `<span class="${colorClass}">${symbol}</span>`;
106
+ } else {
107
+ const text = isTrue ? (format.trueValue ?? this.trueValue) : (format.falseValue ?? this.falseValue);
108
+ const colorClass = isTrue ? 'boolean--true' : 'boolean--false';
109
+ return `<span class="${colorClass}">${text}</span>`;
110
+ }
111
+ }
112
+ }