@oeos-components/utils 0.0.22 → 0.0.24
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 +19 -29
- package/dist/base.d.cts +18 -3
- package/dist/base.d.mts +18 -3
- package/dist/base.d.ts +18 -3
- package/dist/base.mjs +19 -29
- package/package.json +1 -1
package/dist/base.cjs
CHANGED
|
@@ -67,8 +67,8 @@ function setStorage(storageName, params, isSession = false) {
|
|
|
67
67
|
}
|
|
68
68
|
}
|
|
69
69
|
function getStorage(data, isSession = false) {
|
|
70
|
-
let getLocalData =
|
|
71
|
-
let getSessionData =
|
|
70
|
+
let getLocalData = null;
|
|
71
|
+
let getSessionData = null;
|
|
72
72
|
if (isSession) {
|
|
73
73
|
getSessionData = sessionStorage.getItem(data);
|
|
74
74
|
} else {
|
|
@@ -534,32 +534,26 @@ function toLine(text, connect = "-") {
|
|
|
534
534
|
}).toLocaleLowerCase();
|
|
535
535
|
return translateText;
|
|
536
536
|
}
|
|
537
|
+
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
537
538
|
function processWidth(initValue, isBase = false) {
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
res = value + "px";
|
|
549
|
-
} else if (typeof value === "string" && /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)*$/.test(value)) {
|
|
550
|
-
res = value;
|
|
539
|
+
const raw = reactivity.unref(initValue);
|
|
540
|
+
if (!raw) {
|
|
541
|
+
return isBase ? "" : {};
|
|
542
|
+
}
|
|
543
|
+
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
544
|
+
let res;
|
|
545
|
+
if (!isNaN(Number(str))) {
|
|
546
|
+
res = str + "px";
|
|
547
|
+
} else if (_CSS_UNIT_RE.test(str)) {
|
|
548
|
+
res = str;
|
|
551
549
|
} else {
|
|
552
|
-
|
|
553
|
-
return value;
|
|
550
|
+
return isBase ? "" : {};
|
|
554
551
|
}
|
|
555
|
-
|
|
556
|
-
return res;
|
|
557
|
-
}
|
|
558
|
-
return { width: res };
|
|
552
|
+
return isBase ? res : { width: res };
|
|
559
553
|
}
|
|
560
554
|
function throttle(fn, delay = 1e3) {
|
|
561
555
|
let last = 0;
|
|
562
|
-
let timer =
|
|
556
|
+
let timer = void 0;
|
|
563
557
|
return function() {
|
|
564
558
|
let context = this;
|
|
565
559
|
let args = arguments;
|
|
@@ -630,28 +624,24 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
630
624
|
};
|
|
631
625
|
return _debounce;
|
|
632
626
|
}
|
|
633
|
-
function confirm(message, options) {
|
|
627
|
+
function confirm(message, options = {}, appContext = null) {
|
|
634
628
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
635
|
-
const elContext = elementPlus.ElMessageBox.install?.context || elementPlus.ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
636
629
|
const mergeOptions = {
|
|
637
630
|
title: "\u63D0\u793A",
|
|
638
631
|
draggable: true,
|
|
639
632
|
showCancelButton: false,
|
|
640
633
|
confirmButtonText: "\u786E\u5B9A",
|
|
641
634
|
dangerouslyUseHTMLString: true,
|
|
642
|
-
// 允许 HTML
|
|
643
|
-
appContext: elContext,
|
|
644
|
-
// 强制注入 Element Plus 的上下文
|
|
645
635
|
...options
|
|
646
636
|
};
|
|
647
|
-
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
637
|
+
return elementPlus.ElMessageBox.confirm(resolvedMessage, mergeOptions, appContext || elementPlus.ElMessageBox._context);
|
|
648
638
|
}
|
|
649
639
|
function getVariable(propertyName) {
|
|
650
640
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
651
641
|
return res;
|
|
652
642
|
}
|
|
653
643
|
function test() {
|
|
654
|
-
return "\u54C8\u54C8\
|
|
644
|
+
return "\u54C8\u54C8\u54C81111" + /* @__PURE__ */ new Date();
|
|
655
645
|
}
|
|
656
646
|
|
|
657
647
|
exports.$toast = $toast;
|
package/dist/base.d.cts
CHANGED
|
@@ -64,7 +64,7 @@ declare namespace $toast {
|
|
|
64
64
|
var warning: (message: any, otherParams?: {}) => void;
|
|
65
65
|
}
|
|
66
66
|
declare function setStorage(storageName: string, params: any, isSession?: boolean): void;
|
|
67
|
-
declare function getStorage(data: any, isSession?: boolean):
|
|
67
|
+
declare function getStorage(data: any, isSession?: boolean): any;
|
|
68
68
|
/**
|
|
69
69
|
*
|
|
70
70
|
* @param {*} str 需要清空的localStorage或sessionStorage, 如果不传清空所有
|
|
@@ -281,7 +281,22 @@ declare function random(min?: number, max?: number): number;
|
|
|
281
281
|
* toLine('_nameAndy') // _name-andy
|
|
282
282
|
*/
|
|
283
283
|
declare function toLine(text: any, connect?: string): any;
|
|
284
|
-
|
|
284
|
+
type WidthInput = string | number | Ref<string | number>;
|
|
285
|
+
/**
|
|
286
|
+
* processWidth(200) // { width: '200px' }
|
|
287
|
+
*
|
|
288
|
+
* processWidth('200', true) // '200px'
|
|
289
|
+
*
|
|
290
|
+
* processWidth('200.33px') // { width: '200.33px' }
|
|
291
|
+
*
|
|
292
|
+
* processWidth('') // {}
|
|
293
|
+
*
|
|
294
|
+
* processWidth('invalid') // {}
|
|
295
|
+
*
|
|
296
|
+
*/
|
|
297
|
+
declare function processWidth(initValue: WidthInput, isBase?: boolean): {
|
|
298
|
+
width: string;
|
|
299
|
+
} | {} | string;
|
|
285
300
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
286
301
|
/**
|
|
287
302
|
* 封装 Promise 执行,提供自动 loading 状态管理
|
|
@@ -331,7 +346,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
331
346
|
})
|
|
332
347
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
333
348
|
*/
|
|
334
|
-
declare function confirm(message: any, options
|
|
349
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
335
350
|
/** Function to get a CSS custom property value
|
|
336
351
|
*
|
|
337
352
|
* getVariable('--blue');
|
package/dist/base.d.mts
CHANGED
|
@@ -64,7 +64,7 @@ declare namespace $toast {
|
|
|
64
64
|
var warning: (message: any, otherParams?: {}) => void;
|
|
65
65
|
}
|
|
66
66
|
declare function setStorage(storageName: string, params: any, isSession?: boolean): void;
|
|
67
|
-
declare function getStorage(data: any, isSession?: boolean):
|
|
67
|
+
declare function getStorage(data: any, isSession?: boolean): any;
|
|
68
68
|
/**
|
|
69
69
|
*
|
|
70
70
|
* @param {*} str 需要清空的localStorage或sessionStorage, 如果不传清空所有
|
|
@@ -281,7 +281,22 @@ declare function random(min?: number, max?: number): number;
|
|
|
281
281
|
* toLine('_nameAndy') // _name-andy
|
|
282
282
|
*/
|
|
283
283
|
declare function toLine(text: any, connect?: string): any;
|
|
284
|
-
|
|
284
|
+
type WidthInput = string | number | Ref<string | number>;
|
|
285
|
+
/**
|
|
286
|
+
* processWidth(200) // { width: '200px' }
|
|
287
|
+
*
|
|
288
|
+
* processWidth('200', true) // '200px'
|
|
289
|
+
*
|
|
290
|
+
* processWidth('200.33px') // { width: '200.33px' }
|
|
291
|
+
*
|
|
292
|
+
* processWidth('') // {}
|
|
293
|
+
*
|
|
294
|
+
* processWidth('invalid') // {}
|
|
295
|
+
*
|
|
296
|
+
*/
|
|
297
|
+
declare function processWidth(initValue: WidthInput, isBase?: boolean): {
|
|
298
|
+
width: string;
|
|
299
|
+
} | {} | string;
|
|
285
300
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
286
301
|
/**
|
|
287
302
|
* 封装 Promise 执行,提供自动 loading 状态管理
|
|
@@ -331,7 +346,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
331
346
|
})
|
|
332
347
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
333
348
|
*/
|
|
334
|
-
declare function confirm(message: any, options
|
|
349
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
335
350
|
/** Function to get a CSS custom property value
|
|
336
351
|
*
|
|
337
352
|
* getVariable('--blue');
|
package/dist/base.d.ts
CHANGED
|
@@ -64,7 +64,7 @@ declare namespace $toast {
|
|
|
64
64
|
var warning: (message: any, otherParams?: {}) => void;
|
|
65
65
|
}
|
|
66
66
|
declare function setStorage(storageName: string, params: any, isSession?: boolean): void;
|
|
67
|
-
declare function getStorage(data: any, isSession?: boolean):
|
|
67
|
+
declare function getStorage(data: any, isSession?: boolean): any;
|
|
68
68
|
/**
|
|
69
69
|
*
|
|
70
70
|
* @param {*} str 需要清空的localStorage或sessionStorage, 如果不传清空所有
|
|
@@ -281,7 +281,22 @@ declare function random(min?: number, max?: number): number;
|
|
|
281
281
|
* toLine('_nameAndy') // _name-andy
|
|
282
282
|
*/
|
|
283
283
|
declare function toLine(text: any, connect?: string): any;
|
|
284
|
-
|
|
284
|
+
type WidthInput = string | number | Ref<string | number>;
|
|
285
|
+
/**
|
|
286
|
+
* processWidth(200) // { width: '200px' }
|
|
287
|
+
*
|
|
288
|
+
* processWidth('200', true) // '200px'
|
|
289
|
+
*
|
|
290
|
+
* processWidth('200.33px') // { width: '200.33px' }
|
|
291
|
+
*
|
|
292
|
+
* processWidth('') // {}
|
|
293
|
+
*
|
|
294
|
+
* processWidth('invalid') // {}
|
|
295
|
+
*
|
|
296
|
+
*/
|
|
297
|
+
declare function processWidth(initValue: WidthInput, isBase?: boolean): {
|
|
298
|
+
width: string;
|
|
299
|
+
} | {} | string;
|
|
285
300
|
declare function throttle(fn: any, delay?: number): () => void;
|
|
286
301
|
/**
|
|
287
302
|
* 封装 Promise 执行,提供自动 loading 状态管理
|
|
@@ -331,7 +346,7 @@ declare function debounce(func: Func, delay?: number, immediate?: boolean, resul
|
|
|
331
346
|
})
|
|
332
347
|
* 如果是多个dialog嵌套, 可以给上层的dom设置个id如highSettingsForm, 然后appendTo: '#highSettingsForm'
|
|
333
348
|
*/
|
|
334
|
-
declare function confirm(message: any, options
|
|
349
|
+
declare function confirm(message: any, options?: {}, appContext?: null): Promise<element_plus.MessageBoxData>;
|
|
335
350
|
/** Function to get a CSS custom property value
|
|
336
351
|
*
|
|
337
352
|
* getVariable('--blue');
|
package/dist/base.mjs
CHANGED
|
@@ -65,8 +65,8 @@ function setStorage(storageName, params, isSession = false) {
|
|
|
65
65
|
}
|
|
66
66
|
}
|
|
67
67
|
function getStorage(data, isSession = false) {
|
|
68
|
-
let getLocalData =
|
|
69
|
-
let getSessionData =
|
|
68
|
+
let getLocalData = null;
|
|
69
|
+
let getSessionData = null;
|
|
70
70
|
if (isSession) {
|
|
71
71
|
getSessionData = sessionStorage.getItem(data);
|
|
72
72
|
} else {
|
|
@@ -532,32 +532,26 @@ function toLine(text, connect = "-") {
|
|
|
532
532
|
}).toLocaleLowerCase();
|
|
533
533
|
return translateText;
|
|
534
534
|
}
|
|
535
|
+
const _CSS_UNIT_RE = /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)$/;
|
|
535
536
|
function processWidth(initValue, isBase = false) {
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
res = value + "px";
|
|
547
|
-
} else if (typeof value === "string" && /^[0-9]+(\.[0-9]+)?(px|%|em|rem|vw|vh|ch)*$/.test(value)) {
|
|
548
|
-
res = value;
|
|
537
|
+
const raw = unref(initValue);
|
|
538
|
+
if (!raw) {
|
|
539
|
+
return isBase ? "" : {};
|
|
540
|
+
}
|
|
541
|
+
const str = typeof raw === "number" ? `${raw}` : raw;
|
|
542
|
+
let res;
|
|
543
|
+
if (!isNaN(Number(str))) {
|
|
544
|
+
res = str + "px";
|
|
545
|
+
} else if (_CSS_UNIT_RE.test(str)) {
|
|
546
|
+
res = str;
|
|
549
547
|
} else {
|
|
550
|
-
|
|
551
|
-
return value;
|
|
548
|
+
return isBase ? "" : {};
|
|
552
549
|
}
|
|
553
|
-
|
|
554
|
-
return res;
|
|
555
|
-
}
|
|
556
|
-
return { width: res };
|
|
550
|
+
return isBase ? res : { width: res };
|
|
557
551
|
}
|
|
558
552
|
function throttle(fn, delay = 1e3) {
|
|
559
553
|
let last = 0;
|
|
560
|
-
let timer =
|
|
554
|
+
let timer = void 0;
|
|
561
555
|
return function() {
|
|
562
556
|
let context = this;
|
|
563
557
|
let args = arguments;
|
|
@@ -628,28 +622,24 @@ function debounce(func, delay = 500, immediate, resultCallback) {
|
|
|
628
622
|
};
|
|
629
623
|
return _debounce;
|
|
630
624
|
}
|
|
631
|
-
function confirm(message, options) {
|
|
625
|
+
function confirm(message, options = {}, appContext = null) {
|
|
632
626
|
const resolvedMessage = typeof message === "function" ? message() : message;
|
|
633
|
-
const elContext = ElMessageBox.install?.context || ElMessageBox._context || document.querySelector("#app")?._vue_app?._context;
|
|
634
627
|
const mergeOptions = {
|
|
635
628
|
title: "\u63D0\u793A",
|
|
636
629
|
draggable: true,
|
|
637
630
|
showCancelButton: false,
|
|
638
631
|
confirmButtonText: "\u786E\u5B9A",
|
|
639
632
|
dangerouslyUseHTMLString: true,
|
|
640
|
-
// 允许 HTML
|
|
641
|
-
appContext: elContext,
|
|
642
|
-
// 强制注入 Element Plus 的上下文
|
|
643
633
|
...options
|
|
644
634
|
};
|
|
645
|
-
return ElMessageBox.confirm(resolvedMessage, mergeOptions);
|
|
635
|
+
return ElMessageBox.confirm(resolvedMessage, mergeOptions, appContext || ElMessageBox._context);
|
|
646
636
|
}
|
|
647
637
|
function getVariable(propertyName) {
|
|
648
638
|
let res = getComputedStyle(document.documentElement).getPropertyValue(propertyName).trim();
|
|
649
639
|
return res;
|
|
650
640
|
}
|
|
651
641
|
function test() {
|
|
652
|
-
return "\u54C8\u54C8\
|
|
642
|
+
return "\u54C8\u54C8\u54C81111" + /* @__PURE__ */ new Date();
|
|
653
643
|
}
|
|
654
644
|
|
|
655
645
|
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 };
|