zois-core 2.2.1 → 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.
- package/dist/assets/icons/toast-themes/abdl/bottle.svg +10 -0
- package/dist/assets/icons/toast-themes/abdl/diaper.svg +11 -0
- package/dist/assets/icons/toast-themes/abdl/heart.svg +7 -0
- package/dist/assets/icons/toast-themes/abdl/sparkle.svg +5 -0
- package/dist/assets/icons/toast-themes/abdl/star.svg +5 -0
- package/dist/assets/icons/toast-themes/abdl/teddy.svg +18 -0
- package/dist/assets/icons/toast-themes/anime/error.svg +20 -0
- package/dist/assets/icons/toast-themes/anime/info.svg +20 -0
- package/dist/assets/icons/toast-themes/anime/success.svg +16 -0
- package/dist/assets/icons/toast-themes/anime/warning.svg +19 -0
- package/dist/changelogs.js +628 -295
- package/dist/cssVars.js +46 -0
- package/dist/dialogs.js +523 -83
- package/dist/events.js +28 -6
- package/dist/index.js +27 -70
- package/dist/localization.js +250 -40
- package/dist/messaging.js +1 -1
- package/dist/migration.js +37 -0
- package/dist/modules/baseModule.js +110 -0
- package/dist/modules/index.js +4 -0
- package/dist/modules/loadingStrategy.js +20 -0
- package/dist/modules/moduleContext.js +56 -0
- package/dist/modules/modulesManager.js +175 -0
- package/dist/{modSdk.js → patching.js} +33 -9
- package/dist/rpc.js +139 -0
- package/dist/scripts/zois-core.js +14 -14
- package/dist/settings.js +90 -0
- package/dist/settingsDialog.js +1361 -0
- package/dist/shard-modules/{attributesModule.js → attributes.js} +2 -2
- package/dist/shard-modules/{shardModule.js → base.js} +2 -2
- package/dist/shard-modules/{centerModule.js → center.js} +4 -2
- package/dist/shard-modules/{clickModule.js → click.js} +2 -2
- package/dist/shard-modules/{counterUpModule.js → counterUp.js} +2 -2
- package/dist/shard-modules/{dynamicClassModule.js → dynamicClass.js} +2 -2
- package/dist/shard-modules/index.js +9 -9
- package/dist/shard-modules/{multiClickModule.js → multiClick.js} +2 -2
- package/dist/shard-modules/{styleModule.js → style.js} +2 -2
- package/dist/shard-modules/{typeModule.js → type.js} +2 -2
- package/dist/shards/backNextButton.js +173 -0
- package/dist/shards/{shard.js → base.js} +15 -15
- package/dist/shards/{buttonShard.js → button.js} +30 -52
- package/dist/shards/{cardShard.js → card.js} +4 -4
- package/dist/shards/{checkboxShard.js → checkbox.js} +6 -13
- package/dist/shards/{containerShard.js → container.js} +2 -2
- package/dist/shards/extensionsStorageBar.js +377 -0
- package/dist/shards/fileInput.js +180 -0
- package/dist/shards/flexContainer.js +30 -0
- package/dist/shards/gridContainer.js +34 -0
- package/dist/shards/{imageShard.js → image.js} +8 -6
- package/dist/shards/index.js +17 -13
- package/dist/shards/{inputShard.js → input.js} +4 -4
- package/dist/shards/{inputListShard.js → inputList.js} +22 -4
- package/dist/shards/select.js +201 -0
- package/dist/shards/svg.js +28 -0
- package/dist/shards/{tabsShard.js → tabs.js} +18 -19
- package/dist/shards/{textShard.js → text.js} +4 -4
- package/dist/shared.js +215 -0
- package/dist/styles.css +0 -51
- package/dist/subscreens/customTranslations.js +239 -0
- package/dist/subscreens/languageDetails.js +194 -0
- package/dist/subscreens/localization.js +115 -0
- package/dist/toast-themes/abdl.js +419 -0
- package/dist/toast-themes/anime.js +483 -0
- package/dist/toast-themes/base.js +40 -0
- package/dist/toast-themes/cyber.js +538 -0
- package/dist/toast-themes/default.js +282 -0
- package/dist/toastThemesDialog.js +274 -0
- package/dist/toasts.js +195 -174
- package/dist/types/cssVars.d.ts +1 -0
- package/dist/types/dialogs.d.ts +46 -18
- package/dist/types/events.d.ts +11 -2
- package/dist/types/global.d.ts +4 -3
- package/dist/types/index.d.ts +12 -19
- package/dist/types/localization.d.ts +25 -3
- package/dist/types/migration.d.ts +6 -0
- package/dist/types/modules/baseModule.d.ts +108 -0
- package/dist/types/modules/index.d.ts +4 -0
- package/dist/types/modules/loadingStrategy.d.ts +7 -0
- package/dist/types/modules/moduleContext.d.ts +9 -0
- package/dist/types/modules/modulesManager.d.ts +23 -0
- package/dist/types/{modSdk.d.ts → patching.d.ts} +2 -3
- package/dist/types/rpc.d.ts +72 -0
- package/dist/types/settings.d.ts +19 -0
- package/dist/types/settingsDialog.d.ts +4 -0
- package/dist/types/shard-modules/{attributesModule.d.ts → attributes.d.ts} +2 -2
- package/dist/types/shard-modules/{shardModule.d.ts → base.d.ts} +2 -2
- package/dist/types/shard-modules/{centerModule.d.ts → center.d.ts} +2 -1
- package/dist/types/shard-modules/{clickModule.d.ts → click.d.ts} +2 -2
- package/dist/types/shard-modules/{counterUpModule.d.ts → counterUp.d.ts} +2 -2
- package/dist/types/shard-modules/{dynamicClassModule.d.ts → dynamicClass.d.ts} +2 -2
- package/dist/types/shard-modules/index.d.ts +9 -9
- package/dist/types/shard-modules/{multiClickModule.d.ts → multiClick.d.ts} +2 -2
- package/dist/types/shard-modules/{styleModule.d.ts → style.d.ts} +2 -2
- package/dist/types/shard-modules/{typeModule.d.ts → type.d.ts} +2 -2
- package/dist/types/shards/{backNextButtonShard.d.ts → backNextButton.d.ts} +4 -3
- package/dist/types/shards/{shard.d.ts → base.d.ts} +3 -2
- package/dist/types/shards/{buttonShard.d.ts → button.d.ts} +6 -6
- package/dist/types/shards/{cardShard.d.ts → card.d.ts} +3 -3
- package/dist/types/shards/{checkboxShard.d.ts → checkbox.d.ts} +5 -5
- package/dist/types/shards/{containerShard.d.ts → container.d.ts} +2 -2
- package/dist/types/shards/extensionsStorageBar.d.ts +28 -0
- package/dist/types/shards/fileInput.d.ts +10 -0
- package/dist/types/shards/flexContainer.d.ts +14 -0
- package/dist/types/shards/gridContainer.d.ts +18 -0
- package/dist/types/shards/{imageShard.d.ts → image.d.ts} +2 -2
- package/dist/types/shards/index.d.ts +17 -13
- package/dist/types/shards/{inputShard.d.ts → input.d.ts} +3 -3
- package/dist/types/shards/{inputListShard.d.ts → inputList.d.ts} +3 -2
- package/dist/types/shards/{selectShard.d.ts → select.d.ts} +6 -4
- package/dist/types/shards/svg.d.ts +11 -0
- package/dist/types/shards/{tabsShard.d.ts → tabs.d.ts} +3 -6
- package/dist/types/shards/{textShard.d.ts → text.d.ts} +3 -3
- package/dist/types/shared.d.ts +7 -0
- package/dist/types/subscreens/customTranslations.d.ts +10 -0
- package/dist/types/subscreens/languageDetails.d.ts +14 -0
- package/dist/types/subscreens/localization.d.ts +5 -0
- package/dist/types/toast-themes/abdl.d.ts +9 -0
- package/dist/types/toast-themes/anime.d.ts +9 -0
- package/dist/types/toast-themes/base.d.ts +39 -0
- package/dist/types/toast-themes/cyber.d.ts +10 -0
- package/dist/types/toast-themes/default.d.ts +9 -0
- package/dist/types/toastThemesDialog.d.ts +1 -0
- package/dist/types/toasts.d.ts +48 -36
- package/dist/types/ui.d.ts +128 -49
- package/dist/types/validation.d.ts +5 -0
- package/dist/ui.js +414 -79
- package/dist/validation.js +79 -1
- package/dist/wardrobe.js +2 -2
- package/package.json +36 -14
- package/dist/core-subscreen/coreSubscreen.js +0 -81
- package/dist/core-subscreen/developmentSubscreen.js +0 -22
- package/dist/core-subscreen/generalSubscreen.js +0 -23
- package/dist/core-subscreen/mainSubscreen.js +0 -58
- package/dist/core-subscreen/shards/coreButtonShard.js +0 -30
- package/dist/core-subscreen/shards/coreCheckboxShard.js +0 -33
- package/dist/core-subscreen/shards/coreInputListShard.js +0 -38
- package/dist/core-subscreen/shards/coreSelectShard.js +0 -17
- package/dist/core-subscreen/shards/coreTextShard.js +0 -9
- package/dist/core-subscreen/shards/index.js +0 -5
- package/dist/core-subscreen/toastsSubscreen.js +0 -111
- package/dist/core.js +0 -192
- package/dist/shards/backNextButtonShard.js +0 -99
- package/dist/shards/selectShard.js +0 -131
- package/dist/shards/svgShard.js +0 -29
- package/dist/types/core-subscreen/coreSubscreen.d.ts +0 -15
- package/dist/types/core-subscreen/developmentSubscreen.d.ts +0 -5
- package/dist/types/core-subscreen/generalSubscreen.d.ts +0 -5
- package/dist/types/core-subscreen/mainSubscreen.d.ts +0 -6
- package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +0 -5
- package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +0 -6
- package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +0 -6
- package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +0 -5
- package/dist/types/core-subscreen/shards/coreTextShard.d.ts +0 -4
- package/dist/types/core-subscreen/shards/index.d.ts +0 -5
- package/dist/types/core-subscreen/toastsSubscreen.d.ts +0 -5
- package/dist/types/core.d.ts +0 -18
- package/dist/types/shards/svgShard.d.ts +0 -12
|
@@ -0,0 +1,282 @@
|
|
|
1
|
+
import {
|
|
2
|
+
BadgeCheck,
|
|
3
|
+
TriangleAlert,
|
|
4
|
+
Info,
|
|
5
|
+
LoaderCircle,
|
|
6
|
+
X,
|
|
7
|
+
Palette,
|
|
8
|
+
createElement,
|
|
9
|
+
CircleX
|
|
10
|
+
} from "lucide";
|
|
11
|
+
import { getDynamicClass } from "../ui";
|
|
12
|
+
import { ToastTheme, ToastThemeTier } from "./base";
|
|
13
|
+
import { dismissToast } from "../toasts";
|
|
14
|
+
import { createThemesDialog } from "../toastThemesDialog";
|
|
15
|
+
import { getSettings } from "../settings";
|
|
16
|
+
import { jsx, jsxs } from "tsx-dom/jsx-runtime";
|
|
17
|
+
const FIXED_UNIT = 10;
|
|
18
|
+
const BACKGROUND_COLOR = "#1a1d21";
|
|
19
|
+
const PROGRESS_BAR_COLOR = "#1e2126";
|
|
20
|
+
const ICON_COLOR = {
|
|
21
|
+
info: "#6b8afd",
|
|
22
|
+
warning: "#e6b422",
|
|
23
|
+
error: "#f07178",
|
|
24
|
+
success: "#7fd99a"
|
|
25
|
+
};
|
|
26
|
+
function getToastIcon(type) {
|
|
27
|
+
const color = type === "spinner" ? ICON_COLOR.info : ICON_COLOR[type];
|
|
28
|
+
const size = "1em";
|
|
29
|
+
let icon;
|
|
30
|
+
switch (type) {
|
|
31
|
+
case "info":
|
|
32
|
+
icon = createElement(Info);
|
|
33
|
+
break;
|
|
34
|
+
case "warning":
|
|
35
|
+
icon = createElement(TriangleAlert);
|
|
36
|
+
break;
|
|
37
|
+
case "error":
|
|
38
|
+
icon = createElement(CircleX);
|
|
39
|
+
break;
|
|
40
|
+
case "success":
|
|
41
|
+
icon = createElement(BadgeCheck);
|
|
42
|
+
break;
|
|
43
|
+
case "spinner":
|
|
44
|
+
icon = createElement(LoaderCircle);
|
|
45
|
+
icon.style.stroke = color;
|
|
46
|
+
icon.style.cssText += `flex-shrink:0;width:${size};height:${size};animation:zcSpin 0.7s linear infinite;`;
|
|
47
|
+
return icon;
|
|
48
|
+
}
|
|
49
|
+
icon.style.fill = color;
|
|
50
|
+
icon.style.stroke = BACKGROUND_COLOR;
|
|
51
|
+
icon.style.cssText += `flex-shrink:0;width:${size};height:${size};`;
|
|
52
|
+
return icon;
|
|
53
|
+
}
|
|
54
|
+
class DefaultToastTheme extends ToastTheme {
|
|
55
|
+
name = "Default";
|
|
56
|
+
details = "Standard minimalist theme.";
|
|
57
|
+
tier = ToastThemeTier.R;
|
|
58
|
+
init() {
|
|
59
|
+
}
|
|
60
|
+
render(renderData) {
|
|
61
|
+
renderData.isInteractable ??= true;
|
|
62
|
+
const pos = getSettings().toasts?.position ?? "bottom-left";
|
|
63
|
+
const accent = renderData.type === "success" ? "#7fd99a" : renderData.type === "error" ? "#f07178" : renderData.type === "warning" ? "#e6b422" : "#6b8afd";
|
|
64
|
+
const textColor = "#b0bcc8";
|
|
65
|
+
const titleColor = "#e8eef4";
|
|
66
|
+
const toastClassName = getDynamicClass({
|
|
67
|
+
base: {
|
|
68
|
+
display: "flex",
|
|
69
|
+
columnGap: "0.55em",
|
|
70
|
+
alignItems: "flex-start",
|
|
71
|
+
maxWidth: "25vw",
|
|
72
|
+
borderRadius: "0.35em",
|
|
73
|
+
position: "relative",
|
|
74
|
+
overflow: "hidden",
|
|
75
|
+
background: BACKGROUND_COLOR,
|
|
76
|
+
border: "1px solid rgba(255,255,255,0.06)",
|
|
77
|
+
boxShadow: "0 6px 18px rgba(0,0,0,0.32), 0 0 0 1px rgba(0,0,0,0.2)"
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
const iconWrapClass = getDynamicClass({
|
|
81
|
+
base: {
|
|
82
|
+
flexShrink: "0",
|
|
83
|
+
display: "flex",
|
|
84
|
+
alignItems: "center",
|
|
85
|
+
justifyContent: "center",
|
|
86
|
+
width: "1.55em",
|
|
87
|
+
height: "1.55em",
|
|
88
|
+
borderRadius: "6px",
|
|
89
|
+
background: `${accent}18`,
|
|
90
|
+
position: "relative",
|
|
91
|
+
zIndex: "1",
|
|
92
|
+
marginTop: "0.05em"
|
|
93
|
+
}
|
|
94
|
+
});
|
|
95
|
+
const buttonsContainerClassName = getDynamicClass({
|
|
96
|
+
base: {
|
|
97
|
+
display: "flex",
|
|
98
|
+
gap: "0.4em",
|
|
99
|
+
marginTop: "0.35em",
|
|
100
|
+
flexWrap: "wrap",
|
|
101
|
+
position: "relative",
|
|
102
|
+
zIndex: "1"
|
|
103
|
+
},
|
|
104
|
+
">button": {
|
|
105
|
+
flexShrink: "0",
|
|
106
|
+
background: "rgba(255,255,255,0.06)",
|
|
107
|
+
border: "1px solid rgba(255,255,255,0.1)",
|
|
108
|
+
color: titleColor,
|
|
109
|
+
fontSize: "0.8em",
|
|
110
|
+
padding: "0.2em 0.5em",
|
|
111
|
+
borderRadius: "5px",
|
|
112
|
+
cursor: "pointer",
|
|
113
|
+
transition: "background 0.15s ease, border-color 0.15s ease"
|
|
114
|
+
},
|
|
115
|
+
">button:hover": {
|
|
116
|
+
background: "rgba(255,255,255,0.12)",
|
|
117
|
+
borderColor: "rgba(255,255,255,0.18)"
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const actionsClassName = getDynamicClass({
|
|
121
|
+
base: {
|
|
122
|
+
position: "absolute",
|
|
123
|
+
top: "0.35em",
|
|
124
|
+
right: "0.35em",
|
|
125
|
+
display: "flex",
|
|
126
|
+
gap: "0.1em",
|
|
127
|
+
zIndex: "10"
|
|
128
|
+
},
|
|
129
|
+
">button": {
|
|
130
|
+
background: "transparent",
|
|
131
|
+
border: "none",
|
|
132
|
+
cursor: "pointer",
|
|
133
|
+
padding: "0.1em",
|
|
134
|
+
display: "flex",
|
|
135
|
+
alignItems: "center",
|
|
136
|
+
justifyContent: "center",
|
|
137
|
+
opacity: "0.75",
|
|
138
|
+
color: textColor,
|
|
139
|
+
borderRadius: "4px",
|
|
140
|
+
transition: "opacity 0.15s ease, background 0.15s ease"
|
|
141
|
+
},
|
|
142
|
+
">button:hover": {
|
|
143
|
+
opacity: "1",
|
|
144
|
+
background: "rgba(255,255,255,0.1)"
|
|
145
|
+
},
|
|
146
|
+
">button>svg": {
|
|
147
|
+
width: "0.9em",
|
|
148
|
+
height: "0.9em"
|
|
149
|
+
}
|
|
150
|
+
});
|
|
151
|
+
const closeIcon = createElement(X);
|
|
152
|
+
const paletteIcon = createElement(Palette);
|
|
153
|
+
const toast = /* @__PURE__ */ jsxs(
|
|
154
|
+
"div",
|
|
155
|
+
{
|
|
156
|
+
class: toastClassName,
|
|
157
|
+
"data-zc-toast-type": renderData.type,
|
|
158
|
+
"data-zc-toast-id": renderData.id,
|
|
159
|
+
children: [
|
|
160
|
+
renderData.type !== "spinner" && renderData.duration !== 0 && /* @__PURE__ */ jsx(
|
|
161
|
+
"div",
|
|
162
|
+
{
|
|
163
|
+
class: "zcToast-ProgressBar",
|
|
164
|
+
style: {
|
|
165
|
+
animation: `zcToast-progress ${renderData.duration}ms linear 0s 1 alternate none`,
|
|
166
|
+
position: "absolute",
|
|
167
|
+
top: "0",
|
|
168
|
+
left: "0",
|
|
169
|
+
height: "100%",
|
|
170
|
+
borderRadius: "8px",
|
|
171
|
+
background: PROGRESS_BAR_COLOR,
|
|
172
|
+
zIndex: "0"
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
),
|
|
176
|
+
/* @__PURE__ */ jsxs("div", { class: actionsClassName, children: [
|
|
177
|
+
/* @__PURE__ */ jsx(
|
|
178
|
+
"button",
|
|
179
|
+
{
|
|
180
|
+
type: "button",
|
|
181
|
+
title: "Theme menu",
|
|
182
|
+
onClick: (e) => {
|
|
183
|
+
e.stopPropagation();
|
|
184
|
+
if (!renderData.isInteractable) return;
|
|
185
|
+
createThemesDialog();
|
|
186
|
+
},
|
|
187
|
+
children: paletteIcon
|
|
188
|
+
}
|
|
189
|
+
),
|
|
190
|
+
/* @__PURE__ */ jsx(
|
|
191
|
+
"button",
|
|
192
|
+
{
|
|
193
|
+
type: "button",
|
|
194
|
+
title: "Close",
|
|
195
|
+
onClick: (e) => {
|
|
196
|
+
e.stopPropagation();
|
|
197
|
+
if (!renderData.isInteractable) return;
|
|
198
|
+
dismissToast(toast);
|
|
199
|
+
},
|
|
200
|
+
children: closeIcon
|
|
201
|
+
}
|
|
202
|
+
)
|
|
203
|
+
] }),
|
|
204
|
+
/* @__PURE__ */ jsx("div", { class: iconWrapClass, children: getToastIcon(renderData.type) }),
|
|
205
|
+
/* @__PURE__ */ jsxs(
|
|
206
|
+
"div",
|
|
207
|
+
{
|
|
208
|
+
style: {
|
|
209
|
+
width: "100%",
|
|
210
|
+
minWidth: "0",
|
|
211
|
+
paddingRight: "2.5em",
|
|
212
|
+
position: "relative",
|
|
213
|
+
zIndex: "1"
|
|
214
|
+
},
|
|
215
|
+
children: [
|
|
216
|
+
!!renderData.title && /* @__PURE__ */ jsx(
|
|
217
|
+
"p",
|
|
218
|
+
{
|
|
219
|
+
style: {
|
|
220
|
+
color: titleColor,
|
|
221
|
+
fontWeight: "600",
|
|
222
|
+
fontSize: "0.88em",
|
|
223
|
+
margin: "0",
|
|
224
|
+
overflow: "hidden",
|
|
225
|
+
textOverflow: "ellipsis",
|
|
226
|
+
whiteSpace: "nowrap",
|
|
227
|
+
width: "100%"
|
|
228
|
+
},
|
|
229
|
+
children: renderData.title
|
|
230
|
+
}
|
|
231
|
+
),
|
|
232
|
+
/* @__PURE__ */ jsx(
|
|
233
|
+
"p",
|
|
234
|
+
{
|
|
235
|
+
style: {
|
|
236
|
+
color: textColor,
|
|
237
|
+
fontSize: !!renderData.title ? "0.72em" : "0.85em",
|
|
238
|
+
overflowWrap: "anywhere",
|
|
239
|
+
fontWeight: !!renderData.title ? "400" : "600",
|
|
240
|
+
margin: "0",
|
|
241
|
+
marginTop: !!renderData.title ? "0.15em" : void 0,
|
|
242
|
+
lineHeight: "1.3"
|
|
243
|
+
},
|
|
244
|
+
children: renderData.message
|
|
245
|
+
}
|
|
246
|
+
),
|
|
247
|
+
renderData.buttons !== void 0 && /* @__PURE__ */ jsx("div", { class: buttonsContainerClassName, children: renderData.buttons.map((b) => /* @__PURE__ */ jsx(
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
type: "button",
|
|
251
|
+
onClick: () => {
|
|
252
|
+
if (!renderData.isInteractable) return;
|
|
253
|
+
b.action();
|
|
254
|
+
},
|
|
255
|
+
children: b.name
|
|
256
|
+
}
|
|
257
|
+
)) })
|
|
258
|
+
]
|
|
259
|
+
}
|
|
260
|
+
)
|
|
261
|
+
]
|
|
262
|
+
}
|
|
263
|
+
);
|
|
264
|
+
const sz = (value) => renderData.size.scaleWithCanvas ? `calc(var(--size-unit) * ${value * renderData.size.scaleFactor}px)` : `${value * renderData.size.scaleFactor * FIXED_UNIT}px`;
|
|
265
|
+
toast.style.fontSize = sz(2.15);
|
|
266
|
+
toast.style.padding = `${sz(0.85)} ${sz(0.95)}`;
|
|
267
|
+
toast.style.animation = `${pos.includes("left") ? "zcSlideInFromLeft" : "zcSlideInFromRight"} 0.3s ease-out forwards`;
|
|
268
|
+
void toast.offsetHeight;
|
|
269
|
+
if (renderData.type !== "spinner" && renderData.duration !== 0) {
|
|
270
|
+
setTimeout(() => {
|
|
271
|
+
toast.style.animation = `${pos.includes("left") ? "zcSlideOutToLeft" : "zcSlideOutToRight"} 0.3s ease-out forwards`;
|
|
272
|
+
}, renderData.duration);
|
|
273
|
+
setTimeout(() => toast.remove(), renderData.duration + 300);
|
|
274
|
+
}
|
|
275
|
+
return toast;
|
|
276
|
+
}
|
|
277
|
+
}
|
|
278
|
+
const defaultToastTheme = new DefaultToastTheme();
|
|
279
|
+
export {
|
|
280
|
+
DefaultToastTheme,
|
|
281
|
+
defaultToastTheme
|
|
282
|
+
};
|
|
@@ -0,0 +1,274 @@
|
|
|
1
|
+
import { getDynamicClass } from "./ui";
|
|
2
|
+
import { getActiveToastThemeId, isToastThemeUnlocked, setActiveToastTheme, themes } from "./toasts";
|
|
3
|
+
import { Dialog, DialogButton, DialogCloseButton, DialogText } from "./dialogs";
|
|
4
|
+
import { jsx, jsxs } from "tsx-dom/jsx-runtime";
|
|
5
|
+
function createThemesDialog() {
|
|
6
|
+
const toastTypes = [
|
|
7
|
+
{ type: "info", name: "Info" },
|
|
8
|
+
{ type: "success", name: "Success" },
|
|
9
|
+
{ type: "warning", name: "Warning" },
|
|
10
|
+
{ type: "error", name: "Error" },
|
|
11
|
+
{ type: "spinner", name: "Loading" }
|
|
12
|
+
];
|
|
13
|
+
let activeThemeId = getActiveToastThemeId();
|
|
14
|
+
const themeCardClassName = getDynamicClass({
|
|
15
|
+
base: {
|
|
16
|
+
position: "relative",
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
gap: "14px",
|
|
20
|
+
background: "var(--tmd-element, #f2f2f2)",
|
|
21
|
+
border: "1px solid var(--tmd-element, #d0d0d0)",
|
|
22
|
+
borderRadius: "8px",
|
|
23
|
+
padding: "14px",
|
|
24
|
+
color: "var(--tmd-text, #292929)",
|
|
25
|
+
boxShadow: "0 2px 8px rgba(0, 0, 0, 0.1)"
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
const tierStyles = {
|
|
29
|
+
R: {
|
|
30
|
+
color: "var(--tmd-text, #555)",
|
|
31
|
+
fontWeight: "600",
|
|
32
|
+
textShadow: "none"
|
|
33
|
+
},
|
|
34
|
+
SR: {
|
|
35
|
+
background: "linear-gradient(135deg, #4facfe 0%, #00f2fe 100%)",
|
|
36
|
+
WebkitBackgroundClip: "text",
|
|
37
|
+
WebkitTextFillColor: "transparent",
|
|
38
|
+
backgroundClip: "text",
|
|
39
|
+
fontWeight: "700",
|
|
40
|
+
textShadow: "0 0 4px rgba(0, 242, 254, 0.6)",
|
|
41
|
+
filter: "drop-shadow(0 0 4px rgba(79, 172, 254, 0.5))"
|
|
42
|
+
},
|
|
43
|
+
SSR: {
|
|
44
|
+
background: "linear-gradient(135deg, #f093fb 0%, #f5576c 50%, #ffd700 100%)",
|
|
45
|
+
WebkitBackgroundClip: "text",
|
|
46
|
+
WebkitTextFillColor: "transparent",
|
|
47
|
+
backgroundClip: "text",
|
|
48
|
+
fontWeight: "800",
|
|
49
|
+
textShadow: "0 0 6px rgba(245, 87, 108, 0.7)",
|
|
50
|
+
filter: "drop-shadow(0 0 6px rgba(255, 215, 0, 0.6))"
|
|
51
|
+
}
|
|
52
|
+
};
|
|
53
|
+
const sectionContainerClassName = getDynamicClass({
|
|
54
|
+
base: {
|
|
55
|
+
display: "flex",
|
|
56
|
+
flexDirection: "column",
|
|
57
|
+
alignItems: "flex-start",
|
|
58
|
+
gap: "10px",
|
|
59
|
+
padding: "12px",
|
|
60
|
+
borderRadius: "8px",
|
|
61
|
+
background: "var(--tmd-element-hover, #e9e9e9)",
|
|
62
|
+
border: "1px solid var(--tmd-element, #d0d0d0)"
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
const sectionTitleClassName = getDynamicClass({
|
|
66
|
+
base: {
|
|
67
|
+
fontSize: "13px",
|
|
68
|
+
fontWeight: "700",
|
|
69
|
+
letterSpacing: "1px",
|
|
70
|
+
color: "var(--tmd-text, #555)",
|
|
71
|
+
opacity: "0.75"
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
const detailsClassName = getDynamicClass({
|
|
75
|
+
base: {
|
|
76
|
+
width: "100%",
|
|
77
|
+
boxSizing: "border-box",
|
|
78
|
+
fontSize: "17px",
|
|
79
|
+
lineHeight: "1.4"
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
const typesContainerClassName = getDynamicClass({
|
|
83
|
+
base: {
|
|
84
|
+
display: "flex",
|
|
85
|
+
flexDirection: "row",
|
|
86
|
+
flexWrap: "wrap",
|
|
87
|
+
alignItems: "center",
|
|
88
|
+
gap: "6px"
|
|
89
|
+
}
|
|
90
|
+
});
|
|
91
|
+
const typeButtonClassName = getDynamicClass({
|
|
92
|
+
base: {
|
|
93
|
+
fontSize: "15px !important",
|
|
94
|
+
padding: "4px 10px !important",
|
|
95
|
+
borderRadius: "5px !important"
|
|
96
|
+
}
|
|
97
|
+
});
|
|
98
|
+
const setAsDefaultButtonClassName = getDynamicClass({
|
|
99
|
+
base: {
|
|
100
|
+
cursor: "pointer",
|
|
101
|
+
color: "var(--tmd-text, white) !important",
|
|
102
|
+
background: "var(--tmd-accent, #444) !important",
|
|
103
|
+
padding: "8px 16px",
|
|
104
|
+
fontSize: "17px",
|
|
105
|
+
fontWeight: "600",
|
|
106
|
+
border: "1px solid var(--tmd-accent-hover, #333)",
|
|
107
|
+
borderRadius: "6px",
|
|
108
|
+
transition: "background 0.15s ease, color 0.15s ease"
|
|
109
|
+
},
|
|
110
|
+
hover: {
|
|
111
|
+
color: "var(--tmd-text, black) !important",
|
|
112
|
+
background: "var(--tmd-accent-hover, #ddd) !important"
|
|
113
|
+
},
|
|
114
|
+
disabled: {
|
|
115
|
+
background: "var(--tmd-accent-disabled, #959595) !important",
|
|
116
|
+
pointerEvents: "none",
|
|
117
|
+
opacity: "0.7"
|
|
118
|
+
}
|
|
119
|
+
});
|
|
120
|
+
const scrollContainerClassName = getDynamicClass({
|
|
121
|
+
base: {
|
|
122
|
+
display: "flex",
|
|
123
|
+
flexDirection: "column",
|
|
124
|
+
gap: "14px",
|
|
125
|
+
padding: "4px",
|
|
126
|
+
overflowY: "auto",
|
|
127
|
+
scrollbarWidth: "none"
|
|
128
|
+
}
|
|
129
|
+
});
|
|
130
|
+
const scrollbarStyle = document.createElement("style");
|
|
131
|
+
scrollbarStyle.textContent = `.${scrollContainerClassName}::-webkit-scrollbar { display: none; }`;
|
|
132
|
+
const dialog = /* @__PURE__ */ jsxs(Dialog, { wide: true, children: [
|
|
133
|
+
/* @__PURE__ */ jsxs("div", { style: { display: "flex", flexDirection: "row", alignItems: "center", justifyContent: "space-between" }, children: [
|
|
134
|
+
/* @__PURE__ */ jsx(DialogText, { style: { fontSize: "2em", fontWeight: "bold" }, children: "Toast themes" }),
|
|
135
|
+
/* @__PURE__ */ jsx(DialogCloseButton, { onClick: () => dialog.close() })
|
|
136
|
+
] }),
|
|
137
|
+
/* @__PURE__ */ jsx("div", { class: scrollContainerClassName, children: [...themes].sort((a, b) => {
|
|
138
|
+
const tierOrder = { R: 0, SR: 1, SSR: 2 };
|
|
139
|
+
return tierOrder[a.theme.tier] - tierOrder[b.theme.tier];
|
|
140
|
+
}).map((t, i) => {
|
|
141
|
+
const currentTierClassName = getDynamicClass({
|
|
142
|
+
base: {
|
|
143
|
+
position: "absolute",
|
|
144
|
+
top: "12px",
|
|
145
|
+
right: "14px",
|
|
146
|
+
fontSize: "25px",
|
|
147
|
+
...tierStyles[t.theme.tier]
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
if (!isToastThemeUnlocked(t.theme)) {
|
|
151
|
+
return /* @__PURE__ */ jsxs("div", { class: themeCardClassName, style: { paddingBottom: "20px" }, children: [
|
|
152
|
+
/* @__PURE__ */ jsx("span", { style: { fontWeight: "bold", fontSize: "22px" }, children: "????" }),
|
|
153
|
+
/* @__PURE__ */ jsx("span", { class: currentTierClassName, children: t.theme.tier }),
|
|
154
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "16px", opacity: "0.75" }, children: "You should unlock this theme first." })
|
|
155
|
+
] });
|
|
156
|
+
}
|
|
157
|
+
let previewType = "info";
|
|
158
|
+
let showButtons = false;
|
|
159
|
+
const createPreview = () => {
|
|
160
|
+
const previewButtons = [
|
|
161
|
+
{
|
|
162
|
+
name: "Button 1",
|
|
163
|
+
action: () => {
|
|
164
|
+
}
|
|
165
|
+
},
|
|
166
|
+
{
|
|
167
|
+
name: "Button 2",
|
|
168
|
+
action: () => {
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
];
|
|
172
|
+
const renderData = previewType === "spinner" ? {
|
|
173
|
+
message: "Awesome theme!",
|
|
174
|
+
isInteractable: false,
|
|
175
|
+
id: i.toString(),
|
|
176
|
+
type: previewType,
|
|
177
|
+
size: {
|
|
178
|
+
scaleWithCanvas: false,
|
|
179
|
+
scaleFactor: 1
|
|
180
|
+
},
|
|
181
|
+
buttons: showButtons ? previewButtons : void 0
|
|
182
|
+
} : {
|
|
183
|
+
message: "Awesome theme!",
|
|
184
|
+
duration: 0,
|
|
185
|
+
isInteractable: false,
|
|
186
|
+
id: i.toString(),
|
|
187
|
+
type: previewType,
|
|
188
|
+
size: {
|
|
189
|
+
scaleWithCanvas: false,
|
|
190
|
+
scaleFactor: 1
|
|
191
|
+
},
|
|
192
|
+
buttons: showButtons ? previewButtons : void 0
|
|
193
|
+
};
|
|
194
|
+
const preview = t.theme.render(renderData);
|
|
195
|
+
preview.style.width = "fit-content";
|
|
196
|
+
preview.style.maxWidth = "100%";
|
|
197
|
+
return preview;
|
|
198
|
+
};
|
|
199
|
+
const toastPreviewContainer = /* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "flex-start", alignItems: "flex-start", width: "100%", minHeight: "60px" }, children: createPreview() });
|
|
200
|
+
const updatePreview = () => {
|
|
201
|
+
toastPreviewContainer.replaceChildren(createPreview());
|
|
202
|
+
};
|
|
203
|
+
const typeButtons = toastTypes.map(({ type, name }) => {
|
|
204
|
+
const button = /* @__PURE__ */ jsx(
|
|
205
|
+
DialogButton,
|
|
206
|
+
{
|
|
207
|
+
variant: "outline",
|
|
208
|
+
class: typeButtonClassName,
|
|
209
|
+
onClick: () => {
|
|
210
|
+
previewType = type;
|
|
211
|
+
updatePreview();
|
|
212
|
+
},
|
|
213
|
+
children: name
|
|
214
|
+
}
|
|
215
|
+
);
|
|
216
|
+
return { type, button };
|
|
217
|
+
});
|
|
218
|
+
return /* @__PURE__ */ jsxs("div", { class: themeCardClassName, children: [
|
|
219
|
+
/* @__PURE__ */ jsx("span", { style: { fontWeight: "700", fontSize: "22px", paddingRight: "70px" }, children: t.theme.name }),
|
|
220
|
+
/* @__PURE__ */ jsx("span", { class: currentTierClassName, children: t.theme.tier }),
|
|
221
|
+
/* @__PURE__ */ jsxs("div", { class: sectionContainerClassName, children: [
|
|
222
|
+
/* @__PURE__ */ jsx("span", { class: sectionTitleClassName, children: "Details" }),
|
|
223
|
+
/* @__PURE__ */ jsx("span", { class: detailsClassName, children: t.theme.details })
|
|
224
|
+
] }),
|
|
225
|
+
/* @__PURE__ */ jsxs("div", { class: sectionContainerClassName, children: [
|
|
226
|
+
/* @__PURE__ */ jsx("span", { class: sectionTitleClassName, children: "Preview Controls" }),
|
|
227
|
+
/* @__PURE__ */ jsx("div", { class: typesContainerClassName, children: typeButtons.map((b) => b.button) }),
|
|
228
|
+
/* @__PURE__ */ jsxs("label", { style: { display: "inline-flex", gap: "8px", alignItems: "center", cursor: "pointer", fontSize: "15px" }, children: [
|
|
229
|
+
/* @__PURE__ */ jsx(
|
|
230
|
+
"input",
|
|
231
|
+
{
|
|
232
|
+
type: "checkbox",
|
|
233
|
+
style: { accentColor: "var(--tmd-accent, #555)", width: "20px", height: "20px" },
|
|
234
|
+
onChange: (event) => {
|
|
235
|
+
showButtons = event.currentTarget.checked;
|
|
236
|
+
updatePreview();
|
|
237
|
+
}
|
|
238
|
+
}
|
|
239
|
+
),
|
|
240
|
+
"Show Buttons"
|
|
241
|
+
] })
|
|
242
|
+
] }),
|
|
243
|
+
/* @__PURE__ */ jsxs("div", { class: sectionContainerClassName, children: [
|
|
244
|
+
/* @__PURE__ */ jsx("span", { class: sectionTitleClassName, children: "Preview" }),
|
|
245
|
+
toastPreviewContainer
|
|
246
|
+
] }),
|
|
247
|
+
/* @__PURE__ */ jsx("div", { style: { display: "flex", justifyContent: "flex-end" }, children: /* @__PURE__ */ jsx(
|
|
248
|
+
"button",
|
|
249
|
+
{
|
|
250
|
+
class: setAsDefaultButtonClassName,
|
|
251
|
+
disabled: activeThemeId === t.id,
|
|
252
|
+
onClick: (event) => {
|
|
253
|
+
const buttons = document.getElementsByClassName(setAsDefaultButtonClassName);
|
|
254
|
+
for (const button of buttons) {
|
|
255
|
+
button.disabled = false;
|
|
256
|
+
}
|
|
257
|
+
event.currentTarget.disabled = true;
|
|
258
|
+
activeThemeId = t.id;
|
|
259
|
+
setActiveToastTheme(t.theme);
|
|
260
|
+
},
|
|
261
|
+
children: "Set as default"
|
|
262
|
+
}
|
|
263
|
+
) })
|
|
264
|
+
] });
|
|
265
|
+
}) })
|
|
266
|
+
] });
|
|
267
|
+
document.head.append(scrollbarStyle);
|
|
268
|
+
dialog.addEventListener("close", () => scrollbarStyle.remove(), { once: true });
|
|
269
|
+
document.body.append(dialog);
|
|
270
|
+
dialog.showModal();
|
|
271
|
+
}
|
|
272
|
+
export {
|
|
273
|
+
createThemesDialog
|
|
274
|
+
};
|