@svadmin/core 0.82.0 → 0.83.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/package.json +1 -1
- package/src/copy-format.ts +20 -0
- package/src/index.ts +4 -0
package/package.json
CHANGED
package/src/copy-format.ts
CHANGED
|
@@ -214,3 +214,23 @@ export function formatAdminDate(value: Date | number | string, options: AdminDat
|
|
|
214
214
|
if (options.timeZone) fields.timeZone = options.timeZone;
|
|
215
215
|
return new Intl.DateTimeFormat(options.locale, fields).format(date);
|
|
216
216
|
}
|
|
217
|
+
|
|
218
|
+
/** 中文破折号是两字宽,写成两个 em dash。单独的 — 和半角 -- 都换成 ——。 */
|
|
219
|
+
export function formatAdminEmDash(text: string): string {
|
|
220
|
+
return text.replace(/—{2,}|--+/g, '——').replace(/(?<!—)—(?!—)/g, '——');
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
/** 小于等于用 ≤。只替换半角 <=。 */
|
|
224
|
+
export function formatAdminLessThanOrEqual(text: string): string {
|
|
225
|
+
return text.replace(/<=/g, '≤');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** 数字区间用 ~。已经写成 ~ 的保持不动。 */
|
|
229
|
+
export function formatAdminNumericRange(text: string): string {
|
|
230
|
+
return text.replace(/(\d(?:[\d,.]*\d)?)\s*(?:-|—)\s*(\d(?:[\d,.]*\d)?)/g, '$1~$2');
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
/** 英文标点后面补一个空格。小数点、中文标点和已有空格不动。 */
|
|
234
|
+
export function formatAdminEnglishPunctuation(text: string): string {
|
|
235
|
+
return text.replace(/([,;:!?])(?=[A-Za-z])/g, '$1 ');
|
|
236
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -171,7 +171,11 @@ export {
|
|
|
171
171
|
formatAdminCurrency,
|
|
172
172
|
formatAdminDate,
|
|
173
173
|
formatAdminEllipsis,
|
|
174
|
+
formatAdminEmDash,
|
|
175
|
+
formatAdminEnglishPunctuation,
|
|
176
|
+
formatAdminLessThanOrEqual,
|
|
174
177
|
formatAdminNumber,
|
|
178
|
+
formatAdminNumericRange,
|
|
175
179
|
formatAdminPercent,
|
|
176
180
|
formatAdminTime,
|
|
177
181
|
spaceCjkLatin,
|