@slashsuite/ui-react 0.16.1 → 0.16.3

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.
@@ -52,7 +52,7 @@ import { CodeBlock } from "@slashsuite/ui-react";
52
52
 
53
53
  ### Props
54
54
  ### Code
55
- Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line, cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken value at the edge of its box, as `Text` does.
55
+ Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line, cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken value at the edge of its box, as `Text` does.
56
56
  - breakWords: boolean (default false). Breaks a long unbroken value (a URL, a hash) at the edge of its box.
57
57
  - id: string. The root element's `id`: an anchor, or the target of a `for` or an `aria-describedby`.
58
58
  - lines: 1. `1` keeps it on one line, cut with an ellipsis; while it is cut, its whole text shows in a tooltip.
@@ -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
@@ -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 of plain text) 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 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.
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 wraps down to a floor so it never becomes a sliver, and any other cell
323
- (a `Pill`, a `Switch`, a `Button`, a `TextLink`, a `numeric` or `mono` value) stays on one line
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/Code.d.ts CHANGED
@@ -2,7 +2,7 @@ import { type ReactElement, type ReactNode } from "react";
2
2
  import type { Passthrough } from "./props.js";
3
3
  /**
4
4
  * Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a
5
- * touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line,
5
+ * touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line,
6
6
  * cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken
7
7
  * value at the edge of its box, as `Text` does.
8
8
  */
package/dist/Code.js CHANGED
@@ -5,12 +5,12 @@ import { layoutClass } from "./textBox.js";
5
5
  import { Truncated } from "./truncated.js";
6
6
  /**
7
7
  * Inline code: mono, on a subtle inset background. It takes the surrounding text colour and size (a
8
- * touch smaller, for the mono face). `lines={1}` keeps a long value (a hash, a path) on one line,
8
+ * touch smaller, for the mono face, and never under 14px). `lines={1}` keeps a long value (a hash, a path) on one line,
9
9
  * cut with an ellipsis, and shows its whole text in a tooltip while it is cut; `breakWords` instead breaks a long unbroken
10
10
  * value at the edge of its box, as `Text` does.
11
11
  */
12
12
  export function Code({ lines, breakWords = false, children, ...rest }) {
13
- const look = cx("rounded bg-slate-100 px-1 py-0.5 font-mono text-[0.9em]", layoutClass(undefined, lines), breakWords && "break-words");
13
+ const look = cx("rounded bg-slate-100 px-1 py-0.5 font-mono text-[length:max(0.9em,0.875rem)]", layoutClass(undefined, lines), breakWords && "break-words");
14
14
  if (lines === 1) {
15
15
  return (_jsx(Truncated, { as: "code", attrs: rest, text: plainText(children), className: look, children: children }));
16
16
  }
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).map((p, i) => {
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 _jsx("span", { children: words }, i);
30
+ return words;
28
31
  return (_jsx(TextLink, { href: href, underline: true, children: words }, i));
29
32
  }
30
- return _jsx("span", { children: p }, i);
33
+ return p;
31
34
  });
32
35
  }
33
36
  /** The level of a `### ` heading: one below a `## `, never past 6. */
@@ -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 of plain text) wraps onto more
52
- * lines (never narrower than `min-w-48`, so it scrolls the table before it becomes a sliver); any
53
- * other cell stays on one line at its content's width: one that holds a control or a link, and a
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 wraps down to a floor so it never becomes a sliver, and any other cell
84
- * (a `Pill`, a `Switch`, a `Button`, a `TextLink`, a `numeric` or `mono` value) stays on one line
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. */
@@ -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 (plain text and nothing else) wraps, down to
61
- * `min-w-48`; everything else stays on one line at its content's width: a figure, a code, and a cell
62
- * that holds an element (a link, a `Pill`, a `Switch`, a `Button`). So a column of short controls is
63
- * only as wide as they are, and a link's words never break one per line on a phone: the table
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 of plain text) wraps onto more
89
- * lines (never narrower than `min-w-48`, so it scrolls the table before it becomes a sliver); any
90
- * other cell stays on one line at its content's width: one that holds a control or a link, and a
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
- /** Prose: at least one part, every one text. An empty cell (a bone) is not prose and keeps no width. */
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
- const parts = Children.toArray(children);
138
- return parts.length > 0 && parts.every(isText);
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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@slashsuite/ui-react",
3
- "version": "0.16.1",
3
+ "version": "0.16.3",
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",