@kep-platform/basic-component 1.0.22 → 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/PopupBox/PopupBox.d.ts +1 -1
- package/dist/Tree/Tree.js +3 -1
- package/dist/ViewPort/ViewPort.d.ts +0 -2
- package/dist/ViewPort/ViewPort.js +54 -74
- package/dist/ViewPort/ViewPortStore.d.ts +34 -16
- package/dist/ViewPort/ViewPortStore.js +49 -90
- package/dist/ViewPort/ViewPortWindow.js +14 -11
- package/dist/ViewPort/test.js +87 -8
- package/dist/Window/Window.d.ts +10 -3
- package/dist/Window/Window.js +40 -16
- package/dist/Window/WindowController.js +7 -2
- package/dist/Window/WindowOption.d.ts +1 -2
- package/dist/Window/WindowStore.d.ts +5 -0
- package/dist/Window/WindowStore.js +14 -4
- package/package.json +2 -2
- package/dist/ViewPort/Ripple.d.ts +0 -15
- package/dist/ViewPort/Ripple.js +0 -55
|
@@ -18,5 +18,5 @@ export declare function Popup(props: {
|
|
|
18
18
|
trigger?: TriggerType;
|
|
19
19
|
content?: ReactNode;
|
|
20
20
|
onVisibleChange?: (visible: boolean) => void;
|
|
21
|
-
}): string | number | boolean | React.
|
|
21
|
+
}): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
|
|
22
22
|
export default PopupBox;
|
package/dist/Tree/Tree.js
CHANGED
|
@@ -6,6 +6,8 @@ function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o =
|
|
|
6
6
|
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
7
7
|
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
8
8
|
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
9
|
+
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
10
|
+
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
9
11
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
10
12
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
11
13
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
@@ -113,7 +115,7 @@ var Tree = observer(function (_ref) {
|
|
|
113
115
|
var p;
|
|
114
116
|
var newColumns = [];
|
|
115
117
|
for (var i = 0; i < columns.length; i++) {
|
|
116
|
-
p = columns[i];
|
|
118
|
+
p = _objectSpread({}, columns[i]);
|
|
117
119
|
if (p.hideInTable) {
|
|
118
120
|
continue;
|
|
119
121
|
}
|
|
@@ -4,8 +4,6 @@ import { ViewPortWindowProps } from './ViewPortWindow';
|
|
|
4
4
|
type ViewPortProps = {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
viewPortStore: ViewPortStore;
|
|
7
|
-
onScale?: (left: number, top: number, scale: number, ratio: number) => void;
|
|
8
|
-
onScroll?: (left: number, top: number, scale: number, ratio: number) => void;
|
|
9
7
|
} & HtmlHTMLAttributes<HTMLDivElement>;
|
|
10
8
|
declare const ViewPort: React.FunctionComponent<ViewPortProps> & {
|
|
11
9
|
Window: FunctionComponent<ViewPortWindowProps>;
|
|
@@ -1,57 +1,25 @@
|
|
|
1
|
-
var _excluded = ["children", "viewPortStore"
|
|
1
|
+
var _excluded = ["children", "viewPortStore"];
|
|
2
2
|
var _templateObject, _templateObject2, _templateObject3;
|
|
3
3
|
function _extends() { _extends = Object.assign ? Object.assign.bind() : function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); }
|
|
4
4
|
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
7
|
-
import { useDraggable } from '@dnd-kit/core';
|
|
8
7
|
import { runInAction } from 'mobx';
|
|
9
8
|
import { observer } from 'mobx-react-lite';
|
|
10
|
-
import React, {
|
|
9
|
+
import React, { useEffect, useRef } from 'react';
|
|
11
10
|
import styled from 'styled-components';
|
|
12
|
-
import { RippleManagerStore } from "./Ripple";
|
|
13
11
|
import { ViewPortWindow } from "./ViewPortWindow";
|
|
14
12
|
var Container = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tposition: relative;\n\tborder: 1px solid #eee;\n\tbox-shadow: 0 0 7px 0 inset #fefefe;\n"])));
|
|
15
13
|
var Content = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\tposition: absolute;\n"])));
|
|
16
14
|
var Overlay = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
|
|
17
|
-
var rippleManagerStore = new RippleManagerStore();
|
|
18
15
|
var ViewPortComponent = observer(function (props) {
|
|
19
16
|
var children = props.children,
|
|
20
17
|
viewPortStore = props.viewPortStore,
|
|
21
|
-
onScroll = props.onScroll,
|
|
22
|
-
onScale = props.onScale,
|
|
23
18
|
rest = _objectWithoutProperties(props, _excluded);
|
|
24
|
-
var _useDraggable = useDraggable({
|
|
25
|
-
id: 'ViewPortEntity'
|
|
26
|
-
}),
|
|
27
|
-
setNodeRef = _useDraggable.setNodeRef,
|
|
28
|
-
attributes = _useDraggable.attributes,
|
|
29
|
-
listeners = _useDraggable.listeners,
|
|
30
|
-
setActivatorNodeRef = _useDraggable.setActivatorNodeRef,
|
|
31
|
-
transform = _useDraggable.transform;
|
|
32
19
|
var contentRef = useRef(null);
|
|
33
20
|
var containerRef = useRef(null);
|
|
34
|
-
var pointerDownTimer = useRef();
|
|
35
21
|
useEffect(function () {
|
|
36
|
-
|
|
37
|
-
viewPortStore.move(transform);
|
|
38
|
-
onScroll === null || onScroll === void 0 || onScroll(viewPortStore.transform.left, viewPortStore.transform.top, viewPortStore.scale, viewPortStore.ratio);
|
|
39
|
-
} else {
|
|
40
|
-
viewPortStore.endMove();
|
|
41
|
-
}
|
|
42
|
-
}, [transform]);
|
|
43
|
-
useEffect(function () {
|
|
44
|
-
var _contentRef$current, _contentRef$current2, _contentRef$current3;
|
|
45
|
-
function scaleHandler(e) {
|
|
46
|
-
e.stopPropagation();
|
|
47
|
-
e.preventDefault();
|
|
48
|
-
if (e.deltaY > 0) {
|
|
49
|
-
viewPortStore.increaseScale();
|
|
50
|
-
} else {
|
|
51
|
-
viewPortStore.decreaseScale();
|
|
52
|
-
}
|
|
53
|
-
onScale === null || onScale === void 0 || onScale(viewPortStore.transform.left, viewPortStore.transform.top, viewPortStore.scale, viewPortStore.ratio);
|
|
54
|
-
}
|
|
22
|
+
var _contentRef$current, _contentRef$current2;
|
|
55
23
|
function onContentTransitionEnd(e) {
|
|
56
24
|
if (e.target === contentRef.current) {
|
|
57
25
|
runInAction(function () {
|
|
@@ -66,55 +34,67 @@ var ViewPortComponent = observer(function (props) {
|
|
|
66
34
|
});
|
|
67
35
|
}
|
|
68
36
|
}
|
|
69
|
-
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.addEventListener('
|
|
70
|
-
|
|
37
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.addEventListener('transitionend', onContentTransitionEnd);
|
|
38
|
+
(_contentRef$current2 = contentRef.current) === null || _contentRef$current2 === void 0 || _contentRef$current2.addEventListener('transitionstart', onContentTransitionStart);
|
|
39
|
+
return function () {
|
|
40
|
+
var _contentRef$current3, _contentRef$current4;
|
|
41
|
+
(_contentRef$current3 = contentRef.current) === null || _contentRef$current3 === void 0 || _contentRef$current3.removeEventListener('transitionend', onContentTransitionEnd);
|
|
42
|
+
(_contentRef$current4 = contentRef.current) === null || _contentRef$current4 === void 0 || _contentRef$current4.removeEventListener('transitionstart', onContentTransitionStart);
|
|
43
|
+
};
|
|
44
|
+
}, []);
|
|
45
|
+
useEffect(function () {
|
|
46
|
+
function measure() {
|
|
47
|
+
var el = containerRef.current;
|
|
48
|
+
if (!el) return;
|
|
49
|
+
var r = el.getBoundingClientRect();
|
|
50
|
+
var left = r.left + (window.scrollX || window.pageXOffset || 0);
|
|
51
|
+
var top = r.top + (window.scrollY || window.pageYOffset || 0);
|
|
52
|
+
runInAction(function () {
|
|
53
|
+
viewPortStore.setContainerRect({
|
|
54
|
+
left: left,
|
|
55
|
+
top: top,
|
|
56
|
+
right: left + r.width,
|
|
57
|
+
bottom: top + r.height,
|
|
58
|
+
width: r.width,
|
|
59
|
+
height: r.height
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
measure();
|
|
64
|
+
var ro;
|
|
65
|
+
var Rz = window.ResizeObserver;
|
|
66
|
+
if (Rz) {
|
|
67
|
+
ro = new Rz(function () {
|
|
68
|
+
return measure();
|
|
69
|
+
});
|
|
70
|
+
if (ro && containerRef.current) ro.observe(containerRef.current);
|
|
71
|
+
}
|
|
72
|
+
function onScroll() {
|
|
73
|
+
measure();
|
|
74
|
+
}
|
|
75
|
+
function onResize() {
|
|
76
|
+
measure();
|
|
77
|
+
}
|
|
78
|
+
window.addEventListener('scroll', onScroll, {
|
|
79
|
+
passive: true
|
|
71
80
|
});
|
|
72
|
-
|
|
73
|
-
(_contentRef$current3 = contentRef.current) === null || _contentRef$current3 === void 0 || _contentRef$current3.addEventListener('transitionstart', onContentTransitionStart);
|
|
81
|
+
window.addEventListener('resize', onResize);
|
|
74
82
|
return function () {
|
|
75
|
-
|
|
76
|
-
|
|
83
|
+
window.removeEventListener('scroll', onScroll);
|
|
84
|
+
window.removeEventListener('resize', onResize);
|
|
85
|
+
if (ro && containerRef.current) ro.unobserve(containerRef.current);
|
|
86
|
+
if (ro && typeof ro.disconnect === 'function') ro.disconnect();
|
|
77
87
|
};
|
|
78
88
|
}, []);
|
|
79
|
-
var onContentPointerDownHandler = useCallback(function (e) {
|
|
80
|
-
if (viewPortStore.isTransition) return;
|
|
81
|
-
//鼠标点击的时候,先清除定时器,然后再异步触发pointerDown操作,这样保证doubleClick的优先级高于pointerDown
|
|
82
|
-
if (pointerDownTimer.current) clearTimeout(pointerDownTimer.current);
|
|
83
|
-
pointerDownTimer.current = setTimeout(function () {
|
|
84
|
-
var _onPointerDown, _ref;
|
|
85
|
-
listeners === null || listeners === void 0 || (_onPointerDown = (_ref = listeners).onPointerDown) === null || _onPointerDown === void 0 || _onPointerDown.call(_ref, e);
|
|
86
|
-
}, 0);
|
|
87
|
-
}, [listeners]);
|
|
88
|
-
var onContentPointerUpHandler = useCallback(function (e) {
|
|
89
|
-
var _onPointerUp, _ref2;
|
|
90
|
-
if (viewPortStore.isTransition) return;
|
|
91
|
-
listeners === null || listeners === void 0 || (_onPointerUp = (_ref2 = listeners).onPointerUp) === null || _onPointerUp === void 0 || _onPointerUp.call(_ref2, e);
|
|
92
|
-
}, [listeners]);
|
|
93
89
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
94
90
|
style: viewPortStore.containerStyle,
|
|
95
91
|
ref: containerRef
|
|
96
92
|
}, rest), /*#__PURE__*/React.createElement(Overlay, {
|
|
97
93
|
style: viewPortStore.overlayStyle
|
|
98
|
-
}),
|
|
99
|
-
ref:
|
|
100
|
-
contentRef.current = dom;
|
|
101
|
-
setNodeRef(contentRef.current);
|
|
102
|
-
setActivatorNodeRef(contentRef.current);
|
|
103
|
-
}
|
|
104
|
-
}, attributes, {
|
|
105
|
-
onPointerDown: onContentPointerDownHandler,
|
|
106
|
-
onPointerUp: onContentPointerUpHandler,
|
|
107
|
-
onDoubleClick: function onDoubleClick(e) {
|
|
108
|
-
if (viewPortStore.scale !== 1 / viewPortStore.ratio) {
|
|
109
|
-
viewPortStore.unfocus();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
|
-
var target = e.target;
|
|
113
|
-
var rect = target.getBoundingClientRect();
|
|
114
|
-
viewPortStore.focus(e.clientX - rect.left, e.clientY - rect.top);
|
|
115
|
-
},
|
|
94
|
+
}), /*#__PURE__*/React.createElement(Content, {
|
|
95
|
+
ref: contentRef,
|
|
116
96
|
style: viewPortStore.contentStyle
|
|
117
|
-
}
|
|
97
|
+
}, children));
|
|
118
98
|
});
|
|
119
99
|
var ViewPort = ViewPortComponent;
|
|
120
100
|
ViewPort.Window = ViewPortWindow;
|
|
@@ -9,26 +9,22 @@ export declare class ViewPortStore {
|
|
|
9
9
|
x: number;
|
|
10
10
|
y: number;
|
|
11
11
|
};
|
|
12
|
-
scale: number;
|
|
13
12
|
width: number;
|
|
14
13
|
height: number;
|
|
15
|
-
|
|
14
|
+
containerRect: {
|
|
15
|
+
left: number;
|
|
16
|
+
top: number;
|
|
17
|
+
right: number;
|
|
18
|
+
bottom: number;
|
|
19
|
+
width: number;
|
|
20
|
+
height: number;
|
|
21
|
+
};
|
|
16
22
|
isMoving: boolean;
|
|
17
23
|
maxZIndex: number;
|
|
18
24
|
isTransition: boolean;
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
increaseScale(): void;
|
|
22
|
-
decreaseScale(): void;
|
|
23
|
-
validScale(scale: number): number;
|
|
24
|
-
setScale(scale: number): void;
|
|
25
|
+
animationEasing: string;
|
|
26
|
+
constructor(width?: number, height?: number);
|
|
25
27
|
setTransform(left: number, top: number): void;
|
|
26
|
-
get offsetLeft(): number;
|
|
27
|
-
get offsetTop(): number;
|
|
28
|
-
formatedTransform(left: number, top: number): {
|
|
29
|
-
left: number;
|
|
30
|
-
top: number;
|
|
31
|
-
};
|
|
32
28
|
focus(left: number, top: number): void;
|
|
33
29
|
unfocus(): void;
|
|
34
30
|
move(transform: Transform): void;
|
|
@@ -41,13 +37,35 @@ export declare class ViewPortStore {
|
|
|
41
37
|
top: number;
|
|
42
38
|
width: number;
|
|
43
39
|
height: number;
|
|
44
|
-
|
|
40
|
+
};
|
|
41
|
+
setContainerRect(rect: {
|
|
42
|
+
left: number;
|
|
43
|
+
top: number;
|
|
44
|
+
right: number;
|
|
45
|
+
bottom: number;
|
|
46
|
+
width: number;
|
|
47
|
+
height: number;
|
|
48
|
+
}): void;
|
|
49
|
+
get pageBounds(): {
|
|
50
|
+
left: number;
|
|
51
|
+
top: number;
|
|
52
|
+
right: number;
|
|
53
|
+
bottom: number;
|
|
54
|
+
width: number;
|
|
55
|
+
height: number;
|
|
56
|
+
};
|
|
57
|
+
get bounds(): {
|
|
58
|
+
left: number;
|
|
59
|
+
top: number;
|
|
60
|
+
right: number;
|
|
61
|
+
bottom: number;
|
|
62
|
+
width: number;
|
|
63
|
+
height: number;
|
|
45
64
|
};
|
|
46
65
|
posInViewPort(left: number, top: number, width: number, height: number): {
|
|
47
66
|
left: number;
|
|
48
67
|
top: number;
|
|
49
68
|
width: number;
|
|
50
69
|
height: number;
|
|
51
|
-
scale: number;
|
|
52
70
|
};
|
|
53
71
|
}
|
|
@@ -7,8 +7,7 @@ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol"
|
|
|
7
7
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
8
8
|
import { action, computed, makeObservable, observable } from 'mobx';
|
|
9
9
|
export var ViewPortStore = /*#__PURE__*/function () {
|
|
10
|
-
|
|
11
|
-
function ViewPortStore(width, height, ratio) {
|
|
10
|
+
function ViewPortStore(width, height) {
|
|
12
11
|
_classCallCheck(this, ViewPortStore);
|
|
13
12
|
_defineProperty(this, "transform", {
|
|
14
13
|
left: 0,
|
|
@@ -18,120 +17,59 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
18
17
|
x: 0,
|
|
19
18
|
y: 0
|
|
20
19
|
});
|
|
21
|
-
_defineProperty(this, "scale", 0.2);
|
|
22
20
|
_defineProperty(this, "width", 600);
|
|
23
21
|
_defineProperty(this, "height", 600);
|
|
24
|
-
_defineProperty(this, "
|
|
25
|
-
|
|
22
|
+
_defineProperty(this, "containerRect", {
|
|
23
|
+
left: 0,
|
|
24
|
+
top: 0,
|
|
25
|
+
right: 0,
|
|
26
|
+
bottom: 0,
|
|
27
|
+
width: 0,
|
|
28
|
+
height: 0
|
|
29
|
+
});
|
|
26
30
|
_defineProperty(this, "isMoving", false);
|
|
27
31
|
_defineProperty(this, "maxZIndex", 1);
|
|
28
32
|
_defineProperty(this, "isTransition", false);
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
this.scale = 1 / this.ratio;
|
|
32
|
-
}
|
|
33
|
+
//在动画执行期间,禁止任何鼠标操作
|
|
34
|
+
_defineProperty(this, "animationEasing", 'ease-in-out');
|
|
33
35
|
if (width) this.width = width;
|
|
34
36
|
if (height) this.height = height;
|
|
35
37
|
makeObservable(this, {
|
|
36
38
|
transform: observable.struct,
|
|
37
39
|
offset: observable.struct,
|
|
38
|
-
scale: observable,
|
|
39
40
|
width: observable,
|
|
40
41
|
height: observable,
|
|
41
|
-
|
|
42
|
+
containerRect: observable.struct,
|
|
42
43
|
isMoving: observable,
|
|
43
44
|
maxZIndex: observable,
|
|
44
45
|
isTransition: observable,
|
|
45
|
-
|
|
46
|
-
increaseScale: action,
|
|
47
|
-
decreaseScale: action,
|
|
48
|
-
setScale: action,
|
|
46
|
+
animationEasing: observable,
|
|
49
47
|
setTransform: action,
|
|
50
|
-
offsetLeft: computed,
|
|
51
|
-
offsetTop: computed,
|
|
52
48
|
focus: action,
|
|
53
49
|
unfocus: action,
|
|
54
50
|
move: action,
|
|
55
51
|
endMove: action,
|
|
56
|
-
|
|
57
|
-
contentStyle: computed.struct,
|
|
52
|
+
setContainerRect: action,
|
|
58
53
|
viewPortRect: computed.struct,
|
|
59
54
|
overlayStyle: computed.struct
|
|
60
55
|
});
|
|
61
56
|
}
|
|
62
57
|
_createClass(ViewPortStore, [{
|
|
63
|
-
key: "scaleStep",
|
|
64
|
-
get: function get() {
|
|
65
|
-
return 1 / this.ratio * 0.125;
|
|
66
|
-
}
|
|
67
|
-
}, {
|
|
68
|
-
key: "increaseScale",
|
|
69
|
-
value: function increaseScale() {
|
|
70
|
-
this.setScale(this.scale + this.scaleStep);
|
|
71
|
-
this.setTransform(this.transform.left, this.transform.top);
|
|
72
|
-
}
|
|
73
|
-
}, {
|
|
74
|
-
key: "decreaseScale",
|
|
75
|
-
value: function decreaseScale() {
|
|
76
|
-
this.setScale(this.scale - this.scaleStep);
|
|
77
|
-
this.setTransform(this.transform.left, this.transform.top);
|
|
78
|
-
}
|
|
79
|
-
}, {
|
|
80
|
-
key: "validScale",
|
|
81
|
-
value: function validScale(scale) {
|
|
82
|
-
return Math.min(1, Math.max(1 / this.ratio, scale));
|
|
83
|
-
}
|
|
84
|
-
}, {
|
|
85
|
-
key: "setScale",
|
|
86
|
-
value: function setScale(scale) {
|
|
87
|
-
this.scale = this.validScale(scale);
|
|
88
|
-
}
|
|
89
|
-
}, {
|
|
90
58
|
key: "setTransform",
|
|
91
59
|
value: function setTransform(left, top) {
|
|
92
|
-
this.transform =
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
/* 这个函数是获取left偏移量 */
|
|
96
|
-
}, {
|
|
97
|
-
key: "offsetLeft",
|
|
98
|
-
get: function get() {
|
|
99
|
-
return (this.width * this.ratio * this.scale - this.width) / 2;
|
|
100
|
-
}
|
|
101
|
-
/* 获取top偏移量 */
|
|
102
|
-
}, {
|
|
103
|
-
key: "offsetTop",
|
|
104
|
-
get: function get() {
|
|
105
|
-
return (this.height * this.ratio * this.scale - this.height) / 2;
|
|
106
|
-
}
|
|
107
|
-
}, {
|
|
108
|
-
key: "formatedTransform",
|
|
109
|
-
value: function formatedTransform(left, top) {
|
|
110
|
-
var areaLimit = {
|
|
111
|
-
left: {
|
|
112
|
-
min: -this.offsetLeft,
|
|
113
|
-
max: this.offsetLeft
|
|
114
|
-
},
|
|
115
|
-
top: {
|
|
116
|
-
min: -this.offsetTop,
|
|
117
|
-
max: this.offsetTop
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
return {
|
|
121
|
-
left: Math.max(areaLimit.left.min, Math.min(left, areaLimit.left.max)),
|
|
122
|
-
top: Math.max(areaLimit.top.min, Math.min(top, areaLimit.top.max))
|
|
60
|
+
this.transform = {
|
|
61
|
+
left: left,
|
|
62
|
+
top: top
|
|
123
63
|
};
|
|
124
64
|
}
|
|
125
65
|
}, {
|
|
126
66
|
key: "focus",
|
|
127
67
|
value: function focus(left, top) {
|
|
128
|
-
this.
|
|
129
|
-
this.setTransform((1 - this.ratio) * left + this.offsetLeft, (1 - this.ratio) * top + this.offsetTop);
|
|
68
|
+
this.setTransform(left, top);
|
|
130
69
|
}
|
|
131
70
|
}, {
|
|
132
71
|
key: "unfocus",
|
|
133
72
|
value: function unfocus() {
|
|
134
|
-
this.setScale(1 / this.ratio);
|
|
135
73
|
this.setTransform(0, 0);
|
|
136
74
|
}
|
|
137
75
|
}, {
|
|
@@ -158,11 +96,11 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
158
96
|
position: 'absolute',
|
|
159
97
|
left: 0,
|
|
160
98
|
top: 0,
|
|
161
|
-
transform: " translate(".concat(this.transform.left
|
|
162
|
-
width: this.width
|
|
163
|
-
height: this.height
|
|
99
|
+
transform: " translate(".concat(this.transform.left, "px,").concat(this.transform.top, "px)"),
|
|
100
|
+
width: this.width + 'px',
|
|
101
|
+
height: this.height + 'px',
|
|
164
102
|
transformOrigin: 'left top',
|
|
165
|
-
transition: this.isMoving ? 'none' :
|
|
103
|
+
transition: this.isMoving ? 'none' : "all 0.3s ".concat(this.animationEasing),
|
|
166
104
|
background: '#188fff67',
|
|
167
105
|
cursor: this.isMoving ? 'grab' : 'default'
|
|
168
106
|
};
|
|
@@ -197,17 +135,38 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
197
135
|
get: function get() {
|
|
198
136
|
return this.posInViewPort(0, 0, this.width, this.height);
|
|
199
137
|
}
|
|
138
|
+
}, {
|
|
139
|
+
key: "setContainerRect",
|
|
140
|
+
value: function setContainerRect(rect) {
|
|
141
|
+
this.containerRect = rect;
|
|
142
|
+
}
|
|
143
|
+
}, {
|
|
144
|
+
key: "pageBounds",
|
|
145
|
+
get: function get() {
|
|
146
|
+
return this.containerRect;
|
|
147
|
+
}
|
|
200
148
|
|
|
201
|
-
|
|
149
|
+
// 暴露视窗的空间坐标(容器坐标系)
|
|
150
|
+
}, {
|
|
151
|
+
key: "bounds",
|
|
152
|
+
get: function get() {
|
|
153
|
+
return {
|
|
154
|
+
left: 0,
|
|
155
|
+
top: 0,
|
|
156
|
+
right: this.width,
|
|
157
|
+
bottom: this.height,
|
|
158
|
+
width: this.width,
|
|
159
|
+
height: this.height
|
|
160
|
+
};
|
|
161
|
+
}
|
|
202
162
|
}, {
|
|
203
163
|
key: "posInViewPort",
|
|
204
164
|
value: function posInViewPort(left, top, width, height) {
|
|
205
165
|
return {
|
|
206
|
-
left:
|
|
207
|
-
top:
|
|
208
|
-
width: width
|
|
209
|
-
height: height
|
|
210
|
-
scale: this.scale
|
|
166
|
+
left: -this.transform.left + left,
|
|
167
|
+
top: -this.transform.top + top,
|
|
168
|
+
width: width,
|
|
169
|
+
height: height
|
|
211
170
|
};
|
|
212
171
|
}
|
|
213
172
|
}]);
|
|
@@ -16,7 +16,7 @@ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.g
|
|
|
16
16
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
17
17
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
18
18
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
19
|
-
import { action, makeObservable, observable, override } from 'mobx';
|
|
19
|
+
import { action, makeObservable, observable, override, runInAction } from 'mobx';
|
|
20
20
|
import { observer } from 'mobx-react-lite';
|
|
21
21
|
import React, { useEffect } from 'react';
|
|
22
22
|
import { WindowStore } from "../Window";
|
|
@@ -60,7 +60,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
|
|
|
60
60
|
zIndex: this.zIndex,
|
|
61
61
|
transform: 'scale(0)',
|
|
62
62
|
transformOrigin: 'center',
|
|
63
|
-
transition:
|
|
63
|
+
transition: "all ".concat(this.animationDurationClose, " ").concat(this.animationEasing)
|
|
64
64
|
};
|
|
65
65
|
case 'minimize':
|
|
66
66
|
return {
|
|
@@ -71,18 +71,18 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
|
|
|
71
71
|
zIndex: this.zIndex,
|
|
72
72
|
transform: 'scale(0)',
|
|
73
73
|
transformOrigin: 'left top',
|
|
74
|
-
transition: "all ".concat(
|
|
74
|
+
transition: "all ".concat(this.animationDurationMinimize, " ").concat(this.animationEasing)
|
|
75
75
|
};
|
|
76
76
|
case 'fullscreen':
|
|
77
77
|
return {
|
|
78
78
|
left: this.fullscreenPos.left + 'px',
|
|
79
79
|
top: this.fullscreenPos.top + 'px',
|
|
80
|
-
width: this.fullscreenPos.width
|
|
81
|
-
height: this.fullscreenPos.height
|
|
82
|
-
transform:
|
|
80
|
+
width: this.fullscreenPos.width + 'px',
|
|
81
|
+
height: this.fullscreenPos.height + 'px',
|
|
82
|
+
transform: 'none',
|
|
83
83
|
zIndex: this.zIndex,
|
|
84
84
|
transformOrigin: 'left top',
|
|
85
|
-
transition:
|
|
85
|
+
transition: "all ".concat(this.animationDurationFullscreen, " ").concat(this.animationEasing)
|
|
86
86
|
};
|
|
87
87
|
case 'normal':
|
|
88
88
|
default:
|
|
@@ -104,7 +104,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
|
|
|
104
104
|
height: this.height + 'px',
|
|
105
105
|
zIndex: this.zIndex,
|
|
106
106
|
transform: 'none',
|
|
107
|
-
transition:
|
|
107
|
+
transition: "all ".concat(this.animationDurationNormal, " ").concat(this.animationEasing)
|
|
108
108
|
};
|
|
109
109
|
}
|
|
110
110
|
}
|
|
@@ -123,9 +123,10 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
|
|
|
123
123
|
key: "calculateTransform",
|
|
124
124
|
value: function calculateTransform(transform) {
|
|
125
125
|
var _this$transform, _this$transform2;
|
|
126
|
+
// 固定正常尺寸下,直接使用像素位移
|
|
126
127
|
return {
|
|
127
|
-
x:
|
|
128
|
-
y:
|
|
128
|
+
x: transform.x - (((_this$transform = this.transform) === null || _this$transform === void 0 ? void 0 : _this$transform.x) || 0),
|
|
129
|
+
y: transform.y - (((_this$transform2 = this.transform) === null || _this$transform2 === void 0 ? void 0 : _this$transform2.y) || 0)
|
|
129
130
|
};
|
|
130
131
|
}
|
|
131
132
|
}, {
|
|
@@ -253,7 +254,9 @@ export var ViewPortWindow = observer(function ViewPortWindow(props) {
|
|
|
253
254
|
rest = _objectWithoutProperties(props, _excluded);
|
|
254
255
|
useEffect(function () {
|
|
255
256
|
if (!window.disableDefaultCenterDisplay) {
|
|
256
|
-
|
|
257
|
+
runInAction(function () {
|
|
258
|
+
window.centerDisplay();
|
|
259
|
+
});
|
|
257
260
|
}
|
|
258
261
|
}, []);
|
|
259
262
|
return /*#__PURE__*/React.createElement(Window, _extends({
|
package/dist/ViewPort/test.js
CHANGED
|
@@ -1,5 +1,12 @@
|
|
|
1
1
|
var _templateObject;
|
|
2
2
|
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
3
|
+
function _createForOfIteratorHelper(o, allowArrayLike) { var it = typeof Symbol !== "undefined" && o[Symbol.iterator] || o["@@iterator"]; if (!it) { if (Array.isArray(o) || (it = _unsupportedIterableToArray(o)) || allowArrayLike && o && typeof o.length === "number") { if (it) o = it; var i = 0; var F = function F() {}; return { s: F, n: function n() { if (i >= o.length) return { done: true }; return { done: false, value: o[i++] }; }, e: function e(_e) { throw _e; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var normalCompletion = true, didErr = false, err; return { s: function s() { it = it.call(o); }, n: function n() { var step = it.next(); normalCompletion = step.done; return step; }, e: function e(_e2) { didErr = true; err = _e2; }, f: function f() { try { if (!normalCompletion && it.return != null) it.return(); } finally { if (didErr) throw err; } } }; }
|
|
4
|
+
function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
|
|
5
|
+
function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
|
|
6
|
+
function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
|
|
7
|
+
function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) arr2[i] = arr[i]; return arr2; }
|
|
8
|
+
function _iterableToArrayLimit(r, l) { var t = null == r ? null : "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (null != t) { var e, n, i, u, a = [], f = !0, o = !1; try { if (i = (t = t.call(r)).next, 0 === l) { if (Object(t) !== t) return; f = !1; } else for (; !(f = (e = i.call(t)).done) && (a.push(e.value), a.length !== l); f = !0); } catch (r) { o = !0, n = r; } finally { try { if (!f && null != t.return && (u = t.return(), Object(u) !== u)) return; } finally { if (o) throw n; } } return a; } }
|
|
9
|
+
function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
|
|
3
10
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
4
11
|
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
5
12
|
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
@@ -7,16 +14,18 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
7
14
|
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
8
15
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
9
16
|
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
17
|
+
import { QuestionCircleOutlined } from '@ant-design/icons';
|
|
10
18
|
import { DndContext } from '@dnd-kit/core';
|
|
19
|
+
import { Space } from 'antd';
|
|
11
20
|
import { makeAutoObservable, runInAction } from 'mobx';
|
|
12
21
|
import { observer } from 'mobx-react-lite';
|
|
13
|
-
import React, { useEffect } from 'react';
|
|
22
|
+
import React, { useEffect, useRef, useState } from 'react';
|
|
14
23
|
import styled from 'styled-components';
|
|
15
24
|
import { Button, GlobalStyles } from '..';
|
|
16
25
|
import ViewPort from "./ViewPort";
|
|
17
26
|
import { ViewPortStore } from "./ViewPortStore";
|
|
18
27
|
import { ViewPortWindowStore } from "./ViewPortWindow";
|
|
19
|
-
var viewPortStore = new ViewPortStore(600, 600
|
|
28
|
+
var viewPortStore = new ViewPortStore(600, 600);
|
|
20
29
|
var WindowManager = /*#__PURE__*/function () {
|
|
21
30
|
function WindowManager() {
|
|
22
31
|
_classCallCheck(this, WindowManager);
|
|
@@ -40,8 +49,11 @@ var WindowManager = /*#__PURE__*/function () {
|
|
|
40
49
|
}, {
|
|
41
50
|
key: "closeWindowHanlder",
|
|
42
51
|
value: function closeWindowHanlder(id) {
|
|
43
|
-
|
|
44
|
-
|
|
52
|
+
var _this = this;
|
|
53
|
+
runInAction(function () {
|
|
54
|
+
_this.windows = _this.windows.filter(function (window) {
|
|
55
|
+
return window.id !== id;
|
|
56
|
+
});
|
|
45
57
|
});
|
|
46
58
|
}
|
|
47
59
|
}, {
|
|
@@ -67,6 +79,15 @@ var WindowManager = /*#__PURE__*/function () {
|
|
|
67
79
|
var windowManager = new WindowManager();
|
|
68
80
|
var StyledViewPort = styled(ViewPort)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tborder: 1px solid #eee;\n"])));
|
|
69
81
|
export default observer(function Test() {
|
|
82
|
+
var _useState = useState(600),
|
|
83
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
84
|
+
w = _useState2[0],
|
|
85
|
+
setW = _useState2[1];
|
|
86
|
+
var _useState3 = useState(600),
|
|
87
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
88
|
+
h = _useState4[0],
|
|
89
|
+
setH = _useState4[1];
|
|
90
|
+
var containerRef = useRef(null);
|
|
70
91
|
useEffect(function () {
|
|
71
92
|
function setWidthHeight() {
|
|
72
93
|
runInAction(function () {
|
|
@@ -80,9 +101,45 @@ export default observer(function Test() {
|
|
|
80
101
|
window.removeEventListener('resize', setWidthHeight);
|
|
81
102
|
};
|
|
82
103
|
}, []);
|
|
104
|
+
useEffect(function () {
|
|
105
|
+
var el = containerRef.current;
|
|
106
|
+
if (!el) return;
|
|
107
|
+
var ro = new ResizeObserver(function (entries) {
|
|
108
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
109
|
+
_step;
|
|
110
|
+
try {
|
|
111
|
+
var _loop = function _loop() {
|
|
112
|
+
var entry = _step.value;
|
|
113
|
+
var cr = entry.contentRect;
|
|
114
|
+
runInAction(function () {
|
|
115
|
+
// 保证写入的是数字(像素)
|
|
116
|
+
viewPortStore.width = Math.round(cr.width);
|
|
117
|
+
viewPortStore.height = Math.round(cr.height);
|
|
118
|
+
});
|
|
119
|
+
};
|
|
120
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
121
|
+
_loop();
|
|
122
|
+
}
|
|
123
|
+
} catch (err) {
|
|
124
|
+
_iterator.e(err);
|
|
125
|
+
} finally {
|
|
126
|
+
_iterator.f();
|
|
127
|
+
}
|
|
128
|
+
});
|
|
129
|
+
ro.observe(el);
|
|
130
|
+
// 立刻触发一次初始尺寸写入
|
|
131
|
+
var rect = el.getBoundingClientRect();
|
|
132
|
+
runInAction(function () {
|
|
133
|
+
viewPortStore.width = Math.round(rect.width);
|
|
134
|
+
viewPortStore.height = Math.round(rect.height);
|
|
135
|
+
});
|
|
136
|
+
return function () {
|
|
137
|
+
return ro.disconnect();
|
|
138
|
+
};
|
|
139
|
+
}, []);
|
|
83
140
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
|
|
84
141
|
$css: []
|
|
85
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
142
|
+
}), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
86
143
|
onClick: function onClick() {
|
|
87
144
|
windowManager.createWindow();
|
|
88
145
|
}
|
|
@@ -90,18 +147,40 @@ export default observer(function Test() {
|
|
|
90
147
|
onClick: function onClick() {
|
|
91
148
|
windowManager.toggleWindowIdIsJss();
|
|
92
149
|
}
|
|
93
|
-
}, "\u5207\u6362"), /*#__PURE__*/React.createElement(
|
|
150
|
+
}, "\u5207\u6362"), /*#__PURE__*/React.createElement(Button, {
|
|
151
|
+
onClick: function onClick() {
|
|
152
|
+
setW(function (v) {
|
|
153
|
+
return v + 100;
|
|
154
|
+
});
|
|
155
|
+
setH(function (v) {
|
|
156
|
+
return v + 100;
|
|
157
|
+
});
|
|
158
|
+
}
|
|
159
|
+
}, "\u53D8\u5927"), "x: ", viewPortStore.pageBounds.left, " y: ", viewPortStore.pageBounds.top), /*#__PURE__*/React.createElement("div", {
|
|
160
|
+
ref: containerRef,
|
|
161
|
+
style: {
|
|
162
|
+
width: w,
|
|
163
|
+
height: h
|
|
164
|
+
}
|
|
165
|
+
}, /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(StyledViewPort, {
|
|
94
166
|
viewPortStore: viewPortStore
|
|
95
167
|
}, windowManager.windows.map(function (windowStore) {
|
|
96
168
|
return /*#__PURE__*/React.createElement(ViewPort.Window, {
|
|
97
169
|
window: windowStore,
|
|
98
170
|
key: windowStore.id,
|
|
99
|
-
title: windowStore.id
|
|
171
|
+
title: windowStore.id,
|
|
172
|
+
options: [{
|
|
173
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
174
|
+
'aria-label': 'help',
|
|
175
|
+
onClick: function onClick() {
|
|
176
|
+
alert('help clicked');
|
|
177
|
+
}
|
|
178
|
+
}]
|
|
100
179
|
}, /*#__PURE__*/React.createElement("div", {
|
|
101
180
|
style: {
|
|
102
181
|
height: '2000px',
|
|
103
182
|
backgroundColor: 'pink'
|
|
104
183
|
}
|
|
105
184
|
}));
|
|
106
|
-
}))));
|
|
185
|
+
})))));
|
|
107
186
|
});
|
package/dist/Window/Window.d.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
import React, { ReactNode } from 'react';
|
|
1
|
+
import React, { FunctionComponent, ReactNode } from 'react';
|
|
2
2
|
import { ViewPortWindowStore } from '../ViewPort';
|
|
3
|
+
import { WindowOptionProps } from './WindowOption';
|
|
3
4
|
import WindowStore from './WindowStore';
|
|
4
5
|
export type WindowProps = {
|
|
5
6
|
window: WindowStore | ViewPortWindowStore;
|
|
@@ -8,8 +9,14 @@ export type WindowProps = {
|
|
|
8
9
|
onFullscreenHandler?: () => void;
|
|
9
10
|
onFocusHandler?: () => void;
|
|
10
11
|
onShareWindow?: () => void;
|
|
12
|
+
options?: {
|
|
13
|
+
'aria-label': string;
|
|
14
|
+
icon: ReactNode;
|
|
15
|
+
onClick: () => void;
|
|
16
|
+
danger?: boolean;
|
|
17
|
+
}[];
|
|
11
18
|
};
|
|
12
|
-
declare const Window:
|
|
13
|
-
|
|
19
|
+
declare const Window: React.FunctionComponent<WindowProps> & {
|
|
20
|
+
WindowOption: FunctionComponent<WindowOptionProps>;
|
|
14
21
|
};
|
|
15
22
|
export default Window;
|
package/dist/Window/Window.js
CHANGED
|
@@ -42,13 +42,14 @@ var WindowSplitPanelItem = styled.div.withConfig({
|
|
|
42
42
|
})(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n\twidth: ", ";\n\theight: 100%;\n\tborder: 2px solid #b4b4b6;\n\tborder-radius: 4px;\n\ttransition: all 0.3s;\n\tbox-sizing: border-box;\n\tbackground-color: #d7d7d9;\n\tcursor: pointer;\n\n\t&:hover {\n\t\tbackground-color: var(--kep-platform-color-primary);\n\t}\n"])), function (props) {
|
|
43
43
|
return props.width;
|
|
44
44
|
});
|
|
45
|
-
var
|
|
45
|
+
var WindowComponent = observer(function (props) {
|
|
46
46
|
var window = props.window,
|
|
47
47
|
title = props.title,
|
|
48
48
|
children = props.children,
|
|
49
49
|
onFullscreenHandler = props.onFullscreenHandler,
|
|
50
50
|
onFocusHandler = props.onFocusHandler,
|
|
51
|
-
onShareWindow = props.onShareWindow
|
|
51
|
+
onShareWindow = props.onShareWindow,
|
|
52
|
+
options = props.options;
|
|
52
53
|
var windowContainerRef = useRef(null);
|
|
53
54
|
useEffect(function () {
|
|
54
55
|
var _windowContainerRef$c, _windowContainerRef$c2, _windowContainerRef$c3;
|
|
@@ -119,7 +120,9 @@ var Window = observer(function (props) {
|
|
|
119
120
|
onPointerDown: function onPointerDown(e) {
|
|
120
121
|
if (window.disabled) return;
|
|
121
122
|
e.stopPropagation();
|
|
122
|
-
|
|
123
|
+
runInAction(function () {
|
|
124
|
+
window.focus();
|
|
125
|
+
});
|
|
123
126
|
onFocusHandler === null || onFocusHandler === void 0 || onFocusHandler();
|
|
124
127
|
}
|
|
125
128
|
}, /*#__PURE__*/React.createElement(WindowControllerLeft, {
|
|
@@ -157,17 +160,30 @@ var Window = observer(function (props) {
|
|
|
157
160
|
onDoubleClick: function onDoubleClick(e) {
|
|
158
161
|
e.stopPropagation();
|
|
159
162
|
e.preventDefault();
|
|
160
|
-
|
|
161
|
-
window.
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
163
|
+
runInAction(function () {
|
|
164
|
+
if (window.fullscreen) {
|
|
165
|
+
window.fullscreenExitWindow();
|
|
166
|
+
} else {
|
|
167
|
+
window.fullscreenWindow(onFullscreenHandler);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
165
170
|
}
|
|
166
171
|
}, /*#__PURE__*/React.createElement("h5", null, title), /*#__PURE__*/React.createElement(WindowHeaderOptions, {
|
|
167
172
|
onPointerDown: function onPointerDown(e) {
|
|
168
173
|
e.stopPropagation();
|
|
169
174
|
}
|
|
170
|
-
},
|
|
175
|
+
}, Array.isArray(options) && options.map(function (i) {
|
|
176
|
+
if (!i.icon) {
|
|
177
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
178
|
+
} else {
|
|
179
|
+
return /*#__PURE__*/React.createElement(WindowOption, {
|
|
180
|
+
"aria-label": i === null || i === void 0 ? void 0 : i['aria-label'],
|
|
181
|
+
icon: i === null || i === void 0 ? void 0 : i.icon,
|
|
182
|
+
onClick: i === null || i === void 0 ? void 0 : i.onClick,
|
|
183
|
+
danger: i === null || i === void 0 ? void 0 : i.danger
|
|
184
|
+
});
|
|
185
|
+
}
|
|
186
|
+
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
171
187
|
"aria-label": "\u5206\u4EAB\u7A97\u53E3",
|
|
172
188
|
icon: /*#__PURE__*/React.createElement(ShareAltOutlined, null),
|
|
173
189
|
onClick: onShareWindow
|
|
@@ -189,18 +205,22 @@ var Window = observer(function (props) {
|
|
|
189
205
|
icon: /*#__PURE__*/React.createElement(MinusOutlined, null),
|
|
190
206
|
onClick: function onClick() {
|
|
191
207
|
if (window.disabled) return;
|
|
192
|
-
|
|
208
|
+
runInAction(function () {
|
|
209
|
+
window.minimizeWindow();
|
|
210
|
+
});
|
|
193
211
|
}
|
|
194
212
|
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
195
213
|
"aria-label": window.fullscreen ? '退出全屏' : '进入全屏',
|
|
196
214
|
icon: window.fullscreen ? /*#__PURE__*/React.createElement(CompressOutlined, null) : /*#__PURE__*/React.createElement(BorderOutlined, null),
|
|
197
215
|
onClick: function onClick() {
|
|
198
216
|
if (window.disabled) return;
|
|
199
|
-
|
|
200
|
-
window.
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
217
|
+
runInAction(function () {
|
|
218
|
+
if (window.fullscreen) {
|
|
219
|
+
window.fullscreenExitWindow();
|
|
220
|
+
} else {
|
|
221
|
+
window.fullscreenWindow(onFullscreenHandler);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
204
224
|
}
|
|
205
225
|
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
206
226
|
"aria-label": "\u5173\u95ED\u7A97\u53E3",
|
|
@@ -208,8 +228,12 @@ var Window = observer(function (props) {
|
|
|
208
228
|
danger: true,
|
|
209
229
|
onClick: function onClick() {
|
|
210
230
|
if (window.disabled) return;
|
|
211
|
-
|
|
231
|
+
runInAction(function () {
|
|
232
|
+
window.closeWindow();
|
|
233
|
+
});
|
|
212
234
|
}
|
|
213
235
|
})))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
|
|
214
236
|
});
|
|
237
|
+
var Window = WindowComponent;
|
|
238
|
+
Window.WindowOption = WindowOption;
|
|
215
239
|
export default Window;
|
|
@@ -5,6 +5,7 @@ function _objectWithoutProperties(source, excluded) { if (source == null) return
|
|
|
5
5
|
function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
|
|
6
6
|
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
7
7
|
import { useDraggable } from '@dnd-kit/core';
|
|
8
|
+
import { runInAction } from 'mobx';
|
|
8
9
|
import { observer } from 'mobx-react-lite';
|
|
9
10
|
import React, { useEffect } from 'react';
|
|
10
11
|
import styled from 'styled-components';
|
|
@@ -24,9 +25,13 @@ export default observer(function WindowController(props) {
|
|
|
24
25
|
isDragging = _useDraggable.isDragging;
|
|
25
26
|
useEffect(function () {
|
|
26
27
|
if (transform && isDragging) {
|
|
27
|
-
|
|
28
|
+
runInAction(function () {
|
|
29
|
+
window.control(transform, type);
|
|
30
|
+
});
|
|
28
31
|
} else {
|
|
29
|
-
|
|
32
|
+
runInAction(function () {
|
|
33
|
+
window.endControl();
|
|
34
|
+
});
|
|
30
35
|
}
|
|
31
36
|
}, [transform, isDragging, type]);
|
|
32
37
|
return /*#__PURE__*/React.createElement(WindowControllerContainer, _extends({}, rest, attributes, listeners, {
|
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import React, { HtmlHTMLAttributes, ReactNode } from 'react';
|
|
2
|
-
type WindowOptionProps = {
|
|
2
|
+
export type WindowOptionProps = {
|
|
3
3
|
icon: ReactNode;
|
|
4
4
|
color?: string;
|
|
5
5
|
danger?: boolean;
|
|
6
6
|
} & HtmlHTMLAttributes<HTMLSpanElement>;
|
|
7
7
|
export default function WindowOption(props: WindowOptionProps): React.JSX.Element;
|
|
8
|
-
export {};
|
|
@@ -31,6 +31,11 @@ export default class WindowStore {
|
|
|
31
31
|
isClosed: boolean;
|
|
32
32
|
splitPanelVisible: boolean;
|
|
33
33
|
onClosedHandler: ((id: string) => void) | undefined;
|
|
34
|
+
animationDurationClose: string;
|
|
35
|
+
animationDurationMinimize: string;
|
|
36
|
+
animationDurationFullscreen: string;
|
|
37
|
+
animationDurationNormal: string;
|
|
38
|
+
animationEasing: string;
|
|
34
39
|
constructor(id: string, onClosedHandler?: (id: string) => void);
|
|
35
40
|
fullscreenWindow(func?: () => void): void;
|
|
36
41
|
fullscreenExitWindow(): void;
|
|
@@ -34,6 +34,11 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
34
34
|
_defineProperty(this, "isClosed", false);
|
|
35
35
|
_defineProperty(this, "splitPanelVisible", false);
|
|
36
36
|
_defineProperty(this, "onClosedHandler", void 0);
|
|
37
|
+
_defineProperty(this, "animationDurationClose", '0.3s');
|
|
38
|
+
_defineProperty(this, "animationDurationMinimize", '0.3s');
|
|
39
|
+
_defineProperty(this, "animationDurationFullscreen", '0.3s');
|
|
40
|
+
_defineProperty(this, "animationDurationNormal", '0.3s');
|
|
41
|
+
_defineProperty(this, "animationEasing", 'ease-in-out');
|
|
37
42
|
makeObservable(this, {
|
|
38
43
|
width: observable,
|
|
39
44
|
height: observable,
|
|
@@ -46,6 +51,11 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
46
51
|
isTransition: observable,
|
|
47
52
|
isResizing: observable,
|
|
48
53
|
isClosed: observable,
|
|
54
|
+
animationDurationClose: observable,
|
|
55
|
+
animationDurationMinimize: observable,
|
|
56
|
+
animationDurationFullscreen: observable,
|
|
57
|
+
animationDurationNormal: observable,
|
|
58
|
+
animationEasing: observable,
|
|
49
59
|
fullscreenExitWindow: action,
|
|
50
60
|
fullscreenWindow: action,
|
|
51
61
|
control: action,
|
|
@@ -216,7 +226,7 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
216
226
|
zIndex: this.zIndex,
|
|
217
227
|
transform: 'scale(0)',
|
|
218
228
|
transformOrigin: 'center center',
|
|
219
|
-
transition:
|
|
229
|
+
transition: "all ".concat(this.animationDurationClose, " ").concat(this.animationEasing)
|
|
220
230
|
};
|
|
221
231
|
case 'minimize':
|
|
222
232
|
return {
|
|
@@ -227,7 +237,7 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
227
237
|
zIndex: this.zIndex,
|
|
228
238
|
transform: 'scale(0)',
|
|
229
239
|
transformOrigin: 'left top',
|
|
230
|
-
transition:
|
|
240
|
+
transition: "all ".concat(this.animationDurationMinimize, " ").concat(this.animationEasing)
|
|
231
241
|
};
|
|
232
242
|
case 'fullscreen':
|
|
233
243
|
return {
|
|
@@ -237,7 +247,7 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
237
247
|
height: this.fullscreenPos.height + 'px',
|
|
238
248
|
zIndex: this.zIndex,
|
|
239
249
|
transform: 'none',
|
|
240
|
-
transition:
|
|
250
|
+
transition: "all ".concat(this.animationDurationFullscreen, " ").concat(this.animationEasing)
|
|
241
251
|
};
|
|
242
252
|
case 'normal':
|
|
243
253
|
default:
|
|
@@ -259,7 +269,7 @@ var WindowStore = /*#__PURE__*/function () {
|
|
|
259
269
|
height: this.height + 'px',
|
|
260
270
|
zIndex: this.zIndex,
|
|
261
271
|
transform: 'none',
|
|
262
|
-
transition:
|
|
272
|
+
transition: "all ".concat(this.animationDurationNormal, " ").concat(this.animationEasing)
|
|
263
273
|
};
|
|
264
274
|
}
|
|
265
275
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@kep-platform/basic-component",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.24",
|
|
4
4
|
"description": "A react library developed with dumi",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -87,5 +87,5 @@
|
|
|
87
87
|
"authors": [
|
|
88
88
|
"less-step-jss 1599925910@qq.com"
|
|
89
89
|
],
|
|
90
|
-
"gitHead": "
|
|
90
|
+
"gitHead": "cdab8a4027ccc1615c1dd67e8701ce44e3a728e5"
|
|
91
91
|
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from 'react';
|
|
2
|
-
type RippleType = {
|
|
3
|
-
id: number;
|
|
4
|
-
left: number;
|
|
5
|
-
top: number;
|
|
6
|
-
};
|
|
7
|
-
export declare const Ripple: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, never>> & string;
|
|
8
|
-
export declare class RippleManagerStore {
|
|
9
|
-
list: RippleType[];
|
|
10
|
-
constructor();
|
|
11
|
-
clearList(): void;
|
|
12
|
-
addRipple(left: number, top: number): void;
|
|
13
|
-
get rippleInfo(): React.JSX.Element[];
|
|
14
|
-
}
|
|
15
|
-
export {};
|
package/dist/ViewPort/Ripple.js
DELETED
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
var _templateObject, _templateObject2;
|
|
3
|
-
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
4
|
-
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
5
|
-
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
6
|
-
function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
|
|
7
|
-
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
8
|
-
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
9
|
-
function _taggedTemplateLiteral(strings, raw) { if (!raw) { raw = strings.slice(0); } return Object.freeze(Object.defineProperties(strings, { raw: { value: Object.freeze(raw) } })); }
|
|
10
|
-
import { makeAutoObservable } from 'mobx';
|
|
11
|
-
import React from 'react';
|
|
12
|
-
import styled, { keyframes } from 'styled-components';
|
|
13
|
-
var rippleAnimation = keyframes(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n from {\n transform: scale(1);\n }\n to {\n\n transform: scale(4);\n opacity: 0;\n }\n"])));
|
|
14
|
-
export var Ripple = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n position: absolute;\n border-radius: 50%;\n width: 10px;\n height: 10px;\n background-color: #fff0;\n & > div {\n position: absolute;\n left: 0;\n top: 0;\n width: 10px;\n height: 10px;\n background-color: #fff;\n border-radius: 50%;\n margin-left: -5px;\n margin-top: -5px;\n transform: scale(0);\n animation: ", " 500ms linear;\n }\n & .first {\n }\n & .second {\n animation-delay: 150ms;\n }\n"])), rippleAnimation);
|
|
15
|
-
export var RippleManagerStore = /*#__PURE__*/function () {
|
|
16
|
-
function RippleManagerStore() {
|
|
17
|
-
_classCallCheck(this, RippleManagerStore);
|
|
18
|
-
_defineProperty(this, "list", []);
|
|
19
|
-
makeAutoObservable(this);
|
|
20
|
-
}
|
|
21
|
-
_createClass(RippleManagerStore, [{
|
|
22
|
-
key: "clearList",
|
|
23
|
-
value: function clearList() {
|
|
24
|
-
this.list = [];
|
|
25
|
-
}
|
|
26
|
-
}, {
|
|
27
|
-
key: "addRipple",
|
|
28
|
-
value: function addRipple(left, top) {
|
|
29
|
-
this.list.push({
|
|
30
|
-
id: new Date().getTime(),
|
|
31
|
-
left: left,
|
|
32
|
-
top: top
|
|
33
|
-
});
|
|
34
|
-
}
|
|
35
|
-
}, {
|
|
36
|
-
key: "rippleInfo",
|
|
37
|
-
get: function get() {
|
|
38
|
-
return this.list.map(function (ripple) {
|
|
39
|
-
return /*#__PURE__*/React.createElement(Ripple, {
|
|
40
|
-
key: ripple.id,
|
|
41
|
-
style: {
|
|
42
|
-
left: ripple.left,
|
|
43
|
-
top: ripple.top,
|
|
44
|
-
zIndex: 10
|
|
45
|
-
}
|
|
46
|
-
}, /*#__PURE__*/React.createElement("div", {
|
|
47
|
-
className: "first"
|
|
48
|
-
}), /*#__PURE__*/React.createElement("div", {
|
|
49
|
-
className: "second"
|
|
50
|
-
}));
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
}]);
|
|
54
|
-
return RippleManagerStore;
|
|
55
|
-
}();
|