@superdoc-dev/template-builder 0.2.0-next.2 → 0.2.0-next.4
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/README.md +5 -5
- package/dist/defaults/FieldMenu.d.ts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +235 -238
- package/dist/types.d.ts +8 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -24,9 +24,9 @@ function TemplateEditor() {
|
|
|
24
24
|
|
|
25
25
|
fields={{
|
|
26
26
|
available: [
|
|
27
|
-
{ id: '
|
|
28
|
-
{ id: '
|
|
29
|
-
{ id: '
|
|
27
|
+
{ id: '1324567890', label: 'Customer Name', category: 'Contact' },
|
|
28
|
+
{ id: '1324567891', label: 'Invoice Date', category: 'Invoice' },
|
|
29
|
+
{ id: '1324567892', label: 'Amount', category: 'Invoice' }
|
|
30
30
|
]
|
|
31
31
|
}}
|
|
32
32
|
|
|
@@ -47,8 +47,8 @@ function TemplateEditor() {
|
|
|
47
47
|
```javascript
|
|
48
48
|
{
|
|
49
49
|
fields: [
|
|
50
|
-
{ id: "
|
|
51
|
-
{ id: "
|
|
50
|
+
{ id: "1324567890", alias: "Customer Name", tag: "contact" },
|
|
51
|
+
{ id: "1324567891", alias: "Invoice Date", tag: "invoice" }
|
|
52
52
|
],
|
|
53
53
|
document: { /* ProseMirror document JSON */ }
|
|
54
54
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"FieldMenu.d.ts","sourceRoot":"","sources":["../../src/defaults/FieldMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,
|
|
1
|
+
{"version":3,"file":"FieldMenu.d.ts","sourceRoot":"","sources":["../../src/defaults/FieldMenu.tsx"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAmB,cAAc,EAAE,MAAM,UAAU,CAAC;AAEhE,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAkV9C,CAAC"}
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AASA,OAAO,KAAK,KAAK,KAAK,MAAM,SAAS,CAAC;AACtC,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAElD,cAAc,SAAS,CAAC;AACxB,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,CAAC;AAsGhC,QAAA,MAAM,uBAAuB,oJA4jB3B,CAAC;AAIH,eAAe,uBAAuB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";var Ae=Object.create;var
|
|
1
|
+
"use strict";var Ae=Object.create;var be=Object.defineProperty;var Me=Object.getOwnPropertyDescriptor;var Ie=Object.getOwnPropertyNames;var De=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var We=(o,u,f,d)=>{if(u&&typeof u=="object"||typeof u=="function")for(let r of Ie(u))!Le.call(o,r)&&r!==f&&be(o,r,{get:()=>u[r],enumerable:!(d=Me(u,r))||d.enumerable});return o};var Be=(o,u,f)=>(f=o!=null?Ae(De(o)):{},We(u||!o||!o.__esModule?be(f,"default",{value:o,enumerable:!0}):f,o));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const i=require("react");var ie={exports:{}},ne={};/**
|
|
2
2
|
* @license React
|
|
3
3
|
* react-jsx-runtime.production.js
|
|
4
4
|
*
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
*
|
|
7
7
|
* This source code is licensed under the MIT license found in the
|
|
8
8
|
* LICENSE file in the root directory of this source tree.
|
|
9
|
-
*/var
|
|
9
|
+
*/var he;function Ve(){if(he)return ne;he=1;var o=Symbol.for("react.transitional.element"),u=Symbol.for("react.fragment");function f(d,r,l){var F=null;if(l!==void 0&&(F=""+l),r.key!==void 0&&(F=""+r.key),"key"in r){l={};for(var D in r)D!=="key"&&(l[D]=r[D])}else l=r;return r=l.ref,{$$typeof:o,type:d,key:F,ref:r!==void 0?r:null,props:l}}return ne.Fragment=u,ne.jsx=f,ne.jsxs=f,ne}var oe={};/**
|
|
10
10
|
* @license React
|
|
11
11
|
* react-jsx-runtime.development.js
|
|
12
12
|
*
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
*
|
|
15
15
|
* This source code is licensed under the MIT license found in the
|
|
16
16
|
* LICENSE file in the root directory of this source tree.
|
|
17
|
-
*/var
|
|
17
|
+
*/var ye;function Ye(){return ye||(ye=1,process.env.NODE_ENV!=="production"&&(function(){function o(e){if(e==null)return null;if(typeof e=="function")return e.$$typeof===ce?null:e.displayName||e.name||null;if(typeof e=="string")return e;switch(e){case O:return"Fragment";case v:return"Profiler";case Z:return"StrictMode";case b:return"Suspense";case E:return"SuspenseList";case W:return"Activity"}if(typeof e=="object")switch(typeof e.tag=="number"&&console.error("Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."),e.$$typeof){case q:return"Portal";case A:return e.displayName||"Context";case $:return(e._context.displayName||"Context")+".Consumer";case c:var a=e.render;return e=e.displayName,e||(e=a.displayName||a.name||"",e=e!==""?"ForwardRef("+e+")":"ForwardRef"),e;case T:return a=e.displayName||null,a!==null?a:o(e.type)||"Memo";case j:a=e._payload,e=e._init;try{return o(e(a))}catch{}}return null}function u(e){return""+e}function f(e){try{u(e);var a=!1}catch{a=!0}if(a){a=console;var m=a.error,p=typeof Symbol=="function"&&Symbol.toStringTag&&e[Symbol.toStringTag]||e.constructor.name||"Object";return m.call(a,"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",p),u(e)}}function d(e){if(e===O)return"<>";if(typeof e=="object"&&e!==null&&e.$$typeof===j)return"<...>";try{var a=o(e);return a?"<"+a+">":"<...>"}catch{return"<...>"}}function r(){var e=K.A;return e===null?null:e.getOwner()}function l(){return Error("react-stack-top-frame")}function F(e){if(se.call(e,"key")){var a=Object.getOwnPropertyDescriptor(e,"key").get;if(a&&a.isReactWarning)return!1}return e.key!==void 0}function D(e,a){function m(){M||(M=!0,console.error("%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)",a))}m.isReactWarning=!0,Object.defineProperty(e,"key",{get:m,configurable:!0})}function z(){var e=o(this.type);return te[e]||(te[e]=!0,console.error("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.")),e=this.props.ref,e!==void 0?e:null}function H(e,a,m,p,B,J){var h=m.ref;return e={$$typeof:L,type:e,key:a,props:m,_owner:p},(h!==void 0?h:null)!==null?Object.defineProperty(e,"ref",{enumerable:!1,get:z}):Object.defineProperty(e,"ref",{enumerable:!1,value:null}),e._store={},Object.defineProperty(e._store,"validated",{configurable:!1,enumerable:!1,writable:!0,value:0}),Object.defineProperty(e,"_debugInfo",{configurable:!1,enumerable:!1,writable:!0,value:null}),Object.defineProperty(e,"_debugStack",{configurable:!1,enumerable:!1,writable:!0,value:B}),Object.defineProperty(e,"_debugTask",{configurable:!1,enumerable:!1,writable:!0,value:J}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function P(e,a,m,p,B,J){var h=a.children;if(h!==void 0)if(p)if(ee(h)){for(p=0;p<h.length;p++)N(h[p]);Object.freeze&&Object.freeze(h)}else console.error("React.jsx: Static children should always be an array. You are likely explicitly calling React.jsxs or React.jsxDEV. Use the Babel transform instead.");else N(h);if(se.call(a,"key")){h=o(e);var _=Object.keys(a).filter(function(ue){return ue!=="key"});p=0<_.length?"{key: someKey, "+_.join(": ..., ")+": ...}":"{key: someKey}",G[h+p]||(_=0<_.length?"{"+_.join(": ..., ")+": ...}":"{}",console.error(`A props object containing a "key" prop is being spread into JSX:
|
|
18
18
|
let props = %s;
|
|
19
19
|
<%s {...props} />
|
|
20
20
|
React keys must be passed directly to JSX without using spread:
|
|
21
21
|
let props = %s;
|
|
22
|
-
<%s key={someKey} {...props} />`,p,h,w,h),q[h+p]=!0)}if(h=null,x!==void 0&&(f(x),h=""+x),F(a)&&(f(a.key),h=""+a.key),"key"in a){x={};for(var G in a)G!=="key"&&(x[G]=a[G])}else x=a;return h&&D(x,typeof e=="function"?e.displayName||e.name||"Unknown":e),H(e,h,x,n(),B,re)}function N(e){C(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?C(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function C(e){return typeof e=="object"&&e!==null&&e.$$typeof===L}var V=i,L=Symbol.for("react.transitional.element"),U=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),Q=Symbol.for("react.strict_mode"),E=Symbol.for("react.profiler"),Y=Symbol.for("react.consumer"),A=Symbol.for("react.context"),u=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),R=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),Z=V.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=Object.prototype.hasOwnProperty,K=Array.isArray,k=console.createTask?console.createTask:function(){return null};V={react_stack_bottom_frame:function(e){return e()}};var M,ee={},I=V.react_stack_bottom_frame.bind(V,c)(),te=k(l(c)),q={};oe.Fragment=O,oe.jsx=function(e,a,x){var p=1e4>Z.recentlyCreatedOwnerStacks++;return P(e,a,x,!1,p?Error("react-stack-top-frame"):I,p?k(l(e)):te)},oe.jsxs=function(e,a,x){var p=1e4>Z.recentlyCreatedOwnerStacks++;return P(e,a,x,!0,p?Error("react-stack-top-frame"):I,p?k(l(e)):te)}})()),oe}var ye;function Ye(){return ye||(ye=1,process.env.NODE_ENV==="production"?ie.exports=$e():ie.exports=Ve()),ie.exports}var s=Ye();const Ce=({isVisible:o,position:d,availableFields:f,filteredFields:l,filterQuery:n,allowCreate:c,onSelect:F,onClose:D,onCreateField:z})=>{const[H,P]=i.useState(!1),[N,C]=i.useState("");i.useEffect(()=>{o||(P(!1),C(""))},[o]);const V=i.useMemo(()=>({position:"absolute",left:d?.left,top:d?.top,zIndex:1e3,background:"white",border:"1px solid #ddd",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"8px 0",minWidth:"200px"}),[d]),L=l??f,U=!!n,O=i.useMemo(()=>{const u=[],b=new Map;return L.forEach(R=>{const T=R.category?.trim()||"Uncategorized",j=b.get(T);if(j!==void 0){u[j].fields.push(R);return}b.set(T,u.length),u.push({category:T,fields:[R]})}),u},[L]),[Q,E]=i.useState({});i.useEffect(()=>{E(u=>{if(O.length===0)return Object.keys(u).length===0?u:{};const b={};let R=Object.keys(u).length!==O.length;return O.forEach(({category:T},j)=>{const W=U?!0:u[T]??j===0;b[T]=W,!R&&u[T]!==W&&(R=!0)}),R?b:u})},[O,U]);const Y=i.useCallback(u=>{E(b=>({...b,[u]:!b[u]}))},[]);if(!o)return null;const A=async()=>{const u=N.trim();if(!u)return;const b={id:`custom_${Date.now()}`,label:u,category:"Custom"};try{if(z){const R=await z(b);F(R||b)}else F(b)}finally{P(!1),C("")}};return s.jsxs("div",{className:"superdoc-field-menu",style:V,children:[U&&s.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid #f0f0f0",marginBottom:"4px"},children:s.jsxs("div",{style:{fontSize:"12px",color:"#6b7280"},children:["Filtering results for",s.jsx("span",{style:{fontWeight:600,color:"#111827",marginLeft:"4px"},children:n})]})}),c&&!H&&s.jsx("div",{className:"field-menu-item",onClick:()=>P(!0),style:{padding:"8px 16px",cursor:"pointer",color:"#0066cc",fontWeight:500},children:"+ Create New Field"}),c&&H&&s.jsxs("div",{style:{padding:"8px 16px"},children:[s.jsx("input",{type:"text",value:N,placeholder:"Field name...",onChange:u=>C(u.target.value),onKeyDown:u=>{u.key==="Enter"&&A(),u.key==="Escape"&&(P(!1),C(""))},autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid #ddd",borderRadius:"3px"}}),s.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px"},children:[s.jsx("button",{onClick:A,disabled:!N.trim(),style:{padding:"4px 12px",background:N.trim()?"#0066cc":"#ccc",color:"white",border:"none",borderRadius:"3px",cursor:N.trim()?"pointer":"not-allowed"},children:"Create"}),s.jsx("button",{onClick:()=>{P(!1),C("")},style:{padding:"4px 12px",background:"white",border:"1px solid #ddd",borderRadius:"3px",cursor:"pointer"},children:"Cancel"})]})]}),c&&f.length>0&&s.jsx("div",{style:{borderTop:"1px solid #eee",margin:"4px 0"}}),O.length===0?s.jsx("div",{style:{padding:"16px",fontSize:"13px",color:"#6b7280",textAlign:"center"},children:"No matching fields"}):O.map(({category:u,fields:b},R)=>{const T=!!Q[u],j=`${Math.max(b.length*40,0)}px`;return s.jsxs("div",{style:{borderTop:R===0&&c?void 0:"1px solid #f0f0f0"},children:[s.jsxs("button",{type:"button",onClick:()=>Y(u),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,textAlign:"left"},children:[s.jsxs("span",{children:[u," (",b.length,")"]}),s.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:T?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease",marginLeft:"12px"}})]}),s.jsx("div",{"data-category":u,"aria-hidden":!T,style:{overflow:"hidden",maxHeight:T?j:"0px",opacity:T?1:0,transition:"max-height 0.2s ease, opacity 0.2s ease",pointerEvents:T?"auto":"none"},children:s.jsx("div",{style:{padding:T?"4px 0":0},children:b.map(W=>s.jsx("div",{className:"field-menu-item",onClick:()=>F(W),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:s.jsx("span",{style:{fontWeight:500},children:W.label})},W.id))})})]},u)}),s.jsx("div",{style:{borderTop:"1px solid #eee",marginTop:"4px"},children:s.jsx("button",{onClick:D,style:{width:"100%",padding:"6px 16px",background:"#f3f4f6",border:"none",borderRadius:"0 0 4px 4px",cursor:"pointer"},children:"Close"})})]})},Te=({fields:o,onSelect:d,onDelete:f,selectedFieldId:l})=>s.jsxs("div",{className:"superdoc-field-list",style:{width:"250px",background:"white",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px"},children:[s.jsxs("h3",{style:{margin:"0 0 16px 0",fontSize:"16px",fontWeight:"600"},children:["Template Fields (",o.length,")"]}),o.length===0?s.jsxs("div",{style:{color:"#9ca3af",fontSize:"14px",textAlign:"center",padding:"20px 0"},children:["No fields yet. Type ","{{"," to add a field."]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:o.map(n=>s.jsxs("div",{onClick:()=>d(n),style:{position:"relative",padding:"12px",background:l===n.id?"#eff6ff":"#f9fafb",border:l===n.id?"1px solid #3b82f6":"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s"},onMouseEnter:c=>{l!==n.id&&(c.currentTarget.style.background="#f3f4f6")},onMouseLeave:c=>{l!==n.id&&(c.currentTarget.style.background="#f9fafb")},title:n.alias,children:[s.jsx("button",{onClick:c=>{c.stopPropagation(),f(n.id)},style:{position:"absolute",top:"8px",right:"8px",padding:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#9ca3af",transition:"color 0.2s",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:c=>{c.currentTarget.style.color="#ef4444"},onMouseLeave:c=>{c.currentTarget.style.color="#9ca3af"},title:"Delete field",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s.jsxs("div",{style:{paddingRight:"24px"},children:[s.jsx("div",{style:{fontWeight:"500",fontSize:"14px",marginBottom:n.alias&&n.alias!==n.id?"4px":"0"},children:n.id}),n.alias&&n.alias!==n.id&&s.jsx("div",{style:{fontSize:"12px",color:"#4b5563"},children:n.alias})]})]},n.id))})]}),ve=o=>{const d=o.helpers?.structuredContentCommands;return d?.getStructuredContentTags?(d.getStructuredContentTags(o.state)||[]).map(l=>{const c=(l?.node??l)?.attrs??{};return{id:c.id,alias:c.alias||c.label||"",tag:c.tag}}).filter(l=>!!l.id):[]},Ee=(o,d)=>{if(o===d)return!0;if(o.length!==d.length)return!1;for(let f=0;f<o.length;f+=1){const l=o[f],n=d[f];if(!n||l.id!==n.id||l.alias!==n.alias||l.tag!==n.tag||l.position!==n.position)return!1}return!0},ze=o=>{if(!o)return null;if(o===!0)return{selector:"#superdoc-toolbar",config:{},renderDefaultContainer:!0};if(typeof o=="string")return{selector:o,config:{},renderDefaultContainer:!1};const{selector:d,...f}=o;return{selector:d||"#superdoc-toolbar",config:f,renderDefaultContainer:d===void 0}},le=10,He=250,Ue=300,Re=o=>{const d=window.innerWidth-He-le,f=window.innerHeight-Ue-le,l=Math.min(o.left,d),n=Math.min(o.top,f);return new DOMRect(Math.max(l,le),Math.max(n,le),o.width,o.height)},ke=i.forwardRef((o,d)=>{const{document:f,fields:l={},menu:n={},list:c={},toolbar:F,onReady:D,onTrigger:z,onFieldInsert:H,onFieldUpdate:P,onFieldDelete:N,onFieldsChange:C,onFieldSelect:V,onFieldCreate:L,className:U,style:O,documentHeight:Q="600px"}=o,[E,Y]=i.useState(l.initial||[]),[A,u]=i.useState(null),[b,R]=i.useState(!1),[T,j]=i.useState(),[W,ce]=i.useState(""),[Z,se]=i.useState(()=>l.available||[]),K=i.useRef(null),k=i.useRef(null),M=i.useRef(null),ee=i.useRef(l);ee.current=l;const I=i.useRef(null),te=i.useRef(b);i.useEffect(()=>{te.current=b},[b]);const q=n.trigger||"{{",e=ee.current.available||[],a=i.useCallback(t=>{const r=t.trim().toLowerCase();return r?e.filter(y=>{const v=y.label.toLowerCase(),S=y.category?.toLowerCase()||"";return v.includes(r)||S.includes(r)}):e},[e]),x=i.useCallback(t=>{ce(t),se(a(t))},[a]),p=i.useCallback(()=>{x("")},[x]),B=i.useCallback((t,r)=>{if(!k.current?.activeEditor)return!1;const y=k.current.activeEditor,v=`field_${Date.now()}`,S=t==="inline"?y.commands.insertStructuredContentInline?.({attrs:{id:v,alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):r.category},text:r.defaultValue||r.alias}):y.commands.insertStructuredContentBlock?.({attrs:{id:v,alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):r.category},text:r.defaultValue||r.alias});if(S){const _={id:v,alias:r.alias,tag:r.category};Y(g=>{const m=[...g,_];return C?.(m),m}),H?.(_)}return S},[H,C]),re=i.useCallback((t,r)=>{if(!k.current?.activeEditor)return!1;const v=k.current.activeEditor.commands.updateStructuredContentById?.(t,{attrs:r});return v&&Y(S=>{const _=S.map(m=>m.id===t?{...m,...r}:m);C?.(_);const g=_.find(m=>m.id===t);return g&&P?.(g),_}),v},[P,C]),h=i.useCallback(t=>{const r=k.current?.activeEditor;if(!r){console.warn("[SuperDocTemplateBuilder] deleteField called without active editor");let g=!1;return Y(m=>{if(!m.some($=>$.id===t))return m;const X=m.filter($=>$.id!==t);return g=!0,C?.(X),X}),g&&(N?.(t),u(m=>m===t?null:m)),g}let y=!1;try{y=r.commands.deleteStructuredContentById?.(t)??!1}catch(g){console.error("[SuperDocTemplateBuilder] Delete command failed:",g)}let v=ve(r);const S=v.some(g=>g.id===t);!y&&S&&(v=v.filter(g=>g.id!==t));let _=!1;return Y(g=>{if(Ee(g,v))return g;const m=g.some($=>$.id===t),X=v.some($=>$.id===t);return m&&!X&&(_=!0),C?.(v),v}),_&&(N?.(t),u(g=>g===t?null:g)),y||_},[N,C]),w=i.useCallback(t=>{if(!k.current?.activeEditor)return;k.current.activeEditor.commands.selectStructuredContentById?.(t),u(t);const y=E.find(v=>v.id===t);y&&V?.(y)},[E,V]),G=i.useCallback(t=>{if(!t)return;const r=ve(t);Y(y=>Ee(y,r)?y:(C?.(r),r))},[C]);i.useEffect(()=>K.current?((async()=>{const{SuperDoc:r}=await import("superdoc"),y={selector:K.current,document:f?.source,documentMode:f?.mode||"editing",onReady:()=>{if(v.activeEditor){const S=v.activeEditor;S.on("update",({editor:_})=>{const{state:g}=_,{from:m}=g.selection;if(m>=q.length){const de=m-q.length;if(g.doc.textBetween(de,m)===q){const pe=_.view.coordsAtPos(m),me=Re(new DOMRect(pe.left,pe.top,0,0)),xe=()=>{const ae=k.current?.activeEditor;if(!ae)return;const Oe=ae.state.selection.from,Pe=ae.state.tr.delete(de,Oe);ae.view.dispatch(Pe)};M.current=xe,I.current=m,j(me),R(!0),p(),z?.({position:{from:de,to:m},bounds:me,cleanup:xe});return}}if(!te.current)return;if(I.current==null){R(!1),p();return}if(m<I.current){R(!1),I.current=null,p();return}const X=g.doc.textBetween(I.current,m);x(X);const $=_.view.coordsAtPos(m),Ne=Re(new DOMRect($.left,$.top,0,0));j(Ne)}),S.on("update",()=>{G(S)}),G(S)}D?.()}},v=new r({...y,...J&&{toolbar:J.selector,modules:{toolbar:{selector:J.selector,toolbarGroups:J.config.toolbarGroups||["center"],excludeItems:J.config.excludeItems||[],...J.config}}}});k.current=v})(),()=>{M.current=null,I.current=null;const r=k.current;r&&typeof r.destroy=="function"&&r.destroy(),k.current=null}):void 0,[f?.source,f?.mode,q,G,D,z,F]);const ue=i.useCallback(async t=>{if(M.current&&(M.current(),M.current=null),I.current=null,p(),t.id.startsWith("custom_")&&L)try{const r=await L(t);if(r){B("inline",{alias:r.label,category:r.category,metadata:r.metadata,defaultValue:r.defaultValue}),R(!1);return}}catch(r){console.error("Field creation failed:",r)}B("inline",{alias:t.label,category:t.category,metadata:t.metadata,defaultValue:t.defaultValue}),R(!1)},[B,L,p]),we=i.useCallback(()=>{R(!1),I.current=null,p(),M.current&&(M.current(),M.current=null)},[p]),_e=i.useCallback(()=>{if(!k.current?.activeEditor||E.length===0)return;const t=E.findIndex(y=>y.id===A),r=t>=0?(t+1)%E.length:0;w(E[r].id)},[E,A,w]),je=i.useCallback(()=>{if(!k.current?.activeEditor||E.length===0)return;const t=E.findIndex(y=>y.id===A),r=t>0?t-1:E.length-1;w(E[r].id)},[E,A,w]),Se=i.useCallback(async t=>{try{await k.current?.export({exportType:["docx"],exportedName:t?.fileName?t?.fileName:"document"})}catch(r){throw console.error("Failed to export DOCX",r),r}},[]);i.useImperativeHandle(d,()=>({insertField:t=>B("inline",t),insertBlockField:t=>B("block",t),updateField:re,deleteField:h,selectField:w,nextField:_e,previousField:je,getFields:()=>E,exportTemplate:Se}));const Fe=n.component||Ce,fe=c.component||Te,J=ze(F);return s.jsxs("div",{className:`superdoc-template-builder ${U||""}`,style:O,children:[s.jsxs("div",{style:{display:"flex",gap:"20px"},children:[c.position==="left"&&s.jsx("div",{className:"superdoc-template-builder-sidebar",children:s.jsx(fe,{fields:E,onSelect:t=>w(t.id),onDelete:h,selectedFieldId:A||void 0})}),s.jsxs("div",{className:"superdoc-template-builder-document",style:{flex:1},children:[J?.renderDefaultContainer&&s.jsx("div",{id:"superdoc-toolbar",className:"superdoc-template-builder-toolbar","data-testid":"template-builder-toolbar"}),s.jsx("div",{ref:K,className:"superdoc-template-builder-editor",style:{height:Q},"data-testid":"template-builder-editor"})]}),c.position==="right"&&s.jsx("div",{className:"superdoc-template-builder-sidebar",children:s.jsx(fe,{fields:E,onSelect:t=>w(t.id),onDelete:h,selectedFieldId:A||void 0})})]}),s.jsx(Fe,{isVisible:b,position:T,availableFields:l.available||[],filteredFields:Z,filterQuery:W,allowCreate:l.allowCreate||!1,onSelect:ue,onClose:we,onCreateField:L})]})});ke.displayName="SuperDocTemplateBuilder";exports.FieldList=Te;exports.FieldMenu=Ce;exports.default=ke;
|
|
22
|
+
<%s key={someKey} {...props} />`,p,h,_,h),G[h+p]=!0)}if(h=null,m!==void 0&&(f(m),h=""+m),F(a)&&(f(a.key),h=""+a.key),"key"in a){m={};for(var X in a)X!=="key"&&(m[X]=a[X])}else m=a;return h&&D(m,typeof e=="function"?e.displayName||e.name||"Unknown":e),H(e,h,m,r(),B,J)}function N(e){C(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?C(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function C(e){return typeof e=="object"&&e!==null&&e.$$typeof===L}var Y=i,L=Symbol.for("react.transitional.element"),q=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),Z=Symbol.for("react.strict_mode"),v=Symbol.for("react.profiler"),$=Symbol.for("react.consumer"),A=Symbol.for("react.context"),c=Symbol.for("react.forward_ref"),b=Symbol.for("react.suspense"),E=Symbol.for("react.suspense_list"),T=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),W=Symbol.for("react.activity"),ce=Symbol.for("react.client.reference"),K=Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE,se=Object.prototype.hasOwnProperty,ee=Array.isArray,k=console.createTask?console.createTask:function(){return null};Y={react_stack_bottom_frame:function(e){return e()}};var M,te={},I=Y.react_stack_bottom_frame.bind(Y,l)(),re=k(d(l)),G={};oe.Fragment=O,oe.jsx=function(e,a,m){var p=1e4>K.recentlyCreatedOwnerStacks++;return P(e,a,m,!1,p?Error("react-stack-top-frame"):I,p?k(d(e)):re)},oe.jsxs=function(e,a,m){var p=1e4>K.recentlyCreatedOwnerStacks++;return P(e,a,m,!0,p?Error("react-stack-top-frame"):I,p?k(d(e)):re)}})()),oe}var ve;function $e(){return ve||(ve=1,process.env.NODE_ENV==="production"?ie.exports=Ve():ie.exports=Ye()),ie.exports}var s=$e();const Ce=({isVisible:o,position:u,availableFields:f,filteredFields:d,filterQuery:r,allowCreate:l,onSelect:F,onClose:D,onCreateField:z})=>{const[H,P]=i.useState(!1),[N,C]=i.useState("");i.useEffect(()=>{o||(P(!1),C(""))},[o]);const Y=i.useMemo(()=>({position:"absolute",left:u?.left,top:u?.top,zIndex:1e3,background:"white",border:"1px solid #ddd",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"8px 0",minWidth:"200px"}),[u]),L=d??f,q=!!r,O=i.useMemo(()=>{const c=[],b=new Map;return L.forEach(E=>{const T=E.category?.trim()||"Uncategorized",j=b.get(T);if(j!==void 0){c[j].fields.push(E);return}b.set(T,c.length),c.push({category:T,fields:[E]})}),c},[L]),[Z,v]=i.useState({});i.useEffect(()=>{v(c=>{if(O.length===0)return Object.keys(c).length===0?c:{};const b={};let E=Object.keys(c).length!==O.length;return O.forEach(({category:T},j)=>{const W=q?!0:c[T]??j===0;b[T]=W,!E&&c[T]!==W&&(E=!0)}),E?b:c})},[O,q]);const $=i.useCallback(c=>{v(b=>({...b,[c]:!b[c]}))},[]);if(!o)return null;const A=async()=>{const c=N.trim();if(!c)return;const b={id:`custom_${Date.now()}`,label:c,category:"Custom"};try{if(z){const E=await z(b);F(E||b)}else F(b)}finally{P(!1),C("")}};return s.jsxs("div",{className:"superdoc-field-menu",style:Y,children:[q&&s.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid #f0f0f0",marginBottom:"4px"},children:s.jsxs("div",{style:{fontSize:"12px",color:"#6b7280"},children:["Filtering results for",s.jsx("span",{style:{fontWeight:600,color:"#111827",marginLeft:"4px"},children:r})]})}),l&&!H&&s.jsx("div",{className:"field-menu-item",onClick:()=>P(!0),style:{padding:"8px 16px",cursor:"pointer",color:"#0066cc",fontWeight:500},children:"+ Create New Field"}),l&&H&&s.jsxs("div",{style:{padding:"8px 16px"},children:[s.jsx("input",{type:"text",value:N,placeholder:"Field name...",onChange:c=>C(c.target.value),onKeyDown:c=>{c.key==="Enter"&&A(),c.key==="Escape"&&(P(!1),C(""))},autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid #ddd",borderRadius:"3px"}}),s.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px"},children:[s.jsx("button",{onClick:A,disabled:!N.trim(),style:{padding:"4px 12px",background:N.trim()?"#0066cc":"#ccc",color:"white",border:"none",borderRadius:"3px",cursor:N.trim()?"pointer":"not-allowed"},children:"Create"}),s.jsx("button",{onClick:()=>{P(!1),C("")},style:{padding:"4px 12px",background:"white",border:"1px solid #ddd",borderRadius:"3px",cursor:"pointer"},children:"Cancel"})]})]}),l&&f.length>0&&s.jsx("div",{style:{borderTop:"1px solid #eee",margin:"4px 0"}}),O.length===0?s.jsx("div",{style:{padding:"16px",fontSize:"13px",color:"#6b7280",textAlign:"center"},children:"No matching fields"}):O.map(({category:c,fields:b},E)=>{const T=!!Z[c],j=`${Math.max(b.length*40,0)}px`;return s.jsxs("div",{style:{borderTop:E===0&&l?void 0:"1px solid #f0f0f0"},children:[s.jsxs("button",{type:"button",onClick:()=>$(c),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,textAlign:"left"},children:[s.jsxs("span",{children:[c," (",b.length,")"]}),s.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:T?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease",marginLeft:"12px"}})]}),s.jsx("div",{"data-category":c,"aria-hidden":!T,style:{overflow:"hidden",maxHeight:T?j:"0px",opacity:T?1:0,transition:"max-height 0.2s ease, opacity 0.2s ease",pointerEvents:T?"auto":"none"},children:s.jsx("div",{style:{padding:T?"4px 0":0},children:b.map(W=>s.jsx("div",{className:"field-menu-item",onClick:()=>F(W),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:s.jsx("span",{style:{fontWeight:500},children:W.label})},W.id))})})]},c)}),s.jsx("div",{style:{borderTop:"1px solid #eee",marginTop:"4px"},children:s.jsx("button",{onClick:D,style:{width:"100%",padding:"6px 16px",background:"#f3f4f6",border:"none",borderRadius:"0 0 4px 4px",cursor:"pointer"},children:"Close"})})]})},Te=({fields:o,onSelect:u,onDelete:f,selectedFieldId:d})=>s.jsxs("div",{className:"superdoc-field-list",style:{width:"250px",background:"white",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px"},children:[s.jsxs("h3",{style:{margin:"0 0 16px 0",fontSize:"16px",fontWeight:"600"},children:["Template Fields (",o.length,")"]}),o.length===0?s.jsxs("div",{style:{color:"#9ca3af",fontSize:"14px",textAlign:"center",padding:"20px 0"},children:["No fields yet. Type ","{{"," to add a field."]}):s.jsx("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:o.map(r=>s.jsxs("div",{onClick:()=>u(r),style:{position:"relative",padding:"12px",background:d===r.id?"#eff6ff":"#f9fafb",border:d===r.id?"1px solid #3b82f6":"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s"},onMouseEnter:l=>{d!==r.id&&(l.currentTarget.style.background="#f3f4f6")},onMouseLeave:l=>{d!==r.id&&(l.currentTarget.style.background="#f9fafb")},title:r.alias,children:[s.jsx("button",{onClick:l=>{l.stopPropagation(),f(r.id)},style:{position:"absolute",top:"8px",right:"8px",padding:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#9ca3af",transition:"color 0.2s",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:l=>{l.currentTarget.style.color="#ef4444"},onMouseLeave:l=>{l.currentTarget.style.color="#9ca3af"},title:"Delete field",children:s.jsx("svg",{width:"16",height:"16",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:s.jsx("path",{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",stroke:"currentColor",strokeWidth:"1.5",strokeLinecap:"round",strokeLinejoin:"round"})})}),s.jsxs("div",{style:{paddingRight:"24px"},children:[s.jsx("div",{style:{fontWeight:"500",fontSize:"14px",marginBottom:r.alias&&r.alias!==r.id?"4px":"0"},children:r.id}),r.alias&&r.alias!==r.id&&s.jsx("div",{style:{fontSize:"12px",color:"#4b5563"},children:r.alias})]})]},r.id))})]}),fe=o=>{const u=o.helpers?.structuredContentCommands;return u?.getStructuredContentTags?(u.getStructuredContentTags(o.state)||[]).map(d=>{const l=(d?.node??d)?.attrs??{};return{id:l.id,alias:l.alias||l.label||"",tag:l.tag}}):[]},Ee=(o,u)=>{if(o===u)return!0;if(o.length!==u.length)return!1;for(let f=0;f<o.length;f+=1){const d=o[f],r=u[f];if(!r||d.id!==r.id||d.alias!==r.alias||d.tag!==r.tag||d.position!==r.position)return!1}return!0},Ue=o=>{if(!o)return null;if(o===!0)return{selector:"#superdoc-toolbar",config:{},renderDefaultContainer:!0};if(typeof o=="string")return{selector:o,config:{},renderDefaultContainer:!1};const{selector:u,...f}=o;return{selector:u||"#superdoc-toolbar",config:f,renderDefaultContainer:u===void 0}},le=10,ze=250,He=300,Re=o=>{const u=window.innerWidth-ze-le,f=window.innerHeight-He-le,d=Math.min(o.left,u),r=Math.min(o.top,f);return new DOMRect(Math.max(d,le),Math.max(r,le),o.width,o.height)},ke=i.forwardRef((o,u)=>{const{document:f,fields:d={},menu:r={},list:l={},toolbar:F,onReady:D,onTrigger:z,onFieldInsert:H,onFieldUpdate:P,onFieldDelete:N,onFieldsChange:C,onFieldSelect:Y,onFieldCreate:L,className:q,style:O,documentHeight:Z="600px"}=o,[v,$]=i.useState(d.initial||[]),[A,c]=i.useState(null),[b,E]=i.useState(!1),[T,j]=i.useState(),[W,ce]=i.useState(""),[K,se]=i.useState(()=>d.available||[]),ee=i.useRef(null),k=i.useRef(null),M=i.useRef(null),te=i.useRef(d);te.current=d;const I=i.useRef(null),re=i.useRef(b);i.useEffect(()=>{re.current=b},[b]);const G=r.trigger||"{{",e=te.current.available||[],a=i.useCallback(t=>{const n=t.trim().toLowerCase();return n?e.filter(y=>{const R=y.label.toLowerCase(),S=y.category?.toLowerCase()||"";return R.includes(n)||S.includes(n)}):e},[e]),m=i.useCallback(t=>{ce(t),se(a(t))},[a]),p=i.useCallback(()=>{m("")},[m]),B=i.useCallback((t,n)=>{if(!k.current?.activeEditor)return!1;const y=k.current.activeEditor,R=v,S=t==="inline"?y.commands.insertStructuredContentInline?.({attrs:{alias:n.alias,tag:n.metadata?JSON.stringify(n.metadata):n.category},text:n.defaultValue||n.alias}):y.commands.insertStructuredContentBlock?.({attrs:{alias:n.alias,tag:n.metadata?JSON.stringify(n.metadata):n.category},text:n.defaultValue||n.alias});if(S){const w=fe(y);$(w),C?.(w);const x=w.find(g=>!R.some(U=>U.id===g.id));x&&H?.(x)}return S},[H,C,v]),J=i.useCallback((t,n)=>{if(!k.current?.activeEditor)return!1;const R=k.current.activeEditor.commands.updateStructuredContentById?.(t,{attrs:n});return R&&$(S=>{const w=S.map(g=>g.id===t?{...g,...n}:g);C?.(w);const x=w.find(g=>g.id===t);return x&&P?.(x),w}),R},[P,C]),h=i.useCallback(t=>{const n=k.current?.activeEditor;if(!n){console.warn("[SuperDocTemplateBuilder] deleteField called without active editor");let x=!1;return $(g=>{if(!g.some(V=>V.id===t))return g;const U=g.filter(V=>V.id!==t);return x=!0,C?.(U),U}),x&&(N?.(t),c(g=>g===t?null:g)),x}let y=!1;try{y=n.commands.deleteStructuredContentById?.(t)??!1}catch(x){console.error("[SuperDocTemplateBuilder] Delete command failed:",x)}let R=fe(n);const S=R.some(x=>x.id===t);!y&&S&&(R=R.filter(x=>x.id!==t));let w=!1;return $(x=>{if(Ee(x,R))return x;const g=x.some(V=>V.id===t),U=R.some(V=>V.id===t);return g&&!U&&(w=!0),C?.(R),R}),w&&(N?.(t),c(x=>x===t?null:x)),y||w},[N,C]),_=i.useCallback(t=>{if(!k.current?.activeEditor)return;k.current.activeEditor.commands.selectStructuredContentById?.(t),c(t);const y=v.find(R=>R.id===t);y&&Y?.(y)},[v,Y]),X=i.useCallback(t=>{if(!t)return;const n=fe(t);$(y=>Ee(y,n)?y:(C?.(n),n))},[C]);i.useEffect(()=>ee.current?((async()=>{const{SuperDoc:n}=await import("superdoc"),y={selector:ee.current,document:f?.source,documentMode:f?.mode||"editing",onReady:()=>{if(R.activeEditor){const S=R.activeEditor;S.on("update",({editor:w})=>{const{state:x}=w,{from:g}=x.selection;if(g>=G.length){const de=g-G.length;if(x.doc.textBetween(de,g)===G){const me=w.view.coordsAtPos(g),xe=Re(new DOMRect(me.left,me.top,0,0)),ge=()=>{const ae=k.current?.activeEditor;if(!ae)return;const Oe=ae.state.selection.from,Pe=ae.state.tr.delete(de,Oe);ae.view.dispatch(Pe)};M.current=ge,I.current=g,j(xe),E(!0),p(),z?.({position:{from:de,to:g},bounds:xe,cleanup:ge});return}}if(!re.current)return;if(I.current==null){E(!1),p();return}if(g<I.current){E(!1),I.current=null,p();return}const U=x.doc.textBetween(I.current,g);m(U);const V=w.view.coordsAtPos(g),Ne=Re(new DOMRect(V.left,V.top,0,0));j(Ne)}),S.on("update",()=>{X(S)}),X(S)}D?.()}},R=new n({...y,...Q&&{toolbar:Q.selector,modules:{toolbar:{selector:Q.selector,toolbarGroups:Q.config.toolbarGroups||["center"],excludeItems:Q.config.excludeItems||[],...Q.config}}}});k.current=R})(),()=>{M.current=null,I.current=null;const n=k.current;n&&typeof n.destroy=="function"&&n.destroy(),k.current=null}):void 0,[f?.source,f?.mode,G,X,D,z,F]);const ue=i.useCallback(async t=>{if(M.current&&(M.current(),M.current=null),I.current=null,p(),t.id.startsWith("custom_")&&L)try{const n=await L(t);if(n){B("inline",{alias:n.label,category:n.category,metadata:n.metadata,defaultValue:n.defaultValue}),E(!1);return}}catch(n){console.error("Field creation failed:",n)}B("inline",{alias:t.label,category:t.category,metadata:t.metadata,defaultValue:t.defaultValue}),E(!1)},[B,L,p]),we=i.useCallback(()=>{E(!1),I.current=null,p(),M.current&&(M.current(),M.current=null)},[p]),_e=i.useCallback(()=>{if(!k.current?.activeEditor||v.length===0)return;const t=v.findIndex(y=>y.id===A),n=t>=0?(t+1)%v.length:0;_(v[n].id)},[v,A,_]),je=i.useCallback(()=>{if(!k.current?.activeEditor||v.length===0)return;const t=v.findIndex(y=>y.id===A),n=t>0?t-1:v.length-1;_(v[n].id)},[v,A,_]),Se=i.useCallback(async t=>{try{await k.current?.export({exportType:["docx"],exportedName:t?.fileName?t?.fileName:"document"})}catch(n){throw console.error("Failed to export DOCX",n),n}},[]);i.useImperativeHandle(u,()=>({insertField:t=>B("inline",t),insertBlockField:t=>B("block",t),updateField:J,deleteField:h,selectField:_,nextField:_e,previousField:je,getFields:()=>v,exportTemplate:Se}));const Fe=r.component||Ce,pe=l.component||Te,Q=Ue(F);return s.jsxs("div",{className:`superdoc-template-builder ${q||""}`,style:O,children:[s.jsxs("div",{style:{display:"flex",gap:"20px"},children:[l.position==="left"&&s.jsx("div",{className:"superdoc-template-builder-sidebar",children:s.jsx(pe,{fields:v,onSelect:t=>_(t.id),onDelete:h,onUpdate:t=>J(t.id,t),selectedFieldId:A||void 0})}),s.jsxs("div",{className:"superdoc-template-builder-document",style:{flex:1},children:[Q?.renderDefaultContainer&&s.jsx("div",{id:"superdoc-toolbar",className:"superdoc-template-builder-toolbar","data-testid":"template-builder-toolbar"}),s.jsx("div",{ref:ee,className:"superdoc-template-builder-editor",style:{height:Z},"data-testid":"template-builder-editor"})]}),l.position==="right"&&s.jsx("div",{className:"superdoc-template-builder-sidebar",children:s.jsx(pe,{fields:v,onSelect:t=>_(t.id),onDelete:h,onUpdate:t=>J(t.id,t),selectedFieldId:A||void 0})})]}),s.jsx(Fe,{isVisible:b,position:T,availableFields:d.available||[],filteredFields:K,filterQuery:W,allowCreate:d.allowCreate||!1,onSelect:ue,onClose:we,onCreateField:L})]})});ke.displayName="SuperDocTemplateBuilder";exports.FieldList=Te;exports.FieldMenu=Ce;exports.default=ke;
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import Ae, { useState as
|
|
1
|
+
import Ae, { useState as U, useEffect as ue, useMemo as ve, useCallback as C, forwardRef as Me, useRef as K, useImperativeHandle as Ie } from "react";
|
|
2
2
|
var ce = { exports: {} }, se = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -9,12 +9,12 @@ var ce = { exports: {} }, se = {};
|
|
|
9
9
|
* This source code is licensed under the MIT license found in the
|
|
10
10
|
* LICENSE file in the root directory of this source tree.
|
|
11
11
|
*/
|
|
12
|
-
var
|
|
12
|
+
var Ee;
|
|
13
13
|
function De() {
|
|
14
|
-
if (
|
|
15
|
-
|
|
14
|
+
if (Ee) return se;
|
|
15
|
+
Ee = 1;
|
|
16
16
|
var a = Symbol.for("react.transitional.element"), x = Symbol.for("react.fragment");
|
|
17
|
-
function
|
|
17
|
+
function m(c, n, i) {
|
|
18
18
|
var F = null;
|
|
19
19
|
if (i !== void 0 && (F = "" + i), n.key !== void 0 && (F = "" + n.key), "key" in n) {
|
|
20
20
|
i = {};
|
|
@@ -29,7 +29,7 @@ function De() {
|
|
|
29
29
|
props: i
|
|
30
30
|
};
|
|
31
31
|
}
|
|
32
|
-
return se.Fragment = x, se.jsx =
|
|
32
|
+
return se.Fragment = x, se.jsx = m, se.jsxs = m, se;
|
|
33
33
|
}
|
|
34
34
|
var ae = {};
|
|
35
35
|
/**
|
|
@@ -41,9 +41,9 @@ var ae = {};
|
|
|
41
41
|
* This source code is licensed under the MIT license found in the
|
|
42
42
|
* LICENSE file in the root directory of this source tree.
|
|
43
43
|
*/
|
|
44
|
-
var
|
|
44
|
+
var Re;
|
|
45
45
|
function Le() {
|
|
46
|
-
return
|
|
46
|
+
return Re || (Re = 1, process.env.NODE_ENV !== "production" && (function() {
|
|
47
47
|
function a(e) {
|
|
48
48
|
if (e == null) return null;
|
|
49
49
|
if (typeof e == "function")
|
|
@@ -52,13 +52,13 @@ function Le() {
|
|
|
52
52
|
switch (e) {
|
|
53
53
|
case O:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case y:
|
|
56
56
|
return "Profiler";
|
|
57
|
-
case
|
|
57
|
+
case ee:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case g:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case v:
|
|
62
62
|
return "SuspenseList";
|
|
63
63
|
case W:
|
|
64
64
|
return "Activity";
|
|
@@ -67,11 +67,11 @@ function Le() {
|
|
|
67
67
|
switch (typeof e.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), e.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case J:
|
|
71
71
|
return "Portal";
|
|
72
72
|
case A:
|
|
73
73
|
return e.displayName || "Context";
|
|
74
|
-
case
|
|
74
|
+
case $:
|
|
75
75
|
return (e._context.displayName || "Context") + ".Consumer";
|
|
76
76
|
case l:
|
|
77
77
|
var s = e.render;
|
|
@@ -90,7 +90,7 @@ function Le() {
|
|
|
90
90
|
function x(e) {
|
|
91
91
|
return "" + e;
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function m(e) {
|
|
94
94
|
try {
|
|
95
95
|
x(e);
|
|
96
96
|
var s = !1;
|
|
@@ -99,8 +99,8 @@ function Le() {
|
|
|
99
99
|
}
|
|
100
100
|
if (s) {
|
|
101
101
|
s = console;
|
|
102
|
-
var
|
|
103
|
-
return
|
|
102
|
+
var u = s.error, d = typeof Symbol == "function" && Symbol.toStringTag && e[Symbol.toStringTag] || e.constructor.name || "Object";
|
|
103
|
+
return u.call(
|
|
104
104
|
s,
|
|
105
105
|
"The provided key is an unsupported type %s. This value must be coerced to a string before using it here.",
|
|
106
106
|
d
|
|
@@ -119,7 +119,7 @@ function Le() {
|
|
|
119
119
|
}
|
|
120
120
|
}
|
|
121
121
|
function n() {
|
|
122
|
-
var e =
|
|
122
|
+
var e = te.A;
|
|
123
123
|
return e === null ? null : e.getOwner();
|
|
124
124
|
}
|
|
125
125
|
function i() {
|
|
@@ -133,30 +133,30 @@ function Le() {
|
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
135
|
function D(e, s) {
|
|
136
|
-
function
|
|
137
|
-
|
|
136
|
+
function u() {
|
|
137
|
+
M || (M = !0, console.error(
|
|
138
138
|
"%s: `key` is not a prop. Trying to access it will result in `undefined` being returned. If you need to access the same value within the child component, you should pass it as a different prop. (https://react.dev/link/special-props)",
|
|
139
139
|
s
|
|
140
140
|
));
|
|
141
141
|
}
|
|
142
|
-
|
|
143
|
-
get:
|
|
142
|
+
u.isReactWarning = !0, Object.defineProperty(e, "key", {
|
|
143
|
+
get: u,
|
|
144
144
|
configurable: !0
|
|
145
145
|
});
|
|
146
146
|
}
|
|
147
147
|
function H() {
|
|
148
148
|
var e = a(this.type);
|
|
149
|
-
return
|
|
149
|
+
return ne[e] || (ne[e] = !0, console.error(
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
var h =
|
|
153
|
+
function G(e, s, u, d, B, X) {
|
|
154
|
+
var h = u.ref;
|
|
155
155
|
return e = {
|
|
156
156
|
$$typeof: L,
|
|
157
157
|
type: e,
|
|
158
158
|
key: s,
|
|
159
|
-
props:
|
|
159
|
+
props: u,
|
|
160
160
|
_owner: d
|
|
161
161
|
}, (h !== void 0 ? h : null) !== null ? Object.defineProperty(e, "ref", {
|
|
162
162
|
enumerable: !1,
|
|
@@ -180,14 +180,14 @@ function Le() {
|
|
|
180
180
|
configurable: !1,
|
|
181
181
|
enumerable: !1,
|
|
182
182
|
writable: !0,
|
|
183
|
-
value:
|
|
183
|
+
value: X
|
|
184
184
|
}), Object.freeze && (Object.freeze(e.props), Object.freeze(e)), e;
|
|
185
185
|
}
|
|
186
|
-
function P(e, s,
|
|
186
|
+
function P(e, s, u, d, B, X) {
|
|
187
187
|
var h = s.children;
|
|
188
188
|
if (h !== void 0)
|
|
189
189
|
if (d)
|
|
190
|
-
if (
|
|
190
|
+
if (re(h)) {
|
|
191
191
|
for (d = 0; d < h.length; d++)
|
|
192
192
|
N(h[d]);
|
|
193
193
|
Object.freeze && Object.freeze(h);
|
|
@@ -198,10 +198,10 @@ function Le() {
|
|
|
198
198
|
else N(h);
|
|
199
199
|
if (ie.call(s, "key")) {
|
|
200
200
|
h = a(e);
|
|
201
|
-
var
|
|
201
|
+
var j = Object.keys(s).filter(function(pe) {
|
|
202
202
|
return pe !== "key";
|
|
203
203
|
});
|
|
204
|
-
d = 0 <
|
|
204
|
+
d = 0 < j.length ? "{key: someKey, " + j.join(": ..., ") + ": ...}" : "{key: someKey}", q[h + d] || (j = 0 < j.length ? "{" + j.join(": ..., ") + ": ...}" : "{}", console.error(
|
|
205
205
|
`A props object containing a "key" prop is being spread into JSX:
|
|
206
206
|
let props = %s;
|
|
207
207
|
<%s {...props} />
|
|
@@ -210,25 +210,25 @@ React keys must be passed directly to JSX without using spread:
|
|
|
210
210
|
<%s key={someKey} {...props} />`,
|
|
211
211
|
d,
|
|
212
212
|
h,
|
|
213
|
-
|
|
213
|
+
j,
|
|
214
214
|
h
|
|
215
|
-
),
|
|
215
|
+
), q[h + d] = !0);
|
|
216
216
|
}
|
|
217
|
-
if (h = null,
|
|
218
|
-
|
|
219
|
-
for (var
|
|
220
|
-
|
|
221
|
-
} else
|
|
217
|
+
if (h = null, u !== void 0 && (m(u), h = "" + u), F(s) && (m(s.key), h = "" + s.key), "key" in s) {
|
|
218
|
+
u = {};
|
|
219
|
+
for (var Q in s)
|
|
220
|
+
Q !== "key" && (u[Q] = s[Q]);
|
|
221
|
+
} else u = s;
|
|
222
222
|
return h && D(
|
|
223
|
-
|
|
223
|
+
u,
|
|
224
224
|
typeof e == "function" ? e.displayName || e.name || "Unknown" : e
|
|
225
|
-
),
|
|
225
|
+
), G(
|
|
226
226
|
e,
|
|
227
227
|
h,
|
|
228
|
-
|
|
228
|
+
u,
|
|
229
229
|
n(),
|
|
230
230
|
B,
|
|
231
|
-
|
|
231
|
+
X
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
function N(e) {
|
|
@@ -237,50 +237,50 @@ React keys must be passed directly to JSX without using spread:
|
|
|
237
237
|
function R(e) {
|
|
238
238
|
return typeof e == "object" && e !== null && e.$$typeof === L;
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var Y = Ae, L = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), ee = Symbol.for("react.strict_mode"), y = Symbol.for("react.profiler"), $ = Symbol.for("react.consumer"), A = Symbol.for("react.context"), l = Symbol.for("react.forward_ref"), g = Symbol.for("react.suspense"), v = Symbol.for("react.suspense_list"), T = Symbol.for("react.memo"), k = Symbol.for("react.lazy"), W = Symbol.for("react.activity"), fe = Symbol.for("react.client.reference"), te = Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ie = Object.prototype.hasOwnProperty, re = Array.isArray, w = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
|
-
|
|
243
|
+
Y = {
|
|
244
244
|
react_stack_bottom_frame: function(e) {
|
|
245
245
|
return e();
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
-
var
|
|
249
|
-
|
|
248
|
+
var M, ne = {}, I = Y.react_stack_bottom_frame.bind(
|
|
249
|
+
Y,
|
|
250
250
|
i
|
|
251
|
-
)(),
|
|
252
|
-
ae.Fragment = O, ae.jsx = function(e, s,
|
|
253
|
-
var d = 1e4 >
|
|
251
|
+
)(), oe = w(c(i)), q = {};
|
|
252
|
+
ae.Fragment = O, ae.jsx = function(e, s, u) {
|
|
253
|
+
var d = 1e4 > te.recentlyCreatedOwnerStacks++;
|
|
254
254
|
return P(
|
|
255
255
|
e,
|
|
256
256
|
s,
|
|
257
|
-
|
|
257
|
+
u,
|
|
258
258
|
!1,
|
|
259
|
-
d ? Error("react-stack-top-frame") :
|
|
260
|
-
d ? w(c(e)) :
|
|
259
|
+
d ? Error("react-stack-top-frame") : I,
|
|
260
|
+
d ? w(c(e)) : oe
|
|
261
261
|
);
|
|
262
|
-
}, ae.jsxs = function(e, s,
|
|
263
|
-
var d = 1e4 >
|
|
262
|
+
}, ae.jsxs = function(e, s, u) {
|
|
263
|
+
var d = 1e4 > te.recentlyCreatedOwnerStacks++;
|
|
264
264
|
return P(
|
|
265
265
|
e,
|
|
266
266
|
s,
|
|
267
|
-
|
|
267
|
+
u,
|
|
268
268
|
!0,
|
|
269
|
-
d ? Error("react-stack-top-frame") :
|
|
270
|
-
d ? w(c(e)) :
|
|
269
|
+
d ? Error("react-stack-top-frame") : I,
|
|
270
|
+
d ? w(c(e)) : oe
|
|
271
271
|
);
|
|
272
272
|
};
|
|
273
273
|
})()), ae;
|
|
274
274
|
}
|
|
275
|
-
var
|
|
275
|
+
var Te;
|
|
276
276
|
function We() {
|
|
277
|
-
return
|
|
277
|
+
return Te || (Te = 1, process.env.NODE_ENV === "production" ? ce.exports = De() : ce.exports = Le()), ce.exports;
|
|
278
278
|
}
|
|
279
279
|
var o = We();
|
|
280
280
|
const Be = ({
|
|
281
281
|
isVisible: a,
|
|
282
282
|
position: x,
|
|
283
|
-
availableFields:
|
|
283
|
+
availableFields: m,
|
|
284
284
|
filteredFields: c,
|
|
285
285
|
filterQuery: n,
|
|
286
286
|
allowCreate: i,
|
|
@@ -288,11 +288,11 @@ const Be = ({
|
|
|
288
288
|
onClose: D,
|
|
289
289
|
onCreateField: H
|
|
290
290
|
}) => {
|
|
291
|
-
const [
|
|
291
|
+
const [G, P] = U(!1), [N, R] = U("");
|
|
292
292
|
ue(() => {
|
|
293
293
|
a || (P(!1), R(""));
|
|
294
294
|
}, [a]);
|
|
295
|
-
const
|
|
295
|
+
const Y = ve(() => ({
|
|
296
296
|
position: "absolute",
|
|
297
297
|
left: x?.left,
|
|
298
298
|
top: x?.top,
|
|
@@ -303,31 +303,31 @@ const Be = ({
|
|
|
303
303
|
boxShadow: "0 2px 8px rgba(0,0,0,0.1)",
|
|
304
304
|
padding: "8px 0",
|
|
305
305
|
minWidth: "200px"
|
|
306
|
-
}), [x]), L = c ??
|
|
306
|
+
}), [x]), L = c ?? m, J = !!n, O = ve(() => {
|
|
307
307
|
const l = [], g = /* @__PURE__ */ new Map();
|
|
308
|
-
return L.forEach((
|
|
309
|
-
const T =
|
|
308
|
+
return L.forEach((v) => {
|
|
309
|
+
const T = v.category?.trim() || "Uncategorized", k = g.get(T);
|
|
310
310
|
if (k !== void 0) {
|
|
311
|
-
l[k].fields.push(
|
|
311
|
+
l[k].fields.push(v);
|
|
312
312
|
return;
|
|
313
313
|
}
|
|
314
|
-
g.set(T, l.length), l.push({ category: T, fields: [
|
|
314
|
+
g.set(T, l.length), l.push({ category: T, fields: [v] });
|
|
315
315
|
}), l;
|
|
316
|
-
}, [L]), [
|
|
316
|
+
}, [L]), [ee, y] = U({});
|
|
317
317
|
ue(() => {
|
|
318
|
-
|
|
318
|
+
y((l) => {
|
|
319
319
|
if (O.length === 0)
|
|
320
320
|
return Object.keys(l).length === 0 ? l : {};
|
|
321
321
|
const g = {};
|
|
322
|
-
let
|
|
322
|
+
let v = Object.keys(l).length !== O.length;
|
|
323
323
|
return O.forEach(({ category: T }, k) => {
|
|
324
|
-
const W =
|
|
325
|
-
g[T] = W, !
|
|
326
|
-
}),
|
|
324
|
+
const W = J ? !0 : l[T] ?? k === 0;
|
|
325
|
+
g[T] = W, !v && l[T] !== W && (v = !0);
|
|
326
|
+
}), v ? g : l;
|
|
327
327
|
});
|
|
328
|
-
}, [O,
|
|
329
|
-
const
|
|
330
|
-
|
|
328
|
+
}, [O, J]);
|
|
329
|
+
const $ = C((l) => {
|
|
330
|
+
y((g) => ({
|
|
331
331
|
...g,
|
|
332
332
|
[l]: !g[l]
|
|
333
333
|
}));
|
|
@@ -343,16 +343,16 @@ const Be = ({
|
|
|
343
343
|
};
|
|
344
344
|
try {
|
|
345
345
|
if (H) {
|
|
346
|
-
const
|
|
347
|
-
F(
|
|
346
|
+
const v = await H(g);
|
|
347
|
+
F(v || g);
|
|
348
348
|
} else
|
|
349
349
|
F(g);
|
|
350
350
|
} finally {
|
|
351
351
|
P(!1), R("");
|
|
352
352
|
}
|
|
353
353
|
};
|
|
354
|
-
return /* @__PURE__ */ o.jsxs("div", { className: "superdoc-field-menu", style:
|
|
355
|
-
|
|
354
|
+
return /* @__PURE__ */ o.jsxs("div", { className: "superdoc-field-menu", style: Y, children: [
|
|
355
|
+
J && /* @__PURE__ */ o.jsx(
|
|
356
356
|
"div",
|
|
357
357
|
{
|
|
358
358
|
style: {
|
|
@@ -372,7 +372,7 @@ const Be = ({
|
|
|
372
372
|
] })
|
|
373
373
|
}
|
|
374
374
|
),
|
|
375
|
-
i && !
|
|
375
|
+
i && !G && /* @__PURE__ */ o.jsx(
|
|
376
376
|
"div",
|
|
377
377
|
{
|
|
378
378
|
className: "field-menu-item",
|
|
@@ -386,7 +386,7 @@ const Be = ({
|
|
|
386
386
|
children: "+ Create New Field"
|
|
387
387
|
}
|
|
388
388
|
),
|
|
389
|
-
i &&
|
|
389
|
+
i && G && /* @__PURE__ */ o.jsxs("div", { style: { padding: "8px 16px" }, children: [
|
|
390
390
|
/* @__PURE__ */ o.jsx(
|
|
391
391
|
"input",
|
|
392
392
|
{
|
|
@@ -451,7 +451,7 @@ const Be = ({
|
|
|
451
451
|
}
|
|
452
452
|
)
|
|
453
453
|
] }),
|
|
454
|
-
i &&
|
|
454
|
+
i && m.length > 0 && /* @__PURE__ */ o.jsx(
|
|
455
455
|
"div",
|
|
456
456
|
{
|
|
457
457
|
style: {
|
|
@@ -471,20 +471,20 @@ const Be = ({
|
|
|
471
471
|
},
|
|
472
472
|
children: "No matching fields"
|
|
473
473
|
}
|
|
474
|
-
) : O.map(({ category: l, fields: g },
|
|
475
|
-
const T = !!
|
|
474
|
+
) : O.map(({ category: l, fields: g }, v) => {
|
|
475
|
+
const T = !!ee[l], k = `${Math.max(g.length * 40, 0)}px`;
|
|
476
476
|
return /* @__PURE__ */ o.jsxs(
|
|
477
477
|
"div",
|
|
478
478
|
{
|
|
479
479
|
style: {
|
|
480
|
-
borderTop:
|
|
480
|
+
borderTop: v === 0 && i ? void 0 : "1px solid #f0f0f0"
|
|
481
481
|
},
|
|
482
482
|
children: [
|
|
483
483
|
/* @__PURE__ */ o.jsxs(
|
|
484
484
|
"button",
|
|
485
485
|
{
|
|
486
486
|
type: "button",
|
|
487
|
-
onClick: () =>
|
|
487
|
+
onClick: () => $(l),
|
|
488
488
|
style: {
|
|
489
489
|
width: "100%",
|
|
490
490
|
display: "flex",
|
|
@@ -583,10 +583,10 @@ const Be = ({
|
|
|
583
583
|
}
|
|
584
584
|
)
|
|
585
585
|
] });
|
|
586
|
-
},
|
|
586
|
+
}, Ve = ({
|
|
587
587
|
fields: a,
|
|
588
588
|
onSelect: x,
|
|
589
|
-
onDelete:
|
|
589
|
+
onDelete: m,
|
|
590
590
|
selectedFieldId: c
|
|
591
591
|
}) => /* @__PURE__ */ o.jsxs(
|
|
592
592
|
"div",
|
|
@@ -645,7 +645,7 @@ const Be = ({
|
|
|
645
645
|
"button",
|
|
646
646
|
{
|
|
647
647
|
onClick: (i) => {
|
|
648
|
-
i.stopPropagation(),
|
|
648
|
+
i.stopPropagation(), m(n.id);
|
|
649
649
|
},
|
|
650
650
|
style: {
|
|
651
651
|
position: "absolute",
|
|
@@ -719,7 +719,7 @@ const Be = ({
|
|
|
719
719
|
)) })
|
|
720
720
|
]
|
|
721
721
|
}
|
|
722
|
-
),
|
|
722
|
+
), xe = (a) => {
|
|
723
723
|
const x = a.helpers?.structuredContentCommands;
|
|
724
724
|
return x?.getStructuredContentTags ? (x.getStructuredContentTags(a.state) || []).map((c) => {
|
|
725
725
|
const i = (c?.node ?? c)?.attrs ?? {};
|
|
@@ -728,17 +728,17 @@ const Be = ({
|
|
|
728
728
|
alias: i.alias || i.label || "",
|
|
729
729
|
tag: i.tag
|
|
730
730
|
};
|
|
731
|
-
})
|
|
731
|
+
}) : [];
|
|
732
732
|
}, we = (a, x) => {
|
|
733
733
|
if (a === x) return !0;
|
|
734
734
|
if (a.length !== x.length) return !1;
|
|
735
|
-
for (let
|
|
736
|
-
const c = a[
|
|
735
|
+
for (let m = 0; m < a.length; m += 1) {
|
|
736
|
+
const c = a[m], n = x[m];
|
|
737
737
|
if (!n || c.id !== n.id || c.alias !== n.alias || c.tag !== n.tag || c.position !== n.position)
|
|
738
738
|
return !1;
|
|
739
739
|
}
|
|
740
740
|
return !0;
|
|
741
|
-
},
|
|
741
|
+
}, Ye = (a) => {
|
|
742
742
|
if (!a) return null;
|
|
743
743
|
if (a === !0)
|
|
744
744
|
return {
|
|
@@ -752,108 +752,103 @@ const Be = ({
|
|
|
752
752
|
config: {},
|
|
753
753
|
renderDefaultContainer: !1
|
|
754
754
|
};
|
|
755
|
-
const { selector: x, ...
|
|
755
|
+
const { selector: x, ...m } = a;
|
|
756
756
|
return {
|
|
757
757
|
selector: x || "#superdoc-toolbar",
|
|
758
|
-
config:
|
|
758
|
+
config: m,
|
|
759
759
|
renderDefaultContainer: x === void 0
|
|
760
760
|
};
|
|
761
|
-
}, de = 10,
|
|
762
|
-
const x = window.innerWidth -
|
|
761
|
+
}, de = 10, $e = 250, Ue = 300, _e = (a) => {
|
|
762
|
+
const x = window.innerWidth - $e - de, m = window.innerHeight - Ue - de, c = Math.min(a.left, x), n = Math.min(a.top, m);
|
|
763
763
|
return new DOMRect(
|
|
764
764
|
Math.max(c, de),
|
|
765
765
|
Math.max(n, de),
|
|
766
766
|
a.width,
|
|
767
767
|
a.height
|
|
768
768
|
);
|
|
769
|
-
},
|
|
769
|
+
}, ze = Me((a, x) => {
|
|
770
770
|
const {
|
|
771
|
-
document:
|
|
771
|
+
document: m,
|
|
772
772
|
fields: c = {},
|
|
773
773
|
menu: n = {},
|
|
774
774
|
list: i = {},
|
|
775
775
|
toolbar: F,
|
|
776
776
|
onReady: D,
|
|
777
777
|
onTrigger: H,
|
|
778
|
-
onFieldInsert:
|
|
778
|
+
onFieldInsert: G,
|
|
779
779
|
onFieldUpdate: P,
|
|
780
780
|
onFieldDelete: N,
|
|
781
781
|
onFieldsChange: R,
|
|
782
|
-
onFieldSelect:
|
|
782
|
+
onFieldSelect: Y,
|
|
783
783
|
onFieldCreate: L,
|
|
784
|
-
className:
|
|
784
|
+
className: J,
|
|
785
785
|
style: O,
|
|
786
|
-
documentHeight:
|
|
787
|
-
} = a, [
|
|
786
|
+
documentHeight: ee = "600px"
|
|
787
|
+
} = a, [y, $] = U(
|
|
788
788
|
c.initial || []
|
|
789
|
-
), [A, l] =
|
|
790
|
-
|
|
791
|
-
const
|
|
789
|
+
), [A, l] = U(null), [g, v] = U(!1), [T, k] = U(), [W, fe] = U(""), [te, ie] = U(() => c.available || []), re = K(null), w = K(null), M = K(null), ne = K(c);
|
|
790
|
+
ne.current = c;
|
|
791
|
+
const I = K(null), oe = K(g);
|
|
792
792
|
ue(() => {
|
|
793
|
-
|
|
793
|
+
oe.current = g;
|
|
794
794
|
}, [g]);
|
|
795
|
-
const
|
|
795
|
+
const q = n.trigger || "{{", e = ne.current.available || [], s = C(
|
|
796
796
|
(t) => {
|
|
797
797
|
const r = t.trim().toLowerCase();
|
|
798
798
|
return r ? e.filter((b) => {
|
|
799
|
-
const
|
|
800
|
-
return
|
|
799
|
+
const E = b.label.toLowerCase(), S = b.category?.toLowerCase() || "";
|
|
800
|
+
return E.includes(r) || S.includes(r);
|
|
801
801
|
}) : e;
|
|
802
802
|
},
|
|
803
803
|
[e]
|
|
804
|
-
),
|
|
804
|
+
), u = C(
|
|
805
805
|
(t) => {
|
|
806
806
|
fe(t), ie(s(t));
|
|
807
807
|
},
|
|
808
808
|
[s]
|
|
809
809
|
), d = C(() => {
|
|
810
|
-
|
|
811
|
-
}, [
|
|
810
|
+
u("");
|
|
811
|
+
}, [u]), B = C(
|
|
812
812
|
(t, r) => {
|
|
813
813
|
if (!w.current?.activeEditor) return !1;
|
|
814
|
-
const b = w.current.activeEditor,
|
|
814
|
+
const b = w.current.activeEditor, E = y, S = t === "inline" ? b.commands.insertStructuredContentInline?.({
|
|
815
815
|
attrs: {
|
|
816
|
-
id: y,
|
|
817
816
|
alias: r.alias,
|
|
818
817
|
tag: r.metadata ? JSON.stringify(r.metadata) : r.category
|
|
819
818
|
},
|
|
820
819
|
text: r.defaultValue || r.alias
|
|
821
820
|
}) : b.commands.insertStructuredContentBlock?.({
|
|
822
821
|
attrs: {
|
|
823
|
-
id: y,
|
|
824
822
|
alias: r.alias,
|
|
825
823
|
tag: r.metadata ? JSON.stringify(r.metadata) : r.category
|
|
826
824
|
},
|
|
827
825
|
text: r.defaultValue || r.alias
|
|
828
826
|
});
|
|
829
827
|
if (S) {
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
const u = [...m, j];
|
|
837
|
-
return R?.(u), u;
|
|
838
|
-
}), U?.(j);
|
|
828
|
+
const _ = xe(b);
|
|
829
|
+
$(_), R?.(_);
|
|
830
|
+
const f = _.find(
|
|
831
|
+
(p) => !E.some((z) => z.id === p.id)
|
|
832
|
+
);
|
|
833
|
+
f && G?.(f);
|
|
839
834
|
}
|
|
840
835
|
return S;
|
|
841
836
|
},
|
|
842
|
-
[
|
|
843
|
-
),
|
|
837
|
+
[G, R, y]
|
|
838
|
+
), X = C(
|
|
844
839
|
(t, r) => {
|
|
845
840
|
if (!w.current?.activeEditor) return !1;
|
|
846
|
-
const
|
|
841
|
+
const E = w.current.activeEditor.commands.updateStructuredContentById?.(t, {
|
|
847
842
|
attrs: r
|
|
848
843
|
});
|
|
849
|
-
return
|
|
850
|
-
const
|
|
851
|
-
(
|
|
844
|
+
return E && $((S) => {
|
|
845
|
+
const _ = S.map(
|
|
846
|
+
(p) => p.id === t ? { ...p, ...r } : p
|
|
852
847
|
);
|
|
853
|
-
R?.(
|
|
854
|
-
const
|
|
855
|
-
return
|
|
856
|
-
}),
|
|
848
|
+
R?.(_);
|
|
849
|
+
const f = _.find((p) => p.id === t);
|
|
850
|
+
return f && P?.(f), _;
|
|
851
|
+
}), E;
|
|
857
852
|
},
|
|
858
853
|
[P, R]
|
|
859
854
|
), h = C(
|
|
@@ -863,135 +858,135 @@ const Be = ({
|
|
|
863
858
|
console.warn(
|
|
864
859
|
"[SuperDocTemplateBuilder] deleteField called without active editor"
|
|
865
860
|
);
|
|
866
|
-
let
|
|
867
|
-
return
|
|
868
|
-
if (!
|
|
869
|
-
const
|
|
870
|
-
return
|
|
871
|
-
}),
|
|
861
|
+
let f = !1;
|
|
862
|
+
return $((p) => {
|
|
863
|
+
if (!p.some((V) => V.id === t)) return p;
|
|
864
|
+
const z = p.filter((V) => V.id !== t);
|
|
865
|
+
return f = !0, R?.(z), z;
|
|
866
|
+
}), f && (N?.(t), l((p) => p === t ? null : p)), f;
|
|
872
867
|
}
|
|
873
868
|
let b = !1;
|
|
874
869
|
try {
|
|
875
870
|
b = r.commands.deleteStructuredContentById?.(t) ?? !1;
|
|
876
|
-
} catch (
|
|
871
|
+
} catch (f) {
|
|
877
872
|
console.error(
|
|
878
873
|
"[SuperDocTemplateBuilder] Delete command failed:",
|
|
879
|
-
|
|
874
|
+
f
|
|
880
875
|
);
|
|
881
876
|
}
|
|
882
|
-
let
|
|
883
|
-
const S =
|
|
884
|
-
!b && S && (
|
|
885
|
-
let
|
|
886
|
-
return
|
|
887
|
-
if (we(
|
|
888
|
-
return
|
|
889
|
-
const
|
|
890
|
-
return
|
|
891
|
-
}),
|
|
877
|
+
let E = xe(r);
|
|
878
|
+
const S = E.some((f) => f.id === t);
|
|
879
|
+
!b && S && (E = E.filter((f) => f.id !== t));
|
|
880
|
+
let _ = !1;
|
|
881
|
+
return $((f) => {
|
|
882
|
+
if (we(f, E))
|
|
883
|
+
return f;
|
|
884
|
+
const p = f.some((V) => V.id === t), z = E.some((V) => V.id === t);
|
|
885
|
+
return p && !z && (_ = !0), R?.(E), E;
|
|
886
|
+
}), _ && (N?.(t), l((f) => f === t ? null : f)), b || _;
|
|
892
887
|
},
|
|
893
888
|
[N, R]
|
|
894
|
-
),
|
|
889
|
+
), j = C(
|
|
895
890
|
(t) => {
|
|
896
891
|
if (!w.current?.activeEditor) return;
|
|
897
892
|
w.current.activeEditor.commands.selectStructuredContentById?.(t), l(t);
|
|
898
|
-
const b =
|
|
899
|
-
b &&
|
|
893
|
+
const b = y.find((E) => E.id === t);
|
|
894
|
+
b && Y?.(b);
|
|
900
895
|
},
|
|
901
|
-
[
|
|
902
|
-
),
|
|
896
|
+
[y, Y]
|
|
897
|
+
), Q = C(
|
|
903
898
|
(t) => {
|
|
904
899
|
if (!t) return;
|
|
905
|
-
const r =
|
|
906
|
-
|
|
900
|
+
const r = xe(t);
|
|
901
|
+
$((b) => we(b, r) ? b : (R?.(r), r));
|
|
907
902
|
},
|
|
908
903
|
[R]
|
|
909
904
|
);
|
|
910
|
-
ue(() =>
|
|
905
|
+
ue(() => re.current ? ((async () => {
|
|
911
906
|
const { SuperDoc: r } = await import("superdoc"), b = {
|
|
912
|
-
selector:
|
|
913
|
-
document:
|
|
914
|
-
documentMode:
|
|
907
|
+
selector: re.current,
|
|
908
|
+
document: m?.source,
|
|
909
|
+
documentMode: m?.mode || "editing",
|
|
915
910
|
onReady: () => {
|
|
916
|
-
if (
|
|
917
|
-
const S =
|
|
918
|
-
S.on("update", ({ editor:
|
|
919
|
-
const { state:
|
|
920
|
-
if (
|
|
921
|
-
const me =
|
|
922
|
-
if (
|
|
923
|
-
const
|
|
924
|
-
new DOMRect(
|
|
925
|
-
),
|
|
911
|
+
if (E.activeEditor) {
|
|
912
|
+
const S = E.activeEditor;
|
|
913
|
+
S.on("update", ({ editor: _ }) => {
|
|
914
|
+
const { state: f } = _, { from: p } = f.selection;
|
|
915
|
+
if (p >= q.length) {
|
|
916
|
+
const me = p - q.length;
|
|
917
|
+
if (f.doc.textBetween(me, p) === q) {
|
|
918
|
+
const he = _.view.coordsAtPos(p), be = _e(
|
|
919
|
+
new DOMRect(he.left, he.top, 0, 0)
|
|
920
|
+
), ye = () => {
|
|
926
921
|
const le = w.current?.activeEditor;
|
|
927
922
|
if (!le) return;
|
|
928
923
|
const Oe = le.state.selection.from, Pe = le.state.tr.delete(me, Oe);
|
|
929
924
|
le.view.dispatch(Pe);
|
|
930
925
|
};
|
|
931
|
-
|
|
932
|
-
position: { from: me, to:
|
|
933
|
-
bounds:
|
|
934
|
-
cleanup:
|
|
926
|
+
M.current = ye, I.current = p, k(be), v(!0), d(), H?.({
|
|
927
|
+
position: { from: me, to: p },
|
|
928
|
+
bounds: be,
|
|
929
|
+
cleanup: ye
|
|
935
930
|
});
|
|
936
931
|
return;
|
|
937
932
|
}
|
|
938
933
|
}
|
|
939
|
-
if (!
|
|
934
|
+
if (!oe.current)
|
|
940
935
|
return;
|
|
941
|
-
if (
|
|
942
|
-
|
|
936
|
+
if (I.current == null) {
|
|
937
|
+
v(!1), d();
|
|
943
938
|
return;
|
|
944
939
|
}
|
|
945
|
-
if (
|
|
946
|
-
|
|
940
|
+
if (p < I.current) {
|
|
941
|
+
v(!1), I.current = null, d();
|
|
947
942
|
return;
|
|
948
943
|
}
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
944
|
+
const z = f.doc.textBetween(
|
|
945
|
+
I.current,
|
|
946
|
+
p
|
|
952
947
|
);
|
|
953
|
-
|
|
954
|
-
const
|
|
955
|
-
new DOMRect(
|
|
948
|
+
u(z);
|
|
949
|
+
const V = _.view.coordsAtPos(p), Ne = _e(
|
|
950
|
+
new DOMRect(V.left, V.top, 0, 0)
|
|
956
951
|
);
|
|
957
952
|
k(Ne);
|
|
958
953
|
}), S.on("update", () => {
|
|
959
|
-
|
|
960
|
-
}),
|
|
954
|
+
Q(S);
|
|
955
|
+
}), Q(S);
|
|
961
956
|
}
|
|
962
957
|
D?.();
|
|
963
958
|
}
|
|
964
|
-
},
|
|
959
|
+
}, E = new r({
|
|
965
960
|
...b,
|
|
966
|
-
...
|
|
967
|
-
toolbar:
|
|
961
|
+
...Z && {
|
|
962
|
+
toolbar: Z.selector,
|
|
968
963
|
modules: {
|
|
969
964
|
toolbar: {
|
|
970
|
-
selector:
|
|
971
|
-
toolbarGroups:
|
|
972
|
-
excludeItems:
|
|
973
|
-
...
|
|
965
|
+
selector: Z.selector,
|
|
966
|
+
toolbarGroups: Z.config.toolbarGroups || ["center"],
|
|
967
|
+
excludeItems: Z.config.excludeItems || [],
|
|
968
|
+
...Z.config
|
|
974
969
|
}
|
|
975
970
|
}
|
|
976
971
|
}
|
|
977
972
|
});
|
|
978
|
-
w.current =
|
|
973
|
+
w.current = E;
|
|
979
974
|
})(), () => {
|
|
980
|
-
|
|
975
|
+
M.current = null, I.current = null;
|
|
981
976
|
const r = w.current;
|
|
982
977
|
r && typeof r.destroy == "function" && r.destroy(), w.current = null;
|
|
983
978
|
}) : void 0, [
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
J,
|
|
979
|
+
m?.source,
|
|
980
|
+
m?.mode,
|
|
987
981
|
q,
|
|
982
|
+
Q,
|
|
988
983
|
D,
|
|
989
984
|
H,
|
|
990
985
|
F
|
|
991
986
|
]);
|
|
992
987
|
const pe = C(
|
|
993
988
|
async (t) => {
|
|
994
|
-
if (
|
|
989
|
+
if (M.current && (M.current(), M.current = null), I.current = null, d(), t.id.startsWith("custom_") && L)
|
|
995
990
|
try {
|
|
996
991
|
const r = await L(t);
|
|
997
992
|
if (r) {
|
|
@@ -1000,7 +995,7 @@ const Be = ({
|
|
|
1000
995
|
category: r.category,
|
|
1001
996
|
metadata: r.metadata,
|
|
1002
997
|
defaultValue: r.defaultValue
|
|
1003
|
-
}),
|
|
998
|
+
}), v(!1);
|
|
1004
999
|
return;
|
|
1005
1000
|
}
|
|
1006
1001
|
} catch (r) {
|
|
@@ -1011,26 +1006,26 @@ const Be = ({
|
|
|
1011
1006
|
category: t.category,
|
|
1012
1007
|
metadata: t.metadata,
|
|
1013
1008
|
defaultValue: t.defaultValue
|
|
1014
|
-
}),
|
|
1009
|
+
}), v(!1);
|
|
1015
1010
|
},
|
|
1016
1011
|
[B, L, d]
|
|
1017
1012
|
), je = C(() => {
|
|
1018
|
-
|
|
1013
|
+
v(!1), I.current = null, d(), M.current && (M.current(), M.current = null);
|
|
1019
1014
|
}, [d]), Ce = C(() => {
|
|
1020
|
-
if (!w.current?.activeEditor ||
|
|
1015
|
+
if (!w.current?.activeEditor || y.length === 0)
|
|
1021
1016
|
return;
|
|
1022
|
-
const t =
|
|
1017
|
+
const t = y.findIndex(
|
|
1023
1018
|
(b) => b.id === A
|
|
1024
|
-
), r = t >= 0 ? (t + 1) %
|
|
1025
|
-
|
|
1026
|
-
}, [
|
|
1027
|
-
if (!w.current?.activeEditor ||
|
|
1019
|
+
), r = t >= 0 ? (t + 1) % y.length : 0;
|
|
1020
|
+
j(y[r].id);
|
|
1021
|
+
}, [y, A, j]), ke = C(() => {
|
|
1022
|
+
if (!w.current?.activeEditor || y.length === 0)
|
|
1028
1023
|
return;
|
|
1029
|
-
const t =
|
|
1024
|
+
const t = y.findIndex(
|
|
1030
1025
|
(b) => b.id === A
|
|
1031
|
-
), r = t > 0 ? t - 1 :
|
|
1032
|
-
|
|
1033
|
-
}, [
|
|
1026
|
+
), r = t > 0 ? t - 1 : y.length - 1;
|
|
1027
|
+
j(y[r].id);
|
|
1028
|
+
}, [y, A, j]), Se = C(
|
|
1034
1029
|
async (t) => {
|
|
1035
1030
|
try {
|
|
1036
1031
|
await w.current?.export({
|
|
@@ -1043,36 +1038,37 @@ const Be = ({
|
|
|
1043
1038
|
},
|
|
1044
1039
|
[]
|
|
1045
1040
|
);
|
|
1046
|
-
|
|
1041
|
+
Ie(x, () => ({
|
|
1047
1042
|
insertField: (t) => B("inline", t),
|
|
1048
1043
|
insertBlockField: (t) => B("block", t),
|
|
1049
|
-
updateField:
|
|
1044
|
+
updateField: X,
|
|
1050
1045
|
deleteField: h,
|
|
1051
|
-
selectField:
|
|
1046
|
+
selectField: j,
|
|
1052
1047
|
nextField: Ce,
|
|
1053
1048
|
previousField: ke,
|
|
1054
|
-
getFields: () =>
|
|
1049
|
+
getFields: () => y,
|
|
1055
1050
|
exportTemplate: Se
|
|
1056
1051
|
}));
|
|
1057
|
-
const Fe = n.component || Be,
|
|
1052
|
+
const Fe = n.component || Be, ge = i.component || Ve, Z = Ye(F);
|
|
1058
1053
|
return /* @__PURE__ */ o.jsxs(
|
|
1059
1054
|
"div",
|
|
1060
1055
|
{
|
|
1061
|
-
className: `superdoc-template-builder ${
|
|
1056
|
+
className: `superdoc-template-builder ${J || ""}`,
|
|
1062
1057
|
style: O,
|
|
1063
1058
|
children: [
|
|
1064
1059
|
/* @__PURE__ */ o.jsxs("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1065
1060
|
i.position === "left" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1066
|
-
|
|
1061
|
+
ge,
|
|
1067
1062
|
{
|
|
1068
|
-
fields:
|
|
1069
|
-
onSelect: (t) =>
|
|
1063
|
+
fields: y,
|
|
1064
|
+
onSelect: (t) => j(t.id),
|
|
1070
1065
|
onDelete: h,
|
|
1066
|
+
onUpdate: (t) => X(t.id, t),
|
|
1071
1067
|
selectedFieldId: A || void 0
|
|
1072
1068
|
}
|
|
1073
1069
|
) }),
|
|
1074
1070
|
/* @__PURE__ */ o.jsxs("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1075
|
-
|
|
1071
|
+
Z?.renderDefaultContainer && /* @__PURE__ */ o.jsx(
|
|
1076
1072
|
"div",
|
|
1077
1073
|
{
|
|
1078
1074
|
id: "superdoc-toolbar",
|
|
@@ -1083,19 +1079,20 @@ const Be = ({
|
|
|
1083
1079
|
/* @__PURE__ */ o.jsx(
|
|
1084
1080
|
"div",
|
|
1085
1081
|
{
|
|
1086
|
-
ref:
|
|
1082
|
+
ref: re,
|
|
1087
1083
|
className: "superdoc-template-builder-editor",
|
|
1088
|
-
style: { height:
|
|
1084
|
+
style: { height: ee },
|
|
1089
1085
|
"data-testid": "template-builder-editor"
|
|
1090
1086
|
}
|
|
1091
1087
|
)
|
|
1092
1088
|
] }),
|
|
1093
1089
|
i.position === "right" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1094
|
-
|
|
1090
|
+
ge,
|
|
1095
1091
|
{
|
|
1096
|
-
fields:
|
|
1097
|
-
onSelect: (t) =>
|
|
1092
|
+
fields: y,
|
|
1093
|
+
onSelect: (t) => j(t.id),
|
|
1098
1094
|
onDelete: h,
|
|
1095
|
+
onUpdate: (t) => X(t.id, t),
|
|
1099
1096
|
selectedFieldId: A || void 0
|
|
1100
1097
|
}
|
|
1101
1098
|
) })
|
|
@@ -1106,7 +1103,7 @@ const Be = ({
|
|
|
1106
1103
|
isVisible: g,
|
|
1107
1104
|
position: T,
|
|
1108
1105
|
availableFields: c.available || [],
|
|
1109
|
-
filteredFields:
|
|
1106
|
+
filteredFields: te,
|
|
1110
1107
|
filterQuery: W,
|
|
1111
1108
|
allowCreate: c.allowCreate || !1,
|
|
1112
1109
|
onSelect: pe,
|
|
@@ -1118,9 +1115,9 @@ const Be = ({
|
|
|
1118
1115
|
}
|
|
1119
1116
|
);
|
|
1120
1117
|
});
|
|
1121
|
-
|
|
1118
|
+
ze.displayName = "SuperDocTemplateBuilder";
|
|
1122
1119
|
export {
|
|
1123
|
-
|
|
1120
|
+
Ve as FieldList,
|
|
1124
1121
|
Be as FieldMenu,
|
|
1125
|
-
|
|
1122
|
+
ze as default
|
|
1126
1123
|
};
|
package/dist/types.d.ts
CHANGED
|
@@ -6,7 +6,7 @@ export interface FieldDefinition {
|
|
|
6
6
|
metadata?: Record<string, any>;
|
|
7
7
|
}
|
|
8
8
|
export interface TemplateField {
|
|
9
|
-
id: string;
|
|
9
|
+
id: string | number;
|
|
10
10
|
alias: string;
|
|
11
11
|
tag?: string;
|
|
12
12
|
position?: number;
|
|
@@ -33,8 +33,9 @@ export interface FieldMenuProps {
|
|
|
33
33
|
export interface FieldListProps {
|
|
34
34
|
fields: TemplateField[];
|
|
35
35
|
onSelect: (field: TemplateField) => void;
|
|
36
|
-
onDelete: (fieldId: string) => void;
|
|
37
|
-
|
|
36
|
+
onDelete: (fieldId: string | number) => void;
|
|
37
|
+
onUpdate?: (field: TemplateField) => void;
|
|
38
|
+
selectedFieldId?: string | number;
|
|
38
39
|
}
|
|
39
40
|
export interface DocumentConfig {
|
|
40
41
|
source?: string | File | Blob;
|
|
@@ -74,7 +75,7 @@ export interface SuperDocTemplateBuilderProps {
|
|
|
74
75
|
onTrigger?: (event: TriggerEvent) => void;
|
|
75
76
|
onFieldInsert?: (field: TemplateField) => void;
|
|
76
77
|
onFieldUpdate?: (field: TemplateField) => void;
|
|
77
|
-
onFieldDelete?: (fieldId: string) => void;
|
|
78
|
+
onFieldDelete?: (fieldId: string | number) => void;
|
|
78
79
|
onFieldsChange?: (fields: TemplateField[]) => void;
|
|
79
80
|
onFieldSelect?: (field: TemplateField | null) => void;
|
|
80
81
|
onFieldCreate?: (field: FieldDefinition) => void | Promise<FieldDefinition | void>;
|
|
@@ -89,9 +90,9 @@ export interface SuperDocTemplateBuilderHandle {
|
|
|
89
90
|
insertBlockField: (field: Partial<FieldDefinition> & {
|
|
90
91
|
alias: string;
|
|
91
92
|
}) => boolean;
|
|
92
|
-
updateField: (id: string, updates: Partial<TemplateField>) => boolean;
|
|
93
|
-
deleteField: (id: string) => boolean;
|
|
94
|
-
selectField: (id: string) => void;
|
|
93
|
+
updateField: (id: string | number, updates: Partial<TemplateField>) => boolean;
|
|
94
|
+
deleteField: (id: string | number) => boolean;
|
|
95
|
+
selectField: (id: string | number) => void;
|
|
95
96
|
nextField: () => void;
|
|
96
97
|
previousField: () => void;
|
|
97
98
|
getFields: () => TemplateField[];
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,eAAe;IAC9B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC;AAED,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|