@skyservice-developers/vue-dev-kit 2.18.0 → 2.19.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +36 -1
- package/dist/{api-C6FKIf2t.js → money-BCv6JlZu.js} +194 -116
- package/dist/money-dyX9wNiC.cjs +1 -0
- package/dist/sdk/index.d.ts +2 -0
- package/dist/sdk/money.d.ts +29 -0
- package/dist/sdk.cjs +1 -1
- package/dist/sdk.js +32 -29
- package/dist/shared/ui/SkyDateRangePicker/SkyDateRangePicker.vue.d.ts +1 -1
- package/dist/style.css +1 -1
- package/dist/vue-dev-kit.cjs +7 -7
- package/dist/vue-dev-kit.js +26 -23
- package/package.json +1 -1
- package/dist/api-DAgEQpwF.cjs +0 -1
package/README.md
CHANGED
|
@@ -41,7 +41,7 @@ import {
|
|
|
41
41
|
SkyCheckboxFilter, SkySelectFilter,
|
|
42
42
|
TableMassActions, TableColumnSettings, TableVirtualBody,
|
|
43
43
|
// sdk
|
|
44
|
-
navigate, SkyserviceAPI, isInsideIframe,
|
|
44
|
+
navigate, SkyserviceAPI, isInsideIframe, formatMoney, currencyIcon,
|
|
45
45
|
// sky-service-ui-components
|
|
46
46
|
NotificationElement,
|
|
47
47
|
notificationModule, globalStore,
|
|
@@ -1321,6 +1321,41 @@ CSS-змінні (`--sky-filter-*`) — див. [доки](https://74cfe434-a2b3
|
|
|
1321
1321
|
|
|
1322
1322
|
---
|
|
1323
1323
|
|
|
1324
|
+
## formatMoney — сума зі значком валюти
|
|
1325
|
+
|
|
1326
|
+
Живе в **SDK** (`@skyservice-developers/vue-dev-kit/sdk`), а не серед компонентів: там
|
|
1327
|
+
немає Vue, тож модуль доступний і адмінці на Vue 2.
|
|
1328
|
+
|
|
1329
|
+
```ts
|
|
1330
|
+
import { formatMoney, currencyIcon } from '@skyservice-developers/vue-dev-kit/sdk'
|
|
1331
|
+
|
|
1332
|
+
formatMoney('110', { currency: 'UAH' }) // 110.00 ₴
|
|
1333
|
+
formatMoney('1250', { currency: 'UAH' }) // 1 250.00 ₴
|
|
1334
|
+
formatMoney('110', { currency: 'USD', locale: 'en' }) // $110.00
|
|
1335
|
+
formatMoney('110', { currency: null }) // 110.00
|
|
1336
|
+
currencyIcon('KZT') // ₸
|
|
1337
|
+
```
|
|
1338
|
+
|
|
1339
|
+
| Опція | Типово | Опис |
|
|
1340
|
+
|---|---|---|
|
|
1341
|
+
| `currency` | `null` | ISO валюти. Без нього повертається лише число |
|
|
1342
|
+
| `locale` | `'uk'` | Мова інтерфейсу — вирішує, з якого боку значок |
|
|
1343
|
+
| `decimals` | `2` | Знаків після коми |
|
|
1344
|
+
|
|
1345
|
+
**Де стоїть значок** — за правилами мови, не валюти: українська, польська й німецька
|
|
1346
|
+
ставлять його після числа, англійська й турецька перед. Позицію питаємо в `Intl`, а сам
|
|
1347
|
+
значок беремо зі свого списку: для більшості наших валют `Intl` віддає ISO-код замість
|
|
1348
|
+
символу (перевірено на всіх 55 — `₸`, `₺`, `zł`, `₫` він не знає).
|
|
1349
|
+
|
|
1350
|
+
**Формат числа** зведений з адмінкою (`CurrencyFormatted` + `formatNumberWithSpaces`): дві
|
|
1351
|
+
копійки, тисячі через пробіл, крапка як десятковий роздільник. Локальні розділювачі
|
|
1352
|
+
свідомо не беремо — інакше та сама сума виглядала б по-різному в адмінці й у міні-аппі.
|
|
1353
|
+
|
|
1354
|
+
Пробіли всередині — нерозривні, щоб ціна не переносилась на два рядки посеред числа.
|
|
1355
|
+
Нечислове значення повертається як є: краще показати сире, ніж `NaN`.
|
|
1356
|
+
|
|
1357
|
+
---
|
|
1358
|
+
|
|
1324
1359
|
## sky-service-ui-components
|
|
1325
1360
|
|
|
1326
1361
|
Бібліотека re-export-ує весь публічний API пакета `sky-service-ui-components`. Окремо встановлювати його не потрібно — він вже входить у залежності `vue-dev-kit`.
|
|
@@ -1,107 +1,107 @@
|
|
|
1
|
-
import
|
|
2
|
-
const
|
|
3
|
-
let
|
|
4
|
-
function
|
|
5
|
-
return `sdk_${Date.now()}_${++
|
|
1
|
+
import C from "ua-parser-js";
|
|
2
|
+
const g = "DASHBOARD", P = 5e3;
|
|
3
|
+
let A = 0, u = null;
|
|
4
|
+
function R() {
|
|
5
|
+
return `sdk_${Date.now()}_${++A}`;
|
|
6
6
|
}
|
|
7
|
-
function
|
|
7
|
+
function k() {
|
|
8
8
|
return "APP_" + Math.random().toString(36).slice(2, 10);
|
|
9
9
|
}
|
|
10
|
-
function
|
|
10
|
+
function O(t) {
|
|
11
11
|
u = t;
|
|
12
12
|
}
|
|
13
|
-
function
|
|
14
|
-
return u || (u =
|
|
13
|
+
function y() {
|
|
14
|
+
return u || (u = k()), u;
|
|
15
15
|
}
|
|
16
|
-
function
|
|
16
|
+
function c(t) {
|
|
17
17
|
window.parent.postMessage(
|
|
18
18
|
{
|
|
19
19
|
...t,
|
|
20
|
-
sender:
|
|
21
|
-
target: t.target ||
|
|
20
|
+
sender: y(),
|
|
21
|
+
target: t.target || g
|
|
22
22
|
},
|
|
23
23
|
"*"
|
|
24
24
|
);
|
|
25
25
|
}
|
|
26
|
-
function
|
|
27
|
-
return
|
|
28
|
-
const
|
|
26
|
+
function l(t, e, r = P) {
|
|
27
|
+
return S() ? new Promise((n) => {
|
|
28
|
+
const s = R(), i = y(), o = setTimeout(() => {
|
|
29
29
|
window.removeEventListener("message", d), n(null);
|
|
30
30
|
}, r);
|
|
31
|
-
function d(
|
|
32
|
-
const
|
|
33
|
-
(
|
|
31
|
+
function d(w) {
|
|
32
|
+
const a = w.data;
|
|
33
|
+
(a == null ? void 0 : a.type) === "DATA_RESPONSE" && (a == null ? void 0 : a.requestId) === s && (!a.target || a.target === i) && (clearTimeout(o), window.removeEventListener("message", d), n(a.data ?? null));
|
|
34
34
|
}
|
|
35
|
-
window.addEventListener("message", d),
|
|
35
|
+
window.addEventListener("message", d), c({ type: "DATA_REQUEST", requestId: s, source: t, key: e });
|
|
36
36
|
}) : Promise.resolve(null);
|
|
37
37
|
}
|
|
38
|
-
function
|
|
39
|
-
|
|
38
|
+
function B(t) {
|
|
39
|
+
c({ type: "navigate", path: t });
|
|
40
40
|
}
|
|
41
41
|
function E() {
|
|
42
|
-
|
|
42
|
+
c({ type: "exit" });
|
|
43
43
|
}
|
|
44
|
-
const
|
|
44
|
+
const F = E;
|
|
45
45
|
function p(t) {
|
|
46
|
-
return
|
|
46
|
+
return l("store", t);
|
|
47
47
|
}
|
|
48
|
-
function
|
|
49
|
-
return
|
|
48
|
+
function I(t) {
|
|
49
|
+
return l("localStorage", t);
|
|
50
50
|
}
|
|
51
|
-
function
|
|
52
|
-
return
|
|
51
|
+
function G(t) {
|
|
52
|
+
return l("window", t);
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function K() {
|
|
55
55
|
return p("company");
|
|
56
56
|
}
|
|
57
|
-
function
|
|
57
|
+
function x() {
|
|
58
58
|
return p("user");
|
|
59
59
|
}
|
|
60
|
-
function
|
|
61
|
-
return
|
|
60
|
+
function W() {
|
|
61
|
+
return I("token");
|
|
62
62
|
}
|
|
63
|
-
function
|
|
64
|
-
return
|
|
63
|
+
function j() {
|
|
64
|
+
return I("lang");
|
|
65
65
|
}
|
|
66
|
-
function
|
|
66
|
+
function H() {
|
|
67
67
|
return p("productCategories");
|
|
68
68
|
}
|
|
69
|
-
function
|
|
70
|
-
|
|
71
|
-
}
|
|
72
|
-
function z(t) {
|
|
73
|
-
o({ type: "setRocketMode", value: t });
|
|
69
|
+
function Z(t, e) {
|
|
70
|
+
c({ type: "setLocalStorage", key: t, value: e });
|
|
74
71
|
}
|
|
75
|
-
function
|
|
76
|
-
|
|
72
|
+
function q(t) {
|
|
73
|
+
c({ type: "setRocketMode", value: t });
|
|
77
74
|
}
|
|
78
|
-
function
|
|
79
|
-
|
|
75
|
+
function Y(t, e) {
|
|
76
|
+
c({ type: "trackVisit", name: t, path: e });
|
|
80
77
|
}
|
|
81
|
-
function
|
|
82
|
-
|
|
78
|
+
function z(t) {
|
|
79
|
+
c({ type: "openExternalLink", url: t });
|
|
83
80
|
}
|
|
84
|
-
function Q(
|
|
85
|
-
|
|
81
|
+
function Q() {
|
|
82
|
+
c({ type: "openCrispChat" });
|
|
86
83
|
}
|
|
87
84
|
function V(t) {
|
|
88
|
-
|
|
85
|
+
c({ type: "notification", text: t });
|
|
86
|
+
}
|
|
87
|
+
function X(t) {
|
|
88
|
+
c({ type: "notification", text: t, variant: "error" });
|
|
89
89
|
}
|
|
90
90
|
function J(t) {
|
|
91
|
-
|
|
91
|
+
c({ type: "notification", text: t, variant: "warn" });
|
|
92
92
|
}
|
|
93
|
-
function
|
|
93
|
+
function S() {
|
|
94
94
|
try {
|
|
95
95
|
return window.self !== window.top;
|
|
96
96
|
} catch {
|
|
97
97
|
return !0;
|
|
98
98
|
}
|
|
99
99
|
}
|
|
100
|
-
const
|
|
101
|
-
function
|
|
100
|
+
const ee = S;
|
|
101
|
+
function te(t) {
|
|
102
102
|
function e(r) {
|
|
103
103
|
var n;
|
|
104
|
-
((n = r.data) == null ? void 0 : n.sender) ===
|
|
104
|
+
((n = r.data) == null ? void 0 : n.sender) === g && t(r.data);
|
|
105
105
|
}
|
|
106
106
|
return window.addEventListener("message", e), () => window.removeEventListener("message", e);
|
|
107
107
|
}
|
|
@@ -109,25 +109,25 @@ function f() {
|
|
|
109
109
|
if (typeof window > "u") return "browser";
|
|
110
110
|
if (window.webkit != null && window.webkit.messageHandlers !== void 0)
|
|
111
111
|
try {
|
|
112
|
-
if (
|
|
112
|
+
if (C(navigator.userAgent).browser.name === "WebKit") return "ios_webview";
|
|
113
113
|
} catch (t) {
|
|
114
114
|
console.error(t);
|
|
115
115
|
}
|
|
116
116
|
return typeof Android < "u" ? "android_webview" : typeof window.cefQuery < "u" ? "cef_webview" : "browser";
|
|
117
117
|
}
|
|
118
|
-
function
|
|
118
|
+
function ne() {
|
|
119
119
|
return f() === "ios_webview";
|
|
120
120
|
}
|
|
121
|
-
function
|
|
121
|
+
function re() {
|
|
122
122
|
return f() === "android_webview";
|
|
123
123
|
}
|
|
124
|
-
function
|
|
124
|
+
function ie() {
|
|
125
125
|
return f() === "cef_webview";
|
|
126
126
|
}
|
|
127
|
-
function
|
|
127
|
+
function se() {
|
|
128
128
|
return f() !== "browser";
|
|
129
129
|
}
|
|
130
|
-
const
|
|
130
|
+
const T = "https://api.cabinet.developer.skyservice.online/index.php";
|
|
131
131
|
class v {
|
|
132
132
|
constructor(e) {
|
|
133
133
|
this.permsCache = null, this.token = e.token, this.companyId = e.companyId, this.appId = e.appId, this.developerId = e.developerId, this.deploymentId = e.deploymentId, this.appName = e.appName;
|
|
@@ -147,26 +147,26 @@ class v {
|
|
|
147
147
|
}), n = await fetch(`${this.baseUrl}/?${r}`);
|
|
148
148
|
if (!n.ok)
|
|
149
149
|
throw new Error(`Skyservice API error: ${n.status}`);
|
|
150
|
-
const
|
|
151
|
-
if (
|
|
152
|
-
throw new Error(`Skyservice API returned status: ${
|
|
153
|
-
return
|
|
150
|
+
const s = await n.json();
|
|
151
|
+
if (s.status !== "done")
|
|
152
|
+
throw new Error(`Skyservice API returned status: ${s.status}`);
|
|
153
|
+
return s.data;
|
|
154
154
|
}
|
|
155
155
|
async post(e, r, n) {
|
|
156
|
-
const
|
|
156
|
+
const s = new URLSearchParams({
|
|
157
157
|
token: this.token,
|
|
158
158
|
...r
|
|
159
|
-
}), i = await fetch(`${e}?${
|
|
159
|
+
}), i = await fetch(`${e}?${s}`, {
|
|
160
160
|
method: "POST",
|
|
161
161
|
headers: { "Content-Type": "application/json" },
|
|
162
162
|
body: JSON.stringify(n)
|
|
163
163
|
});
|
|
164
164
|
if (!i.ok)
|
|
165
165
|
throw new Error(`Skyservice API error: ${i.status}`);
|
|
166
|
-
const
|
|
167
|
-
if (
|
|
168
|
-
throw new Error(`Skyservice API returned status: ${
|
|
169
|
-
return
|
|
166
|
+
const o = await i.json();
|
|
167
|
+
if (o.status !== "done")
|
|
168
|
+
throw new Error(`Skyservice API returned status: ${o.status}`);
|
|
169
|
+
return o.data;
|
|
170
170
|
}
|
|
171
171
|
// --- Tradepoints ---
|
|
172
172
|
/**
|
|
@@ -195,7 +195,7 @@ class v {
|
|
|
195
195
|
action: "getCategories",
|
|
196
196
|
...e ? { tradepointId: String(e) } : {}
|
|
197
197
|
});
|
|
198
|
-
return
|
|
198
|
+
return b(r, e);
|
|
199
199
|
}
|
|
200
200
|
// --- Products ---
|
|
201
201
|
/**
|
|
@@ -215,7 +215,7 @@ class v {
|
|
|
215
215
|
of: "nomenclatureId",
|
|
216
216
|
...e != null && e.tradepointId ? { tradepointId: String(e.tradepointId) } : {}
|
|
217
217
|
});
|
|
218
|
-
return
|
|
218
|
+
return $(r.items, e == null ? void 0 : e.includeInactive);
|
|
219
219
|
}
|
|
220
220
|
// --- Integrations ---
|
|
221
221
|
/**
|
|
@@ -235,27 +235,27 @@ class v {
|
|
|
235
235
|
title: r,
|
|
236
236
|
settings: n
|
|
237
237
|
}) {
|
|
238
|
-
const
|
|
238
|
+
const s = e ? "activateApp" : "deactivateApp", i = {
|
|
239
239
|
company_id: this.companyId,
|
|
240
240
|
app_id: this.appId,
|
|
241
241
|
...this.developerId !== void 0 && { developer_id: this.developerId },
|
|
242
242
|
...e && n !== void 0 && { settings: n }
|
|
243
|
-
},
|
|
244
|
-
|
|
245
|
-
{ section: "integrations", action:
|
|
243
|
+
}, o = await this.post(
|
|
244
|
+
T,
|
|
245
|
+
{ section: "integrations", action: s },
|
|
246
246
|
i
|
|
247
247
|
);
|
|
248
248
|
return this.deploymentId && this.appName && typeof window < "u" && window.self !== window.top && window.parent.postMessage(
|
|
249
249
|
{
|
|
250
250
|
type: "sendActiveApp",
|
|
251
|
-
id:
|
|
251
|
+
id: o.id,
|
|
252
252
|
is_active: e,
|
|
253
253
|
deploymentId: this.deploymentId,
|
|
254
254
|
appName: this.appName,
|
|
255
255
|
title: r
|
|
256
256
|
},
|
|
257
257
|
"*"
|
|
258
|
-
),
|
|
258
|
+
), o;
|
|
259
259
|
}
|
|
260
260
|
async getPerms(e) {
|
|
261
261
|
const r = await this.loadPerms();
|
|
@@ -272,30 +272,30 @@ class v {
|
|
|
272
272
|
try {
|
|
273
273
|
const n = await p("perms");
|
|
274
274
|
if (n && Object.keys(n).length > 0)
|
|
275
|
-
return this.permsCache =
|
|
275
|
+
return this.permsCache = h(n), this.permsCache;
|
|
276
276
|
} catch {
|
|
277
277
|
}
|
|
278
278
|
const e = await this.get({
|
|
279
279
|
section: "adminPanel",
|
|
280
280
|
action: "getStart"
|
|
281
281
|
});
|
|
282
|
-
return this.permsCache =
|
|
282
|
+
return this.permsCache = h((r = e == null ? void 0 : e.settings) == null ? void 0 : r.perms), this.permsCache;
|
|
283
283
|
}
|
|
284
284
|
}
|
|
285
|
-
function
|
|
285
|
+
function h(t) {
|
|
286
286
|
const e = {};
|
|
287
287
|
if (!t || typeof t != "object") return e;
|
|
288
288
|
for (const [r, n] of Object.entries(t))
|
|
289
289
|
e[r] = !!n;
|
|
290
290
|
return e;
|
|
291
291
|
}
|
|
292
|
-
function
|
|
293
|
-
var n,
|
|
292
|
+
function b(t, e) {
|
|
293
|
+
var n, s;
|
|
294
294
|
const r = [];
|
|
295
295
|
for (const i of t) {
|
|
296
296
|
if (e != null && !((n = i.tradepointShow) == null ? void 0 : n[String(e)]))
|
|
297
297
|
continue;
|
|
298
|
-
const
|
|
298
|
+
const o = {
|
|
299
299
|
id: i.id,
|
|
300
300
|
pid: i.pid,
|
|
301
301
|
name: i.name,
|
|
@@ -303,15 +303,15 @@ function I(t, e) {
|
|
|
303
303
|
background: i.background,
|
|
304
304
|
show: i.show
|
|
305
305
|
};
|
|
306
|
-
i.img && (
|
|
306
|
+
i.img && (o.img = i.img), (s = i.children) != null && s.length && (o.children = b(i.children, e)), r.push(o);
|
|
307
307
|
}
|
|
308
308
|
return r;
|
|
309
309
|
}
|
|
310
|
-
const
|
|
311
|
-
function
|
|
310
|
+
const L = /* @__PURE__ */ new Set(["product", "techcard"]), N = "/img/no.png";
|
|
311
|
+
function $(t, e) {
|
|
312
312
|
const r = [];
|
|
313
313
|
for (const n of t)
|
|
314
|
-
|
|
314
|
+
L.has(n.type) && (!e && !n.active || r.push({
|
|
315
315
|
id: n.id,
|
|
316
316
|
name: n.nomenclatureName,
|
|
317
317
|
price: n.price,
|
|
@@ -320,39 +320,117 @@ function D(t, e) {
|
|
|
320
320
|
active: n.active,
|
|
321
321
|
type: n.type,
|
|
322
322
|
unit: n.unit,
|
|
323
|
-
logo: n.logo && n.logo !==
|
|
323
|
+
logo: n.logo && n.logo !== N ? n.logo : ""
|
|
324
324
|
}));
|
|
325
325
|
return r;
|
|
326
326
|
}
|
|
327
|
+
const D = {
|
|
328
|
+
UAH: "₴",
|
|
329
|
+
USD: "$",
|
|
330
|
+
EUR: "€",
|
|
331
|
+
KZT: "₸",
|
|
332
|
+
GEL: "ლ",
|
|
333
|
+
THB: "฿",
|
|
334
|
+
AMD: "֏",
|
|
335
|
+
BYN: "Br",
|
|
336
|
+
AZN: "₼",
|
|
337
|
+
GHS: "₵",
|
|
338
|
+
KGS: "с",
|
|
339
|
+
PLN: "zł",
|
|
340
|
+
UZS: "soʻm",
|
|
341
|
+
PHP: "₱",
|
|
342
|
+
IDR: "Rp",
|
|
343
|
+
TJS: "с",
|
|
344
|
+
DOP: "$",
|
|
345
|
+
NZD: "$",
|
|
346
|
+
TRY: "₺",
|
|
347
|
+
SGD: "$",
|
|
348
|
+
NGN: "₦",
|
|
349
|
+
MVR: "Rf",
|
|
350
|
+
TMT: "m",
|
|
351
|
+
MDL: "L",
|
|
352
|
+
VND: "₫",
|
|
353
|
+
CRC: "₡",
|
|
354
|
+
INR: "₹",
|
|
355
|
+
CNY: "¥",
|
|
356
|
+
AED: ".د.إ",
|
|
357
|
+
LKR: "₨",
|
|
358
|
+
RON: "L",
|
|
359
|
+
GBP: "£",
|
|
360
|
+
PKR: "₨",
|
|
361
|
+
KRW: "₩",
|
|
362
|
+
MYR: "RM",
|
|
363
|
+
ILS: "₪",
|
|
364
|
+
ZAR: "R",
|
|
365
|
+
UGX: "USh",
|
|
366
|
+
KES: "KSh",
|
|
367
|
+
TZS: "TSh",
|
|
368
|
+
RSD: "din",
|
|
369
|
+
MXN: "$",
|
|
370
|
+
VEF: "BsF",
|
|
371
|
+
CUP: "$",
|
|
372
|
+
COP: "$",
|
|
373
|
+
KWD: ".د.ك",
|
|
374
|
+
CLP: "$",
|
|
375
|
+
IQD: ".د.ع",
|
|
376
|
+
AOA: "Kz",
|
|
377
|
+
GTQ: "Q",
|
|
378
|
+
CZK: "Kč",
|
|
379
|
+
XAF: "CFA",
|
|
380
|
+
CHF: "Fr",
|
|
381
|
+
RUR: "₽",
|
|
382
|
+
SAR: "SRls"
|
|
383
|
+
};
|
|
384
|
+
function U(t) {
|
|
385
|
+
return t ? D[t.toUpperCase()] ?? t : "";
|
|
386
|
+
}
|
|
387
|
+
function _(t, e) {
|
|
388
|
+
try {
|
|
389
|
+
const r = new Intl.NumberFormat(e, { style: "currency", currency: t }).formatToParts(1), n = r.findIndex((i) => i.type === "currency"), s = r.findIndex((i) => i.type === "integer");
|
|
390
|
+
return n !== -1 && s !== -1 && n < s;
|
|
391
|
+
} catch {
|
|
392
|
+
return !1;
|
|
393
|
+
}
|
|
394
|
+
}
|
|
395
|
+
function oe(t, { currency: e = null, locale: r = "uk", decimals: n = 2 } = {}) {
|
|
396
|
+
if (t == null || t === "") return "";
|
|
397
|
+
const s = typeof t == "number" ? t : Number(t);
|
|
398
|
+
if (!Number.isFinite(s)) return String(t);
|
|
399
|
+
const i = " ", [o, d] = Math.abs(s).toFixed(n).split("."), w = o.replace(/\B(?=(\d{3})+(?!\d))/g, i), a = `${s < 0 ? "-" : ""}${w}${d ? "." + d : ""}`, m = U(e);
|
|
400
|
+
return m ? _(e, r) ? `${m}${a}` : `${a}${i}${m}` : a;
|
|
401
|
+
}
|
|
327
402
|
export {
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
403
|
+
Z as A,
|
|
404
|
+
q as B,
|
|
405
|
+
D as C,
|
|
406
|
+
O as D,
|
|
407
|
+
Y as E,
|
|
408
|
+
f as F,
|
|
331
409
|
v as S,
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
410
|
+
K as a,
|
|
411
|
+
j as b,
|
|
412
|
+
U as c,
|
|
413
|
+
I as d,
|
|
336
414
|
E as e,
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
415
|
+
oe as f,
|
|
416
|
+
F as g,
|
|
417
|
+
H as h,
|
|
418
|
+
y as i,
|
|
419
|
+
p as j,
|
|
420
|
+
W as k,
|
|
421
|
+
x as l,
|
|
422
|
+
G as m,
|
|
423
|
+
re as n,
|
|
424
|
+
ie as o,
|
|
425
|
+
ee as p,
|
|
426
|
+
S as q,
|
|
427
|
+
ne as r,
|
|
428
|
+
se as s,
|
|
429
|
+
B as t,
|
|
430
|
+
V as u,
|
|
431
|
+
X as v,
|
|
432
|
+
J as w,
|
|
433
|
+
te as x,
|
|
434
|
+
Q as y,
|
|
357
435
|
z
|
|
358
436
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const R=require("ua-parser-js"),v="DASHBOARD",A=5e3;let E=0,f=null;function L(){return`sdk_${Date.now()}_${++E}`}function N(){return"APP_"+Math.random().toString(36).slice(2,10)}function T(t){f=t}function m(){return f||(f=N()),f}function c(t){window.parent.postMessage({...t,sender:m(),target:t.target||v},"*")}function l(t,e,r=A){return y()?new Promise(n=>{const o=L(),i=m(),s=setTimeout(()=>{window.removeEventListener("message",d),n(null)},r);function d(w){const a=w.data;(a==null?void 0:a.type)==="DATA_RESPONSE"&&(a==null?void 0:a.requestId)===o&&(!a.target||a.target===i)&&(clearTimeout(s),window.removeEventListener("message",d),n(a.data??null))}window.addEventListener("message",d),c({type:"DATA_REQUEST",requestId:o,source:t,key:e})}):Promise.resolve(null)}function D(t){c({type:"navigate",path:t})}function C(){c({type:"exit"})}const $=C;function u(t){return l("store",t)}function h(t){return l("localStorage",t)}function U(t){return l("window",t)}function _(){return u("company")}function M(){return u("user")}function O(){return h("token")}function W(){return h("lang")}function B(){return u("productCategories")}function F(t,e){c({type:"setLocalStorage",key:t,value:e})}function G(t){c({type:"setRocketMode",value:t})}function K(t,e){c({type:"trackVisit",name:t,path:e})}function x(t){c({type:"openExternalLink",url:t})}function j(){c({type:"openCrispChat"})}function H(t){c({type:"notification",text:t})}function Y(t){c({type:"notification",text:t,variant:"error"})}function Z(t){c({type:"notification",text:t,variant:"warn"})}function y(){try{return window.self!==window.top}catch{return!0}}const q=y;function V(t){function e(r){var n;((n=r.data)==null?void 0:n.sender)===v&&t(r.data)}return window.addEventListener("message",e),()=>window.removeEventListener("message",e)}function p(){if(typeof window>"u")return"browser";if(window.webkit!=null&&window.webkit.messageHandlers!==void 0)try{if(R(navigator.userAgent).browser.name==="WebKit")return"ios_webview"}catch(t){console.error(t)}return typeof Android<"u"?"android_webview":typeof window.cefQuery<"u"?"cef_webview":"browser"}function Q(){return p()==="ios_webview"}function z(){return p()==="android_webview"}function X(){return p()==="cef_webview"}function J(){return p()!=="browser"}const ee="https://api.cabinet.developer.skyservice.online/index.php";class I{constructor(e){this.permsCache=null,this.token=e.token,this.companyId=e.companyId,this.appId=e.appId,this.developerId=e.developerId,this.deploymentId=e.deploymentId,this.appName=e.appName;const r=e.domain.replace("dashboard","api");this.baseUrl=r.startsWith("http")?r:`https://${r}`}static create(e){return new I(e)}async get(e){const r=new URLSearchParams({token:this.token,companyId:this.companyId,...e}),n=await fetch(`${this.baseUrl}/?${r}`);if(!n.ok)throw new Error(`Skyservice API error: ${n.status}`);const o=await n.json();if(o.status!=="done")throw new Error(`Skyservice API returned status: ${o.status}`);return o.data}async post(e,r,n){const o=new URLSearchParams({token:this.token,...r}),i=await fetch(`${e}?${o}`,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});if(!i.ok)throw new Error(`Skyservice API error: ${i.status}`);const s=await i.json();if(s.status!=="done")throw new Error(`Skyservice API returned status: ${s.status}`);return s.data}async getTradepoints(e){const r=await this.get({section:"tradepoints",action:"getTradepoints"});return e!=null&&e.includeDeleted?r.items:r.items.filter(n=>!n.deleted&&!n.frozen)}async getCategoryTree(e){const r=await this.get({section:"productCategory",action:"getCategories",...e?{tradepointId:String(e)}:{}});return b(r,e)}async getProducts(e){const r=await this.get({section:"products",action:"getProducts",pagelimit:"9999",ot:"desc",of:"nomenclatureId",...e!=null&&e.tradepointId?{tradepointId:String(e.tradepointId)}:{}});return re(r.items,e==null?void 0:e.includeInactive)}async setAppActive({isActive:e,title:r,settings:n}){const o=e?"activateApp":"deactivateApp",i={company_id:this.companyId,app_id:this.appId,...this.developerId!==void 0&&{developer_id:this.developerId},...e&&n!==void 0&&{settings:n}},s=await this.post(ee,{section:"integrations",action:o},i);return this.deploymentId&&this.appName&&typeof window<"u"&&window.self!==window.top&&window.parent.postMessage({type:"sendActiveApp",id:s.id,is_active:e,deploymentId:this.deploymentId,appName:this.appName,title:r},"*"),s}async getPerms(e){const r=await this.loadPerms();return e===void 0?r:!!r[String(e)]}clearPermsCache(){this.permsCache=null}async loadPerms(){var r;if(this.permsCache)return this.permsCache;if(typeof window<"u")try{const n=await u("perms");if(n&&Object.keys(n).length>0)return this.permsCache=S(n),this.permsCache}catch{}const e=await this.get({section:"adminPanel",action:"getStart"});return this.permsCache=S((r=e==null?void 0:e.settings)==null?void 0:r.perms),this.permsCache}}function S(t){const e={};if(!t||typeof t!="object")return e;for(const[r,n]of Object.entries(t))e[r]=!!n;return e}function b(t,e){var n,o;const r=[];for(const i of t){if(e!=null&&!((n=i.tradepointShow)==null?void 0:n[String(e)]))continue;const s={id:i.id,pid:i.pid,name:i.name,active:i.active,background:i.background,show:i.show};i.img&&(s.img=i.img),(o=i.children)!=null&&o.length&&(s.children=b(i.children,e)),r.push(s)}return r}const te=new Set(["product","techcard"]),ne="/img/no.png";function re(t,e){const r=[];for(const n of t)te.has(n.type)&&(!e&&!n.active||r.push({id:n.id,name:n.nomenclatureName,price:n.price,categoryId:n.categoryId,categoryName:n.categoryTitle||"",active:n.active,type:n.type,unit:n.unit,logo:n.logo&&n.logo!==ne?n.logo:""}));return r}const P={UAH:"₴",USD:"$",EUR:"€",KZT:"₸",GEL:"ლ",THB:"฿",AMD:"֏",BYN:"Br",AZN:"₼",GHS:"₵",KGS:"с",PLN:"zł",UZS:"soʻm",PHP:"₱",IDR:"Rp",TJS:"с",DOP:"$",NZD:"$",TRY:"₺",SGD:"$",NGN:"₦",MVR:"Rf",TMT:"m",MDL:"L",VND:"₫",CRC:"₡",INR:"₹",CNY:"¥",AED:".د.إ",LKR:"₨",RON:"L",GBP:"£",PKR:"₨",KRW:"₩",MYR:"RM",ILS:"₪",ZAR:"R",UGX:"USh",KES:"KSh",TZS:"TSh",RSD:"din",MXN:"$",VEF:"BsF",CUP:"$",COP:"$",KWD:".د.ك",CLP:"$",IQD:".د.ع",AOA:"Kz",GTQ:"Q",CZK:"Kč",XAF:"CFA",CHF:"Fr",RUR:"₽",SAR:"SRls"};function k(t){return t?P[t.toUpperCase()]??t:""}function ie(t,e){try{const r=new Intl.NumberFormat(e,{style:"currency",currency:t}).formatToParts(1),n=r.findIndex(i=>i.type==="currency"),o=r.findIndex(i=>i.type==="integer");return n!==-1&&o!==-1&&n<o}catch{return!1}}function oe(t,{currency:e=null,locale:r="uk",decimals:n=2}={}){if(t==null||t==="")return"";const o=typeof t=="number"?t:Number(t);if(!Number.isFinite(o))return String(t);const i=" ",[s,d]=Math.abs(o).toFixed(n).split("."),w=s.replace(/\B(?=(\d{3})+(?!\d))/g,i),a=`${o<0?"-":""}${w}${d?"."+d:""}`,g=k(e);return g?ie(e,r)?`${g}${a}`:`${a}${i}${g}`:a}exports.CURRENCY_ICONS=P;exports.SkyserviceAPI=I;exports.currencyIcon=k;exports.exit=C;exports.formatMoney=oe;exports.getBack=$;exports.getCompany=_;exports.getLang=W;exports.getLocalStorageData=h;exports.getProductCategories=B;exports.getSenderId=m;exports.getStoreData=u;exports.getToken=O;exports.getUser=M;exports.getWindowData=U;exports.isAndroidWebview=z;exports.isCefWebview=X;exports.isInIframe=q;exports.isInsideIframe=y;exports.isIosWebview=Q;exports.isWebview=J;exports.navigate=D;exports.notify=H;exports.notifyError=Y;exports.notifyWarn=Z;exports.onMessage=V;exports.openCrispChat=j;exports.openExternalLink=x;exports.setLocalStorage=F;exports.setRocketMode=G;exports.setSenderId=T;exports.trackVisit=K;exports.webviewCheck=p;
|
package/dist/sdk/index.d.ts
CHANGED
|
@@ -3,4 +3,6 @@ export { webviewCheck, isIosWebview, isAndroidWebview, isCefWebview, isWebview,
|
|
|
3
3
|
export type { WebviewType } from './webview';
|
|
4
4
|
export { SkyserviceAPI } from './api';
|
|
5
5
|
export type { SkyserviceAPIConfig } from './api';
|
|
6
|
+
export { formatMoney, currencyIcon, CURRENCY_ICONS } from './money';
|
|
7
|
+
export type { FormatMoneyOptions } from './money';
|
|
6
8
|
export type { Tradepoint, TradepointWorkDay, Category, RawCategory, Product, RawProduct, AppIntegration, PermsMap, } from './types';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Гроші: значок валюти й форматування суми. Живе в SDK, бо тут немає Vue —
|
|
3
|
+
* адмінка на Vue 2 не може імпортувати компоненти кіта, а цей модуль може взяти.
|
|
4
|
+
*
|
|
5
|
+
* Формат зведений із адмінкою (`CurrencyFormatted` + `formatNumberWithSpaces`
|
|
6
|
+
* у mathExtended.js): дві копійки, тисячі через пробіл, крапка як десятковий
|
|
7
|
+
* роздільник. Локальні розділювачі свідомо не беремо — інакше та сама сума
|
|
8
|
+
* виглядала б по-різному в адмінці й у міні-аппі.
|
|
9
|
+
*/
|
|
10
|
+
/** ISO → значок. Список курований під наші ринки, узятий з адмінки. */
|
|
11
|
+
export declare const CURRENCY_ICONS: Record<string, string>;
|
|
12
|
+
/** Невідомий код повертаємо як є — це краще за порожнечу біля ціни. */
|
|
13
|
+
export declare function currencyIcon(iso: string | null | undefined): string;
|
|
14
|
+
export interface FormatMoneyOptions {
|
|
15
|
+
/** ISO валюти. Без нього повертається лише число. */
|
|
16
|
+
currency?: string | null;
|
|
17
|
+
/** Мова інтерфейсу — вирішує, з якого боку значок. Типово 'uk'. */
|
|
18
|
+
locale?: string;
|
|
19
|
+
/** Знаків після коми. Типово 2. */
|
|
20
|
+
decimals?: number;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Форматує суму: `formatMoney('1250', { currency: 'UAH' })` → `1 250.00 ₴`.
|
|
24
|
+
* Нечислове значення повертається як є — краще показати сире, ніж `NaN`.
|
|
25
|
+
*
|
|
26
|
+
* Тисячі й значок відбиваються нерозривним пробілом, щоб ціна не переносилась
|
|
27
|
+
* на два рядки посеред числа.
|
|
28
|
+
*/
|
|
29
|
+
export declare function formatMoney(value: string | number | null | undefined, { currency, locale, decimals }?: FormatMoneyOptions): string;
|
package/dist/sdk.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("./money-dyX9wNiC.cjs");exports.CURRENCY_ICONS=e.CURRENCY_ICONS;exports.SkyserviceAPI=e.SkyserviceAPI;exports.currencyIcon=e.currencyIcon;exports.exit=e.exit;exports.formatMoney=e.formatMoney;exports.getBack=e.getBack;exports.getCompany=e.getCompany;exports.getLang=e.getLang;exports.getLocalStorageData=e.getLocalStorageData;exports.getProductCategories=e.getProductCategories;exports.getSenderId=e.getSenderId;exports.getStoreData=e.getStoreData;exports.getToken=e.getToken;exports.getUser=e.getUser;exports.getWindowData=e.getWindowData;exports.isAndroidWebview=e.isAndroidWebview;exports.isCefWebview=e.isCefWebview;exports.isInIframe=e.isInIframe;exports.isInsideIframe=e.isInsideIframe;exports.isIosWebview=e.isIosWebview;exports.isWebview=e.isWebview;exports.navigate=e.navigate;exports.notify=e.notify;exports.notifyError=e.notifyError;exports.notifyWarn=e.notifyWarn;exports.onMessage=e.onMessage;exports.openCrispChat=e.openCrispChat;exports.openExternalLink=e.openExternalLink;exports.setLocalStorage=e.setLocalStorage;exports.setRocketMode=e.setRocketMode;exports.setSenderId=e.setSenderId;exports.trackVisit=e.trackVisit;exports.webviewCheck=e.webviewCheck;
|
package/dist/sdk.js
CHANGED
|
@@ -1,33 +1,36 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { C as s, S as t, c as o, e as i, f as r, g as n, a as g, b as c, d, h as C, i as I, j as f, k, l as v, m as w, n as y, o as S, p as b, q as m, r as p, s as W, t as l, u as x, v as D, w as E, x as L, y as h, z as u, A, B as M, D as R, E as B, F as N } from "./money-BCv6JlZu.js";
|
|
2
2
|
export {
|
|
3
|
-
s as
|
|
4
|
-
t as
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
r as
|
|
8
|
-
n as
|
|
9
|
-
g as
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
l as
|
|
25
|
-
x as
|
|
26
|
-
|
|
27
|
-
|
|
3
|
+
s as CURRENCY_ICONS,
|
|
4
|
+
t as SkyserviceAPI,
|
|
5
|
+
o as currencyIcon,
|
|
6
|
+
i as exit,
|
|
7
|
+
r as formatMoney,
|
|
8
|
+
n as getBack,
|
|
9
|
+
g as getCompany,
|
|
10
|
+
c as getLang,
|
|
11
|
+
d as getLocalStorageData,
|
|
12
|
+
C as getProductCategories,
|
|
13
|
+
I as getSenderId,
|
|
14
|
+
f as getStoreData,
|
|
15
|
+
k as getToken,
|
|
16
|
+
v as getUser,
|
|
17
|
+
w as getWindowData,
|
|
18
|
+
y as isAndroidWebview,
|
|
19
|
+
S as isCefWebview,
|
|
20
|
+
b as isInIframe,
|
|
21
|
+
m as isInsideIframe,
|
|
22
|
+
p as isIosWebview,
|
|
23
|
+
W as isWebview,
|
|
24
|
+
l as navigate,
|
|
25
|
+
x as notify,
|
|
26
|
+
D as notifyError,
|
|
27
|
+
E as notifyWarn,
|
|
28
|
+
L as onMessage,
|
|
29
|
+
h as openCrispChat,
|
|
30
|
+
u as openExternalLink,
|
|
28
31
|
A as setLocalStorage,
|
|
29
|
-
|
|
30
|
-
|
|
32
|
+
M as setRocketMode,
|
|
33
|
+
R as setSenderId,
|
|
31
34
|
B as trackVisit,
|
|
32
|
-
|
|
35
|
+
N as webviewCheck
|
|
33
36
|
};
|