@latty-ds/web 0.2.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 (228) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +106 -0
  3. package/custom-elements.json +8785 -0
  4. package/dist/base/index.d.ts +1 -0
  5. package/dist/base/index.js +35 -0
  6. package/dist/base/themeable-element.d.ts +20 -0
  7. package/dist/components/accordion/accordion.d.ts +82 -0
  8. package/dist/components/accordion/accordion.styles.d.ts +1 -0
  9. package/dist/components/accordion/accordion.types.d.ts +10 -0
  10. package/dist/components/accordion/index.d.ts +8 -0
  11. package/dist/components/accordion/index.js +468 -0
  12. package/dist/components/alert/alert.d.ts +51 -0
  13. package/dist/components/alert/alert.styles.d.ts +1 -0
  14. package/dist/components/alert/alert.types.d.ts +2 -0
  15. package/dist/components/alert/index.d.ts +2 -0
  16. package/dist/components/alert/index.js +746 -0
  17. package/dist/components/avatar/avatar.d.ts +27 -0
  18. package/dist/components/avatar/avatar.styles.d.ts +1 -0
  19. package/dist/components/avatar/avatar.types.d.ts +3 -0
  20. package/dist/components/avatar/index.d.ts +2 -0
  21. package/dist/components/avatar/index.js +222 -0
  22. package/dist/components/badge/badge.d.ts +29 -0
  23. package/dist/components/badge/badge.styles.d.ts +1 -0
  24. package/dist/components/badge/badge.types.d.ts +3 -0
  25. package/dist/components/badge/index.d.ts +2 -0
  26. package/dist/components/badge/index.js +277 -0
  27. package/dist/components/breadcrumb/breadcrumb.d.ts +53 -0
  28. package/dist/components/breadcrumb/breadcrumb.styles.d.ts +2 -0
  29. package/dist/components/breadcrumb/breadcrumb.types.d.ts +1 -0
  30. package/dist/components/breadcrumb/index.d.ts +2 -0
  31. package/dist/components/breadcrumb/index.js +166 -0
  32. package/dist/components/button/button.d.ts +111 -0
  33. package/dist/components/button/button.styles.d.ts +1 -0
  34. package/dist/components/button/button.types.d.ts +38 -0
  35. package/dist/components/button/index.d.ts +8 -0
  36. package/dist/components/button/index.js +466 -0
  37. package/dist/components/calendar/calendar.d.ts +84 -0
  38. package/dist/components/calendar/calendar.styles.d.ts +1 -0
  39. package/dist/components/calendar/calendar.types.d.ts +15 -0
  40. package/dist/components/calendar/index.d.ts +1 -0
  41. package/dist/components/calendar/index.js +958 -0
  42. package/dist/components/checkbox/checkbox.d.ts +113 -0
  43. package/dist/components/checkbox/checkbox.styles.d.ts +1 -0
  44. package/dist/components/checkbox/checkbox.types.d.ts +21 -0
  45. package/dist/components/checkbox/index.d.ts +8 -0
  46. package/dist/components/checkbox/index.js +320 -0
  47. package/dist/components/chip/chip.d.ts +35 -0
  48. package/dist/components/chip/chip.styles.d.ts +1 -0
  49. package/dist/components/chip/chip.types.d.ts +3 -0
  50. package/dist/components/chip/index.d.ts +2 -0
  51. package/dist/components/chip/index.js +282 -0
  52. package/dist/components/color-input/color-input.d.ts +55 -0
  53. package/dist/components/color-input/color-input.styles.d.ts +1 -0
  54. package/dist/components/color-input/color-input.types.d.ts +2 -0
  55. package/dist/components/color-input/index.d.ts +1 -0
  56. package/dist/components/color-input/index.js +489 -0
  57. package/dist/components/combobox/combobox.d.ts +59 -0
  58. package/dist/components/combobox/combobox.styles.d.ts +1 -0
  59. package/dist/components/combobox/combobox.types.d.ts +7 -0
  60. package/dist/components/combobox/index.d.ts +2 -0
  61. package/dist/components/combobox/index.js +1988 -0
  62. package/dist/components/date-input/date-input.d.ts +66 -0
  63. package/dist/components/date-input/date-input.styles.d.ts +1 -0
  64. package/dist/components/date-input/date-input.types.d.ts +3 -0
  65. package/dist/components/date-input/index.d.ts +2 -0
  66. package/dist/components/date-input/index.js +2863 -0
  67. package/dist/components/datepicker/datepicker.d.ts +52 -0
  68. package/dist/components/datepicker/datepicker.styles.d.ts +1 -0
  69. package/dist/components/datepicker/datepicker.types.d.ts +3 -0
  70. package/dist/components/datepicker/index.d.ts +2 -0
  71. package/dist/components/datepicker/index.js +416 -0
  72. package/dist/components/dialog/dialog.d.ts +114 -0
  73. package/dist/components/dialog/dialog.styles.d.ts +1 -0
  74. package/dist/components/dialog/dialog.types.d.ts +11 -0
  75. package/dist/components/dialog/index.d.ts +2 -0
  76. package/dist/components/dialog/index.js +920 -0
  77. package/dist/components/divider/divider.d.ts +35 -0
  78. package/dist/components/divider/divider.styles.d.ts +1 -0
  79. package/dist/components/divider/divider.types.d.ts +2 -0
  80. package/dist/components/divider/index.d.ts +2 -0
  81. package/dist/components/divider/index.js +149 -0
  82. package/dist/components/dropdown/dropdown-item.d.ts +24 -0
  83. package/dist/components/dropdown/dropdown-item.styles.d.ts +1 -0
  84. package/dist/components/dropdown/dropdown.d.ts +30 -0
  85. package/dist/components/dropdown/dropdown.styles.d.ts +1 -0
  86. package/dist/components/dropdown/dropdown.types.d.ts +1 -0
  87. package/dist/components/dropdown/index.d.ts +3 -0
  88. package/dist/components/dropdown/index.js +1791 -0
  89. package/dist/components/header/header.d.ts +19 -0
  90. package/dist/components/header/header.styles.d.ts +1 -0
  91. package/dist/components/header/header.types.d.ts +1 -0
  92. package/dist/components/header/index.d.ts +2 -0
  93. package/dist/components/header/index.js +104 -0
  94. package/dist/components/icon-button/icon-button.d.ts +52 -0
  95. package/dist/components/icon-button/icon-button.styles.d.ts +1 -0
  96. package/dist/components/icon-button/icon-button.types.d.ts +8 -0
  97. package/dist/components/icon-button/index.d.ts +1 -0
  98. package/dist/components/icon-button/index.js +342 -0
  99. package/dist/components/image/image.d.ts +26 -0
  100. package/dist/components/image/image.styles.d.ts +1 -0
  101. package/dist/components/image/image.types.d.ts +0 -0
  102. package/dist/components/image/index.d.ts +1 -0
  103. package/dist/components/image/index.js +105 -0
  104. package/dist/components/link/index.d.ts +1 -0
  105. package/dist/components/link/index.js +108 -0
  106. package/dist/components/link/link.d.ts +22 -0
  107. package/dist/components/link/link.styles.d.ts +1 -0
  108. package/dist/components/link/link.types.d.ts +1 -0
  109. package/dist/components/list/index.d.ts +9 -0
  110. package/dist/components/list/index.js +254 -0
  111. package/dist/components/list/list-item.d.ts +41 -0
  112. package/dist/components/list/list-item.styles.d.ts +1 -0
  113. package/dist/components/list/list.d.ts +85 -0
  114. package/dist/components/list/list.styles.d.ts +1 -0
  115. package/dist/components/list/list.types.d.ts +16 -0
  116. package/dist/components/nav/index.d.ts +3 -0
  117. package/dist/components/nav/index.js +345 -0
  118. package/dist/components/nav/nav-item.d.ts +73 -0
  119. package/dist/components/nav/nav.d.ts +49 -0
  120. package/dist/components/nav/nav.styles.d.ts +2 -0
  121. package/dist/components/nav/nav.types.d.ts +1 -0
  122. package/dist/components/pagination/index.d.ts +2 -0
  123. package/dist/components/pagination/index.js +210 -0
  124. package/dist/components/pagination/pagination.d.ts +34 -0
  125. package/dist/components/pagination/pagination.styles.d.ts +1 -0
  126. package/dist/components/pagination/pagination.types.d.ts +1 -0
  127. package/dist/components/progress/index.d.ts +2 -0
  128. package/dist/components/progress/index.js +167 -0
  129. package/dist/components/progress/progress.d.ts +44 -0
  130. package/dist/components/progress/progress.styles.d.ts +1 -0
  131. package/dist/components/progress/progress.types.d.ts +2 -0
  132. package/dist/components/radio/index.d.ts +8 -0
  133. package/dist/components/radio/index.js +294 -0
  134. package/dist/components/radio/radio.d.ts +96 -0
  135. package/dist/components/radio/radio.styles.d.ts +1 -0
  136. package/dist/components/radio/radio.types.d.ts +21 -0
  137. package/dist/components/radio-group/index.d.ts +8 -0
  138. package/dist/components/radio-group/index.js +384 -0
  139. package/dist/components/radio-group/radio-group.d.ts +100 -0
  140. package/dist/components/radio-group/radio-group.styles.d.ts +1 -0
  141. package/dist/components/radio-group/radio-group.types.d.ts +8 -0
  142. package/dist/components/select/index.d.ts +8 -0
  143. package/dist/components/select/index.js +2123 -0
  144. package/dist/components/select/select.d.ts +129 -0
  145. package/dist/components/select/select.styles.d.ts +1 -0
  146. package/dist/components/select/select.types.d.ts +37 -0
  147. package/dist/components/shared/backdrop.styles.d.ts +1 -0
  148. package/dist/components/shared/floating.d.ts +10 -0
  149. package/dist/components/sidepanel/index.d.ts +1 -0
  150. package/dist/components/sidepanel/index.js +768 -0
  151. package/dist/components/sidepanel/sidepanel.d.ts +48 -0
  152. package/dist/components/sidepanel/sidepanel.styles.d.ts +1 -0
  153. package/dist/components/sidepanel/sidepanel.types.d.ts +1 -0
  154. package/dist/components/skeleton/index.d.ts +2 -0
  155. package/dist/components/skeleton/index.js +129 -0
  156. package/dist/components/skeleton/skeleton.d.ts +39 -0
  157. package/dist/components/skeleton/skeleton.styles.d.ts +1 -0
  158. package/dist/components/skeleton/skeleton.types.d.ts +1 -0
  159. package/dist/components/slider/index.d.ts +2 -0
  160. package/dist/components/slider/index.js +635 -0
  161. package/dist/components/slider/slider.d.ts +33 -0
  162. package/dist/components/slider/slider.styles.d.ts +1 -0
  163. package/dist/components/slider/slider.types.d.ts +1 -0
  164. package/dist/components/snackbar/index.d.ts +2 -0
  165. package/dist/components/snackbar/index.js +358 -0
  166. package/dist/components/snackbar/snackbar.d.ts +63 -0
  167. package/dist/components/snackbar/snackbar.styles.d.ts +1 -0
  168. package/dist/components/snackbar/snackbar.types.d.ts +1 -0
  169. package/dist/components/spinner/index.d.ts +8 -0
  170. package/dist/components/spinner/index.js +131 -0
  171. package/dist/components/spinner/spineer.styles.d.ts +1 -0
  172. package/dist/components/spinner/spinner.d.ts +52 -0
  173. package/dist/components/spinner/spinner.types.d.ts +18 -0
  174. package/dist/components/surface/index.d.ts +8 -0
  175. package/dist/components/surface/index.js +128 -0
  176. package/dist/components/surface/surface.d.ts +48 -0
  177. package/dist/components/surface/surface.styles.d.ts +1 -0
  178. package/dist/components/surface/surface.types.d.ts +20 -0
  179. package/dist/components/switch/index.d.ts +8 -0
  180. package/dist/components/switch/index.js +293 -0
  181. package/dist/components/switch/switch.d.ts +90 -0
  182. package/dist/components/switch/switch.styles.d.ts +1 -0
  183. package/dist/components/switch/switch.types.d.ts +21 -0
  184. package/dist/components/tab/index.d.ts +9 -0
  185. package/dist/components/tab/index.js +252 -0
  186. package/dist/components/tab/tab-panel.d.ts +28 -0
  187. package/dist/components/tab/tab-panel.styles.d.ts +1 -0
  188. package/dist/components/tab/tab.d.ts +59 -0
  189. package/dist/components/tab/tab.styles.d.ts +1 -0
  190. package/dist/components/tab/tab.types.d.ts +7 -0
  191. package/dist/components/tab-group/index.d.ts +8 -0
  192. package/dist/components/tab-group/index.js +441 -0
  193. package/dist/components/tab-group/tab-group.d.ts +99 -0
  194. package/dist/components/tab-group/tab-group.styles.d.ts +1 -0
  195. package/dist/components/tab-group/tab-group.types.d.ts +11 -0
  196. package/dist/components/table/index.d.ts +2 -0
  197. package/dist/components/table/index.js +582 -0
  198. package/dist/components/table/table.d.ts +160 -0
  199. package/dist/components/table/table.styles.d.ts +1 -0
  200. package/dist/components/table/table.types.d.ts +106 -0
  201. package/dist/components/text/index.d.ts +1 -0
  202. package/dist/components/text/index.js +207 -0
  203. package/dist/components/text/text.d.ts +32 -0
  204. package/dist/components/text/text.styles.d.ts +1 -0
  205. package/dist/components/text/text.types.d.ts +2 -0
  206. package/dist/components/textfield/index.d.ts +8 -0
  207. package/dist/components/textfield/index.js +718 -0
  208. package/dist/components/textfield/textfield.d.ts +168 -0
  209. package/dist/components/textfield/textfield.styles.d.ts +1 -0
  210. package/dist/components/textfield/textfield.types.d.ts +40 -0
  211. package/dist/components/tooltip/index.d.ts +2 -0
  212. package/dist/components/tooltip/index.js +379 -0
  213. package/dist/components/tooltip/tooltip.d.ts +42 -0
  214. package/dist/components/tooltip/tooltip.styles.d.ts +1 -0
  215. package/dist/components/tooltip/tooltip.types.d.ts +1 -0
  216. package/dist/css/font-face.css +22 -0
  217. package/dist/css/latty.css +57 -0
  218. package/dist/fonts/HankenGrotesk-Variable.woff2 +0 -0
  219. package/dist/fonts/HankenGrotesk-VariableItalic.woff2 +0 -0
  220. package/dist/index.cjs +12739 -0
  221. package/dist/index.d.ts +101 -0
  222. package/dist/index.js +11406 -0
  223. package/dist/manifest.json +2396 -0
  224. package/dist/utils/click-outside.d.ts +22 -0
  225. package/dist/utils/color.d.ts +14 -0
  226. package/dist/utils/dispatch.d.ts +18 -0
  227. package/dist/utils/index.d.ts +3 -0
  228. package/package.json +231 -0
@@ -0,0 +1,582 @@
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
3
+ var __decorateClass = (decorators, target, key, kind) => {
4
+ var result = kind > 1 ? void 0 : kind ? __getOwnPropDesc(target, key) : target;
5
+ for (var i = decorators.length - 1, decorator; i >= 0; i--)
6
+ if (decorator = decorators[i])
7
+ result = (kind ? decorator(target, key, result) : decorator(result)) || result;
8
+ if (kind && result) __defProp(target, key, result);
9
+ return result;
10
+ };
11
+
12
+ // src/components/table/table.ts
13
+ import { html, nothing } from "lit";
14
+
15
+ // src/base/themeable-element.ts
16
+ import { LitElement } from "lit";
17
+ import { property } from "lit/decorators.js";
18
+ var ThemeableElement = class extends LitElement {
19
+ willUpdate(changed) {
20
+ super.willUpdate(changed);
21
+ if (changed.has("theme")) {
22
+ this._syncThemeAttribute();
23
+ }
24
+ }
25
+ _syncThemeAttribute() {
26
+ if (this.theme === "dark" || this.theme === "light") {
27
+ this.setAttribute("data-theme", this.theme);
28
+ } else {
29
+ this.removeAttribute("data-theme");
30
+ }
31
+ }
32
+ };
33
+ __decorateClass([
34
+ property({ reflect: true })
35
+ ], ThemeableElement.prototype, "theme", 2);
36
+
37
+ // src/components/table/table.ts
38
+ import { customElement, property as property2, state } from "lit/decorators.js";
39
+ import { classMap } from "lit/directives/class-map.js";
40
+ import { styleMap } from "lit/directives/style-map.js";
41
+ import { repeat } from "lit/directives/repeat.js";
42
+
43
+ // src/components/table/table.styles.ts
44
+ import { css } from "lit";
45
+ var tableStyles = css`
46
+ :host {
47
+ display: block;
48
+ font-family: 'Hanken Grotesk', sans-serif;
49
+ overflow: hidden;
50
+ width: 100%;
51
+ }
52
+
53
+ .table-container {
54
+ overflow-x: auto;
55
+ width: 100%;
56
+ }
57
+
58
+ :host([responsive-mode='scroll']) .table-container {
59
+ -webkit-overflow-scrolling: touch;
60
+ }
61
+
62
+ table {
63
+ border-collapse: collapse;
64
+ width: 100%;
65
+ }
66
+
67
+ /* Header */
68
+ thead {
69
+ background: var(--lt-bg-surface);
70
+ border-bottom: 2px solid var(--lt-border-default);
71
+ }
72
+
73
+ th {
74
+ color: var(--lt-text-default);
75
+ font-weight: 600;
76
+ text-align: left;
77
+ white-space: nowrap;
78
+ }
79
+
80
+ th[data-align='center'] {
81
+ text-align: center;
82
+ }
83
+ th[data-align='right'] {
84
+ text-align: right;
85
+ }
86
+
87
+ /* Sortable headers */
88
+ th.sortable {
89
+ cursor: pointer;
90
+ user-select: none;
91
+ transition: background-color 120ms ease;
92
+ }
93
+
94
+ th.sortable:hover {
95
+ background: var(--lt-bg-overlay);
96
+ }
97
+
98
+ th.sortable .header-content {
99
+ align-items: center;
100
+ display: flex;
101
+ gap: var(--lt-spacing-2);
102
+ }
103
+
104
+ th[data-align='center'] .header-content {
105
+ justify-content: center;
106
+ }
107
+ th[data-align='right'] .header-content {
108
+ justify-content: flex-end;
109
+ }
110
+
111
+ .sort-icon {
112
+ color: var(--lt-text-muted);
113
+ display: inline-flex;
114
+ flex-shrink: 0;
115
+ font-size: 0.875rem;
116
+ opacity: 0;
117
+ transition: opacity 120ms ease;
118
+ }
119
+
120
+ th.sortable:hover .sort-icon,
121
+ th.sorted .sort-icon {
122
+ opacity: 1;
123
+ }
124
+
125
+ th.sorted .sort-icon {
126
+ color: var(--lt-interactive-primary-bg);
127
+ }
128
+
129
+ /* Body */
130
+ tbody tr {
131
+ border-bottom: 1px solid var(--lt-border-default);
132
+ transition: background-color 120ms ease;
133
+ }
134
+
135
+ tbody tr:last-child {
136
+ border-bottom: none;
137
+ }
138
+
139
+ :host([hoverable]) tbody tr:hover {
140
+ background: var(--lt-bg-surface);
141
+ }
142
+
143
+ :host([striped]) tbody tr:nth-child(even) {
144
+ background: var(--lt-bg-surface);
145
+ }
146
+
147
+ :host([striped][hoverable]) tbody tr:nth-child(even):hover {
148
+ background: var(--lt-bg-overlay);
149
+ }
150
+
151
+ td {
152
+ color: var(--lt-text-default);
153
+ }
154
+
155
+ td[data-align='center'] {
156
+ text-align: center;
157
+ }
158
+ td[data-align='right'] {
159
+ text-align: right;
160
+ }
161
+
162
+ /* Density variants */
163
+ :host([density='compact']) th,
164
+ :host([density='compact']) td {
165
+ padding: var(--lt-spacing-2) var(--lt-spacing-3);
166
+ }
167
+
168
+ :host([density='normal']) th,
169
+ :host([density='normal']) td {
170
+ padding: var(--lt-spacing-3) var(--lt-spacing-4);
171
+ }
172
+
173
+ :host([density='comfortable']) th,
174
+ :host([density='comfortable']) td {
175
+ padding: var(--lt-spacing-4) var(--lt-spacing-5);
176
+ }
177
+
178
+ /* Sticky columns */
179
+ th.sticky {
180
+ background: var(--lt-bg-surface);
181
+ box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
182
+ left: 0;
183
+ position: sticky;
184
+ z-index: 2;
185
+ }
186
+
187
+ td.sticky {
188
+ background: var(--lt-bg-default);
189
+ box-shadow: 2px 0 4px rgba(0, 0, 0, 0.05);
190
+ left: 0;
191
+ position: sticky;
192
+ z-index: 1;
193
+ }
194
+
195
+ :host([striped]) tbody tr:nth-child(even) td.sticky {
196
+ background: var(--lt-bg-surface);
197
+ }
198
+
199
+ :host([hoverable]) tbody tr:hover td.sticky {
200
+ background: var(--lt-bg-surface);
201
+ }
202
+
203
+ :host([striped][hoverable]) tbody tr:nth-child(even):hover td.sticky {
204
+ background: var(--lt-bg-overlay);
205
+ }
206
+
207
+ /* Border styling */
208
+ :host([bordered]) table {
209
+ border: 1px solid var(--lt-border-default);
210
+ }
211
+
212
+ :host([bordered]) th,
213
+ :host([bordered]) td {
214
+ border-right: 1px solid var(--lt-border-default);
215
+ }
216
+
217
+ :host([bordered]) th:last-child,
218
+ :host([bordered]) td:last-child {
219
+ border-right: none;
220
+ }
221
+
222
+ /* Empty state */
223
+ .empty-state {
224
+ color: var(--lt-text-subtle);
225
+ padding: var(--lt-spacing-8);
226
+ text-align: center;
227
+ }
228
+
229
+ /* Loading state */
230
+ .loading-overlay {
231
+ align-items: center;
232
+ background: rgba(255, 255, 255, 0.8);
233
+ display: flex;
234
+ height: 100%;
235
+ justify-content: center;
236
+ left: 0;
237
+ position: absolute;
238
+ top: 0;
239
+ width: 100%;
240
+ z-index: 10;
241
+ }
242
+
243
+ /* Stack mode for mobile */
244
+ @media (max-width: 768px) {
245
+ :host([responsive-mode='stack']) .table-container {
246
+ overflow-x: visible;
247
+ }
248
+
249
+ :host([responsive-mode='stack']) table,
250
+ :host([responsive-mode='stack']) thead,
251
+ :host([responsive-mode='stack']) tbody,
252
+ :host([responsive-mode='stack']) th,
253
+ :host([responsive-mode='stack']) td,
254
+ :host([responsive-mode='stack']) tr {
255
+ display: block;
256
+ }
257
+
258
+ :host([responsive-mode='stack']) thead {
259
+ display: none;
260
+ }
261
+
262
+ :host([responsive-mode='stack']) tr {
263
+ background: var(--lt-bg-subtle);
264
+ border-radius: var(--lt-border-radius);
265
+ border: 1px solid var(--lt-border-default);
266
+ margin-bottom: var(--lt-spacing-3);
267
+ padding: var(--lt-spacing-4);
268
+ }
269
+
270
+ :host([responsive-mode='stack']) td {
271
+ border: none;
272
+ display: grid;
273
+ gap: var(--lt-spacing-2);
274
+ grid-template-columns: 120px 1fr;
275
+ padding: var(--lt-spacing-2) 0;
276
+ text-align: left;
277
+ }
278
+
279
+ :host([responsive-mode='stack']) td::before {
280
+ content: attr(data-label);
281
+ color: var(--lt-text-default);
282
+ font-weight: 600;
283
+ }
284
+
285
+ :host([responsive-mode='stack']) td:last-child {
286
+ padding-bottom: 0;
287
+ }
288
+ }
289
+
290
+ @media (max-width: 768px) {
291
+ .hide-on-mobile {
292
+ display: none;
293
+ }
294
+ }
295
+
296
+ th.sortable:focus-visible {
297
+ outline: 2px solid var(--lt-interactive-primary-bg);
298
+ outline-offset: -2px;
299
+ }
300
+ `;
301
+
302
+ // src/components/table/table.ts
303
+ import "@latty-ds/icons";
304
+ var jsonArrayConverter = {
305
+ fromAttribute(value) {
306
+ if (value === null) return [];
307
+ try {
308
+ const parsed = JSON.parse(value);
309
+ return Array.isArray(parsed) ? parsed : [];
310
+ } catch {
311
+ return [];
312
+ }
313
+ }
314
+ };
315
+ var Table = class extends ThemeableElement {
316
+ constructor() {
317
+ super(...arguments);
318
+ this.columns = [];
319
+ this.data = [];
320
+ this.density = "normal";
321
+ this.responsiveMode = "scroll";
322
+ this.hoverable = false;
323
+ this.striped = false;
324
+ this.bordered = false;
325
+ this.loading = false;
326
+ this.emptyMessage = "No data available";
327
+ this.rowKey = "";
328
+ this.internalSort = null;
329
+ this.sortedData = [];
330
+ }
331
+ /**
332
+ * Gets the current effective sort state.
333
+ */
334
+ get currentSort() {
335
+ return this.sort ?? this.internalSort;
336
+ }
337
+ willUpdate(changedProperties) {
338
+ super.willUpdate(changedProperties);
339
+ const changed = changedProperties;
340
+ if (changed.has("data") || changed.has("sort") || changed.has("columns") || changed.has("internalSort")) {
341
+ this.updateSortedData();
342
+ }
343
+ }
344
+ /**
345
+ * Updates the sorted data based on current sort state.
346
+ */
347
+ updateSortedData() {
348
+ const data = this.data ?? [];
349
+ if (!this.currentSort) {
350
+ this.sortedData = [...data];
351
+ return;
352
+ }
353
+ const columns = this.columns ?? [];
354
+ const column = columns.find((col) => col.key === this.currentSort.key);
355
+ if (!column) {
356
+ this.sortedData = [...data];
357
+ return;
358
+ }
359
+ const sorted = [...data].sort((a, b) => {
360
+ if (column.sortFn) {
361
+ return column.sortFn(a, b, this.currentSort.direction);
362
+ }
363
+ const aValue = this.getCellValue(a, column.key);
364
+ const bValue = this.getCellValue(b, column.key);
365
+ if (aValue == null && bValue == null) return 0;
366
+ if (aValue == null) return 1;
367
+ if (bValue == null) return -1;
368
+ let comparison = 0;
369
+ if (typeof aValue === "number" && typeof bValue === "number") {
370
+ comparison = aValue - bValue;
371
+ } else {
372
+ comparison = String(aValue).localeCompare(String(bValue));
373
+ }
374
+ return this.currentSort.direction === "asc" ? comparison : -comparison;
375
+ });
376
+ this.sortedData = sorted;
377
+ }
378
+ /**
379
+ * Handles header click for sorting.
380
+ */
381
+ handleHeaderClick(column) {
382
+ if (!column.sortable) return;
383
+ const previousSort = this.currentSort;
384
+ let newDirection = "asc";
385
+ if (previousSort?.key === column.key) {
386
+ newDirection = previousSort.direction === "asc" ? "desc" : "asc";
387
+ }
388
+ const newSort = {
389
+ key: column.key,
390
+ direction: newDirection
391
+ };
392
+ if (this.sort === void 0) {
393
+ this.internalSort = newSort;
394
+ }
395
+ this.dispatchEvent(
396
+ new CustomEvent("sort-change", {
397
+ bubbles: true,
398
+ composed: true,
399
+ detail: {
400
+ key: column.key,
401
+ direction: newDirection,
402
+ previousSort
403
+ }
404
+ })
405
+ );
406
+ }
407
+ /**
408
+ * Gets a cell value from a row using a key (supports nested keys).
409
+ */
410
+ getCellValue(row, key) {
411
+ return key.split(".").reduce((obj, k) => obj?.[k], row);
412
+ }
413
+ /**
414
+ * Renders a cell's content.
415
+ */
416
+ renderCell(column, row, rowIndex) {
417
+ const value = this.getCellValue(row, column.key);
418
+ if (column.render) {
419
+ return column.render(value, row, rowIndex);
420
+ }
421
+ return value ?? "";
422
+ }
423
+ /**
424
+ * Renders the sort icon for a column header.
425
+ */
426
+ renderSortIcon(column) {
427
+ if (!column.sortable) return nothing;
428
+ const isCurrentSort = this.currentSort?.key === column.key;
429
+ const direction = isCurrentSort ? this.currentSort.direction : "asc";
430
+ const iconName = direction === "asc" ? "arrow-up" : "arrow-down";
431
+ return html` <lt-icon class="sort-icon" name=${iconName}></lt-icon> `;
432
+ }
433
+ /**
434
+ * Renders the table header.
435
+ */
436
+ renderHeader() {
437
+ return html`
438
+ <thead>
439
+ <tr>
440
+ ${(this.columns ?? []).map(
441
+ (column) => html`
442
+ <th
443
+ class=${classMap({
444
+ sortable: !!column.sortable,
445
+ sorted: this.currentSort?.key === column.key,
446
+ sticky: !!column.sticky,
447
+ "hide-on-mobile": !!column.hideOnMobile
448
+ })}
449
+ data-align=${column.align || "left"}
450
+ @click=${() => this.handleHeaderClick(column)}
451
+ @keydown=${(e) => {
452
+ if (column.sortable && (e.key === "Enter" || e.key === " ")) {
453
+ e.preventDefault();
454
+ this.handleHeaderClick(column);
455
+ }
456
+ }}
457
+ tabindex=${column.sortable ? "0" : "-1"}
458
+ aria-sort=${column.sortable ? this.currentSort?.key === column.key ? this.currentSort.direction === "asc" ? "ascending" : "descending" : "none" : nothing}
459
+ style=${styleMap({
460
+ ...column.width ? { width: column.width } : {},
461
+ ...column.minWidth ? { minWidth: column.minWidth } : {}
462
+ })}
463
+ >
464
+ ${column.sortable ? html`
465
+ <div class="header-content">
466
+ <span>${column.label}</span>
467
+ ${this.renderSortIcon(column)}
468
+ </div>
469
+ ` : column.label}
470
+ </th>
471
+ `
472
+ )}
473
+ </tr>
474
+ </thead>
475
+ `;
476
+ }
477
+ /**
478
+ * Renders the table body.
479
+ */
480
+ renderBody() {
481
+ const columns = this.columns ?? [];
482
+ if (this.sortedData.length === 0) {
483
+ return html`
484
+ <tbody>
485
+ <tr>
486
+ <td colspan=${columns.length} class="empty-state">${this.emptyMessage}</td>
487
+ </tr>
488
+ </tbody>
489
+ `;
490
+ }
491
+ return html`
492
+ <tbody>
493
+ ${repeat(
494
+ this.sortedData,
495
+ (row) => this.rowKey ? row[this.rowKey] : JSON.stringify(row),
496
+ (row, index) => html`
497
+ <tr>
498
+ ${columns.map(
499
+ (column) => html`
500
+ <td
501
+ class=${classMap({
502
+ sticky: !!column.sticky,
503
+ "hide-on-mobile": !!column.hideOnMobile
504
+ })}
505
+ data-align=${column.align || "left"}
506
+ data-label=${column.label}
507
+ style=${styleMap({
508
+ ...column.width ? { width: column.width } : {},
509
+ ...column.minWidth ? { minWidth: column.minWidth } : {}
510
+ })}
511
+ >
512
+ ${this.renderCell(column, row, index)}
513
+ </td>
514
+ `
515
+ )}
516
+ </tr>
517
+ `
518
+ )}
519
+ </tbody>
520
+ `;
521
+ }
522
+ render() {
523
+ return html`
524
+ <div class="table-container">
525
+ <table>
526
+ ${this.renderHeader()} ${this.renderBody()}
527
+ </table>
528
+ ${this.loading ? html`
529
+ <div class="loading-overlay">
530
+ <lt-spinner></lt-spinner>
531
+ </div>
532
+ ` : nothing}
533
+ </div>
534
+ `;
535
+ }
536
+ };
537
+ Table.styles = tableStyles;
538
+ __decorateClass([
539
+ property2({ converter: jsonArrayConverter })
540
+ ], Table.prototype, "columns", 2);
541
+ __decorateClass([
542
+ property2({ converter: jsonArrayConverter })
543
+ ], Table.prototype, "data", 2);
544
+ __decorateClass([
545
+ property2({ reflect: true })
546
+ ], Table.prototype, "density", 2);
547
+ __decorateClass([
548
+ property2({ reflect: true, attribute: "responsive-mode" })
549
+ ], Table.prototype, "responsiveMode", 2);
550
+ __decorateClass([
551
+ property2({ type: Boolean, reflect: true })
552
+ ], Table.prototype, "hoverable", 2);
553
+ __decorateClass([
554
+ property2({ type: Boolean, reflect: true })
555
+ ], Table.prototype, "striped", 2);
556
+ __decorateClass([
557
+ property2({ type: Boolean, reflect: true })
558
+ ], Table.prototype, "bordered", 2);
559
+ __decorateClass([
560
+ property2({ type: Boolean, reflect: true })
561
+ ], Table.prototype, "loading", 2);
562
+ __decorateClass([
563
+ property2({ attribute: "empty-message" })
564
+ ], Table.prototype, "emptyMessage", 2);
565
+ __decorateClass([
566
+ property2({ attribute: "row-key" })
567
+ ], Table.prototype, "rowKey", 2);
568
+ __decorateClass([
569
+ property2({ type: Object })
570
+ ], Table.prototype, "sort", 2);
571
+ __decorateClass([
572
+ state()
573
+ ], Table.prototype, "internalSort", 2);
574
+ __decorateClass([
575
+ state()
576
+ ], Table.prototype, "sortedData", 2);
577
+ Table = __decorateClass([
578
+ customElement("lt-table")
579
+ ], Table);
580
+ export {
581
+ Table
582
+ };