@onehat/ui 0.3.233 → 0.3.235

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.233",
3
+ "version": "0.3.235",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -205,7 +205,7 @@ function GridComponent(props) {
205
205
  isAddingRef = useRef(),
206
206
  expandedRowsRef = useRef({}),
207
207
  cachedDragElements = useRef(),
208
- idsRef = useRef([]),
208
+ dragSelectionRef = useRef([]),
209
209
  [isInited, setIsInited] = useState(false),
210
210
  [isReady, setIsReady] = useState(false),
211
211
  [isLoading, setIsLoading] = useState(false),
@@ -449,9 +449,8 @@ function GridComponent(props) {
449
449
  let WhichRow = GridRow;
450
450
  if (CURRENT_MODE === UI_MODE_WEB) { // DND is currrently web-only TODO: implement for RN
451
451
  // Create a method that gets an always-current copy of the selection ids
452
- const ids = _.map(selection, (item) => item.id);
453
- idsRef.current = ids;
454
- const getIds = () => idsRef.current;
452
+ dragSelectionRef.current = selection;
453
+ const getSelection = () => dragSelectionRef.current;
455
454
 
456
455
  // assign event handlers
457
456
  if (canRowsReorder && isDragMode) {
@@ -461,7 +460,7 @@ function GridComponent(props) {
461
460
  const dragIx = showHeaders ? index - 1 : index;
462
461
  rowReorderProps.dragSourceItem = {
463
462
  id: item.id,
464
- getIds,
463
+ getSelection,
465
464
  onDrag: (dragState) => {
466
465
  onRowReorderDrag(dragState, dragIx);
467
466
  },
@@ -474,11 +473,11 @@ function GridComponent(props) {
474
473
  rowDragProps.isDragSource = true;
475
474
  rowDragProps.dragSourceType = rowDragSourceType;
476
475
  if (getRowDragSourceItem) {
477
- rowDragProps.dragSourceItem = getRowDragSourceItem(item, getIds, rowDragSourceType);
476
+ rowDragProps.dragSourceItem = getRowDragSourceItem(item, getSelection, rowDragSourceType);
478
477
  } else {
479
478
  rowDragProps.dragSourceItem = {
480
479
  id: item.id,
481
- getIds,
480
+ getSelection,
482
481
  type: rowDragSourceType,
483
482
  };
484
483
  }
@@ -7,6 +7,7 @@ import {
7
7
  EDITOR_MODE__ADD,
8
8
  EDITOR_MODE__EDIT,
9
9
  } from '../../Constants/Editor.js';
10
+ import UiGlobals from '../../UiGlobals.js';
10
11
  import _ from 'lodash';
11
12
 
12
13
  export default function withEditor(WrappedComponent, isTree = false) {
@@ -41,6 +42,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
41
42
  newEntityDisplayValue,
42
43
  newEntityDisplayProperty, // in case the field to set for newEntityDisplayValue is different from model
43
44
  defaultValues,
45
+ stayInEditModeOnSelectionChange = false,
44
46
 
45
47
  // withComponent
46
48
  self,
@@ -423,6 +425,16 @@ export default function withEditor(WrappedComponent, isTree = false) {
423
425
  });
424
426
  },
425
427
  calculateEditorMode = (isIgnoreNextSelectionChange = false) => {
428
+
429
+ let doStayInEditModeOnSelectionChange = stayInEditModeOnSelectionChange;
430
+ if (!_.isNil(UiGlobals.stayInEditModeOnSelectionChange)) {
431
+ // allow global override to for this property
432
+ doStayInEditModeOnSelectionChange = UiGlobals.stayInEditModeOnSelectionChange;
433
+ }
434
+ if (doStayInEditModeOnSelectionChange) {
435
+ isIgnoreNextSelectionChange = true;
436
+ }
437
+
426
438
  // calculateEditorMode gets called only on selection changes
427
439
  let mode;
428
440
  if (isIgnoreNextSelectionChange) {