aprog 2.3.31 → 2.3.40

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/index.js CHANGED
@@ -1,7 +1,5 @@
1
1
  export {
2
- div, span, button, a, img, meta, label, input, select, option, options, form, hr, textarea,
3
- table, caption, thead, tbody, tr, th, td, pre,
4
- attachCustomTitle, _get, _getAll, GUID, isEmpty, apState, date, pause, apFetch, parseCustomMarkup,
2
+ options, attachCustomTitle, _get, _getAll, GUID, isEmpty, apState, date, pause, apFetch, parseCustomMarkup,
5
3
  chars, isNull, isFloat, isNumeric, isObject, elementToObject, copyText, scrollToTop, scrollToBottom,
6
4
  firstKey, isArray, checkArrays, isNumber, isString, isPromise, ucfirst, deepEqual, nodeListToObject
7
5
  } from './src/general.js';
@@ -21,13 +19,24 @@ export {
21
19
  toSnakeCaseStringPrototype, repeatHTMLElementPrototype,
22
20
  replaceChildrenHTMLElementPrototype
23
21
  } from './src/html.js';
24
- export { prism } from "./src/prism.js";
25
- export { uniquePage } from "./src/pages.js";
26
- export { state, wrap, toast, abort, useTableDrag, callback } from "./src/helper.js";
27
- export { loadTranslations, translate } from "./src/translator.js";
28
- export { svg } from "./src/svg.js";
29
- export { Modal, modal, closeAllModals, closeThisModal } from "./src/modal.js";
30
- export { default as AbortError } from './src/classes/AbortError.js';
31
- export { default as SmartWrapper } from './src/classes/SmartWrapper.js';
32
- export { default as StateWrapper } from './src/classes/StateWrapper.js';
33
- export { default as Toast } from './src/classes/Toast.js';
22
+ export {prism} from "./src/prism.js";
23
+ export {uniquePage} from "./src/pages.js";
24
+ export {state, wrap, toast, abort, useTableDrag, callback, json} from "./src/helper.js";
25
+ export {initAprog} from './src/config.js';
26
+ export {loadTranslations, translate} from "./src/translator.js";
27
+ export {svg} from "./src/svg.js";
28
+ export {Modal, modal, closeAllModals, closeThisModal} from "./src/modal.js";
29
+ export {default as AbortError} from './src/classes/AbortError.js';
30
+ export {default as SmartWrapper} from './src/classes/SmartWrapper.js';
31
+ export {default as StateWrapper} from './src/classes/StateWrapper.js';
32
+ export {default as Toast} from './src/classes/Toast.js';
33
+ export {ButtonConstructor} from './src/constructs/ButtonConstructor.js';
34
+ export {InputConstructor} from './src/constructs/InputConstructor.js';
35
+ export {SelectConstructor} from './src/constructs/SelectConstructor.js';
36
+ export {
37
+ div, span, a, button, img, input, select, option,
38
+ label, ul, li, hr, section, header, footer, textarea,
39
+ form, table, thead, tbody, tr, th, td, caption,
40
+ head, meta, body, pre, h1, h2, h3, h4, h5,
41
+ style, script, element
42
+ } from "./src/elements.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "aprog",
3
- "version": "2.3.31",
3
+ "version": "2.3.40",
4
4
  "description": "Допоміжна JavaScript-бібліотека для проєктів",
5
5
  "main": "index.js",
6
6
  "exports": {
package/src/config.js ADDED
@@ -0,0 +1,9 @@
1
+ const config = {
2
+ langLoader: null,
3
+ };
4
+
5
+ export const initAprog = (options = {}) => {
6
+ Object.assign(config, options);
7
+ };
8
+
9
+ export const getAprogConfig = () => config;
@@ -1,5 +1,4 @@
1
1
  import {button, GUID} from "aprog";
2
- import "aprog/css/styles";
3
2
 
4
3
  /**
5
4
  * AprogJS Constructor
@@ -1,5 +1,4 @@
1
1
  import {GUID, input} from "aprog";
2
- import "aprog/css/styles";
3
2
 
4
3
  /**
5
4
  * AprogJS Constructor
@@ -1,5 +1,4 @@
1
1
  import {GUID, select} from "aprog";
2
- import "aprog/css/styles";
3
2
 
4
3
  /**
5
4
  * AprogJS Constructor
@@ -0,0 +1,215 @@
1
+ const appendValue = (element, value) => {
2
+ if (value === null || value === undefined || value === false) {
3
+ return;
4
+ }
5
+
6
+ if (Array.isArray(value)) {
7
+ value.forEach(item => appendValue(element, item));
8
+ return;
9
+ }
10
+
11
+ if (value instanceof Node) {
12
+ element.append(value);
13
+ return;
14
+ }
15
+
16
+ element.insertAdjacentHTML("beforeend", String(value));
17
+ };
18
+
19
+ const setStyle = (element, styles) => {
20
+ if (typeof styles === "string") {
21
+ element.style.cssText = styles;
22
+ return;
23
+ }
24
+
25
+ Object.assign(element.style, styles);
26
+ };
27
+
28
+ const setDataset = (element, dataset) => {
29
+ Object.entries(dataset).forEach(([key, value]) => {
30
+ element.dataset[key] = String(value);
31
+ });
32
+ };
33
+
34
+ const setAttributes = (element, attributes = {}) => {
35
+ Object.entries(attributes).forEach(([name, value]) => {
36
+ if (value === null || value === undefined || value === false) {
37
+ return;
38
+ }
39
+
40
+ // content
41
+ if (name === "value" && !["INPUT", "TEXTAREA", "SELECT", "OPTION"].includes(element.tagName)) {
42
+ appendValue(element, value);
43
+ return;
44
+ }
45
+
46
+ // children
47
+ if (name === "children") {
48
+ appendValue(element, value);
49
+ return;
50
+ }
51
+
52
+ // text
53
+ if (name === "text" || name === "textContent") {
54
+ element.textContent = String(value);
55
+ return;
56
+ }
57
+
58
+ // html
59
+ if (name === "html" || name === "innerHTML") {
60
+ element.innerHTML = String(value);
61
+ return;
62
+ }
63
+
64
+ // class
65
+ if (name === "class" || name === "className") {
66
+ if (Array.isArray(value)) {
67
+ element.className = value.filter(Boolean).join(" ");
68
+ } else {
69
+ element.className = String(value);
70
+ }
71
+
72
+ return;
73
+ }
74
+
75
+ // style
76
+ if (name === "style") {
77
+ setStyle(element, value);
78
+ return;
79
+ }
80
+
81
+ // dataset
82
+ if (name === "dataset") {
83
+ setDataset(element, value);
84
+ return;
85
+ }
86
+
87
+ // events
88
+ if (name.startsWith("on") && typeof value === "function") {
89
+ element.addEventListener(name.slice(2).toLowerCase(), value);
90
+
91
+ return;
92
+ }
93
+
94
+ // focus
95
+ if (name === "focus" && value) {
96
+ queueMicrotask(() => element.focus());
97
+ return;
98
+ }
99
+
100
+ // DOM properties
101
+ if (name in element) {
102
+ try {
103
+ element[name] = value;
104
+ return;
105
+ } catch (_) {
106
+ // fallback → setAttribute
107
+ }
108
+ }
109
+
110
+ // dataSomething → data-something
111
+ if (name.startsWith("data") && name.length > 4) {
112
+ const attribute = name
113
+ .replace(/([A-Z])/g, "-$1")
114
+ .toLowerCase();
115
+
116
+ element.setAttribute(attribute, String(value));
117
+ return;
118
+ }
119
+
120
+ // ariaSomething → aria-something
121
+ if (name.startsWith("aria") && name.length > 4) {
122
+ const attribute = name
123
+ .replace(/([A-Z])/g, "-$1")
124
+ .toLowerCase();
125
+
126
+ element.setAttribute(attribute, String(value));
127
+ return;
128
+ }
129
+
130
+ // boolean attribute
131
+ if (value === true) {
132
+ element.setAttribute(name, "");
133
+ return;
134
+ }
135
+
136
+ // everything else
137
+ element.setAttribute(name, String(value));
138
+ });
139
+
140
+ return element;
141
+ };
142
+
143
+ export const element = (tag = "div", attributes = {}) => {
144
+ return setAttributes(document.createElement(tag), attributes);
145
+ };
146
+
147
+ export const div = (attributes = {}) => element("div", attributes);
148
+
149
+ export const span = (attributes = {}) => element("span", attributes);
150
+
151
+ export const a = (attributes = {}) => element("a", attributes);
152
+
153
+ export const button = (attributes = {}) => element("button", attributes);
154
+
155
+ export const input = (attributes = {}) => element("input", attributes);
156
+
157
+ export const label = (attributes = {}) => element("label", attributes);
158
+
159
+ export const form = (attributes = {}) => element("form", attributes);
160
+
161
+ export const textarea = (attributes = {}) => element("textarea", attributes);
162
+
163
+ export const pre = (attributes = {}) => element("pre", attributes);
164
+
165
+ export const select = (attributes = {}) => element("select", attributes);
166
+
167
+ export const option = (attributes = {}) => element("option", attributes);
168
+
169
+ export const img = (attributes = {}) => element("img", attributes);
170
+
171
+ export const table = (attributes = {}) => element("table", attributes);
172
+
173
+ export const caption = (attributes = {}) => element("caption", attributes);
174
+
175
+ export const thead = (attributes = {}) => element("thead", attributes);
176
+
177
+ export const tbody = (attributes = {}) => element("tbody", attributes);
178
+
179
+ export const tr = (attributes = {}) => element("tr", attributes);
180
+
181
+ export const th = (attributes = {}) => element("th", attributes);
182
+
183
+ export const td = (attributes = {}) => element("td", attributes);
184
+
185
+ export const h1 = (attributes = {}) => element("h1", attributes);
186
+
187
+ export const h2 = (attributes = {}) => element("h2", attributes);
188
+
189
+ export const h3 = (attributes = {}) => element("h3", attributes);
190
+
191
+ export const h4 = (attributes = {}) => element("h4", attributes);
192
+
193
+ export const h5 = (attributes = {}) => element("h5", attributes);
194
+
195
+ export const section = (attributes = {}) => element("section", attributes);
196
+
197
+ export const header = (attributes = {}) => element("header", attributes);
198
+
199
+ export const footer = (attributes = {}) => element("footer", attributes);
200
+
201
+ export const ul = (attributes = {}) => element("ul", attributes);
202
+
203
+ export const li = (attributes = {}) => element("li", attributes);
204
+
205
+ export const hr = (attributes = {}) => element("hr", attributes);
206
+
207
+ export const head = (attributes = {}) => element("head", attributes);
208
+
209
+ export const body = (attributes = {}) => element("body", attributes);
210
+
211
+ export const meta = (attributes = {}) => element("meta", attributes);
212
+
213
+ export const style = (attributes = {}) => element("style", attributes);
214
+
215
+ export const script = (attributes = {}) => element("script", attributes);
package/src/general.js CHANGED
@@ -1351,6 +1351,230 @@ export const img = (attributes = {}) => {
1351
1351
  return img;
1352
1352
  };
1353
1353
 
1354
+ export const h1 = (attributes = {}) => {
1355
+ let h1 = document.createElement("h1");
1356
+ if (attributes) {
1357
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1358
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1359
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1360
+ h1.addEventListener(eventType, attrValue);
1361
+ } else {
1362
+ switch (name) {
1363
+ case "class":
1364
+ case "className":
1365
+ h1.className = String(attrValue);
1366
+ break;
1367
+ case "value":
1368
+ if (isArray(attrValue)) {
1369
+ attrValue.forEach((element) => {
1370
+ isHtmlElement(element) ? h1.append(element) : h1.innerHTML = String(element);
1371
+ });
1372
+ } else {
1373
+ if (isHtmlElement(attrValue)) {
1374
+ h1.appendChild(attrValue);
1375
+ } else {
1376
+ h1.innerHTML = String(attrValue);
1377
+ h1.title = String(attrValue);
1378
+ }
1379
+ }
1380
+ break;
1381
+ case "style":
1382
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1383
+ switch (styleName) {
1384
+ case "zIndex":
1385
+ h1.style[styleName] = `99999${styleValue}`;
1386
+ break;
1387
+ default:
1388
+ h1.style[styleName] = styleValue;
1389
+ break;
1390
+ }
1391
+ });
1392
+ break;
1393
+ default:
1394
+ if (name.startsWith("data")) {
1395
+ const kebabName = name
1396
+ .replace(/^data/, "data")
1397
+ .replace(/([A-Z])/g, "-$1")
1398
+ .toLowerCase();
1399
+ h1.setAttribute(kebabName, String(attrValue));
1400
+ } else {
1401
+ h1.setAttribute(name, String(attrValue));
1402
+ }
1403
+ }
1404
+ }
1405
+ });
1406
+ }
1407
+ return h1;
1408
+ };
1409
+
1410
+ export const h2 = (attributes = {}) => {
1411
+ let h2 = document.createElement("h2");
1412
+ if (attributes) {
1413
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1414
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1415
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1416
+ h2.addEventListener(eventType, attrValue);
1417
+ } else {
1418
+ switch (name) {
1419
+ case "class":
1420
+ case "className":
1421
+ h2.className = String(attrValue);
1422
+ break;
1423
+ case "value":
1424
+ if (isArray(attrValue)) {
1425
+ attrValue.forEach((element) => {
1426
+ isHtmlElement(element) ? h2.append(element) : h2.innerHTML = String(element);
1427
+ });
1428
+ } else {
1429
+ if (isHtmlElement(attrValue)) {
1430
+ h2.appendChild(attrValue);
1431
+ } else {
1432
+ h2.innerHTML = String(attrValue);
1433
+ h2.title = String(attrValue);
1434
+ }
1435
+ }
1436
+ break;
1437
+ case "style":
1438
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1439
+ switch (styleName) {
1440
+ case "zIndex":
1441
+ h2.style[styleName] = `99999${styleValue}`;
1442
+ break;
1443
+ default:
1444
+ h2.style[styleName] = styleValue;
1445
+ break;
1446
+ }
1447
+ });
1448
+ break;
1449
+ default:
1450
+ if (name.startsWith("data")) {
1451
+ const kebabName = name
1452
+ .replace(/^data/, "data")
1453
+ .replace(/([A-Z])/g, "-$1")
1454
+ .toLowerCase();
1455
+ h2.setAttribute(kebabName, String(attrValue));
1456
+ } else {
1457
+ h2.setAttribute(name, String(attrValue));
1458
+ }
1459
+ }
1460
+ }
1461
+ });
1462
+ }
1463
+ return h2;
1464
+ };
1465
+
1466
+ export const h3 = (attributes = {}) => {
1467
+ let h3 = document.createElement("h3");
1468
+ if (attributes) {
1469
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1470
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1471
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1472
+ h3.addEventListener(eventType, attrValue);
1473
+ } else {
1474
+ switch (name) {
1475
+ case "class":
1476
+ case "className":
1477
+ h3.className = String(attrValue);
1478
+ break;
1479
+ case "value":
1480
+ if (isArray(attrValue)) {
1481
+ attrValue.forEach((element) => {
1482
+ isHtmlElement(element) ? h3.append(element) : h3.innerHTML = String(element);
1483
+ });
1484
+ } else {
1485
+ if (isHtmlElement(attrValue)) {
1486
+ h3.appendChild(attrValue);
1487
+ } else {
1488
+ h3.innerHTML = String(attrValue);
1489
+ h3.title = String(attrValue);
1490
+ }
1491
+ }
1492
+ break;
1493
+ case "style":
1494
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1495
+ switch (styleName) {
1496
+ case "zIndex":
1497
+ h3.style[styleName] = `99999${styleValue}`;
1498
+ break;
1499
+ default:
1500
+ h3.style[styleName] = styleValue;
1501
+ break;
1502
+ }
1503
+ });
1504
+ break;
1505
+ default:
1506
+ if (name.startsWith("data")) {
1507
+ const kebabName = name
1508
+ .replace(/^data/, "data")
1509
+ .replace(/([A-Z])/g, "-$1")
1510
+ .toLowerCase();
1511
+ h3.setAttribute(kebabName, String(attrValue));
1512
+ } else {
1513
+ h3.setAttribute(name, String(attrValue));
1514
+ }
1515
+ }
1516
+ }
1517
+ });
1518
+ }
1519
+ return h3;
1520
+ };
1521
+
1522
+ export const element = (tag = "div", attributes = {}) => {
1523
+ let el = document.createElement(tag);
1524
+ if (attributes) {
1525
+ Object.entries(attributes).forEach(([name, attrValue]) => {
1526
+ if ((name.startsWith('on') || name.startsWith("mouse")) && typeof attrValue === 'function') {
1527
+ const eventType = name.startsWith("mouse") ? name.toLowerCase() : name.slice(2).toLowerCase();
1528
+ el.addEventListener(eventType, attrValue);
1529
+ } else {
1530
+ switch (name) {
1531
+ case "class":
1532
+ case "className":
1533
+ el.className = String(attrValue);
1534
+ break;
1535
+ case "value":
1536
+ if (isArray(attrValue)) {
1537
+ attrValue.forEach((element) => {
1538
+ isHtmlElement(element) ? el.append(element) : el.innerHTML = String(element);
1539
+ });
1540
+ } else {
1541
+ if (isHtmlElement(attrValue)) {
1542
+ el.appendChild(attrValue);
1543
+ } else {
1544
+ el.innerHTML = String(attrValue);
1545
+ el.title = String(attrValue);
1546
+ }
1547
+ }
1548
+ break;
1549
+ case "style":
1550
+ Object.entries(attrValue).forEach(([styleName, styleValue]) => {
1551
+ switch (styleName) {
1552
+ case "zIndex":
1553
+ el.style[styleName] = `99999${styleValue}`;
1554
+ break;
1555
+ default:
1556
+ el.style[styleName] = styleValue;
1557
+ break;
1558
+ }
1559
+ });
1560
+ break;
1561
+ default:
1562
+ if (name.startsWith("data")) {
1563
+ const kebabName = name
1564
+ .replace(/^data/, "data")
1565
+ .replace(/([A-Z])/g, "-$1")
1566
+ .toLowerCase();
1567
+ el.setAttribute(kebabName, String(attrValue));
1568
+ } else {
1569
+ el.setAttribute(name, String(attrValue));
1570
+ }
1571
+ }
1572
+ }
1573
+ });
1574
+ }
1575
+ return el;
1576
+ };
1577
+
1354
1578
  export const apState = (initialValue) => {
1355
1579
  let state = initialValue;
1356
1580
  const getState = () => state;
package/src/helper.js CHANGED
@@ -114,3 +114,20 @@ export const useTableDrag = (selectorOrElement, onReorder = null, time = 1000) =
114
114
  * @returns {Function}
115
115
  */
116
116
  export const callback = (fn, ...args) => (...extra) => fn(...args, ...extra);
117
+
118
+ /**
119
+ * Universal function for JSON
120
+ * @param value
121
+ * @returns {*|string}
122
+ */
123
+ export const json = (value) => {
124
+ if (typeof value === 'string') {
125
+ return JSON.parse(value);
126
+ }
127
+
128
+ if (value !== null && typeof value === 'object') {
129
+ return JSON.stringify(value);
130
+ }
131
+
132
+ return value;
133
+ }
package/src/svg.js CHANGED
@@ -72,7 +72,7 @@ export const svg = ({
72
72
  fill="${fill}"
73
73
  stroke="${stroke}"
74
74
  stroke-width="${strokeWidth}"
75
- viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
75
+ viewBox="0 0 101 101" xmlns="http://www.w3.org/2000/svg">
76
76
  <g>
77
77
  <path d="M70.063,27.182c1.398,1.175,3.174,1.821,4.996,1.821c2.312,0,4.488-1.014,5.974-2.782 c2.76-3.289,2.329-8.211-0.96-10.973c-1.4-1.175-3.176-1.822-5-1.822c-2.311,0-4.487,1.014-5.971,2.782 C66.341,19.498,66.773,24.419,70.063,27.182z"></path>
78
78
  <path d="M88.445,36.096c-0.483,0-0.971,0.043-1.448,0.127c-4.485,0.791-7.493,5.086-6.702,9.573 c0.696,3.955,4.111,6.825,8.119,6.825c0.482,0,0.972-0.043,1.451-0.126c4.485-0.792,7.492-5.086,6.701-9.571 C95.868,38.968,92.452,36.096,88.445,36.096z"></path>
@@ -238,15 +238,16 @@ export const svg = ({
238
238
  `,
239
239
 
240
240
  earth: `
241
- <svg id="${id}"
242
- class="${classes}"
243
- width="${w}"
244
- height="${h}"
245
- fill="${fill}"
246
- stroke="${stroke}"
247
- stroke-width="${strokeWidth}"
248
- viewBox="0 0 24 24" xmlns="http://www.w3.org/2000/svg">
249
- <path d="M50 0C22.404 0 0 22.404 0 50s22.404 50 50 50c27.546 0 49.911-22.324 49.992-49.852A1.5 1.5 0 0 0 100 50a1.5 1.5 0 0 0-.006-.133C99.922 22.332 77.552 0 50 0zm0 3c2.776 0 5.49.254 8.133.715c.638 1.396 4.103 1.696.43 1.451c-1.416 2.02-7.019-2.123-10.75.047c-1.119 1.576-8.2 3.272-5.54 5.828c3.787-.687-.417-.067-.304 1.813c-1.936.67-4.686 3.87-4.647.595c-.48-2.398 2.162-4.607-2.115-2.81c-.235 1.306-6.674 3.82-3.453 4.398c3.387-1.7-1.353 2.698 2.59.963c-2.691 1.22-.65 2.551-1.885 5.24c-4.353-2.035-6.359 1.822-7.27 5.52c1.032.097 1.382.636 1.282 1.28c.522.051 1.26.123 1.593.153c2.183-.167 4.193-1.598 5.235-3.683c2.483-1.893 4.515-2.98 7.523-2.838c-1.443-.245-3.368 6.082-.443 3.687c-1.258-5.365 5.58.518 4.082.551c-2.513.372-3.32 1.016-1.156 2.83c1.507 1.147 2.433-4.392 4.275-3.427c-.245-1.055-4.553-4.45-3.916-4.272c.147.041.557.274 1.342.768c3.546 1.116 2.965 5.69 6.185 7.298c2.24 2.913 5.706-1.689 8.155-.293c.084 1.922 2.252 1.727 2.168-.332c2.445 1.872-.26 6.487-3.655 4.641c-3.224 1.858-7.833-4.413-9.785.344c-.87 2.244-3.849-1.737-5.082-1.822c-4.305.477-.172-4.208-3.154-4.71c-3.843-.033-7.797 1.58-11.498 1.34c-2.013.619-3.276 1.445-4.479 2.188c-1.155 1.724-3.425 2.954-5.76 6.254c-.428.66-1.172 1.478-2.058 2.47c-1.212 4.123-2.697 8.25-2.463 12.54c2.643 2.788 3.263 9.522 8.455 8.988c3.43 1.772 6.028-1.288 9.244-.26c.593 3.341 6.865 1.95 5.174 5.295c-1.765 3.996 3.393 5.923 4.236 9.56c2.202 3.636-3.322 7.426 1.114 10.555c2.456 4.07 5.302 10.253 11.18 7.848c4.573-.293 7.37-4.15 10.226-6.781c-.259-4.826 8.459-4.3 6.508-10.436c-1.15-.724.072-3.625-.56-4.652c.654-1.345 2.958-5.176 5.187-7.051c3.417-2.65 4.85-6.796 5.978-10.807c-.698-3.373-2.29-.072-4.318-.215c-5.396 2.001.127-2.32 2.158-3.55c2.866-1.689 5.654-4.57 6.285-7.64c2.656-2.87-6.413-5.658-.715-4.72c3.603-.703 5.451-1.131 6.373 2.319c3.53 1.396 3.249 7.793 5.237 11.277c1.03-1.27.618-.283 1.056 1.244c1.15-3.297-1.273-8.61-.52-12.896A47.197 47.197 0 0 1 97 50c0 25.975-21.025 47-47 47S3 75.975 3 50C3 29.806 15.71 12.61 33.57 5.953c1.734-.496 3.47-.987 5.168-1.588A47.152 47.152 0 0 1 50 3zm10.293 1.143c.499.11 1 .218 1.492.345c-.114.755-.748.287-1.492-.345zM35.168 6.219c-1.148.021-2.457.447-2.117 1.511c.63.232 1.285.06 1.902-.091c2.902-.808 1.691-1.448.215-1.42zm14.113 3.758c1.528-.225.085 4.183-2.281 3.046c-3.878.401.584-.245.725-2.025c.694-.67 1.204-.97 1.556-1.021zm21.49 8.728c.29.035.378.388-.023 1.229c-.327 1.078 4.93 4.569 4.604 6.793c-4.668 1.225-1.75-3.326-4.79-4.252c-3.337-1.105-.66-3.873.21-3.77zm-13.539.873c1.734 2.323 4.44.501 6.967 2.387c3.092 3.12-4.874-.41-6.258 1.389c-4.131 1.271-2.103-2.51-.709-3.776zM16.836 33.754c-.294-.044-.535.16-.748.99c.71.037 1.24.117 1.621.238l.232-.718c-.443-.16-.803-.465-1.105-.51zm58.379.508c.68 2.359 5.965 1.985 4.685 4.195l-.603.426c-1.032-.675-5.325-3.52-4.082-4.621zM62.678 37.29c2.438 1.663 4.185 5.07 5.744 7.74c2.142 1.524 2.21 3.973 3.6 5.899c-.568.72-1.678-.593-1.905-1.06c-1.857-1.299-3.39-4.6-4.703-7.237c-.825-1.828-2.838-3.495-2.736-5.342zm14.586 38.904c-.222-.015-.56.245-1.037.899c-3.443 2.537-6.176 5.556-6.38 9.91c2.385 1.084 4.406-3.285 5.688-4.81c1.469-.711 2.689-5.934 1.729-5.999z"></path>
241
+ <svg id="${id}"
242
+ class="${classes}"
243
+ width="${w}"
244
+ height="${h}"
245
+ fill="${fill}"
246
+ stroke="${stroke}"
247
+ stroke-width="${strokeWidth}"
248
+ viewBox="0 0 512 512" xmlns="http://www.w3.org/2000/svg">
249
+ <path d="M511.434,239.204c-4.138-63.963-31.794-121.624-74.418-164.217c-17.682-17.685-37.951-32.809-60.22-44.74 C340.806,10.962,299.67,0,256,0C185.365,0,121.273,28.67,74.984,74.988C28.663,121.273,0,185.361,0,256 c0,70.639,28.663,134.735,74.984,181.013C121.273,483.329,185.365,512,256,512c10.178,0,20.211-0.593,30.092-1.757 c25.423-2.974,49.714-9.666,72.278-19.558c18.337-8.004,35.573-18.099,51.38-29.968c9.642-7.261,18.755-15.194,27.266-23.704 C483.337,390.734,512,326.639,512,256C512,250.347,511.82,244.748,511.434,239.204z M368.22,213.758 c-8.983,3.483-31.286,4.653-36.252,1.343c-4.943-3.272-17.416-7.379-22.444-6.488c-5.032,0.89,1.604,8.416-4.259,9.338 c-5.86,0.898-13.395-3.208-19.294-7.44c-5.856-4.162-15.144-5.794-15.144-5.794c-2.26-0.273-4.529-0.547-6.789-0.804 c-3.365-6.762-1.608-22.096-13.52-18.63c-11.903,3.475-51.197,10.416-59.77,12.11c-8.573,1.726-18.81,15.39-25.63,25.532 c-6.843,10.244-25.481,42.241-28.842,47.215c-3.365,5.059-4.884,36.65-4.79,44.833c0.085,8.339,37.322,42.623,49.022,44.107 c11.759,1.616,43.697-6.66,52.091-8.417c8.429-1.695,13.309,9.557,19.977,9.431c6.699-0.117,14.948,2.983,8.159,12.689 c-6.82,9.634-6.851,14.413-0.328,20.597c6.547,6.247,19.169,29.381,10.506,47.707c-8.604,18.341-2.292,27.008,2.323,34.262 c0.948,1.491,1.932,3.552,2.916,5.988c-6.637,0.594-13.363,0.89-20.152,0.89c-62.51,0-118.985-25.297-159.97-66.25 C55.07,374.986,29.764,318.51,29.764,256c0-62.51,25.306-118.986,66.266-159.978c40.984-40.952,97.459-66.25,159.97-66.25 c7.765,0,15.476,0.382,23.042,1.155c-1.488,1.101-3.127,2.233-5.032,3.365c-12.649,7.558-17.744,10.931-27.058,13.453 c-9.35,2.506-5.895,21.292-2.475,24.713c3.428,3.42,11.076-0.844,17.006-4.225c5.922-3.365,7.648,3.42,7.675,5.973 c0,2.561,3.424,12.806,8.484,11.111c5.095-1.695,13.457-18.7,12.594-21.222c-0.863-2.569-4.263-9.378,1.608-14.437 c5.805-5.028,12.465-9.198,18.278-13.368c1.811,0.406,3.596,0.891,5.352,1.39c-0.508,1.257-1.667,2.802-3.568,4.498 c-6.64,5.871-9.139,10.103-9.139,10.103s-1.581,13.563,2.62,13.563c4.197,0.023,15.897-2.436,21.698-4.107 c5.836-1.67,5.868,3.428,0.058,5.091c-5.832,1.639-10.834,4.169-10.834,4.169c-0.835,2.522-1.636,5.092-2.471,7.613 c-8.366,5.068-11.7,12.719-11.7,12.719s-37.123,0.804-39.739,1.663c-2.53,0.812-1.694-7.675-1.694-7.675s2.498-8.55-1.729-7.714 c-4.197,0.866-4.224,8.347-4.224,8.55c-0.566,3.396-1.132,6.816-1.667,10.236c0,0-16.194,3.396-19.618,6.84 c-3.392,3.428-14.5,13.672-17.053,15.421c-2.565,1.694-11.134,4.286-14.562,6.012c-3.424,1.734,10.271,7.722,10.271,10.275 c0,2.561,0.031,14.554-5.118,15.414c-5.126,0.866-29.143,0.898-29.143,0.898s-7.683,27.414-5.954,29.982 c1.726,2.553,12.856,8.51,19.708,7.652c6.844-0.874,22.233-8.573,22.233-8.573c2.264-5.153,4.556-10.283,6.848-15.421 c4.552-4.856,9.108-9.713,13.664-14.585c0,0.023,10.236,4.255,13.664,0.828c3.388-3.42,10.15-6.855,10.209-6.855 c0.027,0,6.781,12.781,11.017,14.468c4.251,1.709,11.841,8.487,12.676,12.75c0.836,4.255,1.667,11.907,4.197,10.174 c2.534-1.726,6.789-11.93,6.789-11.93s5.891-3.428-0.836-6.817c-6.73-3.365-18.575-15.272-20.273-17.834 c-1.694-2.561-0.832-10.244,5.091-6.847c5.954,3.428,21.94,18.692,21.94,18.692s0.835,7.675,5.001,11.048 c4.197,3.358,8.366,9.284,8.366,12.68c-0.031,3.396-0.031,5.06,5.801,5.028c5.868-0.031,3.424-11.041,3.424-13.57 c0-2.561-0.8-7.652,3.365-7.652c4.166-0.031,10.806,3.303,10.806,3.303s-4.228,16.974,4.044,19.434 c8.339,2.444,33.82-4.575,33.731-0.351C373.342,191.053,377.246,210.284,368.22,213.758z M415.969,415.977 c-6.043,6.028-12.414,11.728-19.11,17.052c-0.597-11.728-0.445-31.677,1.159-39.477c1.995-9.377,19.559-16.459,27.832-29.405 c8.334-13.008,21.257-27.828,18.844-46.863c-14.141,7.034-22.116,10.603-29.827,6.113c-7.71-4.497-15.178-20.394-18.247-26.828 c-2.862-6.16-29.408-56.733-24.587-60.332c5.032-3.31,28.515,39.212,37.565,51.76c9.142,12.742,5.535,28.975,24.618,18.52 c19.047-10.448,42.358-29.178,45.543-37.362c3.276-8.151-8.334-28.842-13.066-23.846c-4.646,5.06-18.576,7.152-18.607,7.152 c-5.954-10.681-11.997-21.495-18.126-32.387c0,0,7.887-0.149,15.538,6.215c7.71,6.403,22.92,14.109,31.942,15.413 c1.218,0.195,2.678,0.219,4.346,0.133c0.296,4.669,0.448,9.401,0.448,14.164C482.236,318.51,456.93,374.986,415.969,415.977z"></path>
250
+ <path d="M205.232,89.526c2.569,1.718-1.698,9.432-5.114,15.429c-3.42,5.996-1.706,9.417-1.706,9.417 s16.272-2.577,19.688-4.295c3.416-1.701,5.973-12.844,3.4-15.412c-2.569-2.569-11.138-10.268-11.15-12.837 c0-2.569,0.839-11.977-2.596-14.523c-3.42-2.576-11.119,2.28-11.103,7.684C196.655,78.415,202.66,87.808,205.232,89.526z"></path>
250
251
  </svg>
251
252
  `
252
253
  }
package/src/translator.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // Об'єкт для зберігання завантажених перекладів
2
2
  import {isEmpty} from "./general.js";
3
+ import {getAprogConfig} from "./config.js";
3
4
 
4
5
  const translations = {};
5
6
  let translationsLoaded = false;
@@ -10,8 +11,20 @@ let translationsLoaded = false;
10
11
  */
11
12
  export const loadTranslations = async (language = "uk") => {
12
13
  try {
13
- const translationsModule = await import(`../../../resources/lang/${language}.json`);
14
- Object.assign(translations, translationsModule);
14
+ const { langLoader } = getAprogConfig();
15
+
16
+ if (!langLoader) {
17
+ throw new Error("langLoader is not configured");
18
+ }
19
+
20
+ const module = await langLoader(language);
21
+
22
+ Object.keys(translations).forEach(key => {
23
+ delete translations[key];
24
+ });
25
+
26
+ Object.assign(translations, module.default ?? module);
27
+
15
28
  translationsLoaded = true;
16
29
  } catch (error) {
17
30
  console.error(`Помилка завантаження перекладів для мови "${language}":`, error);
@@ -30,10 +43,15 @@ export const translate = (key, values = {}, def = "") => {
30
43
  console.warn(`Переклади ще не завантажені. Ключ: "${key}"`);
31
44
  return !isEmpty(def) ? def : key;
32
45
  }
33
- let translation = translations[key] || key;
34
- // Замінити підстановки {key} у перекладі
46
+
47
+ let translation = translations[key];
48
+ if (isEmpty(translation)) {
49
+ translation = !isEmpty(def) ? def : key;
50
+ }
51
+
35
52
  for (const [placeholder, value] of Object.entries(values)) {
36
- translation = translation.replace(`:${placeholder}`, value.toString());
53
+ translation = translation.replaceAll(`:${placeholder}`, value.toString());
37
54
  }
38
- return !isEmpty(def) ? def : translation;
55
+
56
+ return translation;
39
57
  };
package/src/css/root.css DELETED
@@ -1,86 +0,0 @@
1
- :root {
2
- --c-blue: #0088ff;
3
- --c-green: #008800;
4
- --c-red: #ff2800;
5
- --c-orange: #ff8800;
6
- --c-gold: #ffd700;
7
- --c-yellow: #ffff00;
8
- --c-gray: #999999;
9
- --c-x-light: #F0E1D2;
10
- --c-x-light-rgb: rgb(240,225,210);
11
- /*--c-black: #01090f;*/
12
- --c-black: #333333;
13
- --c-black-rgb: rgb(1,9,15);
14
- --c-dark: #021727;
15
- --c-dark-rgb: rgb(2,23,39);
16
- --c-prev-dark: #032640;
17
- --c-prev-dark-rgb: rgb(3,38,64);
18
- --c-default: #043458;
19
- --c-default-rgb: rgb(4,52,88);
20
- --c-prev-light: #054270;
21
- --c-prev-light-rgb: rgb(5,66,112);
22
- --c-light: #065189;
23
- --c-light-rgb: rgb(6,81,137);
24
- --c-super-light: #075fa1;
25
- --c-super-light-rgb: rgb(7,95,161);
26
- --c-bright: #086db9;
27
- --c-bright-rgb: rgb(8,109,185);
28
- --c-prev-bright: #097cd2;
29
- --c-prev-bright-rgb: rgb(9,124,210);
30
- --c-vivid: #0a8aea;
31
- --c-vivid-rgb: rgb(10,138,234);
32
- --c-sky: #1897f5;
33
- --c-sky-rgb: rgb(24,151,245);
34
- --c-soft-sky: #31a2f6;
35
- --c-soft-sky-rgb: rgb(49,162,246);
36
- --c-light-sky: #49adf7;
37
- --c-light-sky-rgb: rgb(73,173,247);
38
- --c-cloud: #61b8f8;
39
- --c-cloud-rgb: rgb(97,184,248);
40
- --c-bright-cloud: #7ac3f9;
41
- --c-bright-cloud-rgb: rgb(122,195,249);
42
- --c-soft-cloud: #92cefa;
43
- --c-soft-cloud-rgb: rgb(146,206,250);
44
- --c-lighter-cloud: #aad9fb;
45
- --c-lighter-cloud-rgb: rgb(170,217,251);
46
- --c-fade-cloud: #c3e4fc;
47
- --c-fade-cloud-rgb: rgb(195,228,252);
48
- --c-pale-blue: #dbeffd;
49
- --c-pale-blue-rgb: rgb(219,239,253);
50
- --c-near-white: #f3fafe;
51
- --c-near-white-rgb: rgb(243,250,254);
52
- --c-white: #ffffff;
53
- --c-white-rgb: rgb(255,255,255);
54
- --1px: 0.0625rem;
55
- --05px: 0.0313rem;
56
- --size-xxxs: 8px;
57
- --size-xxs: 10px;
58
- --size-xs: 12px;
59
- --size-sm: 14px;
60
- --size-md: 16px;
61
- --size-lg: 18px;
62
- --size-xl: 20px;
63
- --size-xxl: 24px;
64
- --size-xxxl: 32px;
65
- --padding-container: calc(100% - 4rem);
66
- --box-shadow: 0 3px 6px 0 rgba(1,9,15, 0.2), 0 3px 6px 0 rgba(1,9,15, 0.19);
67
- --box-shadow-invert: inset 0 3px 6px 0 rgba(1,9,15, 0.4);
68
- --box-shadow-round: 0 0 6px 0 rgba(1,9,15, 0.4), 0 0 6px 0 rgba(1,9,15, 0.39);
69
- --box-shadow-round-invert: inset 0 0 6px 0 rgba(1,9,15, 0.4);
70
- /*--btn-shadow: 0 3px 8px 0 rgba(4, 52, 88, 0.2), 0 3px 20px 0 rgba(4, 52, 88, 0.19);*/
71
- --btn-shadow: 0 3px 8px 0 rgba(1,9,15, 0.2), 0 3px 20px 0 rgba(1,9,15, 0.19);
72
- --maxIndex: 2147483647;
73
- --allTransition100Linear: all 100ms linear;
74
- --allTransition700: all 700ms ease-in-out;
75
- --border-radius: 0.5rem;
76
-
77
- /* Glass Style */
78
- --glass-bg: rgba(255,255,255,.5);
79
- --glass-super-bg: rgba(255,255,255,.7);
80
- --glass-blur: blur(2px);
81
- --glass-super-blur: blur(6px);
82
- --glass-border: var(--05px) solid var(--c-white);
83
- --glass-radius: 0.5rem;
84
- --glass-shadow: 0 3px 6px rgba(0,0,0,.5);
85
- --glass-shadow-invert: inset 0 3px 6px rgba(0,0,0,.5);
86
- }
@@ -1,129 +0,0 @@
1
- @import "root.css";
2
-
3
- .aprog-btn {
4
- height: 38px;
5
- padding: 0.3rem 0.7rem;
6
- align-items: center;
7
- justify-content: center;
8
- font-size: 1rem;
9
- color: var(--c-black);
10
- background-color: var(--glass-bg);
11
- backdrop-filter: var(--glass-blur);
12
- -webkit-backdrop-filter: var(--glass-blur);
13
- border: var(--glass-border);
14
- border-radius: var(--glass-radius);
15
- box-shadow: var(--glass-shadow);
16
- transition: var(--allTransition100Linear);
17
- cursor: pointer;
18
- }
19
-
20
- .aprog-input, .aprog-select {
21
- min-width: 150px;
22
- width: calc(100% - 30px);
23
- height: 38px;
24
- padding: 0 15px;
25
- font-size: var(--size-sm);
26
- font-weight: 600;
27
- color: var(--c-black);
28
- background-color: var(--glass-bg);
29
- backdrop-filter: var(--glass-blur);
30
- -webkit-backdrop-filter: var(--glass-blur);
31
- border-left: 1px solid var(--c-black);
32
- border-right: 1px solid var(--c-black);
33
- border-radius: var(--glass-radius);
34
- box-shadow: var(--glass-shadow-invert);
35
- outline: none;
36
- }
37
-
38
- .aprog-select {
39
-
40
- }
41
-
42
- .aprog-loader {
43
- /*position: absolute;*/
44
- /*top: 50%;*/
45
- /*left: 50%;*/
46
- /*transform: translate(-50%, -50%);*/
47
- /*width: 35px;*/
48
- /*height: 35px;*/
49
- animation: spin 1s linear infinite;
50
- }
51
-
52
- .aprog-modal {
53
- position: fixed;
54
- top: 50%;
55
- left: 50%;
56
- min-width: 600px;
57
- min-height: 300px;
58
- width: auto;
59
- height: auto;
60
- padding: 20px;
61
- display: flex;
62
- flex-direction: column;
63
- align-items: center;
64
- justify-content: center;
65
- gap: 10px;
66
- background-color: var(--c-white);
67
- border-radius: var(--border-radius);
68
- transform: translate(-50%, -50%);
69
- box-shadow: var(--box-shadow);
70
- z-index: 99999;
71
- }
72
- .aprog-background-modal {
73
- position: fixed;
74
- top: 0;
75
- left: 0;
76
- width: 100%;
77
- height: 100vh;
78
- background-color: rgba(255,255,255, 0.3);
79
- backdrop-filter: blur(4px);
80
- }
81
- .aprog-block-modal {
82
- width: calc(100% - 1rem);
83
- height: calc(100% - 1rem);
84
- padding: 0.5rem;
85
- display: flex;
86
- flex-direction: column;
87
- align-items: center;
88
- justify-content: center;
89
- overflow: hidden;
90
- gap: 20px;
91
- }
92
- .aprog-title-modal {
93
- width: 100%;
94
- display: flex;
95
- align-items: center;
96
- justify-content: center;
97
- font-size: 20px;
98
- font-weight: 600;
99
- text-align: center;
100
- }
101
- .aprog-block-btns-modal {
102
- display: flex;
103
- align-items: center;
104
- justify-content: center;
105
- gap: 20px;
106
- }
107
- .aprog-close {
108
- position: absolute;
109
- top: 10px;
110
- left: 10px;
111
- width: 20px;
112
- height: 20px;
113
- display: flex;
114
- align-items: center;
115
- justify-content: center;
116
- color: var(--c-white);
117
- stroke: var(--c-white);
118
- fill: var(--c-white);
119
- background-color: var(--c-red);
120
- border-radius: 50%;
121
- box-shadow: var(--box-shadow);
122
- transition: var(--allTransition700);
123
- cursor: pointer;
124
- }
125
-
126
- @keyframes spin {
127
- 0% { transform: rotate(0deg); }
128
- 100% { transform: rotate(360deg); }
129
- }