@object-ui/plugin-form 3.1.3 → 3.1.4
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/.turbo/turbo-build.log +24 -13
- package/CHANGELOG.md +10 -0
- package/dist/index.js +1977 -1859
- package/dist/index.umd.cjs +2 -2
- package/package.json +10 -10
package/dist/index.js
CHANGED
|
@@ -1,1870 +1,1988 @@
|
|
|
1
|
-
import
|
|
2
|
-
import { ComponentRegistry as
|
|
3
|
-
import {
|
|
4
|
-
import { buildValidationRules as
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
|
|
8
|
-
var
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
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
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
697
|
-
|
|
698
|
-
|
|
699
|
-
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
if (typeof a == "object")
|
|
738
|
-
n.push(a);
|
|
739
|
-
else if (o?.fields?.[s]) {
|
|
740
|
-
const c = o.fields[s];
|
|
741
|
-
n.push({
|
|
742
|
-
name: s,
|
|
743
|
-
label: b(e.objectName, s, c.label || s),
|
|
744
|
-
type: X(c.type),
|
|
745
|
-
required: c.required || !1,
|
|
746
|
-
disabled: e.readOnly || e.mode === "view" || c.readonly,
|
|
747
|
-
placeholder: c.placeholder,
|
|
748
|
-
description: c.help || c.description,
|
|
749
|
-
validation: B(c),
|
|
750
|
-
field: c,
|
|
751
|
-
options: c.options,
|
|
752
|
-
multiple: c.multiple
|
|
753
|
-
});
|
|
754
|
-
} else
|
|
755
|
-
n.push({
|
|
756
|
-
name: s,
|
|
757
|
-
label: s,
|
|
758
|
-
type: "input"
|
|
759
|
-
});
|
|
760
|
-
}
|
|
761
|
-
return n;
|
|
762
|
-
}, [o, e.readOnly, e.mode]), h = A(async (f) => {
|
|
763
|
-
if (!r)
|
|
764
|
-
return e.onSuccess && await e.onSuccess(f), f;
|
|
765
|
-
try {
|
|
766
|
-
let n;
|
|
767
|
-
return e.mode === "create" ? n = await r.create(e.objectName, f) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, f)), e.onSuccess && await e.onSuccess(n), n;
|
|
768
|
-
} catch (n) {
|
|
769
|
-
throw e.onError && e.onError(n), n;
|
|
770
|
-
}
|
|
771
|
-
}, [e, r]), v = A(() => {
|
|
772
|
-
e.onCancel && e.onCancel();
|
|
773
|
-
}, [e]), D = G(() => e.sections.slice(0, 1), [e.sections]), z = G(() => e.sections.slice(1), [e.sections]);
|
|
774
|
-
G(
|
|
775
|
-
() => e.sections.flatMap((f) => j(f)),
|
|
776
|
-
[e.sections, j]
|
|
777
|
-
);
|
|
778
|
-
const L = e.splitDirection || "horizontal", k = e.splitSize || 50;
|
|
779
|
-
if (F)
|
|
780
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "p-4 border border-red-300 bg-red-50 rounded-md", children: [
|
|
781
|
-
/* @__PURE__ */ t.jsx("h3", { className: "text-red-800 font-semibold", children: "Error loading form" }),
|
|
782
|
-
/* @__PURE__ */ t.jsx("p", { className: "text-red-600 text-sm mt-1", children: F.message })
|
|
783
|
-
] });
|
|
784
|
-
if (I)
|
|
785
|
-
return /* @__PURE__ */ t.jsxs("div", { className: "p-8 text-center", children: [
|
|
786
|
-
/* @__PURE__ */ t.jsx("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }),
|
|
787
|
-
/* @__PURE__ */ t.jsx("p", { className: "mt-2 text-sm text-gray-600", children: "Loading form..." })
|
|
788
|
-
] });
|
|
789
|
-
const U = {
|
|
790
|
-
type: "form",
|
|
791
|
-
layout: "vertical",
|
|
792
|
-
defaultValues: x,
|
|
793
|
-
onSubmit: h,
|
|
794
|
-
onCancel: v
|
|
795
|
-
}, M = (f, n) => /* @__PURE__ */ t.jsx("div", { className: "space-y-4 p-4", children: f.map((a, s) => /* @__PURE__ */ t.jsx(
|
|
796
|
-
te,
|
|
797
|
-
{
|
|
798
|
-
label: a.label,
|
|
799
|
-
description: a.description,
|
|
800
|
-
columns: a.columns || 1,
|
|
801
|
-
children: /* @__PURE__ */ t.jsx(
|
|
802
|
-
J,
|
|
803
|
-
{
|
|
804
|
-
schema: {
|
|
805
|
-
...U,
|
|
806
|
-
fields: j(a),
|
|
807
|
-
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
808
|
-
showCancel: n && e.showCancel !== !1,
|
|
809
|
-
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
810
|
-
cancelLabel: e.cancelText
|
|
811
|
-
}
|
|
812
|
-
}
|
|
813
|
-
)
|
|
814
|
-
},
|
|
815
|
-
a.name || a.label || s
|
|
816
|
-
)) });
|
|
817
|
-
return /* @__PURE__ */ t.jsx("div", { className: W("w-full", i, e.className), children: /* @__PURE__ */ t.jsxs(Pe, { orientation: L, className: "min-h-[300px] rounded-lg border", children: [
|
|
818
|
-
/* @__PURE__ */ t.jsx(be, { defaultSize: k, minSize: 20, children: M(D, z.length === 0) }),
|
|
819
|
-
z.length > 0 && /* @__PURE__ */ t.jsxs(t.Fragment, { children: [
|
|
820
|
-
/* @__PURE__ */ t.jsx(Ae, { withHandle: e.splitResizable !== !1 }),
|
|
821
|
-
/* @__PURE__ */ t.jsx(be, { defaultSize: 100 - k, minSize: 20, children: M(z, !0) })
|
|
822
|
-
] })
|
|
823
|
-
] }) });
|
|
824
|
-
}, nt = /* @__PURE__ */ new Set([
|
|
825
|
-
"field:textarea",
|
|
826
|
-
"field:markdown",
|
|
827
|
-
"field:html",
|
|
828
|
-
"field:grid",
|
|
829
|
-
"field:rich-text",
|
|
830
|
-
"textarea",
|
|
831
|
-
"markdown",
|
|
832
|
-
"html",
|
|
833
|
-
"grid",
|
|
834
|
-
"rich-text"
|
|
835
|
-
]), it = /* @__PURE__ */ new Set([
|
|
836
|
-
"formula",
|
|
837
|
-
"summary",
|
|
838
|
-
"auto_number",
|
|
839
|
-
"autonumber"
|
|
1
|
+
import e, { useCallback as t, useEffect as n, useId as r, useMemo as i, useState as a } from "react";
|
|
2
|
+
import { ComponentRegistry as o } from "@object-ui/core";
|
|
3
|
+
import { SchemaRenderer as s, useSafeFieldLabel as c } from "@object-ui/react";
|
|
4
|
+
import { buildValidationRules as l, evaluateCondition as u, formatFileSize as d, mapFieldTypeToFormType as f } from "@object-ui/fields";
|
|
5
|
+
import { Button as p, Card as m, CardContent as h, CardDescription as g, CardHeader as _, CardTitle as v, Dialog as y, DialogDescription as b, DialogHeader as x, DialogTitle as S, MobileDialogContent as C, ResizableHandle as w, ResizablePanel as T, ResizablePanelGroup as E, Sheet as D, SheetContent as O, SheetDescription as k, SheetHeader as A, SheetTitle as j, Skeleton as M, Tabs as N, TabsContent as P, TabsList as F, TabsTrigger as I, cn as L } from "@object-ui/components";
|
|
6
|
+
import { Check as R, ChevronDown as z, ChevronLeft as B, ChevronRight as V, Loader2 as ee } from "lucide-react";
|
|
7
|
+
//#region \0rolldown/runtime.js
|
|
8
|
+
var H = (e, t) => () => (t || e((t = { exports: {} }).exports, t), t.exports), U = /* @__PURE__ */ ((e) => typeof require < "u" ? require : typeof Proxy < "u" ? new Proxy(e, { get: (e, t) => (typeof require < "u" ? require : e)[t] }) : e)(function(e) {
|
|
9
|
+
if (typeof require < "u") return require.apply(this, arguments);
|
|
10
|
+
throw Error("Calling `require` for \"" + e + "\" in an environment that doesn't expose the `require` function. See https://rolldown.rs/in-depth/bundling-cjs#require-external-modules for more details.");
|
|
11
|
+
}), W = /* @__PURE__ */ H(((e) => {
|
|
12
|
+
var t = Symbol.for("react.transitional.element"), n = Symbol.for("react.fragment");
|
|
13
|
+
function r(e, n, r) {
|
|
14
|
+
var i = null;
|
|
15
|
+
if (r !== void 0 && (i = "" + r), n.key !== void 0 && (i = "" + n.key), "key" in n) for (var a in r = {}, n) a !== "key" && (r[a] = n[a]);
|
|
16
|
+
else r = n;
|
|
17
|
+
return n = r.ref, {
|
|
18
|
+
$$typeof: t,
|
|
19
|
+
type: e,
|
|
20
|
+
key: i,
|
|
21
|
+
ref: n === void 0 ? null : n,
|
|
22
|
+
props: r
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
e.Fragment = n, e.jsx = r, e.jsxs = r;
|
|
26
|
+
})), G = /* @__PURE__ */ H(((e) => {
|
|
27
|
+
process.env.NODE_ENV !== "production" && (function() {
|
|
28
|
+
function t(e) {
|
|
29
|
+
if (e == null) return null;
|
|
30
|
+
if (typeof e == "function") return e.$$typeof === O ? null : e.displayName || e.name || null;
|
|
31
|
+
if (typeof e == "string") return e;
|
|
32
|
+
switch (e) {
|
|
33
|
+
case _: return "Fragment";
|
|
34
|
+
case y: return "Profiler";
|
|
35
|
+
case v: return "StrictMode";
|
|
36
|
+
case C: return "Suspense";
|
|
37
|
+
case w: return "SuspenseList";
|
|
38
|
+
case D: return "Activity";
|
|
39
|
+
}
|
|
40
|
+
if (typeof e == "object") switch (typeof e.tag == "number" && console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."), e.$$typeof) {
|
|
41
|
+
case g: return "Portal";
|
|
42
|
+
case x: return e.displayName || "Context";
|
|
43
|
+
case b: return (e._context.displayName || "Context") + ".Consumer";
|
|
44
|
+
case S:
|
|
45
|
+
var n = e.render;
|
|
46
|
+
return e = e.displayName, e ||= (e = n.displayName || n.name || "", e === "" ? "ForwardRef" : "ForwardRef(" + e + ")"), e;
|
|
47
|
+
case T: return n = e.displayName || null, n === null ? t(e.type) || "Memo" : n;
|
|
48
|
+
case E:
|
|
49
|
+
n = e._payload, e = e._init;
|
|
50
|
+
try {
|
|
51
|
+
return t(e(n));
|
|
52
|
+
} catch {}
|
|
53
|
+
}
|
|
54
|
+
return null;
|
|
55
|
+
}
|
|
56
|
+
function n(e) {
|
|
57
|
+
return "" + e;
|
|
58
|
+
}
|
|
59
|
+
function r(e) {
|
|
60
|
+
try {
|
|
61
|
+
n(e);
|
|
62
|
+
var t = !1;
|
|
63
|
+
} catch {
|
|
64
|
+
t = !0;
|
|
65
|
+
}
|
|
66
|
+
if (t) {
|
|
67
|
+
t = console;
|
|
68
|
+
var r = t.error, i = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
69
|
+
return r.call(t, "The provided key is an unsupported type %s. This value must be coerced to a string before using it here.", i), n(e);
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
function i(e) {
|
|
73
|
+
if (e === _) return "<>";
|
|
74
|
+
if (typeof e == "object" && e && e.$$typeof === E) return "<...>";
|
|
75
|
+
try {
|
|
76
|
+
var n = t(e);
|
|
77
|
+
return n ? "<" + n + ">" : "<...>";
|
|
78
|
+
} catch {
|
|
79
|
+
return "<...>";
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
function a() {
|
|
83
|
+
var e = k.A;
|
|
84
|
+
return e === null ? null : e.getOwner();
|
|
85
|
+
}
|
|
86
|
+
function o() {
|
|
87
|
+
return Error("react-stack-top-frame");
|
|
88
|
+
}
|
|
89
|
+
function s(e) {
|
|
90
|
+
if (A.call(e, "key")) {
|
|
91
|
+
var t = Object.getOwnPropertyDescriptor(e, "key").get;
|
|
92
|
+
if (t && t.isReactWarning) return !1;
|
|
93
|
+
}
|
|
94
|
+
return e.key !== void 0;
|
|
95
|
+
}
|
|
96
|
+
function c(e, t) {
|
|
97
|
+
function n() {
|
|
98
|
+
N || (N = !0, console.error("%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)", t));
|
|
99
|
+
}
|
|
100
|
+
n.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
101
|
+
get: n,
|
|
102
|
+
configurable: !0
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
function l() {
|
|
106
|
+
var e = t(this.type);
|
|
107
|
+
return P[e] || (P[e] = !0, console.error("Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release.")), e = this.props.ref, e === void 0 ? null : e;
|
|
108
|
+
}
|
|
109
|
+
function u(e, t, n, r, i, a) {
|
|
110
|
+
var o = n.ref;
|
|
111
|
+
return e = {
|
|
112
|
+
$$typeof: h,
|
|
113
|
+
type: e,
|
|
114
|
+
key: t,
|
|
115
|
+
props: n,
|
|
116
|
+
_owner: r
|
|
117
|
+
}, (o === void 0 ? null : o) === null ? Object.defineProperty(e, "ref", {
|
|
118
|
+
enumerable: !1,
|
|
119
|
+
value: null
|
|
120
|
+
}) : Object.defineProperty(e, "ref", {
|
|
121
|
+
enumerable: !1,
|
|
122
|
+
get: l
|
|
123
|
+
}), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
124
|
+
configurable: !1,
|
|
125
|
+
enumerable: !1,
|
|
126
|
+
writable: !0,
|
|
127
|
+
value: 0
|
|
128
|
+
}), Object.defineProperty(e, "_debugInfo", {
|
|
129
|
+
configurable: !1,
|
|
130
|
+
enumerable: !1,
|
|
131
|
+
writable: !0,
|
|
132
|
+
value: null
|
|
133
|
+
}), Object.defineProperty(e, "_debugStack", {
|
|
134
|
+
configurable: !1,
|
|
135
|
+
enumerable: !1,
|
|
136
|
+
writable: !0,
|
|
137
|
+
value: i
|
|
138
|
+
}), Object.defineProperty(e, "_debugTask", {
|
|
139
|
+
configurable: !1,
|
|
140
|
+
enumerable: !1,
|
|
141
|
+
writable: !0,
|
|
142
|
+
value: a
|
|
143
|
+
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
144
|
+
}
|
|
145
|
+
function d(e, n, i, o, l, d) {
|
|
146
|
+
var p = n.children;
|
|
147
|
+
if (p !== void 0) if (o) if (j(p)) {
|
|
148
|
+
for (o = 0; o < p.length; o++) f(p[o]);
|
|
149
|
+
Object.freeze && Object.freeze(p);
|
|
150
|
+
} else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");
|
|
151
|
+
else f(p);
|
|
152
|
+
if (A.call(n, "key")) {
|
|
153
|
+
p = t(e);
|
|
154
|
+
var m = Object.keys(n).filter(function(e) {
|
|
155
|
+
return e !== "key";
|
|
156
|
+
});
|
|
157
|
+
o = 0 < m.length ? "{key: someKey, " + m.join(": ..., ") + ": ...}" : "{key: someKey}", L[p + o] || (m = 0 < m.length ? "{" + m.join(": ..., ") + ": ...}" : "{}", console.error("A props object containing a \"key\" prop is being spread into JSX:\n let props = %s;\n <%s {...props} />\nReact keys must be passed directly to JSX without using spread:\n let props = %s;\n <%s key={someKey} {...props} />", o, p, m, p), L[p + o] = !0);
|
|
158
|
+
}
|
|
159
|
+
if (p = null, i !== void 0 && (r(i), p = "" + i), s(n) && (r(n.key), p = "" + n.key), "key" in n) for (var h in i = {}, n) h !== "key" && (i[h] = n[h]);
|
|
160
|
+
else i = n;
|
|
161
|
+
return p && c(i, typeof e == "function" ? e.displayName || e.name || "Unknown" : e), u(e, p, i, a(), l, d);
|
|
162
|
+
}
|
|
163
|
+
function f(e) {
|
|
164
|
+
p(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e && e.$$typeof === E && (e._payload.status === "fulfilled" ? p(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
165
|
+
}
|
|
166
|
+
function p(e) {
|
|
167
|
+
return typeof e == "object" && !!e && e.$$typeof === h;
|
|
168
|
+
}
|
|
169
|
+
var m = U("react"), h = Symbol.for("react.transitional.element"), g = Symbol.for("react.portal"), _ = Symbol.for("react.fragment"), v = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), b = Symbol.for("react.consumer"), x = Symbol.for("react.context"), S = Symbol.for("react.forward_ref"), C = Symbol.for("react.suspense"), w = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), E = Symbol.for("react.lazy"), D = Symbol.for("react.activity"), O = Symbol.for("react.client.reference"), k = m.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, A = Object.prototype.hasOwnProperty, j = Array.isArray, M = console.createTask ? console.createTask : function() {
|
|
170
|
+
return null;
|
|
171
|
+
};
|
|
172
|
+
m = { react_stack_bottom_frame: function(e) {
|
|
173
|
+
return e();
|
|
174
|
+
} };
|
|
175
|
+
var N, P = {}, F = m.react_stack_bottom_frame.bind(m, o)(), I = M(i(o)), L = {};
|
|
176
|
+
e.Fragment = _, e.jsx = function(e, t, n) {
|
|
177
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
178
|
+
return d(e, t, n, !1, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
|
|
179
|
+
}, e.jsxs = function(e, t, n) {
|
|
180
|
+
var r = 1e4 > k.recentlyCreatedOwnerStacks++;
|
|
181
|
+
return d(e, t, n, !0, r ? Error("react-stack-top-frame") : F, r ? M(i(e)) : I);
|
|
182
|
+
};
|
|
183
|
+
})();
|
|
184
|
+
})), K = (/* @__PURE__ */ H(((e, t) => {
|
|
185
|
+
process.env.NODE_ENV === "production" ? t.exports = W() : t.exports = G();
|
|
186
|
+
})))(), q = ({ label: e, description: t, collapsible: n = !1, collapsed: r = !1, columns: i = 1, children: o, className: s, gridClassName: c }) => {
|
|
187
|
+
let [l, u] = a(r), d = {
|
|
188
|
+
1: "grid-cols-1",
|
|
189
|
+
2: "grid-cols-1 md:grid-cols-2",
|
|
190
|
+
3: "grid-cols-1 md:grid-cols-2 lg:grid-cols-3",
|
|
191
|
+
4: "grid-cols-1 md:grid-cols-2 lg:grid-cols-4"
|
|
192
|
+
};
|
|
193
|
+
return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
194
|
+
className: L("form-section", s),
|
|
195
|
+
children: [(e || t) && /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
196
|
+
className: L("flex items-start gap-2 mb-4", n && "cursor-pointer select-none"),
|
|
197
|
+
onClick: () => {
|
|
198
|
+
n && u(!l);
|
|
199
|
+
},
|
|
200
|
+
role: n ? "button" : void 0,
|
|
201
|
+
"aria-expanded": n ? !l : void 0,
|
|
202
|
+
children: [n && /* @__PURE__ */ (0, K.jsx)("span", {
|
|
203
|
+
className: "mt-0.5 text-muted-foreground",
|
|
204
|
+
children: l ? /* @__PURE__ */ (0, K.jsx)(V, { className: "h-4 w-4" }) : /* @__PURE__ */ (0, K.jsx)(z, { className: "h-4 w-4" })
|
|
205
|
+
}), /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
206
|
+
className: "flex-1",
|
|
207
|
+
children: [e && /* @__PURE__ */ (0, K.jsx)("h3", {
|
|
208
|
+
className: "text-base font-semibold text-foreground",
|
|
209
|
+
children: e
|
|
210
|
+
}), t && /* @__PURE__ */ (0, K.jsx)("p", {
|
|
211
|
+
className: "text-sm text-muted-foreground mt-0.5",
|
|
212
|
+
children: t
|
|
213
|
+
})]
|
|
214
|
+
})]
|
|
215
|
+
}), !l && /* @__PURE__ */ (0, K.jsx)("div", {
|
|
216
|
+
className: L("grid gap-4", c || d[i]),
|
|
217
|
+
children: o
|
|
218
|
+
})]
|
|
219
|
+
});
|
|
220
|
+
}, J = ({ schema: n, dataSource: r, className: i }) => {
|
|
221
|
+
let { fieldLabel: o } = c(), [u, d] = a(null), [p, m] = a({}), [h, g] = a(!0), [_, v] = a(null), [y, b] = a(n.defaultTab || n.sections[0]?.name || n.sections[0]?.label || "tab-0");
|
|
222
|
+
e.useEffect(() => {
|
|
223
|
+
(async () => {
|
|
224
|
+
if (!r) {
|
|
225
|
+
g(!1);
|
|
226
|
+
return;
|
|
227
|
+
}
|
|
228
|
+
try {
|
|
229
|
+
d(await r.getObjectSchema(n.objectName));
|
|
230
|
+
} catch (e) {
|
|
231
|
+
v(e);
|
|
232
|
+
}
|
|
233
|
+
})();
|
|
234
|
+
}, [n.objectName, r]), e.useEffect(() => {
|
|
235
|
+
(u || !r) && (async () => {
|
|
236
|
+
if (n.mode === "create" || !n.recordId || !r) {
|
|
237
|
+
m(n.initialData || n.initialValues || {}), g(!1);
|
|
238
|
+
return;
|
|
239
|
+
}
|
|
240
|
+
try {
|
|
241
|
+
m(await r.findOne(n.objectName, n.recordId) || {});
|
|
242
|
+
} catch (e) {
|
|
243
|
+
v(e);
|
|
244
|
+
} finally {
|
|
245
|
+
g(!1);
|
|
246
|
+
}
|
|
247
|
+
})();
|
|
248
|
+
}, [
|
|
249
|
+
u,
|
|
250
|
+
n.mode,
|
|
251
|
+
n.recordId,
|
|
252
|
+
n.initialData,
|
|
253
|
+
n.initialValues,
|
|
254
|
+
r,
|
|
255
|
+
n.objectName
|
|
256
|
+
]);
|
|
257
|
+
let x = t((e) => {
|
|
258
|
+
let t = [];
|
|
259
|
+
for (let r of e.fields) {
|
|
260
|
+
let e = typeof r == "string" ? r : r.name;
|
|
261
|
+
if (typeof r == "object") t.push(r);
|
|
262
|
+
else if (u?.fields?.[e]) {
|
|
263
|
+
let r = u.fields[e];
|
|
264
|
+
t.push({
|
|
265
|
+
name: e,
|
|
266
|
+
label: o(n.objectName, e, r.label || e),
|
|
267
|
+
type: f(r.type),
|
|
268
|
+
required: r.required || !1,
|
|
269
|
+
disabled: n.readOnly || n.mode === "view" || r.readonly,
|
|
270
|
+
placeholder: r.placeholder,
|
|
271
|
+
description: r.help || r.description,
|
|
272
|
+
validation: l(r),
|
|
273
|
+
field: r,
|
|
274
|
+
options: r.options,
|
|
275
|
+
multiple: r.multiple
|
|
276
|
+
});
|
|
277
|
+
} else t.push({
|
|
278
|
+
name: e,
|
|
279
|
+
label: e,
|
|
280
|
+
type: "input"
|
|
281
|
+
});
|
|
282
|
+
}
|
|
283
|
+
return t;
|
|
284
|
+
}, [
|
|
285
|
+
u,
|
|
286
|
+
n.readOnly,
|
|
287
|
+
n.mode
|
|
288
|
+
]), S = t(async (e) => {
|
|
289
|
+
if (!r) return n.onSuccess && await n.onSuccess(e), e;
|
|
290
|
+
try {
|
|
291
|
+
let t;
|
|
292
|
+
return n.mode === "create" ? t = await r.create(n.objectName, e) : n.mode === "edit" && n.recordId && (t = await r.update(n.objectName, n.recordId, e)), n.onSuccess && await n.onSuccess(t), t;
|
|
293
|
+
} catch (e) {
|
|
294
|
+
throw n.onError && n.onError(e), e;
|
|
295
|
+
}
|
|
296
|
+
}, [n, r]), C = t(() => {
|
|
297
|
+
n.onCancel && n.onCancel();
|
|
298
|
+
}, [n]), w = (e, t) => e.name || e.label || `tab-${t}`;
|
|
299
|
+
if (_) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
300
|
+
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
301
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
302
|
+
className: "text-red-800 font-semibold",
|
|
303
|
+
children: "Error loading form"
|
|
304
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
305
|
+
className: "text-red-600 text-sm mt-1",
|
|
306
|
+
children: _.message
|
|
307
|
+
})]
|
|
308
|
+
});
|
|
309
|
+
if (h) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
310
|
+
className: "p-8 text-center",
|
|
311
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
312
|
+
className: "mt-2 text-sm text-gray-600",
|
|
313
|
+
children: "Loading form..."
|
|
314
|
+
})]
|
|
315
|
+
});
|
|
316
|
+
let T = {
|
|
317
|
+
type: "form",
|
|
318
|
+
fields: n.sections.flatMap((e) => x(e)),
|
|
319
|
+
layout: "vertical",
|
|
320
|
+
defaultValues: p,
|
|
321
|
+
submitLabel: n.submitText || (n.mode === "create" ? "Create" : "Update"),
|
|
322
|
+
cancelLabel: n.cancelText,
|
|
323
|
+
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
324
|
+
showCancel: n.showCancel !== !1,
|
|
325
|
+
onSubmit: S,
|
|
326
|
+
onCancel: C
|
|
327
|
+
}, E = n.tabPosition === "left" || n.tabPosition === "right";
|
|
328
|
+
return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
329
|
+
className: L("w-full", i, n.className),
|
|
330
|
+
children: /* @__PURE__ */ (0, K.jsxs)(N, {
|
|
331
|
+
value: y,
|
|
332
|
+
onValueChange: b,
|
|
333
|
+
orientation: E ? "vertical" : "horizontal",
|
|
334
|
+
className: L(E && "flex gap-4"),
|
|
335
|
+
children: [/* @__PURE__ */ (0, K.jsx)(F, {
|
|
336
|
+
className: L(E ? "flex-col h-auto" : "", n.tabPosition === "bottom" && "order-last", n.tabPosition === "right" && "order-last"),
|
|
337
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ (0, K.jsx)(I, {
|
|
338
|
+
value: w(e, t),
|
|
339
|
+
className: E ? "w-full justify-start" : "",
|
|
340
|
+
children: e.label || `Tab ${t + 1}`
|
|
341
|
+
}, w(e, t)))
|
|
342
|
+
}), /* @__PURE__ */ (0, K.jsx)("div", {
|
|
343
|
+
className: "flex-1",
|
|
344
|
+
children: n.sections.map((e, t) => /* @__PURE__ */ (0, K.jsx)(P, {
|
|
345
|
+
value: w(e, t),
|
|
346
|
+
className: "mt-0",
|
|
347
|
+
children: /* @__PURE__ */ (0, K.jsx)(q, {
|
|
348
|
+
description: e.description,
|
|
349
|
+
columns: e.columns || 1,
|
|
350
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
351
|
+
...T,
|
|
352
|
+
fields: x(e),
|
|
353
|
+
showSubmit: n.showSubmit !== !1 && n.mode !== "view",
|
|
354
|
+
showCancel: n.showCancel !== !1
|
|
355
|
+
} })
|
|
356
|
+
})
|
|
357
|
+
}, w(e, t)))
|
|
358
|
+
})]
|
|
359
|
+
})
|
|
360
|
+
});
|
|
361
|
+
}, Y = ({ schema: n, dataSource: r, className: o }) => {
|
|
362
|
+
let { fieldLabel: u } = c(), [d, m] = a(null), [h, g] = a({}), [_, v] = a(!0), [y, b] = a(null), [x, S] = a(0), [C, w] = a(/* @__PURE__ */ new Set()), [T, E] = a(!1), D = n.sections.length, O = x === 0, k = x === D - 1;
|
|
363
|
+
e.useEffect(() => {
|
|
364
|
+
(async () => {
|
|
365
|
+
if (!r) {
|
|
366
|
+
v(!1);
|
|
367
|
+
return;
|
|
368
|
+
}
|
|
369
|
+
try {
|
|
370
|
+
m(await r.getObjectSchema(n.objectName));
|
|
371
|
+
} catch (e) {
|
|
372
|
+
b(e);
|
|
373
|
+
}
|
|
374
|
+
})();
|
|
375
|
+
}, [n.objectName, r]), e.useEffect(() => {
|
|
376
|
+
(d || !r) && (async () => {
|
|
377
|
+
if (n.mode === "create" || !n.recordId || !r) {
|
|
378
|
+
g(n.initialData || n.initialValues || {}), v(!1);
|
|
379
|
+
return;
|
|
380
|
+
}
|
|
381
|
+
try {
|
|
382
|
+
g(await r.findOne(n.objectName, n.recordId) || {});
|
|
383
|
+
} catch (e) {
|
|
384
|
+
b(e);
|
|
385
|
+
} finally {
|
|
386
|
+
v(!1);
|
|
387
|
+
}
|
|
388
|
+
})();
|
|
389
|
+
}, [
|
|
390
|
+
d,
|
|
391
|
+
n.mode,
|
|
392
|
+
n.recordId,
|
|
393
|
+
n.initialData,
|
|
394
|
+
n.initialValues,
|
|
395
|
+
r,
|
|
396
|
+
n.objectName
|
|
397
|
+
]);
|
|
398
|
+
let A = t((e) => {
|
|
399
|
+
let t = [];
|
|
400
|
+
for (let r of e.fields) {
|
|
401
|
+
let e = typeof r == "string" ? r : r.name;
|
|
402
|
+
if (typeof r == "object") t.push(r);
|
|
403
|
+
else if (d?.fields?.[e]) {
|
|
404
|
+
let r = d.fields[e];
|
|
405
|
+
t.push({
|
|
406
|
+
name: e,
|
|
407
|
+
label: u(n.objectName, e, r.label || e),
|
|
408
|
+
type: f(r.type),
|
|
409
|
+
required: r.required || !1,
|
|
410
|
+
disabled: n.readOnly || n.mode === "view" || r.readonly,
|
|
411
|
+
placeholder: r.placeholder,
|
|
412
|
+
description: r.help || r.description,
|
|
413
|
+
validation: l(r),
|
|
414
|
+
field: r,
|
|
415
|
+
options: r.options,
|
|
416
|
+
multiple: r.multiple
|
|
417
|
+
});
|
|
418
|
+
} else t.push({
|
|
419
|
+
name: e,
|
|
420
|
+
label: e,
|
|
421
|
+
type: "input"
|
|
422
|
+
});
|
|
423
|
+
}
|
|
424
|
+
return t;
|
|
425
|
+
}, [
|
|
426
|
+
d,
|
|
427
|
+
n.readOnly,
|
|
428
|
+
n.mode
|
|
429
|
+
]), j = i(() => x >= 0 && x < D ? A(n.sections[x]) : [], [
|
|
430
|
+
x,
|
|
431
|
+
D,
|
|
432
|
+
n.sections,
|
|
433
|
+
A
|
|
434
|
+
]), M = t(async (e) => {
|
|
435
|
+
let t = {
|
|
436
|
+
...h,
|
|
437
|
+
...e
|
|
438
|
+
};
|
|
439
|
+
if (g(t), w((e) => new Set(e).add(x)), k) {
|
|
440
|
+
E(!0);
|
|
441
|
+
try {
|
|
442
|
+
if (!r) return n.onSuccess && await n.onSuccess(t), t;
|
|
443
|
+
let e;
|
|
444
|
+
return n.mode === "create" ? e = await r.create(n.objectName, t) : n.mode === "edit" && n.recordId && (e = await r.update(n.objectName, n.recordId, t)), n.onSuccess && await n.onSuccess(e), e;
|
|
445
|
+
} catch (e) {
|
|
446
|
+
throw n.onError && n.onError(e), e;
|
|
447
|
+
} finally {
|
|
448
|
+
E(!1);
|
|
449
|
+
}
|
|
450
|
+
} else N(x + 1);
|
|
451
|
+
}, [
|
|
452
|
+
h,
|
|
453
|
+
x,
|
|
454
|
+
k,
|
|
455
|
+
n,
|
|
456
|
+
r
|
|
457
|
+
]), N = t((e) => {
|
|
458
|
+
e >= 0 && e < D && (S(e), n.onStepChange && n.onStepChange(e));
|
|
459
|
+
}, [D, n]), P = t(() => {
|
|
460
|
+
N(x - 1);
|
|
461
|
+
}, [x, N]), F = t(() => {
|
|
462
|
+
n.onCancel && n.onCancel();
|
|
463
|
+
}, [n]), I = t((e) => {
|
|
464
|
+
(n.allowSkip || C.has(e) || e <= x) && N(e);
|
|
465
|
+
}, [
|
|
466
|
+
n.allowSkip,
|
|
467
|
+
C,
|
|
468
|
+
x,
|
|
469
|
+
N
|
|
470
|
+
]);
|
|
471
|
+
if (y) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
472
|
+
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
473
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
474
|
+
className: "text-red-800 font-semibold",
|
|
475
|
+
children: "Error loading form"
|
|
476
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
477
|
+
className: "text-red-600 text-sm mt-1",
|
|
478
|
+
children: y.message
|
|
479
|
+
})]
|
|
480
|
+
});
|
|
481
|
+
if (_) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
482
|
+
className: "p-8 text-center",
|
|
483
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
484
|
+
className: "mt-2 text-sm text-gray-600",
|
|
485
|
+
children: "Loading form..."
|
|
486
|
+
})]
|
|
487
|
+
});
|
|
488
|
+
let z = n.sections[x];
|
|
489
|
+
return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
490
|
+
className: L("w-full", o, n.className),
|
|
491
|
+
children: [
|
|
492
|
+
n.showStepIndicator !== !1 && /* @__PURE__ */ (0, K.jsx)("nav", {
|
|
493
|
+
"aria-label": "Progress",
|
|
494
|
+
className: "mb-8",
|
|
495
|
+
children: /* @__PURE__ */ (0, K.jsx)("ol", {
|
|
496
|
+
className: "flex items-center",
|
|
497
|
+
children: n.sections.map((e, t) => {
|
|
498
|
+
let r = t === x, i = C.has(t), a = n.allowSkip || i || t <= x;
|
|
499
|
+
return /* @__PURE__ */ (0, K.jsxs)("li", {
|
|
500
|
+
className: L("relative flex-1", t !== D - 1 && "pr-8 sm:pr-12"),
|
|
501
|
+
children: [t !== D - 1 && /* @__PURE__ */ (0, K.jsx)("div", {
|
|
502
|
+
className: "absolute top-3 sm:top-4 left-6 -right-4 sm:left-10 sm:-right-2 h-0.5",
|
|
503
|
+
"aria-hidden": "true",
|
|
504
|
+
children: /* @__PURE__ */ (0, K.jsx)("div", { className: L("h-full", i ? "bg-primary" : "bg-muted") })
|
|
505
|
+
}), /* @__PURE__ */ (0, K.jsxs)("button", {
|
|
506
|
+
type: "button",
|
|
507
|
+
className: L("group relative flex items-center", a ? "cursor-pointer" : "cursor-not-allowed"),
|
|
508
|
+
onClick: () => I(t),
|
|
509
|
+
disabled: !a,
|
|
510
|
+
children: [/* @__PURE__ */ (0, K.jsx)("span", {
|
|
511
|
+
className: L("flex h-6 w-6 sm:h-8 sm:w-8 items-center justify-center rounded-full text-xs sm:text-sm font-medium transition-colors", i && "bg-primary text-primary-foreground", r && !i && "border-2 border-primary bg-background text-primary", !r && !i && "border-2 border-muted bg-background text-muted-foreground"),
|
|
512
|
+
children: i ? /* @__PURE__ */ (0, K.jsx)(R, { className: "h-3 w-3 sm:h-4 sm:w-4" }) : t + 1
|
|
513
|
+
}), /* @__PURE__ */ (0, K.jsx)("span", {
|
|
514
|
+
className: "ml-2 sm:ml-3 text-xs sm:text-sm font-medium hidden sm:block",
|
|
515
|
+
children: /* @__PURE__ */ (0, K.jsx)("span", {
|
|
516
|
+
className: L(r ? "text-foreground" : "text-muted-foreground"),
|
|
517
|
+
children: e.label || `Step ${t + 1}`
|
|
518
|
+
})
|
|
519
|
+
})]
|
|
520
|
+
})]
|
|
521
|
+
}, t);
|
|
522
|
+
})
|
|
523
|
+
})
|
|
524
|
+
}),
|
|
525
|
+
/* @__PURE__ */ (0, K.jsx)("div", {
|
|
526
|
+
className: "min-h-[200px]",
|
|
527
|
+
children: z && /* @__PURE__ */ (0, K.jsx)(q, {
|
|
528
|
+
label: z.label,
|
|
529
|
+
description: z.description,
|
|
530
|
+
columns: z.columns || 1,
|
|
531
|
+
children: j.length > 0 ? /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
532
|
+
type: "form",
|
|
533
|
+
fields: j,
|
|
534
|
+
layout: "vertical",
|
|
535
|
+
defaultValues: h,
|
|
536
|
+
showSubmit: !1,
|
|
537
|
+
showCancel: !1,
|
|
538
|
+
onSubmit: M
|
|
539
|
+
} }) : /* @__PURE__ */ (0, K.jsx)("div", {
|
|
540
|
+
className: "text-center py-8 text-muted-foreground",
|
|
541
|
+
children: "No fields configured for this step"
|
|
542
|
+
})
|
|
543
|
+
})
|
|
544
|
+
}),
|
|
545
|
+
/* @__PURE__ */ (0, K.jsxs)("div", {
|
|
546
|
+
className: "flex items-center justify-between mt-6 pt-4 border-t",
|
|
547
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { children: n.showCancel !== !1 && /* @__PURE__ */ (0, K.jsx)(p, {
|
|
548
|
+
variant: "ghost",
|
|
549
|
+
onClick: F,
|
|
550
|
+
children: n.cancelText || "Cancel"
|
|
551
|
+
}) }), /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
552
|
+
className: "flex items-center gap-2",
|
|
553
|
+
children: [
|
|
554
|
+
/* @__PURE__ */ (0, K.jsxs)("span", {
|
|
555
|
+
className: "text-sm text-muted-foreground mr-2",
|
|
556
|
+
children: [
|
|
557
|
+
"Step ",
|
|
558
|
+
x + 1,
|
|
559
|
+
" of ",
|
|
560
|
+
D
|
|
561
|
+
]
|
|
562
|
+
}),
|
|
563
|
+
!O && /* @__PURE__ */ (0, K.jsxs)(p, {
|
|
564
|
+
variant: "outline",
|
|
565
|
+
onClick: P,
|
|
566
|
+
children: [/* @__PURE__ */ (0, K.jsx)(B, { className: "h-4 w-4 mr-1" }), n.prevText || "Back"]
|
|
567
|
+
}),
|
|
568
|
+
k ? /* @__PURE__ */ (0, K.jsx)(p, {
|
|
569
|
+
onClick: () => M(h),
|
|
570
|
+
disabled: T || n.mode === "view",
|
|
571
|
+
children: T ? "Submitting..." : n.submitText || (n.mode === "create" ? "Create" : "Update")
|
|
572
|
+
}) : /* @__PURE__ */ (0, K.jsxs)(p, {
|
|
573
|
+
onClick: () => M(h),
|
|
574
|
+
children: [n.nextText || "Next", /* @__PURE__ */ (0, K.jsx)(V, { className: "h-4 w-4 ml-1" })]
|
|
575
|
+
})
|
|
576
|
+
]
|
|
577
|
+
})]
|
|
578
|
+
})
|
|
579
|
+
]
|
|
580
|
+
});
|
|
581
|
+
}, te = ({ schema: e, dataSource: r, className: o }) => {
|
|
582
|
+
let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a({}), [g, _] = a(!0), [v, y] = a(null);
|
|
583
|
+
n(() => {
|
|
584
|
+
(async () => {
|
|
585
|
+
if (!r) {
|
|
586
|
+
_(!1);
|
|
587
|
+
return;
|
|
588
|
+
}
|
|
589
|
+
try {
|
|
590
|
+
p(await r.getObjectSchema(e.objectName));
|
|
591
|
+
} catch (e) {
|
|
592
|
+
y(e), _(!1);
|
|
593
|
+
}
|
|
594
|
+
})();
|
|
595
|
+
}, [e.objectName, r]), n(() => {
|
|
596
|
+
(d || !r) && (async () => {
|
|
597
|
+
if (e.mode === "create" || !e.recordId) {
|
|
598
|
+
h(e.initialData || e.initialValues || {}), _(!1);
|
|
599
|
+
return;
|
|
600
|
+
}
|
|
601
|
+
if (!r) {
|
|
602
|
+
h(e.initialData || e.initialValues || {}), _(!1);
|
|
603
|
+
return;
|
|
604
|
+
}
|
|
605
|
+
try {
|
|
606
|
+
h(await r.findOne(e.objectName, e.recordId) || {});
|
|
607
|
+
} catch (e) {
|
|
608
|
+
y(e);
|
|
609
|
+
} finally {
|
|
610
|
+
_(!1);
|
|
611
|
+
}
|
|
612
|
+
})();
|
|
613
|
+
}, [
|
|
614
|
+
d,
|
|
615
|
+
e.mode,
|
|
616
|
+
e.recordId,
|
|
617
|
+
e.initialData,
|
|
618
|
+
e.initialValues,
|
|
619
|
+
r,
|
|
620
|
+
e.objectName
|
|
621
|
+
]);
|
|
622
|
+
let b = t((t) => {
|
|
623
|
+
let n = [];
|
|
624
|
+
for (let r of t.fields) {
|
|
625
|
+
let t = typeof r == "string" ? r : r.name;
|
|
626
|
+
if (typeof r == "object") n.push(r);
|
|
627
|
+
else if (d?.fields?.[t]) {
|
|
628
|
+
let r = d.fields[t];
|
|
629
|
+
n.push({
|
|
630
|
+
name: t,
|
|
631
|
+
label: u(e.objectName, t, r.label || t),
|
|
632
|
+
type: f(r.type),
|
|
633
|
+
required: r.required || !1,
|
|
634
|
+
disabled: e.readOnly || e.mode === "view" || r.readonly,
|
|
635
|
+
placeholder: r.placeholder,
|
|
636
|
+
description: r.help || r.description,
|
|
637
|
+
validation: l(r),
|
|
638
|
+
field: r,
|
|
639
|
+
options: r.options,
|
|
640
|
+
multiple: r.multiple
|
|
641
|
+
});
|
|
642
|
+
} else n.push({
|
|
643
|
+
name: t,
|
|
644
|
+
label: t,
|
|
645
|
+
type: "input"
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
return n;
|
|
649
|
+
}, [
|
|
650
|
+
d,
|
|
651
|
+
e.readOnly,
|
|
652
|
+
e.mode
|
|
653
|
+
]), x = t(async (t) => {
|
|
654
|
+
if (!r) return e.onSuccess && await e.onSuccess(t), t;
|
|
655
|
+
try {
|
|
656
|
+
let n;
|
|
657
|
+
return e.mode === "create" ? n = await r.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), n;
|
|
658
|
+
} catch (t) {
|
|
659
|
+
throw e.onError && e.onError(t), t;
|
|
660
|
+
}
|
|
661
|
+
}, [e, r]), S = t(() => {
|
|
662
|
+
e.onCancel && e.onCancel();
|
|
663
|
+
}, [e]), C = i(() => e.sections.slice(0, 1), [e.sections]), D = i(() => e.sections.slice(1), [e.sections]);
|
|
664
|
+
i(() => e.sections.flatMap((e) => b(e)), [e.sections, b]);
|
|
665
|
+
let O = e.splitDirection || "horizontal", k = e.splitSize || 50;
|
|
666
|
+
if (v) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
667
|
+
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
668
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
669
|
+
className: "text-red-800 font-semibold",
|
|
670
|
+
children: "Error loading form"
|
|
671
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
672
|
+
className: "text-red-600 text-sm mt-1",
|
|
673
|
+
children: v.message
|
|
674
|
+
})]
|
|
675
|
+
});
|
|
676
|
+
if (g) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
677
|
+
className: "p-8 text-center",
|
|
678
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
679
|
+
className: "mt-2 text-sm text-gray-600",
|
|
680
|
+
children: "Loading form..."
|
|
681
|
+
})]
|
|
682
|
+
});
|
|
683
|
+
let A = {
|
|
684
|
+
type: "form",
|
|
685
|
+
layout: "vertical",
|
|
686
|
+
defaultValues: m,
|
|
687
|
+
onSubmit: x,
|
|
688
|
+
onCancel: S
|
|
689
|
+
}, j = (t, n) => /* @__PURE__ */ (0, K.jsx)("div", {
|
|
690
|
+
className: "space-y-4 p-4",
|
|
691
|
+
children: t.map((t, r) => /* @__PURE__ */ (0, K.jsx)(q, {
|
|
692
|
+
label: t.label,
|
|
693
|
+
description: t.description,
|
|
694
|
+
columns: t.columns || 1,
|
|
695
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
696
|
+
...A,
|
|
697
|
+
fields: b(t),
|
|
698
|
+
showSubmit: n && e.showSubmit !== !1 && e.mode !== "view",
|
|
699
|
+
showCancel: n && e.showCancel !== !1,
|
|
700
|
+
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
701
|
+
cancelLabel: e.cancelText
|
|
702
|
+
} })
|
|
703
|
+
}, t.name || t.label || r))
|
|
704
|
+
});
|
|
705
|
+
return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
706
|
+
className: L("w-full", o, e.className),
|
|
707
|
+
children: /* @__PURE__ */ (0, K.jsxs)(E, {
|
|
708
|
+
orientation: O,
|
|
709
|
+
className: "min-h-[300px] rounded-lg border",
|
|
710
|
+
children: [/* @__PURE__ */ (0, K.jsx)(T, {
|
|
711
|
+
defaultSize: k,
|
|
712
|
+
minSize: 20,
|
|
713
|
+
children: j(C, D.length === 0)
|
|
714
|
+
}), D.length > 0 && /* @__PURE__ */ (0, K.jsxs)(K.Fragment, { children: [/* @__PURE__ */ (0, K.jsx)(w, { withHandle: e.splitResizable !== !1 }), /* @__PURE__ */ (0, K.jsx)(T, {
|
|
715
|
+
defaultSize: 100 - k,
|
|
716
|
+
minSize: 20,
|
|
717
|
+
children: j(D, !0)
|
|
718
|
+
})] })]
|
|
719
|
+
})
|
|
720
|
+
});
|
|
721
|
+
}, ne = new Set([
|
|
722
|
+
"field:textarea",
|
|
723
|
+
"field:markdown",
|
|
724
|
+
"field:html",
|
|
725
|
+
"field:grid",
|
|
726
|
+
"field:rich-text",
|
|
727
|
+
"textarea",
|
|
728
|
+
"markdown",
|
|
729
|
+
"html",
|
|
730
|
+
"grid",
|
|
731
|
+
"rich-text"
|
|
732
|
+
]), re = new Set([
|
|
733
|
+
"formula",
|
|
734
|
+
"summary",
|
|
735
|
+
"auto_number",
|
|
736
|
+
"autonumber"
|
|
840
737
|
]);
|
|
841
|
-
function
|
|
842
|
-
|
|
738
|
+
function ie(e) {
|
|
739
|
+
return ne.has(e);
|
|
843
740
|
}
|
|
844
|
-
function
|
|
845
|
-
|
|
741
|
+
function ae(e) {
|
|
742
|
+
return re.has(e);
|
|
846
743
|
}
|
|
847
|
-
function
|
|
848
|
-
|
|
744
|
+
function oe(e) {
|
|
745
|
+
return e <= 3 ? 1 : 2;
|
|
849
746
|
}
|
|
850
|
-
function
|
|
851
|
-
|
|
747
|
+
function X(e, t) {
|
|
748
|
+
return t <= 1 ? e : e.map((e) => e.colSpan === void 0 && e.type && ie(e.type) ? {
|
|
749
|
+
...e,
|
|
750
|
+
colSpan: t
|
|
751
|
+
} : e);
|
|
852
752
|
}
|
|
853
|
-
function
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
753
|
+
function se(e, t) {
|
|
754
|
+
return t?.fields ? e.filter((e) => {
|
|
755
|
+
let n = t.fields[e.name];
|
|
756
|
+
return n ? !ae(n.type) : !0;
|
|
757
|
+
}) : e;
|
|
858
758
|
}
|
|
859
|
-
function
|
|
860
|
-
|
|
759
|
+
function Z(e) {
|
|
760
|
+
return e <= 1 ? "default" : e === 2 ? "xl" : "full";
|
|
861
761
|
}
|
|
862
|
-
function
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
762
|
+
function Q(e, t, n, r) {
|
|
763
|
+
let i = [...e];
|
|
764
|
+
if (r === "create" && (i = se(i, t)), n !== void 0) return i = X(i, n), {
|
|
765
|
+
fields: i,
|
|
766
|
+
columns: n
|
|
767
|
+
};
|
|
768
|
+
let a = oe(i.length);
|
|
769
|
+
return i = X(i, a), {
|
|
770
|
+
fields: i,
|
|
771
|
+
columns: a
|
|
772
|
+
};
|
|
868
773
|
}
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
1023
|
-
|
|
1024
|
-
|
|
1025
|
-
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
},
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1069
|
-
|
|
1070
|
-
|
|
1071
|
-
|
|
1072
|
-
}
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1089
|
-
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1126
|
-
|
|
1127
|
-
|
|
1128
|
-
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1173
|
-
|
|
1174
|
-
|
|
1175
|
-
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1212
|
-
|
|
1213
|
-
|
|
1214
|
-
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1227
|
-
|
|
1228
|
-
|
|
1229
|
-
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1237
|
-
|
|
1238
|
-
|
|
1239
|
-
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1384
|
-
|
|
1385
|
-
|
|
1386
|
-
|
|
1387
|
-
|
|
1388
|
-
|
|
1389
|
-
|
|
1390
|
-
|
|
1391
|
-
|
|
1392
|
-
|
|
1393
|
-
|
|
1394
|
-
|
|
1395
|
-
|
|
1396
|
-
|
|
1397
|
-
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
|
|
1402
|
-
|
|
1403
|
-
|
|
1404
|
-
|
|
1405
|
-
|
|
1406
|
-
|
|
1407
|
-
|
|
1408
|
-
|
|
1409
|
-
|
|
1410
|
-
|
|
1411
|
-
|
|
1412
|
-
|
|
1413
|
-
|
|
1414
|
-
|
|
1415
|
-
|
|
1416
|
-
|
|
1417
|
-
|
|
1418
|
-
|
|
1419
|
-
|
|
1420
|
-
|
|
1421
|
-
|
|
1422
|
-
|
|
1423
|
-
|
|
1424
|
-
|
|
1425
|
-
|
|
1426
|
-
|
|
1427
|
-
|
|
1428
|
-
|
|
1429
|
-
|
|
1430
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
1437
|
-
|
|
1438
|
-
|
|
1439
|
-
|
|
1440
|
-
|
|
1441
|
-
|
|
1442
|
-
|
|
1443
|
-
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
|
|
1447
|
-
|
|
1448
|
-
|
|
1449
|
-
|
|
1450
|
-
|
|
1451
|
-
|
|
1452
|
-
|
|
1453
|
-
|
|
1454
|
-
|
|
1455
|
-
|
|
1456
|
-
|
|
1457
|
-
|
|
1458
|
-
|
|
1459
|
-
|
|
1460
|
-
|
|
1461
|
-
|
|
1462
|
-
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1469
|
-
|
|
1470
|
-
|
|
1471
|
-
|
|
1472
|
-
|
|
1473
|
-
|
|
1474
|
-
|
|
1475
|
-
|
|
1476
|
-
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
|
|
1494
|
-
|
|
1495
|
-
|
|
1496
|
-
|
|
1497
|
-
|
|
1498
|
-
|
|
1499
|
-
|
|
1500
|
-
|
|
1501
|
-
|
|
1502
|
-
|
|
1503
|
-
|
|
1504
|
-
|
|
1505
|
-
|
|
1506
|
-
|
|
1507
|
-
|
|
1508
|
-
|
|
1509
|
-
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1522
|
-
|
|
1523
|
-
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1531
|
-
|
|
1532
|
-
|
|
1533
|
-
|
|
1534
|
-
|
|
1535
|
-
|
|
1536
|
-
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
|
|
1541
|
-
|
|
1542
|
-
|
|
1543
|
-
|
|
1544
|
-
|
|
1545
|
-
|
|
1546
|
-
|
|
1547
|
-
|
|
1548
|
-
|
|
1549
|
-
|
|
1550
|
-
|
|
1551
|
-
|
|
1552
|
-
|
|
1553
|
-
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
|
|
1557
|
-
|
|
1558
|
-
|
|
1559
|
-
|
|
1560
|
-
|
|
1561
|
-
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
|
|
1565
|
-
|
|
1566
|
-
|
|
1567
|
-
|
|
1568
|
-
|
|
1569
|
-
|
|
1570
|
-
|
|
1571
|
-
|
|
1572
|
-
|
|
1573
|
-
|
|
1574
|
-
|
|
1575
|
-
|
|
1576
|
-
|
|
1577
|
-
|
|
1578
|
-
|
|
1579
|
-
|
|
1580
|
-
|
|
1581
|
-
|
|
1582
|
-
|
|
1583
|
-
|
|
1584
|
-
|
|
1585
|
-
|
|
1586
|
-
|
|
1587
|
-
|
|
1588
|
-
|
|
1589
|
-
|
|
1590
|
-
|
|
1591
|
-
|
|
1592
|
-
|
|
1593
|
-
|
|
1594
|
-
|
|
1595
|
-
|
|
1596
|
-
|
|
1597
|
-
|
|
1598
|
-
|
|
1599
|
-
|
|
1600
|
-
|
|
1601
|
-
|
|
1602
|
-
|
|
1603
|
-
|
|
1604
|
-
|
|
1605
|
-
|
|
1606
|
-
|
|
1607
|
-
|
|
1608
|
-
|
|
1609
|
-
|
|
1610
|
-
|
|
1611
|
-
|
|
1612
|
-
|
|
1613
|
-
|
|
1614
|
-
|
|
1615
|
-
|
|
1616
|
-
|
|
1617
|
-
|
|
1618
|
-
|
|
1619
|
-
|
|
1620
|
-
|
|
1621
|
-
|
|
1622
|
-
|
|
1623
|
-
|
|
1624
|
-
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1634
|
-
|
|
1635
|
-
|
|
1636
|
-
|
|
1637
|
-
|
|
1638
|
-
|
|
1639
|
-
|
|
1640
|
-
|
|
1641
|
-
|
|
1642
|
-
|
|
1643
|
-
|
|
1644
|
-
|
|
1645
|
-
|
|
1646
|
-
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
|
|
1655
|
-
|
|
1656
|
-
|
|
1657
|
-
|
|
1658
|
-
|
|
1659
|
-
|
|
1660
|
-
|
|
1661
|
-
|
|
1662
|
-
|
|
1663
|
-
|
|
1664
|
-
|
|
1665
|
-
|
|
1666
|
-
|
|
1667
|
-
|
|
1668
|
-
|
|
1669
|
-
|
|
1670
|
-
|
|
1671
|
-
|
|
1672
|
-
|
|
1673
|
-
|
|
1674
|
-
|
|
1675
|
-
|
|
1676
|
-
|
|
1677
|
-
|
|
1678
|
-
|
|
1679
|
-
|
|
1680
|
-
|
|
1681
|
-
|
|
1682
|
-
|
|
1683
|
-
|
|
1684
|
-
|
|
1685
|
-
|
|
1686
|
-
|
|
1687
|
-
|
|
1688
|
-
|
|
1689
|
-
|
|
1690
|
-
|
|
1691
|
-
|
|
1692
|
-
|
|
1693
|
-
|
|
1694
|
-
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
774
|
+
//#endregion
|
|
775
|
+
//#region src/DrawerForm.tsx
|
|
776
|
+
var ce = {
|
|
777
|
+
1: void 0,
|
|
778
|
+
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
779
|
+
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
780
|
+
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
781
|
+
}, le = ({ schema: e, dataSource: r, className: o }) => {
|
|
782
|
+
let { fieldLabel: u } = c(), [d, p] = a(null), [m, h] = a([]), [g, _] = a({}), [v, y] = a(!0), [b, x] = a(null), S = e.open !== !1, C = e.drawerSide || "right";
|
|
783
|
+
n(() => {
|
|
784
|
+
(async () => {
|
|
785
|
+
if (!r) {
|
|
786
|
+
y(!1);
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
try {
|
|
790
|
+
p(await r.getObjectSchema(e.objectName));
|
|
791
|
+
} catch (e) {
|
|
792
|
+
x(e), y(!1);
|
|
793
|
+
}
|
|
794
|
+
})();
|
|
795
|
+
}, [e.objectName, r]), n(() => {
|
|
796
|
+
(d || !r) && (async () => {
|
|
797
|
+
if (e.mode === "create" || !e.recordId) {
|
|
798
|
+
_(e.initialData || e.initialValues || {}), y(!1);
|
|
799
|
+
return;
|
|
800
|
+
}
|
|
801
|
+
if (!r) {
|
|
802
|
+
_(e.initialData || e.initialValues || {}), y(!1);
|
|
803
|
+
return;
|
|
804
|
+
}
|
|
805
|
+
try {
|
|
806
|
+
_(await r.findOne(e.objectName, e.recordId) || {});
|
|
807
|
+
} catch (e) {
|
|
808
|
+
x(e);
|
|
809
|
+
} finally {
|
|
810
|
+
y(!1);
|
|
811
|
+
}
|
|
812
|
+
})();
|
|
813
|
+
}, [
|
|
814
|
+
d,
|
|
815
|
+
e.mode,
|
|
816
|
+
e.recordId,
|
|
817
|
+
e.initialData,
|
|
818
|
+
e.initialValues,
|
|
819
|
+
r,
|
|
820
|
+
e.objectName
|
|
821
|
+
]);
|
|
822
|
+
let w = t((t) => {
|
|
823
|
+
let n = [];
|
|
824
|
+
for (let r of t.fields) {
|
|
825
|
+
let t = typeof r == "string" ? r : r.name;
|
|
826
|
+
if (typeof r == "object") n.push(r);
|
|
827
|
+
else if (d?.fields?.[t]) {
|
|
828
|
+
let r = d.fields[t];
|
|
829
|
+
n.push({
|
|
830
|
+
name: t,
|
|
831
|
+
label: u(e.objectName, t, r.label || t),
|
|
832
|
+
type: f(r.type),
|
|
833
|
+
required: r.required || !1,
|
|
834
|
+
disabled: e.readOnly || e.mode === "view" || r.readonly,
|
|
835
|
+
placeholder: r.placeholder,
|
|
836
|
+
description: r.help || r.description,
|
|
837
|
+
validation: l(r),
|
|
838
|
+
field: r,
|
|
839
|
+
options: r.options,
|
|
840
|
+
multiple: r.multiple
|
|
841
|
+
});
|
|
842
|
+
} else n.push({
|
|
843
|
+
name: t,
|
|
844
|
+
label: t,
|
|
845
|
+
type: "input"
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
return n;
|
|
849
|
+
}, [
|
|
850
|
+
d,
|
|
851
|
+
e.readOnly,
|
|
852
|
+
e.mode
|
|
853
|
+
]);
|
|
854
|
+
n(() => {
|
|
855
|
+
if (!d && r) return;
|
|
856
|
+
if (e.customFields?.length) {
|
|
857
|
+
h(e.customFields), y(!1);
|
|
858
|
+
return;
|
|
859
|
+
}
|
|
860
|
+
if (e.sections?.length) {
|
|
861
|
+
y(!1);
|
|
862
|
+
return;
|
|
863
|
+
}
|
|
864
|
+
if (!d) return;
|
|
865
|
+
let t = e.fields || Object.keys(d.fields || {}), n = [];
|
|
866
|
+
for (let r of t) {
|
|
867
|
+
let t = typeof r == "string" ? r : r.name;
|
|
868
|
+
if (!t) continue;
|
|
869
|
+
let i = d.fields?.[t];
|
|
870
|
+
i && n.push({
|
|
871
|
+
name: t,
|
|
872
|
+
label: u(e.objectName, t, i.label || t),
|
|
873
|
+
type: f(i.type),
|
|
874
|
+
required: i.required || !1,
|
|
875
|
+
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
876
|
+
placeholder: i.placeholder,
|
|
877
|
+
description: i.help || i.description,
|
|
878
|
+
validation: l(i),
|
|
879
|
+
field: i,
|
|
880
|
+
options: i.options,
|
|
881
|
+
multiple: i.multiple
|
|
882
|
+
});
|
|
883
|
+
}
|
|
884
|
+
h(n), y(!1);
|
|
885
|
+
}, [
|
|
886
|
+
d,
|
|
887
|
+
e.fields,
|
|
888
|
+
e.customFields,
|
|
889
|
+
e.sections,
|
|
890
|
+
e.readOnly,
|
|
891
|
+
e.mode,
|
|
892
|
+
r
|
|
893
|
+
]);
|
|
894
|
+
let T = t(async (t) => {
|
|
895
|
+
if (!r) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
896
|
+
try {
|
|
897
|
+
let n;
|
|
898
|
+
return e.mode === "create" ? n = await r.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await r.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
899
|
+
} catch (t) {
|
|
900
|
+
throw e.onError && e.onError(t), t;
|
|
901
|
+
}
|
|
902
|
+
}, [e, r]), E = t(() => {
|
|
903
|
+
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
904
|
+
}, [e]), M = i(() => {
|
|
905
|
+
if (e.drawerWidth) return C === "left" || C === "right" ? {
|
|
906
|
+
width: e.drawerWidth,
|
|
907
|
+
maxWidth: e.drawerWidth
|
|
908
|
+
} : {
|
|
909
|
+
height: e.drawerWidth,
|
|
910
|
+
maxHeight: e.drawerWidth
|
|
911
|
+
};
|
|
912
|
+
}, [e.drawerWidth, C]), N = {
|
|
913
|
+
type: "form",
|
|
914
|
+
layout: e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical",
|
|
915
|
+
defaultValues: g,
|
|
916
|
+
submitLabel: e.submitText || (e.mode === "create" ? "Create" : "Update"),
|
|
917
|
+
cancelLabel: e.cancelText,
|
|
918
|
+
showSubmit: e.showSubmit !== !1 && e.mode !== "view",
|
|
919
|
+
showCancel: e.showCancel !== !1,
|
|
920
|
+
onSubmit: T,
|
|
921
|
+
onCancel: E
|
|
922
|
+
};
|
|
923
|
+
return /* @__PURE__ */ (0, K.jsx)(D, {
|
|
924
|
+
open: S,
|
|
925
|
+
onOpenChange: e.onOpenChange,
|
|
926
|
+
children: /* @__PURE__ */ (0, K.jsxs)(O, {
|
|
927
|
+
side: C,
|
|
928
|
+
className: L("overflow-y-auto", o, e.className),
|
|
929
|
+
style: M,
|
|
930
|
+
children: [(e.title || e.description) && /* @__PURE__ */ (0, K.jsxs)(A, { children: [e.title && /* @__PURE__ */ (0, K.jsx)(j, { children: e.title }), e.description && /* @__PURE__ */ (0, K.jsx)(k, { children: e.description })] }), /* @__PURE__ */ (0, K.jsx)("div", {
|
|
931
|
+
className: "@container py-4",
|
|
932
|
+
children: (() => {
|
|
933
|
+
if (b) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
934
|
+
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
935
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
936
|
+
className: "text-red-800 font-semibold",
|
|
937
|
+
children: "Error loading form"
|
|
938
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
939
|
+
className: "text-red-600 text-sm mt-1",
|
|
940
|
+
children: b.message
|
|
941
|
+
})]
|
|
942
|
+
});
|
|
943
|
+
if (v) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
944
|
+
className: "p-8 text-center",
|
|
945
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
946
|
+
className: "mt-2 text-sm text-gray-600",
|
|
947
|
+
children: "Loading form..."
|
|
948
|
+
})]
|
|
949
|
+
});
|
|
950
|
+
if (e.sections?.length) return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
951
|
+
className: "space-y-6",
|
|
952
|
+
children: e.sections.map((t, n) => {
|
|
953
|
+
let r = t.columns || 1;
|
|
954
|
+
return /* @__PURE__ */ (0, K.jsx)(q, {
|
|
955
|
+
label: t.label,
|
|
956
|
+
description: t.description,
|
|
957
|
+
columns: r,
|
|
958
|
+
gridClassName: ce[r],
|
|
959
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
960
|
+
...N,
|
|
961
|
+
fields: w(t),
|
|
962
|
+
showSubmit: n === e.sections.length - 1 && N.showSubmit,
|
|
963
|
+
showCancel: n === e.sections.length - 1 && N.showCancel
|
|
964
|
+
} })
|
|
965
|
+
}, t.name || t.label || n);
|
|
966
|
+
})
|
|
967
|
+
});
|
|
968
|
+
let t = Q(m, d, e.columns, e.mode), n = ce[t.columns || 1];
|
|
969
|
+
return /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
970
|
+
...N,
|
|
971
|
+
fields: t.fields,
|
|
972
|
+
columns: t.columns,
|
|
973
|
+
...n ? { fieldContainerClass: n } : {}
|
|
974
|
+
} });
|
|
975
|
+
})()
|
|
976
|
+
})]
|
|
977
|
+
})
|
|
978
|
+
});
|
|
979
|
+
}, ue = {
|
|
980
|
+
sm: "sm:max-w-sm",
|
|
981
|
+
default: "sm:max-w-lg",
|
|
982
|
+
lg: "sm:max-w-2xl",
|
|
983
|
+
xl: "sm:max-w-5xl",
|
|
984
|
+
full: "sm:max-w-[95vw] sm:w-full"
|
|
985
|
+
}, de = {
|
|
986
|
+
1: void 0,
|
|
987
|
+
2: "grid gap-4 grid-cols-1 @md:grid-cols-2",
|
|
988
|
+
3: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3",
|
|
989
|
+
4: "grid gap-4 grid-cols-1 @md:grid-cols-2 @2xl:grid-cols-3 @4xl:grid-cols-4"
|
|
990
|
+
}, fe = ({ schema: e, dataSource: o, className: u }) => {
|
|
991
|
+
let { fieldLabel: d } = c(), [m, h] = a(null), [g, _] = a([]), [v, w] = a({}), [T, E] = a(!0), [D, O] = a(null), [k, A] = a(!1), j = e.open !== !1, N = r(), P = i(() => e.sections?.length || e.customFields?.length ? null : Q(g, m, e.columns, e.mode), [
|
|
992
|
+
g,
|
|
993
|
+
m,
|
|
994
|
+
e.columns,
|
|
995
|
+
e.mode,
|
|
996
|
+
e.sections,
|
|
997
|
+
e.customFields
|
|
998
|
+
]), F = ue[i(() => {
|
|
999
|
+
if (e.modalSize) return e.modalSize;
|
|
1000
|
+
if (P?.columns && P.columns > 1) return Z(P.columns);
|
|
1001
|
+
if (e.sections?.length) {
|
|
1002
|
+
let t = Math.max(...e.sections.map((e) => Number(e.columns) || 1));
|
|
1003
|
+
if (t > 1) return Z(t);
|
|
1004
|
+
}
|
|
1005
|
+
return "default";
|
|
1006
|
+
}, [
|
|
1007
|
+
e.modalSize,
|
|
1008
|
+
P,
|
|
1009
|
+
e.sections
|
|
1010
|
+
])] || ue.default;
|
|
1011
|
+
n(() => {
|
|
1012
|
+
(async () => {
|
|
1013
|
+
if (!o) {
|
|
1014
|
+
E(!1);
|
|
1015
|
+
return;
|
|
1016
|
+
}
|
|
1017
|
+
try {
|
|
1018
|
+
h(await o.getObjectSchema(e.objectName));
|
|
1019
|
+
} catch (e) {
|
|
1020
|
+
O(e), E(!1);
|
|
1021
|
+
}
|
|
1022
|
+
})();
|
|
1023
|
+
}, [e.objectName, o]), n(() => {
|
|
1024
|
+
(m || !o) && (async () => {
|
|
1025
|
+
if (e.mode === "create" || !e.recordId) {
|
|
1026
|
+
w(e.initialData || e.initialValues || {}), E(!1);
|
|
1027
|
+
return;
|
|
1028
|
+
}
|
|
1029
|
+
if (!o) {
|
|
1030
|
+
w(e.initialData || e.initialValues || {}), E(!1);
|
|
1031
|
+
return;
|
|
1032
|
+
}
|
|
1033
|
+
try {
|
|
1034
|
+
w(await o.findOne(e.objectName, e.recordId) || {});
|
|
1035
|
+
} catch (e) {
|
|
1036
|
+
O(e);
|
|
1037
|
+
} finally {
|
|
1038
|
+
E(!1);
|
|
1039
|
+
}
|
|
1040
|
+
})();
|
|
1041
|
+
}, [
|
|
1042
|
+
m,
|
|
1043
|
+
e.mode,
|
|
1044
|
+
e.recordId,
|
|
1045
|
+
e.initialData,
|
|
1046
|
+
e.initialValues,
|
|
1047
|
+
o,
|
|
1048
|
+
e.objectName
|
|
1049
|
+
]);
|
|
1050
|
+
let I = t((t) => {
|
|
1051
|
+
let n = [];
|
|
1052
|
+
for (let r of t.fields) {
|
|
1053
|
+
let t = typeof r == "string" ? r : r.name;
|
|
1054
|
+
if (typeof r == "object") n.push(r);
|
|
1055
|
+
else if (m?.fields?.[t]) {
|
|
1056
|
+
let r = m.fields[t];
|
|
1057
|
+
n.push({
|
|
1058
|
+
name: t,
|
|
1059
|
+
label: d(e.objectName, t, r.label || t),
|
|
1060
|
+
type: f(r.type),
|
|
1061
|
+
required: r.required || !1,
|
|
1062
|
+
disabled: e.readOnly || e.mode === "view" || r.readonly,
|
|
1063
|
+
placeholder: r.placeholder,
|
|
1064
|
+
description: r.help || r.description,
|
|
1065
|
+
validation: l(r),
|
|
1066
|
+
field: r,
|
|
1067
|
+
options: r.options,
|
|
1068
|
+
multiple: r.multiple
|
|
1069
|
+
});
|
|
1070
|
+
} else n.push({
|
|
1071
|
+
name: t,
|
|
1072
|
+
label: t,
|
|
1073
|
+
type: "input"
|
|
1074
|
+
});
|
|
1075
|
+
}
|
|
1076
|
+
return n;
|
|
1077
|
+
}, [
|
|
1078
|
+
m,
|
|
1079
|
+
e.readOnly,
|
|
1080
|
+
e.mode
|
|
1081
|
+
]);
|
|
1082
|
+
n(() => {
|
|
1083
|
+
if (!m && o) return;
|
|
1084
|
+
if (e.customFields?.length) {
|
|
1085
|
+
_(e.customFields), E(!1);
|
|
1086
|
+
return;
|
|
1087
|
+
}
|
|
1088
|
+
if (e.sections?.length) {
|
|
1089
|
+
E(!1);
|
|
1090
|
+
return;
|
|
1091
|
+
}
|
|
1092
|
+
if (!m) return;
|
|
1093
|
+
let t = e.fields || Object.keys(m.fields || {}), n = [];
|
|
1094
|
+
for (let r of t) {
|
|
1095
|
+
let t = typeof r == "string" ? r : r.name;
|
|
1096
|
+
if (!t) continue;
|
|
1097
|
+
let i = m.fields?.[t];
|
|
1098
|
+
i && n.push({
|
|
1099
|
+
name: t,
|
|
1100
|
+
label: d(e.objectName, t, i.label || t),
|
|
1101
|
+
type: f(i.type),
|
|
1102
|
+
required: i.required || !1,
|
|
1103
|
+
disabled: e.readOnly || e.mode === "view" || i.readonly,
|
|
1104
|
+
placeholder: i.placeholder,
|
|
1105
|
+
description: i.help || i.description,
|
|
1106
|
+
validation: l(i),
|
|
1107
|
+
field: i,
|
|
1108
|
+
options: i.options,
|
|
1109
|
+
multiple: i.multiple
|
|
1110
|
+
});
|
|
1111
|
+
}
|
|
1112
|
+
_(n), E(!1);
|
|
1113
|
+
}, [
|
|
1114
|
+
m,
|
|
1115
|
+
e.fields,
|
|
1116
|
+
e.customFields,
|
|
1117
|
+
e.sections,
|
|
1118
|
+
e.readOnly,
|
|
1119
|
+
e.mode,
|
|
1120
|
+
o
|
|
1121
|
+
]);
|
|
1122
|
+
let R = t(async (t) => {
|
|
1123
|
+
A(!0);
|
|
1124
|
+
try {
|
|
1125
|
+
if (!o) return e.onSuccess && await e.onSuccess(t), e.onOpenChange?.(!1), t;
|
|
1126
|
+
let n;
|
|
1127
|
+
return e.mode === "create" ? n = await o.create(e.objectName, t) : e.mode === "edit" && e.recordId && (n = await o.update(e.objectName, e.recordId, t)), e.onSuccess && await e.onSuccess(n), e.onOpenChange?.(!1), n;
|
|
1128
|
+
} catch (t) {
|
|
1129
|
+
throw e.onError && e.onError(t), t;
|
|
1130
|
+
} finally {
|
|
1131
|
+
A(!1);
|
|
1132
|
+
}
|
|
1133
|
+
}, [e, o]), z = t(() => {
|
|
1134
|
+
e.onCancel && e.onCancel(), e.onOpenChange?.(!1);
|
|
1135
|
+
}, [e]), B = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : "vertical", V = e.showSubmit !== !1 && e.mode !== "view", H = e.showCancel !== !1, U = e.submitText || (e.mode === "create" ? "Create" : "Update"), W = e.cancelText || "Cancel", G = {
|
|
1136
|
+
type: "form",
|
|
1137
|
+
layout: B,
|
|
1138
|
+
defaultValues: v,
|
|
1139
|
+
submitLabel: U,
|
|
1140
|
+
cancelLabel: W,
|
|
1141
|
+
showSubmit: V,
|
|
1142
|
+
showCancel: H,
|
|
1143
|
+
onSubmit: R,
|
|
1144
|
+
onCancel: z,
|
|
1145
|
+
showActions: !1,
|
|
1146
|
+
id: N
|
|
1147
|
+
}, J = () => {
|
|
1148
|
+
if (D) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1149
|
+
className: "p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1150
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
1151
|
+
className: "text-red-800 font-semibold",
|
|
1152
|
+
children: "Error loading form"
|
|
1153
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
1154
|
+
className: "text-red-600 text-sm mt-1",
|
|
1155
|
+
children: D.message
|
|
1156
|
+
})]
|
|
1157
|
+
});
|
|
1158
|
+
if (T) return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1159
|
+
className: "space-y-4",
|
|
1160
|
+
"data-testid": "modal-form-skeleton",
|
|
1161
|
+
children: [
|
|
1162
|
+
1,
|
|
1163
|
+
2,
|
|
1164
|
+
3
|
|
1165
|
+
].map((e) => /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1166
|
+
className: "space-y-2",
|
|
1167
|
+
children: [/* @__PURE__ */ (0, K.jsx)(M, { className: "h-4 w-24" }), /* @__PURE__ */ (0, K.jsx)(M, { className: "h-10 w-full" })]
|
|
1168
|
+
}, e))
|
|
1169
|
+
});
|
|
1170
|
+
if (e.sections?.length) return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1171
|
+
className: "space-y-6",
|
|
1172
|
+
children: e.sections.map((e, t) => {
|
|
1173
|
+
let n = e.columns || 1;
|
|
1174
|
+
return /* @__PURE__ */ (0, K.jsx)(q, {
|
|
1175
|
+
label: e.label,
|
|
1176
|
+
description: e.description,
|
|
1177
|
+
columns: n,
|
|
1178
|
+
gridClassName: de[n],
|
|
1179
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
1180
|
+
...G,
|
|
1181
|
+
fields: I(e)
|
|
1182
|
+
} })
|
|
1183
|
+
}, e.name || e.label || t);
|
|
1184
|
+
})
|
|
1185
|
+
});
|
|
1186
|
+
let t = P ?? Q(g, m, e.columns, e.mode), n = de[t.columns || 1];
|
|
1187
|
+
return /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
1188
|
+
...G,
|
|
1189
|
+
fields: t.fields,
|
|
1190
|
+
columns: t.columns,
|
|
1191
|
+
...n ? { fieldContainerClass: n } : {}
|
|
1192
|
+
} });
|
|
1193
|
+
}, Y = !T && !D && (V || H);
|
|
1194
|
+
return /* @__PURE__ */ (0, K.jsx)(y, {
|
|
1195
|
+
open: j,
|
|
1196
|
+
onOpenChange: e.onOpenChange,
|
|
1197
|
+
children: /* @__PURE__ */ (0, K.jsxs)(C, {
|
|
1198
|
+
className: L(F, "flex flex-col h-[100dvh] sm:h-auto sm:max-h-[90vh] overflow-hidden p-0", u, e.className),
|
|
1199
|
+
children: [
|
|
1200
|
+
(e.title || e.description) && /* @__PURE__ */ (0, K.jsxs)(x, {
|
|
1201
|
+
className: "shrink-0 px-4 pt-4 sm:px-6 sm:pt-6 pb-2 border-b",
|
|
1202
|
+
children: [e.title && /* @__PURE__ */ (0, K.jsx)(S, { children: e.title }), e.description && /* @__PURE__ */ (0, K.jsx)(b, { children: e.description })]
|
|
1203
|
+
}),
|
|
1204
|
+
/* @__PURE__ */ (0, K.jsx)("div", {
|
|
1205
|
+
className: "@container flex-1 overflow-y-auto px-4 sm:px-6 py-4",
|
|
1206
|
+
children: J()
|
|
1207
|
+
}),
|
|
1208
|
+
Y && /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1209
|
+
className: "shrink-0 border-t px-4 sm:px-6 py-3 bg-background",
|
|
1210
|
+
"data-testid": "modal-form-footer",
|
|
1211
|
+
children: /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1212
|
+
className: "flex flex-col sm:flex-row gap-2 sm:justify-end",
|
|
1213
|
+
children: [H && /* @__PURE__ */ (0, K.jsx)(p, {
|
|
1214
|
+
type: "button",
|
|
1215
|
+
variant: "outline",
|
|
1216
|
+
onClick: z,
|
|
1217
|
+
disabled: k,
|
|
1218
|
+
className: "w-full sm:w-auto",
|
|
1219
|
+
children: W
|
|
1220
|
+
}), V && /* @__PURE__ */ (0, K.jsxs)(p, {
|
|
1221
|
+
type: "submit",
|
|
1222
|
+
form: N,
|
|
1223
|
+
disabled: k,
|
|
1224
|
+
className: "w-full sm:w-auto",
|
|
1225
|
+
children: [k && /* @__PURE__ */ (0, K.jsx)(ee, { className: "mr-2 h-4 w-4 animate-spin" }), U]
|
|
1226
|
+
})]
|
|
1227
|
+
})
|
|
1228
|
+
})
|
|
1229
|
+
]
|
|
1230
|
+
})
|
|
1231
|
+
});
|
|
1232
|
+
}, $ = ({ schema: e, dataSource: t }) => {
|
|
1233
|
+
if (e.formType === "tabbed" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(J, {
|
|
1234
|
+
schema: {
|
|
1235
|
+
...e,
|
|
1236
|
+
formType: "tabbed",
|
|
1237
|
+
sections: e.sections.map((e) => ({
|
|
1238
|
+
name: e.name,
|
|
1239
|
+
label: e.label,
|
|
1240
|
+
description: e.description,
|
|
1241
|
+
columns: e.columns,
|
|
1242
|
+
fields: e.fields
|
|
1243
|
+
})),
|
|
1244
|
+
defaultTab: e.defaultTab,
|
|
1245
|
+
tabPosition: e.tabPosition
|
|
1246
|
+
},
|
|
1247
|
+
dataSource: t,
|
|
1248
|
+
className: e.className
|
|
1249
|
+
});
|
|
1250
|
+
if (e.formType === "wizard" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(Y, {
|
|
1251
|
+
schema: {
|
|
1252
|
+
...e,
|
|
1253
|
+
formType: "wizard",
|
|
1254
|
+
sections: e.sections.map((e) => ({
|
|
1255
|
+
name: e.name,
|
|
1256
|
+
label: e.label,
|
|
1257
|
+
description: e.description,
|
|
1258
|
+
columns: e.columns,
|
|
1259
|
+
fields: e.fields
|
|
1260
|
+
})),
|
|
1261
|
+
allowSkip: e.allowSkip,
|
|
1262
|
+
showStepIndicator: e.showStepIndicator,
|
|
1263
|
+
nextText: e.nextText,
|
|
1264
|
+
prevText: e.prevText,
|
|
1265
|
+
onStepChange: e.onStepChange
|
|
1266
|
+
},
|
|
1267
|
+
dataSource: t,
|
|
1268
|
+
className: e.className
|
|
1269
|
+
});
|
|
1270
|
+
if (e.formType === "split" && e.sections?.length) return /* @__PURE__ */ (0, K.jsx)(te, {
|
|
1271
|
+
schema: {
|
|
1272
|
+
...e,
|
|
1273
|
+
formType: "split",
|
|
1274
|
+
sections: e.sections.map((e) => ({
|
|
1275
|
+
name: e.name,
|
|
1276
|
+
label: e.label,
|
|
1277
|
+
description: e.description,
|
|
1278
|
+
columns: e.columns,
|
|
1279
|
+
fields: e.fields
|
|
1280
|
+
})),
|
|
1281
|
+
splitDirection: e.splitDirection,
|
|
1282
|
+
splitSize: e.splitSize,
|
|
1283
|
+
splitResizable: e.splitResizable
|
|
1284
|
+
},
|
|
1285
|
+
dataSource: t,
|
|
1286
|
+
className: e.className
|
|
1287
|
+
});
|
|
1288
|
+
if (e.formType === "drawer") {
|
|
1289
|
+
let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1290
|
+
return /* @__PURE__ */ (0, K.jsx)(le, {
|
|
1291
|
+
schema: {
|
|
1292
|
+
...r,
|
|
1293
|
+
layout: i,
|
|
1294
|
+
formType: "drawer",
|
|
1295
|
+
sections: e.sections?.map((e) => ({
|
|
1296
|
+
name: e.name,
|
|
1297
|
+
label: e.label,
|
|
1298
|
+
description: e.description,
|
|
1299
|
+
columns: e.columns,
|
|
1300
|
+
fields: e.fields
|
|
1301
|
+
})),
|
|
1302
|
+
open: e.open,
|
|
1303
|
+
onOpenChange: e.onOpenChange,
|
|
1304
|
+
drawerSide: e.drawerSide,
|
|
1305
|
+
drawerWidth: e.drawerWidth
|
|
1306
|
+
},
|
|
1307
|
+
dataSource: t,
|
|
1308
|
+
className: e.className
|
|
1309
|
+
});
|
|
1310
|
+
}
|
|
1311
|
+
if (e.formType === "modal") {
|
|
1312
|
+
let { layout: n, ...r } = e, i = e.layout === "vertical" || e.layout === "horizontal" ? e.layout : void 0;
|
|
1313
|
+
return /* @__PURE__ */ (0, K.jsx)(fe, {
|
|
1314
|
+
schema: {
|
|
1315
|
+
...r,
|
|
1316
|
+
layout: i,
|
|
1317
|
+
formType: "modal",
|
|
1318
|
+
sections: e.sections?.map((e) => ({
|
|
1319
|
+
name: e.name,
|
|
1320
|
+
label: e.label,
|
|
1321
|
+
description: e.description,
|
|
1322
|
+
columns: e.columns,
|
|
1323
|
+
fields: e.fields
|
|
1324
|
+
})),
|
|
1325
|
+
open: e.open,
|
|
1326
|
+
onOpenChange: e.onOpenChange,
|
|
1327
|
+
modalSize: e.modalSize,
|
|
1328
|
+
modalCloseButton: e.modalCloseButton
|
|
1329
|
+
},
|
|
1330
|
+
dataSource: t,
|
|
1331
|
+
className: e.className
|
|
1332
|
+
});
|
|
1333
|
+
}
|
|
1334
|
+
return /* @__PURE__ */ (0, K.jsx)(pe, {
|
|
1335
|
+
schema: e,
|
|
1336
|
+
dataSource: t
|
|
1337
|
+
});
|
|
1338
|
+
}, pe = ({ schema: r, dataSource: i }) => {
|
|
1339
|
+
let { fieldLabel: o } = c(), [p, m] = a(null), [h, g] = a([]), [_, v] = a(null), [y, b] = a(!0), [x, S] = a(null), C = r.customFields && r.customFields.length > 0;
|
|
1340
|
+
n(() => {
|
|
1341
|
+
C && (v(r.initialData || r.initialValues || {}), b(!1));
|
|
1342
|
+
}, [
|
|
1343
|
+
C,
|
|
1344
|
+
r.initialData,
|
|
1345
|
+
r.initialValues
|
|
1346
|
+
]), n(() => {
|
|
1347
|
+
C ? m({
|
|
1348
|
+
name: r.objectName,
|
|
1349
|
+
fields: {}
|
|
1350
|
+
}) : r.objectName && i ? (async () => {
|
|
1351
|
+
try {
|
|
1352
|
+
if (!i) throw Error("DataSource is required when using ObjectQL schema fetching (inline fields not provided)");
|
|
1353
|
+
let e = await i.getObjectSchema(r.objectName);
|
|
1354
|
+
if (!e) throw Error(`No schema found for object "${r.objectName}"`);
|
|
1355
|
+
m(e);
|
|
1356
|
+
} catch (e) {
|
|
1357
|
+
S(e), b(!1);
|
|
1358
|
+
}
|
|
1359
|
+
})() : C || b(!1);
|
|
1360
|
+
}, [
|
|
1361
|
+
r.objectName,
|
|
1362
|
+
i,
|
|
1363
|
+
C
|
|
1364
|
+
]), n(() => {
|
|
1365
|
+
p && !C && (async () => {
|
|
1366
|
+
if (!r.recordId || r.mode === "create") {
|
|
1367
|
+
v(r.initialData || r.initialValues || {}), b(!1);
|
|
1368
|
+
return;
|
|
1369
|
+
}
|
|
1370
|
+
if (!C) {
|
|
1371
|
+
if (!i) {
|
|
1372
|
+
S(/* @__PURE__ */ Error("DataSource is required for fetching record data (inline data not provided)")), b(!1);
|
|
1373
|
+
return;
|
|
1374
|
+
}
|
|
1375
|
+
b(!0);
|
|
1376
|
+
try {
|
|
1377
|
+
v(await i.findOne(r.objectName, r.recordId));
|
|
1378
|
+
} catch (e) {
|
|
1379
|
+
console.error("Failed to fetch record:", e), S(e);
|
|
1380
|
+
} finally {
|
|
1381
|
+
b(!1);
|
|
1382
|
+
}
|
|
1383
|
+
}
|
|
1384
|
+
})();
|
|
1385
|
+
}, [
|
|
1386
|
+
r.objectName,
|
|
1387
|
+
r.recordId,
|
|
1388
|
+
r.mode,
|
|
1389
|
+
r.initialValues,
|
|
1390
|
+
r.initialData,
|
|
1391
|
+
i,
|
|
1392
|
+
p,
|
|
1393
|
+
C
|
|
1394
|
+
]), n(() => {
|
|
1395
|
+
if (C && r.customFields) {
|
|
1396
|
+
g(r.customFields), b(!1);
|
|
1397
|
+
return;
|
|
1398
|
+
}
|
|
1399
|
+
if (!p) return;
|
|
1400
|
+
let e = [], t = r.fields || Object.keys(p.fields || {});
|
|
1401
|
+
(Array.isArray(t) ? t : Object.keys(t)).forEach((t) => {
|
|
1402
|
+
let n = typeof t == "string" ? t : t.name;
|
|
1403
|
+
if (!n) return;
|
|
1404
|
+
let i = p.fields?.[n];
|
|
1405
|
+
if (!i && !C) return;
|
|
1406
|
+
let a = !i?.permissions || i?.permissions.write !== !1;
|
|
1407
|
+
if (r.mode !== "view" && !a) return;
|
|
1408
|
+
let s = r.customFields?.find((e) => e.name === n);
|
|
1409
|
+
if (s) e.push(s);
|
|
1410
|
+
else if (i) {
|
|
1411
|
+
let a = {
|
|
1412
|
+
name: n,
|
|
1413
|
+
label: o(r.objectName, n, i.label || t),
|
|
1414
|
+
type: f(i.type),
|
|
1415
|
+
required: i.required || !1,
|
|
1416
|
+
disabled: r.readOnly || r.mode === "view" || i.readonly,
|
|
1417
|
+
placeholder: i.placeholder,
|
|
1418
|
+
description: i.help || i.description,
|
|
1419
|
+
validation: l(i),
|
|
1420
|
+
field: i
|
|
1421
|
+
};
|
|
1422
|
+
if ((i.type === "select" || i.type === "lookup" || i.type === "master_detail") && (a.options = i.options || [], a.multiple = i.multiple), (i.type === "number" || i.type === "currency" || i.type === "percent") && (a.inputType = "number", a.min = i.min, a.max = i.max, a.step = i.precision ? 10 ** -i.precision : void 0), i.type === "date" && (a.inputType = "date"), i.type === "datetime" && (a.inputType = "datetime-local"), (i.type === "text" || i.type === "textarea" || i.type === "markdown" || i.type === "html") && (a.maxLength = i.max_length, a.minLength = i.min_length), (i.type === "file" || i.type === "image") && (a.inputType = "file", a.multiple = i.multiple, a.accept = i.accept ? i.accept.join(",") : void 0, i.max_size)) {
|
|
1423
|
+
let e = `Max size: ${d(i.max_size)}`;
|
|
1424
|
+
a.description = a.description ? `${a.description} (${e})` : e;
|
|
1425
|
+
}
|
|
1426
|
+
i.type === "email" && (a.inputType = "email"), i.type === "phone" && (a.inputType = "tel"), i.type === "url" && (a.inputType = "url"), i.type === "password" && (a.inputType = "password"), i.type === "time" && (a.inputType = "time"), (i.type === "formula" || i.type === "summary" || i.type === "auto_number") && (a.disabled = !0), i.visible_on && (a.visible = (e) => u(i.visible_on, e)), e.push(a);
|
|
1427
|
+
}
|
|
1428
|
+
}), g(e), !C && r.recordId && r.mode !== "create" && i || b(!1);
|
|
1429
|
+
}, [
|
|
1430
|
+
p,
|
|
1431
|
+
r.fields,
|
|
1432
|
+
r.customFields,
|
|
1433
|
+
r.readOnly,
|
|
1434
|
+
r.mode,
|
|
1435
|
+
C,
|
|
1436
|
+
r.recordId,
|
|
1437
|
+
i
|
|
1438
|
+
]);
|
|
1439
|
+
let w = t(async (e, t) => {
|
|
1440
|
+
if (e && (e.nativeEvent || e._reactName === "onSubmit") && (console.warn("ObjectForm: Received Event instead of data in handleSubmit! This suggests a Form renderer issue."), t === void 0 && (t = e, e = {})), C && !i) return r.onSuccess && await r.onSuccess(e), e;
|
|
1441
|
+
if (!i) throw Error("DataSource is required for form submission (inline mode not configured)");
|
|
1442
|
+
try {
|
|
1443
|
+
let t;
|
|
1444
|
+
if (r.mode === "create") t = await i.create(r.objectName, e);
|
|
1445
|
+
else if (r.mode === "edit" && r.recordId) t = await i.update(r.objectName, r.recordId, e);
|
|
1446
|
+
else throw Error("Invalid form mode or missing record ID");
|
|
1447
|
+
return r.onSuccess && await r.onSuccess(t), t;
|
|
1448
|
+
} catch (e) {
|
|
1449
|
+
throw console.error("Failed to submit form:", e), r.onError && r.onError(e), e;
|
|
1450
|
+
}
|
|
1451
|
+
}, [
|
|
1452
|
+
r,
|
|
1453
|
+
i,
|
|
1454
|
+
C
|
|
1455
|
+
]), T = t(() => {
|
|
1456
|
+
r.onCancel && r.onCancel();
|
|
1457
|
+
}, [r]), E = {
|
|
1458
|
+
...e.useMemo(() => {
|
|
1459
|
+
if (!p?.fields) return {};
|
|
1460
|
+
let e = {};
|
|
1461
|
+
return Object.keys(p.fields).forEach((t) => {
|
|
1462
|
+
let n = p.fields[t];
|
|
1463
|
+
n.defaultValue !== void 0 && (e[t] = n.defaultValue);
|
|
1464
|
+
}), e;
|
|
1465
|
+
}, [p]),
|
|
1466
|
+
..._
|
|
1467
|
+
};
|
|
1468
|
+
if (x) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1469
|
+
className: "p-3 sm:p-4 border border-red-300 bg-red-50 rounded-md",
|
|
1470
|
+
children: [/* @__PURE__ */ (0, K.jsx)("h3", {
|
|
1471
|
+
className: "text-red-800 font-semibold",
|
|
1472
|
+
children: "Error loading form"
|
|
1473
|
+
}), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
1474
|
+
className: "text-red-600 text-sm mt-1",
|
|
1475
|
+
children: x.message
|
|
1476
|
+
})]
|
|
1477
|
+
});
|
|
1478
|
+
if (y) return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1479
|
+
className: "p-4 sm:p-8 text-center",
|
|
1480
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", { className: "inline-block animate-spin rounded-full h-8 w-8 border-b-2 border-gray-900" }), /* @__PURE__ */ (0, K.jsx)("p", {
|
|
1481
|
+
className: "mt-2 text-sm text-gray-600",
|
|
1482
|
+
children: "Loading form..."
|
|
1483
|
+
})]
|
|
1484
|
+
});
|
|
1485
|
+
let D = r.layout === "vertical" || r.layout === "horizontal" ? r.layout : "vertical";
|
|
1486
|
+
if (r.sections?.length && (!r.formType || r.formType === "simple")) return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1487
|
+
className: "w-full space-y-6",
|
|
1488
|
+
children: r.sections.map((e, t) => {
|
|
1489
|
+
let n = e.fields.map((e) => typeof e == "string" ? e : e.name), i = h.filter((e) => n.includes(e.name));
|
|
1490
|
+
return /* @__PURE__ */ (0, K.jsx)(q, {
|
|
1491
|
+
label: e.label,
|
|
1492
|
+
description: e.description,
|
|
1493
|
+
collapsible: e.collapsible,
|
|
1494
|
+
collapsed: e.collapsed,
|
|
1495
|
+
columns: e.columns,
|
|
1496
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
1497
|
+
type: "form",
|
|
1498
|
+
fields: i,
|
|
1499
|
+
layout: D,
|
|
1500
|
+
defaultValues: E,
|
|
1501
|
+
showSubmit: t === r.sections.length - 1 && r.showSubmit !== !1 && r.mode !== "view",
|
|
1502
|
+
showCancel: t === r.sections.length - 1 && r.showCancel !== !1,
|
|
1503
|
+
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1504
|
+
cancelLabel: r.cancelText,
|
|
1505
|
+
onSubmit: w,
|
|
1506
|
+
onCancel: T
|
|
1507
|
+
} })
|
|
1508
|
+
}, e.name || e.label || t);
|
|
1509
|
+
})
|
|
1510
|
+
});
|
|
1511
|
+
let O = r.sections?.length ? {
|
|
1512
|
+
fields: h,
|
|
1513
|
+
columns: r.columns
|
|
1514
|
+
} : Q(h, p, r.columns, r.mode);
|
|
1515
|
+
return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1516
|
+
className: "w-full",
|
|
1517
|
+
children: /* @__PURE__ */ (0, K.jsx)(s, { schema: {
|
|
1518
|
+
type: "form",
|
|
1519
|
+
fields: O.fields,
|
|
1520
|
+
layout: D,
|
|
1521
|
+
columns: O.columns,
|
|
1522
|
+
submitLabel: r.submitText || (r.mode === "create" ? "Create" : "Update"),
|
|
1523
|
+
cancelLabel: r.cancelText,
|
|
1524
|
+
showSubmit: r.showSubmit !== !1 && r.mode !== "view",
|
|
1525
|
+
showCancel: r.showCancel !== !1,
|
|
1526
|
+
resetOnSubmit: r.showReset,
|
|
1527
|
+
defaultValues: E,
|
|
1528
|
+
onSubmit: w,
|
|
1529
|
+
onCancel: T,
|
|
1530
|
+
className: r.className
|
|
1531
|
+
} })
|
|
1532
|
+
});
|
|
1533
|
+
}, me = ({ config: e, dataSource: n, prefillParams: r, className: o }) => {
|
|
1534
|
+
let [s, c] = a(!1), [l, u] = a(!1), [d, f] = a(null), p = i(() => {
|
|
1535
|
+
let e = {};
|
|
1536
|
+
if (r) for (let [t, n] of Object.entries(r)) e[t] = n;
|
|
1537
|
+
return typeof window < "u" && new URLSearchParams(window.location.search).forEach((t, n) => {
|
|
1538
|
+
n in e || (e[n] = t);
|
|
1539
|
+
}), Object.keys(e).length > 0 ? e : void 0;
|
|
1540
|
+
}, [r]), m = t(async (t) => {
|
|
1541
|
+
u(!0), f(null);
|
|
1542
|
+
try {
|
|
1543
|
+
if (n && await n.create(e.objectName, t), c(!0), e.thankYouPage?.redirectUrl) {
|
|
1544
|
+
let t = e.thankYouPage.redirectDelay ?? 3e3;
|
|
1545
|
+
setTimeout(() => {
|
|
1546
|
+
window.location.href = e.thankYouPage.redirectUrl;
|
|
1547
|
+
}, t);
|
|
1548
|
+
}
|
|
1549
|
+
} catch (e) {
|
|
1550
|
+
f(e instanceof Error ? e.message : "Failed to submit form. Please try again.");
|
|
1551
|
+
} finally {
|
|
1552
|
+
u(!1);
|
|
1553
|
+
}
|
|
1554
|
+
}, [n, e]), h = t(() => {
|
|
1555
|
+
c(!1), f(null);
|
|
1556
|
+
}, []), g = i(() => {
|
|
1557
|
+
let t = {};
|
|
1558
|
+
return e.branding?.backgroundColor && (t.backgroundColor = e.branding.backgroundColor), t;
|
|
1559
|
+
}, [e.branding]);
|
|
1560
|
+
if (s) {
|
|
1561
|
+
let t = e.thankYouPage;
|
|
1562
|
+
return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1563
|
+
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1564
|
+
style: g,
|
|
1565
|
+
children: /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1566
|
+
className: "max-w-md w-full bg-card rounded-lg shadow-lg p-8 text-center space-y-4",
|
|
1567
|
+
children: [
|
|
1568
|
+
/* @__PURE__ */ (0, K.jsx)("div", {
|
|
1569
|
+
className: "text-4xl",
|
|
1570
|
+
children: "✓"
|
|
1571
|
+
}),
|
|
1572
|
+
/* @__PURE__ */ (0, K.jsx)("h2", {
|
|
1573
|
+
className: "text-xl font-semibold text-foreground",
|
|
1574
|
+
children: t?.title || "Thank You!"
|
|
1575
|
+
}),
|
|
1576
|
+
/* @__PURE__ */ (0, K.jsx)("p", {
|
|
1577
|
+
className: "text-muted-foreground",
|
|
1578
|
+
children: t?.message || "Your submission has been received successfully."
|
|
1579
|
+
}),
|
|
1580
|
+
e.allowMultiple && /* @__PURE__ */ (0, K.jsx)("button", {
|
|
1581
|
+
onClick: h,
|
|
1582
|
+
className: "mt-4 px-4 py-2 text-sm font-medium rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors",
|
|
1583
|
+
children: "Submit Another Response"
|
|
1584
|
+
}),
|
|
1585
|
+
t?.redirectUrl && /* @__PURE__ */ (0, K.jsxs)("p", {
|
|
1586
|
+
className: "text-xs text-muted-foreground",
|
|
1587
|
+
children: [
|
|
1588
|
+
"Redirecting in ",
|
|
1589
|
+
Math.ceil((t.redirectDelay ?? 3e3) / 1e3),
|
|
1590
|
+
" seconds..."
|
|
1591
|
+
]
|
|
1592
|
+
})
|
|
1593
|
+
]
|
|
1594
|
+
})
|
|
1595
|
+
});
|
|
1596
|
+
}
|
|
1597
|
+
return /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1598
|
+
className: `min-h-screen flex items-center justify-center p-4 ${o || ""}`,
|
|
1599
|
+
style: g,
|
|
1600
|
+
children: /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1601
|
+
className: "max-w-2xl w-full bg-card rounded-lg shadow-lg overflow-hidden",
|
|
1602
|
+
children: [
|
|
1603
|
+
/* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1604
|
+
className: "p-6 border-b",
|
|
1605
|
+
style: e.branding?.primaryColor ? { borderBottomColor: e.branding.primaryColor } : void 0,
|
|
1606
|
+
children: [
|
|
1607
|
+
e.branding?.logo && /* @__PURE__ */ (0, K.jsx)("img", {
|
|
1608
|
+
src: e.branding.logo,
|
|
1609
|
+
alt: "Logo",
|
|
1610
|
+
className: "h-8 mb-4"
|
|
1611
|
+
}),
|
|
1612
|
+
e.title && /* @__PURE__ */ (0, K.jsx)("h1", {
|
|
1613
|
+
className: "text-xl font-semibold text-foreground",
|
|
1614
|
+
children: e.title
|
|
1615
|
+
}),
|
|
1616
|
+
e.description && /* @__PURE__ */ (0, K.jsx)("p", {
|
|
1617
|
+
className: "text-sm text-muted-foreground mt-1",
|
|
1618
|
+
children: e.description
|
|
1619
|
+
})
|
|
1620
|
+
]
|
|
1621
|
+
}),
|
|
1622
|
+
/* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1623
|
+
className: "p-6",
|
|
1624
|
+
children: [d && /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1625
|
+
className: "mb-4 p-3 bg-destructive/10 border border-destructive/30 rounded-md text-sm text-destructive",
|
|
1626
|
+
children: d
|
|
1627
|
+
}), /* @__PURE__ */ (0, K.jsx)($, {
|
|
1628
|
+
schema: {
|
|
1629
|
+
type: "object-form",
|
|
1630
|
+
objectName: e.objectName,
|
|
1631
|
+
mode: "create",
|
|
1632
|
+
fields: e.fields,
|
|
1633
|
+
customFields: e.customFields,
|
|
1634
|
+
initialData: p,
|
|
1635
|
+
onSuccess: m,
|
|
1636
|
+
submitLabel: l ? "Submitting..." : "Submit"
|
|
1637
|
+
},
|
|
1638
|
+
dataSource: n
|
|
1639
|
+
})]
|
|
1640
|
+
}),
|
|
1641
|
+
/* @__PURE__ */ (0, K.jsx)("div", {
|
|
1642
|
+
className: "px-6 py-3 border-t bg-muted/20 text-center",
|
|
1643
|
+
children: /* @__PURE__ */ (0, K.jsx)("p", {
|
|
1644
|
+
className: "text-xs text-muted-foreground",
|
|
1645
|
+
children: "Powered by ObjectStack"
|
|
1646
|
+
})
|
|
1647
|
+
})
|
|
1648
|
+
]
|
|
1649
|
+
})
|
|
1650
|
+
});
|
|
1699
1651
|
};
|
|
1700
|
-
|
|
1701
|
-
|
|
1652
|
+
//#endregion
|
|
1653
|
+
//#region src/FormAnalytics.tsx
|
|
1654
|
+
function he(e) {
|
|
1655
|
+
return e < 60 ? `${Math.round(e)}s` : e < 3600 ? `${Math.floor(e / 60)}m ${Math.round(e % 60)}s` : `${Math.floor(e / 3600)}h ${Math.floor(e % 3600 / 60)}m`;
|
|
1702
1656
|
}
|
|
1703
|
-
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
}) =>
|
|
1709
|
-
|
|
1710
|
-
|
|
1711
|
-
|
|
1712
|
-
|
|
1713
|
-
|
|
1714
|
-
|
|
1715
|
-
|
|
1716
|
-
|
|
1717
|
-
|
|
1718
|
-
|
|
1719
|
-
|
|
1720
|
-
|
|
1721
|
-
|
|
1722
|
-
|
|
1723
|
-
|
|
1724
|
-
|
|
1725
|
-
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
-
|
|
1729
|
-
|
|
1730
|
-
|
|
1731
|
-
|
|
1732
|
-
|
|
1733
|
-
|
|
1734
|
-
|
|
1735
|
-
|
|
1736
|
-
|
|
1737
|
-
|
|
1738
|
-
|
|
1739
|
-
|
|
1740
|
-
|
|
1741
|
-
|
|
1742
|
-
|
|
1743
|
-
|
|
1744
|
-
|
|
1745
|
-
|
|
1746
|
-
|
|
1747
|
-
|
|
1748
|
-
|
|
1749
|
-
|
|
1750
|
-
|
|
1751
|
-
|
|
1752
|
-
|
|
1753
|
-
|
|
1754
|
-
|
|
1755
|
-
|
|
1756
|
-
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1760
|
-
|
|
1761
|
-
|
|
1762
|
-
|
|
1763
|
-
|
|
1764
|
-
|
|
1765
|
-
|
|
1766
|
-
|
|
1767
|
-
|
|
1768
|
-
|
|
1769
|
-
|
|
1770
|
-
|
|
1771
|
-
|
|
1772
|
-
|
|
1773
|
-
|
|
1774
|
-
|
|
1775
|
-
|
|
1776
|
-
|
|
1777
|
-
|
|
1778
|
-
|
|
1779
|
-
|
|
1780
|
-
|
|
1781
|
-
|
|
1782
|
-
|
|
1783
|
-
|
|
1784
|
-
|
|
1785
|
-
|
|
1786
|
-
|
|
1787
|
-
|
|
1788
|
-
|
|
1789
|
-
|
|
1790
|
-
|
|
1791
|
-
|
|
1792
|
-
|
|
1793
|
-
|
|
1794
|
-
|
|
1795
|
-
|
|
1796
|
-
|
|
1797
|
-
|
|
1798
|
-
|
|
1799
|
-
|
|
1800
|
-
|
|
1801
|
-
|
|
1802
|
-
|
|
1803
|
-
|
|
1804
|
-
|
|
1805
|
-
|
|
1806
|
-
|
|
1807
|
-
|
|
1808
|
-
|
|
1809
|
-
|
|
1810
|
-
|
|
1811
|
-
|
|
1812
|
-
|
|
1813
|
-
|
|
1814
|
-
|
|
1815
|
-
|
|
1816
|
-
|
|
1817
|
-
|
|
1818
|
-
|
|
1819
|
-
|
|
1820
|
-
|
|
1821
|
-
|
|
1822
|
-
|
|
1823
|
-
|
|
1824
|
-
|
|
1825
|
-
|
|
1826
|
-
|
|
1657
|
+
var ge = ({ formId: e, formTitle: t, metrics: n, className: r }) => {
|
|
1658
|
+
let a = i(() => {
|
|
1659
|
+
if (!n.abandonedSubmissions) return 100;
|
|
1660
|
+
let e = n.totalSubmissions + n.abandonedSubmissions;
|
|
1661
|
+
return e === 0 ? 0 : Math.round(n.totalSubmissions / e * 100);
|
|
1662
|
+
}, [n.totalSubmissions, n.abandonedSubmissions]), o = i(() => n.dailySubmissions?.length ? Math.max(...n.dailySubmissions.map((e) => e.count), 1) : 1, [n.dailySubmissions]);
|
|
1663
|
+
return /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1664
|
+
className: `space-y-4 ${r || ""}`,
|
|
1665
|
+
children: [
|
|
1666
|
+
/* @__PURE__ */ (0, K.jsxs)("div", { children: [/* @__PURE__ */ (0, K.jsx)("h2", {
|
|
1667
|
+
className: "text-lg font-semibold text-foreground",
|
|
1668
|
+
children: t || "Form Analytics"
|
|
1669
|
+
}), /* @__PURE__ */ (0, K.jsxs)("p", {
|
|
1670
|
+
className: "text-sm text-muted-foreground",
|
|
1671
|
+
children: ["Form ID: ", e]
|
|
1672
|
+
})] }),
|
|
1673
|
+
/* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1674
|
+
className: "grid grid-cols-1 sm:grid-cols-3 gap-4",
|
|
1675
|
+
children: [
|
|
1676
|
+
/* @__PURE__ */ (0, K.jsx)(m, { children: /* @__PURE__ */ (0, K.jsxs)(_, {
|
|
1677
|
+
className: "pb-2",
|
|
1678
|
+
children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Total Submissions" }), /* @__PURE__ */ (0, K.jsx)(v, {
|
|
1679
|
+
className: "text-2xl",
|
|
1680
|
+
children: n.totalSubmissions.toLocaleString()
|
|
1681
|
+
})]
|
|
1682
|
+
}) }),
|
|
1683
|
+
/* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsxs)(_, {
|
|
1684
|
+
className: "pb-2",
|
|
1685
|
+
children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Fill Rate" }), /* @__PURE__ */ (0, K.jsxs)(v, {
|
|
1686
|
+
className: "text-2xl",
|
|
1687
|
+
children: [a, "%"]
|
|
1688
|
+
})]
|
|
1689
|
+
}), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1690
|
+
className: "w-full bg-muted rounded-full h-2",
|
|
1691
|
+
children: /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1692
|
+
className: "bg-primary rounded-full h-2 transition-all",
|
|
1693
|
+
style: { width: `${a}%` }
|
|
1694
|
+
})
|
|
1695
|
+
}) })] }),
|
|
1696
|
+
/* @__PURE__ */ (0, K.jsx)(m, { children: /* @__PURE__ */ (0, K.jsxs)(_, {
|
|
1697
|
+
className: "pb-2",
|
|
1698
|
+
children: [/* @__PURE__ */ (0, K.jsx)(g, { children: "Avg. Completion Time" }), /* @__PURE__ */ (0, K.jsx)(v, {
|
|
1699
|
+
className: "text-2xl",
|
|
1700
|
+
children: n.avgCompletionTime ? he(n.avgCompletionTime) : "—"
|
|
1701
|
+
})]
|
|
1702
|
+
}) })
|
|
1703
|
+
]
|
|
1704
|
+
}),
|
|
1705
|
+
n.dailySubmissions && n.dailySubmissions.length > 0 && /* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsx)(_, { children: /* @__PURE__ */ (0, K.jsx)(v, {
|
|
1706
|
+
className: "text-sm font-medium",
|
|
1707
|
+
children: "Daily Submissions"
|
|
1708
|
+
}) }), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1709
|
+
className: "flex items-end gap-1 h-32",
|
|
1710
|
+
children: n.dailySubmissions.map((e, t) => /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1711
|
+
className: "flex-1 flex flex-col items-center gap-1",
|
|
1712
|
+
children: [/* @__PURE__ */ (0, K.jsx)("div", {
|
|
1713
|
+
className: "w-full bg-primary/80 rounded-t transition-all hover:bg-primary",
|
|
1714
|
+
style: {
|
|
1715
|
+
height: `${e.count / o * 100}%`,
|
|
1716
|
+
minHeight: e.count > 0 ? "4px" : "0"
|
|
1717
|
+
},
|
|
1718
|
+
title: `${e.date}: ${e.count} submissions`
|
|
1719
|
+
}), /* @__PURE__ */ (0, K.jsx)("span", {
|
|
1720
|
+
className: "text-[10px] text-muted-foreground truncate w-full text-center",
|
|
1721
|
+
children: e.date.slice(-5)
|
|
1722
|
+
})]
|
|
1723
|
+
}, t))
|
|
1724
|
+
}) })] }),
|
|
1725
|
+
n.fieldDropOff && n.fieldDropOff.length > 0 && /* @__PURE__ */ (0, K.jsxs)(m, { children: [/* @__PURE__ */ (0, K.jsxs)(_, { children: [/* @__PURE__ */ (0, K.jsx)(v, {
|
|
1726
|
+
className: "text-sm font-medium",
|
|
1727
|
+
children: "Field Completion Rates"
|
|
1728
|
+
}), /* @__PURE__ */ (0, K.jsx)(g, { children: "Percentage of users who completed each field" })] }), /* @__PURE__ */ (0, K.jsx)(h, { children: /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1729
|
+
className: "space-y-3",
|
|
1730
|
+
children: n.fieldDropOff.map((e, t) => /* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1731
|
+
className: "space-y-1",
|
|
1732
|
+
children: [/* @__PURE__ */ (0, K.jsxs)("div", {
|
|
1733
|
+
className: "flex justify-between text-sm",
|
|
1734
|
+
children: [/* @__PURE__ */ (0, K.jsx)("span", {
|
|
1735
|
+
className: "text-foreground",
|
|
1736
|
+
children: e.label
|
|
1737
|
+
}), /* @__PURE__ */ (0, K.jsxs)("span", {
|
|
1738
|
+
className: "text-muted-foreground",
|
|
1739
|
+
children: [e.completionRate, "%"]
|
|
1740
|
+
})]
|
|
1741
|
+
}), /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1742
|
+
className: "w-full bg-muted rounded-full h-1.5",
|
|
1743
|
+
children: /* @__PURE__ */ (0, K.jsx)("div", {
|
|
1744
|
+
className: `rounded-full h-1.5 transition-all ${e.completionRate >= 80 ? "bg-green-500" : e.completionRate >= 50 ? "bg-yellow-500" : "bg-destructive"}`,
|
|
1745
|
+
style: { width: `${e.completionRate}%` }
|
|
1746
|
+
})
|
|
1747
|
+
})]
|
|
1748
|
+
}, t))
|
|
1749
|
+
}) })] })
|
|
1750
|
+
]
|
|
1751
|
+
});
|
|
1752
|
+
}, _e = ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)($, { schema: e });
|
|
1753
|
+
o.register("object-form", _e, {
|
|
1754
|
+
namespace: "plugin-form",
|
|
1755
|
+
label: "Object Form",
|
|
1756
|
+
category: "plugin",
|
|
1757
|
+
inputs: [
|
|
1758
|
+
{
|
|
1759
|
+
name: "objectName",
|
|
1760
|
+
type: "string",
|
|
1761
|
+
label: "Object Name",
|
|
1762
|
+
required: !0
|
|
1763
|
+
},
|
|
1764
|
+
{
|
|
1765
|
+
name: "fields",
|
|
1766
|
+
type: "array",
|
|
1767
|
+
label: "Fields"
|
|
1768
|
+
},
|
|
1769
|
+
{
|
|
1770
|
+
name: "mode",
|
|
1771
|
+
type: "enum",
|
|
1772
|
+
label: "Mode",
|
|
1773
|
+
enum: [
|
|
1774
|
+
"create",
|
|
1775
|
+
"edit",
|
|
1776
|
+
"view"
|
|
1777
|
+
]
|
|
1778
|
+
},
|
|
1779
|
+
{
|
|
1780
|
+
name: "formType",
|
|
1781
|
+
type: "enum",
|
|
1782
|
+
label: "Form Type",
|
|
1783
|
+
enum: [
|
|
1784
|
+
"simple",
|
|
1785
|
+
"tabbed",
|
|
1786
|
+
"wizard",
|
|
1787
|
+
"split",
|
|
1788
|
+
"drawer",
|
|
1789
|
+
"modal"
|
|
1790
|
+
]
|
|
1791
|
+
},
|
|
1792
|
+
{
|
|
1793
|
+
name: "sections",
|
|
1794
|
+
type: "array",
|
|
1795
|
+
label: "Sections"
|
|
1796
|
+
},
|
|
1797
|
+
{
|
|
1798
|
+
name: "title",
|
|
1799
|
+
type: "string",
|
|
1800
|
+
label: "Title"
|
|
1801
|
+
},
|
|
1802
|
+
{
|
|
1803
|
+
name: "description",
|
|
1804
|
+
type: "string",
|
|
1805
|
+
label: "Description"
|
|
1806
|
+
},
|
|
1807
|
+
{
|
|
1808
|
+
name: "layout",
|
|
1809
|
+
type: "enum",
|
|
1810
|
+
label: "Layout",
|
|
1811
|
+
enum: [
|
|
1812
|
+
"vertical",
|
|
1813
|
+
"horizontal",
|
|
1814
|
+
"inline",
|
|
1815
|
+
"grid"
|
|
1816
|
+
]
|
|
1817
|
+
},
|
|
1818
|
+
{
|
|
1819
|
+
name: "columns",
|
|
1820
|
+
type: "number",
|
|
1821
|
+
label: "Columns"
|
|
1822
|
+
},
|
|
1823
|
+
{
|
|
1824
|
+
name: "defaultTab",
|
|
1825
|
+
type: "string",
|
|
1826
|
+
label: "Default Tab"
|
|
1827
|
+
},
|
|
1828
|
+
{
|
|
1829
|
+
name: "tabPosition",
|
|
1830
|
+
type: "enum",
|
|
1831
|
+
label: "Tab Position",
|
|
1832
|
+
enum: [
|
|
1833
|
+
"top",
|
|
1834
|
+
"bottom",
|
|
1835
|
+
"left",
|
|
1836
|
+
"right"
|
|
1837
|
+
]
|
|
1838
|
+
},
|
|
1839
|
+
{
|
|
1840
|
+
name: "allowSkip",
|
|
1841
|
+
type: "boolean",
|
|
1842
|
+
label: "Allow Skip Steps"
|
|
1843
|
+
},
|
|
1844
|
+
{
|
|
1845
|
+
name: "showStepIndicator",
|
|
1846
|
+
type: "boolean",
|
|
1847
|
+
label: "Show Step Indicator"
|
|
1848
|
+
},
|
|
1849
|
+
{
|
|
1850
|
+
name: "splitDirection",
|
|
1851
|
+
type: "enum",
|
|
1852
|
+
label: "Split Direction",
|
|
1853
|
+
enum: ["horizontal", "vertical"]
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
name: "splitSize",
|
|
1857
|
+
type: "number",
|
|
1858
|
+
label: "Split Panel Size (%)"
|
|
1859
|
+
},
|
|
1860
|
+
{
|
|
1861
|
+
name: "splitResizable",
|
|
1862
|
+
type: "boolean",
|
|
1863
|
+
label: "Split Resizable"
|
|
1864
|
+
},
|
|
1865
|
+
{
|
|
1866
|
+
name: "drawerSide",
|
|
1867
|
+
type: "enum",
|
|
1868
|
+
label: "Drawer Side",
|
|
1869
|
+
enum: [
|
|
1870
|
+
"top",
|
|
1871
|
+
"bottom",
|
|
1872
|
+
"left",
|
|
1873
|
+
"right"
|
|
1874
|
+
]
|
|
1875
|
+
},
|
|
1876
|
+
{
|
|
1877
|
+
name: "drawerWidth",
|
|
1878
|
+
type: "string",
|
|
1879
|
+
label: "Drawer Width"
|
|
1880
|
+
},
|
|
1881
|
+
{
|
|
1882
|
+
name: "modalSize",
|
|
1883
|
+
type: "enum",
|
|
1884
|
+
label: "Modal Size",
|
|
1885
|
+
enum: [
|
|
1886
|
+
"sm",
|
|
1887
|
+
"default",
|
|
1888
|
+
"lg",
|
|
1889
|
+
"xl",
|
|
1890
|
+
"full"
|
|
1891
|
+
]
|
|
1892
|
+
}
|
|
1893
|
+
]
|
|
1894
|
+
}), o.register("form", _e, {
|
|
1895
|
+
namespace: "view",
|
|
1896
|
+
skipFallback: !0,
|
|
1897
|
+
label: "Data Form View",
|
|
1898
|
+
category: "view",
|
|
1899
|
+
inputs: [
|
|
1900
|
+
{
|
|
1901
|
+
name: "objectName",
|
|
1902
|
+
type: "string",
|
|
1903
|
+
label: "Object Name",
|
|
1904
|
+
required: !0
|
|
1905
|
+
},
|
|
1906
|
+
{
|
|
1907
|
+
name: "fields",
|
|
1908
|
+
type: "array",
|
|
1909
|
+
label: "Fields"
|
|
1910
|
+
},
|
|
1911
|
+
{
|
|
1912
|
+
name: "mode",
|
|
1913
|
+
type: "enum",
|
|
1914
|
+
label: "Mode",
|
|
1915
|
+
enum: [
|
|
1916
|
+
"create",
|
|
1917
|
+
"edit",
|
|
1918
|
+
"view"
|
|
1919
|
+
]
|
|
1920
|
+
}
|
|
1921
|
+
]
|
|
1922
|
+
}), o.register("embeddable-form", ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)(me, { config: e }), {
|
|
1923
|
+
namespace: "plugin-form",
|
|
1924
|
+
label: "Embeddable Form",
|
|
1925
|
+
category: "plugin",
|
|
1926
|
+
inputs: [
|
|
1927
|
+
{
|
|
1928
|
+
name: "formId",
|
|
1929
|
+
type: "string",
|
|
1930
|
+
label: "Form ID",
|
|
1931
|
+
required: !0
|
|
1932
|
+
},
|
|
1933
|
+
{
|
|
1934
|
+
name: "objectName",
|
|
1935
|
+
type: "string",
|
|
1936
|
+
label: "Object Name",
|
|
1937
|
+
required: !0
|
|
1938
|
+
},
|
|
1939
|
+
{
|
|
1940
|
+
name: "title",
|
|
1941
|
+
type: "string",
|
|
1942
|
+
label: "Form Title"
|
|
1943
|
+
},
|
|
1944
|
+
{
|
|
1945
|
+
name: "description",
|
|
1946
|
+
type: "string",
|
|
1947
|
+
label: "Description"
|
|
1948
|
+
},
|
|
1949
|
+
{
|
|
1950
|
+
name: "fields",
|
|
1951
|
+
type: "array",
|
|
1952
|
+
label: "Fields"
|
|
1953
|
+
},
|
|
1954
|
+
{
|
|
1955
|
+
name: "allowMultiple",
|
|
1956
|
+
type: "boolean",
|
|
1957
|
+
label: "Allow Multiple Submissions"
|
|
1958
|
+
}
|
|
1959
|
+
]
|
|
1960
|
+
}), o.register("form-analytics", ({ schema: e }) => /* @__PURE__ */ (0, K.jsx)(ge, {
|
|
1961
|
+
formId: e.formId,
|
|
1962
|
+
formTitle: e.formTitle,
|
|
1963
|
+
metrics: e.metrics || { totalSubmissions: 0 }
|
|
1964
|
+
}), {
|
|
1965
|
+
namespace: "plugin-form",
|
|
1966
|
+
label: "Form Analytics",
|
|
1967
|
+
category: "plugin",
|
|
1968
|
+
inputs: [
|
|
1969
|
+
{
|
|
1970
|
+
name: "formId",
|
|
1971
|
+
type: "string",
|
|
1972
|
+
label: "Form ID",
|
|
1973
|
+
required: !0
|
|
1974
|
+
},
|
|
1975
|
+
{
|
|
1976
|
+
name: "formTitle",
|
|
1977
|
+
type: "string",
|
|
1978
|
+
label: "Form Title"
|
|
1979
|
+
},
|
|
1980
|
+
{
|
|
1981
|
+
name: "metrics",
|
|
1982
|
+
type: "object",
|
|
1983
|
+
label: "Submission Metrics"
|
|
1984
|
+
}
|
|
1985
|
+
]
|
|
1827
1986
|
});
|
|
1828
|
-
|
|
1829
|
-
|
|
1830
|
-
namespace: "plugin-form",
|
|
1831
|
-
label: "Embeddable Form",
|
|
1832
|
-
category: "plugin",
|
|
1833
|
-
inputs: [
|
|
1834
|
-
{ name: "formId", type: "string", label: "Form ID", required: !0 },
|
|
1835
|
-
{ name: "objectName", type: "string", label: "Object Name", required: !0 },
|
|
1836
|
-
{ name: "title", type: "string", label: "Form Title" },
|
|
1837
|
-
{ name: "description", type: "string", label: "Description" },
|
|
1838
|
-
{ name: "fields", type: "array", label: "Fields" },
|
|
1839
|
-
{ name: "allowMultiple", type: "boolean", label: "Allow Multiple Submissions" }
|
|
1840
|
-
]
|
|
1841
|
-
});
|
|
1842
|
-
const yt = ({ schema: e }) => /* @__PURE__ */ t.jsx(bt, { formId: e.formId, formTitle: e.formTitle, metrics: e.metrics || { totalSubmissions: 0 } });
|
|
1843
|
-
ue.register("form-analytics", yt, {
|
|
1844
|
-
namespace: "plugin-form",
|
|
1845
|
-
label: "Form Analytics",
|
|
1846
|
-
category: "plugin",
|
|
1847
|
-
inputs: [
|
|
1848
|
-
{ name: "formId", type: "string", label: "Form ID", required: !0 },
|
|
1849
|
-
{ name: "formTitle", type: "string", label: "Form Title" },
|
|
1850
|
-
{ name: "metrics", type: "object", label: "Submission Metrics" }
|
|
1851
|
-
]
|
|
1852
|
-
});
|
|
1853
|
-
export {
|
|
1854
|
-
ct as DrawerForm,
|
|
1855
|
-
pt as EmbeddableForm,
|
|
1856
|
-
bt as FormAnalytics,
|
|
1857
|
-
te as FormSection,
|
|
1858
|
-
ut as ModalForm,
|
|
1859
|
-
he as ObjectForm,
|
|
1860
|
-
lt as SplitForm,
|
|
1861
|
-
tt as TabbedForm,
|
|
1862
|
-
rt as WizardForm,
|
|
1863
|
-
we as applyAutoColSpan,
|
|
1864
|
-
ce as applyAutoLayout,
|
|
1865
|
-
dt as filterCreateModeFields,
|
|
1866
|
-
at as inferColumns,
|
|
1867
|
-
Ne as inferModalSize,
|
|
1868
|
-
st as isAutoGeneratedFieldType,
|
|
1869
|
-
ot as isWideFieldType
|
|
1870
|
-
};
|
|
1987
|
+
//#endregion
|
|
1988
|
+
export { le as DrawerForm, me as EmbeddableForm, ge as FormAnalytics, q as FormSection, fe as ModalForm, $ as ObjectForm, te as SplitForm, J as TabbedForm, Y as WizardForm, X as applyAutoColSpan, Q as applyAutoLayout, se as filterCreateModeFields, oe as inferColumns, Z as inferModalSize, ae as isAutoGeneratedFieldType, ie as isWideFieldType };
|