aprog 2.2.3 → 2.2.5

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/src/general.js CHANGED
@@ -1,1458 +1,1506 @@
1
1
  export const pause = (variable) => {
2
- if (isNumber(variable)) {
3
- return new Promise(resolve => setTimeout(resolve, variable));
4
- } else {
5
- return new Promise(resolve => {
6
- const checkVariable = () => {
7
- if (variable()) {
8
- resolve();
9
- } else {
10
- setTimeout(checkVariable, 100);
11
- }
12
- };
13
- checkVariable();
14
- });
15
- }
2
+ if (isNumber(variable)) {
3
+ return new Promise(resolve => setTimeout(resolve, variable));
4
+ } else {
5
+ return new Promise(resolve => {
6
+ const checkVariable = () => {
7
+ if (variable()) {
8
+ resolve();
9
+ } else {
10
+ setTimeout(checkVariable, 100);
11
+ }
12
+ };
13
+ checkVariable();
14
+ });
15
+ }
16
16
  };
17
17
 
18
18
  export const date = (format, timestamp = Date.now()) => {
19
- const date = new Date(timestamp);
20
-
21
- const map = {
22
- Y: date.getFullYear(),
23
- m: String(date.getMonth() + 1).padStart(2, '0'),
24
- d: String(date.getDate()).padStart(2, '0'),
25
- H: String(date.getHours()).padStart(2, '0'),
26
- i: String(date.getMinutes()).padStart(2, '0'),
27
- s: String(date.getSeconds()).padStart(2, '0')
28
- };
29
-
30
- return format.replace(/[YmdHis]/g, match => map[match]);
19
+ const date = new Date(timestamp);
20
+
21
+ const map = {
22
+ Y: date.getFullYear(),
23
+ m: String(date.getMonth() + 1).padStart(2, '0'),
24
+ d: String(date.getDate()).padStart(2, '0'),
25
+ H: String(date.getHours()).padStart(2, '0'),
26
+ i: String(date.getMinutes()).padStart(2, '0'),
27
+ s: String(date.getSeconds()).padStart(2, '0')
28
+ };
29
+
30
+ return format.replace(/[YmdHis]/g, match => map[match]);
31
31
  };
32
32
 
33
33
  export const chars = (word) => {
34
- const cyrillicToLatin = {
35
- 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'H', 'Д': 'D', 'Е': 'E', 'Є': 'Ye', 'Ж': 'Zh',
36
- 'З': 'Z', 'И': 'Y', 'І': 'I', 'Ї': 'Yi', 'Й': 'Y', 'К': 'K', 'Л': 'L', 'М': 'M',
37
- 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U', 'Ф': 'F',
38
- 'Х': 'Kh', 'Ц': 'Ts', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Shch', 'Ю': 'Yu', 'Я': 'Ya',
39
- 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'h', 'д': 'd', 'е': 'e', 'є': 'ye', 'ж': 'zh',
40
- 'з': 'z', 'и': 'y', 'і': 'i', 'ї': 'yi', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm',
41
- 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', 'ф': 'f',
42
- 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ю': 'yu', 'я': 'ya',
43
- 'Ь': '', 'ь': '', 'Ъ': '', 'ъ': '', 'Э': 'E', 'э': 'e', 'Ы': 'Y', 'ы': 'y'
44
- };
45
- return word.split('').map(char => cyrillicToLatin[char] || char).join('');
34
+ const cyrillicToLatin = {
35
+ 'А': 'A', 'Б': 'B', 'В': 'V', 'Г': 'H', 'Д': 'D', 'Е': 'E', 'Є': 'Ye', 'Ж': 'Zh',
36
+ 'З': 'Z', 'И': 'Y', 'І': 'I', 'Ї': 'Yi', 'Й': 'Y', 'К': 'K', 'Л': 'L', 'М': 'M',
37
+ 'Н': 'N', 'О': 'O', 'П': 'P', 'Р': 'R', 'С': 'S', 'Т': 'T', 'У': 'U', 'Ф': 'F',
38
+ 'Х': 'Kh', 'Ц': 'Ts', 'Ч': 'Ch', 'Ш': 'Sh', 'Щ': 'Shch', 'Ю': 'Yu', 'Я': 'Ya',
39
+ 'а': 'a', 'б': 'b', 'в': 'v', 'г': 'h', 'д': 'd', 'е': 'e', 'є': 'ye', 'ж': 'zh',
40
+ 'з': 'z', 'и': 'y', 'і': 'i', 'ї': 'yi', 'й': 'y', 'к': 'k', 'л': 'l', 'м': 'm',
41
+ 'н': 'n', 'о': 'o', 'п': 'p', 'р': 'r', 'с': 's', 'т': 't', 'у': 'u', 'ф': 'f',
42
+ 'х': 'kh', 'ц': 'ts', 'ч': 'ch', 'ш': 'sh', 'щ': 'shch', 'ю': 'yu', 'я': 'ya',
43
+ 'Ь': '', 'ь': '', 'Ъ': '', 'ъ': '', 'Э': 'E', 'э': 'e', 'Ы': 'Y', 'ы': 'y'
44
+ };
45
+ return word.split('').map(char => cyrillicToLatin[char] || char).join('');
46
46
  };
47
47
 
48
48
  // Validates
49
49
  export const isArray = (value) => {
50
- return Object.prototype.toString.call(value) === '[object Array]';
50
+ return Object.prototype.toString.call(value) === '[object Array]';
51
51
  };
52
52
 
53
53
  export const isObject = (value) => {
54
- return Object.prototype.toString.call(value) === '[object Object]';
54
+ return Object.prototype.toString.call(value) === '[object Object]';
55
55
  };
56
56
 
57
57
  export const isPromise = (value) => {
58
- return Object.prototype.toString.call(value) === '[object Promise]' ||
59
- (typeof value === 'object' && value !== null && typeof value.then === 'function' && typeof value.catch === 'function');
58
+ return Object.prototype.toString.call(value) === '[object Promise]' ||
59
+ (typeof value === 'object' && value !== null && typeof value.then === 'function' && typeof value.catch === 'function');
60
60
  };
61
61
 
62
62
  export const isNumber = (value) => {
63
- return typeof value === 'number' && !Number.isNaN(value);
63
+ return typeof value === 'number' && !Number.isNaN(value);
64
64
  };
65
65
 
66
66
  export const isNumeric = (value) => {
67
- return /^-?\d+(\.\d+)?$/.test(value);
67
+ return /^-?\d+(\.\d+)?$/.test(value);
68
68
  };
69
69
 
70
70
  export const isFloat = (value) => {
71
- return !isNaN(value) && Number(value) === value && !Number.isInteger(value);
71
+ return !isNaN(value) && Number(value) === value && !Number.isInteger(value);
72
72
  };
73
73
 
74
74
  export const isString = (value) => {
75
- return typeof value === 'string';
75
+ return typeof value === 'string';
76
76
  };
77
77
 
78
78
  export const isNull = (value) => {
79
- return value === null || value === undefined;
79
+ return value === null || value === undefined;
80
80
  };
81
81
 
82
82
  const isHtmlElement = (value) => {
83
- const htmlElements = [
84
- 'HTMLDivElement', "HTMLAnchorElement", 'HTMLSpanElement',
85
- 'HTMLButtonElement', 'HTMLSelectElement', "HTMLMainElement",
86
- 'HTMLInputElement', 'HTMLUlElement', "Promise",
87
- 'HTMLListElement', 'HTMLLabelElement', "HTMLTableCaptionElement",
88
- 'HTMLHRElement', 'SVGSVGElement', 'HTMLPreElement',
89
- 'Promise', "HTMLTextAreaElement", "HTMLTableElement",
90
- "HTMLTHeaderElement", "HTMLTBodyElement", "HTMLTRElement",
91
- "HTMLTHElement", "HTMLTDElement", "HTMLTableSectionElement",
92
- "HTMLTableRowElement", "HTMLTableCellElement", "HTMLImageElement",
93
- "HTMLSectionElement"
94
- ]
95
-
96
- return htmlElements.some((element) => {
97
- return Object.prototype.toString.call(value) === `[object ${element}]`;
98
- });
83
+ const htmlElements = [
84
+ 'HTMLDivElement', "HTMLAnchorElement", 'HTMLSpanElement',
85
+ 'HTMLButtonElement', 'HTMLSelectElement', "HTMLMainElement",
86
+ 'HTMLInputElement', 'HTMLUlElement', "Promise",
87
+ 'HTMLListElement', 'HTMLLabelElement', "HTMLTableCaptionElement",
88
+ 'HTMLHRElement', 'SVGSVGElement', 'HTMLPreElement',
89
+ 'Promise', "HTMLTextAreaElement", "HTMLTableElement",
90
+ "HTMLTHeaderElement", "HTMLTBodyElement", "HTMLTRElement",
91
+ "HTMLTHElement", "HTMLTDElement", "HTMLTableSectionElement",
92
+ "HTMLTableRowElement", "HTMLTableCellElement", "HTMLImageElement",
93
+ "HTMLSectionElement"
94
+ ]
95
+
96
+ return htmlElements.some((element) => {
97
+ return Object.prototype.toString.call(value) === `[object ${element}]`;
98
+ });
99
99
  };
100
100
 
101
101
  export const isEmpty = (variable) => {
102
- if (variable === undefined || variable === null) {
103
- return true;
104
- }
105
- if (typeof variable === 'string' && variable.trim() === '') {
106
- return true;
107
- }
108
- if (Array.isArray(variable) && variable.length === 0) {
109
- return true;
110
- }
111
- if (typeof variable === 'object' && !Array.isArray(variable) && Object.keys(variable).length === 0) {
112
- return true;
113
- }
114
- if (typeof variable === 'number' && variable === 0) {
115
- return false;
116
- }
117
- return !variable;
102
+ if (variable === undefined || variable === null) {
103
+ return true;
104
+ }
105
+ if (typeof variable === 'string' && variable.trim() === '') {
106
+ return true;
107
+ }
108
+ if (Array.isArray(variable) && variable.length === 0) {
109
+ return true;
110
+ }
111
+ if (typeof variable === 'object' && !Array.isArray(variable) && Object.keys(variable).length === 0) {
112
+ return true;
113
+ }
114
+ if (typeof variable === 'number' && variable === 0) {
115
+ return false;
116
+ }
117
+ return !variable;
118
118
  };
119
119
 
120
120
  export const elementToObject = (element) => {
121
- const obj = {};
122
- for (let attr of element.attributes) {
123
- obj[attr.name] = attr.value;
124
- }
125
- if (element.tagName.toLowerCase() === 'input') {
126
- obj['inputValue'] = element.value;
127
- } else if (element.tagName.toLowerCase() === 'select') {
128
- obj['selectValue'] = element.value;
129
- }
130
- return obj;
121
+ const obj = {};
122
+ for (let attr of element.attributes) {
123
+ obj[attr.name] = attr.value;
124
+ }
125
+ if (element.tagName.toLowerCase() === 'input') {
126
+ obj['inputValue'] = element.value;
127
+ } else if (element.tagName.toLowerCase() === 'select') {
128
+ obj['selectValue'] = element.value;
129
+ }
130
+ return obj;
131
131
  };
132
132
 
133
133
  export const nodeListToObject = (nodeList) => {
134
- return Array.from(nodeList).map((el, index) => ({
135
- ...(el.id && {id: el.id}),
136
- ...(el.classList && {classList: [...el.classList]}),
137
- ...(el.name && {name: el.name}),
138
- ...(el.tagName && {element: el.tagName.toLowerCase()}),
139
- ...(el.children && {children: [...nodeListToObject(el.children)]}),
140
- ...(el.attributes && {attributes: Array.from(el.attributes).reduce((acc, attr) => {
141
- acc[attr.name] = attr.value;
142
- return acc;
143
- }, {})}),
144
- ...(el.value && {value: el.value}),
145
- ...(el.innerText && {value: el.innerText}),
146
- index: index
147
- }));
134
+ return Array.from(nodeList).map((el, index) => ({
135
+ ...(el.id && {id: el.id}),
136
+ ...(el.classList && {classList: [...el.classList]}),
137
+ ...(el.name && {name: el.name}),
138
+ ...(el.tagName && {element: el.tagName.toLowerCase()}),
139
+ ...(el.children && {children: [...nodeListToObject(el.children)]}),
140
+ ...(el.attributes && {
141
+ attributes: Array.from(el.attributes).reduce((acc, attr) => {
142
+ acc[attr.name] = attr.value;
143
+ return acc;
144
+ }, {})
145
+ }),
146
+ ...(el.value && {value: el.value}),
147
+ ...(el.innerText && {value: el.innerText}),
148
+ index: index
149
+ }));
148
150
  };
149
151
 
150
152
  export const deepEqual = (obj1, obj2) => {
151
- if (obj1 === obj2) return true;
152
- if (obj1 == null || obj2 == null) return false;
153
- if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
154
- const keys1 = Object.keys(obj1);
155
- const keys2 = Object.keys(obj2);
156
- if (keys1.length !== keys2.length) return false;
157
- for (const key of keys1) {
158
- if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {
159
- return false;
160
- }
153
+ if (obj1 === obj2) return true;
154
+ if (obj1 == null || obj2 == null) return false;
155
+ if (typeof obj1 !== 'object' || typeof obj2 !== 'object') return false;
156
+ const keys1 = Object.keys(obj1);
157
+ const keys2 = Object.keys(obj2);
158
+ if (keys1.length !== keys2.length) return false;
159
+ for (const key of keys1) {
160
+ if (!keys2.includes(key) || !deepEqual(obj1[key], obj2[key])) {
161
+ return false;
161
162
  }
162
- return true;
163
+ }
164
+ return true;
163
165
  };
164
166
 
165
167
  export const ucfirst = (str) => {
166
- if (!str) return str;
167
- return str.charAt(0).toUpperCase() + str.slice(1);
168
+ if (!str) return str;
169
+ return str.charAt(0).toUpperCase() + str.slice(1);
168
170
  };
169
171
 
170
172
  export const firstKey = (object) => {
171
- return Object.keys(object)[0] || null;
173
+ return Object.keys(object)[0] || null;
172
174
  };
173
175
 
174
- export const copyText = async (element) => {
175
- try {
176
- const textToCopy = isHtmlElement(element) ? JSON.stringify(JSON.parse(element.innerText)) : element;
177
- await navigator.clipboard.writeText(textToCopy);
178
- console.log("Скопійовано");
179
- } catch (err) {
180
- console.error('Помилка копіювання! Error:', err);
176
+ /**
177
+ * --- Копіювання тексту з HTML елементу, або просто наданий текст ---
178
+ * @param target
179
+ * @param lang
180
+ * @returns {Promise<string>}
181
+ */
182
+ export const copyText = async (target, lang = false) => {
183
+ try {
184
+ let textToCopy = "";
185
+
186
+ // Якщо передано HTML-елемент — беремо його текст
187
+ if (target instanceof HTMLElement) {
188
+ textToCopy = target.innerText.trim();
189
+ } else {
190
+ textToCopy = String(target).trim();
181
191
  }
192
+
193
+ // Записуємо в буфер
194
+ await navigator.clipboard.writeText(textToCopy);
195
+
196
+ return lang ? "copied" : "Скопійовано";
197
+ } catch (err) {
198
+ console.error("Помилка копіювання! Error:", err);
199
+ return lang ? "error_copied" : "Помилка копіювання!";
200
+ }
182
201
  };
183
202
 
184
203
  // HTML Elements
185
204
  export const options = (object, selected = null, disabled = null) => {
186
- if (isObject(object)) {
187
- return Object.entries(object).map(([key, value]) => {
188
- key = isNumeric(key) ? parseFloat(key) : key;
189
- return {
190
- value: key,
191
- name: value,
192
- selected: key === selected,
193
- disabled: key === disabled,
194
- };
195
- });
196
- } else {
197
- return object.map((value, index) => {
198
- if (isObject(value)) {
199
- return Object.entries(value).map(([key, value]) => {
200
- key = isNumeric(key) ? parseFloat(key) : key;
201
- return {
202
- value: key,
203
- name: value,
204
- selected: key === selected,
205
- disabled: key === disabled,
206
- };
207
- });
208
- } else {
209
- return {
210
- value: value,
211
- name: value,
212
- selected: value === selected,
213
- disabled: value === disabled,
214
- };
215
- }
205
+ if (isObject(object)) {
206
+ return Object.entries(object).map(([key, value]) => {
207
+ key = isNumeric(key) ? parseFloat(key) : key;
208
+ return {
209
+ value: key,
210
+ name: value,
211
+ selected: key === selected,
212
+ disabled: key === disabled,
213
+ };
214
+ });
215
+ } else {
216
+ return object.map((value, index) => {
217
+ if (isObject(value)) {
218
+ return Object.entries(value).map(([key, value]) => {
219
+ key = isNumeric(key) ? parseFloat(key) : key;
220
+ return {
221
+ value: key,
222
+ name: value,
223
+ selected: key === selected,
224
+ disabled: key === disabled,
225
+ };
216
226
  });
217
- }
227
+ } else {
228
+ return {
229
+ value: value,
230
+ name: value,
231
+ selected: value === selected,
232
+ disabled: value === disabled,
233
+ };
234
+ }
235
+ });
236
+ }
218
237
  };
219
238
 
220
239
  export const input = (attributes = {}) => {
221
- let input = document.createElement("input");
222
- if (attributes) {
223
- Object.entries(attributes).forEach(([name, attrValue]) => {
224
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
225
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
226
- input.addEventListener(eventType, attrValue);
240
+ let input = document.createElement("input");
241
+ if (attributes) {
242
+ Object.entries(attributes).forEach(([name, attrValue]) => {
243
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
244
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
245
+ input.addEventListener(eventType, attrValue);
246
+ } else {
247
+ switch (name) {
248
+ case "type":
249
+ input.type = String(attrValue);
250
+ break;
251
+ case "class":
252
+ case "className":
253
+ input.className = String(attrValue);
254
+ break;
255
+ case "style":
256
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
257
+ switch (styleName) {
258
+ case "zIndex":
259
+ input.style[styleName] = `99999${styleValue}`;
260
+ break;
261
+ default:
262
+ input.style[styleName] = styleValue;
263
+ break;
264
+ }
265
+ });
266
+ break;
267
+ case "disabled":
268
+ input.disabled = attrValue;
269
+ break;
270
+ case "autofocus":
271
+ case "focus":
272
+ input.focus();
273
+ break;
274
+ default:
275
+ if (name.startsWith("data")) {
276
+ const kebabName = name
277
+ .replace(/^data/, "data")
278
+ .replace(/([A-Z])/g, "-$1")
279
+ .toLowerCase();
280
+ input.setAttribute(kebabName, String(attrValue));
227
281
  } else {
228
- switch (name) {
229
- case "type":
230
- input.type = String(attrValue);
231
- break;
232
- case "class":
233
- case "className":
234
- input.className = String(attrValue);
235
- break;
236
- case "style":
237
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
238
- switch (styleName) {
239
- case "zIndex":
240
- input.style[styleName] = `99999${styleValue}`;
241
- break;
242
- default:
243
- input.style[styleName] = styleValue;
244
- break;
245
- }
246
- });
247
- break;
248
- case "disabled":
249
- input.disabled = attrValue;
250
- break;
251
- case "autofocus":
252
- case "focus":
253
- input.focus();
254
- break;
255
- default:
256
- if (name.startsWith("data")) {
257
- const kebabName = name
258
- .replace(/^data/, "data")
259
- .replace(/([A-Z])/g, "-$1")
260
- .toLowerCase();
261
- input.setAttribute(kebabName, String(attrValue));
262
- } else {
263
- input.setAttribute(name, String(attrValue));
264
- }
265
- }
282
+ input.setAttribute(name, String(attrValue));
266
283
  }
267
- });
268
- }
269
- return input;
284
+ }
285
+ }
286
+ });
287
+ }
288
+ return input;
270
289
  };
271
290
 
272
291
  export const label = (attributes = {}) => {
273
- let label = document.createElement("label");
274
- label.setAttribute("for", "...");
275
- if (attributes) {
276
- Object.entries(attributes).forEach(([name, attrValue]) => {
277
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
278
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
279
- label.addEventListener(eventType, attrValue);
292
+ let label = document.createElement("label");
293
+ label.setAttribute("for", "...");
294
+ if (attributes) {
295
+ Object.entries(attributes).forEach(([name, attrValue]) => {
296
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
297
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
298
+ label.addEventListener(eventType, attrValue);
299
+ } else {
300
+ switch (name) {
301
+ case "class":
302
+ case "className":
303
+ label.className = String(attrValue);
304
+ break;
305
+ case "value":
306
+ if (isArray(attrValue)) {
307
+ attrValue.forEach((element) => {
308
+ isHtmlElement(element) ? label.appendChild(element) : label.innerHTML = String(element);
309
+ });
280
310
  } else {
281
- switch (name) {
282
- case "class":
283
- case "className":
284
- label.className = String(attrValue);
285
- break;
286
- case "value":
287
- if (isArray(attrValue)) {
288
- attrValue.forEach((element) => {
289
- isHtmlElement(element) ? label.appendChild(element) : label.innerHTML = String(element);
290
- });
291
- } else {
292
- if (isHtmlElement(attrValue)) {
293
- label.appendChild(attrValue);
294
- } else {
295
- label.innerHTML = String(attrValue);
296
- label.title = String(attrValue);
297
- }
298
- }
299
- break;
300
- case "style":
301
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
302
- switch (styleName) {
303
- case "zIndex":
304
- label.style[styleName] = `99999${styleValue}`;
305
- break;
306
- default:
307
- label.style[styleName] = styleValue;
308
- break;
309
- }
310
- });
311
- break;
312
- default:
313
- if (name.startsWith("data")) {
314
- const kebabName = name
315
- .replace(/^data/, "data")
316
- .replace(/([A-Z])/g, "-$1")
317
- .toLowerCase();
318
- label.setAttribute(kebabName, String(attrValue));
319
- } else {
320
- label.setAttribute(name, String(attrValue));
321
- }
322
- }
311
+ if (isHtmlElement(attrValue)) {
312
+ label.appendChild(attrValue);
313
+ } else {
314
+ label.innerHTML = String(attrValue);
315
+ label.title = String(attrValue);
316
+ }
323
317
  }
324
- });
325
- }
326
- return label;
318
+ break;
319
+ case "style":
320
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
321
+ switch (styleName) {
322
+ case "zIndex":
323
+ label.style[styleName] = `99999${styleValue}`;
324
+ break;
325
+ default:
326
+ label.style[styleName] = styleValue;
327
+ break;
328
+ }
329
+ });
330
+ break;
331
+ default:
332
+ if (name.startsWith("data")) {
333
+ const kebabName = name
334
+ .replace(/^data/, "data")
335
+ .replace(/([A-Z])/g, "-$1")
336
+ .toLowerCase();
337
+ label.setAttribute(kebabName, String(attrValue));
338
+ } else {
339
+ label.setAttribute(name, String(attrValue));
340
+ }
341
+ }
342
+ }
343
+ });
344
+ }
345
+ return label;
327
346
  };
328
347
 
329
348
  export const form = (attributes = {}) => {
330
- let form = document.createElement("form");
331
- if (attributes) {
332
- Object.entries(attributes).forEach(([name, attrValue]) => {
333
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
334
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
335
- form.addEventListener(eventType, attrValue);
349
+ let form = document.createElement("form");
350
+ if (attributes) {
351
+ Object.entries(attributes).forEach(([name, attrValue]) => {
352
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
353
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
354
+ form.addEventListener(eventType, attrValue);
355
+ } else {
356
+ switch (name) {
357
+ case "class":
358
+ case "className":
359
+ form.className = String(attrValue);
360
+ break;
361
+ case "action":
362
+ form.action = String(attrValue);
363
+ break;
364
+ case "method":
365
+ form.method = String(attrValue);
366
+ break;
367
+ case "enctype":
368
+ form.enctype = String(attrValue);
369
+ break;
370
+ case "value":
371
+ if (isArray(attrValue)) {
372
+ attrValue.forEach((element) => {
373
+ isHtmlElement(element) ? form.append(element) : form.innerHTML = String(element);
374
+ });
336
375
  } else {
337
- switch (name) {
338
- case "class":
339
- case "className":
340
- form.className = String(attrValue);
341
- break;
342
- case "action":
343
- form.action = String(attrValue);
344
- break;
345
- case "method":
346
- form.method = String(attrValue);
347
- break;
348
- case "enctype":
349
- form.enctype = String(attrValue);
350
- break;
351
- case "value":
352
- if (isArray(attrValue)) {
353
- attrValue.forEach((element) => {
354
- isHtmlElement(element) ? form.append(element) : form.innerHTML = String(element);
355
- });
356
- } else {
357
- if (isHtmlElement(attrValue)) {
358
- form.appendChild(attrValue);
359
- } else {
360
- form.innerHTML = String(attrValue);
361
- form.title = String(attrValue);
362
- }
363
- }
364
- break;
365
- case "style":
366
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
367
- switch (styleName) {
368
- case "zIndex":
369
- form.style[styleName] = `99999${styleValue}`;
370
- break;
371
- default:
372
- form.style[styleName] = styleValue;
373
- break;
374
- }
375
- });
376
- break;
377
- default:
378
- if (name.startsWith("data")) {
379
- const kebabName = name
380
- .replace(/^data/, "data")
381
- .replace(/([A-Z])/g, "-$1")
382
- .toLowerCase();
383
- form.setAttribute(kebabName, String(attrValue));
384
- } else {
385
- form.setAttribute(name, String(attrValue));
386
- }
387
- }
376
+ if (isHtmlElement(attrValue)) {
377
+ form.appendChild(attrValue);
378
+ } else {
379
+ form.innerHTML = String(attrValue);
380
+ form.title = String(attrValue);
381
+ }
388
382
  }
389
- });
390
- }
391
- return form;
383
+ break;
384
+ case "style":
385
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
386
+ switch (styleName) {
387
+ case "zIndex":
388
+ form.style[styleName] = `99999${styleValue}`;
389
+ break;
390
+ default:
391
+ form.style[styleName] = styleValue;
392
+ break;
393
+ }
394
+ });
395
+ break;
396
+ default:
397
+ if (name.startsWith("data")) {
398
+ const kebabName = name
399
+ .replace(/^data/, "data")
400
+ .replace(/([A-Z])/g, "-$1")
401
+ .toLowerCase();
402
+ form.setAttribute(kebabName, String(attrValue));
403
+ } else {
404
+ form.setAttribute(name, String(attrValue));
405
+ }
406
+ }
407
+ }
408
+ });
409
+ }
410
+ return form;
392
411
  };
393
412
 
394
413
  export const div = (attributes = {}) => {
395
- let div = document.createElement("div");
396
- if (attributes) {
397
- Object.entries(attributes).forEach(([name, attrValue]) => {
398
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
399
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
400
- div.addEventListener(eventType, attrValue);
414
+ let div = document.createElement("div");
415
+ if (attributes) {
416
+ Object.entries(attributes).forEach(([name, attrValue]) => {
417
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
418
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
419
+ div.addEventListener(eventType, attrValue);
420
+ } else {
421
+ switch (name) {
422
+ case "class":
423
+ case "className":
424
+ div.className = String(attrValue);
425
+ break;
426
+ case "value":
427
+ if (isArray(attrValue)) {
428
+ attrValue.forEach((element) => {
429
+ isHtmlElement(element) ? div.append(element) : div.innerHTML = String(element);
430
+ });
401
431
  } else {
402
- switch (name) {
403
- case "class":
404
- case "className":
405
- div.className = String(attrValue);
406
- break;
407
- case "value":
408
- if (isArray(attrValue)) {
409
- attrValue.forEach((element) => {
410
- isHtmlElement(element) ? div.append(element) : div.innerHTML = String(element);
411
- });
412
- } else {
413
- if (isHtmlElement(attrValue)) {
414
- div.appendChild(attrValue);
415
- } else {
416
- div.innerHTML = String(attrValue);
417
- div.title = String(attrValue);
418
- }
419
- }
420
- break;
421
- case "style":
422
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
423
- switch (styleName) {
424
- case "zIndex":
425
- div.style[styleName] = `99999${styleValue}`;
426
- break;
427
- default:
428
- div.style[styleName] = styleValue;
429
- break;
430
- }
431
- });
432
- break;
433
- default:
434
- if (name.startsWith("data")) {
435
- const kebabName = name
436
- .replace(/^data/, "data")
437
- .replace(/([A-Z])/g, "-$1")
438
- .toLowerCase();
439
- div.setAttribute(kebabName, String(attrValue));
440
- } else {
441
- div.setAttribute(name, String(attrValue));
442
- }
443
- }
432
+ if (isHtmlElement(attrValue)) {
433
+ div.appendChild(attrValue);
434
+ } else {
435
+ div.innerHTML = String(attrValue);
436
+ div.title = String(attrValue);
437
+ }
444
438
  }
445
- });
446
- }
447
- return div;
439
+ break;
440
+ case "style":
441
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
442
+ switch (styleName) {
443
+ case "zIndex":
444
+ div.style[styleName] = `99999${styleValue}`;
445
+ break;
446
+ default:
447
+ div.style[styleName] = styleValue;
448
+ break;
449
+ }
450
+ });
451
+ break;
452
+ default:
453
+ if (name.startsWith("data")) {
454
+ const kebabName = name
455
+ .replace(/^data/, "data")
456
+ .replace(/([A-Z])/g, "-$1")
457
+ .toLowerCase();
458
+ div.setAttribute(kebabName, String(attrValue));
459
+ } else {
460
+ div.setAttribute(name, String(attrValue));
461
+ }
462
+ }
463
+ }
464
+ });
465
+ }
466
+ return div;
448
467
  };
449
468
 
450
469
  export const a = (attributes = {}) => {
451
- let a = document.createElement("a");
452
- if (attributes) {
453
- Object.entries(attributes).forEach(([name, attrValue]) => {
454
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
455
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
456
- a.addEventListener(eventType, attrValue);
470
+ let a = document.createElement("a");
471
+ if (attributes) {
472
+ Object.entries(attributes).forEach(([name, attrValue]) => {
473
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
474
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
475
+ a.addEventListener(eventType, attrValue);
476
+ } else {
477
+ switch (name) {
478
+ case "class":
479
+ case "className":
480
+ a.className = String(attrValue);
481
+ break;
482
+ case "value":
483
+ if (isArray(attrValue)) {
484
+ attrValue.forEach((element) => {
485
+ isHtmlElement(element) ? a.append(element) : a.innerHTML = String(element);
486
+ });
457
487
  } else {
458
- switch (name) {
459
- case "class":
460
- case "className":
461
- a.className = String(attrValue);
462
- break;
463
- case "value":
464
- if (isArray(attrValue)) {
465
- attrValue.forEach((element) => {
466
- isHtmlElement(element) ? a.append(element) : a.innerHTML = String(element);
467
- });
468
- } else {
469
- if (isHtmlElement(attrValue)) {
470
- a.appendChild(attrValue);
471
- } else {
472
- a.innerHTML = String(attrValue);
473
- a.title = String(attrValue);
474
- }
475
- }
476
- break;
477
- case "style":
478
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
479
- switch (styleName) {
480
- case "zIndex":
481
- a.style[styleName] = `99999${styleValue}`;
482
- break;
483
- default:
484
- a.style[styleName] = styleValue;
485
- break;
486
- }
487
- });
488
- break;
489
- default:
490
- if (name.startsWith("data")) {
491
- const kebabName = name
492
- .replace(/^data/, "data")
493
- .replace(/([A-Z])/g, "-$1")
494
- .toLowerCase();
495
- a.setAttribute(kebabName, String(attrValue));
496
- } else {
497
- a.setAttribute(name, String(attrValue));
498
- }
499
- }
488
+ if (isHtmlElement(attrValue)) {
489
+ a.appendChild(attrValue);
490
+ } else {
491
+ a.innerHTML = String(attrValue);
492
+ a.title = String(attrValue);
493
+ }
500
494
  }
501
- });
502
- }
503
- return a;
495
+ break;
496
+ case "style":
497
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
498
+ switch (styleName) {
499
+ case "zIndex":
500
+ a.style[styleName] = `99999${styleValue}`;
501
+ break;
502
+ default:
503
+ a.style[styleName] = styleValue;
504
+ break;
505
+ }
506
+ });
507
+ break;
508
+ default:
509
+ if (name.startsWith("data")) {
510
+ const kebabName = name
511
+ .replace(/^data/, "data")
512
+ .replace(/([A-Z])/g, "-$1")
513
+ .toLowerCase();
514
+ a.setAttribute(kebabName, String(attrValue));
515
+ } else {
516
+ a.setAttribute(name, String(attrValue));
517
+ }
518
+ }
519
+ }
520
+ });
521
+ }
522
+ return a;
504
523
  };
505
524
 
506
525
  export const span = (attributes = {}) => {
507
- let span = document.createElement("span");
508
- if (attributes) {
509
- Object.entries(attributes).forEach(([name, attrValue]) => {
510
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
511
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
512
- span.addEventListener(eventType, attrValue);
526
+ let span = document.createElement("span");
527
+ if (attributes) {
528
+ Object.entries(attributes).forEach(([name, attrValue]) => {
529
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
530
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
531
+ span.addEventListener(eventType, attrValue);
532
+ } else {
533
+ switch (name) {
534
+ case "class":
535
+ case "className":
536
+ span.className = String(attrValue);
537
+ break;
538
+ case "value":
539
+ if (isArray(attrValue)) {
540
+ attrValue.forEach((element) => {
541
+ isHtmlElement(element) ? span.append(element) : span.innerHTML = String(element);
542
+ });
513
543
  } else {
514
- switch (name) {
515
- case "class":
516
- case "className":
517
- span.className = String(attrValue);
518
- break;
519
- case "value":
520
- if (isArray(attrValue)) {
521
- attrValue.forEach((element) => {
522
- isHtmlElement(element) ? span.append(element) : span.innerHTML = String(element);
523
- });
524
- } else {
525
- if (isHtmlElement(attrValue)) {
526
- span.appendChild(attrValue);
527
- } else {
528
- span.innerHTML = String(attrValue);
529
- span.title = String(attrValue);
530
- }
531
- }
532
- break;
533
- case "style":
534
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
535
- switch (styleName) {
536
- case "zIndex":
537
- span.style[styleName] = `99999${styleValue}`;
538
- break;
539
- default:
540
- span.style[styleName] = styleValue;
541
- break;
542
- }
543
- });
544
- break;
545
- default:
546
- if (name.startsWith("data")) {
547
- const kebabName = name
548
- .replace(/^data/, "data")
549
- .replace(/([A-Z])/g, "-$1")
550
- .toLowerCase();
551
- span.setAttribute(kebabName, String(attrValue));
552
- } else {
553
- span.setAttribute(name, String(attrValue));
554
- }
555
- }
544
+ if (isHtmlElement(attrValue)) {
545
+ span.appendChild(attrValue);
546
+ } else {
547
+ span.innerHTML = String(attrValue);
548
+ span.title = String(attrValue);
549
+ }
556
550
  }
557
- });
558
- }
559
- return span;
551
+ break;
552
+ case "style":
553
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
554
+ switch (styleName) {
555
+ case "zIndex":
556
+ span.style[styleName] = `99999${styleValue}`;
557
+ break;
558
+ default:
559
+ span.style[styleName] = styleValue;
560
+ break;
561
+ }
562
+ });
563
+ break;
564
+ default:
565
+ if (name.startsWith("data")) {
566
+ const kebabName = name
567
+ .replace(/^data/, "data")
568
+ .replace(/([A-Z])/g, "-$1")
569
+ .toLowerCase();
570
+ span.setAttribute(kebabName, String(attrValue));
571
+ } else {
572
+ span.setAttribute(name, String(attrValue));
573
+ }
574
+ }
575
+ }
576
+ });
577
+ }
578
+ return span;
560
579
  };
561
580
 
562
581
  export const textarea = (attributes = {}) => {
563
- let textarea = document.createElement("textarea");
564
- if (attributes) {
565
- Object.entries(attributes).forEach(([name, attrValue]) => {
566
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
567
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
568
- textarea.addEventListener(eventType, attrValue);
582
+ let textarea = document.createElement("textarea");
583
+ if (attributes) {
584
+ Object.entries(attributes).forEach(([name, attrValue]) => {
585
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
586
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
587
+ textarea.addEventListener(eventType, attrValue);
588
+ } else {
589
+ switch (name) {
590
+ case "class":
591
+ case "className":
592
+ textarea.className = String(attrValue);
593
+ break;
594
+ case "value":
595
+ if (isArray(attrValue)) {
596
+ attrValue.forEach((element) => {
597
+ isHtmlElement(element) ? textarea.appendChild(element) : textarea.innerHTML = String(element);
598
+ });
569
599
  } else {
570
- switch (name) {
571
- case "class":
572
- case "className":
573
- textarea.className = String(attrValue);
574
- break;
575
- case "value":
576
- if (isArray(attrValue)) {
577
- attrValue.forEach((element) => {
578
- isHtmlElement(element) ? textarea.appendChild(element) : textarea.innerHTML = String(element);
579
- });
580
- } else {
581
- if (isHtmlElement(attrValue)) {
582
- textarea.appendChild(attrValue);
583
- } else {
584
- textarea.innerHTML = String(attrValue);
585
- textarea.title = String(attrValue);
586
- }
587
- }
588
- break;
589
- case "style":
590
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
591
- switch (styleName) {
592
- case "zIndex":
593
- textarea.style[styleName] = `99999${styleValue}`;
594
- break;
595
- default:
596
- textarea.style[styleName] = styleValue;
597
- break;
598
- }
599
- });
600
- break;
601
- default:
602
- if (name.startsWith("data")) {
603
- const kebabName = name
604
- .replace(/^data/, "data")
605
- .replace(/([A-Z])/g, "-$1")
606
- .toLowerCase();
607
- textarea.setAttribute(kebabName, String(attrValue));
608
- } else {
609
- textarea.setAttribute(name, String(attrValue));
610
- }
611
- }
600
+ if (isHtmlElement(attrValue)) {
601
+ textarea.appendChild(attrValue);
602
+ } else {
603
+ textarea.innerHTML = String(attrValue);
604
+ textarea.title = String(attrValue);
605
+ }
612
606
  }
613
- });
614
- }
615
- return textarea;
607
+ break;
608
+ case "style":
609
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
610
+ switch (styleName) {
611
+ case "zIndex":
612
+ textarea.style[styleName] = `99999${styleValue}`;
613
+ break;
614
+ default:
615
+ textarea.style[styleName] = styleValue;
616
+ break;
617
+ }
618
+ });
619
+ break;
620
+ default:
621
+ if (name.startsWith("data")) {
622
+ const kebabName = name
623
+ .replace(/^data/, "data")
624
+ .replace(/([A-Z])/g, "-$1")
625
+ .toLowerCase();
626
+ textarea.setAttribute(kebabName, String(attrValue));
627
+ } else {
628
+ textarea.setAttribute(name, String(attrValue));
629
+ }
630
+ }
631
+ }
632
+ });
633
+ }
634
+ return textarea;
616
635
  };
617
636
 
618
637
  export const pre = (attributes = {}) => {
619
- let pre = document.createElement("pre");
620
- if (attributes) {
621
- Object.entries(attributes).forEach(([name, attrValue]) => {
622
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
623
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
624
- pre.addEventListener(eventType, attrValue);
638
+ let pre = document.createElement("pre");
639
+ if (attributes) {
640
+ Object.entries(attributes).forEach(([name, attrValue]) => {
641
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
642
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
643
+ pre.addEventListener(eventType, attrValue);
644
+ } else {
645
+ switch (name) {
646
+ case "class":
647
+ case "className":
648
+ pre.className = String(attrValue);
649
+ break;
650
+ case "value":
651
+ if (isArray(attrValue)) {
652
+ attrValue.forEach((element) => {
653
+ isHtmlElement(element) ? pre.appendChild(element) : pre.innerHTML = String(element);
654
+ });
625
655
  } else {
626
- switch (name) {
627
- case "class":
628
- case "className":
629
- pre.className = String(attrValue);
630
- break;
631
- case "value":
632
- if (isArray(attrValue)) {
633
- attrValue.forEach((element) => {
634
- isHtmlElement(element) ? pre.appendChild(element) : pre.innerHTML = String(element);
635
- });
636
- } else {
637
- if (isHtmlElement(attrValue)) {
638
- pre.appendChild(attrValue);
639
- } else {
640
- pre.innerHTML = String(attrValue);
641
- pre.title = String(attrValue);
642
- }
643
- }
644
- break;
645
- case "style":
646
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
647
- switch (styleName) {
648
- case "zIndex":
649
- pre.style[styleName] = `99999${styleValue}`;
650
- break;
651
- default:
652
- pre.style[styleName] = styleValue;
653
- break;
654
- }
655
- });
656
- break;
657
- default:
658
- if (name.startsWith("data")) {
659
- const kebabName = name
660
- .replace(/^data/, "data")
661
- .replace(/([A-Z])/g, "-$1")
662
- .toLowerCase();
663
- pre.setAttribute(kebabName, String(attrValue));
664
- } else {
665
- pre.setAttribute(name, String(attrValue));
666
- }
667
- }
656
+ if (isHtmlElement(attrValue)) {
657
+ pre.appendChild(attrValue);
658
+ } else {
659
+ pre.innerHTML = String(attrValue);
660
+ pre.title = String(attrValue);
661
+ }
668
662
  }
669
- });
670
- }
671
- return pre;
663
+ break;
664
+ case "style":
665
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
666
+ switch (styleName) {
667
+ case "zIndex":
668
+ pre.style[styleName] = `99999${styleValue}`;
669
+ break;
670
+ default:
671
+ pre.style[styleName] = styleValue;
672
+ break;
673
+ }
674
+ });
675
+ break;
676
+ default:
677
+ if (name.startsWith("data")) {
678
+ const kebabName = name
679
+ .replace(/^data/, "data")
680
+ .replace(/([A-Z])/g, "-$1")
681
+ .toLowerCase();
682
+ pre.setAttribute(kebabName, String(attrValue));
683
+ } else {
684
+ pre.setAttribute(name, String(attrValue));
685
+ }
686
+ }
687
+ }
688
+ });
689
+ }
690
+ return pre;
672
691
  };
673
692
 
674
693
  export const button = (attributes = {}) => {
675
- let button = document.createElement("button");
676
- if (attributes) {
677
- Object.entries(attributes).forEach(([name, attrValue]) => {
678
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
679
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
680
- button.addEventListener(eventType, attrValue);
694
+ let button = document.createElement("button");
695
+ if (attributes) {
696
+ Object.entries(attributes).forEach(([name, attrValue]) => {
697
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
698
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
699
+ button.addEventListener(eventType, attrValue);
700
+ } else {
701
+ switch (name) {
702
+ case "class":
703
+ case "className":
704
+ button.className = String(attrValue);
705
+ break;
706
+ case "type":
707
+ button.type = String(attrValue);
708
+ break;
709
+ case "value":
710
+ button.innerHTML = String(attrValue);
711
+ button.title = String(attrValue);
712
+ break;
713
+ case "disabled":
714
+ button.disabled = attrValue;
715
+ break;
716
+ case "style":
717
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
718
+ switch (styleName) {
719
+ case "zIndex":
720
+ button.style[styleName] = `99999${styleValue}`;
721
+ break;
722
+ default:
723
+ button.style[styleName] = styleValue;
724
+ break;
725
+ }
726
+ });
727
+ break;
728
+ default:
729
+ if (name.startsWith("data")) {
730
+ const kebabName = name
731
+ .replace(/^data/, "data")
732
+ .replace(/([A-Z])/g, "-$1")
733
+ .toLowerCase();
734
+ button.setAttribute(kebabName, String(attrValue));
681
735
  } else {
682
- switch (name) {
683
- case "class":
684
- case "className":
685
- button.className = String(attrValue);
686
- break;
687
- case "type":
688
- button.type = String(attrValue);
689
- break;
690
- case "value":
691
- button.innerHTML = String(attrValue);
692
- button.title = String(attrValue);
693
- break;
694
- case "disabled":
695
- button.disabled = attrValue;
696
- break;
697
- case "style":
698
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
699
- switch (styleName) {
700
- case "zIndex":
701
- button.style[styleName] = `99999${styleValue}`;
702
- break;
703
- default:
704
- button.style[styleName] = styleValue;
705
- break;
706
- }
707
- });
708
- break;
709
- default:
710
- if (name.startsWith("data")) {
711
- const kebabName = name
712
- .replace(/^data/, "data")
713
- .replace(/([A-Z])/g, "-$1")
714
- .toLowerCase();
715
- button.setAttribute(kebabName, String(attrValue));
716
- } else {
717
- button.setAttribute(name, String(attrValue));
718
- }
719
- }
736
+ button.setAttribute(name, String(attrValue));
720
737
  }
721
- });
722
- }
723
- return button;
738
+ }
739
+ }
740
+ });
741
+ }
742
+ return button;
724
743
  };
725
744
 
726
745
  export const select = (attributes = {}) => {
727
- let select = document.createElement("select");
728
- let option = document.createElement("option");
729
- if (attributes) {
730
- Object.entries(attributes).forEach(([name, attrValue]) => {
731
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
732
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
733
- select.addEventListener(eventType, attrValue);
734
- } else {
735
- switch (name) {
736
- case "class":
737
- case "className":
738
- select.className = String(attrValue);
739
- break;
740
- case "style":
741
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
742
- switch (styleName) {
743
- case "zIndex":
744
- select.style[styleName] = `99999${styleValue}`;
745
- break;
746
- default:
747
- select.style[styleName] = styleValue;
748
- break;
749
- }
750
- });
751
- break;
752
- case "option":
753
- Object.entries(attrValue).forEach(([optionName, optionValue]) => {
754
- switch (optionName) {
755
- case "value":
756
- option.setAttribute('value', String(optionValue));
757
- break;
758
- case "name":
759
- option.innerHTML = String(optionValue);
760
- break;
761
- case "selected":
762
- option.selected = true;
763
- break;
764
- case "disabled":
765
- option.disabled = true;
766
- break;
767
- }
768
- });
769
- select.appendChild(option);
770
- break;
771
- case "options":
772
- attrValue.forEach((opt) => {
773
- let customOption = document.createElement("option");
774
- Object.entries(opt).forEach(([optionName, optionValue]) => {
775
- switch (optionName) {
776
- case "value":
777
- customOption.value = String(optionValue);
778
- break;
779
- case "name":
780
- customOption.innerHTML = String(optionValue);
781
- break;
782
- case "selected":
783
- customOption.selected = Boolean(optionValue);
784
- break;
785
- case "disabled":
786
- customOption.disabled = Boolean(optionValue);
787
- break;
788
- }
789
- });
790
- select.appendChild(customOption);
791
- });
792
- break;
793
- default:
794
- if (name.startsWith("data")) {
795
- const kebabName = name
796
- .replace(/^data/, "data")
797
- .replace(/([A-Z])/g, "-$1")
798
- .toLowerCase();
799
- select.setAttribute(kebabName, String(attrValue));
800
- } else {
801
- select.setAttribute(name, String(attrValue));
802
- }
746
+ let select = document.createElement("select");
747
+ let option = document.createElement("option");
748
+ if (attributes) {
749
+ Object.entries(attributes).forEach(([name, attrValue]) => {
750
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
751
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
752
+ select.addEventListener(eventType, attrValue);
753
+ } else {
754
+ switch (name) {
755
+ case "class":
756
+ case "className":
757
+ select.className = String(attrValue);
758
+ break;
759
+ case "style":
760
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
761
+ switch (styleName) {
762
+ case "zIndex":
763
+ select.style[styleName] = `99999${styleValue}`;
764
+ break;
765
+ default:
766
+ select.style[styleName] = styleValue;
767
+ break;
768
+ }
769
+ });
770
+ break;
771
+ case "option":
772
+ Object.entries(attrValue).forEach(([optionName, optionValue]) => {
773
+ switch (optionName) {
774
+ case "value":
775
+ option.setAttribute('value', String(optionValue));
776
+ break;
777
+ case "name":
778
+ option.innerHTML = String(optionValue);
779
+ break;
780
+ case "selected":
781
+ option.selected = true;
782
+ break;
783
+ case "disabled":
784
+ option.disabled = true;
785
+ break;
786
+ }
787
+ });
788
+ select.appendChild(option);
789
+ break;
790
+ case "options":
791
+ attrValue.forEach((opt) => {
792
+ let customOption = document.createElement("option");
793
+ Object.entries(opt).forEach(([optionName, optionValue]) => {
794
+ switch (optionName) {
795
+ case "value":
796
+ customOption.value = String(optionValue);
797
+ break;
798
+ case "name":
799
+ customOption.innerHTML = String(optionValue);
800
+ break;
801
+ case "selected":
802
+ customOption.selected = Boolean(optionValue);
803
+ break;
804
+ case "disabled":
805
+ customOption.disabled = Boolean(optionValue);
806
+ break;
803
807
  }
808
+ });
809
+ select.appendChild(customOption);
810
+ });
811
+ break;
812
+ default:
813
+ if (name.startsWith("data")) {
814
+ const kebabName = name
815
+ .replace(/^data/, "data")
816
+ .replace(/([A-Z])/g, "-$1")
817
+ .toLowerCase();
818
+ select.setAttribute(kebabName, String(attrValue));
819
+ } else {
820
+ select.setAttribute(name, String(attrValue));
804
821
  }
805
- });
806
- }
807
- return select;
822
+ }
823
+ }
824
+ });
825
+ }
826
+ return select;
808
827
  };
809
828
 
810
829
  export const option = (attributes = {}) => {
811
- let option = document.createElement("option");
812
- if (attributes) {
813
- Object.entries(attributes).forEach(([optionName, optionValue]) => {
814
- switch (optionName) {
815
- case "value": option.value = optionValue; break;
816
- case "name": option.textContent = optionValue; break;
817
- case "selected": option.selected = !!optionValue; break;
818
- case "disabled": option.disabled = !!optionValue; break;
819
- }
820
- });
821
- }
822
- return option;
830
+ let option = document.createElement("option");
831
+ if (attributes) {
832
+ Object.entries(attributes).forEach(([optionName, optionValue]) => {
833
+ switch (optionName) {
834
+ case "value":
835
+ option.value = optionValue;
836
+ break;
837
+ case "name":
838
+ option.textContent = optionValue;
839
+ break;
840
+ case "selected":
841
+ option.selected = !!optionValue;
842
+ break;
843
+ case "disabled":
844
+ option.disabled = !!optionValue;
845
+ break;
846
+ }
847
+ });
848
+ }
849
+ return option;
823
850
  };
824
851
 
825
852
  export const hr = (attributes = {}) => {
826
- let hr = document.createElement("hr");
827
- if (attributes) {
828
- Object.entries(attributes).forEach(([name, attrValue]) => {
829
- switch (name) {
830
- case "class":
831
- case "className":
832
- hr.className = String(attrValue);
833
- break;
834
- case "style": Object.entries(attrValue).forEach(([styleName, styleValue]) => {
835
- switch (styleName) {
836
- case "zIndex": hr.style[styleName] = `99999${styleValue}`; break;
837
- default: hr.style[styleName] = styleValue; break;
838
- }
839
- }); break;
840
- default: hr.setAttribute(name, String(attrValue));
853
+ let hr = document.createElement("hr");
854
+ if (attributes) {
855
+ Object.entries(attributes).forEach(([name, attrValue]) => {
856
+ switch (name) {
857
+ case "class":
858
+ case "className":
859
+ hr.className = String(attrValue);
860
+ break;
861
+ case "style":
862
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
863
+ switch (styleName) {
864
+ case "zIndex":
865
+ hr.style[styleName] = `99999${styleValue}`;
866
+ break;
867
+ default:
868
+ hr.style[styleName] = styleValue;
869
+ break;
841
870
  }
842
- });
843
- }
844
- return hr;
871
+ });
872
+ break;
873
+ default:
874
+ hr.setAttribute(name, String(attrValue));
875
+ }
876
+ });
877
+ }
878
+ return hr;
845
879
  };
846
880
 
847
881
  export const meta = (attributes = {}) => {
848
- let meta = document.createElement("meta");
849
- if (attributes) {
850
- Object.entries(attributes).forEach(([name, attrValue]) => {
851
- switch (name) {
852
- case "class":
853
- case "className":
854
- meta.className = String(attrValue);
855
- break;
856
- case "style": Object.entries(attrValue).forEach(([styleName, styleValue]) => {
857
- switch (styleName) {
858
- case "zIndex": meta.style[styleName] = `99999${styleValue}`; break;
859
- default: meta.style[styleName] = styleValue; break;
860
- }
861
- }); break;
862
- default: meta.setAttribute(name, String(attrValue));
882
+ let meta = document.createElement("meta");
883
+ if (attributes) {
884
+ Object.entries(attributes).forEach(([name, attrValue]) => {
885
+ switch (name) {
886
+ case "class":
887
+ case "className":
888
+ meta.className = String(attrValue);
889
+ break;
890
+ case "style":
891
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
892
+ switch (styleName) {
893
+ case "zIndex":
894
+ meta.style[styleName] = `99999${styleValue}`;
895
+ break;
896
+ default:
897
+ meta.style[styleName] = styleValue;
898
+ break;
863
899
  }
864
- });
865
- }
866
- return meta;
900
+ });
901
+ break;
902
+ default:
903
+ meta.setAttribute(name, String(attrValue));
904
+ }
905
+ });
906
+ }
907
+ return meta;
867
908
  };
868
909
 
869
910
  export const table = (attributes = {}) => {
870
- let table = document.createElement("table");
871
- if (attributes) {
872
- Object.entries(attributes).forEach(([name, attrValue]) => {
873
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
874
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
875
- table.addEventListener(eventType, attrValue);
911
+ let table = document.createElement("table");
912
+ if (attributes) {
913
+ Object.entries(attributes).forEach(([name, attrValue]) => {
914
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
915
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
916
+ table.addEventListener(eventType, attrValue);
917
+ } else {
918
+ switch (name) {
919
+ case "class":
920
+ case "className":
921
+ table.className = String(attrValue);
922
+ break;
923
+ case "value":
924
+ if (isArray(attrValue)) {
925
+ attrValue.forEach((element) => {
926
+ isHtmlElement(element) ? table.append(element) : table.innerHTML = String(element);
927
+ });
876
928
  } else {
877
- switch (name) {
878
- case "class":
879
- case "className":
880
- table.className = String(attrValue);
881
- break;
882
- case "value":
883
- if (isArray(attrValue)) {
884
- attrValue.forEach((element) => {
885
- isHtmlElement(element) ? table.append(element) : table.innerHTML = String(element);
886
- });
887
- } else {
888
- if (isHtmlElement(attrValue)) {
889
- table.appendChild(attrValue);
890
- } else {
891
- table.innerHTML = String(attrValue);
892
- table.title = String(attrValue);
893
- }
894
- }
895
- break;
896
- case "style":
897
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
898
- switch (styleName) {
899
- case "zIndex":
900
- table.style[styleName] = `99999${styleValue}`;
901
- break;
902
- default:
903
- table.style[styleName] = styleValue;
904
- break;
905
- }
906
- });
907
- break;
908
- default:
909
- if (name.startsWith("data")) {
910
- const kebabName = name
911
- .replace(/^data/, "data")
912
- .replace(/([A-Z])/g, "-$1")
913
- .toLowerCase();
914
- table.setAttribute(kebabName, String(attrValue));
915
- } else {
916
- table.setAttribute(name, String(attrValue));
917
- }
918
- }
929
+ if (isHtmlElement(attrValue)) {
930
+ table.appendChild(attrValue);
931
+ } else {
932
+ table.innerHTML = String(attrValue);
933
+ table.title = String(attrValue);
934
+ }
919
935
  }
920
- });
921
- }
922
- return table;
936
+ break;
937
+ case "style":
938
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
939
+ switch (styleName) {
940
+ case "zIndex":
941
+ table.style[styleName] = `99999${styleValue}`;
942
+ break;
943
+ default:
944
+ table.style[styleName] = styleValue;
945
+ break;
946
+ }
947
+ });
948
+ break;
949
+ default:
950
+ if (name.startsWith("data")) {
951
+ const kebabName = name
952
+ .replace(/^data/, "data")
953
+ .replace(/([A-Z])/g, "-$1")
954
+ .toLowerCase();
955
+ table.setAttribute(kebabName, String(attrValue));
956
+ } else {
957
+ table.setAttribute(name, String(attrValue));
958
+ }
959
+ }
960
+ }
961
+ });
962
+ }
963
+ return table;
923
964
  };
924
965
 
925
966
  export const caption = (attributes = {}) => {
926
- let caption = document.createElement("caption");
927
- if (attributes) {
928
- Object.entries(attributes).forEach(([name, attrValue]) => {
929
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
930
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
931
- caption.addEventListener(eventType, attrValue);
967
+ let caption = document.createElement("caption");
968
+ if (attributes) {
969
+ Object.entries(attributes).forEach(([name, attrValue]) => {
970
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
971
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
972
+ caption.addEventListener(eventType, attrValue);
973
+ } else {
974
+ switch (name) {
975
+ case "side":
976
+ caption.style.captionSide = String(attrValue);
977
+ break;
978
+ case "class":
979
+ case "className":
980
+ caption.className = String(attrValue);
981
+ break;
982
+ case "value":
983
+ if (isArray(attrValue)) {
984
+ attrValue.forEach((element) => {
985
+ isHtmlElement(element) ? caption.append(element) : caption.innerHTML = String(element);
986
+ });
932
987
  } else {
933
- switch (name) {
934
- case "side":
935
- caption.style.captionSide = String(attrValue);
936
- break;
937
- case "class":
938
- case "className":
939
- caption.className = String(attrValue);
940
- break;
941
- case "value":
942
- if (isArray(attrValue)) {
943
- attrValue.forEach((element) => {
944
- isHtmlElement(element) ? caption.append(element) : caption.innerHTML = String(element);
945
- });
946
- } else {
947
- if (isHtmlElement(attrValue)) {
948
- caption.appendChild(attrValue);
949
- } else {
950
- caption.innerHTML = String(attrValue);
951
- caption.title = String(attrValue);
952
- }
953
- }
954
- break;
955
- case "style":
956
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
957
- switch (styleName) {
958
- case "zIndex":
959
- caption.style[styleName] = `99999${styleValue}`;
960
- break;
961
- default:
962
- caption.style[styleName] = styleValue;
963
- break;
964
- }
965
- });
966
- break;
967
- default:
968
- if (name.startsWith("data")) {
969
- const kebabName = name
970
- .replace(/^data/, "data")
971
- .replace(/([A-Z])/g, "-$1")
972
- .toLowerCase();
973
- caption.setAttribute(kebabName, String(attrValue));
974
- } else {
975
- caption.setAttribute(name, String(attrValue));
976
- }
977
- }
988
+ if (isHtmlElement(attrValue)) {
989
+ caption.appendChild(attrValue);
990
+ } else {
991
+ caption.innerHTML = String(attrValue);
992
+ caption.title = String(attrValue);
993
+ }
978
994
  }
979
- });
980
- }
981
- return caption;
995
+ break;
996
+ case "style":
997
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
998
+ switch (styleName) {
999
+ case "zIndex":
1000
+ caption.style[styleName] = `99999${styleValue}`;
1001
+ break;
1002
+ default:
1003
+ caption.style[styleName] = styleValue;
1004
+ break;
1005
+ }
1006
+ });
1007
+ break;
1008
+ default:
1009
+ if (name.startsWith("data")) {
1010
+ const kebabName = name
1011
+ .replace(/^data/, "data")
1012
+ .replace(/([A-Z])/g, "-$1")
1013
+ .toLowerCase();
1014
+ caption.setAttribute(kebabName, String(attrValue));
1015
+ } else {
1016
+ caption.setAttribute(name, String(attrValue));
1017
+ }
1018
+ }
1019
+ }
1020
+ });
1021
+ }
1022
+ return caption;
982
1023
  };
983
1024
 
984
1025
  export const thead = (attributes = {}) => {
985
- let thead = document.createElement("thead");
986
- if (attributes) {
987
- Object.entries(attributes).forEach(([name, attrValue]) => {
988
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
989
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
990
- thead.addEventListener(eventType, attrValue);
1026
+ let thead = document.createElement("thead");
1027
+ if (attributes) {
1028
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1029
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1030
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1031
+ thead.addEventListener(eventType, attrValue);
1032
+ } else {
1033
+ switch (name) {
1034
+ case "class":
1035
+ case "className":
1036
+ thead.className = String(attrValue);
1037
+ break;
1038
+ case "value":
1039
+ if (isArray(attrValue)) {
1040
+ attrValue.forEach((element) => {
1041
+ isHtmlElement(element) ? thead.append(element) : thead.innerHTML = String(element);
1042
+ });
991
1043
  } else {
992
- switch (name) {
993
- case "class":
994
- case "className":
995
- thead.className = String(attrValue);
996
- break;
997
- case "value":
998
- if (isArray(attrValue)) {
999
- attrValue.forEach((element) => {
1000
- isHtmlElement(element) ? thead.append(element) : thead.innerHTML = String(element);
1001
- });
1002
- } else {
1003
- if (isHtmlElement(attrValue)) {
1004
- thead.appendChild(attrValue);
1005
- } else {
1006
- thead.innerHTML = String(attrValue);
1007
- thead.title = String(attrValue);
1008
- }
1009
- }
1010
- break;
1011
- case "style":
1012
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1013
- switch (styleName) {
1014
- case "zIndex":
1015
- thead.style[styleName] = `99999${styleValue}`;
1016
- break;
1017
- default:
1018
- thead.style[styleName] = styleValue;
1019
- break;
1020
- }
1021
- });
1022
- break;
1023
- default:
1024
- if (name.startsWith("data")) {
1025
- const kebabName = name
1026
- .replace(/^data/, "data")
1027
- .replace(/([A-Z])/g, "-$1")
1028
- .toLowerCase();
1029
- thead.setAttribute(kebabName, String(attrValue));
1030
- } else {
1031
- thead.setAttribute(name, String(attrValue));
1032
- }
1033
- }
1044
+ if (isHtmlElement(attrValue)) {
1045
+ thead.appendChild(attrValue);
1046
+ } else {
1047
+ thead.innerHTML = String(attrValue);
1048
+ thead.title = String(attrValue);
1049
+ }
1034
1050
  }
1035
- });
1036
- }
1037
- return thead;
1051
+ break;
1052
+ case "style":
1053
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1054
+ switch (styleName) {
1055
+ case "zIndex":
1056
+ thead.style[styleName] = `99999${styleValue}`;
1057
+ break;
1058
+ default:
1059
+ thead.style[styleName] = styleValue;
1060
+ break;
1061
+ }
1062
+ });
1063
+ break;
1064
+ default:
1065
+ if (name.startsWith("data")) {
1066
+ const kebabName = name
1067
+ .replace(/^data/, "data")
1068
+ .replace(/([A-Z])/g, "-$1")
1069
+ .toLowerCase();
1070
+ thead.setAttribute(kebabName, String(attrValue));
1071
+ } else {
1072
+ thead.setAttribute(name, String(attrValue));
1073
+ }
1074
+ }
1075
+ }
1076
+ });
1077
+ }
1078
+ return thead;
1038
1079
  };
1039
1080
 
1040
1081
  export const tbody = (attributes = {}) => {
1041
- let tbody = document.createElement("tbody");
1042
- if (attributes) {
1043
- Object.entries(attributes).forEach(([name, attrValue]) => {
1044
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1045
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1046
- tbody.addEventListener(eventType, attrValue);
1082
+ let tbody = document.createElement("tbody");
1083
+ if (attributes) {
1084
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1085
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1086
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1087
+ tbody.addEventListener(eventType, attrValue);
1088
+ } else {
1089
+ switch (name) {
1090
+ case "class":
1091
+ case "className":
1092
+ tbody.className = String(attrValue);
1093
+ break;
1094
+ case "value":
1095
+ if (isArray(attrValue)) {
1096
+ attrValue.forEach((element) => {
1097
+ isHtmlElement(element) ? tbody.append(element) : tbody.innerHTML = String(element);
1098
+ });
1047
1099
  } else {
1048
- switch (name) {
1049
- case "class":
1050
- case "className":
1051
- tbody.className = String(attrValue);
1052
- break;
1053
- case "value":
1054
- if (isArray(attrValue)) {
1055
- attrValue.forEach((element) => {
1056
- isHtmlElement(element) ? tbody.append(element) : tbody.innerHTML = String(element);
1057
- });
1058
- } else {
1059
- if (isHtmlElement(attrValue)) {
1060
- tbody.appendChild(attrValue);
1061
- } else {
1062
- tbody.innerHTML = String(attrValue);
1063
- tbody.title = String(attrValue);
1064
- }
1065
- }
1066
- break;
1067
- case "style":
1068
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1069
- switch (styleName) {
1070
- case "zIndex":
1071
- tbody.style[styleName] = `99999${styleValue}`;
1072
- break;
1073
- default:
1074
- tbody.style[styleName] = styleValue;
1075
- break;
1076
- }
1077
- });
1078
- break;
1079
- default:
1080
- if (name.startsWith("data")) {
1081
- const kebabName = name
1082
- .replace(/^data/, "data")
1083
- .replace(/([A-Z])/g, "-$1")
1084
- .toLowerCase();
1085
- tbody.setAttribute(kebabName, String(attrValue));
1086
- } else {
1087
- tbody.setAttribute(name, String(attrValue));
1088
- }
1089
- }
1100
+ if (isHtmlElement(attrValue)) {
1101
+ tbody.appendChild(attrValue);
1102
+ } else {
1103
+ tbody.innerHTML = String(attrValue);
1104
+ tbody.title = String(attrValue);
1105
+ }
1090
1106
  }
1091
- });
1092
- }
1093
- return tbody;
1107
+ break;
1108
+ case "style":
1109
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1110
+ switch (styleName) {
1111
+ case "zIndex":
1112
+ tbody.style[styleName] = `99999${styleValue}`;
1113
+ break;
1114
+ default:
1115
+ tbody.style[styleName] = styleValue;
1116
+ break;
1117
+ }
1118
+ });
1119
+ break;
1120
+ default:
1121
+ if (name.startsWith("data")) {
1122
+ const kebabName = name
1123
+ .replace(/^data/, "data")
1124
+ .replace(/([A-Z])/g, "-$1")
1125
+ .toLowerCase();
1126
+ tbody.setAttribute(kebabName, String(attrValue));
1127
+ } else {
1128
+ tbody.setAttribute(name, String(attrValue));
1129
+ }
1130
+ }
1131
+ }
1132
+ });
1133
+ }
1134
+ return tbody;
1094
1135
  };
1095
1136
 
1096
1137
  export const tr = (attributes = {}) => {
1097
- let tr = document.createElement("tr");
1098
- if (attributes) {
1099
- Object.entries(attributes).forEach(([name, attrValue]) => {
1100
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1101
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1102
- tr.addEventListener(eventType, attrValue);
1138
+ let tr = document.createElement("tr");
1139
+ if (attributes) {
1140
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1141
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1142
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1143
+ tr.addEventListener(eventType, attrValue);
1144
+ } else {
1145
+ switch (name) {
1146
+ case "class":
1147
+ case "className":
1148
+ tr.className = String(attrValue);
1149
+ break;
1150
+ case "value":
1151
+ if (isArray(attrValue)) {
1152
+ attrValue.forEach((element) => {
1153
+ isHtmlElement(element) ? tr.append(element) : tr.innerHTML = String(element);
1154
+ });
1103
1155
  } else {
1104
- switch (name) {
1105
- case "class":
1106
- case "className":
1107
- tr.className = String(attrValue);
1108
- break;
1109
- case "value":
1110
- if (isArray(attrValue)) {
1111
- attrValue.forEach((element) => {
1112
- isHtmlElement(element) ? tr.append(element) : tr.innerHTML = String(element);
1113
- });
1114
- } else {
1115
- if (isHtmlElement(attrValue)) {
1116
- tr.appendChild(attrValue);
1117
- } else {
1118
- tr.innerHTML = String(attrValue);
1119
- tr.title = String(attrValue);
1120
- }
1121
- }
1122
- break;
1123
- case "style":
1124
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1125
- switch (styleName) {
1126
- case "zIndex":
1127
- tr.style[styleName] = `99999${styleValue}`;
1128
- break;
1129
- default:
1130
- tr.style[styleName] = styleValue;
1131
- break;
1132
- }
1133
- });
1134
- break;
1135
- default:
1136
- if (name.startsWith("data")) {
1137
- const kebabName = name
1138
- .replace(/^data/, "data")
1139
- .replace(/([A-Z])/g, "-$1")
1140
- .toLowerCase();
1141
- tr.setAttribute(kebabName, String(attrValue));
1142
- } else {
1143
- tr.setAttribute(name, String(attrValue));
1144
- }
1145
- }
1156
+ if (isHtmlElement(attrValue)) {
1157
+ tr.appendChild(attrValue);
1158
+ } else {
1159
+ tr.innerHTML = String(attrValue);
1160
+ tr.title = String(attrValue);
1161
+ }
1146
1162
  }
1147
- });
1148
- }
1149
- return tr;
1163
+ break;
1164
+ case "style":
1165
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1166
+ switch (styleName) {
1167
+ case "zIndex":
1168
+ tr.style[styleName] = `99999${styleValue}`;
1169
+ break;
1170
+ default:
1171
+ tr.style[styleName] = styleValue;
1172
+ break;
1173
+ }
1174
+ });
1175
+ break;
1176
+ default:
1177
+ if (name.startsWith("data")) {
1178
+ const kebabName = name
1179
+ .replace(/^data/, "data")
1180
+ .replace(/([A-Z])/g, "-$1")
1181
+ .toLowerCase();
1182
+ tr.setAttribute(kebabName, String(attrValue));
1183
+ } else {
1184
+ tr.setAttribute(name, String(attrValue));
1185
+ }
1186
+ }
1187
+ }
1188
+ });
1189
+ }
1190
+ return tr;
1150
1191
  };
1151
1192
 
1152
1193
  export const th = (attributes = {}) => {
1153
- let th = document.createElement("th");
1154
- if (attributes) {
1155
- Object.entries(attributes).forEach(([name, attrValue]) => {
1156
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1157
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1158
- th.addEventListener(eventType, attrValue);
1194
+ let th = document.createElement("th");
1195
+ if (attributes) {
1196
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1197
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1198
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1199
+ th.addEventListener(eventType, attrValue);
1200
+ } else {
1201
+ switch (name) {
1202
+ case "class":
1203
+ case "className":
1204
+ th.className = String(attrValue);
1205
+ break;
1206
+ case "value":
1207
+ if (isArray(attrValue)) {
1208
+ attrValue.forEach((element) => {
1209
+ isHtmlElement(element) ? th.append(element) : th.innerHTML = String(element);
1210
+ });
1159
1211
  } else {
1160
- switch (name) {
1161
- case "class":
1162
- case "className":
1163
- th.className = String(attrValue);
1164
- break;
1165
- case "value":
1166
- if (isArray(attrValue)) {
1167
- attrValue.forEach((element) => {
1168
- isHtmlElement(element) ? th.append(element) : th.innerHTML = String(element);
1169
- });
1170
- } else {
1171
- if (isHtmlElement(attrValue)) {
1172
- th.appendChild(attrValue);
1173
- } else {
1174
- th.innerHTML = String(attrValue);
1175
- th.title = String(attrValue);
1176
- }
1177
- }
1178
- break;
1179
- case "style":
1180
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1181
- switch (styleName) {
1182
- case "zIndex":
1183
- th.style[styleName] = `99999${styleValue}`;
1184
- break;
1185
- default:
1186
- th.style[styleName] = styleValue;
1187
- break;
1188
- }
1189
- });
1190
- break;
1191
- default:
1192
- if (name.startsWith("data")) {
1193
- const kebabName = name
1194
- .replace(/^data/, "data")
1195
- .replace(/([A-Z])/g, "-$1")
1196
- .toLowerCase();
1197
- th.setAttribute(kebabName, String(attrValue));
1198
- } else {
1199
- th.setAttribute(name, String(attrValue));
1200
- }
1201
- }
1212
+ if (isHtmlElement(attrValue)) {
1213
+ th.appendChild(attrValue);
1214
+ } else {
1215
+ th.innerHTML = String(attrValue);
1216
+ th.title = String(attrValue);
1217
+ }
1202
1218
  }
1203
- });
1204
- }
1205
- return th;
1219
+ break;
1220
+ case "style":
1221
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1222
+ switch (styleName) {
1223
+ case "zIndex":
1224
+ th.style[styleName] = `99999${styleValue}`;
1225
+ break;
1226
+ default:
1227
+ th.style[styleName] = styleValue;
1228
+ break;
1229
+ }
1230
+ });
1231
+ break;
1232
+ default:
1233
+ if (name.startsWith("data")) {
1234
+ const kebabName = name
1235
+ .replace(/^data/, "data")
1236
+ .replace(/([A-Z])/g, "-$1")
1237
+ .toLowerCase();
1238
+ th.setAttribute(kebabName, String(attrValue));
1239
+ } else {
1240
+ th.setAttribute(name, String(attrValue));
1241
+ }
1242
+ }
1243
+ }
1244
+ });
1245
+ }
1246
+ return th;
1206
1247
  };
1207
1248
 
1208
1249
  export const td = (attributes = {}) => {
1209
- let td = document.createElement("td");
1210
- if (attributes) {
1211
- Object.entries(attributes).forEach(([name, attrValue]) => {
1212
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1213
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1214
- td.addEventListener(eventType, attrValue);
1250
+ let td = document.createElement("td");
1251
+ if (attributes) {
1252
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1253
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1254
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1255
+ td.addEventListener(eventType, attrValue);
1256
+ } else {
1257
+ switch (name) {
1258
+ case "class":
1259
+ case "className":
1260
+ td.className = String(attrValue);
1261
+ break;
1262
+ case "value":
1263
+ if (isArray(attrValue)) {
1264
+ attrValue.forEach((element) => {
1265
+ isHtmlElement(element) ? td.append(element) : td.innerHTML = String(element);
1266
+ });
1215
1267
  } else {
1216
- switch (name) {
1217
- case "class":
1218
- case "className":
1219
- td.className = String(attrValue);
1220
- break;
1221
- case "value":
1222
- if (isArray(attrValue)) {
1223
- attrValue.forEach((element) => {
1224
- isHtmlElement(element) ? td.append(element) : td.innerHTML = String(element);
1225
- });
1226
- } else {
1227
- if (isHtmlElement(attrValue)) {
1228
- td.appendChild(attrValue);
1229
- } else {
1230
- td.innerHTML = String(attrValue);
1231
- td.title = String(attrValue);
1232
- }
1233
- }
1234
- break;
1235
- case "style":
1236
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1237
- switch (styleName) {
1238
- case "zIndex":
1239
- td.style[styleName] = `99999${styleValue}`;
1240
- break;
1241
- default:
1242
- td.style[styleName] = styleValue;
1243
- break;
1244
- }
1245
- });
1246
- break;
1247
- default:
1248
- if (name.startsWith("data")) {
1249
- const kebabName = name
1250
- .replace(/^data/, "data")
1251
- .replace(/([A-Z])/g, "-$1")
1252
- .toLowerCase();
1253
- td.setAttribute(kebabName, String(attrValue));
1254
- } else {
1255
- td.setAttribute(name, String(attrValue));
1256
- }
1257
- }
1268
+ if (isHtmlElement(attrValue)) {
1269
+ td.appendChild(attrValue);
1270
+ } else {
1271
+ td.innerHTML = String(attrValue);
1272
+ td.title = String(attrValue);
1273
+ }
1258
1274
  }
1259
- });
1260
- }
1261
- return td;
1275
+ break;
1276
+ case "style":
1277
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1278
+ switch (styleName) {
1279
+ case "zIndex":
1280
+ td.style[styleName] = `99999${styleValue}`;
1281
+ break;
1282
+ default:
1283
+ td.style[styleName] = styleValue;
1284
+ break;
1285
+ }
1286
+ });
1287
+ break;
1288
+ default:
1289
+ if (name.startsWith("data")) {
1290
+ const kebabName = name
1291
+ .replace(/^data/, "data")
1292
+ .replace(/([A-Z])/g, "-$1")
1293
+ .toLowerCase();
1294
+ td.setAttribute(kebabName, String(attrValue));
1295
+ } else {
1296
+ td.setAttribute(name, String(attrValue));
1297
+ }
1298
+ }
1299
+ }
1300
+ });
1301
+ }
1302
+ return td;
1262
1303
  };
1263
1304
 
1264
1305
  export const img = (attributes = {}) => {
1265
- let img = document.createElement("img");
1266
- img.alt = "img...";
1267
- if (attributes) {
1268
- Object.entries(attributes).forEach(([name, attrValue]) => {
1269
- if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1270
- const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1271
- img.addEventListener(eventType, attrValue);
1306
+ let img = document.createElement("img");
1307
+ img.alt = "img...";
1308
+ if (attributes) {
1309
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1310
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1311
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1312
+ img.addEventListener(eventType, attrValue);
1313
+ } else {
1314
+ switch (name) {
1315
+ case "class":
1316
+ case "className":
1317
+ img.className = String(attrValue);
1318
+ break;
1319
+ case "src":
1320
+ img.src = String(attrValue);
1321
+ break;
1322
+ case "alt":
1323
+ img.alt = String(attrValue);
1324
+ break;
1325
+ case "style":
1326
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1327
+ switch (styleName) {
1328
+ case "zIndex":
1329
+ img.style[styleName] = `99999${styleValue}`;
1330
+ break;
1331
+ default:
1332
+ img.style[styleName] = styleValue;
1333
+ break;
1334
+ }
1335
+ });
1336
+ break;
1337
+ default:
1338
+ if (name.startsWith("data")) {
1339
+ const kebabName = name
1340
+ .replace(/^data/, "data")
1341
+ .replace(/([A-Z])/g, "-$1")
1342
+ .toLowerCase();
1343
+ img.setAttribute(kebabName, String(attrValue));
1272
1344
  } else {
1273
- switch (name) {
1274
- case "class":
1275
- case "className":
1276
- img.className = String(attrValue);
1277
- break;
1278
- case "src":
1279
- img.src = String(attrValue);
1280
- break;
1281
- case "alt":
1282
- img.alt = String(attrValue);
1283
- break;
1284
- case "style":
1285
- Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1286
- switch (styleName) {
1287
- case "zIndex":
1288
- img.style[styleName] = `99999${styleValue}`;
1289
- break;
1290
- default:
1291
- img.style[styleName] = styleValue;
1292
- break;
1293
- }
1294
- });
1295
- break;
1296
- default:
1297
- if (name.startsWith("data")) {
1298
- const kebabName = name
1299
- .replace(/^data/, "data")
1300
- .replace(/([A-Z])/g, "-$1")
1301
- .toLowerCase();
1302
- img.setAttribute(kebabName, String(attrValue));
1303
- } else {
1304
- img.setAttribute(name, String(attrValue));
1305
- }
1306
- }
1345
+ img.setAttribute(name, String(attrValue));
1307
1346
  }
1308
- });
1309
- }
1310
- return img;
1347
+ }
1348
+ }
1349
+ });
1350
+ }
1351
+ return img;
1311
1352
  };
1312
1353
 
1313
1354
  export const apState = (initialValue) => {
1314
- let state = initialValue;
1315
- const getState = () => state;
1316
- const setState = (newValue) => {
1317
- if (typeof newValue === "function") {
1318
- state = newValue(state);
1319
- } else {
1320
- state = newValue;
1321
- }
1355
+ let state = initialValue;
1356
+ const getState = () => state;
1357
+ const setState = (newValue) => {
1358
+ if (typeof newValue === "function") {
1359
+ state = newValue(state);
1360
+ } else {
1361
+ state = newValue;
1322
1362
  }
1323
- return [getState, setState];
1363
+ }
1364
+ return [getState, setState];
1324
1365
  };
1325
1366
 
1326
1367
  export const apFetch = async (url, params = {}) => {
1327
- const [data, setData] = apState(null);
1328
- const [error, setError] = apState(null);
1329
- const [isLoading, setIsLoading] = apState(false);
1330
-
1331
- const fetchData = async () => {
1332
- setIsLoading(true);
1333
- setError(null);
1334
- try {
1335
- const response = await fetch(url, params);
1336
- if (!response.ok) {
1337
- throw new Error(`HTTP error! Status: ${response.status}`);
1338
- }
1339
- const result = await response.json();
1340
- setData(result);
1341
- } catch (err) {
1342
- console.error(err.message)
1343
- setError(err.message);
1344
- } finally {
1345
- setIsLoading(false);
1346
- }
1347
- };
1348
- await fetchData();
1368
+ const [data, setData] = apState(null);
1369
+ const [error, setError] = apState(null);
1370
+ const [isLoading, setIsLoading] = apState(false);
1371
+
1372
+ const fetchData = async () => {
1373
+ setIsLoading(true);
1374
+ setError(null);
1375
+ try {
1376
+ const response = await fetch(url, params);
1377
+ if (!response.ok) {
1378
+ throw new Error(`HTTP error! Status: ${response.status}`);
1379
+ }
1380
+ const result = await response.json();
1381
+ setData(result);
1382
+ } catch (err) {
1383
+ console.error(err.message)
1384
+ setError(err.message);
1385
+ } finally {
1386
+ setIsLoading(false);
1387
+ }
1388
+ };
1389
+ await fetchData();
1349
1390
 
1350
- return [data, error, isLoading];
1391
+ return [data, error, isLoading];
1351
1392
  };
1352
1393
 
1353
1394
  export const scrollToTop = () => {
1354
- window.scrollTo({
1355
- top: 0,
1356
- behavior: "smooth",
1357
- });
1395
+ window.scrollTo({
1396
+ top: 0,
1397
+ behavior: "smooth",
1398
+ });
1358
1399
  };
1359
1400
 
1360
1401
  export const scrollToBottom = () => {
1361
- window.scrollTo({
1362
- top: document.documentElement.scrollHeight,
1363
- behavior: "smooth",
1364
- });
1402
+ window.scrollTo({
1403
+ top: document.documentElement.scrollHeight,
1404
+ behavior: "smooth",
1405
+ });
1365
1406
  };
1366
1407
 
1367
1408
  export const _get = (name, defaulting = null) => {
1368
- let url = new URL(window.location.href);
1369
- let searchParams = new URLSearchParams(url.search);
1370
- if (searchParams.has(name)) {
1371
- return isFloat(searchParams.get(name)) || isNumeric(searchParams.get(name))
1372
- ? parseFloat(searchParams.get(name))
1373
- : searchParams.get(name);
1374
- }
1375
- return defaulting;
1409
+ let url = new URL(window.location.href);
1410
+ let searchParams = new URLSearchParams(url.search);
1411
+ if (searchParams.has(name)) {
1412
+ return isFloat(searchParams.get(name)) || isNumeric(searchParams.get(name))
1413
+ ? parseFloat(searchParams.get(name))
1414
+ : searchParams.get(name);
1415
+ }
1416
+ return defaulting;
1376
1417
  };
1377
1418
 
1378
1419
  export const _getAll = () => {
1379
- let url = new URL(window.location.href);
1380
- let searchParams = new URLSearchParams(url.search);
1381
- let params = {};
1382
- searchParams.forEach((value, key) => {
1383
- params[key] = isFloat(value) || isNumeric(value) ? parseFloat(value) : value;
1384
- });
1385
- return params;
1420
+ let url = new URL(window.location.href);
1421
+ let searchParams = new URLSearchParams(url.search);
1422
+ let params = {};
1423
+ searchParams.forEach((value, key) => {
1424
+ params[key] = isFloat(value) || isNumeric(value) ? parseFloat(value) : value;
1425
+ });
1426
+ return params;
1386
1427
  };
1387
1428
 
1388
1429
  export const GUID = () => {
1389
- return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
1390
- const random = Math.random() * 16 | 0;
1391
- const value = char === 'x' ? random : (random & 0x3 | 0x8);
1392
- return value.toString(16);
1393
- });
1430
+ let uuid = 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (char) {
1431
+ const random = Math.random() * 16 | 0;
1432
+ const value = char === 'x' ? random : (random & 0x3 | 0x8);
1433
+ return value.toString(16);
1434
+ });
1435
+
1436
+ if (/^[0-9]/.test(uuid)) {
1437
+ const letter = String.fromCharCode(97 + Math.floor(Math.random() * 6)); // a–f
1438
+ uuid = letter + uuid.slice(1);
1439
+ }
1440
+
1441
+ return uuid;
1394
1442
  };
1395
1443
 
1396
1444
  export const checkArrays = (arr1, arr2, checkAll = false) => {
1397
- const set1 = new Set(arr1);
1398
- if (checkAll) {
1399
- return arr2.every(item => set1.has(item));
1400
- } else {
1401
- return arr2.some(item => set1.has(item));
1402
- }
1445
+ const set1 = new Set(arr1);
1446
+ if (checkAll) {
1447
+ return arr2.every(item => set1.has(item));
1448
+ } else {
1449
+ return arr2.some(item => set1.has(item));
1450
+ }
1403
1451
  };
1404
1452
 
1405
1453
  const customTitle = (text) => {
1406
- const title = div({
1407
- id: "tooltip",
1408
- style: {
1409
- position: "absolute",
1410
- padding: "6px 10px",
1411
- display: "block",
1412
- fontSize: "10px",
1413
- whiteSpace: "nowrap",
1414
- color: "#ffffff",
1415
- background: "rgba(51, 51, 51, 0.8)",
1416
- borderRadius: "0.5rem",
1417
- boxShadow: "0 3 7 rgba(51, 51, 51, 0.8)",
1418
- pointerEvents: "none",
1419
- zIndex: 1000,
1420
- },
1421
- value: text
1422
- });
1423
- document.body.appendChild(title);
1454
+ const title = div({
1455
+ id: "tooltip",
1456
+ style: {
1457
+ position: "absolute",
1458
+ padding: "6px 10px",
1459
+ display: "block",
1460
+ fontSize: "10px",
1461
+ whiteSpace: "nowrap",
1462
+ color: "#ffffff",
1463
+ background: "rgba(51, 51, 51, 0.8)",
1464
+ borderRadius: "0.5rem",
1465
+ boxShadow: "0 3 7 rgba(51, 51, 51, 0.8)",
1466
+ pointerEvents: "none",
1467
+ zIndex: 1000,
1468
+ },
1469
+ value: text
1470
+ });
1471
+ document.body.appendChild(title);
1424
1472
 
1425
- return title;
1473
+ return title;
1426
1474
  };
1427
1475
 
1428
1476
  export const attachCustomTitle = (element, text) => {
1429
- let tooltip = element._customTooltip;
1477
+ let tooltip = element._customTooltip;
1430
1478
 
1431
- if (!tooltip) {
1432
- tooltip = customTitle(text);
1433
- element._customTooltip = tooltip;
1434
- }
1479
+ if (!tooltip) {
1480
+ tooltip = customTitle(text);
1481
+ element._customTooltip = tooltip;
1482
+ }
1435
1483
 
1436
- element.addEventListener("mouseenter", () => {
1437
- tooltip.style.display = "block";
1438
- });
1484
+ element.addEventListener("mouseenter", () => {
1485
+ tooltip.style.display = "block";
1486
+ });
1439
1487
 
1440
- element.addEventListener("mousemove", (e) => {
1441
- tooltip.style.left = `${e.pageX + 10}px`;
1442
- tooltip.style.top = `${e.pageY + 10}px`;
1443
- });
1488
+ element.addEventListener("mousemove", (e) => {
1489
+ tooltip.style.left = `${e.pageX + 10}px`;
1490
+ tooltip.style.top = `${e.pageY + 10}px`;
1491
+ });
1444
1492
 
1445
- element.addEventListener("mouseleave", () => {
1446
- tooltip.style.display = "none";
1447
- });
1493
+ element.addEventListener("mouseleave", () => {
1494
+ tooltip.style.display = "none";
1495
+ });
1448
1496
  };
1449
1497
 
1450
1498
  export const parseCustomMarkup = (text) => {
1451
- text = text.replace(/```([\s\S]*?)```/g, (match, p1) => {
1452
- return `<pre style="width: max-content; padding: 2px 8px; color: #333333; background-color: #fdfdfd; border: 0.03125rem solid #dddddd; border-radius: 4px;"><code style="font-family: Monospaced, serif; font-style: italic; font-weight: 100; letter-spacing: 2px;">${p1.trim()}</code></pre>`;
1453
- });
1454
- text = text.replace(/\*\*(.*?)\*\*/g, '<strong style="font-weight: 700;">$1</strong>');
1455
- text = text.replace(/`([^`]+?)`/g, '<code style="font-family: Monospaced, serif; font-style: italic; font-weight: 100; letter-spacing: 2px;">$1</code>');
1456
- text = text.replace(/^\* (.+)$/gm, '<li style="font-family: Times New Roman, serif; font-weight: 400;">$1</li>');
1457
- return `<div style="font-family: Times New Roman, serif; font-weight: 400;">${text}</div>`;
1499
+ text = text.replace(/```([\s\S]*?)```/g, (match, p1) => {
1500
+ return `<pre style="width: max-content; padding: 2px 8px; color: #333333; background-color: #fdfdfd; border: 0.03125rem solid #dddddd; border-radius: 4px;"><code style="font-family: Monospaced, serif; font-style: italic; font-weight: 100; letter-spacing: 2px;">${p1.trim()}</code></pre>`;
1501
+ });
1502
+ text = text.replace(/\*\*(.*?)\*\*/g, '<strong style="font-weight: 700;">$1</strong>');
1503
+ text = text.replace(/`([^`]+?)`/g, '<code style="font-family: Monospaced, serif; font-style: italic; font-weight: 100; letter-spacing: 2px;">$1</code>');
1504
+ text = text.replace(/^\* (.+)$/gm, '<li style="font-family: Times New Roman, serif; font-weight: 400;">$1</li>');
1505
+ return `<div style="font-family: Times New Roman, serif; font-weight: 400;">${text}</div>`;
1458
1506
  }