@kep-platform/basic-component 0.0.39 → 0.0.41

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.
@@ -0,0 +1,15 @@
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 {};
@@ -0,0 +1,56 @@
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
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 { makeAutoObservable } from 'mobx';
9
+ import React from 'react';
10
+ import styled, { keyframes } from 'styled-components';
11
+ var rippleAnimation = keyframes(["from{transform:scale(1);}to{transform:scale(4);opacity:0;}"]);
12
+ export var Ripple = styled.div.withConfig({
13
+ displayName: "Ripple",
14
+ componentId: "basic-component-347b__sc-zqrqyo-0"
15
+ })(["position:absolute;border-radius:50%;width:10px;height:10px;background-color:#fff0;& > div{position:absolute;left:0;top:0;width:10px;height:10px;background-color:#fff;border-radius:50%;margin-left:-5px;margin-top:-5px;transform:scale(0);animation:", " 500ms linear;}& .first{}& .second{animation-delay:150ms;}"], rippleAnimation);
16
+ export var RippleManagerStore = /*#__PURE__*/function () {
17
+ function RippleManagerStore() {
18
+ _classCallCheck(this, RippleManagerStore);
19
+ _defineProperty(this, "list", []);
20
+ makeAutoObservable(this);
21
+ }
22
+ _createClass(RippleManagerStore, [{
23
+ key: "clearList",
24
+ value: function clearList() {
25
+ this.list = [];
26
+ }
27
+ }, {
28
+ key: "addRipple",
29
+ value: function addRipple(left, top) {
30
+ this.list.push({
31
+ id: new Date().getTime(),
32
+ left: left,
33
+ top: top
34
+ });
35
+ }
36
+ }, {
37
+ key: "rippleInfo",
38
+ get: function get() {
39
+ return this.list.map(function (ripple) {
40
+ return /*#__PURE__*/React.createElement(Ripple, {
41
+ key: ripple.id,
42
+ style: {
43
+ left: ripple.left,
44
+ top: ripple.top,
45
+ zIndex: 10
46
+ }
47
+ }, /*#__PURE__*/React.createElement("div", {
48
+ className: "first"
49
+ }), /*#__PURE__*/React.createElement("div", {
50
+ className: "second"
51
+ }));
52
+ });
53
+ }
54
+ }]);
55
+ return RippleManagerStore;
56
+ }();
@@ -1,108 +1,16 @@
1
- import { Transform } from '@dnd-kit/utilities';
2
1
  import React, { HtmlHTMLAttributes, ReactNode } from 'react';
3
- import { WindowStore } from '../Window';
4
- import { WindowProps } from '../Window/Window';
5
- import { WindowControllerType } from '../Window/WindowController';
2
+ import { ViewPortStore } from './ViewPortStore';
6
3
  type ViewPortProps = {
7
4
  children?: ReactNode;
8
5
  viewPortStore: ViewPortStore;
9
6
  onScale?: (left: number, top: number, scale: number, ratio: number) => void;
10
7
  onScroll?: (left: number, top: number, scale: number, ratio: number) => void;
11
8
  } & HtmlHTMLAttributes<HTMLDivElement>;
12
- export declare class ViewPortStore {
13
- transform: {
14
- left: number;
15
- top: number;
16
- };
17
- offset: {
18
- x: number;
19
- y: number;
20
- };
21
- scale: number;
22
- width: number;
23
- height: number;
24
- ratio: number;
25
- isMoving: boolean;
26
- maxZIndex: number;
27
- constructor(width?: number, height?: number, ratio?: number);
28
- increaseScale(): void;
29
- setScale(scale: number): void;
30
- focus(left: number, top: number): void;
31
- decreaseScale(): void;
32
- move(transform: Transform): void;
33
- endMove(): void;
34
- get transformLimit(): {
35
- left: {
36
- max: number;
37
- min: number;
38
- };
39
- top: {
40
- max: number;
41
- min: number;
42
- };
43
- };
44
- formatedTransform(left: number, top: number): {
45
- left: number;
46
- top: number;
47
- };
48
- get formatedScale(): number;
49
- get contentStyle(): {
50
- transform: string;
51
- width: string;
52
- height: string;
53
- transformOrigin: string;
54
- backgroundColor: string;
55
- transition: string;
56
- };
57
- get containerStyle(): {
58
- width: string;
59
- height: string;
60
- overflow: string;
61
- };
62
- get info(): string;
63
- }
64
9
  declare function ViewPort(props: ViewPortProps): React.JSX.Element;
65
10
  declare namespace ViewPort {
66
- var Window: React.FunctionComponent<WindowProps & {
11
+ var Window: React.FunctionComponent<import("../Window/Window").WindowProps & {
67
12
  viewPortStore: ViewPortStore;
68
- window: ViewPortWindowStore;
13
+ window: import("./ViewPortWindow").ViewPortWindowStore;
69
14
  }>;
70
15
  }
71
16
  export default ViewPort;
72
- export declare class ViewPortWindowStore extends WindowStore {
73
- scale: number;
74
- get style(): {
75
- left: string;
76
- top: string;
77
- width: string;
78
- height: string;
79
- zIndex: number;
80
- transform: string;
81
- transition: string;
82
- transformOrigin?: undefined;
83
- } | {
84
- left: string;
85
- top: string;
86
- width: number;
87
- height: number;
88
- zIndex: number;
89
- transform: string;
90
- transition: string;
91
- transformOrigin?: undefined;
92
- } | {
93
- left: string;
94
- top: string;
95
- width: string;
96
- height: string;
97
- zIndex: number;
98
- transform: string;
99
- transformOrigin: string;
100
- transition: string;
101
- };
102
- calculateTransform(transform: Transform): {
103
- x: number;
104
- y: number;
105
- };
106
- controll(transform: Transform, type: WindowControllerType): void;
107
- constructor(id: string, onClosedHandler?: (id: string) => void);
108
- }
@@ -1,30 +1,14 @@
1
- var _excluded = ["children", "viewPortStore"],
2
- _excluded2 = ["viewPortStore", "window"];
3
- 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); }
4
- function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
5
- function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
6
- function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
- function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
8
- function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
9
- function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
- function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
1
+ var _excluded = ["children", "viewPortStore", "onScroll", "onScale"],
2
+ _excluded2 = ["children", "viewPortStore"];
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); }
11
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; }
12
5
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
13
- 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); }
14
- function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
15
- 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); } }
16
- function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
17
- 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; }
18
- function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
19
- 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); }
20
6
  import { DndContext, useDraggable } from '@dnd-kit/core';
21
- import { makeAutoObservable, makeObservable, observable, override, runInAction } from 'mobx';
22
7
  import { observer } from 'mobx-react-lite';
23
8
  import React, { useEffect, useRef } from 'react';
24
9
  import styled from 'styled-components';
25
- import { WindowStore } from "../Window";
26
- import { default as Window } from "../Window/Window";
27
- import { GlobalStyles } from "../__styles";
10
+ import { RippleManagerStore } from "./Ripple";
11
+ import { ViewPortWindow } from "./ViewPortWindow";
28
12
  var Container = styled.div.withConfig({
29
13
  displayName: "Container",
30
14
  componentId: "basic-component-347b__sc-1qpmpop-0"
@@ -33,130 +17,13 @@ var Content = styled.div.withConfig({
33
17
  displayName: "Content",
34
18
  componentId: "basic-component-347b__sc-1qpmpop-1"
35
19
  })(["position:absolute;"]);
36
- export var ViewPortStore = /*#__PURE__*/function () {
37
- function ViewPortStore(width, height, ratio) {
38
- _classCallCheck(this, ViewPortStore);
39
- _defineProperty(this, "transform", {
40
- left: 0,
41
- top: 0
42
- });
43
- _defineProperty(this, "offset", {
44
- x: 0,
45
- y: 0
46
- });
47
- _defineProperty(this, "scale", 1);
48
- _defineProperty(this, "width", 600);
49
- _defineProperty(this, "height", 600);
50
- _defineProperty(this, "ratio", 5);
51
- //缩放比例
52
- _defineProperty(this, "isMoving", false);
53
- _defineProperty(this, "maxZIndex", 1);
54
- if (ratio) this.ratio = ratio;
55
- if (width) this.width = width;
56
- if (height) this.height = height;
57
- makeAutoObservable(this);
58
- }
59
- _createClass(ViewPortStore, [{
60
- key: "increaseScale",
61
- value: function increaseScale() {
62
- if (this.scale < 1) this.scale += 0.03125;else this.scale = 1;
63
- }
64
- }, {
65
- key: "setScale",
66
- value: function setScale(scale) {
67
- this.scale = scale;
68
- }
69
- }, {
70
- key: "focus",
71
- value: function focus(left, top) {
72
- this.scale = 0.8;
73
- this.transform = {
74
- left: (1 - this.ratio) * left,
75
- top: (1 - this.ratio) * top
76
- };
77
- }
78
- }, {
79
- key: "decreaseScale",
80
- value: function decreaseScale() {
81
- if (this.scale > parseFloat((1 / this.ratio).toFixed(1))) this.scale -= 0.03125;
82
- }
83
- }, {
84
- key: "move",
85
- value: function move(transform) {
86
- this.isMoving = true;
87
- this.transform = this.formatedTransform(transform.x - this.offset.x + this.transform.left, transform.y - this.offset.y + this.transform.top);
88
- this.offset.x = transform.x;
89
- this.offset.y = transform.y;
90
- }
91
- }, {
92
- key: "endMove",
93
- value: function endMove() {
94
- this.offset.x = 0;
95
- this.offset.y = 0;
96
- this.isMoving = false;
97
- }
98
- }, {
99
- key: "transformLimit",
100
- get: function get() {
101
- return {
102
- left: {
103
- max: 0,
104
- min: this.width - this.width * this.ratio * this.formatedScale
105
- },
106
- top: {
107
- max: 0,
108
- min: this.height - this.height * this.ratio * this.formatedScale
109
- }
110
- };
111
- }
112
- }, {
113
- key: "formatedTransform",
114
- value: function formatedTransform(left, top) {
115
- return {
116
- left: Math.max(this.transformLimit.left.min, Math.min(left, this.transformLimit.left.max)),
117
- top: Math.max(this.transformLimit.top.min, Math.min(top, this.transformLimit.top.max))
118
- };
119
- }
120
- }, {
121
- key: "formatedScale",
122
- get: function get() {
123
- return Math.min(1, Math.max(1 / this.ratio, this.scale));
124
- }
125
- }, {
126
- key: "contentStyle",
127
- get: function get() {
128
- var transform = this.formatedTransform(this.transform.left, this.transform.top);
129
- return {
130
- transform: "translate(".concat(transform.left, "px,").concat(transform.top, "px) scale(").concat(this.formatedScale, ")"),
131
- width: this.width * this.ratio + 'px',
132
- height: this.height * this.ratio + 'px',
133
- transformOrigin: "0 0",
134
- backgroundColor: 'pink',
135
- transition: this.isMoving ? 'none' : 'all 0.5s'
136
- };
137
- }
138
- }, {
139
- key: "containerStyle",
140
- get: function get() {
141
- return {
142
- width: this.width + 'px',
143
- height: this.height + 'px',
144
- overflow: 'hidden'
145
- };
146
- }
147
- }, {
148
- key: "info",
149
- get: function get() {
150
- return JSON.stringify(this.formatedTransform(this.transform.left, this.transform.top), null, 4);
151
- }
152
- }]);
153
- return ViewPortStore;
154
- }();
20
+ var rippleManagerStore = new RippleManagerStore();
155
21
  var ViewPortEntity = observer(function (props) {
156
22
  var children = props.children,
157
23
  viewPortStore = props.viewPortStore,
158
24
  onScroll = props.onScroll,
159
- onScale = props.onScale;
25
+ onScale = props.onScale,
26
+ rest = _objectWithoutProperties(props, _excluded);
160
27
  var _useDraggable = useDraggable({
161
28
  id: 'ViewPortEntity'
162
29
  }),
@@ -166,6 +33,17 @@ var ViewPortEntity = observer(function (props) {
166
33
  setActivatorNodeRef = _useDraggable.setActivatorNodeRef,
167
34
  transform = _useDraggable.transform;
168
35
  var _ref = useRef(null);
36
+ var createRipple = function createRipple(event) {
37
+ event.preventDefault();
38
+ event.stopPropagation();
39
+ var rect = event.currentTarget.getBoundingClientRect();
40
+ var left = event.clientX - rect.left;
41
+ var top = event.clientY - rect.top;
42
+ rippleManagerStore.addRipple(left, top);
43
+ setTimeout(function () {
44
+ rippleManagerStore.clearList();
45
+ }, 30000);
46
+ };
169
47
  useEffect(function () {
170
48
  if (transform) {
171
49
  viewPortStore.move(transform);
@@ -194,8 +72,9 @@ var ViewPortEntity = observer(function (props) {
194
72
  (_ref$current2 = _ref.current) === null || _ref$current2 === void 0 || _ref$current2.removeEventListener('wheel', scaleHandler);
195
73
  };
196
74
  }, []);
197
- return /*#__PURE__*/React.createElement(Container, {
75
+ return /*#__PURE__*/React.createElement(Container, _extends({
198
76
  style: viewPortStore.containerStyle,
77
+ onPointerDown: createRipple,
199
78
  onDoubleClick: function onDoubleClick(e) {
200
79
  var container = e.currentTarget;
201
80
  var _container$getBoundin = container.getBoundingClientRect(),
@@ -203,11 +82,11 @@ var ViewPortEntity = observer(function (props) {
203
82
  top = _container$getBoundin.top;
204
83
  var offsetLeft = e.clientX - left;
205
84
  var offsetTop = e.clientY - top;
206
- if (viewPortStore.formatedScale > 0.5) {
207
- viewPortStore.setScale(1 / viewPortStore.ratio);
85
+ if (viewPortStore.scale === 1) {
86
+ viewPortStore.unfocus();
208
87
  } else viewPortStore.focus(offsetLeft, offsetTop);
209
88
  }
210
- }, /*#__PURE__*/React.createElement(Content, _extends({
89
+ }, rest), rippleManagerStore.rippleInfo, /*#__PURE__*/React.createElement(Content, _extends({
211
90
  ref: function ref(dom) {
212
91
  _ref.current = dom;
213
92
  setNodeRef(_ref.current);
@@ -220,149 +99,9 @@ var ViewPortEntity = observer(function (props) {
220
99
  export default function ViewPort(props) {
221
100
  var children = props.children,
222
101
  viewPortStore = props.viewPortStore,
223
- rest = _objectWithoutProperties(props, _excluded);
224
- return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(GlobalStyles, {
225
- $css: []
226
- }), /*#__PURE__*/React.createElement(ViewPortEntity, _extends({
102
+ rest = _objectWithoutProperties(props, _excluded2);
103
+ return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(ViewPortEntity, _extends({
227
104
  viewPortStore: viewPortStore
228
105
  }, rest), children));
229
106
  }
230
- export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
231
- _inherits(ViewPortWindowStore, _WindowStore);
232
- var _super = _createSuper(ViewPortWindowStore);
233
- function ViewPortWindowStore(id, onClosedHandler) {
234
- var _this;
235
- _classCallCheck(this, ViewPortWindowStore);
236
- _this = _super.call(this, id, onClosedHandler);
237
- _defineProperty(_assertThisInitialized(_this), "scale", 1);
238
- makeObservable(_assertThisInitialized(_this), {
239
- style: override,
240
- scale: observable,
241
- controll: override
242
- });
243
- return _this;
244
- }
245
- _createClass(ViewPortWindowStore, [{
246
- key: "style",
247
- get: function get() {
248
- if (this.isClosed) {
249
- return {
250
- left: this.left + 'px',
251
- top: this.top + 'px',
252
- width: this.width + 'px',
253
- height: this.height + 'px',
254
- zIndex: this.zIndex,
255
- transform: 'scale(0)',
256
- transition: 'all 0.5s ease-out'
257
- };
258
- }
259
- if (this.isMinimize && this.minimizePos) {
260
- return {
261
- left: this.minimizePos.left + 'px',
262
- top: this.minimizePos.top + 'px',
263
- width: 0,
264
- height: 0,
265
- zIndex: this.zIndex,
266
- transform: 'scale(0)',
267
- transition: 'all 0.5s ease-out'
268
- };
269
- }
270
- if (this.fullscreen) {
271
- return {
272
- left: this.fullscreenPos.left / this.scale + 'px',
273
- top: this.fullscreenPos.top / this.scale + 'px',
274
- width: this.fullscreenPos.width + 'px',
275
- height: this.fullscreenPos.height + 'px',
276
- zIndex: this.zIndex,
277
- transform: "scale(".concat(1 / this.scale, ") "),
278
- transformOrigin: 'left top',
279
- transition: 'width height 0.5s ease-out'
280
- };
281
- }
282
- if (this.isMoving || this.isResizing) {
283
- return {
284
- left: this.left + 'px',
285
- top: this.top + 'px',
286
- width: this.width + 'px',
287
- height: this.height + 'px',
288
- zIndex: this.zIndex,
289
- transform: 'none',
290
- transition: 'none'
291
- };
292
- }
293
- return {
294
- left: this.left + 'px',
295
- top: this.top + 'px',
296
- width: this.width + 'px',
297
- height: this.height + 'px',
298
- zIndex: this.zIndex,
299
- transform: 'none',
300
- transition: 'all 0.5s ease-out'
301
- };
302
- }
303
- }, {
304
- key: "calculateTransform",
305
- value: function calculateTransform(transform) {
306
- var _this$transform, _this$transform2;
307
- return {
308
- x: (transform.x - (((_this$transform = this.transform) === null || _this$transform === void 0 ? void 0 : _this$transform.x) || 0)) / this.scale,
309
- y: (transform.y - (((_this$transform2 = this.transform) === null || _this$transform2 === void 0 ? void 0 : _this$transform2.y) || 0)) / this.scale
310
- };
311
- }
312
- }, {
313
- key: "controll",
314
- value: function controll(transform, type) {
315
- var offsetTransform = this.calculateTransform(transform);
316
- if (type === 'move') {
317
- this.isMoving = true;
318
- this.isResizing = false;
319
- } else {
320
- this.isMoving = false;
321
- this.isResizing = true;
322
- }
323
- if (type.includes('left')) {
324
- this.left = Math.round(this.left + offsetTransform.x);
325
- this.width = Math.round(this.width - offsetTransform.x);
326
- }
327
- if (type.includes('right')) {
328
- this.width = Math.round(this.width + offsetTransform.x);
329
- }
330
- if (type.includes('top')) {
331
- this.top = Math.round(this.top + offsetTransform.y);
332
- this.height = Math.round(this.height - offsetTransform.y);
333
- }
334
- if (type.includes('bottom')) {
335
- this.height = Math.round(this.height + offsetTransform.y);
336
- }
337
- if (type.includes('move')) {
338
- this.left = Math.round(this.left + offsetTransform.x);
339
- this.top = Math.round(this.top + offsetTransform.y);
340
- }
341
- this.transform = transform;
342
- }
343
- }]);
344
- return ViewPortWindowStore;
345
- }(WindowStore);
346
- ViewPort.Window = observer(function ViewPortWindow(props) {
347
- var viewPortStore = props.viewPortStore,
348
- window = props.window,
349
- rest = _objectWithoutProperties(props, _excluded2);
350
- useEffect(function () {
351
- runInAction(function () {
352
- var transform = viewPortStore.formatedTransform(viewPortStore.transform.left, viewPortStore.transform.top);
353
- window.fullscreenPos.left = -transform.left;
354
- window.fullscreenPos.top = -transform.top;
355
- window.fullscreenPos.width = viewPortStore.width;
356
- window.fullscreenPos.height = viewPortStore.height;
357
- window.scale = viewPortStore.formatedScale;
358
- });
359
- }, [viewPortStore.transform.left, viewPortStore.transform.top, viewPortStore.scale, viewPortStore.ratio, viewPortStore.width, viewPortStore.height]);
360
- return /*#__PURE__*/React.createElement(Window, _extends({
361
- window: window
362
- }, rest, {
363
- onFocusHandler: function onFocusHandler() {
364
- viewPortStore.maxZIndex++;
365
- window.zIndex = viewPortStore.maxZIndex;
366
- }
367
- }));
368
- });
107
+ ViewPort.Window = ViewPortWindow;
@@ -0,0 +1,35 @@
1
+ import { Transform } from '@dnd-kit/utilities';
2
+ import { CSSProperties } from 'react';
3
+ export declare class ViewPortStore {
4
+ transform: {
5
+ left: number;
6
+ top: number;
7
+ };
8
+ offset: {
9
+ x: number;
10
+ y: number;
11
+ };
12
+ scale: number;
13
+ width: number;
14
+ height: number;
15
+ ratio: number;
16
+ isMoving: boolean;
17
+ maxZIndex: number;
18
+ constructor(width?: number, height?: number, ratio?: number);
19
+ get scaleStep(): number;
20
+ increaseScale(): void;
21
+ decreaseScale(): void;
22
+ private validScale;
23
+ private setScale;
24
+ private setTransform;
25
+ get offsetLeft(): number;
26
+ get offsetTop(): number;
27
+ private formatedTransform;
28
+ focus(left: number, top: number): void;
29
+ unfocus(): void;
30
+ move(transform: Transform): void;
31
+ endMove(): void;
32
+ get contentStyle(): CSSProperties;
33
+ get containerStyle(): CSSProperties;
34
+ get info(): string;
35
+ }
@@ -0,0 +1,155 @@
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
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
3
+ 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); } }
4
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
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
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
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 { makeAutoObservable } from 'mobx';
9
+ export var ViewPortStore = /*#__PURE__*/function () {
10
+ function ViewPortStore(width, height, ratio) {
11
+ _classCallCheck(this, ViewPortStore);
12
+ _defineProperty(this, "transform", {
13
+ left: 0,
14
+ top: 0
15
+ });
16
+ _defineProperty(this, "offset", {
17
+ x: 0,
18
+ y: 0
19
+ });
20
+ _defineProperty(this, "scale", 1);
21
+ _defineProperty(this, "width", 600);
22
+ _defineProperty(this, "height", 600);
23
+ _defineProperty(this, "ratio", 5);
24
+ //缩放比例
25
+ _defineProperty(this, "isMoving", false);
26
+ _defineProperty(this, "maxZIndex", 1);
27
+ if (ratio) this.ratio = ratio;
28
+ if (width) this.width = width;
29
+ if (height) this.height = height;
30
+ makeAutoObservable(this);
31
+ }
32
+ _createClass(ViewPortStore, [{
33
+ key: "scaleStep",
34
+ get: function get() {
35
+ return 1 / this.ratio * 0.125;
36
+ }
37
+ }, {
38
+ key: "increaseScale",
39
+ value: function increaseScale() {
40
+ this.setScale(this.scale + this.scaleStep);
41
+ this.setTransform(this.transform.left, this.transform.top);
42
+ }
43
+ }, {
44
+ key: "decreaseScale",
45
+ value: function decreaseScale() {
46
+ this.setScale(this.scale - this.scaleStep);
47
+ this.setTransform(this.transform.left, this.transform.top);
48
+ }
49
+ }, {
50
+ key: "validScale",
51
+ value: function validScale(scale) {
52
+ return Math.min(1, Math.max(1 / this.ratio, scale));
53
+ }
54
+ }, {
55
+ key: "setScale",
56
+ value: function setScale(scale) {
57
+ this.scale = this.validScale(scale);
58
+ }
59
+ }, {
60
+ key: "setTransform",
61
+ value: function setTransform(left, top) {
62
+ this.transform = this.formatedTransform(left, top);
63
+ }
64
+
65
+ /* 这个函数是获取left偏移量 */
66
+ }, {
67
+ key: "offsetLeft",
68
+ get: function get() {
69
+ return (this.width * this.ratio * this.scale - this.width) / 2;
70
+ }
71
+ /* 获取top偏移量 */
72
+ }, {
73
+ key: "offsetTop",
74
+ get: function get() {
75
+ return (this.height * this.ratio * this.scale - this.height) / 2;
76
+ }
77
+ }, {
78
+ key: "formatedTransform",
79
+ value: function formatedTransform(left, top) {
80
+ var areaLimit = {
81
+ left: {
82
+ min: -this.offsetLeft,
83
+ max: this.offsetLeft
84
+ },
85
+ top: {
86
+ min: -this.offsetTop,
87
+ max: this.offsetTop
88
+ }
89
+ };
90
+ return {
91
+ left: Math.max(areaLimit.left.min, Math.min(left, areaLimit.left.max)),
92
+ top: Math.max(areaLimit.top.min, Math.min(top, areaLimit.top.max))
93
+ };
94
+ }
95
+ }, {
96
+ key: "focus",
97
+ value: function focus(left, top) {
98
+ this.setScale(1);
99
+ this.setTransform((1 - this.ratio) * left + this.offsetLeft, (1 - this.ratio) * top + this.offsetTop);
100
+ }
101
+ }, {
102
+ key: "unfocus",
103
+ value: function unfocus() {
104
+ this.setScale(1 / this.ratio);
105
+ this.setTransform(0, 0);
106
+ }
107
+ }, {
108
+ key: "move",
109
+ value: function move(transform) {
110
+ this.isMoving = true;
111
+ var calculateLeft = transform.x - this.offset.x + this.transform.left;
112
+ var calculateTop = transform.y - this.offset.y + this.transform.top;
113
+ this.setTransform(calculateLeft, calculateTop);
114
+ this.offset.x = transform.x;
115
+ this.offset.y = transform.y;
116
+ }
117
+ }, {
118
+ key: "endMove",
119
+ value: function endMove() {
120
+ this.offset.x = 0;
121
+ this.offset.y = 0;
122
+ this.isMoving = false;
123
+ }
124
+ }, {
125
+ key: "contentStyle",
126
+ get: function get() {
127
+ return {
128
+ left: -this.offsetLeft,
129
+ top: -this.offsetTop,
130
+ transform: " translate(".concat(this.transform.left, "px,").concat(this.transform.top, "px) scale(").concat(this.scale, ")"),
131
+ width: this.width * this.ratio + 'px',
132
+ height: this.height * this.ratio + 'px',
133
+ transformOrigin: 'left top',
134
+ transition: this.isMoving ? 'none' : 'all 0.5s',
135
+ background: '#188fff67',
136
+ cursor: this.isMoving ? 'grab' : 'default'
137
+ };
138
+ }
139
+ }, {
140
+ key: "containerStyle",
141
+ get: function get() {
142
+ return {
143
+ width: this.width + 'px',
144
+ height: this.height + 'px',
145
+ overflow: 'hidden'
146
+ };
147
+ }
148
+ }, {
149
+ key: "info",
150
+ get: function get() {
151
+ return JSON.stringify(this.formatedTransform(this.transform.left, this.transform.top), null, 4);
152
+ }
153
+ }]);
154
+ return ViewPortStore;
155
+ }();
@@ -0,0 +1,47 @@
1
+ import { Transform } from '@dnd-kit/utilities';
2
+ import React from 'react';
3
+ import { WindowStore } from '../Window';
4
+ import { WindowProps } from '../Window/Window';
5
+ import { WindowControllerType } from '../Window/WindowController';
6
+ import { ViewPortStore } from './ViewPortStore';
7
+ export declare class ViewPortWindowStore extends WindowStore {
8
+ scale: number;
9
+ get style(): {
10
+ left: string;
11
+ top: string;
12
+ width: string;
13
+ height: string;
14
+ zIndex: number;
15
+ transform: string;
16
+ transition: string;
17
+ transformOrigin?: undefined;
18
+ } | {
19
+ left: string;
20
+ top: string;
21
+ width: number;
22
+ height: number;
23
+ zIndex: number;
24
+ transform: string;
25
+ transition: string;
26
+ transformOrigin?: undefined;
27
+ } | {
28
+ left: string;
29
+ top: string;
30
+ width: string;
31
+ height: string;
32
+ zIndex: number;
33
+ transform: string;
34
+ transformOrigin: string;
35
+ transition: string;
36
+ };
37
+ calculateTransform(transform: Transform): {
38
+ x: number;
39
+ y: number;
40
+ };
41
+ controll(transform: Transform, type: WindowControllerType): void;
42
+ constructor(id: string, onClosedHandler?: (id: string) => void);
43
+ }
44
+ export declare const ViewPortWindow: React.FunctionComponent<WindowProps & {
45
+ viewPortStore: ViewPortStore;
46
+ window: ViewPortWindowStore;
47
+ }>;
@@ -0,0 +1,165 @@
1
+ var _excluded = ["viewPortStore", "window"];
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 _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
+ function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; }
5
+ function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
6
+ function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
7
+ 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); } }
8
+ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
9
+ function _inherits(subClass, superClass) { if (typeof superClass !== "function" && superClass !== null) { throw new TypeError("Super expression must either be null or a function"); } subClass.prototype = Object.create(superClass && superClass.prototype, { constructor: { value: subClass, writable: true, configurable: true } }); Object.defineProperty(subClass, "prototype", { writable: false }); if (superClass) _setPrototypeOf(subClass, superClass); }
10
+ function _setPrototypeOf(o, p) { _setPrototypeOf = Object.setPrototypeOf ? Object.setPrototypeOf.bind() : function _setPrototypeOf(o, p) { o.__proto__ = p; return o; }; return _setPrototypeOf(o, p); }
11
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
12
+ function _possibleConstructorReturn(self, call) { if (call && (_typeof(call) === "object" || typeof call === "function")) { return call; } else if (call !== void 0) { throw new TypeError("Derived constructors may only return object or undefined"); } return _assertThisInitialized(self); }
13
+ function _assertThisInitialized(self) { if (self === void 0) { throw new ReferenceError("this hasn't been initialised - super() hasn't been called"); } return self; }
14
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
15
+ function _getPrototypeOf(o) { _getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf.bind() : function _getPrototypeOf(o) { return o.__proto__ || Object.getPrototypeOf(o); }; return _getPrototypeOf(o); }
16
+ function _defineProperty(obj, key, value) { key = _toPropertyKey(key); if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; }
17
+ function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
18
+ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
19
+ import { makeObservable, observable, override, runInAction } from 'mobx';
20
+ import { observer } from 'mobx-react-lite';
21
+ import React, { useEffect } from 'react';
22
+ import { WindowStore } from "../Window";
23
+ import { default as Window } from "../Window/Window";
24
+ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
25
+ _inherits(ViewPortWindowStore, _WindowStore);
26
+ var _super = _createSuper(ViewPortWindowStore);
27
+ function ViewPortWindowStore(id, onClosedHandler) {
28
+ var _this;
29
+ _classCallCheck(this, ViewPortWindowStore);
30
+ _this = _super.call(this, id, onClosedHandler);
31
+ _defineProperty(_assertThisInitialized(_this), "scale", 1);
32
+ makeObservable(_assertThisInitialized(_this), {
33
+ style: override,
34
+ scale: observable,
35
+ controll: override
36
+ });
37
+ return _this;
38
+ }
39
+ _createClass(ViewPortWindowStore, [{
40
+ key: "style",
41
+ get: function get() {
42
+ if (this.isClosed) {
43
+ return {
44
+ left: this.left + 'px',
45
+ top: this.top + 'px',
46
+ width: this.width + 'px',
47
+ height: this.height + 'px',
48
+ zIndex: this.zIndex,
49
+ transform: 'scale(0)',
50
+ transition: 'all 0.5s ease-out'
51
+ };
52
+ }
53
+ if (this.isMinimize && this.minimizePos) {
54
+ return {
55
+ left: this.minimizePos.left + 'px',
56
+ top: this.minimizePos.top + 'px',
57
+ width: 0,
58
+ height: 0,
59
+ zIndex: this.zIndex,
60
+ transform: 'scale(0)',
61
+ transition: 'all 0.5s ease-out'
62
+ };
63
+ }
64
+ if (this.fullscreen) {
65
+ return {
66
+ left: this.fullscreenPos.left / this.scale + 'px',
67
+ top: this.fullscreenPos.top / this.scale + 'px',
68
+ width: this.fullscreenPos.width + 'px',
69
+ height: this.fullscreenPos.height + 'px',
70
+ zIndex: this.zIndex,
71
+ transform: "scale(".concat(1 / this.scale, ") "),
72
+ transformOrigin: 'left top',
73
+ transition: 'width height 0.5s ease-out'
74
+ };
75
+ }
76
+ if (this.isMoving || this.isResizing) {
77
+ return {
78
+ left: this.left + 'px',
79
+ top: this.top + 'px',
80
+ width: this.width + 'px',
81
+ height: this.height + 'px',
82
+ zIndex: this.zIndex,
83
+ transform: 'none',
84
+ transition: 'none'
85
+ };
86
+ }
87
+ return {
88
+ left: this.left + 'px',
89
+ top: this.top + 'px',
90
+ width: this.width + 'px',
91
+ height: this.height + 'px',
92
+ zIndex: this.zIndex,
93
+ transform: 'none',
94
+ transition: 'all 0.5s ease-out'
95
+ };
96
+ }
97
+ }, {
98
+ key: "calculateTransform",
99
+ value: function calculateTransform(transform) {
100
+ var _this$transform, _this$transform2;
101
+ return {
102
+ x: (transform.x - (((_this$transform = this.transform) === null || _this$transform === void 0 ? void 0 : _this$transform.x) || 0)) / this.scale,
103
+ y: (transform.y - (((_this$transform2 = this.transform) === null || _this$transform2 === void 0 ? void 0 : _this$transform2.y) || 0)) / this.scale
104
+ };
105
+ }
106
+ }, {
107
+ key: "controll",
108
+ value: function controll(transform, type) {
109
+ var offsetTransform = this.calculateTransform(transform);
110
+ if (type === 'move') {
111
+ this.isMoving = true;
112
+ this.isResizing = false;
113
+ } else {
114
+ this.isMoving = false;
115
+ this.isResizing = true;
116
+ }
117
+ if (type.includes('left')) {
118
+ this.left = Math.round(this.left + offsetTransform.x);
119
+ this.width = Math.round(this.width - offsetTransform.x);
120
+ }
121
+ if (type.includes('right')) {
122
+ this.width = Math.round(this.width + offsetTransform.x);
123
+ }
124
+ if (type.includes('top')) {
125
+ this.top = Math.round(this.top + offsetTransform.y);
126
+ this.height = Math.round(this.height - offsetTransform.y);
127
+ }
128
+ if (type.includes('bottom')) {
129
+ this.height = Math.round(this.height + offsetTransform.y);
130
+ }
131
+ if (type.includes('move')) {
132
+ this.left = Math.round(this.left + offsetTransform.x);
133
+ this.top = Math.round(this.top + offsetTransform.y);
134
+ }
135
+ this.transform = transform;
136
+ }
137
+ }]);
138
+ return ViewPortWindowStore;
139
+ }(WindowStore);
140
+ export var ViewPortWindow = observer(function ViewPortWindow(props) {
141
+ var viewPortStore = props.viewPortStore,
142
+ window = props.window,
143
+ rest = _objectWithoutProperties(props, _excluded);
144
+ useEffect(function () {
145
+ runInAction(function () {
146
+ window.fullscreenPos.left = -viewPortStore.transform.left + viewPortStore.offsetLeft;
147
+ window.fullscreenPos.top = -viewPortStore.transform.top + viewPortStore.offsetTop;
148
+ window.fullscreenPos.width = viewPortStore.width;
149
+ window.fullscreenPos.height = viewPortStore.height;
150
+ window.scale = viewPortStore.scale;
151
+ });
152
+ }, [viewPortStore.transform.left, viewPortStore.transform.top, viewPortStore.scale, viewPortStore.ratio, viewPortStore.width, viewPortStore.height]);
153
+ useEffect(function () {
154
+ window.left = (viewPortStore.width * viewPortStore.ratio - viewPortStore.width) / 2;
155
+ window.top = (viewPortStore.width * viewPortStore.ratio - viewPortStore.width) / 2;
156
+ }, []);
157
+ return /*#__PURE__*/React.createElement(Window, _extends({
158
+ window: window
159
+ }, rest, {
160
+ onFocusHandler: function onFocusHandler() {
161
+ viewPortStore.maxZIndex++;
162
+ window.zIndex = viewPortStore.maxZIndex;
163
+ }
164
+ }));
165
+ });
@@ -1 +1,2 @@
1
- export { default as ViewPort, ViewPortStore } from './ViewPort';
1
+ export { default as ViewPort } from './ViewPort';
2
+ export { ViewPortStore } from './ViewPortStore';
@@ -1 +1,2 @@
1
- export { default as ViewPort, ViewPortStore } from "./ViewPort";
1
+ export { default as ViewPort } from "./ViewPort";
2
+ export { ViewPortStore } from "./ViewPortStore";
@@ -8,7 +8,11 @@ function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e
8
8
  import { makeAutoObservable, runInAction } from 'mobx';
9
9
  import { observer, useLocalObservable } from 'mobx-react-lite';
10
10
  import React, { useEffect } from 'react';
11
- import ViewPort, { ViewPortStore, ViewPortWindowStore } from "./ViewPort";
11
+ import styled from 'styled-components';
12
+ import { GlobalStyles } from '..';
13
+ import ViewPort from "./ViewPort";
14
+ import { ViewPortStore } from "./ViewPortStore";
15
+ import { ViewPortWindowStore } from "./ViewPortWindow";
12
16
  var WindowManager = /*#__PURE__*/function () {
13
17
  function WindowManager() {
14
18
  _classCallCheck(this, WindowManager);
@@ -33,15 +37,19 @@ var WindowManager = /*#__PURE__*/function () {
33
37
  return WindowManager;
34
38
  }();
35
39
  var windowManager = new WindowManager();
40
+ var StyledViewPort = styled(ViewPort).withConfig({
41
+ displayName: "StyledViewPort",
42
+ componentId: "basic-component-347b__sc-1b1xrkc-0"
43
+ })(["border:1px solid #eee;"]);
36
44
  export default observer(function Test() {
37
45
  var viewPortStore = useLocalObservable(function () {
38
- return new ViewPortStore(600, 600, 5);
46
+ return new ViewPortStore(600, 600, 2);
39
47
  });
40
48
  useEffect(function () {
41
49
  function setWidthHeight() {
42
50
  runInAction(function () {
43
- viewPortStore.width = 800;
44
- viewPortStore.height = 800;
51
+ viewPortStore.width = 600;
52
+ viewPortStore.height = 600;
45
53
  });
46
54
  }
47
55
  window.addEventListener('resize', setWidthHeight);
@@ -50,7 +58,9 @@ export default observer(function Test() {
50
58
  window.removeEventListener('resize', setWidthHeight);
51
59
  };
52
60
  }, []);
53
- return /*#__PURE__*/React.createElement(ViewPort, {
61
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(GlobalStyles, {
62
+ $css: []
63
+ }), /*#__PURE__*/React.createElement(StyledViewPort, {
54
64
  viewPortStore: viewPortStore
55
65
  }, windowManager.windows.map(function (windowStore) {
56
66
  return /*#__PURE__*/React.createElement(ViewPort.Window, {
@@ -59,5 +69,5 @@ export default observer(function Test() {
59
69
  title: 'xixi',
60
70
  viewPortStore: viewPortStore
61
71
  }, /*#__PURE__*/React.createElement("br", null));
62
- }));
72
+ })));
63
73
  });
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "0.0.39",
3
+ "version": "0.0.41",
4
4
  "description": "A react library developed with dumi",
5
5
  "license": "MIT",
6
6
  "module": "dist/index.js",
@@ -47,7 +47,7 @@
47
47
  },
48
48
  "dependencies": {
49
49
  "@ant-design/icons": "^5.3.7",
50
- "@kep-platform/hooks": "^0.0.39",
50
+ "@kep-platform/hooks": "^0.0.41",
51
51
  "color": "^4.2.3",
52
52
  "rc-pagination": "^4.1.0",
53
53
  "styled-components": "^6.1.11"
@@ -87,5 +87,5 @@
87
87
  "authors": [
88
88
  "lee-step-jss 1599925910@qq.com"
89
89
  ],
90
- "gitHead": "4182b7887a19c0ab23c6cdc0084b83cd102c0418"
90
+ "gitHead": "05f330f339c2445ce3234da33d78d1e6f64891c6"
91
91
  }