@dazhicheng/utils 1.3.60 → 1.3.62

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/tool.d.ts CHANGED
@@ -100,6 +100,47 @@ export declare function arrGive(targrt: any, sources: any, key?: any, content?:
100
100
  * @returns 格式化后的时间字符串,空值或无效时间返回空字符串
101
101
  */
102
102
  export declare const dateFormat: (value: string | number | Date | null | undefined, format?: string, tz?: string) => string;
103
+ /** dateFormatBreak 可选参数 */
104
+ export type DateFormatBreakOptions = {
105
+ /** 格式化模板,同 dateFormat,默认 `YYYY-MM-DD HH:mm:ss` */
106
+ format?: string;
107
+ /** 时区,同 dateFormat,默认 `Asia/Shanghai` */
108
+ tz?: string;
109
+ /** 要替换的子串,传给 `String.replaceAll`,默认 `' '` */
110
+ searchValue?: string;
111
+ /** 替换后的子串,传给 `String.replaceAll`,默认 `'\n'` */
112
+ replaceValue?: string;
113
+ };
114
+ /**
115
+ * 时间格式化并换行展示。
116
+ *
117
+ * 底层调用 {@link dateFormat},再对结果做 `replaceAll(searchValue, replaceValue)`,
118
+ * 默认把空格换成换行,便于表格把「日期」与「时间」拆成两行。
119
+ *
120
+ * 展示侧注意:
121
+ * - table column 需配合 `showOverflow: false`,否则单行省略看不到换行
122
+ * - 普通日期两行:`white-space: pre-line`(`\n` 换行,连续空格会折叠)即可
123
+ * - 需保留多空格对齐、或 `format` 结果里带连续空格时:用 `white-space: pre-wrap`
124
+ * (同样保留 `\n`,且连续空格原样保留)
125
+ *
126
+ * @param value 时间值(时间戳、字符串、Date);空值与无效时间同 dateFormat,返回空字符串
127
+ * @param options.format 格式化模板
128
+ * @param options.tz 时区
129
+ * @param options.searchValue 要替换的子串,默认 `' '`
130
+ * @param options.replaceValue 替换后的子串,默认 `'\n'`
131
+ * @returns 替换后的时间字符串
132
+ *
133
+ * @example
134
+ * dateFormatBreak("2026-08-15T02:20:30Z");
135
+ * // '2026-08-15\n10:20:30'
136
+ *
137
+ * dateFormatBreak(row.createTime, { format: "YYYY-MM-DD HH:mm" });
138
+ * // '2026-08-15\n10:20'
139
+ *
140
+ * dateFormatBreak(ts, { searchValue: " ", replaceValue: "<br/>" });
141
+ * // '2026-08-15<br/>10:20:30'
142
+ */
143
+ export declare function dateFormatBreak(value: string | number | Date | null | undefined, options?: DateFormatBreakOptions): string;
103
144
  /**
104
145
  * 深度克隆对象或数组 禁止循环引用对象
105
146
  * @description 使用 klona 库进行深度克隆,支持所有类型的数据结构 https://www.npmjs.com/package/klona
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dazhicheng/utils",
3
- "version": "1.3.60",
3
+ "version": "1.3.62",
4
4
  "description": "工具库",
5
5
  "main": "./dist/index.esm.js",
6
6
  "type": "module",