zois-core 2.2.0 → 3.0.0

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.
Files changed (158) hide show
  1. package/dist/assets/icons/toast-themes/abdl/bottle.svg +10 -0
  2. package/dist/assets/icons/toast-themes/abdl/diaper.svg +11 -0
  3. package/dist/assets/icons/toast-themes/abdl/heart.svg +7 -0
  4. package/dist/assets/icons/toast-themes/abdl/sparkle.svg +5 -0
  5. package/dist/assets/icons/toast-themes/abdl/star.svg +5 -0
  6. package/dist/assets/icons/toast-themes/abdl/teddy.svg +18 -0
  7. package/dist/assets/icons/toast-themes/anime/error.svg +20 -0
  8. package/dist/assets/icons/toast-themes/anime/info.svg +20 -0
  9. package/dist/assets/icons/toast-themes/anime/success.svg +16 -0
  10. package/dist/assets/icons/toast-themes/anime/warning.svg +19 -0
  11. package/dist/changelogs.js +628 -295
  12. package/dist/cssVars.js +46 -0
  13. package/dist/dialogs.js +523 -83
  14. package/dist/events.js +28 -6
  15. package/dist/index.js +27 -70
  16. package/dist/localization.js +250 -40
  17. package/dist/messaging.js +1 -1
  18. package/dist/migration.js +37 -0
  19. package/dist/modules/baseModule.js +110 -0
  20. package/dist/modules/index.js +4 -0
  21. package/dist/modules/loadingStrategy.js +20 -0
  22. package/dist/modules/moduleContext.js +56 -0
  23. package/dist/modules/modulesManager.js +175 -0
  24. package/dist/{modSdk.js → patching.js} +33 -9
  25. package/dist/rpc.js +139 -0
  26. package/dist/scripts/zois-core.js +18 -0
  27. package/dist/settings.js +90 -0
  28. package/dist/settingsDialog.js +1361 -0
  29. package/dist/shard-modules/{attributesModule.js → attributes.js} +2 -2
  30. package/dist/shard-modules/{shardModule.js → base.js} +2 -2
  31. package/dist/shard-modules/{centerModule.js → center.js} +4 -2
  32. package/dist/shard-modules/{clickModule.js → click.js} +2 -2
  33. package/dist/shard-modules/{counterUpModule.js → counterUp.js} +2 -2
  34. package/dist/shard-modules/{dynamicClassModule.js → dynamicClass.js} +2 -2
  35. package/dist/shard-modules/index.js +9 -9
  36. package/dist/shard-modules/{multiClickModule.js → multiClick.js} +2 -2
  37. package/dist/shard-modules/{styleModule.js → style.js} +2 -2
  38. package/dist/shard-modules/{typeModule.js → type.js} +2 -2
  39. package/dist/shards/backNextButton.js +173 -0
  40. package/dist/shards/{shard.js → base.js} +15 -15
  41. package/dist/shards/{buttonShard.js → button.js} +30 -52
  42. package/dist/shards/{cardShard.js → card.js} +4 -4
  43. package/dist/shards/{checkboxShard.js → checkbox.js} +6 -13
  44. package/dist/shards/{containerShard.js → container.js} +2 -2
  45. package/dist/shards/extensionsStorageBar.js +377 -0
  46. package/dist/shards/fileInput.js +180 -0
  47. package/dist/shards/flexContainer.js +30 -0
  48. package/dist/shards/gridContainer.js +34 -0
  49. package/dist/shards/{imageShard.js → image.js} +8 -6
  50. package/dist/shards/index.js +17 -13
  51. package/dist/shards/{inputShard.js → input.js} +4 -4
  52. package/dist/shards/{inputListShard.js → inputList.js} +22 -4
  53. package/dist/shards/select.js +201 -0
  54. package/dist/shards/svg.js +28 -0
  55. package/dist/shards/{tabsShard.js → tabs.js} +18 -19
  56. package/dist/shards/{textShard.js → text.js} +4 -4
  57. package/dist/shared.js +215 -0
  58. package/dist/styles.css +0 -51
  59. package/dist/subscreens/customTranslations.js +239 -0
  60. package/dist/subscreens/languageDetails.js +194 -0
  61. package/dist/subscreens/localization.js +115 -0
  62. package/dist/toast-themes/abdl.js +419 -0
  63. package/dist/toast-themes/anime.js +483 -0
  64. package/dist/toast-themes/base.js +40 -0
  65. package/dist/toast-themes/cyber.js +538 -0
  66. package/dist/toast-themes/default.js +282 -0
  67. package/dist/toastThemesDialog.js +274 -0
  68. package/dist/toasts.js +195 -174
  69. package/dist/types/cssVars.d.ts +1 -0
  70. package/dist/types/dialogs.d.ts +46 -18
  71. package/dist/types/events.d.ts +11 -2
  72. package/dist/types/global.d.ts +4 -3
  73. package/dist/types/index.d.ts +12 -19
  74. package/dist/types/localization.d.ts +25 -3
  75. package/dist/types/migration.d.ts +6 -0
  76. package/dist/types/modules/baseModule.d.ts +108 -0
  77. package/dist/types/modules/index.d.ts +4 -0
  78. package/dist/types/modules/loadingStrategy.d.ts +7 -0
  79. package/dist/types/modules/moduleContext.d.ts +9 -0
  80. package/dist/types/modules/modulesManager.d.ts +23 -0
  81. package/dist/types/{modSdk.d.ts → patching.d.ts} +2 -3
  82. package/dist/types/rpc.d.ts +72 -0
  83. package/dist/types/settings.d.ts +19 -0
  84. package/dist/types/settingsDialog.d.ts +4 -0
  85. package/dist/types/shard-modules/{attributesModule.d.ts → attributes.d.ts} +2 -2
  86. package/dist/types/shard-modules/{shardModule.d.ts → base.d.ts} +2 -2
  87. package/dist/types/shard-modules/{centerModule.d.ts → center.d.ts} +2 -1
  88. package/dist/types/shard-modules/{clickModule.d.ts → click.d.ts} +2 -2
  89. package/dist/types/shard-modules/{counterUpModule.d.ts → counterUp.d.ts} +2 -2
  90. package/dist/types/shard-modules/{dynamicClassModule.d.ts → dynamicClass.d.ts} +2 -2
  91. package/dist/types/shard-modules/index.d.ts +9 -9
  92. package/dist/types/shard-modules/{multiClickModule.d.ts → multiClick.d.ts} +2 -2
  93. package/dist/types/shard-modules/{styleModule.d.ts → style.d.ts} +2 -2
  94. package/dist/types/shard-modules/{typeModule.d.ts → type.d.ts} +2 -2
  95. package/dist/types/shards/{backNextButtonShard.d.ts → backNextButton.d.ts} +4 -3
  96. package/dist/types/shards/{shard.d.ts → base.d.ts} +3 -2
  97. package/dist/types/shards/{buttonShard.d.ts → button.d.ts} +6 -6
  98. package/dist/types/shards/{cardShard.d.ts → card.d.ts} +3 -3
  99. package/dist/types/shards/{checkboxShard.d.ts → checkbox.d.ts} +5 -5
  100. package/dist/types/shards/{containerShard.d.ts → container.d.ts} +2 -2
  101. package/dist/types/shards/extensionsStorageBar.d.ts +28 -0
  102. package/dist/types/shards/fileInput.d.ts +10 -0
  103. package/dist/types/shards/flexContainer.d.ts +14 -0
  104. package/dist/types/shards/gridContainer.d.ts +18 -0
  105. package/dist/types/shards/{imageShard.d.ts → image.d.ts} +2 -2
  106. package/dist/types/shards/index.d.ts +17 -13
  107. package/dist/types/shards/{inputShard.d.ts → input.d.ts} +3 -3
  108. package/dist/types/shards/{inputListShard.d.ts → inputList.d.ts} +3 -2
  109. package/dist/types/shards/{selectShard.d.ts → select.d.ts} +6 -4
  110. package/dist/types/shards/svg.d.ts +11 -0
  111. package/dist/types/shards/{tabsShard.d.ts → tabs.d.ts} +3 -6
  112. package/dist/types/shards/{textShard.d.ts → text.d.ts} +3 -3
  113. package/dist/types/shared.d.ts +7 -0
  114. package/dist/types/subscreens/customTranslations.d.ts +10 -0
  115. package/dist/types/subscreens/languageDetails.d.ts +14 -0
  116. package/dist/types/subscreens/localization.d.ts +5 -0
  117. package/dist/types/toast-themes/abdl.d.ts +9 -0
  118. package/dist/types/toast-themes/anime.d.ts +9 -0
  119. package/dist/types/toast-themes/base.d.ts +39 -0
  120. package/dist/types/toast-themes/cyber.d.ts +10 -0
  121. package/dist/types/toast-themes/default.d.ts +9 -0
  122. package/dist/types/toastThemesDialog.d.ts +1 -0
  123. package/dist/types/toasts.d.ts +48 -36
  124. package/dist/types/ui.d.ts +128 -49
  125. package/dist/types/validation.d.ts +5 -0
  126. package/dist/ui.js +414 -79
  127. package/dist/validation.js +79 -1
  128. package/dist/wardrobe.js +2 -2
  129. package/package.json +37 -15
  130. package/dist/core-subscreen/coreSubscreen.js +0 -81
  131. package/dist/core-subscreen/developmentSubscreen.js +0 -22
  132. package/dist/core-subscreen/generalSubscreen.js +0 -23
  133. package/dist/core-subscreen/mainSubscreen.js +0 -58
  134. package/dist/core-subscreen/shards/coreButtonShard.js +0 -30
  135. package/dist/core-subscreen/shards/coreCheckboxShard.js +0 -33
  136. package/dist/core-subscreen/shards/coreInputListShard.js +0 -38
  137. package/dist/core-subscreen/shards/coreSelectShard.js +0 -17
  138. package/dist/core-subscreen/shards/coreTextShard.js +0 -9
  139. package/dist/core-subscreen/shards/index.js +0 -5
  140. package/dist/core-subscreen/toastsSubscreen.js +0 -111
  141. package/dist/core.js +0 -192
  142. package/dist/shards/backNextButtonShard.js +0 -99
  143. package/dist/shards/selectShard.js +0 -131
  144. package/dist/shards/svgShard.js +0 -29
  145. package/dist/types/core-subscreen/coreSubscreen.d.ts +0 -15
  146. package/dist/types/core-subscreen/developmentSubscreen.d.ts +0 -5
  147. package/dist/types/core-subscreen/generalSubscreen.d.ts +0 -5
  148. package/dist/types/core-subscreen/mainSubscreen.d.ts +0 -6
  149. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +0 -5
  150. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +0 -6
  151. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +0 -6
  152. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +0 -5
  153. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +0 -4
  154. package/dist/types/core-subscreen/shards/index.d.ts +0 -5
  155. package/dist/types/core-subscreen/toastsSubscreen.d.ts +0 -5
  156. package/dist/types/core.d.ts +0 -18
  157. package/dist/types/shards/svgShard.d.ts +0 -12
  158. package/scripts/zois-core.mjs +0 -184
@@ -1,11 +1,11 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  class AttributesModule extends ShardModule {
3
3
  constructor(attributes) {
4
4
  super();
5
5
  this.attributes = attributes;
6
6
  }
7
7
  attributes;
8
- layoutEffect(context, target) {
8
+ beforeMount(context, target) {
9
9
  for (const attributeProperty of Object.keys(this.attributes)) {
10
10
  target.setAttribute(attributeProperty, this.attributes[attributeProperty]);
11
11
  }
@@ -2,9 +2,9 @@ class ShardModule {
2
2
  overrideContext(context, target) {
3
3
  return context;
4
4
  }
5
- layoutEffect(context, target) {
5
+ beforeMount(context, target) {
6
6
  }
7
- effect(context, target) {
7
+ onMount(context, target) {
8
8
  }
9
9
  }
10
10
  export {
@@ -1,11 +1,13 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  class CenterModule extends ShardModule {
3
3
  overrideContext(context, target) {
4
- target.style.transform = "translate(-50%, -50%)";
5
4
  context.x = 1e3;
6
5
  context.y = 500;
7
6
  return context;
8
7
  }
8
+ beforeMount(context, target) {
9
+ target.style.transform = "translate(-50%, -50%)";
10
+ }
9
11
  }
10
12
  export {
11
13
  CenterModule
@@ -1,11 +1,11 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  class ClickModule extends ShardModule {
3
3
  constructor(callback) {
4
4
  super();
5
5
  this.callback = callback;
6
6
  }
7
7
  callback;
8
- layoutEffect(context, target) {
8
+ beforeMount(context, target) {
9
9
  target.addEventListener("click", () => this.callback(target));
10
10
  }
11
11
  }
@@ -1,4 +1,4 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  function countUp(element, endValue, duration, formattingFunction) {
3
3
  if (!element) {
4
4
  throw new Error("Element not found");
@@ -28,7 +28,7 @@ class CounterUpModule extends ShardModule {
28
28
  this.props = props;
29
29
  }
30
30
  props;
31
- effect(context, target) {
31
+ onMount(context, target) {
32
32
  countUp(target, this.props.endValue, this.props.duration, this.props.formattingFunction);
33
33
  }
34
34
  }
@@ -1,12 +1,12 @@
1
1
  import { addDynamicClass } from "../ui";
2
- import { ShardModule } from "./shardModule";
2
+ import { ShardModule } from "./base";
3
3
  class DynamicClassModule extends ShardModule {
4
4
  constructor(style) {
5
5
  super();
6
6
  this.style = style;
7
7
  }
8
8
  style;
9
- layoutEffect(context, target) {
9
+ beforeMount(context, target) {
10
10
  addDynamicClass(target, this.style);
11
11
  }
12
12
  }
@@ -1,9 +1,9 @@
1
- export * from "./shardModule";
2
- export * from "./centerModule";
3
- export * from "./counterUpModule";
4
- export * from "./typeModule";
5
- export * from "./styleModule";
6
- export * from "./dynamicClassModule";
7
- export * from "./attributesModule";
8
- export * from "./clickModule";
9
- export * from "./multiClickModule";
1
+ export * from "./base";
2
+ export * from "./center";
3
+ export * from "./counterUp";
4
+ export * from "./type";
5
+ export * from "./style";
6
+ export * from "./dynamicClass";
7
+ export * from "./attributes";
8
+ export * from "./click";
9
+ export * from "./multiClick";
@@ -1,4 +1,4 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  function addMultiClickListener(element, n, callback, timeout = 400) {
3
3
  let clickCount = 0;
4
4
  let timer = null;
@@ -32,7 +32,7 @@ class MultiClickModule extends ShardModule {
32
32
  this.props = props;
33
33
  }
34
34
  props;
35
- effect(context, target) {
35
+ onMount(context, target) {
36
36
  addMultiClickListener(target, this.props.n, this.props.callback);
37
37
  }
38
38
  }
@@ -1,4 +1,4 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  class StyleModule extends ShardModule {
3
3
  constructor(style) {
4
4
  super();
@@ -11,7 +11,7 @@ class StyleModule extends ShardModule {
11
11
  target.style[styleProperty] = style[styleProperty];
12
12
  }
13
13
  }
14
- layoutEffect(context, target) {
14
+ beforeMount(context, target) {
15
15
  this.applyStyle(target, this.style);
16
16
  }
17
17
  }
@@ -1,4 +1,4 @@
1
- import { ShardModule } from "./shardModule";
1
+ import { ShardModule } from "./base";
2
2
  function type(element, duration) {
3
3
  if (!element) {
4
4
  throw new Error("Element not found");
@@ -28,7 +28,7 @@ class TypeModule extends ShardModule {
28
28
  this.props = props;
29
29
  }
30
30
  props;
31
- effect(context, target) {
31
+ onMount(context, target) {
32
32
  type(target, this.props.duration);
33
33
  }
34
34
  }
@@ -0,0 +1,173 @@
1
+ import { MOD_DATA } from "..";
2
+ import { addDynamicClass, autosetFontSize, createTooltip, setFontFamily } from "../ui";
3
+ import { Shard } from "./base";
4
+ class BackNextButtonShard extends Shard {
5
+ get dynamicClassContainer() {
6
+ return {
7
+ base: {
8
+ display: "flex",
9
+ columnGap: "0.5em",
10
+ justifyContent: "center",
11
+ alignItems: "center",
12
+ color: "var(--tmd-text, black)"
13
+ }
14
+ };
15
+ }
16
+ get dynamicClassButton() {
17
+ return {
18
+ base: {
19
+ cursor: "pointer",
20
+ background: "var(--tmd-element, white)",
21
+ color: "var(--tmd-text, black)",
22
+ border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
23
+ borderRadius: "6px"
24
+ },
25
+ hover: {
26
+ background: "var(--tmd-element-hover, #ebf7fe)",
27
+ borderColor: "var(--tmd-accent-hover, #7dd3fc)",
28
+ color: "var(--tmd-accent-hover, #015a8c)"
29
+ },
30
+ disabled: {
31
+ background: "var(--tmd-element-disabled, #ffa590)",
32
+ pointerEvents: "none"
33
+ }
34
+ };
35
+ }
36
+ get dynamicClassValueContainer() {
37
+ return {
38
+ base: {
39
+ position: "relative",
40
+ display: "grid",
41
+ placeItems: "center",
42
+ background: "var(--tmd-element, white)",
43
+ width: "100%",
44
+ height: "100%",
45
+ borderRadius: "4px",
46
+ overflow: "hidden",
47
+ border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
48
+ boxSizing: "border-box"
49
+ }
50
+ };
51
+ }
52
+ render() {
53
+ const { onChange, isDisabled } = this.context;
54
+ const div = document.createElement("div");
55
+ addDynamicClass(div, this.dynamicClassContainer);
56
+ setFontFamily(div, MOD_DATA.fontFamily);
57
+ let currentIndex = this.context.currentIndex;
58
+ let items = this.context.items;
59
+ let isAnimating = false;
60
+ const updateClasses = () => {
61
+ if (currentIndex === 0 || typeof isDisabled === "function" && isDisabled(items[currentIndex - 1][1])) backBtn.disabled = true;
62
+ else backBtn.disabled = false;
63
+ if (currentIndex === items.length - 1 || typeof isDisabled === "function" && isDisabled(items[currentIndex + 1][1])) nextBtn.disabled = true;
64
+ else nextBtn.disabled = false;
65
+ };
66
+ const slideText = (direction, newIndex) => {
67
+ if (isAnimating) return;
68
+ isAnimating = true;
69
+ currentIndex = newIndex;
70
+ if (typeof onChange === "function") onChange(items[currentIndex][1]);
71
+ updateClasses();
72
+ const outgoing = text;
73
+ const incoming = document.createElement("b");
74
+ incoming.style.cssText = `
75
+ position: absolute;
76
+ inset: 0;
77
+ display: grid;
78
+ place-items: center;
79
+ width: 100%;
80
+ text-align: center;
81
+ margin: 0;
82
+ user-select: none;
83
+ `;
84
+ incoming.textContent = items[currentIndex][0];
85
+ const fromX = direction === "next" ? "100%" : "-100%";
86
+ const toX = direction === "next" ? "-100%" : "100%";
87
+ incoming.style.transform = `translateX(${fromX})`;
88
+ valueContainer.appendChild(incoming);
89
+ void incoming.offsetWidth;
90
+ outgoing.style.transition = "transform 0.35s cubic-bezier(0.4, 0, 0.2, 1)";
91
+ incoming.style.transition = "transform 0.35s cubic-bezier(0.4, 0, 0.2, 1)";
92
+ outgoing.style.transform = `translateX(${toX})`;
93
+ incoming.style.transform = "translateX(0)";
94
+ const onEnd = () => {
95
+ incoming.removeEventListener("transitionend", onEnd);
96
+ outgoing.remove();
97
+ text = incoming;
98
+ text.style.position = "relative";
99
+ text.style.inset = "auto";
100
+ text.style.transform = "";
101
+ text.style.transition = "";
102
+ isAnimating = false;
103
+ };
104
+ incoming.addEventListener("transitionend", onEnd, { once: true });
105
+ };
106
+ const backBtn = document.createElement("button");
107
+ backBtn.style.cssText = `
108
+ font-size: 3.5vw; aspect-ratio: 1/1;
109
+ height: 100%; background-image: url("Icons/Prev.png"); background-size: 100%;
110
+ `;
111
+ addDynamicClass(backBtn, this.dynamicClassButton);
112
+ createTooltip(backBtn, () => {
113
+ return [
114
+ {
115
+ text: this.context.items[currentIndex - 1]?.[0] ?? "-"
116
+ }
117
+ ];
118
+ });
119
+ backBtn.addEventListener("click", () => {
120
+ if (isAnimating) return;
121
+ if (currentIndex === 0) return;
122
+ if (typeof isDisabled === "function" && isDisabled(items[currentIndex - 1][1])) return;
123
+ slideText("back", currentIndex - 1);
124
+ });
125
+ const nextBtn = document.createElement("button");
126
+ nextBtn.style.cssText = `
127
+ font-size: 3.5vw; aspect-ratio: 1/1;
128
+ height: 100%; background-image: url("Icons/Next.png"); background-size: 100%;
129
+ `;
130
+ addDynamicClass(nextBtn, this.dynamicClassButton);
131
+ createTooltip(nextBtn, () => {
132
+ return [
133
+ {
134
+ text: this.context.items[currentIndex + 1]?.[0] ?? "-"
135
+ }
136
+ ];
137
+ });
138
+ nextBtn.addEventListener("click", () => {
139
+ if (isAnimating) return;
140
+ if (currentIndex === items.length - 1) return;
141
+ if (typeof isDisabled === "function" && isDisabled(items[currentIndex + 1][1])) return;
142
+ slideText("next", currentIndex + 1);
143
+ });
144
+ updateClasses();
145
+ const valueContainer = document.createElement("div");
146
+ addDynamicClass(valueContainer, this.dynamicClassValueContainer);
147
+ let text = document.createElement("b");
148
+ text.style.cssText = `
149
+ position: relative;
150
+ width: 100%;
151
+ text-align: center;
152
+ display: grid;
153
+ place-items: center;
154
+ user-select: none;
155
+ `;
156
+ text.textContent = items[currentIndex][0];
157
+ valueContainer.append(text);
158
+ div.append(backBtn, valueContainer, nextBtn);
159
+ return {
160
+ base: div,
161
+ backButton: backBtn,
162
+ nextButton: nextBtn,
163
+ text
164
+ };
165
+ }
166
+ setContextStyles() {
167
+ super.setContextStyles();
168
+ autosetFontSize(this.body.base);
169
+ }
170
+ }
171
+ export {
172
+ BackNextButtonShard
173
+ };
@@ -5,9 +5,8 @@ import { setPosition, setPadding, getRelativeWidth, getRelativeHeight } from "..
5
5
  class Shard {
6
6
  constructor(context) {
7
7
  this.context = context;
8
- this.body = this.generateBody();
8
+ this.body = this.render();
9
9
  this.processModules("overrideContext");
10
- this.processModules("layoutEffect");
11
10
  }
12
11
  context;
13
12
  body = null;
@@ -15,21 +14,22 @@ class Shard {
15
14
  return this.body?.base ?? null;
16
15
  }
17
16
  mount(parentElement = this.context.parent ?? document.body) {
17
+ this.processModules("layoutEffect");
18
18
  parentElement.append(this.body.base);
19
- this.update();
19
+ this.setContextStyles();
20
20
  this.processModules("effect");
21
+ eventBus?.once("subscreenUnloaded", this.unmount.bind(this));
21
22
  eventBus?.emit("shardMounted", {
22
23
  shard: this
23
24
  });
24
- window.addEventListener("resize", () => this.update());
25
- eventBus?.once("subscreenUnloaded", () => {
26
- this.body.base.remove();
27
- eventBus?.emit("shardUnmounted", {
28
- shard: this
29
- });
30
- });
31
25
  return this.mountReturnValue;
32
26
  }
27
+ unmount() {
28
+ this.body.base.remove();
29
+ eventBus?.emit("shardUnmounted", {
30
+ shard: this
31
+ });
32
+ }
33
33
  processModules(stage) {
34
34
  const modules = this.context.modules ?? {};
35
35
  if (stage === "overrideContext") {
@@ -53,7 +53,7 @@ class Shard {
53
53
  if (module instanceof ShardModule) {
54
54
  if (this.body?.[key]) {
55
55
  try {
56
- module.layoutEffect(this.context, this.body[key]);
56
+ module.beforeMount(this.context, this.body[key]);
57
57
  } catch (e) {
58
58
  logger.error("LayoutEffect call failed in", module, e);
59
59
  }
@@ -68,7 +68,7 @@ class Shard {
68
68
  if (module instanceof ShardModule) {
69
69
  if (this.body?.[key]) {
70
70
  try {
71
- module.effect(this.context, this.body[key]);
71
+ module.onMount(this.context, this.body[key]);
72
72
  } catch (e) {
73
73
  logger.error("Effect call failed in", module, e);
74
74
  }
@@ -78,12 +78,12 @@ class Shard {
78
78
  }
79
79
  }
80
80
  }
81
- update() {
81
+ setContextStyles() {
82
82
  const { x, y, anchor, padding, width, height } = this.context;
83
83
  if (typeof x === "number" && typeof y === "number") setPosition(this.body.base, x, y, anchor);
84
84
  if (padding) setPadding(this.body.base, padding);
85
- if (width) this.body.base.style.width = getRelativeWidth(width) + "px";
86
- if (height) this.body.base.style.height = getRelativeHeight(height) + "px";
85
+ if (width) this.body.base.style.width = getRelativeWidth(width);
86
+ if (height) this.body.base.style.height = getRelativeHeight(height);
87
87
  }
88
88
  }
89
89
  export {
@@ -1,51 +1,46 @@
1
1
  import { createElement, ExternalLink } from "lucide";
2
2
  import { MOD_DATA } from "../index";
3
- import { addDynamicClass, autosetFontSize, setFontFamily, setFontSize } from "../ui";
4
- import { Shard } from "./shard";
3
+ import { addDynamicClass, autosetFontSize, createTooltip, setFontFamily, setFontSize } from "../ui";
4
+ import { Shard } from "./base";
5
5
  class ButtonShard extends Shard {
6
6
  get dynamicClassButton() {
7
7
  return {
8
8
  base: {
9
9
  cursor: "pointer",
10
+ borderRadius: "min(1dvh, 0.5dvw)"
11
+ },
12
+ "[data-zc-variant=outlined]": {
10
13
  background: "var(--tmd-element, white)",
11
14
  color: "var(--tmd-text, black)",
12
- border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
13
- borderRadius: "6px"
15
+ border: "min(0.3dvh, 0.15dvw) solid var(--tmd-accent, rgb(34, 34, 34))"
14
16
  },
15
- hover: {
17
+ "[data-zc-variant=outlined]:hover": {
16
18
  background: "var(--tmd-element-hover, #ebf7fe)",
17
19
  borderColor: "var(--tmd-accent-hover, #7dd3fc)",
18
20
  color: "var(--tmd-accent-hover, #015a8c)"
19
21
  },
20
- "> .tooltip": {
21
- position: "absolute",
22
- color: "var(--tmd-text, black)",
23
- textAlign: "center",
24
- padding: "0.3em 0.6em",
25
- borderRadius: "4px",
26
- background: "var(--tmd-element-hint, #e6e6e6)",
27
- width: "max-content",
28
- visibility: "hidden",
29
- zIndex: "10"
30
- },
31
- "> .tooltip[position=left]": {
32
- right: "calc(100% + 1vw)"
33
- },
34
- "> .tooltip[position=right]": {
35
- left: "calc(100% + 1vw)"
36
- },
37
- ":hover .tooltip": {
38
- visibility: "visible"
39
- },
40
22
  "[data-zc-variant=filled]": {
41
23
  background: "var(--tmd-accent, #111)",
42
- border: "2px solid var(--tmd-accent, #111)",
24
+ border: "min(0.3dvh, 0.15dvw) solid var(--tmd-accent, #111)",
43
25
  color: "var(--tmd-text, white)"
44
26
  },
45
27
  "[data-zc-variant=filled]:hover": {
46
28
  background: "var(--tmd-accent-hover, none)",
47
29
  color: "var(--tmd-text, black)"
48
30
  },
31
+ "[data-zc-variant=playful]": {
32
+ background: "var(--tmd-element, white)",
33
+ color: "var(--tmd-text, black)",
34
+ boxShadow: "min(0.4dvh, 0.2dvw) min(0.4dvh, 0.2dvw) 0 var(--tmd-accent, rgb(34, 34, 34))",
35
+ border: "min(0.3dvh, 0.15dvw) solid var(--tmd-accent, rgb(34, 34, 34))",
36
+ fontWeight: "700",
37
+ transition: "transform 0.1s, box-shadow 0.1s"
38
+ },
39
+ "[data-zc-variant=playful]:hover": {
40
+ background: "var(--tmd-element-hover, #e4e4e4)",
41
+ transform: "translate(-1px, -1px)",
42
+ boxShadow: "min(0.6dvh, 0.3dvw) min(0.6dvh, 0.3dvw) 0 var(--tmd-accent, rgb(34, 34, 34))"
43
+ },
49
44
  "> .external-link-icon": {
50
45
  display: "flex",
51
46
  columnGap: "0.25em",
@@ -62,8 +57,8 @@ class ButtonShard extends Shard {
62
57
  }
63
58
  };
64
59
  }
65
- generateBody() {
66
- const { height, text, variant, icon, iconAbsolutePosition = true, tooltip, href, onClick, isDisabled } = this.context;
60
+ render() {
61
+ const { height, text, variant = "outlined", icon, iconAbsolutePosition = true, tooltip, href, onClick, isDisabled } = this.context;
67
62
  let iconElement;
68
63
  let textElement;
69
64
  const btn = document.createElement("button");
@@ -86,6 +81,7 @@ class ButtonShard extends Shard {
86
81
  if (text && iconAbsolutePosition) {
87
82
  iconElement.style.position = "absolute";
88
83
  iconElement.style.left = "1vw";
84
+ if (btn.style.position === "static" || btn.style.position === "") btn.style.position = "relative";
89
85
  }
90
86
  if (text && !iconAbsolutePosition) btn.style.justifyContent = "";
91
87
  btn.append(iconElement);
@@ -101,12 +97,9 @@ class ButtonShard extends Shard {
101
97
  }
102
98
  btn.append(textElement);
103
99
  }
100
+ const tooltipsRows = [];
104
101
  if (tooltip) {
105
- const tooltipEl = document.createElement("span");
106
- tooltipEl.classList.add("tooltip");
107
- tooltipEl.setAttribute("position", tooltip.position);
108
- tooltipEl.textContent = tooltip.text;
109
- btn.append(tooltipEl);
102
+ tooltipsRows.push(...tooltip);
110
103
  }
111
104
  if (href) {
112
105
  const externalLinkContainer = document.createElement("div");
@@ -116,24 +109,9 @@ class ButtonShard extends Shard {
116
109
  externalLinkIcon.style.height = "100%";
117
110
  externalLinkContainer.append(externalLinkIcon);
118
111
  btn.append(externalLinkContainer);
119
- let hrefTooltip = null;
120
- btn.addEventListener("mouseenter", () => {
121
- if (hrefTooltip) return;
122
- hrefTooltip = document.createElement("div");
123
- hrefTooltip.style.cssText = `position: fixed; top: 0; left: 0; right: 0; bottom: 0; margin: auto;
124
- width: fit-content; height: fit-content; font-size: calc(3.5px * var(--size-unit));
125
- z-index: 100; color: var(--tmd-text, black); background: var(--tmd-element, #f8f8f8); padding: 0.2em;
126
- border-radius: 4px; border: 1px solid var(--tmd-element-hover, #9f9f9f);`;
127
- setFontFamily(hrefTooltip, CommonGetFontName());
128
- hrefTooltip.textContent = href;
129
- document.body.append(hrefTooltip);
130
- });
131
- btn.addEventListener("mouseleave", () => {
132
- if (!hrefTooltip) return;
133
- hrefTooltip.remove();
134
- hrefTooltip = null;
135
- });
112
+ tooltipsRows.push({ icon: createElement(ExternalLink), text: href });
136
113
  }
114
+ if (tooltipsRows.length !== 0) createTooltip(btn, tooltipsRows);
137
115
  if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
138
116
  btn.addEventListener("click", () => {
139
117
  if (typeof isDisabled === "function" && isDisabled()) return btn.classList.add("zcDisabled");
@@ -146,8 +124,8 @@ class ButtonShard extends Shard {
146
124
  base: btn
147
125
  };
148
126
  }
149
- update() {
150
- super.update();
127
+ setContextStyles() {
128
+ super.setContextStyles();
151
129
  if ((this.context.fontSize ?? "auto") === "auto") autosetFontSize(this.body.base);
152
130
  else if (typeof this.context.fontSize === "number") setFontSize(this.body.base, this.context.fontSize);
153
131
  }
@@ -1,8 +1,8 @@
1
1
  import { MOD_DATA } from "../index";
2
2
  import { autosetFontSize, setFontFamily } from "../ui";
3
- import { Shard } from "./shard";
3
+ import { Shard } from "./base";
4
4
  class CardShard extends Shard {
5
- generateBody() {
5
+ render() {
6
6
  const { name, value, icon } = this.context;
7
7
  const cardEl = document.createElement("div");
8
8
  cardEl.classList.add("zcCard");
@@ -25,8 +25,8 @@ class CardShard extends Shard {
25
25
  icon
26
26
  };
27
27
  }
28
- update() {
29
- super.update();
28
+ setContextStyles() {
29
+ super.setContextStyles();
30
30
  autosetFontSize(this.body.base);
31
31
  }
32
32
  }
@@ -1,6 +1,6 @@
1
1
  import { MOD_DATA } from "../index";
2
- import { addDynamicClass, autosetFontSize, setFontFamily } from "../ui";
3
- import { Shard } from "./shard";
2
+ import { addDynamicClass, autosetFontSize, createTooltip, setFontFamily } from "../ui";
3
+ import { Shard } from "./base";
4
4
  class CheckboxShard extends Shard {
5
5
  get dynamicClassInput() {
6
6
  return {
@@ -101,7 +101,7 @@ class CheckboxShard extends Shard {
101
101
  get textColor() {
102
102
  return "var(--tmd-text, black)";
103
103
  }
104
- generateBody() {
104
+ render() {
105
105
  const { isChecked, text, tooltip, onChange, isDisabled } = this.context;
106
106
  const wrapper = document.createElement("div");
107
107
  wrapper.style.display = "flex";
@@ -142,22 +142,15 @@ class CheckboxShard extends Shard {
142
142
  }
143
143
  });
144
144
  wrapper.append(box, label);
145
- if (tooltip) {
146
- const tooltipEl = document.createElement("span");
147
- tooltipEl.classList.add("tooltip");
148
- tooltipEl.setAttribute("position", tooltip.position);
149
- tooltipEl.textContent = tooltip.text;
150
- addDynamicClass(tooltipEl, this.dynamicClassTooltip);
151
- box.appendChild(tooltipEl);
152
- }
145
+ if (tooltip) createTooltip(box, tooltip);
153
146
  return {
154
147
  base: wrapper,
155
148
  checkbox: input,
156
149
  label
157
150
  };
158
151
  }
159
- update() {
160
- super.update();
152
+ setContextStyles() {
153
+ super.setContextStyles();
161
154
  if (this.body?.base) {
162
155
  autosetFontSize(this.body.base);
163
156
  }
@@ -1,5 +1,5 @@
1
1
  import { addDynamicClass } from "../ui";
2
- import { Shard } from "./shard";
2
+ import { Shard } from "./base";
3
3
  class ContainerShard extends Shard {
4
4
  get dynamicClassContainer() {
5
5
  return {
@@ -15,7 +15,7 @@ class ContainerShard extends Shard {
15
15
  get mountReturnValue() {
16
16
  return this.body?.content ?? null;
17
17
  }
18
- generateBody() {
18
+ render() {
19
19
  const scrollMode = this.context.scroll ?? "auto";
20
20
  const container = document.createElement("div");
21
21
  container.style.position = "relative";