@onehat/ui 0.3.224 → 0.3.226

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.3.224",
3
+ "version": "0.3.226",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -45,6 +45,15 @@ function Splitter(props) {
45
45
  </Column>;
46
46
  }
47
47
 
48
+ function withAdditionalProps(WrappedComponent) {
49
+ return (props) => {
50
+ return <WrappedComponent
51
+ isDraggable={true}
52
+ {...props}
53
+ />;
54
+ };
55
+ }
56
+
48
57
  // Need a hoc to specifically deliver the 'getParentNode' prop
49
58
  function withParentNode(WrappedComponent) {
50
59
  return (props) => {
@@ -58,4 +67,4 @@ function withParentNode(WrappedComponent) {
58
67
  };
59
68
  }
60
69
 
61
- export default withParentNode(withDraggable(Splitter));
70
+ export default withParentNode(withAdditionalProps(withDraggable(Splitter)));
@@ -454,20 +454,22 @@ function GridComponent(props) {
454
454
  rowReorderProps.proxyPositionRelativeToParent = true;
455
455
  rowReorderProps.getParentNode = (node) => node.parentElement.parentElement.parentElement;
456
456
  rowReorderProps.getProxy = getReorderProxy;
457
- }
458
- if (areRowsDragSource) {
459
- rowDragProps.isDragSource = true;
460
- rowDragProps.dragSourceType = rowDragSourceType;
461
- rowDragProps.dragSourceItem = getRowDragSourceItem ? getRowDragSourceItem(item) : { id: item.id };
462
- }
463
- if (areRowsDropTarget) {
464
- rowDragProps.isDropTarget = true;
465
- rowDragProps.dropTargetAccept = dropTargetAccept;
466
- rowDragProps.onDrop = (droppedItem) => {
467
- // TODO: the item is somehow getting stale
468
- // might have something to do with memoization
469
- onRowDrop(item, droppedItem);
470
- };
457
+ } else {
458
+ // Don't allow drag/drop from withDnd while reordering
459
+ if (areRowsDragSource) {
460
+ rowDragProps.isDragSource = true;
461
+ rowDragProps.dragSourceType = rowDragSourceType;
462
+ rowDragProps.dragSourceItem = getRowDragSourceItem ? getRowDragSourceItem(item) : { id: item.id };
463
+ }
464
+ if (areRowsDropTarget) {
465
+ rowDragProps.isDropTarget = true;
466
+ rowDragProps.dropTargetAccept = dropTargetAccept;
467
+ rowDragProps.onDrop = (droppedItem) => {
468
+ // TODO: the item is somehow getting stale
469
+ // might have something to do with memoization
470
+ onRowDrop(item, droppedItem);
471
+ };
472
+ }
471
473
  }
472
474
  return <GridRow
473
475
  columnsConfig={localColumnsConfig}
@@ -305,7 +305,7 @@ export default function GridHeaderRow(props) {
305
305
  propsToPass = {
306
306
  borderRightWidth: 2,
307
307
  borderRightColor: '#fff',
308
- }
308
+ };
309
309
 
310
310
  if (all.length === 1) {
311
311
  propsToPass.w = '100%';
@@ -27,7 +27,8 @@ function GridRow(props) {
27
27
  bg,
28
28
  item,
29
29
  isInlineEditorShown,
30
- isDragSource = false,
30
+ isDraggable = false, // withDraggable
31
+ isDragSource = false, // withDnd
31
32
  isOver = false,
32
33
  } = props,
33
34
  styles = UiGlobals.styles;
@@ -40,12 +41,6 @@ function GridRow(props) {
40
41
  isPhantom = item.isPhantom,
41
42
  hash = item?.hash || item;
42
43
 
43
- if (props.dragSourceRef) {
44
- rowProps.ref = props.dragSourceRef;
45
- }
46
- if (props.dropTargetRef) {
47
- rowProps.ref = props.dropTargetRef;
48
- }
49
44
  return useMemo(() => {
50
45
  const renderColumns = (item) => {
51
46
  if (_.isArray(columnsConfig)) {
@@ -188,26 +183,36 @@ function GridRow(props) {
188
183
  rowProps.borderWidth = 0;
189
184
  rowProps.borderColor = null;
190
185
  }
186
+
187
+ let rowContents = <>
188
+ {(isDragSource || isDraggable) && <RowDragHandle />}
189
+ {isPhantom && <Box position="absolute" bg="#f00" h={2} w={2} t={0} l={0} />}
190
+
191
+ {renderColumns(item)}
192
+
193
+ {!hideNavColumn && <AngleRight
194
+ color={styles.GRID_NAV_COLUMN_COLOR}
195
+ variant="ghost"
196
+ w={30}
197
+ alignSelf="center"
198
+ mx={3}
199
+ />}
200
+ </>;
201
+
202
+ if (props.dragSourceRef) {
203
+ rowContents = <Row flexGrow={1} flex={1} w="100%" bg={bg} ref={props.dragSourceRef}>{rowContents}</Row>;
204
+ }
205
+ if (props.dropTargetRef) {
206
+ rowContents = <Row flexGrow={1} flex={1} w="100%" bg={bg} ref={props.dropTargetRef}>{rowContents}</Row>;
207
+ }
208
+
191
209
  return <Row
192
210
  alignItems="center"
193
211
  flexGrow={1}
194
212
  {...rowProps}
195
213
  bg={bg}
196
214
  key={hash}
197
- >
198
- {isDragSource && <RowDragHandle />}
199
- {isPhantom && <Box position="absolute" bg="#f00" h={2} w={2} t={0} l={0} />}
200
-
201
- {renderColumns(item)}
202
-
203
- {!hideNavColumn && <AngleRight
204
- color={styles.GRID_NAV_COLUMN_COLOR}
205
- variant="ghost"
206
- w={30}
207
- alignSelf="center"
208
- mx={3}
209
- />}
210
- </Row>;
215
+ >{rowContents}</Row>;
211
216
  }, [
212
217
  columnsConfig,
213
218
  columnProps,
@@ -26,4 +26,13 @@ function HeaderReorderHandle(props) {
26
26
  </Column>;
27
27
  }
28
28
 
29
- export default withDraggable(HeaderReorderHandle);
29
+ function withAdditionalProps(WrappedComponent) {
30
+ return (props) => {
31
+ return <WrappedComponent
32
+ isDraggable={true}
33
+ {...props}
34
+ />;
35
+ };
36
+ }
37
+
38
+ export default withAdditionalProps(withDraggable(HeaderReorderHandle));
@@ -26,4 +26,13 @@ function HeaderResizeHandle(props) {
26
26
  </Column>;
27
27
  }
28
28
 
29
- export default withDraggable(HeaderResizeHandle);
29
+ function withAdditionalProps(WrappedComponent) {
30
+ return (props) => {
31
+ return <WrappedComponent
32
+ isDraggable={true}
33
+ {...props}
34
+ />;
35
+ };
36
+ }
37
+
38
+ export default withAdditionalProps(withDraggable(HeaderResizeHandle));
@@ -11,7 +11,7 @@ function RowDragHandle(props) {
11
11
  return <Column
12
12
  testID="HeaderReorderHandle"
13
13
  bg="trueGray.100"
14
- h="100%"
14
+ // h="100%"
15
15
  w={3}
16
16
  alignItems="center"
17
17
  justifyContent="center"
@@ -87,4 +87,13 @@ export default function TreeNode(props) {
87
87
  ]);
88
88
  }
89
89
 
90
- export const DraggableTreeNode = withDraggable(TreeNode);
90
+ function withAdditionalProps(WrappedComponent) {
91
+ return (props) => {
92
+ return <WrappedComponent
93
+ isDraggable={true}
94
+ {...props}
95
+ />;
96
+ };
97
+ }
98
+
99
+ export const DraggableTreeNode = withAdditionalProps(withDraggable(TreeNode));