@tristan2828/ui-foundation 4.138.0 → 4.140.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.
@@ -1116,7 +1116,7 @@ A record uses the parts it has, in this order:
1116
1116
  - **Facts beside their labels** (`railFields`, `beside` by default), so the short facts read as a list of pairs rather than a column
1117
1117
  of labels; keep labels to a word or two.
1118
1118
  - **The facts rail**: `factsRail` on the
1119
- view puts the record's short facts in a 300px column beside the
1119
+ view puts the record's short facts in a narrow column beside the
1120
1120
  record's body where the view has room (60rem: a laptop's page, a record
1121
1121
  dialog), so the page doesn't end 900px in. The strip stays above it at
1122
1122
  full width, and the rail starts level with the first content under the
@@ -19,31 +19,31 @@
19
19
  - [Typography](#typography) · lines 603–773
20
20
  - [Words on screen: Title Case and sentence case](#words-on-screen-title-case-and-sentence-case) · lines 637–669
21
21
  - [Written text (notes)](#written-text-notes) · lines 671–773
22
- - [Density](#density) · lines 775–886
23
- - [Rows on this device](#rows-on-this-device) · lines 833–860
24
- - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 862–886
25
- - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 888–998
26
- - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1000–1072
27
- - [Notices](#notices) · lines 1074–1101
28
- - [A value over time](#a-value-over-time) · lines 1103–1233
29
- - [Several values over time](#several-values-over-time) · lines 1152–1190
30
- - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1192–1233
31
- - [A list as a board](#a-list-as-a-board) · lines 1235–1345
32
- - [Order, groups and the header](#order-groups-and-the-header) · lines 1288–1345
33
- - [A list as cards](#a-list-as-cards) · lines 1347–1394
34
- - [Images full screen](#images-full-screen) · lines 1396–1442
35
- - [Key numbers on a record](#key-numbers-on-a-record) · lines 1444–1480
36
- - [Parts of the page standards](#parts-of-the-page-standards) · lines 1482–1518
37
- - [A few equal things](#a-few-equal-things) · lines 1520–1635
38
- - [An overview page](#an-overview-page) · lines 1637–1702
39
- - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1704–1767
40
- - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1769–1856
41
- - [Picking at random](#picking-at-random) · lines 1858–1889
42
- - [Filling in what's missing](#filling-in-whats-missing) · lines 1891–1958
43
- - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1960–1979
44
- - [A quick add line](#a-quick-add-line) · lines 1981–2009
45
- - [A month calendar](#a-month-calendar) · lines 2011–2041
46
- - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2043–2095
22
+ - [Density](#density) · lines 775–896
23
+ - [Rows on this device](#rows-on-this-device) · lines 842–869
24
+ - [Page width (a record on a wide screen)](#page-width-a-record-on-a-wide-screen) · lines 871–896
25
+ - [Widget cards (hub pages)](#widget-cards-hub-pages) · lines 898–1008
26
+ - [Module cards (a hub's places)](#module-cards-a-hubs-places) · lines 1010–1082
27
+ - [Notices](#notices) · lines 1084–1111
28
+ - [A value over time](#a-value-over-time) · lines 1113–1243
29
+ - [Several values over time](#several-values-over-time) · lines 1162–1200
30
+ - [Parts of a whole over time](#parts-of-a-whole-over-time) · lines 1202–1243
31
+ - [A list as a board](#a-list-as-a-board) · lines 1245–1355
32
+ - [Order, groups and the header](#order-groups-and-the-header) · lines 1298–1355
33
+ - [A list as cards](#a-list-as-cards) · lines 1357–1404
34
+ - [Images full screen](#images-full-screen) · lines 1406–1452
35
+ - [Key numbers on a record](#key-numbers-on-a-record) · lines 1454–1490
36
+ - [Parts of the page standards](#parts-of-the-page-standards) · lines 1492–1528
37
+ - [A few equal things](#a-few-equal-things) · lines 1530–1645
38
+ - [An overview page](#an-overview-page) · lines 1647–1712
39
+ - [A record's header and empty values](#a-records-header-and-empty-values) · lines 1714–1777
40
+ - [A record's tabs, mark and facts](#a-records-tabs-mark-and-facts) · lines 1779–1866
41
+ - [Picking at random](#picking-at-random) · lines 1868–1899
42
+ - [Filling in what's missing](#filling-in-whats-missing) · lines 1901–1968
43
+ - [Values edited in place: the presets' looks](#values-edited-in-place-the-presets-looks) · lines 1970–1989
44
+ - [A quick add line](#a-quick-add-line) · lines 1991–2019
45
+ - [A month calendar](#a-month-calendar) · lines 2021–2051
46
+ - [The sidebar and the phone's bar](#the-sidebar-and-the-phones-bar) · lines 2053–2112
47
47
 
48
48
  <!-- /index -->
49
49
 
@@ -774,7 +774,7 @@ pulls the eye from every other column (cell patterns 16 and 20).
774
774
 
775
775
  ## Density
776
776
 
777
- Four densities, set with `data-density` on **any ancestor** (a wrapper
777
+ Five densities, set with `data-density` on **any ancestor** (a wrapper
778
778
  `<div>`, a route's layout, or `<html>` for the whole app). It is a token
779
779
  set, not a `DataTable` prop:
780
780
 
@@ -790,16 +790,18 @@ set, not a `DataTable` prop:
790
790
  | `compact` | a hub's cards (`WidgetCard`, `WidgetList` rows, `ModuleCard`); table rows stay the default's | 4px | 32px | a dense hub |
791
791
  | `comfortable` | table rows only | 12px | 48px | short tables, or rows people read rather than scan |
792
792
  | `large` | **everything**: type, spacing, control heights, icons, the sidebar, table rows | 12px | 56px | a screen read from a distance: a TV used as the desktop monitor, with a mouse and keyboard |
793
+ | `extra-large` | **everything**, a step past `large` | 13px | 63px | the same screen read from further back, such as a couch |
793
794
 
794
795
  - `compact` and `comfortable` change padding only. Text keeps
795
796
  `type-body`, so compact never drops below a readable size.
796
- - **Forms are compact at every density but `large`**: inside a
797
+ - **Forms are compact at every density but the two large ones**: inside a
797
798
  `FieldGroup` (every `EntityForm`, `FormDialog` and `FormSection`) the
798
799
  inputs, selects, combobox boxes and default buttons are 32px, the
799
800
  compact table's row, with 14px between fields; under 48rem or on a
800
801
  touch screen 40px, for the finger. They read `--control-height`, which
801
- `FieldGroup` and the forms' bars set from `--spacing`, so `large` grows
802
- them as it grows everything. Outside a form a control keeps its 36px.
802
+ `FieldGroup` and the forms' bars set from `--spacing`, so `large` and
803
+ `extra-large` grow them as they grow everything. Outside a form a control
804
+ keeps its 36px.
803
805
  - On a hub, `compact` takes a `WidgetCard`'s padding from 16px to 12px,
804
806
  a `WidgetList` row from 36px to 32px (6px around its line) and a
805
807
  `ModuleCard`'s band and body by 4px each. On a phone a compact row is
@@ -810,20 +812,27 @@ set, not a `DataTable` prop:
810
812
  Breakpoints and `max-w-*` containers stay where they are, which is
811
813
  what browser zoom can't do (zoom narrows the viewport in CSS pixels, so
812
814
  a wide screen can fall into the phone layout).
813
- - For `large`, set it on **`<html>`**. Menus, selects, dialogs and
814
- tooltips are portaled to `<body>`, so a wrapper `<div>` doesn't reach
815
+ - `extra-large` is `large` about a ninth bigger again: body text 18 → 20px,
816
+ captions 15 → 17px, spacing 5 → 5.6px (controls 45px tall, icons 22px, the
817
+ sidebar 358px), and every other size in proportion. It sets every token
818
+ `large` sets, so whatever follows `large` follows it. It also widens a
819
+ record's facts rail to 336px (`--facts-rail-width`; 300px at every other
820
+ density), so a label still sits beside its value.
821
+ - For `large` and `extra-large`, set it on **`<html>`**. Menus, selects,
822
+ dialogs and tooltips are portaled to `<body>`, so a wrapper `<div>` doesn't reach
815
823
  them. `compact` and `comfortable` only touch tables and hub cards, so a
816
824
  wrapper is fine.
817
825
  - Pick **one density per screen**. Two tables at different densities side
818
826
  by side look like a mistake.
819
- - Size things the way the package does and `large` reaches them for free:
827
+ - Size things the way the package does and `large` and `extra-large` reach
828
+ them for free:
820
829
  Tailwind's spacing and size utilities (`h-8`, `size-4`, `gap-2`, `w-64`)
821
830
  and `text-*`/`type-*`. A fixed `h-[18px]`, `w-[240px]` or
822
- `text-[13px]` stays its size at `large`; write it as a step of the scale
831
+ `text-[13px]` stays its size at both; write it as a step of the scale
823
832
  (`h-[--spacing(4.5)]`) instead.
824
833
  - Under the hood, the table primitive's cells read `--table-cell-px`,
825
- `--table-cell-py` and `--table-head-height`. `large` also redefines
826
- Tailwind's own scale (`--spacing`, `--text-*`, `--radius`), the `--type-*`
834
+ `--table-cell-py` and `--table-head-height`. `large` and `extra-large` also
835
+ redefine Tailwind's own scale (`--spacing`, `--text-*`, `--radius`), the `--type-*`
827
836
  roles and `--control-text-sm` (the small Button and Toggle). The
828
837
  selectors are in `styles/theme.css`. A composite reaches `compact` with
829
838
  the `density-compact:` variant (`styles/index.css`: any ancestor with
@@ -862,10 +871,11 @@ toggle in an app without a palette).
862
871
  ### Page width (a record on a wide screen)
863
872
 
864
873
  A record page (`EntityView`) keeps a reading width: its column is at most
865
- `max-w-4xl`, and with a facts rail the page is that plus the 300px rail.
874
+ `max-w-4xl`, and with a facts rail the page is that plus the 300px rail (336px
875
+ at `extra-large` density).
866
876
  On a TV the right of the page is then empty. `data-width="wide"` on
867
877
  `<html>` lifts the cap: the column fills the page and the rail
868
- stays 300px, moving right with it.
878
+ keeps its width, moving right with it.
869
879
 
870
880
  ```ts
871
881
  // The app's own Page Width setting, kept per browser, applied before first paint.
@@ -2059,6 +2069,7 @@ const nav: NavEntry[] = [
2059
2069
  const bottomBar: BottomBarItem[] = [
2060
2070
  { to: '/', label: 'Home', icon: HouseIcon },
2061
2071
  { group: 'Every day', icon: SunIcon, sheet: 'tiles' },
2072
+ { search: true, icon: SearchIcon },
2062
2073
  ]
2063
2074
  ```
2064
2075
 
@@ -2089,7 +2100,13 @@ const bottomBar: BottomBarItem[] = [
2089
2100
  the hub). It replaces a page's own back link; the bar sits outside
2090
2101
  `<main>`, so the page's links are still the only ones in it.
2091
2102
  - **Search in the bar** (`search={{ placeholder, findRecords, recent }}`):
2092
- a box from 48rem up, a search button on a phone, and the shortcut
2093
- (Ctrl K, ⌘K on a Mac) open a palette of the nav's pages, the records
2103
+ a box from 48rem up, a search button on a phone (the bar's instead,
2104
+ where it has Search), and the shortcut (Ctrl K, ⌘K on a Mac) open a palette of the nav's pages, the records
2094
2105
  opened lately on this device (`useRecentRecord`) and the app's records
2095
2106
  under their `kind`.
2107
+ - **Search on the phone's bar** (`{ search: true, icon: SearchIcon }` in
2108
+ `bottomBar`): a button named Search among the bar's items, opening the
2109
+ same palette in thumb reach. It is an action, not a place: never the
2110
+ current item and never counted. It takes the place of the header's
2111
+ button on a phone, so there is one Search. Without `search`, or past the
2112
+ bar's fifth item, it isn't drawn and the header is as without it.
@@ -4,10 +4,13 @@ import { type BottomBarItem, type NavEntry, type NavLook } from './app-shell-nav
4
4
  * plus the bar (4rem and its 1px border) and the phone's safe area.
5
5
  */
6
6
  export declare const BOTTOM_BAR_PADDING = "max-md:pb-[calc(--spacing(22)+1px+env(safe-area-inset-bottom))]";
7
- export declare function BottomBar({ items, nav, activeTo, navLook, }: {
7
+ export declare function BottomBar({ items, nav, activeTo, navLook, onSearch, }: {
8
+ /** The items drawn (bottomBarItems). */
8
9
  items: readonly BottomBarItem[];
9
10
  nav: readonly NavEntry[];
10
11
  activeTo: string | undefined;
11
12
  /** The shell's `navLook`: a section's sheet follows its look when its item sets no `sheet`. */
12
13
  navLook?: NavLook;
14
+ /** Opens the search palette, for the button pressed. */
15
+ onSearch: (opener: HTMLElement) => void;
13
16
  }): import("react").JSX.Element;
@@ -6,7 +6,8 @@ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-run
6
6
  // their children, under them, by heading where they have them), or with
7
7
  // `sheet: 'tiles'` a grid of the entries as tiles, icon over label, like
8
8
  // a phone's home screen. The sheet closes on navigation, as the
9
- // sidebar's does. The item holding the current page is marked
9
+ // sidebar's does. Or an item is Search, a button that opens the header's
10
+ // own palette (search-palette.tsx), in place of the header's button. The item holding the current page is marked
10
11
  // (`aria-current`). An entry's `count` shows on the phone as it does in
11
12
  // the sidebar: a badge on a bar item's icon (a page's own, or the sum of a
12
13
  // section's), in a tile's corner, at a sheet link's end; nothing at 0 or
@@ -49,7 +50,8 @@ function TileCount({ count }) {
49
50
  }
50
51
  // A bar item's icon, with its count as a badge on its corner: the
51
52
  // primary's fill, ringed in the bar's background so it stands off the
52
- // icon. Sized in em, so it grows with the type at large density.
53
+ // icon. Sized in em, so it grows with the type at large and
54
+ // extra-large density.
53
55
  function BarIcon({ icon: Icon, count }) {
54
56
  const text = navCountText(count);
55
57
  return (_jsxs("span", { className: "relative inline-flex", children: [_jsx(Icon, { "aria-hidden": "true" }), text !== undefined && (_jsx("span", { "aria-hidden": "true", "data-slot": "bottom-bar-count", className: "absolute -top-1.5 left-[calc(100%-0.5rem)] inline-flex h-[1.5em] min-w-[1.5em] items-center justify-center rounded-full bg-primary px-[0.35em] type-caption leading-none font-medium text-primary-foreground tabular-nums ring-2 ring-background", children: text }))] }));
@@ -94,22 +96,23 @@ function SheetTiles({ items, activeTo, withPages, }) {
94
96
  return (_jsx("li", { className: "flex min-w-0", children: _jsxs(Link, { to: to, "aria-current": current, className: `${TILE_CLASS} flex-1`, children: [_jsx(Icon, { "aria-hidden": "true" }), _jsx(CountedLabel, { label: label, count: count, countLabel: countLabel, className: "max-w-full break-words" }), _jsx(TileCount, { count: count })] }) }, to));
95
97
  }) }), withPages && _jsx(SheetPageTiles, { items: items, activeTo: activeTo })] }));
96
98
  }
97
- export function BottomBar({ items, nav, activeTo, navLook = 'list', }) {
99
+ export function BottomBar({ items, nav, activeTo, navLook = 'list', onSearch, }) {
98
100
  // The section open, and the location it was opened at: following a link
99
101
  // in the sheet (or anywhere) moves to a new location, which closes it.
100
102
  const [opened, setOpened] = useState(null);
101
103
  const { key } = useLocation();
102
104
  const openGroup = opened?.at === key ? opened.group : null;
103
105
  const setOpenGroup = (group) => setOpened(group === null ? null : { group, at: key });
104
- // At most five: a sixth wouldn't fit a phone's width with its label.
105
- const shown = items.slice(0, 5);
106
- const current = bottomBarCurrent(shown, nav, activeTo);
106
+ const current = bottomBarCurrent(items, nav, activeTo);
107
107
  const section = openGroup === null ? undefined : bottomBarSection(nav, openGroup);
108
- const openItem = shown.find((item) => 'group' in item && item.group === openGroup);
108
+ const openItem = items.find((item) => 'group' in item && item.group === openGroup);
109
109
  const tiles = openItem !== undefined && bottomBarTiles(openItem, section, navLook);
110
110
  // The current entry's pages show under the tiles when the section's own look is tiles.
111
111
  const withPages = (section?.look ?? navLook) === 'tiles';
112
- return (_jsxs(_Fragment, { children: [_jsx("nav", { "aria-label": "Bottom Bar", "data-slot": "app-shell-bottom-bar", className: "fixed inset-x-0 bottom-0 z-20 border-t border-border bg-background pb-[env(safe-area-inset-bottom)] md:hidden", children: _jsx("ul", { className: "flex h-16 items-stretch gap-1 px-2 py-1.5", children: shown.map((item, index) => {
112
+ return (_jsxs(_Fragment, { children: [_jsx("nav", { "aria-label": "Bottom Bar", "data-slot": "app-shell-bottom-bar", className: "fixed inset-x-0 bottom-0 z-20 border-t border-border bg-background pb-[env(safe-area-inset-bottom)] md:hidden", children: _jsx("ul", { className: "flex h-16 items-stretch gap-1 px-2 py-1.5", children: items.map((item, index) => {
113
+ if ('search' in item) {
114
+ return (_jsx("li", { className: "flex min-w-0 flex-1", children: _jsxs("button", { type: "button", "data-slot": "bottom-bar-search", "aria-haspopup": "dialog", onClick: (event) => onSearch(event.currentTarget), className: ITEM_CLASS, children: [_jsx(BarIcon, { icon: item.icon }), _jsx("span", { className: "max-w-full truncate", children: "Search" })] }) }, "search"));
115
+ }
113
116
  const isCurrent = index === current;
114
117
  const { count, countLabel } = bottomBarCount(item, nav);
115
118
  if ('to' in item) {
@@ -179,9 +179,9 @@ export declare function trailBackTarget(nav: readonly NavEntry[], pathname: stri
179
179
  } | undefined;
180
180
  /**
181
181
  * One item of `AppShell`'s `bottomBar`, the phone's bar of shortcuts: a
182
- * page, or one of the nav's sections by its label, which opens a sheet of
183
- * that section's entries. `label` is a shorter name for the bar
184
- * ("Household" for "Home and money").
182
+ * page, one of the nav's sections by its label, which opens a sheet of
183
+ * that section's entries, or Search. A section's `label` is a shorter name
184
+ * for the bar ("Household" for "Home and money").
185
185
  */
186
186
  export type BottomBarItem = {
187
187
  to: string;
@@ -198,7 +198,23 @@ export type BottomBarItem = {
198
198
  * it, the section's look decides (`NavSection.look`, `navLook`).
199
199
  */
200
200
  sheet?: 'list' | 'tiles';
201
+ } | {
202
+ /**
203
+ * A button named Search that opens the shell's search palette, the
204
+ * one its header opens, in place of the header's own button on a
205
+ * phone. Never the current page, and never counted. Drawn only with
206
+ * the shell's `search`.
207
+ */
208
+ search: true;
209
+ /** The header's is lucide's `SearchIcon`. */
210
+ icon: IconComponent;
201
211
  };
212
+ /**
213
+ * The bar's items that are drawn: Search only when the shell has it, so
214
+ * without it an item after it takes its place, and a bar of Search alone
215
+ * is no bar.
216
+ */
217
+ export declare function bottomBarItems(items: readonly BottomBarItem[] | undefined, hasSearch: boolean): readonly BottomBarItem[];
202
218
  /**
203
219
  * Whether a bottom bar item's sheet is tiles: its own `sheet`, or else
204
220
  * its section's look (the section's `look`, or the shell's `navLook`).
@@ -218,8 +234,11 @@ export declare function bottomBarSection(nav: readonly NavEntry[], label: string
218
234
  /**
219
235
  * Which bar item holds the current page (`activeTo`, from activeNavTo):
220
236
  * the page's own link, or else the section it's in, children included.
237
+ * Never Search.
221
238
  */
222
239
  export declare function bottomBarCurrent(items: readonly BottomBarItem[], nav: readonly NavEntry[], activeTo: string | undefined): number | undefined;
240
+ /** Whether the bar draws Search, of its drawn items (bottomBarItems). */
241
+ export declare function bottomBarHasSearch(drawn: readonly BottomBarItem[]): boolean;
223
242
  /**
224
243
  * A count as drawn: nothing at 0, below it or while it's loading (no
225
244
  * count yet), and "99+" past 99, so a badge keeps its size.
@@ -235,6 +254,7 @@ export declare function navCountSpoken(count: number | undefined, countLabel?: s
235
254
  * A bottom bar item's count: a page's, from its nav entry, or a
236
255
  * section's, the sum of its entries' and their pages'. A section's
237
256
  * `countLabel` is its entries' when they share one, and none otherwise.
257
+ * Search has none.
238
258
  */
239
259
  export declare function bottomBarCount(item: BottomBarItem, nav: readonly NavEntry[]): {
240
260
  count?: number;
@@ -164,6 +164,15 @@ export function trailBackTarget(nav, pathname, trail) {
164
164
  .find((crumb) => crumb.href);
165
165
  return above?.href ? { label: above.label, to: above.href } : fromNav;
166
166
  }
167
+ /**
168
+ * The bar's items that are drawn: Search only when the shell has it, so
169
+ * without it an item after it takes its place, and a bar of Search alone
170
+ * is no bar.
171
+ */
172
+ export function bottomBarItems(items, hasSearch) {
173
+ // At most five: a sixth wouldn't fit a phone's width with its label.
174
+ return (items ?? []).filter((item) => hasSearch || !('search' in item)).slice(0, 5);
175
+ }
167
176
  /**
168
177
  * Whether a bottom bar item's sheet is tiles: its own `sheet`, or else
169
178
  * its section's look (the section's `look`, or the shell's `navLook`).
@@ -205,6 +214,7 @@ export function bottomBarSection(nav, label) {
205
214
  /**
206
215
  * Which bar item holds the current page (`activeTo`, from activeNavTo):
207
216
  * the page's own link, or else the section it's in, children included.
217
+ * Never Search.
208
218
  */
209
219
  export function bottomBarCurrent(items, nav, activeTo) {
210
220
  if (activeTo === undefined)
@@ -215,6 +225,10 @@ export function bottomBarCurrent(items, nav, activeTo) {
215
225
  const group = items.findIndex((item) => 'group' in item && withChildren(bottomBarSection(nav, item.group)?.items ?? []).some((entry) => entry.to === activeTo));
216
226
  return group === -1 ? undefined : group;
217
227
  }
228
+ /** Whether the bar draws Search, of its drawn items (bottomBarItems). */
229
+ export function bottomBarHasSearch(drawn) {
230
+ return drawn.some((item) => 'search' in item);
231
+ }
218
232
  /**
219
233
  * A count as drawn: nothing at 0, below it or while it's loading (no
220
234
  * count yet), and "99+" past 99, so a badge keeps its size.
@@ -239,8 +253,11 @@ export function navCountSpoken(count, countLabel) {
239
253
  * A bottom bar item's count: a page's, from its nav entry, or a
240
254
  * section's, the sum of its entries' and their pages'. A section's
241
255
  * `countLabel` is its entries' when they share one, and none otherwise.
256
+ * Search has none.
242
257
  */
243
258
  export function bottomBarCount(item, nav) {
259
+ if ('search' in item)
260
+ return {};
244
261
  if ('to' in item) {
245
262
  const entry = navItems(nav).find((other) => other.to === item.to);
246
263
  return entry ? { count: entry.count, countLabel: entry.countLabel } : {};
@@ -63,10 +63,12 @@ export type AppShellProps = {
63
63
  /**
64
64
  * A bar of shortcuts at the bottom of a phone's screen (below the md
65
65
  * breakpoint), in thumb reach: at most five, each a page
66
- * (`{ to, label, icon }`) or a nav section by its label
66
+ * (`{ to, label, icon }`), a nav section by its label
67
67
  * (`{ group: 'Every day', icon }`, with an optional shorter `label`),
68
68
  * which opens a sheet of that section's entries (as tiles with
69
- * `sheet: 'tiles'`). The item holding the
69
+ * `sheet: 'tiles'`), or Search (`{ search: true, icon: SearchIcon }`),
70
+ * a button that opens `search`'s palette, drawn only with `search` and
71
+ * in place of the header's button on a phone. The item holding the
70
72
  * current page is marked. The header's menu button stays, for
71
73
  * everything, except on a page below a nav entry, where the back arrow
72
74
  * takes its place. The shell pads its content so nothing sits under the bar.
@@ -86,8 +88,8 @@ export type AppShellProps = {
86
88
  navLook?: NavLook;
87
89
  /**
88
90
  * Search in the header: a box ("Search", or `placeholder`) from
89
- * md up and a button on a phone, both opening a palette (Ctrl K, ⌘K on
90
- * a Mac) that finds the nav's pages by name and, with `findRecords`,
91
+ * md up and a button on a phone (the bottom bar's Search instead, where
92
+ * `bottomBar` has it), both opening a palette (Ctrl K, ⌘K on a Mac) that finds the nav's pages by name and, with `findRecords`,
91
93
  * the app's records, listed under their kinds; Enter opens the one
92
94
  * highlighted. Before you type it lists the records opened lately
93
95
  * (`useRecentRecord`), `recent` of them. No search, no box.
@@ -1,11 +1,11 @@
1
1
  import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { ChevronLeftIcon, ChevronRightIcon, LogOutIcon, MoonIcon, PaletteIcon, Rows3Icon, SunIcon } from 'lucide-react';
3
3
  import { useTheme } from 'next-themes';
4
- import { useCallback, useEffect, useId, useMemo, useState } from 'react';
4
+ import { useCallback, useEffect, useId, useMemo, useRef, useState } from 'react';
5
5
  import { Link, Navigate, Outlet, useLocation } from 'react-router';
6
6
  import { useAuth } from '../../auth/use-auth.js';
7
7
  import { BottomBar, BOTTOM_BAR_PADDING } from './app-shell-bottom-bar.js';
8
- import { activeNavTo, childItems, childRuns, childrenOpen, isNavItemGroup, navCountSpoken, navCountText, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
8
+ import { activeNavTo, bottomBarHasSearch, bottomBarItems, childItems, childRuns, childrenOpen, isNavItemGroup, navCountSpoken, navCountText, navGroups, navPageLabel, navTooltip, navTrail, trailBackTarget, withChildren, } from './app-shell-nav.js';
9
9
  import { versionHref, versionLabel } from './app-shell-version.js';
10
10
  import { ErrorState } from './error-state.js';
11
11
  import { PageTrail } from './page-trail.js';
@@ -233,6 +233,8 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
233
233
  const [pageTrail, setPageTrail] = useState(null);
234
234
  const set = useCallback((owner, crumbs) => setPageTrail({ owner, crumbs }), []);
235
235
  const clear = useCallback((owner) => setPageTrail((current) => (current?.owner === owner ? null : current)), []);
236
+ // The header's palette, for the bottom bar's Search.
237
+ const paletteRef = useRef(null);
236
238
  const trailSlot = useMemo(() => ({ set, clear }), [set, clear]);
237
239
  if (status === 'loading') {
238
240
  return _jsx(AppShellSkeleton, {});
@@ -254,6 +256,8 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
254
256
  return _jsx(Navigate, { to: "/login", replace: true, state: isLoggingOut ? undefined : { from } });
255
257
  }
256
258
  const activeTo = activeNavTo(nav, location.pathname);
259
+ const barItems = bottomBarItems(bottomBar, search !== undefined);
260
+ const hasBar = barItems.length > 0;
257
261
  const ownTrail = pageTrail?.crumbs ?? null;
258
262
  const back = trailBackTarget(nav, location.pathname, ownTrail);
259
263
  const trail = ownTrail ?? navTrail(nav, location.pathname);
@@ -268,5 +272,5 @@ export function AppShell({ title, logo: Logo, nav, sidebarExtra, defaultSidebarO
268
272
  // (AuthProvider), so this stays a deliberate logout: a
269
273
  // clean /login, never the previous user's page as `from`.
270
274
  logout().catch(() => { });
271
- }, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && bottomBar?.length && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { search: search, nav: nav }), _jsx(LookControl, {})] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', bottomBar?.length && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), bottomBar && bottomBar.length > 0 && _jsx(BottomBar, { items: bottomBar, nav: nav, activeTo: activeTo, navLook: navLook })] }), _jsx(Toaster, {})] }));
275
+ }, children: _jsx(LogOutIcon, {}) })] })] })] }) }), _jsx(PageTrailContext.Provider, { value: trailSlot, children: _jsxs("div", { "data-slot": "app-shell-column", className: "flex w-full min-w-0 flex-1 flex-col bg-background", children: [_jsxs("header", { className: "flex h-14 shrink-0 items-center gap-2 border-b border-border px-4", children: [back && _jsx(PhoneBack, { back: back }), _jsx(SidebarTrigger, { className: cn(back && hasBar && 'max-md:hidden') }), _jsx("div", { "data-slot": "app-shell-trail", className: "min-w-0 flex-1", children: trail.length > 0 && _jsx(PageTrail, { crumbs: trail, "aria-label": "You are here", className: "max-md:hidden" }) }), search && _jsx(SearchPalette, { ref: paletteRef, search: search, nav: nav, onBar: bottomBarHasSearch(barItems) }), _jsx(LookControl, {})] }), _jsx(OfflineNotice, {}), _jsx(SidebarInset, { className: "min-w-0", children: _jsx("div", { className: cn('flex-1 p-6', hasBar && BOTTOM_BAR_PADDING), children: _jsx(Outlet, {}) }) })] }) }), hasBar && (_jsx(BottomBar, { items: barItems, nav: nav, activeTo: activeTo, navLook: navLook, onSearch: (opener) => paletteRef.current?.openFrom(opener) }))] }), _jsx(Toaster, {})] }));
272
276
  }
@@ -291,7 +291,7 @@ const STICKY_RULE_CLASS = 'shadow-[inset_0_-1px_0_0_var(--border)]';
291
291
  const STICKY_HEAD_CELL_CLASS = `sticky top-(--data-table-pin-top) z-30 bg-background ${STICKY_RULE_CLASS}`;
292
292
  const STICKY_GROUP_HEADING_CLASS = `sticky top-[calc(var(--data-table-pin-top)+var(--data-table-head-height))] z-20 pt-2 ${STICKY_RULE_CLASS}`;
293
293
  // What focus scrolls to clears the stuck header and heading (3rem covers a
294
- // heading's height, large density included).
294
+ // heading's height, the large densities included).
295
295
  const STICKY_FOCUS_CLASS = '[&_tbody_*]:scroll-mt-[calc(var(--data-table-pin-top)+var(--data-table-head-height)+--spacing(12))]';
296
296
  // A grouping's heading (`groupings`) is a button that folds its rows: the
297
297
  // label, then the count, a chevron that turns when folded.
@@ -224,7 +224,7 @@ export type EntityViewProps = {
224
224
  * The facts rail (record standard A1), in the `tabs` layout:
225
225
  * where the view has room (60rem beside it: a laptop's page, a record
226
226
  * dialog), the sections of short facts (`facts`, placed `rail`, no
227
- * `tab`) go in a 300px column beside the record's body, and leave
227
+ * `tab`) go in a column (300px, `--facts-rail-width`) beside the record's body, and leave
228
228
  * Details. The strip stays above, full width; the rail starts level with
229
229
  * the first content under it (the open tab's first section, or the first
230
230
  * card when cards come before the tabs). A Details tab left with
@@ -203,19 +203,20 @@ 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. The strip stays above both, at
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
207
208
  // full width; the rail starts level with the first content under it: the
208
209
  // first section of the open tab (beside the tab's content, never its bar),
209
210
  // or the first card when the record's first content isn't the tabs.
210
211
  const FACTS_RAIL = {
211
212
  // Page width wide (data-width="wide" on <html>): no cap, the column fills the page.
212
- page: 'max-w-[calc(var(--container-4xl)+var(--spacing)*6+300px)] page-wide:max-w-none',
213
- columns: 'grid grid-cols-[minmax(0,1fr)_300px] items-start gap-6',
213
+ page: 'max-w-[calc(var(--container-4xl)+var(--spacing)*6+var(--facts-rail-width))] page-wide:max-w-none',
214
+ columns: 'grid grid-cols-[minmax(0,1fr)_var(--facts-rail-width)] items-start gap-6',
214
215
  main: 'flex min-w-0 flex-col gap-6',
215
216
  rail: 'col-start-2 row-start-1 flex min-w-0 flex-col gap-6',
216
- // The tab bar over the column only: the rail's 300px and the gap (the
217
+ // The tab bar over the column only: the rail's width and the gap (the
217
218
  // bar's own -mx-1 bleed kept on its left).
218
- barBeside: 'mr-[calc(300px+var(--spacing)*5)]',
219
+ barBeside: 'mr-[calc(var(--facts-rail-width)+var(--spacing)*5)]',
219
220
  };
220
221
  /** A section of short facts placed `rail` with no tab: the facts rail's, where it's drawn. */
221
222
  function isRailFacts(section) {
@@ -1,3 +1,4 @@
1
+ import { type Ref } from 'react';
1
2
  import type { NavEntry } from './app-shell-nav.js';
2
3
  import { type SearchRecord } from '../../lib/search-palette.js';
3
4
  export type { RecentRecord, SearchRecord } from '../../lib/search-palette.js';
@@ -22,8 +23,18 @@ export type AppShellSearch = {
22
23
  */
23
24
  recent?: number | false;
24
25
  };
25
- /** The box (md and up) and the button (a phone) that open the palette, and the palette. */
26
- export declare function SearchPalette({ search, nav }: {
26
+ /** Opens the palette for a button elsewhere in the shell, where focus returns when it closes. */
27
+ export type SearchPaletteHandle = {
28
+ openFrom: (opener: HTMLElement) => void;
29
+ };
30
+ /**
31
+ * The header's box (md and up) and button (a phone, unless the bottom bar
32
+ * has Search: `onBar`) that open the palette, and the palette.
33
+ */
34
+ export declare function SearchPalette({ search, nav, onBar, ref, }: {
27
35
  search: AppShellSearch;
28
36
  nav: readonly NavEntry[];
37
+ /** The bottom bar draws Search, so the header's phone button isn't drawn. */
38
+ onBar: boolean;
39
+ ref?: Ref<SearchPaletteHandle>;
29
40
  }): import("react").JSX.Element;
@@ -1,8 +1,9 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
- // Search in AppShell's bar: a box in the header (a button on a
3
- // phone) and Ctrl K (⌘K on a Mac) open a palette that finds a page or a
4
- // record by name, and Enter opens it. Before you type it lists the
5
- // records you opened lately (useRecentRecord), then the first pages.
2
+ // Search in AppShell's bar: a box in the header (on a phone a button
3
+ // there, or the bottom bar's Search in its place) and Ctrl K (⌘K on a Mac)
4
+ // open a palette that finds a page or a record by name, and Enter opens
5
+ // it. Before you type it lists the records you opened lately
6
+ // (useRecentRecord), then the first pages.
6
7
  //
7
8
  // A combobox over a listbox in a dialog (WAI-ARIA's "combobox with
8
9
  // listbox popup"): focus stays in the box, the arrows move the
@@ -10,7 +11,7 @@ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-run
10
11
  // closes. Hand-rolled because shadcn's Command needs cmdk, which isn't
11
12
  // on the package's allowlist; the dialog is the foundation's own.
12
13
  import { SearchIcon } from 'lucide-react';
13
- import { useEffect, useId, useMemo, useRef, useState } from 'react';
14
+ import { useEffect, useId, useImperativeHandle, useMemo, useRef, useState } from 'react';
14
15
  import { useNavigate } from 'react-router';
15
16
  import { cn } from 'cn';
16
17
  import { useDebouncedValue } from '../../hooks/use-debounced-value.js';
@@ -24,9 +25,33 @@ const PAGES_MATCHED = 6;
24
25
  function isMac() {
25
26
  return typeof navigator !== 'undefined' && /Mac|iPhone|iPad/.test(navigator.platform || navigator.userAgent);
26
27
  }
27
- /** The box (md and up) and the button (a phone) that open the palette, and the palette. */
28
- export function SearchPalette({ search, nav }) {
29
- const [open, setOpen] = useState(false);
28
+ const CLOSED = { open: false, opener: null };
29
+ // What opens the palette: the header's box, its phone button, and the
30
+ // bottom bar's Search (app-shell-bottom-bar.tsx). One is shown at a width.
31
+ const OPENERS = '[data-slot="app-shell-search"], [data-slot="app-shell-search-button"], [data-slot="bottom-bar-search"]';
32
+ const isShown = (element) => element.getClientRects().length > 0;
33
+ // Where focus goes as the palette closes: what opened it, or where that is
34
+ // hidden now (the window was resized across md meanwhile), the one shown
35
+ // in its place. `true` is the dialog's own default.
36
+ function focusAfter(opener) {
37
+ if (!opener?.isConnected)
38
+ return true;
39
+ if (isShown(opener))
40
+ return opener;
41
+ return [...document.querySelectorAll(OPENERS)].find(isShown) ?? true;
42
+ }
43
+ /**
44
+ * The header's box (md and up) and button (a phone, unless the bottom bar
45
+ * has Search: `onBar`) that open the palette, and the palette.
46
+ */
47
+ export function SearchPalette({ search, nav, onBar, ref, }) {
48
+ // `opener` is the button pressed, or for Ctrl K what had focus (null for
49
+ // nothing). Focus goes back to a pressed button itself: a tap doesn't
50
+ // focus one in every browser, so what had focus can't be relied on.
51
+ const [{ open, opener }, setState] = useState(CLOSED);
52
+ const openFrom = (from) => setState({ open: true, opener: from });
53
+ const close = () => setState(CLOSED);
54
+ useImperativeHandle(ref, () => ({ openFrom: (from) => setState({ open: true, opener: from }) }), []);
30
55
  const placeholder = search.placeholder ?? 'Search';
31
56
  const shortcut = isMac() ? '⌘K' : 'Ctrl K';
32
57
  // Ctrl K or ⌘K from anywhere, unless something on the page (an
@@ -38,14 +63,16 @@ export function SearchPalette({ search, nav }) {
38
63
  if (event.key.toLowerCase() !== 'k' || !(event.ctrlKey || event.metaKey))
39
64
  return;
40
65
  event.preventDefault();
41
- setOpen((current) => !current);
66
+ const focused = document.activeElement;
67
+ const from = focused instanceof HTMLElement && focused !== document.body ? focused : null;
68
+ setState((current) => (current.open ? CLOSED : { open: true, opener: from }));
42
69
  };
43
70
  window.addEventListener('keydown', onKeyDown);
44
71
  return () => window.removeEventListener('keydown', onKeyDown);
45
72
  }, []);
46
- return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", "data-slot": "app-shell-search", "aria-keyshortcuts": "Control+K Meta+K", "aria-haspopup": "dialog", onClick: () => setOpen(true), className: "hidden h-8 w-56 shrink-0 items-center gap-2 rounded-lg border border-input bg-background px-2.5 text-sm text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 md:flex lg:w-64", children: [_jsx(SearchIcon, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: placeholder }), _jsx("kbd", { className: "shrink-0 rounded-sm border border-border px-1 font-mono text-xs text-muted-foreground", children: shortcut })] }), _jsx(Button, { variant: "ghost", size: "icon-sm", "data-slot": "app-shell-search-button", "aria-label": placeholder, "aria-haspopup": "dialog", className: "md:hidden", onClick: () => setOpen(true), children: _jsx(SearchIcon, {}) }), _jsx(Dialog, { open: open, onOpenChange: setOpen, children: open && _jsx(Palette, { search: search, nav: nav, placeholder: placeholder, onClose: () => setOpen(false) }) })] }));
73
+ return (_jsxs(_Fragment, { children: [_jsxs("button", { type: "button", "data-slot": "app-shell-search", "aria-keyshortcuts": "Control+K Meta+K", "aria-haspopup": "dialog", onClick: (event) => openFrom(event.currentTarget), className: "hidden h-8 w-56 shrink-0 items-center gap-2 rounded-lg border border-input bg-background px-2.5 text-sm text-muted-foreground transition-colors outline-none hover:bg-muted hover:text-foreground focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 md:flex lg:w-64", children: [_jsx(SearchIcon, { "aria-hidden": "true", className: "size-4 shrink-0" }), _jsx("span", { className: "min-w-0 flex-1 truncate text-left", children: placeholder }), _jsx("kbd", { className: "shrink-0 rounded-sm border border-border px-1 font-mono text-xs text-muted-foreground", children: shortcut })] }), !onBar && (_jsx(Button, { variant: "ghost", size: "icon-sm", "data-slot": "app-shell-search-button", "aria-label": placeholder, "aria-haspopup": "dialog", className: "md:hidden", onClick: (event) => openFrom(event.currentTarget), children: _jsx(SearchIcon, {}) })), _jsx(Dialog, { open: open, onOpenChange: (next) => !next && close(), children: open && _jsx(Palette, { search: search, nav: nav, placeholder: placeholder, opener: opener, onClose: close }) })] }));
47
74
  }
48
- function Palette({ search, nav, placeholder, onClose, }) {
75
+ function Palette({ search, nav, placeholder, opener, onClose, }) {
49
76
  const navigate = useNavigate();
50
77
  const id = useId();
51
78
  const listId = `${id}-list`;
@@ -142,7 +169,7 @@ function Palette({ search, nav, placeholder, onClose, }) {
142
169
  }
143
170
  };
144
171
  const nothing = text && options.length === 0 && records?.status !== 'loading';
145
- return (_jsxs(DialogContent, { showCloseButton: false, "data-slot": "search-palette", className: "top-[12vh] max-h-[76vh] translate-y-0 grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden p-0 sm:max-w-lg", children: [_jsx(DialogTitle, { className: "sr-only", children: placeholder }), _jsx(DialogDescription, { className: "sr-only", children: "Type a page or a record's name; the arrows move through what's found and Enter opens it." }), _jsxs("div", { className: "flex items-center gap-2 border-b border-border px-3", children: [_jsx(SearchIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("input", { role: "combobox", "aria-label": placeholder, "aria-expanded": options.length > 0, "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": activeOption?.id, autoComplete: "off", spellCheck: false, value: query, placeholder: "Go to a page or find a record\u2026", onChange: (event) => {
172
+ return (_jsxs(DialogContent, { showCloseButton: false, finalFocus: () => focusAfter(opener), "data-slot": "search-palette", className: "top-[12vh] max-h-[76vh] translate-y-0 grid-rows-[auto_minmax(0,1fr)] gap-0 overflow-hidden p-0 sm:max-w-lg", children: [_jsx(DialogTitle, { className: "sr-only", children: placeholder }), _jsx(DialogDescription, { className: "sr-only", children: "Type a page or a record's name; the arrows move through what's found and Enter opens it." }), _jsxs("div", { className: "flex items-center gap-2 border-b border-border px-3", children: [_jsx(SearchIcon, { "aria-hidden": "true", className: "size-4 shrink-0 text-muted-foreground" }), _jsx("input", { role: "combobox", "aria-label": placeholder, "aria-expanded": options.length > 0, "aria-controls": listId, "aria-autocomplete": "list", "aria-activedescendant": activeOption?.id, autoComplete: "off", spellCheck: false, value: query, placeholder: "Go to a page or find a record\u2026", onChange: (event) => {
146
173
  setQuery(event.target.value);
147
174
  setActive(0);
148
175
  }, onKeyDown: onKeyDown, className: "h-11 min-w-0 flex-1 bg-transparent text-base outline-none placeholder:text-muted-foreground md:text-sm" }), records?.status === 'loading' && _jsx(Spinner, { "aria-label": "Searching", className: "size-4 text-muted-foreground" })] }), _jsxs("div", { className: "min-h-0 overflow-y-auto p-1", children: [_jsx("div", { role: "listbox", id: listId, "aria-label": placeholder, children: groups.map((group, groupIndex) => (_jsxs("div", { role: "group", "aria-labelledby": `${id}-group-${groupIndex}`, children: [_jsx("div", { id: `${id}-group-${groupIndex}`, className: "px-2 pt-2 pb-1 type-caption text-muted-foreground", children: group.heading }), group.options.map((option) => {
@@ -15,9 +15,9 @@ import { PanelLeftIcon } from "lucide-react";
15
15
  const SIDEBAR_COOKIE_NAME = "sidebar_state";
16
16
  const SIDEBAR_COOKIE_MAX_AGE = 60 * 60 * 24 * 7;
17
17
  // This repo's patch: the widths are steps of Tailwind's spacing scale, not
18
- // rem literals (upstream's 16rem, 18rem, 3rem), so data-density="large"
19
- // widens the sidebar with everything in it and the icon rail still fits
20
- // its buttons (styles/theme.css). Diff against upstream before taking a
18
+ // rem literals (upstream's 16rem, 18rem, 3rem), so data-density="large" (and
19
+ // "extra-large") widens the sidebar with everything in it and the icon rail
20
+ // still fits its buttons (styles/theme.css). Diff against upstream before taking a
21
21
  // new version of this file.
22
22
  const SIDEBAR_WIDTH = "calc(var(--spacing) * 64)";
23
23
  const SIDEBAR_WIDTH_MOBILE = "calc(var(--spacing) * 72)";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.138.0",
3
+ "version": "4.140.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/index.css CHANGED
@@ -30,8 +30,8 @@
30
30
 
31
31
  /* Page width: data-width="wide" on <html> (an app's own setting,
32
32
  kept per browser as Text Size's data-density is) lifts a record page's
33
- reading cap, so its column fills a wide screen; the facts rail stays
34
- 300px. A record in a dialog keeps the dialog's size. `page-wide:max-w-none`. */
33
+ reading cap, so its column fills a wide screen; the facts rail keeps
34
+ its width. A record in a dialog keeps the dialog's size. `page-wide:max-w-none`. */
35
35
  @custom-variant page-wide (&:where([data-width="wide"] *):not(:where([role="dialog"] *, [role="alertdialog"] *)));
36
36
 
37
37
  @theme inline {
@@ -641,7 +641,8 @@
641
641
  --control-height (Input, SelectTrigger, InputGroup, the combobox's chips
642
642
  box and a default Button), 32px, or 40px under 48rem or on a touch
643
643
  screen, for the finger. Anywhere else they keep their 36px. Each is a
644
- calc of --spacing, resolved here, so the large density grows it. */
644
+ calc of --spacing, resolved here, so the large and extra-large densities
645
+ grow it. */
645
646
  [data-slot="field-group"],
646
647
  [data-slot="entity-form-bar"],
647
648
  [data-slot="form-dialog-bar"] {
package/styles/theme.css CHANGED
@@ -616,9 +616,13 @@
616
616
 
617
617
  /* The small size of Button and Toggle (and the calendar's weekdays):
618
618
  between text-xs and text-sm, so it has a token of its own for the
619
- large density to scale. */
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. */
624
+ --facts-rail-width: 300px;
625
+
622
626
  /* Layer 2 — semantic (light) */
623
627
  --background: var(--white);
624
628
  --foreground: var(--black);
@@ -908,7 +912,7 @@
908
912
  * built from --spacing on :root would keep :root's value under here.
909
913
  *
910
914
  * Popups (menus, selects, dialogs, tooltips) are portaled to <body>, so
911
- * they only grow when data-density="large" is on <html>.
915
+ * they only grow when data-density="large" (or "extra-large") is on <html>.
912
916
  */
913
917
  [data-density="large"] {
914
918
  --spacing: 0.3125rem; /* 4px → 5px: h-8 is 40px, size-4 is 20px */
@@ -941,6 +945,52 @@
941
945
  --table-cell-px: 0.75rem;
942
946
  --table-cell-py: 0.75rem;
943
947
  --table-head-height: 3.5rem;
948
+
949
+ --facts-rail-width: 300px; /* the default's: its rows still fit side by side */
950
+ }
951
+
952
+ /*
953
+ * Extra large: the step after large, for a screen read from further back
954
+ * (a couch). It sets every token large sets, the same way and for the same
955
+ * reasons; tests/density.test.ts fails if one is set in only one of them.
956
+ * Body text is 20px where large's is 18px, captions 17px where they're
957
+ * 15px, spacing 5.6px where it's 5px. Every other size is large's scaled by
958
+ * the nearest of those (text and its leading by body's 10/9, caption-sized
959
+ * text by captions' 17/15, boxes by spacing's 1.12), to the nearest pixel.
960
+ */
961
+ [data-density="extra-large"] {
962
+ --spacing: 0.35rem; /* large's 5px → 5.6px: h-8 is 44.8px, size-4 is 22.4px */
963
+ --text-xs: 1.0625rem; /* 15 → 17px */
964
+ --text-sm: 1.25rem; /* 18 → 20px: most UI text */
965
+ --text-base: 1.375rem; /* 20 → 22px */
966
+ --text-lg: 1.5rem; /* 22 → 24px */
967
+ --text-xl: 1.75rem; /* 25 → 28px */
968
+ --text-2xl: 2.0625rem; /* 30 → 33px */
969
+ --control-text-sm: 1.125rem; /* 16 → 18px */
970
+ --radius: 0.75rem; /* 11 → 12px */
971
+
972
+ --type-page-title-size: 2.4375rem; /* 35 → 39px */
973
+ --type-section-title-size: 1.375rem;
974
+ --type-section-title-leading: 2.0625rem;
975
+ --type-body-size: 1.25rem;
976
+ --type-label-size: 1.25rem;
977
+ --type-label-leading: 1.8125rem;
978
+ --type-caption-size: 1.0625rem;
979
+ --type-caption-leading: 1.4375rem;
980
+ --type-numeric-size: 1.9375rem;
981
+ --type-numeric-leading: 2.5rem;
982
+ --type-heading-1-size: 2.4375rem;
983
+ --type-heading-1-leading: 3.125rem;
984
+ --type-heading-2-size: 1.75rem;
985
+ --type-heading-2-leading: 2.375rem;
986
+ --type-heading-3-size: 1.0625rem;
987
+ --type-heading-3-leading: 1.75rem;
988
+
989
+ --table-cell-px: 0.8125rem;
990
+ --table-cell-py: 0.8125rem;
991
+ --table-head-height: 3.9375rem;
992
+
993
+ --facts-rail-width: 336px; /* 300px, so a label still fits beside its value */
944
994
  }
945
995
 
946
996
  .dark {