@pdfme/ui 4.1.0-dev.4 → 4.1.0-dev.6
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.es.js
CHANGED
@@ -152100,36 +152100,47 @@ Check this document: https://pdfme.com/docs/custom-schemas`);
|
|
152100
152100
|
/* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { visibility: lt ? "hidden" : "visible" }, children: a.children })
|
152101
152101
|
] });
|
152102
152102
|
}, LeftSidebar = ({ height: a, scale: s, basePdf: $ }) => {
|
152103
|
-
const { token: _ } = theme.useToken(), _e = reactExports.useContext(PluginsRegistry);
|
152104
|
-
return
|
152103
|
+
const { token: _ } = theme.useToken(), _e = reactExports.useContext(PluginsRegistry), [tt, nt] = reactExports.useState(!1);
|
152104
|
+
return reactExports.useEffect(() => {
|
152105
|
+
const at = () => {
|
152106
|
+
tt && nt(!1);
|
152107
|
+
};
|
152108
|
+
return document.addEventListener("mouseup", at), () => {
|
152109
|
+
document.removeEventListener("mouseup", at);
|
152110
|
+
};
|
152111
|
+
}, [tt]), /* @__PURE__ */ jsxRuntimeExports.jsx(
|
152105
152112
|
"div",
|
152106
152113
|
{
|
152107
152114
|
style: {
|
152108
152115
|
left: 0,
|
152109
|
-
position: "absolute",
|
152110
152116
|
right: 0,
|
152117
|
+
position: "absolute",
|
152111
152118
|
zIndex: 1,
|
152112
152119
|
height: a,
|
152120
|
+
width: 45,
|
152113
152121
|
background: _.colorBgLayout,
|
152114
152122
|
textAlign: "center",
|
152115
|
-
|
152123
|
+
overflow: tt ? "visible" : "auto"
|
152116
152124
|
},
|
152117
|
-
children: Object.entries(_e).map(([
|
152125
|
+
children: Object.entries(_e).map(([at, ot]) => ot != null && ot.propPanel.defaultSchema ? /* @__PURE__ */ jsxRuntimeExports.jsx(
|
152118
152126
|
Draggable$1,
|
152119
152127
|
{
|
152120
152128
|
scale: s,
|
152121
152129
|
basePdf: $,
|
152122
|
-
plugin:
|
152130
|
+
plugin: ot,
|
152123
152131
|
children: /* @__PURE__ */ jsxRuntimeExports.jsx(
|
152124
152132
|
Button$2,
|
152125
152133
|
{
|
152126
|
-
title:
|
152134
|
+
title: at,
|
152135
|
+
onMouseDown: () => {
|
152136
|
+
nt(!0);
|
152137
|
+
},
|
152127
152138
|
style: { width: 35, height: 35, marginTop: "0.25rem", padding: "0.25rem" },
|
152128
|
-
children:
|
152139
|
+
children: ot.propPanel.defaultSchema.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: ot.propPanel.defaultSchema.icon } }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { overflow: "hidden", textOverflow: "ellipsis" }, children: at })
|
152129
152140
|
}
|
152130
152141
|
)
|
152131
152142
|
},
|
152132
|
-
|
152143
|
+
at
|
152133
152144
|
) : null)
|
152134
152145
|
}
|
152135
152146
|
);
|
@@ -162640,7 +162651,7 @@ const Designer$1 = Designer, { Text } = Typography$1, icons = {
|
|
162640
162651
|
const Rt = yt, kt = (vt == null ? void 0 : vt[St]) || "";
|
162641
162652
|
if (Rt === kt)
|
162642
162653
|
return;
|
162643
|
-
xt({ key: St, value: Rt }), Ct = !0;
|
162654
|
+
xt({ key: St, value: Rt }), bt.type === "table" && (Ct = !0);
|
162644
162655
|
} else {
|
162645
162656
|
const Rt = ut[st].find(
|
162646
162657
|
(kt) => kt.id === bt.id
|
package/dist/index.umd.js
CHANGED
@@ -706,7 +706,7 @@ In order to be iterable, non-array objects must have a [Symbol.iterator]() metho
|
|
706
706
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray$1(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray$1(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray$1(a,s)}}function _arrayLikeToArray$1(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}function _iterableToArrayLimit$1(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles$1(a){if(Array.isArray(a))return a}function flattenSchema(){var a=arguments.length>0&&arguments[0]!==void 0?arguments[0]:{},s=arguments.length>1?arguments[1]:void 0,$=arguments.length>2?arguments[2]:void 0,_=arguments.length>3?arguments[3]:void 0,_e=_||{},tt=_cloneDeep(a)||{},nt=s||"#";tt.$id||(tt.$id=nt);var at=[];return isObjType(tt)&&(sortProperties(Object.entries(tt.properties)).forEach(function(ot){var rt=_slicedToArray$1(ot,2),st=rt[0],lt=rt[1],et=isListType(lt)?st+"[]":st,it=nt==="#"?et:nt+"."+et;at.push(it),flattenSchema(lt,it,nt,_e)}),tt.properties={}),isListType(tt)&&(sortProperties(Object.entries(tt.items.properties)).forEach(function(ot){var rt=_slicedToArray$1(ot,2),st=rt[0],lt=rt[1],et=isListType(lt)?st+"[]":st,it=nt==="#"?et:nt+"."+et;at.push(it),flattenSchema(lt,it,nt,_e)}),tt.items.properties={}),tt.type&&(_e[nt]={parent:$,schema:tt,children:at}),_e}function _slicedToArray(a,s){return _arrayWithHoles(a)||_iterableToArrayLimit(a,s)||_unsupportedIterableToArray(a,s)||_nonIterableRest()}function _nonIterableRest(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
|
707
707
|
In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function _unsupportedIterableToArray(a,s){if(a){if(typeof a=="string")return _arrayLikeToArray(a,s);var $=Object.prototype.toString.call(a).slice(8,-1);if($==="Object"&&a.constructor&&($=a.constructor.name),$==="Map"||$==="Set")return Array.from(a);if($==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test($))return _arrayLikeToArray(a,s)}}function _arrayLikeToArray(a,s){(s==null||s>a.length)&&(s=a.length);for(var $=0,_=new Array(s);$<s;$++)_[$]=a[$];return _}function _iterableToArrayLimit(a,s){var $=a==null?null:typeof Symbol<"u"&&a[Symbol.iterator]||a["@@iterator"];if($!=null){var _,_e,tt,nt,at=[],ot=!0,rt=!1;try{if(tt=($=$.call(a)).next,s===0){if(Object($)!==$)return;ot=!1}else for(;!(ot=(_=tt.call($)).done)&&(at.push(_.value),at.length!==s);ot=!0);}catch(st){rt=!0,_e=st}finally{try{if(!ot&&$.return!=null&&(nt=$.return(),Object(nt)!==nt))return}finally{if(rt)throw _e}}return at}}function _arrayWithHoles(a){if(Array.isArray(a))return a}var updateSchemaByPath=function a(s,$,_){var _e=getSchemaFullPath(s,_),tt=_get(_,_e,{}),nt=isFunction$2($)?$(tt):$,at=Object.assign(Object.assign({},tt),nt);nt.props&&(at.props=Object.assign(Object.assign({},tt==null?void 0:tt.props),nt.props)),_set(_,_e,at)},getFieldName=function a(s){if(s){if(typeof s=="boolean")return s;var $=[];return isArray$3(s)&&($=s.map(function(_){return _.split(".").map(function(_e){return isNaN(Number(_e))?_e:_e*1})})),$=s.split(".").map(function(_){return isNaN(Number(_))?_:_*1}),$=$.map(function(_){return typeof _=="string"&&(_==null?void 0:_.indexOf("["))===0&&(_==null?void 0:_.indexOf("]"))===(_==null?void 0:_.length)-1?Number(_.substring(1,_.length-1)):_}),$}},useForm=function a(){var s=Form$3.useForm(),$=_slicedToArray(s,1),_=$[0],_e=reactExports.useRef({}),tt=reactExports.useRef(),nt=reactExports.useRef({}),at=reactExports.useRef({});_.getFieldError;var ot=_.getFieldsError,rt=_.getFieldInstance,st=_.setFieldsValue,lt=_.setFields,et=_.scrollToField,it=_.isFieldsTouched,ut=_.isFieldTouched,ft=_.isFieldValidating,ht=_.resetFields,dt=_.validateFields,gt=__rest$3(_,["getFieldError","getFieldsError","getFieldInstance","setFieldsValue","setFields","scrollToField","isFieldsTouched","isFieldTouched","isFieldValidating","resetFields","validateFields"]),pt=gt,mt=function(At){var xt=tt.current.setState;xt||setTimeout(function(){xt({schema:nt.current,flattenSchema:_e.current})},0),xt(At)},ct=function(At){_e.current=flattenSchema(At)||{},nt.current=At,mt({schema:At,flattenSchema:_e.current})};return pt.setSchema=function(vt){var At=arguments.length>1&&arguments[1]!==void 0?arguments[1]:!1;if(isObject$6(vt)){if(At){ct(vt);return}var xt=cloneDeep(nt.current);Object.keys(vt||{}).forEach(function(bt){updateSchemaByPath(bt,vt[bt],xt)}),ct(xt)}},pt.setSchemaByPath=function(vt,At){if(!(!hasFuncProperty(At)&&_isMatch(At,pt.getSchemaByPath(vt)))){var xt=cloneDeep(nt.current);updateSchemaByPath(vt,At,xt),ct(xt)}},pt.setValues=function(vt){var At=parseBindToValues(vt,_e.current);st(At)},pt.getValues=function(vt,At){var xt,bt=cloneDeep(_.getFieldsValue(getFieldName(vt),At)),Et=((xt=tt.current)===null||xt===void 0?void 0:xt.getState())||{},St=Et.removeHiddenData;return St&&(bt=filterValuesHidden(bt,_e.current)),bt=filterValuesUndefined(bt),parseValuesToBind(bt,_e.current)},pt.getValueByPath=function(vt){var At=getFieldName(vt);return _.getFieldValue(At)},pt.setValueByPath=function(vt,At){if(!_.setFieldValue){var xt=_.getFieldsValue();_set(xt,vt,At),pt.setValues(xt);return}var bt=getFieldName(vt);_.setFieldValue(bt,At);try{JSON.stringify(_.getFieldValue(bt))!==JSON.stringify(At)&&_.setFieldValue(bt,At)}catch{}},pt.getSchemaByPath=function(vt){typeof vt!="string"&&console.warn("请输入正确的路径");var At=getSchemaFullPath(vt,nt.current);return _get(nt.current,At)},pt.getSchema=function(){return nt.current},pt.setErrorFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.removeErrorField=function(vt){lt([{name:getFieldName(vt),errors:[]}])},pt.getFieldError=function(vt){var At=getFieldName(vt);return _.getFieldError(At)},pt.getFieldsError=function(vt){var At=getFieldName(vt);return ot(At)},pt.getFieldInstance=function(vt){var At=getFieldName(vt);return rt(At)},pt.getHiddenValues=function(){var vt=pt.getValues(),At=pt.getValues(!0),xt={},bt=function Et(St,Bt,Ot){Object.keys(St).forEach(function(Tt){var wt=St[Tt],Ct=Ot?"".concat(Ot,".").concat(Tt):Tt;if(!Bt.hasOwnProperty(Tt)){_set(xt,Ct,wt);return}isObject$6(wt)&&Et(wt,Bt[Tt],Ct),isArray$3(wt)&&wt.map(function(It,yt){Et(It,_get(Bt,"".concat(Tt,"[").concat(yt,"]"),[]),"".concat(Ct,"[").concat(yt,"]"))})})};return bt(At,vt,null),xt},pt.setFields=function(vt){var At=transformFieldsData(vt,getFieldName);At&<(At)},pt.__initStore=function(vt){tt.current=vt},pt.scrollToPath=function(vt){for(var At=getFieldName(vt),xt=arguments.length,bt=new Array(xt>1?xt-1:0),Et=1;Et<xt;Et++)bt[Et-1]=arguments[Et];et.apply(void 0,[At].concat(bt))},pt.isFieldsTouched=function(vt,At){var xt=(vt||[]).map(function(bt){return getFieldName(bt)});return it(xt,At)},pt.isFieldTouched=function(vt){var At=getFieldName(vt);return ut(At)},pt.isFieldValidating=function(vt){var At=getFieldName(vt);return ft(At)},pt.resetFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});At.length>0?ht(At):ht()},pt.validateFields=function(vt){var At=(vt||[]).map(function(xt){return getFieldName(xt)});return At.length>0?dt(At):dt()},pt.getFlattenSchema=function(vt){var At;return vt?(At=_e.current)===null||At===void 0?void 0:At[vt]:_e.current},pt.onItemChange=pt.setValueByPath,pt.setFieldRef=function(vt,At){vt&&(at.current[vt]=At)},pt.getFieldRef=function(vt){return at.current[vt]},pt};const FormRender=withProvider(FormCore,defaultWidgets),svgBaseProp={style:{width:"90%",height:"90%"},xmlns:"http://www.w3.org/2000/svg",enableBackground:"new 0 0 24 24",height:"24px",viewBox:"0 0 24 24",width:"24px",fill:"#000000"},createSvgIcon=a=>jsxRuntimeExports.jsxs("svg",{...svgBaseProp,children:[jsxRuntimeExports.jsx("rect",{fill:"none",height:"24",width:"24"}),a]}),createButtonConfig=(a,s,$)=>({id:a,icon:createSvgIcon(s),onClick:$}),AlignWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,pageSize:_e,schema:tt}=a,nt=rt=>{const st=s.map(ct=>ct.id),lt=_.filter(ct=>st.includes(ct.id)),et=["left","center","right"].includes(rt),it=et?"x":"y",ut=et?"width":"height",ft=lt.length===1,ht=_e[ut],dt=ft?0:Math.min(...lt.map(ct=>ct.position[it])),gt=ft?ht:Math.max(...lt.map(ct=>ct.position[it]+ct[ut]));let pt=dt,mt=ct=>0;["center","middle"].includes(rt)?(pt=(dt+gt)/2,mt=ct=>ct/2):["right","bottom"].includes(rt)&&(pt=gt,mt=ct=>ct),$(lt.map(ct=>({key:`position.${it}`,value:round(pt-mt(ct[ut]),2),schemaId:ct.id})))},at=rt=>{const st=s.map(At=>At.id),lt=_.filter(At=>st.includes(At.id)),et=rt==="vertical",it=et?"y":"x",ut=et?"height":"width",ft=Math.min(...lt.map(At=>At.position[it])),ht=Math.max(...lt.map(At=>At.position[it]+At[ut]));if(lt.length<3)return;const dt=ft,gt=ht-ft,pt=lt.reduce((At,xt)=>At+xt[ut],0),ct=(gt-pt)/(lt.length-1);let vt=0;$(lt.map((At,xt)=>{vt+=xt===0?0:lt[xt-1][ut]+ct;const bt=round(dt+vt,2);return{key:`position.${it}`,value:bt,schemaId:At.id}}))},ot=[createButtonConfig("left",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,7H6v3h16V7z M16,14H6v3h10V14z"}),()=>nt("left")),createButtonConfig("center",jsxRuntimeExports.jsx("polygon",{points:"11,2 13,2 13,7 21,7 21,10 13,10 13,14 18,14 18,17 13,17 13,22 11,22 11,17 6,17 6,14 11,14 11,10 3,10 3,7 11,7"}),()=>nt("center")),createButtonConfig("right",jsxRuntimeExports.jsx("path",{d:"M20,2h2v20h-2V2z M2,10h16V7H2V10z M8,17h10v-3H8V17z"}),()=>nt("right")),createButtonConfig("top",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,22h3V6H7V22z M14,16h3V6h-3V16z"}),()=>nt("top")),createButtonConfig("middle",jsxRuntimeExports.jsx("polygon",{points:"22,11 17,11 17,6 14,6 14,11 10,11 10,3 7,3 7,11 1.84,11 1.84,13 7,13 7,21 10,21 10,13 14,13 14,18 17,18 17,13 22,13"}),()=>nt("middle")),createButtonConfig("bottom",jsxRuntimeExports.jsx("path",{d:"M22,22H2v-2h20V22z M10,2H7v16h3V2z M17,8h-3v10h3V8z"}),()=>nt("bottom")),createButtonConfig("vertical",jsxRuntimeExports.jsx("path",{d:"M22,2v2H2V2H22z M7,10.5v3h10v-3H7z M2,20v2h20v-2H2z"}),()=>at("vertical")),createButtonConfig("horizontal",jsxRuntimeExports.jsx("path",{d:"M4,22H2V2h2V22z M22,2h-2v20h2V2z M13.5,7h-3v10h3V7z"}),()=>at("horizontal"))];return jsxRuntimeExports.jsx(Form$3.Item,{label:tt.title,children:jsxRuntimeExports.jsx(Button$2.Group,{children:ot.map(rt=>jsxRuntimeExports.jsx(Button$2,{style:{padding:7},disabled:s.length<=2&&["vertical","horizontal"].includes(rt.id),...rt},rt.id))})})},AlignWidget$1=AlignWidget,WidgetRenderer=a=>{const{widget:s,...$}=a,_=reactExports.useRef(null);return reactExports.useEffect(()=>(_.current&&(_.current.innerHTML="",s({...$,rootElement:_.current})),()=>{_.current&&(_.current.innerHTML="")}),[a.activeSchema]),jsxRuntimeExports.jsx("div",{ref:_})},WidgetRenderer$1=WidgetRenderer,ButtonGroupWidget=a=>{const{activeElements:s,changeSchemas:$,schemas:_,schema:_e}=a,tt=ot=>{const rt=ot.key,st=ot.type,lt=s.map(it=>it.id),et=_.filter(it=>lt.includes(it.id));$(et.map(it=>{const ut=it[rt]??!1,ft=st==="boolean"?!ut:ot.value;return{key:rt,value:ft,schemaId:it.id}}))},nt=ot=>{const rt=ot.key,st=ot.type;let lt=!1;const et=s.map(ut=>ut.id);return _.filter(ut=>et.includes(ut.id)).forEach(ut=>{lt=st==="boolean"?ut[rt]??!1:ut[rt]===ot.value}),lt},at=ot=>{const rt=`data:image/svg+xml;utf8,${encodeURIComponent(ot)}`;return jsxRuntimeExports.jsx("img",{width:17,height:17,src:rt})};return jsxRuntimeExports.jsx(Form$3.Item,{children:jsxRuntimeExports.jsx(Button$2.Group,{children:_e.buttons.map((ot,rt)=>{const st=nt(ot);return jsxRuntimeExports.jsx(Button$2,{type:st?"primary":void 0,ghost:st,onClick:()=>tt(ot),style:{padding:7,zIndex:st?2:0},icon:at(ot.icon)},rt)})})})},ButtonGroupWidget$1=ButtonGroupWidget,{Text:Text$2}=Typography$1,DetailView=a=>{const{token:s}=theme.useToken(),{size:$,changeSchemas:_,deselectSchema:_e,activeSchema:tt,activeElements:nt}=a,at=useForm(),ot=reactExports.useContext(I18nContext),rt=reactExports.useContext(PluginsRegistry),st=reactExports.useContext(OptionsContext),[lt,et]=reactExports.useState({});reactExports.useEffect(()=>{const pt={AlignWidget:mt=>jsxRuntimeExports.jsx(AlignWidget$1,{...mt,...a,options:st}),Divider:()=>jsxRuntimeExports.jsx(Divider$1,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),ButtonGroup:mt=>jsxRuntimeExports.jsx(ButtonGroupWidget$1,{...mt,...a,options:st})};for(const mt of Object.values(rt)){const ct=(mt==null?void 0:mt.propPanel.widgets)||{};Object.entries(ct).forEach(([vt,At])=>{pt[vt]=xt=>jsxRuntimeExports.jsx(WidgetRenderer$1,{...xt,...a,options:st,theme:s,i18n:ot,widget:At})})}et(pt)},[tt,nt,rt,JSON.stringify(st)]),reactExports.useEffect(()=>{const pt={...tt};pt.x=pt.position.x,pt.y=pt.position.y,delete pt.position,pt.key!==(at.getValues()||{}).key&&at.resetFields(),at.setValues(pt)},[at,tt]);const it=pt=>{const mt=[];for(let ct in pt)if(!["id","content"].includes(ct)&&pt[ct]!==tt[ct]){let vt=pt[ct];vt===null&&["rotate","opacity"].includes(ct)&&(vt=void 0),ct==="x"&&(ct="position.x"),ct==="y"&&(ct="position.y"),mt.push({key:ct,value:vt,schemaId:tt.id})}mt.length&&_(mt)},ut=Object.values(rt).find(pt=>(pt==null?void 0:pt.propPanel.defaultSchema.type)===tt.type),ft=ut==null?void 0:ut.propPanel.schema;ft||console.error(`[@pdfme/ui] No propPanel.schema for ${tt.type}.
|
708
708
|
Check this document: https://pdfme.com/docs/custom-schemas`);const ht=Object.entries(rt).map(([pt,mt])=>({label:pt,value:mt==null?void 0:mt.propPanel.defaultSchema.type})),dt=ut.propPanel.defaultSchema,gt={type:"object",column:2,properties:{type:{title:ot("type"),type:"string",widget:"select",props:{options:ht},required:!0,span:10},key:{title:ot("fieldName"),type:"string",required:!0,span:14},"-":{type:"void",widget:"Divider"},align:{title:ot("align"),type:"void",widget:"AlignWidget"},x:{title:"X",type:"number",widget:"inputNumber",required:!0,span:8,min:0},y:{title:"Y",type:"number",widget:"inputNumber",required:!0,span:8,min:0},rotate:{title:ot("rotate"),type:"number",widget:"inputNumber",disabled:(dt==null?void 0:dt.rotate)===void 0,max:360,props:{min:0},span:8},width:{title:ot("width"),type:"number",widget:"inputNumber",required:!0,span:8,props:{min:0}},height:{title:ot("height"),type:"number",widget:"inputNumber",required:!0,span:8,props:{min:0}},opacity:{title:ot("opacity"),type:"number",widget:"inputNumber",disabled:(dt==null?void 0:dt.opacity)===void 0,props:{step:.1,min:0,max:1},span:8}}};if(typeof ft=="function"){const pt=ft({...a,options:st,theme:s,i18n:ot})||{};gt.properties={...gt.properties,...Object.keys(pt).length===0?{}:{"--":{type:"void",widget:"Divider"}},...pt}}else{const pt=ft||{};gt.properties={...gt.properties,...Object.keys(pt).length===0?{}:{"--":{type:"void",widget:"Divider"}},...pt}}return jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsxs("div",{style:{height:40,display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{style:{position:"absolute",zIndex:100,display:"flex",alignItems:"center",justifyContent:"center"},onClick:_e,icon:jsxRuntimeExports.jsx(MenuOutlined$1,{})}),jsxRuntimeExports.jsx(Text$2,{strong:!0,style:{textAlign:"center",width:"100%"},children:ot("editField")})]}),jsxRuntimeExports.jsx(Divider$1,{style:{marginTop:s.marginXS,marginBottom:s.marginXS}}),jsxRuntimeExports.jsx("div",{style:{height:getSidebarContentHeight($.height),overflowY:"auto",overflowX:"hidden"},children:jsxRuntimeExports.jsx(FormRender,{form:at,schema:gt,widgets:lt,watch:{"#":it},locale:"en-US"})})]})},DetailView$1=DetailView,Sidebar=a=>{const{sidebarOpen:s,setSidebarOpen:$,activeElements:_,schemas:_e}=a,{token:tt}=theme.useToken(),nt=()=>_e.filter(ot=>_.map(rt=>rt.id).includes(ot.id)),at=()=>{const ot=nt();return ot[ot.length-1]};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",right:0,zIndex:1,height:"100%",width:s?RIGHT_SIDEBAR_WIDTH:0},children:jsxRuntimeExports.jsxs("div",{children:[jsxRuntimeExports.jsx(Button$2,{style:{position:"absolute",display:"flex",alignItems:"center",justifyContent:"center",top:"1rem",right:"1rem",zIndex:100},icon:s?jsxRuntimeExports.jsx(ArrowRightOutlined$1,{}):jsxRuntimeExports.jsx(ArrowLeftOutlined$1,{}),onClick:()=>$(!s)}),jsxRuntimeExports.jsx("div",{style:{width:RIGHT_SIDEBAR_WIDTH,height:"100%",display:s?"block":"none",top:0,right:0,position:"absolute",padding:"0.7rem 1rem",overflowY:"auto",fontFamily:"'Open Sans', sans-serif",boxSizing:"border-box",background:tt.colorBgLayout},children:jsxRuntimeExports.jsx("div",{children:nt().length===0?jsxRuntimeExports.jsx(ListView$1,{...a}):jsxRuntimeExports.jsx(DetailView$1,{...a,activeSchema:at()})})})]})})},RightSidebar=Sidebar,Wrapper=({children:a,outline:s,onChangeHoveringSchemaId:$,schema:_})=>jsxRuntimeExports.jsx("div",{title:_.key,onMouseEnter:()=>$&&$(_.id),onMouseLeave:()=>$&&$(null),className:SELECTABLE_CLASSNAME,id:_.id,style:{position:"absolute",cursor:_.readOnly?"initial":"pointer",height:_.height*ZOOM,width:_.width*ZOOM,top:_.position.y*ZOOM,left:_.position.x*ZOOM,transform:`rotate(${_.rotate??0}deg)`,opacity:_.opacity??1,outline:s},children:a}),Renderer=a=>{const s=reactExports.useContext(PluginsRegistry),$=reactExports.useContext(OptionsContext),_=reactExports.useContext(I18nContext),{token:_e}=theme.useToken(),{schema:tt,basePdf:nt,value:at,mode:ot,onChange:rt,stopEditing:st,tabIndex:lt,placeholder:et,scale:it}=a,ut=reactExports.useRef(null),ft=reactExports.useRef(new Map);return reactExports.useEffect(()=>{var ht;if(ut.current&&tt.type){const dt=(ht=Object.values(s).find(gt=>(gt==null?void 0:gt.propPanel.defaultSchema.type)===tt.type))==null?void 0:ht.ui;if(!dt){console.error(`[@pdfme/ui] Renderer for type ${tt.type} not found.
|
709
|
-
Check this document: https://pdfme.com/docs/custom-schemas`);return}ut.current.innerHTML="",dt({key:tt.key,value:at,schema:tt,basePdf:nt,rootElement:ut.current,mode:ot,onChange:rt,stopEditing:st,tabIndex:lt,placeholder:et,options:$,theme:_e,i18n:_,pdfJs,_cache:ft.current})}return()=>{ut.current&&(ut.current.innerHTML="")}},[at,JSON.stringify(tt),JSON.stringify($),ot,it]),jsxRuntimeExports.jsx(Wrapper,{...a,children:jsxRuntimeExports.jsx("div",{style:{height:"100%",width:"100%"},ref:ut})})},Renderer$1=Renderer,Draggable$1=a=>{const{scale:s,basePdf:$,plugin:_}=a,{token:_e}=theme.useToken(),tt=_.propPanel.defaultSchema,nt=useDraggable({id:tt.type,data:tt}),{listeners:at,setNodeRef:ot,attributes:rt,transform:st,isDragging:lt}=nt,et={transform:CSS$1.Translate.toString(st)};return jsxRuntimeExports.jsxs("div",{ref:ot,style:et,...at,...rt,children:[lt&&jsxRuntimeExports.jsx("div",{style:{transform:`scale(${s})`},children:jsxRuntimeExports.jsx(Renderer$1,{schema:{...tt,id:tt.type,key:tt.type},basePdf:$,value:tt.content||"",onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:`1px solid ${_e.colorPrimary}`,scale:s},tt.type)}),jsxRuntimeExports.jsx("div",{style:{visibility:lt?"hidden":"visible"},children:a.children})]})},LeftSidebar=({height:a,scale:s,basePdf:$})=>{const{token:_}=theme.useToken(),_e=reactExports.useContext(PluginsRegistry);return jsxRuntimeExports.jsx("div",{style:{left:0,position:"absolute",
|
709
|
+
Check this document: https://pdfme.com/docs/custom-schemas`);return}ut.current.innerHTML="",dt({key:tt.key,value:at,schema:tt,basePdf:nt,rootElement:ut.current,mode:ot,onChange:rt,stopEditing:st,tabIndex:lt,placeholder:et,options:$,theme:_e,i18n:_,pdfJs,_cache:ft.current})}return()=>{ut.current&&(ut.current.innerHTML="")}},[at,JSON.stringify(tt),JSON.stringify($),ot,it]),jsxRuntimeExports.jsx(Wrapper,{...a,children:jsxRuntimeExports.jsx("div",{style:{height:"100%",width:"100%"},ref:ut})})},Renderer$1=Renderer,Draggable$1=a=>{const{scale:s,basePdf:$,plugin:_}=a,{token:_e}=theme.useToken(),tt=_.propPanel.defaultSchema,nt=useDraggable({id:tt.type,data:tt}),{listeners:at,setNodeRef:ot,attributes:rt,transform:st,isDragging:lt}=nt,et={transform:CSS$1.Translate.toString(st)};return jsxRuntimeExports.jsxs("div",{ref:ot,style:et,...at,...rt,children:[lt&&jsxRuntimeExports.jsx("div",{style:{transform:`scale(${s})`},children:jsxRuntimeExports.jsx(Renderer$1,{schema:{...tt,id:tt.type,key:tt.type},basePdf:$,value:tt.content||"",onChangeHoveringSchemaId:()=>{},mode:"viewer",outline:`1px solid ${_e.colorPrimary}`,scale:s},tt.type)}),jsxRuntimeExports.jsx("div",{style:{visibility:lt?"hidden":"visible"},children:a.children})]})},LeftSidebar=({height:a,scale:s,basePdf:$})=>{const{token:_}=theme.useToken(),_e=reactExports.useContext(PluginsRegistry),[tt,nt]=reactExports.useState(!1);return reactExports.useEffect(()=>{const at=()=>{tt&&nt(!1)};return document.addEventListener("mouseup",at),()=>{document.removeEventListener("mouseup",at)}},[tt]),jsxRuntimeExports.jsx("div",{style:{left:0,right:0,position:"absolute",zIndex:1,height:a,width:45,background:_.colorBgLayout,textAlign:"center",overflow:tt?"visible":"auto"},children:Object.entries(_e).map(([at,ot])=>ot!=null&&ot.propPanel.defaultSchema?jsxRuntimeExports.jsx(Draggable$1,{scale:s,basePdf:$,plugin:ot,children:jsxRuntimeExports.jsx(Button$2,{title:at,onMouseDown:()=>{nt(!0)},style:{width:35,height:35,marginTop:"0.25rem",padding:"0.25rem"},children:ot.propPanel.defaultSchema.icon?jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:ot.propPanel.defaultSchema.icon}}):jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:at})})},at):null)})},LeftSidebar$1=LeftSidebar,Paper=a=>{const{paperRefs:s,scale:$,size:_,schemasList:_e,pageSizes:tt,backgrounds:nt,renderPaper:at,renderSchema:ot,hasRulers:rt}=a,st=reactExports.useContext(FontContext),lt=rt?RULER_HEIGHT:0;return tt.length!==nt.length||tt.length!==_e.length?null:jsxRuntimeExports.jsx("div",{style:{transform:`scale(${$})`,transformOrigin:"top left",height:$,width:$},children:nt.map((et,it)=>{const ut=tt[it],ft={width:ut.width*ZOOM,height:ut.height*ZOOM},ht=ft.width*$+lt<_.width?`${(_.width/$-ft.width)/2}px`:`${lt}px`;let dt=it>0?(lt+PAGE_GAP)*(it+1):lt;return rt||(dt+=PAGE_GAP*2),jsxRuntimeExports.jsxs("div",{ref:gt=>{gt&&(s.current[it]=gt)},onMouseDown:gt=>{gt.currentTarget===gt.target&&document&&document.hasFocus()&&document.activeElement instanceof HTMLElement&&document.activeElement.blur()},style:{fontFamily:`'${getFallbackFontName(st)}'`,top:`${dt}px`,left:ht,position:"relative",backgroundImage:`url(${et})`,backgroundSize:`${ft.width}px ${ft.height}px`,...ft},children:[at&&at({paperSize:ft,index:it}),_e[it].map((gt,pt)=>jsxRuntimeExports.jsx("div",{children:ot({schema:gt,index:it===0?pt:pt+_e[it-1].length})},gt.id))]},String(it)+JSON.stringify(ft))})})},Paper$1=Paper;var FUNCTION="function",OBJECT="object",STRING="string",UNDEFINED="undefined",doc=typeof document!==UNDEFINED&&document,OPEN_CLOSED_CHARACTERS=[{open:"(",close:")"},{open:'"',close:'"'},{open:"'",close:"'"},{open:'\\"',close:'\\"'},{open:"\\'",close:"\\'"}],TINY_NUM$1=1e-7,DEFAULT_UNIT_PRESETS={cm:function(a){return a*96/2.54},mm:function(a){return a*96/254},in:function(a){return a*96},pt:function(a){return a*96/72},pc:function(a){return a*96/6},"%":function(a,s){return a*s/100},vw:function(a,s){return s===void 0&&(s=window.innerWidth),a/100*s},vh:function(a,s){return s===void 0&&(s=window.innerHeight),a/100*s},vmax:function(a,s){return s===void 0&&(s=Math.max(window.innerWidth,window.innerHeight)),a/100*s},vmin:function(a,s){return s===void 0&&(s=Math.min(window.innerWidth,window.innerHeight)),a/100*s}};/*! *****************************************************************************
|
710
710
|
Copyright (c) Microsoft Corporation.
|
711
711
|
|
712
712
|
Permission to use, copy, modify, and/or distribute this software for any
|
@@ -1142,4 +1142,4 @@ canvas {
|
|
1142
1142
|
.adder.dragging {
|
1143
1143
|
display: block;
|
1144
1144
|
}
|
1145
|
-
`),GuidesElement=defaultStyled("div",GUIDES_CSS),Guides$1=function(a){__extends(s,a);function s(){var _=a!==null&&a.apply(this,arguments)||this;return _.state={guides:[]},_.scrollPos=0,_.guideElements=[],_.onDragStart=function(_e){var tt=_e.datas,nt=_e.inputEvent,at=_.props.onDragStart;addClass(tt.target,DRAGGING),_.onDrag(_e),at(__assign({},_e,{dragElement:tt.target})),nt.stopPropagation(),nt.preventDefault()},_.onDrag=function(_e){var tt=_.movePos(_e);return _.props.onDrag(__assign({},_e,{dragElement:_e.datas.target})),tt},_.onDragEnd=function(_e){var tt=_e.datas,nt=_e.isDouble,at=_e.distX,ot=_e.distY,rt=_.movePos(_e),st=_.state.guides,lt=_.props,et=lt.onChangeGuides,it=lt.zoom,ut=lt.displayDragPos,ft=lt.digit,ht=lt.lockGuides,dt=parseFloat((rt/it).toFixed(ft||0));if(ut&&(_.displayElement.style.cssText+="display: none;"),removeClass(tt.target,DRAGGING),_.props.onDragEnd(__assign({},_e,{dragElement:tt.target})),tt.fromRuler)rt>=_.scrollPos&&st.indexOf(dt)<0&&_.setState({guides:st.concat([dt])},function(){et({guides:_.state.guides,distX:at,distY:ot,isAdd:!0,isRemove:!1,isChange:!1})});else{var gt=tt.target.getAttribute("data-index"),pt=!1,mt=!1;if(st=st.slice(),nt||dt<_.scrollPos){if(ht&&(ht===!0||ht.indexOf("remove")>-1))return;st.splice(gt,1),pt=!0}else{if(st.indexOf(dt)>-1)return;if(ht&&(ht===!0||ht.indexOf("change")>-1))return;st[gt]=dt,mt=!0}_.setState({guides:st},function(){var ct=_.state.guides;et({distX:at,distY:ot,guides:ct,isAdd:!1,isChange:mt,isRemove:pt})})}},_}var $=s.prototype;return $.render=function(){var _=this.props,_e=_.className,tt=_.type,nt=_.zoom,at=_.style,ot=_.rulerStyle,rt=_.displayDragPos,st=_.cspNonce,lt=_.dragGuideStyle,et=_.portalContainer,it=this.props,ut=this.getTranslateName(),ft={};return PROPERTIES.forEach(function(ht){ht!=="style"&&(ft[ht]=it[ht])}),reactExports.createElement(GuidesElement,{ref:ref(this,"manager"),cspNonce:st,className:prefix("manager",tt)+" "+_e,portalContainer:et,style:at},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler$1,__assign({ref:ref(this,"ruler"),style:ot},ft)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:ut+"("+-this.scrollPos*nt+"px)"}},rt&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:lt}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement")}),this.renderGuides()))},$.renderGuides=function(){var _=this,_e=this.props,tt=_e.type,nt=_e.zoom,at=_e.showGuides,ot=_e.guideStyle,rt=this.getTranslateName(),st=this.state.guides;if(this.guideElements=[],at)return st.map(function(lt,et){return reactExports.createElement("div",{className:prefix("guide",tt),ref:refs(_,"guideElements",et),key:et,"data-index":et,"data-pos":lt,style:__assign({},ot,{transform:rt+"("+lt*nt+"px) translateZ(0px)"})})})},$.componentDidMount=function(){var _=this;this.gesto=new Gesto(this.manager.getElement(),{container:document.body}).on("dragStart",function(_e){var tt=_.props,nt=tt.type,at=tt.zoom,ot=tt.lockGuides;if(ot===!0){_e.stop();return}var rt=_e.inputEvent,st=rt.target,lt=_e.datas,et=_.ruler.canvasElement,it=_.guidesElement,ut=nt==="horizontal",ft=_.originElement.getBoundingClientRect(),ht=getDistElementMatrix(_.manager.getElement()),dt=calculateMatrixDist(ht,[_e.clientX-ft.left,_e.clientY-ft.top]);dt[0]-=it.offsetLeft,dt[1]-=it.offsetTop,dt[ut?1:0]+=_.scrollPos*at,lt.offsetPos=dt,lt.matrix=ht;var gt=ot&&ot.indexOf("add")>-1,pt=ot&&ot.indexOf("remove")>-1,mt=ot&&ot.indexOf("change")>-1;if(st===et){if(gt){_e.stop();return}lt.fromRuler=!0,lt.target=_.adderElement}else if(hasClass(st,GUIDE)){if(pt&&mt){_e.stop();return}lt.target=st}else return _e.stop(),!1;_.onDragStart(_e)}).on("drag",this.onDrag).on("dragEnd",this.onDragEnd),this.setState({guides:this.props.defaultGuides||[]})},$.componentWillUnmount=function(){this.gesto.unset()},$.componentDidUpdate=function(_){_.defaultGuides!==this.props.defaultGuides&&this.setState({guides:this.props.defaultGuides||[]})},$.loadGuides=function(_){this.setState({guides:_})},$.getGuides=function(){return this.state.guides},$.scrollGuides=function(_){var _e=this.props.zoom,tt=this.guidesElement;this.scrollPos=_,tt.style.transform=this.getTranslateName()+"("+-_*_e+"px)";var nt=this.state.guides;this.guideElements.forEach(function(at,ot){at&&(at.style.display=-_+nt[ot]<0?"none":"block")})},$.resize=function(){this.ruler.resize()},$.scroll=function(_){this.ruler.scroll(_)},$.movePos=function(_){var _e=_.datas,tt=_.distX,nt=_.distY,at=this.props,ot=at.type,rt=at.zoom,st=at.snaps,lt=at.snapThreshold,et=at.displayDragPos,it=at.digit,ut=at.dragPosFormat||function(xt){return xt},ft=ot==="horizontal",ht=calculateMatrixDist(_e.matrix,[tt,nt]),dt=_e.offsetPos,gt=ht[0]+dt[0],pt=ht[1]+dt[1],mt=Math.round(ft?pt:gt),ct=parseFloat((mt/rt).toFixed(it||0)),vt=st.slice().sort(function(xt,bt){return Math.abs(ct-xt)-Math.abs(ct-bt)});if(vt.length&&Math.abs(vt[0]*rt-mt)<lt&&(ct=vt[0],mt=ct*rt),et){var At=ot==="horizontal"?[gt,mt]:[mt,pt];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+("translate("+At.map(function(xt){return xt+"px"}).join(", ")+")"),this.displayElement.innerHTML=""+ut(ct)}return _e.target.setAttribute("data-pos",ct),_e.target.style.transform=this.getTranslateName()+"("+mt+"px)",mt},$.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},s.defaultProps={className:"",type:"horizontal",zoom:1,style:{},snapThreshold:5,snaps:[],digit:0,onChangeGuides:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(_){return _},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},portalContainer:null},s}(reactExports.PureComponent);const Guides$2=Guides$1,guideStyle=(a,s,$,_)=>({position:"absolute",top:a,left:s,height:$,width:_,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:$})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-RULER_HEIGHT,-RULER_HEIGHT,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(-RULER_HEIGHT,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(0,-RULER_HEIGHT,a.height,RULER_HEIGHT),type:"vertical",ref:$})]}),Guides=_Guides,Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-RULER_HEIGHT,left:-RULER_HEIGHT,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),Mask$1=Mask,getPaddingStyle=(a,s,$)=>{const _={position:"absolute",background:$,opacity:.25,pointerEvents:"none"};switch(a){case 0:_.top=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 1:_.right=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break;case 2:_.bottom=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 3:_.left=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break}return _},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,$)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle($,s,theme.useToken().token.colorError)},String($)))}),Padding$1=Padding,mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),$=26,_=Math.min(...a.map(({style:tt})=>fmt4Num(tt.top))),_e=Math.max(...a.map(({style:tt})=>fmt4Num(tt.left)+fmt4Num(tt.width)))+10;return jsxRuntimeExports.jsx(Button$2,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:_,left:_e,width:$,height:$,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(CloseOutlined$4,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:$,pageCursor:_,scale:_e,backgrounds:tt,pageSizes:nt,size:at,activeElements:ot,schemasList:rt,hoveringSchemaId:st,onEdit:lt,changeSchemas:et,removeSchemas:it,onChangeHoveringSchemaId:ut,paperRefs:ft,sidebarOpen:ht}=a,{token:dt}=theme.useToken(),gt=reactExports.useContext(PluginsRegistry),pt=reactExports.useRef([]),mt=reactExports.useRef([]),ct=reactExports.useRef(null),[vt,At]=reactExports.useState(!1),[xt,bt]=reactExports.useState(!1),Et=usePrevious(rt[_]),St=Lt=>{Lt.shiftKey&&At(!0)},Bt=Lt=>{(Lt.key==="Shift"||!Lt.shiftKey)&&At(!1),(Lt.key==="Escape"||Lt.key==="Esc")&&bt(!1)},Ot=reactExports.useCallback(()=>{window.addEventListener("keydown",St),window.addEventListener("keyup",Bt)},[]),Tt=reactExports.useCallback(()=>{window.removeEventListener("keydown",St),window.removeEventListener("keyup",Bt)},[]);reactExports.useEffect(()=>(Ot(),Tt),[Ot,Tt]),reactExports.useEffect(()=>{var Pt,Dt;if((Pt=ct.current)==null||Pt.updateRect(),!Et)return;const Lt=JSON.stringify(Et[_]||{}),$t=JSON.stringify(rt[_]||{});Lt===$t&&((Dt=ct.current)==null||Dt.updateRect())},[_,rt,Et]);const wt=({target:Lt,top:$t,left:Pt})=>{const{width:Dt,height:Ut}=Lt.style,Vt=fmt(Dt),Qt=fmt(Ut),qt=$t/ZOOM,Zt=Pt/ZOOM,{width:ar,height:Jt}=nt[_];let rr=0,Yt=0,Kt=0,nr=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;rr=tr*ZOOM,Yt=ir,Kt=sr,nr=cr*ZOOM}qt+Qt>Jt-Kt?Lt.style.top=`${(Jt-Qt-Kt)*ZOOM}px`:Lt.style.top=`${$t<rr?rr:$t}px`,Zt+Vt>ar-Yt?Lt.style.left=`${(ar-Vt-Yt)*ZOOM}px`:Lt.style.left=`${Pt<nr?nr:Pt}px`},Ct=({target:Lt})=>{const{top:$t,left:Pt}=Lt.style;et([{key:"position.y",value:fmt($t),schemaId:Lt.id},{key:"position.x",value:fmt(Pt),schemaId:Lt.id}])},It=({targets:Lt})=>{const $t=Lt.map(({style:{top:Pt,left:Dt},id:Ut})=>[{key:"position.y",value:fmt(Pt),schemaId:Ut},{key:"position.x",value:fmt(Dt),schemaId:Ut}]);et(flatten($t))},yt=({target:Lt,rotate:$t})=>{Lt.style.transform=`rotate(${$t}deg)`},Rt=({target:Lt})=>{const{transform:$t}=Lt.style,Pt=Number($t.replace("rotate(","").replace("deg)","")),Dt=normalizeRotate(Pt);et([{key:"rotate",value:Dt,schemaId:Lt.id}])},kt=({targets:Lt})=>{const $t=Lt.map(({style:{transform:Pt},id:Dt})=>{const Ut=Number(Pt.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(Ut),schemaId:Dt}]});et(flatten($t))},jt=({target:Lt})=>{const{id:$t,style:Pt}=Lt,{width:Dt,height:Ut,top:Vt,left:Qt}=Pt;et([{key:"position.x",value:fmt(Qt),schemaId:$t},{key:"position.y",value:fmt(Vt),schemaId:$t},{key:"width",value:fmt(Dt),schemaId:$t},{key:"height",value:fmt(Ut),schemaId:$t}]);const qt=rt[_].find(Zt=>Zt.id===$t);qt&&(qt.position.x=fmt(Qt),qt.position.y=fmt(Vt),qt.width=fmt(Dt),qt.height=fmt(Ut))},Ht=({targets:Lt})=>{const $t=Lt.map(({style:{width:Pt,height:Dt,top:Ut,left:Vt},id:Qt})=>[{key:"width",value:fmt(Pt),schemaId:Qt},{key:"height",value:fmt(Dt),schemaId:Qt},{key:"position.y",value:fmt(Ut),schemaId:Qt},{key:"position.x",value:fmt(Vt),schemaId:Qt}]);et(flatten($t))},Ft=({target:Lt,width:$t,height:Pt,direction:Dt})=>{if(!Lt)return;let Ut=0,Vt=0,Qt=0,qt=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;Ut=tr*ZOOM,Vt=mm2px(ir),Qt=mm2px(sr),qt=cr*ZOOM}const Zt=mm2px(nt[_].width),ar=mm2px(nt[_].height),Jt={width:`${$t}px`,height:`${Pt}px`},rr=Lt.style;let Yt=fmt4Num(rr.left)+(fmt4Num(rr.width)-$t),Kt=fmt4Num(rr.top)+(fmt4Num(rr.height)-Pt);Yt<qt&&(Yt=qt),Kt<Ut&&(Kt=Ut),Yt+$t>Zt-Vt&&(Jt.width=`${Zt-Vt-Yt}px`),Kt+Pt>ar-Qt&&(Jt.height=`${ar-Qt-Kt}px`);const nr=Dt.toString();isTopLeftResize(nr)?(Jt.top=`${Kt}px`,Jt.left=`${Yt}px`):nr==="1,-1"?Jt.top=`${Kt}px`:nr==="-1,1"&&(Jt.left=`${Yt}px`),Object.assign(rr,Jt)},_t=(Lt,$t)=>Lt[$t]&&Lt[$t].getGuides().map(Pt=>Pt*ZOOM),Nt=Lt=>{Lt.inputEvent.stopPropagation(),bt(!0)},Mt=reactExports.useMemo(()=>{const $t=(rt[_]||[]).filter(Ut=>ot.map(Vt=>Vt.id).includes(Ut.id)).map(Ut=>Ut.type),Pt=[...new Set($t)],Dt=Object.values(gt).map(Ut=>Ut==null?void 0:Ut.propPanel.defaultSchema);return Pt.every(Ut=>{var Vt;return((Vt=Dt.find(Qt=>Qt.type===Ut))==null?void 0:Vt.rotate)!==void 0})},[ot,_,rt,gt]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:ht?RIGHT_SIDEBAR_WIDTH:0,...at},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:ft.current[_],continueSelect:vt,onDragStart:Lt=>{var Dt,Ut;const{inputEvent:$t}=Lt,Pt=(Dt=ct.current)==null?void 0:Dt.isMoveableElement($t.target);($t.type==="touchstart"&&Lt.isTrusted||Pt)&&Lt.stop(),ft.current[_]===$t.target&<([]),((Ut=$t.target)==null?void 0:Ut.id)===DELETE_BTN_ID&&it(ot.map(Vt=>Vt.id))},onSelect:({added:Lt,removed:$t,selected:Pt,inputEvent:Dt})=>{const Ut=Dt.type==="mousedown";let Vt=Ut?Pt:[];!Ut&&Lt.length>0&&(Vt=ot.concat(Lt)),!Ut&&$t.length>0&&(Vt=ot.filter(Qt=>!$t.includes(Qt))),lt(Vt),Vt!=ot&&bt(!1),Dt.shiftKey||At(!1)}}),jsxRuntimeExports.jsx(Paper$1,{paperRefs:ft,scale:_e,size:at,schemasList:rt,pageSizes:nt,backgrounds:tt,hasRulers:!0,renderPaper:({index:Lt,paperSize:$t})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!xt&&ot.length>0&&_===Lt&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:ot}),jsxRuntimeExports.jsx(Padding$1,{basePdf:$}),jsxRuntimeExports.jsx(Guides,{paperSize:$t,horizontalRef:Pt=>{Pt&&(mt.current[Lt]=Pt)},verticalRef:Pt=>{Pt&&(pt.current[Lt]=Pt)}}),_!==Lt?jsxRuntimeExports.jsx(Mask$1,{width:$t.width+RULER_HEIGHT,height:$t.height+RULER_HEIGHT}):!xt&&jsxRuntimeExports.jsx(Moveable,{ref:ct,target:ot,bounds:{left:0,top:0,bottom:$t.height,right:$t.width},horizontalGuidelines:_t(mt.current,Lt),verticalGuidelines:_t(pt.current,Lt),keepRatio:vt,rotatable:Mt,onDrag:wt,onDragEnd:Ct,onDragGroupEnd:It,onRotate:yt,onRotateEnd:Rt,onRotateGroupEnd:kt,onResize:Ft,onResizeEnd:jt,onResizeGroupEnd:Ht,onClick:Nt})]}),renderSchema:({schema:Lt})=>jsxRuntimeExports.jsx(Renderer$1,{schema:Lt,basePdf:$,value:Lt.content||"",onChangeHoveringSchemaId:ut,mode:xt&&ot.map($t=>$t.id).includes(Lt.id)?"designer":"viewer",onChange:$t=>{const Pt=Array.isArray($t)?$t:[$t];et(Pt.map(({key:Dt,value:Ut})=>({key:Dt,value:Ut,schemaId:Lt.id})))},stopEditing:()=>bt(!1),outline:`1px ${st===Lt.id?"solid":"dashed"} ${Lt.readOnly&&st!==Lt.id?"transparent":dt.colorPrimary}`,scale:_e},Lt.id)})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>jsxRuntimeExports.jsx(Spin$1,{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},indicator:jsxRuntimeExports.jsx(LoadingOutlined$1,{style:{fontSize:50},spin:!0})}),Spinner$1=Spinner,Root=({size:a,scale:s,children:$},_)=>{const _e=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const nt=Object.entries(_e).map(([at,{data:ot}])=>new FontFace(at,typeof ot=="string"?`url(${ot})`:ot,{display:"swap"})).filter(at=>!document.fonts.has(at));Promise.allSettled(nt.map(at=>at.load())).then(at=>{at.forEach(ot=>{ot.status==="fulfilled"&&document.fonts.add(ot.value)})})},[_e]),jsxRuntimeExports.jsx("div",{ref:_,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner$1,{}):$})})},Root$1=reactExports.forwardRef(Root),ErrorScreen=({size:a,error:s})=>{const $=reactExports.useContext(I18nContext),{token:_}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:_.colorBgLayout},children:jsxRuntimeExports.jsx(Result$2,{icon:null,title:"ERROR",subTitle:$("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},ErrorScreen$1=ErrorScreen,{Text:Text$1}=Typography$1,Zoom=({zoomLevel:a,setZoomLevel:s,style:$})=>{const nt=a-.25,at=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:.25>=nt,onClick:()=>s(nt),icon:jsxRuntimeExports.jsx(MinusOutlined$1,{style:{color:$.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:$.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:2<at,onClick:()=>s(at),icon:jsxRuntimeExports.jsx(PlusOutlined$4,{style:{color:$.textStyle.color}})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:$,style:_})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a<=0,onClick:()=>$(a-1),children:jsxRuntimeExports.jsx(LeftOutlined$1,{style:{color:_.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:_.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a+1>=s,onClick:()=>$(a+1),children:jsxRuntimeExports.jsx(RightOutlined$1,{style:{color:_.textStyle.color}})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown$1,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$2,{type:"text",children:jsxRuntimeExports.jsx(EllipsisOutlined$1,{style:{color:s.textStyle.color}})})}),CtlBar=a=>{const{token:s}=theme.useToken(),$=reactExports.useContext(I18nContext),{size:_,pageCursor:_e,pageNum:tt,setPageCursor:nt,zoomLevel:at,setZoomLevel:ot,addPageAfter:rt,removePage:st}=a,lt=[];rt&<.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:rt,children:$("addPageAfter")})}),st&&tt>1&&_e!==0&<.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:st,children:$("removePage")})});const et=300,it=lt.length>0?50:0,ut=(tt>1?et:et/2)+it,ft={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:_.width},children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${ut/2}px)`,width:ut,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[tt>1&&jsxRuntimeExports.jsx(Pager,{style:{textStyle:ft},pageCursor:_e,pageNum:tt,setPageCursor:nt}),jsxRuntimeExports.jsx(Zoom,{style:{textStyle:ft},zoomLevel:at,setZoomLevel:ot}),lt.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:lt,style:{textStyle:ft}})]})})},CtlBar$1=CtlBar,scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:$,onChangeTemplate:_,onPageCursorChange:_e})=>{const tt=reactExports.useRef([]),nt=reactExports.useRef([]),at=reactExports.useRef(null),ot=reactExports.useRef([]),rt=reactExports.useContext(I18nContext),st=reactExports.useContext(PluginsRegistry),[lt,et]=reactExports.useState(null),[it,ut]=reactExports.useState([]),[ft,ht]=reactExports.useState([[]]),[dt,gt]=reactExports.useState(0),[pt,mt]=reactExports.useState(1),[ct,vt]=reactExports.useState(!0),[At,xt]=reactExports.useState(null),{backgrounds:bt,pageSizes:Et,scale:St,error:Bt,refresh:Ot}=useUIPreProcessor({template:a,size:s,zoomLevel:pt}),Tt=$t=>{ut($t),et(null)},wt=()=>{ut([]),et(null)};useScrollPageCursor({ref:at,pageSizes:Et,scale:St,pageCursor:dt,onChangePageCursor:$t=>{gt($t),_e($t),wt()}});const Ct=reactExports.useCallback($t=>{nt.current=[],tt.current.push(cloneDeep$2(ft[dt]));const Pt=cloneDeep$2(ft);Pt[dt]=$t,ht(Pt),_(schemasList2template(Pt,a.basePdf))},[a,ft,dt,_]),It=reactExports.useCallback($t=>{Ct(ft[dt].filter(Pt=>!$t.includes(Pt.id))),wt()},[ft,dt,Ct]),yt=reactExports.useCallback($t=>{changeSchemas({objs:$t,schemas:ft[dt],basePdf:a.basePdf,pluginsRegistry:st,pageSize:Et[dt],commitSchemas:Ct})},[Ct,dt,ft,st,Et,a.basePdf]);useInitEvents({pageCursor:dt,pageSizes:Et,activeElements:it,template:a,schemasList:ft,changeSchemas:yt,commitSchemas:Ct,removeSchemas:It,onSaveTemplate:$,past:tt,future:nt,setSchemasList:ht,onEdit:Tt,onEditEnd:wt});const Rt=reactExports.useCallback(async $t=>{var Dt;const Pt=await template2SchemasList($t);ht(Pt),wt(),gt(0),(Dt=at.current)!=null&&Dt.scroll&&at.current.scroll({top:0,behavior:"smooth"})},[]),kt=$t=>{const[Pt,Dt,Ut,Vt]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],Qt=Et[dt],qt=(ar,Jt,rr)=>Math.min(Math.max(ar,Jt),rr),Zt={id:uuid$6(),key:`${rt("field")}${ft[dt].length+1}`,...$t,position:{x:qt(Vt,$t.position.x,Qt.width-Dt-$t.width),y:qt(Pt,$t.position.y,Qt.height-Ut-$t.height)}};if($t.position.y===0){const ar=ot.current[dt],Jt=ar?ar.getBoundingClientRect().top:0;Zt.position.y=Jt>0?Pt:Et[dt].height/2}Ct(ft[dt].concat(Zt)),setTimeout(()=>Tt([document.getElementById(Zt.id)]))},jt=$t=>{Ct($t)},Ht=$t=>{et($t)},Ft=async($t,Pt)=>{gt(Pt);const Dt=schemasList2template($t,a.basePdf);_(Dt),await Rt(Dt),Ot(Dt),setTimeout(()=>at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,Pt,St),0))},_t=()=>{if(dt===0||!window.confirm(rt("removePageConfirm")))return;const $t=cloneDeep$2(ft);$t.splice(dt,1),Ft($t,dt-1)},Nt=()=>{const $t=cloneDeep$2(ft);$t.splice(dt+1,0,[]),Ft($t,dt+1)};At!==a&&(xt(a),Rt(a));const Mt={width:ct?s.width-RIGHT_SIDEBAR_WIDTH:s.width,height:s.height};if(Bt)return jsxRuntimeExports.jsx(ErrorScreen$1,{size:s,error:Bt});const Lt=isBlankPdf(a.basePdf)?{addPageAfter:Nt,removePage:_t}:{};return jsxRuntimeExports.jsx(Root$1,{size:s,scale:St,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:$t=>{var rr,Yt;if(!$t.active)return;const Pt=$t.active,Dt=ot.current[dt].getBoundingClientRect(),Ut=((rr=Pt.rect.current.initial)==null?void 0:rr.left)||0,Vt=((Yt=Pt.rect.current.initial)==null?void 0:Yt.top)||0,Qt=Dt.left-Ut+scaleDragPosAdjustment(20,St),qt=Dt.top-Vt,Zt=($t.delta.y-qt)/St,ar=($t.delta.x-Qt)/St,Jt={x:px2mm(Math.max(0,ar)),y:px2mm(Math.max(0,Zt))};kt({...Pt.data.current,position:Jt})},onDragStart:wt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:Mt,pageCursor:dt,pageNum:ft.length,setPageCursor:$t=>{at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,$t,St),gt($t),wt())},zoomLevel:pt,setZoomLevel:mt,...Lt}),jsxRuntimeExports.jsx(LeftSidebar$1,{height:at.current?at.current.clientHeight:0,scale:St,basePdf:a.basePdf}),jsxRuntimeExports.jsx(RightSidebar,{hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:at.current?at.current.clientHeight:0,size:s,pageSize:Et[dt]??[],activeElements:it,schemas:ft[dt]??[],changeSchemas:yt,onSortEnd:jt,onEdit:$t=>{const Pt=document.getElementById($t);Pt&&Tt([Pt])},onEditEnd:wt,deselectSchema:wt,sidebarOpen:ct,setSidebarOpen:vt}),jsxRuntimeExports.jsx(Canvas$1,{ref:at,paperRefs:ot,basePdf:a.basePdf,hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:dt,scale:St,size:Mt,pageSizes:Et,backgrounds:bt,activeElements:it,schemasList:ft,changeSchemas:yt,removeSchemas:It,sidebarOpen:ct,onEdit:Tt})]})})},DesignerComponent=TemplateEditor,defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let $={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(_=>{isObject(s[_])?_ in a?$[_]=deepMerge(a[_],s[_]):Object.assign($,{[_]:s[_]}):Object.assign($,{[_]:s[_]})}),$},AppContextProvider=({children:a,lang:s,font:$,plugins:_,options:_e})=>{let tt=defaultTheme;_e.theme&&(tt=deepMerge(tt,_e.theme));let nt=getDict(s);return _e.labels&&(nt=deepMerge(nt,_e.labels)),jsxRuntimeExports.jsx(ThemeConfigProvider,{theme:tt,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:at=>i18n(at,nt),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:$,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:_,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:_e,children:a})})})})})},AppContextProvider$1=AppContextProvider;class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$2(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}getPageCursor(){return this.pageCursor}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(DesignerComponent,{template:this.template,onSaveTemplate:s=>{this.template=s,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:s=>{this.pageCursor=s},size:this.size})}),this.domContainer)}}const Designer$1=Designer,{Text}=Typography$1,icons={left:LeftOutlined$1,right:RightOutlined$1,doubleLeft:DoubleLeftOutlined$1,doubleRight:DoubleRightOutlined$1},UnitButton=({type:a,onClick:s,disabled:$,textStyle:_})=>{const _e=icons[a];return jsxRuntimeExports.jsx(Button$2,{type:"text",onClick:s,disabled:$,children:jsxRuntimeExports.jsx(_e,{style:{color:_.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:$,setUnitCursor:_})=>{if($<=1)return null;const{token:_e}=theme.useToken(),tt={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:_e.paddingSM,borderRadius:_e.borderRadius,backgroundColor:_e.colorBgMask},nt={color:_e.colorWhite,fontSize:_e.fontSize,margin:_e.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${tt.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...tt},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>_(0),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>_(s-1),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]})]}),s+1<$&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...tt},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>_(s+1),disabled:s+1>=$,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>_($-1),disabled:s+1>=$,textStyle:nt})]})]})})},UnitPager$1=UnitPager,_cache=new Map,Preview=({template:a,inputs:s,size:$,onChangeInput:_})=>{const{token:_e}=theme.useToken(),tt=reactExports.useContext(FontContext),nt=reactExports.useRef(null),at=reactExports.useRef([]),[ot,rt]=reactExports.useState(0),[st,lt]=reactExports.useState(0),[et,it]=reactExports.useState(1),[ut,ft]=reactExports.useState([[]]),{backgrounds:ht,pageSizes:dt,scale:gt,error:pt,refresh:mt}=useUIPreProcessor({template:a,size:$,zoomLevel:et}),ct=!!_,vt=s[ot],At=bt=>{getDynamicTemplate({template:bt,input:vt,options:{font:tt},_cache,modifyTemplate:St=>modifyTemplateForTable(St),getDynamicHeight:(St,Bt)=>Bt.schema.type!=="table"?Promise.resolve(Bt.schema.height):getDynamicHeightForTable(St,Bt)}).then(async St=>{const Bt=await template2SchemasList(St);ft(Bt),await mt(St)}).catch(St=>console.error("[@pdfme/ui] ",St))};reactExports.useEffect(()=>{ot>s.length-1&&rt(s.length-1),At(a)},[a,s,$]),useScrollPageCursor({ref:nt,pageSizes:dt,scale:gt,pageCursor:st,onChangePageCursor:lt});const xt=({key:bt,value:Et})=>_&&_({index:ot,key:bt,value:Et});return pt?jsxRuntimeExports.jsx(ErrorScreen$1,{size:$,error:pt}):jsxRuntimeExports.jsxs(Root$1,{size:$,scale:gt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:$,pageCursor:st,pageNum:ut.length,setPageCursor:bt=>{nt.current&&(nt.current.scrollTop=getPagesScrollTopByIndex(dt,bt,gt),lt(bt))},zoomLevel:et,setZoomLevel:it}),jsxRuntimeExports.jsx(UnitPager$1,{size:$,unitCursor:ot,unitNum:s.length,setUnitCursor:rt}),jsxRuntimeExports.jsx("div",{ref:nt,style:{...$,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper$1,{paperRefs:at,scale:gt,size:$,schemasList:ut,pageSizes:dt,backgrounds:ht,renderSchema:({schema:bt,index:Et})=>{const{key:St,readOnly:Bt}=bt,Ot=Bt?String(bt.content)||"":String(vt&&vt[St]||"");return jsxRuntimeExports.jsx(Renderer$1,{schema:bt,basePdf:a.basePdf,value:Ot,mode:ct?"form":"viewer",placeholder:bt.content,tabIndex:Et+100,onChange:Tt=>{const wt=Array.isArray(Tt)?Tt:[Tt];let Ct=!1;wt.forEach(({key:It,value:yt})=>{if(It==="content"){const Rt=yt,kt=(vt==null?void 0:vt[St])||"";if(Rt===kt)return;xt({key:St,value:Rt}),Ct=!0}else{const Rt=ut[st].find(kt=>kt.id===bt.id);if(!Rt)return;Rt[It]=yt}}),Ct&&At(a),ft([...ut])},outline:ct&&!bt.readOnly?`1px dashed ${_e.colorPrimary}`:"transparent",scale:gt},bt.id)}})})]})},Preview$1=Preview;class Form extends PreviewUI{constructor(s){super(s)}onChangeInput(s){this.onChangeInputCallback=s}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:$,value:_,key:_e}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:$,value:_,key:_e}),this.inputs&&this.inputs[$]&&this.inputs[$][_e]!==_&&(this.inputs[$][_e]=_,this.render())}})}),this.domContainer)}}const Form$1=Form;class Viewer extends PreviewUI{constructor(s){super(s)}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs})}),this.domContainer)}}const Viewer$1=Viewer;exports.Designer=Designer$1,exports.Form=Form$1,exports.Viewer=Viewer$1,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
1145
|
+
`),GuidesElement=defaultStyled("div",GUIDES_CSS),Guides$1=function(a){__extends(s,a);function s(){var _=a!==null&&a.apply(this,arguments)||this;return _.state={guides:[]},_.scrollPos=0,_.guideElements=[],_.onDragStart=function(_e){var tt=_e.datas,nt=_e.inputEvent,at=_.props.onDragStart;addClass(tt.target,DRAGGING),_.onDrag(_e),at(__assign({},_e,{dragElement:tt.target})),nt.stopPropagation(),nt.preventDefault()},_.onDrag=function(_e){var tt=_.movePos(_e);return _.props.onDrag(__assign({},_e,{dragElement:_e.datas.target})),tt},_.onDragEnd=function(_e){var tt=_e.datas,nt=_e.isDouble,at=_e.distX,ot=_e.distY,rt=_.movePos(_e),st=_.state.guides,lt=_.props,et=lt.onChangeGuides,it=lt.zoom,ut=lt.displayDragPos,ft=lt.digit,ht=lt.lockGuides,dt=parseFloat((rt/it).toFixed(ft||0));if(ut&&(_.displayElement.style.cssText+="display: none;"),removeClass(tt.target,DRAGGING),_.props.onDragEnd(__assign({},_e,{dragElement:tt.target})),tt.fromRuler)rt>=_.scrollPos&&st.indexOf(dt)<0&&_.setState({guides:st.concat([dt])},function(){et({guides:_.state.guides,distX:at,distY:ot,isAdd:!0,isRemove:!1,isChange:!1})});else{var gt=tt.target.getAttribute("data-index"),pt=!1,mt=!1;if(st=st.slice(),nt||dt<_.scrollPos){if(ht&&(ht===!0||ht.indexOf("remove")>-1))return;st.splice(gt,1),pt=!0}else{if(st.indexOf(dt)>-1)return;if(ht&&(ht===!0||ht.indexOf("change")>-1))return;st[gt]=dt,mt=!0}_.setState({guides:st},function(){var ct=_.state.guides;et({distX:at,distY:ot,guides:ct,isAdd:!1,isChange:mt,isRemove:pt})})}},_}var $=s.prototype;return $.render=function(){var _=this.props,_e=_.className,tt=_.type,nt=_.zoom,at=_.style,ot=_.rulerStyle,rt=_.displayDragPos,st=_.cspNonce,lt=_.dragGuideStyle,et=_.portalContainer,it=this.props,ut=this.getTranslateName(),ft={};return PROPERTIES.forEach(function(ht){ht!=="style"&&(ft[ht]=it[ht])}),reactExports.createElement(GuidesElement,{ref:ref(this,"manager"),cspNonce:st,className:prefix("manager",tt)+" "+_e,portalContainer:et,style:at},reactExports.createElement("div",{className:prefix("guide-origin"),ref:ref(this,"originElement")}),reactExports.createElement(Ruler$1,__assign({ref:ref(this,"ruler"),style:ot},ft)),reactExports.createElement("div",{className:GUIDES,ref:ref(this,"guidesElement"),style:{transform:ut+"("+-this.scrollPos*nt+"px)"}},rt&&reactExports.createElement("div",{className:DISPLAY_DRAG,ref:ref(this,"displayElement"),style:lt}),reactExports.createElement("div",{className:ADDER,ref:ref(this,"adderElement")}),this.renderGuides()))},$.renderGuides=function(){var _=this,_e=this.props,tt=_e.type,nt=_e.zoom,at=_e.showGuides,ot=_e.guideStyle,rt=this.getTranslateName(),st=this.state.guides;if(this.guideElements=[],at)return st.map(function(lt,et){return reactExports.createElement("div",{className:prefix("guide",tt),ref:refs(_,"guideElements",et),key:et,"data-index":et,"data-pos":lt,style:__assign({},ot,{transform:rt+"("+lt*nt+"px) translateZ(0px)"})})})},$.componentDidMount=function(){var _=this;this.gesto=new Gesto(this.manager.getElement(),{container:document.body}).on("dragStart",function(_e){var tt=_.props,nt=tt.type,at=tt.zoom,ot=tt.lockGuides;if(ot===!0){_e.stop();return}var rt=_e.inputEvent,st=rt.target,lt=_e.datas,et=_.ruler.canvasElement,it=_.guidesElement,ut=nt==="horizontal",ft=_.originElement.getBoundingClientRect(),ht=getDistElementMatrix(_.manager.getElement()),dt=calculateMatrixDist(ht,[_e.clientX-ft.left,_e.clientY-ft.top]);dt[0]-=it.offsetLeft,dt[1]-=it.offsetTop,dt[ut?1:0]+=_.scrollPos*at,lt.offsetPos=dt,lt.matrix=ht;var gt=ot&&ot.indexOf("add")>-1,pt=ot&&ot.indexOf("remove")>-1,mt=ot&&ot.indexOf("change")>-1;if(st===et){if(gt){_e.stop();return}lt.fromRuler=!0,lt.target=_.adderElement}else if(hasClass(st,GUIDE)){if(pt&&mt){_e.stop();return}lt.target=st}else return _e.stop(),!1;_.onDragStart(_e)}).on("drag",this.onDrag).on("dragEnd",this.onDragEnd),this.setState({guides:this.props.defaultGuides||[]})},$.componentWillUnmount=function(){this.gesto.unset()},$.componentDidUpdate=function(_){_.defaultGuides!==this.props.defaultGuides&&this.setState({guides:this.props.defaultGuides||[]})},$.loadGuides=function(_){this.setState({guides:_})},$.getGuides=function(){return this.state.guides},$.scrollGuides=function(_){var _e=this.props.zoom,tt=this.guidesElement;this.scrollPos=_,tt.style.transform=this.getTranslateName()+"("+-_*_e+"px)";var nt=this.state.guides;this.guideElements.forEach(function(at,ot){at&&(at.style.display=-_+nt[ot]<0?"none":"block")})},$.resize=function(){this.ruler.resize()},$.scroll=function(_){this.ruler.scroll(_)},$.movePos=function(_){var _e=_.datas,tt=_.distX,nt=_.distY,at=this.props,ot=at.type,rt=at.zoom,st=at.snaps,lt=at.snapThreshold,et=at.displayDragPos,it=at.digit,ut=at.dragPosFormat||function(xt){return xt},ft=ot==="horizontal",ht=calculateMatrixDist(_e.matrix,[tt,nt]),dt=_e.offsetPos,gt=ht[0]+dt[0],pt=ht[1]+dt[1],mt=Math.round(ft?pt:gt),ct=parseFloat((mt/rt).toFixed(it||0)),vt=st.slice().sort(function(xt,bt){return Math.abs(ct-xt)-Math.abs(ct-bt)});if(vt.length&&Math.abs(vt[0]*rt-mt)<lt&&(ct=vt[0],mt=ct*rt),et){var At=ot==="horizontal"?[gt,mt]:[mt,pt];this.displayElement.style.cssText+="display: block;transform: translate(-50%, -50%) "+("translate("+At.map(function(xt){return xt+"px"}).join(", ")+")"),this.displayElement.innerHTML=""+ut(ct)}return _e.target.setAttribute("data-pos",ct),_e.target.style.transform=this.getTranslateName()+"("+mt+"px)",mt},$.getTranslateName=function(){return this.props.type==="horizontal"?"translateY":"translateX"},s.defaultProps={className:"",type:"horizontal",zoom:1,style:{},snapThreshold:5,snaps:[],digit:0,onChangeGuides:function(){},onDragStart:function(){},onDrag:function(){},onDragEnd:function(){},displayDragPos:!1,dragPosFormat:function(_){return _},defaultGuides:[],lockGuides:!1,showGuides:!0,guideStyle:{},dragGuideStyle:{},portalContainer:null},s}(reactExports.PureComponent);const Guides$2=Guides$1,guideStyle=(a,s,$,_)=>({position:"absolute",top:a,left:s,height:$,width:_,background:"#333333"}),_Guides=({paperSize:a,horizontalRef:s,verticalRef:$})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[jsxRuntimeExports.jsx("div",{className:"ruler-container",style:guideStyle(-RULER_HEIGHT,-RULER_HEIGHT,RULER_HEIGHT,RULER_HEIGHT)}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(-RULER_HEIGHT,0,RULER_HEIGHT,a.width),type:"horizontal",ref:s}),jsxRuntimeExports.jsx(Guides$2,{zoom:ZOOM,style:guideStyle(0,-RULER_HEIGHT,a.height,RULER_HEIGHT),type:"vertical",ref:$})]}),Guides=_Guides,Mask=({width:a,height:s})=>jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:-RULER_HEIGHT,left:-RULER_HEIGHT,zIndex:100,width:a,height:s,background:theme.useToken().token.colorBgMask}}),Mask$1=Mask,getPaddingStyle=(a,s,$)=>{const _={position:"absolute",background:$,opacity:.25,pointerEvents:"none"};switch(a){case 0:_.top=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 1:_.right=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break;case 2:_.bottom=0,_.height=`${s*ZOOM}px`,_.left=0,_.right=0;break;case 3:_.left=0,_.width=`${s*ZOOM}px`,_.top=0,_.bottom=0;break}return _},Padding=({basePdf:a})=>jsxRuntimeExports.jsx(jsxRuntimeExports.Fragment,{children:isBlankPdf(a)&&a.padding.map((s,$)=>jsxRuntimeExports.jsx("div",{style:getPaddingStyle($,s,theme.useToken().token.colorError)},String($)))}),Padding$1=Padding,mm2px=a=>a*3.7795275591,DELETE_BTN_ID=uuid$6(),fmt4Num=a=>Number(a.replace("px","")),fmt=a=>round(fmt4Num(a)/ZOOM,2),isTopLeftResize=a=>a==="-1,-1"||a==="-1,0"||a==="0,-1",normalizeRotate=a=>(a%360+360)%360,DeleteButton=({activeElements:a})=>{const{token:s}=theme.useToken(),$=26,_=Math.min(...a.map(({style:tt})=>fmt4Num(tt.top))),_e=Math.max(...a.map(({style:tt})=>fmt4Num(tt.left)+fmt4Num(tt.width)))+10;return jsxRuntimeExports.jsx(Button$2,{id:DELETE_BTN_ID,style:{position:"absolute",zIndex:1,top:_,left:_e,width:$,height:$,padding:2,display:"flex",alignItems:"center",justifyContent:"center",borderRadius:s.borderRadius,color:s.colorWhite,background:s.colorPrimary},children:jsxRuntimeExports.jsx(CloseOutlined$4,{style:{pointerEvents:"none"}})})},Canvas=(a,s)=>{const{basePdf:$,pageCursor:_,scale:_e,backgrounds:tt,pageSizes:nt,size:at,activeElements:ot,schemasList:rt,hoveringSchemaId:st,onEdit:lt,changeSchemas:et,removeSchemas:it,onChangeHoveringSchemaId:ut,paperRefs:ft,sidebarOpen:ht}=a,{token:dt}=theme.useToken(),gt=reactExports.useContext(PluginsRegistry),pt=reactExports.useRef([]),mt=reactExports.useRef([]),ct=reactExports.useRef(null),[vt,At]=reactExports.useState(!1),[xt,bt]=reactExports.useState(!1),Et=usePrevious(rt[_]),St=Lt=>{Lt.shiftKey&&At(!0)},Bt=Lt=>{(Lt.key==="Shift"||!Lt.shiftKey)&&At(!1),(Lt.key==="Escape"||Lt.key==="Esc")&&bt(!1)},Ot=reactExports.useCallback(()=>{window.addEventListener("keydown",St),window.addEventListener("keyup",Bt)},[]),Tt=reactExports.useCallback(()=>{window.removeEventListener("keydown",St),window.removeEventListener("keyup",Bt)},[]);reactExports.useEffect(()=>(Ot(),Tt),[Ot,Tt]),reactExports.useEffect(()=>{var Pt,Dt;if((Pt=ct.current)==null||Pt.updateRect(),!Et)return;const Lt=JSON.stringify(Et[_]||{}),$t=JSON.stringify(rt[_]||{});Lt===$t&&((Dt=ct.current)==null||Dt.updateRect())},[_,rt,Et]);const wt=({target:Lt,top:$t,left:Pt})=>{const{width:Dt,height:Ut}=Lt.style,Vt=fmt(Dt),Qt=fmt(Ut),qt=$t/ZOOM,Zt=Pt/ZOOM,{width:ar,height:Jt}=nt[_];let rr=0,Yt=0,Kt=0,nr=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;rr=tr*ZOOM,Yt=ir,Kt=sr,nr=cr*ZOOM}qt+Qt>Jt-Kt?Lt.style.top=`${(Jt-Qt-Kt)*ZOOM}px`:Lt.style.top=`${$t<rr?rr:$t}px`,Zt+Vt>ar-Yt?Lt.style.left=`${(ar-Vt-Yt)*ZOOM}px`:Lt.style.left=`${Pt<nr?nr:Pt}px`},Ct=({target:Lt})=>{const{top:$t,left:Pt}=Lt.style;et([{key:"position.y",value:fmt($t),schemaId:Lt.id},{key:"position.x",value:fmt(Pt),schemaId:Lt.id}])},It=({targets:Lt})=>{const $t=Lt.map(({style:{top:Pt,left:Dt},id:Ut})=>[{key:"position.y",value:fmt(Pt),schemaId:Ut},{key:"position.x",value:fmt(Dt),schemaId:Ut}]);et(flatten($t))},yt=({target:Lt,rotate:$t})=>{Lt.style.transform=`rotate(${$t}deg)`},Rt=({target:Lt})=>{const{transform:$t}=Lt.style,Pt=Number($t.replace("rotate(","").replace("deg)","")),Dt=normalizeRotate(Pt);et([{key:"rotate",value:Dt,schemaId:Lt.id}])},kt=({targets:Lt})=>{const $t=Lt.map(({style:{transform:Pt},id:Dt})=>{const Ut=Number(Pt.replace("rotate(","").replace("deg)",""));return[{key:"rotate",value:normalizeRotate(Ut),schemaId:Dt}]});et(flatten($t))},jt=({target:Lt})=>{const{id:$t,style:Pt}=Lt,{width:Dt,height:Ut,top:Vt,left:Qt}=Pt;et([{key:"position.x",value:fmt(Qt),schemaId:$t},{key:"position.y",value:fmt(Vt),schemaId:$t},{key:"width",value:fmt(Dt),schemaId:$t},{key:"height",value:fmt(Ut),schemaId:$t}]);const qt=rt[_].find(Zt=>Zt.id===$t);qt&&(qt.position.x=fmt(Qt),qt.position.y=fmt(Vt),qt.width=fmt(Dt),qt.height=fmt(Ut))},Ht=({targets:Lt})=>{const $t=Lt.map(({style:{width:Pt,height:Dt,top:Ut,left:Vt},id:Qt})=>[{key:"width",value:fmt(Pt),schemaId:Qt},{key:"height",value:fmt(Dt),schemaId:Qt},{key:"position.y",value:fmt(Ut),schemaId:Qt},{key:"position.x",value:fmt(Vt),schemaId:Qt}]);et(flatten($t))},Ft=({target:Lt,width:$t,height:Pt,direction:Dt})=>{if(!Lt)return;let Ut=0,Vt=0,Qt=0,qt=0;if(isBlankPdf($)){const[tr,ir,sr,cr]=$.padding;Ut=tr*ZOOM,Vt=mm2px(ir),Qt=mm2px(sr),qt=cr*ZOOM}const Zt=mm2px(nt[_].width),ar=mm2px(nt[_].height),Jt={width:`${$t}px`,height:`${Pt}px`},rr=Lt.style;let Yt=fmt4Num(rr.left)+(fmt4Num(rr.width)-$t),Kt=fmt4Num(rr.top)+(fmt4Num(rr.height)-Pt);Yt<qt&&(Yt=qt),Kt<Ut&&(Kt=Ut),Yt+$t>Zt-Vt&&(Jt.width=`${Zt-Vt-Yt}px`),Kt+Pt>ar-Qt&&(Jt.height=`${ar-Qt-Kt}px`);const nr=Dt.toString();isTopLeftResize(nr)?(Jt.top=`${Kt}px`,Jt.left=`${Yt}px`):nr==="1,-1"?Jt.top=`${Kt}px`:nr==="-1,1"&&(Jt.left=`${Yt}px`),Object.assign(rr,Jt)},_t=(Lt,$t)=>Lt[$t]&&Lt[$t].getGuides().map(Pt=>Pt*ZOOM),Nt=Lt=>{Lt.inputEvent.stopPropagation(),bt(!0)},Mt=reactExports.useMemo(()=>{const $t=(rt[_]||[]).filter(Ut=>ot.map(Vt=>Vt.id).includes(Ut.id)).map(Ut=>Ut.type),Pt=[...new Set($t)],Dt=Object.values(gt).map(Ut=>Ut==null?void 0:Ut.propPanel.defaultSchema);return Pt.every(Ut=>{var Vt;return((Vt=Dt.find(Qt=>Qt.type===Ut))==null?void 0:Vt.rotate)!==void 0})},[ot,_,rt,gt]);return jsxRuntimeExports.jsxs("div",{style:{position:"relative",overflow:"auto",marginRight:ht?RIGHT_SIDEBAR_WIDTH:0,...at},ref:s,children:[jsxRuntimeExports.jsx(Selecto,{container:ft.current[_],continueSelect:vt,onDragStart:Lt=>{var Dt,Ut;const{inputEvent:$t}=Lt,Pt=(Dt=ct.current)==null?void 0:Dt.isMoveableElement($t.target);($t.type==="touchstart"&&Lt.isTrusted||Pt)&&Lt.stop(),ft.current[_]===$t.target&<([]),((Ut=$t.target)==null?void 0:Ut.id)===DELETE_BTN_ID&&it(ot.map(Vt=>Vt.id))},onSelect:({added:Lt,removed:$t,selected:Pt,inputEvent:Dt})=>{const Ut=Dt.type==="mousedown";let Vt=Ut?Pt:[];!Ut&&Lt.length>0&&(Vt=ot.concat(Lt)),!Ut&&$t.length>0&&(Vt=ot.filter(Qt=>!$t.includes(Qt))),lt(Vt),Vt!=ot&&bt(!1),Dt.shiftKey||At(!1)}}),jsxRuntimeExports.jsx(Paper$1,{paperRefs:ft,scale:_e,size:at,schemasList:rt,pageSizes:nt,backgrounds:tt,hasRulers:!0,renderPaper:({index:Lt,paperSize:$t})=>jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment,{children:[!xt&&ot.length>0&&_===Lt&&jsxRuntimeExports.jsx(DeleteButton,{activeElements:ot}),jsxRuntimeExports.jsx(Padding$1,{basePdf:$}),jsxRuntimeExports.jsx(Guides,{paperSize:$t,horizontalRef:Pt=>{Pt&&(mt.current[Lt]=Pt)},verticalRef:Pt=>{Pt&&(pt.current[Lt]=Pt)}}),_!==Lt?jsxRuntimeExports.jsx(Mask$1,{width:$t.width+RULER_HEIGHT,height:$t.height+RULER_HEIGHT}):!xt&&jsxRuntimeExports.jsx(Moveable,{ref:ct,target:ot,bounds:{left:0,top:0,bottom:$t.height,right:$t.width},horizontalGuidelines:_t(mt.current,Lt),verticalGuidelines:_t(pt.current,Lt),keepRatio:vt,rotatable:Mt,onDrag:wt,onDragEnd:Ct,onDragGroupEnd:It,onRotate:yt,onRotateEnd:Rt,onRotateGroupEnd:kt,onResize:Ft,onResizeEnd:jt,onResizeGroupEnd:Ht,onClick:Nt})]}),renderSchema:({schema:Lt})=>jsxRuntimeExports.jsx(Renderer$1,{schema:Lt,basePdf:$,value:Lt.content||"",onChangeHoveringSchemaId:ut,mode:xt&&ot.map($t=>$t.id).includes(Lt.id)?"designer":"viewer",onChange:$t=>{const Pt=Array.isArray($t)?$t:[$t];et(Pt.map(({key:Dt,value:Ut})=>({key:Dt,value:Ut,schemaId:Lt.id})))},stopEditing:()=>bt(!1),outline:`1px ${st===Lt.id?"solid":"dashed"} ${Lt.readOnly&&st!==Lt.id?"transparent":dt.colorPrimary}`,scale:_e},Lt.id)})]})},Canvas$1=reactExports.forwardRef(Canvas),Spinner=()=>jsxRuntimeExports.jsx(Spin$1,{style:{width:"100%",height:"100%",display:"flex",alignItems:"center",justifyContent:"center"},indicator:jsxRuntimeExports.jsx(LoadingOutlined$1,{style:{fontSize:50},spin:!0})}),Spinner$1=Spinner,Root=({size:a,scale:s,children:$},_)=>{const _e=reactExports.useContext(FontContext);return reactExports.useEffect(()=>{if(!document||!document.fonts)return;const nt=Object.entries(_e).map(([at,{data:ot}])=>new FontFace(at,typeof ot=="string"?`url(${ot})`:ot,{display:"swap"})).filter(at=>!document.fonts.has(at));Promise.allSettled(nt.map(at=>at.load())).then(at=>{at.forEach(ot=>{ot.status==="fulfilled"&&document.fonts.add(ot.value)})})},[_e]),jsxRuntimeExports.jsx("div",{ref:_,style:{position:"relative",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{margin:"0 auto",...a},children:s===0?jsxRuntimeExports.jsx(Spinner$1,{}):$})})},Root$1=reactExports.forwardRef(Root),ErrorScreen=({size:a,error:s})=>{const $=reactExports.useContext(I18nContext),{token:_}=theme.useToken();return jsxRuntimeExports.jsx("div",{style:{display:"flex",flexDirection:"column",justifyContent:"center",background:BACKGROUND_COLOR,...a},children:jsxRuntimeExports.jsx("div",{style:{width:300,margin:"0 auto",background:_.colorBgLayout},children:jsxRuntimeExports.jsx(Result$2,{icon:null,title:"ERROR",subTitle:$("errorOccurred"),extra:jsxRuntimeExports.jsx("span",{children:s.message})})})})},ErrorScreen$1=ErrorScreen,{Text:Text$1}=Typography$1,Zoom=({zoomLevel:a,setZoomLevel:s,style:$})=>{const nt=a-.25,at=a+.25;return jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:.25>=nt,onClick:()=>s(nt),icon:jsxRuntimeExports.jsx(MinusOutlined$1,{style:{color:$.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:$.textStyle,children:[Math.round(a*100),"%"]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:2<at,onClick:()=>s(at),icon:jsxRuntimeExports.jsx(PlusOutlined$4,{style:{color:$.textStyle.color}})})]})},Pager=({pageCursor:a,pageNum:s,setPageCursor:$,style:_})=>jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center"},children:[jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a<=0,onClick:()=>$(a-1),children:jsxRuntimeExports.jsx(LeftOutlined$1,{style:{color:_.textStyle.color}})}),jsxRuntimeExports.jsxs(Text$1,{strong:!0,style:_.textStyle,children:[a+1,"/",s]}),jsxRuntimeExports.jsx(Button$2,{type:"text",disabled:a+1>=s,onClick:()=>$(a+1),children:jsxRuntimeExports.jsx(RightOutlined$1,{style:{color:_.textStyle.color}})})]}),ContextMenu=({items:a,style:s})=>jsxRuntimeExports.jsx(Dropdown$1,{menu:{items:a},placement:"top",arrow:!0,trigger:["click"],children:jsxRuntimeExports.jsx(Button$2,{type:"text",children:jsxRuntimeExports.jsx(EllipsisOutlined$1,{style:{color:s.textStyle.color}})})}),CtlBar=a=>{const{token:s}=theme.useToken(),$=reactExports.useContext(I18nContext),{size:_,pageCursor:_e,pageNum:tt,setPageCursor:nt,zoomLevel:at,setZoomLevel:ot,addPageAfter:rt,removePage:st}=a,lt=[];rt&<.push({key:"1",label:jsxRuntimeExports.jsx("div",{onClick:rt,children:$("addPageAfter")})}),st&&tt>1&&_e!==0&<.push({key:"2",label:jsxRuntimeExports.jsx("div",{onClick:st,children:$("removePage")})});const et=300,it=lt.length>0?50:0,ut=(tt>1?et:et/2)+it,ft={color:s.colorWhite,fontSize:s.fontSize,margin:s.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",top:"auto",bottom:"6%",width:_.width},children:jsxRuntimeExports.jsxs("div",{style:{display:"flex",alignItems:"center",justifyContent:"space-evenly",position:"relative",zIndex:1,left:`calc(50% - ${ut/2}px)`,width:ut,height:40,boxSizing:"border-box",padding:s.paddingSM,borderRadius:s.borderRadius,backgroundColor:s.colorBgMask},children:[tt>1&&jsxRuntimeExports.jsx(Pager,{style:{textStyle:ft},pageCursor:_e,pageNum:tt,setPageCursor:nt}),jsxRuntimeExports.jsx(Zoom,{style:{textStyle:ft},zoomLevel:at,setZoomLevel:ot}),lt.length>0&&jsxRuntimeExports.jsx(ContextMenu,{items:lt,style:{textStyle:ft}})]})})},CtlBar$1=CtlBar,scaleDragPosAdjustment=(a,s)=>s>1?a*(s-1):s<1?a*-(1-s):0,TemplateEditor=({template:a,size:s,onSaveTemplate:$,onChangeTemplate:_,onPageCursorChange:_e})=>{const tt=reactExports.useRef([]),nt=reactExports.useRef([]),at=reactExports.useRef(null),ot=reactExports.useRef([]),rt=reactExports.useContext(I18nContext),st=reactExports.useContext(PluginsRegistry),[lt,et]=reactExports.useState(null),[it,ut]=reactExports.useState([]),[ft,ht]=reactExports.useState([[]]),[dt,gt]=reactExports.useState(0),[pt,mt]=reactExports.useState(1),[ct,vt]=reactExports.useState(!0),[At,xt]=reactExports.useState(null),{backgrounds:bt,pageSizes:Et,scale:St,error:Bt,refresh:Ot}=useUIPreProcessor({template:a,size:s,zoomLevel:pt}),Tt=$t=>{ut($t),et(null)},wt=()=>{ut([]),et(null)};useScrollPageCursor({ref:at,pageSizes:Et,scale:St,pageCursor:dt,onChangePageCursor:$t=>{gt($t),_e($t),wt()}});const Ct=reactExports.useCallback($t=>{nt.current=[],tt.current.push(cloneDeep$2(ft[dt]));const Pt=cloneDeep$2(ft);Pt[dt]=$t,ht(Pt),_(schemasList2template(Pt,a.basePdf))},[a,ft,dt,_]),It=reactExports.useCallback($t=>{Ct(ft[dt].filter(Pt=>!$t.includes(Pt.id))),wt()},[ft,dt,Ct]),yt=reactExports.useCallback($t=>{changeSchemas({objs:$t,schemas:ft[dt],basePdf:a.basePdf,pluginsRegistry:st,pageSize:Et[dt],commitSchemas:Ct})},[Ct,dt,ft,st,Et,a.basePdf]);useInitEvents({pageCursor:dt,pageSizes:Et,activeElements:it,template:a,schemasList:ft,changeSchemas:yt,commitSchemas:Ct,removeSchemas:It,onSaveTemplate:$,past:tt,future:nt,setSchemasList:ht,onEdit:Tt,onEditEnd:wt});const Rt=reactExports.useCallback(async $t=>{var Dt;const Pt=await template2SchemasList($t);ht(Pt),wt(),gt(0),(Dt=at.current)!=null&&Dt.scroll&&at.current.scroll({top:0,behavior:"smooth"})},[]),kt=$t=>{const[Pt,Dt,Ut,Vt]=isBlankPdf(a.basePdf)?a.basePdf.padding:[0,0,0,0],Qt=Et[dt],qt=(ar,Jt,rr)=>Math.min(Math.max(ar,Jt),rr),Zt={id:uuid$6(),key:`${rt("field")}${ft[dt].length+1}`,...$t,position:{x:qt(Vt,$t.position.x,Qt.width-Dt-$t.width),y:qt(Pt,$t.position.y,Qt.height-Ut-$t.height)}};if($t.position.y===0){const ar=ot.current[dt],Jt=ar?ar.getBoundingClientRect().top:0;Zt.position.y=Jt>0?Pt:Et[dt].height/2}Ct(ft[dt].concat(Zt)),setTimeout(()=>Tt([document.getElementById(Zt.id)]))},jt=$t=>{Ct($t)},Ht=$t=>{et($t)},Ft=async($t,Pt)=>{gt(Pt);const Dt=schemasList2template($t,a.basePdf);_(Dt),await Rt(Dt),Ot(Dt),setTimeout(()=>at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,Pt,St),0))},_t=()=>{if(dt===0||!window.confirm(rt("removePageConfirm")))return;const $t=cloneDeep$2(ft);$t.splice(dt,1),Ft($t,dt-1)},Nt=()=>{const $t=cloneDeep$2(ft);$t.splice(dt+1,0,[]),Ft($t,dt+1)};At!==a&&(xt(a),Rt(a));const Mt={width:ct?s.width-RIGHT_SIDEBAR_WIDTH:s.width,height:s.height};if(Bt)return jsxRuntimeExports.jsx(ErrorScreen$1,{size:s,error:Bt});const Lt=isBlankPdf(a.basePdf)?{addPageAfter:Nt,removePage:_t}:{};return jsxRuntimeExports.jsx(Root$1,{size:s,scale:St,children:jsxRuntimeExports.jsxs(DndContext,{onDragEnd:$t=>{var rr,Yt;if(!$t.active)return;const Pt=$t.active,Dt=ot.current[dt].getBoundingClientRect(),Ut=((rr=Pt.rect.current.initial)==null?void 0:rr.left)||0,Vt=((Yt=Pt.rect.current.initial)==null?void 0:Yt.top)||0,Qt=Dt.left-Ut+scaleDragPosAdjustment(20,St),qt=Dt.top-Vt,Zt=($t.delta.y-qt)/St,ar=($t.delta.x-Qt)/St,Jt={x:px2mm(Math.max(0,ar)),y:px2mm(Math.max(0,Zt))};kt({...Pt.data.current,position:Jt})},onDragStart:wt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:Mt,pageCursor:dt,pageNum:ft.length,setPageCursor:$t=>{at.current&&(at.current.scrollTop=getPagesScrollTopByIndex(Et,$t,St),gt($t),wt())},zoomLevel:pt,setZoomLevel:mt,...Lt}),jsxRuntimeExports.jsx(LeftSidebar$1,{height:at.current?at.current.clientHeight:0,scale:St,basePdf:a.basePdf}),jsxRuntimeExports.jsx(RightSidebar,{hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:at.current?at.current.clientHeight:0,size:s,pageSize:Et[dt]??[],activeElements:it,schemas:ft[dt]??[],changeSchemas:yt,onSortEnd:jt,onEdit:$t=>{const Pt=document.getElementById($t);Pt&&Tt([Pt])},onEditEnd:wt,deselectSchema:wt,sidebarOpen:ct,setSidebarOpen:vt}),jsxRuntimeExports.jsx(Canvas$1,{ref:at,paperRefs:ot,basePdf:a.basePdf,hoveringSchemaId:lt,onChangeHoveringSchemaId:Ht,height:s.height-RULER_HEIGHT*ZOOM,pageCursor:dt,scale:St,size:Mt,pageSizes:Et,backgrounds:bt,activeElements:it,schemasList:ft,changeSchemas:yt,removeSchemas:It,sidebarOpen:ct,onEdit:Tt})]})})},DesignerComponent=TemplateEditor,defaultTheme={token:{colorPrimary:"#38a0ff"},components:{Form:{fontSize:12,margin:8,marginLG:12,marginXS:4,padding:8,paddingLG:12,paddingXS:4,itemMarginBottom:4,verticalLabelPadding:"0 0 2px"}}},isObject=a=>a&&typeof a=="object"&&!Array.isArray(a),deepMerge=(a,s)=>{let $={...a};return isObject(a)&&isObject(s)&&Object.keys(s).forEach(_=>{isObject(s[_])?_ in a?$[_]=deepMerge(a[_],s[_]):Object.assign($,{[_]:s[_]}):Object.assign($,{[_]:s[_]})}),$},AppContextProvider=({children:a,lang:s,font:$,plugins:_,options:_e})=>{let tt=defaultTheme;_e.theme&&(tt=deepMerge(tt,_e.theme));let nt=getDict(s);return _e.labels&&(nt=deepMerge(nt,_e.labels)),jsxRuntimeExports.jsx(ThemeConfigProvider,{theme:tt,children:jsxRuntimeExports.jsx(I18nContext.Provider,{value:at=>i18n(at,nt),children:jsxRuntimeExports.jsx(FontContext.Provider,{value:$,children:jsxRuntimeExports.jsx(PluginsRegistry.Provider,{value:_,children:jsxRuntimeExports.jsx(OptionsContext.Provider,{value:_e,children:a})})})})})},AppContextProvider$1=AppContextProvider;class Designer extends BaseUIClass{constructor(s){super(s),this.pageCursor=0,checkDesignerProps(s)}saveTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.onSaveTemplateCallback&&this.onSaveTemplateCallback(this.template)}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$2(s),this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s),this.render()}onSaveTemplate(s){this.onSaveTemplateCallback=s}onChangeTemplate(s){this.onChangeTemplateCallback=s}getPageCursor(){return this.pageCursor}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(DesignerComponent,{template:this.template,onSaveTemplate:s=>{this.template=s,this.onSaveTemplateCallback&&this.onSaveTemplateCallback(s)},onChangeTemplate:s=>{this.template=s,this.template.pdfmeVersion=PDFME_VERSION,this.onChangeTemplateCallback&&this.onChangeTemplateCallback(s)},onPageCursorChange:s=>{this.pageCursor=s},size:this.size})}),this.domContainer)}}const Designer$1=Designer,{Text}=Typography$1,icons={left:LeftOutlined$1,right:RightOutlined$1,doubleLeft:DoubleLeftOutlined$1,doubleRight:DoubleRightOutlined$1},UnitButton=({type:a,onClick:s,disabled:$,textStyle:_})=>{const _e=icons[a];return jsxRuntimeExports.jsx(Button$2,{type:"text",onClick:s,disabled:$,children:jsxRuntimeExports.jsx(_e,{style:{color:_.color}})})},UnitPager=({size:a,unitCursor:s,unitNum:$,setUnitCursor:_})=>{if($<=1)return null;const{token:_e}=theme.useToken(),tt={pointerEvents:"initial",position:"sticky",zIndex:1,display:"flex",alignItems:"center",boxSizing:"border-box",height:40,padding:_e.paddingSM,borderRadius:_e.borderRadius,backgroundColor:_e.colorBgMask},nt={color:_e.colorWhite,fontSize:_e.fontSize,margin:_e.marginXS};return jsxRuntimeExports.jsx("div",{style:{position:"absolute",...a},children:jsxRuntimeExports.jsxs("div",{style:{position:"sticky",width:"100%",zIndex:1,top:`calc(50% - ${tt.height/2}px)`,display:"flex",alignItems:"center"},children:[s>0&&jsxRuntimeExports.jsxs("div",{style:{left:"1rem",marginLeft:"1rem",...tt},children:[jsxRuntimeExports.jsx(UnitButton,{type:"doubleLeft",onClick:()=>_(0),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"left",onClick:()=>_(s-1),disabled:s<=0,textStyle:nt}),jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]})]}),s+1<$&&jsxRuntimeExports.jsxs("div",{style:{right:"1rem",marginLeft:"auto",marginRight:"1rem",...tt},children:[jsxRuntimeExports.jsxs(Text,{strong:!0,style:nt,children:[s+1,"/",$]}),jsxRuntimeExports.jsx(UnitButton,{type:"right",onClick:()=>_(s+1),disabled:s+1>=$,textStyle:nt}),jsxRuntimeExports.jsx(UnitButton,{type:"doubleRight",onClick:()=>_($-1),disabled:s+1>=$,textStyle:nt})]})]})})},UnitPager$1=UnitPager,_cache=new Map,Preview=({template:a,inputs:s,size:$,onChangeInput:_})=>{const{token:_e}=theme.useToken(),tt=reactExports.useContext(FontContext),nt=reactExports.useRef(null),at=reactExports.useRef([]),[ot,rt]=reactExports.useState(0),[st,lt]=reactExports.useState(0),[et,it]=reactExports.useState(1),[ut,ft]=reactExports.useState([[]]),{backgrounds:ht,pageSizes:dt,scale:gt,error:pt,refresh:mt}=useUIPreProcessor({template:a,size:$,zoomLevel:et}),ct=!!_,vt=s[ot],At=bt=>{getDynamicTemplate({template:bt,input:vt,options:{font:tt},_cache,modifyTemplate:St=>modifyTemplateForTable(St),getDynamicHeight:(St,Bt)=>Bt.schema.type!=="table"?Promise.resolve(Bt.schema.height):getDynamicHeightForTable(St,Bt)}).then(async St=>{const Bt=await template2SchemasList(St);ft(Bt),await mt(St)}).catch(St=>console.error("[@pdfme/ui] ",St))};reactExports.useEffect(()=>{ot>s.length-1&&rt(s.length-1),At(a)},[a,s,$]),useScrollPageCursor({ref:nt,pageSizes:dt,scale:gt,pageCursor:st,onChangePageCursor:lt});const xt=({key:bt,value:Et})=>_&&_({index:ot,key:bt,value:Et});return pt?jsxRuntimeExports.jsx(ErrorScreen$1,{size:$,error:pt}):jsxRuntimeExports.jsxs(Root$1,{size:$,scale:gt,children:[jsxRuntimeExports.jsx(CtlBar$1,{size:$,pageCursor:st,pageNum:ut.length,setPageCursor:bt=>{nt.current&&(nt.current.scrollTop=getPagesScrollTopByIndex(dt,bt,gt),lt(bt))},zoomLevel:et,setZoomLevel:it}),jsxRuntimeExports.jsx(UnitPager$1,{size:$,unitCursor:ot,unitNum:s.length,setUnitCursor:rt}),jsxRuntimeExports.jsx("div",{ref:nt,style:{...$,position:"relative",overflow:"auto"},children:jsxRuntimeExports.jsx(Paper$1,{paperRefs:at,scale:gt,size:$,schemasList:ut,pageSizes:dt,backgrounds:ht,renderSchema:({schema:bt,index:Et})=>{const{key:St,readOnly:Bt}=bt,Ot=Bt?String(bt.content)||"":String(vt&&vt[St]||"");return jsxRuntimeExports.jsx(Renderer$1,{schema:bt,basePdf:a.basePdf,value:Ot,mode:ct?"form":"viewer",placeholder:bt.content,tabIndex:Et+100,onChange:Tt=>{const wt=Array.isArray(Tt)?Tt:[Tt];let Ct=!1;wt.forEach(({key:It,value:yt})=>{if(It==="content"){const Rt=yt,kt=(vt==null?void 0:vt[St])||"";if(Rt===kt)return;xt({key:St,value:Rt}),bt.type==="table"&&(Ct=!0)}else{const Rt=ut[st].find(kt=>kt.id===bt.id);if(!Rt)return;Rt[It]=yt}}),Ct&&At(a),ft([...ut])},outline:ct&&!bt.readOnly?`1px dashed ${_e.colorPrimary}`:"transparent",scale:gt},bt.id)}})})]})},Preview$1=Preview;class Form extends PreviewUI{constructor(s){super(s)}onChangeInput(s){this.onChangeInputCallback=s}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs,onChangeInput:s=>{const{index:$,value:_,key:_e}=s;this.onChangeInputCallback&&this.onChangeInputCallback({index:$,value:_,key:_e}),this.inputs&&this.inputs[$]&&this.inputs[$][_e]!==_&&(this.inputs[$][_e]=_,this.render())}})}),this.domContainer)}}const Form$1=Form;class Viewer extends PreviewUI{constructor(s){super(s)}render(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.render(jsxRuntimeExports.jsx(AppContextProvider$1,{lang:this.getLang(),font:this.getFont(),plugins:this.getPluginsRegistry(),options:this.getOptions(),children:jsxRuntimeExports.jsx(Preview$1,{template:this.template,size:this.size,inputs:this.inputs})}),this.domContainer)}}const Viewer$1=Viewer;exports.Designer=Designer$1,exports.Form=Form$1,exports.Viewer=Viewer$1,Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
import React, { useContext } from 'react';
|
1
|
+
import React, { useContext, useState, useEffect } from 'react';
|
2
2
|
import {
|
3
3
|
Schema,
|
4
4
|
Plugin,
|
@@ -45,16 +45,33 @@ const LeftSidebar = ({ height, scale, basePdf }: { height: number, scale: number
|
|
45
45
|
const { token } = theme.useToken();
|
46
46
|
const pluginsRegistry = useContext(PluginsRegistry);
|
47
47
|
|
48
|
+
const [isDragging, setIsDragging] = useState(false);
|
49
|
+
|
50
|
+
useEffect(() => {
|
51
|
+
const handleMouseUp = () => {
|
52
|
+
if (isDragging) {
|
53
|
+
setIsDragging(false);
|
54
|
+
}
|
55
|
+
};
|
56
|
+
|
57
|
+
document.addEventListener('mouseup', handleMouseUp);
|
58
|
+
|
59
|
+
return () => {
|
60
|
+
document.removeEventListener('mouseup', handleMouseUp);
|
61
|
+
};
|
62
|
+
}, [isDragging]);
|
63
|
+
|
48
64
|
return <div
|
49
65
|
style={{
|
50
66
|
left: 0,
|
51
|
-
position: 'absolute',
|
52
67
|
right: 0,
|
68
|
+
position: 'absolute',
|
53
69
|
zIndex: 1,
|
54
70
|
height,
|
71
|
+
width: 45,
|
55
72
|
background: token.colorBgLayout,
|
56
73
|
textAlign: 'center',
|
57
|
-
|
74
|
+
overflow: isDragging ? 'visible' : 'auto',
|
58
75
|
}}
|
59
76
|
>
|
60
77
|
{Object.entries(pluginsRegistry).map(([label, plugin]) => {
|
@@ -66,6 +83,9 @@ const LeftSidebar = ({ height, scale, basePdf }: { height: number, scale: number
|
|
66
83
|
plugin={plugin}>
|
67
84
|
<Button
|
68
85
|
title={label}
|
86
|
+
onMouseDown={() => {
|
87
|
+
setIsDragging(true);
|
88
|
+
}}
|
69
89
|
style={{ width: 35, height: 35, marginTop: '0.25rem', padding: '0.25rem' }}>
|
70
90
|
{plugin.propPanel.defaultSchema.icon ?
|
71
91
|
<div dangerouslySetInnerHTML={{ __html: plugin.propPanel.defaultSchema.icon }} />
|
@@ -137,8 +137,8 @@ const Preview = ({
|
|
137
137
|
const oldValue = (input?.[key] as string) || '';
|
138
138
|
if (newValue === oldValue) return;
|
139
139
|
handleChangeInput({ key, value: newValue });
|
140
|
-
// TODO
|
141
|
-
isNeedInit = true;
|
140
|
+
// TODO Improve this to allow schema types to determine whether the execution of getDynamicTemplate is required.
|
141
|
+
if (schema.type === 'table') isNeedInit = true;
|
142
142
|
} else {
|
143
143
|
const targetSchema = schemasList[pageCursor].find(
|
144
144
|
(s) => s.id === schema.id
|