@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.
- package/README.md +49 -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/component-css.d.ts +10 -0
- package/dist/_types/ui-kit/primitives/index.d.ts +5 -0
- package/dist/_types/ui-kit/primitives/spec.d.ts +102 -0
- package/dist/_types/ui-kit/primitives/state.d.ts +148 -0
- package/dist/_types/ui-kit/primitives/stylesheet.d.ts +37 -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/emit.d.ts +70 -0
- package/dist/_types/ui-kit/tokens/index.d.ts +6 -0
- package/dist/_types/ui-kit/tokens/oklch.d.ts +53 -0
- package/dist/_types/ui-kit/tokens/resolve.d.ts +4 -0
- package/dist/_types/ui-kit/tokens/scales.d.ts +325 -0
- package/dist/_types/ui-kit/tokens/theme.dqa.d.ts +2 -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-5NTG4J62.js +11 -0
- package/dist/chunks/chunk-66DQVLFK.js +5 -0
- package/dist/chunks/chunk-7WHYHIUX.js +1 -0
- package/dist/chunks/chunk-JOIDPECM.js +3 -0
- package/dist/chunks/chunk-MS2W22ER.js +3 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/kit.css +2291 -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 +61 -4
|
@@ -0,0 +1,325 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Chroma of each grey rung, as a multiple of `tint`.
|
|
3
|
+
*
|
|
4
|
+
* ⭐ One number would have been tidier and wrong. The shipped palette tints its
|
|
5
|
+
* ink seven times harder than its page ground (0.021 vs 0.003), and it is
|
|
6
|
+
* right to: a near-black at zero chroma reads as a different material from
|
|
7
|
+
* the surface it sits on, while the same tint on a near-white is invisible.
|
|
8
|
+
*/
|
|
9
|
+
export declare const GREY_TINT: {
|
|
10
|
+
readonly light: {
|
|
11
|
+
readonly bg: 1;
|
|
12
|
+
/** White, by definition. Tinting it makes it a colour, not a ground. */
|
|
13
|
+
readonly surface: 0;
|
|
14
|
+
readonly 'surface-2': 0.6;
|
|
15
|
+
readonly ink: 7;
|
|
16
|
+
readonly 'ink-2': 8;
|
|
17
|
+
readonly 'ink-3': 10;
|
|
18
|
+
readonly line: 2.5;
|
|
19
|
+
readonly 'line-2': 2;
|
|
20
|
+
};
|
|
21
|
+
/**
|
|
22
|
+
* ⛔ NOT the light table, and getting this wrong shipped twice in one session.
|
|
23
|
+
*
|
|
24
|
+
* ① `surface: 0` is a statement about WHITE. In dark the card ground is a
|
|
25
|
+
* grey, so zero tint left it flatly neutral while the page around it went
|
|
26
|
+
* navy — one panel visibly not belonging to the app.
|
|
27
|
+
* ② The ink multipliers invert. Near black there is room for chroma; near
|
|
28
|
+
* white there is almost none, so carrying 7× tint onto a near-white ink
|
|
29
|
+
* ran out of sRGB and came back clipped on every build.
|
|
30
|
+
*
|
|
31
|
+
* A single table read as one decision. It is two.
|
|
32
|
+
*/
|
|
33
|
+
readonly dark: {
|
|
34
|
+
readonly bg: 1;
|
|
35
|
+
readonly surface: 1.1;
|
|
36
|
+
readonly 'surface-2': 1.05;
|
|
37
|
+
readonly ink: 1.2;
|
|
38
|
+
readonly 'ink-2': 2;
|
|
39
|
+
readonly 'ink-3': 2.6;
|
|
40
|
+
readonly line: 1.8;
|
|
41
|
+
readonly 'line-2': 1.6;
|
|
42
|
+
};
|
|
43
|
+
};
|
|
44
|
+
export declare const LADDER: {
|
|
45
|
+
readonly light: {
|
|
46
|
+
readonly bg: 0.973;
|
|
47
|
+
readonly surface: 1;
|
|
48
|
+
readonly 'surface-2': 0.988;
|
|
49
|
+
readonly ink: 0.239;
|
|
50
|
+
readonly 'ink-2': 0.477;
|
|
51
|
+
/**
|
|
52
|
+
* ⛔ 0.545, NOT the shipped 0.555 — and this one is the whole argument for
|
|
53
|
+
* checking by machine.
|
|
54
|
+
*
|
|
55
|
+
* `tokens.css` says of its own `--fos-ink-3`: *"≥4.5:1 trên nền trắng"*.
|
|
56
|
+
* True, and beside the point: the page ground is `--fos-bg`, not white, and
|
|
57
|
+
* against that the shipped value is 4.40:1. A careful human checked the
|
|
58
|
+
* wrong pair once and it has shipped ever since.
|
|
59
|
+
*/
|
|
60
|
+
readonly 'ink-3': 0.545;
|
|
61
|
+
readonly line: 0.924;
|
|
62
|
+
readonly 'line-2': 0.955;
|
|
63
|
+
/** Where the app's own colour sits so a white label clears AA on it. */
|
|
64
|
+
readonly accent: 0.428;
|
|
65
|
+
readonly accentBg: 0.946;
|
|
66
|
+
/**
|
|
67
|
+
* ⛔ 0.515, NOT the 0.545 the shipped inks average to — and the guard is why.
|
|
68
|
+
*
|
|
69
|
+
* Measured on the palette this replaces: the `warn` chip is 4.10:1 and the
|
|
70
|
+
* `muted` chip 2.84:1 against their own grounds. Both ship today. A badge
|
|
71
|
+
* is the one place a user reads a single word and acts on it, so the rung
|
|
72
|
+
* sits where the worst tone (`done`, at this ground) still clears 4.5:1.
|
|
73
|
+
*/
|
|
74
|
+
readonly toneInk: 0.515;
|
|
75
|
+
readonly toneGround: 0.952;
|
|
76
|
+
};
|
|
77
|
+
/**
|
|
78
|
+
* ⭐ Dark is a DECLARATION here, not a second palette.
|
|
79
|
+
*
|
|
80
|
+
* `tokens.css` records the debt honestly: *"CHƯA đưa dark-mode vào đây…
|
|
81
|
+
* Nhập chung ngay bây giờ là bật dark-mode cho một app chưa từng thiết kế
|
|
82
|
+
* cho nó."* That reasoning was right about the risk and is now cheap to
|
|
83
|
+
* satisfy — the rungs exist, nothing switches until an app asks.
|
|
84
|
+
*
|
|
85
|
+
* LIGHTNESS is anchored on the admin shell ground that already ships
|
|
86
|
+
* (`#08213f`, L 0.247, H 255) so a dark theme reads as the same product.
|
|
87
|
+
*
|
|
88
|
+
* ⚠️ Its CHROMA is not, and cannot be: colourfulness comes from `tint`, and
|
|
89
|
+
* at the default 0.003 the dark grounds land near-neutral rather than the
|
|
90
|
+
* cobalt navy of that shell. An app wanting the navy declares
|
|
91
|
+
* `tint: 0.02`. Baking it in here would make every dark theme on the
|
|
92
|
+
* kernel navy, which is the app's taste smuggled into the engine.
|
|
93
|
+
*/
|
|
94
|
+
readonly dark: {
|
|
95
|
+
readonly bg: 0.2;
|
|
96
|
+
readonly surface: 0.247;
|
|
97
|
+
readonly 'surface-2': 0.224;
|
|
98
|
+
readonly ink: 0.96;
|
|
99
|
+
readonly 'ink-2': 0.8;
|
|
100
|
+
readonly 'ink-3': 0.7;
|
|
101
|
+
readonly line: 0.33;
|
|
102
|
+
readonly 'line-2': 0.285;
|
|
103
|
+
readonly accent: 0.68;
|
|
104
|
+
readonly accentBg: 0.3;
|
|
105
|
+
readonly toneInk: 0.82;
|
|
106
|
+
readonly toneGround: 0.31;
|
|
107
|
+
};
|
|
108
|
+
};
|
|
109
|
+
/**
|
|
110
|
+
* The six weights a state can carry, and the DQA default hue for each.
|
|
111
|
+
*
|
|
112
|
+
* ⚠️ `wait` has no colour in the shipped palette — there are five states there
|
|
113
|
+
* and the ontology vocabulary has six. A tone with nowhere to go is a badge
|
|
114
|
+
* that silently renders as `plain`, which is the failure this package exists
|
|
115
|
+
* to remove, so it gets a hue here.
|
|
116
|
+
*/
|
|
117
|
+
export declare const TONE_HUE: Record<string, {
|
|
118
|
+
hue: number;
|
|
119
|
+
chroma: number;
|
|
120
|
+
}>;
|
|
121
|
+
/** Legacy name each tone also publishes, so the shipped stylesheets keep working. */
|
|
122
|
+
export declare const TONE_ALIAS: Record<string, string>;
|
|
123
|
+
/**
|
|
124
|
+
* Spacing, 4px base. Density scales SPACING ONLY.
|
|
125
|
+
*
|
|
126
|
+
* ⚠️ Never type size, never hit targets. A compact theme is a tighter layout,
|
|
127
|
+
* not a smaller word or a harder button to hit — shrinking those is how
|
|
128
|
+
* "dense" becomes "unusable", and it is the failure mode of every tool that
|
|
129
|
+
* ships a density switch.
|
|
130
|
+
*/
|
|
131
|
+
export declare const SPACE: Record<'compact' | 'cosy' | 'roomy', Record<string, number>>;
|
|
132
|
+
/**
|
|
133
|
+
* A table row, per density — height and cell padding.
|
|
134
|
+
*
|
|
135
|
+
* ⛔ ADDED AFTER `density` WAS FOUND TOO NARROW TO DO ITS JOB.
|
|
136
|
+
*
|
|
137
|
+
* The comment above says density scales spacing and nothing else. That was
|
|
138
|
+
* right about type size and hit targets, and WRONG about a table row: a row's
|
|
139
|
+
* height and its cell padding ARE spacing, and leaving them out meant the one
|
|
140
|
+
* surface where density matters most had no density.
|
|
141
|
+
*
|
|
142
|
+
* Measured on the first app to adopt: cell padding was 8px, 9px and 10px
|
|
143
|
+
* depending on which table you were looking at — three answers to a question
|
|
144
|
+
* the theme was supposed to have settled.
|
|
145
|
+
*
|
|
146
|
+
* ⭐ This is what makes a "comfortable / compact" switch a package feature
|
|
147
|
+
* instead of something each app invents. An officer working a grid all day
|
|
148
|
+
* needs compact; someone opening it weekly needs comfortable.
|
|
149
|
+
*/
|
|
150
|
+
export declare const ROW: Record<'compact' | 'cosy' | 'roomy', {
|
|
151
|
+
h: number;
|
|
152
|
+
padX: number;
|
|
153
|
+
padY: number;
|
|
154
|
+
}>;
|
|
155
|
+
/**
|
|
156
|
+
* How TALL a control is drawn — separate from how big its TARGET is.
|
|
157
|
+
*
|
|
158
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
159
|
+
* ⭐ TWO NUMBERS, BECAUSE THEY ANSWER TWO QUESTIONS
|
|
160
|
+
*
|
|
161
|
+
* The first cut drew every control at the full 44px target, and it read as
|
|
162
|
+
* heavy — correct by the letter of the guideline and wrong for a keyboard-led
|
|
163
|
+
* admin product, where a row of 44px buttons pushes the work down the page.
|
|
164
|
+
*
|
|
165
|
+
* The fix is NOT to shrink the target. It is to notice that "how tall does
|
|
166
|
+
* this look" and "how big an area must a finger hit" were never the same
|
|
167
|
+
* question, and the earlier version answered both with one number.
|
|
168
|
+
*
|
|
169
|
+
* So a control is drawn at `CONTROL[density]`, and on a coarse pointer its
|
|
170
|
+
* hit area is expanded back out to `TOUCH_TARGET` with a transparent
|
|
171
|
+
* ::after — the finger keeps its 44px, the eye gets a 36px button, and
|
|
172
|
+
* nothing was traded away.
|
|
173
|
+
*
|
|
174
|
+
* ⛔ 24px IS THE FLOOR AND IS NOT A STYLE CHOICE. WCAG 2.2 §2.5.8 sets it at
|
|
175
|
+
* AA; `compact` sits at 30 and there is deliberately no density below it.
|
|
176
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
177
|
+
*/
|
|
178
|
+
export declare const CONTROL: Record<'compact' | 'cosy' | 'roomy', number>;
|
|
179
|
+
/** WCAG 2.2 §2.5.8 (AA). Nothing drawn may go under it. */
|
|
180
|
+
export declare const TARGET_FLOOR = 24;
|
|
181
|
+
/**
|
|
182
|
+
* Minimum interactive target, and it does NOT follow density.
|
|
183
|
+
*
|
|
184
|
+
* ⚠️ WCAG 2.2 sets a floor because a finger does not get smaller when a layout
|
|
185
|
+
* gets tighter. An app that runs on tablets in the field — the case that
|
|
186
|
+
* prompted this — cannot trade hit area for rows on screen. `compact` moves
|
|
187
|
+
* the rows closer together; it never shrinks the thing being pressed.
|
|
188
|
+
*/
|
|
189
|
+
export declare const TOUCH_TARGET = 44;
|
|
190
|
+
/** What each step is for. Read this before reaching for a number in between. */
|
|
191
|
+
export declare const SPACE_PURPOSE: Record<string, string>;
|
|
192
|
+
/**
|
|
193
|
+
* Type. Sizes are the ones already shipping; the other three numbers are new.
|
|
194
|
+
*
|
|
195
|
+
* ⛔ Size alone is not a typographic decision, and shipping it alone is why a
|
|
196
|
+
* "type scale" still needs a designer at every use. A 28px heading tracked
|
|
197
|
+
* like body text reads loose; tracking has to tighten as size grows.
|
|
198
|
+
*/
|
|
199
|
+
/**
|
|
200
|
+
* Type — a LADDER around the body size, not a table of pixels.
|
|
201
|
+
*
|
|
202
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
203
|
+
* ⛔ WHY IT STOPPED BEING A TABLE
|
|
204
|
+
*
|
|
205
|
+
* The fixed table had ONE step below 14px. An application built for dense
|
|
206
|
+
* data grids had three, and they were carrying three different jobs: the
|
|
207
|
+
* smallest label, secondary text and column heads, and dense table body.
|
|
208
|
+
* Joining that table would have collapsed two of the three.
|
|
209
|
+
*
|
|
210
|
+
* And it could not simply raise everything, because that application had
|
|
211
|
+
* ruled — on paper, with a reason — that its body text stays at 15px: field
|
|
212
|
+
* officers read accented Vietnamese on low-end machines in poor light. The
|
|
213
|
+
* nearest step above 14 was 20. Joining meant body text growing 15 → 20 on
|
|
214
|
+
* 126 screens.
|
|
215
|
+
*
|
|
216
|
+
* ⭐ So the app declares the ONE number it actually has a reason for — the body
|
|
217
|
+
* size — and the ladder is computed around it. `base: 14` reproduces the old
|
|
218
|
+
* table exactly, so nothing already shipping moves.
|
|
219
|
+
*
|
|
220
|
+
* ⚠️ THIS IS THE UI LADDER AND NOTHING ELSE. Print sheets are laid out in `pt`
|
|
221
|
+
* against a paper standard; a screen's body size has no business reaching
|
|
222
|
+
* them. Same restraint as `density`, which scales spacing and never touches
|
|
223
|
+
* hit targets.
|
|
224
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
225
|
+
*/
|
|
226
|
+
export declare const TEXT_RATIO: Record<string, {
|
|
227
|
+
r: number;
|
|
228
|
+
line: number;
|
|
229
|
+
weight: number;
|
|
230
|
+
tracking: number;
|
|
231
|
+
}>;
|
|
232
|
+
/** Body size when the app does not say. Reproduces the table that shipped. */
|
|
233
|
+
export declare const TEXT_BASE = 14;
|
|
234
|
+
export declare const textScale: (base?: number) => Record<string, {
|
|
235
|
+
size: number;
|
|
236
|
+
line: number;
|
|
237
|
+
weight: number;
|
|
238
|
+
tracking: number;
|
|
239
|
+
}>;
|
|
240
|
+
/** @deprecated The fixed table. `textScale()` replaces it; kept for 0.4.x callers. */
|
|
241
|
+
export declare const TEXT: Record<string, {
|
|
242
|
+
size: number;
|
|
243
|
+
line: number;
|
|
244
|
+
weight: number;
|
|
245
|
+
tracking: number;
|
|
246
|
+
}>;
|
|
247
|
+
export declare const RADIUS: Record<'sharp' | 'soft' | 'round', Record<string, number>>;
|
|
248
|
+
export declare const RADIUS_PURPOSE: Record<string, string>;
|
|
249
|
+
/**
|
|
250
|
+
* Shadow, motion and fonts pass through unchanged.
|
|
251
|
+
*
|
|
252
|
+
* ⚠️ Not computed, and deliberately not: a shadow is a statement about a light
|
|
253
|
+
* source, and there is no ladder to derive it from. They stay as the shipped
|
|
254
|
+
* values so nothing moves under the two apps already using them.
|
|
255
|
+
*/
|
|
256
|
+
export declare const STATIC: {
|
|
257
|
+
readonly 'sh-1': "0 1px 2px rgba(19, 23, 34, .04)";
|
|
258
|
+
readonly 'sh-2': "0 1px 3px rgba(19, 23, 34, .07), 0 1px 2px rgba(19, 23, 34, .04)";
|
|
259
|
+
readonly 'sh-3': "0 12px 28px -10px rgba(19, 23, 34, .16)";
|
|
260
|
+
readonly 'dur-fast': "120ms";
|
|
261
|
+
readonly 'dur-base': "180ms";
|
|
262
|
+
readonly 'ease-out': "cubic-bezier(0.16, 1, 0.3, 1)";
|
|
263
|
+
readonly 'ease-standard': "cubic-bezier(0.4, 0, 0.2, 1)";
|
|
264
|
+
};
|
|
265
|
+
export declare const FONT: {
|
|
266
|
+
sans: string;
|
|
267
|
+
mono: string;
|
|
268
|
+
};
|
|
269
|
+
/**
|
|
270
|
+
* Chart colour — and the one rule that matters more than the palette.
|
|
271
|
+
*
|
|
272
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
273
|
+
* ⛔ NEVER SEPARATE TWO SERIES BY HUE ALONE.
|
|
274
|
+
*
|
|
275
|
+
* Roughly one man in twelve cannot reliably tell red from green. A palette
|
|
276
|
+
* that walks the hue wheel at constant lightness looks varied to the person
|
|
277
|
+
* who picked it and collapses into one grey band for that reader — and the
|
|
278
|
+
* chart is not merely uglier, it is unreadable, with nothing on screen saying
|
|
279
|
+
* so.
|
|
280
|
+
*
|
|
281
|
+
* So the series ladder ALTERNATES LIGHTNESS as it rotates hue. Adjacent
|
|
282
|
+
* series then differ twice over, and the second difference survives when the
|
|
283
|
+
* first one does not. `SERIES_INDISTINCT` measures it rather than trusting it.
|
|
284
|
+
*
|
|
285
|
+
* ⚠️ And the honest limit: past eight categories no palette helps, because the
|
|
286
|
+
* reader is matching swatches to a legend rather than reading a chart. Nine
|
|
287
|
+
* is a `SERIES_TOO_MANY` — a chart problem wearing a colour problem's clothes.
|
|
288
|
+
* ═══════════════════════════════════════════════════════════════════════════
|
|
289
|
+
*/
|
|
290
|
+
export declare const SERIES: {
|
|
291
|
+
readonly light: {
|
|
292
|
+
readonly lo: 0.52;
|
|
293
|
+
readonly hi: 0.68;
|
|
294
|
+
readonly chroma: 0.15;
|
|
295
|
+
};
|
|
296
|
+
readonly dark: {
|
|
297
|
+
readonly lo: 0.62;
|
|
298
|
+
readonly hi: 0.78;
|
|
299
|
+
readonly chroma: 0.13;
|
|
300
|
+
};
|
|
301
|
+
};
|
|
302
|
+
/** Beyond this a legend is doing the work, not the colour. */
|
|
303
|
+
export declare const SERIES_MAX = 8;
|
|
304
|
+
/** Adjacent series must differ in lightness by at least this, hue aside. */
|
|
305
|
+
export declare const SERIES_MIN_LIGHTNESS_GAP = 0.1;
|
|
306
|
+
/**
|
|
307
|
+
* An ordered scale — low to high — for a measure, not for categories.
|
|
308
|
+
*
|
|
309
|
+
* ⚠️ ONE HUE, stepped lightness. A rainbow scale reorders itself in the reader's
|
|
310
|
+
* head (is yellow more than blue?) and is the single most common way a
|
|
311
|
+
* quantity chart lies. Lightness has an obvious direction and keeps it in
|
|
312
|
+
* greyscale, in a photocopy, and for every kind of colour vision.
|
|
313
|
+
*/
|
|
314
|
+
export declare const LEVELS: {
|
|
315
|
+
readonly light: {
|
|
316
|
+
readonly from: 0.93;
|
|
317
|
+
readonly to: 0.45;
|
|
318
|
+
readonly chroma: 0.11;
|
|
319
|
+
};
|
|
320
|
+
readonly dark: {
|
|
321
|
+
readonly from: 0.3;
|
|
322
|
+
readonly to: 0.85;
|
|
323
|
+
readonly chroma: 0.1;
|
|
324
|
+
};
|
|
325
|
+
};
|
|
@@ -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 {};
|