@sybz-components/utils 1.0.17 → 1.0.18
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 +1 -1
- package/dist/base.d.mts +1 -1
- package/dist/base.d.ts +1 -1
- package/dist/base.mjs +1 -1
- package/dist/format.cjs +1 -1
- package/dist/format.mjs +1 -1
- package/dist/http.cjs +1 -1
- package/dist/http.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.mjs +1 -1
- package/dist/shared/{utils.E1TDYt7o.mjs → utils.D3fsXXCj.mjs} +18 -9
- package/dist/shared/{utils.CC08jxyG.cjs → utils.DqukLavi.cjs} +18 -9
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
package/dist/base.d.cts
CHANGED
package/dist/base.d.mts
CHANGED
package/dist/base.d.ts
CHANGED
package/dist/base.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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 configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.
|
|
4
|
+
export { $ as $toast, c as clearStorage, a as clone, b as configureUtils, d as confirm, e as copy, f as debounce, g as delay, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D3fsXXCj.mjs';
|
|
5
5
|
import './confirmSemantic.mjs';
|
|
6
6
|
import 'element-plus';
|
|
7
7
|
import 'axios';
|
package/dist/format.cjs
CHANGED
package/dist/format.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.
|
|
1
|
+
export { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.D3fsXXCj.mjs';
|
|
2
2
|
import './is.mjs';
|
|
3
3
|
import 'consola';
|
|
4
4
|
import 'vue';
|
package/dist/http.cjs
CHANGED
package/dist/http.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import 'axios';
|
|
2
|
-
export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.
|
|
2
|
+
export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.D3fsXXCj.mjs';
|
|
3
3
|
import 'vue';
|
|
4
4
|
import 'consola';
|
|
5
5
|
import 'es-toolkit';
|
package/dist/index.cjs
CHANGED
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.
|
|
1
|
+
export { $ as $toast, H as HttpError, c as clearStorage, a as clone, G as configureHttp, b as configureUtils, d as confirm, e as copy, I as createHttp, f as debounce, g as delay, z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed, h as getStorage, i as getType, j as getUtilsBuildTime, k as getVariable, J as http, l as isEmpty, m as log, n as merge, o as mockValue, p as processWidth, r as random, s as setStorage, t as test, q as throttle, u as toLine, v as tryCatch, w as validate, x as validateForm, y as validateOnSubmit } from './shared/utils.D3fsXXCj.mjs';
|
|
2
2
|
export { resolveConfirmSemantic } from './confirmSemantic.mjs';
|
|
3
3
|
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
4
|
export { SYBZ_THEME_PREFIX, isSybzTheme, resolveSybzComponentTheme } from './theme.mjs';
|
|
@@ -493,19 +493,28 @@ function clearStorage(str = "") {
|
|
|
493
493
|
function _isObjectWithExclude(obj) {
|
|
494
494
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
495
495
|
}
|
|
496
|
-
function validateForm(ref, { message
|
|
496
|
+
function validateForm(ref, { message, detail = false, showMessage = true } = {}) {
|
|
497
497
|
return new Promise((resolve, reject) => {
|
|
498
498
|
unref(ref).validate((valid, status) => {
|
|
499
499
|
if (valid) {
|
|
500
500
|
resolve(status);
|
|
501
501
|
} else {
|
|
502
|
-
if (
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
}
|
|
508
|
-
|
|
502
|
+
if (showMessage) {
|
|
503
|
+
const fieldNames = Object.keys(status ?? {});
|
|
504
|
+
const errors = fieldNames.flatMap((field) => {
|
|
505
|
+
const fieldErrors = status[field];
|
|
506
|
+
return Array.isArray(fieldErrors) ? fieldErrors : [fieldErrors];
|
|
507
|
+
});
|
|
508
|
+
const errorMessages = errors.map((error) => error?.message).filter((errorMessage) => typeof errorMessage === "string" && !!errorMessage.trim());
|
|
509
|
+
const nonRequiredMessage = errors.find((error) => {
|
|
510
|
+
const errorMessage = error?.message;
|
|
511
|
+
if (typeof errorMessage !== "string" || !errorMessage.trim()) return false;
|
|
512
|
+
if ("fieldValue" in Object(error) && !isEmpty(error.fieldValue)) return true;
|
|
513
|
+
return !/^(请输入|请选择|请填写|请上传|请勾选|不能为空)/.test(errorMessage) || /^请输入(?:正确|非负|正|整数|数字|\d|至少|最多|不超过)/.test(errorMessage);
|
|
514
|
+
})?.message;
|
|
515
|
+
const defaultMessage = nonRequiredMessage ?? (errorMessages.length ? "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574" : "\u8868\u5355\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165");
|
|
516
|
+
const toastMessage = message === void 0 ? defaultMessage : message;
|
|
517
|
+
if (toastMessage) $toast(detail ? toastMessage + fieldNames.join(",") : toastMessage, "e");
|
|
509
518
|
}
|
|
510
519
|
reject(status);
|
|
511
520
|
}
|
|
@@ -1195,7 +1204,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1195
1204
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1196
1205
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1197
1206
|
{
|
|
1198
|
-
return "2026-11-
|
|
1207
|
+
return "2026-11-12 14:28:53";
|
|
1199
1208
|
}
|
|
1200
1209
|
}
|
|
1201
1210
|
function test() {
|
|
@@ -499,19 +499,28 @@ function clearStorage(str = "") {
|
|
|
499
499
|
function _isObjectWithExclude(obj) {
|
|
500
500
|
return typeof obj === "object" && obj !== null && "exclude" in obj && Array.isArray(obj.exclude);
|
|
501
501
|
}
|
|
502
|
-
function validateForm(ref, { message
|
|
502
|
+
function validateForm(ref, { message, detail = false, showMessage = true } = {}) {
|
|
503
503
|
return new Promise((resolve, reject) => {
|
|
504
504
|
vue.unref(ref).validate((valid, status) => {
|
|
505
505
|
if (valid) {
|
|
506
506
|
resolve(status);
|
|
507
507
|
} else {
|
|
508
|
-
if (
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
}
|
|
514
|
-
|
|
508
|
+
if (showMessage) {
|
|
509
|
+
const fieldNames = Object.keys(status ?? {});
|
|
510
|
+
const errors = fieldNames.flatMap((field) => {
|
|
511
|
+
const fieldErrors = status[field];
|
|
512
|
+
return Array.isArray(fieldErrors) ? fieldErrors : [fieldErrors];
|
|
513
|
+
});
|
|
514
|
+
const errorMessages = errors.map((error) => error?.message).filter((errorMessage) => typeof errorMessage === "string" && !!errorMessage.trim());
|
|
515
|
+
const nonRequiredMessage = errors.find((error) => {
|
|
516
|
+
const errorMessage = error?.message;
|
|
517
|
+
if (typeof errorMessage !== "string" || !errorMessage.trim()) return false;
|
|
518
|
+
if ("fieldValue" in Object(error) && !isEmpty(error.fieldValue)) return true;
|
|
519
|
+
return !/^(请输入|请选择|请填写|请上传|请勾选|不能为空)/.test(errorMessage) || /^请输入(?:正确|非负|正|整数|数字|\d|至少|最多|不超过)/.test(errorMessage);
|
|
520
|
+
})?.message;
|
|
521
|
+
const defaultMessage = nonRequiredMessage ?? (errorMessages.length ? "\u5B58\u5728\u5FC5\u586B\u9879\u672A\u586B\u5199\uFF0C\u8BF7\u8865\u5145\u5B8C\u6574" : "\u8868\u5355\u6821\u9A8C\u672A\u901A\u8FC7\uFF0C\u8BF7\u68C0\u67E5\u8F93\u5165");
|
|
522
|
+
const toastMessage = message === void 0 ? defaultMessage : message;
|
|
523
|
+
if (toastMessage) $toast(detail ? toastMessage + fieldNames.join(",") : toastMessage, "e");
|
|
515
524
|
}
|
|
516
525
|
reject(status);
|
|
517
526
|
}
|
|
@@ -1201,7 +1210,7 @@ function getVariable(propertyName, fallback = "") {
|
|
|
1201
1210
|
const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
|
|
1202
1211
|
function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
|
|
1203
1212
|
{
|
|
1204
|
-
return "2026-11-
|
|
1213
|
+
return "2026-11-12 14:28:53";
|
|
1205
1214
|
}
|
|
1206
1215
|
}
|
|
1207
1216
|
function test() {
|