zois-core 1.2.1 → 2.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.
- package/README.md +23 -2
- package/dist/assets/icons/exit.svg +17 -0
- package/dist/changelogs.js +153 -0
- package/dist/core-subscreen/coreSubscreen.js +81 -0
- package/dist/core-subscreen/developmentSubscreen.js +22 -0
- package/dist/core-subscreen/generalSubscreen.js +23 -0
- package/dist/core-subscreen/mainSubscreen.js +58 -0
- package/dist/core-subscreen/shards/coreButtonShard.js +30 -0
- package/dist/core-subscreen/shards/coreCheckboxShard.js +33 -0
- package/dist/core-subscreen/shards/coreInputListShard.js +38 -0
- package/dist/core-subscreen/shards/coreSelectShard.js +17 -0
- package/dist/core-subscreen/shards/coreTextShard.js +9 -0
- package/dist/core-subscreen/shards/index.js +5 -0
- package/dist/core-subscreen/toastsSubscreen.js +112 -0
- package/dist/core.js +178 -0
- package/dist/dialogs.js +110 -0
- package/dist/index.js +201 -1
- package/dist/localization.js +71 -0
- package/dist/logging.js +31 -0
- package/dist/messaging.js +234 -1
- package/dist/modSdk.js +63 -0
- package/dist/shard-modules/attributesModule.js +16 -0
- package/dist/shard-modules/centerModule.js +12 -0
- package/dist/shard-modules/clickModule.js +14 -0
- package/dist/shard-modules/counterUpModule.js +37 -0
- package/dist/shard-modules/dynamicClassModule.js +15 -0
- package/dist/shard-modules/index.js +9 -0
- package/dist/shard-modules/multiClickModule.js +41 -0
- package/dist/shard-modules/shardModule.js +12 -0
- package/dist/shard-modules/styleModule.js +20 -0
- package/dist/shard-modules/typeModule.js +37 -0
- package/dist/shards/backNextButtonShard.js +99 -0
- package/dist/shards/buttonShard.js +150 -0
- package/dist/shards/cardShard.js +35 -0
- package/dist/shards/checkboxShard.js +139 -0
- package/dist/shards/containerShard.js +16 -0
- package/dist/shards/imageShard.js +98 -0
- package/dist/shards/index.js +13 -0
- package/dist/shards/inputListShard.js +162 -0
- package/dist/shards/inputShard.js +33 -0
- package/dist/shards/selectShard.js +126 -0
- package/dist/shards/shard.js +79 -0
- package/dist/shards/svgShard.js +29 -0
- package/dist/shards/tabsShard.js +59 -0
- package/dist/shards/textShard.js +27 -0
- package/dist/styles.css +209 -1
- package/dist/toasts.js +189 -0
- package/dist/types/changelogs.d.ts +1 -0
- package/dist/types/core-subscreen/coreSubscreen.d.ts +15 -0
- package/dist/types/core-subscreen/developmentSubscreen.d.ts +5 -0
- package/dist/types/core-subscreen/generalSubscreen.d.ts +5 -0
- package/dist/types/core-subscreen/mainSubscreen.d.ts +6 -0
- package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +5 -0
- package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +6 -0
- package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +6 -0
- package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +5 -0
- package/dist/types/core-subscreen/shards/coreTextShard.d.ts +4 -0
- package/dist/types/core-subscreen/shards/index.d.ts +5 -0
- package/dist/types/core-subscreen/toastsSubscreen.d.ts +5 -0
- package/dist/types/core.d.ts +18 -0
- package/dist/types/dialogs.d.ts +29 -0
- package/dist/types/globals.d.ts +6 -0
- package/dist/types/index.d.ts +62 -6
- package/dist/types/localization.d.ts +4 -0
- package/dist/types/logging.d.ts +16 -0
- package/dist/types/messaging.d.ts +5 -3
- package/dist/types/{modsApi.d.ts → modSdk.d.ts} +2 -2
- package/dist/types/shard-modules/attributesModule.d.ts +7 -0
- package/dist/types/shard-modules/centerModule.d.ts +5 -0
- package/dist/types/shard-modules/clickModule.d.ts +7 -0
- package/dist/types/shard-modules/counterUpModule.d.ts +13 -0
- package/dist/types/shard-modules/dynamicClassModule.d.ts +8 -0
- package/dist/types/{ui-modules → shard-modules}/index.d.ts +2 -0
- package/dist/types/shard-modules/multiClickModule.d.ts +12 -0
- package/dist/types/shard-modules/shardModule.d.ts +7 -0
- package/dist/types/shard-modules/styleModule.d.ts +8 -0
- package/dist/types/shard-modules/typeModule.d.ts +11 -0
- package/dist/types/shards/backNextButtonShard.d.ts +14 -0
- package/dist/types/shards/buttonShard.d.ts +21 -0
- package/dist/types/shards/cardShard.d.ts +10 -0
- package/dist/types/shards/checkboxShard.d.ts +19 -0
- package/dist/types/shards/containerShard.d.ts +7 -0
- package/dist/types/shards/imageShard.d.ts +11 -0
- package/dist/types/shards/index.d.ts +13 -0
- package/dist/types/shards/inputListShard.d.ts +16 -0
- package/dist/types/shards/inputShard.d.ts +14 -0
- package/dist/types/shards/selectShard.d.ts +17 -0
- package/dist/types/shards/shard.d.ts +21 -0
- package/dist/types/shards/svgShard.d.ts +12 -0
- package/dist/types/shards/tabsShard.d.ts +17 -0
- package/dist/types/shards/textShard.d.ts +13 -0
- package/dist/types/toasts.d.ts +21 -0
- package/dist/types/ui.d.ts +35 -148
- package/dist/ui.js +375 -11
- package/dist/validation.js +31 -1
- package/dist/wardrobe.js +167 -1
- package/package.json +47 -26
- package/scripts/zois-core.mjs +126 -0
- package/dist/modsApi.js +0 -1
- package/dist/modules.js +0 -1
- package/dist/popups.js +0 -1
- package/dist/types/modules.d.ts +0 -18
- package/dist/types/popups.d.ts +0 -63
- package/dist/types/ui-modules/attributesModule.d.ts +0 -6
- package/dist/types/ui-modules/centerModule.d.ts +0 -4
- package/dist/types/ui-modules/clickModule.d.ts +0 -6
- package/dist/types/ui-modules/counterUpModule.d.ts +0 -12
- package/dist/types/ui-modules/dynamicClassModule.d.ts +0 -7
- package/dist/types/ui-modules/styleModule.d.ts +0 -7
- package/dist/types/ui-modules/typeModule.d.ts +0 -10
- package/dist/ui-modules/attributesModule.js +0 -1
- package/dist/ui-modules/centerModule.js +0 -1
- package/dist/ui-modules/clickModule.js +0 -1
- package/dist/ui-modules/counterUpModule.js +0 -1
- package/dist/ui-modules/dynamicClassModule.js +0 -1
- package/dist/ui-modules/index.js +0 -1
- package/dist/ui-modules/styleModule.js +0 -1
- package/dist/ui-modules/typeModule.js +0 -1
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
import { createElement, ExternalLink } from "lucide";
|
|
2
|
+
import { MOD_DATA } from "../index";
|
|
3
|
+
import { addDynamicClass, autosetFontSize, setFontFamily, setFontSize } from "../ui";
|
|
4
|
+
import { Shard } from "./shard";
|
|
5
|
+
class ButtonShard extends Shard {
|
|
6
|
+
get dynamicClassButton() {
|
|
7
|
+
return {
|
|
8
|
+
base: {
|
|
9
|
+
cursor: "pointer",
|
|
10
|
+
background: "var(--tmd-element, white)",
|
|
11
|
+
color: "var(--tmd-text, black)",
|
|
12
|
+
border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
|
|
13
|
+
borderRadius: "6px"
|
|
14
|
+
},
|
|
15
|
+
hover: {
|
|
16
|
+
background: "var(--tmd-element-hover, #ebf7fe)",
|
|
17
|
+
borderColor: "var(--tmd-accent-hover, #7dd3fc)",
|
|
18
|
+
color: "var(--tmd-accent-hover, #015a8c)"
|
|
19
|
+
},
|
|
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
|
+
"[data-zc-variant=filled]": {
|
|
41
|
+
background: "var(--tmd-accent, #111)",
|
|
42
|
+
border: "2px solid var(--tmd-accent, #111)",
|
|
43
|
+
color: "var(--tmd-text, white)"
|
|
44
|
+
},
|
|
45
|
+
"[data-zc-variant=filled]:hover": {
|
|
46
|
+
background: "var(--tmd-accent-hover, none)",
|
|
47
|
+
color: "var(--tmd-text, black)"
|
|
48
|
+
},
|
|
49
|
+
"> .external-link-icon": {
|
|
50
|
+
display: "flex",
|
|
51
|
+
columnGap: "0.25em",
|
|
52
|
+
position: "absolute",
|
|
53
|
+
right: "-0.25em",
|
|
54
|
+
top: "-0.25em",
|
|
55
|
+
width: "0.75em",
|
|
56
|
+
height: "0.75em",
|
|
57
|
+
background: "var(--tmd-accent, #5b5bff)",
|
|
58
|
+
color: "var(--tmd-text, white)",
|
|
59
|
+
padding: "0.1em",
|
|
60
|
+
borderRadius: "50%"
|
|
61
|
+
},
|
|
62
|
+
":hover > .external-link-icon": {
|
|
63
|
+
minWidth: "fit-content",
|
|
64
|
+
padding: "0.1em 0.25em",
|
|
65
|
+
borderRadius: "0.5em",
|
|
66
|
+
bottom: "calc(100% + 0.25em)",
|
|
67
|
+
top: "unset"
|
|
68
|
+
},
|
|
69
|
+
"> .external-link-icon > span": {
|
|
70
|
+
display: "none",
|
|
71
|
+
fontSize: "0.5em",
|
|
72
|
+
whiteSpace: "nowrap"
|
|
73
|
+
},
|
|
74
|
+
":hover > .external-link-icon > span": {
|
|
75
|
+
display: "inline"
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
generateBody() {
|
|
80
|
+
const { text, variant, icon, iconAbsolutePosition = true, tooltip, href, onClick, isDisabled } = this.context;
|
|
81
|
+
let iconElement;
|
|
82
|
+
let textElement;
|
|
83
|
+
const btn = document.createElement("button");
|
|
84
|
+
addDynamicClass(btn, this.dynamicClassButton);
|
|
85
|
+
btn.setAttribute("data-zc-variant", variant);
|
|
86
|
+
btn.style.display = "flex";
|
|
87
|
+
btn.style.alignItems = "center";
|
|
88
|
+
btn.style.justifyContent = "center";
|
|
89
|
+
btn.style.columnGap = "1.25vw";
|
|
90
|
+
setFontFamily(btn, MOD_DATA.fontFamily);
|
|
91
|
+
if (icon) {
|
|
92
|
+
if (typeof icon === "string") {
|
|
93
|
+
iconElement = document.createElement("img");
|
|
94
|
+
iconElement.src = icon;
|
|
95
|
+
} else {
|
|
96
|
+
iconElement = icon;
|
|
97
|
+
}
|
|
98
|
+
iconElement.style.height = "80%";
|
|
99
|
+
iconElement.style.width = "auto";
|
|
100
|
+
if (text && iconAbsolutePosition) {
|
|
101
|
+
iconElement.style.position = "absolute";
|
|
102
|
+
iconElement.style.left = "1vw";
|
|
103
|
+
}
|
|
104
|
+
if (text && !iconAbsolutePosition) btn.style.justifyContent = "";
|
|
105
|
+
btn.append(iconElement);
|
|
106
|
+
}
|
|
107
|
+
if (text) {
|
|
108
|
+
textElement = document.createElement("span");
|
|
109
|
+
textElement.textContent = text;
|
|
110
|
+
btn.append(textElement);
|
|
111
|
+
}
|
|
112
|
+
if (tooltip) {
|
|
113
|
+
const tooltipEl = document.createElement("span");
|
|
114
|
+
tooltipEl.classList.add("tooltip");
|
|
115
|
+
tooltipEl.setAttribute("position", tooltip.position);
|
|
116
|
+
tooltipEl.textContent = tooltip.text;
|
|
117
|
+
btn.append(tooltipEl);
|
|
118
|
+
}
|
|
119
|
+
if (href) {
|
|
120
|
+
const externalLinkContainer = document.createElement("div");
|
|
121
|
+
externalLinkContainer.classList.add("external-link-icon");
|
|
122
|
+
const externalLinkIcon = createElement(ExternalLink);
|
|
123
|
+
externalLinkIcon.style.width = "auto";
|
|
124
|
+
externalLinkIcon.style.height = "100%";
|
|
125
|
+
const externalLinkLabel = document.createElement("span");
|
|
126
|
+
externalLinkLabel.textContent = href;
|
|
127
|
+
externalLinkContainer.append(externalLinkIcon, externalLinkLabel);
|
|
128
|
+
btn.append(externalLinkContainer);
|
|
129
|
+
}
|
|
130
|
+
if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
|
|
131
|
+
btn.addEventListener("click", () => {
|
|
132
|
+
if (typeof isDisabled === "function" && isDisabled()) return btn.classList.add("zcDisabled");
|
|
133
|
+
if (typeof onClick === "function") onClick();
|
|
134
|
+
if (href) window.open(href, "_blank", "noopener,noreferrer");
|
|
135
|
+
});
|
|
136
|
+
return {
|
|
137
|
+
text: textElement,
|
|
138
|
+
icon: iconElement,
|
|
139
|
+
base: btn
|
|
140
|
+
};
|
|
141
|
+
}
|
|
142
|
+
update() {
|
|
143
|
+
super.update();
|
|
144
|
+
if ((this.context.fontSize ?? "auto") === "auto") autosetFontSize(this.body.base);
|
|
145
|
+
else if (typeof this.context.fontSize === "number") setFontSize(this.body.base, this.context.fontSize);
|
|
146
|
+
}
|
|
147
|
+
}
|
|
148
|
+
export {
|
|
149
|
+
ButtonShard
|
|
150
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { MOD_DATA } from "../index";
|
|
2
|
+
import { autosetFontSize, setFontFamily } from "../ui";
|
|
3
|
+
import { Shard } from "./shard";
|
|
4
|
+
class CardShard extends Shard {
|
|
5
|
+
generateBody() {
|
|
6
|
+
const { name, value, icon } = this.context;
|
|
7
|
+
const cardEl = document.createElement("div");
|
|
8
|
+
cardEl.classList.add("zcCard");
|
|
9
|
+
setFontFamily(cardEl, MOD_DATA.fontFamily);
|
|
10
|
+
const cardName = document.createElement("p");
|
|
11
|
+
cardName.classList.add("zcCard_name");
|
|
12
|
+
cardName.textContent = name;
|
|
13
|
+
const cardValue = document.createElement("p");
|
|
14
|
+
cardValue.classList.add("zcCard_value");
|
|
15
|
+
cardValue.textContent = `${value}`;
|
|
16
|
+
if (icon) {
|
|
17
|
+
icon.style.cssText += "position: absolute; top: 0.4em; right: 0.4em; width: 1.2em; height: 1.2em;";
|
|
18
|
+
cardEl.append(icon);
|
|
19
|
+
}
|
|
20
|
+
cardEl.append(cardName, cardValue);
|
|
21
|
+
return {
|
|
22
|
+
base: cardEl,
|
|
23
|
+
name: cardName,
|
|
24
|
+
value: cardValue,
|
|
25
|
+
icon
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
update() {
|
|
29
|
+
super.update();
|
|
30
|
+
autosetFontSize(this.body.base);
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
export {
|
|
34
|
+
CardShard
|
|
35
|
+
};
|
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { MOD_DATA } from "../index";
|
|
2
|
+
import { addDynamicClass, autosetFontSize, setFontFamily } from "../ui";
|
|
3
|
+
import { Shard } from "./shard";
|
|
4
|
+
class CheckboxShard extends Shard {
|
|
5
|
+
get dynamicClassInput() {
|
|
6
|
+
return {
|
|
7
|
+
base: {
|
|
8
|
+
width: "min(6dvh, 3dvw)",
|
|
9
|
+
height: "min(6dvh, 3dvw)",
|
|
10
|
+
borderRadius: "min(0.8dvh, 0.3dvw)",
|
|
11
|
+
border: "var(--border-width, 2px) solid #333",
|
|
12
|
+
backgroundColor: "var(--checkbox-color, #fff)",
|
|
13
|
+
position: "relative",
|
|
14
|
+
cursor: "pointer",
|
|
15
|
+
display: "flex",
|
|
16
|
+
alignItems: "center",
|
|
17
|
+
justifyContent: "center",
|
|
18
|
+
transition: "all 0.3s cubic-bezier(0.4, 0, 0.2, 1)",
|
|
19
|
+
appearance: "none"
|
|
20
|
+
},
|
|
21
|
+
":checked": {
|
|
22
|
+
backgroundColor: "var(--tmd-accent, black)",
|
|
23
|
+
borderColor: "var(--tmd-accent, black)"
|
|
24
|
+
},
|
|
25
|
+
":checked > svg": {
|
|
26
|
+
strokeDashoffset: "0"
|
|
27
|
+
},
|
|
28
|
+
":checked:hover": {
|
|
29
|
+
backgroundColor: "var(--tmd-accent-hover, black)"
|
|
30
|
+
},
|
|
31
|
+
".zcDisabled": {
|
|
32
|
+
opacity: "0.6",
|
|
33
|
+
cursor: "not-allowed",
|
|
34
|
+
backgroundColor: "var(--disabled-color, #e5e5e5)"
|
|
35
|
+
},
|
|
36
|
+
".pop": {
|
|
37
|
+
animation: "pop 0.4s cubic-bezier(0.34, 1.56, 0.64, 1) forwards"
|
|
38
|
+
},
|
|
39
|
+
"> .tooltip": {
|
|
40
|
+
position: "absolute",
|
|
41
|
+
color: "var(--tmd-text, black)",
|
|
42
|
+
fontSize: "0.65em",
|
|
43
|
+
textAlign: "center",
|
|
44
|
+
padding: "0.3em 0.6em",
|
|
45
|
+
borderRadius: "4px",
|
|
46
|
+
background: "var(--tmd-element-hint, #e6e6e6)",
|
|
47
|
+
width: "max-content",
|
|
48
|
+
visibility: "hidden",
|
|
49
|
+
zIndex: "10"
|
|
50
|
+
},
|
|
51
|
+
"> .tooltip[position=left]": {
|
|
52
|
+
right: "calc(100% + 1vw)"
|
|
53
|
+
},
|
|
54
|
+
"> .tooltip[position=right]": {
|
|
55
|
+
left: "calc(100% + 1vw)"
|
|
56
|
+
},
|
|
57
|
+
":hover .tooltip": {
|
|
58
|
+
visibility: "visible"
|
|
59
|
+
}
|
|
60
|
+
};
|
|
61
|
+
}
|
|
62
|
+
get dynamicClassCheckmark() {
|
|
63
|
+
return {
|
|
64
|
+
base: {
|
|
65
|
+
width: "70%",
|
|
66
|
+
height: "70%",
|
|
67
|
+
stroke: "var(--tmd-text, white)",
|
|
68
|
+
strokeWidth: "3.5",
|
|
69
|
+
strokeLinecap: "round",
|
|
70
|
+
strokeLinejoin: "round",
|
|
71
|
+
fill: "none",
|
|
72
|
+
strokeDasharray: "24",
|
|
73
|
+
strokeDashoffset: "24",
|
|
74
|
+
transition: "stroke-dashoffset 0.45s cubic-bezier(0.25, 0.1, 0.25, 1)"
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
get textColor() {
|
|
79
|
+
return "var(--tmd-text, black)";
|
|
80
|
+
}
|
|
81
|
+
generateBody() {
|
|
82
|
+
const { isChecked, text, tooltip, onChange, isDisabled } = this.context;
|
|
83
|
+
const wrapper = document.createElement("div");
|
|
84
|
+
wrapper.style.display = "flex";
|
|
85
|
+
wrapper.style.alignItems = "center";
|
|
86
|
+
wrapper.style.columnGap = "1vw";
|
|
87
|
+
wrapper.style.padding = "0.25em";
|
|
88
|
+
const input = document.createElement("input");
|
|
89
|
+
input.type = "checkbox";
|
|
90
|
+
input.checked = isChecked;
|
|
91
|
+
input.classList.add("zcCheckbox");
|
|
92
|
+
addDynamicClass(input, this.dynamicClassInput);
|
|
93
|
+
const checkmark = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
94
|
+
checkmark.setAttribute("viewBox", "0 0 24 24");
|
|
95
|
+
checkmark.setAttribute("class", "checkmark");
|
|
96
|
+
checkmark.innerHTML = `<path d="M5 13L9 17L19 7" />`;
|
|
97
|
+
addDynamicClass(checkmark, this.dynamicClassCheckmark);
|
|
98
|
+
const label = document.createElement("p");
|
|
99
|
+
label.textContent = text;
|
|
100
|
+
label.style.color = this.textColor;
|
|
101
|
+
setFontFamily(label, MOD_DATA.fontFamily);
|
|
102
|
+
if (typeof isDisabled === "function" && isDisabled()) {
|
|
103
|
+
input.disabled = true;
|
|
104
|
+
wrapper.classList.add("zcDisabled");
|
|
105
|
+
}
|
|
106
|
+
input.addEventListener("change", () => {
|
|
107
|
+
if (typeof isDisabled === "function" && isDisabled()) {
|
|
108
|
+
input.checked = !input.checked;
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
if (typeof onChange === "function") onChange();
|
|
112
|
+
if (input.checked) {
|
|
113
|
+
}
|
|
114
|
+
});
|
|
115
|
+
input.appendChild(checkmark);
|
|
116
|
+
wrapper.append(input, label);
|
|
117
|
+
if (tooltip) {
|
|
118
|
+
const tooltipEl = document.createElement("span");
|
|
119
|
+
tooltipEl.classList.add("tooltip");
|
|
120
|
+
tooltipEl.setAttribute("position", tooltip.position);
|
|
121
|
+
tooltipEl.textContent = tooltip.text;
|
|
122
|
+
input.appendChild(tooltipEl);
|
|
123
|
+
}
|
|
124
|
+
return {
|
|
125
|
+
base: wrapper,
|
|
126
|
+
checkbox: input,
|
|
127
|
+
label
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
update() {
|
|
131
|
+
super.update();
|
|
132
|
+
if (this.body?.base) {
|
|
133
|
+
autosetFontSize(this.body.base);
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
}
|
|
137
|
+
export {
|
|
138
|
+
CheckboxShard
|
|
139
|
+
};
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { Shard } from "./shard";
|
|
2
|
+
class ContainerShard extends Shard {
|
|
3
|
+
generateBody() {
|
|
4
|
+
const container = document.createElement("div");
|
|
5
|
+
if (this.context.scroll === "all") container.style.overflow = "scroll";
|
|
6
|
+
if (this.context.scroll === "x") container.style.overflowX = "scroll";
|
|
7
|
+
if (this.context.scroll === "y") container.style.overflowY = "scroll";
|
|
8
|
+
if (this.context.scroll === "auto") container.style.overflow = "auto";
|
|
9
|
+
return {
|
|
10
|
+
base: container
|
|
11
|
+
};
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
export {
|
|
15
|
+
ContainerShard
|
|
16
|
+
};
|
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { Shard } from "./shard";
|
|
2
|
+
class ImageShard extends Shard {
|
|
3
|
+
modal = null;
|
|
4
|
+
generateBody() {
|
|
5
|
+
const { src, alt = "", width, height } = this.context;
|
|
6
|
+
const img = document.createElement("img");
|
|
7
|
+
img.src = src;
|
|
8
|
+
img.alt = alt;
|
|
9
|
+
img.style.cursor = "zoom-in";
|
|
10
|
+
img.style.maxWidth = "100%";
|
|
11
|
+
img.style.height = "auto";
|
|
12
|
+
img.addEventListener("click", () => this.openModal(src, alt));
|
|
13
|
+
return {
|
|
14
|
+
base: img
|
|
15
|
+
};
|
|
16
|
+
}
|
|
17
|
+
openModal(src, alt) {
|
|
18
|
+
this.closeModal();
|
|
19
|
+
this.modal = document.createElement("div");
|
|
20
|
+
this.modal.style.cssText = `
|
|
21
|
+
position: fixed;
|
|
22
|
+
top: 0;
|
|
23
|
+
left: 0;
|
|
24
|
+
width: 100vw;
|
|
25
|
+
height: 100vh;
|
|
26
|
+
background: rgba(0, 0, 0, 0.9);
|
|
27
|
+
display: flex;
|
|
28
|
+
align-items: center;
|
|
29
|
+
justify-content: center;
|
|
30
|
+
z-index: 100;
|
|
31
|
+
opacity: 0;
|
|
32
|
+
transition: opacity 0.3s ease;
|
|
33
|
+
`;
|
|
34
|
+
const modalContent = document.createElement("div");
|
|
35
|
+
modalContent.style.cssText = `
|
|
36
|
+
position: relative;
|
|
37
|
+
max-width: 90vw;
|
|
38
|
+
max-height: 90vh;
|
|
39
|
+
transform: scale(0.7);
|
|
40
|
+
transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
|
|
41
|
+
`;
|
|
42
|
+
const bigImg = document.createElement("img");
|
|
43
|
+
bigImg.src = src;
|
|
44
|
+
bigImg.alt = alt;
|
|
45
|
+
bigImg.style.cssText = `
|
|
46
|
+
max-width: 100%;
|
|
47
|
+
max-height: 90vh;
|
|
48
|
+
box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
|
|
49
|
+
`;
|
|
50
|
+
const closeBtn = document.createElement("button");
|
|
51
|
+
closeBtn.innerHTML = "\u2715";
|
|
52
|
+
closeBtn.style.cssText = `
|
|
53
|
+
position: absolute;
|
|
54
|
+
top: -15px;
|
|
55
|
+
right: -15px;
|
|
56
|
+
width: 40px;
|
|
57
|
+
height: 40px;
|
|
58
|
+
border-radius: 50%;
|
|
59
|
+
background: white;
|
|
60
|
+
color: black;
|
|
61
|
+
font-size: 20px;
|
|
62
|
+
border: none;
|
|
63
|
+
cursor: pointer;
|
|
64
|
+
display: flex;
|
|
65
|
+
align-items: center;
|
|
66
|
+
justify-content: center;
|
|
67
|
+
box-shadow: 0 4px 12px rgba(0,0,0,0.3);
|
|
68
|
+
z-index: 10000;
|
|
69
|
+
`;
|
|
70
|
+
modalContent.appendChild(bigImg);
|
|
71
|
+
modalContent.appendChild(closeBtn);
|
|
72
|
+
this.modal.appendChild(modalContent);
|
|
73
|
+
document.body.appendChild(this.modal);
|
|
74
|
+
setTimeout(() => {
|
|
75
|
+
this.modal.style.opacity = "1";
|
|
76
|
+
modalContent.style.transform = "scale(1)";
|
|
77
|
+
}, 10);
|
|
78
|
+
const close = () => this.closeModal();
|
|
79
|
+
closeBtn.addEventListener("click", close);
|
|
80
|
+
this.modal.addEventListener("click", (e) => {
|
|
81
|
+
if (e.target === this.modal) close();
|
|
82
|
+
});
|
|
83
|
+
document.addEventListener("keydown", (e) => {
|
|
84
|
+
if (e.key === "Escape") close();
|
|
85
|
+
}, { once: true });
|
|
86
|
+
}
|
|
87
|
+
closeModal() {
|
|
88
|
+
if (!this.modal) return;
|
|
89
|
+
this.modal.style.opacity = "0";
|
|
90
|
+
setTimeout(() => {
|
|
91
|
+
this.modal?.remove();
|
|
92
|
+
this.modal = null;
|
|
93
|
+
}, 300);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
export {
|
|
97
|
+
ImageShard
|
|
98
|
+
};
|
|
@@ -0,0 +1,13 @@
|
|
|
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";
|
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { MOD_DATA } from "../index";
|
|
2
|
+
import { addDynamicClass, setFontFamily } from "../ui";
|
|
3
|
+
import { Shard } from "./shard";
|
|
4
|
+
import { createElement, RotateCcw, Trash2 } from "lucide";
|
|
5
|
+
class InputListShard extends Shard {
|
|
6
|
+
get dynamicClassContainer() {
|
|
7
|
+
return {
|
|
8
|
+
base: {
|
|
9
|
+
display: "flex",
|
|
10
|
+
flexDirection: "column",
|
|
11
|
+
gap: "1vw",
|
|
12
|
+
border: "2px solid var(--tmd-accent, black)",
|
|
13
|
+
borderRadius: "4px",
|
|
14
|
+
padding: "0.75vw",
|
|
15
|
+
background: "var(--tmd-element, none)"
|
|
16
|
+
},
|
|
17
|
+
"> div:first-child": {
|
|
18
|
+
display: "flex",
|
|
19
|
+
justifyContent: "space-between",
|
|
20
|
+
alignItems: "center",
|
|
21
|
+
columnGap: "0.75vw",
|
|
22
|
+
width: "100%"
|
|
23
|
+
},
|
|
24
|
+
"> div:first-child > b": {
|
|
25
|
+
fontSize: "clamp(10px, 2.4vw, 28px)",
|
|
26
|
+
color: "var(--tmd-text, black)"
|
|
27
|
+
},
|
|
28
|
+
"> div:first-child > div:last-child": {
|
|
29
|
+
display: "flex",
|
|
30
|
+
columnGap: "0.75vw"
|
|
31
|
+
},
|
|
32
|
+
"> div:last-child": {
|
|
33
|
+
display: "flex",
|
|
34
|
+
gap: "0.25em",
|
|
35
|
+
alignContent: "flex-start",
|
|
36
|
+
flexWrap: "wrap",
|
|
37
|
+
overflowY: "scroll",
|
|
38
|
+
width: "100%"
|
|
39
|
+
},
|
|
40
|
+
"> div:last-child > div": {
|
|
41
|
+
cursor: "pointer",
|
|
42
|
+
background: "var(--tmd-element-hover, rgb(206, 206, 206))",
|
|
43
|
+
color: "var(--tmd-text, black)",
|
|
44
|
+
height: "fit-content",
|
|
45
|
+
padding: "0.25em 0.45em",
|
|
46
|
+
borderRadius: "0.25em",
|
|
47
|
+
fontSize: "clamp(8px, 1.85vw, 24px)"
|
|
48
|
+
}
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
get dynamicClassInput() {
|
|
52
|
+
return {
|
|
53
|
+
base: {
|
|
54
|
+
border: "none !important",
|
|
55
|
+
outline: "none !important",
|
|
56
|
+
background: "none !important",
|
|
57
|
+
flexGrow: "1",
|
|
58
|
+
width: "6vw",
|
|
59
|
+
fontSize: "clamp(8px, 1.85vw, 20px)"
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
get dynamicClassToolsButton() {
|
|
64
|
+
return {
|
|
65
|
+
base: {
|
|
66
|
+
cursor: "pointer",
|
|
67
|
+
display: "grid",
|
|
68
|
+
placeItems: "center",
|
|
69
|
+
background: "var(--tmd-accent, #333)",
|
|
70
|
+
color: "white",
|
|
71
|
+
width: "2.5vw",
|
|
72
|
+
aspectRatio: "1/1",
|
|
73
|
+
borderRadius: "8px",
|
|
74
|
+
border: "none"
|
|
75
|
+
},
|
|
76
|
+
hover: {
|
|
77
|
+
background: "var(--tmd-accent-hover, #00c2cc)"
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
generateBody() {
|
|
82
|
+
const { value, title, fontSize, numbersOnly, onChange, isDisabled } = this.context;
|
|
83
|
+
const checkbox = document.createElement("div");
|
|
84
|
+
const items = [];
|
|
85
|
+
const div = document.createElement("div");
|
|
86
|
+
addDynamicClass(div, this.dynamicClassContainer);
|
|
87
|
+
setFontFamily(div, MOD_DATA.fontFamily);
|
|
88
|
+
const headerElement = document.createElement("div");
|
|
89
|
+
const toolsElement = document.createElement("div");
|
|
90
|
+
const titleElement = document.createElement("b");
|
|
91
|
+
titleElement.textContent = title + ":";
|
|
92
|
+
const itemsElement = document.createElement("div");
|
|
93
|
+
const input = document.createElement("input");
|
|
94
|
+
addDynamicClass(input, this.dynamicClassInput);
|
|
95
|
+
const addButton = (icon, onClick) => {
|
|
96
|
+
const b = document.createElement("button");
|
|
97
|
+
addDynamicClass(b, this.dynamicClassToolsButton);
|
|
98
|
+
icon.style.cssText = "width: 80%; height: auto;";
|
|
99
|
+
b.append(icon);
|
|
100
|
+
b.addEventListener("click", onClick);
|
|
101
|
+
toolsElement.append(b);
|
|
102
|
+
};
|
|
103
|
+
const addItem = (text) => {
|
|
104
|
+
const item = document.createElement("div");
|
|
105
|
+
item.textContent = text;
|
|
106
|
+
itemsElement.insertBefore(item, input);
|
|
107
|
+
item.addEventListener("click", (e) => {
|
|
108
|
+
if (item.style.border === "") item.style.border = "2px solid red";
|
|
109
|
+
else item.style.border = "";
|
|
110
|
+
e.stopPropagation();
|
|
111
|
+
});
|
|
112
|
+
items.push(text);
|
|
113
|
+
};
|
|
114
|
+
addButton(createElement(RotateCcw), () => {
|
|
115
|
+
if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
|
|
116
|
+
itemsElement.innerHTML = "";
|
|
117
|
+
items.splice(0, items.length);
|
|
118
|
+
itemsElement.append(input);
|
|
119
|
+
value?.forEach((v) => addItem(String(v)));
|
|
120
|
+
if (typeof onChange === "function") onChange(numbersOnly ? items.map((i) => parseInt(i)) : items);
|
|
121
|
+
});
|
|
122
|
+
addButton(createElement(Trash2), () => {
|
|
123
|
+
if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
|
|
124
|
+
for (const c of [...itemsElement.children]) {
|
|
125
|
+
if (c.getAttribute("style")?.includes("border: 2px solid red;")) {
|
|
126
|
+
items.splice(items.indexOf(c.textContent), 1);
|
|
127
|
+
c.remove();
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
if (typeof onChange === "function") onChange(numbersOnly ? items.map((i) => parseInt(i)) : items);
|
|
131
|
+
});
|
|
132
|
+
if (typeof isDisabled === "function" && isDisabled()) div.classList.add("zcDisabled");
|
|
133
|
+
input.addEventListener("keypress", (e) => {
|
|
134
|
+
if (document.activeElement === input) {
|
|
135
|
+
switch (e.key) {
|
|
136
|
+
case "Enter":
|
|
137
|
+
if (numbersOnly && Number.isNaN(parseInt(input.value))) return;
|
|
138
|
+
if (input.value.trim() === "") return;
|
|
139
|
+
if (typeof isDisabled === "function" && isDisabled()) return div.classList.add("zcDisabled");
|
|
140
|
+
addItem(input.value);
|
|
141
|
+
input.value = "";
|
|
142
|
+
if (typeof onChange === "function") onChange(numbersOnly ? items.map((i) => parseInt(i)) : items);
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
div.addEventListener("click", (e) => {
|
|
148
|
+
if (e.currentTarget == div) input.focus();
|
|
149
|
+
});
|
|
150
|
+
headerElement.append(titleElement, toolsElement);
|
|
151
|
+
itemsElement.append(input);
|
|
152
|
+
div.append(headerElement, itemsElement);
|
|
153
|
+
value?.forEach((v) => addItem(String(v)));
|
|
154
|
+
return {
|
|
155
|
+
base: div,
|
|
156
|
+
input
|
|
157
|
+
};
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
export {
|
|
161
|
+
InputListShard
|
|
162
|
+
};
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { MOD_DATA } from "../index";
|
|
2
|
+
import { autosetFontSize, setFontFamily, setFontSize } from "../ui";
|
|
3
|
+
import { Shard } from "./shard";
|
|
4
|
+
class InputShard extends Shard {
|
|
5
|
+
generateBody() {
|
|
6
|
+
const { textArea, placeholder, value, isDisabled, onChange, onInput } = this.context;
|
|
7
|
+
const input = document.createElement(textArea ? "textarea" : "input");
|
|
8
|
+
input.classList.add("zcInput");
|
|
9
|
+
if (placeholder) input.placeholder = placeholder;
|
|
10
|
+
if (value) input.value = value;
|
|
11
|
+
setFontFamily(input, MOD_DATA.fontFamily);
|
|
12
|
+
if (typeof isDisabled === "function" && isDisabled()) input.classList.add("zcDisabled");
|
|
13
|
+
input.addEventListener("change", () => {
|
|
14
|
+
if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
|
|
15
|
+
if (typeof onChange === "function") onChange();
|
|
16
|
+
});
|
|
17
|
+
input.addEventListener("input", () => {
|
|
18
|
+
if (typeof isDisabled === "function" && isDisabled()) return input.classList.add("zcDisabled");
|
|
19
|
+
if (typeof onInput === "function") onInput();
|
|
20
|
+
});
|
|
21
|
+
return {
|
|
22
|
+
base: input
|
|
23
|
+
};
|
|
24
|
+
}
|
|
25
|
+
update() {
|
|
26
|
+
super.update();
|
|
27
|
+
if ((this.context.fontSize ?? "auto") === "auto") autosetFontSize(this.body.base);
|
|
28
|
+
else if (typeof this.context.fontSize === "number") setFontSize(this.body.base, this.context.fontSize);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
export {
|
|
32
|
+
InputShard
|
|
33
|
+
};
|