@dqa-ai-solutions/ui-runtime 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/README.md +17 -2
- package/dist/_types/ui-kit/index.d.ts +4 -0
- package/dist/_types/ui-kit/lens/action.d.ts +76 -0
- package/dist/_types/ui-kit/lens/cell.d.ts +79 -0
- package/dist/_types/ui-kit/lens/diagnostic.d.ts +49 -0
- package/dist/_types/ui-kit/lens/format.d.ts +32 -0
- package/dist/_types/ui-kit/lens/index.d.ts +12 -0
- package/dist/_types/ui-kit/lens/list.d.ts +223 -0
- package/dist/_types/ui-kit/lens/milestone.d.ts +112 -0
- package/dist/_types/ui-kit/lens/pattern.d.ts +38 -0
- package/dist/_types/ui-kit/lens/queue.d.ts +30 -0
- package/dist/_types/ui-kit/lens/record.d.ts +110 -0
- package/dist/_types/ui-kit/lens/registry.d.ts +9 -0
- package/dist/_types/ui-kit/lens/shape.d.ts +27 -0
- package/dist/_types/ui-kit/lens/timeline.d.ts +36 -0
- package/dist/_types/ui-kit/primitives/action.d.ts +263 -0
- package/dist/_types/ui-kit/primitives/index.d.ts +2 -0
- package/dist/_types/ui-kit/primitives/state.d.ts +148 -0
- package/dist/_types/ui-kit/shell/index.d.ts +2 -0
- package/dist/_types/ui-kit/shell/nav.d.ts +142 -0
- package/dist/_types/ui-kit/shell/trail.d.ts +85 -0
- package/dist/_types/ui-kit/tokens/index.d.ts +1 -0
- package/dist/_types/ui-kit/tokens/types.d.ts +252 -0
- package/dist/_types/ui-react/elements/action-bar.d.ts +32 -0
- package/dist/_types/ui-react/elements/action-scope.d.ts +9 -0
- package/dist/_types/ui-react/elements/button.d.ts +42 -0
- package/dist/_types/ui-react/elements/choice.d.ts +40 -0
- package/dist/_types/ui-react/elements/columns.d.ts +82 -0
- package/dist/_types/ui-react/elements/dialog-scope.d.ts +15 -0
- package/dist/_types/ui-react/elements/dialog.d.ts +67 -0
- package/dist/_types/ui-react/elements/disclosure.d.ts +305 -0
- package/dist/_types/ui-react/elements/field-attributes.d.ts +39 -0
- package/dist/_types/ui-react/elements/field.d.ts +628 -0
- package/dist/_types/ui-react/elements/file.d.ts +82 -0
- package/dist/_types/ui-react/elements/filter.d.ts +61 -0
- package/dist/_types/ui-react/elements/link.d.ts +38 -0
- package/dist/_types/ui-react/elements/menu.d.ts +56 -0
- package/dist/_types/ui-react/elements/milestone.d.ts +119 -0
- package/dist/_types/ui-react/elements/nav.d.ts +73 -0
- package/dist/_types/ui-react/elements/pop.d.ts +14 -0
- package/dist/_types/ui-react/elements/record.d.ts +174 -0
- package/dist/_types/ui-react/elements/segmented.d.ts +59 -0
- package/dist/_types/ui-react/elements/suggest.d.ts +11 -0
- package/dist/_types/ui-react/elements/surface.d.ts +354 -0
- package/dist/_types/ui-react/elements/table.d.ts +72 -0
- package/dist/_types/ui-react/elements/toast.d.ts +69 -0
- package/dist/_types/ui-react/index.d.ts +22 -0
- package/dist/_types/ui-react/prefix/index.d.ts +8 -0
- package/dist/chunks/chunk-4LX2HZJU.js +0 -0
- package/dist/chunks/chunk-7WHYHIUX.js +1 -0
- package/dist/chunks/chunk-VS5FCRGY.js +3 -0
- package/dist/chunks/chunk-X6SR5UHK.js +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/lens.d.ts +1 -0
- package/dist/lens.js +1 -0
- package/dist/primitives.d.ts +1 -0
- package/dist/primitives.js +1 -0
- package/dist/react.d.ts +1 -0
- package/dist/react.js +1 -0
- package/dist/shell.d.ts +1 -0
- package/dist/shell.js +1 -0
- package/dist/tokens.css +160 -0
- package/dist/tokens.d.ts +1 -0
- package/dist/tokens.dark.css +98 -0
- package/dist/tokens.generated.css +98 -0
- package/dist/tokens.high.css +98 -0
- package/dist/tokens.js +1 -0
- package/package.json +60 -4
|
@@ -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 @@
|
|
|
1
|
+
export * from './types.js';
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import type { Tone } from '@dqa-ai-solutions/core-runtime/view';
|
|
2
|
+
/** A hue in degrees, or a hue with the colourfulness dialled. */
|
|
3
|
+
export type Hue = number | {
|
|
4
|
+
hue: number;
|
|
5
|
+
chroma?: number;
|
|
6
|
+
};
|
|
7
|
+
/**
|
|
8
|
+
* A colour that may also pin its own lightness.
|
|
9
|
+
*
|
|
10
|
+
* ⭐ THE ESCAPE THE LADDER HAS TO HAVE, AND EXACTLY ONE REASON FOR IT.
|
|
11
|
+
*
|
|
12
|
+
* Some colours are FIXED BEFORE THE SOFTWARE EXISTS: a national flag, a
|
|
13
|
+
* regulated corporate mark, a colour written into a standard. Pulling one onto
|
|
14
|
+
* a computed rung does not improve it — it produces a different colour and
|
|
15
|
+
* calls it the brand.
|
|
16
|
+
*
|
|
17
|
+
* Measured, and this is why the escape exists: `#da251d` sits at L 0.572. The
|
|
18
|
+
* ladder puts the action colour at L 0.428, so the resolver returned `#990002`
|
|
19
|
+
* — 1.81:1 away from what was asked, which the eye reads as simply not the
|
|
20
|
+
* same red.
|
|
21
|
+
*
|
|
22
|
+
* ⚠️ PINNING LIGHTNESS DOES NOT BUY OUT OF THE GUARANTEE. The contrast check on
|
|
23
|
+
* the label stays an ERROR. `#da251d` is allowed because white on it measures
|
|
24
|
+
* 4.93:1; a fixed colour that no label can be read on still fails the build.
|
|
25
|
+
* The ladder is negotiable, readability is not.
|
|
26
|
+
*/
|
|
27
|
+
export type ColourDecl = number | {
|
|
28
|
+
hue: number;
|
|
29
|
+
chroma?: number;
|
|
30
|
+
l?: number;
|
|
31
|
+
};
|
|
32
|
+
/** @deprecated Use `ColourDecl`. Kept so 0.3.x callers keep compiling. */
|
|
33
|
+
export type FlairDecl = ColourDecl;
|
|
34
|
+
export interface ThemeDecl {
|
|
35
|
+
/** Which way round the ladders run. */
|
|
36
|
+
scheme?: 'light' | 'dark';
|
|
37
|
+
/**
|
|
38
|
+
* The app's action colour — the one primary button, the focus ring, a link.
|
|
39
|
+
*
|
|
40
|
+
* ⛔ NOT a page ground and not a default button ground. The app this kernel
|
|
41
|
+
* was measured against shipped `.btn, button { background: var(--red) }`,
|
|
42
|
+
* so a bare `<button>` was already the loudest thing on screen; 33 screens
|
|
43
|
+
* ended up a wall of them and a check had to be written to count them.
|
|
44
|
+
* That is a palette defect wearing the costume of a discipline problem,
|
|
45
|
+
* and no amount of review fixes it.
|
|
46
|
+
*/
|
|
47
|
+
primary: ColourDecl;
|
|
48
|
+
/**
|
|
49
|
+
* Identity colours — a gradient, a mark. Never carries meaning, never text.
|
|
50
|
+
*
|
|
51
|
+
* ⭐ THE ONE PLACE A LIGHTNESS MAY BE PINNED, and the exception argues for the
|
|
52
|
+
* rule. Every other rung is computed because something is MEASURED against
|
|
53
|
+
* it; nothing is measured against flair, because nothing is ever read on it.
|
|
54
|
+
* A brand mark is chosen, not derived, and pretending otherwise would mean
|
|
55
|
+
* telling an app its logo colour is off-ladder.
|
|
56
|
+
*/
|
|
57
|
+
flair?: ColourDecl[];
|
|
58
|
+
/**
|
|
59
|
+
* The hue the NEUTRAL ladder runs on. Defaults to `primary`.
|
|
60
|
+
*
|
|
61
|
+
* ⛔ ADDED AFTER THE DEFAULT WAS CAUGHT BEING AN ACCIDENT.
|
|
62
|
+
*
|
|
63
|
+
* The greys borrowed `primary`'s hue, and that read as principled until the
|
|
64
|
+
* second app arrived. It worked because the house grey sits at 264° and the
|
|
65
|
+
* house primary at 259.7° — five degrees apart, so nobody could tell the
|
|
66
|
+
* rule from the coincidence.
|
|
67
|
+
*
|
|
68
|
+
* The first app with a warm action colour broke it outright: a red primary
|
|
69
|
+
* at 28.8° meant NO value of `tint` produced a cool grey. Zero gave dead
|
|
70
|
+
* neutral, anything else gave pink, and the app's real greys (264°, blue)
|
|
71
|
+
* were simply unreachable.
|
|
72
|
+
*
|
|
73
|
+
* ⭐ Cool greys with a warm accent is not an exotic taste — it is the house
|
|
74
|
+
* style of most admin software. The package was quietly forbidding it.
|
|
75
|
+
*
|
|
76
|
+
* ⚠️ Still a HUE, not a colour. The ladder stays computed and the contrast
|
|
77
|
+
* guard still measures it; this widens what can be asked for, it does not
|
|
78
|
+
* let anyone pin a rung.
|
|
79
|
+
*/
|
|
80
|
+
grey?: Hue;
|
|
81
|
+
/**
|
|
82
|
+
* How much of the grey hue bleeds into the neutrals. 0 is neutral.
|
|
83
|
+
*
|
|
84
|
+
* Small numbers (~0.001–0.01). The difference between a slab of grey and a
|
|
85
|
+
* surface that belongs to the rest of the app. The engine tints each rung by
|
|
86
|
+
* a different multiple of this — see `GREY_TINT`.
|
|
87
|
+
*/
|
|
88
|
+
tint?: number;
|
|
89
|
+
/**
|
|
90
|
+
* `high` pushes ink away from its ground across the board.
|
|
91
|
+
*
|
|
92
|
+
* ⭐ This is what the computed ladders buy. A high-contrast theme is one word
|
|
93
|
+
* here, not a second palette somebody has to keep in step with the first.
|
|
94
|
+
*/
|
|
95
|
+
contrast?: 'normal' | 'high' | number | {
|
|
96
|
+
min: number;
|
|
97
|
+
on?: 'ink' | 'ink-2' | 'ink-3' | 'all';
|
|
98
|
+
};
|
|
99
|
+
/** Scales spacing only. Never type size, never hit targets. */
|
|
100
|
+
density?: Density;
|
|
101
|
+
radius?: 'sharp' | 'soft' | 'round';
|
|
102
|
+
font?: {
|
|
103
|
+
sans?: string;
|
|
104
|
+
mono?: string;
|
|
105
|
+
};
|
|
106
|
+
/**
|
|
107
|
+
* The body size the whole type ladder is computed around.
|
|
108
|
+
*
|
|
109
|
+
* ⭐ The app declares the ONE number it has a reason for. Everything else is
|
|
110
|
+
* derived — see `TEXT_RATIO`. `base: 14` reproduces the table that shipped.
|
|
111
|
+
*
|
|
112
|
+
* ⚠️ SCREEN ONLY. A print sheet is laid out in `pt` against a paper standard
|
|
113
|
+
* and must not follow a screen's body size, the same way `density` scales
|
|
114
|
+
* spacing and never touches hit targets.
|
|
115
|
+
*/
|
|
116
|
+
text?: {
|
|
117
|
+
base?: number;
|
|
118
|
+
};
|
|
119
|
+
/**
|
|
120
|
+
* What each tone LOOKS like. The ontology declares a state's weight (`Tone`);
|
|
121
|
+
* the app declares which hue carries that weight here.
|
|
122
|
+
*
|
|
123
|
+
* ⚠️ The engine keeps the ladder inside a tone — ground, ink, and the distance
|
|
124
|
+
* between them. An app picks the hue and cannot pick an unreadable chip.
|
|
125
|
+
*/
|
|
126
|
+
tones?: Partial<Record<Tone, Hue>>;
|
|
127
|
+
/**
|
|
128
|
+
* How many chart colours to emit.
|
|
129
|
+
*
|
|
130
|
+
* ⚠️ A NUMBER, not a list of colours. The app knows how many series its
|
|
131
|
+
* busiest chart has; it does not get to pick what they look like, for the
|
|
132
|
+
* same reason it does not pick a surface — the moment it can, the
|
|
133
|
+
* distinguishability guarantee stops being one.
|
|
134
|
+
*/
|
|
135
|
+
chart?: {
|
|
136
|
+
/** Categorical series. Default 6, hard-reported past 8. */
|
|
137
|
+
series?: number;
|
|
138
|
+
/** Steps in the ordered scale. Default 5. */
|
|
139
|
+
levels?: number;
|
|
140
|
+
/** Hue the ordered scale runs on. Defaults to `primary`. */
|
|
141
|
+
levelHue?: number;
|
|
142
|
+
/**
|
|
143
|
+
* Hue arcs the series palette must walk around.
|
|
144
|
+
*
|
|
145
|
+
* ⭐ A brand colour is not a data series. An application whose identity red
|
|
146
|
+
* also came out as `series-1` had to keep its own chart palette — which is
|
|
147
|
+
* exactly what this package exists to delete. Reserving the arc lets the
|
|
148
|
+
* series ladder stay computed AND stay off the brand.
|
|
149
|
+
*
|
|
150
|
+
* ⚠️ Arcs, not a start offset. A start offset moves the collision rather than
|
|
151
|
+
* removing it: with six series the wheel is walked anyway and the reserved
|
|
152
|
+
* hue comes back around at position four.
|
|
153
|
+
*/
|
|
154
|
+
avoid?: {
|
|
155
|
+
from: number;
|
|
156
|
+
to: number;
|
|
157
|
+
}[];
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
/** Semantic names only. No `red`, no `gray3`, nothing an app has to interpret. */
|
|
161
|
+
export type ThemeColors = Record<string, string>;
|
|
162
|
+
export interface TextStep {
|
|
163
|
+
size: number;
|
|
164
|
+
line: number;
|
|
165
|
+
weight: number;
|
|
166
|
+
tracking: number;
|
|
167
|
+
}
|
|
168
|
+
export type Density = 'compact' | 'cosy' | 'roomy';
|
|
169
|
+
export interface ResolvedTheme {
|
|
170
|
+
scheme: 'light' | 'dark';
|
|
171
|
+
/** Which density `space` and `row` were computed at. */
|
|
172
|
+
density: Density;
|
|
173
|
+
colors: ThemeColors;
|
|
174
|
+
/** Categorical chart colours, in order. `--fos-series-1…n`. */
|
|
175
|
+
series: string[];
|
|
176
|
+
/** One ordered scale — low to high. `--fos-level-1…n`. */
|
|
177
|
+
levels: string[];
|
|
178
|
+
space: Record<string, number>;
|
|
179
|
+
/** Table row geometry for the declared density. */
|
|
180
|
+
row: {
|
|
181
|
+
h: number;
|
|
182
|
+
padX: number;
|
|
183
|
+
padY: number;
|
|
184
|
+
};
|
|
185
|
+
/** How tall a control is DRAWN, per density. */
|
|
186
|
+
controlHeight: number;
|
|
187
|
+
/** Minimum interactive target in px — fixed, never scaled by density. */
|
|
188
|
+
/**
|
|
189
|
+
* ⛔ The smallest a target may ever be — WCAG 2.2 §2.5.8.
|
|
190
|
+
*
|
|
191
|
+
* It became a TOKEN the day the grammar needed it in a rule: a `24px`
|
|
192
|
+
* literal tripped this package's own "no raw pixel sizes" check, which was
|
|
193
|
+
* right to trip. A floor written as a number in one rule is a floor the
|
|
194
|
+
* next rule does not know about.
|
|
195
|
+
*/
|
|
196
|
+
targetFloor: number;
|
|
197
|
+
touchTarget: number;
|
|
198
|
+
radius: Record<string, number>;
|
|
199
|
+
text: Record<string, TextStep>;
|
|
200
|
+
font: {
|
|
201
|
+
sans: string;
|
|
202
|
+
mono: string;
|
|
203
|
+
};
|
|
204
|
+
static: Record<string, string>;
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* ⚠️ Resolution never throws on a bad theme and never silently substitutes.
|
|
208
|
+
* Same rule as the view resolver, for the same reason: throwing kills an app
|
|
209
|
+
* over one number; substituting ships a screen nobody can read while
|
|
210
|
+
* reporting success. Collect everything, then let the caller decide.
|
|
211
|
+
*/
|
|
212
|
+
export interface ThemeDiagnostic {
|
|
213
|
+
severity: 'error' | 'warn';
|
|
214
|
+
code:
|
|
215
|
+
/** Text does not reach WCAG AA against a ground it can land on. */
|
|
216
|
+
'CONTRAST_FAIL'
|
|
217
|
+
/** No label reaches AA on the primary — the one button that must be read. */
|
|
218
|
+
| 'PRIMARY_UNREADABLE'
|
|
219
|
+
/** Two tones too close in hue to tell apart — `done` and `doing` both green. */
|
|
220
|
+
| 'TONE_COLLISION'
|
|
221
|
+
/**
|
|
222
|
+
* The action colour is the same hue as a state.
|
|
223
|
+
*
|
|
224
|
+
* ⛔ WARN, NOT ERROR, AND THE DISTINCTION IS THE POINT. Two tones colliding
|
|
225
|
+
* is a pure defect: both are states, and a user who cannot tell them apart
|
|
226
|
+
* has lost information with nothing to fall back on. A primary button
|
|
227
|
+
* colliding with a state is different — a button and a chip differ in
|
|
228
|
+
* shape and in position, and an organisation may have a fixed identity
|
|
229
|
+
* colour that lands there on purpose. Reported, never blocked.
|
|
230
|
+
*/
|
|
231
|
+
| 'PRIMARY_TONE_COLLISION'
|
|
232
|
+
/** More series than a person can hold apart. A chart problem, not a palette one. */
|
|
233
|
+
| 'SERIES_TOO_MANY'
|
|
234
|
+
/** Two adjacent series separable only by hue — invisible to some readers. */
|
|
235
|
+
| 'SERIES_INDISTINCT'
|
|
236
|
+
/** Asked for more colourfulness than sRGB holds; chroma was reduced. */
|
|
237
|
+
| 'CHROMA_CLIPPED'
|
|
238
|
+
/** A key the theme vocabulary does not have. Accepted-and-ignored is worse. */
|
|
239
|
+
| 'UNKNOWN_KEY'
|
|
240
|
+
/** A number outside the range the ladders were built for. */
|
|
241
|
+
| 'OUT_OF_RANGE'
|
|
242
|
+
/** `contrast: { min }` asked for more separation than the ladder can reach. */
|
|
243
|
+
| 'CONTRAST_UNREACHABLE';
|
|
244
|
+
where: string;
|
|
245
|
+
message: string;
|
|
246
|
+
}
|
|
247
|
+
export interface ThemeResult {
|
|
248
|
+
theme: ResolvedTheme;
|
|
249
|
+
diagnostics: ThemeDiagnostic[];
|
|
250
|
+
/** True when no diagnostic has severity `error`. */
|
|
251
|
+
ok: boolean;
|
|
252
|
+
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ElementType, ReactNode } from 'react';
|
|
2
|
+
import { type ActionFacts, type ActionSurface } from '../../ui-kit/primitives/index.js';
|
|
3
|
+
export interface ActionItem extends Omit<ActionFacts, 'icon'> {
|
|
4
|
+
/** Hình của việc. Nhân không vẽ hình — bên gọi đưa vào. Bắt buộc (luật ③). */
|
|
5
|
+
icon: ReactNode;
|
|
6
|
+
/** Bấm vào. Không có khi việc là một đường dẫn (`as` + `to`/`href`). */
|
|
7
|
+
onSelect?: () => void;
|
|
8
|
+
/** Việc DẪN ĐI ĐÂU ĐÓ — `Link` của bộ định tuyến, hoặc `'a'`. */
|
|
9
|
+
as?: ElementType;
|
|
10
|
+
/** Việc chính gửi một biểu mẫu thì nói ra: `type="submit"` (+ `form` nếu nằm ngoài). */
|
|
11
|
+
type?: 'button' | 'submit' | 'reset';
|
|
12
|
+
form?: string;
|
|
13
|
+
/** Khoá tự do cho thẻ mà `as` chỉ tới — `to`, `href`, `target`… */
|
|
14
|
+
[key: string]: unknown;
|
|
15
|
+
}
|
|
16
|
+
export interface ActionBarProps {
|
|
17
|
+
/** Mặt mà thanh này đứng — quyết ai đứng tại chỗ. */
|
|
18
|
+
surface: ActionSurface;
|
|
19
|
+
/** Tên của nhóm việc — cũng là tên của nút "⋯" và của menu. Chữ của app. */
|
|
20
|
+
label: string;
|
|
21
|
+
/** Hình cho nút "⋯". Bắt buộc khi có việc vào menu. */
|
|
22
|
+
moreIcon?: ReactNode;
|
|
23
|
+
/**
|
|
24
|
+
* CHỮ của nút mở menu — "Thêm". Bắt buộc khi có việc vào menu, trừ dòng bảng
|
|
25
|
+
* (dòng bảng không có chữ). NN/g: hình "⋯" tự nó không mang nghĩa — ghi chữ ra.
|
|
26
|
+
*/
|
|
27
|
+
moreLabel?: string;
|
|
28
|
+
/** Việc của mặt này. `false`/`null` bị bỏ qua, để bên gọi viết `cond && {…}`. */
|
|
29
|
+
actions: Array<ActionItem | false | null | undefined>;
|
|
30
|
+
className?: string;
|
|
31
|
+
}
|
|
32
|
+
export declare function ActionBar({ surface, label, moreIcon, moreLabel, actions, className }: ActionBarProps): import("react").JSX.Element;
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Đang đứng trong một `<ActionBar>` không — `Button` hỏi điều này trước khi
|
|
3
|
+
* chịu tô mình thành việc chính (`tier="key"`).
|
|
4
|
+
*
|
|
5
|
+
* ⚠️ Tệp riêng, vì `ActionBar` vẽ `Button` còn `Button` đọc cờ của `ActionBar`:
|
|
6
|
+
* để hai bên cùng nhập một tệp thứ ba thì không vòng nào khép lại.
|
|
7
|
+
*/
|
|
8
|
+
export declare const InActionBar: import("react").Context<boolean>;
|
|
9
|
+
export declare const useInActionBar: () => boolean;
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import type { ButtonHTMLAttributes, ElementType, ReactNode } from 'react';
|
|
2
|
+
import type { ActionTier } from '../../ui-kit/primitives/index.js';
|
|
3
|
+
interface BaseButtonProps extends Omit<ButtonHTMLAttributes<HTMLButtonElement>, 'type'> {
|
|
4
|
+
/**
|
|
5
|
+
* Bậc — bốn cái, và chúng nói VIỆC NÀY QUAN TRỌNG ĐẾN ĐÂU, không nói màu.
|
|
6
|
+
* Mặc định `normal`: một nút không khai bậc là một nút chưa ai quyết.
|
|
7
|
+
*/
|
|
8
|
+
tier?: ActionTier;
|
|
9
|
+
/**
|
|
10
|
+
* ⛔ `submit` phải NÓI RA. Xem ① ở trên.
|
|
11
|
+
*/
|
|
12
|
+
type?: 'button' | 'submit' | 'reset';
|
|
13
|
+
/** Hình đứng trước chữ. Nhân không vẽ hình — bên gọi đưa vào. */
|
|
14
|
+
icon?: ReactNode;
|
|
15
|
+
/**
|
|
16
|
+
* Đang gửi.
|
|
17
|
+
*
|
|
18
|
+
* ⚠️ Khoá nút VÀ nói ra bằng `aria-busy` — khoá không thôi thì trình đọc màn
|
|
19
|
+
* hình chỉ nghe "nút, không khả dụng", không biết vì sao và không biết
|
|
20
|
+
* bao giờ xong.
|
|
21
|
+
*/
|
|
22
|
+
busy?: boolean;
|
|
23
|
+
/** Thẻ khác — `Link` của bộ định tuyến cho một nút DẪN ĐI ĐÂU ĐÓ. */
|
|
24
|
+
as?: ElementType;
|
|
25
|
+
className?: string;
|
|
26
|
+
[key: string]: unknown;
|
|
27
|
+
}
|
|
28
|
+
/** Nút có chữ. */
|
|
29
|
+
export interface ButtonProps extends BaseButtonProps {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
label?: never;
|
|
32
|
+
}
|
|
33
|
+
/**
|
|
34
|
+
* Nút CHỈ CÓ HÌNH — và `label` là bắt buộc, không phải khuyến nghị.
|
|
35
|
+
*/
|
|
36
|
+
export interface IconButtonProps extends BaseButtonProps {
|
|
37
|
+
children?: never;
|
|
38
|
+
icon: ReactNode;
|
|
39
|
+
label: string;
|
|
40
|
+
}
|
|
41
|
+
export declare function Button(p: ButtonProps | IconButtonProps): import("react").ReactElement<any, string | import("react").JSXElementConstructor<any>>;
|
|
42
|
+
export {};
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import type { InputHTMLAttributes, ReactNode } from 'react';
|
|
2
|
+
/**
|
|
3
|
+
* YES/NO, AND ONE-OF-A-FEW — and the class goes on the LABEL, not the box.
|
|
4
|
+
*
|
|
5
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
6
|
+
* ⛔ WHY THE WRAPPER, MEASURED RATHER THAN ARGUED
|
|
7
|
+
*
|
|
8
|
+
* The kit's rule carries its own reason: *"a checkbox is a few pixels of ink
|
|
9
|
+
* inside a full-size target — shrinking the target to match the ink is the
|
|
10
|
+
* commonest tap failure in a form."* The geometry it emits says the same —
|
|
11
|
+
* `inline-flex`, a `gap` between the ink and its words, `min-height` — all of
|
|
12
|
+
* which describe a LABEL holding a box and a sentence, not a bare box.
|
|
13
|
+
*
|
|
14
|
+
* Both placements were rendered against the emitted stylesheet and measured:
|
|
15
|
+
*
|
|
16
|
+
* class on <label> geometry right · checked colour DEAD
|
|
17
|
+
* class on <input> colour right · words fall to the next line
|
|
18
|
+
*
|
|
19
|
+
* Neither half worked, because the kit's states were written for the input
|
|
20
|
+
* while its geometry was written for the wrapper. The kit has been fixed to
|
|
21
|
+
* say what `pick` already said — `:has(:checked)` — and this component takes
|
|
22
|
+
* the placement the geometry demands.
|
|
23
|
+
*
|
|
24
|
+
* ⚠️ Requires `@dqa-ai-solutions/ui-kit` ≥ 0.27.0. On 0.26.0 the box still works and the
|
|
25
|
+
* selected colour silently does not.
|
|
26
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
27
|
+
*/
|
|
28
|
+
interface ChoiceProps extends Omit<InputHTMLAttributes<HTMLInputElement>, 'type'> {
|
|
29
|
+
/** The words beside the ink. A choice with no words is a choice nobody can read. */
|
|
30
|
+
children?: ReactNode;
|
|
31
|
+
/** Class for the LABEL — the target. Style the box through the kit, not here. */
|
|
32
|
+
className?: string;
|
|
33
|
+
}
|
|
34
|
+
export declare const Check: ({ children, className, ...rest }: ChoiceProps) => import("react").DetailedReactHTMLElement<{
|
|
35
|
+
className: string | undefined;
|
|
36
|
+
}, HTMLElement>;
|
|
37
|
+
export declare const Radio: ({ children, className, ...rest }: ChoiceProps) => import("react").DetailedReactHTMLElement<{
|
|
38
|
+
className: string | undefined;
|
|
39
|
+
}, HTMLElement>;
|
|
40
|
+
export type { ChoiceProps };
|