@unicom-cloud/ui 0.8.101 → 0.8.102
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/Badge.js +7 -54
- package/Copy.js +5 -4
- package/LiquidFill.js +5 -4
- package/List.js +1 -1
- package/Marquee.js +5 -4
- package/QrCode.js +5 -4
- package/Tooltip.js +3 -4
- package/Tour.js +5 -4
- package/anchor/Anchor.js +12 -12
- package/anchor/util.js +10 -10
- package/back-top/index.js +7 -7
- package/badge/index.js +109 -162
- package/card/index.js +63 -43
- package/color-picker/InputHex.js +3 -4
- package/color-picker/InputRgb.js +7 -8
- package/color-picker/Palette.js +3 -4
- package/color-picker/Panel.js +3 -4
- package/color-picker/colors.js +5 -5
- package/color-picker/hooks/useColorPicker.js +3 -4
- package/color-picker/utils.js +14 -15
- package/components/common/utils/PqbCSSTransition.js +1 -1
- package/components/common/utils/constant.js +6 -3
- package/components/common/utils/reactDOM.js +6 -4
- package/components/common/utils/{scrollIntoView.js → scrollIntoViewIfNeeded.js} +1 -1
- package/components/common/utils/setPrimaryColor.js +18 -18
- package/components/common/utils/setTheme.js +8 -9
- package/copy/index.js +3 -2
- package/dist/scroll-into-view-if-needed/compute/index.js +126 -0
- package/dist/scroll-into-view-if-needed/smooth/index.js +70 -0
- package/dist/scroll-into-view-if-needed/src/index.js +19 -19
- package/form/FormItem.js +69 -65
- package/form/context.js +6 -7
- package/grid/Col-.js +86 -0
- package/grid/Col.js +156 -73
- package/grid/Grid.js +71 -67
- package/grid/Row.js +3 -3
- package/grid/index.js +13 -13
- package/index.js +639 -662
- package/input/Textarea.js +1 -1
- package/input/autoSizeTextAreaHeight.js +7 -7
- package/liquid-fill/index.js +5 -4
- package/list/index.js +1 -1
- package/marquee/index.js +5 -4
- package/menu/Item.js +9 -9
- package/package.json +1 -1
- package/qr-code/index.js +5 -4
- package/splitter/SplitBar.js +81 -79
- package/splitter/Splitter.js +70 -78
- package/splitter/hooks/useResizable.js +9 -18
- package/splitter/hooks/useResize.js +10 -10
- package/splitter/hooks/useSizes.js +28 -28
- package/statistic/index.js +10 -10
- package/style.css +1 -1
- package/table/Table.js +369 -370
- package/table/hook/useThResizable.js +5 -4
- package/table/th-resizable/index.js +12 -11
- package/time-picker/util.js +8 -8
- package/tooltip/index.js +1 -2
- package/tour/index.js +5 -4
- package/tree/NodeList.js +1 -1
- package/types/common/utils/constant.d.ts +1 -0
- package/types/common/utils/scrollIntoViewIfNeeded.d.ts +4 -0
- package/types/common/utils/tree.d.ts +1 -0
- package/types/common/utils/tween.d.ts +1 -0
- package/types/pc/anchor/util.d.ts +1 -1
- package/types/pc/badge/interface.d.ts +2 -0
- package/types/pc/card/interface.d.ts +8 -0
- package/types/pc/color-picker/hooks/useColorPicker.d.ts +7 -2
- package/types/pc/color-picker/utils.d.ts +6 -1
- package/types/pc/form/FormItem.d.ts +1 -1
- package/types/pc/grid/Col-.d.ts +4 -0
- package/types/pc/grid/Col.d.ts +3 -2
- package/types/pc/grid/Grid.d.ts +2 -2
- package/types/pc/grid/Item.d.ts +3 -3
- package/types/pc/grid/Row.d.ts +2 -2
- package/types/pc/grid/hook/useResponsiveState.d.ts +2 -2
- package/types/pc/grid/interface.d.ts +13 -7
- package/types/pc/splitter/SplitBar.d.ts +0 -1
- package/types/pc/splitter/hooks/useResizable.d.ts +0 -1
- package/types/pc/splitter/hooks/useResize.d.ts +1 -2
- package/types/pc/splitter/interface.d.ts +0 -8
- package/types/pc/tour/index.d.ts +1 -1
- package/types/pc/upload/interface.d.ts +1 -0
- package/types/pc/utils/constant.d.ts +1 -2
- package/types/pc/utils/dayjs.d.ts +2 -1
- package/types/pc/utils/index.d.ts +2 -5
- package/types/pc/utils/scrollIntoViewIfNeeded.d.ts +3 -0
- package/types/pc/utils/tree.d.ts +2 -1
- package/types/pc/utils/tween.d.ts +1 -1
- package/typography/Ellipsis.js +5 -4
- package/typography/Operations.js +5 -4
- package/upload/request.js +12 -13
- package/upload/request_.js +2 -3
- package/utils/constant.js +5 -5
- package/utils/dayjs.js +13 -12
- package/utils/index.js +261 -284
- package/utils/scrollIntoViewIfNeeded.js +12 -0
- package/utils/tree.js +11 -9
- package/utils/tween.js +5 -5
- package/version/index.js +1 -1
- package/components/common/utils/convertToDurationBasedOnTimeUnits.js +0 -6
- package/dist/compute-scroll-into-view/src/index.js +0 -126
- package/dist/tinycolor/chunk/BOzCVdr0.js +0 -182
- package/dist/tinycolor/customize/index.js +0 -12
- package/dist/tinycolor/src/conversion.js +0 -143
- package/dist/tinycolor/src/css-color-names.js +0 -153
- package/dist/tinycolor/src/format-input.js +0 -77
- package/dist/tinycolor/src/index.js +0 -388
- package/dist/tinycolor/src/util.js +0 -32
- package/types/common/utils/convertToDurationBasedOnTimeUnits.d.ts +0 -3
- package/types/common/utils/scrollIntoView.d.ts +0 -4
- package/types/common/utils/tinycolor.d.ts +0 -1
- package/types/pc/utils/color.d.ts +0 -1
- package/types/pc/utils/computeScrollIntoView.d.ts +0 -1
- package/types/pc/utils/convertToDurationBasedOnTimeUnits.d.ts +0 -3
- package/types/pc/utils/scrollIntoView.d.ts +0 -3
- package/types/pc/utils/tinycolor.d.ts +0 -1
- package/utils/color.js +0 -4
- package/utils/computeScrollIntoView.js +0 -6
- package/utils/convertToDurationBasedOnTimeUnits.js +0 -6
- package/utils/scrollIntoView.js +0 -6
- package/utils/tinycolor.js +0 -29
package/color-picker/utils.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
|
-
import "
|
|
2
|
-
|
|
3
|
-
const G = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Object.keys(t).reduce(
|
|
1
|
+
import s from "@unicom-cloud/utils/tinycolor";
|
|
2
|
+
const R = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Object.keys(t).reduce(
|
|
4
3
|
(e, o) => ({
|
|
5
4
|
...e,
|
|
6
5
|
[o]: t[o] + (r[o] - t[o]) * n
|
|
7
6
|
}),
|
|
8
7
|
{ ...t }
|
|
9
|
-
), b = (t) => t.map(({ color: r, percent: n }) => `${r} ${n}%`).join(", "), w = (t) => `linear-gradient(to right, ${b(t)})`,
|
|
8
|
+
), b = (t) => t.map(({ color: r, percent: n }) => `${r} ${n}%`).join(", "), w = (t) => `linear-gradient(to right, ${b(t)})`, G = (t) => Array.isArray(t) ? w(t) : t, k = (t, r, n, e) => e < 1 ? `rgba(${t}, ${r}, ${n}, ${e.toFixed(2)})` : `rgb(${t}, ${r}, ${n})`, q = (t, r, n, e) => e < 1 ? new s({ r: t, g: r, b: n, a: e }).toHexString() : new s({ r: t, g: r, b: n }).toHexString(), p = (t) => {
|
|
10
9
|
const r = new s({
|
|
11
10
|
h: t.h * 360,
|
|
12
11
|
s: t.s * 100,
|
|
@@ -17,7 +16,7 @@ const G = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Objec
|
|
|
17
16
|
rgb: n,
|
|
18
17
|
hex: e
|
|
19
18
|
};
|
|
20
|
-
}, c = () => Math.random().toFixed(10).slice(2),
|
|
19
|
+
}, c = () => Math.random().toFixed(10).slice(2), A = (t, r) => t.map((n) => {
|
|
21
20
|
const e = new s(n.color).toHsv_();
|
|
22
21
|
return {
|
|
23
22
|
id: c(),
|
|
@@ -25,7 +24,7 @@ const G = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Objec
|
|
|
25
24
|
alpha: r ? 100 : e.a,
|
|
26
25
|
percent: n.percent
|
|
27
26
|
};
|
|
28
|
-
}),
|
|
27
|
+
}), F = (t, r, n) => {
|
|
29
28
|
const e = t.findIndex((a) => a.percent === r);
|
|
30
29
|
if (e !== -1)
|
|
31
30
|
return {
|
|
@@ -65,7 +64,7 @@ const G = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Objec
|
|
|
65
64
|
alpha: v,
|
|
66
65
|
percent: r
|
|
67
66
|
};
|
|
68
|
-
},
|
|
67
|
+
}, S = (t, r) => t.h === r.h && t.s === r.s && t.v === r.v, C = (t, r) => t.r === r.r && t.g === r.g && t.b === r.b && t.a === r.a, j = (t, r) => typeof t == "string" && typeof r == "string" ? t === r : Array.isArray(t) && Array.isArray(r) ? t.length === r.length && t.every((n, e) => {
|
|
69
68
|
const o = r[e];
|
|
70
69
|
return C(
|
|
71
70
|
new s(n.color).toRgba(),
|
|
@@ -73,18 +72,18 @@ const G = (t) => t.sort((r, n) => r.percent - n.percent), H = (t, r, n) => Objec
|
|
|
73
72
|
) && n.percent === o.percent;
|
|
74
73
|
}) : !1;
|
|
75
74
|
export {
|
|
76
|
-
|
|
75
|
+
S as equalsHsv,
|
|
77
76
|
C as equalsRgba,
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
77
|
+
q as formatHex,
|
|
78
|
+
k as formatRgba,
|
|
79
|
+
F as getColorByGradients,
|
|
81
80
|
p as getColorFromHsv,
|
|
82
81
|
b as getGradientString,
|
|
83
82
|
c as getRandomId,
|
|
84
|
-
|
|
85
|
-
|
|
83
|
+
j as isEqualsColors,
|
|
84
|
+
A as mapValueToGradientColor,
|
|
86
85
|
H as mix,
|
|
87
|
-
|
|
86
|
+
G as renderBackground,
|
|
88
87
|
w as renderGradientBackground,
|
|
89
|
-
|
|
88
|
+
R as sortGradientColors
|
|
90
89
|
};
|
|
@@ -9,7 +9,7 @@ import { supportRef as E } from "./is.js";
|
|
|
9
9
|
import { findDOMNode_ as R, callbackOriginRef as x } from "./reactDOM.js";
|
|
10
10
|
function j(n) {
|
|
11
11
|
const { children: e, ...i } = n, o = f(), t = f(), m = l(() => n.nodeRef === void 0 && E(e) && a(e) ? (t.current = !0, s(e, {
|
|
12
|
-
ref
|
|
12
|
+
ref(r) {
|
|
13
13
|
o.current = R(r), x(e, r);
|
|
14
14
|
}
|
|
15
15
|
})) : (t.current = !1, e), [e, n.nodeRef]);
|
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import { UI_PC_KEY as e, UI_PC_THEME_DARK_CLASS_NAME as n } from "@unicom-cloud/utils/constant/ui";
|
|
2
|
+
const E = window.document.documentElement, _ = () => {
|
|
2
3
|
};
|
|
3
4
|
export {
|
|
4
|
-
|
|
5
|
-
|
|
5
|
+
E as CSS_VARIABLE_ELEMENT,
|
|
6
|
+
_ as NOOP,
|
|
7
|
+
e as UI_PC_KEY,
|
|
8
|
+
n as UI_PC_THEME_DARK_CLASS_NAME
|
|
6
9
|
};
|
|
@@ -18,10 +18,12 @@ function p(t) {
|
|
|
18
18
|
const i = !!e?.has(o);
|
|
19
19
|
return e?.add(o), i;
|
|
20
20
|
}
|
|
21
|
-
const
|
|
21
|
+
const m = (t, o) => {
|
|
22
22
|
if (t) {
|
|
23
23
|
if (t instanceof Element)
|
|
24
24
|
return t;
|
|
25
|
+
if (t?.dom instanceof Element)
|
|
26
|
+
return t.dom;
|
|
25
27
|
if (t.current instanceof Element)
|
|
26
28
|
return t.current;
|
|
27
29
|
if (f(t.getRootDOMNode))
|
|
@@ -34,13 +36,13 @@ const N = (t, o) => {
|
|
|
34
36
|
"Element does not define the `getRootDOMNode` method causing a call to React.findDOMNode. but findDOMNode is deprecated in StrictMode. Please check the code logic",
|
|
35
37
|
{ element: t, instance: o }
|
|
36
38
|
), r) ? r(o) : null;
|
|
37
|
-
},
|
|
39
|
+
}, N = (t, o) => {
|
|
38
40
|
t && t.ref && (f(t.ref) && t?.ref(o), "current" in t.ref && (t.ref.current = o));
|
|
39
41
|
}, k = (t) => {
|
|
40
42
|
n = t;
|
|
41
43
|
};
|
|
42
44
|
export {
|
|
43
|
-
|
|
44
|
-
|
|
45
|
+
N as callbackOriginRef,
|
|
46
|
+
m as findDOMNode_,
|
|
45
47
|
k as setCreateRoot
|
|
46
48
|
};
|
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import { CSS_VARIABLE_ELEMENT as
|
|
5
|
-
function
|
|
1
|
+
import { UI_PC_PREFIX as y } from "@unicom-cloud/utils/constant/ui";
|
|
2
|
+
import c from "@unicom-cloud/utils/tinycolor";
|
|
3
|
+
import * as o from "@unicom-cloud/utils/ui-color";
|
|
4
|
+
import { CSS_VARIABLE_ELEMENT as u } from "./constant.js";
|
|
5
|
+
function g(s) {
|
|
6
6
|
const {
|
|
7
7
|
color: e,
|
|
8
|
-
element:
|
|
8
|
+
element: t = u,
|
|
9
9
|
isDark: f = !1,
|
|
10
|
-
prefix:
|
|
11
|
-
} =
|
|
10
|
+
prefix: a = y
|
|
11
|
+
} = s ?? {}, i = {
|
|
12
12
|
color: e
|
|
13
13
|
}, m = f ? o.generateDark(i) : o.generate(i);
|
|
14
|
-
new
|
|
15
|
-
|
|
16
|
-
`--${
|
|
17
|
-
|
|
14
|
+
new c(e).equals(o.primary.value) ? l() : m.forEach((n, r, p) => {
|
|
15
|
+
t.style.setProperty(
|
|
16
|
+
`--${a}-primary-${r + 1}`,
|
|
17
|
+
n.toRgbArrayString()
|
|
18
18
|
);
|
|
19
19
|
});
|
|
20
|
-
function
|
|
21
|
-
m.forEach((
|
|
22
|
-
|
|
20
|
+
function l() {
|
|
21
|
+
m.forEach((n, r, p) => {
|
|
22
|
+
t.style.removeProperty(`--${a}-primary-${r + 1}`);
|
|
23
23
|
});
|
|
24
24
|
}
|
|
25
|
-
return
|
|
25
|
+
return l;
|
|
26
26
|
}
|
|
27
27
|
export {
|
|
28
|
-
|
|
29
|
-
|
|
28
|
+
g as default,
|
|
29
|
+
g as setPrimaryColor
|
|
30
30
|
};
|
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { UI_PC_PREFIX as f } from "@unicom-cloud/utils/constant/ui.js";
|
|
2
|
-
import
|
|
3
|
-
import
|
|
4
|
-
import "
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
if (!p(s)) return;
|
|
2
|
+
import n from "@unicom-cloud/utils/tinycolor";
|
|
3
|
+
import $ from "lodash/isPlainObject";
|
|
4
|
+
import { CSS_VARIABLE_ELEMENT as p } from "./constant.js";
|
|
5
|
+
function P(s) {
|
|
6
|
+
if (!$(s)) return;
|
|
8
7
|
const { prefix: e = f, ...i } = s, c = {
|
|
9
8
|
primary: {
|
|
10
9
|
default: `--${e}-primary-6`,
|
|
@@ -41,7 +40,7 @@ function b(s) {
|
|
|
41
40
|
c[`${o}Color`] = r;
|
|
42
41
|
const l = i[o];
|
|
43
42
|
if (!l) return;
|
|
44
|
-
const a = new n(l), t =
|
|
43
|
+
const a = new n(l), t = p;
|
|
45
44
|
t.style.setProperty(r.default, a.toRgbArrayString());
|
|
46
45
|
const y = i[`${o}Hover`];
|
|
47
46
|
y ? t.style.setProperty(r.hover, new n(y).toRgbArrayString()) : t.style.setProperty(r.hover, a.lighten(10).toRgbArrayString());
|
|
@@ -50,6 +49,6 @@ function b(s) {
|
|
|
50
49
|
});
|
|
51
50
|
}
|
|
52
51
|
export {
|
|
53
|
-
|
|
54
|
-
|
|
52
|
+
P as default,
|
|
53
|
+
P as setTheme
|
|
55
54
|
};
|
package/copy/index.js
CHANGED
|
@@ -5,12 +5,11 @@ import { useContext as h, useState as b, useRef as P, useEffect as w } from "rea
|
|
|
5
5
|
import "../config-provider/ConfigProvider.js";
|
|
6
6
|
import E from "../components/common/hooks/useKeyboardEvent.js";
|
|
7
7
|
import N from "../tooltip/index.js";
|
|
8
|
+
import "@unicom-cloud/utils/date";
|
|
8
9
|
import "@unicom-cloud/utils/case-name";
|
|
9
10
|
import k from "@unicom-cloud/utils/class-name";
|
|
10
|
-
import "../dist/tinycolor/chunk/BOzCVdr0.js";
|
|
11
11
|
import "@unicom-cloud/utils/constant/ui";
|
|
12
12
|
import "../utils/contextHolder.js";
|
|
13
|
-
import "@unicom-cloud/utils/dayjs";
|
|
14
13
|
import I from "@unicom-cloud/utils/clipboard-copy";
|
|
15
14
|
import "../components/common/utils/dayjs.js";
|
|
16
15
|
import "../components/common/utils/dom.js";
|
|
@@ -47,6 +46,8 @@ import "../dist/react-transition-group/src/TransitionGroup.js";
|
|
|
47
46
|
import "../components/common/utils/reactDOM.js";
|
|
48
47
|
import "@unicom-cloud/utils/file/saveAs";
|
|
49
48
|
import "@unicom-cloud/utils/screenfull";
|
|
49
|
+
import "@unicom-cloud/utils/tinycolor";
|
|
50
|
+
import "@unicom-cloud/utils/ui-color";
|
|
50
51
|
import "@unicom-cloud/utils/constant/ui.js";
|
|
51
52
|
import "lodash/isPlainObject";
|
|
52
53
|
import "react-is";
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
const Z = (t) => typeof t == "object" && t != null && t.nodeType === 1, _ = (t, e) => e && t === "hidden" ? !1 : t !== "visible" && t !== "clip", $ = (t) => {
|
|
2
|
+
if (!t.ownerDocument || !t.ownerDocument.defaultView)
|
|
3
|
+
return null;
|
|
4
|
+
try {
|
|
5
|
+
return t.ownerDocument.defaultView.frameElement;
|
|
6
|
+
} catch {
|
|
7
|
+
return null;
|
|
8
|
+
}
|
|
9
|
+
}, tt = (t) => {
|
|
10
|
+
const e = $(t);
|
|
11
|
+
return e ? e.clientHeight < t.scrollHeight || e.clientWidth < t.scrollWidth : !1;
|
|
12
|
+
}, L = (t, e) => {
|
|
13
|
+
if (t.clientHeight < t.scrollHeight || t.clientWidth < t.scrollWidth) {
|
|
14
|
+
const h = getComputedStyle(t, null);
|
|
15
|
+
return _(h.overflowY, e) || _(h.overflowX, e) || tt(t);
|
|
16
|
+
}
|
|
17
|
+
return !1;
|
|
18
|
+
}, S = (t, e, h, i, d, f, a, u) => f < t && a > e || f > t && a < e ? 0 : f <= t && u <= h || a >= e && u >= h ? f - t - i : a > e && u < h || f < t && u > h ? a - e + d : 0, et = (t) => t.parentElement ?? (t.getRootNode().host || null), ot = (t) => {
|
|
19
|
+
const e = window.getComputedStyle(t);
|
|
20
|
+
return {
|
|
21
|
+
top: parseFloat(e.scrollMarginTop) || 0,
|
|
22
|
+
right: parseFloat(e.scrollMarginRight) || 0,
|
|
23
|
+
bottom: parseFloat(e.scrollMarginBottom) || 0,
|
|
24
|
+
left: parseFloat(e.scrollMarginLeft) || 0
|
|
25
|
+
};
|
|
26
|
+
}, nt = (t, e) => {
|
|
27
|
+
if (typeof document > "u")
|
|
28
|
+
return [];
|
|
29
|
+
const { scrollMode: h, block: i, inline: d, boundary: f, skipOverflowHiddenElements: a } = e, u = typeof f == "function" ? f : (H) => H !== f;
|
|
30
|
+
if (!Z(t))
|
|
31
|
+
throw new TypeError("Invalid target");
|
|
32
|
+
const X = document.scrollingElement || document.documentElement, y = [];
|
|
33
|
+
let l = t;
|
|
34
|
+
for (; Z(l) && u(l); ) {
|
|
35
|
+
if (l = et(l), l === X) {
|
|
36
|
+
y.push(l);
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
l != null && l === document.body && L(l) && !L(document.documentElement) || l != null && L(l, a) && y.push(l);
|
|
40
|
+
}
|
|
41
|
+
const g = window.visualViewport?.width ?? innerWidth, p = window.visualViewport?.height ?? innerHeight, { scrollX: m, scrollY: w } = window, {
|
|
42
|
+
height: W,
|
|
43
|
+
width: b,
|
|
44
|
+
top: M,
|
|
45
|
+
right: Y,
|
|
46
|
+
bottom: j,
|
|
47
|
+
left: v
|
|
48
|
+
} = t.getBoundingClientRect(), {
|
|
49
|
+
top: G,
|
|
50
|
+
right: J,
|
|
51
|
+
bottom: K,
|
|
52
|
+
left: P
|
|
53
|
+
} = ot(t);
|
|
54
|
+
let s = i === "start" || i === "nearest" ? M - G : i === "end" ? j + K : M + W / 2 - G + K, c = d === "center" ? v + b / 2 - P + J : d === "end" ? Y + J : v - P;
|
|
55
|
+
const N = [];
|
|
56
|
+
for (let H = 0; H < y.length; H++) {
|
|
57
|
+
const o = y[H], { height: E, width: x, top: C, right: O, bottom: q, left: I } = o.getBoundingClientRect();
|
|
58
|
+
if (h === "if-needed" && M >= 0 && v >= 0 && j <= p && Y <= g && // scrollingElement is added to the frames array even if it's not scrollable, in which case checking its bounds is not required
|
|
59
|
+
(o === X && !L(o) || M >= C && j <= q && v >= I && Y <= O))
|
|
60
|
+
return N;
|
|
61
|
+
const R = getComputedStyle(o), T = parseInt(R.borderLeftWidth, 10), B = parseInt(R.borderTopWidth, 10), F = parseInt(R.borderRightWidth, 10), V = parseInt(R.borderBottomWidth, 10);
|
|
62
|
+
let n = 0, r = 0;
|
|
63
|
+
const k = "offsetWidth" in o ? o.offsetWidth - o.clientWidth - T - F : 0, D = "offsetHeight" in o ? o.offsetHeight - o.clientHeight - B - V : 0, z = "offsetWidth" in o ? o.offsetWidth === 0 ? 0 : x / o.offsetWidth : 0, A = "offsetHeight" in o ? o.offsetHeight === 0 ? 0 : E / o.offsetHeight : 0;
|
|
64
|
+
if (X === o)
|
|
65
|
+
i === "start" ? n = s : i === "end" ? n = s - p : i === "nearest" ? n = S(
|
|
66
|
+
w,
|
|
67
|
+
w + p,
|
|
68
|
+
p,
|
|
69
|
+
B,
|
|
70
|
+
V,
|
|
71
|
+
w + s,
|
|
72
|
+
w + s + W,
|
|
73
|
+
W
|
|
74
|
+
) : n = s - p / 2, d === "start" ? r = c : d === "center" ? r = c - g / 2 : d === "end" ? r = c - g : r = S(
|
|
75
|
+
m,
|
|
76
|
+
m + g,
|
|
77
|
+
g,
|
|
78
|
+
T,
|
|
79
|
+
F,
|
|
80
|
+
m + c,
|
|
81
|
+
m + c + b,
|
|
82
|
+
b
|
|
83
|
+
), n = Math.max(0, n + w), r = Math.max(0, r + m);
|
|
84
|
+
else {
|
|
85
|
+
i === "start" ? n = s - C - B : i === "end" ? n = s - q + V + D : i === "nearest" ? n = S(
|
|
86
|
+
C,
|
|
87
|
+
q,
|
|
88
|
+
E,
|
|
89
|
+
B,
|
|
90
|
+
V + D,
|
|
91
|
+
s,
|
|
92
|
+
s + W,
|
|
93
|
+
W
|
|
94
|
+
) : n = s - (C + E / 2) + D / 2, d === "start" ? r = c - I - T : d === "center" ? r = c - (I + x / 2) + k / 2 : d === "end" ? r = c - O + F + k : r = S(
|
|
95
|
+
I,
|
|
96
|
+
O,
|
|
97
|
+
x,
|
|
98
|
+
T,
|
|
99
|
+
F + k,
|
|
100
|
+
c,
|
|
101
|
+
c + b,
|
|
102
|
+
b
|
|
103
|
+
);
|
|
104
|
+
const { scrollLeft: Q, scrollTop: U } = o;
|
|
105
|
+
n = A === 0 ? 0 : Math.max(
|
|
106
|
+
0,
|
|
107
|
+
Math.min(
|
|
108
|
+
U + n / A,
|
|
109
|
+
o.scrollHeight - E / A + D
|
|
110
|
+
)
|
|
111
|
+
), r = z === 0 ? 0 : Math.max(
|
|
112
|
+
0,
|
|
113
|
+
Math.min(
|
|
114
|
+
Q + r / z,
|
|
115
|
+
o.scrollWidth - x / z + k
|
|
116
|
+
)
|
|
117
|
+
), s += U - n, c += Q - r;
|
|
118
|
+
}
|
|
119
|
+
N.push({ el: o, top: n, left: r });
|
|
120
|
+
}
|
|
121
|
+
return N;
|
|
122
|
+
};
|
|
123
|
+
export {
|
|
124
|
+
nt as compute,
|
|
125
|
+
nt as default
|
|
126
|
+
};
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import u from "../src/index.js";
|
|
2
|
+
let d;
|
|
3
|
+
const b = () => (d || (d = "performance" in window ? performance.now.bind(performance) : Date.now), d());
|
|
4
|
+
function h(o) {
|
|
5
|
+
const s = b(), e = Math.min((s - o.startTime) / o.duration, 1), l = o.ease(e), a = o.startX + (o.x - o.startX) * l, n = o.startY + (o.y - o.startY) * l;
|
|
6
|
+
o.method(a, n, e, l), a !== o.x || n !== o.y ? requestAnimationFrame(() => h(o)) : o.cb();
|
|
7
|
+
}
|
|
8
|
+
function k(o, s, e, l = 600, a = (t) => 1 + --t * t * t * t * t, n, c) {
|
|
9
|
+
const t = o, i = o.scrollLeft, r = o.scrollTop;
|
|
10
|
+
h({
|
|
11
|
+
scrollable: t,
|
|
12
|
+
method: (m, w, v, y) => {
|
|
13
|
+
const f = Math.ceil(m), p = Math.ceil(w);
|
|
14
|
+
o.scrollLeft = f, o.scrollTop = p, c?.({
|
|
15
|
+
target: o,
|
|
16
|
+
elapsed: v,
|
|
17
|
+
value: y,
|
|
18
|
+
left: f,
|
|
19
|
+
top: p
|
|
20
|
+
});
|
|
21
|
+
},
|
|
22
|
+
startTime: b(),
|
|
23
|
+
startX: i,
|
|
24
|
+
startY: r,
|
|
25
|
+
x: s,
|
|
26
|
+
y: e,
|
|
27
|
+
duration: l,
|
|
28
|
+
ease: a,
|
|
29
|
+
cb: n
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
const M = (o) => o && !o.behavior || o.behavior === "smooth";
|
|
33
|
+
function T(o, s) {
|
|
34
|
+
const e = s || {};
|
|
35
|
+
return M(e) ? u(o, {
|
|
36
|
+
block: e.block,
|
|
37
|
+
inline: e.inline,
|
|
38
|
+
scrollMode: e.scrollMode,
|
|
39
|
+
boundary: e.boundary,
|
|
40
|
+
skipOverflowHiddenElements: e.skipOverflowHiddenElements,
|
|
41
|
+
behavior: (l) => Promise.all(
|
|
42
|
+
l.reduce(
|
|
43
|
+
(a, { el: n, left: c, top: t }) => {
|
|
44
|
+
const i = n.scrollLeft, r = n.scrollTop;
|
|
45
|
+
return i === c && r === t ? a : [
|
|
46
|
+
...a,
|
|
47
|
+
new Promise((m) => k(
|
|
48
|
+
n,
|
|
49
|
+
c,
|
|
50
|
+
t,
|
|
51
|
+
e.duration,
|
|
52
|
+
e.ease,
|
|
53
|
+
() => m({
|
|
54
|
+
el: n,
|
|
55
|
+
left: [i, c],
|
|
56
|
+
top: [r, t]
|
|
57
|
+
}),
|
|
58
|
+
e.onScrollChange
|
|
59
|
+
))
|
|
60
|
+
];
|
|
61
|
+
},
|
|
62
|
+
[]
|
|
63
|
+
)
|
|
64
|
+
)
|
|
65
|
+
}) : Promise.resolve(u(o, s));
|
|
66
|
+
}
|
|
67
|
+
const Y = T;
|
|
68
|
+
export {
|
|
69
|
+
Y as default
|
|
70
|
+
};
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { compute as r } from "
|
|
2
|
-
const f = (
|
|
3
|
-
const
|
|
1
|
+
import { compute as r } from "../compute/index.js";
|
|
2
|
+
const f = (o) => o === Object(o) && Object.keys(o).length !== 0, p = (o) => typeof o == "object" ? typeof o.behavior == "function" : !1, d = (o) => o === !1 ? { block: "end", inline: "nearest" } : f(o) ? o : { block: "start", inline: "nearest" }, b = (o) => {
|
|
3
|
+
const t = window.getComputedStyle(o);
|
|
4
4
|
return {
|
|
5
|
-
top: parseFloat(
|
|
6
|
-
right: parseFloat(
|
|
7
|
-
bottom: parseFloat(
|
|
8
|
-
left: parseFloat(
|
|
5
|
+
top: parseFloat(t.scrollMarginTop) || 0,
|
|
6
|
+
right: parseFloat(t.scrollMarginRight) || 0,
|
|
7
|
+
bottom: parseFloat(t.scrollMarginBottom) || 0,
|
|
8
|
+
left: parseFloat(t.scrollMarginLeft) || 0
|
|
9
9
|
};
|
|
10
|
-
},
|
|
11
|
-
let
|
|
12
|
-
for (;
|
|
13
|
-
if (
|
|
10
|
+
}, u = (o) => {
|
|
11
|
+
let t = o;
|
|
12
|
+
for (; t && t.parentNode; ) {
|
|
13
|
+
if (t.parentNode === document)
|
|
14
14
|
return !0;
|
|
15
|
-
|
|
15
|
+
t.parentNode instanceof ShadowRoot ? t = t.parentNode.host : t = t.parentNode;
|
|
16
16
|
}
|
|
17
17
|
return !1;
|
|
18
18
|
};
|
|
19
|
-
function g(
|
|
20
|
-
if (!
|
|
19
|
+
function g(o, t) {
|
|
20
|
+
if (!o.isConnected || !u(o))
|
|
21
21
|
return;
|
|
22
|
-
const e =
|
|
23
|
-
if (p(
|
|
24
|
-
return
|
|
25
|
-
const n = typeof
|
|
26
|
-
for (const { el: a, top: l, left: s } of r(
|
|
22
|
+
const e = b(o);
|
|
23
|
+
if (p(t))
|
|
24
|
+
return t.behavior(r(o, t));
|
|
25
|
+
const n = typeof t == "boolean" ? void 0 : t?.behavior;
|
|
26
|
+
for (const { el: a, top: l, left: s } of r(o, d(t))) {
|
|
27
27
|
const i = l - e.top + e.bottom, c = s - e.left + e.right;
|
|
28
28
|
a.scroll({ top: i, left: c, behavior: n });
|
|
29
29
|
}
|