zois-core 1.2.1 → 2.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 (116) hide show
  1. package/README.md +23 -2
  2. package/dist/changelogs.js +167 -0
  3. package/dist/core-subscreen/coreSubscreen.js +81 -0
  4. package/dist/core-subscreen/developmentSubscreen.js +22 -0
  5. package/dist/core-subscreen/generalSubscreen.js +23 -0
  6. package/dist/core-subscreen/mainSubscreen.js +58 -0
  7. package/dist/core-subscreen/shards/coreButtonShard.js +30 -0
  8. package/dist/core-subscreen/shards/coreCheckboxShard.js +33 -0
  9. package/dist/core-subscreen/shards/coreInputListShard.js +38 -0
  10. package/dist/core-subscreen/shards/coreSelectShard.js +17 -0
  11. package/dist/core-subscreen/shards/coreTextShard.js +9 -0
  12. package/dist/core-subscreen/shards/index.js +5 -0
  13. package/dist/core-subscreen/toastsSubscreen.js +112 -0
  14. package/dist/core.js +178 -0
  15. package/dist/dialogs.js +110 -0
  16. package/dist/index.js +202 -1
  17. package/dist/localization.js +71 -0
  18. package/dist/logging.js +31 -0
  19. package/dist/messaging.js +234 -1
  20. package/dist/modSdk.js +63 -0
  21. package/dist/shard-modules/attributesModule.js +16 -0
  22. package/dist/shard-modules/centerModule.js +12 -0
  23. package/dist/shard-modules/clickModule.js +14 -0
  24. package/dist/shard-modules/counterUpModule.js +37 -0
  25. package/dist/shard-modules/dynamicClassModule.js +15 -0
  26. package/dist/shard-modules/index.js +9 -0
  27. package/dist/shard-modules/multiClickModule.js +41 -0
  28. package/dist/shard-modules/shardModule.js +12 -0
  29. package/dist/shard-modules/styleModule.js +20 -0
  30. package/dist/shard-modules/typeModule.js +37 -0
  31. package/dist/shards/backNextButtonShard.js +99 -0
  32. package/dist/shards/buttonShard.js +118 -0
  33. package/dist/shards/cardShard.js +35 -0
  34. package/dist/shards/checkboxShard.js +139 -0
  35. package/dist/shards/containerShard.js +16 -0
  36. package/dist/shards/imageShard.js +98 -0
  37. package/dist/shards/index.js +13 -0
  38. package/dist/shards/inputListShard.js +162 -0
  39. package/dist/shards/inputShard.js +33 -0
  40. package/dist/shards/selectShard.js +126 -0
  41. package/dist/shards/shard.js +79 -0
  42. package/dist/shards/svgShard.js +47 -0
  43. package/dist/shards/tabsShard.js +59 -0
  44. package/dist/shards/textShard.js +27 -0
  45. package/dist/styles.css +209 -1
  46. package/dist/toasts.js +188 -0
  47. package/dist/types/changelogs.d.ts +1 -0
  48. package/dist/types/core-subscreen/coreSubscreen.d.ts +15 -0
  49. package/dist/types/core-subscreen/developmentSubscreen.d.ts +5 -0
  50. package/dist/types/core-subscreen/generalSubscreen.d.ts +5 -0
  51. package/dist/types/core-subscreen/mainSubscreen.d.ts +6 -0
  52. package/dist/types/core-subscreen/shards/coreButtonShard.d.ts +5 -0
  53. package/dist/types/core-subscreen/shards/coreCheckboxShard.d.ts +6 -0
  54. package/dist/types/core-subscreen/shards/coreInputListShard.d.ts +6 -0
  55. package/dist/types/core-subscreen/shards/coreSelectShard.d.ts +5 -0
  56. package/dist/types/core-subscreen/shards/coreTextShard.d.ts +4 -0
  57. package/dist/types/core-subscreen/shards/index.d.ts +5 -0
  58. package/dist/types/core-subscreen/toastsSubscreen.d.ts +5 -0
  59. package/dist/types/core.d.ts +18 -0
  60. package/dist/types/dialogs.d.ts +29 -0
  61. package/dist/types/index.d.ts +55 -5
  62. package/dist/types/localization.d.ts +4 -0
  63. package/dist/types/logging.d.ts +16 -0
  64. package/dist/types/messaging.d.ts +5 -3
  65. package/dist/types/{modsApi.d.ts → modSdk.d.ts} +2 -2
  66. package/dist/types/shard-modules/attributesModule.d.ts +7 -0
  67. package/dist/types/shard-modules/centerModule.d.ts +5 -0
  68. package/dist/types/shard-modules/clickModule.d.ts +7 -0
  69. package/dist/types/shard-modules/counterUpModule.d.ts +13 -0
  70. package/dist/types/shard-modules/dynamicClassModule.d.ts +8 -0
  71. package/dist/types/{ui-modules → shard-modules}/index.d.ts +2 -0
  72. package/dist/types/shard-modules/multiClickModule.d.ts +12 -0
  73. package/dist/types/shard-modules/shardModule.d.ts +7 -0
  74. package/dist/types/shard-modules/styleModule.d.ts +8 -0
  75. package/dist/types/shard-modules/typeModule.d.ts +11 -0
  76. package/dist/types/shards/backNextButtonShard.d.ts +14 -0
  77. package/dist/types/shards/buttonShard.d.ts +20 -0
  78. package/dist/types/shards/cardShard.d.ts +10 -0
  79. package/dist/types/shards/checkboxShard.d.ts +19 -0
  80. package/dist/types/shards/containerShard.d.ts +7 -0
  81. package/dist/types/shards/imageShard.d.ts +11 -0
  82. package/dist/types/shards/index.d.ts +13 -0
  83. package/dist/types/shards/inputListShard.d.ts +16 -0
  84. package/dist/types/shards/inputShard.d.ts +14 -0
  85. package/dist/types/shards/selectShard.d.ts +17 -0
  86. package/dist/types/shards/shard.d.ts +21 -0
  87. package/dist/types/shards/svgShard.d.ts +12 -0
  88. package/dist/types/shards/tabsShard.d.ts +17 -0
  89. package/dist/types/shards/textShard.d.ts +13 -0
  90. package/dist/types/toasts.d.ts +21 -0
  91. package/dist/types/ui.d.ts +27 -147
  92. package/dist/ui.js +351 -11
  93. package/dist/validation.js +31 -1
  94. package/dist/wardrobe.js +167 -1
  95. package/package.json +44 -26
  96. package/scripts/generateChangelog.mjs +80 -0
  97. package/dist/modsApi.js +0 -1
  98. package/dist/modules.js +0 -1
  99. package/dist/popups.js +0 -1
  100. package/dist/types/modules.d.ts +0 -18
  101. package/dist/types/popups.d.ts +0 -63
  102. package/dist/types/ui-modules/attributesModule.d.ts +0 -6
  103. package/dist/types/ui-modules/centerModule.d.ts +0 -4
  104. package/dist/types/ui-modules/clickModule.d.ts +0 -6
  105. package/dist/types/ui-modules/counterUpModule.d.ts +0 -12
  106. package/dist/types/ui-modules/dynamicClassModule.d.ts +0 -7
  107. package/dist/types/ui-modules/styleModule.d.ts +0 -7
  108. package/dist/types/ui-modules/typeModule.d.ts +0 -10
  109. package/dist/ui-modules/attributesModule.js +0 -1
  110. package/dist/ui-modules/centerModule.js +0 -1
  111. package/dist/ui-modules/clickModule.js +0 -1
  112. package/dist/ui-modules/counterUpModule.js +0 -1
  113. package/dist/ui-modules/dynamicClassModule.js +0 -1
  114. package/dist/ui-modules/index.js +0 -1
  115. package/dist/ui-modules/styleModule.js +0 -1
  116. package/dist/ui-modules/typeModule.js +0 -1
@@ -0,0 +1,118 @@
1
+ import { MOD_DATA } from "../index";
2
+ import { addDynamicClass, autosetFontSize, setFontFamily, setFontSize } from "../ui";
3
+ import { Shard } from "./shard";
4
+ class ButtonShard extends Shard {
5
+ get dynamicClassButton() {
6
+ return {
7
+ base: {
8
+ cursor: "pointer",
9
+ background: "var(--tmd-element, white)",
10
+ color: "var(--tmd-text, black)",
11
+ border: "2px solid var(--tmd-accent, rgb(34, 34, 34))",
12
+ borderRadius: "6px"
13
+ },
14
+ hover: {
15
+ background: "var(--tmd-element-hover, #ebf7fe)",
16
+ borderColor: "var(--tmd-accent-hover, #7dd3fc)",
17
+ color: "var(--tmd-accent-hover, #015a8c)"
18
+ },
19
+ "> .tooltip": {
20
+ position: "absolute",
21
+ color: "var(--tmd-text, black)",
22
+ textAlign: "center",
23
+ padding: "0.3em 0.6em",
24
+ borderRadius: "4px",
25
+ background: "var(--tmd-element-hint, #e6e6e6)",
26
+ width: "max-content",
27
+ visibility: "hidden",
28
+ zIndex: "10"
29
+ },
30
+ "> .tooltip[position=left]": {
31
+ right: "calc(100% + 1vw)"
32
+ },
33
+ "> .tooltip[position=right]": {
34
+ left: "calc(100% + 1vw)"
35
+ },
36
+ ":hover .tooltip": {
37
+ visibility: "visible"
38
+ },
39
+ "[data-zc-style=green]": {
40
+ background: "rgb(124, 255, 124)",
41
+ borderColor: "rgb(82, 204, 82)",
42
+ color: "black"
43
+ },
44
+ "[data-zc-style=green]:hover": {
45
+ background: "rgb(94, 197, 94)",
46
+ color: "black"
47
+ },
48
+ "[data-zc-style=inverted]": {
49
+ background: "var(--tmd-accent, #111)",
50
+ border: "2px solid var(--tmd-accent, #111)",
51
+ color: "var(--tmd-text, white)"
52
+ },
53
+ "[data-zc-style=inverted]:hover": {
54
+ background: "var(--tmd-accent-hover, none)",
55
+ color: "var(--tmd-text, black)"
56
+ }
57
+ };
58
+ }
59
+ generateBody() {
60
+ const { text, fontSize, width, height, padding, style, icon, iconAbsolutePosition = true, tooltip, onClick, isDisabled } = this.context;
61
+ let iconElement;
62
+ let textElement;
63
+ const btn = document.createElement("button");
64
+ addDynamicClass(btn, this.dynamicClassButton);
65
+ btn.setAttribute("data-zc-style", style);
66
+ btn.style.display = "flex";
67
+ btn.style.alignItems = "center";
68
+ btn.style.justifyContent = "center";
69
+ btn.style.columnGap = "1.25vw";
70
+ setFontFamily(btn, MOD_DATA.fontFamily);
71
+ if (icon) {
72
+ if (typeof icon === "string") {
73
+ iconElement = document.createElement("img");
74
+ iconElement.src = icon;
75
+ } else {
76
+ iconElement = icon;
77
+ }
78
+ iconElement.style.height = "80%";
79
+ iconElement.style.width = "auto";
80
+ if (text && iconAbsolutePosition) {
81
+ iconElement.style.position = "absolute";
82
+ iconElement.style.left = "1vw";
83
+ }
84
+ if (text && !iconAbsolutePosition) btn.style.justifyContent = "";
85
+ btn.append(iconElement);
86
+ }
87
+ if (text) {
88
+ textElement = document.createElement("span");
89
+ textElement.textContent = text;
90
+ btn.append(textElement);
91
+ }
92
+ if (tooltip) {
93
+ const tooltipEl = document.createElement("span");
94
+ tooltipEl.classList.add("tooltip");
95
+ tooltipEl.setAttribute("position", tooltip.position);
96
+ tooltipEl.textContent = tooltip.text;
97
+ btn.append(tooltipEl);
98
+ }
99
+ if (typeof isDisabled === "function" && isDisabled()) btn.classList.add("zcDisabled");
100
+ btn.addEventListener("click", () => {
101
+ if (typeof isDisabled === "function" && isDisabled()) return btn.classList.add("zcDisabled");
102
+ if (typeof onClick === "function") onClick();
103
+ });
104
+ return {
105
+ text: textElement,
106
+ icon: iconElement,
107
+ base: btn
108
+ };
109
+ }
110
+ update() {
111
+ super.update();
112
+ if ((this.context.fontSize ?? "auto") === "auto") autosetFontSize(this.body.base);
113
+ else if (typeof this.context.fontSize === "number") setFontSize(this.body.base, this.context.fontSize);
114
+ }
115
+ }
116
+ export {
117
+ ButtonShard
118
+ };
@@ -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
+ };