@onehat/ui 0.3.236 → 0.3.238
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 +1 -1
- package/src/Components/Form/Field/CKEditor/CKEditor.js +3 -4
- package/src/Components/Form/Field/Input.js +1 -4
- package/src/Components/Form/Field/Number.js +2 -4
- package/src/Components/Hoc/Secondary/withSecondaryEditor.js +21 -14
- package/src/Components/Hoc/Secondary/withSecondarySideEditor.js +17 -3
- package/src/Components/Hoc/Secondary/withSecondaryWindowedEditor.js +16 -2
- package/src/UiGlobals.js +3 -0
- package/src/Constants/Input.js +0 -1
package/package.json
CHANGED
|
@@ -2,9 +2,7 @@ import React, { useState, useEffect, useRef, } from 'react';
|
|
|
2
2
|
import {
|
|
3
3
|
Row,
|
|
4
4
|
} from 'native-base';
|
|
5
|
-
import
|
|
6
|
-
AUTO_SUBMIT_DELAY,
|
|
7
|
-
} from '../../../../Constants/Input.js';
|
|
5
|
+
import UiGlobals from '../../../../UiGlobals.js';
|
|
8
6
|
import { CKEditor } from '@ckeditor/ckeditor5-react'; // https://ckeditor.com/docs/ckeditor5/latest/installation/frameworks/react.html
|
|
9
7
|
import './ckeditor.css';
|
|
10
8
|
import Editor from '../../../../../ckeditor5/build/ckeditor.js'; // built using https://ckeditor.com/ckeditor-5/online-builder/
|
|
@@ -19,6 +17,7 @@ const
|
|
|
19
17
|
const {
|
|
20
18
|
value,
|
|
21
19
|
setValue,
|
|
20
|
+
autoSubmitDelay = UiGlobals.autoSubmitDelay,
|
|
22
21
|
h = 150,
|
|
23
22
|
} = props,
|
|
24
23
|
debouncedSetValueRef = useRef(),
|
|
@@ -30,7 +29,7 @@ const
|
|
|
30
29
|
useEffect(() => {
|
|
31
30
|
// Set up debounce fn
|
|
32
31
|
// Have to do this because otherwise, lodash tries to create a debounced version of the fn from only this render
|
|
33
|
-
debouncedSetValueRef.current = _.debounce(setValue,
|
|
32
|
+
debouncedSetValueRef.current = _.debounce(setValue, autoSubmitDelay);
|
|
34
33
|
}, [setValue]);
|
|
35
34
|
|
|
36
35
|
return <Row h={h} flex={1} ref={props.outerRef} {...props}>
|
|
@@ -3,9 +3,6 @@ import {
|
|
|
3
3
|
Input,
|
|
4
4
|
Tooltip,
|
|
5
5
|
} from 'native-base';
|
|
6
|
-
import {
|
|
7
|
-
AUTO_SUBMIT_DELAY,
|
|
8
|
-
} from '../../../Constants/Input.js';
|
|
9
6
|
import UiGlobals from '../../../UiGlobals.js';
|
|
10
7
|
import withComponent from '../../Hoc/withComponent.js';
|
|
11
8
|
import withValue from '../../Hoc/withValue.js';
|
|
@@ -16,7 +13,7 @@ function InputElement(props) {
|
|
|
16
13
|
value,
|
|
17
14
|
setValue,
|
|
18
15
|
autoSubmit = true, // automatically setValue after user stops typing for autoSubmitDelay
|
|
19
|
-
autoSubmitDelay =
|
|
16
|
+
autoSubmitDelay = UiGlobals.autoSubmitDelay,
|
|
20
17
|
autoCapitalize = 'none',
|
|
21
18
|
maxLength,
|
|
22
19
|
onKeyPress,
|
|
@@ -5,9 +5,6 @@ import {
|
|
|
5
5
|
Input,
|
|
6
6
|
Row,
|
|
7
7
|
} from 'native-base';
|
|
8
|
-
import {
|
|
9
|
-
AUTO_SUBMIT_DELAY,
|
|
10
|
-
} from '../../../Constants/Input.js';
|
|
11
8
|
import UiGlobals from '../../../UiGlobals.js';
|
|
12
9
|
import IconButton from '../../Buttons/IconButton.js';
|
|
13
10
|
import withComponent from '../../Hoc/withComponent.js';
|
|
@@ -25,6 +22,7 @@ function NumberElement(props) {
|
|
|
25
22
|
setValue,
|
|
26
23
|
minValue,
|
|
27
24
|
maxValue,
|
|
25
|
+
autoSubmitDelay = UiGlobals.autoSubmitDelay,
|
|
28
26
|
tooltip = null,
|
|
29
27
|
isDisabled = false,
|
|
30
28
|
} = props,
|
|
@@ -94,7 +92,7 @@ function NumberElement(props) {
|
|
|
94
92
|
useEffect(() => {
|
|
95
93
|
// Set up debounce fn
|
|
96
94
|
// Have to do this because otherwise, lodash tries to create a debounced version of the fn from only this render
|
|
97
|
-
debouncedSetValueRef.current = _.debounce(setValue,
|
|
95
|
+
debouncedSetValueRef.current = _.debounce(setValue, autoSubmitDelay);
|
|
98
96
|
}, [setValue]);
|
|
99
97
|
|
|
100
98
|
useEffect(() => {
|
|
@@ -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 (
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
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
|
-
|
|
12
|
-
|
|
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
|
}
|
package/src/UiGlobals.js
CHANGED
|
@@ -9,6 +9,9 @@ const Globals = {
|
|
|
9
9
|
// global defaults
|
|
10
10
|
paginationIsShowMoreOnly: false,
|
|
11
11
|
autoAdjustPageSizeToHeight: true,
|
|
12
|
+
doubleClickingGridRowOpensEditorInViewMode: false,
|
|
13
|
+
disableSavedColumnsConfig: false,
|
|
14
|
+
autoSubmitDelay: 500,
|
|
12
15
|
};
|
|
13
16
|
|
|
14
17
|
export default Globals;
|
package/src/Constants/Input.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const AUTO_SUBMIT_DELAY = 500;
|