@oeos-components/utils 0.0.24 → 0.0.25
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 +43 -3
- package/dist/base.d.cts +4 -0
- package/dist/base.d.mts +4 -0
- package/dist/base.d.ts +4 -0
- package/dist/base.mjs +43 -3
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
|
@@ -626,22 +626,62 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
626
626
|
}
|
|
627
627
|
function confirm(message, options = {}, appContext = null) {
|
|
628
628
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
629
|
+
const resolvedAppendTo = _resolveAppendTarget(options?.appendTo);
|
|
630
|
+
const resolvedAppContext = _resolveAppContext(options?.appContext || appContext);
|
|
629
631
|
const mergeOptions = {
|
|
630
632
|
title: "\u63D0\u793A",
|
|
631
633
|
draggable: true,
|
|
632
634
|
showCancelButton: false,
|
|
633
635
|
confirmButtonText: "\u786E\u5B9A",
|
|
634
636
|
dangerouslyUseHTMLString: true,
|
|
635
|
-
...options
|
|
637
|
+
...options,
|
|
638
|
+
appendTo: resolvedAppendTo,
|
|
639
|
+
appContext: resolvedAppContext
|
|
636
640
|
};
|
|
637
|
-
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions
|
|
641
|
+
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
642
|
+
}
|
|
643
|
+
function _resolveAppendTarget(appendTo) {
|
|
644
|
+
if (typeof document === "undefined") {
|
|
645
|
+
return appendTo;
|
|
646
|
+
}
|
|
647
|
+
if (appendTo instanceof HTMLElement) {
|
|
648
|
+
return appendTo;
|
|
649
|
+
}
|
|
650
|
+
if (typeof appendTo === "string" && appendTo.trim()) {
|
|
651
|
+
const rawSelector = appendTo.trim();
|
|
652
|
+
try {
|
|
653
|
+
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
654
|
+
return document.querySelector(selector) || appendTo;
|
|
655
|
+
} catch (error) {
|
|
656
|
+
return appendTo;
|
|
657
|
+
}
|
|
658
|
+
}
|
|
659
|
+
const overlayList = Array.from(document.querySelectorAll(".el-overlay"));
|
|
660
|
+
const dialogOverlay = overlayList.filter((item) => {
|
|
661
|
+
if (!item.isConnected || item.style.display === "none") {
|
|
662
|
+
return false;
|
|
663
|
+
}
|
|
664
|
+
const containsDialog = item.querySelector(".el-dialog, .el-drawer");
|
|
665
|
+
const containsMessageBox = item.querySelector(".el-message-box");
|
|
666
|
+
return !!containsDialog && !containsMessageBox;
|
|
667
|
+
}).at(-1);
|
|
668
|
+
return dialogOverlay || appendTo;
|
|
669
|
+
}
|
|
670
|
+
function _resolveAppContext(appContext) {
|
|
671
|
+
if (appContext) {
|
|
672
|
+
return appContext;
|
|
673
|
+
}
|
|
674
|
+
if (typeof document === "undefined") {
|
|
675
|
+
return elementPlus.ElMessageBox.install?.context || elementPlus.ElMessageBox._context;
|
|
676
|
+
}
|
|
677
|
+
return elementPlus.ElMessageBox.install?.context || elementPlus.ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
638
678
|
}
|
|
639
679
|
function getVariable(propertyName) {
|
|
640
680
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
641
681
|
return res;
|
|
642
682
|
}
|
|
643
683
|
function test() {
|
|
644
|
-
return
|
|
684
|
+
return `build time: ${"2026-04-04 18:19:03"}`;
|
|
645
685
|
}
|
|
646
686
|
|
|
647
687
|
exports.$toast = $toast;
|
package/dist/base.d.cts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
package/dist/base.d.mts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
package/dist/base.d.ts
CHANGED
|
@@ -326,9 +326,13 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
326
326
|
};
|
|
327
327
|
/**
|
|
328
328
|
* proxy.confirm('确定删除吗?')
|
|
329
|
+
*
|
|
329
330
|
* proxy.confirm('哈哈', { icon: 'el-icon-plus' })
|
|
331
|
+
*
|
|
330
332
|
* close-on-click-modal: 是否可通过点击遮罩层关闭 MessageBox 默认true
|
|
333
|
+
*
|
|
331
334
|
* lock-scroll: 是否在 MessageBox 出现时将 body 滚动锁定. 默认true
|
|
335
|
+
*
|
|
332
336
|
* 设置宽度, 内容使用组件
|
|
333
337
|
import GWarning from '@/autoComponents/gWarning.vue'
|
|
334
338
|
await proxy.confirm('', {
|
package/dist/base.mjs
CHANGED
|
@@ -624,22 +624,62 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
624
624
|
}
|
|
625
625
|
function confirm(message, options = {}, appContext = null) {
|
|
626
626
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
627
|
+
const resolvedAppendTo = _resolveAppendTarget(options?.appendTo);
|
|
628
|
+
const resolvedAppContext = _resolveAppContext(options?.appContext || appContext);
|
|
627
629
|
const mergeOptions = {
|
|
628
630
|
title: "\u63D0\u793A",
|
|
629
631
|
draggable: true,
|
|
630
632
|
showCancelButton: false,
|
|
631
633
|
confirmButtonText: "\u786E\u5B9A",
|
|
632
634
|
dangerouslyUseHTMLString: true,
|
|
633
|
-
...options
|
|
635
|
+
...options,
|
|
636
|
+
appendTo: resolvedAppendTo,
|
|
637
|
+
appContext: resolvedAppContext
|
|
634
638
|
};
|
|
635
|
-
return ElMessageBox.confirm(resolvedMessage, mergeOptions
|
|
639
|
+
return ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
640
|
+
}
|
|
641
|
+
function _resolveAppendTarget(appendTo) {
|
|
642
|
+
if (typeof document === "undefined") {
|
|
643
|
+
return appendTo;
|
|
644
|
+
}
|
|
645
|
+
if (appendTo instanceof HTMLElement) {
|
|
646
|
+
return appendTo;
|
|
647
|
+
}
|
|
648
|
+
if (typeof appendTo === "string" && appendTo.trim()) {
|
|
649
|
+
const rawSelector = appendTo.trim();
|
|
650
|
+
try {
|
|
651
|
+
const selector = rawSelector.startsWith("#") || rawSelector.startsWith(".") || rawSelector.startsWith("[") ? rawSelector : `#${rawSelector}`;
|
|
652
|
+
return document.querySelector(selector) || appendTo;
|
|
653
|
+
} catch (error) {
|
|
654
|
+
return appendTo;
|
|
655
|
+
}
|
|
656
|
+
}
|
|
657
|
+
const overlayList = Array.from(document.querySelectorAll(".el-overlay"));
|
|
658
|
+
const dialogOverlay = overlayList.filter((item) => {
|
|
659
|
+
if (!item.isConnected || item.style.display === "none") {
|
|
660
|
+
return false;
|
|
661
|
+
}
|
|
662
|
+
const containsDialog = item.querySelector(".el-dialog, .el-drawer");
|
|
663
|
+
const containsMessageBox = item.querySelector(".el-message-box");
|
|
664
|
+
return !!containsDialog && !containsMessageBox;
|
|
665
|
+
}).at(-1);
|
|
666
|
+
return dialogOverlay || appendTo;
|
|
667
|
+
}
|
|
668
|
+
function _resolveAppContext(appContext) {
|
|
669
|
+
if (appContext) {
|
|
670
|
+
return appContext;
|
|
671
|
+
}
|
|
672
|
+
if (typeof document === "undefined") {
|
|
673
|
+
return ElMessageBox.install?.context || ElMessageBox._context;
|
|
674
|
+
}
|
|
675
|
+
return ElMessageBox.install?.context || ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
636
676
|
}
|
|
637
677
|
function getVariable(propertyName) {
|
|
638
678
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
639
679
|
return res;
|
|
640
680
|
}
|
|
641
681
|
function test() {
|
|
642
|
-
return
|
|
682
|
+
return `build time: ${"2026-04-04 18:19:03"}`;
|
|
643
683
|
}
|
|
644
684
|
|
|
645
685
|
export { $toast, asyncWrapper, clearStorage, clone, confirm, copy, debounce, getStorage, getType, getVariable, isEmpty, log, merge, notEmpty, processWidth, random, setStorage, sleep, test, throttle, toLine, tryCatch, uuid, validForm, validate, validateTrigger };
|