dlzn-ui 1.13.0 → 1.15.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +5 -4
- package/utils/boolean.d.ts +10 -0
- package/utils/boolean.mjs +14 -0
- package/utils/index.d.ts +1 -0
- package/utils/index.mjs +5 -4
- package/utils/number.d.ts +7 -2
- package/utils/number.mjs +24 -2
- package/utils/string.d.ts +8 -3
- package/utils/string.mjs +4 -1
- package/utils/tool.d.ts +3 -4
- /package/{eslint.config.mjs → eslint-config.mjs} +0 -0
- /package/{prettier.config.mjs → prettier-config.mjs} +0 -0
- /package/{stylelint.config.mjs → stylelint-config.mjs} +0 -0
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"dependencies": {
|
|
3
|
+
"@types/file-saver": "^2.0.7",
|
|
3
4
|
"crypto-js": "^4.2.0",
|
|
4
5
|
"file-saver": "^2.0.5"
|
|
5
6
|
},
|
|
@@ -13,9 +14,9 @@
|
|
|
13
14
|
"import": "./const/index.mjs",
|
|
14
15
|
"types": "./const/index.d.ts"
|
|
15
16
|
},
|
|
16
|
-
"./eslint
|
|
17
|
-
"./prettier
|
|
18
|
-
"./stylelint
|
|
17
|
+
"./eslint-config": "./eslint-config.mjs",
|
|
18
|
+
"./prettier-config": "./prettier-config.mjs",
|
|
19
|
+
"./stylelint-config": "./stylelint-config.mjs",
|
|
19
20
|
"./utils": {
|
|
20
21
|
"import": "./utils/index.mjs",
|
|
21
22
|
"types": "./utils/index.d.ts"
|
|
@@ -57,5 +58,5 @@
|
|
|
57
58
|
"**/*.css"
|
|
58
59
|
],
|
|
59
60
|
"type": "module",
|
|
60
|
-
"version": "1.
|
|
61
|
+
"version": "1.15.0"
|
|
61
62
|
}
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @description: 判断是否为空值,一般用于表单填写时的判断
|
|
3
|
+
* @example 0 和 false 是合法值
|
|
4
|
+
* @example 空格不是合法值
|
|
5
|
+
*/
|
|
6
|
+
export declare function isFalsy(val: any): val is '' | null | undefined;
|
|
7
|
+
/**
|
|
8
|
+
* @description: 判断是否为有效的数字字符串
|
|
9
|
+
*/
|
|
10
|
+
export declare function isValidNumberString(val: any): val is string;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import { validNumberStringReg as e } from "../const/others.mjs";
|
|
2
|
+
//#region src/utils/boolean.ts
|
|
3
|
+
function t(e) {
|
|
4
|
+
return [
|
|
5
|
+
"",
|
|
6
|
+
null,
|
|
7
|
+
void 0
|
|
8
|
+
].includes(e) || typeof e == "string" && e.trim() === "";
|
|
9
|
+
}
|
|
10
|
+
function n(t) {
|
|
11
|
+
return typeof t == "string" && e.test(t);
|
|
12
|
+
}
|
|
13
|
+
//#endregion
|
|
14
|
+
export { t as isFalsy, n as isValidNumberString };
|
package/utils/index.d.ts
CHANGED
package/utils/index.mjs
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
1
|
+
import { isFalsy as e, isValidNumberString as t } from "./boolean.mjs";
|
|
2
|
+
import { formatNumber as n, formatSecondsToChinese as r } from "./number.mjs";
|
|
3
|
+
import { getFilenameFromUrl as i, queryStringToObject as a, stringDisplay as o } from "./string.mjs";
|
|
4
|
+
import { aesDecrypt as s, aesEncrypt as c, saveAs as l } from "./tool.mjs";
|
|
5
|
+
export { s as aesDecrypt, c as aesEncrypt, n as formatNumber, r as formatSecondsToChinese, i as getFilenameFromUrl, e as isFalsy, t as isValidNumberString, a as queryStringToObject, l as saveAs, o as stringDisplay };
|
package/utils/number.d.ts
CHANGED
|
@@ -1,7 +1,12 @@
|
|
|
1
|
+
type FormatNumberConfig = ConstructorParameters<typeof Intl.NumberFormat>[1] & {
|
|
2
|
+
roundingMode?: 'ceil' | 'expand' | 'floor' | 'halfCeil' | 'halfEven' | 'halfExpand' | 'halfFloor' | 'halfTrunc' | 'trunc';
|
|
3
|
+
trailingZeroDisplay?: 'auto' | 'stripIfInteger';
|
|
4
|
+
};
|
|
5
|
+
export declare function formatNumber(n: any, config?: FormatNumberConfig): string;
|
|
1
6
|
/**
|
|
2
7
|
* @description: 将秒数转换为中文
|
|
3
8
|
* @param {number} seconds
|
|
4
9
|
* @return {string}
|
|
5
10
|
*/
|
|
6
|
-
declare function formatSecondsToChinese(seconds: number): string;
|
|
7
|
-
export {
|
|
11
|
+
export declare function formatSecondsToChinese(seconds: number): string;
|
|
12
|
+
export {};
|
package/utils/number.mjs
CHANGED
|
@@ -1,5 +1,27 @@
|
|
|
1
|
+
import { isValidNumberString as e } from "./boolean.mjs";
|
|
1
2
|
//#region src/utils/number.ts
|
|
2
|
-
function
|
|
3
|
+
function t(t, n) {
|
|
4
|
+
if (typeof t != "number" && typeof t != "string" || typeof t == "string" && e(t) === !1 || typeof t == "number" && Number.isFinite(t) === !1) return "";
|
|
5
|
+
let r = Number(t), i = {
|
|
6
|
+
currency: "CNY",
|
|
7
|
+
currencyDisplay: "symbol",
|
|
8
|
+
localeMatcher: "lookup",
|
|
9
|
+
maximumFractionDigits: 2,
|
|
10
|
+
minimumFractionDigits: 0,
|
|
11
|
+
notation: "standard",
|
|
12
|
+
numberingSystem: "latn",
|
|
13
|
+
style: "decimal",
|
|
14
|
+
trailingZeroDisplay: "stripIfInteger",
|
|
15
|
+
useGrouping: !0,
|
|
16
|
+
...n ?? {}
|
|
17
|
+
};
|
|
18
|
+
try {
|
|
19
|
+
return new Intl.NumberFormat("zh-CN", i).format(r);
|
|
20
|
+
} catch (e) {
|
|
21
|
+
return console.error(e?.message ?? "格式化数字失败"), String(r);
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
function n(e) {
|
|
3
25
|
let t = "", n = Math.floor(e / 3600);
|
|
4
26
|
n > 0 && (t += `${n}时`);
|
|
5
27
|
let r = Math.floor(e % 3600 / 60);
|
|
@@ -8,4 +30,4 @@ function e(e) {
|
|
|
8
30
|
return i > 0 && (t += `${i}秒`), t;
|
|
9
31
|
}
|
|
10
32
|
//#endregion
|
|
11
|
-
export {
|
|
33
|
+
export { t as formatNumber, n as formatSecondsToChinese };
|
package/utils/string.d.ts
CHANGED
|
@@ -4,6 +4,11 @@
|
|
|
4
4
|
* @param {boolean} withExt 是否包含扩展名
|
|
5
5
|
* @return {string}
|
|
6
6
|
*/
|
|
7
|
-
declare function getFilenameFromUrl(url: string, withExt?: boolean): string;
|
|
8
|
-
declare function queryStringToObject(queryString: string): Record<string, any>;
|
|
9
|
-
|
|
7
|
+
export declare function getFilenameFromUrl(url: string, withExt?: boolean): string;
|
|
8
|
+
export declare function queryStringToObject(queryString: string): Record<string, any>;
|
|
9
|
+
/**
|
|
10
|
+
* @description: 将值转换为字符串,如果值为 null 或 undefined,则返回空字符串
|
|
11
|
+
* @example String(123n) -> '123' BigInt
|
|
12
|
+
* @return {string}
|
|
13
|
+
*/
|
|
14
|
+
export declare function stringDisplay(val: any): string;
|
package/utils/string.mjs
CHANGED
|
@@ -10,5 +10,8 @@ function e(e, t = !1) {
|
|
|
10
10
|
function t(e) {
|
|
11
11
|
return Object.fromEntries(new URLSearchParams(e));
|
|
12
12
|
}
|
|
13
|
+
function n(e) {
|
|
14
|
+
return [null, void 0].includes(e) ? "" : String(e);
|
|
15
|
+
}
|
|
13
16
|
//#endregion
|
|
14
|
-
export { e as getFilenameFromUrl, t as queryStringToObject };
|
|
17
|
+
export { e as getFilenameFromUrl, t as queryStringToObject, n as stringDisplay };
|
package/utils/tool.d.ts
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { default as FileSaver } from 'file-saver';
|
|
2
|
-
declare function aesDecrypt(word: string, keyWord: string): Promise<string>;
|
|
3
|
-
declare function aesEncrypt(word: string, keyWord: string): Promise<string>;
|
|
4
|
-
declare function saveAs(arg1: Parameters<typeof FileSaver.saveAs>[0], arg2?: Parameters<typeof FileSaver.saveAs>[1], arg3?: FileSaver.FileSaverOptions): Promise<void>;
|
|
5
|
-
export { aesDecrypt, aesEncrypt, saveAs };
|
|
2
|
+
export declare function aesDecrypt(word: string, keyWord: string): Promise<string>;
|
|
3
|
+
export declare function aesEncrypt(word: string, keyWord: string): Promise<string>;
|
|
4
|
+
export declare function saveAs(arg1: Parameters<typeof FileSaver.saveAs>[0], arg2?: Parameters<typeof FileSaver.saveAs>[1], arg3?: FileSaver.FileSaverOptions): Promise<void>;
|
|
File without changes
|
|
File without changes
|
|
File without changes
|