svelte-tably 1.0.2-next.1 → 1.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/LICENSE +20 -20
- package/README.md +301 -301
- package/dist/column/Column.svelte +38 -38
- package/dist/column/Column.svelte.d.ts +1 -2
- package/dist/column/column-state.svelte.d.ts +6 -7
- package/dist/expandable/Expandable.svelte +24 -24
- package/dist/expandable/expandable-state.svelte.d.ts +2 -3
- package/dist/index.d.ts +7 -1
- package/dist/index.js +2 -1
- package/dist/panel/Panel.svelte +20 -20
- package/dist/panel/panel-state.svelte.d.ts +3 -4
- package/dist/row/Row.svelte +24 -24
- package/dist/row/row-state.svelte.d.ts +3 -4
- package/dist/table/Table.svelte +1169 -1146
- package/dist/table/Table.svelte.d.ts +3 -7
- package/dist/table/csv.d.ts +28 -0
- package/dist/table/csv.js +1 -0
- package/dist/table/data.svelte.d.ts +1 -1
- package/dist/table/table-state.svelte.d.ts +15 -9
- package/dist/table/table-state.svelte.js +91 -5
- package/package.json +1 -1
package/dist/table/Table.svelte
CHANGED
|
@@ -1,1146 +1,1169 @@
|
|
|
1
|
-
<!-- @component
|
|
2
|
-
|
|
3
|
-
This is a description, \
|
|
4
|
-
on how to use this.
|
|
5
|
-
|
|
6
|
-
@example
|
|
7
|
-
<Component />
|
|
8
|
-
|
|
9
|
-
-->
|
|
10
|
-
|
|
11
|
-
<script lang="ts">
|
|
12
|
-
import { type Snippet } from 'svelte'
|
|
13
|
-
import { fly } from 'svelte/transition'
|
|
14
|
-
import { sineInOut } from 'svelte/easing'
|
|
15
|
-
import reorder, { type ItemState } from 'runic-reorder'
|
|
16
|
-
import { Virtualization } from './virtualization.svelte.js'
|
|
17
|
-
import {
|
|
18
|
-
TableState,
|
|
19
|
-
type HeaderSelectCtx,
|
|
20
|
-
type RowCtx,
|
|
21
|
-
type RowSelectCtx,
|
|
22
|
-
type TableProps
|
|
23
|
-
} from './table-state.svelte.js'
|
|
24
|
-
import Panel from '../panel/Panel.svelte'
|
|
25
|
-
import Column from '../column/Column.svelte'
|
|
26
|
-
import { assignDescriptors, capitalize, fromProps, mounted, segmentize } from '../utility.svelte.js'
|
|
27
|
-
import { conditional } from '../conditional.svelte.js'
|
|
28
|
-
import { ColumnState, type RowColumnCtx } from '../column/column-state.svelte.js'
|
|
29
|
-
import Expandable from '../expandable/Expandable.svelte'
|
|
30
|
-
import { SizeTween } from '../size-tween.svelte.js'
|
|
31
|
-
import { on } from 'svelte/events'
|
|
32
|
-
import Row from '../row/Row.svelte'
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
<V>(...args:
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
const
|
|
90
|
-
const
|
|
91
|
-
const
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
if (!mount.isMounted)
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
}
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
.
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
if (
|
|
273
|
-
|
|
274
|
-
}
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
if (
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
{
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
{
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
{
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
</
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
{#snippet
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
class:
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
class={column.options.
|
|
443
|
-
class:
|
|
444
|
-
|
|
445
|
-
class:
|
|
446
|
-
|
|
447
|
-
use:
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
{
|
|
462
|
-
|
|
463
|
-
{
|
|
464
|
-
|
|
465
|
-
{
|
|
466
|
-
|
|
467
|
-
{
|
|
468
|
-
|
|
469
|
-
{
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
{
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
{
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
}
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
{
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
{
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
{
|
|
741
|
-
|
|
742
|
-
|
|
743
|
-
|
|
744
|
-
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
{
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
{
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
{
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
{/if}
|
|
796
|
-
|
|
797
|
-
{
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
.
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
>
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
}
|
|
1019
|
-
|
|
1020
|
-
.
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
.
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1
|
+
<!-- @component
|
|
2
|
+
|
|
3
|
+
This is a description, \
|
|
4
|
+
on how to use this.
|
|
5
|
+
|
|
6
|
+
@example
|
|
7
|
+
<Component />
|
|
8
|
+
|
|
9
|
+
-->
|
|
10
|
+
|
|
11
|
+
<script lang="ts">
|
|
12
|
+
import { type Snippet } from 'svelte'
|
|
13
|
+
import { fly } from 'svelte/transition'
|
|
14
|
+
import { sineInOut } from 'svelte/easing'
|
|
15
|
+
import reorder, { type ItemState } from 'runic-reorder'
|
|
16
|
+
import { Virtualization } from './virtualization.svelte.js'
|
|
17
|
+
import {
|
|
18
|
+
TableState,
|
|
19
|
+
type HeaderSelectCtx,
|
|
20
|
+
type RowCtx,
|
|
21
|
+
type RowSelectCtx,
|
|
22
|
+
type TableProps
|
|
23
|
+
} from './table-state.svelte.js'
|
|
24
|
+
import Panel from '../panel/Panel.svelte'
|
|
25
|
+
import Column from '../column/Column.svelte'
|
|
26
|
+
import { assignDescriptors, capitalize, fromProps, mounted, segmentize } from '../utility.svelte.js'
|
|
27
|
+
import { conditional } from '../conditional.svelte.js'
|
|
28
|
+
import { ColumnState, type RowColumnCtx } from '../column/column-state.svelte.js'
|
|
29
|
+
import Expandable from '../expandable/Expandable.svelte'
|
|
30
|
+
import { SizeTween } from '../size-tween.svelte.js'
|
|
31
|
+
import { on } from 'svelte/events'
|
|
32
|
+
import Row from '../row/Row.svelte'
|
|
33
|
+
import type { CSVOptions } from './csv.js'
|
|
34
|
+
|
|
35
|
+
type T = $$Generic<Record<PropertyKey, unknown>>
|
|
36
|
+
|
|
37
|
+
type ConstructorReturnType<T extends new (...args: any[]) => any> =
|
|
38
|
+
T extends new (...args: any[]) => infer K ? K : never
|
|
39
|
+
type ConstructorParams<T extends new (...args: any[]) => any> =
|
|
40
|
+
T extends new (...args: infer K) => any ? K : never
|
|
41
|
+
|
|
42
|
+
type ContentCtx<T extends Record<PropertyKey, unknown>> = {
|
|
43
|
+
Column: {
|
|
44
|
+
new <V>(...args: ConstructorParams<typeof Column<T, V>>): ConstructorReturnType<typeof Column<T, V>>
|
|
45
|
+
<V>(...args: Parameters<typeof Column<T, V>>): ReturnType<typeof Column<T, V>>
|
|
46
|
+
}
|
|
47
|
+
Panel: typeof Panel<T>
|
|
48
|
+
Expandable: typeof Expandable<T>
|
|
49
|
+
Row: typeof Row<T>
|
|
50
|
+
readonly table: TableState<T>
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
type ContentSnippet = Snippet<[context: ContentCtx<T>]>
|
|
54
|
+
|
|
55
|
+
let {
|
|
56
|
+
content,
|
|
57
|
+
selected: _selected = $bindable([]),
|
|
58
|
+
panel: _panel = $bindable(),
|
|
59
|
+
data: _data = $bindable([]),
|
|
60
|
+
table: _table = $bindable(),
|
|
61
|
+
...restProps
|
|
62
|
+
}: TableProps<T> & { content?: ContentSnippet } = $props()
|
|
63
|
+
|
|
64
|
+
const properties = fromProps(restProps, {
|
|
65
|
+
selected: [() => _selected, (v) => (_selected = v)],
|
|
66
|
+
panel: [() => _panel, (v) => (_panel = v)],
|
|
67
|
+
data: [() => _data, (v) => (_data = v)]
|
|
68
|
+
}) as TableProps<T>
|
|
69
|
+
|
|
70
|
+
const mount = mounted()
|
|
71
|
+
|
|
72
|
+
const reorderArea = reorder(rowSnippet)
|
|
73
|
+
|
|
74
|
+
const elements = $state({}) as Record<
|
|
75
|
+
'headers' | 'statusbar' | 'rows' | 'virtualTop' | 'virtualBottom' | 'selects',
|
|
76
|
+
HTMLElement
|
|
77
|
+
>
|
|
78
|
+
|
|
79
|
+
const table = new TableState<T>(properties) as TableState<T>
|
|
80
|
+
|
|
81
|
+
const virtualization = new Virtualization(table)
|
|
82
|
+
|
|
83
|
+
const panelTween = new SizeTween(() => !!properties.panel)
|
|
84
|
+
|
|
85
|
+
let hoveredRow: T | null = $state(null)
|
|
86
|
+
let hoveredColumn: ColumnState | null = $state(null)
|
|
87
|
+
|
|
88
|
+
/** Order of columns */
|
|
89
|
+
const fixed = $derived(table.positions.fixed)
|
|
90
|
+
const hidden = $derived(table.positions.hidden)
|
|
91
|
+
const notHidden = (column: ColumnState) => !table.positions.hidden.includes(column)
|
|
92
|
+
const sticky = $derived(table.positions.sticky.filter(notHidden))
|
|
93
|
+
const scrolled = $derived(table.positions.scroll.filter(notHidden))
|
|
94
|
+
const columns = $derived([...fixed, ...sticky, ...scrolled])
|
|
95
|
+
|
|
96
|
+
const getWidth = (key: string, def: number = 150) =>
|
|
97
|
+
table.columnWidths[key] ??= table.columns[key]?.defaults.width ?? def
|
|
98
|
+
|
|
99
|
+
/** grid-template-columns for widths */
|
|
100
|
+
let style = $state('')
|
|
101
|
+
$effect(() => {
|
|
102
|
+
if (!mount.isMounted) {
|
|
103
|
+
style = ''
|
|
104
|
+
return
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
const context = table.row?.snippets.context ? table.row?.options.context.width : ''
|
|
108
|
+
|
|
109
|
+
const templateColumns =
|
|
110
|
+
columns
|
|
111
|
+
.map((column, i, arr) => {
|
|
112
|
+
const width = getWidth(column.id)
|
|
113
|
+
if (i === arr.length - 1) return `minmax(${width}px, 1fr)`
|
|
114
|
+
return `${width}px`
|
|
115
|
+
})
|
|
116
|
+
.join(' ') + context
|
|
117
|
+
|
|
118
|
+
const theadTempla3teColumns = `
|
|
119
|
+
[data-svelte-tably="${table.cssId}"] > thead > tr,
|
|
120
|
+
[data-svelte-tably="${table.cssId}"] > tfoot > tr {
|
|
121
|
+
grid-template-columns: ${templateColumns};
|
|
122
|
+
}
|
|
123
|
+
`
|
|
124
|
+
|
|
125
|
+
const tbodyTemplateColumns = `
|
|
126
|
+
[data-area-class='${table.cssId}'] tr.row,
|
|
127
|
+
[data-svelte-tably="${table.cssId}"] > tbody::after {
|
|
128
|
+
grid-template-columns: ${templateColumns};
|
|
129
|
+
}
|
|
130
|
+
`
|
|
131
|
+
|
|
132
|
+
let sum = 0
|
|
133
|
+
const stickyLeft = [...fixed, ...sticky]
|
|
134
|
+
.map((column, i, arr) => {
|
|
135
|
+
sum += getWidth(arr[i - 1]?.id, i === 0 ? 0 : undefined)
|
|
136
|
+
return `
|
|
137
|
+
[data-svelte-tably="${table.cssId}"] .column.sticky[data-column='${column.id}'],
|
|
138
|
+
[data-svelte-tably-row='${table.cssId}'] .column.sticky[data-column='${column.id}'] {
|
|
139
|
+
left: ${sum}px;
|
|
140
|
+
}
|
|
141
|
+
`
|
|
142
|
+
})
|
|
143
|
+
.join('')
|
|
144
|
+
|
|
145
|
+
const columnStyling = columns
|
|
146
|
+
.map((column) =>
|
|
147
|
+
!column.options.style ?
|
|
148
|
+
''
|
|
149
|
+
: `
|
|
150
|
+
[data-area-class='${table.cssId}'] .column[data-column='${column.id}'] {
|
|
151
|
+
${column.options.style}
|
|
152
|
+
}
|
|
153
|
+
`
|
|
154
|
+
)
|
|
155
|
+
.join('')
|
|
156
|
+
|
|
157
|
+
style = theadTempla3teColumns + tbodyTemplateColumns + stickyLeft + columnStyling
|
|
158
|
+
})
|
|
159
|
+
|
|
160
|
+
function observeColumnWidth(node: HTMLDivElement, isHeader = false) {
|
|
161
|
+
if (!isHeader) return
|
|
162
|
+
|
|
163
|
+
const key = node.getAttribute('data-column')!
|
|
164
|
+
node.style.width = getWidth(key) + 'px'
|
|
165
|
+
|
|
166
|
+
let mouseup = false
|
|
167
|
+
|
|
168
|
+
const observer = new MutationObserver(() => {
|
|
169
|
+
const width = parseFloat(node.style.width)
|
|
170
|
+
if (width === table.columnWidths[key]) return
|
|
171
|
+
table.columnWidths[key] = width
|
|
172
|
+
if (!mouseup) {
|
|
173
|
+
mouseup = true
|
|
174
|
+
window.addEventListener(
|
|
175
|
+
'click',
|
|
176
|
+
(e) => {
|
|
177
|
+
e.preventDefault()
|
|
178
|
+
e.stopPropagation()
|
|
179
|
+
mouseup = false
|
|
180
|
+
},
|
|
181
|
+
{ once: true, capture: true }
|
|
182
|
+
)
|
|
183
|
+
}
|
|
184
|
+
})
|
|
185
|
+
|
|
186
|
+
observer.observe(node, { attributes: true })
|
|
187
|
+
return { destroy: () => observer.disconnect() }
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
let tbody = $state({
|
|
191
|
+
width: 0
|
|
192
|
+
})
|
|
193
|
+
async function onscroll() {
|
|
194
|
+
const target = virtualization.viewport.element!
|
|
195
|
+
if (target.scrollTop !== virtualization.scrollTop) {
|
|
196
|
+
virtualization.scrollTop = target?.scrollTop ?? virtualization.scrollTop
|
|
197
|
+
}
|
|
198
|
+
|
|
199
|
+
if (elements.selects) {
|
|
200
|
+
elements.selects.scrollTop = target?.scrollTop
|
|
201
|
+
}
|
|
202
|
+
|
|
203
|
+
if (!elements.headers) return
|
|
204
|
+
elements.headers.scrollLeft = target.scrollLeft
|
|
205
|
+
elements.statusbar.scrollLeft = target.scrollLeft
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
// * --- CSV --- *
|
|
209
|
+
let csv = $state(false) as false | {
|
|
210
|
+
selected: CSVOptions<T>['selected']
|
|
211
|
+
filters: CSVOptions<T>['filters']
|
|
212
|
+
columns: CSVOptions<T>['columns']
|
|
213
|
+
}
|
|
214
|
+
let csvElement = $state() as undefined | HTMLTableElement
|
|
215
|
+
|
|
216
|
+
export async function toCSV(options: CSVOptions<T> = {}) {
|
|
217
|
+
csv = {
|
|
218
|
+
selected: !!options.selected,
|
|
219
|
+
filters: options.filters ?? true,
|
|
220
|
+
columns: options.columns ?? false
|
|
221
|
+
}
|
|
222
|
+
let resolve: (value: HTMLTableElement) => void
|
|
223
|
+
const promise = new Promise<HTMLTableElement>((r) => (resolve = r))
|
|
224
|
+
|
|
225
|
+
const clean = $effect.root(() => {
|
|
226
|
+
$effect(() => {
|
|
227
|
+
if (csvElement) {
|
|
228
|
+
resolve(csvElement)
|
|
229
|
+
}
|
|
230
|
+
})
|
|
231
|
+
})
|
|
232
|
+
|
|
233
|
+
let table = await promise
|
|
234
|
+
clean()
|
|
235
|
+
|
|
236
|
+
const separator = options.semicolon ? ';' : ','
|
|
237
|
+
const rows = Array.from(table.rows)
|
|
238
|
+
const csvRows = [] as string[]
|
|
239
|
+
|
|
240
|
+
for (const row of rows) {
|
|
241
|
+
const cells = Array.from(row.cells)
|
|
242
|
+
const csvCells = cells.map((cell) => {
|
|
243
|
+
let text = cell.textContent?.trim() || ''
|
|
244
|
+
|
|
245
|
+
// Escape double quotes and wrap in quotes if needed
|
|
246
|
+
if (text.includes('"')) {
|
|
247
|
+
text = text.replace(/"/g, '""')
|
|
248
|
+
}
|
|
249
|
+
if (text.includes(separator) || text.includes('"') || text.includes('\n')) {
|
|
250
|
+
text = `"${text}"`
|
|
251
|
+
}
|
|
252
|
+
|
|
253
|
+
return text
|
|
254
|
+
})
|
|
255
|
+
csvRows.push(csvCells.join(separator))
|
|
256
|
+
}
|
|
257
|
+
|
|
258
|
+
csv = false
|
|
259
|
+
return csvRows.join('\n')
|
|
260
|
+
}
|
|
261
|
+
table.toCSV = toCSV
|
|
262
|
+
// * --- CSV --- *
|
|
263
|
+
|
|
264
|
+
let expandedRow = $state([]) as T[]
|
|
265
|
+
let expandTick = false
|
|
266
|
+
function toggleExpand(item: T, value?: boolean) {
|
|
267
|
+
if (expandTick) return
|
|
268
|
+
expandTick = true
|
|
269
|
+
requestAnimationFrame(() => (expandTick = false))
|
|
270
|
+
|
|
271
|
+
let indexOf = expandedRow.indexOf(item)
|
|
272
|
+
if (value === undefined) {
|
|
273
|
+
value = indexOf === -1
|
|
274
|
+
}
|
|
275
|
+
if (!value) {
|
|
276
|
+
expandedRow.splice(indexOf, 1)
|
|
277
|
+
return
|
|
278
|
+
}
|
|
279
|
+
if (table.expandable?.options.multiple === true) {
|
|
280
|
+
expandedRow.push(item)
|
|
281
|
+
} else {
|
|
282
|
+
expandedRow[0] = item
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
function addRowColumnEvents(
|
|
287
|
+
node: HTMLTableColElement,
|
|
288
|
+
opts: ['header' | 'row' | 'statusbar', ColumnState, () => RowColumnCtx<T, any>]
|
|
289
|
+
) {
|
|
290
|
+
const [where, column, value] = opts
|
|
291
|
+
if (where !== 'row') return
|
|
292
|
+
if (column.options.onclick) {
|
|
293
|
+
$effect(() => on(node, 'click', (e) => column.options.onclick!(e, value())))
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
|
|
297
|
+
function addRowEvents(node: HTMLTableRowElement, ctx: RowCtx<T>) {
|
|
298
|
+
if (table.row?.events.onclick) {
|
|
299
|
+
$effect(() => on(node, 'click', (e) => table.row?.events.onclick!(e, ctx)))
|
|
300
|
+
}
|
|
301
|
+
if (table.row?.events.oncontextmenu) {
|
|
302
|
+
$effect(() => on(node, 'contextmenu', (e) => table.row?.events.oncontextmenu!(e, ctx)))
|
|
303
|
+
}
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
_table = table
|
|
307
|
+
</script>
|
|
308
|
+
|
|
309
|
+
<!---------------------------------------------------->
|
|
310
|
+
|
|
311
|
+
{#if csv !== false}
|
|
312
|
+
{@const exportedColumns =
|
|
313
|
+
csv.columns === false || csv.columns === undefined ? columns.filter((v) => v.id !== '__fixed')
|
|
314
|
+
: csv.columns === true ? [
|
|
315
|
+
...table.positions.fixed.filter(v => v.id !== '__fixed'),
|
|
316
|
+
...table.positions.sticky,
|
|
317
|
+
...table.positions.scroll
|
|
318
|
+
]
|
|
319
|
+
: csv.columns.map(id => table.columns[id])
|
|
320
|
+
}
|
|
321
|
+
{@const exportedData =
|
|
322
|
+
csv.filters === true || csv.filters === undefined ? table.dataState.current
|
|
323
|
+
: table.dataState.origin /* Filtering happens on the row itself via {#if} */
|
|
324
|
+
}
|
|
325
|
+
{@const filters = Array.isArray(csv.filters) ? (csv as { filters: Array<(item: T) => boolean> }).filters : undefined}
|
|
326
|
+
<table bind:this={csvElement} hidden>
|
|
327
|
+
<thead>
|
|
328
|
+
<tr>
|
|
329
|
+
{#each exportedColumns as column}
|
|
330
|
+
<th>{@render column.snippets.title()}</th>
|
|
331
|
+
{/each}
|
|
332
|
+
</tr>
|
|
333
|
+
</thead>
|
|
334
|
+
<tbody>
|
|
335
|
+
{#each exportedData as row, i}
|
|
336
|
+
{@const isSelected = !csv.selected || table.selected.includes(row)}
|
|
337
|
+
{@const isFiltered = filters ? filters.every((fn) => fn(row)) : true}
|
|
338
|
+
{#if isSelected && isFiltered}
|
|
339
|
+
<tr>
|
|
340
|
+
{#each exportedColumns as column}
|
|
341
|
+
<td>
|
|
342
|
+
{#if column.snippets.row}
|
|
343
|
+
{@render column.snippets.row(row, {
|
|
344
|
+
index: i,
|
|
345
|
+
value: column.options.value?.(row),
|
|
346
|
+
columnHovered: false,
|
|
347
|
+
rowHovered: false,
|
|
348
|
+
itemState: {
|
|
349
|
+
index: i,
|
|
350
|
+
dragging: false,
|
|
351
|
+
positioning: false
|
|
352
|
+
} as ItemState<any>,
|
|
353
|
+
selected: false,
|
|
354
|
+
expanded: false
|
|
355
|
+
})}
|
|
356
|
+
{:else}
|
|
357
|
+
{column.options.value?.(row)}
|
|
358
|
+
{/if}
|
|
359
|
+
</td>
|
|
360
|
+
{/each}
|
|
361
|
+
</tr>
|
|
362
|
+
{/if}
|
|
363
|
+
{/each}
|
|
364
|
+
</tbody>
|
|
365
|
+
</table>
|
|
366
|
+
{/if}
|
|
367
|
+
|
|
368
|
+
<svelte:head>
|
|
369
|
+
{@html `<`+`style>${style}</style>`}
|
|
370
|
+
</svelte:head>
|
|
371
|
+
|
|
372
|
+
{#snippet chevronSnippet(rotation: number = 0)}
|
|
373
|
+
<svg
|
|
374
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
375
|
+
width="16"
|
|
376
|
+
height="16"
|
|
377
|
+
viewBox="0 0 16 16"
|
|
378
|
+
style="transform: rotate({rotation}deg)"
|
|
379
|
+
>
|
|
380
|
+
<path
|
|
381
|
+
fill="currentColor"
|
|
382
|
+
d="M3.2 10.26a.75.75 0 0 0 1.06.04L8 6.773l3.74 3.527a.75.75 0 1 0 1.02-1.1l-4.25-4a.75.75 0 0 0-1.02 0l-4.25 4a.75.75 0 0 0-.04 1.06"
|
|
383
|
+
></path>
|
|
384
|
+
</svg>
|
|
385
|
+
{/snippet}
|
|
386
|
+
|
|
387
|
+
{#snippet dragSnippet()}
|
|
388
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 16 16" style="opacity: .3">
|
|
389
|
+
<path
|
|
390
|
+
fill="currentColor"
|
|
391
|
+
d="M5.5 5a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m0 4.5a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3m1.5 3a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0M10.5 5a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3M12 8a1.5 1.5 0 1 1-3 0a1.5 1.5 0 0 1 3 0m-1.5 6a1.5 1.5 0 1 0 0-3a1.5 1.5 0 0 0 0 3"
|
|
392
|
+
></path>
|
|
393
|
+
</svg>
|
|
394
|
+
{/snippet}
|
|
395
|
+
|
|
396
|
+
{#snippet columnsSnippet(
|
|
397
|
+
renderable: (column: ColumnState) => Snippet<[arg0?: any, arg1?: any]> | undefined,
|
|
398
|
+
arg: null | ((column: ColumnState) => any[]) = null,
|
|
399
|
+
where: 'header' | 'row' | 'statusbar'
|
|
400
|
+
)}
|
|
401
|
+
{@const isHeader = where === 'header'}
|
|
402
|
+
{#each fixed as column, i (column)}
|
|
403
|
+
{#if !hidden.includes(column)}
|
|
404
|
+
{@const args = arg ? arg(column) : []}
|
|
405
|
+
{@const sortable = isHeader && column.options.sort && !table.options.reorderable}
|
|
406
|
+
<svelte:element
|
|
407
|
+
this={isHeader ? 'th' : 'td'}
|
|
408
|
+
class={column.options.class ?? ''}
|
|
409
|
+
class:column={true}
|
|
410
|
+
class:sticky={true}
|
|
411
|
+
class:fixed={true}
|
|
412
|
+
use:addRowColumnEvents={[where, column, () => args[1]]}
|
|
413
|
+
data-column={column.id}
|
|
414
|
+
class:pad={(isHeader && column.options.padHeader) || (!isHeader && column.options.padRow)}
|
|
415
|
+
class:header={isHeader}
|
|
416
|
+
class:sortable
|
|
417
|
+
use:conditional={[isHeader, (node) => table.dataState.sortAction(node, column.id)]}
|
|
418
|
+
onpointerenter={() => (hoveredColumn = column)}
|
|
419
|
+
onpointerleave={() => (hoveredColumn = null)}
|
|
420
|
+
>
|
|
421
|
+
{@render renderable(column)?.(args[0], args[1])}
|
|
422
|
+
{#if isHeader && table.dataState.sortby === column.id && sortable}
|
|
423
|
+
<span class="sorting-icon">
|
|
424
|
+
{@render chevronSnippet(table.dataState.sortReverse ? 0 : 180)}
|
|
425
|
+
</span>
|
|
426
|
+
{/if}
|
|
427
|
+
</svelte:element>
|
|
428
|
+
{/if}
|
|
429
|
+
{/each}
|
|
430
|
+
{#each sticky as column, i (column)}
|
|
431
|
+
{#if !hidden.includes(column)}
|
|
432
|
+
{@const args = arg ? arg(column) : []}
|
|
433
|
+
{@const sortable = isHeader && column.options.sort && !table.options.reorderable}
|
|
434
|
+
<svelte:element
|
|
435
|
+
this={isHeader ? 'th' : 'td'}
|
|
436
|
+
class={column.options.class ?? ''}
|
|
437
|
+
class:column={true}
|
|
438
|
+
class:sticky={true}
|
|
439
|
+
use:addRowColumnEvents={[where, column, () => args[1]]}
|
|
440
|
+
use:observeColumnWidth={isHeader}
|
|
441
|
+
data-column={column.id}
|
|
442
|
+
class:pad={(isHeader && column.options.padHeader) || (!isHeader && column.options.padRow)}
|
|
443
|
+
class:header={isHeader}
|
|
444
|
+
class:resizeable={isHeader && column.options.resizeable && table.options.resizeable}
|
|
445
|
+
class:border={i == sticky.length - 1}
|
|
446
|
+
class:sortable
|
|
447
|
+
use:conditional={[isHeader, (node) => table.dataState.sortAction(node, column.id)]}
|
|
448
|
+
onpointerenter={() => (hoveredColumn = column)}
|
|
449
|
+
onpointerleave={() => (hoveredColumn = null)}
|
|
450
|
+
>
|
|
451
|
+
{@render renderable(column)?.(args[0], args[1])}
|
|
452
|
+
{#if isHeader && table.dataState.sortby === column.id && sortable}
|
|
453
|
+
<span class="sorting-icon">
|
|
454
|
+
{@render chevronSnippet(table.dataState.sortReverse ? 0 : 180)}
|
|
455
|
+
</span>
|
|
456
|
+
{/if}
|
|
457
|
+
</svelte:element>
|
|
458
|
+
{/if}
|
|
459
|
+
{/each}
|
|
460
|
+
{#each scrolled as column, i (column)}
|
|
461
|
+
{#if !hidden.includes(column)}
|
|
462
|
+
{@const args = arg ? arg(column) : []}
|
|
463
|
+
{@const sortable = isHeader && column!.options.sort && !table.options.reorderable}
|
|
464
|
+
<svelte:element
|
|
465
|
+
this={isHeader ? 'th' : 'td'}
|
|
466
|
+
class={column.options.class ?? ''}
|
|
467
|
+
class:column={true}
|
|
468
|
+
data-column={column.id}
|
|
469
|
+
class:pad={(isHeader && column.options.padHeader) || (!isHeader && column.options.padRow)}
|
|
470
|
+
use:addRowColumnEvents={[where, column, () => args[1]]}
|
|
471
|
+
use:observeColumnWidth={isHeader}
|
|
472
|
+
class:resizeable={isHeader && column.options.resizeable && table.options.resizeable}
|
|
473
|
+
class:sortable
|
|
474
|
+
use:conditional={[isHeader, (node) => table.dataState.sortAction(node, column.id)]}
|
|
475
|
+
onpointerenter={() => (hoveredColumn = column)}
|
|
476
|
+
onpointerleave={() => (hoveredColumn = null)}
|
|
477
|
+
>
|
|
478
|
+
{@render renderable(column)?.(args[0], args[1])}
|
|
479
|
+
{#if isHeader && table.dataState.sortby === column.id && sortable}
|
|
480
|
+
<span class="sorting-icon">
|
|
481
|
+
{@render chevronSnippet(table.dataState.sortReverse ? 0 : 180)}
|
|
482
|
+
</span>
|
|
483
|
+
{/if}
|
|
484
|
+
</svelte:element>
|
|
485
|
+
{/if}
|
|
486
|
+
{/each}
|
|
487
|
+
{/snippet}
|
|
488
|
+
|
|
489
|
+
{#snippet defaultRow(item: T, ctx: RowColumnCtx<T, any>)}
|
|
490
|
+
{ctx.value}
|
|
491
|
+
{/snippet}
|
|
492
|
+
|
|
493
|
+
{#snippet rowSnippet(item: T, itemState?: ItemState<T>)}
|
|
494
|
+
{@const index = itemState?.index ?? 0}
|
|
495
|
+
|
|
496
|
+
{@const ctx: RowCtx<T> = {
|
|
497
|
+
get index() {
|
|
498
|
+
return index
|
|
499
|
+
},
|
|
500
|
+
get rowHovered() {
|
|
501
|
+
return hoveredRow === item
|
|
502
|
+
},
|
|
503
|
+
get selected() {
|
|
504
|
+
return table.selected?.includes(item)
|
|
505
|
+
},
|
|
506
|
+
set selected(value) {
|
|
507
|
+
value ?
|
|
508
|
+
table.selected!.push(item)
|
|
509
|
+
: table.selected!.splice(table.selected!.indexOf(item), 1)
|
|
510
|
+
},
|
|
511
|
+
get itemState() {
|
|
512
|
+
return itemState
|
|
513
|
+
},
|
|
514
|
+
get expanded() {
|
|
515
|
+
return expandedRow.includes(item)
|
|
516
|
+
},
|
|
517
|
+
set expanded(value) {
|
|
518
|
+
toggleExpand(item, value)
|
|
519
|
+
}
|
|
520
|
+
}}
|
|
521
|
+
|
|
522
|
+
<tr
|
|
523
|
+
aria-rowindex={index + 1}
|
|
524
|
+
style:opacity={itemState?.positioning ? 0 : 1}
|
|
525
|
+
class="row"
|
|
526
|
+
class:dragging={itemState?.dragging}
|
|
527
|
+
class:selected={table.selected?.includes(item)}
|
|
528
|
+
class:first={index === 0}
|
|
529
|
+
class:last={index === virtualization.area.length - 1}
|
|
530
|
+
{...itemState?.dragging ? { 'data-svelte-tably-row': table.cssId } : {}}
|
|
531
|
+
onpointerenter={() => (hoveredRow = item)}
|
|
532
|
+
onpointerleave={() => (hoveredRow = null)}
|
|
533
|
+
use:addRowEvents={ctx}
|
|
534
|
+
onclick={(e) => {
|
|
535
|
+
if (table.expandable?.options.click === true) {
|
|
536
|
+
let target = e.target as HTMLElement
|
|
537
|
+
if (['INPUT', 'TEXTAREA', 'BUTTON', 'A'].includes(target.tagName)) {
|
|
538
|
+
return
|
|
539
|
+
}
|
|
540
|
+
ctx.expanded = !ctx.expanded
|
|
541
|
+
}
|
|
542
|
+
}}
|
|
543
|
+
>
|
|
544
|
+
{@render columnsSnippet(
|
|
545
|
+
(column) => column.snippets.row ?? defaultRow,
|
|
546
|
+
(column) => {
|
|
547
|
+
return [
|
|
548
|
+
item,
|
|
549
|
+
assignDescriptors(
|
|
550
|
+
{
|
|
551
|
+
get value() {
|
|
552
|
+
return column.options.value ? column.options.value(item) : undefined
|
|
553
|
+
},
|
|
554
|
+
get columnHovered() {
|
|
555
|
+
return hoveredColumn === column
|
|
556
|
+
}
|
|
557
|
+
},
|
|
558
|
+
ctx
|
|
559
|
+
)
|
|
560
|
+
]
|
|
561
|
+
},
|
|
562
|
+
'row'
|
|
563
|
+
)}
|
|
564
|
+
{#if table.row?.snippets.context}
|
|
565
|
+
{#if table.row?.snippets.contextHeader || !table.row?.options.context.hover || hoveredRow === item}
|
|
566
|
+
<td
|
|
567
|
+
class="context-col"
|
|
568
|
+
class:hover={!table.row?.snippets.contextHeader && table.row?.options.context.hover}
|
|
569
|
+
class:hidden={table.row?.options.context.hover &&
|
|
570
|
+
table.row?.snippets.contextHeader &&
|
|
571
|
+
hoveredRow !== item}
|
|
572
|
+
>
|
|
573
|
+
{@render table.row?.snippets.context?.(item, ctx)}
|
|
574
|
+
</td>
|
|
575
|
+
{/if}
|
|
576
|
+
{/if}
|
|
577
|
+
</tr>
|
|
578
|
+
|
|
579
|
+
{@const expandableTween = new SizeTween(() => table.expandable && expandedRow.includes(item), {
|
|
580
|
+
min: 1,
|
|
581
|
+
duration: table.expandable?.options.slide.duration,
|
|
582
|
+
easing: table.expandable?.options.slide.easing
|
|
583
|
+
})}
|
|
584
|
+
{#if expandableTween.current > 0}
|
|
585
|
+
<tr class="expandable" style="height: {expandableTween.current}px">
|
|
586
|
+
<td colspan={columns.length} style="height: {expandableTween.current}px">
|
|
587
|
+
<div bind:offsetHeight={expandableTween.size} style="width: {tbody.width - 3}px">
|
|
588
|
+
{@render table.expandable!.snippets.content?.(item, ctx)}
|
|
589
|
+
</div>
|
|
590
|
+
</td>
|
|
591
|
+
</tr>
|
|
592
|
+
{/if}
|
|
593
|
+
{/snippet}
|
|
594
|
+
|
|
595
|
+
<table
|
|
596
|
+
id={table.id}
|
|
597
|
+
data-svelte-tably={table.cssId}
|
|
598
|
+
class="table svelte-tably"
|
|
599
|
+
style="--t: {virtualization.virtualTop}px; --b: {virtualization.virtualBottom}px;"
|
|
600
|
+
aria-rowcount={table.data.length}
|
|
601
|
+
>
|
|
602
|
+
{#if columns.some((v) => v.snippets.header)}
|
|
603
|
+
<thead class="headers" bind:this={elements.headers}>
|
|
604
|
+
<tr>
|
|
605
|
+
{@render columnsSnippet(
|
|
606
|
+
(column) => column.snippets.header,
|
|
607
|
+
() => [
|
|
608
|
+
{
|
|
609
|
+
get header() {
|
|
610
|
+
return true
|
|
611
|
+
},
|
|
612
|
+
get data() {
|
|
613
|
+
return table.data
|
|
614
|
+
}
|
|
615
|
+
}
|
|
616
|
+
],
|
|
617
|
+
'header'
|
|
618
|
+
)}
|
|
619
|
+
{#if table.row?.snippets.contextHeader}
|
|
620
|
+
<th class="context-col">
|
|
621
|
+
{@render table.row?.snippets.contextHeader()}
|
|
622
|
+
</th>
|
|
623
|
+
{/if}
|
|
624
|
+
</tr>
|
|
625
|
+
<tr style="width:400px;background:none;pointer-events:none;"></tr>
|
|
626
|
+
</thead>
|
|
627
|
+
{/if}
|
|
628
|
+
|
|
629
|
+
<tbody
|
|
630
|
+
class="content"
|
|
631
|
+
use:reorderArea={{ axis: 'y', class: table.cssId }}
|
|
632
|
+
bind:this={virtualization.viewport.element}
|
|
633
|
+
onscrollcapture={onscroll}
|
|
634
|
+
bind:clientHeight={virtualization.viewport.height}
|
|
635
|
+
bind:clientWidth={tbody.width}
|
|
636
|
+
>
|
|
637
|
+
{#if table.options.reorderable}
|
|
638
|
+
{@render reorderArea({
|
|
639
|
+
get view() {
|
|
640
|
+
return virtualization.area
|
|
641
|
+
},
|
|
642
|
+
get modify() {
|
|
643
|
+
return table.dataState.origin
|
|
644
|
+
},
|
|
645
|
+
get startIndex() {
|
|
646
|
+
return virtualization.topIndex
|
|
647
|
+
}
|
|
648
|
+
})}
|
|
649
|
+
{:else}
|
|
650
|
+
{#each virtualization.area as item, i (item)}
|
|
651
|
+
{@render rowSnippet(item, { index: i + virtualization.topIndex } as ItemState)}
|
|
652
|
+
{/each}
|
|
653
|
+
{/if}
|
|
654
|
+
</tbody>
|
|
655
|
+
|
|
656
|
+
{#if columns.some((v) => v.snippets.statusbar)}
|
|
657
|
+
<tfoot class="statusbar" bind:this={elements.statusbar}>
|
|
658
|
+
<tr>
|
|
659
|
+
{@render columnsSnippet(
|
|
660
|
+
(column) => column.snippets.statusbar,
|
|
661
|
+
() => [
|
|
662
|
+
{
|
|
663
|
+
get data() {
|
|
664
|
+
return table.data
|
|
665
|
+
}
|
|
666
|
+
}
|
|
667
|
+
],
|
|
668
|
+
'statusbar'
|
|
669
|
+
)}
|
|
670
|
+
</tr>
|
|
671
|
+
<tr style="width:400px;background:none;pointer-events:none;"></tr>
|
|
672
|
+
</tfoot>
|
|
673
|
+
{/if}
|
|
674
|
+
|
|
675
|
+
<caption class="panel" style="width: {panelTween.current}px;">
|
|
676
|
+
{#if properties.panel && properties.panel in table.panels}
|
|
677
|
+
<div
|
|
678
|
+
class="panel-content"
|
|
679
|
+
bind:offsetWidth={panelTween.size}
|
|
680
|
+
in:fly={{ x: 100, easing: sineInOut, duration: 300 }}
|
|
681
|
+
out:fly={{ x: 100, duration: 200, easing: sineInOut }}
|
|
682
|
+
>
|
|
683
|
+
{@render table.panels[properties.panel].children({
|
|
684
|
+
get table() {
|
|
685
|
+
return table
|
|
686
|
+
},
|
|
687
|
+
get data() {
|
|
688
|
+
return table.data
|
|
689
|
+
}
|
|
690
|
+
})}
|
|
691
|
+
</div>
|
|
692
|
+
{/if}
|
|
693
|
+
</caption>
|
|
694
|
+
<caption
|
|
695
|
+
class="backdrop"
|
|
696
|
+
aria-hidden={properties.panel && table.panels[properties.panel]?.backdrop ? false : true}
|
|
697
|
+
>
|
|
698
|
+
<button
|
|
699
|
+
aria-label="Panel backdrop"
|
|
700
|
+
class="btn-backdrop"
|
|
701
|
+
tabindex="-1"
|
|
702
|
+
onclick={() => (properties.panel = undefined)}
|
|
703
|
+
></button>
|
|
704
|
+
</caption>
|
|
705
|
+
</table>
|
|
706
|
+
|
|
707
|
+
{#snippet headerSelected(ctx: HeaderSelectCtx<T>)}
|
|
708
|
+
<input type="checkbox" indeterminate={ctx.indeterminate} bind:checked={ctx.isSelected} />
|
|
709
|
+
{/snippet}
|
|
710
|
+
|
|
711
|
+
{#snippet rowSelected(ctx: RowSelectCtx<T>)}
|
|
712
|
+
<input type="checkbox" bind:checked={ctx.isSelected} tabindex="-1" />
|
|
713
|
+
{/snippet}
|
|
714
|
+
|
|
715
|
+
{#if table.options.select || table.options.reorderable || table.expandable}
|
|
716
|
+
{@const { select, reorderable } = table.options}
|
|
717
|
+
{@const expandable = table.expandable}
|
|
718
|
+
{@const {
|
|
719
|
+
show = 'hover',
|
|
720
|
+
style = 'column',
|
|
721
|
+
rowSnippet = rowSelected,
|
|
722
|
+
headerSnippet = headerSelected
|
|
723
|
+
} = typeof select === 'boolean' ? {} : select}
|
|
724
|
+
{#if show !== 'never' || reorderable || expandable?.options.chevron !== 'never'}
|
|
725
|
+
<Column
|
|
726
|
+
id="__fixed"
|
|
727
|
+
{table}
|
|
728
|
+
fixed
|
|
729
|
+
width={Math.max(
|
|
730
|
+
48,
|
|
731
|
+
0 +
|
|
732
|
+
(select && show !== 'never' ? 34 : 0) +
|
|
733
|
+
(reorderable ? 34 : 0) +
|
|
734
|
+
(expandable && expandable?.options.chevron !== 'never' ? 34 : 0)
|
|
735
|
+
)}
|
|
736
|
+
resizeable={false}
|
|
737
|
+
>
|
|
738
|
+
{#snippet header()}
|
|
739
|
+
<div class="__fixed">
|
|
740
|
+
{#if reorderable}
|
|
741
|
+
<span style="width: 16px; display: flex; align-items: center;"></span>
|
|
742
|
+
{/if}
|
|
743
|
+
{#if select}
|
|
744
|
+
{@render headerSnippet({
|
|
745
|
+
get isSelected() {
|
|
746
|
+
return table.data.length === table.selected?.length && table.data.length > 0
|
|
747
|
+
},
|
|
748
|
+
set isSelected(value) {
|
|
749
|
+
if (value) {
|
|
750
|
+
table.selected = table.data
|
|
751
|
+
} else {
|
|
752
|
+
table.selected = []
|
|
753
|
+
}
|
|
754
|
+
},
|
|
755
|
+
get selected() {
|
|
756
|
+
return table.selected!
|
|
757
|
+
},
|
|
758
|
+
get indeterminate() {
|
|
759
|
+
return (
|
|
760
|
+
(table.selected?.length || 0) > 0 &&
|
|
761
|
+
table.data.length !== table.selected?.length
|
|
762
|
+
)
|
|
763
|
+
}
|
|
764
|
+
})}
|
|
765
|
+
{/if}
|
|
766
|
+
</div>
|
|
767
|
+
{/snippet}
|
|
768
|
+
{#snippet row(item, row)}
|
|
769
|
+
<div class="__fixed">
|
|
770
|
+
{#if reorderable && row.itemState}
|
|
771
|
+
<span style="width: 16px; display: flex; align-items: center;" use:row.itemState.handle>
|
|
772
|
+
{#if (row.rowHovered && !row.itemState.area.isTarget) || row.itemState.dragging}
|
|
773
|
+
{@render dragSnippet()}
|
|
774
|
+
{/if}
|
|
775
|
+
</span>
|
|
776
|
+
{/if}
|
|
777
|
+
{#if select && (row.selected || show === 'always' || (row.rowHovered && show === 'hover') || row.expanded)}
|
|
778
|
+
{@render rowSnippet({
|
|
779
|
+
get isSelected() {
|
|
780
|
+
return row.selected
|
|
781
|
+
},
|
|
782
|
+
set isSelected(value) {
|
|
783
|
+
row.selected = value
|
|
784
|
+
},
|
|
785
|
+
get row() {
|
|
786
|
+
return row
|
|
787
|
+
},
|
|
788
|
+
get item() {
|
|
789
|
+
return item
|
|
790
|
+
},
|
|
791
|
+
get data() {
|
|
792
|
+
return table.data
|
|
793
|
+
}
|
|
794
|
+
})}
|
|
795
|
+
{/if}
|
|
796
|
+
{#if expandable && expandable?.options.chevron !== 'never'}
|
|
797
|
+
<button class="expand-row" tabindex="-1" onclick={() => (row.expanded = !row.expanded)}>
|
|
798
|
+
{#if row.expanded || expandable.options.chevron === 'always' || (row.rowHovered && expandable.options.chevron === 'hover')}
|
|
799
|
+
{@render chevronSnippet(row.expanded ? 180 : 90)}
|
|
800
|
+
{/if}
|
|
801
|
+
</button>
|
|
802
|
+
{/if}
|
|
803
|
+
</div>
|
|
804
|
+
{/snippet}
|
|
805
|
+
</Column>
|
|
806
|
+
{/if}
|
|
807
|
+
{/if}
|
|
808
|
+
|
|
809
|
+
{#if table.options.auto}
|
|
810
|
+
{#each Object.keys(table.data[0] || {}) as key}
|
|
811
|
+
<Column
|
|
812
|
+
id={key}
|
|
813
|
+
value={(r) => r[key]}
|
|
814
|
+
header={capitalize(segmentize(key))}
|
|
815
|
+
sort={typeof table.data[0]?.[key] === 'number' ?
|
|
816
|
+
(a, b) => a - b
|
|
817
|
+
: (a, b) => String(a).localeCompare(String(b))}
|
|
818
|
+
/>
|
|
819
|
+
{/each}
|
|
820
|
+
{/if}
|
|
821
|
+
|
|
822
|
+
{@render content?.({
|
|
823
|
+
Column,
|
|
824
|
+
Panel,
|
|
825
|
+
Expandable,
|
|
826
|
+
Row,
|
|
827
|
+
get table() {
|
|
828
|
+
return table
|
|
829
|
+
}
|
|
830
|
+
})}
|
|
831
|
+
|
|
832
|
+
<!---------------------------------------------------->
|
|
833
|
+
<style>
|
|
834
|
+
.svelte-tably *,
|
|
835
|
+
.svelte-tably {
|
|
836
|
+
box-sizing: border-box;
|
|
837
|
+
background-color: inherit;
|
|
838
|
+
}
|
|
839
|
+
|
|
840
|
+
.context-col {
|
|
841
|
+
display: flex;
|
|
842
|
+
align-items: center;
|
|
843
|
+
justify-content: center;
|
|
844
|
+
position: sticky;
|
|
845
|
+
right: 0;
|
|
846
|
+
height: 100%;
|
|
847
|
+
z-index: 3;
|
|
848
|
+
padding: 0;
|
|
849
|
+
|
|
850
|
+
&.hover {
|
|
851
|
+
position: absolute;
|
|
852
|
+
}
|
|
853
|
+
&.hidden {
|
|
854
|
+
pointer-events: none;
|
|
855
|
+
user-select: none;
|
|
856
|
+
border-left: none;
|
|
857
|
+
background: none;
|
|
858
|
+
> :global(*) {
|
|
859
|
+
opacity: 0;
|
|
860
|
+
}
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
|
|
864
|
+
:global(:root) {
|
|
865
|
+
--tably-color: hsl(0, 0%, 0%);
|
|
866
|
+
--tably-bg: hsl(0, 0%, 100%);
|
|
867
|
+
--tably-statusbar: hsl(0, 0%, 98%);
|
|
868
|
+
|
|
869
|
+
--tably-border: hsl(0, 0%, 90%);
|
|
870
|
+
--tably-border-grid: hsl(0, 0%, 98%);
|
|
871
|
+
|
|
872
|
+
--tably-padding-x: 1rem;
|
|
873
|
+
--tably-padding-y: 0.5rem;
|
|
874
|
+
|
|
875
|
+
--tably-radius: 0.25rem;
|
|
876
|
+
}
|
|
877
|
+
|
|
878
|
+
.svelte-tably {
|
|
879
|
+
position: relative;
|
|
880
|
+
overflow: visible;
|
|
881
|
+
}
|
|
882
|
+
|
|
883
|
+
.expandable {
|
|
884
|
+
position: relative;
|
|
885
|
+
|
|
886
|
+
& > td {
|
|
887
|
+
position: sticky;
|
|
888
|
+
left: 1px;
|
|
889
|
+
> div {
|
|
890
|
+
position: absolute;
|
|
891
|
+
overflow: auto;
|
|
892
|
+
top: -1.5px;
|
|
893
|
+
left: 0;
|
|
894
|
+
}
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
.expand-row {
|
|
899
|
+
display: flex;
|
|
900
|
+
justify-content: center;
|
|
901
|
+
align-items: center;
|
|
902
|
+
padding: 0;
|
|
903
|
+
outline: none;
|
|
904
|
+
border: none;
|
|
905
|
+
cursor: pointer;
|
|
906
|
+
background-color: transparent;
|
|
907
|
+
color: inherit;
|
|
908
|
+
width: 20px;
|
|
909
|
+
height: 100%;
|
|
910
|
+
|
|
911
|
+
> svg {
|
|
912
|
+
transition: transform 0.15s ease;
|
|
913
|
+
}
|
|
914
|
+
}
|
|
915
|
+
|
|
916
|
+
caption {
|
|
917
|
+
all: unset;
|
|
918
|
+
}
|
|
919
|
+
|
|
920
|
+
input[type='checkbox'] {
|
|
921
|
+
width: 18px;
|
|
922
|
+
height: 18px;
|
|
923
|
+
cursor: pointer;
|
|
924
|
+
}
|
|
925
|
+
|
|
926
|
+
button.btn-backdrop {
|
|
927
|
+
outline: none;
|
|
928
|
+
border: none;
|
|
929
|
+
cursor: pointer;
|
|
930
|
+
}
|
|
931
|
+
|
|
932
|
+
.sorting-icon {
|
|
933
|
+
align-items: center;
|
|
934
|
+
justify-items: end;
|
|
935
|
+
margin: 0;
|
|
936
|
+
margin-left: auto;
|
|
937
|
+
> svg {
|
|
938
|
+
transition: transform 0.15s ease;
|
|
939
|
+
}
|
|
940
|
+
}
|
|
941
|
+
|
|
942
|
+
th:not(:last-child) .sorting-icon {
|
|
943
|
+
margin-right: var(--tably-padding-x);
|
|
944
|
+
}
|
|
945
|
+
|
|
946
|
+
.__fixed {
|
|
947
|
+
display: flex;
|
|
948
|
+
align-items: center;
|
|
949
|
+
justify-content: center;
|
|
950
|
+
gap: 0.25rem;
|
|
951
|
+
position: absolute;
|
|
952
|
+
top: 0;
|
|
953
|
+
left: 0;
|
|
954
|
+
right: 0;
|
|
955
|
+
bottom: 0;
|
|
956
|
+
width: 100%;
|
|
957
|
+
}
|
|
958
|
+
|
|
959
|
+
thead {
|
|
960
|
+
position: relative;
|
|
961
|
+
}
|
|
962
|
+
|
|
963
|
+
tbody::before,
|
|
964
|
+
tbody::after,
|
|
965
|
+
selects::before,
|
|
966
|
+
selects::after {
|
|
967
|
+
content: '';
|
|
968
|
+
display: grid;
|
|
969
|
+
min-height: 100%;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
tbody::before,
|
|
973
|
+
selects::before {
|
|
974
|
+
height: var(--t);
|
|
975
|
+
}
|
|
976
|
+
tbody::after,
|
|
977
|
+
selects::after {
|
|
978
|
+
height: var(--b);
|
|
979
|
+
}
|
|
980
|
+
|
|
981
|
+
.row:global(:is(a)) {
|
|
982
|
+
color: inherit;
|
|
983
|
+
text-decoration: inherit;
|
|
984
|
+
}
|
|
985
|
+
|
|
986
|
+
.backdrop {
|
|
987
|
+
position: absolute;
|
|
988
|
+
left: 0px;
|
|
989
|
+
top: 0px;
|
|
990
|
+
bottom: 0px;
|
|
991
|
+
right: 0px;
|
|
992
|
+
background-color: hsla(0, 0%, 0%, 0.3);
|
|
993
|
+
z-index: 3;
|
|
994
|
+
opacity: 1;
|
|
995
|
+
transition: 0.15s ease;
|
|
996
|
+
border: none;
|
|
997
|
+
outline: none;
|
|
998
|
+
cursor: pointer;
|
|
999
|
+
|
|
1000
|
+
> button {
|
|
1001
|
+
position: absolute;
|
|
1002
|
+
left: 0px;
|
|
1003
|
+
top: 0px;
|
|
1004
|
+
bottom: 0px;
|
|
1005
|
+
right: 0px;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
&[aria-hidden='true'] {
|
|
1009
|
+
opacity: 0;
|
|
1010
|
+
pointer-events: none;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
.sticky {
|
|
1015
|
+
position: sticky;
|
|
1016
|
+
/* right: 100px; */
|
|
1017
|
+
z-index: 1;
|
|
1018
|
+
}
|
|
1019
|
+
|
|
1020
|
+
.sticky.border {
|
|
1021
|
+
border-right: 1px solid var(--tably-border);
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.headers > tr > .column {
|
|
1025
|
+
overflow: hidden;
|
|
1026
|
+
padding: var(--tably-padding-y) 0;
|
|
1027
|
+
cursor: default;
|
|
1028
|
+
user-select: none;
|
|
1029
|
+
|
|
1030
|
+
&:last-child {
|
|
1031
|
+
border-right: none;
|
|
1032
|
+
}
|
|
1033
|
+
|
|
1034
|
+
&.sortable {
|
|
1035
|
+
cursor: pointer;
|
|
1036
|
+
}
|
|
1037
|
+
|
|
1038
|
+
&.resizeable {
|
|
1039
|
+
resize: horizontal;
|
|
1040
|
+
}
|
|
1041
|
+
}
|
|
1042
|
+
|
|
1043
|
+
.table {
|
|
1044
|
+
display: grid;
|
|
1045
|
+
height: auto;
|
|
1046
|
+
max-height: 100%;
|
|
1047
|
+
position: relative;
|
|
1048
|
+
|
|
1049
|
+
color: var(--tably-color);
|
|
1050
|
+
background-color: var(--tably-bg);
|
|
1051
|
+
|
|
1052
|
+
grid-template-areas:
|
|
1053
|
+
'headers panel'
|
|
1054
|
+
'rows panel'
|
|
1055
|
+
'statusbar panel';
|
|
1056
|
+
|
|
1057
|
+
grid-template-columns: auto min-content;
|
|
1058
|
+
grid-template-rows: auto 1fr auto;
|
|
1059
|
+
|
|
1060
|
+
border: 1px solid var(--tably-border);
|
|
1061
|
+
border-radius: var(--tably-radius);
|
|
1062
|
+
}
|
|
1063
|
+
|
|
1064
|
+
.headers {
|
|
1065
|
+
display: flex;
|
|
1066
|
+
grid-area: headers;
|
|
1067
|
+
z-index: 2;
|
|
1068
|
+
overflow: hidden;
|
|
1069
|
+
}
|
|
1070
|
+
|
|
1071
|
+
.headers > tr > .column {
|
|
1072
|
+
width: auto !important;
|
|
1073
|
+
border-bottom: 1px solid var(--tably-border);
|
|
1074
|
+
}
|
|
1075
|
+
.headers > tr > .column,
|
|
1076
|
+
.headers > tr > .context-col {
|
|
1077
|
+
border-bottom: 1px solid var(--tably-border);
|
|
1078
|
+
border-left: 1px solid var(--tably-border-grid);
|
|
1079
|
+
}
|
|
1080
|
+
|
|
1081
|
+
.content {
|
|
1082
|
+
display: grid;
|
|
1083
|
+
grid-auto-rows: max-content;
|
|
1084
|
+
|
|
1085
|
+
grid-area: rows;
|
|
1086
|
+
scrollbar-width: thin;
|
|
1087
|
+
overflow: auto;
|
|
1088
|
+
}
|
|
1089
|
+
|
|
1090
|
+
.statusbar {
|
|
1091
|
+
display: flex;
|
|
1092
|
+
grid-area: statusbar;
|
|
1093
|
+
overflow: hidden;
|
|
1094
|
+
background-color: var(--tably-statusbar);
|
|
1095
|
+
}
|
|
1096
|
+
|
|
1097
|
+
.statusbar > tr > .column {
|
|
1098
|
+
border-top: 1px solid var(--tably-border);
|
|
1099
|
+
padding: calc(var(--tably-padding-y) / 2) 0;
|
|
1100
|
+
}
|
|
1101
|
+
|
|
1102
|
+
.headers > tr,
|
|
1103
|
+
.row,
|
|
1104
|
+
.statusbar > tr {
|
|
1105
|
+
display: grid;
|
|
1106
|
+
width: 100%;
|
|
1107
|
+
height: 100%;
|
|
1108
|
+
min-width: max-content;
|
|
1109
|
+
|
|
1110
|
+
& > .column {
|
|
1111
|
+
display: flex;
|
|
1112
|
+
overflow: hidden;
|
|
1113
|
+
|
|
1114
|
+
&:not(.pad),
|
|
1115
|
+
&.pad > :global(*:first-child) {
|
|
1116
|
+
padding-left: var(--tably-padding-x);
|
|
1117
|
+
}
|
|
1118
|
+
}
|
|
1119
|
+
|
|
1120
|
+
& > *:last-child:not(.context-col) {
|
|
1121
|
+
width: 100%;
|
|
1122
|
+
|
|
1123
|
+
&:not(.pad),
|
|
1124
|
+
&.pad > :global(*:first-child) {
|
|
1125
|
+
padding-right: var(--tably-padding-x);
|
|
1126
|
+
}
|
|
1127
|
+
}
|
|
1128
|
+
}
|
|
1129
|
+
|
|
1130
|
+
.row > .column {
|
|
1131
|
+
background-color: var(--tably-bg);
|
|
1132
|
+
&:not(.pad),
|
|
1133
|
+
&.pad > :global(*:first-child) {
|
|
1134
|
+
padding-top: var(--tably-padding-y);
|
|
1135
|
+
padding-bottom: var(--tably-padding-y);
|
|
1136
|
+
}
|
|
1137
|
+
}
|
|
1138
|
+
|
|
1139
|
+
:global(#runic-drag .row) {
|
|
1140
|
+
border: 1px solid var(--tably-border-grid);
|
|
1141
|
+
border-top: 2px solid var(--tably-border-grid);
|
|
1142
|
+
}
|
|
1143
|
+
|
|
1144
|
+
.row > * {
|
|
1145
|
+
border-left: 1px solid var(--tably-border-grid);
|
|
1146
|
+
border-bottom: 1px solid var(--tably-border-grid);
|
|
1147
|
+
}
|
|
1148
|
+
|
|
1149
|
+
.panel {
|
|
1150
|
+
position: relative;
|
|
1151
|
+
grid-area: panel;
|
|
1152
|
+
height: 100%;
|
|
1153
|
+
overflow: hidden;
|
|
1154
|
+
border-left: 1px solid var(--tably-border);
|
|
1155
|
+
|
|
1156
|
+
z-index: 4;
|
|
1157
|
+
|
|
1158
|
+
> .panel-content {
|
|
1159
|
+
position: absolute;
|
|
1160
|
+
top: 0;
|
|
1161
|
+
right: 0;
|
|
1162
|
+
bottom: 0;
|
|
1163
|
+
width: min-content;
|
|
1164
|
+
overflow: auto;
|
|
1165
|
+
scrollbar-width: thin;
|
|
1166
|
+
padding: var(--tably-padding-y) 0;
|
|
1167
|
+
}
|
|
1168
|
+
}
|
|
1169
|
+
</style>
|