@meshagent/meshagent-tailwind 0.5.7 → 0.5.9
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/CHANGELOG.md +6 -0
- package/dist/cjs/Chat.js +28 -5
- package/dist/cjs/ChatInput.d.ts +4 -1
- package/dist/cjs/ChatInput.js +15 -3
- package/dist/cjs/ChatThread.js +1 -0
- package/dist/cjs/ChatTypingIndicator.js +2 -2
- package/dist/cjs/components/pane-example.d.ts +1 -0
- package/dist/cjs/components/pane-example.js +43 -0
- package/dist/cjs/components/ui/dialog.d.ts +15 -0
- package/dist/cjs/components/ui/dialog.js +166 -0
- package/dist/cjs/components/ui/form.d.ts +24 -0
- package/dist/cjs/components/ui/form.js +146 -0
- package/dist/cjs/components/ui/input.d.ts +3 -0
- package/dist/cjs/components/ui/input.js +41 -0
- package/dist/cjs/components/ui/label.d.ts +4 -0
- package/dist/cjs/components/ui/label.js +53 -0
- package/dist/cjs/components/ui/progress.js +1 -1
- package/dist/cjs/components/ui/radio-group.d.ts +5 -0
- package/dist/cjs/components/ui/radio-group.js +76 -0
- package/dist/cjs/components/ui/select.d.ts +15 -0
- package/dist/cjs/components/ui/select.js +199 -0
- package/dist/cjs/components/ui/sheet.d.ts +13 -0
- package/dist/cjs/components/ui/sheet.js +110 -0
- package/dist/cjs/components/ui/sonner.d.ts +3 -0
- package/dist/cjs/components/ui/sonner.js +42 -0
- package/dist/cjs/lib/pane-service.d.ts +16 -0
- package/dist/cjs/lib/pane-service.js +35 -0
- package/dist/cjs/lib/utils.d.ts +4 -0
- package/dist/cjs/tools/ask-user-for-file.d.ts +10 -0
- package/dist/cjs/tools/ask-user-for-file.js +68 -0
- package/dist/cjs/tools/ask-user.d.ts +10 -0
- package/dist/cjs/tools/ask-user.js +161 -0
- package/dist/cjs/tools/display-document.d.ts +10 -0
- package/dist/cjs/tools/display-document.js +49 -0
- package/dist/cjs/tools/file-dialog.d.ts +11 -0
- package/dist/cjs/tools/file-dialog.js +113 -0
- package/dist/cjs/tools/form-dialog.d.ts +12 -0
- package/dist/cjs/tools/form-dialog.js +92 -0
- package/dist/cjs/tools/form-schema.d.ts +41 -0
- package/dist/cjs/tools/form-schema.js +51 -0
- package/dist/cjs/tools/form.d.ts +16 -0
- package/dist/cjs/tools/form.js +81 -0
- package/dist/cjs/tools/toast.d.ts +10 -0
- package/dist/cjs/tools/toast.js +52 -0
- package/dist/cjs/tools/ui-toolkit.d.ts +6 -0
- package/dist/cjs/tools/ui-toolkit.js +44 -0
- package/dist/esm/Chat.js +29 -6
- package/dist/esm/ChatInput.d.ts +4 -1
- package/dist/esm/ChatInput.js +15 -3
- package/dist/esm/ChatThread.js +1 -0
- package/dist/esm/ChatTypingIndicator.js +2 -2
- package/dist/esm/components/pane-example.d.ts +1 -0
- package/dist/esm/components/pane-example.js +30 -0
- package/dist/esm/components/ui/dialog.d.ts +15 -0
- package/dist/esm/components/ui/dialog.js +136 -0
- package/dist/esm/components/ui/form.d.ts +24 -0
- package/dist/esm/components/ui/form.js +121 -0
- package/dist/esm/components/ui/input.d.ts +3 -0
- package/dist/esm/components/ui/input.js +21 -0
- package/dist/esm/components/ui/label.d.ts +4 -0
- package/dist/esm/components/ui/label.js +23 -0
- package/dist/esm/components/ui/progress.js +1 -1
- package/dist/esm/components/ui/radio-group.d.ts +5 -0
- package/dist/esm/components/ui/radio-group.js +46 -0
- package/dist/esm/components/ui/select.d.ts +15 -0
- package/dist/esm/components/ui/select.js +169 -0
- package/dist/esm/components/ui/sheet.d.ts +13 -0
- package/dist/esm/components/ui/sheet.js +80 -0
- package/dist/esm/components/ui/sonner.d.ts +3 -0
- package/dist/esm/components/ui/sonner.js +22 -0
- package/dist/esm/lib/pane-service.d.ts +16 -0
- package/dist/esm/lib/pane-service.js +15 -0
- package/dist/esm/lib/utils.d.ts +4 -0
- package/dist/esm/tools/ask-user-for-file.d.ts +10 -0
- package/dist/esm/tools/ask-user-for-file.js +48 -0
- package/dist/esm/tools/ask-user.d.ts +10 -0
- package/dist/esm/tools/ask-user.js +141 -0
- package/dist/esm/tools/display-document.d.ts +10 -0
- package/dist/esm/tools/display-document.js +29 -0
- package/dist/esm/tools/file-dialog.d.ts +11 -0
- package/dist/esm/tools/file-dialog.js +101 -0
- package/dist/esm/tools/form-dialog.d.ts +12 -0
- package/dist/esm/tools/form-dialog.js +79 -0
- package/dist/esm/tools/form-schema.d.ts +41 -0
- package/dist/esm/tools/form-schema.js +31 -0
- package/dist/esm/tools/form.d.ts +16 -0
- package/dist/esm/tools/form.js +64 -0
- package/dist/esm/tools/toast.d.ts +10 -0
- package/dist/esm/tools/toast.js +32 -0
- package/dist/esm/tools/ui-toolkit.d.ts +6 -0
- package/dist/esm/tools/ui-toolkit.js +24 -0
- package/dist/index.css +1 -1
- package/package.json +13 -4
|
@@ -0,0 +1,161 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var ask_user_exports = {};
|
|
20
|
+
__export(ask_user_exports, {
|
|
21
|
+
AskUser: () => AskUser
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(ask_user_exports);
|
|
24
|
+
var import_meshagent = require("@meshagent/meshagent");
|
|
25
|
+
var import_form_dialog = require("./form-dialog");
|
|
26
|
+
const askUserSchema = {
|
|
27
|
+
"type": "object",
|
|
28
|
+
"additionalProperties": false,
|
|
29
|
+
"required": ["subject", "form", "help"],
|
|
30
|
+
"properties": {
|
|
31
|
+
"subject": {
|
|
32
|
+
"type": "string",
|
|
33
|
+
"description": "a very short description suitable for a dialog title"
|
|
34
|
+
},
|
|
35
|
+
"help": {
|
|
36
|
+
"type": "string",
|
|
37
|
+
"description": "helpful information that explains why this information is being collected and how it will be used"
|
|
38
|
+
},
|
|
39
|
+
"form": {
|
|
40
|
+
"type": "array",
|
|
41
|
+
"items": {
|
|
42
|
+
"anyOf": [
|
|
43
|
+
{
|
|
44
|
+
"type": "object",
|
|
45
|
+
"additionalProperties": false,
|
|
46
|
+
"required": ["input"],
|
|
47
|
+
"properties": {
|
|
48
|
+
"input": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"additionalProperties": false,
|
|
51
|
+
"required": ["multiline", "name", "description", "default_value"],
|
|
52
|
+
"properties": {
|
|
53
|
+
"name": { "type": "string" },
|
|
54
|
+
"description": { "type": "string" },
|
|
55
|
+
"multiline": { "type": "boolean" },
|
|
56
|
+
"default_value": { "type": "string" }
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
"type": "object",
|
|
63
|
+
"additionalProperties": false,
|
|
64
|
+
"required": ["checkbox"],
|
|
65
|
+
"properties": {
|
|
66
|
+
"checkbox": {
|
|
67
|
+
"type": "object",
|
|
68
|
+
"additionalProperties": false,
|
|
69
|
+
"required": ["name", "description", "default_value"],
|
|
70
|
+
"properties": {
|
|
71
|
+
"name": { "type": "string" },
|
|
72
|
+
"description": { "type": "string" },
|
|
73
|
+
"default_value": { "type": "boolean" }
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"type": "object",
|
|
80
|
+
"additionalProperties": false,
|
|
81
|
+
"required": ["radio_group"],
|
|
82
|
+
"description": "allows the user to select a single option from a list of options. best for multiple choice questions or surveys",
|
|
83
|
+
"properties": {
|
|
84
|
+
"radio_group": {
|
|
85
|
+
"type": "object",
|
|
86
|
+
"additionalProperties": false,
|
|
87
|
+
"required": ["name", "default_value", "description", "options"],
|
|
88
|
+
"properties": {
|
|
89
|
+
"name": { "type": "string" },
|
|
90
|
+
"description": { "type": "string" },
|
|
91
|
+
"default_value": { "type": "string" },
|
|
92
|
+
"options": {
|
|
93
|
+
"type": "array",
|
|
94
|
+
"items": {
|
|
95
|
+
"type": "object",
|
|
96
|
+
"additionalProperties": false,
|
|
97
|
+
"required": ["name", "value"],
|
|
98
|
+
"properties": {
|
|
99
|
+
"name": { "type": "string" },
|
|
100
|
+
"value": { "type": "string" }
|
|
101
|
+
}
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"type": "object",
|
|
110
|
+
"additionalProperties": false,
|
|
111
|
+
"required": ["select"],
|
|
112
|
+
"properties": {
|
|
113
|
+
"select": {
|
|
114
|
+
"type": "object",
|
|
115
|
+
"additionalProperties": false,
|
|
116
|
+
"required": ["name", "options", "description", "default_value"],
|
|
117
|
+
"properties": {
|
|
118
|
+
"name": { "type": "string" },
|
|
119
|
+
"description": { "type": "string" },
|
|
120
|
+
"default_value": { "type": "string" },
|
|
121
|
+
"options": {
|
|
122
|
+
"type": "array",
|
|
123
|
+
"items": {
|
|
124
|
+
"type": "object",
|
|
125
|
+
"additionalProperties": false,
|
|
126
|
+
"required": ["name", "value"],
|
|
127
|
+
"properties": {
|
|
128
|
+
"name": { "type": "string" },
|
|
129
|
+
"value": { "type": "string" }
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
]
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
};
|
|
142
|
+
class AskUser extends import_meshagent.Tool {
|
|
143
|
+
constructor({ name, description, title } = {}) {
|
|
144
|
+
super({
|
|
145
|
+
name: name ?? "ask_user",
|
|
146
|
+
description: description ?? "ask the user a question",
|
|
147
|
+
title: title ?? "Ask User",
|
|
148
|
+
inputSchema: askUserSchema
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
async execute(arguments_) {
|
|
152
|
+
const result = await (0, import_form_dialog.showUserFormDialog)({
|
|
153
|
+
formSchema: arguments_.form,
|
|
154
|
+
title: arguments_.subject
|
|
155
|
+
});
|
|
156
|
+
if (result === null) {
|
|
157
|
+
throw new Error("User cancelled the form dialog");
|
|
158
|
+
}
|
|
159
|
+
return new import_meshagent.JsonResponse({ json: result });
|
|
160
|
+
}
|
|
161
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tool } from '@meshagent/meshagent';
|
|
2
|
+
import type { Response } from '@meshagent/meshagent';
|
|
3
|
+
export declare class DisplayDocument extends Tool {
|
|
4
|
+
constructor({ name, description, title }?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
});
|
|
9
|
+
execute(arguments_: Record<string, any>): Promise<Response>;
|
|
10
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var display_document_exports = {};
|
|
20
|
+
__export(display_document_exports, {
|
|
21
|
+
DisplayDocument: () => DisplayDocument
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(display_document_exports);
|
|
24
|
+
var import_meshagent = require("@meshagent/meshagent");
|
|
25
|
+
const displayDocumentSchema = {
|
|
26
|
+
type: "object",
|
|
27
|
+
additionalProperties: false,
|
|
28
|
+
required: ["path"],
|
|
29
|
+
properties: {
|
|
30
|
+
path: {
|
|
31
|
+
type: "string"
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
class DisplayDocument extends import_meshagent.Tool {
|
|
36
|
+
constructor({ name, description, title } = {}) {
|
|
37
|
+
super({
|
|
38
|
+
name: name ?? "display_document",
|
|
39
|
+
description: description ?? "display document to the user",
|
|
40
|
+
title: title ?? "display document",
|
|
41
|
+
inputSchema: displayDocumentSchema
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
async execute(arguments_) {
|
|
45
|
+
const { path } = arguments_;
|
|
46
|
+
console.log("Navigate to document:", path);
|
|
47
|
+
return new import_meshagent.EmptyResponse();
|
|
48
|
+
}
|
|
49
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare function showFileDialog({ title, description }: {
|
|
2
|
+
title?: string;
|
|
3
|
+
description?: string;
|
|
4
|
+
}): Promise<Record<string, any> | null>;
|
|
5
|
+
export declare function FileDialog({ title, description, onSubmit, onDismiss, onCleanup }: {
|
|
6
|
+
title?: string;
|
|
7
|
+
description?: string;
|
|
8
|
+
onSubmit: (file: File | null) => void;
|
|
9
|
+
onDismiss: () => void;
|
|
10
|
+
onCleanup: () => void;
|
|
11
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var file_dialog_exports = {};
|
|
20
|
+
__export(file_dialog_exports, {
|
|
21
|
+
FileDialog: () => FileDialog,
|
|
22
|
+
showFileDialog: () => showFileDialog
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(file_dialog_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_client = require("react-dom/client");
|
|
28
|
+
var import_dialog = require("../components/ui/dialog");
|
|
29
|
+
var import_button = require("../components/ui/button");
|
|
30
|
+
function showFileDialog({ title, description }) {
|
|
31
|
+
return new Promise((resolve) => {
|
|
32
|
+
const container = document.createElement("div");
|
|
33
|
+
document.body.appendChild(container);
|
|
34
|
+
const root = (0, import_client.createRoot)(container);
|
|
35
|
+
const onCleanup = () => {
|
|
36
|
+
root.unmount();
|
|
37
|
+
container.remove();
|
|
38
|
+
};
|
|
39
|
+
const onDismiss = () => resolve(null);
|
|
40
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
41
|
+
FileDialog,
|
|
42
|
+
{
|
|
43
|
+
title,
|
|
44
|
+
description,
|
|
45
|
+
onSubmit: resolve,
|
|
46
|
+
onDismiss,
|
|
47
|
+
onCleanup
|
|
48
|
+
}
|
|
49
|
+
));
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function FileDialog({ title, description, onSubmit, onDismiss, onCleanup }) {
|
|
53
|
+
const inputRef = (0, import_react.useRef)(null);
|
|
54
|
+
const [open, setOpen] = (0, import_react.useState)(true);
|
|
55
|
+
const [selectedFile, setSelectedFile] = (0, import_react.useState)(null);
|
|
56
|
+
const handleSubmit = (0, import_react.useCallback)((e) => {
|
|
57
|
+
e.preventDefault();
|
|
58
|
+
onSubmit(selectedFile);
|
|
59
|
+
setOpen(false);
|
|
60
|
+
}, [selectedFile, onSubmit]);
|
|
61
|
+
const handleFileChange = (e) => {
|
|
62
|
+
if (e.target.files && e.target.files[0]) {
|
|
63
|
+
setSelectedFile(e.target.files[0]);
|
|
64
|
+
}
|
|
65
|
+
};
|
|
66
|
+
const onOpenChange = (0, import_react.useCallback)((isOpen) => {
|
|
67
|
+
onDismiss();
|
|
68
|
+
setOpen(isOpen);
|
|
69
|
+
}, [onDismiss]);
|
|
70
|
+
const onAnimationEnd = (0, import_react.useCallback)(() => {
|
|
71
|
+
if (!open) {
|
|
72
|
+
onCleanup();
|
|
73
|
+
}
|
|
74
|
+
}, [open, onCleanup]);
|
|
75
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, { open, onOpenChange, modal: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
76
|
+
import_dialog.DialogContent,
|
|
77
|
+
{
|
|
78
|
+
showCloseButton: true,
|
|
79
|
+
onAnimationEnd,
|
|
80
|
+
className: "\n sm:max-w-[425px]\n fixed top-1/2 left-1/2 w-[90vw] max-w-md max-h-[90vh]\n transform -translate-x-1/2 -translate-y-1/2\n bg-white rounded shadow-lg p-6 overflow-y-auto",
|
|
81
|
+
children: [
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogHeader, { children: [
|
|
83
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, { children: title }),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogDescription, { children: description })
|
|
85
|
+
] }),
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
87
|
+
"input",
|
|
88
|
+
{
|
|
89
|
+
id: "file-input",
|
|
90
|
+
type: "file",
|
|
91
|
+
onChange: handleFileChange,
|
|
92
|
+
className: "\n block w-full text-sm text-gray-500 file:mr-4 file:py-2\n file:px-4 file:rounded-full file:border-0 file:text-sm \n file:font-semibold file:bg-gray-100 hover:file:bg-gray-200"
|
|
93
|
+
}
|
|
94
|
+
),
|
|
95
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
96
|
+
"input",
|
|
97
|
+
{
|
|
98
|
+
ref: inputRef,
|
|
99
|
+
type: "file",
|
|
100
|
+
multiple: true,
|
|
101
|
+
accept: "",
|
|
102
|
+
className: "hidden",
|
|
103
|
+
onChange: handleFileChange
|
|
104
|
+
}
|
|
105
|
+
),
|
|
106
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogFooter, { className: "pt-4", children: [
|
|
107
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "outline", children: "Cancel" }) }),
|
|
108
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { onClick: handleSubmit, children: "Submit" })
|
|
109
|
+
] })
|
|
110
|
+
]
|
|
111
|
+
}
|
|
112
|
+
) });
|
|
113
|
+
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { FormSchema } from "./form-schema";
|
|
2
|
+
export declare function showUserFormDialog({ formSchema, title }: {
|
|
3
|
+
formSchema: FormSchema;
|
|
4
|
+
title?: string;
|
|
5
|
+
}): Promise<Record<string, any> | null>;
|
|
6
|
+
export declare function FormDialog({ title, formSchema, onSubmit, onDismiss, onCleanup }: {
|
|
7
|
+
title?: string;
|
|
8
|
+
formSchema: FormSchema;
|
|
9
|
+
onSubmit: (data: Record<string, any>) => void;
|
|
10
|
+
onDismiss: () => void;
|
|
11
|
+
onCleanup: () => void;
|
|
12
|
+
}): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var form_dialog_exports = {};
|
|
20
|
+
__export(form_dialog_exports, {
|
|
21
|
+
FormDialog: () => FormDialog,
|
|
22
|
+
showUserFormDialog: () => showUserFormDialog
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(form_dialog_exports);
|
|
25
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
26
|
+
var import_react = require("react");
|
|
27
|
+
var import_client = require("react-dom/client");
|
|
28
|
+
var import_react_hook_form = require("react-hook-form");
|
|
29
|
+
var import_dialog = require("@/components/ui/dialog");
|
|
30
|
+
var import_button = require("@/components/ui/button");
|
|
31
|
+
var import_form = require("./form");
|
|
32
|
+
function showUserFormDialog({ formSchema, title }) {
|
|
33
|
+
return new Promise((resolve) => {
|
|
34
|
+
const container = document.createElement("div");
|
|
35
|
+
document.body.appendChild(container);
|
|
36
|
+
const root = (0, import_client.createRoot)(container);
|
|
37
|
+
const onCleanup = () => {
|
|
38
|
+
root.unmount();
|
|
39
|
+
container.remove();
|
|
40
|
+
};
|
|
41
|
+
const onDismiss = () => resolve(null);
|
|
42
|
+
root.render(/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
43
|
+
FormDialog,
|
|
44
|
+
{
|
|
45
|
+
title,
|
|
46
|
+
formSchema,
|
|
47
|
+
onSubmit: resolve,
|
|
48
|
+
onDismiss,
|
|
49
|
+
onCleanup
|
|
50
|
+
}
|
|
51
|
+
));
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function FormDialog({ title, formSchema, onSubmit, onDismiss, onCleanup }) {
|
|
55
|
+
const [open, setOpen] = (0, import_react.useState)(true);
|
|
56
|
+
const form = (0, import_react_hook_form.useForm)({
|
|
57
|
+
resolver: async (values) => ({ values, errors: {} }),
|
|
58
|
+
mode: "onChange",
|
|
59
|
+
defaultValues: {}
|
|
60
|
+
});
|
|
61
|
+
const handleSubmit = (0, import_react.useCallback)((e) => {
|
|
62
|
+
e.preventDefault();
|
|
63
|
+
onSubmit(form.getValues());
|
|
64
|
+
}, [onSubmit]);
|
|
65
|
+
const onOpenChange = (0, import_react.useCallback)((isOpen) => {
|
|
66
|
+
onDismiss();
|
|
67
|
+
setOpen(isOpen);
|
|
68
|
+
}, [onDismiss]);
|
|
69
|
+
const onAnimationEnd = (0, import_react.useCallback)(() => {
|
|
70
|
+
if (!open) {
|
|
71
|
+
onCleanup();
|
|
72
|
+
}
|
|
73
|
+
}, [open, onCleanup]);
|
|
74
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.Dialog, { open, onOpenChange, modal: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsxs)(
|
|
75
|
+
import_dialog.DialogContent,
|
|
76
|
+
{
|
|
77
|
+
className: "sm:max-w-[425px]\n fixed top-1/2 left-1/2 w-[90vw] max-w-md max-h-[90vh]\n transform -translate-x-1/2 -translate-y-1/2\n bg-white rounded shadow-lg p-6 overflow-y-auto",
|
|
78
|
+
showCloseButton: true,
|
|
79
|
+
onAnimationEnd,
|
|
80
|
+
children: [
|
|
81
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogHeader, { children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogTitle, { children: title }) }),
|
|
82
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)("form", { onSubmit: handleSubmit, className: "grid gap-4 py-4", children: [
|
|
83
|
+
formSchema.map((fieldItem, index) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_form.FormField, { fieldItem, control: form.control }, index)),
|
|
84
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsxs)(import_dialog.DialogFooter, { className: "pt-4", children: [
|
|
85
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_dialog.DialogClose, { asChild: true, children: /* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { variant: "outline", children: "Cancel" }) }),
|
|
86
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(import_button.Button, { type: "submit", children: "Submit" })
|
|
87
|
+
] })
|
|
88
|
+
] })
|
|
89
|
+
]
|
|
90
|
+
}
|
|
91
|
+
) });
|
|
92
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
export interface BaseField<T> {
|
|
2
|
+
name: string;
|
|
3
|
+
description: string;
|
|
4
|
+
default_value: T;
|
|
5
|
+
}
|
|
6
|
+
export interface InputField extends BaseField<string> {
|
|
7
|
+
multiline: boolean;
|
|
8
|
+
}
|
|
9
|
+
export interface SelectOption {
|
|
10
|
+
name: string;
|
|
11
|
+
value: string;
|
|
12
|
+
}
|
|
13
|
+
export interface SelectField extends BaseField<string> {
|
|
14
|
+
options: SelectOption[];
|
|
15
|
+
}
|
|
16
|
+
export interface RadioOption {
|
|
17
|
+
name: string;
|
|
18
|
+
value: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RadioGroupField extends BaseField<string> {
|
|
21
|
+
options: RadioOption[];
|
|
22
|
+
}
|
|
23
|
+
export interface CheckboxField extends BaseField<boolean> {
|
|
24
|
+
}
|
|
25
|
+
export type FormField = InputField | SelectField | RadioGroupField | CheckboxField;
|
|
26
|
+
export interface InputFieldItem {
|
|
27
|
+
input: InputField;
|
|
28
|
+
}
|
|
29
|
+
export interface SelectFieldItem {
|
|
30
|
+
select: SelectField;
|
|
31
|
+
}
|
|
32
|
+
export interface RadioGroupFieldItem {
|
|
33
|
+
radio_group: RadioGroupField;
|
|
34
|
+
}
|
|
35
|
+
export interface CheckboxFieldItem {
|
|
36
|
+
checkbox: CheckboxField;
|
|
37
|
+
}
|
|
38
|
+
export type FormFieldItem = InputFieldItem | SelectFieldItem | RadioGroupFieldItem | CheckboxFieldItem;
|
|
39
|
+
export type FormSchema = FormFieldItem[];
|
|
40
|
+
export declare function getFormFieldType(fieldItem: FormFieldItem): String;
|
|
41
|
+
export declare function getFormField(fieldItem: FormFieldItem): FormField;
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var form_schema_exports = {};
|
|
20
|
+
__export(form_schema_exports, {
|
|
21
|
+
getFormField: () => getFormField,
|
|
22
|
+
getFormFieldType: () => getFormFieldType
|
|
23
|
+
});
|
|
24
|
+
module.exports = __toCommonJS(form_schema_exports);
|
|
25
|
+
function getFormFieldType(fieldItem) {
|
|
26
|
+
if ("input" in fieldItem) {
|
|
27
|
+
return "input";
|
|
28
|
+
} else if ("select" in fieldItem) {
|
|
29
|
+
return "select";
|
|
30
|
+
} else if ("radio_group" in fieldItem) {
|
|
31
|
+
return "radio_group";
|
|
32
|
+
} else if ("checkbox" in fieldItem) {
|
|
33
|
+
return "checkbox";
|
|
34
|
+
}
|
|
35
|
+
throw new Error("Unknown form field type");
|
|
36
|
+
}
|
|
37
|
+
function getFormField(fieldItem) {
|
|
38
|
+
if ("input" in fieldItem) {
|
|
39
|
+
return fieldItem.input;
|
|
40
|
+
}
|
|
41
|
+
if ("select" in fieldItem) {
|
|
42
|
+
return fieldItem.select;
|
|
43
|
+
}
|
|
44
|
+
if ("radio_group" in fieldItem) {
|
|
45
|
+
return fieldItem.radio_group;
|
|
46
|
+
}
|
|
47
|
+
if ("checkbox" in fieldItem) {
|
|
48
|
+
return fieldItem.checkbox;
|
|
49
|
+
}
|
|
50
|
+
throw new Error("Unknown form field type");
|
|
51
|
+
}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import type { Control } from "react-hook-form";
|
|
3
|
+
import type { FormFieldItem } from "./form-schema";
|
|
4
|
+
export type FieldErrorProperty = {
|
|
5
|
+
errors: string[];
|
|
6
|
+
} | undefined;
|
|
7
|
+
export type FieldErrors = {
|
|
8
|
+
errors: string[];
|
|
9
|
+
properties?: {
|
|
10
|
+
[x: string]: FieldErrorProperty;
|
|
11
|
+
} | undefined;
|
|
12
|
+
};
|
|
13
|
+
export declare function FormField({ fieldItem, control }: {
|
|
14
|
+
fieldItem: FormFieldItem;
|
|
15
|
+
control: Control<any>;
|
|
16
|
+
}): React.ReactElement;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
var form_exports = {};
|
|
20
|
+
__export(form_exports, {
|
|
21
|
+
FormField: () => FormField
|
|
22
|
+
});
|
|
23
|
+
module.exports = __toCommonJS(form_exports);
|
|
24
|
+
var import_jsx_runtime = require("react/jsx-runtime");
|
|
25
|
+
var import_react = require("react");
|
|
26
|
+
var import_react_hook_form = require("react-hook-form");
|
|
27
|
+
var import_form_schema = require("./form-schema");
|
|
28
|
+
function FormField({ fieldItem, control }) {
|
|
29
|
+
const field = (0, import_react.useMemo)(() => (0, import_form_schema.getFormField)(fieldItem), [fieldItem]);
|
|
30
|
+
const fieldKey = (0, import_react.useMemo)(() => (0, import_form_schema.getFormFieldType)(fieldItem), [fieldItem]);
|
|
31
|
+
const { field: controllerField } = (0, import_react_hook_form.useController)({
|
|
32
|
+
name: field.name,
|
|
33
|
+
control,
|
|
34
|
+
defaultValue: field.default_value
|
|
35
|
+
});
|
|
36
|
+
switch (fieldKey) {
|
|
37
|
+
case "checkbox": {
|
|
38
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "flex items-center space-x-2", children: [
|
|
39
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
40
|
+
"input",
|
|
41
|
+
{
|
|
42
|
+
type: "checkbox",
|
|
43
|
+
checked: controllerField.value,
|
|
44
|
+
onChange: (e) => controllerField.onChange(e.target.checked)
|
|
45
|
+
}
|
|
46
|
+
),
|
|
47
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: field.description })
|
|
48
|
+
] });
|
|
49
|
+
}
|
|
50
|
+
case "radio_group": {
|
|
51
|
+
const f2 = field;
|
|
52
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
53
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium mb-1", children: field.description }),
|
|
54
|
+
(f2.options ?? []).map((opt) => /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("label", { className: "flex items-center space-x-2", children: [
|
|
55
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)(
|
|
56
|
+
"input",
|
|
57
|
+
{
|
|
58
|
+
type: "radio",
|
|
59
|
+
value: opt.value,
|
|
60
|
+
checked: controllerField.value === opt.value,
|
|
61
|
+
onChange: () => controllerField.onChange(opt.value)
|
|
62
|
+
}
|
|
63
|
+
),
|
|
64
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("span", { children: opt.name })
|
|
65
|
+
] }, opt.value))
|
|
66
|
+
] });
|
|
67
|
+
}
|
|
68
|
+
case "select": {
|
|
69
|
+
const f2 = field;
|
|
70
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { children: [
|
|
71
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium mb-1", children: field.description }),
|
|
72
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("select", { ...controllerField, className: "border p-2 w-full rounded", children: (f2.options ?? []).map((opt) => /* @__PURE__ */ (0, import_jsx_runtime.jsx)("option", { value: opt.value, children: opt.name }, opt.value)) })
|
|
73
|
+
] });
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
const f = field;
|
|
77
|
+
return /* @__PURE__ */ (0, import_jsx_runtime.jsxs)("div", { className: "space-y-1", children: [
|
|
78
|
+
/* @__PURE__ */ (0, import_jsx_runtime.jsx)("label", { className: "block font-medium", children: f.description }),
|
|
79
|
+
f.multiline ? /* @__PURE__ */ (0, import_jsx_runtime.jsx)("textarea", { ...controllerField, className: "border p-2 w-full rounded" }) : /* @__PURE__ */ (0, import_jsx_runtime.jsx)("input", { type: "text", ...controllerField, className: "border p-2 w-full rounded" })
|
|
80
|
+
] });
|
|
81
|
+
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { Tool } from '@meshagent/meshagent';
|
|
2
|
+
import type { Response } from '@meshagent/meshagent';
|
|
3
|
+
export declare class Toast extends Tool {
|
|
4
|
+
constructor({ name, description, title }?: {
|
|
5
|
+
name?: string;
|
|
6
|
+
description?: string;
|
|
7
|
+
title?: string;
|
|
8
|
+
});
|
|
9
|
+
execute(arguments_: Record<string, any>): Promise<Response>;
|
|
10
|
+
}
|