@pdfme/ui 5.4.4-dev.1 → 5.4.4
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 +1 -1
- package/dist/index.umd.js +1 -1
- package/package.json +1 -1
- package/src/helper.ts +1 -1
package/dist/index.es.js
CHANGED
@@ -74098,7 +74098,7 @@ const uuid$6 = () => "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (a)
|
|
74098
74098
|
const s = Math.random() * 16 | 0;
|
74099
74099
|
return (a == "x" ? s : s & 3 | 8).toString(16);
|
74100
74100
|
}), set$2 = (a, s, c) => {
|
74101
|
-
s = Array.isArray(s) ? s : s.replace(
|
74101
|
+
s = Array.isArray(s) ? s : s.replace("[", ".").replace("]", "").split(".");
|
74102
74102
|
let u = a;
|
74103
74103
|
s.forEach((d, p, v) => {
|
74104
74104
|
if (p == s.length - 1)
|
package/dist/index.umd.js
CHANGED
@@ -174,7 +174,7 @@ ${q}
|
|
174
174
|
* This source code is licensed under the ISC license.
|
175
175
|
* See the LICENSE file in the root directory of this source tree.
|
176
176
|
*/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?.dynamicFontSize,p.onchange=x=>{const g=x.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?.dynamicFontSize;return{fontName:{title:c("schemas.text.fontName"),type:"string",widget:"select",default:p,placeholder:p,props:{options:d.map(x=>({label:x,value:x}))},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:x,_cache:g}=a,b=isEditable(u,c)&&A&&!s,y=S=>{let $=S.innerText;return $.endsWith(`
|
177
|
-
`)&&($=$.slice(0,-1)),$},f=x?.font||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),E=buildStyledTextContainer(a,m,b?A:s),w=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){E.innerHTML=w.split("").map((S,$)=>`<span style="letter-spacing:${String(s).length===$+1?0:"inherit"};">${S}</span>`).join("");return}if(makeElementPlainTextContentEditable(E),E.tabIndex=v||0,E.innerText=u==="designer"?s:w,E.addEventListener("blur",S=>{d&&d({key:"content",value:y(S.target)}),p&&p()}),c.dynamicFontSize){let S;E.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!E.textContent)return;S=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(E),startingFontSize:S}),E.style.fontSize=`${S}pt`;const{topAdj:$,bottomAdj:T}=getBrowserVerticalFontAdjustments(m,S??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);E.style.paddingTop=`${$}px`,E.style.marginBottom=`${T}px`})()},0)})}b&&(E.style.color=PLACEHOLDER_FONT_COLOR,E.addEventListener("focus",()=>{E.innerText===A&&(E.innerText="",E.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{E.focus();const S=window.getSelection(),$=document.createRange();S&&$&&($.selectNodeContents(E),$.collapse(!1),S?.removeAllRanges(),S?.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:x}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),b=x.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 E={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:`${b}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},w=document.createElement("div");return w.id="text-"+String(u.id),Object.assign(w.style,E),y.appendChild(w),w},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=>{s.preventDefault();const c=s.clipboardData?.getData("text"),u=window.getSelection();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(pluginRegistry(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(/\[/g,".").replace(/\]/g,"").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 x=await getB64BasePdf(c),g=b64toUint8Array(x);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((x,g)=>(Object.values(x).forEach(b=>{const{width:y,height:f}=p[g],m=b.position.x+b.width,E=b.position.y+b.height;if(y<m){const w=m-y;b.position.x+=w}if(f<E){const w=E-f;b.position.y+=w}}),x))},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,b)=>Object.assign(g,{originalName:b,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const b=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[b]??0)<f&&(p[b]=f)});const A=v(s);if(p[A]){const g=p[A],b=`${A} copy ${g+1}`;return u.push(b),b}const x=`${s} copy`;return u.push(x),x},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=x=>{let g=0;const{position:b}=x;switch(s){case"up":g=round$1(b.y-v,2);break;case"down":g=round$1(b.y+v,2);break;case"left":g=round$1(b.x-v,2);break;case"right":g=round$1(b.x+v,2);break}return g>0?g:0};return c.map(x=>{let g=A(x);const{width:b,height:y}=x;return p==="x"?g=g>d.width-b?round$1(d.width-b,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:x.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,x,g]=p,{width:b,height:y}=d,f=(m,E,w)=>Math.min(Math.max(Number(m),E),w);s==="position.x"?a.position.x=f(c,g,b-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-x):s==="width"?a.width=f(c,0,b-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-x))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(v=>{d.includes(v)||delete a[v]});const p=u.findByType(c);if(p?.propPanel.defaultSchema){const v=p.propPanel.defaultSchema,A=a;for(const x of Object.keys(v))if(!Object.prototype.hasOwnProperty.call(a,x)){const g=v[x];g!==void 0&&(A[x]=g)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((x,{key:g,value:b,schemaId:y})=>{const f=x.find(m=>m.id===y);return f&&(set$2(f,g,b),g==="type"?handleTypeChange(f,g,b,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,b,u,p)),x},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM},setFontNameRecursively=(a,s,c=new WeakSet)=>{if(!(!a||typeof a!="object"||c.has(a))){c.add(a);for(const u in a)u==="fontName"&&Object.prototype.hasOwnProperty.call(a,u)&&a[u]===void 0?a[u]=s:typeof a[u]=="object"&&a[u]!==null&&setFontNameRecursively(a[u],s,c)}};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=pluginRegistry(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=pluginRegistry(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?.(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[x,g]of A){const b=p[x];b!=null&&(p[x]=b+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:`
|
177
|
+
`)&&($=$.slice(0,-1)),$},f=x?.font||getDefaultFont(),m=await getFontKitFont(c.fontName,f,g),E=buildStyledTextContainer(a,m,b?A:s),w=replaceUnsupportedChars(s,m);if(!isEditable(u,c)){E.innerHTML=w.split("").map((S,$)=>`<span style="letter-spacing:${String(s).length===$+1?0:"inherit"};">${S}</span>`).join("");return}if(makeElementPlainTextContentEditable(E),E.tabIndex=v||0,E.innerText=u==="designer"?s:w,E.addEventListener("blur",S=>{d&&d({key:"content",value:y(S.target)}),p&&p()}),c.dynamicFontSize){let S;E.addEventListener("keyup",()=>{setTimeout(()=>{(()=>{if(!E.textContent)return;S=calculateDynamicFontSize({textSchema:c,fontKitFont:m,value:y(E),startingFontSize:S}),E.style.fontSize=`${S}pt`;const{topAdj:$,bottomAdj:T}=getBrowserVerticalFontAdjustments(m,S??c.fontSize??DEFAULT_FONT_SIZE,c.lineHeight??DEFAULT_LINE_HEIGHT,c.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT);E.style.paddingTop=`${$}px`,E.style.marginBottom=`${T}px`})()},0)})}b&&(E.style.color=PLACEHOLDER_FONT_COLOR,E.addEventListener("focus",()=>{E.innerText===A&&(E.innerText="",E.style.color=c.fontColor??DEFAULT_FONT_COLOR)})),u==="designer"&&setTimeout(()=>{E.focus();const S=window.getSelection(),$=document.createRange();S&&$&&($.selectNodeContents(E),$.collapse(!1),S?.removeAllRanges(),S?.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:x}=getBrowserVerticalFontAdjustments(s,v??u.fontSize??DEFAULT_FONT_SIZE,u.lineHeight??DEFAULT_LINE_HEIGHT,u.verticalAlignment??DEFAULT_VERTICAL_ALIGNMENT),g=A.toString(),b=x.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 E={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:`${b}px`,paddingTop:`${g}px`,backgroundColor:"transparent",textDecoration:m.join(" ")},w=document.createElement("div");return w.id="text-"+String(u.id),Object.assign(w.style,E),y.appendChild(w),w},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=>{s.preventDefault();const c=s.clipboardData?.getData("text"),u=window.getSelection();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(pluginRegistry(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 x=await getB64BasePdf(c),g=b64toUint8Array(x);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((x,g)=>(Object.values(x).forEach(b=>{const{width:y,height:f}=p[g],m=b.position.x+b.width,E=b.position.y+b.height;if(y<m){const w=m-y;b.position.x+=w}if(f<E){const w=E-f;b.position.y+=w}}),x))},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,b)=>Object.assign(g,{originalName:b,copiedNum:0}),{}),v=g=>g.replace(/ copy$| copy [0-9]*$/,"");d.filter(g=>/ copy$| copy [0-9]*$/.test(g)).forEach(g=>{const b=v(g),y=g.match(/[0-9]*$/),f=y&&y[0]?Number(y[0]):1;(p[b]??0)<f&&(p[b]=f)});const A=v(s);if(p[A]){const g=p[A],b=`${A} copy ${g+1}`;return u.push(b),b}const x=`${s} copy`;return u.push(x),x},moveCommandToChangeSchemasArg=a=>{const{command:s,activeSchemas:c,isShift:u,pageSize:d}=a,p=s==="up"||s==="down"?"y":"x",v=u?.1:1,A=x=>{let g=0;const{position:b}=x;switch(s){case"up":g=round$1(b.y-v,2);break;case"down":g=round$1(b.y+v,2);break;case"left":g=round$1(b.x-v,2);break;case"right":g=round$1(b.x+v,2);break}return g>0?g:0};return c.map(x=>{let g=A(x);const{width:b,height:y}=x;return p==="x"?g=g>d.width-b?round$1(d.width-b,2):g:g=g>d.height-y?round$1(d.height-y,2):g,{key:`position.${p}`,value:g,schemaId:x.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,x,g]=p,{width:b,height:y}=d,f=(m,E,w)=>Math.min(Math.max(Number(m),E),w);s==="position.x"?a.position.x=f(c,g,b-a.width-A):s==="position.y"?a.position.y=f(c,v,y-a.height-x):s==="width"?a.width=f(c,0,b-a.position.x-A):s==="height"&&(a.height=f(c,0,y-a.position.y-x))},handleTypeChange=(a,s,c,u)=>{if(s!=="type")return;const d=["id","name","type","position","required"];Object.keys(a).forEach(v=>{d.includes(v)||delete a[v]});const p=u.findByType(c);if(p?.propPanel.defaultSchema){const v=p.propPanel.defaultSchema,A=a;for(const x of Object.keys(v))if(!Object.prototype.hasOwnProperty.call(a,x)){const g=v[x];g!==void 0&&(A[x]=g)}}a.readOnly&&(a.required=!1)},changeSchemas=a=>{const{objs:s,schemas:c,basePdf:u,pluginsRegistry:d,pageSize:p,commitSchemas:v}=a,A=s.reduce((x,{key:g,value:b,schemaId:y})=>{const f=x.find(m=>m.id===y);return f&&(set$2(f,g,b),g==="type"?handleTypeChange(f,g,b,d):["position.x","position.y","width","height"].includes(g)&&handlePositionSizeChange(f,g,b,u,p)),x},cloneDeep$1(c));v(A)},useMaxZoom=()=>{const a=reactExports.useContext(OptionsContext);return a.maxZoom?a.maxZoom/100:DEFAULT_MAX_ZOOM},setFontNameRecursively=(a,s,c=new WeakSet)=>{if(!(!a||typeof a!="object"||c.has(a))){c.add(a);for(const u in a)u==="fontName"&&Object.prototype.hasOwnProperty.call(a,u)&&a[u]===void 0?a[u]=s:typeof a[u]=="object"&&a[u]!==null&&setFontNameRecursively(a[u],s,c)}};class BaseUIClass{constructor(s){this.lang=DEFAULT_LANG,this.font=getDefaultFont(),this.pluginsRegistry=pluginRegistry(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=pluginRegistry(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?.(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[x,g]of A){const b=p[x];b!=null&&(p[x]=b+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:`
|
178
178
|
To pick up a draggable item, press the space bar.
|
179
179
|
While dragging, use the arrow keys to move the item.
|
180
180
|
Press space again to drop the item in its new position, or press escape to cancel.
|
package/package.json
CHANGED
package/src/helper.ts
CHANGED
@@ -49,7 +49,7 @@ export const uuid = () =>
|
|
49
49
|
});
|
50
50
|
|
51
51
|
const set = <T extends object>(obj: T, path: string | string[], value: unknown) => {
|
52
|
-
path = Array.isArray(path) ? path : path.replace(
|
52
|
+
path = Array.isArray(path) ? path : path.replace('[', '.').replace(']', '').split('.');
|
53
53
|
let src: Record<string, unknown> = obj as Record<string, unknown>;
|
54
54
|
path.forEach((key, index, array) => {
|
55
55
|
if (index == path.length - 1) {
|