@marimo-team/islands 0.24.1-dev109 → 0.24.1-dev110
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/{common-qgnc1X0K.js → common-DTE0vt-W.js} +5574 -5471
- package/dist/main.js +6174 -6167
- package/dist/{reveal-component-CPbame7x.js → reveal-component-CW9RWIRA.js} +438 -438
- package/package.json +1 -1
- package/src/components/data-table/__tests__/column-explorer.test.tsx +61 -2
- package/src/components/data-table/__tests__/column-visibility-dropdown.test.tsx +130 -1
- package/src/components/data-table/__tests__/useColumnVisibility.test.ts +153 -1
- package/src/components/data-table/column-explorer-panel/column-explorer.tsx +54 -25
- package/src/components/data-table/column-visibility-dropdown.tsx +62 -14
- package/src/components/data-table/hooks/use-column-visibility.ts +76 -0
- package/src/components/data-table/show-only-column-button.tsx +58 -0
|
@@ -54,3 +54,79 @@ export function getColumnCountForDisplay<TData>(
|
|
|
54
54
|
hiddenColumns: counts.hidden,
|
|
55
55
|
};
|
|
56
56
|
}
|
|
57
|
+
|
|
58
|
+
export function getShowOnlyVisibility<TData>(
|
|
59
|
+
table: Table<TData>,
|
|
60
|
+
columnIds: string[],
|
|
61
|
+
): VisibilityState {
|
|
62
|
+
const showOnlySet = new Set(columnIds);
|
|
63
|
+
const visibility: VisibilityState = {};
|
|
64
|
+
|
|
65
|
+
for (const column of table.getAllLeafColumns()) {
|
|
66
|
+
if (!column.getCanHide()) {
|
|
67
|
+
continue;
|
|
68
|
+
}
|
|
69
|
+
visibility[column.id] = showOnlySet.has(column.id);
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
return visibility;
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function applyShowOnlyColumns<TData>(
|
|
76
|
+
table: Table<TData>,
|
|
77
|
+
columnIds: string[],
|
|
78
|
+
): void {
|
|
79
|
+
table.setColumnVisibility((previous) => ({
|
|
80
|
+
...previous,
|
|
81
|
+
...getShowOnlyVisibility(table, columnIds),
|
|
82
|
+
}));
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
export interface ShowOnlyColumnState {
|
|
86
|
+
visibleHideableColumnIds: readonly string[];
|
|
87
|
+
hideableColumnIdSet: ReadonlySet<string>;
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
export function getShowOnlyColumnState<TData>(
|
|
91
|
+
table: Table<TData>,
|
|
92
|
+
): ShowOnlyColumnState {
|
|
93
|
+
const hideableIds: string[] = [];
|
|
94
|
+
const visibleHideableColumnIds: string[] = [];
|
|
95
|
+
|
|
96
|
+
for (const column of table.getAllLeafColumns()) {
|
|
97
|
+
if (!column.getCanHide()) {
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
hideableIds.push(column.id);
|
|
101
|
+
if (column.getIsVisible()) {
|
|
102
|
+
visibleHideableColumnIds.push(column.id);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
return {
|
|
107
|
+
visibleHideableColumnIds,
|
|
108
|
+
hideableColumnIdSet: new Set(hideableIds),
|
|
109
|
+
};
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function isShowingOnlyColumns(
|
|
113
|
+
state: ShowOnlyColumnState,
|
|
114
|
+
columnIds: readonly string[],
|
|
115
|
+
): boolean {
|
|
116
|
+
const targetIds = new Set(
|
|
117
|
+
columnIds.filter((id) => state.hideableColumnIdSet.has(id)),
|
|
118
|
+
);
|
|
119
|
+
|
|
120
|
+
if (state.visibleHideableColumnIds.length !== targetIds.size) {
|
|
121
|
+
return false;
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
return state.visibleHideableColumnIds.every((id) => targetIds.has(id));
|
|
125
|
+
}
|
|
126
|
+
|
|
127
|
+
export function isShowingOnly<TData>(
|
|
128
|
+
table: Table<TData>,
|
|
129
|
+
columnIds: string[],
|
|
130
|
+
): boolean {
|
|
131
|
+
return isShowingOnlyColumns(getShowOnlyColumnState(table), columnIds);
|
|
132
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
/* Copyright 2026 Marimo. All rights reserved. */
|
|
2
|
+
"use no memo";
|
|
3
|
+
|
|
4
|
+
import type { Table } from "@tanstack/react-table";
|
|
5
|
+
import { ScanEyeIcon } from "lucide-react";
|
|
6
|
+
import { Button } from "@/components/ui/button";
|
|
7
|
+
import { Tooltip } from "@/components/ui/tooltip";
|
|
8
|
+
import { cn } from "@/utils/cn";
|
|
9
|
+
import { applyShowOnlyColumns } from "./hooks/use-column-visibility";
|
|
10
|
+
|
|
11
|
+
export const SHOW_ONLY_COLUMN_LABEL = "Show only this column";
|
|
12
|
+
|
|
13
|
+
interface ShowOnlyColumnButtonProps<TData> {
|
|
14
|
+
table: Table<TData>;
|
|
15
|
+
columnIds: string[];
|
|
16
|
+
disabled: boolean;
|
|
17
|
+
className?: string;
|
|
18
|
+
iconClassName?: string;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export function ShowOnlyColumnButton<TData>({
|
|
22
|
+
table,
|
|
23
|
+
columnIds,
|
|
24
|
+
disabled,
|
|
25
|
+
className,
|
|
26
|
+
iconClassName = "h-3 w-3",
|
|
27
|
+
}: ShowOnlyColumnButtonProps<TData>) {
|
|
28
|
+
return (
|
|
29
|
+
<Tooltip content={SHOW_ONLY_COLUMN_LABEL} delayDuration={400}>
|
|
30
|
+
<Button
|
|
31
|
+
type="button"
|
|
32
|
+
variant="text"
|
|
33
|
+
size="icon"
|
|
34
|
+
aria-label={SHOW_ONLY_COLUMN_LABEL}
|
|
35
|
+
aria-disabled={disabled}
|
|
36
|
+
tabIndex={disabled ? -1 : 0}
|
|
37
|
+
className={cn(
|
|
38
|
+
"h-6 w-6 hover:bg-muted text-muted-foreground hover:text-primary",
|
|
39
|
+
disabled && "opacity-50",
|
|
40
|
+
className,
|
|
41
|
+
)}
|
|
42
|
+
onPointerDown={(event) => {
|
|
43
|
+
event.stopPropagation();
|
|
44
|
+
}}
|
|
45
|
+
onClick={(event) => {
|
|
46
|
+
event.preventDefault();
|
|
47
|
+
event.stopPropagation();
|
|
48
|
+
if (disabled) {
|
|
49
|
+
return;
|
|
50
|
+
}
|
|
51
|
+
applyShowOnlyColumns(table, columnIds);
|
|
52
|
+
}}
|
|
53
|
+
>
|
|
54
|
+
<ScanEyeIcon className={iconClassName} strokeWidth={2.5} />
|
|
55
|
+
</Button>
|
|
56
|
+
</Tooltip>
|
|
57
|
+
);
|
|
58
|
+
}
|