@esheet/builder 0.0.3 → 0.0.4-1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (83) hide show
  1. package/README.md +1 -1
  2. package/dist/index.d.ts +16 -143
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +11252 -6751
  5. package/dist/lib/EsheetBuilder.d.ts +46 -0
  6. package/dist/lib/EsheetBuilder.d.ts.map +1 -0
  7. package/dist/lib/EsheetBuilder.js +111 -0
  8. package/dist/lib/builder-tools.d.ts +107 -0
  9. package/dist/lib/builder-tools.d.ts.map +1 -0
  10. package/dist/lib/builder-tools.js +321 -0
  11. package/dist/lib/components/BuilderHeader.d.ts +7 -0
  12. package/dist/lib/components/BuilderHeader.d.ts.map +1 -0
  13. package/dist/lib/components/BuilderHeader.js +390 -0
  14. package/dist/lib/components/Canvas.d.ts +12 -0
  15. package/dist/lib/components/Canvas.d.ts.map +1 -0
  16. package/dist/lib/components/Canvas.js +288 -0
  17. package/dist/lib/components/CodeView.d.ts +12 -0
  18. package/dist/lib/components/CodeView.d.ts.map +1 -0
  19. package/dist/lib/components/CodeView.js +197 -0
  20. package/dist/lib/components/FeedbackModal.d.ts +23 -0
  21. package/dist/lib/components/FeedbackModal.d.ts.map +1 -0
  22. package/dist/lib/components/FeedbackModal.js +22 -0
  23. package/dist/lib/components/FieldWrapper.d.ts +53 -0
  24. package/dist/lib/components/FieldWrapper.d.ts.map +1 -0
  25. package/dist/lib/components/FieldWrapper.js +152 -0
  26. package/dist/lib/components/MobileBottomDrawer.d.ts +9 -0
  27. package/dist/lib/components/MobileBottomDrawer.d.ts.map +1 -0
  28. package/dist/lib/components/MobileBottomDrawer.js +6 -0
  29. package/dist/lib/components/ToolPanel.d.ts +11 -0
  30. package/dist/lib/components/ToolPanel.d.ts.map +1 -0
  31. package/dist/lib/components/ToolPanel.js +117 -0
  32. package/dist/lib/components/edit-panel/CommonEditor.d.ts +16 -0
  33. package/dist/lib/components/edit-panel/CommonEditor.d.ts.map +1 -0
  34. package/dist/lib/components/edit-panel/CommonEditor.js +16 -0
  35. package/dist/lib/components/edit-panel/DraftIdEditor.d.ts +16 -0
  36. package/dist/lib/components/edit-panel/DraftIdEditor.d.ts.map +1 -0
  37. package/dist/lib/components/edit-panel/DraftIdEditor.js +32 -0
  38. package/dist/lib/components/edit-panel/EditPanel.d.ts +10 -0
  39. package/dist/lib/components/edit-panel/EditPanel.d.ts.map +1 -0
  40. package/dist/lib/components/edit-panel/EditPanel.js +156 -0
  41. package/dist/lib/components/edit-panel/InputTypeEditor.d.ts +16 -0
  42. package/dist/lib/components/edit-panel/InputTypeEditor.d.ts.map +1 -0
  43. package/dist/lib/components/edit-panel/InputTypeEditor.js +32 -0
  44. package/dist/lib/components/edit-panel/LogicEditor.d.ts +15 -0
  45. package/dist/lib/components/edit-panel/LogicEditor.d.ts.map +1 -0
  46. package/dist/lib/components/edit-panel/LogicEditor.js +392 -0
  47. package/dist/lib/components/edit-panel/MatrixEditor.d.ts +12 -0
  48. package/dist/lib/components/edit-panel/MatrixEditor.d.ts.map +1 -0
  49. package/dist/lib/components/edit-panel/MatrixEditor.js +32 -0
  50. package/dist/lib/components/edit-panel/OptionListEditor.d.ts +14 -0
  51. package/dist/lib/components/edit-panel/OptionListEditor.d.ts.map +1 -0
  52. package/dist/lib/components/edit-panel/OptionListEditor.js +27 -0
  53. package/dist/lib/hooks/useFormApi.d.ts +55 -0
  54. package/dist/lib/hooks/useFormApi.d.ts.map +1 -0
  55. package/dist/lib/hooks/useFormApi.js +80 -0
  56. package/dist/lib/hooks/useUiApi.d.ts +22 -0
  57. package/dist/lib/hooks/useUiApi.d.ts.map +1 -0
  58. package/dist/lib/hooks/useUiApi.js +37 -0
  59. package/dist/lib/hooks/useVisibleRootIds.d.ts +11 -0
  60. package/dist/lib/hooks/useVisibleRootIds.d.ts.map +1 -0
  61. package/dist/lib/hooks/useVisibleRootIds.js +32 -0
  62. package/dist/lib/icons.d.ts +31 -0
  63. package/dist/lib/icons.d.ts.map +1 -0
  64. package/dist/lib/icons.js +47 -0
  65. package/dist/lib/mcp/index.d.ts +7 -0
  66. package/dist/lib/mcp/index.d.ts.map +1 -0
  67. package/dist/lib/mcp/index.js +4 -0
  68. package/dist/lib/mcp/system-prompt.d.ts +2 -0
  69. package/dist/lib/mcp/system-prompt.d.ts.map +1 -0
  70. package/dist/lib/mcp/system-prompt.js +9 -0
  71. package/dist/lib/mcp/tool-definitions.d.ts +10 -0
  72. package/dist/lib/mcp/tool-definitions.d.ts.map +1 -0
  73. package/dist/lib/mcp/tool-definitions.js +436 -0
  74. package/dist/lib/mcp/tool-executor.d.ts +5 -0
  75. package/dist/lib/mcp/tool-executor.d.ts.map +1 -0
  76. package/dist/lib/mcp/tool-executor.js +482 -0
  77. package/dist/lib/mcp/useBuilderToolBridge.d.ts +31 -0
  78. package/dist/lib/mcp/useBuilderToolBridge.d.ts.map +1 -0
  79. package/dist/lib/mcp/useBuilderToolBridge.js +56 -0
  80. package/dist/lib/register-defaults.d.ts +2 -0
  81. package/dist/lib/register-defaults.d.ts.map +1 -0
  82. package/dist/lib/register-defaults.js +37 -0
  83. package/package.json +7 -5
@@ -0,0 +1,80 @@
1
+ import React from 'react';
2
+ import { useStore } from 'zustand';
3
+ import { useFormStore } from '@esheet/fields';
4
+ /**
5
+ * useFormApi — reactive field state + form store actions.
6
+ *
7
+ * Touches only the FormStore. For UI state (mode, selection, tabs) use
8
+ * useUiApi(). For the computed visible root IDs use useVisibleRootIds().
9
+ *
10
+ * @param fieldId - The field to bind to. Pass undefined for form-level ops only.
11
+ */
12
+ export function useFormApi(fieldId) {
13
+ const form = useFormStore();
14
+ // --- Reactive field state ---
15
+ const field = useStore(form, (s) => fieldId ? s.getField(fieldId) : undefined);
16
+ const response = useStore(form, (s) => fieldId ? s.getResponse(fieldId) : undefined);
17
+ const isVisible = useStore(form, (s) => fieldId ? s.isVisible(fieldId) : true);
18
+ const isEnabled = useStore(form, (s) => fieldId ? s.isEnabled(fieldId) : true);
19
+ const isRequired = useStore(form, (s) => fieldId ? s.isRequired(fieldId) : false);
20
+ // --- Reactive form-level state ---
21
+ const normalized = useStore(form, (s) => s.normalized);
22
+ const responses = useStore(form, (s) => s.responses);
23
+ const instanceId = useStore(form, (s) => s.instanceId);
24
+ return React.useMemo(() => ({
25
+ field,
26
+ response,
27
+ isVisible,
28
+ isEnabled,
29
+ isRequired,
30
+ normalized,
31
+ responses,
32
+ instanceId,
33
+ form: {
34
+ addField: (type, opts) => form.getState().addField(type, opts),
35
+ loadDefinition: form.getState().loadDefinition,
36
+ setFormId: form.getState().setFormId,
37
+ hydrateDefinition: () => form.getState().hydrateDefinition(),
38
+ hydrateResponse: () => form.getState().hydrateResponse(),
39
+ resetResponses: () => form.getState().resetResponses(),
40
+ },
41
+ field_: {
42
+ update: (patch) => fieldId ? form.getState().updateField(fieldId, patch) : false,
43
+ remove: () => (fieldId ? form.getState().removeField(fieldId) : false),
44
+ move: (toIndex, toParentId) => fieldId
45
+ ? form.getState().moveField(fieldId, toIndex, toParentId)
46
+ : false,
47
+ setResponse: (resp) => fieldId ? form.getState().setResponse(fieldId, resp) : undefined,
48
+ clearResponse: () => fieldId ? form.getState().clearResponse(fieldId) : undefined,
49
+ },
50
+ option: {
51
+ add: (value) => fieldId ? form.getState().addOption(fieldId, value) : null,
52
+ update: (optId, value) => fieldId ? form.getState().updateOption(fieldId, optId, value) : false,
53
+ remove: (optId) => fieldId ? form.getState().removeOption(fieldId, optId) : false,
54
+ },
55
+ row: {
56
+ add: (value) => fieldId ? form.getState().addRow(fieldId, value) : null,
57
+ update: (rowId, value) => fieldId ? form.getState().updateRow(fieldId, rowId, value) : false,
58
+ remove: (rowId) => fieldId ? form.getState().removeRow(fieldId, rowId) : false,
59
+ },
60
+ column: {
61
+ add: (value) => fieldId ? form.getState().addColumn(fieldId, value) : null,
62
+ update: (colId, value) => fieldId ? form.getState().updateColumn(fieldId, colId, value) : false,
63
+ remove: (colId) => fieldId ? form.getState().removeColumn(fieldId, colId) : false,
64
+ },
65
+ _form: form,
66
+ }),
67
+ // eslint-disable-next-line react-hooks/exhaustive-deps
68
+ [
69
+ fieldId,
70
+ field,
71
+ response,
72
+ isVisible,
73
+ isEnabled,
74
+ isRequired,
75
+ normalized,
76
+ responses,
77
+ instanceId,
78
+ form,
79
+ ]);
80
+ }
@@ -0,0 +1,22 @@
1
+ import type { BuilderMode, EditTab, UIStore } from '@esheet/core';
2
+ export interface UiApi {
3
+ mode: BuilderMode;
4
+ selectedFieldId: string | null;
5
+ selectedFieldChildId: string | null;
6
+ editTab: EditTab;
7
+ codeEditorHasError: boolean;
8
+ selectField: (id: string | null) => void;
9
+ selectFieldChild: (parentId: string, childId: string | null) => void;
10
+ setMode: (m: BuilderMode) => void;
11
+ setEditTab: (tab: EditTab) => void;
12
+ setEditModalOpen: (open: boolean) => void;
13
+ clearDragState: () => void;
14
+ _ui: UIStore;
15
+ }
16
+ /**
17
+ * useUiApi — lightweight hook for components that only need UI state/actions.
18
+ *
19
+ * Useful when you don't need field-scoped state. Requires UIContext provider.
20
+ */
21
+ export declare function useUiApi(): UiApi;
22
+ //# sourceMappingURL=useUiApi.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useUiApi.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/useUiApi.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,WAAW,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AAGlE,MAAM,WAAW,KAAK;IACpB,IAAI,EAAE,WAAW,CAAC;IAClB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAC;IAC/B,oBAAoB,EAAE,MAAM,GAAG,IAAI,CAAC;IACpC,OAAO,EAAE,OAAO,CAAC;IACjB,kBAAkB,EAAE,OAAO,CAAC;IAC5B,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACzC,gBAAgB,EAAE,CAAC,QAAQ,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,KAAK,IAAI,CAAC;IACrE,OAAO,EAAE,CAAC,CAAC,EAAE,WAAW,KAAK,IAAI,CAAC;IAClC,UAAU,EAAE,CAAC,GAAG,EAAE,OAAO,KAAK,IAAI,CAAC;IACnC,gBAAgB,EAAE,CAAC,IAAI,EAAE,OAAO,KAAK,IAAI,CAAC;IAC1C,cAAc,EAAE,MAAM,IAAI,CAAC;IAC3B,GAAG,EAAE,OAAO,CAAC;CACd;AAED;;;;GAIG;AACH,wBAAgB,QAAQ,IAAI,KAAK,CAkChC"}
@@ -0,0 +1,37 @@
1
+ import React from 'react';
2
+ import { useStore } from 'zustand';
3
+ import { useUI } from '@esheet/fields';
4
+ /**
5
+ * useUiApi — lightweight hook for components that only need UI state/actions.
6
+ *
7
+ * Useful when you don't need field-scoped state. Requires UIContext provider.
8
+ */
9
+ export function useUiApi() {
10
+ const ui = useUI();
11
+ const mode = useStore(ui, (s) => s.mode);
12
+ const selectedFieldId = useStore(ui, (s) => s.selectedFieldId);
13
+ const selectedFieldChildId = useStore(ui, (s) => s.selectedFieldChildId);
14
+ const editTab = useStore(ui, (s) => s.editTab);
15
+ const codeEditorHasError = useStore(ui, (s) => s.codeEditorHasError);
16
+ return React.useMemo(() => ({
17
+ mode,
18
+ selectedFieldId,
19
+ selectedFieldChildId,
20
+ editTab,
21
+ codeEditorHasError,
22
+ selectField: (id) => ui.getState().selectField(id),
23
+ selectFieldChild: (parentId, childId) => ui.getState().selectFieldChild(parentId, childId),
24
+ setMode: (m) => ui.getState().setMode(m),
25
+ setEditTab: (tab) => ui.getState().setEditTab(tab),
26
+ setEditModalOpen: (open) => ui.getState().setEditModalOpen(open),
27
+ clearDragState: () => ui.getState().clearDragState(),
28
+ _ui: ui,
29
+ }), [
30
+ mode,
31
+ selectedFieldId,
32
+ selectedFieldChildId,
33
+ editTab,
34
+ codeEditorHasError,
35
+ ui,
36
+ ]);
37
+ }
@@ -0,0 +1,11 @@
1
+ /**
2
+ * useVisibleRootIds — returns the root field IDs to render.
3
+ *
4
+ * In build/code mode: all root IDs.
5
+ * In preview mode: only IDs whose visibility rules evaluate to true.
6
+ *
7
+ * Requires both FormStoreContext and UIContext providers.
8
+ * Uses a stable-ref cache so the array reference only changes when content does.
9
+ */
10
+ export declare function useVisibleRootIds(): readonly string[];
11
+ //# sourceMappingURL=useVisibleRootIds.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"useVisibleRootIds.d.ts","sourceRoot":"","sources":["../../../src/lib/hooks/useVisibleRootIds.ts"],"names":[],"mappings":"AAIA;;;;;;;;GAQG;AACH,wBAAgB,iBAAiB,IAAI,SAAS,MAAM,EAAE,CA0BrD"}
@@ -0,0 +1,32 @@
1
+ import React from 'react';
2
+ import { useStore } from 'zustand';
3
+ import { useFormStore, useUI } from '@esheet/fields';
4
+ /**
5
+ * useVisibleRootIds — returns the root field IDs to render.
6
+ *
7
+ * In build/code mode: all root IDs.
8
+ * In preview mode: only IDs whose visibility rules evaluate to true.
9
+ *
10
+ * Requires both FormStoreContext and UIContext providers.
11
+ * Uses a stable-ref cache so the array reference only changes when content does.
12
+ */
13
+ export function useVisibleRootIds() {
14
+ const form = useFormStore();
15
+ const ui = useUI();
16
+ const normalized = useStore(form, (s) => s.normalized);
17
+ const responses = useStore(form, (s) => s.responses);
18
+ const mode = useStore(ui, (s) => s.mode);
19
+ const cacheRef = React.useRef([]);
20
+ return React.useMemo(() => {
21
+ const rootIds = mode !== 'preview'
22
+ ? normalized.rootIds
23
+ : normalized.rootIds.filter((id) => form.getState().isVisible(id));
24
+ const prev = cacheRef.current;
25
+ if (prev.length === rootIds.length &&
26
+ prev.every((v, i) => v === rootIds[i])) {
27
+ return prev;
28
+ }
29
+ cacheRef.current = rootIds;
30
+ return rootIds;
31
+ }, [normalized, responses, mode, form]);
32
+ }
@@ -0,0 +1,31 @@
1
+ /**
2
+ * Builder icon components — ported from questionnaire-builder (old QB).
3
+ *
4
+ * All icons accept a `className` prop and render inline SVGs using `currentColor`.
5
+ * Usage: <TrashIcon className="ms:w-5 ms:h-5 ms:text-mstextmuted" />
6
+ */
7
+ import React from 'react';
8
+ type IconProps = {
9
+ className?: string;
10
+ };
11
+ export { TrashIcon, PlusIcon, ArrowUpIcon, ArrowDownIcon, UpDownArrowIcon, } from '@esheet/fields';
12
+ export declare const ViewBigIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
13
+ export declare const ViewSmallIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
14
+ export declare const EditIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
15
+ export declare const TextFieldsIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
16
+ export declare const SelectionFieldsIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
17
+ export declare const RatingIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
18
+ export declare const MatrixIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
19
+ export declare const RichContentIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
20
+ export declare const OrganizationIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
21
+ export declare const VEditorIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
22
+ export declare const PreviewIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
23
+ export declare const UploadIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
24
+ export declare const DownloadIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
25
+ export declare const CodeIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
26
+ export declare const ChevronIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
27
+ export declare const XIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
28
+ export declare const CheckIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
29
+ export declare const DragHandleIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
30
+ export declare const LogicIcon: React.MemoExoticComponent<({ className }: IconProps) => import("react/jsx-runtime").JSX.Element>;
31
+ //# sourceMappingURL=icons.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"icons.d.ts","sourceRoot":"","sources":["../../src/lib/icons.tsx"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,KAAK,MAAM,OAAO,CAAC;AAE1B,KAAK,SAAS,GAAG;IAAE,SAAS,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC;AAQxC,OAAO,EACL,SAAS,EACT,QAAQ,EACR,WAAW,EACX,aAAa,EACb,eAAe,GAChB,MAAM,gBAAgB,CAAC;AAMxB,eAAO,MAAM,WAAW,4CACD,SAAS,6CAuB/B,CAAC;AAEF,eAAO,MAAM,aAAa,4CACH,SAAS,6CAuB/B,CAAC;AAEF,eAAO,MAAM,QAAQ,4CACE,SAAS,6CAkB/B,CAAC;AAMF,eAAO,MAAM,cAAc,4CACJ,SAAS,6CAiB/B,CAAC;AAEF,eAAO,MAAM,mBAAmB,4CACT,SAAS,6CAkB/B,CAAC;AAEF,eAAO,MAAM,UAAU,4CACA,SAAS,6CAqB/B,CAAC;AAEF,eAAO,MAAM,UAAU,4CACA,SAAS,6CAyB/B,CAAC;AAEF,eAAO,MAAM,eAAe,4CACL,SAAS,6CAiB/B,CAAC;AAEF,eAAO,MAAM,gBAAgB,4CACN,SAAS,6CAkB/B,CAAC;AAMF,eAAO,MAAM,WAAW,4CACD,SAAS,6CAmB/B,CAAC;AAEF,eAAO,MAAM,WAAW,4CACD,SAAS,6CAoB/B,CAAC;AAMF,eAAO,MAAM,UAAU,4CACA,SAAS,6CAoB/B,CAAC;AAEF,eAAO,MAAM,YAAY,4CACF,SAAS,6CAoB/B,CAAC;AAEF,eAAO,MAAM,QAAQ,4CACE,SAAS,6CAmB/B,CAAC;AAMF,eAAO,MAAM,WAAW,4CACD,SAAS,6CAiB/B,CAAC;AAEF,eAAO,MAAM,KAAK,4CACK,SAAS,6CAiB/B,CAAC;AAEF,eAAO,MAAM,SAAS,4CACC,SAAS,6CAkB/B,CAAC;AAEF,eAAO,MAAM,cAAc,4CACJ,SAAS,6CAmB/B,CAAC;AAEF,eAAO,MAAM,SAAS,4CACC,SAAS,6CAqB/B,CAAC"}
@@ -0,0 +1,47 @@
1
+ import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
2
+ /**
3
+ * Builder icon components — ported from questionnaire-builder (old QB).
4
+ *
5
+ * All icons accept a `className` prop and render inline SVGs using `currentColor`.
6
+ * Usage: <TrashIcon className="ms:w-5 ms:h-5 ms:text-mstextmuted" />
7
+ */
8
+ import React from 'react';
9
+ const eq = (a, b) => a.className === b.className;
10
+ // ---------------------------------------------------------------------------
11
+ // Shared icons — re-exported from @esheet/fields
12
+ // ---------------------------------------------------------------------------
13
+ export { TrashIcon, PlusIcon, ArrowUpIcon, ArrowDownIcon, UpDownArrowIcon, } from '@esheet/fields';
14
+ // ---------------------------------------------------------------------------
15
+ // Field Wrapper actions
16
+ // ---------------------------------------------------------------------------
17
+ export const ViewBigIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M12 10v-7l3 3" }), _jsx("path", { d: "M9 6l3 -3" }), _jsx("path", { d: "M12 14v7l3 -3" }), _jsx("path", { d: "M9 18l3 3" }), _jsx("path", { d: "M18 3h1a2 2 0 0 1 2 2v14a2 2 0 0 1 -2 2h-1" }), _jsx("path", { d: "M6 3h-1a2 2 0 0 0 -2 2v14a2 2 0 0 0 2 2h1" })] })), eq);
18
+ export const ViewSmallIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M12 3v7l3 -3" }), _jsx("path", { d: "M9 7l3 3" }), _jsx("path", { d: "M12 21v-7l3 3" }), _jsx("path", { d: "M9 17l3 -3" }), _jsx("path", { d: "M18 9h1a2 2 0 0 1 2 2v2a2 2 0 0 1 -2 2h-1" }), _jsx("path", { d: "M6 9h-1a2 2 0 0 0 -2 2v2a2 2 0 0 0 2 2h1" })] })), eq);
19
+ export const EditIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M7 7H6a2 2 0 0 0-2 2v9a2 2 0 0 0 2 2h9a2 2 0 0 0 2-2v-1" }), _jsx("path", { d: "M20.385 6.585a2.1 2.1 0 0 0-2.97-2.97L9 12v3h3zM16 5l3 3" })] })), eq);
20
+ // ---------------------------------------------------------------------------
21
+ // ToolPanel category icons
22
+ // ---------------------------------------------------------------------------
23
+ export const TextFieldsIcon = React.memo(({ className = '' }) => (_jsx("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M4 8V6a2 2 0 0 1 2-2h2M4 16v2a2 2 0 0 0 2 2h2m8-16h2a2 2 0 0 1 2 2v2m-4 12h2a2 2 0 0 0 2-2v-2m-8 0V9M9 9h6" }) })), eq);
24
+ export const SelectionFieldsIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M3 5a2 2 0 0 1 2-2h14a2 2 0 0 1 2 2v14a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2z" }), _jsx("path", { d: "m9 11l3 3l3-3" })] })), eq);
25
+ export const RatingIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M11 6h9" }), _jsx("path", { d: "M11 12h9" }), _jsx("path", { d: "M12 18h8" }), _jsx("path", { d: "M4 16a2 2 0 1 1 4 0c0 0.591 -0.5 1 -1 1.5L4 20h4" }), _jsx("path", { d: "M6 10V4L4 6" })] })), eq);
26
+ export const MatrixIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M4 5a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M11 5a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M18 5a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M4 12a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M11 12a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M18 12a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M4 19a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M11 19a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" }), _jsx("path", { d: "M18 19a1 1 0 1 0 2 0 1 1 0 1 0 -2 0" })] })), eq);
27
+ export const RichContentIcon = React.memo(({ className = '' }) => (_jsx("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "m15 7 -6.5 6.5a1.5 1.5 0 0 0 3 3L18 10a3 3 0 0 0 -6 -6l-6.5 6.5a4.5 4.5 0 0 0 9 9L21 13" }) })), eq);
28
+ export const OrganizationIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "M9 4h3l2 2h5a2 2 0 0 1 2 2v7a2 2 0 0 1 -2 2H9a2 2 0 0 1 -2 -2V6a2 2 0 0 1 2 -2" }), _jsx("path", { d: "M17 17v2a2 2 0 0 1 -2 2H5a2 2 0 0 1 -2 -2v-9a2 2 0 0 1 2 -2h2" })] })), eq);
29
+ // ---------------------------------------------------------------------------
30
+ // BuilderHeader — mode toggle icons
31
+ // ---------------------------------------------------------------------------
32
+ export const VEditorIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", children: [_jsx("path", { d: "M4 20h4L18.5 9.5a2.828 2.828 0 1 0 -4 -4L4 16v4" }), _jsx("path", { d: "m13.5 6.5 4 4" }), _jsx("path", { d: "m19 16 -2 3h4l-2 3" })] })), eq);
33
+ export const PreviewIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: "2", children: [_jsx("path", { d: "M15 8h0.01" }), _jsx("path", { d: "M3 6a3 3 0 0 1 3 -3h12a3 3 0 0 1 3 3v12a3 3 0 0 1 -3 3H6a3 3 0 0 1 -3 -3V6z" }), _jsx("path", { d: "m3 16 5 -5c0.928 -0.893 2.072 -0.893 3 0l5 5" }), _jsx("path", { d: "m14 14 1 -1c0.928 -0.893 2.072 -0.893 3 0l3 3" })] })), eq);
34
+ // ---------------------------------------------------------------------------
35
+ // BuilderHeader — action icons
36
+ // ---------------------------------------------------------------------------
37
+ export const UploadIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2" }), _jsx("path", { d: "M7 9l5 -5l5 5" }), _jsx("path", { d: "M12 4l0 12" })] })), eq);
38
+ export const DownloadIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M4 17v2a2 2 0 0 0 2 2h12a2 2 0 0 0 2 -2v-2" }), _jsx("path", { d: "M7 11l5 5l5 -5" }), _jsx("path", { d: "M12 4l0 12" })] })), eq);
39
+ export const CodeIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { d: "m7 8 -4 4 4 4" }), _jsx("path", { d: "m17 8 4 4 -4 4" }), _jsx("path", { d: "m14 4 -4 16" })] })), eq);
40
+ // ---------------------------------------------------------------------------
41
+ // Misc / shared
42
+ // ---------------------------------------------------------------------------
43
+ export const ChevronIcon = React.memo(({ className = '' }) => (_jsx("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M6 9l6 6l6 -6" }) })), eq);
44
+ export const XIcon = React.memo(({ className = '' }) => (_jsx("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: _jsx("path", { d: "M18 6L6 18M6 6l12 12" }) })), eq);
45
+ export const CheckIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M5 12l5 5l10 -10" })] })), eq);
46
+ export const DragHandleIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "currentColor", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("circle", { cx: "9", cy: "5", r: "1" }), _jsx("circle", { cx: "9", cy: "12", r: "1" }), _jsx("circle", { cx: "9", cy: "19", r: "1" }), _jsx("circle", { cx: "15", cy: "5", r: "1" }), _jsx("circle", { cx: "15", cy: "12", r: "1" }), _jsx("circle", { cx: "15", cy: "19", r: "1" })] })), eq);
47
+ export const LogicIcon = React.memo(({ className = '' }) => (_jsxs("svg", { className: className, xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", width: "24", height: "24", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [_jsx("path", { stroke: "none", d: "M0 0h24v24H0z", fill: "none" }), _jsx("path", { d: "M22 12h-5" }), _jsx("path", { d: "M2 9h5" }), _jsx("path", { d: "M2 15h5" }), _jsx("path", { d: "M9 5c6 0 8 3.5 8 7s-2 7 -8 7h-2v-14h2" })] })), eq);
@@ -0,0 +1,7 @@
1
+ export { executeToolCall } from './tool-executor.js';
2
+ export { BUILDER_TOOL_DEFINITIONS } from './tool-definitions.js';
3
+ export { BUILDER_SYSTEM_PROMPT } from './system-prompt.js';
4
+ export type { ToolDefinition } from './tool-definitions.js';
5
+ export { useBuilderMcpToolHandler } from './useBuilderToolBridge.js';
6
+ export type { UseBuilderMcpToolHandlerOptions } from './useBuilderToolBridge.js';
7
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/lib/mcp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAE,wBAAwB,EAAE,MAAM,uBAAuB,CAAC;AACjE,OAAO,EAAE,qBAAqB,EAAE,MAAM,oBAAoB,CAAC;AAC3D,YAAY,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AAC5D,OAAO,EAAE,wBAAwB,EAAE,MAAM,2BAA2B,CAAC;AACrE,YAAY,EAAE,+BAA+B,EAAE,MAAM,2BAA2B,CAAC"}
@@ -0,0 +1,4 @@
1
+ export { executeToolCall } from './tool-executor.js';
2
+ export { BUILDER_TOOL_DEFINITIONS } from './tool-definitions.js';
3
+ export { BUILDER_SYSTEM_PROMPT } from './system-prompt.js';
4
+ export { useBuilderMcpToolHandler } from './useBuilderToolBridge.js';
@@ -0,0 +1,2 @@
1
+ export declare const BUILDER_SYSTEM_PROMPT: string;
2
+ //# sourceMappingURL=system-prompt.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"system-prompt.d.ts","sourceRoot":"","sources":["../../../src/lib/mcp/system-prompt.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,qBAAqB,QAS0C,CAAC"}
@@ -0,0 +1,9 @@
1
+ export const BUILDER_SYSTEM_PROMPT = 'Form builder assistant. Field types: text, longtext, multitext, radio, check, boolean, dropdown, multiselectdropdown, rating, ranking, slider, singlematrix, multimatrix, image, html, signature, diagram, display, section. ' +
2
+ 'STRICT WORKFLOW: Before editing options/rows/columns on any field, call get_form_summary first to confirm the fieldType. ' +
3
+ 'singlematrix and multimatrix fields are created empty (no default rows or columns) — after creating one, use add_row/add_column to populate it. Use update_row/remove_row for rows and update_column/remove_column for columns — NEVER use add_option on matrix fields. ' +
4
+ 'add_option is ONLY for: radio, check, boolean, dropdown, multiselectdropdown, rating, ranking, slider, multitext. ' +
5
+ 'IMPORTANT: When building a new form or questionnaire from scratch, ALWAYS call reset_form first to clear placeholder fields before adding new ones. ' +
6
+ 'When using sections: first create the section field, then pass its ID as parentId on each subsequent create_field call to place fields inside it. ' +
7
+ 'PREVIEW FILL WORKFLOW: When asked to fill the preview form, call fill_field for each field. Each response includes filledCount and unfilledFields (only fields still needing values). You are done when unfilledFields is empty. Never skip a field; generate realistic mock values for all fields including dates and times. ' +
8
+ 'TEXT FIELD FORMATS: each field includes a valueFormat property — use it exactly (YYYY-MM-DD for date, YYYY-MM-DDTHH:mm for datetime-local, YYYY-MM for month, HH:mm for time). Wrong formats are rejected. ' +
9
+ 'For conversational questions reply in plain text without calling a tool.';
@@ -0,0 +1,10 @@
1
+ export interface ToolDefinition {
2
+ type: string;
3
+ function: {
4
+ name: string;
5
+ description: string;
6
+ parameters: Record<string, unknown>;
7
+ };
8
+ }
9
+ export declare const BUILDER_TOOL_DEFINITIONS: readonly ToolDefinition[];
10
+ //# sourceMappingURL=tool-definitions.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tool-definitions.d.ts","sourceRoot":"","sources":["../../../src/lib/mcp/tool-definitions.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,cAAc;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE;QACR,IAAI,EAAE,MAAM,CAAC;QACb,WAAW,EAAE,MAAM,CAAC;QACpB,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KACrC,CAAC;CACH;AAED,eAAO,MAAM,wBAAwB,EAAE,SAAS,cAAc,EAyc7D,CAAC"}