@tristan2828/ui-foundation 4.144.1 → 4.145.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.
- package/conventions/docs/add-an-entity.md +24 -17
- package/conventions/docs/design-language.md +61 -42
- package/dist/components/app/editable-value.js +8 -5
- package/dist/components/app/entity-view-facts.d.ts +35 -8
- package/dist/components/app/entity-view-facts.js +66 -17
- package/dist/components/app/entity-view.d.ts +5 -3
- package/dist/components/app/entity-view.js +4 -3
- package/dist/components/app/month-calendar.d.ts +6 -0
- package/dist/components/app/month-calendar.js +3 -2
- package/dist/components/app/widget-card.d.ts +6 -1
- package/dist/components/app/widget-card.js +6 -2
- package/package.json +1 -1
- package/styles/theme.css +6 -4
|
@@ -38,19 +38,19 @@
|
|
|
38
38
|
- [The table opens the view, and the form returns to it](#the-table-opens-the-view-and-the-form-returns-to-it) · lines 860–871
|
|
39
39
|
- [`<SelectValue>` shows the value, not the label](#selectvalue-shows-the-value-not-the-label) · lines 873–919
|
|
40
40
|
- [Choosing how each column looks](#choosing-how-each-column-looks) · lines 921–935
|
|
41
|
-
- [How a list opens a record](#how-a-list-opens-a-record) · lines 937–
|
|
42
|
-
- [The record view](#the-record-view) · lines 1080–
|
|
43
|
-
- [Forms](#forms) · lines
|
|
44
|
-
- [Dialogs](#dialogs) · lines
|
|
45
|
-
- [Toasts and feedback](#toasts-and-feedback) · lines
|
|
46
|
-
- [What not to copy](#what-not-to-copy) · lines
|
|
47
|
-
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines
|
|
48
|
-
- [Saves that don't overwrite](#saves-that-dont-overwrite) · lines
|
|
49
|
-
- [Deleting](#deleting) · lines
|
|
50
|
-
- [Fields only a script writes](#fields-only-a-script-writes) · lines
|
|
51
|
-
- [Searching one part of the app](#searching-one-part-of-the-app) · lines
|
|
52
|
-
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines
|
|
53
|
-
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines
|
|
41
|
+
- [How a list opens a record](#how-a-list-opens-a-record) · lines 937–1448
|
|
42
|
+
- [The record view](#the-record-view) · lines 1080–1267
|
|
43
|
+
- [Forms](#forms) · lines 1269–1352
|
|
44
|
+
- [Dialogs](#dialogs) · lines 1354–1387
|
|
45
|
+
- [Toasts and feedback](#toasts-and-feedback) · lines 1389–1448
|
|
46
|
+
- [What not to copy](#what-not-to-copy) · lines 1450–1477
|
|
47
|
+
- [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1479–1496
|
|
48
|
+
- [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1498–1558
|
|
49
|
+
- [Deleting](#deleting) · lines 1560–1590
|
|
50
|
+
- [Fields only a script writes](#fields-only-a-script-writes) · lines 1592–1611
|
|
51
|
+
- [Searching one part of the app](#searching-one-part-of-the-app) · lines 1613–1622
|
|
52
|
+
- [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1625–1667
|
|
53
|
+
- [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1669–1702
|
|
54
54
|
|
|
55
55
|
<!-- /index -->
|
|
56
56
|
|
|
@@ -1123,8 +1123,9 @@ A record uses the parts it has, in this order:
|
|
|
1123
1123
|
of labels; keep labels to a word or two.
|
|
1124
1124
|
- **The facts rail**: `factsRail` on the
|
|
1125
1125
|
view puts the record's short facts in a narrow column beside the
|
|
1126
|
-
record's body where the view has room (60rem
|
|
1127
|
-
|
|
1126
|
+
record's body where the view has room (60rem at the default Text Size,
|
|
1127
|
+
more at Large and Extra Large as the rail grows: a laptop's page, a
|
|
1128
|
+
record dialog), so the page doesn't end 900px in. The strip stays above it at
|
|
1128
1129
|
full width, and the rail starts level with the first content under the
|
|
1129
1130
|
strip: the open tab's first section (beside the tab's content, not its
|
|
1130
1131
|
bar), or the first card when cards come before the tabs. Beside
|
|
@@ -1147,8 +1148,14 @@ A record uses the parts it has, in this order:
|
|
|
1147
1148
|
] }
|
|
1148
1149
|
```
|
|
1149
1150
|
|
|
1150
|
-
- `text` is a date, a number or a person's name
|
|
1151
|
-
|
|
1151
|
+
- `text` is a date, a number or a person's name. `badges` are a few
|
|
1152
|
+
short labels. `emoji` is the record's emoji (`{ label: 'Emoji', kind:
|
|
1153
|
+
'emoji', emoji: record.emoji }`), drawn as Noto's picture.
|
|
1154
|
+
- **Nothing in the rail is ever cut**, at any Text Size (4.145): a value
|
|
1155
|
+
too long for its line wraps onto another (text, a badge inside its
|
|
1156
|
+
badge, a link, a record, a list item), and unbroken text breaks
|
|
1157
|
+
anywhere. The same in Details. The rail is 300px, 375px at Large and
|
|
1158
|
+
420px at Extra Large, so a short value still keeps one line.
|
|
1152
1159
|
- A link to another record is `record`, and must say `short: true`:
|
|
1153
1160
|
the app vouches its names are short (a person, a place). Records
|
|
1154
1161
|
with long titles (a list of discussions, a log's entries) never go in
|
|
@@ -11,42 +11,42 @@
|
|
|
11
11
|
- [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 259–288
|
|
12
12
|
- [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 290–301
|
|
13
13
|
- [Logos and brand marks](#logos-and-brand-marks) · lines 303–343
|
|
14
|
-
- [Emoji](#emoji) · lines 345–
|
|
15
|
-
- [Categorical colour](#categorical-colour) · lines
|
|
16
|
-
- [Heat scale](#heat-scale) · lines
|
|
17
|
-
- [Depth ramps](#depth-ramps) · lines
|
|
18
|
-
- [A stored colour](#a-stored-colour) · lines
|
|
19
|
-
- [Shapes and sizes](#shapes-and-sizes) · lines
|
|
20
|
-
- [Typography](#typography) · lines
|
|
21
|
-
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines
|
|
22
|
-
- [Written text (notes)](#written-text-notes) · lines
|
|
23
|
-
- [Density](#density) · lines
|
|
24
|
-
- [Rows on this device](#rows-on-this-device) · lines
|
|
25
|
-
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines
|
|
26
|
-
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines
|
|
27
|
-
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines
|
|
28
|
-
- [Notices](#notices) · lines
|
|
29
|
-
- [A value over time](#a-value-over-time) · lines
|
|
30
|
-
- [Several values over time](#several-values-over-time) · lines
|
|
31
|
-
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines
|
|
32
|
-
- [A list as a board](#a-list-as-a-board) · lines
|
|
33
|
-
- [Order, groups and the header](#order-groups-and-the-header) · lines
|
|
34
|
-
- [A list as cards](#a-list-as-cards) · lines
|
|
35
|
-
- [Images full screen](#images-full-screen) · lines
|
|
36
|
-
- [Key numbers on a record](#key-numbers-on-a-record) · lines
|
|
37
|
-
- [Parts of the page standards](#parts-of-the-page-standards) · lines
|
|
38
|
-
- [A few equal things](#a-few-equal-things) · lines
|
|
39
|
-
- [An overview page](#an-overview-page) · lines
|
|
40
|
-
- [A record's header and empty values](#a-records-header-and-empty-values) · lines
|
|
41
|
-
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines
|
|
42
|
-
- [Picking at random](#picking-at-random) · lines
|
|
43
|
-
- [Filling in what's missing](#filling-in-whats-missing) · lines
|
|
44
|
-
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines
|
|
45
|
-
- [A quick add line](#a-quick-add-line) · lines
|
|
46
|
-
- [A date field's quick picks](#a-date-fields-quick-picks) · lines
|
|
47
|
-
- [A month calendar](#a-month-calendar) · lines
|
|
48
|
-
- [A settings page](#a-settings-page) · lines
|
|
49
|
-
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines
|
|
14
|
+
- [Emoji](#emoji) · lines 345–385
|
|
15
|
+
- [Categorical colour](#categorical-colour) · lines 387–452
|
|
16
|
+
- [Heat scale](#heat-scale) · lines 454–506
|
|
17
|
+
- [Depth ramps](#depth-ramps) · lines 508–575
|
|
18
|
+
- [A stored colour](#a-stored-colour) · lines 577–624
|
|
19
|
+
- [Shapes and sizes](#shapes-and-sizes) · lines 626–647
|
|
20
|
+
- [Typography](#typography) · lines 649–819
|
|
21
|
+
- [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 683–715
|
|
22
|
+
- [Written text (notes)](#written-text-notes) · lines 717–819
|
|
23
|
+
- [Density](#density) · lines 821–950
|
|
24
|
+
- [Rows on this device](#rows-on-this-device) · lines 894–922
|
|
25
|
+
- [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 924–950
|
|
26
|
+
- [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 952–1064
|
|
27
|
+
- [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1066–1138
|
|
28
|
+
- [Notices](#notices) · lines 1140–1167
|
|
29
|
+
- [A value over time](#a-value-over-time) · lines 1169–1299
|
|
30
|
+
- [Several values over time](#several-values-over-time) · lines 1218–1256
|
|
31
|
+
- [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1258–1299
|
|
32
|
+
- [A list as a board](#a-list-as-a-board) · lines 1301–1411
|
|
33
|
+
- [Order, groups and the header](#order-groups-and-the-header) · lines 1354–1411
|
|
34
|
+
- [A list as cards](#a-list-as-cards) · lines 1413–1460
|
|
35
|
+
- [Images full screen](#images-full-screen) · lines 1462–1508
|
|
36
|
+
- [Key numbers on a record](#key-numbers-on-a-record) · lines 1510–1546
|
|
37
|
+
- [Parts of the page standards](#parts-of-the-page-standards) · lines 1548–1584
|
|
38
|
+
- [A few equal things](#a-few-equal-things) · lines 1586–1701
|
|
39
|
+
- [An overview page](#an-overview-page) · lines 1703–1768
|
|
40
|
+
- [A record's header and empty values](#a-records-header-and-empty-values) · lines 1770–1833
|
|
41
|
+
- [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1835–1922
|
|
42
|
+
- [Picking at random](#picking-at-random) · lines 1924–1955
|
|
43
|
+
- [Filling in what's missing](#filling-in-whats-missing) · lines 1957–2024
|
|
44
|
+
- [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2026–2045
|
|
45
|
+
- [A quick add line](#a-quick-add-line) · lines 2047–2075
|
|
46
|
+
- [A date field's quick picks](#a-date-fields-quick-picks) · lines 2077–2101
|
|
47
|
+
- [A month calendar](#a-month-calendar) · lines 2103–2135
|
|
48
|
+
- [A settings page](#a-settings-page) · lines 2137–2194
|
|
49
|
+
- [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2196–2255
|
|
50
50
|
|
|
51
51
|
<!-- /index -->
|
|
52
52
|
|
|
@@ -375,6 +375,14 @@ inside text (notes, rich text) stay the device's.
|
|
|
375
375
|
- **`PillFilter`'s `lead`:** a topic's `<Emoji className="size-3.5">`
|
|
376
376
|
before its label inside the pill. Decorative: the pill is still named
|
|
377
377
|
by its label.
|
|
378
|
+
- **The parts that draw an emoji beside its words** (4.145), each
|
|
379
|
+
decorative, the words still naming the thing:
|
|
380
|
+
- a facts rail's `kind: 'emoji'` fact: `size-5`, alone as the value, so
|
|
381
|
+
named by the emoji itself; printed as the character;
|
|
382
|
+
- `WidgetListItem`'s `lead`: `size-4`, before the row's text in its link;
|
|
383
|
+
- `MonthCalendarItem`'s `emoji`: `size-3.5`, no tile, before the title in
|
|
384
|
+
the month's cell and in the day's list. The day's summary line keeps
|
|
385
|
+
the titles' words only.
|
|
378
386
|
|
|
379
387
|
## Categorical colour
|
|
380
388
|
|
|
@@ -853,9 +861,15 @@ set, not a `DataTable` prop:
|
|
|
853
861
|
- `extra-large` is `large` about a ninth bigger again: body text 18 → 20px,
|
|
854
862
|
captions 15 → 17px, spacing 5 → 5.6px (controls 45px tall, icons 22px, the
|
|
855
863
|
sidebar 358px), and every other size in proportion. It sets every token
|
|
856
|
-
`large` sets, so whatever follows `large` follows it.
|
|
857
|
-
|
|
858
|
-
|
|
864
|
+
`large` sets, so whatever follows `large` follows it.
|
|
865
|
+
- **A record's facts rail grows with the text** (`--facts-rail-width`):
|
|
866
|
+
300px at the default, 375px at `large` and 420px at `extra-large`, the
|
|
867
|
+
text's own scale (1.25× and 1.4×), so a short value keeps its one line
|
|
868
|
+
beside its label. The record page grows by the same amount (see "Page
|
|
869
|
+
width"), and the room the view needs before it draws the rail beside
|
|
870
|
+
the body grows with it (960px at the default, about 1,040px and
|
|
871
|
+
1,090px). Nothing in the rail is ever cut, at any size: a value too
|
|
872
|
+
long for its line wraps (add-an-entity.md, "The facts rail").
|
|
859
873
|
- For `large` and `extra-large`, set it on **`<html>`**. Menus, selects,
|
|
860
874
|
dialogs and tooltips are portaled to `<body>`, so a wrapper `<div>` doesn't reach
|
|
861
875
|
them. `compact` and `comfortable` only touch tables and hub cards, so a
|
|
@@ -910,8 +924,9 @@ on a page ("A settings page").
|
|
|
910
924
|
### Page width (a record on a wide screen)
|
|
911
925
|
|
|
912
926
|
A record page (`EntityView`) keeps a reading width: its column is at most
|
|
913
|
-
`max-w-4xl`, and with a facts rail the page is that plus the
|
|
914
|
-
at `extra-large`
|
|
927
|
+
`max-w-4xl`, and with a facts rail the page is that plus the gap and the rail
|
|
928
|
+
(300px, 375px at `large`, 420px at `extra-large`): the column keeps its
|
|
929
|
+
width and the page grows by the rail's extra width.
|
|
915
930
|
On a TV the right of the page is then empty. `data-width="wide"` on
|
|
916
931
|
`<html>` lifts the cap: the column fills the page and the rail
|
|
917
932
|
keeps its width, moving right with it.
|
|
@@ -1034,7 +1049,9 @@ const layout = useWidgetLayout('my-app:hub', Object.keys(HUB_CARDS))
|
|
|
1034
1049
|
- **A row is one line:** its text is a link (`to` for a route in the
|
|
1035
1050
|
app, `href` for an external address, which opens in a new tab with the
|
|
1036
1051
|
external-link mark) or plain text, cut with an ellipsis, the whole of
|
|
1037
|
-
it in the link's name and its tooltip.
|
|
1052
|
+
it in the link's name and its tooltip. A `lead` (an `<Emoji
|
|
1053
|
+
className="size-4">`, an icon) goes before the text inside the link;
|
|
1054
|
+
it's decorative, so the text alone still names the row. After it, an optional `note`
|
|
1038
1055
|
(muted, small: "2 h ago", "holds 2") and an optional `trailing`
|
|
1039
1056
|
element: a tone badge (pattern 5's mapping) or a control.
|
|
1040
1057
|
- **A control in a row is named by the row's text.** Pass `trailing` as
|
|
@@ -2092,6 +2109,8 @@ package's `MonthCalendar`. Not a date picker, which is
|
|
|
2092
2109
|
- **On a laptop the days hold titles**: two to a day, by time, each
|
|
2093
2110
|
after a dot in its tone, and the rest folded to "+N more". **On a phone
|
|
2094
2111
|
they hold dots**, one per item in its tone, up to four.
|
|
2112
|
+
- **An item's `emoji`** is drawn before its title, in the cell and the
|
|
2113
|
+
day's list (Noto's picture, `size-3.5`, decorative).
|
|
2095
2114
|
- **The picked day's list is under the month**, every item with its time
|
|
2096
2115
|
("All day" without one), its `detail` and a link (`to`). The app's own
|
|
2097
2116
|
actions for that day sit beside its heading (`dayActions`, an Add
|
|
@@ -418,11 +418,14 @@ export function EditableField({ label, edit, children, layout = 'block', look =
|
|
|
418
418
|
'group/editable relative cursor-text items-start', !inlineValue && 'gap-1',
|
|
419
419
|
// A row: the row (editRowClass) wears the hover, not the value.
|
|
420
420
|
!row && '-mx-1.5 rounded-md px-1.5 transition-colors hover:bg-muted has-[[data-edit]:focus-visible]:bg-muted',
|
|
421
|
-
// Inline, the cap is its column plus
|
|
422
|
-
//
|
|
423
|
-
// its line) is sized to the margin box,
|
|
424
|
-
// and `max-w-full` then wrapped a short value mid-word.
|
|
425
|
-
|
|
421
|
+
// Inline, the cap is its column plus what the negative margins
|
|
422
|
+
// (-mx-1.5) give back: a parent sized to its content (a title on
|
|
423
|
+
// its line) is sized to the margin box, that much under the box,
|
|
424
|
+
// and `max-w-full` then wrapped a short value mid-word. In
|
|
425
|
+
// spacing steps, not rem: at Large and Extra Large the margins
|
|
426
|
+
// grow with --spacing, and a fixed 0.75rem left the record's
|
|
427
|
+
// title 3-5px short of its one line (4.145).
|
|
428
|
+
layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+var(--spacing)*3)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
|
|
426
429
|
'group-hover/editable:[&_.text-muted-foreground]:text-foreground group-has-[[data-edit]:focus-visible]/editable:[&_.text-muted-foreground]:text-foreground'), children: [children !== undefined ? children : edit.shown, _jsx("span", { role: "status", "data-slot": "editable-value-saved", className: "ml-2 inline-flex items-center gap-1 align-baseline type-caption text-success-text empty:hidden", children: justSaved && (_jsxs(_Fragment, { children: [_jsx(CheckIcon, { "aria-hidden": "true", className: "size-3.5" }), "Saved"] })) })] }), _jsx(InlinePencilRoom, { inline: inlineValue, children: _jsx(Button, { ref: editButton, "data-edit": "", type: "button", variant: "ghost", size: "icon-xs", "aria-label": `Edit ${label}`, onClick: start, className: cn('shrink-0 text-muted-foreground opacity-0 focus-visible:opacity-100 pointer-coarse:opacity-100', row ? 'group-hover/edit-row:opacity-100 hover:bg-transparent max-md:opacity-100' : 'group-hover/editable:opacity-100', inlineValue && 'absolute top-0 left-1 z-10'), children: row ? (_jsxs(_Fragment, { children: [_jsx(PencilIcon, { className: "max-md:hidden pointer-coarse:hidden" }), _jsx(ChevronRightIcon, { className: "hidden max-md:block pointer-coarse:block" })] })) : (_jsx(PencilIcon, {})) }) })] }));
|
|
427
430
|
}
|
|
428
431
|
// Always editable, before the store has it (the first render): the saved value.
|
|
@@ -10,11 +10,20 @@ export type EntityViewFactValue =
|
|
|
10
10
|
status: StatusKind;
|
|
11
11
|
word?: string;
|
|
12
12
|
}
|
|
13
|
-
/** Short text: a date, a number, a person's name.
|
|
13
|
+
/** Short text: a date, a number, a person's name. A long one wraps onto another line, never cut. `null` is empty. */
|
|
14
14
|
| {
|
|
15
15
|
kind: 'text';
|
|
16
16
|
text: string | number | null | undefined;
|
|
17
17
|
}
|
|
18
|
+
/**
|
|
19
|
+
* One emoji (`🎂`), drawn as Noto's picture (`<Emoji>`, `size-5`), named
|
|
20
|
+
* by the emoji itself for a screen reader. Printed as the character.
|
|
21
|
+
* `null` or `''` is empty.
|
|
22
|
+
*/
|
|
23
|
+
| {
|
|
24
|
+
kind: 'emoji';
|
|
25
|
+
emoji: string | null | undefined;
|
|
26
|
+
}
|
|
18
27
|
/** A few short labels (areas, tags) as badges, each with its icon if it has one. None is empty. */
|
|
19
28
|
| {
|
|
20
29
|
kind: 'badges';
|
|
@@ -148,10 +157,14 @@ export type EntityViewFact = EntityViewFactValue & {
|
|
|
148
157
|
/** A small button under the value, drawn in the rail and in Details alike. */
|
|
149
158
|
action?: EntityViewFactAction;
|
|
150
159
|
};
|
|
151
|
-
/**
|
|
152
|
-
|
|
160
|
+
/**
|
|
161
|
+
* A fact as the view draws it: `null` when empty. `label` names a control
|
|
162
|
+
* the fact draws (a switch). `printed`: as the printout has it (an emoji
|
|
163
|
+
* as its character, not Noto's picture).
|
|
164
|
+
*/
|
|
165
|
+
export declare function factValue(fact: EntityViewFactValue, label?: string, printed?: boolean): ReactNode;
|
|
153
166
|
/** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
|
|
154
|
-
export declare function factsAsFields(facts: readonly EntityViewFact[]): {
|
|
167
|
+
export declare function factsAsFields(facts: readonly EntityViewFact[], printed?: boolean): {
|
|
155
168
|
label: string;
|
|
156
169
|
value: ReactNode;
|
|
157
170
|
emptyLabel: string | undefined;
|
|
@@ -169,12 +182,26 @@ export declare function statusSectionFirst<T extends {
|
|
|
169
182
|
placement?: string;
|
|
170
183
|
tab?: string;
|
|
171
184
|
}>(sections: readonly T[]): T[];
|
|
172
|
-
/**
|
|
185
|
+
/**
|
|
186
|
+
* The width the view needs for the facts rail beside its column at
|
|
187
|
+
* Regular: 60rem (the column ~40rem, the 300px rail, the gap). At the
|
|
188
|
+
* large densities it grows by the rail's extra width and the gap's
|
|
189
|
+
* (`factsRailMinWidth`).
|
|
190
|
+
*/
|
|
173
191
|
export declare const FACTS_RAIL_MIN_WIDTH = 960;
|
|
192
|
+
/**
|
|
193
|
+
* The room the rail needs where `node` is, read from the density's own
|
|
194
|
+
* `--facts-rail-width` and `--spacing` (the gap is `gap-6`): 960px at
|
|
195
|
+
* Regular, 1041px at Large, about 1090px at Extra Large.
|
|
196
|
+
*/
|
|
197
|
+
export declare function factsRailMinWidth(node: Element): number;
|
|
174
198
|
/**
|
|
175
199
|
* Whether the element's parent (the room the view has: the page's content
|
|
176
|
-
* area, or a dialog's body) is
|
|
177
|
-
*
|
|
178
|
-
*
|
|
200
|
+
* area, or a dialog's body) is wide enough for the facts rail: `min` px,
|
|
201
|
+
* or by default the rail's room at the density in force
|
|
202
|
+
* (`factsRailMinWidth`). A ResizeObserver measures it: its first report
|
|
203
|
+
* comes after layout and before paint, and then on every resize, so the
|
|
204
|
+
* rail and the Details tab never flash. A change of Text Size
|
|
205
|
+
* (`data-density` on <html>) measures again.
|
|
179
206
|
*/
|
|
180
207
|
export declare function useWideParent<T extends HTMLElement>(enabled: boolean, min?: number): readonly [import("react").Dispatch<import("react").SetStateAction<T | null>>, boolean];
|
|
@@ -9,12 +9,17 @@ import { RatingScore } from './rating-score.js';
|
|
|
9
9
|
import { StepBar } from './step-bar.js';
|
|
10
10
|
import { StatusMark } from './status-mark.js';
|
|
11
11
|
import { FactSwitch } from './fact-extras.js';
|
|
12
|
+
import { Emoji } from './emoji.js';
|
|
12
13
|
const BADGE_TONE = {
|
|
13
14
|
success: 'outline-success',
|
|
14
15
|
warning: 'outline-warning',
|
|
15
16
|
info: 'outline-info',
|
|
16
17
|
destructive: 'outline-destructive',
|
|
17
18
|
};
|
|
19
|
+
// Nothing in the rail is ever cut, at any Text Size (4.145): a value too
|
|
20
|
+
// long for its line wraps onto another, and unbroken text (a code, an
|
|
21
|
+
// address) breaks anywhere rather than running past the rail.
|
|
22
|
+
const NEVER_CUT_INLINE = 'wrap-anywhere';
|
|
18
23
|
const LINK_CLASS = 'rounded-sm font-medium text-link underline-offset-4 outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50';
|
|
19
24
|
// A badge item's icon in the muted tone a list's item icons have
|
|
20
25
|
// (FactList's marks): a component drawn at the badge's icon size, or the
|
|
@@ -25,9 +30,17 @@ function badgeIcon(icon, toned = false) {
|
|
|
25
30
|
const Icon = icon;
|
|
26
31
|
return (_jsx("span", { "data-slot": "entity-view-fact-badge-icon", "aria-hidden": "true", "data-icon": "inline-start", className: cn('inline-flex shrink-0', !toned && 'text-muted-foreground'), children: isComponent ? _jsx(Icon, { "aria-hidden": "true", className: "size-3" }) : icon }));
|
|
27
32
|
}
|
|
28
|
-
/**
|
|
29
|
-
|
|
33
|
+
/**
|
|
34
|
+
* A fact as the view draws it: `null` when empty. `label` names a control
|
|
35
|
+
* the fact draws (a switch). `printed`: as the printout has it (an emoji
|
|
36
|
+
* as its character, not Noto's picture).
|
|
37
|
+
*/
|
|
38
|
+
export function factValue(fact, label = '', printed = false) {
|
|
30
39
|
switch (fact.kind) {
|
|
40
|
+
case 'emoji':
|
|
41
|
+
if (!fact.emoji)
|
|
42
|
+
return null;
|
|
43
|
+
return printed ? fact.emoji : _jsx(Emoji, { emoji: fact.emoji, label: fact.emoji, className: "size-5" });
|
|
31
44
|
case 'switch':
|
|
32
45
|
return _jsx(FactSwitch, { fact: fact, label: label });
|
|
33
46
|
case 'status':
|
|
@@ -36,19 +49,19 @@ export function factValue(fact, label = '') {
|
|
|
36
49
|
if (fact.text === null || fact.text === undefined || fact.text === '')
|
|
37
50
|
return null;
|
|
38
51
|
const text = String(fact.text);
|
|
39
|
-
return (_jsx("span", { "data-slot": "entity-view-fact-text",
|
|
52
|
+
return (_jsx("span", { "data-slot": "entity-view-fact-text", className: cn(NEVER_CUT_INLINE, 'tabular-nums'), children: text }));
|
|
40
53
|
}
|
|
41
54
|
case 'badges':
|
|
42
55
|
if (fact.items.length === 0)
|
|
43
56
|
return null;
|
|
44
|
-
return (_jsx("span", { className: "inline-flex max-w-full flex-wrap gap-1", children: fact.items.map((item, index) => {
|
|
57
|
+
return (_jsx("span", { className: "inline-flex max-w-full min-w-0 flex-wrap gap-1", children: fact.items.map((item, index) => {
|
|
45
58
|
const { label, icon, tone } = typeof item === 'string' ? { label: item, icon: undefined, tone: undefined } : item;
|
|
46
|
-
return (_jsxs(Badge, { variant: tone ? BADGE_TONE[tone] : 'outline', "data-tone": tone, className: "max-w-full", children: [icon !== undefined && icon !== null && badgeIcon(icon, tone !== undefined), _jsx("span", { className:
|
|
59
|
+
return (_jsxs(Badge, { variant: tone ? BADGE_TONE[tone] : 'outline', "data-tone": tone, className: "h-auto min-h-5 max-w-full shrink whitespace-normal", children: [icon !== undefined && icon !== null && badgeIcon(icon, tone !== undefined), _jsx("span", { className: cn('min-w-0', NEVER_CUT_INLINE), children: label })] }, `${index}:${label}`));
|
|
47
60
|
}) }));
|
|
48
61
|
case 'count':
|
|
49
62
|
return fact.to ? (_jsx(Link, { to: fact.to, className: cn(LINK_CLASS, 'tabular-nums'), children: fact.count })) : (_jsx("span", { className: "tabular-nums", children: fact.count }));
|
|
50
63
|
case 'link':
|
|
51
|
-
return (_jsxs("a", { href: fact.href, target: "_blank", rel: "noreferrer", className: cn(LINK_CLASS,
|
|
64
|
+
return (_jsxs("a", { href: fact.href, target: "_blank", rel: "noreferrer", className: cn(LINK_CLASS, NEVER_CUT_INLINE), children: [fact.name, _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "ml-1 inline size-3.5 align-[-0.125em]" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] }));
|
|
52
65
|
case 'list':
|
|
53
66
|
if (fact.items.length === 0)
|
|
54
67
|
return null;
|
|
@@ -60,14 +73,14 @@ export function factValue(fact, label = '') {
|
|
|
60
73
|
return fact.look === 'bar' ? (_jsx(StepBar, { value: fact.value, steps: max, word: fact.word, className: "align-middle" })) : (_jsx(RatingScore, { value: fact.value, max: max, glyph: fact.look === 'hearts' ? 'heart' : 'star', word: fact.word }));
|
|
61
74
|
}
|
|
62
75
|
case 'record':
|
|
63
|
-
return (_jsx(Link, { to: fact.to,
|
|
76
|
+
return (_jsx(Link, { to: fact.to, className: cn(LINK_CLASS, NEVER_CUT_INLINE), children: fact.name }));
|
|
64
77
|
}
|
|
65
78
|
}
|
|
66
79
|
/** A facts section's facts as fields rows, for Details, the column and printing: the status first. */
|
|
67
|
-
export function factsAsFields(facts) {
|
|
80
|
+
export function factsAsFields(facts, printed = false) {
|
|
68
81
|
return statusFirst(facts).map((fact) => ({
|
|
69
82
|
label: fact.label,
|
|
70
|
-
value: factValue(fact, fact.label),
|
|
83
|
+
value: factValue(fact, fact.label, printed),
|
|
71
84
|
emptyLabel: fact.emptyLabel,
|
|
72
85
|
// A switch is its own editor: an `edit` would wrap it in another.
|
|
73
86
|
edit: fact.kind === 'switch' ? undefined : fact.edit,
|
|
@@ -100,24 +113,60 @@ export function statusSectionFirst(sections) {
|
|
|
100
113
|
rest.splice(first, 0, status);
|
|
101
114
|
return rest;
|
|
102
115
|
}
|
|
103
|
-
/**
|
|
116
|
+
/**
|
|
117
|
+
* The width the view needs for the facts rail beside its column at
|
|
118
|
+
* Regular: 60rem (the column ~40rem, the 300px rail, the gap). At the
|
|
119
|
+
* large densities it grows by the rail's extra width and the gap's
|
|
120
|
+
* (`factsRailMinWidth`).
|
|
121
|
+
*/
|
|
104
122
|
export const FACTS_RAIL_MIN_WIDTH = 960;
|
|
123
|
+
// The column's share of FACTS_RAIL_MIN_WIDTH: what's left of 960 without
|
|
124
|
+
// Regular's 300px rail and its 24px gap (gap-6).
|
|
125
|
+
const FACTS_RAIL_COLUMN = FACTS_RAIL_MIN_WIDTH - 300 - 24;
|
|
126
|
+
/**
|
|
127
|
+
* The room the rail needs where `node` is, read from the density's own
|
|
128
|
+
* `--facts-rail-width` and `--spacing` (the gap is `gap-6`): 960px at
|
|
129
|
+
* Regular, 1041px at Large, about 1090px at Extra Large.
|
|
130
|
+
*/
|
|
131
|
+
export function factsRailMinWidth(node) {
|
|
132
|
+
const style = getComputedStyle(node);
|
|
133
|
+
const rail = parseFloat(style.getPropertyValue('--facts-rail-width'));
|
|
134
|
+
const spacing = style.getPropertyValue('--spacing').trim();
|
|
135
|
+
const rootSize = parseFloat(getComputedStyle(document.documentElement).fontSize) || 16;
|
|
136
|
+
const step = spacing.endsWith('rem') ? parseFloat(spacing) * rootSize : parseFloat(spacing);
|
|
137
|
+
if (!Number.isFinite(rail) || !Number.isFinite(step))
|
|
138
|
+
return FACTS_RAIL_MIN_WIDTH;
|
|
139
|
+
return FACTS_RAIL_COLUMN + rail + step * 6;
|
|
140
|
+
}
|
|
105
141
|
/**
|
|
106
142
|
* Whether the element's parent (the room the view has: the page's content
|
|
107
|
-
* area, or a dialog's body) is
|
|
108
|
-
*
|
|
109
|
-
*
|
|
143
|
+
* area, or a dialog's body) is wide enough for the facts rail: `min` px,
|
|
144
|
+
* or by default the rail's room at the density in force
|
|
145
|
+
* (`factsRailMinWidth`). A ResizeObserver measures it: its first report
|
|
146
|
+
* comes after layout and before paint, and then on every resize, so the
|
|
147
|
+
* rail and the Details tab never flash. A change of Text Size
|
|
148
|
+
* (`data-density` on <html>) measures again.
|
|
110
149
|
*/
|
|
111
|
-
export function useWideParent(enabled, min
|
|
150
|
+
export function useWideParent(enabled, min) {
|
|
112
151
|
const [node, setNode] = useState(null);
|
|
113
152
|
const [wide, setWide] = useState(false);
|
|
114
153
|
useLayoutEffect(() => {
|
|
115
154
|
const parent = node?.parentElement;
|
|
116
|
-
if (!enabled || !parent || typeof ResizeObserver === 'undefined')
|
|
155
|
+
if (!enabled || !node || !parent || typeof ResizeObserver === 'undefined')
|
|
117
156
|
return;
|
|
118
|
-
|
|
157
|
+
// Its layout width, not its box on screen: a dialog scaling in as it
|
|
158
|
+
// opens reads ~5% narrow on screen, and the observer doesn't report
|
|
159
|
+
// again when the scale ends, which left a rail that only just fits
|
|
160
|
+
// (Extra Large's ~1,090px in a 70rem dialog) folded for good.
|
|
161
|
+
const measure = () => setWide(parent.offsetWidth >= (min ?? factsRailMinWidth(node)));
|
|
162
|
+
const observer = new ResizeObserver(measure);
|
|
119
163
|
observer.observe(parent);
|
|
120
|
-
|
|
164
|
+
const density = typeof MutationObserver === 'undefined' ? null : new MutationObserver(measure);
|
|
165
|
+
density?.observe(document.documentElement, { attributes: true, attributeFilter: ['data-density', 'class', 'style'] });
|
|
166
|
+
return () => {
|
|
167
|
+
observer.disconnect();
|
|
168
|
+
density?.disconnect();
|
|
169
|
+
};
|
|
121
170
|
}, [node, enabled, min]);
|
|
122
171
|
return [setNode, enabled && wide];
|
|
123
172
|
}
|
|
@@ -222,9 +222,11 @@ export type EntityViewProps = {
|
|
|
222
222
|
railLabel?: string;
|
|
223
223
|
/**
|
|
224
224
|
* The facts rail (record standard A1), in the `tabs` layout:
|
|
225
|
-
* where the view has room (60rem beside it
|
|
226
|
-
* dialog), the sections of short
|
|
227
|
-
* `tab`) go in a column
|
|
225
|
+
* where the view has room (60rem beside it at Regular, more at the large
|
|
226
|
+
* Text Sizes: a laptop's page, a record dialog), the sections of short
|
|
227
|
+
* facts (`facts`, placed `rail`, no `tab`) go in a column
|
|
228
|
+
* (`--facts-rail-width`: 300px, 375px at Large, 420px at Extra Large)
|
|
229
|
+
* beside the record's body, and leave
|
|
228
230
|
* Details. The strip stays above, full width; the rail starts level with
|
|
229
231
|
* the first content under it (the open tab's first section, or the first
|
|
230
232
|
* card when cards come before the tabs). A Details tab left with
|
|
@@ -203,8 +203,9 @@ const RAIL_LAYOUT = {
|
|
|
203
203
|
sticky: '@4xl/view:data-[fits]:sticky @4xl/view:data-[fits]:top-6',
|
|
204
204
|
};
|
|
205
205
|
// The facts rail (A1): the record's column at its usual reading width
|
|
206
|
-
// (max-w-4xl) and
|
|
207
|
-
//
|
|
206
|
+
// (max-w-4xl) and the rail beside it (`--facts-rail-width`: 300px, 375px
|
|
207
|
+
// at Large and 420px at Extra Large, so the page grows by the rail's
|
|
208
|
+
// extra width at those sizes). The strip stays above both, at
|
|
208
209
|
// full width; the rail starts level with the first content under it: the
|
|
209
210
|
// first section of the open tab (beside the tab's content, never its bar),
|
|
210
211
|
// or the first card when the record's first content isn't the tabs.
|
|
@@ -418,7 +419,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
|
|
|
418
419
|
title: section.title,
|
|
419
420
|
...('fields' in section || 'facts' in section
|
|
420
421
|
? {
|
|
421
|
-
fields: ('fields' in section ? section.fields : factsAsFields(section.facts)).map((field) => ({
|
|
422
|
+
fields: ('fields' in section ? section.fields : factsAsFields(section.facts, true)).map((field) => ({
|
|
422
423
|
label: field.label,
|
|
423
424
|
value: field.value !== undefined ? field.value : field.edit?.shown,
|
|
424
425
|
})),
|
|
@@ -9,6 +9,12 @@ export type MonthCalendarItem = {
|
|
|
9
9
|
/** Its day, `'YYYY-MM-DD'`. */
|
|
10
10
|
day: PlainDate;
|
|
11
11
|
title: string;
|
|
12
|
+
/**
|
|
13
|
+
* Its emoji (`🎂`), drawn as Noto's picture before the title in the
|
|
14
|
+
* month's cell and in the day's list. Decorative: the title names it,
|
|
15
|
+
* and the day's summary line keeps the title's words only.
|
|
16
|
+
*/
|
|
17
|
+
emoji?: string | null;
|
|
12
18
|
/** `'HH:MM'`, or none for all day. */
|
|
13
19
|
time?: string | null;
|
|
14
20
|
/** Its dot and mark (design-language.md "Semantic tones"). Defaults to `info`. */
|
|
@@ -27,6 +27,7 @@ import { cn } from 'cn';
|
|
|
27
27
|
import { Button } from '../ui/button.js';
|
|
28
28
|
import { Skeleton } from '../ui/skeleton.js';
|
|
29
29
|
import { formatPlainDate, localToPlainDate } from '../../lib/plain-date.js';
|
|
30
|
+
import { Emoji } from './emoji.js';
|
|
30
31
|
import { ErrorState } from './error-state.js';
|
|
31
32
|
import { recordDialogState } from './record-dialog-context.js';
|
|
32
33
|
const TONE_DOT = {
|
|
@@ -161,10 +162,10 @@ export function MonthCalendar({ label, items = [], today, selected, onSelect, mo
|
|
|
161
162
|
const isToday = day === today;
|
|
162
163
|
const isPicked = day === picked;
|
|
163
164
|
const count = list.length;
|
|
164
|
-
return (_jsxs("td", { "data-day": day, "aria-selected": isPicked, "aria-current": isToday ? 'date' : undefined, tabIndex: day === stop ? 0 : -1, onClick: () => pick(day), onKeyDown: (event) => onKeyDown(event, day), className: cn('h-11 cursor-pointer border-r border-b border-border bg-card p-1 align-top outline-none md:h-20', 'hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset', isPicked && 'shadow-[inset_0_0_0_2px_var(--color-ring)]'), children: [_jsxs("span", { className: "sr-only", children: [`${dayLabel(day)}${isToday ? ', today' : ''}, ${count === 0 ? 'nothing' : count === 1 ? '1 item' : `${count} items`}`, count > 0 && `: ${list.map((item) => item.title).join(', ')}`] }), _jsxs("div", { className: "flex flex-col max-md:items-center", "aria-hidden": "true", children: [_jsx("span", { className: cn('w-fit rounded px-1 text-xs tabular-nums', isToday ? 'bg-primary font-semibold text-primary-foreground' : 'text-muted-foreground'), children: Number(day.slice(8)) }), isLoading ? (_jsx(Skeleton, { className: "mt-1 h-3 w-3/4 max-md:hidden" })) : (_jsxs(_Fragment, { children: [_jsxs("ul", { className: "mt-0.5 flex min-w-0 flex-col gap-0.5 max-md:hidden", children: [list.slice(0, 2).map((item) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1 text-xs text-foreground", children: [_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']) }), _jsx("span", { className: "truncate", children: item.title })] }, item.id))), count > 2 && _jsxs("li", { className: "pl-2.5 text-xs text-muted-foreground", children: ["+", count - 2, " more"] })] }), count > 0 && (_jsx("span", { className: "mt-1 flex justify-center gap-0.5 md:hidden", children: list.slice(0, 4).map((item) => (_jsx("span", { className: cn('size-1.5 rounded-full', TONE_DOT[item.tone ?? 'info']) }, item.id))) }))] }))] })] }, day));
|
|
165
|
+
return (_jsxs("td", { "data-day": day, "aria-selected": isPicked, "aria-current": isToday ? 'date' : undefined, tabIndex: day === stop ? 0 : -1, onClick: () => pick(day), onKeyDown: (event) => onKeyDown(event, day), className: cn('h-11 cursor-pointer border-r border-b border-border bg-card p-1 align-top outline-none md:h-20', 'hover:bg-muted/40 focus-visible:ring-3 focus-visible:ring-ring/50 focus-visible:ring-inset', isPicked && 'shadow-[inset_0_0_0_2px_var(--color-ring)]'), children: [_jsxs("span", { className: "sr-only", children: [`${dayLabel(day)}${isToday ? ', today' : ''}, ${count === 0 ? 'nothing' : count === 1 ? '1 item' : `${count} items`}`, count > 0 && `: ${list.map((item) => item.title).join(', ')}`] }), _jsxs("div", { className: "flex flex-col max-md:items-center", "aria-hidden": "true", children: [_jsx("span", { className: cn('w-fit rounded px-1 text-xs tabular-nums', isToday ? 'bg-primary font-semibold text-primary-foreground' : 'text-muted-foreground'), children: Number(day.slice(8)) }), isLoading ? (_jsx(Skeleton, { className: "mt-1 h-3 w-3/4 max-md:hidden" })) : (_jsxs(_Fragment, { children: [_jsxs("ul", { className: "mt-0.5 flex min-w-0 flex-col gap-0.5 max-md:hidden", children: [list.slice(0, 2).map((item) => (_jsxs("li", { className: "flex min-w-0 items-center gap-1 text-xs text-foreground", children: [_jsx("span", { className: cn('size-1.5 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']) }), item.emoji && _jsx(Emoji, { emoji: item.emoji, className: "size-3.5" }), _jsx("span", { className: "truncate", children: item.title })] }, item.id))), count > 2 && _jsxs("li", { className: "pl-2.5 text-xs text-muted-foreground", children: ["+", count - 2, " more"] })] }), count > 0 && (_jsx("span", { className: "mt-1 flex justify-center gap-0.5 md:hidden", children: list.slice(0, 4).map((item) => (_jsx("span", { className: cn('size-1.5 rounded-full', TONE_DOT[item.tone ?? 'info']) }, item.id))) }))] }))] })] }, day));
|
|
165
166
|
}) }, row))) })] }), _jsxs("div", { role: "group", "aria-label": `${dayLabel(picked)}${picked === today ? ', today' : ''}`, "data-slot": "month-calendar-day", className: "flex flex-col gap-1", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsxs("h3", { className: cn('mr-auto text-sm font-semibold', picked === today ? 'text-link' : 'text-foreground'), children: [dayLabel(picked), picked === today && ' · Today'] }), dayActions?.(picked)] }), isLoading ? (_jsxs("div", { className: "flex flex-col gap-2 py-1", children: [_jsx(Skeleton, { className: "h-4 w-2/3" }), _jsx(Skeleton, { className: "h-4 w-1/2" })] })) : pickedItems.length === 0 ? (_jsx("p", { className: "border-t border-border py-1.5 text-sm text-muted-foreground", children: "Nothing that day." })) : (_jsx("ul", { className: "flex flex-col", children: pickedItems.map((item) => {
|
|
166
167
|
const when = [item.time ? clock(item.time, locale) : 'All day', item.detail].filter(Boolean).join(' · ');
|
|
167
|
-
const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('size-2 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']), "aria-hidden": "true" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: when })] }));
|
|
168
|
+
const body = (_jsxs(_Fragment, { children: [_jsx("span", { className: cn('size-2 shrink-0 rounded-full', TONE_DOT[item.tone ?? 'info']), "aria-hidden": "true" }), item.emoji && _jsx(Emoji, { emoji: item.emoji, className: "size-3.5" }), _jsx("span", { className: "min-w-0 flex-1 truncate", children: item.title }), _jsx("span", { className: "shrink-0 text-xs text-muted-foreground", children: when })] }));
|
|
168
169
|
return (_jsx("li", { className: "border-t border-border", children: item.to ? (_jsx(Link, { to: item.to, state: linkState, className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground outline-none hover:underline focus-visible:ring-3 focus-visible:ring-ring/50", children: body })) : (_jsx("div", { className: "flex min-h-10 items-center gap-2 py-1.5 text-sm text-foreground", children: body })) }, item.id));
|
|
169
170
|
}) }))] })] }))] }));
|
|
170
171
|
}
|
|
@@ -113,6 +113,11 @@ export interface WidgetListItemProps {
|
|
|
113
113
|
to?: To;
|
|
114
114
|
/** An external address: the row is a link that opens in a new tab. Without `to` or `href` the row is plain text. */
|
|
115
115
|
href?: string;
|
|
116
|
+
/**
|
|
117
|
+
* Drawn before the text, inside the link: an emoji (`<Emoji>` at
|
|
118
|
+
* `size-4`) or an icon. Decorative: `children` still names the row.
|
|
119
|
+
*/
|
|
120
|
+
lead?: ReactNode;
|
|
116
121
|
/** A small muted note after the text: "2 h ago", "holds 2". */
|
|
117
122
|
note?: ReactNode;
|
|
118
123
|
/**
|
|
@@ -123,4 +128,4 @@ export interface WidgetListItemProps {
|
|
|
123
128
|
trailing?: ReactNode | ((rowTextId: string) => ReactNode);
|
|
124
129
|
className?: string;
|
|
125
130
|
}
|
|
126
|
-
export declare function WidgetListItem({ children, to, href, note, trailing, className }: WidgetListItemProps): import("react").JSX.Element;
|
|
131
|
+
export declare function WidgetListItem({ children, to, href, lead, note, trailing, className }: WidgetListItemProps): import("react").JSX.Element;
|
|
@@ -145,8 +145,12 @@ export function WidgetList({ children, className }) {
|
|
|
145
145
|
const ROW_LINK_CLASS = 'min-w-0 truncate rounded-sm font-medium text-foreground underline-offset-4 outline-none ' +
|
|
146
146
|
'hover:underline focus-visible:underline focus-visible:ring-3 focus-visible:ring-ring/50 ' +
|
|
147
147
|
'max-sm:density-compact:py-3';
|
|
148
|
-
export function WidgetListItem({ children, to, href, note, trailing, className }) {
|
|
148
|
+
export function WidgetListItem({ children, to, href, lead, note, trailing, className }) {
|
|
149
149
|
const textId = useId();
|
|
150
|
-
const
|
|
150
|
+
const hasLead = lead !== undefined && lead !== null && lead !== false;
|
|
151
|
+
// With a lead the text is its own cut span after it, both on one line.
|
|
152
|
+
const words = hasLead ? (_jsxs(_Fragment, { children: [_jsx("span", { "data-slot": "widget-list-item-lead", "aria-hidden": "true", className: "inline-flex shrink-0", children: lead }), _jsx("span", { className: "min-w-0 truncate", children: children })] })) : (children);
|
|
153
|
+
const leadRow = hasLead && 'flex items-center gap-1.5';
|
|
154
|
+
const text = to !== undefined ? (_jsx(Link, { id: textId, to: to, title: children, className: cn(ROW_LINK_CLASS, leadRow), children: words })) : href !== undefined ? (_jsxs("a", { id: textId, href: href, target: "_blank", rel: "noreferrer", title: children, className: cn(ROW_LINK_CLASS, 'flex items-center gap-1', hasLead && 'gap-1.5'), children: [hasLead ? words : _jsx("span", { className: "truncate", children: children }), _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3 shrink-0 text-muted-foreground" }), _jsx("span", { className: "sr-only", children: " (opens in a new tab)" })] })) : (_jsx("span", { id: textId, title: children, className: cn('min-w-0 truncate text-foreground', leadRow), children: words }));
|
|
151
155
|
return (_jsxs("li", { "data-slot": "widget-list-item", className: cn(ROW_CLASS, 'type-body', className), children: [text, (note !== undefined || trailing !== undefined) && (_jsxs("span", { className: "ml-auto flex shrink-0 items-center gap-3", children: [note !== undefined && _jsx("span", { className: "type-caption tabular-nums text-muted-foreground", children: note }), typeof trailing === 'function' ? trailing(textId) : trailing] }))] }));
|
|
152
156
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tristan2828/ui-foundation",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.145.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": {
|
package/styles/theme.css
CHANGED
|
@@ -619,8 +619,10 @@
|
|
|
619
619
|
large and extra-large densities to scale. */
|
|
620
620
|
--control-text-sm: 0.8rem;
|
|
621
621
|
|
|
622
|
-
/* A record's facts rail (EntityView):
|
|
623
|
-
|
|
622
|
+
/* A record's facts rail (EntityView): wide enough for a label beside a
|
|
623
|
+
short value. It grows with Text Size by the text's own scale (375px
|
|
624
|
+
at large, 420px at extra-large), and the record page grows with it;
|
|
625
|
+
a value that still doesn't fit wraps, never cut. */
|
|
624
626
|
--facts-rail-width: 300px;
|
|
625
627
|
|
|
626
628
|
/* Layer 2 — semantic (light) */
|
|
@@ -946,7 +948,7 @@
|
|
|
946
948
|
--table-cell-py: 0.75rem;
|
|
947
949
|
--table-head-height: 3.5rem;
|
|
948
950
|
|
|
949
|
-
--facts-rail-width:
|
|
951
|
+
--facts-rail-width: 375px; /* 300px × 1.25, the text's own growth: a short value keeps its one line */
|
|
950
952
|
}
|
|
951
953
|
|
|
952
954
|
/*
|
|
@@ -990,7 +992,7 @@
|
|
|
990
992
|
--table-cell-py: 0.8125rem;
|
|
991
993
|
--table-head-height: 3.9375rem;
|
|
992
994
|
|
|
993
|
-
--facts-rail-width:
|
|
995
|
+
--facts-rail-width: 420px; /* 300px × 1.4, as large's grows with its text */
|
|
994
996
|
}
|
|
995
997
|
|
|
996
998
|
.dark {
|