@sybz-components/utils 1.0.20 → 1.0.22

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.CpSVN1vj.cjs');
6
+ const format = require('./shared/utils.BCKcQULi.cjs');
7
7
  require('./confirmSemantic.cjs');
8
8
  require('element-plus');
9
9
  require('axios');
package/dist/base.d.cts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
package/dist/base.d.mts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
package/dist/base.d.ts CHANGED
@@ -39,7 +39,7 @@ interface SybzUtilsConfig {
39
39
  http?: CreateHttpOptions;
40
40
  }
41
41
  interface ToastOptions extends Omit<Partial<MessageOptions>, 'icon'> {
42
- /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 false。仅传可信内容。 */
42
+ /** 是否解析 HTML 字符串,并将已全局注册的组件标签渲染为 Vue 组件;默认 true。仅传可信内容。 */
43
43
  dangerouslyUseHTMLString?: boolean;
44
44
  /** 图标组件,或由全局 SIcon 自动解析的图标名称。 */
45
45
  icon?: string | Component;
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.C6u5wfj0.mjs';
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.veOn4f_Q.mjs';
5
5
  import './confirmSemantic.mjs';
6
6
  import 'element-plus';
7
7
  import 'axios';
package/dist/format.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.CpSVN1vj.cjs');
3
+ const format = require('./shared/utils.BCKcQULi.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 { z as formatBytes, A as formatBytesConvert, B as formatDurationTime, C as formatTextToHtml, D as formatThousands, E as formatTime, F as formatToFixed } from './shared/utils.C6u5wfj0.mjs';
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.veOn4f_Q.mjs';
2
2
  import './is.mjs';
3
3
  import 'consola';
4
4
  import 'vue';
package/dist/http.cjs CHANGED
@@ -1,7 +1,7 @@
1
1
  'use strict';
2
2
 
3
3
  require('axios');
4
- const format = require('./shared/utils.CpSVN1vj.cjs');
4
+ const format = require('./shared/utils.BCKcQULi.cjs');
5
5
  require('vue');
6
6
  require('consola');
7
7
  require('es-toolkit');
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.C6u5wfj0.mjs';
2
+ export { H as HttpError, G as configureHttp, I as createHttp, J as http } from './shared/utils.veOn4f_Q.mjs';
3
3
  import 'vue';
4
4
  import 'consola';
5
5
  import 'es-toolkit';
package/dist/index.cjs CHANGED
@@ -1,6 +1,6 @@
1
1
  'use strict';
2
2
 
3
- const format = require('./shared/utils.CpSVN1vj.cjs');
3
+ const format = require('./shared/utils.BCKcQULi.cjs');
4
4
  const confirmSemantic = require('./confirmSemantic.cjs');
5
5
  const is = require('./is.cjs');
6
6
  const theme = require('./theme.cjs');
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.C6u5wfj0.mjs';
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.veOn4f_Q.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';
@@ -423,7 +423,15 @@ function $toast(message, type = "success", otherParams = {}) {
423
423
  return typeof obj === "object" && obj !== null && !vue.isVNode(obj);
424
424
  }
425
425
  function showToast(options) {
426
- const { theme = utilsConfig.theme, customClass, iconAttrs, handlers, ...messageOptions } = options;
426
+ const {
427
+ theme = utilsConfig.theme,
428
+ customClass,
429
+ iconAttrs,
430
+ handlers,
431
+ dangerouslyUseHTMLString = true,
432
+ ...messageOptions
433
+ } = options;
434
+ let htmlStringEnabled = dangerouslyUseHTMLString;
427
435
  const appContext = _resolveAppContext(null);
428
436
  const appComponents = appContext?.components;
429
437
  if (typeof messageOptions.icon === "string") {
@@ -436,11 +444,11 @@ function $toast(message, type = "success", otherParams = {}) {
436
444
  const icon = messageOptions.icon;
437
445
  messageOptions.icon = () => vue.h(icon, iconAttrs);
438
446
  }
439
- if (typeof messageOptions.message === "string" && messageOptions.dangerouslyUseHTMLString) {
447
+ if (typeof messageOptions.message === "string" && htmlStringEnabled) {
440
448
  const registeredComponents = appComponents ?? {};
441
449
  if (Object.keys(registeredComponents).length > 0) {
442
450
  messageOptions.message = renderToastComponents(messageOptions.message, registeredComponents, handlers);
443
- messageOptions.dangerouslyUseHTMLString = false;
451
+ htmlStringEnabled = false;
444
452
  }
445
453
  }
446
454
  if (options.closeAll) {
@@ -454,6 +462,7 @@ function $toast(message, type = "success", otherParams = {}) {
454
462
  );
455
463
  const resolvedMessageOptions = {
456
464
  ...messageOptions,
465
+ dangerouslyUseHTMLString: htmlStringEnabled,
457
466
  showClose: options.showClose ?? true,
458
467
  customClass: resolvedCustomClass
459
468
  };
@@ -1174,6 +1183,7 @@ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null
1174
1183
  appendTo: resolvedAppendTo,
1175
1184
  appContext: resolvedAppContext,
1176
1185
  customClass: _mergeClassNames(
1186
+ "s-message-box--selectable-title",
1177
1187
  isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
1178
1188
  isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
1179
1189
  isSybzTheme && SYBZ_CONFIRM_BOX_CLASS,
@@ -1195,7 +1205,15 @@ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null
1195
1205
  cancelButtonClass
1196
1206
  )
1197
1207
  };
1198
- return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
1208
+ const result = elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
1209
+ void vue.nextTick(() => {
1210
+ document.querySelectorAll(".s-message-box--selectable-title .el-message-box__title > span").forEach((title) => {
1211
+ if (title.dataset.selectableTitle) return;
1212
+ title.dataset.selectableTitle = "true";
1213
+ title.addEventListener("mousedown", (event) => event.stopPropagation());
1214
+ });
1215
+ });
1216
+ return result;
1199
1217
  }
1200
1218
  function _escapeHtml(value) {
1201
1219
  return String(value).replace(/[&<>'"]/g, (character) => {
@@ -1249,8 +1267,18 @@ function _resolveAppContext(appContext) {
1249
1267
  if (typeof document === "undefined") {
1250
1268
  return elementPlusContext;
1251
1269
  }
1252
- const appRoot = document.querySelector("#app");
1253
- return elementPlusContext || appRoot?._vue_app?._context || null;
1270
+ return elementPlusContext || _mountedAppContext();
1271
+ }
1272
+ function _mountedAppContext() {
1273
+ const roots = [document.querySelector("#app"), document.querySelector("[data-v-app]")];
1274
+ for (const root of roots) {
1275
+ const element = root;
1276
+ const context = element?.__vue_app__?._context ?? element?._vue_app?._context;
1277
+ if (context) {
1278
+ return context;
1279
+ }
1280
+ }
1281
+ return null;
1254
1282
  }
1255
1283
  function getVariable(propertyName, fallback = "") {
1256
1284
  if (typeof document === "undefined") {
@@ -1262,7 +1290,7 @@ function getVariable(propertyName, fallback = "") {
1262
1290
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1263
1291
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1264
1292
  {
1265
- return "2026-11-20 11:05:15";
1293
+ return "2026-11-23 13:45:27";
1266
1294
  }
1267
1295
  }
1268
1296
  function test() {
@@ -1,4 +1,4 @@
1
- import { isVNode, h, Fragment, isRef, unref, toRaw } from 'vue';
1
+ import { isVNode, h, Fragment, isRef, unref, nextTick, toRaw } from 'vue';
2
2
  import { consola } from 'consola';
3
3
  import { cloneDeep } from 'es-toolkit';
4
4
  import { resolveConfirmSemantic } from '../confirmSemantic.mjs';
@@ -417,7 +417,15 @@ function $toast(message, type = "success", otherParams = {}) {
417
417
  return typeof obj === "object" && obj !== null && !isVNode(obj);
418
418
  }
419
419
  function showToast(options) {
420
- const { theme = utilsConfig.theme, customClass, iconAttrs, handlers, ...messageOptions } = options;
420
+ const {
421
+ theme = utilsConfig.theme,
422
+ customClass,
423
+ iconAttrs,
424
+ handlers,
425
+ dangerouslyUseHTMLString = true,
426
+ ...messageOptions
427
+ } = options;
428
+ let htmlStringEnabled = dangerouslyUseHTMLString;
421
429
  const appContext = _resolveAppContext(null);
422
430
  const appComponents = appContext?.components;
423
431
  if (typeof messageOptions.icon === "string") {
@@ -430,11 +438,11 @@ function $toast(message, type = "success", otherParams = {}) {
430
438
  const icon = messageOptions.icon;
431
439
  messageOptions.icon = () => h(icon, iconAttrs);
432
440
  }
433
- if (typeof messageOptions.message === "string" && messageOptions.dangerouslyUseHTMLString) {
441
+ if (typeof messageOptions.message === "string" && htmlStringEnabled) {
434
442
  const registeredComponents = appComponents ?? {};
435
443
  if (Object.keys(registeredComponents).length > 0) {
436
444
  messageOptions.message = renderToastComponents(messageOptions.message, registeredComponents, handlers);
437
- messageOptions.dangerouslyUseHTMLString = false;
445
+ htmlStringEnabled = false;
438
446
  }
439
447
  }
440
448
  if (options.closeAll) {
@@ -448,6 +456,7 @@ function $toast(message, type = "success", otherParams = {}) {
448
456
  );
449
457
  const resolvedMessageOptions = {
450
458
  ...messageOptions,
459
+ dangerouslyUseHTMLString: htmlStringEnabled,
451
460
  showClose: options.showClose ?? true,
452
461
  customClass: resolvedCustomClass
453
462
  };
@@ -1168,6 +1177,7 @@ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null
1168
1177
  appendTo: resolvedAppendTo,
1169
1178
  appContext: resolvedAppContext,
1170
1179
  customClass: _mergeClassNames(
1180
+ "s-message-box--selectable-title",
1171
1181
  isChenghuaTheme && CHENGHUA_CONFIRM_BOX_CLASS,
1172
1182
  isShijingshanTheme && SHIJINGSHAN_CONFIRM_BOX_CLASS,
1173
1183
  isSybzTheme && SYBZ_CONFIRM_BOX_CLASS,
@@ -1189,7 +1199,15 @@ function confirm(messageOrOptions, optionsOrAppContext = null, appContext = null
1189
1199
  cancelButtonClass
1190
1200
  )
1191
1201
  };
1192
- return ElMessageBox.confirm(resolvedMessage, mergeOptions);
1202
+ const result = ElMessageBox.confirm(resolvedMessage, mergeOptions);
1203
+ void nextTick(() => {
1204
+ document.querySelectorAll(".s-message-box--selectable-title .el-message-box__title > span").forEach((title) => {
1205
+ if (title.dataset.selectableTitle) return;
1206
+ title.dataset.selectableTitle = "true";
1207
+ title.addEventListener("mousedown", (event) => event.stopPropagation());
1208
+ });
1209
+ });
1210
+ return result;
1193
1211
  }
1194
1212
  function _escapeHtml(value) {
1195
1213
  return String(value).replace(/[&<>'"]/g, (character) => {
@@ -1243,8 +1261,18 @@ function _resolveAppContext(appContext) {
1243
1261
  if (typeof document === "undefined") {
1244
1262
  return elementPlusContext;
1245
1263
  }
1246
- const appRoot = document.querySelector("#app");
1247
- return elementPlusContext || appRoot?._vue_app?._context || null;
1264
+ return elementPlusContext || _mountedAppContext();
1265
+ }
1266
+ function _mountedAppContext() {
1267
+ const roots = [document.querySelector("#app"), document.querySelector("[data-v-app]")];
1268
+ for (const root of roots) {
1269
+ const element = root;
1270
+ const context = element?.__vue_app__?._context ?? element?._vue_app?._context;
1271
+ if (context) {
1272
+ return context;
1273
+ }
1274
+ }
1275
+ return null;
1248
1276
  }
1249
1277
  function getVariable(propertyName, fallback = "") {
1250
1278
  if (typeof document === "undefined") {
@@ -1256,7 +1284,7 @@ function getVariable(propertyName, fallback = "") {
1256
1284
  const DEFAULT_BUILD_TIME_FALLBACK = "\u672A\u6CE8\u5165";
1257
1285
  function getUtilsBuildTime(fallback = DEFAULT_BUILD_TIME_FALLBACK) {
1258
1286
  {
1259
- return "2026-11-20 11:05:15";
1287
+ return "2026-11-23 13:45:27";
1260
1288
  }
1261
1289
  }
1262
1290
  function test() {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sybz-components/utils",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
4
4
  "description": "utils of sybz-components",
5
5
  "license": "MIT",
6
6
  "type": "commonjs",
@@ -64,7 +64,6 @@
64
64
  "axios": "^1.19.0",
65
65
  "code-inspector-plugin": "^2.0.9",
66
66
  "consola": "^3.4.2",
67
- "element-plus": "^2.11.5",
68
67
  "es-toolkit": "^1.39.10",
69
68
  "eslint": "9.39.4",
70
69
  "eslint-config-prettier": "9.1.2",
@@ -75,10 +74,15 @@
75
74
  "lodash-es": "^4.17.21",
76
75
  "prettier": "3.8.4",
77
76
  "tailwindcss": "^4.3.3",
78
- "vue": "3.4.15",
79
77
  "vue-eslint-parser": "10.4.1"
80
78
  },
79
+ "devDependencies": {
80
+ "element-plus": "^2.11.5",
81
+ "vue": "3.4.15"
82
+ },
81
83
  "peerDependencies": {
82
- "vite": ">=5 <7"
84
+ "element-plus": ">=2.3.0 <3",
85
+ "vite": ">=5 <7",
86
+ "vue": ">=3.4.0 <4"
83
87
  }
84
88
  }