@onehat/ui 0.2.57 → 0.2.59
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/cypress/plugins/index.js +2 -0
- package/cypress/support/commands.js +2 -0
- package/cypress/support/e2e.js +2 -0
- package/cypress.config.js +41 -0
- package/package.json +34 -25
- package/src/Components/Form/Field/CKEditor/CKEditor.js +1 -1
- package/src/Components/Form/Form.js +1 -1
- package/src/Components/Grid/Grid.js +12 -5
- package/src/Components/Grid/GridHeaderRow.js +5 -2
- package/src/Components/Grid/GridRow.js +2 -0
- package/src/Components/Hoc/withContextMenu.js +1 -1
- package/src/Components/Icons/BarsStaggered.js +14 -0
- package/src/Components/Icons/Circle.js +14 -0
- package/src/Components/Icons/Folder.js +14 -0
- package/src/Components/Icons/FolderClosed.js +14 -0
- package/src/Components/Icons/FolderOpen.js +14 -0
- package/src/Components/Icons/FolderTree.js +14 -0
- package/src/Components/Icons/Leaf.js +14 -0
- package/src/Components/Icons/MagnifyingGlass.js +14 -0
- package/src/Components/Icons/collapse.js +17 -0
- package/src/Components/Tree/Tree.js +1143 -0
- package/src/Components/Tree/TreeNode.js +94 -0
- package/src/Constants/Styles.js +14 -0
- package/src/Functions/BankersRound.js +1 -1
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
import { useState, useMemo, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Box,
|
|
4
|
+
Row,
|
|
5
|
+
Text,
|
|
6
|
+
} from 'native-base';
|
|
7
|
+
import {
|
|
8
|
+
VERTICAL,
|
|
9
|
+
} from '../../Constants/Directions.js';
|
|
10
|
+
import UiGlobals from '../../UiGlobals.js';
|
|
11
|
+
import withDraggable from '../Hoc/withDraggable.js';
|
|
12
|
+
import IconButton from '../Buttons/IconButton.js';
|
|
13
|
+
import _ from 'lodash';
|
|
14
|
+
|
|
15
|
+
// This was broken out from Tree simply so we can memoize it
|
|
16
|
+
|
|
17
|
+
export default function TreeNode(props) {
|
|
18
|
+
const {
|
|
19
|
+
nodeProps,
|
|
20
|
+
bg,
|
|
21
|
+
datum,
|
|
22
|
+
onToggle,
|
|
23
|
+
} = props,
|
|
24
|
+
styles = UiGlobals.styles,
|
|
25
|
+
item = datum.item,
|
|
26
|
+
isPhantom = item.isPhantom,
|
|
27
|
+
isExpanded = datum.isExpanded,
|
|
28
|
+
hasChildren = datum.hasChildren,
|
|
29
|
+
depth = datum.depth,
|
|
30
|
+
text = datum.text,
|
|
31
|
+
iconCollapsed = datum.iconCollapsed,
|
|
32
|
+
iconExpanded = datum.iconExpanded,
|
|
33
|
+
iconLeaf = datum.iconLeaf,
|
|
34
|
+
hash = item?.hash || item;
|
|
35
|
+
|
|
36
|
+
const icon = hasChildren ? (isExpanded ? iconCollapsed : iconExpanded) : iconLeaf;
|
|
37
|
+
|
|
38
|
+
return useMemo(() => {
|
|
39
|
+
|
|
40
|
+
return <Row
|
|
41
|
+
alignItems="center"
|
|
42
|
+
flexGrow={1}
|
|
43
|
+
{...nodeProps}
|
|
44
|
+
bg={bg}
|
|
45
|
+
key={hash}
|
|
46
|
+
pl={(depth * 10) + 'px'}
|
|
47
|
+
>
|
|
48
|
+
{isPhantom && <Box position="absolute" bg="#f00" h={2} w={2} t={0} l={0} />}
|
|
49
|
+
|
|
50
|
+
<IconButton
|
|
51
|
+
icon={icon}
|
|
52
|
+
onPress={onToggle}
|
|
53
|
+
/>
|
|
54
|
+
|
|
55
|
+
<Text
|
|
56
|
+
key={key}
|
|
57
|
+
overflow="hidden"
|
|
58
|
+
textOverflow="ellipsis"
|
|
59
|
+
alignSelf="center"
|
|
60
|
+
style={{ userSelect: 'none', }}
|
|
61
|
+
fontSize={styles.TREE_NODE_FONTSIZE}
|
|
62
|
+
px={styles.TREE_NODE_PX}
|
|
63
|
+
py={styles.TREE_NODE_PY}
|
|
64
|
+
numberOfLines={1}
|
|
65
|
+
ellipsizeMode="head"
|
|
66
|
+
{...propsToPass}
|
|
67
|
+
>{text}</Text>
|
|
68
|
+
|
|
69
|
+
</Row>;
|
|
70
|
+
}, [
|
|
71
|
+
nodeProps,
|
|
72
|
+
bg,
|
|
73
|
+
item,
|
|
74
|
+
isPhantom,
|
|
75
|
+
hash, // this is an easy way to determine if the data has changed and the item needs to be rerendered
|
|
76
|
+
isExpanded,
|
|
77
|
+
hasChildren,
|
|
78
|
+
depth,
|
|
79
|
+
text,
|
|
80
|
+
icon,
|
|
81
|
+
onToggle,
|
|
82
|
+
]);
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
function withAdditionalProps(WrappedComponent) {
|
|
86
|
+
return (props) => {
|
|
87
|
+
return <WrappedComponent
|
|
88
|
+
mode={VERTICAL}
|
|
89
|
+
{...props}
|
|
90
|
+
/>;
|
|
91
|
+
};
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export const ReorderableTreeNode = withAdditionalProps(withDraggable(TreeNode));
|
package/src/Constants/Styles.js
CHANGED
|
@@ -52,8 +52,12 @@ const defaults = {
|
|
|
52
52
|
GRID_HEADER_BG: '#eee',
|
|
53
53
|
GRID_HEADER_HOVER_BG: '#ddd',
|
|
54
54
|
GRID_HEADER_FONTSIZE: DEFAULT_FONTSIZE,
|
|
55
|
+
GRID_HEADER_CELL_PX: 2,
|
|
56
|
+
GRID_HEADER_CELL_PY: 3,
|
|
55
57
|
GRID_INLINE_EDITOR_BORDER_COLOR: 'primary.100',
|
|
56
58
|
GRID_NAV_COLUMN_COLOR: '#aaa',
|
|
59
|
+
GRID_CELL_PX: 2,
|
|
60
|
+
GRID_CELL_PY: 3,
|
|
57
61
|
GRID_ROW_BG: WHITE,
|
|
58
62
|
GRID_ROW_HOVER_BG: 'hover',
|
|
59
63
|
GRID_ROW_SELECTED_BG: 'selected',
|
|
@@ -85,6 +89,16 @@ const defaults = {
|
|
|
85
89
|
TAB_COLOR: WHITE,
|
|
86
90
|
TAB_FONTSIZE: DEFAULT_FONTSIZE,
|
|
87
91
|
TEXT_FONTSIZE: DEFAULT_FONTSIZE,
|
|
92
|
+
TREE_NODE_FONTSIZE: DEFAULT_FONTSIZE,
|
|
93
|
+
TREE_NODE_PX: 2,
|
|
94
|
+
TREE_NODE_PY: 3,
|
|
95
|
+
TREE_NODE_BG: WHITE,
|
|
96
|
+
TREE_NODE_HOVER_BG: 'hover',
|
|
97
|
+
TREE_NODE_SELECTED_BG: 'selected',
|
|
98
|
+
TREE_NODE_SELECTED_HOVER_BG: 'selectedHover',
|
|
99
|
+
TREE_TOOLBAR_ITEMS_COLOR: 'trueGray.800',
|
|
100
|
+
TREE_TOOLBAR_ITEMS_DISABLED_COLOR: 'disabled',
|
|
101
|
+
TREE_TOOLBAR_ITEMS_ICON_SIZE: 'sm',
|
|
88
102
|
};
|
|
89
103
|
|
|
90
104
|
export default defaults;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import round from 'locutus/php/math/round'; // Port of PHP functions to JS
|
|
1
|
+
import round from 'locutus/php/math/round.js'; // Port of PHP functions to JS
|
|
2
2
|
|
|
3
3
|
// Rounds to the nearest EVEN integer. This means it is unbiased (doesn't always round up, doesn't always round down)
|
|
4
4
|
export function BankersRound($x) {
|