@superdoc-dev/template-builder 1.1.0-next.9 → 1.2.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +18 -0
- package/dist/index.js +1 -1
- package/dist/index.mjs +987 -1102
- package/dist/types.d.ts +11 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1,1103 +1,988 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
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
|
-
"div",
|
|
375
|
-
{
|
|
376
|
-
className: "field-menu-item",
|
|
377
|
-
onClick: () => z(h),
|
|
378
|
-
style: {
|
|
379
|
-
padding: "8px 16px",
|
|
380
|
-
cursor: "pointer",
|
|
381
|
-
display: "flex",
|
|
382
|
-
alignItems: "flex-start",
|
|
383
|
-
justifyContent: "space-between",
|
|
384
|
-
gap: "8px"
|
|
385
|
-
},
|
|
386
|
-
children: [
|
|
387
|
-
/* @__PURE__ */ o("div", { style: { flex: 1, minWidth: 0 }, children: [
|
|
388
|
-
/* @__PURE__ */ r("div", { style: { fontWeight: 500, fontSize: "13px" }, children: h.label || h.id }),
|
|
389
|
-
/* @__PURE__ */ o(
|
|
390
|
-
"div",
|
|
391
|
-
{
|
|
392
|
-
style: {
|
|
393
|
-
fontSize: "11px",
|
|
394
|
-
color: "#9ca3af",
|
|
395
|
-
marginTop: "2px"
|
|
396
|
-
},
|
|
397
|
-
children: [
|
|
398
|
-
"ID: ",
|
|
399
|
-
h.id
|
|
400
|
-
]
|
|
401
|
-
}
|
|
402
|
-
)
|
|
403
|
-
] }),
|
|
404
|
-
/* @__PURE__ */ r(
|
|
405
|
-
"span",
|
|
406
|
-
{
|
|
407
|
-
style: {
|
|
408
|
-
fontSize: "11px",
|
|
409
|
-
color: "#6b7280",
|
|
410
|
-
padding: "2px 6px",
|
|
411
|
-
background: "#f3f4f6",
|
|
412
|
-
borderRadius: "3px",
|
|
413
|
-
textTransform: "capitalize",
|
|
414
|
-
flexShrink: 0
|
|
415
|
-
},
|
|
416
|
-
children: h.mode || "inline"
|
|
417
|
-
}
|
|
418
|
-
)
|
|
419
|
-
]
|
|
420
|
-
},
|
|
421
|
-
h.id
|
|
422
|
-
)) })
|
|
423
|
-
] }),
|
|
424
|
-
/* @__PURE__ */ r(
|
|
425
|
-
"div",
|
|
426
|
-
{
|
|
427
|
-
style: {
|
|
428
|
-
borderTop: "1px solid #eee",
|
|
429
|
-
marginTop: "4px"
|
|
430
|
-
},
|
|
431
|
-
children: /* @__PURE__ */ r(
|
|
432
|
-
"button",
|
|
433
|
-
{
|
|
434
|
-
onClick: P,
|
|
435
|
-
style: {
|
|
436
|
-
width: "100%",
|
|
437
|
-
padding: "6px 16px",
|
|
438
|
-
background: "#f3f4f6",
|
|
439
|
-
border: "none",
|
|
440
|
-
borderRadius: "0 0 4px 4px",
|
|
441
|
-
cursor: "pointer"
|
|
442
|
-
},
|
|
443
|
-
children: "Close"
|
|
444
|
-
}
|
|
445
|
-
)
|
|
446
|
-
}
|
|
447
|
-
)
|
|
448
|
-
] });
|
|
449
|
-
}, Le = (n) => {
|
|
450
|
-
const l = n.split("-");
|
|
451
|
-
return l.length > 2 ? l[l.length - 1].substring(0, 6) : n.substring(0, 6);
|
|
452
|
-
}, ve = ({ field: n, onSelect: l, onDelete: f, isSelected: s, isGrouped: c = !1 }) => /* @__PURE__ */ o(
|
|
453
|
-
"div",
|
|
454
|
-
{
|
|
455
|
-
onClick: () => l(n),
|
|
456
|
-
style: {
|
|
457
|
-
position: "relative",
|
|
458
|
-
padding: "10px 12px",
|
|
459
|
-
background: s ? "#eff6ff" : "#f9fafb",
|
|
460
|
-
border: s ? "1px solid #3b82f6" : "1px solid #e5e7eb",
|
|
461
|
-
borderRadius: "6px",
|
|
462
|
-
cursor: "pointer",
|
|
463
|
-
transition: "all 0.2s",
|
|
464
|
-
fontSize: c ? "13px" : "14px"
|
|
465
|
-
},
|
|
466
|
-
onMouseEnter: (a) => {
|
|
467
|
-
s || (a.currentTarget.style.background = "#f3f4f6");
|
|
468
|
-
},
|
|
469
|
-
onMouseLeave: (a) => {
|
|
470
|
-
s || (a.currentTarget.style.background = "#f9fafb");
|
|
471
|
-
},
|
|
472
|
-
title: n.alias,
|
|
473
|
-
children: [
|
|
474
|
-
/* @__PURE__ */ r(
|
|
475
|
-
"button",
|
|
476
|
-
{
|
|
477
|
-
onClick: (a) => {
|
|
478
|
-
a.stopPropagation(), f(n.id);
|
|
479
|
-
},
|
|
480
|
-
style: {
|
|
481
|
-
position: "absolute",
|
|
482
|
-
top: "6px",
|
|
483
|
-
right: "6px",
|
|
484
|
-
padding: "4px",
|
|
485
|
-
background: "transparent",
|
|
486
|
-
border: "none",
|
|
487
|
-
cursor: "pointer",
|
|
488
|
-
color: "#9ca3af",
|
|
489
|
-
transition: "color 0.2s",
|
|
490
|
-
display: "flex",
|
|
491
|
-
alignItems: "center",
|
|
492
|
-
justifyContent: "center"
|
|
493
|
-
},
|
|
494
|
-
onMouseEnter: (a) => {
|
|
495
|
-
a.currentTarget.style.color = "#ef4444";
|
|
496
|
-
},
|
|
497
|
-
onMouseLeave: (a) => {
|
|
498
|
-
a.currentTarget.style.color = "#9ca3af";
|
|
499
|
-
},
|
|
500
|
-
title: "Delete field",
|
|
501
|
-
children: /* @__PURE__ */ r("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ r(
|
|
502
|
-
"path",
|
|
503
|
-
{
|
|
504
|
-
d: "M6 2V1.5C6 1.22386 6.22386 1 6.5 1H9.5C9.77614 1 10 1.22386 10 1.5V2M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4",
|
|
505
|
-
stroke: "currentColor",
|
|
506
|
-
strokeWidth: "1.5",
|
|
507
|
-
strokeLinecap: "round",
|
|
508
|
-
strokeLinejoin: "round"
|
|
509
|
-
}
|
|
510
|
-
) })
|
|
511
|
-
}
|
|
512
|
-
),
|
|
513
|
-
/* @__PURE__ */ o("div", { style: { paddingRight: "24px" }, children: [
|
|
514
|
-
/* @__PURE__ */ r(
|
|
515
|
-
"div",
|
|
516
|
-
{
|
|
517
|
-
style: {
|
|
518
|
-
fontWeight: "500",
|
|
519
|
-
fontSize: c ? "12px" : "14px",
|
|
520
|
-
color: c ? "#6b7280" : "#111827"
|
|
521
|
-
},
|
|
522
|
-
children: n.alias || n.id
|
|
523
|
-
}
|
|
524
|
-
),
|
|
525
|
-
/* @__PURE__ */ o(
|
|
526
|
-
"div",
|
|
527
|
-
{
|
|
528
|
-
style: {
|
|
529
|
-
display: "flex",
|
|
530
|
-
alignItems: "center",
|
|
531
|
-
gap: "6px",
|
|
532
|
-
fontSize: "11px",
|
|
533
|
-
color: "#9ca3af",
|
|
534
|
-
marginTop: "2px"
|
|
535
|
-
},
|
|
536
|
-
children: [
|
|
537
|
-
/* @__PURE__ */ o("span", { children: [
|
|
538
|
-
"ID: ",
|
|
539
|
-
n.id
|
|
540
|
-
] }),
|
|
541
|
-
n.mode && /* @__PURE__ */ r(
|
|
542
|
-
"span",
|
|
543
|
-
{
|
|
544
|
-
style: {
|
|
545
|
-
fontSize: "9px",
|
|
546
|
-
padding: "2px 5px",
|
|
547
|
-
borderRadius: "3px",
|
|
548
|
-
background: n.mode === "block" ? "#dbeafe" : "#f3f4f6",
|
|
549
|
-
color: n.mode === "block" ? "#1e40af" : "#4b5563",
|
|
550
|
-
fontWeight: "500"
|
|
551
|
-
},
|
|
552
|
-
children: n.mode
|
|
553
|
-
}
|
|
554
|
-
)
|
|
555
|
-
]
|
|
556
|
-
}
|
|
557
|
-
)
|
|
558
|
-
] })
|
|
559
|
-
]
|
|
560
|
-
}
|
|
561
|
-
), Pe = ({ fields: n, onSelect: l, onDelete: f, selectedFieldId: s }) => {
|
|
562
|
-
const [c, a] = I(/* @__PURE__ */ new Set()), { groupedFields: z, ungroupedFields: P } = pe(() => {
|
|
563
|
-
const p = {}, E = [];
|
|
564
|
-
return n.forEach((x) => {
|
|
565
|
-
x.group ? (p[x.group] || (p[x.group] = []), p[x.group].push(x)) : E.push(x);
|
|
566
|
-
}), { groupedFields: p, ungroupedFields: E };
|
|
567
|
-
}, [n]), O = (p) => {
|
|
568
|
-
a((E) => {
|
|
569
|
-
const x = new Set(E);
|
|
570
|
-
return x.has(p) ? x.delete(p) : x.add(p), x;
|
|
571
|
-
});
|
|
572
|
-
};
|
|
573
|
-
return /* @__PURE__ */ o(
|
|
574
|
-
"div",
|
|
575
|
-
{
|
|
576
|
-
className: "superdoc-field-list",
|
|
577
|
-
style: {
|
|
578
|
-
width: "250px",
|
|
579
|
-
background: "white",
|
|
580
|
-
border: "1px solid #e5e7eb",
|
|
581
|
-
borderRadius: "8px",
|
|
582
|
-
padding: "16px"
|
|
583
|
-
},
|
|
584
|
-
children: [
|
|
585
|
-
/* @__PURE__ */ o("h3", { style: { margin: "0 0 16px 0", fontSize: "16px", fontWeight: "600" }, children: [
|
|
586
|
-
"Template Fields (",
|
|
587
|
-
n.length,
|
|
588
|
-
")"
|
|
589
|
-
] }),
|
|
590
|
-
n.length === 0 ? /* @__PURE__ */ o(
|
|
591
|
-
"div",
|
|
592
|
-
{
|
|
593
|
-
style: {
|
|
594
|
-
color: "#9ca3af",
|
|
595
|
-
fontSize: "14px",
|
|
596
|
-
textAlign: "center",
|
|
597
|
-
padding: "20px 0"
|
|
598
|
-
},
|
|
599
|
-
children: [
|
|
600
|
-
"No fields yet. Type ",
|
|
601
|
-
"{{",
|
|
602
|
-
" to add a field."
|
|
603
|
-
]
|
|
604
|
-
}
|
|
605
|
-
) : /* @__PURE__ */ o("div", { style: { display: "flex", flexDirection: "column", gap: "8px" }, children: [
|
|
606
|
-
P.map((p) => /* @__PURE__ */ r(
|
|
607
|
-
ve,
|
|
608
|
-
{
|
|
609
|
-
field: p,
|
|
610
|
-
onSelect: l,
|
|
611
|
-
onDelete: f,
|
|
612
|
-
isSelected: s === p.id
|
|
613
|
-
},
|
|
614
|
-
p.id
|
|
615
|
-
)),
|
|
616
|
-
Object.entries(z).map(([p, E]) => {
|
|
617
|
-
const x = c.has(p), y = E[0];
|
|
618
|
-
return /* @__PURE__ */ o("div", { children: [
|
|
619
|
-
/* @__PURE__ */ r(
|
|
620
|
-
"div",
|
|
621
|
-
{
|
|
622
|
-
style: {
|
|
623
|
-
position: "relative",
|
|
624
|
-
padding: "12px",
|
|
625
|
-
background: "#f9fafb",
|
|
626
|
-
border: "1px solid #e5e7eb",
|
|
627
|
-
borderRadius: "6px",
|
|
628
|
-
cursor: "pointer",
|
|
629
|
-
transition: "all 0.2s"
|
|
630
|
-
},
|
|
631
|
-
onClick: () => O(p),
|
|
632
|
-
onMouseEnter: (w) => {
|
|
633
|
-
w.currentTarget.style.background = "#f3f4f6";
|
|
634
|
-
},
|
|
635
|
-
onMouseLeave: (w) => {
|
|
636
|
-
w.currentTarget.style.background = "#f9fafb";
|
|
637
|
-
},
|
|
638
|
-
children: /* @__PURE__ */ o("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
639
|
-
/* @__PURE__ */ r("span", { style: { fontSize: "12px", color: "#6b7280" }, children: x ? "▼" : "▶" }),
|
|
640
|
-
/* @__PURE__ */ o("div", { style: { flex: 1 }, children: [
|
|
641
|
-
/* @__PURE__ */ r("div", { style: { fontWeight: "500", fontSize: "14px" }, children: y.alias }),
|
|
642
|
-
/* @__PURE__ */ o(
|
|
643
|
-
"div",
|
|
644
|
-
{
|
|
645
|
-
style: {
|
|
646
|
-
fontSize: "11px",
|
|
647
|
-
color: "#9ca3af",
|
|
648
|
-
marginTop: "2px"
|
|
649
|
-
},
|
|
650
|
-
children: [
|
|
651
|
-
"group: ",
|
|
652
|
-
Le(p),
|
|
653
|
-
" (",
|
|
654
|
-
E.length,
|
|
655
|
-
" fields)"
|
|
656
|
-
]
|
|
657
|
-
}
|
|
658
|
-
)
|
|
659
|
-
] })
|
|
660
|
-
] })
|
|
661
|
-
}
|
|
662
|
-
),
|
|
663
|
-
x && /* @__PURE__ */ r(
|
|
664
|
-
"div",
|
|
665
|
-
{
|
|
666
|
-
style: {
|
|
667
|
-
marginLeft: "16px",
|
|
668
|
-
marginTop: "4px",
|
|
669
|
-
display: "flex",
|
|
670
|
-
flexDirection: "column",
|
|
671
|
-
gap: "4px"
|
|
672
|
-
},
|
|
673
|
-
children: E.map((w) => /* @__PURE__ */ r(
|
|
674
|
-
ve,
|
|
675
|
-
{
|
|
676
|
-
field: w,
|
|
677
|
-
onSelect: l,
|
|
678
|
-
onDelete: f,
|
|
679
|
-
isSelected: s === w.id,
|
|
680
|
-
isGrouped: !0
|
|
681
|
-
},
|
|
682
|
-
w.id
|
|
683
|
-
))
|
|
684
|
-
}
|
|
685
|
-
)
|
|
686
|
-
] }, p);
|
|
687
|
-
})
|
|
688
|
-
] })
|
|
689
|
-
]
|
|
690
|
-
}
|
|
691
|
-
);
|
|
692
|
-
}, Q = (n) => {
|
|
693
|
-
const l = n.helpers?.structuredContentCommands;
|
|
694
|
-
return l?.getStructuredContentTags ? (l.getStructuredContentTags(n.state) || []).map((s) => {
|
|
695
|
-
const c = s?.node ?? s, a = c?.attrs ?? {}, P = (c?.type?.name || "").includes("Block") ? "block" : "inline";
|
|
696
|
-
return {
|
|
697
|
-
id: a.id,
|
|
698
|
-
alias: a.alias || a.label || "",
|
|
699
|
-
tag: a.tag,
|
|
700
|
-
mode: P,
|
|
701
|
-
group: l.getGroup?.(a.tag) ?? void 0
|
|
702
|
-
};
|
|
703
|
-
}) : [];
|
|
704
|
-
}, Fe = (n, l) => {
|
|
705
|
-
if (n === l) return !0;
|
|
706
|
-
if (n.length !== l.length) return !1;
|
|
707
|
-
for (let f = 0; f < n.length; f += 1) {
|
|
708
|
-
const s = n[f], c = l[f];
|
|
709
|
-
if (!c || s.id !== c.id || s.alias !== c.alias || s.tag !== c.tag || s.position !== c.position || s.mode !== c.mode || s.group !== c.group)
|
|
710
|
-
return !1;
|
|
711
|
-
}
|
|
712
|
-
return !0;
|
|
713
|
-
}, Ae = (n) => {
|
|
714
|
-
if (!n) return null;
|
|
715
|
-
if (n === !0)
|
|
716
|
-
return {
|
|
717
|
-
selector: "#superdoc-toolbar",
|
|
718
|
-
config: {},
|
|
719
|
-
renderDefaultContainer: !0
|
|
720
|
-
};
|
|
721
|
-
if (typeof n == "string")
|
|
722
|
-
return {
|
|
723
|
-
selector: n,
|
|
724
|
-
config: {},
|
|
725
|
-
renderDefaultContainer: !1
|
|
726
|
-
};
|
|
727
|
-
const { selector: l, ...f } = n;
|
|
728
|
-
return {
|
|
729
|
-
selector: l || "#superdoc-toolbar",
|
|
730
|
-
config: f,
|
|
731
|
-
renderDefaultContainer: l === void 0
|
|
732
|
-
};
|
|
733
|
-
}, re = 10, Ve = 250, je = 300, Ce = (n) => {
|
|
734
|
-
const l = window.innerWidth - Ve - re, f = window.innerHeight - je - re, s = Math.min(n.left, l), c = Math.min(n.top, f);
|
|
735
|
-
return new DOMRect(
|
|
736
|
-
Math.max(s, re),
|
|
737
|
-
Math.max(c, re),
|
|
738
|
-
n.width,
|
|
739
|
-
n.height
|
|
740
|
-
);
|
|
741
|
-
}, Ge = Be(
|
|
742
|
-
(n, l) => {
|
|
743
|
-
const {
|
|
744
|
-
document: f,
|
|
745
|
-
fields: s = {},
|
|
746
|
-
menu: c = {},
|
|
747
|
-
list: a = {},
|
|
748
|
-
toolbar: z,
|
|
749
|
-
onReady: P,
|
|
750
|
-
onTrigger: O,
|
|
751
|
-
onFieldInsert: p,
|
|
752
|
-
onFieldUpdate: E,
|
|
753
|
-
onFieldDelete: x,
|
|
754
|
-
onFieldsChange: y,
|
|
755
|
-
onFieldSelect: w,
|
|
756
|
-
onFieldCreate: R,
|
|
757
|
-
onExport: U,
|
|
758
|
-
className: A,
|
|
759
|
-
style: X,
|
|
760
|
-
documentHeight: ie = "600px"
|
|
761
|
-
} = n, [u, B] = I(s.initial || []), [V, _] = I(null), [j, D] = I(!1), [h, W] = I(), [b, Y] = I(""), [ee, we] = I(() => s.available || []), se = J(null), k = J(null), M = J(null), fe = J(s);
|
|
762
|
-
fe.current = s;
|
|
763
|
-
const H = J(null), ge = J(j);
|
|
764
|
-
oe(() => {
|
|
765
|
-
ge.current = j;
|
|
766
|
-
}, [j]);
|
|
767
|
-
const te = c.trigger || "{{", le = fe.current.available || [], G = pe(() => Ae(z), [z]), me = T(
|
|
768
|
-
(e) => {
|
|
769
|
-
const t = e.trim().toLowerCase();
|
|
770
|
-
return t ? le.filter((i) => i.label.toLowerCase().includes(t)) : le;
|
|
771
|
-
},
|
|
772
|
-
[le]
|
|
773
|
-
), de = T(
|
|
774
|
-
(e) => {
|
|
775
|
-
Y(e), we(me(e));
|
|
776
|
-
},
|
|
777
|
-
[me]
|
|
778
|
-
), L = T(() => {
|
|
779
|
-
de("");
|
|
780
|
-
}, [de]), K = T(
|
|
781
|
-
(e, t) => {
|
|
782
|
-
if (!k.current?.activeEditor) return !1;
|
|
783
|
-
const i = k.current.activeEditor, v = u, C = e === "inline" ? i.commands.insertStructuredContentInline?.({
|
|
784
|
-
attrs: {
|
|
785
|
-
alias: t.alias,
|
|
786
|
-
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
787
|
-
},
|
|
788
|
-
text: t.defaultValue || t.alias
|
|
789
|
-
}) : i.commands.insertStructuredContentBlock?.({
|
|
790
|
-
attrs: {
|
|
791
|
-
alias: t.alias,
|
|
792
|
-
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
793
|
-
},
|
|
794
|
-
text: t.defaultValue || t.alias
|
|
795
|
-
});
|
|
796
|
-
if (C) {
|
|
797
|
-
const g = Q(i);
|
|
798
|
-
B(g), y?.(g);
|
|
799
|
-
const S = g.find(
|
|
800
|
-
(F) => !v.some((d) => d.id === F.id)
|
|
801
|
-
);
|
|
802
|
-
S && p?.(S);
|
|
803
|
-
}
|
|
804
|
-
return C ?? !1;
|
|
805
|
-
},
|
|
806
|
-
[p, y, u]
|
|
807
|
-
), Z = T(
|
|
808
|
-
(e, t) => {
|
|
809
|
-
if (!k.current?.activeEditor) return !1;
|
|
810
|
-
const v = k.current.activeEditor.commands.updateStructuredContentById?.(e, {
|
|
811
|
-
attrs: t
|
|
812
|
-
});
|
|
813
|
-
return v && B((C) => {
|
|
814
|
-
const g = C.map((F) => F.id === e ? { ...F, ...t } : F);
|
|
815
|
-
y?.(g);
|
|
816
|
-
const S = g.find((F) => F.id === e);
|
|
817
|
-
return S && E?.(S), g;
|
|
818
|
-
}), v ?? !1;
|
|
819
|
-
},
|
|
820
|
-
[E, y]
|
|
821
|
-
), ae = T(
|
|
822
|
-
(e) => {
|
|
823
|
-
const t = k.current?.activeEditor;
|
|
824
|
-
if (!t) {
|
|
825
|
-
let d = !1;
|
|
826
|
-
return B((m) => {
|
|
827
|
-
if (!m.some((N) => N.id === e)) return m;
|
|
828
|
-
const q = m.filter((N) => N.id !== e);
|
|
829
|
-
return d = !0, y?.(q), x?.(e), q;
|
|
830
|
-
}), d && _((m) => m === e ? null : m), d;
|
|
831
|
-
}
|
|
832
|
-
const v = u.find((d) => d.id === e)?.group;
|
|
833
|
-
let C = !1;
|
|
834
|
-
try {
|
|
835
|
-
C = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
836
|
-
} catch (d) {
|
|
837
|
-
console.warn("[TemplateBuilder] Failed to delete structured content:", e, d), C = !1;
|
|
838
|
-
}
|
|
839
|
-
let g = Q(t);
|
|
840
|
-
const S = g.some((d) => d.id === e);
|
|
841
|
-
if (!C && S && (g = g.filter((d) => d.id !== e)), v) {
|
|
842
|
-
const d = g.filter((m) => m.group === v);
|
|
843
|
-
if (d.length === 1) {
|
|
844
|
-
const m = d[0];
|
|
845
|
-
t.commands.updateStructuredContentById?.(m.id, {
|
|
846
|
-
attrs: { tag: void 0 }
|
|
847
|
-
}), g = Q(t);
|
|
848
|
-
}
|
|
849
|
-
}
|
|
850
|
-
let F = !1;
|
|
851
|
-
return B((d) => {
|
|
852
|
-
if (Fe(d, g))
|
|
853
|
-
return d;
|
|
854
|
-
const m = d.some((N) => N.id === e), q = g.some((N) => N.id === e);
|
|
855
|
-
return m && !q && (F = !0), y?.(g), F && x?.(e), g;
|
|
856
|
-
}), F && _((d) => d === e ? null : d), C || F;
|
|
857
|
-
},
|
|
858
|
-
[x, y, u]
|
|
859
|
-
), $ = T(
|
|
860
|
-
(e) => {
|
|
861
|
-
if (!k.current?.activeEditor) return;
|
|
862
|
-
k.current.activeEditor.commands.selectStructuredContentById?.(e), _(e);
|
|
863
|
-
const i = u.find((v) => v.id === e);
|
|
864
|
-
i && w?.(i);
|
|
865
|
-
},
|
|
866
|
-
[u, w]
|
|
867
|
-
), ce = T(
|
|
868
|
-
(e) => {
|
|
869
|
-
if (!e) return;
|
|
870
|
-
const t = Q(e);
|
|
871
|
-
B((i) => Fe(i, t) ? i : (y?.(t), t));
|
|
872
|
-
},
|
|
873
|
-
[y]
|
|
874
|
-
);
|
|
875
|
-
oe(() => {
|
|
876
|
-
if (!se.current) return;
|
|
877
|
-
let e = !1, t = null;
|
|
878
|
-
return (async () => {
|
|
879
|
-
const { SuperDoc: v } = await import("superdoc");
|
|
880
|
-
if (e) return;
|
|
881
|
-
const C = {
|
|
882
|
-
comments: !1,
|
|
883
|
-
...G && {
|
|
884
|
-
toolbar: {
|
|
885
|
-
selector: G.selector,
|
|
886
|
-
toolbarGroups: G.config.toolbarGroups || ["center"],
|
|
887
|
-
excludeItems: G.config.excludeItems || [],
|
|
888
|
-
...G.config
|
|
889
|
-
}
|
|
890
|
-
}
|
|
891
|
-
}, g = () => {
|
|
892
|
-
if (!e) {
|
|
893
|
-
if (t?.activeEditor) {
|
|
894
|
-
const S = t.activeEditor;
|
|
895
|
-
S.on("update", ({ editor: F }) => {
|
|
896
|
-
const { state: d } = F, { from: m } = d.selection;
|
|
897
|
-
if (m >= te.length) {
|
|
898
|
-
const ue = m - te.length;
|
|
899
|
-
if (d.doc.textBetween(ue, m) === te) {
|
|
900
|
-
const he = F.view.coordsAtPos(m), be = Ce(new DOMRect(he.left, he.top, 0, 0)), ye = () => {
|
|
901
|
-
const ne = k.current?.activeEditor;
|
|
902
|
-
if (!ne) return;
|
|
903
|
-
const Ne = ne.state.selection.from, ze = ne.state.tr.delete(ue, Ne);
|
|
904
|
-
ne.view.dispatch(ze);
|
|
905
|
-
};
|
|
906
|
-
M.current = ye, H.current = m, W(be), D(!0), L(), O?.({
|
|
907
|
-
position: { from: ue, to: m },
|
|
908
|
-
bounds: be,
|
|
909
|
-
cleanup: ye
|
|
910
|
-
});
|
|
911
|
-
return;
|
|
912
|
-
}
|
|
913
|
-
}
|
|
914
|
-
if (!ge.current)
|
|
915
|
-
return;
|
|
916
|
-
if (H.current == null) {
|
|
917
|
-
D(!1), L();
|
|
918
|
-
return;
|
|
919
|
-
}
|
|
920
|
-
if (m < H.current) {
|
|
921
|
-
D(!1), H.current = null, L();
|
|
922
|
-
return;
|
|
923
|
-
}
|
|
924
|
-
const q = d.doc.textBetween(H.current, m);
|
|
925
|
-
de(q);
|
|
926
|
-
const N = F.view.coordsAtPos(m), De = Ce(new DOMRect(N.left, N.top, 0, 0));
|
|
927
|
-
W(De);
|
|
928
|
-
}), S.on("update", () => {
|
|
929
|
-
ce(S);
|
|
930
|
-
}), ce(S);
|
|
931
|
-
}
|
|
932
|
-
P?.();
|
|
933
|
-
}
|
|
934
|
-
};
|
|
935
|
-
t = new v({
|
|
936
|
-
selector: se.current,
|
|
937
|
-
document: f?.source,
|
|
938
|
-
documentMode: f?.mode || "editing",
|
|
939
|
-
modules: C,
|
|
940
|
-
toolbar: G?.selector,
|
|
941
|
-
onReady: g
|
|
942
|
-
}), k.current = t;
|
|
943
|
-
})(), () => {
|
|
944
|
-
e = !0, M.current = null, H.current = null, t && typeof t.destroy == "function" && t.destroy(), k.current = null;
|
|
945
|
-
};
|
|
946
|
-
}, [f?.source, f?.mode, te, ce, P, O, G]);
|
|
947
|
-
const ke = T(
|
|
948
|
-
async (e) => {
|
|
949
|
-
M.current && (M.current(), M.current = null), H.current = null, L();
|
|
950
|
-
const t = e.mode || "inline";
|
|
951
|
-
if (e.id.startsWith("custom_") && R) {
|
|
952
|
-
const i = await R(e);
|
|
953
|
-
if (i) {
|
|
954
|
-
const v = i.mode || t;
|
|
955
|
-
K(v, {
|
|
956
|
-
alias: i.label,
|
|
957
|
-
metadata: i.metadata,
|
|
958
|
-
defaultValue: i.defaultValue
|
|
959
|
-
}), D(!1);
|
|
960
|
-
return;
|
|
961
|
-
}
|
|
962
|
-
}
|
|
963
|
-
K(t, {
|
|
964
|
-
alias: e.label,
|
|
965
|
-
metadata: e.metadata,
|
|
966
|
-
defaultValue: e.defaultValue
|
|
967
|
-
}), D(!1);
|
|
968
|
-
},
|
|
969
|
-
[K, R, L]
|
|
970
|
-
), Se = T(
|
|
971
|
-
(e) => {
|
|
972
|
-
M.current && (M.current(), M.current = null), H.current = null, L();
|
|
973
|
-
const t = k.current?.activeEditor;
|
|
974
|
-
if (!t) return;
|
|
975
|
-
const i = t.helpers?.structuredContentCommands;
|
|
976
|
-
if (!i) return;
|
|
977
|
-
const v = e.group || `group-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`, C = i.createTagObject?.({
|
|
978
|
-
group: v
|
|
979
|
-
});
|
|
980
|
-
if ((e.mode || "inline") === "inline" ? t.commands.insertStructuredContentInline?.({
|
|
981
|
-
attrs: {
|
|
982
|
-
alias: e.alias,
|
|
983
|
-
tag: C
|
|
984
|
-
},
|
|
985
|
-
text: e.alias
|
|
986
|
-
}) : t.commands.insertStructuredContentBlock?.({
|
|
987
|
-
attrs: {
|
|
988
|
-
alias: e.alias,
|
|
989
|
-
tag: C
|
|
990
|
-
},
|
|
991
|
-
text: e.alias
|
|
992
|
-
})) {
|
|
993
|
-
e.group || Z(e.id, { tag: C }), D(!1);
|
|
994
|
-
const F = Q(t);
|
|
995
|
-
B(F), y?.(F);
|
|
996
|
-
}
|
|
997
|
-
},
|
|
998
|
-
[Z, L, y]
|
|
999
|
-
), Te = T(() => {
|
|
1000
|
-
D(!1), H.current = null, L(), M.current && (M.current(), M.current = null);
|
|
1001
|
-
}, [L]), Ee = T(() => {
|
|
1002
|
-
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1003
|
-
const e = u.findIndex((i) => i.id === V), t = e >= 0 ? (e + 1) % u.length : 0;
|
|
1004
|
-
$(u[t].id);
|
|
1005
|
-
}, [u, V, $]), Ie = T(() => {
|
|
1006
|
-
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1007
|
-
const e = u.findIndex((i) => i.id === V), t = e > 0 ? e - 1 : u.length - 1;
|
|
1008
|
-
$(u[t].id);
|
|
1009
|
-
}, [u, V, $]), Me = T(
|
|
1010
|
-
async (e) => {
|
|
1011
|
-
const { fileName: t = "document", triggerDownload: i = !0 } = e || {}, v = await k.current?.export({
|
|
1012
|
-
exportType: ["docx"],
|
|
1013
|
-
exportedName: t,
|
|
1014
|
-
triggerDownload: i
|
|
1015
|
-
}), C = k.current?.activeEditor;
|
|
1016
|
-
if (C) {
|
|
1017
|
-
const g = Q(C);
|
|
1018
|
-
U?.({ fields: g, blob: i ? void 0 : v, fileName: t });
|
|
1019
|
-
}
|
|
1020
|
-
return v;
|
|
1021
|
-
},
|
|
1022
|
-
[U]
|
|
1023
|
-
);
|
|
1024
|
-
We(l, () => ({
|
|
1025
|
-
insertField: (e) => K("inline", e),
|
|
1026
|
-
insertBlockField: (e) => K("block", e),
|
|
1027
|
-
updateField: Z,
|
|
1028
|
-
deleteField: ae,
|
|
1029
|
-
selectField: $,
|
|
1030
|
-
nextField: Ee,
|
|
1031
|
-
previousField: Ie,
|
|
1032
|
-
getFields: () => u,
|
|
1033
|
-
exportTemplate: Me,
|
|
1034
|
-
getSuperDoc: () => k.current
|
|
1035
|
-
}));
|
|
1036
|
-
const Re = c.component || He, xe = a.component || Pe;
|
|
1037
|
-
return /* @__PURE__ */ o("div", { className: `superdoc-template-builder ${A || ""}`, style: X, children: [
|
|
1038
|
-
/* @__PURE__ */ o("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1039
|
-
a.position === "left" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1040
|
-
xe,
|
|
1041
|
-
{
|
|
1042
|
-
fields: u,
|
|
1043
|
-
onSelect: (e) => $(e.id),
|
|
1044
|
-
onDelete: ae,
|
|
1045
|
-
onUpdate: (e) => Z(e.id, e),
|
|
1046
|
-
selectedFieldId: V || void 0
|
|
1047
|
-
}
|
|
1048
|
-
) }),
|
|
1049
|
-
/* @__PURE__ */ o("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1050
|
-
G?.renderDefaultContainer && /* @__PURE__ */ r(
|
|
1051
|
-
"div",
|
|
1052
|
-
{
|
|
1053
|
-
id: "superdoc-toolbar",
|
|
1054
|
-
className: "superdoc-template-builder-toolbar",
|
|
1055
|
-
"data-testid": "template-builder-toolbar"
|
|
1056
|
-
}
|
|
1057
|
-
),
|
|
1058
|
-
/* @__PURE__ */ r(
|
|
1059
|
-
"div",
|
|
1060
|
-
{
|
|
1061
|
-
ref: se,
|
|
1062
|
-
className: "superdoc-template-builder-editor",
|
|
1063
|
-
style: { height: ie },
|
|
1064
|
-
"data-testid": "template-builder-editor"
|
|
1065
|
-
}
|
|
1066
|
-
)
|
|
1067
|
-
] }),
|
|
1068
|
-
a.position === "right" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1069
|
-
xe,
|
|
1070
|
-
{
|
|
1071
|
-
fields: u,
|
|
1072
|
-
onSelect: (e) => $(e.id),
|
|
1073
|
-
onDelete: ae,
|
|
1074
|
-
onUpdate: (e) => Z(e.id, e),
|
|
1075
|
-
selectedFieldId: V || void 0
|
|
1076
|
-
}
|
|
1077
|
-
) })
|
|
1078
|
-
] }),
|
|
1079
|
-
/* @__PURE__ */ r(
|
|
1080
|
-
Re,
|
|
1081
|
-
{
|
|
1082
|
-
isVisible: j,
|
|
1083
|
-
position: h,
|
|
1084
|
-
availableFields: s.available || [],
|
|
1085
|
-
filteredFields: ee,
|
|
1086
|
-
filterQuery: b,
|
|
1087
|
-
allowCreate: s.allowCreate || !1,
|
|
1088
|
-
onSelect: ke,
|
|
1089
|
-
onClose: Te,
|
|
1090
|
-
onCreateField: R,
|
|
1091
|
-
existingFields: u,
|
|
1092
|
-
onSelectExisting: Se
|
|
1093
|
-
}
|
|
1094
|
-
)
|
|
1095
|
-
] });
|
|
1096
|
-
}
|
|
1097
|
-
);
|
|
1098
|
-
Ge.displayName = "SuperDocTemplateBuilder";
|
|
1099
|
-
export {
|
|
1100
|
-
Pe as FieldList,
|
|
1101
|
-
He as FieldMenu,
|
|
1102
|
-
Ge as default
|
|
1
|
+
import { forwardRef, useCallback, useEffect, useImperativeHandle, useMemo, useRef, useState } from "react";
|
|
2
|
+
import { jsx, jsxs } from "react/jsx-runtime";
|
|
3
|
+
const FieldMenu = ({ isVisible: e, position: t, availableFields: r, filteredFields: a, filterQuery: s, allowCreate: c, onSelect: l, onClose: u, onCreateField: d, existingFields: f = [], onSelectExisting: ne }) => {
|
|
4
|
+
let [p, m] = useState(!1), [h, g] = useState(""), [_, v] = useState("inline"), [y, b] = useState(!0), [x, S] = useState(!0);
|
|
5
|
+
useEffect(() => {
|
|
6
|
+
e || (m(!1), g(""), v("inline"));
|
|
7
|
+
}, [e]);
|
|
8
|
+
let C = useMemo(() => ({
|
|
9
|
+
position: "absolute",
|
|
10
|
+
left: t?.left,
|
|
11
|
+
top: t?.top,
|
|
12
|
+
zIndex: 1e3,
|
|
13
|
+
background: "white",
|
|
14
|
+
border: "1px solid #ddd",
|
|
15
|
+
borderRadius: "4px",
|
|
16
|
+
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
17
|
+
padding: "8px 0",
|
|
18
|
+
width: "280px"
|
|
19
|
+
}), [t]), w = a ?? r, T = !!s;
|
|
20
|
+
if (useEffect(() => {
|
|
21
|
+
T && S(!0);
|
|
22
|
+
}, [T]), !e) return null;
|
|
23
|
+
let E = async () => {
|
|
24
|
+
let e = h.trim();
|
|
25
|
+
if (!e) return;
|
|
26
|
+
let t = {
|
|
27
|
+
id: `custom_${Date.now()}`,
|
|
28
|
+
label: e,
|
|
29
|
+
mode: _
|
|
30
|
+
};
|
|
31
|
+
try {
|
|
32
|
+
l(d && await d(t) || t);
|
|
33
|
+
} finally {
|
|
34
|
+
m(!1), g(""), v("inline");
|
|
35
|
+
}
|
|
36
|
+
};
|
|
37
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
38
|
+
className: "superdoc-field-menu",
|
|
39
|
+
style: C,
|
|
40
|
+
children: [
|
|
41
|
+
T && /* @__PURE__ */ jsx("div", {
|
|
42
|
+
style: {
|
|
43
|
+
padding: "8px 16px",
|
|
44
|
+
borderBottom: "1px solid #f0f0f0",
|
|
45
|
+
marginBottom: "4px"
|
|
46
|
+
},
|
|
47
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
48
|
+
style: {
|
|
49
|
+
fontSize: "12px",
|
|
50
|
+
color: "#6b7280"
|
|
51
|
+
},
|
|
52
|
+
children: ["Filtering results for", /* @__PURE__ */ jsx("span", {
|
|
53
|
+
style: {
|
|
54
|
+
fontWeight: 600,
|
|
55
|
+
color: "#111827",
|
|
56
|
+
marginLeft: "4px"
|
|
57
|
+
},
|
|
58
|
+
children: s
|
|
59
|
+
})]
|
|
60
|
+
})
|
|
61
|
+
}),
|
|
62
|
+
c && !p && /* @__PURE__ */ jsx("div", {
|
|
63
|
+
className: "field-menu-item",
|
|
64
|
+
onClick: () => m(!0),
|
|
65
|
+
style: {
|
|
66
|
+
padding: "8px 16px",
|
|
67
|
+
cursor: "pointer",
|
|
68
|
+
color: "#0066cc",
|
|
69
|
+
fontWeight: 500
|
|
70
|
+
},
|
|
71
|
+
children: "+ Create New Field"
|
|
72
|
+
}),
|
|
73
|
+
c && p && /* @__PURE__ */ jsxs("div", {
|
|
74
|
+
style: { padding: "8px 16px" },
|
|
75
|
+
children: [
|
|
76
|
+
/* @__PURE__ */ jsx("input", {
|
|
77
|
+
type: "text",
|
|
78
|
+
value: h,
|
|
79
|
+
placeholder: "Field name...",
|
|
80
|
+
onChange: (e) => g(e.target.value),
|
|
81
|
+
onKeyDown: (e) => {
|
|
82
|
+
e.key === "Enter" && E(), e.key === "Escape" && (m(!1), g(""), v("inline"));
|
|
83
|
+
},
|
|
84
|
+
autoFocus: !0,
|
|
85
|
+
style: {
|
|
86
|
+
width: "100%",
|
|
87
|
+
padding: "4px 8px",
|
|
88
|
+
border: "1px solid #ddd",
|
|
89
|
+
borderRadius: "3px"
|
|
90
|
+
}
|
|
91
|
+
}),
|
|
92
|
+
/* @__PURE__ */ jsxs("div", {
|
|
93
|
+
style: {
|
|
94
|
+
marginTop: "8px",
|
|
95
|
+
display: "flex",
|
|
96
|
+
gap: "12px",
|
|
97
|
+
fontSize: "13px"
|
|
98
|
+
},
|
|
99
|
+
children: [/* @__PURE__ */ jsxs("label", {
|
|
100
|
+
style: {
|
|
101
|
+
display: "flex",
|
|
102
|
+
alignItems: "center",
|
|
103
|
+
gap: "4px",
|
|
104
|
+
cursor: "pointer"
|
|
105
|
+
},
|
|
106
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
107
|
+
type: "radio",
|
|
108
|
+
value: "inline",
|
|
109
|
+
checked: _ === "inline",
|
|
110
|
+
onChange: () => v("inline")
|
|
111
|
+
}), "Inline"]
|
|
112
|
+
}), /* @__PURE__ */ jsxs("label", {
|
|
113
|
+
style: {
|
|
114
|
+
display: "flex",
|
|
115
|
+
alignItems: "center",
|
|
116
|
+
gap: "4px",
|
|
117
|
+
cursor: "pointer"
|
|
118
|
+
},
|
|
119
|
+
children: [/* @__PURE__ */ jsx("input", {
|
|
120
|
+
type: "radio",
|
|
121
|
+
value: "block",
|
|
122
|
+
checked: _ === "block",
|
|
123
|
+
onChange: () => v("block")
|
|
124
|
+
}), "Block"]
|
|
125
|
+
})]
|
|
126
|
+
}),
|
|
127
|
+
/* @__PURE__ */ jsxs("div", {
|
|
128
|
+
style: {
|
|
129
|
+
marginTop: "8px",
|
|
130
|
+
display: "flex",
|
|
131
|
+
gap: "8px"
|
|
132
|
+
},
|
|
133
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
134
|
+
onClick: E,
|
|
135
|
+
disabled: !h.trim(),
|
|
136
|
+
style: {
|
|
137
|
+
padding: "4px 12px",
|
|
138
|
+
background: h.trim() ? "#0066cc" : "#ccc",
|
|
139
|
+
color: "white",
|
|
140
|
+
border: "none",
|
|
141
|
+
borderRadius: "3px",
|
|
142
|
+
cursor: h.trim() ? "pointer" : "not-allowed"
|
|
143
|
+
},
|
|
144
|
+
children: "Create"
|
|
145
|
+
}), /* @__PURE__ */ jsx("button", {
|
|
146
|
+
onClick: () => {
|
|
147
|
+
m(!1), g(""), v("inline");
|
|
148
|
+
},
|
|
149
|
+
style: {
|
|
150
|
+
padding: "4px 12px",
|
|
151
|
+
background: "white",
|
|
152
|
+
border: "1px solid #ddd",
|
|
153
|
+
borderRadius: "3px",
|
|
154
|
+
cursor: "pointer"
|
|
155
|
+
},
|
|
156
|
+
children: "Cancel"
|
|
157
|
+
})]
|
|
158
|
+
})
|
|
159
|
+
]
|
|
160
|
+
}),
|
|
161
|
+
c && r.length > 0 && /* @__PURE__ */ jsx("div", { style: {
|
|
162
|
+
borderTop: "1px solid #eee",
|
|
163
|
+
margin: "4px 0"
|
|
164
|
+
} }),
|
|
165
|
+
f.length > 0 && (() => {
|
|
166
|
+
let e = /* @__PURE__ */ new Map();
|
|
167
|
+
f.forEach((t) => {
|
|
168
|
+
let n = t.group || `individual-${t.id}`, r = e.get(n) || [];
|
|
169
|
+
r.push(t), e.set(n, r);
|
|
170
|
+
});
|
|
171
|
+
let t = Array.from(e.values()).map((e) => ({
|
|
172
|
+
...e[0],
|
|
173
|
+
count: e.length
|
|
174
|
+
}));
|
|
175
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
176
|
+
style: { borderBottom: "1px solid #f0f0f0" },
|
|
177
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
178
|
+
type: "button",
|
|
179
|
+
onClick: () => b(!y),
|
|
180
|
+
style: {
|
|
181
|
+
width: "100%",
|
|
182
|
+
display: "flex",
|
|
183
|
+
alignItems: "center",
|
|
184
|
+
justifyContent: "space-between",
|
|
185
|
+
padding: "8px 16px",
|
|
186
|
+
background: "transparent",
|
|
187
|
+
border: "none",
|
|
188
|
+
cursor: "pointer",
|
|
189
|
+
fontWeight: 500,
|
|
190
|
+
fontSize: "13px",
|
|
191
|
+
color: "#374151",
|
|
192
|
+
textAlign: "left"
|
|
193
|
+
},
|
|
194
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
195
|
+
"Existing Fields (",
|
|
196
|
+
t.length,
|
|
197
|
+
")"
|
|
198
|
+
] }), /* @__PURE__ */ jsx("span", {
|
|
199
|
+
"aria-hidden": !0,
|
|
200
|
+
style: {
|
|
201
|
+
display: "inline-block",
|
|
202
|
+
width: "8px",
|
|
203
|
+
height: "8px",
|
|
204
|
+
borderRight: "2px solid #666",
|
|
205
|
+
borderBottom: "2px solid #666",
|
|
206
|
+
transform: y ? "rotate(45deg)" : "rotate(-45deg)",
|
|
207
|
+
transition: "transform 0.2s ease"
|
|
208
|
+
}
|
|
209
|
+
})]
|
|
210
|
+
}), y && /* @__PURE__ */ jsx("div", {
|
|
211
|
+
style: {
|
|
212
|
+
maxHeight: "300px",
|
|
213
|
+
overflowY: "auto"
|
|
214
|
+
},
|
|
215
|
+
children: t.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
216
|
+
className: "field-menu-item",
|
|
217
|
+
onClick: () => ne?.(e),
|
|
218
|
+
style: {
|
|
219
|
+
padding: "8px 16px",
|
|
220
|
+
cursor: "pointer",
|
|
221
|
+
display: "flex",
|
|
222
|
+
alignItems: "flex-start",
|
|
223
|
+
justifyContent: "space-between",
|
|
224
|
+
gap: "8px"
|
|
225
|
+
},
|
|
226
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
227
|
+
style: {
|
|
228
|
+
flex: 1,
|
|
229
|
+
minWidth: 0
|
|
230
|
+
},
|
|
231
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
232
|
+
style: {
|
|
233
|
+
fontWeight: 500,
|
|
234
|
+
fontSize: "13px"
|
|
235
|
+
},
|
|
236
|
+
children: e.alias || e.id
|
|
237
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
238
|
+
style: {
|
|
239
|
+
fontSize: "11px",
|
|
240
|
+
color: "#9ca3af",
|
|
241
|
+
marginTop: "2px"
|
|
242
|
+
},
|
|
243
|
+
children: e.group ? `group (${e.count} fields)` : `ID: ${e.id}`
|
|
244
|
+
})]
|
|
245
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
246
|
+
style: {
|
|
247
|
+
fontSize: "11px",
|
|
248
|
+
color: "#6b7280",
|
|
249
|
+
padding: "2px 6px",
|
|
250
|
+
background: "#f3f4f6",
|
|
251
|
+
borderRadius: "3px",
|
|
252
|
+
textTransform: "capitalize",
|
|
253
|
+
flexShrink: 0
|
|
254
|
+
},
|
|
255
|
+
children: e.mode || "inline"
|
|
256
|
+
})]
|
|
257
|
+
}, e.group || e.id))
|
|
258
|
+
})]
|
|
259
|
+
});
|
|
260
|
+
})(),
|
|
261
|
+
w.length === 0 ? /* @__PURE__ */ jsx("div", {
|
|
262
|
+
style: {
|
|
263
|
+
padding: "16px",
|
|
264
|
+
fontSize: "13px",
|
|
265
|
+
color: "#6b7280",
|
|
266
|
+
textAlign: "center"
|
|
267
|
+
},
|
|
268
|
+
children: "No matching fields"
|
|
269
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
270
|
+
style: { borderBottom: "1px solid #f0f0f0" },
|
|
271
|
+
children: [/* @__PURE__ */ jsxs("button", {
|
|
272
|
+
type: "button",
|
|
273
|
+
onClick: () => S(!x),
|
|
274
|
+
style: {
|
|
275
|
+
width: "100%",
|
|
276
|
+
display: "flex",
|
|
277
|
+
alignItems: "center",
|
|
278
|
+
justifyContent: "space-between",
|
|
279
|
+
padding: "8px 16px",
|
|
280
|
+
background: "transparent",
|
|
281
|
+
border: "none",
|
|
282
|
+
cursor: "pointer",
|
|
283
|
+
fontWeight: 500,
|
|
284
|
+
fontSize: "13px",
|
|
285
|
+
color: "#374151",
|
|
286
|
+
textAlign: "left"
|
|
287
|
+
},
|
|
288
|
+
children: [/* @__PURE__ */ jsxs("span", { children: [
|
|
289
|
+
"Available Fields (",
|
|
290
|
+
w.length,
|
|
291
|
+
")"
|
|
292
|
+
] }), /* @__PURE__ */ jsx("span", {
|
|
293
|
+
"aria-hidden": !0,
|
|
294
|
+
style: {
|
|
295
|
+
display: "inline-block",
|
|
296
|
+
width: "8px",
|
|
297
|
+
height: "8px",
|
|
298
|
+
borderRight: "2px solid #666",
|
|
299
|
+
borderBottom: "2px solid #666",
|
|
300
|
+
transform: x ? "rotate(45deg)" : "rotate(-45deg)",
|
|
301
|
+
transition: "transform 0.2s ease"
|
|
302
|
+
}
|
|
303
|
+
})]
|
|
304
|
+
}), x && /* @__PURE__ */ jsx("div", {
|
|
305
|
+
style: {
|
|
306
|
+
maxHeight: "300px",
|
|
307
|
+
overflowY: "auto"
|
|
308
|
+
},
|
|
309
|
+
children: w.map((e) => /* @__PURE__ */ jsxs("div", {
|
|
310
|
+
className: "field-menu-item",
|
|
311
|
+
onClick: () => l(e),
|
|
312
|
+
style: {
|
|
313
|
+
padding: "8px 16px",
|
|
314
|
+
cursor: "pointer",
|
|
315
|
+
display: "flex",
|
|
316
|
+
alignItems: "flex-start",
|
|
317
|
+
justifyContent: "space-between",
|
|
318
|
+
gap: "8px"
|
|
319
|
+
},
|
|
320
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
321
|
+
style: {
|
|
322
|
+
flex: 1,
|
|
323
|
+
minWidth: 0
|
|
324
|
+
},
|
|
325
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
326
|
+
style: {
|
|
327
|
+
fontWeight: 500,
|
|
328
|
+
fontSize: "13px"
|
|
329
|
+
},
|
|
330
|
+
children: e.label || e.id
|
|
331
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
332
|
+
style: {
|
|
333
|
+
fontSize: "11px",
|
|
334
|
+
color: "#9ca3af",
|
|
335
|
+
marginTop: "2px"
|
|
336
|
+
},
|
|
337
|
+
children: ["ID: ", e.id]
|
|
338
|
+
})]
|
|
339
|
+
}), /* @__PURE__ */ jsx("span", {
|
|
340
|
+
style: {
|
|
341
|
+
fontSize: "11px",
|
|
342
|
+
color: "#6b7280",
|
|
343
|
+
padding: "2px 6px",
|
|
344
|
+
background: "#f3f4f6",
|
|
345
|
+
borderRadius: "3px",
|
|
346
|
+
textTransform: "capitalize",
|
|
347
|
+
flexShrink: 0
|
|
348
|
+
},
|
|
349
|
+
children: e.mode || "inline"
|
|
350
|
+
})]
|
|
351
|
+
}, e.id))
|
|
352
|
+
})]
|
|
353
|
+
}),
|
|
354
|
+
/* @__PURE__ */ jsx("div", {
|
|
355
|
+
style: {
|
|
356
|
+
borderTop: "1px solid #eee",
|
|
357
|
+
marginTop: "4px"
|
|
358
|
+
},
|
|
359
|
+
children: /* @__PURE__ */ jsx("button", {
|
|
360
|
+
onClick: u,
|
|
361
|
+
style: {
|
|
362
|
+
width: "100%",
|
|
363
|
+
padding: "6px 16px",
|
|
364
|
+
background: "#f3f4f6",
|
|
365
|
+
border: "none",
|
|
366
|
+
borderRadius: "0 0 4px 4px",
|
|
367
|
+
cursor: "pointer"
|
|
368
|
+
},
|
|
369
|
+
children: "Close"
|
|
370
|
+
})
|
|
371
|
+
})
|
|
372
|
+
]
|
|
373
|
+
});
|
|
1103
374
|
};
|
|
375
|
+
var shortenGroupId = (e) => {
|
|
376
|
+
let t = e.split("-");
|
|
377
|
+
return t.length > 2 ? t[t.length - 1].substring(0, 6) : e.substring(0, 6);
|
|
378
|
+
}, FieldItem = ({ field: e, onSelect: t, onDelete: n, isSelected: r, isGrouped: i = !1 }) => /* @__PURE__ */ jsxs("div", {
|
|
379
|
+
onClick: () => t(e),
|
|
380
|
+
style: {
|
|
381
|
+
position: "relative",
|
|
382
|
+
padding: "10px 12px",
|
|
383
|
+
background: r ? "#eff6ff" : "#f9fafb",
|
|
384
|
+
border: r ? "1px solid #3b82f6" : "1px solid #e5e7eb",
|
|
385
|
+
borderRadius: "6px",
|
|
386
|
+
cursor: "pointer",
|
|
387
|
+
transition: "all 0.2s",
|
|
388
|
+
fontSize: i ? "13px" : "14px"
|
|
389
|
+
},
|
|
390
|
+
onMouseEnter: (e) => {
|
|
391
|
+
r || (e.currentTarget.style.background = "#f3f4f6");
|
|
392
|
+
},
|
|
393
|
+
onMouseLeave: (e) => {
|
|
394
|
+
r || (e.currentTarget.style.background = "#f9fafb");
|
|
395
|
+
},
|
|
396
|
+
title: e.alias,
|
|
397
|
+
children: [/* @__PURE__ */ jsx("button", {
|
|
398
|
+
onClick: (t) => {
|
|
399
|
+
t.stopPropagation(), n(e.id);
|
|
400
|
+
},
|
|
401
|
+
style: {
|
|
402
|
+
position: "absolute",
|
|
403
|
+
top: "6px",
|
|
404
|
+
right: "6px",
|
|
405
|
+
padding: "4px",
|
|
406
|
+
background: "transparent",
|
|
407
|
+
border: "none",
|
|
408
|
+
cursor: "pointer",
|
|
409
|
+
color: "#9ca3af",
|
|
410
|
+
transition: "color 0.2s",
|
|
411
|
+
display: "flex",
|
|
412
|
+
alignItems: "center",
|
|
413
|
+
justifyContent: "center"
|
|
414
|
+
},
|
|
415
|
+
onMouseEnter: (e) => {
|
|
416
|
+
e.currentTarget.style.color = "#ef4444";
|
|
417
|
+
},
|
|
418
|
+
onMouseLeave: (e) => {
|
|
419
|
+
e.currentTarget.style.color = "#9ca3af";
|
|
420
|
+
},
|
|
421
|
+
title: "Delete field",
|
|
422
|
+
children: /* @__PURE__ */ jsx("svg", {
|
|
423
|
+
width: "14",
|
|
424
|
+
height: "14",
|
|
425
|
+
viewBox: "0 0 16 16",
|
|
426
|
+
fill: "none",
|
|
427
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
428
|
+
children: /* @__PURE__ */ jsx("path", {
|
|
429
|
+
d: "M6 2V1.5C6 1.22386 6.22386 1 6.5 1H9.5C9.77614 1 10 1.22386 10 1.5V2M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4",
|
|
430
|
+
stroke: "currentColor",
|
|
431
|
+
strokeWidth: "1.5",
|
|
432
|
+
strokeLinecap: "round",
|
|
433
|
+
strokeLinejoin: "round"
|
|
434
|
+
})
|
|
435
|
+
})
|
|
436
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
437
|
+
style: { paddingRight: "24px" },
|
|
438
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
439
|
+
style: {
|
|
440
|
+
fontWeight: "500",
|
|
441
|
+
fontSize: i ? "12px" : "14px",
|
|
442
|
+
color: i ? "#6b7280" : "#111827"
|
|
443
|
+
},
|
|
444
|
+
children: e.alias || e.id
|
|
445
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
446
|
+
style: {
|
|
447
|
+
display: "flex",
|
|
448
|
+
alignItems: "center",
|
|
449
|
+
gap: "6px",
|
|
450
|
+
fontSize: "11px",
|
|
451
|
+
color: "#9ca3af",
|
|
452
|
+
marginTop: "2px"
|
|
453
|
+
},
|
|
454
|
+
children: [/* @__PURE__ */ jsxs("span", { children: ["ID: ", e.id] }), e.mode && /* @__PURE__ */ jsx("span", {
|
|
455
|
+
style: {
|
|
456
|
+
fontSize: "9px",
|
|
457
|
+
padding: "2px 5px",
|
|
458
|
+
borderRadius: "3px",
|
|
459
|
+
background: e.mode === "block" ? "#dbeafe" : "#f3f4f6",
|
|
460
|
+
color: e.mode === "block" ? "#1e40af" : "#4b5563",
|
|
461
|
+
fontWeight: "500"
|
|
462
|
+
},
|
|
463
|
+
children: e.mode
|
|
464
|
+
})]
|
|
465
|
+
})]
|
|
466
|
+
})]
|
|
467
|
+
});
|
|
468
|
+
const FieldList = ({ fields: e, onSelect: t, onDelete: n, selectedFieldId: r }) => {
|
|
469
|
+
let [a, s] = useState(/* @__PURE__ */ new Set()), { groupedFields: u, ungroupedFields: d } = useMemo(() => {
|
|
470
|
+
let t = {}, n = [];
|
|
471
|
+
return e.forEach((e) => {
|
|
472
|
+
e.group ? (t[e.group] || (t[e.group] = []), t[e.group].push(e)) : n.push(e);
|
|
473
|
+
}), {
|
|
474
|
+
groupedFields: t,
|
|
475
|
+
ungroupedFields: n
|
|
476
|
+
};
|
|
477
|
+
}, [e]), f = (e) => {
|
|
478
|
+
s((t) => {
|
|
479
|
+
let n = new Set(t);
|
|
480
|
+
return n.has(e) ? n.delete(e) : n.add(e), n;
|
|
481
|
+
});
|
|
482
|
+
};
|
|
483
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
484
|
+
className: "superdoc-field-list",
|
|
485
|
+
style: {
|
|
486
|
+
width: "250px",
|
|
487
|
+
background: "white",
|
|
488
|
+
border: "1px solid #e5e7eb",
|
|
489
|
+
borderRadius: "8px",
|
|
490
|
+
padding: "16px"
|
|
491
|
+
},
|
|
492
|
+
children: [/* @__PURE__ */ jsxs("h3", {
|
|
493
|
+
style: {
|
|
494
|
+
margin: "0 0 16px 0",
|
|
495
|
+
fontSize: "16px",
|
|
496
|
+
fontWeight: "600"
|
|
497
|
+
},
|
|
498
|
+
children: [
|
|
499
|
+
"Template Fields (",
|
|
500
|
+
e.length,
|
|
501
|
+
")"
|
|
502
|
+
]
|
|
503
|
+
}), e.length === 0 ? /* @__PURE__ */ jsxs("div", {
|
|
504
|
+
style: {
|
|
505
|
+
color: "#9ca3af",
|
|
506
|
+
fontSize: "14px",
|
|
507
|
+
textAlign: "center",
|
|
508
|
+
padding: "20px 0"
|
|
509
|
+
},
|
|
510
|
+
children: [
|
|
511
|
+
"No fields yet. Type ",
|
|
512
|
+
"{{",
|
|
513
|
+
" to add a field."
|
|
514
|
+
]
|
|
515
|
+
}) : /* @__PURE__ */ jsxs("div", {
|
|
516
|
+
style: {
|
|
517
|
+
display: "flex",
|
|
518
|
+
flexDirection: "column",
|
|
519
|
+
gap: "8px"
|
|
520
|
+
},
|
|
521
|
+
children: [d.map((e) => /* @__PURE__ */ jsx(FieldItem, {
|
|
522
|
+
field: e,
|
|
523
|
+
onSelect: t,
|
|
524
|
+
onDelete: n,
|
|
525
|
+
isSelected: r === e.id
|
|
526
|
+
}, e.id)), Object.entries(u).map(([e, i]) => {
|
|
527
|
+
let o = a.has(e), s = i[0];
|
|
528
|
+
return /* @__PURE__ */ jsxs("div", { children: [/* @__PURE__ */ jsx("div", {
|
|
529
|
+
style: {
|
|
530
|
+
position: "relative",
|
|
531
|
+
padding: "12px",
|
|
532
|
+
background: "#f9fafb",
|
|
533
|
+
border: "1px solid #e5e7eb",
|
|
534
|
+
borderRadius: "6px",
|
|
535
|
+
cursor: "pointer",
|
|
536
|
+
transition: "all 0.2s"
|
|
537
|
+
},
|
|
538
|
+
onClick: () => f(e),
|
|
539
|
+
onMouseEnter: (e) => {
|
|
540
|
+
e.currentTarget.style.background = "#f3f4f6";
|
|
541
|
+
},
|
|
542
|
+
onMouseLeave: (e) => {
|
|
543
|
+
e.currentTarget.style.background = "#f9fafb";
|
|
544
|
+
},
|
|
545
|
+
children: /* @__PURE__ */ jsxs("div", {
|
|
546
|
+
style: {
|
|
547
|
+
display: "flex",
|
|
548
|
+
alignItems: "center",
|
|
549
|
+
gap: "8px"
|
|
550
|
+
},
|
|
551
|
+
children: [/* @__PURE__ */ jsx("span", {
|
|
552
|
+
style: {
|
|
553
|
+
fontSize: "12px",
|
|
554
|
+
color: "#6b7280"
|
|
555
|
+
},
|
|
556
|
+
children: o ? "▼" : "▶"
|
|
557
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
558
|
+
style: { flex: 1 },
|
|
559
|
+
children: [/* @__PURE__ */ jsx("div", {
|
|
560
|
+
style: {
|
|
561
|
+
fontWeight: "500",
|
|
562
|
+
fontSize: "14px"
|
|
563
|
+
},
|
|
564
|
+
children: s.alias
|
|
565
|
+
}), /* @__PURE__ */ jsxs("div", {
|
|
566
|
+
style: {
|
|
567
|
+
fontSize: "11px",
|
|
568
|
+
color: "#9ca3af",
|
|
569
|
+
marginTop: "2px"
|
|
570
|
+
},
|
|
571
|
+
children: [
|
|
572
|
+
"group: ",
|
|
573
|
+
shortenGroupId(e),
|
|
574
|
+
" (",
|
|
575
|
+
i.length,
|
|
576
|
+
" fields)"
|
|
577
|
+
]
|
|
578
|
+
})]
|
|
579
|
+
})]
|
|
580
|
+
})
|
|
581
|
+
}), o && /* @__PURE__ */ jsx("div", {
|
|
582
|
+
style: {
|
|
583
|
+
marginLeft: "16px",
|
|
584
|
+
marginTop: "4px",
|
|
585
|
+
display: "flex",
|
|
586
|
+
flexDirection: "column",
|
|
587
|
+
gap: "4px"
|
|
588
|
+
},
|
|
589
|
+
children: i.map((e) => /* @__PURE__ */ jsx(FieldItem, {
|
|
590
|
+
field: e,
|
|
591
|
+
onSelect: t,
|
|
592
|
+
onDelete: n,
|
|
593
|
+
isSelected: r === e.id,
|
|
594
|
+
isGrouped: !0
|
|
595
|
+
}, e.id))
|
|
596
|
+
})] }, e);
|
|
597
|
+
})]
|
|
598
|
+
})]
|
|
599
|
+
});
|
|
600
|
+
};
|
|
601
|
+
var getTemplateFieldsFromEditor = (e) => {
|
|
602
|
+
let t = e.helpers?.structuredContentCommands;
|
|
603
|
+
return t?.getStructuredContentTags ? (t.getStructuredContentTags(e.state) || []).map((e) => {
|
|
604
|
+
let n = e?.node ?? e, r = n?.attrs ?? {}, i = (n?.type?.name || "").includes("Block") ? "block" : "inline";
|
|
605
|
+
return {
|
|
606
|
+
id: r.id,
|
|
607
|
+
alias: r.alias || r.label || "",
|
|
608
|
+
tag: r.tag,
|
|
609
|
+
mode: i,
|
|
610
|
+
group: t.getGroup?.(r.tag) ?? void 0
|
|
611
|
+
};
|
|
612
|
+
}) : [];
|
|
613
|
+
}, areTemplateFieldsEqual = (e, t) => {
|
|
614
|
+
if (e === t) return !0;
|
|
615
|
+
if (e.length !== t.length) return !1;
|
|
616
|
+
for (let n = 0; n < e.length; n += 1) {
|
|
617
|
+
let r = e[n], i = t[n];
|
|
618
|
+
if (!i || r.id !== i.id || r.alias !== i.alias || r.tag !== i.tag || r.position !== i.position || r.mode !== i.mode || r.group !== i.group) return !1;
|
|
619
|
+
}
|
|
620
|
+
return !0;
|
|
621
|
+
}, resolveToolbar = (e) => {
|
|
622
|
+
if (!e) return null;
|
|
623
|
+
if (e === !0) return {
|
|
624
|
+
selector: "#superdoc-toolbar",
|
|
625
|
+
config: {},
|
|
626
|
+
renderDefaultContainer: !0
|
|
627
|
+
};
|
|
628
|
+
if (typeof e == "string") return {
|
|
629
|
+
selector: e,
|
|
630
|
+
config: {},
|
|
631
|
+
renderDefaultContainer: !1
|
|
632
|
+
};
|
|
633
|
+
let { selector: t, ...n } = e;
|
|
634
|
+
return {
|
|
635
|
+
selector: t || "#superdoc-toolbar",
|
|
636
|
+
config: n,
|
|
637
|
+
renderDefaultContainer: t === void 0
|
|
638
|
+
};
|
|
639
|
+
}, MENU_VIEWPORT_PADDING = 10, MENU_APPROX_WIDTH = 250, MENU_APPROX_HEIGHT = 300, clampToViewport = (e) => {
|
|
640
|
+
let t = window.innerWidth - MENU_APPROX_WIDTH - MENU_VIEWPORT_PADDING, n = window.innerHeight - MENU_APPROX_HEIGHT - MENU_VIEWPORT_PADDING, r = Math.min(e.left, t), i = Math.min(e.top, n);
|
|
641
|
+
return new DOMRect(Math.max(r, MENU_VIEWPORT_PADDING), Math.max(i, MENU_VIEWPORT_PADDING), e.width, e.height);
|
|
642
|
+
}, SuperDocTemplateBuilder = forwardRef((e, c) => {
|
|
643
|
+
let { document: l, fields: p = {}, menu: m = {}, list: h = {}, toolbar: _, cspNonce: v, telemetry: y, licenseKey: b, onReady: x, onTrigger: S, onFieldInsert: C, onFieldUpdate: w, onFieldDelete: T, onFieldsChange: E, onFieldSelect: re, onFieldCreate: D, onExport: O, className: ie, style: ae, documentHeight: oe = "600px" } = e, [k, A] = useState(p.initial || []), [j, M] = useState(null), [N, P] = useState(!1), [se, F] = useState(), [ce, le] = useState(""), [ue, de] = useState(() => p.available || []), I = useRef(null), L = useRef(null), R = useRef(null), z = useRef(p);
|
|
644
|
+
z.current = p;
|
|
645
|
+
let B = useRef(null), V = useRef(N);
|
|
646
|
+
useEffect(() => {
|
|
647
|
+
V.current = N;
|
|
648
|
+
}, [N]);
|
|
649
|
+
let H = m.trigger || "{{", U = z.current.available || [], W = useMemo(() => resolveToolbar(_), [_]), G = useMemo(() => ({
|
|
650
|
+
enabled: y?.enabled ?? !0,
|
|
651
|
+
metadata: {
|
|
652
|
+
source: "template-builder",
|
|
653
|
+
...y?.metadata
|
|
654
|
+
}
|
|
655
|
+
}), [y?.enabled, JSON.stringify(y?.metadata)]), K = useCallback((e) => {
|
|
656
|
+
let t = e.trim().toLowerCase();
|
|
657
|
+
return t ? U.filter((e) => e.label.toLowerCase().includes(t)) : U;
|
|
658
|
+
}, [U]), q = useCallback((e) => {
|
|
659
|
+
le(e), de(K(e));
|
|
660
|
+
}, [K]), J = useCallback(() => {
|
|
661
|
+
q("");
|
|
662
|
+
}, [q]), Y = useCallback((e, t) => {
|
|
663
|
+
if (!L.current?.activeEditor) return !1;
|
|
664
|
+
let n = L.current.activeEditor, r = k, i = e === "inline" ? n.commands.insertStructuredContentInline?.({
|
|
665
|
+
attrs: {
|
|
666
|
+
alias: t.alias,
|
|
667
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
668
|
+
},
|
|
669
|
+
text: t.defaultValue || t.alias
|
|
670
|
+
}) : n.commands.insertStructuredContentBlock?.({
|
|
671
|
+
attrs: {
|
|
672
|
+
alias: t.alias,
|
|
673
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
674
|
+
},
|
|
675
|
+
text: t.defaultValue || t.alias
|
|
676
|
+
});
|
|
677
|
+
if (i) {
|
|
678
|
+
let e = getTemplateFieldsFromEditor(n);
|
|
679
|
+
A(e), E?.(e);
|
|
680
|
+
let t = e.find((e) => !r.some((t) => t.id === e.id));
|
|
681
|
+
t && C?.(t);
|
|
682
|
+
}
|
|
683
|
+
return i ?? !1;
|
|
684
|
+
}, [
|
|
685
|
+
C,
|
|
686
|
+
E,
|
|
687
|
+
k
|
|
688
|
+
]), X = useCallback((e, t) => {
|
|
689
|
+
if (!L.current?.activeEditor) return !1;
|
|
690
|
+
let n = L.current.activeEditor.commands.updateStructuredContentById?.(e, { attrs: t });
|
|
691
|
+
return n && A((n) => {
|
|
692
|
+
let r = n.map((n) => n.id === e ? {
|
|
693
|
+
...n,
|
|
694
|
+
...t
|
|
695
|
+
} : n);
|
|
696
|
+
E?.(r);
|
|
697
|
+
let i = r.find((t) => t.id === e);
|
|
698
|
+
return i && w?.(i), r;
|
|
699
|
+
}), n ?? !1;
|
|
700
|
+
}, [w, E]), Z = useCallback((e) => {
|
|
701
|
+
let t = L.current?.activeEditor;
|
|
702
|
+
if (!t) {
|
|
703
|
+
let t = !1;
|
|
704
|
+
return A((n) => {
|
|
705
|
+
if (!n.some((t) => t.id === e)) return n;
|
|
706
|
+
let r = n.filter((t) => t.id !== e);
|
|
707
|
+
return t = !0, E?.(r), T?.(e), r;
|
|
708
|
+
}), t && M((t) => t === e ? null : t), t;
|
|
709
|
+
}
|
|
710
|
+
let n = k.find((t) => t.id === e)?.group, r = !1;
|
|
711
|
+
try {
|
|
712
|
+
r = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
713
|
+
} catch (t) {
|
|
714
|
+
console.warn("[TemplateBuilder] Failed to delete structured content:", e, t), r = !1;
|
|
715
|
+
}
|
|
716
|
+
let i = getTemplateFieldsFromEditor(t), a = i.some((t) => t.id === e);
|
|
717
|
+
if (!r && a && (i = i.filter((t) => t.id !== e)), n) {
|
|
718
|
+
let e = i.filter((e) => e.group === n);
|
|
719
|
+
if (e.length === 1) {
|
|
720
|
+
let n = e[0];
|
|
721
|
+
t.commands.updateStructuredContentById?.(n.id, { attrs: { tag: void 0 } }), i = getTemplateFieldsFromEditor(t);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
let o = !1;
|
|
725
|
+
return A((t) => {
|
|
726
|
+
if (areTemplateFieldsEqual(t, i)) return t;
|
|
727
|
+
let n = t.some((t) => t.id === e), r = i.some((t) => t.id === e);
|
|
728
|
+
return n && !r && (o = !0), E?.(i), o && T?.(e), i;
|
|
729
|
+
}), o && M((t) => t === e ? null : t), r || o;
|
|
730
|
+
}, [
|
|
731
|
+
T,
|
|
732
|
+
E,
|
|
733
|
+
k
|
|
734
|
+
]), Q = useCallback((e) => {
|
|
735
|
+
if (!L.current?.activeEditor) return;
|
|
736
|
+
L.current.activeEditor.commands.selectStructuredContentById?.(e), M(e);
|
|
737
|
+
let t = k.find((t) => t.id === e);
|
|
738
|
+
t && re?.(t);
|
|
739
|
+
}, [k, re]), $ = useCallback((e) => {
|
|
740
|
+
if (!e) return;
|
|
741
|
+
let t = getTemplateFieldsFromEditor(e);
|
|
742
|
+
A((e) => areTemplateFieldsEqual(e, t) ? e : (E?.(t), t));
|
|
743
|
+
}, [E]);
|
|
744
|
+
useEffect(() => {
|
|
745
|
+
if (!I.current) return;
|
|
746
|
+
let e = !1, t = null;
|
|
747
|
+
return (async () => {
|
|
748
|
+
let { SuperDoc: n } = await import("superdoc");
|
|
749
|
+
if (e) return;
|
|
750
|
+
let r = {
|
|
751
|
+
comments: !1,
|
|
752
|
+
...W && { toolbar: {
|
|
753
|
+
selector: W.selector,
|
|
754
|
+
toolbarGroups: W.config.toolbarGroups || ["center"],
|
|
755
|
+
excludeItems: W.config.excludeItems || [],
|
|
756
|
+
...W.config
|
|
757
|
+
} }
|
|
758
|
+
}, i = () => {
|
|
759
|
+
if (!e) {
|
|
760
|
+
if (t?.activeEditor) {
|
|
761
|
+
let e = t.activeEditor;
|
|
762
|
+
e.on("update", ({ editor: e }) => {
|
|
763
|
+
let { state: t } = e, { from: n } = t.selection;
|
|
764
|
+
if (n >= H.length) {
|
|
765
|
+
let r = n - H.length;
|
|
766
|
+
if (t.doc.textBetween(r, n) === H) {
|
|
767
|
+
let t = e.view.coordsAtPos(n), i = clampToViewport(new DOMRect(t.left, t.top, 0, 0)), a = () => {
|
|
768
|
+
let e = L.current?.activeEditor;
|
|
769
|
+
if (!e) return;
|
|
770
|
+
let t = e.state.selection.from, n = e.state.tr.delete(r, t);
|
|
771
|
+
e.view.dispatch(n);
|
|
772
|
+
};
|
|
773
|
+
R.current = a, B.current = n, F(i), P(!0), J(), S?.({
|
|
774
|
+
position: {
|
|
775
|
+
from: r,
|
|
776
|
+
to: n
|
|
777
|
+
},
|
|
778
|
+
bounds: i,
|
|
779
|
+
cleanup: a
|
|
780
|
+
});
|
|
781
|
+
return;
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
if (!V.current) return;
|
|
785
|
+
if (B.current == null) {
|
|
786
|
+
P(!1), J();
|
|
787
|
+
return;
|
|
788
|
+
}
|
|
789
|
+
if (n < B.current) {
|
|
790
|
+
P(!1), B.current = null, J();
|
|
791
|
+
return;
|
|
792
|
+
}
|
|
793
|
+
q(t.doc.textBetween(B.current, n));
|
|
794
|
+
let r = e.view.coordsAtPos(n);
|
|
795
|
+
F(clampToViewport(new DOMRect(r.left, r.top, 0, 0)));
|
|
796
|
+
}), e.on("update", () => {
|
|
797
|
+
$(e);
|
|
798
|
+
}), $(e);
|
|
799
|
+
}
|
|
800
|
+
x?.();
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
t = new n({
|
|
804
|
+
selector: I.current,
|
|
805
|
+
document: l?.source,
|
|
806
|
+
documentMode: l?.mode || "editing",
|
|
807
|
+
modules: r,
|
|
808
|
+
toolbar: W?.selector,
|
|
809
|
+
cspNonce: v,
|
|
810
|
+
telemetry: G,
|
|
811
|
+
...b && { licenseKey: b },
|
|
812
|
+
onReady: i
|
|
813
|
+
}), L.current = t;
|
|
814
|
+
})(), () => {
|
|
815
|
+
e = !0, R.current = null, B.current = null, t && typeof t.destroy == "function" && t.destroy(), L.current = null;
|
|
816
|
+
};
|
|
817
|
+
}, [
|
|
818
|
+
l?.source,
|
|
819
|
+
l?.mode,
|
|
820
|
+
H,
|
|
821
|
+
$,
|
|
822
|
+
x,
|
|
823
|
+
S,
|
|
824
|
+
W,
|
|
825
|
+
v,
|
|
826
|
+
G,
|
|
827
|
+
b
|
|
828
|
+
]);
|
|
829
|
+
let fe = useCallback(async (e) => {
|
|
830
|
+
R.current &&= (R.current(), null), B.current = null, J();
|
|
831
|
+
let t = e.mode || "inline";
|
|
832
|
+
if (e.id.startsWith("custom_") && D) {
|
|
833
|
+
let n = await D(e);
|
|
834
|
+
if (n) {
|
|
835
|
+
Y(n.mode || t, {
|
|
836
|
+
alias: n.label,
|
|
837
|
+
metadata: n.metadata,
|
|
838
|
+
defaultValue: n.defaultValue
|
|
839
|
+
}), P(!1);
|
|
840
|
+
return;
|
|
841
|
+
}
|
|
842
|
+
}
|
|
843
|
+
Y(t, {
|
|
844
|
+
alias: e.label,
|
|
845
|
+
metadata: e.metadata,
|
|
846
|
+
defaultValue: e.defaultValue
|
|
847
|
+
}), P(!1);
|
|
848
|
+
}, [
|
|
849
|
+
Y,
|
|
850
|
+
D,
|
|
851
|
+
J
|
|
852
|
+
]), pe = useCallback((e) => {
|
|
853
|
+
R.current &&= (R.current(), null), B.current = null, J();
|
|
854
|
+
let t = L.current?.activeEditor;
|
|
855
|
+
if (!t) return;
|
|
856
|
+
let n = t.helpers?.structuredContentCommands;
|
|
857
|
+
if (!n) return;
|
|
858
|
+
let r = e.group || `group-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`, i = n.createTagObject?.({ group: r });
|
|
859
|
+
if ((e.mode || "inline") === "inline" ? t.commands.insertStructuredContentInline?.({
|
|
860
|
+
attrs: {
|
|
861
|
+
alias: e.alias,
|
|
862
|
+
tag: i
|
|
863
|
+
},
|
|
864
|
+
text: e.alias
|
|
865
|
+
}) : t.commands.insertStructuredContentBlock?.({
|
|
866
|
+
attrs: {
|
|
867
|
+
alias: e.alias,
|
|
868
|
+
tag: i
|
|
869
|
+
},
|
|
870
|
+
text: e.alias
|
|
871
|
+
})) {
|
|
872
|
+
e.group || X(e.id, { tag: i }), P(!1);
|
|
873
|
+
let n = getTemplateFieldsFromEditor(t);
|
|
874
|
+
A(n), E?.(n);
|
|
875
|
+
}
|
|
876
|
+
}, [
|
|
877
|
+
X,
|
|
878
|
+
J,
|
|
879
|
+
E
|
|
880
|
+
]), me = useCallback(() => {
|
|
881
|
+
P(!1), B.current = null, J(), R.current &&= (R.current(), null);
|
|
882
|
+
}, [J]), he = useCallback(() => {
|
|
883
|
+
if (!L.current?.activeEditor || k.length === 0) return;
|
|
884
|
+
let e = k.findIndex((e) => e.id === j);
|
|
885
|
+
Q(k[e >= 0 ? (e + 1) % k.length : 0].id);
|
|
886
|
+
}, [
|
|
887
|
+
k,
|
|
888
|
+
j,
|
|
889
|
+
Q
|
|
890
|
+
]), ge = useCallback(() => {
|
|
891
|
+
if (!L.current?.activeEditor || k.length === 0) return;
|
|
892
|
+
let e = k.findIndex((e) => e.id === j);
|
|
893
|
+
Q(k[e > 0 ? e - 1 : k.length - 1].id);
|
|
894
|
+
}, [
|
|
895
|
+
k,
|
|
896
|
+
j,
|
|
897
|
+
Q
|
|
898
|
+
]), _e = useCallback(async (e) => {
|
|
899
|
+
let { fileName: t = "document", triggerDownload: n = !0 } = e || {}, r = await L.current?.export({
|
|
900
|
+
exportType: ["docx"],
|
|
901
|
+
exportedName: t,
|
|
902
|
+
triggerDownload: n
|
|
903
|
+
}), i = L.current?.activeEditor;
|
|
904
|
+
if (i) {
|
|
905
|
+
let e = getTemplateFieldsFromEditor(i);
|
|
906
|
+
O?.({
|
|
907
|
+
fields: e,
|
|
908
|
+
blob: n ? void 0 : r,
|
|
909
|
+
fileName: t
|
|
910
|
+
});
|
|
911
|
+
}
|
|
912
|
+
return r;
|
|
913
|
+
}, [O]);
|
|
914
|
+
useImperativeHandle(c, () => ({
|
|
915
|
+
insertField: (e) => Y("inline", e),
|
|
916
|
+
insertBlockField: (e) => Y("block", e),
|
|
917
|
+
updateField: X,
|
|
918
|
+
deleteField: Z,
|
|
919
|
+
selectField: Q,
|
|
920
|
+
nextField: he,
|
|
921
|
+
previousField: ge,
|
|
922
|
+
getFields: () => k,
|
|
923
|
+
exportTemplate: _e,
|
|
924
|
+
getSuperDoc: () => L.current
|
|
925
|
+
}));
|
|
926
|
+
let ve = m.component || FieldMenu, ye = h.component || FieldList;
|
|
927
|
+
return /* @__PURE__ */ jsxs("div", {
|
|
928
|
+
className: `superdoc-template-builder ${ie || ""}`,
|
|
929
|
+
style: ae,
|
|
930
|
+
children: [/* @__PURE__ */ jsxs("div", {
|
|
931
|
+
style: {
|
|
932
|
+
display: "flex",
|
|
933
|
+
gap: "20px"
|
|
934
|
+
},
|
|
935
|
+
children: [
|
|
936
|
+
h.position === "left" && /* @__PURE__ */ jsx("div", {
|
|
937
|
+
className: "superdoc-template-builder-sidebar",
|
|
938
|
+
children: /* @__PURE__ */ jsx(ye, {
|
|
939
|
+
fields: k,
|
|
940
|
+
onSelect: (e) => Q(e.id),
|
|
941
|
+
onDelete: Z,
|
|
942
|
+
onUpdate: (e) => X(e.id, e),
|
|
943
|
+
selectedFieldId: j || void 0
|
|
944
|
+
})
|
|
945
|
+
}),
|
|
946
|
+
/* @__PURE__ */ jsxs("div", {
|
|
947
|
+
className: "superdoc-template-builder-document",
|
|
948
|
+
style: { flex: 1 },
|
|
949
|
+
children: [W?.renderDefaultContainer && /* @__PURE__ */ jsx("div", {
|
|
950
|
+
id: "superdoc-toolbar",
|
|
951
|
+
className: "superdoc-template-builder-toolbar",
|
|
952
|
+
"data-testid": "template-builder-toolbar"
|
|
953
|
+
}), /* @__PURE__ */ jsx("div", {
|
|
954
|
+
ref: I,
|
|
955
|
+
className: "superdoc-template-builder-editor",
|
|
956
|
+
style: { height: oe },
|
|
957
|
+
"data-testid": "template-builder-editor"
|
|
958
|
+
})]
|
|
959
|
+
}),
|
|
960
|
+
h.position === "right" && /* @__PURE__ */ jsx("div", {
|
|
961
|
+
className: "superdoc-template-builder-sidebar",
|
|
962
|
+
children: /* @__PURE__ */ jsx(ye, {
|
|
963
|
+
fields: k,
|
|
964
|
+
onSelect: (e) => Q(e.id),
|
|
965
|
+
onDelete: Z,
|
|
966
|
+
onUpdate: (e) => X(e.id, e),
|
|
967
|
+
selectedFieldId: j || void 0
|
|
968
|
+
})
|
|
969
|
+
})
|
|
970
|
+
]
|
|
971
|
+
}), /* @__PURE__ */ jsx(ve, {
|
|
972
|
+
isVisible: N,
|
|
973
|
+
position: se,
|
|
974
|
+
availableFields: p.available || [],
|
|
975
|
+
filteredFields: ue,
|
|
976
|
+
filterQuery: ce,
|
|
977
|
+
allowCreate: p.allowCreate || !1,
|
|
978
|
+
onSelect: fe,
|
|
979
|
+
onClose: me,
|
|
980
|
+
onCreateField: D,
|
|
981
|
+
existingFields: k,
|
|
982
|
+
onSelectExisting: pe
|
|
983
|
+
})]
|
|
984
|
+
});
|
|
985
|
+
});
|
|
986
|
+
SuperDocTemplateBuilder.displayName = "SuperDocTemplateBuilder";
|
|
987
|
+
var src_default = SuperDocTemplateBuilder;
|
|
988
|
+
export { FieldList, FieldMenu, src_default as default };
|