@xemahq/ui-kernel 0.11.1 → 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 (234) hide show
  1. package/package.json +1 -2
  2. package/src/index.ts +0 -17
  3. package/src/lib/biome-host/agent-validation.ts +0 -239
  4. package/src/lib/biome-host/biome-builders.ts +0 -112
  5. package/src/lib/biome-host/biome-mode.ts +0 -6
  6. package/src/lib/biome-host/biome-navigation.ts +0 -37
  7. package/src/lib/biome-host/biome-registry.ts +0 -299
  8. package/src/lib/biome-host/biome-scope-hooks.ts +0 -41
  9. package/src/lib/biome-host/biome-scope.tsx +0 -52
  10. package/src/lib/biome-host/biome-scoped-query.ts +0 -134
  11. package/src/lib/biome-host/create-biome-orval-config.ts +0 -82
  12. package/src/lib/biome-host/define-web-biome.spec.ts +0 -221
  13. package/src/lib/biome-host/define-web-biome.ts +0 -222
  14. package/src/lib/biome-host/errors.ts +0 -220
  15. package/src/lib/biome-host/frontend-biome.ts +0 -256
  16. package/src/lib/biome-host/host-bridge.ts +0 -281
  17. package/src/lib/biome-host/host-sources.ts +0 -54
  18. package/src/lib/biome-host/i18n-hooks.ts +0 -51
  19. package/src/lib/biome-host/i18n-port.test.ts +0 -50
  20. package/src/lib/biome-host/i18n-port.ts +0 -96
  21. package/src/lib/biome-host/index.ts +0 -35
  22. package/src/lib/biome-host/realtime-hooks.ts +0 -75
  23. package/src/lib/biome-host/realtime-port.ts +0 -115
  24. package/src/lib/biome-host/session-contributions.ts +0 -296
  25. package/src/lib/biome-host/use-mutation-with-error-toast.ts +0 -90
  26. package/src/lib/biome-host/use-page-state.ts +0 -248
  27. package/src/lib/capabilities/capability-context.ts +0 -25
  28. package/src/lib/capabilities/capability-provider.tsx +0 -73
  29. package/src/lib/capabilities/index.ts +0 -17
  30. package/src/lib/capabilities/types.ts +0 -69
  31. package/src/lib/capabilities/use-capability.ts +0 -79
  32. package/src/lib/contribution-registry/contribution-registry.spec.ts +0 -141
  33. package/src/lib/contribution-registry/contribution-registry.ts +0 -204
  34. package/src/lib/contribution-registry/index.ts +0 -9
  35. package/src/lib/contribution-registry/renderable-registry.ts +0 -142
  36. package/src/lib/system-bus/capability-invoke.ts +0 -92
  37. package/src/lib/system-bus/deeplink.ts +0 -210
  38. package/src/lib/system-bus/enums.ts +0 -86
  39. package/src/lib/system-bus/host-ports.ts +0 -93
  40. package/src/lib/system-bus/index.ts +0 -16
  41. package/src/lib/system-bus/intent-registry.ts +0 -109
  42. package/src/lib/system-bus/intents.ts +0 -113
  43. package/src/lib/system-bus/palette.ts +0 -78
  44. package/src/lib/system-bus/system-bus-builder.ts +0 -159
  45. package/src/lib/system-bus/system-bus.ts +0 -37
  46. package/src/lib/system-bus/windows.ts +0 -51
  47. package/src/offline/id.ts +0 -16
  48. package/src/offline/index.ts +0 -54
  49. package/src/offline/mutation.ts +0 -75
  50. package/src/offline/offline-status-badge.tsx +0 -51
  51. package/src/offline/online-controller.ts +0 -105
  52. package/src/offline/outbox.test.ts +0 -172
  53. package/src/offline/outbox.ts +0 -348
  54. package/src/offline/react-hooks.ts +0 -40
  55. package/src/offline/react.tsx +0 -32
  56. package/src/offline/storage.ts +0 -112
  57. package/src/offline/types.ts +0 -77
  58. package/src/org-db/components/DbResultTable.tsx +0 -176
  59. package/src/org-db/index.ts +0 -1
  60. package/src/pdf/index.ts +0 -11
  61. package/src/registry/index.ts +0 -9
  62. package/src/registry/lib/agent-validation-host.ts +0 -36
  63. package/src/registry/lib/biome-slot.tsx +0 -50
  64. package/src/registry/lib/biomes-enabled-context.ts +0 -20
  65. package/src/registry/lib/extension-points.ts +0 -134
  66. package/src/registry/lib/primitives/SessionEventCard.tsx +0 -164
  67. package/src/registry/lib/primitives/SessionEventTimeline.tsx +0 -95
  68. package/src/registry/lib/primitives/SessionMutationBar.tsx +0 -76
  69. package/src/registry/lib/primitives/SessionTabbedDrawer.tsx +0 -165
  70. package/src/registry/lib/primitives/index.ts +0 -18
  71. package/src/registry/lib/session-context-builder.ts +0 -84
  72. package/src/registry/lib/session-context-provider.tsx +0 -33
  73. package/src/registry/lib/session-context.ts +0 -21
  74. package/src/registry/lib/session-selectors.ts +0 -272
  75. package/src/session/comments/CommentRail.tsx +0 -164
  76. package/src/session/index.ts +0 -3
  77. package/src/session/lib/cn.ts +0 -11
  78. package/src/session/shell/SessionWorkspaceShell.tsx +0 -147
  79. package/src/session-kit/approvals/ApprovalButton.tsx +0 -89
  80. package/src/session-kit/approvals/ApprovalCard.tsx +0 -341
  81. package/src/session-kit/approvals/ApprovalsCenter.tsx +0 -336
  82. package/src/session-kit/approvals/CapabilityApprovalStickyBar.tsx +0 -118
  83. package/src/session-kit/approvals/Obligation.tsx +0 -111
  84. package/src/session-kit/approvals/ScopedBody.tsx +0 -392
  85. package/src/session-kit/approvals/approval-icons.ts +0 -31
  86. package/src/session-kit/approvals/approval-model.ts +0 -204
  87. package/src/session-kit/approvals/index.ts +0 -22
  88. package/src/session-kit/approvals/obligation-display.ts +0 -100
  89. package/src/session-kit/approvals/risk-accent.ts +0 -47
  90. package/src/session-kit/approvals/scope-icons.ts +0 -19
  91. package/src/session-kit/combobox/Combobox.tsx +0 -358
  92. package/src/session-kit/combobox/use-click-outside.ts +0 -21
  93. package/src/session-kit/display/ContextHeader.tsx +0 -148
  94. package/src/session-kit/display/FileDiffCard.tsx +0 -140
  95. package/src/session-kit/display/MD.tsx +0 -162
  96. package/src/session-kit/display/MessageTurn.tsx +0 -157
  97. package/src/session-kit/display/ThinkingPanel.tsx +0 -81
  98. package/src/session-kit/display/TodoChecklist.tsx +0 -120
  99. package/src/session-kit/display/TokenMeter.tsx +0 -89
  100. package/src/session-kit/display/ToolStrip.tsx +0 -278
  101. package/src/session-kit/display/TypingDots.tsx +0 -24
  102. package/src/session-kit/index.ts +0 -44
  103. package/src/session-kit/lib/enums.ts +0 -66
  104. package/src/session-kit/lib/portal-accent.ts +0 -30
  105. package/src/session-kit/lib/status-dot.ts +0 -68
  106. package/src/session-kit/primitives/Avatar.tsx +0 -44
  107. package/src/session-kit/primitives/PortalGlyph.tsx +0 -51
  108. package/src/session-kit/primitives/RiskPill.tsx +0 -95
  109. package/src/session-kit/primitives/ScopeDot.tsx +0 -47
  110. package/src/session-kit/primitives/Segmented.tsx +0 -71
  111. package/src/ui/branding/app-branding-context.ts +0 -20
  112. package/src/ui/branding/app-branding-provider.tsx +0 -123
  113. package/src/ui/branding/sanitize.ts +0 -89
  114. package/src/ui/breakpoints.ts +0 -14
  115. package/src/ui/capture/document-preview.tsx +0 -166
  116. package/src/ui/capture/field-spec-to-zod.test.ts +0 -81
  117. package/src/ui/capture/field-spec-to-zod.ts +0 -174
  118. package/src/ui/capture/field-spec-validate.ts +0 -236
  119. package/src/ui/capture/field-spec.test.ts +0 -49
  120. package/src/ui/capture/field-spec.ts +0 -274
  121. package/src/ui/capture/index.ts +0 -51
  122. package/src/ui/capture/schema-field-input.tsx +0 -620
  123. package/src/ui/capture/schema-form.tsx +0 -149
  124. package/src/ui/capture/submit-values.test.ts +0 -70
  125. package/src/ui/capture/submit-values.ts +0 -63
  126. package/src/ui/capture/use-prefill.ts +0 -186
  127. package/src/ui/capture/use-schema-validation.ts +0 -145
  128. package/src/ui/capture/use-wizard.ts +0 -180
  129. package/src/ui/capture/value-format.ts +0 -32
  130. package/src/ui/capture/wizard.tsx +0 -105
  131. package/src/ui/charts/bar-chart.tsx +0 -139
  132. package/src/ui/charts/chart-frame.tsx +0 -125
  133. package/src/ui/charts/chart-types.ts +0 -52
  134. package/src/ui/charts/chart-utils.ts +0 -190
  135. package/src/ui/charts/charts.test.tsx +0 -204
  136. package/src/ui/charts/donut-chart.tsx +0 -129
  137. package/src/ui/charts/index.ts +0 -27
  138. package/src/ui/charts/line-chart.tsx +0 -202
  139. package/src/ui/charts/sparkline.tsx +0 -109
  140. package/src/ui/chrome/AsyncBoundary.tsx +0 -74
  141. package/src/ui/chrome/EmptyState.tsx +0 -257
  142. package/src/ui/chrome/ErrorCard.tsx +0 -63
  143. package/src/ui/chrome/LoadingState.tsx +0 -61
  144. package/src/ui/chrome/PageHeader.tsx +0 -137
  145. package/src/ui/chrome/RecordCardList.tsx +0 -98
  146. package/src/ui/chrome/StateCard.tsx +0 -150
  147. package/src/ui/chrome/confirm-delete-dialog.tsx +0 -59
  148. package/src/ui/chrome/page-shell.spec.tsx +0 -117
  149. package/src/ui/chrome/page-shell.tsx +0 -221
  150. package/src/ui/chrome/scope-badge.tsx +0 -40
  151. package/src/ui/chrome/status-badge.tsx +0 -79
  152. package/src/ui/cn.ts +0 -32
  153. package/src/ui/design-tokens.ts +0 -372
  154. package/src/ui/hooks/use-debounced-value.ts +0 -16
  155. package/src/ui/hooks/use-is-mobile.ts +0 -28
  156. package/src/ui/index.ts +0 -110
  157. package/src/ui/pdf/pdf-preview.tsx +0 -122
  158. package/src/ui/primitives/alert-dialog.tsx +0 -104
  159. package/src/ui/primitives/async-combobox.tsx +0 -182
  160. package/src/ui/primitives/badge-variants.ts +0 -21
  161. package/src/ui/primitives/badge.tsx +0 -25
  162. package/src/ui/primitives/button-variants.ts +0 -31
  163. package/src/ui/primitives/button.tsx +0 -29
  164. package/src/ui/primitives/card.tsx +0 -43
  165. package/src/ui/primitives/checkbox.tsx +0 -26
  166. package/src/ui/primitives/collapsible.tsx +0 -9
  167. package/src/ui/primitives/dialog.tsx +0 -103
  168. package/src/ui/primitives/dropdown-menu.tsx +0 -179
  169. package/src/ui/primitives/form-stepper.tsx +0 -94
  170. package/src/ui/primitives/form-stepper.types.ts +0 -15
  171. package/src/ui/primitives/input.tsx +0 -22
  172. package/src/ui/primitives/label.tsx +0 -17
  173. package/src/ui/primitives/overflow-tabs.tsx +0 -331
  174. package/src/ui/primitives/popover.tsx +0 -33
  175. package/src/ui/primitives/preview-device-frame.tsx +0 -213
  176. package/src/ui/primitives/radio-group.tsx +0 -36
  177. package/src/ui/primitives/resizable.tsx +0 -67
  178. package/src/ui/primitives/scroll-area.tsx +0 -38
  179. package/src/ui/primitives/select.tsx +0 -143
  180. package/src/ui/primitives/separator.tsx +0 -20
  181. package/src/ui/primitives/sheet.tsx +0 -107
  182. package/src/ui/primitives/skeleton.tsx +0 -99
  183. package/src/ui/primitives/switch.tsx +0 -27
  184. package/src/ui/primitives/table.tsx +0 -72
  185. package/src/ui/primitives/tabs.tsx +0 -53
  186. package/src/ui/primitives/tag-multi-select.tsx +0 -261
  187. package/src/ui/primitives/textarea.tsx +0 -21
  188. package/src/ui/primitives/tooltip.tsx +0 -30
  189. package/src/ui/primitives/url-preview-chrome.tsx +0 -103
  190. package/src/vista/GenericCatalogueSurface.tsx +0 -179
  191. package/src/vista/SurfaceFallbackCard.tsx +0 -109
  192. package/src/vista/VistaPanel.tsx +0 -163
  193. package/src/vista/form-payload.spec.ts +0 -139
  194. package/src/vista/html/CustomUiFrame.spec.tsx +0 -127
  195. package/src/vista/html/CustomUiFrame.tsx +0 -206
  196. package/src/vista/html/custom-ui-frame-bridge.spec.ts +0 -191
  197. package/src/vista/html/custom-ui-frame-bridge.ts +0 -98
  198. package/src/vista/html/custom-ui-frame-contract.ts +0 -88
  199. package/src/vista/html/custom-ui-intents.spec.ts +0 -135
  200. package/src/vista/html/custom-ui-intents.ts +0 -155
  201. package/src/vista/html/custom-ui-srcdoc.spec.ts +0 -151
  202. package/src/vista/html/custom-ui-srcdoc.ts +0 -193
  203. package/src/vista/html/index.ts +0 -13
  204. package/src/vista/index.ts +0 -52
  205. package/src/vista/surface-catalogue.spec.ts +0 -140
  206. package/src/vista/surface-catalogue.ts +0 -90
  207. package/src/vista/surface-icons.ts +0 -57
  208. package/src/vista/surface-registry.ts +0 -56
  209. package/src/vista/surfaces/ChartSurface.tsx +0 -34
  210. package/src/vista/surfaces/FilesSurface.tsx +0 -202
  211. package/src/vista/surfaces/FormSurface.tsx +0 -380
  212. package/src/vista/surfaces/HtmlSurface.tsx +0 -43
  213. package/src/vista/surfaces/TableSurface.tsx +0 -100
  214. package/src/vista/surfaces/UrlSurface.tsx +0 -40
  215. package/src/vista/surfaces/blob-surfaces.tsx +0 -139
  216. package/src/vista/surfaces/elicitation-transport.spec.ts +0 -369
  217. package/src/vista/surfaces/elicitation-transport.ts +0 -367
  218. package/src/vista/surfaces/file-surface-utils.ts +0 -69
  219. package/src/vista/surfaces/index.ts +0 -24
  220. package/src/vista/surfaces/register-surfaces.tsx +0 -139
  221. package/src/vista/surfaces/text-surfaces.tsx +0 -132
  222. package/src/vista/use-vista-tabs.ts +0 -196
  223. package/src/vista/vista-code-renderer-context.ts +0 -16
  224. package/src/vista/vista-code-renderer.tsx +0 -35
  225. package/src/vista/vista-file-context.ts +0 -14
  226. package/src/vista/vista-file-source.tsx +0 -141
  227. package/src/vista/vista-form-context.ts +0 -20
  228. package/src/vista/vista-form-host.tsx +0 -48
  229. package/src/vista/vista-model.ts +0 -137
  230. package/src/vista/vista-open-context.tsx +0 -27
  231. package/src/vista/vista-open-state.ts +0 -11
  232. package/src/vista/vista-payloads.ts +0 -635
  233. package/src/vista/vista-tabs-manifest.ts +0 -138
  234. package/src/vista/vista-tools.ts +0 -232
@@ -1,118 +0,0 @@
1
- /**
2
- * Sticky CAPABILITY-approval bar — pinned above the composer
3
- * so a pending capability approval is always actionable without scrolling
4
- * back to the inline card.
5
- *
6
- * NOTE on naming: this is DISTINCT from the clarification-gate
7
- * `StickyApprovalBar` (`src/components/clarification/StickyApprovalBar.tsx`),
8
- * which approves a clarification CONTRACT (attempt counters, reject
9
- * reasons, override rationale). This bar approves a suspended CAPABILITY
10
- * CALL (risk tier + biome + Review/Deny/Approve). The two concerns are
11
- * deliberately separate components so neither regresses the other.
12
- *
13
- * Title + RiskPill + biome + Review / Deny / Approve. The bar surface is
14
- * tinted with the risk accent; critical/high force the risk colour on the
15
- * approve button.
16
- */
17
- import {
18
- ApprovalDecision,
19
- isExplicitApprovalTier,
20
- type ApprovalRequest,
21
- } from './approval-model';
22
- import { ApprovalButton } from './ApprovalButton';
23
- import { RISK_ACCENT } from './risk-accent';
24
- import { RiskPill } from '../primitives/RiskPill';
25
-
26
- import type { ApprovalIcons } from './approval-icons';
27
- import type { ReactElement } from 'react';
28
-
29
- export interface CapabilityApprovalStickyBarProps {
30
- readonly request: ApprovalRequest;
31
- readonly icons: Pick<ApprovalIcons, 'shield' | 'check'>;
32
- readonly onResolve: (
33
- decision: ApprovalDecision,
34
- request: ApprovalRequest,
35
- ) => void;
36
- /** "Review" scrolls/opens the inline card; optional. */
37
- readonly onReview?: () => void;
38
- /** Portal/brand accent for the (non-critical) approve button. */
39
- readonly accent?: string;
40
- }
41
-
42
- export function CapabilityApprovalStickyBar({
43
- request,
44
- icons,
45
- onResolve,
46
- onReview,
47
- accent = 'hsl(var(--primary))',
48
- }: CapabilityApprovalStickyBarProps): ReactElement {
49
- const r = RISK_ACCENT[request.riskTier];
50
- const explicit = isExplicitApprovalTier(request.riskTier);
51
- return (
52
- <div
53
- style={{
54
- display: 'flex',
55
- alignItems: 'center',
56
- gap: 11,
57
- padding: '9px 13px',
58
- borderRadius: 11,
59
- border: `1px solid ${r.bd}`,
60
- background: r.bg,
61
- marginBottom: 9,
62
- }}
63
- >
64
- <span style={{ color: r.fg, flexShrink: 0, display: 'inline-flex' }}>
65
- {icons.shield(17)}
66
- </span>
67
- <div style={{ flex: 1, minWidth: 0 }}>
68
- <div style={{ display: 'flex', alignItems: 'center', gap: 7 }}>
69
- <span
70
- style={{
71
- fontSize: 13,
72
- fontWeight: 600,
73
- color: 'hsl(var(--ink))',
74
- overflow: 'hidden',
75
- textOverflow: 'ellipsis',
76
- whiteSpace: 'nowrap',
77
- }}
78
- >
79
- {request.title}
80
- </span>
81
- <RiskPill tier={request.riskTier} size="xs" />
82
- </div>
83
- <div
84
- style={{
85
- fontSize: 11.5,
86
- color: 'hsl(var(--ink-3))',
87
- overflow: 'hidden',
88
- textOverflow: 'ellipsis',
89
- whiteSpace: 'nowrap',
90
- }}
91
- >
92
- {request.biomeName} · awaiting your approval
93
- </div>
94
- </div>
95
- {onReview && (
96
- <ApprovalButton variant="ghost" size="sm" onClick={onReview}>
97
- Review
98
- </ApprovalButton>
99
- )}
100
- <ApprovalButton
101
- variant="ghost"
102
- size="sm"
103
- onClick={() => onResolve(ApprovalDecision.Denied, request)}
104
- >
105
- Deny
106
- </ApprovalButton>
107
- <ApprovalButton
108
- variant="primary"
109
- size="sm"
110
- icon={icons.check(13)}
111
- accent={explicit ? r.fg : accent}
112
- onClick={() => onResolve(ApprovalDecision.Approved, request)}
113
- >
114
- Approve
115
- </ApprovalButton>
116
- </div>
117
- );
118
- }
@@ -1,111 +0,0 @@
1
- /**
2
- * Obligation chip + quorum dots.
3
- *
4
- * `Obligation` renders one obligation as a chip: host-supplied icon (via
5
- * `renderIcon` from the stable `ObligationIcon` key) + label + optional
6
- * pre-formatted mono value. An obligation whose `kind` is outside the
7
- * known `PolicyObligationKind` map fails SAFE to a visible "unknown"
8
- * chip (shield glyph + the raw kind) — never a silent drop.
9
- *
10
- * `QuorumDots` renders `have/need` approver dots (filled = collected).
11
- */
12
- import { OBLIGATION_DISPLAY, ObligationIcon } from './obligation-display';
13
-
14
- import type { ApprovalObligation } from './approval-model';
15
- import type { ReactElement, ReactNode } from 'react';
16
-
17
- export interface ObligationProps {
18
- readonly obligation: ApprovalObligation;
19
- /** Host icon renderer for a stable `ObligationIcon` key (kit is icon-agnostic). */
20
- readonly renderIcon: (key: ObligationIcon, size: number) => ReactNode;
21
- }
22
-
23
- export function Obligation({
24
- obligation,
25
- renderIcon,
26
- }: ObligationProps): ReactElement {
27
- // Known kinds resolve to a label + icon key; an unknown discriminant
28
- // (a not-yet-mapped kernel kind) renders a visible fallback rather than
29
- // disappearing — fail-fast, but on screen.
30
- const meta = OBLIGATION_DISPLAY[obligation.kind];
31
- const iconKey = meta?.iconKey ?? ObligationIcon.ShieldCheck;
32
- const label = meta?.label ?? `unknown: ${obligation.kind}`;
33
- return (
34
- <span
35
- style={{
36
- display: 'inline-flex',
37
- alignItems: 'center',
38
- gap: 5,
39
- padding: '3px 8px',
40
- borderRadius: 6,
41
- whiteSpace: 'nowrap',
42
- background: 'hsl(var(--muted))',
43
- border: '1px solid hsl(var(--rule))',
44
- fontSize: 11.5,
45
- color: 'hsl(var(--ink-2))',
46
- }}
47
- >
48
- <span style={{ color: 'hsl(var(--ink-3))', display: 'inline-flex' }}>
49
- {renderIcon(iconKey, 12)}
50
- </span>
51
- <span style={{ color: 'hsl(var(--ink-3))' }}>{label}</span>
52
- {obligation.value && (
53
- <span
54
- className="mono"
55
- style={{ fontSize: 11, color: 'hsl(var(--ink))', fontWeight: 500 }}
56
- >
57
- {obligation.value}
58
- </span>
59
- )}
60
- </span>
61
- );
62
- }
63
-
64
- export interface QuorumDotsProps {
65
- readonly have: number;
66
- readonly need: number;
67
- /** Host icon for the leading "users" glyph. */
68
- readonly usersIcon?: ReactNode;
69
- }
70
-
71
- export function QuorumDots({
72
- have,
73
- need,
74
- usersIcon,
75
- }: QuorumDotsProps): ReactElement {
76
- return (
77
- <span
78
- style={{
79
- display: 'inline-flex',
80
- alignItems: 'center',
81
- gap: 6,
82
- fontSize: 12,
83
- color: 'hsl(var(--ink-3))',
84
- }}
85
- >
86
- {usersIcon}
87
- <span style={{ display: 'inline-flex', gap: 3 }}>
88
- {Array.from({ length: need }).map((_, i) => {
89
- const filled = i < have;
90
- return (
91
- <span
92
- key={`quorum-${i}`}
93
- style={{
94
- width: 7,
95
- height: 7,
96
- borderRadius: '50%',
97
- background: filled ? 'hsl(var(--success))' : 'transparent',
98
- border: `1.5px solid ${
99
- filled ? 'hsl(var(--success))' : 'hsl(var(--rule-2))'
100
- }`,
101
- }}
102
- />
103
- );
104
- })}
105
- </span>
106
- <span className="mono" style={{ fontSize: 11 }}>
107
- {have}/{need} approvers
108
- </span>
109
- </span>
110
- );
111
- }
@@ -1,392 +0,0 @@
1
- /**
2
- * Scoped approval bodies — the biome-supplied typed detail
3
- * that renders UNDER the generic frame.
4
- *
5
- * `ScopedBody` is an EXHAUSTIVE switch over `ApprovalScopeKind`. A scope
6
- * whose `kind` is outside the closed set fails SAFE to a visible
7
- * "unknown scope" placeholder (it surfaces the raw kind) rather than
8
- * silently dropping the body — the same fail-fast-but-visible contract as
9
- * the unknown-obligation and unknown-chat-widget paths.
10
- *
11
- * Icon-agnostic: bodies that need a glyph take a `renderIcon` mapping a
12
- * stable `ScopeIcon` key to a host icon node.
13
- */
14
- import {
15
- ApprovalScopeKind,
16
- type ApprovalScope,
17
- type DeployScope,
18
- type FilesScope,
19
- type PaymentScope,
20
- type SlackScope,
21
- type SqlScope,
22
- } from './approval-model';
23
- import { ScopeIcon, type ScopeIconRenderer } from './scope-icons';
24
-
25
- import type { ReactElement, ReactNode } from 'react';
26
-
27
- export interface ScopedBodyProps {
28
- readonly scope: ApprovalScope;
29
- readonly renderIcon: ScopeIconRenderer;
30
- }
31
-
32
- export function ScopedBody({
33
- scope,
34
- renderIcon,
35
- }: ScopedBodyProps): ReactElement {
36
- switch (scope.kind) {
37
- case ApprovalScopeKind.Payment:
38
- return <PaymentBody s={scope} />;
39
- case ApprovalScopeKind.Sql:
40
- return <SqlBody s={scope} renderIcon={renderIcon} />;
41
- case ApprovalScopeKind.Slack:
42
- return <SlackBody s={scope} renderIcon={renderIcon} />;
43
- case ApprovalScopeKind.Deploy:
44
- return <DeployBody s={scope} renderIcon={renderIcon} />;
45
- case ApprovalScopeKind.Files:
46
- return <FilesBody s={scope} renderIcon={renderIcon} />;
47
- default:
48
- return <UnknownScopeBody scope={scope} />;
49
- }
50
- }
51
-
52
- /** Visible fallback for a scope kind the host does not (yet) understand. */
53
- function UnknownScopeBody({
54
- scope,
55
- }: Readonly<{ scope: { readonly kind: string } }>): ReactElement {
56
- return (
57
- <div
58
- style={{
59
- padding: '8px 11px',
60
- borderRadius: 7,
61
- border: '1px dashed hsl(var(--rule-2))',
62
- background: 'hsl(var(--muted))',
63
- fontSize: 12,
64
- color: 'hsl(var(--ink-3))',
65
- }}
66
- >
67
- Unknown approval detail{' '}
68
- <span className="mono" style={{ color: 'hsl(var(--ink-2))' }}>
69
- {scope.kind}
70
- </span>{' '}
71
- — this biome ships a scope kind this host build cannot render. Review
72
- the request before deciding.
73
- </div>
74
- );
75
- }
76
-
77
- function KV({
78
- k,
79
- v,
80
- mono,
81
- strong,
82
- }: Readonly<{
83
- k: string;
84
- v: ReactNode;
85
- mono?: boolean;
86
- strong?: boolean;
87
- }>): ReactElement {
88
- return (
89
- <div
90
- style={{
91
- display: 'flex',
92
- justifyContent: 'space-between',
93
- gap: 12,
94
- padding: '3px 0',
95
- }}
96
- >
97
- <span
98
- style={{ fontSize: 12, color: 'hsl(var(--ink-3))', whiteSpace: 'nowrap' }}
99
- >
100
- {k}
101
- </span>
102
- <span
103
- className={mono ? 'mono' : undefined}
104
- style={{
105
- fontSize: mono ? 12 : 12.5,
106
- color: 'hsl(var(--ink))',
107
- fontWeight: strong ? 600 : 450,
108
- textAlign: 'right',
109
- whiteSpace: 'nowrap',
110
- }}
111
- >
112
- {v}
113
- </span>
114
- </div>
115
- );
116
- }
117
-
118
- function PaymentBody({ s }: Readonly<{ s: PaymentScope }>): ReactElement {
119
- return (
120
- <div>
121
- <div style={{ marginBottom: 9 }}>
122
- <div
123
- className="serif"
124
- style={{
125
- fontSize: 27,
126
- fontWeight: 600,
127
- color: 'hsl(var(--ink))',
128
- lineHeight: 1.05,
129
- }}
130
- >
131
- {s.amount}
132
- </div>
133
- <div
134
- style={{ fontSize: 12.5, color: 'hsl(var(--ink-3))', marginTop: 2 }}
135
- >
136
- to {s.payee}
137
- </div>
138
- </div>
139
- <div style={{ borderTop: '1px solid hsl(var(--rule))', paddingTop: 4 }}>
140
- <KV k="Method" v={s.method} />
141
- <KV k="Account" v={s.account} mono />
142
- {s.memo && <KV k="Memo" v={s.memo} />}
143
- </div>
144
- </div>
145
- );
146
- }
147
-
148
- function SqlBody({
149
- s,
150
- renderIcon,
151
- }: Readonly<{ s: SqlScope; renderIcon: ScopeIconRenderer }>): ReactElement {
152
- return (
153
- <div>
154
- <div
155
- style={{ display: 'flex', gap: 8, marginBottom: 7, flexWrap: 'wrap' }}
156
- >
157
- <Tag icon={renderIcon(ScopeIcon.Database, 12)} t={s.dialect} />
158
- <Tag icon={renderIcon(ScopeIcon.Layers, 12)} t={s.table} />
159
- <Tag
160
- icon={renderIcon(ScopeIcon.Alert, 12)}
161
- t={`${s.rowsAffected} rows`}
162
- warn
163
- />
164
- </div>
165
- <pre
166
- className="mono"
167
- style={{
168
- margin: 0,
169
- padding: '10px 12px',
170
- background: 'hsl(var(--ink) / 0.04)',
171
- border: '1px solid hsl(var(--rule))',
172
- borderRadius: 8,
173
- fontSize: 12,
174
- lineHeight: 1.6,
175
- color: 'hsl(var(--ink))',
176
- overflowX: 'auto',
177
- whiteSpace: 'pre',
178
- }}
179
- >
180
- {s.query}
181
- </pre>
182
- </div>
183
- );
184
- }
185
-
186
- function SlackBody({
187
- s,
188
- renderIcon,
189
- }: Readonly<{ s: SlackScope; renderIcon: ScopeIconRenderer }>): ReactElement {
190
- return (
191
- <div>
192
- <div
193
- style={{
194
- display: 'flex',
195
- alignItems: 'center',
196
- gap: 8,
197
- marginBottom: 7,
198
- fontSize: 12.5,
199
- }}
200
- >
201
- <span style={{ color: 'hsl(var(--ink-3))', display: 'inline-flex' }}>
202
- {renderIcon(ScopeIcon.Send, 13)}
203
- </span>
204
- <span
205
- className="mono"
206
- style={{ color: 'hsl(var(--ink))', fontWeight: 600 }}
207
- >
208
- {s.channel}
209
- </span>
210
- <span style={{ color: 'hsl(var(--ink-4))' }}>
211
- · {s.workspace} · as {s.as}
212
- </span>
213
- </div>
214
- <div
215
- style={{
216
- padding: '10px 12px',
217
- background: 'hsl(var(--paper-elev))',
218
- border: '1px solid hsl(var(--rule))',
219
- borderRadius: 8,
220
- fontSize: 13,
221
- lineHeight: 1.55,
222
- color: 'hsl(var(--ink-2))',
223
- whiteSpace: 'pre-wrap',
224
- }}
225
- >
226
- {s.message}
227
- </div>
228
- </div>
229
- );
230
- }
231
-
232
- function DeployBody({
233
- s,
234
- renderIcon,
235
- }: Readonly<{ s: DeployScope; renderIcon: ScopeIconRenderer }>): ReactElement {
236
- return (
237
- <div>
238
- <div
239
- style={{
240
- display: 'flex',
241
- alignItems: 'center',
242
- gap: 8,
243
- marginBottom: 8,
244
- }}
245
- >
246
- <span
247
- className="mono serif"
248
- style={{ fontSize: 18, fontWeight: 600, color: 'hsl(var(--ink))' }}
249
- >
250
- {s.version}
251
- </span>
252
- <span style={{ color: 'hsl(var(--ink-4))', display: 'inline-flex' }}>
253
- {renderIcon(ScopeIcon.ArrowRight, 14)}
254
- </span>
255
- <Tag icon={renderIcon(ScopeIcon.Globe, 12)} t={s.cluster} warn />
256
- </div>
257
- <div style={{ display: 'flex', gap: 14, marginBottom: 8 }}>
258
- <Stat2 n={s.services} l="services" />
259
- <Stat2 n={s.migrations} l="migrations" warn />
260
- </div>
261
- <div style={{ display: 'flex', flexDirection: 'column', gap: 3 }}>
262
- {s.changelog.map((c) => (
263
- <div
264
- key={c}
265
- style={{
266
- display: 'flex',
267
- gap: 8,
268
- fontSize: 12,
269
- color: 'hsl(var(--ink-2))',
270
- }}
271
- >
272
- <span
273
- style={{
274
- marginTop: 7,
275
- width: 3,
276
- height: 3,
277
- borderRadius: '50%',
278
- background: 'hsl(var(--ink-4))',
279
- flexShrink: 0,
280
- }}
281
- />
282
- <span className="mono" style={{ fontSize: 11.5 }}>
283
- {c}
284
- </span>
285
- </div>
286
- ))}
287
- </div>
288
- </div>
289
- );
290
- }
291
-
292
- function FilesBody({
293
- s,
294
- renderIcon,
295
- }: Readonly<{ s: FilesScope; renderIcon: ScopeIconRenderer }>): ReactElement {
296
- return (
297
- <div style={{ display: 'flex', flexDirection: 'column', gap: 5 }}>
298
- {s.files.map((f) => (
299
- <div
300
- key={f.path}
301
- style={{
302
- display: 'flex',
303
- alignItems: 'center',
304
- gap: 9,
305
- padding: '5px 9px',
306
- background: 'hsl(var(--paper-elev))',
307
- border: '1px solid hsl(var(--rule))',
308
- borderRadius: 7,
309
- }}
310
- >
311
- <span style={{ color: 'hsl(var(--warning))', display: 'inline-flex' }}>
312
- {renderIcon(ScopeIcon.FileEdit, 13)}
313
- </span>
314
- <span
315
- className="mono"
316
- style={{
317
- fontSize: 12,
318
- color: 'hsl(var(--ink))',
319
- flex: 1,
320
- overflow: 'hidden',
321
- textOverflow: 'ellipsis',
322
- whiteSpace: 'nowrap',
323
- }}
324
- >
325
- {f.path}
326
- </span>
327
- <span
328
- className="mono"
329
- style={{ fontSize: 11, color: 'hsl(var(--success))' }}
330
- >
331
- +{f.add}
332
- </span>
333
- <span
334
- className="mono"
335
- style={{ fontSize: 11, color: 'hsl(var(--danger))' }}
336
- >
337
- −{f.del}
338
- </span>
339
- </div>
340
- ))}
341
- </div>
342
- );
343
- }
344
-
345
- function Tag({
346
- icon,
347
- t,
348
- warn,
349
- }: Readonly<{ icon: ReactNode; t: string; warn?: boolean }>): ReactElement {
350
- return (
351
- <span
352
- style={{
353
- display: 'inline-flex',
354
- alignItems: 'center',
355
- gap: 5,
356
- padding: '2px 8px',
357
- borderRadius: 6,
358
- fontSize: 11.5,
359
- background: warn ? 'hsl(var(--warning) / 0.1)' : 'hsl(var(--muted))',
360
- border: `1px solid ${
361
- warn ? 'hsl(var(--warning) / 0.3)' : 'hsl(var(--rule))'
362
- }`,
363
- color: warn ? 'hsl(var(--warning))' : 'hsl(var(--ink-2))',
364
- }}
365
- >
366
- {icon}
367
- {t}
368
- </span>
369
- );
370
- }
371
-
372
- function Stat2({
373
- n,
374
- l,
375
- warn,
376
- }: Readonly<{ n: number; l: string; warn?: boolean }>): ReactElement {
377
- return (
378
- <span style={{ display: 'inline-flex', alignItems: 'baseline', gap: 5 }}>
379
- <span
380
- className="serif"
381
- style={{
382
- fontSize: 18,
383
- fontWeight: 600,
384
- color: warn ? 'hsl(var(--warning))' : 'hsl(var(--ink))',
385
- }}
386
- >
387
- {n}
388
- </span>
389
- <span style={{ fontSize: 11.5, color: 'hsl(var(--ink-3))' }}>{l}</span>
390
- </span>
391
- );
392
- }
@@ -1,31 +0,0 @@
1
- /**
2
- * The icon contract for the approval surfaces. The kit is icon-agnostic
3
- * (it never imports an icon set), so the host supplies one bundle that
4
- * resolves every glyph the approval frame, scoped bodies, obligation
5
- * chips and Center need. Keeping it as a single typed bundle means a
6
- * consumer wires icons ONCE and passes it to every approval surface.
7
- */
8
- import type { ObligationIcon } from './obligation-display';
9
- import type { ScopeIcon } from './scope-icons';
10
- import type { ReactNode } from 'react';
11
-
12
- export interface ApprovalIcons {
13
- /** Map a stable obligation-chip glyph key → host icon node. */
14
- readonly obligation: (key: ObligationIcon, size: number) => ReactNode;
15
- /** Map a stable scoped-body glyph key → host icon node. */
16
- readonly scope: (key: ScopeIcon, size: number) => ReactNode;
17
- /** Frame: the "approval required" / approve shield. */
18
- readonly shield: (size: number) => ReactNode;
19
- /** Frame: capability-ref leading bolt. */
20
- readonly capability: (size: number) => ReactNode;
21
- /** Frame: approver-role person glyph. */
22
- readonly user: (size: number) => ReactNode;
23
- /** Quorum: multi-approver glyph. */
24
- readonly users: (size: number) => ReactNode;
25
- /** Resolved state: approved tick. */
26
- readonly approved: (size: number) => ReactNode;
27
- /** Resolved state: denied cross. */
28
- readonly denied: (size: number) => ReactNode;
29
- /** Generic small check (action buttons / Center). */
30
- readonly check: (size: number) => ReactNode;
31
- }