@unicom-cloud/ui 0.8.99 → 0.8.100
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/Anchor.js +3 -1
- package/Badge.js +7 -6
- package/Copy.js +49 -2
- package/Flex.js +12 -0
- package/Grid.js +1 -1
- package/LiquidFill.js +3 -2
- package/Marquee.js +3 -2
- package/QrCode.js +3 -2
- package/Splitter.js +4 -5
- package/Tag.js +3 -2
- package/Tour.js +3 -2
- package/alert/index.js +38 -39
- package/anchor/index.js +5 -3
- package/badge/index.js +19 -18
- package/copy/index.js +83 -35
- package/flex/index.js +59 -0
- package/flex/interface.js +34 -0
- package/flex/utils.js +13 -0
- package/grid/{GridItem.js → Item.js} +15 -15
- package/grid/index.js +1 -1
- package/index.js +503 -493
- package/input/Button.js +39 -34
- package/input/Textarea.js +108 -104
- package/liquid-fill/index.js +3 -2
- package/marquee/index.js +3 -2
- package/package.json +1 -1
- package/qr-code/index.js +3 -2
- package/segmented/index.js +112 -104
- package/spin/index.js +75 -62
- package/splitter/Panel.js +39 -0
- package/splitter/SplitBar.js +157 -0
- package/splitter/Splitter.js +139 -0
- package/splitter/hooks/useEvent.js +12 -0
- package/splitter/hooks/useItems.js +26 -0
- package/splitter/hooks/useResizable.js +26 -0
- package/splitter/hooks/useResize.js +68 -0
- package/splitter/hooks/useSizes.js +60 -0
- package/splitter/index.js +5 -115
- package/style.css +1 -1
- package/table/Table.js +1 -1
- package/table/hook/useThResizable.js +72 -26
- package/table/tbody/Td.js +80 -77
- package/table/th-resizable/index.js +92 -35
- package/tag/index.js +42 -41
- package/tooltip/index.js +89 -82
- package/tour/index.js +5 -6
- package/types/common/space/index.d.ts +2 -1
- package/types/pc/affix/interface.d.ts +0 -2
- package/types/pc/alert/index.d.ts +2 -2
- package/types/pc/anchor/index.d.ts +2 -1
- package/types/pc/anchor/interface.d.ts +0 -2
- package/types/pc/auto-complete/interface.d.ts +0 -6
- package/types/pc/avatar/interface.d.ts +0 -4
- package/types/pc/breadcrumb/interface.d.ts +0 -3
- package/types/pc/carousel/interface.d.ts +2 -6
- package/types/pc/cascader/interface.d.ts +6 -18
- package/types/pc/checkbox/interface.d.ts +0 -1
- package/types/pc/collapse/interface.d.ts +0 -2
- package/types/pc/color-picker/interface.d.ts +0 -2
- package/types/pc/config-provider/interface.d.ts +13 -17
- package/types/pc/copy/interface.d.ts +2 -1
- package/types/pc/date-picker/interface.d.ts +0 -17
- package/types/pc/descriptions/interface.d.ts +0 -1
- package/types/pc/drawer/interface.d.ts +0 -7
- package/types/pc/dropdown/interface.d.ts +0 -1
- package/types/pc/flex/index.d.ts +9 -0
- package/types/pc/flex/interface.d.ts +61 -0
- package/types/pc/flex/utils.d.ts +9 -0
- package/types/pc/form/interface.d.ts +9 -22
- package/types/pc/form/util.d.ts +1 -1
- package/types/pc/grid/index.d.ts +3 -3
- package/types/pc/grid/interface.d.ts +1 -6
- package/types/pc/image/interface.d.ts +0 -13
- package/types/pc/index.d.ts +6 -2
- package/types/pc/input/Textarea.d.ts +2 -6
- package/types/pc/input/interface.d.ts +5 -13
- package/types/pc/input-number/interface.d.ts +0 -4
- package/types/pc/input-tag/interface.d.ts +0 -13
- package/types/pc/layout/interface.d.ts +0 -1
- package/types/pc/link/interface.d.ts +0 -1
- package/types/pc/list/interface.d.ts +0 -4
- package/types/pc/menu/interface.d.ts +0 -8
- package/types/pc/message/interface.d.ts +0 -2
- package/types/pc/modal/interface.d.ts +0 -5
- package/types/pc/notification/interface.d.ts +0 -1
- package/types/pc/pagination/interface.d.ts +0 -2
- package/types/pc/popconfirm/interface.d.ts +8 -10
- package/types/pc/popover/interface.d.ts +0 -1
- package/types/pc/progress/interface.d.ts +0 -3
- package/types/pc/resize-box/interface.d.ts +1 -7
- package/types/pc/select/interface.d.ts +0 -12
- package/types/pc/select-view/interface.d.ts +0 -7
- package/types/pc/slider/interface.d.ts +0 -4
- package/types/pc/space/index.d.ts +1 -0
- package/types/pc/spin/interface.d.ts +4 -1
- package/types/pc/splitter/Panel.d.ts +8 -0
- package/types/pc/splitter/SplitBar.d.ts +21 -0
- package/types/pc/splitter/Splitter.d.ts +4 -0
- package/types/pc/splitter/hooks/useEvent.d.ts +3 -0
- package/types/pc/splitter/hooks/useItems.d.ts +10 -0
- package/types/pc/splitter/hooks/useResizable.d.ts +8 -0
- package/types/pc/splitter/hooks/useResize.d.ts +4 -0
- package/types/pc/splitter/hooks/useSizes.d.ts +5 -0
- package/types/pc/splitter/index.d.ts +8 -4
- package/types/pc/splitter/interface.d.ts +181 -38
- package/types/pc/statistic/interface.d.ts +0 -4
- package/types/pc/steps/interface.d.ts +0 -3
- package/types/pc/table/hook/useThResizable.d.ts +2 -2
- package/types/pc/table/interface.d.ts +4 -15
- package/types/pc/tabs/interface.d.ts +0 -7
- package/types/pc/tag/index.d.ts +2 -0
- package/types/pc/tag/interface.d.ts +0 -1
- package/types/pc/time-picker/interface.d.ts +0 -7
- package/types/pc/tooltip/interface.d.ts +4 -1
- package/types/pc/transfer/interface.d.ts +2 -9
- package/types/pc/tree/interface.d.ts +2 -8
- package/types/pc/tree-select/interface.d.ts +0 -8
- package/types/pc/trigger/interface.d.ts +0 -5
- package/types/pc/typography/EditContent.d.ts +2 -1
- package/types/pc/typography/interface.d.ts +45 -30
- package/types/pc/upload/interface.d.ts +6 -11
- package/types/pc/utils/index.d.ts +1 -0
- package/types/pc/utils/names.d.ts +6 -0
- package/types/pc/utils/toArray.d.ts +7 -0
- package/types/pc/verification-code/interface.d.ts +0 -2
- package/types/pc/watermark/interface.d.ts +0 -2
- package/typography/Base.js +73 -73
- package/typography/EditContent.js +43 -33
- package/typography/Ellipsis.js +117 -184
- package/typography/Operations.js +97 -49
- package/typography/useCssEllipsis.js +7 -6
- package/utils/index.js +117 -115
- package/utils/names.js +4 -0
- package/utils/toArray.js +12 -0
- package/version/index.js +1 -1
- /package/types/pc/grid/{GridItem.d.ts → Item.d.ts} +0 -0
|
@@ -0,0 +1,139 @@
|
|
|
1
|
+
import { jsxs as I, jsx as g } from "react/jsx-runtime";
|
|
2
|
+
import p, { useState as ce, useRef as fe, useEffect as me, useImperativeHandle as pe } from "react";
|
|
3
|
+
import "../config-provider/ConfigProvider.js";
|
|
4
|
+
import ue from "../components/common/hooks/useMergeProps.js";
|
|
5
|
+
import P from "@unicom-cloud/utils/class-name";
|
|
6
|
+
import { resizeObserver as ze } from "../components/common/utils/resizeObserver.js";
|
|
7
|
+
import m from "./hooks/useEvent.js";
|
|
8
|
+
import Se from "./hooks/useItems.js";
|
|
9
|
+
import Ce from "./hooks/useResizable.js";
|
|
10
|
+
import de from "./hooks/useResize.js";
|
|
11
|
+
import he from "./hooks/useSizes.js";
|
|
12
|
+
import { InternalPanel as ge } from "./Panel.js";
|
|
13
|
+
import Re from "./SplitBar.js";
|
|
14
|
+
import Me from "../config-provider/context.js";
|
|
15
|
+
const be = {
|
|
16
|
+
layout: "horizontal"
|
|
17
|
+
};
|
|
18
|
+
function Ne(O, $) {
|
|
19
|
+
const { getPrefixCls: x, componentConfig: y, rtl: k } = p.useContext(Me), H = ue(
|
|
20
|
+
O,
|
|
21
|
+
be,
|
|
22
|
+
y?.Splitter
|
|
23
|
+
), {
|
|
24
|
+
prefixCls: U,
|
|
25
|
+
className: j,
|
|
26
|
+
style: w,
|
|
27
|
+
layout: u = "horizontal",
|
|
28
|
+
children: B,
|
|
29
|
+
rootClassName: D,
|
|
30
|
+
onResizeStart: V,
|
|
31
|
+
onResize: R,
|
|
32
|
+
onResizeEnd: z,
|
|
33
|
+
lazy: W,
|
|
34
|
+
...F
|
|
35
|
+
} = H, n = x?.("splitter", U), l = u === "vertical", c = k, r = Se(B), [S, L] = ce(), o = fe(null), T = () => {
|
|
36
|
+
const t = o.current?.offsetWidth, e = o.current?.offsetHeight, s = l ? e : t;
|
|
37
|
+
s !== 0 && L(s);
|
|
38
|
+
}, [
|
|
39
|
+
_,
|
|
40
|
+
C,
|
|
41
|
+
d,
|
|
42
|
+
M,
|
|
43
|
+
b,
|
|
44
|
+
q
|
|
45
|
+
] = he(r, S), N = Ce(r, C, c), [A, G, J, K, v] = de(
|
|
46
|
+
r,
|
|
47
|
+
N,
|
|
48
|
+
d,
|
|
49
|
+
S,
|
|
50
|
+
q,
|
|
51
|
+
c
|
|
52
|
+
), Q = m((t) => {
|
|
53
|
+
A(t), V?.(C);
|
|
54
|
+
}), X = m(
|
|
55
|
+
(t, e, s) => {
|
|
56
|
+
const a = G(t, e);
|
|
57
|
+
s ? z?.(a) : R?.(a);
|
|
58
|
+
}
|
|
59
|
+
), Y = m((t) => {
|
|
60
|
+
J(), t || z?.(C);
|
|
61
|
+
}), Z = m(
|
|
62
|
+
(t, e) => {
|
|
63
|
+
const s = K(t, e);
|
|
64
|
+
R?.(s), z?.(s);
|
|
65
|
+
}
|
|
66
|
+
), ee = P(
|
|
67
|
+
n,
|
|
68
|
+
j,
|
|
69
|
+
`${n}-${u}`,
|
|
70
|
+
{
|
|
71
|
+
[`${n}-rtl`]: c
|
|
72
|
+
},
|
|
73
|
+
D
|
|
74
|
+
), E = `${n}-mask`, i = p.useMemo(() => {
|
|
75
|
+
const t = [];
|
|
76
|
+
let e = 0;
|
|
77
|
+
for (let s = 0; s < r.length; s += 1)
|
|
78
|
+
e += d[s], t.push(e);
|
|
79
|
+
return t;
|
|
80
|
+
}, [d]);
|
|
81
|
+
return me(() => {
|
|
82
|
+
const t = ze([o.current], () => {
|
|
83
|
+
T();
|
|
84
|
+
});
|
|
85
|
+
return () => {
|
|
86
|
+
t();
|
|
87
|
+
};
|
|
88
|
+
}, [o.current]), pe($, () => ({ dom: o.current })), /* @__PURE__ */ I("div", { style: w, className: ee, ref: o, ...F, children: [
|
|
89
|
+
r.map((t, e) => {
|
|
90
|
+
const s = /* @__PURE__ */ g(
|
|
91
|
+
ge,
|
|
92
|
+
{
|
|
93
|
+
...t,
|
|
94
|
+
prefixCls: n,
|
|
95
|
+
size: _[e]
|
|
96
|
+
}
|
|
97
|
+
);
|
|
98
|
+
let a = null;
|
|
99
|
+
const f = N[e];
|
|
100
|
+
if (f) {
|
|
101
|
+
const te = (i[e - 1] || 0) + M[e], se = (i[e + 1] || 100) - b[e + 1], ne = (i[e - 1] || 0) + b[e], oe = (i[e + 1] || 100) - M[e + 1];
|
|
102
|
+
a = /* @__PURE__ */ g(
|
|
103
|
+
Re,
|
|
104
|
+
{
|
|
105
|
+
lazy: W,
|
|
106
|
+
index: e,
|
|
107
|
+
active: v === e,
|
|
108
|
+
prefixCls: n,
|
|
109
|
+
vertical: l,
|
|
110
|
+
resizable: f.resizable,
|
|
111
|
+
ariaNow: i[e] * 100,
|
|
112
|
+
ariaMin: Math.max(te, se) * 100,
|
|
113
|
+
ariaMax: Math.min(ne, oe) * 100,
|
|
114
|
+
startCollapsible: f.startCollapsible,
|
|
115
|
+
endCollapsible: f.endCollapsible,
|
|
116
|
+
onOffsetStart: Q,
|
|
117
|
+
onOffsetUpdate: (re, ie, ae, le) => {
|
|
118
|
+
let h = l ? ae : ie;
|
|
119
|
+
c && !l && (h = -h), X(re, h, le);
|
|
120
|
+
},
|
|
121
|
+
onOffsetEnd: Y,
|
|
122
|
+
onCollapse: Z,
|
|
123
|
+
containerSize: S || 0
|
|
124
|
+
}
|
|
125
|
+
);
|
|
126
|
+
}
|
|
127
|
+
return /* @__PURE__ */ I(p.Fragment, { children: [
|
|
128
|
+
s,
|
|
129
|
+
a
|
|
130
|
+
] }, `split-panel-${e}`);
|
|
131
|
+
}),
|
|
132
|
+
typeof v == "number" && /* @__PURE__ */ g("div", { "aria-hidden": !0, className: P(E, `${E}-${u}`) })
|
|
133
|
+
] });
|
|
134
|
+
}
|
|
135
|
+
const ve = p.forwardRef(Ne);
|
|
136
|
+
process.env.NODE_ENV !== "production" && (ve.displayName = "Splitter");
|
|
137
|
+
export {
|
|
138
|
+
ve as default
|
|
139
|
+
};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import n from "react";
|
|
2
|
+
function c(r) {
|
|
3
|
+
const e = n.useRef();
|
|
4
|
+
return e.current = r, n.useCallback(function(...t) {
|
|
5
|
+
if (!e.current)
|
|
6
|
+
throw new Error("Callback is not defined");
|
|
7
|
+
return e.current.apply(void 0, t);
|
|
8
|
+
}, []);
|
|
9
|
+
}
|
|
10
|
+
export {
|
|
11
|
+
c as default
|
|
12
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import o from "react";
|
|
2
|
+
import { toArray as i } from "../../utils/toArray.js";
|
|
3
|
+
function p(t) {
|
|
4
|
+
if (t && typeof t == "object")
|
|
5
|
+
return t;
|
|
6
|
+
const e = !!t;
|
|
7
|
+
return {
|
|
8
|
+
start: e,
|
|
9
|
+
end: e
|
|
10
|
+
};
|
|
11
|
+
}
|
|
12
|
+
function f(t) {
|
|
13
|
+
return o.useMemo(
|
|
14
|
+
() => i(t).filter((r) => o.isValidElement(r)).map((r) => {
|
|
15
|
+
const { props: s } = r, { collapsible: n, ...m } = s;
|
|
16
|
+
return {
|
|
17
|
+
...m,
|
|
18
|
+
collapsible: p(n)
|
|
19
|
+
};
|
|
20
|
+
}),
|
|
21
|
+
[t]
|
|
22
|
+
);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
f as default
|
|
26
|
+
};
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
import v from "react";
|
|
2
|
+
function I(l, s, o) {
|
|
3
|
+
return v.useMemo(() => {
|
|
4
|
+
const r = [];
|
|
5
|
+
for (let e = 0; e < l.length - 1; e += 1) {
|
|
6
|
+
const p = l[e], u = l[e + 1], t = s[e], n = s[e + 1], {
|
|
7
|
+
resizable: z = !0,
|
|
8
|
+
min: d,
|
|
9
|
+
collapsible: a
|
|
10
|
+
} = p, {
|
|
11
|
+
resizable: C = !0,
|
|
12
|
+
min: f,
|
|
13
|
+
collapsible: i
|
|
14
|
+
} = u, m = z && C && (t !== 0 || !d) && (n !== 0 || !f), b = a.end && t > 0 || i.start && n === 0 && t > 0, c = i.start && n > 0 || a.end && t === 0 && n > 0;
|
|
15
|
+
r[e] = {
|
|
16
|
+
resizable: m,
|
|
17
|
+
startCollapsible: !!(o ? c : b),
|
|
18
|
+
endCollapsible: !!(o ? b : c)
|
|
19
|
+
};
|
|
20
|
+
}
|
|
21
|
+
return r;
|
|
22
|
+
}, [s, l, o]);
|
|
23
|
+
}
|
|
24
|
+
export {
|
|
25
|
+
I as default
|
|
26
|
+
};
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
import x from "react";
|
|
2
|
+
import { getPtg as q } from "./useSizes.js";
|
|
3
|
+
function J(b, v, P, j, C, k) {
|
|
4
|
+
const i = b.map((t) => [t.min, t.max]), S = j || 0, M = (t) => t * S;
|
|
5
|
+
function a(t, f) {
|
|
6
|
+
return typeof t == "string" ? M(q(t)) : t ?? f;
|
|
7
|
+
}
|
|
8
|
+
const [O, y] = x.useState([]), I = x.useRef([]), [g, p] = x.useState(null), U = () => P.map(M);
|
|
9
|
+
return [
|
|
10
|
+
(t) => {
|
|
11
|
+
y(U()), p({
|
|
12
|
+
index: t,
|
|
13
|
+
confirmed: !1
|
|
14
|
+
});
|
|
15
|
+
},
|
|
16
|
+
(t, f) => {
|
|
17
|
+
let n = null;
|
|
18
|
+
if ((!g || !g.confirmed) && f !== 0) {
|
|
19
|
+
if (f > 0)
|
|
20
|
+
n = t, p({
|
|
21
|
+
index: t,
|
|
22
|
+
confirmed: !0
|
|
23
|
+
});
|
|
24
|
+
else
|
|
25
|
+
for (let r = t; r >= 0; r -= 1)
|
|
26
|
+
if (O[r] > 0 && v[r].resizable) {
|
|
27
|
+
n = r, p({
|
|
28
|
+
index: r,
|
|
29
|
+
confirmed: !0
|
|
30
|
+
});
|
|
31
|
+
break;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
const c = n ?? g?.index ?? t, e = [...O], s = c + 1, l = a(i[c][0], 0), d = a(i[s][0], 0), u = a(
|
|
35
|
+
i[c][1],
|
|
36
|
+
S
|
|
37
|
+
), m = a(
|
|
38
|
+
i[s][1],
|
|
39
|
+
S
|
|
40
|
+
);
|
|
41
|
+
let o = f;
|
|
42
|
+
return e[c] + o < l && (o = l - e[c]), e[s] - o < d && (o = e[s] - d), e[c] + o > u && (o = u - e[c]), e[s] - o > m && (o = e[s] - m), e[c] += o, e[s] -= o, C(e), e;
|
|
43
|
+
},
|
|
44
|
+
() => {
|
|
45
|
+
p(null);
|
|
46
|
+
},
|
|
47
|
+
(t, f) => {
|
|
48
|
+
const n = U(), c = k ? f === "start" ? "end" : "start" : f, e = c === "start" ? t : t + 1, s = c === "start" ? t + 1 : t, l = n[e], d = n[s];
|
|
49
|
+
if (l !== 0 && d !== 0)
|
|
50
|
+
n[e] = 0, n[s] += l, I.current[t] = l;
|
|
51
|
+
else {
|
|
52
|
+
const u = l + d, m = a(i[e][0], 0), o = a(
|
|
53
|
+
i[e][1],
|
|
54
|
+
S
|
|
55
|
+
), r = a(i[s][0], 0), E = a(
|
|
56
|
+
i[s][1],
|
|
57
|
+
S
|
|
58
|
+
), L = Math.max(m, u - E), T = Math.min(o, u - r), R = r || (T - L) / 2, z = I.current[t], h = u - z;
|
|
59
|
+
z && z <= E && z >= r && h <= o && h >= m ? (n[s] = z, n[e] = h) : (n[e] -= R, n[s] += R);
|
|
60
|
+
}
|
|
61
|
+
return C(n), n;
|
|
62
|
+
},
|
|
63
|
+
g?.index
|
|
64
|
+
];
|
|
65
|
+
}
|
|
66
|
+
export {
|
|
67
|
+
J as default
|
|
68
|
+
};
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import i from "react";
|
|
2
|
+
function l(s) {
|
|
3
|
+
return Number(s.slice(0, -1)) / 100;
|
|
4
|
+
}
|
|
5
|
+
function z(s) {
|
|
6
|
+
return typeof s == "string" && s.endsWith("%");
|
|
7
|
+
}
|
|
8
|
+
function C(s, u) {
|
|
9
|
+
const S = s.map((e) => e.size), c = s.length, o = u || 0, M = (e) => e * o, [d, x] = i.useState(() => s.map((e) => e.defaultSize)), a = i.useMemo(() => {
|
|
10
|
+
const e = [];
|
|
11
|
+
for (let r = 0; r < c; r += 1)
|
|
12
|
+
e[r] = S[r] ?? d[r];
|
|
13
|
+
return e;
|
|
14
|
+
}, [c, d, S]), p = i.useMemo(() => {
|
|
15
|
+
let e = [], r = 0;
|
|
16
|
+
for (let n = 0; n < c; n += 1) {
|
|
17
|
+
const t = a[n];
|
|
18
|
+
if (z(t))
|
|
19
|
+
e[n] = l(t);
|
|
20
|
+
else if (t || t === 0) {
|
|
21
|
+
const g = Number(t);
|
|
22
|
+
Number.isNaN(g) || (e[n] = g / o);
|
|
23
|
+
} else
|
|
24
|
+
r += 1, e[n] = void 0;
|
|
25
|
+
}
|
|
26
|
+
const f = e.reduce((n, t) => n + (t || 0), 0);
|
|
27
|
+
if (f > 1 || !r) {
|
|
28
|
+
const n = 1 / f;
|
|
29
|
+
e = e.map((t) => t === void 0 ? 0 : t * n);
|
|
30
|
+
} else {
|
|
31
|
+
const n = (1 - f) / r;
|
|
32
|
+
e = e.map((t) => t === void 0 ? n : t);
|
|
33
|
+
}
|
|
34
|
+
return e;
|
|
35
|
+
}, [a, o]), m = i.useMemo(
|
|
36
|
+
() => p.map(M),
|
|
37
|
+
[p, o]
|
|
38
|
+
), P = i.useMemo(
|
|
39
|
+
() => s.map((e) => z(e.min) ? l(e.min) : (e.min || 0) / o),
|
|
40
|
+
[s, o]
|
|
41
|
+
), N = i.useMemo(
|
|
42
|
+
() => s.map((e) => z(e.max) ? l(e.max) : (e.max || o) / o),
|
|
43
|
+
[s, o]
|
|
44
|
+
);
|
|
45
|
+
return [
|
|
46
|
+
i.useMemo(
|
|
47
|
+
() => u ? m : a,
|
|
48
|
+
[m, u]
|
|
49
|
+
),
|
|
50
|
+
m,
|
|
51
|
+
p,
|
|
52
|
+
P,
|
|
53
|
+
N,
|
|
54
|
+
x
|
|
55
|
+
];
|
|
56
|
+
}
|
|
57
|
+
export {
|
|
58
|
+
C as default,
|
|
59
|
+
l as getPtg
|
|
60
|
+
};
|
package/splitter/index.js
CHANGED
|
@@ -1,117 +1,7 @@
|
|
|
1
|
-
import
|
|
2
|
-
import
|
|
3
|
-
const
|
|
4
|
-
|
|
5
|
-
initialSize: 0.5,
|
|
6
|
-
minSize: "10%",
|
|
7
|
-
maxSize: "90%",
|
|
8
|
-
gutterSize: 8,
|
|
9
|
-
disabled: !1
|
|
10
|
-
}, A = (b) => {
|
|
11
|
-
const {
|
|
12
|
-
direction: e,
|
|
13
|
-
initialSize: D,
|
|
14
|
-
minSize: M,
|
|
15
|
-
maxSize: E,
|
|
16
|
-
gutterSize: c,
|
|
17
|
-
gutterStyle: W,
|
|
18
|
-
disabled: a,
|
|
19
|
-
onDragStart: h,
|
|
20
|
-
onDragEnd: z,
|
|
21
|
-
onDrag: p,
|
|
22
|
-
firstPane: L,
|
|
23
|
-
secondPane: N,
|
|
24
|
-
style: H,
|
|
25
|
-
className: R
|
|
26
|
-
} = { ...I, ...b }, [o, j] = P(D), [r, S] = P(!1), n = m(null), g = m(0), v = m(0), y = i(
|
|
27
|
-
(t) => {
|
|
28
|
-
if (typeof t == "string") {
|
|
29
|
-
if (t.endsWith("%"))
|
|
30
|
-
return parseFloat(t) / 100;
|
|
31
|
-
if (t.endsWith("px") && n.current) {
|
|
32
|
-
const w = parseFloat(t), d = e === "horizontal" ? n.current.offsetWidth : n.current.offsetHeight;
|
|
33
|
-
return w / d;
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
return t;
|
|
37
|
-
},
|
|
38
|
-
[e]
|
|
39
|
-
), x = y(M), $ = y(E), F = i(
|
|
40
|
-
(t) => {
|
|
41
|
-
a || (S(!0), g.current = e === "horizontal" ? t.clientX : t.clientY, v.current = o, document.body.style.cursor = e === "horizontal" ? "col-resize" : "row-resize", document.body.style.userSelect = "none", h?.());
|
|
42
|
-
},
|
|
43
|
-
[e, a, o, h]
|
|
44
|
-
), l = i(
|
|
45
|
-
(t) => {
|
|
46
|
-
if (!r || !n.current) return;
|
|
47
|
-
const d = (e === "horizontal" ? t.clientX : t.clientY) - g.current, Y = e === "horizontal" ? n.current.offsetWidth : n.current.offsetHeight;
|
|
48
|
-
let s = v.current + d / Y;
|
|
49
|
-
s = Math.max(x, Math.min($, s)), j(s), p?.(s);
|
|
50
|
-
},
|
|
51
|
-
[r, e, x, $, p]
|
|
52
|
-
), u = i(() => {
|
|
53
|
-
r && (S(!1), document.body.style.cursor = "", document.body.style.userSelect = "", z?.(o));
|
|
54
|
-
}, [r, o, z]);
|
|
55
|
-
C(() => (document.addEventListener("mousemove", l), document.addEventListener("mouseup", u), () => {
|
|
56
|
-
document.removeEventListener("mousemove", l), document.removeEventListener("mouseup", u);
|
|
57
|
-
}), [l, u]);
|
|
58
|
-
const V = `calc(${o * 100}% - ${c / 2}px)`, X = `calc(${(1 - o) * 100}% - ${c / 2}px)`;
|
|
59
|
-
return /* @__PURE__ */ k(
|
|
60
|
-
"div",
|
|
61
|
-
{
|
|
62
|
-
ref: n,
|
|
63
|
-
className: `splitter-container ${e} ${R}`,
|
|
64
|
-
style: {
|
|
65
|
-
display: "flex",
|
|
66
|
-
flexDirection: e === "horizontal" ? "row" : "column",
|
|
67
|
-
width: "100%",
|
|
68
|
-
height: "100%",
|
|
69
|
-
overflow: "hidden",
|
|
70
|
-
...H
|
|
71
|
-
},
|
|
72
|
-
children: [
|
|
73
|
-
/* @__PURE__ */ f(
|
|
74
|
-
"div",
|
|
75
|
-
{
|
|
76
|
-
className: "splitter-pane first",
|
|
77
|
-
style: {
|
|
78
|
-
flex: `0 0 ${V}`,
|
|
79
|
-
overflow: "auto",
|
|
80
|
-
minWidth: 0,
|
|
81
|
-
minHeight: 0
|
|
82
|
-
},
|
|
83
|
-
children: L
|
|
84
|
-
}
|
|
85
|
-
),
|
|
86
|
-
/* @__PURE__ */ f(
|
|
87
|
-
"div",
|
|
88
|
-
{
|
|
89
|
-
className: `splitter-gutter ${e} ${r ? "active" : ""} ${a ? "disabled" : ""}`,
|
|
90
|
-
style: {
|
|
91
|
-
[e === "horizontal" ? "width" : "height"]: c,
|
|
92
|
-
...W
|
|
93
|
-
},
|
|
94
|
-
onMouseDown: F
|
|
95
|
-
}
|
|
96
|
-
),
|
|
97
|
-
/* @__PURE__ */ f(
|
|
98
|
-
"div",
|
|
99
|
-
{
|
|
100
|
-
className: "splitter-pane second",
|
|
101
|
-
style: {
|
|
102
|
-
flex: `0 0 ${X}`,
|
|
103
|
-
overflow: "auto",
|
|
104
|
-
minWidth: 0,
|
|
105
|
-
minHeight: 0
|
|
106
|
-
},
|
|
107
|
-
children: N
|
|
108
|
-
}
|
|
109
|
-
)
|
|
110
|
-
]
|
|
111
|
-
}
|
|
112
|
-
);
|
|
113
|
-
};
|
|
1
|
+
import t from "./Panel.js";
|
|
2
|
+
import o from "./Splitter.js";
|
|
3
|
+
const e = o;
|
|
4
|
+
e.Panel = t;
|
|
114
5
|
export {
|
|
115
|
-
|
|
116
|
-
A as default
|
|
6
|
+
e as default
|
|
117
7
|
};
|