@zero-library/common 2.2.9 → 2.2.11
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.js +42 -15
- package/dist/index.cjs.js.map +1 -1
- package/dist/index.d.mts +55 -10
- package/dist/index.d.ts +55 -10
- package/dist/index.esm.js +42 -16
- package/dist/index.esm.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -950,9 +950,7 @@ declare const getWebSocketUrl: (path: string, customHost?: string) => string;
|
|
|
950
950
|
* )
|
|
951
951
|
* // => { x: 1, y: 3 }
|
|
952
952
|
*/
|
|
953
|
-
declare
|
|
954
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
955
|
-
}): U;
|
|
953
|
+
declare const transform: <T extends object, U extends object>(source: T, fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U;
|
|
956
954
|
/**
|
|
957
955
|
* 批量对象转换函数
|
|
958
956
|
* @param sources - 源对象数组
|
|
@@ -963,9 +961,7 @@ declare function transform<T extends object, U extends object>(source: T, fieldM
|
|
|
963
961
|
* transforms([{ a: 1 }], { x: 'a' })
|
|
964
962
|
* // => [{ x: 1 }]
|
|
965
963
|
*/
|
|
966
|
-
declare
|
|
967
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
968
|
-
}): U[];
|
|
964
|
+
declare const transforms: <T extends object, U extends object>(sources: T[], fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U[];
|
|
969
965
|
/**
|
|
970
966
|
* 将数字金额转换为中文大写金额
|
|
971
967
|
*
|
|
@@ -1122,14 +1118,14 @@ declare const executeScript: (script: string, params: {
|
|
|
1122
1118
|
* @returns 加密后的字符串
|
|
1123
1119
|
* @throws 当密钥为空或加密过程失败时抛出错误
|
|
1124
1120
|
*/
|
|
1125
|
-
declare
|
|
1121
|
+
declare const aesEncrypt: <T = any>(data: T, key: string) => string;
|
|
1126
1122
|
/**
|
|
1127
1123
|
* AES 解密
|
|
1128
1124
|
* @param data - 加密后的字符串
|
|
1129
1125
|
* @param key - 解密密钥
|
|
1130
1126
|
* @returns 解密后的数据,解密失败时返回null
|
|
1131
1127
|
*/
|
|
1132
|
-
declare
|
|
1128
|
+
declare const aesDecrypt: <T = any>(data: string, key: string) => T | null;
|
|
1133
1129
|
type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
|
|
1134
1130
|
interface FormatSizeOptions {
|
|
1135
1131
|
/** 起始单位,默认 KB */
|
|
@@ -1166,7 +1162,7 @@ interface FormatSizeOptions {
|
|
|
1166
1162
|
* @remarks
|
|
1167
1163
|
* - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
|
|
1168
1164
|
*/
|
|
1169
|
-
declare
|
|
1165
|
+
declare const formatSize: (value: number | string, options?: FormatSizeOptions) => number | string;
|
|
1170
1166
|
/**
|
|
1171
1167
|
* Markdown转纯文本
|
|
1172
1168
|
* @param markdown - 原始 Markdown 内容
|
|
@@ -1176,6 +1172,55 @@ declare function formatSize(value: number | string, options?: FormatSizeOptions)
|
|
|
1176
1172
|
* markdownToText('## 标题\n\n- 列表项1\n- 列表项2 <div>123</div>') // '标题 列表项1 列表项2 123'
|
|
1177
1173
|
*/
|
|
1178
1174
|
declare const markdownToText: (markdown: string) => string;
|
|
1175
|
+
interface FindTreeNodesOptions {
|
|
1176
|
+
/** 树的id字段名,默认 "id" */
|
|
1177
|
+
id?: string;
|
|
1178
|
+
/** 子节点字段名,默认 "children" */
|
|
1179
|
+
children?: string;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* 从树结构中查找指定id列表的节点,并以自定义结构返回
|
|
1183
|
+
* - 支持跳过某些id(通过formatFn返回null/undefined)
|
|
1184
|
+
* - 支持自定义字段名
|
|
1185
|
+
*
|
|
1186
|
+
* @template T - 树节点类型,必须是键值对对象
|
|
1187
|
+
* @template R - 返回节点类型,默认与T相同
|
|
1188
|
+
* @param tree - 树结构数组
|
|
1189
|
+
* @param ids - 要查找的节点ID列表
|
|
1190
|
+
* @param formatFn - 可选的节点格式化函数,用于自定义返回节点的结构
|
|
1191
|
+
* @param options - 配置选项
|
|
1192
|
+
* @param options.id - ID字段名,默认为 "id"
|
|
1193
|
+
* @param options.children - 子节点字段名,默认为 "children"
|
|
1194
|
+
* @returns 符合ID列表的节点数组,按formatFn格式化后返回
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* // 基本用法
|
|
1198
|
+
* const tree = [
|
|
1199
|
+
* { id: 1, name: 'Node 1', children: [{ id: 2, name: 'Node 1-1' }] },
|
|
1200
|
+
* { id: 3, name: 'Node 2', children: [] }
|
|
1201
|
+
* ]
|
|
1202
|
+
* const result = findTreeNodesByIds(tree, [1, 2])
|
|
1203
|
+
* // => [{ id: 1, name: 'Node 1' }, { id: 2, name: 'Node 1-1' }]
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* // 使用格式化函数
|
|
1207
|
+
* const result = findTreeNodesByIds(tree, [1], (node) => ({ label: node.name, value: node.id }))
|
|
1208
|
+
* // => [{ label: 'Node 1', value: 1 }]
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // 自定义字段名
|
|
1212
|
+
* const treeWithCustomFields = [
|
|
1213
|
+
* { key: 'a', title: 'Node A', subItems: [{ key: 'b', title: 'Node B' }] }
|
|
1214
|
+
* ]
|
|
1215
|
+
* const result = findTreeNodesByIds(
|
|
1216
|
+
* treeWithCustomFields,
|
|
1217
|
+
* ['a'],
|
|
1218
|
+
* undefined,
|
|
1219
|
+
* { id: 'key', children: 'subItems' }
|
|
1220
|
+
* )
|
|
1221
|
+
* // => [{ key: 'a', title: 'Node A', subItems: undefined }]
|
|
1222
|
+
*/
|
|
1223
|
+
declare const findTreeNodesByIds: <T extends Record<string, any>, R = T>(tree: T[], ids?: T[keyof T][], formatFn?: (node: T) => R | null | undefined, options?: FindTreeNodesOptions) => R[];
|
|
1179
1224
|
|
|
1180
1225
|
type DateType = string | number | Date | dayjs.Dayjs | null;
|
|
1181
1226
|
/** 默认日期时间格式:年-月-日 时:分:秒 */
|
|
@@ -2268,4 +2313,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
|
|
|
2268
2313
|
clear: () => void;
|
|
2269
2314
|
};
|
|
2270
2315
|
|
|
2271
|
-
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
|
2316
|
+
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FindTreeNodesOptions, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
package/dist/index.d.ts
CHANGED
|
@@ -950,9 +950,7 @@ declare const getWebSocketUrl: (path: string, customHost?: string) => string;
|
|
|
950
950
|
* )
|
|
951
951
|
* // => { x: 1, y: 3 }
|
|
952
952
|
*/
|
|
953
|
-
declare
|
|
954
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
955
|
-
}): U;
|
|
953
|
+
declare const transform: <T extends object, U extends object>(source: T, fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U;
|
|
956
954
|
/**
|
|
957
955
|
* 批量对象转换函数
|
|
958
956
|
* @param sources - 源对象数组
|
|
@@ -963,9 +961,7 @@ declare function transform<T extends object, U extends object>(source: T, fieldM
|
|
|
963
961
|
* transforms([{ a: 1 }], { x: 'a' })
|
|
964
962
|
* // => [{ x: 1 }]
|
|
965
963
|
*/
|
|
966
|
-
declare
|
|
967
|
-
[K in keyof U]: keyof T | ((source: T) => U[K]) | U[K];
|
|
968
|
-
}): U[];
|
|
964
|
+
declare const transforms: <T extends object, U extends object>(sources: T[], fieldMap: { [K in keyof U]: keyof T | ((source: T) => U[K]) | U[K]; }) => U[];
|
|
969
965
|
/**
|
|
970
966
|
* 将数字金额转换为中文大写金额
|
|
971
967
|
*
|
|
@@ -1122,14 +1118,14 @@ declare const executeScript: (script: string, params: {
|
|
|
1122
1118
|
* @returns 加密后的字符串
|
|
1123
1119
|
* @throws 当密钥为空或加密过程失败时抛出错误
|
|
1124
1120
|
*/
|
|
1125
|
-
declare
|
|
1121
|
+
declare const aesEncrypt: <T = any>(data: T, key: string) => string;
|
|
1126
1122
|
/**
|
|
1127
1123
|
* AES 解密
|
|
1128
1124
|
* @param data - 加密后的字符串
|
|
1129
1125
|
* @param key - 解密密钥
|
|
1130
1126
|
* @returns 解密后的数据,解密失败时返回null
|
|
1131
1127
|
*/
|
|
1132
|
-
declare
|
|
1128
|
+
declare const aesDecrypt: <T = any>(data: string, key: string) => T | null;
|
|
1133
1129
|
type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
|
|
1134
1130
|
interface FormatSizeOptions {
|
|
1135
1131
|
/** 起始单位,默认 KB */
|
|
@@ -1166,7 +1162,7 @@ interface FormatSizeOptions {
|
|
|
1166
1162
|
* @remarks
|
|
1167
1163
|
* - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
|
|
1168
1164
|
*/
|
|
1169
|
-
declare
|
|
1165
|
+
declare const formatSize: (value: number | string, options?: FormatSizeOptions) => number | string;
|
|
1170
1166
|
/**
|
|
1171
1167
|
* Markdown转纯文本
|
|
1172
1168
|
* @param markdown - 原始 Markdown 内容
|
|
@@ -1176,6 +1172,55 @@ declare function formatSize(value: number | string, options?: FormatSizeOptions)
|
|
|
1176
1172
|
* markdownToText('## 标题\n\n- 列表项1\n- 列表项2 <div>123</div>') // '标题 列表项1 列表项2 123'
|
|
1177
1173
|
*/
|
|
1178
1174
|
declare const markdownToText: (markdown: string) => string;
|
|
1175
|
+
interface FindTreeNodesOptions {
|
|
1176
|
+
/** 树的id字段名,默认 "id" */
|
|
1177
|
+
id?: string;
|
|
1178
|
+
/** 子节点字段名,默认 "children" */
|
|
1179
|
+
children?: string;
|
|
1180
|
+
}
|
|
1181
|
+
/**
|
|
1182
|
+
* 从树结构中查找指定id列表的节点,并以自定义结构返回
|
|
1183
|
+
* - 支持跳过某些id(通过formatFn返回null/undefined)
|
|
1184
|
+
* - 支持自定义字段名
|
|
1185
|
+
*
|
|
1186
|
+
* @template T - 树节点类型,必须是键值对对象
|
|
1187
|
+
* @template R - 返回节点类型,默认与T相同
|
|
1188
|
+
* @param tree - 树结构数组
|
|
1189
|
+
* @param ids - 要查找的节点ID列表
|
|
1190
|
+
* @param formatFn - 可选的节点格式化函数,用于自定义返回节点的结构
|
|
1191
|
+
* @param options - 配置选项
|
|
1192
|
+
* @param options.id - ID字段名,默认为 "id"
|
|
1193
|
+
* @param options.children - 子节点字段名,默认为 "children"
|
|
1194
|
+
* @returns 符合ID列表的节点数组,按formatFn格式化后返回
|
|
1195
|
+
*
|
|
1196
|
+
* @example
|
|
1197
|
+
* // 基本用法
|
|
1198
|
+
* const tree = [
|
|
1199
|
+
* { id: 1, name: 'Node 1', children: [{ id: 2, name: 'Node 1-1' }] },
|
|
1200
|
+
* { id: 3, name: 'Node 2', children: [] }
|
|
1201
|
+
* ]
|
|
1202
|
+
* const result = findTreeNodesByIds(tree, [1, 2])
|
|
1203
|
+
* // => [{ id: 1, name: 'Node 1' }, { id: 2, name: 'Node 1-1' }]
|
|
1204
|
+
*
|
|
1205
|
+
* @example
|
|
1206
|
+
* // 使用格式化函数
|
|
1207
|
+
* const result = findTreeNodesByIds(tree, [1], (node) => ({ label: node.name, value: node.id }))
|
|
1208
|
+
* // => [{ label: 'Node 1', value: 1 }]
|
|
1209
|
+
*
|
|
1210
|
+
* @example
|
|
1211
|
+
* // 自定义字段名
|
|
1212
|
+
* const treeWithCustomFields = [
|
|
1213
|
+
* { key: 'a', title: 'Node A', subItems: [{ key: 'b', title: 'Node B' }] }
|
|
1214
|
+
* ]
|
|
1215
|
+
* const result = findTreeNodesByIds(
|
|
1216
|
+
* treeWithCustomFields,
|
|
1217
|
+
* ['a'],
|
|
1218
|
+
* undefined,
|
|
1219
|
+
* { id: 'key', children: 'subItems' }
|
|
1220
|
+
* )
|
|
1221
|
+
* // => [{ key: 'a', title: 'Node A', subItems: undefined }]
|
|
1222
|
+
*/
|
|
1223
|
+
declare const findTreeNodesByIds: <T extends Record<string, any>, R = T>(tree: T[], ids?: T[keyof T][], formatFn?: (node: T) => R | null | undefined, options?: FindTreeNodesOptions) => R[];
|
|
1179
1224
|
|
|
1180
1225
|
type DateType = string | number | Date | dayjs.Dayjs | null;
|
|
1181
1226
|
/** 默认日期时间格式:年-月-日 时:分:秒 */
|
|
@@ -2268,4 +2313,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
|
|
|
2268
2313
|
clear: () => void;
|
|
2269
2314
|
};
|
|
2270
2315
|
|
|
2271
|
-
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
|
2316
|
+
export { _default$p as AudioPlayer, type AudioPlayerProps, BusinessCode, type CacheMessage, type ComponentMapType, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, _default$o as DocxPreview, type DocxPreviewProps, _default$n as FileIcon, type FileIconProps, _default$m as FilePreview, _default$l as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FindTreeNodesOptions, type FormatSizeOptions, HttpStatus, _default$h as Iframe, type IframeProps, _default$g as LazyComponent, type LazyComponentProps, _default$f as MarkdownEditor, type MarkdownEditorProps, _default$k as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$j as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$e as RenderMarkdown, type RenderMarkdownProps, _default$d as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SetIntervalType, type SizeUnit, _default$b as SpeechButton, type SpeechPermission, type SpeechProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$i as VideoPlayer, type VideoPlayerProps, type WebSocketProps, type WebSocketType, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, _default$8 as useAutoRefresh, _default$7 as useCountDown, _default$6 as useCreateValtioContext, _default$5 as useDebounce, _default$4 as useDeepEffect, _default$9 as useIframeRelayBridge, _default$3 as useRefState, _default$c as useSpeech, _default$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
|
package/dist/index.esm.js
CHANGED
|
@@ -561,7 +561,7 @@ var getWebSocketUrl = (path, customHost) => {
|
|
|
561
561
|
const host = customHost || window.location.host;
|
|
562
562
|
return `${protocol}//${host}${path}`;
|
|
563
563
|
};
|
|
564
|
-
|
|
564
|
+
var transform = (source, fieldMap) => {
|
|
565
565
|
const result = {};
|
|
566
566
|
for (const [targetKey, mapping] of Object.entries(fieldMap)) {
|
|
567
567
|
const key = targetKey;
|
|
@@ -574,10 +574,10 @@ function transform(source, fieldMap) {
|
|
|
574
574
|
}
|
|
575
575
|
}
|
|
576
576
|
return result;
|
|
577
|
-
}
|
|
578
|
-
|
|
577
|
+
};
|
|
578
|
+
var transforms = (sources, fieldMap) => {
|
|
579
579
|
return sources?.map((source) => transform(source, fieldMap)) || [];
|
|
580
|
-
}
|
|
580
|
+
};
|
|
581
581
|
var convertCurrency = (money = "") => {
|
|
582
582
|
let newMoney = money;
|
|
583
583
|
const cnNums = ["\u96F6", "\u58F9", "\u8D30", "\u53C1", "\u8086", "\u4F0D", "\u9646", "\u67D2", "\u634C", "\u7396"];
|
|
@@ -723,7 +723,7 @@ var executeScript = (script, params) => {
|
|
|
723
723
|
console.error("unsafe script");
|
|
724
724
|
}
|
|
725
725
|
};
|
|
726
|
-
|
|
726
|
+
var aesEncrypt = (data, key) => {
|
|
727
727
|
if (!key) throw new Error("AES Encrypt: key is required");
|
|
728
728
|
if (isNullOrUnDef(data)) return "";
|
|
729
729
|
try {
|
|
@@ -733,8 +733,8 @@ function aesEncrypt(data, key) {
|
|
|
733
733
|
console.error("AES Encrypt error:", err);
|
|
734
734
|
throw new Error("AES Encrypt failed");
|
|
735
735
|
}
|
|
736
|
-
}
|
|
737
|
-
|
|
736
|
+
};
|
|
737
|
+
var aesDecrypt = (data, key) => {
|
|
738
738
|
if (!key) throw new Error("AES Decrypt: key is required");
|
|
739
739
|
if (!data) return null;
|
|
740
740
|
try {
|
|
@@ -746,8 +746,8 @@ function aesDecrypt(data, key) {
|
|
|
746
746
|
console.error("AES Decrypt error:", err);
|
|
747
747
|
return null;
|
|
748
748
|
}
|
|
749
|
-
}
|
|
750
|
-
|
|
749
|
+
};
|
|
750
|
+
var formatSize = (value, options = {}) => {
|
|
751
751
|
if (isNullOrUnDef(value) || !isNumberNoNaN(Number(value))) return value;
|
|
752
752
|
const UNIT_LIST = ["B", "KB", "MB", "GB", "TB", "PB"];
|
|
753
753
|
const { from = "KB", precision: precision2 = 2, trimZero = false, maxUnit } = options;
|
|
@@ -767,7 +767,7 @@ function formatSize(value, options = {}) {
|
|
|
767
767
|
index++;
|
|
768
768
|
}
|
|
769
769
|
return `${toFixed(size, precision2, !trimZero)}${UNIT_LIST[index]}`;
|
|
770
|
-
}
|
|
770
|
+
};
|
|
771
771
|
var markdownToText = (() => {
|
|
772
772
|
const md2 = new MarkdownIt({
|
|
773
773
|
html: true,
|
|
@@ -781,6 +781,32 @@ var markdownToText = (() => {
|
|
|
781
781
|
return text;
|
|
782
782
|
};
|
|
783
783
|
})();
|
|
784
|
+
var findTreeNodesByIds = (tree, ids, formatFn, options = {}) => {
|
|
785
|
+
const { id = "id", children = "children" } = options;
|
|
786
|
+
if (!ids?.length) {
|
|
787
|
+
return [];
|
|
788
|
+
}
|
|
789
|
+
const result = [];
|
|
790
|
+
const idSet = new Set(ids);
|
|
791
|
+
const dfs = (nodes) => {
|
|
792
|
+
for (const node of nodes) {
|
|
793
|
+
if (idSet.size === 0) break;
|
|
794
|
+
const nodeId = node[id];
|
|
795
|
+
if (idSet.has(nodeId)) {
|
|
796
|
+
idSet.delete(nodeId);
|
|
797
|
+
const formatted = formatFn ? formatFn(node) : { ...node, [children]: void 0 };
|
|
798
|
+
if (!isNullOrUnDef(formatted)) {
|
|
799
|
+
result.push(formatted);
|
|
800
|
+
}
|
|
801
|
+
}
|
|
802
|
+
if (node[children]?.length && idSet.size > 0) {
|
|
803
|
+
dfs(node[children]);
|
|
804
|
+
}
|
|
805
|
+
}
|
|
806
|
+
};
|
|
807
|
+
dfs(tree);
|
|
808
|
+
return result;
|
|
809
|
+
};
|
|
784
810
|
dayjs.extend(relativeTime);
|
|
785
811
|
var DEFAULT_DATE_TIME_FORMAT = "YYYY-MM-DD HH:mm:ss";
|
|
786
812
|
var DEFAULT_DATE_FORMAT = "YYYY-MM-DD";
|
|
@@ -1170,7 +1196,7 @@ var DocxPreview_default = ({ fileUrl, scale = 1 }) => {
|
|
|
1170
1196
|
const resetZoom = () => {
|
|
1171
1197
|
setZoomRatio(1);
|
|
1172
1198
|
};
|
|
1173
|
-
return /* @__PURE__ */ jsxs("div", { className: classNames(styles_module_default.nsPreviewDocx, "height-full"), children: [
|
|
1199
|
+
return /* @__PURE__ */ jsxs("div", { className: classNames(styles_module_default.nsPreviewDocx, "height-full", "width-full"), children: [
|
|
1174
1200
|
/* @__PURE__ */ jsxs(Flex, { gap: 6, align: "center", className: styles_module_default.docxToolbar, children: [
|
|
1175
1201
|
/* @__PURE__ */ jsx(Button, { onClick: zoomOut, icon: /* @__PURE__ */ jsx(MinusCircleOutlined, {}), title: "\u7F29\u5C0F" }),
|
|
1176
1202
|
/* @__PURE__ */ jsx(Button, { onClick: zoomIn, icon: /* @__PURE__ */ jsx(PlusCircleOutlined, {}), title: "\u653E\u5927" }),
|
|
@@ -1409,7 +1435,7 @@ var MarkdownPreview_default = ({ fileUrl, searchValue }) => {
|
|
|
1409
1435
|
useEffect(() => {
|
|
1410
1436
|
init();
|
|
1411
1437
|
}, [fileUrl]);
|
|
1412
|
-
return error ? /* @__PURE__ */ jsx(Result, { status: "error", title: error }) : /* @__PURE__ */ jsx("div", { className: "height-full", children: /* @__PURE__ */ jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
1438
|
+
return error ? /* @__PURE__ */ jsx(Result, { status: "error", title: error }) : /* @__PURE__ */ jsx("div", { className: "height-full width-full", children: /* @__PURE__ */ jsx(RenderMarkdown_default, { content, searchValue }) });
|
|
1413
1439
|
};
|
|
1414
1440
|
|
|
1415
1441
|
// src/hooks/iframe/iframeRelay.ts
|
|
@@ -1990,7 +2016,7 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
1990
2016
|
}, 500);
|
|
1991
2017
|
onSetPageNo?.(currentPage + 1);
|
|
1992
2018
|
}, [currentPage]);
|
|
1993
|
-
return /* @__PURE__ */ jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsx(Worker, { workerUrl:
|
|
2019
|
+
return /* @__PURE__ */ jsx("div", { ref: embedRef, className: styles_module_default.nsPreviewPdf, children: /* @__PURE__ */ jsx(Worker, { workerUrl: `https://logosdata.cn/public/pdf/pdf.worker.min.js`, children: /* @__PURE__ */ jsxs(Splitter, { onResize: setSizes, children: [
|
|
1994
2020
|
isHasThumbnails && /* @__PURE__ */ jsx(Splitter.Panel, { resizable: false, size: sizes[0], min: 250, max: 500, collapsible: true, children: /* @__PURE__ */ jsx(Thumbnails, {}) }),
|
|
1995
2021
|
/* @__PURE__ */ jsx(Splitter.Panel, { children: /* @__PURE__ */ jsxs("div", { className: "height-full", children: [
|
|
1996
2022
|
/* @__PURE__ */ jsx(
|
|
@@ -2011,13 +2037,13 @@ var PdfPreview_default = ({ password, fileUrl, pageNo = 1, scale = 1, isHasThumb
|
|
|
2011
2037
|
// 启用 CMap 支持,解决中文字体显示问题
|
|
2012
2038
|
// cMapUrl: 指定 CMap 文件的 URL,用于处理非拉丁字符(如中文)
|
|
2013
2039
|
// cMapPacked: 使用压缩的 CMap 文件以提高性能
|
|
2014
|
-
cMapUrl: "
|
|
2040
|
+
cMapUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/cmaps/",
|
|
2015
2041
|
// 使用可用的源
|
|
2016
2042
|
cMapPacked: true,
|
|
2017
2043
|
// 禁用字体子集化,确保完整字体加载
|
|
2018
2044
|
disableFontFace: false,
|
|
2019
2045
|
// 启用标准字体支持
|
|
2020
|
-
standardFontDataUrl: "
|
|
2046
|
+
standardFontDataUrl: "https://logosdata.cn/public/pdf/pdfjs-dist@3.2.146/standard_fonts/",
|
|
2021
2047
|
// 设置字体回退策略
|
|
2022
2048
|
fallbackFontName: "Helvetica"
|
|
2023
2049
|
});
|
|
@@ -5984,6 +6010,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
|
|
|
5984
6010
|
return avatarSrc ? /* @__PURE__ */ jsx(Avatar, { size, src: avatarSrc }) : /* @__PURE__ */ jsx(Avatar, { size, className: "cursor-pointer", style: { backgroundColor: "var(--ant-color-primary)" }, children: userName?.slice(0, 1)?.toLocaleUpperCase() });
|
|
5985
6011
|
};
|
|
5986
6012
|
|
|
5987
|
-
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MultiEmailValidator, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, SpeechButton_default as SpeechButton, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSpeech_default as useSpeech, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
6013
|
+
export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, DocxPreview_default as DocxPreview, FileIcon_default as FileIcon, FilePreview_default as FilePreview, FilePreviewDrawer_default as FilePreviewDrawer, HttpStatus, Iframe_default as Iframe, LazyComponent_default as LazyComponent, MarkdownEditor_default as MarkdownEditor, MarkdownPreview_default as MarkdownPreview, MultiEmailValidator, PdfPreview_default as PdfPreview, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, SpeechButton_default as SpeechButton, ThanNumLengthValidator, ThanNumValidator, UserAvatar_default as UserAvatar, VideoPlayer_default as VideoPlayer, absVal, addUrlLastSlash, aesDecrypt, aesEncrypt, arrToObj, buildUrlParams, cachedMessage, calculate, compareNum, convertCurrency, convertNewlineToBr, copyText, createRequest, createSecureManager, createTokenManager, decimalPlaces, deepCopy, deepEqual, deepMerge, dividedBy, downloadFile, emit, emitToChild, executeScript, findTreeNodesByIds, formatDate, formatNumberWithCommas, formatSize, genNonDuplicateID, generateRandomNumbers, getAllUrlParams, getDeviceId, getEndOfTimestamp, getFileName, getFileSuffixName, getRowSpanCount, getStartOfTimestamp, getTimestamp, getWebSocketUrl, importThirdPartyFile, is, isArray, isBlob, isBoolean, isDate, isDef, isElement, isEmpty, isEmptyObj, isExpire, isExternal, isFunction, isInteger, isJson, isLocalhost, isMap, isNegative, isNull, isNullOrUnDef, isNumber, isNumberNoNaN, isObject, isPromise, isReferenceType, isRegExp, isScriptSafe, isSet, isString, isUnDef, isWindow, markdownToText, minus, objToOptions, plus, precision, processItemList, propsMerge, setInterval2 as setInterval, setUrlMainSource, shouldRender, times, toFixed, transform, transforms, useAutoRefresh_default as useAutoRefresh, useCountDown_default as useCountDown, useCreateValtioContext_default as useCreateValtioContext, useDebounce_default as useDebounce, useDeepEffect_default as useDeepEffect, useIframeRelayBridge_default as useIframeRelayBridge, useRefState_default as useRefState, useSpeech_default as useSpeech, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
|
|
5988
6014
|
//# sourceMappingURL=index.esm.js.map
|
|
5989
6015
|
//# sourceMappingURL=index.esm.js.map
|