@ai-gui/plugin-form 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/README.md +42 -0
- package/dist/index.cjs +625 -0
- package/dist/index.d.cts +64 -0
- package/dist/index.d.ts +64 -0
- package/dist/index.js +598 -0
- package/package.json +59 -0
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AIGuiPlugin, ActionRuntime } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type FormFieldType = "text" | "textarea" | "number" | "date" | "select" | "checkbox" | "radio";
|
|
5
|
+
interface FormOption {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
interface FormFieldBase {
|
|
10
|
+
name: string;
|
|
11
|
+
type: FormFieldType;
|
|
12
|
+
label: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
}
|
|
16
|
+
interface FormStringField extends FormFieldBase {
|
|
17
|
+
type: "text" | "textarea";
|
|
18
|
+
minLength?: number;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
pattern?: string;
|
|
21
|
+
}
|
|
22
|
+
interface FormDateField extends FormFieldBase {
|
|
23
|
+
type: "date";
|
|
24
|
+
}
|
|
25
|
+
interface FormNumberField extends FormFieldBase {
|
|
26
|
+
type: "number";
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
}
|
|
30
|
+
interface FormChoiceField extends FormFieldBase {
|
|
31
|
+
type: "select" | "radio";
|
|
32
|
+
options: FormOption[];
|
|
33
|
+
}
|
|
34
|
+
interface FormCheckboxField extends FormFieldBase {
|
|
35
|
+
type: "checkbox";
|
|
36
|
+
}
|
|
37
|
+
type FormField = FormStringField | FormDateField | FormNumberField | FormChoiceField | FormCheckboxField;
|
|
38
|
+
interface FormDefinition {
|
|
39
|
+
id: string;
|
|
40
|
+
fields: FormField[];
|
|
41
|
+
submitAction: string;
|
|
42
|
+
submitLabel?: string;
|
|
43
|
+
}
|
|
44
|
+
type FormParseResult = {
|
|
45
|
+
valid: true;
|
|
46
|
+
data: FormDefinition;
|
|
47
|
+
} | {
|
|
48
|
+
valid: false;
|
|
49
|
+
issues: string[];
|
|
50
|
+
};
|
|
51
|
+
interface FormValidationResult {
|
|
52
|
+
valid: boolean;
|
|
53
|
+
values: Record<string, string | number | boolean>;
|
|
54
|
+
errors: Record<string, string>;
|
|
55
|
+
}
|
|
56
|
+
interface FormPluginOptions {
|
|
57
|
+
/** Shared core runtime whose registry is the only allowlist for submitAction. */
|
|
58
|
+
actionRuntime: ActionRuntime;
|
|
59
|
+
}
|
|
60
|
+
declare function formPromptSpec(): string;
|
|
61
|
+
declare function form(options: FormPluginOptions): AIGuiPlugin;
|
|
62
|
+
declare function parseFormDefinition(source: string): FormParseResult;
|
|
63
|
+
declare function validateFormValues(definition: FormDefinition, input: Record<string, unknown>): FormValidationResult; //#endregion
|
|
64
|
+
export { FormCheckboxField, FormChoiceField, FormDateField, FormDefinition, FormField, FormFieldType, FormNumberField, FormOption, FormParseResult, FormPluginOptions, FormStringField, FormValidationResult, form, formPromptSpec, parseFormDefinition, validateFormValues };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { AIGuiPlugin, ActionRuntime } from "@ai-gui/core";
|
|
2
|
+
|
|
3
|
+
//#region src/index.d.ts
|
|
4
|
+
type FormFieldType = "text" | "textarea" | "number" | "date" | "select" | "checkbox" | "radio";
|
|
5
|
+
interface FormOption {
|
|
6
|
+
label: string;
|
|
7
|
+
value: string;
|
|
8
|
+
}
|
|
9
|
+
interface FormFieldBase {
|
|
10
|
+
name: string;
|
|
11
|
+
type: FormFieldType;
|
|
12
|
+
label: string;
|
|
13
|
+
required?: boolean;
|
|
14
|
+
placeholder?: string;
|
|
15
|
+
}
|
|
16
|
+
interface FormStringField extends FormFieldBase {
|
|
17
|
+
type: "text" | "textarea";
|
|
18
|
+
minLength?: number;
|
|
19
|
+
maxLength?: number;
|
|
20
|
+
pattern?: string;
|
|
21
|
+
}
|
|
22
|
+
interface FormDateField extends FormFieldBase {
|
|
23
|
+
type: "date";
|
|
24
|
+
}
|
|
25
|
+
interface FormNumberField extends FormFieldBase {
|
|
26
|
+
type: "number";
|
|
27
|
+
min?: number;
|
|
28
|
+
max?: number;
|
|
29
|
+
}
|
|
30
|
+
interface FormChoiceField extends FormFieldBase {
|
|
31
|
+
type: "select" | "radio";
|
|
32
|
+
options: FormOption[];
|
|
33
|
+
}
|
|
34
|
+
interface FormCheckboxField extends FormFieldBase {
|
|
35
|
+
type: "checkbox";
|
|
36
|
+
}
|
|
37
|
+
type FormField = FormStringField | FormDateField | FormNumberField | FormChoiceField | FormCheckboxField;
|
|
38
|
+
interface FormDefinition {
|
|
39
|
+
id: string;
|
|
40
|
+
fields: FormField[];
|
|
41
|
+
submitAction: string;
|
|
42
|
+
submitLabel?: string;
|
|
43
|
+
}
|
|
44
|
+
type FormParseResult = {
|
|
45
|
+
valid: true;
|
|
46
|
+
data: FormDefinition;
|
|
47
|
+
} | {
|
|
48
|
+
valid: false;
|
|
49
|
+
issues: string[];
|
|
50
|
+
};
|
|
51
|
+
interface FormValidationResult {
|
|
52
|
+
valid: boolean;
|
|
53
|
+
values: Record<string, string | number | boolean>;
|
|
54
|
+
errors: Record<string, string>;
|
|
55
|
+
}
|
|
56
|
+
interface FormPluginOptions {
|
|
57
|
+
/** Shared core runtime whose registry is the only allowlist for submitAction. */
|
|
58
|
+
actionRuntime: ActionRuntime;
|
|
59
|
+
}
|
|
60
|
+
declare function formPromptSpec(): string;
|
|
61
|
+
declare function form(options: FormPluginOptions): AIGuiPlugin;
|
|
62
|
+
declare function parseFormDefinition(source: string): FormParseResult;
|
|
63
|
+
declare function validateFormValues(definition: FormDefinition, input: Record<string, unknown>): FormValidationResult; //#endregion
|
|
64
|
+
export { FormCheckboxField, FormChoiceField, FormDateField, FormDefinition, FormField, FormFieldType, FormNumberField, FormOption, FormParseResult, FormPluginOptions, FormStringField, FormValidationResult, form, formPromptSpec, parseFormDefinition, validateFormValues };
|