@zero-library/common 2.2.1 → 2.2.2

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.d.mts CHANGED
@@ -194,7 +194,7 @@ declare const _default$g: ({ fileUrl }: VideoPlayerProps) => react_jsx_runtime.J
194
194
  * Iframe组件属性接口
195
195
  */
196
196
  interface IframeProps {
197
- /** 默认主源 */
197
+ /** 默认主源 用于在内部区分来源 */
198
198
  defaultMainSource?: string;
199
199
  /** iframe ID */
200
200
  id?: string;
@@ -276,20 +276,18 @@ interface RenderMarkdownProps {
276
276
  content?: string;
277
277
  /** 搜索关键字 */
278
278
  searchValue?: string;
279
- /** 自定义组件映射 */
279
+ /** 自定义组件映射, 默认会传入loading、data 属性以及透传参数 */
280
280
  customComponents?: ComponentMapType;
281
- /** 内容变化回调 */
282
- onChange?: (value: string) => void;
283
- /** 部分内容变化回调 */
284
- onPartialChange?: (oldValue: string, newValue: string) => void;
281
+ /** 透传入自定义组件的参数方法 */
282
+ [key: string]: any;
285
283
  }
286
284
  /**
287
285
  * Markdown渲染组件
288
286
  * 将Markdown文本转换为HTML并渲染为React组件
289
- * 支持自定义组件、搜索高亮、内容编辑等功能
287
+ * 支持自定义组件、搜索高亮等功能
290
288
  * @param RenderMarkdownProps - 组件属性
291
289
  */
292
- declare const _default$c: ({ content, searchValue, customComponents, onChange, onPartialChange }: RenderMarkdownProps) => react_jsx_runtime.JSX.Element;
290
+ declare const _default$c: ({ content, searchValue, customComponents, ...rest }: RenderMarkdownProps) => react_jsx_runtime.JSX.Element;
293
291
 
294
292
  /**
295
293
  * 渲染控制对象类型
@@ -1084,6 +1082,44 @@ declare function aesEncrypt<T = any>(data: T, key: string): string;
1084
1082
  * @returns 解密后的数据,解密失败时返回null
1085
1083
  */
1086
1084
  declare function aesDecrypt<T = any>(data: string, key: string): T | null;
1085
+ declare const formatKB: (kbNum?: number) => string;
1086
+ type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
1087
+ interface FormatSizeOptions {
1088
+ /** 起始单位,默认 KB */
1089
+ from?: SizeUnit;
1090
+ /** 保留小数位数,默认 2 */
1091
+ precision?: number;
1092
+ /** 是否去除多余的 0,如 1.00 -> 1 */
1093
+ trimZero?: boolean;
1094
+ /** 最大单位限制 */
1095
+ maxUnit?: SizeUnit;
1096
+ }
1097
+ /**
1098
+ * 格式化文件大小显示
1099
+ *
1100
+ * 将给定的数值按照指定单位转换为更友好的可读格式(如KB, MB, GB等)
1101
+ * 支持从不同单位开始转换,并可自定义精度和最大单位限制
1102
+ *
1103
+ * @param value - 需要格式化的数值(可以是数字或数字字符串)
1104
+ * @param options - 格式化选项
1105
+ * @param options.from - 输入数值的单位,默认为 'KB'
1106
+ * @param options.precision - 保留的小数位数,默认为 2
1107
+ * @param options.trimZero - 是否去除尾部的零,默认为 false
1108
+ * @param options.maxUnit - 最大转换单位,超过该单位则不再转换,默认无限制
1109
+ *
1110
+ * @returns 格式化后的文件大小字符串,如果输入无效则返回原值
1111
+ *
1112
+ * @example
1113
+ * formatSize(1024) // "1024.00KB"
1114
+ * formatSize(1024, { from: 'B' }) // "1.00KB"
1115
+ * formatSize(1024, { precision: 0 }) // "1024KB"
1116
+ * formatSize(1024, { trimZero: true }) // "1024KB"
1117
+ * formatSize(2048, { maxUnit: 'KB' }) // "2048.00KB" (不会转换为MB)
1118
+ *
1119
+ * @remarks
1120
+ * - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
1121
+ */
1122
+ declare function formatSize(value: number | string, options?: FormatSizeOptions): number | string;
1087
1123
 
1088
1124
  type DateType = string | number | Date | dayjs.Dayjs | null;
1089
1125
  /** 默认日期时间格式:年-月-日 时:分:秒 */
@@ -1847,6 +1883,19 @@ declare const RegDetailAddress: {
1847
1883
  pattern: RegExp;
1848
1884
  message: string;
1849
1885
  };
1886
+ /**
1887
+ * 密码强度验证规则
1888
+ *
1889
+ * 正则表达式要求:
1890
+ * 1. 长度在8到26位之间
1891
+ * 2. 必须包含至少一个字母(大小写均可)
1892
+ * 3. 必须包含至少一个数字
1893
+ * 4. 只能包含字母和数字(不允许特殊字符)
1894
+ */
1895
+ declare const RegPassword: {
1896
+ pattern: RegExp;
1897
+ message: string;
1898
+ };
1850
1899
  /**
1851
1900
  * 手机号或固定电话验证器
1852
1901
  * 验证输入是否符合手机号或固定电话格式
@@ -2163,4 +2212,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
2163
2212
  clear: () => void;
2164
2213
  };
2165
2214
 
2166
- export { _default$m 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$l as FileIcon, type FileIconProps, _default$k as FilePreview, _default$j as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, HttpStatus, _default$f as Iframe, type IframeProps, _default$e as LazyComponent, type LazyComponentProps, _default$d as MarkdownEditor, type MarkdownEditorProps, _default$i as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$h as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$c as RenderMarkdown, type RenderMarkdownProps, _default$b as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$g 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, 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, 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$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
2215
+ export { _default$m 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$l as FileIcon, type FileIconProps, _default$k as FilePreview, _default$j as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$f as Iframe, type IframeProps, _default$e as LazyComponent, type LazyComponentProps, _default$d as MarkdownEditor, type MarkdownEditorProps, _default$i as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$h as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$c as RenderMarkdown, type RenderMarkdownProps, _default$b as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SizeUnit, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$g 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, formatKB, 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, 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$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
package/dist/index.d.ts CHANGED
@@ -194,7 +194,7 @@ declare const _default$g: ({ fileUrl }: VideoPlayerProps) => react_jsx_runtime.J
194
194
  * Iframe组件属性接口
195
195
  */
196
196
  interface IframeProps {
197
- /** 默认主源 */
197
+ /** 默认主源 用于在内部区分来源 */
198
198
  defaultMainSource?: string;
199
199
  /** iframe ID */
200
200
  id?: string;
@@ -276,20 +276,18 @@ interface RenderMarkdownProps {
276
276
  content?: string;
277
277
  /** 搜索关键字 */
278
278
  searchValue?: string;
279
- /** 自定义组件映射 */
279
+ /** 自定义组件映射, 默认会传入loading、data 属性以及透传参数 */
280
280
  customComponents?: ComponentMapType;
281
- /** 内容变化回调 */
282
- onChange?: (value: string) => void;
283
- /** 部分内容变化回调 */
284
- onPartialChange?: (oldValue: string, newValue: string) => void;
281
+ /** 透传入自定义组件的参数方法 */
282
+ [key: string]: any;
285
283
  }
286
284
  /**
287
285
  * Markdown渲染组件
288
286
  * 将Markdown文本转换为HTML并渲染为React组件
289
- * 支持自定义组件、搜索高亮、内容编辑等功能
287
+ * 支持自定义组件、搜索高亮等功能
290
288
  * @param RenderMarkdownProps - 组件属性
291
289
  */
292
- declare const _default$c: ({ content, searchValue, customComponents, onChange, onPartialChange }: RenderMarkdownProps) => react_jsx_runtime.JSX.Element;
290
+ declare const _default$c: ({ content, searchValue, customComponents, ...rest }: RenderMarkdownProps) => react_jsx_runtime.JSX.Element;
293
291
 
294
292
  /**
295
293
  * 渲染控制对象类型
@@ -1084,6 +1082,44 @@ declare function aesEncrypt<T = any>(data: T, key: string): string;
1084
1082
  * @returns 解密后的数据,解密失败时返回null
1085
1083
  */
1086
1084
  declare function aesDecrypt<T = any>(data: string, key: string): T | null;
1085
+ declare const formatKB: (kbNum?: number) => string;
1086
+ type SizeUnit = 'B' | 'KB' | 'MB' | 'GB' | 'TB' | 'PB';
1087
+ interface FormatSizeOptions {
1088
+ /** 起始单位,默认 KB */
1089
+ from?: SizeUnit;
1090
+ /** 保留小数位数,默认 2 */
1091
+ precision?: number;
1092
+ /** 是否去除多余的 0,如 1.00 -> 1 */
1093
+ trimZero?: boolean;
1094
+ /** 最大单位限制 */
1095
+ maxUnit?: SizeUnit;
1096
+ }
1097
+ /**
1098
+ * 格式化文件大小显示
1099
+ *
1100
+ * 将给定的数值按照指定单位转换为更友好的可读格式(如KB, MB, GB等)
1101
+ * 支持从不同单位开始转换,并可自定义精度和最大单位限制
1102
+ *
1103
+ * @param value - 需要格式化的数值(可以是数字或数字字符串)
1104
+ * @param options - 格式化选项
1105
+ * @param options.from - 输入数值的单位,默认为 'KB'
1106
+ * @param options.precision - 保留的小数位数,默认为 2
1107
+ * @param options.trimZero - 是否去除尾部的零,默认为 false
1108
+ * @param options.maxUnit - 最大转换单位,超过该单位则不再转换,默认无限制
1109
+ *
1110
+ * @returns 格式化后的文件大小字符串,如果输入无效则返回原值
1111
+ *
1112
+ * @example
1113
+ * formatSize(1024) // "1024.00KB"
1114
+ * formatSize(1024, { from: 'B' }) // "1.00KB"
1115
+ * formatSize(1024, { precision: 0 }) // "1024KB"
1116
+ * formatSize(1024, { trimZero: true }) // "1024KB"
1117
+ * formatSize(2048, { maxUnit: 'KB' }) // "2048.00KB" (不会转换为MB)
1118
+ *
1119
+ * @remarks
1120
+ * - 支持从 B, KB, MB, GB, TB, PB 等单位开始转换
1121
+ */
1122
+ declare function formatSize(value: number | string, options?: FormatSizeOptions): number | string;
1087
1123
 
1088
1124
  type DateType = string | number | Date | dayjs.Dayjs | null;
1089
1125
  /** 默认日期时间格式:年-月-日 时:分:秒 */
@@ -1847,6 +1883,19 @@ declare const RegDetailAddress: {
1847
1883
  pattern: RegExp;
1848
1884
  message: string;
1849
1885
  };
1886
+ /**
1887
+ * 密码强度验证规则
1888
+ *
1889
+ * 正则表达式要求:
1890
+ * 1. 长度在8到26位之间
1891
+ * 2. 必须包含至少一个字母(大小写均可)
1892
+ * 3. 必须包含至少一个数字
1893
+ * 4. 只能包含字母和数字(不允许特殊字符)
1894
+ */
1895
+ declare const RegPassword: {
1896
+ pattern: RegExp;
1897
+ message: string;
1898
+ };
1850
1899
  /**
1851
1900
  * 手机号或固定电话验证器
1852
1901
  * 验证输入是否符合手机号或固定电话格式
@@ -2163,4 +2212,4 @@ declare function createTokenManager({ key, storage }: TokenManagerProps): {
2163
2212
  clear: () => void;
2164
2213
  };
2165
2214
 
2166
- export { _default$m 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$l as FileIcon, type FileIconProps, _default$k as FilePreview, _default$j as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, HttpStatus, _default$f as Iframe, type IframeProps, _default$e as LazyComponent, type LazyComponentProps, _default$d as MarkdownEditor, type MarkdownEditorProps, _default$i as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$h as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$c as RenderMarkdown, type RenderMarkdownProps, _default$b as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$g 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, 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, 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$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
2215
+ export { _default$m 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$l as FileIcon, type FileIconProps, _default$k as FilePreview, _default$j as FilePreviewDrawer, type FilePreviewDrawerProps, type FilePreviewProps, type FormatSizeOptions, HttpStatus, _default$f as Iframe, type IframeProps, _default$e as LazyComponent, type LazyComponentProps, _default$d as MarkdownEditor, type MarkdownEditorProps, _default$i as MarkdownPreview, type MarkdownPreviewProps, MultiEmailValidator, _default$h as PdfPreview, type PdfPreviewProps, PhoneOrMobileValidator, RegBankCardNo, RegDetailAddress, RegEmail, RegFixedTelePhone, RegIdentityCardNo, RegMobile, RegNumNo, RegPassword, RegSmsCode, RegTaxNo, RegTelePhone, type RenderControl, _default$c as RenderMarkdown, type RenderMarkdownProps, _default$b as RenderWrapper, type RenderWrapperProps, type RequestConfig, type SecureManagerProps, type SizeUnit, ThanNumLengthValidator, ThanNumValidator, type TokenManagerProps, _default$a as UserAvatar, type UserAvatarProps, _default$g 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, formatKB, 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, 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$2 as useSyncInput, _default$1 as useThrottle, _default as useWebSocket };
package/dist/index.esm.js CHANGED
@@ -15,9 +15,9 @@ import zh_CN from '@react-pdf-viewer/locales/lib/zh_CN.json';
15
15
  import '@react-pdf-viewer/page-navigation/lib/styles/index.css';
16
16
  import AES from 'crypto-js/aes';
17
17
  import encUtf8 from 'crypto-js/enc-utf8';
18
+ import Decimal from 'decimal.js';
18
19
  import dayjs from 'dayjs';
19
20
  import relativeTime from 'dayjs/plugin/relativeTime';
20
- import Decimal from 'decimal.js';
21
21
  import axios from 'axios';
22
22
  import '@react-pdf-viewer/thumbnail/lib/styles/index.css';
23
23
  import '@react-pdf-viewer/zoom/lib/styles/index.css';
@@ -215,7 +215,7 @@ try {
215
215
  md.use(alertInlinePlugin);
216
216
  } catch {
217
217
  }
218
- var RenderMarkdown_default = ({ content = "", searchValue, customComponents, onChange, onPartialChange }) => {
218
+ var RenderMarkdown_default = ({ content = "", searchValue, customComponents, ...rest }) => {
219
219
  const reactContent = useMemo(() => {
220
220
  if (!content) return null;
221
221
  const { text: preprocessed, placeholders } = alertMarkClean(content);
@@ -235,18 +235,7 @@ var RenderMarkdown_default = ({ content = "", searchValue, customComponents, onC
235
235
  const raw = placeholders.get(dataAttr) ?? "";
236
236
  data = parseData(raw);
237
237
  }
238
- return /* @__PURE__ */ jsx(
239
- LazyComponent_default,
240
- {
241
- type,
242
- data,
243
- loading,
244
- customComponents,
245
- onChange,
246
- onPartialChange
247
- },
248
- `${type}${lazyIndex}`
249
- );
238
+ return /* @__PURE__ */ jsx(LazyComponent_default, { customComponents, type, data, loading, ...rest }, `${type}${lazyIndex}`);
250
239
  }
251
240
  }
252
241
  });
@@ -589,6 +578,60 @@ var useDebounce_default = (func, wait = 400) => {
589
578
  debounce.cancel = cancel;
590
579
  return useCallback(debounce, []);
591
580
  };
581
+ var OperatorToMethodName = {
582
+ "+": "plus",
583
+ "-": "minus",
584
+ "*": "times",
585
+ "/": "dividedBy"
586
+ };
587
+ var calculate = (operator, ...args) => {
588
+ if (args.length === 0) return "0";
589
+ const [arg, ...newArgs] = args;
590
+ return newArgs.reduce((acc, val) => acc[OperatorToMethodName[operator]](new Decimal(val)), new Decimal(arg)).toString();
591
+ };
592
+ var plus = (...args) => calculate("+", ...args);
593
+ var minus = (...args) => calculate("-", ...args);
594
+ var times = (...args) => calculate("*", ...args);
595
+ var dividedBy = (...args) => calculate("/", ...args);
596
+ var decimalPlaces = (arg1) => {
597
+ return new Decimal(arg1).decimalPlaces();
598
+ };
599
+ var precision = (arg1) => {
600
+ return new Decimal(arg1).precision(true);
601
+ };
602
+ var absVal = (arg1) => new Decimal(arg1).abs().toString();
603
+ var compareNum = (arg1, arg2, type) => {
604
+ const x = new Decimal(arg1);
605
+ const y = new Decimal(arg2);
606
+ switch (type) {
607
+ case ">":
608
+ return x.greaterThan(y);
609
+ case ">=":
610
+ return x.greaterThanOrEqualTo(y);
611
+ case "<":
612
+ return x.lessThan(y);
613
+ case "<=":
614
+ return x.lessThanOrEqualTo(y);
615
+ case "==":
616
+ return x.equals(y);
617
+ }
618
+ };
619
+ var toFixed = (num, decimals = 2, fill = true) => {
620
+ const x = new Decimal(num);
621
+ if (fill) {
622
+ return x.toFixed(decimals, Decimal.ROUND_HALF_UP);
623
+ } else {
624
+ return x.toDecimalPlaces(decimals, Decimal.ROUND_HALF_UP).toString();
625
+ }
626
+ };
627
+ var isInteger = (num) => {
628
+ return new Decimal(num).isInteger();
629
+ };
630
+ var isNegative = (num) => {
631
+ return new Decimal(num).isNegative();
632
+ };
633
+
634
+ // src/utils/common.ts
592
635
  var deepCopy = (obj, isJson2 = true) => {
593
636
  if (isJson2) {
594
637
  try {
@@ -1073,6 +1116,38 @@ function aesDecrypt(data, key) {
1073
1116
  return null;
1074
1117
  }
1075
1118
  }
1119
+ var formatKB = (kbNum) => {
1120
+ if (!isNumber(kbNum)) return kbNum;
1121
+ const units = ["KB", "MB", "GB", "TB"];
1122
+ let size = kbNum;
1123
+ let index = 0;
1124
+ while (size >= 1024 && index < units.length - 1) {
1125
+ size /= 1024;
1126
+ index++;
1127
+ }
1128
+ return `${size.toFixed(2)} ${units[index]}`;
1129
+ };
1130
+ function formatSize(value, options = {}) {
1131
+ if (isNullOrUnDef(value) || !isNumberNoNaN(Number(value))) return value;
1132
+ const UNIT_LIST = ["B", "KB", "MB", "GB", "TB", "PB"];
1133
+ const { from = "KB", precision: precision2 = 2, trimZero = false, maxUnit } = options;
1134
+ let index = UNIT_LIST.indexOf(from);
1135
+ if (index === -1) {
1136
+ console.warn(`Invalid from: ${from}`);
1137
+ return value;
1138
+ }
1139
+ const maxIndex = maxUnit ? UNIT_LIST.indexOf(maxUnit) : UNIT_LIST.length - 1;
1140
+ if (maxIndex === -1) {
1141
+ console.warn(`Invalid maxUnit: ${maxUnit}`);
1142
+ return value;
1143
+ }
1144
+ let size = value;
1145
+ while (compareNum(size, 1024, ">=") && index < maxIndex) {
1146
+ size = dividedBy(size, 1024);
1147
+ index++;
1148
+ }
1149
+ return `${toFixed(size, precision2, !trimZero)}${UNIT_LIST[index]}`;
1150
+ }
1076
1151
 
1077
1152
  // src/hooks/useDeepEffect.ts
1078
1153
  var useDeepEffect_default = (effect, deps) => {
@@ -1170,58 +1245,6 @@ var getTimestamp = (date) => {
1170
1245
  var isExpire = (date) => {
1171
1246
  return dayjs(date).isBefore(getStartOfTimestamp());
1172
1247
  };
1173
- var OperatorToMethodName = {
1174
- "+": "plus",
1175
- "-": "minus",
1176
- "*": "times",
1177
- "/": "dividedBy"
1178
- };
1179
- var calculate = (operator, ...args) => {
1180
- if (args.length === 0) return "0";
1181
- const [arg, ...newArgs] = args;
1182
- return newArgs.reduce((acc, val) => acc[OperatorToMethodName[operator]](new Decimal(val)), new Decimal(arg)).toString();
1183
- };
1184
- var plus = (...args) => calculate("+", ...args);
1185
- var minus = (...args) => calculate("-", ...args);
1186
- var times = (...args) => calculate("*", ...args);
1187
- var dividedBy = (...args) => calculate("/", ...args);
1188
- var decimalPlaces = (arg1) => {
1189
- return new Decimal(arg1).decimalPlaces();
1190
- };
1191
- var precision = (arg1) => {
1192
- return new Decimal(arg1).precision(true);
1193
- };
1194
- var absVal = (arg1) => new Decimal(arg1).abs().toString();
1195
- var compareNum = (arg1, arg2, type) => {
1196
- const x = new Decimal(arg1);
1197
- const y = new Decimal(arg2);
1198
- switch (type) {
1199
- case ">":
1200
- return x.greaterThan(y);
1201
- case ">=":
1202
- return x.greaterThanOrEqualTo(y);
1203
- case "<":
1204
- return x.lessThan(y);
1205
- case "<=":
1206
- return x.lessThanOrEqualTo(y);
1207
- case "==":
1208
- return x.equals(y);
1209
- }
1210
- };
1211
- var toFixed = (num, decimals = 2, fill = true) => {
1212
- const x = new Decimal(num);
1213
- if (fill) {
1214
- return x.toFixed(decimals, Decimal.ROUND_HALF_UP);
1215
- } else {
1216
- return x.toDecimalPlaces(decimals, Decimal.ROUND_HALF_UP).toString();
1217
- }
1218
- };
1219
- var isInteger = (num) => {
1220
- return new Decimal(num).isInteger();
1221
- };
1222
- var isNegative = (num) => {
1223
- return new Decimal(num).isNegative();
1224
- };
1225
1248
  var createCachedMessage = () => {
1226
1249
  const messageCache = {};
1227
1250
  return ({ title = "\u63D0\u793A", content, type = "warning", duration = 3, onClose, isCache = true, isOnly = false }) => {
@@ -1306,6 +1329,10 @@ var RegDetailAddress = {
1306
1329
  pattern: /.*(街|路|村|乡|镇|道|巷|号).*/,
1307
1330
  message: "\u5FC5\u987B\u5305\u542B\u201C\u8857\u3001\u8DEF\u3001\u6751\u3001\u4E61\u3001\u9547\u3001\u9053\u3001\u5DF7\u3001\u53F7\u201D\u7B49\u5173\u952E\u8BCD\u4E4B\u4E00"
1308
1331
  };
1332
+ var RegPassword = {
1333
+ pattern: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{8,26}$/,
1334
+ message: "\u5BC6\u7801\u4E3A8\u523026\u4F4D\u4E4B\u95F4\u6570\u5B57\u4E0E\u5B57\u6BCD\u7EC4\u5408"
1335
+ };
1309
1336
  var PhoneOrMobileValidator = (errMessage = "\u8054\u7CFB\u7535\u8BDD\u683C\u5F0F\u4E0D\u6B63\u786E") => ({
1310
1337
  validator: (_, value) => !value || RegFixedTelePhone.pattern.test(value) || RegMobile.pattern.test(value) ? Promise.resolve() : Promise.reject(new Error(errMessage))
1311
1338
  });
@@ -5756,6 +5783,6 @@ var UserAvatar_default = ({ size, avatarSrc, userName }) => {
5756
5783
  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() });
5757
5784
  };
5758
5785
 
5759
- export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, 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, RegSmsCode, RegTaxNo, RegTelePhone, RenderMarkdown_default as RenderMarkdown, RenderWrapper_default as RenderWrapper, 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, 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, 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, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
5786
+ export { AudioPlayer_default as AudioPlayer, BusinessCode, DEFAULT_DATE_FORMAT, DEFAULT_DATE_TIME_FORMAT, DEFAULT_YEAR_MONTH_DAY_FORMAT, DEFAULT_YEAR_MONTH_FORMAT, 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, 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, formatKB, 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, 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, useSyncInput_default as useSyncInput, useThrottle_default as useThrottle, useWebSocket_default as useWebSocket };
5760
5787
  //# sourceMappingURL=index.esm.js.map
5761
5788
  //# sourceMappingURL=index.esm.js.map