@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,274 +0,0 @@
1
- // ═══════════════════════════════════════════════════════════════════════════
2
- // Guided-capture field spec — the ONE schema shape the capture kit consumes
3
- //
4
- // This is the frontend-agnostic superset of app-forge-web's `AppField`. The
5
- // wire/definition layer (app-forge-api, its renderer's `AppFieldType`) owns 10
6
- // closed field types; this kit mirrors those 10 verbatim (same string values,
7
- // so an `AppField` is structurally assignable to `CaptureFieldSpec`) and ADDS
8
- // two structural composites — `object` and `list` — plus optional `section`
9
- // grouping. A workbench therefore extends ONE renderer (`<SchemaForm>`) instead
10
- // of the three parallel schema→form implementations that exist today.
11
- //
12
- // Value shape produced/consumed:
13
- // scalar field → string | number | boolean (per type)
14
- // object field → Record<string, unknown> (nested record)
15
- // list field → unknown[] (array of item records)
16
- // ═══════════════════════════════════════════════════════════════════════════
17
-
18
- /**
19
- * Closed set of capture field types. The first ten are value-identical to
20
- * app-forge-web's `AppFieldType` (`string`/`text`/`number`/`decimal`/`boolean`/
21
- * `date`/`datetime`/`enum`/`reference`/`user`) so definitions authored for the
22
- * App Platform pass straight through. `object`/`list` are the structural
23
- * composites this kit adds for nested + repeatable capture.
24
- *
25
- * The string VALUES are the contract — keep the first ten identical to
26
- * `AppFieldType` in `@xemahq/kernel-contracts/app-definition` (the single
27
- * source of truth for App Platform field types). Adding a value here that
28
- * `AppFieldType` lacks is fine (superset); changing an existing shared value is
29
- * not. This kit can't import the enum (it adds members), so the shared values
30
- * are mirrored deliberately.
31
- */
32
- export enum CaptureFieldType {
33
- String = 'string',
34
- Text = 'text',
35
- Number = 'number',
36
- Decimal = 'decimal',
37
- Boolean = 'boolean',
38
- Date = 'date',
39
- Datetime = 'datetime',
40
- Enum = 'enum',
41
- Reference = 'reference',
42
- User = 'user',
43
- Object = 'object',
44
- List = 'list',
45
- // ── Media capture (field-capture kit) ──
46
- // Value is a data-URL string (base64), so it stays JSON-serializable and
47
- // flows unchanged through the record model + the offline outbox. `Image`
48
- // opens the device camera on mobile (`capture`), `File` attaches any file,
49
- // `Audio` records a voice memo via MediaRecorder.
50
- Image = 'image',
51
- File = 'file',
52
- Audio = 'audio',
53
- // ── Scalar text refinements (absorbed from the connector credential form) ──
54
- // These change only the NATIVE INPUT TYPE (keyboard + browser affordances);
55
- // the value is a plain string. `Json` additionally renders as a mono textarea
56
- // and is validated as parseable JSON.
57
- Email = 'email',
58
- Url = 'url',
59
- Json = 'json',
60
- }
61
-
62
- /**
63
- * Normalization applied to a captured STRING value at the input boundary.
64
- *
65
- * Value-identical in meaning to the connector `CredentialFieldTransform`
66
- * (`NONE`/`UPPERCASE`/`LOWERCASE`/`TRIM`) but named in this kit's lowercase
67
- * vocabulary, because the capture kit is domain-agnostic and must not import a
68
- * connector contract. The connector→capture adapter lives at the consuming
69
- * seam, not here.
70
- *
71
- * This is the ONLY normalization the kit performs. There is deliberately no
72
- * blanket trim on submit: an undeclared transform would silently override a
73
- * field that declared {@link CaptureFieldTransform.None}.
74
- */
75
- export enum CaptureFieldTransform {
76
- None = 'none',
77
- Uppercase = 'uppercase',
78
- Lowercase = 'lowercase',
79
- Trim = 'trim',
80
- }
81
-
82
- /** Apply a declared transform to a string value. Total; absent = unchanged. */
83
- export function applyCaptureTransform(
84
- value: string,
85
- transform: CaptureFieldTransform | `${CaptureFieldTransform}` | undefined,
86
- ): string {
87
- switch (transform) {
88
- case CaptureFieldTransform.Uppercase:
89
- return value.toUpperCase();
90
- case CaptureFieldTransform.Lowercase:
91
- return value.toLowerCase();
92
- case CaptureFieldTransform.Trim:
93
- return value.trim();
94
- case CaptureFieldTransform.None:
95
- case undefined:
96
- return value;
97
- default:
98
- return value;
99
- }
100
- }
101
-
102
- /**
103
- * A single capture field. Structural superset of app-forge's `AppField`:
104
- * `key`/`label`/`type`/`required`/`enumValues`/`referenceEntity` carry the
105
- * exact same meaning, so `AppField[]` can be handed to this kit unchanged. The
106
- * extra props are additive and all optional.
107
- *
108
- * `type` accepts the {@link CaptureFieldType} enum OR its bare string value, so
109
- * `{ type: 'string' }` (app-forge shape) and `{ type: CaptureFieldType.String }`
110
- * both type-check.
111
- */
112
- export interface CaptureFieldSpec {
113
- readonly key: string;
114
- readonly label: string;
115
- readonly type: CaptureFieldType | `${CaptureFieldType}`;
116
- readonly required?: boolean;
117
- /** Helper text rendered under the label. */
118
- readonly description?: string;
119
- /** Placeholder for text-like inputs. */
120
- readonly placeholder?: string;
121
- /** Only for `enum` — the allowed values. */
122
- readonly enumValues?: readonly string[];
123
- /** Only for `reference` — key of the target entity (opaque to this kit). */
124
- readonly referenceEntity?: string;
125
- /** Only for `object`/`list` — the nested item shape. */
126
- readonly fields?: readonly CaptureFieldSpec[];
127
- /** `number`/`decimal`: numeric bounds. `list`: min/max item count. */
128
- readonly min?: number;
129
- readonly max?: number;
130
- /**
131
- * `image`/`file`/`audio`: the `accept` filter for the file picker (e.g.
132
- * `image/*`, `application/pdf`). Defaults per type when omitted.
133
- */
134
- readonly accept?: string;
135
- /**
136
- * `image`/`file`: the HTML `capture` hint — `environment` opens the rear
137
- * camera, `user` the front camera. Omitted = a normal file picker.
138
- */
139
- readonly capture?: 'user' | 'environment';
140
- /**
141
- * Optional section grouping key for FLAT `CaptureFieldSpec[]` schemas. When a
142
- * schema is expressed as {@link CaptureSection}[] this is ignored (grouping is
143
- * explicit). See {@link groupFieldsBySection}.
144
- */
145
- readonly section?: string;
146
- /**
147
- * DECLARED write-only secrecy. When true the input is masked, never
148
- * pre-filled from a read, and never echoed back by any read path.
149
- *
150
- * Secrecy is DECLARED, never inferred from {@link type}: a plain-`string`
151
- * field can be a secret and a `password`-shaped field can be public. The
152
- * renderer reads this flag and nothing else — do not re-introduce a
153
- * `type === password` inference.
154
- */
155
- readonly isSecret?: boolean;
156
- /**
157
- * Declared normalization applied to the string value at the input boundary.
158
- * Absent = {@link CaptureFieldTransform.None}.
159
- */
160
- readonly transform?: CaptureFieldTransform | `${CaptureFieldTransform}`;
161
- }
162
-
163
- /** A titled group of fields — the explicit sectioned schema shape. */
164
- export interface CaptureSection {
165
- readonly key: string;
166
- readonly title: string;
167
- readonly description?: string;
168
- readonly fields: readonly CaptureFieldSpec[];
169
- }
170
-
171
- /**
172
- * A capture schema is EITHER a flat field list OR a list of titled sections.
173
- * `<SchemaForm>`, `useSchemaValidation`, and `<DocumentPreview>` all accept
174
- * either face.
175
- */
176
- export type CaptureSchema =
177
- | {
178
- readonly fields: readonly CaptureFieldSpec[];
179
- readonly sections?: undefined;
180
- }
181
- | {
182
- readonly sections: readonly CaptureSection[];
183
- readonly fields?: undefined;
184
- };
185
-
186
- /** Structured record value the capture kit reads/writes. */
187
- export type CaptureValues = Record<string, unknown>;
188
-
189
- /** True if `x` is the sectioned face of a schema. */
190
- export function isSectioned(
191
- x: CaptureSchema | readonly CaptureFieldSpec[] | readonly CaptureSection[],
192
- ): x is { readonly sections: readonly CaptureSection[] } {
193
- return (
194
- !Array.isArray(x) &&
195
- 'sections' in (x as object) &&
196
- Array.isArray((x as { sections?: unknown }).sections)
197
- );
198
- }
199
-
200
- /**
201
- * Normalize any accepted schema face to the flat list of TOP-LEVEL fields.
202
- * (Nested `object`/`list` item fields are NOT flattened — they belong to their
203
- * parent's value.) Accepts a `CaptureFieldSpec[]`, a `CaptureSection[]`, or a
204
- * `CaptureSchema`.
205
- */
206
- export function toFieldList(
207
- schema:
208
- | CaptureSchema
209
- | readonly CaptureFieldSpec[]
210
- | readonly CaptureSection[],
211
- ): readonly CaptureFieldSpec[] {
212
- if (Array.isArray(schema)) {
213
- const arr = schema as readonly (CaptureFieldSpec | CaptureSection)[];
214
- // A CaptureSection has `title`+`fields`; a CaptureFieldSpec has `type`.
215
- if (
216
- arr.length > 0 &&
217
- arr.every((e) => 'title' in e && 'fields' in e && !('type' in e))
218
- ) {
219
- return (arr as readonly CaptureSection[]).flatMap((s) => s.fields);
220
- }
221
- return arr as readonly CaptureFieldSpec[];
222
- }
223
- if (isSectioned(schema)) {
224
- return schema.sections.flatMap((s) => s.fields);
225
- }
226
- return (schema as { fields: readonly CaptureFieldSpec[] }).fields;
227
- }
228
-
229
- /**
230
- * Resolve any accepted schema face to `CaptureSection[]`. A flat field list
231
- * collapses to a single untitled section (or is split by each field's
232
- * `section` key when present).
233
- */
234
- export function toSections(
235
- schema:
236
- | CaptureSchema
237
- | readonly CaptureFieldSpec[]
238
- | readonly CaptureSection[],
239
- fallbackTitle = '',
240
- ): readonly CaptureSection[] {
241
- if (
242
- Array.isArray(schema) &&
243
- schema.length > 0 &&
244
- (schema as readonly object[]).every((e) => 'title' in e && 'fields' in e)
245
- ) {
246
- return schema as readonly CaptureSection[];
247
- }
248
- if (!Array.isArray(schema) && isSectioned(schema)) {
249
- return schema.sections;
250
- }
251
- return groupFieldsBySection(toFieldList(schema), fallbackTitle);
252
- }
253
-
254
- /** Split a flat field list into sections by each field's `section` key. */
255
- export function groupFieldsBySection(
256
- fields: readonly CaptureFieldSpec[],
257
- fallbackTitle = '',
258
- ): readonly CaptureSection[] {
259
- const order: string[] = [];
260
- const byKey = new Map<string, CaptureFieldSpec[]>();
261
- for (const f of fields) {
262
- const key = f.section ?? '';
263
- if (!byKey.has(key)) {
264
- byKey.set(key, []);
265
- order.push(key);
266
- }
267
- byKey.get(key)!.push(f);
268
- }
269
- return order.map((key) => ({
270
- key: key || '_',
271
- title: key || fallbackTitle,
272
- fields: byKey.get(key)!,
273
- }));
274
- }
@@ -1,51 +0,0 @@
1
- // ═══════════════════════════════════════════════════════════════════════════
2
- // @xemahq/ui-kernel — guided-capture UX kit (B5)
3
- //
4
- // Headless engines + presentation-thin primitives for schema-driven, guided
5
- // data capture: a wizard state machine, live client-side validation, AI/context
6
- // pre-fill, a single consolidated schema→form renderer, and a review-step
7
- // document preview. Consolidates the three parallel schema→form implementations
8
- // so a workbench extends ONE renderer.
9
- // ═══════════════════════════════════════════════════════════════════════════
10
-
11
- // ── field-spec model (aligned superset of app-forge's AppFieldType) ──
12
- export {
13
- CaptureFieldType,
14
- CaptureFieldTransform,
15
- applyCaptureTransform,
16
- isSectioned,
17
- toFieldList,
18
- toSections,
19
- groupFieldsBySection,
20
- type CaptureFieldSpec,
21
- type CaptureSection,
22
- type CaptureSchema,
23
- type CaptureValues,
24
- } from './field-spec';
25
-
26
- // ── total runtime validator for a wire-carried schema ──
27
- export { validateCaptureField, validateCaptureFields } from './field-spec-validate';
28
-
29
- // ── schema → zod adapter ──
30
- export { fieldSpecToZod, isEmptyValue, isParsableJson } from './field-spec-to-zod';
31
-
32
- // ── values → wire payload ──
33
- export { captureValuesToStringMap, captureValuesToSubmitPayload } from './submit-values';
34
-
35
- // ── validation + "missing info" ──
36
- export { useSchemaValidation, type SchemaValidationResult } from './use-schema-validation';
37
-
38
- // ── pre-fill ──
39
- export { usePrefill, type UsePrefillOptions, type UsePrefillResult } from './use-prefill';
40
-
41
- // ── wizard engine + shell ──
42
- export { useWizard, type WizardApi, type WizardStepDef, type UseWizardOptions } from './use-wizard';
43
- export { Wizard, WizardStep, type WizardProps, type WizardStepProps } from './wizard';
44
-
45
- // ── consolidated schema form ──
46
- export { SchemaForm, type SchemaFormProps } from './schema-form';
47
- export { SchemaFieldInput, type SchemaFieldInputProps, type RenderReference } from './schema-field-input';
48
- export { asString, formatScalar } from './value-format';
49
-
50
- // ── review-step document preview ──
51
- export { DocumentPreview, type DocumentPreviewProps } from './document-preview';