@onehat/ui 0.2.76 → 0.2.78
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/Editor/Editor.js +1 -11
- package/src/Components/Form/Form.js +24 -22
- package/src/Components/Grid/Grid.js +29 -19
- package/src/Components/Grid/GridHeaderRow.js +6 -0
- package/src/Components/Grid/GridRow.js +6 -0
- package/src/Components/Hoc/withDraggable.js +8 -3
- package/src/Components/Hoc/withEditor.js +35 -11
- package/src/Components/Hoc/withInlineEditor.js +53 -22
- package/src/Components/Tree/Tree.js +282 -257
- package/src/Components/Tree/TreeNode.js +12 -18
- package/src/Constants/Directions.js +1 -0
- package/src/Constants/Styles.js +5 -0
- package/src/Constants/Tree.js +4 -1
- package/src/Constants/UiModes.js +3 -3
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { useMemo, } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Icon,
|
|
@@ -6,9 +6,6 @@ import {
|
|
|
6
6
|
Spinner,
|
|
7
7
|
Text,
|
|
8
8
|
} from 'native-base';
|
|
9
|
-
import {
|
|
10
|
-
VERTICAL,
|
|
11
|
-
} from '../../Constants/Directions.js';
|
|
12
9
|
import UiGlobals from '../../UiGlobals.js';
|
|
13
10
|
import withDraggable from '../Hoc/withDraggable.js';
|
|
14
11
|
import IconButton from '../Buttons/IconButton.js';
|
|
@@ -22,6 +19,8 @@ export default function TreeNode(props) {
|
|
|
22
19
|
bg,
|
|
23
20
|
datum,
|
|
24
21
|
onToggle,
|
|
22
|
+
isDragMode,
|
|
23
|
+
isHighlighted,
|
|
25
24
|
...propsToPass
|
|
26
25
|
} = props,
|
|
27
26
|
styles = UiGlobals.styles,
|
|
@@ -37,7 +36,9 @@ export default function TreeNode(props) {
|
|
|
37
36
|
iconLeaf = datum.iconLeaf,
|
|
38
37
|
hash = item?.hash || item;
|
|
39
38
|
|
|
40
|
-
const
|
|
39
|
+
const
|
|
40
|
+
icon = hasChildren ? (isExpanded ? iconExpanded : iconCollapsed) : iconLeaf,
|
|
41
|
+
adjustedBg = isHighlighted ? styles.TREE_NODE_HIGHLIGHTED_BG : bg;
|
|
41
42
|
|
|
42
43
|
return useMemo(() => {
|
|
43
44
|
|
|
@@ -45,14 +46,14 @@ export default function TreeNode(props) {
|
|
|
45
46
|
alignItems="center"
|
|
46
47
|
flexGrow={1}
|
|
47
48
|
{...nodeProps}
|
|
48
|
-
bg={
|
|
49
|
+
bg={adjustedBg}
|
|
49
50
|
key={hash}
|
|
50
51
|
>
|
|
51
52
|
{isPhantom && <Box position="absolute" bg="#f00" h={2} w={2} t={0} l={0} />}
|
|
52
53
|
|
|
53
54
|
{isLoading ?
|
|
54
55
|
<Spinner px={2} /> :
|
|
55
|
-
(hasChildren ? <IconButton icon={icon} onPress={() => onToggle(datum)} /> : <Icon as={icon} px={2} />)}
|
|
56
|
+
(hasChildren && !isDragMode ? <IconButton icon={icon} onPress={() => onToggle(datum)} /> : <Icon as={icon} px={2} />)}
|
|
56
57
|
|
|
57
58
|
<Text
|
|
58
59
|
overflow="hidden"
|
|
@@ -70,7 +71,7 @@ export default function TreeNode(props) {
|
|
|
70
71
|
</Row>;
|
|
71
72
|
}, [
|
|
72
73
|
nodeProps,
|
|
73
|
-
|
|
74
|
+
adjustedBg,
|
|
74
75
|
item,
|
|
75
76
|
isPhantom,
|
|
76
77
|
hash, // this is an easy way to determine if the data has changed and the item needs to be rerendered
|
|
@@ -81,16 +82,9 @@ export default function TreeNode(props) {
|
|
|
81
82
|
icon,
|
|
82
83
|
onToggle,
|
|
83
84
|
isLoading,
|
|
85
|
+
isDragMode,
|
|
86
|
+
isHighlighted,
|
|
84
87
|
]);
|
|
85
88
|
}
|
|
86
89
|
|
|
87
|
-
|
|
88
|
-
return (props) => {
|
|
89
|
-
return <WrappedComponent
|
|
90
|
-
mode={VERTICAL}
|
|
91
|
-
{...props}
|
|
92
|
-
/>;
|
|
93
|
-
};
|
|
94
|
-
}
|
|
95
|
-
|
|
96
|
-
export const ReorderableTreeNode = withAdditionalProps(withDraggable(TreeNode));
|
|
90
|
+
export const DraggableTreeNode = withDraggable(TreeNode);
|
package/src/Constants/Styles.js
CHANGED
|
@@ -67,6 +67,7 @@ const defaults = {
|
|
|
67
67
|
ICON_BUTTON_BG_DISABLED: 'trueGray.200',
|
|
68
68
|
ICON_BUTTON_BG_HOVER: '#000:alpha.20',
|
|
69
69
|
ICON_BUTTON_BG_PRESSED: '#000:alpha.30',
|
|
70
|
+
INLINE_EDITOR_MIN_WIDTH: 150,
|
|
70
71
|
PANEL_FOOTER_BG: 'primary.100', // :alpha.50
|
|
71
72
|
PANEL_HEADER_BG: 'primary.100',
|
|
72
73
|
PANEL_HEADER_BG_VERTICAL: 'primary.100',
|
|
@@ -76,6 +77,9 @@ const defaults = {
|
|
|
76
77
|
PANEL_HEADER_TEXT_FONTSIZE: 15,
|
|
77
78
|
PANEL_HEADER_PX: 3,
|
|
78
79
|
PANEL_HEADER_PY: 1,
|
|
80
|
+
REORDER_BORDER_COLOR: '#23d9ea',
|
|
81
|
+
REORDER_BORDER_WIDTH: 4,
|
|
82
|
+
REORDER_BORDER_STYLE: 'dashed',
|
|
79
83
|
TAB_ACTIVE_BG: 'trueGray.200',
|
|
80
84
|
TAB_ACTIVE_HOVER_BG: 'trueGray.200',
|
|
81
85
|
TAB_ACTIVE_COLOR: 'primary.800',
|
|
@@ -94,6 +98,7 @@ const defaults = {
|
|
|
94
98
|
TREE_NODE_HOVER_BG: 'hover',
|
|
95
99
|
TREE_NODE_SELECTED_BG: 'selected',
|
|
96
100
|
TREE_NODE_SELECTED_HOVER_BG: 'selectedHover',
|
|
101
|
+
TREE_NODE_HIGHLIGHTED_BG: '#ffa',
|
|
97
102
|
TOOLBAR_ITEMS_COLOR: 'trueGray.800',
|
|
98
103
|
TOOLBAR_ITEMS_DISABLED_COLOR: 'trueGray.400',
|
|
99
104
|
TOOLBAR_ITEMS_ICON_SIZE: 'sm',
|
package/src/Constants/Tree.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export const SORT_ASCENDING = 'ASC'; // This is what RestTrait expects
|
|
2
2
|
export const SORT_DESCENDING = 'DESC'; // This is what RestTrait expects
|
|
3
3
|
export const DROP_POSITION_BEFORE = 'before'; // This is what RestTrait expects
|
|
4
|
-
export const DROP_POSITION_AFTER = 'after'; // This is what RestTrait expects
|
|
4
|
+
export const DROP_POSITION_AFTER = 'after'; // This is what RestTrait expects
|
|
5
|
+
export const COLLAPSED = 'COLLAPSED';
|
|
6
|
+
export const EXPANDED = 'EXPANDED';
|
|
7
|
+
export const LEAF = 'LEAF';
|
package/src/Constants/UiModes.js
CHANGED
|
@@ -5,8 +5,8 @@ export const UI_MODE_WEB = 'Web';
|
|
|
5
5
|
export const UI_MODE_REACT_NATIVE = 'ReactNative';
|
|
6
6
|
|
|
7
7
|
export let CURRENT_MODE;
|
|
8
|
-
if (
|
|
9
|
-
CURRENT_MODE = UI_MODE_REACT_NATIVE;
|
|
10
|
-
} else if (isBrowser || isWebWorker) {
|
|
8
|
+
if (isBrowser || isWebWorker) {
|
|
11
9
|
CURRENT_MODE = UI_MODE_WEB;
|
|
10
|
+
} else if (isReactNative) {
|
|
11
|
+
CURRENT_MODE = UI_MODE_REACT_NATIVE;
|
|
12
12
|
}
|