@slashsuite/ui-react 0.16.0 → 0.16.2
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/agent-docs/components/table.md +6 -6
- package/dist/Markdown.js +6 -3
- package/dist/Table.d.ts +2 -1
- package/dist/Table.js +5 -4
- package/dist/TableCells.d.ts +7 -6
- package/dist/TableCells.js +18 -12
- package/dist/tableColumns.d.ts +6 -0
- package/dist/tableColumns.js +1 -0
- package/package.json +1 -1
|
@@ -48,7 +48,7 @@ import {
|
|
|
48
48
|
- Mark a row's status with `tone` (a stripe and a soft fill, or `muted` to fade the row) or with `stripe` (the stripe alone, in the `muted`, `info`, `positive`, `warn` or `danger` tone, which keeps the row's hover). Give one of them, never both, and name the status in a cell as well (a `Pill`), or draw a `Legend` for the colours.
|
|
49
49
|
- A table with no rows takes `TableBody empty={<EmptyState title="No quotes yet." />}`: one muted line in a cell that spans every column the head declares, with the head still drawn. Write `TableHead` and its cells inline, so the table can count them.
|
|
50
50
|
- Group rows with a `TableGroupRow`: it spans every column the head declares, and `trailing` is a count or a subtotal at the far end. A full-width note or panel is a `TableCell span="full"`; `align="center"` centres it. `indent` (1 to 3) sets a start-aligned cell in, for the lines under a parent row. A column with nothing to say in its head (its actions) takes a `TableHeaderCell` with `label="Actions"`. Inside a `Card` a table is plain: no card of its own, only the row dividers.
|
|
51
|
-
- The cell that names its row (the customer, the build) is a `TableHeaderCell` in the body row: a row header, drawn as a strong cell. Prose wraps; everything else stays on one line: a link, a code, a figure and a date never break, and a long table scrolls sideways instead of squeezing them.
|
|
51
|
+
- The cell that names its row (the customer, the build) is a `TableHeaderCell` in the body row: a row header, drawn as a strong cell. Prose wraps, a sentence with a link or a code in it too; everything else stays on one line: a link, a code, a figure and a date alone never break, and a long table scrolls sideways instead of squeezing them.
|
|
52
52
|
- A table read on a phone row by row, with few columns, takes `narrow="stack"`: on a screen narrower than `sm` (a phone) each row is a card, the first column its title and every other cell a line with its column's title. A table compared down its columns keeps the default, `narrow="scroll"`.
|
|
53
53
|
|
|
54
54
|
### Don't
|
|
@@ -277,7 +277,7 @@ down a column.
|
|
|
277
277
|
new direction.
|
|
278
278
|
|
|
279
279
|
### TableHead
|
|
280
|
-
The `<thead>`: small uppercase column titles, on a tinted strip unless the table is in a card. Holds one `TableRow` of `TableHeaderCell`s. Unless the table is in a card, it stays in view under the `AppShell` header while the page scrolls past the rows,
|
|
280
|
+
The `<thead>`: small uppercase column titles, on a tinted strip unless the table is in a card. Holds one `TableRow` of `TableHeaderCell`s. Unless the table is in a card, it stays in view under the `AppShell` header while the page scrolls past the rows, once the table is measured and fits its box; before that, and while the table is wider than its box, it stays at the top of the table.
|
|
281
281
|
|
|
282
282
|
### TableBody
|
|
283
283
|
The `<tbody>`: the rows, each with a line above it and, unless the table is in a card, a fill on hover. With no rows it draws `empty` (an `EmptyState`, one muted line here) in one cell that spans every column the head declares; the head stays drawn, so the reader sees what the table holds. In a loading `Table` a body with no rows draws five rows of bones instead, never `empty`.
|
|
@@ -312,16 +312,16 @@ With `onSort` the title becomes a button that asks for the next direction. The t
|
|
|
312
312
|
sorts, filters or pages.
|
|
313
313
|
|
|
314
314
|
### TableCell
|
|
315
|
-
A `<td>`. `tone` is the text weight and colour (see `CellTone`; in a `TableFoot` it defaults to `strong`); `numeric` sets end alignment and tabular figures (a cell under a `numeric` head cell is numeric already), `mono` a small mono face. `secondary` is a second, muted line under the content. One rule for wrapping: prose (a cell
|
|
315
|
+
A `<td>`. `tone` is the text weight and colour (see `CellTone`; in a `TableFoot` it defaults to `strong`); `numeric` sets end alignment and tabular figures (a cell under a `numeric` head cell is numeric already), `mono` a small mono face. `secondary` is a second, muted line under the content. One rule for wrapping: prose (a cell with words in it, plain or with a link or a code among them) wraps onto more lines (never narrower than `min-w-48`, so it scrolls the table before it becomes a sliver); any other cell stays on one line at its content's width: one that holds only a control or a link, and a `numeric` or `mono` cell (a figure, a code, a type). `lines={1}` caps a long value's width, cuts it with an ellipsis on one line and, while it is cut, shows the full text in a tooltip on hover, focus and a tap; the content is then plain text (strings and numbers), since that is what the tooltip shows. `colSpan` passes through: a cell that spans the row is a full-width panel (a note under a group), and `align="center"` centres it. A table with no rows takes `TableBody empty`, not a cell built by hand. `span="full"` spans every column the head declares, so a panel under a row needs no count. `indent` sets a start-aligned cell in by 1 to 3 levels, for a line under a parent row. While `loading` an empty cell draws one bone, the width of a short value.
|
|
316
316
|
- align: "center" | "end" | "start" (default end for a numeric cell, else start). The cell's horizontal alignment; `center` for a full-width note.
|
|
317
317
|
- colSpan: number. How many columns the cell spans; `span="full"` spans them all without a count.
|
|
318
318
|
- indent: 2 | 3 | 1. Sets the cell in by this many levels (1 to 3), for a line under a parent row. Start-aligned cells only.
|
|
319
319
|
- lines: 1. `1` caps the width and cuts a long value with an ellipsis on one line; while it is cut, the full
|
|
320
320
|
text shows in a tooltip on hover, keyboard focus and a tap. Plain text content only.
|
|
321
321
|
|
|
322
|
-
Without it, a prose cell
|
|
323
|
-
(a `Pill`, a `Switch`, a `Button`, a
|
|
324
|
-
at its content's width.
|
|
322
|
+
Without it, a prose cell (words, with or without a link or a code among them) wraps down to a
|
|
323
|
+
floor so it never becomes a sliver, and any other cell (a `Pill`, a `Switch`, a `Button`, a
|
|
324
|
+
`TextLink` alone, a `numeric` or `mono` value) stays on one line at its content's width.
|
|
325
325
|
- loading: boolean. The data is not here yet: an empty slot draws a bone of its shape, a filled one draws as usual.
|
|
326
326
|
Left out, the part takes the nearest loading layout's or part's; `false` opts it out inside one.
|
|
327
327
|
- loadingLabel: string (default Loading). What a screen reader hears while this part is loading, when its own `loading` is set.
|
package/dist/Markdown.js
CHANGED
|
@@ -15,8 +15,11 @@ const SAFE_SRC = /^(https?:|\/|\.\/|\.\.\/|data:image\/)/i;
|
|
|
15
15
|
const INLINE = /(\*\*[^*]+\*\*|!?\[[^\]]*\]\([^)\s]*\))/g;
|
|
16
16
|
const LINK = /^\[([^\]]*)\]\(([^)\s]*)\)$/;
|
|
17
17
|
const IMAGE = /^!\[([^\]]*)\]\(([^)\s]*)\)$/;
|
|
18
|
+
/** A line's inline parts; plain words stay plain text, so a table cell of them reads as prose and wraps. */
|
|
18
19
|
function inline(text) {
|
|
19
|
-
return text.split(INLINE).
|
|
20
|
+
return text.split(INLINE).flatMap((p, i) => {
|
|
21
|
+
if (p === "")
|
|
22
|
+
return [];
|
|
20
23
|
if (p.startsWith("**") && p.endsWith("**") && p.length > 4) {
|
|
21
24
|
return (_jsx("strong", { className: "font-semibold text-slate-900", children: p.slice(2, -2) }, i));
|
|
22
25
|
}
|
|
@@ -24,10 +27,10 @@ function inline(text) {
|
|
|
24
27
|
if (link) {
|
|
25
28
|
const [, words = "", href = ""] = link;
|
|
26
29
|
if (!SAFE_HREF.test(href))
|
|
27
|
-
return
|
|
30
|
+
return words;
|
|
28
31
|
return (_jsx(TextLink, { href: href, underline: true, children: words }, i));
|
|
29
32
|
}
|
|
30
|
-
return
|
|
33
|
+
return p;
|
|
31
34
|
});
|
|
32
35
|
}
|
|
33
36
|
/** The level of a `### ` heading: one below a `## `, never past 6. */
|
package/dist/Table.d.ts
CHANGED
|
@@ -47,7 +47,8 @@ export declare function Table({ label, size, narrow, sortedLabel, loading, loadi
|
|
|
47
47
|
/**
|
|
48
48
|
* The `<thead>`: small uppercase column titles, on a tinted strip unless the table is in a card.
|
|
49
49
|
* Holds one `TableRow` of `TableHeaderCell`s. Unless the table is in a card, it stays in view under
|
|
50
|
-
* the `AppShell` header while the page scrolls past the rows,
|
|
50
|
+
* the `AppShell` header while the page scrolls past the rows, once the table is measured and fits
|
|
51
|
+
* its box; before that, and while the table is wider than its box, it stays at the top of the table.
|
|
51
52
|
*/
|
|
52
53
|
export declare function TableHead({ children, ...rest }: {
|
|
53
54
|
children: ReactNode;
|
package/dist/Table.js
CHANGED
|
@@ -40,7 +40,7 @@ export function Table({ label, size = "sm", narrow = "scroll", sortedLabel = eng
|
|
|
40
40
|
// Until measured (a page rendered on the server) and while too wide, the box scrolls sideways.
|
|
41
41
|
// Once it fits, it clips instead: a clipping box is no scroll container, so the head can stick.
|
|
42
42
|
const fits = measured && !overflows;
|
|
43
|
-
return (_jsx(TableContext.Provider, { value: { plain, size, numeric, columns, announce, stack, titles }, children: _jsx(DensityProvider, { size: size, children: _jsxs("div", { ref: attach, ...stopProps, className: cx(fits ? "overflow-clip" : "overflow-x-auto", ring, !plain && "rounded-xl border border-slate-200/70 bg-white shadow-sm"), children: [_jsxs("table", { ...rest, ...stackRole(stack, "table"), ...busy(owner, waiting), className: cx("w-full text-left text-sm", stack && STACK.table), children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(LoadingScope, { loading: waiting, children: children })] }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }), _jsx("div", { role: "status", className: "sr-only", children: said })] }) }) }));
|
|
43
|
+
return (_jsx(TableContext.Provider, { value: { plain, fits, size, numeric, columns, announce, stack, titles }, children: _jsx(DensityProvider, { size: size, children: _jsxs("div", { ref: attach, ...stopProps, className: cx(fits ? "overflow-clip" : "overflow-x-auto", ring, !plain && "rounded-xl border border-slate-200/70 bg-white shadow-sm"), children: [_jsxs("table", { ...rest, ...stackRole(stack, "table"), ...busy(owner, waiting), className: cx("w-full text-left text-sm", stack && STACK.table), children: [_jsx("caption", { className: "sr-only", children: label }), _jsx(LoadingScope, { loading: waiting, children: children })] }), _jsx(BusyLabel, { owner: owner, loading: waiting, label: loadingLabel }), _jsx("div", { role: "status", className: "sr-only", children: said })] }) }) }));
|
|
44
44
|
}
|
|
45
45
|
/** The default `sortedLabel`. */
|
|
46
46
|
function englishSorted(column, sort) {
|
|
@@ -54,11 +54,12 @@ function tableWider(box) {
|
|
|
54
54
|
/**
|
|
55
55
|
* The `<thead>`: small uppercase column titles, on a tinted strip unless the table is in a card.
|
|
56
56
|
* Holds one `TableRow` of `TableHeaderCell`s. Unless the table is in a card, it stays in view under
|
|
57
|
-
* the `AppShell` header while the page scrolls past the rows,
|
|
57
|
+
* the `AppShell` header while the page scrolls past the rows, once the table is measured and fits
|
|
58
|
+
* its box; before that, and while the table is wider than its box, it stays at the top of the table.
|
|
58
59
|
*/
|
|
59
60
|
export function TableHead({ children, ...rest }) {
|
|
60
|
-
const { plain, stack } = useContext(TableContext);
|
|
61
|
-
return (_jsx("thead", { ...rest, ...stackRole(stack, "rowgroup"), className: cx("text-sm uppercase tracking-wide text-slate-500", !plain && "sticky top-[var(--app-header,0px)] z-1
|
|
61
|
+
const { plain, fits, stack } = useContext(TableContext);
|
|
62
|
+
return (_jsx("thead", { ...rest, ...stackRole(stack, "rowgroup"), className: cx("text-sm uppercase tracking-wide text-slate-500", !plain && "bg-slate-50", !plain && fits && "sticky top-[var(--app-header,0px)] z-1", stack && STACK.head), children: _jsx(SectionContext.Provider, { value: "head", children: children }) }));
|
|
62
63
|
}
|
|
63
64
|
/**
|
|
64
65
|
* The `<tbody>`: the rows, each with a line above it and, unless the table is in a card, a fill on
|
package/dist/TableCells.d.ts
CHANGED
|
@@ -48,9 +48,10 @@ type Indent = 1 | 2 | 3;
|
|
|
48
48
|
* A `<td>`. `tone` is the text weight and colour (see `CellTone`; in a `TableFoot` it defaults to
|
|
49
49
|
* `strong`); `numeric` sets end alignment and tabular figures (a cell under a `numeric` head cell is
|
|
50
50
|
* numeric already), `mono` a small mono face. `secondary` is a second,
|
|
51
|
-
* muted line under the content. One rule for wrapping: prose (a cell
|
|
52
|
-
* lines (never narrower than `min-w-48`, so it scrolls the
|
|
53
|
-
* other cell stays on one line at its content's width: one that
|
|
51
|
+
* muted line under the content. One rule for wrapping: prose (a cell with words in it, plain or with a
|
|
52
|
+
* link or a code among them) wraps onto more lines (never narrower than `min-w-48`, so it scrolls the
|
|
53
|
+
* table before it becomes a sliver); any other cell stays on one line at its content's width: one that
|
|
54
|
+
* holds only a control or a link, and a
|
|
54
55
|
* `numeric` or `mono` cell (a figure, a code, a type). `lines={1}` caps a long value's width, cuts it with
|
|
55
56
|
* an ellipsis on one line and, while it is cut, shows the full text in a tooltip on hover, focus and a
|
|
56
57
|
* tap; the content is then plain text (strings and numbers), since that is what the tooltip shows. `colSpan` passes through: a cell that
|
|
@@ -80,9 +81,9 @@ export declare function TableCell({ span, colSpan, align, tone, numeric, mono, l
|
|
|
80
81
|
* `1` caps the width and cuts a long value with an ellipsis on one line; while it is cut, the full
|
|
81
82
|
* text shows in a tooltip on hover, keyboard focus and a tap. Plain text content only.
|
|
82
83
|
*
|
|
83
|
-
* Without it, a prose cell
|
|
84
|
-
* (a `Pill`, a `Switch`, a `Button`, a
|
|
85
|
-
* at its content's width.
|
|
84
|
+
* Without it, a prose cell (words, with or without a link or a code among them) wraps down to a
|
|
85
|
+
* floor so it never becomes a sliver, and any other cell (a `Pill`, a `Switch`, a `Button`, a
|
|
86
|
+
* `TextLink` alone, a `numeric` or `mono` value) stays on one line at its content's width.
|
|
86
87
|
*/
|
|
87
88
|
lines?: 1 | undefined;
|
|
88
89
|
/** A second, muted line under the content. */
|
package/dist/TableCells.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
-
import { Children, useContext } from "react";
|
|
2
|
+
import { Children, Fragment, isValidElement, useContext, } from "react";
|
|
3
3
|
import { cx } from "./cx.js";
|
|
4
4
|
import { TableContext, useNumericColumn, useStackLabel } from "./tableColumns.js";
|
|
5
5
|
import { ALIGN, PAD, SectionContext, STACK, stackRole, } from "./tableRow.js";
|
|
@@ -57,11 +57,11 @@ function spansColumns(span, colSpan) {
|
|
|
57
57
|
return span === "full" || (colSpan !== undefined && colSpan > 1);
|
|
58
58
|
}
|
|
59
59
|
/**
|
|
60
|
-
* The wrapping rule, one for every cell: prose (
|
|
61
|
-
* `min-w-48`; everything else stays on one line
|
|
62
|
-
*
|
|
63
|
-
* only as wide as they are, and a link's words
|
|
64
|
-
* scrolls instead.
|
|
60
|
+
* The wrapping rule, one for every cell: prose (words, alone or with inline parts among them, such as
|
|
61
|
+
* a sentence with a link or a code in it) wraps, down to `min-w-48`; everything else stays on one line
|
|
62
|
+
* at its content's width: a figure, a code, and a cell of elements alone (a link, a `Pill`, a
|
|
63
|
+
* `Switch`, a `Button`). So a column of short controls is only as wide as they are, and a link's words
|
|
64
|
+
* never break one per line on a phone: the table scrolls instead.
|
|
65
65
|
*/
|
|
66
66
|
function figureClass(numeric, mono, prose) {
|
|
67
67
|
if (!numeric && !mono)
|
|
@@ -85,9 +85,10 @@ const INDENT = {
|
|
|
85
85
|
* A `<td>`. `tone` is the text weight and colour (see `CellTone`; in a `TableFoot` it defaults to
|
|
86
86
|
* `strong`); `numeric` sets end alignment and tabular figures (a cell under a `numeric` head cell is
|
|
87
87
|
* numeric already), `mono` a small mono face. `secondary` is a second,
|
|
88
|
-
* muted line under the content. One rule for wrapping: prose (a cell
|
|
89
|
-
* lines (never narrower than `min-w-48`, so it scrolls the
|
|
90
|
-
* other cell stays on one line at its content's width: one that
|
|
88
|
+
* muted line under the content. One rule for wrapping: prose (a cell with words in it, plain or with a
|
|
89
|
+
* link or a code among them) wraps onto more lines (never narrower than `min-w-48`, so it scrolls the
|
|
90
|
+
* table before it becomes a sliver); any other cell stays on one line at its content's width: one that
|
|
91
|
+
* holds only a control or a link, and a
|
|
91
92
|
* `numeric` or `mono` cell (a figure, a code, a type). `lines={1}` caps a long value's width, cuts it with
|
|
92
93
|
* an ellipsis on one line and, while it is cut, shows the full text in a tooltip on hover, focus and a
|
|
93
94
|
* tap; the content is then plain text (strings and numbers), since that is what the tooltip shows. `colSpan` passes through: a cell that
|
|
@@ -132,10 +133,15 @@ function Stacked({ label, children }) {
|
|
|
132
133
|
return (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", className: STACK.label, children: label }), _jsx("div", { className: STACK.value, children: children })] }));
|
|
133
134
|
}
|
|
134
135
|
const isText = (node) => typeof node === "string" || typeof node === "number";
|
|
135
|
-
/**
|
|
136
|
+
/**
|
|
137
|
+
* Prose: words in the cell itself, alone or among inline parts (a sentence with a link or a code in
|
|
138
|
+
* it), a fragment's parts counted as the cell's own. A cell of elements alone, joined by nothing but spaces, is not prose; nor is an empty cell (a
|
|
139
|
+
* bone), which keeps no width.
|
|
140
|
+
*/
|
|
136
141
|
function isProse(children) {
|
|
137
|
-
|
|
138
|
-
|
|
142
|
+
return Children.toArray(children).some((part) => isValidElement(part) && part.type === Fragment
|
|
143
|
+
? isProse(part.props.children)
|
|
144
|
+
: isText(part) && String(part).trim() !== "");
|
|
139
145
|
}
|
|
140
146
|
/** What a cell holds: the content, cut to one line when `truncate` (its full text in a tooltip while cut), then the `secondary` line. */
|
|
141
147
|
function CellBody({ align, truncate, secondary, children, }) {
|
package/dist/tableColumns.d.ts
CHANGED
|
@@ -6,6 +6,12 @@ import type { Size } from "./size.js";
|
|
|
6
6
|
*/
|
|
7
7
|
type TableSetting = {
|
|
8
8
|
plain: boolean;
|
|
9
|
+
/**
|
|
10
|
+
* Whether the table was measured and fits its box. Only then does the box clip instead of
|
|
11
|
+
* scroll, so only then can the head stick to the page: inside a box that scrolls sideways a
|
|
12
|
+
* sticky head sticks to that box, pushed down over the rows by the app header's height.
|
|
13
|
+
*/
|
|
14
|
+
fits: boolean;
|
|
9
15
|
size: Size;
|
|
10
16
|
numeric: readonly boolean[];
|
|
11
17
|
/** How many columns the head declares, or `undefined` with no `TableHead`. */
|
package/dist/tableColumns.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@slashsuite/ui-react",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.2",
|
|
4
4
|
"description": "UISlash React components: primitives, typography roles and a safe Markdown renderer, written against Tailwind v4 utilities. Pair with a theme from @slashsuite/themes.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"components",
|