zois-core 1.1.2 → 1.1.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/messaging.js CHANGED
@@ -1 +1 @@
1
- import{getPlayer as g,MOD_DATA as u}from"./index";import{hookFunction as p,HookPriority as m}from"./modsApi";import{setFontFamily as h}from"./ui";import{validateData as f}from"./validation";class k{sendBeep(n,e){const c={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...n})};ServerSend("AccountBeep",c)}sendPacket(n,e,c){const o={Content:u.key,Dictionary:{msg:n},Type:"Hidden"};e&&(o.Dictionary.data=e),c&&(o.Target=c),ServerSend("ChatRoomChat",o)}sendAction(n,e=void 0,c=[]){if(!n||!ServerPlayerIsInChatRoom())return;const o=CharacterPronounDescription(Player)==="She/Her",i=o?"Her":"His",s=o?"Her":"Him",r=o?"Herself":"Himself",t=o?"She":"He";n=n.replaceAll("<Possessive>",i).replaceAll("<possessive>",i.toLocaleLowerCase()).replaceAll("<Intensive>",s).replaceAll("<intensive>",s.toLocaleLowerCase()).replaceAll("<SelfIntensive>",r).replaceAll("<selfIntensive>",r.toLocaleLowerCase()).replaceAll("<Pronoun>",t).replaceAll("<pronoun>",t.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:n},...c]})}sendRequest({message:n,data:e={},target:c,type:o="packet"}){const i=crypto.randomUUID();return new Promise(s=>{let r;o==="packet"?(C.sendPacket("request",{requestId:i,message:n,data:e},c),r=p("ChatRoomMessage",m.ADD_BEHAVIOR,(t,a)=>{const l=t[0],d=g(l.Sender);if(!d)return a(t);if(l.Content===u.key&&!d.IsPlayer()){const y=l.Dictionary.msg,R=l.Dictionary.data;y==="requestResponse"&&R.requestId===i&&(r(),s({data:R.data,isError:!1}))}return a(t)})):(C.sendBeep({type:`${u.key}_request`,requestId:i,message:n,data:e},c),r=p("ServerAccountBeep",m.ADD_BEHAVIOR,(t,a)=>{const l=t[0];if(l.BeepType!=="Leash")return a(t);let d;try{d=JSON.parse(l.Message)}catch{return a(t)}return d.type===`${u.key}_requestResponse`&&d.requestId===i&&(r(),s({data:d.data,isError:!1})),a(t)})),setTimeout(()=>{r(),s({isError:!0})},6e3)})}sendLocal(n){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),h(e,u.fontFamily),e.style.background=u.chatMessageBackground??"#55edc095",e.style.color=u.chatMessageColor??"black",e.style.margin="0.15em 0",typeof n=="string"?e.innerHTML=n:e.appendChild(n),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(n){ServerSend("ChatRoomChat",{Type:"Chat",Content:n})}onRequest(n,e,c){let o,i;typeof e=="function"&&e.prototype?.constructor==e?(i=e,o=c):o=e,p("ChatRoomMessage",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0],a=g(t.Sender);if(!a)return r(s);if(t.Content===u.key&&!a.IsPlayer()){const l=t.Dictionary?.msg,d=t.Dictionary?.data;if(l==="request"&&d.message===n){if(typeof d.requestId!="string"||typeof d.message!="string")return;if(i&&!(await f(d.data,i)).isValid)return r(s);const y=o(d.data,a);y!==void 0&&C.sendPacket("requestResponse",{requestId:d.requestId,message:d.message,data:y},a.MemberNumber)}}return r(s)}),p("ServerAccountBeep",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0];if(t.BeepType!=="Leash")return r(s);let a;try{a=JSON.parse(t.Message)}catch{return r(s)}if(a.type===`${u.key}_request`&&a.message===n){if(typeof a.requestId!="string")return;if(i&&!(await f(a.data,i)).isValid)return r(s);o(a.data,t.MemberNumber,t.MemberName)!==void 0&&C.sendBeep({type:`${u.key}_requestResponse`,requestId:a.requestId,message:a.message,data:a.data},t.MemberNumber)}return r(s)})}onPacket(n,e,c){p("ChatRoomMessage",m.ADD_BEHAVIOR,async(o,i)=>{let s,r;typeof e=="function"&&e.prototype?.constructor==e?(r=e,s=c):s=e;const t=o[0],a=g(t.Sender);if(!a)return i(o);if(t.Content===u.key&&t.Dictionary.msg===n&&!a.IsPlayer()){if(r&&!(await f(t.Dictionary?.data,r)).isValid)return i(o);s(t.Dictionary.data,a)}return i(o)})}}const C=new k;export{C as messagesManager};
1
+ import{getPlayer as g,MOD_DATA as l}from"./index";import{hookFunction as p,HookPriority as m}from"./modsApi";import{setFontFamily as h}from"./ui";import{validateData as f}from"./validation";class k{sendBeep(a,e){const d={IsSecret:!0,BeepType:"Leash",MemberNumber:e,Message:JSON.stringify({...a})};ServerSend("AccountBeep",d)}sendPacket(a,e,d){const o={Content:l.key,Dictionary:{msg:a},Type:"Hidden"};e&&(o.Dictionary.data=e),d&&(o.Target=d),ServerSend("ChatRoomChat",o)}sendAction(a,e=void 0,d=[]){if(!a||!ServerPlayerIsInChatRoom())return;const o=CharacterPronounDescription(Player)==="She/Her",i=o?"Her":"His",s=o?"Her":"Him",r=o?"Herself":"Himself",t=o?"She":"He";a=a.replaceAll("<Possessive>",i).replaceAll("<possessive>",i.toLocaleLowerCase()).replaceAll("<Intensive>",s).replaceAll("<intensive>",s.toLocaleLowerCase()).replaceAll("<SelfIntensive>",r).replaceAll("<selfIntensive>",r.toLocaleLowerCase()).replaceAll("<Pronoun>",t).replaceAll("<pronoun>",t.toLocaleLowerCase()),ServerSend("ChatRoomChat",{Content:"ZC_CUSTOM_ACTION",Type:"Action",Target:e??void 0,Dictionary:[{Tag:'MISSING TEXT IN "Interface.csv": ZC_CUSTOM_ACTION',Text:a},...d]})}sendRequest({message:a,data:e={},target:d,type:o="packet"}){const i=crypto.randomUUID();return new Promise(s=>{let r;o==="packet"?(C.sendPacket("request",{requestId:i,message:a,data:e},d),r=p("ChatRoomMessage",m.ADD_BEHAVIOR,(t,n)=>{const u=t[0],c=g(u.Sender);if(!c)return n(t);if(u.Content===l.key&&!c.IsPlayer()){const y=u.Dictionary.msg,R=u.Dictionary.data;y==="requestResponse"&&R.requestId===i&&(r(),s({data:R.data,isError:!1}))}return n(t)})):(C.sendBeep({type:`${l.key}_request`,requestId:i,message:a,data:e},d),r=p("ServerAccountBeep",m.ADD_BEHAVIOR,(t,n)=>{const u=t[0];if(u.BeepType!=="Leash")return n(t);let c;try{c=JSON.parse(u.Message)}catch{return n(t)}return c.type===`${l.key}_requestResponse`&&c.requestId===i&&(r(),s({data:c.data,isError:!1})),n(t)})),setTimeout(()=>{r(),s({isError:!0})},6e3)})}sendLocal(a){if(!ServerPlayerIsInChatRoom())return;const e=document.createElement("div");e.setAttribute("class","ChatMessage ChatMessageLocalMessage"),e.setAttribute("data-time",ChatRoomCurrentTime()),e.setAttribute("data-sender",`${Player.MemberNumber}`),h(e,l.fontFamily),e.style.background=l.chatMessageBackground??"#55edc095",e.style.color=l.chatMessageColor??"black",e.style.margin="0.15em 0",typeof a=="string"?e.innerHTML=a:e.appendChild(a),document.querySelector("#TextAreaChatLog").appendChild(e),ElementScrollToEnd("TextAreaChatLog")}sendChat(a){ServerSend("ChatRoomChat",{Type:"Chat",Content:a})}onRequest(a,e,d){let o,i;typeof e=="function"&&e.prototype?.constructor==e?(i=e,o=d):o=e,p("ChatRoomMessage",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0],n=g(t.Sender);if(!n)return r(s);if(t.Content===l.key&&!n.IsPlayer()){const u=t.Dictionary?.msg,c=t.Dictionary?.data;if(u==="request"&&c.message===a){if(typeof c.requestId!="string"||typeof c.message!="string")return;if(i&&!(await f(c.data,i)).isValid)return r(s);const y=o(c.data,n);y!==void 0&&C.sendPacket("requestResponse",{requestId:c.requestId,message:c.message,data:y},n.MemberNumber)}}return r(s)}),p("ServerAccountBeep",m.ADD_BEHAVIOR,async(s,r)=>{const t=s[0];if(t.BeepType!=="Leash")return r(s);let n;try{n=JSON.parse(t.Message)}catch{return r(s)}if(n.type===`${l.key}_request`&&n.message===a){if(typeof n.requestId!="string")return;if(i&&!(await f(n.data,i)).isValid)return r(s);const u=o(n.data,t.MemberNumber,t.MemberName);u!==void 0&&C.sendBeep({type:`${l.key}_requestResponse`,requestId:n.requestId,message:n.message,data:u},t.MemberNumber)}return r(s)})}onPacket(a,e,d){p("ChatRoomMessage",m.ADD_BEHAVIOR,async(o,i)=>{let s,r;typeof e=="function"&&e.prototype?.constructor==e?(r=e,s=d):s=e;const t=o[0],n=g(t.Sender);if(!n)return i(o);if(t.Content===l.key&&t.Dictionary.msg===a&&!n.IsPlayer()){if(r&&!(await f(t.Dictionary?.data,r)).isValid)return i(o);s(t.Dictionary.data,n)}return i(o)})}}const C=new k;export{C as messagesManager};
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}
@@ -0,0 +1,6 @@
1
+ import { BaseModule, Context, ModuleTarget } from "../modules";
2
+ export declare class AttributesModule extends BaseModule {
3
+ private attributes;
4
+ constructor(attributes: Record<string, string>);
5
+ layoutEffect(context: Context, target: ModuleTarget): void;
6
+ }
@@ -2,3 +2,4 @@ export * from "./centerModule";
2
2
  export * from "./counterUpModule";
3
3
  export * from "./typeModule";
4
4
  export * from "./styleModule";
5
+ export * from "./attributesModule";
@@ -1,6 +1,8 @@
1
1
  import { BaseModule, Context, ModuleTarget } from "../modules";
2
2
  export declare class StyleModule extends BaseModule {
3
3
  private style;
4
- constructor(style: Partial<CSSStyleDeclaration>);
4
+ private extended?;
5
+ constructor(style: Partial<CSSStyleDeclaration>, extended?: Partial<Record<"click" | "hover", Partial<CSSStyleDeclaration>>>);
6
+ private applyStyle;
5
7
  layoutEffect(context: Context, target: ModuleTarget): void;
6
8
  }
@@ -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;
@@ -72,6 +73,13 @@ interface CreateImageArgs extends BaseElementArgs<"base"> {
72
73
  src: string;
73
74
  width: number;
74
75
  }
76
+ interface CreateSvgArgs extends BaseElementArgs<"base"> {
77
+ dataurl: string;
78
+ size: number;
79
+ fill?: string;
80
+ stroke?: string;
81
+ strokeWidth?: string;
82
+ }
75
83
  interface CreateBackNextButtonArgs extends BaseElementArgs<"base" | "backButton" | "nextButton" | "text"> {
76
84
  width: number;
77
85
  height: number;
@@ -108,7 +116,11 @@ interface CreateSelectArgs extends BaseElementArgs<"base"> {
108
116
  onChange?: (name: any) => void;
109
117
  isDisabled?: () => boolean;
110
118
  }
111
- interface DrawPolylineArrowArgs extends Omit<BaseElementArgs<"base">, "x" | "y"> {
119
+ interface CreateContainerArgs extends BaseElementArgs<"base"> {
120
+ width?: number;
121
+ height?: number;
122
+ }
123
+ interface DrawPolylineArrowArgs {
112
124
  points: {
113
125
  x: number;
114
126
  y: number;
@@ -118,6 +130,7 @@ interface DrawPolylineArrowArgs extends Omit<BaseElementArgs<"base">, "x" | "y">
118
130
  circleRadius?: number;
119
131
  circleColor?: string;
120
132
  }
133
+ export declare function dataUrlSvgWithColor(dataUrl: string, newColor: string): string;
121
134
  export declare function getRelativeHeight(height: number): number;
122
135
  export declare function getRelativeWidth(width: number): number;
123
136
  export declare function getRelativeY(yPos: number, anchorPosition?: 'top' | 'bottom'): number;
@@ -148,17 +161,19 @@ export declare abstract class BaseSubscreen {
148
161
  setPreviousSubscreen(): void;
149
162
  setSubscreen(subscreen: BaseSubscreen | null): void;
150
163
  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;
164
+ createText({ text, color, x, y, width, height, withBackground, withBorder, fontSize, anchor, padding, place, modules }: CreateTextArgs): HTMLParagraphElement;
152
165
  createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled, modules }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
153
166
  createCheckbox({ text, x, y, isChecked, width, modules, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
154
167
  createScrollView({ scroll, x, y, width, height, anchor, modules, place }: CreateScrollViewArgs): HTMLDivElement;
155
168
  createInputList({ x, y, width, height, title, value, modules, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
156
169
  createImage({ x, y, width, src, place, anchor, modules }: CreateImageArgs): HTMLImageElement;
170
+ createSvg({ x, y, size, dataurl, place, anchor, fill, stroke, strokeWidth, modules }: CreateSvgArgs): HTMLElement;
157
171
  createBackNextButton({ x, y, width, height, items, currentIndex, modules, isBold, anchor, place, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
158
172
  createTabs({ x, y, width, tabs, anchor, place, currentTabName, modules }: CreateTabArgs): HTMLDivElement;
159
173
  drawPolylineArrow({ points, strokeColor, lineWidth, circleRadius, circleColor }: DrawPolylineArrowArgs): void;
160
174
  createCard({ x, y, name, value, icon, anchor, place, modules }: CreateCardArgs): HTMLDivElement;
161
175
  createSelect({ x, y, width, options, currentOption, anchor, place, modules, onChange, isDisabled }: CreateSelectArgs): HTMLDivElement;
176
+ createContainer({ x, y, anchor, place, modules }: CreateContainerArgs): HTMLDivElement;
162
177
  }
163
178
  export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
164
179
  export {};
@@ -0,0 +1 @@
1
+ import{BaseModule as o}from"../modules";class c extends o{constructor(e){super();this.attributes=e}layoutEffect(e,r){for(const t of Object.keys(this.attributes))r.setAttribute(t,this.attributes[t])}}export{c as AttributesModule};
@@ -1 +1 @@
1
- export*from"./centerModule";export*from"./counterUpModule";export*from"./typeModule";export*from"./styleModule";
1
+ export*from"./centerModule";export*from"./counterUpModule";export*from"./typeModule";export*from"./styleModule";export*from"./attributesModule";
@@ -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 i}from"../modules";class r extends i{constructor(l,e){super();this.style=l;this.extended=e}applyStyle(l,e){for(const t of Object.keys(e))!isNaN(t)||typeof e[t]=="function"||(l.style[t]=e[t])}layoutEffect(l,e){this.applyStyle(e,this.style);const t=Object.assign({},e.style);this.extended?.click&&e.addEventListener("click",()=>{this.applyStyle(e,this.extended.click),setTimeout(()=>this.applyStyle(e,t),250)}),this.extended?.hover&&(e.addEventListener("mouseenter",()=>{this.applyStyle(e,this.extended.hover)}),e.addEventListener("mouseleave",()=>{this.applyStyle(e,t)}))}}export{r 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 P,CircleX as R,createElement as B,Trash2 as V}from"lucide";import{getThemedColorsModule as S,MOD_DATA as L}from"./index";import{StyleModule as z}from"./ui-modules";function q(v,e){return v.replace(/fill="[^"]*"/g,`fill="${e}"`).replace(/stroke="[^"]*"/g,`stroke="${e}"`)}function H(v){return v*(MainCanvas.canvas.clientHeight/1e3)}function I(v){return v*(MainCanvas.canvas.clientWidth/2e3)}function W(v,e="top"){const o=MainCanvas.canvas.clientHeight/1e3;return e==="top"?MainCanvas.canvas.offsetTop+v*o:window.innerHeight-(MainCanvas.canvas.offsetTop+MainCanvas.canvas.clientHeight)+v*o}function D(v,e="left"){const o=MainCanvas.canvas.clientWidth/2e3;return e==="left"?MainCanvas.canvas.offsetLeft+v*o:window.innerWidth-(MainCanvas.canvas.offsetLeft+MainCanvas.canvas.clientWidth)+v*o}function j(v,e,o,l="top-left"){const u=l==="top-left"||l==="top-right"?"top":"bottom",r=l==="top-left"||l==="bottom-left"?"left":"right",t=W(o,u),p=D(e,r);Object.assign(v.style,{position:"fixed",[r]:p+"px",[u]:t+"px"})}function J(v,e,o){Object.assign(v.style,{width:I(e)+"px",height:H(o)+"px"})}function G(v,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,u=Math.min(o,l)/100,r=e*u;Object.assign(v.style,{fontSize:r+"px"})}function A(v,e){v.style.fontFamily=e??"sans-serif"}function O(v,e){const o=MainCanvas.canvas.clientWidth,l=MainCanvas.canvas.clientHeight,u=Math.min(o,l)/100,r=e*u;Object.assign(v.style,{padding:r+"px"})}function X(v){const e=MainCanvas.canvas.clientWidth<=MainCanvas.canvas.clientHeight*2?MainCanvas.canvas.clientWidth/50:MainCanvas.canvas.clientHeight/25;Object.assign(v.style,{fontSize:e+"px"})}function U(){F(M)}function F(v){M=k,k=v,k&&k.load(),M&&M.unload()}function K(){return k}let k,M=null;class Q{htmlElements=[];resizeEventListeners=[];tabHandlers={};addElement(e,{x:o,y:l,width:u,height:r,padding:t,fontSize:p="auto",anchor:g,place:m,modules:d={},modulesMap:s}){A(e,L.fontFamily);const c={anchor:g,x:o,y:l,width:u,height:r,padding:t,fontSize:p,place:m,element:e};Object.keys(d)?.forEach(a=>{d[a].forEach(f=>{const i=f.overrideProperties(c,s[a]);g=i.anchor,o=i.x,l=i.y,u=i.width,r=i.height,t=i.padding,p=i.fontSize,m=i.place,e=i.element})});const n=()=>{typeof o=="number"&&typeof l=="number"&&j(e,o,l,g),p==="auto"?X(e):G(e,p),t&&O(e,t),u&&(e.style.width=I(u)+"px"),r&&(e.style.height=H(r)+"px")};n(),window.addEventListener("resize",n),Object.keys(d)?.forEach(a=>{d[a].forEach(f=>{f.layoutEffect(c,s[a])})}),m&&document.body.append(e),this.resizeEventListeners.push(n),this.htmlElements.push(e),Object.keys(d)?.forEach(a=>{d[a].forEach(f=>{f.effect(c,s[a])})})}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",modules:{base:[new z({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;"),T[this.constructor.name]&&T[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(){U()}setSubscreen(e){F(e)}createButton({text:e,x:o,y:l,width:u,height:r,fontSize:t="auto",anchor:p="top-left",padding:g,style:m="default",place:d=!0,icon:s,iconAbsolutePosition:c=!0,iconWidth:n,tooltip:a,onClick:f,isDisabled:i,modules:h}){let b,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",A(y,L.fontFamily),s&&(typeof s=="string"?(b=document.createElement("img"),b.src=s):b=s,n?b.style.width=n:b.style.height="80%",e&&c&&(b.style.position="absolute",b.style.left="1vw"),e&&!c&&(y.style.justifyContent=""),y.append(b)),e&&(C=document.createElement("span"),C.textContent=e,s&&!c&&n&&(C.style.width="100%",C.style.marginRight=n),y.append(C)),a){const x=document.createElement("span");x.classList.add("tooltip"),x.setAttribute("position",a.position),x.textContent=a.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:o,y:l,width:u,height:r,anchor:p,place:d,fontSize:t,padding:g,modules:h,modulesMap:{base:y,text:C,icon:b}}),y}createText({text:e,color:o,x:l,y:u,width:r,height:t,withBackground:p=!1,withBorder:g=!1,fontSize:m="auto",anchor:d="top-left",padding:s,place:c=!0,modules:n}){const a=document.createElement("p");return a.innerHTML=e,a.style.color=o??"var(--tmd-text, black)",p&&(a.style.background="var(--tmd-element,rgb(239, 239, 239))"),g&&(a.style.border="2px solid var(--tmd-accent, rgb(236, 236, 236))"),A(a,L.fontFamily),this.addElement(a,{x:l,y:u,width:r,height:t,anchor:d,place:c,fontSize:m,padding:s,modules:n,modulesMap:{base:a}}),a}createInput({value:e,placeholder:o,x:l,y:u,width:r,height:t,textArea:p=!1,fontSize:g="auto",anchor:m="top-left",padding:d,place:s=!0,onChange:c,onInput:n,isDisabled:a,modules:f}){const i=document.createElement(p?"textarea":"input");return i.classList.add("zcInput"),o&&(i.placeholder=o),e&&(i.value=e),A(i,L.fontFamily),typeof a=="function"&&a()&&i.classList.add("zcDisabled"),i.addEventListener("change",()=>{if(typeof a=="function"&&a())return i.classList.add("zcDisabled");typeof c=="function"&&c()}),i.addEventListener("input",()=>{if(typeof a=="function"&&a())return i.classList.add("zcDisabled");typeof n=="function"&&n()}),this.addElement(i,{x:l,y:u,width:r,height:t,anchor:m,place:s,fontSize:g,padding:d,modules:f,modulesMap:{base:i}}),i}createCheckbox({text:e,x:o,y:l,isChecked:u,width:r,modules:t,anchor:p="top-left",place:g=!0,isDisabled:m,onChange:d}){const s=document.createElement("div");s.style.display="flex",s.style.alignItems="center",s.style.columnGap="1vw";const c=document.createElement("input");c.type="checkbox",c.checked=u,c.style.borderRadius="min(0.8dvh, 0.3dvw)",c.style.aspectRatio="1/1",c.classList.add("zcCheckbox","checkbox");const n=document.createElement("p");return n.textContent=e,n.style.color="var(--tmd-text, black)",A(n,L.fontFamily),typeof m=="function"&&m()&&s.classList.add("zcDisabled"),s.addEventListener("change",()=>{if(typeof m=="function"&&m())return s.classList.add("zcDisabled");typeof d=="function"&&d()}),s.append(c,n),this.addElement(s,{x:o,y:l,width:r,anchor:p,place:g,modules:t,modulesMap:{base:s,checkbox:c,label:n}}),s}createScrollView({scroll:e,x:o,y:l,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:l,width:u,height:r,anchor:t,place:g,modules:p,modulesMap:{base:m}}),m}createInputList({x:e,y:o,width:l,height:u,title:r,value:t,modules:p,anchor:g="top-left",place:m=!0,numbersOnly:d=!1,isDisabled:s,onChange:c}){const n=[],a=document.createElement("div");a.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
+ `,A(a,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=r+":",i.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 b=document.createElement("input");b.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 w=this.createButton({icon:x,place:!1,onClick:E,style:"default",modules:{icon:[new z({width:"70%",height:"70%"})]}});w.style.width="2em",w.style.aspectRatio="1/1",f.append(w)},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,h.insertBefore(E,b),E.addEventListener("click",w=>{E.style.border===""?E.style.border="2px solid red":E.style.border="",w.stopPropagation()}),n.push(x)};return C(B(R),()=>{if(typeof s=="function"&&s())return a.classList.add("zcDisabled");h.innerHTML="",n.splice(0,n.length),h.append(b),t.forEach(x=>y(String(x))),typeof c=="function"&&c(d?n.map(x=>parseInt(x)):n)}),C(B(V),()=>{if(typeof s=="function"&&s())return a.classList.add("zcDisabled");for(const x of[...h.children])x.getAttribute("style").includes("border: 2px solid red;")&&(n.splice(n.indexOf(x.textContent),1),x.remove());typeof c=="function"&&c(d?n.map(x=>parseInt(x)):n)}),typeof s=="function"&&s()&&a.classList.add("zcDisabled"),b.addEventListener("keypress",x=>{if(document.activeElement===b)switch(x.key){case"Enter":if(d&&Number.isNaN(parseInt(b.value))||b.value.trim()==="")return;if(typeof s=="function"&&s())return a.classList.add("zcDisabled");y(b.value),b.value="",typeof c=="function"&&c(d?n.map(E=>parseInt(E)):n);break}}),a.addEventListener("click",x=>{x.currentTarget==a&&b.focus()}),h.append(b),a.append(f,i,h),this.addElement(a,{x:e,y:o,width:l,height:u,anchor:g,place:m,modules:p,modulesMap:{base:a,input:b}}),t.forEach(x=>y(String(x))),a}createImage({x:e,y:o,width:l,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:l,height:0,anchor:t,place:r,modules:p,modulesMap:{base:g}}),g}createSvg({x:e,y:o,size:l,dataurl:u,place:r=!0,anchor:t="top-left",fill:p="var(--tmd-accent, black)",stroke:g="var(--tmd-accent-hover, black)",strokeWidth:m="2px",modules:d}){function s(a){const f=a.replace("data:image/svg+xml,",""),i=decodeURIComponent(f),h=document.createElement("div");return h.innerHTML=i,h.firstElementChild}function c(a,{fill:f,stroke:i}){return a.querySelectorAll("*").forEach(b=>{b.getAttribute("fill")!=="none"&&b.setAttribute("fill",f),b.getAttribute("stroke")!=="none"&&b.setAttribute("stroke",i)}),a.getAttribute("fill")!=="none"&&a.setAttribute("fill",f),a.getAttribute("stroke")!=="none"&&a.setAttribute("stroke",i),a}const n=s(u);return c(n,{fill:p,stroke:g}),n.setAttribute("stroke-width",m),this.addElement(n,{x:e,y:o,width:l,height:l,anchor:t,place:r,modules:d,modulesMap:{base:n}}),n}createBackNextButton({x:e,y:o,width:l,height:u,items:r,currentIndex:t,modules:p,isBold:g=!1,anchor:m="top-left",place:d=!0,onChange:s,isDisabled:c}){const n=document.createElement("div");n.classList.add("zcBackNextButton"),A(n,L.fontFamily);const a=()=>{t===0||typeof c=="function"&&c(r[t-1][1])?f.classList.add("zcBackNextButton-btnDisabled"):f.classList.remove("zcBackNextButton-btnDisabled"),t===r.length-1||typeof c=="function"&&c(r[t+1][1])?i.classList.add("zcBackNextButton-btnDisabled"):i.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 c=="function"&&c(r[t-1][1]))return f.classList.add("zcDisabled");t--,h.textContent=r[t][0],typeof s=="function"&&s(r[t][1]),a()});const i=document.createElement("button");i.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
+ `,i.classList.add("zcButton"),i.addEventListener("click",()=>{if(t===r.length-1||typeof c=="function"&&c(r[t+1][1]))return i.classList.add("zcDisabled");t++,h.textContent=r[t][0],typeof s=="function"&&s(r[t][1]),a()}),a();const h=document.createElement("p");return g&&(h.style.fontWeight="bold"),h.textContent=r[t][0],n.append(f,h,i),this.addElement(n,{x:e,y:o,width:l,height:u,anchor:m,place:d,modules:p,modulesMap:{base:n,backButton:f,nextButton:i,text:h}}),n}createTabs({x:e,y:o,width:l,tabs:u,anchor:r="top-left",place:t=!0,currentTabName:p,modules:g}){let m=[];const d=document.createElement("div");return d.classList.add("zcTabs"),A(d,L.fontFamily),u.forEach(s=>{const c=()=>{for(const f of d.children)f.removeAttribute("data-opened");for(const f of m)f instanceof Node&&document.body.removeChild(f);m=[],n.setAttribute("data-opened","true");const a=document.body.append.bind(document.body);document.body.append=(...f)=>{m.push(...f),a(...f)},this.tabHandlers.unload?.(),this.tabHandlers.exit?.(),s.load(),this.tabHandlers={run:s.run,load:s.load,unload:s.unload,exit:s.exit},document.body.append=a},n=document.createElement("button");n.textContent=s.name,s.name===p&&c(),n.addEventListener("click",c),d.append(n)}),this.addElement(d,{x:e,y:o,width:l,anchor:r,place:t,modules:g,modulesMap:{base:d}}),d}drawPolylineArrow({points:e,strokeColor:o=S()?.base?.text??"black",lineWidth:l=2,circleRadius:u=5,circleColor:r=S()?.base?.text??"black"}){if(e.length<2)return;const t=MainCanvas.canvas.getContext("2d");t.save(),t.strokeStyle=o,t.lineWidth=l,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:l,value:u,icon:r,anchor:t="top-left",place:p=!0,modules:g}){const m=document.createElement("div");m.classList.add("zcCard");const d=document.createElement("p");d.classList.add("zcCard_name"),d.textContent=l;const s=document.createElement("p");return s.classList.add("zcCard_value"),s.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(d,s),this.addElement(m,{x:e,y:o,anchor:t,place:p,modules:g,modulesMap:{name:d,value:s,base:m,icon:null}}),m}createSelect({x:e,y:o,width:l,options:u,currentOption:r,anchor:t="top-left",place:p=!0,modules:g,onChange:m,isDisabled:d}){let s=!1,c;const n=document.createElement("div");n.classList.add("zcSelect"),n.setAttribute("opened",!1),n.addEventListener("click",()=>{if(d&&d())return n.classList.add("zcDisabled");s?(s=!1,c.remove()):(s=!0,c=document.createElement("div"),c.setAttribute("data-zc-position",typeof o=="number"&&o>500-n.offsetHeight/2?"top":"bottom"),u.forEach(h=>{const b=document.createElement("div");b.style.cssText="display: flex; align-items: center; column-gap: 0.5em;",h.icon&&(h.icon.style.cssText="color: #bcbcbc;",b.append(h.icon)),b.append(h.text),h.name===r&&b.append(i),b.addEventListener("click",()=>{r=h.name,a.textContent=h.text,c.remove(),m&&m(h.name)}),c.append(b)}),n.append(c))});const a=document.createElement("p");a.textContent=u.find(h=>h.name===r).text;const f=B(P),i=B(N);return i.style.cssText="position: absolute; right: 0.25em;",n.append(a,f),d&&d()&&n.classList.add("zcDisabled"),this.addElement(n,{x:e,y:o,width:l,anchor:t,place:p,modules:g,modulesMap:{base:n}}),n}createContainer({x:e,y:o,anchor:l="top-left",place:u=!0,modules:r}){const t=document.createElement("div");return this.addElement(t,{x:e,y:o,anchor:l,place:u,modules:r,modulesMap:{base:t}}),t}}const T={};function Z(v,e){T[v]||(T[v]=[]),T[v].push(e)}export{Q as BaseSubscreen,X as autosetFontSize,q as dataUrlSvgWithColor,K as getCurrentSubscreen,H as getRelativeHeight,I as getRelativeWidth,D as getRelativeX,W as getRelativeY,Z as hookSubscreen,A as setFontFamily,G as setFontSize,O as setPadding,j as setPosition,U 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.2",
3
+ "version": "1.1.4",
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": {