@tristan2828/ui-foundation 4.129.1 → 4.130.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,19 +15,19 @@
15
15
  - Step 8: Add Playwright specs for all three screens · lines 776–863
16
16
  - Step 9: Register the nav entry and route names · lines 864–878
17
17
  - Step 10: `npm run verify`. · lines 879–881
18
- - [How a list opens a record](#how-a-list-opens-a-record) · lines 883–1402
18
+ - [How a list opens a record](#how-a-list-opens-a-record) · lines 883–1408
19
19
  - [The record view](#the-record-view) · lines 1036–1217
20
- - [Forms](#forms) · lines 1219–1301
21
- - [Dialogs](#dialogs) · lines 1303–1336
22
- - [Toasts and feedback](#toasts-and-feedback) · lines 1338–1402
23
- - [What not to copy](#what-not-to-copy) · lines 1404–1439
24
- - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1441–1458
25
- - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1460–1525
26
- - [Deleting](#deleting) · lines 1527–1558
27
- - [Fields only a script writes](#fields-only-a-script-writes) · lines 1560–1581
28
- - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1583–1592
29
- - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1595–1637
30
- - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1639–1675
20
+ - [Forms](#forms) · lines 1219–1307
21
+ - [Dialogs](#dialogs) · lines 1309–1342
22
+ - [Toasts and feedback](#toasts-and-feedback) · lines 1344–1408
23
+ - [What not to copy](#what-not-to-copy) · lines 1410–1445
24
+ - [After a commit, in the backend](#after-a-commit-in-the-backend) · lines 1447–1464
25
+ - [Saves that don't overwrite](#saves-that-dont-overwrite) · lines 1466–1531
26
+ - [Deleting](#deleting) · lines 1533–1564
27
+ - [Fields only a script writes](#fields-only-a-script-writes) · lines 1566–1587
28
+ - [Searching one part of the app](#searching-one-part-of-the-app) · lines 1589–1598
29
+ - [What a chat is told about an entity](#what-a-chat-is-told-about-an-entity) · lines 1601–1643
30
+ - [Behind a sign-in proxy](#behind-a-sign-in-proxy) · lines 1645–1681
31
31
 
32
32
  <!-- /index -->
33
33
 
@@ -1275,6 +1275,12 @@ shape (4.85):
1275
1275
  the trigger and on each item in its list (`inPlace.select` passes them
1276
1276
  through). With `kind`, leave out a `render` that draws its own icon
1277
1277
  (a `StatusMark`), or the option shows two.
1278
+ A status picked several at once (a multi-value status filter, a
1279
+ "statuses" field) is a `MultiChoice` given those same options (4.130):
1280
+ `options={STATUS_OPTIONS}` in place of bare values, so each option's
1281
+ kind icon (or `icon`) is drawn before its words in the list, on its
1282
+ chip, and on a filter's summary ("Status: ● Active +1"), and its
1283
+ `label` names it with no `getLabel`.
1278
1284
  - **The controls** (4.88): a choice of two to four short options is
1279
1285
  `ChoiceButtons` (`inPlace.choice` in place), five or more an
1280
1286
  `OptionSelect`. A date is `DateField`, typed ("3/14", "Mar 14",
@@ -41,10 +41,10 @@
41
41
  - [23. A Group menu, and a record read beside the list](#23-a-group-menu-and-a-record-read-beside-the-list) · lines 1935–2011
42
42
  - [24. A stored colour beside its name](#24-a-stored-colour-beside-its-name) · lines 2013–2099
43
43
  - [Picking one on a form: `ColorField`](#picking-one-on-a-form-colorfield) · lines 2038–2099
44
- - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2101–2342
45
- - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2271–2342
46
- - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2344–2380
47
- - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2382–2431
44
+ - [25. A list's tools: views, filters, columns, row actions, a phone's rows](#25-a-lists-tools-views-filters-columns-row-actions-a-phones-rows) · lines 2101–2347
45
+ - [The framed look, and sibling lists beside the title](#the-framed-look-and-sibling-lists-beside-the-title) · lines 2276–2347
46
+ - [26. A record's related list, capped](#26-a-records-related-list-capped) · lines 2349–2385
47
+ - [27. A repeat and its next time](#27-a-repeat-and-its-next-time) · lines 2387–2436
48
48
 
49
49
  <!-- /index -->
50
50
 
@@ -2210,8 +2210,13 @@ const { filters, multiFilters, setFilter, setFilters, setMultiFilter, activeView
2210
2210
  `search.onKeyDown` (4.123) gives the search box's keys to the app
2211
2211
  first: Enter on "#12" opening record 12, `preventDefault()` keeping the
2212
2212
  key from the box. `MultiChoice`'s `label` makes it "Rooms: Hall +1"
2213
- instead of a chip per pick. Below 48rem search and Filters share a line
2214
- and every filter, primary ones too, is in Filters' bottom sheet, so pass
2213
+ instead of a chip per pick. Given `OptionSelect`'s options
2214
+ (`{ value, label, kind?, icon? }`, 4.130) in place of bare values,
2215
+ `MultiChoice` draws each option's icon as OptionSelect does: in the
2216
+ list, on each chip, and before the summary's first pick ("Status: ●
2217
+ Active +1"), so a status filter that takes several keeps its icons.
2218
+ Below 48rem search and Filters share a line and every filter, primary
2219
+ ones too, is in Filters' bottom sheet, so pass
2215
2220
  `primaryActive` (their chips) and an `onClearAll` that clears them all
2216
2221
  in one `setFilters` call.
2217
2222
  - **A date filter** (4.110) is `FilterDate`: "Any due date" while off,
@@ -1,12 +1,21 @@
1
1
  import * as React from 'react';
2
- export declare function MultiChoice<T extends string>({ options, value, onValueChange, getLabel, id, placeholder, label, 'aria-label': ariaLabel, 'aria-invalid': ariaInvalid, className, }: {
3
- /** Every allowed option, in display order. */
4
- options: readonly T[];
2
+ import type { OptionSelectOption } from './option-select.js';
3
+ /** An option with its words and, optionally, its icon: OptionSelect's option, the same shape. */
4
+ export type MultiChoiceOption<T extends string> = OptionSelectOption<T>;
5
+ export type MultiChoiceProps<T extends string> = {
6
+ /**
7
+ * Every allowed option, in display order: bare values, or (4.130)
8
+ * OptionSelect's `{ value, label, kind?, icon? }`, whose `label` names it
9
+ * and whose `kind` or `icon` is drawn before the words, as OptionSelect
10
+ * draws it.
11
+ */
12
+ options: readonly T[] | readonly MultiChoiceOption<T>[];
5
13
  value: T[];
6
14
  onValueChange: (value: T[]) => void;
7
15
  /**
8
16
  * The text shown for an option: on its chip, in the dropdown, and what
9
- * typing matches against. Defaults to the value itself.
17
+ * typing matches against. Defaults to the value itself, or to the
18
+ * option's `label` when options are objects.
10
19
  */
11
20
  getLabel?: (value: T) => string;
12
21
  /** Id for the text input, so a <FieldLabel htmlFor> labels it. */
@@ -24,4 +33,5 @@ export declare function MultiChoice<T extends string>({ options, value, onValueC
24
33
  'aria-label'?: string;
25
34
  'aria-invalid'?: boolean;
26
35
  className?: string;
27
- }): React.JSX.Element;
36
+ };
37
+ export declare function MultiChoice<T extends string>({ options, value, onValueChange, getLabel, id, placeholder, label, 'aria-label': ariaLabel, 'aria-invalid': ariaInvalid, className, }: MultiChoiceProps<T>): React.JSX.Element;
@@ -1,4 +1,4 @@
1
- import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
2
  // A multi-choice picker: selected options as removable chips, the rest in a
3
3
  // filterable dropdown. The one control for every "multi choice" field
4
4
  // (conventions/docs/entity-plan-template.md) — on a form (Widget Tags) and as a table
@@ -13,13 +13,41 @@ import { jsxs as _jsxs, jsx as _jsx } from "react/jsx-runtime";
13
13
  // A toolbar filter's summary ("Status: Active +1", `label`) keeps the
14
14
  // control one line high however narrow it is (4.109): it truncates, and
15
15
  // the text box beside it takes no room until it's focused.
16
+ //
17
+ // An option can carry a status kind or an icon (4.130), as OptionSelect's
18
+ // and ChoiceButtons' do, drawn by the same OptionIcon: pass the options as
19
+ // `{ value, label, kind?, icon? }` (OptionSelectOption) in place of bare
20
+ // values. The icon goes before the words on the option in the list, on its
21
+ // chip and on the summary's first pick. Decorative: the words say it.
16
22
  import * as React from 'react';
17
23
  import { cn } from 'cn';
18
24
  import { Combobox, ComboboxChip, ComboboxChips, ComboboxChipsInput, ComboboxContent, ComboboxEmpty, ComboboxItem, ComboboxList, ComboboxValue, useComboboxAnchor, } from '../ui/combobox.js';
19
- export function MultiChoice({ options, value, onValueChange, getLabel = String, id, placeholder, label, 'aria-label': ariaLabel, 'aria-invalid': ariaInvalid, className, }) {
25
+ import { OptionIcon } from './option-icon.js';
26
+ export function MultiChoice({ options, value, onValueChange, getLabel, id, placeholder, label, 'aria-label': ariaLabel, 'aria-invalid': ariaInvalid, className, }) {
20
27
  const anchor = useComboboxAnchor();
28
+ // Bare values or option objects: the values are what the combobox holds,
29
+ // the objects (by value) give the words and the icon.
30
+ const { values, byValue } = React.useMemo(() => {
31
+ const byValue = new Map();
32
+ const values = options.map((option) => {
33
+ if (typeof option === 'string')
34
+ return option;
35
+ byValue.set(option.value, option);
36
+ return option.value;
37
+ });
38
+ return { values, byValue };
39
+ }, [options]);
40
+ const labelOf = (option) => (getLabel ? getLabel(option) : (byValue.get(option)?.label ?? String(option)));
41
+ const iconOf = (option, slot) => {
42
+ const found = byValue.get(option);
43
+ return found ? _jsx(OptionIcon, { kind: found.kind, icon: found.icon, slot: slot }) : null;
44
+ };
45
+ const hasIcon = (option) => {
46
+ const found = byValue.get(option);
47
+ return Boolean(found && (found.kind || found.icon));
48
+ };
21
49
  const summarised = label !== undefined && value.length > 0;
22
- return (_jsxs(Combobox, { multiple: true, autoHighlight: true, items: options, value: value, onValueChange: (next, details) => {
50
+ return (_jsxs(Combobox, { multiple: true, autoHighlight: true, items: values, value: value, onValueChange: (next, details) => {
23
51
  // Base UI empties the value on Escape while the list is closed, so
24
52
  // a second Escape after a pick wiped every chip (issue #123). Escape
25
53
  // never removes picks here: a chip's remove button, Backspace or
@@ -31,5 +59,5 @@ export function MultiChoice({ options, value, onValueChange, getLabel = String,
31
59
  return;
32
60
  }
33
61
  onValueChange(next);
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)) })] })] }));
62
+ }, itemToStringLabel: labelOf, 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 ? (hasIcon(selected[0]) ? (_jsxs("span", { "data-slot": "multi-choice-summary", className: "flex min-w-0 items-center gap-1.5 pl-1 type-body text-foreground", children: [_jsxs("span", { className: "shrink-0", children: [label, ":"] }), iconOf(selected[0], 'multi-choice-icon'), _jsxs("span", { className: "min-w-0 truncate", children: [labelOf(selected[0]), selected.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: [" +", selected.length - 1] })] })] })) : (_jsxs("span", { "data-slot": "multi-choice-summary", className: "min-w-0 truncate pl-1 type-body text-foreground", children: [label, ": ", labelOf(selected[0]), selected.length > 1 && _jsxs("span", { className: "text-muted-foreground", children: [" +", selected.length - 1] })] }))) : null, (label === undefined ? selected : []).map((option) => (_jsxs(ComboboxChip, { removeLabel: labelOf(option), children: [iconOf(option, 'multi-choice-icon'), labelOf(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) => (_jsxs(ComboboxItem, { value: option, children: [iconOf(option, 'multi-choice-icon'), labelOf(option)] }, option)) })] })] }));
35
63
  }
@@ -16,8 +16,10 @@ declare function ComboboxCollection({ ...props }: ComboboxPrimitive.Collection.P
16
16
  declare function ComboboxEmpty({ className, ...props }: ComboboxPrimitive.Empty.Props): React.JSX.Element;
17
17
  declare function ComboboxSeparator({ className, ...props }: ComboboxPrimitive.Separator.Props): React.JSX.Element;
18
18
  declare function ComboboxChips({ className, ...props }: React.ComponentPropsWithRef<typeof ComboboxPrimitive.Chips> & ComboboxPrimitive.Chips.Props): React.JSX.Element;
19
- declare function ComboboxChip({ className, children, showRemove, ...props }: ComboboxPrimitive.Chip.Props & {
19
+ declare function ComboboxChip({ className, children, showRemove, removeLabel, ...props }: ComboboxPrimitive.Chip.Props & {
20
20
  showRemove?: boolean;
21
+ /** The chip's words, naming its remove button ("Remove <words>") when its children aren't plain text (ui-foundation, 4.130). */
22
+ removeLabel?: string;
21
23
  }): React.JSX.Element;
22
24
  declare function ComboboxChipsInput({ className, ...props }: ComboboxPrimitive.Input.Props): React.JSX.Element;
23
25
  declare function useComboboxAnchor(): React.RefObject<HTMLDivElement | null>;
@@ -46,12 +46,12 @@ function ComboboxSeparator({ className, ...props }) {
46
46
  function ComboboxChips({ className, ...props }) {
47
47
  return (_jsx(ComboboxPrimitive.Chips, { "data-slot": "combobox-chips", className: cn("flex min-h-[var(--control-height,--spacing(9))] flex-wrap items-center gap-1 rounded-md border border-input bg-transparent bg-clip-padding px-2.5 py-1 text-sm transition-colors focus-within:border-ring focus-within:ring-3 focus-within:ring-ring/50 has-aria-invalid:border-destructive has-aria-invalid:ring-3 has-aria-invalid:ring-destructive/20 has-data-[slot=combobox-chip]:px-1 dark:bg-input/30 dark:has-aria-invalid:border-destructive/50 dark:has-aria-invalid:ring-destructive/40", className), ...props }));
48
48
  }
49
- function ComboboxChip({ className, children, showRemove = true, ...props }) {
49
+ function ComboboxChip({ className, children, showRemove = true, removeLabel, ...props }) {
50
50
  return (_jsxs(ComboboxPrimitive.Chip, { "data-slot": "combobox-chip", className: cn("flex h-[calc(--spacing(5.25))] w-fit items-center justify-center gap-1 rounded-sm bg-muted px-1.5 text-xs font-medium whitespace-nowrap text-foreground has-disabled:pointer-events-none has-disabled:cursor-not-allowed has-disabled:opacity-50 has-data-[slot=combobox-chip-remove]:pr-0", className), ...props, children: [children, showRemove && (_jsx(ComboboxPrimitive.ChipRemove
51
51
  // Patched (ui-foundation, Phase G): upstream's icon-only remove
52
52
  // button has no accessible name — a critical axe violation. Name
53
53
  // it after the chip ("Remove fragile") when the chip is plain text.
54
- , { "aria-label": typeof children === "string" ? `Remove ${children}` : "Remove", render: _jsx(Button, { variant: "ghost", size: "icon-xs" }), className: "-ml-1 opacity-50 hover:opacity-100", "data-slot": "combobox-chip-remove", children: _jsx(XIcon, { className: "pointer-events-none" }) }))] }));
54
+ , { "aria-label": removeLabel !== undefined ? `Remove ${removeLabel}` : typeof children === "string" ? `Remove ${children}` : "Remove", render: _jsx(Button, { variant: "ghost", size: "icon-xs" }), className: "-ml-1 opacity-50 hover:opacity-100", "data-slot": "combobox-chip-remove", children: _jsx(XIcon, { className: "pointer-events-none" }) }))] }));
55
55
  }
56
56
  // Patched (ui-foundation, issue #94): upstream's input always keeps 4rem,
57
57
  // so chips that fit on one line still pushed it onto an empty second one
package/dist/index.d.ts CHANGED
@@ -64,7 +64,7 @@ export { countTasks, toggleTaskAt, type TaskCount } from './lib/markdown-tasks.j
64
64
  export { NotesOutline, type NotesOutlineProps } from './components/app/notes-outline.js';
65
65
  export type { HeadingFrom, HeadingLevel, TableLook } from './components/app/prose-look.js';
66
66
  export { MockModeBanner } from './components/app/mock-mode-banner.js';
67
- export { MultiChoice } from './components/app/multi-choice.js';
67
+ export { MultiChoice, type MultiChoiceOption, type MultiChoiceProps } from './components/app/multi-choice.js';
68
68
  export { MultiPick, type MultiPickOption, type MultiPickProps } from './components/app/multi-pick.js';
69
69
  export { MultiReference } from './components/app/multi-reference.js';
70
70
  export { ListEditor } from './components/app/list-editor.js';
@@ -123,6 +123,13 @@ export declare const POPUP_FOCUS_GUARDS = "[data-base-ui-focus-guard]";
123
123
  * by design (`disableRules: ['region']`) and brings focus guards
124
124
  * (`exclude: [POPUP_FOCUS_GUARDS]`), while every other rule, contrast
125
125
  * included, still checks the list.
126
+ *
127
+ * It scans in axe's legacy mode: axe runs inside the page and opens no
128
+ * other. The default mode finishes each scan in a fresh blank page, and
129
+ * starting that page's renderer stalled scans past a test's 30 s when
130
+ * several browsers started together (a run's first wave, or the fresh
131
+ * workers after a failure). The cost: cross-origin frames aren't scanned;
132
+ * same-origin frames still are.
126
133
  */
127
134
  export declare function expectNoAxeViolations(page: Page, options?: {
128
135
  disableRules?: string[];
@@ -287,10 +287,17 @@ export const POPUP_FOCUS_GUARDS = '[data-base-ui-focus-guard]';
287
287
  * by design (`disableRules: ['region']`) and brings focus guards
288
288
  * (`exclude: [POPUP_FOCUS_GUARDS]`), while every other rule, contrast
289
289
  * included, still checks the list.
290
+ *
291
+ * It scans in axe's legacy mode: axe runs inside the page and opens no
292
+ * other. The default mode finishes each scan in a fresh blank page, and
293
+ * starting that page's renderer stalled scans past a test's 30 s when
294
+ * several browsers started together (a run's first wave, or the fresh
295
+ * workers after a failure). The cost: cross-origin frames aren't scanned;
296
+ * same-origin frames still are.
290
297
  */
291
298
  export async function expectNoAxeViolations(page, options = {}) {
292
299
  await waitForTransitions(page);
293
- const builder = new AxeBuilder({ page });
300
+ const builder = new AxeBuilder({ page }).setLegacyMode(true);
294
301
  if (options.disableRules?.length)
295
302
  builder.disableRules(options.disableRules);
296
303
  for (const selector of options.exclude ?? [])
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tristan2828/ui-foundation",
3
- "version": "4.129.1",
3
+ "version": "4.130.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": {