@sybz-components/utils 0.0.12 → 1.0.1

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/base.cjs CHANGED
@@ -3,7 +3,7 @@
3
3
  require('vue');
4
4
  require('consola');
5
5
  require('es-toolkit');
6
- const format = require('./shared/utils.DUIw9c4e.cjs');
6
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
7
7
  require('element-plus');
8
8
  require('./is.cjs');
9
9
 
package/dist/base.d.cts CHANGED
@@ -120,7 +120,7 @@ interface ConfirmOptions extends ElMessageBoxOptions {
120
120
  /**
121
121
  * 确认框主题。
122
122
  */
123
- theme?: '' | 'chenghua';
123
+ theme?: 'default' | 'chenghua' | 'shijingshan';
124
124
  /**
125
125
  * 手动传入 appContext,处理多应用或嵌套弹窗场景。
126
126
  */
package/dist/base.d.mts CHANGED
@@ -120,7 +120,7 @@ interface ConfirmOptions extends ElMessageBoxOptions {
120
120
  /**
121
121
  * 确认框主题。
122
122
  */
123
- theme?: '' | 'chenghua';
123
+ theme?: 'default' | 'chenghua' | 'shijingshan';
124
124
  /**
125
125
  * 手动传入 appContext,处理多应用或嵌套弹窗场景。
126
126
  */
package/dist/base.d.ts CHANGED
@@ -120,7 +120,7 @@ interface ConfirmOptions extends ElMessageBoxOptions {
120
120
  /**
121
121
  * 确认框主题。
122
122
  */
123
- theme?: '' | 'chenghua';
123
+ theme?: 'default' | 'chenghua' | 'shijingshan';
124
124
  /**
125
125
  * 手动传入 appContext,处理多应用或嵌套弹窗场景。
126
126
  */
package/dist/base.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import 'vue';
2
2
  import 'consola';
3
3
  import 'es-toolkit';
4
- export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.CTnx12Vx.mjs';
4
+ export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.C6HkWKyE.mjs';
5
5
  import 'element-plus';
6
6
  import './is.mjs';
package/dist/format.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.DUIw9c4e.cjs');
3
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
4
4
  require('./is.cjs');
5
5
  require('consola');
6
6
  require('vue');
@@ -12,7 +12,6 @@ require('element-plus');
12
12
  exports.formatBytes = format.formatBytes;
13
13
  exports.formatBytesConvert = format.formatBytesConvert;
14
14
  exports.formatDurationTime = format.formatDurationTime;
15
- exports.formatImg = format.formatImg;
16
15
  exports.formatTextToHtml = format.formatTextToHtml;
17
16
  exports.formatThousands = format.formatThousands;
18
17
  exports.formatTime = format.formatTime;
package/dist/format.d.cts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.d.mts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.d.ts CHANGED
@@ -36,15 +36,6 @@ interface FormatBytesConvertOptions {
36
36
  */
37
37
  digit?: number;
38
38
  }
39
- /**
40
- * `formatImg` 的配置项。
41
- */
42
- interface FormatImgOptions {
43
- /**
44
- * 静态资源根目录,默认 `assets/images`。
45
- */
46
- basePath?: string;
47
- }
48
39
  /**
49
40
  * `formatToFixed` 的配置项。
50
41
  */
@@ -160,21 +151,6 @@ declare function formatTime(time?: FormatTimeInput, cFormat?: string, fallback?:
160
151
  * // => '05分00秒'
161
152
  */
162
153
  declare function formatDurationTime(timestamp: number, cFormat?: string): string;
163
- /**
164
- * 获取 `assets` 目录下的静态资源地址。
165
- *
166
- * @param photoName 文件名;未带后缀时会自动补 `.png`。
167
- * @param addPath 额外子目录,例如 `menu`。
168
- * @param options 配置项。
169
- * @returns 静态资源的完整 URL;如果本身已是 `http/https` 地址,则原样返回。
170
- *
171
- * @example
172
- * formatImg('logo')
173
- *
174
- * @example
175
- * formatImg('avatar.png', 'user')
176
- */
177
- declare function formatImg(photoName: string, addPath?: string, { basePath }?: FormatImgOptions): string;
178
154
  /**
179
155
  * 按指定小数位格式化数字,并可附带前后缀、单位和千分位。
180
156
  *
@@ -204,5 +180,5 @@ declare function formatToFixed(value: unknown, options?: FormatToFixedOptions |
204
180
  declare function formatTextToHtml(str: string): string;
205
181
  declare function formatTextToHtml<T>(str: T): T;
206
182
 
207
- export { formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed };
208
- export type { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
183
+ export { formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed };
184
+ export type { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions };
package/dist/format.mjs CHANGED
@@ -1,4 +1,4 @@
1
- export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.CTnx12Vx.mjs';
1
+ export { y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatTextToHtml, C as formatThousands, D as formatTime, E as formatToFixed } from './shared/utils.C6HkWKyE.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
package/dist/index.cjs CHANGED
@@ -1,15 +1,11 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.DUIw9c4e.cjs');
4
- const day = require('./day.cjs');
3
+ const format = require('./shared/utils.q3_d_9Nx.cjs');
5
4
  const is = require('./is.cjs');
6
- const ws = require('./ws.cjs');
7
5
  require('vue');
8
6
  require('consola');
9
7
  require('es-toolkit');
10
8
  require('element-plus');
11
- require('dayjs');
12
- require('qs');
13
9
 
14
10
 
15
11
 
@@ -23,7 +19,6 @@ exports.delay = format.delay;
23
19
  exports.formatBytes = format.formatBytes;
24
20
  exports.formatBytesConvert = format.formatBytesConvert;
25
21
  exports.formatDurationTime = format.formatDurationTime;
26
- exports.formatImg = format.formatImg;
27
22
  exports.formatTextToHtml = format.formatTextToHtml;
28
23
  exports.formatThousands = format.formatThousands;
29
24
  exports.formatTime = format.formatTime;
@@ -46,11 +41,6 @@ exports.tryCatch = format.tryCatch;
46
41
  exports.validate = format.validate;
47
42
  exports.validateForm = format.validateForm;
48
43
  exports.validateOnSubmit = format.validateOnSubmit;
49
- exports.diffDate = day.diffDate;
50
- exports.diffDateFromCurrent = day.diffDateFromCurrent;
51
- exports.formatDate = day.formatDate;
52
- exports.formatDateToDay = day.formatDateToDay;
53
- exports.formatDateToMinute = day.formatDateToMinute;
54
44
  exports.isArray = is.isArray;
55
45
  exports.isBoolean = is.isBoolean;
56
46
  exports.isComponent = is.isComponent;
@@ -73,4 +63,3 @@ exports.isUrl = is.isUrl;
73
63
  exports.objectToString = is.objectToString;
74
64
  exports.toRawType = is.toRawType;
75
65
  exports.toTypeString = is.toTypeString;
76
- exports.WS = ws.WS;
package/dist/index.d.cts CHANGED
@@ -1,8 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.cjs';
2
- export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.cjs';
3
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.cjs';
4
- export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.cjs';
5
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
6
4
  import 'element-plus';
7
5
  import 'vue';
8
- import 'dayjs';
package/dist/index.d.mts CHANGED
@@ -1,8 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.mjs';
2
- export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.mjs';
3
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
4
- export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.mjs';
5
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
6
4
  import 'element-plus';
7
5
  import 'vue';
8
- import 'dayjs';
package/dist/index.d.ts CHANGED
@@ -1,8 +1,5 @@
1
1
  export { $toast, clearStorage, clone, confirm, copy, debounce, delay, getStorage, getType, getUtilsBuildTime, getVariable, isEmpty, log, merge, mockValue, processWidth, random, setStorage, test, throttle, toLine, tryCatch, validate, validateForm, validateOnSubmit } from './base.js';
2
- export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.js';
3
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.js';
4
- export { WS, WSAutoReconnectOptions, WSHeartbeatOptions, WSOptions } from './ws.js';
5
- export { FormatBytesConvertOptions, FormatBytesOptions, FormatImgOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatImg, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
3
+ export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
6
4
  import 'element-plus';
7
5
  import 'vue';
8
- import 'dayjs';
package/dist/index.mjs CHANGED
@@ -1,10 +1,6 @@
1
- export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatImg, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.CTnx12Vx.mjs';
2
- export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute } from './day.mjs';
1
+ export { $ as $toast, c as clearStorage, a as clone, b as confirm, d as copy, e as debounce, f as delay, y as formatBytes, z as formatBytesConvert, A as formatDurationTime, B as formatTextToHtml, C as formatThousands, D as formatTime, E as formatToFixed, g as getStorage, h as getType, i as getUtilsBuildTime, j as getVariable, k as isEmpty, l as log, m as merge, n as mockValue, p as processWidth, r as random, s as setStorage, t as test, o as throttle, q as toLine, u as tryCatch, v as validate, w as validateForm, x as validateOnSubmit } from './shared/utils.C6HkWKyE.mjs';
3
2
  export { isArray, isBoolean, isComponent, isDate, isEmptyObject, isFunction, isIOS, isMap, isNumber, isObject, isPlainObject, isPromise, isRegExp, isSVGElement, isSet, isString, isStringNumber, isSymbol, isUrl, objectToString, toRawType, toTypeString } from './is.mjs';
4
- export { WS } from './ws.mjs';
5
3
  import 'vue';
6
4
  import 'consola';
7
5
  import 'es-toolkit';
8
6
  import 'element-plus';
9
- import 'dayjs';
10
- import 'qs';
@@ -177,18 +177,6 @@ function formatDurationTime(timestamp, cFormat = "{d}\u5929{h}\u65F6{i}\u5206{s}
177
177
  return String(value || "00");
178
178
  });
179
179
  }
180
- function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {}) {
181
- if (photoName.startsWith("http") || photoName.startsWith("https")) {
182
- return photoName;
183
- }
184
- if (photoName.indexOf(".") === -1) {
185
- photoName = photoName + ".png";
186
- }
187
- const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
188
- const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
189
- const mergeSrc = `${addLastSlash}${photoName}`;
190
- return new URL(`../${addLastBasePathSlash}${mergeSrc}`, import.meta.url).href;
191
- }
192
180
  function formatToFixed(value, options) {
193
181
  if (typeof options === "number") {
194
182
  options = { digit: options };
@@ -234,6 +222,9 @@ const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
234
222
  const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
235
223
  const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
236
224
  const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
225
+ const SHIJINGSHAN_CONFIRM_BOX_CLASS = "s-message-box--shijingshan";
226
+ const SHIJINGSHAN_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--shijingshan";
227
+ const SHIJINGSHAN_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--shijingshan";
237
228
  function _getBrowserStorage(isSession = false) {
238
229
  if (typeof window === "undefined") {
239
230
  return null;
@@ -800,7 +791,7 @@ function toLine(text, connect = "-") {
800
791
  const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
801
792
  function processWidth(initValue, isBase = false) {
802
793
  const raw = unref(initValue);
803
- if (!raw) {
794
+ if (raw === void 0 || raw === null || raw === "") {
804
795
  return isBase ? "" : {};
805
796
  }
806
797
  const str = typeof raw === "number" ? `${raw}` : raw;
@@ -844,8 +835,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
844
835
  const context = lastThis;
845
836
  lastArgs = void 0;
846
837
  lastThis = void 0;
847
- result = fn.apply(context, args);
848
- resultCallback?.(result);
838
+ const nextResult = fn.apply(context, args);
839
+ result = nextResult;
840
+ resultCallback?.(nextResult);
849
841
  return result;
850
842
  };
851
843
  const flush = () => {
@@ -957,6 +949,7 @@ function confirm(message, options = {}, appContext = null) {
957
949
  const resolvedAppendTo = _resolveAppendTarget(appendTo);
958
950
  const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
959
951
  const isChenghuaTheme = theme === "chenghua";
952
+ const isShijingshanTheme = theme === "shijingshan";
960
953
  const mergeOptions = {
961
954
  title: "\u63D0\u793A",
962
955
  draggable: true,
@@ -967,15 +960,21 @@ function confirm(message, options = {}, appContext = null) {
967
960
  ...messageBoxOptions,
968
961
  appendTo: resolvedAppendTo,
969
962
  appContext: resolvedAppContext,
970
- customClass: _mergeClassNames(isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS, customClass),
963
+ customClass: _mergeClassNames(
964
+ isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
965
+ isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
966
+ customClass
967
+ ),
971
968
  confirmButtonClass: _mergeClassNames(
972
969
  DEFAULT_CONFIRM_BUTTON_CLASS,
973
970
  isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
971
+ isShijingshanTheme && SHIJINGSHAN_CONFIRM_BUTTON_CLASS,
974
972
  confirmButtonClass
975
973
  ),
976
974
  cancelButtonClass: _mergeClassNames(
977
975
  DEFAULT_CANCEL_BUTTON_CLASS,
978
976
  isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
977
+ isShijingshanTheme && SHIJINGSHAN_CANCEL_BUTTON_CLASS,
979
978
  cancelButtonClass
980
979
  )
981
980
  };
@@ -1034,11 +1033,11 @@ function getVariable(propertyName, fallback = "") {
1034
1033
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1035
1034
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1036
1035
  {
1037
- return "2026-07-02 16:09:23";
1036
+ return "2026-07-10 15:30:17";
1038
1037
  }
1039
1038
  }
1040
1039
  function test() {
1041
1040
  return `build time: ${getUtilsBuildTime()}`;
1042
1041
  }
1043
1042
 
1044
- export { $toast as $, formatDurationTime as A, formatImg as B, formatTextToHtml as C, formatThousands as D, formatTime as E, formatToFixed as F, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e, delay as f, getStorage as g, getType as h, getUtilsBuildTime as i, getVariable as j, isEmpty as k, log as l, merge as m, mockValue as n, throttle as o, processWidth as p, toLine as q, random as r, setStorage as s, test as t, tryCatch as u, validate as v, validateForm as w, validateOnSubmit as x, formatBytes as y, formatBytesConvert as z };
1043
+ export { $toast as $, formatDurationTime as A, formatTextToHtml as B, formatThousands as C, formatTime as D, formatToFixed as E, clone as a, confirm as b, clearStorage as c, copy as d, debounce as e, delay as f, getStorage as g, getType as h, getUtilsBuildTime as i, getVariable as j, isEmpty as k, log as l, merge as m, mockValue as n, throttle as o, processWidth as p, toLine as q, random as r, setStorage as s, test as t, tryCatch as u, validate as v, validateForm as w, validateOnSubmit as x, formatBytes as y, formatBytesConvert as z };
@@ -6,7 +6,6 @@ const esToolkit = require('es-toolkit');
6
6
  const elementPlus = require('element-plus');
7
7
  const is = require('../is.cjs');
8
8
 
9
- var _documentCurrentScript = typeof document !== 'undefined' ? document.currentScript : null;
10
9
  function formatBytes(bytes, options = {}) {
11
10
  let { digit = 2, thousands = false, prefix = "", suffix = "", roundType = "floor" } = options;
12
11
  if (is.isStringNumber(bytes) || is.isNumber(bytes)) {
@@ -180,18 +179,6 @@ function formatDurationTime(timestamp, cFormat = "{d}\u5929{h}\u65F6{i}\u5206{s}
180
179
  return String(value || "00");
181
180
  });
182
181
  }
183
- function formatImg(photoName, addPath = "", { basePath = "assets/images" } = {}) {
184
- if (photoName.startsWith("http") || photoName.startsWith("https")) {
185
- return photoName;
186
- }
187
- if (photoName.indexOf(".") === -1) {
188
- photoName = photoName + ".png";
189
- }
190
- const addLastSlash = addPath.endsWith("/") || !addPath ? addPath : `${addPath}/`;
191
- const addLastBasePathSlash = basePath.endsWith("/") || !basePath ? basePath : `${basePath}/`;
192
- const mergeSrc = `${addLastSlash}${photoName}`;
193
- return new URL(`../${addLastBasePathSlash}${mergeSrc}`, (typeof document === 'undefined' ? require('u' + 'rl').pathToFileURL(__filename).href : (_documentCurrentScript && _documentCurrentScript.tagName.toUpperCase() === 'SCRIPT' && _documentCurrentScript.src || new URL('shared/utils.DUIw9c4e.cjs', document.baseURI).href))).href;
194
- }
195
182
  function formatToFixed(value, options) {
196
183
  if (typeof options === "number") {
197
184
  options = { digit: options };
@@ -237,6 +224,9 @@ const DEFAULT_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn";
237
224
  const CHENGHUA_CONFIRM_BOX_CLASS = "s-message-box--chenghua";
238
225
  const CHENGHUA_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--chenghua";
239
226
  const CHENGHUA_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--chenghua";
227
+ const SHIJINGSHAN_CONFIRM_BOX_CLASS = "s-message-box--shijingshan";
228
+ const SHIJINGSHAN_CONFIRM_BUTTON_CLASS = "s-message-box__confirm-btn--shijingshan";
229
+ const SHIJINGSHAN_CANCEL_BUTTON_CLASS = "s-message-box__cancel-btn--shijingshan";
240
230
  function _getBrowserStorage(isSession = false) {
241
231
  if (typeof window === "undefined") {
242
232
  return null;
@@ -803,7 +793,7 @@ function toLine(text, connect = "-") {
803
793
  const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
804
794
  function processWidth(initValue, isBase = false) {
805
795
  const raw = vue.unref(initValue);
806
- if (!raw) {
796
+ if (raw === void 0 || raw === null || raw === "") {
807
797
  return isBase ? "" : {};
808
798
  }
809
799
  const str = typeof raw === "number" ? `${raw}` : raw;
@@ -847,8 +837,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
847
837
  const context = lastThis;
848
838
  lastArgs = void 0;
849
839
  lastThis = void 0;
850
- result = fn.apply(context, args);
851
- resultCallback?.(result);
840
+ const nextResult = fn.apply(context, args);
841
+ result = nextResult;
842
+ resultCallback?.(nextResult);
852
843
  return result;
853
844
  };
854
845
  const flush = () => {
@@ -960,6 +951,7 @@ function confirm(message, options = {}, appContext = null) {
960
951
  const resolvedAppendTo = _resolveAppendTarget(appendTo);
961
952
  const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
962
953
  const isChenghuaTheme = theme === "chenghua";
954
+ const isShijingshanTheme = theme === "shijingshan";
963
955
  const mergeOptions = {
964
956
  title: "\u63D0\u793A",
965
957
  draggable: true,
@@ -970,15 +962,21 @@ function confirm(message, options = {}, appContext = null) {
970
962
  ...messageBoxOptions,
971
963
  appendTo: resolvedAppendTo,
972
964
  appContext: resolvedAppContext,
973
- customClass: _mergeClassNames(isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS, customClass),
965
+ customClass: _mergeClassNames(
966
+ isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
967
+ isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
968
+ customClass
969
+ ),
974
970
  confirmButtonClass: _mergeClassNames(
975
971
  DEFAULT_CONFIRM_BUTTON_CLASS,
976
972
  isChenghuaTheme && CHENGHUA_CONFIRM_BUTTON_CLASS,
973
+ isShijingshanTheme && SHIJINGSHAN_CONFIRM_BUTTON_CLASS,
977
974
  confirmButtonClass
978
975
  ),
979
976
  cancelButtonClass: _mergeClassNames(
980
977
  DEFAULT_CANCEL_BUTTON_CLASS,
981
978
  isChenghuaTheme && CHENGHUA_CANCEL_BUTTON_CLASS,
979
+ isShijingshanTheme && SHIJINGSHAN_CANCEL_BUTTON_CLASS,
982
980
  cancelButtonClass
983
981
  )
984
982
  };
@@ -1037,7 +1035,7 @@ function getVariable(propertyName, fallback = "") {
1037
1035
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1038
1036
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1039
1037
  {
1040
- return "2026-07-02 16:09:23";
1038
+ return "2026-07-10 15:30:17";
1041
1039
  }
1042
1040
  }
1043
1041
  function test() {
@@ -1054,7 +1052,6 @@ exports.delay = delay;
1054
1052
  exports.formatBytes = formatBytes;
1055
1053
  exports.formatBytesConvert = formatBytesConvert;
1056
1054
  exports.formatDurationTime = formatDurationTime;
1057
- exports.formatImg = formatImg;
1058
1055
  exports.formatTextToHtml = formatTextToHtml;
1059
1056
  exports.formatThousands = formatThousands;
1060
1057
  exports.formatTime = formatTime;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybz-components/utils",
3
- "version": "0.0.12",
3
+ "version": "1.0.1",
4
4
  "description": "utils of sybz-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -16,6 +16,8 @@
16
16
  },
17
17
  "scripts": {
18
18
  "build": "npx unbuild",
19
+ "typecheck": "tsc --noEmit -p tsconfig.json",
20
+ "test": "vitest run --root ../.. packages/utils/src",
19
21
  "stub": "npx unbuild --stub",
20
22
  "releaseOld": "npx unbuild && npm version patch && git add . && git commit -m \"chore: release @sybz-components/utils v$(npm pkg get version | sed 's/\"//g')\" && git push origin && npm publish",
21
23
  "release": "node ./scripts/release.mjs"
@@ -25,11 +27,9 @@
25
27
  "@vue/reactivity": "^3.5.18",
26
28
  "@vue/shared": "^3.5.18",
27
29
  "consola": "^3.4.2",
28
- "dayjs": "^1.11.19",
29
30
  "element-plus": "^2.11.5",
30
31
  "es-toolkit": "^1.39.10",
31
32
  "lodash-es": "^4.17.21",
32
- "qs": "^6.15.0",
33
33
  "vue": "3.4.15"
34
34
  }
35
35
  }
package/dist/day.cjs DELETED
@@ -1,41 +0,0 @@
1
- 'use strict';
2
-
3
- const dayjs = require('dayjs');
4
-
5
- function _interopDefaultCompat (e) { return e && typeof e === 'object' && 'default' in e ? e.default : e; }
6
-
7
- const dayjs__default = /*#__PURE__*/_interopDefaultCompat(dayjs);
8
-
9
- function formatDate(date, format = "YYYY-MM-DD HH:mm:ss") {
10
- return dayjs__default(date || /* @__PURE__ */ new Date()).format(format);
11
- }
12
- const formatDateToDay = (date) => formatDate(date, "YYYY-MM-DD");
13
- const formatDateToMinute = (date) => formatDate(date, "YYYY-MM-DD HH:mm");
14
- function diffDate(date1, date2 = dayjs__default(), format = "second") {
15
- if (!date1) return;
16
- return dayjs__default(date1).diff(dayjs__default(date2), format);
17
- }
18
- function diffDateFromCurrent(second) {
19
- if (second >= 60 * 60 * 24 * 365) {
20
- return `${parseInt(String(second / (60 * 60 * 24 * 365)))}\u5E74\u524D`;
21
- }
22
- if (second >= 60 * 60 * 24 * 30) {
23
- return `${parseInt(String(second / (60 * 60 * 24 * 30)))}\u6708\u524D`;
24
- }
25
- if (second >= 60 * 60 * 24) {
26
- return `${parseInt(String(second / (60 * 60 * 24)))}\u5929\u524D`;
27
- }
28
- if (second >= 60 * 60) {
29
- return `${parseInt(String(second / (60 * 60)))}\u5C0F\u65F6\u524D`;
30
- }
31
- if (second >= 60) {
32
- return `${parseInt(String(second / 60))}\u5206\u949F\u524D`;
33
- }
34
- return `${parseInt(String(second))}\u79D2\u524D`;
35
- }
36
-
37
- exports.diffDate = diffDate;
38
- exports.diffDateFromCurrent = diffDateFromCurrent;
39
- exports.formatDate = formatDate;
40
- exports.formatDateToDay = formatDateToDay;
41
- exports.formatDateToMinute = formatDateToMinute;
package/dist/day.d.cts DELETED
@@ -1,81 +0,0 @@
1
- import { ConfigType, QUnitType, OpUnitType } from 'dayjs';
2
-
3
- type DayUnit = QUnitType | OpUnitType;
4
- /**
5
- * 使用 `dayjs` 格式化日期。
6
- *
7
- * @param date 要格式化的日期值。为空时默认使用当前时间。
8
- * @param format 输出格式,默认 `YYYY-MM-DD HH:mm:ss`。
9
- * @returns 格式化后的日期字符串。
10
- *
11
- * @example
12
- * formatDate('2026-04-24 12:30:45')
13
- * // => '2026-04-24 12:30:45'
14
- *
15
- * @example
16
- * formatDate('2026-04-24 12:30:45', 'YYYY/MM/DD')
17
- * // => '2026/04/24'
18
- */
19
- declare function formatDate(date?: ConfigType, format?: string): string;
20
- /**
21
- * 将日期格式化为 `YYYY-MM-DD`。
22
- *
23
- * @param date 要格式化的日期值。
24
- * @returns 形如 `2026-04-24` 的字符串。
25
- *
26
- * @example
27
- * formatDateToDay(new Date())
28
- *
29
- * @example
30
- * formatDateToDay('2026-04-24 12:30:45')
31
- * // => '2026-04-24'
32
- */
33
- declare const formatDateToDay: (date: ConfigType) => string;
34
- /**
35
- * 将日期格式化为 `YYYY-MM-DD HH:mm`。
36
- *
37
- * @param date 要格式化的日期值。
38
- * @returns 形如 `2026-04-24 12:30` 的字符串。
39
- *
40
- * @example
41
- * formatDateToMinute(new Date())
42
- *
43
- * @example
44
- * formatDateToMinute('2026-04-24 12:30:45')
45
- * // => '2026-04-24 12:30'
46
- */
47
- declare const formatDateToMinute: (date: ConfigType) => string;
48
- /**
49
- * 计算两个日期之间的差值。
50
- *
51
- * @param date1 起始时间。未传时返回 `undefined`。
52
- * @param date2 对比时间,默认取当前时间。
53
- * @param format 差值单位,默认 `second`。
54
- * @returns 两个时间的差值。
55
- *
56
- * @example
57
- * diffDate('2026-04-24 12:00:00', '2026-04-24 11:59:00')
58
- * // => 60
59
- *
60
- * @example
61
- * diffDate('2026-04-24 12:00:00', '2026-04-24 11:30:00', 'minute')
62
- * // => 30
63
- */
64
- declare function diffDate(date1: ConfigType, date2?: ConfigType, format?: DayUnit): number | undefined;
65
- /**
66
- * 将秒数转换成“几秒前 / 几分钟前 / 几小时前 / 几天前”这类相对时间文案。
67
- *
68
- * @param second 距离当前时间的秒数。
69
- * @returns 中文相对时间描述。
70
- *
71
- * @example
72
- * diffDateFromCurrent(45)
73
- * // => '45秒前'
74
- *
75
- * @example
76
- * diffDateFromCurrent(3600)
77
- * // => '1小时前'
78
- */
79
- declare function diffDateFromCurrent(second: number): string;
80
-
81
- export { diffDate, diffDateFromCurrent, formatDate, formatDateToDay, formatDateToMinute };