@onehat/ui 0.3.235 → 0.3.237

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.235",
3
+ "version": "0.3.237",
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
  EDITOR_MODE__VIEW,
7
7
  EDITOR_MODE__ADD,
8
8
  EDITOR_MODE__EDIT,
9
+ EDITOR_TYPE__SIDE,
9
10
  } from '../../../Constants/Editor.js';
10
11
  import _ from 'lodash';
11
12
 
@@ -36,6 +37,7 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
36
37
  }
37
38
  return 'record' + (secondarySelection[0].displayValue ? ' "' + secondarySelection[0].displayValue + '"' : '') + '?';
38
39
  },
40
+ secondaryEditorType,
39
41
  secondaryOnAdd,
40
42
  secondaryOnChange, // any kind of crud change
41
43
  secondaryOnDelete,
@@ -428,23 +430,28 @@ export default function withSecondaryEditor(WrappedComponent, isTree = false) {
428
430
  calculateEditorMode = (secondaryIsIgnoreNextSelectionChange = false) => {
429
431
  // calculateEditorMode gets called only on selection changes
430
432
  let mode;
431
- if (secondaryIsIgnoreNextSelectionChange) {
432
- mode = secondaryEditorMode;
433
- if (!secondaryCanEditorViewOnly && secondaryUserCanEdit) {
434
- if (secondarySelection.length > 1) {
435
- if (!secondaryDisableEdit) {
436
- // For multiple entities selected, change it to edit multiple mode
437
- mode = EDITOR_MODE__EDIT;
438
- }
439
- } else if (secondarySelection.length === 1 && !secondarySelection[0].isDestroyed && secondarySelection[0].isPhantom) {
440
- if (!secondaryDisableAdd) {
441
- // When a phantom entity is selected, change it to add mode.
442
- mode = EDITOR_MODE__ADD;
433
+ if (secondaryEditorType === EDITOR_TYPE__SIDE && !_.isNil(UiGlobals.isSideEditorAlwaysEditMode) && UiGlobals.isSideEditorAlwaysEditMode) {
434
+ // special case: side editor is always edit mode
435
+ mode = EDITOR_MODE__EDIT;
436
+ } else {
437
+ if (secondaryIsIgnoreNextSelectionChange) {
438
+ mode = secondaryEditorMode;
439
+ if (!secondaryCanEditorViewOnly && secondaryUserCanEdit) {
440
+ if (secondarySelection.length > 1) {
441
+ if (!secondaryDisableEdit) {
442
+ // For multiple entities selected, change it to edit multiple mode
443
+ mode = EDITOR_MODE__EDIT;
444
+ }
445
+ } else if (secondarySelection.length === 1 && !secondarySelection[0].isDestroyed && secondarySelection[0].isPhantom) {
446
+ if (!secondaryDisableAdd) {
447
+ // When a phantom entity is selected, change it to add mode.
448
+ mode = EDITOR_MODE__ADD;
449
+ }
443
450
  }
444
451
  }
452
+ } else {
453
+ mode = secondarySelection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
445
454
  }
446
- } else {
447
- mode = secondarySelection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
448
455
  }
449
456
  return mode;
450
457
  },
@@ -8,8 +8,22 @@ import _ from 'lodash';
8
8
  // NOTE: This is a modified version of @onehat/ui/src/Hoc/withSideEditor
9
9
  // This HOC will eventually get out of sync with that one, and may need to be updated.
10
10
 
11
- export default function withSideEditor(WrappedComponent, isTree = false) {
12
- return withSecondaryEditor((props) => {
11
+
12
+ function withAdditionalProps(WrappedComponent) {
13
+ return (props) => {
14
+ // provide the editorType to withEditor
15
+ return <WrappedComponent
16
+ editorType={EDITOR_TYPE__SIDE}
17
+ {...props}
18
+ />;
19
+ };
20
+ }
21
+
22
+ // NOTE: Effectivtly, the HOC composition is:
23
+ // withAdditionalProps(withSecondaryEditor(withSecondarySideEditor))
24
+
25
+ export default function withSecondarySideEditor(WrappedComponent, isTree = false) {
26
+ return withAdditionalProps(withSecondaryEditor((props) => {
13
27
  const {
14
28
  SecondaryEditor,
15
29
  secondaryEditorProps = {},
@@ -46,5 +60,5 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
46
60
  reference="secondaryEditor"
47
61
  />}
48
62
  />;
49
- });
63
+ }));
50
64
  }
@@ -13,8 +13,22 @@ import _ from 'lodash';
13
13
  // NOTE: This is a modified version of @onehat/ui/src/Hoc/withWindowedEditor
14
14
  // This HOC will eventually get out of sync with that one, and may need to be updated.
15
15
 
16
+
17
+ function withAdditionalProps(WrappedComponent) {
18
+ return (props) => {
19
+ // provide the editorType to withEditor
20
+ return <WrappedComponent
21
+ editorType={EDITOR_TYPE__WINDOWED}
22
+ {...props}
23
+ />;
24
+ };
25
+ }
26
+
27
+ // NOTE: Effectivtly, the HOC composition is:
28
+ // withAdditionalProps(withSecondaryEditor(withSecondaryWindowedEditor))
29
+
16
30
  export default function withSecondaryWindowedEditor(WrappedComponent, isTree = false) {
17
- return withSecondaryEditor((props) => {
31
+ return withAdditionalProps(withSecondaryEditor((props) => {
18
32
  const {
19
33
  secondaryIsEditorShown = false,
20
34
  secondarySetIsEditorShown,
@@ -67,5 +81,5 @@ export default function withSecondaryWindowedEditor(WrappedComponent, isTree = f
67
81
  />
68
82
  </Modal>}
69
83
  </>;
70
- }, isTree);
84
+ }, isTree));
71
85
  }
@@ -6,6 +6,7 @@ import {
6
6
  EDITOR_MODE__VIEW,
7
7
  EDITOR_MODE__ADD,
8
8
  EDITOR_MODE__EDIT,
9
+ EDITOR_TYPE__SIDE,
9
10
  } from '../../Constants/Editor.js';
10
11
  import UiGlobals from '../../UiGlobals.js';
11
12
  import _ from 'lodash';
@@ -34,6 +35,7 @@ export default function withEditor(WrappedComponent, isTree = false) {
34
35
  }
35
36
  return 'record' + (selection[0].displayValue ? ' "' + selection[0].displayValue + '"' : '') + '?';
36
37
  },
38
+ editorType,
37
39
  onAdd,
38
40
  onChange, // any kind of crud change
39
41
  onDelete,
@@ -437,23 +439,28 @@ export default function withEditor(WrappedComponent, isTree = false) {
437
439
 
438
440
  // calculateEditorMode gets called only on selection changes
439
441
  let mode;
440
- if (isIgnoreNextSelectionChange) {
441
- mode = editorMode;
442
- if (!canEditorViewOnly && userCanEdit) {
443
- if (selection.length > 1) {
444
- if (!disableEdit) {
445
- // For multiple entities selected, change it to edit multiple mode
446
- mode = EDITOR_MODE__EDIT;
447
- }
448
- } else if (selection.length === 1 && !selection[0].isDestroyed && selection[0].isPhantom) {
449
- if (!disableAdd) {
450
- // When a phantom entity is selected, change it to add mode.
451
- mode = EDITOR_MODE__ADD;
442
+ if (editorType === EDITOR_TYPE__SIDE && !_.isNil(UiGlobals.isSideEditorAlwaysEditMode) && UiGlobals.isSideEditorAlwaysEditMode) {
443
+ // special case: side editor is always edit mode
444
+ mode = EDITOR_MODE__EDIT;
445
+ } else {
446
+ if (isIgnoreNextSelectionChange) {
447
+ mode = editorMode;
448
+ if (!canEditorViewOnly && userCanEdit) {
449
+ if (selection.length > 1) {
450
+ if (!disableEdit) {
451
+ // For multiple entities selected, change it to edit multiple mode
452
+ mode = EDITOR_MODE__EDIT;
453
+ }
454
+ } else if (selection.length === 1 && !selection[0].isDestroyed && selection[0].isPhantom) {
455
+ if (!disableAdd) {
456
+ // When a phantom entity is selected, change it to add mode.
457
+ mode = EDITOR_MODE__ADD;
458
+ }
452
459
  }
453
460
  }
461
+ } else {
462
+ mode = selection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
454
463
  }
455
- } else {
456
- mode = selection.length > 1 ? EDITOR_MODE__EDIT : EDITOR_MODE__VIEW;
457
464
  }
458
465
  return mode;
459
466
  },
@@ -18,8 +18,23 @@ import Form from '../Form/Form.js';
18
18
  import withEditor from './withEditor.js';
19
19
  import _ from 'lodash';
20
20
 
21
+
22
+
23
+ function withAdditionalProps(WrappedComponent) {
24
+ return (props) => {
25
+ // provide the editorType to withEditor
26
+ return <WrappedComponent
27
+ editorType={EDITOR_TYPE__INLINE}
28
+ {...props}
29
+ />;
30
+ };
31
+ }
32
+
33
+ // NOTE: Effectivtly, the HOC composition is:
34
+ // withAdditionalProps(withEditor(withWindowedEditor))
35
+
21
36
  export default function withInlineEditor(WrappedComponent) {
22
- return withEditor((props) => {
37
+ return withAdditionalProps(withEditor((props) => {
23
38
  const {
24
39
  editorType,
25
40
  isEditorShown = false,
@@ -147,5 +162,5 @@ export default function withInlineEditor(WrappedComponent) {
147
162
  inlineEditor={inlineEditor}
148
163
  isInlineEditorShown={isEditorShown}
149
164
  />;
150
- });
165
+ }));
151
166
  }
@@ -6,8 +6,21 @@ import withEditor from './withEditor.js';
6
6
  import _ from 'lodash';
7
7
 
8
8
 
9
+ function withAdditionalProps(WrappedComponent) {
10
+ return (props) => {
11
+ // provide the editorType to withEditor
12
+ return <WrappedComponent
13
+ editorType={EDITOR_TYPE__SIDE}
14
+ {...props}
15
+ />;
16
+ };
17
+ }
18
+
19
+ // NOTE: Effectivtly, the HOC composition is:
20
+ // withAdditionalProps(withEditor(withSideEditor))
21
+
9
22
  export default function withSideEditor(WrappedComponent, isTree = false) {
10
- return withEditor((props) => {
23
+ return withAdditionalProps(withEditor((props) => {
11
24
  const {
12
25
  Editor,
13
26
  editorProps = {},
@@ -44,5 +57,5 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
44
57
  reference="editor"
45
58
  />}
46
59
  />;
47
- });
60
+ }));
48
61
  }
@@ -25,8 +25,24 @@ import _ from 'lodash';
25
25
  // then switch position to absolute, draggable area would be header of panel
26
26
  // const DraggableColumn = withAdditionalProps(withDraggable(Column));
27
27
 
28
+
29
+
30
+
31
+ function withAdditionalProps(WrappedComponent) {
32
+ return (props) => {
33
+ // provide the editorType to withEditor
34
+ return <WrappedComponent
35
+ editorType={EDITOR_TYPE__WINDOWED}
36
+ {...props}
37
+ />;
38
+ };
39
+ }
40
+
41
+ // NOTE: Effectivtly, the HOC composition is:
42
+ // withAdditionalProps(withEditor(withWindowedEditor))
43
+
28
44
  export default function withWindowedEditor(WrappedComponent, isTree = false) {
29
- return withEditor((props) => {
45
+ return withAdditionalProps(withEditor((props) => {
30
46
  const {
31
47
  isEditorShown = false,
32
48
  setIsEditorShown,
@@ -65,5 +81,5 @@ export default function withWindowedEditor(WrappedComponent, isTree = false) {
65
81
  />
66
82
  </Modal>}
67
83
  </>;
68
- }, isTree);
84
+ }, isTree));
69
85
  }