@supersuit/components 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,14 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.3.0 (2026-12-02)
4
+
5
+ The first four components of the component library adoption and desktop superarchitecture, built from the specs approved 2026-12-02 with every open-question recommendation taken.
6
+
7
+ - **row** (`@supersuit/components/row`): `Row`, `RowList` and `Fold`. One target per row (a link, else a button), an optional `action` beside it, pressed (dropped by a drag past 10 px), selected (`aria-current="page"`), unread, two title lines on a phone and one from 1024 px, and a fold with `aria-expanded` and `aria-controls`.
8
+ - **choice-chips** (`@supersuit/components/choice-chips`): `ChoiceChips` in two modes. Pick several: `aria-pressed` toggle chips with a tick. Pick one: a segmented `radiogroup` with roving focus and arrow keys that skip disabled options, a second tap that clears only an optional question, and a measured switch to wrapping chips when the track does not fit. Every chip at least 44 px tall.
9
+ - **page-header** (`@supersuit/components/page-header`): `PageHeader`. The phone back row with the title under it, a floating Back driven by `@supersuit/home-screen-app`'s `backReveal` (passed in), a More menu with Suggest a change and My suggestions at the bottom, and inside the app shell from 1024 px a 72 px title row with no Back, a detail-pane `h2`, a round icon action in the narrow list pane so its title keeps its room, and a "‹ Parent" crumb on a deeper screen. Also `ShellContext`, `useDesktop` and `DESKTOP_QUERY`.
10
+ - **app-shell** (`@supersuit/components/app-shell`): `AppShell`, `ShellSheet` and `HomeColumns`. A 30rem phone column below 1024 px; from 1024 px a 240 px side menu drawn from the tile list (filled and outlined counts, off tiles left out, the More folder only while it waits) and a single 52rem page or a 360 px list beside its open item. A sheet becomes a centred 560 px dialog that traps focus. The skip link comes first; opening an item moves focus to its heading.
11
+
3
12
  ## 0.2.0 (2026-12-01)
4
13
 
5
14
  Brand themes, one sound engine, a measured depth check and the `@supersuit` registry. Approved in the component library on shadcn superarchitecture (2026-12-01). The first version on npm; 0.1.0 was never published.
package/README.md CHANGED
@@ -16,6 +16,10 @@ import '@supersuit/components/voice-field/styles.css'
16
16
  | Component | Import | Spec |
17
17
  | --- | --- | --- |
18
18
  | Voice field: one text box that can also be spoken | `@supersuit/components/voice-field` | [specs/voice-field](specs/voice-field/SPEC.md) |
19
+ | Row: one line in a list, and the fold that groups rows | `@supersuit/components/row` | [specs/row](specs/row/SPEC.md) |
20
+ | Choice chips: pick one or pick several, as pills | `@supersuit/components/choice-chips` | [specs/choice-chips](specs/choice-chips/SPEC.md) |
21
+ | Page header: Back, the screen's name and More | `@supersuit/components/page-header` | [specs/page-header](specs/page-header/SPEC.md) |
22
+ | App shell: a phone column, or a side menu and a wide main area from 1024 px | `@supersuit/components/app-shell` | [specs/app-shell](specs/app-shell/SPEC.md) |
19
23
 
20
24
  `test/library.test.ts` refuses a component that is missing its spec, its mockup, its conformance test, its subpath export or its place in the `components` list.
21
25
 
@@ -137,6 +141,89 @@ To restyle, set the variables: `--vf-ground`, `--vf-card`, `--vf-field`, `--vf-t
137
141
 
138
142
  An app with its own CSS can skip `styles.css` and pass classes instead (`className`, `classNames`). Supertools does this.
139
143
 
144
+ ## Row
145
+
146
+ One line in a list: an optional picture, a title, a quieter second line, and one end item (a count, a chevron or a time). A `Fold` groups rows, says how many it holds, and opens or closes. The spec is [specs/row/SPEC.md](specs/row/SPEC.md).
147
+
148
+ ```tsx
149
+ import { Row, RowList, Fold } from '@supersuit/components/row'
150
+ import '@supersuit/components/row/styles.css'
151
+
152
+ <RowList>
153
+ <Row href="/meetings/1" title="Weekly sync" second="Ada and Bo, 45 minutes" lead={{ initials: 'AB' }} end={{ time: 'Tue' }} unread />
154
+ </RowList>
155
+ <Fold label="Done" count={2} open={open} onToggle={setOpen}>
156
+ <Row href="/x" title="Rent" end={{ chevron: true }} />
157
+ </Fold>
158
+ ```
159
+
160
+ - The whole row is one target: a link with `href` (`linkAs` takes Next.js `Link`), else a button. `action` draws an optional button beside it, never inside it.
161
+ - `selected` sets `aria-current="page"`; use it only in a desktop list beside its detail. `unread` adds the dot and "Unread" before the name. A count is read as "{n} waiting".
162
+ - A title takes two lines on a phone and one from 1024 px or in a `look="pane"` list (`titleLines` overrides). The colours are the theme roles a compiled brand theme sets (`.theme-maison-dawn`, `.theme-maison-night`); with no theme, Maison Dawn.
163
+ - `test/row/conformance.test.tsx` renders every state in both themes.
164
+
165
+ ## Choice chips
166
+
167
+ Pick one or pick several, as pills, every chip at least 44 px tall. The spec is [specs/choice-chips/SPEC.md](specs/choice-chips/SPEC.md).
168
+
169
+ ```tsx
170
+ import { ChoiceChips } from '@supersuit/components/choice-chips'
171
+ import '@supersuit/components/choice-chips/styles.css'
172
+
173
+ <ChoiceChips mode="several" label="Category" optional options={[{ value: 'meals', label: 'Meals' }]} value={tags} onChange={setTags} />
174
+ <ChoiceChips mode="one" label="Paid with" required options={[{ value: 'me', label: 'I paid' }, { value: 'company', label: 'The company paid' }]} value={paid} onChange={setPaid} />
175
+ ```
176
+
177
+ - **Pick several** is a `role="group"` of `aria-pressed` buttons. A chosen chip is filled and carries a tick. A disabled option stays focusable, is `aria-disabled`, and is described by the help line.
178
+ - **Pick one** is a `role="radiogroup"`: one option in the tab order, arrow keys move the choice and skip disabled options. A second tap clears an `optional` question, never a `required` one.
179
+ - A track that does not fit its container draws as wrapping chips with the same radio semantics. The switch is measured with a `ResizeObserver`; `layout="track"` or `"wrap"` forces one form.
180
+ - `onChange` runs on every tap. There is no Apply button.
181
+
182
+ ## Page header
183
+
184
+ The top of every screen below the home: Back, the screen's name, and the three-dots More menu with Suggest a change. The spec is [specs/page-header/SPEC.md](specs/page-header/SPEC.md).
185
+
186
+ ```tsx
187
+ import * as homeScreen from '@supersuit/home-screen-app' // backReveal and backRevealAt
188
+ import { PageHeader } from '@supersuit/components/page-header'
189
+ import '@supersuit/components/page-header/styles.css'
190
+
191
+ <PageHeader title="Lunch with Ada" back={{ href: '/expenses', label: 'Expenses' }} backReveal={homeScreen}
192
+ actions={[{ label: 'Edit', icon: <Pencil /> }]} onSuggest={openSuggest} onMySuggestions={openMine} />
193
+ ```
194
+
195
+ - **Back is a link to a fixed parent**, named "Back to {parent}", never `history.back()`.
196
+ - **On a phone** (and at every width outside the app shell): the 44 px back row, then the title under it. The floating Back is drawn only while `backReveal` says it is shown. It follows the page and any scroller at least 60% of the window tall.
197
+ - **On a desktop inside the app shell** (1024 px and up): a 72 px title row with no Back. Each action is a filled pill with its word. `pane="detail"` makes the item title an `h2`; `pane="list"` keeps the screen's `h1`. `deep` adds the "‹ Parent" crumb.
198
+ - **More** is a menu button: the app's `menu` items, then Suggest a change and My suggestions. Arrow keys move, Enter picks, Escape closes and returns focus to More. `signedIn={false}` drops it.
199
+ - The shell's state (`ShellContext`, `useDesktop`, `DESKTOP_QUERY`) is exported here too. The app shell provides it.
200
+ - `@supersuit/home-screen-app` is not a dependency of this package, so the app passes its rule in. Without `backReveal`, nothing floats.
201
+
202
+ ## App shell
203
+
204
+ The page frame every app sits in. Below 1024 px it is one phone column, at most 30rem, with safe-area padding. From 1024 px (measured on the window) it is a 240 px side menu and a wide main area. The spec is [specs/app-shell/SPEC.md](specs/app-shell/SPEC.md).
205
+
206
+ ```tsx
207
+ import { AppShell, ShellSheet } from '@supersuit/components/app-shell'
208
+ import '@supersuit/components/app-shell/styles.css'
209
+
210
+ const tiles = [
211
+ { id: 'waiting', name: 'Waiting on you', href: '/waiting', icon: <Inbox />, count: 3, waiting: true },
212
+ { id: 'meetings', name: 'Meetings', href: '/meetings', icon: <Calendar />, count: 12 },
213
+ ]
214
+
215
+ <AppShell appName="Cofounders" tiles={tiles} current="meetings" person={{ name: 'Ada Lovelace' }}
216
+ layout="list-detail" thing="meeting" listLabel="Meetings" list={<RowList look="pane">...</RowList>}
217
+ detailLabel={item?.title} detailHeader={item && <PageHeader pane="detail" title={item.title} back={{ href: '/meetings' }} />}
218
+ detail={item && <Meeting item={item} />} />
219
+ ```
220
+
221
+ - **The shell draws the side menu from `tiles`**, the same list the launcher reads: icon, name, count. A filled count waits on this person (`waiting`); an outlined one is a plain total. `off` tiles are left out. `folder: 'more'` tiles show under the separator only while something in them waits. `extra` holds app-wide entries such as Search.
222
+ - **A screen declares its layout:** `single` (one page, at most 52rem) or `list-detail` (a 360 px list and a detail pane whose text is at most 44rem). On a phone, the open item shows alone. When another item opens, focus goes to the detail pane's heading.
223
+ - **`ShellSheet`** is a sheet on a phone and a centred 560 px dialog from 1024 px, with the same content. Escape, the scrim and Close close it. It traps focus and gives it back.
224
+ - `HomeColumns` sets the home's sections side by side on a desktop. `grow` lets a screen widen to 44rem from 768 px inside the phone column.
225
+ - "Skip to content" is the first focusable item. The layout is plain CSS media queries, so it works in Next.js and Vite apps alike; the same 1024 px query, read in script, tells the page header and the sheet which form to take.
226
+
140
227
  ## Brand themes: `@supersuit/components/theme` and `supersuit-theme`
141
228
 
142
229
  A brand theme is one JSON record in the `brand-theme/v1` format: colours, type, corner, depth, sounds and the depth bar. The spec is [specs/brand-theme/v1/SPEC.md](specs/brand-theme/v1/SPEC.md). It ships in the package at the same path, and it has no public URL yet. Maison's records are `themes/maison-dawn.theme.json` and `themes/maison-night.theme.json`. `fixtures/garden/garden.theme.json` is an invented brand that proves any brand works.
@@ -226,6 +313,7 @@ npm run build # dist/, checked by scripts/check-dist.mjs
226
313
  npm run check:consumer # packs the tarball, installs it under .tmp/, imports each subpath
227
314
  bash scripts/mutate.sh # breaks each voice-field rule on purpose; every line must say "caught"
228
315
  npx vite demo/voice-field # the five states, live, in both themes
316
+ npx vite demo/app-shell # also demo/row, demo/choice-chips, demo/page-header: every state, both themes
229
317
  ```
230
318
 
231
319
  ## Contributing
@@ -0,0 +1,68 @@
1
+ import { type ElementType, type ReactNode } from 'react';
2
+ export interface ShellTile {
3
+ id: string;
4
+ name: string;
5
+ href: string;
6
+ icon: ReactNode;
7
+ /** A number, never a word from inside the tile. */
8
+ count?: number;
9
+ /** The count is something waiting on this person (filled); else it is a plain total (outlined). */
10
+ waiting?: boolean;
11
+ /** A tile from the More folder: shown at the end, under the separator, only while something in it waits. */
12
+ folder?: 'more';
13
+ /** Off for this app: not in the side menu. */
14
+ off?: boolean;
15
+ }
16
+ export interface AppShellWords {
17
+ skip: string;
18
+ emptyTitle: string;
19
+ emptyLine: (thing: string) => string;
20
+ close: string;
21
+ /** A count's screen-reader text. A plain total is read as the number alone. */
22
+ waiting: (n: number) => string;
23
+ }
24
+ export declare const defaultAppShellWords: AppShellWords;
25
+ export interface AppShellProps {
26
+ appName: string;
27
+ /** The app's mark in the side menu. Default: the first letter of its name. */
28
+ mark?: ReactNode;
29
+ /** The home's tiles, in the home's order: the same list the launcher reads. */
30
+ tiles: ShellTile[];
31
+ /** The id of the tile this screen belongs to. */
32
+ current?: string;
33
+ /** App-wide entries under the separator (Search). */
34
+ extra?: ShellTile[];
35
+ /** The signed-in person, at the foot of the side menu. */
36
+ person?: {
37
+ name: string;
38
+ initials?: string;
39
+ };
40
+ /** `single` (default): one page. `list-detail`: a list beside its open item. */
41
+ layout?: 'single' | 'list-detail';
42
+ /** The page, for a single screen. */
43
+ children?: ReactNode;
44
+ /** List and detail: the list pane, its header (a PageHeader with pane="list"), and its name. */
45
+ list?: ReactNode;
46
+ listHeader?: ReactNode;
47
+ listLabel?: string;
48
+ /** List and detail: the open item's body, its header (a PageHeader with pane="detail"), and its name. Absent: nothing open. */
49
+ detail?: ReactNode;
50
+ detailHeader?: ReactNode;
51
+ detailLabel?: string;
52
+ /** Changes when another item opens: focus then goes to the detail pane's heading. Default: detailLabel. */
53
+ detailKey?: string;
54
+ /** What the list holds, for "Pick a {thing} on the left to see it here." */
55
+ thing?: string;
56
+ /** Let this screen grow to 44rem from 768 px, inside the phone column. */
57
+ grow?: boolean;
58
+ /** The link component, e.g. Next.js `Link`. Default `a`. */
59
+ linkAs?: ElementType;
60
+ words?: Partial<AppShellWords>;
61
+ className?: string;
62
+ }
63
+ export declare function AppShell(p: AppShellProps): import("react").JSX.Element;
64
+ /** The home on a desktop: its sections side by side as columns. On a phone they stack. */
65
+ export declare function HomeColumns({ children, className }: {
66
+ children: ReactNode;
67
+ className?: string;
68
+ }): import("react").JSX.Element;
@@ -0,0 +1,62 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // THE PAGE FRAME EVERY APP SITS IN (spec approved 2026-12-02). Below 1024 px: one phone column, at most 30rem,
4
+ // centred, with safe-area padding. From 1024 px (measured on the window): a 240 px side menu drawn from the app's
5
+ // tile list, and a wide main area holding one page (at most 52rem) or a 360 px list beside its open item. The layout
6
+ // is CSS (media queries), so it is right on the first paint in Next.js and Vite alike; the same 1024 px query, read
7
+ // in script, tells the parts inside (the page header, a sheet) which form to take.
8
+ import { useEffect, useId, useRef } from 'react';
9
+ import { ShellContext, useDesktop } from '../page-header/shell-context.js';
10
+ export const defaultAppShellWords = {
11
+ skip: 'Skip to content',
12
+ emptyTitle: 'Nothing open',
13
+ emptyLine: (thing) => `Pick a ${thing} on the left to see it here.`,
14
+ close: 'Close',
15
+ waiting: (n) => `${n} waiting`,
16
+ };
17
+ function NavItem({ t, current, Link, w }) {
18
+ const on = t.id === current;
19
+ const has = typeof t.count === 'number' && t.count > 0;
20
+ const name = has ? `${t.name}, ${t.waiting ? w.waiting(t.count) : String(t.count)}` : t.name;
21
+ return (_jsx("li", { children: _jsxs(Link, { href: t.href, className: "ss-shell-nav-link", "aria-current": on ? 'page' : undefined, "aria-label": name, children: [_jsx("span", { className: "ss-shell-nav-icon", "aria-hidden": "true", children: t.icon }), _jsx("span", { className: "ss-shell-nav-name", children: t.name }), has && _jsx("span", { className: "ss-shell-count", "data-waiting": t.waiting ? '' : undefined, "aria-hidden": "true", children: t.count })] }) }));
22
+ }
23
+ export function AppShell(p) {
24
+ const w = { ...defaultAppShellWords, ...p.words };
25
+ const desktop = useDesktop();
26
+ const Link = p.linkAs ?? 'a';
27
+ const mainId = `ss-shell-main-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
28
+ const main = useRef(null);
29
+ const detailPane = useRef(null);
30
+ const home = p.tiles.filter((t) => !t.off && t.folder !== 'more');
31
+ const folder = p.tiles.filter((t) => !t.off && t.folder === 'more' && t.waiting && (t.count ?? 0) > 0);
32
+ const after = [...(p.extra ?? []).filter((t) => !t.off), ...folder];
33
+ // Opening another item moves focus to the detail pane's heading; the list keeps its scroll position.
34
+ const key = p.detailKey ?? p.detailLabel;
35
+ const firstKey = useRef(true);
36
+ useEffect(() => {
37
+ if (firstKey.current) {
38
+ firstKey.current = false;
39
+ return;
40
+ }
41
+ if (key == null)
42
+ return;
43
+ const h = detailPane.current?.querySelector('h1, h2, h3');
44
+ if (!h)
45
+ return;
46
+ if (!h.hasAttribute('tabindex'))
47
+ h.setAttribute('tabindex', '-1');
48
+ h.focus({ preventScroll: true });
49
+ }, [key]);
50
+ const skip = (e) => { e.preventDefault(); main.current?.focus(); };
51
+ const open = p.detail != null;
52
+ const layout = p.layout ?? 'single';
53
+ return (_jsx(ShellContext.Provider, { value: { inShell: true, desktop, appName: p.appName }, children: _jsxs("div", { className: ['ss-shell', p.className].filter(Boolean).join(' '), "data-desktop": desktop ? '' : undefined, "data-grow": p.grow ? '' : undefined, children: [_jsx("a", { className: "ss-shell-skip", href: `#${mainId}`, onClick: skip, children: w.skip }), _jsxs("nav", { className: "ss-shell-side", "aria-label": p.appName, children: [_jsxs("div", { className: "ss-shell-app", children: [_jsx("span", { className: "ss-shell-mark", "aria-hidden": "true", children: p.mark ?? p.appName.slice(0, 1) }), _jsx("span", { className: "ss-shell-app-name", children: p.appName })] }), _jsx("ul", { className: "ss-shell-nav", children: home.map((t) => _jsx(NavItem, { t: t, current: p.current, Link: Link, w: w }, t.id)) }), after.length > 0 && _jsxs(_Fragment, { children: [_jsx("div", { className: "ss-shell-sep", role: "presentation" }), _jsx("ul", { className: "ss-shell-nav", children: after.map((t) => _jsx(NavItem, { t: t, current: p.current, Link: Link, w: w }, t.id)) })] }), p.person && (_jsxs("div", { className: "ss-shell-who", children: [_jsx("span", { className: "ss-shell-who-av", "aria-hidden": "true", children: p.person.initials ?? p.person.name.slice(0, 1) }), _jsx("span", { children: p.person.name })] }))] }), _jsxs("main", { ref: main, id: mainId, tabIndex: -1, className: "ss-shell-main", "data-layout": layout, children: [layout === 'single'
54
+ ? _jsx("div", { className: "ss-shell-page", children: p.children })
55
+ : (_jsxs("div", { className: "ss-shell-ld", "data-open": open ? '' : undefined, children: [_jsxs("section", { className: "ss-shell-list", "aria-label": p.listLabel, children: [p.listHeader, _jsx("div", { className: "ss-shell-list-body", children: p.list })] }), _jsx("section", { ref: detailPane, className: "ss-shell-detail", "aria-label": open ? p.detailLabel : w.emptyTitle, children: open
56
+ ? _jsxs(_Fragment, { children: [p.detailHeader, _jsx("div", { className: "ss-shell-detail-body", children: p.detail })] })
57
+ : (_jsxs("div", { className: "ss-shell-empty", children: [_jsx("span", { className: "ss-shell-empty-icon", "aria-hidden": "true", children: _jsxs("svg", { viewBox: "0 0 24 24", width: "30", height: "30", fill: "none", stroke: "currentColor", strokeWidth: "1.7", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("rect", { x: "3", y: "4", width: "18", height: "16", rx: "3" }), _jsx("path", { d: "M9 4v16" })] }) }), _jsx("b", { className: "ss-shell-empty-title", children: w.emptyTitle }), _jsx("p", { children: w.emptyLine(p.thing ?? 'item') })] })) })] })), p.children && layout === 'list-detail' ? p.children : null] })] }) }));
58
+ }
59
+ /** The home on a desktop: its sections side by side as columns. On a phone they stack. */
60
+ export function HomeColumns({ children, className }) {
61
+ return _jsx("div", { className: ['ss-shell-columns', className].filter(Boolean).join(' '), children: children });
62
+ }
@@ -0,0 +1,3 @@
1
+ export { AppShell, HomeColumns, defaultAppShellWords, type AppShellProps, type AppShellWords, type ShellTile } from './app-shell.js';
2
+ export { ShellSheet, SWIPE_CLOSE, type ShellSheetProps } from './sheet.js';
3
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY, type ShellState } from '../page-header/shell-context.js';
@@ -0,0 +1,5 @@
1
+ // @supersuit/components/app-shell: the page frame every app sits in. Import the styles once:
2
+ // import '@supersuit/components/app-shell/styles.css'
3
+ export { AppShell, HomeColumns, defaultAppShellWords } from './app-shell.js';
4
+ export { ShellSheet, SWIPE_CLOSE } from './sheet.js';
5
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY } from '../page-header/shell-context.js';
@@ -0,0 +1,14 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ShellSheetProps {
3
+ open: boolean;
4
+ onClose: () => void;
5
+ /** The overlay's name, drawn at its top. */
6
+ title: string;
7
+ children: ReactNode;
8
+ /** The close button's name. Default "Close". */
9
+ closeLabel?: string;
10
+ className?: string;
11
+ }
12
+ /** A drag down the grab handle past this many pixels closes the sheet. */
13
+ export declare const SWIPE_CLOSE = 80;
14
+ export declare function ShellSheet(p: ShellSheetProps): import("react").JSX.Element | null;
@@ -0,0 +1,57 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // THE SHELL'S OVERLAY: a sheet that rises from the bottom on a phone, and the same content as a centred 560 px dialog
4
+ // from 1024 px. Same content, same order. Escape and a tap on the scrim close it, as a swipe down on the sheet's
5
+ // grab handle does. While open it traps focus; when it closes, focus goes back to whatever opened it.
6
+ import { useEffect, useId, useRef } from 'react';
7
+ import { useDesktop, useShell } from '../page-header/shell-context.js';
8
+ /** A drag down the grab handle past this many pixels closes the sheet. */
9
+ export const SWIPE_CLOSE = 80;
10
+ const FOCUSABLE = 'a[href], button:not([disabled]), input:not([disabled]), select:not([disabled]), textarea:not([disabled]), [tabindex]:not([tabindex="-1"])';
11
+ export function ShellSheet(p) {
12
+ const shell = useShell();
13
+ const windowDesktop = useDesktop();
14
+ const desktop = shell.inShell ? shell.desktop : windowDesktop;
15
+ const titleId = `ss-sheet-title-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
16
+ const panel = useRef(null);
17
+ const drag = useRef(null);
18
+ useEffect(() => {
19
+ if (!p.open)
20
+ return;
21
+ const opener = document.activeElement;
22
+ const first = panel.current?.querySelector(FOCUSABLE);
23
+ (first ?? panel.current)?.focus();
24
+ return () => { if (opener && document.contains(opener))
25
+ opener.focus(); };
26
+ }, [p.open]);
27
+ if (!p.open)
28
+ return null;
29
+ const key = (e) => {
30
+ if (e.key === 'Escape') {
31
+ e.preventDefault();
32
+ p.onClose();
33
+ return;
34
+ }
35
+ if (e.key !== 'Tab')
36
+ return;
37
+ const all = [...(panel.current?.querySelectorAll(FOCUSABLE) ?? [])];
38
+ if (!all.length) {
39
+ e.preventDefault();
40
+ return;
41
+ }
42
+ const first = all[0], last = all[all.length - 1];
43
+ if (e.shiftKey && document.activeElement === first) {
44
+ e.preventDefault();
45
+ last.focus();
46
+ }
47
+ else if (!e.shiftKey && document.activeElement === last) {
48
+ e.preventDefault();
49
+ first.focus();
50
+ }
51
+ };
52
+ const down = (e) => { drag.current = e.clientY; };
53
+ const up = (e) => { if (drag.current != null && e.clientY - drag.current > SWIPE_CLOSE)
54
+ p.onClose(); drag.current = null; };
55
+ const form = desktop ? 'dialog' : 'sheet';
56
+ return (_jsxs("div", { className: "ss-sheet-layer", "data-form": form, children: [_jsx("div", { className: "ss-sheet-scrim", onClick: p.onClose }), _jsxs("div", { ref: panel, role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, tabIndex: -1, className: ['ss-sheet', p.className].filter(Boolean).join(' '), "data-form": form, onKeyDown: key, children: [form === 'sheet' && _jsx("div", { className: "ss-sheet-grab", "aria-hidden": "true", onPointerDown: down, onPointerUp: up }), _jsxs("div", { className: "ss-sheet-head", children: [_jsx("b", { id: titleId, className: "ss-sheet-title", children: p.title }), form === 'dialog' && (_jsx("button", { type: "button", className: "ss-sheet-close", "aria-label": p.closeLabel ?? 'Close', onClick: p.onClose, children: _jsx("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", "aria-hidden": "true", children: _jsx("path", { d: "M6 6l12 12M18 6 6 18" }) }) }))] }), _jsx("div", { className: "ss-sheet-body", children: p.children })] })] }));
57
+ }
@@ -0,0 +1,112 @@
1
+ /* @supersuit/components/app-shell: the page frame every app sits in (spec approved 2026-12-02).
2
+ *
3
+ * One breakpoint: 1024 px, measured on the window (a media query), never on the device. Below it, a phone column at
4
+ * most 30rem wide, centred, with safe-area padding. From it, a 240 px side menu and a wide main area.
5
+ *
6
+ * Every colour is a theme role (--background, --card, --popover, --foreground, --muted-foreground, --border,
7
+ * --secondary, --muted, --accent-ink, --primary, --primary-foreground, --input, --scrim, --ring) and titles use
8
+ * --font-display, as a compiled brand theme names them: put `.theme-maison-dawn` or `.theme-maison-night` on any
9
+ * element above. With no theme, the Maison Dawn values are the fallbacks.
10
+ */
11
+
12
+ .ss-shell {
13
+ position: relative; box-sizing: border-box; min-height: 100vh; min-height: 100dvh;
14
+ background: var(--background, #F3E5D5); color: var(--foreground, #2A231B);
15
+ font-family: var(--font-text, "DM Sans", system-ui, sans-serif);
16
+ }
17
+ .ss-shell :focus { outline: none; }
18
+ .ss-shell :focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: 2px; }
19
+
20
+ .ss-shell-skip {
21
+ position: absolute; z-index: 50; left: 12px; top: 12px; transform: translateY(-200%);
22
+ display: inline-flex; align-items: center; min-height: 44px; padding: 0 16px; border-radius: 999px;
23
+ background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-weight: 600; text-decoration: none;
24
+ }
25
+ .ss-shell-skip:focus, .ss-shell-skip:focus-visible { transform: none; }
26
+
27
+ /* ---------- phone: one column ---------- */
28
+ .ss-shell-side { display: none; }
29
+ .ss-shell-main {
30
+ display: block; box-sizing: border-box; width: 100%; max-width: 30rem; margin: 0 auto;
31
+ padding-top: env(safe-area-inset-top, 0px); padding-bottom: env(safe-area-inset-bottom, 0px);
32
+ }
33
+ @media (min-width: 768px) and (max-width: 1023.98px) {
34
+ .ss-shell[data-grow] .ss-shell-main { max-width: 44rem; }
35
+ }
36
+ /* List and detail on a phone: the open item alone, or the list alone. */
37
+ .ss-shell-ld[data-open] .ss-shell-list { display: none; }
38
+ .ss-shell-ld:not([data-open]) .ss-shell-detail { display: none; }
39
+ .ss-shell-detail-body { box-sizing: border-box; padding: 0 16px 24px; }
40
+ .ss-shell-columns { display: grid; gap: 20px; }
41
+
42
+ /* ---------- the side menu ---------- */
43
+ .ss-shell-app { display: flex; align-items: center; gap: 10px; padding: 4px 12px 18px; font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); }
44
+ .ss-shell-mark { flex: none; width: 30px; height: 30px; border-radius: 9px; display: flex; align-items: center; justify-content: center; background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-family: var(--font-text, "DM Sans", system-ui, sans-serif); font-size: 14px; font-weight: 600; }
45
+ .ss-shell-app-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
46
+ .ss-shell-nav { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
47
+ .ss-shell-nav-link {
48
+ position: relative; box-sizing: border-box; display: flex; align-items: center; gap: 12px; min-height: 44px; padding: 0 10px 0 12px;
49
+ border-radius: 10px; color: var(--foreground, #2A231B); font-size: 15px; text-decoration: none;
50
+ }
51
+ .ss-shell-nav-link:hover { background: var(--muted, #EFE4D6); }
52
+ .ss-shell-nav-link[aria-current="page"] { background: var(--secondary, #EADCC9); font-weight: 600; }
53
+ .ss-shell-nav-link[aria-current="page"]::before { content: ""; position: absolute; left: -12px; top: 10px; bottom: 10px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-ink, #2B3B50); }
54
+ .ss-shell-nav-link:focus-visible { outline-offset: -2px; }
55
+ .ss-shell-nav-icon { flex: none; display: flex; color: var(--accent-ink, #2B3B50); }
56
+ .ss-shell-nav-icon svg { width: 20px; height: 20px; }
57
+ .ss-shell-nav-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
58
+ .ss-shell-count {
59
+ flex: none; box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; min-width: 22px; height: 22px; padding: 0 7px;
60
+ border-radius: 11px; background: none; color: var(--muted-foreground, #665B4D); box-shadow: inset 0 0 0 1px var(--border, #D9CDBB);
61
+ font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums;
62
+ }
63
+ .ss-shell-count[data-waiting] { background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); box-shadow: none; }
64
+ .ss-shell-sep { height: 1px; margin: 10px 12px; background: var(--border, #D9CDBB); }
65
+ .ss-shell-who { margin-top: auto; display: flex; align-items: center; gap: 10px; padding: 8px 12px; font-size: 14px; color: var(--muted-foreground, #665B4D); }
66
+ .ss-shell-who-av { flex: none; width: 30px; height: 30px; border-radius: 50%; display: flex; align-items: center; justify-content: center; background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-size: 13px; font-weight: 600; }
67
+
68
+ /* ---------- the empty detail pane ---------- */
69
+ .ss-shell-empty { flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 10px; padding: 24px; text-align: center; color: var(--muted-foreground, #665B4D); }
70
+ .ss-shell-empty-icon { width: 64px; height: 64px; border-radius: 20px; display: flex; align-items: center; justify-content: center; background: var(--muted, #EFE4D6); color: var(--accent-ink, #2B3B50); }
71
+ .ss-shell-empty-title { font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-weight: var(--display-weight, 400); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); color: var(--foreground, #2A231B); }
72
+ .ss-shell-empty p { margin: 0; max-width: 22rem; font-size: 15px; }
73
+
74
+ /* ---------- the overlay: a sheet on a phone ---------- */
75
+ .ss-sheet-layer { position: fixed; inset: 0; z-index: 40; }
76
+ .ss-sheet-scrim { position: absolute; inset: 0; background: var(--scrim, rgb(42 35 27 / 0.34)); }
77
+ .ss-sheet {
78
+ position: absolute; left: 0; right: 0; bottom: 0; box-sizing: border-box; max-height: 92vh; overflow-y: auto;
79
+ padding: 8px 8px calc(16px + env(safe-area-inset-bottom, 0px)); border-radius: 24px 24px 0 0;
80
+ background: var(--popover, #FAF7F2); color: var(--foreground, #2A231B); box-shadow: 0 -12px 30px -16px rgb(0 0 0 / 0.35);
81
+ }
82
+ .ss-sheet-grab { width: 38px; height: 5px; margin: 4px auto 10px; border-radius: 3px; background: var(--input, #C5B399); touch-action: none; cursor: grab; }
83
+ .ss-sheet-head { display: flex; align-items: center; min-height: 44px; padding: 6px 4px 6px 16px; }
84
+ .ss-sheet-title { flex: 1; font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-weight: var(--display-weight, 400); font-size: 26px; letter-spacing: var(--display-tracking, -0.01em); }
85
+ .ss-sheet-close { flex: none; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; padding: 0; border: 0; border-radius: 50%; background: transparent; color: var(--foreground, #2A231B); cursor: pointer; }
86
+ .ss-sheet-close:hover { background: var(--muted, #EFE4D6); }
87
+ .ss-sheet-body { padding: 0 8px; }
88
+ /* From 1024 px, the same content as a centred dialog. */
89
+ .ss-sheet[data-form="dialog"] {
90
+ left: 50%; right: auto; top: 50%; bottom: auto; width: min(560px, calc(100vw - 32px)); max-height: 86vh; transform: translate(-50%, -50%);
91
+ padding: 8px 8px 16px; border-radius: 18px; box-shadow: 0 0 0 1px var(--border, #D9CDBB), 0 30px 60px -20px rgb(0 0 0 / 0.4);
92
+ }
93
+
94
+ /* ---------- desktop: the side menu and the main area ---------- */
95
+ @media (min-width: 1024px) {
96
+ .ss-shell { display: grid; grid-template-columns: 240px minmax(0, 1fr); height: 100vh; height: 100dvh; }
97
+ .ss-shell-side {
98
+ display: flex; flex-direction: column; gap: 2px; box-sizing: border-box; min-height: 0; overflow-y: auto; padding: 20px 12px;
99
+ background: var(--card, #FAF7F2); border-right: 1px solid var(--border, #D9CDBB);
100
+ }
101
+ .ss-shell-main { max-width: none; margin: 0; padding: 0; min-height: 0; overflow-y: auto; }
102
+ .ss-shell-main[data-layout="list-detail"] { overflow: hidden; }
103
+ .ss-shell-page { max-width: 52rem; margin: 0 auto; padding-bottom: 32px; }
104
+ .ss-shell-ld { display: grid; grid-template-columns: 360px minmax(0, 1fr); height: 100%; }
105
+ .ss-shell-ld .ss-shell-list, .ss-shell-ld[data-open] .ss-shell-list,
106
+ .ss-shell-ld .ss-shell-detail, .ss-shell-ld:not([data-open]) .ss-shell-detail { display: flex; flex-direction: column; min-width: 0; min-height: 0; }
107
+ .ss-shell-list { border-right: 1px solid var(--border, #D9CDBB); }
108
+ .ss-shell-list-body, .ss-shell-detail { overflow-y: auto; }
109
+ .ss-shell-list-body { flex: 1; min-height: 0; }
110
+ .ss-shell-detail-body { max-width: 44rem; padding: 24px 36px; font-size: 16px; line-height: 1.6; }
111
+ .ss-shell-columns { grid-template-columns: repeat(3, minmax(0, 1fr)); padding: 24px 32px; }
112
+ }
@@ -0,0 +1,40 @@
1
+ import { type ReactNode } from 'react';
2
+ export interface ChoiceOption {
3
+ value: string;
4
+ label: ReactNode;
5
+ /** Shown in place, never chosen. Say why in the help line. */
6
+ disabled?: boolean;
7
+ }
8
+ export interface ChoiceChipsWords {
9
+ /** The marker after the label of an optional question. */
10
+ optional: string;
11
+ }
12
+ export declare const defaultChoiceChipsWords: ChoiceChipsWords;
13
+ interface Common {
14
+ label: ReactNode;
15
+ options: ChoiceOption[];
16
+ /** Under the chips. Also the description of every disabled chip. */
17
+ help?: ReactNode;
18
+ /** Adds "(optional)" after the label. In pick one, also lets a second tap clear the choice. */
19
+ optional?: boolean;
20
+ words?: Partial<ChoiceChipsWords>;
21
+ className?: string;
22
+ }
23
+ export interface SeveralProps extends Common {
24
+ mode: 'several';
25
+ value: string[];
26
+ onChange: (value: string[]) => void;
27
+ }
28
+ export interface OneProps extends Common {
29
+ mode: 'one';
30
+ value: string | null;
31
+ onChange: (value: string | null) => void;
32
+ /** A required question: a second tap never clears it. */
33
+ required?: boolean;
34
+ /** `auto` (default) measures: a track that does not fit draws as wrapping chips. `track` and `wrap` force one form. */
35
+ layout?: 'auto' | 'track' | 'wrap';
36
+ }
37
+ export type ChoiceChipsProps = SeveralProps | OneProps;
38
+ export declare const Tick: () => import("react").JSX.Element;
39
+ export declare function ChoiceChips(p: ChoiceChipsProps): import("react").JSX.Element;
40
+ export {};
@@ -0,0 +1,106 @@
1
+ 'use client';
2
+ import { jsx as _jsx, Fragment as _Fragment, jsxs as _jsxs } from "react/jsx-runtime";
3
+ // PICK ONE OR PICK SEVERAL, AS PILLS (spec approved 2026-12-02). Pick several is a row of toggle chips, each a
4
+ // <button aria-pressed> with a tick when chosen, so the state never rests on colour. Pick one is a segmented track
5
+ // with radio semantics: one option in the tab order, arrow keys that move the choice and skip disabled options. A
6
+ // track that does not fit its container draws as wrapping chips and keeps the radio semantics; that switch is
7
+ // measured, never set by a breakpoint. Changes are immediate: onChange on every tap, no Apply button.
8
+ import { useCallback, useId, useLayoutEffect, useEffect, useRef, useState } from 'react';
9
+ export const defaultChoiceChipsWords = { optional: '(optional)' };
10
+ const useIso = typeof window === 'undefined' ? useEffect : useLayoutEffect;
11
+ const idOf = (raw) => raw.replace(/[^a-zA-Z0-9_-]/g, '');
12
+ export const Tick = () => (_jsx("svg", { className: "ss-chip-tick", viewBox: "0 0 24 24", width: "16", height: "16", fill: "none", stroke: "currentColor", strokeWidth: "2.4", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "M5 12.5 10 17.5 19 7" }) }));
13
+ /** The track's form: measured against the container, so the same set sits on one line where it fits. */
14
+ function useForm(layout, key) {
15
+ const host = useRef(null);
16
+ const natural = useRef(0);
17
+ const [measured, setMeasured] = useState('track');
18
+ const measure = useCallback(() => {
19
+ const h = host.current;
20
+ if (!h)
21
+ return;
22
+ const track = h.querySelector('.ss-seg-track');
23
+ if (track) {
24
+ natural.current = track.scrollWidth;
25
+ if (track.scrollWidth > h.clientWidth)
26
+ setMeasured('wrap');
27
+ }
28
+ else if (natural.current && h.clientWidth >= natural.current)
29
+ setMeasured('track');
30
+ }, []);
31
+ // A new set of options has a new natural width: draw it as a track again and measure that.
32
+ useIso(() => { natural.current = 0; setMeasured('track'); }, [key]);
33
+ useIso(() => { if (layout === 'auto')
34
+ measure(); });
35
+ useEffect(() => {
36
+ if (layout !== 'auto' || typeof ResizeObserver === 'undefined' || !host.current)
37
+ return;
38
+ const ro = new ResizeObserver(() => measure());
39
+ ro.observe(host.current);
40
+ return () => ro.disconnect();
41
+ }, [layout, measure]);
42
+ return { host, form: layout === 'auto' ? measured : layout };
43
+ }
44
+ export function ChoiceChips(p) {
45
+ const w = { ...defaultChoiceChipsWords, ...p.words };
46
+ const id = idOf(useId());
47
+ const labelId = `ss-chips-label-${id}`;
48
+ const helpId = `ss-chips-help-${id}`;
49
+ const optionsKey = p.options.map((o) => o.value).join('\u0000');
50
+ const { host, form } = useForm(p.mode === 'one' ? (p.layout ?? 'auto') : 'wrap', optionsKey);
51
+ const refs = useRef([]);
52
+ const label = _jsxs("div", { id: labelId, className: "ss-chips-label", children: [p.label, p.optional && _jsxs(_Fragment, { children: [" ", _jsx("small", { children: w.optional })] })] });
53
+ const help = p.help != null ? _jsx("p", { id: helpId, className: "ss-chips-help", children: p.help }) : null;
54
+ const describedBy = p.help != null ? helpId : undefined;
55
+ let body;
56
+ if (p.mode === 'several') {
57
+ const chosen = new Set(p.value);
58
+ body = (_jsx("div", { role: "group", "aria-labelledby": labelId, "aria-describedby": describedBy, className: "ss-chips-set", children: p.options.map((o) => {
59
+ const on = chosen.has(o.value);
60
+ return (_jsxs("button", { type: "button", className: "ss-chip", "aria-pressed": on, "aria-disabled": o.disabled ? true : undefined, "aria-describedby": o.disabled ? describedBy : undefined, onClick: () => {
61
+ if (o.disabled)
62
+ return;
63
+ p.onChange(on ? p.value.filter((v) => v !== o.value) : [...p.value, o.value]);
64
+ }, children: [on && _jsx(Tick, {}), _jsx("span", { children: o.label })] }, o.value));
65
+ }) }));
66
+ }
67
+ else {
68
+ const one = p;
69
+ const enabled = one.options.map((o, i) => (o.disabled ? -1 : i)).filter((i) => i >= 0);
70
+ const chosenAt = one.options.findIndex((o) => o.value === one.value && !o.disabled);
71
+ const stop = chosenAt >= 0 ? chosenAt : (enabled[0] ?? -1);
72
+ const pick = (i) => {
73
+ const o = one.options[i];
74
+ if (!o || o.disabled)
75
+ return;
76
+ if (o.value === one.value) {
77
+ if (one.optional && !one.required)
78
+ one.onChange(null);
79
+ return;
80
+ }
81
+ one.onChange(o.value);
82
+ };
83
+ const key = (e, i) => {
84
+ const step = e.key === 'ArrowRight' || e.key === 'ArrowDown' ? 1 : e.key === 'ArrowLeft' || e.key === 'ArrowUp' ? -1 : 0;
85
+ if (e.key === ' ' || e.key === 'Enter') {
86
+ e.preventDefault();
87
+ if (one.options[i]?.value !== one.value)
88
+ pick(i);
89
+ return;
90
+ }
91
+ if (!step || !enabled.length)
92
+ return;
93
+ e.preventDefault();
94
+ const at = enabled.indexOf(i);
95
+ const next = enabled[((at < 0 ? 0 : at + step) + enabled.length) % enabled.length];
96
+ one.onChange(one.options[next].value);
97
+ refs.current[next]?.focus();
98
+ };
99
+ const wrap = form === 'wrap';
100
+ body = (_jsx("div", { role: "radiogroup", "aria-labelledby": labelId, "aria-describedby": describedBy, "aria-required": one.required ? true : undefined, className: wrap ? 'ss-chips-set' : 'ss-seg-track', children: one.options.map((o, i) => {
101
+ const on = i === chosenAt;
102
+ return (_jsxs("button", { ref: (el) => { refs.current[i] = el; }, type: "button", role: "radio", "aria-checked": on, "aria-disabled": o.disabled ? true : undefined, tabIndex: i === stop ? 0 : -1, className: wrap ? 'ss-chip' : 'ss-seg-option', onClick: () => pick(i), onKeyDown: (e) => key(e, i), children: [wrap && on && _jsx(Tick, {}), _jsx("span", { children: o.label })] }, o.value));
103
+ }) }));
104
+ }
105
+ return (_jsxs("div", { ref: host, className: ['ss-chips', p.className].filter(Boolean).join(' '), "data-mode": p.mode, "data-form": p.mode === 'one' ? form : 'wrap', children: [label, body, help] }));
106
+ }
@@ -0,0 +1 @@
1
+ export { ChoiceChips, Tick, defaultChoiceChipsWords, type ChoiceChipsProps, type SeveralProps, type OneProps, type ChoiceOption, type ChoiceChipsWords } from './choice-chips.js';
@@ -0,0 +1,3 @@
1
+ // @supersuit/components/choice-chips: pick one or pick several, as pills. Import the styles once:
2
+ // import '@supersuit/components/choice-chips/styles.css'
3
+ export { ChoiceChips, Tick, defaultChoiceChipsWords } from './choice-chips.js';