@dust-tt/sparkle 0.2.207 → 0.2.210-rc

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 (140) hide show
  1. package/dist/cjs/_index.d.ts +4 -4
  2. package/dist/cjs/components/Checkbox.d.ts +3 -3
  3. package/dist/cjs/components/DataTable.d.ts +6 -2
  4. package/dist/cjs/components/Tree.d.ts +9 -6
  5. package/dist/cjs/components/WindowUtility.d.ts +15 -0
  6. package/dist/cjs/icons/solid/ArrowDownS.d.ts +4 -0
  7. package/dist/cjs/icons/solid/ArrowLeftS.d.ts +4 -0
  8. package/dist/cjs/icons/solid/ArrowRightS.d.ts +4 -0
  9. package/dist/cjs/icons/solid/ArrowUpS.d.ts +4 -0
  10. package/dist/cjs/icons/solid/ChevronDoubleLeft.d.ts +4 -0
  11. package/dist/cjs/icons/solid/ChevronDoubleRight.d.ts +4 -0
  12. package/dist/cjs/icons/solid/Company.d.ts +4 -0
  13. package/dist/cjs/icons/solid/Filter.d.ts +4 -0
  14. package/dist/cjs/icons/solid/Heart.d.ts +4 -0
  15. package/dist/cjs/icons/solid/History.d.ts +4 -0
  16. package/dist/cjs/icons/solid/Home.d.ts +4 -0
  17. package/dist/cjs/icons/solid/MarkPen.d.ts +4 -0
  18. package/dist/cjs/icons/solid/Translate.d.ts +4 -0
  19. package/dist/cjs/icons/solid/index.d.ts +13 -0
  20. package/dist/cjs/icons/stroke/ArrowDownS.d.ts +4 -0
  21. package/dist/cjs/icons/stroke/ArrowLeftS.d.ts +4 -0
  22. package/dist/cjs/icons/stroke/ArrowRightS.d.ts +4 -0
  23. package/dist/cjs/icons/stroke/ArrowUpS.d.ts +4 -0
  24. package/dist/cjs/icons/stroke/ChevronDoubleLeft.d.ts +4 -0
  25. package/dist/cjs/icons/stroke/ChevronDoubleRight.d.ts +4 -0
  26. package/dist/cjs/icons/stroke/Company.d.ts +4 -0
  27. package/dist/cjs/icons/stroke/Filter.d.ts +4 -0
  28. package/dist/cjs/icons/stroke/Heart.d.ts +4 -0
  29. package/dist/cjs/icons/stroke/History.d.ts +4 -0
  30. package/dist/cjs/icons/stroke/Home.d.ts +4 -0
  31. package/dist/cjs/icons/stroke/MarkPen.d.ts +4 -0
  32. package/dist/cjs/icons/stroke/Translate.d.ts +4 -0
  33. package/dist/cjs/icons/stroke/index.d.ts +13 -0
  34. package/dist/cjs/index.js +283 -65
  35. package/dist/cjs/index.js.map +1 -1
  36. package/dist/cjs/stories/Checkbox.stories.d.ts +2 -0
  37. package/dist/cjs/stories/Tree.stories.d.ts +0 -1
  38. package/dist/esm/_index.d.ts +4 -4
  39. package/dist/esm/components/Checkbox.d.ts +3 -3
  40. package/dist/esm/components/DataTable.d.ts +6 -2
  41. package/dist/esm/components/Tree.d.ts +9 -6
  42. package/dist/esm/components/WindowUtility.d.ts +15 -0
  43. package/dist/esm/icons/solid/ArrowDownS.d.ts +4 -0
  44. package/dist/esm/icons/solid/ArrowLeftS.d.ts +4 -0
  45. package/dist/esm/icons/solid/ArrowRightS.d.ts +4 -0
  46. package/dist/esm/icons/solid/ArrowUpS.d.ts +4 -0
  47. package/dist/esm/icons/solid/ChevronDoubleLeft.d.ts +4 -0
  48. package/dist/esm/icons/solid/ChevronDoubleRight.d.ts +4 -0
  49. package/dist/esm/icons/solid/Company.d.ts +4 -0
  50. package/dist/esm/icons/solid/Filter.d.ts +4 -0
  51. package/dist/esm/icons/solid/Heart.d.ts +4 -0
  52. package/dist/esm/icons/solid/History.d.ts +4 -0
  53. package/dist/esm/icons/solid/Home.d.ts +4 -0
  54. package/dist/esm/icons/solid/MarkPen.d.ts +4 -0
  55. package/dist/esm/icons/solid/Translate.d.ts +4 -0
  56. package/dist/esm/icons/solid/index.d.ts +13 -0
  57. package/dist/esm/icons/stroke/ArrowDownS.d.ts +4 -0
  58. package/dist/esm/icons/stroke/ArrowLeftS.d.ts +4 -0
  59. package/dist/esm/icons/stroke/ArrowRightS.d.ts +4 -0
  60. package/dist/esm/icons/stroke/ArrowUpS.d.ts +4 -0
  61. package/dist/esm/icons/stroke/ChevronDoubleLeft.d.ts +4 -0
  62. package/dist/esm/icons/stroke/ChevronDoubleRight.d.ts +4 -0
  63. package/dist/esm/icons/stroke/Company.d.ts +4 -0
  64. package/dist/esm/icons/stroke/Filter.d.ts +4 -0
  65. package/dist/esm/icons/stroke/Heart.d.ts +4 -0
  66. package/dist/esm/icons/stroke/History.d.ts +4 -0
  67. package/dist/esm/icons/stroke/Home.d.ts +4 -0
  68. package/dist/esm/icons/stroke/MarkPen.d.ts +4 -0
  69. package/dist/esm/icons/stroke/Translate.d.ts +4 -0
  70. package/dist/esm/icons/stroke/index.d.ts +13 -0
  71. package/dist/esm/index.js +258 -66
  72. package/dist/esm/index.js.map +1 -1
  73. package/dist/esm/stories/Checkbox.stories.d.ts +2 -0
  74. package/dist/esm/stories/Tree.stories.d.ts +0 -1
  75. package/dist/tsconfig.tsbuildinfo +1 -1
  76. package/package.json +1 -1
  77. package/src/_index.ts +52 -0
  78. package/src/components/Checkbox.tsx +42 -12
  79. package/src/components/DataTable.tsx +125 -91
  80. package/src/components/Tree.tsx +71 -66
  81. package/src/components/WindowUtility.tsx +67 -0
  82. package/src/icons/solid/ArrowDownS.tsx +15 -0
  83. package/src/icons/solid/ArrowLeftS.tsx +15 -0
  84. package/src/icons/solid/ArrowRightS.tsx +15 -0
  85. package/src/icons/solid/ArrowUpS.tsx +15 -0
  86. package/src/icons/solid/ChevronDoubleLeft.tsx +22 -0
  87. package/src/icons/solid/ChevronDoubleRight.tsx +22 -0
  88. package/src/icons/solid/Company.tsx +20 -0
  89. package/src/icons/solid/Filter.tsx +18 -0
  90. package/src/icons/solid/Heart.tsx +18 -0
  91. package/src/icons/solid/History.tsx +18 -0
  92. package/src/icons/solid/Home.tsx +20 -0
  93. package/src/icons/solid/MarkPen.tsx +18 -0
  94. package/src/icons/solid/Translate.tsx +18 -0
  95. package/src/icons/solid/index.ts +14 -0
  96. package/src/icons/src/solid/arrow-down-s.svg +3 -0
  97. package/src/icons/src/solid/arrow-left-s.svg +3 -0
  98. package/src/icons/src/solid/arrow-right-s.svg +3 -0
  99. package/src/icons/src/solid/arrow-up-s.svg +3 -0
  100. package/src/icons/src/solid/chevron-double-left.svg +4 -0
  101. package/src/icons/src/solid/chevron-double-right.svg +4 -0
  102. package/src/icons/src/solid/company.svg +3 -0
  103. package/src/icons/src/solid/filter.svg +3 -0
  104. package/src/icons/src/solid/heart.svg +3 -0
  105. package/src/icons/src/solid/history.svg +3 -0
  106. package/src/icons/src/solid/home.svg +3 -0
  107. package/src/icons/src/solid/mark-pen.svg +3 -0
  108. package/src/icons/src/solid/translate.svg +3 -0
  109. package/src/icons/src/stroke/arrow-down-s.svg +3 -0
  110. package/src/icons/src/stroke/arrow-left-s.svg +3 -0
  111. package/src/icons/src/stroke/arrow-right-s.svg +3 -0
  112. package/src/icons/src/stroke/arrow-up-s.svg +3 -0
  113. package/src/icons/src/stroke/chevron-double-left.svg +4 -0
  114. package/src/icons/src/stroke/chevron-double-right.svg +4 -0
  115. package/src/icons/src/stroke/company.svg +9 -0
  116. package/src/icons/src/stroke/filter.svg +3 -0
  117. package/src/icons/src/stroke/heart.svg +3 -0
  118. package/src/icons/src/stroke/history.svg +3 -0
  119. package/src/icons/src/stroke/home.svg +3 -0
  120. package/src/icons/src/stroke/mark-pen.svg +3 -0
  121. package/src/icons/src/stroke/translate.svg +3 -0
  122. package/src/icons/stroke/ArrowDownS.tsx +15 -0
  123. package/src/icons/stroke/ArrowLeftS.tsx +15 -0
  124. package/src/icons/stroke/ArrowRightS.tsx +15 -0
  125. package/src/icons/stroke/ArrowUpS.tsx +15 -0
  126. package/src/icons/stroke/ChevronDoubleLeft.tsx +16 -0
  127. package/src/icons/stroke/ChevronDoubleRight.tsx +16 -0
  128. package/src/icons/stroke/Company.tsx +24 -0
  129. package/src/icons/stroke/Filter.tsx +15 -0
  130. package/src/icons/stroke/Heart.tsx +20 -0
  131. package/src/icons/stroke/History.tsx +18 -0
  132. package/src/icons/stroke/Home.tsx +20 -0
  133. package/src/icons/stroke/MarkPen.tsx +18 -0
  134. package/src/icons/stroke/Translate.tsx +18 -0
  135. package/src/icons/stroke/index.ts +13 -0
  136. package/src/logo/src/platforms/Zendesk.svg +6 -0
  137. package/src/stories/Checkbox.stories.tsx +63 -2
  138. package/src/stories/Citation.stories.tsx +1 -0
  139. package/src/stories/DataTable.stories.tsx +14 -6
  140. package/src/stories/Tree.stories.tsx +152 -189
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dust-tt/sparkle",
3
- "version": "0.2.207",
3
+ "version": "0.2.210-rc",
4
4
  "scripts": {
5
5
  "build": "rm -rf dist && rollup -c",
6
6
  "build:with-tw-base": "rollup -c --environment INCLUDE_TW_BASE:true",
package/src/_index.ts CHANGED
@@ -252,11 +252,15 @@ import {
252
252
  ArrowDown as ArrowDownIcon,
253
253
  ArrowDownCircle as ArrowDownCircleIcon,
254
254
  ArrowDownOnSquare as ArrowDownOnSquareIcon,
255
+ ArrowDownS as ArrowDownSIcon,
255
256
  ArrowLeft as ArrowLeftIcon,
257
+ ArrowLeftS as ArrowLeftSIcon,
256
258
  ArrowPath as ArrowPathIcon,
257
259
  ArrowRight as ArrowRightIcon,
260
+ ArrowRightS as ArrowRightSIcon,
258
261
  ArrowUp as ArrowUpIcon,
259
262
  ArrowUpOnSquare as ArrowUpOnSquareIcon,
263
+ ArrowUpS as ArrowUpSIcon,
260
264
  Attachment as AttachmentIcon,
261
265
  Backspace as BackspaceIcon,
262
266
  Bookmark as BookmarkIcon,
@@ -269,6 +273,8 @@ import {
269
273
  ChatBubbleThought as ChatBubbleThoughtIcon,
270
274
  Check as CheckIcon,
271
275
  CheckCircle as CheckCircleIcon,
276
+ ChevronDoubleLeft as ChevronDoubleLeftIcon,
277
+ ChevronDoubleRight as ChevronDoubleRightIcon,
272
278
  ChevronDown as ChevronDownIcon,
273
279
  ChevronLeft as ChevronLeftIcon,
274
280
  ChevronRight as ChevronRightIcon,
@@ -285,6 +291,7 @@ import {
285
291
  Cog6Tooth as Cog6ToothIcon,
286
292
  Command as CommandIcon,
287
293
  CommandLine as CommandLineIcon,
294
+ Company as CompanyIcon,
288
295
  Cube as CubeIcon,
289
296
  Dash as DashIcon,
290
297
  Document as DocumentIcon,
@@ -299,6 +306,7 @@ import {
299
306
  ExternalLink as ExternalLinkIcon,
300
307
  Eye as EyeIcon,
301
308
  EyeSlash as EyeSlashIcon,
309
+ Filter as FilterIcon,
302
310
  Fire as FireIcon,
303
311
  Flag as FlagIcon,
304
312
  Folder as FolderIcon,
@@ -309,8 +317,11 @@ import {
309
317
  Grab as GrabIcon,
310
318
  HandThumbDown as HandThumbDownIcon,
311
319
  HandThumbUp as HandThumbUpIcon,
320
+ Heart as HeartIcon,
312
321
  HeartAlt as HeartAltIcon,
313
322
  Hexagon as HexagonIcon,
323
+ History as HistoryIcon,
324
+ Home as HomeIcon,
314
325
  Image as ImageIcon,
315
326
  InformationCircle as InformationCircleIcon,
316
327
  Key as KeyIcon,
@@ -325,6 +336,7 @@ import {
325
336
  Logout as LogoutIcon,
326
337
  Magic as MagicIcon,
327
338
  MagnifyingGlass as MagnifyingGlassIcon,
339
+ MarkPen as MarkPenIcon,
328
340
  Menu as MenuIcon,
329
341
  More as MoreIcon,
330
342
  MovingMail as MovingMailIcon,
@@ -357,6 +369,7 @@ import {
357
369
  Template as TemplateIcon,
358
370
  TestTube as TestTubeIcon,
359
371
  Time as TimeIcon,
372
+ Translate as TranslateIcon,
360
373
  Trash as TrashIcon,
361
374
  Triangle as TriangleIcon,
362
375
  User as UserIcon,
@@ -372,11 +385,15 @@ export {
372
385
  ArrowDownCircleIcon,
373
386
  ArrowDownIcon,
374
387
  ArrowDownOnSquareIcon,
388
+ ArrowDownSIcon,
375
389
  ArrowLeftIcon,
390
+ ArrowLeftSIcon,
376
391
  ArrowPathIcon,
377
392
  ArrowRightIcon,
393
+ ArrowRightSIcon,
378
394
  ArrowUpIcon,
379
395
  ArrowUpOnSquareIcon,
396
+ ArrowUpSIcon,
380
397
  AttachmentIcon,
381
398
  BackspaceIcon,
382
399
  BookmarkIcon,
@@ -389,6 +406,8 @@ export {
389
406
  ChatBubbleThoughtIcon,
390
407
  CheckCircleIcon,
391
408
  CheckIcon,
409
+ ChevronDoubleLeftIcon,
410
+ ChevronDoubleRightIcon,
392
411
  ChevronDownIcon,
393
412
  ChevronLeftIcon,
394
413
  ChevronRightIcon,
@@ -405,6 +424,7 @@ export {
405
424
  Cog6ToothIcon,
406
425
  CommandIcon,
407
426
  CommandLineIcon,
427
+ CompanyIcon,
408
428
  CubeIcon,
409
429
  DashIcon,
410
430
  DocumentDuplicateIcon,
@@ -419,6 +439,7 @@ export {
419
439
  ExternalLinkIcon,
420
440
  EyeIcon,
421
441
  EyeSlashIcon,
442
+ FilterIcon,
422
443
  FireIcon,
423
444
  FlagIcon,
424
445
  FolderIcon,
@@ -430,7 +451,10 @@ export {
430
451
  HandThumbDownIcon,
431
452
  HandThumbUpIcon,
432
453
  HeartAltIcon,
454
+ HeartIcon,
433
455
  HexagonIcon,
456
+ HistoryIcon,
457
+ HomeIcon,
434
458
  ImageIcon,
435
459
  InformationCircleIcon,
436
460
  KeyIcon,
@@ -445,6 +469,7 @@ export {
445
469
  LogoutIcon,
446
470
  MagicIcon,
447
471
  MagnifyingGlassIcon,
472
+ MarkPenIcon,
448
473
  MenuIcon,
449
474
  MoreIcon,
450
475
  MovingMailIcon,
@@ -477,6 +502,7 @@ export {
477
502
  TemplateIcon,
478
503
  TestTubeIcon,
479
504
  TimeIcon,
505
+ TranslateIcon,
480
506
  TrashIcon,
481
507
  TriangleIcon,
482
508
  UserArrowIcon,
@@ -492,11 +518,15 @@ import {
492
518
  ArrowDown as ArrowDownStrokeIcon,
493
519
  ArrowDownCircle as ArrowDownCircleStrokeIcon,
494
520
  ArrowDownOnSquare as ArrowDownOnSquareStrokeIcon,
521
+ ArrowDownS as ArrowDownSStrokeIcon,
495
522
  ArrowLeft as ArrowLeftStrokeIcon,
523
+ ArrowLeftS as ArrowLeftSStrokeIcon,
496
524
  ArrowPath as ArrowPathStrokeIcon,
497
525
  ArrowRight as ArrowRightStrokeIcon,
526
+ ArrowRightS as ArrowRightSStrokeIcon,
498
527
  ArrowUp as ArrowUpStrokeIcon,
499
528
  ArrowUpOnSquare as ArrowUpOnSquareStrokeIcon,
529
+ ArrowUpS as ArrowUpSStrokeIcon,
500
530
  Attachment as AttachmentStrokeIcon,
501
531
  Backspace as BackspaceStrokeIcon,
502
532
  Bookmark as BookmarkStrokeIcon,
@@ -509,6 +539,8 @@ import {
509
539
  ChatBubbleThought as ChatBubbleThoughtStrokeIcon,
510
540
  Check as CheckStrokeIcon,
511
541
  CheckCircle as CheckCircleStrokeIcon,
542
+ ChevronDoubleLeft as ChevronDoubleLeftStrokeIcon,
543
+ ChevronDoubleRight as ChevronDoubleRightStrokeIcon,
512
544
  ChevronDown as ChevronDownStrokeIcon,
513
545
  ChevronLeft as ChevronLeftStrokeIcon,
514
546
  ChevronRight as ChevronRightStrokeIcon,
@@ -525,6 +557,7 @@ import {
525
557
  Cog6Tooth as Cog6ToothStrokeIcon,
526
558
  Command as CommandStrokeIcon,
527
559
  CommandLine as CommandLineStrokeIcon,
560
+ Company as CompanyStrokeIcon,
528
561
  Cube as CubeStrokeIcon,
529
562
  Dash as DashStrokeIcon,
530
563
  Document as DocumentStrokeIcon,
@@ -539,6 +572,7 @@ import {
539
572
  ExternalLink as ExternalLinkStrokeIcon,
540
573
  Eye as EyeStrokeIcon,
541
574
  EyeSlash as EyeSlashStrokeIcon,
575
+ Filter as FilterStrokeIcon,
542
576
  Fire as FireStrokeIcon,
543
577
  Flag as FlagStrokeIcon,
544
578
  Folder as FolderStrokeIcon,
@@ -549,8 +583,11 @@ import {
549
583
  Grab as GrabStrokeIcon,
550
584
  HandThumbDown as HandThumbDownStrokeIcon,
551
585
  HandThumbUp as HandThumbUpStrokeIcon,
586
+ Heart as HeartStrokeIcon,
552
587
  HeartAlt as HeartAltStrokeIcon,
553
588
  Hexagon as HexagonStrokeIcon,
589
+ History as HistoryStrokeIcon,
590
+ Home as HomeStrokeIcon,
554
591
  Image as ImageStrokeIcon,
555
592
  InformationCircle as InformationCircleStrokeIcon,
556
593
  Key as KeyStrokeIcon,
@@ -565,6 +602,7 @@ import {
565
602
  Logout as LogoutStrokeIcon,
566
603
  Magic as MagicStrokeIcon,
567
604
  MagnifyingGlass as MagnifyingGlassStrokeIcon,
605
+ MarkPen as MarkPenStrokeIcon,
568
606
  Menu as MenuStrokeIcon,
569
607
  More as MoreStrokeIcon,
570
608
  MovingMail as MovingMailStrokeIcon,
@@ -597,6 +635,7 @@ import {
597
635
  Template as TemplateStrokeIcon,
598
636
  TestTube as TestTubeStrokeIcon,
599
637
  Time as TimeStrokeIcon,
638
+ Translate as TranslateStrokeIcon,
600
639
  Trash as TrashStrokeIcon,
601
640
  Triangle as TriangleStrokeIcon,
602
641
  User as UserStrokeIcon,
@@ -611,11 +650,15 @@ import {
611
650
  export {
612
651
  ArrowDownCircleStrokeIcon,
613
652
  ArrowDownOnSquareStrokeIcon,
653
+ ArrowDownSStrokeIcon,
614
654
  ArrowDownStrokeIcon,
655
+ ArrowLeftSStrokeIcon,
615
656
  ArrowLeftStrokeIcon,
616
657
  ArrowPathStrokeIcon,
658
+ ArrowRightSStrokeIcon,
617
659
  ArrowRightStrokeIcon,
618
660
  ArrowUpOnSquareStrokeIcon,
661
+ ArrowUpSStrokeIcon,
619
662
  ArrowUpStrokeIcon,
620
663
  AttachmentStrokeIcon,
621
664
  BackspaceStrokeIcon,
@@ -629,6 +672,8 @@ export {
629
672
  ChatBubbleThoughtStrokeIcon,
630
673
  CheckCircleStrokeIcon,
631
674
  CheckStrokeIcon,
675
+ ChevronDoubleLeftStrokeIcon,
676
+ ChevronDoubleRightStrokeIcon,
632
677
  ChevronDownStrokeIcon,
633
678
  ChevronLeftStrokeIcon,
634
679
  ChevronRightStrokeIcon,
@@ -645,6 +690,7 @@ export {
645
690
  Cog6ToothStrokeIcon,
646
691
  CommandLineStrokeIcon,
647
692
  CommandStrokeIcon,
693
+ CompanyStrokeIcon,
648
694
  CubeStrokeIcon,
649
695
  DashStrokeIcon,
650
696
  DocumentDuplicateStrokeIcon,
@@ -659,6 +705,7 @@ export {
659
705
  ExternalLinkStrokeIcon,
660
706
  EyeSlashStrokeIcon,
661
707
  EyeStrokeIcon,
708
+ FilterStrokeIcon,
662
709
  FireStrokeIcon,
663
710
  FlagStrokeIcon,
664
711
  FolderOpenStrokeIcon,
@@ -670,7 +717,10 @@ export {
670
717
  HandThumbDownStrokeIcon,
671
718
  HandThumbUpStrokeIcon,
672
719
  HeartAltStrokeIcon,
720
+ HeartStrokeIcon,
673
721
  HexagonStrokeIcon,
722
+ HistoryStrokeIcon,
723
+ HomeStrokeIcon,
674
724
  ImageStrokeIcon,
675
725
  InformationCircleStrokeIcon,
676
726
  KeyStrokeIcon,
@@ -685,6 +735,7 @@ export {
685
735
  LogoutStrokeIcon,
686
736
  MagicStrokeIcon,
687
737
  MagnifyingGlassStrokeIcon,
738
+ MarkPenStrokeIcon,
688
739
  MenuStrokeIcon,
689
740
  MoreStrokeIcon,
690
741
  MovingMailStrokeIcon,
@@ -717,6 +768,7 @@ export {
717
768
  TemplateStrokeIcon,
718
769
  TestTubeStrokeIcon,
719
770
  TimeStrokeIcon,
771
+ TranslateStrokeIcon,
720
772
  TrashStrokeIcon,
721
773
  TriangleStrokeIcon,
722
774
  UserArrowStrokeIcon,
@@ -7,23 +7,42 @@ import { Icon } from "./Icon";
7
7
 
8
8
  export interface CheckboxProps {
9
9
  variant?: "selectable" | "checkable";
10
- checked: boolean;
10
+ size?: "xs" | "sm";
11
+ checked?: true | false | "partial";
11
12
  disabled?: boolean;
12
- partialChecked?: boolean;
13
13
  onChange: (checked: boolean) => void;
14
14
  className?: string;
15
15
  }
16
16
 
17
17
  export function Checkbox({
18
18
  variant = "selectable",
19
- checked,
19
+ checked = false,
20
+ size = "sm",
20
21
  onChange,
21
22
  className = "",
22
23
  disabled,
23
- partialChecked,
24
24
  }: CheckboxProps) {
25
+ let isChecked: boolean;
26
+ let isPartialChecked: boolean;
27
+ switch (checked) {
28
+ case true:
29
+ isChecked = true;
30
+ isPartialChecked = false;
31
+ break;
32
+ case false:
33
+ isChecked = false;
34
+ isPartialChecked = false;
35
+ break;
36
+ case "partial":
37
+ isChecked = true;
38
+ isPartialChecked = true;
39
+ break;
40
+ default:
41
+ throw new Error("Invalid checked prop");
42
+ }
43
+
25
44
  const baseStyleClasses = {
26
- base: "s-border s-justify-center s-w-5 s-h-5 s-rounded-md s-flex s-items-center s-transition-colors s-duration-300 s-ease-out",
45
+ base: "s-border s-justify-center s-flex s-items-center s-transition-colors s-duration-300 s-ease-out",
27
46
  idle: "s-bg-structure-50 s-border-element-600 s-cursor-pointer",
28
47
  hover:
29
48
  "hover:s-border-action-500 hover:s-bg-action-200 hover:s-text-white/100",
@@ -37,6 +56,11 @@ export function Checkbox({
37
56
  },
38
57
  };
39
58
 
59
+ const baseSizeClasses = {
60
+ xs: "s-w-4 s-h-4 s-rounded",
61
+ sm: "s-w-5 s-h-5 s-rounded-md",
62
+ };
63
+
40
64
  const checkedIndicatorClasses = {
41
65
  base: "s-transition s-duration-300 s-ease-in-out",
42
66
  selected: "s-opacity-100 s-bg-action-500 dark:s-bg-action-500-dark",
@@ -45,9 +69,15 @@ export function Checkbox({
45
69
  disabled: "s-opacity-100 s-bg-element-500 dark:s-bg-element-500-dark",
46
70
  };
47
71
 
72
+ const sizeStyles = {
73
+ xs: { width: "12px", height: "12px", borderRadius: "2px" },
74
+ sm: { width: "14px", height: "14px", borderRadius: "3px" },
75
+ };
76
+
48
77
  const combinedBaseClasses = classNames(
49
78
  baseStyleClasses.base,
50
- checked || partialChecked ? "s-text-white" : "s-text-white/0",
79
+ baseSizeClasses[size],
80
+ isChecked || isPartialChecked ? "s-text-white" : "s-text-white/0",
51
81
  disabled ? baseStyleClasses.disabled : baseStyleClasses.idle,
52
82
  !disabled ? baseStyleClasses.hover : "",
53
83
  disabled ? baseStyleClasses.dark.disabled : baseStyleClasses.dark.base,
@@ -58,18 +88,18 @@ export function Checkbox({
58
88
  const combinedCheckedIndicatorClasses = classNames(
59
89
  checkedIndicatorClasses.base,
60
90
  disabled ? checkedIndicatorClasses.disabled : "",
61
- checked && !partialChecked && !disabled
91
+ isChecked && !isPartialChecked && !disabled
62
92
  ? checkedIndicatorClasses.selected
63
93
  : "",
64
- partialChecked && !disabled ? checkedIndicatorClasses.partialChecked : "",
65
- !checked && !disabled ? checkedIndicatorClasses.unselected : ""
94
+ isPartialChecked && !disabled ? checkedIndicatorClasses.partialChecked : "",
95
+ !isChecked && !disabled ? checkedIndicatorClasses.unselected : ""
66
96
  );
67
97
 
68
98
  return (
69
99
  <label>
70
100
  <input
71
101
  type="checkbox"
72
- checked={checked}
102
+ checked={isChecked}
73
103
  onChange={(e) => onChange && onChange(e.target.checked)}
74
104
  className="s-hidden"
75
105
  disabled={disabled}
@@ -77,11 +107,11 @@ export function Checkbox({
77
107
  <div className={classNames(combinedBaseClasses, "s-relative")}>
78
108
  <div
79
109
  className={combinedCheckedIndicatorClasses}
80
- style={{ width: "14px", height: "14px", borderRadius: "3px" }}
110
+ style={sizeStyles[size]}
81
111
  />
82
112
  {variant === "checkable" && (
83
113
  <div className="s-absolute">
84
- <Icon visual={partialChecked ? Dash : Check} size="xs" />
114
+ <Icon visual={isPartialChecked ? Dash : Check} size="xs" />
85
115
  </div>
86
116
  )}
87
117
  </div>
@@ -11,11 +11,12 @@ import {
11
11
  import React, { ReactNode, useEffect, useState } from "react";
12
12
 
13
13
  import { DropdownItemProps } from "@sparkle/components/DropdownMenu";
14
- import { Avatar, DropdownMenu, MoreIcon } from "@sparkle/index";
14
+ import { Avatar, DropdownMenu, IconButton, MoreIcon } from "@sparkle/index";
15
15
  import { ArrowDownIcon, ArrowUpIcon } from "@sparkle/index";
16
16
  import { classNames } from "@sparkle/lib/utils";
17
17
 
18
18
  import { Icon } from "./Icon";
19
+ import { breakpoints, useWindowSize } from "./WindowUtility";
19
20
 
20
21
  interface TBaseData {
21
22
  onClick?: () => void;
@@ -36,6 +37,16 @@ interface DataTableProps<TData extends TBaseData, TValue> {
36
37
  columnsBreakpoints?: ColumnBreakpoint;
37
38
  }
38
39
 
40
+ function shouldRenderColumn(
41
+ windowWidth: number,
42
+ breakpoint?: keyof typeof breakpoints
43
+ ): boolean {
44
+ if (!breakpoint) {
45
+ return true;
46
+ }
47
+ return windowWidth >= breakpoints[breakpoint];
48
+ }
49
+
39
50
  export function DataTable<TData extends TBaseData, TValue>({
40
51
  data,
41
52
  columns,
@@ -45,6 +56,7 @@ export function DataTable<TData extends TBaseData, TValue>({
45
56
  initialColumnOrder,
46
57
  columnsBreakpoints = {},
47
58
  }: DataTableProps<TData, TValue>) {
59
+ const windowSize = useWindowSize();
48
60
  const [sorting, setSorting] = useState<SortingState>(
49
61
  initialColumnOrder ?? []
50
62
  );
@@ -75,43 +87,49 @@ export function DataTable<TData extends TBaseData, TValue>({
75
87
  <DataTable.Header>
76
88
  {table.getHeaderGroups().map((headerGroup) => (
77
89
  <DataTable.Row key={headerGroup.id}>
78
- {headerGroup.headers.map((header) => (
79
- <DataTable.Head
80
- key={header.id}
81
- onClick={header.column.getToggleSortingHandler()}
82
- className={classNames(
83
- header.column.getCanSort() ? "s-cursor-pointer" : "",
84
- columnsBreakpoints[header.id]
85
- ? `s-hidden ${columnsBreakpoints[header.id]}:s-block`
86
- : ""
87
- )}
88
- >
89
- <div className="s-flex s-items-center s-space-x-1 s-whitespace-nowrap">
90
- {flexRender(
91
- header.column.columnDef.header,
92
- header.getContext()
90
+ {headerGroup.headers.map((header) => {
91
+ const breakpoint = columnsBreakpoints[header.id];
92
+ if (
93
+ !windowSize.width ||
94
+ !shouldRenderColumn(windowSize.width, breakpoint)
95
+ ) {
96
+ return null;
97
+ }
98
+ return (
99
+ <DataTable.Head
100
+ key={header.id}
101
+ onClick={header.column.getToggleSortingHandler()}
102
+ className={classNames(
103
+ header.column.getCanSort() ? "s-cursor-pointer" : ""
93
104
  )}
94
- {header.column.getCanSort() && (
95
- <Icon
96
- visual={
97
- header.column.getIsSorted() === "asc"
98
- ? ArrowUpIcon
99
- : header.column.getIsSorted() === "desc"
100
- ? ArrowDownIcon
101
- : ArrowDownIcon
102
- }
103
- size="xs"
104
- className={classNames(
105
- "s-ml-1",
106
- header.column.getIsSorted()
107
- ? "s-opacity-100"
108
- : "s-opacity-0"
109
- )}
110
- />
111
- )}
112
- </div>
113
- </DataTable.Head>
114
- ))}
105
+ >
106
+ <div className="s-flex s-items-center s-space-x-1 s-whitespace-nowrap">
107
+ {flexRender(
108
+ header.column.columnDef.header,
109
+ header.getContext()
110
+ )}
111
+ {header.column.getCanSort() && (
112
+ <Icon
113
+ visual={
114
+ header.column.getIsSorted() === "asc"
115
+ ? ArrowUpIcon
116
+ : header.column.getIsSorted() === "desc"
117
+ ? ArrowDownIcon
118
+ : ArrowDownIcon
119
+ }
120
+ size="xs"
121
+ className={classNames(
122
+ "s-ml-1",
123
+ header.column.getIsSorted()
124
+ ? "s-opacity-100"
125
+ : "s-opacity-0"
126
+ )}
127
+ />
128
+ )}
129
+ </div>
130
+ </DataTable.Head>
131
+ );
132
+ })}
115
133
  </DataTable.Row>
116
134
  ))}
117
135
  </DataTable.Header>
@@ -122,18 +140,20 @@ export function DataTable<TData extends TBaseData, TValue>({
122
140
  onClick={row.original.onClick}
123
141
  moreMenuItems={row.original.moreMenuItems}
124
142
  >
125
- {row.getVisibleCells().map((cell) => (
126
- <DataTable.Cell
127
- key={cell.id}
128
- className={classNames(
129
- columnsBreakpoints[cell.column.id]
130
- ? `s-hidden ${columnsBreakpoints[cell.column.id]}:s-block`
131
- : ""
132
- )}
133
- >
134
- {flexRender(cell.column.columnDef.cell, cell.getContext())}
135
- </DataTable.Cell>
136
- ))}
143
+ {row.getVisibleCells().map((cell) => {
144
+ const breakpoint = columnsBreakpoints[cell.column.id];
145
+ if (
146
+ !windowSize.width ||
147
+ !shouldRenderColumn(windowSize.width, breakpoint)
148
+ ) {
149
+ return null;
150
+ }
151
+ return (
152
+ <DataTable.Cell key={cell.id}>
153
+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
154
+ </DataTable.Cell>
155
+ );
156
+ })}
137
157
  </DataTable.Row>
138
158
  ))}
139
159
  </DataTable.Body>
@@ -225,23 +245,23 @@ DataTable.Row = function Row({
225
245
  return (
226
246
  <tr
227
247
  className={classNames(
228
- "s-border-b s-border-structure-200 s-text-sm",
229
- onClick ? "s-cursor-pointer hover:s-bg-gray-50" : "",
248
+ "s-group s-border-b s-border-structure-200 s-text-sm s-transition-colors s-duration-300 s-ease-out",
249
+ onClick ? "s-cursor-pointer hover:s-bg-structure-50" : "",
230
250
  className || ""
231
251
  )}
232
252
  onClick={onClick ? onClick : undefined}
233
253
  {...props}
234
254
  >
235
255
  {children}
236
- {moreMenuItems && (
237
- <td className="s-w-1 s-cursor-pointer s-pl-1 s-text-element-600">
238
- <DropdownMenu className="s-flex">
256
+ <td className="s-w-1 s-cursor-pointer s-pl-1 s-text-element-600">
257
+ {moreMenuItems && (
258
+ <DropdownMenu className="s-mr-1.5 s-flex">
239
259
  <DropdownMenu.Button
240
260
  onClick={(e) => {
241
261
  e.stopPropagation();
242
262
  }}
243
263
  >
244
- <Icon visual={MoreIcon} size="sm" />
264
+ <IconButton icon={MoreIcon} size="sm" variant="tertiary" />
245
265
  </DropdownMenu.Button>
246
266
  <DropdownMenu.Items origin="topRight" width={220}>
247
267
  {moreMenuItems?.map((item, index) => (
@@ -249,12 +269,31 @@ DataTable.Row = function Row({
249
269
  ))}
250
270
  </DropdownMenu.Items>
251
271
  </DropdownMenu>
252
- </td>
253
- )}
272
+ )}
273
+ </td>
254
274
  </tr>
255
275
  );
256
276
  };
257
- interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
277
+
278
+ interface CellProps extends React.HTMLAttributes<HTMLTableCellElement> {
279
+ children: ReactNode;
280
+ }
281
+
282
+ DataTable.Cell = function Cell({ children, className, ...props }: CellProps) {
283
+ return (
284
+ <td
285
+ className={classNames(
286
+ "s-h-12 s-whitespace-nowrap s-pl-1.5 s-text-element-800",
287
+ className || ""
288
+ )}
289
+ {...props}
290
+ >
291
+ {children}
292
+ </td>
293
+ );
294
+ };
295
+
296
+ interface CellContentProps extends React.TdHTMLAttributes<HTMLDivElement> {
258
297
  avatarUrl?: string;
259
298
  icon?: React.ComponentType<{ className?: string }>;
260
299
  iconClassName?: string;
@@ -263,7 +302,7 @@ interface CellProps extends React.TdHTMLAttributes<HTMLTableCellElement> {
263
302
  description?: string;
264
303
  }
265
304
 
266
- DataTable.Cell = function Cell({
305
+ DataTable.CellContent = function CellContent({
267
306
  children,
268
307
  className,
269
308
  avatarUrl,
@@ -272,44 +311,39 @@ DataTable.Cell = function Cell({
272
311
  iconClassName,
273
312
  description,
274
313
  ...props
275
- }: CellProps) {
314
+ }: CellContentProps) {
276
315
  return (
277
- <td
278
- className={classNames(
279
- "s-whitespace-nowrap s-py-2 s-pl-0.5 s-text-element-800",
280
- className || ""
281
- )}
316
+ <div
317
+ className={classNames("s-flex s-items-center s-py-2", className || "")}
282
318
  {...props}
283
319
  >
320
+ {avatarUrl && (
321
+ <Avatar
322
+ visual={avatarUrl}
323
+ size="xs"
324
+ className="s-mr-2"
325
+ isRounded={roundedAvatar ?? false}
326
+ />
327
+ )}
328
+ {icon && (
329
+ <Icon
330
+ visual={icon}
331
+ size="sm"
332
+ className={classNames(
333
+ "s-mr-2 s-text-element-600",
334
+ iconClassName || ""
335
+ )}
336
+ />
337
+ )}
284
338
  <div className="s-flex">
285
- {avatarUrl && (
286
- <Avatar
287
- visual={avatarUrl}
288
- size="xs"
289
- className="s-mr-2"
290
- isRounded={roundedAvatar ?? false}
291
- />
339
+ <span className="s-text-sm s-text-element-800">{children}</span>
340
+ {description && (
341
+ <span className="s-pl-2 s-text-sm s-text-element-600">
342
+ {description}
343
+ </span>
292
344
  )}
293
- {icon && (
294
- <Icon
295
- visual={icon}
296
- size="sm"
297
- className={classNames(
298
- "s-mr-2 s-text-element-600",
299
- iconClassName || ""
300
- )}
301
- />
302
- )}
303
- <div className="s-flex">
304
- <span className="s-text-sm s-text-element-800">{children}</span>
305
- {description && (
306
- <span className="s-pl-2 s-text-sm s-text-element-600">
307
- {description}
308
- </span>
309
- )}
310
- </div>
311
345
  </div>
312
- </td>
346
+ </div>
313
347
  );
314
348
  };
315
349