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