fan-standard-comp 3.1.9 → 3.2.0

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.
Files changed (176) hide show
  1. package/Readme.md +35 -0
  2. package/dist/fan-standard-comp.umd.js +15 -10
  3. package/es/ButtonGroup/ButtonList.js +0 -3
  4. package/es/ButtonGroup/ButtonMenu.js +0 -3
  5. package/es/ButtonGroup/PopConfirmTitle.js +5 -15
  6. package/es/ButtonGroup/index.d.ts +2 -0
  7. package/es/ButtonGroup/index.js +223 -193
  8. package/es/ButtonGroup/style/index.less +1 -1
  9. package/es/DragContent/DragBar.js +2 -6
  10. package/es/DragContent/index.js +44 -75
  11. package/es/FormComp/ChunkUploader/api.js +6 -10
  12. package/es/FormComp/ChunkUploader/index.js +105 -171
  13. package/es/FormComp/ChunkUploader/lib.js +4 -17
  14. package/es/FormComp/ChunkUploader/upload-queue.class.js +10 -45
  15. package/es/FormComp/ChunkUploader/worker.js +0 -3
  16. package/es/FormComp/EditButton/index.js +24 -49
  17. package/es/FormComp/FieldComponent/ReUpload.js +18 -38
  18. package/es/FormComp/FieldComponent/RefactorTreeSelect.js +37 -75
  19. package/es/FormComp/FieldComponent/TitleNode.js +1 -3
  20. package/es/FormComp/FieldComponent/index.js +38 -74
  21. package/es/FormComp/FieldComponent/setReadonlyValues.js +34 -63
  22. package/es/FormComp/FieldComponent/style/index.less +6 -0
  23. package/es/FormComp/RenderItemGroup/index.js +46 -74
  24. package/es/FormComp/Uploader/index.js +36 -77
  25. package/es/FormComp/Uploader/util.js +0 -6
  26. package/es/FormComp/VarTemplate/index.js +58 -96
  27. package/es/NavLeafScroll/index.js +172 -154
  28. package/es/NavLeafScroll/style/index.less +33 -1
  29. package/es/RefactorTree/index.js +36 -53
  30. package/es/RefactorTree/indexTreeNode.js +35 -68
  31. package/es/RefactorTree/util.js +9 -43
  32. package/es/SpecIcon/fonts/iconfont.js +7 -12
  33. package/es/SpecIcon/index.js +16 -25
  34. package/es/SplitterLayout/Pane.js +2 -5
  35. package/es/SplitterLayout/index.js +20 -70
  36. package/es/StandardContent/SplitterLayout/Pane.js +6 -10
  37. package/es/StandardContent/SplitterLayout/index.js +12 -63
  38. package/es/StandardContent/SubfieldContent.js +12 -14
  39. package/es/StandardContent/WrapperContent.js +8 -10
  40. package/es/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  41. package/es/StandardDragModal/ChangeStandardModal.js +493 -0
  42. package/es/StandardDragModal/DraggableModal.d.ts +7 -0
  43. package/es/StandardDragModal/DraggableModal.js +31 -0
  44. package/es/StandardDragModal/DraggableModalContext.d.ts +9 -0
  45. package/es/StandardDragModal/DraggableModalContext.js +5 -0
  46. package/es/StandardDragModal/DraggableModalInner.d.ts +16 -0
  47. package/es/StandardDragModal/DraggableModalInner.js +114 -0
  48. package/es/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  49. package/es/StandardDragModal/DraggableModalProvider.js +40 -0
  50. package/es/StandardDragModal/Modal.d.ts +11 -0
  51. package/es/StandardDragModal/Modal.js +24 -0
  52. package/es/StandardDragModal/ResizeHandle.d.ts +2 -0
  53. package/es/StandardDragModal/ResizeHandle.js +8 -0
  54. package/es/StandardDragModal/clamp.d.ts +1 -0
  55. package/es/StandardDragModal/clamp.js +3 -0
  56. package/es/StandardDragModal/draggableModalReducer.d.ts +66 -0
  57. package/es/StandardDragModal/draggableModalReducer.js +157 -0
  58. package/es/StandardDragModal/getWindowSize.d.ts +4 -0
  59. package/es/StandardDragModal/getWindowSize.js +6 -0
  60. package/es/StandardDragModal/index.d.ts +3 -11
  61. package/es/StandardDragModal/index.js +3 -30
  62. package/es/StandardDragModal/index.less +65 -0
  63. package/es/StandardDragModal/useDrag.d.ts +5 -0
  64. package/es/StandardDragModal/useDrag.js +66 -0
  65. package/es/StandardDragModal/usePrevious.d.ts +1 -0
  66. package/es/StandardDragModal/usePrevious.js +8 -0
  67. package/es/StandardDragModal/useResize.d.ts +7 -0
  68. package/es/StandardDragModal/useResize.js +74 -0
  69. package/es/StandardFilter/index.d.ts +1 -0
  70. package/es/StandardFilter/index.js +32 -70
  71. package/es/StandardForm/ActionList.js +5 -7
  72. package/es/StandardForm/StepForm.js +50 -71
  73. package/es/StandardForm/TabForm.js +58 -70
  74. package/es/StandardForm/index.js +37 -56
  75. package/es/StandardModal/UpdateFormRef.js +1 -4
  76. package/es/StandardModal/index.d.ts +0 -1
  77. package/es/StandardModal/index.js +115 -159
  78. package/es/StandardPanel/index.js +19 -35
  79. package/es/StandardTable/index.js +20 -30
  80. package/es/components/IconNode/index.js +0 -4
  81. package/es/index.d.ts +1 -0
  82. package/es/index.js +15 -14
  83. package/es/utils/ValueFormat.js +0 -9
  84. package/es/utils/dictSelectUtil.js +153 -0
  85. package/es/utils/filterPermission.js +16 -34
  86. package/es/utils/getParentNodes.js +24 -47
  87. package/es/utils/index.js +2 -1
  88. package/lib/ButtonGroup/ButtonList.js +1 -13
  89. package/lib/ButtonGroup/ButtonMenu.js +1 -8
  90. package/lib/ButtonGroup/PopConfirmTitle.js +3 -16
  91. package/lib/ButtonGroup/index.d.ts +2 -0
  92. package/lib/ButtonGroup/index.js +226 -216
  93. package/lib/ButtonGroup/style/index.less +1 -1
  94. package/lib/DragContent/DragBar.js +2 -10
  95. package/lib/DragContent/index.js +47 -85
  96. package/lib/FormComp/ChunkUploader/api.js +6 -15
  97. package/lib/FormComp/ChunkUploader/index.js +107 -185
  98. package/lib/FormComp/ChunkUploader/lib.js +8 -27
  99. package/lib/FormComp/ChunkUploader/upload-queue.class.js +10 -46
  100. package/lib/FormComp/ChunkUploader/worker.js +1 -5
  101. package/lib/FormComp/EditButton/index.js +26 -60
  102. package/lib/FormComp/FieldComponent/ReUpload.js +21 -50
  103. package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +39 -90
  104. package/lib/FormComp/FieldComponent/TitleNode.js +1 -5
  105. package/lib/FormComp/FieldComponent/index.js +38 -110
  106. package/lib/FormComp/FieldComponent/setReadonlyValues.js +37 -79
  107. package/lib/FormComp/FieldComponent/style/index.less +6 -0
  108. package/lib/FormComp/RenderItemGroup/index.js +46 -87
  109. package/lib/FormComp/Uploader/index.js +38 -95
  110. package/lib/FormComp/Uploader/util.js +1 -9
  111. package/lib/FormComp/VarTemplate/index.js +62 -106
  112. package/lib/FormComp/index.js +0 -2
  113. package/lib/NavLeafScroll/index.js +174 -165
  114. package/lib/NavLeafScroll/style/index.less +33 -1
  115. package/lib/RefactorTree/index.js +36 -67
  116. package/lib/RefactorTree/indexTreeNode.js +37 -83
  117. package/lib/RefactorTree/util.js +11 -45
  118. package/lib/SpecIcon/fonts/iconfont.js +7 -12
  119. package/lib/SpecIcon/index.js +16 -30
  120. package/lib/SplitterLayout/Pane.js +0 -7
  121. package/lib/SplitterLayout/index.js +18 -72
  122. package/lib/StandardContent/SplitterLayout/Pane.js +6 -14
  123. package/lib/StandardContent/SplitterLayout/index.js +12 -68
  124. package/lib/StandardContent/SubfieldContent.js +12 -21
  125. package/lib/StandardContent/WrapperContent.js +8 -16
  126. package/lib/StandardDragModal/ChangeStandardModal.d.ts +44 -0
  127. package/lib/StandardDragModal/ChangeStandardModal.js +502 -0
  128. package/lib/StandardDragModal/DraggableModal.d.ts +7 -0
  129. package/lib/StandardDragModal/DraggableModal.js +40 -0
  130. package/lib/StandardDragModal/DraggableModalContext.d.ts +9 -0
  131. package/lib/StandardDragModal/DraggableModalContext.js +15 -0
  132. package/lib/StandardDragModal/DraggableModalInner.d.ts +16 -0
  133. package/lib/StandardDragModal/DraggableModalInner.js +124 -0
  134. package/lib/StandardDragModal/DraggableModalProvider.d.ts +4 -0
  135. package/lib/StandardDragModal/DraggableModalProvider.js +48 -0
  136. package/lib/StandardDragModal/Modal.d.ts +11 -0
  137. package/lib/StandardDragModal/Modal.js +32 -0
  138. package/lib/StandardDragModal/ResizeHandle.d.ts +2 -0
  139. package/lib/StandardDragModal/ResizeHandle.js +18 -0
  140. package/lib/StandardDragModal/clamp.d.ts +1 -0
  141. package/lib/StandardDragModal/clamp.js +10 -0
  142. package/lib/StandardDragModal/draggableModalReducer.d.ts +66 -0
  143. package/lib/StandardDragModal/draggableModalReducer.js +167 -0
  144. package/lib/StandardDragModal/getWindowSize.d.ts +4 -0
  145. package/lib/StandardDragModal/getWindowSize.js +13 -0
  146. package/lib/StandardDragModal/index.d.ts +3 -11
  147. package/lib/StandardDragModal/index.js +33 -38
  148. package/lib/StandardDragModal/index.less +65 -0
  149. package/lib/StandardDragModal/useDrag.d.ts +5 -0
  150. package/lib/StandardDragModal/useDrag.js +73 -0
  151. package/lib/StandardDragModal/usePrevious.d.ts +1 -0
  152. package/lib/StandardDragModal/usePrevious.js +15 -0
  153. package/lib/StandardDragModal/useResize.d.ts +7 -0
  154. package/lib/StandardDragModal/useResize.js +81 -0
  155. package/lib/StandardFilter/index.d.ts +1 -0
  156. package/lib/StandardFilter/index.js +30 -78
  157. package/lib/StandardForm/ActionList.js +5 -12
  158. package/lib/StandardForm/StepForm.js +52 -90
  159. package/lib/StandardForm/TabForm.js +61 -88
  160. package/lib/StandardForm/index.js +40 -75
  161. package/lib/StandardModal/UpdateFormRef.js +4 -12
  162. package/lib/StandardModal/index.d.ts +0 -1
  163. package/lib/StandardModal/index.js +117 -184
  164. package/lib/StandardPanel/index.js +22 -48
  165. package/lib/StandardTable/index.js +20 -39
  166. package/lib/components/IconNode/index.js +0 -7
  167. package/lib/components/index.js +0 -2
  168. package/lib/data/index.js +4 -7
  169. package/lib/index.d.ts +1 -0
  170. package/lib/index.js +50 -68
  171. package/lib/utils/ValueFormat.js +0 -10
  172. package/lib/utils/dictSelectUtil.js +161 -0
  173. package/lib/utils/filterPermission.js +15 -39
  174. package/lib/utils/getParentNodes.js +25 -52
  175. package/lib/utils/index.js +24 -9
  176. package/package.json +6 -5
@@ -0,0 +1,114 @@
1
+ import "antd/es/modal/style";
2
+ import _Modal from "antd/es/modal";
3
+ import { __rest } from "tslib";
4
+ import * as React from 'react';
5
+ import { useEffect, useMemo, useCallback, memo } from 'react';
6
+ import { ResizeHandle } from './ResizeHandle';
7
+ import { useDrag } from './useDrag';
8
+ import { usePrevious } from './usePrevious';
9
+ import { useResize } from './useResize';
10
+ var modalStyle = {
11
+ margin: 0,
12
+ paddingBottom: 0,
13
+ pointerEvents: 'auto'
14
+ };
15
+ function DraggableModalInnerNonMemo(_a) {
16
+ var id = _a.id,
17
+ modalState = _a.modalState,
18
+ dispatch = _a.dispatch,
19
+ visible = _a.visible,
20
+ children = _a.children,
21
+ title = _a.title,
22
+ initialWidth = _a.initialWidth,
23
+ initialHeight = _a.initialHeight,
24
+ otherProps = __rest(_a, ["id", "modalState", "dispatch", "visible", "children", "title", "initialWidth", "initialHeight"]); // Call on mount and unmount.
25
+ useEffect(function () {
26
+ dispatch({
27
+ type: 'mount',
28
+ id: id,
29
+ intialState: {
30
+ initialWidth: initialWidth,
31
+ initialHeight: initialHeight
32
+ }
33
+ });
34
+ return function () {
35
+ return dispatch({
36
+ type: 'unmount',
37
+ id: id
38
+ });
39
+ };
40
+ }, [dispatch, id, initialWidth, initialHeight]);
41
+ // Bring this to the front if it's been opened with props.
42
+ var visiblePrevious = usePrevious(visible);
43
+ useEffect(function () {
44
+ if (visible !== visiblePrevious) {
45
+ if (visible) {
46
+ dispatch({
47
+ type: 'show',
48
+ id: id
49
+ });
50
+ } else {
51
+ dispatch({
52
+ type: 'hide',
53
+ id: id
54
+ });
55
+ }
56
+ }
57
+ }, [visible, visiblePrevious, id, dispatch]);
58
+ var zIndex = modalState.zIndex,
59
+ x = modalState.x,
60
+ y = modalState.y,
61
+ width = modalState.width,
62
+ height = modalState.height;
63
+ var style = useMemo(function () {
64
+ return Object.assign(Object.assign({}, modalStyle), {
65
+ top: y,
66
+ left: x,
67
+ height: height
68
+ });
69
+ }, [y, x, height]);
70
+ var onFocus = useCallback(function () {
71
+ return dispatch({
72
+ type: 'focus',
73
+ id: id
74
+ });
75
+ }, [id, dispatch]);
76
+ var onDragWithID = useCallback(function (args) {
77
+ return dispatch(Object.assign({
78
+ type: 'drag',
79
+ id: id
80
+ }, args));
81
+ }, [dispatch, id]);
82
+ var onResizeWithID = useCallback(function (args) {
83
+ return dispatch(Object.assign({
84
+ type: 'resize',
85
+ id: id
86
+ }, args));
87
+ }, [dispatch, id]);
88
+ var onMouseDrag = useDrag(x, y, onDragWithID);
89
+ var onMouseResize = useResize(x, y, width, height, onResizeWithID);
90
+ var titleElement = useMemo(function () {
91
+ return /*#__PURE__*/React.createElement("div", {
92
+ className: "ant-design-draggable-modal-title",
93
+ onMouseDown: onMouseDrag,
94
+ onClick: onFocus
95
+ }, title);
96
+ }, [onMouseDrag, onFocus, title]);
97
+ return /*#__PURE__*/React.createElement(_Modal, Object.assign({
98
+ wrapClassName: "ant-design-draggable-modal",
99
+ style: style,
100
+ width: width,
101
+ destroyOnClose: true,
102
+ mask: false,
103
+ maskClosable: false,
104
+ zIndex: zIndex,
105
+ title: titleElement,
106
+ open: visible
107
+ }, otherProps), children, /*#__PURE__*/React.createElement(ResizeHandle, {
108
+ onMouseDown: onMouseResize
109
+ }));
110
+ }
111
+ export var DraggableModalInner = /*#__PURE__*/memo(DraggableModalInnerNonMemo);
112
+ if (process.env.NODE_ENV !== 'production') {
113
+ DraggableModalInner.displayName = 'DraggableModalInner';
114
+ }
@@ -0,0 +1,4 @@
1
+ import * as React from 'react';
2
+ export declare const DraggableModalProvider: ({ children, }: {
3
+ children: React.ReactNode;
4
+ }) => React.ReactElement;
@@ -0,0 +1,40 @@
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 _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
3
+ 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."); }
4
+ 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); }
5
+ 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; }
6
+ 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; } }
7
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
8
+ import * as React from 'react';
9
+ import { useEffect, useReducer } from 'react';
10
+ import { DraggableModalContext } from './DraggableModalContext';
11
+ import { getWindowSize } from './getWindowSize';
12
+ import { draggableModalReducer, initialModalsState } from './draggableModalReducer';
13
+ export var DraggableModalProvider = function DraggableModalProvider(_ref) {
14
+ var children = _ref.children;
15
+ var _useReducer = useReducer(draggableModalReducer, initialModalsState),
16
+ _useReducer2 = _slicedToArray(_useReducer, 2),
17
+ state = _useReducer2[0],
18
+ dispatch = _useReducer2[1];
19
+ useEffect(function () {
20
+ var onResize = function onResize() {
21
+ return dispatch({
22
+ type: 'windowResize',
23
+ size: getWindowSize()
24
+ });
25
+ };
26
+ if ((typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object') {
27
+ window.addEventListener('resize', onResize);
28
+ onResize();
29
+ }
30
+ return function () {
31
+ (typeof window === "undefined" ? "undefined" : _typeof(window)) === 'object' && window.removeEventListener('resize', onResize);
32
+ };
33
+ }, [dispatch]);
34
+ return /*#__PURE__*/React.createElement(DraggableModalContext.Provider, {
35
+ value: {
36
+ state: state,
37
+ dispatch: dispatch
38
+ }
39
+ }, children);
40
+ };
@@ -0,0 +1,11 @@
1
+ import React from 'react';
2
+ import './index.less';
3
+ interface StandardDragModalProps {
4
+ visible: boolean;
5
+ title?: string | React.ReactNode;
6
+ initialWidth?: number;
7
+ initialHeight?: number;
8
+ [k: string]: any;
9
+ }
10
+ declare const StandardDragModal: (props: StandardDragModalProps) => JSX.Element;
11
+ export default StandardDragModal;
@@ -0,0 +1,24 @@
1
+ import { __rest } from "tslib";
2
+ import React from 'react';
3
+ import { DraggableModal, DraggableModalProvider } from './index';
4
+ import './index.less';
5
+ var StandardDragModal = function StandardDragModal(props) {
6
+ var visible = props.visible,
7
+ onCancel = props.onCancel,
8
+ onSubmit = props.onSubmit,
9
+ children = props.children,
10
+ others = __rest(props, ["visible", "onCancel", "onSubmit", "children"]);
11
+ var handleOk = function handleOk() {
12
+ onSubmit && onSubmit();
13
+ };
14
+ var handleCancel = function handleCancel() {
15
+ onCancel && onCancel();
16
+ };
17
+ return /*#__PURE__*/React.createElement(DraggableModalProvider, null, /*#__PURE__*/React.createElement(DraggableModal, Object.assign({
18
+ visible: visible,
19
+ onOk: handleOk,
20
+ onCancel: handleCancel,
21
+ zIndex: 1001
22
+ }, others), children));
23
+ };
24
+ export default StandardDragModal;
@@ -0,0 +1,2 @@
1
+ import * as React from 'react';
2
+ export declare const ResizeHandle: (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.ReactElement;
@@ -0,0 +1,8 @@
1
+ import * as React from 'react';
2
+ export var ResizeHandle = function ResizeHandle(props) {
3
+ return /*#__PURE__*/React.createElement("div", Object.assign({
4
+ className: "ant-design-draggable-modal-resize-handle"
5
+ }, props), /*#__PURE__*/React.createElement("div", {
6
+ className: "ant-design-draggable-modal-resize-handle-inner"
7
+ }));
8
+ };
@@ -0,0 +1 @@
1
+ export declare const clamp: (min: number, max: number, value: number) => number;
@@ -0,0 +1,3 @@
1
+ export var clamp = function clamp(min, max, value) {
2
+ return Math.max(min, Math.min(max, value));
3
+ };
@@ -0,0 +1,66 @@
1
+ export declare type ModalID = string;
2
+ export interface ModalState {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ zIndex: number;
8
+ visible: boolean;
9
+ }
10
+ export interface ModalsState {
11
+ maxZIndex: number;
12
+ windowSize: {
13
+ width: number;
14
+ height: number;
15
+ };
16
+ modals: {
17
+ [key: string]: ModalState;
18
+ };
19
+ }
20
+ export declare const initialModalsState: ModalsState;
21
+ export declare const initialModalState: ModalState;
22
+ export declare type Action = {
23
+ type: 'show';
24
+ id: ModalID;
25
+ } | {
26
+ type: 'hide';
27
+ id: ModalID;
28
+ } | {
29
+ type: 'focus';
30
+ id: ModalID;
31
+ } | {
32
+ type: 'unmount';
33
+ id: ModalID;
34
+ } | {
35
+ type: 'mount';
36
+ id: ModalID;
37
+ intialState: {
38
+ initialWidth?: number;
39
+ initialHeight?: number;
40
+ };
41
+ } | {
42
+ type: 'windowResize';
43
+ size: {
44
+ width: number;
45
+ height: number;
46
+ };
47
+ } | {
48
+ type: 'drag';
49
+ id: ModalID;
50
+ x: number;
51
+ y: number;
52
+ } | {
53
+ type: 'resize';
54
+ id: ModalID;
55
+ x: number;
56
+ y: number;
57
+ width: number;
58
+ height: number;
59
+ };
60
+ export declare const getModalState: ({ state, id, initialWidth, initialHeight, }: {
61
+ state: ModalsState;
62
+ id: ModalID;
63
+ initialWidth?: number;
64
+ initialHeight?: number;
65
+ }) => ModalState;
66
+ export declare const draggableModalReducer: (state: ModalsState, action: Action) => ModalsState;
@@ -0,0 +1,157 @@
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 _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; }
3
+ function _toPropertyKey(arg) { var key = _toPrimitive(arg, "string"); return _typeof(key) === "symbol" ? key : String(key); }
4
+ function _toPrimitive(input, hint) { if (_typeof(input) !== "object" || input === null) return input; var prim = input[Symbol.toPrimitive]; if (prim !== undefined) { var res = prim.call(input, hint || "default"); if (_typeof(res) !== "object") return res; throw new TypeError("@@toPrimitive must return a primitive value."); } return (hint === "string" ? String : Number)(input); }
5
+ function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
6
+ function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
7
+ 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); }
8
+ function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
9
+ function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
10
+ 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; }
11
+ import { getWindowSize } from './getWindowSize';
12
+ import { clamp } from './clamp';
13
+ var mapObject = function mapObject(o, f) {
14
+ return Object.assign.apply(Object, [{}].concat(_toConsumableArray(Object.keys(o).map(function (k) {
15
+ return _defineProperty({}, k, f(o[k]));
16
+ }))));
17
+ };
18
+ export var initialModalsState = {
19
+ maxZIndex: 0,
20
+ windowSize: getWindowSize(),
21
+ modals: {}
22
+ };
23
+ export var initialModalState = {
24
+ x: 0,
25
+ y: 0,
26
+ width: 800,
27
+ height: 800,
28
+ zIndex: 0,
29
+ visible: false
30
+ };
31
+ var getInitialModalState = function getInitialModalState(_ref2) {
32
+ var _ref2$initialWidth = _ref2.initialWidth,
33
+ initialWidth = _ref2$initialWidth === void 0 ? initialModalState.width : _ref2$initialWidth,
34
+ _ref2$initialHeight = _ref2.initialHeight,
35
+ initialHeight = _ref2$initialHeight === void 0 ? initialModalState.height : _ref2$initialHeight;
36
+ return Object.assign(Object.assign({}, initialModalState), {
37
+ width: initialWidth,
38
+ height: initialHeight
39
+ });
40
+ };
41
+ export var getModalState = function getModalState(_ref3) {
42
+ var state = _ref3.state,
43
+ id = _ref3.id,
44
+ initialWidth = _ref3.initialWidth,
45
+ initialHeight = _ref3.initialHeight;
46
+ return state.modals[id] || getInitialModalState({
47
+ initialWidth: initialWidth,
48
+ initialHeight: initialHeight
49
+ });
50
+ };
51
+ var getNextZIndex = function getNextZIndex(state, id) {
52
+ return getModalState({
53
+ state: state,
54
+ id: id
55
+ }).zIndex === state.maxZIndex ? state.maxZIndex : state.maxZIndex + 1;
56
+ };
57
+ var clampDrag = function clampDrag(windowWidth, windowHeight, x, y, width, height) {
58
+ var maxX = windowWidth - width;
59
+ var maxY = windowHeight - height;
60
+ var clampedX = clamp(0, maxX, x);
61
+ var clampedY = clamp(0, maxY, y);
62
+ return {
63
+ x: clampedX,
64
+ y: clampedY
65
+ };
66
+ };
67
+ var clampResize = function clampResize(windowWidth, windowHeight, x, y, width, height) {
68
+ var maxWidth = windowWidth - x;
69
+ var maxHeight = windowHeight - y;
70
+ var clampedWidth = clamp(200, maxWidth, width);
71
+ var clampedHeight = clamp(200, maxHeight, height);
72
+ return {
73
+ width: clampedWidth,
74
+ height: clampedHeight
75
+ };
76
+ };
77
+ export var draggableModalReducer = function draggableModalReducer(state, action) {
78
+ switch (action.type) {
79
+ case 'resize':
80
+ var size = clampResize(state.windowSize.width, state.windowSize.height, action.x, action.y, action.width, action.height);
81
+ return Object.assign(Object.assign({}, state), {
82
+ maxZIndex: getNextZIndex(state, action.id),
83
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign(Object.assign({}, state.modals[action.id]), size), {
84
+ zIndex: getNextZIndex(state, action.id)
85
+ })))
86
+ });
87
+ case 'drag':
88
+ return Object.assign(Object.assign({}, state), {
89
+ maxZIndex: getNextZIndex(state, action.id),
90
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign(Object.assign({}, state.modals[action.id]), clampDrag(state.windowSize.width, state.windowSize.height, action.x, action.y, state.modals[action.id].width, state.modals[action.id].height)), {
91
+ zIndex: getNextZIndex(state, action.id)
92
+ })))
93
+ });
94
+ case 'show':
95
+ {
96
+ var _modalState = state.modals[action.id];
97
+ var centerX = state.windowSize.width / 2 - _modalState.width / 2;
98
+ var centerY = state.windowSize.height / 2 - _modalState.height / 2;
99
+ var position = clampDrag(state.windowSize.width, state.windowSize.height, centerX, centerY, _modalState.width, _modalState.height);
100
+ var _size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, _modalState.width, _modalState.height);
101
+ return Object.assign(Object.assign({}, state), {
102
+ maxZIndex: state.maxZIndex + 1,
103
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign(Object.assign(Object.assign({}, _modalState), position), _size), {
104
+ zIndex: state.maxZIndex + 1,
105
+ visible: true
106
+ })))
107
+ });
108
+ }
109
+ case 'focus':
110
+ var modalState = state.modals[action.id];
111
+ return Object.assign(Object.assign({}, state), {
112
+ maxZIndex: state.maxZIndex + 1,
113
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign({}, modalState), {
114
+ zIndex: state.maxZIndex + 1
115
+ })))
116
+ });
117
+ case 'hide':
118
+ {
119
+ var _modalState2 = state.modals[action.id];
120
+ return Object.assign(Object.assign({}, state), {
121
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign({}, _modalState2), {
122
+ visible: false
123
+ })))
124
+ });
125
+ }
126
+ case 'mount':
127
+ var initialState = getInitialModalState(action.intialState);
128
+ return Object.assign(Object.assign({}, state), {
129
+ maxZIndex: state.maxZIndex + 1,
130
+ modals: Object.assign(Object.assign({}, state.modals), _defineProperty({}, action.id, Object.assign(Object.assign({}, initialState), {
131
+ x: state.windowSize.width / 2 - initialState.width / 2,
132
+ y: state.windowSize.height / 2 - initialState.height / 2,
133
+ zIndex: state.maxZIndex + 1
134
+ })))
135
+ });
136
+ case 'unmount':
137
+ var modalsClone = Object.assign({}, state.modals);
138
+ delete modalsClone[action.id];
139
+ return Object.assign(Object.assign({}, state), {
140
+ modals: modalsClone
141
+ });
142
+ case 'windowResize':
143
+ return Object.assign(Object.assign({}, state), {
144
+ windowSize: action.size,
145
+ modals: mapObject(state.modals, function (modalState) {
146
+ if (!modalState.visible) {
147
+ return modalState;
148
+ }
149
+ var position = clampDrag(state.windowSize.width, state.windowSize.height, modalState.x, modalState.y, modalState.width, modalState.height);
150
+ var size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, modalState.width, modalState.height);
151
+ return Object.assign(Object.assign(Object.assign({}, modalState), position), size);
152
+ })
153
+ });
154
+ default:
155
+ throw new Error();
156
+ }
157
+ };
@@ -0,0 +1,4 @@
1
+ export declare const getWindowSize: () => {
2
+ width: number;
3
+ height: number;
4
+ };
@@ -0,0 +1,6 @@
1
+ export var getWindowSize = function getWindowSize() {
2
+ return {
3
+ width: window.innerWidth || 0,
4
+ height: window.innerHeight || 0
5
+ };
6
+ };
@@ -1,11 +1,3 @@
1
- import React from 'react';
2
- import 'ant-design-draggable-modal/dist/index.css';
3
- interface StandardDragModalProps {
4
- visible: boolean;
5
- title?: string | React.ReactNode;
6
- initialWidth?: number;
7
- initialHeight?: number;
8
- [k: string]: any;
9
- }
10
- declare const StandardDragModal: (props: StandardDragModalProps) => JSX.Element;
11
- export default StandardDragModal;
1
+ export * from './DraggableModal';
2
+ export * from './DraggableModalContext';
3
+ export * from './DraggableModalProvider';
@@ -1,30 +1,3 @@
1
- import { __rest } from "tslib";
2
- import React from 'react';
3
- import { DraggableModal, DraggableModalProvider } from 'ant-design-draggable-modal';
4
- import 'ant-design-draggable-modal/dist/index.css';
5
-
6
- var StandardDragModal = function StandardDragModal(props) {
7
- var visible = props.visible,
8
- onCancel = props.onCancel,
9
- onSubmit = props.onSubmit,
10
- children = props.children,
11
- others = __rest(props, ["visible", "onCancel", "onSubmit", "children"]);
12
-
13
- var handleOk = function handleOk() {
14
- onSubmit && onSubmit();
15
- };
16
-
17
- var handleCancel = function handleCancel() {
18
- onCancel && onCancel();
19
- };
20
-
21
- return /*#__PURE__*/React.createElement(DraggableModalProvider, null, /*#__PURE__*/React.createElement(DraggableModal, Object.assign({
22
- visible: visible,
23
- onOk: handleOk,
24
- onCancel: handleCancel
25
- }, others, {
26
- zIndex: 1001
27
- }), children));
28
- };
29
-
30
- export default StandardDragModal;
1
+ export * from './DraggableModal';
2
+ export * from './DraggableModalContext';
3
+ export * from './DraggableModalProvider';
@@ -0,0 +1,65 @@
1
+ /**
2
+ * NOTE: This is not compiled.
3
+ */
4
+
5
+ .ant-design-draggable-modal {
6
+ pointer-events: none;
7
+ overflow: hidden !important;
8
+ }
9
+
10
+ .ant-design-draggable-modal .ant-modal {
11
+ display: flex;
12
+ max-width: none;
13
+ transform-origin: 50% 50% !important;
14
+ }
15
+
16
+ .ant-design-draggable-modal .ant-modal-content {
17
+ flex: 1;
18
+ display: flex;
19
+ flex-direction: column;
20
+ }
21
+
22
+ .ant-design-draggable-modal .ant-modal-header {
23
+ flex: 0;
24
+ padding: 0;
25
+ }
26
+
27
+ .ant-design-draggable-modal .ant-modal-footer {
28
+ flex: 0;
29
+ padding: 16px;
30
+ }
31
+
32
+ .ant-design-draggable-modal .ant-design-draggable-modal-title {
33
+ cursor: move;
34
+ padding: 16px;
35
+ }
36
+
37
+ .ant-design-draggable-modal .ant-design-draggable-modal-title::before {
38
+ content: '\00a0';
39
+ }
40
+
41
+ .ant-design-draggable-modal .ant-modal-body {
42
+ flex: 1;
43
+ overflow-y: auto;
44
+ padding: 16px;
45
+ }
46
+
47
+ .ant-design-draggable-modal-resize-handle-inner {
48
+ width: 12px;
49
+ right: 14px;
50
+ border: 2px solid grey;
51
+ height: 12px;
52
+ bottom: 14px;
53
+ position: absolute;
54
+ border-top: 0;
55
+ border-left: 0;
56
+ }
57
+
58
+ .ant-design-draggable-modal-resize-handle {
59
+ right: -10px;
60
+ width: 44px;
61
+ bottom: -10px;
62
+ cursor: se-resize;
63
+ height: 44px;
64
+ position: absolute;
65
+ }
@@ -0,0 +1,5 @@
1
+ import * as React from 'react';
2
+ export declare const useDrag: (x: number, y: number, onDrag: (args: {
3
+ x: number;
4
+ y: number;
5
+ }) => void) => (e: React.MouseEvent) => void;
@@ -0,0 +1,66 @@
1
+ function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
2
+ 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."); }
3
+ 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); }
4
+ 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; }
5
+ 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; } }
6
+ function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
+ import { useState, useEffect, useCallback } from 'react';
8
+ export var useDrag = function useDrag(x, y, onDrag) {
9
+ var _useState = useState(false),
10
+ _useState2 = _slicedToArray(_useState, 2),
11
+ dragging = _useState2[0],
12
+ setDragging = _useState2[1];
13
+ var _useState3 = useState({
14
+ initX: 0,
15
+ initY: 0,
16
+ mouseDownX: 0,
17
+ mouseDownY: 0
18
+ }),
19
+ _useState4 = _slicedToArray(_useState3, 2),
20
+ initialDragState = _useState4[0],
21
+ setInitialDragState = _useState4[1];
22
+ var onMouseDown = useCallback(function (e) {
23
+ e.preventDefault();
24
+ setInitialDragState({
25
+ initX: x,
26
+ initY: y,
27
+ mouseDownX: e.clientX,
28
+ mouseDownY: e.clientY
29
+ });
30
+ setDragging(true);
31
+ }, [x, y, setDragging, setInitialDragState]);
32
+ useEffect(function () {
33
+ var onMouseMove = function onMouseMove(e) {
34
+ if (dragging) {
35
+ var initX = initialDragState.initX,
36
+ mouseDownX = initialDragState.mouseDownX,
37
+ initY = initialDragState.initY,
38
+ mouseDownY = initialDragState.mouseDownY;
39
+ var dx = e.clientX - mouseDownX;
40
+ var dy = e.clientY - mouseDownY;
41
+ var _x = initX + dx;
42
+ var _y = initY + dy;
43
+ onDrag({
44
+ x: _x,
45
+ y: _y
46
+ });
47
+ }
48
+ };
49
+ window.addEventListener('mousemove', onMouseMove, {
50
+ passive: true
51
+ });
52
+ return function () {
53
+ return window.removeEventListener('mousemove', onMouseMove);
54
+ };
55
+ }, [initialDragState, dragging, onDrag]);
56
+ useEffect(function () {
57
+ var onMouseUp = function onMouseUp() {
58
+ setDragging(false);
59
+ };
60
+ window.addEventListener('mouseup', onMouseUp);
61
+ return function () {
62
+ return window.removeEventListener('mouseup', onMouseUp);
63
+ };
64
+ }, [setDragging]);
65
+ return onMouseDown;
66
+ };
@@ -0,0 +1 @@
1
+ export declare const usePrevious: <T>(value: T) => T;
@@ -0,0 +1,8 @@
1
+ import { useRef, useEffect } from 'react';
2
+ export var usePrevious = function usePrevious(value) {
3
+ var ref = useRef(value);
4
+ useEffect(function () {
5
+ ref.current = value;
6
+ }, [value]);
7
+ return ref.current;
8
+ };
@@ -0,0 +1,7 @@
1
+ import * as React from 'react';
2
+ export declare const useResize: (x: number, y: number, width: number, height: number, onResize: (args: {
3
+ x: number;
4
+ y: number;
5
+ width: number;
6
+ height: number;
7
+ }) => void) => (e: React.MouseEvent) => void;