@superdoc-dev/template-builder 0.1.0 → 0.2.0-next.2
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 +408 -394
- 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
|
|
22
|
-
|
|
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 D in n)
|
|
22
|
+
D !== "key" && (i[D] = n[D]);
|
|
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 W:
|
|
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 T:
|
|
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) {
|
|
@@ -132,9 +132,9 @@ function De() {
|
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
135
|
+
function D(e, s) {
|
|
136
136
|
function f() {
|
|
137
|
-
|
|
137
|
+
I || (I = !0, console.error(
|
|
138
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
139
|
s
|
|
140
140
|
));
|
|
@@ -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: L,
|
|
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,93 +209,93 @@ 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 && D(
|
|
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
|
}
|
|
234
234
|
function N(e) {
|
|
235
|
-
|
|
235
|
+
R(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? R(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
237
|
+
function R(e) {
|
|
238
|
+
return typeof e == "object" && e !== null && e.$$typeof === L;
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var V = Ae, L = 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"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), W = 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, w = 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
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
)(), ne =
|
|
248
|
+
var I, re = {}, M = V.react_stack_bottom_frame.bind(
|
|
249
|
+
V,
|
|
250
|
+
i
|
|
251
|
+
)(), ne = w(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") :
|
|
260
|
-
d ?
|
|
259
|
+
d ? Error("react-stack-top-frame") : M,
|
|
260
|
+
d ? w(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") :
|
|
270
|
-
d ?
|
|
269
|
+
d ? Error("react-stack-top-frame") : M,
|
|
270
|
+
d ? w(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
|
-
onClose:
|
|
288
|
+
onClose: D,
|
|
289
289
|
onCreateField: H
|
|
290
290
|
}) => {
|
|
291
|
-
const [U,
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
}, [
|
|
295
|
-
const
|
|
291
|
+
const [U, P] = z(!1), [N, R] = z("");
|
|
292
|
+
ue(() => {
|
|
293
|
+
a || (P(!1), R(""));
|
|
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]), L = c ?? p, G = !!n, O = ye(() => {
|
|
307
|
+
const l = [], g = /* @__PURE__ */ new Map();
|
|
308
|
+
return L.forEach((E) => {
|
|
309
|
+
const T = E.category?.trim() || "Uncategorized", k = g.get(T);
|
|
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(T, l.length), l.push({ category: T, fields: [E] });
|
|
315
|
+
}), l;
|
|
316
|
+
}, [L]), [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: T }, k) => {
|
|
324
|
+
const W = G ? !0 : l[T] ?? k === 0;
|
|
325
|
+
g[T] = W, !E && l[T] !== W && (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), R("");
|
|
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) => R(l.target.value),
|
|
397
|
+
onKeyDown: (l) => {
|
|
398
|
+
l.key === "Enter" && A(), l.key === "Escape" && (P(!1), R(""));
|
|
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), R("");
|
|
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 T = !!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: T ? "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": !T,
|
|
531
531
|
style: {
|
|
532
532
|
overflow: "hidden",
|
|
533
|
-
maxHeight:
|
|
534
|
-
opacity:
|
|
533
|
+
maxHeight: T ? k : "0px",
|
|
534
|
+
opacity: T ? 1 : 0,
|
|
535
535
|
transition: "max-height 0.2s ease, opacity 0.2s ease",
|
|
536
|
-
pointerEvents:
|
|
536
|
+
pointerEvents: T ? "auto" : "none"
|
|
537
537
|
},
|
|
538
|
-
children: /* @__PURE__ */
|
|
538
|
+
children: /* @__PURE__ */ o.jsx("div", { style: { padding: T ? "4px 0" : 0 }, children: g.map((W) => /* @__PURE__ */ o.jsx(
|
|
539
539
|
"div",
|
|
540
540
|
{
|
|
541
541
|
className: "field-menu-item",
|
|
542
|
-
onClick: () => F(
|
|
542
|
+
onClick: () => F(W),
|
|
543
543
|
style: {
|
|
544
544
|
padding: "8px 16px",
|
|
545
545
|
cursor: "pointer",
|
|
@@ -547,28 +547,28 @@ 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: W.label })
|
|
551
551
|
},
|
|
552
|
-
|
|
552
|
+
W.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
|
-
onClick:
|
|
571
|
+
onClick: D,
|
|
572
572
|
style: {
|
|
573
573
|
width: "100%",
|
|
574
574
|
padding: "6px 16px",
|
|
@@ -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
|
-
onReady:
|
|
776
|
+
onReady: D,
|
|
769
777
|
onTrigger: H,
|
|
770
778
|
onFieldInsert: U,
|
|
771
|
-
onFieldUpdate:
|
|
779
|
+
onFieldUpdate: P,
|
|
772
780
|
onFieldDelete: N,
|
|
773
|
-
onFieldsChange:
|
|
774
|
-
onFieldSelect:
|
|
775
|
-
onFieldCreate:
|
|
776
|
-
className:
|
|
781
|
+
onFieldsChange: R,
|
|
782
|
+
onFieldSelect: V,
|
|
783
|
+
onFieldCreate: L,
|
|
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), [T, k] = z(), [W, fe] = z(""), [ee, ie] = z(() => c.available || []), te = Z(null), w = Z(null), I = Z(null), re = Z(c);
|
|
782
790
|
re.current = c;
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
ne.current =
|
|
786
|
-
}, [
|
|
787
|
-
const
|
|
791
|
+
const M = 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
|
-
if (!
|
|
806
|
-
const
|
|
813
|
+
if (!w.current?.activeEditor) return !1;
|
|
814
|
+
const b = w.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 = [...
|
|
829
|
-
return
|
|
830
|
-
}), U?.(
|
|
835
|
+
Y((m) => {
|
|
836
|
+
const u = [...m, j];
|
|
837
|
+
return R?.(u), u;
|
|
838
|
+
}), U?.(j);
|
|
831
839
|
}
|
|
832
840
|
return S;
|
|
833
841
|
},
|
|
834
|
-
[U,
|
|
835
|
-
), oe =
|
|
842
|
+
[U, R]
|
|
843
|
+
), oe = C(
|
|
836
844
|
(t, r) => {
|
|
837
|
-
if (!
|
|
838
|
-
const y =
|
|
845
|
+
if (!w.current?.activeEditor) return !1;
|
|
846
|
+
const y = w.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
|
-
|
|
846
|
-
const
|
|
847
|
-
return
|
|
853
|
+
R?.(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, R]
|
|
859
|
+
), h = C(
|
|
852
860
|
(t) => {
|
|
853
|
-
const r =
|
|
861
|
+
const r = w.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, R?.(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), R?.(y), y;
|
|
891
|
+
}), j && (N?.(t), l((m) => m === t ? null : m)), b || j;
|
|
884
892
|
},
|
|
885
|
-
[N,
|
|
886
|
-
),
|
|
893
|
+
[N, R]
|
|
894
|
+
), _ = C(
|
|
887
895
|
(t) => {
|
|
888
|
-
if (!
|
|
889
|
-
|
|
890
|
-
const
|
|
891
|
-
|
|
896
|
+
if (!w.current?.activeEditor) return;
|
|
897
|
+
w.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 : (R?.(r), r));
|
|
899
907
|
},
|
|
900
|
-
[
|
|
908
|
+
[R]
|
|
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
|
|
916
|
-
|
|
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 = () => {
|
|
926
|
+
const le = w.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
|
-
|
|
922
|
-
position: { from:
|
|
923
|
-
bounds:
|
|
931
|
+
I.current = be, M.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 (M.current == null) {
|
|
932
942
|
E(!1), d();
|
|
933
943
|
return;
|
|
934
944
|
}
|
|
935
|
-
if (u <
|
|
936
|
-
E(!1),
|
|
945
|
+
if (u < M.current) {
|
|
946
|
+
E(!1), M.current = null, d();
|
|
937
947
|
return;
|
|
938
948
|
}
|
|
939
|
-
const Q =
|
|
940
|
-
|
|
949
|
+
const Q = m.doc.textBetween(
|
|
950
|
+
M.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
|
+
D?.();
|
|
951
963
|
}
|
|
952
964
|
}, y = new r({
|
|
953
|
-
...
|
|
965
|
+
...b,
|
|
954
966
|
...X && {
|
|
955
967
|
toolbar: X.selector,
|
|
956
968
|
modules: {
|
|
@@ -963,25 +975,27 @@ const Le = ({
|
|
|
963
975
|
}
|
|
964
976
|
}
|
|
965
977
|
});
|
|
966
|
-
|
|
978
|
+
w.current = y;
|
|
967
979
|
})(), () => {
|
|
968
|
-
|
|
980
|
+
I.current = null, M.current = null;
|
|
981
|
+
const r = w.current;
|
|
982
|
+
r && typeof r.destroy == "function" && r.destroy(), w.current = null;
|
|
969
983
|
}) : void 0, [
|
|
970
|
-
|
|
971
|
-
|
|
984
|
+
p?.source,
|
|
985
|
+
p?.mode,
|
|
986
|
+
J,
|
|
972
987
|
q,
|
|
973
|
-
|
|
974
|
-
I,
|
|
988
|
+
D,
|
|
975
989
|
H,
|
|
976
990
|
F
|
|
977
991
|
]);
|
|
978
|
-
const
|
|
992
|
+
const pe = C(
|
|
979
993
|
async (t) => {
|
|
980
|
-
if (
|
|
994
|
+
if (I.current && (I.current(), I.current = null), M.current = null, d(), t.id.startsWith("custom_") && L)
|
|
981
995
|
try {
|
|
982
|
-
const r = await
|
|
996
|
+
const r = await L(t);
|
|
983
997
|
if (r) {
|
|
984
|
-
|
|
998
|
+
B("inline", {
|
|
985
999
|
alias: r.label,
|
|
986
1000
|
category: r.category,
|
|
987
1001
|
metadata: r.metadata,
|
|
@@ -992,34 +1006,34 @@ const Le = ({
|
|
|
992
1006
|
} catch (r) {
|
|
993
1007
|
console.error("Field creation failed:", r);
|
|
994
1008
|
}
|
|
995
|
-
|
|
1009
|
+
B("inline", {
|
|
996
1010
|
alias: t.label,
|
|
997
1011
|
category: t.category,
|
|
998
1012
|
metadata: t.metadata,
|
|
999
1013
|
defaultValue: t.defaultValue
|
|
1000
1014
|
}), E(!1);
|
|
1001
1015
|
},
|
|
1002
|
-
[
|
|
1003
|
-
), je =
|
|
1004
|
-
E(!1),
|
|
1005
|
-
}, [d]),
|
|
1006
|
-
if (!
|
|
1016
|
+
[B, L, d]
|
|
1017
|
+
), je = C(() => {
|
|
1018
|
+
E(!1), M.current = null, d(), I.current && (I.current(), I.current = null);
|
|
1019
|
+
}, [d]), Ce = C(() => {
|
|
1020
|
+
if (!w.current?.activeEditor || v.length === 0)
|
|
1007
1021
|
return;
|
|
1008
1022
|
const t = v.findIndex(
|
|
1009
|
-
(
|
|
1023
|
+
(b) => b.id === A
|
|
1010
1024
|
), r = t >= 0 ? (t + 1) % v.length : 0;
|
|
1011
|
-
|
|
1012
|
-
}, [v,
|
|
1013
|
-
if (!
|
|
1025
|
+
_(v[r].id);
|
|
1026
|
+
}, [v, A, _]), ke = C(() => {
|
|
1027
|
+
if (!w.current?.activeEditor || v.length === 0)
|
|
1014
1028
|
return;
|
|
1015
1029
|
const t = v.findIndex(
|
|
1016
|
-
(
|
|
1030
|
+
(b) => b.id === A
|
|
1017
1031
|
), r = t > 0 ? t - 1 : v.length - 1;
|
|
1018
|
-
|
|
1019
|
-
}, [v,
|
|
1032
|
+
_(v[r].id);
|
|
1033
|
+
}, [v, A, _]), Se = C(
|
|
1020
1034
|
async (t) => {
|
|
1021
1035
|
try {
|
|
1022
|
-
await
|
|
1036
|
+
await w.current?.export({
|
|
1023
1037
|
exportType: ["docx"],
|
|
1024
1038
|
exportedName: t?.fileName ? t?.fileName : "document"
|
|
1025
1039
|
});
|
|
@@ -1029,36 +1043,36 @@ const Le = ({
|
|
|
1029
1043
|
},
|
|
1030
1044
|
[]
|
|
1031
1045
|
);
|
|
1032
|
-
|
|
1033
|
-
insertField: (t) =>
|
|
1034
|
-
insertBlockField: (t) =>
|
|
1046
|
+
Me(x, () => ({
|
|
1047
|
+
insertField: (t) => B("inline", t),
|
|
1048
|
+
insertBlockField: (t) => B("block", t),
|
|
1035
1049
|
updateField: oe,
|
|
1036
|
-
deleteField:
|
|
1037
|
-
selectField:
|
|
1038
|
-
nextField:
|
|
1039
|
-
previousField:
|
|
1050
|
+
deleteField: h,
|
|
1051
|
+
selectField: _,
|
|
1052
|
+
nextField: Ce,
|
|
1053
|
+
previousField: ke,
|
|
1040
1054
|
getFields: () => v,
|
|
1041
|
-
exportTemplate:
|
|
1055
|
+
exportTemplate: Se
|
|
1042
1056
|
}));
|
|
1043
|
-
const
|
|
1044
|
-
return /* @__PURE__ */
|
|
1057
|
+
const Fe = n.component || Be, xe = i.component || $e, X = Ve(F);
|
|
1058
|
+
return /* @__PURE__ */ o.jsxs(
|
|
1045
1059
|
"div",
|
|
1046
1060
|
{
|
|
1047
|
-
className: `superdoc-template-builder ${
|
|
1061
|
+
className: `superdoc-template-builder ${G || ""}`,
|
|
1048
1062
|
style: O,
|
|
1049
1063
|
children: [
|
|
1050
|
-
/* @__PURE__ */
|
|
1051
|
-
|
|
1052
|
-
|
|
1064
|
+
/* @__PURE__ */ o.jsxs("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1065
|
+
i.position === "left" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1066
|
+
xe,
|
|
1053
1067
|
{
|
|
1054
1068
|
fields: v,
|
|
1055
|
-
onSelect: (t) =>
|
|
1056
|
-
onDelete:
|
|
1057
|
-
selectedFieldId:
|
|
1069
|
+
onSelect: (t) => _(t.id),
|
|
1070
|
+
onDelete: h,
|
|
1071
|
+
selectedFieldId: A || void 0
|
|
1058
1072
|
}
|
|
1059
1073
|
) }),
|
|
1060
|
-
/* @__PURE__ */
|
|
1061
|
-
X?.renderDefaultContainer && /* @__PURE__ */
|
|
1074
|
+
/* @__PURE__ */ o.jsxs("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1075
|
+
X?.renderDefaultContainer && /* @__PURE__ */ o.jsx(
|
|
1062
1076
|
"div",
|
|
1063
1077
|
{
|
|
1064
1078
|
id: "superdoc-toolbar",
|
|
@@ -1066,7 +1080,7 @@ const Le = ({
|
|
|
1066
1080
|
"data-testid": "template-builder-toolbar"
|
|
1067
1081
|
}
|
|
1068
1082
|
),
|
|
1069
|
-
/* @__PURE__ */
|
|
1083
|
+
/* @__PURE__ */ o.jsx(
|
|
1070
1084
|
"div",
|
|
1071
1085
|
{
|
|
1072
1086
|
ref: te,
|
|
@@ -1076,37 +1090,37 @@ const Le = ({
|
|
|
1076
1090
|
}
|
|
1077
1091
|
)
|
|
1078
1092
|
] }),
|
|
1079
|
-
|
|
1080
|
-
|
|
1093
|
+
i.position === "right" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1094
|
+
xe,
|
|
1081
1095
|
{
|
|
1082
1096
|
fields: v,
|
|
1083
|
-
onSelect: (t) =>
|
|
1084
|
-
onDelete:
|
|
1085
|
-
selectedFieldId:
|
|
1097
|
+
onSelect: (t) => _(t.id),
|
|
1098
|
+
onDelete: h,
|
|
1099
|
+
selectedFieldId: A || void 0
|
|
1086
1100
|
}
|
|
1087
1101
|
) })
|
|
1088
1102
|
] }),
|
|
1089
|
-
/* @__PURE__ */
|
|
1090
|
-
|
|
1103
|
+
/* @__PURE__ */ o.jsx(
|
|
1104
|
+
Fe,
|
|
1091
1105
|
{
|
|
1092
|
-
isVisible:
|
|
1093
|
-
position:
|
|
1106
|
+
isVisible: g,
|
|
1107
|
+
position: T,
|
|
1094
1108
|
availableFields: c.available || [],
|
|
1095
1109
|
filteredFields: ee,
|
|
1096
|
-
filterQuery:
|
|
1110
|
+
filterQuery: W,
|
|
1097
1111
|
allowCreate: c.allowCreate || !1,
|
|
1098
|
-
onSelect:
|
|
1112
|
+
onSelect: pe,
|
|
1099
1113
|
onClose: je,
|
|
1100
|
-
onCreateField:
|
|
1114
|
+
onCreateField: L
|
|
1101
1115
|
}
|
|
1102
1116
|
)
|
|
1103
1117
|
]
|
|
1104
1118
|
}
|
|
1105
1119
|
);
|
|
1106
1120
|
});
|
|
1107
|
-
|
|
1121
|
+
He.displayName = "SuperDocTemplateBuilder";
|
|
1108
1122
|
export {
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1123
|
+
$e as FieldList,
|
|
1124
|
+
Be as FieldMenu,
|
|
1125
|
+
He as default
|
|
1112
1126
|
};
|