@ninebone/util 1.0.44 โ 1.0.45
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/nine-util.js +13 -4
- package/dist/nine-util.js.map +1 -1
- package/dist/nine-util.umd.js +1 -1
- package/dist/nine-util.umd.js.map +1 -1
- package/package.json +1 -1
package/dist/nine-util.js
CHANGED
|
@@ -1313,7 +1313,7 @@ class NineSplitter extends HTMLElement {
|
|
|
1313
1313
|
const htmlTmpl = document.createElement("template");
|
|
1314
1314
|
htmlTmpl.innerHTML = `
|
|
1315
1315
|
<style>
|
|
1316
|
-
@import "https://cdn.jsdelivr.net/npm/@ninebone/util@${"1.0.
|
|
1316
|
+
@import "https://cdn.jsdelivr.net/npm/@ninebone/util@${"1.0.45"}/dist/css/nine-util.css";
|
|
1317
1317
|
${customImport}
|
|
1318
1318
|
</style>
|
|
1319
1319
|
${gripTmpl}
|
|
@@ -1857,9 +1857,9 @@ class NineUtil {
|
|
|
1857
1857
|
return v + Array(n - String(v).length + 1).join(str || "0");
|
|
1858
1858
|
});
|
|
1859
1859
|
__publicField(this, "cut", (v, len) => {
|
|
1860
|
-
|
|
1861
|
-
|
|
1862
|
-
for (
|
|
1860
|
+
const str = v;
|
|
1861
|
+
let s = 0;
|
|
1862
|
+
for (let i = 0; i < str.length; i++) {
|
|
1863
1863
|
s += str.charCodeAt(i) > 128 ? 2 : 1;
|
|
1864
1864
|
if (s > len) return str.substring(0, i);
|
|
1865
1865
|
}
|
|
@@ -1868,6 +1868,15 @@ class NineUtil {
|
|
|
1868
1868
|
__publicField(this, "getByteLength", (v) => {
|
|
1869
1869
|
return v.replace(/[\0-\x7f]|([0-\u07ff]|(.))/g, "$&$1$2").length;
|
|
1870
1870
|
});
|
|
1871
|
+
__publicField(this, "oppositeColor", (bgColor, lightColor = "#ffffff", darkColor = "#000000") => {
|
|
1872
|
+
const color = bgColor && bgColor.charAt(0) === "#" ? bgColor.substring(1, 7) : bgColor || "ffffff";
|
|
1873
|
+
const r = parseInt(color.substring(0, 2), 16);
|
|
1874
|
+
const g = parseInt(color.substring(2, 4), 16);
|
|
1875
|
+
const b = parseInt(color.substring(4, 6), 16);
|
|
1876
|
+
if (isNaN(r) || isNaN(g) || isNaN(b)) return darkColor;
|
|
1877
|
+
const yuv = (r * 299 + g * 587 + b * 114) / 1e3;
|
|
1878
|
+
return yuv >= 128 ? darkColor : lightColor;
|
|
1879
|
+
});
|
|
1871
1880
|
/**
|
|
1872
1881
|
* ๐ฎ ์ด๊ฐ๋จ ๋ง๋ฅ ๋๋๊ทธ ํ์
์์ง (Promise/Then ๊ท๊ฒฉ)
|
|
1873
1882
|
* @param {React.Component} ContentComponent - ํ์
๋ด๋ถ์ ๋์ธ ๋ฆฌ์กํธ ์ปดํฌ๋ํธ
|