zois-core 1.1.8 → 1.2.1
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/LICENSE +21 -21
- package/README.md +1 -1
- package/dist/index.js +1 -1
- package/dist/modsApi.js +1 -1
- package/dist/popups.js +1 -1
- package/dist/styles.css +1 -1
- package/dist/types/index.d.ts +2 -0
- package/dist/types/popups.d.ts +22 -15
- package/dist/types/ui.d.ts +4 -1
- package/dist/ui.js +5 -5
- package/package.json +1 -1
package/LICENSE
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
MIT License
|
|
2
|
-
|
|
3
|
-
Copyright (c) 2025 Zoi
|
|
4
|
-
|
|
5
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
-
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
-
in the Software without restriction, including without limitation the rights
|
|
8
|
-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
-
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
-
furnished to do so, subject to the following conditions:
|
|
11
|
-
|
|
12
|
-
The above copyright notice and this permission notice shall be included in all
|
|
13
|
-
copies or substantial portions of the Software.
|
|
14
|
-
|
|
15
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
-
SOFTWARE.
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Zoi
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
## The core for the my mods, which contains a shared code reused in all my mods
|
|
1
|
+
## The core for the my mods, which contains a shared code reused in all my mods
|
|
2
2
|

|
package/dist/index.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import l from"./styles.css";import{findModByName as u,registerMod as g}from"./modsApi";import{initVirtualDOM as
|
|
1
|
+
import l from"./styles.css";import{findModByName as u,registerMod as g}from"./modsApi";import{initVirtualDOM as m,useToastsStore as d,useDialogStore as f}from"./popups";import{version as c}from"../package.json";import{version as B}from"../package.json";let p;function D(e){if(!window.ZOISCORE){const t=document.createElement("style");t.innerHTML=l,document.head.append(t),window.ZOISCORE=Object.freeze({loaded:!0,useToastsStore:d,useDialogStore:f,version:c}),document.addEventListener("click",r=>{const o=r.target.closest("a");if(o&&o.href)try{const n=new URL(o.href);if(n.protocol==="zc:"&&(r.preventDefault(),o.href.startsWith("zc://open"))){const i={subscreen:n.searchParams.get("subscreen")};n.searchParams.get("mod")&&(i.mod=n.searchParams.get("mod")),window.dispatchEvent(new CustomEvent("zoiscore:open",{detail:i}))}}catch{}},!0),m()}p={...e},g()}function h(e){return new Promise(t=>setTimeout(t,e))}async function y(e,t=()=>!1){for(;!e();){if(t())return!1;await h(10)}return!0}function b(e,t){return e=Math.ceil(e),t=Math.floor(t),Math.floor(Math.random()*(t-e+1))+e}function S(e,t){const r=e.split("."),o=t.split(".");for(let n=0;n<Math.max(r.length,o.length);n++){const i=parseInt(r[n]||"0",10),s=parseInt(o[n]||"0",10);if(i>s)return!0;if(i<s)return!1}return!1}function T(e,t){return!e&&!t||!e&&t==="Default"||!t&&e==="Default"||e==="Default"&&Array.isArray(t)&&t.filter(r=>r==="Default").length===t.length||t==="Default"&&Array.isArray(e)&&e.filter(r=>r==="Default").length===e.length?!0:JSON.stringify(e)===JSON.stringify(t)}function N(e){return typeof e=="string"?Math.round(new TextEncoder().encode(e).byteLength/100)/10:Math.round(new TextEncoder().encode(JSON.stringify(e)).byteLength/100)/10}function O(e){if(e)return ChatRoomCharacter.find(t=>t.MemberNumber==e||t.Name.toLowerCase()===e||t.Nickname?.toLowerCase()===e)}function k(e){return CharacterNickname(e)}function E(){if(!u("Themed"))return null;const e=JSON.parse(LZString.decompressFromBase64(Player.ExtensionSettings.Themed??""));return!e?.GlobalModule?.themedEnabled||!e?.GlobalModule?.doVanillaGuiOverhaul?null:e.ColorsModule}function P(e){const t=document.createElement("style");t.innerHTML=e,document.head.append(t)}function v(e){y(()=>typeof window.Player?.MemberNumber=="number").then(()=>setTimeout(e,b(3e3,6e3)))}function a(e){return typeof e!="object"||e===null?e:Array.isArray(e)?e.map(a).sort():Object.keys(e).sort().reduce((t,r)=>(t[r]=a(e[r]),t),{})}export{p as MOD_DATA,T as colorsEqual,k as getNickname,O as getPlayer,b as getRandomNumber,N as getSizeInKbytes,E as getThemedColorsModule,P as injectStyles,S as isVersionNewer,a as normalizeObject,D as registerCore,h as sleep,B as version,y as waitFor,v as waitForStart};
|
package/dist/modsApi.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import
|
|
1
|
+
import c from"bondage-club-mod-sdk";import{MOD_DATA as o}from"./index";import{getCurrentSubscreen as u,setSubscreen as d}from"./ui";import{dialogsManager as m}from"./popups";var f=(t=>(t[t.OBSERVE=0]="OBSERVE",t[t.ADD_BEHAVIOR=1]="ADD_BEHAVIOR",t[t.MODIFY_BEHAVIOR=5]="MODIFY_BEHAVIOR",t[t.OVERRIDE_BEHAVIOR=10]="OVERRIDE_BEHAVIOR",t[t.TOP=100]="TOP",t))(f||{});let s;function O(){window.ZOISCORE_MODS??=[],window.ZOISCORE_MODS.push({name:o.name,fullName:o.fullName,key:o.key,version:o.version,deepLinkSubscreens:o.deepLinkSubscreens??[]}),s=c.registerMod({name:o.name,fullName:o.fullName,version:o.version,repository:o.repository}),l("GameKeyDown",1,(e,n)=>{const r=u();if(CommonKey.IsPressed(e[0],"Escape")&&r)return r.exit(),!1;const i=document.querySelector(".zcDialog");return i instanceof HTMLDivElement?(i.focus(),!1):n(e)}),window.addEventListener("zoiscore:open",async e=>{const n=e.detail.subscreen,r=e.detail.mod;if(r&&r!==o.key||u()?.constructor.name===n)return;const a=o.deepLinkSubscreens?.find(t=>t.constructor.name===n);a&&await m.confirm({message:"This deep link wants to redirect you to another subscreen. Confirm the redirecting."})&&d(a)})}function l(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.hookFunction(e,n,r)}function w(e,n){if(!s)throw new Error("zois-core is not registered");s.patchFunction(e,n)}function I(e,n,r){if(!s)throw new Error("zois-core is not registered");return s.callOriginal(e,n)}function y(){return c.getModsInfo()}function x(e){return!!c.getModsInfo().find(n=>n.name===e)}export{f as HookPriority,I as callOriginal,x as findModByName,y as getLoadedMods,l as hookFunction,s as modSdk,w as patchFunction,O as registerMod};
|
package/dist/popups.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{
|
|
1
|
+
import{getRelativeX as D,getRelativeY as P}from"./ui";import{MOD_DATA as g}from"./index";import{useState as u,useEffect as f,useRef as k}from"react";import x from"react-dom/client";import{create as w}from"zustand";import{CircleAlert as E,CircleCheck as O,CircleX as I,Info as R}from"lucide-react";import{Fragment as v,jsx as i,jsxs as d}from"react/jsx-runtime";function z({children:t}){const[e,o]=u({}),r=window.ZOISCORE.useToastsStore(s=>s.clearToasts);return f(()=>{const s=()=>{o({fontFamily:CommonGetFontName(),bottom:P(5)+"px",left:D(5)+"px"})};return window.addEventListener("resize",s),s(),()=>{window.removeEventListener("resize",s)}},[]),i("div",{className:"zcToastsContainer",style:e,onClick:()=>{document.querySelectorAll(".zcToast").forEach(s=>{s.classList.add("exiting")}),setTimeout(r,300)},children:t})}const M=({type:t,theme:e})=>{switch(t){case"info":return i(R,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#addbff",stroke:e?e.iconStrokeColor:"#385073"}});case"success":return i(O,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#c3ffc3",stroke:e?e.iconStrokeColor:"#028f74"}});case"warning":return i(E,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffdfaf",stroke:e?e.iconStrokeColor:"#9c7633"}});case"error":return i(I,{style:{flexShrink:0,width:"1.65em",height:"1.65em",fill:e?e.iconFillColor:"#ffb2b2",stroke:e?e.iconStrokeColor:"#7f2828"}});case"spinner":return i("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"}})}},F=({title:t,message:e,type:o,duration:r,theme:s})=>{const[n,l]=u({}),[c,m]=u(!1),a=s?s.backgroundColor:o==="success"?"#3ece7e":o==="warning"?"#debf72":o==="error"?"rgb(212, 46, 107)":"rgb(80, 80, 223)",p=s?s.titleColor:o==="info"||o==="spinner"?"rgb(47, 46, 104)":o==="success"?"#244428":o==="error"?"rgb(113, 2, 2)":"#5e4328",y=s?s.messageColor:o==="info"||o==="spinner"?"#b8b8ff":o==="success"?"#c7f9c7":o==="error"?"rgb(255, 152, 152)":"#ffeec5";return f(()=>{const T=()=>{const C=MainCanvas.canvas.clientWidth,b=MainCanvas.canvas.clientHeight,S=Math.min(C,b)/100;l({position:"relative",width:"100%",fontSize:3*S+"px",padding:1.5*S+"px",background:a})};window.addEventListener("resize",T),T();const h=setTimeout(()=>m(!0),r);return()=>{clearTimeout(h),window.removeEventListener("resize",T)}},[]),d("div",{className:`zcToast ${c&&"exiting"}`,"data-zc-toast-type":o,style:n,children:[d("div",{style:{display:"flex",alignItems:"center",gap:"1vw",position:"relative",zIndex:5},children:[i(M,{type:o,theme:s}),d("div",{children:[t&&e&&d(v,{children:[i("p",{style:{color:p,fontWeight:"bold"},children:t}),i("p",{style:{color:y,fontSize:"70%",fontWeight:"bold",overflowWrap:"anywhere",marginTop:"0.25em"},children:e})]}),(!t&&e||t&&!e)&&i("p",{style:{position:"relative",zIndex:5,color:y,fontWeight:"bold",overflowWrap:"anywhere"},children:t||e})]})]}),o!=="spinner"&&i("div",{className:"zcToast-ProgressBar",style:{animation:`zcToast-progress ${r}ms linear 0s 1 alternate none`,position:"absolute",top:0,left:0,height:"100%",borderRadius:"4px",background:s?s.progressBarColor:o==="info"?"rgb(103, 103, 234)":o==="success"?"#34bc71":o==="warning"?"#d0af5e":"rgb(183, 40, 92)"}})]})};function W({dialog:t}){const e=window.ZOISCORE.useDialogStore(a=>a.clearDialog),[o,r]=u(""),[s,n]=u(t.type==="pick"?t.options?.[0]?.value:null),l=k(null),c=()=>{e(),t.type==="prompt"&&t.promise.resolve(o),t.type==="confirm"&&t.promise.resolve(!0),t.type==="pick"&&t.promise.resolve(s)},m=()=>{e(),t.promise.resolve(!1)};return f(()=>(document.body.style.pointerEvents="none",t.type==="prompt"&&l.current instanceof HTMLInputElement&&(console.log("Focus call"),l.current.focus()),()=>{document.body.style.pointerEvents=""}),[]),f(()=>{const a=p=>{(p.key==="Enter"||p.key==="Escape")&&(p.preventDefault(),p.stopPropagation()),p.key==="Enter"&&c(),p.key==="Escape"&&m()};return document.addEventListener("keydown",a),()=>{document.removeEventListener("keydown",a)}},[c,m]),d(v,{children:[d("div",{className:"zcDialog","data-zc-dialog-type":t.type,style:{fontFamily:CommonGetFontName()},children:[i("p",{children:t.message}),t.type==="prompt"&&i("input",{ref:l,type:"text",value:o,style:{color:"white",marginTop:"1px",width:"90%",background:"rgb(82, 89, 104)",border:"none",borderRadius:"4px",padding:"0.45em"},onChange:a=>{console.log(a.currentTarget.value),r(a.currentTarget.value)}}),t.type==="pick"&&i("select",{style:{cursor:"pointer",width:"90%",background:"rgb(82, 89, 104)",border:"none",padding:"0.4em",color:"white",borderRadius:"4px"},children:t.options.map(a=>i("option",{onClick:()=>{n(a.value)},children:a.name},a.name))}),d("div",{style:{display:"flex",justifyContent:"end",columnGap:"0.75em",width:"100%",padding:"1em"},children:[i("button",{onClick:m,children:"Cancel"}),i("button",{onClick:c,children:"Ok"})]})]}),i("div",{style:{position:"fixed",top:"0",left:"0",width:"100%",height:"100%",zIndex:"20",opacity:"0.5",background:"black"}})]})}class L{generateToastId(){return crypto.randomUUID()}process({title:e,message:o,duration:r,type:s,id:n,theme:l}){const{addToast:c,removeToast:m}=window.ZOISCORE.useToastsStore.getState();c({id:n,title:e,message:o,duration:r,type:s,theme:l}),setTimeout(()=>m(n),r+300)}info({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"info",id:s,theme:n})}success({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"success",id:s,theme:n})}warn({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"warning",id:s,theme:n})}error({title:e,message:o,duration:r}){const s=this.generateToastId(),n=g.singleToastsTheme;this.process({title:e,message:o,duration:r,type:"error",id:s,theme:n})}spinner({title:e,message:o}){const r=this.generateToastId(),s=g.singleToastsTheme;return this.process({title:e,message:o,duration:1e6,type:"spinner",id:r,theme:s}),r}removeSpinner(e){const{removeToast:o}=window.ZOISCORE.useToastsStore.getState();o(e)}}class Z{prompt({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"prompt",message:e,promise:{resolve:r,reject:s}})})}confirm({message:e}){const{setDialog:o}=window.ZOISCORE.useDialogStore.getState();return new Promise((r,s)=>{o({type:"confirm",message:e,promise:{resolve:r,reject:s}})})}pick({message:e,options:o}){const{setDialog:r}=window.ZOISCORE.useDialogStore.getState();return new Promise((s,n)=>{r({type:"pick",message:e,options:o,promise:{resolve:s,reject:n}})})}}function B(){const t=window.ZOISCORE.useToastsStore(o=>o.toasts),e=window.ZOISCORE.useDialogStore(o=>o.dialog);return d(v,{children:[i(z,{children:t.map(({title:o,message:r,type:s,duration:n,id:l,theme:c})=>i(F,{id:l,title:o,message:r,type:s,duration:n,theme:c},l))}),e&&i(W,{dialog:e})]})}class N extends HTMLElement{disconnectedCallback(){ServerShowBeep("VirtualDOM was removed, chaos is coming...",5e3,{})}}const oe=w(t=>({toasts:[],addToast:e=>t(o=>({toasts:[...o.toasts,e]})),removeToast:e=>t(o=>({toasts:o.toasts.filter(r=>r.id!==e)})),clearToasts:()=>t({toasts:[]})})),te=w(t=>({dialog:null,setDialog:e=>t({dialog:e}),clearDialog:()=>t({dialog:null})}));function se(){customElements.define("zc-virtual-dom",N);const t=document.createElement("zc-virtual-dom");document.body.append(t),x.createRoot(document.getElementsByTagName("zc-virtual-dom")[0]).render(i(B,{}))}const re=new L,ie=new Z;export{ie as dialogsManager,se as initVirtualDOM,re as toastsManager,te as useDialogStore,oe 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;
|
|
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;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:30}@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;border-radius:4px}.zcToast.exiting{animation:zcSlideOutToLeft .3s ease-out forwards}.zcToast p{color:#fff}.zcDialog{display:flex;flex-direction:column;align-items:center;background:#39404d;margin:auto;position:absolute;inset:0;border:none;border-radius:4px;min-width:200px;max-width:450px;width:90%;height:fit-content;z-index:100;pointer-events:all!important;box-shadow:0 0 6px 1px #0000006e}.zcDialog>p{padding:.75em 0;user-select:none;width:90%;color:#fff}.zcDialog>input:focus{outline:2px solid rgb(0,238,255)}.zcDialog>div>button{cursor:pointer;padding:6px 14px;border:none;border-radius:4px;font-weight:700}.zcDialog>div>button:first-child{background:#495263;color:#fff}.zcDialog>div>button:first-child:hover{background:#565e6c}.zcDialog>div>button:last-child{background:#0ef}.zcDialog>div>button:last-child:hover{background:#04cbd9}@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}
|
package/dist/types/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { BaseSubscreen } from "./ui";
|
|
1
2
|
export interface ModData {
|
|
2
3
|
name: string;
|
|
3
4
|
fullName: string;
|
|
@@ -15,6 +16,7 @@ export interface ModData {
|
|
|
15
16
|
iconFillColor: string;
|
|
16
17
|
iconStrokeColor: string;
|
|
17
18
|
};
|
|
19
|
+
deepLinkSubscreens?: BaseSubscreen[];
|
|
18
20
|
}
|
|
19
21
|
interface ThemedColorsModule {
|
|
20
22
|
base: {
|
package/dist/types/popups.d.ts
CHANGED
|
@@ -7,23 +7,28 @@ interface ToastProps {
|
|
|
7
7
|
duration: number;
|
|
8
8
|
theme?: ModData["singleToastsTheme"];
|
|
9
9
|
}
|
|
10
|
-
interface
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
title?: string;
|
|
14
|
-
body: string;
|
|
15
|
-
buttons: {
|
|
16
|
-
direction: "row" | "column";
|
|
17
|
-
list: {
|
|
18
|
-
text: string;
|
|
19
|
-
value?: unknown;
|
|
20
|
-
}[];
|
|
21
|
-
};
|
|
10
|
+
interface BaseDialogProps<T> {
|
|
11
|
+
type: "prompt" | "confirm" | "pick";
|
|
12
|
+
message: string;
|
|
22
13
|
promise: {
|
|
23
|
-
resolve: (data:
|
|
24
|
-
reject: (data:
|
|
14
|
+
resolve: (data: T) => void;
|
|
15
|
+
reject: (data: T) => void;
|
|
25
16
|
};
|
|
26
17
|
}
|
|
18
|
+
interface ConfirmDialogProps extends BaseDialogProps<boolean> {
|
|
19
|
+
type: "confirm";
|
|
20
|
+
}
|
|
21
|
+
interface PromptDialogProps extends BaseDialogProps<string | false> {
|
|
22
|
+
type: "prompt";
|
|
23
|
+
}
|
|
24
|
+
interface PickDialogProps<T> extends BaseDialogProps<T | false> {
|
|
25
|
+
type: "pick";
|
|
26
|
+
options: {
|
|
27
|
+
name: string;
|
|
28
|
+
value: T;
|
|
29
|
+
}[];
|
|
30
|
+
}
|
|
31
|
+
type DialogProps = ConfirmDialogProps | PromptDialogProps | PickDialogProps<unknown>;
|
|
27
32
|
declare class ToastsManager {
|
|
28
33
|
private generateToastId;
|
|
29
34
|
private process;
|
|
@@ -35,7 +40,9 @@ declare class ToastsManager {
|
|
|
35
40
|
removeSpinner(id: string): void;
|
|
36
41
|
}
|
|
37
42
|
declare class DialogsManager {
|
|
38
|
-
|
|
43
|
+
prompt({ message }: Omit<PromptDialogProps, "type" | "promise">): Promise<string | false>;
|
|
44
|
+
confirm({ message }: Omit<ConfirmDialogProps, "type" | "promise">): Promise<boolean>;
|
|
45
|
+
pick<T>({ message, options }: Omit<PickDialogProps<T>, "type" | "promise">): Promise<T | false>;
|
|
39
46
|
}
|
|
40
47
|
export interface ToastsStore {
|
|
41
48
|
toasts: ToastProps[];
|
package/dist/types/ui.d.ts
CHANGED
|
@@ -138,7 +138,10 @@ export interface DynamicClassStyles {
|
|
|
138
138
|
before?: Partial<CSSStyleDeclaration>;
|
|
139
139
|
after?: Partial<CSSStyleDeclaration>;
|
|
140
140
|
}
|
|
141
|
+
export declare function hexToRgb(hex: string): string;
|
|
141
142
|
export declare function dataUrlSvgWithColor(dataUrl: string, newColor: string): string;
|
|
143
|
+
export declare function dataUrlSvgReplaceVars(dataUrl: string, vars: Record<string, string>): string;
|
|
144
|
+
export declare function cssVar(name: string, fallback: string): string;
|
|
142
145
|
export declare function getRelativeHeight(height: number): number;
|
|
143
146
|
export declare function getRelativeWidth(width: number): number;
|
|
144
147
|
export declare function getRelativeY(yPos: number, anchorPosition?: 'top' | 'bottom'): number;
|
|
@@ -182,7 +185,7 @@ export declare abstract class BaseSubscreen {
|
|
|
182
185
|
drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
|
|
183
186
|
createCard({ x, y, name, value, icon, anchor, place, modules }: CreateCardArgs): HTMLDivElement;
|
|
184
187
|
createSelect({ x, y, width, options, currentOption, anchor, place, modules, onChange, isDisabled }: CreateSelectArgs): HTMLDivElement;
|
|
185
|
-
createContainer({ x, y, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
|
|
188
|
+
createContainer({ x, y, width, height, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
|
|
186
189
|
}
|
|
187
190
|
export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
|
|
188
191
|
export {};
|
package/dist/ui.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import{Check as
|
|
1
|
+
import{Check as I,ChevronDown as N,CircleX as V,createElement as T,Trash2 as R}from"lucide";import{getThemedColorsModule as z,MOD_DATA as C}from"./index";import{StyleModule as H}from"./ui-modules";function W(l){l=l.replace("#","");const e=parseInt(l.substring(0,2),16),n=parseInt(l.substring(2,4),16),c=parseInt(l.substring(4,6),16);return`rgb(${e}, ${n}, ${c})`}function J(l,e){return l.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function Q(l,e){for(let[n,c]of Object.entries(e))c.startsWith("#")&&(c=W(c)),l=l.replaceAll(`$${n}`,c);return l}function ee(l,e){return getComputedStyle(document.documentElement).getPropertyValue(l).trim()||e}function D(l){return l*(MainCanvas.canvas.clientHeight/1e3)}function $(l){return l*(MainCanvas.canvas.clientWidth/2e3)}function F(l,e="top"){const n=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+l*n:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+l*n}function O(l,e="left"){const n=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+l*n:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+l*n}function j(l,e,n,c="top-left"){const i=c==="top-left"||c==="top-right"?"top":"bottom",a=c==="top-left"||c==="bottom-left"?"left":"right",t=F(n,i),m=O(e,a);Object.assign(l.style,{position:"fixed",[a]:m+"px",[i]:t+"px"})}function te(l,e,n){Object.assign(l.style,{width:$(e)+"px",height:D(n)+"px"})}function G(l,e){const n=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,i=Math.min(n,c)/100,a=e*i;Object.assign(l.style,{fontSize:a+"px"})}function L(l,e){l.style.fontFamily=e??"sans-serif"}function X(l,e){const n=MainCanvas.canvas.clientWidth,c=MainCanvas.canvas.clientHeight,i=Math.min(n,c)/100,a=e*i;Object.assign(l.style,{padding:a+"px"})}function _(l){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(l.style,{fontSize:e+"px"})}const B=[];function Y(l){const e=n=>n?JSON.stringify(Object.keys(n).sort().reduce((c,i)=>(c[i]=n[i],c),{})):"null";return`base:${e(l.base)}|hover:${e(l.hover)}|active:${e(l.active)}|before:${e(l.before)}|after:${e(l.after)}`}function ne(l,e){const n=Y(e),c=B.find(b=>b.key===n);if(c)return l.classList.add(c.className);let i;do i="dynamic-"+Math.random().toString(36).substring(2,10);while(B.find(b=>b.className===i));B.push({key:n,className:i});const a=(b,p)=>{let u=`${b} {`;for(const[o,d]of Object.entries(p))u+=`${o.replace(/([a-z0-9]|(?=[A-Z]))([A-Z])/g,"$1-$2").toLowerCase()}: ${d};`;return u+="}",u};let t="";e.base&&(t+=a(`.${i}`,e.base)),e.hover&&(t+=a(`.${i}:hover`,e.hover)),e.active&&(t+=a(`.${i}:active`,e.active)),e.focus&&(t+=a(`.${i}:focus`,e.focus)),e.disabled&&(t+=a(`.${i}:disabled`,e.disabled)),e.before&&(t+=a(`.${i}:before`,e.before)),e.after&&(t+=a(`.${i}:after`,e.after));let m=document.getElementById(`${C.key??""}-dynamic-classes`);m?m.textContent+=t:(m=document.createElement("style"),m.id=`${C.key??""}-dynamic-classes`,m.textContent=t,document.head.appendChild(m)),l.classList.add(i)}function K(){P(w)}function P(l){w=k,k=l,k&&k.load(),w&&w.unload()}function ae(){return k}let k,w=null;class se{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:n,y:c,width:i,height:a,padding:t,fontSize:m="auto",anchor:b,place:p,modules:u={},modulesMap:o}){L(e,C.fontFamily);const d={anchor:b,x:n,y:c,width:i,height:a,padding:t,fontSize:m,place:p,element:e};Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{const f=g.overrideProperties(d,o[r]);b=f.anchor,n=f.x,c=f.y,i=f.width,a=f.height,t=f.padding,m=f.fontSize,p=f.place,e=f.element})});const s=()=>{typeof n=="number"&&typeof c=="number"&&j(e,n,c,b),m==="auto"?_(e):G(e,m),t&&X(e,t),i&&(e.style.width=$(i)+"px"),a&&(e.style.height=D(a)+"px")};s(),window.addEventListener("resize",s),Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{g.layoutEffect(d,o[r])})}),p&&document.body.append(e),this.resizeEventListeners.push(s),this.htmlElements.push(e),Object.keys(u)?.forEach(r=>{u[r].forEach(g=>{g.effect(d,o[r])})})}get currentSubscreen(){return k}get previousSubscreen(){return w}get name(){return""}run(){this.tabHandlers.run?.()}load(){this.createButton({x:1815,y:75,width:90,height:90,icon:"Icons/Exit.png",modules:{base:[new H({zIndex:"10"})]}}).addEventListener("click",()=>this.exit()),this.name&&(this.createText({text:this.name,x:100,y:60,fontSize:8}).style.cssText+="max-width: 85%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; padding: 0.1em;"),M[this.constructor.name]&&M[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(){K()}setSubscreen(e){P(e)}createButton({text:e,x:n,y:c,width:i,height:a,fontSize:t="auto",anchor:m="top-left",padding:b,style:p="default",place:u=!0,icon:o,iconAbsolutePosition:d=!0,tooltip:s,onClick:r,isDisabled:g,modules:f}){let h,v;const y=document.createElement("button");if(y.classList.add("zcButton"),y.setAttribute("data-zc-style",p),y.style.display="flex",y.style.alignItems="center",y.style.justifyContent="center",y.style.columnGap="1.25vw",L(y,C.fontFamily),o&&(typeof o=="string"?(h=document.createElement("img"),h.src=o):h=o,h.style.height="80%",h.style.width="auto",e&&d&&(h.style.position="absolute",h.style.left="1vw"),e&&!d&&(y.style.justifyContent=""),y.append(h)),e&&(v=document.createElement("span"),v.textContent=e,y.append(v)),s){const S=document.createElement("span");S.classList.add("tooltip"),S.setAttribute("position",s.position),S.textContent=s.text,y.append(S)}return typeof g=="function"&&g()&&y.classList.add("zcDisabled"),y.addEventListener("click",()=>{if(typeof g=="function"&&g())return y.classList.add("zcDisabled");typeof r=="function"&&r()}),this.addElement(y,{x:n,y:c,width:i,height:a,anchor:m,place:u,fontSize:t,padding:b,modules:f,modulesMap:{base:y,text:v,icon:h}}),y}createText({text:e,color:n,x:c,y:i,width:a,height:t,withBackground:m=!1,withBorder:b=!1,fontSize:p="auto",anchor:u="top-left",padding:o,place:d=!0,modules:s}){const r=document.createElement("p");return r.innerHTML=e,r.style.color=n??"var(--tmd-text, black)",m&&(r.style.background="var(--tmd-element,rgb(239, 239, 239))"),b&&(r.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),L(r,C.fontFamily),this.addElement(r,{x:c,y:i,width:a,height:t,anchor:u,place:d,fontSize:p,padding:o,modules:s,modulesMap:{base:r}}),r}createInput({value:e,placeholder:n,x:c,y:i,width:a,height:t,textArea:m=!1,fontSize:b="auto",anchor:p="top-left",padding:u,place:o=!0,onChange:d,onInput:s,isDisabled:r,modules:g}){const f=document.createElement(m?"textarea":"input");return f.classList.add("zcInput"),n&&(f.placeholder=n),e&&(f.value=e),L(f,C.fontFamily),typeof r=="function"&&r()&&f.classList.add("zcDisabled"),f.addEventListener("change",()=>{if(typeof r=="function"&&r())return f.classList.add("zcDisabled");typeof d=="function"&&d()}),f.addEventListener("input",()=>{if(typeof r=="function"&&r())return f.classList.add("zcDisabled");typeof s=="function"&&s()}),this.addElement(f,{x:c,y:i,width:a,height:t,anchor:p,place:o,fontSize:b,padding:u,modules:g,modulesMap:{base:f}}),f}createCheckbox({text:e,x:n,y:c,isChecked:i,width:a,modules:t,anchor:m="top-left",place:b=!0,isDisabled:p,onChange:u}){const o=document.createElement("div");o.style.display="flex",o.style.alignItems="center",o.style.columnGap="1vw";const d=document.createElement("input");d.type="checkbox",d.checked=i,d.style.borderRadius="min(0.8dvh, 0.3dvw)",d.style.aspectRatio="1/1",d.classList.add("zcCheckbox","checkbox");const s=document.createElement("p");return s.textContent=e,s.style.color="var(--tmd-text, black)",L(s,C.fontFamily),typeof p=="function"&&p()&&o.classList.add("zcDisabled"),o.addEventListener("change",()=>{if(typeof p=="function"&&p())return o.classList.add("zcDisabled");typeof u=="function"&&u()}),o.append(d,s),this.addElement(o,{x:n,y:c,width:a,anchor:m,place:b,modules:t,modulesMap:{base:o,checkbox:d,label:s}}),o}createScrollView({scroll:e,x:n,y:c,width:i,height:a,anchor:t="top-left",modules:m,place:b=!0}){const p=document.createElement("div");return e==="all"&&(p.style.overflow="scroll"),e==="x"&&(p.style.overflowX="scroll"),e==="y"&&(p.style.overflowY="scroll"),this.addElement(p,{x:n,y:c,width:i,height:a,anchor:t,place:b,modules:m,modulesMap:{base:p}}),p}createInputList({x:e,y:n,width:c,height:i,title:a,value:t,modules:m,anchor:b="top-left",place:p=!0,numbersOnly:u=!1,isDisabled:o,onChange:d}){const s=[],r=document.createElement("div");r.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
|
-
`,L(
|
|
5
|
-
overflow-y: scroll;`;const v=document.createElement("input");v.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 y=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new H({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",
|
|
4
|
+
`,L(r,C.fontFamily);const g=document.createElement("div");g.style.cssText="display: flex; justify-content: center; column-gap: 1vw; width: 100%;";const f=document.createElement("b");f.textContent=a+":",f.style.cssText="width: 100%; font-size: clamp(10px, 2.4vw, 24px); color: var(--tmd-text, black);";const h=document.createElement("div");h.style.cssText=`display: flex; gap: 1vw; flex-wrap: wrap; align-content: flex-start;
|
|
5
|
+
overflow-y: scroll;`;const v=document.createElement("input");v.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 y=(x,E)=>{const A=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new H({width:"70%",height:"70%"})]}});A.style.width="2em",A.style.aspectRatio="1/1",g.append(A)},S=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,h.insertBefore(E,v),E.addEventListener("click",A=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",A.stopPropagation()}),s.push(x)};return y(T(V),()=>{if(typeof o=="function"&&o())return r.classList.add("zcDisabled");h.innerHTML="",s.splice(0,s.length),h.append(v),t.forEach(x=>S(String(x))),typeof d=="function"&&d(u?s.map(x=>parseInt(x)):s)}),y(T(R),()=>{if(typeof o=="function"&&o())return r.classList.add("zcDisabled");for(const x of[...h.children])x.getAttribute("style").includes("border: 2px solid red;")&&(s.splice(s.indexOf(x.textContent),1),x.remove());typeof d=="function"&&d(u?s.map(x=>parseInt(x)):s)}),typeof o=="function"&&o()&&r.classList.add("zcDisabled"),v.addEventListener("keypress",x=>{if(document.activeElement===v)switch(x.key){case"Enter":if(u&&Number.isNaN(parseInt(v.value))||v.value.trim()==="")return;if(typeof o=="function"&&o())return r.classList.add("zcDisabled");S(v.value),v.value="",typeof d=="function"&&d(u?s.map(E=>parseInt(E)):s);break}}),r.addEventListener("click",x=>{x.currentTarget==r&&v.focus()}),h.append(v),r.append(g,f,h),this.addElement(r,{x:e,y:n,width:c,height:i,anchor:b,place:p,modules:m,modulesMap:{base:r,input:v}}),t.forEach(x=>S(String(x))),r}createImage({x:e,y:n,width:c,src:i,place:a=!0,anchor:t="top-left",modules:m}){const b=document.createElement("img");return b.style.height="auto",b.src=i,this.addElement(b,{x:e,y:n,width:c,height:0,anchor:t,place:a,modules:m,modulesMap:{base:b}}),b}createSvg({x:e,y:n,size:c,dataurl:i,place:a=!0,anchor:t="top-left",fill:m="var(--tmd-accent, black)",stroke:b="var(--tmd-accent-hover, black)",strokeWidth:p="2px",modules:u}){function o(r){const g=r.replace("data:image/svg+xml,",""),f=decodeURIComponent(g),h=document.createElement("div");return h.innerHTML=f,h.firstElementChild}function d(r,{fill:g,stroke:f}){return r.querySelectorAll("*").forEach(v=>{v.getAttribute("fill")!=="none"&&v.setAttribute("fill",g),v.getAttribute("stroke")!=="none"&&v.setAttribute("stroke",f)}),r.getAttribute("fill")!=="none"&&r.setAttribute("fill",g),r.getAttribute("stroke")!=="none"&&r.setAttribute("stroke",f),r}const s=o(i);return d(s,{fill:m,stroke:b}),s.setAttribute("stroke-width",p),this.addElement(s,{x:e,y:n,width:c,height:c,anchor:t,place:a,modules:u,modulesMap:{base:s}}),s}createBackNextButton({x:e,y:n,width:c,height:i,items:a,currentIndex:t,modules:m,isBold:b=!1,anchor:p="top-left",place:u=!0,onChange:o,isDisabled:d}){const s=document.createElement("div");s.classList.add("zcBackNextButton"),L(s,C.fontFamily);const r=()=>{t===0||typeof d=="function"&&d(a[t-1][1])?g.classList.add("zcBackNextButton-btnDisabled"):g.classList.remove("zcBackNextButton-btnDisabled"),t===a.length-1||typeof d=="function"&&d(a[t+1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled")},g=document.createElement("button");g.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
|
-
`,
|
|
8
|
+
`,g.classList.add("zcButton"),g.addEventListener("click",()=>{if(t===0||typeof d=="function"&&d(a[t-1][1]))return g.classList.add("zcDisabled");t--,h.textContent=a[t][0],typeof o=="function"&&o(a[t][1]),r()});const f=document.createElement("button");f.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
|
-
`,
|
|
11
|
+
`,f.classList.add("zcButton"),f.addEventListener("click",()=>{if(t===a.length-1||typeof d=="function"&&d(a[t+1][1]))return f.classList.add("zcDisabled");t++,h.textContent=a[t][0],typeof o=="function"&&o(a[t][1]),r()}),r();const h=document.createElement("p");return b&&(h.style.fontWeight="bold"),h.textContent=a[t][0],s.append(g,h,f),this.addElement(s,{x:e,y:n,width:c,height:i,anchor:p,place:u,modules:m,modulesMap:{base:s,backButton:g,nextButton:f,text:h}}),s}createTabs({x:e,y:n,width:c,tabs:i,anchor:a="top-left",place:t=!0,currentTabName:m,modules:b}){let p=[];const u=document.createElement("div");return u.classList.add("zcTabs"),L(u,C.fontFamily),i.forEach(o=>{const d=()=>{for(const g of u.children)g.removeAttribute("data-opened");for(const g of p)g instanceof Node&&document.body.removeChild(g);p=[],s.setAttribute("data-opened","true");const r=document.body.append.bind(document.body);document.body.append=(...g)=>{p.push(...g),r(...g)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),o.load(),this.tabHandlers={run:o.run,load:o.load,unload:o.unload,exit:o.exit},document.body.append=r},s=document.createElement("button");s.textContent=o.name,o.name===m&&d(),s.addEventListener("click",d),u.append(s)}),this.addElement(u,{x:e,y:n,width:c,anchor:a,place:t,modules:b,modulesMap:{base:u}}),u}drawPolylineArrow({points:e,strokeColor:n=z()?.base?.text??"black",lineWidth:c=2,circleRadius:i=5,circleColor:a=z()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=n,t.lineWidth=c,t.fillStyle=a,t.beginPath(),t.moveTo(e[0].x,e[0].y);for(let m=1;m<e.length;m++)t.lineTo(e[m].x,e[m].y);t.stroke(),t.beginPath(),t.arc(e[0].x,e[0].y,i,0,Math.PI*2),t.fill(),t.beginPath(),t.arc(e[e.length-1].x,e[e.length-1].y,i,0,Math.PI*2),t.fill(),t.restore()}createCard({x:e,y:n,name:c,value:i,icon:a,anchor:t="top-left",place:m=!0,modules:b}){const p=document.createElement("div");p.classList.add("zcCard");const u=document.createElement("p");u.classList.add("zcCard_name"),u.textContent=c;const o=document.createElement("p");return o.classList.add("zcCard_value"),o.textContent=`${i}`,a&&(a.style.cssText+="position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;",p.append(a)),p.append(u,o),this.addElement(p,{x:e,y:n,anchor:t,place:m,modules:b,modulesMap:{name:u,value:o,base:p,icon:null}}),p}createSelect({x:e,y:n,width:c,options:i,currentOption:a,anchor:t="top-left",place:m=!0,modules:b,onChange:p,isDisabled:u}){let o=!1,d;const s=document.createElement("div");s.classList.add("zcSelect"),s.setAttribute("opened",!1),s.addEventListener("click",()=>{if(u&&u())return s.classList.add("zcDisabled");o?(o=!1,d.remove()):(o=!0,d=document.createElement("div"),d.setAttribute("data-zc-position",typeof n=="number"&&n>500-s.offsetHeight/2?"top":"bottom"),i.forEach(h=>{const v=document.createElement("div");v.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",h.icon&&(h.icon.style.cssText="color: #bcbcbc;",v.append(h.icon)),v.append(h.text),h.name===a&&v.append(f),v.addEventListener("click",()=>{a=h.name,r.textContent=h.text,d.remove(),p&&p(h.name)}),d.append(v)}),s.append(d))});const r=document.createElement("p");r.textContent=i.find(h=>h.name===a).text;const g=T(N),f=T(I);return f.style.cssText="position: absolute; right: 0.25em;",s.append(r,g),u&&u()&&s.classList.add("zcDisabled"),this.addElement(s,{x:e,y:n,width:c,anchor:t,place:m,modules:b,modulesMap:{base:s}}),s}createContainer({x:e,y:n,width:c,height:i,anchor:a="top-left",place:t=!0,modules:m}){const b=document.createElement("div");return this.addElement(b,{x:e,y:n,width:c,height:i,anchor:a,place:t,modules:m,modulesMap:{base:b}}),b}}const M={};function re(l,e){M[l]||(M[l]=[]),M[l].push(e)}export{se as BaseSubscreen,ne as addDynamicClass,_ as autosetFontSize,ee as cssVar,Q as dataUrlSvgReplaceVars,J as dataUrlSvgWithColor,ae as getCurrentSubscreen,D as getRelativeHeight,$ as getRelativeWidth,O as getRelativeX,F as getRelativeY,W as hexToRgb,re as hookSubscreen,L as setFontFamily,G as setFontSize,X as setPadding,j as setPosition,K as setPreviousSubscreen,te as setSize,P as setSubscreen};
|