@contractspec/lib.design-system 3.8.10 → 3.9.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/README.md CHANGED
@@ -1,68 +1,168 @@
1
1
  # @contractspec/lib.design-system
2
2
 
3
- Website: https://contractspec.io
3
+ `@contractspec/lib.design-system` provides higher-level design-system components, tokens, platform adapters, renderers, and composed layouts used across web, native, marketing, legal, agent, and application surfaces.
4
4
 
5
- **Design tokens and theming primitives.**
5
+ Website: https://contractspec.io
6
6
 
7
- ## What It Provides
7
+ ## Installation
8
8
 
9
- - **Layer**: lib.
10
- - **Consumers**: accessibility, presentation-runtime-react, video-gen, bundles, apps.
11
- - Related ContractSpec packages include `@contractspec/lib.ai-agent`, `@contractspec/lib.contracts-runtime-client-react`, `@contractspec/lib.contracts-spec`, `@contractspec/lib.example-shared-ui`, `@contractspec/lib.presentation-runtime-react`, `@contractspec/lib.ui-kit`, ...
9
+ `bun add @contractspec/lib.design-system`
12
10
 
13
- ## Installation
11
+ or
14
12
 
15
13
  `npm install @contractspec/lib.design-system`
16
14
 
17
- or
15
+ ## What belongs here
18
16
 
19
- `bun add @contractspec/lib.design-system`
17
+ This package owns the higher-level design-system layer:
18
+
19
+ - Theme tokens and token bridging.
20
+ - Platform helpers and responsive hooks.
21
+ - Renderers and form-contract integration.
22
+ - Higher-level atoms, molecules, organisms, templates, and visualization components.
23
+ - Registry metadata and shadcn-style component registry support.
24
+
25
+ Use this package when you want the composed design-system layer. Do not use it when a lower-level primitive from `ui-kit` or `ui-kit-web` is enough.
26
+
27
+ ## Core workflows
28
+
29
+ ### Import a higher-level design-system component
30
+
31
+ ```ts
32
+ import { AppLayout, Button, HeroSection } from "@contractspec/lib.design-system";
33
+ ```
34
+
35
+ ### Work with tokens and platform helpers
36
+
37
+ ```ts
38
+ import {
39
+ createTranslationResolver,
40
+ defaultTokens,
41
+ mapTokensForPlatform,
42
+ resolvePlatformTheme,
43
+ resolveThemeRefTokens,
44
+ withPlatformUI,
45
+ } from "@contractspec/lib.design-system";
46
+
47
+ const nativeTokens = mapTokensForPlatform("native", defaultTokens);
48
+ const ui = withPlatformUI({
49
+ tokens: defaultTokens,
50
+ platform: "web",
51
+ });
52
+ ```
53
+
54
+ ### Resolve contract-backed themes
55
+
56
+ ```ts
57
+ import { ThemeRegistry } from "@contractspec/lib.contracts-spec/themes";
58
+ import { resolvePlatformTheme } from "@contractspec/lib.design-system";
59
+
60
+ const registry = new ThemeRegistry([themeSpec]);
61
+
62
+ const webTokens = resolvePlatformTheme(
63
+ registry,
64
+ { key: "design.brand", version: "1.0.0" },
65
+ "web",
66
+ { targets: ["tenant:acme"] }
67
+ );
68
+ ```
69
+
70
+ ### Provide translations to contract-driven renderers
71
+
72
+ ```tsx
73
+ import {
74
+ createTranslationResolver,
75
+ DesignSystemTranslationProvider,
76
+ } from "@contractspec/lib.design-system";
77
+
78
+ const resolver = createTranslationResolver({
79
+ registry: translationRegistry,
80
+ locale: "fr",
81
+ specKeys: ["design-system.form", "design-system.data-view"],
82
+ });
83
+
84
+ <DesignSystemTranslationProvider resolver={resolver}>
85
+ {children}
86
+ </DesignSystemTranslationProvider>;
87
+ ```
88
+
89
+ ## API map
90
+
91
+ ### Theme and platform
92
+
93
+ - `defaultTokens` and token interfaces from `./theme/tokens`
94
+ - `mapTokensForPlatform` from `./theme/tokenBridge`
95
+ - `resolveThemeSpecTokens`, `resolveThemeRefTokens`, and `resolvePlatformTheme` from `./theme/contracts`
96
+ - theme variants
97
+ - `withPlatformUI`
98
+ - `useColorScheme`
99
+ - `useReducedMotion`
100
+ - `useResponsive`
101
+
102
+ ### Renderers and hooks
103
+
104
+ - renderer exports from `./renderers`
105
+ - form-contract renderer support, including readonly, autocomplete, address, phone, date, time, and datetime FormSpec fields
106
+ - translation-aware rendering through `DesignSystemTranslationProvider` and `createTranslationResolver`
107
+ - hooks such as `useListUrlState`
108
+ - navigation-related shared types
109
+
110
+ ### Component composition layers
111
+
112
+ - atoms
113
+ - forms
114
+ - legal
115
+ - marketing
116
+ - molecules
117
+ - organisms
118
+ - templates
119
+ - visualization
120
+ - agent and approval components
20
121
 
21
- ## Usage
122
+ The root barrel is the primary API and already groups these exports in one place.
22
123
 
23
- Import the root entrypoint from `@contractspec/lib.design-system`, or choose a documented subpath when you only need one part of the package surface.
124
+ ## Public surface
24
125
 
25
- ## Architecture
126
+ The root barrel at `src/index.ts` is the main public API for this package.
26
127
 
27
- - `src/components/` contains reusable UI components and view composition.
28
- - `src/hooks/` contains custom hooks for host applications.
29
- - `src/index.ts` is the root public barrel and package entrypoint.
30
- - `src/lib/` contains package-local helper utilities and adapters.
31
- - `src/platform` is part of the package's public or composition surface.
32
- - `src/renderers` is part of the package's public or composition surface.
33
- - `src/theme` is part of the package's public or composition surface.
128
+ The export map is broad, but it is centralized:
129
+
130
+ - theme and platform helpers
131
+ - renderer exports
132
+ - high-level components grouped by composition layer
133
+ - hooks and shared types
34
134
 
35
- ## Public Entry Points
135
+ The package also ships registry metadata and build support:
136
+
137
+ - `components.json`
138
+ - `registry/registry.json`
139
+ - `bun run registry:build`
140
+
141
+ ## Operational semantics and gotchas
36
142
 
37
- - Export `.` resolves through `./src/index.ts`.
143
+ - Token names and token shapes are compatibility surface.
144
+ - `mapTokensForPlatform()` deliberately returns different token shapes for web and native, and can now map resolved contract-backed tokens.
145
+ - `withPlatformUI()` is a lightweight adapter, not a full runtime framework.
146
+ - Theme integration is utility-first in this tranche: resolve tokens from `ThemeSpec` / `ThemeRef`, then map them per platform. There is no runtime theme provider yet.
147
+ - The root barrel is broad and therefore high-blast-radius.
148
+ - This package depends on both `ui-kit` and `ui-kit-web`.
149
+ - The package includes legal, marketing, agent, app-shell, and visualization compositions, not just low-level primitives.
38
150
 
39
- ## Local Commands
151
+ ## When not to use this package
40
152
 
41
- - `bun run dev` contractspec-bun-build dev
42
- - `bun run build` bun run prebuild && bun run build:bundle && bun run build:types
43
- - `bun run test` bun test --pass-with-no-tests
44
- - `bun run lint` — bun run lint:fix
45
- - `bun run lint:check` — biome check .
46
- - `bun run lint:fix` — biome check --write --unsafe --only=nursery/useSortedClasses . && biome check --write .
47
- - `bun run typecheck` — tsc --noEmit -p tsconfig.build.json
48
- - `bun run publish:pkg` — bun publish --tolerate-republish --ignore-scripts --verbose
49
- - `bun run publish:pkg:canary` — bun publish:pkg --tag canary
50
- - `bun run build:bundle` — contractspec-bun-build transpile
51
- - `bun run build:types` — contractspec-bun-build types
52
- - `bun run registry:build` — bun run scripts/build-registry.ts
53
- - `bun run prebuild` — contractspec-bun-build prebuild
153
+ - Do not use it for tiny low-level utilities.
154
+ - Do not use it for router-agnostic links.
155
+ - Do not use it when a single lower-level primitive from `ui-kit` or `ui-kit-web` is enough.
54
156
 
55
- ## Recent Updates
157
+ ## Related packages
56
158
 
57
- - Replace eslint+prettier by biomejs to optimize speed.
58
- - Add data visualization capabilities.
59
- - Add table capabilities.
60
- - Resolve lint, build, and type errors across nine packages.
61
- - Add AI provider ranking system with ranking-driven model selection.
62
- - Stabilize marketing header interactions.
159
+ - `@contractspec/lib.ui-kit`
160
+ - `@contractspec/lib.ui-kit-web`
161
+ - `@contractspec/lib.ui-kit-core`
162
+ - `@contractspec/lib.ui-link`
63
163
 
64
- ## Notes
164
+ ## Local commands
65
165
 
66
- - **High blast radius** — all UI surfaces depend on design tokens; treat token names and values as public API.
67
- - Component hierarchy must be preserved; do not flatten or restructure without coordinating downstream consumers.
68
- - Token removals or renames are breaking changes.
166
+ - `bun run lint:check`
167
+ - `bun run typecheck`
168
+ - `bun run test`