@pdfme/ui 5.3.16-dev.29 → 5.3.16-dev.30
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 +2 -3
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/class.ts +3 -1
package/dist/index.es.js
CHANGED
@@ -80761,11 +80761,10 @@ const arrayBufferToBase64 = (a) => {
|
|
80761
80761
|
class BaseUIClass {
|
80762
80762
|
constructor(s) {
|
80763
80763
|
this.lang = DEFAULT_LANG, this.font = getDefaultFont(), this.pluginsRegistry = builtInPlugins, this.options = {}, this.setSize = debounce$1(() => {
|
80764
|
-
|
80765
|
-
this.size = {
|
80764
|
+
this.domContainer && (this.size = {
|
80766
80765
|
height: this.domContainer.clientHeight || window.innerHeight,
|
80767
80766
|
width: this.domContainer.clientWidth || window.innerWidth
|
80768
|
-
}, this.render();
|
80767
|
+
}, this.render());
|
80769
80768
|
}, 100), this.resizeObserver = new ResizeObserver(this.setSize), checkUIProps(s);
|
80770
80769
|
const { domContainer: c, template: u, options: d = {}, plugins: p = {} } = s;
|
80771
80770
|
this.domContainer = c, this.template = cloneDeep$1(u), this.options = d, this.size = {
|
package/dist/index.umd.js
CHANGED
@@ -183,7 +183,7 @@ endstream`,s}copyBytesInto(s,c){this.updateDict();const u=c;c+=this.dict.copyByt
|
|
183
183
|
* This source code is licensed under the ISC license.
|
184
184
|
* See the LICENSE file in the root directory of this source tree.
|
185
185
|
*/const Underline=[["path",{d:"M6 4v6a6 6 0 0 0 12 0V4"}],["line",{x1:"4",x2:"20",y1:"20",y2:"20"}]],TextStrikethroughIcon=createSvgStr(Strikethrough),TextUnderlineIcon=createSvgStr(Underline),TextAlignLeftIcon=createSvgStr(AlignLeft),TextAlignCenterIcon=createSvgStr(AlignCenter),TextAlignRightIcon=createSvgStr(AlignRight),TextAlignJustifyIcon=createSvgStr(AlignJustify),TextVerticalAlignTopIcon=createSvgStr(ArrowUpToLine),TextVerticalAlignMiddleIcon='<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" viewBox="0 0 24 24"><path d="M8 19h3v4h2v-4h3l-4-4l-4 4zm8-14h-3V1h-2v4H8l4 4l4-4zM4 11v2h16v-2H4z" fill="currentColor"></path></svg>',TextVerticalAlignBottomIcon=createSvgStr(ArrowDownToLine);var Formatter;(function(a){a.STRIKETHROUGH="strikethrough",a.UNDERLINE="underline",a.ALIGNMENT="alignment",a.VERTICAL_ALIGNMENT="verticalAlignment"})(Formatter||(Formatter={}));function getExtraFormatterSchema(a){const s=[{key:Formatter.STRIKETHROUGH,icon:TextStrikethroughIcon,type:"boolean"},{key:Formatter.UNDERLINE,icon:TextUnderlineIcon,type:"boolean"},{key:Formatter.ALIGNMENT,icon:TextAlignLeftIcon,type:"select",value:DEFAULT_ALIGNMENT},{key:Formatter.ALIGNMENT,icon:TextAlignCenterIcon,type:"select",value:ALIGN_CENTER},{key:Formatter.ALIGNMENT,icon:TextAlignRightIcon,type:"select",value:ALIGN_RIGHT},{key:Formatter.ALIGNMENT,icon:TextAlignJustifyIcon,type:"select",value:ALIGN_JUSTIFY},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignTopIcon,type:"select",value:DEFAULT_VERTICAL_ALIGNMENT},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignMiddleIcon,type:"select",value:VERTICAL_ALIGN_MIDDLE},{key:Formatter.VERTICAL_ALIGNMENT,icon:TextVerticalAlignBottomIcon,type:"select",value:VERTICAL_ALIGN_BOTTOM}];return{title:a("schemas.text.format"),widget:"ButtonGroup",buttons:s,span:24}}const UseDynamicFontSize=a=>{const{rootElement:s,changeSchemas:c,activeSchema:u,i18n:d}=a,p=document.createElement("input");p.type="checkbox",p.checked=!!(u!=null&&u.dynamicFontSize),p.onchange=b=>{const g=b.target.checked?{min:DEFAULT_DYNAMIC_MIN_FONT_SIZE,max:DEFAULT_DYNAMIC_MAX_FONT_SIZE,fit:DEFAULT_DYNAMIC_FIT}:void 0;c([{key:"dynamicFontSize",value:g,schemaId:u.id}])};const v=document.createElement("label"),A=document.createElement("span");A.innerText=d("schemas.text.dynamicFontSize")||"",A.style.cssText="margin-left: 0.5rem",v.style.cssText="display: flex; width: 100%;",v.appendChild(p),v.appendChild(A),s.appendChild(v)},propPanel={schema:({options:a,activeSchema:s,i18n:c})=>{const u=a.font||{[DEFAULT_FONT_NAME]:{data:"",fallback:!0}},d=Object.keys(u),p=getFallbackFontName(u),v=!!(s!=null&&s.dynamicFontSize);return{fontName:{title:c("schemas.text.fontName"),type:"string",widget:"select",default:p,placeholder:p,props:{options:d.map(b=>({label:b,value:b}))},span:12},fontSize:{title:c("schemas.text.size"),type:"number",widget:"inputNumber",span:6,disabled:v,props:{min:0}},characterSpacing:{title:c("schemas.text.spacing"),type:"number",widget:"inputNumber",span:6,props:{min:0}},formatter:getExtraFormatterSchema(c),lineHeight:{title:c("schemas.text.lineHeight"),type:"number",widget:"inputNumber",props:{step:.1,min:0},span:8},useDynamicFontSize:{type:"boolean",widget:"UseDynamicFontSize",bind:!1,span:16},dynamicFontSize:{type:"object",widget:"card",column:3,properties:{min:{title:c("schemas.text.min"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},max:{title:c("schemas.text.max"),type:"number",widget:"inputNumber",hidden:!v,props:{min:0}},fit:{title:c("schemas.text.fit"),type:"string",widget:"select",hidden:!v,props:{options:[{label:c("schemas.horizontal"),value:DYNAMIC_FIT_HORIZONTAL},{label:c("schemas.vertical"),value:DYNAMIC_FIT_VERTICAL}]}}}},fontColor:{title:c("schemas.textColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]},backgroundColor:{title:c("schemas.bgColor"),type:"string",widget:"color",props:{disabledAlpha:!0},rules:[{pattern:HEX_COLOR_PATTERN,message:c("validation.hexColor")}]}}},widgets:{UseDynamicFontSize},defaultSchema:{name:"",type:"text",content:"Type Something...",position:{x:0,y:0},width:45,height:10,rotate:0,alignment:DEFAULT_ALIGNMENT,verticalAlignment:DEFAULT_VERTICAL_ALIGNMENT,fontSize:DEFAULT_FONT_SIZE,lineHeight:DEFAULT_LINE_HEIGHT,characterSpacing:DEFAULT_CHARACTER_SPACING,dynamicFontSize:void 0,fontColor:DEFAULT_FONT_COLOR,fontName:void 0,backgroundColor:"",opacity:DEFAULT_OPACITY,strikethrough:!1,underline:!1}},replaceUnsupportedChars=(a,s)=>{const c={},u=p=>{if(p in c)return c[p];const v=s.hasGlyphForCodePoint(p.codePointAt(0)||0);return c[p]=v,v};return a.split(/(\r\n|\n|\r)/).map(p=>/\r\n|\n|\r/.test(p)?p:p.split("").map(v=>/\s/.test(v)||v.charCodeAt(0)<32||u(v)?v:"〿").join("")).join("")},uiRender=async a=>{const{value:s,schema:c,mode:u,onChange:d,stopEditing:p,tabIndex:v,placeholder:A,options:b,_cache:g}=a,x=isEditable(u,c)&&A&&!s,y=w=>{let _=w.innerText;return _.endsWith(`
|
186
|
-
`)&&(_=_.slice(0,-1)),_},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,_)=>`<span style="letter-spacing:${String(s).length===_+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:_,bottomAdj:I}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${_}px`,C.style.marginBottom=`${I}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),_=document.createRange();w&&_&&(_.selectNodeContents(C),_.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(_))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p}=a;let v;u.dynamicFontSize&&c&&(v=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:v}));const{topAdj:A,bottomAdj:b}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),x=b.toString(),y=document.createElement("div"),f={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(y.style,f),d.innerHTML="",d.appendChild(y);const m=[];u.strikethrough&&m.push("line-through"),u.underline&&m.push("underline");const C={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${v??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${x}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},S=document.createElement("div");return S.id="text-"+String(u.id),Object.assign(S.style,C),y.appendChild(S),S},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(builtInPlugins),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){const s=hotkeys$1;typeof s.unbind=="function"&&s.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!Object.prototype.hasOwnProperty.call(u,d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c),g=b64toUint8Array(b);p=await pdf2size(g)}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(g=>{d.includes(g)||delete a[g]});const p=c;let v;const A=Object.entries(u);for(let g=0;g<A.length;g++){const[,x]=A[g];if(!x||typeof x!="object"||!("propPanel"in x)||!x.propPanel||typeof x.propPanel!="object")continue;const y=x.propPanel;if(!("defaultSchema"in y)||!y.defaultSchema||typeof y.defaultSchema!="object")continue;const f=y.defaultSchema;if(!("type"in f)||typeof f.type!="string")continue;const m=f.type;if(m===p){const C={type:m};Object.keys(f).forEach(S=>{S!=="type"&&Object.prototype.hasOwnProperty.call(f,S)&&(C[S]=f[S])}),v={propPanel:{defaultSchema:C}};break}}const b=v==null?void 0:v.propPanel;if(b!=null&&b.defaultSchema){const g=b.defaultSchema,x=a;for(const y of Object.keys(g))if(!Object.prototype.hasOwnProperty.call(a,y)&&Object.prototype.hasOwnProperty.call(g,y)){const f=g[y];f!==void 0&&(x[y]=f)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=builtInPlugins,this.options={},this.setSize=debounce$1(()=>{if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render()},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=p)}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
186
|
+
`)&&(_=_.slice(0,-1)),_},f=(b==null?void 0:b.font)||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),C=buildStyledTextContainer(a,m,x?A:s),S=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){C.innerHTML=S.split("").map((w,_)=>`<span style="letter-spacing:${String(s).length===_+1?0:"inherit"};">${w}</span>`).join("");return}if(makeElementPlainTextContentEditable(C),C.tabIndex=v||0,C.innerText=u==="designer"?s:S,C.addEventListener("blur",w=>{d&&d({key:"content",value:y(w.target)}),p&&p()}),c.dynamicFontSize){let w;C.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!C.textContent)return;w=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(C),startingFontSize:w}),C.style.fontSize=`${w}pt`;const{topAdj:_,bottomAdj:I}=getBrowserVerticalFontAdjustments(m,w??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);C.style.paddingTop=`${_}px`,C.style.marginBottom=`${I}px`})()},0)})}x&&(C.style.color=PLACEHOLDER_FONT_COLOR,C.addEventListener("focus",()=>{C.innerText===A&&(C.innerText="",C.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{C.focus();const w=window.getSelection(),_=document.createRange();w&&_&&(_.selectNodeContents(C),_.collapse(!1),w==null||w.removeAllRanges(),w==null||w.addRange(_))})},buildStyledTextContainer=(a,s,c)=>{const{schema:u,rootElement:d,mode:p}=a;let v;u.dynamicFontSize&&c&&(v=calculateDynamicFontSize({textSchema:u,fontKitFont:s,value:c,startingFontSize:v}));const{topAdj:A,bottomAdj:b}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),x=b.toString(),y=document.createElement("div"),f={padding:0,resize:"none",backgroundColor:getBackgroundColor(c,u),border:"none",display:"flex",flexDirection:"column",justifyContent:mapVerticalAlignToFlex(u.verticalAlignment),width:"100%",height:"100%",cursor:isEditable(p,u)?"text":"default"};Object.assign(y.style,f),d.innerHTML="",d.appendChild(y);const m=[];u.strikethrough&&m.push("line-through"),u.underline&&m.push("underline");const C={fontFamily:u.fontName?`'${u.fontName}'`:"inherit",color:u.fontColor?u.fontColor:DEFAULT_FONT_COLOR,fontSize:`${v??u.fontSize??DEFAULT_FONT_SIZE}pt`,letterSpacing:`${u.characterSpacing??DEFAULT_CHARACTER_SPACING}pt`,lineHeight:`${u.lineHeight??DEFAULT_LINE_HEIGHT}em`,textAlign:u.alignment??DEFAULT_ALIGNMENT,whiteSpace:"pre-wrap",wordBreak:"break-word",resize:"none",border:"none",outline:"none",marginBottom:`${x}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},S=document.createElement("div");return S.id="text-"+String(u.id),Object.assign(S.style,C),y.appendChild(S),S},makeElementPlainTextContentEditable=a=>{if(!isFirefox()){a.contentEditable="plaintext-only";return}a.contentEditable="true",a.addEventListener("keydown",s=>{s.key==="Enter"&&!s.shiftKey&&(s.preventDefault(),document.execCommand("insertLineBreak",!1,void 0))}),a.addEventListener("paste",s=>{var d;s.preventDefault();const c=(d=s.clipboardData)==null?void 0:d.getData("text"),u=window.getSelection();u!=null&&u.rangeCount&&(u.deleteFromDocument(),u.getRangeAt(0).insertNode(document.createTextNode(c||"")),u.collapseToEnd())})},mapVerticalAlignToFlex=a=>{switch(a){case VERTICAL_ALIGN_TOP:return"flex-start";case VERTICAL_ALIGN_MIDDLE:return"center";case VERTICAL_ALIGN_BOTTOM:return"flex-end"}return"flex-start"},getBackgroundColor=(a,s)=>!a||!s.backgroundColor?"transparent":s.backgroundColor,textSchema={pdf:pdfRender,ui:uiRender,propPanel,icon:createSvgStr(TextCursorInput)},builtInPlugins={Text:textSchema},I18nContext=reactExports.createContext(i18n),FontContext=reactExports.createContext(getDefaultFont()),PluginsRegistry=reactExports.createContext(builtInPlugins),OptionsContext=reactExports.createContext({}),CacheContext=reactExports.createContext(new Map),hotkeys=function(a,s){return hotkeys$1(a,s)};hotkeys.shift=!1,hotkeys.unbind=function(a){const s=hotkeys$1;typeof s.unbind=="function"&&s.unbind(a)};const uuid$6=()=>"xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g,a=>{const s=Math.random()*16|0;return(a=="x"?s:s&3|8).toString(16)}),set$2=(a,s,c)=>{s=Array.isArray(s)?s:s.replace("[",".").replace("]","").split(".");let u=a;s.forEach((d,p,v)=>{if(p==s.length-1)u[d]=c;else{if(!Object.prototype.hasOwnProperty.call(u,d)){const A=v[p+1];u[d]=String(Number(A))===A?[]:{}}u=u[d]}})},debounce$1=(a,s=20)=>{let c=null;return(...d)=>{c&&clearTimeout(c),c=setTimeout(()=>a(...d),s)}},shift=(a,s,c)=>{c&&(s=-s);const u=`${a}`.split("e");return+`${u[0]}e${u[1]?Number(u[1])+s:s}`},round$1=(a,s)=>shift(Math.round(shift(a,s,!1)),s,!0),flatten=a=>[].concat(...a),up="up",shiftUp="shift+up",down="down",shiftDown="shift+down",left="left",shiftLeft="shift+left",right="right",shiftRight="shift+right",rmWin="backspace",rmMac="delete",esc="esc",copyWin="ctrl+c",copyMac="command+c",pasteWin="ctrl+v",pasteMac="command+v",redoWin="ctrl+y",redoMac="shift+command+z",undoWin="ctrl+z",undoMac="command+z",saveWin="ctrl+s",saveMac="command+s",selectAllWin="ctrl+a",selectAllMac="command+a",keys$2=[up,shiftUp,down,shiftDown,left,shiftLeft,right,shiftRight,rmMac,rmWin,esc,copyWin,copyMac,pasteWin,pasteMac,redoWin,redoMac,undoWin,undoMac,saveWin,saveMac,selectAllWin,selectAllMac],initShortCuts=a=>{hotkeys(keys$2.join(),(s,c)=>{switch(c.shortcut){case up:case shiftUp:s.preventDefault(),a.move("up",hotkeys.shift);break;case down:case shiftDown:s.preventDefault(),a.move("down",hotkeys.shift);break;case left:case shiftLeft:s.preventDefault(),a.move("left",hotkeys.shift);break;case right:case shiftRight:s.preventDefault(),a.move("right",hotkeys.shift);break;case rmWin:case rmMac:a.remove();break;case esc:a.esc();break;case copyWin:case copyMac:a.copy();break;case pasteWin:case pasteMac:a.paste();break;case redoWin:case redoMac:a.redo();break;case undoWin:case undoMac:a.undo();break;case saveWin:case saveMac:s.preventDefault(),a.save();break;case selectAllWin:case selectAllMac:s.preventDefault(),a.selectAll();break}})},destroyShortCuts=()=>{hotkeys.unbind(keys$2.join())};function detectMimeType(a){const s=new DataView(a);return s.getUint8(0)===137&&s.getUint8(1)===80&&s.getUint8(2)===78&&s.getUint8(3)===71?"image/png":s.getUint8(0)===255&&s.getUint8(1)===216&&s.getUint8(2)===255?"image/jpeg":""}const arrayBufferToBase64=a=>{const s=detectMimeType(a),c=new Uint8Array(a);let u="";for(let p=0;p<c.length;p++)u+=String.fromCharCode(c[p]);const d=btoa(u);return s?`data:${s};base64,${d}`:`data:application/octet-stream;base64,${d}`},convertSchemasForUI=a=>(a.schemas.forEach(s=>{s.forEach(c=>{c.id=uuid$6(),c.content=c.content||""})}),a.schemas),template2SchemasList=async a=>{const s=cloneDeep$1(a),{basePdf:c,schemas:u}=s,d=convertSchemasForUI(s);let p=[];if(isBlankPdf(c))p=u.map(()=>({width:c.width,height:c.height}));else{const b=await getB64BasePdf(c),g=b64toUint8Array(b);p=await pdf2size(g)}const v=d.length,A=p.length;return(v<A?d.concat(new Array(A-v).fill(cloneDeep$1([]))):d.slice(0,p.length)).map((b,g)=>(Object.values(b).forEach(x=>{const{width:y,height:f}=p[g],m=x.position.x+x.width,C=x.position.y+x.height;if(y<m){const S=m-y;x.position.x+=S}if(f<C){const S=C-f;x.position.y+=S}}),b))},schemasList2template=(a,s)=>({schemas:cloneDeep$1(a).map(c=>c.map(u=>(delete u.id,u))),basePdf:s}),getUniqueSchemaName=a=>{const{copiedSchemaName:s,schema:c,stackUniqueSchemaNames:u}=a,d=c.map(g=>g.name).concat(u),p=d.reduce((g,x)=>Object.assign(g,{originalName:x,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const x=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[x]??0)<f&&(p[x]=f)});const A=v(s);if(p[A]){const g=p[A],x=`${A} copy ${g+1}`;return u.push(x),x}const b=`${s} copy`;return u.push(b),b},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=b=>{let g=0;const{position:x}=b;switch(s){case"up":g=round$1(x.y-v,2);break;case"down":g=round$1(x.y+v,2);break;case"left":g=round$1(x.x-v,2);break;case"right":g=round$1(x.x+v,2);break}return g>0?g:0};return c.map(b=>{let g=A(b);const{width:x,height:y}=b;return p==="x"?g=g>d.width-x?round$1(d.width-x,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:b.id}})},getPagesScrollTopByIndex=(a,s,c)=>a.slice(0,s).reduce((u,d)=>u+(d.height*ZOOM+RULER_HEIGHT*c)*c,0),getSidebarContentHeight=a=>a-RULER_HEIGHT-RULER_HEIGHT/2-30,handlePositionSizeChange=(a,s,c,u,d)=>{const p=isBlankPdf(u)?u.padding:[0,0,0,0],[v,A,b,g]=p,{width:x,height:y}=d,f=(m,C,S)=>Math.min(Math.max(Number(m),C),S);s==="position.x"?a.position.x=f(c,g,x-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-b):s==="width"?a.width=f(c,0,x-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-b))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(g=>{d.includes(g)||delete a[g]});const p=c;let v;const A=Object.entries(u);for(let g=0;g<A.length;g++){const[,x]=A[g];if(!x||typeof x!="object"||!("propPanel"in x)||!x.propPanel||typeof x.propPanel!="object")continue;const y=x.propPanel;if(!("defaultSchema"in y)||!y.defaultSchema||typeof y.defaultSchema!="object")continue;const f=y.defaultSchema;if(!("type"in f)||typeof f.type!="string")continue;const m=f.type;if(m===p){const C={type:m};Object.keys(f).forEach(S=>{S!=="type"&&Object.prototype.hasOwnProperty.call(f,S)&&(C[S]=f[S])}),v={propPanel:{defaultSchema:C}};break}}const b=v==null?void 0:v.propPanel;if(b!=null&&b.defaultSchema){const g=b.defaultSchema,x=a;for(const y of Object.keys(g))if(!Object.prototype.hasOwnProperty.call(a,y)&&Object.prototype.hasOwnProperty.call(g,y)){const f=g[y];f!==void 0&&(x[y]=f)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((b,{key:g,value:x,schemaId:y})=>{const f=b.find(m=>m.id===y);return f&&(set$2(f,g,x),g==="type"?handleTypeChange(f,g,x,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,x,u,p)),b},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=builtInPlugins,this.options={},this.setSize=debounce$1(()=>{this.domContainer&&(this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.render())},100),this.resizeObserver=new ResizeObserver(this.setSize),checkUIProps(s);const{domContainer:c,template:u,options:d={},plugins:p={}}=s;this.domContainer=c,this.template=cloneDeep$1(u),this.options=d,this.size={height:this.domContainer.clientHeight||window.innerHeight,width:this.domContainer.clientWidth||window.innerWidth},this.resizeObserver.observe(this.domContainer);const{lang:v,font:A}=d;v&&(this.lang=v),A&&(this.font=A),Object.values(p).length>0&&(this.pluginsRegistry=p)}getLang(){return this.lang}getFont(){return this.font}getPluginsRegistry(){return this.pluginsRegistry}getOptions(){return this.options}getTemplate(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.template}updateTemplate(s){if(checkTemplate(s),!this.domContainer)throw Error(DESTROYED_ERR_MSG);this.template=cloneDeep$1(s),this.render()}updateOptions(s){checkUIOptions(s);const{lang:c,font:u}=s||{};c&&(this.lang=c),u&&(this.font=u),this.options=Object.assign(this.options,s),this.render()}destroy(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);ReactDOM.unmountComponentAtNode(this.domContainer),this.resizeObserver.unobserve(this.domContainer),this.domContainer=null}}class PreviewUI extends BaseUIClass{constructor(s){super(s),checkPreviewProps(s),this.inputs=convertToStingObjectArray(cloneDeep$1(s.inputs))}getInputs(){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);return this.inputs}setInputs(s){if(!this.domContainer)throw Error(DESTROYED_ERR_MSG);checkInputs(s),this.inputs=convertToStingObjectArray(s),this.render()}}function convertToStingObjectArray(a){return a.map(s=>{const c={};return Object.keys(s).forEach(u=>{const d=s[u];Array.isArray(d)?c[u]=JSON.stringify(d):c[u]=d}),c})}function useCombinedRefs(){for(var a=arguments.length,s=new Array(a),c=0;c<a;c++)s[c]=arguments[c];return reactExports.useMemo(()=>u=>{s.forEach(d=>d(u))},s)}const canUseDOM=typeof window<"u"&&typeof window.document<"u"&&typeof window.document.createElement<"u";function isWindow$4(a){const s=Object.prototype.toString.call(a);return s==="[object Window]"||s==="[object global]"}function isNode$1(a){return"nodeType"in a}function getWindow$1(a){var s,c;return a?isWindow$4(a)?a:isNode$1(a)&&(s=(c=a.ownerDocument)==null?void 0:c.defaultView)!=null?s:window:window}function isDocument(a){const{Document:s}=getWindow$1(a);return a instanceof s}function isHTMLElement(a){return isWindow$4(a)?!1:a instanceof getWindow$1(a).HTMLElement}function isSVGElement(a){return a instanceof getWindow$1(a).SVGElement}function getOwnerDocument(a){return a?isWindow$4(a)?a.document:isNode$1(a)?isDocument(a)?a:isHTMLElement(a)||isSVGElement(a)?a.ownerDocument:document:document:document}const useIsomorphicLayoutEffect$1=canUseDOM?reactExports.useLayoutEffect:reactExports.useEffect;function useEvent$1(a){const s=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{s.current=a}),reactExports.useCallback(function(){for(var c=arguments.length,u=new Array(c),d=0;d<c;d++)u[d]=arguments[d];return s.current==null?void 0:s.current(...u)},[])}function useInterval(){const a=reactExports.useRef(null),s=reactExports.useCallback((u,d)=>{a.current=setInterval(u,d)},[]),c=reactExports.useCallback(()=>{a.current!==null&&(clearInterval(a.current),a.current=null)},[]);return[s,c]}function useLatestValue(a,s){s===void 0&&(s=[a]);const c=reactExports.useRef(a);return useIsomorphicLayoutEffect$1(()=>{c.current!==a&&(c.current=a)},s),c}function useLazyMemo(a,s){const c=reactExports.useRef();return reactExports.useMemo(()=>{const u=a(c.current);return c.current=u,u},[...s])}function useNodeRef(a){const s=useEvent$1(a),c=reactExports.useRef(null),u=reactExports.useCallback(d=>{d!==c.current&&(s==null||s(d,c.current)),c.current=d},[]);return[c,u]}function usePrevious$2(a){const s=reactExports.useRef();return reactExports.useEffect(()=>{s.current=a},[a]),s.current}let ids={};function useUniqueId(a,s){return reactExports.useMemo(()=>{if(s)return s;const c=ids[a]==null?0:ids[a]+1;return ids[a]=c,a+"-"+c},[a,s])}function createAdjustmentFn(a){return function(s){for(var c=arguments.length,u=new Array(c>1?c-1:0),d=1;d<c;d++)u[d-1]=arguments[d];return u.reduce((p,v)=>{const A=Object.entries(v);for(const[b,g]of A){const x=p[b];x!=null&&(p[b]=x+a*g)}return p},{...s})}}const add$1=createAdjustmentFn(1),subtract=createAdjustmentFn(-1);function hasViewportRelativeCoordinates(a){return"clientX"in a&&"clientY"in a}function isKeyboardEvent(a){if(!a)return!1;const{KeyboardEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function isTouchEvent(a){if(!a)return!1;const{TouchEvent:s}=getWindow$1(a.target);return s&&a instanceof s}function getEventCoordinates(a){if(isTouchEvent(a)){if(a.touches&&a.touches.length){const{clientX:s,clientY:c}=a.touches[0];return{x:s,y:c}}else if(a.changedTouches&&a.changedTouches.length){const{clientX:s,clientY:c}=a.changedTouches[0];return{x:s,y:c}}}return hasViewportRelativeCoordinates(a)?{x:a.clientX,y:a.clientY}:null}const CSS$1=Object.freeze({Translate:{toString(a){if(!a)return;const{x:s,y:c}=a;return"translate3d("+(s?Math.round(s):0)+"px, "+(c?Math.round(c):0)+"px, 0)"}},Scale:{toString(a){if(!a)return;const{scaleX:s,scaleY:c}=a;return"scaleX("+s+") scaleY("+c+")"}},Transform:{toString(a){if(a)return[CSS$1.Translate.toString(a),CSS$1.Scale.toString(a)].join(" ")}},Transition:{toString(a){let{property:s,duration:c,easing:u}=a;return s+" "+c+"ms "+u}}}),SELECTOR="a,frame,iframe,input:not([type=hidden]):not(:disabled),select:not(:disabled),textarea:not(:disabled),button:not(:disabled),*[tabindex]";function findFirstFocusableNode(a){return a.matches(SELECTOR)?a:a.querySelector(SELECTOR)}const hiddenStyles={display:"none"};function HiddenText(a){let{id:s,value:c}=a;return React.createElement("div",{id:s,style:hiddenStyles},c)}function LiveRegion(a){let{id:s,announcement:c,ariaLiveType:u="assertive"}=a;const d={position:"fixed",top:0,left:0,width:1,height:1,margin:-1,border:0,padding:0,overflow:"hidden",clip:"rect(0 0 0 0)",clipPath:"inset(100%)",whiteSpace:"nowrap"};return React.createElement("div",{id:s,style:d,role:"status","aria-live":u,"aria-atomic":!0},c)}function useAnnouncement(){const[a,s]=reactExports.useState("");return{announce:reactExports.useCallback(u=>{u!=null&&s(u)},[]),announcement:a}}const DndMonitorContext=reactExports.createContext(null);function useDndMonitor(a){const s=reactExports.useContext(DndMonitorContext);reactExports.useEffect(()=>{if(!s)throw new Error("useDndMonitor must be used within a children of <DndContext>");return s(a)},[a,s])}function useDndMonitorProvider(){const[a]=reactExports.useState(()=>new Set),s=reactExports.useCallback(u=>(a.add(u),()=>a.delete(u)),[a]);return[reactExports.useCallback(u=>{let{type:d,event:p}=u;a.forEach(v=>{var A;return(A=v[d])==null?void 0:A.call(v,p)})},[a]),s]}const defaultScreenReaderInstructions={draggable:`
|
187
187
|
To pick up a draggable item, press the space bar.
|
188
188
|
While dragging, use the arrow keys to move the item.
|
189
189
|
Press space again to drop the item in its new position, or press escape to cancel.
|
package/package.json
CHANGED
package/src/class.ts
CHANGED
@@ -36,7 +36,9 @@ export abstract class BaseUIClass {
|
|
36
36
|
private options: UIOptions = {};
|
37
37
|
|
38
38
|
private readonly setSize = debounce(() => {
|
39
|
-
if (!this.domContainer)
|
39
|
+
if (!this.domContainer) {
|
40
|
+
return;
|
41
|
+
}
|
40
42
|
this.size = {
|
41
43
|
height: this.domContainer.clientHeight || window.innerHeight,
|
42
44
|
width: this.domContainer.clientWidth || window.innerWidth,
|