@onehat/ui 0.2.80 → 0.2.81
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,3 +1,4 @@
|
|
|
1
|
+
import { useState, } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
EDITOR_TYPE__SIDE,
|
|
3
4
|
} from '../../Constants/Editor.js';
|
|
@@ -12,20 +13,27 @@ export default function withSideEditor(WrappedComponent, isTree = false) {
|
|
|
12
13
|
Editor,
|
|
13
14
|
editorProps = {},
|
|
14
15
|
sideFlex = 100,
|
|
15
|
-
} = props
|
|
16
|
+
} = props,
|
|
17
|
+
[selection, setSelection] = useState(null);
|
|
18
|
+
|
|
16
19
|
|
|
17
20
|
if (!Editor) {
|
|
18
21
|
throw Error('Editor is not defined');
|
|
19
22
|
}
|
|
20
23
|
|
|
21
24
|
return <Container
|
|
22
|
-
center={<WrappedComponent
|
|
25
|
+
center={<WrappedComponent
|
|
26
|
+
isTree={isTree}
|
|
27
|
+
{...props}
|
|
28
|
+
onSelectionChange={setSelection}
|
|
29
|
+
/>}
|
|
23
30
|
east={<Editor
|
|
24
31
|
editorType={EDITOR_TYPE__SIDE}
|
|
25
32
|
flex={sideFlex}
|
|
26
|
-
{
|
|
33
|
+
selection={selection} // This needs to be whatever the selection is in the center component
|
|
34
|
+
// {...props}
|
|
27
35
|
{...editorProps}
|
|
28
36
|
/>}
|
|
29
37
|
/>;
|
|
30
|
-
}
|
|
38
|
+
});
|
|
31
39
|
}
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import Svg, { Defs, G, Path } from "react-native-svg"
|
|
3
|
+
import { Icon } from 'native-base';
|
|
4
|
+
|
|
5
|
+
function SvgComponent(props) {
|
|
6
|
+
return (
|
|
7
|
+
<Icon
|
|
8
|
+
id="Layer_2"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 237.17 235.06"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<Defs></Defs>
|
|
14
|
+
<G id="Layer_1-2">
|
|
15
|
+
<Path
|
|
16
|
+
className="cls-1"
|
|
17
|
+
d="M237.17 235.06H0V0h237.17v235.06zM13.46 221.59H223.7V13.47H13.47V221.6z"
|
|
18
|
+
/>
|
|
19
|
+
<Path
|
|
20
|
+
className="cls-1"
|
|
21
|
+
d="M200.77 192.33H36.4V42.74h164.36v149.59zm-150.9-13.47H187.3V56.2H49.87v122.66z"
|
|
22
|
+
/>
|
|
23
|
+
</G>
|
|
24
|
+
</Icon>
|
|
25
|
+
)
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export default SvgComponent
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import * as React from "react"
|
|
2
|
+
import Svg, { G, Path } from "react-native-svg"
|
|
3
|
+
import { Icon } from 'native-base';
|
|
4
|
+
|
|
5
|
+
function SvgComponent(props) {
|
|
6
|
+
return (
|
|
7
|
+
<Icon
|
|
8
|
+
id="Layer_2"
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 237.17 235.06"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<G id="Layer_1-2">
|
|
14
|
+
<Path
|
|
15
|
+
d="M85.22 235.06H0V0h85.22v235.06zm-71.75-13.47h58.29V13.47H13.47V221.6zM237.17 235.06H109.74V0h127.43v235.06zm-113.96-13.47h100.5V13.47h-100.5V221.6z"
|
|
16
|
+
strokeWidth={0}
|
|
17
|
+
/>
|
|
18
|
+
</G>
|
|
19
|
+
</Icon>
|
|
20
|
+
)
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
export default SvgComponent
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import React, { useState, useEffect, useMemo, useId, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
Column,
|
|
4
|
+
Row,
|
|
5
|
+
Text,
|
|
6
|
+
} from 'native-base';
|
|
7
|
+
import IconButton from '../Buttons/IconButton';
|
|
8
|
+
import FullWidth from '../Icons/FullWidth';
|
|
9
|
+
import SideBySide from '../Icons/SideBySide';
|
|
10
|
+
import getSaved from '../../Functions/getSaved.js';
|
|
11
|
+
import setSaved from '../../Functions/setSaved.js';
|
|
12
|
+
import _ from 'lodash';
|
|
13
|
+
|
|
14
|
+
const
|
|
15
|
+
MODE_FULL = 'MODE_FULL',
|
|
16
|
+
MODE_SIDE = 'MODE_SIDE';
|
|
17
|
+
|
|
18
|
+
export default function ManagerScreen(props) {
|
|
19
|
+
const {
|
|
20
|
+
title,
|
|
21
|
+
sideModeComponent,
|
|
22
|
+
fullModeComponent,
|
|
23
|
+
} = props,
|
|
24
|
+
id = useId(),
|
|
25
|
+
[isReady, setIsReady] = useState(false),
|
|
26
|
+
[mode, setModeRaw] = useState(MODE_FULL),
|
|
27
|
+
setMode = (newMode) => {
|
|
28
|
+
if (newMode === mode) {
|
|
29
|
+
return; // no change
|
|
30
|
+
}
|
|
31
|
+
setModeRaw(newMode);
|
|
32
|
+
setSaved(id + '-mode', newMode);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
useEffect(() => {
|
|
36
|
+
// Restore saved settings
|
|
37
|
+
(async () => {
|
|
38
|
+
|
|
39
|
+
let key, val;
|
|
40
|
+
key = id + '-mode';
|
|
41
|
+
val = await getSaved(key);
|
|
42
|
+
if (!_.isNil(val)) {
|
|
43
|
+
setMode(val);
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (!isReady) {
|
|
47
|
+
setIsReady(true);
|
|
48
|
+
}
|
|
49
|
+
})();
|
|
50
|
+
}, []);
|
|
51
|
+
|
|
52
|
+
if (!isReady) {
|
|
53
|
+
return null;
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
let whichComponent;
|
|
57
|
+
if (mode === MODE_FULL) {
|
|
58
|
+
whichComponent = fullModeComponent;
|
|
59
|
+
} else if (mode === MODE_SIDE) {
|
|
60
|
+
whichComponent = sideModeComponent;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return <Column flex={1} w="100%">
|
|
64
|
+
<Row
|
|
65
|
+
h="80px"
|
|
66
|
+
py={2}
|
|
67
|
+
>
|
|
68
|
+
<Text p={4} fontSize="26" fontWeight={700}>{title}</Text>
|
|
69
|
+
<IconButton
|
|
70
|
+
icon={FullWidth}
|
|
71
|
+
_icon={{
|
|
72
|
+
size: '30px',
|
|
73
|
+
color: mode === MODE_FULL ? 'primary.100' : '#000',
|
|
74
|
+
}}
|
|
75
|
+
disabled={mode === MODE_FULL}
|
|
76
|
+
onPress={() => setMode(MODE_FULL)}
|
|
77
|
+
tooltip="Full Width"
|
|
78
|
+
/>
|
|
79
|
+
<IconButton
|
|
80
|
+
icon={SideBySide}
|
|
81
|
+
_icon={{
|
|
82
|
+
size: '30px',
|
|
83
|
+
color: mode === MODE_SIDE ? 'primary.100' : '#000',
|
|
84
|
+
}}
|
|
85
|
+
disabled={mode === MODE_SIDE}
|
|
86
|
+
onPress={() => setMode(MODE_SIDE)}
|
|
87
|
+
tooltip="Side Editor"
|
|
88
|
+
/>
|
|
89
|
+
</Row>
|
|
90
|
+
{whichComponent}
|
|
91
|
+
</Column>;
|
|
92
|
+
}
|
|
@@ -32,7 +32,6 @@ export default function TabBar(props) {
|
|
|
32
32
|
startsCollapsed = true,
|
|
33
33
|
onChangeCurrentTab,
|
|
34
34
|
onChangeIsCollapsed,
|
|
35
|
-
saveCurrentTab = true,
|
|
36
35
|
...propsToPass
|
|
37
36
|
} = props,
|
|
38
37
|
styles = UiGlobals.styles,
|
|
@@ -55,15 +54,16 @@ export default function TabBar(props) {
|
|
|
55
54
|
return currentTabIx;
|
|
56
55
|
},
|
|
57
56
|
setCurrentTab = (ix) => {
|
|
57
|
+
if ((useLocal && ix === currentTabIxLocal) || ix === currentTabIx) {
|
|
58
|
+
return; // no change
|
|
59
|
+
}
|
|
58
60
|
if (useLocal) {
|
|
59
61
|
setCurrentTabIxLocal(ix);
|
|
62
|
+
setSaved(id + '-currentTabIx', ix);
|
|
60
63
|
}
|
|
61
64
|
if (onChangeCurrentTab) {
|
|
62
65
|
onChangeCurrentTab(ix);
|
|
63
66
|
}
|
|
64
|
-
if (saveCurrentTab) {
|
|
65
|
-
setSaved(id + '-currentTabIx', ix);
|
|
66
|
-
}
|
|
67
67
|
},
|
|
68
68
|
onToggleCollapse = () => {
|
|
69
69
|
setIsCollapsed(!isCollapsed);
|
|
@@ -310,7 +310,7 @@ export default function TabBar(props) {
|
|
|
310
310
|
setIsCollapsed(val);
|
|
311
311
|
}
|
|
312
312
|
|
|
313
|
-
if (
|
|
313
|
+
if (useLocal) {
|
|
314
314
|
key = id + '-currentTabIx';
|
|
315
315
|
val = await getSaved(key);
|
|
316
316
|
if (!_.isNil(val)) {
|