@tristan2828/ui-foundation 4.107.0 → 4.109.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -15,18 +15,18 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 755–832
16
16
  - Step 9: Register the nav entry and route names · lines 833–847
17
17
  - Step 10: `npm run verify`. · lines 848–850
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1249
19
- - [The record view](#the-record-view) · lines 1005–1099
20
- - [Forms](#forms) · lines 1101–1166
21
- - [Dialogs](#dialogs) · lines 1168–1199
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1201–1249
23
- - [What not to copy](#what-not-to-copy) · lines 1251–1283
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1285–1302
25
- - [Deleting](#deleting) · lines 1304–1335
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1337–1358
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1360–1369
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1372–1414
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1416–1452
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1257
19
+ - [The record view](#the-record-view) · lines 1005–1102
20
+ - [Forms](#forms) · lines 1104–1174
21
+ - [Dialogs](#dialogs) · lines 1176–1207
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1209–1257
23
+ - [What not to copy](#what-not-to-copy) · lines 1259–1291
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1293–1310
25
+ - [Deleting](#deleting) · lines 1312–1343
26
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1345–1366
27
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1368–1377
28
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1380–1422
29
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1424–1460
30
30
 
31
31
  <!-- /index -->
32
32
 
@@ -1046,9 +1046,12 @@ A record uses the parts it has, in this order:
1046
1046
  4.81), so the short facts read as a list of pairs rather than a column
1047
1047
  of labels; keep labels to a word or two.
1048
1048
  - **The facts rail** (4.106, record standard A1): `factsRail` on the
1049
- view puts the record's short facts in a 300px column beside the strip
1050
- and the tabs where the view has room (60rem: a laptop's page, a record
1051
- dialog), so the page doesn't end 900px in. Only short values go in it,
1049
+ view puts the record's short facts in a 300px column beside the
1050
+ record's body where the view has room (60rem: a laptop's page, a record
1051
+ dialog), so the page doesn't end 900px in. The strip stays above it at
1052
+ full width, and the rail starts level with the first content under the
1053
+ strip: the open tab's first section (beside the tab's content, not its
1054
+ bar), or the first card when cards come before the tabs (4.108). Only short values go in it,
1052
1055
  and the API holds to that: a rail section is `facts`, not `fields`,
1053
1056
  each fact one of a few kinds, never free markup:
1054
1057
 
@@ -1140,6 +1143,11 @@ shape (4.85):
1140
1143
  in its colour before the word, the same as the record's `StatusMark`
1141
1144
  (`icon` overrides the kind's icon; an `icon` with no `kind` stays
1142
1145
  uncoloured). Map the enum to kinds once and use that map for both.
1146
+ A status of five or more is an `OptionSelect` with the same `kind` on
1147
+ each option (4.109): the kind's icon in its colour before the words, on
1148
+ the trigger and on each item in its list (`inPlace.select` passes them
1149
+ through). With `kind`, leave out a `render` that draws its own icon
1150
+ (a `StatusMark`), or the option shows two.
1143
1151
  - **The controls** (4.88): a choice of two to four short options is
1144
1152
  `ChoiceButtons` (`inPlace.choice` in place), five or more an
1145
1153
  `OptionSelect`. A date is `DateField`, typed ("3/14", "Mar 14",
@@ -1,5 +1,5 @@
1
1
  import type { ReactNode } from 'react';
2
- import { type StatusKind } from '../../lib/status-kinds.js';
2
+ import type { StatusKind } from '../../lib/status-kinds.js';
3
3
  import type { IconComponent } from './icon-component.js';
4
4
  export type ChoiceButtonsOption<T> = {
5
5
  value: T;
@@ -1,7 +1,7 @@
1
1
  import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from 'cn';
3
3
  import { ToggleGroup, ToggleGroupItem } from '../ui/toggle-group.js';
4
- import { STATUS_KIND_ICONS, STATUS_KIND_TONES } from '../../lib/status-kinds.js';
4
+ import { OptionIcon } from './option-icon.js';
5
5
  export function ChoiceButtons({ id, options, value, onValueChange, render, clearable = false, invalid = false, disabled = false, className, ...aria }) {
6
6
  const at = value == null ? -1 : options.findIndex((option) => option.value === value);
7
7
  return (_jsx(ToggleGroup, { id: id, "data-slot": "choice-buttons", variant: "outline", spacing: 0, value: at === -1 ? [] : [String(at)], onValueChange: (next) => {
@@ -22,11 +22,5 @@ export function ChoiceButtons({ id, options, value, onValueChange, render, clear
22
22
  '-ml-px border-l! h-(--control-height,--spacing(8)) max-w-full px-3 font-normal text-muted-foreground',
23
23
  // Picked: the theme colour. On top of the ones before and
24
24
  // after it (`z-1`), so its whole border shows where they overlap.
25
- 'aria-pressed:z-1 aria-pressed:border-primary aria-pressed:bg-primary/12 aria-pressed:font-medium aria-pressed:text-primary-text hover:aria-pressed:bg-primary/16 hover:aria-pressed:text-primary-text', invalid && 'border-destructive'), children: [_jsx(OptionIcon, { option: option }), render ? render(option.value, option.label) : option.label] }, String(option.value)))) }));
26
- }
27
- function OptionIcon({ option }) {
28
- const Icon = option.icon ?? (option.kind ? STATUS_KIND_ICONS[option.kind] : undefined);
29
- if (!Icon)
30
- return null;
31
- return (_jsx(Icon, { "aria-hidden": "true", "data-slot": "choice-buttons-icon", "data-kind": option.kind, className: cn('size-3.5 shrink-0', option.kind && STATUS_KIND_TONES[option.kind]) }));
25
+ 'aria-pressed:z-1 aria-pressed:border-primary aria-pressed:bg-primary/12 aria-pressed:font-medium aria-pressed:text-primary-text hover:aria-pressed:bg-primary/16 hover:aria-pressed:text-primary-text', invalid && 'border-destructive'), children: [_jsx(OptionIcon, { kind: option.kind, icon: option.icon, slot: "choice-buttons-icon" }), render ? render(option.value, option.label) : option.label] }, String(option.value)))) }));
32
26
  }
@@ -99,7 +99,7 @@ export type InPlaceRecurrenceConfig<TRequired extends boolean = boolean> = {
99
99
  };
100
100
  /**
101
101
  * One option of a select: its value and its words. `kind` and `icon`
102
- * (4.105) are ChoiceButtons': drawn by `look: 'buttons'` only.
102
+ * (4.105) are ChoiceButtons': drawn by both looks (the select's since 4.109).
103
103
  */
104
104
  export type InPlaceOption<T> = ChoiceButtonsOption<T>;
105
105
  /**
@@ -224,9 +224,11 @@ export type EntityViewProps = {
224
224
  * The facts rail (4.106, 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 strip and the tabs, and leave
228
- * Details; a Details tab left with nothing isn't drawn. Narrower (a
229
- * phone), they're in Details as before. Sections with `fields` or
227
+ * `tab`) go in a 300px column beside the record's body, and leave
228
+ * Details. The strip stays above, full width; the rail starts level with
229
+ * the first content under it (the open tab's first section, or the first
230
+ * card when cards come before the tabs; 4.108). A Details tab left with
231
+ * nothing isn't drawn. Narrower (a phone), they're in Details as before. Sections with `fields` or
230
232
  * `content` never go in it: a rail holds short values only.
231
233
  */
232
234
  factsRail?: boolean;
@@ -186,12 +186,18 @@ const RAIL_LAYOUT = {
186
186
  sticky: '@4xl/view:data-[fits]:sticky @4xl/view:data-[fits]:top-6',
187
187
  };
188
188
  // The facts rail (A1): the record's column at its usual reading width
189
- // (max-w-4xl) and a 300px rail beside it, top-aligned with the strip.
189
+ // (max-w-4xl) and a 300px rail beside it. The strip stays above both, at
190
+ // full width; the rail starts level with the first content under it: the
191
+ // first section of the open tab (beside the tab's content, never its bar),
192
+ // or the first card when the record's first content isn't the tabs (4.108).
190
193
  const FACTS_RAIL = {
191
194
  page: 'max-w-[calc(var(--container-4xl)+var(--spacing)*6+300px)]',
192
195
  columns: 'grid grid-cols-[minmax(0,1fr)_300px] items-start gap-6',
193
196
  main: 'flex min-w-0 flex-col gap-6',
194
- rail: 'flex min-w-0 flex-col gap-6',
197
+ rail: 'col-start-2 row-start-1 flex min-w-0 flex-col gap-6',
198
+ // The tab bar over the column only: the rail's 300px and the gap (the
199
+ // bar's own -mx-1 bleed kept on its left).
200
+ barBeside: 'mr-[calc(300px+var(--spacing)*5)]',
195
201
  };
196
202
  /** A section of short facts placed `rail` with no tab: the facts rail's, where it's drawn. */
197
203
  function isRailFacts(section) {
@@ -302,7 +308,7 @@ function useStuck() {
302
308
  }, [marker, bar]);
303
309
  return { setMarker, setBar, stuck };
304
310
  }
305
- function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop, }) {
311
+ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop, aside, }) {
306
312
  const { setMarker, setBar, stuck } = useStuck();
307
313
  const countOf = (tab) => {
308
314
  if (!counts)
@@ -323,13 +329,16 @@ function MainTabs({ tabs, label, railFields = 'beside', title, counts, stickyTop
323
329
  const search = params.toString();
324
330
  void navigate({ pathname: location.pathname, search: search ? `?${search}` : '', hash: location.hash }, { replace: true, state: location.state, preventScrollReset: true });
325
331
  };
332
+ // Kept mounted, the closed tabs are hidden (no box), so beside the rail
333
+ // only the open one takes the first column.
334
+ const panels = tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: cn('@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]', aside !== undefined && 'col-start-1 row-start-1'), children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)));
326
335
  return (_jsxs(Tabs, { value: selected, onValueChange: (value) => select(String(value)), "data-slot": "entity-view-tabs", className: "min-w-0 gap-6", children: [_jsx("div", { ref: setMarker, "aria-hidden": "true", "data-slot": "entity-view-tabs-marker", className: "h-px -mb-6" }), _jsxs("div", { ref: setBar, "data-slot": "entity-view-tab-bar", "data-stuck": stuck ? '' : undefined,
327
336
  // A record dialog's body sets --entity-view-sticky-top to minus its
328
337
  // padding, so the bar sits at the body's own top edge there.
329
- style: { top: stickyTop ?? 'var(--entity-view-sticky-top, 0px)' }, className: "sticky z-10 -mx-1 flex min-w-0 flex-col gap-1 bg-background px-1 pt-0 data-[stuck]:pt-2 data-[stuck]:shadow-[0_8px_12px_-10px_var(--color-foreground)]", children: [stuck && title && (_jsx("p", { "data-slot": "entity-view-tab-bar-title", "aria-hidden": "true", className: "truncate type-label font-semibold text-foreground", children: title })), _jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-0 overflow-x-auto overflow-y-hidden border-b border-border p-0 md:gap-1 [scrollbar-width:thin]", children: tabs.map((tab) => {
338
+ style: { top: stickyTop ?? 'var(--entity-view-sticky-top, 0px)' }, className: cn('sticky z-10 -mx-1 flex min-w-0 flex-col gap-1 bg-background px-1 pt-0 data-[stuck]:pt-2 data-[stuck]:shadow-[0_8px_12px_-10px_var(--color-foreground)]', aside !== undefined && FACTS_RAIL.barBeside), children: [stuck && title && (_jsx("p", { "data-slot": "entity-view-tab-bar-title", "aria-hidden": "true", className: "truncate type-label font-semibold text-foreground", children: title })), _jsx(TabsList, { variant: "line", activateOnFocus: true, "aria-label": label, className: "h-auto w-full max-w-full justify-start gap-0 overflow-x-auto overflow-y-hidden border-b border-border p-0 md:gap-1 [scrollbar-width:thin]", children: tabs.map((tab) => {
330
339
  const count = countOf(tab);
331
340
  return (_jsxs(TabsTrigger, { value: tab.slug, className: "h-11 flex-none gap-1.5 px-2.5 text-sm font-semibold text-muted-foreground group-data-horizontal/tabs:after:bottom-0 group-data-horizontal/tabs:after:h-[3px] after:bg-primary data-active:text-primary-text md:px-4 md:text-base dark:text-muted-foreground dark:data-active:text-primary-text", children: [tab.name, count > 0 && (_jsx("span", { "data-slot": "entity-view-tab-count", className: "rounded-full bg-muted px-1.5 text-xs leading-[1.0625rem] font-medium tabular-nums text-foreground", children: count }))] }, tab.slug));
332
- }) })] }), tabs.map((tab) => (_jsx(TabsContent, { value: tab.slug, keepMounted: true, className: "@container/tab flex min-w-0 flex-col gap-6 [font-size:inherit]", children: _jsx(TabBody, { tab: tab, railFields: railFields }) }, tab.slug)))] }));
341
+ }) })] }), aside === undefined ? (panels) : (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [panels, aside] }))] }));
333
342
  }
334
343
  // The `tabs` layout's sections (1A): the main column's untabbed sections,
335
344
  // then the tab list, with the facts (placed `rail`, no tab) as the last
@@ -406,7 +415,11 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
406
415
  const shaped = layout === 'tabs' ? tabsLayout(railFacts.length > 0 ? sections.filter((section) => !isRailFacts(section)) : sections, detailsTab) : null;
407
416
  const tabs = shaped ? shaped.tabs : tabsOf(mainSections);
408
417
  const tabbed = (section) => section.placement !== 'rail' && section.tab !== undefined;
409
- const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop }));
418
+ const factsAside = railFacts.length > 0 && (_jsx("aside", { "aria-label": factsRailLabel ?? `${title ?? 'Record'} facts`, "data-slot": "entity-view-facts-rail", className: FACTS_RAIL.rail, children: railFacts.map((section) => (_jsx(ViewSection, { section: section, inRail: true, factsRail: true }, section.title))) }));
419
+ // The record's first content under the strip is the tab bar: the rail
420
+ // goes in the tabs, beside the open tab's content.
421
+ const factsInTabs = factsAside !== false && shaped !== null && shaped.above.length === 0 && tabs.length > 0;
422
+ const tabList = tabs.length > 0 && (_jsx(MainTabs, { tabs: tabs, label: tabsLabel, railFields: railFields, title: title, counts: tabCounts, stickyTop: tabsStickyTop, aside: factsInTabs ? factsAside : undefined }));
410
423
  const main = (_jsxs("div", { className: cn(RAIL_LAYOUT.main, railSections.length === 0 && RAIL_LAYOUT.mainAlone), children: [mainSections
411
424
  .filter((section) => !tabbed(section))
412
425
  .map((section) => (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
@@ -420,7 +433,7 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
420
433
  else if (shaped) {
421
434
  const column = (_jsxs(_Fragment, { children: [shaped.above.map((section) => section.placement === 'rail' ? (_jsx(ViewSection, { section: section, inRail: true, railFields: railFields }, section.title)) : (_jsx(ViewSection, { section: section }, section.title))), tabList] }));
422
435
  body =
423
- railFacts.length > 0 ? (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [_jsxs("div", { className: FACTS_RAIL.main, children: [strip && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), column] }), _jsx("aside", { "aria-label": factsRailLabel ?? `${title ?? 'Record'} facts`, "data-slot": "entity-view-facts-rail", className: FACTS_RAIL.rail, children: railFacts.map((section) => (_jsx(ViewSection, { section: section, inRail: true, factsRail: true }, section.title))) })] })) : (column);
436
+ factsAside !== false && !factsInTabs ? (_jsxs("div", { "data-slot": "entity-view-with-facts", className: FACTS_RAIL.columns, children: [_jsx("div", { className: cn(FACTS_RAIL.main, 'col-start-1 row-start-1'), children: column }), factsAside] })) : (column);
424
437
  }
425
438
  else {
426
439
  body = (_jsxs(_Fragment, { children: [sections
@@ -429,5 +442,5 @@ export function EntityView({ title, documentTitle, titleEdit, leading, subtitle,
429
442
  }
430
443
  return (_jsx(EditInPlaceContext.Provider, { value: store, children: _jsx(EmptyContext.Provider, { value: { text: emptyText, fold: emptyFields === 'fold' }, children: _jsxs("div", { ref: setRoot, className: layout === 'rail' && !card
431
444
  ? RAIL_LAYOUT.page
432
- : cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && 'sm:min-w-64 sm:gap-4'), children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && (!card || cardStrip) && railFacts.length === 0 && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
445
+ : cn('flex flex-col', railFacts.length > 0 ? FACTS_RAIL.page : 'max-w-4xl', card ? 'gap-4' : 'gap-6'), "data-facts-rail": railFacts.length > 0 ? '' : undefined, "data-state": "success", "data-layout": layout, "data-look": card ? 'card' : undefined, children: [editing && _jsx(LeaveGuard, { store: store }), !dialog && !trail && _jsx(BackLink, { back: back }), !dialog && trail && !inShell && _jsx(PageTrail, { crumbs: trail }), _jsxs("header", { className: card ? 'flex items-start justify-between gap-3' : 'flex flex-col gap-3 sm:flex-row sm:items-start sm:justify-between', children: [_jsxs("div", { className: cn('flex min-w-0 flex-1 items-start gap-3', !card && 'sm:min-w-64 sm:gap-4'), children: [leading && (_jsx("div", { "data-slot": "entity-view-leading", className: "flex shrink-0 items-center", children: leading })), _jsxs("div", { className: "flex min-w-0 flex-1 flex-col gap-2", children: [_jsxs("div", { "data-slot": "entity-view-title-line", className: "flex min-w-0 flex-wrap items-center gap-x-3 gap-y-2", children: [_jsx("h1", { id: dialog?.titleId, className: cn('min-w-0 max-w-full break-words text-foreground', card ? 'type-section-title' : 'type-page-title'), children: titleEdit ? (_jsx(EditableField, { label: titleEdit.label, edit: titleEdit, layout: "inline", keepPencilRoom: true, children: title })) : (title) }), badges && (_jsx("div", { "data-slot": "entity-view-badges", className: "flex flex-wrap items-center gap-1.5", children: badges }))] }), subtitle && (_jsx("div", { "data-slot": "entity-view-subtitle", className: "type-body break-words text-muted-foreground", children: subtitle }))] })] }), card ? (_jsxs("div", { "data-slot": "entity-view-card-controls", className: "flex shrink-0 items-center gap-1", children: [printButton, actions, dialog?.controls] })) : ((actions || printButton) && (_jsxs("div", { className: "flex min-w-0 flex-wrap items-center gap-2 sm:justify-end", children: [printButton, actions] })))] }), _jsx("div", { role: "status", "data-slot": "entity-view-notice", className: "empty:hidden", children: notice }), strip && (!card || cardStrip) && _jsx("div", { "data-slot": "entity-view-strip", children: strip }), body, footer && (_jsx("footer", { "data-slot": "entity-view-footer", className: "type-caption text-muted-foreground", children: footer }))] }) }) }));
433
446
  }
@@ -9,10 +9,16 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
9
9
  // Values are the wire's enum strings; `getLabel` names them when those
10
10
  // aren't fit to show (`quick_win` → "Quick win"). Chips, options and the
11
11
  // typed-text match all use the label, and the value is what's emitted.
12
+ //
13
+ // A toolbar filter's summary ("Status: Active +1", `label`) keeps the
14
+ // control one line high however narrow it is (4.109): it truncates, and
15
+ // the text box beside it takes no room until it's focused.
12
16
  import * as React from 'react';
17
+ import { cn } from 'cn';
13
18
  import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxContent, ComboboxEmpty, ComboboxItem, ComboboxList, ComboboxValue, useComboboxAnchor, } from '../ui/combobox.js';
14
19
  export function MultiChoice({ options, value, onValueChange, getLabel = String, id, placeholder, label, 'aria-label': ariaLabel, 'aria-invalid': ariaInvalid, className, }) {
15
20
  const anchor = useComboboxAnchor();
21
+ const summarised = label !== undefined && value.length > 0;
16
22
  return (_jsxs(Combobox, { multiple: true, autoHighlight: true, items: options, value: value, onValueChange: (next, details) => {
17
23
  // Base UI empties the value on Escape while the list is closed, so
18
24
  // a second Escape after a pick wiped every chip (issue #123). Escape
@@ -25,5 +31,5 @@ export function MultiChoice({ options, value, onValueChange, getLabel = String,
25
31
  return;
26
32
  }
27
33
  onValueChange(next);
28
- }, itemToStringLabel: getLabel, children: [_jsx(ComboboxChips, { ref: anchor, className: className, children: _jsx(ComboboxValue, { children: (selected) => (_jsxs(React.Fragment, { children: [label !== undefined && selected.length > 0 ? (_jsxs("span", { "data-slot": "multi-choice-summary", className: "min-w-0 truncate pl-1 type-body text-foreground", children: [label, ": ", getLabel(selected[0]), selected.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: [" +", selected.length - 1] })] })) : null, (label === undefined ? selected : []).map((option) => (_jsx(ComboboxChip, { children: getLabel(option) }, option))), _jsx(ComboboxChipsInput, { id: id, "aria-label": ariaLabel, "aria-invalid": ariaInvalid, placeholder: selected.length === 0 ? placeholder : undefined })] })) }) }), _jsxs(ComboboxContent, { anchor: anchor, children: [_jsx(ComboboxEmpty, { children: "No options found." }), _jsx(ComboboxList, { children: (option) => (_jsx(ComboboxItem, { value: option, children: getLabel(option) }, option)) })] })] }));
34
+ }, itemToStringLabel: getLabel, children: [_jsx(ComboboxChips, { ref: anchor, className: cn(summarised && 'flex-nowrap', className), children: _jsx(ComboboxValue, { children: (selected) => (_jsxs(React.Fragment, { children: [label !== undefined && selected.length > 0 ? (_jsxs("span", { "data-slot": "multi-choice-summary", className: "min-w-0 truncate pl-1 type-body text-foreground", children: [label, ": ", getLabel(selected[0]), selected.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: [" +", selected.length - 1] })] })) : null, (label === undefined ? selected : []).map((option) => (_jsx(ComboboxChip, { children: getLabel(option) }, option))), _jsx(ComboboxChipsInput, { id: id, "aria-label": ariaLabel, "aria-invalid": ariaInvalid, placeholder: selected.length === 0 ? placeholder : undefined, className: summarised ? 'min-w-0 focus:min-w-16' : undefined })] })) }) }), _jsxs(ComboboxContent, { anchor: anchor, children: [_jsx(ComboboxEmpty, { children: "No options found." }), _jsx(ComboboxList, { children: (option) => (_jsx(ComboboxItem, { value: option, children: getLabel(option) }, option)) })] })] }));
29
35
  }
@@ -0,0 +1,7 @@
1
+ import { type StatusKind } from '../../lib/status-kinds.js';
2
+ import type { IconComponent } from './icon-component.js';
3
+ export declare function OptionIcon({ kind, icon, slot }: {
4
+ kind?: StatusKind;
5
+ icon?: IconComponent;
6
+ slot: string;
7
+ }): import("react").JSX.Element | null;
@@ -0,0 +1,13 @@
1
+ import { jsx as _jsx } from "react/jsx-runtime";
2
+ // An option's icon, shared by ChoiceButtons and OptionSelect (4.109): a
3
+ // status kind's icon in its colour (StatusMark's, lib/status-kinds.ts), or
4
+ // the option's own icon, uncoloured without a kind. Decorative: the
5
+ // option's word says it.
6
+ import { cn } from 'cn';
7
+ import { STATUS_KIND_ICONS, STATUS_KIND_TONES } from '../../lib/status-kinds.js';
8
+ export function OptionIcon({ kind, icon, slot }) {
9
+ const Icon = icon ?? (kind ? STATUS_KIND_ICONS[kind] : undefined);
10
+ if (!Icon)
11
+ return null;
12
+ return (_jsx(Icon, { "aria-hidden": "true", "data-slot": slot, "data-kind": kind, className: cn('size-3.5 shrink-0', kind && STATUS_KIND_TONES[kind]) }));
13
+ }
@@ -1,7 +1,13 @@
1
1
  import type { ReactNode } from 'react';
2
+ import type { StatusKind } from '../../lib/status-kinds.js';
3
+ import type { IconComponent } from './icon-component.js';
2
4
  export type OptionSelectOption<T> = {
3
5
  value: T;
4
6
  label: string;
7
+ /** A status kind (4.109): its icon, in its colour, before the words, as StatusMark and ChoiceButtons draw it. */
8
+ kind?: StatusKind;
9
+ /** An icon before the words; with `kind`, in place of the kind's. Uncoloured without a `kind`. */
10
+ icon?: IconComponent;
5
11
  };
6
12
  export type OptionSelectProps<T extends string | number> = {
7
13
  id?: string;
@@ -1,9 +1,10 @@
1
- import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
1
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  import { cn } from 'cn';
3
3
  import { Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from '../ui/select.js';
4
+ import { OptionIcon } from './option-icon.js';
4
5
  const NONE = '__none__';
5
6
  export function OptionSelect({ id, options, value, onValueChange, render, required = false, emptyLabel = 'Not set', placeholder = 'Pick one', invalid = false, disabled, defaultOpen, onOpenChange, modal, className, ...aria }) {
6
- const shown = (option) => (render ? render(option.value, option.label) : option.label);
7
+ const shown = (option) => (_jsxs(_Fragment, { children: [_jsx(OptionIcon, { kind: option.kind, icon: option.icon, slot: "option-select-icon" }), render ? render(option.value, option.label) : option.label] }));
7
8
  const at = value == null ? -1 : options.findIndex((option) => option.value === value);
8
9
  const key = at === -1 ? (required ? null : NONE) : String(at);
9
10
  return (_jsxs(Select, { value: key, onValueChange: (next) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.107.0",
3
+ "version": "4.109.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": {