@superdoc-dev/template-builder 0.2.0-next.1 → 0.2.0-next.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -4
- package/dist/index.mjs +269 -270
- package/dist/types.d.ts +7 -7
- package/dist/types.d.ts.map +1 -1
- package/package.json +1 -1
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;AAwGhC,QAAA,MAAM,uBAAuB,oJA2jB3B,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 Q: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=Z.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 H(){var e=o(this.type);return ee[e]||(ee[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 U(e,a,m,p,B,re){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:H}):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:re}),Object.freeze&&(Object.freeze(e.props),Object.freeze(e)),e}function P(e,a,m,p,B,re){var h=a.children;if(h!==void 0)if(p)if(K(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&&M(x,typeof e=="function"?e.displayName||e.name||"Unknown":e),H(e,h,x,r(),B,re)}function N(e){T(e)?e._store&&(e._store.validated=1):typeof e=="object"&&e!==null&&e.$$typeof===j&&(e._payload.status==="fulfilled"?T(e._payload.value)&&e._payload.value._store&&(e._payload.value._store.validated=1):e._store&&(e._store.validated=1))}function T(e){return typeof e=="object"&&e!==null&&e.$$typeof===I}var V=i,I=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"),k=Symbol.for("react.memo"),j=Symbol.for("react.lazy"),D=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,C=console.createTask?console.createTask:function(){return null};V={react_stack_bottom_frame:function(e){return e()}};var L,ee={},W=V.react_stack_bottom_frame.bind(V,c)(),te=C(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"):W,p?C(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"):W,p?C(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:n,position:d,availableFields:f,filteredFields:l,filterQuery:r,allowCreate:c,onSelect:F,onClose:M,onCreateField:z})=>{const[H,P]=i.useState(!1),[N,T]=i.useState("");i.useEffect(()=>{n||(P(!1),T(""))},[n]);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]),I=l??f,U=!!r,O=i.useMemo(()=>{const u=[],b=new Map;return I.forEach(R=>{const k=R.category?.trim()||"Uncategorized",j=b.get(k);if(j!==void 0){u[j].fields.push(R);return}b.set(k,u.length),u.push({category:k,fields:[R]})}),u},[I]),[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:k},j)=>{const D=U?!0:u[k]??j===0;b[k]=D,!R&&u[k]!==D&&(R=!0)}),R?b:u})},[O,U]);const Y=i.useCallback(u=>{E(b=>({...b,[u]:!b[u]}))},[]);if(!n)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),T("")}};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:r})]})}),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=>T(u.target.value),onKeyDown:u=>{u.key==="Enter"&&A(),u.key==="Escape"&&(P(!1),T(""))},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),T("")},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 k=!!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:k?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease",marginLeft:"12px"}})]}),s.jsx("div",{"data-category":u,"aria-hidden":!k,style:{overflow:"hidden",maxHeight:k?j:"0px",opacity:k?1:0,transition:"max-height 0.2s ease, opacity 0.2s ease",pointerEvents:k?"auto":"none"},children:s.jsx("div",{style:{padding:k?"4px 0":0},children:b.map(D=>s.jsx("div",{className:"field-menu-item",onClick:()=>F(D),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"center",justifyContent:"space-between"},children:s.jsx("span",{style:{fontWeight:500},children:D.label})},D.id))})})]},u)}),s.jsx("div",{style:{borderTop:"1px solid #eee",marginTop:"4px"},children:s.jsx("button",{onClick:M,style:{width:"100%",padding:"6px 16px",background:"#f3f4f6",border:"none",borderRadius:"0 0 4px 4px",cursor:"pointer"},children:"Close"})})]})},Te=({fields:n,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 (",n.length,")"]}),n.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:n.map(r=>s.jsxs("div",{onClick:()=>d(r),style:{position:"relative",padding:"12px",background:l===r.id?"#eff6ff":"#f9fafb",border:l===r.id?"1px solid #3b82f6":"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s"},onMouseEnter:c=>{l!==r.id&&(c.currentTarget.style.background="#f3f4f6")},onMouseLeave:c=>{l!==r.id&&(c.currentTarget.style.background="#f9fafb")},title:r.alias,children:[s.jsx("button",{onClick:c=>{c.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: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: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))})]}),ve=n=>{const d=n.helpers?.structuredContentCommands;return d?.getStructuredContentTags?(d.getStructuredContentTags(n.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=(n,d)=>{if(n===d)return!0;if(n.length!==d.length)return!1;for(let f=0;f<n.length;f+=1){const l=n[f],r=d[f];if(!r||l.id!==r.id||l.alias!==r.alias||l.tag!==r.tag||l.position!==r.position)return!1}return!0},ze=n=>{if(!n)return null;if(n===!0)return{selector:"#superdoc-toolbar",config:{},renderDefaultContainer:!0};if(typeof n=="string")return{selector:n,config:{},renderDefaultContainer:!1};const{selector:d,...f}=n;return{selector:d||"#superdoc-toolbar",config:f,renderDefaultContainer:d===void 0}},le=10,He=250,Ue=300,Re=n=>{const d=window.innerWidth-He-le,f=window.innerHeight-Ue-le,l=Math.min(n.left,d),r=Math.min(n.top,f);return new DOMRect(Math.max(l,le),Math.max(r,le),n.width,n.height)},ke=i.forwardRef((n,d)=>{const{document:f,fields:l={},menu:r={},list:c={},toolbar:F,onReady:M,onTrigger:z,onFieldInsert:H,onFieldUpdate:P,onFieldDelete:N,onFieldsChange:T,onFieldSelect:V,onFieldCreate:I,className:U,style:O,documentHeight:Q="600px"}=n,[E,Y]=i.useState(l.initial||[]),[A,u]=i.useState(null),[b,R]=i.useState(!1),[k,j]=i.useState(),[D,ce]=i.useState(""),[Z,se]=i.useState(()=>l.available||[]),K=i.useRef(null),C=i.useRef(null),L=i.useRef(null),ee=i.useRef(l);ee.current=l;const W=i.useRef(null),te=i.useRef(b);i.useEffect(()=>{te.current=b},[b]);const q=r.trigger||"{{",e=ee.current.available||[],a=i.useCallback(t=>{const o=t.trim().toLowerCase();return o?e.filter(y=>{const v=y.label.toLowerCase(),S=y.category?.toLowerCase()||"";return v.includes(o)||S.includes(o)}):e},[e]),x=i.useCallback(t=>{ce(t),se(a(t))},[a]),p=i.useCallback(()=>{x("")},[x]),B=i.useCallback((t,o)=>{if(!C.current?.activeEditor)return!1;const y=C.current.activeEditor,v=`field_${Date.now()}`,S=t==="inline"?y.commands.insertStructuredContentInline?.({attrs:{id:v,alias:o.alias,tag:o.metadata?JSON.stringify(o.metadata):o.category},text:o.defaultValue||o.alias}):y.commands.insertStructuredContentBlock?.({attrs:{id:v,alias:o.alias,tag:o.metadata?JSON.stringify(o.metadata):o.category},text:o.defaultValue||o.alias});if(S){const _={id:v,alias:o.alias,tag:o.category};Y(g=>{const m=[...g,_];return T?.(m),m}),H?.(_)}return S},[H,T]),re=i.useCallback((t,o)=>{if(!C.current?.activeEditor)return!1;const v=C.current.activeEditor.commands.updateStructuredContentById?.(t,{attrs:o});return v&&Y(S=>{const _=S.map(m=>m.id===t?{...m,...o}:m);T?.(_);const g=_.find(m=>m.id===t);return g&&P?.(g),_}),v},[P,T]),h=i.useCallback(t=>{const o=C.current?.activeEditor;if(!o){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,T?.(X),X}),g&&(N?.(t),u(m=>m===t?null:m)),g}let y=!1;try{y=o.commands.deleteStructuredContentById?.(t)??!1}catch(g){console.error("[SuperDocTemplateBuilder] Delete command failed:",g)}let v=ve(o);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),T?.(v),v}),_&&(N?.(t),u(g=>g===t?null:g)),y||_},[N,T]),w=i.useCallback(t=>{if(!C.current?.activeEditor)return;C.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 o=ve(t);Y(y=>Ee(y,o)?y:(T?.(o),o))},[T]);i.useEffect(()=>K.current?((async()=>{const{SuperDoc:o}=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=C.current?.activeEditor;if(!ae)return;const Oe=ae.state.selection.from,Pe=ae.state.tr.delete(de,Oe);ae.view.dispatch(Pe)};L.current=xe,W.current=m,j(me),R(!0),p(),z?.({position:{from:de,to:m},bounds:me,cleanup:xe});return}}if(!te.current)return;if(W.current==null){R(!1),p();return}if(m<W.current){R(!1),W.current=null,p();return}const X=g.doc.textBetween(W.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)}M?.()}},v=new o({...y,...J&&{toolbar:J.selector,modules:{toolbar:{selector:J.selector,toolbarGroups:J.config.toolbarGroups||["center"],excludeItems:J.config.excludeItems||[],...J.config}}}});C.current=v})(),()=>{C.current&&(typeof C.current.destroy=="function"&&C.current.destroy(),C.current=null)}):void 0,[f?.source,f?.mode,q,G,M,z,F]);const ue=i.useCallback(async t=>{if(L.current&&(L.current(),L.current=null),W.current=null,p(),t.id.startsWith("custom_")&&I)try{const o=await I(t);if(o){B("inline",{alias:o.label,category:o.category,metadata:o.metadata,defaultValue:o.defaultValue}),R(!1);return}}catch(o){console.error("Field creation failed:",o)}B("inline",{alias:t.label,category:t.category,metadata:t.metadata,defaultValue:t.defaultValue}),R(!1)},[B,I,p]),we=i.useCallback(()=>{R(!1),W.current=null,p(),L.current&&(L.current(),L.current=null)},[p]),_e=i.useCallback(()=>{if(!C.current?.activeEditor||E.length===0)return;const t=E.findIndex(y=>y.id===A),o=t>=0?(t+1)%E.length:0;w(E[o].id)},[E,A,w]),je=i.useCallback(()=>{if(!C.current?.activeEditor||E.length===0)return;const t=E.findIndex(y=>y.id===A),o=t>0?t-1:E.length-1;w(E[o].id)},[E,A,w]),Se=i.useCallback(async t=>{try{await C.current?.export({exportType:["docx"],exportedName:t?.fileName?t?.fileName:"document"})}catch(o){throw console.error("Failed to export DOCX",o),o}},[]);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=r.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:k,availableFields:l.available||[],filteredFields:Z,filterQuery:D,allowCreate:l.allowCreate||!1,onSelect:ue,onClose:we,onCreateField:I})]})});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 J in a)J!=="key"&&(m[J]=a[J])}else m=a;return h&&D(m,typeof e=="function"?e.displayName||e.name||"Unknown":e),U(e,h,m,r(),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 Y=i,L=Symbol.for("react.transitional.element"),q=Symbol.for("react.portal"),O=Symbol.for("react.fragment"),Q=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"),Z=Y.__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};Y={react_stack_bottom_frame:function(e){return e()}};var M,ee={},I=Y.react_stack_bottom_frame.bind(Y,l)(),te=k(d(l)),G={};oe.Fragment=O,oe.jsx=function(e,a,m){var p=1e4>Z.recentlyCreatedOwnerStacks++;return P(e,a,m,!1,p?Error("react-stack-top-frame"):I,p?k(d(e)):te)},oe.jsxs=function(e,a,m){var p=1e4>Z.recentlyCreatedOwnerStacks++;return P(e,a,m,!0,p?Error("react-stack-top-frame"):I,p?k(d(e)):te)}})()),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:H})=>{const[U,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]),[Q,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(H){const E=await H(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&&!U&&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&&U&&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=!!Q[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},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:u,...f}=o;return{selector:u||"#superdoc-toolbar",config:f,renderDefaultContainer:u===void 0}},le=10,He=250,Ue=300,Re=o=>{const u=window.innerWidth-He-le,f=window.innerHeight-Ue-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:H,onFieldInsert:U,onFieldUpdate:P,onFieldDelete:N,onFieldsChange:C,onFieldSelect:Y,onFieldCreate:L,className:q,style:O,documentHeight:Q="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(""),[Z,se]=i.useState(()=>d.available||[]),K=i.useRef(null),k=i.useRef(null),M=i.useRef(null),ee=i.useRef(d);ee.current=d;const I=i.useRef(null),te=i.useRef(b);i.useEffect(()=>{te.current=b},[b]);const G=r.trigger||"{{",e=ee.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(z=>z.id===g.id));x&&U?.(x)}return S},[U,C,v]),re=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 z=g.filter(V=>V.id!==t);return x=!0,C?.(z),z}),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),z=R.some(V=>V.id===t);return g&&!z&&(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]),J=i.useCallback(t=>{if(!t)return;const n=fe(t);$(y=>Ee(y,n)?y:(C?.(n),n))},[C]);i.useEffect(()=>K.current?((async()=>{const{SuperDoc:n}=await import("superdoc"),y={selector:K.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(),H?.({position:{from:de,to:g},bounds:xe,cleanup:ge});return}}if(!te.current)return;if(I.current==null){E(!1),p();return}if(g<I.current){E(!1),I.current=null,p();return}const z=x.doc.textBetween(I.current,g);m(z);const V=w.view.coordsAtPos(g),Ne=Re(new DOMRect(V.left,V.top,0,0));j(Ne)}),S.on("update",()=>{J(S)}),J(S)}D?.()}},R=new n({...y,...X&&{toolbar:X.selector,modules:{toolbar:{selector:X.selector,toolbarGroups:X.config.toolbarGroups||["center"],excludeItems:X.config.excludeItems||[],...X.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,J,D,H,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:re,deleteField:h,selectField:_,nextField:_e,previousField:je,getFields:()=>v,exportTemplate:Se}));const Fe=r.component||Ce,pe=l.component||Te,X=ze(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,selectedFieldId:A||void 0})}),s.jsxs("div",{className:"superdoc-template-builder-document",style:{flex:1},children:[X?.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"})]}),l.position==="right"&&s.jsx("div",{className:"superdoc-template-builder-sidebar",children:s.jsx(pe,{fields:v,onSelect:t=>_(t.id),onDelete:h,selectedFieldId:A||void 0})})]}),s.jsx(Fe,{isVisible:b,position:T,availableFields:d.available||[],filteredFields:Z,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 z, useEffect as ue, useMemo as
|
|
1
|
+
import Ae, { useState as z, useEffect as ue, useMemo as ve, useCallback as C, forwardRef as Me, useRef as Z, useImperativeHandle as Ie } from "react";
|
|
2
2
|
var ce = { exports: {} }, se = {};
|
|
3
3
|
/**
|
|
4
4
|
* @license React
|
|
@@ -9,17 +9,17 @@ 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 = {};
|
|
21
|
-
for (var
|
|
22
|
-
|
|
21
|
+
for (var D in n)
|
|
22
|
+
D !== "key" && (i[D] = n[D]);
|
|
23
23
|
} else i = n;
|
|
24
24
|
return n = i.ref, {
|
|
25
25
|
$$typeof: a,
|
|
@@ -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,31 +52,31 @@ function Le() {
|
|
|
52
52
|
switch (e) {
|
|
53
53
|
case O:
|
|
54
54
|
return "Fragment";
|
|
55
|
-
case
|
|
55
|
+
case y:
|
|
56
56
|
return "Profiler";
|
|
57
57
|
case K:
|
|
58
58
|
return "StrictMode";
|
|
59
59
|
case g:
|
|
60
60
|
return "Suspense";
|
|
61
|
-
case
|
|
61
|
+
case v:
|
|
62
62
|
return "SuspenseList";
|
|
63
|
-
case
|
|
63
|
+
case W:
|
|
64
64
|
return "Activity";
|
|
65
65
|
}
|
|
66
66
|
if (typeof e == "object")
|
|
67
67
|
switch (typeof e.tag == "number" && console.error(
|
|
68
68
|
"Received an unexpected object in getComponentNameFromType(). This is likely a bug in React. Please file an issue."
|
|
69
69
|
), e.$$typeof) {
|
|
70
|
-
case
|
|
70
|
+
case 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;
|
|
78
78
|
return e = e.displayName, e || (e = s.displayName || s.name || "", e = e !== "" ? "ForwardRef(" + e + ")" : "ForwardRef"), e;
|
|
79
|
-
case
|
|
79
|
+
case T:
|
|
80
80
|
return s = e.displayName || null, s !== null ? s : a(e.type) || "Memo";
|
|
81
81
|
case k:
|
|
82
82
|
s = e._payload, e = e._init;
|
|
@@ -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
|
|
@@ -132,35 +132,35 @@ function Le() {
|
|
|
132
132
|
}
|
|
133
133
|
return e.key !== void 0;
|
|
134
134
|
}
|
|
135
|
-
function
|
|
136
|
-
function
|
|
137
|
-
|
|
135
|
+
function D(e, s) {
|
|
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
|
-
function
|
|
147
|
+
function U() {
|
|
148
148
|
var e = a(this.type);
|
|
149
149
|
return re[e] || (re[e] = !0, console.error(
|
|
150
150
|
"Accessing element.ref was removed in React 19. ref is now a regular prop. It will be removed from the JSX Element type in a future release."
|
|
151
151
|
)), e = this.props.ref, e !== void 0 ? e : null;
|
|
152
152
|
}
|
|
153
|
-
function
|
|
154
|
-
var h =
|
|
153
|
+
function G(e, s, u, d, B, oe) {
|
|
154
|
+
var h = u.ref;
|
|
155
155
|
return e = {
|
|
156
|
-
$$typeof:
|
|
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,
|
|
163
|
-
get:
|
|
163
|
+
get: U
|
|
164
164
|
}) : Object.defineProperty(e, "ref", { enumerable: !1, value: null }), e._store = {}, Object.defineProperty(e._store, "validated", {
|
|
165
165
|
configurable: !1,
|
|
166
166
|
enumerable: !1,
|
|
@@ -183,7 +183,7 @@ function Le() {
|
|
|
183
183
|
value: oe
|
|
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, oe) {
|
|
187
187
|
var h = s.children;
|
|
188
188
|
if (h !== void 0)
|
|
189
189
|
if (d)
|
|
@@ -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,89 +210,89 @@ 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
|
|
222
|
-
return h &&
|
|
223
|
-
|
|
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 X in s)
|
|
220
|
+
X !== "key" && (u[X] = s[X]);
|
|
221
|
+
} else u = s;
|
|
222
|
+
return h && D(
|
|
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
|
oe
|
|
232
232
|
);
|
|
233
233
|
}
|
|
234
234
|
function N(e) {
|
|
235
|
-
|
|
235
|
+
R(e) ? e._store && (e._store.validated = 1) : typeof e == "object" && e !== null && e.$$typeof === k && (e._payload.status === "fulfilled" ? R(e._payload.value) && e._payload.value._store && (e._payload.value._store.validated = 1) : e._store && (e._store.validated = 1));
|
|
236
236
|
}
|
|
237
|
-
function
|
|
238
|
-
return typeof e == "object" && e !== null && e.$$typeof ===
|
|
237
|
+
function R(e) {
|
|
238
|
+
return typeof e == "object" && e !== null && e.$$typeof === L;
|
|
239
239
|
}
|
|
240
|
-
var
|
|
240
|
+
var Y = Ae, L = Symbol.for("react.transitional.element"), J = Symbol.for("react.portal"), O = Symbol.for("react.fragment"), K = 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"), ee = Y.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE, ie = Object.prototype.hasOwnProperty, te = Array.isArray, w = console.createTask ? console.createTask : function() {
|
|
241
241
|
return null;
|
|
242
242
|
};
|
|
243
|
-
|
|
243
|
+
Y = {
|
|
244
244
|
react_stack_bottom_frame: function(e) {
|
|
245
245
|
return e();
|
|
246
246
|
}
|
|
247
247
|
};
|
|
248
|
-
var
|
|
249
|
-
|
|
248
|
+
var M, re = {}, I = Y.react_stack_bottom_frame.bind(
|
|
249
|
+
Y,
|
|
250
250
|
i
|
|
251
|
-
)(), ne =
|
|
252
|
-
ae.Fragment = O, ae.jsx = function(e, s,
|
|
251
|
+
)(), ne = w(c(i)), q = {};
|
|
252
|
+
ae.Fragment = O, ae.jsx = function(e, s, u) {
|
|
253
253
|
var d = 1e4 > ee.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 ?
|
|
259
|
+
d ? Error("react-stack-top-frame") : I,
|
|
260
|
+
d ? w(c(e)) : ne
|
|
261
261
|
);
|
|
262
|
-
}, ae.jsxs = function(e, s,
|
|
262
|
+
}, ae.jsxs = function(e, s, u) {
|
|
263
263
|
var d = 1e4 > ee.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 ?
|
|
269
|
+
d ? Error("react-stack-top-frame") : I,
|
|
270
|
+
d ? w(c(e)) : ne
|
|
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,
|
|
287
287
|
onSelect: F,
|
|
288
|
-
onClose:
|
|
289
|
-
onCreateField:
|
|
288
|
+
onClose: D,
|
|
289
|
+
onCreateField: U
|
|
290
290
|
}) => {
|
|
291
|
-
const [
|
|
291
|
+
const [G, P] = z(!1), [N, R] = z("");
|
|
292
292
|
ue(() => {
|
|
293
|
-
a || (P(!1),
|
|
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]),
|
|
306
|
+
}), [x]), L = c ?? m, J = !!n, O = ve(() => {
|
|
307
307
|
const l = [], g = /* @__PURE__ */ new Map();
|
|
308
|
-
return
|
|
309
|
-
const
|
|
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(
|
|
314
|
+
g.set(T, l.length), l.push({ category: T, fields: [v] });
|
|
315
315
|
}), l;
|
|
316
|
-
}, [
|
|
316
|
+
}, [L]), [K, y] = z({});
|
|
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
|
|
323
|
-
return O.forEach(({ category:
|
|
324
|
-
const
|
|
325
|
-
g[
|
|
326
|
-
}),
|
|
322
|
+
let v = Object.keys(l).length !== O.length;
|
|
323
|
+
return O.forEach(({ category: T }, k) => {
|
|
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
|
}));
|
|
@@ -342,17 +342,17 @@ const Be = ({
|
|
|
342
342
|
category: "Custom"
|
|
343
343
|
};
|
|
344
344
|
try {
|
|
345
|
-
if (
|
|
346
|
-
const
|
|
347
|
-
F(
|
|
345
|
+
if (U) {
|
|
346
|
+
const v = await U(g);
|
|
347
|
+
F(v || g);
|
|
348
348
|
} else
|
|
349
349
|
F(g);
|
|
350
350
|
} finally {
|
|
351
|
-
P(!1),
|
|
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,16 +386,16 @@ 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
|
{
|
|
393
393
|
type: "text",
|
|
394
394
|
value: N,
|
|
395
395
|
placeholder: "Field name...",
|
|
396
|
-
onChange: (l) =>
|
|
396
|
+
onChange: (l) => R(l.target.value),
|
|
397
397
|
onKeyDown: (l) => {
|
|
398
|
-
l.key === "Enter" && A(), l.key === "Escape" && (P(!1),
|
|
398
|
+
l.key === "Enter" && A(), l.key === "Escape" && (P(!1), R(""));
|
|
399
399
|
},
|
|
400
400
|
autoFocus: !0,
|
|
401
401
|
style: {
|
|
@@ -435,7 +435,7 @@ const Be = ({
|
|
|
435
435
|
"button",
|
|
436
436
|
{
|
|
437
437
|
onClick: () => {
|
|
438
|
-
P(!1),
|
|
438
|
+
P(!1), R("");
|
|
439
439
|
},
|
|
440
440
|
style: {
|
|
441
441
|
padding: "4px 12px",
|
|
@@ -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
|
|
474
|
+
) : O.map(({ category: l, fields: g }, v) => {
|
|
475
|
+
const T = !!K[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",
|
|
@@ -514,7 +514,7 @@ const Be = ({
|
|
|
514
514
|
height: "8px",
|
|
515
515
|
borderRight: "2px solid #666",
|
|
516
516
|
borderBottom: "2px solid #666",
|
|
517
|
-
transform:
|
|
517
|
+
transform: T ? "rotate(45deg)" : "rotate(-45deg)",
|
|
518
518
|
transition: "transform 0.2s ease",
|
|
519
519
|
marginLeft: "12px"
|
|
520
520
|
}
|
|
@@ -527,19 +527,19 @@ const Be = ({
|
|
|
527
527
|
"div",
|
|
528
528
|
{
|
|
529
529
|
"data-category": l,
|
|
530
|
-
"aria-hidden": !
|
|
530
|
+
"aria-hidden": !T,
|
|
531
531
|
style: {
|
|
532
532
|
overflow: "hidden",
|
|
533
|
-
maxHeight:
|
|
534
|
-
opacity:
|
|
533
|
+
maxHeight: T ? k : "0px",
|
|
534
|
+
opacity: T ? 1 : 0,
|
|
535
535
|
transition: "max-height 0.2s ease, opacity 0.2s ease",
|
|
536
|
-
pointerEvents:
|
|
536
|
+
pointerEvents: T ? "auto" : "none"
|
|
537
537
|
},
|
|
538
|
-
children: /* @__PURE__ */ o.jsx("div", { style: { padding:
|
|
538
|
+
children: /* @__PURE__ */ o.jsx("div", { style: { padding: T ? "4px 0" : 0 }, children: g.map((W) => /* @__PURE__ */ o.jsx(
|
|
539
539
|
"div",
|
|
540
540
|
{
|
|
541
541
|
className: "field-menu-item",
|
|
542
|
-
onClick: () => F(
|
|
542
|
+
onClick: () => F(W),
|
|
543
543
|
style: {
|
|
544
544
|
padding: "8px 16px",
|
|
545
545
|
cursor: "pointer",
|
|
@@ -547,9 +547,9 @@ const Be = ({
|
|
|
547
547
|
alignItems: "center",
|
|
548
548
|
justifyContent: "space-between"
|
|
549
549
|
},
|
|
550
|
-
children: /* @__PURE__ */ o.jsx("span", { style: { fontWeight: 500 }, children:
|
|
550
|
+
children: /* @__PURE__ */ o.jsx("span", { style: { fontWeight: 500 }, children: W.label })
|
|
551
551
|
},
|
|
552
|
-
|
|
552
|
+
W.id
|
|
553
553
|
)) })
|
|
554
554
|
}
|
|
555
555
|
)
|
|
@@ -568,7 +568,7 @@ const Be = ({
|
|
|
568
568
|
children: /* @__PURE__ */ o.jsx(
|
|
569
569
|
"button",
|
|
570
570
|
{
|
|
571
|
-
onClick:
|
|
571
|
+
onClick: D,
|
|
572
572
|
style: {
|
|
573
573
|
width: "100%",
|
|
574
574
|
padding: "6px 16px",
|
|
@@ -583,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,253 +752,252 @@ 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, ze = 300, _e = (a) => {
|
|
762
|
+
const x = window.innerWidth - $e - de, m = window.innerHeight - ze - 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
|
-
}, He =
|
|
769
|
+
}, He = 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
|
-
onReady:
|
|
777
|
-
onTrigger:
|
|
778
|
-
onFieldInsert:
|
|
776
|
+
onReady: D,
|
|
777
|
+
onTrigger: U,
|
|
778
|
+
onFieldInsert: G,
|
|
779
779
|
onFieldUpdate: P,
|
|
780
780
|
onFieldDelete: N,
|
|
781
|
-
onFieldsChange:
|
|
782
|
-
onFieldSelect:
|
|
783
|
-
onFieldCreate:
|
|
784
|
-
className:
|
|
781
|
+
onFieldsChange: R,
|
|
782
|
+
onFieldSelect: Y,
|
|
783
|
+
onFieldCreate: L,
|
|
784
|
+
className: J,
|
|
785
785
|
style: O,
|
|
786
786
|
documentHeight: K = "600px"
|
|
787
|
-
} = a, [
|
|
787
|
+
} = a, [y, $] = z(
|
|
788
788
|
c.initial || []
|
|
789
|
-
), [A, l] = z(
|
|
789
|
+
), [A, l] = z(
|
|
790
|
+
null
|
|
791
|
+
), [g, v] = z(!1), [T, k] = z(), [W, fe] = z(""), [ee, ie] = z(() => c.available || []), te = Z(null), w = Z(null), M = Z(null), re = Z(c);
|
|
790
792
|
re.current = c;
|
|
791
|
-
const
|
|
793
|
+
const I = Z(null), ne = Z(g);
|
|
792
794
|
ue(() => {
|
|
793
795
|
ne.current = g;
|
|
794
796
|
}, [g]);
|
|
795
|
-
const
|
|
797
|
+
const q = n.trigger || "{{", e = re.current.available || [], s = C(
|
|
796
798
|
(t) => {
|
|
797
799
|
const r = t.trim().toLowerCase();
|
|
798
800
|
return r ? e.filter((b) => {
|
|
799
|
-
const
|
|
800
|
-
return
|
|
801
|
+
const E = b.label.toLowerCase(), S = b.category?.toLowerCase() || "";
|
|
802
|
+
return E.includes(r) || S.includes(r);
|
|
801
803
|
}) : e;
|
|
802
804
|
},
|
|
803
805
|
[e]
|
|
804
|
-
),
|
|
806
|
+
), u = C(
|
|
805
807
|
(t) => {
|
|
806
808
|
fe(t), ie(s(t));
|
|
807
809
|
},
|
|
808
810
|
[s]
|
|
809
811
|
), d = C(() => {
|
|
810
|
-
|
|
811
|
-
}, [
|
|
812
|
+
u("");
|
|
813
|
+
}, [u]), B = C(
|
|
812
814
|
(t, r) => {
|
|
813
|
-
if (!
|
|
814
|
-
const b =
|
|
815
|
+
if (!w.current?.activeEditor) return !1;
|
|
816
|
+
const b = w.current.activeEditor, E = y, S = t === "inline" ? b.commands.insertStructuredContentInline?.({
|
|
815
817
|
attrs: {
|
|
816
|
-
id: y,
|
|
817
818
|
alias: r.alias,
|
|
818
819
|
tag: r.metadata ? JSON.stringify(r.metadata) : r.category
|
|
819
820
|
},
|
|
820
821
|
text: r.defaultValue || r.alias
|
|
821
822
|
}) : b.commands.insertStructuredContentBlock?.({
|
|
822
823
|
attrs: {
|
|
823
|
-
id: y,
|
|
824
824
|
alias: r.alias,
|
|
825
825
|
tag: r.metadata ? JSON.stringify(r.metadata) : r.category
|
|
826
826
|
},
|
|
827
827
|
text: r.defaultValue || r.alias
|
|
828
828
|
});
|
|
829
829
|
if (S) {
|
|
830
|
-
const
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
const u = [...m, j];
|
|
837
|
-
return T?.(u), u;
|
|
838
|
-
}), U?.(j);
|
|
830
|
+
const _ = xe(b);
|
|
831
|
+
$(_), R?.(_);
|
|
832
|
+
const f = _.find(
|
|
833
|
+
(p) => !E.some((H) => H.id === p.id)
|
|
834
|
+
);
|
|
835
|
+
f && G?.(f);
|
|
839
836
|
}
|
|
840
837
|
return S;
|
|
841
838
|
},
|
|
842
|
-
[
|
|
839
|
+
[G, R, y]
|
|
843
840
|
), oe = C(
|
|
844
841
|
(t, r) => {
|
|
845
|
-
if (!
|
|
846
|
-
const
|
|
842
|
+
if (!w.current?.activeEditor) return !1;
|
|
843
|
+
const E = w.current.activeEditor.commands.updateStructuredContentById?.(t, {
|
|
847
844
|
attrs: r
|
|
848
845
|
});
|
|
849
|
-
return
|
|
850
|
-
const
|
|
851
|
-
(
|
|
846
|
+
return E && $((S) => {
|
|
847
|
+
const _ = S.map(
|
|
848
|
+
(p) => p.id === t ? { ...p, ...r } : p
|
|
852
849
|
);
|
|
853
|
-
|
|
854
|
-
const
|
|
855
|
-
return
|
|
856
|
-
}),
|
|
850
|
+
R?.(_);
|
|
851
|
+
const f = _.find((p) => p.id === t);
|
|
852
|
+
return f && P?.(f), _;
|
|
853
|
+
}), E;
|
|
857
854
|
},
|
|
858
|
-
[P,
|
|
855
|
+
[P, R]
|
|
859
856
|
), h = C(
|
|
860
857
|
(t) => {
|
|
861
|
-
const r =
|
|
858
|
+
const r = w.current?.activeEditor;
|
|
862
859
|
if (!r) {
|
|
863
860
|
console.warn(
|
|
864
861
|
"[SuperDocTemplateBuilder] deleteField called without active editor"
|
|
865
862
|
);
|
|
866
|
-
let
|
|
867
|
-
return
|
|
868
|
-
if (!
|
|
869
|
-
const
|
|
870
|
-
return
|
|
871
|
-
}),
|
|
863
|
+
let f = !1;
|
|
864
|
+
return $((p) => {
|
|
865
|
+
if (!p.some((V) => V.id === t)) return p;
|
|
866
|
+
const H = p.filter((V) => V.id !== t);
|
|
867
|
+
return f = !0, R?.(H), H;
|
|
868
|
+
}), f && (N?.(t), l((p) => p === t ? null : p)), f;
|
|
872
869
|
}
|
|
873
870
|
let b = !1;
|
|
874
871
|
try {
|
|
875
872
|
b = r.commands.deleteStructuredContentById?.(t) ?? !1;
|
|
876
|
-
} catch (
|
|
873
|
+
} catch (f) {
|
|
877
874
|
console.error(
|
|
878
875
|
"[SuperDocTemplateBuilder] Delete command failed:",
|
|
879
|
-
|
|
876
|
+
f
|
|
880
877
|
);
|
|
881
878
|
}
|
|
882
|
-
let
|
|
883
|
-
const S =
|
|
884
|
-
!b && S && (
|
|
885
|
-
let
|
|
886
|
-
return
|
|
887
|
-
if (we(
|
|
888
|
-
return
|
|
889
|
-
const
|
|
890
|
-
return
|
|
891
|
-
}),
|
|
879
|
+
let E = xe(r);
|
|
880
|
+
const S = E.some((f) => f.id === t);
|
|
881
|
+
!b && S && (E = E.filter((f) => f.id !== t));
|
|
882
|
+
let _ = !1;
|
|
883
|
+
return $((f) => {
|
|
884
|
+
if (we(f, E))
|
|
885
|
+
return f;
|
|
886
|
+
const p = f.some((V) => V.id === t), H = E.some((V) => V.id === t);
|
|
887
|
+
return p && !H && (_ = !0), R?.(E), E;
|
|
888
|
+
}), _ && (N?.(t), l((f) => f === t ? null : f)), b || _;
|
|
892
889
|
},
|
|
893
|
-
[N,
|
|
894
|
-
),
|
|
890
|
+
[N, R]
|
|
891
|
+
), j = C(
|
|
895
892
|
(t) => {
|
|
896
|
-
if (!
|
|
897
|
-
|
|
898
|
-
const b =
|
|
899
|
-
b &&
|
|
893
|
+
if (!w.current?.activeEditor) return;
|
|
894
|
+
w.current.activeEditor.commands.selectStructuredContentById?.(t), l(t);
|
|
895
|
+
const b = y.find((E) => E.id === t);
|
|
896
|
+
b && Y?.(b);
|
|
900
897
|
},
|
|
901
|
-
[
|
|
902
|
-
),
|
|
898
|
+
[y, Y]
|
|
899
|
+
), X = C(
|
|
903
900
|
(t) => {
|
|
904
901
|
if (!t) return;
|
|
905
|
-
const r =
|
|
906
|
-
|
|
902
|
+
const r = xe(t);
|
|
903
|
+
$((b) => we(b, r) ? b : (R?.(r), r));
|
|
907
904
|
},
|
|
908
|
-
[
|
|
905
|
+
[R]
|
|
909
906
|
);
|
|
910
907
|
ue(() => te.current ? ((async () => {
|
|
911
908
|
const { SuperDoc: r } = await import("superdoc"), b = {
|
|
912
909
|
selector: te.current,
|
|
913
|
-
document:
|
|
914
|
-
documentMode:
|
|
910
|
+
document: m?.source,
|
|
911
|
+
documentMode: m?.mode || "editing",
|
|
915
912
|
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
|
-
),
|
|
926
|
-
const le =
|
|
913
|
+
if (E.activeEditor) {
|
|
914
|
+
const S = E.activeEditor;
|
|
915
|
+
S.on("update", ({ editor: _ }) => {
|
|
916
|
+
const { state: f } = _, { from: p } = f.selection;
|
|
917
|
+
if (p >= q.length) {
|
|
918
|
+
const me = p - q.length;
|
|
919
|
+
if (f.doc.textBetween(me, p) === q) {
|
|
920
|
+
const he = _.view.coordsAtPos(p), be = _e(
|
|
921
|
+
new DOMRect(he.left, he.top, 0, 0)
|
|
922
|
+
), ye = () => {
|
|
923
|
+
const le = w.current?.activeEditor;
|
|
927
924
|
if (!le) return;
|
|
928
925
|
const Oe = le.state.selection.from, Pe = le.state.tr.delete(me, Oe);
|
|
929
926
|
le.view.dispatch(Pe);
|
|
930
927
|
};
|
|
931
|
-
|
|
932
|
-
position: { from: me, to:
|
|
933
|
-
bounds:
|
|
934
|
-
cleanup:
|
|
928
|
+
M.current = ye, I.current = p, k(be), v(!0), d(), U?.({
|
|
929
|
+
position: { from: me, to: p },
|
|
930
|
+
bounds: be,
|
|
931
|
+
cleanup: ye
|
|
935
932
|
});
|
|
936
933
|
return;
|
|
937
934
|
}
|
|
938
935
|
}
|
|
939
936
|
if (!ne.current)
|
|
940
937
|
return;
|
|
941
|
-
if (
|
|
942
|
-
|
|
938
|
+
if (I.current == null) {
|
|
939
|
+
v(!1), d();
|
|
943
940
|
return;
|
|
944
941
|
}
|
|
945
|
-
if (
|
|
946
|
-
|
|
942
|
+
if (p < I.current) {
|
|
943
|
+
v(!1), I.current = null, d();
|
|
947
944
|
return;
|
|
948
945
|
}
|
|
949
|
-
const
|
|
950
|
-
|
|
951
|
-
|
|
946
|
+
const H = f.doc.textBetween(
|
|
947
|
+
I.current,
|
|
948
|
+
p
|
|
952
949
|
);
|
|
953
|
-
|
|
954
|
-
const
|
|
955
|
-
new DOMRect(
|
|
950
|
+
u(H);
|
|
951
|
+
const V = _.view.coordsAtPos(p), Ne = _e(
|
|
952
|
+
new DOMRect(V.left, V.top, 0, 0)
|
|
956
953
|
);
|
|
957
954
|
k(Ne);
|
|
958
955
|
}), S.on("update", () => {
|
|
959
|
-
|
|
960
|
-
}),
|
|
956
|
+
X(S);
|
|
957
|
+
}), X(S);
|
|
961
958
|
}
|
|
962
|
-
|
|
959
|
+
D?.();
|
|
963
960
|
}
|
|
964
|
-
},
|
|
961
|
+
}, E = new r({
|
|
965
962
|
...b,
|
|
966
|
-
...
|
|
967
|
-
toolbar:
|
|
963
|
+
...Q && {
|
|
964
|
+
toolbar: Q.selector,
|
|
968
965
|
modules: {
|
|
969
966
|
toolbar: {
|
|
970
|
-
selector:
|
|
971
|
-
toolbarGroups:
|
|
972
|
-
excludeItems:
|
|
973
|
-
...
|
|
967
|
+
selector: Q.selector,
|
|
968
|
+
toolbarGroups: Q.config.toolbarGroups || ["center"],
|
|
969
|
+
excludeItems: Q.config.excludeItems || [],
|
|
970
|
+
...Q.config
|
|
974
971
|
}
|
|
975
972
|
}
|
|
976
973
|
}
|
|
977
974
|
});
|
|
978
|
-
|
|
975
|
+
w.current = E;
|
|
979
976
|
})(), () => {
|
|
980
|
-
|
|
977
|
+
M.current = null, I.current = null;
|
|
978
|
+
const r = w.current;
|
|
979
|
+
r && typeof r.destroy == "function" && r.destroy(), w.current = null;
|
|
981
980
|
}) : void 0, [
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
J,
|
|
981
|
+
m?.source,
|
|
982
|
+
m?.mode,
|
|
985
983
|
q,
|
|
986
|
-
|
|
987
|
-
|
|
984
|
+
X,
|
|
985
|
+
D,
|
|
986
|
+
U,
|
|
988
987
|
F
|
|
989
988
|
]);
|
|
990
989
|
const pe = C(
|
|
991
990
|
async (t) => {
|
|
992
|
-
if (
|
|
991
|
+
if (M.current && (M.current(), M.current = null), I.current = null, d(), t.id.startsWith("custom_") && L)
|
|
993
992
|
try {
|
|
994
|
-
const r = await
|
|
993
|
+
const r = await L(t);
|
|
995
994
|
if (r) {
|
|
996
995
|
B("inline", {
|
|
997
996
|
alias: r.label,
|
|
998
997
|
category: r.category,
|
|
999
998
|
metadata: r.metadata,
|
|
1000
999
|
defaultValue: r.defaultValue
|
|
1001
|
-
}),
|
|
1000
|
+
}), v(!1);
|
|
1002
1001
|
return;
|
|
1003
1002
|
}
|
|
1004
1003
|
} catch (r) {
|
|
@@ -1009,29 +1008,29 @@ const Be = ({
|
|
|
1009
1008
|
category: t.category,
|
|
1010
1009
|
metadata: t.metadata,
|
|
1011
1010
|
defaultValue: t.defaultValue
|
|
1012
|
-
}),
|
|
1011
|
+
}), v(!1);
|
|
1013
1012
|
},
|
|
1014
|
-
[B,
|
|
1013
|
+
[B, L, d]
|
|
1015
1014
|
), je = C(() => {
|
|
1016
|
-
|
|
1015
|
+
v(!1), I.current = null, d(), M.current && (M.current(), M.current = null);
|
|
1017
1016
|
}, [d]), Ce = C(() => {
|
|
1018
|
-
if (!
|
|
1017
|
+
if (!w.current?.activeEditor || y.length === 0)
|
|
1019
1018
|
return;
|
|
1020
|
-
const t =
|
|
1019
|
+
const t = y.findIndex(
|
|
1021
1020
|
(b) => b.id === A
|
|
1022
|
-
), r = t >= 0 ? (t + 1) %
|
|
1023
|
-
|
|
1024
|
-
}, [
|
|
1025
|
-
if (!
|
|
1021
|
+
), r = t >= 0 ? (t + 1) % y.length : 0;
|
|
1022
|
+
j(y[r].id);
|
|
1023
|
+
}, [y, A, j]), ke = C(() => {
|
|
1024
|
+
if (!w.current?.activeEditor || y.length === 0)
|
|
1026
1025
|
return;
|
|
1027
|
-
const t =
|
|
1026
|
+
const t = y.findIndex(
|
|
1028
1027
|
(b) => b.id === A
|
|
1029
|
-
), r = t > 0 ? t - 1 :
|
|
1030
|
-
|
|
1031
|
-
}, [
|
|
1028
|
+
), r = t > 0 ? t - 1 : y.length - 1;
|
|
1029
|
+
j(y[r].id);
|
|
1030
|
+
}, [y, A, j]), Se = C(
|
|
1032
1031
|
async (t) => {
|
|
1033
1032
|
try {
|
|
1034
|
-
await
|
|
1033
|
+
await w.current?.export({
|
|
1035
1034
|
exportType: ["docx"],
|
|
1036
1035
|
exportedName: t?.fileName ? t?.fileName : "document"
|
|
1037
1036
|
});
|
|
@@ -1041,36 +1040,36 @@ const Be = ({
|
|
|
1041
1040
|
},
|
|
1042
1041
|
[]
|
|
1043
1042
|
);
|
|
1044
|
-
|
|
1043
|
+
Ie(x, () => ({
|
|
1045
1044
|
insertField: (t) => B("inline", t),
|
|
1046
1045
|
insertBlockField: (t) => B("block", t),
|
|
1047
1046
|
updateField: oe,
|
|
1048
1047
|
deleteField: h,
|
|
1049
|
-
selectField:
|
|
1048
|
+
selectField: j,
|
|
1050
1049
|
nextField: Ce,
|
|
1051
1050
|
previousField: ke,
|
|
1052
|
-
getFields: () =>
|
|
1051
|
+
getFields: () => y,
|
|
1053
1052
|
exportTemplate: Se
|
|
1054
1053
|
}));
|
|
1055
|
-
const Fe = n.component || Be,
|
|
1054
|
+
const Fe = n.component || Be, ge = i.component || Ve, Q = Ye(F);
|
|
1056
1055
|
return /* @__PURE__ */ o.jsxs(
|
|
1057
1056
|
"div",
|
|
1058
1057
|
{
|
|
1059
|
-
className: `superdoc-template-builder ${
|
|
1058
|
+
className: `superdoc-template-builder ${J || ""}`,
|
|
1060
1059
|
style: O,
|
|
1061
1060
|
children: [
|
|
1062
1061
|
/* @__PURE__ */ o.jsxs("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1063
1062
|
i.position === "left" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1064
|
-
|
|
1063
|
+
ge,
|
|
1065
1064
|
{
|
|
1066
|
-
fields:
|
|
1067
|
-
onSelect: (t) =>
|
|
1065
|
+
fields: y,
|
|
1066
|
+
onSelect: (t) => j(t.id),
|
|
1068
1067
|
onDelete: h,
|
|
1069
1068
|
selectedFieldId: A || void 0
|
|
1070
1069
|
}
|
|
1071
1070
|
) }),
|
|
1072
1071
|
/* @__PURE__ */ o.jsxs("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1073
|
-
|
|
1072
|
+
Q?.renderDefaultContainer && /* @__PURE__ */ o.jsx(
|
|
1074
1073
|
"div",
|
|
1075
1074
|
{
|
|
1076
1075
|
id: "superdoc-toolbar",
|
|
@@ -1089,10 +1088,10 @@ const Be = ({
|
|
|
1089
1088
|
)
|
|
1090
1089
|
] }),
|
|
1091
1090
|
i.position === "right" && /* @__PURE__ */ o.jsx("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ o.jsx(
|
|
1092
|
-
|
|
1091
|
+
ge,
|
|
1093
1092
|
{
|
|
1094
|
-
fields:
|
|
1095
|
-
onSelect: (t) =>
|
|
1093
|
+
fields: y,
|
|
1094
|
+
onSelect: (t) => j(t.id),
|
|
1096
1095
|
onDelete: h,
|
|
1097
1096
|
selectedFieldId: A || void 0
|
|
1098
1097
|
}
|
|
@@ -1102,14 +1101,14 @@ const Be = ({
|
|
|
1102
1101
|
Fe,
|
|
1103
1102
|
{
|
|
1104
1103
|
isVisible: g,
|
|
1105
|
-
position:
|
|
1104
|
+
position: T,
|
|
1106
1105
|
availableFields: c.available || [],
|
|
1107
1106
|
filteredFields: ee,
|
|
1108
|
-
filterQuery:
|
|
1107
|
+
filterQuery: W,
|
|
1109
1108
|
allowCreate: c.allowCreate || !1,
|
|
1110
1109
|
onSelect: pe,
|
|
1111
1110
|
onClose: je,
|
|
1112
|
-
onCreateField:
|
|
1111
|
+
onCreateField: L
|
|
1113
1112
|
}
|
|
1114
1113
|
)
|
|
1115
1114
|
]
|
|
@@ -1118,7 +1117,7 @@ const Be = ({
|
|
|
1118
1117
|
});
|
|
1119
1118
|
He.displayName = "SuperDocTemplateBuilder";
|
|
1120
1119
|
export {
|
|
1121
|
-
|
|
1120
|
+
Ve as FieldList,
|
|
1122
1121
|
Be as FieldMenu,
|
|
1123
1122
|
He as default
|
|
1124
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,8 @@ export interface FieldMenuProps {
|
|
|
33
33
|
export interface FieldListProps {
|
|
34
34
|
fields: TemplateField[];
|
|
35
35
|
onSelect: (field: TemplateField) => void;
|
|
36
|
-
onDelete: (fieldId: string) => void;
|
|
37
|
-
selectedFieldId?: string;
|
|
36
|
+
onDelete: (fieldId: string | number) => void;
|
|
37
|
+
selectedFieldId?: string | number;
|
|
38
38
|
}
|
|
39
39
|
export interface DocumentConfig {
|
|
40
40
|
source?: string | File | Blob;
|
|
@@ -74,7 +74,7 @@ export interface SuperDocTemplateBuilderProps {
|
|
|
74
74
|
onTrigger?: (event: TriggerEvent) => void;
|
|
75
75
|
onFieldInsert?: (field: TemplateField) => void;
|
|
76
76
|
onFieldUpdate?: (field: TemplateField) => void;
|
|
77
|
-
onFieldDelete?: (fieldId: string) => void;
|
|
77
|
+
onFieldDelete?: (fieldId: string | number) => void;
|
|
78
78
|
onFieldsChange?: (fields: TemplateField[]) => void;
|
|
79
79
|
onFieldSelect?: (field: TemplateField | null) => void;
|
|
80
80
|
onFieldCreate?: (field: FieldDefinition) => void | Promise<FieldDefinition | void>;
|
|
@@ -89,9 +89,9 @@ export interface SuperDocTemplateBuilderHandle {
|
|
|
89
89
|
insertBlockField: (field: Partial<FieldDefinition> & {
|
|
90
90
|
alias: string;
|
|
91
91
|
}) => boolean;
|
|
92
|
-
updateField: (id: string, updates: Partial<TemplateField>) => boolean;
|
|
93
|
-
deleteField: (id: string) => boolean;
|
|
94
|
-
selectField: (id: string) => void;
|
|
92
|
+
updateField: (id: string | number, updates: Partial<TemplateField>) => boolean;
|
|
93
|
+
deleteField: (id: string | number) => boolean;
|
|
94
|
+
selectField: (id: string | number) => void;
|
|
95
95
|
nextField: () => void;
|
|
96
96
|
previousField: () => void;
|
|
97
97
|
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":"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,GAAG,MAAM,CAAC;IACpB,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,QAAQ,EAAE;QAAE,IAAI,EAAE,MAAM,CAAC;QAAC,EAAE,EAAE,MAAM,CAAA;KAAE,CAAC;IACvC,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,OAAO,EAAE,MAAM,IAAI,CAAC;CACrB;AAED,MAAM,WAAW,cAAc;IAC7B,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,eAAe,EAAE,eAAe,EAAE,CAAC;IACnC,cAAc,CAAC,EAAE,eAAe,EAAE,CAAC;IACnC,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,QAAQ,EAAE,CAAC,KAAK,EAAE,eAAe,KAAK,IAAI,CAAC;IAC3C,OAAO,EAAE,MAAM,IAAI,CAAC;IACpB,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,eAAe,KACnB,IAAI,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;CAC7C;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,aAAa,EAAE,CAAC;IACxB,QAAQ,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IACzC,QAAQ,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC7C,eAAe,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;CACnC;AAED,MAAM,WAAW,cAAc;IAC7B,MAAM,CAAC,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI,CAAC;IAC9B,IAAI,CAAC,EAAE,SAAS,GAAG,SAAS,CAAC;CAC9B;AAED,MAAM,WAAW,YAAY;IAC3B,SAAS,CAAC,EAAE,eAAe,EAAE,CAAC;IAC9B,OAAO,CAAC,EAAE,aAAa,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,OAAO,CAAC;CACvB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC,cAAc,CAAC,CAAC;IAChD,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;CAC7B;AAED,MAAM,WAAW,aAAa;IAC5B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,aAAa,CAAC,EAAE,MAAM,EAAE,CAAC;IACzB,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC;IAClC,KAAK,CAAC,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC;IACxB,WAAW,CAAC,EAAE,OAAO,CAAC;IACtB,qBAAqB,CAAC,EAAE,OAAO,CAAC;IAChC,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC/B,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC7B;AAED,MAAM,WAAW,4BAA4B;IAC3C,QAAQ,CAAC,EAAE,cAAc,CAAC;IAC1B,MAAM,CAAC,EAAE,YAAY,CAAC;IACtB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,IAAI,CAAC,EAAE,UAAU,CAAC;IAClB,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,GAAG,aAAa,CAAC;IAG3C,OAAO,CAAC,EAAE,MAAM,IAAI,CAAC;IACrB,SAAS,CAAC,EAAE,CAAC,KAAK,EAAE,YAAY,KAAK,IAAI,CAAC;IAC1C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,KAAK,IAAI,CAAC;IAC/C,aAAa,CAAC,EAAE,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IACnD,cAAc,CAAC,EAAE,CAAC,MAAM,EAAE,aAAa,EAAE,KAAK,IAAI,CAAC;IACnD,aAAa,CAAC,EAAE,CAAC,KAAK,EAAE,aAAa,GAAG,IAAI,KAAK,IAAI,CAAC;IACtD,aAAa,CAAC,EAAE,CACd,KAAK,EAAE,eAAe,KACnB,IAAI,GAAG,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAAC;IAG5C,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,KAAK,CAAC,aAAa,CAAC;IAC5B,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,6BAA6B;IAC5C,WAAW,EAAE,CAAC,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC;IAC9E,gBAAgB,EAAE,CAChB,KAAK,EAAE,OAAO,CAAC,eAAe,CAAC,GAAG;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,KAChD,OAAO,CAAC;IACb,WAAW,EAAE,CACX,EAAE,EAAE,MAAM,GAAG,MAAM,EACnB,OAAO,EAAE,OAAO,CAAC,aAAa,CAAC,KAC5B,OAAO,CAAC;IACb,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,OAAO,CAAC;IAC9C,WAAW,EAAE,CAAC,EAAE,EAAE,MAAM,GAAG,MAAM,KAAK,IAAI,CAAC;IAC3C,SAAS,EAAE,MAAM,IAAI,CAAC;IACtB,aAAa,EAAE,MAAM,IAAI,CAAC;IAC1B,SAAS,EAAE,MAAM,aAAa,EAAE,CAAC;IACjC,cAAc,EAAE,CAAC,OAAO,CAAC,EAAE;QAAE,QAAQ,CAAC,EAAE,MAAM,CAAA;KAAE,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;CACpE"}
|