@kengic/core.react 0.0.1-beta.36 → 0.0.1-beta.37
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/kengic-core.react.js
CHANGED
|
@@ -45842,10 +45842,12 @@ function rre(e) {
|
|
|
45842
45842
|
}, [t, r, i]);
|
|
45843
45843
|
}
|
|
45844
45844
|
function are(e) {
|
|
45845
|
-
const {
|
|
45846
|
-
let
|
|
45847
|
-
const
|
|
45848
|
-
let
|
|
45845
|
+
const { getProps: t, domRef: r } = e, { width: i, height: l } = rj(document.documentElement) ?? { width: 0, height: 0 }, c = 48, f = 400;
|
|
45846
|
+
let p = null, m = null, g = null;
|
|
45847
|
+
const [b, E] = C.useState(null);
|
|
45848
|
+
let w = null, O = null;
|
|
45849
|
+
const M = Math.min(t.kgMinWidth ?? f, i), P = Math.min(t.kgMaxWidth ?? i, i), R = Math.min(t.kgMaxHeight ?? l, l), [A, D] = C.useState(0);
|
|
45850
|
+
let k = 0, F = 0, L = 0, z = 0, H = {
|
|
45849
45851
|
remove: () => {
|
|
45850
45852
|
}
|
|
45851
45853
|
}, K = {
|
|
@@ -45861,30 +45863,30 @@ function are(e) {
|
|
|
45861
45863
|
H.remove(), K.remove();
|
|
45862
45864
|
}
|
|
45863
45865
|
function te(U) {
|
|
45864
|
-
if (!
|
|
45866
|
+
if (!g) {
|
|
45865
45867
|
Op("弹窗元素为空.");
|
|
45866
45868
|
return;
|
|
45867
45869
|
}
|
|
45868
45870
|
const { event: W } = U ?? {}, ne = W.pageX;
|
|
45869
|
-
let Y = Math.min(
|
|
45870
|
-
|
|
45871
|
-
const V =
|
|
45872
|
-
Y !== V && (
|
|
45871
|
+
let Y = Math.min(P, Math.max(M, k + ne - L));
|
|
45872
|
+
g.offsetLeft + Y > i && (Y = i - g.offsetLeft);
|
|
45873
|
+
const V = g.offsetWidth, ve = Number(getComputedStyle(g).left.replace(/px/g, "")) + (Y - V) / 2;
|
|
45874
|
+
Y !== V && (g.style.width = `${Y}px`, g.style.left = `${ve}px`);
|
|
45873
45875
|
}
|
|
45874
45876
|
function le(U) {
|
|
45875
|
-
if (!
|
|
45877
|
+
if (!g) {
|
|
45876
45878
|
Op("弹窗元素为空.");
|
|
45877
45879
|
return;
|
|
45878
45880
|
}
|
|
45879
|
-
const { event: W } = U ?? {}, ne = W.pageY, Y = (w == null ? void 0 : w.clientHeight) ??
|
|
45880
|
-
let ve = Math.min(
|
|
45881
|
-
|
|
45882
|
-
const de =
|
|
45883
|
-
ve !== de && (
|
|
45881
|
+
const { event: W } = U ?? {}, ne = W.pageY, Y = (w == null ? void 0 : w.clientHeight) ?? c, V = (O == null ? void 0 : O.clientHeight) ?? 0, ae = Math.min((t == null ? void 0 : t.kgMinHeight) ?? Y + V + rR * 2, l);
|
|
45882
|
+
let ve = Math.min(R, Math.max(ae, F + ne - z));
|
|
45883
|
+
g.offsetTop + ve > l && (ve = l - g.offsetTop);
|
|
45884
|
+
const de = g.offsetHeight, ke = Number(getComputedStyle(g).top.replace(/px/g, "")) + (ve - de) / 2;
|
|
45885
|
+
ve !== de && (g.style.height = `${ve}px`, g.style.top = `${ke}px`);
|
|
45884
45886
|
}
|
|
45885
45887
|
function J(U) {
|
|
45886
45888
|
const { event: W, handleType: ne } = U ?? {};
|
|
45887
|
-
if (!
|
|
45889
|
+
if (!g) {
|
|
45888
45890
|
Op("弹窗元素为空.");
|
|
45889
45891
|
return;
|
|
45890
45892
|
}
|
|
@@ -45912,11 +45914,11 @@ function are(e) {
|
|
|
45912
45914
|
function Q(U) {
|
|
45913
45915
|
const { event: W, handleType: ne } = U ?? {};
|
|
45914
45916
|
if (W.stopPropagation(), W.preventDefault(), Z(), !(W instanceof MouseEvent && W.which !== 1)) {
|
|
45915
|
-
if (!
|
|
45917
|
+
if (!g) {
|
|
45916
45918
|
Op("弹窗元素为空.");
|
|
45917
45919
|
return;
|
|
45918
45920
|
}
|
|
45919
|
-
L = W.pageX, z = W.pageY, k =
|
|
45921
|
+
L = W.pageX, z = W.pageY, k = g.offsetWidth, F = g.offsetHeight, Number(getComputedStyle(g).top.replace(/px/g, "")), H = q(document.documentElement, "mousemove", (Y) => me({ event: Y, handleType: ne })), K = q(document.documentElement, "mouseup", (Y) => ie({ event: Y, handleType: ne }));
|
|
45920
45922
|
}
|
|
45921
45923
|
}
|
|
45922
45924
|
function me(U) {
|
|
@@ -45925,48 +45927,34 @@ function are(e) {
|
|
|
45925
45927
|
function ie(U) {
|
|
45926
45928
|
J(U), Z();
|
|
45927
45929
|
}
|
|
45928
|
-
|
|
45930
|
+
C.useEffect(() => {
|
|
45929
45931
|
var nt, _e, Ke, st, zt, Ht, mn, xt, gt;
|
|
45930
|
-
|
|
45931
|
-
const U = (
|
|
45932
|
+
m = ((zt = (st = (Ke = (_e = (nt = r.current) == null ? void 0 : nt.parentElement) == null ? void 0 : _e.parentElement) == null ? void 0 : Ke.parentElement) == null ? void 0 : st.parentElement) == null ? void 0 : zt.parentElement) ?? null, g = ((gt = (xt = (mn = (Ht = r.current) == null ? void 0 : Ht.parentElement) == null ? void 0 : mn.parentElement) == null ? void 0 : xt.parentElement) == null ? void 0 : gt.parentElement) ?? null, E((m == null ? void 0 : m.querySelector(".kgcrant-modal-content")) ?? null), w = (m == null ? void 0 : m.querySelector(".kgcrant-modal-header")) ?? null, O = (m == null ? void 0 : m.querySelector(".kgcrant-modal-footer")) ?? null;
|
|
45933
|
+
const U = (m == null ? void 0 : m.querySelector(".resize-handle-top-left")) ?? null, W = (m == null ? void 0 : m.querySelector(".resize-handle-top")) ?? null, ne = (m == null ? void 0 : m.querySelector(".resize-handle-top-right")) ?? null, Y = (m == null ? void 0 : m.querySelector(".resize-handle-right")) ?? null, V = (m == null ? void 0 : m.querySelector(".resize-handle-bottom-right")) ?? null, ae = (m == null ? void 0 : m.querySelector(".resize-handle-bottom")) ?? null, ve = (m == null ? void 0 : m.querySelector(".resize-handle-bottom-left")) ?? null, de = (m == null ? void 0 : m.querySelector(".resize-handle-left")) ?? null;
|
|
45932
45934
|
Dp("src/component/KgModal/hook/useDragToResize.ts | 001", {
|
|
45933
|
-
domRef:
|
|
45934
|
-
modalContentElement:
|
|
45935
|
-
modalElement:
|
|
45935
|
+
domRef: r.current,
|
|
45936
|
+
modalContentElement: b,
|
|
45937
|
+
modalElement: g,
|
|
45936
45938
|
modalFooterElement: O,
|
|
45937
45939
|
modalHeaderElement: w,
|
|
45938
|
-
modalWrapElement:
|
|
45939
|
-
open: !!
|
|
45940
|
+
modalWrapElement: m,
|
|
45941
|
+
open: !!t.open
|
|
45940
45942
|
});
|
|
45941
45943
|
const we = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "top-left" }), ke = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "top" }), Ae = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "top-right" }), $e = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "right" }), He = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "bottom-right" }), Qe = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "bottom" }), ut = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "bottom-left" }), De = (Et) => Q == null ? void 0 : Q({ event: Et, handleType: "left" });
|
|
45942
|
-
return !
|
|
45943
|
-
|
|
45944
|
+
return !r.current || !t.open || !m || !g || !b || !w || !O || (U == null || U.addEventListener("mousedown", we), W == null || W.addEventListener("mousedown", ke), ne == null || ne.addEventListener("mousedown", Ae), Y == null || Y.addEventListener("mousedown", $e), V == null || V.addEventListener("mousedown", He), ae == null || ae.addEventListener("mousedown", Qe), ve == null || ve.addEventListener("mousedown", ut), de == null || de.addEventListener("mousedown", De)), () => {
|
|
45945
|
+
p == null || p.disconnect(), Z(), U == null || U.removeEventListener("mousedown", we), W == null || W.removeEventListener("mousedown", ke), ne == null || ne.removeEventListener("mousedown", Ae), Y == null || Y.removeEventListener("mousedown", $e), V == null || V.removeEventListener("mousedown", He), ae == null || ae.removeEventListener("mousedown", Qe), ve == null || ve.removeEventListener("mousedown", ut), de == null || de.removeEventListener("mousedown", De);
|
|
45944
45946
|
};
|
|
45945
|
-
}, [
|
|
45947
|
+
}, [r, !!t.open]), C.useEffect(() => {
|
|
45946
45948
|
Dp("src/component/KgModal/hook/useDragToResize.ts | 002", {
|
|
45947
|
-
modalContentElement:
|
|
45948
|
-
}),
|
|
45949
|
-
|
|
45950
|
-
}), m.observe(E)) : m == null || m.disconnect();
|
|
45951
|
-
}, [E]), C.useEffect(() => {
|
|
45949
|
+
modalContentElement: b
|
|
45950
|
+
}), b ? (p = new ResizeObserver(() => D(b.offsetHeight)), p.observe(b)) : p == null || p.disconnect();
|
|
45951
|
+
}, [b]), C.useEffect(() => {
|
|
45952
45952
|
Dp("src/component/KgModal/hook/useDragToResize.ts | 003", {
|
|
45953
|
-
currentModalContentOffsetHeight:
|
|
45954
|
-
maxHeight:
|
|
45955
|
-
modalElement:
|
|
45956
|
-
}),
|
|
45957
|
-
}, [
|
|
45958
|
-
/**
|
|
45959
|
-
* 鼠标按下事件.
|
|
45960
|
-
*
|
|
45961
|
-
* @param param.event 鼠标事件对象.
|
|
45962
|
-
* @param param.handleType 拖拽位置.
|
|
45963
|
-
*/
|
|
45964
|
-
onMouseDown: Q,
|
|
45965
|
-
/**
|
|
45966
|
-
* 弹窗宽度.
|
|
45967
|
-
*/
|
|
45968
|
-
width: M
|
|
45969
|
-
};
|
|
45953
|
+
currentModalContentOffsetHeight: A,
|
|
45954
|
+
maxHeight: R,
|
|
45955
|
+
modalElement: g
|
|
45956
|
+
}), g && A > R && (g.style.height = `${R}px`);
|
|
45957
|
+
}, [g, A, R]);
|
|
45970
45958
|
}
|
|
45971
45959
|
function ire({}) {
|
|
45972
45960
|
return /* @__PURE__ */ Kt.jsx("div", { className: "kgcrant-kg-modal--header--buttons--close", children: /* @__PURE__ */ Kt.jsx(__, { icon: "ant-design:close-outlined" }) });
|
|
@@ -46278,21 +46266,14 @@ function Oae({}) {
|
|
|
46278
46266
|
}
|
|
46279
46267
|
function Vj({ children: e, closeIcon: t, ...r }) {
|
|
46280
46268
|
const i = C.useRef(null), l = (() => {
|
|
46281
|
-
let
|
|
46282
|
-
return
|
|
46269
|
+
let c = { ...r };
|
|
46270
|
+
return c.closable = !0, c.wrapClassName = c.wrapClassName ? `${c.wrapClassName} kgcrant-kg-modal` : "kgcrant-kg-modal", c.centered = c.centered !== void 0 ? c.centered : !0, c.keyboard = c.keyboard !== void 0 ? c.keyboard : !1, c.maskClosable = c.maskClosable !== void 0 ? c.maskClosable : !1, c.okButtonProps = c.okButtonProps !== void 0 ? c.okButtonProps : {}, c.cancelButtonProps = c.cancelButtonProps !== void 0 ? c.cancelButtonProps : {}, c.kgIsDragToMove = c.kgIsDragToMove !== void 0 ? c.kgIsDragToMove : !0, c.kgIsDragToResize = c.kgIsDragToResize !== void 0 ? c.kgIsDragToResize : !0, r.kgShowOkButton || (c.okButtonProps.className = "kgcrant-kg-invisible"), r.kgShowCancelButton || (c.cancelButtonProps.className = "kgcrant-kg-invisible"), r.kgFullHeight && (c.wrapClassName += " kgcrant-kg-modal--full-height"), c;
|
|
46283
46271
|
})();
|
|
46284
|
-
rre({ domRef: i, kgIsDragToMove: !!l.kgIsDragToMove, open: !!l.open })
|
|
46285
|
-
const { width: c, onMouseDown: f } = are({
|
|
46286
|
-
domRef: i,
|
|
46287
|
-
getProps: l,
|
|
46288
|
-
props: r
|
|
46289
|
-
});
|
|
46290
|
-
return /* @__PURE__ */ Kt.jsx(_ae, { value: r, children: /* @__PURE__ */ Kt.jsxs(
|
|
46272
|
+
return rre({ domRef: i, kgIsDragToMove: !!l.kgIsDragToMove, open: !!l.open }), are({ domRef: i, getProps: l }), /* @__PURE__ */ Kt.jsx(_ae, { value: r, children: /* @__PURE__ */ Kt.jsxs(
|
|
46291
46273
|
Cl,
|
|
46292
46274
|
{
|
|
46293
46275
|
closeIcon: /* @__PURE__ */ Kt.jsx(Oae, {}),
|
|
46294
46276
|
...l,
|
|
46295
|
-
width: c,
|
|
46296
46277
|
children: [
|
|
46297
46278
|
e,
|
|
46298
46279
|
/* @__PURE__ */ Kt.jsx("div", { ref: i }),
|
package/package.json
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { MutableRefObject } from 'react';
|
|
2
2
|
import { KgModalProps } from '../KgModal';
|
|
3
|
-
type HandleType = 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' | 'bottom' | 'bottom-left' | 'left';
|
|
4
3
|
/**
|
|
5
4
|
* 拖拽改变大小.
|
|
6
5
|
*
|
|
@@ -11,21 +10,4 @@ type HandleType = 'top-left' | 'top' | 'top-right' | 'right' | 'bottom-right' |
|
|
|
11
10
|
export declare function useDragToResize(param: {
|
|
12
11
|
domRef: MutableRefObject<HTMLDivElement | null>;
|
|
13
12
|
getProps: KgModalProps;
|
|
14
|
-
|
|
15
|
-
}): {
|
|
16
|
-
/**
|
|
17
|
-
* 鼠标按下事件.
|
|
18
|
-
*
|
|
19
|
-
* @param param.event 鼠标事件对象.
|
|
20
|
-
* @param param.handleType 拖拽位置.
|
|
21
|
-
*/
|
|
22
|
-
onMouseDown: (param: {
|
|
23
|
-
event: MouseEvent;
|
|
24
|
-
handleType: HandleType;
|
|
25
|
-
}) => void;
|
|
26
|
-
/**
|
|
27
|
-
* 弹窗宽度.
|
|
28
|
-
*/
|
|
29
|
-
width: string | number;
|
|
30
|
-
};
|
|
31
|
-
export {};
|
|
13
|
+
}): void;
|