kerfjs 5.0.0-beta.117 → 5.0.0-beta.119

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,7 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
8
8
 
9
9
  ### Added
10
10
 
11
+ - **Stable `StateBanner` root identity.** `rootAttributes` accepts a safe `data-key` so a conditional status banner can disappear before a sibling without replacing the sibling's focused action (`KF-KDF5YG`).
11
12
  - **Native drag on `SummaryRow` options.** `draggable` writes the native attribute on the selectable row or board card root, preserving its option semantics and delegated identity across rerenders (`KF-NHPCWZ`).
12
13
  - **Static diagnostic `SummaryRow`.** `semanticRole="group"` renders a labeled, non-option list row or board card that retains rail and selected visuals while a nested native recovery action owns focus and activation (`KF-H32FQY`).
13
14
  - **Dense-feed media deferral.** `BackdropImage.deferOffscreen` and `ContentItem.media.deferOffscreen` opt into skipping offscreen hero painting while retaining card height and the shared scrollport. The 200-card constrained-CPU feed improved in both desktop and narrow measurements; the default remains unchanged (`KF-J5SAFS`).
@@ -156,6 +157,9 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
156
157
 
157
158
  ### Fixed
158
159
 
160
+ - **Live Markdown editor at phone width.** The editor and preview stack into full-width, independently scrolling panes on narrow screens; tablet and desktop keep the side-by-side layout (`KF-HR730P`).
161
+ - **UI doctor KUI-L401 respects `ChoiceChips` modes.** Radio and toggle modes no longer require `wireChoiceChips`; listbox and dynamic modes still do. Entry-point wiring remains recognized when bundle entries are declared in `.kerf-ui-profile.json` (`KF-KCM28K`, `KF-CYYR43`).
162
+ - **Site audit accepts the patched DOMPurify release.** The documentation site's direct dependency and lockfile now use DOMPurify 3.4.17, resolving the reported sanitizer advisories while keeping the audit policy and Markdown editor behavior intact (`KF-VB4EXK`).
159
163
  - **Quiet and danger Text contrast on lowered surfaces.** The shared light quiet and dark danger colors now clear WCAG AA when `Text` appears in a lowered `ValueTableRow` or `ListHeader` status over the document baseline, in both the foundation fallback and Web Awesome theme (`KF-CQWA7G`).
160
164
  - **`require-data-key-in-each` recognizes component `rootAttributes` keys.** A statically named `"data-key"` or `id` in a component row's `rootAttributes` object now satisfies the rule. Dynamic objects and ambiguous later spreads remain diagnostic; native and fragment roots retain their checks (`KF-PD9ZGA`).
161
165
  - **Web Awesome Carousel specimens show full slides in Firefox.** A `wa-carousel`'s scroll container is a `grid-auto-columns: 100%` track under an aspect ratio, so it has no definite intrinsic width. In the catalog's shrink-to-fit specimen column Chromium and WebKit resolved it from the aspect ratio (a 457px carousel at 1100px), but Firefox sized it to the first slide's text: a 191px carousel with a 103×34px track that clipped "Foundation" and "Focused carousel item" at every width. The Carousel and Carousel Item specimens now take the medium width tier, as the Zoomable Frame specimen does, so every engine renders the same full slides. A three-engine check asserts the track holds the whole slide at 1100px and 320px (`KF-0TGNQG`).
package/ai/manifest.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
- "kerfjsVersion": "5.0.0-beta.117",
2
+ "kerfjsVersion": "5.0.0-beta.119",
3
3
  "files": [
4
4
  {
5
5
  "name": "skill",
6
6
  "source": "kerf.claude-skill.md",
7
7
  "bundle": "ai/skill.md",
8
8
  "dest": ".claude/skills/kerf-app/SKILL.md",
9
- "version": "1.27.0",
10
- "sha256": "7e8722c2cf9f66b3aac2e413f8a19d3cc703bf2588cad8bed3b1075e719efc16",
9
+ "version": "1.28.0",
10
+ "sha256": "95a803e82a234dda363f468511bf64247c89798c1af8a1c62d082b40627f41aa",
11
11
  "history": {
12
12
  "1.0.0": "bef982cb743fd4c73e666ee5cf774112e57c93ebb13b24bbacbf08577db0930a",
13
13
  "1.1.0": "f2aadb21e33dd389028951ae1ecbd9f8ba68648b3c5beba43fb4dfa2ab29f195",
@@ -42,7 +42,19 @@
42
42
  "1.24.0": "f74616ec20120fa97ec2ff7e92971f5721ee8dcb0b5b7da2dd2604bb87002b69",
43
43
  "1.25.0": "bc2622cb12b382118e44aa50d1afb058252e0caf85b7c0ced4433bc0ca76f7c1",
44
44
  "1.26.0": "64a86a36399d12e5803a050c116d32d8762608d91ec9222670592ff471bc64b8",
45
- "1.27.0": "7e8722c2cf9f66b3aac2e413f8a19d3cc703bf2588cad8bed3b1075e719efc16"
45
+ "1.27.0": "7cc6a566cbe08023079731b98166e3c5e49160a8844358f928acf3ee0654092c",
46
+ "1.28.0": "95a803e82a234dda363f468511bf64247c89798c1af8a1c62d082b40627f41aa"
47
+ }
48
+ },
49
+ {
50
+ "name": "ui-skill",
51
+ "source": "kerf.ui-skill.md",
52
+ "bundle": "ai/ui-skill.md",
53
+ "dest": ".claude/skills/kerf-ui/SKILL.md",
54
+ "version": "1.0.0",
55
+ "sha256": "ee6e0e1d4028c37c3cc868ec12459e23cfa42c9dcaac791011c656984ae19310",
56
+ "history": {
57
+ "1.0.0": "ee6e0e1d4028c37c3cc868ec12459e23cfa42c9dcaac791011c656984ae19310"
46
58
  }
47
59
  },
48
60
  {
package/ai/skill.md CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  name: kerf-app
3
3
  description: Build UIs in the kerf reactive framework and its @kerfjs/ui component package (https://github.com/brianwestphal/kerf). Use this skill whenever the user is writing or modifying code that imports `kerfjs` or `@kerfjs/ui`, asks to add a feature to a kerf app, or asks "how do I do X in kerf?". Use it proactively the moment you spot a kerf import in the file you're editing.
4
- kerf-skill-version: 1.27.0
4
+ kerf-skill-version: 1.28.0
5
5
  ---
6
6
 
7
7
  # Building apps with kerf
@@ -21,8 +21,9 @@ kerf is a ~15 KB reactive UI framework (still ~15 KB with `arraySignal`): signal
21
21
  installs the matching AI skill, Kerf ESLint preset, TypeScript settings,
22
22
  and `kerf:check`; UI projects also get catalog and doctor checks. Run
23
23
  `npm run kerf:check` in the selected package after UI changes, alongside
24
- the project's own lint and tests. If setup is intentionally not used,
25
- install and configure these checks explicitly before coding; a generic
24
+ the project's own lint and tests. For package upgrades, follow the
25
+ `node_modules/@kerfjs/ui/docs/upgrading.md` lockstep checklist. If setup is
26
+ intentionally not used, install and configure these checks explicitly before coding; a generic
26
27
  ESLint preset does not check Kerf contracts.
27
28
  - Install: `npm install kerfjs`
28
29
  - `tsconfig.json`: `"jsx": "react-jsx"`, `"jsxImportSource": "kerfjs"`
package/ai/ui-skill.md ADDED
@@ -0,0 +1,18 @@
1
+ ---
2
+ name: kerf-ui
3
+ description: Build Kerf interfaces with the @kerfjs/ui component package.
4
+ kerf-skill-version: 1.0.0
5
+ ---
6
+
7
+ # Building with @kerfjs/ui
8
+
9
+ Before changing a consuming interface, resolve these files from the selected
10
+ package (which may live inside a workspace) and read them in order:
11
+
12
+ 1. `node_modules/@kerfjs/ui/llms.txt` for the retrieval order and package overview.
13
+ 2. `node_modules/@kerfjs/ui/ai/skill.md` for the UI rules and component selection process.
14
+ 3. The component references and contracts named by those files for each component you use.
15
+
16
+ Use the installed package's guidance so its instructions match the UI version in this project. Follow the project's own UI conventions and run its `kerf:check` after a change.
17
+
18
+ <!-- KERF-APP-CANONICAL-END · your customizations below -->
package/llms.txt CHANGED
@@ -21,7 +21,7 @@ kerf renders JSX to a structured `SafeHtml` (string for static content; tagged "
21
21
  - [`kerf.claude-skill.md`](https://github.com/brianwestphal/kerf/blob/main/kerf.claude-skill.md): drop-in [Claude Code](https://claude.com/claude-code) skill. Copy into `~/.claude/skills/kerf-app/SKILL.md` (or your project's `.claude/skills/kerf-app/SKILL.md`) — or use the bundled mirror at `node_modules/kerfjs/ai/skill.md` once you've `npm install`ed kerfjs.
22
22
  - [`eslint-plugin-kerfjs`](https://github.com/brianwestphal/kerf/blob/main/eslint-plugin/README.md): companion ESLint plugin enforcing the hard rules at edit time — eight AST-only core rules in `kerfjs.configs.recommended`: `no-inline-jsx-event-handlers`, `require-data-key-in-each`, `no-nested-mount`, `prefer-module-jsx-augmentation` (error) plus `require-delegate-disposer`, `prefer-attr-selector`, `no-raw-with-dynamic-arg`, `ai-assistant-configs` (warn), with no `parserServices` dependency; plus seven `@kerfjs/ui` catalog-contract rules (`ui-component-ownership`, `ui-composition`, `ui-css-values`, `ui-exceptional-shorthands`, `ui-preferences`, `ui-public-boundaries`, `ui-wiring`) in the `recommended-ui` / `strict-ui` configs. Install with `npm install --save-dev eslint-plugin-kerfjs` and add `kerfjs.configs.recommended` to your eslint config. Recommended when authoring kerf code with an AI assistant — eslint feedback surfaces in the IDE before `tsc` or runtime warns ever run.
23
23
  - [`create-kerf-component`](https://github.com/brianwestphal/kerf/blob/main/create-kerf-component/README.md): companion initializer that scaffolds a publishable kerf component package with the hard packaging rules, an example component, and explicit `kerf.components.json` source metadata plus deterministic `component-composition.json` generation/checking. Run `npm create kerf-component@latest <dir>`.
24
- - [`@kerfjs/ui` AI guide](https://github.com/brianwestphal/kerf/blob/main/ui/ai/skill.md) and [UI `llms.txt`](https://github.com/brianwestphal/kerf/blob/main/ui/llms.txt): start with the component-selection decision pass before writing JSX or CSS; use the package's layout and spacing ownership to avoid custom wrappers and styling.
24
+ - [`@kerfjs/ui` AI guide](https://github.com/brianwestphal/kerf/blob/main/ui/ai/skill.md) and [UI `llms.txt`](https://brianwestphal.github.io/kerf/ui/llms.txt) (also bundled at `node_modules/@kerfjs/ui/llms.txt`): start with the component-selection decision pass before writing JSX or CSS; use the package's layout and spacing ownership to avoid custom wrappers and styling.
25
25
 
26
26
  ## Reference docs
27
27
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "kerfjs",
3
- "version": "5.0.0-beta.117",
3
+ "version": "5.0.0-beta.119",
4
4
  "description": "Tiny reactive UI framework — fine-grained signals + DOM morphing + JSX. Apply the smallest possible cut to update your DOM.",
5
5
  "type": "module",
6
6
  "sideEffects": [
@@ -196,7 +196,7 @@
196
196
  "domotion-svg": "^0.30.1",
197
197
  "eslint": "^10.8.0",
198
198
  "eslint-plugin-simple-import-sort": "^12.1.1",
199
- "gitgist": "^1.1.0",
199
+ "gitgist": "1.2.0",
200
200
  "happy-dom": "^20.14.5",
201
201
  "http-server": "^14.1.1",
202
202
  "husky": "^9.1.7",
@@ -214,6 +214,10 @@
214
214
  "esbuild": "0.28.2"
215
215
  },
216
216
  "gitgist": {
217
+ "provider": "claude-cli",
218
+ "fallbackProvider": "codex",
219
+ "maxDiffChars": 150000,
220
+ "linkCommits": true,
217
221
  "exclude": [
218
222
  "site/public/demos/*.svg",
219
223
  "ai/*",
package/setup/index.mjs CHANGED
@@ -27,6 +27,12 @@ import {
27
27
  jsoncValueEdit,
28
28
  parseJsoncDocument,
29
29
  } from './jsonc.mjs';
30
+ import {
31
+ uiAppFiles,
32
+ uiDoctorConfig,
33
+ uiEslintTemplate,
34
+ uiPrettierConfig,
35
+ } from './ui-baseline.mjs';
30
36
 
31
37
  const execFileAsync = promisify(execFile);
32
38
  const packageRoot = resolve(dirname(fileURLToPath(import.meta.url)), '..');
@@ -450,6 +456,7 @@ function addMapValues(target, additions, path, context) {
450
456
  }
451
457
 
452
458
  function eslintTemplate(mode, format = 'module') {
459
+ if (mode === 'ui') return uiEslintTemplate(format);
453
460
  const preset = mode === 'ui' ? 'recommended-ui' : 'recommended';
454
461
  if (format === 'commonjs')
455
462
  return `module.exports = (async () => {\n const { default: parser } = await import('@typescript-eslint/parser');\n const { default: kerfjs } = await import('eslint-plugin-kerfjs');\n return [\n { files: ['**/*.{ts,tsx}'], languageOptions: { parser } },\n kerfjs.configs['${preset}'],\n ];\n})();\n`;
@@ -743,6 +750,7 @@ export async function planKerfSetup({
743
750
  });
744
751
  }
745
752
  for (const file of aiManifest.files) {
753
+ if (file.name === 'ui-skill' && mode !== 'ui') continue;
746
754
  if (
747
755
  file.name === 'cursorrules' &&
748
756
  !(await exists(resolve(root, '.cursor'))) &&
@@ -751,13 +759,16 @@ export async function planKerfSetup({
751
759
  continue;
752
760
  const destination = resolve(root, file.dest);
753
761
  const bundled = await readFile(resolve(packageRoot, file.bundle), 'utf8');
754
- if (file.name === 'skill' && guidanceSource) {
762
+ if ((file.name === 'skill' || file.name === 'ui-skill') && guidanceSource) {
755
763
  const sourcePath = resolve(root, guidanceSource);
756
764
  const importPath = relative(dirname(destination), sourcePath).replaceAll(
757
765
  '\\',
758
766
  '/',
759
767
  );
760
- const shared = `---\nname: kerf-app\ndescription: Use the shared workspace guidance for Kerf application work.\n---\n\n@${importPath}\n`;
768
+ const shared =
769
+ file.name === 'ui-skill'
770
+ ? `---\nname: kerf-ui\ndescription: Use shared workspace guidance and the installed @kerfjs/ui instructions.\n---\n\n@${importPath}\n\nIn the selected package, read \`node_modules/@kerfjs/ui/llms.txt\` first, then \`node_modules/@kerfjs/ui/ai/skill.md\` and the component references they name.\n`
771
+ : `---\nname: kerf-app\ndescription: Use the shared workspace guidance for Kerf application work.\n---\n\n@${importPath}\n`;
761
772
  const current = await readText(destination);
762
773
  knownResolutionIds.add(file.dest);
763
774
  if (current !== null && current !== shared && !resolutions[file.dest]) {
@@ -805,6 +816,19 @@ export async function planKerfSetup({
805
816
 
806
817
  const packagePath = resolve(selected.directory, 'package.json');
807
818
  const nextManifest = JSON.parse(JSON.stringify(selected.manifest));
819
+ const freshUiApp =
820
+ mode === 'ui' &&
821
+ !(await exists(resolve(selected.directory, 'src'))) &&
822
+ !(await exists(resolve(selected.directory, 'index.html'))) &&
823
+ !(await exists(resolve(selected.directory, 'vite.config.mjs'))) &&
824
+ !(await exists(resolve(selected.directory, 'app')));
825
+ const scaffoldUiApp =
826
+ freshUiApp ||
827
+ Boolean(
828
+ priorPackageState.managed?.[
829
+ `${packageKey === '.' ? '' : `${packageKey}/`}src/app/main.tsx`
830
+ ],
831
+ );
808
832
  nextManifest.scripts ??= {};
809
833
  nextManifest.devDependencies ??= {};
810
834
  nextManifest.dependencies ??= {};
@@ -816,7 +840,7 @@ export async function planKerfSetup({
816
840
  selected.directory === root
817
841
  ? ''
818
842
  : ` --root ${portable(selected.directory, root)} --package ${nextManifest.name}${
819
- (await exists(packageDoctorConfig))
843
+ mode === 'ui' || (await exists(packageDoctorConfig))
820
844
  ? ` --config ${shellArg(portable(root, packageDoctorConfig))}`
821
845
  : ''
822
846
  }`;
@@ -824,11 +848,21 @@ export async function planKerfSetup({
824
848
  nextManifest.scripts,
825
849
  mode === 'ui'
826
850
  ? {
827
- 'kerf:check': `tsc --noEmit && eslint . && kerf-component-catalog --check && kerf-ui-doctor --full${workspaceDoctorArgs}`,
851
+ lint: 'prettier --check . --ignore-unknown && eslint . --max-warnings 0',
852
+ typecheck: 'tsc --noEmit',
853
+ check: `prettier --check . --ignore-unknown && eslint . --max-warnings 0 && tsc --noEmit && kerf-component-catalog --check && kerf-ui-doctor --full${workspaceDoctorArgs}${scaffoldUiApp ? ' && node --test tests/structure.test.mjs && vite build' : ''}`,
854
+ 'kerf:check': `prettier --check . --ignore-unknown && eslint . --max-warnings 0 && tsc --noEmit && kerf-component-catalog --check && kerf-ui-doctor --full${workspaceDoctorArgs}${scaffoldUiApp ? ' && node --test tests/structure.test.mjs && vite build' : ''}`,
828
855
  'kerf:doctor': `kerf-ui-doctor --full${workspaceDoctorArgs}`,
829
856
  'kerf:doctor:changed': `kerf-ui-doctor --changed${workspaceDoctorArgs}`,
830
857
  'catalog:generate': 'kerf-component-catalog --write',
831
858
  'catalog:check': 'kerf-component-catalog --check',
859
+ ...(scaffoldUiApp
860
+ ? {
861
+ dev: 'vite',
862
+ build: 'vite build',
863
+ 'test:structure': 'node --test tests/structure.test.mjs',
864
+ }
865
+ : {}),
832
866
  }
833
867
  : { 'kerf:check': 'tsc --noEmit && eslint .' },
834
868
  'package.json#scripts',
@@ -842,6 +876,16 @@ export async function planKerfSetup({
842
876
  eslint: '^9.0.0',
843
877
  typescript: '^5.0.0 || ^6.0.0',
844
878
  ...(mode === 'ui' ? { 'create-kerf-component': setupVersion } : {}),
879
+ ...(mode === 'ui'
880
+ ? {
881
+ '@eslint/js': '^9.0.0',
882
+ '@stylistic/eslint-plugin': '^5.0.0',
883
+ 'eslint-plugin-simple-import-sort': '^12.1.1',
884
+ prettier: '^3.0.0',
885
+ 'typescript-eslint': '^8.65.0',
886
+ ...(scaffoldUiApp ? { vite: '^7.0.0' } : {}),
887
+ }
888
+ : {}),
845
889
  },
846
890
  'package.json#devDependencies',
847
891
  context,
@@ -914,6 +958,7 @@ export async function planKerfSetup({
914
958
  module: 'ESNext',
915
959
  moduleResolution: 'Bundler',
916
960
  strict: true,
961
+ ...(mode === 'ui' ? { noUncheckedIndexedAccess: true } : {}),
917
962
  jsx: 'react-jsx',
918
963
  jsxImportSource: 'kerfjs',
919
964
  };
@@ -1041,12 +1086,19 @@ export async function planKerfSetup({
1041
1086
  ? { value: template }
1042
1087
  : wasEditedManaged
1043
1088
  ? { conflict: 'setup-authored config was customized' }
1044
- : commonjs
1045
- ? {
1046
- conflict:
1047
- 'CommonJS config requires an explicit Kerf preset merge',
1048
- }
1049
- : mergeEslintConfig(source, mode);
1089
+ : mode === 'ui'
1090
+ ? source === template
1091
+ ? { value: source }
1092
+ : {
1093
+ conflict:
1094
+ 'existing UI ESLint config needs the full typed Kerf baseline',
1095
+ }
1096
+ : commonjs
1097
+ ? {
1098
+ conflict:
1099
+ 'CommonJS config requires an explicit Kerf preset merge',
1100
+ }
1101
+ : mergeEslintConfig(source, mode);
1050
1102
  if (merged.conflict) {
1051
1103
  activeConflictIds.add(id);
1052
1104
  if (!resolutions[id])
@@ -1065,6 +1117,54 @@ export async function planKerfSetup({
1065
1117
  }
1066
1118
  }
1067
1119
  if (mode === 'ui') {
1120
+ const prettierFiles = [
1121
+ 'prettier.config.mjs',
1122
+ 'prettier.config.js',
1123
+ '.prettierrc',
1124
+ '.prettierrc.json',
1125
+ '.prettierrc.js',
1126
+ '.prettierrc.mjs',
1127
+ ];
1128
+ if (
1129
+ !(
1130
+ await Promise.all(
1131
+ prettierFiles.map((name) =>
1132
+ exists(resolve(selected.directory, name)),
1133
+ ),
1134
+ )
1135
+ ).some(Boolean)
1136
+ ) {
1137
+ await addAction(
1138
+ resolve(selected.directory, 'prettier.config.mjs'),
1139
+ uiPrettierConfig,
1140
+ );
1141
+ }
1142
+ if (!(await exists(packageDoctorConfig)))
1143
+ await addAction(packageDoctorConfig, stableJson(uiDoctorConfig), 'json');
1144
+ if (scaffoldUiApp)
1145
+ for (const [path, content] of Object.entries(uiAppFiles())) {
1146
+ const destination = resolve(selected.directory, path);
1147
+ const id = portable(root, destination);
1148
+ const current = await readText(destination);
1149
+ knownResolutionIds.add(id);
1150
+ if (
1151
+ current !== null &&
1152
+ current !== content &&
1153
+ managedBefore[id]?.sha256 !== sha256(current)
1154
+ ) {
1155
+ activeConflictIds.add(id);
1156
+ if (!resolutions[id]) {
1157
+ conflicts.push({
1158
+ id,
1159
+ message: 'app scaffold file was customized; choose keep or kerf',
1160
+ });
1161
+ continue;
1162
+ }
1163
+ if (resolutions[id] === 'keep') continue;
1164
+ }
1165
+ await addAction(destination, content);
1166
+ managedAfter[id] = { sha256: sha256(content) };
1167
+ }
1068
1168
  if (!nextManifest.name)
1069
1169
  throw new Error(
1070
1170
  'UI setup requires package.json name for catalog identity.',
@@ -1255,6 +1355,16 @@ export function formatSetupPlan(plan) {
1255
1355
  `CONFLICT ${conflict.id}: ${conflict.message} (use --resolve ${conflict.id}=keep|kerf)`,
1256
1356
  );
1257
1357
  if (!plan.actions.length && !plan.conflicts.length) lines.push('No changes.');
1358
+ lines.push('AI guidance: .claude/skills/kerf-app/SKILL.md');
1359
+ if (plan.mode === 'ui') {
1360
+ lines.push('AI UI guidance: .claude/skills/kerf-ui/SKILL.md');
1361
+ lines.push(
1362
+ `Read first: ${portable(plan.root, resolve(plan.packageRoot, 'node_modules/@kerfjs/ui/llms.txt'))}`,
1363
+ );
1364
+ lines.push(
1365
+ `Then read: ${portable(plan.root, resolve(plan.packageRoot, 'node_modules/@kerfjs/ui/ai/skill.md'))}`,
1366
+ );
1367
+ }
1258
1368
  return lines.join('\n');
1259
1369
  }
1260
1370
 
@@ -0,0 +1,210 @@
1
+ /** Files used only when setup initializes an empty UI application. */
2
+ export function uiAppFiles() {
3
+ return {
4
+ '.prettierignore': `.claude/
5
+ dist/
6
+ node_modules/
7
+ component-composition.json
8
+ tsconfig.json
9
+ `,
10
+ 'index.html': `<!doctype html>
11
+ <html lang="en">
12
+ <head>
13
+ <meta charset="UTF-8" />
14
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
15
+ <title>Kerf app</title>
16
+ </head>
17
+ <body>
18
+ <div id="app"></div>
19
+ <script type="module" src="/src/app/main.tsx"></script>
20
+ </body>
21
+ </html>
22
+ `,
23
+ 'ux-demo/index.html': `<!doctype html>
24
+ <html lang="en">
25
+ <head>
26
+ <meta charset="UTF-8" />
27
+ <meta name="viewport" content="width=device-width, initial-scale=1.0" />
28
+ <title>UX demo</title>
29
+ </head>
30
+ <body>
31
+ <div id="app"></div>
32
+ <script type="module" src="/src/ux-demo/main.tsx"></script>
33
+ </body>
34
+ </html>
35
+ `,
36
+ 'vite.config.mjs': `import { resolve } from 'node:path';
37
+ import { defineConfig } from 'vite';
38
+
39
+ export default defineConfig({
40
+ build: {
41
+ rollupOptions: {
42
+ input: {
43
+ app: resolve(import.meta.dirname, 'index.html'),
44
+ 'ux-demo': resolve(import.meta.dirname, 'ux-demo/index.html'),
45
+ },
46
+ },
47
+ },
48
+ });
49
+ `,
50
+ 'src/app/main.tsx': `import '@kerfjs/ui/document.css';
51
+
52
+ import { Text } from '@kerfjs/ui/text';
53
+ import { mount } from 'kerfjs';
54
+
55
+ const root = document.getElementById('app');
56
+ if (!root) throw new Error('Missing #app root.');
57
+
58
+ mount(root, () => (
59
+ <main>
60
+ <Text variant="h1">Your Kerf app</Text>
61
+ <Text>Build your first feature in src/features.</Text>
62
+ <a href="/ux-demo/">Open the UX demo</a>
63
+ </main>
64
+ ));
65
+ `,
66
+ 'src/ux-demo/main.tsx': `import '@kerfjs/ui/document.css';
67
+ import '@kerfjs/ui/layout.css';
68
+ import '@kerfjs/ui/catalog.css';
69
+ import './style.css';
70
+
71
+ import { Catalog, type CatalogSection } from '@kerfjs/ui/catalog';
72
+ import { wireCatalog } from '@kerfjs/ui/wire-catalog';
73
+ import { mount, signal } from 'kerfjs';
74
+
75
+ import { ButtonDemo } from './demos/button.js';
76
+
77
+ const sections: CatalogSection[] = [
78
+ {
79
+ category: 'Components',
80
+ entries: [{ id: 'button', name: 'Button', description: 'A pressable action.' }],
81
+ },
82
+ ];
83
+ const active = signal('button');
84
+ const collapsed = signal(false);
85
+ const root = document.getElementById('app');
86
+ if (!root) throw new Error('Missing #app root.');
87
+
88
+ mount(root, () => (
89
+ <Catalog
90
+ brand={{ title: 'Your app', subtitle: 'UX demo' }}
91
+ sections={sections}
92
+ active={active.value}
93
+ content={<ButtonDemo />}
94
+ collapsed={collapsed.value}
95
+ />
96
+ ));
97
+ wireCatalog(root, {
98
+ onSelect: (id) => {
99
+ active.value = id;
100
+ },
101
+ onToggleSidebar: () => {
102
+ collapsed.value = !collapsed.value;
103
+ },
104
+ collapsed,
105
+ });
106
+ `,
107
+ 'src/ux-demo/style.css': `html,
108
+ body,
109
+ #app {
110
+ height: 100%;
111
+ }
112
+ `,
113
+ 'src/ux-demo/demos/button.tsx': `import { Button } from '@kerfjs/ui/button';
114
+ import { CatalogExample, CatalogExampleStack } from '@kerfjs/ui/catalog';
115
+
116
+ export function ButtonDemo() {
117
+ return (
118
+ <CatalogExampleStack label="Button" rootAttributes={{ 'data-demo': 'button' }}>
119
+ <CatalogExample label="Default" align="inline-control">
120
+ <Button href="/">Back to App</Button>
121
+ </CatalogExample>
122
+ </CatalogExampleStack>
123
+ );
124
+ }
125
+ `,
126
+ 'src/components/index.ts': 'export {};\n',
127
+ 'src/features/index.ts': 'export {};\n',
128
+ 'src/platform/index.ts': 'export {};\n',
129
+ 'src/shared/index.ts': 'export {};\n',
130
+ 'src/styles.d.ts': `declare module '*.css';\n`,
131
+ 'tests/structure.test.mjs': `import assert from 'node:assert/strict';
132
+ import { stat } from 'node:fs/promises';
133
+ import { resolve } from 'node:path';
134
+ import test from 'node:test';
135
+
136
+ test('the application ownership directories exist', async () => {
137
+ for (const name of ['app', 'components', 'features', 'platform', 'shared', 'ux-demo/demos']) {
138
+ assert.equal((await stat(resolve('src', name))).isDirectory(), true, name);
139
+ }
140
+ });
141
+ `,
142
+ };
143
+ }
144
+
145
+ export const uiPrettierConfig = `export default { printWidth: 120, singleQuote: true };\n`;
146
+
147
+ export const uiDoctorConfig = {
148
+ schemaVersion: 1,
149
+ failOn: 'warning',
150
+ suppressions: [],
151
+ };
152
+
153
+ export function uiEslintTemplate(format = 'module') {
154
+ const body = `const noPrettierIgnore = {
155
+ rules: {
156
+ 'no-prettier-ignore': {
157
+ create(context) {
158
+ return {
159
+ Program() {
160
+ for (const comment of context.sourceCode.getAllComments()) {
161
+ if (/\\bprettier-ignore\\b/u.test(comment.value))
162
+ context.report({ loc: comment.loc, message: 'Remove prettier-ignore; fix the formatting.' });
163
+ }
164
+ },
165
+ };
166
+ },
167
+ },
168
+ },
169
+ };
170
+
171
+ const config = tseslint.config(
172
+ { ignores: ['dist/**', 'node_modules/**', 'component-composition.json'] },
173
+ {
174
+ files: ['**/*.{ts,tsx}'],
175
+ extends: [js.configs.recommended, ...tseslint.configs.strictTypeChecked, kerfjs.configs['recommended-ui']],
176
+ languageOptions: { parserOptions: { projectService: true, tsconfigRootDir: import.meta.dirname } },
177
+ linterOptions: { reportUnusedDisableDirectives: 'error' },
178
+ plugins: { '@stylistic': stylistic, 'simple-import-sort': simpleImportSort, local: noPrettierIgnore },
179
+ rules: {
180
+ '@typescript-eslint/strict-boolean-expressions': 'error',
181
+ '@typescript-eslint/switch-exhaustiveness-check': 'error',
182
+ '@typescript-eslint/consistent-type-imports': 'error',
183
+ 'simple-import-sort/imports': 'error',
184
+ 'simple-import-sort/exports': 'error',
185
+ '@stylistic/jsx-self-closing-comp': ['error', { component: true, html: true }],
186
+ 'local/no-prettier-ignore': 'error',
187
+ },
188
+ },
189
+ );
190
+ `;
191
+ if (format === 'commonjs')
192
+ return `module.exports = (async () => {
193
+ const [{ default: js }, { default: tseslint }, { default: kerfjs }, { default: stylistic }, { default: simpleImportSort }] = await Promise.all([
194
+ import('@eslint/js'), import('typescript-eslint'), import('eslint-plugin-kerfjs'),
195
+ import('@stylistic/eslint-plugin'), import('eslint-plugin-simple-import-sort'),
196
+ ]);
197
+ ${body.replace('import.meta.dirname', 'process.cwd()')}
198
+ return config;
199
+ })();
200
+ `;
201
+ return `import js from '@eslint/js';
202
+ import stylistic from '@stylistic/eslint-plugin';
203
+ import simpleImportSort from 'eslint-plugin-simple-import-sort';
204
+ import kerfjs from 'eslint-plugin-kerfjs';
205
+ import tseslint from 'typescript-eslint';
206
+
207
+ ${body}
208
+ export default config;
209
+ `;
210
+ }