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