@sybz-components/utils 1.0.0 → 1.0.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/base.cjs +1 -1
- package/dist/base.d.cts +11 -8
- package/dist/base.d.mts +11 -8
- package/dist/base.d.ts +11 -8
- package/dist/base.mjs +1 -1
- package/dist/format.cjs +1 -2
- package/dist/format.d.cts +2 -26
- package/dist/format.d.mts +2 -26
- package/dist/format.d.ts +2 -26
- package/dist/format.mjs +1 -1
- package/dist/index.cjs +1 -2
- package/dist/index.d.cts +1 -1
- package/dist/index.d.mts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{utils.aC91nrkh.cjs → utils.CJVcMXo1.cjs} +6 -19
- package/dist/shared/{utils.BEyMaMZg.mjs → utils.D2T1ouSy.mjs} +7 -18
- package/package.json +4 -3
package/dist/base.cjs
CHANGED
package/dist/base.d.cts
CHANGED
|
@@ -136,8 +136,11 @@ interface TryCatchResult<T> {
|
|
|
136
136
|
*/
|
|
137
137
|
error: any;
|
|
138
138
|
}
|
|
139
|
+
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
140
|
+
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
141
|
+
type ToastType = MessageType | ShortType;
|
|
139
142
|
/**
|
|
140
|
-
*
|
|
143
|
+
* @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
|
|
141
144
|
*
|
|
142
145
|
* 支持三种常见写法:
|
|
143
146
|
* 1. `$toast('保存成功')`
|
|
@@ -150,22 +153,22 @@ interface TryCatchResult<T> {
|
|
|
150
153
|
* @returns 无返回值。
|
|
151
154
|
*
|
|
152
155
|
* @example
|
|
153
|
-
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { $toast } from '@sybz-components/utils'
|
|
154
158
|
*
|
|
155
|
-
*
|
|
159
|
+
* $toast('保存成功')
|
|
156
160
|
* $toast('保存失败', 'e')
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
161
|
* $toast({
|
|
160
162
|
* message: '自定义提示',
|
|
161
163
|
* type: 'warning',
|
|
162
164
|
* duration: 1000,
|
|
163
165
|
* closeAll: true,
|
|
164
166
|
* })
|
|
167
|
+
* $toast.error('接口请求失败', { showClose: true })
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
|
|
165
171
|
*/
|
|
166
|
-
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
167
|
-
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
168
|
-
type ToastType = MessageType | ShortType;
|
|
169
172
|
declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
170
173
|
declare namespace $toast {
|
|
171
174
|
var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
|
package/dist/base.d.mts
CHANGED
|
@@ -136,8 +136,11 @@ interface TryCatchResult<T> {
|
|
|
136
136
|
*/
|
|
137
137
|
error: any;
|
|
138
138
|
}
|
|
139
|
+
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
140
|
+
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
141
|
+
type ToastType = MessageType | ShortType;
|
|
139
142
|
/**
|
|
140
|
-
*
|
|
143
|
+
* @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
|
|
141
144
|
*
|
|
142
145
|
* 支持三种常见写法:
|
|
143
146
|
* 1. `$toast('保存成功')`
|
|
@@ -150,22 +153,22 @@ interface TryCatchResult<T> {
|
|
|
150
153
|
* @returns 无返回值。
|
|
151
154
|
*
|
|
152
155
|
* @example
|
|
153
|
-
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { $toast } from '@sybz-components/utils'
|
|
154
158
|
*
|
|
155
|
-
*
|
|
159
|
+
* $toast('保存成功')
|
|
156
160
|
* $toast('保存失败', 'e')
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
161
|
* $toast({
|
|
160
162
|
* message: '自定义提示',
|
|
161
163
|
* type: 'warning',
|
|
162
164
|
* duration: 1000,
|
|
163
165
|
* closeAll: true,
|
|
164
166
|
* })
|
|
167
|
+
* $toast.error('接口请求失败', { showClose: true })
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
|
|
165
171
|
*/
|
|
166
|
-
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
167
|
-
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
168
|
-
type ToastType = MessageType | ShortType;
|
|
169
172
|
declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
170
173
|
declare namespace $toast {
|
|
171
174
|
var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
|
package/dist/base.d.ts
CHANGED
|
@@ -136,8 +136,11 @@ interface TryCatchResult<T> {
|
|
|
136
136
|
*/
|
|
137
137
|
error: any;
|
|
138
138
|
}
|
|
139
|
+
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
140
|
+
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
141
|
+
type ToastType = MessageType | ShortType;
|
|
139
142
|
/**
|
|
140
|
-
*
|
|
143
|
+
* @description 显示消息提示。默认展示成功状态,并支持类型简写、完整配置和快捷调用。
|
|
141
144
|
*
|
|
142
145
|
* 支持三种常见写法:
|
|
143
146
|
* 1. `$toast('保存成功')`
|
|
@@ -150,22 +153,22 @@ interface TryCatchResult<T> {
|
|
|
150
153
|
* @returns 无返回值。
|
|
151
154
|
*
|
|
152
155
|
* @example
|
|
153
|
-
*
|
|
156
|
+
* ```ts
|
|
157
|
+
* import { $toast } from '@sybz-components/utils'
|
|
154
158
|
*
|
|
155
|
-
*
|
|
159
|
+
* $toast('保存成功')
|
|
156
160
|
* $toast('保存失败', 'e')
|
|
157
|
-
*
|
|
158
|
-
* @example
|
|
159
161
|
* $toast({
|
|
160
162
|
* message: '自定义提示',
|
|
161
163
|
* type: 'warning',
|
|
162
164
|
* duration: 1000,
|
|
163
165
|
* closeAll: true,
|
|
164
166
|
* })
|
|
167
|
+
* $toast.error('接口请求失败', { showClose: true })
|
|
168
|
+
* ```
|
|
169
|
+
*
|
|
170
|
+
* @see {@link https://liulihao88.github.io/sybz-components/components/utils/$toast/home.html 详细文档}
|
|
165
171
|
*/
|
|
166
|
-
type MessageType = 'success' | 'info' | 'error' | 'warning';
|
|
167
|
-
type ShortType = 's' | 'i' | 'e' | 'w';
|
|
168
|
-
type ToastType = MessageType | ShortType;
|
|
169
172
|
declare function $toast(message: string | ToastOptions | VNode | (() => VNode), type?: ToastType | ToastOptions, otherParams?: ToastOptions): void;
|
|
170
173
|
declare namespace $toast {
|
|
171
174
|
var success: (message: string | ToastOptions | VNode<vue.RendererNode, vue.RendererElement, {
|
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.
|
|
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.D2T1ouSy.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.
|
|
3
|
+
const format = require('./shared/utils.CJVcMXo1.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,
|
|
208
|
-
export type { FormatBytesConvertOptions, FormatBytesOptions,
|
|
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,
|
|
208
|
-
export type { FormatBytesConvertOptions, FormatBytesOptions,
|
|
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,
|
|
208
|
-
export type { FormatBytesConvertOptions, FormatBytesOptions,
|
|
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
|
|
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.D2T1ouSy.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.
|
|
3
|
+
const format = require('./shared/utils.CJVcMXo1.cjs');
|
|
4
4
|
const is = require('./is.cjs');
|
|
5
5
|
require('vue');
|
|
6
6
|
require('consola');
|
|
@@ -19,7 +19,6 @@ exports.delay = format.delay;
|
|
|
19
19
|
exports.formatBytes = format.formatBytes;
|
|
20
20
|
exports.formatBytesConvert = format.formatBytesConvert;
|
|
21
21
|
exports.formatDurationTime = format.formatDurationTime;
|
|
22
|
-
exports.formatImg = format.formatImg;
|
|
23
22
|
exports.formatTextToHtml = format.formatTextToHtml;
|
|
24
23
|
exports.formatThousands = format.formatThousands;
|
|
25
24
|
exports.formatTime = format.formatTime;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,5 +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
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
|
-
export { FormatBytesConvertOptions, FormatBytesOptions,
|
|
3
|
+
export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.cjs';
|
|
4
4
|
import 'element-plus';
|
|
5
5
|
import 'vue';
|
package/dist/index.d.mts
CHANGED
|
@@ -1,5 +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
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
|
-
export { FormatBytesConvertOptions, FormatBytesOptions,
|
|
3
|
+
export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.mjs';
|
|
4
4
|
import 'element-plus';
|
|
5
5
|
import 'vue';
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +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
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
|
-
export { FormatBytesConvertOptions, FormatBytesOptions,
|
|
3
|
+
export { FormatBytesConvertOptions, FormatBytesOptions, FormatTimeFallback, FormatTimeInput, FormatToFixedOptions, formatBytes, formatBytesConvert, formatDurationTime, formatTextToHtml, formatThousands, formatTime, formatToFixed } from './format.js';
|
|
4
4
|
import 'element-plus';
|
|
5
5
|
import 'vue';
|
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
|
|
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.D2T1ouSy.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';
|
|
@@ -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)) {
|
|
@@ -111,7 +110,7 @@ function formatTime(time = /* @__PURE__ */ new Date(), cFormat = "{y}-{m}-{d} {h
|
|
|
111
110
|
} else if (dateOnlyRegex.test(timeStr)) {
|
|
112
111
|
const [, year, month, day] = timeStr.match(dateOnlyRegex);
|
|
113
112
|
date = new Date(Number(year), Number(month) - 1, Number(day));
|
|
114
|
-
} else if (
|
|
113
|
+
} else if (/^[+-]?\d+\.\d+$/.test(timeStr)) {
|
|
115
114
|
date = new Date(parseFloat(timeStr) * 1e3);
|
|
116
115
|
} else if (/^\d{10}$/.test(timeStr)) {
|
|
117
116
|
date = new Date(parseInt(timeStr) * 1e3);
|
|
@@ -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.aC91nrkh.cjs', document.baseURI).href))).href;
|
|
194
|
-
}
|
|
195
182
|
function formatToFixed(value, options) {
|
|
196
183
|
if (typeof options === "number") {
|
|
197
184
|
options = { digit: options };
|
|
@@ -379,7 +366,7 @@ function clearStorage(str = "") {
|
|
|
379
366
|
function _isObjectWithExclude(obj) {
|
|
380
367
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
381
368
|
}
|
|
382
|
-
function validateForm(ref, { message = "\
|
|
369
|
+
function validateForm(ref, { message = "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574", detail = false, showMessage = true } = {}) {
|
|
383
370
|
return new Promise((resolve, reject) => {
|
|
384
371
|
vue.unref(ref).validate((valid, status) => {
|
|
385
372
|
if (valid) {
|
|
@@ -850,8 +837,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
|
|
|
850
837
|
const context = lastThis;
|
|
851
838
|
lastArgs = void 0;
|
|
852
839
|
lastThis = void 0;
|
|
853
|
-
|
|
854
|
-
|
|
840
|
+
const nextResult = fn.apply(context, args);
|
|
841
|
+
result = nextResult;
|
|
842
|
+
resultCallback?.(nextResult);
|
|
855
843
|
return result;
|
|
856
844
|
};
|
|
857
845
|
const flush = () => {
|
|
@@ -1047,7 +1035,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1047
1035
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1048
1036
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1049
1037
|
{
|
|
1050
|
-
return "2026-07-
|
|
1038
|
+
return "2026-07-29 15:14:53";
|
|
1051
1039
|
}
|
|
1052
1040
|
}
|
|
1053
1041
|
function test() {
|
|
@@ -1064,7 +1052,6 @@ exports.delay = delay;
|
|
|
1064
1052
|
exports.formatBytes = formatBytes;
|
|
1065
1053
|
exports.formatBytesConvert = formatBytesConvert;
|
|
1066
1054
|
exports.formatDurationTime = formatDurationTime;
|
|
1067
|
-
exports.formatImg = formatImg;
|
|
1068
1055
|
exports.formatTextToHtml = formatTextToHtml;
|
|
1069
1056
|
exports.formatThousands = formatThousands;
|
|
1070
1057
|
exports.formatTime = formatTime;
|
|
@@ -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 (
|
|
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);
|
|
@@ -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 };
|
|
@@ -376,7 +364,7 @@ function clearStorage(str = "") {
|
|
|
376
364
|
function _isObjectWithExclude(obj) {
|
|
377
365
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
378
366
|
}
|
|
379
|
-
function validateForm(ref, { message = "\
|
|
367
|
+
function validateForm(ref, { message = "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574", detail = false, showMessage = true } = {}) {
|
|
380
368
|
return new Promise((resolve, reject) => {
|
|
381
369
|
unref(ref).validate((valid, status) => {
|
|
382
370
|
if (valid) {
|
|
@@ -847,8 +835,9 @@ function throttle(fn, delay2 = 1e3, options = {}, resultCallback) {
|
|
|
847
835
|
const context = lastThis;
|
|
848
836
|
lastArgs = void 0;
|
|
849
837
|
lastThis = void 0;
|
|
850
|
-
|
|
851
|
-
|
|
838
|
+
const nextResult = fn.apply(context, args);
|
|
839
|
+
result = nextResult;
|
|
840
|
+
resultCallback?.(nextResult);
|
|
852
841
|
return result;
|
|
853
842
|
};
|
|
854
843
|
const flush = () => {
|
|
@@ -1044,11 +1033,11 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1044
1033
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1045
1034
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1046
1035
|
{
|
|
1047
|
-
return "2026-07-
|
|
1036
|
+
return "2026-07-29 15:14:53";
|
|
1048
1037
|
}
|
|
1049
1038
|
}
|
|
1050
1039
|
function test() {
|
|
1051
1040
|
return `build time: ${getUtilsBuildTime()}`;
|
|
1052
1041
|
}
|
|
1053
1042
|
|
|
1054
|
-
export { $toast as $, formatDurationTime as A,
|
|
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 };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sybz-components/utils",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.2",
|
|
4
4
|
"description": "utils of sybz-components",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"type": "commonjs",
|
|
@@ -16,10 +16,11 @@
|
|
|
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
|
-
"release": "node ./scripts/release.mjs"
|
|
22
|
-
"release:skip": "node ./scripts/release.mjs --skip-version-bump"
|
|
23
|
+
"release": "node ./scripts/release.mjs"
|
|
23
24
|
},
|
|
24
25
|
"author": "",
|
|
25
26
|
"dependencies": {
|