@marimo-team/islands 0.23.11-dev24 → 0.23.11-dev26

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.
@@ -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-Cw3yT99u.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-CPhtKPn4.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
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@marimo-team/islands",
3
- "version": "0.23.11-dev24",
3
+ "version": "0.23.11-dev26",
4
4
  "main": "dist/main.js",
5
5
  "types": "dist/index.d.ts",
6
6
  "type": "module",
@@ -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: getMeta(key),
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
 
@@ -11,6 +11,7 @@ declare module "@tanstack/react-table" {
11
11
  dataType?: DataType;
12
12
  filterType?: FilterType;
13
13
  minFractionDigits?: number;
14
+ width?: number;
14
15
  }
15
16
  }
16
17
 
@@ -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 max-w-[300px] outline-hidden border-r border-r-border/75",
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
  }
@@ -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,