@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.
@@ -0,0 +1,38 @@
1
+ /* @supersuit/components/choice-chips: pick one or pick several, as pills (spec approved 2026-12-02).
2
+ *
3
+ * Every colour is a theme role (--card, --input, --primary, --primary-foreground, --muted, --border, --placeholder,
4
+ * --foreground, --muted-foreground, --ring), as a compiled brand theme names them: put `.theme-maison-dawn` or
5
+ * `.theme-maison-night` on any element above. With no theme, the Maison Dawn values are the fallbacks. The part has
6
+ * no breakpoint: toggle chips wrap when they run out of room, and a track that does not fit draws as chips.
7
+ */
8
+
9
+ .ss-chips { min-width: 0; font-family: var(--font-text, "DM Sans", system-ui, sans-serif); color: var(--foreground, #2A231B); }
10
+ .ss-chips-label { margin: 0 0 8px; font-size: 15px; font-weight: 600; }
11
+ .ss-chips-label small { font-size: 14px; font-weight: 400; color: var(--muted-foreground, #665B4D); }
12
+ .ss-chips-help { margin: 6px 0 0; font-size: 14px; line-height: 1.4; color: var(--muted-foreground, #665B4D); }
13
+
14
+ /* Toggle chips, and a pick-one set too wide for its track. */
15
+ .ss-chips-set { display: flex; flex-wrap: wrap; gap: 8px; }
16
+ .ss-chip {
17
+ box-sizing: border-box; display: inline-flex; align-items: center; gap: 6px; min-height: 44px; margin: 0; padding: 0 16px;
18
+ border: 0; border-radius: 999px; background: var(--card, #FAF7F2); color: var(--foreground, #2A231B);
19
+ box-shadow: inset 0 0 0 1px var(--input, #C5B399); font: inherit; font-size: 15px; font-weight: 500; white-space: nowrap; cursor: pointer;
20
+ -webkit-tap-highlight-color: transparent; touch-action: manipulation;
21
+ }
22
+ .ss-chip[aria-pressed="true"], .ss-chip[aria-checked="true"] { background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); box-shadow: none; }
23
+ .ss-chip[aria-disabled="true"] { background: var(--muted, #EFE4D6); color: var(--placeholder, #A39C93); box-shadow: none; cursor: default; }
24
+ .ss-chip:focus { outline: none; }
25
+ .ss-chip:focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: 2px; }
26
+ .ss-chip-tick { flex: none; width: 16px; height: 16px; margin-left: -4px; }
27
+
28
+ /* Pick one: the segmented track. It never wraps or scrolls inside itself. */
29
+ .ss-seg-track { box-sizing: border-box; display: inline-flex; flex-wrap: nowrap; overflow: hidden; max-width: none; gap: 2px; padding: 2px; border-radius: 999px; background: var(--muted, #EFE4D6); box-shadow: inset 0 0 0 1px var(--border, #D9CDBB); }
30
+ .ss-seg-option {
31
+ box-sizing: border-box; flex: none; display: inline-flex; align-items: center; justify-content: center; min-height: 44px; margin: 0; padding: 0 16px;
32
+ border: 0; border-radius: 999px; background: transparent; color: var(--foreground, #2A231B); font: inherit; font-size: 15px; font-weight: 500; white-space: nowrap; cursor: pointer;
33
+ -webkit-tap-highlight-color: transparent; touch-action: manipulation;
34
+ }
35
+ .ss-seg-option[aria-checked="true"] { background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); box-shadow: 0 1px 2px rgb(0 0 0 / 0.2); }
36
+ .ss-seg-option[aria-disabled="true"] { color: var(--placeholder, #A39C93); cursor: default; }
37
+ .ss-seg-option:focus { outline: none; }
38
+ .ss-seg-option:focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: 1px; }
package/dist/index.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export declare const components: readonly ["voice-field"];
1
+ export declare const components: readonly ["app-shell", "choice-chips", "page-header", "row", "voice-field"];
2
2
  export type ComponentName = (typeof components)[number];
3
3
  export declare const modules: readonly ["sound", "theme", "check/depth"];
4
4
  export type ModuleName = (typeof modules)[number];
package/dist/index.js CHANGED
@@ -3,7 +3,7 @@
3
3
  // import { VoiceField } from '@supersuit/components/voice-field'
4
4
  // import '@supersuit/components/voice-field/styles.css'
5
5
  // The root imports no component on purpose. It names the components this version ships.
6
- export const components = ['voice-field'];
6
+ export const components = ['app-shell', 'choice-chips', 'page-header', 'row', 'voice-field'];
7
7
  // The modules: shared behaviour with no part of its own (no spec, no mockup), each its own subpath too.
8
8
  // import { sound } from '@supersuit/components/sound'
9
9
  // import { compileTheme } from '@supersuit/components/theme'
@@ -0,0 +1,2 @@
1
+ export { PageHeader, defaultPageHeaderWords, TALL_SCROLLER, type PageHeaderProps, type PageHeaderWords, type BackRevealRule, type HeaderAction, type MenuItem, } from './page-header.js';
2
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY, type ShellState } from './shell-context.js';
@@ -0,0 +1,4 @@
1
+ // @supersuit/components/page-header: the top of every screen below the home. Import the styles once:
2
+ // import '@supersuit/components/page-header/styles.css'
3
+ export { PageHeader, defaultPageHeaderWords, TALL_SCROLLER, } from './page-header.js';
4
+ export { ShellContext, useShell, useDesktop, DESKTOP_QUERY } from './shell-context.js';
@@ -0,0 +1,58 @@
1
+ import { type ElementType, type ReactNode } from 'react';
2
+ export interface PageHeaderWords {
3
+ back: string;
4
+ backTo: (parent: string) => string;
5
+ more: string;
6
+ suggest: string;
7
+ mySuggestions: string;
8
+ }
9
+ export declare const defaultPageHeaderWords: PageHeaderWords;
10
+ /** The floating Back's rule: `backRevealAt` and `backReveal` from `@supersuit/home-screen-app`, passed as is. */
11
+ export interface BackRevealRule<S extends {
12
+ shown: boolean;
13
+ } = {
14
+ shown: boolean;
15
+ }> {
16
+ backRevealAt: (y: number) => S;
17
+ backReveal: (prev: S, y: number) => S;
18
+ }
19
+ export interface HeaderAction {
20
+ label: string;
21
+ icon: ReactNode;
22
+ href?: string;
23
+ onClick?: () => void;
24
+ }
25
+ export interface MenuItem {
26
+ label: string;
27
+ onSelect: () => void;
28
+ }
29
+ export interface PageHeaderProps {
30
+ /** The screen's name: the h1 (the h2 of a detail pane). */
31
+ title: string;
32
+ /** The screen's fixed parent. `label` is the parent's name ("Home", "Expenses"); without it Back says "Back". */
33
+ back?: {
34
+ href: string;
35
+ label?: string;
36
+ };
37
+ /** The screen's own buttons: icon buttons on a phone, filled pills with their word on a desktop. */
38
+ actions?: HeaderAction[];
39
+ /** Signed out, there is no More. Default true. */
40
+ signedIn?: boolean;
41
+ /** The app's own items, drawn above Suggest a change and My suggestions. */
42
+ menu?: MenuItem[];
43
+ onSuggest?: () => void;
44
+ onMySuggestions?: () => void;
45
+ /** In a list-and-detail screen: the list pane keeps the screen's name (h1), the detail pane names the item (h2). */
46
+ pane?: 'list' | 'detail';
47
+ /** A screen deeper than its tile with no list beside it: on a desktop, a "‹ Parent" crumb before the title. */
48
+ deep?: boolean;
49
+ /** The floating Back's rule. Pass `@supersuit/home-screen-app` (or its two functions). Without it, nothing floats. */
50
+ backReveal?: BackRevealRule<any>;
51
+ /** The link component, e.g. Next.js `Link`. Default `a`. */
52
+ linkAs?: ElementType;
53
+ words?: Partial<PageHeaderWords>;
54
+ className?: string;
55
+ }
56
+ /** A scroller at least this share of the window tall moves the floating Back; a smaller one (a chip row) never does. */
57
+ export declare const TALL_SCROLLER = 0.6;
58
+ export declare function PageHeader(p: PageHeaderProps): import("react").JSX.Element;
@@ -0,0 +1,124 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // THE TOP OF EVERY SCREEN BELOW THE HOME (spec approved 2026-12-02). On a phone: the back row (Back to a fixed
4
+ // parent, the screen's own buttons, then More) with the title under it, and a pill copy of Back that floats in when
5
+ // the screen scrolls up. On a desktop inside the app shell: a 72 px title row with no Back, because the side menu
6
+ // shows where you are; a deeper screen gets a small "‹ Parent" crumb. Back is always a link to a fixed parent,
7
+ // never history.back(): a screen opened from a notification or a link has no history.
8
+ import { useEffect, useId, useRef, useState } from 'react';
9
+ import { useShell } from './shell-context.js';
10
+ export const defaultPageHeaderWords = {
11
+ back: 'Back',
12
+ backTo: (parent) => `Back to ${parent}`,
13
+ more: 'More',
14
+ suggest: 'Suggest a change',
15
+ mySuggestions: 'My suggestions',
16
+ };
17
+ const ChevronLeft = ({ size = 22 }) => (_jsx("svg", { className: "ss-ph-chevron", viewBox: "0 0 24 24", width: size, height: size, fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m15 18-6-6 6-6" }) }));
18
+ const Dots = () => (_jsxs("svg", { viewBox: "0 0 24 24", width: "22", height: "22", fill: "currentColor", "aria-hidden": "true", children: [_jsx("circle", { cx: "5", cy: "12", r: "1.8" }), _jsx("circle", { cx: "12", cy: "12", r: "1.8" }), _jsx("circle", { cx: "19", cy: "12", r: "1.8" })] }));
19
+ /** A scroller at least this share of the window tall moves the floating Back; a smaller one (a chip row) never does. */
20
+ export const TALL_SCROLLER = 0.6;
21
+ function useFloatingBack(rule, on) {
22
+ const [shown, setShown] = useState(false);
23
+ useEffect(() => {
24
+ if (!rule || !on || typeof window === 'undefined') {
25
+ setShown(false);
26
+ return;
27
+ }
28
+ let state = rule.backRevealAt(window.scrollY || 0);
29
+ const step = (y) => { state = rule.backReveal(state, y); setShown(!!state.shown); };
30
+ const onWindow = () => step(window.scrollY || 0);
31
+ const onElement = (e) => {
32
+ const t = e.target;
33
+ if (!(t instanceof HTMLElement))
34
+ return;
35
+ if (t.clientHeight < TALL_SCROLLER * window.innerHeight)
36
+ return;
37
+ step(t.scrollTop);
38
+ };
39
+ window.addEventListener('scroll', onWindow, { passive: true });
40
+ document.addEventListener('scroll', onElement, { capture: true, passive: true });
41
+ return () => { window.removeEventListener('scroll', onWindow); document.removeEventListener('scroll', onElement, { capture: true }); };
42
+ }, [rule, on]);
43
+ return shown;
44
+ }
45
+ function More({ w, items }) {
46
+ const [open, setOpen] = useState(false);
47
+ const button = useRef(null);
48
+ const menu = useRef(null);
49
+ const id = `ss-ph-menu-${useId().replace(/[^a-zA-Z0-9_-]/g, '')}`;
50
+ const itemsOf = () => [...(menu.current?.querySelectorAll('[role="menuitem"]') ?? [])];
51
+ const close = (refocus) => { setOpen(false); if (refocus)
52
+ button.current?.focus(); };
53
+ useEffect(() => { if (open)
54
+ itemsOf()[0]?.focus(); }, [open]);
55
+ useEffect(() => {
56
+ if (!open)
57
+ return;
58
+ const away = (e) => { const t = e.target; if (!menu.current?.contains(t) && !button.current?.contains(t))
59
+ setOpen(false); };
60
+ document.addEventListener('pointerdown', away);
61
+ return () => document.removeEventListener('pointerdown', away);
62
+ }, [open]);
63
+ const key = (e, i) => {
64
+ const all = itemsOf();
65
+ if (e.key === 'ArrowDown') {
66
+ e.preventDefault();
67
+ all[(i + 1) % all.length]?.focus();
68
+ }
69
+ else if (e.key === 'ArrowUp') {
70
+ e.preventDefault();
71
+ all[(i - 1 + all.length) % all.length]?.focus();
72
+ }
73
+ else if (e.key === 'Home') {
74
+ e.preventDefault();
75
+ all[0]?.focus();
76
+ }
77
+ else if (e.key === 'End') {
78
+ e.preventDefault();
79
+ all[all.length - 1]?.focus();
80
+ }
81
+ else if (e.key === 'Escape') {
82
+ e.preventDefault();
83
+ close(true);
84
+ }
85
+ else if (e.key === 'Tab')
86
+ setOpen(false);
87
+ else if (e.key === 'Enter' || e.key === ' ') {
88
+ e.preventDefault();
89
+ items[i]?.onSelect();
90
+ close(true);
91
+ }
92
+ };
93
+ return (_jsxs("span", { className: "ss-ph-more-wrap", children: [_jsx("button", { ref: button, type: "button", className: "ss-ph-more", "aria-label": w.more, "aria-haspopup": "menu", "aria-expanded": open, "aria-controls": open ? id : undefined, "data-open": open ? '' : undefined, onClick: () => setOpen((o) => !o), children: _jsx(Dots, {}) }), open && (_jsx("div", { ref: menu, id: id, role: "menu", "aria-label": w.more, className: "ss-ph-menu", children: items.map((it, i) => (_jsx("div", { role: "menuitem", tabIndex: -1, className: "ss-ph-menu-item", onKeyDown: (e) => key(e, i), onClick: () => { it.onSelect(); close(true); }, children: it.label }, i))) }))] }));
94
+ }
95
+ function Action({ a, Link }) {
96
+ const inner = _jsxs(_Fragment, { children: [a.icon, _jsx("span", { className: "ss-ph-action-word", children: a.label })] });
97
+ return a.href != null
98
+ ? _jsx(Link, { href: a.href, className: "ss-ph-action", "aria-label": a.label, onClick: a.onClick, children: inner })
99
+ : _jsx("button", { type: "button", className: "ss-ph-action", "aria-label": a.label, onClick: a.onClick, children: inner });
100
+ }
101
+ export function PageHeader(p) {
102
+ const w = { ...defaultPageHeaderWords, ...p.words };
103
+ const shell = useShell();
104
+ const desktop = shell.inShell && shell.desktop;
105
+ const Link = p.linkAs ?? 'a';
106
+ const signedIn = p.signedIn ?? true;
107
+ const floating = useFloatingBack(p.backReveal, !desktop && !!p.back);
108
+ const backName = p.back?.label ? w.backTo(p.back.label) : w.back;
109
+ const items = [
110
+ ...(p.menu ?? []),
111
+ { label: w.suggest, onSelect: () => p.onSuggest?.() },
112
+ { label: w.mySuggestions, onSelect: () => p.onMySuggestions?.() },
113
+ ];
114
+ const H = p.pane === 'detail' ? 'h2' : 'h1';
115
+ const title = _jsx(H, { className: "ss-ph-title", title: p.title, children: p.title });
116
+ const end = (_jsxs("span", { className: "ss-ph-end", children: [p.actions?.map((a, i) => _jsx(Action, { a: a, Link: Link }, i)), signedIn && _jsx(More, { w: w, items: items })] }));
117
+ const cls = ['ss-ph', p.className].filter(Boolean).join(' ');
118
+ if (desktop) {
119
+ return (_jsx("header", { className: cls, "data-form": "desktop", "data-pane": p.pane, children: _jsxs("div", { className: "ss-ph-row", children: [p.deep && p.back && (_jsxs(Link, { href: p.back.href, className: "ss-ph-crumb", "aria-label": backName, children: [_jsx(ChevronLeft, { size: 18 }), p.back.label ?? w.back] })), title, end] }) }));
120
+ }
121
+ return (_jsxs("header", { className: cls, "data-form": "phone", "data-pane": p.pane, children: [_jsxs("div", { className: "ss-ph-row", children: [p.back
122
+ ? _jsxs(Link, { href: p.back.href, className: "ss-ph-back", "aria-label": backName, children: [_jsx(ChevronLeft, {}), p.back.label ?? w.back] })
123
+ : _jsx("span", {}), end] }), title, floating && p.back && (_jsxs(Link, { href: p.back.href, className: "ss-ph-float", "aria-label": backName, children: [_jsx(ChevronLeft, {}), p.back.label ?? w.back] }))] }));
124
+ }
@@ -0,0 +1,12 @@
1
+ export declare const DESKTOP_QUERY = "(min-width: 1024px)";
2
+ export interface ShellState {
3
+ /** True inside an AppShell. Outside it, the page header keeps the phone form at every width. */
4
+ inShell: boolean;
5
+ /** The window is at least 1024 px wide. */
6
+ desktop: boolean;
7
+ appName?: string;
8
+ }
9
+ export declare const ShellContext: import("react").Context<ShellState>;
10
+ export declare const useShell: () => ShellState;
11
+ /** Whether the window is at least 1024 px wide. False on the server and where matchMedia is missing. */
12
+ export declare function useDesktop(): boolean;
@@ -0,0 +1,21 @@
1
+ 'use client';
2
+ // What the app shell tells the parts inside it: that there is a shell, the app's name, and whether the window is
3
+ // at least 1024 px wide (the one breakpoint, measured on the window, never on the device). The page header reads it
4
+ // to drop Back on a desktop, where the side menu shows where you are. The app shell provides it; this file lives
5
+ // with the page header so the header needs nothing from the shell's own code.
6
+ import { createContext, useContext, useSyncExternalStore } from 'react';
7
+ export const DESKTOP_QUERY = '(min-width: 1024px)';
8
+ export const ShellContext = createContext({ inShell: false, desktop: false });
9
+ export const useShell = () => useContext(ShellContext);
10
+ const query = () => (typeof window !== 'undefined' && typeof window.matchMedia === 'function' ? window.matchMedia(DESKTOP_QUERY) : null);
11
+ function subscribe(change) {
12
+ const q = query();
13
+ if (!q)
14
+ return () => { };
15
+ q.addEventListener('change', change);
16
+ return () => q.removeEventListener('change', change);
17
+ }
18
+ /** Whether the window is at least 1024 px wide. False on the server and where matchMedia is missing. */
19
+ export function useDesktop() {
20
+ return useSyncExternalStore(subscribe, () => query()?.matches ?? false, () => false);
21
+ }
@@ -0,0 +1,77 @@
1
+ /* @supersuit/components/page-header: the back row on a phone, the title row on a desktop (spec approved 2026-12-02).
2
+ *
3
+ * Every colour is a theme role (--foreground, --muted-foreground, --background, --border, --popover, --muted,
4
+ * --primary, --primary-foreground, --ring) and the title is --font-display, as a compiled brand theme names them:
5
+ * put `.theme-maison-dawn` or `.theme-maison-night` on any element above. With no theme, the Maison Dawn values are
6
+ * the fallbacks. The form (phone or desktop) is chosen by the app shell at 1024 px; outside it, always the phone.
7
+ */
8
+
9
+ .ss-ph { position: relative; min-width: 0; font-family: var(--font-text, "DM Sans", system-ui, sans-serif); color: var(--foreground, #2A231B); }
10
+ .ss-ph :focus { outline: none; }
11
+ .ss-ph :focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: 2px; }
12
+
13
+ /* ---------- phone: the back row, then the title under it ---------- */
14
+ .ss-ph-row { box-sizing: border-box; display: flex; align-items: center; justify-content: space-between; gap: 4px; height: 44px; padding: 0 4px; }
15
+ .ss-ph-back {
16
+ box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; min-width: 44px; padding: 0 12px 0 6px;
17
+ border-radius: 999px; color: var(--foreground, #2A231B); font-size: 16px; text-decoration: none; -webkit-tap-highlight-color: transparent;
18
+ }
19
+ .ss-ph-chevron { flex: none; }
20
+ .ss-ph-title {
21
+ margin: 4px 16px 12px; font-family: var(--font-display, "Instrument Serif", Georgia, serif); font-weight: var(--display-weight, 400);
22
+ font-size: 34px; line-height: 1.1; letter-spacing: var(--display-tracking, -0.01em); overflow-wrap: anywhere;
23
+ }
24
+ .ss-ph-end { display: flex; align-items: center; gap: 2px; min-width: 0; }
25
+
26
+ /* The screen's own buttons: a 44 px icon button on a phone, its word read but not shown. */
27
+ .ss-ph-action {
28
+ box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; gap: 6px; width: 44px; height: 44px; margin: 0; padding: 0;
29
+ border: 0; border-radius: 50%; background: transparent; color: var(--foreground, #2A231B); font: inherit; text-decoration: none; cursor: pointer;
30
+ }
31
+ .ss-ph-action svg { width: 22px; height: 22px; flex: none; }
32
+ .ss-ph-action-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
33
+
34
+ /* More: the last item on the right, and its menu. */
35
+ .ss-ph-more-wrap { position: relative; display: inline-flex; }
36
+ .ss-ph-more {
37
+ box-sizing: border-box; display: inline-flex; align-items: center; justify-content: center; width: 44px; height: 44px; margin: 0; padding: 0;
38
+ border: 0; border-radius: 50%; background: transparent; color: var(--foreground, #2A231B); cursor: pointer;
39
+ }
40
+ .ss-ph-more[data-open] { background: var(--muted, #EFE4D6); }
41
+ .ss-ph-menu {
42
+ position: absolute; z-index: 20; top: calc(100% + 4px); right: 0; box-sizing: border-box; min-width: 220px; padding: 6px;
43
+ border-radius: 14px; background: var(--popover, #FAF7F2); color: var(--foreground, #2A231B);
44
+ box-shadow: 0 0 0 1px var(--border, #D9CDBB), 0 18px 36px -16px rgb(0 0 0 / 0.35);
45
+ }
46
+ .ss-ph-menu-item { display: flex; align-items: center; min-height: 44px; padding: 0 12px; border-radius: 9px; font-size: 15px; cursor: pointer; }
47
+ .ss-ph-menu-item:hover, .ss-ph-menu-item:focus { background: var(--muted, #EFE4D6); outline: none; }
48
+ .ss-ph-menu-item:focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: -2px; }
49
+
50
+ /* The floating Back: a pill copy of Back, drawn only while shown. */
51
+ .ss-ph-float {
52
+ position: fixed; z-index: 30; left: 12px; top: calc(env(safe-area-inset-top, 0px) + 8px);
53
+ box-sizing: border-box; display: inline-flex; align-items: center; gap: 2px; min-height: 44px; padding: 0 16px 0 8px; border-radius: 999px;
54
+ background: var(--background, #F3E5D5); color: var(--foreground, #2A231B); font-size: 16px; text-decoration: none;
55
+ box-shadow: 0 0 0 1px var(--border, #D9CDBB), 0 8px 20px -8px rgb(0 0 0 / 0.3);
56
+ }
57
+
58
+ /* ---------- desktop, inside the app shell: a title row, no Back ---------- */
59
+ .ss-ph[data-form="desktop"] .ss-ph-row { height: 72px; gap: 12px; padding: 0 20px 0 32px; border-bottom: 1px solid var(--border, #D9CDBB); }
60
+ .ss-ph[data-form="desktop"] .ss-ph-title { flex: 1 1 auto; min-width: 0; margin: 0; font-size: 32px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
61
+ .ss-ph[data-form="desktop"][data-pane="list"] .ss-ph-row { padding: 0 12px 0 20px; }
62
+ .ss-ph[data-form="desktop"][data-pane="list"] .ss-ph-title { font-size: 30px; }
63
+ .ss-ph[data-form="desktop"][data-pane="detail"] .ss-ph-row { padding-left: 36px; }
64
+ .ss-ph[data-form="desktop"][data-pane="detail"] .ss-ph-title { font-size: 28px; }
65
+ .ss-ph[data-form="desktop"] .ss-ph-action {
66
+ width: auto; min-height: 44px; padding: 0 16px; border-radius: 999px;
67
+ background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-size: 15px; font-weight: 600;
68
+ }
69
+ .ss-ph[data-form="desktop"] .ss-ph-action svg { width: 18px; height: 18px; }
70
+ .ss-ph[data-form="desktop"] .ss-ph-action-word { position: static; width: auto; height: auto; overflow: visible; clip: auto; }
71
+ /* The list pane is narrow, so its button stays a round icon and the title keeps the room (its word is still read). */
72
+ .ss-ph[data-form="desktop"][data-pane="list"] .ss-ph-action { width: 44px; padding: 0; }
73
+ .ss-ph[data-form="desktop"][data-pane="list"] .ss-ph-action-word { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
74
+ .ss-ph-crumb {
75
+ flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 0 10px 0 4px; margin-left: -12px;
76
+ color: var(--muted-foreground, #665B4D); font-size: 15px; text-decoration: none;
77
+ }
@@ -0,0 +1 @@
1
+ export { Row, RowList, Fold, Chevron, defaultRowWords, PRESS_SLOP, type RowProps, type RowListProps, type FoldProps, type RowLead, type RowEnd, type RowWords } from './row.js';
@@ -0,0 +1,3 @@
1
+ // @supersuit/components/row: one line in a list, and the fold that groups rows. Import the styles once:
2
+ // import '@supersuit/components/row/styles.css'
3
+ export { Row, RowList, Fold, Chevron, defaultRowWords, PRESS_SLOP } from './row.js';
@@ -0,0 +1,76 @@
1
+ import { type ElementType, type ReactNode } from 'react';
2
+ export interface RowWords {
3
+ /** Said before the name of an unread row. */
4
+ unread: string;
5
+ /** Said for a count. */
6
+ waiting: (n: number) => string;
7
+ /** The fold's label. */
8
+ fold: (label: string, n: number) => string;
9
+ }
10
+ export declare const defaultRowWords: RowWords;
11
+ export type RowLead = {
12
+ initials: string;
13
+ tone?: 'primary' | 'accent';
14
+ } | {
15
+ src: string;
16
+ alt?: string;
17
+ } | {
18
+ icon: ReactNode;
19
+ };
20
+ export type RowEnd = {
21
+ count: number;
22
+ } | {
23
+ chevron: true;
24
+ } | {
25
+ time: string;
26
+ label?: string;
27
+ };
28
+ export interface RowProps {
29
+ title: string;
30
+ second?: string;
31
+ lead?: RowLead;
32
+ /** One end item at most. */
33
+ end?: RowEnd;
34
+ unread?: boolean;
35
+ /** The open item in a list beside its detail (desktop only). Sets aria-current="page". */
36
+ selected?: boolean;
37
+ /** A link when given; else the row is a button. */
38
+ href?: string;
39
+ onClick?: () => void;
40
+ /** The link component, e.g. Next.js `Link`. Default `a`. */
41
+ linkAs?: ElementType;
42
+ /** An optional button after the end item, outside the row's own target. */
43
+ action?: ReactNode;
44
+ /** Title lines before the ellipsis. Default: two on a phone, one from 1024 px and in a `pane` list. */
45
+ titleLines?: 1 | 2;
46
+ words?: Partial<RowWords>;
47
+ className?: string;
48
+ }
49
+ /** A drag past this many pixels is a scroll, and the press is dropped. */
50
+ export declare const PRESS_SLOP = 10;
51
+ export declare const Chevron: ({ className }: {
52
+ className?: string;
53
+ }) => import("react").JSX.Element;
54
+ export declare function Row(p: RowProps): import("react").JSX.Element;
55
+ export interface RowListProps {
56
+ children: ReactNode;
57
+ /** `card` (default): a card with 18 px corners, as on a phone. `pane`: edge to edge, as in a desktop list pane. */
58
+ look?: 'card' | 'pane';
59
+ id?: string;
60
+ hidden?: boolean;
61
+ className?: string;
62
+ 'aria-label'?: string;
63
+ }
64
+ export declare function RowList({ children, look, className, ...rest }: RowListProps): import("react").JSX.Element;
65
+ export interface FoldProps {
66
+ label: string;
67
+ /** How many rows it holds. */
68
+ count: number;
69
+ open: boolean;
70
+ onToggle: (open: boolean) => void;
71
+ children: ReactNode;
72
+ look?: 'card' | 'pane';
73
+ words?: Partial<RowWords>;
74
+ className?: string;
75
+ }
76
+ export declare function Fold(p: FoldProps): import("react").JSX.Element;
@@ -0,0 +1,69 @@
1
+ 'use client';
2
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
3
+ // ONE LINE IN A LIST (spec approved 2026-12-02): an optional picture, a title, a quieter second line, and one item at
4
+ // the end (a count, a chevron or a time). The whole row is one target: a link when it opens something, else a
5
+ // button. An action is its own button beside the target, never inside it. A Fold groups rows and opens or closes;
6
+ // the app keeps whether it is open, and the app says when a row is unread or selected.
7
+ import { useId, useRef, useState } from 'react';
8
+ export const defaultRowWords = {
9
+ unread: 'Unread',
10
+ waiting: (n) => `${n} waiting`,
11
+ fold: (label, n) => `${label} · ${n}`,
12
+ };
13
+ /** A drag past this many pixels is a scroll, and the press is dropped. */
14
+ export const PRESS_SLOP = 10;
15
+ function Lead({ lead }) {
16
+ if ('initials' in lead)
17
+ return _jsx("span", { className: "ss-row-lead", "data-lead": "avatar", "data-tone": lead.tone ?? 'primary', "aria-hidden": "true", children: lead.initials });
18
+ if ('src' in lead)
19
+ return _jsx("span", { className: "ss-row-lead", "data-lead": "photo", "aria-hidden": "true", children: _jsx("img", { src: lead.src, alt: lead.alt ?? '' }) });
20
+ return _jsx("span", { className: "ss-row-lead", "data-lead": "icon", "aria-hidden": "true", children: lead.icon });
21
+ }
22
+ export const Chevron = ({ className }) => (_jsx("svg", { className: className, viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m9 6 6 6-6 6" }) }));
23
+ function endWords(end, w) {
24
+ if (!end)
25
+ return null;
26
+ if ('count' in end)
27
+ return w.waiting(end.count);
28
+ if ('time' in end)
29
+ return end.label ?? end.time;
30
+ return null;
31
+ }
32
+ export function Row(p) {
33
+ const w = { ...defaultRowWords, ...p.words };
34
+ const [pressed, setPressed] = useState(false);
35
+ const from = useRef(null);
36
+ const down = (e) => { from.current = { x: e.clientX, y: e.clientY }; setPressed(true); };
37
+ const move = (e) => {
38
+ const f = from.current;
39
+ if (!f)
40
+ return;
41
+ if (Math.hypot(e.clientX - f.x, e.clientY - f.y) > PRESS_SLOP) {
42
+ from.current = null;
43
+ setPressed(false);
44
+ }
45
+ };
46
+ const up = () => { from.current = null; setPressed(false); };
47
+ const name = [p.unread ? w.unread : null, p.title, p.second ?? null, endWords(p.end, w)].filter(Boolean).join(', ');
48
+ const end = p.end;
49
+ const inner = _jsxs(_Fragment, { children: [p.unread && _jsx("span", { className: "ss-row-dot", "aria-hidden": "true" }), p.lead && _jsx(Lead, { lead: p.lead }), _jsxs("span", { className: "ss-row-text", "aria-hidden": "true", children: [_jsx("span", { className: "ss-row-title", title: p.title, children: p.title }), p.second && _jsx("span", { className: "ss-row-second", children: p.second })] }), end && _jsxs("span", { className: "ss-row-end", "aria-hidden": "true", children: ['count' in end && _jsx("span", { className: "ss-row-count", children: end.count }), 'chevron' in end && _jsx(Chevron, { className: "ss-row-chevron" }), 'time' in end && _jsx("span", { className: "ss-row-time", children: end.time })] })] });
50
+ const shared = {
51
+ className: 'ss-row-target',
52
+ 'aria-label': name,
53
+ 'aria-current': p.selected ? 'page' : undefined,
54
+ onPointerDown: down, onPointerMove: move, onPointerUp: up, onPointerCancel: up, onPointerLeave: up,
55
+ };
56
+ const Link = p.linkAs ?? 'a';
57
+ return (_jsxs("li", { className: ['ss-row', p.className].filter(Boolean).join(' '), "data-lead": p.lead ? '' : undefined, "data-unread": p.unread ? '' : undefined, "data-selected": p.selected ? '' : undefined, "data-pressed": pressed ? '' : undefined, "data-title-lines": p.titleLines, children: [p.href != null
58
+ ? _jsx(Link, { href: p.href, onClick: p.onClick, ...shared, children: inner })
59
+ : _jsx("button", { type: "button", onClick: p.onClick, ...shared, children: inner }), p.action && _jsx("span", { className: "ss-row-action", children: p.action })] }));
60
+ }
61
+ export function RowList({ children, look = 'card', className, ...rest }) {
62
+ return _jsx("ul", { className: ['ss-rows', className].filter(Boolean).join(' '), "data-look": look, ...rest, children: children });
63
+ }
64
+ export function Fold(p) {
65
+ const w = { ...defaultRowWords, ...p.words };
66
+ const id = useId();
67
+ const listId = `ss-fold-${id.replace(/[^a-zA-Z0-9_-]/g, '')}`;
68
+ return (_jsxs("div", { className: ['ss-fold', p.className].filter(Boolean).join(' '), "data-open": p.open ? '' : undefined, children: [_jsxs("button", { type: "button", className: "ss-fold-button", "aria-expanded": p.open, "aria-controls": listId, onClick: () => p.onToggle(!p.open), children: [_jsx("span", { className: "ss-fold-label", children: w.fold(p.label, p.count) }), _jsx("svg", { className: "ss-fold-arrow", viewBox: "0 0 24 24", width: "18", height: "18", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", "aria-hidden": "true", children: _jsx("path", { d: "m6 9 6 6 6-6" }) })] }), _jsx(RowList, { id: listId, look: p.look, hidden: !p.open, children: p.children })] }));
69
+ }
@@ -0,0 +1,69 @@
1
+ /* @supersuit/components/row: one line in a list, and the fold (spec approved 2026-12-02).
2
+ *
3
+ * Every colour is a theme role (--card, --foreground, --muted-foreground, --border, --muted, --secondary,
4
+ * --accent-ink, --primary, --primary-foreground, --placeholder, --ring), as a compiled brand theme names them:
5
+ * put `.theme-maison-dawn` or `.theme-maison-night` (from `supersuit-theme build`) on any element above. With no
6
+ * theme, the Maison Dawn values are the fallbacks. The row has no breakpoint of its own: it fills its container.
7
+ */
8
+
9
+ .ss-rows { list-style: none; margin: 0; padding: 0; font-family: var(--font-text, "DM Sans", system-ui, sans-serif); color: var(--foreground, #2A231B); }
10
+ .ss-rows[data-look="card"] { background: var(--card, #FAF7F2); border-radius: 18px; box-shadow: 0 0 0 1px var(--border, #D9CDBB); overflow: hidden; }
11
+ .ss-rows[data-look="pane"] { background: transparent; }
12
+ .ss-rows[hidden] { display: none; }
13
+
14
+ .ss-row { position: relative; display: flex; align-items: center; }
15
+ .ss-row + .ss-row::before { content: ""; position: absolute; z-index: 1; top: 0; right: 0; left: 16px; height: 1px; background: var(--border, #D9CDBB); pointer-events: none; }
16
+ .ss-row[data-lead] + .ss-row[data-lead]::before { left: 68px; }
17
+ .ss-row:is([data-selected], [data-pressed])::before, .ss-row:is([data-selected], [data-pressed]) + .ss-row::before { display: none; }
18
+
19
+ .ss-row-target {
20
+ position: relative; flex: 1 1 auto; min-width: 0; box-sizing: border-box; display: flex; align-items: center; gap: 12px;
21
+ min-height: 60px; margin: 0; padding: 8px 12px 8px 16px; border: 0; border-radius: 0;
22
+ background: transparent; color: inherit; font: inherit; text-align: left; text-decoration: none; cursor: pointer;
23
+ -webkit-tap-highlight-color: transparent; touch-action: manipulation;
24
+ }
25
+ .ss-row-target:focus { outline: none; }
26
+ .ss-row-target:focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: -2px; border-radius: 4px; }
27
+ .ss-row[data-pressed] { background: var(--muted, #EFE4D6); }
28
+ .ss-row[data-selected] { background: var(--secondary, #EADCC9); }
29
+ .ss-row[data-selected]::after { content: ""; position: absolute; left: 0; top: 8px; bottom: 8px; width: 3px; border-radius: 0 3px 3px 0; background: var(--accent-ink, #2B3B50); }
30
+
31
+ .ss-row-dot { position: absolute; left: 4px; top: 50%; width: 8px; height: 8px; margin-top: -4px; border-radius: 50%; background: var(--accent-ink, #2B3B50); }
32
+
33
+ .ss-row-lead { flex: none; width: 40px; height: 40px; display: flex; align-items: center; justify-content: center; overflow: hidden; }
34
+ .ss-row-lead[data-lead="avatar"], .ss-row-lead[data-lead="photo"] { border-radius: 50%; font-size: 15px; font-weight: 600; color: var(--primary-foreground, #F3EDE3); background: var(--primary, #22324A); }
35
+ .ss-row-lead[data-tone="accent"] { background: var(--accent-ink, #2B3B50); }
36
+ .ss-row-lead img { width: 100%; height: 100%; object-fit: cover; }
37
+ .ss-row-lead[data-lead="icon"] { border-radius: 12px; background: var(--muted, #EFE4D6); color: var(--accent-ink, #2B3B50); }
38
+ .ss-row-lead[data-lead="icon"] svg { width: 20px; height: 20px; }
39
+
40
+ .ss-row-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
41
+ /* Two lines then an ellipsis on a phone, where no detail pane shows the rest; one line in a desktop list. */
42
+ .ss-row-title { font-size: 17px; line-height: 22px; font-weight: 500; overflow: hidden; text-overflow: ellipsis; display: -webkit-box; -webkit-box-orient: vertical; -webkit-line-clamp: 2; overflow-wrap: anywhere; }
43
+ @media (min-width: 1024px) {
44
+ .ss-row-title { -webkit-line-clamp: 1; }
45
+ }
46
+ .ss-rows[data-look="pane"] .ss-row-title { -webkit-line-clamp: 1; }
47
+ .ss-row[data-title-lines="1"] .ss-row-title { -webkit-line-clamp: 1; }
48
+ .ss-row[data-title-lines="2"] .ss-row-title { -webkit-line-clamp: 2; }
49
+ .ss-row[data-unread] .ss-row-title { font-weight: 600; }
50
+ .ss-row-second { font-size: 14px; line-height: 19px; color: var(--muted-foreground, #665B4D); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
51
+
52
+ .ss-row-end { flex: none; display: flex; align-items: center; gap: 8px; }
53
+ .ss-row-time { font-size: 13px; color: var(--muted-foreground, #665B4D); font-variant-numeric: tabular-nums; }
54
+ .ss-row-count { display: inline-flex; align-items: center; justify-content: center; box-sizing: border-box; min-width: 22px; height: 22px; padding: 0 7px; border-radius: 11px; background: var(--primary, #22324A); color: var(--primary-foreground, #F3EDE3); font-size: 12px; font-weight: 600; font-variant-numeric: tabular-nums; }
55
+ .ss-row-chevron { width: 18px; height: 18px; color: var(--placeholder, #A39C93); }
56
+ .ss-row-action { flex: none; display: flex; align-items: center; padding-right: 12px; }
57
+
58
+ /* ---------- the fold ---------- */
59
+ .ss-fold { font-family: var(--font-text, "DM Sans", system-ui, sans-serif); }
60
+ .ss-fold-button {
61
+ box-sizing: border-box; width: 100%; min-height: 48px; display: flex; align-items: center; gap: 10px; margin: 0; padding: 0 12px 0 16px;
62
+ border: 0; background: transparent; font: inherit; font-size: 15px; font-weight: 600; color: var(--muted-foreground, #665B4D); cursor: pointer;
63
+ }
64
+ .ss-fold-button:focus { outline: none; }
65
+ .ss-fold-button:focus-visible { outline: 2px solid var(--ring, #2B3B50); outline-offset: -2px; border-radius: 4px; }
66
+ .ss-fold-label { flex: 1; text-align: left; }
67
+ .ss-fold-arrow { width: 18px; height: 18px; transition: transform 0.15s ease; }
68
+ .ss-fold:not([data-open]) .ss-fold-arrow { transform: rotate(-90deg); }
69
+ @media (prefers-reduced-motion: reduce) { .ss-fold-arrow { transition: none; } }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@supersuit/components",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "The Supersuit component library: brand themes compiled to CSS (theme), one sound engine (sound), a measured depth check (check/depth), the @supersuit shadcn registry, and components with an approved spec, a React implementation and a conformance test (voice-field).",
5
5
  "type": "module",
6
6
  "exports": {
@@ -13,6 +13,26 @@
13
13
  "import": "./dist/voice-field/index.js"
14
14
  },
15
15
  "./voice-field/styles.css": "./dist/voice-field/styles.css",
16
+ "./row": {
17
+ "types": "./dist/row/index.d.ts",
18
+ "import": "./dist/row/index.js"
19
+ },
20
+ "./row/styles.css": "./dist/row/styles.css",
21
+ "./choice-chips": {
22
+ "types": "./dist/choice-chips/index.d.ts",
23
+ "import": "./dist/choice-chips/index.js"
24
+ },
25
+ "./choice-chips/styles.css": "./dist/choice-chips/styles.css",
26
+ "./page-header": {
27
+ "types": "./dist/page-header/index.d.ts",
28
+ "import": "./dist/page-header/index.js"
29
+ },
30
+ "./page-header/styles.css": "./dist/page-header/styles.css",
31
+ "./app-shell": {
32
+ "types": "./dist/app-shell/index.d.ts",
33
+ "import": "./dist/app-shell/index.js"
34
+ },
35
+ "./app-shell/styles.css": "./dist/app-shell/styles.css",
16
36
  "./sound": {
17
37
  "types": "./dist/sound/index.d.ts",
18
38
  "import": "./dist/sound/index.js"