@sybz-components/utils 1.0.1 → 1.0.3

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.q3_d_9Nx.cjs');
6
+ const format = require('./shared/utils.BdgV5p_d.cjs');
7
7
  require('element-plus');
8
8
  require('./is.cjs');
9
9
 
package/dist/base.d.cts CHANGED
@@ -1,7 +1,6 @@
1
- import * as element_plus from 'element-plus';
2
- import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
3
1
  import * as vue from 'vue';
4
- import { VNode, Ref, AppContext } from 'vue';
2
+ import { AppContext, VNode, Ref } from 'vue';
3
+ import { ElMessageBoxOptions, MessageOptions, ElMessageBox } from 'element-plus';
5
4
 
6
5
  type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
7
6
  type StorageValue = unknown;
@@ -116,7 +115,16 @@ interface CopyOptions extends ToastOptions {
116
115
  }
117
116
  type WidthInput = string | number | Ref<string | number>;
118
117
  type ConfirmMessage = string | VNode | (() => VNode);
118
+ type ConfirmVariant = 'default' | 'delete' | 'warning';
119
119
  interface ConfirmOptions extends ElMessageBoxOptions {
120
+ /**
121
+ * 确认框语义样式。
122
+ */
123
+ variant?: ConfirmVariant;
124
+ /**
125
+ * 删除场景中要操作的目标名称。
126
+ */
127
+ target?: string;
120
128
  /**
121
129
  * 确认框主题。
122
130
  */
@@ -136,8 +144,11 @@ interface TryCatchResult<T> {
136
144
  */
137
145
  error: any;
138
146
  }
147
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
148
+ type ShortType = 's' | 'i' | 'e' | 'w';
149
+ type ToastType = MessageType | ShortType;
139
150
  /**
140
- * 显示消息提示。
151
+ * @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
141
152
  *
142
153
  * 支持三种常见写法:
143
154
  * 1. `$toast('保存成功')`
@@ -150,22 +161,22 @@ interface TryCatchResult<T> {
150
161
  * @returns 无返回值。
151
162
  *
152
163
  * @example
153
- * $toast('保存成功')
164
+ * ```ts
165
+ * import { $toast } from '@sybz-components/utils'
154
166
  *
155
- * @example
167
+ * $toast('保存成功')
156
168
  * $toast('保存失败', 'e')
157
- *
158
- * @example
159
169
  * $toast({
160
170
  * message: '自定义提示',
161
171
  * type: 'warning',
162
172
  * duration: 1000,
163
173
  * closeAll: true,
164
174
  * })
175
+ * $toast.error('接口请求失败', { showClose: true })
176
+ * ```
177
+ *
178
+ * @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
165
179
  */
166
- type MessageType = 'success' | 'info' | 'error' | 'warning';
167
- type ShortType = 's' | 'i' | 'e' | 'w';
168
- type ToastType = MessageType | ShortType;
169
180
  declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
170
181
  declare namespace $toast {
171
182
  var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
@@ -568,8 +579,16 @@ declare function debounce<T extends Func>(func: T, delay?: number, immediate?: b
568
579
  * showCancelButton: true,
569
580
  * appendTo: '#dialogRoot',
570
581
  * })
582
+ *
583
+ * @example
584
+ * await confirm({
585
+ * variant: 'delete',
586
+ * target: '机器之心公众号',
587
+ * theme: 'shijingshan',
588
+ * })
571
589
  */
572
- declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): Promise<element_plus.MessageBoxData>;
590
+ declare function confirm(options: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
591
+ declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
573
592
  /**
574
593
  * 读取根节点上的 CSS 自定义变量。
575
594
  *
@@ -600,3 +619,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
600
619
  declare function test(): string;
601
620
 
602
621
  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 };
622
+ export type { ConfirmOptions };
package/dist/base.d.mts CHANGED
@@ -1,7 +1,6 @@
1
- import * as element_plus from 'element-plus';
2
- import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
3
1
  import * as vue from 'vue';
4
- import { VNode, Ref, AppContext } from 'vue';
2
+ import { AppContext, VNode, Ref } from 'vue';
3
+ import { ElMessageBoxOptions, MessageOptions, ElMessageBox } from 'element-plus';
5
4
 
6
5
  type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
7
6
  type StorageValue = unknown;
@@ -116,7 +115,16 @@ interface CopyOptions extends ToastOptions {
116
115
  }
117
116
  type WidthInput = string | number | Ref<string | number>;
118
117
  type ConfirmMessage = string | VNode | (() => VNode);
118
+ type ConfirmVariant = 'default' | 'delete' | 'warning';
119
119
  interface ConfirmOptions extends ElMessageBoxOptions {
120
+ /**
121
+ * 确认框语义样式。
122
+ */
123
+ variant?: ConfirmVariant;
124
+ /**
125
+ * 删除场景中要操作的目标名称。
126
+ */
127
+ target?: string;
120
128
  /**
121
129
  * 确认框主题。
122
130
  */
@@ -136,8 +144,11 @@ interface TryCatchResult<T> {
136
144
  */
137
145
  error: any;
138
146
  }
147
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
148
+ type ShortType = 's' | 'i' | 'e' | 'w';
149
+ type ToastType = MessageType | ShortType;
139
150
  /**
140
- * 显示消息提示。
151
+ * @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
141
152
  *
142
153
  * 支持三种常见写法:
143
154
  * 1. `$toast('保存成功')`
@@ -150,22 +161,22 @@ interface TryCatchResult<T> {
150
161
  * @returns 无返回值。
151
162
  *
152
163
  * @example
153
- * $toast('保存成功')
164
+ * ```ts
165
+ * import { $toast } from '@sybz-components/utils'
154
166
  *
155
- * @example
167
+ * $toast('保存成功')
156
168
  * $toast('保存失败', 'e')
157
- *
158
- * @example
159
169
  * $toast({
160
170
  * message: '自定义提示',
161
171
  * type: 'warning',
162
172
  * duration: 1000,
163
173
  * closeAll: true,
164
174
  * })
175
+ * $toast.error('接口请求失败', { showClose: true })
176
+ * ```
177
+ *
178
+ * @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
165
179
  */
166
- type MessageType = 'success' | 'info' | 'error' | 'warning';
167
- type ShortType = 's' | 'i' | 'e' | 'w';
168
- type ToastType = MessageType | ShortType;
169
180
  declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
170
181
  declare namespace $toast {
171
182
  var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
@@ -568,8 +579,16 @@ declare function debounce<T extends Func>(func: T, delay?: number, immediate?: b
568
579
  * showCancelButton: true,
569
580
  * appendTo: '#dialogRoot',
570
581
  * })
582
+ *
583
+ * @example
584
+ * await confirm({
585
+ * variant: 'delete',
586
+ * target: '机器之心公众号',
587
+ * theme: 'shijingshan',
588
+ * })
571
589
  */
572
- declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): Promise<element_plus.MessageBoxData>;
590
+ declare function confirm(options: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
591
+ declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
573
592
  /**
574
593
  * 读取根节点上的 CSS 自定义变量。
575
594
  *
@@ -600,3 +619,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
600
619
  declare function test(): string;
601
620
 
602
621
  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 };
622
+ export type { ConfirmOptions };
package/dist/base.d.ts CHANGED
@@ -1,7 +1,6 @@
1
- import * as element_plus from 'element-plus';
2
- import { MessageOptions, ElMessageBoxOptions } from 'element-plus';
3
1
  import * as vue from 'vue';
4
- import { VNode, Ref, AppContext } from 'vue';
2
+ import { AppContext, VNode, Ref } from 'vue';
3
+ import { ElMessageBoxOptions, MessageOptions, ElMessageBox } from 'element-plus';
5
4
 
6
5
  type Func<Args extends any[] = any[], Return = any> = (...args: Args) => Return;
7
6
  type StorageValue = unknown;
@@ -116,7 +115,16 @@ interface CopyOptions extends ToastOptions {
116
115
  }
117
116
  type WidthInput = string | number | Ref<string | number>;
118
117
  type ConfirmMessage = string | VNode | (() => VNode);
118
+ type ConfirmVariant = 'default' | 'delete' | 'warning';
119
119
  interface ConfirmOptions extends ElMessageBoxOptions {
120
+ /**
121
+ * 确认框语义样式。
122
+ */
123
+ variant?: ConfirmVariant;
124
+ /**
125
+ * 删除场景中要操作的目标名称。
126
+ */
127
+ target?: string;
120
128
  /**
121
129
  * 确认框主题。
122
130
  */
@@ -136,8 +144,11 @@ interface TryCatchResult<T> {
136
144
  */
137
145
  error: any;
138
146
  }
147
+ type MessageType = 'success' | 'info' | 'error' | 'warning';
148
+ type ShortType = 's' | 'i' | 'e' | 'w';
149
+ type ToastType = MessageType | ShortType;
139
150
  /**
140
- * 显示消息提示。
151
+ * @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
141
152
  *
142
153
  * 支持三种常见写法:
143
154
  * 1. `$toast('保存成功')`
@@ -150,22 +161,22 @@ interface TryCatchResult<T> {
150
161
  * @returns 无返回值。
151
162
  *
152
163
  * @example
153
- * $toast('保存成功')
164
+ * ```ts
165
+ * import { $toast } from '@sybz-components/utils'
154
166
  *
155
- * @example
167
+ * $toast('保存成功')
156
168
  * $toast('保存失败', 'e')
157
- *
158
- * @example
159
169
  * $toast({
160
170
  * message: '自定义提示',
161
171
  * type: 'warning',
162
172
  * duration: 1000,
163
173
  * closeAll: true,
164
174
  * })
175
+ * $toast.error('接口请求失败', { showClose: true })
176
+ * ```
177
+ *
178
+ * @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
165
179
  */
166
- type MessageType = 'success' | 'info' | 'error' | 'warning';
167
- type ShortType = 's' | 'i' | 'e' | 'w';
168
- type ToastType = MessageType | ShortType;
169
180
  declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
170
181
  declare namespace $toast {
171
182
  var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
@@ -568,8 +579,16 @@ declare function debounce<T extends Func>(func: T, delay?: number, immediate?: b
568
579
  * showCancelButton: true,
569
580
  * appendTo: '#dialogRoot',
570
581
  * })
582
+ *
583
+ * @example
584
+ * await confirm({
585
+ * variant: 'delete',
586
+ * target: '机器之心公众号',
587
+ * theme: 'shijingshan',
588
+ * })
571
589
  */
572
- declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): Promise<element_plus.MessageBoxData>;
590
+ declare function confirm(options: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
591
+ declare function confirm(message: ConfirmMessage, options?: ConfirmOptions, appContext?: AppContext | null): ReturnType<typeof ElMessageBox.confirm>;
573
592
  /**
574
593
  * 读取根节点上的 CSS 自定义变量。
575
594
  *
@@ -600,3 +619,4 @@ declare function getUtilsBuildTime(fallback?: string): string;
600
619
  declare function test(): string;
601
620
 
602
621
  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 };
622
+ export type { ConfirmOptions };
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.C6HkWKyE.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.D_q5VNCx.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.q3_d_9Nx.cjs');
3
+ const format = require('./shared/utils.BdgV5p_d.cjs');
4
4
  require('./is.cjs');
5
5
  require('consola');
6
6
  require('vue');
package/dist/format.mjs CHANGED
@@ -1,4 +1,4 @@
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';
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.D_q5VNCx.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.q3_d_9Nx.cjs');
3
+ const format = require('./shared/utils.BdgV5p_d.cjs');
4
4
  const is = require('./is.cjs');
5
5
  require('vue');
6
6
  require('consola');
package/dist/index.d.cts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ export { $toast, ConfirmOptions, 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
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';
3
3
  export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
4
- import 'element-plus';
5
4
  import 'vue';
5
+ import 'element-plus';
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ export { $toast, ConfirmOptions, 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
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';
3
3
  export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
4
- import 'element-plus';
5
4
  import 'vue';
5
+ import 'element-plus';
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
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';
1
+ export { $toast, ConfirmOptions, 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
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';
3
3
  export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
4
- import 'element-plus';
5
4
  import 'vue';
5
+ import 'element-plus';
package/dist/index.mjs CHANGED
@@ -1,4 +1,4 @@
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';
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.D_q5VNCx.mjs';
2
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';
3
3
  import 'vue';
4
4
  import 'consola';
@@ -110,7 +110,7 @@ function formatTime(time = /* @__PURE__ */ new Date(), cFormat = "{y}-{m}-{d} {h
110
110
  } else if (dateOnlyRegex.test(timeStr)) {
111
111
  const [, year, month, day] = timeStr.match(dateOnlyRegex);
112
112
  date = new Date(Number(year), Number(month) - 1, Number(day));
113
- } else if (timeStr.includes(".") && !isNaN(parseFloat(timeStr))) {
113
+ } else if (/^[+-]?\d+\.\d+$/.test(timeStr)) {
114
114
  date = new Date(parseFloat(timeStr) * 1e3);
115
115
  } else if (/^\d{10}$/.test(timeStr)) {
116
116
  date = new Date(parseInt(timeStr) * 1e3);
@@ -366,7 +366,7 @@ function clearStorage(str = "") {
366
366
  function _isObjectWithExclude(obj) {
367
367
  return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
368
368
  }
369
- function validateForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
369
+ function validateForm(ref, { message = "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574", detail = false, showMessage = true } = {}) {
370
370
  return new Promise((resolve, reject) => {
371
371
  vue.unref(ref).validate((valid, status) => {
372
372
  if (valid) {
@@ -937,9 +937,16 @@ function debounce(func, delay2 = 500, immediate, resultCallback) {
937
937
  };
938
938
  return _debounce;
939
939
  }
940
- function confirm(message, options = {}, appContext = null) {
940
+ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null) {
941
+ const isOptionsCall = typeof messageOrOptions === "object" && messageOrOptions !== null && !vue.isVNode(messageOrOptions);
942
+ const options = isOptionsCall ? messageOrOptions : optionsOrAppContext ?? {};
943
+ const message = isOptionsCall ? options.message ?? "" : messageOrOptions;
944
+ const argumentAppContext = isOptionsCall ? optionsOrAppContext : appContext;
941
945
  const {
946
+ message: _message,
942
947
  theme,
948
+ variant = "default",
949
+ target,
943
950
  customClass,
944
951
  confirmButtonClass,
945
952
  cancelButtonClass,
@@ -947,11 +954,13 @@ function confirm(message, options = {}, appContext = null) {
947
954
  appContext: optionAppContext,
948
955
  ...messageBoxOptions
949
956
  } = options;
950
- const resolvedMessage = typeof message === "function" ? message() : message;
957
+ const inputMessage = typeof message === "function" ? message() : message;
958
+ const resolvedMessage = variant === "delete" && target !== void 0 && !inputMessage ? `\u786E\u8BA4\u8981\u5220\u9664<code type="danger">${_escapeHtml(target)}</code>\u5417? \u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002` : inputMessage;
951
959
  const resolvedAppendTo = _resolveAppendTarget(appendTo);
952
- const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
960
+ const resolvedAppContext = _resolveAppContext(optionAppContext || argumentAppContext);
953
961
  const isChenghuaTheme = theme === "chenghua";
954
962
  const isShijingshanTheme = theme === "shijingshan";
963
+ const variantOptions = variant === "delete" ? { title: "\u5220\u9664\u786E\u8BA4", confirmButtonText: "\u5220\u9664" } : variant === "warning" ? { title: "\u8B66\u544A" } : {};
955
964
  const mergeOptions = {
956
965
  title: "\u63D0\u793A",
957
966
  draggable: true,
@@ -959,12 +968,14 @@ function confirm(message, options = {}, appContext = null) {
959
968
  cancelButtonText: "\u53D6\u6D88",
960
969
  confirmButtonText: "\u786E\u5B9A",
961
970
  dangerouslyUseHTMLString: true,
971
+ ...variantOptions,
962
972
  ...messageBoxOptions,
963
973
  appendTo: resolvedAppendTo,
964
974
  appContext: resolvedAppContext,
965
975
  customClass: _mergeClassNames(
966
976
  isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
967
977
  isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
978
+ variant !== "default" && `s-message-box--${variant}`,
968
979
  customClass
969
980
  ),
970
981
  confirmButtonClass: _mergeClassNames(
@@ -982,6 +993,18 @@ function confirm(message, options = {}, appContext = null) {
982
993
  };
983
994
  return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
984
995
  }
996
+ function _escapeHtml(value) {
997
+ return value.replace(/[&<>'"]/g, (character) => {
998
+ const entities = {
999
+ "&": "&amp;",
1000
+ "<": "&lt;",
1001
+ ">": "&gt;",
1002
+ "'": "&#39;",
1003
+ '"': "&quot;"
1004
+ };
1005
+ return entities[character];
1006
+ });
1007
+ }
985
1008
  function _mergeClassNames(...classNames) {
986
1009
  return classNames.filter(Boolean).join(" ");
987
1010
  }
@@ -1035,7 +1058,7 @@ function getVariable(propertyName, fallback = "") {
1035
1058
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1036
1059
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1037
1060
  {
1038
- return "2026-07-10 15:30:17";
1061
+ return "2026-08-05 15:34:14";
1039
1062
  }
1040
1063
  }
1041
1064
  function test() {
@@ -1,4 +1,4 @@
1
- import { isRef, unref, toRaw } from 'vue';
1
+ import { isRef, unref, isVNode, toRaw } from 'vue';
2
2
  import { consola } from 'consola';
3
3
  import { cloneDeep } from 'es-toolkit';
4
4
  import { ElMessage, ElMessageBox } from 'element-plus';
@@ -108,7 +108,7 @@ function formatTime(time = /* @__PURE__ */ new Date(), cFormat = "{y}-{m}-{d} {h
108
108
  } else if (dateOnlyRegex.test(timeStr)) {
109
109
  const [, year, month, day] = timeStr.match(dateOnlyRegex);
110
110
  date = new Date(Number(year), Number(month) - 1, Number(day));
111
- } else if (timeStr.includes(".") && !isNaN(parseFloat(timeStr))) {
111
+ } else if (/^[+-]?\d+\.\d+$/.test(timeStr)) {
112
112
  date = new Date(parseFloat(timeStr) * 1e3);
113
113
  } else if (/^\d{10}$/.test(timeStr)) {
114
114
  date = new Date(parseInt(timeStr) * 1e3);
@@ -364,7 +364,7 @@ function clearStorage(str = "") {
364
364
  function _isObjectWithExclude(obj) {
365
365
  return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
366
366
  }
367
- function validateForm(ref, { message = "\u8868\u5355\u6821\u9A8C\u9519\u8BEF, \u8BF7\u68C0\u67E5", detail = false, showMessage = true } = {}) {
367
+ function validateForm(ref, { message = "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574", detail = false, showMessage = true } = {}) {
368
368
  return new Promise((resolve, reject) => {
369
369
  unref(ref).validate((valid, status) => {
370
370
  if (valid) {
@@ -935,9 +935,16 @@ function debounce(func, delay2 = 500, immediate, resultCallback) {
935
935
  };
936
936
  return _debounce;
937
937
  }
938
- function confirm(message, options = {}, appContext = null) {
938
+ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null) {
939
+ const isOptionsCall = typeof messageOrOptions === "object" && messageOrOptions !== null && !isVNode(messageOrOptions);
940
+ const options = isOptionsCall ? messageOrOptions : optionsOrAppContext ?? {};
941
+ const message = isOptionsCall ? options.message ?? "" : messageOrOptions;
942
+ const argumentAppContext = isOptionsCall ? optionsOrAppContext : appContext;
939
943
  const {
944
+ message: _message,
940
945
  theme,
946
+ variant = "default",
947
+ target,
941
948
  customClass,
942
949
  confirmButtonClass,
943
950
  cancelButtonClass,
@@ -945,11 +952,13 @@ function confirm(message, options = {}, appContext = null) {
945
952
  appContext: optionAppContext,
946
953
  ...messageBoxOptions
947
954
  } = options;
948
- const resolvedMessage = typeof message === "function" ? message() : message;
955
+ const inputMessage = typeof message === "function" ? message() : message;
956
+ const resolvedMessage = variant === "delete" && target !== void 0 && !inputMessage ? `\u786E\u8BA4\u8981\u5220\u9664<code type="danger">${_escapeHtml(target)}</code>\u5417? \u5220\u9664\u540E\u4E0D\u53EF\u6062\u590D\u3002` : inputMessage;
949
957
  const resolvedAppendTo = _resolveAppendTarget(appendTo);
950
- const resolvedAppContext = _resolveAppContext(optionAppContext || appContext);
958
+ const resolvedAppContext = _resolveAppContext(optionAppContext || argumentAppContext);
951
959
  const isChenghuaTheme = theme === "chenghua";
952
960
  const isShijingshanTheme = theme === "shijingshan";
961
+ const variantOptions = variant === "delete" ? { title: "\u5220\u9664\u786E\u8BA4", confirmButtonText: "\u5220\u9664" } : variant === "warning" ? { title: "\u8B66\u544A" } : {};
953
962
  const mergeOptions = {
954
963
  title: "\u63D0\u793A",
955
964
  draggable: true,
@@ -957,12 +966,14 @@ function confirm(message, options = {}, appContext = null) {
957
966
  cancelButtonText: "\u53D6\u6D88",
958
967
  confirmButtonText: "\u786E\u5B9A",
959
968
  dangerouslyUseHTMLString: true,
969
+ ...variantOptions,
960
970
  ...messageBoxOptions,
961
971
  appendTo: resolvedAppendTo,
962
972
  appContext: resolvedAppContext,
963
973
  customClass: _mergeClassNames(
964
974
  isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
965
975
  isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
976
+ variant !== "default" && `s-message-box--${variant}`,
966
977
  customClass
967
978
  ),
968
979
  confirmButtonClass: _mergeClassNames(
@@ -980,6 +991,18 @@ function confirm(message, options = {}, appContext = null) {
980
991
  };
981
992
  return ElMessageBox.confirm(resolvedMessage, mergeOptions);
982
993
  }
994
+ function _escapeHtml(value) {
995
+ return value.replace(/[&<>'"]/g, (character) => {
996
+ const entities = {
997
+ "&": "&amp;",
998
+ "<": "&lt;",
999
+ ">": "&gt;",
1000
+ "'": "&#39;",
1001
+ '"': "&quot;"
1002
+ };
1003
+ return entities[character];
1004
+ });
1005
+ }
983
1006
  function _mergeClassNames(...classNames) {
984
1007
  return classNames.filter(Boolean).join(" ");
985
1008
  }
@@ -1033,7 +1056,7 @@ function getVariable(propertyName, fallback = "") {
1033
1056
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1034
1057
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1035
1058
  {
1036
- return "2026-07-10 15:30:17";
1059
+ return "2026-08-05 15:34:14";
1037
1060
  }
1038
1061
  }
1039
1062
  function test() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybz-components/utils",
3
- "version": "1.0.1",
3
+ "version": "1.0.3",
4
4
  "description": "utils of sybz-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",