@onehat/ui 0.4.67 → 0.4.68
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,14 +1,9 @@
|
|
|
1
|
-
import { useCallback } from 'react';
|
|
1
|
+
import { useCallback, useState } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Box,
|
|
3
4
|
Fab, FabIcon, FabLabel,
|
|
4
5
|
VStack,
|
|
5
6
|
} from '@project-components/Gluestack';
|
|
6
|
-
import Animated, {
|
|
7
|
-
useSharedValue,
|
|
8
|
-
useAnimatedStyle,
|
|
9
|
-
useDerivedValue,
|
|
10
|
-
withTiming,
|
|
11
|
-
} from 'react-native-reanimated';
|
|
12
7
|
import IconButton from '../Buttons/IconButton.js';
|
|
13
8
|
import FabWithTooltip from './FabWithTooltip.js';
|
|
14
9
|
import EllipsisVertical from '../Icons/EllipsisVertical.js';
|
|
@@ -20,7 +15,7 @@ import Xmark from '../Icons/Xmark.js';
|
|
|
20
15
|
export default function DynamicFab(props) {
|
|
21
16
|
const {
|
|
22
17
|
icon,
|
|
23
|
-
buttons, // to show when expanded
|
|
18
|
+
buttons = [], // to show when expanded
|
|
24
19
|
label,
|
|
25
20
|
tooltip,
|
|
26
21
|
tooltipPlacement = 'left',
|
|
@@ -28,21 +23,13 @@ export default function DynamicFab(props) {
|
|
|
28
23
|
tooltipTriggerClassName,
|
|
29
24
|
collapseOnPress = true,
|
|
30
25
|
} = props,
|
|
31
|
-
isExpanded =
|
|
26
|
+
[isExpanded, setIsExpanded] = useState(false),
|
|
32
27
|
toggleFab = useCallback(() => {
|
|
33
|
-
|
|
28
|
+
setIsExpanded(prev => !prev);
|
|
34
29
|
}, []),
|
|
35
30
|
buttonSpacing = 45,
|
|
36
31
|
verticalOffset = 50; // to shift the entire expanded group up
|
|
37
|
-
|
|
38
|
-
return {
|
|
39
|
-
opacity: withTiming(isExpanded.value, { duration: 200 }),
|
|
40
|
-
pointerEvents: isExpanded.value ? 'auto' : 'none', // Disable interaction when collapsed
|
|
41
|
-
};
|
|
42
|
-
}),
|
|
43
|
-
isExpandedForRender = useDerivedValue(() => { // Use useDerivedValue to safely read the shared value during render
|
|
44
|
-
return isExpanded.value > 0;
|
|
45
|
-
});
|
|
32
|
+
|
|
46
33
|
|
|
47
34
|
let className = `
|
|
48
35
|
DynamicFab
|
|
@@ -67,16 +54,17 @@ export default function DynamicFab(props) {
|
|
|
67
54
|
...btnConfigToPass
|
|
68
55
|
} = btnConfig;
|
|
69
56
|
|
|
70
|
-
|
|
57
|
+
if (!isExpanded) {
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return <Box
|
|
71
62
|
key={ix}
|
|
72
|
-
style={
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
right: 0,
|
|
78
|
-
},
|
|
79
|
-
]}
|
|
63
|
+
style={{
|
|
64
|
+
position: 'absolute',
|
|
65
|
+
bottom: buttonSpacing * (ix + 1) + verticalOffset, // Static vertical positioning
|
|
66
|
+
right: 0,
|
|
67
|
+
}}
|
|
80
68
|
>
|
|
81
69
|
<IconButton
|
|
82
70
|
className={`
|
|
@@ -89,12 +77,12 @@ export default function DynamicFab(props) {
|
|
|
89
77
|
onPress={() => {
|
|
90
78
|
onPress();
|
|
91
79
|
if (collapseOnPress) {
|
|
92
|
-
|
|
80
|
+
setIsExpanded(false);
|
|
93
81
|
}
|
|
94
82
|
}}
|
|
95
83
|
{...btnConfigToPass}
|
|
96
84
|
/>
|
|
97
|
-
</
|
|
85
|
+
</Box>;
|
|
98
86
|
})}
|
|
99
87
|
<FabWithTooltip
|
|
100
88
|
size="lg"
|
|
@@ -105,9 +93,7 @@ export default function DynamicFab(props) {
|
|
|
105
93
|
tooltipClassName={tooltipClassName}
|
|
106
94
|
tooltipTriggerClassName={tooltipTriggerClassName}
|
|
107
95
|
>
|
|
108
|
-
<
|
|
109
|
-
<FabIcon as={isExpandedForRender.value ? Xmark : icon || EllipsisVertical} />
|
|
110
|
-
</Animated.View>
|
|
96
|
+
<FabIcon as={isExpanded ? Xmark : icon || EllipsisVertical} />
|
|
111
97
|
{label ? <FabLabel>{label}</FabLabel> : null}
|
|
112
98
|
</FabWithTooltip>
|
|
113
99
|
</VStack>;
|
|
@@ -8,7 +8,10 @@ import {
|
|
|
8
8
|
} from '@project-components/Gluestack';
|
|
9
9
|
import {
|
|
10
10
|
UI_MODE_WEB,
|
|
11
|
+
UI_MODE_NATIVE,
|
|
12
|
+
CURRENT_MODE,
|
|
11
13
|
} from '../../Constants/UiModes.js';
|
|
14
|
+
import { getEmptyImage } from 'react-dnd-html5-backend';
|
|
12
15
|
import * as colourMixer from '@k-renwick/colour-mixer';
|
|
13
16
|
import getComponentFromType from '../../Functions/getComponentFromType.js';
|
|
14
17
|
import UiGlobals from '../../UiGlobals.js';
|