@kep-platform/basic-component 1.0.20 → 1.0.22

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.
@@ -192,15 +192,15 @@ export var TreeNodeController = observer(function (_ref) {
192
192
  } else {
193
193
  //如果有loadData则触发。
194
194
  if (loadData && !loaded) {
195
+ onExpand(expandedKeys.concat([node[fieldNames.key]]), {
196
+ nativeEvent: e,
197
+ node: node,
198
+ expanded: !expanded
199
+ });
195
200
  setLoading(true);
196
201
  loadData(node).then(function () {
197
202
  setLoading(false);
198
203
  setLoadedKeys(loadedKeys.concat([node[fieldNames.key]]));
199
- onExpand(expandedKeys.concat([node[fieldNames.key]]), {
200
- nativeEvent: e,
201
- node: node,
202
- expanded: !expanded
203
- });
204
204
  }, function () {
205
205
  setLoading(false);
206
206
  });
@@ -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,7 +59,7 @@ 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',
62
+ transformOrigin: 'center',
59
63
  transition: 'all 0.3s ease-out'
60
64
  };
61
65
  case 'minimize':
@@ -78,7 +82,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
78
82
  transform: "scale(".concat(1 / this.viewPortStore.scale, ")"),
79
83
  zIndex: this.zIndex,
80
84
  transformOrigin: 'left top',
81
- transition: 'width height 0.5s ease-out'
85
+ transition: 'all 0.3s ease-out'
82
86
  };
83
87
  case 'normal':
84
88
  default:
@@ -125,8 +129,8 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
125
129
  };
126
130
  }
127
131
  }, {
128
- key: "controll",
129
- value: function controll(transform, type) {
132
+ key: "control",
133
+ value: function control(transform, type) {
130
134
  var offsetTransform = this.calculateTransform(transform);
131
135
  if (type === 'move') {
132
136
  this.isMoving = true;
@@ -154,6 +158,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
154
158
  this.top = Math.round(this.top + offsetTransform.y);
155
159
  }
156
160
  this.transform = transform;
161
+ this.enforceBounds();
157
162
  }
158
163
  }, {
159
164
  key: "centerDisplay",
@@ -162,6 +167,7 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
162
167
  var rect = this.viewPortStore.viewPortRect;
163
168
  this.left = rect.left + Math.max(0, rect.width - this.width) / 2;
164
169
  this.top = rect.top + Math.max(0, rect.height - this.height) / 2;
170
+ this.enforceBounds();
165
171
  }
166
172
  }, {
167
173
  key: "fullscreenWindow",
@@ -209,6 +215,30 @@ export var ViewPortWindowStore = /*#__PURE__*/function (_WindowStore) {
209
215
  this.top = 0;
210
216
  this.width = this.calculatePercentageValue(arr[index], this.viewPortStore.viewPortRect.width);
211
217
  this.height = this.viewPortStore.viewPortRect.height;
218
+ this.enforceBounds();
219
+ }
220
+
221
+ // 边界约束方法
222
+ }, {
223
+ key: "enforceBounds",
224
+ value: function enforceBounds() {
225
+ // 如果允许超出则不做任何约束
226
+ if (this.allowOverflow) return;
227
+ var rect = this.viewPortStore.viewPortRect;
228
+ var minWidth = 50;
229
+ var minHeight = 50;
230
+
231
+ // 限制尺寸不会超过 viewport
232
+ if (this.width > rect.width) this.width = rect.width;
233
+ if (this.height > rect.height) this.height = rect.height;
234
+
235
+ // 限制最小尺寸
236
+ this.width = Math.max(this.width, minWidth);
237
+ this.height = Math.max(this.height, minHeight);
238
+
239
+ // 限制位置在 viewport 内
240
+ this.left = Math.max(rect.left, Math.min(this.left, rect.left + rect.width - this.width));
241
+ this.top = Math.max(rect.top, Math.min(this.top, rect.top + rect.height - this.height));
212
242
  }
213
243
  }, {
214
244
  key: "disabled",
@@ -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"])));
@@ -168,6 +168,7 @@ var Window = observer(function (props) {
168
168
  e.stopPropagation();
169
169
  }
170
170
  }, /*#__PURE__*/React.createElement(WindowOption, {
171
+ "aria-label": "\u5206\u4EAB\u7A97\u53E3",
171
172
  icon: /*#__PURE__*/React.createElement(ShareAltOutlined, null),
172
173
  onClick: onShareWindow
173
174
  }), 'viewPortStore' in window && window.viewPortStore && /*#__PURE__*/React.createElement(Popover, {
@@ -184,30 +185,31 @@ var Window = observer(function (props) {
184
185
  }, /*#__PURE__*/React.createElement(WindowOption, {
185
186
  icon: /*#__PURE__*/React.createElement(SplitCellsOutlined, null)
186
187
  })), /*#__PURE__*/React.createElement(WindowOption, {
188
+ "aria-label": "\u6700\u5C0F\u5316\u7A97\u53E3",
187
189
  icon: /*#__PURE__*/React.createElement(MinusOutlined, null),
188
190
  onClick: function onClick() {
189
191
  if (window.disabled) return;
190
192
  window.minimizeWindow();
191
193
  }
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),
194
+ }), /*#__PURE__*/React.createElement(WindowOption, {
195
+ "aria-label": window.fullscreen ? '退出全屏' : '进入全屏',
196
+ icon: window.fullscreen ? /*#__PURE__*/React.createElement(CompressOutlined, null) : /*#__PURE__*/React.createElement(BorderOutlined, null),
200
197
  onClick: function onClick() {
201
198
  if (window.disabled) return;
202
- window.fullscreenExitWindow();
199
+ if (window.fullscreen) {
200
+ window.fullscreenExitWindow();
201
+ } else {
202
+ window.fullscreenWindow(onFullscreenHandler);
203
+ }
203
204
  }
204
205
  }), /*#__PURE__*/React.createElement(WindowOption, {
206
+ "aria-label": "\u5173\u95ED\u7A97\u53E3",
207
+ icon: /*#__PURE__*/React.createElement(CloseOutlined, null),
208
+ danger: true,
205
209
  onClick: function onClick() {
206
210
  if (window.disabled) return;
207
211
  window.closeWindow();
208
- },
209
- icon: /*#__PURE__*/React.createElement(CloseOutlined, null),
210
- danger: true
212
+ }
211
213
  })))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
212
214
  });
213
215
  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, {
@@ -40,8 +40,8 @@ export default class WindowStore {
40
40
  x: number;
41
41
  y: number;
42
42
  };
43
- controll(transform: Transform, type: WindowControllerType): void;
44
- endControll(): void;
43
+ control(transform: Transform, type: WindowControllerType): void;
44
+ endControl(): void;
45
45
  minimizeWindow(): void;
46
46
  normalizeWindow(): void;
47
47
  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);
@@ -48,8 +48,8 @@ var WindowStore = /*#__PURE__*/function () {
48
48
  isClosed: observable,
49
49
  fullscreenExitWindow: action,
50
50
  fullscreenWindow: action,
51
- controll: action,
52
- endControll: action,
51
+ control: action,
52
+ endControl: action,
53
53
  style: computed.struct,
54
54
  isMinimize: observable,
55
55
  minimizePos: observable.struct,
@@ -62,7 +62,8 @@ var WindowStore = /*#__PURE__*/function () {
62
62
  focus: action,
63
63
  info: computed,
64
64
  disabled: computed,
65
- splitPanelVisible: observable
65
+ splitPanelVisible: observable,
66
+ onSplitWindowHandler: action
66
67
  });
67
68
  this.id = id;
68
69
  this.onClosedHandler = onClosedHandler;
@@ -101,37 +102,34 @@ var WindowStore = /*#__PURE__*/function () {
101
102
  };
102
103
  }
103
104
  }, {
104
- key: "controll",
105
- value: function controll(transform, type) {
106
- var _this = this;
105
+ key: "control",
106
+ value: function control(transform, type) {
107
107
  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
- });
108
+ this.isMoving = type === 'move';
109
+ this.isResizing = type !== 'move';
110
+ if (type.includes('left')) {
111
+ this.left = Math.round(this.left + offsetTransform.x);
112
+ this.width = Math.round(this.width - offsetTransform.x);
113
+ }
114
+ if (type.includes('right')) {
115
+ this.width = Math.round(this.width + offsetTransform.x);
116
+ }
117
+ if (type.includes('top')) {
118
+ this.top = Math.round(this.top + offsetTransform.y);
119
+ this.height = Math.round(this.height - offsetTransform.y);
120
+ }
121
+ if (type.includes('bottom')) {
122
+ this.height = Math.round(this.height + offsetTransform.y);
123
+ }
124
+ if (type.includes('move')) {
125
+ this.left = Math.round(this.left + offsetTransform.x);
126
+ this.top = Math.round(this.top + offsetTransform.y);
127
+ }
128
+ this.transform = transform;
131
129
  }
132
130
  }, {
133
- key: "endControll",
134
- value: function endControll() {
131
+ key: "endControl",
132
+ value: function endControl() {
135
133
  this.isMoving = false;
136
134
  this.isResizing = false;
137
135
  this.resetState();
@@ -167,6 +165,7 @@ var WindowStore = /*#__PURE__*/function () {
167
165
  key: "focus",
168
166
  value: function focus() {
169
167
  this.zIndex++;
168
+ this.isMinimize = false;
170
169
  }
171
170
  }, {
172
171
  key: "calculatePercentageValue",
@@ -178,12 +177,12 @@ var WindowStore = /*#__PURE__*/function () {
178
177
  }, {
179
178
  key: "onSplitWindowHandler",
180
179
  value: function onSplitWindowHandler(arr, index) {
181
- var _this2 = this;
180
+ var _this = this;
182
181
  this.restoreWindow();
183
182
  this.splitPanelVisible = false;
184
183
  var leftPieces = arr.slice(0, index);
185
184
  var leftWidth = leftPieces.reduce(function (acc, cur) {
186
- return acc + _this2.calculatePercentageValue(cur, _this2.fullscreenPos.width);
185
+ return acc + _this.calculatePercentageValue(cur, _this.fullscreenPos.width);
187
186
  }, 0);
188
187
  this.left = leftWidth;
189
188
  this.top = 0;
@@ -224,7 +223,7 @@ var WindowStore = /*#__PURE__*/function () {
224
223
  left: this.minimizePos.left + 'px',
225
224
  top: this.minimizePos.top + 'px',
226
225
  width: this.width + 'px',
227
- height: this.width + 'px',
226
+ height: this.height + 'px',
228
227
  zIndex: this.zIndex,
229
228
  transform: 'scale(0)',
230
229
  transformOrigin: 'left top',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kep-platform/basic-component",
3
- "version": "1.0.20",
3
+ "version": "1.0.22",
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": "111251d1ba815452a258dd87095534e1a783cf7f"
90
+ "gitHead": "15bac3be22032d6bc72a3d08502801bf3d1d5901"
91
91
  }