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