@constructive-io/blocks-ui 0.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Constructive
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,117 @@
1
+ # @constructive-io/blocks-ui
2
+
3
+ <p align="center" width="100%">
4
+ <img height="250" src="https://raw.githubusercontent.com/constructive-io/constructive/refs/heads/main/assets/outline-logo.svg" />
5
+ </p>
6
+
7
+ <p align="center" width="100%">
8
+ <a href="https://github.com/constructive-io/blocks/actions/workflows/ci.yml">
9
+ <img height="20" src="https://github.com/constructive-io/blocks/actions/workflows/ci.yml/badge.svg" />
10
+ </a>
11
+ <a href="https://github.com/constructive-io/blocks/blob/main/LICENSE"><img height="20" src="https://img.shields.io/badge/license-MIT-blue.svg"/></a>
12
+ <a href="https://www.npmjs.com/package/@constructive-io/blocks-ui"><img height="20" src="https://img.shields.io/github/package-json/v/constructive-io/blocks?filename=packages%2Fblocks-ui%2Fpackage.json"/></a>
13
+ </p>
14
+
15
+ The default widget registry for [`blocks-renderer`](../blocks-renderer): every
16
+ Constructive document node type wired to a `@constructive-io/ui` component.
17
+
18
+ `blocks-renderer` walks a `UIDocument` and asks a registry "what renders a
19
+ `Select`?". This package answers that question so a generated document renders
20
+ without any host wiring — and, because it is a plain `type → component` map, it
21
+ doubles as the worked example for writing your own.
22
+
23
+ ```bash
24
+ pnpm add @constructive-io/blocks-ui
25
+ ```
26
+
27
+ ```tsx
28
+ 'use client';
29
+
30
+ import { DocumentRenderer } from 'blocks-renderer';
31
+ import { defaultBlockRegistry } from '@constructive-io/blocks-ui';
32
+ import { schemaToDocument } from 'json-schema-to-blocks';
33
+
34
+ const document = schemaToDocument({
35
+ type: 'object',
36
+ required: ['title'],
37
+ properties: {
38
+ title: { type: 'string', maxLength: 120 },
39
+ status: { type: 'string', enum: ['draft', 'review', 'live'] },
40
+ featured: { type: 'boolean' }
41
+ }
42
+ });
43
+
44
+ export function PostForm() {
45
+ return (
46
+ <DocumentRenderer
47
+ document={document}
48
+ registry={defaultBlockRegistry}
49
+ onSubmit={(values) => console.log(values)}
50
+ />
51
+ );
52
+ }
53
+ ```
54
+
55
+ ## Replacing components
56
+
57
+ The registry is data, so layer over it instead of forking it. `composeRegistry`
58
+ applies the later registry on top, type by type:
59
+
60
+ ```tsx
61
+ import { composeRegistry } from 'blocks-renderer';
62
+ import { defaultBlockRegistry } from '@constructive-io/blocks-ui';
63
+
64
+ const registry = composeRegistry(defaultBlockRegistry, {
65
+ Select: MyCombobox,
66
+ DataTable: MyDataTable
67
+ });
68
+ ```
69
+
70
+ Take a subset if the page chrome is yours: `widgetRegistry` (the form
71
+ controls), `containerRegistry` (`Page`, `Form`, `Section`, `Grid`, `Tabs`), and
72
+ `blockRegistry` (`Button`, `ActionBar`, `Markdown`, `StatCard`) are exported
73
+ separately.
74
+
75
+ Writing an adapter from scratch needs nothing from this package — a registry is
76
+ `Record<string, ComponentType<BlockProps>>`. `useNodeField` and `FieldShell` are
77
+ exported for reuse, and reading them is the fastest way to see how a node's
78
+ `name`, `required`, and `constraints` become renderer form state.
79
+
80
+ ## What is intentionally not registered
81
+
82
+ `DataTable`, `DetailPanel`, `RelationList`, `Chart`, and `AgentChat` need a
83
+ query runtime and a data source, so they are left out and fall back to the
84
+ renderer's visible unknown-node placeholder. Register them with your own
85
+ data-bound components (for example against `@constructive-io/data`).
86
+
87
+ `CodeEditor`, `MarkdownEditor`, and `JsonEditor` render as a monospace textarea:
88
+ a real editor is a heavy dependency, so it belongs in the host that wants it.
89
+ `FileUpload` records the selected file name only — the byte upload needs your
90
+ storage adapter.
91
+
92
+ ## Form state
93
+
94
+ Widgets own no state. Each one reads and writes the `DocumentRenderer` context
95
+ through `useBlockField`, so validation, defaults, and submission stay with the
96
+ renderer and the document's declared constraints:
97
+
98
+ ```tsx
99
+ export function MyInput({ props }: BlockProps) {
100
+ const field = useNodeField(props);
101
+
102
+ return (
103
+ <FieldShell props={props} id={field.id} error={field.error}>
104
+ <input
105
+ id={field.id}
106
+ value={String(field.value ?? '')}
107
+ onChange={(event) => field.setValue(event.target.value)}
108
+ disabled={field.disabled}
109
+ />
110
+ </FieldShell>
111
+ );
112
+ }
113
+ ```
114
+
115
+ ## License
116
+
117
+ MIT
package/dist/index.cjs ADDED
@@ -0,0 +1,440 @@
1
+ 'use strict';
2
+
3
+ var ui = require('@constructive-io/ui');
4
+ var blocksRenderer = require('blocks-renderer');
5
+ var jsxRuntime = require('react/jsx-runtime');
6
+ var react = require('react');
7
+
8
+ function text(props, ...keys) {
9
+ for (const key of keys) {
10
+ const value = props[key];
11
+ if (typeof value === "string") return value;
12
+ }
13
+ return void 0;
14
+ }
15
+ var VARIANTS = /* @__PURE__ */ new Set(["default", "destructive", "outline", "secondary", "ghost", "link"]);
16
+ function ButtonBlock({ node, props }) {
17
+ const { onAction } = blocksRenderer.useRenderer();
18
+ const label = text(props, "text", "label") ?? "Button";
19
+ const variant = text(props, "variant");
20
+ const submits = props.type === "submit" || props.submit === true;
21
+ const action = node.actions?.click;
22
+ return /* @__PURE__ */ jsxRuntime.jsx(
23
+ ui.Button,
24
+ {
25
+ type: submits ? "submit" : "button",
26
+ disabled: Boolean(props.disabled),
27
+ ...variant && VARIANTS.has(variant) ? { variant } : {},
28
+ ...action ? { onClick: () => onAction?.(action, "click") } : {},
29
+ children: label
30
+ }
31
+ );
32
+ }
33
+ function ActionBarBlock({ props, children }) {
34
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["flex flex-wrap items-center gap-2", props.className ? String(props.className) : ""].join(" ").trim(), children });
35
+ }
36
+ function MarkdownBlock({ props }) {
37
+ const content = text(props, "content", "text", "markdown") ?? "";
38
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "whitespace-pre-wrap text-sm leading-relaxed", children: content });
39
+ }
40
+ function StatCardBlock({ props }) {
41
+ const label = text(props, "label", "title") ?? "";
42
+ const value = props.value;
43
+ const description = text(props, "description");
44
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { children: [
45
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.CardHeader, { children: [
46
+ /* @__PURE__ */ jsxRuntime.jsx(ui.CardTitle, { className: "text-sm font-medium text-muted-foreground", children: label }),
47
+ description && /* @__PURE__ */ jsxRuntime.jsx(ui.CardDescription, { children: description })
48
+ ] }),
49
+ /* @__PURE__ */ jsxRuntime.jsx(ui.CardContent, { children: /* @__PURE__ */ jsxRuntime.jsx("span", { className: "text-2xl font-semibold tabular-nums", children: value === null || value === void 0 ? "\u2014" : String(value) }) })
50
+ ] });
51
+ }
52
+ function text2(props, key) {
53
+ const value = props[key];
54
+ return typeof value === "string" ? value : void 0;
55
+ }
56
+ function PageBlock({ props, children }) {
57
+ const title = text2(props, "title");
58
+ const description = text2(props, "description");
59
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: props.className ? String(props.className) : "flex flex-col gap-6", children: [
60
+ (title || description) && /* @__PURE__ */ jsxRuntime.jsxs("header", { className: "flex flex-col gap-1", children: [
61
+ title && /* @__PURE__ */ jsxRuntime.jsx("h1", { className: "text-2xl font-semibold tracking-tight", children: title }),
62
+ description && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "text-muted-foreground", children: description })
63
+ ] }),
64
+ children
65
+ ] });
66
+ }
67
+ function FormBlock({ node, props, children }) {
68
+ const { onAction } = blocksRenderer.useRenderer();
69
+ const submitLabel = text2(props, "submitLabel") ?? (props.mode === "update" ? "Save" : "Submit");
70
+ return /* @__PURE__ */ jsxRuntime.jsxs(
71
+ "form",
72
+ {
73
+ className: "flex flex-col gap-5",
74
+ noValidate: true,
75
+ onSubmit: (event) => {
76
+ event.preventDefault();
77
+ onAction?.(node.actions?.submit ?? { type: "handler", handler: "submit" }, "submit");
78
+ },
79
+ children: [
80
+ children,
81
+ /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex gap-2", children: /* @__PURE__ */ jsxRuntime.jsx(ui.Button, { type: "submit", children: submitLabel }) })
82
+ ]
83
+ }
84
+ );
85
+ }
86
+ function SectionBlock({ props, children }) {
87
+ const title = text2(props, "title");
88
+ if (!title) {
89
+ return /* @__PURE__ */ jsxRuntime.jsx("section", { className: "flex flex-col gap-4", children });
90
+ }
91
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Card, { children: [
92
+ /* @__PURE__ */ jsxRuntime.jsx(ui.CardHeader, { children: /* @__PURE__ */ jsxRuntime.jsx(ui.CardTitle, { children: title }) }),
93
+ /* @__PURE__ */ jsxRuntime.jsx(ui.CardContent, { className: "flex flex-col gap-5", children })
94
+ ] });
95
+ }
96
+ function GridBlock({ props, children }) {
97
+ const columns = typeof props.columns === "number" ? Math.min(Math.max(props.columns, 1), 4) : 2;
98
+ const template = ["grid-cols-1", "md:grid-cols-2", "md:grid-cols-3", "md:grid-cols-4"][columns - 1];
99
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: `grid gap-5 ${template}`, children });
100
+ }
101
+ var SPANS = ["", "md:col-span-2", "md:col-span-3", "md:col-span-4"];
102
+ function GridColumnBlock({ props, children }) {
103
+ const span = typeof props.span === "number" ? Math.min(Math.max(props.span, 1), 4) : 1;
104
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: ["flex flex-col gap-5", SPANS[span - 1]].filter(Boolean).join(" "), children });
105
+ }
106
+ function TabsBlock({ node }) {
107
+ const tabs = node.children ?? [];
108
+ if (tabs.length === 0) return null;
109
+ const first = tabs[0].key;
110
+ return /* @__PURE__ */ jsxRuntime.jsxs(ui.Tabs, { defaultValue: first, children: [
111
+ /* @__PURE__ */ jsxRuntime.jsx(ui.TabsList, { children: tabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(ui.TabsTrigger, { value: tab.key, children: text2(tab.props, "label") ?? text2(tab.props, "title") ?? tab.key }, tab.key)) }),
112
+ tabs.map((tab) => /* @__PURE__ */ jsxRuntime.jsx(ui.TabsContent, { value: tab.key, children: /* @__PURE__ */ jsxRuntime.jsx(blocksRenderer.BlockRenderer, { node: tab }) }, tab.key))
113
+ ] });
114
+ }
115
+ function TabBlock({ children }) {
116
+ return /* @__PURE__ */ jsxRuntime.jsx("div", { className: "flex flex-col gap-5 pt-4", children });
117
+ }
118
+ function useNodeField(props) {
119
+ const name = typeof props.name === "string" ? props.name : void 0;
120
+ const { value, error, setValue, mode } = blocksRenderer.useBlockField(name);
121
+ const id = react.useId();
122
+ return {
123
+ name,
124
+ id,
125
+ value,
126
+ error,
127
+ setValue,
128
+ /** `edit` is the authoring surface, so widgets are inert there. */
129
+ disabled: Boolean(props.disabled) || mode === "edit",
130
+ required: Boolean(props.required),
131
+ placeholder: typeof props.placeholder === "string" ? props.placeholder : void 0
132
+ };
133
+ }
134
+ function FieldShell({ props, id, error, children }) {
135
+ if (props.hidden) return null;
136
+ const label = typeof props.label === "string" ? props.label : props.name ?? "";
137
+ return /* @__PURE__ */ jsxRuntime.jsx(
138
+ ui.Field,
139
+ {
140
+ label,
141
+ htmlFor: id,
142
+ required: Boolean(props.required),
143
+ ...typeof props.description === "string" ? { description: props.description } : {},
144
+ ...error ? { error } : {},
145
+ ...typeof props.className === "string" ? { className: props.className } : {},
146
+ children
147
+ }
148
+ );
149
+ }
150
+ function readOptions(props) {
151
+ const options = props.options;
152
+ if (!Array.isArray(options)) return [];
153
+ return options.map((option) => {
154
+ if (option !== null && typeof option === "object") {
155
+ const entry = option;
156
+ const value2 = String(entry.value ?? "");
157
+ return { label: String(entry.label ?? value2), value: value2 };
158
+ }
159
+ const value = String(option ?? "");
160
+ return { label: value, value };
161
+ });
162
+ }
163
+ function textValue(value) {
164
+ if (value === void 0 || value === null) return "";
165
+ return typeof value === "string" ? value : String(value);
166
+ }
167
+ function inputConstraints(props) {
168
+ const constraints = props.constraints ?? {};
169
+ return {
170
+ ...constraints.minLength != null ? { minLength: constraints.minLength } : {},
171
+ ...constraints.maxLength != null ? { maxLength: constraints.maxLength } : {},
172
+ ...constraints.pattern ? { pattern: constraints.pattern } : {}
173
+ };
174
+ }
175
+ function numericConstraints(props) {
176
+ const constraints = props.constraints ?? {};
177
+ return {
178
+ ...constraints.minValue != null ? { min: constraints.minValue } : {},
179
+ ...constraints.maxValue != null ? { max: constraints.maxValue } : {},
180
+ ...typeof props.step === "number" ? { step: props.step } : {}
181
+ };
182
+ }
183
+ function numberValue(raw) {
184
+ if (raw === "") return null;
185
+ const parsed = Number(raw);
186
+ return Number.isFinite(parsed) ? parsed : raw;
187
+ }
188
+ var ZONE_SUFFIX = /(?:Z|[+-]\d{2}:?\d{2})$/;
189
+ function zonedValue(local, zone) {
190
+ if (local === "") return null;
191
+ if (!zone) return local;
192
+ const seconds = local.length > 16 ? "" : ":00";
193
+ return `${local}${seconds}${zone}`;
194
+ }
195
+ function TextInput({ props, type }) {
196
+ const field = useNodeField(props);
197
+ const inputType = type ?? (typeof props.inputType === "string" ? props.inputType : "text");
198
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
199
+ ui.Input,
200
+ {
201
+ id: field.id,
202
+ name: field.name,
203
+ type: inputType,
204
+ value: textValue(field.value),
205
+ onChange: (event) => field.setValue(event.target.value),
206
+ disabled: field.disabled,
207
+ required: field.required,
208
+ ...field.placeholder ? { placeholder: field.placeholder } : {},
209
+ ...inputConstraints(props)
210
+ }
211
+ ) });
212
+ }
213
+ function InputBlock({ props }) {
214
+ return /* @__PURE__ */ jsxRuntime.jsx(TextInput, { props });
215
+ }
216
+ function TextareaBlock({ props }) {
217
+ const field = useNodeField(props);
218
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
219
+ ui.Textarea,
220
+ {
221
+ id: field.id,
222
+ name: field.name,
223
+ value: textValue(field.value),
224
+ onChange: (event) => field.setValue(event.target.value),
225
+ disabled: field.disabled,
226
+ required: field.required,
227
+ ...field.placeholder ? { placeholder: field.placeholder } : {},
228
+ ...inputConstraints(props)
229
+ }
230
+ ) });
231
+ }
232
+ function CodeBlock({ props }) {
233
+ const field = useNodeField(props);
234
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
235
+ ui.Textarea,
236
+ {
237
+ id: field.id,
238
+ name: field.name,
239
+ className: "font-mono text-sm",
240
+ rows: 10,
241
+ spellCheck: false,
242
+ value: textValue(field.value),
243
+ onChange: (event) => field.setValue(event.target.value),
244
+ disabled: field.disabled,
245
+ required: field.required,
246
+ ...field.placeholder ? { placeholder: field.placeholder } : {}
247
+ }
248
+ ) });
249
+ }
250
+ function NumberInputBlock({ props }) {
251
+ const field = useNodeField(props);
252
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
253
+ ui.Input,
254
+ {
255
+ id: field.id,
256
+ name: field.name,
257
+ type: "number",
258
+ value: textValue(field.value),
259
+ onChange: (event) => field.setValue(numberValue(event.target.value)),
260
+ disabled: field.disabled,
261
+ required: field.required,
262
+ ...field.placeholder ? { placeholder: field.placeholder } : {},
263
+ ...numericConstraints(props)
264
+ }
265
+ ) });
266
+ }
267
+ function SelectBlock({ props }) {
268
+ const field = useNodeField(props);
269
+ const options = readOptions(props);
270
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsxs(
271
+ ui.Select,
272
+ {
273
+ value: textValue(field.value),
274
+ onValueChange: (value) => field.setValue(value),
275
+ disabled: field.disabled,
276
+ children: [
277
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SelectTrigger, { id: field.id, children: /* @__PURE__ */ jsxRuntime.jsx(ui.SelectValue, { placeholder: field.placeholder ?? "Select\u2026" }) }),
278
+ /* @__PURE__ */ jsxRuntime.jsx(ui.SelectContent, { children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsx(ui.SelectItem, { value: option.value, children: option.label }, option.value)) })
279
+ ]
280
+ }
281
+ ) });
282
+ }
283
+ function RadioGroupBlock({ props }) {
284
+ const field = useNodeField(props);
285
+ const options = readOptions(props);
286
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
287
+ ui.RadioGroup,
288
+ {
289
+ value: textValue(field.value),
290
+ onValueChange: (value) => field.setValue(value),
291
+ disabled: field.disabled,
292
+ children: options.map((option) => /* @__PURE__ */ jsxRuntime.jsxs(ui.Label, { className: "flex items-center gap-2 font-normal", children: [
293
+ /* @__PURE__ */ jsxRuntime.jsx(ui.Radio, { value: option.value }),
294
+ option.label
295
+ ] }, option.value))
296
+ }
297
+ ) });
298
+ }
299
+ function BooleanField({
300
+ props,
301
+ control
302
+ }) {
303
+ const field = useNodeField(props);
304
+ if (props.hidden) return null;
305
+ const label = typeof props.label === "string" ? props.label : props.name ?? "";
306
+ return /* @__PURE__ */ jsxRuntime.jsxs("div", { className: typeof props.className === "string" ? props.className : void 0, children: [
307
+ /* @__PURE__ */ jsxRuntime.jsxs(ui.Label, { htmlFor: field.id, className: "flex items-center gap-2 font-normal", children: [
308
+ control({
309
+ id: field.id,
310
+ checked: Boolean(field.value),
311
+ disabled: field.disabled,
312
+ onCheckedChange: (checked) => field.setValue(checked)
313
+ }),
314
+ label
315
+ ] }),
316
+ typeof props.description === "string" && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-muted-foreground", children: props.description }),
317
+ field.error && /* @__PURE__ */ jsxRuntime.jsx("p", { className: "mt-1 text-sm text-destructive", children: field.error })
318
+ ] });
319
+ }
320
+ function CheckboxBlock({ props }) {
321
+ return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { props, control: (args) => /* @__PURE__ */ jsxRuntime.jsx(ui.Checkbox, { ...args }) });
322
+ }
323
+ function SwitchBlock({ props }) {
324
+ return /* @__PURE__ */ jsxRuntime.jsx(BooleanField, { props, control: (args) => /* @__PURE__ */ jsxRuntime.jsx(ui.Switch, { ...args }) });
325
+ }
326
+ function DatePickerBlock({ props }) {
327
+ return /* @__PURE__ */ jsxRuntime.jsx(TextInput, { props, type: "date" });
328
+ }
329
+ function DateTimePickerBlock({ props }) {
330
+ const field = useNodeField(props);
331
+ const raw = textValue(field.value);
332
+ const local = raw.length > 16 ? raw.slice(0, 16) : raw;
333
+ const zone = ZONE_SUFFIX.exec(raw)?.[0] ?? "";
334
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
335
+ ui.Input,
336
+ {
337
+ id: field.id,
338
+ name: field.name,
339
+ type: "datetime-local",
340
+ value: local,
341
+ onChange: (event) => field.setValue(zonedValue(event.target.value, zone)),
342
+ disabled: field.disabled,
343
+ required: field.required
344
+ }
345
+ ) });
346
+ }
347
+ function TimePickerBlock({ props }) {
348
+ return /* @__PURE__ */ jsxRuntime.jsx(TextInput, { props, type: "time" });
349
+ }
350
+ function PhoneInputBlock({ props }) {
351
+ return /* @__PURE__ */ jsxRuntime.jsx(TextInput, { props, type: "tel" });
352
+ }
353
+ function FileUploadBlock({ props }) {
354
+ const field = useNodeField(props);
355
+ return /* @__PURE__ */ jsxRuntime.jsx(FieldShell, { props, id: field.id, error: field.error, children: /* @__PURE__ */ jsxRuntime.jsx(
356
+ ui.Input,
357
+ {
358
+ id: field.id,
359
+ name: field.name,
360
+ type: "file",
361
+ onChange: (event) => field.setValue(event.target.files?.[0]?.name ?? null),
362
+ disabled: field.disabled,
363
+ required: field.required
364
+ }
365
+ ) });
366
+ }
367
+
368
+ // src/registry.ts
369
+ var widgetRegistry = {
370
+ Input: InputBlock,
371
+ Textarea: TextareaBlock,
372
+ Select: SelectBlock,
373
+ RadioGroup: RadioGroupBlock,
374
+ Checkbox: CheckboxBlock,
375
+ Switch: SwitchBlock,
376
+ NumberInput: NumberInputBlock,
377
+ DatePicker: DatePickerBlock,
378
+ DateTimePicker: DateTimePickerBlock,
379
+ TimePicker: TimePickerBlock,
380
+ PhoneInput: PhoneInputBlock,
381
+ CodeEditor: CodeBlock,
382
+ MarkdownEditor: CodeBlock,
383
+ JsonEditor: CodeBlock,
384
+ FileUpload: FileUploadBlock
385
+ };
386
+ var containerRegistry = {
387
+ Page: PageBlock,
388
+ Form: FormBlock,
389
+ Section: SectionBlock,
390
+ Grid: GridBlock,
391
+ GridColumn: GridColumnBlock,
392
+ Tabs: TabsBlock,
393
+ Tab: TabBlock
394
+ };
395
+ var blockRegistry = {
396
+ Button: ButtonBlock,
397
+ ActionBar: ActionBarBlock,
398
+ Markdown: MarkdownBlock,
399
+ StatCard: StatCardBlock
400
+ };
401
+ var defaultBlockRegistry = {
402
+ ...widgetRegistry,
403
+ ...containerRegistry,
404
+ ...blockRegistry
405
+ };
406
+
407
+ exports.ActionBarBlock = ActionBarBlock;
408
+ exports.ButtonBlock = ButtonBlock;
409
+ exports.CheckboxBlock = CheckboxBlock;
410
+ exports.CodeBlock = CodeBlock;
411
+ exports.DatePickerBlock = DatePickerBlock;
412
+ exports.DateTimePickerBlock = DateTimePickerBlock;
413
+ exports.FieldShell = FieldShell;
414
+ exports.FileUploadBlock = FileUploadBlock;
415
+ exports.FormBlock = FormBlock;
416
+ exports.GridBlock = GridBlock;
417
+ exports.GridColumnBlock = GridColumnBlock;
418
+ exports.InputBlock = InputBlock;
419
+ exports.MarkdownBlock = MarkdownBlock;
420
+ exports.NumberInputBlock = NumberInputBlock;
421
+ exports.PageBlock = PageBlock;
422
+ exports.PhoneInputBlock = PhoneInputBlock;
423
+ exports.RadioGroupBlock = RadioGroupBlock;
424
+ exports.SectionBlock = SectionBlock;
425
+ exports.SelectBlock = SelectBlock;
426
+ exports.StatCardBlock = StatCardBlock;
427
+ exports.SwitchBlock = SwitchBlock;
428
+ exports.TabBlock = TabBlock;
429
+ exports.TabsBlock = TabsBlock;
430
+ exports.TextareaBlock = TextareaBlock;
431
+ exports.TimePickerBlock = TimePickerBlock;
432
+ exports.blockRegistry = blockRegistry;
433
+ exports.containerRegistry = containerRegistry;
434
+ exports.defaultBlockRegistry = defaultBlockRegistry;
435
+ exports.readOptions = readOptions;
436
+ exports.textValue = textValue;
437
+ exports.useNodeField = useNodeField;
438
+ exports.widgetRegistry = widgetRegistry;
439
+ //# sourceMappingURL=index.cjs.map
440
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/blocks.tsx","../src/containers.tsx","../src/field.tsx","../src/widgets.tsx","../src/registry.ts"],"names":["useRenderer","jsx","Button","Card","jsxs","CardHeader","CardTitle","CardDescription","CardContent","text","Tabs","TabsList","TabsTrigger","TabsContent","BlockRenderer","useBlockField","useId","Field","value","Input","Textarea","Select","SelectTrigger","SelectValue","SelectContent","SelectItem","RadioGroup","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;AAAA,EACZ,IAAA,EAAM,SAAA;AAAA,EACN,GAAA,EAAK;AACN;AAGO,IAAM,aAAA,GAA+B;AAAA,EAC3C,MAAA,EAAQ,WAAA;AAAA,EACR,SAAA,EAAW,cAAA;AAAA,EACX,QAAA,EAAU,aAAA;AAAA,EACV,QAAA,EAAU;AACX;AAMO,IAAM,oBAAA,GAAsC;AAAA,EAClD,GAAG,cAAA;AAAA,EACH,GAAG,iBAAA;AAAA,EACH,GAAG;AACJ","file":"index.cjs","sourcesContent":["'use client';\n\n/**\n * Document-level blocks that need no data source. The data blocks\n * (`DataTable`, `DetailPanel`, `RelationList`, `Chart`, `AgentChat`) are\n * deliberately absent: they need a query runtime, so they fall back to the\n * renderer's visible `UnknownBlock` until a host registers them.\n */\n\nimport { Button, Card, CardContent, CardDescription, CardHeader, CardTitle } from '@constructive-io/ui';\nimport { useRenderer } from 'blocks-renderer';\nimport type { BlockProps } from 'blocks-renderer';\nimport type { UINodeProps } from 'blocks-schema';\n\nfunction text(props: UINodeProps, ...keys: string[]): string | undefined {\n\tfor (const key of keys) {\n\t\tconst value = props[key];\n\t\tif (typeof value === 'string') return value;\n\t}\n\treturn undefined;\n}\n\nconst VARIANTS = new Set(['default', 'destructive', 'outline', 'secondary', 'ghost', 'link']);\n\n/**\n * A button either submits its form or fires its `click` action; the renderer\n * decides what an action means, so this block only reports the event.\n */\nexport function ButtonBlock({ node, props }: BlockProps) {\n\tconst { onAction } = useRenderer();\n\tconst label = text(props, 'text', 'label') ?? 'Button';\n\tconst variant = text(props, 'variant');\n\tconst submits = props.type === 'submit' || props.submit === true;\n\tconst action = node.actions?.click;\n\n\treturn (\n\t\t<Button\n\t\t\ttype={submits ? 'submit' : 'button'}\n\t\t\tdisabled={Boolean(props.disabled)}\n\t\t\t{...(variant && VARIANTS.has(variant) ? { variant: variant as 'default' } : {})}\n\t\t\t{...(action ? { onClick: () => onAction?.(action, 'click') } : {})}\n\t\t>\n\t\t\t{label}\n\t\t</Button>\n\t);\n}\n\nexport function ActionBarBlock({ props, children }: BlockProps) {\n\treturn (\n\t\t<div className={['flex flex-wrap items-center gap-2', props.className ? String(props.className) : ''].join(' ').trim()}>\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\n/**\n * Markdown source is rendered as pre-wrapped text rather than parsed: a parser\n * is a dependency and an XSS surface, and a host that wants one registers it.\n */\nexport function MarkdownBlock({ props }: BlockProps) {\n\tconst content = text(props, 'content', 'text', 'markdown') ?? '';\n\n\treturn <div className=\"whitespace-pre-wrap text-sm leading-relaxed\">{content}</div>;\n}\n\nexport function StatCardBlock({ props }: BlockProps) {\n\tconst label = text(props, 'label', 'title') ?? '';\n\tconst value = props.value;\n\tconst description = text(props, 'description');\n\n\treturn (\n\t\t<Card>\n\t\t\t<CardHeader>\n\t\t\t\t<CardTitle className=\"text-sm font-medium text-muted-foreground\">{label}</CardTitle>\n\t\t\t\t{description && <CardDescription>{description}</CardDescription>}\n\t\t\t</CardHeader>\n\t\t\t<CardContent>\n\t\t\t\t<span className=\"text-2xl font-semibold tabular-nums\">\n\t\t\t\t\t{value === null || value === undefined ? '—' : String(value)}\n\t\t\t\t</span>\n\t\t\t</CardContent>\n\t\t</Card>\n\t);\n}\n","'use client';\n\n/**\n * Container nodes: layout plus, for `Form`, the submit path. Children arrive\n * already rendered, so a container only positions them — except `Tabs`, which\n * needs its children's labels to build triggers and therefore renders them\n * itself through {@link BlockRenderer}.\n */\n\nimport { Button, Card, CardContent, CardHeader, CardTitle, Tabs, TabsContent, TabsList, TabsTrigger } from '@constructive-io/ui';\nimport { BlockRenderer, useRenderer } from 'blocks-renderer';\nimport type { BlockProps } from 'blocks-renderer';\nimport type { UINodeProps } from 'blocks-schema';\n\nfunction text(props: UINodeProps, key: string): string | undefined {\n\tconst value = props[key];\n\treturn typeof value === 'string' ? value : undefined;\n}\n\nexport function PageBlock({ props, children }: BlockProps) {\n\tconst title = text(props, 'title');\n\tconst description = text(props, 'description');\n\n\treturn (\n\t\t<div className={props.className ? String(props.className) : 'flex flex-col gap-6'}>\n\t\t\t{(title || description) && (\n\t\t\t\t<header className=\"flex flex-col gap-1\">\n\t\t\t\t\t{title && <h1 className=\"text-2xl font-semibold tracking-tight\">{title}</h1>}\n\t\t\t\t\t{description && <p className=\"text-muted-foreground\">{description}</p>}\n\t\t\t\t</header>\n\t\t\t)}\n\t\t\t{children}\n\t\t</div>\n\t);\n}\n\n/**\n * Submitting delegates to the renderer: it validates every field against the\n * document's constraints before calling the host's `onSubmit`, so this component\n * never inspects values itself.\n */\nexport function FormBlock({ node, props, children }: BlockProps) {\n\tconst { onAction } = useRenderer();\n\tconst submitLabel = text(props, 'submitLabel') ?? (props.mode === 'update' ? 'Save' : 'Submit');\n\n\treturn (\n\t\t<form\n\t\t\tclassName=\"flex flex-col gap-5\"\n\t\t\tnoValidate\n\t\t\tonSubmit={(event) => {\n\t\t\t\tevent.preventDefault();\n\t\t\t\tonAction?.(node.actions?.submit ?? { type: 'handler', handler: 'submit' }, 'submit');\n\t\t\t}}\n\t\t>\n\t\t\t{children}\n\t\t\t<div className=\"flex gap-2\">\n\t\t\t\t<Button type=\"submit\">{submitLabel}</Button>\n\t\t\t</div>\n\t\t</form>\n\t);\n}\n\nexport function SectionBlock({ props, children }: BlockProps) {\n\tconst title = text(props, 'title');\n\n\tif (!title) {\n\t\treturn <section className=\"flex flex-col gap-4\">{children}</section>;\n\t}\n\n\treturn (\n\t\t<Card>\n\t\t\t<CardHeader>\n\t\t\t\t<CardTitle>{title}</CardTitle>\n\t\t\t</CardHeader>\n\t\t\t<CardContent className=\"flex flex-col gap-5\">{children}</CardContent>\n\t\t</Card>\n\t);\n}\n\n/** `columns` is a count, so the grid stays declarative rather than class-driven. */\nexport function GridBlock({ props, children }: BlockProps) {\n\tconst columns = typeof props.columns === 'number' ? Math.min(Math.max(props.columns, 1), 4) : 2;\n\tconst template = ['grid-cols-1', 'md:grid-cols-2', 'md:grid-cols-3', 'md:grid-cols-4'][columns - 1];\n\n\treturn <div className={`grid gap-5 ${template}`}>{children}</div>;\n}\n\n// Spelled out rather than interpolated, because Tailwind only ships classes it\n// can see in the source.\nconst SPANS = ['', 'md:col-span-2', 'md:col-span-3', 'md:col-span-4'];\n\nexport function GridColumnBlock({ props, children }: BlockProps) {\n\tconst span = typeof props.span === 'number' ? Math.min(Math.max(props.span, 1), 4) : 1;\n\n\treturn <div className={['flex flex-col gap-5', SPANS[span - 1]].filter(Boolean).join(' ')}>{children}</div>;\n}\n\nexport function TabsBlock({ node }: BlockProps) {\n\tconst tabs = node.children ?? [];\n\tif (tabs.length === 0) return null;\n\n\tconst first = tabs[0]!.key;\n\n\treturn (\n\t\t<Tabs defaultValue={first}>\n\t\t\t<TabsList>\n\t\t\t\t{tabs.map((tab) => (\n\t\t\t\t\t<TabsTrigger key={tab.key} value={tab.key}>\n\t\t\t\t\t\t{text(tab.props, 'label') ?? text(tab.props, 'title') ?? tab.key}\n\t\t\t\t\t</TabsTrigger>\n\t\t\t\t))}\n\t\t\t</TabsList>\n\t\t\t{tabs.map((tab) => (\n\t\t\t\t<TabsContent key={tab.key} value={tab.key}>\n\t\t\t\t\t<BlockRenderer node={tab} />\n\t\t\t\t</TabsContent>\n\t\t\t))}\n\t\t</Tabs>\n\t);\n}\n\n/** Rendered inside a `TabsContent` by {@link TabsBlock}; it owns no chrome. */\nexport function TabBlock({ children }: BlockProps) {\n\treturn <div className=\"flex flex-col gap-5 pt-4\">{children}</div>;\n}\n","'use client';\n\n/**\n * The field plumbing every widget shares: a node's props are presentation\n * (`label`, `description`, `required`), while its value lives in the renderer's\n * form state keyed by `props.name`. Widgets therefore never own state; they read\n * and write the document's.\n */\n\nimport { Field } from '@constructive-io/ui';\nimport { useBlockField } from 'blocks-renderer';\nimport type { UINodeProps } from 'blocks-schema';\nimport { useId } from 'react';\nimport type { ReactNode } from 'react';\n\n/** The value/error wiring for one widget node, plus a stable control id. */\nexport function useNodeField(props: UINodeProps) {\n\tconst name = typeof props.name === 'string' ? props.name : undefined;\n\tconst { value, error, setValue, mode } = useBlockField(name);\n\tconst id = useId();\n\n\treturn {\n\t\tname,\n\t\tid,\n\t\tvalue,\n\t\terror,\n\t\tsetValue,\n\t\t/** `edit` is the authoring surface, so widgets are inert there. */\n\t\tdisabled: Boolean(props.disabled) || mode === 'edit',\n\t\trequired: Boolean(props.required),\n\t\tplaceholder: typeof props.placeholder === 'string' ? props.placeholder : undefined,\n\t};\n}\n\nexport interface FieldShellProps {\n\tprops: UINodeProps;\n\tid: string;\n\terror?: string;\n\tchildren: ReactNode;\n}\n\n/**\n * Label, description, and error chrome around a control. `hidden` fields stay\n * in the document (they still carry a value) but render nothing.\n */\nexport function FieldShell({ props, id, error, children }: FieldShellProps) {\n\tif (props.hidden) return null;\n\n\tconst label = typeof props.label === 'string' ? props.label : (props.name as string | undefined) ?? '';\n\n\treturn (\n\t\t<Field\n\t\t\tlabel={label}\n\t\t\thtmlFor={id}\n\t\t\trequired={Boolean(props.required)}\n\t\t\t{...(typeof props.description === 'string' ? { description: props.description } : {})}\n\t\t\t{...(error ? { error } : {})}\n\t\t\t{...(typeof props.className === 'string' ? { className: props.className } : {})}\n\t\t>\n\t\t\t{children}\n\t\t</Field>\n\t);\n}\n\n/** `{ label, value }[]`, however the document spelled the options. */\nexport interface WidgetOption {\n\tlabel: string;\n\tvalue: string;\n}\n\nexport function readOptions(props: UINodeProps): WidgetOption[] {\n\tconst options = props.options;\n\tif (!Array.isArray(options)) return [];\n\n\treturn options.map((option) => {\n\t\tif (option !== null && typeof option === 'object') {\n\t\t\tconst entry = option as { label?: unknown; value?: unknown };\n\t\t\tconst value = String(entry.value ?? '');\n\t\t\treturn { label: String(entry.label ?? value), value };\n\t\t}\n\t\tconst value = String(option ?? '');\n\t\treturn { label: value, value };\n\t});\n}\n\n/** Controlled inputs cannot take `undefined`, and `null` means \"cleared\". */\nexport function textValue(value: unknown): string {\n\tif (value === undefined || value === null) return '';\n\treturn typeof value === 'string' ? value : String(value);\n}\n","'use client';\n\n/**\n * Widget nodes → `@constructive-io/ui` controls.\n *\n * Each component is deliberately small and independently replaceable: a host\n * that dislikes one of these layers its own over the default registry rather\n * than forking the set.\n */\n\nimport { Checkbox, Input, Label, Radio, RadioGroup, Select, SelectContent, SelectItem, SelectTrigger, SelectValue, Switch, Textarea } from '@constructive-io/ui';\nimport type { BlockProps } from 'blocks-renderer';\nimport type { UINodeConstraints, UINodeProps } from 'blocks-schema';\nimport type { ReactNode } from 'react';\n\nimport { FieldShell, readOptions, textValue, useNodeField } from './field';\n\n/** Native validation attributes the document already declares. */\nfunction inputConstraints(props: UINodeProps) {\n\tconst constraints = (props.constraints ?? {}) as UINodeConstraints;\n\treturn {\n\t\t...(constraints.minLength != null ? { minLength: constraints.minLength } : {}),\n\t\t...(constraints.maxLength != null ? { maxLength: constraints.maxLength } : {}),\n\t\t...(constraints.pattern ? { pattern: constraints.pattern } : {}),\n\t};\n}\n\nfunction numericConstraints(props: UINodeProps) {\n\tconst constraints = (props.constraints ?? {}) as UINodeConstraints;\n\treturn {\n\t\t...(constraints.minValue != null ? { min: constraints.minValue } : {}),\n\t\t...(constraints.maxValue != null ? { max: constraints.maxValue } : {}),\n\t\t...(typeof props.step === 'number' ? { step: props.step } : {}),\n\t};\n}\n\n/** An empty number input is absent, and a half-typed one is not yet a number. */\nfunction numberValue(raw: string): number | string | null {\n\tif (raw === '') return null;\n\tconst parsed = Number(raw);\n\treturn Number.isFinite(parsed) ? parsed : raw;\n}\n\nconst ZONE_SUFFIX = /(?:Z|[+-]\\d{2}:?\\d{2})$/;\n\n/** Re-attaches the zone the stored value carried to a minute-precision edit. */\nfunction zonedValue(local: string, zone: string): string | null {\n\tif (local === '') return null;\n\tif (!zone) return local;\n\tconst seconds = local.length > 16 ? '' : ':00';\n\treturn `${local}${seconds}${zone}`;\n}\n\n/** A text-ish input; `inputType` carries the HTML type a format implies. */\nfunction TextInput({ props, type }: { props: UINodeProps; type?: string }) {\n\tconst field = useNodeField(props);\n\tconst inputType = type ?? (typeof props.inputType === 'string' ? props.inputType : 'text');\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Input\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\ttype={inputType}\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonChange={(event) => field.setValue(event.target.value)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t\t{...(field.placeholder ? { placeholder: field.placeholder } : {})}\n\t\t\t\t{...inputConstraints(props)}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n\nexport function InputBlock({ props }: BlockProps) {\n\treturn <TextInput props={props} />;\n}\n\nexport function TextareaBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Textarea\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonChange={(event) => field.setValue(event.target.value)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t\t{...(field.placeholder ? { placeholder: field.placeholder } : {})}\n\t\t\t\t{...inputConstraints(props)}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n\n/**\n * Code and prose editors fall back to a monospace textarea: a real editor is a\n * heavy dependency, and a host that wants one registers it for these two types.\n */\nexport function CodeBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Textarea\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\tclassName=\"font-mono text-sm\"\n\t\t\t\trows={10}\n\t\t\t\tspellCheck={false}\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonChange={(event) => field.setValue(event.target.value)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t\t{...(field.placeholder ? { placeholder: field.placeholder } : {})}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n\nexport function NumberInputBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Input\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\ttype=\"number\"\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonChange={(event) => field.setValue(numberValue(event.target.value))}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t\t{...(field.placeholder ? { placeholder: field.placeholder } : {})}\n\t\t\t\t{...numericConstraints(props)}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n\nexport function SelectBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\tconst options = readOptions(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Select\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonValueChange={(value) => field.setValue(value)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t>\n\t\t\t\t<SelectTrigger id={field.id}>\n\t\t\t\t\t<SelectValue placeholder={field.placeholder ?? 'Select…'} />\n\t\t\t\t</SelectTrigger>\n\t\t\t\t<SelectContent>\n\t\t\t\t\t{options.map((option) => (\n\t\t\t\t\t\t<SelectItem key={option.value} value={option.value}>\n\t\t\t\t\t\t\t{option.label}\n\t\t\t\t\t\t</SelectItem>\n\t\t\t\t\t))}\n\t\t\t\t</SelectContent>\n\t\t\t</Select>\n\t\t</FieldShell>\n\t);\n}\n\nexport function RadioGroupBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\tconst options = readOptions(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<RadioGroup\n\t\t\t\tvalue={textValue(field.value)}\n\t\t\t\tonValueChange={(value) => field.setValue(value)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t>\n\t\t\t\t{options.map((option) => (\n\t\t\t\t\t<Label key={option.value} className=\"flex items-center gap-2 font-normal\">\n\t\t\t\t\t\t<Radio value={option.value} />\n\t\t\t\t\t\t{option.label}\n\t\t\t\t\t</Label>\n\t\t\t\t))}\n\t\t\t</RadioGroup>\n\t\t</FieldShell>\n\t);\n}\n\n/** Boolean widgets carry their own label, so they skip the field shell's. */\nfunction BooleanField({\n\tprops,\n\tcontrol,\n}: {\n\tprops: UINodeProps;\n\tcontrol: (args: { id: string; checked: boolean; disabled: boolean; onCheckedChange: (checked: boolean) => void }) => ReactNode;\n}) {\n\tconst field = useNodeField(props);\n\tif (props.hidden) return null;\n\n\tconst label = typeof props.label === 'string' ? props.label : (props.name as string | undefined) ?? '';\n\n\treturn (\n\t\t<div className={typeof props.className === 'string' ? props.className : undefined}>\n\t\t\t<Label htmlFor={field.id} className=\"flex items-center gap-2 font-normal\">\n\t\t\t\t{control({\n\t\t\t\t\tid: field.id,\n\t\t\t\t\tchecked: Boolean(field.value),\n\t\t\t\t\tdisabled: field.disabled,\n\t\t\t\t\tonCheckedChange: (checked) => field.setValue(checked),\n\t\t\t\t})}\n\t\t\t\t{label}\n\t\t\t</Label>\n\t\t\t{typeof props.description === 'string' && (\n\t\t\t\t<p className=\"mt-1 text-sm text-muted-foreground\">{props.description}</p>\n\t\t\t)}\n\t\t\t{field.error && <p className=\"mt-1 text-sm text-destructive\">{field.error}</p>}\n\t\t</div>\n\t);\n}\n\nexport function CheckboxBlock({ props }: BlockProps) {\n\treturn <BooleanField props={props} control={(args) => <Checkbox {...args} />} />;\n}\n\nexport function SwitchBlock({ props }: BlockProps) {\n\treturn <BooleanField props={props} control={(args) => <Switch {...args} />} />;\n}\n\nexport function DatePickerBlock({ props }: BlockProps) {\n\treturn <TextInput props={props} type=\"date\" />;\n}\n\n/**\n * `datetime-local` needs `YYYY-MM-DDTHH:mm`, while a document (and Postgres)\n * speaks ISO-8601 with a zone, so the value is trimmed for display and the\n * incoming zone is reapplied on write-back rather than dropped.\n */\nexport function DateTimePickerBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\tconst raw = textValue(field.value);\n\tconst local = raw.length > 16 ? raw.slice(0, 16) : raw;\n\tconst zone = ZONE_SUFFIX.exec(raw)?.[0] ?? '';\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Input\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\ttype=\"datetime-local\"\n\t\t\t\tvalue={local}\n\t\t\t\tonChange={(event) =>\n\t\t\t\t\tfield.setValue(zonedValue(event.target.value, zone))\n\t\t\t\t}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n\nexport function TimePickerBlock({ props }: BlockProps) {\n\treturn <TextInput props={props} type=\"time\" />;\n}\n\nexport function PhoneInputBlock({ props }: BlockProps) {\n\treturn <TextInput props={props} type=\"tel\" />;\n}\n\n/**\n * A file field holds the file name in form state; uploading bytes needs a\n * storage adapter, which is a host concern rather than a widget's.\n */\nexport function FileUploadBlock({ props }: BlockProps) {\n\tconst field = useNodeField(props);\n\n\treturn (\n\t\t<FieldShell props={props} id={field.id} error={field.error}>\n\t\t\t<Input\n\t\t\t\tid={field.id}\n\t\t\t\tname={field.name}\n\t\t\t\ttype=\"file\"\n\t\t\t\tonChange={(event) => field.setValue(event.target.files?.[0]?.name ?? null)}\n\t\t\t\tdisabled={field.disabled}\n\t\t\t\trequired={field.required}\n\t\t\t/>\n\t\t</FieldShell>\n\t);\n}\n","/**\n * The default registry: Constructive node types → components.\n *\n * It is split into three layers so a host can take only what it wants — the\n * widgets without the page chrome, say — and compose the rest itself.\n */\n\nimport type { BlockRegistry } from 'blocks-renderer';\n\nimport { ActionBarBlock, ButtonBlock, MarkdownBlock, StatCardBlock } from './blocks';\nimport {\n\tFormBlock,\n\tGridBlock,\n\tGridColumnBlock,\n\tPageBlock,\n\tSectionBlock,\n\tTabBlock,\n\tTabsBlock,\n} from './containers';\nimport {\n\tCheckboxBlock,\n\tCodeBlock,\n\tDatePickerBlock,\n\tDateTimePickerBlock,\n\tFileUploadBlock,\n\tInputBlock,\n\tNumberInputBlock,\n\tPhoneInputBlock,\n\tRadioGroupBlock,\n\tSelectBlock,\n\tSwitchBlock,\n\tTextareaBlock,\n\tTimePickerBlock,\n} from './widgets';\n\n/** Every field widget in `WIDGET_NODE_TYPES`. */\nexport const widgetRegistry: BlockRegistry = {\n\tInput: InputBlock,\n\tTextarea: TextareaBlock,\n\tSelect: SelectBlock,\n\tRadioGroup: RadioGroupBlock,\n\tCheckbox: CheckboxBlock,\n\tSwitch: SwitchBlock,\n\tNumberInput: NumberInputBlock,\n\tDatePicker: DatePickerBlock,\n\tDateTimePicker: DateTimePickerBlock,\n\tTimePicker: TimePickerBlock,\n\tPhoneInput: PhoneInputBlock,\n\tCodeEditor: CodeBlock,\n\tMarkdownEditor: CodeBlock,\n\tJsonEditor: CodeBlock,\n\tFileUpload: FileUploadBlock,\n};\n\n/** Every layout type in `CONTAINER_NODE_TYPES`. */\nexport const containerRegistry: BlockRegistry = {\n\tPage: PageBlock,\n\tForm: FormBlock,\n\tSection: SectionBlock,\n\tGrid: GridBlock,\n\tGridColumn: GridColumnBlock,\n\tTabs: TabsBlock,\n\tTab: TabBlock,\n};\n\n/** The blocks that need no data source. */\nexport const blockRegistry: BlockRegistry = {\n\tButton: ButtonBlock,\n\tActionBar: ActionBarBlock,\n\tMarkdown: MarkdownBlock,\n\tStatCard: StatCardBlock,\n};\n\n/**\n * Everything above, ready to render a generated document. Layer over it rather\n * than editing it: `composeRegistry(defaultBlockRegistry, myRegistry)`.\n */\nexport const defaultBlockRegistry: BlockRegistry = {\n\t...widgetRegistry,\n\t...containerRegistry,\n\t...blockRegistry,\n};\n"]}