@liteforge/table 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/styles.js ADDED
@@ -0,0 +1,345 @@
1
+ /**
2
+ * @liteforge/table - Default CSS Theme
3
+ *
4
+ * Minimal, clean default styles using CSS variables.
5
+ * Injected once when the first table renders (unless unstyled: true).
6
+ */
7
+ let stylesInjected = false;
8
+ const DEFAULT_STYLES = `
9
+ /* ─── CSS Variables (Customizable) ─────────────────────────── */
10
+
11
+ :root {
12
+ --lf-table-bg: #ffffff;
13
+ --lf-table-border: #e2e8f0;
14
+ --lf-table-border-radius: 8px;
15
+ --lf-table-header-bg: #f8fafc;
16
+ --lf-table-header-color: #374151;
17
+ --lf-table-header-font-weight: 600;
18
+ --lf-table-row-bg: #ffffff;
19
+ --lf-table-row-bg-hover: #f1f5f9;
20
+ --lf-table-row-bg-selected: #eff6ff;
21
+ --lf-table-row-bg-striped: #f8fafc;
22
+ --lf-table-cell-padding: 12px 16px;
23
+ --lf-table-cell-color: #1e293b;
24
+ --lf-table-cell-font-size: 14px;
25
+ --lf-table-sort-icon-color: #94a3b8;
26
+ --lf-table-sort-icon-active: #3b82f6;
27
+ --lf-table-pagination-bg: #f8fafc;
28
+ --lf-table-pagination-btn: #3b82f6;
29
+ --lf-table-search-border: #d1d5db;
30
+ --lf-table-search-focus: #3b82f6;
31
+ }
32
+
33
+ /* ─── Root Container ───────────────────────────────────────── */
34
+
35
+ .lf-table {
36
+ background: var(--lf-table-bg);
37
+ border: 1px solid var(--lf-table-border);
38
+ border-radius: var(--lf-table-border-radius);
39
+ overflow: hidden;
40
+ font-family: system-ui, -apple-system, sans-serif;
41
+ }
42
+
43
+ /* ─── Search ───────────────────────────────────────────────── */
44
+
45
+ .lf-table-search {
46
+ padding: 12px 16px;
47
+ border-bottom: 1px solid var(--lf-table-border);
48
+ }
49
+
50
+ .lf-table-search-input {
51
+ width: 100%;
52
+ padding: 8px 12px;
53
+ border: 1px solid var(--lf-table-search-border);
54
+ border-radius: 6px;
55
+ font-size: 14px;
56
+ outline: none;
57
+ transition: border-color 0.2s, box-shadow 0.2s;
58
+ }
59
+
60
+ .lf-table-search-input:focus {
61
+ border-color: var(--lf-table-search-focus);
62
+ box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
63
+ }
64
+
65
+ /* ─── Column Toggle ────────────────────────────────────────── */
66
+
67
+ .lf-table-column-toggle {
68
+ position: relative;
69
+ padding: 8px 16px;
70
+ border-bottom: 1px solid var(--lf-table-border);
71
+ }
72
+
73
+ .lf-table-column-toggle-btn {
74
+ padding: 6px 12px;
75
+ border: 1px solid var(--lf-table-border);
76
+ border-radius: 4px;
77
+ background: white;
78
+ cursor: pointer;
79
+ font-size: 13px;
80
+ }
81
+
82
+ .lf-table-column-toggle-btn:hover {
83
+ background: var(--lf-table-row-bg-hover);
84
+ }
85
+
86
+ .lf-table-column-toggle-dropdown {
87
+ position: absolute;
88
+ top: 100%;
89
+ left: 16px;
90
+ background: white;
91
+ border: 1px solid var(--lf-table-border);
92
+ border-radius: 6px;
93
+ padding: 8px 0;
94
+ z-index: 1000;
95
+ box-shadow: 0 4px 12px rgba(0,0,0,0.1);
96
+ min-width: 150px;
97
+ }
98
+
99
+ .lf-table-column-toggle-item {
100
+ display: flex;
101
+ align-items: center;
102
+ gap: 8px;
103
+ padding: 6px 12px;
104
+ cursor: pointer;
105
+ font-size: 13px;
106
+ }
107
+
108
+ .lf-table-column-toggle-item:hover {
109
+ background: var(--lf-table-row-bg-hover);
110
+ }
111
+
112
+ /* ─── Filters ──────────────────────────────────────────────── */
113
+
114
+ .lf-table-filters {
115
+ display: flex;
116
+ flex-wrap: wrap;
117
+ gap: 12px;
118
+ padding: 12px 16px;
119
+ border-bottom: 1px solid var(--lf-table-border);
120
+ background: var(--lf-table-header-bg);
121
+ }
122
+
123
+ .lf-table-filter-item {
124
+ display: flex;
125
+ flex-direction: column;
126
+ gap: 4px;
127
+ }
128
+
129
+ .lf-table-filter-item label {
130
+ font-size: 11px;
131
+ font-weight: 500;
132
+ color: var(--lf-table-header-color);
133
+ text-transform: uppercase;
134
+ letter-spacing: 0.5px;
135
+ }
136
+
137
+ .lf-table-filter-item input,
138
+ .lf-table-filter-item select {
139
+ padding: 6px 10px;
140
+ border: 1px solid var(--lf-table-search-border);
141
+ border-radius: 4px;
142
+ font-size: 13px;
143
+ min-width: 120px;
144
+ }
145
+
146
+ /* ─── Table Container (Scroll) ─────────────────────────────── */
147
+
148
+ .lf-table-container {
149
+ overflow-x: auto;
150
+ }
151
+
152
+ /* ─── Table Element ────────────────────────────────────────── */
153
+
154
+ .lf-table-element {
155
+ width: 100%;
156
+ border-collapse: collapse;
157
+ }
158
+
159
+ /* ─── Header ───────────────────────────────────────────────── */
160
+
161
+ .lf-table-header {
162
+ background: var(--lf-table-header-bg);
163
+ }
164
+
165
+ .lf-table-header-row {
166
+ border-bottom: 1px solid var(--lf-table-border);
167
+ }
168
+
169
+ .lf-table-header-cell {
170
+ padding: var(--lf-table-cell-padding);
171
+ text-align: left;
172
+ font-size: var(--lf-table-cell-font-size);
173
+ font-weight: var(--lf-table-header-font-weight);
174
+ color: var(--lf-table-header-color);
175
+ white-space: nowrap;
176
+ user-select: none;
177
+ }
178
+
179
+ .lf-table-header-cell--sortable {
180
+ cursor: pointer;
181
+ }
182
+
183
+ .lf-table-header-cell--sortable:hover {
184
+ background: rgba(0,0,0,0.03);
185
+ }
186
+
187
+ .lf-table-header-cell--select {
188
+ width: 40px;
189
+ text-align: center;
190
+ }
191
+
192
+ .lf-table-sort-icon {
193
+ color: var(--lf-table-sort-icon-color);
194
+ margin-left: 4px;
195
+ font-size: 12px;
196
+ }
197
+
198
+ .lf-table-header-cell--sorted-asc .lf-table-sort-icon,
199
+ .lf-table-header-cell--sorted-desc .lf-table-sort-icon {
200
+ color: var(--lf-table-sort-icon-active);
201
+ }
202
+
203
+ /* ─── Body ─────────────────────────────────────────────────── */
204
+
205
+ .lf-table-body {
206
+ background: var(--lf-table-row-bg);
207
+ }
208
+
209
+ .lf-table-row {
210
+ border-bottom: 1px solid var(--lf-table-border);
211
+ transition: background-color 0.15s;
212
+ }
213
+
214
+ .lf-table-row:last-child {
215
+ border-bottom: none;
216
+ }
217
+
218
+ .lf-table-row:hover {
219
+ background: var(--lf-table-row-bg-hover);
220
+ }
221
+
222
+ .lf-table-row--odd {
223
+ background: var(--lf-table-row-bg-striped);
224
+ }
225
+
226
+ .lf-table-row--odd:hover {
227
+ background: var(--lf-table-row-bg-hover);
228
+ }
229
+
230
+ .lf-table-row--selected {
231
+ background: var(--lf-table-row-bg-selected) !important;
232
+ }
233
+
234
+ .lf-table-cell {
235
+ padding: var(--lf-table-cell-padding);
236
+ font-size: var(--lf-table-cell-font-size);
237
+ color: var(--lf-table-cell-color);
238
+ }
239
+
240
+ .lf-table-cell--select {
241
+ width: 40px;
242
+ text-align: center;
243
+ }
244
+
245
+ /* ─── Empty State ──────────────────────────────────────────── */
246
+
247
+ .lf-table-empty {
248
+ padding: 40px;
249
+ text-align: center;
250
+ color: #9ca3af;
251
+ font-size: 14px;
252
+ }
253
+
254
+ /* ─── Pagination ───────────────────────────────────────────── */
255
+
256
+ .lf-table-pagination {
257
+ display: flex;
258
+ align-items: center;
259
+ justify-content: space-between;
260
+ gap: 16px;
261
+ padding: 12px 16px;
262
+ background: var(--lf-table-pagination-bg);
263
+ border-top: 1px solid var(--lf-table-border);
264
+ font-size: 13px;
265
+ }
266
+
267
+ .lf-table-pagination-info {
268
+ color: #6b7280;
269
+ }
270
+
271
+ .lf-table-pagination-controls {
272
+ display: flex;
273
+ align-items: center;
274
+ gap: 12px;
275
+ }
276
+
277
+ .lf-table-pagination-controls button {
278
+ padding: 6px 12px;
279
+ border: 1px solid var(--lf-table-border);
280
+ border-radius: 4px;
281
+ background: white;
282
+ cursor: pointer;
283
+ font-size: 13px;
284
+ transition: background-color 0.15s;
285
+ }
286
+
287
+ .lf-table-pagination-controls button:hover:not(:disabled) {
288
+ background: var(--lf-table-row-bg-hover);
289
+ }
290
+
291
+ .lf-table-pagination-controls button:disabled {
292
+ opacity: 0.5;
293
+ cursor: not-allowed;
294
+ }
295
+
296
+ .lf-table-pagination-sizes {
297
+ padding: 6px 10px;
298
+ border: 1px solid var(--lf-table-border);
299
+ border-radius: 4px;
300
+ font-size: 13px;
301
+ background: white;
302
+ }
303
+
304
+ /* ─── Dark Mode Support ────────────────────────────────────── */
305
+
306
+ [data-theme="dark"] {
307
+ --lf-table-bg: #1e1e2e;
308
+ --lf-table-border: #313244;
309
+ --lf-table-header-bg: #181825;
310
+ --lf-table-header-color: #cdd6f4;
311
+ --lf-table-row-bg: #1e1e2e;
312
+ --lf-table-row-bg-hover: #313244;
313
+ --lf-table-row-bg-selected: #45475a;
314
+ --lf-table-row-bg-striped: #181825;
315
+ --lf-table-cell-color: #cdd6f4;
316
+ --lf-table-pagination-bg: #181825;
317
+ --lf-table-search-border: #45475a;
318
+ }
319
+ `;
320
+ /**
321
+ * Inject default styles into the document head.
322
+ * Called automatically when the first table is created (unless unstyled: true).
323
+ */
324
+ export function injectDefaultStyles() {
325
+ if (stylesInjected)
326
+ return;
327
+ if (typeof document === 'undefined')
328
+ return; // SSR safety
329
+ const style = document.createElement('style');
330
+ style.id = 'lf-table-styles';
331
+ style.textContent = DEFAULT_STYLES;
332
+ document.head.appendChild(style);
333
+ stylesInjected = true;
334
+ }
335
+ /**
336
+ * Reset styles injection flag (for testing)
337
+ */
338
+ export function resetStylesInjection() {
339
+ stylesInjected = false;
340
+ const existing = document.getElementById('lf-table-styles');
341
+ if (existing) {
342
+ existing.remove();
343
+ }
344
+ }
345
+ //# sourceMappingURL=styles.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"styles.js","sourceRoot":"","sources":["../src/styles.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,IAAI,cAAc,GAAG,KAAK,CAAA;AAE1B,MAAM,cAAc,GAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAuTtB,CAAA;AAED;;;GAGG;AACH,MAAM,UAAU,mBAAmB;IACjC,IAAI,cAAc;QAAE,OAAM;IAC1B,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAM,CAAC,aAAa;IAEzD,MAAM,KAAK,GAAG,QAAQ,CAAC,aAAa,CAAC,OAAO,CAAC,CAAA;IAC7C,KAAK,CAAC,EAAE,GAAG,iBAAiB,CAAA;IAC5B,KAAK,CAAC,WAAW,GAAG,cAAc,CAAA;IAClC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,KAAK,CAAC,CAAA;IAEhC,cAAc,GAAG,IAAI,CAAA;AACvB,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,oBAAoB;IAClC,cAAc,GAAG,KAAK,CAAA;IACtB,MAAM,QAAQ,GAAG,QAAQ,CAAC,cAAc,CAAC,iBAAiB,CAAC,CAAA;IAC3D,IAAI,QAAQ,EAAE,CAAC;QACb,QAAQ,CAAC,MAAM,EAAE,CAAA;IACnB,CAAC;AACH,CAAC"}
@@ -0,0 +1,9 @@
1
+ /**
2
+ * @liteforge/table - createTable Implementation
3
+ *
4
+ * Signals-based data table with sorting, filtering, pagination, and selection.
5
+ * Uses computed() pipeline for efficient fine-grained updates.
6
+ */
7
+ import type { TableOptions, TableResult } from './types.js';
8
+ export declare function createTable<T>(options: TableOptions<T>): TableResult<T>;
9
+ //# sourceMappingURL=table.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"table.d.ts","sourceRoot":"","sources":["../src/table.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,KAAK,EACV,YAAY,EACZ,WAAW,EAIZ,MAAM,YAAY,CAAA;AA4GnB,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,YAAY,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAywBvE"}