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