fan-standard-comp 3.2.1 → 3.2.3
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.
- package/Readme.md +2 -32
- package/dist/09cd8e9be7081f2166444cce393fe968.svg +54 -0
- package/dist/e3378c145b7db195ad068735e15fb28a.svg +165 -0
- package/dist/fan-standard-comp.umd.js +183 -439
- package/dist/fonts/iconfont.ttf +0 -0
- package/dist/fonts/iconfont.woff +0 -0
- package/dist/fonts/lg.ttf +0 -0
- package/dist/fonts/lg.woff +0 -0
- package/dist/fonts/lg.woff2 +0 -0
- package/es/ButtonGroup/ButtonList.d.ts +2 -1
- package/es/ButtonGroup/ButtonMenu.d.ts +2 -1
- package/es/ButtonGroup/PopConfirmTitle.js +5 -5
- package/es/ButtonGroup/index.d.ts +3 -1
- package/es/ButtonGroup/index.js +146 -180
- package/es/ButtonGroup/style/index.less +4 -1
- package/es/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
- package/es/CalendarCoordPicker/CalendarMonthPicker.js +26 -0
- package/es/CalendarCoordPicker/index.d.ts +8 -0
- package/es/CalendarCoordPicker/index.js +296 -0
- package/es/CalendarCoordPicker/index.less +31 -0
- package/es/ConfigContext/index.d.ts +7 -0
- package/es/ConfigContext/index.js +12 -0
- package/es/DragContent/index.d.ts +1 -1
- package/es/DragContent/index.js +5 -5
- package/es/FormComp/ChunkUploader/api.js +14 -14
- package/es/FormComp/ChunkUploader/index.js +132 -139
- package/es/FormComp/ChunkUploader/lib.js +21 -21
- package/es/FormComp/ChunkUploader/upload-queue.class.js +64 -66
- package/es/FormComp/EditButton/index.d.ts +1 -1
- package/es/FormComp/EditButton/index.js +15 -17
- package/es/FormComp/FieldComponent/ReUpload.d.ts +1 -1
- package/es/FormComp/FieldComponent/ReUpload.js +37 -23
- package/es/FormComp/FieldComponent/RefactorTextarea.js +32 -0
- package/es/FormComp/FieldComponent/RefactorTreeSelect.js +72 -19
- package/es/FormComp/FieldComponent/TitleNode.d.ts +2 -1
- package/es/FormComp/FieldComponent/index.d.ts +1 -1
- package/es/FormComp/FieldComponent/index.js +37 -26
- package/es/FormComp/FieldComponent/setReadonlyValues.js +6 -6
- package/es/FormComp/RenderItemGroup/index.js +24 -8
- package/es/FormComp/Uploader/index.d.ts +9 -2
- package/es/FormComp/Uploader/index.js +325 -156
- package/es/FormComp/VarTemplate/index.js +57 -64
- package/es/ImageGallery/ImagePreview.d.ts +13 -0
- package/es/ImageGallery/ImagePreview.js +168 -0
- package/es/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
- package/es/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
- package/es/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
- package/es/ImageGallery/PreviewStyles/lg-video.css +144 -0
- package/es/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
- package/es/ImageGallery/PreviewStyles/lightgallery.css +728 -0
- package/es/ImageGallery/SliderContent.d.ts +7 -0
- package/es/ImageGallery/SliderContent.js +699 -0
- package/es/ImageGallery/Thumbnail.d.ts +3 -0
- package/es/ImageGallery/Thumbnail.js +296 -0
- package/es/ImageGallery/hook/uniqueId.d.ts +1 -0
- package/es/ImageGallery/hook/uniqueId.js +10 -0
- package/es/ImageGallery/index.d.ts +4 -0
- package/es/ImageGallery/index.js +29 -0
- package/es/ImageGallery/style/index.less +5 -0
- package/es/ImageGallery/types.d.ts +5 -0
- package/es/ImageGallery/types.js +1 -0
- package/es/NavLeafScroll/index.js +94 -50
- package/es/RefactorTree/index.d.ts +1 -1
- package/es/RefactorTree/index.js +6 -6
- package/es/RefactorTree/indexTreeNode.d.ts +1 -1
- package/es/RefactorTree/indexTreeNode.js +19 -17
- package/es/RefactorTree/util.js +18 -18
- package/es/SpecIcon/fonts/demo_index.html +559 -5
- package/es/SpecIcon/fonts/iconfont.css +101 -3
- package/es/SpecIcon/fonts/iconfont.js +34 -27
- package/es/SpecIcon/fonts/iconfont.json +168 -0
- package/es/SpecIcon/fonts/iconfont.svg +163 -171
- package/es/SpecIcon/fonts/iconfont.ttf +0 -0
- package/es/SpecIcon/fonts/iconfont.woff +0 -0
- package/es/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/es/SpecIcon/style/iconfont.less +106 -11
- package/es/SplitterLayout/Pane.d.ts +1 -1
- package/es/SplitterLayout/index.js +25 -26
- package/es/StandardContent/SplitterLayout/Pane.js +3 -3
- package/es/StandardContent/SplitterLayout/index.js +25 -26
- package/es/StandardContent/SubfieldContent.d.ts +1 -1
- package/es/StandardContent/WrapperContent.d.ts +1 -1
- package/es/StandardDragModal/index.d.ts +11 -3
- package/es/StandardDragModal/index.js +25 -3
- package/es/StandardFilter/index.d.ts +5 -16
- package/es/StandardFilter/index.js +212 -200
- package/es/StandardFilter/indexClass.d.ts +37 -0
- package/es/StandardFilter/indexClass.js +217 -0
- package/es/StandardFilter/style/index.less +82 -9
- package/es/StandardForm/StepForm.d.ts +1 -1
- package/es/StandardForm/StepForm.js +28 -22
- package/es/StandardForm/TabForm.d.ts +1 -1
- package/es/StandardForm/TabForm.js +41 -43
- package/es/StandardForm/index.d.ts +1 -1
- package/es/StandardForm/index.js +5 -5
- package/es/StandardModal/UpdateFormRef.js +0 -1
- package/es/StandardModal/index.d.ts +2 -1
- package/es/StandardModal/index.js +25 -39
- package/es/StandardPanel/index.d.ts +1 -1
- package/es/StandardPanel/index.js +7 -7
- package/es/StandardTable/index.d.ts +1 -0
- package/es/StandardTable/index.js +44 -26
- package/es/components/IconNode/index.d.ts +1 -1
- package/es/components/IconNode/index.js +0 -1
- package/es/data/general.config.js +31 -0
- package/es/index.d.ts +3 -1
- package/es/index.js +6 -2
- package/es/utils/filterPermission.js +7 -10
- package/es/utils/getParentNodes.js +101 -26
- package/es/utils/index.js +2 -3
- package/es/utils/urlUtils.js +76 -0
- package/lib/ButtonGroup/ButtonList.d.ts +2 -1
- package/lib/ButtonGroup/ButtonList.js +2 -3
- package/lib/ButtonGroup/ButtonMenu.d.ts +2 -1
- package/lib/ButtonGroup/ButtonMenu.js +2 -3
- package/lib/ButtonGroup/PopConfirmTitle.js +7 -8
- package/lib/ButtonGroup/index.d.ts +3 -1
- package/lib/ButtonGroup/index.js +150 -185
- package/lib/ButtonGroup/style/index.less +4 -1
- package/lib/CalendarCoordPicker/CalendarMonthPicker.d.ts +5 -0
- package/lib/CalendarCoordPicker/CalendarMonthPicker.js +36 -0
- package/lib/CalendarCoordPicker/index.d.ts +8 -0
- package/lib/CalendarCoordPicker/index.js +305 -0
- package/lib/CalendarCoordPicker/index.less +31 -0
- package/lib/ConfigContext/index.d.ts +7 -0
- package/lib/ConfigContext/index.js +17 -0
- package/lib/DragContent/DragBar.js +2 -3
- package/lib/DragContent/index.d.ts +1 -1
- package/lib/DragContent/index.js +9 -10
- package/lib/FormComp/ChunkUploader/api.js +15 -15
- package/lib/FormComp/ChunkUploader/index.js +135 -142
- package/lib/FormComp/ChunkUploader/lib.js +22 -22
- package/lib/FormComp/ChunkUploader/upload-queue.class.js +66 -69
- package/lib/FormComp/ChunkUploader/worker.js +1 -1
- package/lib/FormComp/EditButton/index.d.ts +1 -1
- package/lib/FormComp/EditButton/index.js +19 -22
- package/lib/FormComp/FieldComponent/ReUpload.d.ts +1 -1
- package/lib/FormComp/FieldComponent/ReUpload.js +40 -28
- package/lib/FormComp/FieldComponent/RefactorTextarea.js +42 -0
- package/lib/FormComp/FieldComponent/RefactorTreeSelect.js +75 -23
- package/lib/FormComp/FieldComponent/TitleNode.d.ts +2 -1
- package/lib/FormComp/FieldComponent/TitleNode.js +2 -3
- package/lib/FormComp/FieldComponent/index.d.ts +1 -1
- package/lib/FormComp/FieldComponent/index.js +41 -28
- package/lib/FormComp/FieldComponent/setReadonlyValues.js +15 -20
- package/lib/FormComp/RenderItemGroup/index.js +26 -11
- package/lib/FormComp/Uploader/index.d.ts +9 -2
- package/lib/FormComp/Uploader/index.js +325 -159
- package/lib/FormComp/VarTemplate/index.js +63 -71
- package/lib/FormComp/index.js +1 -1
- package/lib/ImageGallery/ImagePreview.d.ts +13 -0
- package/lib/ImageGallery/ImagePreview.js +178 -0
- package/lib/ImageGallery/PreviewStyles/ImagePreview.less +730 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.svg +54 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.ttf +0 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.woff +0 -0
- package/lib/ImageGallery/PreviewStyles/fonts/lg.woff2 +0 -0
- package/lib/ImageGallery/PreviewStyles/lg-thumbnail.css +108 -0
- package/lib/ImageGallery/PreviewStyles/lg-video.css +144 -0
- package/lib/ImageGallery/PreviewStyles/lg-zoom.css +116 -0
- package/lib/ImageGallery/PreviewStyles/lightgallery.css +728 -0
- package/lib/ImageGallery/SliderContent.d.ts +7 -0
- package/lib/ImageGallery/SliderContent.js +708 -0
- package/lib/ImageGallery/Thumbnail.d.ts +3 -0
- package/lib/ImageGallery/Thumbnail.js +306 -0
- package/lib/ImageGallery/hook/uniqueId.d.ts +1 -0
- package/lib/ImageGallery/hook/uniqueId.js +17 -0
- package/lib/ImageGallery/index.d.ts +4 -0
- package/lib/ImageGallery/index.js +36 -0
- package/lib/ImageGallery/style/index.less +5 -0
- package/lib/ImageGallery/types.d.ts +5 -0
- package/lib/ImageGallery/types.js +5 -0
- package/lib/NavLeafScroll/index.js +98 -55
- package/lib/RefactorTree/index.d.ts +1 -1
- package/lib/RefactorTree/index.js +10 -11
- package/lib/RefactorTree/indexTreeNode.d.ts +1 -1
- package/lib/RefactorTree/indexTreeNode.js +23 -22
- package/lib/RefactorTree/util.js +18 -18
- package/lib/SpecIcon/fonts/demo_index.html +559 -5
- package/lib/SpecIcon/fonts/iconfont.css +101 -3
- package/lib/SpecIcon/fonts/iconfont.js +34 -27
- package/lib/SpecIcon/fonts/iconfont.json +168 -0
- package/lib/SpecIcon/fonts/iconfont.svg +163 -171
- package/lib/SpecIcon/fonts/iconfont.ttf +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff +0 -0
- package/lib/SpecIcon/fonts/iconfont.woff2 +0 -0
- package/lib/SpecIcon/index.js +2 -3
- package/lib/SpecIcon/style/iconfont.less +106 -11
- package/lib/SplitterLayout/Pane.d.ts +1 -1
- package/lib/SplitterLayout/Pane.js +2 -3
- package/lib/SplitterLayout/index.js +27 -29
- package/lib/StandardContent/SplitterLayout/Pane.js +5 -6
- package/lib/StandardContent/SplitterLayout/index.js +27 -29
- package/lib/StandardContent/SubfieldContent.d.ts +1 -1
- package/lib/StandardContent/SubfieldContent.js +2 -3
- package/lib/StandardContent/WrapperContent.d.ts +1 -1
- package/lib/StandardContent/WrapperContent.js +2 -3
- package/lib/StandardDragModal/index.d.ts +11 -3
- package/lib/StandardDragModal/index.js +27 -33
- package/lib/StandardFilter/index.d.ts +5 -16
- package/lib/StandardFilter/index.js +215 -201
- package/lib/StandardFilter/indexClass.d.ts +37 -0
- package/lib/StandardFilter/indexClass.js +223 -0
- package/lib/StandardFilter/style/index.less +82 -9
- package/lib/StandardForm/ActionList.js +2 -3
- package/lib/StandardForm/StepForm.d.ts +1 -1
- package/lib/StandardForm/StepForm.js +32 -27
- package/lib/StandardForm/TabForm.d.ts +1 -1
- package/lib/StandardForm/TabForm.js +45 -48
- package/lib/StandardForm/index.d.ts +1 -1
- package/lib/StandardForm/index.js +9 -10
- package/lib/StandardModal/UpdateFormRef.js +3 -4
- package/lib/StandardModal/index.d.ts +2 -1
- package/lib/StandardModal/index.js +29 -43
- package/lib/StandardPanel/index.d.ts +1 -1
- package/lib/StandardPanel/index.js +11 -12
- package/lib/StandardTable/index.d.ts +1 -0
- package/lib/StandardTable/index.js +49 -29
- package/lib/components/IconNode/index.d.ts +1 -1
- package/lib/components/IconNode/index.js +2 -4
- package/lib/components/index.js +1 -1
- package/lib/data/func.code.js +2 -3
- package/lib/data/general.config.js +33 -3
- package/lib/data/index.js +1 -1
- package/lib/index.d.ts +3 -1
- package/lib/index.js +30 -10
- package/lib/utils/ValueFormat.js +1 -2
- package/lib/utils/filterPermission.js +11 -18
- package/lib/utils/getParentNodes.js +103 -29
- package/lib/utils/index.js +5 -27
- package/lib/utils/urlUtils.js +82 -0
- package/package.json +15 -9
- package/dist/f26952c118ab6cdcd23dc0028ee98c11.svg +0 -173
- package/dist/fonts/iconfont.eot +0 -0
- package/es/StandardDragModal/ChangeStandardModal.d.ts +0 -44
- package/es/StandardDragModal/ChangeStandardModal.js +0 -493
- package/es/StandardDragModal/DraggableModal.d.ts +0 -7
- package/es/StandardDragModal/DraggableModal.js +0 -31
- package/es/StandardDragModal/DraggableModalContext.d.ts +0 -9
- package/es/StandardDragModal/DraggableModalContext.js +0 -5
- package/es/StandardDragModal/DraggableModalInner.d.ts +0 -16
- package/es/StandardDragModal/DraggableModalInner.js +0 -114
- package/es/StandardDragModal/DraggableModalProvider.d.ts +0 -4
- package/es/StandardDragModal/DraggableModalProvider.js +0 -40
- package/es/StandardDragModal/Modal.d.ts +0 -11
- package/es/StandardDragModal/Modal.js +0 -24
- package/es/StandardDragModal/ResizeHandle.d.ts +0 -2
- package/es/StandardDragModal/ResizeHandle.js +0 -8
- package/es/StandardDragModal/clamp.d.ts +0 -1
- package/es/StandardDragModal/clamp.js +0 -3
- package/es/StandardDragModal/draggableModalReducer.d.ts +0 -66
- package/es/StandardDragModal/draggableModalReducer.js +0 -157
- package/es/StandardDragModal/getWindowSize.d.ts +0 -4
- package/es/StandardDragModal/getWindowSize.js +0 -6
- package/es/StandardDragModal/index.less +0 -65
- package/es/StandardDragModal/useDrag.d.ts +0 -5
- package/es/StandardDragModal/useDrag.js +0 -66
- package/es/StandardDragModal/usePrevious.d.ts +0 -1
- package/es/StandardDragModal/usePrevious.js +0 -8
- package/es/StandardDragModal/useResize.d.ts +0 -7
- package/es/StandardDragModal/useResize.js +0 -74
- package/es/utils/dictSelectUtil.js +0 -153
- package/lib/StandardDragModal/ChangeStandardModal.d.ts +0 -44
- package/lib/StandardDragModal/ChangeStandardModal.js +0 -502
- package/lib/StandardDragModal/DraggableModal.d.ts +0 -7
- package/lib/StandardDragModal/DraggableModal.js +0 -40
- package/lib/StandardDragModal/DraggableModalContext.d.ts +0 -9
- package/lib/StandardDragModal/DraggableModalContext.js +0 -15
- package/lib/StandardDragModal/DraggableModalInner.d.ts +0 -16
- package/lib/StandardDragModal/DraggableModalInner.js +0 -124
- package/lib/StandardDragModal/DraggableModalProvider.d.ts +0 -4
- package/lib/StandardDragModal/DraggableModalProvider.js +0 -48
- package/lib/StandardDragModal/Modal.d.ts +0 -11
- package/lib/StandardDragModal/Modal.js +0 -32
- package/lib/StandardDragModal/ResizeHandle.d.ts +0 -2
- package/lib/StandardDragModal/ResizeHandle.js +0 -18
- package/lib/StandardDragModal/clamp.d.ts +0 -1
- package/lib/StandardDragModal/clamp.js +0 -10
- package/lib/StandardDragModal/draggableModalReducer.d.ts +0 -66
- package/lib/StandardDragModal/draggableModalReducer.js +0 -167
- package/lib/StandardDragModal/getWindowSize.d.ts +0 -4
- package/lib/StandardDragModal/getWindowSize.js +0 -13
- package/lib/StandardDragModal/index.less +0 -65
- package/lib/StandardDragModal/useDrag.d.ts +0 -5
- package/lib/StandardDragModal/useDrag.js +0 -73
- package/lib/StandardDragModal/usePrevious.d.ts +0 -1
- package/lib/StandardDragModal/usePrevious.js +0 -15
- package/lib/StandardDragModal/useResize.d.ts +0 -7
- package/lib/StandardDragModal/useResize.js +0 -81
- package/lib/utils/dictSelectUtil.js +0 -161
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
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
|
-
};
|
|
@@ -1,11 +0,0 @@
|
|
|
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;
|
|
@@ -1,24 +0,0 @@
|
|
|
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;
|
|
@@ -1,8 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const clamp: (min: number, max: number, value: number) => number;
|
|
@@ -1,66 +0,0 @@
|
|
|
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;
|
|
@@ -1,157 +0,0 @@
|
|
|
1
|
-
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
2
|
-
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
|
-
};
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,66 +0,0 @@
|
|
|
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
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export declare const usePrevious: <T>(value: T) => T;
|
|
@@ -1,74 +0,0 @@
|
|
|
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 useResize = function useResize(x, y, width, height, onResize) {
|
|
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
|
-
initWidth: 0,
|
|
17
|
-
initHeight: 0,
|
|
18
|
-
mouseDownX: 0,
|
|
19
|
-
mouseDownY: 0
|
|
20
|
-
}),
|
|
21
|
-
_useState4 = _slicedToArray(_useState3, 2),
|
|
22
|
-
initialDragState = _useState4[0],
|
|
23
|
-
setInitialDragState = _useState4[1];
|
|
24
|
-
var onMouseDown = useCallback(function (e) {
|
|
25
|
-
e.preventDefault();
|
|
26
|
-
setInitialDragState({
|
|
27
|
-
initX: x,
|
|
28
|
-
initY: y,
|
|
29
|
-
initWidth: width,
|
|
30
|
-
initHeight: height,
|
|
31
|
-
mouseDownX: e.clientX,
|
|
32
|
-
mouseDownY: e.clientY
|
|
33
|
-
});
|
|
34
|
-
setDragging(true);
|
|
35
|
-
}, [width, height, setDragging, setInitialDragState, x, y]);
|
|
36
|
-
useEffect(function () {
|
|
37
|
-
var onMouseMove = function onMouseMove(e) {
|
|
38
|
-
if (dragging) {
|
|
39
|
-
var initX = initialDragState.initX,
|
|
40
|
-
initY = initialDragState.initY,
|
|
41
|
-
initWidth = initialDragState.initWidth,
|
|
42
|
-
mouseDownX = initialDragState.mouseDownX,
|
|
43
|
-
initHeight = initialDragState.initHeight,
|
|
44
|
-
mouseDownY = initialDragState.mouseDownY;
|
|
45
|
-
var dx = e.clientX - mouseDownX;
|
|
46
|
-
var dy = e.clientY - mouseDownY;
|
|
47
|
-
var _width = initWidth + dx;
|
|
48
|
-
var _height = initHeight + dy;
|
|
49
|
-
return onResize({
|
|
50
|
-
x: initX,
|
|
51
|
-
y: initY,
|
|
52
|
-
width: _width,
|
|
53
|
-
height: _height
|
|
54
|
-
});
|
|
55
|
-
}
|
|
56
|
-
};
|
|
57
|
-
window.addEventListener('mousemove', onMouseMove, {
|
|
58
|
-
passive: true
|
|
59
|
-
});
|
|
60
|
-
return function () {
|
|
61
|
-
return window.removeEventListener('mousemove', onMouseMove);
|
|
62
|
-
};
|
|
63
|
-
}, [initialDragState, dragging, onResize]);
|
|
64
|
-
useEffect(function () {
|
|
65
|
-
var onMouseUp = function onMouseUp() {
|
|
66
|
-
setDragging(false);
|
|
67
|
-
};
|
|
68
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
69
|
-
return function () {
|
|
70
|
-
return window.removeEventListener('mouseup', onMouseUp);
|
|
71
|
-
};
|
|
72
|
-
}, [setDragging]);
|
|
73
|
-
return onMouseDown;
|
|
74
|
-
};
|