d2coreui 21.0.33 → 23.0.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.
- package/components/clipboard/clipboardUtils.d.ts +4 -3
- package/components/clipboard/clipboardUtils.js +47 -22
- package/components/clipboard/clipboardUtils.js.map +1 -1
- package/components/codemirror/SyntaxHighlighter.d.ts +21 -21
- package/components/codemirror/SyntaxHighlighter.js +45 -44
- package/components/codemirror/SyntaxHighlighter.js.map +1 -1
- package/components/collapse/expandable.d.ts +13 -12
- package/components/collapse/expandable.js +20 -20
- package/components/collapse/expandable.js.map +1 -1
- package/components/color/colorPicker.d.ts +20 -20
- package/components/color/colorPicker.js +53 -53
- package/components/color/colorPicker.js.map +1 -1
- package/components/color/colorSwatch.d.ts +13 -12
- package/components/color/colorSwatch.js +62 -62
- package/components/color/colorSwatch.js.map +1 -1
- package/components/color/colorUtils.d.ts +7 -7
- package/components/color/colorUtils.js +43 -43
- package/components/color/colorUtils.js.map +1 -1
- package/components/date/dateRangeInput.d.ts +66 -64
- package/components/date/dateRangeInput.js +292 -297
- package/components/date/dateRangeInput.js.map +1 -1
- package/components/date/dateRangeInputAdvancedPanel.d.ts +27 -26
- package/components/date/dateRangeInputAdvancedPanel.js +130 -115
- package/components/date/dateRangeInputAdvancedPanel.js.map +1 -1
- package/components/date/dateRangeInputConfirm.d.ts +31 -29
- package/components/date/dateRangeInputConfirm.js +132 -121
- package/components/date/dateRangeInputConfirm.js.map +1 -1
- package/components/date/dateTimeInput.d.ts +72 -69
- package/components/date/dateTimeInput.js +440 -412
- package/components/date/dateTimeInput.js.map +1 -1
- package/components/date/durationInput.d.ts +59 -56
- package/components/date/durationInput.js +269 -280
- package/components/date/durationInput.js.map +1 -1
- package/components/form/NiceFormItem.d.ts +14 -14
- package/components/form/NiceFormItem.js +28 -31
- package/components/form/NiceFormItem.js.map +1 -1
- package/components/grid/cell/beanAccessor.d.ts +9 -0
- package/components/grid/cell/beanAccessor.js +13 -0
- package/components/grid/cell/beanAccessor.js.map +1 -0
- package/components/grid/cell/cellEditorUtils.d.ts +4 -4
- package/components/grid/cell/cellEditorUtils.js +8 -8
- package/components/grid/cell/customEnumCellEditor.d.ts +4 -26
- package/components/grid/cell/customEnumCellEditor.js +82 -91
- package/components/grid/cell/customEnumCellEditor.js.map +1 -1
- package/components/grid/cell/dataGridCellEditorComponent.d.ts +14 -0
- package/components/grid/cell/dataGridCellEditorComponent.js +49 -0
- package/components/grid/cell/dataGridCellEditorComponent.js.map +1 -0
- package/components/grid/cell/dateCellEditor.d.ts +4 -25
- package/components/grid/cell/dateCellEditor.js +53 -72
- package/components/grid/cell/dateCellEditor.js.map +1 -1
- package/components/grid/cell/durationCellEditor.d.ts +4 -24
- package/components/grid/cell/durationCellEditor.js +74 -97
- package/components/grid/cell/durationCellEditor.js.map +1 -1
- package/components/grid/cell/hexaOctetStringCellEditor.d.ts +4 -24
- package/components/grid/cell/hexaOctetStringCellEditor.js +70 -94
- package/components/grid/cell/hexaOctetStringCellEditor.js.map +1 -1
- package/components/grid/cell/hexaValueCellEditor.d.ts +4 -24
- package/components/grid/cell/hexaValueCellEditor.js +65 -89
- package/components/grid/cell/hexaValueCellEditor.js.map +1 -1
- package/components/grid/cell/numberCellEditor.d.ts +4 -27
- package/components/grid/cell/numberCellEditor.js +73 -95
- package/components/grid/cell/numberCellEditor.js.map +1 -1
- package/components/grid/cell/rangeSelector.d.ts +78 -78
- package/components/grid/cell/rangeSelector.js +526 -518
- package/components/grid/cell/rangeSelector.js.map +1 -1
- package/components/grid/cell/simpleStatusTextCellEditor.d.ts +4 -32
- package/components/grid/cell/simpleStatusTextCellEditor.js +106 -116
- package/components/grid/cell/simpleStatusTextCellEditor.js.map +1 -1
- package/components/grid/cell/statusTextCellEditor.d.ts +4 -32
- package/components/grid/cell/statusTextCellEditor.js +136 -159
- package/components/grid/cell/statusTextCellEditor.js.map +1 -1
- package/components/grid/cell/tableDefaultRowStyleRules.d.ts +20 -20
- package/components/grid/cell/tableDefaultRowStyleRules.js +29 -18
- package/components/grid/cell/tableDefaultRowStyleRules.js.map +1 -1
- package/components/grid/cell/textCellEditor.d.ts +4 -21
- package/components/grid/cell/textCellEditor.js +63 -85
- package/components/grid/cell/textCellEditor.js.map +1 -1
- package/components/grid/cell/withAgGridHooks.d.ts +3 -0
- package/components/grid/cell/withAgGridHooks.js +15 -0
- package/components/grid/cell/withAgGridHooks.js.map +1 -0
- package/components/grid/columnUtils.d.ts +5 -5
- package/components/grid/columnUtils.js +26 -26
- package/components/grid/columnUtils.js.map +1 -1
- package/components/grid/config/columnTransfer.d.ts +21 -22
- package/components/grid/config/columnTransfer.js +205 -201
- package/components/grid/config/columnTransfer.js.map +1 -1
- package/components/grid/config/dataGridEditor.d.ts +41 -41
- package/components/grid/config/dataGridEditor.js +181 -160
- package/components/grid/config/dataGridEditor.js.map +1 -1
- package/components/grid/config/rowHeightCalculator.d.ts +8 -0
- package/components/grid/config/rowHeightCalculator.js +20 -0
- package/components/grid/config/rowHeightCalculator.js.map +1 -0
- package/components/grid/config/rowStylePicker.d.ts +27 -25
- package/components/grid/config/rowStylePicker.js +127 -109
- package/components/grid/config/rowStylePicker.js.map +1 -1
- package/components/grid/dataGrid.d.ts +218 -206
- package/components/grid/dataGrid.js +1629 -1538
- package/components/grid/dataGrid.js.map +1 -1
- package/components/grid/detail/detailHeaderPanel.d.ts +13 -13
- package/components/grid/detail/detailHeaderPanel.js +25 -25
- package/components/grid/detail/detailHeaderPanel.js.map +1 -1
- package/components/grid/export/contextMenu.d.ts +18 -24
- package/components/grid/export/contextMenu.js +116 -113
- package/components/grid/export/contextMenu.js.map +1 -1
- package/components/grid/export/progressPopup.d.ts +29 -29
- package/components/grid/export/progressPopup.js +93 -93
- package/components/grid/export/progressPopup.js.map +1 -1
- package/components/grid/export/worker/clipboardExport.d.ts +1 -1
- package/components/grid/export/worker/clipboardExport.js +8 -8
- package/components/grid/export/worker/csvExport.d.ts +1 -1
- package/components/grid/export/worker/csvExport.js +8 -8
- package/components/grid/export/worker/pdfExport.d.ts +1 -1
- package/components/grid/export/worker/pdfExport.js +81 -81
- package/components/grid/export/worker/pdfExport.js.map +1 -1
- package/components/grid/export/worker/txtExport.d.ts +1 -1
- package/components/grid/export/worker/txtExport.js +19 -19
- package/components/grid/extendedDataGrid.d.ts +140 -140
- package/components/grid/extendedDataGrid.js +704 -695
- package/components/grid/extendedDataGrid.js.map +1 -1
- package/components/grid/filter/customColumnFilter.d.ts +5 -21
- package/components/grid/filter/customColumnFilter.js +11 -82
- package/components/grid/filter/customColumnFilter.js.map +1 -1
- package/components/grid/filter/dataGridColumnFilter.d.ts +17 -0
- package/components/grid/filter/dataGridColumnFilter.js +49 -0
- package/components/grid/filter/dataGridColumnFilter.js.map +1 -0
- package/components/grid/filter/dateColumnFilter.d.ts +7 -11
- package/components/grid/filter/dateColumnFilter.js +22 -56
- package/components/grid/filter/dateColumnFilter.js.map +1 -1
- package/components/grid/filter/textColumnFilter.d.ts +8 -20
- package/components/grid/filter/textColumnFilter.js +24 -76
- package/components/grid/filter/textColumnFilter.js.map +1 -1
- package/components/grid/filter/wildcardQuickFilterEngine.d.ts +7 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js +48 -0
- package/components/grid/filter/wildcardQuickFilterEngine.js.map +1 -0
- package/components/grid/header/simpleHeader.d.ts +17 -16
- package/components/grid/header/simpleHeader.js +230 -186
- package/components/grid/header/simpleHeader.js.map +1 -1
- package/components/grid/panel/dataGridPagination.d.ts +16 -16
- package/components/grid/panel/dataGridPagination.js +58 -58
- package/components/grid/panel/dataGridPagination.js.map +1 -1
- package/components/grid/panel/loadingOverlay.d.ts +6 -6
- package/components/grid/panel/loadingOverlay.js +10 -10
- package/components/grid/panel/loadingOverlay.js.map +1 -1
- package/components/grid/panel/noRecordsOverlay.d.ts +6 -6
- package/components/grid/panel/noRecordsOverlay.js +10 -10
- package/components/grid/panel/noRecordsOverlay.js.map +1 -1
- package/components/grid/panel/tablePagination.d.ts +10 -10
- package/components/grid/panel/tablePagination.js +45 -45
- package/components/grid/panel/tablePagination.js.map +1 -1
- package/components/icons/dropdownArrow.d.ts +8 -0
- package/components/icons/dropdownArrow.js +59 -0
- package/components/icons/dropdownArrow.js.map +1 -0
- package/components/icons/undoIcon.d.ts +8 -8
- package/components/icons/undoIcon.js +6 -6
- package/components/input/autoCompleteInput.d.ts +35 -35
- package/components/input/autoCompleteInput.js +122 -121
- package/components/input/autoCompleteInput.js.map +1 -1
- package/components/input/draftUtils.d.ts +4 -4
- package/components/input/draftUtils.js +48 -48
- package/components/input/draftUtils.js.map +1 -1
- package/components/input/draftail.d.ts +1 -1
- package/components/input/draftail.js +1 -1
- package/components/input/hexaFormattedInput.d.ts +16 -16
- package/components/input/hexaFormattedInput.js +54 -54
- package/components/input/hexaFormattedInput.js.map +1 -1
- package/components/input/mask/helpers.d.ts +28 -28
- package/components/input/mask/helpers.js +112 -112
- package/components/input/mask/helpers.js.map +1 -1
- package/components/input/mask/inputMaskCore.d.ts +46 -46
- package/components/input/mask/inputMaskCore.js +278 -278
- package/components/input/mask/inputMaskCore.js.map +1 -1
- package/components/input/mask/pattern.d.ts +20 -20
- package/components/input/mask/pattern.js +78 -78
- package/components/input/mask/pattern.js.map +1 -1
- package/components/input/maskedInput.d.ts +373 -351
- package/components/input/maskedInput.js +224 -224
- package/components/input/maskedInput.js.map +1 -1
- package/components/input/passwordInput.d.ts +9 -9
- package/components/input/passwordInput.js +55 -55
- package/components/input/passwordInput.js.map +1 -1
- package/components/input/simpleAutoComplete.d.ts +12 -12
- package/components/input/simpleAutoComplete.js +41 -43
- package/components/input/simpleAutoComplete.js.map +1 -1
- package/components/input/textarea/extractSpansOfClasses.d.ts +15 -15
- package/components/input/textarea/extractSpansOfClasses.js +96 -96
- package/components/input/textarea/extractSpansOfClasses.js.map +1 -1
- package/components/input/textarea/getRanges.d.ts +1 -1
- package/components/input/textarea/getRanges.js +73 -73
- package/components/input/textarea/getRanges.js.map +1 -1
- package/components/input/textarea/getType.d.ts +1 -1
- package/components/input/textarea/getType.js +26 -26
- package/components/input/textarea/getType.js.map +1 -1
- package/components/input/textarea/highlighedContents.d.ts +6 -6
- package/components/input/textarea/highlighedContents.js +10 -10
- package/components/input/textarea/mentionsWithHighlighting.d.ts +27 -27
- package/components/input/textarea/mentionsWithHighlighting.js +60 -60
- package/components/input/textarea/mentionsWithHighlighting.js.map +1 -1
- package/components/keyboard/keyboardUtils.d.ts +5 -5
- package/components/keyboard/keyboardUtils.js +32 -32
- package/components/modal/draggableModalProvider.d.ts +4 -4
- package/components/modal/draggableModalProvider.js +21 -21
- package/components/modal/draggableModalProvider.js.map +1 -1
- package/components/modal/impl/clamp.d.ts +1 -1
- package/components/modal/impl/clamp.js +1 -1
- package/components/modal/impl/clamp.js.map +1 -1
- package/components/modal/impl/draggableModal.d.ts +12 -12
- package/components/modal/impl/draggableModal.js +17 -17
- package/components/modal/impl/draggableModal.js.map +1 -1
- package/components/modal/impl/draggableModalContext.d.ts +9 -9
- package/components/modal/impl/draggableModalContext.js +2 -2
- package/components/modal/impl/draggableModalContext.js.map +1 -1
- package/components/modal/impl/draggableModalInner.d.ts +15 -13
- package/components/modal/impl/draggableModalInner.js +57 -55
- package/components/modal/impl/draggableModalInner.js.map +1 -1
- package/components/modal/impl/draggableModalReducer.d.ts +66 -62
- package/components/modal/impl/draggableModalReducer.js +77 -78
- package/components/modal/impl/draggableModalReducer.js.map +1 -1
- package/components/modal/impl/getWindowSize.d.ts +4 -4
- package/components/modal/impl/getWindowSize.js +4 -4
- package/components/modal/impl/getWindowSize.js.map +1 -1
- package/components/modal/impl/index.d.ts +3 -3
- package/components/modal/impl/index.js +3 -3
- package/components/modal/impl/index.js.map +1 -1
- package/components/modal/impl/resizeHandle.d.ts +3 -3
- package/components/modal/impl/resizeHandle.js +4 -4
- package/components/modal/impl/resizeHandle.js.map +1 -1
- package/components/modal/impl/useDrag.d.ts +5 -5
- package/components/modal/impl/useDrag.js +42 -42
- package/components/modal/impl/useDrag.js.map +1 -1
- package/components/modal/impl/usePrevious.d.ts +1 -1
- package/components/modal/impl/usePrevious.js +8 -8
- package/components/modal/impl/usePrevious.js.map +1 -1
- package/components/modal/impl/useResize.d.ts +7 -7
- package/components/modal/impl/useResize.js +46 -46
- package/components/modal/impl/useResize.js.map +1 -1
- package/components/modal/modalDialog.d.ts +49 -49
- package/components/modal/modalDialog.js +152 -152
- package/components/modal/modalDialog.js.map +1 -1
- package/components/picker/enumValuePicker.d.ts +16 -16
- package/components/picker/enumValuePicker.js +34 -34
- package/components/picker/enumValuePicker.js.map +1 -1
- package/components/platformSpecific.d.ts +10 -10
- package/components/platformSpecific.js +27 -27
- package/components/scrollTo/onlyText.d.ts +4 -4
- package/components/scrollTo/onlyText.js +30 -30
- package/components/scrollTo/onlyText.js.map +1 -1
- package/components/scrollTo/scrollTo.d.ts +41 -39
- package/components/scrollTo/scrollTo.js +264 -264
- package/components/scrollTo/scrollTo.js.map +1 -1
- package/components/style/withCss.d.ts +9 -0
- package/components/style/withCss.js +6 -0
- package/components/style/withCss.js.map +1 -0
- package/components/style/withInputNumberCss.d.ts +6 -0
- package/components/style/withInputNumberCss.js +13 -0
- package/components/style/withInputNumberCss.js.map +1 -0
- package/components/table/dragSortingTable.d.ts +13 -14
- package/components/table/dragSortingTable.js +96 -82
- package/components/table/dragSortingTable.js.map +1 -1
- package/components/text/impl/innerSize.d.ts +2 -2
- package/components/text/impl/innerSize.js +12 -12
- package/components/text/impl/series.d.ts +1 -1
- package/components/text/impl/series.js +28 -28
- package/components/text/impl/shallowEqual.d.ts +1 -1
- package/components/text/impl/shallowEqual.js +18 -18
- package/components/text/impl/shallowEqual.js.map +1 -1
- package/components/text/impl/uniqueId.d.ts +1 -1
- package/components/text/impl/uniqueId.js +4 -4
- package/components/text/impl/whilst.d.ts +1 -1
- package/components/text/impl/whilst.js +19 -19
- package/components/text/impl/whilst.js.map +1 -1
- package/components/text/textFit.d.ts +38 -38
- package/components/text/textFit.js +165 -168
- package/components/text/textFit.js.map +1 -1
- package/i18n/components.cs.json +101 -100
- package/i18n/components.sk.json +101 -100
- package/i18n/components.uk.json +101 -100
- package/i18n/componentsLocaleHolder.d.ts +3 -3
- package/i18n/componentsLocaleHolder.js +28 -28
- package/i18n/componentsLocaleHolder.js.map +1 -1
- package/package.json +71 -70
- package/style/index.less +274 -298
- package/style/modal/DraggableModal.css +43 -40
- package/style/modal/ResizeHandle.css +27 -19
- package/tsconfig.build.json +24 -24
- package/tsconfig.json +11 -11
- package/components/grid/cell/wildcardQuickFilter.d.ts +0 -11
- package/components/grid/cell/wildcardQuickFilter.js +0 -61
- package/components/grid/cell/wildcardQuickFilter.js.map +0 -1
- package/components/table/dataTable.d.ts +0 -17
- package/components/table/dataTable.js +0 -79
- package/components/table/dataTable.js.map +0 -1
- package/style/antd/antd-tree-showline.css +0 -25
- package/style/antd/full-height-tabs.scss +0 -63
- package/style/draftail/draftail-editor.css +0 -179
- package/style/table/dragSortingTable.css +0 -7
|
@@ -1,79 +1,78 @@
|
|
|
1
|
-
import { getWindowSize } from './getWindowSize';
|
|
2
|
-
import { clamp } from './clamp';
|
|
3
|
-
const mapObject = (o, f) => Object.assign({}, ...Object.keys(o).map(k => ({ [k]: f(o[k]) })));
|
|
4
|
-
export const initialModalsState = {
|
|
5
|
-
maxZIndex: 0,
|
|
6
|
-
windowSize: getWindowSize(),
|
|
7
|
-
modals: {},
|
|
8
|
-
};
|
|
9
|
-
export const initialModalState = {
|
|
10
|
-
x: 0,
|
|
11
|
-
y: 0,
|
|
12
|
-
width: 400,
|
|
13
|
-
height: 400,
|
|
14
|
-
zIndex: 0,
|
|
15
|
-
visible: false,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
width: initialWidth
|
|
19
|
-
|
|
20
|
-
});
|
|
21
|
-
|
|
22
|
-
const
|
|
23
|
-
const
|
|
24
|
-
const
|
|
25
|
-
const
|
|
26
|
-
const
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
const
|
|
32
|
-
const
|
|
33
|
-
const
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
const
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
};
|
|
1
|
+
import { getWindowSize } from './getWindowSize';
|
|
2
|
+
import { clamp } from './clamp';
|
|
3
|
+
const mapObject = (o, f) => Object.assign({}, ...Object.keys(o).map(k => ({ [k]: f(o[k]) })));
|
|
4
|
+
export const initialModalsState = {
|
|
5
|
+
maxZIndex: 0,
|
|
6
|
+
windowSize: getWindowSize(),
|
|
7
|
+
modals: {},
|
|
8
|
+
};
|
|
9
|
+
export const initialModalState = {
|
|
10
|
+
x: 0,
|
|
11
|
+
y: 0,
|
|
12
|
+
width: 400,
|
|
13
|
+
height: 400,
|
|
14
|
+
zIndex: 0,
|
|
15
|
+
visible: false,
|
|
16
|
+
};
|
|
17
|
+
const getInitialModalState = ({ initialWidth = initialModalState.width, initialHeight = initialModalState.height, }) => {
|
|
18
|
+
return Object.assign(Object.assign({}, initialModalState), { width: initialWidth, height: initialHeight });
|
|
19
|
+
};
|
|
20
|
+
export const getModalState = ({ state, id, initialWidth, initialHeight, }) => state.modals[id] || getInitialModalState({ initialWidth, initialHeight });
|
|
21
|
+
const getNextZIndex = (state, id) => getModalState({ state, id }).zIndex === state.maxZIndex ? state.maxZIndex : state.maxZIndex + 1;
|
|
22
|
+
const clampDrag = (windowWidth, windowHeight, x, y, width, height) => {
|
|
23
|
+
const maxX = windowWidth - width;
|
|
24
|
+
const maxY = windowHeight - height;
|
|
25
|
+
const clampedX = clamp(0, maxX, x);
|
|
26
|
+
const clampedY = clamp(0, maxY, y);
|
|
27
|
+
return { x: clampedX, y: clampedY };
|
|
28
|
+
};
|
|
29
|
+
const clampResize = (windowWidth, windowHeight, x, y, width, height) => {
|
|
30
|
+
const maxWidth = windowWidth - x;
|
|
31
|
+
const maxHeight = windowHeight - y;
|
|
32
|
+
const clampedWidth = clamp(200, maxWidth, width);
|
|
33
|
+
const clampedHeight = clamp(200, maxHeight, height);
|
|
34
|
+
return { width: clampedWidth, height: clampedHeight };
|
|
35
|
+
};
|
|
36
|
+
export const draggableModalReducer = (state, action) => {
|
|
37
|
+
switch (action.type) {
|
|
38
|
+
case 'resize':
|
|
39
|
+
const size = clampResize(state.windowSize.width, state.windowSize.height, action.x, action.y, action.width, action.height);
|
|
40
|
+
return Object.assign(Object.assign({}, state), { maxZIndex: getNextZIndex(state, action.id), modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign({}, state.modals[action.id]), size), { zIndex: getNextZIndex(state, action.id) }) }) });
|
|
41
|
+
case 'drag':
|
|
42
|
+
return Object.assign(Object.assign({}, state), { maxZIndex: getNextZIndex(state, action.id), modals: Object.assign(Object.assign({}, state.modals), { [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)), { zIndex: getNextZIndex(state, action.id) }) }) });
|
|
43
|
+
case 'show': {
|
|
44
|
+
const modalState = state.modals[action.id];
|
|
45
|
+
const centerX = state.windowSize.width / 2 - modalState.width / 2;
|
|
46
|
+
const centerY = state.windowSize.height / 2 - modalState.height / 2;
|
|
47
|
+
const position = clampDrag(state.windowSize.width, state.windowSize.height, centerX, centerY, modalState.width, modalState.height);
|
|
48
|
+
const size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, modalState.width, modalState.height);
|
|
49
|
+
return Object.assign(Object.assign({}, state), { maxZIndex: state.maxZIndex + 1, modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign(Object.assign(Object.assign({}, modalState), position), size), { zIndex: state.maxZIndex + 1, visible: true }) }) });
|
|
50
|
+
}
|
|
51
|
+
case 'focus':
|
|
52
|
+
const modalState = state.modals[action.id];
|
|
53
|
+
return Object.assign(Object.assign({}, state), { maxZIndex: state.maxZIndex + 1, modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign({}, modalState), { zIndex: state.maxZIndex + 1 }) }) });
|
|
54
|
+
case 'hide': {
|
|
55
|
+
const modalState = state.modals[action.id];
|
|
56
|
+
return Object.assign(Object.assign({}, state), { modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign({}, modalState), { visible: false }) }) });
|
|
57
|
+
}
|
|
58
|
+
case 'mount':
|
|
59
|
+
const initialState = getInitialModalState(action.intialState);
|
|
60
|
+
return Object.assign(Object.assign({}, state), { maxZIndex: state.maxZIndex + 1, modals: Object.assign(Object.assign({}, state.modals), { [action.id]: Object.assign(Object.assign({}, initialState), { x: state.windowSize.width / 2 - initialState.width / 2, y: state.windowSize.height / 2 - initialState.height / 2, zIndex: state.maxZIndex + 1 }) }) });
|
|
61
|
+
case 'unmount':
|
|
62
|
+
const modalsClone = Object.assign({}, state.modals);
|
|
63
|
+
delete modalsClone[action.id];
|
|
64
|
+
return Object.assign(Object.assign({}, state), { modals: modalsClone });
|
|
65
|
+
case 'windowResize':
|
|
66
|
+
return Object.assign(Object.assign({}, state), { windowSize: action.size, modals: mapObject(state.modals, (modalState) => {
|
|
67
|
+
if (!modalState.visible) {
|
|
68
|
+
return modalState;
|
|
69
|
+
}
|
|
70
|
+
const position = clampDrag(state.windowSize.width, state.windowSize.height, modalState.x, modalState.y, modalState.width, modalState.height);
|
|
71
|
+
const size = clampResize(state.windowSize.width, state.windowSize.height, position.x, position.y, modalState.width, modalState.height);
|
|
72
|
+
return Object.assign(Object.assign(Object.assign({}, modalState), position), size);
|
|
73
|
+
}) });
|
|
74
|
+
default:
|
|
75
|
+
throw new Error();
|
|
76
|
+
}
|
|
77
|
+
};
|
|
79
78
|
//# sourceMappingURL=draggableModalReducer.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draggableModalReducer.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalReducer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAI,CAAuB,EAAE,CAAkB,EAAwB,EAAE,CACvF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;AA2BnE,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC3C,SAAS,EAAE,CAAC;IACZ,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAe;IACzC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,KAAK;CACjB,CAAC;AAmBF,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,KAAkB,EAAE,EAAW,E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,CAAC;YAC9B,uCACO,KAAK,KACR,MAAM,EAAE,WAAW,IACrB;QACN,KAAK,cAAc;YACf,uCACO,KAAK,KACR,UAAU,EAAE,MAAM,CAAC,IAAI,EACvB,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;oBACvD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE;wBACrB,OAAO,UAAU,CAAA;qBACpB;oBACD,MAAM,QAAQ,GAAG,SAAS,CACtB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,MAAM,IAAI,GAAG,WAAW,CACpB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,qDACO,UAAU,GACV,QAAQ,GACR,IAAI,EACV;gBACL,CAAC,CAAC,IACL;QACL;YACI,MAAM,IAAI,KAAK,EAAE,CAAA;KACxB;AACL,CAAC,CAAA","sourcesContent":["import {getWindowSize} from './getWindowSize'\nimport {clamp} from './clamp'\n\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\n\n// ID for a specific modal.\nexport type ModalID = string\n\n// State for a specific modal.\nexport interface ModalState {\n x: number\n y: number\n width: number\n height: number\n zIndex: number\n visible: boolean\n}\n\n// State of all modals.\nexport interface ModalsState {\n maxZIndex: number\n windowSize: {\n width: number\n height: number\n }\n modals: {\n [key: string]: ModalState\n }\n}\n\nexport const initialModalsState: ModalsState = {\n maxZIndex: 0,\n windowSize: getWindowSize(),\n modals: {},\n};\n\nexport const initialModalState: ModalState = {\n x: 0,\n y: 0,\n width: 400,\n height: 400,\n zIndex: 0,\n visible: false,\n};\n\nexport type Action =\n | { type: 'show'; id: ModalID }\n | { type: 'hide'; id: ModalID }\n | { type: 'focus'; id: ModalID }\n | { type: 'unmount'; id: ModalID }\n | { type: 'mount'; id: ModalID, size: { width?: number; height?: number } }\n | { type: 'windowResize'; size: { width: number; height: number } }\n | { type: 'drag'; id: ModalID; x: number; y: number }\n | {\n type: 'resize'\n id: ModalID\n x: number\n y: number\n width: number\n height: number\n}\n\nexport const getOrCreateModalState = (state: ModalsState, id: ModalID, initialWidth: number | undefined, initialHeight: number | undefined): ModalState =>\n state.modals[id] || Object.assign({}, initialModalState, {\n width: initialWidth ? initialWidth : 400,\n height: initialHeight ? initialHeight : 400\n });\n\nexport const getModalState = (state: ModalsState, id: ModalID): ModalState =>\n state.modals[id] || initialModalState;\n\nconst getNextZIndex = (state: ModalsState, id: string): number =>\n getModalState(state, id).zIndex === state.maxZIndex ? state.maxZIndex : state.maxZIndex + 1;\n\nconst clampDrag = (\n windowWidth: number,\n windowHeight: number,\n x: number,\n y: number,\n width: number,\n height: number,\n): { x: number; y: number } => {\n const maxX = windowWidth - width;\n const maxY = windowHeight - height;\n const clampedX = clamp(0, maxX, x);\n const clampedY = clamp(0, maxY, y);\n return {x: clampedX, y: clampedY}\n}\n\nconst clampResize = (\n windowWidth: number,\n windowHeight: number,\n x: number,\n y: number,\n width: number,\n height: number,\n): { width: number; height: number } => {\n const maxWidth = windowWidth - x;\n const maxHeight = windowHeight - y;\n const clampedWidth = clamp(200, maxWidth, width);\n const clampedHeight = clamp(200, maxHeight, height);\n return {width: clampedWidth, height: clampedHeight}\n}\n\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\n switch (action.type) {\n case 'resize':\n const size = clampResize(\n state.windowSize.width,\n state.windowSize.height,\n action.x,\n action.y,\n action.width,\n action.height,\n )\n return {\n ...state,\n maxZIndex: getNextZIndex(state, action.id),\n modals: {\n ...state.modals,\n [action.id]: {\n ...state.modals[action.id],\n ...size,\n zIndex: getNextZIndex(state, action.id),\n },\n },\n }\n case 'drag':\n return {\n ...state,\n maxZIndex: getNextZIndex(state, action.id),\n modals: {\n ...state.modals,\n [action.id]: {\n ...state.modals[action.id],\n ...clampDrag(\n state.windowSize.width,\n state.windowSize.height,\n action.x,\n action.y,\n state.modals[action.id].width,\n state.modals[action.id].height,\n ),\n zIndex: getNextZIndex(state, action.id),\n },\n },\n }\n case 'show': {\n const modalState = state.modals[action.id]\n const centerX = state.windowSize.width / 2 - modalState.width / 2\n const centerY = state.windowSize.height / 2 - modalState.height / 2\n const position = clampDrag(\n state.windowSize.width,\n state.windowSize.height,\n centerX,\n centerY,\n modalState.width,\n modalState.height,\n )\n const size = clampResize(\n state.windowSize.width,\n state.windowSize.height,\n position.x,\n position.y,\n modalState.width,\n modalState.height,\n )\n return {\n ...state,\n maxZIndex: state.maxZIndex + 1,\n modals: {\n ...state.modals,\n [action.id]: {\n ...modalState,\n ...position,\n ...size,\n zIndex: state.maxZIndex + 1,\n visible: true,\n },\n },\n }\n }\n case 'focus':\n const modalState = state.modals[action.id]\n return {\n ...state,\n maxZIndex: state.maxZIndex + 1,\n modals: {\n ...state.modals,\n [action.id]: {\n ...modalState,\n zIndex: state.maxZIndex + 1,\n },\n },\n }\n case 'hide': {\n const modalState = state.modals[action.id]\n return {\n ...state,\n modals: {\n ...state.modals,\n [action.id]: {\n ...modalState,\n visible: false,\n },\n },\n }\n }\n case 'mount':\n const initialState = Object.assign({}, initialModalState, action.size);\n return {\n ...state,\n maxZIndex: state.maxZIndex + 1,\n modals: {\n ...state.modals,\n [action.id]: {\n ...initialState,\n x: state.windowSize.width / 2 - initialState.width / 2,\n y: state.windowSize.height / 2 - initialState.height / 2,\n zIndex: state.maxZIndex + 1,\n },\n },\n };\n case 'unmount':\n const modalsClone = {...state.modals};\n delete modalsClone[action.id];\n return {\n ...state,\n modals: modalsClone,\n };\n case 'windowResize':\n return {\n ...state,\n windowSize: action.size,\n modals: mapObject(state.modals, (modalState: ModalState) => {\n if (!modalState.visible) {\n return modalState\n }\n const position = clampDrag(\n state.windowSize.width,\n state.windowSize.height,\n modalState.x,\n modalState.y,\n modalState.width,\n modalState.height,\n )\n const size = clampResize(\n state.windowSize.width,\n state.windowSize.height,\n position.x,\n position.y,\n modalState.width,\n modalState.height,\n )\n return {\n ...modalState,\n ...position,\n ...size,\n }\n }),\n }\n default:\n throw new Error()\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"draggableModalReducer.js","sourceRoot":"","sources":["../../../../../components/modal/impl/draggableModalReducer.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,aAAa,EAAC,MAAM,iBAAiB,CAAA;AAC7C,OAAO,EAAC,KAAK,EAAC,MAAM,SAAS,CAAA;AAE7B,MAAM,SAAS,GAAG,CAAI,CAAuB,EAAE,CAAkB,EAAwB,EAAE,CACvF,MAAM,CAAC,MAAM,CAAC,EAAE,EAAE,GAAG,MAAM,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,EAAC,CAAC,CAAC,CAAC,CAAA;AA2BnE,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC3C,SAAS,EAAE,CAAC;IACZ,UAAU,EAAE,aAAa,EAAE;IAC3B,MAAM,EAAE,EAAE;CACb,CAAC;AAEF,MAAM,CAAC,MAAM,iBAAiB,GAAe;IACzC,CAAC,EAAE,CAAC;IACJ,CAAC,EAAE,CAAC;IACJ,KAAK,EAAE,GAAG;IACV,MAAM,EAAE,GAAG;IACX,MAAM,EAAE,CAAC;IACT,OAAO,EAAE,KAAK;CACjB,CAAC;AAEF,MAAM,oBAAoB,GAAG,CAAC,EACI,YAAY,GAAG,iBAAiB,CAAC,KAAK,EAC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,uCACO,KAAK,KACR,UAAU,EAAE,MAAM,CAAC,IAAI,EACvB,MAAM,EAAE,SAAS,CAAC,KAAK,CAAC,MAAM,EAAE,CAAC,UAAsB,EAAE,EAAE;oBACvD,IAAI,CAAC,UAAU,CAAC,OAAO,EAAE,CAAC;wBACtB,OAAO,UAAU,CAAA;oBACrB,CAAC;oBACD,MAAM,QAAQ,GAAG,SAAS,CACtB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,CAAC,EACZ,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,MAAM,IAAI,GAAG,WAAW,CACpB,KAAK,CAAC,UAAU,CAAC,KAAK,EACtB,KAAK,CAAC,UAAU,CAAC,MAAM,EACvB,QAAQ,CAAC,CAAC,EACV,QAAQ,CAAC,CAAC,EACV,UAAU,CAAC,KAAK,EAChB,UAAU,CAAC,MAAM,CACpB,CAAA;oBACD,qDACO,UAAU,GACV,QAAQ,GACR,IAAI,EACV;gBACL,CAAC,CAAC,IACL;QACL;YACI,MAAM,IAAI,KAAK,EAAE,CAAA;IACzB,CAAC;AACL,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {getWindowSize} from './getWindowSize'\r\nimport {clamp} from './clamp'\r\n\r\nconst mapObject = <T>(o: { [key: string]: T }, f: (value: T) => T): { [key: string]: T } =>\r\n Object.assign({}, ...Object.keys(o).map(k => ({[k]: f(o[k])})))\r\n\r\n// ID for a specific modal.\r\nexport type ModalID = string\r\n\r\n// State for a specific modal.\r\nexport interface ModalState {\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n zIndex: number\r\n visible: boolean\r\n}\r\n\r\n// State of all modals.\r\nexport interface ModalsState {\r\n maxZIndex: number\r\n windowSize: {\r\n width: number\r\n height: number\r\n }\r\n modals: {\r\n [key: string]: ModalState\r\n }\r\n}\r\n\r\nexport const initialModalsState: ModalsState = {\r\n maxZIndex: 0,\r\n windowSize: getWindowSize(),\r\n modals: {},\r\n};\r\n\r\nexport const initialModalState: ModalState = {\r\n x: 0,\r\n y: 0,\r\n width: 400,\r\n height: 400,\r\n zIndex: 0,\r\n visible: false,\r\n};\r\n\r\nconst getInitialModalState = ({\r\n initialWidth = initialModalState.width,\r\n initialHeight = initialModalState.height,\r\n }: {\r\n initialWidth?: number\r\n initialHeight?: number\r\n}) => {\r\n return {\r\n ...initialModalState,\r\n width: initialWidth,\r\n height: initialHeight,\r\n }\r\n}\r\n\r\nexport type Action =\r\n | { type: 'show'; id: ModalID }\r\n | { type: 'hide'; id: ModalID }\r\n | { type: 'focus'; id: ModalID }\r\n | { type: 'unmount'; id: ModalID }\r\n | { type: 'mount'; id: ModalID, intialState: { initialWidth?: number; initialHeight?: number } }\r\n | { type: 'windowResize'; size: { width: number; height: number } }\r\n | { type: 'drag'; id: ModalID; x: number; y: number }\r\n | {\r\n type: 'resize'\r\n id: ModalID\r\n x: number\r\n y: number\r\n width: number\r\n height: number\r\n}\r\n\r\nexport const getModalState = ({\r\n state,\r\n id,\r\n initialWidth,\r\n initialHeight,\r\n }: {\r\n state: ModalsState\r\n id: ModalID\r\n initialWidth?: number\r\n initialHeight?: number\r\n}): ModalState => state.modals[id] || getInitialModalState({ initialWidth, initialHeight })\r\n\r\nconst getNextZIndex = (state: ModalsState, id: string): number =>\r\n getModalState({state, id}).zIndex === state.maxZIndex ? state.maxZIndex : state.maxZIndex + 1;\r\n\r\nconst clampDrag = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { x: number; y: number } => {\r\n const maxX = windowWidth - width;\r\n const maxY = windowHeight - height;\r\n const clampedX = clamp(0, maxX, x);\r\n const clampedY = clamp(0, maxY, y);\r\n return {x: clampedX, y: clampedY}\r\n}\r\n\r\nconst clampResize = (\r\n windowWidth: number,\r\n windowHeight: number,\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n): { width: number; height: number } => {\r\n const maxWidth = windowWidth - x;\r\n const maxHeight = windowHeight - y;\r\n const clampedWidth = clamp(200, maxWidth, width);\r\n const clampedHeight = clamp(200, maxHeight, height);\r\n return {width: clampedWidth, height: clampedHeight}\r\n}\r\n\r\nexport const draggableModalReducer = (state: ModalsState, action: Action): ModalsState => {\r\n switch (action.type) {\r\n case 'resize':\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n action.width,\r\n action.height,\r\n )\r\n return {\r\n ...state,\r\n maxZIndex: getNextZIndex(state, action.id),\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...size,\r\n zIndex: getNextZIndex(state, action.id),\r\n },\r\n },\r\n }\r\n case 'drag':\r\n return {\r\n ...state,\r\n maxZIndex: getNextZIndex(state, action.id),\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...state.modals[action.id],\r\n ...clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n action.x,\r\n action.y,\r\n state.modals[action.id].width,\r\n state.modals[action.id].height,\r\n ),\r\n zIndex: getNextZIndex(state, action.id),\r\n },\r\n },\r\n }\r\n case 'show': {\r\n const modalState = state.modals[action.id]\r\n const centerX = state.windowSize.width / 2 - modalState.width / 2\r\n const centerY = state.windowSize.height / 2 - modalState.height / 2\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n centerX,\r\n centerY,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...state,\r\n maxZIndex: state.maxZIndex + 1,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n zIndex: state.maxZIndex + 1,\r\n visible: true,\r\n },\r\n },\r\n }\r\n }\r\n case 'focus':\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n maxZIndex: state.maxZIndex + 1,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n zIndex: state.maxZIndex + 1,\r\n },\r\n },\r\n }\r\n case 'hide': {\r\n const modalState = state.modals[action.id]\r\n return {\r\n ...state,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...modalState,\r\n visible: false,\r\n },\r\n },\r\n }\r\n }\r\n case 'mount':\r\n const initialState = getInitialModalState(action.intialState);\r\n return {\r\n ...state,\r\n maxZIndex: state.maxZIndex + 1,\r\n modals: {\r\n ...state.modals,\r\n [action.id]: {\r\n ...initialState,\r\n x: state.windowSize.width / 2 - initialState.width / 2,\r\n y: state.windowSize.height / 2 - initialState.height / 2,\r\n zIndex: state.maxZIndex + 1,\r\n },\r\n },\r\n };\r\n case 'unmount':\r\n const modalsClone = {...state.modals};\r\n delete modalsClone[action.id];\r\n return {\r\n ...state,\r\n modals: modalsClone,\r\n };\r\n case 'windowResize':\r\n return {\r\n ...state,\r\n windowSize: action.size,\r\n modals: mapObject(state.modals, (modalState: ModalState) => {\r\n if (!modalState.visible) {\r\n return modalState\r\n }\r\n const position = clampDrag(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n modalState.x,\r\n modalState.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n const size = clampResize(\r\n state.windowSize.width,\r\n state.windowSize.height,\r\n position.x,\r\n position.y,\r\n modalState.width,\r\n modalState.height,\r\n )\r\n return {\r\n ...modalState,\r\n ...position,\r\n ...size,\r\n }\r\n }),\r\n }\r\n default:\r\n throw new Error()\r\n }\r\n}\r\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const getWindowSize: () => {
|
|
2
|
-
width: number;
|
|
3
|
-
height: number;
|
|
4
|
-
};
|
|
1
|
+
export declare const getWindowSize: () => {
|
|
2
|
+
width: number;
|
|
3
|
+
height: number;
|
|
4
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export const getWindowSize = () => ({
|
|
2
|
-
width: window.innerWidth || 0,
|
|
3
|
-
height: window.innerHeight || 0,
|
|
4
|
-
});
|
|
1
|
+
export const getWindowSize = () => ({
|
|
2
|
+
width: window.innerWidth || 0,
|
|
3
|
+
height: window.innerHeight || 0,
|
|
4
|
+
});
|
|
5
5
|
//# sourceMappingURL=getWindowSize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getWindowSize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/getWindowSize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"getWindowSize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/getWindowSize.ts"],"names":[],"mappings":"AAEA,MAAM,CAAC,MAAM,aAAa,GAAG,GAAsC,EAAE,CAAC,CAAC;IACnE,KAAK,EAAE,MAAM,CAAC,UAAU,IAAI,CAAC;IAC7B,MAAM,EAAE,MAAM,CAAC,WAAW,IAAI,CAAC;CAClC,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nexport const getWindowSize = (): { width: number; height: number } => ({\r\n width: window.innerWidth || 0,\r\n height: window.innerHeight || 0,\r\n})\r\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export * from './draggableModal';
|
|
2
|
-
export * from './draggableModalContext';
|
|
3
|
-
export * from '../draggableModalProvider';
|
|
1
|
+
export * from './draggableModal';
|
|
2
|
+
export * from './draggableModalContext';
|
|
3
|
+
export * from '../draggableModalProvider';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export * from './draggableModal';
|
|
2
|
-
export * from './draggableModalContext';
|
|
3
|
-
export * from '../draggableModalProvider';
|
|
1
|
+
export * from './draggableModal';
|
|
2
|
+
export * from './draggableModalContext';
|
|
3
|
+
export * from '../draggableModalProvider';
|
|
4
4
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../components/modal/impl/index.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../components/modal/impl/index.ts"],"names":[],"mappings":"AAEA,cAAc,kBAAkB,CAAA;AAChC,cAAc,yBAAyB,CAAA;AACvC,cAAc,2BAA2B,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nexport * from './draggableModal'\r\nexport * from './draggableModalContext'\r\nexport * from '../draggableModalProvider'\r\n"]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import '../../../style/modal/ResizeHandle.css';
|
|
3
|
-
export declare const ResizeHandle: (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.ReactElement;
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '../../../style/modal/ResizeHandle.css';
|
|
3
|
+
export declare const ResizeHandle: (props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>) => React.ReactElement;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import * as React from 'react';
|
|
2
|
-
import '../../../style/modal/ResizeHandle.css';
|
|
3
|
-
export const ResizeHandle = (props) => (React.createElement("div", Object.assign({ className: "ant-design-draggable-modal-resize-handle" }, props),
|
|
4
|
-
React.createElement("div", { className: "ant-design-draggable-modal-resize-handle-inner" })));
|
|
1
|
+
import * as React from 'react';
|
|
2
|
+
import '../../../style/modal/ResizeHandle.css';
|
|
3
|
+
export const ResizeHandle = (props) => (React.createElement("div", Object.assign({ className: "ant-design-draggable-modal-resize-handle" }, props),
|
|
4
|
+
React.createElement("div", { className: "ant-design-draggable-modal-resize-handle-inner" })));
|
|
5
5
|
//# sourceMappingURL=resizeHandle.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"resizeHandle.js","sourceRoot":"","sources":["../../../../../components/modal/impl/resizeHandle.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"resizeHandle.js","sourceRoot":"","sources":["../../../../../components/modal/impl/resizeHandle.tsx"],"names":[],"mappings":"AAEA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAA;AAC9B,OAAO,uCAAuC,CAAA;AAE9C,MAAM,CAAC,MAAM,YAAY,GAAG,CACxB,KAAoF,EAClE,EAAE,CAAC,CACrB,2CAAK,SAAS,EAAC,0CAA0C,IAAK,KAAK;IAC/D,6BAAK,SAAS,EAAC,gDAAgD,GAAG,CAChE,CACT,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport '../../../style/modal/ResizeHandle.css'\r\n\r\nexport const ResizeHandle = (\r\n props: React.DetailedHTMLProps<React.HTMLAttributes<HTMLDivElement>, HTMLDivElement>,\r\n): React.ReactElement => (\r\n <div className=\"ant-design-draggable-modal-resize-handle\" {...props}>\r\n <div className=\"ant-design-draggable-modal-resize-handle-inner\" />\r\n </div>\r\n)\r\n"]}
|
|
@@ -1,5 +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;
|
|
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);
|
|
@@ -1,43 +1,43 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
export const useDrag = (x, y, onDrag) => {
|
|
3
|
-
const [dragging, setDragging] = useState(false);
|
|
4
|
-
const [initialDragState, setInitialDragState] = useState({
|
|
5
|
-
initX: 0,
|
|
6
|
-
initY: 0,
|
|
7
|
-
mouseDownX: 0,
|
|
8
|
-
mouseDownY: 0,
|
|
9
|
-
});
|
|
10
|
-
const onMouseDown = useCallback((e) => {
|
|
11
|
-
e.preventDefault();
|
|
12
|
-
setInitialDragState({
|
|
13
|
-
initX: x,
|
|
14
|
-
initY: y,
|
|
15
|
-
mouseDownX: e.clientX,
|
|
16
|
-
mouseDownY: e.clientY,
|
|
17
|
-
});
|
|
18
|
-
setDragging(true);
|
|
19
|
-
}, [x, y, setDragging, setInitialDragState]);
|
|
20
|
-
useEffect(() => {
|
|
21
|
-
const onMouseMove = (e) => {
|
|
22
|
-
if (dragging) {
|
|
23
|
-
const { initX, mouseDownX, initY, mouseDownY } = initialDragState;
|
|
24
|
-
let dx = e.clientX - mouseDownX;
|
|
25
|
-
let dy = e.clientY - mouseDownY;
|
|
26
|
-
const x = initX + dx;
|
|
27
|
-
const y = initY + dy;
|
|
28
|
-
onDrag({ x, y });
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
|
32
|
-
return () => window.removeEventListener('mousemove', onMouseMove);
|
|
33
|
-
}, [initialDragState, dragging, onDrag]);
|
|
34
|
-
useEffect(() => {
|
|
35
|
-
const onMouseUp = () => {
|
|
36
|
-
setDragging(false);
|
|
37
|
-
};
|
|
38
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
39
|
-
return () => window.removeEventListener('mouseup', onMouseUp);
|
|
40
|
-
}, [setDragging]);
|
|
41
|
-
return onMouseDown;
|
|
42
|
-
};
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
export const useDrag = (x, y, onDrag) => {
|
|
3
|
+
const [dragging, setDragging] = useState(false);
|
|
4
|
+
const [initialDragState, setInitialDragState] = useState({
|
|
5
|
+
initX: 0,
|
|
6
|
+
initY: 0,
|
|
7
|
+
mouseDownX: 0,
|
|
8
|
+
mouseDownY: 0,
|
|
9
|
+
});
|
|
10
|
+
const onMouseDown = useCallback((e) => {
|
|
11
|
+
e.preventDefault();
|
|
12
|
+
setInitialDragState({
|
|
13
|
+
initX: x,
|
|
14
|
+
initY: y,
|
|
15
|
+
mouseDownX: e.clientX,
|
|
16
|
+
mouseDownY: e.clientY,
|
|
17
|
+
});
|
|
18
|
+
setDragging(true);
|
|
19
|
+
}, [x, y, setDragging, setInitialDragState]);
|
|
20
|
+
useEffect(() => {
|
|
21
|
+
const onMouseMove = (e) => {
|
|
22
|
+
if (dragging) {
|
|
23
|
+
const { initX, mouseDownX, initY, mouseDownY } = initialDragState;
|
|
24
|
+
let dx = e.clientX - mouseDownX;
|
|
25
|
+
let dy = e.clientY - mouseDownY;
|
|
26
|
+
const x = initX + dx;
|
|
27
|
+
const y = initY + dy;
|
|
28
|
+
onDrag({ x, y });
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
|
32
|
+
return () => window.removeEventListener('mousemove', onMouseMove);
|
|
33
|
+
}, [initialDragState, dragging, onDrag]);
|
|
34
|
+
useEffect(() => {
|
|
35
|
+
const onMouseUp = () => {
|
|
36
|
+
setDragging(false);
|
|
37
|
+
};
|
|
38
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
39
|
+
return () => window.removeEventListener('mouseup', onMouseUp);
|
|
40
|
+
}, [setDragging]);
|
|
41
|
+
return onMouseDown;
|
|
42
|
+
};
|
|
43
43
|
//# sourceMappingURL=useDrag.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useDrag.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useDrag.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useDrag.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useDrag.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAEtD,MAAM,CAAC,MAAM,OAAO,GAAG,CACnB,CAAS,EACT,CAAS,EACT,MAAgD,EACjB,EAAE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AAC,CAAA;QACpE,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;IACrE,CAAC,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,MAAM,CAAC,CAAC,CAAA;IAExC,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,GAAS,EAAE;YACzB,WAAW,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;QAC7C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACjE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,OAAO,WAAW,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {useCallback, useEffect, useState} from 'react'\r\n\r\nexport const useDrag = (\r\n x: number,\r\n y: number,\r\n onDrag: (args: { x: number; y: number }) => void,\r\n): ((e: React.MouseEvent) => void) => {\r\n const [dragging, setDragging] = useState(false)\r\n const [initialDragState, setInitialDragState] = useState({\r\n initX: 0,\r\n initY: 0,\r\n mouseDownX: 0,\r\n mouseDownY: 0,\r\n })\r\n\r\n const onMouseDown = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.preventDefault()\r\n setInitialDragState({\r\n initX: x,\r\n initY: y,\r\n mouseDownX: e.clientX,\r\n mouseDownY: e.clientY,\r\n })\r\n setDragging(true)\r\n },\r\n [x, y, setDragging, setInitialDragState],\r\n )\r\n\r\n useEffect(() => {\r\n const onMouseMove = (e: MouseEvent): void => {\r\n if (dragging) {\r\n const { initX, mouseDownX, initY, mouseDownY } = initialDragState\r\n let dx = e.clientX - mouseDownX\r\n let dy = e.clientY - mouseDownY\r\n const x = initX + dx\r\n const y = initY + dy\r\n onDrag({ x, y })\r\n }\r\n }\r\n window.addEventListener('mousemove', onMouseMove, { passive: true })\r\n return () => window.removeEventListener('mousemove', onMouseMove)\r\n }, [initialDragState, dragging, onDrag])\r\n\r\n useEffect(() => {\r\n const onMouseUp = (): void => {\r\n setDragging(false)\r\n }\r\n window.addEventListener('mouseup', onMouseUp)\r\n return () => window.removeEventListener('mouseup', onMouseUp)\r\n }, [setDragging])\r\n\r\n return onMouseDown\r\n}\r\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const usePrevious: <T>(value: T) => T
|
|
1
|
+
export declare const usePrevious: <T>(value: T) => T;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import { useEffect, useRef } from 'react';
|
|
2
|
-
export const usePrevious = (value) => {
|
|
3
|
-
const ref = useRef(
|
|
4
|
-
useEffect(() => {
|
|
5
|
-
ref.current = value;
|
|
6
|
-
});
|
|
7
|
-
return ref.current;
|
|
8
|
-
};
|
|
1
|
+
import { useEffect, useRef } from 'react';
|
|
2
|
+
export const usePrevious = (value) => {
|
|
3
|
+
const ref = useRef(value);
|
|
4
|
+
useEffect(() => {
|
|
5
|
+
ref.current = value;
|
|
6
|
+
}, [value]);
|
|
7
|
+
return ref.current;
|
|
8
|
+
};
|
|
9
9
|
//# sourceMappingURL=usePrevious.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../../../components/modal/impl/usePrevious.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"usePrevious.js","sourceRoot":"","sources":["../../../../../components/modal/impl/usePrevious.ts"],"names":[],"mappings":"AAEA,OAAO,EAAC,SAAS,EAAE,MAAM,EAAC,MAAM,OAAO,CAAA;AAEvC,MAAM,CAAC,MAAM,WAAW,GAAG,CAAI,KAAQ,EAAK,EAAE;IAC1C,MAAM,GAAG,GAAG,MAAM,CAAI,KAAK,CAAC,CAAA;IAC5B,SAAS,CAAC,GAAG,EAAE;QACX,GAAG,CAAC,OAAO,GAAG,KAAK,CAAA;IACvB,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAA;IACX,OAAO,GAAG,CAAC,OAAO,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport {useEffect, useRef} from 'react'\r\n\r\nexport const usePrevious = <T>(value: T): T => {\r\n const ref = useRef<T>(value)\r\n useEffect(() => {\r\n ref.current = value\r\n }, [value])\r\n return ref.current\r\n}\r\n"]}
|
|
@@ -1,7 +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;
|
|
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);
|
|
@@ -1,47 +1,47 @@
|
|
|
1
|
-
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
-
export const useResize = (x, y, width, height, onResize) => {
|
|
3
|
-
const [dragging, setDragging] = useState(false);
|
|
4
|
-
const [initialDragState, setInitialDragState] = useState({
|
|
5
|
-
initX: 0,
|
|
6
|
-
initY: 0,
|
|
7
|
-
initWidth: 0,
|
|
8
|
-
initHeight: 0,
|
|
9
|
-
mouseDownX: 0,
|
|
10
|
-
mouseDownY: 0,
|
|
11
|
-
});
|
|
12
|
-
const onMouseDown = useCallback((e) => {
|
|
13
|
-
e.preventDefault();
|
|
14
|
-
setInitialDragState({
|
|
15
|
-
initX: x,
|
|
16
|
-
initY: y,
|
|
17
|
-
initWidth: width,
|
|
18
|
-
initHeight: height,
|
|
19
|
-
mouseDownX: e.clientX,
|
|
20
|
-
mouseDownY: e.clientY,
|
|
21
|
-
});
|
|
22
|
-
setDragging(true);
|
|
23
|
-
}, [width, height, setDragging, setInitialDragState, x, y]);
|
|
24
|
-
useEffect(() => {
|
|
25
|
-
const onMouseMove = (e) => {
|
|
26
|
-
if (dragging) {
|
|
27
|
-
const { initX, initY, initWidth, mouseDownX, initHeight, mouseDownY, } = initialDragState;
|
|
28
|
-
let dx = e.clientX - mouseDownX;
|
|
29
|
-
let dy = e.clientY - mouseDownY;
|
|
30
|
-
const width = initWidth + dx;
|
|
31
|
-
const height = initHeight + dy;
|
|
32
|
-
return onResize({ x: initX, y: initY, width, height });
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
|
36
|
-
return () => window.removeEventListener('mousemove', onMouseMove);
|
|
37
|
-
}, [initialDragState, dragging, onResize]);
|
|
38
|
-
useEffect(() => {
|
|
39
|
-
const onMouseUp = () => {
|
|
40
|
-
setDragging(false);
|
|
41
|
-
};
|
|
42
|
-
window.addEventListener('mouseup', onMouseUp);
|
|
43
|
-
return () => window.removeEventListener('mouseup', onMouseUp);
|
|
44
|
-
}, [setDragging]);
|
|
45
|
-
return onMouseDown;
|
|
46
|
-
};
|
|
1
|
+
import { useCallback, useEffect, useState } from 'react';
|
|
2
|
+
export const useResize = (x, y, width, height, onResize) => {
|
|
3
|
+
const [dragging, setDragging] = useState(false);
|
|
4
|
+
const [initialDragState, setInitialDragState] = useState({
|
|
5
|
+
initX: 0,
|
|
6
|
+
initY: 0,
|
|
7
|
+
initWidth: 0,
|
|
8
|
+
initHeight: 0,
|
|
9
|
+
mouseDownX: 0,
|
|
10
|
+
mouseDownY: 0,
|
|
11
|
+
});
|
|
12
|
+
const onMouseDown = useCallback((e) => {
|
|
13
|
+
e.preventDefault();
|
|
14
|
+
setInitialDragState({
|
|
15
|
+
initX: x,
|
|
16
|
+
initY: y,
|
|
17
|
+
initWidth: width,
|
|
18
|
+
initHeight: height,
|
|
19
|
+
mouseDownX: e.clientX,
|
|
20
|
+
mouseDownY: e.clientY,
|
|
21
|
+
});
|
|
22
|
+
setDragging(true);
|
|
23
|
+
}, [width, height, setDragging, setInitialDragState, x, y]);
|
|
24
|
+
useEffect(() => {
|
|
25
|
+
const onMouseMove = (e) => {
|
|
26
|
+
if (dragging) {
|
|
27
|
+
const { initX, initY, initWidth, mouseDownX, initHeight, mouseDownY, } = initialDragState;
|
|
28
|
+
let dx = e.clientX - mouseDownX;
|
|
29
|
+
let dy = e.clientY - mouseDownY;
|
|
30
|
+
const width = initWidth + dx;
|
|
31
|
+
const height = initHeight + dy;
|
|
32
|
+
return onResize({ x: initX, y: initY, width, height });
|
|
33
|
+
}
|
|
34
|
+
};
|
|
35
|
+
window.addEventListener('mousemove', onMouseMove, { passive: true });
|
|
36
|
+
return () => window.removeEventListener('mousemove', onMouseMove);
|
|
37
|
+
}, [initialDragState, dragging, onResize]);
|
|
38
|
+
useEffect(() => {
|
|
39
|
+
const onMouseUp = () => {
|
|
40
|
+
setDragging(false);
|
|
41
|
+
};
|
|
42
|
+
window.addEventListener('mouseup', onMouseUp);
|
|
43
|
+
return () => window.removeEventListener('mouseup', onMouseUp);
|
|
44
|
+
}, [setDragging]);
|
|
45
|
+
return onMouseDown;
|
|
46
|
+
};
|
|
47
47
|
//# sourceMappingURL=useResize.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"useResize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useResize.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"useResize.js","sourceRoot":"","sources":["../../../../../components/modal/impl/useResize.ts"],"names":[],"mappings":"AAGA,OAAO,EAAC,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAC,MAAM,OAAO,CAAA;AAWtD,MAAM,CAAC,MAAM,SAAS,GAAG,CACrB,CAAS,EACT,CAAS,EACT,KAAa,EACb,MAAc,EACd,QAAiF,EAClD,EAAE;IACjC,MAAM,CAAC,QAAQ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E,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,CAAC,CAAA;YAC1D,CAAC;QACL,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,WAAW,EAAE,WAAW,EAAE,EAAE,OAAO,EAAE,IAAI,EAAE,CAAC,CAAA;QACpE,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,WAAW,EAAE,WAAW,CAAC,CAAA;IACrE,CAAC,EAAE,CAAC,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,CAAC,CAAC,CAAA;IAE1C,SAAS,CAAC,GAAG,EAAE;QACX,MAAM,SAAS,GAAG,GAAS,EAAE;YACzB,WAAW,CAAC,KAAK,CAAC,CAAA;QACtB,CAAC,CAAA;QACD,MAAM,CAAC,gBAAgB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAC;QAC9C,OAAO,GAAG,EAAE,CAAC,MAAM,CAAC,mBAAmB,CAAC,SAAS,EAAE,SAAS,CAAC,CAAA;IACjE,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAA;IAEjB,OAAO,WAAW,CAAA;AACtB,CAAC,CAAA","sourcesContent":["// https://github.com/CUBETIQ/antd-modal/\r\n\r\nimport * as React from 'react'\r\nimport {useCallback, useEffect, useState} from 'react'\r\n\r\ninterface InitialState {\r\n initX: number\r\n initY: number\r\n initWidth: number\r\n initHeight: number\r\n mouseDownX: number\r\n mouseDownY: number\r\n}\r\n\r\nexport const useResize = (\r\n x: number,\r\n y: number,\r\n width: number,\r\n height: number,\r\n onResize: (args: { x: number; y: number; width: number; height: number }) => void,\r\n): ((e: React.MouseEvent) => void) => {\r\n const [dragging, setDragging] = useState(false);\r\n const [initialDragState, setInitialDragState] = useState<InitialState>({\r\n initX: 0,\r\n initY: 0,\r\n initWidth: 0,\r\n initHeight: 0,\r\n mouseDownX: 0,\r\n mouseDownY: 0,\r\n })\r\n\r\n const onMouseDown = useCallback(\r\n (e: React.MouseEvent) => {\r\n e.preventDefault()\r\n setInitialDragState({\r\n initX: x,\r\n initY: y,\r\n initWidth: width,\r\n initHeight: height,\r\n mouseDownX: e.clientX,\r\n mouseDownY: e.clientY,\r\n })\r\n setDragging(true)\r\n },\r\n [width, height, setDragging, setInitialDragState, x, y],\r\n )\r\n\r\n useEffect(() => {\r\n const onMouseMove = (e: MouseEvent): void => {\r\n if (dragging) {\r\n const {\r\n initX,\r\n initY,\r\n initWidth,\r\n mouseDownX,\r\n initHeight,\r\n mouseDownY,\r\n } = initialDragState\r\n let dx = e.clientX - mouseDownX\r\n let dy = e.clientY - mouseDownY\r\n const width = initWidth + dx;\r\n const height = initHeight + dy;\r\n return onResize({ x: initX, y: initY, width, height })\r\n }\r\n }\r\n window.addEventListener('mousemove', onMouseMove, { passive: true })\r\n return () => window.removeEventListener('mousemove', onMouseMove)\r\n }, [initialDragState, dragging, onResize])\r\n\r\n useEffect(() => {\r\n const onMouseUp = (): void => {\r\n setDragging(false)\r\n }\r\n window.addEventListener('mouseup', onMouseUp);\r\n return () => window.removeEventListener('mouseup', onMouseUp)\r\n }, [setDragging])\r\n\r\n return onMouseDown\r\n}\r\n"]}
|