zois-core 1.0.5 → 1.0.6

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/README.md CHANGED
@@ -1,19 +1,2 @@
1
- ⠀⠀⠀⠀⠀⢀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
2
- ⠀⠀⠀⠀⠀⡟⠈⠛⢦⣄⠀⠀⠀⠀⠀⣀⡴⠚⠩⠘⡇⠀⠀
3
- ⠀⠀⠀⠀⠀⣧⠀⡀⠄⠈⠛⠛⠛⠛⢛⠁⠌⠀⠀⠀⡇⠀⠀
4
- ⠀⠀⠀⠀⠀⣿⠞⠁⠀⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣧
5
- ⠀⠀⠀⠀⣼⠃⢠⠤⢤⠀⠀⠀⠀⢀⡤⢤⡀⠀⠀⠀⠘⣧
6
- ⠀⢀⣤⣤⣧⡄⠀⠀⠀⠀⣤⡀⠀⠀⠀⠀⠁⣤⣤⣤⣤⣼⣦⡄
7
- ⠀⢀⣠⡤⣷⠶⠀⠀⠀⠦⠜⠤⠄⠀⠀⠀⠰⠦⣤⣄⣀⣸⠃
8
- ⠀⠀⠀⠀⠘⢧⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣽⣋⠁
9
- ⠀⠀⠀⠀⠀⠀⠈⠙⢳⡶⠶⠶⠶⠶⠶⠶⠖⠛⠛⠍⠀⠉⠛
10
- ⠀⠀⠀⠀⠀⠀⠀⢠⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⣦⡀
11
- ⠀⠀⠀⠀⠀⠀⠀⣾⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀
12
- ⠀⠀⠀⠀⠀⠀⠀⣏⠀⠀⠀⠀⢠⠆⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⡇
13
- ⠀⠀⠀⠀⠀⠀⠀⢻⡀⠀⠀⠀⣿⠀⠀⠀⠀⢠⡾⠋⠁⠀⠀⠀⠀⠀⠀⢸⡇
14
- ⠀⠀⠀⠀⠀⠀⠀⠈⢷⡀⠀⠀⣿⠀⠀⠀⠀⣿⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⠃
15
- ⠀⠀⠀⠀⠀⠀⠀⠀⠈⢧⣀⣠⣼⣧⣀⣀⣰⣟⡀⠀⠀⠀⠀⠀⢀⣀⣼⢿⡀
16
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣟⠁⠀⠉⠉⠉⠉⠙⠛⠛⠛⠻⠿⠛⠛⠉⠁⣼⠁
17
- ⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢦⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⣤⡴⠞⠁
18
-
19
- ## 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
+ ![Typing SVG](https://readme-typing-svg.herokuapp.com/?lines=Shush+from+here)
package/dist/styles.css CHANGED
@@ -74,6 +74,25 @@
74
74
  border: 2px solid var(--tmd-accent, black);
75
75
  border-radius: 4px;
76
76
  }
77
+ .zcTabs {
78
+ display: flex;
79
+ }
80
+ .zcTabs button {
81
+ cursor: pointer;
82
+ width: 100%;
83
+ color: var(--tmd-text, black);
84
+ background: none;
85
+ border: none;
86
+ border-bottom: 2px solid var(--tmd-element, rgb(214, 214, 214));
87
+ }
88
+ .zcTabs button[data-opened=true] {
89
+ font-weight: bold;
90
+ border-bottom: 2px solid var(--tmd-accent, rgb(81, 81, 231)) !important;
91
+ }
92
+ .zcTabs button:hover {
93
+ background: var(--tmd-element, rgb(235, 235, 235));
94
+ border-bottom: 2px solid var(--tmd-element-hover, rgb(149, 149, 149));
95
+ }
77
96
  .zcDisabled {
78
97
  pointer-events: none;
79
98
  opacity: 0.6;
package/dist/ui.d.ts CHANGED
@@ -22,7 +22,7 @@ interface CreateButtonArgs {
22
22
  }
23
23
  interface CreateTextArgs {
24
24
  text?: string;
25
- color?: "string";
25
+ color?: string;
26
26
  x?: number;
27
27
  y?: number;
28
28
  fontSize?: number | "auto";
@@ -102,6 +102,17 @@ interface CreateBackNextButtonArgs {
102
102
  onChange?: (value: any) => void;
103
103
  isDisabled?: () => boolean;
104
104
  }
105
+ interface CreateTabArgs {
106
+ x: number;
107
+ y: number;
108
+ width: number;
109
+ tabs: {
110
+ name: string;
111
+ load: () => void;
112
+ }[];
113
+ currentTabName: string;
114
+ anchor?: Anchor;
115
+ }
105
116
  export declare function setPreviousSubscreen(): void;
106
117
  export declare function setSubscreen(subscreen: BaseSubscreen | null): void;
107
118
  export declare function getCurrentSubscreen(): BaseSubscreen;
@@ -121,11 +132,12 @@ export declare abstract class BaseSubscreen {
121
132
  createButton({ text, x, y, width, height, fontSize, anchor, padding, style, place, icon, iconAbsolutePosition, iconWidth, tooltip, onClick, isDisabled }: CreateButtonArgs): HTMLButtonElement;
122
133
  createText({ text, color, x, y, width, height, withBackground, fontSize, anchor, padding, place }: CreateTextArgs): HTMLParagraphElement;
123
134
  createInput({ value, placeholder, x, y, width, height, textArea, fontSize, anchor, padding, place, onChange, onInput, isDisabled }: CreateInputArgs): HTMLInputElement | HTMLTextAreaElement;
124
- createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLInputElement;
135
+ createCheckbox({ text, x, y, isChecked, width, anchor, place, isDisabled, onChange }: CreateCheckboxArgs): HTMLDivElement;
125
136
  createScrollView({ scroll, x, y, width, height, anchor }: CreateScrollViewArgs): HTMLDivElement;
126
137
  createInputList({ x, y, width, height, title, value, anchor, place, numbersOnly, isDisabled, onChange }: CreateInputListArgs): HTMLDivElement;
127
138
  createImage({ x, y, width, src, }: CreateImageArgs): HTMLImageElement;
128
139
  createBackNextButton({ x, y, width, height, items, currentIndex, isBold, onChange, isDisabled }: CreateBackNextButtonArgs): HTMLDivElement;
140
+ createTabs({ x, y, width, tabs, anchor, currentTabName }: CreateTabArgs): HTMLDivElement;
129
141
  }
130
142
  export declare function hookSubscreen(subscreenName: string, hook: (subscreen: BaseSubscreen) => void): void;
131
143
  export {};
package/dist/ui.js CHANGED
@@ -65,6 +65,14 @@ function loadSubscreen(subscreen) {
65
65
  height: 90,
66
66
  icon: "Icons/Exit.png"
67
67
  }).addEventListener("click", () => subscreen.exit());
68
+ if (subscreen.name) {
69
+ subscreen.createText({
70
+ text: subscreen.name,
71
+ x: 100,
72
+ y: 60,
73
+ fontSize: 10
74
+ });
75
+ }
68
76
  subscreen.load();
69
77
  if (subscreenHooks[subscreen.name]) {
70
78
  subscreenHooks[subscreen.name].forEach((hook) => hook(subscreen));
@@ -280,19 +288,22 @@ class BaseSubscreen {
280
288
  isDisabled,
281
289
  onChange
282
290
  }) {
283
- const checkbox = document.createElement("input");
284
- checkbox.type = "checkbox";
285
- checkbox.checked = isChecked;
286
- checkbox.classList.add("zcCheckbox", "checkbox");
291
+ const checkbox = document.createElement("div");
292
+ checkbox.style.display = "flex";
293
+ checkbox.style.alignItems = "center";
294
+ checkbox.style.columnGap = "1vw";
295
+ const input = document.createElement("input");
296
+ input.type = "checkbox";
297
+ input.checked = isChecked;
298
+ input.style.borderRadius = "min(0.8dvh, 0.3dvw)";
299
+ input.classList.add("zcCheckbox", "checkbox");
287
300
  const p = document.createElement("p");
288
301
  p.textContent = text;
289
302
  p.style.color = "var(--tmd-text, black)";
290
303
  setFontFamily(p, MOD_DATA.fontFamily);
291
304
  const setProperties = () => {
292
305
  if (typeof x === "number" && typeof y === "number") setPosition(checkbox, x, y, anchor);
293
- setPosition(p, x + 100, y, anchor);
294
- setSize(checkbox, 65, 65);
295
- if (width) setSize(p, width, null);
306
+ if (width) checkbox.style.width = getRelativeWidth(width) + "px";
296
307
  setFontSize(p, 5);
297
308
  };
298
309
  setProperties();
@@ -302,7 +313,8 @@ class BaseSubscreen {
302
313
  if (typeof onChange === "function") onChange();
303
314
  });
304
315
  window.addEventListener("resize", setProperties);
305
- if (place) document.body.append(checkbox, p);
316
+ checkbox.append(input, p);
317
+ if (place) document.body.append(checkbox);
306
318
  this.resizeEventListeners.push(setProperties);
307
319
  this.htmlElements.push(checkbox, p);
308
320
  return checkbox;
@@ -502,6 +514,54 @@ class BaseSubscreen {
502
514
  this.htmlElements.push(div);
503
515
  return div;
504
516
  }
517
+ createTabs({
518
+ x,
519
+ y,
520
+ width,
521
+ tabs,
522
+ anchor = "top-left",
523
+ currentTabName
524
+ }) {
525
+ let tabElements = [];
526
+ const tabsEl = document.createElement("div");
527
+ tabsEl.classList.add("zcTabs");
528
+ setFontFamily(tabsEl, MOD_DATA.fontFamily);
529
+ tabs.forEach((tab) => {
530
+ const switchTab = () => {
531
+ for (const c of tabsEl.children) {
532
+ c.removeAttribute("data-opened");
533
+ }
534
+ for (const c of tabElements) {
535
+ if (c instanceof Node) document.body.removeChild(c);
536
+ }
537
+ tabElements = [];
538
+ tabEl.setAttribute("data-opened", "true");
539
+ const originalAppend = document.body.append.bind(document.body);
540
+ document.body.append = (...nodes) => {
541
+ tabElements.push(...nodes);
542
+ originalAppend(...nodes);
543
+ };
544
+ tab.load();
545
+ document.body.append = originalAppend;
546
+ };
547
+ const tabEl = document.createElement("button");
548
+ tabEl.textContent = tab.name;
549
+ if (tab.name === currentTabName) switchTab();
550
+ tabEl.addEventListener("click", switchTab);
551
+ tabsEl.append(tabEl);
552
+ });
553
+ const setProperties = () => {
554
+ if (typeof x === "number" && typeof y === "number") setPosition(tabsEl, x, y, anchor);
555
+ setSize(tabsEl, width, 80);
556
+ autosetFontSize(tabsEl);
557
+ };
558
+ setProperties();
559
+ window.addEventListener("resize", setProperties);
560
+ document.body.append(tabsEl);
561
+ this.resizeEventListeners.push(setProperties);
562
+ this.htmlElements.push(tabsEl);
563
+ return tabsEl;
564
+ }
505
565
  }
506
566
  let subscreenHooks = {};
507
567
  function hookSubscreen(subscreenName, hook) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "zois-core",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
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",