@agent-native/core 0.39.2 → 0.40.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/README.md +1 -1
- package/dist/action.js +12 -0
- package/dist/action.js.map +1 -1
- package/dist/cli/create.d.ts.map +1 -1
- package/dist/cli/create.js +5 -1
- package/dist/cli/create.js.map +1 -1
- package/dist/cli/skills.d.ts +4 -3
- package/dist/cli/skills.d.ts.map +1 -1
- package/dist/cli/skills.js +756 -694
- package/dist/cli/skills.js.map +1 -1
- package/dist/client/blocks/AiEditableField.d.ts +8 -0
- package/dist/client/blocks/AiEditableField.d.ts.map +1 -0
- package/dist/client/blocks/AiEditableField.js +10 -0
- package/dist/client/blocks/AiEditableField.js.map +1 -0
- package/dist/client/blocks/BlockView.d.ts +3 -3
- package/dist/client/blocks/BlockView.d.ts.map +1 -1
- package/dist/client/blocks/BlockView.js +15 -3
- package/dist/client/blocks/BlockView.js.map +1 -1
- package/dist/client/blocks/SchemaBlockEditor.js +2 -2
- package/dist/client/blocks/SchemaBlockEditor.js.map +1 -1
- package/dist/client/blocks/index.d.ts +5 -2
- package/dist/client/blocks/index.d.ts.map +1 -1
- package/dist/client/blocks/index.js +6 -3
- package/dist/client/blocks/index.js.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/ApiEndpointBlock.js +20 -6
- package/dist/client/blocks/library/ApiEndpointBlock.js.map +1 -1
- package/dist/client/blocks/library/DiffBlock.d.ts +29 -0
- package/dist/client/blocks/library/DiffBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/DiffBlock.js +190 -30
- package/dist/client/blocks/library/DiffBlock.js.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/FileTreeBlock.js +46 -7
- package/dist/client/blocks/library/FileTreeBlock.js.map +1 -1
- package/dist/client/blocks/library/HighlightedCode.d.ts +10 -0
- package/dist/client/blocks/library/HighlightedCode.d.ts.map +1 -0
- package/dist/client/blocks/library/HighlightedCode.js +92 -0
- package/dist/client/blocks/library/HighlightedCode.js.map +1 -0
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts +9 -4
- package/dist/client/blocks/library/JsonExplorerBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/JsonExplorerBlock.js +66 -30
- package/dist/client/blocks/library/JsonExplorerBlock.js.map +1 -1
- package/dist/client/blocks/library/MermaidBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/MermaidBlock.js +73 -44
- package/dist/client/blocks/library/MermaidBlock.js.map +1 -1
- package/dist/client/blocks/library/OpenApiSpecBlock.d.ts.map +1 -1
- package/dist/client/blocks/library/OpenApiSpecBlock.js +3 -2
- package/dist/client/blocks/library/OpenApiSpecBlock.js.map +1 -1
- package/dist/client/blocks/library/checklist.d.ts.map +1 -1
- package/dist/client/blocks/library/checklist.js +1 -0
- package/dist/client/blocks/library/checklist.js.map +1 -1
- package/dist/client/blocks/library/code-tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/code-tabs.js +183 -102
- package/dist/client/blocks/library/code-tabs.js.map +1 -1
- package/dist/client/blocks/library/columns.config.d.ts +60 -0
- package/dist/client/blocks/library/columns.config.d.ts.map +1 -0
- package/dist/client/blocks/library/columns.config.js +37 -0
- package/dist/client/blocks/library/columns.config.js.map +1 -0
- package/dist/client/blocks/library/columns.d.ts +25 -0
- package/dist/client/blocks/library/columns.d.ts.map +1 -0
- package/dist/client/blocks/library/columns.js +199 -0
- package/dist/client/blocks/library/columns.js.map +1 -0
- package/dist/client/blocks/library/dev-doc-ui.d.ts +2 -1
- package/dist/client/blocks/library/dev-doc-ui.d.ts.map +1 -1
- package/dist/client/blocks/library/dev-doc-ui.js +2 -1
- package/dist/client/blocks/library/dev-doc-ui.js.map +1 -1
- package/dist/client/blocks/library/html.d.ts +1 -1
- package/dist/client/blocks/library/html.d.ts.map +1 -1
- package/dist/client/blocks/library/html.js +34 -4
- package/dist/client/blocks/library/html.js.map +1 -1
- package/dist/client/blocks/library/json-explorer.config.d.ts +3 -1
- package/dist/client/blocks/library/json-explorer.config.d.ts.map +1 -1
- package/dist/client/blocks/library/json-explorer.config.js +30 -1
- package/dist/client/blocks/library/json-explorer.config.js.map +1 -1
- package/dist/client/blocks/library/server-specs.d.ts.map +1 -1
- package/dist/client/blocks/library/server-specs.js +13 -3
- package/dist/client/blocks/library/server-specs.js.map +1 -1
- package/dist/client/blocks/library/specs.d.ts +4 -4
- package/dist/client/blocks/library/specs.d.ts.map +1 -1
- package/dist/client/blocks/library/specs.js +21 -16
- package/dist/client/blocks/library/specs.js.map +1 -1
- package/dist/client/blocks/library/table.config.d.ts +3 -0
- package/dist/client/blocks/library/table.config.d.ts.map +1 -1
- package/dist/client/blocks/library/table.config.js +13 -1
- package/dist/client/blocks/library/table.config.js.map +1 -1
- package/dist/client/blocks/library/table.d.ts.map +1 -1
- package/dist/client/blocks/library/table.js +90 -9
- package/dist/client/blocks/library/table.js.map +1 -1
- package/dist/client/blocks/library/tabs.config.d.ts +16 -8
- package/dist/client/blocks/library/tabs.config.d.ts.map +1 -1
- package/dist/client/blocks/library/tabs.config.js +10 -4
- package/dist/client/blocks/library/tabs.config.js.map +1 -1
- package/dist/client/blocks/library/tabs.d.ts.map +1 -1
- package/dist/client/blocks/library/tabs.js +146 -21
- package/dist/client/blocks/library/tabs.js.map +1 -1
- package/dist/client/blocks/server.d.ts +2 -1
- package/dist/client/blocks/server.d.ts.map +1 -1
- package/dist/client/blocks/server.js +1 -0
- package/dist/client/blocks/server.js.map +1 -1
- package/dist/client/blocks/types.d.ts +99 -9
- package/dist/client/blocks/types.d.ts.map +1 -1
- package/dist/client/blocks/types.js.map +1 -1
- package/dist/client/index.d.ts +1 -1
- package/dist/client/index.d.ts.map +1 -1
- package/dist/client/index.js +2 -2
- package/dist/client/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/BubbleToolbar.js +13 -3
- package/dist/client/rich-markdown-editor/BubbleToolbar.js.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.d.ts +49 -4
- package/dist/client/rich-markdown-editor/DragHandle.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/DragHandle.js +656 -88
- package/dist/client/rich-markdown-editor/DragHandle.js.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts +10 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js +180 -15
- package/dist/client/rich-markdown-editor/RegistryBlockNode.js.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts +2 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js +3 -1
- package/dist/client/rich-markdown-editor/SharedRichEditor.js.map +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts +5 -0
- package/dist/client/rich-markdown-editor/SlashCommandMenu.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js +33 -5
- package/dist/client/rich-markdown-editor/SlashCommandMenu.js.map +1 -1
- package/dist/client/rich-markdown-editor/index.d.ts +3 -3
- package/dist/client/rich-markdown-editor/index.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/index.js +2 -2
- package/dist/client/rich-markdown-editor/index.js.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts +14 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/registrySlashCommands.js +38 -0
- package/dist/client/rich-markdown-editor/registrySlashCommands.js.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts +1 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.d.ts.map +1 -1
- package/dist/client/rich-markdown-editor/useCollabReconcile.js +4 -0
- package/dist/client/rich-markdown-editor/useCollabReconcile.js.map +1 -1
- package/dist/db/client.d.ts.map +1 -1
- package/dist/db/client.js +17 -1
- package/dist/db/client.js.map +1 -1
- package/dist/sharing/access.d.ts +4 -2
- package/dist/sharing/access.d.ts.map +1 -1
- package/dist/sharing/access.js +8 -3
- package/dist/sharing/access.js.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.d.ts.map +1 -1
- package/dist/sharing/actions/set-resource-visibility.js +2 -3
- package/dist/sharing/actions/set-resource-visibility.js.map +1 -1
- package/dist/sharing/registry.d.ts +13 -0
- package/dist/sharing/registry.d.ts.map +1 -1
- package/dist/sharing/registry.js.map +1 -1
- package/dist/styles/rich-markdown-editor.css +15 -0
- package/package.json +16 -1
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { BlockAiFieldActionProps, BlockRenderContext } from "./types.js";
|
|
2
|
+
export declare function AiEditableFieldLabel({ htmlFor, label, ctx, action, }: {
|
|
3
|
+
htmlFor: string;
|
|
4
|
+
label: string;
|
|
5
|
+
ctx: BlockRenderContext;
|
|
6
|
+
action?: Omit<BlockAiFieldActionProps, "fieldLabel">;
|
|
7
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
8
|
+
//# sourceMappingURL=AiEditableField.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiEditableField.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/AiEditableField.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,uBAAuB,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAC;AAE9E,wBAAgB,oBAAoB,CAAC,EACnC,OAAO,EACP,KAAK,EACL,GAAG,EACH,MAAM,GACP,EAAE;IACD,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,kBAAkB,CAAC;IACxB,MAAM,CAAC,EAAE,IAAI,CAAC,uBAAuB,EAAE,YAAY,CAAC,CAAC;CACtD,2CAiBA"}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
export function AiEditableFieldLabel({ htmlFor, label, ctx, action, }) {
|
|
3
|
+
return (_jsxs("div", { className: "sticky top-0 z-10 flex items-center justify-between gap-3 bg-background/95 py-1 backdrop-blur supports-[backdrop-filter]:bg-background/80", children: [_jsx("label", { htmlFor: htmlFor, className: "text-xs font-semibold text-muted-foreground", children: label }), action
|
|
4
|
+
? ctx.renderAiFieldAction?.({
|
|
5
|
+
...action,
|
|
6
|
+
fieldLabel: label,
|
|
7
|
+
})
|
|
8
|
+
: null] }));
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=AiEditableField.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"AiEditableField.js","sourceRoot":"","sources":["../../../src/client/blocks/AiEditableField.tsx"],"names":[],"mappings":";AAEA,MAAM,UAAU,oBAAoB,CAAC,EACnC,OAAO,EACP,KAAK,EACL,GAAG,EACH,MAAM,GAMP;IACC,OAAO,CACL,eAAK,SAAS,EAAC,2IAA2I,aACxJ,gBACE,OAAO,EAAE,OAAO,EAChB,SAAS,EAAC,6CAA6C,YAEtD,KAAK,GACA,EACP,MAAM;gBACL,CAAC,CAAC,GAAG,CAAC,mBAAmB,EAAE,CAAC;oBACxB,GAAG,MAAM;oBACT,UAAU,EAAE,KAAK;iBAClB,CAAC;gBACJ,CAAC,CAAC,IAAI,IACJ,CACP,CAAC;AACJ,CAAC","sourcesContent":["import type { BlockAiFieldActionProps, BlockRenderContext } from \"./types.js\";\n\nexport function AiEditableFieldLabel({\n htmlFor,\n label,\n ctx,\n action,\n}: {\n htmlFor: string;\n label: string;\n ctx: BlockRenderContext;\n action?: Omit<BlockAiFieldActionProps, \"fieldLabel\">;\n}) {\n return (\n <div className=\"sticky top-0 z-10 flex items-center justify-between gap-3 bg-background/95 py-1 backdrop-blur supports-[backdrop-filter]:bg-background/80\">\n <label\n htmlFor={htmlFor}\n className=\"text-xs font-semibold text-muted-foreground\"\n >\n {label}\n </label>\n {action\n ? ctx.renderAiFieldAction?.({\n ...action,\n fieldLabel: label,\n })\n : null}\n </div>\n );\n}\n"]}
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import type { BlockSpec, BlockRenderContext } from "./types.js";
|
|
1
|
+
import type { BlockDataChangeMeta, BlockSpec, BlockRenderContext } from "./types.js";
|
|
2
2
|
/**
|
|
3
3
|
* Resolve a spec's effective edit surface. Defaults to `"inline"` when the block
|
|
4
4
|
* ships a custom `Edit` (its author built direct-manipulation editing), else
|
|
5
5
|
* `"panel"` — an auto-form block is a property form, which reads best behind a
|
|
6
6
|
* corner edit button. An explicit `spec.editSurface` always wins.
|
|
7
7
|
*/
|
|
8
|
-
export declare function blockEditSurface(spec: BlockSpec<any>): "inline" | "panel";
|
|
8
|
+
export declare function blockEditSurface(spec: BlockSpec<any>): "inline" | "panel" | "container";
|
|
9
9
|
/**
|
|
10
10
|
* Render one registered block. In read mode (or when the spec is inline-only and
|
|
11
11
|
* not editing) it renders the spec's `Read`. In edit mode for a `block`-placed
|
|
@@ -29,7 +29,7 @@ export declare function BlockView({ spec, block, editing, editable, onChange, ct
|
|
|
29
29
|
/** Whether this specific block allows editing (block.editable !== false). */
|
|
30
30
|
editable?: boolean;
|
|
31
31
|
/** Commit a new `data` value for the block. */
|
|
32
|
-
onChange?: (nextData: unknown) => void;
|
|
32
|
+
onChange?: (nextData: unknown, meta?: BlockDataChangeMeta) => void;
|
|
33
33
|
ctx: BlockRenderContext;
|
|
34
34
|
}): import("react/jsx-runtime").JSX.Element;
|
|
35
35
|
//# sourceMappingURL=BlockView.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockView.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/BlockView.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"BlockView.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/BlockView.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,EACV,mBAAmB,EACnB,SAAS,EACT,kBAAkB,EACnB,MAAM,YAAY,CAAC;AAGpB;;;;;GAKG;AACH,wBAAgB,gBAAgB,CAC9B,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,GACnB,QAAQ,GAAG,OAAO,GAAG,WAAW,CAElC;AAED;;;;;;;;;GASG;AACH,wBAAgB,SAAS,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAe,EACf,QAAQ,EACR,GAAG,GACJ,EAAE;IACD,IAAI,EAAE,SAAS,CAAC,GAAG,CAAC,CAAC;IACrB,KAAK,EAAE;QAAE,EAAE,EAAE,MAAM,CAAC;QAAC,KAAK,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAC;QAAC,IAAI,EAAE,OAAO,CAAA;KAAE,CAAC;IACvE,yDAAyD;IACzD,OAAO,EAAE,OAAO,CAAC;IACjB,6EAA6E;IAC7E,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,+CAA+C;IAC/C,QAAQ,CAAC,EAAE,CAAC,QAAQ,EAAE,OAAO,EAAE,IAAI,CAAC,EAAE,mBAAmB,KAAK,IAAI,CAAC;IACnE,GAAG,EAAE,kBAAkB,CAAC;CACzB,2CA0FA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { useState } from "react";
|
|
2
3
|
import { IconPencil } from "@tabler/icons-react";
|
|
3
4
|
import { SchemaBlockEditor } from "./SchemaBlockEditor.js";
|
|
4
5
|
/**
|
|
@@ -21,21 +22,32 @@ export function blockEditSurface(spec) {
|
|
|
21
22
|
* recognizes a block type — the legacy switch handles unregistered types.
|
|
22
23
|
*/
|
|
23
24
|
export function BlockView({ spec, block, editing, editable = true, onChange, ctx, }) {
|
|
25
|
+
const [panelHovered, setPanelHovered] = useState(false);
|
|
24
26
|
const Read = spec.Read;
|
|
25
27
|
const readNode = (_jsx(Read, { data: block.data, blockId: block.id, title: block.title, summary: block.summary, ctx: ctx }));
|
|
26
28
|
const canEdit = editing && editable && spec.placement.includes("block") && !!onChange;
|
|
27
29
|
if (!canEdit)
|
|
28
30
|
return readNode;
|
|
29
|
-
const commit = (nextData) => onChange?.(nextData);
|
|
31
|
+
const commit = (nextData, meta) => onChange?.(nextData, meta);
|
|
32
|
+
const updatePanelHover = (event) => {
|
|
33
|
+
const target = event.target;
|
|
34
|
+
setPanelHovered(target instanceof HTMLElement &&
|
|
35
|
+
target.closest(".an-block-panel") === event.currentTarget);
|
|
36
|
+
};
|
|
30
37
|
const Edit = spec.Edit;
|
|
31
38
|
const formNode = Edit ? (_jsx(Edit, { data: block.data, onChange: commit, editable: true, blockId: block.id, title: block.title, summary: block.summary, ctx: ctx })) : (_jsx(SchemaBlockEditor, { data: block.data, onChange: commit, schema: spec.schema, editable: true, blockId: block.id, ctx: ctx }));
|
|
32
39
|
// Panel mode: show the rendered block with a corner edit button that opens the
|
|
33
40
|
// form in the app-provided panel (popover). Falls back to inline editing when
|
|
34
41
|
// the app hasn't wired `renderEditSurface`.
|
|
35
42
|
if (blockEditSurface(spec) === "panel" && ctx.renderEditSurface) {
|
|
36
|
-
return (_jsxs("div", { className: "an-block-panel
|
|
43
|
+
return (_jsxs("div", { className: "an-block-panel relative", onMouseEnter: updatePanelHover, onMouseMove: updatePanelHover, onMouseLeave: () => setPanelHovered(false), children: [readNode, _jsx("div", { className: "an-block-panel__edit absolute right-2 top-2 z-10", children: ctx.renderEditSurface({
|
|
37
44
|
title: spec.label,
|
|
38
|
-
|
|
45
|
+
blockId: block.id,
|
|
46
|
+
blockType: spec.type,
|
|
47
|
+
blockTitle: block.title,
|
|
48
|
+
blockSummary: block.summary,
|
|
49
|
+
blockData: block.data,
|
|
50
|
+
trigger: (_jsx("button", { type: "button", "data-plan-interactive": true, "aria-label": `Edit ${spec.label}`, className: "an-block-edit-trigger flex size-7 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring data-[visible=true]:opacity-100", "data-visible": panelHovered, children: _jsx(IconPencil, { className: "size-4" }) })),
|
|
39
51
|
children: formNode,
|
|
40
52
|
}) })] }));
|
|
41
53
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockView.js","sourceRoot":"","sources":["../../../src/client/blocks/BlockView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;
|
|
1
|
+
{"version":3,"file":"BlockView.js","sourceRoot":"","sources":["../../../src/client/blocks/BlockView.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,QAAQ,EAAsC,MAAM,OAAO,CAAC;AACrE,OAAO,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAMjD,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D;;;;;GAKG;AACH,MAAM,UAAU,gBAAgB,CAC9B,IAAoB;IAEpB,OAAO,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,CAAC,QAAQ,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC;AAC9D,CAAC;AAED;;;;;;;;;GASG;AACH,MAAM,UAAU,SAAS,CAAC,EACxB,IAAI,EACJ,KAAK,EACL,OAAO,EACP,QAAQ,GAAG,IAAI,EACf,QAAQ,EACR,GAAG,GAWJ;IACC,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IACxD,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;IACvB,MAAM,QAAQ,GAAG,CACf,KAAC,IAAI,IACH,IAAI,EAAE,KAAK,CAAC,IAAI,EAChB,OAAO,EAAE,KAAK,CAAC,EAAE,EACjB,KAAK,EAAE,KAAK,CAAC,KAAK,E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,CAAC,IAAI,CAAC,KAAK,OAAO,IAAI,GAAG,CAAC,iBAAiB,EAAE,CAAC;QAChE,OAAO,CACL,eACE,SAAS,EAAC,yBAAyB,EACnC,YAAY,EAAE,gBAAgB,EAC9B,WAAW,EAAE,gBAAgB,EAC7B,YAAY,EAAE,GAAG,EAAE,CAAC,eAAe,CAAC,KAAK,CAAC,aAEzC,QAAQ,EACT,cAAK,SAAS,EAAC,kDAAkD,YAC9D,GAAG,CAAC,iBAAiB,CAAC;wBACrB,KAAK,EAAE,IAAI,CAAC,KAAK;wBACjB,OAAO,EAAE,KAAK,CAAC,EAAE;wBACjB,SAAS,EAAE,IAAI,CAAC,IAAI;wBACpB,UAAU,EAAE,KAAK,CAAC,KAAK;wBACvB,YAAY,EAAE,KAAK,CAAC,OAAO;wBAC3B,SAAS,EAAE,KAAK,CAAC,IAAI;wBACrB,OAAO,EAAE,CACP,iBACE,IAAI,EAAC,QAAQ,+CAED,QAAQ,IAAI,CAAC,KAAK,EAAE,EAChC,SAAS,EAAC,6RAA6R,kBACzR,YAAY,YAE1B,KAAC,UAAU,IAAC,SAAS,EAAC,QAAQ,GAAG,GAC1B,CACV;wBACD,QAAQ,EAAE,QAAQ;qBACnB,CAAC,GACE,IACF,CACP,CAAC;IACJ,CAAC;IAED,qCAAqC;IACrC,OAAO,QAAQ,CAAC;AAClB,CAAC","sourcesContent":["import { useState, type MouseEvent as ReactMouseEvent } from \"react\";\nimport { IconPencil } from \"@tabler/icons-react\";\nimport type {\n BlockDataChangeMeta,\n BlockSpec,\n BlockRenderContext,\n} from \"./types.js\";\nimport { SchemaBlockEditor } from \"./SchemaBlockEditor.js\";\n\n/**\n * Resolve a spec's effective edit surface. Defaults to `\"inline\"` when the block\n * ships a custom `Edit` (its author built direct-manipulation editing), else\n * `\"panel\"` — an auto-form block is a property form, which reads best behind a\n * corner edit button. An explicit `spec.editSurface` always wins.\n */\nexport function blockEditSurface(\n spec: BlockSpec<any>,\n): \"inline\" | \"panel\" | \"container\" {\n return spec.editSurface ?? (spec.Edit ? \"inline\" : \"panel\");\n}\n\n/**\n * Render one registered block. In read mode (or when the spec is inline-only and\n * not editing) it renders the spec's `Read`. In edit mode for a `block`-placed\n * spec it renders the editor — either inline (the spec's `Edit` or the\n * schema-driven {@link SchemaBlockEditor}) or, for `editSurface: \"panel\"` blocks,\n * the rendered `Read` plus a corner edit button that opens that editor in the\n * app-provided panel ({@link BlockRenderContext.renderEditSurface}, e.g. a\n * popover). This is what the app renderer delegates to once the registry\n * recognizes a block type — the legacy switch handles unregistered types.\n */\nexport function BlockView({\n spec,\n block,\n editing,\n editable = true,\n onChange,\n ctx,\n}: {\n spec: BlockSpec<any>;\n block: { id: string; title?: string; summary?: string; data: unknown };\n /** Whether the document is in an editable/edit state. */\n editing: boolean;\n /** Whether this specific block allows editing (block.editable !== false). */\n editable?: boolean;\n /** Commit a new `data` value for the block. */\n onChange?: (nextData: unknown, meta?: BlockDataChangeMeta) => void;\n ctx: BlockRenderContext;\n}) {\n const [panelHovered, setPanelHovered] = useState(false);\n const Read = spec.Read;\n const readNode = (\n <Read\n data={block.data}\n blockId={block.id}\n title={block.title}\n summary={block.summary}\n ctx={ctx}\n />\n );\n\n const canEdit =\n editing && editable && spec.placement.includes(\"block\") && !!onChange;\n\n if (!canEdit) return readNode;\n\n const commit = (nextData: unknown, meta?: BlockDataChangeMeta) =>\n onChange?.(nextData, meta);\n const updatePanelHover = (event: ReactMouseEvent<HTMLElement>) => {\n const target = event.target;\n setPanelHovered(\n target instanceof HTMLElement &&\n target.closest(\".an-block-panel\") === event.currentTarget,\n );\n };\n\n const Edit = spec.Edit;\n const formNode = Edit ? (\n <Edit\n data={block.data}\n onChange={commit}\n editable\n blockId={block.id}\n title={block.title}\n summary={block.summary}\n ctx={ctx}\n />\n ) : (\n <SchemaBlockEditor\n data={block.data}\n onChange={commit}\n schema={spec.schema}\n editable\n blockId={block.id}\n ctx={ctx}\n />\n );\n\n // Panel mode: show the rendered block with a corner edit button that opens the\n // form in the app-provided panel (popover). Falls back to inline editing when\n // the app hasn't wired `renderEditSurface`.\n if (blockEditSurface(spec) === \"panel\" && ctx.renderEditSurface) {\n return (\n <div\n className=\"an-block-panel relative\"\n onMouseEnter={updatePanelHover}\n onMouseMove={updatePanelHover}\n onMouseLeave={() => setPanelHovered(false)}\n >\n {readNode}\n <div className=\"an-block-panel__edit absolute right-2 top-2 z-10\">\n {ctx.renderEditSurface({\n title: spec.label,\n blockId: block.id,\n blockType: spec.type,\n blockTitle: block.title,\n blockSummary: block.summary,\n blockData: block.data,\n trigger: (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label={`Edit ${spec.label}`}\n className=\"an-block-edit-trigger flex size-7 items-center justify-center rounded-md text-muted-foreground opacity-0 transition-[color,opacity] hover:text-foreground focus-visible:opacity-100 focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring data-[visible=true]:opacity-100\"\n data-visible={panelHovered}\n >\n <IconPencil className=\"size-4\" />\n </button>\n ),\n children: formNode,\n })}\n </div>\n </div>\n );\n }\n\n // Inline mode (direct manipulation).\n return formNode;\n}\n"]}
|
|
@@ -31,8 +31,8 @@ export function SchemaBlockEditor({ data, onChange, schema, editable, blockId, c
|
|
|
31
31
|
const optional = fields.filter((field) => field.optional);
|
|
32
32
|
return (_jsxs("div", { className: "an-schema-block-editor flex flex-col gap-3", children: [required.map((field) => (_jsx(FieldControl, { field: field, value: data[field.key], onChange: (value) => setField(field.key, value), editable: editable, blockId: blockId, ctx: ctx }, field.key))), optional.length > 0 && (_jsx("div", { className: "flex flex-col gap-3", children: showOptional ? (optional.map((field) => (_jsx(FieldControl, { field: field, value: data[field.key], onChange: (value) => setField(field.key, value), editable: editable, blockId: blockId, ctx: ctx }, field.key)))) : (_jsx("button", { type: "button", "data-plan-interactive": true, className: "self-start text-sm text-muted-foreground underline-offset-2 hover:underline", onClick: () => setShowOptional(true), children: "More options" })) }))] }));
|
|
33
33
|
}
|
|
34
|
-
const inputClass = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm
|
|
35
|
-
const textareaClass = "flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm
|
|
34
|
+
const inputClass = "flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
|
|
35
|
+
const textareaClass = "flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50";
|
|
36
36
|
function FieldLabel({ children }) {
|
|
37
37
|
return (_jsx("span", { className: "text-xs font-medium text-muted-foreground", children: children }));
|
|
38
38
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"SchemaBlockEditor.js","sourceRoot":"","sources":["../../../src/client/blocks/SchemaBlockEditor.tsx"],"names":[],"mappings":";AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAC1D,OAAO,EAAE,EAAE,EAAE,MAAM,aAAa,CAAC;AAEjC,OAAO,EAAE,UAAU,EAAwB,MAAM,6BAA6B,CAAC;AAE/E;;;;;;;;;;;;;GAaG;AACH,MAAM,UAAU,iBAAiB,CAAI,EACnC,IAAI,EACJ,QAAQ,EACR,MAAM,EACN,QAAQ,EACR,OAAO,EACP,GAAG,GAQJ;IACC,MAAM,MAAM,GAAG,OAAO,CAAC,GAAG,EAAE,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3D,MAAM,CAAC,YAAY,EAAE,eAAe,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAC;IAExD,MAAM,QAAQ,GAAG,CAAC,GAAW,EAAE,KA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C,KAAC,SAAS,IAAC,SAAS,EAAC,QAAQ,GAAG,GACzB,CACV,KAvEI,KAAK,CAwEN,CACP,CAAC,GACE,EACL,QAAQ,IAAI,CACX,kBACE,IAAI,EAAC,QAAQ,iCAEb,SAAS,EAAC,oIAAoI,EAC9I,OAAO,EAAE,OAAO,aAEhB,KAAC,QAAQ,IAAC,SAAS,EAAC,QAAQ,GAAG,UAC1B,KAAK,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,IAAI,MAAM,IACpD,CACV,IACG,CACP,CAAC;IACJ,CAAC;IAED,0EAA0E;IAC1E,2EAA2E;IAC3E,qCAAqC;IACrC,OAAO,CACL,eACE,SAAS,EAAE,EAAE,CACX,sFAAsF,CACvF,aAED,KAAC,UAAU,cAAE,KAAK,CAAC,KAAK,GAAc,EACtC,aAAG,SAAS,EAAC,MAAM,6BACJ,KAAK,CAAC,IAAI,uEAErB,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState } from \"react\";\nimport type { ZodType } from \"zod\";\nimport { IconPlus, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../utils.js\";\nimport type { BlockRenderContext } from \"./types.js\";\nimport { introspect, type FieldDescriptor } from \"./schema-form/introspect.js\";\n\n/**\n * Schema-driven auto-editor. When a {@link BlockSpec} omits `Edit`, the registry\n * renders this: it walks the block's zod `data` schema and renders one control\n * per field (string → input, longtext → textarea, number, boolean → toggle,\n * enum → native select, array → repeating rows, object → nested fieldset). A\n * `markdown()`-tagged string field defers to the app-provided inline rich\n * editor via `ctx.renderMarkdownEditor` so prose stays Notion-editable.\n *\n * It uses plain accessible native controls (not template shadcn primitives,\n * which core does not bundle) styled to match the shadcn look. Validation runs\n * the spec's own schema on every edit; the raw edit is kept in local state so a\n * transiently-invalid value (e.g. mid-typing) doesn't get rolled back, and only\n * valid data is committed upstream.\n */\nexport function SchemaBlockEditor<T>({\n data,\n onChange,\n schema,\n editable,\n blockId,\n ctx,\n}: {\n data: T;\n onChange: (next: T) => void;\n schema: ZodType<T>;\n editable: boolean;\n blockId?: string;\n ctx: BlockRenderContext;\n}) {\n const fields = useMemo(() => introspect(schema), [schema]);\n const [showOptional, setShowOptional] = useState(false);\n\n const setField = (key: string, value: unknown) => {\n const next = { ...(data as Record<string, unknown>), [key]: value } as T;\n const parsed = schema.safeParse(next);\n // Commit valid data; otherwise pass the raw edit through so the user can\n // keep typing — the upstream owner re-validates before persisting.\n onChange((parsed.success ? parsed.data : next) as T);\n };\n\n const required = fields.filter((field) => !field.optional);\n const optional = fields.filter((field) => field.optional);\n\n return (\n <div className=\"an-schema-block-editor flex flex-col gap-3\">\n {required.map((field) => (\n <FieldControl\n key={field.key}\n field={field}\n value={(data as Record<string, unknown>)[field.key]}\n onChange={(value) => setField(field.key, value)}\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))}\n {optional.length > 0 && (\n <div className=\"flex flex-col gap-3\">\n {showOptional ? (\n optional.map((field) => (\n <FieldControl\n key={field.key}\n field={field}\n value={(data as Record<string, unknown>)[field.key]}\n onChange={(value) => setField(field.key, value)}\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))\n ) : (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"self-start text-sm text-muted-foreground underline-offset-2 hover:underline\"\n onClick={() => setShowOptional(true)}\n >\n More options\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nconst inputClass =\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm shadow-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\nconst textareaClass =\n \"flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm shadow-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\nfunction FieldLabel({ children }: { children: React.ReactNode }) {\n return (\n <span className=\"text-xs font-medium text-muted-foreground\">\n {children}\n </span>\n );\n}\n\n/** A sensible empty value for a single field, used when adding array items. */\nfunction emptyForField(field: FieldDescriptor): unknown {\n switch (field.kind) {\n case \"text\":\n // A field literally named `id` gets a fresh stable id so new rows are\n // distinguishable without the user having to type one.\n return field.key === \"id\"\n ? `item-${Math.random().toString(36).slice(2, 10)}`\n : \"\";\n case \"longtext\":\n case \"markdown\":\n case \"richtext\":\n return \"\";\n case \"boolean\":\n return false;\n case \"enum\":\n return field.enumValues?.[0];\n case \"array\":\n return [];\n case \"object\":\n return emptyObjectFromFields(field.fields);\n case \"number\":\n default:\n // number → undefined (the input shows blank until the user types); any\n // unsupported kind also defaults to undefined.\n return undefined;\n }\n}\n\n/** Build an empty object value from a descriptor's child fields. */\nfunction emptyObjectFromFields(\n fields: FieldDescriptor[] | undefined,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const child of fields ?? []) {\n result[child.key] = emptyForField(child);\n }\n return result;\n}\n\n/** A scalar element kind classified from an array's inner element schema. */\nfunction scalarKindFromInner(\n inner: FieldDescriptor[\"inner\"],\n): \"number\" | \"boolean\" | \"text\" {\n const type = (inner?._def as { type?: string } | undefined)?.type;\n if (type === \"number\" || type === \"bigint\") return \"number\";\n if (type === \"boolean\") return \"boolean\";\n return \"text\";\n}\n\n/** An empty value for a scalar array element of the given kind. */\nfunction emptyScalar(kind: \"number\" | \"boolean\" | \"text\"): unknown {\n if (kind === \"boolean\") return false;\n if (kind === \"number\") return undefined;\n return \"\";\n}\n\nfunction FieldControl({\n field,\n value,\n onChange,\n editable,\n blockId,\n ctx,\n}: {\n field: FieldDescriptor;\n value: unknown;\n onChange: (value: unknown) => void;\n editable: boolean;\n blockId?: string;\n ctx: BlockRenderContext;\n}) {\n if (field.kind === \"markdown\" || field.kind === \"richtext\") {\n const node = ctx.renderMarkdownEditor?.({\n value: typeof value === \"string\" ? value : \"\",\n onChange: (next) => onChange(next),\n editable,\n blockId,\n });\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n {node ?? (\n // Fallback when no app markdown editor is injected: a plain textarea.\n <textarea\n data-plan-interactive\n className={textareaClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n )}\n </label>\n );\n }\n\n if (field.kind === \"boolean\") {\n return (\n <label className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n data-plan-interactive\n className=\"size-4 rounded border-input accent-primary\"\n checked={Boolean(value)}\n disabled={!editable}\n onChange={(event) => onChange(event.target.checked)}\n />\n <FieldLabel>{field.label}</FieldLabel>\n </label>\n );\n }\n\n if (field.kind === \"enum\") {\n const options = field.enumValues ?? [];\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <select\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value || undefined)}\n >\n {field.optional && <option value=\"\">—</option>}\n {options.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n </label>\n );\n }\n\n if (field.kind === \"number\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <input\n type=\"number\"\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"number\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => {\n const raw = event.target.value;\n onChange(raw === \"\" ? undefined : Number(raw));\n }}\n />\n </label>\n );\n }\n\n if (field.kind === \"longtext\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <textarea\n data-plan-interactive\n className={textareaClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n </label>\n );\n }\n\n if (field.kind === \"text\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <input\n type=\"text\"\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n </label>\n );\n }\n\n if (field.kind === \"object\" && field.fields && field.fields.length > 0) {\n const objValue =\n value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n return (\n <div className=\"flex flex-col gap-3 rounded-md border border-input px-3 py-3\">\n <FieldLabel>{field.label}</FieldLabel>\n <div className=\"flex flex-col gap-3\">\n {field.fields.map((child) => (\n <FieldControl\n key={child.key}\n field={child}\n value={objValue[child.key]}\n onChange={(childVal) =>\n onChange({ ...objValue, [child.key]: childVal })\n }\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))}\n </div>\n </div>\n );\n }\n\n if (field.kind === \"array\") {\n const items = Array.isArray(value) ? (value as unknown[]) : [];\n const replaceItem = (index: number, next: unknown) => {\n const copy = items.slice();\n copy[index] = next;\n onChange(copy);\n };\n const removeItem = (index: number) => {\n onChange(items.filter((_, i) => i !== index));\n };\n const objectElement =\n Array.isArray(field.fields) && field.fields.length > 0;\n const scalarKind = objectElement ? null : scalarKindFromInner(field.inner);\n const addItem = () => {\n if (objectElement) {\n onChange([...items, emptyObjectFromFields(field.fields)]);\n } else {\n onChange([...items, emptyScalar(scalarKind ?? \"text\")]);\n }\n };\n return (\n <div className=\"flex flex-col gap-2\">\n <FieldLabel>{field.label}</FieldLabel>\n <div className=\"flex flex-col gap-2\">\n {items.map((item, index) => (\n <div\n key={index}\n className=\"flex items-start gap-2 rounded-md border border-input px-3 py-3\"\n >\n <div className=\"flex flex-1 flex-col gap-3\">\n {objectElement ? (\n field.fields!.map((child) => {\n const itemValue =\n item && typeof item === \"object\" && !Array.isArray(item)\n ? (item as Record<string, unknown>)\n : {};\n return (\n <FieldControl\n key={child.key}\n field={child}\n value={itemValue[child.key]}\n onChange={(childVal) =>\n replaceItem(index, {\n ...itemValue,\n [child.key]: childVal,\n })\n }\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n );\n })\n ) : scalarKind === \"boolean\" ? (\n <input\n type=\"checkbox\"\n data-plan-interactive\n className=\"size-4 self-start rounded border-input accent-primary\"\n checked={Boolean(item)}\n disabled={!editable}\n onChange={(event) =>\n replaceItem(index, event.target.checked)\n }\n />\n ) : scalarKind === \"number\" ? (\n <input\n type=\"number\"\n data-plan-interactive\n className={inputClass}\n value={typeof item === \"number\" ? item : \"\"}\n disabled={!editable}\n onChange={(event) => {\n const raw = event.target.value;\n replaceItem(index, raw === \"\" ? undefined : Number(raw));\n }}\n />\n ) : (\n <input\n type=\"text\"\n data-plan-interactive\n className={inputClass}\n value={typeof item === \"string\" ? item : \"\"}\n disabled={!editable}\n onChange={(event) => replaceItem(index, event.target.value)}\n />\n )}\n </div>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove item\"\n className=\"mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => removeItem(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n ))}\n </div>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex items-center gap-1.5 self-start text-sm text-muted-foreground underline-offset-2 hover:text-foreground hover:underline\"\n onClick={addItem}\n >\n <IconPlus className=\"size-4\" />\n Add {field.label.replace(/s$/i, \"\").toLowerCase() || \"item\"}\n </button>\n )}\n </div>\n );\n }\n\n // Unsupported / structured-without-fields: the auto-editor cannot infer a\n // control. Blocks with these fields should ship a custom `Edit`. Surface a\n // hint in dev so the gap is visible.\n return (\n <div\n className={cn(\n \"rounded-md border border-dashed border-input px-3 py-2 text-xs text-muted-foreground\",\n )}\n >\n <FieldLabel>{field.label}</FieldLabel>\n <p className=\"mt-1\">\n This field ({field.kind}) needs a custom editor — define `Edit` on the\n block spec.\n </p>\n </div>\n );\n}\n"]}
|
|
1
|
+
{"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SAAS,EAAC,MAAM,6BACJ,KAAK,CAAC,IAAI,uEAErB,IACA,CACP,CAAC;AACJ,CAAC","sourcesContent":["import { useMemo, useState } from \"react\";\nimport type { ZodType } from \"zod\";\nimport { IconPlus, IconTrash } from \"@tabler/icons-react\";\nimport { cn } from \"../utils.js\";\nimport type { BlockRenderContext } from \"./types.js\";\nimport { introspect, type FieldDescriptor } from \"./schema-form/introspect.js\";\n\n/**\n * Schema-driven auto-editor. When a {@link BlockSpec} omits `Edit`, the registry\n * renders this: it walks the block's zod `data` schema and renders one control\n * per field (string → input, longtext → textarea, number, boolean → toggle,\n * enum → native select, array → repeating rows, object → nested fieldset). A\n * `markdown()`-tagged string field defers to the app-provided inline rich\n * editor via `ctx.renderMarkdownEditor` so prose stays Notion-editable.\n *\n * It uses plain accessible native controls (not template shadcn primitives,\n * which core does not bundle) styled to match the shadcn look. Validation runs\n * the spec's own schema on every edit; the raw edit is kept in local state so a\n * transiently-invalid value (e.g. mid-typing) doesn't get rolled back, and only\n * valid data is committed upstream.\n */\nexport function SchemaBlockEditor<T>({\n data,\n onChange,\n schema,\n editable,\n blockId,\n ctx,\n}: {\n data: T;\n onChange: (next: T) => void;\n schema: ZodType<T>;\n editable: boolean;\n blockId?: string;\n ctx: BlockRenderContext;\n}) {\n const fields = useMemo(() => introspect(schema), [schema]);\n const [showOptional, setShowOptional] = useState(false);\n\n const setField = (key: string, value: unknown) => {\n const next = { ...(data as Record<string, unknown>), [key]: value } as T;\n const parsed = schema.safeParse(next);\n // Commit valid data; otherwise pass the raw edit through so the user can\n // keep typing — the upstream owner re-validates before persisting.\n onChange((parsed.success ? parsed.data : next) as T);\n };\n\n const required = fields.filter((field) => !field.optional);\n const optional = fields.filter((field) => field.optional);\n\n return (\n <div className=\"an-schema-block-editor flex flex-col gap-3\">\n {required.map((field) => (\n <FieldControl\n key={field.key}\n field={field}\n value={(data as Record<string, unknown>)[field.key]}\n onChange={(value) => setField(field.key, value)}\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))}\n {optional.length > 0 && (\n <div className=\"flex flex-col gap-3\">\n {showOptional ? (\n optional.map((field) => (\n <FieldControl\n key={field.key}\n field={field}\n value={(data as Record<string, unknown>)[field.key]}\n onChange={(value) => setField(field.key, value)}\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))\n ) : (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"self-start text-sm text-muted-foreground underline-offset-2 hover:underline\"\n onClick={() => setShowOptional(true)}\n >\n More options\n </button>\n )}\n </div>\n )}\n </div>\n );\n}\n\nconst inputClass =\n \"flex h-9 w-full rounded-md border border-input bg-transparent px-3 py-1 text-sm transition-colors placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\nconst textareaClass =\n \"flex min-h-[80px] w-full rounded-md border border-input bg-transparent px-3 py-2 text-sm placeholder:text-muted-foreground focus-visible:outline-none focus-visible:ring-1 focus-visible:ring-ring disabled:cursor-not-allowed disabled:opacity-50\";\n\nfunction FieldLabel({ children }: { children: React.ReactNode }) {\n return (\n <span className=\"text-xs font-medium text-muted-foreground\">\n {children}\n </span>\n );\n}\n\n/** A sensible empty value for a single field, used when adding array items. */\nfunction emptyForField(field: FieldDescriptor): unknown {\n switch (field.kind) {\n case \"text\":\n // A field literally named `id` gets a fresh stable id so new rows are\n // distinguishable without the user having to type one.\n return field.key === \"id\"\n ? `item-${Math.random().toString(36).slice(2, 10)}`\n : \"\";\n case \"longtext\":\n case \"markdown\":\n case \"richtext\":\n return \"\";\n case \"boolean\":\n return false;\n case \"enum\":\n return field.enumValues?.[0];\n case \"array\":\n return [];\n case \"object\":\n return emptyObjectFromFields(field.fields);\n case \"number\":\n default:\n // number → undefined (the input shows blank until the user types); any\n // unsupported kind also defaults to undefined.\n return undefined;\n }\n}\n\n/** Build an empty object value from a descriptor's child fields. */\nfunction emptyObjectFromFields(\n fields: FieldDescriptor[] | undefined,\n): Record<string, unknown> {\n const result: Record<string, unknown> = {};\n for (const child of fields ?? []) {\n result[child.key] = emptyForField(child);\n }\n return result;\n}\n\n/** A scalar element kind classified from an array's inner element schema. */\nfunction scalarKindFromInner(\n inner: FieldDescriptor[\"inner\"],\n): \"number\" | \"boolean\" | \"text\" {\n const type = (inner?._def as { type?: string } | undefined)?.type;\n if (type === \"number\" || type === \"bigint\") return \"number\";\n if (type === \"boolean\") return \"boolean\";\n return \"text\";\n}\n\n/** An empty value for a scalar array element of the given kind. */\nfunction emptyScalar(kind: \"number\" | \"boolean\" | \"text\"): unknown {\n if (kind === \"boolean\") return false;\n if (kind === \"number\") return undefined;\n return \"\";\n}\n\nfunction FieldControl({\n field,\n value,\n onChange,\n editable,\n blockId,\n ctx,\n}: {\n field: FieldDescriptor;\n value: unknown;\n onChange: (value: unknown) => void;\n editable: boolean;\n blockId?: string;\n ctx: BlockRenderContext;\n}) {\n if (field.kind === \"markdown\" || field.kind === \"richtext\") {\n const node = ctx.renderMarkdownEditor?.({\n value: typeof value === \"string\" ? value : \"\",\n onChange: (next) => onChange(next),\n editable,\n blockId,\n });\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n {node ?? (\n // Fallback when no app markdown editor is injected: a plain textarea.\n <textarea\n data-plan-interactive\n className={textareaClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n )}\n </label>\n );\n }\n\n if (field.kind === \"boolean\") {\n return (\n <label className=\"flex items-center gap-2\">\n <input\n type=\"checkbox\"\n data-plan-interactive\n className=\"size-4 rounded border-input accent-primary\"\n checked={Boolean(value)}\n disabled={!editable}\n onChange={(event) => onChange(event.target.checked)}\n />\n <FieldLabel>{field.label}</FieldLabel>\n </label>\n );\n }\n\n if (field.kind === \"enum\") {\n const options = field.enumValues ?? [];\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <select\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value || undefined)}\n >\n {field.optional && <option value=\"\">—</option>}\n {options.map((option) => (\n <option key={option} value={option}>\n {option}\n </option>\n ))}\n </select>\n </label>\n );\n }\n\n if (field.kind === \"number\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <input\n type=\"number\"\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"number\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => {\n const raw = event.target.value;\n onChange(raw === \"\" ? undefined : Number(raw));\n }}\n />\n </label>\n );\n }\n\n if (field.kind === \"longtext\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <textarea\n data-plan-interactive\n className={textareaClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n </label>\n );\n }\n\n if (field.kind === \"text\") {\n return (\n <label className=\"flex flex-col gap-1.5\">\n <FieldLabel>{field.label}</FieldLabel>\n <input\n type=\"text\"\n data-plan-interactive\n className={inputClass}\n value={typeof value === \"string\" ? value : \"\"}\n disabled={!editable}\n onChange={(event) => onChange(event.target.value)}\n />\n </label>\n );\n }\n\n if (field.kind === \"object\" && field.fields && field.fields.length > 0) {\n const objValue =\n value && typeof value === \"object\" && !Array.isArray(value)\n ? (value as Record<string, unknown>)\n : {};\n return (\n <div className=\"flex flex-col gap-3 rounded-md border border-input px-3 py-3\">\n <FieldLabel>{field.label}</FieldLabel>\n <div className=\"flex flex-col gap-3\">\n {field.fields.map((child) => (\n <FieldControl\n key={child.key}\n field={child}\n value={objValue[child.key]}\n onChange={(childVal) =>\n onChange({ ...objValue, [child.key]: childVal })\n }\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n ))}\n </div>\n </div>\n );\n }\n\n if (field.kind === \"array\") {\n const items = Array.isArray(value) ? (value as unknown[]) : [];\n const replaceItem = (index: number, next: unknown) => {\n const copy = items.slice();\n copy[index] = next;\n onChange(copy);\n };\n const removeItem = (index: number) => {\n onChange(items.filter((_, i) => i !== index));\n };\n const objectElement =\n Array.isArray(field.fields) && field.fields.length > 0;\n const scalarKind = objectElement ? null : scalarKindFromInner(field.inner);\n const addItem = () => {\n if (objectElement) {\n onChange([...items, emptyObjectFromFields(field.fields)]);\n } else {\n onChange([...items, emptyScalar(scalarKind ?? \"text\")]);\n }\n };\n return (\n <div className=\"flex flex-col gap-2\">\n <FieldLabel>{field.label}</FieldLabel>\n <div className=\"flex flex-col gap-2\">\n {items.map((item, index) => (\n <div\n key={index}\n className=\"flex items-start gap-2 rounded-md border border-input px-3 py-3\"\n >\n <div className=\"flex flex-1 flex-col gap-3\">\n {objectElement ? (\n field.fields!.map((child) => {\n const itemValue =\n item && typeof item === \"object\" && !Array.isArray(item)\n ? (item as Record<string, unknown>)\n : {};\n return (\n <FieldControl\n key={child.key}\n field={child}\n value={itemValue[child.key]}\n onChange={(childVal) =>\n replaceItem(index, {\n ...itemValue,\n [child.key]: childVal,\n })\n }\n editable={editable}\n blockId={blockId}\n ctx={ctx}\n />\n );\n })\n ) : scalarKind === \"boolean\" ? (\n <input\n type=\"checkbox\"\n data-plan-interactive\n className=\"size-4 self-start rounded border-input accent-primary\"\n checked={Boolean(item)}\n disabled={!editable}\n onChange={(event) =>\n replaceItem(index, event.target.checked)\n }\n />\n ) : scalarKind === \"number\" ? (\n <input\n type=\"number\"\n data-plan-interactive\n className={inputClass}\n value={typeof item === \"number\" ? item : \"\"}\n disabled={!editable}\n onChange={(event) => {\n const raw = event.target.value;\n replaceItem(index, raw === \"\" ? undefined : Number(raw));\n }}\n />\n ) : (\n <input\n type=\"text\"\n data-plan-interactive\n className={inputClass}\n value={typeof item === \"string\" ? item : \"\"}\n disabled={!editable}\n onChange={(event) => replaceItem(index, event.target.value)}\n />\n )}\n </div>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n aria-label=\"Remove item\"\n className=\"mt-0.5 inline-flex size-7 shrink-0 items-center justify-center rounded-md text-muted-foreground transition-colors hover:bg-muted hover:text-foreground\"\n onClick={() => removeItem(index)}\n >\n <IconTrash className=\"size-4\" />\n </button>\n )}\n </div>\n ))}\n </div>\n {editable && (\n <button\n type=\"button\"\n data-plan-interactive\n className=\"inline-flex items-center gap-1.5 self-start text-sm text-muted-foreground underline-offset-2 hover:text-foreground hover:underline\"\n onClick={addItem}\n >\n <IconPlus className=\"size-4\" />\n Add {field.label.replace(/s$/i, \"\").toLowerCase() || \"item\"}\n </button>\n )}\n </div>\n );\n }\n\n // Unsupported / structured-without-fields: the auto-editor cannot infer a\n // control. Blocks with these fields should ship a custom `Edit`. Surface a\n // hint in dev so the gap is visible.\n return (\n <div\n className={cn(\n \"rounded-md border border-dashed border-input px-3 py-2 text-xs text-muted-foreground\",\n )}\n >\n <FieldLabel>{field.label}</FieldLabel>\n <p className=\"mt-1\">\n This field ({field.kind}) needs a custom editor — define `Edit` on the\n block spec.\n </p>\n </div>\n );\n}\n"]}
|
|
@@ -13,10 +13,11 @@
|
|
|
13
13
|
* This entry includes the React surface. For server/agent code that must stay
|
|
14
14
|
* React-free, import from `@agent-native/core/blocks/server`.
|
|
15
15
|
*/
|
|
16
|
-
export { defineBlock, type BlockSpec, type BlockPlacement, type BlockMdxConfig, type BlockAttrReader, type BlockRenderContext, type BlockReadProps, type BlockEditProps, type MdxAttrValue, type NestedBlock, } from "./types.js";
|
|
16
|
+
export { defineBlock, type BlockSpec, type BlockPlacement, type BlockMdxConfig, type BlockAttrReader, type BlockRenderContext, type BlockReadProps, type BlockEditProps, type MdxAttrValue, type NestedBlock, type BlockAiFieldActionProps, type BlockContainerRegion, type BlockContainerSpec, type BlockDataChangeMeta, } from "./types.js";
|
|
17
17
|
export { BlockRegistry, registerBlocks } from "./registry.js";
|
|
18
18
|
export { BlockRegistryProvider, useBlockRegistry, useOptionalBlockRegistry, } from "./provider.js";
|
|
19
19
|
export { BlockView, blockEditSurface } from "./BlockView.js";
|
|
20
|
+
export { AiEditableFieldLabel } from "./AiEditableField.js";
|
|
20
21
|
export { SchemaBlockEditor } from "./SchemaBlockEditor.js";
|
|
21
22
|
export { markdown, richtext, introspect, type FieldKind, type FieldDescriptor, } from "./schema-form/introspect.js";
|
|
22
23
|
export { prop, escapeAttr, jsonExpression, attributeValue, createAttrReader, serializeSpecBlock, parseSpecBlock, type MdxJsxNode, type MdxAttrNode, type SerializableBlock, type ParsedBlockBase, } from "./mdx.js";
|
|
@@ -31,7 +32,9 @@ export { codeTabsSchema, codeTabsMdx, type CodeTabsData, type CodeTabsTab, } fro
|
|
|
31
32
|
export { htmlBlock, HtmlReadBlock, HtmlEditBlock } from "./library/html.js";
|
|
32
33
|
export { htmlSchema, htmlMdx, type HtmlBlockData, } from "./library/html.config.js";
|
|
33
34
|
export { tabsBlock, TabsBlockReader, TabsBlockEditor } from "./library/tabs.js";
|
|
34
|
-
export { tabsSchema, tabsMdx, type TabsData, type TabsTab, } from "./library/tabs.config.js";
|
|
35
|
+
export { tabsSchema, tabsMdx, type TabsData, type TabsOrientation, type TabsTab, } from "./library/tabs.config.js";
|
|
36
|
+
export { columnsBlock, ColumnsBlockReader, ColumnsBlockEditor, } from "./library/columns.js";
|
|
37
|
+
export { columnsSchema, columnsMdx, type ColumnsData, type ColumnsColumn, } from "./library/columns.config.js";
|
|
35
38
|
export { MermaidRead, MermaidEdit } from "./library/MermaidBlock.js";
|
|
36
39
|
export { mermaidSchema, mermaidMdx, type MermaidData, } from "./library/mermaid.config.js";
|
|
37
40
|
export { ApiEndpointRead, ApiEndpointEdit, } from "./library/ApiEndpointBlock.js";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAGH,OAAO,EACL,WAAW,EACX,KAAK,SAAS,EACd,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,eAAe,EACpB,KAAK,kBAAkB,EACvB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,mBAAmB,GACzB,MAAM,YAAY,CAAC;AAGpB,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAGvB,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAG3D,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,KAAK,SAAS,EACd,KAAK,eAAe,GACrB,MAAM,6BAA6B,CAAC;AAGrC,OAAO,EACL,IAAI,EACJ,UAAU,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,EACd,KAAK,UAAU,EACf,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,UAAU,CAAC;AAGlB,OAAO,EACL,sBAAsB,EACtB,8BAA8B,EAC9B,KAAK,aAAa,GACnB,MAAM,YAAY,CAAC;AAMpB,OAA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AK,eAAe,GACrB,MAAM,kCAAkC,CAAC"}
|
|
@@ -20,6 +20,7 @@ export { BlockRegistry, registerBlocks } from "./registry.js";
|
|
|
20
20
|
export { BlockRegistryProvider, useBlockRegistry, useOptionalBlockRegistry, } from "./provider.js";
|
|
21
21
|
// Rendering
|
|
22
22
|
export { BlockView, blockEditSurface } from "./BlockView.js";
|
|
23
|
+
export { AiEditableFieldLabel } from "./AiEditableField.js";
|
|
23
24
|
export { SchemaBlockEditor } from "./SchemaBlockEditor.js";
|
|
24
25
|
// Schema-form helpers
|
|
25
26
|
export { markdown, richtext, introspect, } from "./schema-form/introspect.js";
|
|
@@ -28,9 +29,9 @@ export { prop, escapeAttr, jsonExpression, attributeValue, createAttrReader, ser
|
|
|
28
29
|
// Agent schema export
|
|
29
30
|
export { describeBlocksForAgent, renderBlockVocabularyReference, } from "./agent.js";
|
|
30
31
|
// Standard library registration. Apps call `registerLibraryBlocks(registry)` to
|
|
31
|
-
// register the whole standard library (the
|
|
32
|
-
//
|
|
33
|
-
//
|
|
32
|
+
// register the whole standard library (the pre-built specs + dev-doc specs) in
|
|
33
|
+
// one place, then register only their app-specific blocks on top.
|
|
34
|
+
// `libraryBlockSpecs` is the underlying ordered array.
|
|
34
35
|
export { libraryBlockSpecs, registerLibraryBlocks, } from "./library/specs.js";
|
|
35
36
|
// Standard block library (React specs). Apps register these in their browser
|
|
36
37
|
// registry alongside their own app-specific blocks.
|
|
@@ -44,6 +45,8 @@ export { htmlBlock, HtmlReadBlock, HtmlEditBlock } from "./library/html.js";
|
|
|
44
45
|
export { htmlSchema, htmlMdx, } from "./library/html.config.js";
|
|
45
46
|
export { tabsBlock, TabsBlockReader, TabsBlockEditor } from "./library/tabs.js";
|
|
46
47
|
export { tabsSchema, tabsMdx, } from "./library/tabs.config.js";
|
|
48
|
+
export { columnsBlock, ColumnsBlockReader, ColumnsBlockEditor, } from "./library/columns.js";
|
|
49
|
+
export { columnsSchema, columnsMdx, } from "./library/columns.config.js";
|
|
47
50
|
// Dev-doc block library (React `Read`/`Edit` renderers + their React-free
|
|
48
51
|
// schema/MDX config). Apps register these alongside their own blocks, supplying
|
|
49
52
|
// app-specific spec metadata (label/description/editSurface/empty) via
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAoB;AACpB,OAAO,EACL,WAAW,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/client/blocks/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAEH,oBAAoB;AACpB,OAAO,EACL,WAAW,GAcZ,MAAM,YAAY,CAAC;AAEpB,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAC9D,OAAO,EACL,qBAAqB,EACrB,gBAAgB,EAChB,wBAAwB,GACzB,MAAM,eAAe,CAAC;AAEvB,YAAY;AACZ,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,gBAAgB,CAAC;AAC7D,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAC;AAE3D,sBAAsB;AACtB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,GAGX,MAAM,6BAA6B,CAAC;AAErC,+EAA+E;AAC/E,OAAO,EACL,IAAI,EACJ,UAAU,EACV,cAAc,EACd,cAAc,EACd,gBAAgB,EAChB,kBAAkB,EAClB,cAAc,GAKf,MAAM,UAAU,CAAC;AAElB,sBAAsB;AACtB,OAAO,EACL,sBAAsB,EACtB,8BAA8B,GAE/B,MAAM,YAAY,CAAC;AAEpB,gFAAgF;AAChF,+EAA+E;AAC/E,kEAAkE;AAClE,uDAAuD;AACvD,OAAO,EACL,iBAAiB,EACjB,qBAAqB,GAEtB,MAAM,oBAAoB,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,EACZ,yBAAyB,GAM1B,MAAM,gCAAgC,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,wBAAwB,CAAC;AAC5D,OAAO,EACL,UAAU,EACV,OAAO,GAGR,MAAM,0BAA0B,CAAC;AAClC,OAAO,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AACxE,OAAO,EACL,cAAc,EACd,WAAW,EACX,iBAAiB,GAIlB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,gCAAgC,CAAC;AACxC,OAAO,EACL,kBAAkB,EAClB,eAAe,GAEhB,MAAM,mCAAmC,CAAC;AAC3C,OAAO,EACL,iBAAiB,EACjB,iBAAiB,GAClB,MAAM,iCAAiC,CAAC;AACzC,OAAO,EACL,mBAAmB,EACnB,gBAAgB,GAGjB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,EACL,eAAe,EACf,eAAe,GAChB,MAAM,+BAA+B,CAAC;AACvC,OAAO,EACL,iBAAiB,EACjB,cAAc,GAEf,MAAM,kCAAkC,CAAC","sourcesContent":["/**\n * `@agent-native/core/blocks` — the first-party block registry.\n *\n * A block registry unifies structured document blocks under one `defineBlock`\n * contract: a zod `schema` for the data, an `mdx` config for byte-stable MDX\n * round-trip, a `Read` renderer, an optional `Edit` (auto-generated from the\n * schema when omitted), and `placement` (top-level and/or inline). Apps create a\n * `BlockRegistry`, register the core standard library plus their own specs, and\n * render through `BlockView` inside a `BlockRegistryProvider`. The renderer\n * checks the registry first and falls back to legacy code for unregistered\n * types, so existing documents keep working unchanged.\n *\n * This entry includes the React surface. For server/agent code that must stay\n * React-free, import from `@agent-native/core/blocks/server`.\n */\n\n// Types + authoring\nexport {\n defineBlock,\n type BlockSpec,\n type BlockPlacement,\n type BlockMdxConfig,\n type BlockAttrReader,\n type BlockRenderContext,\n type BlockReadProps,\n type BlockEditProps,\n type MdxAttrValue,\n type NestedBlock,\n type BlockAiFieldActionProps,\n type BlockContainerRegion,\n type BlockContainerSpec,\n type BlockDataChangeMeta,\n} from \"./types.js\";\n\n// Registry + provisioning\nexport { BlockRegistry, registerBlocks } from \"./registry.js\";\nexport {\n BlockRegistryProvider,\n useBlockRegistry,\n useOptionalBlockRegistry,\n} from \"./provider.js\";\n\n// Rendering\nexport { BlockView, blockEditSurface } from \"./BlockView.js\";\nexport { AiEditableFieldLabel } from \"./AiEditableField.js\";\nexport { SchemaBlockEditor } from \"./SchemaBlockEditor.js\";\n\n// Schema-form helpers\nexport {\n markdown,\n richtext,\n introspect,\n type FieldKind,\n type FieldDescriptor,\n} from \"./schema-form/introspect.js\";\n\n// MDX round-trip (registry-driven serialize/parse + shared encoder primitives)\nexport {\n prop,\n escapeAttr,\n jsonExpression,\n attributeValue,\n createAttrReader,\n serializeSpecBlock,\n parseSpecBlock,\n type MdxJsxNode,\n type MdxAttrNode,\n type SerializableBlock,\n type ParsedBlockBase,\n} from \"./mdx.js\";\n\n// Agent schema export\nexport {\n describeBlocksForAgent,\n renderBlockVocabularyReference,\n type BlockAgentDoc,\n} from \"./agent.js\";\n\n// Standard library registration. Apps call `registerLibraryBlocks(registry)` to\n// register the whole standard library (the pre-built specs + dev-doc specs) in\n// one place, then register only their app-specific blocks on top.\n// `libraryBlockSpecs` is the underlying ordered array.\nexport {\n libraryBlockSpecs,\n registerLibraryBlocks,\n type LibraryBlockOverrides,\n} from \"./library/specs.js\";\n\n// Standard block library (React specs). Apps register these in their browser\n// registry alongside their own app-specific blocks.\nexport {\n checklistBlock,\n ChecklistBlock,\n ChecklistEditor,\n} from \"./library/checklist.js\";\nexport {\n checklistSchema,\n checklistMdx,\n type ChecklistData,\n type ChecklistItem,\n} from \"./library/checklist.config.js\";\nexport { tableBlock } from \"./library/table.js\";\nexport {\n tableSchema,\n tableMdx,\n type TableData,\n} from \"./library/table.config.js\";\nexport { codeTabsBlock } from \"./library/code-tabs.js\";\nexport {\n codeTabsSchema,\n codeTabsMdx,\n type CodeTabsData,\n type CodeTabsTab,\n} from \"./library/code-tabs.config.js\";\nexport { htmlBlock, HtmlReadBlock, HtmlEditBlock } from \"./library/html.js\";\nexport {\n htmlSchema,\n htmlMdx,\n type HtmlBlockData,\n} from \"./library/html.config.js\";\nexport { tabsBlock, TabsBlockReader, TabsBlockEditor } from \"./library/tabs.js\";\nexport {\n tabsSchema,\n tabsMdx,\n type TabsData,\n type TabsOrientation,\n type TabsTab,\n} from \"./library/tabs.config.js\";\nexport {\n columnsBlock,\n ColumnsBlockReader,\n ColumnsBlockEditor,\n} from \"./library/columns.js\";\nexport {\n columnsSchema,\n columnsMdx,\n type ColumnsData,\n type ColumnsColumn,\n} from \"./library/columns.config.js\";\n\n// Dev-doc block library (React `Read`/`Edit` renderers + their React-free\n// schema/MDX config). Apps register these alongside their own blocks, supplying\n// app-specific spec metadata (label/description/editSurface/empty) via\n// `defineBlock`. Mirrors the standard library above.\nexport { MermaidRead, MermaidEdit } from \"./library/MermaidBlock.js\";\nexport {\n mermaidSchema,\n mermaidMdx,\n type MermaidData,\n} from \"./library/mermaid.config.js\";\nexport {\n ApiEndpointRead,\n ApiEndpointEdit,\n} from \"./library/ApiEndpointBlock.js\";\nexport {\n apiEndpointSchema,\n apiEndpointMdx,\n API_ENDPOINT_METHODS,\n API_PARAM_LOCATIONS,\n type ApiEndpointData,\n type ApiEndpointMethod,\n type ApiEndpointParam,\n type ApiEndpointRequest,\n type ApiEndpointResponse,\n type ApiParamLocation,\n} from \"./library/api-endpoint.config.js\";\nexport { DataModelRead, DataModelEdit } from \"./library/DataModelBlock.js\";\nexport {\n dataModelSchema,\n dataModelMdx,\n DATA_MODEL_RELATION_KINDS,\n type DataModelData,\n type DataModelEntity,\n type DataModelField,\n type DataModelRelation,\n type DataModelRelationKind,\n} from \"./library/data-model.config.js\";\nexport { DiffRead, DiffEdit } from \"./library/DiffBlock.js\";\nexport {\n diffSchema,\n diffMdx,\n type DiffData,\n type DiffMode,\n} from \"./library/diff.config.js\";\nexport { FileTreeRead, FileTreeEdit } from \"./library/FileTreeBlock.js\";\nexport {\n fileTreeSchema,\n fileTreeMdx,\n FILE_TREE_CHANGES,\n type FileTreeData,\n type FileTreeEntry,\n type FileTreeChange,\n} from \"./library/file-tree.config.js\";\nexport {\n JsonExplorerRead,\n JsonExplorerEdit,\n} from \"./library/JsonExplorerBlock.js\";\nexport {\n jsonExplorerSchema,\n jsonExplorerMdx,\n type JsonExplorerData,\n} from \"./library/json-explorer.config.js\";\nexport {\n AnnotatedCodeRead,\n AnnotatedCodeEdit,\n} from \"./library/AnnotatedCodeBlock.js\";\nexport {\n annotatedCodeSchema,\n annotatedCodeMdx,\n type AnnotatedCodeData,\n type AnnotatedCodeAnnotation,\n} from \"./library/annotated-code.config.js\";\nexport {\n OpenApiSpecRead,\n OpenApiSpecEdit,\n} from \"./library/OpenApiSpecBlock.js\";\nexport {\n openApiSpecSchema,\n openApiSpecMdx,\n type OpenApiSpecData,\n} from \"./library/openapi-spec.config.js\";\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ApiEndpointBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/ApiEndpointBlock.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,0BAA0B,CAAC;
|
|
1
|
+
{"version":3,"file":"ApiEndpointBlock.d.ts","sourceRoot":"","sources":["../../../../src/client/blocks/library/ApiEndpointBlock.tsx"],"names":[],"mappings":"AAQA,OAAO,KAAK,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAClE,OAAO,KAAK,EACV,eAAe,EAKhB,MAAM,0BAA0B,CAAC;AAgHlC;;;;;;;GAOG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,OAAO,EACP,KAAK,EACL,OAAO,EACP,GAAG,GACJ,EAAE,cAAc,CAAC,eAAe,CAAC,2CAqNjC;AAMD;;;;;;GAMG;AACH,wBAAgB,eAAe,CAAC,EAC9B,IAAI,EACJ,QAAQ,EACR,QAAQ,GACT,EAAE,cAAc,CAAC,eAAe,CAAC,2CAsTjC"}
|
|
@@ -3,7 +3,9 @@ import { useState } from "react";
|
|
|
3
3
|
import { IconChevronRight, IconLock, IconPlus, IconTrash, } from "@tabler/icons-react";
|
|
4
4
|
import { cn } from "../../utils.js";
|
|
5
5
|
import { API_ENDPOINT_METHODS, API_PARAM_LOCATIONS, } from "./api-endpoint.config.js";
|
|
6
|
+
import { JsonExplorerSurface } from "./JsonExplorerBlock.js";
|
|
6
7
|
import { DevBadge, DevInput, DevSwitch, DevTextarea, DevSelect, } from "./dev-doc-ui.js";
|
|
8
|
+
import { CodeSurface } from "./HighlightedCode.js";
|
|
7
9
|
/**
|
|
8
10
|
* Read + Edit renderers for an `api-endpoint` block — a Swagger / Stripe-style
|
|
9
11
|
* API reference. Lives in core so any app can register the dev-doc block (no
|
|
@@ -55,11 +57,23 @@ function fenceLangForContentType(contentType) {
|
|
|
55
57
|
return "yaml";
|
|
56
58
|
return "json";
|
|
57
59
|
}
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
function shouldUseJsonExplorer(example, contentType) {
|
|
61
|
+
const ct = (contentType ?? "").toLowerCase();
|
|
62
|
+
if (contentType && !ct.includes("json"))
|
|
63
|
+
return false;
|
|
64
|
+
try {
|
|
65
|
+
JSON.parse(example);
|
|
66
|
+
return true;
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
return false;
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function ApiExample({ example, contentType, className, }) {
|
|
73
|
+
if (shouldUseJsonExplorer(example, contentType)) {
|
|
74
|
+
return (_jsx(JsonExplorerSurface, { data: { json: example, collapsedDepth: 2 }, className: className }));
|
|
75
|
+
}
|
|
76
|
+
return (_jsx(CodeSurface, { code: example, language: fenceLangForContentType(contentType), className: className }));
|
|
63
77
|
}
|
|
64
78
|
/* ── Read (collapsed-by-default swagger row) ───────────────────────────────── */
|
|
65
79
|
/**
|
|
@@ -80,7 +94,7 @@ export function ApiEndpointRead({ data, blockId, title, summary, ctx, }) {
|
|
|
80
94
|
hasRequest ||
|
|
81
95
|
responses.length > 0 ||
|
|
82
96
|
Boolean(data.auth);
|
|
83
|
-
return (_jsxs("section", { className: "plan-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsxs("div", { className: "overflow-hidden rounded-xl border border-plan-line bg-plan-block", children: [_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": open, onClick: () => setOpen((value) => !value), className: cn("flex w-full items-center gap-3 px-4 py-3 text-left transition-colors", "hover:bg-accent/40"), children: [_jsx(IconChevronRight, { className: cn("size-4 shrink-0 text-plan-muted transition-transform", open && "rotate-90") }), _jsx("span", { className: cn("shrink-0 rounded-md px-2 py-1 font-mono text-xs font-bold uppercase tracking-wide", METHOD_PILL[data.method]), children: data.method }), _jsx("span", { className: cn("min-w-0 truncate font-mono text-sm font-semibold text-plan-text", data.deprecated && "text-plan-muted line-through"), children: data.path }), data.deprecated && (_jsx(DevBadge, { className: "shrink-0 border-amber-500/40 text-amber-600 dark:text-amber-300", children: "Deprecated" })), (data.summary || summary) && (_jsx("span", { className: "ml-1 min-w-0 flex-1 truncate text-sm text-plan-muted", children: data.summary || summary })), data.auth && (_jsx(IconLock, { className: "size-3.5 shrink-0 text-plan-muted", "aria-label": "Requires authentication" }))] }), open && hasBody && (_jsxs("div", { className: "border-t border-plan-line px-4 py-4", children: [data.auth && (_jsxs("div", { className: "mb-4 flex items-center gap-2 text-xs text-plan-muted", children: [_jsx(IconLock, { className: "size-3.5 shrink-0" }), _jsxs("span", { children: [_jsx("span", { className: "font-medium text-plan-text", children: "Auth:" }), " ", data.auth] })] })), data.description?.trim() && (_jsx("div", { className: "an-api-endpoint-desc", children: ctx.renderMarkdown?.(data.description) })), params.length > 0 && (_jsxs("div", { className: "mt-5", children: [_jsx("div", { className: "text-xs font-semibold uppercase tracking-wide text-plan-muted", children: "Parameters" }), _jsx("div", { className: "mt-2 overflow-hidden rounded-lg border border-plan-line", children: _jsxs("table", { className: "w-full border-collapse text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-accent/30 text-left text-xs uppercase tracking-wide text-plan-muted", children: [_jsx("th", { className: "px-3 py-2 font-medium", children: "Name" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "In" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Type" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Required" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Description" })] }) }), _jsx("tbody", { children: params.map((param, index) => (_jsxs("tr", { className: "border-t border-plan-line align-top", children: [_jsx("td", { className: "px-3 py-2 font-mono text-xs font-semibold text-plan-text", children: param.name }), _jsx("td", { className: "px-3 py-2", children: _jsx("span", { className: cn("rounded px-1.5 py-0.5 font-mono text-[11px] font-semibold", PARAM_IN_BADGE[param.in]), children: param.in }) }), _jsx("td", { className: "px-3 py-2 font-mono text-xs text-plan-muted", children: param.type || "—" }), _jsx("td", { className: "px-3 py-2 text-xs", children: param.required ? (_jsx("span", { className: "font-medium text-red-600 dark:text-red-300", children: "required" })) : (_jsx("span", { className: "text-plan-muted", children: "optional" })) }), _jsx("td", { className: "px-3 py-2 text-xs text-plan-muted", children: param.description || "—" })] }, `${param.name}-${index}`))) })] }) })] })), hasRequest && (_jsxs("div", { className: "mt-5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-xs font-semibold uppercase tracking-wide text-plan-muted", children: "Request body" }), data.request?.contentType && (_jsx("span", { className: "rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted", children: data.request.contentType }))] }), data.request?.example && (_jsx(
|
|
97
|
+
return (_jsxs("section", { className: "plan-block", "data-block-id": blockId, children: [title && _jsx("div", { className: "plan-block-label", children: title }), _jsxs("div", { className: "overflow-hidden rounded-xl border border-plan-line bg-plan-block", children: [_jsxs("button", { type: "button", "data-plan-interactive": true, "aria-expanded": open, onClick: () => setOpen((value) => !value), className: cn("flex w-full items-center gap-3 px-4 py-3 text-left transition-colors", "hover:bg-accent/40"), children: [_jsx(IconChevronRight, { className: cn("size-4 shrink-0 text-plan-muted transition-transform", open && "rotate-90") }), _jsx("span", { className: cn("shrink-0 rounded-md px-2 py-1 font-mono text-xs font-bold uppercase tracking-wide", METHOD_PILL[data.method]), children: data.method }), _jsx("span", { className: cn("min-w-0 truncate font-mono text-sm font-semibold text-plan-text", data.deprecated && "text-plan-muted line-through"), children: data.path }), data.deprecated && (_jsx(DevBadge, { className: "shrink-0 border-amber-500/40 text-amber-600 dark:text-amber-300", children: "Deprecated" })), (data.summary || summary) && (_jsx("span", { className: "ml-1 min-w-0 flex-1 truncate text-sm text-plan-muted", children: data.summary || summary })), data.auth && (_jsx(IconLock, { className: "size-3.5 shrink-0 text-plan-muted", "aria-label": "Requires authentication" }))] }), open && hasBody && (_jsxs("div", { className: "border-t border-plan-line px-4 py-4", children: [data.auth && (_jsxs("div", { className: "mb-4 flex items-center gap-2 text-xs text-plan-muted", children: [_jsx(IconLock, { className: "size-3.5 shrink-0" }), _jsxs("span", { children: [_jsx("span", { className: "font-medium text-plan-text", children: "Auth:" }), " ", data.auth] })] })), data.description?.trim() && (_jsx("div", { className: "an-api-endpoint-desc", children: ctx.renderMarkdown?.(data.description) })), params.length > 0 && (_jsxs("div", { className: "mt-5", children: [_jsx("div", { className: "text-xs font-semibold uppercase tracking-wide text-plan-muted", children: "Parameters" }), _jsx("div", { className: "mt-2 overflow-hidden rounded-lg border border-plan-line", children: _jsxs("table", { className: "w-full border-collapse text-sm", children: [_jsx("thead", { children: _jsxs("tr", { className: "bg-accent/30 text-left text-xs uppercase tracking-wide text-plan-muted", children: [_jsx("th", { className: "px-3 py-2 font-medium", children: "Name" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "In" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Type" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Required" }), _jsx("th", { className: "px-3 py-2 font-medium", children: "Description" })] }) }), _jsx("tbody", { children: params.map((param, index) => (_jsxs("tr", { className: "border-t border-plan-line align-top", children: [_jsx("td", { className: "px-3 py-2 font-mono text-xs font-semibold text-plan-text", children: param.name }), _jsx("td", { className: "px-3 py-2", children: _jsx("span", { className: cn("rounded px-1.5 py-0.5 font-mono text-[11px] font-semibold", PARAM_IN_BADGE[param.in]), children: param.in }) }), _jsx("td", { className: "px-3 py-2 font-mono text-xs text-plan-muted", children: param.type || "—" }), _jsx("td", { className: "px-3 py-2 text-xs", children: param.required ? (_jsx("span", { className: "font-medium text-red-600 dark:text-red-300", children: "required" })) : (_jsx("span", { className: "text-plan-muted", children: "optional" })) }), _jsx("td", { className: "px-3 py-2 text-xs text-plan-muted", children: param.description || "—" })] }, `${param.name}-${index}`))) })] }) })] })), hasRequest && (_jsxs("div", { className: "mt-5", children: [_jsxs("div", { className: "flex items-center gap-2", children: [_jsx("span", { className: "text-xs font-semibold uppercase tracking-wide text-plan-muted", children: "Request body" }), data.request?.contentType && (_jsx("span", { className: "rounded bg-accent/40 px-1.5 py-0.5 font-mono text-[11px] text-plan-muted", children: data.request.contentType }))] }), data.request?.example && (_jsx(ApiExample, { example: data.request.example, contentType: data.request.contentType, className: "mt-2 an-api-endpoint-example" }))] })), responses.length > 0 && (_jsxs("div", { className: "mt-5", children: [_jsx("div", { className: "text-xs font-semibold uppercase tracking-wide text-plan-muted", children: "Responses" }), _jsx("div", { className: "mt-2 flex flex-col gap-3", children: responses.map((response, index) => (_jsxs("div", { className: "rounded-lg border border-plan-line", children: [_jsxs("div", { className: "flex items-center gap-2 px-3 py-2", children: [_jsx("span", { className: cn("rounded px-2 py-0.5 font-mono text-xs font-bold", statusPillClass(response.status)), children: response.status }), response.description && (_jsx("span", { className: "text-sm text-plan-muted", children: response.description }))] }), response.example && (_jsx("div", { className: "border-t border-plan-line px-3 pb-3 pt-3 an-api-endpoint-example", children: _jsx(ApiExample, { example: response.example, className: "mt-0" }) }))] }, `${response.status}-${index}`))) })] }))] }))] })] }));
|
|
84
98
|
}
|
|
85
99
|
/* ── Edit (panel form) ─────────────────────────────────────────────────────── */
|
|
86
100
|
const fieldLabelClass = "text-xs font-medium text-muted-foreground";
|