@pdfme/ui 4.1.0-dev.5 → 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 /* @__PURE__ */ jsxRuntimeExports.jsx(
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
- width: 45
152123
+ overflow: tt ? "visible" : "auto"
152116
152124
  },
152117
- children: Object.entries(_e).map(([tt, nt]) => nt != null && nt.propPanel.defaultSchema ? /* @__PURE__ */ jsxRuntimeExports.jsx(
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: nt,
152130
+ plugin: ot,
152123
152131
  children: /* @__PURE__ */ jsxRuntimeExports.jsx(
152124
152132
  Button$2,
152125
152133
  {
152126
- title: tt,
152134
+ title: at,
152135
+ onMouseDown: () => {
152136
+ nt(!0);
152137
+ },
152127
152138
  style: { width: 35, height: 35, marginTop: "0.25rem", padding: "0.25rem" },
152128
- children: nt.propPanel.defaultSchema.icon ? /* @__PURE__ */ jsxRuntimeExports.jsx("div", { dangerouslySetInnerHTML: { __html: nt.propPanel.defaultSchema.icon } }) : /* @__PURE__ */ jsxRuntimeExports.jsx("div", { style: { overflow: "hidden", textOverflow: "ellipsis" }, children: tt })
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
- tt
152143
+ at
152133
152144
  ) : null)
152134
152145
  }
152135
152146
  );
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&&lt(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&&lt(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",right:0,zIndex:1,height:a,background:_.colorBgLayout,textAlign:"center",width:45},children:Object.entries(_e).map(([tt,nt])=>nt!=null&&nt.propPanel.defaultSchema?jsxRuntimeExports.jsx(Draggable$1,{scale:s,basePdf:$,plugin:nt,children:jsxRuntimeExports.jsx(Button$2,{title:tt,style:{width:35,height:35,marginTop:"0.25rem",padding:"0.25rem"},children:nt.propPanel.defaultSchema.icon?jsxRuntimeExports.jsx("div",{dangerouslySetInnerHTML:{__html:nt.propPanel.defaultSchema.icon}}):jsxRuntimeExports.jsx("div",{style:{overflow:"hidden",textOverflow:"ellipsis"},children:tt})})},tt):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}};/*! *****************************************************************************
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
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@pdfme/ui",
3
- "version": "4.1.0-dev.5",
3
+ "version": "4.1.0-dev.6",
4
4
  "sideEffects": false,
5
5
  "author": "hand-dot",
6
6
  "license": "MIT",
@@ -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
- width: 45,
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 }} />