@tristan2828/ui-foundation 4.108.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–1252
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 852–1257
19
19
  - [The record view](#the-record-view) · lines 1005–1102
20
- - [Forms](#forms) · lines 1104–1169
21
- - [Dialogs](#dialogs) · lines 1171–1202
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1204–1252
23
- - [What not to copy](#what-not-to-copy) · lines 1254–1286
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1288–1305
25
- - [Deleting](#deleting) · lines 1307–1338
26
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1340–1361
27
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1363–1372
28
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1375–1417
29
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1419–1455
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
 
@@ -1143,6 +1143,11 @@ shape (4.85):
1143
1143
  in its colour before the word, the same as the record's `StatusMark`
1144
1144
  (`icon` overrides the kind's icon; an `icon` with no `kind` stays
1145
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.
1146
1151
  - **The controls** (4.88): a choice of two to four short options is
1147
1152
  `ChoiceButtons` (`inPlace.choice` in place), five or more an
1148
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
  /**
@@ -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.108.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": {