@onehat/ui 0.3.225 → 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.225",
3
+ "version": "0.3.226",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -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}
@@ -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,
@@ -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"