Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions .changeset/36048-list-column-lines-row-36.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
---
'@object-ui/plugin-grid': patch
'@object-ui/i18n': patch
---

feat(plugin-grid): a list draws a line between columns, its default rows and header are 36px tall, and the footer shows 「+ Add calculation」 at rest

Clause-②: no
Metadata-protocol: none

- A line of the same colour and weight as the row lines now runs between columns in the header, the rows and the footer row, with none after the last cell. The last frozen column keeps its scroll shadow on top of its line.
- The default row height (`compact`, the density a view without `rowHeight` gets, shown as Compact in the row-height menu) is 36px instead of 32px, and the header is 36px too. The Standard and Spacious densities are unchanged.
- In a list whose reader may change the view, every footer cell without a calculation shows a faint 「+ Add calculation」 at all times instead of only on hover. A reader who may not change the view still sees only the calculations already set. The `grid.summary.calculate` text changes in every language pack to match.
60 changes: 53 additions & 7 deletions ui/e2e/list-frame-geometry-35548.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,14 @@ import { uiRoot } from '../scripts/ui-root.mjs';
*
* view bar 40 (the object's name as the page's heading, the switcher and
* View settings on the left; search, New and ⋮ on the right) · condition
* row 40, resident · header 32 · row 33, 13px on the heading, the header,
* row 40, resident · header 36 · row 36, its line included
* (objectstack#36048; 32 and 33 before it), 13px on the heading, the header,
* the cells and the bar buttons, the view switcher as one trigger (type
* icon → name → count → caret), and each column total under its own
* column, right edge on the column's right edge. No page bar is drawn
* above the view bar.
* above the view bar. A line of the row lines' colour and weight runs
* between columns in the header, the rows and the footer row, and none
* after the last cell, drawn as an inset shadow (objectstack#36048).
*
* ⚠️ A Playwright spec, not a vitest test: jsdom has no layout engine, so a
* height read there is 0 and a class-shape assertion would pass against
Expand Down Expand Up @@ -112,7 +115,7 @@ const DENSITY = (() => {
const block = pick('grid', /export const OBJECT_GRID_TABLE_DENSITY = \[([\s\S]*?)\]\.join/, 'OBJECT_GRID_TABLE_DENSITY');
return [...block.matchAll(/'([^']+)'/g)].map((m) => m[1]).join(' ');
})();
const ROW_CELL = carrying(pick('grid', /rowHeightMode === 'compact'\s*\?\s*'([^']+)'/, 'the default (compact) row arm'), ['h-8', 'text-[13px]'], 'row arm');
const ROW_CELL = carrying(pick('grid', /rowHeightMode === 'compact'\s*\?\s*'([^']+)'/, 'the default (compact) row arm'), ['h-9', 'text-[13px]'], 'row arm');
const ROW_ACTION = (() => {
const at = SRC.rowAction.indexOf('data-testid="row-action-trigger"');
const cls = [...SRC.rowAction.slice(0, at).matchAll(/className="([^"]+)"/g)].pop()?.[1];
Expand Down Expand Up @@ -206,7 +209,9 @@ const CANDIDATES = [
let css = '';
test.beforeAll(async () => {
const twEntry = fileURLToPath(import.meta.resolve('tailwindcss/index.css'));
const compiler = await compile('@import "tailwindcss";', {
// The app's border colour, so the row line and the column line resolve to a
// real colour each and their comparison below means something.
const compiler = await compile('@import "tailwindcss"; @theme { --color-border: rgb(225 225 234); }', {
base: path.dirname(twEntry),
loadStylesheet: async (id: string, base: string) => {
const file = id === 'tailwindcss' ? twEntry : path.resolve(base, id);
Expand Down Expand Up @@ -255,6 +260,31 @@ async function measure(page: Page, locale: 'zh' | 'en' = 'zh') {
switcherOrder: ['type-icon', 'label', 'count', 'caret'].map((p) => rect($(`#sw-${p}`))!.left),
cols,
footText: ($('#tfoot') as HTMLElement).innerText,
// objectstack#36048 — the column lines, read off one cell per part.
lines: (() => {
// The line is an inset shadow on the cell's right edge (a collapsed
// border would stay behind a frozen cell when the rows scroll):
// read the one inset layer, its offsets and its colour.
const border = (el: Element | null) => {
if (!el) return null;
const layers = getComputedStyle(el).boxShadow.split(/,(?![^(]*\))/).map((l) => l.trim());
const inset = layers.filter((l) => /\binset\b/.test(l) && !/^(rgba\(0, 0, 0, 0\)|transparent)\s/.test(l));
const one = inset[0] ?? '';
const m = /\s((?:-?[\d.]+px\s+){3}-?[\d.]+px)\s+inset$/.exec(one);
return { insetLayers: inset.length, offsets: m ? m[1] : '', color: m ? one.slice(0, m.index).trim() : '', borderRight: getComputedStyle(el).borderRightWidth };
};
const rowLine = getComputedStyle(document.querySelector('tbody tr')!);
return {
rowLine: { width: rowLine.borderBottomWidth, color: rowLine.borderBottomColor },
header: border($('thead th[data-col="account"]')),
headerLast: border($('thead th:last-child')),
body: border($('tbody tr td[data-col="account"]')),
bodyLead: border($('tbody tr td:first-child')),
bodyLast: border($('tbody tr td:last-child')),
foot: border($('#tfoot td[data-col="account"]')),
footLast: border($('#tfoot td:last-child')),
};
})(),
overflowX: document.documentElement.scrollWidth - document.documentElement.clientWidth,
};
});
Expand All @@ -272,15 +302,15 @@ test.describe('the list page frame (objectstack#35548)', () => {
expect([...at].sort((a, b) => a - b)).toEqual(at);
});

test('1280×800: no page bar, view bar 40, condition row 40, header 32, rows 33, first row top ≤ 168', async ({ page }) => {
test('1280×800: no page bar, view bar 40, condition row 40, header 36, rows 36, first row top ≤ 168', async ({ page }) => {
const r = await measure(page);
expect(r.page, 'a page bar is drawn above the view bar').toBeNull();
expect(r.viewbar.top).toBeCloseTo(48, 0);
expect(r.viewbar.height).toBeCloseTo(40, 0);
expect(r.condition.height, 'the resident condition row').toBeCloseTo(40, 0);
expect(r.thead.top, 'the header under the two rows').toBeCloseTo(128, 0);
expect(r.thead.height).toBeCloseTo(32, 0);
for (const h of r.rowHeights) expect(h, 'a data row is not 33px').toBeCloseTo(33, 0);
expect(r.thead.height).toBeCloseTo(36, 0);
for (const h of r.rowHeights) expect(h, 'a data row is not 36px').toBeCloseTo(36, 0);
expect(r.firstRow.top).toBeLessThanOrEqual(168);
expect(r.newButton.height).toBeGreaterThanOrEqual(24);
expect(r.newButton.height).toBeLessThanOrEqual(28);
Expand All @@ -300,6 +330,22 @@ test.describe('the list page frame (objectstack#35548)', () => {
for (const f of fonts.bar) expect(f).toBe('13px');
});

test('a line between columns in the header, the rows and the footer, the row lines\' colour and weight, none after the last cell (objectstack#36048)', async ({ page }) => {
const { lines } = await measure(page);
expect(lines.rowLine.width).toBe('1px');
expect(lines.rowLine.color).not.toBe('rgba(0, 0, 0, 0)');
for (const [part, b] of Object.entries({ header: lines.header, body: lines.body, bodyLead: lines.bodyLead, foot: lines.foot })) {
expect(b, part).not.toBeNull();
expect(b!.insetLayers, `${part}: one column line`).toBe(1);
expect(b!.offsets, `${part}: a 1px line on the right edge`).toBe('-1px 0px 0px 0px');
expect(b!.color, `${part}: column line colour`).toBe(lines.rowLine.color);
expect(b!.borderRight, `${part}: drawn as a shadow, not a border`).toBe('0px');
}
for (const [part, b] of Object.entries({ headerLast: lines.headerLast, bodyLast: lines.bodyLast, footLast: lines.footLast })) {
expect(b!.insetLayers, `${part}: a line after the last cell`).toBe(0);
}
});

test('the switcher reads type icon → name → count → caret, left to right', async ({ page }) => {
const { switcherOrder } = await measure(page);
expect([...switcherOrder].sort((a, b) => a - b)).toEqual(switcherOrder);
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ar.ts
Original file line number Diff line number Diff line change
Expand Up @@ -713,7 +713,7 @@ const ar = {
earliest: "الأقدم",
latest: "الأحدث",
pageName: "{{label}} (هذه الصفحة)",
calculate: "حساب",
calculate: "إضافة حساب",
none: "لا شيء",
menuPercentEmpty: "نسبة الفارغ",
menuPercentFilled: "نسبة المعبأ",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/de.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ const de = {
earliest: "Frühestes",
latest: "Spätestes",
pageName: "{{label}} (diese Seite)",
calculate: "Berechnen",
calculate: "Berechnung hinzufügen",
none: "Keine",
menuPercentEmpty: "Anteil leer",
menuPercentFilled: "Anteil gefüllt",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/en.ts
Original file line number Diff line number Diff line change
Expand Up @@ -905,7 +905,7 @@ const en = {
earliest: 'Earliest',
latest: 'Latest',
pageName: '{{label}} (this page)',
calculate: 'Calculate',
calculate: 'Add calculation',
none: 'None',
menuPercentEmpty: 'Percent empty',
menuPercentFilled: 'Percent filled',
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/es.ts
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ const es = {
earliest: "Más antigua",
latest: "Más reciente",
pageName: "{{label}} (esta página)",
calculate: "Calcular",
calculate: "Añadir cálculo",
none: "Ninguno",
menuPercentEmpty: "Porcentaje vacío",
menuPercentFilled: "Porcentaje con valor",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/fr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ const fr = {
earliest: "Plus ancienne",
latest: "Plus récente",
pageName: "{{label}} (cette page)",
calculate: "Calculer",
calculate: "Ajouter un calcul",
none: "Aucun",
menuPercentEmpty: "Pourcentage vide",
menuPercentFilled: "Pourcentage rempli",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ja.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ const ja = {
earliest: "最も早い",
latest: "最も遅い",
pageName: "{{label}}(このページ)",
calculate: "計算",
calculate: "集計を追加",
none: "なし",
menuPercentEmpty: "空の割合",
menuPercentFilled: "入力済みの割合",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -655,7 +655,7 @@ const ko = {
earliest: "가장 이른",
latest: "가장 늦은",
pageName: "{{label}} (이 페이지)",
calculate: "계산",
calculate: "계산 추가",
none: "없음",
menuPercentEmpty: "빈 값 비율",
menuPercentFilled: "입력된 값 비율",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/pt-BR.ts
Original file line number Diff line number Diff line change
Expand Up @@ -668,7 +668,7 @@ const pt = {
earliest: "Mais antiga",
latest: "Mais recente",
pageName: "{{label}} (esta página)",
calculate: "Calcular",
calculate: "Adicionar cálculo",
none: "Nenhum",
menuPercentEmpty: "Percentual vazio",
menuPercentFilled: "Percentual preenchido",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/ru.ts
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ const ru = {
earliest: "Самая ранняя",
latest: "Самая поздняя",
pageName: "{{label}} (эта страница)",
calculate: "Вычислить",
calculate: "Добавить расчёт",
none: "Нет",
menuPercentEmpty: "Доля пустых",
menuPercentFilled: "Доля заполненных",
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/zh-Hans.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ const zh = {
earliest: '最早',
latest: '最晚',
pageName: '{{label}}(本页)',
calculate: '计算',
calculate: '添加统计',
none: '无',
menuPercentEmpty: '空值占比',
menuPercentFilled: '非空占比',
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/i18n/src/locales/zh-Hant.ts
Original file line number Diff line number Diff line change
Expand Up @@ -635,7 +635,7 @@ const zhHant = {
earliest: '最早',
latest: '最晚',
pageName: '{{label}}(本頁)',
calculate: '計算',
calculate: '新增統計',
none: '無',
menuPercentEmpty: '空值佔比',
menuPercentFilled: '非空佔比',
Expand Down
24 changes: 17 additions & 7 deletions ui/packages/plugin-grid/src/ObjectGrid.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -627,11 +627,20 @@ function getDataConfig(schema: ObjectGridSchema): ViewData | null {
* deliberately at that package's floor, and that is exactly how `bf97b98c8` took it.
*/
/**
* The grid table's frame (objectstack#35548): every header cell 32px tall at
* 13px, and the row lines a shade off the background rather than a rule.
* The grid table's frame (objectstack#35548): every header cell at 13px, and
* the row lines a shade off the background rather than a rule.
* objectstack#36048 — the header is 36px tall, as the default row is, and a
* line of the same shade and weight as the row lines runs between columns in
* the header, the rows and the footer row (none after the last cell). The
* line is an inset shadow on the cell's right edge, not a border: the table
* collapses its borders, and a collapsed border belongs to the table, so a
* frozen (sticky) cell's border stays behind when the rows scroll sideways
* and the frozen columns lose their lines. The inset shadow is the cell's
* own and composes with the last frozen column's scroll shadow.
*/
export const OBJECT_GRID_TABLE_DENSITY = [
'[&_thead_th]:h-8 [&_thead_th]:py-0 [&_thead_th]:text-[13px] [&_tbody_tr]:border-border/50',
'[&_thead_th]:h-9 [&_thead_th]:py-0 [&_thead_th]:text-[13px] [&_tbody_tr]:border-border/50',
'[&_th:not(:last-child)]:inset-shadow-[-1px_0_0_0] [&_th:not(:last-child)]:inset-shadow-border/50 [&_td:not(:last-child)]:inset-shadow-[-1px_0_0_0] [&_td:not(:last-child)]:inset-shadow-border/50',
// A referenced record (a lookup's link) is a small chip led by its name's
// first letter; an option label keeps its colour, less saturated.
'[&_td_a[data-record-link]]:inline-flex [&_td_a[data-record-link]]:h-5 [&_td_a[data-record-link]]:max-w-full [&_td_a[data-record-link]]:items-center [&_td_a[data-record-link]]:gap-1 [&_td_a[data-record-link]]:rounded [&_td_a[data-record-link]]:bg-muted [&_td_a[data-record-link]]:px-1.5 [&_td_a[data-record-link]]:text-foreground [&_td_a[data-record-link]]:hover:no-underline [&_td_a[data-record-link]]:hover:bg-accent',
Expand Down Expand Up @@ -2109,11 +2118,12 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({

// Density-driven cell padding/font (applied to every column so it actually reaches <td>).
// `h-*` enforces a minimum row height so the action-button column doesn't dictate it.
// objectstack#35548 — the default (`compact`) row is 33px: a 32px cell and
// the row's 1px line.
// objectstack#36048 — the default (`compact`) row is 36px, its line
// included, as the header is (it was a 32px cell, objectstack#35548). The
// measured heights are pinned by `e2e/list-frame-geometry-35548.spec.ts`.
const rowHeightCellClass =
rowHeightMode === 'compact'
? 'px-3 py-1 h-8 text-[13px] leading-tight'
? 'px-3 py-1 h-9 text-[13px] leading-tight'
: rowHeightMode === 'short'
? 'px-3 py-1 h-9 text-[13px] leading-normal'
: rowHeightMode === 'tall'
Expand Down Expand Up @@ -3551,7 +3561,7 @@ export const ObjectGrid: React.FC<ObjectGridComponentProps> = ({
keyboardNavigation: schema.keyboardNavigation ?? inlineEditable,
// The save bar sits on the grid's own inset, as its cells do (`px-3`),
// never flush against the view's edge (objectstack-ai/objectstack#27520).
// objectstack#35548 — a 32px header at 13px over faint row lines.
// objectstack#35548 / #36048 — a 36px header at 13px over faint row and column lines.
className: ['[&>[data-slot=table-toolbar]]:px-3 [&>[data-slot=table-toolbar]]:pt-2', OBJECT_GRID_TABLE_DENSITY, schema.className].filter(Boolean).join(' '),
cellClassName: rowHeightMode === 'compact'
? 'px-3 py-1 text-[13px] leading-tight'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,7 @@ describe('the resident footer row (objectstack#35702)', () => {
]);
const row = await screen.findByTestId('data-table-summary-row');
expect(within(row).queryByRole('button')).toBeNull();
expect(within(row).queryByText('Add calculation')).toBeNull();
expect(within(row).getByTestId('data-table-summary-amount')).toHaveTextContent('Sum 350');
});

Expand All @@ -137,7 +138,9 @@ describe('the resident footer row (objectstack#35702)', () => {
const onPick = vi.fn();
renderGrid({ residentSummaryRow: true, onColumnSummaryPick: onPick });
await screen.findByTestId('data-table-summary-row');
expect(screen.getByTestId('summary-picker-hint-amount')).toHaveTextContent('Calculate');
// objectstack#36048 — the entry shows at rest, not only on hover.
expect(screen.getByTestId('summary-picker-hint-amount')).toHaveTextContent('Add calculation');
expect(screen.getByTestId('summary-picker-hint-amount').className).not.toMatch(/(^|\s)opacity-0(\s|$)/);

await user.click(screen.getByTestId('summary-picker-amount'));
const menu = await screen.findByTestId('summary-menu-amount');
Expand Down Expand Up @@ -222,7 +225,7 @@ describe('the resident footer row (objectstack#35702)', () => {
await user.click(within(await screen.findByTestId('summary-menu-amount')).getByTestId('summary-option-sum'));
expect(onPick).toHaveBeenLastCalledWith('amount', 'sum');
await waitFor(() => expect(screen.getByTestId('summary-picker-amount')).not.toHaveTextContent('Sum'));
expect(screen.getByTestId('summary-picker-hint-amount')).toHaveTextContent('Calculate');
expect(screen.getByTestId('summary-picker-hint-amount')).toHaveTextContent('Add calculation');
});

it('keeps a pick the host saved', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,10 @@ function renderGrid(opts?: Record<string, any>) {
* They are therefore separately observable, and each case below asserts both.
*/
const COLUMN_COPY: Record<string, string[]> = {
// objectstack#35548 — the default (`compact`) row is 33px: a 32px cell and its line.
compact: ['px-3', 'py-1', 'h-8', 'text-[13px]', 'leading-tight'],
// objectstack#36048 — the default (`compact`) cell is 36px (32px before it,
// objectstack#35548). It shares `short`'s floor and keeps its own leading, so
// the two still resolve to different copies.
compact: ['px-3', 'py-1', 'h-9', 'text-[13px]', 'leading-tight'],
short: ['px-3', 'py-1', 'h-9', 'text-[13px]', 'leading-normal'],
medium: ['px-3', 'py-1.5', 'h-11', 'text-[13px]', 'leading-normal'],
tall: ['px-3', 'py-2.5', 'h-14', 'text-sm'],
Expand Down
11 changes: 7 additions & 4 deletions ui/packages/plugin-grid/src/objectGridSummaryPicker.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,9 @@
* figure in the normal one (「Sum ¥1,234,500」). For a reader who may change
* the view it is also the control: a click opens one menu of the calculations
* the column's field type allows, the current one ticked and 「None」 last; an
* empty cell shows 「Calculate」 on hover. Without `onPick` it only draws.
* empty cell always shows a faint 「+ Add calculation」, so a reader who has
* never hovered the footer still sees the control (objectstack#36048). Without
* `onPick` it only draws, and an empty cell draws nothing.
*/

import React from 'react';
Expand All @@ -16,7 +18,7 @@ import {
DropdownMenuSeparator,
DropdownMenuTrigger,
} from '@object-ui/components';
import { Check } from 'lucide-react';
import { Check, Plus } from 'lucide-react';
import type { ColumnSummaryType, SummaryTranslate } from './useColumnSummary';
import { summaryMenuLabel } from './useColumnSummary';

Expand Down Expand Up @@ -77,9 +79,10 @@ export function SummaryCellPicker({ field, figure, current, offered, temporal, a
) : (
<span
data-testid={`summary-picker-hint-${field}`}
className="text-muted-foreground opacity-0 transition-opacity group-hover/summary:opacity-100 group-focus-visible/summary:opacity-100"
className="inline-flex min-w-0 items-center gap-1 truncate font-normal text-muted-foreground/70 transition-colors group-hover/summary:text-foreground group-focus-visible/summary:text-foreground"
>
{t('grid.summary.calculate')}
<Plus className="h-3.5 w-3.5 shrink-0" aria-hidden="true" />
<span className="truncate">{t('grid.summary.calculate')}</span>
</span>
)}
</button>
Expand Down
2 changes: 1 addition & 1 deletion ui/packages/plugin-grid/src/useColumnSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ const SUMMARY_DEFAULT_TRANSLATIONS: Record<string, string> = {
'grid.summary.earliest': 'Earliest',
'grid.summary.latest': 'Latest',
'grid.summary.pageName': '{{label}} (this page)',
'grid.summary.calculate': 'Calculate',
'grid.summary.calculate': 'Add calculation',
'grid.summary.none': 'None',
'grid.summary.menuPercentEmpty': 'Percent empty',
'grid.summary.menuPercentFilled': 'Percent filled',
Expand Down
Loading