@dqa-ai-solutions/ui-runtime 0.0.0-stage → 0.2.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 (79) hide show
  1. package/README.md +49 -2
  2. package/dist/_types/ui-kit/index.d.ts +4 -0
  3. package/dist/_types/ui-kit/lens/action.d.ts +76 -0
  4. package/dist/_types/ui-kit/lens/cell.d.ts +79 -0
  5. package/dist/_types/ui-kit/lens/diagnostic.d.ts +49 -0
  6. package/dist/_types/ui-kit/lens/format.d.ts +32 -0
  7. package/dist/_types/ui-kit/lens/index.d.ts +12 -0
  8. package/dist/_types/ui-kit/lens/list.d.ts +223 -0
  9. package/dist/_types/ui-kit/lens/milestone.d.ts +112 -0
  10. package/dist/_types/ui-kit/lens/pattern.d.ts +38 -0
  11. package/dist/_types/ui-kit/lens/queue.d.ts +30 -0
  12. package/dist/_types/ui-kit/lens/record.d.ts +110 -0
  13. package/dist/_types/ui-kit/lens/registry.d.ts +9 -0
  14. package/dist/_types/ui-kit/lens/shape.d.ts +27 -0
  15. package/dist/_types/ui-kit/lens/timeline.d.ts +36 -0
  16. package/dist/_types/ui-kit/primitives/action.d.ts +263 -0
  17. package/dist/_types/ui-kit/primitives/component-css.d.ts +10 -0
  18. package/dist/_types/ui-kit/primitives/index.d.ts +5 -0
  19. package/dist/_types/ui-kit/primitives/spec.d.ts +102 -0
  20. package/dist/_types/ui-kit/primitives/state.d.ts +148 -0
  21. package/dist/_types/ui-kit/primitives/stylesheet.d.ts +37 -0
  22. package/dist/_types/ui-kit/shell/index.d.ts +2 -0
  23. package/dist/_types/ui-kit/shell/nav.d.ts +142 -0
  24. package/dist/_types/ui-kit/shell/trail.d.ts +85 -0
  25. package/dist/_types/ui-kit/tokens/emit.d.ts +70 -0
  26. package/dist/_types/ui-kit/tokens/index.d.ts +6 -0
  27. package/dist/_types/ui-kit/tokens/oklch.d.ts +53 -0
  28. package/dist/_types/ui-kit/tokens/resolve.d.ts +4 -0
  29. package/dist/_types/ui-kit/tokens/scales.d.ts +325 -0
  30. package/dist/_types/ui-kit/tokens/theme.dqa.d.ts +2 -0
  31. package/dist/_types/ui-kit/tokens/types.d.ts +252 -0
  32. package/dist/_types/ui-react/elements/action-bar.d.ts +32 -0
  33. package/dist/_types/ui-react/elements/action-scope.d.ts +9 -0
  34. package/dist/_types/ui-react/elements/button.d.ts +42 -0
  35. package/dist/_types/ui-react/elements/choice.d.ts +40 -0
  36. package/dist/_types/ui-react/elements/columns.d.ts +82 -0
  37. package/dist/_types/ui-react/elements/dialog-scope.d.ts +15 -0
  38. package/dist/_types/ui-react/elements/dialog.d.ts +67 -0
  39. package/dist/_types/ui-react/elements/disclosure.d.ts +305 -0
  40. package/dist/_types/ui-react/elements/field-attributes.d.ts +39 -0
  41. package/dist/_types/ui-react/elements/field.d.ts +628 -0
  42. package/dist/_types/ui-react/elements/file.d.ts +82 -0
  43. package/dist/_types/ui-react/elements/filter.d.ts +61 -0
  44. package/dist/_types/ui-react/elements/link.d.ts +38 -0
  45. package/dist/_types/ui-react/elements/menu.d.ts +56 -0
  46. package/dist/_types/ui-react/elements/milestone.d.ts +119 -0
  47. package/dist/_types/ui-react/elements/nav.d.ts +73 -0
  48. package/dist/_types/ui-react/elements/pop.d.ts +14 -0
  49. package/dist/_types/ui-react/elements/record.d.ts +174 -0
  50. package/dist/_types/ui-react/elements/segmented.d.ts +59 -0
  51. package/dist/_types/ui-react/elements/suggest.d.ts +11 -0
  52. package/dist/_types/ui-react/elements/surface.d.ts +354 -0
  53. package/dist/_types/ui-react/elements/table.d.ts +72 -0
  54. package/dist/_types/ui-react/elements/toast.d.ts +69 -0
  55. package/dist/_types/ui-react/index.d.ts +22 -0
  56. package/dist/_types/ui-react/prefix/index.d.ts +8 -0
  57. package/dist/chunks/chunk-5NTG4J62.js +11 -0
  58. package/dist/chunks/chunk-66DQVLFK.js +5 -0
  59. package/dist/chunks/chunk-7WHYHIUX.js +1 -0
  60. package/dist/chunks/chunk-JOIDPECM.js +3 -0
  61. package/dist/chunks/chunk-MS2W22ER.js +3 -0
  62. package/dist/index.d.ts +1 -0
  63. package/dist/index.js +1 -0
  64. package/dist/kit.css +2291 -0
  65. package/dist/lens.d.ts +1 -0
  66. package/dist/lens.js +1 -0
  67. package/dist/primitives.d.ts +1 -0
  68. package/dist/primitives.js +1 -0
  69. package/dist/react.d.ts +1 -0
  70. package/dist/react.js +1 -0
  71. package/dist/shell.d.ts +1 -0
  72. package/dist/shell.js +1 -0
  73. package/dist/tokens.css +160 -0
  74. package/dist/tokens.d.ts +1 -0
  75. package/dist/tokens.dark.css +98 -0
  76. package/dist/tokens.generated.css +98 -0
  77. package/dist/tokens.high.css +98 -0
  78. package/dist/tokens.js +1 -0
  79. package/package.json +61 -4
@@ -0,0 +1,148 @@
1
+ /** What a surface is made of. Decides whether a skeleton is even appropriate. */
2
+ export type SurfaceKind = 'table' | 'list' | 'card' | 'record' | 'field' | 'action';
3
+ /**
4
+ * ⚠️ Skeletons belong to surfaces that hold DATA, and to nothing else.
5
+ *
6
+ * Borrowed whole from Carbon, which states it plainly: action components —
7
+ * buttons, inputs, checkboxes, toggles — do not need a skeleton state. A
8
+ * pulsing grey rectangle where a button will be is not a loading hint, it is
9
+ * a control the user cannot yet see the purpose of.
10
+ */
11
+ export type SkeletonKind = 'rows' | 'block' | null;
12
+ export declare const skeletonFor: (surface: SurfaceKind) => SkeletonKind;
13
+ /** Why there is nothing to show. The two are different screens, not one. */
14
+ export type EmptyReason = 'no-records' | 'no-match';
15
+ /** One thing the user can do from here. */
16
+ export interface NextStep {
17
+ label: string;
18
+ /** An action name, a route — whatever the renderer knows how to follow. */
19
+ go: string;
20
+ }
21
+ /**
22
+ * What the screen says when it is empty.
23
+ *
24
+ * ⛔ `noMatch.action` IS REQUIRED, and that is the whole point of splitting the
25
+ * two reasons apart. A list emptied by a filter looks identical to a system
26
+ * with no data in it, and the user cannot tell which they are looking at —
27
+ * they conclude the records are gone. The way out of a filter has to be on
28
+ * the screen that the filter emptied, so the type will not let you ship one
29
+ * without it.
30
+ *
31
+ * ⚠️ `noRecords.action` is optional on purpose: plenty of lists are empty
32
+ * because the person looking has nothing to do yet, and inventing a button
33
+ * for them is worse than silence.
34
+ */
35
+ export interface EmptyCopy {
36
+ noRecords: {
37
+ title: string;
38
+ body?: string;
39
+ action?: NextStep;
40
+ };
41
+ noMatch: {
42
+ title: string;
43
+ body?: string;
44
+ action: NextStep;
45
+ };
46
+ }
47
+ /**
48
+ * Something provably wrong with the data that arrived — not with the request.
49
+ *
50
+ * ⭐ `missing-key` is the one the reference app bled on: a contract promises a
51
+ * derived property, the read layer never produced the key, and the cell drew
52
+ * an em dash. Identical on screen to "this record has no link", so a broken
53
+ * join and an empty field looked the same for weeks.
54
+ */
55
+ export interface Fault {
56
+ kind: 'missing-key' | 'stale' | 'clipped';
57
+ message: string;
58
+ }
59
+ export type SurfaceState<T> = {
60
+ kind: 'loading';
61
+ skeleton: SkeletonKind;
62
+ label: string;
63
+ } | {
64
+ kind: 'forbidden';
65
+ message: string;
66
+ } | {
67
+ kind: 'error';
68
+ message: string;
69
+ retry: boolean;
70
+ } | {
71
+ kind: 'empty';
72
+ because: EmptyReason;
73
+ title: string;
74
+ body?: string;
75
+ action?: NextStep;
76
+ }
77
+ /** Data arrived AND is provably incomplete. The renderer draws both. */
78
+ | {
79
+ kind: 'partial';
80
+ data: T;
81
+ faults: Fault[];
82
+ } | {
83
+ kind: 'ready';
84
+ data: T;
85
+ };
86
+ export interface SurfaceInput<T> {
87
+ /** Set to the reason when the viewer may not see this at all. */
88
+ forbidden?: string | false;
89
+ error?: string | null;
90
+ loading: boolean;
91
+ data?: T | null;
92
+ /** How many records `data` holds, when it is a collection. */
93
+ count?: number;
94
+ /** True while a search or filter is narrowing the result. */
95
+ narrowed?: boolean;
96
+ faults?: Fault[];
97
+ /** Required — see `EmptyCopy`. */
98
+ empty: EmptyCopy;
99
+ surface?: SurfaceKind;
100
+ /** Whether the error is worth offering a retry for. */
101
+ retry?: boolean;
102
+ loadingLabel?: string;
103
+ }
104
+ /**
105
+ * One place the order of precedence is decided, so fifty screens cannot each
106
+ * decide it differently.
107
+ *
108
+ * ⭐ THE TWO RULINGS WORTH READING
109
+ *
110
+ * ① Loading with data already in hand stays `ready`. Re-fetching must not
111
+ * blank the screen the user is reading — the reference app got this right
112
+ * by hand (`loading && !data ? <Loading/> : …`) on some screens and wrong
113
+ * on others, which is exactly what a shared decision is for.
114
+ *
115
+ * ② An error with data already in hand is a FAULT, not a state. Throwing away
116
+ * a page of records because a background refresh failed tells the user the
117
+ * data is gone when it is merely old.
118
+ */
119
+ export declare function surfaceState<T>(input: SurfaceInput<T>): SurfaceState<T>;
120
+ /** Every state, answered. A missing key is a type error, not a blank screen. */
121
+ export interface StateHandlers<T, R> {
122
+ loading: (s: Extract<SurfaceState<T>, {
123
+ kind: 'loading';
124
+ }>) => R;
125
+ forbidden: (s: Extract<SurfaceState<T>, {
126
+ kind: 'forbidden';
127
+ }>) => R;
128
+ error: (s: Extract<SurfaceState<T>, {
129
+ kind: 'error';
130
+ }>) => R;
131
+ empty: (s: Extract<SurfaceState<T>, {
132
+ kind: 'empty';
133
+ }>) => R;
134
+ partial: (s: Extract<SurfaceState<T>, {
135
+ kind: 'partial';
136
+ }>) => R;
137
+ ready: (s: Extract<SurfaceState<T>, {
138
+ kind: 'ready';
139
+ }>) => R;
140
+ }
141
+ /**
142
+ * ⭐ THE ENFORCEMENT. Generic in `R`, so the same call works for a React node, an
143
+ * HTML string, or a line of terminal output — the states are a fact about the
144
+ * data, not about the framework drawing it.
145
+ */
146
+ export declare function matchState<T, R>(state: SurfaceState<T>, on: StateHandlers<T, R>): R;
147
+ /** Compile-time proof a union was handled; a loud failure if it was not. */
148
+ export declare function assertNever(value: never, where: string): never;
@@ -0,0 +1,37 @@
1
+ import { type EmitOptions } from '../tokens/emit.js';
2
+ import type { ResolvedTheme, Density } from '../tokens/types.js';
3
+ /**
4
+ * Element defaults, so semantic HTML is already right.
5
+ *
6
+ * ⚠️ Everything here is `:where(...)`. An app overrides any of it with a plain
7
+ * selector and never has to think about specificity.
8
+ */
9
+ export declare function emitBaseCss(prefix?: string): string;
10
+ /**
11
+ * The mould — page frame, rhythm, and the few layouts every screen repeats.
12
+ *
13
+ * ⚠️ Deliberately small. A kit that also owns page composition stops being a kit
14
+ * and becomes a framework nobody can build an unusual screen in. What is here
15
+ * is the shape an operational product repeats on every screen: a page with a
16
+ * header, sections at one rhythm, a form that does not step, a table that
17
+ * scrolls sideways instead of breaking the page.
18
+ */
19
+ export declare function emitLayoutCss(prefix?: string): string;
20
+ export interface StylesheetOptions extends EmitOptions {
21
+ /** Density blocks to emit alongside the default — see `emitCss`. */
22
+ densities?: Density[];
23
+ /** Leave out the element defaults if the app already has its own reset. */
24
+ base?: boolean;
25
+ /** Leave out the page frame if the app composes its own layout. */
26
+ layout?: boolean;
27
+ }
28
+ /**
29
+ * The whole kit, in cascade order, from one call.
30
+ *
31
+ * writeFileSync('ui-kit.css', emitStylesheet(theme))
32
+ *
33
+ * Order matters and is not the caller's problem: base (zero specificity) →
34
+ * tokens → type → components → layout. An application's own stylesheet loads
35
+ * after this one and wins wherever it says anything.
36
+ */
37
+ export declare function emitStylesheet(theme: ResolvedTheme, options?: StylesheetOptions): string;
@@ -0,0 +1,2 @@
1
+ export { navModel, routesOf, domainOf, type NavDecl, type NavDomain, type NavCluster, type NavItem, type ItemState, type ResolvedNavItem, type ResolvedNavCluster, type Route, type Viewer, type NavModel, } from './nav.js';
2
+ export { emptyTrail, moveTrail, titleTrail, backOf, returnOf, parseTrail, type Trail, type TrailEntry, type TrailMove, type TrailPlace, type TrailReturn, } from './trail.js';
@@ -0,0 +1,142 @@
1
+ import type { LensDiagnostic } from '../lens/index.js';
2
+ export interface NavItem {
3
+ name: string;
4
+ label: string;
5
+ /**
6
+ * Absolute, within the domain. `/members`, not `members`.
7
+ *
8
+ * ⭐ OPTIONAL, AND THE ABSENCE MEANS SOMETHING: this part of the scope is
9
+ * DECLARED BUT NOT BUILT YET. The item still appears, dimmed and inert.
10
+ *
11
+ * Borrowed from an application bitten by the opposite: its menu was
12
+ * hand-written and listed only finished screens, so a system with 19
13
+ * entities across 5 clusters opened as a 9-item product and one whole
14
+ * cluster was invisible. A menu is a MAP OF THE SCOPE, and a map that omits
15
+ * the unbuilt roads is not a smaller map — it is a wrong one.
16
+ */
17
+ path?: string;
18
+ /** Roles that may enter. Absent means everyone in the domain. */
19
+ need?: string[];
20
+ /**
21
+ * Match this path EXACTLY, never as a prefix.
22
+ *
23
+ * ⚠️ Almost always wrong, and load-bearing for the one case it is right: an
24
+ * item at `/` is a prefix of every other page, so without this the home
25
+ * entry is lit on every screen in the product.
26
+ */
27
+ end?: boolean;
28
+ /**
29
+ * Routes that live UNDER this item and never appear in a menu.
30
+ *
31
+ * ⛔ ADDED AFTER A CLAIM OF MINE TURNED OUT WRONG BY A FACTOR OF THREE.
32
+ *
33
+ * The fit log said `routesOf()` replaces a hand-written route table: "126
34
+ * imports, 130 routes". Run against a real declaration it produced **49
35
+ * routes against the application's 128**. The 79 missing were never menu
36
+ * entries and never could be — `/members/:id`, `/plans/new`,
37
+ * `/documents/:id/print`. A menu that lists `/members/:id` is a broken menu.
38
+ *
39
+ * ⭐ So `routesOf` was never a route-table generator. It was HALF a table,
40
+ * and the other half had no vocabulary. This is that half.
41
+ *
42
+ * Paths are relative to the parent, so the prefix stays written once. A
43
+ * child may NARROW the roles — a "new record" form is routinely restricted
44
+ * where the list above it is not, and today that restriction is retyped by
45
+ * hand in a route guard.
46
+ */
47
+ under?: {
48
+ path: string;
49
+ need?: string[];
50
+ end?: boolean;
51
+ }[];
52
+ }
53
+ /**
54
+ * ⛔ TWO REASONS AN ITEM IS NOT AVAILABLE, AND THEY MUST NOT LOOK ALIKE.
55
+ *
56
+ * hidden — the viewer does not hold the role. Left out entirely: showing
57
+ * every item and then refusing makes someone learn a system that is
58
+ * not theirs.
59
+ * unbuilt — the work IS theirs and the screen does not exist yet. Shown,
60
+ * dimmed, inert. Hiding it misreports the scope; enabling it is a
61
+ * link into nothing.
62
+ *
63
+ * Collapsing the two into one grey state is a rail lying in both directions
64
+ * at once.
65
+ */
66
+ export type ItemState = 'ready' | 'unbuilt';
67
+ export interface NavCluster {
68
+ name: string;
69
+ /**
70
+ * ⚠️ Optional: a cluster may have no heading at all. Some rails open with a
71
+ * few entries belonging to no named group, and inventing a title for them
72
+ * ("General", "Other") adds a word the reader has to skip past.
73
+ */
74
+ label?: string;
75
+ items: NavItem[];
76
+ }
77
+ /** An item as the rail should draw it. */
78
+ export interface ResolvedNavItem extends NavItem {
79
+ state: ItemState;
80
+ }
81
+ export interface ResolvedNavCluster {
82
+ name: string;
83
+ label?: string;
84
+ items: ResolvedNavItem[];
85
+ }
86
+ export interface NavDomain {
87
+ name: string;
88
+ label: string;
89
+ need?: string[];
90
+ /** Reachable from every domain — an alert feed, a search. */
91
+ crossDomain?: boolean;
92
+ /** Cluster names, in the order they should read. */
93
+ clusters?: string[];
94
+ }
95
+ export interface NavDecl {
96
+ domains: NavDomain[];
97
+ clusters: NavCluster[];
98
+ }
99
+ export interface Viewer {
100
+ roles: string[];
101
+ }
102
+ export interface NavModel {
103
+ /** Null when the path names no domain the viewer may enter. */
104
+ domain: NavDomain | null;
105
+ /** What to draw in the rail — already filtered, already ordered. */
106
+ clusters: ResolvedNavCluster[];
107
+ active: {
108
+ cluster: string;
109
+ item: ResolvedNavItem;
110
+ } | null;
111
+ /** `launcher` when there is no domain to show: the entry screen, not an error. */
112
+ entry: 'launcher' | 'domain';
113
+ diagnostics: LensDiagnostic[];
114
+ }
115
+ /** The domain a path is inside — the first segment, and nothing cleverer. */
116
+ export declare const domainOf: (path: string) => string;
117
+ export declare function navModel(decl: NavDecl, viewer: Viewer, path: string): NavModel;
118
+ /**
119
+ * Every route the shell must serve, derived from the declaration.
120
+ *
121
+ * ⭐ The point is that it is DERIVED. A hand-written route table and a
122
+ * hand-written menu are two lists of the same thing, and the reference app
123
+ * had to write a build check to keep them honest. Generate one from the
124
+ * other and there is nothing left to check.
125
+ */
126
+ export interface Route {
127
+ path: string;
128
+ item: NavItem;
129
+ cluster: string;
130
+ /** True for a route that is not itself a menu entry — see `NavItem.under`. */
131
+ child: boolean;
132
+ /** Roles for THIS route: the child's if it narrows, otherwise the item's. */
133
+ need?: string[];
134
+ }
135
+ /**
136
+ * Every route the shell must serve — menu entries AND the pages under them.
137
+ *
138
+ * ⚠️ Unbuilt items yield nothing, children included. A route to a screen that
139
+ * does not exist is a blank page, which reads as a defect; a dimmed menu
140
+ * entry reads as "not yet", which is the truth.
141
+ */
142
+ export declare const routesOf: (decl: NavDecl) => Route[];
@@ -0,0 +1,85 @@
1
+ /** How the viewer arrived at a place — the three moves a history stack has. */
2
+ export type TrailMove = 'PUSH' | 'REPLACE' | 'POP';
3
+ /**
4
+ * One history entry, as the router names it.
5
+ *
6
+ * `key` is the router's id for the ENTRY, not for the address: the same
7
+ * address visited twice is two entries. `path` is the address without its
8
+ * query; `href` is the whole thing, to open it again.
9
+ */
10
+ export interface TrailPlace {
11
+ key: string;
12
+ path: string;
13
+ href: string;
14
+ }
15
+ export interface TrailEntry {
16
+ path: string;
17
+ href: string;
18
+ /** What the screen called itself. Given by the app, never guessed here. */
19
+ title?: string;
20
+ /** The entry directly beneath this one in the history stack. */
21
+ below?: string;
22
+ /** Order of first sight — used only to forget the oldest. */
23
+ seq: number;
24
+ }
25
+ export interface Trail {
26
+ /** The entry the viewer is on. */
27
+ at?: string;
28
+ seq: number;
29
+ entries: Record<string, TrailEntry>;
30
+ }
31
+ /** Where "back" should go. */
32
+ export type TrailReturn =
33
+ /** Step back `steps` entries through history — the viewer came from there. */
34
+ {
35
+ kind: 'history';
36
+ steps: number;
37
+ href: string;
38
+ title?: string;
39
+ }
40
+ /** No known way in (a link opened cold, a new tab): go to a place the app named. */
41
+ | {
42
+ kind: 'parent';
43
+ href: string;
44
+ title?: string;
45
+ };
46
+ export declare const emptyTrail: () => Trail;
47
+ /**
48
+ * Record one move. Pure: returns a new trail.
49
+ *
50
+ * ⚠️ IDEMPOTENT ON PURPOSE. Renderers run effects twice in development and
51
+ * re-run them on unrelated renders; a second call for the entry the viewer
52
+ * is already on changes nothing.
53
+ */
54
+ export declare function moveTrail(trail: Trail, move: TrailMove, place: TrailPlace, cap?: number): Trail;
55
+ /**
56
+ * The screen at `key` names itself. Creates a stub when the move has not been
57
+ * recorded yet (see `moveTrail`).
58
+ */
59
+ export declare function titleTrail(trail: Trail, key: string, title: string): Trail;
60
+ /**
61
+ * The nearest entry beneath `key` that is a DIFFERENT screen, and how many
62
+ * steps back it is. `null` when the trail does not know — the entry was opened
63
+ * cold, or the chain was forgotten.
64
+ */
65
+ export declare function backOf(trail: Trail, key: string | undefined): Extract<TrailReturn, {
66
+ kind: 'history';
67
+ }> | null;
68
+ /**
69
+ * Where "back" goes: through history when the trail knows, else the first
70
+ * fallback the app offers.
71
+ *
72
+ * ⭐ The fallbacks are in order of how much they know. An app typically passes
73
+ * a target the CALLER wrote into the link first, then the parent the screen
74
+ * itself declares. Neither is used when the trail knows better.
75
+ */
76
+ export declare function returnOf(trail: Trail, key: string | undefined, ...fallbacks: ({
77
+ href: string;
78
+ title?: string;
79
+ } | null | undefined)[]): TrailReturn | null;
80
+ /**
81
+ * Read a trail back from storage. Anything that is not a trail — a stale
82
+ * shape, a hand edit, `null` — becomes an empty one rather than an error: a
83
+ * lost trail costs a fallback link, a thrown error costs the screen.
84
+ */
85
+ export declare function parseTrail(value: unknown): Trail;
@@ -0,0 +1,70 @@
1
+ import type { ResolvedTheme, Density } from './types.js';
2
+ export interface EmitOptions {
3
+ /** Where the variables land. Two themes = two calls, two selectors. */
4
+ selector?: string;
5
+ /** Variable prefix, without dashes. */
6
+ prefix?: string;
7
+ /**
8
+ * Write each spacing and radius step's purpose beside it.
9
+ *
10
+ * ⭐ On by default. A developer reads the generated file far more often than
11
+ * they read this package, and a scale whose steps explain themselves is the
12
+ * difference between "24 or 32?" and "this is a card".
13
+ */
14
+ annotate?: boolean;
15
+ /** Prepended verbatim, inside the block. For an app's own bridge aliases. */
16
+ tail?: string;
17
+ /**
18
+ * Also emit `:root[data-density="…"]` overrides, so a density switch is a
19
+ * single attribute rather than a second stylesheet.
20
+ *
21
+ * ⭐ Only the tokens density actually governs appear in these blocks — the
22
+ * package knows which, so the app never has to guess.
23
+ *
24
+ * ⛔ `--fos-touch` IS NEVER AMONG THEM, and that absence is deliberate enough
25
+ * to be tested. It is fixed at 44px across all three densities because a
26
+ * finger does not get smaller when a layout gets tighter; a density block
27
+ * containing it would invite the next reader to believe otherwise.
28
+ *
29
+ * ⚠️ The theme's own density is added if missing. Without it there is no
30
+ * selector to switch BACK to the default, and the app discovers that after
31
+ * shipping the switch.
32
+ */
33
+ densities?: Density[];
34
+ }
35
+ export declare function emitCss(theme: ResolvedTheme, options?: EmitOptions): string;
36
+ /**
37
+ * Every variable name this theme defines.
38
+ *
39
+ * ⭐ Exported so an app can check its own stylesheet against it. A `var(--fos-x)`
40
+ * naming nothing is the failure CSS handles worst: no warning, no fallback —
41
+ * it DROPS THE WHOLE DECLARATION. The app measured for this package lost a red
42
+ * marker bar exactly that way and found out by looking at the screen.
43
+ */
44
+ export declare function tokenNames(theme: ResolvedTheme, prefix?: string): string[];
45
+ /**
46
+ * Type steps as CLASSES — the ergonomic half, and it exists because the
47
+ * variables alone measurably failed.
48
+ *
49
+ * ⛔ THE MEASUREMENT THAT FORCED THIS
50
+ *
51
+ * `emitCss` publishes four variables per step: size, line, weight, tracking —
52
+ * 24 in all. The first application to adopt the package wired **the size, and
53
+ * nothing else**: 0 of the 18 secondary tokens. The other three ended up
54
+ * scattered through 4,788 lines of stylesheet, a different answer each time,
55
+ * and that inconsistency is exactly what makes an interface read as patchwork.
56
+ *
57
+ * Nobody was careless. Four variables per step means an author has to REMEMBER
58
+ * to compose four, and under any deadline they take the one that visibly
59
+ * changes something. This is the same shape as a shared component that ships
60
+ * with six call sites and sixty-two hand-rolled copies: the right thing existed
61
+ * and the easy thing won.
62
+ *
63
+ * ⚠️ AND IT BENDS A RULE THIS PACKAGE STATES ELSEWHERE — that the engine emits
64
+ * variables and never CSS rules. The rule holds where it was aimed: nothing
65
+ * here decides what a card or a button looks like. A type step is different,
66
+ * because the engine already owns all four of its numbers; withholding them
67
+ * as four separate parts was not restraint, it was an assembly instruction
68
+ * nobody follows.
69
+ */
70
+ export declare function emitTypeUtilities(theme: ResolvedTheme, prefix?: string): string;
@@ -0,0 +1,6 @@
1
+ export * from './types.js';
2
+ export { resolveTheme, formatThemeDiagnostics } from './resolve.js';
3
+ export { emitCss, emitTypeUtilities, tokenNames, type EmitOptions } from './emit.js';
4
+ export { DQA_THEME } from './theme.dqa.js';
5
+ export { SPACE, SPACE_PURPOSE, RADIUS, RADIUS_PURPOSE, TEXT, FONT, STATIC, LADDER, GREY_TINT, TONE_HUE, TONE_ALIAS, CONTROL, TARGET_FLOOR, } from './scales.js';
6
+ export { toHex, fromHex, contrast, luminance, type Oklch } from './oklch.js';
@@ -0,0 +1,53 @@
1
+ /** Lightness 0–1, chroma 0–~0.4, hue in degrees. */
2
+ export interface Oklch {
3
+ l: number;
4
+ c: number;
5
+ h: number;
6
+ }
7
+ export interface Rgb {
8
+ r: number;
9
+ g: number;
10
+ b: number;
11
+ }
12
+ /**
13
+ * Pull chroma down until the colour fits in sRGB, keeping lightness and hue.
14
+ *
15
+ * ⚠️ NOT a per-channel clamp. Clamping moves the hue — ask for a saturated blue
16
+ * at high lightness and a clamp hands back something visibly purple: the
17
+ * app's brand colour rendered wrong, with no complaint. Reducing chroma keeps
18
+ * the colour recognisably itself and merely duller, and `clipped` says so out
19
+ * loud so the resolver can report it.
20
+ */
21
+ export declare function fit(colour: Oklch): {
22
+ rgb: Rgb;
23
+ clipped: boolean;
24
+ };
25
+ /** OKLCH → `#rrggbb`, chroma-fitted. */
26
+ export declare function toHex(colour: Oklch): {
27
+ hex: string;
28
+ clipped: boolean;
29
+ };
30
+ /**
31
+ * WCAG relative luminance, measured on the BYTES that ship.
32
+ *
33
+ * ⭐ Deliberately re-read from the hex rather than kept from the float pipeline.
34
+ * The browser paints the rounded 8-bit value, so that is the value whose
35
+ * contrast has to pass. A theme that passes at full precision and fails after
36
+ * rounding would be a check that lies in the app's favour.
37
+ */
38
+ export declare function luminance(hex: string): number;
39
+ /** WCAG 2.x contrast ratio, 1–21. */
40
+ export declare function contrast(a: string, b: string): number;
41
+ /**
42
+ * `#rrggbb` → OKLCH. The inverse, and it earns its place twice.
43
+ *
44
+ * ⭐ It is how the ladders in `scales.ts` were DERIVED rather than invented: the
45
+ * hand-written palette that shipped before this package was read back into
46
+ * OKLCH, and the rungs are where its own colours already sat. A computed
47
+ * system that lands somewhere else than the brand it replaces is a redesign
48
+ * wearing the costume of a refactor.
49
+ *
50
+ * ⚠️ Also the migration tool. An app holding a legacy hex can ask what hue it
51
+ * actually is, instead of guessing a declaration and comparing screenshots.
52
+ */
53
+ export declare function fromHex(hex: string): Oklch;
@@ -0,0 +1,4 @@
1
+ import type { ThemeDecl, ThemeDiagnostic, ThemeResult } from './types.js';
2
+ export declare function resolveTheme(decl: ThemeDecl): ThemeResult;
3
+ /** One block a build step or a start-up can print. */
4
+ export declare function formatThemeDiagnostics(list: ThemeDiagnostic[]): string;