@schema-engine/layout 0.0.0-stage → 0.5.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.
Files changed (53) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +57 -2
  3. package/dist/index.d.ts +37 -0
  4. package/dist/index.js +4 -0
  5. package/dist/index.js.map +7 -0
  6. package/dist/lib/appearance.d.ts +204 -0
  7. package/dist/lib/appearance.js +2 -0
  8. package/dist/lib/appearance.js.map +7 -0
  9. package/dist/lib/deep-readonly.d.ts +10 -0
  10. package/dist/lib/deep-readonly.js +0 -0
  11. package/dist/lib/deep-readonly.js.map +7 -0
  12. package/dist/lib/grid-placement.d.ts +107 -0
  13. package/dist/lib/grid-placement.js +1 -0
  14. package/dist/lib/grid-placement.js.map +7 -0
  15. package/dist/lib/grid-styles.d.ts +178 -0
  16. package/dist/lib/grid-styles.js +2 -0
  17. package/dist/lib/grid-styles.js.map +7 -0
  18. package/dist/lib/layout-issue.d.ts +12 -0
  19. package/dist/lib/layout-issue.js +0 -0
  20. package/dist/lib/layout-issue.js.map +7 -0
  21. package/dist/lib/layout-theme.d.ts +94 -0
  22. package/dist/lib/layout-theme.js +4 -0
  23. package/dist/lib/layout-theme.js.map +7 -0
  24. package/dist/recipes/bind-recipe.d.ts +12 -0
  25. package/dist/recipes/bind-recipe.js +1 -0
  26. package/dist/recipes/bind-recipe.js.map +7 -0
  27. package/dist/recipes/define-recipe-spec.d.ts +49 -0
  28. package/dist/recipes/define-recipe-spec.js +1 -0
  29. package/dist/recipes/define-recipe-spec.js.map +7 -0
  30. package/dist/recipes/merge-slot-defaults.d.ts +8 -0
  31. package/dist/recipes/merge-slot-defaults.js +1 -0
  32. package/dist/recipes/merge-slot-defaults.js.map +7 -0
  33. package/dist/recipes/protocol.d.ts +69 -0
  34. package/dist/recipes/protocol.js +1 -0
  35. package/dist/recipes/protocol.js.map +7 -0
  36. package/dist/recipes/resolve-recipe-view.d.ts +52 -0
  37. package/dist/recipes/resolve-recipe-view.js +1 -0
  38. package/dist/recipes/resolve-recipe-view.js.map +7 -0
  39. package/dist/recipes/types.d.ts +53 -0
  40. package/dist/recipes/types.js +0 -0
  41. package/dist/recipes/types.js.map +7 -0
  42. package/dist/recipes/view-model.d.ts +20 -0
  43. package/dist/recipes/view-model.js +1 -0
  44. package/dist/recipes/view-model.js.map +7 -0
  45. package/dist/schemas/appearance.d.ts +57 -0
  46. package/dist/schemas/appearance.js +1 -0
  47. package/dist/schemas/appearance.js.map +7 -0
  48. package/dist/schemas/grid.d.ts +666 -0
  49. package/dist/schemas/grid.js +1 -0
  50. package/dist/schemas/grid.js.map +7 -0
  51. package/package.json +75 -3
  52. package/skill/SKILL.md +79 -0
  53. package/skill/reference/layout.md +48 -0
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../../src/schemas/grid.ts"],
4
+ "sourcesContent": ["import * as z from 'zod/mini';\n\n/**\n * Semantic gap tokens for grid layouts.\n *\n * @remarks\n * Tokens are indirections to overridable CSS variables: the renderer emits\n * `var(--se-grid-gap-<token>)`, so hosts restyle every grid by overriding the\n * token at `:root`. Raw CSS strings (e.g. `'1.5rem'`) are the one-off escape\n * hatch.\n */\nexport const GridGapTokens = ['none', 'compact', 'default', 'loose', 'wide'] as const;\n\nexport type GridGapToken = (typeof GridGapTokens)[number];\n\n/**\n * Semantic gap token or a raw CSS length.\n *\n * @remarks\n * The enum branch is redundant for validation \u2014 the string branch accepts the\n * same values \u2014 and `z.infer` collapses the union to `string`. It is kept\n * because `z.toJSONSchema` emits it as `anyOf: [{enum: [...]}, {type: string}]`,\n * which is how the token vocabulary reaches registry and docs consumers.\n */\nexport const GridGapValueSchema = z\n\t.union([z.enum(GridGapTokens), z.string()])\n\t.check(z.describe('Semantic gap token (none | compact | default | loose | wide) or a raw CSS length.'));\n\n/**\n * Words that are not valid grid area names: `grid-area` reads `auto` and `span`\n * as placement keywords, the CSS-wide keywords reset a declaration, and `none`\n * and `default` are excluded from a `<custom-ident>` by the CSS grammar.\n */\nconst RESERVED_AREA_NAMES = [\n\t'auto',\n\t'span',\n\t'none',\n\t'default',\n\t'inherit',\n\t'initial',\n\t'unset',\n\t'revert',\n\t'revert-layer',\n];\n\n/**\n * A word as a pattern that matches it in any letter case.\n *\n * @remarks\n * Spelled with character classes instead of an `i` flag because the JSON Schema\n * export keeps only a regex's source, so a flag would be lost and editors would\n * accept `AUTO` and reject `Street`.\n */\nfunction anyCase(word: string): string {\n\treturn word\n\t\t.split('')\n\t\t.map((char) => (/[a-z]/i.test(char) ? `[${char.toLowerCase()}${char.toUpperCase()}]` : char))\n\t\t.join('');\n}\n\nconst AREA_NAME_SOURCE = `(?!(?:${RESERVED_AREA_NAMES.map(anyCase).join('|')})(?![\\\\w-]))-?[_a-zA-Z][_a-zA-Z0-9-]*`;\n\n/**\n * Name of a grid area: an ASCII CSS identifier that is not a reserved word.\n *\n * @remarks\n * Names are written into a custom property that the stylesheet reads as CSS, so\n * the pattern is the injection guard. Nothing outside `[A-Za-z0-9_-]` can reach the\n * property, which rules out quotes, semicolons, braces and whitespace.\n */\nconst GridAreaNameSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(new RegExp(`^${AREA_NAME_SOURCE}$`), 'Area names are CSS identifiers such as \"header\" or \"side-2\".'),\n\t\tz.describe('Name of a cell group in the grid template: a CSS identifier such as \"header\" or \"side-2\".'),\n\t);\n\n/** A value per cascade slot (`default`, `sm` ... `2xl`), each optional. */\nfunction perBreakpoint<T extends z.ZodMiniType>(schema: T) {\n\treturn z.strictObject({\n\t\tdefault: z.optional(schema),\n\t\tsm: z.optional(schema),\n\t\tmd: z.optional(schema),\n\t\tlg: z.optional(schema),\n\t\txl: z.optional(schema),\n\t\t'2xl': z.optional(schema),\n\t});\n}\n\nfunction responsiveSchema<T extends z.ZodMiniType>(schema: T) {\n\treturn z.optional(perBreakpoint(schema));\n}\n\n/** One row of a template: area names or `.` for an empty cell, separated by spaces. */\nconst GridAreaRowSchema = z\n\t.string()\n\t.check(\n\t\tz.regex(\n\t\t\tnew RegExp(`^\\\\s*(?:\\\\.+|${AREA_NAME_SOURCE})(?:\\\\s+(?:\\\\.+|${AREA_NAME_SOURCE}))*\\\\s*$`),\n\t\t\t'A grid areas row lists area names (CSS identifiers) or \".\" for an empty cell, separated by spaces.',\n\t\t),\n\t);\n\nconst GridAreaRowsSchema = z.array(GridAreaRowSchema).check(z.minLength(1));\n\n/**\n * A drawn layout: rows of area names, optionally per breakpoint.\n *\n * @remarks\n * The column count comes from the rows, so a grid with `areas` sets no\n * `columns`. Rows of one template must be the same length and each name must\n * fill a rectangle; the domain validator checks both, as CSS drops a template that\n * breaks either.\n */\nconst GridAreasSchema = z\n\t.union([GridAreaRowsSchema, perBreakpoint(GridAreaRowsSchema)])\n\t.check(\n\t\tz.describe(\n\t\t\t'Rows of area names separated by spaces (\".\" is an empty cell), or a record of them per breakpoint (default, sm ... 2xl).',\n\t\t),\n\t);\n\nconst GridLayoutPropertiesSchema = z.strictObject({\n\tareas: z.optional(GridAreasSchema),\n\tcolumns: z.optional(z.union([z.number(), z.literal('auto')])),\n\tgap: z.optional(GridGapValueSchema),\n\tgapX: z.optional(GridGapValueSchema),\n\tgapY: z.optional(GridGapValueSchema),\n\tminColumnWidth: z.optional(z.string()),\n\tjustifyItems: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\talignItems: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\tplaceItems: z.optional(z.string()),\n\tjustifyContent: z.optional(\n\t\tz.enum(['start', 'end', 'center', 'stretch', 'space-around', 'space-between', 'space-evenly']),\n\t),\n\talignContent: z.optional(\n\t\tz.enum(['start', 'end', 'center', 'stretch', 'space-around', 'space-between', 'space-evenly']),\n\t),\n\tplaceContent: z.optional(z.string()),\n});\n\nexport const GridBreakpointConfigSchema = z.pick(GridLayoutPropertiesSchema, {\n\tcolumns: true,\n\tgap: true,\n\tgapX: true,\n\tgapY: true,\n\tminColumnWidth: true,\n});\n\nexport const GridLayoutConfigSchema = z.extend(GridLayoutPropertiesSchema, {\n\tresponsive: responsiveSchema(GridBreakpointConfigSchema),\n});\n\n/**\n * Named item widths, as shares of the row.\n *\n * @remarks\n * A grid whose items use `width` or `offset` is laid out on 12 tracks, so\n * every name is a whole number of tracks: `full` 12, `three-quarters` 9,\n * `two-thirds` 8, `half` 6, `third` 4, `quarter` 3. An item that sets no width\n * fills the row.\n */\nexport const GridWidthNames = ['full', 'three-quarters', 'two-thirds', 'half', 'third', 'quarter'] as const;\n\nexport type GridWidthName = (typeof GridWidthNames)[number];\n\n/** Named offsets: the widths that are a fraction of the row, without `full`. */\nexport const GridOffsetNames = ['three-quarters', 'two-thirds', 'half', 'third', 'quarter'] as const;\n\nexport type GridOffsetName = (typeof GridOffsetNames)[number];\n\nconst ElementGridPropertiesSchema = z.strictObject({\n\tarea: z\n\t\t.optional(GridAreaNameSchema)\n\t\t.check(z.describe('Name of the cell group this item fills in the grid areas template.')),\n\twidth: z\n\t\t.optional(z.enum(GridWidthNames))\n\t\t.check(z.describe(`Named share of the row (${GridWidthNames.join(' | ')}).`)),\n\toffset: z\n\t\t.optional(z.enum(GridOffsetNames))\n\t\t.check(z.describe(`Named empty space before the item (${GridOffsetNames.join(' | ')}).`)),\n\tcolumn: z.optional(z.union([z.number(), z.string()])),\n\trow: z.optional(z.union([z.number(), z.string()])),\n\tjustifySelf: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\talignSelf: z.optional(z.enum(['start', 'end', 'center', 'stretch'])),\n\tplaceSelf: z.optional(z.string()),\n\tmarginBlockStart: z\n\t\t.optional(GridGapValueSchema)\n\t\t.check(z.describe('Extra space before this element, on top of the grid row gap.')),\n\tmarginBlockEnd: z\n\t\t.optional(GridGapValueSchema)\n\t\t.check(z.describe('Extra space after this element, on top of the grid row gap.')),\n});\n\nexport const ItemGridBreakpointSchema = z.extend(z.omit(ElementGridPropertiesSchema, { placeSelf: true }), {\n\thidden: z.optional(z.boolean()),\n});\n\nexport const ElementGridConfigSchema = z.extend(ElementGridPropertiesSchema, {\n\tresponsive: responsiveSchema(ItemGridBreakpointSchema),\n});\n\nexport type GridBreakpointConfig = z.infer<typeof GridBreakpointConfigSchema>;\nexport type ItemGridBreakpointConfig = z.infer<typeof ItemGridBreakpointSchema>;\nexport type ElementGridConfig = z.infer<typeof ElementGridConfigSchema>;\nexport type GridLayoutConfig = z.infer<typeof GridLayoutConfigSchema>;\n"],
5
+ "mappings": "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",
6
+ "names": ["z", "GridGapTokens", "GridGapValueSchema", "RESERVED_AREA_NAMES", "anyCase", "word", "char", "AREA_NAME_SOURCE", "GridAreaNameSchema", "perBreakpoint", "schema", "responsiveSchema", "GridAreaRowSchema", "GridAreaRowsSchema", "GridAreasSchema", "GridLayoutPropertiesSchema", "GridBreakpointConfigSchema", "GridLayoutConfigSchema", "GridWidthNames", "GridOffsetNames", "ElementGridPropertiesSchema", "ItemGridBreakpointSchema", "ElementGridConfigSchema"]
7
+ }
package/package.json CHANGED
@@ -1,6 +1,78 @@
1
1
  {
2
2
  "name": "@schema-engine/layout",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
3
+ "type": "module",
4
+ "version": "0.5.1",
5
+ "description": "Domain-neutral layout for Schema Engine: a named grid, appearance axes and a theme compiler",
6
+ "keywords": [
7
+ "schema-engine",
8
+ "layout",
9
+ "grid",
10
+ "theme",
11
+ "css"
12
+ ],
13
+ "author": "Andrea Zanenghi",
14
+ "license": "MIT",
15
+ "repository": {
16
+ "type": "git",
17
+ "url": "git+https://github.com/schema-engine/schema-engine.git",
18
+ "directory": "packages/layout"
19
+ },
20
+ "engines": {
21
+ "node": "^24.22.0 || >=26.0.0"
22
+ },
23
+ "homepage": "https://schema-engine.com/docs/layout/overview",
24
+ "publishConfig": {
25
+ "access": "public"
26
+ },
27
+ "sideEffects": false,
28
+ "main": "dist/index.js",
29
+ "module": "dist/index.js",
30
+ "types": "dist/index.d.ts",
31
+ "exports": {
32
+ "./package.json": {
33
+ "import": "./package.json"
34
+ },
35
+ ".": {
36
+ "types": "./dist/index.d.ts",
37
+ "import": "./dist/index.js"
38
+ }
39
+ },
40
+ "files": [
41
+ "/dist/*",
42
+ "/skill"
43
+ ],
44
+ "lint-staged": {
45
+ "**/*.{js,mjs,cjs,jsx,ts,mts,cts,tsx}": [
46
+ "oxlint",
47
+ "prettier --write"
48
+ ],
49
+ "**/*.{json,jsonc,md,yml,yaml}": [
50
+ "prettier --write"
51
+ ]
52
+ },
53
+ "dependencies": {
54
+ "@standard-schema/spec": "^1.1.0",
55
+ "@schema-engine/registry": "^0.5.1"
56
+ },
57
+ "devDependencies": {
58
+ "esbuild": "^0.27.0",
59
+ "tsc-alias": "^1.8.16",
60
+ "typescript": "^5.9.3",
61
+ "vitest": "^5.1.1",
62
+ "zod": "^4.0.17",
63
+ "@schema-engine/scripts": "0.0.0"
64
+ },
65
+ "peerDependencies": {
66
+ "zod": "^4.0.17"
67
+ },
68
+ "scripts": {
69
+ "build:lib": "pnpm clean && pnpm build:files && pnpm build:types",
70
+ "build:files": "node ./build.ts",
71
+ "build:types": "tsc -p tsconfig.build.json && tsc-alias -p tsconfig.build.json",
72
+ "watch:lib": "node ./build.ts --watch",
73
+ "clean": "rm -rf ./dist",
74
+ "test:all": "vitest run",
75
+ "lint-staged": "lint-staged",
76
+ "check-types": "tsc --noEmit"
77
+ }
6
78
  }
package/skill/SKILL.md ADDED
@@ -0,0 +1,79 @@
1
+ ---
2
+ name: schema-engine
3
+ description: |
4
+ Schema Engine is a common language for declarative interfaces: registrations
5
+ keyed by `$type`, actions that run in sequences, documents that are plain
6
+ data, and rendering from that data. Forms is its first domain. Use this
7
+ skill when an agent is asked to build, configure, validate, submit or extend
8
+ anything with @schema-engine/registry, @schema-engine/actions,
9
+ @schema-engine/layout, @schema-engine/forms, @schema-engine/forms-react or
10
+ @schema-engine/forms-radiant, or to write a form widget for React or Radiant.
11
+ ---
12
+
13
+ # Schema Engine
14
+
15
+ Schema Engine is one grammar for interfaces that are described as data. A team registers the pieces (elements, actions, rules, appearance axes) under a `$type`, and a document, plain JSON or YAML, names them. The engine checks the document against the registrations and the renderer draws what passed. Forms is the first domain: a framework-free engine owns validation, state and submission, and a renderer (React or Radiant) only draws the fields and bridges the user's controls into that state.
16
+
17
+ This file is the router. It defines the concepts once; the references assume them and never repeat them. Read a reference only when the task needs it.
18
+
19
+ ## Core concepts
20
+
21
+ - **registration**: `{ $type, schema, metadata, ... }`, where `$type` is the stable key, `schema` is any Standard Schema that describes its config, and `metadata` names it. Elements, recipes, actions, validation rules and appearance axes are all registrations.
22
+ - **registry**: a read-only registry, `createRegistry(kind, registrations)` from `@schema-engine/registry`, built once from a list. The last registration of a `$type` wins without a warning, which is how you replace a built-in.
23
+ - **document**: serializable data whose every node names a registration by `$type`. It is checked against the registrations at the boundary, so what is rendered or run has passed its schema.
24
+ - **action**: a registration with `execute` that runs on a trigger. Actions run as a sequence, an inner array is a parallel group, and a failure that sets `shouldContinue: false` stops what follows and cancels the group's siblings through their `signal`.
25
+
26
+ ## Forms concepts
27
+
28
+ - **config**: a form is plain data, a `FormConfig` of steps holding elements, each with a `$type`, a `name`, `rules` and `constraints`. `engine.defineForm()` (typed, in TypeScript) or `engine.validateForm(unknown)` (portable JSON) checks it against the engine's registrations and returns a frozen `NormalizedFormConfig` that the engine owns.
29
+ - **container**: the form's state, a `FormStateContainer` from `@schema-engine/forms/state-container`. It owns the nested values, errors, warnings, touched and dirty marks, field-array row ids and the validation in flight. Paths are dotted (`contacts.1.email`) and `FORM_ROOT` is the form itself. Every change is a command (`setValue`, `blur`, `reportNative`, `validate`, `submit`, `reset`, `fieldArray`), and every read is a pure selector over an immutable snapshot.
30
+ - **runtime**: `createFormRuntime` is the lifecycle every renderer shares. It builds the container and owns the submission, the wizard steps and their navigation, `form_mount` and `form_change`, and every action dispatch. A renderer supplies only what an element can do, such as focus.
31
+ - **issues and the formatter**: the engine reports what is wrong as an issue (`type`, `source`, `ruleId`, `params`, `message`) and never makes up text. `formatIssue`, a function of the application, turns an issue into the words shown, and falls back to the issue's own `message`.
32
+
33
+ Outcomes use one vocabulary: a check or a submission ends `passed`, `invalid` or `overtaken`. `overtaken` means an edit or a reset outran the check, so there is no verdict and nothing to show.
34
+
35
+ ## Packages
36
+
37
+ | Package | Role |
38
+ | ------------------------------ | ----------------------------------------------------------------------------------------------------------------------------------------- |
39
+ | `@schema-engine/registry` | The registration contract and read-only registries every package builds on, and `/yaml` for documents authored as YAML. Ships this router |
40
+ | `@schema-engine/actions` | Actions: `parseActions`, and a dispatcher that runs a sequence with parallel groups, cancellation and results |
41
+ | `@schema-engine/layout` | Domain-neutral grid, appearance axes, layout themes and the recipe protocol |
42
+ | `@schema-engine/forms` | The forms engine: config, validation, constraints, the container, the runtime |
43
+ | `@schema-engine/forms-react` | React renderer: `FormRenderer` and the hooks. You write the widgets; ready-made ones come from the optional shadcn registry |
44
+ | `@schema-engine/forms-radiant` | Radiant renderer: `se-form-instance`, `FormController`, widgets and recipes in the package |
45
+
46
+ A symbol has one import path. `@schema-engine/forms` has these entries: `.` (the engine, the runtime and the types), `/state-container` (the container and its selectors), `/csrf`, `/server-errors`, `/recipes`, `/recipes/built-in`, `/browser` (browser-side actions such as auto-save), `/testing` (conformance suites; they need vitest) and `/agent-tool` (experimental).
47
+
48
+ ## To do X, read Y
49
+
50
+ Each package ships this router as its own `skill/SKILL.md` and its references in its `skill/reference/` folder, so a reference is `node_modules/@schema-engine/<package>/skill/reference/<file>`, and any installed package has the router. Read the rows of the packages the project depends on and skip the others: a package that is not installed has no file. The deployed site serves the latest version of the router and of every reference at `/skill/`, with the references flat at `/skill/reference/<file>`.
51
+
52
+ | To do | Package | Reference |
53
+ | ---------------------------------------------------------------------------- | ------------------------------ | ------------------------------------ |
54
+ | Register something, build a registry, or read a YAML document | `@schema-engine/registry` | `reference/registry.md` |
55
+ | Parse, dispatch or cancel actions outside a form | `@schema-engine/actions` | `reference/actions.md` |
56
+ | Build a grid, an appearance axis or a layout theme | `@schema-engine/layout` | `reference/layout.md` |
57
+ | Create an engine, author a config, use the container or the runtime directly | `@schema-engine/forms` | `reference/forms.md` |
58
+ | Add a rule, explain a validation result, or translate messages | `@schema-engine/forms` | `reference/forms-validation.md` |
59
+ | Handle submit, server errors, CSRF or wizard steps | `@schema-engine/forms` | `reference/forms-submission.md` |
60
+ | Run code on a form event, or define a form action | `@schema-engine/forms` | `reference/forms-actions.md` |
61
+ | Render a form in React, or use its hooks | `@schema-engine/forms-react` | `reference/forms-react.md` |
62
+ | Write or change a React field widget, and test it | `@schema-engine/forms-react` | `reference/forms-react-widgets.md` |
63
+ | Render a form in Radiant, or reach the container from an element | `@schema-engine/forms-radiant` | `reference/forms-radiant.md` |
64
+ | Write or change a Radiant field widget, and test it | `@schema-engine/forms-radiant` | `reference/forms-radiant-widgets.md` |
65
+
66
+ ## Documentation map
67
+
68
+ The full documentation is at `/docs` on the deployed site. The LLM-exported corpus is `/llms.txt` (index) and `/docs-llm/<section>/<slug>.md` (page bodies).
69
+
70
+ | Section | Path prefix |
71
+ | ------------------------------ | ---------------------------------- |
72
+ | Schema Engine | `/docs/schema-engine/introduction` |
73
+ | `@schema-engine/registry` | `/docs/registry/overview` |
74
+ | `@schema-engine/actions` | `/docs/actions/overview` |
75
+ | `@schema-engine/forms` | `/docs/forms/overview` |
76
+ | `@schema-engine/forms-react` | `/docs/forms-react/overview` |
77
+ | `@schema-engine/forms-radiant` | `/docs/forms-radiant/overview` |
78
+ | `@schema-engine/layout` | `/docs/layout/overview` |
79
+ | Examples | `/docs/examples/overview` |
@@ -0,0 +1,48 @@
1
+ # @schema-engine/layout
2
+
3
+ Domain-neutral layout: the grid, the appearance axes and the theme that compiles both. It knows nothing about forms, so any container of items can use it; the forms engine takes a theme as `layout`. The terms are defined in the router (`SKILL.md`).
4
+
5
+ ## One theme
6
+
7
+ `createLayoutTheme({ grid, appearance }, { reservedNames? })` compiles the grid vocabulary and the appearance axes once into a frozen theme: `id` (the value of `data-se-theme`), `css` (one stylesheet scoped by `[data-se-theme="<id>"]`), `grid`, `axes` (axis name to its values) and `appearance` (the axes as a read-only registry). Options that describe the same theme give the same id, so two engines built from equal options share a stylesheet; pass one compiled theme to several consumers to make them carry the same `data-se-theme`. `getDefaultLayoutTheme()` is the shared default and `isLayoutTheme(value)` tells a theme from options for one.
8
+
9
+ ```ts title="layout/theme.ts"
10
+ import {
11
+ builtInAxes,
12
+ createLayoutTheme,
13
+ defineAxis,
14
+ getAppearanceAttributes,
15
+ getGridVariables,
16
+ mergeAppearance,
17
+ } from '@schema-engine/layout';
18
+
19
+ const tone = defineAxis({
20
+ $type: 'tone',
21
+ metadata: { name: 'Tone' },
22
+ default: 'neutral',
23
+ values: { neutral: {}, brand: { '--se-accent': '#f60' } },
24
+ });
25
+
26
+ export const theme = createLayoutTheme({
27
+ grid: { breakpoints: { md: '50rem' }, gap: { default: '1rem' } },
28
+ appearance: [...builtInAxes, tone],
29
+ });
30
+
31
+ export const attributes = getAppearanceAttributes(mergeAppearance({ size: 'compact' }, { tone: 'brand' }));
32
+
33
+ export const containerStyle = getGridVariables({ columns: 2 }, theme.grid, []);
34
+ ```
35
+
36
+ ## Appearance axes
37
+
38
+ An axis is one independent dimension of appearance with 2 to 5 named values, each a set of semantic CSS tokens (`--` keys) that components read; components never read the value itself. `defineAxis({ $type, values, default, metadata })` builds one and throws on a bad name, a bad value count, a token that is not a custom property or a `default` that is not a value. `builtInAxes` is `size` (`compact`, `default`, `comfortable`) and `surface` (`flat`, `outlined`, `elevated`); axes are registrations, so a later axis of the same `$type` replaces the earlier one, and a list without `builtInAxes` has neither. An axis becomes a `data-se-<axis>` attribute, so a domain passes the attribute names it already writes as `reservedNames`.
39
+
40
+ The pure helpers: `checkAppearance(authored, options)` validates a pick, `mergeAppearance(inherited, own)` lays a child over its parent, `pickSupportedAppearance(picks, axes)` keeps what an owner supports and `getAppearanceAttributes(selection)` produces the `data-se-*` attributes. Walking a document to inherit picks belongs to each domain. `createAppearanceSchema(registry)` is the closed schema of a pick, for JSON Schema export.
41
+
42
+ ## Grid
43
+
44
+ A grid container takes `columns`, `gap`, `gapX`, `gapY`, `areas`, alignment and a `responsive` map by breakpoint; an item takes `width`, `offset`, `area`, `column`, `row`, self-alignment and block margins, and a `responsive` map by breakpoint that can also set `hidden`. `getGridVariables(grid, theme.grid, items)` and `getGridItemVariables(item.grid)` return records of `--se-grid-*` and `--se-item-*` custom properties that fit a React `style` and a plain `style` object. A renderer puts `GRID_CLASS` on every container, `GRID_ITEM_CLASS` on every item and `data-se-theme="<id>"` on both; the stylesheet selects only those hooks.
45
+
46
+ ## Recipe protocol
47
+
48
+ A recipe composes named slots into a view. `defineRecipeProtocol` declares a domain's slots and kinds once; `defineProtocolRecipeSpec`, `bindRecipe` and `createRecipeRegistry` build the recipes of that protocol. Forms is the first protocol.