@mulmochat-plugin/form 0.3.1 → 0.3.2
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/dist/core.cjs +1 -2
- package/dist/core.js +2 -432
- package/dist/index.cjs +1 -1
- package/dist/index.d.ts +2 -2
- package/dist/index.js +3 -9
- package/dist/plugin-BgGi_Eou.js +354 -0
- package/dist/plugin-DbwkQIio.cjs +2 -0
- package/dist/style.css +3 -1
- package/dist/vue.cjs +1 -1
- package/dist/vue.js +516 -580
- package/package.json +15 -14
package/dist/core.cjs
CHANGED
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Form creation error`,i),{message:`Form error: ${i instanceof Error?i.message:"Unknown error"}`,instructions:"Acknowledge that there was an error creating the form and suggest trying again with corrected field definitions."}}},p={toolDefinition:s,execute:d,generatingMessage:"Preparing form...",isEnabled:()=>!0,samples:l};exports.SAMPLES=l;exports.TOOL_DEFINITION=s;exports.TOOL_NAME=n;exports.executeForm=d;exports.pluginCore=p;
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require(`./plugin-DbwkQIio.cjs`);exports.SAMPLES=e.r,exports.TOOL_DEFINITION=e.i,exports.TOOL_NAME=e.a,exports.executeForm=e.t,exports.pluginCore=e.n;
|
package/dist/core.js
CHANGED
|
@@ -1,432 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
name: u,
|
|
4
|
-
description: "Create a structured form to collect information from the user. Supports various field types including text input, textarea, multiple choice (radio), dropdown menus, checkboxes, date/time pickers, and number inputs. Each field can have validation rules and help text.",
|
|
5
|
-
parameters: {
|
|
6
|
-
type: "object",
|
|
7
|
-
properties: {
|
|
8
|
-
title: {
|
|
9
|
-
type: "string",
|
|
10
|
-
description: "Optional title for the form (e.g., 'User Registration')"
|
|
11
|
-
},
|
|
12
|
-
description: {
|
|
13
|
-
type: "string",
|
|
14
|
-
description: "Optional description explaining the purpose of the form"
|
|
15
|
-
},
|
|
16
|
-
fields: {
|
|
17
|
-
type: "array",
|
|
18
|
-
description: "Array of form fields with various types and configurations",
|
|
19
|
-
items: {
|
|
20
|
-
type: "object",
|
|
21
|
-
properties: {
|
|
22
|
-
id: {
|
|
23
|
-
type: "string",
|
|
24
|
-
description: "Unique identifier for the field (e.g., 'email', 'birthdate'). This will be the key in the JSON response. Use descriptive camelCase or snake_case names."
|
|
25
|
-
},
|
|
26
|
-
type: {
|
|
27
|
-
type: "string",
|
|
28
|
-
enum: [
|
|
29
|
-
"text",
|
|
30
|
-
"textarea",
|
|
31
|
-
"radio",
|
|
32
|
-
"dropdown",
|
|
33
|
-
"checkbox",
|
|
34
|
-
"date",
|
|
35
|
-
"time",
|
|
36
|
-
"number"
|
|
37
|
-
],
|
|
38
|
-
description: "Field type: 'text' for short text, 'textarea' for long text, 'radio' for 2-6 choices, 'dropdown' for many choices, 'checkbox' for multiple selections, 'date' for date picker, 'time' for time picker, 'number' for numeric input"
|
|
39
|
-
},
|
|
40
|
-
label: {
|
|
41
|
-
type: "string",
|
|
42
|
-
description: "Field label shown to the user"
|
|
43
|
-
},
|
|
44
|
-
description: {
|
|
45
|
-
type: "string",
|
|
46
|
-
description: "Optional help text explaining the field"
|
|
47
|
-
},
|
|
48
|
-
required: {
|
|
49
|
-
type: "boolean",
|
|
50
|
-
description: "Whether the field is required (default: false)"
|
|
51
|
-
},
|
|
52
|
-
placeholder: {
|
|
53
|
-
type: "string",
|
|
54
|
-
description: "Placeholder text for text/textarea fields"
|
|
55
|
-
},
|
|
56
|
-
validation: {
|
|
57
|
-
type: "string",
|
|
58
|
-
description: "For text fields: 'email', 'url', 'phone', or a regex pattern"
|
|
59
|
-
},
|
|
60
|
-
minLength: {
|
|
61
|
-
type: "number",
|
|
62
|
-
description: "Minimum character length for textarea fields"
|
|
63
|
-
},
|
|
64
|
-
maxLength: {
|
|
65
|
-
type: "number",
|
|
66
|
-
description: "Maximum character length for textarea fields"
|
|
67
|
-
},
|
|
68
|
-
rows: {
|
|
69
|
-
type: "number",
|
|
70
|
-
description: "Number of visible rows for textarea (default: 4)"
|
|
71
|
-
},
|
|
72
|
-
choices: {
|
|
73
|
-
type: "array",
|
|
74
|
-
items: { type: "string" },
|
|
75
|
-
description: "Array of choices for radio/dropdown/checkbox fields. Radio should have 2-6 choices, dropdown for 7+ choices."
|
|
76
|
-
},
|
|
77
|
-
searchable: {
|
|
78
|
-
type: "boolean",
|
|
79
|
-
description: "Make dropdown searchable (for large lists)"
|
|
80
|
-
},
|
|
81
|
-
minSelections: {
|
|
82
|
-
type: "number",
|
|
83
|
-
description: "Minimum number of selections for checkbox fields"
|
|
84
|
-
},
|
|
85
|
-
maxSelections: {
|
|
86
|
-
type: "number",
|
|
87
|
-
description: "Maximum number of selections for checkbox fields"
|
|
88
|
-
},
|
|
89
|
-
minDate: {
|
|
90
|
-
type: "string",
|
|
91
|
-
description: "Minimum date (ISO format: YYYY-MM-DD)"
|
|
92
|
-
},
|
|
93
|
-
maxDate: {
|
|
94
|
-
type: "string",
|
|
95
|
-
description: "Maximum date (ISO format: YYYY-MM-DD)"
|
|
96
|
-
},
|
|
97
|
-
format: {
|
|
98
|
-
type: "string",
|
|
99
|
-
description: "Format for time fields: '12hr' or '24hr'"
|
|
100
|
-
},
|
|
101
|
-
min: {
|
|
102
|
-
type: "number",
|
|
103
|
-
description: "Minimum value for number fields"
|
|
104
|
-
},
|
|
105
|
-
max: {
|
|
106
|
-
type: "number",
|
|
107
|
-
description: "Maximum value for number fields"
|
|
108
|
-
},
|
|
109
|
-
step: {
|
|
110
|
-
type: "number",
|
|
111
|
-
description: "Step increment for number fields"
|
|
112
|
-
},
|
|
113
|
-
defaultValue: {
|
|
114
|
-
description: "Optional default/pre-filled value for the field. Type varies by field: string for text/textarea/radio/dropdown/date/time, number for number fields, array of strings for checkbox fields. For radio/dropdown, must be one of the choices. For checkbox, must be a subset of choices."
|
|
115
|
-
}
|
|
116
|
-
},
|
|
117
|
-
required: ["id", "type", "label"]
|
|
118
|
-
},
|
|
119
|
-
minItems: 1
|
|
120
|
-
}
|
|
121
|
-
},
|
|
122
|
-
required: ["fields"]
|
|
123
|
-
}
|
|
124
|
-
}, m = [
|
|
125
|
-
{
|
|
126
|
-
name: "Contact Form",
|
|
127
|
-
args: {
|
|
128
|
-
title: "Contact Us",
|
|
129
|
-
description: "Please fill out the form below to get in touch.",
|
|
130
|
-
fields: [
|
|
131
|
-
{
|
|
132
|
-
id: "name",
|
|
133
|
-
type: "text",
|
|
134
|
-
label: "Full Name",
|
|
135
|
-
required: !0,
|
|
136
|
-
placeholder: "John Doe"
|
|
137
|
-
},
|
|
138
|
-
{
|
|
139
|
-
id: "email",
|
|
140
|
-
type: "text",
|
|
141
|
-
label: "Email Address",
|
|
142
|
-
required: !0,
|
|
143
|
-
placeholder: "john@example.com",
|
|
144
|
-
validation: "email"
|
|
145
|
-
},
|
|
146
|
-
{
|
|
147
|
-
id: "subject",
|
|
148
|
-
type: "dropdown",
|
|
149
|
-
label: "Subject",
|
|
150
|
-
choices: [
|
|
151
|
-
"General Inquiry",
|
|
152
|
-
"Technical Support",
|
|
153
|
-
"Sales",
|
|
154
|
-
"Feedback"
|
|
155
|
-
],
|
|
156
|
-
required: !0
|
|
157
|
-
},
|
|
158
|
-
{
|
|
159
|
-
id: "message",
|
|
160
|
-
type: "textarea",
|
|
161
|
-
label: "Message",
|
|
162
|
-
required: !0,
|
|
163
|
-
minLength: 10,
|
|
164
|
-
maxLength: 500,
|
|
165
|
-
rows: 5
|
|
166
|
-
}
|
|
167
|
-
]
|
|
168
|
-
}
|
|
169
|
-
},
|
|
170
|
-
{
|
|
171
|
-
name: "Survey Form",
|
|
172
|
-
args: {
|
|
173
|
-
title: "Customer Satisfaction Survey",
|
|
174
|
-
fields: [
|
|
175
|
-
{
|
|
176
|
-
id: "satisfaction",
|
|
177
|
-
type: "radio",
|
|
178
|
-
label: "How satisfied are you with our service?",
|
|
179
|
-
choices: [
|
|
180
|
-
"Very Satisfied",
|
|
181
|
-
"Satisfied",
|
|
182
|
-
"Neutral",
|
|
183
|
-
"Dissatisfied",
|
|
184
|
-
"Very Dissatisfied"
|
|
185
|
-
],
|
|
186
|
-
required: !0
|
|
187
|
-
},
|
|
188
|
-
{
|
|
189
|
-
id: "features",
|
|
190
|
-
type: "checkbox",
|
|
191
|
-
label: "Which features do you use most?",
|
|
192
|
-
choices: [
|
|
193
|
-
"Dashboard",
|
|
194
|
-
"Reports",
|
|
195
|
-
"Analytics",
|
|
196
|
-
"API",
|
|
197
|
-
"Integrations"
|
|
198
|
-
],
|
|
199
|
-
minSelections: 1,
|
|
200
|
-
maxSelections: 3
|
|
201
|
-
},
|
|
202
|
-
{
|
|
203
|
-
id: "recommendation",
|
|
204
|
-
type: "number",
|
|
205
|
-
label: "How likely are you to recommend us? (0-10)",
|
|
206
|
-
min: 0,
|
|
207
|
-
max: 10,
|
|
208
|
-
step: 1
|
|
209
|
-
}
|
|
210
|
-
]
|
|
211
|
-
}
|
|
212
|
-
},
|
|
213
|
-
{
|
|
214
|
-
name: "Event Registration",
|
|
215
|
-
args: {
|
|
216
|
-
title: "Event Registration",
|
|
217
|
-
description: "Register for our upcoming conference.",
|
|
218
|
-
fields: [
|
|
219
|
-
{
|
|
220
|
-
id: "attendeeName",
|
|
221
|
-
type: "text",
|
|
222
|
-
label: "Attendee Name",
|
|
223
|
-
required: !0
|
|
224
|
-
},
|
|
225
|
-
{
|
|
226
|
-
id: "eventDate",
|
|
227
|
-
type: "date",
|
|
228
|
-
label: "Preferred Date",
|
|
229
|
-
required: !0,
|
|
230
|
-
minDate: "2025-01-01",
|
|
231
|
-
maxDate: "2025-12-31"
|
|
232
|
-
},
|
|
233
|
-
{
|
|
234
|
-
id: "sessionTime",
|
|
235
|
-
type: "time",
|
|
236
|
-
label: "Session Time",
|
|
237
|
-
format: "12hr"
|
|
238
|
-
},
|
|
239
|
-
{
|
|
240
|
-
id: "dietaryRestrictions",
|
|
241
|
-
type: "checkbox",
|
|
242
|
-
label: "Dietary Restrictions",
|
|
243
|
-
choices: ["Vegetarian", "Vegan", "Gluten-Free", "Halal", "Kosher"]
|
|
244
|
-
}
|
|
245
|
-
]
|
|
246
|
-
}
|
|
247
|
-
}
|
|
248
|
-
], h = async (p, n) => {
|
|
249
|
-
try {
|
|
250
|
-
const { title: i, description: s, fields: t } = n;
|
|
251
|
-
if (!t || !Array.isArray(t) || t.length === 0)
|
|
252
|
-
throw new Error("At least one field is required");
|
|
253
|
-
const o = /* @__PURE__ */ new Set();
|
|
254
|
-
for (let r = 0; r < t.length; r++) {
|
|
255
|
-
const e = t[r];
|
|
256
|
-
if (!e.id || typeof e.id != "string")
|
|
257
|
-
throw new Error(`Field ${r + 1} must have a valid 'id' property`);
|
|
258
|
-
if (!e.type || typeof e.type != "string")
|
|
259
|
-
throw new Error(`Field ${r + 1} must have a valid 'type' property`);
|
|
260
|
-
if (!e.label || typeof e.label != "string")
|
|
261
|
-
throw new Error(`Field ${r + 1} must have a valid 'label' property`);
|
|
262
|
-
if (o.has(e.id))
|
|
263
|
-
throw new Error(`Duplicate field ID: '${e.id}'`);
|
|
264
|
-
switch (o.add(e.id), e.type) {
|
|
265
|
-
case "text":
|
|
266
|
-
case "textarea":
|
|
267
|
-
if (e.minLength !== void 0 && e.maxLength !== void 0 && e.minLength > e.maxLength)
|
|
268
|
-
throw new Error(
|
|
269
|
-
`Field '${e.id}': minLength cannot be greater than maxLength`
|
|
270
|
-
);
|
|
271
|
-
break;
|
|
272
|
-
case "radio":
|
|
273
|
-
if (!Array.isArray(e.choices) || e.choices.length < 2)
|
|
274
|
-
throw new Error(
|
|
275
|
-
`Field '${e.id}': radio fields must have at least 2 choices`
|
|
276
|
-
);
|
|
277
|
-
e.choices.length > 6 && console.warn(
|
|
278
|
-
`Field '${e.id}': radio fields with more than 6 choices should use 'dropdown' type instead`
|
|
279
|
-
);
|
|
280
|
-
break;
|
|
281
|
-
case "dropdown":
|
|
282
|
-
case "checkbox":
|
|
283
|
-
if (!Array.isArray(e.choices) || e.choices.length < 1)
|
|
284
|
-
throw new Error(
|
|
285
|
-
`Field '${e.id}': ${e.type} fields must have at least 1 choice`
|
|
286
|
-
);
|
|
287
|
-
break;
|
|
288
|
-
case "number":
|
|
289
|
-
if (e.min !== void 0 && e.max !== void 0 && e.min > e.max)
|
|
290
|
-
throw new Error(
|
|
291
|
-
`Field '${e.id}': min cannot be greater than max`
|
|
292
|
-
);
|
|
293
|
-
break;
|
|
294
|
-
case "date":
|
|
295
|
-
if (e.minDate && e.maxDate && e.minDate > e.maxDate)
|
|
296
|
-
throw new Error(
|
|
297
|
-
`Field '${e.id}': minDate cannot be after maxDate`
|
|
298
|
-
);
|
|
299
|
-
break;
|
|
300
|
-
case "time":
|
|
301
|
-
break;
|
|
302
|
-
default: {
|
|
303
|
-
const a = e;
|
|
304
|
-
throw new Error(
|
|
305
|
-
`Field '${a.id}': unknown field type '${a.type}'`
|
|
306
|
-
);
|
|
307
|
-
}
|
|
308
|
-
}
|
|
309
|
-
if (e.type === "checkbox") {
|
|
310
|
-
if (e.minSelections !== void 0 && e.maxSelections !== void 0 && e.minSelections > e.maxSelections)
|
|
311
|
-
throw new Error(
|
|
312
|
-
`Field '${e.id}': minSelections cannot be greater than maxSelections`
|
|
313
|
-
);
|
|
314
|
-
if (e.maxSelections !== void 0 && e.maxSelections > e.choices.length)
|
|
315
|
-
throw new Error(
|
|
316
|
-
`Field '${e.id}': maxSelections cannot exceed number of choices`
|
|
317
|
-
);
|
|
318
|
-
}
|
|
319
|
-
if (e.defaultValue !== void 0)
|
|
320
|
-
switch (e.type) {
|
|
321
|
-
case "text":
|
|
322
|
-
case "textarea":
|
|
323
|
-
if (typeof e.defaultValue != "string")
|
|
324
|
-
throw new Error(
|
|
325
|
-
`Field '${e.id}': defaultValue must be a string`
|
|
326
|
-
);
|
|
327
|
-
if (e.minLength !== void 0 && e.defaultValue.length < e.minLength)
|
|
328
|
-
throw new Error(
|
|
329
|
-
`Field '${e.id}': defaultValue length is less than minLength`
|
|
330
|
-
);
|
|
331
|
-
if (e.maxLength !== void 0 && e.defaultValue.length > e.maxLength)
|
|
332
|
-
throw new Error(
|
|
333
|
-
`Field '${e.id}': defaultValue length exceeds maxLength`
|
|
334
|
-
);
|
|
335
|
-
break;
|
|
336
|
-
case "radio":
|
|
337
|
-
case "dropdown":
|
|
338
|
-
if (typeof e.defaultValue != "string")
|
|
339
|
-
throw new Error(
|
|
340
|
-
`Field '${e.id}': defaultValue must be a string`
|
|
341
|
-
);
|
|
342
|
-
if (!e.choices.includes(e.defaultValue))
|
|
343
|
-
throw new Error(
|
|
344
|
-
`Field '${e.id}': defaultValue '${e.defaultValue}' is not in choices`
|
|
345
|
-
);
|
|
346
|
-
break;
|
|
347
|
-
case "checkbox":
|
|
348
|
-
if (!Array.isArray(e.defaultValue))
|
|
349
|
-
throw new Error(
|
|
350
|
-
`Field '${e.id}': defaultValue must be an array`
|
|
351
|
-
);
|
|
352
|
-
for (const a of e.defaultValue)
|
|
353
|
-
if (!e.choices.includes(a))
|
|
354
|
-
throw new Error(
|
|
355
|
-
`Field '${e.id}': defaultValue contains '${a}' which is not in choices`
|
|
356
|
-
);
|
|
357
|
-
if (e.minSelections !== void 0 && e.defaultValue.length < e.minSelections)
|
|
358
|
-
throw new Error(
|
|
359
|
-
`Field '${e.id}': defaultValue has fewer selections than minSelections`
|
|
360
|
-
);
|
|
361
|
-
if (e.maxSelections !== void 0 && e.defaultValue.length > e.maxSelections)
|
|
362
|
-
throw new Error(
|
|
363
|
-
`Field '${e.id}': defaultValue has more selections than maxSelections`
|
|
364
|
-
);
|
|
365
|
-
break;
|
|
366
|
-
case "number":
|
|
367
|
-
if (typeof e.defaultValue != "number")
|
|
368
|
-
throw new Error(
|
|
369
|
-
`Field '${e.id}': defaultValue must be a number`
|
|
370
|
-
);
|
|
371
|
-
if (e.min !== void 0 && e.defaultValue < e.min)
|
|
372
|
-
throw new Error(
|
|
373
|
-
`Field '${e.id}': defaultValue is less than min`
|
|
374
|
-
);
|
|
375
|
-
if (e.max !== void 0 && e.defaultValue > e.max)
|
|
376
|
-
throw new Error(
|
|
377
|
-
`Field '${e.id}': defaultValue is greater than max`
|
|
378
|
-
);
|
|
379
|
-
break;
|
|
380
|
-
case "date":
|
|
381
|
-
if (typeof e.defaultValue != "string")
|
|
382
|
-
throw new Error(
|
|
383
|
-
`Field '${e.id}': defaultValue must be a string (ISO date format)`
|
|
384
|
-
);
|
|
385
|
-
if (e.minDate !== void 0 && e.defaultValue < e.minDate)
|
|
386
|
-
throw new Error(
|
|
387
|
-
`Field '${e.id}': defaultValue is before minDate`
|
|
388
|
-
);
|
|
389
|
-
if (e.maxDate !== void 0 && e.defaultValue > e.maxDate)
|
|
390
|
-
throw new Error(
|
|
391
|
-
`Field '${e.id}': defaultValue is after maxDate`
|
|
392
|
-
);
|
|
393
|
-
break;
|
|
394
|
-
case "time":
|
|
395
|
-
if (typeof e.defaultValue != "string")
|
|
396
|
-
throw new Error(
|
|
397
|
-
`Field '${e.id}': defaultValue must be a string`
|
|
398
|
-
);
|
|
399
|
-
break;
|
|
400
|
-
}
|
|
401
|
-
}
|
|
402
|
-
const l = {
|
|
403
|
-
title: i,
|
|
404
|
-
description: s,
|
|
405
|
-
fields: t
|
|
406
|
-
}, d = `${t.length} field${t.length > 1 ? "s" : ""}`, c = i ? `: ${i}` : "";
|
|
407
|
-
return {
|
|
408
|
-
message: `Form created with ${d}${c}`,
|
|
409
|
-
jsonData: l,
|
|
410
|
-
instructions: "The form has been presented to the user. Wait for the user to fill out and submit the form. They will send their responses as a JSON message."
|
|
411
|
-
};
|
|
412
|
-
} catch (i) {
|
|
413
|
-
return console.error(`ERR: exception
|
|
414
|
-
Form creation error`, i), {
|
|
415
|
-
message: `Form error: ${i instanceof Error ? i.message : "Unknown error"}`,
|
|
416
|
-
instructions: "Acknowledge that there was an error creating the form and suggest trying again with corrected field definitions."
|
|
417
|
-
};
|
|
418
|
-
}
|
|
419
|
-
}, b = {
|
|
420
|
-
toolDefinition: f,
|
|
421
|
-
execute: h,
|
|
422
|
-
generatingMessage: "Preparing form...",
|
|
423
|
-
isEnabled: () => !0,
|
|
424
|
-
samples: m
|
|
425
|
-
};
|
|
426
|
-
export {
|
|
427
|
-
m as SAMPLES,
|
|
428
|
-
f as TOOL_DEFINITION,
|
|
429
|
-
u as TOOL_NAME,
|
|
430
|
-
h as executeForm,
|
|
431
|
-
b as pluginCore
|
|
432
|
-
};
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./plugin-BgGi_Eou.js";
|
|
2
|
+
export { r as SAMPLES, t as TOOL_DEFINITION, e as TOOL_NAME, i as executeForm, n as pluginCore };
|
package/dist/index.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require(`./plugin-DbwkQIio.cjs`);require(`./core.cjs`),exports.SAMPLES=e.r,exports.TOOL_DEFINITION=e.i,exports.TOOL_NAME=e.a,exports.default=e.n,exports.pluginCore=e.n,exports.executeForm=e.t;
|
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
O as TOOL_DEFINITION,
|
|
5
|
-
u as TOOL_NAME,
|
|
6
|
-
l as default,
|
|
7
|
-
p as executeForm,
|
|
8
|
-
t as pluginCore
|
|
9
|
-
};
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./plugin-BgGi_Eou.js";
|
|
2
|
+
import "./core.js";
|
|
3
|
+
export { r as SAMPLES, t as TOOL_DEFINITION, e as TOOL_NAME, n as default, n as pluginCore, i as executeForm };
|