@tristan2828/ui-foundation 4.144.1 → 4.146.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.
@@ -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–1441
42
- - [The record view](#the-record-view) · lines 1080–1260
43
- - [Forms](#forms) · lines 1262–1345
44
- - [Dialogs](#dialogs) · lines 1347–1380
45
- - [Toasts and feedback](#toasts-and-feedback) · lines 1382–1441
46
- - [What not to copy](#what-not-to-copy) · lines 1443–1470
47
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1472–1489
48
- - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1491–1551
49
- - [Deleting](#deleting) · lines 1553–1583
50
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1585–1604
51
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1606–1615
52
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1618–1660
53
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1662–1695
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: a laptop's page, a record
1127
- dialog), so the page doesn't end 900px in. The strip stays above it at
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: one line, cut with
1151
- its whole text on hover. `badges` are a few short labels.
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
@@ -3,50 +3,51 @@
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
- - [Palettes](#palettes) · lines 59–142
7
- - [Glow](#glow) · lines 144–163
8
- - [Semantic tones](#semantic-tones) · lines 165–193
9
- - [The three badge styles](#the-three-badge-styles) · lines 195–212
10
- - [Status marks](#status-marks) · lines 214–257
11
- - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 259–288
12
- - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 290–301
13
- - [Logos and brand marks](#logos-and-brand-marks) · lines 303–343
14
- - [Emoji](#emoji) · lines 345–377
15
- - [Categorical colour](#categorical-colour) · lines 379–444
16
- - [Heat scale](#heat-scale) · lines 446–498
17
- - [Depth ramps](#depth-ramps) · lines 500–567
18
- - [A stored colour](#a-stored-colour) · lines 569–616
19
- - [Shapes and sizes](#shapes-and-sizes) · lines 618–639
20
- - [Typography](#typography) · lines 641–811
21
- - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 675–707
22
- - [Written text (notes)](#written-text-notes) · lines 709–811
23
- - [Density](#density) · lines 813–935
24
- - [Rows on this device](#rows-on-this-device) · lines 880–908
25
- - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 910–935
26
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 937–1047
27
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1049–1121
28
- - [Notices](#notices) · lines 1123–1150
29
- - [A value over time](#a-value-over-time) · lines 1152–1282
30
- - [Several values over time](#several-values-over-time) · lines 1201–1239
31
- - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1241–1282
32
- - [A list as a board](#a-list-as-a-board) · lines 1284–1394
33
- - [Order, groups and the header](#order-groups-and-the-header) · lines 1337–1394
34
- - [A list as cards](#a-list-as-cards) · lines 1396–1443
35
- - [Images full screen](#images-full-screen) · lines 1445–1491
36
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1493–1529
37
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1531–1567
38
- - [A few equal things](#a-few-equal-things) · lines 1569–1684
39
- - [An overview page](#an-overview-page) · lines 1686–1751
40
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1753–1816
41
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1818–1905
42
- - [Picking at random](#picking-at-random) · lines 1907–1938
43
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1940–2007
44
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2009–2028
45
- - [A quick add line](#a-quick-add-line) · lines 2030–2058
46
- - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2060–2084
47
- - [A month calendar](#a-month-calendar) · lines 2086–2116
48
- - [A settings page](#a-settings-page) · lines 2118–2175
49
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2177–2236
6
+ - [Palettes](#palettes) · lines 60–143
7
+ - [Glow](#glow) · lines 145–164
8
+ - [Semantic tones](#semantic-tones) · lines 166–194
9
+ - [The three badge styles](#the-three-badge-styles) · lines 196–213
10
+ - [Status marks](#status-marks) · lines 215–258
11
+ - [Mapping an enum to tones](#mapping-an-enum-to-tones) · lines 260–289
12
+ - [Glyphs and icons: 3:1](#glyphs-and-icons-31) · lines 291–302
13
+ - [Logos and brand marks](#logos-and-brand-marks) · lines 304–344
14
+ - [Emoji](#emoji) · lines 346–386
15
+ - [Categorical colour](#categorical-colour) · lines 388–453
16
+ - [Heat scale](#heat-scale) · lines 455–507
17
+ - [Depth ramps](#depth-ramps) · lines 509–576
18
+ - [A stored colour](#a-stored-colour) · lines 578–625
19
+ - [Shapes and sizes](#shapes-and-sizes) · lines 627–648
20
+ - [Typography](#typography) · lines 650–820
21
+ - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 684–716
22
+ - [Written text (notes)](#written-text-notes) · lines 718–820
23
+ - [Density](#density) · lines 822–951
24
+ - [Rows on this device](#rows-on-this-device) · lines 895–923
25
+ - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 925–951
26
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 953–1065
27
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1067–1139
28
+ - [Notices](#notices) · lines 1141–1168
29
+ - [A value over time](#a-value-over-time) · lines 1170–1300
30
+ - [Several values over time](#several-values-over-time) · lines 1219–1257
31
+ - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1259–1300
32
+ - [A list as a board](#a-list-as-a-board) · lines 1302–1412
33
+ - [Order, groups and the header](#order-groups-and-the-header) · lines 1355–1412
34
+ - [A list as cards](#a-list-as-cards) · lines 1414–1461
35
+ - [Images full screen](#images-full-screen) · lines 1463–1509
36
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1511–1547
37
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1549–1585
38
+ - [A few equal things](#a-few-equal-things) · lines 1587–1702
39
+ - [An overview page](#an-overview-page) · lines 1704–1769
40
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1771–1834
41
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1836–1923
42
+ - [Picking at random](#picking-at-random) · lines 1925–1956
43
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1958–2025
44
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 2027–2046
45
+ - [A quick add line](#a-quick-add-line) · lines 2048–2076
46
+ - [A date field's quick picks](#a-date-fields-quick-picks) · lines 2078–2102
47
+ - [A few choices, then the month](#a-few-choices-then-the-month) · lines 2104–2130
48
+ - [A month calendar](#a-month-calendar) · lines 2132–2164
49
+ - [A settings page](#a-settings-page) · lines 2166–2223
50
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2225–2284
50
51
 
51
52
  <!-- /index -->
52
53
 
@@ -375,6 +376,14 @@ inside text (notes, rich text) stay the device's.
375
376
  - **`PillFilter`'s `lead`:** a topic's `<Emoji className="size-3.5">`
376
377
  before its label inside the pill. Decorative: the pill is still named
377
378
  by its label.
379
+ - **The parts that draw an emoji beside its words** (4.145), each
380
+ decorative, the words still naming the thing:
381
+ - a facts rail's `kind: 'emoji'` fact: `size-5`, alone as the value, so
382
+ named by the emoji itself; printed as the character;
383
+ - `WidgetListItem`'s `lead`: `size-4`, before the row's text in its link;
384
+ - `MonthCalendarItem`'s `emoji`: `size-3.5`, no tile, before the title in
385
+ the month's cell and in the day's list. The day's summary line keeps
386
+ the titles' words only.
378
387
 
379
388
  ## Categorical colour
380
389
 
@@ -853,9 +862,15 @@ set, not a `DataTable` prop:
853
862
  - `extra-large` is `large` about a ninth bigger again: body text 18 → 20px,
854
863
  captions 15 → 17px, spacing 5 → 5.6px (controls 45px tall, icons 22px, the
855
864
  sidebar 358px), and every other size in proportion. It sets every token
856
- `large` sets, so whatever follows `large` follows it. It also widens a
857
- record's facts rail to 336px (`--facts-rail-width`; 300px at every other
858
- density), so a label still sits beside its value.
865
+ `large` sets, so whatever follows `large` follows it.
866
+ - **A record's facts rail grows with the text** (`--facts-rail-width`):
867
+ 300px at the default, 375px at `large` and 420px at `extra-large`, the
868
+ text's own scale (1.25× and 1.4×), so a short value keeps its one line
869
+ beside its label. The record page grows by the same amount (see "Page
870
+ width"), and the room the view needs before it draws the rail beside
871
+ the body grows with it (960px at the default, about 1,040px and
872
+ 1,090px). Nothing in the rail is ever cut, at any size: a value too
873
+ long for its line wraps (add-an-entity.md, "The facts rail").
859
874
  - For `large` and `extra-large`, set it on **`<html>`**. Menus, selects,
860
875
  dialogs and tooltips are portaled to `<body>`, so a wrapper `<div>` doesn't reach
861
876
  them. `compact` and `comfortable` only touch tables and hub cards, so a
@@ -910,8 +925,9 @@ on a page ("A settings page").
910
925
  ### Page width (a record on a wide screen)
911
926
 
912
927
  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 300px rail (336px
914
- at `extra-large` density).
928
+ `max-w-4xl`, and with a facts rail the page is that plus the gap and the rail
929
+ (300px, 375px at `large`, 420px at `extra-large`): the column keeps its
930
+ width and the page grows by the rail's extra width.
915
931
  On a TV the right of the page is then empty. `data-width="wide"` on
916
932
  `<html>` lifts the cap: the column fills the page and the rail
917
933
  keeps its width, moving right with it.
@@ -1034,7 +1050,9 @@ const layout = useWidgetLayout('my-app:hub', Object.keys(HUB_CARDS))
1034
1050
  - **A row is one line:** its text is a link (`to` for a route in the
1035
1051
  app, `href` for an external address, which opens in a new tab with the
1036
1052
  external-link mark) or plain text, cut with an ellipsis, the whole of
1037
- it in the link's name and its tooltip. After it, an optional `note`
1053
+ it in the link's name and its tooltip. A `lead` (an `<Emoji
1054
+ className="size-4">`, an icon) goes before the text inside the link;
1055
+ it's decorative, so the text alone still names the row. After it, an optional `note`
1038
1056
  (muted, small: "2 h ago", "holds 2") and an optional `trailing`
1039
1057
  element: a tone badge (pattern 5's mapping) or a control.
1040
1058
  - **A control in a row is named by the row's text.** Pass `trailing` as
@@ -2083,6 +2101,34 @@ days over the calendar, for a due day picked in one press:
2083
2101
  ahead; a day something happened (finished, bought) has no use for
2084
2102
  them.
2085
2103
 
2104
+ ## A few choices, then the month
2105
+
2106
+ A row's "move to" picker (a to-do's ⋯: the parts of the day, Tomorrow,
2107
+ or any day) is the package's `DateChoices`, never a `DropdownMenu` with a
2108
+ calendar in it. A calendar's grid can't sit inside `role="menu"`, and a
2109
+ menu's arrows never reach it.
2110
+
2111
+ - **The look is DateField's popup:** the app's `choices` at the top, under
2112
+ their `choicesLabel` heading ("Move to"), each a ghost button with its
2113
+ label on the left and its `value` muted on the right (a start time, "Thu,
2114
+ Nov 26"), over a `border-border` rule. Then the month, on the day the
2115
+ thing sits on (`value`), with today ringed (`today`, the app's own day,
2116
+ the browser's when left out). A choice that can't be picked now (a block
2117
+ that has ended) is `disabled`: shown, greyed, skipped by Tab.
2118
+ - **It's a dialog named for what it moves** (`label`, "Move Water the
2119
+ plants"), opened from the app's own `trigger`. It opens on the first
2120
+ choice that can be pressed, or on the month's day when there are none.
2121
+ Tab goes through the choices, then the month's buttons and its day,
2122
+ where the arrows move a day or a week. Escape closes, and focus goes
2123
+ back to the trigger.
2124
+ - **A choice runs its own `onSelect`; a day picked runs `onPick`** with
2125
+ its `'YYYY-MM-DD'`. Either closes the popup first, so a row that moves
2126
+ away leaves nothing open behind it. Each choice is named for its label
2127
+ and value ("Tomorrow, Thu, Nov 26"), as the quick picks are.
2128
+ - **DateField's popup shares its parts:** its quick picks are the same
2129
+ rows, its month the same calendar. A field still opens on the day, with
2130
+ its picks before it; a picker opens on its first choice.
2131
+
2086
2132
  ## A month calendar
2087
2133
 
2088
2134
  A month of days holding the app's dated things (events, visits): the
@@ -2092,6 +2138,8 @@ package's `MonthCalendar`. Not a date picker, which is
2092
2138
  - **On a laptop the days hold titles**: two to a day, by time, each
2093
2139
  after a dot in its tone, and the rest folded to "+N more". **On a phone
2094
2140
  they hold dots**, one per item in its tone, up to four.
2141
+ - **An item's `emoji`** is drawn before its title, in the cell and the
2142
+ day's list (Noto's picture, `size-3.5`, decorative).
2095
2143
  - **The picked day's list is under the month**, every item with its time
2096
2144
  ("All day" without one), its `detail` and a link (`to`). The app's own
2097
2145
  actions for that day sit beside its heading (`dayActions`, an Add
@@ -0,0 +1,63 @@
1
+ import { type ReactElement, type ReactNode } from 'react';
2
+ import { type PlainDate } from '../../lib/plain-date.js';
3
+ import type { WeekdayCode } from '../../lib/recurrence.js';
4
+ export type DateChoice = {
5
+ /** Its words, on the left: "Morning", "Tomorrow". Title Case. */
6
+ label: string;
7
+ /** What it means, muted on the right: a start time, a day ("Thu, Nov 26"). */
8
+ value?: string;
9
+ /** Shown, greyed and not pressable: a block that has ended. */
10
+ disabled?: boolean;
11
+ /** Pressed: the popup closes, then this runs. */
12
+ onSelect: () => void;
13
+ };
14
+ export type DateChoicesProps = {
15
+ /**
16
+ * The button that opens it, as a Base UI `render` element (`<Button
17
+ * size="icon-sm" variant="ghost" aria-label="Move Water the plants" />`),
18
+ * with `children` inside it.
19
+ */
20
+ trigger: ReactElement;
21
+ children?: ReactNode;
22
+ /** The popup's name, read when it opens: "Move Water the plants". */
23
+ label: string;
24
+ /** The rows' heading, shown over them and naming their group: "Move to". */
25
+ choicesLabel?: string;
26
+ choices?: readonly DateChoice[];
27
+ /** The day it's on now, `'YYYY-MM-DD'`: marked in the calendar, whose month opens on it. */
28
+ value?: PlainDate;
29
+ /**
30
+ * Today as the app counts it (a day that rolls over at 4 AM, say), ringed
31
+ * in the calendar. Defaults to the browser's today.
32
+ */
33
+ today?: PlainDate;
34
+ /** A day picked in the calendar, `'YYYY-MM-DD'`. The popup closes first. */
35
+ onPick: (day: PlainDate) => void;
36
+ /** The day the calendar's weeks start on (`'MO'` to `'SU'`; Monday when left out). */
37
+ weekStart?: WeekdayCode;
38
+ /** Where it lines up with the trigger. Defaults to `'end'`, as a row's ⋯ menu does. */
39
+ align?: 'start' | 'center' | 'end';
40
+ open?: boolean;
41
+ onOpenChange?: (open: boolean) => void;
42
+ className?: string;
43
+ };
44
+ export declare function DateChoices({ trigger, children, label, choicesLabel, choices, value, today, onPick, weekStart, align, open: givenOpen, onOpenChange, className, }: DateChoicesProps): import("react").JSX.Element;
45
+ /**
46
+ * The rows over a date popup's calendar, DateField's quick picks among
47
+ * them: ghost buttons in a named group, each its label on the left and its
48
+ * value muted on the right, named for both ("Tomorrow, Thu, Nov 26").
49
+ */
50
+ export declare function DateChoiceRows({ label, showLabel, choices, slot, }: {
51
+ label?: string;
52
+ /** The heading over the rows; `false` names the group without showing it (Quick Picks). */
53
+ showLabel?: boolean;
54
+ choices: readonly DateChoice[];
55
+ slot?: string;
56
+ }): import("react").JSX.Element | null;
57
+ /** A date popup's month: the day it's on marked, today ringed, a pick given as `'YYYY-MM-DD'`. */
58
+ export declare function DateChoiceCalendar({ value, today, weekStart, onPick, }: {
59
+ value?: PlainDate;
60
+ today?: PlainDate;
61
+ weekStart?: WeekdayCode;
62
+ onPick: (day: PlainDate) => void;
63
+ }): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ // A few choices, then the month calendar, opened from any trigger: a
3
+ // "move to" picker in DateField's look. The app gives its rows (a label,
4
+ // its value muted on the right, disabled or not) and the day the thing
5
+ // sits on; a row runs its own `onSelect` and a day picked in the calendar
6
+ // runs `onPick`, and either closes the popup.
7
+ //
8
+ // It is a dialog, never a menu: a calendar's grid can't sit inside a
9
+ // `role="menu"`, whose children are menu items. So the rows are buttons
10
+ // in a named group and the keyboard is DateField's: Tab goes through the
11
+ // rows, then the calendar (its month buttons, then its day, where the
12
+ // arrows move), Escape closes and focus goes back to the trigger. It
13
+ // opens on the first row that can be pressed, or on the calendar's day
14
+ // when there is none.
15
+ //
16
+ // DateField's own popup is built from the same parts: its quick picks are
17
+ // `DateChoiceRows`, and its calendar is `DateChoiceCalendar`.
18
+ import { useId, useRef, useState } from 'react';
19
+ import { cn } from 'cn';
20
+ import { Button } from '../ui/button.js';
21
+ import { Calendar } from '../ui/calendar.js';
22
+ import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover.js';
23
+ import { localToPlainDate, plainDateToLocal } from '../../lib/plain-date.js';
24
+ export function DateChoices({ trigger, children, label, choicesLabel, choices = [], value, today, onPick, weekStart, align = 'end', open: givenOpen, onOpenChange, className, }) {
25
+ const [ownOpen, setOwnOpen] = useState(false);
26
+ const open = givenOpen ?? ownOpen;
27
+ const popup = useRef(null);
28
+ const changeOpen = (next) => {
29
+ setOwnOpen(next);
30
+ onOpenChange?.(next);
31
+ };
32
+ // Closed first, then the app's own work: a row that moves the thing away
33
+ // (and unmounts the trigger) leaves nothing open behind it.
34
+ const close = (then) => {
35
+ changeOpen(false);
36
+ then();
37
+ };
38
+ return (_jsxs(Popover, { open: open, onOpenChange: changeOpen, children: [_jsx(PopoverTrigger, { render: trigger, children: children }), _jsxs(PopoverContent, { ref: popup, align: align, className: cn('w-auto p-0', className), "data-slot": "date-choices", "aria-label": label, initialFocus: () => popup.current?.querySelector('[data-slot="date-choice"]:not(:disabled)') ??
39
+ popup.current?.querySelector('button[data-day][tabindex="0"]') ??
40
+ true, children: [_jsx(DateChoiceRows, { label: choicesLabel, choices: choices.map((choice) => ({ ...choice, onSelect: () => close(choice.onSelect) })) }), _jsx(DateChoiceCalendar, { value: value, today: today, weekStart: weekStart, onPick: (day) => close(() => onPick(day)) })] })] }));
41
+ }
42
+ /**
43
+ * The rows over a date popup's calendar, DateField's quick picks among
44
+ * them: ghost buttons in a named group, each its label on the left and its
45
+ * value muted on the right, named for both ("Tomorrow, Thu, Nov 26").
46
+ */
47
+ export function DateChoiceRows({ label, showLabel = true, choices, slot = 'date-choices-rows', }) {
48
+ const headingId = useId();
49
+ if (choices.length === 0)
50
+ return null;
51
+ const shown = label && showLabel;
52
+ return (_jsxs("div", { role: "group", "aria-label": shown ? undefined : label, "aria-labelledby": shown ? headingId : undefined, "data-slot": slot, className: "flex flex-col gap-0.5 border-b border-border p-2", children: [shown && (_jsx("div", { id: headingId, className: "px-3 py-1 text-xs font-medium text-muted-foreground", children: label })), choices.map((choice) => (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", "data-slot": "date-choice", disabled: choice.disabled, className: "w-full justify-between gap-4 font-normal", "aria-label": choice.value ? `${choice.label}, ${choice.value}` : choice.label, onClick: choice.onSelect, children: [_jsx("span", { children: choice.label }), choice.value && _jsx("span", { className: "text-muted-foreground tabular-nums", children: choice.value })] }, choice.label)))] }));
53
+ }
54
+ // Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
55
+ const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
56
+ /** A date popup's month: the day it's on marked, today ringed, a pick given as `'YYYY-MM-DD'`. */
57
+ export function DateChoiceCalendar({ value, today, weekStart, onPick, }) {
58
+ const selected = value ? plainDateToLocal(value) : undefined;
59
+ return (_jsx(Calendar, { mode: "single",
60
+ // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
61
+ required: true, selected: selected, defaultMonth: selected, today: today ? plainDateToLocal(today) : undefined, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => onPick(localToPlainDate(date)) }));
62
+ }
@@ -24,21 +24,20 @@ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
24
24
  // week start), or an app passes its own list. Each is a button named for
25
25
  // its words and the day it sets ("Next Week, Mon, Nov 30"); pressing one
26
26
  // sets that day and closes, as a day picked in the calendar does. Off
27
- // unless asked for.
27
+ // unless asked for. The picks and the calendar are DateChoices' parts, the
28
+ // same rows and month an app's own "move to" picker shows.
28
29
  import { useId, useRef, useState } from 'react';
29
30
  import { CalendarIcon } from 'lucide-react';
30
31
  import { cn } from 'cn';
31
32
  import { Button } from '../ui/button.js';
32
- import { Calendar } from '../ui/calendar.js';
33
33
  import { InputGroup, InputGroupAddon, InputGroupButton, InputGroupInput } from '../ui/input-group.js';
34
34
  import { Popover, PopoverContent, PopoverTrigger } from '../ui/popover.js';
35
35
  import { DATE_QUICK_PICKS } from '../../lib/date-quick-picks.js';
36
- import { formatPlainDate, localToPlainDate, parsePlainDate, plainDateExamples, plainDateToLocal, unreadableDateMessage, } from '../../lib/plain-date.js';
36
+ import { formatPlainDate, localToPlainDate, parsePlainDate, plainDateExamples, unreadableDateMessage, } from '../../lib/plain-date.js';
37
+ import { DateChoiceCalendar, DateChoiceRows } from './date-choices.js';
37
38
  export function DateField({ typing = true, onProblem, ...props }) {
38
39
  return typing ? _jsx(TypedDate, { ...props, onProblem: onProblem }) : _jsx(DateButton, { ...props });
39
40
  }
40
- // Calendar's `weekStartsOn` by code. Left out, it's Calendar's own default (Monday).
41
- const WEEK_STARTS_ON = { SU: 0, MO: 1, TU: 2, WE: 3, TH: 4, FR: 5, SA: 6 };
42
41
  // The quick picks over the calendar, each named for its words and its day,
43
42
  // counted from the browser's own today when the calendar opens.
44
43
  function QuickPicks({ picks, weekStart = 'MO', locale, onPick, }) {
@@ -46,10 +45,9 @@ function QuickPicks({ picks, weekStart = 'MO', locale, onPick, }) {
46
45
  if (list.length === 0)
47
46
  return null;
48
47
  const today = localToPlainDate(new Date());
49
- return (_jsx("div", { role: "group", "aria-label": "Quick Picks", "data-slot": "date-field-quick-picks", className: "flex flex-col gap-0.5 border-b border-border p-2", children: list.map((pick) => {
48
+ return (_jsx(DateChoiceRows, { label: "Quick Picks", showLabel: false, slot: "date-field-quick-picks", choices: list.map((pick) => {
50
49
  const day = pick.day(today, weekStart);
51
- const shown = formatPlainDate(day, { weekday: 'short', month: 'short', day: 'numeric' }, locale);
52
- return (_jsxs(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full justify-between gap-4 font-normal", "aria-label": `${pick.label}, ${shown}`, onClick: () => onPick(day), children: [_jsx("span", { children: pick.label }), _jsx("span", { className: "text-muted-foreground", children: shown })] }, pick.label));
50
+ return { label: pick.label, value: formatPlainDate(day, { weekday: 'short', month: 'short', day: 'numeric' }, locale), onSelect: () => onPick(day) };
53
51
  }) }));
54
52
  }
55
53
  function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, quickPicks, locale, className, 'aria-describedby': describedBy, ...aria }) {
@@ -125,20 +123,16 @@ function TypedDate({ id, value, onChange, onPick, onProblem, placeholder, cleara
125
123
  changeOpen(true);
126
124
  }
127
125
  };
128
- const selected = plainDateToLocal(given);
129
126
  const showProblem = told && problem !== null;
130
127
  return (_jsxs("div", { "data-slot": "date-field", "data-kind": "date", className: cn('flex w-full min-w-0 flex-col gap-1.5', className), children: [_jsxs(InputGroup, { ref: group, children: [_jsx(InputGroupInput, { ref: box, id: id, value: text, onChange: (event) => type(event.target.value), onBlur: settle, onKeyDown: onKeyDown, placeholder: placeholder ?? plainDateExamples(locale), readOnly: readOnly, autoComplete: "off", "aria-invalid": invalid || showProblem || undefined, "aria-describedby": [showProblem ? messageId : null, describedBy].filter(Boolean).join(' ') || undefined, ...aria }), _jsx(InputGroupAddon, { align: "inline-end", children: _jsxs(Popover, { open: open, onOpenChange: changeOpen, modal: modal, children: [_jsx(PopoverTrigger, { render: _jsx(InputGroupButton, { type: "button", size: "icon-xs", variant: "ghost", disabled: readOnly, "aria-label": "Open Calendar" }), children: _jsx(CalendarIcon, { "aria-hidden": "true" }) }), _jsxs(PopoverContent, { ref: popup, anchor: group, align: "start", className: "w-auto p-0", "data-slot": "date-field-calendar", "aria-label": "Calendar",
131
128
  // The day the keyboard starts from (the chosen one, else today).
132
129
  initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true,
133
130
  // Back to the box, where typing goes on.
134
- finalFocus: box, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(Calendar, { mode: "single",
135
- // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
136
- required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
131
+ finalFocus: box, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(DateChoiceCalendar, { value: given, weekStart: weekStart, onPick: pick }), clearable && given && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }) })] }), showProblem && (_jsx("p", { id: messageId, "data-slot": "date-field-problem", className: "type-caption text-destructive-text", children: problem }))] }));
137
132
  }
138
133
  function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date', clearable = false, invalid = false, readOnly = false, defaultOpen = false, modal, onOpenChange, format, weekStart, quickPicks, locale, className, ...aria }) {
139
134
  const [open, setOpen] = useState(defaultOpen && !readOnly);
140
135
  const popup = useRef(null);
141
- const selected = plainDateToLocal(value);
142
136
  const shown = formatPlainDate(value, format, locale);
143
137
  const changeOpen = (next) => {
144
138
  if (next && readOnly)
@@ -155,7 +149,5 @@ function DateButton({ id, value, onChange, onPick, placeholder = 'Pick a date',
155
149
  // The day the keyboard starts from (the chosen one, else today):
156
150
  // the one day react-day-picker makes tabbable. The popup would
157
151
  // otherwise take focus itself, past the Calendar's autoFocus.
158
- initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(Calendar, { mode: "single",
159
- // Picking the chosen day again keeps it (and closes), never unsets it: Clear does that.
160
- required: true, selected: selected, defaultMonth: selected, weekStartsOn: weekStart && WEEK_STARTS_ON[weekStart], onSelect: (date) => pick(localToPlainDate(date)) }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
152
+ initialFocus: () => popup.current?.querySelector('button[data-day][tabindex="0"]') ?? true, children: [_jsx(QuickPicks, { picks: quickPicks, weekStart: weekStart, locale: locale, onPick: pick }), _jsx(DateChoiceCalendar, { value: value, weekStart: weekStart, onPick: pick }), clearable && value && (_jsx("div", { className: "border-t border-border p-2", children: _jsx(Button, { type: "button", variant: "ghost", size: "sm", className: "w-full", onClick: () => pick(''), children: "Clear" }) }))] })] }));
161
153
  }
@@ -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 the 0.75rem the negative
422
- // margins give back: a parent sized to its content (a title on
423
- // its line) is sized to the margin box, 0.75rem under the box,
424
- // and `max-w-full` then wrapped a short value mid-word.
425
- layout === 'block' ? 'flex w-full' : cn('inline-flex align-top', row ? 'max-w-full' : 'max-w-[calc(100%+0.75rem)]'), className), children: [_jsxs("span", { className: cn('min-w-0 flex-1', !row &&
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. One line, cut with its whole text on hover. `null` is empty. */
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
- /** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
152
- export declare function factValue(fact: EntityViewFactValue, label?: string): ReactNode;
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
- /** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
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 at least `min` px wide. A ResizeObserver
177
- * measures it: its first report comes after layout and before paint, and
178
- * then on every resize, so the rail and the Details tab never flash.
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
- /** A fact as the view draws it: `null` when empty. `label` names a control the fact draws (a switch). */
29
- export function factValue(fact, label = '') {
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", title: text, className: "inline-block max-w-full truncate align-bottom tabular-nums", children: 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: "min-w-0 truncate", children: label })] }, `${index}:${label}`));
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, 'inline-flex max-w-full items-center gap-1'), children: [_jsx("span", { className: "truncate", children: fact.name }), _jsx(ExternalLinkIcon, { "aria-hidden": "true", className: "size-3.5 shrink-0" }), _jsx("span", { className: "sr-only", children: "(opens in a new tab)" })] }));
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, title: fact.name, className: cn(LINK_CLASS, 'inline-block max-w-full truncate align-bottom'), children: fact.name }));
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
- /** The width the view needs for the facts rail beside its column: 60rem (the column ~40rem, a 300px rail, the gap). */
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 at least `min` px wide. A ResizeObserver
108
- * measures it: its first report comes after layout and before paint, and
109
- * then on every resize, so the rail and the Details tab never flash.
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 = FACTS_RAIL_MIN_WIDTH) {
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
- const observer = new ResizeObserver(() => setWide(parent.getBoundingClientRect().width >= min));
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
- return () => observer.disconnect();
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: a laptop's page, a record
226
- * dialog), the sections of short facts (`facts`, placed `rail`, no
227
- * `tab`) go in a column (300px, `--facts-rail-width`) beside the record's body, and leave
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 a 300px rail beside it (`--facts-rail-width`, 336px at extra-large
207
- // density). The strip stays above both, at
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 text = to !== undefined ? (_jsx(Link, { id: textId, to: to, title: children, className: ROW_LINK_CLASS, children: children })) : href !== undefined ? (_jsxs("a", { id: textId, href: href, target: "_blank", rel: "noreferrer", title: children, className: cn(ROW_LINK_CLASS, 'flex items-center gap-1'), children: [_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: "min-w-0 truncate text-foreground", children: children }));
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/dist/index.d.ts CHANGED
@@ -105,6 +105,7 @@ export { RatingStar, type RatingStarProps, type RatingStarValue } from './compon
105
105
  export { RatingScore, type RatingScoreGlyph, type RatingScoreProps } from './components/app/rating-score.js';
106
106
  export { RatingInput, type RatingInputProps, type RatingInputSource } from './components/app/rating-input.js';
107
107
  export { DateField, type DateFieldProps } from './components/app/date-field.js';
108
+ export { DateChoices, type DateChoice, type DateChoicesProps } from './components/app/date-choices.js';
108
109
  export { addPlainDays, comingWeekday, DATE_QUICK_PICKS, NEXT_WEEK_PICK, THIS_WEEKEND_PICK, TODAY_PICK, TOMORROW_PICK, type DateQuickPick, } from './lib/date-quick-picks.js';
109
110
  export { EmojiField, type EmojiFieldProps } from './components/app/emoji-field.js';
110
111
  export { Emoji, EmojiTile, type EmojiProps, type EmojiTileProps } from './components/app/emoji.js';
package/dist/index.js CHANGED
@@ -115,6 +115,7 @@ export { RatingStar } from './components/app/rating-star.js';
115
115
  export { RatingScore } from './components/app/rating-score.js';
116
116
  export { RatingInput } from './components/app/rating-input.js';
117
117
  export { DateField } from './components/app/date-field.js';
118
+ export { DateChoices } from './components/app/date-choices.js';
118
119
  export { addPlainDays, comingWeekday, DATE_QUICK_PICKS, NEXT_WEEK_PICK, THIS_WEEKEND_PICK, TODAY_PICK, TOMORROW_PICK, } from './lib/date-quick-picks.js';
119
120
  export { EmojiField } from './components/app/emoji-field.js';
120
121
  export { Emoji, EmojiTile } from './components/app/emoji.js';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.144.1",
3
+ "version": "4.146.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): a fixed width, wide enough for a
623
- label beside its value. Only extra-large widens it. */
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: 300px; /* the default's: its rows still fit side by side */
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: 336px; /* 300px, so a label still fits beside its value */
995
+ --facts-rail-width: 420px; /* 300px × 1.4, as large's grows with its text */
994
996
  }
995
997
 
996
998
  .dark {