@jinaan/uikit 0.1.40 → 0.1.41

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jinaan/uikit",
3
- "version": "0.1.40",
3
+ "version": "0.1.41",
4
4
  "description": "Reusable React and Tailwind UI components for Jinaan projects.",
5
5
  "license": "UNLICENSED",
6
6
  "type": "module",
@@ -125,6 +125,8 @@ interface DataTableProps<T> {
125
125
  filters?: DataTableFilter<T>[];
126
126
  toolbarStart?: ReactNode;
127
127
  toolbarEnd?: ReactNode;
128
+ /** Show the "Columns" visibility/reorder picker in the toolbar. Default true. */
129
+ columnPicker?: boolean;
128
130
 
129
131
  tabs?: TabDef[];
130
132
  activeTab?: string;
@@ -211,6 +213,7 @@ export function DataTable<T>({
211
213
  filters,
212
214
  toolbarStart,
213
215
  toolbarEnd,
216
+ columnPicker = true,
214
217
  tabs,
215
218
  activeTab,
216
219
  onTabChange,
@@ -484,84 +487,86 @@ export function DataTable<T>({
484
487
  />
485
488
  )}
486
489
  {toolbarStart}
487
- <DropdownMenu>
488
- <DropdownMenuTrigger asChild>
489
- <Button
490
- variant="secondary"
491
- size="md"
492
- leadingIcon={<ColumnsIcon />}
493
- trailingIcon={<DropdownMenuChevron />}
494
- >
495
- Columns
496
- </Button>
497
- </DropdownMenuTrigger>
498
- <DropdownMenuContent align="end" className="w-54">
499
- <DropdownMenuLabel className="text-[13px]">Active columns</DropdownMenuLabel>
500
- {visibleColumns.map((c) => {
501
- const pinned = isPinned(c);
502
- return (
503
- <DropdownMenuCheckboxItem
504
- key={c.id}
505
- checked
506
- draggable={!pinned}
507
- onDragStart={(e) => {
508
- if (pinned) {
509
- e.preventDefault();
510
- return;
511
- }
512
- e.dataTransfer.effectAllowed = "move";
513
- e.dataTransfer.setData("text/plain", c.id);
514
- setDragId(c.id);
515
- }}
516
- onDragOver={(e) => {
517
- if (dragId) {
518
- e.preventDefault();
519
- moveBefore(dragId, c.id);
520
- }
521
- }}
522
- onDrop={(e) => e.preventDefault()}
523
- onDragEnd={() => setDragId(null)}
524
- onCheckedChange={(next) => {
525
- if (!next && !pinned) {
526
- setHidden((prev) => ({ ...prev, [c.id]: true }));
527
- }
528
- }}
529
- onSelect={(e) => e.preventDefault()}
530
- className="justify-between"
531
- >
532
- <span className="truncate">{c.header}</span>
533
- {pinned ? (
534
- <Lock className="size-3.5 shrink-0 text-subtle" aria-hidden />
535
- ) : (
536
- <DotsSixVertical
537
- aria-hidden
538
- className={cn(
539
- "size-3.5 shrink-0",
540
- dragId === c.id ? "text-primary" : "text-subtle",
541
- )}
542
- />
543
- )}
544
- </DropdownMenuCheckboxItem>
545
- );
546
- })}
547
- {hiddenColumns.length > 0 ? (
548
- <>
549
- <DropdownMenuSeparator />
550
- <DropdownMenuLabel className="text-[13px]">Available columns</DropdownMenuLabel>
551
- {hiddenColumns.map((c) => (
490
+ {columnPicker && (
491
+ <DropdownMenu>
492
+ <DropdownMenuTrigger asChild>
493
+ <Button
494
+ variant="secondary"
495
+ size="md"
496
+ leadingIcon={<ColumnsIcon />}
497
+ trailingIcon={<DropdownMenuChevron />}
498
+ >
499
+ Columns
500
+ </Button>
501
+ </DropdownMenuTrigger>
502
+ <DropdownMenuContent align="end" className="w-54">
503
+ <DropdownMenuLabel className="text-[13px]">Active columns</DropdownMenuLabel>
504
+ {visibleColumns.map((c) => {
505
+ const pinned = isPinned(c);
506
+ return (
552
507
  <DropdownMenuCheckboxItem
553
508
  key={c.id}
554
- checked={false}
555
- onCheckedChange={() => showColumn(c.id)}
509
+ checked
510
+ draggable={!pinned}
511
+ onDragStart={(e) => {
512
+ if (pinned) {
513
+ e.preventDefault();
514
+ return;
515
+ }
516
+ e.dataTransfer.effectAllowed = "move";
517
+ e.dataTransfer.setData("text/plain", c.id);
518
+ setDragId(c.id);
519
+ }}
520
+ onDragOver={(e) => {
521
+ if (dragId) {
522
+ e.preventDefault();
523
+ moveBefore(dragId, c.id);
524
+ }
525
+ }}
526
+ onDrop={(e) => e.preventDefault()}
527
+ onDragEnd={() => setDragId(null)}
528
+ onCheckedChange={(next) => {
529
+ if (!next && !pinned) {
530
+ setHidden((prev) => ({ ...prev, [c.id]: true }));
531
+ }
532
+ }}
556
533
  onSelect={(e) => e.preventDefault()}
534
+ className="justify-between"
557
535
  >
558
- {c.header}
536
+ <span className="truncate">{c.header}</span>
537
+ {pinned ? (
538
+ <Lock className="size-3.5 shrink-0 text-subtle" aria-hidden />
539
+ ) : (
540
+ <DotsSixVertical
541
+ aria-hidden
542
+ className={cn(
543
+ "size-3.5 shrink-0",
544
+ dragId === c.id ? "text-primary" : "text-subtle",
545
+ )}
546
+ />
547
+ )}
559
548
  </DropdownMenuCheckboxItem>
560
- ))}
561
- </>
562
- ) : null}
563
- </DropdownMenuContent>
564
- </DropdownMenu>
549
+ );
550
+ })}
551
+ {hiddenColumns.length > 0 ? (
552
+ <>
553
+ <DropdownMenuSeparator />
554
+ <DropdownMenuLabel className="text-[13px]">Available columns</DropdownMenuLabel>
555
+ {hiddenColumns.map((c) => (
556
+ <DropdownMenuCheckboxItem
557
+ key={c.id}
558
+ checked={false}
559
+ onCheckedChange={() => showColumn(c.id)}
560
+ onSelect={(e) => e.preventDefault()}
561
+ >
562
+ {c.header}
563
+ </DropdownMenuCheckboxItem>
564
+ ))}
565
+ </>
566
+ ) : null}
567
+ </DropdownMenuContent>
568
+ </DropdownMenu>
569
+ )}
565
570
  {filters && filters.length > 0 ? (
566
571
  <DropdownMenu>
567
572
  <DropdownMenuTrigger asChild>