@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/vue.js
CHANGED
|
@@ -1,582 +1,518 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
},
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
import { a as e, i as t, n, r, t as i } from "./plugin-BgGi_Eou.js";
|
|
2
|
+
import { Fragment as a, computed as o, createCommentVNode as s, createElementBlock as c, createElementVNode as l, createTextVNode as u, defineComponent as d, normalizeClass as f, normalizeStyle as p, openBlock as m, ref as h, renderList as g, toDisplayString as _, vModelCheckbox as ee, vModelRadio as te, vModelSelect as v, vModelText as y, watch as b, withDirectives as x, withModifiers as S } from "vue";
|
|
3
|
+
//#region src/vue/View.vue?vue&type=script&setup=true&lang.ts
|
|
4
|
+
var ne = { class: "w-full h-full overflow-y-auto p-8" }, re = {
|
|
5
|
+
key: 0,
|
|
6
|
+
class: "max-w-3xl w-full mx-auto"
|
|
7
|
+
}, ie = {
|
|
8
|
+
key: 0,
|
|
9
|
+
class: "text-gray-900 text-3xl font-bold mb-4 text-center"
|
|
10
10
|
}, ae = {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
},
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
}, oe = { class: "text-red-700 space-y-1" }, se = ["href", "onClick"],
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
11
|
+
key: 1,
|
|
12
|
+
class: "text-gray-600 text-center mb-8 text-lg"
|
|
13
|
+
}, C = {
|
|
14
|
+
key: 2,
|
|
15
|
+
class: "bg-red-50 border-2 border-red-500 rounded-lg p-4 mb-6",
|
|
16
|
+
role: "alert"
|
|
17
|
+
}, oe = { class: "text-red-700 space-y-1" }, se = ["href", "onClick"], ce = ["id"], le = ["for"], ue = {
|
|
18
|
+
key: 0,
|
|
19
|
+
class: "text-red-500 ml-1",
|
|
20
|
+
"aria-label": "required"
|
|
21
21
|
}, de = {
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
},
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
},
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
},
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
const m = L.value?.userResponses || {}, U = h.filter((k) => {
|
|
520
|
-
const y = m[k.id];
|
|
521
|
-
return y == null ? !1 : typeof y == "string" ? y.trim() !== "" : Array.isArray(y) ? y.length > 0 : !0;
|
|
522
|
-
}).length;
|
|
523
|
-
return Math.round(U / h.length * 100);
|
|
524
|
-
});
|
|
525
|
-
return (h, m) => (u(), i("div", Fe, [
|
|
526
|
-
l("div", Ue, [
|
|
527
|
-
m[1] || (m[1] = l("svg", {
|
|
528
|
-
class: "w-12 h-12 mx-auto mb-3 text-blue-600",
|
|
529
|
-
fill: "none",
|
|
530
|
-
stroke: "currentColor",
|
|
531
|
-
viewBox: "0 0 24 24"
|
|
532
|
-
}, [
|
|
533
|
-
l("path", {
|
|
534
|
-
"stroke-linecap": "round",
|
|
535
|
-
"stroke-linejoin": "round",
|
|
536
|
-
"stroke-width": "2",
|
|
537
|
-
d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
538
|
-
})
|
|
539
|
-
], -1)),
|
|
540
|
-
l("h3", Ee, v(p.value?.title || "Form"), 1),
|
|
541
|
-
l("p", Re, v(d.value) + " field" + v(d.value !== 1 ? "s" : ""), 1),
|
|
542
|
-
o.value ? (u(), i("div", je, [...m[0] || (m[0] = [
|
|
543
|
-
l("svg", {
|
|
544
|
-
class: "w-3 h-3",
|
|
545
|
-
fill: "currentColor",
|
|
546
|
-
viewBox: "0 0 20 20"
|
|
547
|
-
}, [
|
|
548
|
-
l("path", {
|
|
549
|
-
"fill-rule": "evenodd",
|
|
550
|
-
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
551
|
-
"clip-rule": "evenodd"
|
|
552
|
-
})
|
|
553
|
-
], -1),
|
|
554
|
-
B(" Submitted ", -1)
|
|
555
|
-
])])) : (u(), i("div", qe, [
|
|
556
|
-
l("div", ze, [
|
|
557
|
-
l("div", {
|
|
558
|
-
class: "h-full bg-blue-600 transition-all duration-300",
|
|
559
|
-
style: Z({ width: `${n.value}%` })
|
|
560
|
-
}, null, 4)
|
|
561
|
-
]),
|
|
562
|
-
l("span", Ne, v(n.value) + "%", 1)
|
|
563
|
-
]))
|
|
564
|
-
])
|
|
565
|
-
]));
|
|
566
|
-
}
|
|
567
|
-
}), Ae = {
|
|
568
|
-
...K,
|
|
569
|
-
viewComponent: Me,
|
|
570
|
-
previewComponent: Pe
|
|
571
|
-
}, Te = { plugin: Ae };
|
|
572
|
-
export {
|
|
573
|
-
Pe as Preview,
|
|
574
|
-
We as SAMPLES,
|
|
575
|
-
Ge as TOOL_DEFINITION,
|
|
576
|
-
Ke as TOOL_NAME,
|
|
577
|
-
Me as View,
|
|
578
|
-
Te as default,
|
|
579
|
-
Qe as executeForm,
|
|
580
|
-
Ae as plugin,
|
|
581
|
-
K as pluginCore
|
|
582
|
-
};
|
|
22
|
+
key: 0,
|
|
23
|
+
class: "text-gray-600 text-sm mb-2"
|
|
24
|
+
}, fe = [
|
|
25
|
+
"id",
|
|
26
|
+
"onUpdate:modelValue",
|
|
27
|
+
"placeholder",
|
|
28
|
+
"aria-invalid",
|
|
29
|
+
"aria-describedby",
|
|
30
|
+
"onBlur",
|
|
31
|
+
"onInput"
|
|
32
|
+
], pe = [
|
|
33
|
+
"id",
|
|
34
|
+
"onUpdate:modelValue",
|
|
35
|
+
"placeholder",
|
|
36
|
+
"rows",
|
|
37
|
+
"aria-invalid",
|
|
38
|
+
"aria-describedby",
|
|
39
|
+
"onBlur",
|
|
40
|
+
"onInput"
|
|
41
|
+
], me = [
|
|
42
|
+
"id",
|
|
43
|
+
"onUpdate:modelValue",
|
|
44
|
+
"min",
|
|
45
|
+
"max",
|
|
46
|
+
"step",
|
|
47
|
+
"aria-invalid",
|
|
48
|
+
"aria-describedby",
|
|
49
|
+
"onBlur",
|
|
50
|
+
"onInput"
|
|
51
|
+
], he = [
|
|
52
|
+
"id",
|
|
53
|
+
"onUpdate:modelValue",
|
|
54
|
+
"min",
|
|
55
|
+
"max",
|
|
56
|
+
"aria-invalid",
|
|
57
|
+
"aria-describedby",
|
|
58
|
+
"onBlur",
|
|
59
|
+
"onChange"
|
|
60
|
+
], w = [
|
|
61
|
+
"id",
|
|
62
|
+
"onUpdate:modelValue",
|
|
63
|
+
"aria-invalid",
|
|
64
|
+
"aria-describedby",
|
|
65
|
+
"onBlur",
|
|
66
|
+
"onChange"
|
|
67
|
+
], T = ["aria-invalid", "aria-describedby"], E = [
|
|
68
|
+
"name",
|
|
69
|
+
"value",
|
|
70
|
+
"onUpdate:modelValue",
|
|
71
|
+
"onChange",
|
|
72
|
+
"onBlur"
|
|
73
|
+
], D = { class: "text-gray-800" }, O = [
|
|
74
|
+
"id",
|
|
75
|
+
"onUpdate:modelValue",
|
|
76
|
+
"aria-invalid",
|
|
77
|
+
"aria-describedby",
|
|
78
|
+
"onBlur",
|
|
79
|
+
"onChange"
|
|
80
|
+
], k = ["value"], A = ["aria-invalid", "aria-describedby"], j = [
|
|
81
|
+
"value",
|
|
82
|
+
"onUpdate:modelValue",
|
|
83
|
+
"onChange",
|
|
84
|
+
"onBlur"
|
|
85
|
+
], M = { class: "text-gray-800" }, N = ["id"], P = { key: 0 }, F = { class: "mt-8 flex justify-center" }, I = ["disabled"], L = { class: "mt-4 text-center text-gray-600 text-sm" }, R = /* @__PURE__ */ ((e, t) => {
|
|
86
|
+
let n = e.__vccOpts || e;
|
|
87
|
+
for (let [e, r] of t) n[e] = r;
|
|
88
|
+
return n;
|
|
89
|
+
})(/* @__PURE__ */ d({
|
|
90
|
+
__name: "View",
|
|
91
|
+
props: {
|
|
92
|
+
selectedResult: {},
|
|
93
|
+
sendTextMessage: { type: Function }
|
|
94
|
+
},
|
|
95
|
+
emits: ["updateResult"],
|
|
96
|
+
setup(e, { emit: t }) {
|
|
97
|
+
let n = e, r = t, i = h(null), d = h({}), p = h(/* @__PURE__ */ new Set()), R = h(/* @__PURE__ */ new Map()), z = h(!1), B = h(!1), V = h(!1);
|
|
98
|
+
b(() => n.selectedResult, (e, t) => {
|
|
99
|
+
if (e?.toolName === "presentForm" && e.jsonData && (!t || !t.jsonData || t.uuid !== e.uuid || t.jsonData !== e.jsonData)) {
|
|
100
|
+
if (V.value = !0, i.value = e.jsonData, d.value = {}, i.value.fields.forEach((e) => {
|
|
101
|
+
d.value[e.id] = H(e);
|
|
102
|
+
}), e.viewState) {
|
|
103
|
+
let t = e.viewState;
|
|
104
|
+
t.userResponses && Object.assign(d.value, t.userResponses), t.touched && (p.value = new Set(t.touched), t.touched.forEach((e) => {
|
|
105
|
+
J(e);
|
|
106
|
+
})), t.submitted !== void 0 && (z.value = t.submitted);
|
|
107
|
+
}
|
|
108
|
+
V.value = !1;
|
|
109
|
+
}
|
|
110
|
+
}, { immediate: !0 }), b([
|
|
111
|
+
d,
|
|
112
|
+
p,
|
|
113
|
+
z
|
|
114
|
+
], () => {
|
|
115
|
+
V.value || !n.selectedResult || r("updateResult", {
|
|
116
|
+
...n.selectedResult,
|
|
117
|
+
viewState: {
|
|
118
|
+
userResponses: { ...d.value },
|
|
119
|
+
touched: Array.from(p.value),
|
|
120
|
+
submitted: z.value
|
|
121
|
+
}
|
|
122
|
+
});
|
|
123
|
+
}, { deep: !0 });
|
|
124
|
+
function H(e) {
|
|
125
|
+
let t = e;
|
|
126
|
+
if (t.defaultValue !== void 0) switch (e.type) {
|
|
127
|
+
case "radio":
|
|
128
|
+
case "dropdown": {
|
|
129
|
+
let n = e.choices.indexOf(t.defaultValue);
|
|
130
|
+
return n === -1 ? null : n;
|
|
131
|
+
}
|
|
132
|
+
case "checkbox": return Array.isArray(t.defaultValue) ? t.defaultValue.map((t) => e.choices.indexOf(t)).filter((e) => e !== -1) : [];
|
|
133
|
+
default: return t.defaultValue;
|
|
134
|
+
}
|
|
135
|
+
switch (e.type) {
|
|
136
|
+
case "text":
|
|
137
|
+
case "textarea": return "";
|
|
138
|
+
case "number": return e.min === void 0 ? 0 : e.min;
|
|
139
|
+
case "date":
|
|
140
|
+
case "time": return "";
|
|
141
|
+
case "radio":
|
|
142
|
+
case "dropdown": return null;
|
|
143
|
+
case "checkbox": return [];
|
|
144
|
+
default: return null;
|
|
145
|
+
}
|
|
146
|
+
}
|
|
147
|
+
function U(e) {
|
|
148
|
+
return e == null ? !0 : typeof e == "string" ? e.trim() === "" : Array.isArray(e) ? e.length === 0 : !1;
|
|
149
|
+
}
|
|
150
|
+
function W(e) {
|
|
151
|
+
return /^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(e);
|
|
152
|
+
}
|
|
153
|
+
function G(e) {
|
|
154
|
+
try {
|
|
155
|
+
return new URL(e), !0;
|
|
156
|
+
} catch {
|
|
157
|
+
return !1;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
function K(e) {
|
|
161
|
+
return /^[\d\s\-+()]+$/.test(e) && e.replace(/\D/g, "").length >= 10;
|
|
162
|
+
}
|
|
163
|
+
function q(e, t) {
|
|
164
|
+
if (e.required && U(t)) return `${e.label} is required`;
|
|
165
|
+
if (U(t)) return null;
|
|
166
|
+
switch (e.type) {
|
|
167
|
+
case "text": {
|
|
168
|
+
let n = e;
|
|
169
|
+
if (n.validation === "email" && !W(t)) return "Please enter a valid email address";
|
|
170
|
+
if (n.validation === "url" && !G(t)) return "Please enter a valid URL";
|
|
171
|
+
if (n.validation === "phone" && !K(t)) return "Please enter a valid phone number";
|
|
172
|
+
if (typeof n.validation == "string" && n.validation !== "email" && n.validation !== "url" && n.validation !== "phone") try {
|
|
173
|
+
if (!new RegExp(n.validation).test(t)) return `${e.label} format is invalid`;
|
|
174
|
+
} catch {
|
|
175
|
+
console.warn(`Invalid regex pattern: ${n.validation}`);
|
|
176
|
+
}
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
179
|
+
case "textarea": {
|
|
180
|
+
let n = e;
|
|
181
|
+
if (n.minLength && t.length < n.minLength) return `Must be at least ${n.minLength} characters (currently ${t.length})`;
|
|
182
|
+
if (n.maxLength && t.length > n.maxLength) return `Must be no more than ${n.maxLength} characters (currently ${t.length})`;
|
|
183
|
+
break;
|
|
184
|
+
}
|
|
185
|
+
case "number": {
|
|
186
|
+
let n = e;
|
|
187
|
+
if (n.min !== void 0 && t < n.min) return `Must be at least ${n.min}`;
|
|
188
|
+
if (n.max !== void 0 && t > n.max) return `Must be no more than ${n.max}`;
|
|
189
|
+
break;
|
|
190
|
+
}
|
|
191
|
+
case "date": {
|
|
192
|
+
let n = e;
|
|
193
|
+
if (n.minDate && t < n.minDate) return `Date must be on or after ${n.minDate}`;
|
|
194
|
+
if (n.maxDate && t > n.maxDate) return `Date must be on or before ${n.maxDate}`;
|
|
195
|
+
break;
|
|
196
|
+
}
|
|
197
|
+
case "checkbox": {
|
|
198
|
+
let n = e, r = t?.length || 0;
|
|
199
|
+
if (n.minSelections && r < n.minSelections) return `Please select at least ${n.minSelections} option${n.minSelections > 1 ? "s" : ""}`;
|
|
200
|
+
if (n.maxSelections && r > n.maxSelections) return `Please select no more than ${n.maxSelections} option${n.maxSelections > 1 ? "s" : ""}`;
|
|
201
|
+
break;
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
return null;
|
|
205
|
+
}
|
|
206
|
+
function J(e) {
|
|
207
|
+
let t = i.value?.fields.find((t) => t.id === e);
|
|
208
|
+
if (!t) return !0;
|
|
209
|
+
let n = d.value[e], r = q(t, n);
|
|
210
|
+
return r ? (R.value.set(e, {
|
|
211
|
+
fieldId: e,
|
|
212
|
+
message: r,
|
|
213
|
+
type: "custom"
|
|
214
|
+
}), !1) : (R.value.delete(e), !0);
|
|
215
|
+
}
|
|
216
|
+
function Y(e) {
|
|
217
|
+
p.value.add(e), J(e);
|
|
218
|
+
}
|
|
219
|
+
function X(e) {
|
|
220
|
+
p.value.has(e) && J(e);
|
|
221
|
+
}
|
|
222
|
+
function Z(e) {
|
|
223
|
+
return R.value.has(e);
|
|
224
|
+
}
|
|
225
|
+
function Q(e) {
|
|
226
|
+
let t = document.getElementById(`input-${e}`);
|
|
227
|
+
t && (t.focus(), t.scrollIntoView({
|
|
228
|
+
behavior: "smooth",
|
|
229
|
+
block: "center"
|
|
230
|
+
}));
|
|
231
|
+
}
|
|
232
|
+
function ge(e) {
|
|
233
|
+
return (e.type === "text" || e.type === "textarea") && e.maxLength !== void 0;
|
|
234
|
+
}
|
|
235
|
+
function $(e) {
|
|
236
|
+
if (e.type !== "text" && e.type !== "textarea") return !1;
|
|
237
|
+
let t = e.maxLength;
|
|
238
|
+
return t ? (d.value[e.id] || "").length / t > .9 : !1;
|
|
239
|
+
}
|
|
240
|
+
let _e = o(() => i.value?.fields.filter((e) => e.required).length || 0), ve = o(() => i.value ? i.value.fields.filter((e) => e.required && !U(d.value[e.id])).length : 0);
|
|
241
|
+
function ye() {
|
|
242
|
+
if (z.value) return;
|
|
243
|
+
if (i.value?.fields.forEach((e) => {
|
|
244
|
+
p.value.add(e.id), J(e.id);
|
|
245
|
+
}), R.value.size > 0) {
|
|
246
|
+
B.value = !0;
|
|
247
|
+
let e = Array.from(R.value.keys())[0];
|
|
248
|
+
Q(e);
|
|
249
|
+
return;
|
|
250
|
+
}
|
|
251
|
+
let e = {};
|
|
252
|
+
i.value?.fields.forEach((t) => {
|
|
253
|
+
let n = d.value[t.id];
|
|
254
|
+
t.type === "radio" || t.type === "dropdown" ? n == null ? e[t.id] = null : e[t.id] = t.choices[n] : t.type === "checkbox" ? e[t.id] = (n || []).map((e) => t.choices[e]) : e[t.id] = n;
|
|
255
|
+
});
|
|
256
|
+
let t = JSON.stringify({ formSubmission: {
|
|
257
|
+
formTitle: i.value?.title || "Form",
|
|
258
|
+
responses: e
|
|
259
|
+
} }, null, 2);
|
|
260
|
+
z.value = !0, n.sendTextMessage(t);
|
|
261
|
+
}
|
|
262
|
+
return (e, t) => (m(), c("div", ne, [i.value ? (m(), c("div", re, [
|
|
263
|
+
i.value.title ? (m(), c("h2", ie, _(i.value.title), 1)) : s("", !0),
|
|
264
|
+
i.value.description ? (m(), c("p", ae, _(i.value.description), 1)) : s("", !0),
|
|
265
|
+
B.value && R.value.size > 0 ? (m(), c("div", C, [t[0] ||= l("h3", { class: "text-red-800 font-semibold mb-2 flex items-center gap-2" }, [l("svg", {
|
|
266
|
+
class: "w-5 h-5",
|
|
267
|
+
fill: "currentColor",
|
|
268
|
+
viewBox: "0 0 20 20",
|
|
269
|
+
"aria-hidden": "true"
|
|
270
|
+
}, [l("path", {
|
|
271
|
+
"fill-rule": "evenodd",
|
|
272
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
|
|
273
|
+
"clip-rule": "evenodd"
|
|
274
|
+
})]), u(" Please fix the following errors: ")], -1), l("ul", oe, [(m(!0), c(a, null, g(R.value, ([e, t]) => (m(), c("li", { key: e }, [l("a", {
|
|
275
|
+
href: `#${e}`,
|
|
276
|
+
onClick: S((t) => Q(e), ["prevent"]),
|
|
277
|
+
class: "hover:underline cursor-pointer"
|
|
278
|
+
}, _(t.message), 9, se)]))), 128))])])) : s("", !0),
|
|
279
|
+
l("form", {
|
|
280
|
+
onSubmit: S(ye, ["prevent"]),
|
|
281
|
+
class: "space-y-6"
|
|
282
|
+
}, [
|
|
283
|
+
(m(!0), c(a, null, g(i.value.fields, (e) => (m(), c("div", {
|
|
284
|
+
key: e.id,
|
|
285
|
+
id: e.id,
|
|
286
|
+
class: f(["form-field", { "has-error": Z(e.id) && p.value.has(e.id) }])
|
|
287
|
+
}, [
|
|
288
|
+
l("label", {
|
|
289
|
+
for: `input-${e.id}`,
|
|
290
|
+
class: f(["block text-gray-800 font-semibold mb-2", { "text-red-600": Z(e.id) && p.value.has(e.id) }])
|
|
291
|
+
}, [u(_(e.label) + " ", 1), e.required ? (m(), c("span", ue, "*")) : s("", !0)], 10, le),
|
|
292
|
+
e.description ? (m(), c("p", de, _(e.description), 1)) : s("", !0),
|
|
293
|
+
e.type === "text" ? x((m(), c("input", {
|
|
294
|
+
key: 1,
|
|
295
|
+
id: `input-${e.id}`,
|
|
296
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
297
|
+
type: "text",
|
|
298
|
+
placeholder: e.placeholder,
|
|
299
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
300
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
301
|
+
onBlur: (t) => Y(e.id),
|
|
302
|
+
onInput: (t) => X(e.id),
|
|
303
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors", {
|
|
304
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
305
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
306
|
+
}])
|
|
307
|
+
}, null, 42, fe)), [[y, d.value[e.id]]]) : e.type === "textarea" ? x((m(), c("textarea", {
|
|
308
|
+
key: 2,
|
|
309
|
+
id: `input-${e.id}`,
|
|
310
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
311
|
+
placeholder: e.placeholder,
|
|
312
|
+
rows: e.rows || 4,
|
|
313
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
314
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
315
|
+
onBlur: (t) => Y(e.id),
|
|
316
|
+
onInput: (t) => X(e.id),
|
|
317
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors resize-y", {
|
|
318
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
319
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
320
|
+
}])
|
|
321
|
+
}, null, 42, pe)), [[y, d.value[e.id]]]) : e.type === "number" ? x((m(), c("input", {
|
|
322
|
+
key: 3,
|
|
323
|
+
id: `input-${e.id}`,
|
|
324
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
325
|
+
type: "number",
|
|
326
|
+
min: e.min,
|
|
327
|
+
max: e.max,
|
|
328
|
+
step: e.step,
|
|
329
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
330
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
331
|
+
onBlur: (t) => Y(e.id),
|
|
332
|
+
onInput: (t) => X(e.id),
|
|
333
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors", {
|
|
334
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
335
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
336
|
+
}])
|
|
337
|
+
}, null, 42, me)), [[
|
|
338
|
+
y,
|
|
339
|
+
d.value[e.id],
|
|
340
|
+
void 0,
|
|
341
|
+
{ number: !0 }
|
|
342
|
+
]]) : e.type === "date" ? x((m(), c("input", {
|
|
343
|
+
key: 4,
|
|
344
|
+
id: `input-${e.id}`,
|
|
345
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
346
|
+
type: "date",
|
|
347
|
+
min: e.minDate,
|
|
348
|
+
max: e.maxDate,
|
|
349
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
350
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
351
|
+
onBlur: (t) => Y(e.id),
|
|
352
|
+
onChange: (t) => X(e.id),
|
|
353
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors", {
|
|
354
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
355
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
356
|
+
}])
|
|
357
|
+
}, null, 42, he)), [[y, d.value[e.id]]]) : e.type === "time" ? x((m(), c("input", {
|
|
358
|
+
key: 5,
|
|
359
|
+
id: `input-${e.id}`,
|
|
360
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
361
|
+
type: "time",
|
|
362
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
363
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
364
|
+
onBlur: (t) => Y(e.id),
|
|
365
|
+
onChange: (t) => X(e.id),
|
|
366
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors", {
|
|
367
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
368
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
369
|
+
}])
|
|
370
|
+
}, null, 42, w)), [[y, d.value[e.id]]]) : e.type === "radio" ? (m(), c("div", {
|
|
371
|
+
key: 6,
|
|
372
|
+
class: "space-y-2",
|
|
373
|
+
role: "radiogroup",
|
|
374
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
375
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0
|
|
376
|
+
}, [(m(!0), c(a, null, g(e.choices, (t, n) => (m(), c("label", {
|
|
377
|
+
key: n,
|
|
378
|
+
class: f(["flex items-center p-3 border-2 border-gray-300 rounded-lg cursor-pointer transition-all hover:bg-gray-50", {
|
|
379
|
+
"border-blue-500 bg-blue-50": d.value[e.id] === n,
|
|
380
|
+
"border-gray-300": d.value[e.id] !== n
|
|
381
|
+
}])
|
|
382
|
+
}, [x(l("input", {
|
|
383
|
+
type: "radio",
|
|
384
|
+
name: e.id,
|
|
385
|
+
value: n,
|
|
386
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
387
|
+
onChange: (t) => X(e.id),
|
|
388
|
+
onBlur: (t) => Y(e.id),
|
|
389
|
+
class: "mr-3 h-4 w-4 flex-shrink-0"
|
|
390
|
+
}, null, 40, E), [[te, d.value[e.id]]]), l("span", D, _(t), 1)], 2))), 128))], 8, T)) : e.type === "dropdown" ? x((m(), c("select", {
|
|
391
|
+
key: 7,
|
|
392
|
+
id: `input-${e.id}`,
|
|
393
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
394
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
395
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0,
|
|
396
|
+
onBlur: (t) => Y(e.id),
|
|
397
|
+
onChange: (t) => X(e.id),
|
|
398
|
+
class: f(["w-full px-4 py-2 border-2 border-gray-300 rounded-lg focus:outline-none focus:ring-2 focus:ring-blue-500 transition-colors bg-white", {
|
|
399
|
+
"border-red-500 focus:ring-red-500": Z(e.id) && p.value.has(e.id),
|
|
400
|
+
"border-gray-300": !Z(e.id) || !p.value.has(e.id)
|
|
401
|
+
}])
|
|
402
|
+
}, [t[1] ||= l("option", {
|
|
403
|
+
value: null,
|
|
404
|
+
disabled: ""
|
|
405
|
+
}, "Select an option...", -1), (m(!0), c(a, null, g(e.choices, (e, t) => (m(), c("option", {
|
|
406
|
+
key: t,
|
|
407
|
+
value: t
|
|
408
|
+
}, _(e), 9, k))), 128))], 42, O)), [[v, d.value[e.id]]]) : e.type === "checkbox" ? (m(), c("div", {
|
|
409
|
+
key: 8,
|
|
410
|
+
class: "space-y-2",
|
|
411
|
+
role: "group",
|
|
412
|
+
"aria-invalid": Z(e.id) && p.value.has(e.id),
|
|
413
|
+
"aria-describedby": Z(e.id) && p.value.has(e.id) ? `${e.id}-error` : void 0
|
|
414
|
+
}, [(m(!0), c(a, null, g(e.choices, (t, n) => (m(), c("label", {
|
|
415
|
+
key: n,
|
|
416
|
+
class: f(["flex items-center p-3 border-2 border-gray-300 rounded-lg cursor-pointer transition-all hover:bg-gray-50", {
|
|
417
|
+
"border-blue-500 bg-blue-50": (d.value[e.id] || []).includes(n),
|
|
418
|
+
"border-gray-300": !(d.value[e.id] || []).includes(n)
|
|
419
|
+
}])
|
|
420
|
+
}, [x(l("input", {
|
|
421
|
+
type: "checkbox",
|
|
422
|
+
value: n,
|
|
423
|
+
"onUpdate:modelValue": (t) => d.value[e.id] = t,
|
|
424
|
+
onChange: (t) => X(e.id),
|
|
425
|
+
onBlur: (t) => Y(e.id),
|
|
426
|
+
class: "mr-3 h-4 w-4 flex-shrink-0"
|
|
427
|
+
}, null, 40, j), [[ee, d.value[e.id]]]), l("span", M, _(t), 1)], 2))), 128))], 8, A)) : s("", !0),
|
|
428
|
+
Z(e.id) && p.value.has(e.id) ? (m(), c("div", {
|
|
429
|
+
key: 9,
|
|
430
|
+
id: `${e.id}-error`,
|
|
431
|
+
class: "flex items-center gap-2 mt-2 text-red-600 text-sm",
|
|
432
|
+
role: "alert"
|
|
433
|
+
}, [t[2] ||= l("svg", {
|
|
434
|
+
class: "w-4 h-4 flex-shrink-0",
|
|
435
|
+
fill: "currentColor",
|
|
436
|
+
viewBox: "0 0 20 20",
|
|
437
|
+
"aria-hidden": "true"
|
|
438
|
+
}, [l("path", {
|
|
439
|
+
"fill-rule": "evenodd",
|
|
440
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z",
|
|
441
|
+
"clip-rule": "evenodd"
|
|
442
|
+
})], -1), u(" " + _(R.value.get(e.id)?.message), 1)], 8, N)) : s("", !0),
|
|
443
|
+
ge(e) ? (m(), c("div", {
|
|
444
|
+
key: 10,
|
|
445
|
+
class: f(["text-sm mt-2", {
|
|
446
|
+
"text-amber-600 font-semibold": $(e),
|
|
447
|
+
"text-gray-500": !$(e)
|
|
448
|
+
}])
|
|
449
|
+
}, [
|
|
450
|
+
u(_((d.value[e.id] || "").length) + " ", 1),
|
|
451
|
+
e.maxLength ? (m(), c("span", P, " / " + _(e.maxLength), 1)) : s("", !0),
|
|
452
|
+
t[3] ||= u(" characters ", -1)
|
|
453
|
+
], 2)) : s("", !0)
|
|
454
|
+
], 10, ce))), 128)),
|
|
455
|
+
l("div", F, [l("button", {
|
|
456
|
+
type: "submit",
|
|
457
|
+
disabled: z.value,
|
|
458
|
+
class: f([z.value ? "bg-green-600 cursor-default" : "bg-blue-600 hover:bg-blue-700", "px-8 py-3 rounded-lg text-white font-semibold text-lg transition-colors"])
|
|
459
|
+
}, _(z.value ? "Submitted" : "Submit Form"), 11, I)]),
|
|
460
|
+
l("div", L, _(ve.value) + " / " + _(_e.value) + " required fields completed ", 1)
|
|
461
|
+
], 32)
|
|
462
|
+
])) : s("", !0)]));
|
|
463
|
+
}
|
|
464
|
+
}), [["__scopeId", "data-v-cd2c3f48"]]), z = { class: "w-full h-full flex flex-col items-center justify-center p-4 bg-gradient-to-br from-blue-50 to-indigo-50 rounded-lg border-2 border-gray-200" }, B = { class: "text-center" }, V = { class: "text-gray-900 font-bold text-lg mb-1 line-clamp-2" }, H = { class: "text-gray-600 text-sm mb-2" }, U = {
|
|
465
|
+
key: 0,
|
|
466
|
+
class: "flex items-center justify-center gap-2"
|
|
467
|
+
}, W = { class: "w-32 h-2 bg-gray-200 rounded-full overflow-hidden" }, G = { class: "text-xs text-gray-500" }, K = {
|
|
468
|
+
key: 1,
|
|
469
|
+
class: "inline-flex items-center gap-1 px-3 py-1 bg-green-100 text-green-700 rounded-full text-xs font-semibold"
|
|
470
|
+
}, q = /* @__PURE__ */ d({
|
|
471
|
+
__name: "Preview",
|
|
472
|
+
props: { result: {} },
|
|
473
|
+
setup(e) {
|
|
474
|
+
let t = e, n = o(() => t.result?.toolName === "presentForm" ? t.result.jsonData : null), r = o(() => t.result?.viewState || null), i = o(() => n.value?.fields.length || 0), a = o(() => r.value?.submitted || !1), s = o(() => {
|
|
475
|
+
if (!n.value || a.value) return 100;
|
|
476
|
+
let e = n.value.fields.filter((e) => e.required);
|
|
477
|
+
if (e.length === 0) return 0;
|
|
478
|
+
let t = r.value?.userResponses || {}, i = e.filter((e) => {
|
|
479
|
+
let n = t[e.id];
|
|
480
|
+
return n == null ? !1 : typeof n == "string" ? n.trim() !== "" : Array.isArray(n) ? n.length > 0 : !0;
|
|
481
|
+
}).length;
|
|
482
|
+
return Math.round(i / e.length * 100);
|
|
483
|
+
});
|
|
484
|
+
return (e, t) => (m(), c("div", z, [l("div", B, [
|
|
485
|
+
t[1] ||= l("svg", {
|
|
486
|
+
class: "w-12 h-12 mx-auto mb-3 text-blue-600",
|
|
487
|
+
fill: "none",
|
|
488
|
+
stroke: "currentColor",
|
|
489
|
+
viewBox: "0 0 24 24"
|
|
490
|
+
}, [l("path", {
|
|
491
|
+
"stroke-linecap": "round",
|
|
492
|
+
"stroke-linejoin": "round",
|
|
493
|
+
"stroke-width": "2",
|
|
494
|
+
d: "M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"
|
|
495
|
+
})], -1),
|
|
496
|
+
l("h3", V, _(n.value?.title || "Form"), 1),
|
|
497
|
+
l("p", H, _(i.value) + " field" + _(i.value === 1 ? "" : "s"), 1),
|
|
498
|
+
a.value ? (m(), c("div", K, [...t[0] ||= [l("svg", {
|
|
499
|
+
class: "w-3 h-3",
|
|
500
|
+
fill: "currentColor",
|
|
501
|
+
viewBox: "0 0 20 20"
|
|
502
|
+
}, [l("path", {
|
|
503
|
+
"fill-rule": "evenodd",
|
|
504
|
+
d: "M10 18a8 8 0 100-16 8 8 0 000 16zm3.707-9.293a1 1 0 00-1.414-1.414L9 10.586 7.707 9.293a1 1 0 00-1.414 1.414l2 2a1 1 0 001.414 0l4-4z",
|
|
505
|
+
"clip-rule": "evenodd"
|
|
506
|
+
})], -1), u(" Submitted ", -1)]])) : (m(), c("div", U, [l("div", W, [l("div", {
|
|
507
|
+
class: "h-full bg-blue-600 transition-all duration-300",
|
|
508
|
+
style: p({ width: `${s.value}%` })
|
|
509
|
+
}, null, 4)]), l("span", G, _(s.value) + "%", 1)]))
|
|
510
|
+
])]));
|
|
511
|
+
}
|
|
512
|
+
}), J = {
|
|
513
|
+
...n,
|
|
514
|
+
viewComponent: R,
|
|
515
|
+
previewComponent: q
|
|
516
|
+
}, Y = { plugin: J };
|
|
517
|
+
//#endregion
|
|
518
|
+
export { q as Preview, r as SAMPLES, t as TOOL_DEFINITION, e as TOOL_NAME, R as View, Y as default, i as executeForm, J as plugin, n as pluginCore };
|