@mulmochat-plugin/form 0.1.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 +96 -0
- package/dist/common/index.d.ts +7 -0
- package/dist/common/types.d.ts +128 -0
- package/dist/form.css +1 -0
- package/dist/index.cjs +2 -0
- package/dist/index.d.ts +15 -0
- package/dist/index.js +994 -0
- package/dist/plugin.d.ts +105 -0
- package/dist/previews/FormPreview.vue.d.ts +7 -0
- package/dist/types.d.ts +5 -0
- package/dist/views/FormView.vue.d.ts +12 -0
- package/package.json +50 -0
package/dist/plugin.d.ts
ADDED
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* MulmoChat Form Plugin
|
|
3
|
+
*
|
|
4
|
+
* A plugin for creating structured forms to collect user information.
|
|
5
|
+
*
|
|
6
|
+
* @example Basic usage
|
|
7
|
+
* ```typescript
|
|
8
|
+
* import { plugin } from "@mulmochat-plugin/form";
|
|
9
|
+
* import "@mulmochat-plugin/form/style.css";
|
|
10
|
+
* // Use plugin directly
|
|
11
|
+
* ```
|
|
12
|
+
*/
|
|
13
|
+
import type { ToolPlugin, ToolResult } from "./common";
|
|
14
|
+
/** Field type discriminator */
|
|
15
|
+
export type FieldType = "text" | "textarea" | "radio" | "dropdown" | "checkbox" | "date" | "time" | "number";
|
|
16
|
+
/** Base field interface */
|
|
17
|
+
export interface BaseField {
|
|
18
|
+
id: string;
|
|
19
|
+
type: FieldType;
|
|
20
|
+
label: string;
|
|
21
|
+
description?: string;
|
|
22
|
+
required?: boolean;
|
|
23
|
+
maxLength?: number;
|
|
24
|
+
}
|
|
25
|
+
/** Text field */
|
|
26
|
+
export interface TextField extends BaseField {
|
|
27
|
+
type: "text";
|
|
28
|
+
placeholder?: string;
|
|
29
|
+
validation?: "email" | "url" | "phone" | string;
|
|
30
|
+
defaultValue?: string;
|
|
31
|
+
minLength?: number;
|
|
32
|
+
maxLength?: number;
|
|
33
|
+
}
|
|
34
|
+
/** Textarea field */
|
|
35
|
+
export interface TextareaField extends BaseField {
|
|
36
|
+
type: "textarea";
|
|
37
|
+
placeholder?: string;
|
|
38
|
+
minLength?: number;
|
|
39
|
+
maxLength?: number;
|
|
40
|
+
rows?: number;
|
|
41
|
+
defaultValue?: string;
|
|
42
|
+
}
|
|
43
|
+
/** Radio field */
|
|
44
|
+
export interface RadioField extends BaseField {
|
|
45
|
+
type: "radio";
|
|
46
|
+
choices: string[];
|
|
47
|
+
defaultValue?: string;
|
|
48
|
+
}
|
|
49
|
+
/** Dropdown field */
|
|
50
|
+
export interface DropdownField extends BaseField {
|
|
51
|
+
type: "dropdown";
|
|
52
|
+
choices: string[];
|
|
53
|
+
searchable?: boolean;
|
|
54
|
+
defaultValue?: string;
|
|
55
|
+
}
|
|
56
|
+
/** Checkbox field */
|
|
57
|
+
export interface CheckboxField extends BaseField {
|
|
58
|
+
type: "checkbox";
|
|
59
|
+
choices: string[];
|
|
60
|
+
minSelections?: number;
|
|
61
|
+
maxSelections?: number;
|
|
62
|
+
defaultValue?: string[];
|
|
63
|
+
}
|
|
64
|
+
/** Date field */
|
|
65
|
+
export interface DateField extends BaseField {
|
|
66
|
+
type: "date";
|
|
67
|
+
minDate?: string;
|
|
68
|
+
maxDate?: string;
|
|
69
|
+
format?: string;
|
|
70
|
+
defaultValue?: string;
|
|
71
|
+
}
|
|
72
|
+
/** Time field */
|
|
73
|
+
export interface TimeField extends BaseField {
|
|
74
|
+
type: "time";
|
|
75
|
+
format?: "12hr" | "24hr";
|
|
76
|
+
defaultValue?: string;
|
|
77
|
+
}
|
|
78
|
+
/** Number field */
|
|
79
|
+
export interface NumberField extends BaseField {
|
|
80
|
+
type: "number";
|
|
81
|
+
min?: number;
|
|
82
|
+
max?: number;
|
|
83
|
+
step?: number;
|
|
84
|
+
defaultValue?: number;
|
|
85
|
+
}
|
|
86
|
+
/** Union type for all fields */
|
|
87
|
+
export type FormField = TextField | TextareaField | RadioField | DropdownField | CheckboxField | DateField | TimeField | NumberField;
|
|
88
|
+
/** Form data stored in result.jsonData */
|
|
89
|
+
export interface FormData {
|
|
90
|
+
title?: string;
|
|
91
|
+
description?: string;
|
|
92
|
+
fields: FormField[];
|
|
93
|
+
}
|
|
94
|
+
/** Arguments passed to the form tool */
|
|
95
|
+
export interface FormArgs {
|
|
96
|
+
title?: string;
|
|
97
|
+
description?: string;
|
|
98
|
+
fields: FormField[];
|
|
99
|
+
}
|
|
100
|
+
/** Form tool result type */
|
|
101
|
+
export type FormResult = ToolResult<never, FormData>;
|
|
102
|
+
/**
|
|
103
|
+
* Form plugin instance
|
|
104
|
+
*/
|
|
105
|
+
export declare const plugin: ToolPlugin<never, FormData, FormArgs>;
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { ToolResult } from "../common";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
result: ToolResult;
|
|
4
|
+
};
|
|
5
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
6
|
+
declare const _default: typeof __VLS_export;
|
|
7
|
+
export default _default;
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Re-export common types for backward compatibility.
|
|
3
|
+
* New plugins should import from "./common" directly.
|
|
4
|
+
*/
|
|
5
|
+
export type { ToolContext, ToolResult, ToolPlugin, ToolDefinition, JsonSchemaProperty, StartApiResponse, FileUploadConfig, ToolPluginConfig, ToolSample, } from "./common";
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ToolResult } from "../common";
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
selectedResult: ToolResult | null;
|
|
4
|
+
sendTextMessage: (text?: string) => void;
|
|
5
|
+
};
|
|
6
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
7
|
+
updateResult: (result: ToolResult<unknown, unknown>) => any;
|
|
8
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
9
|
+
onUpdateResult?: ((result: ToolResult<unknown, unknown>) => any) | undefined;
|
|
10
|
+
}>, {}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
11
|
+
declare const _default: typeof __VLS_export;
|
|
12
|
+
export default _default;
|
package/package.json
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@mulmochat-plugin/form",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Form plugin for MulmoChat",
|
|
5
|
+
"type": "module",
|
|
6
|
+
"main": "./dist/index.cjs",
|
|
7
|
+
"module": "./dist/index.js",
|
|
8
|
+
"types": "./dist/index.d.ts",
|
|
9
|
+
"exports": {
|
|
10
|
+
".": {
|
|
11
|
+
"types": "./dist/index.d.ts",
|
|
12
|
+
"import": "./dist/index.js",
|
|
13
|
+
"require": "./dist/index.cjs"
|
|
14
|
+
},
|
|
15
|
+
"./style.css": "./dist/form.css"
|
|
16
|
+
},
|
|
17
|
+
"files": [
|
|
18
|
+
"dist"
|
|
19
|
+
],
|
|
20
|
+
"scripts": {
|
|
21
|
+
"dev": "vite",
|
|
22
|
+
"build": "vite build && vue-tsc -p tsconfig.build.json --emitDeclarationOnly",
|
|
23
|
+
"typecheck": "vue-tsc --noEmit",
|
|
24
|
+
"lint": "eslint src demo"
|
|
25
|
+
},
|
|
26
|
+
"peerDependencies": {
|
|
27
|
+
"vue": "^3.5.0"
|
|
28
|
+
},
|
|
29
|
+
"devDependencies": {
|
|
30
|
+
"@tailwindcss/vite": "^4.1.18",
|
|
31
|
+
"@typescript-eslint/eslint-plugin": "^8.53.0",
|
|
32
|
+
"@typescript-eslint/parser": "^8.53.0",
|
|
33
|
+
"@vitejs/plugin-vue": "^6.0.3",
|
|
34
|
+
"eslint": "^9.39.2",
|
|
35
|
+
"eslint-plugin-vue": "^10.6.2",
|
|
36
|
+
"globals": "^17.0.0",
|
|
37
|
+
"tailwindcss": "^4.1.18",
|
|
38
|
+
"typescript": "~5.9.3",
|
|
39
|
+
"vite": "^7.3.1",
|
|
40
|
+
"vue": "^3.5.26",
|
|
41
|
+
"vue-eslint-parser": "^10.2.0",
|
|
42
|
+
"vue-tsc": "^3.2.2"
|
|
43
|
+
},
|
|
44
|
+
"keywords": [
|
|
45
|
+
"mulmochat",
|
|
46
|
+
"plugin",
|
|
47
|
+
"form"
|
|
48
|
+
],
|
|
49
|
+
"license": "MIT"
|
|
50
|
+
}
|