@tristan2828/ui-foundation 4.95.0 → 4.96.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.
@@ -15,17 +15,17 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 752–830
16
16
  - Step 9: Register the nav entry and route names · lines 831–845
17
17
  - Step 10: `npm run verify`. · lines 846–848
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 850–1169
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 850–1178
19
19
  - [The record view](#the-record-view) · lines 999–1047
20
20
  - [Forms](#forms) · lines 1049–1101
21
21
  - [Dialogs](#dialogs) · lines 1103–1128
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1130–1169
23
- - [What not to copy](#what-not-to-copy) · lines 1171–1197
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1199–1216
25
- - [Deleting](#deleting) · lines 1218–1249
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1251–1272
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1274–1283
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1286–1328
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1130–1178
23
+ - [What not to copy](#what-not-to-copy) · lines 1180–1206
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1208–1225
25
+ - [Deleting](#deleting) · lines 1227–1258
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1260–1281
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1283–1292
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1295–1337
29
29
 
30
30
  <!-- /index -->
31
31
 
@@ -1154,6 +1154,15 @@ sight.** What happened where the person is looking says so there.
1154
1154
  `open`/`onOpenChange`, opened by a `DataTable` `rowActions` entry's
1155
1155
  `onSelect` (a row's ⋯ menu). `verb="Retire"` for a retire.
1156
1156
  Never a delete without a confirm, never a hand-written dialog.
1157
+ - **A delete that asks a reason: `DeleteAction reason`** (4.96). One
1158
+ optional field between the sentence and the buttons, a "Why" box:
1159
+ `reason={{ label: 'Why remove it?', hint: 'Kept with its history.' }}`
1160
+ and `onDelete={(why) => remove({ id, reason: why })}`, `why` trimmed
1161
+ and `''` when nothing's typed. The rest is the same confirm: 420px, a
1162
+ bottom sheet on a phone, Cancel then the filled destructive button, a
1163
+ refusal in the dialog with Try again (sending the same words), and
1164
+ closing with something typed asks "Discard your changes?" first. One
1165
+ field only: a confirm that needs more is a `FormDialog`.
1157
1166
  - **A toast's words come from `notify.done(verb, name, { undo })`**: the
1158
1167
  verb first, "Deleted The Long Walk", "Added Paper Atlas"; Undo, when
1159
1168
  given, then says "Restored The Long Walk". Never "X deleted", never
@@ -3,46 +3,46 @@
3
3
  <!-- index: written by `npm run docs:index` in the package from the headings below; never edit it by hand -->
4
4
  ## Index
5
5
 
6
- - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 74–93
7
- - [1. Plain text](#1-plain-text) · lines 95–148
8
- - [2. Icon + label](#2-icon--label) · lines 150–173
9
- - [3. Icon in a badge](#3-icon-in-a-badge) · lines 175–188
10
- - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 190–267
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 215–267
12
- - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 269–282
13
- - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 284–296
14
- - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 298–319
15
- - [8. Date, relative](#8-date-relative) · lines 321–358
16
- - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 360–408
17
- - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 378–408
18
- - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 410–460
19
- - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 428–460
20
- - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 462–502
21
- - [12. Boolean](#12-boolean) · lines 504–534
22
- - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 536–572
23
- - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 556–572
24
- - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 574–591
25
- - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 593–702
26
- - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 619–702
27
- - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 704–739
28
- - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 741–814
29
- - [18. Editable value](#18-editable-value) · lines 816–1494
30
- - [Presets: one line per field](#presets-one-line-per-field) · lines 1126–1194
31
- - [Several fields edited as one](#several-fields-edited-as-one) · lines 1196–1232
32
- - [A link and its label](#a-link-and-its-label) · lines 1234–1258
33
- - [A list of sub-items](#a-list-of-sub-items) · lines 1260–1393
34
- - [In a table's rows](#in-a-tables-rows) · lines 1395–1480
35
- - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1482–1494
36
- - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1496–1562
37
- - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1564–1628
38
- - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1630–1728
39
- - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1730–1759
40
- - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1761–1799
41
- - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1801–1877
42
- - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1879–1902
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 1904–1990
44
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1992–2028
45
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2030–2075
6
+ - [The rules that apply to every cell](#the-rules-that-apply-to-every-cell) · lines 74–94
7
+ - [1. Plain text](#1-plain-text) · lines 96–149
8
+ - [2. Icon + label](#2-icon--label) · lines 151–174
9
+ - [3. Icon in a badge](#3-icon-in-a-badge) · lines 176–189
10
+ - [4. Icon only, label in a tooltip](#4-icon-only-label-in-a-tooltip) · lines 191–268
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 216–268
12
+ - [5. Enum → tone-mapped badge](#5-enum--tone-mapped-badge) · lines 270–283
13
+ - [6. Multi-value enum, clustered](#6-multi-value-enum-clustered) · lines 285–297
14
+ - [7. Link as an outline button](#7-link-as-an-outline-button) · lines 299–320
15
+ - [8. Date, relative](#8-date-relative) · lines 322–359
16
+ - [9. Ordinal scale (bounded integer)](#9-ordinal-scale-bounded-integer) · lines 361–409
17
+ - [Two variants the package draws: a step bar and a star](#two-variants-the-package-draws-a-step-bar-and-a-star) · lines 379–409
18
+ - [10. Summary in the cell, detail in a popover](#10-summary-in-the-cell-detail-in-a-popover) · lines 411–461
19
+ - [A second example: what a row depends on](#a-second-example-what-a-row-depends-on) · lines 429–461
20
+ - [11. Number or currency — Unproven](#11-number-or-currency--unproven) · lines 463–503
21
+ - [12. Boolean](#12-boolean) · lines 505–535
22
+ - [13. Progress bar — Unproven](#13-progress-bar--unproven) · lines 537–573
23
+ - [The compact form: `ProgressRing`](#the-compact-form-progressring) · lines 557–573
24
+ - [14. Avatar and name — Unproven](#14-avatar-and-name--unproven) · lines 575–592
25
+ - [15. Yes/no you flip in the row](#15-yesno-you-flip-in-the-row) · lines 594–703
26
+ - [A variant: a pressed icon inside another value's cell](#a-variant-a-pressed-icon-inside-another-values-cell) · lines 620–703
27
+ - [16. Title linking to the record's view](#16-title-linking-to-the-records-view) · lines 705–740
28
+ - [17. Quick action on the view](#17-quick-action-on-the-view) · lines 742–815
29
+ - [18. Editable value](#18-editable-value) · lines 817–1495
30
+ - [Presets: one line per field](#presets-one-line-per-field) · lines 1127–1195
31
+ - [Several fields edited as one](#several-fields-edited-as-one) · lines 1197–1233
32
+ - [A link and its label](#a-link-and-its-label) · lines 1235–1259
33
+ - [A list of sub-items](#a-list-of-sub-items) · lines 1261–1394
34
+ - [In a table's rows](#in-a-tables-rows) · lines 1396–1481
35
+ - [A table of a few short columns: `width="content"`](#a-table-of-a-few-short-columns-widthcontent) · lines 1483–1495
36
+ - [19. Stage circle for an ordered status](#19-stage-circle-for-an-ordered-status) · lines 1497–1563
37
+ - [20. Count linking to the related records](#20-count-linking-to-the-related-records) · lines 1565–1629
38
+ - [21. Rows grouped under headings, and a pill filter](#21-rows-grouped-under-headings-and-a-pill-filter) · lines 1631–1729
39
+ - [22. A highlighted row, and rows that are done](#22-a-highlighted-row-and-rows-that-are-done) · lines 1731–1760
40
+ - [24. A list's rows: hover, lines, rows per page](#24-a-lists-rows-hover-lines-rows-per-page) · lines 1762–1800
41
+ - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1802–1878
42
+ - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 1880–1903
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 1905–1991
44
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 1993–2029
45
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2031–2076
46
46
 
47
47
  <!-- /index -->
48
48
 
@@ -74,9 +74,10 @@ too, so it ships here for every app.
74
74
  ## The rules that apply to every cell
75
75
 
76
76
  - **An empty value renders an em dash**, never a blank cell: a blank reads
77
- as a rendering bug. Define it once per columns file —
78
- `const emptyCell = <span className="text-muted-foreground">—</span>` —
79
- and use it everywhere. The one exception is a value whose "nothing" state
77
+ as a rendering bug. Draw it with the package's `EmptyText` (4.96), the
78
+ record's own dash, read by a screen reader as "Not set" (`label` for
79
+ other words): `const emptyCell = <EmptyText />` once per columns file,
80
+ used everywhere. Never a hand-written dash. The one exception is a value whose "nothing" state
80
81
  has its own meaning (an unrated 0-of-5 scale, a missing image), where the
81
82
  shape itself should say so.
82
83
  - **Colour is never the only signal.** Greyscale, colourblindness and print
@@ -30,12 +30,12 @@
30
30
  - [Parts of the page standards](#parts-of-the-page-standards) · lines 1278–1321
31
31
  - [A few equal things](#a-few-equal-things) · lines 1323–1407
32
32
  - [An overview page](#an-overview-page) · lines 1409–1472
33
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1473–1511
34
- - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1513–1558
35
- - [Picking at random](#picking-at-random) · lines 1560–1591
36
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1593–1660
37
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1662–1687
38
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1689–1762
33
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1473–1524
34
+ - [A record's tabs, mark and rail](#a-records-tabs-mark-and-rail) · lines 1526–1571
35
+ - [Picking at random](#picking-at-random) · lines 1573–1604
36
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1606–1673
37
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1675–1700
38
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 1702–1775
39
39
 
40
40
  <!-- /index -->
41
41
 
@@ -1502,6 +1502,19 @@ data on each its own.
1502
1502
  muted text tone, read by a screen reader as "Not set": the same on
1503
1503
  every field, the presets' included. A field's own `emptyLabel` still
1504
1504
  wins where words say more than a dash ("No budget yet").
1505
+ - **The same dash off the record: `EmptyText`** (4.96). An app's own
1506
+ strip, summary line or cell with nothing in it draws
1507
+ `isEmptyValue(value) ? <EmptyText /> : value`, never a dash and an
1508
+ `sr-only` of its own. `label` is what a screen reader says for the
1509
+ dash ("Not set" unless set: `label="No reason given"`), `text` shows
1510
+ words instead of it, and `className` replaces the muted tone's class
1511
+ (keep a muted tone: `className="type-label text-muted-foreground"` on a
1512
+ label-sized line). EntityView, KeyStats, EqualItems, ValueList and the
1513
+ hub cards' "Couldn't load" all draw through it.
1514
+
1515
+ ```tsx
1516
+ <p className="type-body">{shelf} · {isEmptyValue(reason) ? <EmptyText label="No reason given" /> : reason}</p>
1517
+ ```
1505
1518
  - **Folded empties** (`emptyFields="fold"`): each fields card lists its
1506
1519
  filled fields, then a muted, underlined "N empty" with a down chevron
1507
1520
  under them opens the rest in their places, each still edited in place,
@@ -1,12 +1,23 @@
1
1
  import { type ReactElement, type ReactNode } from 'react';
2
2
  export type DeleteKind = 'soft' | 'hard';
3
+ /** The one field a confirm can ask (4.96): an optional reason, in a textarea. */
4
+ export type DeleteReason = {
5
+ /** The field's label: "Why" unless set ("Why remove it?"). */
6
+ label?: string;
7
+ /** A line under the box, in muted type ("Kept with its history."). */
8
+ hint?: ReactNode;
9
+ placeholder?: string;
10
+ };
3
11
  export type DeleteActionProps = {
4
12
  /** What's deleted, as the page names it: "The Long Walk". */
5
13
  name: string;
6
14
  /** `soft`: it goes to Deleted and Restore brings it back. `hard`: it's gone. */
7
15
  kind: DeleteKind;
8
- /** Deletes it. A rejection keeps the dialog open with the reason. */
9
- onDelete: () => Promise<unknown>;
16
+ /**
17
+ * Deletes it. A rejection keeps the dialog open with the reason. With
18
+ * `reason`, it's given what was typed, trimmed ('' for nothing).
19
+ */
20
+ onDelete: (reason: string) => Promise<unknown>;
10
21
  /** A soft delete's Undo: restores it. Without it the toast has no Undo. */
11
22
  onRestore?: () => Promise<unknown>;
12
23
  /** After it's deleted and the toast is up: leave the record's page, say. */
@@ -17,6 +28,8 @@ export type DeleteActionProps = {
17
28
  verbDone?: string;
18
29
  /** Another sentence under the question than `kind`'s. */
19
30
  description?: ReactNode;
31
+ /** Ask a reason: one optional field between the sentence and the buttons, passed to `onDelete`. */
32
+ reason?: DeleteReason;
20
33
  /** `"icon"` (the default), `"button"` (the verb in words), an element to open it, or `null` for none. */
21
34
  trigger?: 'icon' | 'button' | ReactElement | null;
22
35
  /** The icon trigger's size: `default` (36px, a header) or `sm` (32px, a row). */
@@ -25,4 +38,4 @@ export type DeleteActionProps = {
25
38
  open?: boolean;
26
39
  onOpenChange?: (open: boolean) => void;
27
40
  };
28
- export declare function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb, verbDone, description, trigger, size, open: openProp, onOpenChange, }: DeleteActionProps): import("react").JSX.Element;
41
+ export declare function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb, verbDone, description, reason, trigger, size, open: openProp, onOpenChange, }: DeleteActionProps): import("react").JSX.Element;
@@ -14,16 +14,24 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
14
14
  // - `verb` covers the other ways something leaves a list: `verb="Retire"`
15
15
  // asks "Retire <name>?" on a "Retire" button and says "Retired <name>".
16
16
  //
17
+ // - `reason` (4.96) puts one field between the sentence and the buttons, a
18
+ // "Why" box, optional: what's typed (trimmed, '' for nothing) is
19
+ // `onDelete`'s argument, and Try again sends it again. While something's
20
+ // typed, closing asks "Discard your changes?" first (the dialog
21
+ // standard's `dirty`). Width, words and the buttons stay as they are.
22
+ //
17
23
  // The trigger is an icon (IconAction's Trash2) unless `trigger` says
18
24
  // otherwise: `"button"` for a "Delete" button in words, an element of the
19
25
  // caller's, or `null` for none, opened with `open`/`onOpenChange` (a row's
20
26
  // menu item).
21
- import { useState } from 'react';
27
+ import { useId, useState } from 'react';
22
28
  import { Trash2Icon } from 'lucide-react';
23
29
  import { useAction } from '../../hooks/use-action.js';
24
30
  import { Button } from '../ui/button.js';
25
31
  import { Dialog, DialogClose, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '../ui/dialog.js';
32
+ import { Field, FieldDescription, FieldLabel } from '../ui/field.js';
26
33
  import { Spinner } from '../ui/spinner.js';
34
+ import { Textarea } from '../ui/textarea.js';
27
35
  import { ActionError } from './action-error.js';
28
36
  import { IconAction } from './icon-action.js';
29
37
  import { notify, pastTense } from './notify.js';
@@ -31,7 +39,7 @@ const SAYS = {
31
39
  soft: 'It goes to Deleted, and Restore brings it back.',
32
40
  hard: 'This can’t be undone.',
33
41
  };
34
- export function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb = 'Delete', verbDone, description, trigger = 'icon', size = 'default', open: openProp, onOpenChange, }) {
42
+ export function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb = 'Delete', verbDone, description, reason, trigger = 'icon', size = 'default', open: openProp, onOpenChange, }) {
35
43
  const [openState, setOpenState] = useState(false);
36
44
  const open = openProp ?? openState;
37
45
  const setOpen = (next) => {
@@ -41,8 +49,17 @@ export function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb
41
49
  };
42
50
  const done = verbDone ?? pastTense(verb);
43
51
  const remove = useAction(onDelete, { failed: `Couldn't ${verb.toLowerCase()} ${name}` });
52
+ const reasonId = useId();
53
+ const [typed, setTyped] = useState('');
54
+ // A closed confirm starts empty next time, however it was closed.
55
+ const [wasOpen, setWasOpen] = useState(open);
56
+ if (wasOpen !== open) {
57
+ setWasOpen(open);
58
+ if (!open)
59
+ setTyped('');
60
+ }
44
61
  const confirm = async () => {
45
- const outcome = await remove.run();
62
+ const outcome = await remove.run(reason ? typed.trim() : '');
46
63
  if (!outcome.ok)
47
64
  return;
48
65
  // Whether or not this is still on screen: a row's delete is gone with
@@ -57,5 +74,5 @@ export function DeleteAction({ name, kind, onDelete, onRestore, onDeleted, verb
57
74
  if (!next)
58
75
  remove.reset();
59
76
  setOpen(next);
60
- }, children: [trigger === 'icon' && (_jsx(DialogTrigger, { render: _jsx(IconAction, { icon: Trash2Icon, label: verb, tone: "destructive", size: size }) })), trigger === 'button' && (_jsx(DialogTrigger, { render: _jsx(Button, { variant: "outline", size: size === 'sm' ? 'sm' : 'default' }), children: verb })), trigger && typeof trigger === 'object' && _jsx(DialogTrigger, { render: trigger }), _jsxs(DialogContent, { size: "confirm", "data-slot": "delete-action", "data-kind": kind, children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: [verb, " ", name, "?"] }), _jsx(DialogDescription, { children: description ?? SAYS[kind] })] }), _jsx(ActionError, { action: { ...remove, retry: confirm } }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline", disabled: remove.pending }), children: "Cancel" }), _jsxs(Button, { variant: "destructive", disabled: remove.pending, onClick: () => void confirm(), children: [remove.pending && _jsx(Spinner, { className: "size-4" }), verb] })] })] })] }));
77
+ }, children: [trigger === 'icon' && (_jsx(DialogTrigger, { render: _jsx(IconAction, { icon: Trash2Icon, label: verb, tone: "destructive", size: size }) })), trigger === 'button' && (_jsx(DialogTrigger, { render: _jsx(Button, { variant: "outline", size: size === 'sm' ? 'sm' : 'default' }), children: verb })), trigger && typeof trigger === 'object' && _jsx(DialogTrigger, { render: trigger }), _jsxs(DialogContent, { size: "confirm", dirty: reason !== undefined && typed.trim() !== '' && !remove.pending, "data-slot": "delete-action", "data-kind": kind, children: [_jsxs(DialogHeader, { children: [_jsxs(DialogTitle, { children: [verb, " ", name, "?"] }), _jsx(DialogDescription, { children: description ?? SAYS[kind] })] }), reason && (_jsxs(Field, { "data-slot": "delete-action-reason", children: [_jsx(FieldLabel, { htmlFor: reasonId, children: reason.label ?? 'Why' }), _jsx(Textarea, { id: reasonId, value: typed, placeholder: reason.placeholder, disabled: remove.pending, onChange: (event) => setTyped(event.target.value) }), reason.hint && _jsx(FieldDescription, { children: reason.hint })] })), _jsx(ActionError, { action: { ...remove, retry: confirm } }), _jsxs(DialogFooter, { children: [_jsx(DialogClose, { render: _jsx(Button, { variant: "outline", disabled: remove.pending }), children: "Cancel" }), _jsxs(Button, { variant: "destructive", disabled: remove.pending, onClick: () => void confirm(), children: [remove.pending && _jsx(Spinner, { className: "size-4" }), verb] })] })] })] }));
61
78
  }
@@ -1,5 +1,12 @@
1
- /** The empty text in the muted tone; the dash is read as "Not set". */
2
- export declare function EmptyText({ text, className }: {
1
+ import type { ComponentProps } from 'react';
2
+ /** Any other span attribute (`data-state`, `id`) passes through to the span. */
3
+ export type EmptyTextProps = Omit<ComponentProps<'span'>, 'children'> & {
4
+ /** What shows: the dash unless set. Words ("No budget yet") read as they are. */
3
5
  text?: string;
6
+ /** What a screen reader says for the dash: "Not set" unless set ("No reason given"). */
7
+ label?: string;
8
+ /** Replaces the muted text tone's class (keep a muted tone: `type-body text-muted-foreground`). */
4
9
  className?: string;
5
- }): import("react").JSX.Element;
10
+ };
11
+ /** The empty text in the muted tone; the dash is read as `label`, "Not set" by default. */
12
+ export declare function EmptyText({ text, label, className, ...props }: EmptyTextProps): import("react").JSX.Element;
@@ -1,11 +1,6 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
- // What an empty value reads as on a record (form standard 22.2, #F17): a
3
- // dash in the muted text tone, everywhere, with "Not set" as what a screen
4
- // reader says for it. Words given instead ("No budget yet") read as they
5
- // are. EntityView, its strip (KeyStats) and the inPlace presets' fields all
6
- // show it.
7
2
  import { EMPTY_DASH } from '../../lib/empty-value.js';
8
- /** The empty text in the muted tone; the dash is read as "Not set". */
9
- export function EmptyText({ text = EMPTY_DASH, className }) {
10
- return (_jsx("span", { "data-slot": "empty-value", className: className ?? 'text-muted-foreground', children: text === EMPTY_DASH ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: EMPTY_DASH }), _jsx("span", { className: "sr-only", children: "Not set" })] })) : (text) }));
3
+ /** The empty text in the muted tone; the dash is read as `label`, "Not set" by default. */
4
+ export function EmptyText({ text = EMPTY_DASH, label = 'Not set', className, ...props }) {
5
+ return (_jsx("span", { "data-slot": "empty-value", ...props, className: className ?? 'text-muted-foreground', children: text === EMPTY_DASH ? (_jsxs(_Fragment, { children: [_jsx("span", { "aria-hidden": "true", children: EMPTY_DASH }), _jsx("span", { className: "sr-only", children: label })] })) : (text) }));
11
6
  }
@@ -39,6 +39,7 @@ import { cn } from 'cn';
39
39
  import { Button } from '../ui/button.js';
40
40
  import { Card } from '../ui/card.js';
41
41
  import { Skeleton } from '../ui/skeleton.js';
42
+ import { EmptyText } from './empty-value.js';
42
43
  // Whole class names per slot, so Tailwind generates them.
43
44
  const ICON_CLASS = {
44
45
  1: 'text-category-1',
@@ -94,7 +95,7 @@ function ChipValue({ state, value }) {
94
95
  if (state === 'loading')
95
96
  return (_jsxs(_Fragment, { children: [_jsx(Skeleton, { className: "h-4 w-4" }), _jsx("span", { className: "sr-only", children: "Loading" })] }));
96
97
  if (state === 'error')
97
- return (_jsxs("span", { className: "text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "Couldn't load" })] }));
98
+ return (_jsx(EmptyText, { label: "Couldn't load" }));
98
99
  if (value === undefined)
99
100
  return null;
100
101
  return (_jsx("span", { "data-slot": "module-card-chip-value", className: "font-semibold tabular-nums", children: value }));
@@ -27,6 +27,7 @@ import { Freshness } from './freshness.js';
27
27
  import { NeedsYou } from './needs-you.js';
28
28
  import { WidgetCard, WidgetCardGroup } from './widget-card.js';
29
29
  import { Skeleton } from '../ui/skeleton.js';
30
+ import { EmptyText } from './empty-value.js';
30
31
  const WIDE_QUERY = '(min-width: 48rem)';
31
32
  const canMatchMedia = () => typeof window !== 'undefined' && typeof window.matchMedia === 'function';
32
33
  function subscribeWide(listener) {
@@ -59,5 +60,5 @@ function PartCard({ part }) {
59
60
  function OverviewTile({ id, part, open, controls, onToggle, }) {
60
61
  const { icon: Icon } = part;
61
62
  const state = part.error ? 'error' : part.isLoading ? 'loading' : part.empty ? 'empty' : 'success';
62
- return (_jsxs("button", { type: "button", id: id, "data-slot": "overview-tile", "data-state": state, "aria-expanded": open, "aria-controls": controls, onClick: onToggle, className: cn('glow-edge flex w-full min-w-0 flex-col items-start gap-0.5 rounded-lg bg-card px-3 py-2.5 text-left text-card-foreground', 'shadow-(--card-shadow) ring-1 ring-border outline-none hover:bg-muted', 'focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:ring-2 aria-expanded:ring-primary'), children: [_jsxs("span", { className: "flex min-w-0 max-w-full items-center gap-1.5 type-label text-muted-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-link" }), _jsx("span", { className: "truncate", children: part.title })] }), state === 'loading' ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { "data-state": "loading", className: "my-1 h-6 w-16" }), _jsx("span", { className: "sr-only", children: "Loading" })] })) : state === 'error' ? (_jsxs("span", { "data-state": "error", className: "type-numeric text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "Couldn't load" })] })) : state === 'empty' ? (_jsx("span", { "data-state": "empty", className: "py-0.5 type-body text-muted-foreground", children: "Nothing yet" })) : (part.value !== undefined && (_jsx("span", { "data-slot": "overview-tile-value", className: "max-w-full truncate type-numeric text-foreground", children: part.value }))), state === 'success' && part.freshness && _jsx(Freshness, { ...part.freshness })] }));
63
+ return (_jsxs("button", { type: "button", id: id, "data-slot": "overview-tile", "data-state": state, "aria-expanded": open, "aria-controls": controls, onClick: onToggle, className: cn('glow-edge flex w-full min-w-0 flex-col items-start gap-0.5 rounded-lg bg-card px-3 py-2.5 text-left text-card-foreground', 'shadow-(--card-shadow) ring-1 ring-border outline-none hover:bg-muted', 'focus-visible:ring-3 focus-visible:ring-ring/50 aria-expanded:ring-2 aria-expanded:ring-primary'), children: [_jsxs("span", { className: "flex min-w-0 max-w-full items-center gap-1.5 type-label text-muted-foreground", children: [Icon && _jsx(Icon, { "aria-hidden": "true", className: "size-4 shrink-0 text-link" }), _jsx("span", { className: "truncate", children: part.title })] }), state === 'loading' ? (_jsxs(_Fragment, { children: [_jsx(Skeleton, { "data-state": "loading", className: "my-1 h-6 w-16" }), _jsx("span", { className: "sr-only", children: "Loading" })] })) : state === 'error' ? (_jsx(EmptyText, { "data-state": "error", label: "Couldn't load", className: "type-numeric text-muted-foreground" })) : state === 'empty' ? (_jsx("span", { "data-state": "empty", className: "py-0.5 type-body text-muted-foreground", children: "Nothing yet" })) : (part.value !== undefined && (_jsx("span", { "data-slot": "overview-tile-value", className: "max-w-full truncate type-numeric text-foreground", children: part.value }))), state === 'success' && part.freshness && _jsx(Freshness, { ...part.freshness })] }));
63
64
  }
@@ -2,9 +2,10 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from 'cn';
3
3
  import { Badge } from '../ui/badge.js';
4
4
  import { Tooltip, TooltipContent, TooltipProvider, TooltipTrigger } from '../ui/tooltip.js';
5
+ import { EmptyText } from './empty-value.js';
5
6
  export function ValueList({ items, max = 2, className }) {
6
7
  if (items.length === 0) {
7
- return (_jsxs("span", { "data-slot": "value-list", "data-state": "empty", className: cn('text-muted-foreground', className), children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "None" })] }));
8
+ return (_jsx(EmptyText, { "data-slot": "value-list", "data-state": "empty", label: "None", className: cn('text-muted-foreground', className) }));
8
9
  }
9
10
  const shown = items.slice(0, Math.max(0, max));
10
11
  const folded = items.slice(shown.length);
@@ -75,6 +75,7 @@ import { Card, CardContent, CardHeader } from '../ui/card.js';
75
75
  import { Skeleton } from '../ui/skeleton.js';
76
76
  import { useIsMobile } from '../../hooks/use-mobile.js';
77
77
  import { useRememberedFlag } from '../../hooks/use-remembered-flag.js';
78
+ import { EmptyText } from './empty-value.js';
78
79
  const HEADER_LINK_CLASS = 'shrink-0 rounded-sm type-label text-foreground underline underline-offset-4 outline-none ' +
79
80
  'hover:decoration-2 focus-visible:ring-3 focus-visible:ring-ring/50';
80
81
  export function WidgetCard({ id, title, icon: Icon, to, value, line, freshness, headingLevel = 2, link, isLoading, error, onRetry, isEmpty, emptyMessage, empty, skeletonRows = 3, collapsible = false, defaultCollapsed = false, storageKey, summary: ownSummary, emptySummary, children, className, }) {
@@ -115,7 +116,7 @@ function WidgetCardSummary({ state, summary, emptySummary, }) {
115
116
  return (_jsxs(_Fragment, { children: [_jsx(Skeleton, { "data-state": "loading", className: "h-4 w-8" }), _jsx("span", { className: "sr-only", children: "Loading" })] }));
116
117
  }
117
118
  if (state === 'error') {
118
- return (_jsxs("span", { "data-state": "error", className: "type-label text-muted-foreground", children: [_jsx("span", { "aria-hidden": "true", children: "\u2014" }), _jsx("span", { className: "sr-only", children: "Couldn't load" })] }));
119
+ return (_jsx(EmptyText, { "data-state": "error", label: "Couldn't load", className: "type-label text-muted-foreground" }));
119
120
  }
120
121
  if (state === 'empty') {
121
122
  return emptySummary === undefined ? null : (_jsx("span", { "data-state": "empty", className: "type-label text-muted-foreground", children: emptySummary }));
package/dist/index.d.ts CHANGED
@@ -22,6 +22,8 @@ export { ChoiceButtons, type ChoiceButtonsOption, type ChoiceButtonsProps } from
22
22
  export { ReferenceCombobox, type ReferenceComboboxProps, type ReferenceRecord } from './components/app/reference-combobox.js';
23
23
  export { fieldRows, type FieldKind, type FieldRowItem, type FieldRowPlace, type FieldSize } from './lib/field-rows.js';
24
24
  export { KeyStats, type KeyStat, type KeyStatsProps } from './components/app/key-stats.js';
25
+ export { EmptyText, type EmptyTextProps } from './components/app/empty-value.js';
26
+ export { isEmptyValue } from './lib/empty-value.js';
25
27
  export { IconAction, type IconActionProps } from './components/app/icon-action.js';
26
28
  export { EntityView, type EntityViewEmptyFields, type EntityViewField, type EntityViewLayout, type EntityViewMobileOrder, type EntityViewPlacement, type EntityViewProps, type EntityViewRailFields, type EntityViewSection, } from './components/app/entity-view.js';
27
29
  export { entityViewTabSlug } from './lib/entity-view-tab.js';
@@ -29,7 +31,7 @@ export { usePrinting } from './components/app/print-context.js';
29
31
  export { RecordDialogRoute, RecordLink, type RecordDialogRouteProps, type RecordLinkProps, } from './components/app/record-dialog.js';
30
32
  export { recordDialogState, useNewRecordDialog, useOpenRecord, useRecordDialog, type NewRecordDialogContextValue, type RecordDialogBackground, type RecordDialogContextValue, type RecordDialogState, } from './components/app/record-dialog-context.js';
31
33
  export { FormDialog, type FormDialogProps } from './components/app/form-dialog.js';
32
- export { DeleteAction, type DeleteActionProps, type DeleteKind } from './components/app/delete-action.js';
34
+ export { DeleteAction, type DeleteActionProps, type DeleteKind, type DeleteReason } from './components/app/delete-action.js';
33
35
  export { notify, doneMessage, pastTense, type NotifyDoneOptions } from './components/app/notify.js';
34
36
  export { useAction, type ActionOutcome, type ActionState, type UseActionOptions } from './hooks/use-action.js';
35
37
  export { ActionError, type ActionErrorProps } from './components/app/action-error.js';
package/dist/index.js CHANGED
@@ -26,6 +26,10 @@ export { ChoiceButtons } from './components/app/choice-buttons.js';
26
26
  export { ReferenceCombobox } from './components/app/reference-combobox.js';
27
27
  export { fieldRows } from './lib/field-rows.js';
28
28
  export { KeyStats } from './components/app/key-stats.js';
29
+ // The record's empty value (4.96): a muted dash read as "Not set", for an
30
+ // app's own strips, summary lines and cells.
31
+ export { EmptyText } from './components/app/empty-value.js';
32
+ export { isEmptyValue } from './lib/empty-value.js';
29
33
  export { IconAction } from './components/app/icon-action.js';
30
34
  export { EntityView, } from './components/app/entity-view.js';
31
35
  export { entityViewTabSlug } from './lib/entity-view-tab.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.95.0",
3
+ "version": "4.96.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": {