@kep-platform/basic-component 1.0.21 → 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.
@@ -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.JSX.Element | Iterable<React.ReactNode> | null | undefined;
21
+ }): string | number | boolean | Iterable<React.ReactNode> | React.JSX.Element | null | undefined;
22
22
  export default PopupBox;
@@ -1,5 +1,5 @@
1
1
  import React, { ReactNode } from 'react';
2
- export declare const MainArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof import("../Flex").FlexItemProps | keyof React.HtmlHTMLAttributes<HTMLDivElement>> & import("../Flex").FlexItemProps & React.HtmlHTMLAttributes<HTMLDivElement>, "ref"> & {
2
+ export declare const MainArea: import("styled-components/dist/types").IStyledComponentBase<"web", import("styled-components").FastOmit<Omit<import("styled-components").FastOmit<React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>, keyof React.HtmlHTMLAttributes<HTMLDivElement> | keyof import("../Flex").FlexItemProps> & import("../Flex").FlexItemProps & React.HtmlHTMLAttributes<HTMLDivElement>, "ref"> & {
3
3
  ref?: ((instance: HTMLDivElement | null) => void) | React.RefObject<HTMLDivElement> | null | undefined;
4
4
  }, never>> & string;
5
5
  type MainPropertyProps = {
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
- onScale?: (left: number, top: number, scale: number, ratio: number) => void;
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", "onScale"];
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, viewPortStore.scale, viewPortStore.ratio);
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, _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
- }
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('wheel', scaleHandler, {
70
- passive: false
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
- (_contentRef$current2 = contentRef.current) === null || _contentRef$current2 === void 0 || _contentRef$current2.addEventListener('transitionend', onContentTransitionEnd);
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
- var _contentRef$current4;
76
- (_contentRef$current4 = contentRef.current) === null || _contentRef$current4 === void 0 || _contentRef$current4.removeEventListener('wheel', scaleHandler);
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
- }), rippleManagerStore.rippleInfo, /*#__PURE__*/React.createElement(Content, _extends({
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
- ratio: number;
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
- constructor(width?: number, height?: number, ratio?: number);
20
- get scaleStep(): number;
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
- scale: number;
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 { action, computed, makeObservable, observable } from 'mobx';
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, "ratio", 5);
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
- if (ratio) {
30
- this.ratio = ratio;
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
- ratio: observable,
42
+ containerRect: observable.struct,
42
43
  isMoving: observable,
43
44
  maxZIndex: observable,
44
45
  isTransition: observable,
45
- scaleStep: computed,
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 = this.formatedTransform(left, top);
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.setScale(1);
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 - this.offsetLeft, "px,").concat(this.transform.top - this.offsetTop, "px) scale(").concat(this.scale, ")"),
162
- width: this.width * this.ratio + 'px',
163
- height: this.height * this.ratio + 'px',
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' : 'all 0.3s ease-in-out',
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
- /* 这个函数比较重要,因为你想要让content中的元素在视窗相对位置显示,这个函数会帮你计算偏移量和缩放量,直接得出你的元素应该在content中的偏移量 */
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: (-this.transform.left + this.offsetLeft + left) / this.scale,
207
- top: (-this.transform.top + this.offsetTop + top) / this.scale,
208
- width: width / this.scale,
209
- height: height / this.scale,
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
  }]);
@@ -7,6 +7,7 @@ import { ViewPortStore } from './ViewPortStore';
7
7
  export declare class ViewPortWindowStore extends WindowStore {
8
8
  viewPortStore: ViewPortStore;
9
9
  disableDefaultCenterDisplay: boolean;
10
+ allowOverflow: boolean;
10
11
  get style(): {
11
12
  left: string;
12
13
  top: string;
@@ -32,13 +33,15 @@ export declare class ViewPortWindowStore extends WindowStore {
32
33
  x: number;
33
34
  y: number;
34
35
  };
35
- controll(transform: Transform, type: WindowControllerType): void;
36
+ control(transform: Transform, type: WindowControllerType): void;
36
37
  centerDisplay(): void;
37
38
  fullscreenWindow(func?: () => void): void;
38
39
  toggleWindow(): void;
39
40
  onSplitWindowHandler(arr: string[], index: number): void;
41
+ enforceBounds(): void;
40
42
  constructor(id: string, viewPort: ViewPortStore, config?: {
41
43
  disableDefaultCenterDisplay?: boolean;
44
+ allowOverflow?: boolean;
42
45
  onClosedHandler?: (id: string) => void;
43
46
  });
44
47
  get disabled(): boolean;
@@ -30,16 +30,20 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
30
30
  _this = _super.call(this, id, config === null || config === void 0 ? void 0 : config.onClosedHandler);
31
31
  _defineProperty(_assertThisInitialized(_this), "viewPortStore", void 0);
32
32
  _defineProperty(_assertThisInitialized(_this), "disableDefaultCenterDisplay", false);
33
+ _defineProperty(_assertThisInitialized(_this), "allowOverflow", false);
33
34
  _this.viewPortStore = viewPort;
34
35
  _this.fullscreenPos = viewPort.viewPortRect;
35
36
  _this.disableDefaultCenterDisplay = (config === null || config === void 0 ? void 0 : config.disableDefaultCenterDisplay) || false;
37
+ _this.allowOverflow = (config === null || config === void 0 ? void 0 : config.allowOverflow) || false;
36
38
  makeObservable(_assertThisInitialized(_this), {
37
39
  style: override,
38
- controll: override,
40
+ control: override,
39
41
  focus: override,
40
42
  centerDisplay: action,
41
43
  disabled: override,
42
- disableDefaultCenterDisplay: observable
44
+ disableDefaultCenterDisplay: observable,
45
+ allowOverflow: observable,
46
+ enforceBounds: action
43
47
  });
44
48
  return _this;
45
49
  }
@@ -55,8 +59,8 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
55
59
  height: this.height + 'px',
56
60
  zIndex: this.zIndex,
57
61
  transform: 'scale(0)',
58
- transformOrigin: 'center center',
59
- transition: 'all 0.3s ease-out'
62
+ transformOrigin: 'center',
63
+ transition: "all ".concat(this.animationDurationClose, " ").concat(this.animationEasing)
60
64
  };
61
65
  case 'minimize':
62
66
  return {
@@ -67,18 +71,18 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
67
71
  zIndex: this.zIndex,
68
72
  transform: 'scale(0)',
69
73
  transformOrigin: 'left top',
70
- transition: "all ".concat(0.5 + this.viewPortStore.scale, "s ease-out")
74
+ transition: "all ".concat(this.animationDurationMinimize, " ").concat(this.animationEasing)
71
75
  };
72
76
  case 'fullscreen':
73
77
  return {
74
78
  left: this.fullscreenPos.left + 'px',
75
79
  top: this.fullscreenPos.top + 'px',
76
- width: this.fullscreenPos.width * this.viewPortStore.scale + 'px',
77
- height: this.fullscreenPos.height * this.viewPortStore.scale + 'px',
78
- transform: "scale(".concat(1 / this.viewPortStore.scale, ")"),
80
+ width: this.fullscreenPos.width + 'px',
81
+ height: this.fullscreenPos.height + 'px',
82
+ transform: 'none',
79
83
  zIndex: this.zIndex,
80
84
  transformOrigin: 'left top',
81
- transition: 'width height 0.5s ease-out'
85
+ transition: "all ".concat(this.animationDurationFullscreen, " ").concat(this.animationEasing)
82
86
  };
83
87
  case 'normal':
84
88
  default:
@@ -100,7 +104,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
100
104
  height: this.height + 'px',
101
105
  zIndex: this.zIndex,
102
106
  transform: 'none',
103
- transition: 'all 0.3s ease-out'
107
+ transition: "all ".concat(this.animationDurationNormal, " ").concat(this.animationEasing)
104
108
  };
105
109
  }
106
110
  }
@@ -119,14 +123,15 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
119
123
  key: "calculateTransform",
120
124
  value: function calculateTransform(transform) {
121
125
  var _this$transform, _this$transform2;
126
+ // 固定正常尺寸下,直接使用像素位移
122
127
  return {
123
- x: (transform.x - (((_this$transform = this.transform) === null || _this$transform === void 0 ? void 0 : _this$transform.x) || 0)) / this.viewPortStore.scale,
124
- y: (transform.y - (((_this$transform2 = this.transform) === null || _this$transform2 === void 0 ? void 0 : _this$transform2.y) || 0)) / this.viewPortStore.scale
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)
125
130
  };
126
131
  }
127
132
  }, {
128
- key: "controll",
129
- value: function controll(transform, type) {
133
+ key: "control",
134
+ value: function control(transform, type) {
130
135
  var offsetTransform = this.calculateTransform(transform);
131
136
  if (type === 'move') {
132
137
  this.isMoving = true;
@@ -154,6 +159,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
154
159
  this.top = Math.round(this.top + offsetTransform.y);
155
160
  }
156
161
  this.transform = transform;
162
+ this.enforceBounds();
157
163
  }
158
164
  }, {
159
165
  key: "centerDisplay",
@@ -162,6 +168,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
162
168
  var rect = this.viewPortStore.viewPortRect;
163
169
  this.left = rect.left + Math.max(0, rect.width - this.width) / 2;
164
170
  this.top = rect.top + Math.max(0, rect.height - this.height) / 2;
171
+ this.enforceBounds();
165
172
  }
166
173
  }, {
167
174
  key: "fullscreenWindow",
@@ -209,6 +216,30 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
209
216
  this.top = 0;
210
217
  this.width = this.calculatePercentageValue(arr[index], this.viewPortStore.viewPortRect.width);
211
218
  this.height = this.viewPortStore.viewPortRect.height;
219
+ this.enforceBounds();
220
+ }
221
+
222
+ // 边界约束方法
223
+ }, {
224
+ key: "enforceBounds",
225
+ value: function enforceBounds() {
226
+ // 如果允许超出则不做任何约束
227
+ if (this.allowOverflow) return;
228
+ var rect = this.viewPortStore.viewPortRect;
229
+ var minWidth = 50;
230
+ var minHeight = 50;
231
+
232
+ // 限制尺寸不会超过 viewport
233
+ if (this.width > rect.width) this.width = rect.width;
234
+ if (this.height > rect.height) this.height = rect.height;
235
+
236
+ // 限制最小尺寸
237
+ this.width = Math.max(this.width, minWidth);
238
+ this.height = Math.max(this.height, minHeight);
239
+
240
+ // 限制位置在 viewport 内
241
+ this.left = Math.max(rect.left, Math.min(this.left, rect.left + rect.width - this.width));
242
+ this.top = Math.max(rect.top, Math.min(this.top, rect.top + rect.height - this.height));
212
243
  }
213
244
  }, {
214
245
  key: "disabled",
@@ -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, 1);
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(DndContext, null, /*#__PURE__*/React.createElement(StyledViewPort, {
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
  });
@@ -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: ((props: WindowProps) => React.JSX.Element) & {
13
- displayName: string;
19
+ declare const Window: React.FunctionComponent<WindowProps> & {
20
+ WindowOption: FunctionComponent<WindowOptionProps>;
14
21
  };
15
22
  export default Window;
@@ -25,10 +25,10 @@ var WindowHeader = styled.div.withConfig({
25
25
  })(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n\theight: 40px;\n\tpadding: 6px 12px;\n\tline-height: 26px;\n\tfont-size: 16px;\n\tbackground-color: var(--kep-platform-color-bg-layout-header);\n\ttransition: margin 0.35s, opacity 0.7s, box-shadow 0.7s;\n\tposition: relative;\n\tcolor: #000;\n\t& > h5 {\n\t\tcolor: #000;\n\t}\n"])));
26
26
  var WindowHeaderOptions = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\tright: 0;\n\ttop: 0;\n\theight: 100%;\n\tdisplay: flex;\n\tz-index: 3;\n"])));
27
27
  var WindowBody = styled.div(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n\toverflow: auto;\n\tpadding: 12px;\n\tflex: 1;\n"])));
28
- var WindowControllerLeft = styled(WindowController)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tcursor: e-resize;\n\tz-index: 2;\n"])));
29
- var WindowControllerRight = styled(WindowController)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\theight: 100%;\n\tright: 0;\n\ttop: 0;\n\tbottom: 0;\n\tcursor: e-resize;\n\tz-index: 2;\n"])));
30
- var WindowControllerTop = styled(WindowController)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 100%;\n\theight: 6px;\n\tleft: 0;\n\tright: 0;\n\ttop: 0;\n\tcursor: n-resize;\n\tz-index: 2;\n"])));
31
- var WindowControllerBottom = styled(WindowController)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 100%;\n\theight: 6px;\n\tleft: 0;\n\tright: 0;\n\tbottom: 0;\n\tcursor: n-resize;\n\tz-index: 2;\n"])));
28
+ var WindowControllerLeft = styled(WindowController)(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\tleft: 0;\n\ttop: 0;\n\tbottom: 0;\n\tcursor: ew-resize;\n\tz-index: 2;\n"])));
29
+ var WindowControllerRight = styled(WindowController)(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\theight: 100%;\n\tright: 0;\n\ttop: 0;\n\tbottom: 0;\n\tcursor: ew-resize;\n\tz-index: 2;\n"])));
30
+ var WindowControllerTop = styled(WindowController)(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 100%;\n\theight: 6px;\n\tleft: 0;\n\tright: 0;\n\ttop: 0;\n\tcursor: ns-resize;\n\tz-index: 2;\n"])));
31
+ var WindowControllerBottom = styled(WindowController)(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 100%;\n\theight: 6px;\n\tleft: 0;\n\tright: 0;\n\tbottom: 0;\n\tcursor: ns-resize;\n\tz-index: 2;\n"])));
32
32
  var WindowControllerLeftTop = styled(WindowController)(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\theight: 6px;\n\tleft: 0;\n\ttop: 0;\n\tcursor: nwse-resize;\n\tz-index: 2;\n"])));
33
33
  var WindowControllerLeftBottom = styled(WindowController)(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\theight: 6px;\n\tleft: 0;\n\tbottom: 0;\n\tcursor: nesw-resize;\n\tz-index: 2;\n"])));
34
34
  var WindowControllerRightTop = styled(WindowController)(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n\tposition: absolute;\n\twidth: 6px;\n\theight: 6px;\n\tright: 0;\n\ttop: 0;\n\tcursor: nesw-resize;\n\tz-index: 2;\n"])));
@@ -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 Window = observer(function (props) {
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,19 @@ var Window = observer(function (props) {
167
168
  onPointerDown: function onPointerDown(e) {
168
169
  e.stopPropagation();
169
170
  }
170
- }, /*#__PURE__*/React.createElement(WindowOption, {
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, {
183
+ "aria-label": "\u5206\u4EAB\u7A97\u53E3",
171
184
  icon: /*#__PURE__*/React.createElement(ShareAltOutlined, null),
172
185
  onClick: onShareWindow
173
186
  }), 'viewPortStore' in window && window.viewPortStore && /*#__PURE__*/React.createElement(Popover, {
@@ -184,30 +197,33 @@ var Window = observer(function (props) {
184
197
  }, /*#__PURE__*/React.createElement(WindowOption, {
185
198
  icon: /*#__PURE__*/React.createElement(SplitCellsOutlined, null)
186
199
  })), /*#__PURE__*/React.createElement(WindowOption, {
200
+ "aria-label": "\u6700\u5C0F\u5316\u7A97\u53E3",
187
201
  icon: /*#__PURE__*/React.createElement(MinusOutlined, null),
188
202
  onClick: function onClick() {
189
203
  if (window.disabled) return;
190
204
  window.minimizeWindow();
191
205
  }
192
- }), !window.fullscreen ? /*#__PURE__*/React.createElement(WindowOption, {
193
- icon: /*#__PURE__*/React.createElement(BorderOutlined, null),
194
- onClick: function onClick() {
195
- if (window.disabled) return;
196
- window.fullscreenWindow(onFullscreenHandler);
197
- }
198
- }) : /*#__PURE__*/React.createElement(WindowOption, {
199
- icon: /*#__PURE__*/React.createElement(CompressOutlined, null),
206
+ }), /*#__PURE__*/React.createElement(WindowOption, {
207
+ "aria-label": window.fullscreen ? '退出全屏' : '进入全屏',
208
+ icon: window.fullscreen ? /*#__PURE__*/React.createElement(CompressOutlined, null) : /*#__PURE__*/React.createElement(BorderOutlined, null),
200
209
  onClick: function onClick() {
201
210
  if (window.disabled) return;
202
- window.fullscreenExitWindow();
211
+ if (window.fullscreen) {
212
+ window.fullscreenExitWindow();
213
+ } else {
214
+ window.fullscreenWindow(onFullscreenHandler);
215
+ }
203
216
  }
204
217
  }), /*#__PURE__*/React.createElement(WindowOption, {
218
+ "aria-label": "\u5173\u95ED\u7A97\u53E3",
219
+ icon: /*#__PURE__*/React.createElement(CloseOutlined, null),
220
+ danger: true,
205
221
  onClick: function onClick() {
206
222
  if (window.disabled) return;
207
223
  window.closeWindow();
208
- },
209
- icon: /*#__PURE__*/React.createElement(CloseOutlined, null),
210
- danger: true
224
+ }
211
225
  })))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
212
226
  });
227
+ var Window = WindowComponent;
228
+ Window.WindowOption = WindowOption;
213
229
  export default Window;
@@ -8,7 +8,7 @@ import { useDraggable } from '@dnd-kit/core';
8
8
  import { observer } from 'mobx-react-lite';
9
9
  import React, { useEffect } from 'react';
10
10
  import styled from 'styled-components';
11
- var WindowControllerContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &:active,\n &:focus {\n outline: none;\n }\n"])));
11
+ var WindowControllerContainer = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n\t&:active,\n\t&:focus {\n\t\toutline: none;\n\t}\n"])));
12
12
  export default observer(function WindowController(props) {
13
13
  var type = props.type,
14
14
  window = props.window,
@@ -24,9 +24,9 @@ export default observer(function WindowController(props) {
24
24
  isDragging = _useDraggable.isDragging;
25
25
  useEffect(function () {
26
26
  if (transform && isDragging) {
27
- window.controll(transform, type);
27
+ window.control(transform, type);
28
28
  } else {
29
- window.endControll();
29
+ window.endControl();
30
30
  }
31
31
  }, [transform, isDragging, type]);
32
32
  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;
@@ -40,8 +45,8 @@ export default class WindowStore {
40
45
  x: number;
41
46
  y: number;
42
47
  };
43
- controll(transform: Transform, type: WindowControllerType): void;
44
- endControll(): void;
48
+ control(transform: Transform, type: WindowControllerType): void;
49
+ endControl(): void;
45
50
  minimizeWindow(): void;
46
51
  normalizeWindow(): void;
47
52
  restoreWindow(): void;
@@ -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 { action, computed, makeObservable, observable, runInAction } from 'mobx';
8
+ import { action, computed, makeObservable, observable } from 'mobx';
9
9
  var WindowStore = /*#__PURE__*/function () {
10
10
  function WindowStore(id, onClosedHandler) {
11
11
  _classCallCheck(this, WindowStore);
@@ -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,10 +51,15 @@ 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
- controll: action,
52
- endControll: action,
61
+ control: action,
62
+ endControl: action,
53
63
  style: computed.struct,
54
64
  isMinimize: observable,
55
65
  minimizePos: observable.struct,
@@ -62,7 +72,8 @@ var WindowStore = /*#__PURE__*/function () {
62
72
  focus: action,
63
73
  info: computed,
64
74
  disabled: computed,
65
- splitPanelVisible: observable
75
+ splitPanelVisible: observable,
76
+ onSplitWindowHandler: action
66
77
  });
67
78
  this.id = id;
68
79
  this.onClosedHandler = onClosedHandler;
@@ -101,37 +112,34 @@ var WindowStore = /*#__PURE__*/function () {
101
112
  };
102
113
  }
103
114
  }, {
104
- key: "controll",
105
- value: function controll(transform, type) {
106
- var _this = this;
115
+ key: "control",
116
+ value: function control(transform, type) {
107
117
  var offsetTransform = this.calculateTransform(transform);
108
- runInAction(function () {
109
- _this.isMoving = type === 'move';
110
- _this.isResizing = type !== 'move';
111
- if (type.includes('left')) {
112
- _this.left = Math.round(_this.left + offsetTransform.x);
113
- _this.width = Math.round(_this.width - offsetTransform.x);
114
- }
115
- if (type.includes('right')) {
116
- _this.width = Math.round(_this.width + offsetTransform.x);
117
- }
118
- if (type.includes('top')) {
119
- _this.top = Math.round(_this.top + offsetTransform.y);
120
- _this.height = Math.round(_this.height - offsetTransform.y);
121
- }
122
- if (type.includes('bottom')) {
123
- _this.height = Math.round(_this.height + offsetTransform.y);
124
- }
125
- if (type.includes('move')) {
126
- _this.left = Math.round(_this.left + offsetTransform.x);
127
- _this.top = Math.round(_this.top + offsetTransform.y);
128
- }
129
- _this.transform = transform;
130
- });
118
+ this.isMoving = type === 'move';
119
+ this.isResizing = type !== 'move';
120
+ if (type.includes('left')) {
121
+ this.left = Math.round(this.left + offsetTransform.x);
122
+ this.width = Math.round(this.width - offsetTransform.x);
123
+ }
124
+ if (type.includes('right')) {
125
+ this.width = Math.round(this.width + offsetTransform.x);
126
+ }
127
+ if (type.includes('top')) {
128
+ this.top = Math.round(this.top + offsetTransform.y);
129
+ this.height = Math.round(this.height - offsetTransform.y);
130
+ }
131
+ if (type.includes('bottom')) {
132
+ this.height = Math.round(this.height + offsetTransform.y);
133
+ }
134
+ if (type.includes('move')) {
135
+ this.left = Math.round(this.left + offsetTransform.x);
136
+ this.top = Math.round(this.top + offsetTransform.y);
137
+ }
138
+ this.transform = transform;
131
139
  }
132
140
  }, {
133
- key: "endControll",
134
- value: function endControll() {
141
+ key: "endControl",
142
+ value: function endControl() {
135
143
  this.isMoving = false;
136
144
  this.isResizing = false;
137
145
  this.resetState();
@@ -167,6 +175,7 @@ var WindowStore = /*#__PURE__*/function () {
167
175
  key: "focus",
168
176
  value: function focus() {
169
177
  this.zIndex++;
178
+ this.isMinimize = false;
170
179
  }
171
180
  }, {
172
181
  key: "calculatePercentageValue",
@@ -178,12 +187,12 @@ var WindowStore = /*#__PURE__*/function () {
178
187
  }, {
179
188
  key: "onSplitWindowHandler",
180
189
  value: function onSplitWindowHandler(arr, index) {
181
- var _this2 = this;
190
+ var _this = this;
182
191
  this.restoreWindow();
183
192
  this.splitPanelVisible = false;
184
193
  var leftPieces = arr.slice(0, index);
185
194
  var leftWidth = leftPieces.reduce(function (acc, cur) {
186
- return acc + _this2.calculatePercentageValue(cur, _this2.fullscreenPos.width);
195
+ return acc + _this.calculatePercentageValue(cur, _this.fullscreenPos.width);
187
196
  }, 0);
188
197
  this.left = leftWidth;
189
198
  this.top = 0;
@@ -217,18 +226,18 @@ var WindowStore = /*#__PURE__*/function () {
217
226
  zIndex: this.zIndex,
218
227
  transform: 'scale(0)',
219
228
  transformOrigin: 'center center',
220
- transition: 'all 0.3s ease-in-out'
229
+ transition: "all ".concat(this.animationDurationClose, " ").concat(this.animationEasing)
221
230
  };
222
231
  case 'minimize':
223
232
  return {
224
233
  left: this.minimizePos.left + 'px',
225
234
  top: this.minimizePos.top + 'px',
226
235
  width: this.width + 'px',
227
- height: this.width + 'px',
236
+ height: this.height + 'px',
228
237
  zIndex: this.zIndex,
229
238
  transform: 'scale(0)',
230
239
  transformOrigin: 'left top',
231
- transition: 'all 0.3s ease-in-out'
240
+ transition: "all ".concat(this.animationDurationMinimize, " ").concat(this.animationEasing)
232
241
  };
233
242
  case 'fullscreen':
234
243
  return {
@@ -238,7 +247,7 @@ var WindowStore = /*#__PURE__*/function () {
238
247
  height: this.fullscreenPos.height + 'px',
239
248
  zIndex: this.zIndex,
240
249
  transform: 'none',
241
- transition: 'all 0.3s ease-in-out'
250
+ transition: "all ".concat(this.animationDurationFullscreen, " ").concat(this.animationEasing)
242
251
  };
243
252
  case 'normal':
244
253
  default:
@@ -260,7 +269,7 @@ var WindowStore = /*#__PURE__*/function () {
260
269
  height: this.height + 'px',
261
270
  zIndex: this.zIndex,
262
271
  transform: 'none',
263
- transition: 'all 0.3s ease-in-out'
272
+ transition: "all ".concat(this.animationDurationNormal, " ").concat(this.animationEasing)
264
273
  };
265
274
  }
266
275
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "1.0.21",
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": "8e45b692a1b25bfb1750114aefe5727edca77b09"
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 {};
@@ -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
- }();