@cameronsjo/artificer 0.23.0 → 0.24.1
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/README.md +1 -1
- package/dist/react/chrome.d.ts +98 -0
- package/dist/react/chrome.d.ts.map +1 -0
- package/dist/react/chrome.js +171 -0
- package/dist/react/index.d.ts +6 -0
- package/dist/react/index.d.ts.map +1 -0
- package/dist/react/index.js +6 -0
- package/dist/react/primitives.d.ts +98 -0
- package/dist/react/primitives.d.ts.map +1 -0
- package/dist/react/primitives.js +115 -0
- package/dist/react/sidenav-sections.d.ts +36 -0
- package/dist/react/sidenav-sections.d.ts.map +1 -0
- package/dist/react/sidenav-sections.js +41 -0
- package/package.json +43 -8
- package/reference/SKILL.md +1 -1
- package/src/artificer-whimsy.js +1 -1
- package/src/artificer.css +14 -2
- package/src/primitives.json +44 -8
- package/src/tokens.json +1 -1
- package/types/focus.d.ts +17 -0
- package/types/icons.d.ts +23 -0
- package/types/options.d.ts +33 -0
- package/types/tabs.d.ts +26 -0
- package/types/theme.d.ts +28 -0
- package/types/tree.d.ts +31 -0
- package/types/whimsy.d.ts +47 -0
package/README.md
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
# Artificer · Design System Handoff
|
|
2
2
|
|
|
3
3
|
Cameron's personal design system, packaged for use in real codebases.
|
|
4
|
-
**v0.
|
|
4
|
+
**v0.24.1 · 2026** — the chrome ships once: a compiled React adapter lands at `@cameronsjo/artificer/react` (ESM + `d.ts`, `react >=18` peer) with the whole app shell as components — `AppShell`, `Appbar`, `NavDrawer`, `SideNav` (flat or collapsible sections), `SideNavFooter`, and the canonical `ThemeToggle` — so consumers import the chrome instead of hand-assembling recipes that drift. Ambient TypeScript types ship for all seven vanilla behavior modules. `.app-shell` gains knobs (`--shell-rail`, `--shell-gap`) and `.sidenav--sticky` mints the pinned rail, replacing per-app grid overrides. Nav `href`s pass a scheme guard; the export pipeline rebuilds `dist/` from reviewed sources and hard-fails on missing package exports. See `CHANGELOG.md` for what changed.
|
|
5
5
|
|
|
6
6
|
---
|
|
7
7
|
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* App chrome — the shared shell every Artificer tool-SPA composes: appbar,
|
|
3
|
+
* nav drawer, sidenav (flat or collapsible sections), and the theme toggle.
|
|
4
|
+
*
|
|
5
|
+
* One implementation, canonical markup, behavior from the shipped vanilla
|
|
6
|
+
* modules (artificer-theme.js, artificer-focus.js) — never re-implemented
|
|
7
|
+
* here. Born from the 2026-08 mobile sweep, where hand-copied chrome drifted
|
|
8
|
+
* into divergent bugs across consumers.
|
|
9
|
+
*/
|
|
10
|
+
import * as React from 'react';
|
|
11
|
+
export declare function ThemeToggle({ inline, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
12
|
+
inline?: boolean;
|
|
13
|
+
}): React.JSX.Element;
|
|
14
|
+
/**
|
|
15
|
+
* Reactive read of the applied theme ('dark' | 'light'). State is OWNED by
|
|
16
|
+
* artificer-theme.js — this hook only observes `data-theme` on <html>; call
|
|
17
|
+
* `toggle()` (which defers to the module) to change it. Replaces the removed
|
|
18
|
+
* 2-state `useTheme`, which duplicated the module's persistence and predated
|
|
19
|
+
* the canonical dark → light → auto cycle.
|
|
20
|
+
*/
|
|
21
|
+
export declare function useThemeMode(): {
|
|
22
|
+
theme: 'dark' | 'light';
|
|
23
|
+
toggle: () => void;
|
|
24
|
+
};
|
|
25
|
+
export declare function AppShell({ rail, gap, className, style, ...rest }: React.HTMLAttributes<HTMLDivElement> & {
|
|
26
|
+
/** Rail column width — sets --shell-rail (default 240px). */
|
|
27
|
+
rail?: string;
|
|
28
|
+
/** Rail↔content column gap — sets --shell-gap (default 0). */
|
|
29
|
+
gap?: string;
|
|
30
|
+
}): React.JSX.Element;
|
|
31
|
+
export declare function AppShellContent({ as: As, className, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
32
|
+
as?: React.ElementType;
|
|
33
|
+
}): React.JSX.Element;
|
|
34
|
+
export declare function Appbar({ brand, brandHref, brandWhimsy, contained, sticky, search, actions, menu, className, children, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
35
|
+
/** Brand text/node — rendered inside the canonical `.appbar__brand > .wordmark` composition. */
|
|
36
|
+
brand: React.ReactNode;
|
|
37
|
+
brandHref?: string;
|
|
38
|
+
/** Adds `.whimsy` to the wordmark (the brand is the sanctioned whimsy home in the bar). */
|
|
39
|
+
brandWhimsy?: boolean;
|
|
40
|
+
/** `.appbar--contained` — zero inline padding when the bar sits inside a padded container. */
|
|
41
|
+
contained?: boolean;
|
|
42
|
+
/** false → `.appbar--static` (opts out of sticky positioning). */
|
|
43
|
+
sticky?: boolean;
|
|
44
|
+
search?: React.ReactNode;
|
|
45
|
+
actions?: React.ReactNode;
|
|
46
|
+
/** Hamburger — appears below --bp-tablet via the `.appbar__menu-btn` rule. */
|
|
47
|
+
menu?: {
|
|
48
|
+
controls: string;
|
|
49
|
+
open: boolean;
|
|
50
|
+
onClick: () => void;
|
|
51
|
+
label?: string;
|
|
52
|
+
};
|
|
53
|
+
}): React.JSX.Element;
|
|
54
|
+
export declare function NavDrawer({ open, onClose, id, label, className, children, }: {
|
|
55
|
+
open: boolean;
|
|
56
|
+
onClose: () => void;
|
|
57
|
+
/** Matches the Appbar menu's aria-controls. */
|
|
58
|
+
id: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
className?: string;
|
|
61
|
+
children: React.ReactNode;
|
|
62
|
+
}): React.JSX.Element;
|
|
63
|
+
export interface SideNavItem {
|
|
64
|
+
key: string;
|
|
65
|
+
label: React.ReactNode;
|
|
66
|
+
/** Rendered as <a href> when present, else a <button> (SPA state switch). */
|
|
67
|
+
href?: string;
|
|
68
|
+
onSelect?: () => void;
|
|
69
|
+
active?: boolean;
|
|
70
|
+
/** Lucide-canonical icon name, rendered as `<i data-icon>`. */
|
|
71
|
+
icon?: string;
|
|
72
|
+
count?: React.ReactNode;
|
|
73
|
+
}
|
|
74
|
+
export interface SideNavGroup {
|
|
75
|
+
key: string;
|
|
76
|
+
label: React.ReactNode;
|
|
77
|
+
items: SideNavItem[];
|
|
78
|
+
}
|
|
79
|
+
/**
|
|
80
|
+
* The section spine. Flat groups by default; `sections` renders each group as
|
|
81
|
+
* a collapsible `<details class="sidenav__section">` driven by the pure
|
|
82
|
+
* open-state machine (desktop open, mobile collapsed-except-active,
|
|
83
|
+
* force-open on navigation change, user toggles sticky, viewport changes
|
|
84
|
+
* re-derive untouched sections only).
|
|
85
|
+
*/
|
|
86
|
+
export declare function SideNav({ groups, sections, sticky, footer, className, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
87
|
+
groups: SideNavGroup[];
|
|
88
|
+
sections?: boolean;
|
|
89
|
+
/** `.sidenav--sticky` — the pinned rail (set --sidenav-sticky-top to clear sticky chrome). */
|
|
90
|
+
sticky?: boolean;
|
|
91
|
+
/** Bottom-anchored row (SideNavFooter) — the theme toggle's drawer seat. */
|
|
92
|
+
footer?: React.ReactNode;
|
|
93
|
+
}): React.JSX.Element;
|
|
94
|
+
/** Bottom-anchored settings row — the theme toggle's drawer seat. */
|
|
95
|
+
export declare function SideNavFooter({ label, className, children, ...rest }: React.HTMLAttributes<HTMLDivElement> & {
|
|
96
|
+
label?: React.ReactNode;
|
|
97
|
+
}): React.JSX.Element;
|
|
98
|
+
//# sourceMappingURL=chrome.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"chrome.d.ts","sourceRoot":"","sources":["../../framework-adapters/react/src/chrome.tsx"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAkB/B,wBAAgB,WAAW,CAAC,EAC1B,MAAc,EACd,SAAS,EACT,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,oBAAoB,CAAC,iBAAiB,CAAC,GAAG;IAAE,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,qBAUtE;AAED;;;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E,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;CAC1B,qBA4FA;AAED,qEAAqE;AACrE,wBAAgB,aAAa,CAAC,EAC5B,KAAe,EACf,SAAS,EACT,QAAQ,EACR,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,cAAc,CAAC,cAAc,CAAC,GAAG;IAAE,KAAK,CAAC,EAAE,KAAK,CAAC,SAAS,CAAA;CAAE,qBAOpE"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import { Fragment as _Fragment, jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* App chrome — the shared shell every Artificer tool-SPA composes: appbar,
|
|
4
|
+
* nav drawer, sidenav (flat or collapsible sections), and the theme toggle.
|
|
5
|
+
*
|
|
6
|
+
* One implementation, canonical markup, behavior from the shipped vanilla
|
|
7
|
+
* modules (artificer-theme.js, artificer-focus.js) — never re-implemented
|
|
8
|
+
* here. Born from the 2026-08 mobile sweep, where hand-copied chrome drifted
|
|
9
|
+
* into divergent bugs across consumers.
|
|
10
|
+
*/
|
|
11
|
+
import * as React from 'react';
|
|
12
|
+
import { cx, safeHref } from './primitives.js';
|
|
13
|
+
import { defaultSectionOpen, onNavigationActivates, onUserToggle, onViewportChange, } from './sidenav-sections.js';
|
|
14
|
+
// ─── ThemeToggle ─────────────────────────────────────────────────────────
|
|
15
|
+
//
|
|
16
|
+
// The canonical control is an EMPTY button — artificer-theme.js observes the
|
|
17
|
+
// DOM (v0.19.0+), injects the half-circle glyph, narrates state on
|
|
18
|
+
// aria-label/title, and keeps every instance on the page in sync. React must
|
|
19
|
+
// render it childless and never manage its state.
|
|
20
|
+
export function ThemeToggle({ inline = false, className, ...rest }) {
|
|
21
|
+
return (_jsx("button", { type: "button", "data-theme-toggle": true, "aria-label": "Toggle theme", ...rest, className: cx('theme-toggle', inline && 'theme-toggle--inline', className) }));
|
|
22
|
+
}
|
|
23
|
+
/**
|
|
24
|
+
* Reactive read of the applied theme ('dark' | 'light'). State is OWNED by
|
|
25
|
+
* artificer-theme.js — this hook only observes `data-theme` on <html>; call
|
|
26
|
+
* `toggle()` (which defers to the module) to change it. Replaces the removed
|
|
27
|
+
* 2-state `useTheme`, which duplicated the module's persistence and predated
|
|
28
|
+
* the canonical dark → light → auto cycle.
|
|
29
|
+
*/
|
|
30
|
+
export function useThemeMode() {
|
|
31
|
+
const subscribe = React.useCallback((onChange) => {
|
|
32
|
+
const mo = new MutationObserver(onChange);
|
|
33
|
+
mo.observe(document.documentElement, { attributes: true, attributeFilter: ['data-theme'] });
|
|
34
|
+
return () => mo.disconnect();
|
|
35
|
+
}, []);
|
|
36
|
+
const theme = React.useSyncExternalStore(subscribe, () => (document.documentElement.getAttribute('data-theme') === 'light' ? 'light' : 'dark'), () => 'dark');
|
|
37
|
+
const toggle = React.useCallback(() => {
|
|
38
|
+
window.ArtificerTheme?.toggle?.();
|
|
39
|
+
}, []);
|
|
40
|
+
return { theme, toggle };
|
|
41
|
+
}
|
|
42
|
+
// ─── AppShell ────────────────────────────────────────────────────────────
|
|
43
|
+
export function AppShell({ rail, gap, className, style, ...rest }) {
|
|
44
|
+
const vars = {};
|
|
45
|
+
if (rail)
|
|
46
|
+
vars['--shell-rail'] = rail;
|
|
47
|
+
if (gap)
|
|
48
|
+
vars['--shell-gap'] = gap;
|
|
49
|
+
return (_jsx("div", { ...rest, style: { ...vars, ...style }, className: cx('app-shell', className) }));
|
|
50
|
+
}
|
|
51
|
+
export function AppShellContent({ as: As = 'main', className, ...rest }) {
|
|
52
|
+
return _jsx(As, { ...rest, className: cx('app-shell__content', className) });
|
|
53
|
+
}
|
|
54
|
+
// ─── Appbar ──────────────────────────────────────────────────────────────
|
|
55
|
+
export function Appbar({ brand, brandHref = '/', brandWhimsy = false, contained = false, sticky = true, search, actions, menu, className, children, ...rest }) {
|
|
56
|
+
return (_jsxs("header", { ...rest, className: cx('appbar', contained && 'appbar--contained', !sticky && 'appbar--static', className), children: [menu && (_jsx("button", { type: "button", className: "btn btn--ghost btn--icon btn--icon-prominent appbar__menu-btn", "aria-controls": menu.controls, "aria-expanded": menu.open, "aria-label": menu.label ?? (menu.open ? 'Close navigation' : 'Open navigation'), onClick: menu.onClick, children: _jsx("i", { "data-icon": "menu", "aria-hidden": "true" }) })), _jsx("a", { className: "appbar__brand", href: safeHref(brandHref) ?? '/', children: _jsx("span", { className: cx('wordmark', brandWhimsy && 'whimsy'), children: brand }) }), search && _jsx("div", { className: "appbar__search", children: search }), _jsx("span", { className: "appbar__spacer" }), actions && _jsx("div", { className: "appbar__actions", children: actions }), children] }));
|
|
57
|
+
}
|
|
58
|
+
// ─── NavDrawer ───────────────────────────────────────────────────────────
|
|
59
|
+
//
|
|
60
|
+
// Off-canvas drawer + scrim. The `[data-nav-open]` CSS hook lives on a
|
|
61
|
+
// display:contents wrapper OWNED by the component, so consumers don't manage
|
|
62
|
+
// an ancestor attribute. Closed → `inert` (set via attribute for React 18
|
|
63
|
+
// compat); open → focus-trapped via artificer-focus.js, Esc and scrim-click
|
|
64
|
+
// close.
|
|
65
|
+
export function NavDrawer({ open, onClose, id, label = 'Navigation', className, children, }) {
|
|
66
|
+
const ref = React.useRef(null);
|
|
67
|
+
// Attribute toggle in a LAYOUT effect — synchronous before paint, so a
|
|
68
|
+
// closed drawer is never focusable-while-aria-hidden for a visible frame.
|
|
69
|
+
// The declarative prop can't serve both React majors: 18 renders only the
|
|
70
|
+
// string form (`inert=""`) and warns on booleans; 19 types it boolean and
|
|
71
|
+
// DROPS the falsy string. CSR contract: pre-hydration SSR markup carries
|
|
72
|
+
// aria-hidden only (both current consumers are CSR SPAs).
|
|
73
|
+
React.useLayoutEffect(() => {
|
|
74
|
+
ref.current?.toggleAttribute('inert', !open);
|
|
75
|
+
}, [open]);
|
|
76
|
+
React.useEffect(() => {
|
|
77
|
+
if (!open || !ref.current || !window.ArtificerFocus)
|
|
78
|
+
return;
|
|
79
|
+
const trap = window.ArtificerFocus.trap(ref.current, { onEscape: onClose });
|
|
80
|
+
return () => trap.release();
|
|
81
|
+
}, [open, onClose]);
|
|
82
|
+
return (_jsxs("div", { style: { display: 'contents' }, ...(open ? { 'data-nav-open': '' } : {}), children: [_jsx("div", { className: "nav-scrim", onClick: onClose }), _jsx("aside", { ref: ref, id: id, className: cx('nav-drawer', className), "aria-label": label, "aria-hidden": !open, children: children })] }));
|
|
83
|
+
}
|
|
84
|
+
function SideNavRow({ item }) {
|
|
85
|
+
const inner = (_jsxs(_Fragment, { children: [item.icon && _jsx("i", { "data-icon": item.icon, "aria-hidden": "true" }), _jsx("span", { className: "label", children: item.label }), item.count != null && _jsx("span", { className: "count", children: item.count })] }));
|
|
86
|
+
const current = item.active ? { 'aria-current': 'page' } : {};
|
|
87
|
+
// safeHref: a scheme-bearing href must be http/https/mailto/tel — a
|
|
88
|
+
// javascript: URL from a dynamic nav source would execute on click.
|
|
89
|
+
const href = safeHref(item.href);
|
|
90
|
+
return href ? (_jsx("a", { href: href, ...current, onClick: item.onSelect, children: inner })) : (_jsx("button", { type: "button", ...current, onClick: item.onSelect, children: inner }));
|
|
91
|
+
}
|
|
92
|
+
const TABLET_QUERY = '(max-width: 800px)'; // literal mirror of --bp-tablet (CSS @media can't read tokens)
|
|
93
|
+
function currentViewport() {
|
|
94
|
+
return typeof window !== 'undefined' && window.matchMedia(TABLET_QUERY).matches ? 'mobile' : 'desktop';
|
|
95
|
+
}
|
|
96
|
+
function groupIsActive(group) {
|
|
97
|
+
return group.items.some((i) => i.active);
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* The section spine. Flat groups by default; `sections` renders each group as
|
|
101
|
+
* a collapsible `<details class="sidenav__section">` driven by the pure
|
|
102
|
+
* open-state machine (desktop open, mobile collapsed-except-active,
|
|
103
|
+
* force-open on navigation change, user toggles sticky, viewport changes
|
|
104
|
+
* re-derive untouched sections only).
|
|
105
|
+
*/
|
|
106
|
+
export function SideNav({ groups, sections = false, sticky = false, footer, className, ...rest }) {
|
|
107
|
+
// SSR-agnostic initial state: always the 'desktop' shape (every section
|
|
108
|
+
// open), matching what a server render would have produced — a viewport
|
|
109
|
+
// read here would hydration-mismatch on a mobile client (<details open>
|
|
110
|
+
// disagreement). The mount effect below corrects to the real viewport.
|
|
111
|
+
const [openMap, setOpenMap] = React.useState(() => Object.fromEntries(groups.map((g) => [g.key, { open: defaultSectionOpen('desktop', groupIsActive(g)), touched: false }])));
|
|
112
|
+
// Track per-group active state so a navigation that ACTIVATES a section
|
|
113
|
+
// force-opens it (false→true edge only — a deliberate collapse of the
|
|
114
|
+
// already-active section is never fought).
|
|
115
|
+
const prevActive = React.useRef({});
|
|
116
|
+
React.useEffect(() => {
|
|
117
|
+
if (!sections)
|
|
118
|
+
return;
|
|
119
|
+
setOpenMap((m) => {
|
|
120
|
+
let next = m;
|
|
121
|
+
for (const g of groups) {
|
|
122
|
+
const active = groupIsActive(g);
|
|
123
|
+
const was = prevActive.current[g.key] ?? false;
|
|
124
|
+
prevActive.current[g.key] = active;
|
|
125
|
+
const state = m[g.key] ?? { open: defaultSectionOpen(currentViewport(), active), touched: false };
|
|
126
|
+
if (active && !was) {
|
|
127
|
+
if (next === m)
|
|
128
|
+
next = { ...m };
|
|
129
|
+
next[g.key] = onNavigationActivates(state);
|
|
130
|
+
}
|
|
131
|
+
else if (!(g.key in m)) {
|
|
132
|
+
if (next === m)
|
|
133
|
+
next = { ...m };
|
|
134
|
+
next[g.key] = state;
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
return next;
|
|
138
|
+
});
|
|
139
|
+
}, [sections, groups]);
|
|
140
|
+
// Viewport crossings re-derive defaults for untouched sections — and the
|
|
141
|
+
// same correction runs ONCE at mount, because the initial state above is
|
|
142
|
+
// deliberately the SSR-safe desktop shape rather than a viewport read.
|
|
143
|
+
React.useEffect(() => {
|
|
144
|
+
if (!sections || typeof window === 'undefined')
|
|
145
|
+
return;
|
|
146
|
+
const mq = window.matchMedia(TABLET_QUERY);
|
|
147
|
+
const applyViewport = () => {
|
|
148
|
+
const vp = mq.matches ? 'mobile' : 'desktop';
|
|
149
|
+
setOpenMap((m) => Object.fromEntries(groups.map((g) => {
|
|
150
|
+
const state = m[g.key] ?? { open: defaultSectionOpen(vp, groupIsActive(g)), touched: false };
|
|
151
|
+
return [g.key, onViewportChange(state, vp, groupIsActive(g))];
|
|
152
|
+
})));
|
|
153
|
+
};
|
|
154
|
+
applyViewport();
|
|
155
|
+
mq.addEventListener('change', applyViewport);
|
|
156
|
+
return () => mq.removeEventListener('change', applyViewport);
|
|
157
|
+
}, [sections, groups]);
|
|
158
|
+
return (_jsxs("nav", { ...rest, className: cx('sidenav', sticky && 'sidenav--sticky', className), children: [groups.map((g) => sections ? (_jsxs("details", { className: "sidenav__section", open: openMap[g.key]?.open ?? true, onToggle: (e) => {
|
|
159
|
+
const nextOpen = e.currentTarget.open;
|
|
160
|
+
setOpenMap((m) => {
|
|
161
|
+
const state = m[g.key];
|
|
162
|
+
if (state && state.open === nextOpen)
|
|
163
|
+
return m; // programmatic echo, not a user toggle
|
|
164
|
+
return { ...m, [g.key]: onUserToggle(nextOpen) };
|
|
165
|
+
});
|
|
166
|
+
}, children: [_jsx("summary", { children: g.label }), g.items.map((item) => (_jsx(SideNavRow, { item: item }, item.key)))] }, g.key)) : (_jsxs(React.Fragment, { children: [_jsx("div", { className: "sidenav__group", children: g.label }), g.items.map((item) => (_jsx(SideNavRow, { item: item }, item.key)))] }, g.key))), footer] }));
|
|
167
|
+
}
|
|
168
|
+
/** Bottom-anchored settings row — the theme toggle's drawer seat. */
|
|
169
|
+
export function SideNavFooter({ label = 'Theme', className, children, ...rest }) {
|
|
170
|
+
return (_jsxs("div", { ...rest, className: cx('sidenav__footer', className), children: [_jsx("span", { children: label }), children ?? _jsx(ThemeToggle, { inline: true })] }));
|
|
171
|
+
}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { cx, safeHref, Stack, Cluster, Container, GridAuto, Button, Field, Input, Textarea, Select, Notification, Modal, Icon, useIcons, useWhimsy, } from './primitives.js';
|
|
2
|
+
export { ThemeToggle, useThemeMode, AppShell, AppShellContent, Appbar, NavDrawer, SideNav, SideNavFooter, } from './chrome.js';
|
|
3
|
+
export type { SideNavItem, SideNavGroup } from './chrome.js';
|
|
4
|
+
export { defaultSectionOpen, onNavigationActivates, onUserToggle, onViewportChange, } from './sidenav-sections.js';
|
|
5
|
+
export type { SectionOpenState, Viewport } from './sidenav-sections.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../framework-adapters/react/src/index.ts"],"names":[],"mappings":"AAIA,OAAO,EACL,EAAE,EACF,QAAQ,EACR,KAAK,EACL,OAAO,EACP,SAAS,EACT,QAAQ,EACR,MAAM,EACN,KAAK,EACL,KAAK,EACL,QAAQ,EACR,MAAM,EACN,YAAY,EACZ,KAAK,EACL,IAAI,EACJ,QAAQ,EACR,SAAS,GACV,MAAM,iBAAiB,CAAC;AAEzB,OAAO,EACL,WAAW,EACX,YAAY,EACZ,QAAQ,EACR,eAAe,EACf,MAAM,EACN,SAAS,EACT,OAAO,EACP,aAAa,GACd,MAAM,aAAa,CAAC;AACrB,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE7D,OAAO,EACL,kBAAkB,EAClB,qBAAqB,EACrB,YAAY,EACZ,gBAAgB,GACjB,MAAM,uBAAuB,CAAC;AAC/B,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAC"}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
// @cameronsjo/artificer/react — React adapter, compiled to dist/react.
|
|
2
|
+
// Primitives emit canonical classes; chrome components single-source the app
|
|
3
|
+
// shell; behavior stays in the vanilla modules (theme/focus/icons).
|
|
4
|
+
export { cx, safeHref, Stack, Cluster, Container, GridAuto, Button, Field, Input, Textarea, Select, Notification, Modal, Icon, useIcons, useWhimsy, } from './primitives.js';
|
|
5
|
+
export { ThemeToggle, useThemeMode, AppShell, AppShellContent, Appbar, NavDrawer, SideNav, SideNavFooter, } from './chrome.js';
|
|
6
|
+
export { defaultSectionOpen, onNavigationActivates, onUserToggle, onViewportChange, } from './sidenav-sections.js';
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* React primitives for Artificer — thin wrappers that emit the canonical CSS
|
|
3
|
+
* classes; they don't reinvent the system.
|
|
4
|
+
*
|
|
5
|
+
* Setup once, in your app entry (e.g. main.tsx):
|
|
6
|
+
*
|
|
7
|
+
* import '@cameronsjo/artificer/artificer.css';
|
|
8
|
+
* import '@cameronsjo/artificer/theme.js';
|
|
9
|
+
* import '@cameronsjo/artificer/focus.js'; // only if using <Modal> / <NavDrawer>
|
|
10
|
+
* import '@cameronsjo/artificer/icons.js'; // only if using <Icon>
|
|
11
|
+
*/
|
|
12
|
+
import * as React from 'react';
|
|
13
|
+
/** Join class names, dropping falsy segments. */
|
|
14
|
+
export declare function cx(...parts: Array<string | false | null | undefined>): string;
|
|
15
|
+
/**
|
|
16
|
+
* Nav-href guard — the chrome components are the first place Artificer
|
|
17
|
+
* renders consumer-supplied strings into <a href>, so the scheme check lives
|
|
18
|
+
* here once instead of in every consumer. React renders `javascript:` URLs
|
|
19
|
+
* (dev-warning only), which would execute in the app origin on click.
|
|
20
|
+
* Allowed: relative paths, fragments, queries, and http/https/mailto/tel.
|
|
21
|
+
* Anything else returns undefined — the caller drops the attribute.
|
|
22
|
+
*/
|
|
23
|
+
export declare function safeHref(href: string | undefined): string | undefined;
|
|
24
|
+
type StackGap = 'xs' | 'sm' | 'md' | 'lg' | 'xl' | '2xl';
|
|
25
|
+
export declare function Stack({ gap, as: As, className, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
26
|
+
gap?: StackGap;
|
|
27
|
+
as?: React.ElementType;
|
|
28
|
+
}): React.JSX.Element;
|
|
29
|
+
export declare function Cluster({ gap, between, end, as: As, className, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
30
|
+
gap?: 'sm' | 'md' | 'lg';
|
|
31
|
+
between?: boolean;
|
|
32
|
+
end?: boolean;
|
|
33
|
+
as?: React.ElementType;
|
|
34
|
+
}): React.JSX.Element;
|
|
35
|
+
export declare function Container({ size, as: As, className, ...rest }: React.HTMLAttributes<HTMLElement> & {
|
|
36
|
+
size?: 'sm' | 'md' | 'lg';
|
|
37
|
+
as?: React.ElementType;
|
|
38
|
+
}): React.JSX.Element;
|
|
39
|
+
export declare function GridAuto({ min, className, style, ...rest }: React.HTMLAttributes<HTMLDivElement> & {
|
|
40
|
+
min?: number;
|
|
41
|
+
}): React.JSX.Element;
|
|
42
|
+
type ButtonVariant = 'primary' | 'secondary' | 'ghost' | 'destructive';
|
|
43
|
+
export declare function Button({ variant, size, className, ...rest }: React.ButtonHTMLAttributes<HTMLButtonElement> & {
|
|
44
|
+
variant?: ButtonVariant;
|
|
45
|
+
size?: 'sm';
|
|
46
|
+
}): React.JSX.Element;
|
|
47
|
+
interface FieldControlProps {
|
|
48
|
+
id?: string;
|
|
49
|
+
'aria-invalid'?: 'true';
|
|
50
|
+
'aria-describedby'?: string;
|
|
51
|
+
}
|
|
52
|
+
export declare function Field({ label, hint, error, id, className, children, }: {
|
|
53
|
+
label: string;
|
|
54
|
+
hint?: string;
|
|
55
|
+
error?: string;
|
|
56
|
+
id: string;
|
|
57
|
+
className?: string;
|
|
58
|
+
children: React.ReactElement<FieldControlProps>;
|
|
59
|
+
}): React.JSX.Element;
|
|
60
|
+
export declare const Input: (p: React.InputHTMLAttributes<HTMLInputElement>) => React.JSX.Element;
|
|
61
|
+
export declare const Textarea: (p: React.TextareaHTMLAttributes<HTMLTextAreaElement>) => React.JSX.Element;
|
|
62
|
+
export declare const Select: (p: React.SelectHTMLAttributes<HTMLSelectElement>) => React.JSX.Element;
|
|
63
|
+
type NotifTier = 'urgent' | 'attention' | 'info' | 'background';
|
|
64
|
+
export declare function Notification({ tier, title, children, action, }: {
|
|
65
|
+
tier?: NotifTier;
|
|
66
|
+
title: string;
|
|
67
|
+
children?: React.ReactNode;
|
|
68
|
+
action?: {
|
|
69
|
+
label: string;
|
|
70
|
+
onClick: () => void;
|
|
71
|
+
};
|
|
72
|
+
}): React.JSX.Element;
|
|
73
|
+
declare global {
|
|
74
|
+
interface Window {
|
|
75
|
+
ArtificerFocus?: {
|
|
76
|
+
trap: (el: HTMLElement, opts?: {
|
|
77
|
+
onEscape?: (e: Event) => void;
|
|
78
|
+
}) => {
|
|
79
|
+
release: () => void;
|
|
80
|
+
};
|
|
81
|
+
};
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
export declare function Modal({ open, onClose, title, children, footer, labelledBy, }: {
|
|
85
|
+
open: boolean;
|
|
86
|
+
onClose: () => void;
|
|
87
|
+
title: string;
|
|
88
|
+
children: React.ReactNode;
|
|
89
|
+
footer?: React.ReactNode;
|
|
90
|
+
labelledBy?: string;
|
|
91
|
+
}): React.JSX.Element | null;
|
|
92
|
+
export declare function Icon({ name, ...rest }: {
|
|
93
|
+
name: string;
|
|
94
|
+
} & React.HTMLAttributes<HTMLElement>): React.JSX.Element;
|
|
95
|
+
export declare function useIcons(ref?: React.RefObject<HTMLElement | null>): void;
|
|
96
|
+
export declare function useWhimsy(ref?: React.RefObject<HTMLElement | null>): void;
|
|
97
|
+
export {};
|
|
98
|
+
//# sourceMappingURL=primitives.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"primitives.d.ts","sourceRoot":"","sources":["../../framework-adapters/react/src/primitives.tsx"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAE/B,iDAAiD;AACjD,wBAAgB,EAAE,CAAC,GAAG,KAAK,EAAE,KAAK,CAAC,MAAM,GAAG,KAAK,GAAG,IAAI,GAAG,SAAS,CAAC,GAAG,MAAM,CAE7E;AAED;;;;;;;GAO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s } from "react/jsx-runtime";
|
|
2
|
+
/**
|
|
3
|
+
* React primitives for Artificer — thin wrappers that emit the canonical CSS
|
|
4
|
+
* classes; they don't reinvent the system.
|
|
5
|
+
*
|
|
6
|
+
* Setup once, in your app entry (e.g. main.tsx):
|
|
7
|
+
*
|
|
8
|
+
* import '@cameronsjo/artificer/artificer.css';
|
|
9
|
+
* import '@cameronsjo/artificer/theme.js';
|
|
10
|
+
* import '@cameronsjo/artificer/focus.js'; // only if using <Modal> / <NavDrawer>
|
|
11
|
+
* import '@cameronsjo/artificer/icons.js'; // only if using <Icon>
|
|
12
|
+
*/
|
|
13
|
+
import * as React from 'react';
|
|
14
|
+
/** Join class names, dropping falsy segments. */
|
|
15
|
+
export function cx(...parts) {
|
|
16
|
+
return parts.filter(Boolean).join(' ');
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* Nav-href guard — the chrome components are the first place Artificer
|
|
20
|
+
* renders consumer-supplied strings into <a href>, so the scheme check lives
|
|
21
|
+
* here once instead of in every consumer. React renders `javascript:` URLs
|
|
22
|
+
* (dev-warning only), which would execute in the app origin on click.
|
|
23
|
+
* Allowed: relative paths, fragments, queries, and http/https/mailto/tel.
|
|
24
|
+
* Anything else returns undefined — the caller drops the attribute.
|
|
25
|
+
*/
|
|
26
|
+
export function safeHref(href) {
|
|
27
|
+
if (href == null)
|
|
28
|
+
return undefined;
|
|
29
|
+
const trimmed = href.trim();
|
|
30
|
+
if (/^(?:[a-z][a-z0-9+.-]*):/i.test(trimmed)) {
|
|
31
|
+
return /^(?:https?|mailto|tel):/i.test(trimmed) ? href : undefined;
|
|
32
|
+
}
|
|
33
|
+
return href; // relative / fragment / query — no scheme to abuse
|
|
34
|
+
}
|
|
35
|
+
export function Stack({ gap = 'md', as: As = 'div', className = '', ...rest }) {
|
|
36
|
+
return _jsx(As, { ...rest, className: cx('stack', `stack--${gap}`, className) });
|
|
37
|
+
}
|
|
38
|
+
export function Cluster({ gap = 'md', between, end, as: As = 'div', className = '', ...rest }) {
|
|
39
|
+
return (_jsx(As, { ...rest, className: cx('cluster', `cluster--${gap}`, between && 'cluster--between', end && 'cluster--end', className) }));
|
|
40
|
+
}
|
|
41
|
+
export function Container({ size = 'md', as: As = 'div', className = '', ...rest }) {
|
|
42
|
+
return _jsx(As, { ...rest, className: cx('container', `container--${size}`, className) });
|
|
43
|
+
}
|
|
44
|
+
export function GridAuto({ min = 240, className = '', style, ...rest }) {
|
|
45
|
+
const vars = { '--min': `${min}px` };
|
|
46
|
+
return _jsx("div", { ...rest, style: { ...vars, ...style }, className: cx('grid-auto', className) });
|
|
47
|
+
}
|
|
48
|
+
export function Button({ variant = 'secondary', size, className = '', ...rest }) {
|
|
49
|
+
return _jsx("button", { ...rest, className: cx('btn', `btn--${variant}`, size && `btn--${size}`, className) });
|
|
50
|
+
}
|
|
51
|
+
export function Field({ label, hint, error, id, className = '', children, }) {
|
|
52
|
+
const errId = error ? `${id}-err` : undefined;
|
|
53
|
+
const hintId = !error && hint ? `${id}-hint` : undefined;
|
|
54
|
+
const extra = { id };
|
|
55
|
+
if (error)
|
|
56
|
+
extra['aria-invalid'] = 'true';
|
|
57
|
+
const describedBy = errId ?? hintId;
|
|
58
|
+
if (describedBy)
|
|
59
|
+
extra['aria-describedby'] = describedBy;
|
|
60
|
+
return (_jsxs("div", { className: cx('field', error && 'field--invalid', className), children: [_jsx("label", { className: "field__label", htmlFor: id, children: label }), React.cloneElement(children, extra), error && (_jsx("p", { className: "field__error", id: errId, children: error })), !error && hint && (_jsx("p", { className: "field__hint", id: hintId, children: hint }))] }));
|
|
61
|
+
}
|
|
62
|
+
export const Input = (p) => (_jsx("input", { ...p, className: cx('input', p.className) }));
|
|
63
|
+
export const Textarea = (p) => (_jsx("textarea", { ...p, className: cx('textarea', p.className) }));
|
|
64
|
+
export const Select = (p) => (_jsx("select", { ...p, className: cx('select', p.className) }));
|
|
65
|
+
export function Notification({ tier = 'info', title, children, action, }) {
|
|
66
|
+
// Live-region contract: urgent → alert (assertive) · attention/info →
|
|
67
|
+
// status (polite) · background → NO role — a silent badge, never announced.
|
|
68
|
+
const role = tier === 'urgent' ? 'alert' : tier === 'background' ? undefined : 'status';
|
|
69
|
+
return (_jsxs("div", { className: `notif notif--${tier}`, ...(role ? { role } : {}), children: [_jsx("span", { className: `dot dot--${tier}`, "aria-hidden": "true" }), _jsxs("div", { className: "notif__body", children: [_jsx("p", { className: "notif__title", children: title }), children && _jsx("p", { className: "notif__msg", children: children })] }), action && (_jsx(Button, { variant: "ghost", size: "sm", onClick: action.onClick, children: action.label }))] }));
|
|
70
|
+
}
|
|
71
|
+
export function Modal({ open, onClose, title, children, footer, labelledBy, }) {
|
|
72
|
+
const ref = React.useRef(null);
|
|
73
|
+
// useId is called unconditionally — `labelledBy || useId()` would make the
|
|
74
|
+
// hook conditional on the prop, which React forbids.
|
|
75
|
+
const autoId = React.useId();
|
|
76
|
+
const titleId = labelledBy ?? autoId;
|
|
77
|
+
React.useEffect(() => {
|
|
78
|
+
if (!open || !ref.current || !window.ArtificerFocus)
|
|
79
|
+
return;
|
|
80
|
+
const trap = window.ArtificerFocus.trap(ref.current, { onEscape: onClose });
|
|
81
|
+
return () => trap.release();
|
|
82
|
+
}, [open, onClose]);
|
|
83
|
+
if (!open)
|
|
84
|
+
return null;
|
|
85
|
+
return (_jsx("div", { className: "scrim", role: "presentation", onClick: (e) => {
|
|
86
|
+
if (e.target === e.currentTarget)
|
|
87
|
+
onClose();
|
|
88
|
+
}, children: _jsxs("div", { ref: ref, className: "modal", role: "dialog", "aria-modal": "true", "aria-labelledby": titleId, children: [_jsx("h2", { id: titleId, className: "modal__title", children: title }), _jsx("div", { className: "modal__body", children: children }), footer && _jsx("div", { className: "modal__footer", children: footer })] }) }));
|
|
89
|
+
}
|
|
90
|
+
// ─── Icon ────────────────────────────────────────────────────────────────
|
|
91
|
+
//
|
|
92
|
+
// Renders the <i data-icon> placeholder and hydrates it after mount via
|
|
93
|
+
// artificer-icons.js. For a whole subtree of icons mounted at once, prefer
|
|
94
|
+
// useIcons(ref) on the container, or ArtificerIcons.observe(root).
|
|
95
|
+
export function Icon({ name, ...rest }) {
|
|
96
|
+
const ref = React.useRef(null);
|
|
97
|
+
React.useEffect(() => {
|
|
98
|
+
window.ArtificerIcons?.hydrate(ref.current?.parentElement ?? document);
|
|
99
|
+
}, [name]);
|
|
100
|
+
return _jsx("i", { ref: ref, "data-icon": name, "aria-hidden": "true", ...rest });
|
|
101
|
+
}
|
|
102
|
+
// ─── Lifecycle hooks (SPA) ───────────────────────────────────────────────
|
|
103
|
+
export function useIcons(ref) {
|
|
104
|
+
React.useEffect(() => {
|
|
105
|
+
window.ArtificerIcons?.hydrate(ref?.current ?? document);
|
|
106
|
+
});
|
|
107
|
+
}
|
|
108
|
+
export function useWhimsy(ref) {
|
|
109
|
+
React.useEffect(() => {
|
|
110
|
+
const scope = ref?.current ?? document;
|
|
111
|
+
const w = window;
|
|
112
|
+
w.Whimsy?.hydrate(scope);
|
|
113
|
+
w.Whimsy?.greeting?.(scope);
|
|
114
|
+
});
|
|
115
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export type Viewport = 'desktop' | 'mobile';
|
|
2
|
+
export interface SectionOpenState {
|
|
3
|
+
open: boolean;
|
|
4
|
+
/** Set once the user explicitly toggles the section's <summary>. A touched
|
|
5
|
+
* section's open state is never overwritten by a later viewport default
|
|
6
|
+
* recompute — only another explicit toggle changes it from here on. */
|
|
7
|
+
touched: boolean;
|
|
8
|
+
}
|
|
9
|
+
/**
|
|
10
|
+
* The default open state for a fresh read of the viewport: desktop opens
|
|
11
|
+
* every section (the persistent sidenav has room), mobile opens only the
|
|
12
|
+
* section holding the active view (a fresh drawer mount shouldn't dump a
|
|
13
|
+
* wall of expanded rows).
|
|
14
|
+
*/
|
|
15
|
+
export declare function defaultSectionOpen(viewport: Viewport, isActive: boolean): boolean;
|
|
16
|
+
/**
|
|
17
|
+
* A viewport change (resize, rotation, breakpoint crossing) re-derives the
|
|
18
|
+
* default — but only for a section the user hasn't manually toggled. A
|
|
19
|
+
* manual toggle always outranks a later default recompute.
|
|
20
|
+
*/
|
|
21
|
+
export declare function onViewportChange(state: SectionOpenState, viewport: Viewport, isActive: boolean): SectionOpenState;
|
|
22
|
+
/**
|
|
23
|
+
* `nav` transitioning into this section's active view force-opens it — a
|
|
24
|
+
* collapsed section can't show `aria-current="page"`. This does NOT mark the
|
|
25
|
+
* section touched (touched is reserved for an explicit user toggle) and the
|
|
26
|
+
* caller is responsible for only invoking it on the false->true edge, not on
|
|
27
|
+
* every render while already active. That means a user who deliberately
|
|
28
|
+
* collapses the section that's ALREADY active is never fought: isActive
|
|
29
|
+
* hasn't changed, so this function is never called again for that section
|
|
30
|
+
* until nav leaves and re-enters it.
|
|
31
|
+
*/
|
|
32
|
+
export declare function onNavigationActivates(state: SectionOpenState): SectionOpenState;
|
|
33
|
+
/** An explicit user click on the <summary> — always wins, and marks the
|
|
34
|
+
* section touched so no later viewport recompute can override it. */
|
|
35
|
+
export declare function onUserToggle(nextOpen: boolean): SectionOpenState;
|
|
36
|
+
//# sourceMappingURL=sidenav-sections.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sidenav-sections.d.ts","sourceRoot":"","sources":["../../framework-adapters/react/src/sidenav-sections.ts"],"names":[],"mappings":"AAKA,MAAM,MAAM,QAAQ,GAAG,SAAS,GAAG,QAAQ,CAAC;AAE5C,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,OAAO,CAAC;IACd;;2EAEuE;IACvE,OAAO,EAAE,OAAO,CAAC;CAClB;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,QAAQ,EAAE,QAAQ,EAAE,OAAO,GAAG,OAAO,CAEjF;AAED;;;;GAIG;AACH,wBAAgB,gBAAgB,CAC9B,KAAK,EAAE,gBAAgB,EACvB,QAAQ,EAAE,QAAQ,EAClB,QAAQ,EAAE,OAAO,GAChB,gBAAgB,CAGlB;AAED;;;;;;;;;GASG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,gBAAgB,GAAG,gBAAgB,CAE/E;AAED;qEACqE;AACrE,wBAAgB,YAAY,CAAC,QAAQ,EAAE,OAAO,GAAG,gBAAgB,CAEhE"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
// Pure open-state decisions for collapsible `.sidenav__section`s. Kept free of
|
|
2
|
+
// React/DOM so the rules are unit-testable without mounting a component or
|
|
3
|
+
// faking matchMedia. Lifted upstream from spec-compare (proven in production
|
|
4
|
+
// with its test suite) as part of the chrome-components mint.
|
|
5
|
+
/**
|
|
6
|
+
* The default open state for a fresh read of the viewport: desktop opens
|
|
7
|
+
* every section (the persistent sidenav has room), mobile opens only the
|
|
8
|
+
* section holding the active view (a fresh drawer mount shouldn't dump a
|
|
9
|
+
* wall of expanded rows).
|
|
10
|
+
*/
|
|
11
|
+
export function defaultSectionOpen(viewport, isActive) {
|
|
12
|
+
return viewport === 'desktop' || isActive;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* A viewport change (resize, rotation, breakpoint crossing) re-derives the
|
|
16
|
+
* default — but only for a section the user hasn't manually toggled. A
|
|
17
|
+
* manual toggle always outranks a later default recompute.
|
|
18
|
+
*/
|
|
19
|
+
export function onViewportChange(state, viewport, isActive) {
|
|
20
|
+
if (state.touched)
|
|
21
|
+
return state;
|
|
22
|
+
return { ...state, open: defaultSectionOpen(viewport, isActive) };
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* `nav` transitioning into this section's active view force-opens it — a
|
|
26
|
+
* collapsed section can't show `aria-current="page"`. This does NOT mark the
|
|
27
|
+
* section touched (touched is reserved for an explicit user toggle) and the
|
|
28
|
+
* caller is responsible for only invoking it on the false->true edge, not on
|
|
29
|
+
* every render while already active. That means a user who deliberately
|
|
30
|
+
* collapses the section that's ALREADY active is never fought: isActive
|
|
31
|
+
* hasn't changed, so this function is never called again for that section
|
|
32
|
+
* until nav leaves and re-enters it.
|
|
33
|
+
*/
|
|
34
|
+
export function onNavigationActivates(state) {
|
|
35
|
+
return { ...state, open: true };
|
|
36
|
+
}
|
|
37
|
+
/** An explicit user click on the <summary> — always wins, and marks the
|
|
38
|
+
* section touched so no later viewport recompute can override it. */
|
|
39
|
+
export function onUserToggle(nextOpen) {
|
|
40
|
+
return { open: nextOpen, touched: true };
|
|
41
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cameronsjo/artificer",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.1",
|
|
4
4
|
"description": "Cameron's personal design system — AuDHD-friendly, dark-first, for tools and dashboards. Apache-2.0 but Cameron-first: published for my own reuse, unsupported, no stability guarantees implied.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"author": "Cameron Sjo",
|
|
@@ -23,21 +23,56 @@
|
|
|
23
23
|
"./texture.css": "./src/artificer-texture.css",
|
|
24
24
|
"./editorial.css": "./src/artificer-editorial.css",
|
|
25
25
|
"./print.css": "./src/print.css",
|
|
26
|
-
"./theme.js":
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
"./
|
|
31
|
-
|
|
32
|
-
|
|
26
|
+
"./theme.js": {
|
|
27
|
+
"types": "./types/theme.d.ts",
|
|
28
|
+
"default": "./src/artificer-theme.js"
|
|
29
|
+
},
|
|
30
|
+
"./focus.js": {
|
|
31
|
+
"types": "./types/focus.d.ts",
|
|
32
|
+
"default": "./src/artificer-focus.js"
|
|
33
|
+
},
|
|
34
|
+
"./tabs.js": {
|
|
35
|
+
"types": "./types/tabs.d.ts",
|
|
36
|
+
"default": "./src/artificer-tabs.js"
|
|
37
|
+
},
|
|
38
|
+
"./options.js": {
|
|
39
|
+
"types": "./types/options.d.ts",
|
|
40
|
+
"default": "./src/artificer-options.js"
|
|
41
|
+
},
|
|
42
|
+
"./tree.js": {
|
|
43
|
+
"types": "./types/tree.d.ts",
|
|
44
|
+
"default": "./src/artificer-tree.js"
|
|
45
|
+
},
|
|
46
|
+
"./icons.js": {
|
|
47
|
+
"types": "./types/icons.d.ts",
|
|
48
|
+
"default": "./src/artificer-icons.js"
|
|
49
|
+
},
|
|
50
|
+
"./whimsy.js": {
|
|
51
|
+
"types": "./types/whimsy.d.ts",
|
|
52
|
+
"default": "./src/artificer-whimsy.js"
|
|
53
|
+
},
|
|
54
|
+
"./react": {
|
|
55
|
+
"types": "./dist/react/index.d.ts",
|
|
56
|
+
"default": "./dist/react/index.js"
|
|
57
|
+
},
|
|
33
58
|
"./tokens.json": "./src/tokens.json",
|
|
34
59
|
"./package.json": "./package.json"
|
|
35
60
|
},
|
|
36
61
|
"files": [
|
|
37
62
|
"src",
|
|
38
63
|
"bin",
|
|
64
|
+
"types",
|
|
65
|
+
"dist",
|
|
39
66
|
"reference/SKILL.md"
|
|
40
67
|
],
|
|
68
|
+
"peerDependencies": {
|
|
69
|
+
"react": ">=18"
|
|
70
|
+
},
|
|
71
|
+
"peerDependenciesMeta": {
|
|
72
|
+
"react": {
|
|
73
|
+
"optional": true
|
|
74
|
+
}
|
|
75
|
+
},
|
|
41
76
|
"publishConfig": {
|
|
42
77
|
"access": "public"
|
|
43
78
|
},
|
package/reference/SKILL.md
CHANGED
|
@@ -3,7 +3,7 @@ name: Artificer
|
|
|
3
3
|
description: Cameron's personal design system. AuDHD-optimized, Ghostty-rooted, dark-first with a paper-stock light mode and a Jazz Age Deco palette (burnished gold + royal purple). Use for tools, dashboards, agent UIs, terminals, settings panels — anything that must stay calm until something demands action. Do NOT use for marketing sites, kid-facing UI, or anywhere the goal is delight-via-stimulation.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
|
-
# Artificer · v0.
|
|
6
|
+
# Artificer · v0.24.1
|
|
7
7
|
|
|
8
8
|
A neurodivergent-first design system for Cameron. Every token and rule here exists to reduce cognitive load for an AuDHD brain that **scans instead of reads** and holds **3–4 items** in working memory.
|
|
9
9
|
|
package/src/artificer-whimsy.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
-
ARTIFICER · Whimsy helper · v0.
|
|
2
|
+
ARTIFICER · Whimsy helper · v0.24.1
|
|
3
3
|
─────────────────────────────────────────────────────────────────────────
|
|
4
4
|
Tiny, dependency-free. Pairs with artificer-whimsy.css. Exposes window.Whimsy.
|
|
5
5
|
|
package/src/artificer.css
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* ═══════════════════════════════════════════════════════════════════════════
|
|
2
|
-
ARTIFICER · Design tokens · v0.
|
|
2
|
+
ARTIFICER · Design tokens · v0.24.1 (apothecary × deco × speakeasy)
|
|
3
3
|
AuDHD-optimized, Ghostty-rooted, with warm Jazz-Age accents.
|
|
4
4
|
Default theme = dark. Add data-theme="light" on <html> for ivory paper mode.
|
|
5
5
|
|
|
@@ -213,7 +213,7 @@
|
|
|
213
213
|
--z-toast: 3000; /* always-on-top notifications */
|
|
214
214
|
|
|
215
215
|
/* Artificer v0.10.1 — baseline contract: see CLAUDE.md § Baseline contract */
|
|
216
|
-
--art-version: "0.
|
|
216
|
+
--art-version: "0.24.1";
|
|
217
217
|
|
|
218
218
|
color-scheme: dark;
|
|
219
219
|
}
|
|
@@ -2025,9 +2025,21 @@ select:focus-visible,
|
|
|
2025
2025
|
min-height: 100dvh;
|
|
2026
2026
|
grid-template-rows: [bar] auto [body] 1fr;
|
|
2027
2027
|
grid-template-columns: [rail] var(--shell-rail, 240px) [main-start] minmax(0, 1fr) [main-end];
|
|
2028
|
+
column-gap: var(--shell-gap, 0px); /* rail↔content breathing room; 0 keeps the
|
|
2029
|
+
classic flush shell — consumers set --shell-gap instead of redefining the grid */
|
|
2028
2030
|
}
|
|
2029
2031
|
.app-shell > .appbar { grid-row: bar; grid-column: 1 / -1; }
|
|
2030
2032
|
.app-shell > .sidenav { grid-row: body; grid-column: rail; }
|
|
2033
|
+
/* Sticky rail — the sidenav pins while the content scrolls. align-self: start
|
|
2034
|
+
is load-bearing: a default-stretch grid child is as tall as the body row and
|
|
2035
|
+
has nowhere to stick. --sidenav-sticky-top clears any sticky chrome above
|
|
2036
|
+
(e.g. calc(56px + var(--s-md)) under a sticky .appbar). Replaces the
|
|
2037
|
+
consumer-invented sticky wrapper aside. */
|
|
2038
|
+
.sidenav--sticky {
|
|
2039
|
+
position: sticky;
|
|
2040
|
+
top: var(--sidenav-sticky-top, var(--s-md));
|
|
2041
|
+
align-self: start;
|
|
2042
|
+
}
|
|
2031
2043
|
.app-shell__content {
|
|
2032
2044
|
grid-row: body; grid-column: main-start / main-end;
|
|
2033
2045
|
min-width: 0; /* belt-and-suspenders with the minmax(0,1fr) main track */
|
package/src/primitives.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schemaVersion": "1",
|
|
3
|
-
"$version": "0.
|
|
4
|
-
"$doc": "Primitive mint ledger (ADR 0037, #199). Provenance + adoption semantics for every shipped primitive. tokens.json owns token VALUES; scripts/css-token-set.baseline.json owns the token SET; this file owns grouping, vintage, recipes, and adoption signals. Gated by scripts/check-primitives.mjs (check:primitives). minted 'pending-backfill' marks an entry awaiting mechanical dating (all dated by #199 PR-3's backfill; the sentinel remains legal for future re-derivations); 'unreleased' marks a mint on a feature branch, swept to the release version by sync:primitives-vintage.",
|
|
3
|
+
"$version": "0.24.1",
|
|
4
|
+
"$doc": "Primitive mint ledger (ADR 0037, #199). Provenance + adoption semantics for every shipped primitive. tokens.json owns token VALUES; scripts/css-token-set.baseline.json owns the token SET; this file owns grouping, vintage, recipes, and adoption signals. Gated by scripts/check-primitives.mjs (check:primitives). minted 'pending-backfill' marks an entry awaiting mechanical dating (all dated by #199 PR-3's backfill; the sentinel remains legal for future re-derivations); 'unreleased' marks a mint on a feature branch, swept to the release version by sync:primitives-vintage. The 'js' field names a VANILLA src/ behavior module (data- hook + window API); the 'react' field names the compiled React adapter component(s) for the primitive (@cameronsjo/artificer/react) — distinct fields because they are distinct consumption models.",
|
|
5
5
|
"primitives": {
|
|
6
6
|
"stack": {
|
|
7
7
|
"kind": "utility",
|
|
@@ -180,7 +180,15 @@
|
|
|
180
180
|
"app-shell",
|
|
181
181
|
"app-shell__content"
|
|
182
182
|
],
|
|
183
|
-
"recipe": "App shell / full-viewport layout"
|
|
183
|
+
"recipe": "App shell / full-viewport layout",
|
|
184
|
+
"variants": [
|
|
185
|
+
{
|
|
186
|
+
"class": "app-shell",
|
|
187
|
+
"minted": "0.24.0",
|
|
188
|
+
"note": "knobs, not overrides: --shell-rail (rail width, 240px default) and --shell-gap (rail-to-content column gap, 0 default) — consumers tune the grid via custom properties instead of redefining grid-template-columns"
|
|
189
|
+
}
|
|
190
|
+
],
|
|
191
|
+
"react": "AppShell + AppShellContent"
|
|
184
192
|
},
|
|
185
193
|
"appbar": {
|
|
186
194
|
"kind": "component",
|
|
@@ -193,7 +201,8 @@
|
|
|
193
201
|
"appbar__search",
|
|
194
202
|
"appbar__spacer"
|
|
195
203
|
],
|
|
196
|
-
"recipe": "Top app bar"
|
|
204
|
+
"recipe": "Top app bar",
|
|
205
|
+
"react": "Appbar"
|
|
197
206
|
},
|
|
198
207
|
"sidenav": {
|
|
199
208
|
"kind": "component",
|
|
@@ -203,22 +212,29 @@
|
|
|
203
212
|
"sidenav__group",
|
|
204
213
|
"sidenav__section",
|
|
205
214
|
"sidenav__footer",
|
|
215
|
+
"sidenav--sticky",
|
|
206
216
|
"label",
|
|
207
217
|
"count"
|
|
208
218
|
],
|
|
209
219
|
"recipe": "Side navigation",
|
|
210
220
|
"variants": [
|
|
221
|
+
{
|
|
222
|
+
"class": "sidenav--sticky",
|
|
223
|
+
"minted": "0.24.0",
|
|
224
|
+
"note": "sticky rail — pins the sidenav while .app-shell__content scrolls; align-self:start is load-bearing (a stretch child has nowhere to stick); --sidenav-sticky-top clears sticky chrome above. Replaces consumer-invented sticky wrapper asides"
|
|
225
|
+
},
|
|
211
226
|
{
|
|
212
227
|
"class": "sidenav__section",
|
|
213
|
-
"minted": "
|
|
228
|
+
"minted": "0.23.0",
|
|
214
229
|
"note": "collapsible group — <details class=\"sidenav__section\"> whose <summary> carries the group-label treatment + twisty; rows keep full sidenav styling. The section holding [aria-current=\"page\"] must be rendered open (consumer JS owns the open attribute); sticky group labels deliberately don't apply inside <details>"
|
|
215
230
|
},
|
|
216
231
|
{
|
|
217
232
|
"class": "sidenav__footer",
|
|
218
|
-
"minted": "
|
|
233
|
+
"minted": "0.23.0",
|
|
219
234
|
"note": "bottom-anchored settings row (margin-top:auto in the min-height:100% drawer sidenav) — the theme toggle's drawer seat; pairs a text label with a canonical .theme-toggle--inline [data-theme-toggle] button"
|
|
220
235
|
}
|
|
221
|
-
]
|
|
236
|
+
],
|
|
237
|
+
"react": "SideNav + SideNavFooter"
|
|
222
238
|
},
|
|
223
239
|
"nav-drawer": {
|
|
224
240
|
"kind": "component",
|
|
@@ -227,7 +243,8 @@
|
|
|
227
243
|
"nav-drawer",
|
|
228
244
|
"nav-scrim"
|
|
229
245
|
],
|
|
230
|
-
"recipe": "Mobile nav drawer"
|
|
246
|
+
"recipe": "Mobile nav drawer",
|
|
247
|
+
"react": "NavDrawer"
|
|
231
248
|
},
|
|
232
249
|
"crumb": {
|
|
233
250
|
"kind": "component",
|
|
@@ -1173,6 +1190,25 @@
|
|
|
1173
1190
|
"adoption": [
|
|
1174
1191
|
"btn"
|
|
1175
1192
|
]
|
|
1193
|
+
},
|
|
1194
|
+
"0.24.0": {
|
|
1195
|
+
"title": "chrome components: the compiled React adapter (@cameronsjo/artificer/react) single-sources the app shell; ambient d.ts for the vanilla modules; app-shell knobs + sticky rail",
|
|
1196
|
+
"minted": [],
|
|
1197
|
+
"breaking": [
|
|
1198
|
+
{
|
|
1199
|
+
"kind": "remove",
|
|
1200
|
+
"what": "useTheme React hook (framework-adapters/react-components.tsx, copy-consumed only — never npm-imported)",
|
|
1201
|
+
"from": "2-state dark/light hook duplicating the module's persistence",
|
|
1202
|
+
"to": "canonical <ThemeToggle /> (artificer-theme.js owns state) + useThemeMode() for reactive reads",
|
|
1203
|
+
"why": "the hook predated the 3-state canonical cycle and desynced from module-owned toggles"
|
|
1204
|
+
}
|
|
1205
|
+
],
|
|
1206
|
+
"adoption": [
|
|
1207
|
+
"appbar",
|
|
1208
|
+
"sidenav",
|
|
1209
|
+
"nav-drawer",
|
|
1210
|
+
"app-shell"
|
|
1211
|
+
]
|
|
1176
1212
|
}
|
|
1177
1213
|
},
|
|
1178
1214
|
"$exempt": []
|
package/src/tokens.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"$schema": "https://design-tokens.org/schema.json",
|
|
3
3
|
"$description": "Artificer · Cameron's personal design system. Machine-readable token export. Mirrors artificer.css. Source of truth lives in the CSS — regenerate this file if tokens change there.",
|
|
4
|
-
"$version": "0.
|
|
4
|
+
"$version": "0.24.1",
|
|
5
5
|
|
|
6
6
|
"color": {
|
|
7
7
|
"$description": "All colors paired with their dark/light values. AAA-tuned where indicated. v0.6 palette: apothecary × deco × speakeasy.",
|
package/types/focus.d.ts
ADDED
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-focus.js — the modal/drawer focus trap. Import for
|
|
3
|
+
* effect: `import '@cameronsjo/artificer/focus.js';`
|
|
4
|
+
*/
|
|
5
|
+
export interface ArtificerFocusApi {
|
|
6
|
+
/** Trap focus inside `el` (Tab cycles; focusables recomputed every Tab).
|
|
7
|
+
* `onEscape` fires on Esc; `release()` untraps and restores focus to the
|
|
8
|
+
* previously-focused element. */
|
|
9
|
+
trap(el: Element | null, opts?: { onEscape?: (e: KeyboardEvent) => void }): { release(): void };
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
declare global {
|
|
13
|
+
interface Window {
|
|
14
|
+
ArtificerFocus?: ArtificerFocusApi;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
export {};
|
package/types/icons.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-icons.js — Lucide-rooted icon hydration for
|
|
3
|
+
* `<i data-icon="name">` placeholders (unknown names render a dashed
|
|
4
|
+
* placeholder, never a silent blank). Import for effect:
|
|
5
|
+
* `import '@cameronsjo/artificer/icons.js';`
|
|
6
|
+
*/
|
|
7
|
+
export interface ArtificerIconsApi {
|
|
8
|
+
/** Build one icon SVG element for `name`, or null for an unknown name. */
|
|
9
|
+
build(name: string): SVGSVGElement | null;
|
|
10
|
+
/** One-shot hydrate of `root` (default document). */
|
|
11
|
+
hydrate(root?: ParentNode | null): void;
|
|
12
|
+
/** Hydrate `root` now and watch for inserted icons (SPA). Returns a disconnect fn. */
|
|
13
|
+
observe(root?: Element | null): () => void;
|
|
14
|
+
/** Canonical icon names. */
|
|
15
|
+
list(): string[];
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
declare global {
|
|
19
|
+
interface Window {
|
|
20
|
+
ArtificerIcons?: ArtificerIconsApi;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
export {};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-options.js — option-navigation behavior for the
|
|
3
|
+
* `.menu`/`.listbox` primitive (roving tabindex or aria-activedescendant).
|
|
4
|
+
* Import for effect: `import '@cameronsjo/artificer/options.js';`
|
|
5
|
+
*/
|
|
6
|
+
export interface ArtificerOptionsApi {
|
|
7
|
+
/** Roving-tabindex keyboard model on a standalone listbox/menu. Returns a teardown fn. */
|
|
8
|
+
enhance(
|
|
9
|
+
el: Element | null,
|
|
10
|
+
opts?: { onSelect?: (index: number, option: Element) => void; wrap?: boolean },
|
|
11
|
+
): () => void;
|
|
12
|
+
/** aria-activedescendant cursor for the palette/combobox recipe; focus stays
|
|
13
|
+
* on the input; printable keys and Escape are never consumed. The handle's
|
|
14
|
+
* refresh() re-reads options after the consumer filters the list. */
|
|
15
|
+
combobox(
|
|
16
|
+
input: HTMLInputElement | null,
|
|
17
|
+
list: Element | null,
|
|
18
|
+
opts?: { onSelect?: (index: number, option: Element) => void },
|
|
19
|
+
): { refresh(): void; teardown(): void };
|
|
20
|
+
/** enhance() every [data-options] / [data-combobox] under `root` (SPA). Returns a disconnect fn. */
|
|
21
|
+
observe(root?: Element | null): () => void;
|
|
22
|
+
/** Pure: next option index for `key` (clamped for listboxes, wrapping for menus), or null. */
|
|
23
|
+
nextOption(key: string, current: number, count: number, opts?: { wrap?: boolean }): number | null;
|
|
24
|
+
/** Pure: type-to-select match — index of the option matching `buffer`, or null. */
|
|
25
|
+
matchOption(labels: string[], buffer: string, current: number): number | null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
declare global {
|
|
29
|
+
interface Window {
|
|
30
|
+
ArtificerOptions?: ArtificerOptionsApi;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {};
|
package/types/tabs.d.ts
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-tabs.js — the WAI-ARIA tabs behavior for the `.tabs`
|
|
3
|
+
* primitive. Frameworks that own selection state use the pure `nextIndex`
|
|
4
|
+
* only (enhance/observe toggle panels via `hidden`, which fights conditional
|
|
5
|
+
* rendering). Import for effect: `import '@cameronsjo/artificer/tabs.js';`
|
|
6
|
+
*/
|
|
7
|
+
export interface ArtificerTabsApi {
|
|
8
|
+
/** Wire the APG keyboard model onto a tablist element. Returns a teardown fn. */
|
|
9
|
+
enhance(el: Element | null, opts?: { onSelect?: (index: number, tab: Element) => void }): () => void;
|
|
10
|
+
/** enhance() every [data-tabs] under `root` now and as inserted (SPA). Returns a disconnect fn. */
|
|
11
|
+
observe(root?: Element | null): () => void;
|
|
12
|
+
/** Pure state machine: the index focus/selection moves to for `key`, or null when not a tab-nav key. */
|
|
13
|
+
nextIndex(
|
|
14
|
+
key: string,
|
|
15
|
+
current: number,
|
|
16
|
+
count: number,
|
|
17
|
+
opts?: { orientation?: 'horizontal' | 'vertical' },
|
|
18
|
+
): number | null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
declare global {
|
|
22
|
+
interface Window {
|
|
23
|
+
ArtificerTabs?: ArtificerTabsApi;
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
export {};
|
package/types/theme.d.ts
ADDED
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-theme.js — a side-effect script that owns theme state:
|
|
3
|
+
* three modes (dark / light / auto), persistence under `ArtificerTheme.KEY`,
|
|
4
|
+
* canonical empty `[data-theme-toggle]` buttons hydrated with the half-circle
|
|
5
|
+
* glyph, all instances kept in sync. Import for effect:
|
|
6
|
+
* import '@cameronsjo/artificer/theme.js';
|
|
7
|
+
*/
|
|
8
|
+
export type ArtificerThemeMode = 'dark' | 'light' | 'auto';
|
|
9
|
+
|
|
10
|
+
export interface ArtificerThemeApi {
|
|
11
|
+
/** Apply + persist a mode ('auto' follows prefers-color-scheme live). */
|
|
12
|
+
apply(mode: ArtificerThemeMode): void;
|
|
13
|
+
/** Cycle dark → light → auto. */
|
|
14
|
+
toggle(): void;
|
|
15
|
+
/** Bind any unbound [data-theme-toggle] buttons now (idempotent). */
|
|
16
|
+
bind(): void;
|
|
17
|
+
/** bind() now, then watch `root` (default body) for inserted toggles. Returns a disconnect fn. */
|
|
18
|
+
observe(root?: Element | null): () => void;
|
|
19
|
+
/** The localStorage key ('artificer.theme') — the ONE source of truth; never re-hardcode it. */
|
|
20
|
+
readonly KEY: string;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
declare global {
|
|
24
|
+
interface Window {
|
|
25
|
+
ArtificerTheme?: ArtificerThemeApi;
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
export {};
|
package/types/tree.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-tree.js — the APG tree behavior for the `.tree`
|
|
3
|
+
* primitive (inert on `.tree--static` by design). Import for effect:
|
|
4
|
+
* `import '@cameronsjo/artificer/tree.js';`
|
|
5
|
+
*/
|
|
6
|
+
export interface ArtificerTreeApi {
|
|
7
|
+
/** Wire roving tabindex + arrow-key model onto a [role=tree] element. Returns a teardown fn. */
|
|
8
|
+
enhance(
|
|
9
|
+
treeEl: Element | null,
|
|
10
|
+
opts?: {
|
|
11
|
+
onSelect?: (item: Element) => void;
|
|
12
|
+
onToggle?: (item: Element, expanded: boolean) => void;
|
|
13
|
+
},
|
|
14
|
+
): () => void;
|
|
15
|
+
/** enhance() every [data-tree] under `root` (SPA). Returns a disconnect fn. */
|
|
16
|
+
observe(root?: Element | null): () => void;
|
|
17
|
+
/** Pure: next visible item index for `key` (a tree never wraps), or null. */
|
|
18
|
+
nextVisible(key: string, current: number, count: number): number | null;
|
|
19
|
+
/** Pure: the action for `key` given item state — expand / collapse / activate / move, or null. */
|
|
20
|
+
treeAction(
|
|
21
|
+
key: string,
|
|
22
|
+
state: { expanded?: boolean; isParent?: boolean },
|
|
23
|
+
): string | null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
declare global {
|
|
27
|
+
interface Window {
|
|
28
|
+
ArtificerTree?: ArtificerTreeApi;
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {};
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Types for artificer-whimsy.js — the sanctioned whimsy layer (burnished
|
|
3
|
+
* sine-wave rainbow; opt-in, settles, reduced-motion-safe). Import for
|
|
4
|
+
* effect: `import '@cameronsjo/artificer/whimsy.js';`
|
|
5
|
+
*/
|
|
6
|
+
export interface WhimsyApi {
|
|
7
|
+
/** Split [data-whimsy~="wave"] elements under `root` into bobbing chars. */
|
|
8
|
+
hydrate(root?: ParentNode | null): void;
|
|
9
|
+
/** hydrate() now and watch `root` for inserted whimsy nodes (SPA). Returns a disconnect fn. */
|
|
10
|
+
observe(root?: Element | null): () => void;
|
|
11
|
+
/** Ignite a target when a trigger word is typed into `input`. Returns a teardown fn. */
|
|
12
|
+
watch(
|
|
13
|
+
input: HTMLElement | null,
|
|
14
|
+
opts?: { triggers?: string[]; target?: Element | null; loops?: number; settle?: 'static' | 'glacial' },
|
|
15
|
+
): () => void;
|
|
16
|
+
/** One-shot celebration — auto-clears. */
|
|
17
|
+
celebrate(el: Element | null, opts?: number | { ms?: number }): void;
|
|
18
|
+
/** Dissolve treatment (fade-through-whimsy) for a leaving element. */
|
|
19
|
+
dissolve(el: Element | null, opts?: Record<string, unknown>): void;
|
|
20
|
+
/** Pure: the dissolve keyframe timeline for `opts` under a reduced-motion flag. */
|
|
21
|
+
dissolveTimeline(opts?: Record<string, unknown>, reducedMotion?: boolean): unknown;
|
|
22
|
+
/** Pure: parse a CSS duration string to milliseconds (NaN for invalid input). */
|
|
23
|
+
parseMs(value: string | null | undefined): number;
|
|
24
|
+
/** Swap [data-whimsy-greeting] elements under `root` to their seasonal line (idempotent). */
|
|
25
|
+
greeting(root?: ParentNode): void;
|
|
26
|
+
/** Pure: the greeting line + class set for a date. */
|
|
27
|
+
greetingFor(date?: Date | null, opts?: { default?: string; defaultClass?: string }): unknown;
|
|
28
|
+
/** Ignite, then settle after N hue-cycles. Returns a cancel fn. */
|
|
29
|
+
run(el: Element | null, opts?: { loops?: number; settle?: 'static' | 'glacial' }): () => void;
|
|
30
|
+
/** Freeze long-lived whimsy: 'static' (motion off) or 'glacial' (one slow drift). */
|
|
31
|
+
settle(el: Element | null, mode?: 'static' | 'glacial'): void;
|
|
32
|
+
/** Undo a settle. */
|
|
33
|
+
unsettle(el: Element | null): void;
|
|
34
|
+
/** Arrange a settle after `loops` hue-cycles. */
|
|
35
|
+
scheduleSettle(el: Element | null, loops?: number, mode?: 'static' | 'glacial'): void;
|
|
36
|
+
/** Manually add the flowing-gradient state. */
|
|
37
|
+
ignite(el: Element | null): void;
|
|
38
|
+
/** Manually remove the flowing-gradient state. */
|
|
39
|
+
clear(el: Element | null): void;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
declare global {
|
|
43
|
+
interface Window {
|
|
44
|
+
Whimsy?: WhimsyApi;
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
export {};
|