@m4l/components 9.2.12 → 9.2.15-beta.2
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/@types/types.d.ts +1 -4
- package/components/AccountPopover/slots/AccountPopoverSlots.d.ts +3 -3
- package/components/AppBar/slots/AppBarSlots.d.ts +2 -2
- package/components/Chip/slots/ChipSlots.d.ts +1 -1
- package/components/Color/slots/ColorSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionCancel/slots/ActionsCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionFormCancel/slots/ActionFormCancelSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionIntro/slots/ActionsIntroSlots.d.ts +1 -1
- package/components/CommonActions/components/ActionsContainer/slots/ActionsContainerSlots.d.ts +1 -1
- package/components/DataGrid/contexts/DataGridContext/index.js +3 -3
- package/components/DataGrid/contexts/DataGridContext/types.d.ts +7 -4
- package/components/DataGrid/formatters/ColumnBooleanFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnBooleanFormatter/formatter.js +27 -0
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnBooleanFormatter/index.js +1 -27
- package/components/DataGrid/formatters/ColumnBooleanFormatter/useColumnBoolean.js +1 -1
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/formatter.d.ts +7 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/formatter.js +23 -0
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.d.ts +3 -7
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/index.js +1 -23
- package/components/DataGrid/formatters/ColumnConcatenatedValueFormatter/useColumnConcatenatedValue.js +1 -1
- package/components/DataGrid/formatters/ColumnDateFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/formatter.js +20 -0
- package/components/DataGrid/formatters/ColumnDateFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnDateFormatter/index.js +1 -20
- package/components/DataGrid/formatters/ColumnDateFormatter/useColumnDate.js +1 -1
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnIconFormatter/formatter.js +12 -0
- package/components/DataGrid/formatters/ColumnIconFormatter/index.d.ts +2 -5
- package/components/DataGrid/formatters/ColumnIconFormatter/index.js +1 -12
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/formatter.d.ts +6 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/formatter.js +21 -0
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index.d.ts +3 -6
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/index.js +1 -21
- package/components/DataGrid/formatters/ColumnInteractiveCheckFormatter/useColumnInteractiveCheck.js +1 -1
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/formatter.js +14 -0
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/index.js +1 -14
- package/components/DataGrid/formatters/ColumnNestedValueFormatter/useColumnNestedValue.js +1 -1
- package/components/DataGrid/formatters/ColumnPointsFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/formatter.js +12 -0
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnPointsFormatter/index.js +1 -12
- package/components/DataGrid/formatters/ColumnPointsFormatter/useColumnPoints.js +1 -1
- package/components/DataGrid/formatters/ColumnPriceFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/formatter.js +12 -0
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnPriceFormatter/index.js +1 -12
- package/components/DataGrid/formatters/ColumnPriceFormatter/useColumnPrice.js +1 -1
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.d.ts +9 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/formatter.js +36 -0
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index.d.ts +3 -9
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/index.js +1 -36
- package/components/DataGrid/formatters/ColumnSetCheckFormatter/useColumnSetCheck.js +1 -1
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/formatter.d.ts +5 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/formatter.js +12 -0
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.d.ts +3 -5
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/index.js +1 -12
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.d.ts +1 -1
- package/components/DataGrid/formatters/ColumnUncertaintyFormatter/useColumnUncertainty.js +3 -3
- package/components/DataGrid/formatters/index.d.ts +11 -21
- package/components/DataGrid/index.d.ts +1 -1
- package/components/DataGrid/subcomponents/Actions/subcomponents/Settings/subcomponents/ColumnsConfig/index.js +1 -1
- package/components/DragResizeWindowRND/DragResizeWindowRND.d.ts +2 -2
- package/components/DragResizeWindowRND/slots/DragResizeWindowRNDSlots.js +1 -1
- package/components/DragResizeWindowRND/types.d.ts +1 -1
- package/components/DynamicFilter/constants.d.ts +1 -0
- package/components/DynamicFilter/constants.js +3 -1
- package/components/DynamicFilter/slots/dynamicFilterSlots.d.ts +2 -2
- package/components/DynamicFilter/subcomponents/PopoverFilter/usePopoverFilter.d.ts +3 -3
- package/components/DynamicFilter/subcomponents/PopoverMenuFields/PopoverMenuFields.js +17 -0
- package/components/DynamicSort/constants.d.ts +1 -0
- package/components/DynamicSort/constants.js +3 -1
- package/components/DynamicSort/icons.d.ts +4 -2
- package/components/DynamicSort/icons.js +5 -4
- package/components/DynamicSort/slots/DynamicSortSlots.d.ts +2 -2
- package/components/DynamicSort/subcomponents/AppliedSortChip/useAppliedSortChip.js +2 -2
- package/components/DynamicSort/subcomponents/FieldTypes/StringSort/index.js +3 -3
- package/components/DynamicSort/subcomponents/PopoverMenuFields/PopoverMenuFields.js +17 -0
- package/components/DynamicSort/subcomponents/PopoverSort/usePopoverSort.d.ts +3 -3
- package/components/Label/slots/LabelSlots.d.ts +1 -1
- package/components/LanguagePopover/slots/LanguagePopoverSlots.d.ts +1 -1
- package/components/MenuActions/index.d.ts +1 -0
- package/components/MenuActions/slots/MenuActionsSlots.d.ts +2 -2
- package/components/ModalDialog/slots/ModalDialogSlots.d.ts +2 -2
- package/components/NumberInput/slots/NumberInputSlots.d.ts +2 -2
- package/components/PropertyValue/PropertyValue.js +2 -1
- package/components/ToastContainer/slots/toastContainerSlots.d.ts +2 -2
- package/components/WindowBase/hooks/useWindowToolsMF/index.d.ts +1 -1
- package/components/WindowBase/index.d.ts +1 -0
- package/components/areas/components/AreasAdmin/slots/AreasAdminSlots.d.ts +2 -2
- package/components/areas/types.d.ts +2 -2
- package/components/extended/React-Splitter-Layout/index.d.ts +1 -0
- package/components/hook-form/RHFCheckbox/slots/RHFCheckBoxSlots.d.ts +1 -1
- package/components/hook-form/RHFPeriod/slots/RHFPeriodSlots.d.ts +2 -2
- package/components/hook-form/RHFSelect/slots/RHFSlots.d.ts +1 -1
- package/components/hook-form/RHFTextField/slots/RHFTextFieldSlots.d.ts +1 -1
- package/components/hook-form/RHFTextFieldPassword/slots/RHFTextFieldPasswordSlots.d.ts +2 -2
- package/components/index.d.ts +1 -5
- package/components/mui_extended/Accordion/Accordion.js +1 -1
- package/components/mui_extended/Accordion/index.d.ts +1 -0
- package/components/mui_extended/Accordion/slots/AccordionSlots.d.ts +2 -2
- package/components/mui_extended/Accordion/types.d.ts +3 -3
- package/components/mui_extended/Autocomplete/slots/AutocompleteSlots.d.ts +4 -4
- package/components/mui_extended/Avatar/slots/AvatarSlots.d.ts +1 -1
- package/components/mui_extended/Badge/slots/BadgeSlots.d.ts +1 -1
- package/components/mui_extended/Button/slots/ButtonSlots.d.ts +1 -1
- package/components/mui_extended/CheckBox/slots/CheckBoxSlots.d.ts +1 -1
- package/components/mui_extended/DateTimePicker/slots/DateTimePickerSlots.d.ts +4 -4
- package/components/mui_extended/Divider/slots/DividerSlots.d.ts +1 -1
- package/components/mui_extended/IconButton/slots/IconButtonSlots.d.ts +2 -2
- package/components/mui_extended/LoadingButton/slots/LoadingButtonSlots.d.ts +1 -1
- package/components/mui_extended/MenuDivider/slots/MenuDividerSlots.d.ts +1 -1
- package/components/mui_extended/MenuItem/slots/MenuItemSlots.d.ts +1 -1
- package/components/mui_extended/Popper/slots/PopperStlots.d.ts +1 -1
- package/components/mui_extended/Select/slots/SelectSlots.d.ts +2 -2
- package/components/mui_extended/Skeleton/Slots/skeletonSlots.d.ts +1 -1
- package/components/mui_extended/Stack/slots/StackSlot.d.ts +1 -1
- package/components/mui_extended/Tab/Slots/TabSlots.d.ts +1 -1
- package/components/mui_extended/Tab/index.d.ts +1 -0
- package/components/mui_extended/Tabs/index.d.ts +1 -0
- package/components/mui_extended/Tabs/slots/TabsSlots.d.ts +2 -2
- package/components/mui_extended/TextField/slots/TextFieldSlots.d.ts +1 -1
- package/components/mui_extended/TimePicker/slots/TimePickerSlots.d.ts +3 -3
- package/components/mui_extended/ToggleButton/slots/ToggleButtonSlots.d.ts +1 -1
- package/components/mui_extended/ToggleIconButton/slots/ToggleIconButtonSlots.d.ts +1 -1
- package/components/mui_extended/Typography/slots/typographySlots.d.ts +1 -1
- package/components/mui_extended/index.d.ts +3 -3
- package/components/popups/components/PopupsViewer/slots/popupsViewerSlots.d.ts +1 -1
- package/index.js +191 -193
- package/package.json +7 -9
- package/patchLibErrors/index.d.ts +1 -1
- package/patchLibErrors/patchErrors.d.ts +5 -0
- package/utils/getNullGuard.d.ts +4 -0
- package/utils/getNullGuard.js +9 -0
- package/utils/index.d.ts +2 -1
- package/components/DragResizeWindow/DragResizeWindow.d.ts +0 -20
- package/components/DragResizeWindow/DragResizeWindow.js +0 -226
- package/components/DragResizeWindow/DragResizeWindow.styles.d.ts +0 -5
- package/components/DragResizeWindow/DragResizeWindow.styles.js +0 -47
- package/components/DragResizeWindow/classes/index.d.ts +0 -2
- package/components/DragResizeWindow/classes/index.js +0 -17
- package/components/DragResizeWindow/classes/types.d.ts +0 -8
- package/components/DragResizeWindow/constants.d.ts +0 -3
- package/components/DragResizeWindow/constants.js +0 -6
- package/components/DragResizeWindow/helpers/draggingOrResizingWindow.d.ts +0 -7
- package/components/DragResizeWindow/helpers/expandingParentContainer.d.ts +0 -12
- package/components/DragResizeWindow/helpers/expandingParentContainer.js +0 -31
- package/components/DragResizeWindow/helpers/getInitialSize.d.ts +0 -15
- package/components/DragResizeWindow/helpers/getInitialSize.js +0 -56
- package/components/DragResizeWindow/helpers/index.d.ts +0 -6
- package/components/DragResizeWindow/helpers/isElmentInViewport.d.ts +0 -15
- package/components/DragResizeWindow/helpers/isElmentInViewport.js +0 -1
- package/components/DragResizeWindow/helpers/pointPosition.d.ts +0 -36
- package/components/DragResizeWindow/helpers/pointPosition.js +0 -82
- package/components/DragResizeWindow/helpers/shrinkingParentContainer.d.ts +0 -6
- package/components/DragResizeWindow/helpers/shrinkingParentContainer.js +0 -34
- package/components/DragResizeWindow/hooks/useDimensionEffects.d.ts +0 -23
- package/components/DragResizeWindow/hooks/useDimensionEffects.js +0 -92
- package/components/DragResizeWindow/hooks/useDragOptions.d.ts +0 -28
- package/components/DragResizeWindow/hooks/useDragOptions.js +0 -167
- package/components/DragResizeWindow/hooks/useResizeOptions.d.ts +0 -45
- package/components/DragResizeWindow/hooks/useResizeOptions.js +0 -218
- package/components/DragResizeWindow/icons.d.ts +0 -3
- package/components/DragResizeWindow/index.d.ts +0 -2
- package/components/DragResizeWindow/slots/DragResizeWindowSlots.d.ts +0 -6
- package/components/DragResizeWindow/slots/DragResizeWindowSlots.js +0 -14
- package/components/DragResizeWindow/slots/slots.d.ts +0 -4
- package/components/DragResizeWindow/slots/slots.js +0 -8
- package/components/DragResizeWindow/tests/DragResizeWindow.test.d.ts +0 -1
- package/components/DragResizeWindow/types.d.ts +0 -316
- package/components/DragResizeWindow/utils.d.ts +0 -15
- package/components/DragResizeWindow/utils.js +0 -36
- package/components/ScrollToTop/index.d.ts +0 -4
- package/components/ScrollToTop/index.js +0 -12
- package/components/WrapperComponent/index.js +0 -14
- package/not_recognized/index.js +0 -1280
- package/patchLibErrors/defaultPropsError.d.ts +0 -5
- package/patchLibErrors/defaultPropsError.js +0 -1
- package/storybook/components/DragResizeWindow/stories/DragResizeWindow.stories.d.ts +0 -7
- package/storybook/components/DragResizeWindow/stories/constants.d.ts +0 -3
- package/storybook/components/DragResizeWindow/stories/subcomponents/ContentExample.d.ts +0 -4
- package/storybook/components/DragResizeWindow/stories/subcomponents/WithExtendedContainer.d.ts +0 -5
- package/storybook/components/DragResizeWindow/stories/types.d.ts +0 -3
- /package/components/{DragResizeWindow/helpers → DataGrid/formatters/ColumnChipStatusFormatter}/index.js +0 -0
- /package/components/{DragResizeWindow → mui_extended/Tab}/index.js +0 -0
- /package/{components/DragResizeWindow/helpers/draggingOrResizingWindow.js → patchLibErrors/patchErrors.js} +0 -0
package/not_recognized/index.js
DELETED
|
@@ -1,1280 +0,0 @@
|
|
|
1
|
-
import { memo, useCallback, useMemo, PureComponent, createElement } from "react";
|
|
2
|
-
import Draggable from "react-draggable";
|
|
3
|
-
import { jsx, jsxs } from "react/jsx-runtime";
|
|
4
|
-
import { flushSync } from "react-dom";
|
|
5
|
-
var __assign$2 = function() {
|
|
6
|
-
__assign$2 = Object.assign || function(t) {
|
|
7
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
8
|
-
s = arguments[i];
|
|
9
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
10
|
-
t[p] = s[p];
|
|
11
|
-
}
|
|
12
|
-
return t;
|
|
13
|
-
};
|
|
14
|
-
return __assign$2.apply(this, arguments);
|
|
15
|
-
};
|
|
16
|
-
var rowSizeBase = {
|
|
17
|
-
width: "100%",
|
|
18
|
-
height: "10px",
|
|
19
|
-
top: "0px",
|
|
20
|
-
left: "0px",
|
|
21
|
-
cursor: "row-resize"
|
|
22
|
-
};
|
|
23
|
-
var colSizeBase = {
|
|
24
|
-
width: "10px",
|
|
25
|
-
height: "100%",
|
|
26
|
-
top: "0px",
|
|
27
|
-
left: "0px",
|
|
28
|
-
cursor: "col-resize"
|
|
29
|
-
};
|
|
30
|
-
var edgeBase = {
|
|
31
|
-
width: "20px",
|
|
32
|
-
height: "20px",
|
|
33
|
-
position: "absolute",
|
|
34
|
-
zIndex: 1
|
|
35
|
-
};
|
|
36
|
-
var styles = {
|
|
37
|
-
top: __assign$2(__assign$2({}, rowSizeBase), { top: "-5px" }),
|
|
38
|
-
right: __assign$2(__assign$2({}, colSizeBase), { left: void 0, right: "-5px" }),
|
|
39
|
-
bottom: __assign$2(__assign$2({}, rowSizeBase), { top: void 0, bottom: "-5px" }),
|
|
40
|
-
left: __assign$2(__assign$2({}, colSizeBase), { left: "-5px" }),
|
|
41
|
-
topRight: __assign$2(__assign$2({}, edgeBase), { right: "-10px", top: "-10px", cursor: "ne-resize" }),
|
|
42
|
-
bottomRight: __assign$2(__assign$2({}, edgeBase), { right: "-10px", bottom: "-10px", cursor: "se-resize" }),
|
|
43
|
-
bottomLeft: __assign$2(__assign$2({}, edgeBase), { left: "-10px", bottom: "-10px", cursor: "sw-resize" }),
|
|
44
|
-
topLeft: __assign$2(__assign$2({}, edgeBase), { left: "-10px", top: "-10px", cursor: "nw-resize" })
|
|
45
|
-
};
|
|
46
|
-
var Resizer = memo(function(props) {
|
|
47
|
-
var onResizeStart = props.onResizeStart, direction = props.direction, children = props.children, replaceStyles = props.replaceStyles, className = props.className;
|
|
48
|
-
var onMouseDown = useCallback(function(e) {
|
|
49
|
-
onResizeStart(e, direction);
|
|
50
|
-
}, [onResizeStart, direction]);
|
|
51
|
-
var onTouchStart = useCallback(function(e) {
|
|
52
|
-
onResizeStart(e, direction);
|
|
53
|
-
}, [onResizeStart, direction]);
|
|
54
|
-
var style = useMemo(function() {
|
|
55
|
-
return __assign$2(__assign$2({ position: "absolute", userSelect: "none" }, styles[direction]), replaceStyles !== null && replaceStyles !== void 0 ? replaceStyles : {});
|
|
56
|
-
}, [replaceStyles, direction]);
|
|
57
|
-
return jsx("div", { className: className || void 0, style, onMouseDown, onTouchStart, children });
|
|
58
|
-
});
|
|
59
|
-
var __extends$1 = /* @__PURE__ */ function() {
|
|
60
|
-
var extendStatics2 = function(d, b) {
|
|
61
|
-
extendStatics2 = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
62
|
-
d2.__proto__ = b2;
|
|
63
|
-
} || function(d2, b2) {
|
|
64
|
-
for (var p in b2) if (Object.prototype.hasOwnProperty.call(b2, p)) d2[p] = b2[p];
|
|
65
|
-
};
|
|
66
|
-
return extendStatics2(d, b);
|
|
67
|
-
};
|
|
68
|
-
return function(d, b) {
|
|
69
|
-
if (typeof b !== "function" && b !== null)
|
|
70
|
-
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
|
|
71
|
-
extendStatics2(d, b);
|
|
72
|
-
function __() {
|
|
73
|
-
this.constructor = d;
|
|
74
|
-
}
|
|
75
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
76
|
-
};
|
|
77
|
-
}();
|
|
78
|
-
var __assign$1 = function() {
|
|
79
|
-
__assign$1 = Object.assign || function(t) {
|
|
80
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
81
|
-
s = arguments[i];
|
|
82
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
83
|
-
t[p] = s[p];
|
|
84
|
-
}
|
|
85
|
-
return t;
|
|
86
|
-
};
|
|
87
|
-
return __assign$1.apply(this, arguments);
|
|
88
|
-
};
|
|
89
|
-
var DEFAULT_SIZE = {
|
|
90
|
-
width: "auto",
|
|
91
|
-
height: "auto"
|
|
92
|
-
};
|
|
93
|
-
var clamp = function(n, min, max) {
|
|
94
|
-
return Math.max(Math.min(n, max), min);
|
|
95
|
-
};
|
|
96
|
-
var snap = function(n, size, gridGap) {
|
|
97
|
-
var v = Math.round(n / size);
|
|
98
|
-
return v * size + gridGap * (v - 1);
|
|
99
|
-
};
|
|
100
|
-
var hasDirection = function(dir, target) {
|
|
101
|
-
return new RegExp(dir, "i").test(target);
|
|
102
|
-
};
|
|
103
|
-
var isTouchEvent = function(event) {
|
|
104
|
-
return Boolean(event.touches && event.touches.length);
|
|
105
|
-
};
|
|
106
|
-
var isMouseEvent = function(event) {
|
|
107
|
-
return Boolean((event.clientX || event.clientX === 0) && (event.clientY || event.clientY === 0));
|
|
108
|
-
};
|
|
109
|
-
var findClosestSnap = function(n, snapArray, snapGap) {
|
|
110
|
-
if (snapGap === void 0) {
|
|
111
|
-
snapGap = 0;
|
|
112
|
-
}
|
|
113
|
-
var closestGapIndex = snapArray.reduce(function(prev, curr, index) {
|
|
114
|
-
return Math.abs(curr - n) < Math.abs(snapArray[prev] - n) ? index : prev;
|
|
115
|
-
}, 0);
|
|
116
|
-
var gap = Math.abs(snapArray[closestGapIndex] - n);
|
|
117
|
-
return snapGap === 0 || gap < snapGap ? snapArray[closestGapIndex] : n;
|
|
118
|
-
};
|
|
119
|
-
var getStringSize = function(n) {
|
|
120
|
-
n = n.toString();
|
|
121
|
-
if (n === "auto") {
|
|
122
|
-
return n;
|
|
123
|
-
}
|
|
124
|
-
if (n.endsWith("px")) {
|
|
125
|
-
return n;
|
|
126
|
-
}
|
|
127
|
-
if (n.endsWith("%")) {
|
|
128
|
-
return n;
|
|
129
|
-
}
|
|
130
|
-
if (n.endsWith("vh")) {
|
|
131
|
-
return n;
|
|
132
|
-
}
|
|
133
|
-
if (n.endsWith("vw")) {
|
|
134
|
-
return n;
|
|
135
|
-
}
|
|
136
|
-
if (n.endsWith("vmax")) {
|
|
137
|
-
return n;
|
|
138
|
-
}
|
|
139
|
-
if (n.endsWith("vmin")) {
|
|
140
|
-
return n;
|
|
141
|
-
}
|
|
142
|
-
return "".concat(n, "px");
|
|
143
|
-
};
|
|
144
|
-
var getPixelSize = function(size, parentSize, innerWidth, innerHeight) {
|
|
145
|
-
if (size && typeof size === "string") {
|
|
146
|
-
if (size.endsWith("px")) {
|
|
147
|
-
return Number(size.replace("px", ""));
|
|
148
|
-
}
|
|
149
|
-
if (size.endsWith("%")) {
|
|
150
|
-
var ratio = Number(size.replace("%", "")) / 100;
|
|
151
|
-
return parentSize * ratio;
|
|
152
|
-
}
|
|
153
|
-
if (size.endsWith("vw")) {
|
|
154
|
-
var ratio = Number(size.replace("vw", "")) / 100;
|
|
155
|
-
return innerWidth * ratio;
|
|
156
|
-
}
|
|
157
|
-
if (size.endsWith("vh")) {
|
|
158
|
-
var ratio = Number(size.replace("vh", "")) / 100;
|
|
159
|
-
return innerHeight * ratio;
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
return size;
|
|
163
|
-
};
|
|
164
|
-
var calculateNewMax = function(parentSize, innerWidth, innerHeight, maxWidth, maxHeight, minWidth, minHeight) {
|
|
165
|
-
maxWidth = getPixelSize(maxWidth, parentSize.width, innerWidth, innerHeight);
|
|
166
|
-
maxHeight = getPixelSize(maxHeight, parentSize.height, innerWidth, innerHeight);
|
|
167
|
-
minWidth = getPixelSize(minWidth, parentSize.width, innerWidth, innerHeight);
|
|
168
|
-
minHeight = getPixelSize(minHeight, parentSize.height, innerWidth, innerHeight);
|
|
169
|
-
return {
|
|
170
|
-
maxWidth: typeof maxWidth === "undefined" ? void 0 : Number(maxWidth),
|
|
171
|
-
maxHeight: typeof maxHeight === "undefined" ? void 0 : Number(maxHeight),
|
|
172
|
-
minWidth: typeof minWidth === "undefined" ? void 0 : Number(minWidth),
|
|
173
|
-
minHeight: typeof minHeight === "undefined" ? void 0 : Number(minHeight)
|
|
174
|
-
};
|
|
175
|
-
};
|
|
176
|
-
var normalizeToPair = function(val) {
|
|
177
|
-
return Array.isArray(val) ? val : [val, val];
|
|
178
|
-
};
|
|
179
|
-
var definedProps = [
|
|
180
|
-
"as",
|
|
181
|
-
"ref",
|
|
182
|
-
"style",
|
|
183
|
-
"className",
|
|
184
|
-
"grid",
|
|
185
|
-
"gridGap",
|
|
186
|
-
"snap",
|
|
187
|
-
"bounds",
|
|
188
|
-
"boundsByDirection",
|
|
189
|
-
"size",
|
|
190
|
-
"defaultSize",
|
|
191
|
-
"minWidth",
|
|
192
|
-
"minHeight",
|
|
193
|
-
"maxWidth",
|
|
194
|
-
"maxHeight",
|
|
195
|
-
"lockAspectRatio",
|
|
196
|
-
"lockAspectRatioExtraWidth",
|
|
197
|
-
"lockAspectRatioExtraHeight",
|
|
198
|
-
"enable",
|
|
199
|
-
"handleStyles",
|
|
200
|
-
"handleClasses",
|
|
201
|
-
"handleWrapperStyle",
|
|
202
|
-
"handleWrapperClass",
|
|
203
|
-
"children",
|
|
204
|
-
"onResizeStart",
|
|
205
|
-
"onResize",
|
|
206
|
-
"onResizeStop",
|
|
207
|
-
"handleComponent",
|
|
208
|
-
"scale",
|
|
209
|
-
"resizeRatio",
|
|
210
|
-
"snapGap"
|
|
211
|
-
];
|
|
212
|
-
var baseClassName = "__resizable_base__";
|
|
213
|
-
var Resizable = (
|
|
214
|
-
/** @class */
|
|
215
|
-
function(_super) {
|
|
216
|
-
__extends$1(Resizable2, _super);
|
|
217
|
-
function Resizable2(props) {
|
|
218
|
-
var _a, _b, _c, _d;
|
|
219
|
-
var _this = _super.call(this, props) || this;
|
|
220
|
-
_this.ratio = 1;
|
|
221
|
-
_this.resizable = null;
|
|
222
|
-
_this.parentLeft = 0;
|
|
223
|
-
_this.parentTop = 0;
|
|
224
|
-
_this.resizableLeft = 0;
|
|
225
|
-
_this.resizableRight = 0;
|
|
226
|
-
_this.resizableTop = 0;
|
|
227
|
-
_this.resizableBottom = 0;
|
|
228
|
-
_this.targetLeft = 0;
|
|
229
|
-
_this.targetTop = 0;
|
|
230
|
-
_this.delta = {
|
|
231
|
-
width: 0,
|
|
232
|
-
height: 0
|
|
233
|
-
};
|
|
234
|
-
_this.appendBase = function() {
|
|
235
|
-
if (!_this.resizable || !_this.window) {
|
|
236
|
-
return null;
|
|
237
|
-
}
|
|
238
|
-
var parent = _this.parentNode;
|
|
239
|
-
if (!parent) {
|
|
240
|
-
return null;
|
|
241
|
-
}
|
|
242
|
-
var element = _this.window.document.createElement("div");
|
|
243
|
-
element.style.width = "100%";
|
|
244
|
-
element.style.height = "100%";
|
|
245
|
-
element.style.position = "absolute";
|
|
246
|
-
element.style.transform = "scale(0, 0)";
|
|
247
|
-
element.style.left = "0";
|
|
248
|
-
element.style.flex = "0 0 100%";
|
|
249
|
-
if (element.classList) {
|
|
250
|
-
element.classList.add(baseClassName);
|
|
251
|
-
} else {
|
|
252
|
-
element.className += baseClassName;
|
|
253
|
-
}
|
|
254
|
-
parent.appendChild(element);
|
|
255
|
-
return element;
|
|
256
|
-
};
|
|
257
|
-
_this.removeBase = function(base) {
|
|
258
|
-
var parent = _this.parentNode;
|
|
259
|
-
if (!parent) {
|
|
260
|
-
return;
|
|
261
|
-
}
|
|
262
|
-
parent.removeChild(base);
|
|
263
|
-
};
|
|
264
|
-
_this.state = {
|
|
265
|
-
isResizing: false,
|
|
266
|
-
width: (_b = (_a = _this.propsSize) === null || _a === void 0 ? void 0 : _a.width) !== null && _b !== void 0 ? _b : "auto",
|
|
267
|
-
height: (_d = (_c = _this.propsSize) === null || _c === void 0 ? void 0 : _c.height) !== null && _d !== void 0 ? _d : "auto",
|
|
268
|
-
direction: "right",
|
|
269
|
-
original: {
|
|
270
|
-
x: 0,
|
|
271
|
-
y: 0,
|
|
272
|
-
width: 0,
|
|
273
|
-
height: 0
|
|
274
|
-
},
|
|
275
|
-
backgroundStyle: {
|
|
276
|
-
height: "100%",
|
|
277
|
-
width: "100%",
|
|
278
|
-
backgroundColor: "rgba(0,0,0,0)",
|
|
279
|
-
cursor: "auto",
|
|
280
|
-
opacity: 0,
|
|
281
|
-
position: "fixed",
|
|
282
|
-
zIndex: 9999,
|
|
283
|
-
top: "0",
|
|
284
|
-
left: "0",
|
|
285
|
-
bottom: "0",
|
|
286
|
-
right: "0"
|
|
287
|
-
},
|
|
288
|
-
flexBasis: void 0
|
|
289
|
-
};
|
|
290
|
-
_this.onResizeStart = _this.onResizeStart.bind(_this);
|
|
291
|
-
_this.onMouseMove = _this.onMouseMove.bind(_this);
|
|
292
|
-
_this.onMouseUp = _this.onMouseUp.bind(_this);
|
|
293
|
-
return _this;
|
|
294
|
-
}
|
|
295
|
-
Object.defineProperty(Resizable2.prototype, "parentNode", {
|
|
296
|
-
get: function() {
|
|
297
|
-
if (!this.resizable) {
|
|
298
|
-
return null;
|
|
299
|
-
}
|
|
300
|
-
return this.resizable.parentNode;
|
|
301
|
-
},
|
|
302
|
-
enumerable: false,
|
|
303
|
-
configurable: true
|
|
304
|
-
});
|
|
305
|
-
Object.defineProperty(Resizable2.prototype, "window", {
|
|
306
|
-
get: function() {
|
|
307
|
-
if (!this.resizable) {
|
|
308
|
-
return null;
|
|
309
|
-
}
|
|
310
|
-
if (!this.resizable.ownerDocument) {
|
|
311
|
-
return null;
|
|
312
|
-
}
|
|
313
|
-
return this.resizable.ownerDocument.defaultView;
|
|
314
|
-
},
|
|
315
|
-
enumerable: false,
|
|
316
|
-
configurable: true
|
|
317
|
-
});
|
|
318
|
-
Object.defineProperty(Resizable2.prototype, "propsSize", {
|
|
319
|
-
get: function() {
|
|
320
|
-
return this.props.size || this.props.defaultSize || DEFAULT_SIZE;
|
|
321
|
-
},
|
|
322
|
-
enumerable: false,
|
|
323
|
-
configurable: true
|
|
324
|
-
});
|
|
325
|
-
Object.defineProperty(Resizable2.prototype, "size", {
|
|
326
|
-
get: function() {
|
|
327
|
-
var width = 0;
|
|
328
|
-
var height = 0;
|
|
329
|
-
if (this.resizable && this.window) {
|
|
330
|
-
var orgWidth = this.resizable.offsetWidth;
|
|
331
|
-
var orgHeight = this.resizable.offsetHeight;
|
|
332
|
-
var orgPosition = this.resizable.style.position;
|
|
333
|
-
if (orgPosition !== "relative") {
|
|
334
|
-
this.resizable.style.position = "relative";
|
|
335
|
-
}
|
|
336
|
-
width = this.resizable.style.width !== "auto" ? this.resizable.offsetWidth : orgWidth;
|
|
337
|
-
height = this.resizable.style.height !== "auto" ? this.resizable.offsetHeight : orgHeight;
|
|
338
|
-
this.resizable.style.position = orgPosition;
|
|
339
|
-
}
|
|
340
|
-
return { width, height };
|
|
341
|
-
},
|
|
342
|
-
enumerable: false,
|
|
343
|
-
configurable: true
|
|
344
|
-
});
|
|
345
|
-
Object.defineProperty(Resizable2.prototype, "sizeStyle", {
|
|
346
|
-
get: function() {
|
|
347
|
-
var _this = this;
|
|
348
|
-
var size = this.props.size;
|
|
349
|
-
var getSize = function(key) {
|
|
350
|
-
var _a;
|
|
351
|
-
if (typeof _this.state[key] === "undefined" || _this.state[key] === "auto") {
|
|
352
|
-
return "auto";
|
|
353
|
-
}
|
|
354
|
-
if (_this.propsSize && _this.propsSize[key] && ((_a = _this.propsSize[key]) === null || _a === void 0 ? void 0 : _a.toString().endsWith("%"))) {
|
|
355
|
-
if (_this.state[key].toString().endsWith("%")) {
|
|
356
|
-
return _this.state[key].toString();
|
|
357
|
-
}
|
|
358
|
-
var parentSize = _this.getParentSize();
|
|
359
|
-
var value = Number(_this.state[key].toString().replace("px", ""));
|
|
360
|
-
var percent = value / parentSize[key] * 100;
|
|
361
|
-
return "".concat(percent, "%");
|
|
362
|
-
}
|
|
363
|
-
return getStringSize(_this.state[key]);
|
|
364
|
-
};
|
|
365
|
-
var width = size && typeof size.width !== "undefined" && !this.state.isResizing ? getStringSize(size.width) : getSize("width");
|
|
366
|
-
var height = size && typeof size.height !== "undefined" && !this.state.isResizing ? getStringSize(size.height) : getSize("height");
|
|
367
|
-
return { width, height };
|
|
368
|
-
},
|
|
369
|
-
enumerable: false,
|
|
370
|
-
configurable: true
|
|
371
|
-
});
|
|
372
|
-
Resizable2.prototype.getParentSize = function() {
|
|
373
|
-
if (!this.parentNode) {
|
|
374
|
-
if (!this.window) {
|
|
375
|
-
return { width: 0, height: 0 };
|
|
376
|
-
}
|
|
377
|
-
return { width: this.window.innerWidth, height: this.window.innerHeight };
|
|
378
|
-
}
|
|
379
|
-
var base = this.appendBase();
|
|
380
|
-
if (!base) {
|
|
381
|
-
return { width: 0, height: 0 };
|
|
382
|
-
}
|
|
383
|
-
var wrapChanged = false;
|
|
384
|
-
var wrap = this.parentNode.style.flexWrap;
|
|
385
|
-
if (wrap !== "wrap") {
|
|
386
|
-
wrapChanged = true;
|
|
387
|
-
this.parentNode.style.flexWrap = "wrap";
|
|
388
|
-
}
|
|
389
|
-
base.style.position = "relative";
|
|
390
|
-
base.style.minWidth = "100%";
|
|
391
|
-
base.style.minHeight = "100%";
|
|
392
|
-
var size = {
|
|
393
|
-
width: base.offsetWidth,
|
|
394
|
-
height: base.offsetHeight
|
|
395
|
-
};
|
|
396
|
-
if (wrapChanged) {
|
|
397
|
-
this.parentNode.style.flexWrap = wrap;
|
|
398
|
-
}
|
|
399
|
-
this.removeBase(base);
|
|
400
|
-
return size;
|
|
401
|
-
};
|
|
402
|
-
Resizable2.prototype.bindEvents = function() {
|
|
403
|
-
if (this.window) {
|
|
404
|
-
this.window.addEventListener("mouseup", this.onMouseUp);
|
|
405
|
-
this.window.addEventListener("mousemove", this.onMouseMove);
|
|
406
|
-
this.window.addEventListener("mouseleave", this.onMouseUp);
|
|
407
|
-
this.window.addEventListener("touchmove", this.onMouseMove, {
|
|
408
|
-
capture: true,
|
|
409
|
-
passive: false
|
|
410
|
-
});
|
|
411
|
-
this.window.addEventListener("touchend", this.onMouseUp);
|
|
412
|
-
}
|
|
413
|
-
};
|
|
414
|
-
Resizable2.prototype.unbindEvents = function() {
|
|
415
|
-
if (this.window) {
|
|
416
|
-
this.window.removeEventListener("mouseup", this.onMouseUp);
|
|
417
|
-
this.window.removeEventListener("mousemove", this.onMouseMove);
|
|
418
|
-
this.window.removeEventListener("mouseleave", this.onMouseUp);
|
|
419
|
-
this.window.removeEventListener("touchmove", this.onMouseMove, true);
|
|
420
|
-
this.window.removeEventListener("touchend", this.onMouseUp);
|
|
421
|
-
}
|
|
422
|
-
};
|
|
423
|
-
Resizable2.prototype.componentDidMount = function() {
|
|
424
|
-
if (!this.resizable || !this.window) {
|
|
425
|
-
return;
|
|
426
|
-
}
|
|
427
|
-
var computedStyle = this.window.getComputedStyle(this.resizable);
|
|
428
|
-
this.setState({
|
|
429
|
-
width: this.state.width || this.size.width,
|
|
430
|
-
height: this.state.height || this.size.height,
|
|
431
|
-
flexBasis: computedStyle.flexBasis !== "auto" ? computedStyle.flexBasis : void 0
|
|
432
|
-
});
|
|
433
|
-
};
|
|
434
|
-
Resizable2.prototype.componentWillUnmount = function() {
|
|
435
|
-
if (this.window) {
|
|
436
|
-
this.unbindEvents();
|
|
437
|
-
}
|
|
438
|
-
};
|
|
439
|
-
Resizable2.prototype.createSizeForCssProperty = function(newSize, kind) {
|
|
440
|
-
var propsSize = this.propsSize && this.propsSize[kind];
|
|
441
|
-
return this.state[kind] === "auto" && this.state.original[kind] === newSize && (typeof propsSize === "undefined" || propsSize === "auto") ? "auto" : newSize;
|
|
442
|
-
};
|
|
443
|
-
Resizable2.prototype.calculateNewMaxFromBoundary = function(maxWidth, maxHeight) {
|
|
444
|
-
var boundsByDirection = this.props.boundsByDirection;
|
|
445
|
-
var direction = this.state.direction;
|
|
446
|
-
var widthByDirection = boundsByDirection && hasDirection("left", direction);
|
|
447
|
-
var heightByDirection = boundsByDirection && hasDirection("top", direction);
|
|
448
|
-
var boundWidth;
|
|
449
|
-
var boundHeight;
|
|
450
|
-
if (this.props.bounds === "parent") {
|
|
451
|
-
var parent_1 = this.parentNode;
|
|
452
|
-
if (parent_1) {
|
|
453
|
-
boundWidth = widthByDirection ? this.resizableRight - this.parentLeft : parent_1.offsetWidth + (this.parentLeft - this.resizableLeft);
|
|
454
|
-
boundHeight = heightByDirection ? this.resizableBottom - this.parentTop : parent_1.offsetHeight + (this.parentTop - this.resizableTop);
|
|
455
|
-
}
|
|
456
|
-
} else if (this.props.bounds === "window") {
|
|
457
|
-
if (this.window) {
|
|
458
|
-
boundWidth = widthByDirection ? this.resizableRight : this.window.innerWidth - this.resizableLeft;
|
|
459
|
-
boundHeight = heightByDirection ? this.resizableBottom : this.window.innerHeight - this.resizableTop;
|
|
460
|
-
}
|
|
461
|
-
} else if (this.props.bounds) {
|
|
462
|
-
boundWidth = widthByDirection ? this.resizableRight - this.targetLeft : this.props.bounds.offsetWidth + (this.targetLeft - this.resizableLeft);
|
|
463
|
-
boundHeight = heightByDirection ? this.resizableBottom - this.targetTop : this.props.bounds.offsetHeight + (this.targetTop - this.resizableTop);
|
|
464
|
-
}
|
|
465
|
-
if (boundWidth && Number.isFinite(boundWidth)) {
|
|
466
|
-
maxWidth = maxWidth && maxWidth < boundWidth ? maxWidth : boundWidth;
|
|
467
|
-
}
|
|
468
|
-
if (boundHeight && Number.isFinite(boundHeight)) {
|
|
469
|
-
maxHeight = maxHeight && maxHeight < boundHeight ? maxHeight : boundHeight;
|
|
470
|
-
}
|
|
471
|
-
return { maxWidth, maxHeight };
|
|
472
|
-
};
|
|
473
|
-
Resizable2.prototype.calculateNewSizeFromDirection = function(clientX, clientY) {
|
|
474
|
-
var scale = this.props.scale || 1;
|
|
475
|
-
var _a = normalizeToPair(this.props.resizeRatio || 1), resizeRatioX = _a[0], resizeRatioY = _a[1];
|
|
476
|
-
var _b = this.state, direction = _b.direction, original = _b.original;
|
|
477
|
-
var _c = this.props, lockAspectRatio = _c.lockAspectRatio, lockAspectRatioExtraHeight = _c.lockAspectRatioExtraHeight, lockAspectRatioExtraWidth = _c.lockAspectRatioExtraWidth;
|
|
478
|
-
var newWidth = original.width;
|
|
479
|
-
var newHeight = original.height;
|
|
480
|
-
var extraHeight = lockAspectRatioExtraHeight || 0;
|
|
481
|
-
var extraWidth = lockAspectRatioExtraWidth || 0;
|
|
482
|
-
if (hasDirection("right", direction)) {
|
|
483
|
-
newWidth = original.width + (clientX - original.x) * resizeRatioX / scale;
|
|
484
|
-
if (lockAspectRatio) {
|
|
485
|
-
newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
|
|
486
|
-
}
|
|
487
|
-
}
|
|
488
|
-
if (hasDirection("left", direction)) {
|
|
489
|
-
newWidth = original.width - (clientX - original.x) * resizeRatioX / scale;
|
|
490
|
-
if (lockAspectRatio) {
|
|
491
|
-
newHeight = (newWidth - extraWidth) / this.ratio + extraHeight;
|
|
492
|
-
}
|
|
493
|
-
}
|
|
494
|
-
if (hasDirection("bottom", direction)) {
|
|
495
|
-
newHeight = original.height + (clientY - original.y) * resizeRatioY / scale;
|
|
496
|
-
if (lockAspectRatio) {
|
|
497
|
-
newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
|
|
498
|
-
}
|
|
499
|
-
}
|
|
500
|
-
if (hasDirection("top", direction)) {
|
|
501
|
-
newHeight = original.height - (clientY - original.y) * resizeRatioY / scale;
|
|
502
|
-
if (lockAspectRatio) {
|
|
503
|
-
newWidth = (newHeight - extraHeight) * this.ratio + extraWidth;
|
|
504
|
-
}
|
|
505
|
-
}
|
|
506
|
-
return { newWidth, newHeight };
|
|
507
|
-
};
|
|
508
|
-
Resizable2.prototype.calculateNewSizeFromAspectRatio = function(newWidth, newHeight, max, min) {
|
|
509
|
-
var _a = this.props, lockAspectRatio = _a.lockAspectRatio, lockAspectRatioExtraHeight = _a.lockAspectRatioExtraHeight, lockAspectRatioExtraWidth = _a.lockAspectRatioExtraWidth;
|
|
510
|
-
var computedMinWidth = typeof min.width === "undefined" ? 10 : min.width;
|
|
511
|
-
var computedMaxWidth = typeof max.width === "undefined" || max.width < 0 ? newWidth : max.width;
|
|
512
|
-
var computedMinHeight = typeof min.height === "undefined" ? 10 : min.height;
|
|
513
|
-
var computedMaxHeight = typeof max.height === "undefined" || max.height < 0 ? newHeight : max.height;
|
|
514
|
-
var extraHeight = lockAspectRatioExtraHeight || 0;
|
|
515
|
-
var extraWidth = lockAspectRatioExtraWidth || 0;
|
|
516
|
-
if (lockAspectRatio) {
|
|
517
|
-
var extraMinWidth = (computedMinHeight - extraHeight) * this.ratio + extraWidth;
|
|
518
|
-
var extraMaxWidth = (computedMaxHeight - extraHeight) * this.ratio + extraWidth;
|
|
519
|
-
var extraMinHeight = (computedMinWidth - extraWidth) / this.ratio + extraHeight;
|
|
520
|
-
var extraMaxHeight = (computedMaxWidth - extraWidth) / this.ratio + extraHeight;
|
|
521
|
-
var lockedMinWidth = Math.max(computedMinWidth, extraMinWidth);
|
|
522
|
-
var lockedMaxWidth = Math.min(computedMaxWidth, extraMaxWidth);
|
|
523
|
-
var lockedMinHeight = Math.max(computedMinHeight, extraMinHeight);
|
|
524
|
-
var lockedMaxHeight = Math.min(computedMaxHeight, extraMaxHeight);
|
|
525
|
-
newWidth = clamp(newWidth, lockedMinWidth, lockedMaxWidth);
|
|
526
|
-
newHeight = clamp(newHeight, lockedMinHeight, lockedMaxHeight);
|
|
527
|
-
} else {
|
|
528
|
-
newWidth = clamp(newWidth, computedMinWidth, computedMaxWidth);
|
|
529
|
-
newHeight = clamp(newHeight, computedMinHeight, computedMaxHeight);
|
|
530
|
-
}
|
|
531
|
-
return { newWidth, newHeight };
|
|
532
|
-
};
|
|
533
|
-
Resizable2.prototype.setBoundingClientRect = function() {
|
|
534
|
-
var adjustedScale = 1 / (this.props.scale || 1);
|
|
535
|
-
if (this.props.bounds === "parent") {
|
|
536
|
-
var parent_2 = this.parentNode;
|
|
537
|
-
if (parent_2) {
|
|
538
|
-
var parentRect = parent_2.getBoundingClientRect();
|
|
539
|
-
this.parentLeft = parentRect.left * adjustedScale;
|
|
540
|
-
this.parentTop = parentRect.top * adjustedScale;
|
|
541
|
-
}
|
|
542
|
-
}
|
|
543
|
-
if (this.props.bounds && typeof this.props.bounds !== "string") {
|
|
544
|
-
var targetRect = this.props.bounds.getBoundingClientRect();
|
|
545
|
-
this.targetLeft = targetRect.left * adjustedScale;
|
|
546
|
-
this.targetTop = targetRect.top * adjustedScale;
|
|
547
|
-
}
|
|
548
|
-
if (this.resizable) {
|
|
549
|
-
var _a = this.resizable.getBoundingClientRect(), left = _a.left, top_1 = _a.top, right = _a.right, bottom = _a.bottom;
|
|
550
|
-
this.resizableLeft = left * adjustedScale;
|
|
551
|
-
this.resizableRight = right * adjustedScale;
|
|
552
|
-
this.resizableTop = top_1 * adjustedScale;
|
|
553
|
-
this.resizableBottom = bottom * adjustedScale;
|
|
554
|
-
}
|
|
555
|
-
};
|
|
556
|
-
Resizable2.prototype.onResizeStart = function(event, direction) {
|
|
557
|
-
if (!this.resizable || !this.window) {
|
|
558
|
-
return;
|
|
559
|
-
}
|
|
560
|
-
var clientX = 0;
|
|
561
|
-
var clientY = 0;
|
|
562
|
-
if (event.nativeEvent && isMouseEvent(event.nativeEvent)) {
|
|
563
|
-
clientX = event.nativeEvent.clientX;
|
|
564
|
-
clientY = event.nativeEvent.clientY;
|
|
565
|
-
} else if (event.nativeEvent && isTouchEvent(event.nativeEvent)) {
|
|
566
|
-
clientX = event.nativeEvent.touches[0].clientX;
|
|
567
|
-
clientY = event.nativeEvent.touches[0].clientY;
|
|
568
|
-
}
|
|
569
|
-
if (this.props.onResizeStart) {
|
|
570
|
-
if (this.resizable) {
|
|
571
|
-
var startResize = this.props.onResizeStart(event, direction, this.resizable);
|
|
572
|
-
if (startResize === false) {
|
|
573
|
-
return;
|
|
574
|
-
}
|
|
575
|
-
}
|
|
576
|
-
}
|
|
577
|
-
if (this.props.size) {
|
|
578
|
-
if (typeof this.props.size.height !== "undefined" && this.props.size.height !== this.state.height) {
|
|
579
|
-
this.setState({ height: this.props.size.height });
|
|
580
|
-
}
|
|
581
|
-
if (typeof this.props.size.width !== "undefined" && this.props.size.width !== this.state.width) {
|
|
582
|
-
this.setState({ width: this.props.size.width });
|
|
583
|
-
}
|
|
584
|
-
}
|
|
585
|
-
this.ratio = typeof this.props.lockAspectRatio === "number" ? this.props.lockAspectRatio : this.size.width / this.size.height;
|
|
586
|
-
var flexBasis;
|
|
587
|
-
var computedStyle = this.window.getComputedStyle(this.resizable);
|
|
588
|
-
if (computedStyle.flexBasis !== "auto") {
|
|
589
|
-
var parent_3 = this.parentNode;
|
|
590
|
-
if (parent_3) {
|
|
591
|
-
var dir = this.window.getComputedStyle(parent_3).flexDirection;
|
|
592
|
-
this.flexDir = dir.startsWith("row") ? "row" : "column";
|
|
593
|
-
flexBasis = computedStyle.flexBasis;
|
|
594
|
-
}
|
|
595
|
-
}
|
|
596
|
-
this.setBoundingClientRect();
|
|
597
|
-
this.bindEvents();
|
|
598
|
-
var state = {
|
|
599
|
-
original: {
|
|
600
|
-
x: clientX,
|
|
601
|
-
y: clientY,
|
|
602
|
-
width: this.size.width,
|
|
603
|
-
height: this.size.height
|
|
604
|
-
},
|
|
605
|
-
isResizing: true,
|
|
606
|
-
backgroundStyle: __assign$1(__assign$1({}, this.state.backgroundStyle), { cursor: this.window.getComputedStyle(event.target).cursor || "auto" }),
|
|
607
|
-
direction,
|
|
608
|
-
flexBasis
|
|
609
|
-
};
|
|
610
|
-
this.setState(state);
|
|
611
|
-
};
|
|
612
|
-
Resizable2.prototype.onMouseMove = function(event) {
|
|
613
|
-
var _this = this;
|
|
614
|
-
if (!this.state.isResizing || !this.resizable || !this.window) {
|
|
615
|
-
return;
|
|
616
|
-
}
|
|
617
|
-
if (this.window.TouchEvent && isTouchEvent(event)) {
|
|
618
|
-
try {
|
|
619
|
-
event.preventDefault();
|
|
620
|
-
event.stopPropagation();
|
|
621
|
-
} catch (e) {
|
|
622
|
-
}
|
|
623
|
-
}
|
|
624
|
-
var _a = this.props, maxWidth = _a.maxWidth, maxHeight = _a.maxHeight, minWidth = _a.minWidth, minHeight = _a.minHeight;
|
|
625
|
-
var clientX = isTouchEvent(event) ? event.touches[0].clientX : event.clientX;
|
|
626
|
-
var clientY = isTouchEvent(event) ? event.touches[0].clientY : event.clientY;
|
|
627
|
-
var _b = this.state, direction = _b.direction, original = _b.original, width = _b.width, height = _b.height;
|
|
628
|
-
var parentSize = this.getParentSize();
|
|
629
|
-
var max = calculateNewMax(parentSize, this.window.innerWidth, this.window.innerHeight, maxWidth, maxHeight, minWidth, minHeight);
|
|
630
|
-
maxWidth = max.maxWidth;
|
|
631
|
-
maxHeight = max.maxHeight;
|
|
632
|
-
minWidth = max.minWidth;
|
|
633
|
-
minHeight = max.minHeight;
|
|
634
|
-
var _c = this.calculateNewSizeFromDirection(clientX, clientY), newHeight = _c.newHeight, newWidth = _c.newWidth;
|
|
635
|
-
var boundaryMax = this.calculateNewMaxFromBoundary(maxWidth, maxHeight);
|
|
636
|
-
if (this.props.snap && this.props.snap.x) {
|
|
637
|
-
newWidth = findClosestSnap(newWidth, this.props.snap.x, this.props.snapGap);
|
|
638
|
-
}
|
|
639
|
-
if (this.props.snap && this.props.snap.y) {
|
|
640
|
-
newHeight = findClosestSnap(newHeight, this.props.snap.y, this.props.snapGap);
|
|
641
|
-
}
|
|
642
|
-
var newSize = this.calculateNewSizeFromAspectRatio(newWidth, newHeight, { width: boundaryMax.maxWidth, height: boundaryMax.maxHeight }, { width: minWidth, height: minHeight });
|
|
643
|
-
newWidth = newSize.newWidth;
|
|
644
|
-
newHeight = newSize.newHeight;
|
|
645
|
-
if (this.props.grid) {
|
|
646
|
-
var newGridWidth = snap(newWidth, this.props.grid[0], this.props.gridGap ? this.props.gridGap[0] : 0);
|
|
647
|
-
var newGridHeight = snap(newHeight, this.props.grid[1], this.props.gridGap ? this.props.gridGap[1] : 0);
|
|
648
|
-
var gap = this.props.snapGap || 0;
|
|
649
|
-
var w = gap === 0 || Math.abs(newGridWidth - newWidth) <= gap ? newGridWidth : newWidth;
|
|
650
|
-
var h = gap === 0 || Math.abs(newGridHeight - newHeight) <= gap ? newGridHeight : newHeight;
|
|
651
|
-
newWidth = w;
|
|
652
|
-
newHeight = h;
|
|
653
|
-
}
|
|
654
|
-
var delta = {
|
|
655
|
-
width: newWidth - original.width,
|
|
656
|
-
height: newHeight - original.height
|
|
657
|
-
};
|
|
658
|
-
this.delta = delta;
|
|
659
|
-
if (width && typeof width === "string") {
|
|
660
|
-
if (width.endsWith("%")) {
|
|
661
|
-
var percent = newWidth / parentSize.width * 100;
|
|
662
|
-
newWidth = "".concat(percent, "%");
|
|
663
|
-
} else if (width.endsWith("vw")) {
|
|
664
|
-
var vw = newWidth / this.window.innerWidth * 100;
|
|
665
|
-
newWidth = "".concat(vw, "vw");
|
|
666
|
-
} else if (width.endsWith("vh")) {
|
|
667
|
-
var vh = newWidth / this.window.innerHeight * 100;
|
|
668
|
-
newWidth = "".concat(vh, "vh");
|
|
669
|
-
}
|
|
670
|
-
}
|
|
671
|
-
if (height && typeof height === "string") {
|
|
672
|
-
if (height.endsWith("%")) {
|
|
673
|
-
var percent = newHeight / parentSize.height * 100;
|
|
674
|
-
newHeight = "".concat(percent, "%");
|
|
675
|
-
} else if (height.endsWith("vw")) {
|
|
676
|
-
var vw = newHeight / this.window.innerWidth * 100;
|
|
677
|
-
newHeight = "".concat(vw, "vw");
|
|
678
|
-
} else if (height.endsWith("vh")) {
|
|
679
|
-
var vh = newHeight / this.window.innerHeight * 100;
|
|
680
|
-
newHeight = "".concat(vh, "vh");
|
|
681
|
-
}
|
|
682
|
-
}
|
|
683
|
-
var newState = {
|
|
684
|
-
width: this.createSizeForCssProperty(newWidth, "width"),
|
|
685
|
-
height: this.createSizeForCssProperty(newHeight, "height")
|
|
686
|
-
};
|
|
687
|
-
if (this.flexDir === "row") {
|
|
688
|
-
newState.flexBasis = newState.width;
|
|
689
|
-
} else if (this.flexDir === "column") {
|
|
690
|
-
newState.flexBasis = newState.height;
|
|
691
|
-
}
|
|
692
|
-
var widthChanged = this.state.width !== newState.width;
|
|
693
|
-
var heightChanged = this.state.height !== newState.height;
|
|
694
|
-
var flexBaseChanged = this.state.flexBasis !== newState.flexBasis;
|
|
695
|
-
var changed = widthChanged || heightChanged || flexBaseChanged;
|
|
696
|
-
if (changed) {
|
|
697
|
-
flushSync(function() {
|
|
698
|
-
_this.setState(newState);
|
|
699
|
-
});
|
|
700
|
-
}
|
|
701
|
-
if (this.props.onResize) {
|
|
702
|
-
if (changed) {
|
|
703
|
-
this.props.onResize(event, direction, this.resizable, delta);
|
|
704
|
-
}
|
|
705
|
-
}
|
|
706
|
-
};
|
|
707
|
-
Resizable2.prototype.onMouseUp = function(event) {
|
|
708
|
-
var _a, _b;
|
|
709
|
-
var _c = this.state, isResizing = _c.isResizing, direction = _c.direction;
|
|
710
|
-
_c.original;
|
|
711
|
-
if (!isResizing || !this.resizable) {
|
|
712
|
-
return;
|
|
713
|
-
}
|
|
714
|
-
if (this.props.onResizeStop) {
|
|
715
|
-
this.props.onResizeStop(event, direction, this.resizable, this.delta);
|
|
716
|
-
}
|
|
717
|
-
if (this.props.size) {
|
|
718
|
-
this.setState({ width: (_a = this.props.size.width) !== null && _a !== void 0 ? _a : "auto", height: (_b = this.props.size.height) !== null && _b !== void 0 ? _b : "auto" });
|
|
719
|
-
}
|
|
720
|
-
this.unbindEvents();
|
|
721
|
-
this.setState({
|
|
722
|
-
isResizing: false,
|
|
723
|
-
backgroundStyle: __assign$1(__assign$1({}, this.state.backgroundStyle), { cursor: "auto" })
|
|
724
|
-
});
|
|
725
|
-
};
|
|
726
|
-
Resizable2.prototype.updateSize = function(size) {
|
|
727
|
-
var _a, _b;
|
|
728
|
-
this.setState({ width: (_a = size.width) !== null && _a !== void 0 ? _a : "auto", height: (_b = size.height) !== null && _b !== void 0 ? _b : "auto" });
|
|
729
|
-
};
|
|
730
|
-
Resizable2.prototype.renderResizer = function() {
|
|
731
|
-
var _this = this;
|
|
732
|
-
var _a = this.props, enable = _a.enable, handleStyles = _a.handleStyles, handleClasses = _a.handleClasses, handleWrapperStyle = _a.handleWrapperStyle, handleWrapperClass = _a.handleWrapperClass, handleComponent = _a.handleComponent;
|
|
733
|
-
if (!enable) {
|
|
734
|
-
return null;
|
|
735
|
-
}
|
|
736
|
-
var resizers = Object.keys(enable).map(function(dir) {
|
|
737
|
-
if (enable[dir] !== false) {
|
|
738
|
-
return jsx(Resizer, { direction: dir, onResizeStart: _this.onResizeStart, replaceStyles: handleStyles && handleStyles[dir], className: handleClasses && handleClasses[dir], children: handleComponent && handleComponent[dir] ? handleComponent[dir] : null }, dir);
|
|
739
|
-
}
|
|
740
|
-
return null;
|
|
741
|
-
});
|
|
742
|
-
return jsx("div", { className: handleWrapperClass, style: handleWrapperStyle, children: resizers });
|
|
743
|
-
};
|
|
744
|
-
Resizable2.prototype.render = function() {
|
|
745
|
-
var _this = this;
|
|
746
|
-
var extendsProps = Object.keys(this.props).reduce(function(acc, key) {
|
|
747
|
-
if (definedProps.indexOf(key) !== -1) {
|
|
748
|
-
return acc;
|
|
749
|
-
}
|
|
750
|
-
acc[key] = _this.props[key];
|
|
751
|
-
return acc;
|
|
752
|
-
}, {});
|
|
753
|
-
var style = __assign$1(__assign$1(__assign$1({ position: "relative", userSelect: this.state.isResizing ? "none" : "auto" }, this.props.style), this.sizeStyle), { maxWidth: this.props.maxWidth, maxHeight: this.props.maxHeight, minWidth: this.props.minWidth, minHeight: this.props.minHeight, boxSizing: "border-box", flexShrink: 0 });
|
|
754
|
-
if (this.state.flexBasis) {
|
|
755
|
-
style.flexBasis = this.state.flexBasis;
|
|
756
|
-
}
|
|
757
|
-
var Wrapper = this.props.as || "div";
|
|
758
|
-
return jsxs(Wrapper, __assign$1({ style, className: this.props.className }, extendsProps, {
|
|
759
|
-
// `ref` is after `extendsProps` to ensure this one wins over a version
|
|
760
|
-
// passed in
|
|
761
|
-
ref: function(c) {
|
|
762
|
-
if (c) {
|
|
763
|
-
_this.resizable = c;
|
|
764
|
-
}
|
|
765
|
-
},
|
|
766
|
-
children: [this.state.isResizing && jsx("div", { style: this.state.backgroundStyle }), this.props.children, this.renderResizer()]
|
|
767
|
-
}));
|
|
768
|
-
};
|
|
769
|
-
Resizable2.defaultProps = {
|
|
770
|
-
as: "div",
|
|
771
|
-
onResizeStart: function() {
|
|
772
|
-
},
|
|
773
|
-
onResize: function() {
|
|
774
|
-
},
|
|
775
|
-
onResizeStop: function() {
|
|
776
|
-
},
|
|
777
|
-
enable: {
|
|
778
|
-
top: true,
|
|
779
|
-
right: true,
|
|
780
|
-
bottom: true,
|
|
781
|
-
left: true,
|
|
782
|
-
topRight: true,
|
|
783
|
-
bottomRight: true,
|
|
784
|
-
bottomLeft: true,
|
|
785
|
-
topLeft: true
|
|
786
|
-
},
|
|
787
|
-
style: {},
|
|
788
|
-
grid: [1, 1],
|
|
789
|
-
gridGap: [0, 0],
|
|
790
|
-
lockAspectRatio: false,
|
|
791
|
-
lockAspectRatioExtraWidth: 0,
|
|
792
|
-
lockAspectRatioExtraHeight: 0,
|
|
793
|
-
scale: 1,
|
|
794
|
-
resizeRatio: 1,
|
|
795
|
-
snapGap: 0
|
|
796
|
-
};
|
|
797
|
-
return Resizable2;
|
|
798
|
-
}(PureComponent)
|
|
799
|
-
);
|
|
800
|
-
/*! *****************************************************************************
|
|
801
|
-
Copyright (c) Microsoft Corporation. All rights reserved.
|
|
802
|
-
Licensed under the Apache License, Version 2.0 (the "License"); you may not use
|
|
803
|
-
this file except in compliance with the License. You may obtain a copy of the
|
|
804
|
-
License at http://www.apache.org/licenses/LICENSE-2.0
|
|
805
|
-
|
|
806
|
-
THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
|
807
|
-
KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
|
|
808
|
-
WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
|
|
809
|
-
MERCHANTABLITY OR NON-INFRINGEMENT.
|
|
810
|
-
|
|
811
|
-
See the Apache Version 2.0 License for specific language governing permissions
|
|
812
|
-
and limitations under the License.
|
|
813
|
-
***************************************************************************** */
|
|
814
|
-
var extendStatics = function(d, b) {
|
|
815
|
-
extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d2, b2) {
|
|
816
|
-
d2.__proto__ = b2;
|
|
817
|
-
} || function(d2, b2) {
|
|
818
|
-
for (var p in b2) if (b2.hasOwnProperty(p)) d2[p] = b2[p];
|
|
819
|
-
};
|
|
820
|
-
return extendStatics(d, b);
|
|
821
|
-
};
|
|
822
|
-
function __extends(d, b) {
|
|
823
|
-
extendStatics(d, b);
|
|
824
|
-
function __() {
|
|
825
|
-
this.constructor = d;
|
|
826
|
-
}
|
|
827
|
-
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
|
|
828
|
-
}
|
|
829
|
-
var __assign = function() {
|
|
830
|
-
__assign = Object.assign || function __assign2(t) {
|
|
831
|
-
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
832
|
-
s = arguments[i];
|
|
833
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p)) t[p] = s[p];
|
|
834
|
-
}
|
|
835
|
-
return t;
|
|
836
|
-
};
|
|
837
|
-
return __assign.apply(this, arguments);
|
|
838
|
-
};
|
|
839
|
-
function __rest(s, e) {
|
|
840
|
-
var t = {};
|
|
841
|
-
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
|
|
842
|
-
t[p] = s[p];
|
|
843
|
-
if (s != null && typeof Object.getOwnPropertySymbols === "function")
|
|
844
|
-
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
|
|
845
|
-
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
|
|
846
|
-
t[p[i]] = s[p[i]];
|
|
847
|
-
}
|
|
848
|
-
return t;
|
|
849
|
-
}
|
|
850
|
-
var resizableStyle = {
|
|
851
|
-
width: "auto",
|
|
852
|
-
height: "auto",
|
|
853
|
-
display: "inline-block",
|
|
854
|
-
position: "absolute",
|
|
855
|
-
top: 0,
|
|
856
|
-
left: 0
|
|
857
|
-
};
|
|
858
|
-
var getEnableResizingByFlag = function(flag) {
|
|
859
|
-
return {
|
|
860
|
-
bottom: flag,
|
|
861
|
-
bottomLeft: flag,
|
|
862
|
-
bottomRight: flag,
|
|
863
|
-
left: flag,
|
|
864
|
-
right: flag,
|
|
865
|
-
top: flag,
|
|
866
|
-
topLeft: flag,
|
|
867
|
-
topRight: flag
|
|
868
|
-
};
|
|
869
|
-
};
|
|
870
|
-
var Rnd = (
|
|
871
|
-
/** @class */
|
|
872
|
-
function(_super) {
|
|
873
|
-
__extends(Rnd2, _super);
|
|
874
|
-
function Rnd2(props) {
|
|
875
|
-
var _this = _super.call(this, props) || this;
|
|
876
|
-
_this.resizingPosition = { x: 0, y: 0 };
|
|
877
|
-
_this.offsetFromParent = { left: 0, top: 0 };
|
|
878
|
-
_this.resizableElement = { current: null };
|
|
879
|
-
_this.originalPosition = { x: 0, y: 0 };
|
|
880
|
-
_this.state = {
|
|
881
|
-
resizing: false,
|
|
882
|
-
bounds: {
|
|
883
|
-
top: 0,
|
|
884
|
-
right: 0,
|
|
885
|
-
bottom: 0,
|
|
886
|
-
left: 0
|
|
887
|
-
},
|
|
888
|
-
maxWidth: props.maxWidth,
|
|
889
|
-
maxHeight: props.maxHeight
|
|
890
|
-
};
|
|
891
|
-
_this.onResizeStart = _this.onResizeStart.bind(_this);
|
|
892
|
-
_this.onResize = _this.onResize.bind(_this);
|
|
893
|
-
_this.onResizeStop = _this.onResizeStop.bind(_this);
|
|
894
|
-
_this.onDragStart = _this.onDragStart.bind(_this);
|
|
895
|
-
_this.onDrag = _this.onDrag.bind(_this);
|
|
896
|
-
_this.onDragStop = _this.onDragStop.bind(_this);
|
|
897
|
-
_this.getMaxSizesFromProps = _this.getMaxSizesFromProps.bind(_this);
|
|
898
|
-
return _this;
|
|
899
|
-
}
|
|
900
|
-
Rnd2.prototype.componentDidMount = function() {
|
|
901
|
-
this.updateOffsetFromParent();
|
|
902
|
-
var _a = this.offsetFromParent, left = _a.left, top = _a.top;
|
|
903
|
-
var _b = this.getDraggablePosition(), x = _b.x, y = _b.y;
|
|
904
|
-
this.draggable.setState({
|
|
905
|
-
x: x - left,
|
|
906
|
-
y: y - top
|
|
907
|
-
});
|
|
908
|
-
this.forceUpdate();
|
|
909
|
-
};
|
|
910
|
-
Rnd2.prototype.getDraggablePosition = function() {
|
|
911
|
-
var _a = this.draggable.state, x = _a.x, y = _a.y;
|
|
912
|
-
return { x, y };
|
|
913
|
-
};
|
|
914
|
-
Rnd2.prototype.getParent = function() {
|
|
915
|
-
return this.resizable && this.resizable.parentNode;
|
|
916
|
-
};
|
|
917
|
-
Rnd2.prototype.getParentSize = function() {
|
|
918
|
-
return this.resizable.getParentSize();
|
|
919
|
-
};
|
|
920
|
-
Rnd2.prototype.getMaxSizesFromProps = function() {
|
|
921
|
-
var maxWidth = typeof this.props.maxWidth === "undefined" ? Number.MAX_SAFE_INTEGER : this.props.maxWidth;
|
|
922
|
-
var maxHeight = typeof this.props.maxHeight === "undefined" ? Number.MAX_SAFE_INTEGER : this.props.maxHeight;
|
|
923
|
-
return { maxWidth, maxHeight };
|
|
924
|
-
};
|
|
925
|
-
Rnd2.prototype.getSelfElement = function() {
|
|
926
|
-
return this.resizable && this.resizable.resizable;
|
|
927
|
-
};
|
|
928
|
-
Rnd2.prototype.getOffsetHeight = function(boundary) {
|
|
929
|
-
var scale = this.props.scale;
|
|
930
|
-
switch (this.props.bounds) {
|
|
931
|
-
case "window":
|
|
932
|
-
return window.innerHeight / scale;
|
|
933
|
-
case "body":
|
|
934
|
-
return document.body.offsetHeight / scale;
|
|
935
|
-
default:
|
|
936
|
-
return boundary.offsetHeight;
|
|
937
|
-
}
|
|
938
|
-
};
|
|
939
|
-
Rnd2.prototype.getOffsetWidth = function(boundary) {
|
|
940
|
-
var scale = this.props.scale;
|
|
941
|
-
switch (this.props.bounds) {
|
|
942
|
-
case "window":
|
|
943
|
-
return window.innerWidth / scale;
|
|
944
|
-
case "body":
|
|
945
|
-
return document.body.offsetWidth / scale;
|
|
946
|
-
default:
|
|
947
|
-
return boundary.offsetWidth;
|
|
948
|
-
}
|
|
949
|
-
};
|
|
950
|
-
Rnd2.prototype.onDragStart = function(e, data) {
|
|
951
|
-
if (this.props.onDragStart) {
|
|
952
|
-
this.props.onDragStart(e, data);
|
|
953
|
-
}
|
|
954
|
-
var pos = this.getDraggablePosition();
|
|
955
|
-
this.originalPosition = pos;
|
|
956
|
-
if (!this.props.bounds)
|
|
957
|
-
return;
|
|
958
|
-
var parent = this.getParent();
|
|
959
|
-
var scale = this.props.scale;
|
|
960
|
-
var boundary;
|
|
961
|
-
if (this.props.bounds === "parent") {
|
|
962
|
-
boundary = parent;
|
|
963
|
-
} else if (this.props.bounds === "body") {
|
|
964
|
-
var parentRect_1 = parent.getBoundingClientRect();
|
|
965
|
-
var parentLeft_1 = parentRect_1.left;
|
|
966
|
-
var parentTop_1 = parentRect_1.top;
|
|
967
|
-
var bodyRect = document.body.getBoundingClientRect();
|
|
968
|
-
var left_1 = -(parentLeft_1 - parent.offsetLeft * scale - bodyRect.left) / scale;
|
|
969
|
-
var top_1 = -(parentTop_1 - parent.offsetTop * scale - bodyRect.top) / scale;
|
|
970
|
-
var right = (document.body.offsetWidth - this.resizable.size.width * scale) / scale + left_1;
|
|
971
|
-
var bottom = (document.body.offsetHeight - this.resizable.size.height * scale) / scale + top_1;
|
|
972
|
-
return this.setState({ bounds: { top: top_1, right, bottom, left: left_1 } });
|
|
973
|
-
} else if (this.props.bounds === "window") {
|
|
974
|
-
if (!this.resizable)
|
|
975
|
-
return;
|
|
976
|
-
var parentRect_2 = parent.getBoundingClientRect();
|
|
977
|
-
var parentLeft_2 = parentRect_2.left;
|
|
978
|
-
var parentTop_2 = parentRect_2.top;
|
|
979
|
-
var left_2 = -(parentLeft_2 - parent.offsetLeft * scale) / scale;
|
|
980
|
-
var top_2 = -(parentTop_2 - parent.offsetTop * scale) / scale;
|
|
981
|
-
var right = (window.innerWidth - this.resizable.size.width * scale) / scale + left_2;
|
|
982
|
-
var bottom = (window.innerHeight - this.resizable.size.height * scale) / scale + top_2;
|
|
983
|
-
return this.setState({ bounds: { top: top_2, right, bottom, left: left_2 } });
|
|
984
|
-
} else if (typeof this.props.bounds === "string") {
|
|
985
|
-
boundary = document.querySelector(this.props.bounds);
|
|
986
|
-
} else if (this.props.bounds instanceof HTMLElement) {
|
|
987
|
-
boundary = this.props.bounds;
|
|
988
|
-
}
|
|
989
|
-
if (!(boundary instanceof HTMLElement) || !(parent instanceof HTMLElement)) {
|
|
990
|
-
return;
|
|
991
|
-
}
|
|
992
|
-
var boundaryRect = boundary.getBoundingClientRect();
|
|
993
|
-
var boundaryLeft = boundaryRect.left;
|
|
994
|
-
var boundaryTop = boundaryRect.top;
|
|
995
|
-
var parentRect = parent.getBoundingClientRect();
|
|
996
|
-
var parentLeft = parentRect.left;
|
|
997
|
-
var parentTop = parentRect.top;
|
|
998
|
-
var left = (boundaryLeft - parentLeft) / scale;
|
|
999
|
-
var top = boundaryTop - parentTop;
|
|
1000
|
-
if (!this.resizable)
|
|
1001
|
-
return;
|
|
1002
|
-
this.updateOffsetFromParent();
|
|
1003
|
-
var offset = this.offsetFromParent;
|
|
1004
|
-
this.setState({
|
|
1005
|
-
bounds: {
|
|
1006
|
-
top: top - offset.top,
|
|
1007
|
-
right: left + (boundary.offsetWidth - this.resizable.size.width) - offset.left / scale,
|
|
1008
|
-
bottom: top + (boundary.offsetHeight - this.resizable.size.height) - offset.top,
|
|
1009
|
-
left: left - offset.left / scale
|
|
1010
|
-
}
|
|
1011
|
-
});
|
|
1012
|
-
};
|
|
1013
|
-
Rnd2.prototype.onDrag = function(e, data) {
|
|
1014
|
-
if (!this.props.onDrag)
|
|
1015
|
-
return;
|
|
1016
|
-
var _a = this.offsetFromParent, left = _a.left, top = _a.top;
|
|
1017
|
-
if (!this.props.dragAxis || this.props.dragAxis === "both") {
|
|
1018
|
-
return this.props.onDrag(e, __assign(__assign({}, data), { x: data.x + left, y: data.y + top }));
|
|
1019
|
-
} else if (this.props.dragAxis === "x") {
|
|
1020
|
-
return this.props.onDrag(e, __assign(__assign({}, data), { x: data.x + left, y: this.originalPosition.y + top, deltaY: 0 }));
|
|
1021
|
-
} else if (this.props.dragAxis === "y") {
|
|
1022
|
-
return this.props.onDrag(e, __assign(__assign({}, data), { x: this.originalPosition.x + left, y: data.y + top, deltaX: 0 }));
|
|
1023
|
-
}
|
|
1024
|
-
};
|
|
1025
|
-
Rnd2.prototype.onDragStop = function(e, data) {
|
|
1026
|
-
if (!this.props.onDragStop)
|
|
1027
|
-
return;
|
|
1028
|
-
var _a = this.offsetFromParent, left = _a.left, top = _a.top;
|
|
1029
|
-
if (!this.props.dragAxis || this.props.dragAxis === "both") {
|
|
1030
|
-
return this.props.onDragStop(e, __assign(__assign({}, data), { x: data.x + left, y: data.y + top }));
|
|
1031
|
-
} else if (this.props.dragAxis === "x") {
|
|
1032
|
-
return this.props.onDragStop(e, __assign(__assign({}, data), { x: data.x + left, y: this.originalPosition.y + top, deltaY: 0 }));
|
|
1033
|
-
} else if (this.props.dragAxis === "y") {
|
|
1034
|
-
return this.props.onDragStop(e, __assign(__assign({}, data), { x: this.originalPosition.x + left, y: data.y + top, deltaX: 0 }));
|
|
1035
|
-
}
|
|
1036
|
-
};
|
|
1037
|
-
Rnd2.prototype.onResizeStart = function(e, dir, elementRef) {
|
|
1038
|
-
e.stopPropagation();
|
|
1039
|
-
this.setState({
|
|
1040
|
-
resizing: true
|
|
1041
|
-
});
|
|
1042
|
-
var scale = this.props.scale;
|
|
1043
|
-
var offset = this.offsetFromParent;
|
|
1044
|
-
var pos = this.getDraggablePosition();
|
|
1045
|
-
this.resizingPosition = { x: pos.x + offset.left, y: pos.y + offset.top };
|
|
1046
|
-
this.originalPosition = pos;
|
|
1047
|
-
if (this.props.bounds) {
|
|
1048
|
-
var parent_1 = this.getParent();
|
|
1049
|
-
var boundary = void 0;
|
|
1050
|
-
if (this.props.bounds === "parent") {
|
|
1051
|
-
boundary = parent_1;
|
|
1052
|
-
} else if (this.props.bounds === "body") {
|
|
1053
|
-
boundary = document.body;
|
|
1054
|
-
} else if (this.props.bounds === "window") {
|
|
1055
|
-
boundary = window;
|
|
1056
|
-
} else if (typeof this.props.bounds === "string") {
|
|
1057
|
-
boundary = document.querySelector(this.props.bounds);
|
|
1058
|
-
} else if (this.props.bounds instanceof HTMLElement) {
|
|
1059
|
-
boundary = this.props.bounds;
|
|
1060
|
-
}
|
|
1061
|
-
var self_1 = this.getSelfElement();
|
|
1062
|
-
if (self_1 instanceof Element && (boundary instanceof HTMLElement || boundary === window) && parent_1 instanceof HTMLElement) {
|
|
1063
|
-
var _a = this.getMaxSizesFromProps(), maxWidth = _a.maxWidth, maxHeight = _a.maxHeight;
|
|
1064
|
-
var parentSize = this.getParentSize();
|
|
1065
|
-
if (maxWidth && typeof maxWidth === "string") {
|
|
1066
|
-
if (maxWidth.endsWith("%")) {
|
|
1067
|
-
var ratio = Number(maxWidth.replace("%", "")) / 100;
|
|
1068
|
-
maxWidth = parentSize.width * ratio;
|
|
1069
|
-
} else if (maxWidth.endsWith("px")) {
|
|
1070
|
-
maxWidth = Number(maxWidth.replace("px", ""));
|
|
1071
|
-
}
|
|
1072
|
-
}
|
|
1073
|
-
if (maxHeight && typeof maxHeight === "string") {
|
|
1074
|
-
if (maxHeight.endsWith("%")) {
|
|
1075
|
-
var ratio = Number(maxHeight.replace("%", "")) / 100;
|
|
1076
|
-
maxHeight = parentSize.height * ratio;
|
|
1077
|
-
} else if (maxHeight.endsWith("px")) {
|
|
1078
|
-
maxHeight = Number(maxHeight.replace("px", ""));
|
|
1079
|
-
}
|
|
1080
|
-
}
|
|
1081
|
-
var selfRect = self_1.getBoundingClientRect();
|
|
1082
|
-
var selfLeft = selfRect.left;
|
|
1083
|
-
var selfTop = selfRect.top;
|
|
1084
|
-
var boundaryRect = this.props.bounds === "window" ? { left: 0, top: 0 } : boundary.getBoundingClientRect();
|
|
1085
|
-
var boundaryLeft = boundaryRect.left;
|
|
1086
|
-
var boundaryTop = boundaryRect.top;
|
|
1087
|
-
var offsetWidth = this.getOffsetWidth(boundary);
|
|
1088
|
-
var offsetHeight = this.getOffsetHeight(boundary);
|
|
1089
|
-
var hasLeft = dir.toLowerCase().endsWith("left");
|
|
1090
|
-
var hasRight = dir.toLowerCase().endsWith("right");
|
|
1091
|
-
var hasTop = dir.startsWith("top");
|
|
1092
|
-
var hasBottom = dir.startsWith("bottom");
|
|
1093
|
-
if ((hasLeft || hasTop) && this.resizable) {
|
|
1094
|
-
var max = (selfLeft - boundaryLeft) / scale + this.resizable.size.width;
|
|
1095
|
-
this.setState({ maxWidth: max > Number(maxWidth) ? maxWidth : max });
|
|
1096
|
-
}
|
|
1097
|
-
if (hasRight || this.props.lockAspectRatio && !hasLeft && !hasTop) {
|
|
1098
|
-
var max = offsetWidth + (boundaryLeft - selfLeft) / scale;
|
|
1099
|
-
this.setState({ maxWidth: max > Number(maxWidth) ? maxWidth : max });
|
|
1100
|
-
}
|
|
1101
|
-
if ((hasTop || hasLeft) && this.resizable) {
|
|
1102
|
-
var max = (selfTop - boundaryTop) / scale + this.resizable.size.height;
|
|
1103
|
-
this.setState({
|
|
1104
|
-
maxHeight: max > Number(maxHeight) ? maxHeight : max
|
|
1105
|
-
});
|
|
1106
|
-
}
|
|
1107
|
-
if (hasBottom || this.props.lockAspectRatio && !hasTop && !hasLeft) {
|
|
1108
|
-
var max = offsetHeight + (boundaryTop - selfTop) / scale;
|
|
1109
|
-
this.setState({
|
|
1110
|
-
maxHeight: max > Number(maxHeight) ? maxHeight : max
|
|
1111
|
-
});
|
|
1112
|
-
}
|
|
1113
|
-
}
|
|
1114
|
-
} else {
|
|
1115
|
-
this.setState({
|
|
1116
|
-
maxWidth: this.props.maxWidth,
|
|
1117
|
-
maxHeight: this.props.maxHeight
|
|
1118
|
-
});
|
|
1119
|
-
}
|
|
1120
|
-
if (this.props.onResizeStart) {
|
|
1121
|
-
this.props.onResizeStart(e, dir, elementRef);
|
|
1122
|
-
}
|
|
1123
|
-
};
|
|
1124
|
-
Rnd2.prototype.onResize = function(e, direction, elementRef, delta) {
|
|
1125
|
-
var _this = this;
|
|
1126
|
-
var newPos = { x: this.originalPosition.x, y: this.originalPosition.y };
|
|
1127
|
-
var left = -delta.width;
|
|
1128
|
-
var top = -delta.height;
|
|
1129
|
-
var directions = ["top", "left", "topLeft", "bottomLeft", "topRight"];
|
|
1130
|
-
if (directions.includes(direction)) {
|
|
1131
|
-
if (direction === "bottomLeft") {
|
|
1132
|
-
newPos.x += left;
|
|
1133
|
-
} else if (direction === "topRight") {
|
|
1134
|
-
newPos.y += top;
|
|
1135
|
-
} else {
|
|
1136
|
-
newPos.x += left;
|
|
1137
|
-
newPos.y += top;
|
|
1138
|
-
}
|
|
1139
|
-
}
|
|
1140
|
-
var draggableState = this.draggable.state;
|
|
1141
|
-
if (newPos.x !== draggableState.x || newPos.y !== draggableState.y) {
|
|
1142
|
-
flushSync(function() {
|
|
1143
|
-
_this.draggable.setState(newPos);
|
|
1144
|
-
});
|
|
1145
|
-
}
|
|
1146
|
-
this.updateOffsetFromParent();
|
|
1147
|
-
var offset = this.offsetFromParent;
|
|
1148
|
-
var x = this.getDraggablePosition().x + offset.left;
|
|
1149
|
-
var y = this.getDraggablePosition().y + offset.top;
|
|
1150
|
-
this.resizingPosition = { x, y };
|
|
1151
|
-
if (!this.props.onResize)
|
|
1152
|
-
return;
|
|
1153
|
-
this.props.onResize(e, direction, elementRef, delta, {
|
|
1154
|
-
x,
|
|
1155
|
-
y
|
|
1156
|
-
});
|
|
1157
|
-
};
|
|
1158
|
-
Rnd2.prototype.onResizeStop = function(e, direction, elementRef, delta) {
|
|
1159
|
-
this.setState({
|
|
1160
|
-
resizing: false
|
|
1161
|
-
});
|
|
1162
|
-
var _a = this.getMaxSizesFromProps(), maxWidth = _a.maxWidth, maxHeight = _a.maxHeight;
|
|
1163
|
-
this.setState({ maxWidth, maxHeight });
|
|
1164
|
-
if (this.props.onResizeStop) {
|
|
1165
|
-
this.props.onResizeStop(e, direction, elementRef, delta, this.resizingPosition);
|
|
1166
|
-
}
|
|
1167
|
-
};
|
|
1168
|
-
Rnd2.prototype.updateSize = function(size) {
|
|
1169
|
-
if (!this.resizable)
|
|
1170
|
-
return;
|
|
1171
|
-
this.resizable.updateSize({ width: size.width, height: size.height });
|
|
1172
|
-
};
|
|
1173
|
-
Rnd2.prototype.updatePosition = function(position) {
|
|
1174
|
-
this.draggable.setState(position);
|
|
1175
|
-
};
|
|
1176
|
-
Rnd2.prototype.updateOffsetFromParent = function() {
|
|
1177
|
-
var scale = this.props.scale;
|
|
1178
|
-
var parent = this.getParent();
|
|
1179
|
-
var self = this.getSelfElement();
|
|
1180
|
-
if (!parent || self === null) {
|
|
1181
|
-
return {
|
|
1182
|
-
top: 0,
|
|
1183
|
-
left: 0
|
|
1184
|
-
};
|
|
1185
|
-
}
|
|
1186
|
-
var parentRect = parent.getBoundingClientRect();
|
|
1187
|
-
var parentLeft = parentRect.left;
|
|
1188
|
-
var parentTop = parentRect.top;
|
|
1189
|
-
var selfRect = self.getBoundingClientRect();
|
|
1190
|
-
var position = this.getDraggablePosition();
|
|
1191
|
-
var scrollLeft = parent.scrollLeft;
|
|
1192
|
-
var scrollTop = parent.scrollTop;
|
|
1193
|
-
this.offsetFromParent = {
|
|
1194
|
-
left: selfRect.left - parentLeft + scrollLeft - position.x * scale,
|
|
1195
|
-
top: selfRect.top - parentTop + scrollTop - position.y * scale
|
|
1196
|
-
};
|
|
1197
|
-
};
|
|
1198
|
-
Rnd2.prototype.render = function() {
|
|
1199
|
-
var _this = this;
|
|
1200
|
-
var _a = this.props, disableDragging = _a.disableDragging, style = _a.style, dragHandleClassName = _a.dragHandleClassName, position = _a.position, onMouseDown = _a.onMouseDown, onMouseUp = _a.onMouseUp, dragAxis = _a.dragAxis, dragGrid = _a.dragGrid, bounds = _a.bounds, enableUserSelectHack = _a.enableUserSelectHack, cancel = _a.cancel, children = _a.children;
|
|
1201
|
-
_a.onResizeStart;
|
|
1202
|
-
_a.onResize;
|
|
1203
|
-
_a.onResizeStop;
|
|
1204
|
-
_a.onDragStart;
|
|
1205
|
-
_a.onDrag;
|
|
1206
|
-
_a.onDragStop;
|
|
1207
|
-
var resizeHandleStyles = _a.resizeHandleStyles, resizeHandleClasses = _a.resizeHandleClasses, resizeHandleComponent = _a.resizeHandleComponent, enableResizing = _a.enableResizing, resizeGrid = _a.resizeGrid, resizeHandleWrapperClass = _a.resizeHandleWrapperClass, resizeHandleWrapperStyle = _a.resizeHandleWrapperStyle, scale = _a.scale, allowAnyClick = _a.allowAnyClick, dragPositionOffset = _a.dragPositionOffset, resizableProps = __rest(_a, ["disableDragging", "style", "dragHandleClassName", "position", "onMouseDown", "onMouseUp", "dragAxis", "dragGrid", "bounds", "enableUserSelectHack", "cancel", "children", "onResizeStart", "onResize", "onResizeStop", "onDragStart", "onDrag", "onDragStop", "resizeHandleStyles", "resizeHandleClasses", "resizeHandleComponent", "enableResizing", "resizeGrid", "resizeHandleWrapperClass", "resizeHandleWrapperStyle", "scale", "allowAnyClick", "dragPositionOffset"]);
|
|
1208
|
-
var defaultValue = this.props.default ? __assign({}, this.props.default) : void 0;
|
|
1209
|
-
delete resizableProps.default;
|
|
1210
|
-
var cursorStyle = disableDragging || dragHandleClassName ? { cursor: "auto" } : { cursor: "move" };
|
|
1211
|
-
var innerStyle = __assign(__assign(__assign({}, resizableStyle), cursorStyle), style);
|
|
1212
|
-
var _b = this.offsetFromParent, left = _b.left, top = _b.top;
|
|
1213
|
-
var draggablePosition;
|
|
1214
|
-
if (position) {
|
|
1215
|
-
draggablePosition = {
|
|
1216
|
-
x: position.x - left,
|
|
1217
|
-
y: position.y - top
|
|
1218
|
-
};
|
|
1219
|
-
}
|
|
1220
|
-
var pos = this.state.resizing ? void 0 : draggablePosition;
|
|
1221
|
-
var dragAxisOrUndefined = this.state.resizing ? "both" : dragAxis;
|
|
1222
|
-
return createElement(
|
|
1223
|
-
Draggable,
|
|
1224
|
-
{
|
|
1225
|
-
ref: function(c) {
|
|
1226
|
-
if (!c)
|
|
1227
|
-
return;
|
|
1228
|
-
_this.draggable = c;
|
|
1229
|
-
},
|
|
1230
|
-
handle: dragHandleClassName ? ".".concat(dragHandleClassName) : void 0,
|
|
1231
|
-
defaultPosition: defaultValue,
|
|
1232
|
-
onMouseDown,
|
|
1233
|
-
// @ts-expect-error
|
|
1234
|
-
onMouseUp,
|
|
1235
|
-
onStart: this.onDragStart,
|
|
1236
|
-
onDrag: this.onDrag,
|
|
1237
|
-
onStop: this.onDragStop,
|
|
1238
|
-
axis: dragAxisOrUndefined,
|
|
1239
|
-
disabled: disableDragging,
|
|
1240
|
-
grid: dragGrid,
|
|
1241
|
-
bounds: bounds ? this.state.bounds : void 0,
|
|
1242
|
-
position: pos,
|
|
1243
|
-
enableUserSelectHack,
|
|
1244
|
-
cancel,
|
|
1245
|
-
scale,
|
|
1246
|
-
allowAnyClick,
|
|
1247
|
-
nodeRef: this.resizableElement,
|
|
1248
|
-
positionOffset: dragPositionOffset
|
|
1249
|
-
},
|
|
1250
|
-
createElement(Resizable, __assign({}, resizableProps, { ref: function(c) {
|
|
1251
|
-
if (!c)
|
|
1252
|
-
return;
|
|
1253
|
-
_this.resizable = c;
|
|
1254
|
-
_this.resizableElement.current = c.resizable;
|
|
1255
|
-
}, defaultSize: defaultValue, size: this.props.size, enable: typeof enableResizing === "boolean" ? getEnableResizingByFlag(enableResizing) : enableResizing, onResizeStart: this.onResizeStart, onResize: this.onResize, onResizeStop: this.onResizeStop, style: innerStyle, minWidth: this.props.minWidth, minHeight: this.props.minHeight, maxWidth: this.state.resizing ? this.state.maxWidth : this.props.maxWidth, maxHeight: this.state.resizing ? this.state.maxHeight : this.props.maxHeight, grid: resizeGrid, handleWrapperClass: resizeHandleWrapperClass, handleWrapperStyle: resizeHandleWrapperStyle, lockAspectRatio: this.props.lockAspectRatio, lockAspectRatioExtraWidth: this.props.lockAspectRatioExtraWidth, lockAspectRatioExtraHeight: this.props.lockAspectRatioExtraHeight, handleStyles: resizeHandleStyles, handleClasses: resizeHandleClasses, handleComponent: resizeHandleComponent, scale: this.props.scale }), children)
|
|
1256
|
-
);
|
|
1257
|
-
};
|
|
1258
|
-
Rnd2.defaultProps = {
|
|
1259
|
-
maxWidth: Number.MAX_SAFE_INTEGER,
|
|
1260
|
-
maxHeight: Number.MAX_SAFE_INTEGER,
|
|
1261
|
-
scale: 1,
|
|
1262
|
-
onResizeStart: function() {
|
|
1263
|
-
},
|
|
1264
|
-
onResize: function() {
|
|
1265
|
-
},
|
|
1266
|
-
onResizeStop: function() {
|
|
1267
|
-
},
|
|
1268
|
-
onDragStart: function() {
|
|
1269
|
-
},
|
|
1270
|
-
onDrag: function() {
|
|
1271
|
-
},
|
|
1272
|
-
onDragStop: function() {
|
|
1273
|
-
}
|
|
1274
|
-
};
|
|
1275
|
-
return Rnd2;
|
|
1276
|
-
}(PureComponent)
|
|
1277
|
-
);
|
|
1278
|
-
export {
|
|
1279
|
-
Rnd as R
|
|
1280
|
-
};
|