@superdoc-dev/template-builder 1.0.0 → 1.0.1-next.1
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/defaults/FieldList.d.ts +2 -3
- package/dist/defaults/FieldMenu.d.ts +0 -1
- package/dist/defaults/index.d.ts +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +1 -1
- package/dist/index.mjs +381 -404
- package/dist/test/setup.d.ts +0 -0
- package/dist/types.d.ts +0 -1
- package/package.json +27 -46
- package/dist/defaults/FieldList.d.ts.map +0 -1
- package/dist/defaults/FieldMenu.d.ts.map +0 -1
- package/dist/defaults/index.d.ts.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/types.d.ts.map +0 -1
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { FC } from 'react';
|
|
2
2
|
import { FieldListProps } from '../types';
|
|
3
|
-
export declare const FieldList:
|
|
4
|
-
//# sourceMappingURL=FieldList.d.ts.map
|
|
3
|
+
export declare const FieldList: FC<FieldListProps>;
|
package/dist/defaults/index.d.ts
CHANGED
package/dist/index.d.ts
CHANGED
|
@@ -4,4 +4,3 @@ export * from './types';
|
|
|
4
4
|
export { FieldMenu, FieldList };
|
|
5
5
|
declare const SuperDocTemplateBuilder: import('react').ForwardRefExoticComponent<Types.SuperDocTemplateBuilderProps & import('react').RefAttributes<Types.SuperDocTemplateBuilderHandle>>;
|
|
6
6
|
export default SuperDocTemplateBuilder;
|
|
7
|
-
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";var Ne=Object.create;var ge=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(n,o,d,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of Be(o))!Le.call(n,l)&&l!==d&&ge(n,l,{get:()=>o[l],enumerable:!(i=ze(o,l))||i.enumerable});return n};var Pe=(n,o,d)=>(d=n!=null?Ne(We(n)):{},He(o||!n||!n.__esModule?ge(d,"default",{value:n,enumerable:!0}):d,n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),s=require("react"),ye=({isVisible:n,position:o,availableFields:d,filteredFields:i,filterQuery:l,allowCreate:c,onSelect:R,onClose:W,onCreateField:V,existingFields:x=[],onSelectExisting:w})=>{const[m,y]=s.useState(!1),[k,E]=s.useState(""),[_,L]=s.useState("inline"),[q,te]=s.useState(!0),[p,D]=s.useState(!0);s.useEffect(()=>{n||(y(!1),E(""),L("inline"))},[n]);const H=s.useMemo(()=>({position:"absolute",left:o?.left,top:o?.top,zIndex:1e3,background:"white",border:"1px solid #ddd",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"8px 0",width:"280px"}),[o]),O=i??d,P=!!l;if(s.useEffect(()=>{P&&D(!0)},[P]),!n)return null;const M=async()=>{const h=k.trim();if(!h)return;const N={id:`custom_${Date.now()}`,label:h,mode:_};try{if(V){const b=await V(N);R(b||N)}else R(N)}finally{y(!1),E(""),L("inline")}};return t.jsxs("div",{className:"superdoc-field-menu",style:H,children:[P&&t.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid #f0f0f0",marginBottom:"4px"},children:t.jsxs("div",{style:{fontSize:"12px",color:"#6b7280"},children:["Filtering results for",t.jsx("span",{style:{fontWeight:600,color:"#111827",marginLeft:"4px"},children:l})]})}),c&&!m&&t.jsx("div",{className:"field-menu-item",onClick:()=>y(!0),style:{padding:"8px 16px",cursor:"pointer",color:"#0066cc",fontWeight:500},children:"+ Create New Field"}),c&&m&&t.jsxs("div",{style:{padding:"8px 16px"},children:[t.jsx("input",{type:"text",value:k,placeholder:"Field name...",onChange:h=>E(h.target.value),onKeyDown:h=>{h.key==="Enter"&&M(),h.key==="Escape"&&(y(!1),E(""),L("inline"))},autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid #ddd",borderRadius:"3px"}}),t.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"12px",fontSize:"13px"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},children:[t.jsx("input",{type:"radio",value:"inline",checked:_==="inline",onChange:()=>L("inline")}),"Inline"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},children:[t.jsx("input",{type:"radio",value:"block",checked:_==="block",onChange:()=>L("block")}),"Block"]})]}),t.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px"},children:[t.jsx("button",{onClick:M,disabled:!k.trim(),style:{padding:"4px 12px",background:k.trim()?"#0066cc":"#ccc",color:"white",border:"none",borderRadius:"3px",cursor:k.trim()?"pointer":"not-allowed"},children:"Create"}),t.jsx("button",{onClick:()=>{y(!1),E(""),L("inline")},style:{padding:"4px 12px",background:"white",border:"1px solid #ddd",borderRadius:"3px",cursor:"pointer"},children:"Cancel"})]})]}),c&&d.length>0&&t.jsx("div",{style:{borderTop:"1px solid #eee",margin:"4px 0"}}),x.length>0&&(()=>{const h=new Map;x.forEach(b=>{const J=b.group||`individual-${b.id}`,Y=h.get(J)||[];Y.push(b),h.set(J,Y)});const N=Array.from(h.values()).map(b=>({...b[0],count:b.length}));return t.jsxs("div",{style:{borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("button",{type:"button",onClick:()=>te(!q),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,fontSize:"13px",color:"#374151",textAlign:"left"},children:[t.jsxs("span",{children:["Existing Fields (",N.length,")"]}),t.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:q?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease"}})]}),q&&t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:N.map(b=>t.jsxs("div",{className:"field-menu-item",onClick:()=>w?.(b),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:b.alias||b.id}),t.jsx("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:b.group?`group (${b.count} fields)`:`ID: ${b.id}`})]}),t.jsx("span",{style:{fontSize:"11px",color:"#6b7280",padding:"2px 6px",background:"#f3f4f6",borderRadius:"3px",textTransform:"capitalize",flexShrink:0},children:b.mode||"inline"})]},b.group||b.id))})]})})(),O.length===0?t.jsx("div",{style:{padding:"16px",fontSize:"13px",color:"#6b7280",textAlign:"center"},children:"No matching fields"}):t.jsxs("div",{style:{borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("button",{type:"button",onClick:()=>D(!p),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,fontSize:"13px",color:"#374151",textAlign:"left"},children:[t.jsxs("span",{children:["Available Fields (",O.length,")"]}),t.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:p?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease"}})]}),p&&t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:O.map(h=>t.jsxs("div",{className:"field-menu-item",onClick:()=>R(h),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:h.label||h.id}),t.jsxs("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:["ID: ",h.id]})]}),t.jsx("span",{style:{fontSize:"11px",color:"#6b7280",padding:"2px 6px",background:"#f3f4f6",borderRadius:"3px",textTransform:"capitalize",flexShrink:0},children:h.mode||"inline"})]},h.id))})]}),t.jsx("div",{style:{borderTop:"1px solid #eee",marginTop:"4px"},children:t.jsx("button",{onClick:W,style:{width:"100%",padding:"6px 16px",background:"#f3f4f6",border:"none",borderRadius:"0 0 4px 4px",cursor:"pointer"},children:"Close"})})]})},Ae=n=>{const o=n.split("-");return o.length>2?o[o.length-1].substring(0,6):n.substring(0,6)},me=({field:n,onSelect:o,onDelete:d,isSelected:i,isGrouped:l=!1})=>t.jsxs("div",{onClick:()=>o(n),style:{position:"relative",padding:"10px 12px",background:i?"#eff6ff":"#f9fafb",border:i?"1px solid #3b82f6":"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s",fontSize:l?"13px":"14px"},onMouseEnter:c=>{i||(c.currentTarget.style.background="#f3f4f6")},onMouseLeave:c=>{i||(c.currentTarget.style.background="#f9fafb")},title:n.alias,children:[t.jsx("button",{onClick:c=>{c.stopPropagation(),d(n.id)},style:{position:"absolute",top:"6px",right:"6px",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:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.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"})})}),t.jsxs("div",{style:{paddingRight:"24px"},children:[t.jsx("div",{style:{fontWeight:"500",fontSize:l?"12px":"14px",color:l?"#6b7280":"#111827"},children:n.alias||n.id}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:[t.jsxs("span",{children:["ID: ",n.id]}),n.mode&&t.jsx("span",{style:{fontSize:"9px",padding:"2px 5px",borderRadius:"3px",background:n.mode==="block"?"#dbeafe":"#f3f4f6",color:n.mode==="block"?"#1e40af":"#4b5563",fontWeight:"500"},children:n.mode})]})]})]}),ve=({fields:n,onSelect:o,onDelete:d,selectedFieldId:i})=>{const[l,c]=s.useState(new Set),{groupedFields:R,ungroupedFields:W}=s.useMemo(()=>{const x={},w=[];return n.forEach(m=>{m.group?(x[m.group]||(x[m.group]=[]),x[m.group].push(m)):w.push(m)}),{groupedFields:x,ungroupedFields:w}},[n]),V=x=>{c(w=>{const m=new Set(w);return m.has(x)?m.delete(x):m.add(x),m})};return t.jsxs("div",{className:"superdoc-field-list",style:{width:"250px",background:"white",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px"},children:[t.jsxs("h3",{style:{margin:"0 0 16px 0",fontSize:"16px",fontWeight:"600"},children:["Template Fields (",n.length,")"]}),n.length===0?t.jsxs("div",{style:{color:"#9ca3af",fontSize:"14px",textAlign:"center",padding:"20px 0"},children:["No fields yet. Type ","{{"," to add a field."]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[W.map(x=>t.jsx(me,{field:x,onSelect:o,onDelete:d,isSelected:i===x.id},x.id)),Object.entries(R).map(([x,w])=>{const m=l.has(x),y=w[0];return t.jsxs("div",{children:[t.jsx("div",{style:{position:"relative",padding:"12px",background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s"},onClick:()=>V(x),onMouseEnter:k=>{k.currentTarget.style.background="#f3f4f6"},onMouseLeave:k=>{k.currentTarget.style.background="#f9fafb"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:m?"▼":"▶"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:"500",fontSize:"14px"},children:y.alias}),t.jsxs("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:["group: ",Ae(x)," (",w.length," fields)"]})]})]})}),m&&t.jsx("div",{style:{marginLeft:"16px",marginTop:"4px",display:"flex",flexDirection:"column",gap:"4px"},children:w.map(k=>t.jsx(me,{field:k,onSelect:o,onDelete:d,isSelected:i===k.id,isGrouped:!0},k.id))})]},x)})]})]})},U=n=>{const o=n.helpers?.structuredContentCommands;return o?.getStructuredContentTags?(o.getStructuredContentTags(n.state)||[]).map(i=>{const l=i?.node??i,c=l?.attrs??{},W=(l?.type?.name||"").includes("Block")?"block":"inline";return{id:c.id,alias:c.alias||c.label||"",tag:c.tag,mode:W,group:o.getGroup?.(c.tag)??void 0}}):[]},he=(n,o)=>{if(n===o)return!0;if(n.length!==o.length)return!1;for(let d=0;d<n.length;d+=1){const i=n[d],l=o[d];if(!l||i.id!==l.id||i.alias!==l.alias||i.tag!==l.tag||i.position!==l.position||i.mode!==l.mode||i.group!==l.group)return!1}return!0},Ve=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:o,...d}=n;return{selector:o||"#superdoc-toolbar",config:d,renderDefaultContainer:o===void 0}},ee=10,Oe=250,Ge=300,be=n=>{const o=window.innerWidth-Oe-ee,d=window.innerHeight-Ge-ee,i=Math.min(n.left,o),l=Math.min(n.top,d);return new DOMRect(Math.max(i,ee),Math.max(l,ee),n.width,n.height)},je=s.forwardRef((n,o)=>{const{document:d,fields:i={},menu:l={},list:c={},toolbar:R,onReady:W,onTrigger:V,onFieldInsert:x,onFieldUpdate:w,onFieldDelete:m,onFieldsChange:y,onFieldSelect:k,onFieldCreate:E,onExport:_,className:L,style:q,documentHeight:te="600px"}=n,[p,D]=s.useState(i.initial||[]),[H,O]=s.useState(null),[P,M]=s.useState(!1),[h,N]=s.useState(),[b,J]=s.useState(""),[Y,Ce]=s.useState(()=>i.available||[]),ne=s.useRef(null),F=s.useRef(null),T=s.useRef(null),ae=s.useRef(i);ae.current=i;const z=s.useRef(null),de=s.useRef(P);s.useEffect(()=>{de.current=P},[P]);const K=l.trigger||"{{",re=ae.current.available||[],A=s.useMemo(()=>Ve(R),[R]),ce=s.useCallback(e=>{const r=e.trim().toLowerCase();return r?re.filter(a=>a.label.toLowerCase().includes(r)):re},[re]),se=s.useCallback(e=>{J(e),Ce(ce(e))},[ce]),B=s.useCallback(()=>{se("")},[se]),Q=s.useCallback((e,r)=>{if(!F.current?.activeEditor)return!1;const a=F.current.activeEditor,v=p,C=e==="inline"?a.commands.insertStructuredContentInline?.({attrs:{alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):void 0},text:r.defaultValue||r.alias}):a.commands.insertStructuredContentBlock?.({attrs:{alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):void 0},text:r.defaultValue||r.alias});if(C){const f=U(a);D(f),y?.(f);const S=f.find(j=>!v.some(u=>u.id===j.id));S&&x?.(S)}return C??!1},[x,y,p]),X=s.useCallback((e,r)=>{if(!F.current?.activeEditor)return!1;const v=F.current.activeEditor.commands.updateStructuredContentById?.(e,{attrs:r});return v&&D(C=>{const f=C.map(j=>j.id===e?{...j,...r}:j);y?.(f);const S=f.find(j=>j.id===e);return S&&w?.(S),f}),v??!1},[w,y]),oe=s.useCallback(e=>{const r=F.current?.activeEditor;if(!r){let u=!1;return D(g=>{if(!g.some(I=>I.id===e))return g;const $=g.filter(I=>I.id!==e);return u=!0,y?.($),m?.(e),$}),u&&O(g=>g===e?null:g),u}const v=p.find(u=>u.id===e)?.group;let C=!1;try{C=r.commands.deleteStructuredContentById?.(e)??!1}catch{C=!1}let f=U(r);const S=f.some(u=>u.id===e);if(!C&&S&&(f=f.filter(u=>u.id!==e)),v){const u=f.filter(g=>g.group===v);if(u.length===1){const g=u[0];r.commands.updateStructuredContentById?.(g.id,{attrs:{tag:void 0}}),f=U(r)}}let j=!1;return D(u=>{if(he(u,f))return u;const g=u.some(I=>I.id===e),$=f.some(I=>I.id===e);return g&&!$&&(j=!0),y?.(f),j&&m?.(e),f}),j&&O(u=>u===e?null:u),C||j},[m,y,p]),G=s.useCallback(e=>{if(!F.current?.activeEditor)return;F.current.activeEditor.commands.selectStructuredContentById?.(e),O(e);const a=p.find(v=>v.id===e);a&&k?.(a)},[p,k]),ie=s.useCallback(e=>{if(!e)return;const r=U(e);D(a=>he(a,r)?a:(y?.(r),r))},[y]);s.useEffect(()=>{if(!ne.current)return;let e=!1,r=null;return(async()=>{const{SuperDoc:v}=await import("superdoc");if(e)return;const C={comments:!1,...A&&{toolbar:{selector:A.selector,toolbarGroups:A.config.toolbarGroups||["center"],excludeItems:A.config.excludeItems||[],...A.config}}},f=()=>{if(!e){if(r?.activeEditor){const S=r.activeEditor;S.on("update",({editor:j})=>{const{state:u}=j,{from:g}=u.selection;if(g>=K.length){const le=g-K.length;if(u.doc.textBetween(le,g)===K){const pe=j.view.coordsAtPos(g),xe=be(new DOMRect(pe.left,pe.top,0,0)),fe=()=>{const Z=F.current?.activeEditor;if(!Z)return;const Re=Z.state.selection.from,De=Z.state.tr.delete(le,Re);Z.view.dispatch(De)};T.current=fe,z.current=g,N(xe),M(!0),B(),V?.({position:{from:le,to:g},bounds:xe,cleanup:fe});return}}if(!de.current)return;if(z.current==null){M(!1),B();return}if(g<z.current){M(!1),z.current=null,B();return}const $=u.doc.textBetween(z.current,g);se($);const I=j.view.coordsAtPos(g),Ie=be(new DOMRect(I.left,I.top,0,0));N(Ie)}),S.on("update",()=>{ie(S)}),ie(S)}W?.()}};r=new v({selector:ne.current,document:d?.source,documentMode:d?.mode||"editing",modules:C,toolbar:A?.selector,onReady:f}),F.current=r})(),()=>{e=!0,T.current=null,z.current=null,r&&typeof r.destroy=="function"&&r.destroy(),F.current=null}},[d?.source,d?.mode,K,ie,W,V,A]);const ke=s.useCallback(async e=>{T.current&&(T.current(),T.current=null),z.current=null,B();const r=e.mode||"inline";if(e.id.startsWith("custom_")&&E){const a=await E(e);if(a){const v=a.mode||r;Q(v,{alias:a.label,metadata:a.metadata,defaultValue:a.defaultValue}),M(!1);return}}Q(r,{alias:e.label,metadata:e.metadata,defaultValue:e.defaultValue}),M(!1)},[Q,E,B]),Fe=s.useCallback(e=>{T.current&&(T.current(),T.current=null),z.current=null,B();const r=F.current?.activeEditor;if(!r)return;const a=r.helpers?.structuredContentCommands;if(!a)return;const v=e.group||`group-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,C=a.createTagObject?.({group:v});if((e.mode||"inline")==="inline"?r.commands.insertStructuredContentInline?.({attrs:{alias:e.alias,tag:C},text:e.alias}):r.commands.insertStructuredContentBlock?.({attrs:{alias:e.alias,tag:C},text:e.alias})){e.group||X(e.id,{tag:C}),M(!1);const j=U(r);D(j),y?.(j)}},[X,B,y]),Se=s.useCallback(()=>{M(!1),z.current=null,B(),T.current&&(T.current(),T.current=null)},[B]),we=s.useCallback(()=>{if(!F.current?.activeEditor||p.length===0)return;const e=p.findIndex(a=>a.id===H),r=e>=0?(e+1)%p.length:0;G(p[r].id)},[p,H,G]),Te=s.useCallback(()=>{if(!F.current?.activeEditor||p.length===0)return;const e=p.findIndex(a=>a.id===H),r=e>0?e-1:p.length-1;G(p[r].id)},[p,H,G]),Ee=s.useCallback(async e=>{const{fileName:r="document",triggerDownload:a=!0}=e||{},v=await F.current?.export({exportType:["docx"],exportedName:r,triggerDownload:a}),C=F.current?.activeEditor;if(C){const f=U(C);_?.({fields:f,blob:a?void 0:v,fileName:r})}return v},[_]);s.useImperativeHandle(o,()=>({insertField:e=>Q("inline",e),insertBlockField:e=>Q("block",e),updateField:X,deleteField:oe,selectField:G,nextField:we,previousField:Te,getFields:()=>p,exportTemplate:Ee,getSuperDoc:()=>F.current}));const Me=l.component||ye,ue=c.component||ve;return t.jsxs("div",{className:`superdoc-template-builder ${L||""}`,style:q,children:[t.jsxs("div",{style:{display:"flex",gap:"20px"},children:[c.position==="left"&&t.jsx("div",{className:"superdoc-template-builder-sidebar",children:t.jsx(ue,{fields:p,onSelect:e=>G(e.id),onDelete:oe,onUpdate:e=>X(e.id,e),selectedFieldId:H||void 0})}),t.jsxs("div",{className:"superdoc-template-builder-document",style:{flex:1},children:[A?.renderDefaultContainer&&t.jsx("div",{id:"superdoc-toolbar",className:"superdoc-template-builder-toolbar","data-testid":"template-builder-toolbar"}),t.jsx("div",{ref:ne,className:"superdoc-template-builder-editor",style:{height:te},"data-testid":"template-builder-editor"})]}),c.position==="right"&&t.jsx("div",{className:"superdoc-template-builder-sidebar",children:t.jsx(ue,{fields:p,onSelect:e=>G(e.id),onDelete:oe,onUpdate:e=>X(e.id,e),selectedFieldId:H||void 0})})]}),t.jsx(Me,{isVisible:P,position:h,availableFields:i.available||[],filteredFields:Y,filterQuery:b,allowCreate:i.allowCreate||!1,onSelect:ke,onClose:Se,onCreateField:E,existingFields:p,onSelectExisting:Fe})]})});je.displayName="SuperDocTemplateBuilder";exports.FieldList=ve;exports.FieldMenu=ye;exports.default=je;
|
|
1
|
+
"use strict";var Ne=Object.create;var ge=Object.defineProperty;var ze=Object.getOwnPropertyDescriptor;var Be=Object.getOwnPropertyNames;var We=Object.getPrototypeOf,Le=Object.prototype.hasOwnProperty;var He=(n,o,d,i)=>{if(o&&typeof o=="object"||typeof o=="function")for(let l of Be(o))!Le.call(n,l)&&l!==d&&ge(n,l,{get:()=>o[l],enumerable:!(i=ze(o,l))||i.enumerable});return n};var Pe=(n,o,d)=>(d=n!=null?Ne(We(n)):{},He(o||!n||!n.__esModule?ge(d,"default",{value:n,enumerable:!0}):d,n));Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:"Module"}});const t=require("react/jsx-runtime"),s=require("react"),ye=({isVisible:n,position:o,availableFields:d,filteredFields:i,filterQuery:l,allowCreate:u,onSelect:R,onClose:W,onCreateField:V,existingFields:x=[],onSelectExisting:w})=>{const[m,y]=s.useState(!1),[F,E]=s.useState(""),[_,L]=s.useState("inline"),[q,te]=s.useState(!0),[p,D]=s.useState(!0);s.useEffect(()=>{n||(y(!1),E(""),L("inline"))},[n]);const H=s.useMemo(()=>({position:"absolute",left:o?.left,top:o?.top,zIndex:1e3,background:"white",border:"1px solid #ddd",borderRadius:"4px",boxShadow:"0 2px 8px rgba(0,0,0,0.1)",padding:"8px 0",width:"280px"}),[o]),O=i??d,P=!!l;if(s.useEffect(()=>{P&&D(!0)},[P]),!n)return null;const M=async()=>{const h=F.trim();if(!h)return;const N={id:`custom_${Date.now()}`,label:h,mode:_};try{if(V){const b=await V(N);R(b||N)}else R(N)}finally{y(!1),E(""),L("inline")}};return t.jsxs("div",{className:"superdoc-field-menu",style:H,children:[P&&t.jsx("div",{style:{padding:"8px 16px",borderBottom:"1px solid #f0f0f0",marginBottom:"4px"},children:t.jsxs("div",{style:{fontSize:"12px",color:"#6b7280"},children:["Filtering results for",t.jsx("span",{style:{fontWeight:600,color:"#111827",marginLeft:"4px"},children:l})]})}),u&&!m&&t.jsx("div",{className:"field-menu-item",onClick:()=>y(!0),style:{padding:"8px 16px",cursor:"pointer",color:"#0066cc",fontWeight:500},children:"+ Create New Field"}),u&&m&&t.jsxs("div",{style:{padding:"8px 16px"},children:[t.jsx("input",{type:"text",value:F,placeholder:"Field name...",onChange:h=>E(h.target.value),onKeyDown:h=>{h.key==="Enter"&&M(),h.key==="Escape"&&(y(!1),E(""),L("inline"))},autoFocus:!0,style:{width:"100%",padding:"4px 8px",border:"1px solid #ddd",borderRadius:"3px"}}),t.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"12px",fontSize:"13px"},children:[t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},children:[t.jsx("input",{type:"radio",value:"inline",checked:_==="inline",onChange:()=>L("inline")}),"Inline"]}),t.jsxs("label",{style:{display:"flex",alignItems:"center",gap:"4px",cursor:"pointer"},children:[t.jsx("input",{type:"radio",value:"block",checked:_==="block",onChange:()=>L("block")}),"Block"]})]}),t.jsxs("div",{style:{marginTop:"8px",display:"flex",gap:"8px"},children:[t.jsx("button",{onClick:M,disabled:!F.trim(),style:{padding:"4px 12px",background:F.trim()?"#0066cc":"#ccc",color:"white",border:"none",borderRadius:"3px",cursor:F.trim()?"pointer":"not-allowed"},children:"Create"}),t.jsx("button",{onClick:()=>{y(!1),E(""),L("inline")},style:{padding:"4px 12px",background:"white",border:"1px solid #ddd",borderRadius:"3px",cursor:"pointer"},children:"Cancel"})]})]}),u&&d.length>0&&t.jsx("div",{style:{borderTop:"1px solid #eee",margin:"4px 0"}}),x.length>0&&(()=>{const h=new Map;x.forEach(b=>{const J=b.group||`individual-${b.id}`,Y=h.get(J)||[];Y.push(b),h.set(J,Y)});const N=Array.from(h.values()).map(b=>({...b[0],count:b.length}));return t.jsxs("div",{style:{borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("button",{type:"button",onClick:()=>te(!q),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,fontSize:"13px",color:"#374151",textAlign:"left"},children:[t.jsxs("span",{children:["Existing Fields (",N.length,")"]}),t.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:q?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease"}})]}),q&&t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:N.map(b=>t.jsxs("div",{className:"field-menu-item",onClick:()=>w?.(b),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:b.alias||b.id}),t.jsx("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:b.group?`group (${b.count} fields)`:`ID: ${b.id}`})]}),t.jsx("span",{style:{fontSize:"11px",color:"#6b7280",padding:"2px 6px",background:"#f3f4f6",borderRadius:"3px",textTransform:"capitalize",flexShrink:0},children:b.mode||"inline"})]},b.group||b.id))})]})})(),O.length===0?t.jsx("div",{style:{padding:"16px",fontSize:"13px",color:"#6b7280",textAlign:"center"},children:"No matching fields"}):t.jsxs("div",{style:{borderBottom:"1px solid #f0f0f0"},children:[t.jsxs("button",{type:"button",onClick:()=>D(!p),style:{width:"100%",display:"flex",alignItems:"center",justifyContent:"space-between",padding:"8px 16px",background:"transparent",border:"none",cursor:"pointer",fontWeight:500,fontSize:"13px",color:"#374151",textAlign:"left"},children:[t.jsxs("span",{children:["Available Fields (",O.length,")"]}),t.jsx("span",{"aria-hidden":!0,style:{display:"inline-block",width:"8px",height:"8px",borderRight:"2px solid #666",borderBottom:"2px solid #666",transform:p?"rotate(45deg)":"rotate(-45deg)",transition:"transform 0.2s ease"}})]}),p&&t.jsx("div",{style:{maxHeight:"300px",overflowY:"auto"},children:O.map(h=>t.jsxs("div",{className:"field-menu-item",onClick:()=>R(h),style:{padding:"8px 16px",cursor:"pointer",display:"flex",alignItems:"flex-start",justifyContent:"space-between",gap:"8px"},children:[t.jsxs("div",{style:{flex:1,minWidth:0},children:[t.jsx("div",{style:{fontWeight:500,fontSize:"13px"},children:h.label||h.id}),t.jsxs("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:["ID: ",h.id]})]}),t.jsx("span",{style:{fontSize:"11px",color:"#6b7280",padding:"2px 6px",background:"#f3f4f6",borderRadius:"3px",textTransform:"capitalize",flexShrink:0},children:h.mode||"inline"})]},h.id))})]}),t.jsx("div",{style:{borderTop:"1px solid #eee",marginTop:"4px"},children:t.jsx("button",{onClick:W,style:{width:"100%",padding:"6px 16px",background:"#f3f4f6",border:"none",borderRadius:"0 0 4px 4px",cursor:"pointer"},children:"Close"})})]})},Ae=n=>{const o=n.split("-");return o.length>2?o[o.length-1].substring(0,6):n.substring(0,6)},me=({field:n,onSelect:o,onDelete:d,isSelected:i,isGrouped:l=!1})=>t.jsxs("div",{onClick:()=>o(n),style:{position:"relative",padding:"10px 12px",background:i?"#eff6ff":"#f9fafb",border:i?"1px solid #3b82f6":"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s",fontSize:l?"13px":"14px"},onMouseEnter:u=>{i||(u.currentTarget.style.background="#f3f4f6")},onMouseLeave:u=>{i||(u.currentTarget.style.background="#f9fafb")},title:n.alias,children:[t.jsx("button",{onClick:u=>{u.stopPropagation(),d(n.id)},style:{position:"absolute",top:"6px",right:"6px",padding:"4px",background:"transparent",border:"none",cursor:"pointer",color:"#9ca3af",transition:"color 0.2s",display:"flex",alignItems:"center",justifyContent:"center"},onMouseEnter:u=>{u.currentTarget.style.color="#ef4444"},onMouseLeave:u=>{u.currentTarget.style.color="#9ca3af"},title:"Delete field",children:t.jsx("svg",{width:"14",height:"14",viewBox:"0 0 16 16",fill:"none",xmlns:"http://www.w3.org/2000/svg",children:t.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"})})}),t.jsxs("div",{style:{paddingRight:"24px"},children:[t.jsx("div",{style:{fontWeight:"500",fontSize:l?"12px":"14px",color:l?"#6b7280":"#111827"},children:n.alias||n.id}),t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"6px",fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:[t.jsxs("span",{children:["ID: ",n.id]}),n.mode&&t.jsx("span",{style:{fontSize:"9px",padding:"2px 5px",borderRadius:"3px",background:n.mode==="block"?"#dbeafe":"#f3f4f6",color:n.mode==="block"?"#1e40af":"#4b5563",fontWeight:"500"},children:n.mode})]})]})]}),ve=({fields:n,onSelect:o,onDelete:d,selectedFieldId:i})=>{const[l,u]=s.useState(new Set),{groupedFields:R,ungroupedFields:W}=s.useMemo(()=>{const x={},w=[];return n.forEach(m=>{m.group?(x[m.group]||(x[m.group]=[]),x[m.group].push(m)):w.push(m)}),{groupedFields:x,ungroupedFields:w}},[n]),V=x=>{u(w=>{const m=new Set(w);return m.has(x)?m.delete(x):m.add(x),m})};return t.jsxs("div",{className:"superdoc-field-list",style:{width:"250px",background:"white",border:"1px solid #e5e7eb",borderRadius:"8px",padding:"16px"},children:[t.jsxs("h3",{style:{margin:"0 0 16px 0",fontSize:"16px",fontWeight:"600"},children:["Template Fields (",n.length,")"]}),n.length===0?t.jsxs("div",{style:{color:"#9ca3af",fontSize:"14px",textAlign:"center",padding:"20px 0"},children:["No fields yet. Type ","{{"," to add a field."]}):t.jsxs("div",{style:{display:"flex",flexDirection:"column",gap:"8px"},children:[W.map(x=>t.jsx(me,{field:x,onSelect:o,onDelete:d,isSelected:i===x.id},x.id)),Object.entries(R).map(([x,w])=>{const m=l.has(x),y=w[0];return t.jsxs("div",{children:[t.jsx("div",{style:{position:"relative",padding:"12px",background:"#f9fafb",border:"1px solid #e5e7eb",borderRadius:"6px",cursor:"pointer",transition:"all 0.2s"},onClick:()=>V(x),onMouseEnter:F=>{F.currentTarget.style.background="#f3f4f6"},onMouseLeave:F=>{F.currentTarget.style.background="#f9fafb"},children:t.jsxs("div",{style:{display:"flex",alignItems:"center",gap:"8px"},children:[t.jsx("span",{style:{fontSize:"12px",color:"#6b7280"},children:m?"▼":"▶"}),t.jsxs("div",{style:{flex:1},children:[t.jsx("div",{style:{fontWeight:"500",fontSize:"14px"},children:y.alias}),t.jsxs("div",{style:{fontSize:"11px",color:"#9ca3af",marginTop:"2px"},children:["group: ",Ae(x)," (",w.length," fields)"]})]})]})}),m&&t.jsx("div",{style:{marginLeft:"16px",marginTop:"4px",display:"flex",flexDirection:"column",gap:"4px"},children:w.map(F=>t.jsx(me,{field:F,onSelect:o,onDelete:d,isSelected:i===F.id,isGrouped:!0},F.id))})]},x)})]})]})},U=n=>{const o=n.helpers?.structuredContentCommands;return o?.getStructuredContentTags?(o.getStructuredContentTags(n.state)||[]).map(i=>{const l=i?.node??i,u=l?.attrs??{},W=(l?.type?.name||"").includes("Block")?"block":"inline";return{id:u.id,alias:u.alias||u.label||"",tag:u.tag,mode:W,group:o.getGroup?.(u.tag)??void 0}}):[]},he=(n,o)=>{if(n===o)return!0;if(n.length!==o.length)return!1;for(let d=0;d<n.length;d+=1){const i=n[d],l=o[d];if(!l||i.id!==l.id||i.alias!==l.alias||i.tag!==l.tag||i.position!==l.position||i.mode!==l.mode||i.group!==l.group)return!1}return!0},Ve=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:o,...d}=n;return{selector:o||"#superdoc-toolbar",config:d,renderDefaultContainer:o===void 0}},ee=10,Oe=250,Ge=300,be=n=>{const o=window.innerWidth-Oe-ee,d=window.innerHeight-Ge-ee,i=Math.min(n.left,o),l=Math.min(n.top,d);return new DOMRect(Math.max(i,ee),Math.max(l,ee),n.width,n.height)},je=s.forwardRef((n,o)=>{const{document:d,fields:i={},menu:l={},list:u={},toolbar:R,onReady:W,onTrigger:V,onFieldInsert:x,onFieldUpdate:w,onFieldDelete:m,onFieldsChange:y,onFieldSelect:F,onFieldCreate:E,onExport:_,className:L,style:q,documentHeight:te="600px"}=n,[p,D]=s.useState(i.initial||[]),[H,O]=s.useState(null),[P,M]=s.useState(!1),[h,N]=s.useState(),[b,J]=s.useState(""),[Y,Ce]=s.useState(()=>i.available||[]),ne=s.useRef(null),k=s.useRef(null),T=s.useRef(null),ae=s.useRef(i);ae.current=i;const z=s.useRef(null),de=s.useRef(P);s.useEffect(()=>{de.current=P},[P]);const K=l.trigger||"{{",re=ae.current.available||[],A=s.useMemo(()=>Ve(R),[R]),ce=s.useCallback(e=>{const r=e.trim().toLowerCase();return r?re.filter(a=>a.label.toLowerCase().includes(r)):re},[re]),se=s.useCallback(e=>{J(e),Ce(ce(e))},[ce]),B=s.useCallback(()=>{se("")},[se]),Q=s.useCallback((e,r)=>{if(!k.current?.activeEditor)return!1;const a=k.current.activeEditor,v=p,C=e==="inline"?a.commands.insertStructuredContentInline?.({attrs:{alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):void 0},text:r.defaultValue||r.alias}):a.commands.insertStructuredContentBlock?.({attrs:{alias:r.alias,tag:r.metadata?JSON.stringify(r.metadata):void 0},text:r.defaultValue||r.alias});if(C){const f=U(a);D(f),y?.(f);const S=f.find(j=>!v.some(c=>c.id===j.id));S&&x?.(S)}return C??!1},[x,y,p]),X=s.useCallback((e,r)=>{if(!k.current?.activeEditor)return!1;const v=k.current.activeEditor.commands.updateStructuredContentById?.(e,{attrs:r});return v&&D(C=>{const f=C.map(j=>j.id===e?{...j,...r}:j);y?.(f);const S=f.find(j=>j.id===e);return S&&w?.(S),f}),v??!1},[w,y]),oe=s.useCallback(e=>{const r=k.current?.activeEditor;if(!r){let c=!1;return D(g=>{if(!g.some(I=>I.id===e))return g;const $=g.filter(I=>I.id!==e);return c=!0,y?.($),m?.(e),$}),c&&O(g=>g===e?null:g),c}const v=p.find(c=>c.id===e)?.group;let C=!1;try{C=r.commands.deleteStructuredContentById?.(e)??!1}catch(c){console.warn("[TemplateBuilder] Failed to delete structured content:",e,c),C=!1}let f=U(r);const S=f.some(c=>c.id===e);if(!C&&S&&(f=f.filter(c=>c.id!==e)),v){const c=f.filter(g=>g.group===v);if(c.length===1){const g=c[0];r.commands.updateStructuredContentById?.(g.id,{attrs:{tag:void 0}}),f=U(r)}}let j=!1;return D(c=>{if(he(c,f))return c;const g=c.some(I=>I.id===e),$=f.some(I=>I.id===e);return g&&!$&&(j=!0),y?.(f),j&&m?.(e),f}),j&&O(c=>c===e?null:c),C||j},[m,y,p]),G=s.useCallback(e=>{if(!k.current?.activeEditor)return;k.current.activeEditor.commands.selectStructuredContentById?.(e),O(e);const a=p.find(v=>v.id===e);a&&F?.(a)},[p,F]),ie=s.useCallback(e=>{if(!e)return;const r=U(e);D(a=>he(a,r)?a:(y?.(r),r))},[y]);s.useEffect(()=>{if(!ne.current)return;let e=!1,r=null;return(async()=>{const{SuperDoc:v}=await import("superdoc");if(e)return;const C={comments:!1,...A&&{toolbar:{selector:A.selector,toolbarGroups:A.config.toolbarGroups||["center"],excludeItems:A.config.excludeItems||[],...A.config}}},f=()=>{if(!e){if(r?.activeEditor){const S=r.activeEditor;S.on("update",({editor:j})=>{const{state:c}=j,{from:g}=c.selection;if(g>=K.length){const le=g-K.length;if(c.doc.textBetween(le,g)===K){const pe=j.view.coordsAtPos(g),xe=be(new DOMRect(pe.left,pe.top,0,0)),fe=()=>{const Z=k.current?.activeEditor;if(!Z)return;const Re=Z.state.selection.from,De=Z.state.tr.delete(le,Re);Z.view.dispatch(De)};T.current=fe,z.current=g,N(xe),M(!0),B(),V?.({position:{from:le,to:g},bounds:xe,cleanup:fe});return}}if(!de.current)return;if(z.current==null){M(!1),B();return}if(g<z.current){M(!1),z.current=null,B();return}const $=c.doc.textBetween(z.current,g);se($);const I=j.view.coordsAtPos(g),Ie=be(new DOMRect(I.left,I.top,0,0));N(Ie)}),S.on("update",()=>{ie(S)}),ie(S)}W?.()}};r=new v({selector:ne.current,document:d?.source,documentMode:d?.mode||"editing",modules:C,toolbar:A?.selector,onReady:f}),k.current=r})(),()=>{e=!0,T.current=null,z.current=null,r&&typeof r.destroy=="function"&&r.destroy(),k.current=null}},[d?.source,d?.mode,K,ie,W,V,A]);const Fe=s.useCallback(async e=>{T.current&&(T.current(),T.current=null),z.current=null,B();const r=e.mode||"inline";if(e.id.startsWith("custom_")&&E){const a=await E(e);if(a){const v=a.mode||r;Q(v,{alias:a.label,metadata:a.metadata,defaultValue:a.defaultValue}),M(!1);return}}Q(r,{alias:e.label,metadata:e.metadata,defaultValue:e.defaultValue}),M(!1)},[Q,E,B]),ke=s.useCallback(e=>{T.current&&(T.current(),T.current=null),z.current=null,B();const r=k.current?.activeEditor;if(!r)return;const a=r.helpers?.structuredContentCommands;if(!a)return;const v=e.group||`group-${Date.now()}-${Math.random().toString(36).substring(2,11)}`,C=a.createTagObject?.({group:v});if((e.mode||"inline")==="inline"?r.commands.insertStructuredContentInline?.({attrs:{alias:e.alias,tag:C},text:e.alias}):r.commands.insertStructuredContentBlock?.({attrs:{alias:e.alias,tag:C},text:e.alias})){e.group||X(e.id,{tag:C}),M(!1);const j=U(r);D(j),y?.(j)}},[X,B,y]),Se=s.useCallback(()=>{M(!1),z.current=null,B(),T.current&&(T.current(),T.current=null)},[B]),we=s.useCallback(()=>{if(!k.current?.activeEditor||p.length===0)return;const e=p.findIndex(a=>a.id===H),r=e>=0?(e+1)%p.length:0;G(p[r].id)},[p,H,G]),Te=s.useCallback(()=>{if(!k.current?.activeEditor||p.length===0)return;const e=p.findIndex(a=>a.id===H),r=e>0?e-1:p.length-1;G(p[r].id)},[p,H,G]),Ee=s.useCallback(async e=>{const{fileName:r="document",triggerDownload:a=!0}=e||{},v=await k.current?.export({exportType:["docx"],exportedName:r,triggerDownload:a}),C=k.current?.activeEditor;if(C){const f=U(C);_?.({fields:f,blob:a?void 0:v,fileName:r})}return v},[_]);s.useImperativeHandle(o,()=>({insertField:e=>Q("inline",e),insertBlockField:e=>Q("block",e),updateField:X,deleteField:oe,selectField:G,nextField:we,previousField:Te,getFields:()=>p,exportTemplate:Ee,getSuperDoc:()=>k.current}));const Me=l.component||ye,ue=u.component||ve;return t.jsxs("div",{className:`superdoc-template-builder ${L||""}`,style:q,children:[t.jsxs("div",{style:{display:"flex",gap:"20px"},children:[u.position==="left"&&t.jsx("div",{className:"superdoc-template-builder-sidebar",children:t.jsx(ue,{fields:p,onSelect:e=>G(e.id),onDelete:oe,onUpdate:e=>X(e.id,e),selectedFieldId:H||void 0})}),t.jsxs("div",{className:"superdoc-template-builder-document",style:{flex:1},children:[A?.renderDefaultContainer&&t.jsx("div",{id:"superdoc-toolbar",className:"superdoc-template-builder-toolbar","data-testid":"template-builder-toolbar"}),t.jsx("div",{ref:ne,className:"superdoc-template-builder-editor",style:{height:te},"data-testid":"template-builder-editor"})]}),u.position==="right"&&t.jsx("div",{className:"superdoc-template-builder-sidebar",children:t.jsx(ue,{fields:p,onSelect:e=>G(e.id),onDelete:oe,onUpdate:e=>X(e.id,e),selectedFieldId:H||void 0})})]}),t.jsx(Me,{isVisible:P,position:h,availableFields:i.available||[],filteredFields:Y,filterQuery:b,allowCreate:i.allowCreate||!1,onSelect:Fe,onClose:Se,onCreateField:E,existingFields:p,onSelectExisting:ke})]})});je.displayName="SuperDocTemplateBuilder";exports.FieldList=ve;exports.FieldMenu=ye;exports.default=je;
|
package/dist/index.mjs
CHANGED
|
@@ -6,14 +6,14 @@ const He = ({
|
|
|
6
6
|
availableFields: f,
|
|
7
7
|
filteredFields: s,
|
|
8
8
|
filterQuery: c,
|
|
9
|
-
allowCreate:
|
|
9
|
+
allowCreate: a,
|
|
10
10
|
onSelect: z,
|
|
11
11
|
onClose: P,
|
|
12
12
|
onCreateField: O,
|
|
13
13
|
existingFields: p = [],
|
|
14
14
|
onSelectExisting: E
|
|
15
15
|
}) => {
|
|
16
|
-
const [
|
|
16
|
+
const [x, y] = I(!1), [w, R] = I(""), [U, A] = I("inline"), [X, ie] = I(!0), [u, B] = I(!0);
|
|
17
17
|
oe(() => {
|
|
18
18
|
n || (y(!1), R(""), A("inline"));
|
|
19
19
|
}, [n]);
|
|
@@ -65,7 +65,7 @@ const He = ({
|
|
|
65
65
|
] })
|
|
66
66
|
}
|
|
67
67
|
),
|
|
68
|
-
|
|
68
|
+
a && !x && /* @__PURE__ */ r(
|
|
69
69
|
"div",
|
|
70
70
|
{
|
|
71
71
|
className: "field-menu-item",
|
|
@@ -79,7 +79,7 @@ const He = ({
|
|
|
79
79
|
children: "+ Create New Field"
|
|
80
80
|
}
|
|
81
81
|
),
|
|
82
|
-
|
|
82
|
+
a && x && /* @__PURE__ */ o("div", { style: { padding: "8px 16px" }, children: [
|
|
83
83
|
/* @__PURE__ */ r(
|
|
84
84
|
"input",
|
|
85
85
|
{
|
|
@@ -203,7 +203,7 @@ const He = ({
|
|
|
203
203
|
}
|
|
204
204
|
)
|
|
205
205
|
] }),
|
|
206
|
-
|
|
206
|
+
a && f.length > 0 && /* @__PURE__ */ r(
|
|
207
207
|
"div",
|
|
208
208
|
{
|
|
209
209
|
style: {
|
|
@@ -463,19 +463,19 @@ const He = ({
|
|
|
463
463
|
transition: "all 0.2s",
|
|
464
464
|
fontSize: c ? "13px" : "14px"
|
|
465
465
|
},
|
|
466
|
-
onMouseEnter: (
|
|
467
|
-
s || (
|
|
466
|
+
onMouseEnter: (a) => {
|
|
467
|
+
s || (a.currentTarget.style.background = "#f3f4f6");
|
|
468
468
|
},
|
|
469
|
-
onMouseLeave: (
|
|
470
|
-
s || (
|
|
469
|
+
onMouseLeave: (a) => {
|
|
470
|
+
s || (a.currentTarget.style.background = "#f9fafb");
|
|
471
471
|
},
|
|
472
472
|
title: n.alias,
|
|
473
473
|
children: [
|
|
474
474
|
/* @__PURE__ */ r(
|
|
475
475
|
"button",
|
|
476
476
|
{
|
|
477
|
-
onClick: (
|
|
478
|
-
|
|
477
|
+
onClick: (a) => {
|
|
478
|
+
a.stopPropagation(), f(n.id);
|
|
479
479
|
},
|
|
480
480
|
style: {
|
|
481
481
|
position: "absolute",
|
|
@@ -491,33 +491,23 @@ const He = ({
|
|
|
491
491
|
alignItems: "center",
|
|
492
492
|
justifyContent: "center"
|
|
493
493
|
},
|
|
494
|
-
onMouseEnter: (
|
|
495
|
-
|
|
494
|
+
onMouseEnter: (a) => {
|
|
495
|
+
a.currentTarget.style.color = "#ef4444";
|
|
496
496
|
},
|
|
497
|
-
onMouseLeave: (
|
|
498
|
-
|
|
497
|
+
onMouseLeave: (a) => {
|
|
498
|
+
a.currentTarget.style.color = "#9ca3af";
|
|
499
499
|
},
|
|
500
500
|
title: "Delete field",
|
|
501
|
-
children: /* @__PURE__ */ r(
|
|
502
|
-
"
|
|
501
|
+
children: /* @__PURE__ */ r("svg", { width: "14", height: "14", viewBox: "0 0 16 16", fill: "none", xmlns: "http://www.w3.org/2000/svg", children: /* @__PURE__ */ r(
|
|
502
|
+
"path",
|
|
503
503
|
{
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
children: /* @__PURE__ */ r(
|
|
510
|
-
"path",
|
|
511
|
-
{
|
|
512
|
-
d: "M6 2V1.5C6 1.22386 6.22386 1 6.5 1H9.5C9.77614 1 10 1.22386 10 1.5V2M2 4H14M12.6667 4L12.1991 11.0129C12.129 12.065 12.0939 12.5911 11.8667 12.99C11.6666 13.3412 11.3648 13.6235 11.0011 13.7998C10.588 14 10.0607 14 9.00623 14H6.99377C5.93927 14 5.41202 14 4.99889 13.7998C4.63517 13.6235 4.33339 13.3412 4.13332 12.99C3.90607 12.5911 3.871 12.065 3.80086 11.0129L3.33333 4",
|
|
513
|
-
stroke: "currentColor",
|
|
514
|
-
strokeWidth: "1.5",
|
|
515
|
-
strokeLinecap: "round",
|
|
516
|
-
strokeLinejoin: "round"
|
|
517
|
-
}
|
|
518
|
-
)
|
|
504
|
+
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",
|
|
505
|
+
stroke: "currentColor",
|
|
506
|
+
strokeWidth: "1.5",
|
|
507
|
+
strokeLinecap: "round",
|
|
508
|
+
strokeLinejoin: "round"
|
|
519
509
|
}
|
|
520
|
-
)
|
|
510
|
+
) })
|
|
521
511
|
}
|
|
522
512
|
),
|
|
523
513
|
/* @__PURE__ */ o("div", { style: { paddingRight: "24px" }, children: [
|
|
@@ -568,21 +558,16 @@ const He = ({
|
|
|
568
558
|
] })
|
|
569
559
|
]
|
|
570
560
|
}
|
|
571
|
-
), Pe = ({
|
|
572
|
-
|
|
573
|
-
onSelect: l,
|
|
574
|
-
onDelete: f,
|
|
575
|
-
selectedFieldId: s
|
|
576
|
-
}) => {
|
|
577
|
-
const [c, d] = I(/* @__PURE__ */ new Set()), { groupedFields: z, ungroupedFields: P } = pe(() => {
|
|
561
|
+
), Pe = ({ fields: n, onSelect: l, onDelete: f, selectedFieldId: s }) => {
|
|
562
|
+
const [c, a] = I(/* @__PURE__ */ new Set()), { groupedFields: z, ungroupedFields: P } = pe(() => {
|
|
578
563
|
const p = {}, E = [];
|
|
579
|
-
return n.forEach((
|
|
580
|
-
|
|
564
|
+
return n.forEach((x) => {
|
|
565
|
+
x.group ? (p[x.group] || (p[x.group] = []), p[x.group].push(x)) : E.push(x);
|
|
581
566
|
}), { groupedFields: p, ungroupedFields: E };
|
|
582
567
|
}, [n]), O = (p) => {
|
|
583
|
-
|
|
584
|
-
const
|
|
585
|
-
return
|
|
568
|
+
a((E) => {
|
|
569
|
+
const x = new Set(E);
|
|
570
|
+
return x.has(p) ? x.delete(p) : x.add(p), x;
|
|
586
571
|
});
|
|
587
572
|
};
|
|
588
573
|
return /* @__PURE__ */ o(
|
|
@@ -629,7 +614,7 @@ const He = ({
|
|
|
629
614
|
p.id
|
|
630
615
|
)),
|
|
631
616
|
Object.entries(z).map(([p, E]) => {
|
|
632
|
-
const
|
|
617
|
+
const x = c.has(p), y = E[0];
|
|
633
618
|
return /* @__PURE__ */ o("div", { children: [
|
|
634
619
|
/* @__PURE__ */ r(
|
|
635
620
|
"div",
|
|
@@ -651,7 +636,7 @@ const He = ({
|
|
|
651
636
|
w.currentTarget.style.background = "#f9fafb";
|
|
652
637
|
},
|
|
653
638
|
children: /* @__PURE__ */ o("div", { style: { display: "flex", alignItems: "center", gap: "8px" }, children: [
|
|
654
|
-
/* @__PURE__ */ r("span", { style: { fontSize: "12px", color: "#6b7280" }, children:
|
|
639
|
+
/* @__PURE__ */ r("span", { style: { fontSize: "12px", color: "#6b7280" }, children: x ? "▼" : "▶" }),
|
|
655
640
|
/* @__PURE__ */ o("div", { style: { flex: 1 }, children: [
|
|
656
641
|
/* @__PURE__ */ r("div", { style: { fontWeight: "500", fontSize: "14px" }, children: y.alias }),
|
|
657
642
|
/* @__PURE__ */ o(
|
|
@@ -675,7 +660,7 @@ const He = ({
|
|
|
675
660
|
] })
|
|
676
661
|
}
|
|
677
662
|
),
|
|
678
|
-
|
|
663
|
+
x && /* @__PURE__ */ r(
|
|
679
664
|
"div",
|
|
680
665
|
{
|
|
681
666
|
style: {
|
|
@@ -707,16 +692,16 @@ const He = ({
|
|
|
707
692
|
}, Q = (n) => {
|
|
708
693
|
const l = n.helpers?.structuredContentCommands;
|
|
709
694
|
return l?.getStructuredContentTags ? (l.getStructuredContentTags(n.state) || []).map((s) => {
|
|
710
|
-
const c = s?.node ?? s,
|
|
695
|
+
const c = s?.node ?? s, a = c?.attrs ?? {}, P = (c?.type?.name || "").includes("Block") ? "block" : "inline";
|
|
711
696
|
return {
|
|
712
|
-
id:
|
|
713
|
-
alias:
|
|
714
|
-
tag:
|
|
697
|
+
id: a.id,
|
|
698
|
+
alias: a.alias || a.label || "",
|
|
699
|
+
tag: a.tag,
|
|
715
700
|
mode: P,
|
|
716
|
-
group: l.getGroup?.(
|
|
701
|
+
group: l.getGroup?.(a.tag) ?? void 0
|
|
717
702
|
};
|
|
718
703
|
}) : [];
|
|
719
|
-
},
|
|
704
|
+
}, Fe = (n, l) => {
|
|
720
705
|
if (n === l) return !0;
|
|
721
706
|
if (n.length !== l.length) return !1;
|
|
722
707
|
for (let f = 0; f < n.length; f += 1) {
|
|
@@ -745,7 +730,7 @@ const He = ({
|
|
|
745
730
|
config: f,
|
|
746
731
|
renderDefaultContainer: l === void 0
|
|
747
732
|
};
|
|
748
|
-
}, re = 10, Ve = 250, je = 300,
|
|
733
|
+
}, re = 10, Ve = 250, je = 300, Ce = (n) => {
|
|
749
734
|
const l = window.innerWidth - Ve - re, f = window.innerHeight - je - re, s = Math.min(n.left, l), c = Math.min(n.top, f);
|
|
750
735
|
return new DOMRect(
|
|
751
736
|
Math.max(s, re),
|
|
@@ -753,371 +738,363 @@ const He = ({
|
|
|
753
738
|
n.width,
|
|
754
739
|
n.height
|
|
755
740
|
);
|
|
756
|
-
}, Ge = Be(
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
() => s.available || []
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
de(
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
802
|
-
|
|
803
|
-
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
S && p?.(S);
|
|
819
|
-
}
|
|
820
|
-
return F ?? !1;
|
|
821
|
-
},
|
|
822
|
-
[p, y, u]
|
|
823
|
-
), Z = T(
|
|
824
|
-
(e, t) => {
|
|
825
|
-
if (!k.current?.activeEditor) return !1;
|
|
826
|
-
const v = k.current.activeEditor.commands.updateStructuredContentById?.(e, {
|
|
827
|
-
attrs: t
|
|
828
|
-
});
|
|
829
|
-
return v && B((F) => {
|
|
830
|
-
const g = F.map((C) => C.id === e ? { ...C, ...t } : C);
|
|
831
|
-
y?.(g);
|
|
832
|
-
const S = g.find((C) => C.id === e);
|
|
833
|
-
return S && E?.(S), g;
|
|
834
|
-
}), v ?? !1;
|
|
835
|
-
},
|
|
836
|
-
[E, y]
|
|
837
|
-
), ae = T(
|
|
838
|
-
(e) => {
|
|
839
|
-
const t = k.current?.activeEditor;
|
|
840
|
-
if (!t) {
|
|
841
|
-
let a = !1;
|
|
842
|
-
return B((x) => {
|
|
843
|
-
if (!x.some((N) => N.id === e)) return x;
|
|
844
|
-
const q = x.filter((N) => N.id !== e);
|
|
845
|
-
return a = !0, y?.(q), m?.(e), q;
|
|
846
|
-
}), a && _((x) => x === e ? null : x), a;
|
|
847
|
-
}
|
|
848
|
-
const v = u.find((a) => a.id === e)?.group;
|
|
849
|
-
let F = !1;
|
|
850
|
-
try {
|
|
851
|
-
F = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
852
|
-
} catch {
|
|
853
|
-
F = !1;
|
|
854
|
-
}
|
|
855
|
-
let g = Q(t);
|
|
856
|
-
const S = g.some((a) => a.id === e);
|
|
857
|
-
if (!F && S && (g = g.filter((a) => a.id !== e)), v) {
|
|
858
|
-
const a = g.filter((x) => x.group === v);
|
|
859
|
-
if (a.length === 1) {
|
|
860
|
-
const x = a[0];
|
|
861
|
-
t.commands.updateStructuredContentById?.(x.id, {
|
|
862
|
-
attrs: { tag: void 0 }
|
|
863
|
-
}), g = Q(t);
|
|
741
|
+
}, Ge = Be(
|
|
742
|
+
(n, l) => {
|
|
743
|
+
const {
|
|
744
|
+
document: f,
|
|
745
|
+
fields: s = {},
|
|
746
|
+
menu: c = {},
|
|
747
|
+
list: a = {},
|
|
748
|
+
toolbar: z,
|
|
749
|
+
onReady: P,
|
|
750
|
+
onTrigger: O,
|
|
751
|
+
onFieldInsert: p,
|
|
752
|
+
onFieldUpdate: E,
|
|
753
|
+
onFieldDelete: x,
|
|
754
|
+
onFieldsChange: y,
|
|
755
|
+
onFieldSelect: w,
|
|
756
|
+
onFieldCreate: R,
|
|
757
|
+
onExport: U,
|
|
758
|
+
className: A,
|
|
759
|
+
style: X,
|
|
760
|
+
documentHeight: ie = "600px"
|
|
761
|
+
} = n, [u, B] = I(s.initial || []), [V, _] = I(null), [j, D] = I(!1), [h, W] = I(), [b, Y] = I(""), [ee, we] = I(() => s.available || []), se = J(null), k = J(null), M = J(null), fe = J(s);
|
|
762
|
+
fe.current = s;
|
|
763
|
+
const H = J(null), ge = J(j);
|
|
764
|
+
oe(() => {
|
|
765
|
+
ge.current = j;
|
|
766
|
+
}, [j]);
|
|
767
|
+
const te = c.trigger || "{{", le = fe.current.available || [], G = pe(() => Ae(z), [z]), me = T(
|
|
768
|
+
(e) => {
|
|
769
|
+
const t = e.trim().toLowerCase();
|
|
770
|
+
return t ? le.filter((i) => i.label.toLowerCase().includes(t)) : le;
|
|
771
|
+
},
|
|
772
|
+
[le]
|
|
773
|
+
), de = T(
|
|
774
|
+
(e) => {
|
|
775
|
+
Y(e), we(me(e));
|
|
776
|
+
},
|
|
777
|
+
[me]
|
|
778
|
+
), L = T(() => {
|
|
779
|
+
de("");
|
|
780
|
+
}, [de]), K = T(
|
|
781
|
+
(e, t) => {
|
|
782
|
+
if (!k.current?.activeEditor) return !1;
|
|
783
|
+
const i = k.current.activeEditor, v = u, C = e === "inline" ? i.commands.insertStructuredContentInline?.({
|
|
784
|
+
attrs: {
|
|
785
|
+
alias: t.alias,
|
|
786
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
787
|
+
},
|
|
788
|
+
text: t.defaultValue || t.alias
|
|
789
|
+
}) : i.commands.insertStructuredContentBlock?.({
|
|
790
|
+
attrs: {
|
|
791
|
+
alias: t.alias,
|
|
792
|
+
tag: t.metadata ? JSON.stringify(t.metadata) : void 0
|
|
793
|
+
},
|
|
794
|
+
text: t.defaultValue || t.alias
|
|
795
|
+
});
|
|
796
|
+
if (C) {
|
|
797
|
+
const g = Q(i);
|
|
798
|
+
B(g), y?.(g);
|
|
799
|
+
const S = g.find(
|
|
800
|
+
(F) => !v.some((d) => d.id === F.id)
|
|
801
|
+
);
|
|
802
|
+
S && p?.(S);
|
|
864
803
|
}
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
804
|
+
return C ?? !1;
|
|
805
|
+
},
|
|
806
|
+
[p, y, u]
|
|
807
|
+
), Z = T(
|
|
808
|
+
(e, t) => {
|
|
809
|
+
if (!k.current?.activeEditor) return !1;
|
|
810
|
+
const v = k.current.activeEditor.commands.updateStructuredContentById?.(e, {
|
|
811
|
+
attrs: t
|
|
812
|
+
});
|
|
813
|
+
return v && B((C) => {
|
|
814
|
+
const g = C.map((F) => F.id === e ? { ...F, ...t } : F);
|
|
815
|
+
y?.(g);
|
|
816
|
+
const S = g.find((F) => F.id === e);
|
|
817
|
+
return S && E?.(S), g;
|
|
818
|
+
}), v ?? !1;
|
|
819
|
+
},
|
|
820
|
+
[E, y]
|
|
821
|
+
), ae = T(
|
|
822
|
+
(e) => {
|
|
823
|
+
const t = k.current?.activeEditor;
|
|
824
|
+
if (!t) {
|
|
825
|
+
let d = !1;
|
|
826
|
+
return B((m) => {
|
|
827
|
+
if (!m.some((N) => N.id === e)) return m;
|
|
828
|
+
const q = m.filter((N) => N.id !== e);
|
|
829
|
+
return d = !0, y?.(q), x?.(e), q;
|
|
830
|
+
}), d && _((m) => m === e ? null : m), d;
|
|
831
|
+
}
|
|
832
|
+
const v = u.find((d) => d.id === e)?.group;
|
|
833
|
+
let C = !1;
|
|
834
|
+
try {
|
|
835
|
+
C = t.commands.deleteStructuredContentById?.(e) ?? !1;
|
|
836
|
+
} catch (d) {
|
|
837
|
+
console.warn("[TemplateBuilder] Failed to delete structured content:", e, d), C = !1;
|
|
838
|
+
}
|
|
839
|
+
let g = Q(t);
|
|
840
|
+
const S = g.some((d) => d.id === e);
|
|
841
|
+
if (!C && S && (g = g.filter((d) => d.id !== e)), v) {
|
|
842
|
+
const d = g.filter((m) => m.group === v);
|
|
843
|
+
if (d.length === 1) {
|
|
844
|
+
const m = d[0];
|
|
845
|
+
t.commands.updateStructuredContentById?.(m.id, {
|
|
846
|
+
attrs: { tag: void 0 }
|
|
847
|
+
}), g = Q(t);
|
|
905
848
|
}
|
|
906
849
|
}
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
if (
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
850
|
+
let F = !1;
|
|
851
|
+
return B((d) => {
|
|
852
|
+
if (Fe(d, g))
|
|
853
|
+
return d;
|
|
854
|
+
const m = d.some((N) => N.id === e), q = g.some((N) => N.id === e);
|
|
855
|
+
return m && !q && (F = !0), y?.(g), F && x?.(e), g;
|
|
856
|
+
}), F && _((d) => d === e ? null : d), C || F;
|
|
857
|
+
},
|
|
858
|
+
[x, y, u]
|
|
859
|
+
), $ = T(
|
|
860
|
+
(e) => {
|
|
861
|
+
if (!k.current?.activeEditor) return;
|
|
862
|
+
k.current.activeEditor.commands.selectStructuredContentById?.(e), _(e);
|
|
863
|
+
const i = u.find((v) => v.id === e);
|
|
864
|
+
i && w?.(i);
|
|
865
|
+
},
|
|
866
|
+
[u, w]
|
|
867
|
+
), ce = T(
|
|
868
|
+
(e) => {
|
|
869
|
+
if (!e) return;
|
|
870
|
+
const t = Q(e);
|
|
871
|
+
B((i) => Fe(i, t) ? i : (y?.(t), t));
|
|
872
|
+
},
|
|
873
|
+
[y]
|
|
874
|
+
);
|
|
875
|
+
oe(() => {
|
|
876
|
+
if (!se.current) return;
|
|
877
|
+
let e = !1, t = null;
|
|
878
|
+
return (async () => {
|
|
879
|
+
const { SuperDoc: v } = await import("superdoc");
|
|
880
|
+
if (e) return;
|
|
881
|
+
const C = {
|
|
882
|
+
comments: !1,
|
|
883
|
+
...G && {
|
|
884
|
+
toolbar: {
|
|
885
|
+
selector: G.selector,
|
|
886
|
+
toolbarGroups: G.config.toolbarGroups || ["center"],
|
|
887
|
+
excludeItems: G.config.excludeItems || [],
|
|
888
|
+
...G.config
|
|
889
|
+
}
|
|
890
|
+
}
|
|
891
|
+
}, g = () => {
|
|
892
|
+
if (!e) {
|
|
893
|
+
if (t?.activeEditor) {
|
|
894
|
+
const S = t.activeEditor;
|
|
895
|
+
S.on("update", ({ editor: F }) => {
|
|
896
|
+
const { state: d } = F, { from: m } = d.selection;
|
|
897
|
+
if (m >= te.length) {
|
|
898
|
+
const ue = m - te.length;
|
|
899
|
+
if (d.doc.textBetween(ue, m) === te) {
|
|
900
|
+
const he = F.view.coordsAtPos(m), be = Ce(new DOMRect(he.left, he.top, 0, 0)), ye = () => {
|
|
901
|
+
const ne = k.current?.activeEditor;
|
|
902
|
+
if (!ne) return;
|
|
903
|
+
const Ne = ne.state.selection.from, ze = ne.state.tr.delete(ue, Ne);
|
|
904
|
+
ne.view.dispatch(ze);
|
|
905
|
+
};
|
|
906
|
+
M.current = ye, H.current = m, W(be), D(!0), L(), O?.({
|
|
907
|
+
position: { from: ue, to: m },
|
|
908
|
+
bounds: be,
|
|
909
|
+
cleanup: ye
|
|
910
|
+
});
|
|
911
|
+
return;
|
|
912
|
+
}
|
|
913
|
+
}
|
|
914
|
+
if (!ge.current)
|
|
915
|
+
return;
|
|
916
|
+
if (H.current == null) {
|
|
917
|
+
D(!1), L();
|
|
927
918
|
return;
|
|
928
919
|
}
|
|
929
|
-
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
}
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
const N = C.view.coordsAtPos(x), De = Fe(new DOMRect(N.left, N.top, 0, 0));
|
|
943
|
-
W(De);
|
|
944
|
-
}), S.on("update", () => {
|
|
945
|
-
ce(S);
|
|
946
|
-
}), ce(S);
|
|
920
|
+
if (m < H.current) {
|
|
921
|
+
D(!1), H.current = null, L();
|
|
922
|
+
return;
|
|
923
|
+
}
|
|
924
|
+
const q = d.doc.textBetween(H.current, m);
|
|
925
|
+
de(q);
|
|
926
|
+
const N = F.view.coordsAtPos(m), De = Ce(new DOMRect(N.left, N.top, 0, 0));
|
|
927
|
+
W(De);
|
|
928
|
+
}), S.on("update", () => {
|
|
929
|
+
ce(S);
|
|
930
|
+
}), ce(S);
|
|
931
|
+
}
|
|
932
|
+
P?.();
|
|
947
933
|
}
|
|
948
|
-
|
|
949
|
-
|
|
934
|
+
};
|
|
935
|
+
t = new v({
|
|
936
|
+
selector: se.current,
|
|
937
|
+
document: f?.source,
|
|
938
|
+
documentMode: f?.mode || "editing",
|
|
939
|
+
modules: C,
|
|
940
|
+
toolbar: G?.selector,
|
|
941
|
+
onReady: g
|
|
942
|
+
}), k.current = t;
|
|
943
|
+
})(), () => {
|
|
944
|
+
e = !0, M.current = null, H.current = null, t && typeof t.destroy == "function" && t.destroy(), k.current = null;
|
|
950
945
|
};
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
P,
|
|
968
|
-
O,
|
|
969
|
-
G
|
|
970
|
-
]);
|
|
971
|
-
const ke = T(
|
|
972
|
-
async (e) => {
|
|
973
|
-
M.current && (M.current(), M.current = null), H.current = null, L();
|
|
974
|
-
const t = e.mode || "inline";
|
|
975
|
-
if (e.id.startsWith("custom_") && R) {
|
|
976
|
-
const i = await R(e);
|
|
977
|
-
if (i) {
|
|
978
|
-
const v = i.mode || t;
|
|
979
|
-
K(v, {
|
|
980
|
-
alias: i.label,
|
|
981
|
-
metadata: i.metadata,
|
|
982
|
-
defaultValue: i.defaultValue
|
|
983
|
-
}), D(!1);
|
|
984
|
-
return;
|
|
946
|
+
}, [f?.source, f?.mode, te, ce, P, O, G]);
|
|
947
|
+
const ke = T(
|
|
948
|
+
async (e) => {
|
|
949
|
+
M.current && (M.current(), M.current = null), H.current = null, L();
|
|
950
|
+
const t = e.mode || "inline";
|
|
951
|
+
if (e.id.startsWith("custom_") && R) {
|
|
952
|
+
const i = await R(e);
|
|
953
|
+
if (i) {
|
|
954
|
+
const v = i.mode || t;
|
|
955
|
+
K(v, {
|
|
956
|
+
alias: i.label,
|
|
957
|
+
metadata: i.metadata,
|
|
958
|
+
defaultValue: i.defaultValue
|
|
959
|
+
}), D(!1);
|
|
960
|
+
return;
|
|
961
|
+
}
|
|
985
962
|
}
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
}
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
B(C), y?.(C);
|
|
1020
|
-
}
|
|
1021
|
-
},
|
|
1022
|
-
[Z, L, y]
|
|
1023
|
-
), Te = T(() => {
|
|
1024
|
-
D(!1), H.current = null, L(), M.current && (M.current(), M.current = null);
|
|
1025
|
-
}, [L]), Ee = T(() => {
|
|
1026
|
-
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1027
|
-
const e = u.findIndex((i) => i.id === V), t = e >= 0 ? (e + 1) % u.length : 0;
|
|
1028
|
-
$(u[t].id);
|
|
1029
|
-
}, [u, V, $]), Ie = T(() => {
|
|
1030
|
-
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1031
|
-
const e = u.findIndex((i) => i.id === V), t = e > 0 ? e - 1 : u.length - 1;
|
|
1032
|
-
$(u[t].id);
|
|
1033
|
-
}, [u, V, $]), Me = T(
|
|
1034
|
-
async (e) => {
|
|
1035
|
-
const { fileName: t = "document", triggerDownload: i = !0 } = e || {}, v = await k.current?.export({
|
|
1036
|
-
exportType: ["docx"],
|
|
1037
|
-
exportedName: t,
|
|
1038
|
-
triggerDownload: i
|
|
1039
|
-
}), F = k.current?.activeEditor;
|
|
1040
|
-
if (F) {
|
|
1041
|
-
const g = Q(F);
|
|
1042
|
-
U?.({ fields: g, blob: i ? void 0 : v, fileName: t });
|
|
1043
|
-
}
|
|
1044
|
-
return v;
|
|
1045
|
-
},
|
|
1046
|
-
[U]
|
|
1047
|
-
);
|
|
1048
|
-
We(l, () => ({
|
|
1049
|
-
insertField: (e) => K("inline", e),
|
|
1050
|
-
insertBlockField: (e) => K("block", e),
|
|
1051
|
-
updateField: Z,
|
|
1052
|
-
deleteField: ae,
|
|
1053
|
-
selectField: $,
|
|
1054
|
-
nextField: Ee,
|
|
1055
|
-
previousField: Ie,
|
|
1056
|
-
getFields: () => u,
|
|
1057
|
-
exportTemplate: Me,
|
|
1058
|
-
getSuperDoc: () => k.current
|
|
1059
|
-
}));
|
|
1060
|
-
const Re = c.component || He, me = d.component || Pe;
|
|
1061
|
-
return /* @__PURE__ */ o("div", { className: `superdoc-template-builder ${A || ""}`, style: X, children: [
|
|
1062
|
-
/* @__PURE__ */ o("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1063
|
-
d.position === "left" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1064
|
-
me,
|
|
1065
|
-
{
|
|
1066
|
-
fields: u,
|
|
1067
|
-
onSelect: (e) => $(e.id),
|
|
1068
|
-
onDelete: ae,
|
|
1069
|
-
onUpdate: (e) => Z(e.id, e),
|
|
1070
|
-
selectedFieldId: V || void 0
|
|
963
|
+
K(t, {
|
|
964
|
+
alias: e.label,
|
|
965
|
+
metadata: e.metadata,
|
|
966
|
+
defaultValue: e.defaultValue
|
|
967
|
+
}), D(!1);
|
|
968
|
+
},
|
|
969
|
+
[K, R, L]
|
|
970
|
+
), Se = T(
|
|
971
|
+
(e) => {
|
|
972
|
+
M.current && (M.current(), M.current = null), H.current = null, L();
|
|
973
|
+
const t = k.current?.activeEditor;
|
|
974
|
+
if (!t) return;
|
|
975
|
+
const i = t.helpers?.structuredContentCommands;
|
|
976
|
+
if (!i) return;
|
|
977
|
+
const v = e.group || `group-${Date.now()}-${Math.random().toString(36).substring(2, 11)}`, C = i.createTagObject?.({
|
|
978
|
+
group: v
|
|
979
|
+
});
|
|
980
|
+
if ((e.mode || "inline") === "inline" ? t.commands.insertStructuredContentInline?.({
|
|
981
|
+
attrs: {
|
|
982
|
+
alias: e.alias,
|
|
983
|
+
tag: C
|
|
984
|
+
},
|
|
985
|
+
text: e.alias
|
|
986
|
+
}) : t.commands.insertStructuredContentBlock?.({
|
|
987
|
+
attrs: {
|
|
988
|
+
alias: e.alias,
|
|
989
|
+
tag: C
|
|
990
|
+
},
|
|
991
|
+
text: e.alias
|
|
992
|
+
})) {
|
|
993
|
+
e.group || Z(e.id, { tag: C }), D(!1);
|
|
994
|
+
const F = Q(t);
|
|
995
|
+
B(F), y?.(F);
|
|
1071
996
|
}
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
997
|
+
},
|
|
998
|
+
[Z, L, y]
|
|
999
|
+
), Te = T(() => {
|
|
1000
|
+
D(!1), H.current = null, L(), M.current && (M.current(), M.current = null);
|
|
1001
|
+
}, [L]), Ee = T(() => {
|
|
1002
|
+
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1003
|
+
const e = u.findIndex((i) => i.id === V), t = e >= 0 ? (e + 1) % u.length : 0;
|
|
1004
|
+
$(u[t].id);
|
|
1005
|
+
}, [u, V, $]), Ie = T(() => {
|
|
1006
|
+
if (!k.current?.activeEditor || u.length === 0) return;
|
|
1007
|
+
const e = u.findIndex((i) => i.id === V), t = e > 0 ? e - 1 : u.length - 1;
|
|
1008
|
+
$(u[t].id);
|
|
1009
|
+
}, [u, V, $]), Me = T(
|
|
1010
|
+
async (e) => {
|
|
1011
|
+
const { fileName: t = "document", triggerDownload: i = !0 } = e || {}, v = await k.current?.export({
|
|
1012
|
+
exportType: ["docx"],
|
|
1013
|
+
exportedName: t,
|
|
1014
|
+
triggerDownload: i
|
|
1015
|
+
}), C = k.current?.activeEditor;
|
|
1016
|
+
if (C) {
|
|
1017
|
+
const g = Q(C);
|
|
1018
|
+
U?.({ fields: g, blob: i ? void 0 : v, fileName: t });
|
|
1019
|
+
}
|
|
1020
|
+
return v;
|
|
1021
|
+
},
|
|
1022
|
+
[U]
|
|
1023
|
+
);
|
|
1024
|
+
We(l, () => ({
|
|
1025
|
+
insertField: (e) => K("inline", e),
|
|
1026
|
+
insertBlockField: (e) => K("block", e),
|
|
1027
|
+
updateField: Z,
|
|
1028
|
+
deleteField: ae,
|
|
1029
|
+
selectField: $,
|
|
1030
|
+
nextField: Ee,
|
|
1031
|
+
previousField: Ie,
|
|
1032
|
+
getFields: () => u,
|
|
1033
|
+
exportTemplate: Me,
|
|
1034
|
+
getSuperDoc: () => k.current
|
|
1035
|
+
}));
|
|
1036
|
+
const Re = c.component || He, xe = a.component || Pe;
|
|
1037
|
+
return /* @__PURE__ */ o("div", { className: `superdoc-template-builder ${A || ""}`, style: X, children: [
|
|
1038
|
+
/* @__PURE__ */ o("div", { style: { display: "flex", gap: "20px" }, children: [
|
|
1039
|
+
a.position === "left" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1040
|
+
xe,
|
|
1076
1041
|
{
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1042
|
+
fields: u,
|
|
1043
|
+
onSelect: (e) => $(e.id),
|
|
1044
|
+
onDelete: ae,
|
|
1045
|
+
onUpdate: (e) => Z(e.id, e),
|
|
1046
|
+
selectedFieldId: V || void 0
|
|
1080
1047
|
}
|
|
1081
|
-
),
|
|
1082
|
-
/* @__PURE__ */
|
|
1083
|
-
|
|
1048
|
+
) }),
|
|
1049
|
+
/* @__PURE__ */ o("div", { className: "superdoc-template-builder-document", style: { flex: 1 }, children: [
|
|
1050
|
+
G?.renderDefaultContainer && /* @__PURE__ */ r(
|
|
1051
|
+
"div",
|
|
1052
|
+
{
|
|
1053
|
+
id: "superdoc-toolbar",
|
|
1054
|
+
className: "superdoc-template-builder-toolbar",
|
|
1055
|
+
"data-testid": "template-builder-toolbar"
|
|
1056
|
+
}
|
|
1057
|
+
),
|
|
1058
|
+
/* @__PURE__ */ r(
|
|
1059
|
+
"div",
|
|
1060
|
+
{
|
|
1061
|
+
ref: se,
|
|
1062
|
+
className: "superdoc-template-builder-editor",
|
|
1063
|
+
style: { height: ie },
|
|
1064
|
+
"data-testid": "template-builder-editor"
|
|
1065
|
+
}
|
|
1066
|
+
)
|
|
1067
|
+
] }),
|
|
1068
|
+
a.position === "right" && /* @__PURE__ */ r("div", { className: "superdoc-template-builder-sidebar", children: /* @__PURE__ */ r(
|
|
1069
|
+
xe,
|
|
1084
1070
|
{
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1071
|
+
fields: u,
|
|
1072
|
+
onSelect: (e) => $(e.id),
|
|
1073
|
+
onDelete: ae,
|
|
1074
|
+
onUpdate: (e) => Z(e.id, e),
|
|
1075
|
+
selectedFieldId: V || void 0
|
|
1089
1076
|
}
|
|
1090
|
-
)
|
|
1077
|
+
) })
|
|
1091
1078
|
] }),
|
|
1092
|
-
|
|
1093
|
-
|
|
1079
|
+
/* @__PURE__ */ r(
|
|
1080
|
+
Re,
|
|
1094
1081
|
{
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1082
|
+
isVisible: j,
|
|
1083
|
+
position: h,
|
|
1084
|
+
availableFields: s.available || [],
|
|
1085
|
+
filteredFields: ee,
|
|
1086
|
+
filterQuery: b,
|
|
1087
|
+
allowCreate: s.allowCreate || !1,
|
|
1088
|
+
onSelect: ke,
|
|
1089
|
+
onClose: Te,
|
|
1090
|
+
onCreateField: R,
|
|
1091
|
+
existingFields: u,
|
|
1092
|
+
onSelectExisting: Se
|
|
1100
1093
|
}
|
|
1101
|
-
)
|
|
1102
|
-
] })
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
{
|
|
1106
|
-
isVisible: j,
|
|
1107
|
-
position: h,
|
|
1108
|
-
availableFields: s.available || [],
|
|
1109
|
-
filteredFields: ee,
|
|
1110
|
-
filterQuery: b,
|
|
1111
|
-
allowCreate: s.allowCreate || !1,
|
|
1112
|
-
onSelect: ke,
|
|
1113
|
-
onClose: Te,
|
|
1114
|
-
onCreateField: R,
|
|
1115
|
-
existingFields: u,
|
|
1116
|
-
onSelectExisting: Se
|
|
1117
|
-
}
|
|
1118
|
-
)
|
|
1119
|
-
] });
|
|
1120
|
-
});
|
|
1094
|
+
)
|
|
1095
|
+
] });
|
|
1096
|
+
}
|
|
1097
|
+
);
|
|
1121
1098
|
Ge.displayName = "SuperDocTemplateBuilder";
|
|
1122
1099
|
export {
|
|
1123
1100
|
Pe as FieldList,
|
|
File without changes
|
package/dist/types.d.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@superdoc-dev/template-builder",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.1-next.1",
|
|
4
4
|
"description": "React template builder component for SuperDoc",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -21,19 +21,16 @@
|
|
|
21
21
|
"dev": "vite build --watch",
|
|
22
22
|
"build": "tsc && vite build",
|
|
23
23
|
"type-check": "tsc --noEmit",
|
|
24
|
-
"lint": "eslint src
|
|
25
|
-
"lint:fix": "eslint src
|
|
26
|
-
"
|
|
27
|
-
"format:check": "prettier --check \"src/**/*.{ts,tsx}\" \"demo/**/*.{ts,tsx}\"",
|
|
28
|
-
"test": "vitest",
|
|
24
|
+
"lint": "eslint src",
|
|
25
|
+
"lint:fix": "eslint src --fix",
|
|
26
|
+
"test": "vitest run",
|
|
29
27
|
"test:watch": "vitest --watch",
|
|
30
|
-
"
|
|
31
|
-
"release": "semantic-release",
|
|
32
|
-
"check:all": "pnpm run format:check && pnpm run lint && pnpm run type-check && pnpm run build"
|
|
28
|
+
"prepublishOnly": "pnpm run build"
|
|
33
29
|
},
|
|
34
30
|
"repository": {
|
|
35
31
|
"type": "git",
|
|
36
|
-
"url": "https://github.com/superdoc-dev/
|
|
32
|
+
"url": "git+https://github.com/superdoc-dev/superdoc.git",
|
|
33
|
+
"directory": "packages/template-builder"
|
|
37
34
|
},
|
|
38
35
|
"keywords": [
|
|
39
36
|
"superdoc",
|
|
@@ -46,54 +43,38 @@
|
|
|
46
43
|
"react"
|
|
47
44
|
],
|
|
48
45
|
"author": "SuperDoc Team",
|
|
49
|
-
"license": "
|
|
46
|
+
"license": "AGPL-3.0",
|
|
50
47
|
"bugs": {
|
|
51
|
-
"url": "https://github.com/superdoc-dev/
|
|
48
|
+
"url": "https://github.com/superdoc-dev/superdoc/issues"
|
|
52
49
|
},
|
|
53
|
-
"homepage": "https://github.com/superdoc-dev/template-builder#readme",
|
|
50
|
+
"homepage": "https://github.com/superdoc-dev/superdoc/tree/main/packages/template-builder#readme",
|
|
54
51
|
"peerDependencies": {
|
|
55
52
|
"react": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
56
53
|
"react-dom": "^16.8.0 || ^17.0.0 || ^18.0.0 || ^19.0.0",
|
|
57
|
-
"superdoc": "^1.
|
|
54
|
+
"superdoc": "^1.9.0"
|
|
58
55
|
},
|
|
59
56
|
"devDependencies": {
|
|
60
|
-
"@
|
|
61
|
-
"@
|
|
62
|
-
"@
|
|
63
|
-
"@
|
|
64
|
-
"@
|
|
65
|
-
"@
|
|
66
|
-
"
|
|
67
|
-
"
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
71
|
-
"
|
|
72
|
-
"
|
|
73
|
-
"
|
|
74
|
-
"
|
|
75
|
-
"jsdom": "
|
|
76
|
-
"lint-staged": "^16.2.7",
|
|
77
|
-
"prettier": "^3.6.2",
|
|
78
|
-
"react": "^19.2.0",
|
|
79
|
-
"react-dom": "^19.2.0",
|
|
80
|
-
"semantic-release": "^25.0.2",
|
|
81
|
-
"typescript": "^5.9.3",
|
|
82
|
-
"typescript-eslint": "^8.47.0",
|
|
83
|
-
"vite": "^7.2.4",
|
|
84
|
-
"vite-plugin-dts": "^4.5.4",
|
|
85
|
-
"vitest": "^4.0.13"
|
|
57
|
+
"@testing-library/jest-dom": "catalog:",
|
|
58
|
+
"@testing-library/react": "catalog:",
|
|
59
|
+
"@testing-library/user-event": "catalog:",
|
|
60
|
+
"@types/react": "catalog:",
|
|
61
|
+
"@types/react-dom": "catalog:",
|
|
62
|
+
"@vitejs/plugin-react": "catalog:",
|
|
63
|
+
"eslint-plugin-react": "catalog:",
|
|
64
|
+
"eslint-plugin-react-hooks": "catalog:",
|
|
65
|
+
"react": "catalog:",
|
|
66
|
+
"react-dom": "catalog:",
|
|
67
|
+
"superdoc": "workspace:*",
|
|
68
|
+
"typescript": "catalog:",
|
|
69
|
+
"vite": "catalog:",
|
|
70
|
+
"vite-plugin-dts": "catalog:",
|
|
71
|
+
"vitest": "catalog:",
|
|
72
|
+
"jsdom": "catalog:"
|
|
86
73
|
},
|
|
87
74
|
"publishConfig": {
|
|
88
75
|
"access": "public"
|
|
89
76
|
},
|
|
90
77
|
"engines": {
|
|
91
78
|
"node": ">=18"
|
|
92
|
-
},
|
|
93
|
-
"lint-staged": {
|
|
94
|
-
"*.{ts,tsx}": [
|
|
95
|
-
"prettier --write",
|
|
96
|
-
"eslint --fix"
|
|
97
|
-
]
|
|
98
79
|
}
|
|
99
80
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"FieldList.d.ts","sourceRoot":"","sources":["../../src/defaults/FieldList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAA4B,MAAM,OAAO,CAAC;AACjD,OAAO,KAAK,EAAE,cAAc,EAAiB,MAAM,UAAU,CAAC;AA0H9D,eAAO,MAAM,SAAS,EAAE,KAAK,CAAC,EAAE,CAAC,cAAc,CAoJ9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CA8b9C,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/defaults/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC"}
|
package/dist/index.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAUA,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;AAoGhC,QAAA,MAAM,uBAAuB,oJAymB3B,CAAC;AAIH,eAAe,uBAAuB,CAAC"}
|
package/dist/types.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"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"}
|