minutool 1.0.23 → 1.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/index.d.ts +4 -6
- package/dist/minutool.js +26 -26
- package/dist/minutool.js.map +1 -1
- package/dist/minutool.umd.cjs +1 -1
- package/dist/minutool.umd.cjs.map +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -281,13 +281,11 @@ export declare const countDown: (timeout: number, tickFunc?: (timeout: number) =
|
|
|
281
281
|
|
|
282
282
|
/**
|
|
283
283
|
* 创建 HTML 节点
|
|
284
|
-
* @param
|
|
285
|
-
* @param
|
|
286
|
-
* @returns
|
|
287
|
-
* @example
|
|
288
|
-
* createDomByHtml('<div>Hello</div>')
|
|
284
|
+
* @param html - HTML 字符串
|
|
285
|
+
* @param [parentNode=null] - 父级节点,如果提供则自动添加到父节点
|
|
286
|
+
* @returns 返回创建的元素,单个或多个
|
|
289
287
|
*/
|
|
290
|
-
export declare const createDomByHtml: (html: string, parentNode?: HTMLElement | null) =>
|
|
288
|
+
export declare const createDomByHtml: <T extends Element = Element>(html: string, parentNode?: HTMLElement | null) => T | T[];
|
|
291
289
|
|
|
292
290
|
/**
|
|
293
291
|
* CSS 选择器转义(处理特殊字符)
|
package/dist/minutool.js
CHANGED
|
@@ -65,7 +65,7 @@ const pe = (t, e) => {
|
|
|
65
65
|
return e;
|
|
66
66
|
const n = e.split("-")[0], o = t.find((r) => r.startsWith(n));
|
|
67
67
|
return o || t[0];
|
|
68
|
-
}, Ee = () => navigator.userAgent.toLowerCase().indexOf("firefox") > -1, Te = (1 + Math.sqrt(5)) / 2 - 1, Q = 96, Me = (t, e = Q) => t / 25.4 * e, Ae = (t) => Math.round(t * 56.6929), Se = (t) => t * 2.83464566929, Ce = (t) => t / 2.83464566929, _e = (t, e = Q) => 25.4 * t / e,
|
|
68
|
+
}, Ee = () => navigator.userAgent.toLowerCase().indexOf("firefox") > -1, Te = (1 + Math.sqrt(5)) / 2 - 1, Q = 96, Me = (t, e = Q) => t / 25.4 * e, Ae = (t) => Math.round(t * 56.6929), Se = (t) => t * 2.83464566929, Ce = (t) => t / 2.83464566929, _e = (t, e = Q) => 25.4 * t / e, De = (t, e, n) => Math.min(Math.max(t, e), n), w = (t, e, n, o = !0) => o ? t >= e && t <= n : t > e && t < n, Ne = (t, e) => Math.floor(Math.random() * (e + 1 - t)) + t, gt = (t, e = 2) => {
|
|
69
69
|
let n = Math.pow(10, e);
|
|
70
70
|
return Math.round(t * n) / n;
|
|
71
71
|
}, C = (t) => typeof t == "number" ? isFinite(t) : typeof t != "string" ? !1 : /^[+-]?(\d+\.?\d*|\.\d+)$/.test(t), Oe = (...t) => {
|
|
@@ -297,18 +297,18 @@ const At = (t = "") => "guid_" + (t || yt(6)) + ++Mt, Xe = (t, e) => {
|
|
|
297
297
|
console.log(t);
|
|
298
298
|
}, $ = new EventTarget(), Ct = /* @__PURE__ */ new Map(), L = /* @__PURE__ */ new Map();
|
|
299
299
|
let _t = 0;
|
|
300
|
-
const
|
|
300
|
+
const Dt = "__MINUTOOL_SYM_EVENT__";
|
|
301
301
|
function U(t) {
|
|
302
302
|
if (!L.has(t)) {
|
|
303
|
-
const e = `${
|
|
303
|
+
const e = `${Dt}${++_t}`;
|
|
304
304
|
L.set(t, e), Ct.set(e, t);
|
|
305
305
|
}
|
|
306
306
|
return L.get(t);
|
|
307
307
|
}
|
|
308
308
|
const cn = (t, e) => {
|
|
309
|
-
const n = t.map((o) =>
|
|
309
|
+
const n = t.map((o) => Nt(o, e));
|
|
310
310
|
return () => n.forEach((o) => o());
|
|
311
|
-
},
|
|
311
|
+
}, Nt = (t, e) => ($.addEventListener(typeof t == "symbol" ? U(t) : t, e), () => Ot(t, e)), Ot = (t, e) => {
|
|
312
312
|
$.removeEventListener(typeof t == "symbol" ? U(t) : t, e);
|
|
313
313
|
}, ln = (t, e = null) => {
|
|
314
314
|
$.dispatchEvent(new CustomEvent(typeof t == "symbol" ? U(t) : t, { detail: e }));
|
|
@@ -437,14 +437,14 @@ const _n = (t, e = !1) => (!e && t in y || (y[t] = new Promise((n, o) => {
|
|
|
437
437
|
}, r.onerror = () => {
|
|
438
438
|
o();
|
|
439
439
|
}, document.head.append(r);
|
|
440
|
-
})), y[t]),
|
|
440
|
+
})), y[t]), Dn = (t, e = !1) => (!e && t in y || (y[t] = new Promise((n, o) => {
|
|
441
441
|
let r = document.createElement("script");
|
|
442
442
|
r.src = t, r.onload = () => {
|
|
443
443
|
n();
|
|
444
444
|
}, r.onerror = () => {
|
|
445
445
|
o();
|
|
446
446
|
}, document.head.append(r);
|
|
447
|
-
})), y[t]),
|
|
447
|
+
})), y[t]), Nn = (t) => {
|
|
448
448
|
let e = t.style.visibility, n = t.style.display, o, r;
|
|
449
449
|
return t.style.visibility = "hidden", t.style.display = "block", o = t.clientWidth, r = t.clientHeight, t.style.visibility = e, t.style.display = n, { width: o, height: r };
|
|
450
450
|
}, kt = (t, e = "", n = document) => {
|
|
@@ -460,12 +460,12 @@ w(t.top + t.height, e.top, e.top + e.height) && w(t.left + t.width, e.left, e.le
|
|
|
460
460
|
return t;
|
|
461
461
|
}
|
|
462
462
|
}, In = (t, e = null) => {
|
|
463
|
-
|
|
463
|
+
const n = document.createElement("template");
|
|
464
464
|
t = t.trim(), n.innerHTML = t;
|
|
465
465
|
let o = [];
|
|
466
|
-
return e ? n.content.
|
|
466
|
+
return e ? Array.from(n.content.children).forEach((r) => {
|
|
467
467
|
o.push(e.appendChild(r));
|
|
468
|
-
}) : o = Array.from(n.content.
|
|
468
|
+
}) : o = Array.from(n.content.children), o.length === 1 ? o[0] : o;
|
|
469
469
|
}, Pt = (t, e = !1) => {
|
|
470
470
|
if (!t)
|
|
471
471
|
throw new Error("el is null");
|
|
@@ -505,8 +505,8 @@ function Pn(t, e = null) {
|
|
|
505
505
|
if (h.button !== 0)
|
|
506
506
|
return;
|
|
507
507
|
a = !0;
|
|
508
|
-
const
|
|
509
|
-
s = h.clientX -
|
|
508
|
+
const D = n.getBoundingClientRect();
|
|
509
|
+
s = h.clientX - D.left, c = h.clientY - D.top, document.addEventListener("mousemove", l), document.addEventListener("mouseup", T), h.preventDefault();
|
|
510
510
|
};
|
|
511
511
|
return e.addEventListener("mousedown", g), () => {
|
|
512
512
|
T(), e.removeEventListener("mousedown", g), n.style.position = o, n.style.left = r, n.style.top = i, n.style.transform = p;
|
|
@@ -741,7 +741,7 @@ const Gn = (t) => (A || (A = document.createElement("div")), t = t.replace(/<scr
|
|
|
741
741
|
}), b = (t, e) => {
|
|
742
742
|
let n = (t & 65535) + (e & 65535);
|
|
743
743
|
return (t >> 16) + (e >> 16) + (n >> 16) << 16 | n & 65535;
|
|
744
|
-
}, Yt = (t, e) => t << e | t >>> 32 - e, O = (t, e, n, o, r, i) => b(Yt(b(b(e, t), b(o, i)), r), n), u = (t, e, n, o, r, i, p) => O(e & n | ~e & o, t, e, r, i, p), f = (t, e, n, o, r, i, p) => O(e & o | n & ~o, t, e, r, i, p), m = (t, e, n, o, r, i, p) => O(e ^ n ^ o, t, e, r, i, p), d = (t, e, n, o, r, i, p) => O(n ^ (e | ~o), t, e, r, i, p),
|
|
744
|
+
}, Yt = (t, e) => t << e | t >>> 32 - e, O = (t, e, n, o, r, i) => b(Yt(b(b(e, t), b(o, i)), r), n), u = (t, e, n, o, r, i, p) => O(e & n | ~e & o, t, e, r, i, p), f = (t, e, n, o, r, i, p) => O(e & o | n & ~o, t, e, r, i, p), m = (t, e, n, o, r, i, p) => O(e ^ n ^ o, t, e, r, i, p), d = (t, e, n, o, r, i, p) => O(n ^ (e | ~o), t, e, r, i, p), N = (t, e) => {
|
|
745
745
|
t[e >> 5] |= 128 << e % 32, t[(e + 64 >>> 9 << 4) + 14] = e;
|
|
746
746
|
let n, o, r, i, p, a = 1732584193, s = -271733879, c = -1732584194, l = 271733878;
|
|
747
747
|
for (n = 0; n < t.length; n += 16)
|
|
@@ -760,11 +760,11 @@ const Gn = (t) => (A || (A = document.createElement("div")), t = t.replace(/<scr
|
|
|
760
760
|
for (e = 0; e < o; e += 8)
|
|
761
761
|
n[e >> 5] |= (t.charCodeAt(e / 8) & 255) << e % 32;
|
|
762
762
|
return n;
|
|
763
|
-
}, jt = (t) => nt(
|
|
763
|
+
}, jt = (t) => nt(N(F(t), t.length * 8)), qt = (t, e) => {
|
|
764
764
|
let n, o = F(t), r = [], i = [], p;
|
|
765
|
-
for (r[15] = i[15] = void 0, o.length > 16 && (o =
|
|
765
|
+
for (r[15] = i[15] = void 0, o.length > 16 && (o = N(o, t.length * 8)), n = 0; n < 16; n += 1)
|
|
766
766
|
r[n] = o[n] ^ 909522486, i[n] = o[n] ^ 1549556828;
|
|
767
|
-
return p =
|
|
767
|
+
return p = N(r.concat(F(e)), 512 + e.length * 8), nt(N(i.concat(p), 640));
|
|
768
768
|
}, ot = (t) => {
|
|
769
769
|
let e = "0123456789abcdef", n = "", o, r;
|
|
770
770
|
for (r = 0; r < t.length; r += 1)
|
|
@@ -1238,7 +1238,7 @@ const oe = (t, e = !1) => {
|
|
|
1238
1238
|
for (const n in t)
|
|
1239
1239
|
t[n] === null ? delete t[n] : e && typeof t[n] == "object" && oe(t[n], !0);
|
|
1240
1240
|
return t;
|
|
1241
|
-
}, xo = (/* @__PURE__ */ new Date()).getFullYear(), wo = (/* @__PURE__ */ new Date()).getMonth() + 1, vo = (/* @__PURE__ */ new Date()).getDate(), yo = 60 * 1e3, bo = 60 * 60 * 1e3, _ = 24 * 60 * 60 * 1e3, Eo = 7 * _, To = 30 * _, Mo = 31 * _, Ao = 365 * _, So = 366 * _, Co = 0, _o = 1,
|
|
1241
|
+
}, xo = (/* @__PURE__ */ new Date()).getFullYear(), wo = (/* @__PURE__ */ new Date()).getMonth() + 1, vo = (/* @__PURE__ */ new Date()).getDate(), yo = 60 * 1e3, bo = 60 * 60 * 1e3, _ = 24 * 60 * 60 * 1e3, Eo = 7 * _, To = 30 * _, Mo = 31 * _, Ao = 365 * _, So = 366 * _, Co = 0, _o = 1, Do = 2, No = 3, Oo = 4, Ro = 5, Lo = 6, re = ["Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"], ie = ["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"], ae = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"], se = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"], Io = ["一月", "二月", "三月", "四月", "五月", "六月", "七月", "八月", "九月", "十月", "十一月", "十二月"], ko = ["1月", "2月", "3月", "4月", "5月", "6月", "7月", "8月", "9月", "10月", "11月", "12月"], Po = ["日", "一", "二", "三", "四", "五", "六"], Fo = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"], Ho = (t, e, n) => {
|
|
1242
1242
|
let o = () => {
|
|
1243
1243
|
if (e && e(t), t-- > 0) {
|
|
1244
1244
|
setTimeout(o, 1e3);
|
|
@@ -1390,8 +1390,8 @@ const oe = (t, e = !1) => {
|
|
|
1390
1390
|
minute: "numeric",
|
|
1391
1391
|
second: "numeric"
|
|
1392
1392
|
}), r = n.formatToParts(e), i = o.formatToParts(e), p = (l) => {
|
|
1393
|
-
const T = l.find((x) => x.type === "year").value, g = l.find((x) => x.type === "month").value, h = l.find((x) => x.type === "day").value,
|
|
1394
|
-
return Date.UTC(Number(T), Number(g) - 1, Number(h), Number(
|
|
1393
|
+
const T = l.find((x) => x.type === "year").value, g = l.find((x) => x.type === "month").value, h = l.find((x) => x.type === "day").value, D = l.find((x) => x.type === "hour").value, lt = l.find((x) => x.type === "minute").value, pt = l.find((x) => x.type === "second").value;
|
|
1394
|
+
return Date.UTC(Number(T), Number(g) - 1, Number(h), Number(D), Number(lt), Number(pt));
|
|
1395
1395
|
}, a = p(r), s = p(i);
|
|
1396
1396
|
return (a - s) / 1e3 / 60;
|
|
1397
1397
|
}, le = (t) => {
|
|
@@ -1412,8 +1412,8 @@ export {
|
|
|
1412
1412
|
Lo as DAY_SATURDAY,
|
|
1413
1413
|
Co as DAY_SUNDAY,
|
|
1414
1414
|
Oo as DAY_THURSDAY,
|
|
1415
|
-
|
|
1416
|
-
|
|
1415
|
+
Do as DAY_TUESDAY,
|
|
1416
|
+
No as DAY_WEDNESDAY,
|
|
1417
1417
|
Te as GOLDEN_RATIO,
|
|
1418
1418
|
no as MIME_BINARY_DEFAULT,
|
|
1419
1419
|
io as MIME_EXTENSION_MAP,
|
|
@@ -1506,7 +1506,7 @@ export {
|
|
|
1506
1506
|
ze as formatSize,
|
|
1507
1507
|
Pt as getBoundingClientRect,
|
|
1508
1508
|
Je as getCookie,
|
|
1509
|
-
|
|
1509
|
+
Nn as getDomDimension,
|
|
1510
1510
|
ao as getJson,
|
|
1511
1511
|
Tn as getNodeXPath,
|
|
1512
1512
|
ce as getTimezoneOffsetMinutes,
|
|
@@ -1536,9 +1536,9 @@ export {
|
|
|
1536
1536
|
St as isUrl,
|
|
1537
1537
|
Fe as kebabCase,
|
|
1538
1538
|
An as keepRectInContainer,
|
|
1539
|
-
|
|
1539
|
+
De as limit,
|
|
1540
1540
|
_n as loadCss,
|
|
1541
|
-
|
|
1541
|
+
Dn as loadScript,
|
|
1542
1542
|
bn as lockElementInteraction,
|
|
1543
1543
|
Vn as markdown2Html,
|
|
1544
1544
|
eo as md5,
|
|
@@ -1559,7 +1559,7 @@ export {
|
|
|
1559
1559
|
Ot as offEvent,
|
|
1560
1560
|
pn as onDocReady,
|
|
1561
1561
|
Mn as onDomTreeChange,
|
|
1562
|
-
|
|
1562
|
+
Nt as onEvent,
|
|
1563
1563
|
cn as onEvents,
|
|
1564
1564
|
yn as onHover,
|
|
1565
1565
|
k as parseUnit,
|
|
@@ -1571,7 +1571,7 @@ export {
|
|
|
1571
1571
|
_e as pxToMm,
|
|
1572
1572
|
Vt as queryReplace,
|
|
1573
1573
|
at as queryToObj,
|
|
1574
|
-
|
|
1574
|
+
Ne as randomInt,
|
|
1575
1575
|
yt as randomString,
|
|
1576
1576
|
Ue as randomWords,
|
|
1577
1577
|
Sn as rectAssoc,
|