@kep-platform/basic-component 1.0.22 → 1.0.23
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 +1 -2
- package/dist/ViewPort/ViewPort.js +50 -27
- package/dist/ViewPort/ViewPortStore.d.ts +34 -16
- package/dist/ViewPort/ViewPortStore.js +49 -96
- package/dist/ViewPort/ViewPortWindow.js +10 -9
- package/dist/ViewPort/test.js +82 -6
- package/dist/Window/Window.d.ts +10 -3
- package/dist/Window/Window.js +17 -3
- 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,7 @@ import { ViewPortWindowProps } from './ViewPortWindow';
|
|
|
4
4
|
type ViewPortProps = {
|
|
5
5
|
children: ReactNode;
|
|
6
6
|
viewPortStore: ViewPortStore;
|
|
7
|
-
|
|
8
|
-
onScroll?: (left: number, top: number, scale: number, ratio: number) => void;
|
|
7
|
+
onScroll?: (left: number, top: number) => void;
|
|
9
8
|
} & HtmlHTMLAttributes<HTMLDivElement>;
|
|
10
9
|
declare const ViewPort: React.FunctionComponent<ViewPortProps> & {
|
|
11
10
|
Window: FunctionComponent<ViewPortWindowProps>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
var _excluded = ["children", "viewPortStore", "onScroll"
|
|
1
|
+
var _excluded = ["children", "viewPortStore", "onScroll"];
|
|
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; }
|
|
@@ -9,17 +9,14 @@ import { runInAction } from 'mobx';
|
|
|
9
9
|
import { observer } from 'mobx-react-lite';
|
|
10
10
|
import React, { useCallback, useEffect, useRef } from 'react';
|
|
11
11
|
import styled from 'styled-components';
|
|
12
|
-
import { RippleManagerStore } from "./Ripple";
|
|
13
12
|
import { ViewPortWindow } from "./ViewPortWindow";
|
|
14
13
|
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
14
|
var Content = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n\tposition: absolute;\n"])));
|
|
16
15
|
var Overlay = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral([""])));
|
|
17
|
-
var rippleManagerStore = new RippleManagerStore();
|
|
18
16
|
var ViewPortComponent = observer(function (props) {
|
|
19
17
|
var children = props.children,
|
|
20
18
|
viewPortStore = props.viewPortStore,
|
|
21
19
|
onScroll = props.onScroll,
|
|
22
|
-
onScale = props.onScale,
|
|
23
20
|
rest = _objectWithoutProperties(props, _excluded);
|
|
24
21
|
var _useDraggable = useDraggable({
|
|
25
22
|
id: 'ViewPortEntity'
|
|
@@ -35,23 +32,13 @@ var ViewPortComponent = observer(function (props) {
|
|
|
35
32
|
useEffect(function () {
|
|
36
33
|
if (transform) {
|
|
37
34
|
viewPortStore.move(transform);
|
|
38
|
-
onScroll === null || onScroll === void 0 || onScroll(viewPortStore.transform.left, viewPortStore.transform.top
|
|
35
|
+
onScroll === null || onScroll === void 0 || onScroll(viewPortStore.transform.left, viewPortStore.transform.top);
|
|
39
36
|
} else {
|
|
40
37
|
viewPortStore.endMove();
|
|
41
38
|
}
|
|
42
39
|
}, [transform]);
|
|
43
40
|
useEffect(function () {
|
|
44
|
-
var _contentRef$current, _contentRef$current2
|
|
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
|
-
}
|
|
41
|
+
var _contentRef$current, _contentRef$current2;
|
|
55
42
|
function onContentTransitionEnd(e) {
|
|
56
43
|
if (e.target === contentRef.current) {
|
|
57
44
|
runInAction(function () {
|
|
@@ -66,14 +53,54 @@ var ViewPortComponent = observer(function (props) {
|
|
|
66
53
|
});
|
|
67
54
|
}
|
|
68
55
|
}
|
|
69
|
-
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.addEventListener('
|
|
70
|
-
|
|
56
|
+
(_contentRef$current = contentRef.current) === null || _contentRef$current === void 0 || _contentRef$current.addEventListener('transitionend', onContentTransitionEnd);
|
|
57
|
+
(_contentRef$current2 = contentRef.current) === null || _contentRef$current2 === void 0 || _contentRef$current2.addEventListener('transitionstart', onContentTransitionStart);
|
|
58
|
+
return function () {
|
|
59
|
+
var _contentRef$current3, _contentRef$current4;
|
|
60
|
+
(_contentRef$current3 = contentRef.current) === null || _contentRef$current3 === void 0 || _contentRef$current3.removeEventListener('transitionend', onContentTransitionEnd);
|
|
61
|
+
(_contentRef$current4 = contentRef.current) === null || _contentRef$current4 === void 0 || _contentRef$current4.removeEventListener('transitionstart', onContentTransitionStart);
|
|
62
|
+
};
|
|
63
|
+
}, []);
|
|
64
|
+
useEffect(function () {
|
|
65
|
+
function measure() {
|
|
66
|
+
var el = containerRef.current;
|
|
67
|
+
if (!el) return;
|
|
68
|
+
var r = el.getBoundingClientRect();
|
|
69
|
+
var left = r.left + (window.scrollX || window.pageXOffset || 0);
|
|
70
|
+
var top = r.top + (window.scrollY || window.pageYOffset || 0);
|
|
71
|
+
viewPortStore.setContainerRect({
|
|
72
|
+
left: left,
|
|
73
|
+
top: top,
|
|
74
|
+
right: left + r.width,
|
|
75
|
+
bottom: top + r.height,
|
|
76
|
+
width: r.width,
|
|
77
|
+
height: r.height
|
|
78
|
+
});
|
|
79
|
+
}
|
|
80
|
+
measure();
|
|
81
|
+
var ro;
|
|
82
|
+
var Rz = window.ResizeObserver;
|
|
83
|
+
if (Rz) {
|
|
84
|
+
ro = new Rz(function () {
|
|
85
|
+
return measure();
|
|
86
|
+
});
|
|
87
|
+
if (ro && containerRef.current) ro.observe(containerRef.current);
|
|
88
|
+
}
|
|
89
|
+
function onScroll() {
|
|
90
|
+
measure();
|
|
91
|
+
}
|
|
92
|
+
function onResize() {
|
|
93
|
+
measure();
|
|
94
|
+
}
|
|
95
|
+
window.addEventListener('scroll', onScroll, {
|
|
96
|
+
passive: true
|
|
71
97
|
});
|
|
72
|
-
|
|
73
|
-
(_contentRef$current3 = contentRef.current) === null || _contentRef$current3 === void 0 || _contentRef$current3.addEventListener('transitionstart', onContentTransitionStart);
|
|
98
|
+
window.addEventListener('resize', onResize);
|
|
74
99
|
return function () {
|
|
75
|
-
|
|
76
|
-
|
|
100
|
+
window.removeEventListener('scroll', onScroll);
|
|
101
|
+
window.removeEventListener('resize', onResize);
|
|
102
|
+
if (ro && containerRef.current) ro.unobserve(containerRef.current);
|
|
103
|
+
if (ro && typeof ro.disconnect === 'function') ro.disconnect();
|
|
77
104
|
};
|
|
78
105
|
}, []);
|
|
79
106
|
var onContentPointerDownHandler = useCallback(function (e) {
|
|
@@ -95,7 +122,7 @@ var ViewPortComponent = observer(function (props) {
|
|
|
95
122
|
ref: containerRef
|
|
96
123
|
}, rest), /*#__PURE__*/React.createElement(Overlay, {
|
|
97
124
|
style: viewPortStore.overlayStyle
|
|
98
|
-
}),
|
|
125
|
+
}), /*#__PURE__*/React.createElement(Content, _extends({
|
|
99
126
|
ref: function ref(dom) {
|
|
100
127
|
contentRef.current = dom;
|
|
101
128
|
setNodeRef(contentRef.current);
|
|
@@ -105,10 +132,6 @@ var ViewPortComponent = observer(function (props) {
|
|
|
105
132
|
onPointerDown: onContentPointerDownHandler,
|
|
106
133
|
onPointerUp: onContentPointerUpHandler,
|
|
107
134
|
onDoubleClick: function onDoubleClick(e) {
|
|
108
|
-
if (viewPortStore.scale !== 1 / viewPortStore.ratio) {
|
|
109
|
-
viewPortStore.unfocus();
|
|
110
|
-
return;
|
|
111
|
-
}
|
|
112
135
|
var target = e.target;
|
|
113
136
|
var rect = target.getBoundingClientRect();
|
|
114
137
|
viewPortStore.focus(e.clientX - rect.left, e.clientY - rect.top);
|
|
@@ -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
|
}
|
|
@@ -5,10 +5,9 @@ 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 {
|
|
8
|
+
import { 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,53 @@ 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,
|
|
49
|
-
setTransform: action,
|
|
50
|
-
offsetLeft: computed,
|
|
51
|
-
offsetTop: computed,
|
|
52
|
-
focus: action,
|
|
53
|
-
unfocus: action,
|
|
54
|
-
move: action,
|
|
55
|
-
endMove: action,
|
|
56
|
-
containerStyle: computed.struct,
|
|
57
|
-
contentStyle: computed.struct,
|
|
46
|
+
animationEasing: observable,
|
|
58
47
|
viewPortRect: computed.struct,
|
|
59
48
|
overlayStyle: computed.struct
|
|
60
49
|
});
|
|
61
50
|
}
|
|
62
51
|
_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
52
|
key: "setTransform",
|
|
91
53
|
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))
|
|
54
|
+
this.transform = {
|
|
55
|
+
left: left,
|
|
56
|
+
top: top
|
|
123
57
|
};
|
|
124
58
|
}
|
|
125
59
|
}, {
|
|
126
60
|
key: "focus",
|
|
127
61
|
value: function focus(left, top) {
|
|
128
|
-
this.
|
|
129
|
-
this.setTransform((1 - this.ratio) * left + this.offsetLeft, (1 - this.ratio) * top + this.offsetTop);
|
|
62
|
+
this.setTransform(left, top);
|
|
130
63
|
}
|
|
131
64
|
}, {
|
|
132
65
|
key: "unfocus",
|
|
133
66
|
value: function unfocus() {
|
|
134
|
-
this.setScale(1 / this.ratio);
|
|
135
67
|
this.setTransform(0, 0);
|
|
136
68
|
}
|
|
137
69
|
}, {
|
|
@@ -158,11 +90,11 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
158
90
|
position: 'absolute',
|
|
159
91
|
left: 0,
|
|
160
92
|
top: 0,
|
|
161
|
-
transform: " translate(".concat(this.transform.left
|
|
162
|
-
width: this.width
|
|
163
|
-
height: this.height
|
|
93
|
+
transform: " translate(".concat(this.transform.left, "px,").concat(this.transform.top, "px)"),
|
|
94
|
+
width: this.width + 'px',
|
|
95
|
+
height: this.height + 'px',
|
|
164
96
|
transformOrigin: 'left top',
|
|
165
|
-
transition: this.isMoving ? 'none' :
|
|
97
|
+
transition: this.isMoving ? 'none' : "all 0.3s ".concat(this.animationEasing),
|
|
166
98
|
background: '#188fff67',
|
|
167
99
|
cursor: this.isMoving ? 'grab' : 'default'
|
|
168
100
|
};
|
|
@@ -197,17 +129,38 @@ export var ViewPortStore = /*#__PURE__*/function () {
|
|
|
197
129
|
get: function get() {
|
|
198
130
|
return this.posInViewPort(0, 0, this.width, this.height);
|
|
199
131
|
}
|
|
132
|
+
}, {
|
|
133
|
+
key: "setContainerRect",
|
|
134
|
+
value: function setContainerRect(rect) {
|
|
135
|
+
this.containerRect = rect;
|
|
136
|
+
}
|
|
137
|
+
}, {
|
|
138
|
+
key: "pageBounds",
|
|
139
|
+
get: function get() {
|
|
140
|
+
return this.containerRect;
|
|
141
|
+
}
|
|
200
142
|
|
|
201
|
-
|
|
143
|
+
// 暴露视窗的空间坐标(容器坐标系)
|
|
144
|
+
}, {
|
|
145
|
+
key: "bounds",
|
|
146
|
+
get: function get() {
|
|
147
|
+
return {
|
|
148
|
+
left: 0,
|
|
149
|
+
top: 0,
|
|
150
|
+
right: this.width,
|
|
151
|
+
bottom: this.height,
|
|
152
|
+
width: this.width,
|
|
153
|
+
height: this.height
|
|
154
|
+
};
|
|
155
|
+
}
|
|
202
156
|
}, {
|
|
203
157
|
key: "posInViewPort",
|
|
204
158
|
value: function posInViewPort(left, top, width, height) {
|
|
205
159
|
return {
|
|
206
|
-
left:
|
|
207
|
-
top:
|
|
208
|
-
width: width
|
|
209
|
-
height: height
|
|
210
|
-
scale: this.scale
|
|
160
|
+
left: -this.transform.left + left,
|
|
161
|
+
top: -this.transform.top + top,
|
|
162
|
+
width: width,
|
|
163
|
+
height: height
|
|
211
164
|
};
|
|
212
165
|
}
|
|
213
166
|
}]);
|
|
@@ -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
|
}, {
|
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);
|
|
@@ -67,6 +76,15 @@ var WindowManager = /*#__PURE__*/function () {
|
|
|
67
76
|
var windowManager = new WindowManager();
|
|
68
77
|
var StyledViewPort = styled(ViewPort)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\tborder: 1px solid #eee;\n"])));
|
|
69
78
|
export default observer(function Test() {
|
|
79
|
+
var _useState = useState(600),
|
|
80
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
81
|
+
w = _useState2[0],
|
|
82
|
+
setW = _useState2[1];
|
|
83
|
+
var _useState3 = useState(600),
|
|
84
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
85
|
+
h = _useState4[0],
|
|
86
|
+
setH = _useState4[1];
|
|
87
|
+
var containerRef = useRef(null);
|
|
70
88
|
useEffect(function () {
|
|
71
89
|
function setWidthHeight() {
|
|
72
90
|
runInAction(function () {
|
|
@@ -80,9 +98,45 @@ export default observer(function Test() {
|
|
|
80
98
|
window.removeEventListener('resize', setWidthHeight);
|
|
81
99
|
};
|
|
82
100
|
}, []);
|
|
101
|
+
useEffect(function () {
|
|
102
|
+
var el = containerRef.current;
|
|
103
|
+
if (!el) return;
|
|
104
|
+
var ro = new ResizeObserver(function (entries) {
|
|
105
|
+
var _iterator = _createForOfIteratorHelper(entries),
|
|
106
|
+
_step;
|
|
107
|
+
try {
|
|
108
|
+
var _loop = function _loop() {
|
|
109
|
+
var entry = _step.value;
|
|
110
|
+
var cr = entry.contentRect;
|
|
111
|
+
runInAction(function () {
|
|
112
|
+
// 保证写入的是数字(像素)
|
|
113
|
+
viewPortStore.width = Math.round(cr.width);
|
|
114
|
+
viewPortStore.height = Math.round(cr.height);
|
|
115
|
+
});
|
|
116
|
+
};
|
|
117
|
+
for (_iterator.s(); !(_step = _iterator.n()).done;) {
|
|
118
|
+
_loop();
|
|
119
|
+
}
|
|
120
|
+
} catch (err) {
|
|
121
|
+
_iterator.e(err);
|
|
122
|
+
} finally {
|
|
123
|
+
_iterator.f();
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
ro.observe(el);
|
|
127
|
+
// 立刻触发一次初始尺寸写入
|
|
128
|
+
var rect = el.getBoundingClientRect();
|
|
129
|
+
runInAction(function () {
|
|
130
|
+
viewPortStore.width = Math.round(rect.width);
|
|
131
|
+
viewPortStore.height = Math.round(rect.height);
|
|
132
|
+
});
|
|
133
|
+
return function () {
|
|
134
|
+
return ro.disconnect();
|
|
135
|
+
};
|
|
136
|
+
}, []);
|
|
83
137
|
return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
|
|
84
138
|
$css: []
|
|
85
|
-
}), /*#__PURE__*/React.createElement(Button, {
|
|
139
|
+
}), /*#__PURE__*/React.createElement(Space, null, /*#__PURE__*/React.createElement(Button, {
|
|
86
140
|
onClick: function onClick() {
|
|
87
141
|
windowManager.createWindow();
|
|
88
142
|
}
|
|
@@ -90,18 +144,40 @@ export default observer(function Test() {
|
|
|
90
144
|
onClick: function onClick() {
|
|
91
145
|
windowManager.toggleWindowIdIsJss();
|
|
92
146
|
}
|
|
93
|
-
}, "\u5207\u6362"), /*#__PURE__*/React.createElement(
|
|
147
|
+
}, "\u5207\u6362"), /*#__PURE__*/React.createElement(Button, {
|
|
148
|
+
onClick: function onClick() {
|
|
149
|
+
setW(function (v) {
|
|
150
|
+
return v + 100;
|
|
151
|
+
});
|
|
152
|
+
setH(function (v) {
|
|
153
|
+
return v + 100;
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
}, "\u53D8\u5927"), "x: ", viewPortStore.pageBounds.left, " y: ", viewPortStore.pageBounds.top), /*#__PURE__*/React.createElement("div", {
|
|
157
|
+
ref: containerRef,
|
|
158
|
+
style: {
|
|
159
|
+
width: w,
|
|
160
|
+
height: h
|
|
161
|
+
}
|
|
162
|
+
}, /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(StyledViewPort, {
|
|
94
163
|
viewPortStore: viewPortStore
|
|
95
164
|
}, windowManager.windows.map(function (windowStore) {
|
|
96
165
|
return /*#__PURE__*/React.createElement(ViewPort.Window, {
|
|
97
166
|
window: windowStore,
|
|
98
167
|
key: windowStore.id,
|
|
99
|
-
title: windowStore.id
|
|
168
|
+
title: windowStore.id,
|
|
169
|
+
options: [{
|
|
170
|
+
icon: /*#__PURE__*/React.createElement(QuestionCircleOutlined, null),
|
|
171
|
+
'aria-label': 'help',
|
|
172
|
+
onClick: function onClick() {
|
|
173
|
+
alert('help clicked');
|
|
174
|
+
}
|
|
175
|
+
}]
|
|
100
176
|
}, /*#__PURE__*/React.createElement("div", {
|
|
101
177
|
style: {
|
|
102
178
|
height: '2000px',
|
|
103
179
|
backgroundColor: 'pink'
|
|
104
180
|
}
|
|
105
181
|
}));
|
|
106
|
-
}))));
|
|
182
|
+
})))));
|
|
107
183
|
});
|
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;
|
|
@@ -167,7 +168,18 @@ var Window = observer(function (props) {
|
|
|
167
168
|
onPointerDown: function onPointerDown(e) {
|
|
168
169
|
e.stopPropagation();
|
|
169
170
|
}
|
|
170
|
-
},
|
|
171
|
+
}, Array.isArray(options) && options.map(function (i) {
|
|
172
|
+
if (!i.icon) {
|
|
173
|
+
return /*#__PURE__*/React.createElement(React.Fragment, null);
|
|
174
|
+
} else {
|
|
175
|
+
return /*#__PURE__*/React.createElement(WindowOption, {
|
|
176
|
+
"aria-label": i === null || i === void 0 ? void 0 : i['aria-label'],
|
|
177
|
+
icon: i === null || i === void 0 ? void 0 : i.icon,
|
|
178
|
+
onClick: i === null || i === void 0 ? void 0 : i.onClick,
|
|
179
|
+
danger: i === null || i === void 0 ? void 0 : i.danger
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
}), /*#__PURE__*/React.createElement(WindowOption, {
|
|
171
183
|
"aria-label": "\u5206\u4EAB\u7A97\u53E3",
|
|
172
184
|
icon: /*#__PURE__*/React.createElement(ShareAltOutlined, null),
|
|
173
185
|
onClick: onShareWindow
|
|
@@ -212,4 +224,6 @@ var Window = observer(function (props) {
|
|
|
212
224
|
}
|
|
213
225
|
})))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
|
|
214
226
|
});
|
|
227
|
+
var Window = WindowComponent;
|
|
228
|
+
Window.WindowOption = WindowOption;
|
|
215
229
|
export default Window;
|
|
@@ -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.23",
|
|
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": "1405b843c379237db0900f5ed07a4c3dfc7a05f3"
|
|
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
|
-
}();
|