@karta.io/utils 0.33.7 → 0.34.0-alpha.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/dist/index.cjs +119 -121
- package/dist/index.d.ts +14 -15
- package/dist/index.mjs +96 -110
- package/package.json +17 -14
package/dist/index.cjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
const camelCase = require('lodash/camelCase.js');
|
|
4
|
+
const commonData = require('@karta.io/common-data');
|
|
4
5
|
const libphonenumberJs = require('libphonenumber-js');
|
|
5
6
|
const snakeCase = require('lodash/snakeCase.js');
|
|
6
7
|
const vue = require('vue');
|
|
@@ -14,15 +15,26 @@ const customParseFormat = require('dayjs/plugin/customParseFormat.js');
|
|
|
14
15
|
const detectBrowser = require('detect-browser');
|
|
15
16
|
const logdown = require('logdown');
|
|
16
17
|
|
|
18
|
+
function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
|
|
19
|
+
|
|
20
|
+
const camelCase__default = /*#__PURE__*/_interopDefaultCompat(camelCase);
|
|
21
|
+
const snakeCase__default = /*#__PURE__*/_interopDefaultCompat(snakeCase);
|
|
22
|
+
const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
|
|
23
|
+
const utc__default = /*#__PURE__*/_interopDefaultCompat(utc);
|
|
24
|
+
const tz__default = /*#__PURE__*/_interopDefaultCompat(tz);
|
|
25
|
+
const updateLocale__default = /*#__PURE__*/_interopDefaultCompat(updateLocale);
|
|
26
|
+
const isToday__default = /*#__PURE__*/_interopDefaultCompat(isToday);
|
|
27
|
+
const customParseFormat__default = /*#__PURE__*/_interopDefaultCompat(customParseFormat);
|
|
28
|
+
const logdown__default = /*#__PURE__*/_interopDefaultCompat(logdown);
|
|
29
|
+
|
|
17
30
|
function camelizeKeys(object) {
|
|
18
|
-
if (Array.isArray(object))
|
|
31
|
+
if (Array.isArray(object))
|
|
19
32
|
return object.map((v) => camelizeKeys(v));
|
|
20
|
-
}
|
|
21
33
|
if (object !== null && object.constructor === Object) {
|
|
22
34
|
return Object.keys(object).reduce(
|
|
23
35
|
(result, key) => ({
|
|
24
36
|
...result,
|
|
25
|
-
[
|
|
37
|
+
[camelCase__default(key)]: camelizeKeys(object[key])
|
|
26
38
|
}),
|
|
27
39
|
{}
|
|
28
40
|
);
|
|
@@ -33,31 +45,28 @@ function camelizeKeys(object) {
|
|
|
33
45
|
function createClassName(className) {
|
|
34
46
|
return function f(...classNames) {
|
|
35
47
|
const result = classNames.join("");
|
|
36
|
-
|
|
48
|
+
const create = (...args) => args.length ? f.apply(null, [result, ...args])() : result;
|
|
49
|
+
return create;
|
|
37
50
|
}(className);
|
|
38
51
|
}
|
|
39
52
|
|
|
40
|
-
function formatMoney(value, currency, options = {
|
|
41
|
-
|
|
42
|
-
if (value === null || Number.isNaN(convertedValue))
|
|
53
|
+
function formatMoney(value, currency = commonData.CURRENCY_DEFAULT, options = {}) {
|
|
54
|
+
const convertedValue = Number(value);
|
|
55
|
+
if (value === null || Number.isNaN(convertedValue))
|
|
43
56
|
return "";
|
|
44
|
-
}
|
|
45
|
-
const formatter = new Intl.NumberFormat(
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
}
|
|
57
|
+
const { locale = "en-US", ...otherOptions } = options;
|
|
58
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
59
|
+
style: "currency",
|
|
60
|
+
currency,
|
|
61
|
+
minimumFractionDigits: 2,
|
|
62
|
+
maximumFractionDigits: 2,
|
|
63
|
+
...otherOptions
|
|
52
64
|
});
|
|
53
65
|
return formatter.format(convertedValue);
|
|
54
66
|
}
|
|
55
67
|
|
|
56
68
|
function genLoadingTableRows(columns, limit) {
|
|
57
|
-
const row = columns.reduce(
|
|
58
|
-
(acc, curr) => ({ ...acc, [curr.key]: void 0 }),
|
|
59
|
-
{}
|
|
60
|
-
);
|
|
69
|
+
const row = columns.reduce((acc, curr) => ({ ...acc, [curr.key]: void 0 }), {});
|
|
61
70
|
return Array.from(Array(limit).keys()).map((item) => ({ id: item, ...row }));
|
|
62
71
|
}
|
|
63
72
|
|
|
@@ -66,7 +75,8 @@ function genRandomNumber(min, max) {
|
|
|
66
75
|
}
|
|
67
76
|
|
|
68
77
|
function genUUID() {
|
|
69
|
-
let d = new Date().getTime()
|
|
78
|
+
let d = (/* @__PURE__ */ new Date()).getTime();
|
|
79
|
+
let d2 = performance && performance.now && performance.now() * 1e3 || 0;
|
|
70
80
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
71
81
|
let r = Math.random() * 16;
|
|
72
82
|
if (d > 0) {
|
|
@@ -139,9 +149,7 @@ function getPaginationParams({
|
|
|
139
149
|
offset: validatedPage * validatedLimit - validatedLimit
|
|
140
150
|
};
|
|
141
151
|
}
|
|
142
|
-
function getPaginationLimit({
|
|
143
|
-
limit
|
|
144
|
-
}) {
|
|
152
|
+
function getPaginationLimit({ limit }) {
|
|
145
153
|
return validateNumber(limit, LIMIT_DEFAULT);
|
|
146
154
|
}
|
|
147
155
|
function getPaginationOffset({
|
|
@@ -163,22 +171,20 @@ function parsePhone(phone) {
|
|
|
163
171
|
if (!phone || typeof phone !== "string")
|
|
164
172
|
return "";
|
|
165
173
|
const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
|
|
166
|
-
if (replacedPhone.length === 1 && replacedPhone !== "+")
|
|
174
|
+
if (replacedPhone.length === 1 && replacedPhone !== "+")
|
|
167
175
|
return `+${replacedPhone}`;
|
|
168
|
-
}
|
|
169
176
|
const phoneNumber = libphonenumberJs.parsePhoneNumberFromString(replacedPhone);
|
|
170
177
|
return phoneNumber ? phoneNumber.formatInternational() : replacedPhone;
|
|
171
178
|
}
|
|
172
179
|
|
|
173
180
|
function snakelizeKeys(prop) {
|
|
174
|
-
if (Array.isArray(prop))
|
|
181
|
+
if (Array.isArray(prop))
|
|
175
182
|
return prop.map((item) => snakelizeKeys(item));
|
|
176
|
-
}
|
|
177
183
|
if (prop !== null && prop !== void 0 && prop.constructor === Object) {
|
|
178
184
|
return Object.keys(prop).reduce(
|
|
179
185
|
(accum, current) => ({
|
|
180
186
|
...accum,
|
|
181
|
-
[
|
|
187
|
+
[snakeCase__default(current)]: snakelizeKeys(prop[current])
|
|
182
188
|
}),
|
|
183
189
|
{}
|
|
184
190
|
);
|
|
@@ -202,27 +208,21 @@ function unformatNumber(value) {
|
|
|
202
208
|
const commasCount = (string.match(/,/g) || []).length;
|
|
203
209
|
if (!Number.isNaN(Number(string)))
|
|
204
210
|
return Number(string);
|
|
205
|
-
if (hasSpace && hasComma && commaIndex > spaceIndex)
|
|
211
|
+
if (hasSpace && hasComma && commaIndex > spaceIndex)
|
|
206
212
|
locale = LOCALE_RU;
|
|
207
|
-
|
|
208
|
-
if (hasSpace && !hasComma && !hasDot) {
|
|
213
|
+
if (hasSpace && !hasComma && !hasDot)
|
|
209
214
|
locale = LOCALE_RU;
|
|
210
|
-
|
|
211
|
-
if (hasComma && hasDot && dotIndex > commaIndex) {
|
|
215
|
+
if (hasComma && hasDot && dotIndex > commaIndex)
|
|
212
216
|
locale = LOCALE_EN;
|
|
213
|
-
|
|
214
|
-
if (hasComma && !hasSpace && !hasDot && commasCount > 1) {
|
|
217
|
+
if (hasComma && !hasSpace && !hasDot && commasCount > 1)
|
|
215
218
|
locale = LOCALE_EN;
|
|
216
|
-
}
|
|
217
219
|
if (commasCount === 1 && !hasSpace && !hasDot) {
|
|
218
220
|
locale = string.length - 1 - commaIndex === 3 ? LOCALE_EN : LOCALE_RU;
|
|
219
221
|
}
|
|
220
|
-
if (locale === LOCALE_RU)
|
|
222
|
+
if (locale === LOCALE_RU)
|
|
221
223
|
return Number(string.replaceAll(" ", "").replace(",", "."));
|
|
222
|
-
|
|
223
|
-
if (locale === LOCALE_EN) {
|
|
224
|
+
if (locale === LOCALE_EN)
|
|
224
225
|
return Number(string.replaceAll(",", ""));
|
|
225
|
-
}
|
|
226
226
|
return value;
|
|
227
227
|
}
|
|
228
228
|
|
|
@@ -231,9 +231,8 @@ function UiComponentsResolver(options = {}) {
|
|
|
231
231
|
return (name) => {
|
|
232
232
|
const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
|
|
233
233
|
const isUiComponent = componentName.startsWith("Ui");
|
|
234
|
-
if (isUiComponent)
|
|
234
|
+
if (isUiComponent)
|
|
235
235
|
return { name: componentName, from: "@karta.io/ui-components" };
|
|
236
|
-
}
|
|
237
236
|
};
|
|
238
237
|
}
|
|
239
238
|
|
|
@@ -241,9 +240,8 @@ function useAbortController(callback) {
|
|
|
241
240
|
let controller = null;
|
|
242
241
|
return {
|
|
243
242
|
async call(...args) {
|
|
244
|
-
if (controller)
|
|
243
|
+
if (controller)
|
|
245
244
|
controller.abort();
|
|
246
|
-
}
|
|
247
245
|
controller = new AbortController();
|
|
248
246
|
let response;
|
|
249
247
|
if (args.length > 0) {
|
|
@@ -283,11 +281,7 @@ function useAsyncMultiselect({
|
|
|
283
281
|
const page = vue.ref(1);
|
|
284
282
|
const options = vue.computed(() => [...items.value.values()]);
|
|
285
283
|
const hasNextPage = vue.computed(() => count.value > items.value.size);
|
|
286
|
-
const {
|
|
287
|
-
call: apiMethodWAC,
|
|
288
|
-
abort,
|
|
289
|
-
isAborted
|
|
290
|
-
} = useAbortController(apiMethod);
|
|
284
|
+
const { call: apiMethodWAC, abort, isAborted } = useAbortController(apiMethod);
|
|
291
285
|
const handleSearch = async (value) => {
|
|
292
286
|
if (search.value === value)
|
|
293
287
|
return;
|
|
@@ -305,12 +299,10 @@ function useAsyncMultiselect({
|
|
|
305
299
|
});
|
|
306
300
|
count.value = itemsCount;
|
|
307
301
|
if (isSearch) {
|
|
308
|
-
const cashedMapItems = selectedValues.value.map(
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
]
|
|
313
|
-
);
|
|
302
|
+
const cashedMapItems = selectedValues.value.map((selectedValue) => [
|
|
303
|
+
selectedValue,
|
|
304
|
+
items.value.get(selectedValue)
|
|
305
|
+
]);
|
|
314
306
|
items.value = new Map([...cashedMapItems]);
|
|
315
307
|
}
|
|
316
308
|
const resultsForMap = results.map(mapResultCallback);
|
|
@@ -354,11 +346,7 @@ function useAsyncSelect({
|
|
|
354
346
|
const page = vue.ref(1);
|
|
355
347
|
const options = vue.computed(() => [...items.value.values()]);
|
|
356
348
|
const hasNextPage = vue.computed(() => count.value > items.value.size);
|
|
357
|
-
const {
|
|
358
|
-
call: apiMethodWAC,
|
|
359
|
-
abort,
|
|
360
|
-
isAborted
|
|
361
|
-
} = useAbortController(apiMethod);
|
|
349
|
+
const { call: apiMethodWAC, abort, isAborted } = useAbortController(apiMethod);
|
|
362
350
|
const handleSearch = async (value) => {
|
|
363
351
|
if (search.value === value)
|
|
364
352
|
return;
|
|
@@ -375,9 +363,8 @@ function useAsyncSelect({
|
|
|
375
363
|
...params
|
|
376
364
|
});
|
|
377
365
|
count.value = itemsCount;
|
|
378
|
-
if (isSearch)
|
|
366
|
+
if (isSearch)
|
|
379
367
|
items.value = /* @__PURE__ */ new Map();
|
|
380
|
-
}
|
|
381
368
|
const resultsForMap = results.map(mapResultCallback);
|
|
382
369
|
items.value = new Map([...items.value, ...resultsForMap]);
|
|
383
370
|
page.value += 1;
|
|
@@ -406,23 +393,19 @@ function useAsyncSelect({
|
|
|
406
393
|
};
|
|
407
394
|
}
|
|
408
395
|
|
|
409
|
-
|
|
396
|
+
function _bem(block, blockSuffix, element, modifier, modifierValue) {
|
|
410
397
|
let cls = block;
|
|
411
|
-
if (blockSuffix)
|
|
398
|
+
if (blockSuffix)
|
|
412
399
|
cls += `-${blockSuffix}`;
|
|
413
|
-
|
|
414
|
-
if (element) {
|
|
400
|
+
if (element)
|
|
415
401
|
cls += `__${element}`;
|
|
416
|
-
|
|
417
|
-
if (modifier) {
|
|
402
|
+
if (modifier)
|
|
418
403
|
cls += `_${modifier}`;
|
|
419
|
-
|
|
420
|
-
if (modifierValue) {
|
|
404
|
+
if (modifierValue)
|
|
421
405
|
cls += `_${modifierValue}`;
|
|
422
|
-
}
|
|
423
406
|
return cls;
|
|
424
|
-
}
|
|
425
|
-
|
|
407
|
+
}
|
|
408
|
+
function useClassName(block) {
|
|
426
409
|
const b = (blockSuffix = "") => _bem(block, blockSuffix, "", "", "");
|
|
427
410
|
const e = (element) => element ? _bem(block, "", element, "", "") : "";
|
|
428
411
|
const m = (modifier, condition = true) => modifier && condition ? _bem(block, "", "", modifier, "") : "";
|
|
@@ -430,9 +413,8 @@ const useClassName = (block) => {
|
|
|
430
413
|
const mv = (modifier, modifierValue, condition = true) => modifier && modifierValue && condition ? _bem(block, "", "", modifier, modifierValue) : "";
|
|
431
414
|
const cssVar = (object) => {
|
|
432
415
|
const styles = {};
|
|
433
|
-
for (const key in object)
|
|
416
|
+
for (const key in object)
|
|
434
417
|
styles[`--${block}-${key}`] = object[key];
|
|
435
|
-
}
|
|
436
418
|
return styles;
|
|
437
419
|
};
|
|
438
420
|
const cssVarName = (name) => `--${block}-${name}`;
|
|
@@ -446,32 +428,34 @@ const useClassName = (block) => {
|
|
|
446
428
|
cssVar,
|
|
447
429
|
cssVarName
|
|
448
430
|
};
|
|
449
|
-
}
|
|
431
|
+
}
|
|
450
432
|
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
433
|
+
dayjs__default.extend(utc__default);
|
|
434
|
+
dayjs__default.extend(tz__default);
|
|
435
|
+
dayjs__default.extend(updateLocale__default);
|
|
436
|
+
dayjs__default.extend(isToday__default);
|
|
437
|
+
dayjs__default.extend(customParseFormat__default);
|
|
456
438
|
function useDayjs(timezone) {
|
|
457
|
-
|
|
439
|
+
dayjs__default.updateLocale("en", {
|
|
458
440
|
weekStart: 1
|
|
459
441
|
});
|
|
460
|
-
if (!timezone)
|
|
461
|
-
return
|
|
462
|
-
|
|
463
|
-
const dayjsExtended = (date, format, locale, strict) => dayjs(date, format, locale, strict).tz(timezone);
|
|
442
|
+
if (!timezone)
|
|
443
|
+
return dayjs__default;
|
|
444
|
+
const dayjsExtended = (date, format, locale, strict) => dayjs__default(date, format, locale, strict).tz(timezone);
|
|
464
445
|
return dayjsExtended;
|
|
465
446
|
}
|
|
466
447
|
|
|
467
448
|
function parseVersion(version) {
|
|
468
449
|
if (typeof version !== "string" && typeof version !== "number") {
|
|
469
|
-
throw new TypeError(
|
|
470
|
-
"Browser version must be type of string, number or negative boolean"
|
|
471
|
-
);
|
|
450
|
+
throw new TypeError("Browser version must be type of string, number or negative boolean");
|
|
472
451
|
}
|
|
473
452
|
const [major, minor = 0, patch = 0, build = 0] = typeof version === "string" ? version.split(".").map(Number) : [version];
|
|
474
|
-
return {
|
|
453
|
+
return {
|
|
454
|
+
major,
|
|
455
|
+
minor,
|
|
456
|
+
patch,
|
|
457
|
+
build
|
|
458
|
+
};
|
|
475
459
|
}
|
|
476
460
|
function isVersionLower(minimum, target) {
|
|
477
461
|
for (const k of ["major", "minor", "patch"]) {
|
|
@@ -516,7 +500,7 @@ function isEnabled(options) {
|
|
|
516
500
|
}
|
|
517
501
|
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
518
502
|
if (isNode) {
|
|
519
|
-
const debug = process.env
|
|
503
|
+
const debug = process.env.NODE_DEBUG;
|
|
520
504
|
if (debug === "true")
|
|
521
505
|
return true;
|
|
522
506
|
if (debug === "false")
|
|
@@ -526,7 +510,7 @@ function isEnabled(options) {
|
|
|
526
510
|
}
|
|
527
511
|
function useLogger(scope, options) {
|
|
528
512
|
const prefix = options?.tag ? `[${scope.toUpperCase()}.${options.tag}]:` : `[${scope.toUpperCase()}]:`;
|
|
529
|
-
const logger =
|
|
513
|
+
const logger = logdown__default(prefix, { prefixColor: options?.color });
|
|
530
514
|
logger.state.isEnabled = isEnabled(options);
|
|
531
515
|
return logger;
|
|
532
516
|
}
|
|
@@ -538,35 +522,49 @@ function validatePhone(rule, value) {
|
|
|
538
522
|
return phoneNumber ? phoneNumber.isValid() : false;
|
|
539
523
|
}
|
|
540
524
|
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
}
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
}
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
}
|
|
525
|
+
function isRequired(value = true, message = "This field is required") {
|
|
526
|
+
return {
|
|
527
|
+
required: value,
|
|
528
|
+
message
|
|
529
|
+
};
|
|
530
|
+
}
|
|
531
|
+
function isMax(value = 255, message) {
|
|
532
|
+
return {
|
|
533
|
+
max: value,
|
|
534
|
+
message: message ?? `Length must be no more than ${value} characters`
|
|
535
|
+
};
|
|
536
|
+
}
|
|
537
|
+
function isMin(value = 3, message) {
|
|
538
|
+
return {
|
|
539
|
+
min: value,
|
|
540
|
+
message: message ?? `Length must be at least ${value} characters`
|
|
541
|
+
};
|
|
542
|
+
}
|
|
543
|
+
function isTypeEmail(message = "Invalid format") {
|
|
544
|
+
return {
|
|
545
|
+
type: "email",
|
|
546
|
+
message
|
|
547
|
+
};
|
|
548
|
+
}
|
|
549
|
+
function isTypeUrl(message = "The url is invalid") {
|
|
550
|
+
return {
|
|
551
|
+
type: "url",
|
|
552
|
+
message
|
|
553
|
+
};
|
|
554
|
+
}
|
|
555
|
+
function isTypeNumber(value = 1, message) {
|
|
556
|
+
return {
|
|
557
|
+
type: "number",
|
|
558
|
+
min: value,
|
|
559
|
+
message: message ?? `Must be at least ${value}`
|
|
560
|
+
};
|
|
561
|
+
}
|
|
562
|
+
function isStrictLength(value = 3, message) {
|
|
563
|
+
return {
|
|
564
|
+
len: value,
|
|
565
|
+
message: message ?? `Length must be exactly ${value} characters`
|
|
566
|
+
};
|
|
567
|
+
}
|
|
570
568
|
|
|
571
569
|
exports.UiComponentsResolver = UiComponentsResolver;
|
|
572
570
|
exports.camelizeKeys = camelizeKeys;
|
package/dist/index.d.ts
CHANGED
|
@@ -19,11 +19,10 @@ declare function camelizeKeys(object: Dictionary): Dictionary;
|
|
|
19
19
|
|
|
20
20
|
declare function createClassName(className: string): (...classNames: string[]) => string;
|
|
21
21
|
|
|
22
|
-
|
|
23
|
-
locale
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
}): string;
|
|
22
|
+
interface Options$2 extends Intl.NumberFormatOptions {
|
|
23
|
+
locale?: string;
|
|
24
|
+
}
|
|
25
|
+
declare function formatMoney(value: string | number | null | undefined, currency?: string, options?: Options$2): string;
|
|
27
26
|
|
|
28
27
|
declare function genLoadingTableRows(columns: Dictionary[], limit: number): {
|
|
29
28
|
id: number | undefined;
|
|
@@ -48,7 +47,7 @@ declare function isElementIgnored({ ignoredClasses, event, }?: {
|
|
|
48
47
|
event?: Event;
|
|
49
48
|
}): boolean;
|
|
50
49
|
|
|
51
|
-
declare function isEmptyObject(object:
|
|
50
|
+
declare function isEmptyObject(object: object): boolean;
|
|
52
51
|
|
|
53
52
|
declare function getPaginationParams({ page, limit, }: {
|
|
54
53
|
page: string | number;
|
|
@@ -57,7 +56,7 @@ declare function getPaginationParams({ page, limit, }: {
|
|
|
57
56
|
limit: number;
|
|
58
57
|
offset: number;
|
|
59
58
|
};
|
|
60
|
-
declare function getPaginationLimit({ limit
|
|
59
|
+
declare function getPaginationLimit({ limit }: {
|
|
61
60
|
limit: string | number;
|
|
62
61
|
}): number;
|
|
63
62
|
declare function getPaginationOffset({ page, limit, }: {
|
|
@@ -137,7 +136,7 @@ declare function useAsyncSelect<T extends (...args: any[]) => any, K extends (pa
|
|
|
137
136
|
handleSearch: (value: string) => Promise<void>;
|
|
138
137
|
};
|
|
139
138
|
|
|
140
|
-
declare
|
|
139
|
+
declare function useClassName(block: string): {
|
|
141
140
|
b: (blockSuffix?: string) => string;
|
|
142
141
|
e: (element?: string) => string;
|
|
143
142
|
m: (modifier?: string, condition?: boolean) => string;
|
|
@@ -183,18 +182,18 @@ declare function useLogger(scope: string, options?: Options): logdown.Logger;
|
|
|
183
182
|
|
|
184
183
|
declare function validatePhone(rule: string, value: string): boolean;
|
|
185
184
|
|
|
186
|
-
declare
|
|
187
|
-
declare
|
|
185
|
+
declare function isRequired(value?: boolean, message?: string): RuleItem;
|
|
186
|
+
declare function isMax(value?: number, message?: string): {
|
|
188
187
|
max: number;
|
|
189
188
|
message: string;
|
|
190
189
|
};
|
|
191
|
-
declare
|
|
190
|
+
declare function isMin(value?: number, message?: string): {
|
|
192
191
|
min: number;
|
|
193
192
|
message: string;
|
|
194
193
|
};
|
|
195
|
-
declare
|
|
196
|
-
declare
|
|
197
|
-
declare
|
|
198
|
-
declare
|
|
194
|
+
declare function isTypeEmail(message?: string): RuleItem;
|
|
195
|
+
declare function isTypeUrl(message?: string): RuleItem;
|
|
196
|
+
declare function isTypeNumber(value?: number, message?: string): RuleItem;
|
|
197
|
+
declare function isStrictLength(value?: number, message?: string): RuleItem;
|
|
199
198
|
|
|
200
199
|
export { BrowserInfo, Dictionary, ResponseError, UiComponentsResolver, VersionsList, camelizeKeys, createClassName, formatMoney, genLoadingTableRows, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, isElementIgnored, isEmptyObject, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncMultiselect, useAsyncSelect, useClassName, useDayjs, useDetectBrowser, useLogger, validateNumber, validatePhone };
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import camelCase from 'lodash/camelCase.js';
|
|
2
|
+
import { CURRENCY_DEFAULT } from '@karta.io/common-data';
|
|
2
3
|
import { parsePhoneNumberFromString } from 'libphonenumber-js';
|
|
3
4
|
import snakeCase from 'lodash/snakeCase.js';
|
|
4
5
|
import { ref, computed, onBeforeUnmount } from 'vue';
|
|
@@ -13,9 +14,8 @@ import { detect } from 'detect-browser';
|
|
|
13
14
|
import logdown from 'logdown';
|
|
14
15
|
|
|
15
16
|
function camelizeKeys(object) {
|
|
16
|
-
if (Array.isArray(object))
|
|
17
|
+
if (Array.isArray(object))
|
|
17
18
|
return object.map((v) => camelizeKeys(v));
|
|
18
|
-
}
|
|
19
19
|
if (object !== null && object.constructor === Object) {
|
|
20
20
|
return Object.keys(object).reduce(
|
|
21
21
|
(result, key) => ({
|
|
@@ -31,31 +31,28 @@ function camelizeKeys(object) {
|
|
|
31
31
|
function createClassName(className) {
|
|
32
32
|
return function f(...classNames) {
|
|
33
33
|
const result = classNames.join("");
|
|
34
|
-
|
|
34
|
+
const create = (...args) => args.length ? f.apply(null, [result, ...args])() : result;
|
|
35
|
+
return create;
|
|
35
36
|
}(className);
|
|
36
37
|
}
|
|
37
38
|
|
|
38
|
-
function formatMoney(value, currency, options = {
|
|
39
|
-
|
|
40
|
-
if (value === null || Number.isNaN(convertedValue))
|
|
39
|
+
function formatMoney(value, currency = CURRENCY_DEFAULT, options = {}) {
|
|
40
|
+
const convertedValue = Number(value);
|
|
41
|
+
if (value === null || Number.isNaN(convertedValue))
|
|
41
42
|
return "";
|
|
42
|
-
}
|
|
43
|
-
const formatter = new Intl.NumberFormat(
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
}
|
|
43
|
+
const { locale = "en-US", ...otherOptions } = options;
|
|
44
|
+
const formatter = new Intl.NumberFormat(locale, {
|
|
45
|
+
style: "currency",
|
|
46
|
+
currency,
|
|
47
|
+
minimumFractionDigits: 2,
|
|
48
|
+
maximumFractionDigits: 2,
|
|
49
|
+
...otherOptions
|
|
50
50
|
});
|
|
51
51
|
return formatter.format(convertedValue);
|
|
52
52
|
}
|
|
53
53
|
|
|
54
54
|
function genLoadingTableRows(columns, limit) {
|
|
55
|
-
const row = columns.reduce(
|
|
56
|
-
(acc, curr) => ({ ...acc, [curr.key]: void 0 }),
|
|
57
|
-
{}
|
|
58
|
-
);
|
|
55
|
+
const row = columns.reduce((acc, curr) => ({ ...acc, [curr.key]: void 0 }), {});
|
|
59
56
|
return Array.from(Array(limit).keys()).map((item) => ({ id: item, ...row }));
|
|
60
57
|
}
|
|
61
58
|
|
|
@@ -64,7 +61,8 @@ function genRandomNumber(min, max) {
|
|
|
64
61
|
}
|
|
65
62
|
|
|
66
63
|
function genUUID() {
|
|
67
|
-
let d = new Date().getTime()
|
|
64
|
+
let d = (/* @__PURE__ */ new Date()).getTime();
|
|
65
|
+
let d2 = performance && performance.now && performance.now() * 1e3 || 0;
|
|
68
66
|
return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, (c) => {
|
|
69
67
|
let r = Math.random() * 16;
|
|
70
68
|
if (d > 0) {
|
|
@@ -137,9 +135,7 @@ function getPaginationParams({
|
|
|
137
135
|
offset: validatedPage * validatedLimit - validatedLimit
|
|
138
136
|
};
|
|
139
137
|
}
|
|
140
|
-
function getPaginationLimit({
|
|
141
|
-
limit
|
|
142
|
-
}) {
|
|
138
|
+
function getPaginationLimit({ limit }) {
|
|
143
139
|
return validateNumber(limit, LIMIT_DEFAULT);
|
|
144
140
|
}
|
|
145
141
|
function getPaginationOffset({
|
|
@@ -161,17 +157,15 @@ function parsePhone(phone) {
|
|
|
161
157
|
if (!phone || typeof phone !== "string")
|
|
162
158
|
return "";
|
|
163
159
|
const replacedPhone = phone.replace(/[a-zA-Z]/g, "");
|
|
164
|
-
if (replacedPhone.length === 1 && replacedPhone !== "+")
|
|
160
|
+
if (replacedPhone.length === 1 && replacedPhone !== "+")
|
|
165
161
|
return `+${replacedPhone}`;
|
|
166
|
-
}
|
|
167
162
|
const phoneNumber = parsePhoneNumberFromString(replacedPhone);
|
|
168
163
|
return phoneNumber ? phoneNumber.formatInternational() : replacedPhone;
|
|
169
164
|
}
|
|
170
165
|
|
|
171
166
|
function snakelizeKeys(prop) {
|
|
172
|
-
if (Array.isArray(prop))
|
|
167
|
+
if (Array.isArray(prop))
|
|
173
168
|
return prop.map((item) => snakelizeKeys(item));
|
|
174
|
-
}
|
|
175
169
|
if (prop !== null && prop !== void 0 && prop.constructor === Object) {
|
|
176
170
|
return Object.keys(prop).reduce(
|
|
177
171
|
(accum, current) => ({
|
|
@@ -200,27 +194,21 @@ function unformatNumber(value) {
|
|
|
200
194
|
const commasCount = (string.match(/,/g) || []).length;
|
|
201
195
|
if (!Number.isNaN(Number(string)))
|
|
202
196
|
return Number(string);
|
|
203
|
-
if (hasSpace && hasComma && commaIndex > spaceIndex)
|
|
197
|
+
if (hasSpace && hasComma && commaIndex > spaceIndex)
|
|
204
198
|
locale = LOCALE_RU;
|
|
205
|
-
|
|
206
|
-
if (hasSpace && !hasComma && !hasDot) {
|
|
199
|
+
if (hasSpace && !hasComma && !hasDot)
|
|
207
200
|
locale = LOCALE_RU;
|
|
208
|
-
|
|
209
|
-
if (hasComma && hasDot && dotIndex > commaIndex) {
|
|
201
|
+
if (hasComma && hasDot && dotIndex > commaIndex)
|
|
210
202
|
locale = LOCALE_EN;
|
|
211
|
-
|
|
212
|
-
if (hasComma && !hasSpace && !hasDot && commasCount > 1) {
|
|
203
|
+
if (hasComma && !hasSpace && !hasDot && commasCount > 1)
|
|
213
204
|
locale = LOCALE_EN;
|
|
214
|
-
}
|
|
215
205
|
if (commasCount === 1 && !hasSpace && !hasDot) {
|
|
216
206
|
locale = string.length - 1 - commaIndex === 3 ? LOCALE_EN : LOCALE_RU;
|
|
217
207
|
}
|
|
218
|
-
if (locale === LOCALE_RU)
|
|
208
|
+
if (locale === LOCALE_RU)
|
|
219
209
|
return Number(string.replaceAll(" ", "").replace(",", "."));
|
|
220
|
-
|
|
221
|
-
if (locale === LOCALE_EN) {
|
|
210
|
+
if (locale === LOCALE_EN)
|
|
222
211
|
return Number(string.replaceAll(",", ""));
|
|
223
|
-
}
|
|
224
212
|
return value;
|
|
225
213
|
}
|
|
226
214
|
|
|
@@ -229,9 +217,8 @@ function UiComponentsResolver(options = {}) {
|
|
|
229
217
|
return (name) => {
|
|
230
218
|
const componentName = prefix && name.startsWith(prefix) ? name.substring(prefix.length) : name;
|
|
231
219
|
const isUiComponent = componentName.startsWith("Ui");
|
|
232
|
-
if (isUiComponent)
|
|
220
|
+
if (isUiComponent)
|
|
233
221
|
return { name: componentName, from: "@karta.io/ui-components" };
|
|
234
|
-
}
|
|
235
222
|
};
|
|
236
223
|
}
|
|
237
224
|
|
|
@@ -239,9 +226,8 @@ function useAbortController(callback) {
|
|
|
239
226
|
let controller = null;
|
|
240
227
|
return {
|
|
241
228
|
async call(...args) {
|
|
242
|
-
if (controller)
|
|
229
|
+
if (controller)
|
|
243
230
|
controller.abort();
|
|
244
|
-
}
|
|
245
231
|
controller = new AbortController();
|
|
246
232
|
let response;
|
|
247
233
|
if (args.length > 0) {
|
|
@@ -281,11 +267,7 @@ function useAsyncMultiselect({
|
|
|
281
267
|
const page = ref(1);
|
|
282
268
|
const options = computed(() => [...items.value.values()]);
|
|
283
269
|
const hasNextPage = computed(() => count.value > items.value.size);
|
|
284
|
-
const {
|
|
285
|
-
call: apiMethodWAC,
|
|
286
|
-
abort,
|
|
287
|
-
isAborted
|
|
288
|
-
} = useAbortController(apiMethod);
|
|
270
|
+
const { call: apiMethodWAC, abort, isAborted } = useAbortController(apiMethod);
|
|
289
271
|
const handleSearch = async (value) => {
|
|
290
272
|
if (search.value === value)
|
|
291
273
|
return;
|
|
@@ -303,12 +285,10 @@ function useAsyncMultiselect({
|
|
|
303
285
|
});
|
|
304
286
|
count.value = itemsCount;
|
|
305
287
|
if (isSearch) {
|
|
306
|
-
const cashedMapItems = selectedValues.value.map(
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
]
|
|
311
|
-
);
|
|
288
|
+
const cashedMapItems = selectedValues.value.map((selectedValue) => [
|
|
289
|
+
selectedValue,
|
|
290
|
+
items.value.get(selectedValue)
|
|
291
|
+
]);
|
|
312
292
|
items.value = new Map([...cashedMapItems]);
|
|
313
293
|
}
|
|
314
294
|
const resultsForMap = results.map(mapResultCallback);
|
|
@@ -352,11 +332,7 @@ function useAsyncSelect({
|
|
|
352
332
|
const page = ref(1);
|
|
353
333
|
const options = computed(() => [...items.value.values()]);
|
|
354
334
|
const hasNextPage = computed(() => count.value > items.value.size);
|
|
355
|
-
const {
|
|
356
|
-
call: apiMethodWAC,
|
|
357
|
-
abort,
|
|
358
|
-
isAborted
|
|
359
|
-
} = useAbortController(apiMethod);
|
|
335
|
+
const { call: apiMethodWAC, abort, isAborted } = useAbortController(apiMethod);
|
|
360
336
|
const handleSearch = async (value) => {
|
|
361
337
|
if (search.value === value)
|
|
362
338
|
return;
|
|
@@ -373,9 +349,8 @@ function useAsyncSelect({
|
|
|
373
349
|
...params
|
|
374
350
|
});
|
|
375
351
|
count.value = itemsCount;
|
|
376
|
-
if (isSearch)
|
|
352
|
+
if (isSearch)
|
|
377
353
|
items.value = /* @__PURE__ */ new Map();
|
|
378
|
-
}
|
|
379
354
|
const resultsForMap = results.map(mapResultCallback);
|
|
380
355
|
items.value = new Map([...items.value, ...resultsForMap]);
|
|
381
356
|
page.value += 1;
|
|
@@ -404,23 +379,19 @@ function useAsyncSelect({
|
|
|
404
379
|
};
|
|
405
380
|
}
|
|
406
381
|
|
|
407
|
-
|
|
382
|
+
function _bem(block, blockSuffix, element, modifier, modifierValue) {
|
|
408
383
|
let cls = block;
|
|
409
|
-
if (blockSuffix)
|
|
384
|
+
if (blockSuffix)
|
|
410
385
|
cls += `-${blockSuffix}`;
|
|
411
|
-
|
|
412
|
-
if (element) {
|
|
386
|
+
if (element)
|
|
413
387
|
cls += `__${element}`;
|
|
414
|
-
|
|
415
|
-
if (modifier) {
|
|
388
|
+
if (modifier)
|
|
416
389
|
cls += `_${modifier}`;
|
|
417
|
-
|
|
418
|
-
if (modifierValue) {
|
|
390
|
+
if (modifierValue)
|
|
419
391
|
cls += `_${modifierValue}`;
|
|
420
|
-
}
|
|
421
392
|
return cls;
|
|
422
|
-
}
|
|
423
|
-
|
|
393
|
+
}
|
|
394
|
+
function useClassName(block) {
|
|
424
395
|
const b = (blockSuffix = "") => _bem(block, blockSuffix, "", "", "");
|
|
425
396
|
const e = (element) => element ? _bem(block, "", element, "", "") : "";
|
|
426
397
|
const m = (modifier, condition = true) => modifier && condition ? _bem(block, "", "", modifier, "") : "";
|
|
@@ -428,9 +399,8 @@ const useClassName = (block) => {
|
|
|
428
399
|
const mv = (modifier, modifierValue, condition = true) => modifier && modifierValue && condition ? _bem(block, "", "", modifier, modifierValue) : "";
|
|
429
400
|
const cssVar = (object) => {
|
|
430
401
|
const styles = {};
|
|
431
|
-
for (const key in object)
|
|
402
|
+
for (const key in object)
|
|
432
403
|
styles[`--${block}-${key}`] = object[key];
|
|
433
|
-
}
|
|
434
404
|
return styles;
|
|
435
405
|
};
|
|
436
406
|
const cssVarName = (name) => `--${block}-${name}`;
|
|
@@ -444,7 +414,7 @@ const useClassName = (block) => {
|
|
|
444
414
|
cssVar,
|
|
445
415
|
cssVarName
|
|
446
416
|
};
|
|
447
|
-
}
|
|
417
|
+
}
|
|
448
418
|
|
|
449
419
|
dayjs.extend(utc);
|
|
450
420
|
dayjs.extend(tz);
|
|
@@ -455,21 +425,23 @@ function useDayjs(timezone) {
|
|
|
455
425
|
dayjs.updateLocale("en", {
|
|
456
426
|
weekStart: 1
|
|
457
427
|
});
|
|
458
|
-
if (!timezone)
|
|
428
|
+
if (!timezone)
|
|
459
429
|
return dayjs;
|
|
460
|
-
}
|
|
461
430
|
const dayjsExtended = (date, format, locale, strict) => dayjs(date, format, locale, strict).tz(timezone);
|
|
462
431
|
return dayjsExtended;
|
|
463
432
|
}
|
|
464
433
|
|
|
465
434
|
function parseVersion(version) {
|
|
466
435
|
if (typeof version !== "string" && typeof version !== "number") {
|
|
467
|
-
throw new TypeError(
|
|
468
|
-
"Browser version must be type of string, number or negative boolean"
|
|
469
|
-
);
|
|
436
|
+
throw new TypeError("Browser version must be type of string, number or negative boolean");
|
|
470
437
|
}
|
|
471
438
|
const [major, minor = 0, patch = 0, build = 0] = typeof version === "string" ? version.split(".").map(Number) : [version];
|
|
472
|
-
return {
|
|
439
|
+
return {
|
|
440
|
+
major,
|
|
441
|
+
minor,
|
|
442
|
+
patch,
|
|
443
|
+
build
|
|
444
|
+
};
|
|
473
445
|
}
|
|
474
446
|
function isVersionLower(minimum, target) {
|
|
475
447
|
for (const k of ["major", "minor", "patch"]) {
|
|
@@ -514,7 +486,7 @@ function isEnabled(options) {
|
|
|
514
486
|
}
|
|
515
487
|
const isNode = typeof process !== "undefined" && process.versions != null && process.versions.node != null;
|
|
516
488
|
if (isNode) {
|
|
517
|
-
const debug = process.env
|
|
489
|
+
const debug = process.env.NODE_DEBUG;
|
|
518
490
|
if (debug === "true")
|
|
519
491
|
return true;
|
|
520
492
|
if (debug === "false")
|
|
@@ -536,34 +508,48 @@ function validatePhone(rule, value) {
|
|
|
536
508
|
return phoneNumber ? phoneNumber.isValid() : false;
|
|
537
509
|
}
|
|
538
510
|
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
}
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
}
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
}
|
|
511
|
+
function isRequired(value = true, message = "This field is required") {
|
|
512
|
+
return {
|
|
513
|
+
required: value,
|
|
514
|
+
message
|
|
515
|
+
};
|
|
516
|
+
}
|
|
517
|
+
function isMax(value = 255, message) {
|
|
518
|
+
return {
|
|
519
|
+
max: value,
|
|
520
|
+
message: message ?? `Length must be no more than ${value} characters`
|
|
521
|
+
};
|
|
522
|
+
}
|
|
523
|
+
function isMin(value = 3, message) {
|
|
524
|
+
return {
|
|
525
|
+
min: value,
|
|
526
|
+
message: message ?? `Length must be at least ${value} characters`
|
|
527
|
+
};
|
|
528
|
+
}
|
|
529
|
+
function isTypeEmail(message = "Invalid format") {
|
|
530
|
+
return {
|
|
531
|
+
type: "email",
|
|
532
|
+
message
|
|
533
|
+
};
|
|
534
|
+
}
|
|
535
|
+
function isTypeUrl(message = "The url is invalid") {
|
|
536
|
+
return {
|
|
537
|
+
type: "url",
|
|
538
|
+
message
|
|
539
|
+
};
|
|
540
|
+
}
|
|
541
|
+
function isTypeNumber(value = 1, message) {
|
|
542
|
+
return {
|
|
543
|
+
type: "number",
|
|
544
|
+
min: value,
|
|
545
|
+
message: message ?? `Must be at least ${value}`
|
|
546
|
+
};
|
|
547
|
+
}
|
|
548
|
+
function isStrictLength(value = 3, message) {
|
|
549
|
+
return {
|
|
550
|
+
len: value,
|
|
551
|
+
message: message ?? `Length must be exactly ${value} characters`
|
|
552
|
+
};
|
|
553
|
+
}
|
|
568
554
|
|
|
569
555
|
export { UiComponentsResolver, camelizeKeys, createClassName, formatMoney, genLoadingTableRows, genRandomNumber, genUUID, getCardNumber, getCountryFromPhone, getPaginationLimit, getPaginationOffset, getPaginationPages, getPaginationParams, isElementIgnored, isEmptyObject, isMax, isMin, isRequired, isStrictLength, isTypeEmail, isTypeNumber, isTypeUrl, parsePhone, snakelizeKeys, unformatNumber, useAbortController, useAsyncMultiselect, useAsyncSelect, useClassName, useDayjs, useDetectBrowser, useLogger, validateNumber, validatePhone };
|
package/package.json
CHANGED
|
@@ -1,11 +1,12 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@karta.io/utils",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.34.0-alpha.1",
|
|
4
4
|
"description": "karta.io utils for admin and application",
|
|
5
5
|
"author": "Vitaly Blokhin <karambafe@gmail.com>",
|
|
6
6
|
"homepage": "",
|
|
7
7
|
"license": "MIT",
|
|
8
8
|
"sideEffects": false,
|
|
9
|
+
"type": "module",
|
|
9
10
|
"exports": {
|
|
10
11
|
".": {
|
|
11
12
|
"require": "./dist/index.cjs",
|
|
@@ -20,34 +21,36 @@
|
|
|
20
21
|
"dist"
|
|
21
22
|
],
|
|
22
23
|
"peerDependencies": {
|
|
23
|
-
"vue": "3.
|
|
24
|
+
"vue": "3.3.x"
|
|
24
25
|
},
|
|
25
26
|
"dependencies": {
|
|
26
|
-
"@karta.io/common-data": "^0.
|
|
27
|
+
"@karta.io/common-data": "^0.34.0-alpha.1",
|
|
27
28
|
"@vueuse/core": "9.13.0",
|
|
28
29
|
"async-validator": "4.2.5",
|
|
29
|
-
"dayjs": "1.11.
|
|
30
|
+
"dayjs": "1.11.8",
|
|
30
31
|
"detect-browser": "5.3.0",
|
|
31
|
-
"libphonenumber-js": "1.
|
|
32
|
+
"libphonenumber-js": "1.10.36",
|
|
32
33
|
"lodash": "4.17.21",
|
|
33
34
|
"logdown": "3.3.1"
|
|
34
35
|
},
|
|
35
36
|
"devDependencies": {
|
|
36
37
|
"@qvant/prettier-config": "0.1.0",
|
|
37
|
-
"eslint": "
|
|
38
|
+
"@typescript-eslint/eslint-plugin": "5.60.1",
|
|
39
|
+
"@typescript-eslint/parser": "5.60.1",
|
|
40
|
+
"eslint": "8.43.0",
|
|
38
41
|
"eslint-config-airbnb-base": "15.0.0",
|
|
39
|
-
"eslint-plugin-import": "2.
|
|
40
|
-
"prettier": "2.8.
|
|
41
|
-
"typescript": "
|
|
42
|
-
"unbuild": "1.
|
|
43
|
-
"vitest": "0.
|
|
44
|
-
"vue": "3.
|
|
42
|
+
"eslint-plugin-import": "2.27.5",
|
|
43
|
+
"prettier": "2.8.8",
|
|
44
|
+
"typescript": "5.0.4",
|
|
45
|
+
"unbuild": "1.2.1",
|
|
46
|
+
"vitest": "0.32.2",
|
|
47
|
+
"vue": "3.3.4"
|
|
45
48
|
},
|
|
46
49
|
"scripts": {
|
|
47
50
|
"dev": "vitest",
|
|
48
51
|
"build": "unbuild",
|
|
49
|
-
"lint": "eslint \"**/*.{ts,js}\"
|
|
50
|
-
"lint:fix": "eslint --fix \"**/*.{ts,js}\"
|
|
52
|
+
"lint": "eslint \"**/*.{ts,js}\"",
|
|
53
|
+
"lint:fix": "eslint --fix \"**/*.{ts,js}\"",
|
|
51
54
|
"test": "pnpm lint && vitest run",
|
|
52
55
|
"prettier": "prettier --check --ignore-unknown \"**/*\"",
|
|
53
56
|
"prettier:fix": "prettier --write --ignore-unknown \"**/*\"",
|