@xemahq/ui-kernel 0.11.0 → 0.11.2

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 (237) hide show
  1. package/dist/ui/chrome/page-shell.d.ts +1 -1
  2. package/dist/ui/chrome/page-shell.d.ts.map +1 -1
  3. package/dist/ui/chrome/page-shell.js +9 -4
  4. package/dist/ui/chrome/page-shell.js.map +1 -1
  5. package/package.json +6 -4
  6. package/src/index.ts +0 -17
  7. package/src/lib/biome-host/agent-validation.ts +0 -239
  8. package/src/lib/biome-host/biome-builders.ts +0 -112
  9. package/src/lib/biome-host/biome-mode.ts +0 -6
  10. package/src/lib/biome-host/biome-navigation.ts +0 -37
  11. package/src/lib/biome-host/biome-registry.ts +0 -299
  12. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  13. package/src/lib/biome-host/biome-scope.tsx +0 -52
  14. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  15. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  16. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  17. package/src/lib/biome-host/define-web-biome.ts +0 -222
  18. package/src/lib/biome-host/errors.ts +0 -220
  19. package/src/lib/biome-host/frontend-biome.ts +0 -256
  20. package/src/lib/biome-host/host-bridge.ts +0 -281
  21. package/src/lib/biome-host/host-sources.ts +0 -54
  22. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  23. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  24. package/src/lib/biome-host/i18n-port.ts +0 -96
  25. package/src/lib/biome-host/index.ts +0 -35
  26. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  27. package/src/lib/biome-host/realtime-port.ts +0 -115
  28. package/src/lib/biome-host/session-contributions.ts +0 -296
  29. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  30. package/src/lib/biome-host/use-page-state.ts +0 -248
  31. package/src/lib/capabilities/capability-context.ts +0 -25
  32. package/src/lib/capabilities/capability-provider.tsx +0 -73
  33. package/src/lib/capabilities/index.ts +0 -17
  34. package/src/lib/capabilities/types.ts +0 -69
  35. package/src/lib/capabilities/use-capability.ts +0 -79
  36. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  37. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  38. package/src/lib/contribution-registry/index.ts +0 -9
  39. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  40. package/src/lib/system-bus/capability-invoke.ts +0 -92
  41. package/src/lib/system-bus/deeplink.ts +0 -210
  42. package/src/lib/system-bus/enums.ts +0 -86
  43. package/src/lib/system-bus/host-ports.ts +0 -93
  44. package/src/lib/system-bus/index.ts +0 -16
  45. package/src/lib/system-bus/intent-registry.ts +0 -109
  46. package/src/lib/system-bus/intents.ts +0 -113
  47. package/src/lib/system-bus/palette.ts +0 -78
  48. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  49. package/src/lib/system-bus/system-bus.ts +0 -37
  50. package/src/lib/system-bus/windows.ts +0 -51
  51. package/src/offline/id.ts +0 -16
  52. package/src/offline/index.ts +0 -54
  53. package/src/offline/mutation.ts +0 -75
  54. package/src/offline/offline-status-badge.tsx +0 -51
  55. package/src/offline/online-controller.ts +0 -105
  56. package/src/offline/outbox.test.ts +0 -172
  57. package/src/offline/outbox.ts +0 -348
  58. package/src/offline/react-hooks.ts +0 -40
  59. package/src/offline/react.tsx +0 -32
  60. package/src/offline/storage.ts +0 -112
  61. package/src/offline/types.ts +0 -77
  62. package/src/org-db/components/DbResultTable.tsx +0 -176
  63. package/src/org-db/index.ts +0 -1
  64. package/src/pdf/index.ts +0 -11
  65. package/src/registry/index.ts +0 -9
  66. package/src/registry/lib/agent-validation-host.ts +0 -36
  67. package/src/registry/lib/biome-slot.tsx +0 -50
  68. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  69. package/src/registry/lib/extension-points.ts +0 -134
  70. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  71. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  72. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  73. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  74. package/src/registry/lib/primitives/index.ts +0 -18
  75. package/src/registry/lib/session-context-builder.ts +0 -84
  76. package/src/registry/lib/session-context-provider.tsx +0 -33
  77. package/src/registry/lib/session-context.ts +0 -21
  78. package/src/registry/lib/session-selectors.ts +0 -272
  79. package/src/session/comments/CommentRail.tsx +0 -164
  80. package/src/session/index.ts +0 -3
  81. package/src/session/lib/cn.ts +0 -11
  82. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  83. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  84. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  85. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  86. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  87. package/src/session-kit/approvals/Obligation.tsx +0 -111
  88. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  89. package/src/session-kit/approvals/approval-icons.ts +0 -31
  90. package/src/session-kit/approvals/approval-model.ts +0 -204
  91. package/src/session-kit/approvals/index.ts +0 -22
  92. package/src/session-kit/approvals/obligation-display.ts +0 -100
  93. package/src/session-kit/approvals/risk-accent.ts +0 -47
  94. package/src/session-kit/approvals/scope-icons.ts +0 -19
  95. package/src/session-kit/combobox/Combobox.tsx +0 -358
  96. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  97. package/src/session-kit/display/ContextHeader.tsx +0 -148
  98. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  99. package/src/session-kit/display/MD.tsx +0 -162
  100. package/src/session-kit/display/MessageTurn.tsx +0 -157
  101. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  102. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  103. package/src/session-kit/display/TokenMeter.tsx +0 -89
  104. package/src/session-kit/display/ToolStrip.tsx +0 -278
  105. package/src/session-kit/display/TypingDots.tsx +0 -24
  106. package/src/session-kit/index.ts +0 -44
  107. package/src/session-kit/lib/enums.ts +0 -66
  108. package/src/session-kit/lib/portal-accent.ts +0 -30
  109. package/src/session-kit/lib/status-dot.ts +0 -68
  110. package/src/session-kit/primitives/Avatar.tsx +0 -44
  111. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  112. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  113. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  114. package/src/session-kit/primitives/Segmented.tsx +0 -71
  115. package/src/ui/branding/app-branding-context.ts +0 -20
  116. package/src/ui/branding/app-branding-provider.tsx +0 -123
  117. package/src/ui/branding/sanitize.ts +0 -89
  118. package/src/ui/breakpoints.ts +0 -14
  119. package/src/ui/capture/document-preview.tsx +0 -166
  120. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  121. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  122. package/src/ui/capture/field-spec-validate.ts +0 -236
  123. package/src/ui/capture/field-spec.test.ts +0 -49
  124. package/src/ui/capture/field-spec.ts +0 -274
  125. package/src/ui/capture/index.ts +0 -51
  126. package/src/ui/capture/schema-field-input.tsx +0 -620
  127. package/src/ui/capture/schema-form.tsx +0 -149
  128. package/src/ui/capture/submit-values.test.ts +0 -70
  129. package/src/ui/capture/submit-values.ts +0 -63
  130. package/src/ui/capture/use-prefill.ts +0 -186
  131. package/src/ui/capture/use-schema-validation.ts +0 -145
  132. package/src/ui/capture/use-wizard.ts +0 -180
  133. package/src/ui/capture/value-format.ts +0 -32
  134. package/src/ui/capture/wizard.tsx +0 -105
  135. package/src/ui/charts/bar-chart.tsx +0 -139
  136. package/src/ui/charts/chart-frame.tsx +0 -125
  137. package/src/ui/charts/chart-types.ts +0 -52
  138. package/src/ui/charts/chart-utils.ts +0 -190
  139. package/src/ui/charts/charts.test.tsx +0 -204
  140. package/src/ui/charts/donut-chart.tsx +0 -129
  141. package/src/ui/charts/index.ts +0 -27
  142. package/src/ui/charts/line-chart.tsx +0 -202
  143. package/src/ui/charts/sparkline.tsx +0 -109
  144. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  145. package/src/ui/chrome/EmptyState.tsx +0 -257
  146. package/src/ui/chrome/ErrorCard.tsx +0 -63
  147. package/src/ui/chrome/LoadingState.tsx +0 -61
  148. package/src/ui/chrome/PageHeader.tsx +0 -137
  149. package/src/ui/chrome/RecordCardList.tsx +0 -98
  150. package/src/ui/chrome/StateCard.tsx +0 -150
  151. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  152. package/src/ui/chrome/page-shell.tsx +0 -189
  153. package/src/ui/chrome/scope-badge.tsx +0 -40
  154. package/src/ui/chrome/status-badge.tsx +0 -79
  155. package/src/ui/cn.ts +0 -32
  156. package/src/ui/design-tokens.ts +0 -372
  157. package/src/ui/hooks/use-debounced-value.ts +0 -16
  158. package/src/ui/hooks/use-is-mobile.ts +0 -28
  159. package/src/ui/index.ts +0 -110
  160. package/src/ui/pdf/pdf-preview.tsx +0 -122
  161. package/src/ui/primitives/alert-dialog.tsx +0 -104
  162. package/src/ui/primitives/async-combobox.tsx +0 -182
  163. package/src/ui/primitives/badge-variants.ts +0 -21
  164. package/src/ui/primitives/badge.tsx +0 -25
  165. package/src/ui/primitives/button-variants.ts +0 -31
  166. package/src/ui/primitives/button.tsx +0 -29
  167. package/src/ui/primitives/card.tsx +0 -43
  168. package/src/ui/primitives/checkbox.tsx +0 -26
  169. package/src/ui/primitives/collapsible.tsx +0 -9
  170. package/src/ui/primitives/dialog.tsx +0 -103
  171. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  172. package/src/ui/primitives/form-stepper.tsx +0 -94
  173. package/src/ui/primitives/form-stepper.types.ts +0 -15
  174. package/src/ui/primitives/input.tsx +0 -22
  175. package/src/ui/primitives/label.tsx +0 -17
  176. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  177. package/src/ui/primitives/popover.tsx +0 -33
  178. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  179. package/src/ui/primitives/radio-group.tsx +0 -36
  180. package/src/ui/primitives/resizable.tsx +0 -67
  181. package/src/ui/primitives/scroll-area.tsx +0 -38
  182. package/src/ui/primitives/select.tsx +0 -143
  183. package/src/ui/primitives/separator.tsx +0 -20
  184. package/src/ui/primitives/sheet.tsx +0 -107
  185. package/src/ui/primitives/skeleton.tsx +0 -99
  186. package/src/ui/primitives/switch.tsx +0 -27
  187. package/src/ui/primitives/table.tsx +0 -72
  188. package/src/ui/primitives/tabs.tsx +0 -53
  189. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  190. package/src/ui/primitives/textarea.tsx +0 -21
  191. package/src/ui/primitives/tooltip.tsx +0 -30
  192. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  193. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  194. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  195. package/src/vista/VistaPanel.tsx +0 -163
  196. package/src/vista/form-payload.spec.ts +0 -139
  197. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  198. package/src/vista/html/CustomUiFrame.tsx +0 -206
  199. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  200. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  201. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  202. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  203. package/src/vista/html/custom-ui-intents.ts +0 -155
  204. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  205. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  206. package/src/vista/html/index.ts +0 -13
  207. package/src/vista/index.ts +0 -52
  208. package/src/vista/surface-catalogue.spec.ts +0 -140
  209. package/src/vista/surface-catalogue.ts +0 -90
  210. package/src/vista/surface-icons.ts +0 -57
  211. package/src/vista/surface-registry.ts +0 -56
  212. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  213. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  214. package/src/vista/surfaces/FormSurface.tsx +0 -380
  215. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  216. package/src/vista/surfaces/TableSurface.tsx +0 -100
  217. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  218. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  219. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  220. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  221. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  222. package/src/vista/surfaces/index.ts +0 -24
  223. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  224. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  225. package/src/vista/use-vista-tabs.ts +0 -196
  226. package/src/vista/vista-code-renderer-context.ts +0 -16
  227. package/src/vista/vista-code-renderer.tsx +0 -35
  228. package/src/vista/vista-file-context.ts +0 -14
  229. package/src/vista/vista-file-source.tsx +0 -141
  230. package/src/vista/vista-form-context.ts +0 -20
  231. package/src/vista/vista-form-host.tsx +0 -48
  232. package/src/vista/vista-model.ts +0 -137
  233. package/src/vista/vista-open-context.tsx +0 -27
  234. package/src/vista/vista-open-state.ts +0 -11
  235. package/src/vista/vista-payloads.ts +0 -635
  236. package/src/vista/vista-tabs-manifest.ts +0 -138
  237. package/src/vista/vista-tools.ts +0 -232
@@ -1,341 +0,0 @@
1
- /**
2
- * The GENERIC approval frame — identical platform-wide.
3
- *
4
- * Header: "Approval required" + RiskPill (reused from the kit) + mono
5
- * capability ref + serif title + summary. Then the biome-supplied
6
- * `ScopedBody`. Then obligations chips (closed `PolicyObligationKind`
7
- * taxonomy), approver role, and quorum dots. Actions: Deny / Allow once /
8
- * Approve — low risk gets "Approve & remember"; high & critical are
9
- * explicit Approve only (no allow-once-remember). The accent rail uses the
10
- * SAME risk→colour mapping as the pill.
11
- *
12
- * Resolved state collapses to a compact confirmation row; a
13
- * quorum-approved request reads "approved · waiting on N more approver".
14
- *
15
- * Controlled OR uncontrolled: pass `decision` to control the resolved
16
- * state from the host (the real flow), or omit it and the card tracks its
17
- * own optimistic resolved state. `onResolve(decision, request)` always
18
- * fires.
19
- */
20
- import { useState, type ReactElement } from 'react';
21
-
22
- import {
23
- ApprovalDecision,
24
- isExplicitApprovalTier,
25
- isQuorum,
26
- type ApprovalRequest,
27
- } from './approval-model';
28
- import { ApprovalButton } from './ApprovalButton';
29
- import { Obligation, QuorumDots } from './Obligation';
30
- import { RISK_ACCENT } from './risk-accent';
31
- import { ScopedBody } from './ScopedBody';
32
- import { RiskPill } from '../primitives/RiskPill';
33
-
34
- import type { ApprovalIcons } from './approval-icons';
35
-
36
- export interface ApprovalCardProps {
37
- readonly request: ApprovalRequest;
38
- readonly icons: ApprovalIcons;
39
- /** Resolution callback. Fires before/after the host updates `decision`. */
40
- readonly onResolve: (
41
- decision: ApprovalDecision,
42
- request: ApprovalRequest,
43
- ) => void;
44
- /**
45
- * Controlled resolved state. Omit for uncontrolled (the card collapses
46
- * optimistically on click). The real host flow passes the server-known
47
- * decision so the collapse reflects committed state.
48
- */
49
- readonly decision?: ApprovalDecision | null;
50
- /** Portal/brand accent for the (non-critical) primary approve button. */
51
- readonly accent?: string;
52
- }
53
-
54
- export function ApprovalCard({
55
- request,
56
- icons,
57
- onResolve,
58
- decision,
59
- accent = 'hsl(var(--primary))',
60
- }: ApprovalCardProps): ReactElement {
61
- const [localDecision, setLocalDecision] = useState<ApprovalDecision | null>(
62
- null,
63
- );
64
- const resolved = decision ?? localDecision;
65
- const r = RISK_ACCENT[request.riskTier];
66
- const explicit = isExplicitApprovalTier(request.riskTier);
67
- const quorum = isQuorum(request);
68
- const approveLabel = resolveApproveLabel(request, quorum, explicit);
69
-
70
- function resolve(d: ApprovalDecision): void {
71
- if (decision === undefined) {
72
- setLocalDecision(d);
73
- }
74
- onResolve(d, request);
75
- }
76
-
77
- if (resolved) {
78
- const approved = resolved === ApprovalDecision.Approved;
79
- const remaining =
80
- (request.requireApproverCount ?? 1) - ((request.approvalsIn ?? 0) + 1);
81
- const approvedLabel =
82
- quorum && remaining > 0
83
- ? `approved · waiting on ${remaining} more approver${remaining === 1 ? '' : 's'}`
84
- : 'approved, capability resumed';
85
- return (
86
- <div
87
- style={{
88
- marginTop: 9,
89
- display: 'flex',
90
- alignItems: 'center',
91
- gap: 10,
92
- padding: '11px 14px',
93
- borderRadius: 11,
94
- border: `1px solid ${
95
- approved ? 'hsl(var(--success) / 0.3)' : 'hsl(var(--rule))'
96
- }`,
97
- background: approved
98
- ? 'hsl(var(--success) / 0.06)'
99
- : 'hsl(var(--muted))',
100
- }}
101
- >
102
- <span
103
- style={{
104
- color: approved ? 'hsl(var(--success))' : 'hsl(var(--ink-3))',
105
- display: 'inline-flex',
106
- }}
107
- >
108
- {approved ? icons.approved(17) : icons.denied(17)}
109
- </span>
110
- <span style={{ fontSize: 13, color: 'hsl(var(--ink-2))' }}>
111
- <strong style={{ color: 'hsl(var(--ink))', fontWeight: 600 }}>
112
- {request.title}
113
- </strong>{' '}
114
- — {approved ? approvedLabel : 'denied'}
115
- </span>
116
- </div>
117
- );
118
- }
119
-
120
- return (
121
- <div
122
- style={{
123
- marginTop: 9,
124
- borderRadius: 12,
125
- overflow: 'hidden',
126
- border: `1px solid ${explicit ? r.bd : 'hsl(var(--rule-2))'}`,
127
- boxShadow: 'var(--shadow-2)',
128
- background: 'hsl(var(--paper-elev))',
129
- }}
130
- >
131
- <div style={{ display: 'flex' }}>
132
- {/* accent rail — same risk→colour mapping as the pill */}
133
- <div
134
- style={{
135
- width: 3,
136
- flexShrink: 0,
137
- background: explicit ? r.fg : 'hsl(var(--rule-2))',
138
- }}
139
- />
140
- <div style={{ flex: 1, minWidth: 0 }}>
141
- {/* header — generic */}
142
- <div
143
- style={{
144
- padding: '11px 14px 9px',
145
- borderBottom: '1px solid hsl(var(--rule))',
146
- }}
147
- >
148
- <div
149
- style={{
150
- display: 'flex',
151
- alignItems: 'center',
152
- gap: 8,
153
- marginBottom: 6,
154
- }}
155
- >
156
- <span
157
- style={{
158
- color: explicit ? r.fg : 'hsl(var(--primary))',
159
- display: 'inline-flex',
160
- }}
161
- >
162
- {icons.shield(16)}
163
- </span>
164
- <span
165
- className="cap"
166
- style={{ color: 'hsl(var(--ink-3))', letterSpacing: '0.1em' }}
167
- >
168
- Approval required
169
- </span>
170
- <RiskPill tier={request.riskTier} size="xs" />
171
- <span style={{ flex: 1 }} />
172
- <span
173
- className="mono"
174
- style={{
175
- fontSize: 10.5,
176
- color: 'hsl(var(--ink-4))',
177
- display: 'inline-flex',
178
- alignItems: 'center',
179
- gap: 4,
180
- overflow: 'hidden',
181
- textOverflow: 'ellipsis',
182
- whiteSpace: 'nowrap',
183
- maxWidth: '50%',
184
- }}
185
- >
186
- {icons.capability(11)}
187
- {request.capability}
188
- </span>
189
- </div>
190
- <div
191
- className="serif"
192
- style={{
193
- fontSize: 15,
194
- fontWeight: 600,
195
- color: 'hsl(var(--ink))',
196
- lineHeight: 1.3,
197
- }}
198
- >
199
- {request.title}
200
- </div>
201
- <div
202
- style={{
203
- fontSize: 12.5,
204
- color: 'hsl(var(--ink-3))',
205
- marginTop: 2,
206
- }}
207
- >
208
- {request.summary}
209
- </div>
210
- </div>
211
-
212
- {/* SCOPED biome body */}
213
- <div
214
- style={{
215
- padding: '10px 14px',
216
- background: 'hsl(var(--paper) / 0.5)',
217
- }}
218
- >
219
- <div
220
- style={{
221
- display: 'flex',
222
- alignItems: 'center',
223
- gap: 6,
224
- marginBottom: 8,
225
- }}
226
- >
227
- <span
228
- className="cap"
229
- style={{ fontSize: 9.5, color: 'hsl(var(--ink-4))' }}
230
- >
231
- Details from {request.biomeName}
232
- </span>
233
- <span
234
- style={{ flex: 1, height: 1, background: 'hsl(var(--rule))' }}
235
- />
236
- </div>
237
- <ScopedBody scope={request.scope} renderIcon={icons.scope} />
238
- </div>
239
-
240
- {/* obligations + approver requirement — generic */}
241
- <div
242
- style={{
243
- padding: '10px 14px',
244
- borderTop: '1px solid hsl(var(--rule))',
245
- display: 'flex',
246
- flexDirection: 'column',
247
- gap: 9,
248
- }}
249
- >
250
- {request.obligations && request.obligations.length > 0 && (
251
- <div style={{ display: 'flex', flexWrap: 'wrap', gap: 6 }}>
252
- {request.obligations.map((o) => (
253
- <Obligation
254
- key={o.kind}
255
- obligation={o}
256
- renderIcon={icons.obligation}
257
- />
258
- ))}
259
- </div>
260
- )}
261
- <div
262
- style={{
263
- display: 'flex',
264
- alignItems: 'center',
265
- gap: 10,
266
- flexWrap: 'wrap',
267
- }}
268
- >
269
- {request.requireRole && (
270
- <span
271
- style={{
272
- display: 'inline-flex',
273
- alignItems: 'center',
274
- gap: 5,
275
- fontSize: 12,
276
- color: 'hsl(var(--ink-3))',
277
- }}
278
- >
279
- {icons.user(13)}approver role{' '}
280
- <span className="mono" style={{ color: 'hsl(var(--ink-2))' }}>
281
- {request.requireRole}
282
- </span>
283
- </span>
284
- )}
285
- {quorum && (
286
- <QuorumDots
287
- have={request.approvalsIn ?? 0}
288
- need={request.requireApproverCount ?? 1}
289
- usersIcon={icons.users(13)}
290
- />
291
- )}
292
- <span style={{ flex: 1 }} />
293
- <ApprovalButton
294
- variant="ghost"
295
- size="sm"
296
- onClick={() => resolve(ApprovalDecision.Denied)}
297
- >
298
- Deny
299
- </ApprovalButton>
300
- {!explicit && (
301
- <ApprovalButton
302
- variant="soft"
303
- size="sm"
304
- icon={icons.check(13)}
305
- onClick={() => resolve(ApprovalDecision.Approved)}
306
- >
307
- Allow once
308
- </ApprovalButton>
309
- )}
310
- <ApprovalButton
311
- variant="primary"
312
- size="sm"
313
- icon={icons.shield(13)}
314
- accent={explicit ? r.fg : accent}
315
- onClick={() => resolve(ApprovalDecision.Approved)}
316
- >
317
- {approveLabel}
318
- </ApprovalButton>
319
- </div>
320
- </div>
321
- </div>
322
- </div>
323
- </div>
324
- );
325
- }
326
-
327
- /**
328
- * The primary-button label: a quorum step ("Approve (1 of 2)"), a plain
329
- * "Approve" for explicit (high/critical) tiers, or "Approve & remember"
330
- * for low/medium where allow-once-remember is offered.
331
- */
332
- function resolveApproveLabel(
333
- request: ApprovalRequest,
334
- quorum: boolean,
335
- explicit: boolean,
336
- ): string {
337
- if (quorum) {
338
- return `Approve (${(request.approvalsIn ?? 0) + 1} of ${request.requireApproverCount})`;
339
- }
340
- return explicit ? 'Approve' : 'Approve & remember';
341
- }
@@ -1,336 +0,0 @@
1
- /**
2
- * Approvals Center body — the cross-portal batch-review list.
3
- *
4
- * This is the GENERIC, prop-driven body (toolbar + rows + empty state). It
5
- * does NOT own the drawer chrome: the host wraps it in its own `Sheet`
6
- * (the host carries the overlay/focus-trap/portal primitive). That keeps
7
- * the kit free of any host UI dependency while the batching/selection
8
- * logic stays generic and reusable.
9
- *
10
- * Batches approvals ACROSS all portals/sessions: each row carries its
11
- * portal + biome + quorum and an "Open session" affordance. "Select
12
- * low-risk" selects every low/medium item; bulk "Approve N" resolves the
13
- * selection. The row model (`ApprovalCenterItem`) already carries
14
- * portalId/name/accent so host portals can group by portal without a reshape.
15
- */
16
- import { CapabilityRiskTier } from '@xemahq/kernel-contracts/capability';
17
- import { useCallback, useState, type ReactElement } from 'react';
18
-
19
- import { ApprovalDecision, type ApprovalCenterItem } from './approval-model';
20
- import { ApprovalButton } from './ApprovalButton';
21
- import { RiskPill } from '../primitives/RiskPill';
22
-
23
- import type { ApprovalIcons } from './approval-icons';
24
-
25
- export interface ApprovalsCenterProps {
26
- readonly items: readonly ApprovalCenterItem[];
27
- readonly icons: Pick<ApprovalIcons, 'check' | 'approved'>;
28
- /** Resolve a single item (also used by the bulk action per-item). */
29
- readonly onResolve: (
30
- decision: ApprovalDecision,
31
- item: ApprovalCenterItem,
32
- ) => void;
33
- /** "Open session" — host navigates to the suspended capability's session. */
34
- readonly onOpen?: (item: ApprovalCenterItem) => void;
35
- }
36
-
37
- const LOW_RISK: ReadonlySet<CapabilityRiskTier> = new Set([
38
- CapabilityRiskTier.Low,
39
- CapabilityRiskTier.Medium,
40
- ]);
41
-
42
- export function ApprovalsCenter({
43
- items,
44
- icons,
45
- onResolve,
46
- onOpen,
47
- }: ApprovalsCenterProps): ReactElement {
48
- const [selected, setSelected] = useState<ReadonlySet<string>>(
49
- () => new Set(),
50
- );
51
-
52
- const toggle = useCallback((id: string) => {
53
- setSelected((prev) => {
54
- const next = new Set(prev);
55
- if (next.has(id)) {
56
- next.delete(id);
57
- } else {
58
- next.add(id);
59
- }
60
- return next;
61
- });
62
- }, []);
63
-
64
- const selectLowRisk = useCallback(() => {
65
- setSelected(
66
- new Set(
67
- items
68
- .filter((it) => LOW_RISK.has(it.request.riskTier))
69
- .map((it) => it.id),
70
- ),
71
- );
72
- }, [items]);
73
-
74
- const approveSelected = useCallback(() => {
75
- for (const id of selected) {
76
- const it = items.find((x) => x.id === id);
77
- if (it) {
78
- onResolve(ApprovalDecision.Approved, it);
79
- }
80
- }
81
- setSelected(new Set());
82
- }, [selected, items, onResolve]);
83
-
84
- return (
85
- <div
86
- style={{
87
- display: 'flex',
88
- flexDirection: 'column',
89
- height: '100%',
90
- minHeight: 0,
91
- }}
92
- >
93
- {/* selection toolbar */}
94
- <div
95
- style={{
96
- padding: '9px 16px',
97
- borderBottom: '1px solid hsl(var(--rule))',
98
- display: 'flex',
99
- alignItems: 'center',
100
- gap: 9,
101
- }}
102
- >
103
- <span style={{ fontSize: 12, color: 'hsl(var(--ink-3))' }}>
104
- {selected.size} selected
105
- </span>
106
- <span style={{ flex: 1 }} />
107
- <ApprovalButton
108
- variant="ghost"
109
- size="xs"
110
- onClick={selectLowRisk}
111
- disabled={items.length === 0}
112
- >
113
- Select low-risk
114
- </ApprovalButton>
115
- <ApprovalButton
116
- variant="primary"
117
- size="xs"
118
- icon={icons.check(12)}
119
- disabled={selected.size === 0}
120
- onClick={approveSelected}
121
- >
122
- Approve {selected.size || ''}
123
- </ApprovalButton>
124
- </div>
125
-
126
- {/* rows */}
127
- <div
128
- style={{
129
- flex: 1,
130
- minHeight: 0,
131
- overflowY: 'auto',
132
- padding: 12,
133
- display: 'flex',
134
- flexDirection: 'column',
135
- gap: 9,
136
- }}
137
- >
138
- {items.length === 0 ? (
139
- <div
140
- style={{
141
- textAlign: 'center',
142
- padding: '48px 0',
143
- color: 'hsl(var(--ink-3))',
144
- }}
145
- >
146
- <span
147
- style={{
148
- color: 'hsl(var(--success))',
149
- display: 'inline-flex',
150
- marginBottom: 10,
151
- }}
152
- >
153
- {icons.approved(26)}
154
- </span>
155
- <div style={{ fontSize: 13.5 }}>Nothing waiting on you.</div>
156
- </div>
157
- ) : (
158
- items.map((it) => (
159
- <ApprovalRow
160
- key={it.id}
161
- item={it}
162
- checked={selected.has(it.id)}
163
- onToggle={() => toggle(it.id)}
164
- onResolve={onResolve}
165
- {...(onOpen ? { onOpen } : {})}
166
- icons={icons}
167
- />
168
- ))
169
- )}
170
- </div>
171
- </div>
172
- );
173
- }
174
-
175
- interface ApprovalRowProps {
176
- readonly item: ApprovalCenterItem;
177
- readonly checked: boolean;
178
- readonly onToggle: () => void;
179
- readonly onResolve: (
180
- decision: ApprovalDecision,
181
- item: ApprovalCenterItem,
182
- ) => void;
183
- readonly onOpen?: (item: ApprovalCenterItem) => void;
184
- readonly icons: Pick<ApprovalIcons, 'check'>;
185
- }
186
-
187
- function ApprovalRow({
188
- item,
189
- checked,
190
- onToggle,
191
- onResolve,
192
- onOpen,
193
- icons,
194
- }: ApprovalRowProps): ReactElement {
195
- const { request } = item;
196
- const quorum = (request.requireApproverCount ?? 1) > 1;
197
- return (
198
- <div
199
- style={{
200
- border: `1px solid ${
201
- checked ? 'hsl(var(--primary) / 0.4)' : 'hsl(var(--rule))'
202
- }`,
203
- borderRadius: 10,
204
- background: 'hsl(var(--paper-elev))',
205
- boxShadow: checked
206
- ? '0 0 0 1px hsl(var(--primary) / 0.2)'
207
- : 'var(--shadow-2)',
208
- overflow: 'hidden',
209
- }}
210
- >
211
- <div style={{ display: 'flex', gap: 10, padding: '11px 12px' }}>
212
- <button
213
- type="button"
214
- onClick={onToggle}
215
- aria-pressed={checked}
216
- aria-label={checked ? 'Deselect' : 'Select'}
217
- style={{
218
- width: 18,
219
- height: 18,
220
- borderRadius: 5,
221
- marginTop: 1,
222
- flexShrink: 0,
223
- display: 'grid',
224
- placeItems: 'center',
225
- border: checked ? 'none' : '1.5px solid hsl(var(--rule-2))',
226
- background: checked ? 'hsl(var(--primary))' : 'transparent',
227
- color: '#fff',
228
- cursor: 'pointer',
229
- }}
230
- >
231
- {checked && icons.check(12)}
232
- </button>
233
- <div style={{ flex: 1, minWidth: 0 }}>
234
- <div
235
- style={{
236
- display: 'flex',
237
- alignItems: 'center',
238
- gap: 7,
239
- marginBottom: 3,
240
- }}
241
- >
242
- <span
243
- style={{
244
- fontSize: 13.5,
245
- fontWeight: 600,
246
- color: 'hsl(var(--ink))',
247
- overflow: 'hidden',
248
- textOverflow: 'ellipsis',
249
- whiteSpace: 'nowrap',
250
- minWidth: 0,
251
- }}
252
- >
253
- {request.title}
254
- </span>
255
- <RiskPill tier={request.riskTier} size="xs" />
256
- </div>
257
- <div
258
- style={{
259
- display: 'flex',
260
- alignItems: 'center',
261
- gap: 7,
262
- fontSize: 11.5,
263
- color: 'hsl(var(--ink-3))',
264
- flexWrap: 'wrap',
265
- }}
266
- >
267
- {(item.portalName || item.portalAccentVar) && (
268
- <span
269
- style={{
270
- display: 'inline-flex',
271
- alignItems: 'center',
272
- gap: 4,
273
- }}
274
- >
275
- {item.portalAccentVar && (
276
- <span
277
- style={{
278
- width: 7,
279
- height: 7,
280
- borderRadius: 2,
281
- background: `hsl(${item.portalAccentVar})`,
282
- }}
283
- />
284
- )}
285
- {item.portalName}
286
- </span>
287
- )}
288
- {item.portalName && <span>·</span>}
289
- <span>{request.biomeName}</span>
290
- {quorum && (
291
- <>
292
- <span>·</span>
293
- <span className="mono">
294
- {request.approvalsIn ?? 0}/{request.requireApproverCount}
295
- </span>
296
- </>
297
- )}
298
- </div>
299
- </div>
300
- </div>
301
- <div
302
- style={{
303
- display: 'flex',
304
- gap: 7,
305
- padding: '0 12px 11px',
306
- justifyContent: 'flex-end',
307
- }}
308
- >
309
- {onOpen && (
310
- <ApprovalButton
311
- variant="ghost"
312
- size="xs"
313
- onClick={() => onOpen(item)}
314
- >
315
- Open session
316
- </ApprovalButton>
317
- )}
318
- <ApprovalButton
319
- variant="ghost"
320
- size="xs"
321
- onClick={() => onResolve(ApprovalDecision.Denied, item)}
322
- >
323
- Deny
324
- </ApprovalButton>
325
- <ApprovalButton
326
- variant="soft"
327
- size="xs"
328
- icon={icons.check(12)}
329
- onClick={() => onResolve(ApprovalDecision.Approved, item)}
330
- >
331
- Approve
332
- </ApprovalButton>
333
- </div>
334
- </div>
335
- );
336
- }