forge
Explore
Log in

Don't you dare go Hollow

📊 restyle DataTable and drop density + resize

Browse files at this commit

83a0fdab88eabbdf833bc0e7c75a2b1714273582Burak BoduroğluParent: 72a2390
  • refactor
    • 📊 restyle DataTable and drop density + resize
Show full message
refactor: 📊 restyle DataTable and drop density + resize
- headers Title Case (drop uppercase/bold) → medium weight, muted, tracking-normal
- cells tabular-nums for aligned digits without a mono font; remove zebra striping
- lighten sticky frozen-column seam: clean border + softer shadow
- remove column resizing (handles, sizing state, width persistence) and row density toggle
- simplify table-preferences to visibility-only; drop density/reset i18n keys
- search + columns button: rounded-full pill → rounded-lg
- refresh ui-redesign-tokens doc + ui-conventions skill; sync .codex mirror
.claude/skills/ui-conventions/SKILL.mdmodified+1 -1
@@ -46,7 +46,7 @@ Active project reference docs (read the relevant one before changing that area):
46 ## Tables46 ## Tables
47 47
48 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.48 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.
49-- Actions columns use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"İŞLEMLER"`.49+- Actions columns stay fixed at `w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap` to prevent localized headers like `"İŞLEMLER"` from changing their size.
50 - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages.50 - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages.
51 - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally).51 - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally).
52 - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may.52 - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may.
.codex/skills/ui-conventions/SKILL.mdmodified+1 -1
@@ -46,7 +46,7 @@ Active project reference docs (read the relevant one before changing that area):
46 ## Tables46 ## Tables
47 47
48 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.48 - Application tables must use `src/components/ui/data-table.tsx` `DataTable`.
49-- Actions columns use `w-28 min-w-[7rem] text-center whitespace-nowrap` to prevent truncation of localized headers like `"İŞLEMLER"`.49+- Actions columns stay fixed at `w-[110px] min-w-[110px] max-w-[110px] h-[45px] text-center whitespace-nowrap` to prevent localized headers like `"İŞLEMLER"` from changing their size.
50 - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages.50 - Table-page headers fold into the `DataTable` title/description/actions area; do not render a separate `PageHeader` above table-primary pages.
51 - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally).51 - Search inputs, dropdown filters, filter buttons, and toolbar actions share the same height/radius (`h-9 rounded-lg` unless the shared component changes the standard globally).
52 - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may.52 - Pages/domain components must not import or render `Table` primitives directly; only the `DataTable` wrapper and table primitive files may.
docs/ui/ui-redesign-tokens.mdmodified+12 -10
@@ -60,18 +60,20 @@ display-font, translucent surface, or custom shadow rules.
60 ## DataTable60 ## DataTable
61 61
62 - Table shell: `rounded-lg border bg-card`62 - Table shell: `rounded-lg border bg-card`
63-- Header: sticky, `11px` bold uppercase, `tracking-[0.16em]`, muted background63+- Header: sticky, `text-xs` medium **Title Case** (no uppercase transform),
64-- Body: compact by default, even-row muted zebra, restrained hover64+ `tracking-normal`, muted foreground/background
65-- Cell padding: compact `py-1.5`; normal `py-3`; comfortable `py-5`65+- Body: flat rows (no zebra), restrained hover, `tabular-nums` cells so digits
66-- The rightmost action/update column is `w-28`, centered, sticky right, and66+ align vertically without a monospace font
67- inherits the exact opaque zebra/hover row surface67+- Cell padding: fixed `py-3` (no density / row-height toggle)
68-- Data columns start at a consistent width, fill the available table width, and68+- The rightmost action/update column stays fixed at `110×45px`, centered, sticky
69- expose mouse, touch, and keyboard resize handles; action/update stays fixed69+ right, and inherits the exact opaque row surface
70-- Search and column controls: `h-9`; search remains pill-shaped like bDash70+- Data columns fill the available table width at a consistent proportional width.
71+ Column resizing is not offered (no resize handles, no width persistence)
72+- Search and column controls: `h-9 rounded-lg` (not pill)
71 - Pagination includes range, optional page-size selector, previous/next, and page73 - Pagination includes range, optional page-size selector, previous/next, and page
72 count74 count
73-- `storageKey` remains optional. When provided, column widths, visibility, and75+- `storageKey` remains optional. When provided, only column visibility persists
74- density persist under `hezarfen.table.<storageKey>` and resizing is enabled.76+ under `hezarfen.table.<storageKey>`.
75 - Application tables use `DataTable`; page/domain components do not render table77 - Application tables use `DataTable`; page/domain components do not render table
76 primitives directly.78 primitives directly.
77 79
src/components/ui/data-table-search.tsxmodified+2 -2
@@ -10,7 +10,7 @@ export type DataTableSearchProps = {
10 class?: string;10 class?: string;
11 };11 };
12 12
13-/** Pill-shaped search field: leading icon + conditional clear (X) button (bdash look). */13+/** Rounded search field: leading icon + conditional clear (X) button. */
14 export function DataTableSearch(props: DataTableSearchProps) {14 export function DataTableSearch(props: DataTableSearchProps) {
15 return (15 return (
16 <div class={cn("relative w-full sm:max-w-xs", props.class)}>16 <div class={cn("relative w-full sm:max-w-xs", props.class)}>
@@ -19,7 +19,7 @@ export function DataTableSearch(props: DataTableSearchProps) {
19 value={props.value}19 value={props.value}
20 onInput={(event) => props.onChange(event.currentTarget.value)}20 onInput={(event) => props.onChange(event.currentTarget.value)}
21 placeholder={props.placeholder ?? "Ara"}21 placeholder={props.placeholder ?? "Ara"}
22- class={cn("h-9 rounded-full bg-muted/40", props.value ? "pl-9 pr-8" : "pl-9")}22+ class={cn("h-9 rounded-lg bg-muted/40", props.value ? "pl-9 pr-8" : "pl-9")}
23 />23 />
24 <Show when={props.value}>24 <Show when={props.value}>
25 <button25 <button
src/components/ui/data-table-view-menu.test.tsxmodified+0 -2
@@ -10,8 +10,6 @@ test("opens the columns menu from its trigger", async () => {
10 <PreferencesProvider>10 <PreferencesProvider>
11 <DataTableViewMenu11 <DataTableViewMenu
12 columns={[{ id: "email", label: "E-posta", visible: true, toggle: () => undefined }]}12 columns={[{ id: "email", label: "E-posta", visible: true, toggle: () => undefined }]}
13- density="compact"
14- onDensityChange={() => undefined}
15 />13 />
16 </PreferencesProvider>14 </PreferencesProvider>
17 ));15 ));
src/components/ui/data-table-view-menu.tsxmodified+15 -53
@@ -1,18 +1,13 @@
1-import { For, Show } from "solid-js";1+import { For } from "solid-js";
2 import {2 import {
3 DropdownMenu,3 DropdownMenu,
4 DropdownMenuCheckboxItem,4 DropdownMenuCheckboxItem,
5 DropdownMenuContent,5 DropdownMenuContent,
6- DropdownMenuItem,
7 DropdownMenuLabel,6 DropdownMenuLabel,
8- DropdownMenuRadioGroup,
9- DropdownMenuRadioItem,
10- DropdownMenuSeparator,
11 DropdownMenuTrigger,7 DropdownMenuTrigger,
12 } from "@/components/ui/dropdown-menu";8 } from "@/components/ui/dropdown-menu";
13-import { IconChevronDown, IconRotateCcw } from "@/components/ui/icons";9+import { IconChevronDown } from "@/components/ui/icons";
14 import { useT } from "@/stores/preferences-context";10 import { useT } from "@/stores/preferences-context";
15-import type { TableDensity } from "@/lib/table-preferences";
16 11
17 export type ViewMenuColumn = {12 export type ViewMenuColumn = {
18 id: string;13 id: string;
@@ -23,63 +18,30 @@ export type ViewMenuColumn = {
23 18
24 export type DataTableViewMenuProps = {19 export type DataTableViewMenuProps = {
25 columns: ViewMenuColumn[];20 columns: ViewMenuColumn[];
26- density: TableDensity;
27- onDensityChange: (density: TableDensity) => void;
28- /** When provided, a "reset column widths" item is shown (resize-enabled tables). */
29- onResetWidths?: () => void;
30 };21 };
31 22
32-const DENSITIES: TableDensity[] = ["compact", "normal", "comfortable"];23+/** Column visibility menu (rounded-lg, no density/resize controls). */
33-
34-/** Column visibility + row density + reset widths menu (bdash DataTableViewMenu port). */
35 export function DataTableViewMenu(props: DataTableViewMenuProps) {24 export function DataTableViewMenu(props: DataTableViewMenuProps) {
36 const t = useT();25 const t = useT();
37- const densityLabel = (density: TableDensity) =>
38- density === "compact"
39- ? t("common.densityCompact")
40- : density === "comfortable"
41- ? t("common.densityComfortable")
42- : t("common.densityNormal");
43 26
44 return (27 return (
45 <DropdownMenu placement="bottom-end" gutter={6}>28 <DropdownMenu placement="bottom-end" gutter={6}>
46- <DropdownMenuTrigger class="ml-auto inline-flex h-9 items-center justify-center gap-2 whitespace-nowrap rounded-full border border-border/80 bg-card px-3.5 text-sm font-semibold shadow-xs transition-all hover:bg-muted active:scale-[0.98] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">29+ <DropdownMenuTrigger class="ml-auto inline-flex h-9 items-center justify-center gap-2 whitespace-nowrap rounded-lg border border-border/70 bg-muted/40 px-3.5 text-sm font-medium transition-all hover:bg-muted active:scale-[0.98] focus-visible:outline-hidden focus-visible:ring-2 focus-visible:ring-ring">
47 {t("common.columns")}30 {t("common.columns")}
48 <IconChevronDown class="h-3.5 w-3.5 opacity-60" />31 <IconChevronDown class="h-3.5 w-3.5 opacity-60" />
49 </DropdownMenuTrigger>32 </DropdownMenuTrigger>
50 <DropdownMenuContent class="w-56">33 <DropdownMenuContent class="w-56">
51- <Show when={props.columns.length > 0}>34+ <DropdownMenuLabel>{t("common.visibleColumns")}</DropdownMenuLabel>
52- <DropdownMenuLabel>{t("common.visibleColumns")}</DropdownMenuLabel>35+ <For each={props.columns}>
53- <For each={props.columns}>36+ {(column) => (
54- {(column) => (37+ <DropdownMenuCheckboxItem
55- <DropdownMenuCheckboxItem38+ checked={column.visible}
56- checked={column.visible}39+ onChange={(value) => column.toggle(!!value)}
57- onChange={(value) => column.toggle(!!value)}40+ >
58- >41+ {column.label}
59- {column.label}42+ </DropdownMenuCheckboxItem>
60- </DropdownMenuCheckboxItem>43+ )}
61- )}44+ </For>
62- </For>
63- <DropdownMenuSeparator />
64- </Show>
65- <DropdownMenuLabel>{t("common.rowDensity")}</DropdownMenuLabel>
66- <DropdownMenuRadioGroup
67- value={props.density}
68- onChange={(value) => props.onDensityChange(value as TableDensity)}
69- >
70- <For each={DENSITIES}>
71- {(density) => (
72- <DropdownMenuRadioItem value={density}>{densityLabel(density)}</DropdownMenuRadioItem>
73- )}
74- </For>
75- </DropdownMenuRadioGroup>
76- <Show when={props.onResetWidths}>
77- <DropdownMenuSeparator />
78- <DropdownMenuItem onSelect={() => props.onResetWidths?.()}>
79- <IconRotateCcw class="h-4 w-4" />
80- {t("common.resetColumnWidths")}
81- </DropdownMenuItem>
82- </Show>
83 </DropdownMenuContent>45 </DropdownMenuContent>
84 </DropdownMenu>46 </DropdownMenu>
85 );47 );
src/components/ui/data-table.test.tsxmodified+24 -17
@@ -8,7 +8,12 @@ type Row = { name: string; role?: string };
8 const columns: ColumnDef<Row>[] = [8 const columns: ColumnDef<Row>[] = [
9 { accessorKey: "name", header: "Name" },9 { accessorKey: "name", header: "Name" },
10 { id: "update", header: "Role", cell: () => "Role" },10 { id: "update", header: "Role", cell: () => "Role" },
11- { id: "actions", header: "Actions", cell: () => "…" },11+ {
12+ id: "actions",
13+ header: "Actions",
14+ meta: { headerClass: "w-14", cellClass: "w-40 text-right" },
15+ cell: () => "…",
16+ },
12 ];17 ];
13 18
14 beforeEach(() => {19 beforeEach(() => {
@@ -17,22 +22,7 @@ beforeEach(() => {
17 });22 });
18 afterEach(() => vi.restoreAllMocks());23 afterEach(() => vi.restoreAllMocks());
19 24
20-test("resizes data columns with the keyboard and keeps actions fixed", () => {25+test("keeps only the rightmost action column sticky and fixed at 110x45", () => {
21- render(() => (
22- <PreferencesProvider>
23- <DataTable columns={columns} data={[{ name: "Ada" }]} storageKey="people" enableColumnVisibility={false} />
24- </PreferencesProvider>
25- ));
26-
27- const separator = screen.getAllByRole("separator", { name: "Sütun genişliğini ayarla" })[0];
28- fireEvent.keyDown(separator, { key: "ArrowRight" });
29-
30- const saved = JSON.parse(localStorage.getItem("hezarfen.table.people") ?? "{}");
31- expect(saved.sizing.name).toBe(158);
32- expect(screen.getAllByRole("separator")).toHaveLength(2);
33-});
34-
35-test("keeps only the rightmost action column sticky", () => {
36 render(() => (26 render(() => (
37 <PreferencesProvider>27 <PreferencesProvider>
38 <DataTable columns={columns} data={[{ name: "Ada" }]} enableColumnVisibility={false} />28 <DataTable columns={columns} data={[{ name: "Ada" }]} enableColumnVisibility={false} />
@@ -41,7 +31,24 @@ test("keeps only the rightmost action column sticky", () => {
41 31
42 const actionsHeader = screen.getByRole("columnheader", { name: "Actions" });32 const actionsHeader = screen.getByRole("columnheader", { name: "Actions" });
43 expect(actionsHeader.classList).toContain("table-sticky-head-right");33 expect(actionsHeader.classList).toContain("table-sticky-head-right");
34+ expect(actionsHeader.classList).toContain("table-action-cell");
35+ expect(actionsHeader.classList).toContain("h-[45px]");
36+ expect(actionsHeader.classList).toContain("w-[110px]");
37+ expect(actionsHeader.classList).not.toContain("w-14");
38+ expect(actionsHeader.style.width).toBe("110px");
44 expect(actionsHeader.classList).toContain("z-30");39 expect(actionsHeader.classList).toContain("z-30");
40+ const actionsCell = screen.getByRole("cell", { name: "…" });
41+ expect(actionsCell.classList).toContain("table-action-cell");
42+ expect(actionsCell.classList).toContain("h-[45px]");
43+ expect(actionsCell.classList).toContain("w-[110px]");
44+ expect(actionsCell.classList).not.toContain("w-40");
45+ expect(actionsCell.classList).toContain("text-center");
46+ expect(actionsCell.classList).not.toContain("text-right");
47+ expect(actionsCell.style.width).toBe("110px");
48+ const columnTracks = document.querySelectorAll("col");
49+ expect(columnTracks[0]?.style.width).toBe("calc(50% - 55px)");
50+ expect(columnTracks[1]?.style.width).toBe("calc(50% - 55px)");
51+ expect(columnTracks[2]?.style.width).toBe("110px");
45 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));52 const roleHeader = screen.getAllByRole("columnheader").find((header) => header.textContent?.startsWith("Role"));
46 expect(roleHeader?.classList).not.toContain("table-sticky-head-right");53 expect(roleHeader?.classList).not.toContain("table-sticky-head-right");
47 });54 });
src/components/ui/data-table.tsxmodified+58 -68
@@ -4,7 +4,6 @@ import {
4 type Column,4 type Column,
5 type ColumnDef,5 type ColumnDef,
6 type ColumnFiltersState,6 type ColumnFiltersState,
7- type ColumnSizingState,
8 type PaginationState,7 type PaginationState,
9 type SortingState,8 type SortingState,
10 type Updater,9 type Updater,
@@ -32,7 +31,7 @@ declare module "@tanstack/solid-table" {
32 label?: string;31 label?: string;
33 /** Header + cell horizontal alignment. Applied to both so they never drift apart. */32 /** Header + cell horizontal alignment. Applied to both so they never drift apart. */
34 align?: "left" | "center" | "right";33 align?: "left" | "center" | "right";
35- /** Freeze this column to the left edge on horizontal scroll (fintables-style). */34+ /** Freeze this column to the left edge on horizontal scroll. */
36 stickyLeft?: boolean;35 stickyLeft?: boolean;
37 /** Vertical divider on the given edge — separates frozen label from metric columns. */36 /** Vertical divider on the given edge — separates frozen label from metric columns. */
38 divider?: "left" | "right";37 divider?: "left" | "right";
@@ -103,8 +102,6 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
103 return props.columns;102 return props.columns;
104 },103 },
105 enableSorting: props.enableSorting ?? true,104 enableSorting: props.enableSorting ?? true,
106- enableColumnResizing: true,
107- columnResizeMode: "onChange",
108 getCoreRowModel: getCoreRowModel(),105 getCoreRowModel: getCoreRowModel(),
109 getSortedRowModel: getSortedRowModel(),106 getSortedRowModel: getSortedRowModel(),
110 getFilteredRowModel: getFilteredRowModel(),107 getFilteredRowModel: getFilteredRowModel(),
@@ -113,8 +110,6 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
113 onColumnFiltersChange: setColumnFilters,110 onColumnFiltersChange: setColumnFilters,
114 onColumnVisibilityChange: (updater) =>111 onColumnVisibilityChange: (updater) =>
115 prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)),112 prefs.setVisibility(resolveUpdater(updater, prefs.preferences().visibility)),
116- onColumnSizingChange: (updater) =>
117- prefs.setSizing(resolveUpdater(updater, prefs.preferences().sizing) as ColumnSizingState),
118 onPaginationChange: setPagination,113 onPaginationChange: setPagination,
119 state: {114 state: {
120 get sorting() {115 get sorting() {
@@ -126,9 +121,6 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
126 get columnVisibility() {121 get columnVisibility() {
127 return prefs.preferences().visibility;122 return prefs.preferences().visibility;
128 },123 },
129- get columnSizing() {
130- return prefs.preferences().sizing;
131- },
132 get pagination() {124 get pagination() {
133 return props.manualPagination125 return props.manualPagination
134 ? { pageIndex: props.manualPagination.pageIndex, pageSize: props.manualPagination.pageSize }126 ? { pageIndex: props.manualPagination.pageIndex, pageSize: props.manualPagination.pageSize }
@@ -145,7 +137,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
145 const divider = column.columnDef.meta?.divider;137 const divider = column.columnDef.meta?.divider;
146 return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined;138 return divider === "left" ? "border-l border-border/70" : divider === "right" ? "border-r border-border/70" : undefined;
147 };139 };
148- const actionColumnClass = (columnId: string) => stickyRightLocked(columnId) ? "w-28 min-w-28 px-2 text-center whitespace-nowrap" : undefined;140+ const actionColumnClass = (columnId: string) => stickyRightLocked(columnId) ? "table-action-cell h-[45px] w-[110px] min-w-[110px] max-w-[110px] px-2 py-0 text-center whitespace-nowrap" : undefined;
149 const stickyHeadClass = (column: Column<TData, unknown>) =>141 const stickyHeadClass = (column: Column<TData, unknown>) =>
150 isStickyLeft(column)142 isStickyLeft(column)
151 ? "table-sticky-head-left sticky left-0 z-30"143 ? "table-sticky-head-left sticky left-0 z-30"
@@ -171,11 +163,24 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
171 toggle: (visible: boolean) => column.toggleVisibility(visible),163 toggle: (visible: boolean) => column.toggleVisibility(visible),
172 }));164 }));
173 const colSpan = () => Math.max(1, table.getVisibleLeafColumns().length);165 const colSpan = () => Math.max(1, table.getVisibleLeafColumns().length);
174- const tableWidth = () =>166+ const dataColumnsWidth = () =>
167+ table.getVisibleLeafColumns().reduce(
168+ (total, column) => total + (stickyRightLocked(column.id) ? 0 : column.getSize()),
169+ 0,
170+ );
171+ const actionColumnsWidth = () =>
175 table.getVisibleLeafColumns().reduce(172 table.getVisibleLeafColumns().reduce(
176- (total, column) => total + (stickyRightLocked(column.id) ? 112 : column.getSize()),173+ (total, column) => total + (stickyRightLocked(column.id) ? 110 : 0),
177 0,174 0,
178 );175 );
176+ const tableWidth = () => dataColumnsWidth() + actionColumnsWidth();
177+ const columnWidth = (column: Column<TData, unknown>) => {
178+ if (stickyRightLocked(column.id)) return "110px";
179+ const total = dataColumnsWidth();
180+ if (total === 0) return `${column.getSize()}px`;
181+ const share = column.getSize() / total;
182+ return `calc(${share * 100}% - ${share * actionColumnsWidth()}px)`;
183+ };
179 const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0;184 const showColumnMenu = () => (props.enableColumnVisibility ?? true) && hideableColumns().length > 0;
180 const showSearch = () => props.searchPredicate != null || props.filterColumn != null || props.onSearchInput != null;185 const showSearch = () => props.searchPredicate != null || props.filterColumn != null || props.onSearchInput != null;
181 const showHeader = () => props.title != null || props.description != null || props.actions != null;186 const showHeader = () => props.title != null || props.description != null || props.actions != null;
@@ -209,7 +214,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
209 const align = alignOf(header.column);214 const align = alignOf(header.column);
210 if (!(props.enableSorting ?? true) || !header.column.getCanSort()) {215 if (!(props.enableSorting ?? true) || !header.column.getCanSort()) {
211 // The th already carries alignClass; the block span makes text-align resolve.216 // The th already carries alignClass; the block span makes text-align resolve.
212- return <span class="block truncate">{content}</span>;217+ return <span class="block truncate whitespace-nowrap">{content}</span>;
213 }218 }
214 const sorted = () => header.column.getIsSorted();219 const sorted = () => header.column.getIsSorted();
215 return (220 return (
@@ -217,14 +222,17 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
217 type="button"222 type="button"
218 variant="ghost"223 variant="ghost"
219 size="sm"224 size="sm"
220- // th text-align positions this inline-flex button; -ml-3 only trims the left gutter.225+ // th text-align positions this inline-flex button; -ml-2 cancels the button's
221- class={cn("h-8 px-2 uppercase", align === "left" && "-ml-3", sorted() && "text-foreground")}226+ // px-2 so header text starts at the same gutter as the cell text below it.
227+ class={cn("h-8 min-w-0 max-w-full px-2 font-medium tracking-normal normal-case", align === "left" && "-ml-2", sorted() && "text-foreground")}
222 onClick={() => header.column.toggleSorting(sorted() === "asc")}228 onClick={() => header.column.toggleSorting(sorted() === "asc")}
223 >229 >
224- {content}230+ <span class="truncate">{content}</span>
225 <Show231 <Show
226 when={sorted() !== false}232 when={sorted() !== false}
227- fallback={<IconChevronsUpDown class="h-3.5 w-3.5 opacity-50" />}233+ fallback={
234+ <IconChevronsUpDown class="h-3.5 w-3.5 opacity-0 transition-opacity group-hover/head:opacity-50 group-focus-within/head:opacity-50" />
235+ }
228 >236 >
229 <Show237 <Show
230 when={sorted() === "asc"}238 when={sorted() === "asc"}
@@ -270,12 +278,7 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
270 </div>278 </div>
271 <Show when={showColumnMenu()}>279 <Show when={showColumnMenu()}>
272 <div class="flex justify-end">280 <div class="flex justify-end">
273- <DataTableViewMenu281+ <DataTableViewMenu columns={viewMenuColumns()} />
274- columns={viewMenuColumns()}
275- density={prefs.preferences().density}
276- onDensityChange={prefs.setDensity}
277- onResetWidths={prefs.resetSizing}
278- />
279 </div>282 </div>
280 </Show>283 </Show>
281 </div>284 </div>
@@ -283,9 +286,13 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
283 <DataTableFrame>286 <DataTableFrame>
284 <Table287 <Table
285 class={cn("data-table table-fixed", props.tableClass)}288 class={cn("data-table table-fixed", props.tableClass)}
286- data-density={prefs.preferences().density}
287 style={{ width: `max(100%, ${tableWidth()}px)` }}289 style={{ width: `max(100%, ${tableWidth()}px)` }}
288 >290 >
291+ <colgroup>
292+ <For each={table.getVisibleLeafColumns()}>
293+ {(column) => <col style={{ width: columnWidth(column) }} />}
294+ </For>
295+ </colgroup>
289 <TableHeader>296 <TableHeader>
290 <For each={table.getHeaderGroups()}>297 <For each={table.getHeaderGroups()}>
291 {(headerGroup) => (298 {(headerGroup) => (
@@ -295,43 +302,16 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
295 <TableHead302 <TableHead
296 colSpan={header.colSpan}303 colSpan={header.colSpan}
297 class={cn(304 class={cn(
298- "group/head relative",305+ "group/head relative overflow-hidden",
299 alignClass[alignOf(header.column)],306 alignClass[alignOf(header.column)],
300 dividerClass(header.column),307 dividerClass(header.column),
301- actionColumnClass(header.column.id),
302 stickyHeadClass(header.column),308 stickyHeadClass(header.column),
303 header.column.columnDef.meta?.headerClass,309 header.column.columnDef.meta?.headerClass,
310+ actionColumnClass(header.column.id),
304 )}311 )}
305- style={{ width: `${stickyRightLocked(header.column.id) ? 112 : header.getSize()}px` }}312+ style={{ width: columnWidth(header.column) }}
306 >313 >
307 <Show when={!header.isPlaceholder}>{renderHeader(header)}</Show>314 <Show when={!header.isPlaceholder}>{renderHeader(header)}</Show>
308- <Show when={header.column.getCanResize() && !stickyRightLocked(header.column.id)}>
309- <div
310- role="separator"
311- aria-orientation="vertical"
312- aria-label="Sütun genişliğini ayarla"
313- aria-valuemin={header.column.columnDef.minSize ?? 72}
314- aria-valuenow={header.getSize()}
315- tabIndex={0}
316- onMouseDown={header.getResizeHandler()}
317- onTouchStart={header.getResizeHandler()}
318- onDblClick={() => header.column.resetSize()}
319- onKeyDown={(event) => {
320- if (event.key !== "ArrowLeft" && event.key !== "ArrowRight") return;
321- event.preventDefault();
322- const step = event.shiftKey ? 32 : 8;
323- const delta = event.key === "ArrowLeft" ? -step : step;
324- const min = header.column.columnDef.minSize ?? 72;
325- prefs.setSizing({
326- ...prefs.preferences().sizing,
327- [header.column.id]: Math.max(min, header.getSize() + delta),
328- });
329- }}
330- class="absolute right-0 top-0 z-20 flex h-full w-2 cursor-col-resize touch-none select-none items-center justify-center opacity-0 transition-opacity hover:opacity-100 focus-visible:opacity-100 focus-visible:outline-hidden group-hover/head:opacity-100"
331- >
332- <span class="h-1/2 w-px rounded bg-primary/70" />
333- </div>
334- </Show>
335 </TableHead>315 </TableHead>
336 )}316 )}
337 </For>317 </For>
@@ -371,20 +351,30 @@ export function DataTable<TData, TValue = unknown>(props: DataTableProps<TData,
371 }}351 }}
372 >352 >
373 <For each={row.getVisibleCells()}>353 <For each={row.getVisibleCells()}>
374- {(cell) => (354+ {(cell) => {
375- <TableCell355+ const val = cell.getValue();
376- class={cn(356+ const isText = typeof val === "string" || typeof val === "number";
377- alignClass[alignOf(cell.column)],357+ const isSystemColumn = ["actions", "update", "select"].includes(cell.column.id);
378- dividerClass(cell.column),358+ const isEmpty = !isSystemColumn && (val == null || val === "");
379- actionColumnClass(cell.column.id),359+
380- stickyCellClass(cell.column),360+ return (
381- cell.column.columnDef.meta?.cellClass,361+ <TableCell
382- )}362+ class={cn(
383- style={{ width: `${stickyRightLocked(cell.column.id) ? 112 : cell.column.getSize()}px` }}363+ alignClass[alignOf(cell.column)],
384- >364+ dividerClass(cell.column),
385- {flexRender(cell.column.columnDef.cell, cell.getContext())}365+ stickyCellClass(cell.column),
386- </TableCell>366+ cell.column.columnDef.meta?.cellClass,
387- )}367+ actionColumnClass(cell.column.id),
368+ )}
369+ style={{ width: columnWidth(cell.column) }}
370+ title={isText && !isEmpty ? String(val) : undefined}
371+ >
372+ <Show when={!isEmpty} fallback={<span class="text-muted-foreground/40">-</span>}>
373+ {flexRender(cell.column.columnDef.cell, cell.getContext())}
374+ </Show>
375+ </TableCell>
376+ );
377+ }}
388 </For>378 </For>
389 </TableRow>379 </TableRow>
390 )}380 )}
src/components/ui/table.tsxmodified+3 -3
@@ -25,7 +25,7 @@ export function TableHeader(props: ParentProps<ComponentProps<"thead">>) {
25 export function TableBody(props: ParentProps<ComponentProps<"tbody">>) {25 export function TableBody(props: ParentProps<ComponentProps<"tbody">>) {
26 const [local, rest] = splitProps(props, ["class", "children"]);26 const [local, rest] = splitProps(props, ["class", "children"]);
27 return (27 return (
28- <tbody class={cn("[&_tr:last-child]:border-0 [&_tr:nth-child(even)]:bg-muted/22", local.class)} {...rest}>28+ <tbody class={cn("[&_tr:last-child]:border-0", local.class)} {...rest}>
29 {local.children}29 {local.children}
30 </tbody>30 </tbody>
31 );31 );
@@ -35,7 +35,7 @@ export function TableRow(props: ParentProps<ComponentProps<"tr">>) {
35 const [local, rest] = splitProps(props, ["class", "children"]);35 const [local, rest] = splitProps(props, ["class", "children"]);
36 return (36 return (
37 <tr37 <tr
38- class={cn("border-b border-border/70 transition-colors hover:bg-muted/55 data-[state=selected]:bg-muted", local.class)}38+ class={cn("border-b border-border/70 transition-colors hover:bg-muted/65 data-[state=selected]:bg-muted", local.class)}
39 {...rest}39 {...rest}
40 >40 >
41 {local.children}41 {local.children}
@@ -48,7 +48,7 @@ export function TableHead(props: ParentProps<ComponentProps<"th">>) {
48 return (48 return (
49 <th49 <th
50 class={cn(50 class={cn(
51- "sticky top-0 z-20 h-11 whitespace-nowrap px-3 text-left align-middle text-[11px] font-bold uppercase tracking-[0.16em] text-muted-foreground first:pl-4 last:pr-4 has-[[role=checkbox]]:pr-0 [&_*]:uppercase",51+ "sticky top-0 z-20 h-11 whitespace-nowrap px-3 text-left align-middle text-xs font-medium tracking-normal text-muted-foreground first:pl-4 last:pr-4 has-[[role=checkbox]]:pr-0",
52 local.class,52 local.class,
53 )}53 )}
54 {...rest}54 {...rest}
src/i18n/messages.tsmodified+37 -19
@@ -20,6 +20,14 @@ export type MessageKey =
20 | "ai.suggest2"20 | "ai.suggest2"
21 | "ai.suggest3"21 | "ai.suggest3"
22 | "ai.suggest4"22 | "ai.suggest4"
23+ | "ai.suggestStaff1"
24+ | "ai.suggestStaff2"
25+ | "ai.suggestStaff3"
26+ | "ai.suggestStaff4"
27+ | "ai.suggestParent1"
28+ | "ai.suggestParent2"
29+ | "ai.suggestParent3"
30+ | "ai.suggestParent4"
23 | "nav.home"31 | "nav.home"
24 | "nav.today"32 | "nav.today"
25 | "nav.classes"33 | "nav.classes"
@@ -94,11 +102,6 @@ export type MessageKey =
94 | "common.actions"102 | "common.actions"
95 | "common.columns"103 | "common.columns"
96 | "common.visibleColumns"104 | "common.visibleColumns"
97- | "common.rowDensity"
98- | "common.densityCompact"
99- | "common.densityNormal"
100- | "common.densityComfortable"
101- | "common.resetColumnWidths"
102 | "common.pageRange"105 | "common.pageRange"
103 | "common.rowsPerPage"106 | "common.rowsPerPage"
104 | "common.moreFilters"107 | "common.moreFilters"
@@ -715,6 +718,9 @@ export type MessageKey =
715 | "courses.kind.course"718 | "courses.kind.course"
716 | "courses.kind.study"719 | "courses.kind.study"
717 | "courses.kind.club"720 | "courses.kind.club"
721+ | "courses.kind.courseSingular"
722+ | "courses.kind.studySingular"
723+ | "courses.kind.clubSingular"
718 | "courses.capacity"724 | "courses.capacity"
719 | "courses.capacityOptional"725 | "courses.capacityOptional"
720 | "courses.teachers"726 | "courses.teachers"
@@ -1197,6 +1203,14 @@ const en: Dict = {
1197 "ai.suggest2": "Which exams are coming up?",1203 "ai.suggest2": "Which exams are coming up?",
1198 "ai.suggest3": "Do I have any missing homework?",1204 "ai.suggest3": "Do I have any missing homework?",
1199 "ai.suggest4": "How is my attendance this term?",1205 "ai.suggest4": "How is my attendance this term?",
1206+ "ai.suggestStaff1": "What is on the schedule today?",
1207+ "ai.suggestStaff2": "Which exams are coming up?",
1208+ "ai.suggestStaff3": "Which students have low attendance?",
1209+ "ai.suggestStaff4": "Summarize this week's events.",
1210+ "ai.suggestParent1": "What are my child's classes today?",
1211+ "ai.suggestParent2": "Which exams does my child have soon?",
1212+ "ai.suggestParent3": "How is my child's attendance this term?",
1213+ "ai.suggestParent4": "What is on this week's meal menu?",
1200 "nav.home": "Home",1214 "nav.home": "Home",
1201 "nav.today": "Today",1215 "nav.today": "Today",
1202 "nav.classes": "Education",1216 "nav.classes": "Education",
@@ -1226,7 +1240,7 @@ const en: Dict = {
1226 "nav.attendance": "Attendance",1240 "nav.attendance": "Attendance",
1227 "nav.questions": "Question Pool",1241 "nav.questions": "Question Pool",
1228 "nav.work": "Work Log",1242 "nav.work": "Work Log",
1229- "nav.staffWork": "Staff work",1243+ "nav.staffWork": "Staff Shifts",
1230 "nav.users": "Users",1244 "nav.users": "Users",
1231 "nav.studentMarks": "Student marks",1245 "nav.studentMarks": "Student marks",
1232 "nav.studentAttendance": "Student attendance",1246 "nav.studentAttendance": "Student attendance",
@@ -1245,7 +1259,7 @@ const en: Dict = {
1245 "nav.preferences": "Preferences",1259 "nav.preferences": "Preferences",
1246 "nav.group.students": "Student Management",1260 "nav.group.students": "Student Management",
1247 "nav.group.school": "Management",1261 "nav.group.school": "Management",
1248- "nav.group.classes": "Education",1262+ "nav.group.classes": "Academics",
1249 "nav.group.grades": "Grades",1263 "nav.group.grades": "Grades",
1250 "nav.group.reports": "Reports",1264 "nav.group.reports": "Reports",
1251 "nav.group.settings": "Settings",1265 "nav.group.settings": "Settings",
@@ -1271,11 +1285,6 @@ const en: Dict = {
1271 "common.actions": "Actions",1285 "common.actions": "Actions",
1272 "common.columns": "Columns",1286 "common.columns": "Columns",
1273 "common.visibleColumns": "Visible columns",1287 "common.visibleColumns": "Visible columns",
1274- "common.rowDensity": "Row density",
1275- "common.densityCompact": "Compact",
1276- "common.densityNormal": "Normal",
1277- "common.densityComfortable": "Comfortable",
1278- "common.resetColumnWidths": "Reset column widths",
1279 "common.pageRange": "{start}-{end} of {total}",1288 "common.pageRange": "{start}-{end} of {total}",
1280 "common.rowsPerPage": "{size} / page",1289 "common.rowsPerPage": "{size} / page",
1281 "common.moreFilters": "More filters",1290 "common.moreFilters": "More filters",
@@ -1978,6 +1987,9 @@ const en: Dict = {
1978 "courses.kind.course": "Classes",1987 "courses.kind.course": "Classes",
1979 "courses.kind.study": "Study",1988 "courses.kind.study": "Study",
1980 "courses.kind.club": "Club",1989 "courses.kind.club": "Club",
1990+ "courses.kind.courseSingular": "Class",
1991+ "courses.kind.studySingular": "Study session",
1992+ "courses.kind.clubSingular": "Club",
1981 "courses.capacity": "Capacity",1993 "courses.capacity": "Capacity",
1982 "courses.capacityOptional": "Optional seat cap",1994 "courses.capacityOptional": "Optional seat cap",
1983 "courses.teachers": "Teachers",1995 "courses.teachers": "Teachers",
@@ -2386,6 +2398,14 @@ const tr: Dict = {
2386 "ai.suggest2": "Yaklaşan sınavlarım neler?",2398 "ai.suggest2": "Yaklaşan sınavlarım neler?",
2387 "ai.suggest3": "Eksik ödevim var mı?",2399 "ai.suggest3": "Eksik ödevim var mı?",
2388 "ai.suggest4": "Bu dönem devamsızlığım nasıl?",2400 "ai.suggest4": "Bu dönem devamsızlığım nasıl?",
2401+ "ai.suggestStaff1": "Bugün programda neler var?",
2402+ "ai.suggestStaff2": "Yaklaşan sınavlar neler?",
2403+ "ai.suggestStaff3": "Hangi öğrencilerin devamsızlığı yüksek?",
2404+ "ai.suggestStaff4": "Bu haftanın etkinliklerini özetle.",
2405+ "ai.suggestParent1": "Çocuğumun bugün hangi dersleri var?",
2406+ "ai.suggestParent2": "Çocuğumun yaklaşan sınavları neler?",
2407+ "ai.suggestParent3": "Çocuğumun bu dönem devamsızlığı nasıl?",
2408+ "ai.suggestParent4": "Bu haftanın yemek menüsünde ne var?",
2389 "nav.home": "Ana sayfa",2409 "nav.home": "Ana sayfa",
2390 "nav.today": "Bugün",2410 "nav.today": "Bugün",
2391 "nav.classes": "Eğitim",2411 "nav.classes": "Eğitim",
@@ -2415,7 +2435,7 @@ const tr: Dict = {
2415 "nav.attendance": "Yoklama",2435 "nav.attendance": "Yoklama",
2416 "nav.questions": "Soru Havuzu",2436 "nav.questions": "Soru Havuzu",
2417 "nav.work": "Çalışma Kaydı",2437 "nav.work": "Çalışma Kaydı",
2418- "nav.staffWork": "Mesailer",2438+ "nav.staffWork": "Personel Mesaisi",
2419 "nav.users": "Kullanıcılar",2439 "nav.users": "Kullanıcılar",
2420 "nav.studentMarks": "Öğrenci notları",2440 "nav.studentMarks": "Öğrenci notları",
2421 "nav.studentAttendance": "Öğrenci yoklamaları",2441 "nav.studentAttendance": "Öğrenci yoklamaları",
@@ -2434,7 +2454,7 @@ const tr: Dict = {
2434 "nav.preferences": "Tercihler",2454 "nav.preferences": "Tercihler",
2435 "nav.group.students": "Öğrenci Yönetimi",2455 "nav.group.students": "Öğrenci Yönetimi",
2436 "nav.group.school": "Yönetim",2456 "nav.group.school": "Yönetim",
2437- "nav.group.classes": "Eğitim",2457+ "nav.group.classes": "Akademik",
2438 "nav.group.grades": "Notlar",2458 "nav.group.grades": "Notlar",
2439 "nav.group.reports": "Raporlar",2459 "nav.group.reports": "Raporlar",
2440 "nav.group.settings": "Ayarlar",2460 "nav.group.settings": "Ayarlar",
@@ -2460,11 +2480,6 @@ const tr: Dict = {
2460 "common.actions": "İşlemler",2480 "common.actions": "İşlemler",
2461 "common.columns": "Sütunlar",2481 "common.columns": "Sütunlar",
2462 "common.visibleColumns": "Görünür sütunlar",2482 "common.visibleColumns": "Görünür sütunlar",
2463- "common.rowDensity": "Satır yoğunluğu",
2464- "common.densityCompact": "Sıkı",
2465- "common.densityNormal": "Normal",
2466- "common.densityComfortable": "Rahat",
2467- "common.resetColumnWidths": "Sütun genişliklerini sıfırla",
2468 "common.pageRange": "{total} kayıttan {start}-{end}",2483 "common.pageRange": "{total} kayıttan {start}-{end}",
2469 "common.rowsPerPage": "{size} / sayfa",2484 "common.rowsPerPage": "{size} / sayfa",
2470 "common.moreFilters": "Daha fazla filtre",2485 "common.moreFilters": "Daha fazla filtre",
@@ -3167,6 +3182,9 @@ const tr: Dict = {
3167 "courses.kind.course": "Dersler",3182 "courses.kind.course": "Dersler",
3168 "courses.kind.study": "Etüt",3183 "courses.kind.study": "Etüt",
3169 "courses.kind.club": "Kulüp",3184 "courses.kind.club": "Kulüp",
3185+ "courses.kind.courseSingular": "Ders",
3186+ "courses.kind.studySingular": "Etüt",
3187+ "courses.kind.clubSingular": "Kulüp",
3170 "courses.capacity": "Kapasite",3188 "courses.capacity": "Kapasite",
3171 "courses.capacityOptional": "İsteğe bağlı kontenjan",3189 "courses.capacityOptional": "İsteğe bağlı kontenjan",
3172 "courses.teachers": "Öğretmenler",3190 "courses.teachers": "Öğretmenler",
src/lib/table-preferences.test.tsxmodified+6 -23
@@ -10,29 +10,18 @@ const storageKey = `hezarfen.table.${key}`;
10 10
11 beforeEach(() => localStorage.clear());11 beforeEach(() => localStorage.clear());
12 12
13-test("reads saved widths, visibility and density", () => {13+test("reads saved visibility", () => {
14 localStorage.setItem(14 localStorage.setItem(
15 storageKey,15 storageKey,
16- JSON.stringify({16+ JSON.stringify({ visibility: { email: false } }),
17- sizing: { name: 240 },
18- visibility: { email: false },
19- density: "comfortable",
20- }),
21 );17 );
22 18
23- expect(readTablePreferences(key)).toEqual({19+ expect(readTablePreferences(key)).toEqual({ visibility: { email: false } });
24- sizing: { name: 240 },
25- visibility: { email: false },
26- density: "comfortable",
27- });
28 });20 });
29 21
30-test("falls back to compact defaults for broken storage", () => {22+test("falls back to defaults for broken storage", () => {
31 localStorage.setItem(storageKey, "{broken");23 localStorage.setItem(storageKey, "{broken");
32 expect(readTablePreferences(key)).toEqual(defaultTablePreferences);24 expect(readTablePreferences(key)).toEqual(defaultTablePreferences);
33-
34- localStorage.setItem(storageKey, JSON.stringify({ density: "huge" }));
35- expect(readTablePreferences(key).density).toBe("compact");
36 });25 });
37 26
38 function PreferencesProbe() {27 function PreferencesProbe() {
@@ -40,24 +29,18 @@ function PreferencesProbe() {
40 return (29 return (
41 <>30 <>
42 <output data-testid="preferences">{JSON.stringify(controller.preferences())}</output>31 <output data-testid="preferences">{JSON.stringify(controller.preferences())}</output>
43- <button type="button" onClick={() => controller.setSizing({ name: 320 })}>width</button>
44 <button type="button" onClick={() => controller.setVisibility({ email: false })}>visibility</button>32 <button type="button" onClick={() => controller.setVisibility({ email: false })}>visibility</button>
45- <button type="button" onClick={() => controller.setDensity("normal")}>density</button>
46 </>33 </>
47 );34 );
48 }35 }
49 36
50-test("persists width, visibility and density changes", () => {37+test("persists visibility changes", () => {
51 render(() => <PreferencesProbe />);38 render(() => <PreferencesProbe />);
52 39
53- fireEvent.click(screen.getByRole("button", { name: "width" }));
54 fireEvent.click(screen.getByRole("button", { name: "visibility" }));40 fireEvent.click(screen.getByRole("button", { name: "visibility" }));
55- fireEvent.click(screen.getByRole("button", { name: "density" }));
56 41
57 expect(JSON.parse(localStorage.getItem(storageKey) ?? "{}")).toEqual({42 expect(JSON.parse(localStorage.getItem(storageKey) ?? "{}")).toEqual({
58- sizing: { name: 320 },
59 visibility: { email: false },43 visibility: { email: false },
60- density: "normal",
61 });44 });
62- expect(screen.getByTestId("preferences").textContent).toContain('"density":"normal"');45+ expect(screen.getByTestId("preferences").textContent).toContain('"email":false');
63 });46 });
src/lib/table-preferences.tsmodified+1 -19
@@ -1,24 +1,16 @@
1 import { createSignal, onMount } from "solid-js";1 import { createSignal, onMount } from "solid-js";
2 2
3-export type TableDensity = "compact" | "normal" | "comfortable";
4-
5-/** TanStack `columnSizing` shape: column id → width (px). */
6-export type ColumnSizing = Record<string, number>;
7 /** TanStack `columnVisibility` shape: column id → visible. Absent = visible. */3 /** TanStack `columnVisibility` shape: column id → visible. Absent = visible. */
8 export type ColumnVisibility = Record<string, boolean>;4 export type ColumnVisibility = Record<string, boolean>;
9 5
10 export type TablePreferences = {6 export type TablePreferences = {
11- sizing: ColumnSizing;
12 visibility: ColumnVisibility;7 visibility: ColumnVisibility;
13- density: TableDensity;
14 };8 };
15 9
16 const STORAGE_PREFIX = "hezarfen.table.";10 const STORAGE_PREFIX = "hezarfen.table.";
17 11
18 export const defaultTablePreferences: TablePreferences = {12 export const defaultTablePreferences: TablePreferences = {
19- sizing: {},
20 visibility: {},13 visibility: {},
21- density: "compact",
22 };14 };
23 15
24 export function readTablePreferences(storageKey: string): TablePreferences {16 export function readTablePreferences(storageKey: string): TablePreferences {
@@ -28,14 +20,7 @@ export function readTablePreferences(storageKey: string): TablePreferences {
28 if (!raw) return defaultTablePreferences;20 if (!raw) return defaultTablePreferences;
29 const parsed = JSON.parse(raw) as Partial<TablePreferences>;21 const parsed = JSON.parse(raw) as Partial<TablePreferences>;
30 return {22 return {
31- sizing: typeof parsed.sizing === "object" && parsed.sizing ? parsed.sizing : {},
32 visibility: typeof parsed.visibility === "object" && parsed.visibility ? parsed.visibility : {},23 visibility: typeof parsed.visibility === "object" && parsed.visibility ? parsed.visibility : {},
33- density:
34- parsed.density === "compact" ||
35- parsed.density === "comfortable" ||
36- parsed.density === "normal"
37- ? parsed.density
38- : defaultTablePreferences.density,
39 };24 };
40 } catch {25 } catch {
41 return defaultTablePreferences;26 return defaultTablePreferences;
@@ -54,7 +39,7 @@ function writePreferences(storageKey: string | undefined, preferences: TablePref
54 export type TablePreferencesController = ReturnType<typeof createTablePreferences>;39 export type TablePreferencesController = ReturnType<typeof createTablePreferences>;
55 40
56 /**41 /**
57- * Column widths, column visibility and row density persisted per table.42+ * Column visibility persisted per table.
58 * When `storageKey` is omitted the preferences stay in memory only (ephemeral).43 * When `storageKey` is omitted the preferences stay in memory only (ephemeral).
59 * Preferences load in `onMount` so the first render matches the SSR-free default.44 * Preferences load in `onMount` so the first render matches the SSR-free default.
60 */45 */
@@ -75,9 +60,6 @@ export function createTablePreferences(storageKey?: string) {
75 60
76 return {61 return {
77 preferences,62 preferences,
78- setDensity: (density: TableDensity) => patch({ density }),
79- setSizing: (sizing: ColumnSizing) => patch({ sizing }),
80- resetSizing: () => patch({ sizing: {} }),
81 setVisibility: (visibility: ColumnVisibility) => patch({ visibility }),63 setVisibility: (visibility: ColumnVisibility) => patch({ visibility }),
82 };64 };
83 }65 }