@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,38 @@
1
+ import type { ResolvedAction, ViewContract } from '@dqa-ai-solutions/core-runtime/view';
2
+ export type Presentation = {
3
+ readonly surface: 'none';
4
+ } | {
5
+ readonly surface: 'action';
6
+ /** What the person must see before acting — empty means nothing beyond the record. */
7
+ readonly review: readonly string[];
8
+ readonly input: 'none' | 'fields' | 'document';
9
+ /** Fields the person types · fields the software proposes and the person confirms. */
10
+ readonly typed: readonly string[];
11
+ readonly suggested: readonly string[];
12
+ readonly over: 'single' | 'records' | {
13
+ readonly rows: string;
14
+ };
15
+ };
16
+ export type Determined<T> = {
17
+ readonly determined: true;
18
+ readonly value: T;
19
+ } | {
20
+ readonly determined: false;
21
+ readonly why: string;
22
+ };
23
+ export declare function presentationOf(action: ResolvedAction): Determined<Presentation>;
24
+ /**
25
+ * Who else may see a record at a state, on one line — REAL role codes.
26
+ *
27
+ * ⚠️ Intent, not enforcement. Row-level security in the host's store decides what a person can
28
+ * actually read; this says what the screen should show a reader who is not acting.
29
+ */
30
+ export declare function readersOf(contract: ViewContract, process: string, state: string): Determined<readonly string[]>;
31
+ /**
32
+ * Every step and state of a contract the selector could not decide — the coverage question a
33
+ * build can ask before anyone opens a screen. Empty means every step has exactly one pattern.
34
+ */
35
+ export declare function undeterminedIn(contract: ViewContract): {
36
+ at: string;
37
+ why: string;
38
+ }[];
@@ -0,0 +1,30 @@
1
+ import type { ViewContract } from '@dqa-ai-solutions/core-runtime/view';
2
+ import { type SurfaceState, type EmptyCopy, type Fault } from '../primitives/index.js';
3
+ import { type Cell, type CellContext } from './cell.js';
4
+ import type { LensDiagnostic } from './diagnostic.js';
5
+ export interface QueueItem {
6
+ id: string;
7
+ entity: string;
8
+ main: Cell;
9
+ sub: Cell | null;
10
+ badge: Cell | null;
11
+ }
12
+ export interface QueueInput {
13
+ /** A queue mixes entities, so contracts arrive keyed by entity name. */
14
+ contracts: Record<string, ViewContract>;
15
+ items: {
16
+ entity: string;
17
+ record: Record<string, unknown>;
18
+ }[] | null;
19
+ loading: boolean;
20
+ error?: string | null;
21
+ forbidden?: string | false;
22
+ narrowed?: boolean;
23
+ empty: EmptyCopy;
24
+ }
25
+ export interface QueueModel {
26
+ state: SurfaceState<QueueItem[]>;
27
+ diagnostics: LensDiagnostic[];
28
+ faults: Fault[];
29
+ }
30
+ export declare function queueModel(input: QueueInput, ctx: CellContext): QueueModel;
@@ -0,0 +1,110 @@
1
+ import type { ViewContract, ResolvedField } from '@dqa-ai-solutions/core-runtime/view';
2
+ import { type SurfaceState, type EmptyCopy, type Fault, type ActionView } from '../primitives/index.js';
3
+ import { type Cell, type CellContext } from './cell.js';
4
+ import { type ActionHints } from './action.js';
5
+ import type { LensDiagnostic } from './diagnostic.js';
6
+ export interface RecordSection {
7
+ name: string;
8
+ label?: string;
9
+ /** Which tab this belongs on. Omitted, it sits on the first tab. */
10
+ tab?: string;
11
+ /** Property names, from those the contract carries. */
12
+ facts?: string[];
13
+ /** A named component instead of facts. The two are exclusive. */
14
+ block?: string;
15
+ /** Visible only while the record is in one of these states. */
16
+ when?: string[];
17
+ }
18
+ export interface RecordLayout {
19
+ /** Optional — see the header. Without it, one section holding every fact. */
20
+ sections?: RecordSection[];
21
+ tabs?: {
22
+ name: string;
23
+ label: string;
24
+ }[];
25
+ }
26
+ export type RecordPart = {
27
+ kind: 'facts';
28
+ name: string;
29
+ label?: string;
30
+ facts: {
31
+ field: ResolvedField;
32
+ cell: Cell;
33
+ }[];
34
+ }
35
+ /**
36
+ * The records hanging off this one — most of a record page.
37
+ *
38
+ * ⚠️ Rows arrive from the app under `related[name]`; this package never
39
+ * queries. Absent rows are reported, never drawn as an empty table: a
40
+ * section that silently shows nothing looks identical to one that has
41
+ * nothing to show.
42
+ */
43
+ | {
44
+ kind: 'related';
45
+ name: string;
46
+ label: string;
47
+ entity: string;
48
+ columns: ResolvedField[];
49
+ rows: {
50
+ id: string;
51
+ cells: Cell[];
52
+ }[];
53
+ rowHeaderKey: string | null;
54
+ } | {
55
+ kind: 'block';
56
+ name: string;
57
+ label?: string;
58
+ widget: string;
59
+ } | {
60
+ kind: 'missing-block';
61
+ name: string;
62
+ widget: string;
63
+ message: string;
64
+ };
65
+ export interface RecordTab {
66
+ name: string;
67
+ label: string;
68
+ parts: RecordPart[];
69
+ }
70
+ export interface RecordBody {
71
+ /** What this record is CALLED to a person. */
72
+ title: string | null;
73
+ /** The state badge, with the weight the ontology gave it. */
74
+ badge: Cell | null;
75
+ /** One clause saying what the current state MEANS operationally. */
76
+ hint?: string;
77
+ /**
78
+ * The state the record is IN, as the ontology spells it.
79
+ *
80
+ * ⭐ Load-bearing inside this model already — it filters sections, related
81
+ * rows and available actions — and it was invisible on the way out, so a
82
+ * renderer wanting to draw it had to re-derive it from the record. That is
83
+ * the same shape as an app hand-writing `subjectOf`: the contract knows,
84
+ * and the package did not hand it over.
85
+ *
86
+ * ⚠️ The raw name, not wording. `badge` carries what a person reads.
87
+ */
88
+ state: string | null;
89
+ tabs: RecordTab[];
90
+ actions: ActionView[];
91
+ }
92
+ export interface RecordInput {
93
+ contract: ViewContract;
94
+ record: Record<string, unknown> | null;
95
+ loading: boolean;
96
+ error?: string | null;
97
+ forbidden?: string | false;
98
+ layout?: RecordLayout;
99
+ hints?: ActionHints;
100
+ /** Rows for each declared related list, keyed by its `name`. */
101
+ related?: Record<string, Record<string, unknown>[]>;
102
+ /** Shown when the id resolves to nothing. */
103
+ empty: EmptyCopy;
104
+ }
105
+ export interface RecordModel {
106
+ state: SurfaceState<RecordBody>;
107
+ diagnostics: LensDiagnostic[];
108
+ faults: Fault[];
109
+ }
110
+ export declare function recordModel(input: RecordInput, ctx: CellContext): RecordModel;
@@ -0,0 +1,9 @@
1
+ export interface BlockRegistry {
2
+ /** True when the renderer can draw a block by this name. */
3
+ has(name: string): boolean;
4
+ /** Every name, for diagnostics that need to suggest one. */
5
+ names(): string[];
6
+ }
7
+ export declare const registryOf: (names: readonly string[]) => BlockRegistry;
8
+ /** A registry that accepts nothing — the correct default for a print renderer. */
9
+ export declare const NO_BLOCKS: BlockRegistry;
@@ -0,0 +1,27 @@
1
+ /** The read layer never produced this key — not a value, a wiring fault. */
2
+ export declare const ABSENT: unique symbol;
3
+ /**
4
+ * One property of one record, wherever the store chose to put it.
5
+ *
6
+ * ⚠️ THE ENVELOPE WINS A COLLISION, deliberately. It holds the ontology's own
7
+ * properties; a store column that happens to share a name is the one that
8
+ * should give way — otherwise a soft-delete flag called `status` quietly
9
+ * replaces the workflow state called `status`.
10
+ */
11
+ export declare function readValue(row: Record<string, unknown>, key: string): unknown | typeof ABSENT;
12
+ /**
13
+ * The record flattened: envelope over top-level, in one object.
14
+ *
15
+ * ⭐ FOR THE CALLER READING SEVERAL FIELDS AT ONCE, which is what every copy of
16
+ * `x.data ?? x` in the wild was actually doing — a filter testing three
17
+ * properties of a signed decision, a row builder reading four columns.
18
+ * Offering only `readValue` would have left those sites writing the merge
19
+ * themselves, which is the thing being removed.
20
+ *
21
+ * ⚠️ `data` itself is dropped from the result. A flattened view with a nested
22
+ * `data` key still in it invites exactly the two-shape confusion this exists
23
+ * to end.
24
+ *
25
+ * ⚠️ Same collision rule as `readValue`: the envelope wins.
26
+ */
27
+ export declare function fieldsOf(row: Record<string, unknown>): Record<string, unknown>;
@@ -0,0 +1,36 @@
1
+ import { type SurfaceState, type EmptyCopy } from '../primitives/index.js';
2
+ import type { Formatter } from './format.js';
3
+ import type { LensDiagnostic } from './diagnostic.js';
4
+ /** `"<entity>.<event>" → the sentence a person reads.` */
5
+ export type EventVocabulary = Record<string, string>;
6
+ export interface RawEvent {
7
+ /** `staffMember.selected` — machine name, never shown. */
8
+ event: string;
9
+ at: string;
10
+ actor?: string;
11
+ /** Anything the renderer may want; the lens does not read it. */
12
+ detail?: Record<string, unknown>;
13
+ }
14
+ export interface TimelineEntry {
15
+ event: string;
16
+ label: string;
17
+ at: string;
18
+ /** Written with the app's locale — never a raw ISO stamp. */
19
+ when: string;
20
+ actor?: string;
21
+ detail?: Record<string, unknown>;
22
+ /** True when no wording existed and the machine name is standing in. */
23
+ unlabelled: boolean;
24
+ }
25
+ export interface TimelineInput {
26
+ events: RawEvent[] | null;
27
+ vocabulary: EventVocabulary;
28
+ loading: boolean;
29
+ error?: string | null;
30
+ empty: EmptyCopy;
31
+ }
32
+ export interface TimelineModel {
33
+ state: SurfaceState<TimelineEntry[]>;
34
+ diagnostics: LensDiagnostic[];
35
+ }
36
+ export declare function timelineModel(input: TimelineInput, format: Formatter): TimelineModel;
@@ -0,0 +1,263 @@
1
+ /** Four, because measurement found the app really had two and needed four. */
2
+ export type ActionTier = 'key' | 'normal' | 'quiet' | 'danger';
3
+ /**
4
+ * What the action does. Every field is a fact the workflow already states —
5
+ * `to`, `decision.outcome` — not a presentation choice someone makes here.
6
+ */
7
+ export interface ActionFacts {
8
+ key: string;
9
+ label: string;
10
+ /** The step has a `to`: it moves the record onward. */
11
+ advances?: boolean;
12
+ /** A decision step's verdict. */
13
+ outcome?: 'approve' | 'reject';
14
+ /** Leaves the surface without writing anything — cancel, close, back. */
15
+ exits?: boolean;
16
+ /** Irreversible, or removes a record from the roll. */
17
+ destroys?: boolean;
18
+ /**
19
+ * THIS is the one action the surface exists for — said out loud.
20
+ *
21
+ * ⭐ Only needed when the facts above leave it open: two steps that both
22
+ * advance, and no `decision.outcome` to tell them apart. The user ruled on
23
+ * 26/9/2026 that a flat screen is not an answer: *"trên 1 màn hình luôn
24
+ * phải define button nào là chính, button còn lại nằm trong …"* — so where
25
+ * the workflow cannot decide, the screen's author decides, here.
26
+ *
27
+ * ⛔ At most one per surface. Two `primary` is the same non-answer as none.
28
+ */
29
+ primary?: boolean;
30
+ /**
31
+ * Icon the renderer resolves. ⛔ NOT optional in practice — see `actionBar`.
32
+ *
33
+ * The package cannot ship icons: they are an application's own drawings. What
34
+ * it can do is refuse to pretend a button without one is finished.
35
+ */
36
+ icon?: string;
37
+ busy?: boolean;
38
+ disabled?: DisabledReason | false;
39
+ /**
40
+ * What this step still lacks a basis for.
41
+ *
42
+ * ⭐ Not a defect and not a reason to disable — the step is takeable, and
43
+ * somebody decided it should be. It is a caveat the person pressing the
44
+ * button deserves to read, and it travels with the button rather than
45
+ * sitting in a YAML file nobody opens.
46
+ */
47
+ provisional?: string;
48
+ }
49
+ /**
50
+ * ⛔ A CONTROL MAY NOT BE DISABLED WITHOUT SAYING WHY.
51
+ *
52
+ * There is deliberately no `disabled: true`. A greyed-out button with no
53
+ * explanation is the worst thing a workflow app can show: the user's job is
54
+ * right there, it will not respond, and nothing on screen says whether they
55
+ * are too early, lack the role, or are looking at a bug. They ask a colleague,
56
+ * and the colleague does not know either.
57
+ */
58
+ export interface DisabledReason {
59
+ because: string;
60
+ /** What would make it available — a state to reach, a role to hold. */
61
+ hint?: string;
62
+ }
63
+ /**
64
+ * What a renderer receives.
65
+ *
66
+ * ⛔ ONE `label`, AND THERE IS NO SECOND ONE. The pattern this forbids —
67
+ * `{busy ? 'Đang ghi…' : 'Lưu quyết toán'}` — was found at 62 call sites in
68
+ * the reference app on the day after a shared busy-button component was
69
+ * built. It changes the button's width under the finger that just pressed it,
70
+ * which reads as the button moving away. `busy` is a flag; the word stays put.
71
+ */
72
+ export interface ActionView {
73
+ key: string;
74
+ /**
75
+ * ALWAYS present, even when it is not drawn.
76
+ *
77
+ * ⛔ When `showLabel` is false the label does not disappear — it becomes the
78
+ * accessible name and the tooltip. An icon-only control with no name is
79
+ * invisible to a screen reader and a guess for everyone else; the label is
80
+ * the thing that stops that, so it is never optional.
81
+ */
82
+ label: string;
83
+ tier: ActionTier;
84
+ /**
85
+ * The action this surface exists for. Its PLACE, not its paint: a primary
86
+ * that destroys (*"Đóng đợt khám"* in its own confirm dialog) is still the
87
+ * primary, but its tier stays `danger` — a solid colour on an irreversible
88
+ * step would be the one thing the eye trusts without reading.
89
+ */
90
+ primary: boolean;
91
+ icon?: string;
92
+ /**
93
+ * Draw the word, or carry it as `aria-label` + `title`.
94
+ *
95
+ * ⭐ Words everywhere except a table row, where the data owns the words and an
96
+ * action is an icon with its word as name and tooltip (see `actionBar` ④).
97
+ */
98
+ showLabel: boolean;
99
+ busy: boolean;
100
+ disabled: false | DisabledReason;
101
+ /** A caveat to show beside the button — see `ActionFacts.provisional`. */
102
+ provisional?: string;
103
+ }
104
+ /**
105
+ * Which action a surface exists for — or `null` when the facts cannot say.
106
+ *
107
+ * The ladder, in order, among the actions that do not merely leave (`exits`):
108
+ * ⓪ exactly one `primary` → that one (the author said so)
109
+ * ① exactly one `approve` decision → that one
110
+ * ② exactly one advancing step → that one (a `reject` does not count)
111
+ * ③ exactly one action at all → that one (a lone step IS the point)
112
+ * ④ otherwise → `null`, and `actionBar` reports it
113
+ *
114
+ * ⛔ CHANGED 26/9/2026. This used to end in "otherwise none — flat beats wrong".
115
+ * The user ruled the other way: every screen defines its primary, the rest
116
+ * go behind one trigger. ④ is therefore not a quiet outcome any more; it is
117
+ * `missingPrimary`, and `<ActionBar>` refuses to render it in development.
118
+ */
119
+ export declare function primaryOf(actions: ActionFacts[]): ActionFacts | null;
120
+ /**
121
+ * Resolve a surface's actions: **exactly one** primary where there is anything
122
+ * to do, and a tier for every action from what it does.
123
+ *
124
+ * ⭐ The primary is `key` — unless it destroys, then it stays `danger` (outlined,
125
+ * never filled; see `TIER_PAINT`). Nothing else is ever `key`.
126
+ */
127
+ export declare function actionViews(actions: ActionFacts[]): ActionView[];
128
+ /**
129
+ * A row of actions, arranged for the surface it stands on.
130
+ *
131
+ * ═══════════════════════════════════════════════════════════════════════════
132
+ * ⭐ EVERY RULE HAS A SCOPE — the user, 27/9/2026: *"quy tắc trên nó còn phải
133
+ * có phạm vi nữa, ví dụ là trên toàn 1 màn hình hay trên 1 thẻ, section hay
134
+ * 1 table"*.
135
+ *
136
+ * | scope | primary (`key`) | secondaries |
137
+ * |-----------------------------------------|--------------------------|-------------------|
138
+ * | SCREEN — a page, or an open dialog | EXACTLY ONE, outside cards | — |
139
+ * | BAR — `page` head, `dialog`, `form` | must hold the screen's | ② and ③ below |
140
+ * | SCOPE — `card` (a card or a section) | its OWN one, or none | ② and ③ below |
141
+ * | REPEATED — `table` row, `item` card | NEVER | ③, ④ below |
142
+ *
143
+ * A card or a section is a SCOPE of its own: its primary is the point of
144
+ * that card, and does not compete with the screen's. The user, 27/9/2026,
145
+ * shown room cards with only `normal` buttons: *"theo thiết kế của ta thì
146
+ * cái card hay section vẫn có thể có button với style primary"*.
147
+ *
148
+ * The SCREEN rule is counted across bars by `<ActionBar>` (development
149
+ * only): more than one primary among the bars that are not cards, or a
150
+ * card with work and no primary anywhere on its screen, throws. The BAR
151
+ * and REPEATED rules are decided here.
152
+ *
153
+ * ⭐ FOUR RULES — AND WHERE EACH ONE COMES FROM
154
+ *
155
+ * ① ONE PRIMARY PER SCREEN, HELD BY EMPHASIS. A page, a card, a rail, a form
156
+ * or a dialog paints exactly one action `key`; every other action is drawn
157
+ * at a lower tier. The user, 26/9/2026: *"trên 1 màn hình chỉ có 1 action
158
+ * chính"*. The same rule stands in Carbon, Material and Polaris.
159
+ *
160
+ * ② ONE SECONDARY IN SIGHT, WITH ITS WORD. One-primary is kept by EMPHASIS,
161
+ * not by hiding everything else. Beside the primary stands ONE secondary
162
+ * action, drawn at its own lower tier. The screen's author decides which
163
+ * one by the order of the actions.
164
+ *
165
+ * ⛔ CHANGED 27/9/2026. From 26/9 to 27/9 the rule was "the rest go behind
166
+ * ⋯". Room cards ended up showing only a "⋯" that held "Mở hàng chờ"
167
+ * and "Rời phòng", and the card with a result being entered hid "Lưu".
168
+ * The user: *"chỗ hiển thị button và ... thực sự có vấn đề thật"*, and
169
+ * asked what the rest of the world has proven:
170
+ * · NN/g, contextual menus: menus hold SECONDARY, non-critical
171
+ * actions only, and "do not use contextual menus when there are
172
+ * only one or two possible actions", because hiding them "saves
173
+ * no space, increases effort, and reduces discoverability".
174
+ * · Material 3, cards: supplemental actions are shown; use an
175
+ * overflow menu for more than two.
176
+ * · Shopify Polaris, page actions: a primary plus at most two
177
+ * secondaries in sight; the rest roll up into "More actions".
178
+ * · GOV.UK summary card: the card's actions are short words in its
179
+ * header, two to three, never hidden.
180
+ * The user picked the stricter end of that range after seeing both on
181
+ * a design canvas, *"nếu keep tối đa 2 button, 1 chính 1 phụ"*, and
182
+ * approved it: *"ok, nhìn hợp lý đấy"*.
183
+ *
184
+ * ③ NEVER A MENU OF ONE. Exactly two secondaries: both stand in sight,
185
+ * because a menu holding the one left over is a click spent on nothing
186
+ * (NN/g). Three or more: one stands in sight and the rest, always two or
187
+ * more, go behind the trigger. Actions that destroy are the first to go
188
+ * into the menu, where the word is read before the press. The trigger
189
+ * shows a word (`moreLabel`, e.g. "Thêm"), not a bare "⋯". NN/g: the icon
190
+ * "lacks inherent meaning; include descriptions as visible labels".
191
+ * THE WAY OUT (`exits`: Huỷ, Đóng) never makes a fourth button:
192
+ * · in a DIALOG it is not in the foot at all — it is the ✕ of the
193
+ * dialog's head (`DialogHead` in @dqa-ai-solutions/ui-react), and an `<ActionBar>`
194
+ * inside a dialog refuses an exit. The foot counts like a page.
195
+ * · in a FORM on a page (no head to go to) it COUNTS as a secondary and
196
+ * is the one kept in sight, drawn `quiet`, never put in a menu: exit +
197
+ * one more stand side by side; exit + two or more leaves the exit in
198
+ * sight and the rest behind the trigger.
199
+ * ⛔ Until 27/9/2026 the exit was not counted, and a dialog showed
200
+ * "Đóng · Lưu tiền sử · Cấp lại mật khẩu · Tiếp đón" — four in a row. The
201
+ * user: *"lối ra chính cũng nên được tính là 1 nút phụ, để nó không bao
202
+ * giờ show đến 4 buttons"*, *"hoặc … đưa lối ra chính lên trên … header
203
+ * của dialog"* — and, shown both, chose the head: *"dùng style loại B"*.
204
+ *
205
+ * ④ ROWS AND LIST ITEMS HAVE NO PRIMARY. Forty rows, each painting one `key`,
206
+ * would be forty primaries on one screen. A card that is a place of its
207
+ * own (a room you hold, a section) is a `card`, and keeps its primary.
208
+ * · `table` (a row): data competes with words, so actions are icons,
209
+ * with the word as their name and tooltip.
210
+ * · `item` (a card repeated in a list): actions are words, drawn
211
+ * `normal` / `quiet`, as on a GOV.UK summary card.
212
+ * Both follow the counting of ③: up to two in sight; from three, one in
213
+ * sight and the rest behind the trigger.
214
+ *
215
+ * And EVERY ACTION HAS AN ICON: a menu item without its mark reads as
216
+ * unfinished, and an icon-only action without one is an unlabelled box.
217
+ * Reported, never guessed at.
218
+ * ═══════════════════════════════════════════════════════════════════════════
219
+ */
220
+ export interface ActionBar {
221
+ /** Drawn in place, in order. */
222
+ inline: ActionView[];
223
+ /** Behind one trigger — never exactly one item. Menu items always show their word. */
224
+ menu: ActionView[];
225
+ /** Actions with no icon to fall back on. */
226
+ missingIcon: string[];
227
+ /**
228
+ * The surface offers something to do and nothing says which is the point —
229
+ * two advancing steps, no `decision.outcome`, no `primary`. Mark one.
230
+ */
231
+ missingPrimary: boolean;
232
+ }
233
+ /**
234
+ * Where a bar stands — see the scope table above. `table` and `item` repeat
235
+ * down the screen and have no primary. `page`, `dialog`, `form` and `rail`
236
+ * must name theirs. A `card` (also a section) is its own scope: it may carry
237
+ * its own primary, or none if another bar of its screen has one.
238
+ */
239
+ export type ActionSurface = 'page' | 'dialog' | 'form' | 'table' | 'rail' | 'card' | 'item';
240
+ /** Secondary actions kept in sight beside the primary — see ②. */
241
+ export declare const VISIBLE_SECONDARY = 1;
242
+ /**
243
+ * How many of `n` secondary actions stay in sight: one, and both when there
244
+ * are exactly two, so that the menu never holds only one (③).
245
+ */
246
+ export declare const inSightCount: (n: number) => number;
247
+ export declare function actionBar(facts: ActionFacts[], where: {
248
+ surface: ActionSurface;
249
+ }): ActionBar;
250
+ /**
251
+ * Which tokens paint a tier. Names only — this package emits no CSS rules.
252
+ *
253
+ * ⛔ `normal` sits on `--fos-surface`, NOT on the action colour. The reference
254
+ * app's stylesheet declared `.btn, button { background: var(--red) }`, so a
255
+ * bare `<button>` was already the loudest thing on the page; 33 screens ended
256
+ * up a wall of red that nobody chose, and a build check had to be written to
257
+ * count them. The default has to be quiet or the discipline never holds.
258
+ */
259
+ export declare const TIER_PAINT: Record<ActionTier, {
260
+ background: string;
261
+ ink: string;
262
+ border: string | null;
263
+ }>;
@@ -0,0 +1,10 @@
1
+ export interface ComponentCssOptions {
2
+ prefix?: string;
3
+ }
4
+ /**
5
+ * Structural CSS for every element the grammar covers.
6
+ *
7
+ * Load it AFTER the theme's variables and before the app's own stylesheet, so
8
+ * an app can still override a specific screen — it simply no longer has to.
9
+ */
10
+ export declare function emitComponentCss(options?: ComponentCssOptions): string;
@@ -0,0 +1,5 @@
1
+ export { type SurfaceKind, type SkeletonKind, type EmptyReason, type NextStep, type EmptyCopy, type Fault, type SurfaceState, type SurfaceInput, type StateHandlers, skeletonFor, surfaceState, matchState, assertNever, } from './state.js';
2
+ export { type ActionTier, type ActionFacts, type DisabledReason, type ActionView, actionViews, actionBar, primaryOf, inSightCount, VISIBLE_SECONDARY, TIER_PAINT, type ActionBar, type ActionSurface, } from './action.js';
3
+ export { type Surface, type Token, type TextRole, type TextSpec, type ButtonSpec, type FieldSpec, type TabSpec, type TableSpec, type MenuItemSpec, textSpec, buttonSpec, fieldSpec, tabSpec, tableSpec, menuItemSpec, SURFACES, TEXT_ROLES, } from './spec.js';
4
+ export { emitComponentCss, type ComponentCssOptions } from './component-css.js';
5
+ export { emitStylesheet, emitBaseCss, emitLayoutCss, type StylesheetOptions, } from './stylesheet.js';
@@ -0,0 +1,102 @@
1
+ import type { ActionTier } from './action.js';
2
+ /** Where an element stands. Position, not appearance. */
3
+ export type Surface = 'page' | 'dialog' | 'form' | 'table' | 'rail' | 'card';
4
+ /** A token reference — never a value. */
5
+ export type Token = string;
6
+ /**
7
+ * Every job text does. Naming the JOB, never the size.
8
+ *
9
+ * ⚠️ `label` and `hint` are different roles even though a lazy system would
10
+ * render both as small grey text. A label names a field and is read before
11
+ * the answer; a hint qualifies it and is read only when the answer is
12
+ * unclear. Giving them the same weight makes the form one flat wall.
13
+ */
14
+ export type TextRole = 'page-title' | 'section-title' | 'card-title' | 'lead' | 'body' | 'label' | 'hint' | 'error' | 'table-header' | 'table-cell' | 'table-cell-sub' | 'badge' | 'empty-title' | 'empty-body' | 'rail-item' | 'tab' | 'note' | 'delta';
15
+ export interface TextSpec {
16
+ /** Type step — the class from `emitTypeUtilities`, all four numbers. */
17
+ step: string;
18
+ ink: Token;
19
+ /** Overrides the step's weight when the ROLE needs more emphasis than the size. */
20
+ weight?: number;
21
+ numeric?: boolean;
22
+ }
23
+ export declare const textSpec: (role: TextRole) => TextSpec;
24
+ export interface ButtonSpec {
25
+ tier: ActionTier;
26
+ /** Token for the control's height. */
27
+ height: Token;
28
+ padX: Token;
29
+ gap: Token;
30
+ text: TextRole;
31
+ background: Token;
32
+ ink: Token;
33
+ border: Token | null;
34
+ }
35
+ export declare function buttonSpec(where: {
36
+ surface: Surface;
37
+ tier: ActionTier;
38
+ }): ButtonSpec;
39
+ export interface FieldSpec {
40
+ height: Token;
41
+ padX: Token;
42
+ radius: Token;
43
+ background: Token;
44
+ ink: Token;
45
+ border: Token;
46
+ label: TextRole;
47
+ hint: TextRole;
48
+ error: TextRole;
49
+ }
50
+ /**
51
+ * ⚠️ An input inside a TABLE (inline editing) keeps the row's height; anywhere
52
+ * else it takes the full target. Same rule as a button, same one reason.
53
+ */
54
+ export declare const fieldSpec: (surface: Surface) => FieldSpec;
55
+ export interface TabSpec {
56
+ height: Token;
57
+ padX: Token;
58
+ text: TextRole;
59
+ ink: Token;
60
+ activeInk: Token;
61
+ /** How the current tab is marked. */
62
+ marker: 'underline' | 'filled';
63
+ }
64
+ /**
65
+ * Two levels, and they must not look alike.
66
+ *
67
+ * ⚠️ Page tabs switch what the screen IS; tabs inside a card switch a slice of
68
+ * one thing. Drawn the same, a reader cannot tell how far a click will take
69
+ * them — so the page level underlines and the nested level fills.
70
+ */
71
+ export declare const tabSpec: (surface: Surface) => TabSpec;
72
+ export interface TableSpec {
73
+ headerHeight: Token;
74
+ rowHeight: Token;
75
+ padX: Token;
76
+ padY: Token;
77
+ header: TextRole;
78
+ cell: TextRole;
79
+ cellSub: TextRole;
80
+ /** Between rows. A long table without one lets the eye slip a line. */
81
+ rule: Token;
82
+ /** Under the header — heavier, so the head reads as a head. */
83
+ headerRule: Token;
84
+ hover: Token;
85
+ selected: Token;
86
+ }
87
+ export declare const tableSpec: () => TableSpec;
88
+ export interface MenuItemSpec {
89
+ height: Token;
90
+ padX: Token;
91
+ text: TextRole;
92
+ ink: Token;
93
+ activeInk: Token;
94
+ activeBackground: Token;
95
+ hover: Token;
96
+ /** Declared scope with no screen behind it yet — see `NavItem.path`. */
97
+ unbuiltInk: Token;
98
+ }
99
+ export declare const menuItemSpec: () => MenuItemSpec;
100
+ /** Every surface, so a caller can prove it covered them all. */
101
+ export declare const SURFACES: readonly Surface[];
102
+ export declare const TEXT_ROLES: TextRole[];