@marimo-team/islands 0.23.11-dev23 → 0.23.11-dev25
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/{code-visibility-elFBcBvs.js → code-visibility-Qkh2E7Cp.js} +44 -31
- package/dist/main.js +947 -944
- package/dist/{reveal-component-BcklswWX.js → reveal-component-D6n0D5SX.js} +1 -1
- package/package.json +1 -1
- package/src/components/data-table/__tests__/columns.test.tsx +20 -0
- package/src/components/data-table/columns.tsx +16 -1
- package/src/components/data-table/filters/types.ts +1 -0
- package/src/components/data-table/renderers.tsx +5 -1
- package/src/components/editor/header/__tests__/status.test.tsx +0 -4
- package/src/components/editor/header/status.tsx +2 -3
- package/src/core/websocket/__tests__/useMarimoKernelConnection.test.ts +0 -13
- package/src/core/websocket/types.ts +0 -1
- package/src/core/websocket/useMarimoKernelConnection.tsx +0 -14
- package/src/plugins/impl/DataTablePlugin.tsx +8 -0
|
@@ -9,7 +9,7 @@ import { t as require_compiler_runtime } from "./compiler-runtime-CEbnTgxf.js";
|
|
|
9
9
|
import { lt as kioskModeAtom } from "./html-to-image-BJbLjZyG.js";
|
|
10
10
|
import "./chunk-5FQGJX7Z-BbqSm5gU.js";
|
|
11
11
|
import { u as createLucideIcon } from "./dist-Dk6PV_d3.js";
|
|
12
|
-
import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, in as Expand, ot as Panel, rn as EyeOff, s as SlideSidebar, sn as Code, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-
|
|
12
|
+
import { a as DEFAULT_SLIDE_TYPE, c as Slide, ct as PanelResizeHandle, i as DEFAULT_DECK_TRANSITION, in as Expand, ot as Panel, rn as EyeOff, s as SlideSidebar, sn as Code, st as PanelGroup, t as useNotebookCodeAvailable } from "./code-visibility-Qkh2E7Cp.js";
|
|
13
13
|
import { X as useDebouncedCallback } from "./input-Cn-SZdXY.js";
|
|
14
14
|
import "./toDate-B4-pUFYh.js";
|
|
15
15
|
import "./react-dom-BTJzcVJ9.js";
|
package/package.json
CHANGED
|
@@ -1082,3 +1082,23 @@ describe("renderCellValue with datetime values", () => {
|
|
|
1082
1082
|
});
|
|
1083
1083
|
});
|
|
1084
1084
|
});
|
|
1085
|
+
|
|
1086
|
+
test("column_widths sets fixed size and meta.width", () => {
|
|
1087
|
+
const cols = generateColumns({
|
|
1088
|
+
rowHeaders: [],
|
|
1089
|
+
selection: null,
|
|
1090
|
+
fieldTypes: [
|
|
1091
|
+
["a", ["number", "int64"]],
|
|
1092
|
+
["b", ["string", "str"]],
|
|
1093
|
+
],
|
|
1094
|
+
columnWidths: { a: 120 },
|
|
1095
|
+
});
|
|
1096
|
+
const a = cols.find((c) => c.id === "a");
|
|
1097
|
+
const b = cols.find((c) => c.id === "b");
|
|
1098
|
+
expect(a?.size).toBe(120);
|
|
1099
|
+
expect(a?.minSize).toBe(120);
|
|
1100
|
+
expect(a?.maxSize).toBe(120);
|
|
1101
|
+
expect(a?.meta?.width).toBe(120);
|
|
1102
|
+
expect(b?.size).toBeUndefined();
|
|
1103
|
+
expect(b?.meta?.width).toBeUndefined();
|
|
1104
|
+
});
|
|
@@ -118,6 +118,7 @@ export function generateColumns<T>({
|
|
|
118
118
|
showDataTypes,
|
|
119
119
|
calculateTopKRows,
|
|
120
120
|
fractionDigitsByColumn,
|
|
121
|
+
columnWidths,
|
|
121
122
|
}: {
|
|
122
123
|
rowHeaders: FieldTypesWithExternalType;
|
|
123
124
|
selection: DataTableSelection;
|
|
@@ -129,6 +130,7 @@ export function generateColumns<T>({
|
|
|
129
130
|
showDataTypes?: boolean;
|
|
130
131
|
calculateTopKRows?: CalculateTopKRows;
|
|
131
132
|
fractionDigitsByColumn?: Record<string, number>;
|
|
133
|
+
columnWidths?: Record<string, number>;
|
|
132
134
|
}): ColumnDef<T>[] {
|
|
133
135
|
// Row-headers are typically index columns
|
|
134
136
|
const rowHeadersSet = new Set(rowHeaders.map(([columnName]) => columnName));
|
|
@@ -311,7 +313,20 @@ export function generateColumns<T>({
|
|
|
311
313
|
// Can only sort if key is defined
|
|
312
314
|
// For example, unnamed index columns, won't be sortable
|
|
313
315
|
enableSorting: !!key,
|
|
314
|
-
meta:
|
|
316
|
+
meta: {
|
|
317
|
+
...getMeta(key),
|
|
318
|
+
width: columnWidths?.[key],
|
|
319
|
+
},
|
|
320
|
+
// size seeds the width before measurement; minSize/maxSize pin
|
|
321
|
+
// getSize() to the fixed width so the per-paint measurement writeback
|
|
322
|
+
// cannot drift the header width or sticky-pin offsets.
|
|
323
|
+
...(columnWidths?.[key] !== undefined
|
|
324
|
+
? {
|
|
325
|
+
size: columnWidths[key],
|
|
326
|
+
minSize: columnWidths[key],
|
|
327
|
+
maxSize: columnWidths[key],
|
|
328
|
+
}
|
|
329
|
+
: {}),
|
|
315
330
|
}),
|
|
316
331
|
);
|
|
317
332
|
|
|
@@ -141,6 +141,7 @@ export const DataTableBody = <TData,>({
|
|
|
141
141
|
const renderCells = (cells: Cell<TData, unknown>[]) => {
|
|
142
142
|
return cells.map((cell) => {
|
|
143
143
|
const { className, style: pinningstyle } = getPinningStyles(cell.column);
|
|
144
|
+
const fixedWidth = cell.column.columnDef.meta?.width;
|
|
144
145
|
const style = Object.assign(
|
|
145
146
|
{},
|
|
146
147
|
cell.getUserStyling?.() || {},
|
|
@@ -153,7 +154,8 @@ export const DataTableBody = <TData,>({
|
|
|
153
154
|
{...getCellDomProps(cell.id)}
|
|
154
155
|
key={cell.id}
|
|
155
156
|
className={cn(
|
|
156
|
-
"whitespace-pre truncate
|
|
157
|
+
"whitespace-pre truncate outline-hidden border-r border-r-border/75",
|
|
158
|
+
!fixedWidth && "max-w-[300px]",
|
|
157
159
|
cell.column.getColumnWrapping &&
|
|
158
160
|
cell.column.getColumnWrapping?.() === "wrap" &&
|
|
159
161
|
COLUMN_WRAPPING_STYLES,
|
|
@@ -297,6 +299,7 @@ function getPinningStyles<TData>(
|
|
|
297
299
|
isPinned === "left" && column.getIsLastColumn("left");
|
|
298
300
|
const isFirstRightPinnedColumn =
|
|
299
301
|
isPinned === "right" && column.getIsFirstColumn("right");
|
|
302
|
+
const fixedWidth = column.columnDef.meta?.width;
|
|
300
303
|
|
|
301
304
|
return {
|
|
302
305
|
className: cn(isPinned && "bg-inherit", "shadow-r z-10"),
|
|
@@ -313,6 +316,7 @@ function getPinningStyles<TData>(
|
|
|
313
316
|
position: isPinned ? "sticky" : "relative",
|
|
314
317
|
zIndex: isPinned ? 1 : 0,
|
|
315
318
|
width: column.getSize(),
|
|
319
|
+
...(fixedWidth ? { minWidth: fixedWidth, maxWidth: fixedWidth } : {}),
|
|
316
320
|
},
|
|
317
321
|
};
|
|
318
322
|
}
|
|
@@ -67,10 +67,6 @@ describe("StatusOverlay disconnect indicator", () => {
|
|
|
67
67
|
});
|
|
68
68
|
|
|
69
69
|
it.each([
|
|
70
|
-
[
|
|
71
|
-
WebSocketClosedReason.MALFORMED_QUERY,
|
|
72
|
-
"the kernel did not recognize a request; please file a bug with marimo",
|
|
73
|
-
],
|
|
74
70
|
[
|
|
75
71
|
WebSocketClosedReason.KERNEL_STARTUP_ERROR,
|
|
76
72
|
"Failed to start kernel sandbox",
|
|
@@ -22,9 +22,8 @@ export const StatusOverlay: React.FC<{
|
|
|
22
22
|
const { mode } = useAtomValue(viewStateAtom);
|
|
23
23
|
const isClosed = connection.state === WebSocketState.CLOSED;
|
|
24
24
|
const isOpen = connection.state === WebSocketState.OPEN;
|
|
25
|
-
// Only KERNEL_DISCONNECTED is recoverable by a retry.
|
|
26
|
-
//
|
|
27
|
-
// fail the same way.
|
|
25
|
+
// Only KERNEL_DISCONNECTED is recoverable by a retry. KERNEL_STARTUP_ERROR
|
|
26
|
+
// would deterministically fail the same way.
|
|
28
27
|
const canReconnect =
|
|
29
28
|
isClosed && connection.code === WebSocketClosedReason.KERNEL_DISCONNECTED;
|
|
30
29
|
|
|
@@ -32,7 +32,6 @@ describe("classifyCloseEvent", () => {
|
|
|
32
32
|
|
|
33
33
|
describe("terminal closes (server-initiated)", () => {
|
|
34
34
|
it.each([
|
|
35
|
-
"MARIMO_WRONG_KERNEL_ID",
|
|
36
35
|
"MARIMO_NO_FILE_KEY",
|
|
37
36
|
"MARIMO_NO_SESSION_ID",
|
|
38
37
|
"MARIMO_NO_SESSION",
|
|
@@ -49,18 +48,6 @@ describe("classifyCloseEvent", () => {
|
|
|
49
48
|
}
|
|
50
49
|
});
|
|
51
50
|
|
|
52
|
-
it("MARIMO_MALFORMED_QUERY → terminal but does NOT close transport", () => {
|
|
53
|
-
const decision = classify("MARIMO_MALFORMED_QUERY");
|
|
54
|
-
expect(decision.kind).toBe("terminal");
|
|
55
|
-
expect(decision.status).toMatchObject({
|
|
56
|
-
state: WebSocketState.CLOSED,
|
|
57
|
-
code: WebSocketClosedReason.MALFORMED_QUERY,
|
|
58
|
-
});
|
|
59
|
-
if (decision.kind === "terminal") {
|
|
60
|
-
expect(decision.closeTransport).toBe(false);
|
|
61
|
-
}
|
|
62
|
-
});
|
|
63
|
-
|
|
64
51
|
it("MARIMO_KERNEL_STARTUP_ERROR → terminal + closeTransport", () => {
|
|
65
52
|
const decision = classify("MARIMO_KERNEL_STARTUP_ERROR");
|
|
66
53
|
expect(decision.kind).toBe("terminal");
|
|
@@ -82,12 +82,10 @@ const SUPPORTS_LAZY_KERNELS = true;
|
|
|
82
82
|
// (marimo/_server/api/endpoints/ws_endpoint.py and ws/*.py). Keep in sync with
|
|
83
83
|
// the backend literals.
|
|
84
84
|
export type CloseReason =
|
|
85
|
-
| "MARIMO_WRONG_KERNEL_ID"
|
|
86
85
|
| "MARIMO_NO_FILE_KEY"
|
|
87
86
|
| "MARIMO_NO_SESSION_ID"
|
|
88
87
|
| "MARIMO_NO_SESSION"
|
|
89
88
|
| "MARIMO_SHUTDOWN"
|
|
90
|
-
| "MARIMO_MALFORMED_QUERY"
|
|
91
89
|
| "MARIMO_KERNEL_STARTUP_ERROR"
|
|
92
90
|
| typeof TRANSPORT_EXHAUSTED_REASON;
|
|
93
91
|
|
|
@@ -107,7 +105,6 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
|
107
105
|
reason: "kernel not found",
|
|
108
106
|
},
|
|
109
107
|
};
|
|
110
|
-
case "MARIMO_WRONG_KERNEL_ID":
|
|
111
108
|
case "MARIMO_NO_FILE_KEY":
|
|
112
109
|
case "MARIMO_NO_SESSION_ID":
|
|
113
110
|
case "MARIMO_NO_SESSION":
|
|
@@ -121,17 +118,6 @@ export function classifyCloseEvent(event: { reason?: string }): CloseDecision {
|
|
|
121
118
|
},
|
|
122
119
|
closeTransport: true,
|
|
123
120
|
};
|
|
124
|
-
case "MARIMO_MALFORMED_QUERY":
|
|
125
|
-
return {
|
|
126
|
-
kind: "terminal",
|
|
127
|
-
status: {
|
|
128
|
-
state: WebSocketState.CLOSED,
|
|
129
|
-
code: WebSocketClosedReason.MALFORMED_QUERY,
|
|
130
|
-
reason:
|
|
131
|
-
"the kernel did not recognize a request; please file a bug with marimo",
|
|
132
|
-
},
|
|
133
|
-
closeTransport: false,
|
|
134
|
-
};
|
|
135
121
|
case "MARIMO_KERNEL_STARTUP_ERROR":
|
|
136
122
|
return {
|
|
137
123
|
kind: "terminal",
|
|
@@ -195,6 +195,7 @@ interface Data<T> {
|
|
|
195
195
|
hiddenColumns?: string[];
|
|
196
196
|
textJustifyColumns?: Record<string, "left" | "center" | "right">;
|
|
197
197
|
wrappedColumns?: string[];
|
|
198
|
+
columnWidths?: Record<string, number>;
|
|
198
199
|
headerTooltip?: Record<string, string>;
|
|
199
200
|
totalColumns: number;
|
|
200
201
|
maxColumns: number | "all";
|
|
@@ -274,6 +275,9 @@ export const DataTablePlugin = createPlugin<S>("marimo-table")
|
|
|
274
275
|
.record(z.string(), z.enum(["left", "center", "right"]))
|
|
275
276
|
.optional(),
|
|
276
277
|
wrappedColumns: z.array(z.string()).optional(),
|
|
278
|
+
columnWidths: z
|
|
279
|
+
.record(z.string(), z.number().int().positive())
|
|
280
|
+
.optional(),
|
|
277
281
|
headerTooltip: z.record(z.string(), z.string()).optional(),
|
|
278
282
|
fieldTypes: columnToFieldTypesSchema.nullish(),
|
|
279
283
|
totalColumns: z.number(),
|
|
@@ -848,6 +852,7 @@ const DataTableComponent = ({
|
|
|
848
852
|
hiddenColumns,
|
|
849
853
|
textJustifyColumns,
|
|
850
854
|
wrappedColumns,
|
|
855
|
+
columnWidths,
|
|
851
856
|
headerTooltip,
|
|
852
857
|
totalColumns,
|
|
853
858
|
get_row_ids,
|
|
@@ -935,6 +940,7 @@ const DataTableComponent = ({
|
|
|
935
940
|
const memoizedRowHeaders = useDeepCompareMemoize(rowHeaders);
|
|
936
941
|
const memoizedTextJustifyColumns = useDeepCompareMemoize(textJustifyColumns);
|
|
937
942
|
const memoizedWrappedColumns = useDeepCompareMemoize(wrappedColumns);
|
|
943
|
+
const memoizedColumnWidths = useDeepCompareMemoize(columnWidths);
|
|
938
944
|
const memoizedChartSpecModel = useDeepCompareMemoize(chartSpecModel);
|
|
939
945
|
const fractionDigitsByColumn = useDeepCompareMemoize(computedFractionDigits);
|
|
940
946
|
const shownColumns = memoizedClampedFieldTypes.length;
|
|
@@ -953,6 +959,7 @@ const DataTableComponent = ({
|
|
|
953
959
|
fieldTypes: memoizedClampedFieldTypes,
|
|
954
960
|
textJustifyColumns: memoizedTextJustifyColumns,
|
|
955
961
|
wrappedColumns: memoizedWrappedColumns,
|
|
962
|
+
columnWidths: memoizedColumnWidths,
|
|
956
963
|
headerTooltip: headerTooltip,
|
|
957
964
|
// Only show data types if they are explicitly set
|
|
958
965
|
showDataTypes: showDataTypes,
|
|
@@ -967,6 +974,7 @@ const DataTableComponent = ({
|
|
|
967
974
|
memoizedClampedFieldTypes,
|
|
968
975
|
memoizedTextJustifyColumns,
|
|
969
976
|
memoizedWrappedColumns,
|
|
977
|
+
memoizedColumnWidths,
|
|
970
978
|
headerTooltip,
|
|
971
979
|
calculate_top_k_rows,
|
|
972
980
|
fractionDigitsByColumn,
|