@onehat/ui 0.4.71 → 0.4.72

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.
Files changed (44) hide show
  1. package/package.json +1 -1
  2. package/src/Components/Buttons/Button.js +13 -6
  3. package/src/Components/Container/ScreenContainer.js +1 -0
  4. package/src/Components/Form/Field/Combo/MeterTypesCombo.js +4 -2
  5. package/src/Components/Form/Field/Input.js +5 -4
  6. package/src/Components/Grid/Grid.js +16 -7
  7. package/src/Components/Grid/GridHeaderRow.js +1 -1
  8. package/src/Components/Grid/GridRow.js +35 -34
  9. package/src/Components/Grid/RowDragHandle.js +25 -10
  10. package/src/Components/Grid/RowHandle.js +55 -0
  11. package/src/{Hooks → Components/Grid}/useAsyncRenderers.js +1 -1
  12. package/src/Components/Hoc/Secondary/withSecondaryData.js +2 -1
  13. package/src/Components/Hoc/Secondary/withSecondaryEditor.js +3 -2
  14. package/src/Components/Hoc/Secondary/withSecondarySelection.js +3 -2
  15. package/src/Components/Hoc/Secondary/withSecondaryValue.js +2 -1
  16. package/src/Components/Hoc/withAlert.js +3 -1
  17. package/src/Components/Hoc/withCollapsible.js +9 -4
  18. package/src/Components/Hoc/withComponent.js +6 -0
  19. package/src/Components/Hoc/withContextMenu.js +6 -0
  20. package/src/Components/Hoc/withData.js +3 -2
  21. package/src/Components/Hoc/withDnd.js +16 -8
  22. package/src/Components/Hoc/withDraggable.js +21 -5
  23. package/src/Components/Hoc/withEditor.js +2 -1
  24. package/src/Components/Hoc/withEvents.js +11 -1
  25. package/src/Components/Hoc/withFilters.js +7 -2
  26. package/src/Components/Hoc/withModal.js +3 -2
  27. package/src/Components/Hoc/withPdfButtons.js +3 -2
  28. package/src/Components/Hoc/withPermissions.js +3 -2
  29. package/src/Components/Hoc/withPresetButtons.js +3 -2
  30. package/src/Components/Hoc/withSelection.js +2 -8
  31. package/src/Components/Hoc/withToast.js +4 -2
  32. package/src/Components/Hoc/withTooltip.js +10 -1
  33. package/src/Components/Hoc/withValue.js +3 -9
  34. package/src/Components/Messages/GlobalModals.js +47 -0
  35. package/src/Components/Tree/Tree.js +22 -6
  36. package/src/Components/Tree/TreeNode.js +11 -11
  37. package/src/Components/Tree/TreeNodeDragHandle.js +8 -4
  38. package/src/Components/Viewer/MeterTypeText.js +21 -1
  39. package/src/Constants/MeterTypes.js +2 -0
  40. package/src/Functions/addIconProps.js +46 -0
  41. package/src/Functions/testProps.js +1 -1
  42. package/src/Hooks/useWhyDidYouUpdate.js +33 -0
  43. package/src/PlatformImports/Web/Attachments.js +1 -1
  44. package/src/Components/Hoc/withBlank.js +0 -10
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@onehat/ui",
3
- "version": "0.4.71",
3
+ "version": "0.4.72",
4
4
  "description": "Base UI for OneHat apps",
5
5
  "main": "src/index.js",
6
6
  "type": "module",
@@ -6,6 +6,7 @@ import {
6
6
  ButtonIcon,
7
7
  ButtonGroup,
8
8
  } from '@project-components/Gluestack';
9
+ import addIconProps from '../../Functions/addIconProps.js';
9
10
  import clsx from 'clsx';
10
11
  import withComponent from '../Hoc/withComponent.js';
11
12
  import withTooltip from '../Hoc/withTooltip.js';
@@ -24,23 +25,23 @@ const ButtonComponent = forwardRef((props, ref) => {
24
25
  _text = {}, // props for ButtonText
25
26
  ...propsToPass
26
27
  } = props;
27
-
28
+
28
29
  if (icon) {
29
30
  if (isValidElement(icon)) {
30
31
  if (_icon) {
31
- icon = cloneElement(icon, {..._icon});
32
+ icon = cloneElement(icon, addIconProps(_icon || {}));
32
33
  }
33
34
  } else {
34
- icon = <ButtonIcon className="ButtonIcon" as={icon} {..._icon} />;
35
+ icon = <ButtonIcon as={icon} {...addIconProps(_icon || {})} />;
35
36
  }
36
37
  }
37
38
  if (rightIcon) {
38
39
  if (isValidElement(rightIcon)) {
39
40
  if (_rightIcon) {
40
- rightIcon = cloneElement(rightIcon, {..._rightIcon});
41
+ rightIcon = cloneElement(rightIcon, addIconProps(_rightIcon || {}));
41
42
  }
42
43
  } else {
43
- rightIcon = <ButtonIcon className="ButtonIcon" as={rightIcon} {..._rightIcon} />;
44
+ rightIcon = <ButtonIcon as={rightIcon} {...addIconProps(_rightIcon || {})} />;
44
45
  }
45
46
  }
46
47
 
@@ -55,12 +56,18 @@ const ButtonComponent = forwardRef((props, ref) => {
55
56
  let className = clsx(
56
57
  'Button',
57
58
  'flex',
59
+ 'flex-row',
60
+ 'items-center',
58
61
  );
59
62
  if (propsToPass.className) {
60
63
  className += ' ' + propsToPass.className;
61
64
  }
62
65
 
63
- return <Button {...propsToPass} className={className} ref={ref}>
66
+ return <Button
67
+ {...propsToPass}
68
+ className={className}
69
+ ref={ref}
70
+ >
64
71
  {isLoading && <ButtonSpinner className="ButtonSpinner" {..._spinner} />}
65
72
  {icon}
66
73
  {text && <ButtonText className="ButtonText" {..._text}>{text}</ButtonText>}
@@ -50,6 +50,7 @@ function ScreenContainer(props) {
50
50
  onLayout={onLayout}
51
51
  {...safeAreaProps}
52
52
  className={className}
53
+ style={{ minHeight: height - headerHeight }}
53
54
  >
54
55
  {props.children}
55
56
  </VStackNative>;
@@ -9,11 +9,13 @@ import ArrayCombo from './ArrayCombo.js';
9
9
  import {
10
10
  METER_TYPES__HOURS,
11
11
  METER_TYPES__MILES,
12
+ METER_TYPES__HOURS_TEXT,
13
+ METER_TYPES__MILES_TEXT,
12
14
  } from '../../../../Constants/MeterTypes.js';
13
15
 
14
16
  const data = [
15
- [METER_TYPES__HOURS, 'Time (hrs)'],
16
- [METER_TYPES__MILES, 'Distance (mi/km)'],
17
+ [METER_TYPES__HOURS, METER_TYPES__HOURS_TEXT],
18
+ [METER_TYPES__MILES, METER_TYPES__MILES_TEXT],
17
19
  ];
18
20
  function MeterTypesCombo(props) {
19
21
  return <ArrayCombo
@@ -8,6 +8,7 @@ import {
8
8
  hasFlex,
9
9
  } from '../../../Functions/tailwindFunctions.js';
10
10
  import UiGlobals from '../../../UiGlobals.js';
11
+ import addIconProps from '../../../Functions/addIconProps.js';
11
12
  import withComponent from '../../Hoc/withComponent.js';
12
13
  import withTooltip from '../../Hoc/withTooltip.js';
13
14
  import withValue from '../../Hoc/withValue.js';
@@ -145,10 +146,10 @@ const InputElement = forwardRef((props, ref) => {
145
146
  _leftIcon.className = 'leftInputIcon mr-2 ' + _leftIcon.className; // prepend the margin, so it can potentially be overridden
146
147
  if (isValidElement(leftIcon)) {
147
148
  if (_leftIcon) {
148
- leftIcon = cloneElement(leftIcon, {..._leftIcon});
149
+ leftIcon = cloneElement(leftIcon, addIconProps(_leftIcon || {}));
149
150
  }
150
151
  } else {
151
- leftIcon = <InputIcon as={leftIcon} {..._leftIcon} />;
152
+ leftIcon = <InputIcon as={leftIcon} {...addIconProps(_leftIcon || {})} />;
152
153
  }
153
154
  if (leftIconHandler) {
154
155
  leftIcon = <InputSlot onPress={leftIconHandler} className="LeftInputSlot">
@@ -169,10 +170,10 @@ const InputElement = forwardRef((props, ref) => {
169
170
  _rightIcon.className = 'rightInputIcon ml-2 ' + _rightIcon.className; // prepend the margin, so it can potentially be overridden
170
171
  if (isValidElement(rightIcon)) {
171
172
  if (_rightIcon) {
172
- rightIcon = cloneElement(rightIcon, {..._rightIcon});
173
+ rightIcon = cloneElement(rightIcon, addIconProps(_rightIcon || {}));
173
174
  }
174
175
  } else {
175
- rightIcon = <InputIcon as={rightIcon} {..._rightIcon} />;
176
+ rightIcon = <InputIcon as={rightIcon} {...addIconProps(_rightIcon || {})} />;
176
177
  }
177
178
  if (rightIconHandler) {
178
179
  rightIcon = <InputSlot onPress={rightIconHandler} className="RightInputSlot">
@@ -35,7 +35,6 @@ import {
35
35
  hasFlex,
36
36
  } from '../../Functions/tailwindFunctions.js';
37
37
  import * as yup from 'yup'; // https://github.com/jquense/yup#string
38
- import Inflector from 'inflector-js';
39
38
  import { EDITOR_TYPE__PLAIN } from '../../Constants/Editor.js';
40
39
  import UiGlobals from '../../UiGlobals.js';
41
40
  import useForceUpdate from '../../Hooks/useForceUpdate.js';
@@ -171,6 +170,7 @@ function GridComponent(props) {
171
170
 
172
171
  // DND
173
172
  canRowsReorder = false,
173
+ canRowDrag, // optional fn to customize whether each row can be dragged
174
174
  canRowAcceptDrop, // optional fn to customize whether each node can accept a dropped item: (targetItem, draggedItem) => boolean
175
175
  getCustomDragProxy, // optional fn to render custom drag preview: (item, selection) => ReactElement
176
176
  dragPreviewOptions, // optional object for drag preview positioning options
@@ -540,6 +540,7 @@ function GridComponent(props) {
540
540
  rowReorderProps.dragSourceItem = {
541
541
  id: item.id,
542
542
  getSelection,
543
+ isInSelection,
543
544
  onDrag: (dragState) => {
544
545
  onRowReorderDrag(dragState, dragIx);
545
546
  },
@@ -547,20 +548,30 @@ function GridComponent(props) {
547
548
  rowReorderProps.onDragEnd = onRowReorderEnd;
548
549
  } else {
549
550
  // Don't allow drag/drop from withDnd while reordering
550
- if (areRowsDragSource) {
551
+ if (areRowsDragSource && (!canRowDrag || canRowDrag(item))) {
551
552
  WhichRow = DragSourceGridRow;
552
553
  rowDragProps.isDragSource = true;
553
554
  rowDragProps.dragSourceType = rowDragSourceType;
554
555
  if (getRowDragSourceItem) {
555
- rowDragProps.dragSourceItem = getRowDragSourceItem(item, getSelection, rowDragSourceType);
556
+ rowDragProps.dragSourceItem = getRowDragSourceItem(item, getSelection, isInSelection, rowDragSourceType);
556
557
  } else {
557
558
  rowDragProps.dragSourceItem = {
558
559
  id: item.id,
559
560
  item,
560
561
  getSelection,
562
+ isInSelection,
561
563
  type: rowDragSourceType,
562
564
  };
563
565
  }
566
+ rowDragProps.dragSourceItem.onDragStart = () => {
567
+ if (!isInSelection(item)) { // get updated isSelected (will be stale if using one in closure)
568
+ // reset the selection to just this one node if it's not already selected
569
+ setSelection([item]);
570
+ }
571
+ };
572
+ if (canRowDrag) {
573
+ rowDragProps.canDrag = () => canRowDrag(item, rowDragProps.dragSourceItem);
574
+ }
564
575
 
565
576
  // Add custom drag preview options
566
577
  if (dragPreviewOptions) {
@@ -697,8 +708,7 @@ function GridComponent(props) {
697
708
  };
698
709
  },
699
710
  buildCachedDragElements = (dragState) => {
700
- const
701
- {
711
+ const {
702
712
  canDrag,
703
713
  isDragging,
704
714
  clientOffset,
@@ -747,8 +757,7 @@ function GridComponent(props) {
747
757
  cachedDragElements.current = buildCachedDragElements(dragState);
748
758
  }
749
759
 
750
- const
751
- {
760
+ const {
752
761
  canDrag,
753
762
  isDragging,
754
763
  clientOffset,
@@ -407,7 +407,7 @@ export default function GridHeaderRow(props) {
407
407
  'overflow-hidden',
408
408
  'text-ellipsis',
409
409
  'px-2',
410
- py-3,
410
+ 'py-3',
411
411
  styles.GRID_HEADER_CLASSNAME,
412
412
  )}
413
413
  >{header}</TextNative>
@@ -20,9 +20,8 @@ import { withDragSource, withDropTarget } from '../Hoc/withDnd.js';
20
20
  import testProps from '../../Functions/testProps.js';
21
21
  import Loading from '../Messages/Loading.js';
22
22
  import AngleRight from '../Icons/AngleRight.js';
23
- import RowDragHandle from './RowDragHandle.js';
24
- import RowSelectHandle from './RowSelectHandle.js';
25
- import useAsyncRenderers from '../../Hooks/useAsyncRenderers.js';
23
+ import RowHandle from './RowHandle.js';
24
+ import useAsyncRenderers from './useAsyncRenderers.js';
26
25
  import _ from 'lodash';
27
26
 
28
27
  // Conditional import for web only
@@ -45,7 +44,6 @@ function GridRow(props) {
45
44
  rowProps,
46
45
  hideNavColumn,
47
46
  showSelectHandle,
48
- isRowSelectable,
49
47
  isRowHoverable,
50
48
  isSelected,
51
49
  isHovered,
@@ -102,7 +100,7 @@ function GridRow(props) {
102
100
  actualCanDrop = validateDrop(draggedItem);
103
101
  }
104
102
 
105
- if (isRowSelectable && isSelected) {
103
+ if (showSelectHandle && isSelected) {
106
104
  if (showHovers && isHovered) {
107
105
  mixWith = styles.GRID_ROW_SELECTED_BG_HOVER;
108
106
  } else {
@@ -198,13 +196,33 @@ function GridRow(props) {
198
196
  };
199
197
 
200
198
  let content = null;
199
+ let textClassName = clsx(
200
+ 'GridRow-TextNative',
201
+ 'self-center',
202
+ 'overflow-hidden',
203
+ colClassName,
204
+ styles.GRID_CELL_CLASSNAME,
205
+ styles.GRID_ROW_MAX_HEIGHT_EXTRA,
206
+ );
207
+ if (config.className) {
208
+ textClassName += ' ' + config.className;
209
+ }
210
+ const rendererProps = {
211
+ ...testProps('rendererCol-' + config.fieldName),
212
+ className: textClassName,
213
+ ...propsToPass,
214
+ ...extraProps,
215
+ style: colStyle,
216
+ };
201
217
  if (config.isAsync) {
218
+ // TODO: Figure out how to pass the rendererProps to the async renderer function
219
+ throw Error('Not yet working correctly!');
202
220
  // Async renderer
203
221
  if (isLoading) {
204
222
  content = <Loading />;
205
223
  } else if (asyncResult) {
206
224
  if (asyncResult.error) {
207
- content = <Text>Render Error: {asyncResult.error.message || String(asyncResult.error)}</Text>;
225
+ content = <Text key={key}>Render Error: {asyncResult.error.message || String(asyncResult.error)}</Text>;
208
226
  } else {
209
227
  content = asyncResult.result;
210
228
  }
@@ -212,24 +230,17 @@ function GridRow(props) {
212
230
  } else {
213
231
  // Synchronous renderer
214
232
  try {
215
- const result = config.renderer(item);
233
+ const result = config.renderer(item, config.fieldName, rendererProps, key);
216
234
  if (result && typeof result.then === 'function') {
217
- content = <Text>Error: Async renderer not properly configured</Text>;
235
+ content = <Text key={key}>Error: Async renderer not properly configured</Text>;
218
236
  } else {
219
237
  content = result;
220
238
  }
221
239
  } catch (error) {
222
- content = <Text>Render Error: {error}</Text>;
240
+ content = <Text key={key}>Render Error: {error}</Text>;
223
241
  }
224
242
  }
225
- return <HStackNative
226
- key={key}
227
- {...testProps('rendererCol-' + key)}
228
- className={colClassName}
229
- {...propsToPass}
230
- {...extraProps}
231
- style={colStyle}
232
- >{content}</HStackNative>;
243
+ return content;
233
244
  }
234
245
  if (config.fieldName) {
235
246
 
@@ -342,8 +353,13 @@ function GridRow(props) {
342
353
  };
343
354
 
344
355
  let rowContents = <>
345
- {(isDragSource || isDraggable) && <RowDragHandle />}
346
- {showSelectHandle && <RowSelectHandle />}
356
+ {(isDragSource || isDraggable || showSelectHandle) &&
357
+ <RowHandle
358
+ ref={dragSourceRef}
359
+ isDragSource={isDragSource}
360
+ isDraggable={isDraggable}
361
+ showSelectHandle={showSelectHandle}
362
+ />}
347
363
 
348
364
  {isPhantom &&
349
365
  <Box
@@ -373,21 +389,6 @@ function GridRow(props) {
373
389
  )}
374
390
  />}
375
391
  </>;
376
-
377
- if (dragSourceRef) {
378
- rowContents = <HStack
379
- ref={dragSourceRef}
380
- className={clsx(
381
- 'GridRow-dragSourceRef',
382
- 'w-full',
383
- 'flex-1',
384
- 'grow-1',
385
- )}
386
- style={{
387
- backgroundColor: bg,
388
- }}
389
- >{rowContents}</HStack>;
390
- }
391
392
  if (dropTargetRef) {
392
393
  rowContents = <HStack
393
394
  ref={dropTargetRef}
@@ -1,3 +1,4 @@
1
+ import { forwardRef } from 'react';
1
2
  import {
2
3
  Icon,
3
4
  VStack,
@@ -6,15 +7,29 @@ import clsx from 'clsx';
6
7
  import styles from '../../Styles/StyleSheets.js';
7
8
  import GripVertical from '../Icons/GripVertical.js';
8
9
 
9
- function RowDragHandle(props) { return <VStack
10
- style={styles.ewResize}
11
- className="RowDragHandle bg-grey-100 w-[7px] items-center justify-center select-none"
12
- >
13
- <Icon
14
- as={GripVertical}
15
- size="xs"
16
- className="handle w-full h-full text-[#ccc]" />
17
- </VStack>;
18
- }
10
+ const RowDragHandle = forwardRef(function(props, ref) {
11
+ let className = clsx(
12
+ 'RowDragHandle',
13
+ 'bg-grey-100',
14
+ 'w-[17px]',
15
+ 'items-center',
16
+ 'justify-center',
17
+ 'select-none',
18
+ );
19
+ if (props.className) {
20
+ className += ' ' + props.className;
21
+ }
22
+ return <VStack
23
+ {...props}
24
+ ref={ref}
25
+ style={styles.ewResize}
26
+ className={className}
27
+ >
28
+ <Icon
29
+ as={GripVertical}
30
+ size="xs"
31
+ className="handle w-full h-full text-[#ccc]" />
32
+ </VStack>;
33
+ });
19
34
 
20
35
  export default RowDragHandle;
@@ -0,0 +1,55 @@
1
+ import { forwardRef } from 'react';
2
+ import {
3
+ Icon,
4
+ VStack,
5
+ } from '@project-components/Gluestack';
6
+ import withTooltip from '@onehat/ui/src/Components/Hoc/withTooltip';
7
+ import clsx from 'clsx';
8
+ import Arcs from '../Icons/Arcs.js';
9
+
10
+ const RowHandle = forwardRef(function RowHandle(props, ref) {
11
+ const {
12
+ isDragSource,
13
+ isDraggable
14
+ } = props;
15
+ let className = clsx(
16
+ 'RowHandle',
17
+ 'h-full',
18
+ 'w-[40px]',
19
+ 'px-2',
20
+ 'items-center',
21
+ 'justify-center',
22
+ 'select-none',
23
+ 'cursor-pointer'
24
+ );
25
+ return <VStack
26
+ ref={isDragSource || isDraggable ? ref : undefined}
27
+ className={className}
28
+ >
29
+ <Icon as={Arcs} size="xs" className="w-full h-full text-[#ddd]" />
30
+ </VStack>;
31
+ });
32
+
33
+ function withAdditionalProps(WrappedComponent) {
34
+ return (props) => {
35
+ const {
36
+ showSelectHandle,
37
+ isDragSource,
38
+ isDraggable
39
+ } = props;
40
+ let tooltipParts = [];
41
+ if (showSelectHandle) {
42
+ tooltipParts.push('Select');
43
+ }
44
+ if (isDragSource || isDraggable) {
45
+ tooltipParts.push('Drag');
46
+ }
47
+ const tooltip = tooltipParts.length === 2 ? tooltipParts.join(' or ') : tooltipParts[0];
48
+ return <WrappedComponent
49
+ tooltip={tooltip}
50
+ {...props}
51
+ />;
52
+ };
53
+ }
54
+
55
+ export default withAdditionalProps(withTooltip(RowHandle));
@@ -7,7 +7,7 @@ export default function useAsyncRenderers(columnsConfig, item) {
7
7
 
8
8
  useEffect(() => {
9
9
  const asyncConfigs = columnsConfig.filter(config =>
10
- config.renderer && typeof config.renderer === 'function'
10
+ config.isAsync && config.renderer && typeof config.renderer === 'function'
11
11
  );
12
12
 
13
13
  if (asyncConfigs.length === 0) {
@@ -8,7 +8,7 @@ import _ from 'lodash';
8
8
  export default function withSecondaryData(WrappedComponent) {
9
9
  return (props) => {
10
10
 
11
- if (props.secondaryDisableWithData) {
11
+ if (props.secondaryDisableWithData || props.secondaryAlreadyHasWithData) {
12
12
  return <WrappedComponent {...props} />;
13
13
  }
14
14
 
@@ -104,6 +104,7 @@ export default function withSecondaryData(WrappedComponent) {
104
104
  return <WrappedComponent
105
105
  {...propsToPass}
106
106
  secondaryDisableWithData={false}
107
+ secondaryAlreadyHasWithData={true}
107
108
  SecondaryRepository={LocalSecondaryRepository}
108
109
  secondaryModel={secondaryModel}
109
110
  secondaryData={secondaryData}
@@ -24,7 +24,7 @@ import _ from 'lodash';
24
24
  export default function withSecondaryEditor(WrappedComponent, isTree = false) {
25
25
  return forwardRef((props, ref) => {
26
26
 
27
- if (props.secondaryDisableWithEditor) {
27
+ if (props.secondaryDisableWithEditor || props.secondaryAlreadyHasWithEditor) {
28
28
  return <WrappedComponent {...props} ref={ref} isTree={isTree} />;
29
29
  }
30
30
 
@@ -643,8 +643,9 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
643
643
 
644
644
  return <WrappedComponent
645
645
  {...props}
646
- ref={ref}
647
646
  secondaryDisableWithEditor={false}
647
+ secondaryAlreadyHasWithEditor={true}
648
+ ref={ref}
648
649
  secondaryCurrentRecord={secondaryCurrentRecord}
649
650
  secondarySetCurrentRecord={secondarySetCurrentRecord}
650
651
  secondaryIsEditorShown={secondaryIsEditorShown}
@@ -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.alert) {
22
+ if (props.disableWithAlert || props.alreadyHasWithAlert) {
23
23
  return <WrappedComponent {...props} ref={ref} />;
24
24
  }
25
25
 
@@ -170,6 +170,8 @@ function withAlert(WrappedComponent) {
170
170
  return <WrappedComponent
171
171
  {...props}
172
172
  ref={ref}
173
+ disableWithAlert={false}
174
+ alreadyHasWithAlert={true}
173
175
  alert={onAlert}
174
176
  confirm={onConfirm}
175
177
  hideAlert={hideModal}
@@ -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
- const
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}