@kep-platform/basic-component 1.0.23 → 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/ViewPort/ViewPort.d.ts +0 -1
- package/dist/ViewPort/ViewPort.js +14 -57
- package/dist/ViewPort/ViewPortStore.js +7 -1
- package/dist/ViewPort/ViewPortWindow.js +4 -2
- package/dist/ViewPort/test.js +5 -2
- package/dist/Window/Window.js +23 -13
- package/dist/Window/WindowController.js +7 -2
- package/package.json +2 -2
|
@@ -4,7 +4,6 @@ import { ViewPortWindowProps } from './ViewPortWindow';
|
|
|
4
4
|
type ViewPortProps = {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
viewPortStore: ViewPortStore;
|
|
7
|
-
onScroll?: (left: number, top: number) => void;
|
|
8
7
|
} & HtmlHTMLAttributes<HTMLDivElement>;
|
|
9
8
|
declare const ViewPort: React.FunctionComponent<ViewPortProps> & {
|
|
10
9
|
Window: FunctionComponent<ViewPortWindowProps>;
|
|
@@ -1,13 +1,12 @@
|
|
|
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
11
|
import { ViewPortWindow } from "./ViewPortWindow";
|
|
13
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"])));
|
|
@@ -16,27 +15,9 @@ var Overlay = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplate
|
|
|
16
15
|
var ViewPortComponent = observer(function (props) {
|
|
17
16
|
var children = props.children,
|
|
18
17
|
viewPortStore = props.viewPortStore,
|
|
19
|
-
onScroll = props.onScroll,
|
|
20
18
|
rest = _objectWithoutProperties(props, _excluded);
|
|
21
|
-
var _useDraggable = useDraggable({
|
|
22
|
-
id: 'ViewPortEntity'
|
|
23
|
-
}),
|
|
24
|
-
setNodeRef = _useDraggable.setNodeRef,
|
|
25
|
-
attributes = _useDraggable.attributes,
|
|
26
|
-
listeners = _useDraggable.listeners,
|
|
27
|
-
setActivatorNodeRef = _useDraggable.setActivatorNodeRef,
|
|
28
|
-
transform = _useDraggable.transform;
|
|
29
19
|
var contentRef = useRef(null);
|
|
30
20
|
var containerRef = useRef(null);
|
|
31
|
-
var pointerDownTimer = useRef();
|
|
32
|
-
useEffect(function () {
|
|
33
|
-
if (transform) {
|
|
34
|
-
viewPortStore.move(transform);
|
|
35
|
-
onScroll === null || onScroll === void 0 || onScroll(viewPortStore.transform.left, viewPortStore.transform.top);
|
|
36
|
-
} else {
|
|
37
|
-
viewPortStore.endMove();
|
|
38
|
-
}
|
|
39
|
-
}, [transform]);
|
|
40
21
|
useEffect(function () {
|
|
41
22
|
var _contentRef$current, _contentRef$current2;
|
|
42
23
|
function onContentTransitionEnd(e) {
|
|
@@ -68,13 +49,15 @@ var ViewPortComponent = observer(function (props) {
|
|
|
68
49
|
var r = el.getBoundingClientRect();
|
|
69
50
|
var left = r.left + (window.scrollX || window.pageXOffset || 0);
|
|
70
51
|
var top = r.top + (window.scrollY || window.pageYOffset || 0);
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
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
|
+
});
|
|
78
61
|
});
|
|
79
62
|
}
|
|
80
63
|
measure();
|
|
@@ -103,41 +86,15 @@ var ViewPortComponent = observer(function (props) {
|
|
|
103
86
|
if (ro && typeof ro.disconnect === 'function') ro.disconnect();
|
|
104
87
|
};
|
|
105
88
|
}, []);
|
|
106
|
-
var onContentPointerDownHandler = useCallback(function (e) {
|
|
107
|
-
if (viewPortStore.isTransition) return;
|
|
108
|
-
//鼠标点击的时候,先清除定时器,然后再异步触发pointerDown操作,这样保证doubleClick的优先级高于pointerDown
|
|
109
|
-
if (pointerDownTimer.current) clearTimeout(pointerDownTimer.current);
|
|
110
|
-
pointerDownTimer.current = setTimeout(function () {
|
|
111
|
-
var _onPointerDown, _ref;
|
|
112
|
-
listeners === null || listeners === void 0 || (_onPointerDown = (_ref = listeners).onPointerDown) === null || _onPointerDown === void 0 || _onPointerDown.call(_ref, e);
|
|
113
|
-
}, 0);
|
|
114
|
-
}, [listeners]);
|
|
115
|
-
var onContentPointerUpHandler = useCallback(function (e) {
|
|
116
|
-
var _onPointerUp, _ref2;
|
|
117
|
-
if (viewPortStore.isTransition) return;
|
|
118
|
-
listeners === null || listeners === void 0 || (_onPointerUp = (_ref2 = listeners).onPointerUp) === null || _onPointerUp === void 0 || _onPointerUp.call(_ref2, e);
|
|
119
|
-
}, [listeners]);
|
|
120
89
|
return /*#__PURE__*/React.createElement(Container, _extends({
|
|
121
90
|
style: viewPortStore.containerStyle,
|
|
122
91
|
ref: containerRef
|
|
123
92
|
}, rest), /*#__PURE__*/React.createElement(Overlay, {
|
|
124
93
|
style: viewPortStore.overlayStyle
|
|
125
|
-
}), /*#__PURE__*/React.createElement(Content,
|
|
126
|
-
ref:
|
|
127
|
-
contentRef.current = dom;
|
|
128
|
-
setNodeRef(contentRef.current);
|
|
129
|
-
setActivatorNodeRef(contentRef.current);
|
|
130
|
-
}
|
|
131
|
-
}, attributes, {
|
|
132
|
-
onPointerDown: onContentPointerDownHandler,
|
|
133
|
-
onPointerUp: onContentPointerUpHandler,
|
|
134
|
-
onDoubleClick: function onDoubleClick(e) {
|
|
135
|
-
var target = e.target;
|
|
136
|
-
var rect = target.getBoundingClientRect();
|
|
137
|
-
viewPortStore.focus(e.clientX - rect.left, e.clientY - rect.top);
|
|
138
|
-
},
|
|
94
|
+
}), /*#__PURE__*/React.createElement(Content, {
|
|
95
|
+
ref: contentRef,
|
|
139
96
|
style: viewPortStore.contentStyle
|
|
140
|
-
}
|
|
97
|
+
}, children));
|
|
141
98
|
});
|
|
142
99
|
var ViewPort = ViewPortComponent;
|
|
143
100
|
ViewPort.Window = ViewPortWindow;
|
|
@@ -5,7 +5,7 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
5
5
|
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; }
|
|
6
6
|
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
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
|
-
import { computed, makeObservable, observable } from 'mobx';
|
|
8
|
+
import { action, computed, makeObservable, observable } from 'mobx';
|
|
9
9
|
export var ViewPortStore = /*#__PURE__*/function () {
|
|
10
10
|
function ViewPortStore(width, height) {
|
|
11
11
|
_classCallCheck(this, ViewPortStore);
|
|
@@ -44,6 +44,12 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
44
44
|
maxZIndex: observable,
|
|
45
45
|
isTransition: observable,
|
|
46
46
|
animationEasing: observable,
|
|
47
|
+
setTransform: action,
|
|
48
|
+
focus: action,
|
|
49
|
+
unfocus: action,
|
|
50
|
+
move: action,
|
|
51
|
+
endMove: action,
|
|
52
|
+
setContainerRect: action,
|
|
47
53
|
viewPortRect: computed.struct,
|
|
48
54
|
overlayStyle: computed.struct
|
|
49
55
|
});
|
|
@@ -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";
|
|
@@ -254,7 +254,9 @@ export var ViewPortWindow = observer(function ViewPortWindow(props) {
|
|
|
254
254
|
rest = _objectWithoutProperties(props, _excluded);
|
|
255
255
|
useEffect(function () {
|
|
256
256
|
if (!window.disableDefaultCenterDisplay) {
|
|
257
|
-
|
|
257
|
+
runInAction(function () {
|
|
258
|
+
window.centerDisplay();
|
|
259
|
+
});
|
|
258
260
|
}
|
|
259
261
|
}, []);
|
|
260
262
|
return /*#__PURE__*/React.createElement(Window, _extends({
|
package/dist/ViewPort/test.js
CHANGED
|
@@ -49,8 +49,11 @@ var WindowManager = /*#__PURE__*/function () {
|
|
|
49
49
|
}, {
|
|
50
50
|
key: "closeWindowHanlder",
|
|
51
51
|
value: function closeWindowHanlder(id) {
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
var _this = this;
|
|
53
|
+
runInAction(function () {
|
|
54
|
+
_this.windows = _this.windows.filter(function (window) {
|
|
55
|
+
return window.id !== id;
|
|
56
|
+
});
|
|
54
57
|
});
|
|
55
58
|
}
|
|
56
59
|
}, {
|
package/dist/Window/Window.js
CHANGED
|
@@ -120,7 +120,9 @@ var WindowComponent = observer(function (props) {
|
|
|
120
120
|
onPointerDown: function onPointerDown(e) {
|
|
121
121
|
if (window.disabled) return;
|
|
122
122
|
e.stopPropagation();
|
|
123
|
-
|
|
123
|
+
runInAction(function () {
|
|
124
|
+
window.focus();
|
|
125
|
+
});
|
|
124
126
|
onFocusHandler === null || onFocusHandler === void 0 || onFocusHandler();
|
|
125
127
|
}
|
|
126
128
|
}, /*#__PURE__*/React.createElement(WindowControllerLeft, {
|
|
@@ -158,11 +160,13 @@ var WindowComponent = observer(function (props) {
|
|
|
158
160
|
onDoubleClick: function onDoubleClick(e) {
|
|
159
161
|
e.stopPropagation();
|
|
160
162
|
e.preventDefault();
|
|
161
|
-
|
|
162
|
-
window.
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
163
|
+
runInAction(function () {
|
|
164
|
+
if (window.fullscreen) {
|
|
165
|
+
window.fullscreenExitWindow();
|
|
166
|
+
} else {
|
|
167
|
+
window.fullscreenWindow(onFullscreenHandler);
|
|
168
|
+
}
|
|
169
|
+
});
|
|
166
170
|
}
|
|
167
171
|
}, /*#__PURE__*/React.createElement("h5", null, title), /*#__PURE__*/React.createElement(WindowHeaderOptions, {
|
|
168
172
|
onPointerDown: function onPointerDown(e) {
|
|
@@ -201,18 +205,22 @@ var WindowComponent = observer(function (props) {
|
|
|
201
205
|
icon: /*#__PURE__*/React.createElement(MinusOutlined, null),
|
|
202
206
|
onClick: function onClick() {
|
|
203
207
|
if (window.disabled) return;
|
|
204
|
-
|
|
208
|
+
runInAction(function () {
|
|
209
|
+
window.minimizeWindow();
|
|
210
|
+
});
|
|
205
211
|
}
|
|
206
212
|
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
207
213
|
"aria-label": window.fullscreen ? '退出全屏' : '进入全屏',
|
|
208
214
|
icon: window.fullscreen ? /*#__PURE__*/React.createElement(CompressOutlined, null) : /*#__PURE__*/React.createElement(BorderOutlined, null),
|
|
209
215
|
onClick: function onClick() {
|
|
210
216
|
if (window.disabled) return;
|
|
211
|
-
|
|
212
|
-
window.
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
217
|
+
runInAction(function () {
|
|
218
|
+
if (window.fullscreen) {
|
|
219
|
+
window.fullscreenExitWindow();
|
|
220
|
+
} else {
|
|
221
|
+
window.fullscreenWindow(onFullscreenHandler);
|
|
222
|
+
}
|
|
223
|
+
});
|
|
216
224
|
}
|
|
217
225
|
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
218
226
|
"aria-label": "\u5173\u95ED\u7A97\u53E3",
|
|
@@ -220,7 +228,9 @@ var WindowComponent = observer(function (props) {
|
|
|
220
228
|
danger: true,
|
|
221
229
|
onClick: function onClick() {
|
|
222
230
|
if (window.disabled) return;
|
|
223
|
-
|
|
231
|
+
runInAction(function () {
|
|
232
|
+
window.closeWindow();
|
|
233
|
+
});
|
|
224
234
|
}
|
|
225
235
|
})))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
|
|
226
236
|
});
|
|
@@ -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, {
|
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
|
}
|