@superdoc-dev/template-builder 0.2.0 → 0.3.0

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