@tristan2828/ui-foundation 4.102.0 → 4.103.0

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.
@@ -4,46 +4,46 @@
4
4
  ## Index
5
5
 
6
6
  - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 75–98
7
- - [1. Plain text](#1-plain-text) · lines 100–153
8
- - [2. Icon + label](#2-icon--label) · lines 155–178
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 180–193
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 195–272
11
- - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 220–272
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 274–294
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 296–308
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 310–331
15
- - [8. Date, relative](#8-date-relative) · lines 333–370
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 372–420
17
- - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 390–420
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 422–472
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 440–472
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 474–514
21
- - [12. Boolean](#12-boolean) · lines 516–546
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 548–584
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 568–584
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 586–603
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 605–714
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 631–714
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 716–751
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 753–826
29
- - [18. Editable value](#18-editable-value) · lines 828–1531
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1163–1231
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1233–1269
32
- - [A link and its label](#a-link-and-its-label) · lines 1271–1295
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1297–1430
34
- - [In a table's rows](#in-a-tables-rows) · lines 1432–1517
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1519–1531
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1533–1599
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1601–1665
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1667–1765
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1767–1796
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1798–1836
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1838–1914
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1916–1939
43
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1941–2067
44
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2029–2067
45
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2069–2105
46
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2107–2152
7
+ - [1. Plain text](#1-plain-text) · lines 100–155
8
+ - [2. Icon + label](#2-icon--label) · lines 157–180
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 182–195
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 197–274
11
+ - [Several values: the icons side by side, every name in one tooltip](#several-values-the-icons-side-by-side-every-name-in-one-tooltip) · lines 222–274
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 276–296
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 298–310
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 312–333
15
+ - [8. Date, relative](#8-date-relative) · lines 335–372
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 374–422
17
+ - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 392–422
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 424–474
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 442–474
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 476–516
21
+ - [12. Boolean](#12-boolean) · lines 518–548
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 550–586
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 570–586
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 588–605
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 607–716
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 633–716
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 718–764
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 766–839
29
+ - [18. Editable value](#18-editable-value) · lines 841–1544
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1176–1244
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1246–1282
32
+ - [A link and its label](#a-link-and-its-label) · lines 1284–1308
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1310–1443
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1445–1530
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1532–1544
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1546–1612
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1614–1678
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1680–1778
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1780–1809
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1811–1849
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1851–1927
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1929–1952
43
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 1954–2080
44
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2042–2080
45
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2082–2118
46
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2120–2165
47
47
 
48
48
  <!-- /index -->
49
49
 
@@ -151,6 +151,8 @@ can't make the whole table thousands of pixels wide:
151
151
  reads the whole text either way, and the record shows it too.
152
152
  - `meta.maxWidth` alone caps the column and lets its text wrap, for a
153
153
  value worth reading whole in the row.
154
+ - The title column (the first) is cut this way already, with no `meta`
155
+ (pattern 16, 4.103).
154
156
 
155
157
  ## 2. Icon + label
156
158
 
@@ -749,6 +751,17 @@ cell: ({ row }) => (
749
751
  - **Cost:** none to speak of. Specs that match the title as a cell still
750
752
  work (`getByRole('cell', { name })` reads the link's text); ones that
751
753
  opened the form from a row button go through the view's Edit instead.
754
+ - **DataTable caps the title column (4.103).** The first column is the
755
+ title column: at every width it's cut to one line at 24rem (never over
756
+ 60% of the table's area) with an ellipsis, so a long title (a
757
+ discussion's topic) can't push the other columns off. A cut title shows
758
+ whole in a tooltip on hover and when its link takes focus; the link
759
+ stays the row's only tab stop, and a screen reader reads it whole. Put
760
+ the title column first and write no clip of your own (`truncate`,
761
+ `max-w-*`) around it. `meta: { wrap: true }` wraps it at the cap
762
+ instead, for a title worth reading whole in the row;
763
+ `meta: { maxWidth: 'none' }` lifts the cap. Its own `meta.clip` or
764
+ `meta.maxWidth` works as on any column (cut, or wrapped, at that width).
752
765
 
753
766
  ## 17. Quick action on the view
754
767
 
@@ -22,9 +22,19 @@ declare module '@tanstack/table-core' {
22
22
  /**
23
23
  * The widest the column's content gets, as a CSS length: `'24rem'`
24
24
  * unless set, with `clip` (and never over 60% of the table's area, for
25
- * a phone). Without `clip`, the content wraps at it.
25
+ * a phone). Without `clip`, the content wraps at it. The title column
26
+ * (the first) is cut at 24rem when neither is set.
26
27
  */
27
28
  maxWidth?: string;
29
+ /**
30
+ * The title column (the table's first, the row's name): wrap at
31
+ * `maxWidth` (`'24rem'` unless set) instead of the default, one line cut
32
+ * at 24rem with an ellipsis. For a title worth reading whole in the row.
33
+ * A title column with `maxWidth: 'none'` has no cap at all (the look
34
+ * before 4.103); one with its own `clip` or `maxWidth` is cut or wrapped
35
+ * at it, as any column is.
36
+ */
37
+ wrap?: boolean;
28
38
  /**
29
39
  * The column's name in DataTable's Columns menu (`columnsMenu`), for a
30
40
  * column whose `header` isn't a string.
@@ -138,15 +138,20 @@ function PageSizeMenu({ pageSizes, value, onValueChange, }) {
138
138
  // A cell's text cut to one line (`meta.clip`). Only when it is cut does it
139
139
  // take a tab stop and a tooltip with the whole text, on hover and on focus;
140
140
  // re-measured on every render (the text may change) and on every resize.
141
- function ClippedText({ maxWidth, children }) {
141
+ // A cut cell whose content has a control of its own (the title's link)
142
+ // takes no tab stop: the control already has one, and focusing it opens
143
+ // the tooltip, since focus reaches the trigger from inside it.
144
+ function ClippedText({ maxWidth, slot = 'data-table-clip', children, }) {
142
145
  const ref = useRef(null);
143
146
  const [fullText, setFullText] = useState(null);
147
+ const [hasControl, setHasControl] = useState(false);
144
148
  const measure = () => {
145
149
  const element = ref.current;
146
150
  if (!element)
147
151
  return;
148
152
  const isCut = element.scrollWidth > element.clientWidth + 0.5;
149
153
  setFullText(isCut ? element.textContent?.trim() || null : null);
154
+ setHasControl(element.querySelector(ROW_CONTROL_SELECTOR) !== null);
150
155
  };
151
156
  useLayoutEffect(measure);
152
157
  useEffect(() => {
@@ -157,10 +162,10 @@ function ClippedText({ maxWidth, children }) {
157
162
  observer.observe(element);
158
163
  return () => observer.disconnect();
159
164
  }, []);
160
- return (_jsxs(Tooltip, { disabled: fullText === null, children: [_jsx(TooltipTrigger, { render: _jsx("span", { ref: ref, "data-slot": "data-table-clip", className: CLIP_CLASS,
165
+ return (_jsxs(Tooltip, { disabled: fullText === null, children: [_jsx(TooltipTrigger, { render: _jsx("span", { ref: ref, "data-slot": slot, className: slot === 'data-table-title' ? TITLE_CLIP_CLASS : CLIP_CLASS,
161
166
  // Never more than 60% of the table's area, so on a phone the
162
167
  // cut column leaves the name and the rest room.
163
- style: { maxWidth: `min(${maxWidth}, 60cqw)` }, tabIndex: fullText === null ? undefined : 0 }), children: children }), _jsx(TooltipContent, { className: "max-w-sm break-words whitespace-normal", children: fullText })] }));
168
+ style: { maxWidth: `min(${maxWidth}, 60cqw)` }, tabIndex: fullText === null || hasControl ? undefined : 0 }), children: children }), _jsx(TooltipContent, { className: "max-w-sm break-words whitespace-normal", children: fullText })] }));
164
169
  }
165
170
  // Whether the detail panel (`detailPanel`) fits beside the table, or opens
166
171
  // as a bottom sheet. Wide on the server and wherever matchMedia is missing
@@ -221,11 +226,15 @@ const HOVER_FOCUSED_ROW_CLASS = 'focus-visible:hover:[&>td:first-child]:shadow-[
221
226
  // A column's `meta.clip`: one line, cut at `meta.maxWidth` with an ellipsis.
222
227
  const DEFAULT_CLIP_WIDTH = '24rem';
223
228
  const CLIP_CLASS = 'block truncate rounded-sm outline-none focus-visible:ring-3 focus-visible:ring-ring/50';
229
+ // The title's: padding, taken back by the margin, keeps its link's focus
230
+ // ring clear of the cut.
231
+ const TITLE_CLIP_CLASS = cn(CLIP_CLASS, '-m-1 p-1');
224
232
  // A pinned first column's content, capped below md at 45% of the table's
225
233
  // scroll area (`cqw`: the container is an inline-size query container)
226
234
  // and wrapping, so a long title can't widen the column past the screen
227
235
  // and leave every other column scrolling underneath it (issue #91).
228
- // Wider screens are unchanged: the column sizes to its content.
236
+ // The title inside is capped at every width too (cut at 24rem, or
237
+ // wrapped with `meta.wrap`), so wider screens don't overrun either.
229
238
  const PINNED_FIRST_CONTENT_CLASS = 'max-md:max-w-[45cqw] max-md:whitespace-normal max-md:break-words';
230
239
  // `highlightRow`: the wash on every cell, so it covers the zebra stripe
231
240
  // (on the row) and the pinned cells' opaque backgrounds (on the cell, and
@@ -700,7 +709,14 @@ export function DataTable({ columns, data, total, page, pageSize, onPageChange,
700
709
  : {}), className: cn('hover:bg-transparent', hovers && HOVER_ROW_CLASS, isHighlighted && HIGHLIGHTED_ROW_CLASS, rowsOpen && SELECTABLE_ROW_CLASS, rowsOpen && hovers && HOVER_FOCUSED_ROW_CLASS, isSelected && SELECTED_ROW_CLASS), children: row.getVisibleCells().map((cell, index) => {
701
710
  const meta = cell.column.columnDef.meta;
702
711
  const value = flexRender(cell.column.columnDef.cell, cell.getContext());
703
- const shown = meta?.clip ? (_jsx(ClippedText, { maxWidth: meta.maxWidth ?? DEFAULT_CLIP_WIDTH, children: value })) : meta?.maxWidth ? (_jsx("div", { className: "whitespace-normal break-words", style: { maxWidth: meta.maxWidth }, children: value })) : (value);
712
+ // The title column (the first) is capped at every width (a long
713
+ // discussion topic overran above md): cut to one line by default,
714
+ // or wrapped with `meta.wrap`; `maxWidth: 'none'` lifts the cap. A
715
+ // first column with its own `clip` or `maxWidth` keeps their meaning.
716
+ const isTitle = index === 0 &&
717
+ cell.column.id !== ROW_ACTIONS_COLUMN_ID &&
718
+ (meta?.wrap || (!meta?.clip && meta?.maxWidth === undefined));
719
+ const shown = isTitle && meta?.wrap ? (_jsx("div", { "data-slot": "data-table-title", className: "whitespace-normal break-words", style: { maxWidth: `min(${meta.maxWidth ?? DEFAULT_CLIP_WIDTH}, 60cqw)` }, children: value })) : isTitle ? (_jsx(ClippedText, { maxWidth: meta?.maxWidth ?? DEFAULT_CLIP_WIDTH, slot: "data-table-title", children: value })) : meta?.clip ? (_jsx(ClippedText, { maxWidth: meta.maxWidth ?? DEFAULT_CLIP_WIDTH, children: value })) : meta?.maxWidth && meta.maxWidth !== 'none' ? (_jsx("div", { className: "whitespace-normal break-words", style: { maxWidth: meta.maxWidth }, children: value })) : (value);
704
720
  const isPinnedFirst = pinFirstColumn && index === 0;
705
721
  const isPinnedLast = pinLast && index === row.getVisibleCells().length - 1;
706
722
  return (_jsx(TableCell, { className: cn(isPinnedFirst && PINNED_COLUMN_CLASS, isPinnedLast && PINNED_LAST_COLUMN_CLASS, (isPinnedFirst || isPinnedLast) && striped && PINNED_STRIPED_CELL_CLASS, alignClass(meta?.align), cell.column.id === ROW_ACTIONS_COLUMN_ID && ROW_ACTIONS_CELL_CLASS), children: isPinnedFirst ? _jsx("div", { className: PINNED_FIRST_CONTENT_CLASS, children: shown }) : shown }, cell.id));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.102.0",
3
+ "version": "4.103.0",
4
4
  "description": "Shared UI foundation for contract-first, database-backed React apps: shadcn primitives, DataTable/EntityForm composites, auth, the gateway error seam, design tokens, lint rules and the AI playbook.",
5
5
  "license": "MIT",
6
6
  "repository": {