From 13891083dfbf1faa52b04cca08b8703297bd18d0 Mon Sep 17 00:00:00 2001 From: bailey <74082460+bmjcoding@users.noreply.github.com> Date: Sun, 22 Nov 2026 16:28:26 -0600 Subject: [PATCH 1/5] Lists and facts (cimip-gaps-2, B6): PanelList, SelectableList, DescriptionList narrow="line", missing-value words, CodeBlock wrap, Select toolbar, the form dialog body's stack, round 56 A panel of rows (PanelList, PanelRow); a list to choose several from outside a table (SelectableList, SelectableItem, SelectionBar); one-line facts in a narrow column (DescriptionList narrow="line", label column at size-field-label-inline); the app's own words for an absent value (DescriptionItem missing with children); CodeBlock wrap (breaks at spaces only); Select toolbar (its own width); a block between a form dialog's description and its first field sits space-4 above the label. Described menu rows that wrap are the owner's call: round 56 pictures three options and builds none. Entries outside the notification centre are B7's NotificationList. A plain Badge's size is kept by design. React's alone. LinkTabs' limit 141,500 to 141,700 (DECISIONS 246). Decided and built by Opus on the no-council path; not reviewed. Co-Authored-By: Claude Opus 5.5 --- docs/foundations.md | 69 ++- packages/react/README.md | 8 +- packages/react/src/choice.tsx | 14 +- packages/react/src/code-lines.tsx | 30 ++ packages/react/src/description-list.tsx | 23 +- packages/react/src/display.tsx | 4 +- packages/react/src/feedback.tsx | 26 +- packages/react/src/index.ts | 4 + packages/react/src/panel-list.tsx | 92 ++++ packages/react/src/selectable-list.tsx | 150 +++++++ packages/react/src/styles/components.css | 108 ++++- packages/react/test/bundle.test.mjs | 4 +- packages/react/test/export-sizes.json | 27 +- packages/react/test/lists-facts.test.mjs | 425 +++++++++++++++++++ tools/review/build.mjs | 3 +- tools/review/round56.tsx | 517 +++++++++++++++++++++++ tools/review/rounds.tsx | 2 + 17 files changed, 1465 insertions(+), 41 deletions(-) create mode 100644 packages/react/src/panel-list.tsx create mode 100644 packages/react/src/selectable-list.tsx create mode 100644 packages/react/test/lists-facts.test.mjs create mode 100644 tools/review/round56.tsx diff --git a/docs/foundations.md b/docs/foundations.md index fc0df50e..66427a40 100644 --- a/docs/foundations.md +++ b/docs/foundations.md @@ -150,7 +150,7 @@ kept as a rule so both themes behave alike (DECISIONS 166). Four text levels wer items are focusable rows: their ring goes around the hugging pill (see [Navigation](#navigation)). So are the notification centre's entries: links or buttons, which join the hover glide on navigation's rules (below). Otherwise Basalt ships none: the rows of Menu, Select, Combobox and CommandMenu are options and show the plate, breadcrumbs and pagination are - inline, and a settings or list row is the app's own markup. The accordion trigger is the one full-width band that is + inline, a `PanelList` row is a band that is itself the link or button (the flush −2 inset; see [Lists and facts](#lists-and-facts)), and any other settings or list row is the app's own markup. The accordion trigger is the one full-width band that is itself a button; it keeps the ring it was built with and is open for the panel. - **Hover and selected:** washes of 6% and 9% white, or 4% and 7% black, so they work on any @@ -235,6 +235,7 @@ kept as a rule so both themes behave alike (DECISIONS 166). Four text levels wer box that is mixed while some rows are selected), and the count ("3 of 12 selected") is written in a polite live region by the app. Basalt ships no helper for the column or the count: the column is the app's own markup on `Table`, `TableCell` and `Checkbox`, given a first column `size-control-md` wide, and the row takes `selected`. + Outside a table the same selection is `SelectableList` (see [Lists and facts](#lists-and-facts)), which draws the boxes, the all box and the count. Do not mark selection with a vertical line. - **The still table** (the owner's rule, decision 71: header positions, column widths and alignment never move, through sort, filter, paging or loading). `Table` takes `columns` and is then `table-layout: fixed` from a `colgroup`: every @@ -469,12 +470,14 @@ kept as a rule so both themes behave alike (DECISIONS 166). Four text levels wer (its dividers then stay inside the card's padding). The label column is a fixed 160px (`size-description-label`), never sized to its longest label, so every list on a page shares one value edge; a long label wraps inside it. The list is its own container and stacks, label over value `space-0-5` apart, when its own width is under 480px (30rem), whatever - the viewport. The label is 13/18 at 400 in secondary ink on the value's baseline; the value is 14/20 at 400 in primary + the viewport; with `narrow="line"` it keeps each label and value on one row there instead, the label column at 80px (see + [Lists and facts](#lists-and-facts)). The label is 13/18 at 400 in secondary ink on the value's baseline; the value is 14/20 at 400 in primary ink with tabular numerals, start-aligned. Mono is for identifiers only (a `mono` option), at 13px on the 20px line. Rows take `space-2-5` above and below, so a one-line row is 40px, with a `border-divider` between rows (drawn inside the row, as the table's is), never above the first or below the last; the first and last rows lose their outer padding. Several values in one row stack `space-1` apart. A missing value says "Not observed" in tertiary ink, with no - mark, as a table cell does (decision 95). The gap between the label column and the value is `space-4`. + mark, as a table cell does (decision 95); a value that is absent rather than unmeasured says so in the app's words, in the + same ink (see [Lists and facts](#lists-and-facts)). The gap between the label column and the value is `space-4`. - **Meter** (`Meter`, on Base UI's Meter): how much of a cap is used, and not `Progress` (a task finishing). The head has the label at the start (13/18 at 500, primary) and the reading at the end: the value in primary at 500 with tabular numerals, then "of" with the cap and its unit in secondary ("1,240 of 2,000 min"), reserving the width of the cap @@ -520,7 +523,7 @@ kept as a rule so both themes behave alike (DECISIONS 166). Four text levels wer live transcript is `role="log"` only while lines arrive, never idle, paused or finished; it has a fixed height of nine lines that scrolls inside, so arriving lines never move the page, and follows new lines only while the reader is at the end. A replay has a pause control, and every word that changes in place in the head reserves its widest form. - Long lines scroll sideways, as `CodeBlock`'s do. (Decision 98.) The gutter is one column for the whole block, `CodeBlock`'s + Long lines scroll sideways, as `CodeBlock`'s do unless it is given `wrap` (see [Lists and facts](#lists-and-facts)). (Decision 98.) The gutter is one column for the whole block, `CodeBlock`'s too: the prompt's width plus 1ch, at least 24px, measured by the browser and never counted in characters, so `$` is exactly 24px and a longer prompt ("PS>") or a wide glyph widens the column for every line and the text of every line starts on one edge. The terminal is the container for its own head: under 30rem of its own width (not the viewport's) the copy button is @@ -581,7 +584,9 @@ kept as a rule so both themes behave alike (DECISIONS 166). Four text levels wer the wider seat on whole pixels (1 + 6 + 2 at 20, 3 + 6 + 3 at 24). The 20 cell (9 by 15) sits in a 9 by 16 box, one hairline below, so it lands on whole pixels in any even line. A plain `Badge` takes the size and sets the seat and the gap, and a braille `Spinner` inside it takes the same - size. The toast's 16px mark seat is unchanged. Status: decided by the council (DECISIONS 99); the + size. A plain `Badge` sets no font size of its own: it is a word in its line (a cell, a row, a heading) and takes that line's size, which is what lets + its `size` follow the word's cap height. So an app sets its base type on its root (`font: text-base` on `body`), as it sets the page's colour, and a + plain badge outside a component is never the browser's 16px (cimip-gaps-2, B6: kept by design). The toast's 16px mark seat is unchanged. Status: decided by the council (DECISIONS 99); the implementation hasn't been reviewed. `LoopsToggle` and the ambient loop: decided by the council (DECISIONS 136) and approved by the owner (DECISIONS 139); the implementation hasn't been reviewed. - **A control that asks the server is busy until the answer, and never sends twice** (DECISIONS 255, 260). Every button waits for its own @@ -1046,7 +1051,7 @@ The padding is the one-line row's, so a two-line plate is the one-line plate plu - **Search.** Descriptions are search keywords, ranked below title matches. There is no match highlighting: bold letters change widths as you type. - **Where to use it.** Freely in the command menu and the list. In Menu and Select, describe a choice only when the label alone can't tell the choices apart (a visibility, a role, a plan, a model), never to explain an obvious action ("Copy link" stays one line). A described - menu is as wide as its content, up to `size-popover-max` (320), and then descriptions truncate. + menu is as wide as its content, up to `size-popover-max` (320), and then descriptions truncate. (Whether a longer description wraps or the menu widens is open for the owner: see [Lists and facts](#lists-and-facts).) ### Overlays and search @@ -2104,6 +2109,56 @@ every page, every sort), the band, Previous, Next, the count's seat, the page si (`packages/react/test/lists-modals.test.mjs`). Not checked: a real phone (on iOS the held foot sits under the keyboard while typing, as in any web form), WebKit, Firefox, a screen reader and a Windows contrast theme. +## Lists and facts + +**Status.** Gaps found by building CIMIP on Basalt (cimip-gaps-2, batch B6), decided and built by Opus on the no-council path (DECISIONS 226 and 265); Astra reviews the +code and the lead checks the pixels, and neither has happened yet. Every part is general and is shown in the review round (56, renumbered at merge if it collides) in at least two unlike +domains. React's alone (see [What the HTML skill does not draw](#what-the-html-skill-does-not-draw)). + +- **A panel of rows** (`PanelList`, `PanelRow`). Rows of one list in one panel: the panel's level (one above what it sits in, 3 at most), its one rim, radius 12 (a card's), + and a `border-divider` between rows, never above the first or below the last. Each row is a link (with `href`) or a button across the whole band. It is not a form of + `DirectoryList`: the directory is a site's ruled list on the page, rimless, with no wash, three fixed columns and an arrow; a panel of rows is an app's list of things to + open, where the band is the target. A row is a title (primary, 500, `text-base`), an optional description (secondary, `text-sm`), a leading seat centred on the title's line + (a plain `Badge`, an `Avatar`, an icon), a trailing value on the title's line (secondary, `text-sm`, tabular, never cut) and anything the app adds under the description. + The title and the description are one line each, cut with an ellipsis, so a row's height is known; the whole text is still read. Padding `space-3` by `space-4`; at least + 44 tall on a coarse pointer. **Hover** is the hover wash, full bleed, and lifts no ink; a **press** steps to the selected wash; **focus** is the 2px ring inside at −2, because + the band is flush with the panel's clipping edge, and the first and last rows take the panel's inner corner (12 less the rim, 11) so the ring follows it. A row that opens a + new tab draws the new-tab arrow after its title and says so. Name the list (`aria-label`, or `aria-labelledby` on its heading). +- **A list to choose several from, outside a table** (`SelectableList`, `SelectableItem`, `SelectionBar`). The table's selection (see Selected rows), for a list: a chosen + row is the selected wash as a band and its checked box carries the state, and rows are divided by `border-divider` as a table's are. The row is its checkbox's label, so a + press anywhere on it chooses it; focus is the box's own ring at +2, inside the row's padding (`space-2-5` by `space-3`), as a band that holds its own control focuses that + control. The **bar** holds the all box (checked when every row is chosen, mixed while some are, disabled when none can be; its words are the app's, "Select all" by + default), the count in words in a polite `role="status"` line ("2 of 8 selected" by default, or the app's own noun) whose room is held for its widest form, and the actions + at the end, which stay mounted and are `aria-disabled` at zero so focus stays. It sticks to its edge of the scroller (`barSide`: above the rows, or under them for a list at + a sheet's foot), opaque in its surface's colour on a `border-divider` (it is not the smoked surface), and is static in print. The app owns the data: `values` lists what can + be chosen now, and a row whose value has left it (one dealt with) keeps its place and its box with an empty check seat, so nothing moves under a pointer, and it is no longer + counted. The value is always in the list's order. +- **Entries outside the notification centre** are B7's `NotificationList` (the centre's rows in the page, with no head, a current entry and a name), not a part of this batch. +- **One-line facts in a narrow column** (`DescriptionList narrow="line"`). Under 480 of its own width a list stacks by default, which doubles a narrow column's height. With + `narrow="line"` each label and value stay on one row there, and the label column narrows to `size-field-label-inline` (80px, the inline field label's width, so no token is + made); the gap stays `space-4`, a long label wraps inside its column, and several values (`values`, a name then a line then an action) stack in the value column `space-1` + apart, as from 480. From 480 it is the list as it ships. The default stays `stack`, so no shipped list changes. +- **Missing-value words.** "Not observed" is for a reading that could have been taken and was not (a measurement, a sensor, a coverage figure): it stays the default of + `DescriptionItem missing` and `TableCell notObserved`. Anything else that has no value says what is absent, in the app's words, as the children of the same prop: "None yet", + "No one", "No email", "No issue linked", in sentence case, naming the thing where the label does not. It is the same tertiary ink with no mark, and never blank, a dash or a + zero (a zero is a value). The words belong to the product: Basalt has no second default. +- **Code that wraps** (`CodeBlock wrap`). An opt-in for a command that must be read whole in a narrow column (one a reader is asked to approve). Each run of characters + between spaces is drawn as one word that never breaks inside, and the spaces stand between the words, so a line breaks at a space and nowhere else: never after a hyphen, a + slash or a dot, where a browser's own wrap would break a flag or a path. A word longer than the line is not broken: the block scrolls sideways for it, as an unwrapped block + does. With no prompt each source line is a row whose continuation is indented 2ch (an empty line keeps its 20px), so a wrapped line never reads as a new one; beside a + prompt the gutter already marks where a line starts and the continuation starts at the text's edge. Copy takes the code as given. The default still scrolls. +- **A select at its own width** (`Select toolbar`). In a toolbar row a `Select` is as wide as its widest label, not its container's width: every option and the placeholder + stand unseen in the value's one cell (as `MultiSelect toolbar` does), so a choice moves nothing after it, and two selects and a search share a row. In a column narrower than + that it fills the column and cuts the value with an ellipsis; in `FilterToolbar` under 720 it fills its column, as the filters' triggers do. `numeric` stays the form for numbers. +- **What sits between a form dialog's description and its first field.** A spacing rule, not a slot: the body's blocks after the description are one stack at the form gap + (`space-4`), so a block between the description and the first field (a row of ready answers, a callout, a sentence) sits `space-4` above the field's label, as one field + sits above the next, and the description keeps its own `space-5` under it (the two margins collapse). The body already takes any children; a slot would only fix their order. + A group of ready answers is named by the app. +- **Described menu rows that are longer than 320 are the owner's call** and nothing is built. Foundations says both lines are cut and never wrap so a row's height is known + ([Two-line rows](#two-line-rows)); reversing it, or widening a described menu past `size-popover-max` (DECISIONS 155 kept the popover at 320), is his. The options are + pictured in round 56: as shipped; wrapping inside 320; or as wide as the longest line up to the window, then wrapping (what CIMIP does meanwhile). +- **A plain `Badge`'s size** is kept by design (see the status marks under [Lines, states and actions](#lines-states-and-actions)). + ## Loading in the page's own shape **Status.** Decided by Opus and approved by the owner (DECISIONS 247, 248, 249b and 258: the shape of what it stands for, known words kept and icons hidden, @@ -2177,7 +2232,7 @@ as if it were known, which Basalt can't detect. ## What the HTML skill does not draw -The log slots, the status bar, the command block, the event log, the source stamp, the inline-label rows, the filter toolbar, the notice bar, the listbox, the open list, the drawer and `Reflow` are React's alone: the HTML skill has no module for them (DECISIONS 167, Q8). So are `Pagination` and `ListBand` (DECISIONS 222: the skill has no pagination module and none is added). The skill's modules draw the rest (DECISIONS 230, the owner approved the caps): `select` has `data-numeric` (the width of its widest option, measured once fonts are ready; cap 9,000), `filter` has a toolbar trigger that holds its widest value (cap 17,450), and the form dialog is a module of its own, `dialog-form` (`data-form`: the 480 box, the held head and foot, the scrolling body, full screen under 720, the top held as it opens and first focus by the input that opened it; cap 2,200), so the plain and alert dialog keep `dialog`'s 5,150. React's alone: `FormGrid` and the rest of Declare's gaps (DECISIONS 242: the form grid, a segmented control's `fullWidth`, `required`, `invalid` and its tab stop on the chosen value, a `Switch` description, `TextButton` keeping focus and underlining a `Reserve`), the held top's re-measure on a window resize, and the scrim closing a form only while nothing has been entered (the skill's scrim closes it). React's alone too: `LoadingShape` and its parts (DECISIONS 258; the skill's loading shape is a follow-up batch). Whether the skill gets the links and the charts is not decided. +The log slots, the status bar, the command block, the event log, the source stamp, the inline-label rows, the filter toolbar, the notice bar, the listbox, the open list, the drawer and `Reflow` are React's alone: the HTML skill has no module for them (DECISIONS 167, Q8). So are `Pagination` and `ListBand` (DECISIONS 222: the skill has no pagination module and none is added). The skill's modules draw the rest (DECISIONS 230, the owner approved the caps): `select` has `data-numeric` (the width of its widest option, measured once fonts are ready; cap 9,000), `filter` has a toolbar trigger that holds its widest value (cap 17,450), and the form dialog is a module of its own, `dialog-form` (`data-form`: the 480 box, the held head and foot, the scrolling body, full screen under 720, the top held as it opens and first focus by the input that opened it; cap 2,200), so the plain and alert dialog keep `dialog`'s 5,150. React's alone: `FormGrid` and the rest of Declare's gaps (DECISIONS 242: the form grid, a segmented control's `fullWidth`, `required`, `invalid` and its tab stop on the chosen value, a `Switch` description, `TextButton` keeping focus and underlining a `Reserve`), the held top's re-measure on a window resize, and the scrim closing a form only while nothing has been entered (the skill's scrim closes it). React's alone too: `LoadingShape` and its parts (DECISIONS 258; the skill's loading shape is a follow-up batch), and the parts of [Lists and facts](#lists-and-facts) (`PanelList`, `SelectableList`, `DescriptionList narrow`, `CodeBlock wrap`, `Select toolbar` and the form dialog body's stack); a later batch may bring them to the skill. Whether the skill gets the links and the charts is not decided. ## Logs, status and forms diff --git a/packages/react/README.md b/packages/react/README.md index d970aa47..6414cee0 100644 --- a/packages/react/README.md +++ b/packages/react/README.md @@ -93,7 +93,7 @@ only where `prefers-reduced-transparency` is evaluated (Chromium 118 and later); | `BadgePair` | A name with at most two badges: the `status` first, then one neutral `fact`. When the name and the pair don't fit on one line the pair moves under the name as a unit; a badge never truncates. | | `Card`, `CardHeader`, `CardTitle`, `CardDescription`, `CardContent`, `CardFooter` | `CardTitle` is an `h3`; give it `level` (2 to 6) to put the card in the page's outline where it belongs. The size and weight stay the same at every level. | | `ChoiceCard`, `ChoiceCardGroup` | A card you can choose: a native radio (or, with `multiple`, a checkbox) wearing a card, with `title`, `description` and `children`; the whole card is the label and the choice box sits in a seat reserved on every card, so choosing moves no title. Put the cards of one choice in a `ChoiceCardGroup` and name it (`aria-label` or `aria-labelledby`). | -| `DescriptionList`, `DescriptionItem` | Facts about one thing as a `dl`: each `DescriptionItem` has a `term` and its `children` (or `values` for several `dd`s); `mono` for identifiers; `missing` keeps the label and says "Not observed". The label column is fixed and the list stacks under 480px of its own width. | +| `DescriptionList`, `DescriptionItem` | Facts about one thing as a `dl`: each `DescriptionItem` has a `term` and its `children` (or `values` for several `dd`s); `mono` for identifiers; `missing` keeps the label and says "Not observed" (a reading not taken), or the app's own words given as its children ("None yet", "No one") for a value that is absent. The label column is fixed and the list stacks under 480px of its own width; `narrow="line"` keeps each label and value on one row there, the label column at 80px. | | `Stats`, `Stat`, `formatStatTime` | A row of figures, never boxed (`Stats`, one `dl`; `min` is the narrowest a stat gets before the row wraps): each `Stat` has a `label`, a `value`, a `note` and a `source` with its `time`. `formatStatTime(time, { now, timeZone, locale })` writes the time as the stat does, in the locale's hour (`en-US` by default: "4:41 AM", "Nov 7, 8:02 AM"). | | `TableContainer`, `Table`, `TableHeader`, `TableBody`, `TableRow`, `TableHead`, `TableCell` | `numeric` cells use tabular numerals, end-aligned with their header; `mono` cells for IDs and hashes. Give `TableContainer` a `label` ("Runs table"): while the table is wider than its box the container is a keyboard stop with that name as a `region`, so the hidden columns can be scrolled to without a pointer (an `aria-label` or `aria-labelledby` works too; with none of the three the stop is named by the table's `caption`, and with no caption "Scrollable table"). On touch a lone checkbox or link in a cell has a 44px hit box. In a still table (`columns`) a cell whose text is cut by the ellipsis is a focus stop (`data-cut`, `tabindex="0"`), and on hover or focus its whole value opens in place on a level-3 plate (Esc closes it; it is `aria-hidden`, the cell holds the value); each cut cell is one added tab stop. Size a column of one fixed form (a date, a time, a status) for its longest form under WCAG 1.4.12 spacing, so only free text is cut, and size a header's label to fit its column under the same spacing: a cut sortable header opens no plate (the sort button is the whole cell and its name holds the label), a plain header does. A sortable `TableHead` (`onSortChange`) asks for the first direction, then the reverse, then `undefined`: the table's own order, with no column lit. Sort with `sortRows(rows, value, direction)` from the order the rows loaded in, every time, so ties keep it and the third press gives it back row for row. `TableHeadExplainer`, given to a sortable header as `explainer` (a `title`, one to three sentences and at most one link), says what a column a reader could misread means: it opens from the header on hover after 600ms, on keyboard focus and on a long press on touch, above the header or beside it and never over its column; a press still sorts. A `Table` renders every row it is given (see [Long lists](#long-lists)): page one that can pass a few hundred rows with `Pagination`. | | `TableEmpty`, `TableScrollHint` | `TableEmpty` is the row a table shows when no row matches: one cell across `colSpan` columns, under the unchanged header, with a sentence (`children`) and an `action` that names what hid the rows: a search alone gets a sentence that names the term (`No runs match “zzq”.`) and "Clear search"; a chosen filter gets "Clear filters", and in the mixed case "Clear filters" clears the search too. `TableScrollHint` is one line right after a `TableContainer` that is wider than its box ("Scroll sideways to see all 6 columns", `label` sets the words); it shows only while the table overflows, is `aria-hidden` and never changes while the table scrolls. | @@ -101,7 +101,7 @@ only where `prefers-reduced-transparency` is evaluated (Chromium 118 and later); | `Tooltip`, `TooltipProvider` | Supplements a name with a linked accessible description; never replaces a label. | | `Checkbox`, `Switch` | The label is `children`. A switch takes effect immediately; a checkbox on submit. `Switch` takes a `description`: a line under its row in a `Field` description's style, at the column's start edge (not indented past the switch), linked with `aria-describedby` (DECISIONS 242). | | `RadioGroup`, `Radio` | A few options, all visible; arrow keys move the choice. | -| `Select` | `options` of `{ value, label, disabled? }`; labelled by its `Field`. `numeric` makes a Select of numbers (a page size) as wide as its widest option, below `size-select-min`, whatever is chosen. | +| `Select` | `options` of `{ value, label, disabled? }`; labelled by its `Field`. `numeric` makes a Select of numbers (a page size) as wide as its widest option, below `size-select-min`, whatever is chosen. `toolbar` makes any Select as wide as its widest label instead of its container, so selects share a toolbar row and a choice moves nothing after it; in a narrower column it fills the column and cuts the value. | | `ToastProvider`, `useToast` | `useToast().show({ title, description?, status?, action?, home?, group?, running? })`, then `update(id, patch)`, `close(id)` or `promise(work, { running, success, error })`. A toast stays until dismissed unless it names a `home` for what it says (`"centre"`, `"row"`, `"key"` or `"page"`; an action needs one that is not the page), and then it closes after 5s. Level 1, three deep, danger announced assertively. A toast with an `action` is announced with one more sentence: "Undo is available. Press F6 to reach it." (F6 moves to the stack's named region, where the action is a stop.) Pass `actionWords={(label) => string}` to `ToastProvider` to say it in another language or other words; a toast with no action says nothing extra. Nothing extra is drawn, and it is said once. | | `NotificationCentre` | The durable copy a toast points to: a bell button with a dot (count in its name) opening a popover of `entries` (`{ id, title, description?, time, status?, unread?, href? }`), "Mark all as read" and "View all". Presentational: you own the entries, their read state and the page. | | `CommandMenu` | ⌘K: `groups` of `{ label, commands }`, each command `{ id, label, icon?, description?, shortcut?, keywords?, danger?, onSelect? }`; you bind the shortcut. A `description` is a second line, and is searched below the label; `danger` draws the command in the danger colour, as in `Menu`. | @@ -117,7 +117,7 @@ only where `prefers-reduced-transparency` is evaluated (Chromium 118 and later); | `Spinner`, `Skeleton`, `NumberTicker` | Loading and rolling tabular digits. Spinner variants: `ring` (default) and `braille`. `glide` eases a ticker toward its value over `slow`. Under reduced motion and in forced colours the strips are hidden, the number is plain tabular text in the sentence's own line, and a new value changes in place; the system then paints one selection band and its selected-text colour on the digits. A ticker is an inline box, so in a stretched flex row its digits sit where a plain-text sibling's text sits, not on the bottom of the row as they used to (the sparkline's own headline keeps its place). | | `Slide`, `useGlide`, `useReducedMotion`, `useSlideDirection` | Motion helpers. `Slide` wraps a tab or segment panel so a change slides it in (or fades it under reduced motion) without re-keying it, so a field inside keeps its value and focus; `useSlideDirection(value, order)` says which way a value moved through an ordered list (`""` until the first change). `useGlide(target)` eases a number toward `target` over `slow` (give a screen reader `target`, not the in-between value). `useReducedMotion()` is true after mount when the reader asked for reduced motion. | | `MorphIcon`, `TextMorph`, `Sparkline`, `Stepper`, `LivePreview`, `TravelSpinner` | Motion primitives. `Sparkline` is a line and its latest value, not a charting component. See [docs/motion.md](../../docs/motion.md). `TextMorph`'s `label` is what a screen reader hears when `text` changes, if that should say more than the glyphs show; nothing extra is drawn. `Stepper` is a `group` named "Steps" (`label` sets the name), and the step's name is read with where the user is: "Step 2 of 3: Review", once, when it changes. `positionLabel={(step, total) => string}` sets those words for another language. | -| `CodeBlock` | `code`, optional `language`, `title`, `copyable`. Language-aware syntax; exact-text copying and keyboard scrolling. Each language loads on first use: plain text first, colour moments later. For highlighted server-rendered HTML, `await preloadCodeLanguages(["ts", "bash"])` before rendering. | +| `CodeBlock` | `code`, optional `language`, `title`, `copyable`, `prompt`, and `wrap` (break long lines at spaces only, each run between spaces kept whole; a continuation indented 2ch; a word longer than the line still scrolls). Language-aware syntax; exact-text copying and keyboard scrolling. Each language loads on first use: plain text first, colour moments later. For highlighted server-rendered HTML, `await preloadCodeLanguages(["ts", "bash"])` before rendering. | | `Accordion`, `AccordionItem` | Secondary detail; keyboard operated, with coordinated panel and caret motion. An item's header is an `h3`; `headingLevel` (2 to 6) sets its level in the page's outline, and it draws the same at every level. | | `Toolbar`, `ToolbarButton`, `ToolbarIconButton`, `ToolbarLink`, `ToolbarInput`, `ToolbarGroup`, `ToolbarSeparator` | One tab stop for a row (or column) of controls, as the WAI-ARIA toolbar pattern describes: the arrow keys along its `orientation` move between the controls and wrap (`loopFocus={false}` stops at the ends), Home and End go to the first and last, and in a right-to-left page the arrows follow the page. See [Toolbar](#toolbar). | | The core glyphs | `HomeGlyph` and `ArrowDownGlyph`, `ArrowLeftGlyph`, `ArrowRightGlyph`, `ArrowUpGlyph`, `CalendarGlyph`, `CheckGlyph`, `ChevronDownGlyph`, `ChevronLeftGlyph`, `ChevronRightGlyph`, `ChevronUpGlyph`, `CloseGlyph`, `CopyGlyph`, `DownloadGlyph`, `EditGlyph`, `ExternalGlyph`, `HistoryGlyph`, `MenuGlyph`, `MessagesGlyph`, `MinusGlyph`, `MoreGlyph`, `MoreNavGlyph`, `NotificationsGlyph`, `PauseGlyph`, `PlanGlyph`, `PlayGlyph`, `PlusGlyph`, `PolicyGlyph`, `ProfileGlyph`, `RecordsGlyph`, `RoutesGlyph`, `RunsGlyph`, `SandboxesGlyph`, `SearchGlyph`, `SettingsGlyph`, `SourcesGlyph`, `TrashGlyph`, `TrendsGlyph`: one module each, drawn by `Icon` (next row) or passed to any `icon` prop. | @@ -191,6 +191,8 @@ None of these changes how anything looks: each is an option Base UI already had, | `AppTile` | The picture an app gives it (`src`), clipped to a superellipse of exponent 5 (no radius) with a 1px `border-hairline` that follows it (DECISIONS 162, votes 5 and 6). `size` is 20, 32, 36, 40, 44, 48 or 52; left out it is as wide as its box, square. Decorative (`aria-hidden`), always beside the company's name; flat (no shadow); not drawn in forced colours. Each tile carries its own clip. Basalt ships no company's icon file: the product gives one it has the right to show. | | `PeriodStepper` | Two icon buttons round a label that says which stretch of time is shown (DECISIONS 162, D19b): `label`, `spokenPrefix`, `previousLabel`, `nextLabel`, `onPrevious`, `onNext`. `atStart` and `atEnd` stop a button and keep its focus (`aria-disabled`); `whole` hides both and keeps their room, for the view with no periods. The core chevrons, ghost, 32px; the label is 500, tabular, in a seat of at least 128px. The label is spoken once, after it holds still for `delay` ms (400), with the prefix. Under 640px of the app's container (`container-type: inline-size`, in a bar that wraps) it takes its own row, 52px tall with a hairline above and 44 by 44 buttons. Not `Stepper` (a short flow) and not `Pagination`. | | `ListBand` | The count, the pager and the page size of a list, as one band above it (DECISIONS 222): `total`, `maxTotal`, `page`, `pageSize`, `pageSizes` (10, 25, 50, 100), `onPageChange`, `onPageSizeChange`, `noun` ("Incidents": it names the select, "Incidents per page", and is said in the announcement), `sizeLabel` ("per page"). The count ("1–25 of 214") sits at the start in a seat as wide as its widest form, the `Pagination` in the centre, the page size at the end. From 720 it is sticky under the app's bar, opaque, with a divider only while stuck; a page or size change while stuck returns the window to where the band rests. A new size keeps the reader's first row in view (it calls `onPageChange` after `onPageSizeChange`). A page or size change is spoken once after 400ms by the band's own polite line; a change of `total` clears it. Under 640px of its width (720 on a coarse pointer) the numbers go, and the page size follows the pager or, where the two do not fit together, is the end of a second row. The app owns the rows, the page and the filters, and returns to page 1 on a search, a filter or a sort. `children` is the list itself: it follows the band and its Back to top and is followed by the foot. Under 720, with more than one page, the band's Previous, count and Next are drawn again centred under the list (the foot, named by `footLabel`): a press changes the page, returns the window to where the band rests and moves focus to the band's own arrow. `heading` (an id or a ref) is what Back to top focuses; `backToTop={false}` leaves it out. | +| `PanelList`, `PanelRow` | Rows of one list in one panel (its level, one rim, radius 12, a divider between rows). A `PanelRow` is a link (`href`) or a button across its whole band: `title` (500, one line, cut), `description` (secondary, one line, cut), `leading` (a seat on the title's line: a plain `Badge`, an `Avatar`), `trailing` (a time or count, never cut) and children under the description. Hover is the wash, full bleed; focus is the ring inside at −2, following the panel's corner on the end rows. Name the list with `aria-label` or `aria-labelledby`. Not `DirectoryList`, which is a site's rimless list on the page. | +| `SelectableList`, `SelectableItem`, `SelectionBar` | Several to choose from, outside a table. `SelectableList` takes `label`, `values` (what can be chosen now, in order), `value`/`defaultValue`/`onValueChange`, a `bar` and `barSide` (`top` or `bottom`). A `SelectableItem` (`value`, optional `label` for the box's name) is its checkbox's label, so the whole row is the target; chosen, it is the selected wash. A row whose value leaves `values` keeps its place with an empty seat. `SelectionBar` holds the all box (`allLabel`, mixed while some are chosen), the count in words (`count(chosen, total)`, "2 of 8 selected" by default, its room held) and the actions (children); it sticks to its edge of the scroller, opaque on a divider. | | `BackToTop` | A button that takes the window to the top of a long list (DECISIONS 227 and 228; `ListBand` draws one). It sits at the top of the screen, centred on the list, `space-2` under the bar and from 720 under the stuck band, in a dock of zero height right after the band, so it takes no room. It is drawn while the reader scrolls down once the list's top (`list`, a ref) is more than one window above, and it leaves when they scroll up by 8px (the position is held between the page's ends). It never leaves while it holds focus and is not drawn while a modal is open. It fades over `duration-fast` and never slides. A press goes to the top at once and focuses the `heading`. A secondary `sm` Button with the up arrow and "Back to top", with `shadow-overlay`, at every width. | | `ambient(index)`, `AmbientMark`, `AMBIENT_MAX`, `ambientTiming(index)` | A page's one ambient loop: opacity only, in a `Stage`'s art or a framed drawing, at most 24 marks of `size-dot`. `ambient(i)` returns the props for any element (`ambientTiming(i)` is the period factor, 0.6 to 1.4, and the phase it is built from); `AmbientMark` is a `size-dot` span. Held by the hold, still under reduced motion, in forced colours and in print. | | `Reflow`, `ReflowItem`, `REFLOW_BOUND` | A list or grid that is filtered or sorted: `order` names the ids shown, every `ReflowItem` stays mounted (an item not shown is `hidden`), and the items that stay move by transform. `fallbackFocus` is the result line focus falls back to; `onReflow` reports what moved. Past `REFLOW_BOUND` (48) items that would move on screen, a change lands at once. | diff --git a/packages/react/src/choice.tsx b/packages/react/src/choice.tsx index 016b8539..4649b759 100644 --- a/packages/react/src/choice.tsx +++ b/packages/react/src/choice.tsx @@ -216,6 +216,12 @@ export interface SelectProps { * chosen value's width: every option is drawn in the trigger's one cell, unseen, so choosing moves nothing beside it. */ numeric?: boolean; + /** + * Use in a toolbar row: the trigger is as wide as its widest option (or the placeholder), not its container's width, so two selects and a search share a row, + * and choosing never moves what follows it. Every option's label is laid out unseen in the value's one cell, as `MultiSelect toolbar` does. In a column + * narrower than that it fills the column and cuts the value with an ellipsis. For numbers, use `numeric`. + */ + toolbar?: boolean; className?: string; } @@ -223,7 +229,7 @@ export interface SelectProps { * One choice from a list too long for radios. Inside a `Field` it takes the field's label. * The list opens below the trigger, like a menu. */ -export function Select({ options, placeholder = "Select…", controlSize = "md", className, "aria-label": ariaLabel, valuePrefix, numeric, inputRef, ...props }: SelectProps) { +export function Select({ options, placeholder = "Select…", controlSize = "md", className, "aria-label": ariaLabel, valuePrefix, numeric, toolbar, inputRef, ...props }: SelectProps) { const mirror = useMirrorRef(inputRef); const ids = { prefix: React.useId(), value: React.useId() }; const layer = useFloatingLayer(); @@ -237,6 +243,12 @@ export function Select({ options, placeholder = "Select…", controlSize = "md", {valuePrefix} + ) : toolbar ? ( + // A toolbar select holds the width of its widest label: each option (and the placeholder) stands unseen in the value's one cell, so choosing moves nothing after it. + + + {[placeholder, ...options.map((o) => o.label)].map((label, i) => )} + ) : ( // A numeric select holds the width of its widest option: the value's cell carries it as eights in an attribute that a pseudo-element paints, so choosing moves nothing and the DOM holds the words once. String(o.label).length))) : undefined} className="basalt-select-value" placeholder={placeholder} /> diff --git a/packages/react/src/code-lines.tsx b/packages/react/src/code-lines.tsx index 2bfd120b..e5bb9707 100644 --- a/packages/react/src/code-lines.tsx +++ b/packages/react/src/code-lines.tsx @@ -45,6 +45,36 @@ export function codeLines(code: string, tokens: CodeToken[] | null): CodeRun[][] return lines; } +const SPACE = /([ \t]+)/; + +/** + * One line's runs as words for a block that wraps (`CodeBlock wrap`): each run of characters between spaces is one `basalt-code-word`, which never + * breaks inside, and the spaces stand between the words, so a wrapped line breaks at a space and nowhere else (never after a hyphen or a slash). + * A word longer than the line is not broken: the block scrolls sideways for it, as an unwrapped block does. Colours are kept inside the words. + */ +export function codeWords(line: CodeRun[]): React.ReactNode[] { + const out: React.ReactNode[] = []; + let word: React.ReactNode[] = []; + const flush = () => { + if (!word.length) return; + out.push({word}); + word = []; + }; + for (const run of line) { + for (const piece of run.text.split(SPACE)) { + if (!piece) continue; + if (SPACE.test(piece)) { + flush(); + out.push(piece); + } else { + word.push(run.color ? {piece} : piece); + } + } + } + flush(); + return out; +} + /** Whether a line ends in a backslash, so the next line continues it and takes an empty gutter. */ export const continues = (line: CodeRun[] | undefined) => line?.at(-1)?.text.endsWith("\\") ?? false; diff --git a/packages/react/src/description-list.tsx b/packages/react/src/description-list.tsx index 5291b04d..0e0fe80d 100644 --- a/packages/react/src/description-list.tsx +++ b/packages/react/src/description-list.tsx @@ -2,7 +2,10 @@ import * as React from "react"; import { join } from "./utils"; -/** The words for a fact with no value. Batch 2's table cell says the same words in the same ink; see `docs/foundations.md`. */ +/** + * The default words for a fact with no value: a reading that could have been taken and was not. Batch 2's table cell says the same words in + * the same ink; see `docs/foundations.md`. Any other absence says what is absent in the app's own words ("No ticket", "None yet"). + */ export const NOT_OBSERVED = "Not observed"; export interface DescriptionListProps extends React.ComponentProps<"dl"> { @@ -12,6 +15,12 @@ export interface DescriptionListProps extends React.ComponentProps<"dl"> { * the list, and the detail takes the rest. */ form?: "rows" | "stacked" | "three"; + /** + * How a `rows` list lays out under 480px of its own width. `stack` (the default) puts each label over its value. `line` keeps the label and the value + * on one row, the label column narrowing to `size-field-label-inline` (80px, the inline field label's), so a list in a narrow column (a sidebar, a + * card beside the page) is no taller than its values. A long label wraps inside the column; several values stack in the value column. + */ + narrow?: "stack" | "line"; } /** @@ -19,8 +28,8 @@ export interface DescriptionListProps extends React.ComponentProps<"dl"> { * own; it goes in a card only when the card is the object. The label column is a fixed width (`size-description-label`), and the * list stacks (label over value) when its own width, not the viewport's, is under 480px. */ -export function DescriptionList({ form = "rows", className, ...props }: DescriptionListProps) { - return
; +export function DescriptionList({ form = "rows", narrow = "stack", className, ...props }: DescriptionListProps) { + return
; } export interface DescriptionColumnsProps extends React.ComponentProps<"div"> {} @@ -43,7 +52,11 @@ export interface DescriptionItemProps extends Omit, values?: React.ReactNode[]; /** Identifiers (IDs, hosts, images, addresses) are mono, at 13px on the value's 20px line. Prose and numbers are not. */ mono?: boolean; - /** The fact has no value: the row keeps its label and says "Not observed" in tertiary ink, with no mark. */ + /** + * The fact has no value: the row keeps its label and says so in tertiary ink, with no mark. With no children it says "Not observed", the words for a + * reading that could have been taken and was not. Anything else that is absent says what is absent in the app's words, given as the children + * ("No ticket", "No email", "None yet"): a missing value is never blank, a dash or zero. + */ missing?: boolean; /** A third column, in a list whose `form` is `three`: what the thing is. It starts after the value and takes the rest of the row. */ detail?: React.ReactNode; @@ -51,7 +64,7 @@ export interface DescriptionItemProps extends Omit, /** One row: a `div` holding one `dt` and one or more `dd`. */ export function DescriptionItem({ term, children, values, mono, missing, detail, className, ...props }: DescriptionItemProps) { - const details = missing ? [NOT_OBSERVED] : values ?? [children]; + const details = missing ? [children ?? NOT_OBSERVED] : values ?? [children]; return (
{term}
diff --git a/packages/react/src/display.tsx b/packages/react/src/display.tsx index c036a269..56825c2f 100644 --- a/packages/react/src/display.tsx +++ b/packages/react/src/display.tsx @@ -438,8 +438,8 @@ export interface TableCellProps extends React.ComponentProps<"td"> { mono?: boolean; /** * No reading was taken: the cell says "Not observed" in tertiary ink, with no mark, ending on the numbers' edge in a numeric - * column. It is not zero (`0` is a digit in primary) and not empty (an empty string stays blank). Children replace the words, - * for translation. A not-observed value sorts after every observed value in both directions: see foundations. + * column. It is not zero (`0` is a digit in primary) and not empty (an empty string stays blank). Children replace the words: + * for translation, and for a value that is absent rather than unmeasured, in the app's words ("No ticket", "None yet"), in the same ink. A not-observed value sorts after every observed value in both directions: see foundations. */ notObserved?: boolean; } diff --git a/packages/react/src/feedback.tsx b/packages/react/src/feedback.tsx index 51da149c..628aaab7 100644 --- a/packages/react/src/feedback.tsx +++ b/packages/react/src/feedback.tsx @@ -12,7 +12,7 @@ import { CheckGlyph } from "./glyphs/check"; import { ChevronDownGlyph } from "./glyphs/chevron-down"; import { CopyGlyph } from "./glyphs/copy"; import { IconButton } from "./button"; -import { CodeLine, CodePrompt, codeLines, continues } from "./code-lines"; +import { CodeLine, CodePrompt, codeLines, codeWords, continues } from "./code-lines"; import { loadFlight } from "./control-icon"; import { Icon } from "./icon"; import { codeLanguageStatus, highlightCode, loadCodeLanguage } from "./syntax"; @@ -272,6 +272,12 @@ export interface CodeBlockProps { * exactly as given. */ prompt?: string; + /** + * Wrap long lines instead of scrolling sideways, so a command can be read whole in a narrow column. Lines break only at a space: each run of + * characters between spaces is kept whole (a flag, a path, a hyphenated name), and a word longer than the line still scrolls. A wrapped line's + * continuation is indented 2ch (beside a prompt, it starts at the text's edge), so it never reads as a new line. Copy is unchanged. + */ + wrap?: boolean; className?: string; } @@ -281,8 +287,8 @@ const COLOUR_LATER_FROM = 10_000; /** `useSyncExternalStore` with nothing to subscribe to: false in the browser, true on the server and in the hydrating render. */ const noSubscription = () => () => {}; -/** Code, commands or logs, in mono on a sunken surface, scrolling sideways rather than wrapping. */ -export function CodeBlock({ code, language, title, copyable = true, prompt, className }: CodeBlockProps) { +/** Code, commands or logs, in mono on a sunken surface, scrolling sideways rather than wrapping (`wrap` breaks long lines at spaces instead). */ +export function CodeBlock({ code, language, title, copyable = true, prompt, wrap = false, className }: CodeBlockProps) { // A well: level 1 on the page, one deeper inside a card, and so on up to 3. const level = usePanelLevel(); // The code renders as plain text at once; colour follows when its grammar has loaded, with @@ -331,7 +337,8 @@ export function CodeBlock({ code, language, title, copyable = true, prompt, clas return { nodes, rest: code.slice(cursor) }; }, [tokens, code]); // With a prompt, every line has a gutter, so the text is cut into lines; without one the block is a single run of text. - const lines = React.useMemo(() => (prompt === undefined ? null : codeLines(code, tokens)), [prompt, code, tokens]); + // A block that wraps is cut into lines too, each a row of words that break only at a space. + const lines = React.useMemo(() => (prompt === undefined && !wrap ? null : codeLines(code, tokens)), [prompt, wrap, code, tokens]); const [copied, setCopied] = React.useState(false); React.useEffect(() => { if (!copied) return; @@ -357,7 +364,7 @@ export function CodeBlock({ code, language, title, copyable = true, prompt, clas ) : null; return ( -
+
{title ? (
{title} @@ -366,16 +373,21 @@ export function CodeBlock({ code, language, title, copyable = true, prompt, clas ) : null} {/* a scrollable region must be reachable by keyboard */}
-        {lines ? (
+        {lines && prompt !== undefined ? (
           
             {lines.map((line, i) => (
                0 && continues(lines[i - 1]) ? null : {prompt}}>
                 {/* A line that is one plain run is passed as a string. React hydrates a string child by its text alone, so a cold
                     client (grammar not loaded yet) matches a server that sent coloured spans for the same line. */}
-                {line.length === 1 && line[0] && !line[0].color ? line[0].text : line.map((run, j) => (run.color ? {run.text} : {run.text}))}
+                {wrap ? codeWords(line) : line.length === 1 && line[0] && !line[0].color ? line[0].text : line.map((run, j) => (run.color ? {run.text} : {run.text}))}
               
             ))}
           
+        ) : lines ? (
+          // A block that wraps, with no prompt: one row a line, its continuation indented so it never reads as a line of its own.
+          
+            {lines.map((line, i) => {codeWords(line)})}
+          
         ) : (
           {tokens ? <>{content.nodes}{content.rest} : code}
         )}
diff --git a/packages/react/src/index.ts b/packages/react/src/index.ts
index d4214b8b..19893476 100644
--- a/packages/react/src/index.ts
+++ b/packages/react/src/index.ts
@@ -190,6 +190,10 @@ export { LinkCard, LinkTile } from "./link-card";
 export type { LinkCardProps, LinkTileProps } from "./link-card";
 export { BigLinkList, BigLinkRow, DirectoryList, DirectoryRow } from "./link-rows";
 export type { BigLinkListProps, BigLinkRowProps, DirectoryListProps, DirectoryRowProps } from "./link-rows";
+export { PanelList, PanelRow } from "./panel-list";
+export type { PanelListProps, PanelRowProps } from "./panel-list";
+export { SelectableItem, SelectableList, SelectionBar } from "./selectable-list";
+export type { SelectableItemProps, SelectableListProps, SelectionBarProps } from "./selectable-list";
 export { Reveal } from "./reveal";
 export type { RevealProps } from "./reveal";
 export { CopyButton } from "./copy-button";
diff --git a/packages/react/src/panel-list.tsx b/packages/react/src/panel-list.tsx
new file mode 100644
index 00000000..8968c0aa
--- /dev/null
+++ b/packages/react/src/panel-list.tsx
@@ -0,0 +1,92 @@
+// A panel of rows (cimip-gaps-2, B6 item 1): one rimmed panel holding a list, each row a full-bleed band that is itself a link or a button.
+// Not a variant of `DirectoryList`, which is a site's ruled list on the page with no rim, no wash and three fixed columns: this is an app's
+// list of things to open, in one panel, where the band is the target, its hover is the row's wash and its focus is the flush −2 inset.
+import * as React from "react";
+
+import { inLevel, usePanelLevel } from "./layers";
+import { NewTabGlyph, NewTabWords, opensNewTab } from "./new-tab";
+import { join } from "./utils";
+
+export interface PanelListProps extends React.ComponentProps<"ul"> {
+  /** `PanelRow`s, as direct children. Name the list with `aria-label` or `aria-labelledby` (its heading). */
+  children: React.ReactNode;
+}
+
+/**
+ * Rows of one list in one panel: the panel's level (one above what it sits in, 3 at most), its one rim and radius 12, and a `border-divider`
+ * between rows (never above the first or below the last). Each row is a `PanelRow`.
+ */
+export function PanelList({ className, children, ...props }: PanelListProps) {
+  const level = usePanelLevel();
+  return (
+    
    + {inLevel(level, children)} +
+ ); +} + +interface PanelRowOwnProps { + /** What the row is, on its first line: primary ink at 500, one line, cut with an ellipsis (the whole text is still read). */ + title: React.ReactNode; + /** A second line: secondary ink at `text-sm`, one line, cut with an ellipsis. */ + description?: React.ReactNode; + /** A seat before the words, centred on the title's line: a status `Badge`, an `Avatar`, an icon. */ + leading?: React.ReactNode; + /** At the row's end on the title's line: a time, a count, a short state. Secondary ink, `text-sm`, tabular numerals, never cut. */ + trailing?: React.ReactNode; + /** More under the description, laid out by the app (a third line, a row of badges). */ + children?: React.ReactNode; + /** The words a row that opens a new tab adds to its name, for translation. Default "(opens in a new tab)". */ + newTabLabel?: string; +} + +export type PanelRowProps = PanelRowOwnProps & + ( + | ({ href: string } & Omit, "title" | "children" | "href">) + | ({ href?: undefined } & Omit, "title" | "children">) + ); + +/** + * One row of a `PanelList`: a link (with `href`) or a button across the whole band. Hover is the row's wash, full bleed, and lifts no ink; a + * press steps it once more; focus is the 2px ring drawn inside at −2, because the band is flush with the panel's clipping edge (the first and + * last rows round it with the panel's inner corner). A row that opens a new tab draws the new-tab arrow after its title and says so. + */ +export function PanelRow(props: PanelRowProps) { + const { title, description, leading, trailing, children, newTabLabel, className, ...rest } = props; + const newTab = "href" in rest && rest.href !== undefined ? opensNewTab((rest as React.ComponentProps<"a">).target) : false; + const body = ( + <> + {leading !== undefined ? {leading} : null} + + + {title} + {newTab ? ( + <> + + + + ) : null} + + {description !== undefined ? {description} : null} + {children} + + {trailing !== undefined ? {trailing} : null} + + ); + const classes = join("basalt-panel-row", className); + if ("href" in rest && rest.href !== undefined) { + const { target, rel, ...link } = rest as React.ComponentProps<"a">; + const safe = newTab ? [...new Set([...(rel?.split(/\s+/).filter(Boolean) ?? []), "noopener", "noreferrer"])].join(" ") : rel; + return ( +
  • + {body} +
  • + ); + } + const { type = "button", ...button } = rest as React.ComponentProps<"button">; + return ( +
  • + +
  • + ); +} diff --git a/packages/react/src/selectable-list.tsx b/packages/react/src/selectable-list.tsx new file mode 100644 index 00000000..d4616e05 --- /dev/null +++ b/packages/react/src/selectable-list.tsx @@ -0,0 +1,150 @@ +// A selectable list outside a table (cimip-gaps-2, B6 item 3): a checkbox per row, an "all" box that goes mixed, a count in words and a bar of +// actions, as a table's selection has (foundations, "Selected rows"). A row is its checkbox's label, so the whole row is the target; a chosen row +// is the selected wash as a band, and its checked box carries the state. +import * as React from "react"; + +import { Checkbox } from "./choice"; +import { Reserve } from "./reserve"; +import { join } from "./utils"; + +interface Selection { + values: readonly string[]; + chosen: ReadonlySet; + set: (next: string[]) => void; +} + +const SelectionContext = React.createContext(null); + +function useSelection(part: string): Selection { + const selection = React.useContext(SelectionContext); + if (!selection) throw new Error(`${part} must be inside a SelectableList.`); + return selection; +} + +export interface SelectableListProps extends Omit, "defaultValue" | "onChange" | "children"> { + /** Names the list ("People waiting", "Open requests"). */ + label: string; + /** + * Every value that can be chosen now, in the list's order. A row whose value is not here (one already dealt with) keeps its place with an empty + * check seat, and a chosen value that leaves it is no longer counted. + */ + values: readonly string[]; + /** Controlled: the chosen values. */ + value?: readonly string[]; + defaultValue?: readonly string[]; + /** The chosen values after a press, in the list's order, holding only values that can still be chosen. */ + onValueChange?: (value: string[]) => void; + /** A `SelectionBar`: the all box, the count and the actions. */ + bar?: React.ReactNode; + /** Where the bar sits: above the rows (default), or under them (a list at the foot of a sheet). It sticks to that edge of its scroller. */ + barSide?: "top" | "bottom"; + /** `SelectableItem`s. */ + children: React.ReactNode; +} + +/** + * A list to choose several from, outside a table. Nothing is chosen at first unless the app says so. The bar's all box chooses every value that + * can be chosen, or none, and is mixed while some are; the count says how many in words, once, politely. The app owns the data and the actions. + */ +export function SelectableList({ label, values, value, defaultValue, onValueChange, bar, barSide = "top", className, children, ...props }: SelectableListProps) { + const [own, setOwn] = React.useState(defaultValue ?? []); + const current = value ?? own; + const chosen = React.useMemo(() => { + const open = new Set(values); + return new Set(current.filter((v) => open.has(v))); + }, [current, values]); + const set = React.useCallback( + (next: string[]) => { + const keep = new Set(next); + const ordered = values.filter((v) => keep.has(v)); + if (value === undefined) setOwn(ordered); + onValueChange?.(ordered); + }, + [values, value, onValueChange], + ); + const selection = React.useMemo(() => ({ values, chosen, set }), [values, chosen, set]); + const list = ( +
      + {children} +
    + ); + return ( + +
    + {barSide === "top" ? bar : null} + {list} + {barSide === "bottom" ? bar : null} +
    +
    + ); +} + +export interface SelectableItemProps extends Omit, "children"> { + /** The value this row stands for. */ + value: string; + /** The checkbox's name when the row's words are long ("Choose Ada Byrne"). By default the name is the row's words. */ + label?: string; + /** The row's words: the row is the checkbox's label, so a press anywhere on it chooses it. */ + children: React.ReactNode; +} + +/** + * One row: a checkbox and the row's words, the whole row its label. Chosen, it takes the selected wash as a band and its box is checked. A row + * whose value is no longer in the list's `values` keeps its box with an empty check seat, so nothing moves when a row is dealt with. + */ +export function SelectableItem({ value, label, children, className, ...props }: SelectableItemProps) { + const selection = useSelection("SelectableItem"); + const open = selection.values.includes(value); + const on = open && selection.chosen.has(value); + return ( +
  • + {open ? ( + selection.set(checked ? [...selection.chosen, value] : [...selection.chosen].filter((v) => v !== value))} + > + {children} + + ) : ( + + + )} +
  • + ); +} + +export interface SelectionBarProps extends Omit, "children"> { + /** The all box's words: what it chooses ("All waiting"). Default "Select all". */ + allLabel?: React.ReactNode; + /** The count in words. Default "3 of 12 selected"; pass the app's own ("3 of 12 chosen"). Its room is held for the widest count, so it never moves the actions. */ + count?: (chosen: number, total: number) => string; + /** The actions on what is chosen. Keep them mounted at zero, disabled in place with `focusableWhenDisabled`, so focus stays. */ + children?: React.ReactNode; +} + +const DEFAULT_COUNT = (chosen: number, total: number) => `${chosen} of ${total} selected`; + +/** + * The band at the list's edge: the all box (checked when every row is chosen, mixed when some are, disabled when none can be), the count in words in + * a polite status line, then the actions at the end. It sticks to its edge of the scroller, opaque in its surface's colour, on a divider. + */ +export function SelectionBar({ allLabel = "Select all", count = DEFAULT_COUNT, className, children, ...props }: SelectionBarProps) { + const selection = useSelection("SelectionBar"); + const total = selection.values.length; + const n = selection.chosen.size; + const all = total > 0 && n === total; + return ( +
    + 0 && !all} disabled={total === 0} onCheckedChange={(checked) => selection.set(checked ? [...selection.values] : [])}> + {allLabel} + + + + + {children !== undefined ? {children} : null} +
    + ); +} diff --git a/packages/react/src/styles/components.css b/packages/react/src/styles/components.css index 27666f4f..3dc20b2a 100644 --- a/packages/react/src/styles/components.css +++ b/packages/react/src/styles/components.css @@ -94,6 +94,7 @@ /* Every panel has one rim: a real 1px border in two solid colours, the top lit in dark. Never on a control, chip or badge. A border (not a shadow) so forced colours keep it. */ .basalt-card, + .basalt-panel-list, .basalt-table-container, .basalt-code, .basalt-callout, @@ -857,6 +858,9 @@ .basalt-dialog[data-form] .basalt-sheet-body { padding-block: var(--basalt-space-5); } /* The description opens the body, so the held head stays one line. */ .basalt-dialog[data-form] .basalt-sheet-body > .basalt-dialog-description:first-child { margin: 0 0 var(--basalt-space-5); font-size: var(--basalt-text-sm-size); line-height: var(--basalt-text-sm-line-height); } + /* What the body holds after the description is one stack at the form gap (space-4): a block between the description and the first field (a row of ready answers, + a callout, a sentence) sits space-4 above the field's label, as one field sits above the next. It collapses with the description's own space-5, which stays. */ + .basalt-dialog[data-form] .basalt-sheet-body > * + * { margin-top: var(--basalt-space-4); } .basalt-dialog[data-form] .basalt-sheet-foot .basalt-dialog-actions { margin-top: 0; } /* Under 720 a form is a full-screen modal: the whole window, square, no rim or shadow (no edge meets the page), level 1, rising from the bottom on the sheet's motion. The head takes the top safe area and the foot the bottom one; the foot's two actions are equal 44px buttons, Cancel first. An alert dialog stays centred at every width. */ @@ -2938,6 +2942,12 @@ .basalt-select-trigger:has(> .basalt-select-value[data-widest]) { width: auto; min-width: 0; font-variant-numeric: tabular-nums; } .basalt-select-value[data-widest] { display: inline-grid; justify-items: start; } .basalt-select-value[data-widest]::after { content: attr(data-widest); grid-area: 1 / 1; height: 0; overflow: hidden; visibility: hidden; user-select: none; pointer-events: none; } + /* A toolbar select (toolbar) is as wide as its widest label, not its container: every option and the placeholder stand unseen in the value's one cell, so a choice + moves nothing after it. In a column narrower than that it fills the column and the value is cut with an ellipsis. */ + .basalt-select-trigger:has(> .basalt-select-seat) { width: auto; max-width: 100%; min-width: 0; } + .basalt-select-seat { display: inline-grid; grid-template-columns: minmax(0, 1fr); justify-items: start; min-width: 0; } + .basalt-select-seat > * { grid-area: 1 / 1; min-width: 0; max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; line-height: var(--basalt-text-base-line-height); } + .basalt-select-seat > [aria-hidden] { visibility: hidden; user-select: none; pointer-events: none; } .basalt-select-icon { display: flex; color: var(--basalt-text-secondary); } .basalt-select-trigger[data-disabled] { color: var(--basalt-text-disabled); background: var(--basalt-surface-sunken); cursor: not-allowed; } .basalt-select-trigger[data-invalid] { box-shadow: inset 0 0 0 var(--basalt-size-hairline) var(--basalt-status-danger); } @@ -3854,6 +3864,14 @@ } .basalt-code[data-titled] .basalt-code-pre { padding-right: var(--basalt-space-4); } + /* wrap: a long line breaks at a space and nowhere else. Each run between spaces is a word that never breaks inside (white-space: nowrap on the word; + the break between a space and the next word belongs to the line, which wraps), so a flag, a path or a hyphenated name stays whole; a word longer than + the line still scrolls the block sideways. With no prompt each line is a row whose continuation is indented 2ch; beside a prompt the gutter marks a line. */ + .basalt-code[data-wrap] .basalt-code-pre { white-space: pre-wrap; overflow-wrap: normal; } + .basalt-code[data-wrap] .basalt-code-lines { grid-template-columns: minmax(calc(var(--basalt-size-icon-sm) + var(--basalt-space-2)), max-content) minmax(0, 1fr); width: auto; } + .basalt-code-word { white-space: nowrap; } + /* stylelint-disable-next-line unit-disallowed-list -- two characters of the code font, so the indent follows the font; no token holds a width in characters */ + .basalt-code-row { display: block; min-height: var(--basalt-size-code-line-height); padding-inline-start: 2ch; text-indent: -2ch; } .basalt-code-pre code { font: inherit; } .basalt-code-pre:focus-visible { outline: var(--basalt-size-focus-width) solid var(--basalt-border-focus); outline-offset: var(--basalt-size-focus-offset); } /* Copy sits top right: in the title row when there is one, else over the code's corner. */ @@ -3920,9 +3938,12 @@ /* size-breakpoint-container (480px): a container query cannot read a token */ /* stylelint-disable-next-line basalt/container-length -- size-breakpoint-container (480px); a container query cannot read a custom property */ @container (width < 480px) { - .basalt-description-item { grid-template-columns: minmax(0, 1fr); row-gap: var(--basalt-space-0-5); } + .basalt-description-list:not([data-narrow="line"]) .basalt-description-item { grid-template-columns: minmax(0, 1fr); row-gap: var(--basalt-space-0-5); } /* several values stay space-1 apart: the row gap is already space-0-5 */ - .basalt-description-details + .basalt-description-details { grid-column: 1; margin-top: calc(var(--basalt-space-1) - var(--basalt-space-0-5)); } + .basalt-description-list:not([data-narrow="line"]) .basalt-description-details + .basalt-description-details { grid-column: 1; margin-top: calc(var(--basalt-space-1) - var(--basalt-space-0-5)); } + /* narrow="line": the label and the value stay on one row in a narrow column, the label column at the inline field label's width (80), so the list is no taller + than its values. A long label wraps inside it; several values stack in the value column, space-1 apart, as they do from 480. */ + .basalt-description-list[data-narrow="line"] .basalt-description-item { grid-template-columns: var(--basalt-size-field-label-inline) minmax(0, 1fr); } } /* Meter: how much of a cap is used. Not Progress: an outlined slot (8px, 1px input boundary, transparent inside) that is the cap @@ -4970,6 +4991,84 @@ /* The directory: a head, then rows ruled by hairlines, each one link with three fixed columns (name, sentence, state). The name and state columns are 160px, size-description-label's value, for another role here; the sentence takes the rest. */ + /* ---- PanelList: rows of one list in one panel (cimip-gaps-2, B6) ---- + The panel's level, one rim, radius 12 and a divider between rows. Each row is a band that is itself a link or a button: hover is the row's wash, full bleed, + lifting no ink; a press steps it to the selected wash; focus is the 2px ring inside at −2, because the band meets the panel's clipping edge, and the first + and last rows take the panel's inner corner so the ring follows it. Not DirectoryList, which is rimless, washless and on the page. */ + .basalt-panel-list { box-sizing: border-box; margin: 0; padding: 0; list-style: none; overflow: clip; border-radius: var(--basalt-radius-lg); background: var(--_surface, var(--basalt-surface-raised)); color: var(--basalt-text-primary); font-family: var(--basalt-font-family-sans); } + .basalt-panel-item + .basalt-panel-item { border-top: var(--basalt-size-hairline) solid var(--basalt-border-divider); } + .basalt-panel-row { + box-sizing: border-box; + display: grid; + grid-template-columns: minmax(0, 1fr) auto; + column-gap: var(--basalt-space-3); + align-items: start; + width: 100%; + margin: 0; + padding: var(--basalt-space-3) var(--basalt-space-4); + border: 0; + background: transparent; + color: inherit; + font: var(--basalt-font-weight-regular) var(--basalt-text-base-size) / var(--basalt-text-base-line-height) var(--basalt-font-family-sans); + text-align: start; + text-decoration: none; + cursor: pointer; + transition: background-color var(--basalt-duration-fast) var(--basalt-ease-out); + } + .basalt-panel-row:has(> .basalt-panel-row-lead) { grid-template-columns: auto minmax(0, 1fr) auto; } + .basalt-panel-row:hover { background-color: var(--basalt-state-hover); transition-duration: var(--basalt-duration-instant); } + .basalt-panel-row:active { background-color: var(--basalt-state-selected); } + .basalt-panel-row:focus-visible { outline: var(--basalt-size-focus-width) solid var(--basalt-border-focus); outline-offset: calc(-1 * var(--basalt-size-focus-width)); } + .basalt-panel-item:first-child > .basalt-panel-row { border-start-start-radius: calc(var(--basalt-radius-lg) - var(--basalt-size-hairline)); border-start-end-radius: calc(var(--basalt-radius-lg) - var(--basalt-size-hairline)); } + .basalt-panel-item:last-child > .basalt-panel-row { border-end-start-radius: calc(var(--basalt-radius-lg) - var(--basalt-size-hairline)); border-end-end-radius: calc(var(--basalt-radius-lg) - var(--basalt-size-hairline)); } + .basalt-panel-row-lead { display: flex; align-items: center; min-height: var(--basalt-text-base-line-height); } + .basalt-panel-row-words { display: grid; gap: var(--basalt-space-0-5); min-width: 0; } + .basalt-panel-row-title, .basalt-panel-row-description { display: block; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; } + .basalt-panel-row-title { font-weight: var(--basalt-font-weight-medium); } + .basalt-panel-row-description { color: var(--basalt-text-secondary); font-size: var(--basalt-text-sm-size); line-height: var(--basalt-text-sm-line-height); } + .basalt-panel-row-end { color: var(--basalt-text-secondary); font-size: var(--basalt-text-sm-size); line-height: var(--basalt-text-base-line-height); font-variant-numeric: tabular-nums; white-space: nowrap; } + @media (pointer: coarse) { + .basalt-panel-row { min-height: var(--basalt-size-tap-min); } + } + + /* ---- SelectableList: a list to choose several from, outside a table (cimip-gaps-2, B6) ---- + As a table's selection: a checkbox per row, the whole row its label; a chosen row is the selected wash as a band, its checked box the state (the wash alone + is about 1.2:1); the bar holds the all box (mixed while some are chosen), the count in words and the actions. Rows are divided as a table's are. The bar sticks + to its edge of the scroller, opaque in its surface's colour (it is not the smoked surface), on a divider. Focus is each box's own ring at +2, inside the row's padding. */ + .basalt-selectable-list { min-width: 0; font-family: var(--basalt-font-family-sans); } + .basalt-selectable-items { margin: 0; padding: 0; list-style: none; } + .basalt-selectable-item + .basalt-selectable-item { border-top: var(--basalt-size-hairline) solid var(--basalt-border-divider); } + .basalt-selectable-item > .basalt-choice { box-sizing: border-box; display: flex; align-items: flex-start; gap: var(--basalt-space-3); width: 100%; padding: var(--basalt-space-2-5) var(--basalt-space-3); } + .basalt-selectable-item > .basalt-choice > .basalt-checkbox, + .basalt-selectable-seat { margin-block: calc((var(--basalt-text-base-line-height) - var(--basalt-size-choice)) / 2); } + .basalt-selectable-seat { flex: none; width: var(--basalt-size-choice); height: var(--basalt-size-choice); } + .basalt-selectable-item > .basalt-choice > .basalt-choice-label { flex: 1 1 auto; min-width: 0; } + .basalt-selectable-item[data-done] > .basalt-choice { cursor: default; } + .basalt-selectable-words { display: block; min-width: 0; } + @media (hover: hover) { + .basalt-selectable-item:not([data-done]):hover { background: var(--basalt-state-hover); } + } + .basalt-selectable-item[data-selected] { background: var(--basalt-state-selected); } + @media (pointer: coarse) { + .basalt-selectable-item > .basalt-choice { min-height: var(--basalt-size-tap-min); } + } + .basalt-selection-bar { + position: sticky; + z-index: 1; + display: flex; + flex-wrap: wrap; + align-items: center; + column-gap: var(--basalt-space-4); + row-gap: var(--basalt-space-2); + padding: var(--basalt-space-2) var(--basalt-space-3); + background: var(--_surface, var(--basalt-surface-page)); + } + .basalt-selectable-list[data-bar="top"] > .basalt-selection-bar { top: 0; border-bottom: var(--basalt-size-hairline) solid var(--basalt-border-divider); } + .basalt-selectable-list[data-bar="bottom"] > .basalt-selection-bar { bottom: 0; border-top: var(--basalt-size-hairline) solid var(--basalt-border-divider); } + .basalt-selection-count { color: var(--basalt-text-secondary); font: var(--basalt-font-weight-regular) var(--basalt-text-sm-size) / var(--basalt-text-sm-line-height) var(--basalt-font-family-sans); font-variant-numeric: tabular-nums; white-space: nowrap; } + .basalt-selection-actions { display: flex; flex-wrap: wrap; gap: var(--basalt-space-2); margin-inline-start: auto; } + @media print { .basalt-selection-bar { position: static; } } + .basalt-directory { color: var(--basalt-text-primary); font-family: var(--basalt-font-family-sans); font-size: var(--basalt-text-md-size); line-height: var(--basalt-text-md-line-height); letter-spacing: var(--basalt-text-md-tracking); } .basalt-directory-head { margin: 0; padding-block-end: var(--basalt-space-3); color: var(--basalt-text-secondary); font: var(--basalt-font-weight-medium) var(--basalt-text-md-size) / var(--basalt-text-md-line-height) var(--basalt-font-family-sans); letter-spacing: var(--basalt-text-md-tracking); } .basalt-directory-list { margin: 0; padding: 0; list-style: none; } @@ -5460,7 +5559,7 @@ tab's Highlight underline, and keeps its 600. Keyboard focus is the standard ring (2px, offset 2) on the chosen item as on every other control, which an outline of its own on the chosen item used to hide. */ /* Panels: the rim is a real border already, so forced colours keep an edge; it just takes the system colour. */ - .basalt-card, .basalt-table-container, .basalt-code, .basalt-callout, .basalt-preview-card, .basalt-dialog, .basalt-menu, .basalt-popover, .basalt-tooltip, .basalt-skip-link, .basalt-cell-peek, .basalt-peek, .basalt-toast, .basalt-command-page, .basalt-command-pane, .basalt-framed-frame { border-color: CanvasText; } + .basalt-card, .basalt-panel-list, .basalt-table-container, .basalt-code, .basalt-callout, .basalt-preview-card, .basalt-dialog, .basalt-menu, .basalt-popover, .basalt-tooltip, .basalt-skip-link, .basalt-cell-peek, .basalt-peek, .basalt-toast, .basalt-command-page, .basalt-command-pane, .basalt-framed-frame { border-color: CanvasText; } /* A callout's status is the icon's shape and the words. An SVG keeps its own authored colour in forced colours, so the green, amber or red would survive: the icon takes the system foreground like the text beside it. */ .basalt-callout[data-status] .basalt-callout-icon { color: CanvasText; } @@ -6009,6 +6108,8 @@ .basalt-filter-toolbar:has(> .basalt-filter-toolbar-search) > .basalt-filter-toolbar-result { grid-column: 1 / -1; grid-row: auto; } /* A trigger in a toolbar fills its column and cuts its value with an ellipsis; the checklist shows it whole. */ .basalt-filter-toolbar .basalt-filter-trigger { width: 100%; min-width: 0; justify-content: space-between; } + /* A toolbar Select fills its column under 720, as the filters' triggers do, and from 720 is as wide as its widest label. */ + .basalt-filter-toolbar .basalt-select-trigger:has(> .basalt-select-seat) { width: 100%; } .basalt-filter-toolbar .basalt-filter-trigger .basalt-button-label { min-width: 0; } .basalt-filter-toolbar-result { grid-column: 1; grid-row: 3; color: var(--basalt-text-secondary); font: var(--basalt-font-weight-regular) var(--basalt-text-base-size) / var(--basalt-text-base-line-height) var(--basalt-font-family-sans); font-variant-numeric: tabular-nums; } .basalt-filter-toolbar-result > * { margin: 0; } @@ -6021,6 +6122,7 @@ .basalt-filter-toolbar-kind { display: none; } .basalt-filter-toolbar-search { flex: none; order: -1; width: var(--basalt-size-search-trigger); } .basalt-filter-toolbar .basalt-filter-trigger { width: auto; } + .basalt-filter-toolbar .basalt-select-trigger:has(> .basalt-select-seat) { width: auto; } .basalt-filter-toolbar-result { order: 2; } .basalt-filter-toolbar-sort { order: 3; margin-inline-start: auto; } .basalt-filter-toolbar-label { display: block; } diff --git a/packages/react/test/bundle.test.mjs b/packages/react/test/bundle.test.mjs index 0bac70b5..aad77fb7 100644 --- a/packages/react/test/bundle.test.mjs +++ b/packages/react/test/bundle.test.mjs @@ -105,7 +105,9 @@ for (const [name, limit] of [["SheetHeader", 82_000], ["SearchDialog", 88_000]]) // DECISIONS 154, the controls port: each new export alone, with splitting. Measured: TextButton 8,570, SwitchRow 24,794, SwitchRowGroup 10,977, // OptionChips 37,699 (Base UI's radio group), LinkTabs 140,720 (it carries the Select under 720, DECISIONS 154 A15: Base UI's select and its popup), LinkTab 649 (3,898 once its label takes ChosenLabel, the selected state a Tab's children take: join 2 in integration-nov15b, DECISIONS 138 A, 145, 149; the limit is the measured bytes rounded up to the next 50), TabsPanels 519, useConfirm 399, CONFIRM_MS 185; the limits sit just above. -for (const [name, limit, baseUi] of [["TextButton", 10_600, true], ["SwitchRow", 25_500, true], ["SwitchRowGroup", 11_600, true], ["OptionChips", 38_400, true], ["LinkTabs", 141_500, true], ["LinkTab", 3_900, false], ["TabsPanels", 900, false], ["useConfirm", 800, false], ["CONFIRM_MS", 400, false]]) { +// cimip-gaps-2 B6 (DECISIONS 246: trim first, then a raise the feature needs): LinkTabs carries the Select, and `Select toolbar` (the unseen labels that hold its width) adds 212 bytes +// after a 67-byte trim (no attribute, no class on the labels): measured 141,669, from main's 141,457, so the limit goes from 141,500 to 141,700. +for (const [name, limit, baseUi] of [["TextButton", 10_600, true], ["SwitchRow", 25_500, true], ["SwitchRowGroup", 11_600, true], ["OptionChips", 38_400, true], ["LinkTabs", 141_700, true], ["LinkTab", 3_900, false], ["TabsPanels", 900, false], ["useConfirm", 800, false], ["CONFIRM_MS", 400, false]]) { test(`${name} alone, with splitting, loads only its own static graph (${limit} bytes at most)`, async () => { const { bytes, chunks, inputs } = await graph(name); assert.ok(bytes < limit, `${name}: ${bytes} bytes in ${chunks} chunks (limit ${limit})`); diff --git a/packages/react/test/export-sizes.json b/packages/react/test/export-sizes.json index 4e5c5246..5050f401 100644 --- a/packages/react/test/export-sizes.json +++ b/packages/react/test/export-sizes.json @@ -54,7 +54,7 @@ "ChoiceCardGroup": 294, "Clock": 2826, "CloseGlyph": 2836, - "CodeBlock": 22441, + "CodeBlock": 22949, "Columns": 265, "ColumnsItem": 257, "Combobox": 164576, @@ -67,8 +67,8 @@ "CoverageStrip": 1570, "DateAge": 2527, "DescriptionColumns": 216, - "DescriptionItem": 578, - "DescriptionList": 258, + "DescriptionItem": 581, + "DescriptionList": 326, "Dialog": 70433, "DialogActions": 234, "DialogClose": 69690, @@ -122,9 +122,9 @@ "Link": 5148, "LinkCard": 5040, "LinkTab": 3764, - "LinkTabs": 140937, + "LinkTabs": 141149, "LinkTile": 4463, - "ListBand": 157320, + "ListBand": 157530, "Listbox": 3240, "ListboxGroup": 405, "ListboxOption": 4052, @@ -175,6 +175,8 @@ "PageWait": 2453, "Pagination": 21695, "PairedArt": 462, + "PanelList": 469, + "PanelRow": 4642, "PauseGlyph": 2819, "PeriodStepper": 17812, "PhaseChart": 51249, @@ -216,7 +218,10 @@ "SectionIntro": 224, "Segment": 15718, "SegmentedControl": 19383, - "Select": 139960, + "Select": 140172, + "SelectableItem": 25536, + "SelectableList": 794, + "SelectionBar": 25827, "Separator": 4531, "SettingsGlyph": 3100, "ShareBar": 1411, @@ -233,7 +238,7 @@ "ShortcutList": 10032, "SingleKeysSwitch": 17082, "SiteBrand": 1302, - "SiteFooter": 14780, + "SiteFooter": 14782, "SiteHeader": 175837, "SiteLockupDefs": 694, "SiteMenu": 168176, @@ -369,11 +374,11 @@ "useWaitMark": 303 }, "package": { - "bytes": 760821, - "gzip": 250482 + "bytes": 765042, + "gzip": 251652 }, "styles": { - "bytes": 306194, - "gzip": 40099 + "bytes": 312357, + "gzip": 40812 } } diff --git a/packages/react/test/lists-facts.test.mjs b/packages/react/test/lists-facts.test.mjs new file mode 100644 index 00000000..bf05d145 --- /dev/null +++ b/packages/react/test/lists-facts.test.mjs @@ -0,0 +1,425 @@ +// lists-facts (cimip-gaps-2, batch B6): a panel of rows (PanelList), a list to choose several from outside a table (SelectableList), one-line facts in a narrow column +// (DescriptionList narrow="line") and missing-value words, CodeBlock wrap (breaks at spaces only), Select toolbar (its own width), and a form dialog's body spacing. Found by +// building CIMIP on Basalt; every fixture is from another domain. Decided and built by Opus on the no-council path; the implementation has not been reviewed. Driven in Chromium +// against the built package with the real stylesheet. The fixtures load no web font, so every measured margin is wider than a fallback font's width. Synthetic data only. +import assert from "node:assert/strict"; +import fs from "node:fs"; +import { createRequire } from "node:module"; +import { after, before, describe, test } from "node:test"; + +import { fixturePage, launch, settle } from "./support.mjs"; + +const axeSource = fs.readFileSync(createRequire(import.meta.url).resolve("axe-core/axe.min.js"), "utf8"); +let browser; +before(async () => { browser = await launch(); }); +after(async () => { await browser?.close(); }); + +const COARSE = { hasTouch: true, isMobile: true }; +const open = async (fixture, { width = 1440, height = 900, theme = "dark", ...options } = {}) => { + const { page, errors } = await fixturePage(browser, fixture, { theme, viewport: { width, height }, ...options }); + if (options.isMobile) { await page.evaluate(() => { const meta = document.createElement("meta"); meta.name = "viewport"; meta.content = "width=device-width, initial-scale=1"; document.head.append(meta); }); } + await settle(page); + page.errors = errors; + return page; +}; +const axe = async (page) => { + await page.evaluate(() => { document.title = "Basalt"; document.documentElement.lang = "en"; }); + await page.addScriptTag({ content: axeSource }); + return page.evaluate(async () => { + const options = { runOnly: { type: "tag", values: ["wcag2a", "wcag2aa", "wcag21a", "wcag21aa", "wcag22aa"] }, resultTypes: ["violations"] }; + const result = await globalThis.axe.run({ exclude: [["[data-base-ui-focus-guard]"]] }, options); + return result.violations.map((v) => `${v.id}: ${v.nodes.map((n) => n.target.join(" ")).join(" | ")}`); + }); +}; +const PAGE = `document.body.style.margin = "0"; document.body.style.background = "var(--basalt-surface-page)"; document.body.style.color = "var(--basalt-text-primary)";`; + +// ---- PanelList ---- + +const PANEL = `${PAGE} +createRoot(document.getElementById("root")).render( +
    +

    Recent builds

    + + Passed} /> + { window.pressed = (window.pressed ?? 0) + 1; }} /> + + +
    +
    +);`; + +describe("PanelList", () => { + test("a panel at its level with one rim, radius 12, a divider between rows only, and rows that are links or buttons", async () => { + for (const theme of ["dark", "light"]) { + const page = await open(PANEL, { theme }); + const info = await page.evaluate(() => { + const list = document.querySelector(".basalt-panel-list"); + const cs = getComputedStyle(list); + const items = [...list.children].map((li) => getComputedStyle(li).borderTopWidth); + return { level: list.dataset.level, inner: document.getElementById("inner").dataset.level, radius: cs.borderTopLeftRadius, rim: cs.borderTopWidth, side: cs.borderLeftWidth, items, r1: document.getElementById("r1").tagName, r2: [document.getElementById("r2").tagName, document.getElementById("r2").type], rel: document.getElementById("r3").rel, newTab: document.getElementById("r3").textContent }; + }); + assert.equal(info.level, "1"); + assert.equal(info.inner, "2", "a panel inside a card is one level deeper"); + assert.equal(info.radius, "12px"); + assert.equal(info.rim, "1px"); + assert.equal(info.side, "1px"); + assert.deepEqual(info.items, ["0px", "1px", "1px"], "a divider between rows, never above the first"); + assert.equal(info.r1, "A"); + assert.deepEqual(info.r2, ["BUTTON", "button"]); + assert.deepEqual(info.rel.split(" ").sort(), ["external", "noopener", "noreferrer"]); + assert.match(info.newTab, /opens in a new tab/); + assert.deepEqual(await axe(page), [], theme); + assert.deepEqual(page.errors, []); + await page.close(); + } + }); + + test("the band is full bleed: hover is a wash with no ink change; focus is the ring inside at −2 and the end rows take the panel's inner corner", async () => { + const page = await open(PANEL); + const rest = await page.evaluate(() => { const r = document.getElementById("r1"); return { bg: getComputedStyle(r).backgroundColor, ink: getComputedStyle(r.querySelector(".basalt-panel-row-title")).color, w: r.getBoundingClientRect().width, list: document.querySelector(".basalt-panel-list").clientWidth }; }); + assert.equal(rest.w, rest.list, "the row is the panel's inner width"); + await page.hover("#r1"); + await settle(page); + const hover = await page.evaluate(() => { const r = document.getElementById("r1"); return { bg: getComputedStyle(r).backgroundColor, ink: getComputedStyle(r.querySelector(".basalt-panel-row-title")).color }; }); + assert.notEqual(hover.bg, rest.bg); + assert.equal(hover.ink, rest.ink, "hover lifts no ink"); + await page.mouse.move(0, 0); + await page.keyboard.press("Tab"); + const ring = await page.evaluate(() => { const r = document.activeElement; const cs = getComputedStyle(r); return { id: r.id, style: cs.outlineStyle, width: cs.outlineWidth, offset: cs.outlineOffset, radius: cs.borderTopLeftRadius, last: getComputedStyle(document.getElementById("r3")).borderBottomLeftRadius, mid: getComputedStyle(document.getElementById("r2")).borderTopLeftRadius }; }); + assert.equal(ring.id, "r1"); + assert.equal(ring.style, "solid"); + assert.equal(ring.width, "2px"); + assert.equal(ring.offset, "-2px"); + assert.equal(ring.radius, "11px"); + assert.equal(ring.last, "11px"); + assert.equal(ring.mid, "0px"); + await page.close(); + }); + + test("the title and description are one line each and cut; the trailing value is never cut; a coarse pointer's row is at least 44", async () => { + const page = await open(PANEL, { width: 390, ...COARSE }); + const info = await page.evaluate(() => { + const r2 = document.getElementById("r2"); + const title = r2.querySelector(".basalt-panel-row-title"); + const end = r2.querySelector(".basalt-panel-row-end"); + return { cut: title.scrollWidth > title.clientWidth, lines: Math.round(title.getBoundingClientRect().height), endCut: end.scrollWidth > end.clientWidth, heights: [...document.querySelectorAll(".basalt-panel-row")].map((r) => r.getBoundingClientRect().height) }; + }); + assert.ok(info.cut); + assert.equal(info.lines, 20); + assert.equal(info.endCut, false); + for (const h of info.heights) assert.ok(h >= 44, `row ${h}`); + await page.close(); + }); +}); + +// ---- SelectableList ---- + +const PICK = (bar = "top") => `${PAGE} +const PEOPLE = [["a", "Ada Byrne"], ["k", "Kofi Mensah"], ["l", "Lena Ishikawa"], ["r", "Rafael Ortiz"], ["s", "Sana Iqbal"], ["t", "Tomas Weir"], ["u", "Uma Patel"], ["v", "Vera Lund"]]; +function App() { + const [chosen, setChosen] = React.useState([]); + const [done, setDone] = React.useState([]); + window.chosen = chosen; + const open = PEOPLE.map((p) => p[0]).filter((id) => !done.includes(id)); + const n = chosen.filter((id) => open.includes(id)).length; + return ( +
    + { window.changes = [...(window.changes ?? []), v]; setChosen(v); }} barSide="${bar}" + bar={ c + " of " + t + " chosen"}> { setDone([...done, ...chosen]); setChosen([]); }}>Let in}> + {PEOPLE.map(([id, name]) => {name})} + +
    + ); +} +createRoot(document.getElementById("root")).render();`; + +const allBox = (page) => page.locator("#bar [role='checkbox']"); + +describe("SelectableList", () => { + test("a press anywhere on a row chooses it; the all box goes mixed, then all, then none; the count says so in words", async () => { + const page = await open(PICK()); + assert.equal(await allBox(page).getAttribute("aria-checked"), "false"); + assert.equal(await page.locator(".basalt-selection-count [data-on]").textContent(), "0 of 8 chosen"); + // The row's far end (its words' empty room) is still the checkbox's label. + const row = await page.locator("#row-k").boundingBox(); + await page.mouse.click(row.x + row.width - 8, row.y + row.height / 2); + await settle(page); + assert.deepEqual(await page.evaluate(() => window.chosen), ["k"]); + assert.equal(await page.locator("#row-k").getAttribute("data-selected"), ""); + assert.equal(await page.locator("#row-k [role='checkbox']").getAttribute("aria-checked"), "true"); + assert.equal(await allBox(page).getAttribute("aria-checked"), "mixed"); + assert.equal(await page.locator(".basalt-selection-count [data-on]").textContent(), "1 of 8 chosen"); + await allBox(page).click(); + assert.deepEqual(await page.evaluate(() => window.chosen), ["a", "k", "l", "r", "s", "t", "u", "v"]); + assert.equal(await allBox(page).getAttribute("aria-checked"), "true"); + await allBox(page).click(); + assert.deepEqual(await page.evaluate(() => window.chosen), []); + // Chosen out of order, the value is in the list's order. + await page.locator("#row-r [role='checkbox']").click(); + await page.locator("#row-a [role='checkbox']").click(); + assert.deepEqual(await page.evaluate(() => window.chosen), ["a", "r"]); + assert.equal(await page.locator("#row-a [role='checkbox']").getAttribute("aria-label"), "Choose Ada Byrne"); + assert.equal(await page.locator(".basalt-selection-count").getAttribute("role"), "status"); + assert.deepEqual(page.errors, []); + await page.close(); + }); + + test("a row dealt with keeps its place and box with an empty seat, and is no longer counted; the count's room never changes", async () => { + const page = await open(PICK()); + const before = await page.evaluate(() => ({ rows: [...document.querySelectorAll(".basalt-selectable-item")].map((r) => { const b = r.getBoundingClientRect(); return [b.top, b.height]; }), count: document.querySelector(".basalt-selection-count").getBoundingClientRect().width, admit: document.getElementById("admit").getBoundingClientRect().left })); + await page.locator("#row-a [role='checkbox']").click(); + await page.locator("#row-l [role='checkbox']").click(); + const mid = await page.evaluate(() => ({ count: document.querySelector(".basalt-selection-count").getBoundingClientRect().width, admit: document.getElementById("admit").getBoundingClientRect().left })); + assert.equal(mid.count, before.count, "the count's room is held"); + assert.equal(mid.admit, before.admit, "the actions do not move"); + await page.click("#admit"); + await settle(page); + const after = await page.evaluate(() => ({ rows: [...document.querySelectorAll(".basalt-selectable-item")].map((r) => { const b = r.getBoundingClientRect(); return [b.top, b.height]; }), done: [...document.querySelectorAll(".basalt-selectable-item[data-done]")].map((r) => r.id), boxes: document.querySelectorAll(".basalt-selectable-item [role='checkbox']").length, seat: (() => { const s = document.querySelector("#row-a .basalt-selectable-seat").getBoundingClientRect(); const b = document.querySelector("#row-k [role='checkbox']").getBoundingClientRect(); return [s.width, s.height, s.left, b.width, b.height, b.left]; })() })); + assert.deepEqual(after.rows, before.rows, "no row moved"); + assert.deepEqual(after.done, ["row-a", "row-l"]); + assert.equal(after.boxes, 6); + assert.deepEqual(after.seat.slice(0, 3), after.seat.slice(3), "the empty seat is the box's size and place"); + assert.equal(await page.locator(".basalt-selection-count [data-on]").textContent(), "0 of 6 chosen"); + assert.equal(await page.locator("#admit").getAttribute("aria-disabled"), "true"); + await page.close(); + }); + + test("the bar sticks to its edge of the scroller, opaque, on a divider", async () => { + for (const [side, edge] of [["top", "borderBottomWidth"], ["bottom", "borderTopWidth"]]) { + const page = await open(PICK(side)); + await page.evaluate(() => { document.getElementById("scroller").scrollTop = 80; }); + const info = await page.evaluate((edge) => { + const s = document.getElementById("scroller").getBoundingClientRect(); + const bar = document.getElementById("bar"); + const b = bar.getBoundingClientRect(); + const cs = getComputedStyle(bar); + return { position: cs.position, top: b.top - s.top, bottom: s.bottom - b.bottom, bg: cs.backgroundColor, line: cs[edge] }; + }, edge); + assert.equal(info.position, "sticky"); + assert.equal(Math.round(side === "top" ? info.top : info.bottom), 0, side); + assert.ok(!/transparent|\/ 0|rgba\(0, 0, 0, 0\)/.test(info.bg) && !/\/\s*0?\.\d/.test(info.bg), `an opaque fill: ${info.bg}`); + assert.equal(info.line, "1px"); + await page.close(); + } + }); + + test("no axe violations in either theme, and a coarse pointer's row is at least 44", async () => { + for (const theme of ["dark", "light"]) { + const page = await open(PICK(), { theme }); + await page.locator("#row-a [role='checkbox']").click(); + // The actions' ink steps from disabled as the first row is chosen: read it once the step has run. + await settle(page); + assert.deepEqual(await axe(page), [], theme); + await page.close(); + } + const page = await open(PICK(), { width: 390, ...COARSE }); + const heights = await page.evaluate(() => [...document.querySelectorAll(".basalt-selectable-item")].map((r) => r.getBoundingClientRect().height)); + for (const h of heights) assert.ok(h >= 44, `row ${h}`); + await page.close(); + }); +}); + +// ---- DescriptionList narrow="line" and missing words ---- + +const FACTS = `${PAGE} +const items = ( + <> + release/2.4 + + None yet + + No reply yet + +); +createRoot(document.getElementById("root")).render( +
    +
    {items}
    +
    {items}
    +
    {items}
    +
    +);`; + +describe("DescriptionList", () => { + test("narrow=\"line\" keeps label and value on one row under 480, the label column 80; the default still stacks; 480 and up is unchanged", async () => { + const page = await open(FACTS); + const info = await page.evaluate(() => { + const read = (list) => [...document.querySelectorAll(`#${list} .basalt-description-item`)].map((item) => { + const dt = item.querySelector("dt").getBoundingClientRect(); + const dds = [...item.querySelectorAll("dd")].map((d) => d.getBoundingClientRect()); + return { dtTop: dt.top, dtW: dt.width, ddTop: dds[0].top, ddLeft: dds[0].left - item.getBoundingClientRect().left, second: dds[1] ? [dds[1].top - dds[0].bottom, dds[1].left - item.getBoundingClientRect().left] : null, h: item.getBoundingClientRect().height }; + }); + return { stack: read("stack"), line: read("line"), wide: read("wide"), height: ["stack", "line"].map((id) => document.getElementById(id).getBoundingClientRect().height) }; + }); + for (const row of info.line) { + assert.ok(row.ddTop - row.dtTop < 2 && row.ddTop - row.dtTop > -2, "on one row"); + assert.equal(row.dtW, 80); + assert.equal(row.ddLeft, 96, "80 and the space-4 gap"); + } + assert.deepEqual(info.line[3].second, [4, 96], "a second value stacks in the value column, space-1 apart"); + for (const row of info.stack) assert.ok(row.ddTop > row.dtTop + 10, "the default stacks"); + for (const row of info.wide) { assert.equal(row.dtW, 160); assert.equal(row.ddLeft, 176); } + assert.ok(info.height[1] < info.height[0] * 0.75, `one line each is shorter: ${info.height}`); + // A long label wraps inside its 80. + assert.ok(info.line[4].h > 40, "a label that wraps makes its own row taller"); + await page.close(); + }); + + test("a missing value says \"Not observed\" by default, or the app's own words, in tertiary ink with no mark", async () => { + const page = await open(FACTS); + const info = await page.evaluate(() => { + const dd = (id) => document.querySelector(`#line #${id} dd`); + const p = dd("i1"); + return { observed: dd("i2").textContent, own: dd("i3").textContent, same: getComputedStyle(dd("i2")).color === getComputedStyle(dd("i3")).color, differs: getComputedStyle(dd("i3")).color !== getComputedStyle(p).color, mono: dd("i3").hasAttribute("data-mono"), missing: dd("i3").hasAttribute("data-missing") }; + }); + assert.equal(info.observed, "Not observed"); + assert.equal(info.own, "None yet"); + assert.ok(info.same, "the same ink for both"); + assert.ok(info.differs, "not the value's primary ink"); + assert.equal(info.mono, false); + assert.equal(info.missing, true); + assert.deepEqual(await axe(page), []); + await page.close(); + }); +}); + +// ---- CodeBlock wrap ---- + +const CMD = "deploy --project storefront-web --region us-east-2 --image registry.example.com/web:2.4.1 --replicas 3 --confirm"; +const LONG = "x".repeat(90); +const CODE = `${PAGE} +createRoot(document.getElementById("root")).render( +
    + + + + +
    +);`; + +describe("CodeBlock wrap", () => { + test("a long line breaks at spaces only: every word is whole on one line, and the block does not scroll", async () => { + const page = await open(CODE, { width: 390 }); + const info = await page.evaluate(() => { + const read = (sel) => { + const pre = document.querySelector(`${sel} .basalt-code-pre`); + const words = [...pre.querySelectorAll(".basalt-code-word")]; + return { scrolls: pre.scrollWidth > pre.clientWidth + 1, split: words.filter((w) => w.getClientRects().length !== 1).map((w) => w.textContent), lines: Math.round(pre.querySelector("code").getBoundingClientRect().height / 20), text: pre.textContent }; + }; + return { prompt: read(".w-prompt"), plain: read(".w-plain"), scroll: read(".scroll"), long: read(".w-long") }; + }); + assert.equal(info.prompt.scrolls, false); + assert.deepEqual(info.prompt.split, [], "no word breaks inside, after a hyphen, a slash or a dot"); + assert.ok(info.prompt.lines >= 3, `wrapped onto ${info.prompt.lines} lines`); + assert.equal(info.plain.scrolls, false); + assert.deepEqual(info.plain.split, []); + assert.ok(info.plain.text.includes("--image registry.example.com/web:2.4.1"), "the text is the code"); + assert.equal(info.scroll.scrolls, true, "without wrap it scrolls, as shipped"); + assert.equal(info.scroll.lines, 1); + assert.equal(info.long.scrolls, true, "a word longer than the line still scrolls"); + assert.deepEqual(info.long.split, []); + await page.close(); + }); + + test("with no prompt a wrapped line's continuation is indented 2ch, an empty line keeps its height, and beside a prompt the continuation starts at the text's edge", async () => { + const page = await open(CODE, { width: 390 }); + const info = await page.evaluate(() => { + const row = document.querySelector(".w-plain .basalt-code-row"); + const words = [...row.querySelectorAll(".basalt-code-word")]; + const first = words[0].getBoundingClientRect(); + const later = words.find((w) => w.getBoundingClientRect().top > first.top + 10).getBoundingClientRect(); + const ch = (() => { const s = document.createElement("span"); s.textContent = "0"; row.append(s); const w = s.getBoundingClientRect().width; s.remove(); return w; })(); + const rows = [...document.querySelectorAll(".w-plain .basalt-code-row")].map((r) => r.getBoundingClientRect().height); + const text = [...document.querySelector(".w-prompt .basalt-code-text").querySelectorAll(".basalt-code-word")]; + const t0 = text[0].getBoundingClientRect(); + const t1 = text.find((w) => w.getBoundingClientRect().top > t0.top + 10).getBoundingClientRect(); + return { indent: later.left - first.left, ch, empty: rows[1], prompt: t1.left - t0.left }; + }); + assert.ok(Math.abs(info.indent - 2 * info.ch) < 0.5, `indent ${info.indent}, 2ch ${2 * info.ch}`); + assert.equal(info.empty, 20, "an empty line keeps its line"); + assert.ok(Math.abs(info.prompt) < 0.5, "beside a prompt the continuation is on the text's edge"); + await page.close(); + }); +}); + +// ---- Select toolbar ---- + +const SELECTS = `${PAGE} +const STATUS = [{ value: "any", label: "Any status" }, { value: "open", label: "Open" }, { value: "waiting", label: "Waiting on customer" }]; +function App() { + const [v, setV] = React.useState("open"); + window.setStatus = setV; + return ( +
    +
    + + +
    +
    + ]} /> +
    + ); +} +createRoot(document.getElementById("root")).render();`; + +describe("Select toolbar", () => { + test("as wide as its widest option, whatever is chosen; it fills a narrower column and cuts; in FilterToolbar it fills its column under 720", async () => { + const page = await open(SELECTS); + const read = () => page.evaluate(() => { const t = [...document.querySelectorAll("#row .basalt-select-trigger")].map((el) => el.getBoundingClientRect()); return { w: t[0].width, next: t[1].left }; }); + const a = await read(); + await page.evaluate(() => window.setStatus("waiting")); + await settle(page); + const b = await read(); + await page.evaluate(() => window.setStatus("any")); + await settle(page); + const c = await read(); + assert.equal(b.w, a.w); + assert.equal(c.w, a.w); + assert.equal(b.next, a.next, "choosing moves nothing after it"); + assert.ok(a.w < 300, `not stretched: ${a.w}`); + const name = await page.locator("#row .basalt-select-trigger").first().evaluate((el) => el.textContent); + assert.ok(name.includes("Any status")); + const narrow = await page.evaluate(() => { const t = document.querySelector("#narrow .basalt-select-trigger"); const v = t.querySelector(".basalt-select-value"); return { w: t.getBoundingClientRect().width, cut: v.scrollWidth > v.clientWidth, ellipsis: getComputedStyle(v).textOverflow }; }); + assert.equal(narrow.w, 120); + assert.ok(narrow.cut); + assert.equal(narrow.ellipsis, "ellipsis"); + // The sizers are hidden from assistive technology and the trigger's name is the value alone. + assert.deepEqual(await axe(page), []); + await page.close(); + const phone = await open(SELECTS, { width: 390, ...COARSE }); + const fill = await phone.evaluate(() => { const t = document.querySelector(".basalt-filter-toolbar .basalt-select-trigger"); return [t.getBoundingClientRect().width, t.closest(".basalt-filter-toolbar-filter").getBoundingClientRect().width]; }); + assert.equal(fill[0], fill[1]); + await phone.close(); + }); +}); + +// ---- The form dialog's body ---- + +const DIALOG = `${PAGE} +createRoot(document.getElementById("root")).render( + + + Reply + + They see this by email. +
    Looking into it
    + +
    + Cancel} /> +
    +
    +);`; + +describe("Form dialog body", () => { + test("a block between the description and the first field sits space-4 above the label; the description keeps space-5 under it", async () => { + const page = await open(DIALOG); + const gaps = await page.evaluate(() => { + const r = (el) => el.getBoundingClientRect(); + const desc = r(document.getElementById("desc")); + const ready = r(document.getElementById("ready")); + const label = r(document.querySelector("#f .basalt-field-label, #f label")); + return [ready.top - desc.bottom, label.top - ready.bottom]; + }); + assert.deepEqual(gaps.map(Math.round), [20, 16]); + await page.close(); + }); +}); diff --git a/tools/review/build.mjs b/tools/review/build.mjs index ae4e44e9..ab30db71 100644 --- a/tools/review/build.mjs +++ b/tools/review/build.mjs @@ -380,7 +380,8 @@ for (const id of rounds) { } // Round 34: every element that marks itself `data-wt-force="hover"` or `"focus"` is held in that state with Chromium's forced // pseudo-classes (no pointer or key is needed), so one page can show many parts hovered and focused at once. - if (id === "34") { + // Round 56 (and any later round) marks its own held rows the same way. + if (id === "34" || (Number(id) >= 56 && (await page.locator("[data-wt-force]").count()) > 0)) { await page.waitForTimeout(700); // The movement readouts click each control through in turn: the shot waits until every one has written its answer. await page.waitForFunction(() => ![...document.querySelectorAll("[data-wt-movement]")].some((el) => el.textContent === "measuring"), undefined, { timeout: 60000 }); diff --git a/tools/review/round56.tsx b/tools/review/round56.tsx new file mode 100644 index 00000000..77dd0cbb --- /dev/null +++ b/tools/review/round56.tsx @@ -0,0 +1,517 @@ +// Round 56: lists and facts (cimip-gaps-2, batch B6). Found by building CIMIP on Basalt; every part here is general and shown in at least two unlike domains +// (a support inbox, a build pipeline, a shared document, a team chat). Synthetic data only. Decided and built by Opus on the no-council path (DECISIONS 226 and 265); +// Astra reviews the code and the lead checks the pixels; nothing here has been reviewed yet. The described-menu step is the owner's call and ships nothing: its +// three options are pictures (unlayered demo CSS on purpose, so the option can override `@layer basalt`). +// States: `focus` and `hover` hold a row with Chromium's forced pseudo-classes (`data-wt-force`); `open` opens the step's dialog or menus; each may end in +// `-forced-colours` or `-reduced-motion`. + +import * as React from "react"; + +import { + Avatar, + Badge, + Button, + Card, + CodeBlock, + DescriptionItem, + DescriptionList, + Dialog, + DialogActions, + DialogClose, + DialogContent, + DialogDescription, + DialogTitle, + DialogTrigger, + Field, + FilterToolbar, + Form, + Input, + Menu, + MenuContent, + MenuRadioGroup, + MenuRadioItem, + MenuTrigger, + PanelList, + PanelRow, + SelectableItem, + SelectableList, + Select, + SelectionBar, + SheetBody, + SheetFooter, + SheetHeader, + Text, + Textarea, +} from "../../packages/react/src/index"; +import type { Round } from "./rounds"; + +const kindOf = (state: string) => state.replace(/-(reduced-motion|forced-colours)$/, ""); +const stack: React.CSSProperties = { display: "flex", flexDirection: "column", gap: "var(--basalt-space-3)", minWidth: 0 }; +const pair: React.CSSProperties = { display: "grid", gridTemplateColumns: "repeat(auto-fit, minmax(min(100%, 340px), 1fr))", gap: "var(--basalt-space-8)", alignItems: "start" }; +const Caption = ({ children }: { children: React.ReactNode }) => {children}; + +// ---- 1. PanelList ---- + +const REQUESTS = [ + { id: "r-2201", title: "Refund for a duplicate charge on the annual plan", from: "Juno Halvorsen · Billing", time: "9:42 AM", status: "warning" as const, word: "Waiting" }, + { id: "r-2198", title: "Can't sign in after changing my email", from: "Teodor Vance · Accounts", time: "8:15 AM", status: "danger" as const, word: "Overdue" }, + { id: "r-2190", title: "Export to CSV drops the last column", from: "Mira Okafor · Reports", time: "Yesterday", status: "success" as const, word: "Answered" }, +]; +const BUILDS = [ + { id: "b-981", title: "main · Bump the image cache to 30 days", detail: "Checks, unit tests and the browser suite", time: "4m 12s", status: "success" as const, word: "Passed" }, + { id: "b-980", title: "release/2.4 · Pin the font loader", detail: "The browser suite is running", time: "2m 50s", status: "warning" as const, word: "Running" }, + { id: "b-979", title: "feature/search-index · Rebuild the index nightly instead of on every write to the store", detail: "Unit tests failed in search/index.test.ts", time: "11m 03s", status: "danger" as const, word: "Failed" }, +]; + +function Panels({ state }: { state: string }) { + const kind = kindOf(state); + return ( +
    +
    + A support inbox: each request is one link across its band. +

    Open requests

    + + {REQUESTS.map((r, i) => ( + {r.word}} data-wt-force={i === 1 && kind === "focus" ? "focus" : i === 0 && kind === "hover" ? "hover" : undefined} /> + ))} + +
    +
    + A build pipeline: rows are buttons that open a build's log; the last is cut and still read whole. + + {BUILDS.map((b) => ( + {b.word}} onClick={() => {}} /> + ))} + + +
    +
    + ); +} + +// ---- 2. SelectableList ---- + +const ASKING = [ + { id: "u1", name: "Ada Byrne", detail: "Design · asked to edit", time: "2 min ago" }, + { id: "u2", name: "Kofi Mensah", detail: "Finance · asked to comment", time: "6 min ago" }, + { id: "u3", name: "Lena Ishikawa", detail: "Legal · asked to edit", time: "14 min ago" }, + { id: "u4", name: "Rafael Ortiz", detail: "Sales · asked to view", time: "31 min ago" }, +]; +const QUEUE = [ + { id: "m1", name: "#launch-planning", detail: "Weekly summary, scheduled for Monday" }, + { id: "m2", name: "#design-review", detail: "Reminder to vote on the new icons" }, + { id: "m3", name: "#support", detail: "Holiday hours for the help desk" }, +]; + +function Selectable({ state }: { state: string }) { + const kind = kindOf(state); + const [asking, setAsking] = React.useState(kind === "all" ? ASKING.map((a) => a.id) : kind === "none" ? [] : ["u1", "u3"]); + const [done, setDone] = React.useState>(() => new Set(kind === "done" ? ["u2"] : [])); + const [queued, setQueued] = React.useState(["m2"]); + const open = ASKING.filter((a) => !done.has(a.id)).map((a) => a.id); + const n = asking.filter((id) => open.includes(id)).length; + return ( +
    +
    + A shared document: people asking for access. The bar sticks to the top of its scroller. + + `${c} of ${t} chosen`}> + + + + } + > + {ASKING.map((a) => ( + + + + + {a.name} + {done.has(a.id) ? "Answered" : a.detail} + + {a.time} + + + ))} + + +
    +
    + A team chat: scheduled messages, the bar under the rows (as at the foot of a sheet). + + q.id)} + value={queued} + onValueChange={setQueued} + barSide="bottom" + bar={ + + + + } + > + {QUEUE.map((q) => ( + + + {q.name} + {q.detail} + + + ))} + + +
    +
    + ); +} + +// ---- 3. DescriptionList narrow="line", and missing words ---- + +function Facts() { + const column: React.CSSProperties = { width: 320, maxWidth: "100%", padding: "var(--basalt-space-4)" }; + return ( +
    +
    + A build, stacked (the default under 480). + + + release/2.4 + Priya Raman + + None yet + + +
    +
    + The same facts, narrow="line": one row each. + + + release/2.4 + Priya Raman + + None yet + + +
    +
    + A support request, narrow="line", with a value of several lines. + + + Annual plan since Mar 2024, ]} /> + No one + No issue linked + Today, 9:42 AM + + +
    +
    + ); +} + +// ---- 4. CodeBlock wrap ---- + +const DEPLOY = "deploy --project storefront-web --region us-east-2 --image registry.example.com/web:2.4.1 --replicas 3 --confirm"; +const MIGRATE = "psql \"$DATABASE_URL\" --set ON_ERROR_STOP=1 --file migrations/2026-11-22-add-order-index.sql"; + +function Code() { + return ( +
    +
    + A command to approve, as shipped: it scrolls sideways. + + wrap: it breaks at spaces only, so every flag and the image name stay whole. + +
    +
    + wrap with no prompt: a continuation is indented 2ch, so it never reads as a new line. + +
    +
    + ); +} + +// ---- 5. Select toolbar ---- + +const STATUS = [{ value: "any", label: "Any status" }, { value: "open", label: "Open" }, { value: "waiting", label: "Waiting on customer" }, { value: "closed", label: "Closed" }]; +const OWNER = [{ value: "anyone", label: "Anyone" }, { value: "me", label: "Assigned to me" }, { value: "none", label: "No one" }]; +const BRANCH = [{ value: "all", label: "All branches" }, { value: "main", label: "main" }, { value: "release", label: "release/2.4" }]; +const RESULT = [{ value: "any", label: "Any result" }, { value: "passed", label: "Passed" }, { value: "failed", label: "Failed" }]; + +function Toolbars() { + return ( +
    +
    + A support inbox: a search and two selects share one row; each select is as wide as its widest option. + } filter={[]} /> +
    +
    + A build pipeline: the same, in a plain row. Choosing "release/2.4" moves nothing after it. +
    + + +
    +
    +
    + Before: a Select fills its container, so two cannot share a row. +
    + +
    +
    +
    + ); +} + +// ---- 6. The form dialog's body ---- + +function Reply({ open, domain }: { open: boolean; domain: "support" | "doc" }) { + const [text, setText] = React.useState(""); + const words = domain === "support" + ? { opener: "Reply", title: "Reply to Juno Halvorsen", description: "They see this by email and on the request's page. Internal notes stay hidden.", ready: [["Looking into it", "Thanks for the details. I'm looking into the duplicate charge now."], ["Refund sent", "The refund is on its way and shows in 5 to 10 business days."]], label: "Message", send: "Send reply" } + : { opener: "Comment", title: "Comment on “Q1 plan”", description: "Everyone who can view the document sees the comment beside the paragraph.", ready: [["Approve", "Approved from my side."], ["Needs a source", "Can we add a source for this number?"]], label: "Comment", send: "Post comment" }; + return ( + + {words.opener}} /> + + {words.title} + + {words.description} +
    + {words.ready.map(([label, sentence]) => )} +
    +
    e.preventDefault()}> +