zois-core 2.2.1 → 3.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (159) 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 +6 -6
  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 +67 -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 +14 -14
  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} +8 -15
  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} +8 -8
  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} +10 -6
  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 +10 -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} +6 -6
  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/input.d.ts +14 -0
  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/types/wardrobe.d.ts +1 -1
  127. package/dist/ui.js +414 -79
  128. package/dist/validation.js +79 -1
  129. package/dist/wardrobe.js +4 -4
  130. package/package.json +36 -14
  131. package/dist/core-subscreen/coreSubscreen.js +0 -81
  132. package/dist/core-subscreen/developmentSubscreen.js +0 -22
  133. package/dist/core-subscreen/generalSubscreen.js +0 -23
  134. package/dist/core-subscreen/mainSubscreen.js +0 -58
  135. package/dist/core-subscreen/shards/coreButtonShard.js +0 -30
  136. package/dist/core-subscreen/shards/coreCheckboxShard.js +0 -33
  137. package/dist/core-subscreen/shards/coreInputListShard.js +0 -38
  138. package/dist/core-subscreen/shards/coreSelectShard.js +0 -17
  139. package/dist/core-subscreen/shards/coreTextShard.js +0 -9
  140. package/dist/core-subscreen/shards/index.js +0 -5
  141. package/dist/core-subscreen/toastsSubscreen.js +0 -111
  142. package/dist/core.js +0 -192
  143. package/dist/shards/backNextButtonShard.js +0 -99
  144. package/dist/shards/selectShard.js +0 -131
  145. package/dist/shards/svgShard.js +0 -29
  146. package/dist/types/core-subscreen/coreSubscreen.d.ts +0 -15
  147. package/dist/types/core-subscreen/developmentSubscreen.d.ts +0 -5
  148. package/dist/types/core-subscreen/generalSubscreen.d.ts +0 -5
  149. package/dist/types/core-subscreen/mainSubscreen.d.ts +0 -6
  150. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +0 -5
  151. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +0 -6
  152. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +0 -6
  153. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +0 -5
  154. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +0 -4
  155. package/dist/types/core-subscreen/shards/index.d.ts +0 -5
  156. package/dist/types/core-subscreen/toastsSubscreen.d.ts +0 -5
  157. package/dist/types/core.d.ts +0 -18
  158. package/dist/types/shards/inputShard.d.ts +0 -14
  159. package/dist/types/shards/svgShard.d.ts +0 -12
@@ -0,0 +1,377 @@
1
+ import { MOD_DATA } from "../index";
2
+ import { getDynamicClass, setFontFamily } from "../ui";
3
+ import { Shard } from "./base";
4
+ import { jsx, jsxs } from "tsx-dom/jsx-runtime";
5
+ const EXTENSION_SETTINGS_LIMIT_BYTES = 180 * 1024;
6
+ const OTHER_PALETTE = [
7
+ "rgba(100, 149, 237, 0.85)",
8
+ "rgba(72, 201, 176, 0.85)",
9
+ "rgba(244, 162, 97, 0.85)",
10
+ "rgba(231, 111, 81, 0.75)",
11
+ "rgba(156, 136, 255, 0.85)",
12
+ "rgba(86, 207, 225, 0.85)"
13
+ ];
14
+ const FOCUS_COLOR = "var(--tmd-accent, #3b82f6)";
15
+ const FREE_COLOR = "rgba(128, 128, 128, 0.22)";
16
+ function measureEntryBytes(value) {
17
+ if (value == null) return 0;
18
+ const str = typeof value === "string" ? value : JSON.stringify(value);
19
+ return new TextEncoder().encode(str).byteLength;
20
+ }
21
+ function formatBytes(bytes) {
22
+ if (bytes < 1024) return `${bytes} B`;
23
+ const kb = bytes / 1024;
24
+ if (kb < 1024) return `${kb < 10 ? kb.toFixed(2) : kb.toFixed(1)} KB`;
25
+ return `${(kb / 1024).toFixed(2)} MB`;
26
+ }
27
+ function escapeHtml(text) {
28
+ return text.replace(/&/g, "&amp;").replace(/</g, "&lt;").replace(/>/g, "&gt;").replace(/"/g, "&quot;");
29
+ }
30
+ function collectEntries(focusKey) {
31
+ const settings = globalThis.Player?.ExtensionSettings;
32
+ if (!settings || typeof settings !== "object") {
33
+ return [{ key: focusKey, bytes: 0, isFocus: true }];
34
+ }
35
+ const entries = [];
36
+ let focusFound = false;
37
+ for (const key of Object.keys(settings)) {
38
+ const bytes = measureEntryBytes(settings[key]);
39
+ if (bytes <= 0 && key !== focusKey) continue;
40
+ const isFocus = key === focusKey;
41
+ if (isFocus) focusFound = true;
42
+ entries.push({ key, bytes, isFocus });
43
+ }
44
+ if (!focusFound) {
45
+ entries.push({ key: focusKey, bytes: 0, isFocus: true });
46
+ }
47
+ entries.sort((a, b) => {
48
+ if (a.isFocus !== b.isFocus) return a.isFocus ? -1 : 1;
49
+ return b.bytes - a.bytes;
50
+ });
51
+ return entries;
52
+ }
53
+ class ExtensionsStorageBarShard extends Shard {
54
+ get dynamicClassRoot() {
55
+ return {
56
+ base: {
57
+ position: "relative",
58
+ display: "flex",
59
+ flexDirection: "row",
60
+ alignItems: "stretch",
61
+ gap: "0.75em",
62
+ boxSizing: "border-box",
63
+ color: "var(--tmd-text, #111)",
64
+ userSelect: "none",
65
+ height: "100%",
66
+ minHeight: "calc(28 * var(--size-unit) * 1px)",
67
+ width: "100%"
68
+ }
69
+ };
70
+ }
71
+ get dynamicClassColumn() {
72
+ return {
73
+ base: {
74
+ display: "flex",
75
+ flexDirection: "column",
76
+ alignItems: "stretch",
77
+ flex: "0 0 auto",
78
+ alignSelf: "stretch",
79
+ height: "100%",
80
+ minHeight: "calc(28 * var(--size-unit) * 1px)",
81
+ position: "relative",
82
+ boxSizing: "border-box"
83
+ },
84
+ ":hover > div:last-child": {
85
+ visibility: "visible",
86
+ opacity: "1"
87
+ }
88
+ };
89
+ }
90
+ get dynamicClassBar() {
91
+ return {
92
+ base: {
93
+ position: "relative",
94
+ flex: "1 1 auto",
95
+ width: "calc(8 * var(--size-unit) * 1px)",
96
+ minWidth: "14px",
97
+ minHeight: "calc(28 * var(--size-unit) * 1px)",
98
+ height: "100%",
99
+ alignSelf: "stretch",
100
+ display: "flex",
101
+ flexDirection: "column-reverse",
102
+ borderRadius: "8px",
103
+ overflow: "hidden",
104
+ border: "1px solid var(--tmd-accent, rgba(0,0,0,0.35))",
105
+ background: "var(--tmd-element, #f3f4f6)",
106
+ boxSizing: "border-box"
107
+ },
108
+ "> div": {
109
+ width: "100%",
110
+ minHeight: "0",
111
+ flexBasis: "0",
112
+ boxSizing: "border-box",
113
+ transition: "filter 0.15s ease",
114
+ cursor: "default"
115
+ },
116
+ "> div:hover": {
117
+ filter: "brightness(1.15)"
118
+ },
119
+ "> div[data-focus=true]": {
120
+ boxShadow: "inset 0 0 0 2px rgba(255,255,255,0.55)",
121
+ filter: "brightness(1.08)"
122
+ }
123
+ };
124
+ }
125
+ get dynamicClassLegend() {
126
+ return {
127
+ base: {
128
+ flex: "1 1 auto",
129
+ minWidth: "0",
130
+ minHeight: "0",
131
+ display: "flex",
132
+ flexDirection: "column",
133
+ gap: "0.35em",
134
+ overflowY: "auto",
135
+ overflowX: "hidden",
136
+ fontSize: "calc(1.45 * var(--size-unit) * 1px)",
137
+ lineHeight: "1.3",
138
+ boxSizing: "border-box"
139
+ },
140
+ "> div": {
141
+ display: "flex",
142
+ alignItems: "center",
143
+ gap: "0.45em",
144
+ padding: "0.2em 0.15em",
145
+ borderRadius: "4px"
146
+ },
147
+ "> div:hover": {
148
+ background: "var(--tmd-element-hover, rgba(0,0,0,0.04))"
149
+ },
150
+ "> div > span:first-child": {
151
+ flex: "0 0 auto",
152
+ width: "0.75em",
153
+ height: "0.75em",
154
+ borderRadius: "2px",
155
+ border: "1px solid rgba(0,0,0,0.12)",
156
+ boxSizing: "border-box"
157
+ },
158
+ "> div > p": {
159
+ margin: "0",
160
+ flex: "1 1 auto",
161
+ minWidth: "0",
162
+ display: "flex",
163
+ flexDirection: "column",
164
+ gap: "0.1em"
165
+ },
166
+ "> div > p > strong": {
167
+ fontWeight: "600",
168
+ overflow: "hidden",
169
+ textOverflow: "ellipsis",
170
+ whiteSpace: "nowrap"
171
+ },
172
+ "> div > p > span": {
173
+ opacity: "0.75",
174
+ fontSize: "0.9em"
175
+ }
176
+ };
177
+ }
178
+ get dynamicClassSummary() {
179
+ return {
180
+ base: {
181
+ marginTop: "0.35em",
182
+ flex: "0 0 auto",
183
+ fontSize: "calc(1.5 * var(--size-unit) * 1px)",
184
+ textAlign: "left",
185
+ lineHeight: "1.25",
186
+ width: "100%",
187
+ wordBreak: "break-word",
188
+ boxSizing: "border-box"
189
+ },
190
+ "> p": {
191
+ margin: "0"
192
+ },
193
+ "> p:last-child": {
194
+ opacity: "0.75",
195
+ fontSize: "0.85em"
196
+ }
197
+ };
198
+ }
199
+ get dynamicClassTooltip() {
200
+ const tipSide = this.context.tooltipPosition ?? "left";
201
+ return {
202
+ base: {
203
+ position: "absolute",
204
+ top: "50%",
205
+ transform: "translateY(-50%)",
206
+ ...tipSide === "left" ? { right: "calc(100% + 0.5em)" } : { left: "calc(100% + 0.5em)" },
207
+ background: "var(--tmd-element-hint, #1f2937)",
208
+ color: "var(--tmd-text, #f9fafb)",
209
+ padding: "0.45em 0.65em",
210
+ borderRadius: "6px",
211
+ fontSize: "calc(1.35 * var(--size-unit) * 1px)",
212
+ lineHeight: "1.35",
213
+ width: "max-content",
214
+ maxWidth: "14em",
215
+ visibility: "hidden",
216
+ opacity: "0",
217
+ pointerEvents: "none",
218
+ zIndex: "20",
219
+ boxShadow: "0 4px 14px rgba(0,0,0,0.25)",
220
+ transition: "opacity 0.12s ease"
221
+ }
222
+ };
223
+ }
224
+ get dynamicClassSide() {
225
+ return {
226
+ base: {
227
+ display: "flex",
228
+ flexDirection: "column",
229
+ flex: "1 1 auto",
230
+ minWidth: "0",
231
+ minHeight: "0",
232
+ height: "100%",
233
+ boxSizing: "border-box"
234
+ }
235
+ };
236
+ }
237
+ render() {
238
+ const focusKey = this.context.modKey;
239
+ const limit = EXTENSION_SETTINGS_LIMIT_BYTES;
240
+ const entries = collectEntries(focusKey);
241
+ const usedTotal = entries.reduce((s, e) => s + e.bytes, 0);
242
+ const free = Math.max(0, limit - usedTotal);
243
+ const focusBytes = entries.find((e) => e.isFocus)?.bytes ?? 0;
244
+ const rootClass = getDynamicClass(this.dynamicClassRoot);
245
+ const columnClass = getDynamicClass(this.dynamicClassColumn);
246
+ const barClass = getDynamicClass(this.dynamicClassBar);
247
+ const legendClass = getDynamicClass(this.dynamicClassLegend);
248
+ const summaryClass = getDynamicClass(this.dynamicClassSummary);
249
+ const tooltipClass = getDynamicClass(this.dynamicClassTooltip);
250
+ const sideClass = getDynamicClass(this.dynamicClassSide);
251
+ const tooltip = /* @__PURE__ */ jsx("div", { class: tooltipClass });
252
+ const defaultTooltipHtml = () => [
253
+ `<strong>${escapeHtml(focusKey)}</strong>: ${formatBytes(focusBytes)}`,
254
+ `All mods: ${formatBytes(usedTotal)} / ${formatBytes(limit)}`,
255
+ `Free: ${formatBytes(free)}`
256
+ ].join("<br>");
257
+ const showTooltip = (html) => {
258
+ tooltip.innerHTML = html;
259
+ };
260
+ showTooltip(defaultTooltipHtml());
261
+ const segInfos = [];
262
+ let otherColorIndex = 0;
263
+ for (const entry of entries) {
264
+ if (entry.bytes <= 0 && !entry.isFocus) continue;
265
+ const color = entry.isFocus ? FOCUS_COLOR : OTHER_PALETTE[otherColorIndex++ % OTHER_PALETTE.length];
266
+ segInfos.push({
267
+ key: entry.key,
268
+ label: entry.key,
269
+ bytes: entry.bytes,
270
+ color,
271
+ isFocus: entry.isFocus
272
+ });
273
+ }
274
+ if (free > 0) {
275
+ segInfos.push({
276
+ key: "__free",
277
+ label: "Free",
278
+ bytes: free,
279
+ color: FREE_COLOR,
280
+ isFocus: false,
281
+ isFree: true
282
+ });
283
+ }
284
+ const barSegments = segInfos.map((info) => {
285
+ const pct = limit > 0 ? info.bytes / limit * 100 : 0;
286
+ const flexGrow = Math.max(info.bytes, 1);
287
+ return /* @__PURE__ */ jsx(
288
+ "div",
289
+ {
290
+ "data-focus": info.isFocus ? "true" : "false",
291
+ "data-key": info.key,
292
+ title: `${info.label}: ${formatBytes(info.bytes)}`,
293
+ style: {
294
+ flex: `${flexGrow} 0 0`,
295
+ background: info.color
296
+ },
297
+ onMouseEnter: () => {
298
+ showTooltip(
299
+ [
300
+ `<strong>${escapeHtml(info.label)}</strong>`,
301
+ formatBytes(info.bytes),
302
+ `${pct.toFixed(1)}% of limit`
303
+ ].join("<br>")
304
+ );
305
+ },
306
+ onMouseLeave: () => showTooltip(defaultTooltipHtml())
307
+ }
308
+ );
309
+ });
310
+ const legendItems = segInfos.map((info) => {
311
+ const pct = limit > 0 ? info.bytes / limit * 100 : 0;
312
+ return /* @__PURE__ */ jsxs(
313
+ "div",
314
+ {
315
+ onMouseEnter: () => {
316
+ showTooltip(
317
+ [
318
+ `<strong>${escapeHtml(info.label)}</strong>`,
319
+ formatBytes(info.bytes),
320
+ `${pct.toFixed(1)}% of limit`
321
+ ].join("<br>")
322
+ );
323
+ },
324
+ onMouseLeave: () => showTooltip(defaultTooltipHtml()),
325
+ children: [
326
+ /* @__PURE__ */ jsx("span", { style: { background: info.color } }),
327
+ /* @__PURE__ */ jsxs("p", { children: [
328
+ /* @__PURE__ */ jsx("strong", { children: info.label }),
329
+ /* @__PURE__ */ jsxs("span", { children: [
330
+ formatBytes(info.bytes),
331
+ " \xB7 ",
332
+ pct.toFixed(1),
333
+ "%"
334
+ ] })
335
+ ] })
336
+ ]
337
+ }
338
+ );
339
+ });
340
+ const bar = /* @__PURE__ */ jsx("div", { class: barClass, children: barSegments });
341
+ const legend = /* @__PURE__ */ jsx("div", { class: legendClass, children: legendItems });
342
+ const summary = /* @__PURE__ */ jsxs("div", { class: summaryClass, children: [
343
+ /* @__PURE__ */ jsxs("p", { children: [
344
+ /* @__PURE__ */ jsx("strong", { children: focusKey }),
345
+ " \xB7 ",
346
+ formatBytes(focusBytes)
347
+ ] }),
348
+ /* @__PURE__ */ jsxs("p", { children: [
349
+ formatBytes(usedTotal),
350
+ " / ",
351
+ formatBytes(limit)
352
+ ] })
353
+ ] });
354
+ const root = /* @__PURE__ */ jsxs("div", { class: rootClass, children: [
355
+ /* @__PURE__ */ jsxs("div", { class: columnClass, children: [
356
+ bar,
357
+ tooltip
358
+ ] }),
359
+ /* @__PURE__ */ jsxs("div", { class: sideClass, children: [
360
+ legend,
361
+ summary
362
+ ] })
363
+ ] });
364
+ setFontFamily(root, MOD_DATA.fontFamily);
365
+ return {
366
+ base: root,
367
+ bar,
368
+ tooltip,
369
+ summary,
370
+ legend
371
+ };
372
+ }
373
+ }
374
+ export {
375
+ EXTENSION_SETTINGS_LIMIT_BYTES,
376
+ ExtensionsStorageBarShard
377
+ };
@@ -0,0 +1,180 @@
1
+ import { MOD_DATA } from "../index";
2
+ import { autosetFontSize, getDynamicClass, setFontFamily } from "../ui";
3
+ import { Shard } from "./base";
4
+ import { jsx, jsxs } from "tsx-dom/jsx-runtime";
5
+ class FileInputShard extends Shard {
6
+ render() {
7
+ const rootClassName = getDynamicClass({
8
+ base: {
9
+ display: "flex",
10
+ alignItems: "center",
11
+ justifyContent: "center",
12
+ width: "100%",
13
+ height: "100%",
14
+ minWidth: "0",
15
+ boxSizing: "border-box",
16
+ padding: "0.8em 1.2em",
17
+ border: "2px dashed var(--tmd-accent, #777)",
18
+ borderRadius: "0.65em",
19
+ background: "var(--tmd-element, rgba(127,127,127,0.12))",
20
+ color: "var(--tmd-text, black)",
21
+ cursor: "pointer",
22
+ transition: "background 140ms ease, border-color 140ms ease, box-shadow 140ms ease",
23
+ fontFamily: "inherit",
24
+ overflow: "hidden"
25
+ },
26
+ hover: {
27
+ background: "var(--tmd-element-hover, rgba(127,127,127,0.22))",
28
+ borderColor: "var(--tmd-accent-hover, var(--tmd-accent, #777))"
29
+ },
30
+ focus: {
31
+ outline: "2px solid var(--tmd-accent-hover, var(--tmd-accent, #777))",
32
+ outlineOffset: "3px"
33
+ },
34
+ active: {
35
+ transform: "scale(0.99)"
36
+ }
37
+ });
38
+ const dragOverClassName = getDynamicClass({
39
+ base: {
40
+ background: "var(--tmd-element-hover, rgba(127,127,127,0.28))",
41
+ borderColor: "var(--tmd-accent-hover, var(--tmd-accent, #777))"
42
+ }
43
+ });
44
+ const inputClassName = getDynamicClass({
45
+ base: {
46
+ position: "absolute",
47
+ width: "1px",
48
+ height: "1px",
49
+ padding: "0",
50
+ margin: "-1px",
51
+ overflow: "hidden",
52
+ clip: "rect(0, 0, 0, 0)",
53
+ whiteSpace: "nowrap",
54
+ border: "0"
55
+ }
56
+ });
57
+ const contentClassName = getDynamicClass({
58
+ base: {
59
+ display: "flex",
60
+ alignItems: "center",
61
+ justifyContent: "center",
62
+ minWidth: "0",
63
+ maxWidth: "100%",
64
+ pointerEvents: "none"
65
+ }
66
+ });
67
+ const textBlockClassName = getDynamicClass({
68
+ base: {
69
+ display: "flex",
70
+ flexDirection: "column",
71
+ alignItems: "center",
72
+ gap: "0.2em",
73
+ minWidth: "0",
74
+ overflow: "hidden"
75
+ }
76
+ });
77
+ const titleClassName = getDynamicClass({
78
+ base: {
79
+ display: "block",
80
+ fontWeight: "600",
81
+ lineHeight: "1.25",
82
+ overflow: "hidden",
83
+ textOverflow: "ellipsis",
84
+ whiteSpace: "nowrap"
85
+ }
86
+ });
87
+ const hintClassName = getDynamicClass({
88
+ base: {
89
+ display: "block",
90
+ opacity: "0.72",
91
+ fontSize: "0.78em",
92
+ lineHeight: "1.25",
93
+ whiteSpace: "nowrap"
94
+ }
95
+ });
96
+ const titleElement = /* @__PURE__ */ jsx("span", { class: titleClassName, children: this.context.title });
97
+ const hintElement = /* @__PURE__ */ jsx("span", { class: hintClassName, children: "JSON files \xB7 Click or drop here" });
98
+ const applyFile = (file) => {
99
+ titleElement.textContent = file.name;
100
+ hintElement.textContent = `${(file.size / 1024).toFixed(1)} KB \xB7 Click or drop to replace`;
101
+ this.context.onFile?.(file);
102
+ };
103
+ const isAccepted = (file) => {
104
+ const accept = this.context.accept ?? ".json,application/json";
105
+ const tokens = accept.split(",").map((token) => token.trim().toLowerCase()).filter(Boolean);
106
+ if (tokens.length === 0) return true;
107
+ const fileName = file.name.toLowerCase();
108
+ const fileType = (file.type || "").toLowerCase();
109
+ return tokens.some((token) => {
110
+ if (token.startsWith(".")) return fileName.endsWith(token);
111
+ if (token.endsWith("/*")) return fileType.startsWith(token.slice(0, -1));
112
+ return fileType === token;
113
+ });
114
+ };
115
+ const root = /* @__PURE__ */ jsxs(
116
+ "label",
117
+ {
118
+ class: rootClassName,
119
+ onDragEnter: (event) => {
120
+ event.preventDefault();
121
+ event.stopPropagation();
122
+ event.currentTarget.classList.add(dragOverClassName);
123
+ },
124
+ onDragOver: (event) => {
125
+ event.preventDefault();
126
+ event.stopPropagation();
127
+ if (event.dataTransfer) {
128
+ event.dataTransfer.dropEffect = "copy";
129
+ }
130
+ event.currentTarget.classList.add(dragOverClassName);
131
+ },
132
+ onDragLeave: (event) => {
133
+ event.preventDefault();
134
+ event.stopPropagation();
135
+ if (!event.currentTarget.contains(event.relatedTarget)) {
136
+ event.currentTarget.classList.remove(dragOverClassName);
137
+ }
138
+ },
139
+ onDrop: (event) => {
140
+ event.preventDefault();
141
+ event.stopPropagation();
142
+ event.currentTarget.classList.remove(dragOverClassName);
143
+ const file = event.dataTransfer?.files?.[0];
144
+ if (!file) return;
145
+ if (!isAccepted(file)) return;
146
+ applyFile(file);
147
+ },
148
+ children: [
149
+ /* @__PURE__ */ jsx(
150
+ "input",
151
+ {
152
+ class: inputClassName,
153
+ type: "file",
154
+ accept: this.context.accept ?? ".json,application/json",
155
+ "aria-label": "Choose a translation file",
156
+ onChange: (event) => {
157
+ const file = event.currentTarget.files?.[0];
158
+ if (!file) return;
159
+ applyFile(file);
160
+ }
161
+ }
162
+ ),
163
+ /* @__PURE__ */ jsx("span", { class: contentClassName, children: /* @__PURE__ */ jsxs("span", { class: textBlockClassName, children: [
164
+ titleElement,
165
+ hintElement
166
+ ] }) })
167
+ ]
168
+ }
169
+ );
170
+ setFontFamily(root, MOD_DATA.fontFamily);
171
+ return { base: root };
172
+ }
173
+ setContextStyles() {
174
+ super.setContextStyles();
175
+ autosetFontSize(this.body.base);
176
+ }
177
+ }
178
+ export {
179
+ FileInputShard
180
+ };
@@ -0,0 +1,30 @@
1
+ import { u } from "../ui";
2
+ import { StyleModule } from "../shard-modules";
3
+ import { ContainerShard } from "./container";
4
+ class FlexContainerShard extends ContainerShard {
5
+ constructor(context) {
6
+ super({
7
+ ...context,
8
+ modules: {
9
+ ...context.modules,
10
+ content: [
11
+ ...context.modules?.content ?? [],
12
+ new StyleModule({
13
+ display: "flex",
14
+ flexDirection: context.direction,
15
+ flexWrap: context.wrap,
16
+ gap: context.gap !== void 0 ? u(context.gap) : void 0,
17
+ rowGap: context.rowGap !== void 0 ? u(context.rowGap) : void 0,
18
+ columnGap: context.columnGap !== void 0 ? u(context.columnGap) : void 0,
19
+ alignItems: context.alignItems,
20
+ alignContent: context.alignContent,
21
+ justifyContent: context.justifyContent
22
+ })
23
+ ]
24
+ }
25
+ });
26
+ }
27
+ }
28
+ export {
29
+ FlexContainerShard
30
+ };
@@ -0,0 +1,34 @@
1
+ import { u } from "../ui";
2
+ import { StyleModule } from "../shard-modules";
3
+ import { ContainerShard } from "./container";
4
+ class GridContainerShard extends ContainerShard {
5
+ constructor(context) {
6
+ super({
7
+ ...context,
8
+ modules: {
9
+ ...context.modules,
10
+ content: [
11
+ ...context.modules?.content ?? [],
12
+ new StyleModule({
13
+ display: "grid",
14
+ gridTemplateColumns: context.templateColumns,
15
+ gridTemplateRows: context.templateRows,
16
+ gridAutoColumns: context.autoColumns,
17
+ gridAutoRows: context.autoRows,
18
+ gridAutoFlow: context.autoFlow,
19
+ gap: context.gap !== void 0 ? u(context.gap) : void 0,
20
+ rowGap: context.rowGap !== void 0 ? u(context.rowGap) : void 0,
21
+ columnGap: context.columnGap !== void 0 ? u(context.columnGap) : void 0,
22
+ alignItems: context.alignItems,
23
+ alignContent: context.alignContent,
24
+ justifyItems: context.justifyItems,
25
+ justifyContent: context.justifyContent
26
+ })
27
+ ]
28
+ }
29
+ });
30
+ }
31
+ }
32
+ export {
33
+ GridContainerShard
34
+ };
@@ -1,7 +1,8 @@
1
- import { Shard } from "./shard";
1
+ import { keydownManager } from "../ui";
2
+ import { Shard } from "./base";
2
3
  class ImageShard extends Shard {
3
4
  modal = null;
4
- generateBody() {
5
+ render() {
5
6
  const { src, alt = "" } = this.context;
6
7
  const img = document.createElement("img");
7
8
  img.src = src;
@@ -75,14 +76,15 @@ class ImageShard extends Shard {
75
76
  this.modal.style.opacity = "1";
76
77
  modalContent.style.transform = "scale(1)";
77
78
  }, 10);
78
- const close = () => this.closeModal();
79
+ const close = () => {
80
+ unregisterEscape();
81
+ this.closeModal();
82
+ };
79
83
  closeBtn.addEventListener("click", close);
80
84
  this.modal.addEventListener("click", (e) => {
81
85
  if (e.target === this.modal) close();
82
86
  });
83
- document.addEventListener("keydown", (e) => {
84
- if (e.key === "Escape") close();
85
- }, { once: true });
87
+ const unregisterEscape = keydownManager.register("Escape", close);
86
88
  }
87
89
  closeModal() {
88
90
  if (!this.modal) return;
@@ -1,13 +1,17 @@
1
- export * from "./backNextButtonShard";
2
- export * from "./buttonShard";
3
- export * from "./cardShard";
4
- export * from "./checkboxShard";
5
- export * from "./containerShard";
6
- export * from "./imageShard";
7
- export * from "./inputListShard";
8
- export * from "./inputShard";
9
- export * from "./selectShard";
10
- export * from "./shard";
11
- export * from "./svgShard";
12
- export * from "./tabsShard";
13
- export * from "./textShard";
1
+ export * from "./backNextButton";
2
+ export * from "./button";
3
+ export * from "./card";
4
+ export * from "./checkbox";
5
+ export * from "./container";
6
+ export * from "./image";
7
+ export * from "./inputList";
8
+ export * from "./input";
9
+ export * from "./select";
10
+ export * from "./base";
11
+ export * from "./svg";
12
+ export * from "./tabs";
13
+ export * from "./text";
14
+ export * from "./extensionsStorageBar";
15
+ export * from "./fileInput";
16
+ export * from "./flexContainer";
17
+ export * from "./gridContainer";