@kep-platform/basic-component 0.0.29 → 0.0.32

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,6 @@
1
+ import React, { ReactNode } from 'react';
2
+ type DraggableProps = {
3
+ children: ReactNode;
4
+ };
5
+ export default function Draggable(props: DraggableProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,34 @@
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 _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); }
3
+ 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; }
4
+ 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; }
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 { useDraggable } from '@dnd-kit/core';
9
+ import React from 'react';
10
+ export default function Draggable(props) {
11
+ var _useDraggable = useDraggable({
12
+ id: 'draggable'
13
+ }),
14
+ attributes = _useDraggable.attributes,
15
+ listeners = _useDraggable.listeners,
16
+ setNodeRef = _useDraggable.setNodeRef,
17
+ setActivatorNodeRef = _useDraggable.setActivatorNodeRef,
18
+ transform = _useDraggable.transform;
19
+ var style = transform ? {
20
+ transform: "translate3d(".concat(transform.x, "px, ").concat(transform.y, "px, 0)")
21
+ } : undefined;
22
+ return /*#__PURE__*/React.createElement("div", {
23
+ style: _objectSpread({
24
+ width: '200px',
25
+ height: '200px',
26
+ backgroundColor: 'pink'
27
+ }, style),
28
+ ref: setNodeRef
29
+ }, /*#__PURE__*/React.createElement("button", _extends({
30
+ type: "button"
31
+ }, listeners, attributes, {
32
+ ref: setActivatorNodeRef
33
+ }), props.children));
34
+ }
@@ -0,0 +1,6 @@
1
+ import React, { ReactNode } from 'react';
2
+ type DroppableProps = {
3
+ children: ReactNode;
4
+ };
5
+ export default function Droppable(props: DroppableProps): React.JSX.Element;
6
+ export {};
@@ -0,0 +1,16 @@
1
+ import { useDroppable } from '@dnd-kit/core';
2
+ import React from 'react';
3
+ export default function Droppable(props) {
4
+ var _useDroppable = useDroppable({
5
+ id: 'droppable'
6
+ }),
7
+ isOver = _useDroppable.isOver,
8
+ setNodeRef = _useDroppable.setNodeRef;
9
+ var style = {
10
+ color: isOver ? 'green' : undefined
11
+ };
12
+ return /*#__PURE__*/React.createElement("div", {
13
+ ref: setNodeRef,
14
+ style: style
15
+ }, props.children);
16
+ }
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: () => React.JSX.Element;
3
+ export default _default;
@@ -0,0 +1,13 @@
1
+ import { DndContext } from '@dnd-kit/core';
2
+ import React from 'react';
3
+ import Draggable from "./Draggable";
4
+ import Droppable from "./Droppable";
5
+ export default (function () {
6
+ return /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(DndContext, {
7
+ onDragStart: function onDragStart() {}
8
+ }, /*#__PURE__*/React.createElement(DndContext, {
9
+ onDragEnd: function onDragEnd() {}
10
+ }, /*#__PURE__*/React.createElement(Draggable, null, "123"), /*#__PURE__*/React.createElement(Droppable, null, "456")), /*#__PURE__*/React.createElement(DndContext, {
11
+ onDragEnd: function onDragEnd() {}
12
+ }, /*#__PURE__*/React.createElement(Draggable, null, "123"), /*#__PURE__*/React.createElement(Droppable, null, "456"))));
13
+ });
package/dist/Grid/Row.js CHANGED
@@ -47,7 +47,6 @@ var Row = function Row(props) {
47
47
  return child;
48
48
  }
49
49
  } else {
50
- console.warn('行组件内部只能渲染列组件');
51
50
  return false;
52
51
  }
53
52
  }));
@@ -77,6 +77,6 @@ export function Popup(props) {
77
77
  visible: visible,
78
78
  ref: popupBox
79
79
  }, content), /*#__PURE__*/React.cloneElement(children, mergeProps));
80
- } else console.warn('PopupMenu需要一个触发元素!');
80
+ }
81
81
  }
82
82
  export default PopupBox;
package/dist/Tree/Tree.js CHANGED
@@ -71,7 +71,6 @@ var Tree = observer(function (_ref) {
71
71
  multiple = _ref$multiple === void 0 ? false : _ref$multiple,
72
72
  _ref$bordered = _ref.bordered,
73
73
  bordered = _ref$bordered === void 0 ? false : _ref$bordered;
74
- console.log('tree render...');
75
74
  var rootNode = useMemo(function () {
76
75
  return _defineProperty(_defineProperty(_defineProperty({}, fieldNames.key, 'root'), "nodeType", nodeTypeMap.virtual), "children", treeData);
77
76
  }, [treeData]);
@@ -117,7 +117,6 @@ export var TreeNodeController = observer(function (_ref) {
117
117
  onContextMenuItemSelect = _ref.onContextMenuItemSelect,
118
118
  titleRender = _ref.titleRender;
119
119
  /* 处理子节点缩进 */
120
- console.log('treeNode render');
121
120
  var childLevel = useMemo(function () {
122
121
  return level + 1;
123
122
  }, [level]);
@@ -0,0 +1,15 @@
1
+ import React, { ReactNode } from 'react';
2
+ import WindowStore from './WindowStore';
3
+ export type WindowProps = {
4
+ window: WindowStore;
5
+ children: ReactNode;
6
+ title: ReactNode;
7
+ minimizePos?: {
8
+ left: number;
9
+ top: number;
10
+ };
11
+ };
12
+ declare const Window: ((props: WindowProps) => React.JSX.Element) & {
13
+ displayName: string;
14
+ };
15
+ export default Window;
@@ -0,0 +1,152 @@
1
+ import { CloseCircleOutlined, FullscreenExitOutlined, FullscreenOutlined, MinusCircleOutlined } from '@ant-design/icons';
2
+ import { observer } from 'mobx-react-lite';
3
+ import React from 'react';
4
+ import styled, { css } from 'styled-components';
5
+ import { Space } from "../Space";
6
+ import WindowController from "./WindowController";
7
+ import WindowOption from "./WindowOption";
8
+ var WindowContainer = styled.div.withConfig({
9
+ shouldForwardProp: function shouldForwardProp(prop) {
10
+ return !['isMinimize'].includes(prop);
11
+ }
12
+ }).withConfig({
13
+ displayName: "WindowContainer",
14
+ componentId: "basic-component-347b__sc-7yonmq-0"
15
+ })(["box-shadow:var(--kep-platform-box-shadow);position:absolute;padding:", ";border-radius:4px;background-color:#fff;overflow:hidden;"], function (props) {
16
+ return props.isMinimize ? '0px' : '6px';
17
+ });
18
+ var WindowEntity = styled.div.withConfig({
19
+ displayName: "WindowEntity",
20
+ componentId: "basic-component-347b__sc-7yonmq-1"
21
+ })(["width:100%;height:100%;"]);
22
+ var WindowHeader = styled.div.withConfig({
23
+ shouldForwardProp: function shouldForwardProp(prop) {
24
+ return !['isDragging'].includes(prop);
25
+ }
26
+ }).withConfig({
27
+ displayName: "WindowHeader",
28
+ componentId: "basic-component-347b__sc-7yonmq-2"
29
+ })(["height:40px;padding:6px;border-radius:4px;line-height:26px;font-size:16px;background-color:var(--kep-platform-color-primary);transition:margin 0.35s,opacity 0.7s,box-shadow 0.7s;position:relative;color:#fff;cursor:move;& > h5{color:#fff;}&:hover{opacity:0.9;}", ""], function (props) {
30
+ if (props.isDragging) {
31
+ return css(["margin:0 4px;"]);
32
+ }
33
+ });
34
+ var WindowHeaderOptions = styled.div.withConfig({
35
+ displayName: "WindowHeaderOptions",
36
+ componentId: "basic-component-347b__sc-7yonmq-3"
37
+ })(["position:absolute;right:6px;top:6px;"]);
38
+ var WindowBody = styled.div.withConfig({
39
+ displayName: "WindowBody",
40
+ componentId: "basic-component-347b__sc-7yonmq-4"
41
+ })(["overflow:auto;padding:12px;"]);
42
+ var WindowControllerLeft = styled(WindowController).withConfig({
43
+ displayName: "WindowControllerLeft",
44
+ componentId: "basic-component-347b__sc-7yonmq-5"
45
+ })(["position:absolute;width:6px;left:0;top:0;bottom:0;cursor:e-resize;"]);
46
+ var WindowControllerRight = styled(WindowController).withConfig({
47
+ displayName: "WindowControllerRight",
48
+ componentId: "basic-component-347b__sc-7yonmq-6"
49
+ })(["position:absolute;width:6px;height:100%;right:0;top:0;bottom:0;cursor:e-resize;"]);
50
+ var WindowControllerTop = styled(WindowController).withConfig({
51
+ displayName: "WindowControllerTop",
52
+ componentId: "basic-component-347b__sc-7yonmq-7"
53
+ })(["position:absolute;width:100%;height:6px;left:0;right:0;top:0;cursor:n-resize;"]);
54
+ var WindowControllerBottom = styled(WindowController).withConfig({
55
+ displayName: "WindowControllerBottom",
56
+ componentId: "basic-component-347b__sc-7yonmq-8"
57
+ })(["position:absolute;width:100%;height:6px;left:0;right:0;bottom:0;cursor:n-resize;"]);
58
+ var WindowControllerLeftTop = styled(WindowController).withConfig({
59
+ displayName: "WindowControllerLeftTop",
60
+ componentId: "basic-component-347b__sc-7yonmq-9"
61
+ })(["position:absolute;width:6px;height:6px;left:0;top:0;cursor:nwse-resize;"]);
62
+ var WindowControllerLeftBottom = styled(WindowController).withConfig({
63
+ displayName: "WindowControllerLeftBottom",
64
+ componentId: "basic-component-347b__sc-7yonmq-10"
65
+ })(["position:absolute;width:6px;height:6px;left:0;bottom:0;cursor:nesw-resize;"]);
66
+ var WindowControllerRightTop = styled(WindowController).withConfig({
67
+ displayName: "WindowControllerRightTop",
68
+ componentId: "basic-component-347b__sc-7yonmq-11"
69
+ })(["position:absolute;width:6px;height:6px;right:0;top:0;cursor:nesw-resize;"]);
70
+ var WindowControllerRightBottom = styled(WindowController).withConfig({
71
+ displayName: "WindowControllerRightBottom",
72
+ componentId: "basic-component-347b__sc-7yonmq-12"
73
+ })(["position:absolute;width:6px;height:6px;right:0;bottom:0;cursor:nwse-resize;"]);
74
+ var Window = observer(function (props) {
75
+ var window = props.window,
76
+ title = props.title,
77
+ children = props.children,
78
+ _props$minimizePos = props.minimizePos,
79
+ minimizePos = _props$minimizePos === void 0 ? {
80
+ left: 0,
81
+ top: 0
82
+ } : _props$minimizePos;
83
+ /* style 的原因是因为性能问题 */
84
+ return /*#__PURE__*/React.createElement(WindowContainer, {
85
+ style: window.style,
86
+ isMinimize: !!window.isMinimize,
87
+ onTransitionEnd: function onTransitionEnd(e) {
88
+ if (e.target === e.currentTarget && window.isClosed && e.nativeEvent.propertyName === 'transform') {
89
+ var _window$onClosedHandl;
90
+ (_window$onClosedHandl = window.onClosedHandler) === null || _window$onClosedHandl === void 0 || _window$onClosedHandl.call(window, window.id);
91
+ }
92
+ }
93
+ }, /*#__PURE__*/React.createElement(WindowControllerLeft, {
94
+ window: window,
95
+ type: "left"
96
+ }), /*#__PURE__*/React.createElement(WindowControllerRight, {
97
+ window: window,
98
+ type: "right"
99
+ }), /*#__PURE__*/React.createElement(WindowControllerTop, {
100
+ window: window,
101
+ type: "top"
102
+ }), /*#__PURE__*/React.createElement(WindowControllerBottom, {
103
+ window: window,
104
+ type: "bottom"
105
+ }), /*#__PURE__*/React.createElement(WindowControllerLeftTop, {
106
+ window: window,
107
+ type: "left-top"
108
+ }), /*#__PURE__*/React.createElement(WindowControllerLeftBottom, {
109
+ window: window,
110
+ type: "left-bottom"
111
+ }), /*#__PURE__*/React.createElement(WindowControllerRightTop, {
112
+ window: window,
113
+ type: "right-top"
114
+ }), /*#__PURE__*/React.createElement(WindowControllerRightBottom, {
115
+ window: window,
116
+ type: "right-bottom"
117
+ }), /*#__PURE__*/React.createElement(WindowEntity, null, /*#__PURE__*/React.createElement(WindowController, {
118
+ window: window,
119
+ type: "move"
120
+ }, /*#__PURE__*/React.createElement(WindowHeader, {
121
+ isDragging: window.isMoving
122
+ }, /*#__PURE__*/React.createElement("h5", null, title), /*#__PURE__*/React.createElement(WindowHeaderOptions, {
123
+ onPointerDown: function onPointerDown(e) {
124
+ e.stopPropagation();
125
+ }
126
+ }, /*#__PURE__*/React.createElement(Space, null, !window.fullscreen ? /*#__PURE__*/React.createElement(WindowOption, {
127
+ color: "var(--kep-platform-orange-4)",
128
+ icon: /*#__PURE__*/React.createElement(FullscreenOutlined, null),
129
+ onClick: function onClick() {
130
+ return window.fullscreenWindow();
131
+ }
132
+ }) : /*#__PURE__*/React.createElement(WindowOption, {
133
+ color: "var(--kep-platform-orange-4)",
134
+ icon: /*#__PURE__*/React.createElement(FullscreenExitOutlined, null),
135
+ onClick: function onClick() {
136
+ window.fullscreenExitWindow();
137
+ }
138
+ }), /*#__PURE__*/React.createElement(WindowOption, {
139
+ color: "var(--kep-platform-green-3)",
140
+ icon: /*#__PURE__*/React.createElement(MinusCircleOutlined, null),
141
+ onClick: function onClick() {
142
+ window.minimizeWindow(minimizePos);
143
+ }
144
+ }), /*#__PURE__*/React.createElement(WindowOption, {
145
+ onClick: function onClick() {
146
+ window.closeWindow();
147
+ },
148
+ icon: /*#__PURE__*/React.createElement(CloseCircleOutlined, null),
149
+ color: "var(--kep-platform-red)"
150
+ }))))), /*#__PURE__*/React.createElement(WindowBody, null, children)));
151
+ });
152
+ export default Window;
@@ -0,0 +1,10 @@
1
+ import React, { ReactNode } from 'react';
2
+ import WindowStore from './WindowStore';
3
+ export type WindowControllerType = 'left' | 'right' | 'top' | 'bottom' | 'left-top' | 'right-top' | 'left-bottom' | 'right-bottom' | 'move';
4
+ type WindowControllerProps = {
5
+ type: WindowControllerType;
6
+ window: WindowStore;
7
+ children?: ReactNode;
8
+ };
9
+ export default function WindowController(props: WindowControllerProps): React.JSX.Element;
10
+ export {};
@@ -0,0 +1,37 @@
1
+ var _excluded = ["type", "window", "children"];
2
+ 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); }
3
+ 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; }
4
+ 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; }
5
+ import { useDraggable } from '@dnd-kit/core';
6
+ import React, { useEffect } from 'react';
7
+ import styled from 'styled-components';
8
+ var WindowControllerContainer = styled.div.withConfig({
9
+ displayName: "WindowControllerContainer",
10
+ componentId: "basic-component-347b__sc-1rv6ocd-0"
11
+ })(["&:active,&:focus{outline:none;}"]);
12
+ export default function WindowController(props) {
13
+ var type = props.type,
14
+ window = props.window,
15
+ children = props.children,
16
+ rest = _objectWithoutProperties(props, _excluded);
17
+ var _useDraggable = useDraggable({
18
+ id: "".concat(window.id, "/").concat(type),
19
+ disabled: window.fullscreen
20
+ }),
21
+ attributes = _useDraggable.attributes,
22
+ transform = _useDraggable.transform,
23
+ setNodeRef = _useDraggable.setNodeRef,
24
+ listeners = _useDraggable.listeners,
25
+ isDragging = _useDraggable.isDragging;
26
+ useEffect(function () {
27
+ if (transform && isDragging) {
28
+ window.controll(transform, type);
29
+ } else {
30
+ window.endControll();
31
+ }
32
+ }, [transform, isDragging, type]);
33
+ return /*#__PURE__*/React.createElement(WindowControllerContainer, _extends({}, rest, attributes, listeners, {
34
+ ref: setNodeRef,
35
+ role: "div"
36
+ }), children);
37
+ }
@@ -0,0 +1,7 @@
1
+ import React, { HtmlHTMLAttributes, ReactNode } from 'react';
2
+ type WindowOptionProps = {
3
+ icon: ReactNode;
4
+ color?: string;
5
+ } & HtmlHTMLAttributes<HTMLSpanElement>;
6
+ export default function WindowOption(props: WindowOptionProps): React.JSX.Element;
7
+ export {};
@@ -0,0 +1,43 @@
1
+ var _excluded = ["icon"];
2
+ 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); }
3
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
4
+ 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."); }
5
+ 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); }
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
+ 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
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
9
+ 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; }
10
+ 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; }
11
+ import React, { useState } from 'react';
12
+ import styled, { css } from 'styled-components';
13
+ var WindowOptionContainer = styled.span.withConfig({
14
+ shouldForwardProp: function shouldForwardProp(prop) {
15
+ return !['active'].includes(prop);
16
+ }
17
+ }).withConfig({
18
+ displayName: "WindowOptionContainer",
19
+ componentId: "basic-component-347b__sc-1ebf27x-0"
20
+ })(["cursor:pointer;& svg{transition:transform 0.5s;color:", ";}&:hover{& svg{transform:scale(1.2);}}", ""], function (props) {
21
+ return props.color || 'auto';
22
+ }, function (props) {
23
+ if (props.active) {
24
+ return css(["& svg{transform:scale(0.9) !important;}"]);
25
+ }
26
+ });
27
+ export default function WindowOption(props) {
28
+ var icon = props.icon,
29
+ rest = _objectWithoutProperties(props, _excluded);
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ active = _useState2[0],
33
+ setActive = _useState2[1];
34
+ return /*#__PURE__*/React.createElement(WindowOptionContainer, _extends({}, rest, {
35
+ onPointerDown: function onPointerDown() {
36
+ setActive(true);
37
+ },
38
+ onPointerUp: function onPointerUp() {
39
+ setActive(false);
40
+ },
41
+ active: active
42
+ }), icon);
43
+ }
@@ -0,0 +1,49 @@
1
+ import { Transform } from '@dnd-kit/utilities';
2
+ import { WindowControllerType } from './WindowController';
3
+ export default class WindowStore {
4
+ width: string;
5
+ height: string;
6
+ left: string;
7
+ top: string;
8
+ zIndex: number;
9
+ fullscreen: boolean;
10
+ id: string;
11
+ transform: {
12
+ x: number;
13
+ y: number;
14
+ } | null;
15
+ isMoving: boolean;
16
+ isResizing: boolean;
17
+ minimizePos: {
18
+ left: number;
19
+ top: number;
20
+ } | null;
21
+ isMinimize: boolean;
22
+ isClosed: boolean;
23
+ onClosedHandler: ((id: string) => void) | undefined;
24
+ constructor(id: string, onClosedHandler?: (id: string) => void);
25
+ fullscreenWindow(): void;
26
+ fullscreenExitWindow(): void;
27
+ resetState(): void;
28
+ calculateTransform(transform: Transform): {
29
+ x: number;
30
+ y: number;
31
+ };
32
+ controll(transform: Transform, type: WindowControllerType): void;
33
+ endControll(): void;
34
+ minimizeWindow(minimize: {
35
+ left: number;
36
+ top: number;
37
+ }): void;
38
+ normalizeWindow(): void;
39
+ closeWindow(): void;
40
+ get style(): {
41
+ left: string | number;
42
+ top: string | number;
43
+ width: string | number;
44
+ height: string | number;
45
+ zIndex: number;
46
+ transform: string;
47
+ transition: string;
48
+ };
49
+ }
@@ -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 { action, computed, makeObservable, observable } from 'mobx';
9
+ var WindowStore = /*#__PURE__*/function () {
10
+ function WindowStore(id, onClosedHandler) {
11
+ _classCallCheck(this, WindowStore);
12
+ _defineProperty(this, "width", '400px');
13
+ _defineProperty(this, "height", '400px');
14
+ _defineProperty(this, "left", '0px');
15
+ _defineProperty(this, "top", '0px');
16
+ _defineProperty(this, "zIndex", 1);
17
+ _defineProperty(this, "fullscreen", true);
18
+ _defineProperty(this, "id", '');
19
+ _defineProperty(this, "transform", null);
20
+ _defineProperty(this, "isMoving", false);
21
+ _defineProperty(this, "isResizing", false);
22
+ _defineProperty(this, "minimizePos", null);
23
+ _defineProperty(this, "isMinimize", false);
24
+ _defineProperty(this, "isClosed", false);
25
+ _defineProperty(this, "onClosedHandler", void 0);
26
+ makeObservable(this, {
27
+ width: observable,
28
+ height: observable,
29
+ left: observable,
30
+ top: observable,
31
+ zIndex: observable,
32
+ fullscreen: observable,
33
+ transform: observable.struct,
34
+ isMoving: observable,
35
+ isResizing: observable,
36
+ isClosed: observable,
37
+ fullscreenExitWindow: action,
38
+ fullscreenWindow: action,
39
+ controll: action,
40
+ endControll: action,
41
+ style: computed.struct,
42
+ isMinimize: observable,
43
+ minimizePos: observable.struct,
44
+ minimizeWindow: action,
45
+ normalizeWindow: action,
46
+ closeWindow: action,
47
+ resetState: action
48
+ });
49
+ this.id = id;
50
+ this.onClosedHandler = onClosedHandler;
51
+ }
52
+ _createClass(WindowStore, [{
53
+ key: "fullscreenWindow",
54
+ value: function fullscreenWindow() {
55
+ this.resetState();
56
+ this.fullscreen = true;
57
+ }
58
+ }, {
59
+ key: "fullscreenExitWindow",
60
+ value: function fullscreenExitWindow() {
61
+ this.resetState();
62
+ this.fullscreen = false;
63
+ }
64
+ }, {
65
+ key: "resetState",
66
+ value: function resetState() {
67
+ this.transform = null;
68
+ }
69
+ }, {
70
+ key: "calculateTransform",
71
+ value: function calculateTransform(transform) {
72
+ var _this$transform, _this$transform2;
73
+ return {
74
+ x: transform.x - (((_this$transform = this.transform) === null || _this$transform === void 0 ? void 0 : _this$transform.x) || 0),
75
+ y: transform.y - (((_this$transform2 = this.transform) === null || _this$transform2 === void 0 ? void 0 : _this$transform2.y) || 0)
76
+ };
77
+ }
78
+ }, {
79
+ key: "controll",
80
+ value: function controll(transform, type) {
81
+ var offsetTransform = this.calculateTransform(transform);
82
+ if (type === 'move') {
83
+ this.isMoving = true;
84
+ this.isResizing = false;
85
+ } else {
86
+ this.isMoving = false;
87
+ this.isResizing = true;
88
+ }
89
+ if (type.includes('left')) {
90
+ this.left = Math.round(parseFloat(this.left) + offsetTransform.x) + 'px';
91
+ this.width = Math.round(parseFloat(this.width) - offsetTransform.x) + 'px';
92
+ }
93
+ if (type.includes('right')) {
94
+ this.width = Math.round(parseFloat(this.width) + offsetTransform.x) + 'px';
95
+ }
96
+ if (type.includes('top')) {
97
+ this.top = Math.round(parseFloat(this.top) + offsetTransform.y) + 'px';
98
+ this.height = Math.round(parseFloat(this.height) - offsetTransform.y) + 'px';
99
+ }
100
+ if (type.includes('bottom')) {
101
+ this.height = Math.round(parseFloat(this.height) + offsetTransform.y) + 'px';
102
+ }
103
+ if (type.includes('move')) {
104
+ this.left = Math.round(parseFloat(this.left) + offsetTransform.x) + 'px';
105
+ this.top = Math.round(parseFloat(this.top) + offsetTransform.y) + 'px';
106
+ }
107
+ this.transform = transform;
108
+ }
109
+ }, {
110
+ key: "endControll",
111
+ value: function endControll() {
112
+ this.isMoving = false;
113
+ this.isResizing = false;
114
+ this.resetState();
115
+ }
116
+ }, {
117
+ key: "minimizeWindow",
118
+ value: function minimizeWindow(minimize) {
119
+ this.minimizePos = minimize;
120
+ this.isMinimize = true;
121
+ this.fullscreen = false;
122
+ this.resetState();
123
+ }
124
+ }, {
125
+ key: "normalizeWindow",
126
+ value: function normalizeWindow() {
127
+ this.minimizePos = null;
128
+ this.isMinimize = false;
129
+ this.fullscreen = false;
130
+ this.resetState();
131
+ }
132
+ }, {
133
+ key: "closeWindow",
134
+ value: function closeWindow() {
135
+ this.isClosed = true;
136
+ this.resetState();
137
+ }
138
+ }, {
139
+ key: "style",
140
+ get: function get() {
141
+ var renderStyle = {
142
+ left: this.isClosed ? this.left : this.isMinimize && this.minimizePos ? this.minimizePos.left : this.fullscreen ? 0 : this.left,
143
+ top: this.isClosed ? this.top : this.isMinimize && this.minimizePos ? this.minimizePos.top : this.fullscreen ? 0 : this.top,
144
+ width: this.isClosed ? this.width : this.isMinimize ? 0 : this.fullscreen ? '100%' : this.width,
145
+ height: this.isClosed ? this.height : this.isMinimize ? 0 : this.fullscreen ? '100%' : this.height,
146
+ zIndex: this.zIndex,
147
+ transform: this.isMinimize || this.isClosed ? 'scale(0)' : 'none',
148
+ transition: this.isMoving || this.isResizing ? 'none' : 'all 0.5s ease-out'
149
+ };
150
+ return renderStyle;
151
+ }
152
+ }]);
153
+ return WindowStore;
154
+ }();
155
+ export { WindowStore as default };
@@ -0,0 +1,2 @@
1
+ export { default as Window } from './Window';
2
+ export { default as WindowStore } from './WindowStore';
@@ -0,0 +1,2 @@
1
+ export { default as Window } from "./Window";
2
+ export { default as WindowStore } from "./WindowStore";
@@ -0,0 +1,3 @@
1
+ import React from 'react';
2
+ declare const _default: React.FunctionComponent<object>;
3
+ export default _default;
@@ -0,0 +1,61 @@
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 { DndContext } from '@dnd-kit/core';
9
+ import { makeAutoObservable } from 'mobx';
10
+ import { observer } from 'mobx-react-lite';
11
+ import React from 'react';
12
+ import { Button } from "../Button";
13
+ import { Space } from "../Space";
14
+ import { GlobalStyles } from "../__styles";
15
+ import { Window, WindowStore } from "./index";
16
+ var WindowManager = /*#__PURE__*/function () {
17
+ function WindowManager() {
18
+ _classCallCheck(this, WindowManager);
19
+ _defineProperty(this, "windows", [new WindowStore('jss', this.closeWindowHanlder.bind(this)), new WindowStore('jx', this.closeWindowHanlder.bind(this)), new WindowStore('jiangxin', this.closeWindowHanlder.bind(this)), new WindowStore('xixi', this.closeWindowHanlder.bind(this))]);
20
+ makeAutoObservable(this);
21
+ }
22
+ _createClass(WindowManager, [{
23
+ key: "closeWindowHanlder",
24
+ value: function closeWindowHanlder(id) {
25
+ this.windows = this.windows.filter(function (window) {
26
+ return window.id !== id;
27
+ });
28
+ }
29
+ }, {
30
+ key: "report",
31
+ get: function get() {
32
+ return this.windows.map(function (window) {
33
+ return window.id;
34
+ }).join(',');
35
+ }
36
+ }]);
37
+ return WindowManager;
38
+ }();
39
+ var windowManager = new WindowManager();
40
+ export default observer(function Test() {
41
+ return /*#__PURE__*/React.createElement(DndContext, null, /*#__PURE__*/React.createElement(Space, null, windowManager.report, /*#__PURE__*/React.createElement(Button, {
42
+ onClick: function onClick() {
43
+ windowManager.windows.forEach(function (window) {
44
+ window.normalizeWindow();
45
+ });
46
+ }
47
+ }, "\u5C55\u5F00")), /*#__PURE__*/React.createElement("div", {
48
+ style: {
49
+ position: 'relative',
50
+ height: '1200px'
51
+ }
52
+ }, /*#__PURE__*/React.createElement(GlobalStyles, {
53
+ $css: []
54
+ }), windowManager.windows.map(function (windowStore) {
55
+ return /*#__PURE__*/React.createElement(Window, {
56
+ window: windowStore,
57
+ key: windowStore.id,
58
+ title: 'xixi'
59
+ }, "123");
60
+ })));
61
+ });
package/package.json CHANGED
@@ -1,87 +1,90 @@
1
1
  {
2
- "name": "@kep-platform/basic-component",
3
- "version": "0.0.29",
4
- "description": "A react library developed with dumi",
5
- "module": "dist/index.js",
6
- "types": "dist/index.d.ts",
7
- "scripts": {
8
- "start": "npm run dev",
9
- "dev": "dumi dev",
10
- "build": "father build",
11
- "build:watch": "father dev",
12
- "docs:build": "dumi build",
13
- "docs:preview": "dumi preview",
14
- "prepare": "dumi setup",
15
- "doctor": "father doctor",
16
- "lint": "npm run lint:es && npm run lint:css",
17
- "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
18
- "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
19
- "prepublishOnly": "father doctor && npm run build"
20
- },
21
- "authors": [
22
- "lee-step-jss 1599925910@qq.com"
23
- ],
24
- "license": "MIT",
25
- "files": [
26
- "dist"
27
- ],
28
- "commitlint": {
29
- "extends": [
30
- "@commitlint/config-conventional"
31
- ]
32
- },
33
- "lint-staged": {
34
- "*.{md,json}": [
35
- "prettier --write --no-error-on-unmatched-pattern"
2
+ "name": "@kep-platform/basic-component",
3
+ "version": "0.0.32",
4
+ "description": "A react library developed with dumi",
5
+ "license": "MIT",
6
+ "module": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
36
10
  ],
37
- "*.{css,less}": [
38
- "stylelint --fix",
39
- "prettier --write"
11
+ "scripts": {
12
+ "build": "father build",
13
+ "build:watch": "father dev",
14
+ "dev": "dumi dev",
15
+ "docs:build": "dumi build",
16
+ "docs:preview": "dumi preview",
17
+ "doctor": "father doctor",
18
+ "lint": "npm run lint:es && npm run lint:css",
19
+ "lint:css": "stylelint \"{src,test}/**/*.{css,less}\"",
20
+ "lint:es": "eslint \"{src,test}/**/*.{js,jsx,ts,tsx}\"",
21
+ "prepare": "dumi setup",
22
+ "prepublishOnly": "npm run build",
23
+ "start": "npm run dev"
24
+ },
25
+ "commitlint": {
26
+ "extends": [
27
+ "@commitlint/config-conventional"
28
+ ]
29
+ },
30
+ "lint-staged": {
31
+ "*.{md,json}": [
32
+ "prettier --write --no-error-on-unmatched-pattern"
33
+ ],
34
+ "*.{css,less}": [
35
+ "stylelint --fix",
36
+ "prettier --write"
37
+ ],
38
+ "*.{js,jsx}": [
39
+ "eslint --fix",
40
+ "prettier --write"
41
+ ],
42
+ "*.{ts,tsx}": [
43
+ "eslint --fix",
44
+ "prettier --parser=typescript --write"
45
+ ]
46
+ },
47
+ "dependencies": {
48
+ "@ant-design/icons": "^5.3.7",
49
+ "@dnd-kit/core": "^6.1.0",
50
+ "@dnd-kit/utilities": "^3.2.2",
51
+ "@kep-platform/hooks": "^0.0.32",
52
+ "color": "^4.2.3",
53
+ "rc-pagination": "^4.1.0",
54
+ "styled-components": "^6.1.11"
55
+ },
56
+ "devDependencies": {
57
+ "@babel/runtime": "^7.24.6",
58
+ "@commitlint/cli": "^17.1.2",
59
+ "@commitlint/config-conventional": "^17.1.0",
60
+ "@types/color": "^3.0.6",
61
+ "@types/react": "^18.0.0",
62
+ "@types/react-dom": "^18.0.0",
63
+ "@umijs/lint": "^4.0.0",
64
+ "babel-plugin-transform-remove-console": "^6.9.4",
65
+ "dumi": "^2.3.0",
66
+ "eslint": "^8.23.0",
67
+ "father": "^4.1.0",
68
+ "husky": "^8.0.1",
69
+ "lint-staged": "^13.0.3",
70
+ "prettier": "^2.7.1",
71
+ "prettier-plugin-organize-imports": "^3.0.0",
72
+ "prettier-plugin-packagejson": "^2.2.18",
73
+ "react": "^18.0.0",
74
+ "react-dom": "^18.0.0",
75
+ "stylelint": "^14.9.1"
76
+ },
77
+ "peerDependencies": {
78
+ "mobx": "^6.12.3",
79
+ "mobx-react-lite": "^4.0.7",
80
+ "react": ">=16.9.0",
81
+ "react-dom": ">=16.9.0"
82
+ },
83
+ "publishConfig": {
84
+ "access": "public"
85
+ },
86
+ "authors": [
87
+ "lee-step-jss 1599925910@qq.com"
40
88
  ],
41
- "*.{js,jsx}": [
42
- "eslint --fix",
43
- "prettier --write"
44
- ],
45
- "*.{ts,tsx}": [
46
- "eslint --fix",
47
- "prettier --parser=typescript --write"
48
- ]
49
- },
50
- "publishConfig": {
51
- "access": "public"
52
- },
53
- "peerDependencies": {
54
- "mobx": "^6.12.3",
55
- "mobx-react-lite": "^4.0.7",
56
- "react": ">=16.9.0",
57
- "react-dom": ">=16.9.0"
58
- },
59
- "devDependencies": {
60
- "@babel/runtime": "^7.24.6",
61
- "@commitlint/cli": "^17.1.2",
62
- "@commitlint/config-conventional": "^17.1.0",
63
- "@types/color": "^3.0.6",
64
- "@types/react": "^18.0.0",
65
- "@types/react-dom": "^18.0.0",
66
- "@umijs/lint": "^4.0.0",
67
- "dumi": "^2.3.0",
68
- "eslint": "^8.23.0",
69
- "father": "^4.1.0",
70
- "husky": "^8.0.1",
71
- "lint-staged": "^13.0.3",
72
- "prettier": "^2.7.1",
73
- "prettier-plugin-organize-imports": "^3.0.0",
74
- "prettier-plugin-packagejson": "^2.2.18",
75
- "react": "^18.0.0",
76
- "react-dom": "^18.0.0",
77
- "stylelint": "^14.9.1"
78
- },
79
- "gitHead": "b6a8afddc8aeca25f7a15bd7a64b6467ba730a54",
80
- "dependencies": {
81
- "@ant-design/icons": "^5.3.7",
82
- "@kep-platform/hooks": "^0.0.29",
83
- "color": "^4.2.3",
84
- "rc-pagination": "^4.1.0",
85
- "styled-components": "^6.1.11"
86
- }
89
+ "gitHead": "581914abdd5785a77fa0400eb7cce9f25e07eabf"
87
90
  }