@pisell/utils 3.0.5 → 3.0.6
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/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/es/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +11 -0
- package/es/arrayUtils.d.ts +76 -1
- package/es/arrayUtils.js +103 -24
- package/es/common/stateHelper.d.ts +22 -0
- package/es/common/stateHelper.js +23 -0
- package/es/common/types.d.ts +31 -0
- package/es/componentStorage.d.ts +38 -0
- package/es/componentStorage.js +106 -0
- package/es/constants/index.js +7 -9
- package/es/date.d.ts +6 -3
- package/es/date.js +36 -53
- package/es/document.d.ts +6 -3
- package/es/document.js +43 -67
- package/es/escPosPrinter/EscPosPrinter.js +353 -490
- package/es/escPosPrinter/index.d.ts +9 -9
- package/es/escPosPrinter/index.js +37 -52
- package/es/format.d.ts +12 -11
- package/es/format.js +90 -112
- package/es/image.d.ts +13 -10
- package/es/image.js +48 -60
- package/es/index.d.ts +39 -18
- package/es/index.js +40 -29
- package/es/jsBridge/index.d.ts +14 -106
- package/es/jsBridge/index.js +57 -40
- package/es/jsBridge/regDeviceApi.js +87 -126
- package/es/jsBridge/types.d.ts +129 -0
- package/es/locales.d.ts +11 -11
- package/es/locales.js +79 -69
- package/es/log.d.ts +11 -6
- package/es/log.js +37 -59
- package/es/miniRedux.d.ts +20 -13
- package/es/miniRedux.js +42 -71
- package/es/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/es/number-input/hooks/useNumberInputState.js +72 -0
- package/es/number-input/types.d.ts +96 -0
- package/es/number-input/utils/formatter.d.ts +56 -0
- package/es/number-input/utils/formatter.js +56 -0
- package/es/number-input/utils/validation.d.ts +32 -0
- package/es/number-input/utils/validation.js +52 -0
- package/es/otherUtils.d.ts +51 -0
- package/es/otherUtils.js +71 -129
- package/es/platform.d.ts +12 -9
- package/es/platform.js +61 -85
- package/es/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/es/select/hooks/useDebouncedSearch.js +41 -0
- package/es/select/hooks/useSelectState.d.ts +19 -0
- package/es/select/hooks/useSelectState.js +60 -0
- package/es/select/index.d.ts +7 -0
- package/es/select/types.d.ts +256 -0
- package/es/select/utils/filterOptions.d.ts +23 -0
- package/es/select/utils/filterOptions.js +29 -0
- package/es/select/utils/helpers.d.ts +43 -0
- package/es/select/utils/helpers.js +51 -0
- package/es/select/utils/index.d.ts +4 -0
- package/es/select/utils/sortOptions.d.ts +13 -0
- package/es/select/utils/sortOptions.js +20 -0
- package/es/select/utils/tagAggregation.d.ts +25 -0
- package/es/select/utils/tagAggregation.js +35 -0
- package/es/text-input/hooks/useTextInputState.d.ts +28 -0
- package/es/text-input/hooks/useTextInputState.js +70 -0
- package/es/text-input/types.d.ts +56 -0
- package/es/text-input/utils/validation.d.ts +28 -0
- package/es/text-input/utils/validation.js +51 -0
- package/es/typeUtils.d.ts +11 -8
- package/es/typeUtils.js +61 -84
- package/es/walletValidity.d.ts +57 -0
- package/es/walletValidity.js +404 -460
- package/es/weighing.d.ts +65 -0
- package/es/weighing.js +96 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js +27 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/defineProperty.js +12 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js +25 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPrimitive.js +14 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/toPropertyKey.js +9 -0
- package/lib/_virtual/_@oxc-project_runtime@0.122.0/helpers/typeof.js +16 -0
- package/lib/_virtual/_rolldown/runtime.js +23 -0
- package/lib/arrayUtils.d.ts +76 -1
- package/lib/arrayUtils.js +102 -37
- package/lib/common/stateHelper.d.ts +22 -0
- package/lib/common/stateHelper.js +23 -0
- package/lib/common/types.d.ts +31 -0
- package/lib/componentStorage.d.ts +38 -0
- package/lib/componentStorage.js +114 -0
- package/lib/constants/index.js +7 -36
- package/lib/date.d.ts +6 -3
- package/lib/date.js +43 -65
- package/lib/document.d.ts +6 -3
- package/lib/document.js +46 -62
- package/lib/escPosPrinter/EscPosPrinter.js +327 -403
- package/lib/escPosPrinter/index.d.ts +9 -9
- package/lib/escPosPrinter/index.js +38 -84
- package/lib/format.d.ts +12 -11
- package/lib/format.js +91 -93
- package/lib/image.d.ts +13 -10
- package/lib/image.js +48 -74
- package/lib/index.d.ts +39 -18
- package/lib/index.js +137 -68
- package/lib/jsBridge/index.d.ts +14 -106
- package/lib/jsBridge/index.js +60 -60
- package/lib/jsBridge/regDeviceApi.js +86 -133
- package/lib/jsBridge/types.d.ts +129 -0
- package/lib/locales.d.ts +11 -11
- package/lib/locales.js +79 -63
- package/lib/log.d.ts +11 -6
- package/lib/log.js +37 -61
- package/lib/miniRedux.d.ts +20 -13
- package/lib/miniRedux.js +43 -91
- package/lib/number-input/hooks/useNumberInputState.d.ts +29 -0
- package/lib/number-input/hooks/useNumberInputState.js +73 -0
- package/lib/number-input/types.d.ts +96 -0
- package/lib/number-input/utils/formatter.d.ts +56 -0
- package/lib/number-input/utils/formatter.js +58 -0
- package/lib/number-input/utils/validation.d.ts +32 -0
- package/lib/number-input/utils/validation.js +52 -0
- package/lib/otherUtils.d.ts +51 -0
- package/lib/otherUtils.js +86 -98
- package/lib/platform.d.ts +12 -9
- package/lib/platform.js +68 -123
- package/lib/select/hooks/useDebouncedSearch.d.ts +23 -0
- package/lib/select/hooks/useDebouncedSearch.js +42 -0
- package/lib/select/hooks/useSelectState.d.ts +19 -0
- package/lib/select/hooks/useSelectState.js +62 -0
- package/lib/select/index.d.ts +7 -0
- package/lib/select/types.d.ts +256 -0
- package/lib/select/utils/filterOptions.d.ts +23 -0
- package/lib/select/utils/filterOptions.js +30 -0
- package/lib/select/utils/helpers.d.ts +43 -0
- package/lib/select/utils/helpers.js +55 -0
- package/lib/select/utils/index.d.ts +4 -0
- package/lib/select/utils/sortOptions.d.ts +13 -0
- package/lib/select/utils/sortOptions.js +20 -0
- package/lib/select/utils/tagAggregation.d.ts +25 -0
- package/lib/select/utils/tagAggregation.js +35 -0
- package/lib/text-input/hooks/useTextInputState.d.ts +28 -0
- package/lib/text-input/hooks/useTextInputState.js +71 -0
- package/lib/text-input/types.d.ts +56 -0
- package/lib/text-input/utils/validation.d.ts +28 -0
- package/lib/text-input/utils/validation.js +51 -0
- package/lib/typeUtils.d.ts +11 -8
- package/lib/typeUtils.js +68 -73
- package/lib/walletValidity.d.ts +57 -0
- package/lib/walletValidity.js +420 -323
- package/lib/weighing.d.ts +65 -0
- package/lib/weighing.js +114 -0
- package/package.json +1 -1
- package/es/firebase/config/index.d.ts +0 -13
- package/es/firebase/config/index.js +0 -54
- package/es/firebase/index.d.ts +0 -28
- package/es/firebase/index.js +0 -232
- package/lib/firebase/config/index.d.ts +0 -13
- package/lib/firebase/config/index.js +0 -79
- package/lib/firebase/index.d.ts +0 -28
- package/lib/firebase/index.js +0 -180
|
@@ -0,0 +1,114 @@
|
|
|
1
|
+
const require_objectSpread2 = require("./_virtual/_@oxc-project_runtime@0.122.0/helpers/objectSpread2.js");
|
|
2
|
+
const require_typeUtils = require("./typeUtils.js");
|
|
3
|
+
//#region src/componentStorage.ts
|
|
4
|
+
/**
|
|
5
|
+
* 组件级 localStorage 存储:列设置、列显隐等。
|
|
6
|
+
* 供 pisellDataSourceContainer、pisellRecordBoard 等复用,key 含 pathname 与 memory_key 以区分页面。
|
|
7
|
+
*/
|
|
8
|
+
/** 生成存储 key 的路径后缀:pathname 或 pathname#memory_key(来自 URL memory_key 参数) */
|
|
9
|
+
function getStorageKeySuffix() {
|
|
10
|
+
if (typeof window === "undefined" || typeof window.location === "undefined") return "/";
|
|
11
|
+
const { pathname, search } = window.location;
|
|
12
|
+
const appendPath = pathname || "/";
|
|
13
|
+
let memoryKey = "";
|
|
14
|
+
try {
|
|
15
|
+
const mk = new URLSearchParams(search || "").get("memory_key");
|
|
16
|
+
if (mk && mk.trim() !== "") memoryKey = mk.trim();
|
|
17
|
+
} catch (_unused) {}
|
|
18
|
+
return memoryKey ? `${appendPath}#${memoryKey}` : appendPath;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* 生成组件实例的存储 key。
|
|
22
|
+
* @param componentId 组件实例 id(如 __id)
|
|
23
|
+
* @param prefix 前缀,如 'table-setting'、'record-board-column-visibility'
|
|
24
|
+
*/
|
|
25
|
+
function getComponentStorageKey(componentId, prefix) {
|
|
26
|
+
if (typeof window === "undefined" || typeof window.location === "undefined") return `${prefix}-${componentId}`;
|
|
27
|
+
return `${prefix}-${componentId}-${getStorageKeySuffix()}`;
|
|
28
|
+
}
|
|
29
|
+
function saveColumnSettingToLocal(params) {
|
|
30
|
+
const { componentId, columnSetting } = params;
|
|
31
|
+
if (!componentId) return;
|
|
32
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
33
|
+
const storageKey = getComponentStorageKey(componentId, "table-setting");
|
|
34
|
+
const data = {
|
|
35
|
+
column_setting: columnSetting,
|
|
36
|
+
updatedAt: Date.now()
|
|
37
|
+
};
|
|
38
|
+
try {
|
|
39
|
+
window.localStorage.setItem(storageKey, JSON.stringify(data));
|
|
40
|
+
} catch (_unused2) {}
|
|
41
|
+
}
|
|
42
|
+
function getColumnSettingFromLocal(componentId) {
|
|
43
|
+
if (!componentId) return null;
|
|
44
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
45
|
+
const storageKey = getComponentStorageKey(componentId, "table-setting");
|
|
46
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
47
|
+
if (raw && require_typeUtils.isJson(raw)) {
|
|
48
|
+
const data = JSON.parse(raw);
|
|
49
|
+
const arr = data === null || data === void 0 ? void 0 : data.column_setting;
|
|
50
|
+
return Array.isArray(arr) ? arr : null;
|
|
51
|
+
}
|
|
52
|
+
return null;
|
|
53
|
+
}
|
|
54
|
+
function clearColumnSettingFromLocal(componentId) {
|
|
55
|
+
if (!componentId) return;
|
|
56
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
57
|
+
const storageKey = getComponentStorageKey(componentId, "table-setting");
|
|
58
|
+
window.localStorage.removeItem(storageKey);
|
|
59
|
+
}
|
|
60
|
+
const RECORD_BOARD_VISIBILITY_PREFIX = "record-board-column-visibility";
|
|
61
|
+
function saveColumnVisibilityToLocal(params) {
|
|
62
|
+
const { componentId, columnVisibility, columnOrder } = params;
|
|
63
|
+
if (!componentId) return;
|
|
64
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
65
|
+
const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
|
|
66
|
+
const data = require_objectSpread2._objectSpread2(require_objectSpread2._objectSpread2({ column_visibility: columnVisibility }, columnOrder != null && { column_order: columnOrder }), {}, { updatedAt: Date.now() });
|
|
67
|
+
try {
|
|
68
|
+
window.localStorage.setItem(storageKey, JSON.stringify(data));
|
|
69
|
+
} catch (_unused3) {}
|
|
70
|
+
}
|
|
71
|
+
function getColumnVisibilityFromLocal(componentId) {
|
|
72
|
+
if (!componentId) return null;
|
|
73
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
74
|
+
const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
|
|
75
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
76
|
+
if (raw && require_typeUtils.isJson(raw)) {
|
|
77
|
+
const data = JSON.parse(raw);
|
|
78
|
+
const vis = data === null || data === void 0 ? void 0 : data.column_visibility;
|
|
79
|
+
return vis && typeof vis === "object" && vis !== null ? vis : null;
|
|
80
|
+
}
|
|
81
|
+
return null;
|
|
82
|
+
}
|
|
83
|
+
/** RecordBoard 列设置(显隐 + 顺序)从 localStorage 读取,用于列设置弹层拖拽排序与显隐持久化 */
|
|
84
|
+
function getRecordBoardColumnSettingFromLocal(componentId) {
|
|
85
|
+
if (!componentId) return null;
|
|
86
|
+
if (typeof window === "undefined" || !window.localStorage) return null;
|
|
87
|
+
const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
|
|
88
|
+
const raw = window.localStorage.getItem(storageKey);
|
|
89
|
+
if (raw && require_typeUtils.isJson(raw)) {
|
|
90
|
+
const data = JSON.parse(raw);
|
|
91
|
+
const vis = data === null || data === void 0 ? void 0 : data.column_visibility;
|
|
92
|
+
return {
|
|
93
|
+
columnVisibility: vis && typeof vis === "object" && vis !== null ? vis : {},
|
|
94
|
+
columnOrder: Array.isArray(data === null || data === void 0 ? void 0 : data.column_order) ? data.column_order : null
|
|
95
|
+
};
|
|
96
|
+
}
|
|
97
|
+
return null;
|
|
98
|
+
}
|
|
99
|
+
function clearColumnVisibilityFromLocal(componentId) {
|
|
100
|
+
if (!componentId) return;
|
|
101
|
+
if (typeof window === "undefined" || !window.localStorage) return;
|
|
102
|
+
const storageKey = getComponentStorageKey(componentId, RECORD_BOARD_VISIBILITY_PREFIX);
|
|
103
|
+
window.localStorage.removeItem(storageKey);
|
|
104
|
+
}
|
|
105
|
+
//#endregion
|
|
106
|
+
exports.clearColumnSettingFromLocal = clearColumnSettingFromLocal;
|
|
107
|
+
exports.clearColumnVisibilityFromLocal = clearColumnVisibilityFromLocal;
|
|
108
|
+
exports.getColumnSettingFromLocal = getColumnSettingFromLocal;
|
|
109
|
+
exports.getColumnVisibilityFromLocal = getColumnVisibilityFromLocal;
|
|
110
|
+
exports.getComponentStorageKey = getComponentStorageKey;
|
|
111
|
+
exports.getRecordBoardColumnSettingFromLocal = getRecordBoardColumnSettingFromLocal;
|
|
112
|
+
exports.getStorageKeySuffix = getStorageKeySuffix;
|
|
113
|
+
exports.saveColumnSettingToLocal = saveColumnSettingToLocal;
|
|
114
|
+
exports.saveColumnVisibilityToLocal = saveColumnVisibilityToLocal;
|
package/lib/constants/index.js
CHANGED
|
@@ -1,36 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
14
|
-
}
|
|
15
|
-
return to;
|
|
16
|
-
};
|
|
17
|
-
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
18
|
-
|
|
19
|
-
// src/constants/index.ts
|
|
20
|
-
var constants_exports = {};
|
|
21
|
-
__export(constants_exports, {
|
|
22
|
-
webHookApi: () => webHookApi
|
|
23
|
-
});
|
|
24
|
-
module.exports = __toCommonJS(constants_exports);
|
|
25
|
-
var webHookApi = {
|
|
26
|
-
warning_log: {
|
|
27
|
-
// 非生产环境共用一个url
|
|
28
|
-
test: "https://open.feishu.cn/open-apis/bot/v2/hook/985186a7-d939-4daf-9f30-3a3cc9c47d97",
|
|
29
|
-
// 生产环境
|
|
30
|
-
prod: "https://open.feishu.cn/open-apis/bot/v2/hook/887dfff9-2ccc-4513-87ff-a05d8cef953e"
|
|
31
|
-
}
|
|
32
|
-
};
|
|
33
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
34
|
-
0 && (module.exports = {
|
|
35
|
-
webHookApi
|
|
36
|
-
});
|
|
1
|
+
//#region src/constants/index.ts
|
|
2
|
+
const webHookApi = { warning_log: {
|
|
3
|
+
test: "https://open.feishu.cn/open-apis/bot/v2/hook/985186a7-d939-4daf-9f30-3a3cc9c47d97",
|
|
4
|
+
prod: "https://open.feishu.cn/open-apis/bot/v2/hook/887dfff9-2ccc-4513-87ff-a05d8cef953e"
|
|
5
|
+
} };
|
|
6
|
+
//#endregion
|
|
7
|
+
exports.webHookApi = webHookApi;
|
package/lib/date.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
//#region src/date.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* @title: 格式化日期
|
|
3
4
|
* @description:
|
|
@@ -7,7 +8,7 @@
|
|
|
7
8
|
* @Author: zhiwei.Wang
|
|
8
9
|
* @Date: 2023-07-21 10:49
|
|
9
10
|
*/
|
|
10
|
-
|
|
11
|
+
declare const formatDate: (date: string | Date, format?: string) => string;
|
|
11
12
|
/**
|
|
12
13
|
* @title: excel日期 转 js日期
|
|
13
14
|
* @description:
|
|
@@ -16,7 +17,7 @@ export declare const formatDate: (date: string | Date, format?: string) => strin
|
|
|
16
17
|
* @Author: zhiwei.Wang
|
|
17
18
|
* @Date: 2023-07-21 10:49
|
|
18
19
|
*/
|
|
19
|
-
|
|
20
|
+
declare const excelDateToJSDate: (excelDate: number) => string;
|
|
20
21
|
/**
|
|
21
22
|
* @title: js日期 转 excel日期
|
|
22
23
|
* @description:
|
|
@@ -25,4 +26,6 @@ export declare const excelDateToJSDate: (excelDate: number) => string;
|
|
|
25
26
|
* @Author: zhiwei.Wang
|
|
26
27
|
* @Date: 2023-07-21 10:49
|
|
27
28
|
*/
|
|
28
|
-
|
|
29
|
+
declare const jsDateToExcelDate: (jsDate: string) => number;
|
|
30
|
+
//#endregion
|
|
31
|
+
export { excelDateToJSDate, formatDate, jsDateToExcelDate };
|
package/lib/date.js
CHANGED
|
@@ -1,68 +1,46 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
const require_runtime = require("./_virtual/_rolldown/runtime.js");
|
|
2
|
+
let dayjs = require("dayjs");
|
|
3
|
+
dayjs = require_runtime.__toESM(dayjs);
|
|
4
|
+
//#region src/date.ts
|
|
5
|
+
const formatMaps = ["D MMM YYYY, hh:mma", "YYYY-MM-DD"];
|
|
6
|
+
/**
|
|
7
|
+
* @title: 格式化日期
|
|
8
|
+
* @description:
|
|
9
|
+
* @param {string} date
|
|
10
|
+
* @param {string} format
|
|
11
|
+
* @return {*}
|
|
12
|
+
* @Author: zhiwei.Wang
|
|
13
|
+
* @Date: 2023-07-21 10:49
|
|
14
|
+
*/
|
|
15
|
+
const formatDate = (date, format) => {
|
|
16
|
+
let _format = format || formatMaps[0];
|
|
17
|
+
if (!date) return date;
|
|
18
|
+
return (0, dayjs.default)(date).format(_format);
|
|
10
19
|
};
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
20
|
+
/**
|
|
21
|
+
* @title: excel日期 转 js日期
|
|
22
|
+
* @description:
|
|
23
|
+
* @param {number} excelDate
|
|
24
|
+
* @return {*}
|
|
25
|
+
* @Author: zhiwei.Wang
|
|
26
|
+
* @Date: 2023-07-21 10:49
|
|
27
|
+
*/
|
|
28
|
+
const excelDateToJSDate = (excelDate) => {
|
|
29
|
+
const dateOffset = (excelDate - 25569) * 864e5;
|
|
30
|
+
return formatDate(new Date(dateOffset), formatMaps[1]);
|
|
18
31
|
};
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
// src/date.ts
|
|
30
|
-
var date_exports = {};
|
|
31
|
-
__export(date_exports, {
|
|
32
|
-
excelDateToJSDate: () => excelDateToJSDate,
|
|
33
|
-
formatDate: () => formatDate,
|
|
34
|
-
jsDateToExcelDate: () => jsDateToExcelDate
|
|
35
|
-
});
|
|
36
|
-
module.exports = __toCommonJS(date_exports);
|
|
37
|
-
var import_dayjs = __toESM(require("dayjs"));
|
|
38
|
-
var formatMaps = [
|
|
39
|
-
// 19 Jul 2023, 09:00am
|
|
40
|
-
"D MMM YYYY, hh:mma",
|
|
41
|
-
// 2023-07-19
|
|
42
|
-
"YYYY-MM-DD"
|
|
43
|
-
];
|
|
44
|
-
var formatDate = (date, format) => {
|
|
45
|
-
let _format = format || formatMaps[0];
|
|
46
|
-
if (!date) {
|
|
47
|
-
return date;
|
|
48
|
-
}
|
|
49
|
-
return (0, import_dayjs.default)(date).format(_format);
|
|
32
|
+
/**
|
|
33
|
+
* @title: js日期 转 excel日期
|
|
34
|
+
* @description:
|
|
35
|
+
* @param {string} jsDate
|
|
36
|
+
* @return {*}
|
|
37
|
+
* @Author: zhiwei.Wang
|
|
38
|
+
* @Date: 2023-07-21 10:49
|
|
39
|
+
*/
|
|
40
|
+
const jsDateToExcelDate = (jsDate) => {
|
|
41
|
+
return (new Date(jsDate) - new Date(Date.UTC(1900, 0, 1))) / 864e5 + 25569;
|
|
50
42
|
};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
};
|
|
56
|
-
var jsDateToExcelDate = (jsDate) => {
|
|
57
|
-
const _jsDate = new Date(jsDate);
|
|
58
|
-
const excelStartDate = new Date(Date.UTC(1900, 0, 1));
|
|
59
|
-
const dateOffset = _jsDate - excelStartDate;
|
|
60
|
-
const excelDate = dateOffset / 864e5 + 25569;
|
|
61
|
-
return excelDate;
|
|
62
|
-
};
|
|
63
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
64
|
-
0 && (module.exports = {
|
|
65
|
-
excelDateToJSDate,
|
|
66
|
-
formatDate,
|
|
67
|
-
jsDateToExcelDate
|
|
68
|
-
});
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.excelDateToJSDate = excelDateToJSDate;
|
|
45
|
+
exports.formatDate = formatDate;
|
|
46
|
+
exports.jsDateToExcelDate = jsDateToExcelDate;
|
package/lib/document.d.ts
CHANGED
|
@@ -1,13 +1,16 @@
|
|
|
1
|
+
//#region src/document.d.ts
|
|
1
2
|
/**
|
|
2
3
|
* @Title: 设置主题
|
|
3
4
|
* @Describe: 传入字符串键值对
|
|
4
5
|
* @Author: Wzw
|
|
5
6
|
*/
|
|
6
|
-
|
|
7
|
-
|
|
7
|
+
declare const setTheme: (themes: {
|
|
8
|
+
[key: string]: string;
|
|
8
9
|
}) => void;
|
|
9
10
|
/**
|
|
10
11
|
* 复制到剪切板
|
|
11
12
|
* @param text
|
|
12
13
|
*/
|
|
13
|
-
|
|
14
|
+
declare const copyToClipboard: (text: string) => Promise<void>;
|
|
15
|
+
//#endregion
|
|
16
|
+
export { copyToClipboard, setTheme };
|
package/lib/document.js
CHANGED
|
@@ -1,64 +1,48 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
const require_asyncToGenerator = require("./_virtual/_@oxc-project_runtime@0.122.0/helpers/asyncToGenerator.js");
|
|
2
|
+
//#region src/document.ts
|
|
3
|
+
/**
|
|
4
|
+
* @Title: 设置主题
|
|
5
|
+
* @Describe: 传入字符串键值对
|
|
6
|
+
* @Author: Wzw
|
|
7
|
+
*/
|
|
8
|
+
const setTheme = (themes) => {
|
|
9
|
+
try {
|
|
10
|
+
let _themes = Object.entries(themes);
|
|
11
|
+
for (let item of _themes) document.documentElement.style.setProperty(item[0], item[1]);
|
|
12
|
+
} catch (err) {
|
|
13
|
+
console.error(err);
|
|
14
|
+
}
|
|
8
15
|
};
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
+
const httpCopyToClipboard = (text) => {
|
|
17
|
+
const textArea = document.createElement("textarea");
|
|
18
|
+
textArea.value = text;
|
|
19
|
+
textArea.style.position = "fixed";
|
|
20
|
+
textArea.style.top = "-10000px";
|
|
21
|
+
textArea.style.left = "-10000px";
|
|
22
|
+
document.body.appendChild(textArea);
|
|
23
|
+
textArea.focus();
|
|
24
|
+
textArea.select();
|
|
25
|
+
document.execCommand("copy");
|
|
26
|
+
document.body.removeChild(textArea);
|
|
16
27
|
};
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
textArea.value = text;
|
|
39
|
-
textArea.style.position = "fixed";
|
|
40
|
-
textArea.style.top = "-10000px";
|
|
41
|
-
textArea.style.left = "-10000px";
|
|
42
|
-
document.body.appendChild(textArea);
|
|
43
|
-
textArea.focus();
|
|
44
|
-
textArea.select();
|
|
45
|
-
document.execCommand("copy");
|
|
46
|
-
document.body.removeChild(textArea);
|
|
47
|
-
};
|
|
48
|
-
var copyToClipboard = async (text) => {
|
|
49
|
-
if (navigator.clipboard) {
|
|
50
|
-
try {
|
|
51
|
-
return await navigator.clipboard.writeText(text);
|
|
52
|
-
} catch (error) {
|
|
53
|
-
console.error(error);
|
|
54
|
-
return httpCopyToClipboard(text);
|
|
55
|
-
}
|
|
56
|
-
} else {
|
|
57
|
-
return httpCopyToClipboard(text);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
61
|
-
0 && (module.exports = {
|
|
62
|
-
copyToClipboard,
|
|
63
|
-
setTheme
|
|
64
|
-
});
|
|
28
|
+
/**
|
|
29
|
+
* 复制到剪切板
|
|
30
|
+
* @param text
|
|
31
|
+
*/
|
|
32
|
+
const copyToClipboard = function() {
|
|
33
|
+
var _ref = require_asyncToGenerator._asyncToGenerator(function* (text) {
|
|
34
|
+
if (navigator.clipboard) try {
|
|
35
|
+
return yield navigator.clipboard.writeText(text);
|
|
36
|
+
} catch (error) {
|
|
37
|
+
console.error(error);
|
|
38
|
+
return httpCopyToClipboard(text);
|
|
39
|
+
}
|
|
40
|
+
else return httpCopyToClipboard(text);
|
|
41
|
+
});
|
|
42
|
+
return function copyToClipboard(_x) {
|
|
43
|
+
return _ref.apply(this, arguments);
|
|
44
|
+
};
|
|
45
|
+
}();
|
|
46
|
+
//#endregion
|
|
47
|
+
exports.copyToClipboard = copyToClipboard;
|
|
48
|
+
exports.setTheme = setTheme;
|