@jaetask/toolkit 0.0.0-stage → 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/ui.d.ts ADDED
@@ -0,0 +1,26 @@
1
+ import { type ButtonHTMLAttributes, type InputHTMLAttributes, type LabelHTMLAttributes, type ReactNode, type SelectHTMLAttributes, type TextareaHTMLAttributes } from "react";
2
+ export declare const cx: (...parts: (string | false | null | undefined)[]) => string;
3
+ export type ButtonVariant = "grey" | "primary" | "danger";
4
+ /** The surface a grey button sits on: a warm grey panel (default) or a white card. */
5
+ export type Surface = "panel" | "white";
6
+ export declare const Button: import("react").ForwardRefExoticComponent<ButtonHTMLAttributes<HTMLButtonElement> & {
7
+ variant?: ButtonVariant;
8
+ surface?: Surface;
9
+ } & import("react").RefAttributes<HTMLButtonElement>>;
10
+ export declare const Input: import("react").ForwardRefExoticComponent<InputHTMLAttributes<HTMLInputElement> & import("react").RefAttributes<HTMLInputElement>>;
11
+ export declare const Textarea: import("react").ForwardRefExoticComponent<TextareaHTMLAttributes<HTMLTextAreaElement> & import("react").RefAttributes<HTMLTextAreaElement>>;
12
+ export declare const Select: import("react").ForwardRefExoticComponent<SelectHTMLAttributes<HTMLSelectElement> & import("react").RefAttributes<HTMLSelectElement>>;
13
+ export declare function Label({ className, ...rest }: LabelHTMLAttributes<HTMLLabelElement>): import("react").JSX.Element;
14
+ /**
15
+ * Permanent delete, confirmed by typing the name. Archive is the everyday way to retire something;
16
+ * this is the only dialog the toolkit has.
17
+ */
18
+ export declare function ConfirmDelete({ name, what, onConfirm, label, }: {
19
+ name: string;
20
+ what?: string;
21
+ onConfirm: () => void;
22
+ label?: string;
23
+ }): import("react").JSX.Element;
24
+ export type Children = {
25
+ children?: ReactNode;
26
+ };
package/dist/ui.js ADDED
@@ -0,0 +1,37 @@
1
+ import { jsx as _jsx, jsxs as _jsxs, Fragment as _Fragment } from "react/jsx-runtime";
2
+ // UI primitives: buttons, inputs and the one dialog. No sheets or drawers: every edit is its own page.
3
+ import { forwardRef, useId, useRef, useState, } from "react";
4
+ export const cx = (...parts) => parts.filter(Boolean).join(" ");
5
+ export const Button = forwardRef(function Button({ variant = "grey", surface = "panel", className, type, ...rest }, ref) {
6
+ return (_jsx("button", { ref: ref, type: type ?? "button", "data-variant": variant, "data-surface": surface, className: cx("tk-button", className), ...rest }));
7
+ });
8
+ export const Input = forwardRef(function Input({ className, ...rest }, ref) {
9
+ return _jsx("input", { ref: ref, className: cx("tk-input", className), ...rest });
10
+ });
11
+ export const Textarea = forwardRef(function Textarea({ className, ...rest }, ref) {
12
+ return _jsx("textarea", { ref: ref, className: cx("tk-textarea", className), ...rest });
13
+ });
14
+ export const Select = forwardRef(function Select({ className, ...rest }, ref) {
15
+ return _jsx("select", { ref: ref, className: cx("tk-select", className), ...rest });
16
+ });
17
+ export function Label({ className, ...rest }) {
18
+ // biome-ignore lint/a11y/noLabelWithoutControl: callers pass htmlFor
19
+ return _jsx("label", { className: cx("tk-row-title", className), ...rest });
20
+ }
21
+ /**
22
+ * Permanent delete, confirmed by typing the name. Archive is the everyday way to retire something;
23
+ * this is the only dialog the toolkit has.
24
+ */
25
+ export function ConfirmDelete({ name, what = "this", onConfirm, label = "Delete", }) {
26
+ const ref = useRef(null);
27
+ const [typed, setTyped] = useState("");
28
+ const id = useId();
29
+ return (_jsxs(_Fragment, { children: [_jsx(Button, { variant: "danger", onClick: () => ref.current?.showModal(), children: label }), _jsx("dialog", { ref: ref, className: "tk-dialog", "aria-labelledby": `${id}-t`, children: _jsxs("form", { method: "dialog", className: "tk-dialog-form", onSubmit: (e) => {
30
+ e.preventDefault();
31
+ if (typed !== name)
32
+ return;
33
+ ref.current?.close();
34
+ onConfirm();
35
+ }, children: [_jsxs("h2", { id: `${id}-t`, className: "tk-dialog-title", children: ["Delete ", what, " for good?"] }), _jsxs("p", { className: "tk-muted", children: ["This cannot be undone. Type ", _jsx("b", { children: name }), " to confirm."] }), _jsx(Input, { "aria-label": `Type ${name} to confirm`, value: typed, onChange: (e) => setTyped(e.target.value) }), _jsxs("div", { className: "tk-edit-bar", children: [_jsx(Button, { surface: "white", onClick: () => ref.current?.close(), children: "Cancel" }), _jsx(Button, { type: "submit", variant: "danger", disabled: typed !== name, children: label })] })] }) })] }));
36
+ }
37
+ //# sourceMappingURL=ui.js.map
package/dist/ui.js.map ADDED
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ui.js","sourceRoot":"","sources":["../src/ui.tsx"],"names":[],"mappings":";AAAA,uGAAuG;AACvG,OAAO,EAEL,UAAU,EAMV,KAAK,EACL,MAAM,EACN,QAAQ,GACT,MAAM,OAAO,CAAC;AAEf,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG,KAA4C,EAAE,EAAE,CACpE,KAAK,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;AAMlC,MAAM,CAAC,MAAM,MAAM,GAAG,UAAU,CAG9B,SAAS,MAAM,CAAC,EAAE,OAAO,GAAG,MAAM,EAAE,OAAO,GAAG,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG;IACtF,OAAO,CACL,iBACE,GAAG,EAAE,GAAG,EACR,IAAI,EAAE,IAAI,IAAI,QAAQ,kBACR,OAAO,kBACP,OAAO,EACrB,SAAS,EAAE,EAAE,CAAC,WAAW,EAAE,SAAS,CAAC,KACjC,IAAI,GACR,CACH,CAAC;AACJ,CAAC,CAAC,CAAC;AAEH,MAAM,CAAC,MAAM,KAAK,GAAG,UAAU,CAC7B,SAAS,KAAK,CAAC,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,EAAE,GAAG;IACxC,OAAO,gBAAO,GAAG,EAAE,GAAG,EAAE,SAAS,EAAE,EAAE,CAAC,UAAU,EAAE,SAAS,CAAC,KAAM,IAAI,GAAI,CAAC;AAC7E,CAAC,CACF,CAAC;AAEF,MAAM,CAAC,MAAM,QAAQ,GA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f,SAAS,EAAC,gBAAgB,EAC1B,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE;wBACd,CAAC,CAAC,cAAc,EAAE,CAAC;wBACnB,IAAI,KAAK,KAAK,IAAI;4BAAE,OAAO;wBAC3B,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,CAAC;wBACrB,SAAS,EAAE,CAAC;oBACd,CAAC,aAED,cAAI,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,SAAS,EAAC,iBAAiB,wBACpC,IAAI,kBACT,EACL,aAAG,SAAS,EAAC,UAAU,6CACO,sBAAI,IAAI,GAAK,oBACvC,EACJ,KAAC,KAAK,kBACQ,QAAQ,IAAI,aAAa,EACrC,KAAK,EAAE,KAAK,EACZ,QAAQ,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,GACzC,EACF,eAAK,SAAS,EAAC,aAAa,aAC1B,KAAC,MAAM,IAAC,OAAO,EAAC,OAAO,EAAC,OAAO,EAAE,GAAG,EAAE,CAAC,GAAG,CAAC,OAAO,EAAE,KAAK,EAAE,uBAElD,EACT,KAAC,MAAM,IAAC,IAAI,EAAC,QAAQ,EAAC,OAAO,EAAC,QAAQ,EAAC,QAAQ,EAAE,KAAK,KAAK,IAAI,YAC5D,KAAK,GACC,IACL,IACD,GACA,IACR,CACJ,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,72 @@
1
1
  {
2
2
  "name": "@jaetask/toolkit",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "One shell and page kit for every Kit app: sidebar, sections, edit pages and tokens, as React components.",
5
+ "keywords": [
6
+ "react",
7
+ "app-shell",
8
+ "design-system",
9
+ "ux-flow"
10
+ ],
11
+ "author": "jaetask",
12
+ "license": "MIT",
13
+ "homepage": "https://github.com/jaetask/toolkit#readme",
14
+ "repository": {
15
+ "type": "git",
16
+ "url": "git+https://github.com/jaetask/toolkit.git"
17
+ },
18
+ "bugs": "https://github.com/jaetask/toolkit/issues",
19
+ "type": "module",
20
+ "sideEffects": [
21
+ "*.css"
22
+ ],
23
+ "files": [
24
+ "dist",
25
+ "skills",
26
+ "README.md",
27
+ "LICENSE",
28
+ "CHANGELOG.md"
29
+ ],
30
+ "exports": {
31
+ ".": {
32
+ "types": "./dist/index.d.ts",
33
+ "import": "./dist/index.js"
34
+ },
35
+ "./styles.css": "./dist/styles.css",
36
+ "./fonts/*": "./dist/fonts/*"
37
+ },
38
+ "bin": {
39
+ "toolkit-guard": "./dist/guard.js"
40
+ },
41
+ "publishConfig": {
42
+ "access": "public",
43
+ "registry": "https://registry.npmjs.org"
44
+ },
45
+ "engines": {
46
+ "node": ">=22.13"
47
+ },
48
+ "scripts": {
49
+ "build": "tsc -p tsconfig.build.json && cp src/styles.css dist/styles.css && rm -rf dist/fonts && cp -R src/fonts dist/fonts && chmod +x dist/guard.js",
50
+ "typecheck": "tsc --noEmit",
51
+ "lint": "biome lint . && node scripts/check-scrub.mjs",
52
+ "format": "biome format --write .",
53
+ "format:check": "biome format .",
54
+ "test": "tsx --test src/*.test.tsx src/*.test.ts",
55
+ "demo": "tsx scripts/demo.tsx",
56
+ "prepare": "npm run build && (git config core.hooksPath .agents/guardrails/hooks || true)"
57
+ },
58
+ "peerDependencies": {
59
+ "react": "^18.3.1 || ^19.0.0",
60
+ "react-dom": "^18.3.1 || ^19.0.0"
61
+ },
62
+ "devDependencies": {
63
+ "@biomejs/biome": "2.6.5",
64
+ "@types/node": "22.18.0",
65
+ "@types/react": "18.3.31",
66
+ "@types/react-dom": "18.3.7",
67
+ "react": "18.3.1",
68
+ "react-dom": "18.3.1",
69
+ "tsx": "4.20.5",
70
+ "typescript": "5.9.2"
71
+ }
72
+ }
@@ -0,0 +1,22 @@
1
+ ---
2
+
3
+ name: ux-flow
4
+ description: Show and edit an app's data the same way on every page, so users know the next page before it lands. Use when building or changing any page that shows or edits data.
5
+ ---
6
+
7
+ # UX flow
8
+
9
+ ![A read page stacks sections; Edit opens that section's own edit page in the same frame, and Back, Cancel or Save return to the same spot.](ux-flow.svg)
10
+
11
+ Every Kit app feels the same. The user reads, edits, and lands back where they were.
12
+
13
+ - **Read page.** Sections stacked at one width. Each has a title, one line on what it holds, and its data, read-only. A list row opens its own page.
14
+ - **Edit.** One button per section. It opens that section's own edit page and carries the way back (`?from=`).
15
+ - **Edit page.** The read page's width and frame. Back at the top. Labelled rows: label and one line on the left, input on the right. Cancel and Save at the bottom; both return to the same spot.
16
+ - **One home per field.** Each value is edited on exactly one page.
17
+ - **One way in.** Every edit takes this trip. Sheets, drawers, side panels, inline editors and separate settings pages each break it. Dialogs only confirm.
18
+ - **Real data.** Show what is stored or computed from it; an empty section says how to fill it.
19
+ - **Deliberate delete.** Archive first. Permanent delete confirms by name.
20
+
21
+ 1. Build from `@jaetask/toolkit`: `Panel`, `ListRow`, `EditLink`, `EditFrame`, `Row`, `BackLink`, inside `AppShell`. A missing piece goes into the toolkit, never a single page.
22
+ 2. Run `npx toolkit-guard src` with the app's lint. It fails on a hand-built shell or kit component, a sheet or drawer, or a literal colour, and names the toolkit piece to use.
@@ -0,0 +1,14 @@
1
+ <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 764 362" width="100%" style="max-width:764px;height:auto" role="img" aria-label="A read page stacks sections; Edit opens that section&#x27;s own edit page in the same frame, and Back, Cancel or Save return to the same spot on the read page."><style>
2
+ svg { --paper:#fff; --ink:#0a0a0a; --muted:#525252; --accent:#0000ff; --tint:rgba(0,0,255,.05); --fill:rgba(10,10,10,.05); --line:rgba(10,10,10,.3);
3
+ font-family: system-ui, -apple-system, 'Segoe UI', sans-serif }
4
+ @media (prefers-color-scheme: dark) { svg { --paper:#0d0d10; --ink:#f2f2f2; --muted:#a3a3a3; --accent:#8894ff; --tint:rgba(136,148,255,.12); --fill:rgba(255,255,255,.06); --line:rgba(255,255,255,.3) } }
5
+ .bg { fill: var(--paper) }
6
+ .n { fill: var(--paper); stroke: var(--ink) } .s { fill: var(--fill); stroke: var(--line) }
7
+ .f { fill: var(--tint); stroke: var(--accent); stroke-width: 1.2 } .o { fill: var(--paper); stroke: var(--ink); stroke-dasharray: 5 4 }
8
+ .t { fill: var(--ink) } .m { fill: var(--muted) } .a { fill: var(--accent) }
9
+ .e { stroke: var(--ink); stroke-width: 1.2; fill: none } .ea { stroke: var(--accent); stroke-width: 1.4; fill: none }
10
+ .hm { fill: var(--ink) } .ham { fill: var(--accent) }
11
+ </style><defs>
12
+ <marker id="h" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" class="hm"/></marker>
13
+ <marker id="ha" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" orient="auto-start-reverse"><path d="M0,0 L10,5 L0,10 z" class="ham"/></marker>
14
+ </defs><rect class="bg" x="0" y="0" width="764" height="362"/><text x="20" y="22" class="t" font-size="13" font-weight="700" text-anchor="start">UX flow: read, edit, land back where you were</text><rect x="20" y="40" width="300" height="54" rx="6" class="s"/><text x="32" y="65" class="t" font-size="13" font-weight="700" text-anchor="start">Read page</text><text x="32" y="82" class="m" font-size="11" font-weight="400" text-anchor="start">full width, sections stacked</text><rect x="36" y="100" width="268" height="54" rx="6" class="n"/><text x="48" y="125" class="t" font-size="13" font-weight="700" text-anchor="start">Section: title, one line</text><text x="48" y="142" class="m" font-size="11" font-weight="400" text-anchor="start">rows of data, read-only</text><rect x="36" y="166" width="268" height="54" rx="6" class="n"/><text x="48" y="191" class="t" font-size="13" font-weight="700" text-anchor="start">Section: list</text><text x="48" y="208" class="m" font-size="11" font-weight="400" text-anchor="start">each row opens its own page</text><text x="232" y="122" class="a" font-size="12" font-weight="700" text-anchor="start">Edit</text><path d="M262,118 L420,118" class="ea" marker-end="url(#ha)"/><text x="322" y="108" class="m" font-size="11" font-weight="400" text-anchor="start">?from=this page</text><rect x="424" y="40" width="320" height="54" rx="6" class="s"/><text x="436" y="65" class="t" font-size="13" font-weight="700" text-anchor="start">Edit page, one section only</text><text x="436" y="82" class="m" font-size="11" font-weight="400" text-anchor="start">same width and frame as the read page</text><rect x="440" y="100" width="288" height="54" rx="6" class="n"/><text x="452" y="125" class="t" font-size="13" font-weight="700" text-anchor="start">Back (top)</text><text x="452" y="142" class="m" font-size="11" font-weight="400" text-anchor="start">returns to ?from, nothing saved</text><rect x="440" y="160" width="288" height="54" rx="6" class="n"/><text x="452" y="185" class="t" font-size="13" font-weight="700" text-anchor="start">Labelled rows</text><text x="452" y="202" class="m" font-size="11" font-weight="400" text-anchor="start">label + one line left, input right</text><rect x="440" y="220" width="288" height="54" rx="6" class="f"/><text x="452" y="245" class="a" font-size="13" font-weight="700" text-anchor="start">Cancel / Save (bottom)</text><text x="452" y="262" class="m" font-size="11" font-weight="400" text-anchor="start">both return to the same spot</text><path d="M440,248 L370,248 L370,130 L308,130" class="ea" marker-end="url(#ha)"/><text x="366" y="196" class="m" font-size="11" font-weight="400" text-anchor="end">back to</text><text x="366" y="210" class="m" font-size="11" font-weight="400" text-anchor="end">same spot</text><rect x="20" y="300" width="724" height="54" rx="6" class="o"/><text x="32" y="325" class="t" font-size="13" font-weight="700" text-anchor="start">One way in: no sheets, drawers, side panels, inline editors or settings pages</text><text x="32" y="342" class="m" font-size="11" font-weight="400" text-anchor="start">dialogs only confirm</text></svg>