@cameronsjo/artificer 0.24.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 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.24.0 · 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.
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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AM,EACN,SAAS,EACT,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG;IACrC,MAAM,EAAE,YAAY,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,8FAA8F;IAC9F,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,4EAA4E;IAC5E,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;;;;;;;GAOG;AACH,wBAAgB,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM,GAAG,SAAS,CAOrE;AAID,KAAK,QAAQ,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,IAAI,GAAG,KAAK,CAAC;AACzD,wBAAgB,KAAK,CAAC,EACpB,GAAU,EACV,EAAE,EAAE,EAAU,EACd,SAAc,EACd,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG;IAAE,GAAG,CAAC,EAAE,QAAQ,CAAC;IAAC,EAAE,CAAC,EAAE,KAAK,CAAC,WAAW,CAAA;CAAE,qBAEhF;AAED,wBAAgB,OAAO,CAAC,EACtB,GAAU,EACV,OAAO,EACP,GAAG,EACH,EAAE,EAAE,EAAU,EACd,SAAc,EACd,GAAG,IAAI,EACR,EAAE,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,GAAG;IACrC,GAAG,CAAC,EAAE,IAAI,GAAG,IA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IAAI,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,KAAK,CAAC,SAAS,CAAC;IAC1B,MAAM,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,4BA+BA;AAQD,wBAAgB,IAAI,CAAC,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE;IAAE,IAAI,EAAE,MAAM,CAAA;CAAE,GAAG,KAAK,CAAC,cAAc,CAAC,WAAW,CAAC,qBAQ3F;AAID,wBAAgB,QAAQ,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QAMjE;AAED,wBAAgB,SAAS,CAAC,GAAG,CAAC,EAAE,KAAK,CAAC,SAAS,CAAC,WAAW,GAAG,IAAI,CAAC,QASlE"}
@@ -0,0 +1,115 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } 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.24.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",
@@ -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.24.0
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
 
@@ -1,5 +1,5 @@
1
1
  /* ═══════════════════════════════════════════════════════════════════════════
2
- ARTIFICER · Whimsy helper · v0.24.0
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.24.0 (apothecary × deco × speakeasy)
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.24.0";
216
+ --art-version: "0.24.1";
217
217
 
218
218
  color-scheme: dark;
219
219
  }
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "$schemaVersion": "1",
3
- "$version": "0.24.0",
3
+ "$version": "0.24.1",
4
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": {
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.24.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.",