@oeos-components/utils 0.0.22 → 0.0.23
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 +16 -22
- package/dist/base.d.cts +17 -2
- package/dist/base.d.mts +17 -2
- package/dist/base.d.ts +17 -2
- package/dist/base.mjs +16 -22
- 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;
|
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 状态管理
|
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 状态管理
|
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 状态管理
|
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;
|