@onehat/ui 0.4.71 → 0.4.73
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/package.json +2 -1
- package/src/Components/Buttons/Button.js +20 -6
- package/src/Components/Container/ScreenContainer.js +1 -0
- package/src/Components/Editor/InlineEditor.js +2 -1
- package/src/Components/Form/Field/Color.js +2 -1
- package/src/Components/Form/Field/Combo/Combo.js +55 -37
- package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
- package/src/Components/Form/Field/Date.js +9 -8
- package/src/Components/Form/Field/Input.js +5 -4
- package/src/Components/Form/Field/Json.js +3 -2
- package/src/Components/Form/Field/TextArea.js +1 -1
- package/src/Components/Form/FieldSet.js +1 -1
- package/src/Components/Form/Form.js +4 -1
- package/src/Components/Gluestack/accordion/index.tsx +5 -1
- package/src/Components/Gluestack/actionsheet/index.tsx +5 -1
- package/src/Components/Gluestack/alert/index.tsx +5 -1
- package/src/Components/Gluestack/badge/index.tsx +5 -1
- package/src/Components/Gluestack/button/index.tsx +5 -1
- package/src/Components/Gluestack/checkbox/index.tsx +5 -1
- package/src/Components/Gluestack/fab/index.tsx +5 -1
- package/src/Components/Gluestack/form-control/index.tsx +5 -1
- package/src/Components/Gluestack/icon/createIcon.js +74 -0
- package/src/Components/Gluestack/icon/index.tsx +46 -88
- package/src/Components/Gluestack/input/index.tsx +5 -1
- package/src/Components/Gluestack/select/index.tsx +5 -1
- package/src/Components/Grid/Grid.js +24 -11
- package/src/Components/Grid/GridHeaderRow.js +4 -3
- package/src/Components/Grid/GridRow.js +35 -34
- package/src/Components/Grid/RowDragHandle.js +25 -10
- package/src/Components/Grid/RowHandle.js +55 -0
- package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
- package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +3 -2
- package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
- package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
- package/src/Components/Hoc/withAlert.js +21 -11
- package/src/Components/Hoc/withCollapsible.js +9 -4
- package/src/Components/Hoc/withComponent.js +6 -0
- package/src/Components/Hoc/withContextMenu.js +6 -0
- package/src/Components/Hoc/withData.js +3 -2
- package/src/Components/Hoc/withDnd.js +52 -40
- package/src/Components/Hoc/withDraggable.js +21 -5
- package/src/Components/Hoc/withEditor.js +2 -1
- package/src/Components/Hoc/withEvents.js +11 -1
- package/src/Components/Hoc/withFilters.js +7 -2
- package/src/Components/Hoc/withModal.js +3 -2
- package/src/Components/Hoc/withPdfButtons.js +3 -2
- package/src/Components/Hoc/withPermissions.js +3 -2
- package/src/Components/Hoc/withPresetButtons.js +3 -2
- package/src/Components/Hoc/withSelection.js +2 -8
- package/src/Components/Hoc/withToast.js +4 -2
- package/src/Components/Hoc/withTooltip.js +10 -1
- package/src/Components/Hoc/withValue.js +3 -9
- package/src/Components/Messages/GlobalModals.js +70 -0
- package/src/Components/Messages/Loading.js +2 -2
- package/src/Components/Messages/ProgressModal.js +63 -0
- package/src/Components/Messages/WaitMessage.js +7 -2
- package/src/Components/Report/Report.js +15 -5
- package/src/Components/Toolbar/Pagination.js +1 -1
- package/src/Components/Toolbar/Toolbar.js +26 -6
- package/src/Components/Tree/Tree.js +22 -6
- package/src/Components/Tree/TreeNode.js +11 -11
- package/src/Components/Tree/TreeNodeDragHandle.js +8 -4
- package/src/Components/Viewer/MeterTypeText.js +21 -1
- package/src/Components/Viewer/TextWithLinks.js +2 -1
- package/src/Constants/Dates.js +5 -2
- package/src/Constants/MeterTypes.js +2 -0
- package/src/Functions/addIconProps.js +46 -0
- package/src/Functions/downloadInBackground.js +47 -7
- package/src/Functions/getReport.js +5 -2
- package/src/Functions/testProps.js +1 -1
- package/src/Functions/trackEngagementHit.js +2 -1
- package/src/Hooks/useWhyDidYouUpdate.js +33 -0
- package/src/PlatformImports/Web/Attachments.js +1 -1
- package/src/Components/Hoc/withBlank.js +0 -10
|
@@ -14,7 +14,7 @@ import _ from 'lodash';
|
|
|
14
14
|
export default function withSelection(WrappedComponent) {
|
|
15
15
|
return forwardRef((props, ref) => {
|
|
16
16
|
|
|
17
|
-
if (props.secondaryDisableWithSelection) {
|
|
17
|
+
if (props.secondaryDisableWithSelection || props.secondaryAlreadyHasWithSelection) {
|
|
18
18
|
return <WrappedComponent {...props} />;
|
|
19
19
|
}
|
|
20
20
|
|
|
@@ -414,8 +414,9 @@ export default function withSelection(WrappedComponent) {
|
|
|
414
414
|
|
|
415
415
|
return <WrappedComponent
|
|
416
416
|
{...props}
|
|
417
|
-
ref={ref}
|
|
418
417
|
secondaryDisableWithSelection={false}
|
|
418
|
+
secondaryAlreadyHasWithSelection={true}
|
|
419
|
+
ref={ref}
|
|
419
420
|
secondarySelection={secondaryGetSelection()}
|
|
420
421
|
secondaryGetSelection={secondaryGetSelection}
|
|
421
422
|
secondarySetSelection={secondarySetSelection}
|
|
@@ -10,7 +10,7 @@ import _ from 'lodash';
|
|
|
10
10
|
export default function withSecondaryValue(WrappedComponent) {
|
|
11
11
|
return (props) => {
|
|
12
12
|
|
|
13
|
-
if (props.secondaryDisableWithValue) {
|
|
13
|
+
if (props.secondaryDisableWithValue || props.secondaryAlreadyHasWithValue) {
|
|
14
14
|
return <WrappedComponent {...props} />;
|
|
15
15
|
}
|
|
16
16
|
|
|
@@ -146,6 +146,7 @@ export default function withSecondaryValue(WrappedComponent) {
|
|
|
146
146
|
return <WrappedComponent
|
|
147
147
|
{...props}
|
|
148
148
|
secondaryDisableWithValue={false}
|
|
149
|
+
secondaryAlreadyHasWithValue={true}
|
|
149
150
|
secondaryValue={convertedValue}
|
|
150
151
|
secondarySetValue={secondarySetValue}
|
|
151
152
|
secondaryOnChangeSelection={secondaryOnChangeSelection}
|
|
@@ -19,7 +19,7 @@ import _ from 'lodash';
|
|
|
19
19
|
function withAlert(WrappedComponent) {
|
|
20
20
|
return forwardRef((props, ref) => {
|
|
21
21
|
|
|
22
|
-
if (props.disableWithAlert || props.
|
|
22
|
+
if (props.disableWithAlert || props.alreadyHasWithAlert) {
|
|
23
23
|
return <WrappedComponent {...props} ref={ref} />;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -29,9 +29,10 @@ function withAlert(WrappedComponent) {
|
|
|
29
29
|
} = props,
|
|
30
30
|
getBody = (args) => {
|
|
31
31
|
const {
|
|
32
|
-
icon,
|
|
32
|
+
icon = TriangleExclamation,
|
|
33
33
|
message,
|
|
34
|
-
|
|
34
|
+
textColor = 'text-black',
|
|
35
|
+
fillColor = 'fill-black',
|
|
35
36
|
} = args;
|
|
36
37
|
return <HStack className="withAlert-HStack flex-1 w-full">
|
|
37
38
|
<Box className={clsx(
|
|
@@ -43,12 +44,15 @@ function withAlert(WrappedComponent) {
|
|
|
43
44
|
'justify-center',
|
|
44
45
|
'pr-3',
|
|
45
46
|
)}>
|
|
46
|
-
<Icon
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
47
|
+
<Icon
|
|
48
|
+
as={icon}
|
|
49
|
+
className={clsx(
|
|
50
|
+
'withAlert-Icon',
|
|
51
|
+
'h-[40px]',
|
|
52
|
+
'w-[40px]',
|
|
53
|
+
fillColor,
|
|
54
|
+
)}
|
|
55
|
+
/>
|
|
52
56
|
</Box>
|
|
53
57
|
<Box className={clsx(
|
|
54
58
|
'withAlert-Box2',
|
|
@@ -60,7 +64,7 @@ function withAlert(WrappedComponent) {
|
|
|
60
64
|
)}>
|
|
61
65
|
<Text className={clsx(
|
|
62
66
|
'withAlert-Text',
|
|
63
|
-
|
|
67
|
+
textColor,
|
|
64
68
|
'text-[18px]',
|
|
65
69
|
'flex-none',
|
|
66
70
|
'mr-2',
|
|
@@ -108,7 +112,7 @@ function withAlert(WrappedComponent) {
|
|
|
108
112
|
body: getBody({
|
|
109
113
|
icon: TriangleExclamation,
|
|
110
114
|
message,
|
|
111
|
-
|
|
115
|
+
fillColor: 'fill-red-500',
|
|
112
116
|
}),
|
|
113
117
|
onOk: () => {
|
|
114
118
|
hideModal();
|
|
@@ -121,6 +125,7 @@ function withAlert(WrappedComponent) {
|
|
|
121
125
|
customButtons: buttons ?? null,
|
|
122
126
|
h: 250,
|
|
123
127
|
w: 400,
|
|
128
|
+
whichModal: 'alert',
|
|
124
129
|
});
|
|
125
130
|
},
|
|
126
131
|
onConfirm = (message, onYes, includeCancel = false, onNo) => {
|
|
@@ -145,6 +150,7 @@ function withAlert(WrappedComponent) {
|
|
|
145
150
|
includeCancel,
|
|
146
151
|
h: 250,
|
|
147
152
|
w: 400,
|
|
153
|
+
whichModal: 'confirm',
|
|
148
154
|
});
|
|
149
155
|
},
|
|
150
156
|
onInfo = (message) => {
|
|
@@ -160,6 +166,7 @@ function withAlert(WrappedComponent) {
|
|
|
160
166
|
canClose: true,
|
|
161
167
|
h: 200,
|
|
162
168
|
w: 400,
|
|
169
|
+
whichModal: 'info',
|
|
163
170
|
});
|
|
164
171
|
};
|
|
165
172
|
|
|
@@ -170,7 +177,10 @@ function withAlert(WrappedComponent) {
|
|
|
170
177
|
return <WrappedComponent
|
|
171
178
|
{...props}
|
|
172
179
|
ref={ref}
|
|
180
|
+
disableWithAlert={false}
|
|
181
|
+
alreadyHasWithAlert={true}
|
|
173
182
|
alert={onAlert}
|
|
183
|
+
getAlertBody={getBody}
|
|
174
184
|
confirm={onConfirm}
|
|
175
185
|
hideAlert={hideModal}
|
|
176
186
|
showInfo={onInfo}
|
|
@@ -2,8 +2,12 @@ import { forwardRef, useState } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export default function withCollapsible(WrappedComponent) {
|
|
4
4
|
return forwardRef((props, ref) => {
|
|
5
|
-
|
|
6
|
-
|
|
5
|
+
|
|
6
|
+
if (props.alreadyHasWithCollapsible) {
|
|
7
|
+
return <WrappedComponent {...props} ref={ref} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
const {
|
|
7
11
|
isCollapsed = false,
|
|
8
12
|
startsCollapsed = false,
|
|
9
13
|
setIsCollapsed,
|
|
@@ -12,10 +16,11 @@ export default function withCollapsible(WrappedComponent) {
|
|
|
12
16
|
[localIsCollapsed, setLocalIsCollapsed] = useState(startsCollapsed);
|
|
13
17
|
|
|
14
18
|
return <WrappedComponent
|
|
15
|
-
isCollapsed={bypass ? isCollapsed : localIsCollapsed}
|
|
16
|
-
setIsCollapsed={bypass ? setIsCollapsed : setLocalIsCollapsed}
|
|
17
19
|
{...props}
|
|
20
|
+
alreadyHasWithCollapsible={true}
|
|
18
21
|
ref={ref}
|
|
22
|
+
isCollapsed={bypass ? isCollapsed : localIsCollapsed}
|
|
23
|
+
setIsCollapsed={bypass ? setIsCollapsed : setLocalIsCollapsed}
|
|
19
24
|
/>;
|
|
20
25
|
});
|
|
21
26
|
}
|
|
@@ -14,6 +14,10 @@ import _ from 'lodash';
|
|
|
14
14
|
export default function withComponent(WrappedComponent) {
|
|
15
15
|
return forwardRef((props, ref) => {
|
|
16
16
|
|
|
17
|
+
// if (props.disableWithComponent || props.alreadyHasWithComponent) {
|
|
18
|
+
// return <WrappedComponent {...props} ref={ref} />;
|
|
19
|
+
// }
|
|
20
|
+
|
|
17
21
|
props = _.clone(props); // without cloning, I couldn't write to props
|
|
18
22
|
|
|
19
23
|
// translate h, w, and flex tokens to styles
|
|
@@ -90,6 +94,8 @@ export default function withComponent(WrappedComponent) {
|
|
|
90
94
|
self={selfRef.current}
|
|
91
95
|
{...propsToPass}
|
|
92
96
|
ref={ref}
|
|
97
|
+
disableWithComponent={false}
|
|
98
|
+
// alreadyHasWithComponent={true}
|
|
93
99
|
/>;
|
|
94
100
|
});
|
|
95
101
|
}
|
|
@@ -11,6 +11,11 @@ import _ from 'lodash';
|
|
|
11
11
|
|
|
12
12
|
export default function withContextMenu(WrappedComponent) {
|
|
13
13
|
return forwardRef((props, ref) => {
|
|
14
|
+
|
|
15
|
+
if (props.alreadyHasWithContextMenu) {
|
|
16
|
+
return <WrappedComponent {...props} ref={ref} />;
|
|
17
|
+
}
|
|
18
|
+
|
|
14
19
|
const {
|
|
15
20
|
// extract and pass
|
|
16
21
|
disableContextMenu = false,
|
|
@@ -161,6 +166,7 @@ export default function withContextMenu(WrappedComponent) {
|
|
|
161
166
|
|
|
162
167
|
return <WrappedComponent
|
|
163
168
|
{...propsToPass}
|
|
169
|
+
alreadyHasWithContextMenu={true}
|
|
164
170
|
ref={ref}
|
|
165
171
|
onContextMenu={onContextMenu}
|
|
166
172
|
/>;
|
|
@@ -12,7 +12,7 @@ import _ from 'lodash';
|
|
|
12
12
|
export default function withData(WrappedComponent) {
|
|
13
13
|
return forwardRef((props, ref) => {
|
|
14
14
|
|
|
15
|
-
if (props.disableWithData) {
|
|
15
|
+
if (props.disableWithData || props.alreadyHasWithData) {
|
|
16
16
|
return <WrappedComponent {...props} ref={ref} />;
|
|
17
17
|
}
|
|
18
18
|
|
|
@@ -121,8 +121,9 @@ export default function withData(WrappedComponent) {
|
|
|
121
121
|
|
|
122
122
|
return <WrappedComponent
|
|
123
123
|
{...props}
|
|
124
|
-
ref={ref}
|
|
125
124
|
disableWithData={false}
|
|
125
|
+
alreadyHasWithData={true}
|
|
126
|
+
ref={ref}
|
|
126
127
|
Repository={LocalRepository}
|
|
127
128
|
fields={fields}
|
|
128
129
|
idField={idField}
|
|
@@ -16,10 +16,27 @@ import {
|
|
|
16
16
|
// If you need constraints, you can potentially use a CustomDragLayer (see code at bottom)
|
|
17
17
|
// but it will lag behind, compared to what the native drag layer can do
|
|
18
18
|
|
|
19
|
+
function defaultDragCollect(monitor, props2) { // Optional. The collecting function. It should return a plain object of the props to return for injection into your component. It receives two parameters, monitor and props. Read the overview for an introduction to the monitors and the collecting function. See the collecting function described in detail in the next section.
|
|
20
|
+
// monitor fn determines which props from dnd state get passed
|
|
21
|
+
return {
|
|
22
|
+
// canDrag: !!monitor.canDrag(), // Returns trueif no drag operation is in progress, and the owner's canDrag() returns true or is not defined.
|
|
23
|
+
isDragging: !!monitor.isDragging(), // Returns trueif a drag operation is in progress, and either the owner initiated the drag, or its isDragging() is defined and returns true.
|
|
24
|
+
type: monitor.getItemType(), // Returns a string or a symbol identifying the type of the current dragged item. Returns null if no item is being dragged.
|
|
25
|
+
item: monitor.getItem(), // Returns a plain object representing the currently dragged item. Every drag source must specify it by returning an object from its beginDrag() method. Returns nullif no item is being dragged.
|
|
26
|
+
dropResult: monitor.getDropResult(), // Returns a plain object representing the last recorded drop result. The drop targets may optionally specify it by returning an object from their drop()methods. When a chain of drop()is dispatched for the nested targets, bottom up, any parent that explicitly returns its own result from drop()overrides the child drop result previously set by the child. Returns nullif called outside endDrag().
|
|
27
|
+
didDrop: !!monitor.didDrop(), // Returns trueif some drop target has handled the drop event, falseotherwise. Even if a target did not return a drop result, didDrop() returns true. Use it inside endDrag()to test whether any drop target has handled the drop. Returns falseif called outside endDrag().
|
|
28
|
+
initialClientOffset: monitor.getInitialClientOffset(), // Returns the { x, y }client offset of the pointer at the time when the current drag operation has started. Returns nullif no item is being dragged.
|
|
29
|
+
initialSourceClientOffset: monitor.getInitialSourceClientOffset(), // Returns the { x, y }client offset of the drag source component's root DOM node at the time when the current drag operation has started. Returns nullif no item is being dragged.
|
|
30
|
+
clientOffset: monitor.getClientOffset(), // Returns the last recorded { x, y }client offset of the pointer while a drag operation is in progress. Returns nullif no item is being dragged.
|
|
31
|
+
differenceFromInitialOffset: monitor.getDifferenceFromInitialOffset(), // Returns the { x, y }difference between the last recorded client offset of the pointer and the client offset when the current drag operation has started. Returns nullif no item is being dragged.
|
|
32
|
+
sourceClientOffset: monitor.getSourceClientOffset(), // Returns the projected { x, y }client offset of the drag source component's root DOM node, based on its position at the time when the current drag operation has started, and the movement difference. Returns nullif no item is being dragged.
|
|
33
|
+
};
|
|
34
|
+
};
|
|
35
|
+
|
|
19
36
|
export function withDragSource(WrappedComponent) {
|
|
20
37
|
return forwardRef((props, ref) => {
|
|
21
|
-
|
|
22
|
-
if (!props.isDragSource) {
|
|
38
|
+
|
|
39
|
+
if (!props.isDragSource || props.alreadyHasDragSource) {
|
|
23
40
|
return <WrappedComponent {...props} ref={ref} />;
|
|
24
41
|
}
|
|
25
42
|
|
|
@@ -37,36 +54,27 @@ export function withDragSource(WrappedComponent) {
|
|
|
37
54
|
dragOptions = null,
|
|
38
55
|
dropEffect = null,
|
|
39
56
|
// onDrag,
|
|
57
|
+
onDragStart = null,
|
|
40
58
|
onDragEnd = null,
|
|
41
59
|
canDrag = null,
|
|
42
60
|
isDragging = null,
|
|
43
61
|
getDragProxy,
|
|
44
|
-
dragCollect =
|
|
45
|
-
// monitor fn determines which props from dnd state get passed
|
|
46
|
-
return {
|
|
47
|
-
// canDrag: !!monitor.canDrag(), // Returns trueif no drag operation is in progress, and the owner's canDrag() returns true or is not defined.
|
|
48
|
-
isDragging: !!monitor.isDragging(), // Returns trueif a drag operation is in progress, and either the owner initiated the drag, or its isDragging() is defined and returns true.
|
|
49
|
-
type: monitor.getItemType(), // Returns a string or a symbol identifying the type of the current dragged item. Returns null if no item is being dragged.
|
|
50
|
-
item: monitor.getItem(), // Returns a plain object representing the currently dragged item. Every drag source must specify it by returning an object from its beginDrag() method. Returns nullif no item is being dragged.
|
|
51
|
-
dropResult: monitor.getDropResult(), // Returns a plain object representing the last recorded drop result. The drop targets may optionally specify it by returning an object from their drop()methods. When a chain of drop()is dispatched for the nested targets, bottom up, any parent that explicitly returns its own result from drop()overrides the child drop result previously set by the child. Returns nullif called outside endDrag().
|
|
52
|
-
didDrop: !!monitor.didDrop(), // Returns trueif some drop target has handled the drop event, falseotherwise. Even if a target did not return a drop result, didDrop() returns true. Use it inside endDrag()to test whether any drop target has handled the drop. Returns falseif called outside endDrag().
|
|
53
|
-
initialClientOffset: monitor.getInitialClientOffset(), // Returns the { x, y }client offset of the pointer at the time when the current drag operation has started. Returns nullif no item is being dragged.
|
|
54
|
-
initialSourceClientOffset: monitor.getInitialSourceClientOffset(), // Returns the { x, y }client offset of the drag source component's root DOM node at the time when the current drag operation has started. Returns nullif no item is being dragged.
|
|
55
|
-
clientOffset: monitor.getClientOffset(), // Returns the last recorded { x, y }client offset of the pointer while a drag operation is in progress. Returns nullif no item is being dragged.
|
|
56
|
-
differenceFromInitialOffset: monitor.getDifferenceFromInitialOffset(), // Returns the { x, y }difference between the last recorded client offset of the pointer and the client offset when the current drag operation has started. Returns nullif no item is being dragged.
|
|
57
|
-
sourceClientOffset: monitor.getSourceClientOffset(), // Returns the projected { x, y }client offset of the drag source component's root DOM node, based on its position at the time when the current drag operation has started, and the movement difference. Returns nullif no item is being dragged.
|
|
58
|
-
};
|
|
59
|
-
},
|
|
62
|
+
dragCollect = defaultDragCollect,
|
|
60
63
|
} = props,
|
|
61
64
|
[dragState, dragSourceRef, dragPreviewRef] = useDrag(() => { // A specification object or a function that creates a specification object.
|
|
62
65
|
// The useDrag hook provides a way to wire your component into the DnD system as a drag source. By passing in a specification into useDrag, you declaratively describe the typeof draggable being generated, the itemobject representing the drag source, what props to collect, and more. The useDraghooks returns a few key items: a set of collected props, and refs that may be attached to drag source and drag preview elements
|
|
63
66
|
|
|
64
67
|
return {
|
|
65
68
|
type: dragSourceType, // Required. This must be either a string or a symbol. Only the drop targets registered for the same type will react to this item.
|
|
66
|
-
item: {
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
69
|
+
item: () => { // Required (object or function). If a function, it runs only once at the start of a drag.
|
|
70
|
+
if (dragSourceItem.onDragStart) {
|
|
71
|
+
dragSourceItem.onDragStart();
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...dragSourceItem,
|
|
75
|
+
getDragProxy,
|
|
76
|
+
};
|
|
77
|
+
},
|
|
70
78
|
// When an object, it is a plain JavaScript object describing the data being dragged. This is the only information available to the drop targets about the drag source so it's important to pick the minimal data they need to know. You may be tempted to put a complex reference here, but you should try very hard to avoid doing this because it couples the drag sources and drop targets. It's a good idea to use something like { id }.
|
|
71
79
|
// When a function, it is fired at the beginning of the drag operation and returns an object representing the drag operation (see first bullet). If null is returned, the drag operation is cancelled.
|
|
72
80
|
previewOptions: dragPreviewOptions, // Optional. A plain JavaScript object describing drag preview options.
|
|
@@ -92,7 +100,7 @@ export function withDragSource(WrappedComponent) {
|
|
|
92
100
|
};
|
|
93
101
|
},*/
|
|
94
102
|
};
|
|
95
|
-
}),
|
|
103
|
+
}, [dragSourceItem, getDragProxy, dragSourceType, dragPreviewOptions, dragOptions, dropEffect, onDragEnd, canDrag, isDragging, dragCollect]),
|
|
96
104
|
{
|
|
97
105
|
canDrag: stateCanDrag,
|
|
98
106
|
isDragging: stateIsDragging,
|
|
@@ -114,11 +122,12 @@ export function withDragSource(WrappedComponent) {
|
|
|
114
122
|
if (layer.isDragging && dragSourceItem?.id === layer.item.id) {
|
|
115
123
|
dragSourceItem.onDrag(layer);
|
|
116
124
|
}
|
|
117
|
-
}, [layer]);
|
|
125
|
+
}, [layer, dragSourceItem]);
|
|
118
126
|
}
|
|
119
127
|
|
|
120
128
|
return <WrappedComponent
|
|
121
129
|
{...props}
|
|
130
|
+
alreadyHasDragSource={true}
|
|
122
131
|
ref={ref}
|
|
123
132
|
canDrag={stateCanDrag}
|
|
124
133
|
isDragging={stateIsDragging}
|
|
@@ -129,11 +138,17 @@ export function withDragSource(WrappedComponent) {
|
|
|
129
138
|
});
|
|
130
139
|
}
|
|
131
140
|
|
|
132
|
-
|
|
141
|
+
function defaultDropCollect(monitor, props) {
|
|
142
|
+
return {
|
|
143
|
+
canDrop: !!monitor.canDrop(),
|
|
144
|
+
isOver: !!monitor.isOver(),
|
|
145
|
+
draggedItem: monitor.getItem(), // Pass the dragged item so TreeNode can evaluate custom logic
|
|
146
|
+
};
|
|
147
|
+
}
|
|
133
148
|
export function withDropTarget(WrappedComponent) {
|
|
134
149
|
return forwardRef((props, ref) => {
|
|
135
150
|
|
|
136
|
-
if (!props.isDropTarget) {
|
|
151
|
+
if (!props.isDropTarget || props.alreadyHasDropTarget) {
|
|
137
152
|
return <WrappedComponent {...props} ref={ref} />;
|
|
138
153
|
}
|
|
139
154
|
|
|
@@ -147,13 +162,7 @@ export function withDropTarget(WrappedComponent) {
|
|
|
147
162
|
onDrop = null,
|
|
148
163
|
onDropHover = null,
|
|
149
164
|
canDrop = null,
|
|
150
|
-
dropCollect =
|
|
151
|
-
return {
|
|
152
|
-
canDrop: !!monitor.canDrop(),
|
|
153
|
-
isOver: !!monitor.isOver(),
|
|
154
|
-
draggedItem: monitor.getItem(), // Pass the dragged item so TreeNode can evaluate custom logic
|
|
155
|
-
};
|
|
156
|
-
},
|
|
165
|
+
dropCollect = defaultDropCollect,
|
|
157
166
|
} = props,
|
|
158
167
|
localTargetRef = useRef(null),
|
|
159
168
|
[dropState, dropTargetRef] = useDrop(() => { // A specification object or a function that creates a specification object.
|
|
@@ -180,7 +189,7 @@ export function withDropTarget(WrappedComponent) {
|
|
|
180
189
|
};
|
|
181
190
|
},*/
|
|
182
191
|
};
|
|
183
|
-
}),
|
|
192
|
+
}, [dropTargetAccept, dropOptions, onDrop, onDropHover, canDrop, dropCollect]),
|
|
184
193
|
{
|
|
185
194
|
canDrop: stateCanDrop,
|
|
186
195
|
isOver,
|
|
@@ -197,8 +206,9 @@ export function withDropTarget(WrappedComponent) {
|
|
|
197
206
|
dropTargetRef(localTargetRef); // register DOM node with react-dnd
|
|
198
207
|
|
|
199
208
|
return <WrappedComponent
|
|
200
|
-
|
|
209
|
+
alreadyHasDropTarget={true}
|
|
201
210
|
ref={ref}
|
|
211
|
+
canDrop={stateCanDrop}
|
|
202
212
|
isOver={isOver}
|
|
203
213
|
dropTargetRef={localTargetRef}
|
|
204
214
|
draggedItem={draggedItem} // Pass the dragged item
|
|
@@ -213,11 +223,13 @@ export function GlobalDragProxy() {
|
|
|
213
223
|
isDragging,
|
|
214
224
|
item,
|
|
215
225
|
currentOffset,
|
|
216
|
-
} = useDragLayer((monitor) =>
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
226
|
+
} = useDragLayer((monitor) => {
|
|
227
|
+
return {
|
|
228
|
+
isDragging: monitor.isDragging(),
|
|
229
|
+
item: monitor.getItem(),
|
|
230
|
+
currentOffset: monitor.getSourceClientOffset(),
|
|
231
|
+
};
|
|
232
|
+
});
|
|
221
233
|
|
|
222
234
|
if (!isDragging || !currentOffset || CURRENT_MODE !== UI_MODE_WEB) { // Native uses a native drag layer, so we don't need to render a custom proxy
|
|
223
235
|
return null;
|
|
@@ -23,7 +23,7 @@ import getComponentFromType from '../../Functions/getComponentFromType.js';
|
|
|
23
23
|
export default function withDraggable(WrappedComponent) {
|
|
24
24
|
return forwardRef((props, ref) => {
|
|
25
25
|
|
|
26
|
-
if (!props.isDraggable) {
|
|
26
|
+
if (!props.isDraggable || props.alreadyHasDraggable) {
|
|
27
27
|
return <WrappedComponent {...props} ref={ref} />;
|
|
28
28
|
}
|
|
29
29
|
|
|
@@ -237,7 +237,11 @@ export default function withDraggable(WrappedComponent) {
|
|
|
237
237
|
{...draggableProps}
|
|
238
238
|
>
|
|
239
239
|
<div ref={nodeRef} className="nsResize">
|
|
240
|
-
<WrappedComponent
|
|
240
|
+
<WrappedComponent
|
|
241
|
+
{...propsToPass}
|
|
242
|
+
alreadyHasDraggable={true}
|
|
243
|
+
ref={ref}
|
|
244
|
+
/>
|
|
241
245
|
</div>
|
|
242
246
|
</Draggable>;
|
|
243
247
|
} else if (mode === HORIZONTAL) {
|
|
@@ -252,7 +256,11 @@ export default function withDraggable(WrappedComponent) {
|
|
|
252
256
|
{...draggableProps}
|
|
253
257
|
>
|
|
254
258
|
<div ref={nodeRef} className="ewResize" style={{ height: '100%', }}>
|
|
255
|
-
<WrappedComponent
|
|
259
|
+
<WrappedComponent
|
|
260
|
+
{...propsToPass}
|
|
261
|
+
alreadyHasDraggable={true}
|
|
262
|
+
ref={ref}
|
|
263
|
+
/>
|
|
256
264
|
</div>
|
|
257
265
|
</Draggable>;
|
|
258
266
|
}
|
|
@@ -268,14 +276,22 @@ export default function withDraggable(WrappedComponent) {
|
|
|
268
276
|
nodeRef={nodeRef}
|
|
269
277
|
{...draggableProps}
|
|
270
278
|
>
|
|
271
|
-
<WrappedComponent
|
|
279
|
+
<WrappedComponent
|
|
280
|
+
{...propsToPass}
|
|
281
|
+
alreadyHasDraggable={true}
|
|
282
|
+
ref={nodeRef}
|
|
283
|
+
/>
|
|
272
284
|
</Draggable>;
|
|
273
285
|
} else if (CURRENT_MODE === UI_MODE_NATIVE) {
|
|
274
286
|
|
|
275
287
|
// NOT YET IMPLEMENTED
|
|
276
288
|
// Really need to replace most of this, as much of it is web-centric.
|
|
277
289
|
|
|
278
|
-
return <WrappedComponent
|
|
290
|
+
return <WrappedComponent
|
|
291
|
+
{...propsToPass}
|
|
292
|
+
alreadyHasDraggable={true}
|
|
293
|
+
ref={ref}
|
|
294
|
+
/>;
|
|
279
295
|
|
|
280
296
|
}
|
|
281
297
|
});
|
|
@@ -21,7 +21,7 @@ import _ from 'lodash';
|
|
|
21
21
|
export default function withEditor(WrappedComponent, isTree = false) {
|
|
22
22
|
return forwardRef((props, ref) => {
|
|
23
23
|
|
|
24
|
-
if (props.disableWithEditor) {
|
|
24
|
+
if (props.disableWithEditor || props.alreadyHasWithEditor) {
|
|
25
25
|
return <WrappedComponent {...props} ref={ref} isTree={isTree} />;
|
|
26
26
|
}
|
|
27
27
|
|
|
@@ -702,6 +702,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
|
|
|
702
702
|
{...props}
|
|
703
703
|
ref={ref}
|
|
704
704
|
disableWithEditor={false}
|
|
705
|
+
alreadyHasWithEditor={true}
|
|
705
706
|
currentRecord={currentRecord}
|
|
706
707
|
setCurrentRecord={setCurrentRecord}
|
|
707
708
|
isEditorShown={isEditorShown}
|
|
@@ -2,9 +2,19 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
|
|
3
3
|
export default function withEvents(WrappedComponent) {
|
|
4
4
|
return forwardRef((props, ref) => {
|
|
5
|
+
|
|
6
|
+
if (props.alreadyHasWithEvents) {
|
|
7
|
+
return <WrappedComponent {...props} ref={ref} />;
|
|
8
|
+
}
|
|
9
|
+
|
|
5
10
|
const {
|
|
6
11
|
onEvent,
|
|
7
12
|
} = props;
|
|
8
|
-
return <WrappedComponent
|
|
13
|
+
return <WrappedComponent
|
|
14
|
+
{...props}
|
|
15
|
+
alreadyHasWithEvents={true}
|
|
16
|
+
ref={ref}
|
|
17
|
+
fireEvent={onEvent}
|
|
18
|
+
/>;
|
|
9
19
|
});
|
|
10
20
|
}
|
|
@@ -42,7 +42,7 @@ const isWindows = Platform.OS === 'windows';
|
|
|
42
42
|
export default function withFilters(WrappedComponent) {
|
|
43
43
|
return forwardRef((props, ref) => {
|
|
44
44
|
|
|
45
|
-
if (!props.useFilters) {
|
|
45
|
+
if (!props.useFilters || props.alreadyHasWithFilters) {
|
|
46
46
|
return <WrappedComponent {...props} ref={ref} />;
|
|
47
47
|
}
|
|
48
48
|
|
|
@@ -695,7 +695,12 @@ export default function withFilters(WrappedComponent) {
|
|
|
695
695
|
</HStack>}
|
|
696
696
|
</Toolbar>;
|
|
697
697
|
|
|
698
|
-
return <WrappedComponent
|
|
698
|
+
return <WrappedComponent
|
|
699
|
+
{...props}
|
|
700
|
+
ref={ref}
|
|
701
|
+
alreadyHasWithFilters={true}
|
|
702
|
+
topToolbar={toolbar}
|
|
703
|
+
/>;
|
|
699
704
|
|
|
700
705
|
});
|
|
701
706
|
}
|
|
@@ -19,7 +19,7 @@ import _ from 'lodash';
|
|
|
19
19
|
export default function withModal(WrappedComponent) {
|
|
20
20
|
return forwardRef((props, ref) => {
|
|
21
21
|
|
|
22
|
-
if (props.disableWithModal || props.
|
|
22
|
+
if (props.disableWithModal || props.alreadyHasWithModal) {
|
|
23
23
|
return <WrappedComponent {...props} ref={ref} />;
|
|
24
24
|
}
|
|
25
25
|
|
|
@@ -180,12 +180,13 @@ export default function withModal(WrappedComponent) {
|
|
|
180
180
|
<WrappedComponent
|
|
181
181
|
{...props}
|
|
182
182
|
disableWithModal={false}
|
|
183
|
+
alreadyHasWithModal={true}
|
|
184
|
+
ref={ref}
|
|
183
185
|
showModal={showModal}
|
|
184
186
|
hideModal={onCancel || hideModal}
|
|
185
187
|
updateModalBody={updateModalBody}
|
|
186
188
|
isModalShown={isModalShown}
|
|
187
189
|
whichModal={whichModal}
|
|
188
|
-
ref={ref}
|
|
189
190
|
/>
|
|
190
191
|
{isModalShown &&
|
|
191
192
|
<Modal
|
|
@@ -22,7 +22,7 @@ export default function withPdfButtons(WrappedComponent) {
|
|
|
22
22
|
if (props.canUser && !props.canUser(VIEW)) { // permissions
|
|
23
23
|
showButtons = false;
|
|
24
24
|
}
|
|
25
|
-
if (!showButtons) {
|
|
25
|
+
if (!showButtons || props.alreadyHasWithPdfButtons) {
|
|
26
26
|
// bypass everything.
|
|
27
27
|
// If we don't do this, we get an infinite recursion with Form
|
|
28
28
|
// because this HOC wraps Form and uses Form itself.
|
|
@@ -384,9 +384,10 @@ export default function withPdfButtons(WrappedComponent) {
|
|
|
384
384
|
|
|
385
385
|
return <WrappedComponent
|
|
386
386
|
{...props}
|
|
387
|
+
ref={ref}
|
|
388
|
+
alreadyHasWithPdfButtons={true}
|
|
387
389
|
additionalEditButtons={additionalEditButtons}
|
|
388
390
|
additionalViewButtons={additionalViewButtons}
|
|
389
|
-
ref={ref}
|
|
390
391
|
/>;
|
|
391
392
|
}));
|
|
392
393
|
}
|
|
@@ -97,7 +97,7 @@ export function canUser(permission, modelToCheck = null) {
|
|
|
97
97
|
export default function withPermissions(WrappedComponent, forceUsePermissions = false) {
|
|
98
98
|
return forwardRef((props, ref) => {
|
|
99
99
|
|
|
100
|
-
if (!props.usePermissions && !forceUsePermissions) {
|
|
100
|
+
if ((!props.usePermissions && !forceUsePermissions) || props.alreadyHasWithPermissions) {
|
|
101
101
|
return <WrappedComponent {...props} ref={ref} />;
|
|
102
102
|
}
|
|
103
103
|
|
|
@@ -126,9 +126,10 @@ export default function withPermissions(WrappedComponent, forceUsePermissions =
|
|
|
126
126
|
|
|
127
127
|
return <WrappedComponent
|
|
128
128
|
{...props}
|
|
129
|
+
alreadyHasWithPermissions={true}
|
|
130
|
+
ref={ref}
|
|
129
131
|
canUser={canUserDecorator}
|
|
130
132
|
showPermissionsError={showPermissionsError}
|
|
131
|
-
ref={ref}
|
|
132
133
|
/>;
|
|
133
134
|
});
|
|
134
135
|
}
|
|
@@ -41,7 +41,7 @@ const presetButtons = [
|
|
|
41
41
|
export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
42
42
|
return forwardRef((props, ref) => {
|
|
43
43
|
|
|
44
|
-
if (props.disablePresetButtons) {
|
|
44
|
+
if (props.disablePresetButtons || props.alreadyHasWithPresetButtons) {
|
|
45
45
|
// bypass everything
|
|
46
46
|
return <WrappedComponent {...props} ref={ref} />;
|
|
47
47
|
}
|
|
@@ -433,8 +433,9 @@ export default function withPresetButtons(WrappedComponent, isGrid = false) {
|
|
|
433
433
|
|
|
434
434
|
return <WrappedComponent
|
|
435
435
|
{...propsToPass}
|
|
436
|
-
ref={ref}
|
|
437
436
|
disablePresetButtons={false}
|
|
437
|
+
alreadyHasWithPresetButtons={true}
|
|
438
|
+
ref={ref}
|
|
438
439
|
contextMenuItems={[
|
|
439
440
|
...localContextMenuItems,
|
|
440
441
|
...contextMenuItems,
|
|
@@ -12,14 +12,7 @@ import _ from 'lodash';
|
|
|
12
12
|
export default function withSelection(WrappedComponent) {
|
|
13
13
|
return forwardRef((props, ref) => {
|
|
14
14
|
|
|
15
|
-
if (props.disableWithSelection) {
|
|
16
|
-
return <WrappedComponent {...props} ref={ref} />;
|
|
17
|
-
}
|
|
18
|
-
|
|
19
|
-
if (props.setSelection) {
|
|
20
|
-
// bypass everything, since we're already using withSelection() in hierarchy.
|
|
21
|
-
// For example, Combo has withSelection(), and intenally it uses Grid which also has withSelection(),
|
|
22
|
-
// but we only need it defined once for the whole thing.
|
|
15
|
+
if (props.disableWithSelection || props.alreadyHasWithSelection) {
|
|
23
16
|
return <WrappedComponent {...props} ref={ref} />;
|
|
24
17
|
}
|
|
25
18
|
|
|
@@ -427,6 +420,7 @@ export default function withSelection(WrappedComponent) {
|
|
|
427
420
|
{...props}
|
|
428
421
|
ref={ref}
|
|
429
422
|
disableWithSelection={false}
|
|
423
|
+
alreadyHasWithSelection={true}
|
|
430
424
|
selection={getSelection()}
|
|
431
425
|
getSelection={getSelection}
|
|
432
426
|
setSelection={setSelection}
|
|
@@ -13,7 +13,7 @@ import _ from 'lodash';
|
|
|
13
13
|
export default function withToast(WrappedComponent) {
|
|
14
14
|
return forwardRef((props, ref) => {
|
|
15
15
|
|
|
16
|
-
if (props.disableWithToast || props.
|
|
16
|
+
if (props.disableWithToast || props.alreadyHasWithToast) {
|
|
17
17
|
return <WrappedComponent {...props} ref={ref} />;
|
|
18
18
|
}
|
|
19
19
|
|
|
@@ -80,8 +80,10 @@ export default function withToast(WrappedComponent) {
|
|
|
80
80
|
|
|
81
81
|
return <WrappedComponent
|
|
82
82
|
{...props}
|
|
83
|
-
|
|
83
|
+
alreadyHasWithToast={true}
|
|
84
|
+
disableWithToast={false}
|
|
84
85
|
ref={ref}
|
|
86
|
+
showToast={showToast}
|
|
85
87
|
/>;
|
|
86
88
|
});
|
|
87
89
|
}
|