@supersuit/components 0.0.0-stage → 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 +55 -0
- package/LICENSE +21 -0
- package/README.md +338 -2
- package/bin/supersuit-theme.mjs +116 -0
- package/dist/app-shell/app-shell.d.ts +68 -0
- package/dist/app-shell/app-shell.js +62 -0
- package/dist/app-shell/index.d.ts +3 -0
- package/dist/app-shell/index.js +5 -0
- package/dist/app-shell/sheet.d.ts +14 -0
- package/dist/app-shell/sheet.js +57 -0
- package/dist/app-shell/styles.css +112 -0
- package/dist/check/depth/bar.d.ts +27 -0
- package/dist/check/depth/bar.js +40 -0
- package/dist/check/depth/check.d.ts +40 -0
- package/dist/check/depth/check.js +50 -0
- package/dist/check/depth/crop.d.ts +24 -0
- package/dist/check/depth/crop.js +126 -0
- package/dist/check/depth/index.d.ts +3 -0
- package/dist/check/depth/index.js +5 -0
- package/dist/check/depth/measure.d.ts +42 -0
- package/dist/check/depth/measure.js +141 -0
- package/dist/check/depth/parts-page.d.ts +6 -0
- package/dist/check/depth/parts-page.js +69 -0
- package/dist/check/depth/playwright.d.ts +4 -0
- package/dist/check/depth/playwright.js +10 -0
- package/dist/check/depth/png.d.ts +3 -0
- package/dist/check/depth/png.js +12 -0
- package/dist/check/depth/shoot.d.ts +37 -0
- package/dist/check/depth/shoot.js +30 -0
- package/dist/choice-chips/choice-chips.d.ts +40 -0
- package/dist/choice-chips/choice-chips.js +106 -0
- package/dist/choice-chips/index.d.ts +1 -0
- package/dist/choice-chips/index.js +3 -0
- package/dist/choice-chips/styles.css +38 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +11 -0
- package/dist/page-header/index.d.ts +2 -0
- package/dist/page-header/index.js +4 -0
- package/dist/page-header/page-header.d.ts +58 -0
- package/dist/page-header/page-header.js +124 -0
- package/dist/page-header/shell-context.d.ts +12 -0
- package/dist/page-header/shell-context.js +21 -0
- package/dist/page-header/styles.css +77 -0
- package/dist/row/index.d.ts +1 -0
- package/dist/row/index.js +3 -0
- package/dist/row/row.d.ts +76 -0
- package/dist/row/row.js +69 -0
- package/dist/row/styles.css +69 -0
- package/dist/sound/engine.d.ts +59 -0
- package/dist/sound/engine.js +325 -0
- package/dist/sound/index.d.ts +18 -0
- package/dist/sound/index.js +10 -0
- package/dist/sound/synth.d.ts +24 -0
- package/dist/sound/synth.js +139 -0
- package/dist/theme/color.d.ts +29 -0
- package/dist/theme/color.js +116 -0
- package/dist/theme/compile.d.ts +23 -0
- package/dist/theme/compile.js +138 -0
- package/dist/theme/index.d.ts +3 -0
- package/dist/theme/index.js +4 -0
- package/dist/theme/record.d.ts +90 -0
- package/dist/theme/record.js +222 -0
- package/dist/voice-field/box-trace.d.ts +18 -0
- package/dist/voice-field/box-trace.js +87 -0
- package/dist/voice-field/index.d.ts +8 -0
- package/dist/voice-field/index.js +10 -0
- package/dist/voice-field/recorder.d.ts +71 -0
- package/dist/voice-field/recorder.js +211 -0
- package/dist/voice-field/rules.d.ts +27 -0
- package/dist/voice-field/rules.js +62 -0
- package/dist/voice-field/saved-take.d.ts +7 -0
- package/dist/voice-field/saved-take.js +66 -0
- package/dist/voice-field/store.d.ts +27 -0
- package/dist/voice-field/store.js +40 -0
- package/dist/voice-field/styles.css +161 -0
- package/dist/voice-field/toast.d.ts +13 -0
- package/dist/voice-field/toast.js +26 -0
- package/dist/voice-field/voice-field.d.ts +80 -0
- package/dist/voice-field/voice-field.js +259 -0
- package/dist/voice-field/words.d.ts +37 -0
- package/dist/voice-field/words.js +33 -0
- package/package.json +126 -4
- package/specs/brand-theme/v1/SPEC.md +130 -0
- package/specs/brand-theme/v1/default-bar.json +1196 -0
|
@@ -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,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;
|
package/dist/row/row.js
ADDED
|
@@ -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; } }
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { type SoundName, type SoundRecipe } from './synth.js';
|
|
2
|
+
export type SoundSetting = 'sounds' | 'pressSounds' | 'haptics';
|
|
3
|
+
export declare const SETTING_DEFAULTS: Record<SoundSetting, boolean>;
|
|
4
|
+
export declare const settingKey: (key: SoundSetting) => string;
|
|
5
|
+
/** The primary faces Supertools draws as buttons ("BUTTONS LOOK LIKE BUTTONS"), and a card's recommended answer:
|
|
6
|
+
* feel.ts's PRIMARY, kept until the raw-control baseline reaches zero. A switch, a radio, a tab or a pressed chip
|
|
7
|
+
* is a choice, not a button. `data-feel="tap"` opts any other control in. */
|
|
8
|
+
export declare const PRIMARY: string;
|
|
9
|
+
/** Android patterns, in milliseconds (vibrate, pause, vibrate ...). */
|
|
10
|
+
export declare const PATTERNS: Record<SoundName, number[]>;
|
|
11
|
+
/** iPhone ticks: one for a tap, two for success, three for an error, one for the rest. */
|
|
12
|
+
export declare const TICKS: Record<SoundName, number>;
|
|
13
|
+
/** The gap between iPhone ticks. A later tick goes only while the browser still counts the tap as active. */
|
|
14
|
+
export declare const TICK_GAP_MS = 90;
|
|
15
|
+
interface UserActivation {
|
|
16
|
+
isActive: boolean;
|
|
17
|
+
hasBeenActive: boolean;
|
|
18
|
+
}
|
|
19
|
+
type Nav = {
|
|
20
|
+
vibrate?: (p: number | number[]) => boolean;
|
|
21
|
+
userActivation?: UserActivation;
|
|
22
|
+
};
|
|
23
|
+
type Ctx = Pick<AudioContext, 'state' | 'currentTime' | 'destination' | 'resume' | 'createBuffer' | 'createBufferSource'> & {
|
|
24
|
+
sampleRate?: number;
|
|
25
|
+
};
|
|
26
|
+
export interface SoundEnv {
|
|
27
|
+
win: (Pick<Window, 'matchMedia' | 'setTimeout'> & Partial<Pick<Window, 'requestAnimationFrame'>> & {
|
|
28
|
+
AudioContext?: new () => Ctx;
|
|
29
|
+
webkitAudioContext?: new () => Ctx;
|
|
30
|
+
}) | null;
|
|
31
|
+
doc: Document | null;
|
|
32
|
+
nav: Nav | null;
|
|
33
|
+
storage: Pick<Storage, 'getItem' | 'setItem'> | null;
|
|
34
|
+
now(): number;
|
|
35
|
+
}
|
|
36
|
+
export interface InstallOptions {
|
|
37
|
+
/** Which elements make a tap (sound and haptic). Default: PRIMARY. */
|
|
38
|
+
selectors?: {
|
|
39
|
+
tap?: string;
|
|
40
|
+
};
|
|
41
|
+
/** The brand's sound recipe. Default: Maison. */
|
|
42
|
+
recipe?: SoundRecipe;
|
|
43
|
+
}
|
|
44
|
+
export declare function makeSoundEngine(envOf?: () => SoundEnv): {
|
|
45
|
+
play: (name: SoundName) => void;
|
|
46
|
+
setting: (key: SoundSetting) => boolean;
|
|
47
|
+
setSetting: (key: SoundSetting, on: boolean) => void;
|
|
48
|
+
soundFor: (target: Element, opts?: {
|
|
49
|
+
tap?: string;
|
|
50
|
+
}) => SoundName | null;
|
|
51
|
+
install: (doc?: Document | null, opts?: InstallOptions) => () => void;
|
|
52
|
+
haptic: (name: SoundName) => void;
|
|
53
|
+
haptics: () => "vibrate" | "switch" | null;
|
|
54
|
+
unlock: () => void;
|
|
55
|
+
/** for tests */
|
|
56
|
+
reset(): void;
|
|
57
|
+
};
|
|
58
|
+
export type SoundEngine = ReturnType<typeof makeSoundEngine>;
|
|
59
|
+
export {};
|