zois-core 1.1.1 → 1.1.3

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/popups.js CHANGED
@@ -1 +1 @@
1
- import{getRelativeWidth as C,getRelativeX as y,getRelativeY as D}from"./ui";import{MOD_DATA as p}from"./index";import{useState as g,useEffect as f}from"react";import x from"react-dom/client";import{create as T}from"zustand";import{CircleAlert as z,CircleCheck as O,CircleX as k,Info as E}from"lucide-react";import{Fragment as w,jsx as a,jsxs as d}from"react/jsx-runtime";function I({children:o}){const[t,e]=g({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{e({fontFamily:CommonGetFontName(),bottom:D(5)+"px",left:y(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),a("div",{className:"zcToastsContainer",style:t,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:o})}const P=({type:o,theme:t})=>{switch(o){case"info":return a(E,{style:{width:"1.65em",height:"1.65em",fill:t?t.iconFillColor:"#addbff",stroke:t?t.iconStrokeColor:"#385073"}});case"success":return a(O,{style:{width:"1.65em",height:"1.65em",fill:t?t.iconFillColor:"#c3ffc3",stroke:t?t.iconStrokeColor:"#028f74"}});case"warning":return a(z,{style:{width:"1.65em",height:"1.65em",fill:t?t.iconFillColor:"#ffdfaf",stroke:t?t.iconStrokeColor:"#9c7633"}});case"error":return a(k,{style:{width:"1.65em",height:"1.65em",fill:t?t.iconFillColor:"#ffb2b2",stroke:t?t.iconStrokeColor:"#7f2828"}});case"spinner":return a("div",{style:{width:"1.65em",height:"1.65em",boxSizing:"border-box",border:"2px solid",borderRadius:"100%",borderColor:`transparent ${t?t.iconFillColor:"rgb(154 154 255)"}`,animation:"zcSpin 0.65s linear infinite"}})}};function R({title:o,message:t,type:e,duration:r,id:s,theme:i}){const[n,c]=g({}),[l,m]=g(!1);return f(()=>{const u=()=>{const h=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,v=Math.min(h,b)/100;c({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*v+"px",padding:1.5*v+"px",background:i?i.backgroundColor:e==="success"?"#3ece7e":e==="warning"?"#debf72":e==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)"})};window.addEventListener("resize",u),u();const S=setTimeout(()=>m(!0),r);return()=>{clearTimeout(S),window.removeEventListener("resize",u)}},[]),d("div",{className:`zcToast ${l&&"exiting"}`,"data-zc-toast-type":e,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[a(P,{type:e,theme:i}),d("div",{children:[o&&t&&d(w,{children:[a("p",{style:{color:i?i.titleColor:"white"},children:o}),a("p",{style:{color:i?i.messageColor:e==="info"||e==="spinner"?"#b8b8ff":e==="success"?"#c7f9c7":e==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%",overflowWrap:"anywhere",marginTop:"0.25em"},children:t})]}),(!o&&t||o&&!t)&&a("p",{style:{position:"relative",zIndex:5},children:o||t})]})]}),e!=="spinner"&&a("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",background:i?i.progressBarColor:e==="info"?"rgb(103, 103, 234)":e==="success"?"#34bc71":e==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})}function M({dialog:o}){const t=window.ZOISCORE.useDialogStore(n=>n.clearDialog),[e,r]=g({}),[s,i]=g([]);return f(()=>{const n=()=>{const c=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,m=Math.min(c,l)/100;r({width:C(o.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:CommonGetFontName(),border:"none",padding:2*m})};return window.addEventListener("resize",n),n(),()=>{window.removeEventListener("resize",n)}},[]),d("dialog",{open:Object.keys(e).length>0,"data-zc-dialog-type":o.type,style:e,children:[o.title&&a("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:o.title}),a("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:o.body}),a("div",{style:{display:"flex",flexDirection:o.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:o.buttons?.list?.map((n,c)=>a("button",{className:"zcDialogBtn","data-zc-picked":s.includes(c),style:{width:"100%",position:"relative"},onClick:()=>{o.type==="choice_one"?(t(),o.promise.resolve(n.value)):s.includes(c)?i(s.filter(l=>l!==c)):i([...s,c])},children:n.text}))}),o.type==="choice_multiple"&&a("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{t(),o.promise.resolve(o.buttons.list.filter((n,c)=>s.includes(c)).map(n=>n.value))},children:"Confirm"})]})}class F{generateToastId(){return crypto.randomUUID()}process({title:t,message:e,duration:r,type:s,id:i,theme:n}){const{addToast:c,removeToast:l}=window.ZOISCORE.useToastsStore.getState();c({id:i,title:t,message:e,duration:r,type:s,theme:n}),setTimeout(()=>l(i),r+300)}info({title:t,message:e,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:t,message:e,duration:r,type:"info",id:s,theme:i})}success({title:t,message:e,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:t,message:e,duration:r,type:"success",id:s,theme:i})}warn({title:t,message:e,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:t,message:e,duration:r,type:"warning",id:s,theme:i})}error({title:t,message:e,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:t,message:e,duration:r,type:"error",id:s,theme:i})}spinner({title:t,message:e}){const r=this.generateToastId(),s=p.singleToastsTheme;return this.process({title:t,message:e,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(t){const{removeToast:e}=window.ZOISCORE.useToastsStore.getState();e(t)}}class N{showDialog({type:t,title:e,body:r,buttons:s,width:i}){const{setDialog:n}=window.ZOISCORE.useDialogStore.getState();return new Promise((c,l)=>{n({width:i,type:t,title:e,body:r,buttons:s,promise:{resolve:c,reject:l}})})}}function L(){const o=window.ZOISCORE.useToastsStore(e=>e.toasts),t=window.ZOISCORE.useDialogStore(e=>e.dialog);return d(w,{children:[a(I,{children:o.map(({title:e,message:r,type:s,duration:i,id:n,theme:c})=>a(R,{id:n,title:e,message:r,type:s,duration:i,theme:c},n))}),t&&a(M,{dialog:t})]})}class W extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const q=T(o=>({toasts:[],addToast:t=>o(e=>({toasts:[...e.toasts,t]})),removeToast:t=>o(e=>({toasts:e.toasts.filter(r=>r.id!==t)})),clearToasts:()=>o({toasts:[]})})),Y=T(o=>({dialog:null,setDialog:t=>o({dialog:t}),clearDialog:()=>o({dialog:null})}));function K(){customElements.define("zc-virtual-dom",W);const o=document.createElement("zc-virtual-dom");document.body.append(o),x.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(a(L,{}))}const Q=new F,tt=new N;export{tt as dialogsManager,K as initVirtualDOM,Q as toastsManager,Y as useDialogStore,q as useToastsStore};
1
+ import{getRelativeWidth as C,getRelativeX as y,getRelativeY as x}from"./ui";import{MOD_DATA as p}from"./index";import{useState as g,useEffect as f}from"react";import D from"react-dom/client";import{create as T}from"zustand";import{CircleAlert as k,CircleCheck as z,CircleX as O,Info as E}from"lucide-react";import{Fragment as w,jsx as a,jsxs as d}from"react/jsx-runtime";function I({children:o}){const[e,t]=g({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{t({fontFamily:CommonGetFontName(),bottom:x(5)+"px",left:y(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),a("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:o})}const P=({type:o,theme:e})=>{switch(o){case"info":return a(E,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return a(z,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return a(k,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return a(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return a("div",{style:{flexShrink:0,width:"1.65em",height:"1.65em",boxSizing:"border-box",border:"2px solid",borderRadius:"100%",borderColor:`transparent ${e?e.iconFillColor:"rgb(154 154 255)"}`,animation:"zcSpin 0.65s linear infinite"}})}};function R({title:o,message:e,type:t,duration:r,id:s,theme:i}){const[n,c]=g({}),[l,m]=g(!1);return f(()=>{const u=()=>{const h=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,v=Math.min(h,b)/100;c({position:"relative",width:"100%",borderRadius:"0.1em",fontSize:3*v+"px",padding:1.5*v+"px",background:i?i.backgroundColor:t==="success"?"#3ece7e":t==="warning"?"#debf72":t==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)"})};window.addEventListener("resize",u),u();const S=setTimeout(()=>m(!0),r);return()=>{clearTimeout(S),window.removeEventListener("resize",u)}},[]),d("div",{className:`zcToast ${l&&"exiting"}`,"data-zc-toast-type":t,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[a(P,{type:t,theme:i}),d("div",{children:[o&&e&&d(w,{children:[a("p",{style:{color:i?i.titleColor:"white"},children:o}),a("p",{style:{color:i?i.messageColor:t==="info"||t==="spinner"?"#b8b8ff":t==="success"?"#c7f9c7":t==="error"?"#f8bcbc":"#ffeec5",fontSize:"70%",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!o&&e||o&&!e)&&a("p",{style:{position:"relative",zIndex:5},children:o||e})]})]}),t!=="spinner"&&a("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",background:i?i.progressBarColor:t==="info"?"rgb(103, 103, 234)":t==="success"?"#34bc71":t==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})}function M({dialog:o}){const e=window.ZOISCORE.useDialogStore(n=>n.clearDialog),[t,r]=g({}),[s,i]=g([]);return f(()=>{const n=()=>{const c=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,m=Math.min(c,l)/100;r({width:C(o.width),position:"absolute",top:"50%",left:"50%",transform:"translate(-50%, -50%)",background:"rgba(36, 36, 36, 0.96)",zIndex:20,fontFamily:CommonGetFontName(),border:"none",padding:2*m})};return window.addEventListener("resize",n),n(),()=>{window.removeEventListener("resize",n)}},[]),d("dialog",{open:Object.keys(t).length>0,"data-zc-dialog-type":o.type,style:t,children:[o.title&&a("p",{style:{position:"absolute",top:0,left:0,fontWeight:"bold",color:"white",fontSize:"clamp(6px, 2vw, 24px)",padding:"0.25em",background:"#2d2d2d",width:"100%"},children:o.title}),a("p",{style:{padding:"1em",marginTop:"2vw",fontSize:"clamp(6px, 2vw, 24px)",color:"white"},children:o.body}),a("div",{style:{display:"flex",flexDirection:o.buttons.direction,justifyContent:"center",gap:"0.5vw"},children:o.buttons?.list?.map((n,c)=>a("button",{className:"zcDialogBtn","data-zc-picked":s.includes(c),style:{width:"100%",position:"relative"},onClick:()=>{o.type==="choice_one"?(e(),o.promise.resolve(n.value)):s.includes(c)?i(s.filter(l=>l!==c)):i([...s,c])},children:n.text}))}),o.type==="choice_multiple"&&a("button",{style:{cursor:"pointer",color:"white",background:"#4d4d4d",border:"none",marginTop:"1vw",fontSize:"clamp(8px,2.5vw,28px)",padding:"0.2em",borderRadius:"4px"},onClick:()=>{e(),o.promise.resolve(o.buttons.list.filter((n,c)=>s.includes(c)).map(n=>n.value))},children:"Confirm"})]})}class F{generateToastId(){return crypto.randomUUID()}process({title:e,message:t,duration:r,type:s,id:i,theme:n}){const{addToast:c,removeToast:l}=window.ZOISCORE.useToastsStore.getState();c({id:i,title:e,message:t,duration:r,type:s,theme:n}),setTimeout(()=>l(i),r+300)}info({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"info",id:s,theme:i})}success({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"success",id:s,theme:i})}warn({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"warning",id:s,theme:i})}error({title:e,message:t,duration:r}){const s=this.generateToastId(),i=p.singleToastsTheme;this.process({title:e,message:t,duration:r,type:"error",id:s,theme:i})}spinner({title:e,message:t}){const r=this.generateToastId(),s=p.singleToastsTheme;return this.process({title:e,message:t,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(e){const{removeToast:t}=window.ZOISCORE.useToastsStore.getState();t(e)}}class N{showDialog({type:e,title:t,body:r,buttons:s,width:i}){const{setDialog:n}=window.ZOISCORE.useDialogStore.getState();return new Promise((c,l)=>{n({width:i,type:e,title:t,body:r,buttons:s,promise:{resolve:c,reject:l}})})}}function L(){const o=window.ZOISCORE.useToastsStore(t=>t.toasts),e=window.ZOISCORE.useDialogStore(t=>t.dialog);return d(w,{children:[a(I,{children:o.map(({title:t,message:r,type:s,duration:i,id:n,theme:c})=>a(R,{id:n,title:t,message:r,type:s,duration:i,theme:c},n))}),e&&a(M,{dialog:e})]})}class W extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const q=T(o=>({toasts:[],addToast:e=>o(t=>({toasts:[...t.toasts,e]})),removeToast:e=>o(t=>({toasts:t.toasts.filter(r=>r.id!==e)})),clearToasts:()=>o({toasts:[]})})),Y=T(o=>({dialog:null,setDialog:e=>o({dialog:e}),clearDialog:()=>o({dialog:null})}));function K(){customElements.define("zc-virtual-dom",W);const o=document.createElement("zc-virtual-dom");document.body.append(o),D.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(a(L,{}))}const Q=new F,ee=new N;export{ee as dialogsManager,K as initVirtualDOM,Q as toastsManager,Y as useDialogStore,q as useToastsStore};
package/dist/styles.css CHANGED
@@ -1 +1 @@
1
- *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;min-height:100%;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcBackNextButton-btnDisabled{background:#ffa590;pointer-events:none}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcCard{border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;background:var(--tmd-element, white);color:var(--tmd-text, black);padding:.4em 2.5em .4em .4em}.zcCard:hover{border:2px solid var(--tmd-accent-hover, rgb(170, 170, 170))}.zcCard_name{font-size:.5em;color:var(--tmd-text, rgb(100, 100, 100))}.zcCard_value{color:var(--tmd-text, black);margin-top:.4em;font-weight:700}.zcSelect{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;padding:.45em}.zcSelect[opened=true]{border-color:var(--tmd-accent-hover, rgb(0, 96, 223))}.zcSelect[opened=false]:hover{border-color:var(--tmd-accent-hover, rgb(170, 170, 170))}.zcSelect>svg{position:absolute;right:.45em;top:50%;transform:translateY(-50%);width:1.5em;height:1.5em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div[data-zc-position=bottom]{position:absolute;top:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6ed);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div[data-zc-position=top]{position:absolute;bottom:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6ed);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div>div{color:var(--tmd-text, black);width:100%;padding:.45em;border-radius:.25em}.zcSelect>div>div>svg{width:1.25em;height:1.25em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div>div:hover{background:var(--tmd-element-hover, #ededed)}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:10}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{max-width:25vw;animation:zcSlideInFromLeft .3s ease-out forwards}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}@keyframes zcSpin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes zcCursorBlink{0%{border-right-color:transparent}to{border-right-color:#2a2a2a}}.zcCursor{border-right:2px solid var(--tmd-text, rgb(42, 42, 42));width:fit-content}.zcDisabled{pointer-events:none;opacity:.6}
1
+ *{margin:0;padding:0;box-sizing:border-box}.zcButton{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcButton:hover{background:var(--tmd-element-hover, #ebf7fe);border-color:var(--tmd-accent-hover, #7dd3fc);color:var(--tmd-accent-hover, #015a8c)}.zcButton .tooltip{position:absolute;color:#000;text-align:center;padding:4px;border-radius:4px;background:#ff8;border:2px solid #e7e787;width:max-content;min-height:100%;visibility:hidden;z-index:10}.zcButton .tooltip[position=left]{right:calc(100% + 1vw)}.zcButton .tooltip[position=right]{left:calc(100% + 1vw)}.zcButton:hover .tooltip{visibility:visible}.zcButton[data-zc-style=green]{background:#7cff7c;border-color:#52cc52;color:#000}.zcButton[data-zc-style=green]:hover{background:#5ec55e;color:#000}.zcButton[data-zc-style=inverted]{background:var(--tmd-accent, #303030);border:none;color:var(--tmd-text, white)}.zcButton[data-zc-style=inverted]:hover{background:var(--tmd-accent-hover, #474747)}.zcInput{background:var(--tmd-element, white);color:var(--tmd-text, black);padding:2vw;border:2px solid var(--tmd-accent, black);border-radius:4px}.zcInput::placeholder{color:var(--tmd-text, black)}.zcBackNextButton{display:flex;column-gap:2vw;justify-content:center;align-items:center;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, black);border-radius:4px}.zcBackNextButton-btnDisabled{background:#ffa590;pointer-events:none}.zcTabs{display:flex}.zcTabs button{cursor:pointer;width:100%;color:var(--tmd-text, black);background:none;border:none;border-bottom:2px solid var(--tmd-element, rgb(214, 214, 214));padding:.25em}.zcTabs button[data-opened=true]{font-weight:700;border-bottom:2px solid var(--tmd-accent, rgb(81, 81, 231))!important}.zcTabs button:hover{background:var(--tmd-element, rgb(235, 235, 235));border-bottom:2px solid var(--tmd-element-hover, rgb(149, 149, 149))}.zcCard{border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;background:var(--tmd-element, white);color:var(--tmd-text, black);padding:.4em 2.5em .4em .4em}.zcCard:hover{border:2px solid var(--tmd-accent-hover, rgb(170, 170, 170))}.zcCard_name{font-size:.5em;color:var(--tmd-text, rgb(100, 100, 100))}.zcCard_value{color:var(--tmd-text, black);margin-top:.4em;font-weight:700}.zcSelect{cursor:pointer;background:var(--tmd-element, white);color:var(--tmd-text, black);border:2px solid var(--tmd-accent, rgb(195, 195, 195));border-radius:.4em;padding:.45em;z-index:10}.zcSelect[opened=true]{border-color:var(--tmd-accent-hover, rgb(0, 96, 223))}.zcSelect[opened=false]:hover{border-color:var(--tmd-accent-hover, rgb(170, 170, 170))}.zcSelect>svg{position:absolute;right:.45em;top:50%;transform:translateY(-50%);width:1.5em;height:1.5em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div[data-zc-position=bottom]{position:absolute;top:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div[data-zc-position=top]{position:absolute;bottom:calc(100% + .45em);left:0;width:100%;background:var(--tmd-element, #f6f6f6ed);border:2px solid var(--tmd-element-hover, rgb(235 235 235));border-radius:.4em}.zcSelect>div>div{color:var(--tmd-text, black);width:100%;padding:.45em;border-radius:.25em}.zcSelect>div>div>svg{width:1.25em;height:1.25em;color:var(--tmd-accent, rgb(0, 96, 223))}.zcSelect>div>div:hover{background:var(--tmd-element-hover, #ededed)}.zcToastsContainer{display:flex;flex-direction:column;gap:.25vw;cursor:pointer;position:fixed;z-index:10}@keyframes zcToast-progress{0%{width:0}to{width:100%}}@keyframes zcSlideInFromLeft{0%{transform:translate(-100%);opacity:0}to{transform:translate(0);opacity:1}}@keyframes zcSlideOutToLeft{0%{transform:translate(0);opacity:1}to{transform:translate(-100%);opacity:0}}.zcToast{max-width:25vw;animation:zcSlideInFromLeft .3s ease-out forwards}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn:before{content:"";position:absolute;left:1vw;top:50%;transform:translateY(-50%);border:2px solid white;width:.5em;aspect-ratio:1/1;border-radius:50%}dialog[data-zc-dialog-type=choice_multiple] .zcDialogBtn[data-zc-picked=true]:before{background:#fff}.zcDialogBtn{cursor:pointer;background:#ffffff17;border:none;font-size:clamp(6px,2vw,24px);color:#fff;padding:.2em;border-radius:.5em}.zcDialogBtn:hover{background:#ffffff24}@keyframes zcSpin{0%{transform:rotate(0)}to{transform:rotate(360deg)}}@keyframes zcCursorBlink{0%{border-right-color:transparent}to{border-right-color:#2a2a2a}}.zcCursor{border-right:2px solid var(--tmd-text, rgb(42, 42, 42));width:fit-content}.zcDisabled{pointer-events:none;opacity:.6}
@@ -29,6 +29,7 @@ interface CreateTextArgs extends BaseElementArgs<"base"> {
29
29
  color?: string;
30
30
  fontSize?: number | "auto";
31
31
  withBackground?: boolean;
32
+ withBorder?: boolean;
32
33
  width?: number;
33
34
  height?: number;
34
35
  padding?: number;
@@ -108,7 +109,11 @@ interface CreateSelectArgs extends BaseElementArgs<"base"> {
108
109
  onChange?: (name: any) => void;
109
110
  isDisabled?: () => boolean;
110
111
  }
111
- interface DrawPolylineArrowArgs extends Omit<BaseElementArgs<"base">, "x" | "y"> {
112
+ interface CreateContainerArgs extends BaseElementArgs<"base"> {
113
+ width?: number;
114
+ height?: number;
115
+ }
116
+ interface DrawPolylineArrowArgs {
112
117
  points: {
113
118
  x: number;
114
119
  y: number;
@@ -118,6 +123,7 @@ interface DrawPolylineArrowArgs extends Omit<BaseElementArgs<"base">, "x" | "y">
118
123
  circleRadius?: number;
119
124
  circleColor?: string;
120
125
  }
126
+ export declare function dataUrlSvgWithColor(dataUrl: string, newColor: string): string;
121
127
  export declare function getRelativeHeight(height: number): number;
122
128
  export declare function getRelativeWidth(width: number): number;
123
129
  export declare function getRelativeY(yPos: number, anchorPosition?: 'top' | 'bottom'): number;
@@ -148,7 +154,7 @@ export declare abstract class BaseSubscreen {
148
154
  setPreviousSubscreen(): void;
149
155
  setSubscreen(subscreen: BaseSubscreen | null): void;
150
156
  createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth, tooltip, onClick, isDisabled, modules }: CreateButtonArgs): HTMLButtonElement;
151
- createText({ text, color, x, y, width, height, withBackground, fontSize, anchor, padding, place, modules }: CreateTextArgs): HTMLParagraphElement;
157
+ createText({ text, color, x, y, width, height, withBackground, withBorder, fontSize, anchor, padding, place, modules }: CreateTextArgs): HTMLParagraphElement;
152
158
  createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled, modules }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
153
159
  createCheckbox({ text, x, y, isChecked, width, modules, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
154
160
  createScrollView({ scroll, x, y, width, height, anchor, modules, place }: CreateScrollViewArgs): HTMLDivElement;
@@ -159,6 +165,7 @@ export declare abstract class BaseSubscreen {
159
165
  drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
160
166
  createCard({ x, y, name, value, icon, anchor, place, modules }: CreateCardArgs): HTMLDivElement;
161
167
  createSelect({ x, y, width, options, currentOption, anchor, place, modules, onChange, isDisabled }: CreateSelectArgs): HTMLDivElement;
168
+ createContainer({ x, y, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
162
169
  }
163
170
  export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
164
171
  export {};
@@ -1 +1 @@
1
- import{BaseModule as r}from"../modules";class n extends r{constructor(e){super();this.style=e}layoutEffect(e,o){for(const t of Object.keys(this.style))o.style.setProperty(t,this.style[t])}}export{n as StyleModule};
1
+ import{BaseModule as l}from"../modules";class n extends l{constructor(e){super();this.style=e}layoutEffect(e,o){for(const t of Object.keys(this.style))o.style[t]=this.style[t]}}export{n as StyleModule};
package/dist/ui.js CHANGED
@@ -1,11 +1,11 @@
1
- import{Check as N,ChevronDown as I,CircleX as P,createElement as T,Trash2 as D}from"lucide";import{getThemedColorsModule as z,MOD_DATA as L}from"./index";import{StyleModule as R}from"./ui-modules";function S(h){return h*(MainCanvas.canvas.clientHeight/1e3)}function H(h){return h*(MainCanvas.canvas.clientWidth/2e3)}function V(h,e="top"){const r=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+h*r:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+h*r}function W(h,e="left"){const r=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+h*r:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+h*r}function j(h,e,r,u="top-left"){const m=u==="top-left"||u==="top-right"?"top":"bottom",s=u==="top-left"||u==="bottom-left"?"left":"right",n=V(r,m),p=W(e,s);Object.assign(h.style,{position:"fixed",[s]:p+"px",[m]:n+"px"})}function J(h,e,r){Object.assign(h.style,{width:H(e)+"px",height:S(r)+"px"})}function O(h,e){const r=MainCanvas.canvas.clientWidth,u=MainCanvas.canvas.clientHeight,m=Math.min(r,u)/100,s=e*m;Object.assign(h.style,{fontSize:s+"px"})}function w(h,e){h.style.fontFamily=e??"sans-serif"}function G(h,e){const r=MainCanvas.canvas.clientWidth,u=MainCanvas.canvas.clientHeight,m=Math.min(r,u)/100,s=e*m;Object.assign(h.style,{padding:s+"px"})}function X(h){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(h.style,{fontSize:e+"px"})}function Y(){F(M)}function F(h){M=k,k=h,k&&k.load(),M&&M.unload()}function K(){return k}let k,M=null;class Q{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:r,y:u,width:m,height:s,padding:n,fontSize:p="auto",anchor:b,place:d,modules:l={},modulesMap:a}){w(e,L.fontFamily);const o={anchor:b,x:r,y:u,width:m,height:s,padding:n,fontSize:p,place:d,element:e};Object.keys(l)?.forEach(c=>{l[c].forEach(f=>{const i=f.overrideProperties(o,a[c]);b=i.anchor,r=i.x,u=i.y,m=i.width,s=i.height,n=i.padding,p=i.fontSize,d=i.place,e=i.element})});const t=()=>{typeof r=="number"&&typeof u=="number"&&j(e,r,u,b),p==="auto"?X(e):O(e,p),n&&G(e,n),m&&(e.style.width=H(m)+"px"),s&&(e.style.height=S(s)+"px")};t(),window.addEventListener("resize",t),Object.keys(l)?.forEach(c=>{l[c].forEach(f=>{f.layoutEffect(o,a[c])})}),d&&document.body.append(e),this.resizeEventListeners.push(t),this.htmlElements.push(e),Object.keys(l)?.forEach(c=>{l[c].forEach(f=>{f.effect(o,a[c])})})}get currentSubscreen(){return k}get previousSubscreen(){return M}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:10}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),B[this.constructor.name]&&B[this.name].forEach(e=>e(this))}unload(){this.tabHandlers.unload?.(),this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){this.tabHandlers.exit?.(),this.setSubscreen(this.previousSubscreen)}update(){}setPreviousSubscreen(){Y()}setSubscreen(e){F(e)}createButton({text:e,x:r,y:u,width:m,height:s,fontSize:n="auto",anchor:p="top-left",padding:b,style:d="default",place:l=!0,icon:a,iconAbsolutePosition:o=!0,iconWidth:t,tooltip:c,onClick:f,isDisabled:i,modules:v}){let g,C;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",d),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.columnGap="1.25vw",w(y,L.fontFamily),a&&(typeof a=="string"?(g=document.createElement("img"),g.src=a):g=a,t?g.style.width=t:g.style.height="80%",e&&o&&(g.style.position="absolute",g.style.left="1vw"),e&&!o&&(y.style.justifyContent=""),y.append(g)),e&&(C=document.createElement("span"),C.textContent=e,a&&!o&&t&&(C.style.width="100%",C.style.marginRight=t),y.append(C)),c){const x=document.createElement("span");x.classList.add("tooltip"),x.setAttribute("position",c.position),x.textContent=c.text,y.append(x)}return typeof i=="function"&&i()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof i=="function"&&i())return y.classList.add("zcDisabled");typeof f=="function"&&f()}),this.addElement(y,{x:r,y:u,width:m,height:s,anchor:p,place:l,fontSize:n,padding:b,modules:v,modulesMap:{base:y,text:C,icon:g}}),y}createText({text:e,color:r,x:u,y:m,width:s,height:n,withBackground:p=!1,fontSize:b="auto",anchor:d="top-left",padding:l,place:a=!0,modules:o}){const t=document.createElement("p");return t.innerHTML=e,t.style.color=r??"var(--tmd-text, black)",p&&(t.style.background="var(--tmd-element,rgb(239, 239, 239))"),w(t,L.fontFamily),this.addElement(t,{x:u,y:m,width:s,height:n,anchor:d,place:a,fontSize:b,padding:l,modules:o,modulesMap:{base:t}}),t}createInput({value:e,placeholder:r,x:u,y:m,width:s,height:n,textArea:p=!1,fontSize:b="auto",anchor:d="top-left",padding:l,place:a=!0,onChange:o,onInput:t,isDisabled:c,modules:f}){const i=document.createElement(p?"textarea":"input");return i.classList.add("zcInput"),r&&(i.placeholder=r),e&&(i.value=e),w(i,L.fontFamily),typeof c=="function"&&c()&&i.classList.add("zcDisabled"),i.addEventListener("change",()=>{if(typeof c=="function"&&c())return i.classList.add("zcDisabled");typeof o=="function"&&o()}),i.addEventListener("input",()=>{if(typeof c=="function"&&c())return i.classList.add("zcDisabled");typeof t=="function"&&t()}),this.addElement(i,{x:u,y:m,width:s,height:n,anchor:d,place:a,fontSize:b,padding:l,modules:f,modulesMap:{base:i}}),i}createCheckbox({text:e,x:r,y:u,isChecked:m,width:s,modules:n,anchor:p="top-left",place:b=!0,isDisabled:d,onChange:l}){const a=document.createElement("div");a.style.display="flex",a.style.alignItems="center",a.style.columnGap="1vw";const o=document.createElement("input");o.type="checkbox",o.checked=m,o.style.borderRadius="min(0.8dvh, 0.3dvw)",o.style.aspectRatio="1/1",o.classList.add("zcCheckbox","checkbox");const t=document.createElement("p");return t.textContent=e,t.style.color="var(--tmd-text, black)",w(t,L.fontFamily),typeof d=="function"&&d()&&a.classList.add("zcDisabled"),a.addEventListener("change",()=>{if(typeof d=="function"&&d())return a.classList.add("zcDisabled");typeof l=="function"&&l()}),a.append(o,t),this.addElement(a,{x:r,y:u,width:s,anchor:p,place:b,modules:n,modulesMap:{base:a,checkbox:o,label:t}}),a}createScrollView({scroll:e,x:r,y:u,width:m,height:s,anchor:n="top-left",modules:p,place:b=!0}){const d=document.createElement("div");return e==="all"&&(d.style.overflow="scroll"),e==="x"&&(d.style.overflowX="scroll"),e==="y"&&(d.style.overflowY="scroll"),this.addElement(d,{x:r,y:u,width:m,height:s,anchor:n,place:b,modules:p,modulesMap:{base:d}}),d}createInputList({x:e,y:r,width:u,height:m,title:s,value:n,modules:p,anchor:b="top-left",place:d=!0,numbersOnly:l=!1,isDisabled:a,onChange:o}){const t=[],c=document.createElement("div");c.style.cssText=`
1
+ import{Check as N,ChevronDown as I,CircleX as P,createElement as T,Trash2 as D}from"lucide";import{getThemedColorsModule as z,MOD_DATA as L}from"./index";import{StyleModule as W}from"./ui-modules";function q(b,e){return b.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function S(b){return b*(MainCanvas.canvas.clientHeight/1e3)}function H(b){return b*(MainCanvas.canvas.clientWidth/2e3)}function R(b,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+b*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+b*o}function V(b,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+b*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+b*o}function j(b,e,o,d="top-left"){const u=d==="top-left"||d==="top-right"?"top":"bottom",r=d==="top-left"||d==="bottom-left"?"left":"right",t=R(o,u),p=V(e,r);Object.assign(b.style,{position:"fixed",[r]:p+"px",[u]:t+"px"})}function J(b,e,o){Object.assign(b.style,{width:H(e)+"px",height:S(o)+"px"})}function O(b,e){const o=MainCanvas.canvas.clientWidth,d=MainCanvas.canvas.clientHeight,u=Math.min(o,d)/100,r=e*u;Object.assign(b.style,{fontSize:r+"px"})}function k(b,e){b.style.fontFamily=e??"sans-serif"}function G(b,e){const o=MainCanvas.canvas.clientWidth,d=MainCanvas.canvas.clientHeight,u=Math.min(o,d)/100,r=e*u;Object.assign(b.style,{padding:r+"px"})}function X(b){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(b.style,{fontSize:e+"px"})}function Y(){F(M)}function F(b){M=w,w=b,w&&w.load(),M&&M.unload()}function K(){return w}let w,M=null;class Q{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:o,y:d,width:u,height:r,padding:t,fontSize:p="auto",anchor:g,place:m,modules:l={},modulesMap:n}){k(e,L.fontFamily);const i={anchor:g,x:o,y:d,width:u,height:r,padding:t,fontSize:p,place:m,element:e};Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{const c=f.overrideProperties(i,n[s]);g=c.anchor,o=c.x,d=c.y,u=c.width,r=c.height,t=c.padding,p=c.fontSize,m=c.place,e=c.element})});const a=()=>{typeof o=="number"&&typeof d=="number"&&j(e,o,d,g),p==="auto"?X(e):O(e,p),t&&G(e,t),u&&(e.style.width=H(u)+"px"),r&&(e.style.height=S(r)+"px")};a(),window.addEventListener("resize",a),Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{f.layoutEffect(i,n[s])})}),m&&document.body.append(e),this.resizeEventListeners.push(a),this.htmlElements.push(e),Object.keys(l)?.forEach(s=>{l[s].forEach(f=>{f.effect(i,n[s])})})}get currentSubscreen(){return w}get previousSubscreen(){return M}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png"}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:10}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),B[this.constructor.name]&&B[this.name].forEach(e=>e(this))}unload(){this.tabHandlers.unload?.(),this.htmlElements.forEach(e=>{e.remove()}),this.resizeEventListeners.forEach(e=>{removeEventListener("resize",e)})}click(){}exit(){this.tabHandlers.exit?.(),this.setSubscreen(this.previousSubscreen)}update(){}setPreviousSubscreen(){Y()}setSubscreen(e){F(e)}createButton({text:e,x:o,y:d,width:u,height:r,fontSize:t="auto",anchor:p="top-left",padding:g,style:m="default",place:l=!0,icon:n,iconAbsolutePosition:i=!0,iconWidth:a,tooltip:s,onClick:f,isDisabled:c,modules:v}){let h,C;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",m),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.columnGap="1.25vw",k(y,L.fontFamily),n&&(typeof n=="string"?(h=document.createElement("img"),h.src=n):h=n,a?h.style.width=a:h.style.height="80%",e&&i&&(h.style.position="absolute",h.style.left="1vw"),e&&!i&&(y.style.justifyContent=""),y.append(h)),e&&(C=document.createElement("span"),C.textContent=e,n&&!i&&a&&(C.style.width="100%",C.style.marginRight=a),y.append(C)),s){const x=document.createElement("span");x.classList.add("tooltip"),x.setAttribute("position",s.position),x.textContent=s.text,y.append(x)}return typeof c=="function"&&c()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof c=="function"&&c())return y.classList.add("zcDisabled");typeof f=="function"&&f()}),this.addElement(y,{x:o,y:d,width:u,height:r,anchor:p,place:l,fontSize:t,padding:g,modules:v,modulesMap:{base:y,text:C,icon:h}}),y}createText({text:e,color:o,x:d,y:u,width:r,height:t,withBackground:p=!1,withBorder:g=!1,fontSize:m="auto",anchor:l="top-left",padding:n,place:i=!0,modules:a}){const s=document.createElement("p");return s.innerHTML=e,s.style.color=o??"var(--tmd-text, black)",p&&(s.style.background="var(--tmd-element,rgb(239, 239, 239))"),g&&(s.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),k(s,L.fontFamily),this.addElement(s,{x:d,y:u,width:r,height:t,anchor:l,place:i,fontSize:m,padding:n,modules:a,modulesMap:{base:s}}),s}createInput({value:e,placeholder:o,x:d,y:u,width:r,height:t,textArea:p=!1,fontSize:g="auto",anchor:m="top-left",padding:l,place:n=!0,onChange:i,onInput:a,isDisabled:s,modules:f}){const c=document.createElement(p?"textarea":"input");return c.classList.add("zcInput"),o&&(c.placeholder=o),e&&(c.value=e),k(c,L.fontFamily),typeof s=="function"&&s()&&c.classList.add("zcDisabled"),c.addEventListener("change",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");typeof i=="function"&&i()}),c.addEventListener("input",()=>{if(typeof s=="function"&&s())return c.classList.add("zcDisabled");typeof a=="function"&&a()}),this.addElement(c,{x:d,y:u,width:r,height:t,anchor:m,place:n,fontSize:g,padding:l,modules:f,modulesMap:{base:c}}),c}createCheckbox({text:e,x:o,y:d,isChecked:u,width:r,modules:t,anchor:p="top-left",place:g=!0,isDisabled:m,onChange:l}){const n=document.createElement("div");n.style.display="flex",n.style.alignItems="center",n.style.columnGap="1vw";const i=document.createElement("input");i.type="checkbox",i.checked=u,i.style.borderRadius="min(0.8dvh, 0.3dvw)",i.style.aspectRatio="1/1",i.classList.add("zcCheckbox","checkbox");const a=document.createElement("p");return a.textContent=e,a.style.color="var(--tmd-text, black)",k(a,L.fontFamily),typeof m=="function"&&m()&&n.classList.add("zcDisabled"),n.addEventListener("change",()=>{if(typeof m=="function"&&m())return n.classList.add("zcDisabled");typeof l=="function"&&l()}),n.append(i,a),this.addElement(n,{x:o,y:d,width:r,anchor:p,place:g,modules:t,modulesMap:{base:n,checkbox:i,label:a}}),n}createScrollView({scroll:e,x:o,y:d,width:u,height:r,anchor:t="top-left",modules:p,place:g=!0}){const m=document.createElement("div");return e==="all"&&(m.style.overflow="scroll"),e==="x"&&(m.style.overflowX="scroll"),e==="y"&&(m.style.overflowY="scroll"),this.addElement(m,{x:o,y:d,width:u,height:r,anchor:t,place:g,modules:p,modulesMap:{base:m}}),m}createInputList({x:e,y:o,width:d,height:u,title:r,value:t,modules:p,anchor:g="top-left",place:m=!0,numbersOnly:l=!1,isDisabled:n,onChange:i}){const a=[],s=document.createElement("div");s.style.cssText=`
2
2
  display: flex; flex-direction: column; gap: 1vw; border: 2px solid var(--tmd-accent, black);
3
3
  border-radius: 4px; padding: 0.75vw; background: var(--tmd-element, none);
4
- `,w(c,L.fontFamily);const f=document.createElement("div");f.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const i=document.createElement("b");i.textContent=s+":",i.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const v=document.createElement("div");v.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
- overflow-y: scroll;`;const g=document.createElement("input");g.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const C=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new R({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",f.append(A)},y=x=>{const E=document.createElement("div");E.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",E.textContent=x,v.insertBefore(E,g),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),t.push(x)};return C(T(P),()=>{if(typeof a=="function"&&a())return c.classList.add("zcDisabled");v.innerHTML="",t.splice(0,t.length),v.append(g),n.forEach(x=>y(String(x))),typeof o=="function"&&o(l?t.map(x=>parseInt(x)):t)}),C(T(D),()=>{if(typeof a=="function"&&a())return c.classList.add("zcDisabled");for(const x of[...v.children])x.getAttribute("style").includes("border: 2px solid red;")&&(t.splice(t.indexOf(x.textContent),1),x.remove());typeof o=="function"&&o(l?t.map(x=>parseInt(x)):t)}),typeof a=="function"&&a()&&c.classList.add("zcDisabled"),g.addEventListener("keypress",x=>{if(document.activeElement===g)switch(x.key){case"Enter":if(l&&Number.isNaN(parseInt(g.value))||g.value.trim()==="")return;if(typeof a=="function"&&a())return c.classList.add("zcDisabled");y(g.value),g.value="",typeof o=="function"&&o(l?t.map(E=>parseInt(E)):t);break}}),c.addEventListener("click",x=>{x.currentTarget==c&&g.focus()}),v.append(g),c.append(f,i,v),this.addElement(c,{x:e,y:r,width:u,height:m,anchor:b,place:d,modules:p,modulesMap:{base:c,input:g}}),n.forEach(x=>y(String(x))),c}createImage({x:e,y:r,width:u,src:m,place:s=!0,anchor:n="top-left",modules:p}){const b=document.createElement("img");return b.style.height="auto",b.src=m,this.addElement(b,{x:e,y:r,width:u,height:0,anchor:n,place:s,modules:p,modulesMap:{base:b}}),b}createBackNextButton({x:e,y:r,width:u,height:m,items:s,currentIndex:n,modules:p,isBold:b=!1,anchor:d="top-left",place:l=!0,onChange:a,isDisabled:o}){const t=document.createElement("div");t.classList.add("zcBackNextButton"),w(t,L.fontFamily);const c=()=>{n===0||typeof o=="function"&&o(s[n-1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled"),n===s.length-1||typeof o=="function"&&o(s[n+1][1])?i.classList.add("zcBackNextButton-btnDisabled"):i.classList.remove("zcBackNextButton-btnDisabled")},f=document.createElement("button");f.style.cssText=`
4
+ `,k(s,L.fontFamily);const f=document.createElement("div");f.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const c=document.createElement("b");c.textContent=r+":",c.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const v=document.createElement("div");v.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
5
+ overflow-y: scroll;`;const h=document.createElement("input");h.style.cssText="border: none; outline: none; background: none; height: fit-content; flex-grow: 1; padding: 0.8vw; width: 6vw; font-size: clamp(8px, 2vw, 20px);";const C=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new W({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",f.append(A)},y=x=>{const E=document.createElement("div");E.style.cssText="cursor: pointer; background: var(--tmd-element-hover, rgb(206, 206, 206)); color: var(--tmd-text, black); height: fit-content; padding: 0.8vw; border-radius: 0.8vw; font-size: clamp(8px, 2vw, 20px);",E.textContent=x,v.insertBefore(E,h),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),a.push(x)};return C(T(P),()=>{if(typeof n=="function"&&n())return s.classList.add("zcDisabled");v.innerHTML="",a.splice(0,a.length),v.append(h),t.forEach(x=>y(String(x))),typeof i=="function"&&i(l?a.map(x=>parseInt(x)):a)}),C(T(D),()=>{if(typeof n=="function"&&n())return s.classList.add("zcDisabled");for(const x of[...v.children])x.getAttribute("style").includes("border: 2px solid red;")&&(a.splice(a.indexOf(x.textContent),1),x.remove());typeof i=="function"&&i(l?a.map(x=>parseInt(x)):a)}),typeof n=="function"&&n()&&s.classList.add("zcDisabled"),h.addEventListener("keypress",x=>{if(document.activeElement===h)switch(x.key){case"Enter":if(l&&Number.isNaN(parseInt(h.value))||h.value.trim()==="")return;if(typeof n=="function"&&n())return s.classList.add("zcDisabled");y(h.value),h.value="",typeof i=="function"&&i(l?a.map(E=>parseInt(E)):a);break}}),s.addEventListener("click",x=>{x.currentTarget==s&&h.focus()}),v.append(h),s.append(f,c,v),this.addElement(s,{x:e,y:o,width:d,height:u,anchor:g,place:m,modules:p,modulesMap:{base:s,input:h}}),t.forEach(x=>y(String(x))),s}createImage({x:e,y:o,width:d,src:u,place:r=!0,anchor:t="top-left",modules:p}){const g=document.createElement("img");return g.style.height="auto",g.src=u,this.addElement(g,{x:e,y:o,width:d,height:0,anchor:t,place:r,modules:p,modulesMap:{base:g}}),g}createBackNextButton({x:e,y:o,width:d,height:u,items:r,currentIndex:t,modules:p,isBold:g=!1,anchor:m="top-left",place:l=!0,onChange:n,isDisabled:i}){const a=document.createElement("div");a.classList.add("zcBackNextButton"),k(a,L.fontFamily);const s=()=>{t===0||typeof i=="function"&&i(r[t-1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled"),t===r.length-1||typeof i=="function"&&i(r[t+1][1])?c.classList.add("zcBackNextButton-btnDisabled"):c.classList.remove("zcBackNextButton-btnDisabled")},f=document.createElement("button");f.style.cssText=`
6
6
  position: absolute; left: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
7
7
  height: 140%; background-image: url("Icons/Prev.png"); background-size: 100%;
8
- `,f.classList.add("zcButton"),f.addEventListener("click",()=>{if(n===0||typeof o=="function"&&o(s[n-1][1]))return f.classList.add("zcDisabled");n--,v.textContent=s[n][0],typeof a=="function"&&a(s[n][1]),c()});const i=document.createElement("button");i.style.cssText=`
8
+ `,f.classList.add("zcButton"),f.addEventListener("click",()=>{if(t===0||typeof i=="function"&&i(r[t-1][1]))return f.classList.add("zcDisabled");t--,v.textContent=r[t][0],typeof n=="function"&&n(r[t][1]),s()});const c=document.createElement("button");c.style.cssText=`
9
9
  position: absolute; right: 1vw; font-size: 3.5vw; aspect-ratio: 1/1;
10
10
  height: 140%; background-image: url("Icons/Next.png"); background-size: 100%;
11
- `,i.classList.add("zcButton"),i.addEventListener("click",()=>{if(n===s.length-1||typeof o=="function"&&o(s[n+1][1]))return i.classList.add("zcDisabled");n++,v.textContent=s[n][0],typeof a=="function"&&a(s[n][1]),c()}),c();const v=document.createElement("p");return b&&(v.style.fontWeight="bold"),v.textContent=s[n][0],t.append(f,v,i),this.addElement(t,{x:e,y:r,width:u,height:m,anchor:d,place:l,modules:p,modulesMap:{base:t,backButton:f,nextButton:i,text:v}}),t}createTabs({x:e,y:r,width:u,tabs:m,anchor:s="top-left",place:n=!0,currentTabName:p,modules:b}){let d=[];const l=document.createElement("div");return l.classList.add("zcTabs"),w(l,L.fontFamily),m.forEach(a=>{const o=()=>{for(const f of l.children)f.removeAttribute("data-opened");for(const f of d)f instanceof Node&&document.body.removeChild(f);d=[],t.setAttribute("data-opened","true");const c=document.body.append.bind(document.body);document.body.append=(...f)=>{d.push(...f),c(...f)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),a.load(),this.tabHandlers={run:a.run,load:a.load,unload:a.unload,exit:a.exit},document.body.append=c},t=document.createElement("button");t.textContent=a.name,a.name===p&&o(),t.addEventListener("click",o),l.append(t)}),this.addElement(l,{x:e,y:r,width:u,anchor:s,place:n,modules:b,modulesMap:{base:l}}),l}drawPolylineArrow({points:e,strokeColor:r=z()?.base?.text??"black",lineWidth:u=2,circleRadius:m=5,circleColor:s=z()?.base?.text??"black"}){if(e.length<2)return;const n=MainCanvas.canvas.getContext("2d");n.save(),n.strokeStyle=r,n.lineWidth=u,n.fillStyle=s,n.beginPath(),n.moveTo(e[0].x,e[0].y);for(let p=1;p<e.length;p++)n.lineTo(e[p].x,e[p].y);n.stroke(),n.beginPath(),n.arc(e[0].x,e[0].y,m,0,Math.PI*2),n.fill(),n.beginPath(),n.arc(e[e.length-1].x,e[e.length-1].y,m,0,Math.PI*2),n.fill(),n.restore()}createCard({x:e,y:r,name:u,value:m,icon:s,anchor:n="top-left",place:p=!0,modules:b}){const d=document.createElement("div");d.classList.add("zcCard");const l=document.createElement("p");l.classList.add("zcCard_name"),l.textContent=u;const a=document.createElement("p");return a.classList.add("zcCard_value"),a.textContent=`${m}`,s&&(s.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",d.append(s)),d.append(l,a),this.addElement(d,{x:e,y:r,anchor:n,place:p,modules:b,modulesMap:{name:l,value:a,base:d,icon:null}}),d}createSelect({x:e,y:r,width:u,options:m,currentOption:s,anchor:n="top-left",place:p=!0,modules:b,onChange:d,isDisabled:l}){let a=!1,o;const t=document.createElement("div");t.classList.add("zcSelect"),t.setAttribute("opened",!1),t.addEventListener("click",()=>{if(l&&l())return t.classList.add("zcDisabled");a?(a=!1,o.remove()):(a=!0,o=document.createElement("div"),o.setAttribute("data-zc-position",typeof r=="number"&&r>500-t.offsetHeight/2?"top":"bottom"),m.forEach(v=>{const g=document.createElement("div");g.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",v.icon&&(v.icon.style.cssText="color: #bcbcbc;",g.append(v.icon)),g.append(v.text),v.name===s&&g.append(i),g.addEventListener("click",()=>{s=v.name,c.textContent=v.text,o.remove(),d&&d(v.name)}),o.append(g)}),t.append(o))});const c=document.createElement("p");c.textContent=m.find(v=>v.name===s).name;const f=T(I),i=T(N);return i.style.cssText="position: absolute; right: 0.25em;",t.append(c,f),l&&l()&&t.classList.add("zcDisabled"),this.addElement(t,{x:e,y:r,width:u,anchor:n,place:p,modules:b,modulesMap:{base:t}}),t}}const B={};function U(h,e){B[h]||(B[h]=[]),B[h].push(e)}export{Q as BaseSubscreen,X as autosetFontSize,K as getCurrentSubscreen,S as getRelativeHeight,H as getRelativeWidth,W as getRelativeX,V as getRelativeY,U as hookSubscreen,w as setFontFamily,O as setFontSize,G as setPadding,j as setPosition,Y as setPreviousSubscreen,J as setSize,F as setSubscreen};
11
+ `,c.classList.add("zcButton"),c.addEventListener("click",()=>{if(t===r.length-1||typeof i=="function"&&i(r[t+1][1]))return c.classList.add("zcDisabled");t++,v.textContent=r[t][0],typeof n=="function"&&n(r[t][1]),s()}),s();const v=document.createElement("p");return g&&(v.style.fontWeight="bold"),v.textContent=r[t][0],a.append(f,v,c),this.addElement(a,{x:e,y:o,width:d,height:u,anchor:m,place:l,modules:p,modulesMap:{base:a,backButton:f,nextButton:c,text:v}}),a}createTabs({x:e,y:o,width:d,tabs:u,anchor:r="top-left",place:t=!0,currentTabName:p,modules:g}){let m=[];const l=document.createElement("div");return l.classList.add("zcTabs"),k(l,L.fontFamily),u.forEach(n=>{const i=()=>{for(const f of l.children)f.removeAttribute("data-opened");for(const f of m)f instanceof Node&&document.body.removeChild(f);m=[],a.setAttribute("data-opened","true");const s=document.body.append.bind(document.body);document.body.append=(...f)=>{m.push(...f),s(...f)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),n.load(),this.tabHandlers={run:n.run,load:n.load,unload:n.unload,exit:n.exit},document.body.append=s},a=document.createElement("button");a.textContent=n.name,n.name===p&&i(),a.addEventListener("click",i),l.append(a)}),this.addElement(l,{x:e,y:o,width:d,anchor:r,place:t,modules:g,modulesMap:{base:l}}),l}drawPolylineArrow({points:e,strokeColor:o=z()?.base?.text??"black",lineWidth:d=2,circleRadius:u=5,circleColor:r=z()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=d,t.fillStyle=r,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let p=1;p<e.length;p++)t.lineTo(e[p].x,e[p].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,u,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,u,0,Math.PI*2),t.fill(),t.restore()}createCard({x:e,y:o,name:d,value:u,icon:r,anchor:t="top-left",place:p=!0,modules:g}){const m=document.createElement("div");m.classList.add("zcCard");const l=document.createElement("p");l.classList.add("zcCard_name"),l.textContent=d;const n=document.createElement("p");return n.classList.add("zcCard_value"),n.textContent=`${u}`,r&&(r.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",m.append(r)),m.append(l,n),this.addElement(m,{x:e,y:o,anchor:t,place:p,modules:g,modulesMap:{name:l,value:n,base:m,icon:null}}),m}createSelect({x:e,y:o,width:d,options:u,currentOption:r,anchor:t="top-left",place:p=!0,modules:g,onChange:m,isDisabled:l}){let n=!1,i;const a=document.createElement("div");a.classList.add("zcSelect"),a.setAttribute("opened",!1),a.addEventListener("click",()=>{if(l&&l())return a.classList.add("zcDisabled");n?(n=!1,i.remove()):(n=!0,i=document.createElement("div"),i.setAttribute("data-zc-position",typeof o=="number"&&o>500-a.offsetHeight/2?"top":"bottom"),u.forEach(v=>{const h=document.createElement("div");h.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",v.icon&&(v.icon.style.cssText="color: #bcbcbc;",h.append(v.icon)),h.append(v.text),v.name===r&&h.append(c),h.addEventListener("click",()=>{r=v.name,s.textContent=v.text,i.remove(),m&&m(v.name)}),i.append(h)}),a.append(i))});const s=document.createElement("p");s.textContent=u.find(v=>v.name===r).text;const f=T(I),c=T(N);return c.style.cssText="position: absolute; right: 0.25em;",a.append(s,f),l&&l()&&a.classList.add("zcDisabled"),this.addElement(a,{x:e,y:o,width:d,anchor:t,place:p,modules:g,modulesMap:{base:a}}),a}createContainer({x:e,y:o,anchor:d="top-left",place:u=!0,modules:r}){const t=document.createElement("div");return this.addElement(t,{x:e,y:o,anchor:d,place:u,modules:r,modulesMap:{base:t}}),t}}const B={};function Z(b,e){B[b]||(B[b]=[]),B[b].push(e)}export{Q as BaseSubscreen,X as autosetFontSize,q as dataUrlSvgWithColor,K as getCurrentSubscreen,S as getRelativeHeight,H as getRelativeWidth,V as getRelativeX,R as getRelativeY,Z as hookSubscreen,k as setFontFamily,O as setFontSize,G as setPadding,j as setPosition,Y as setPreviousSubscreen,J as setSize,F as setSubscreen};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.1.1",
3
+ "version": "1.1.3",
4
4
  "description": "The core for the my mods, which contains a shared code reused in all my mods",
5
5
  "author": "Zoi",
6
6
  "license": "MIT",
@@ -54,7 +54,6 @@
54
54
  "react": "^19.1.0",
55
55
  "react-dom": "^19.1.0",
56
56
  "reflect-metadata": "^0.2.2",
57
- "zois-core": "link:C:/Users/VolkPC/AppData/Local/pnpm/global/5/node_modules/zois-core",
58
57
  "zustand": "^5.0.5"
59
58
  },
60
59
  "devDependencies": {