@fto-consult/expo-ui 2.4.0 → 2.4.5

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,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "2.4.0",
3
+ "version": "2.4.5",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -7,15 +7,16 @@ import {MENU_ICON} from "$ecomponents/Icon";
7
7
  import theme,{Colors} from "$theme";
8
8
  import Group from "./GroupComponent";
9
9
  import Portal from "$ecomponents/Portal";
10
+ import Auth from "$cauth";
10
11
 
11
12
  const FabGroupComponent = React.forwardRef((props,innerRef)=>{
12
13
  let {openedIcon,screenName,display:customDisplay,primary,actionMutator,secondary,onOpen,prepareActions,fabStyle,open:customOpen,onClose,onStateChange:customOnStateChange,closedIcon,color,actions:customActions,children,...customRest} = props;
13
-
14
14
  const [state, setState] = React.useStateIfMounted({
15
15
  open: typeof customOpen =='boolean'? customOpen : false,
16
16
  display : typeof customDisplay ==='boolean'? customDisplay : true,
17
17
  });
18
18
  const onStateChange = ({ open,...rest}) => {
19
+ if(state.open == open) return;
19
20
  setState({ ...state,open });
20
21
  if(customOnStateChange){
21
22
  customOnStateChange({open,...rest})
@@ -52,6 +53,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
52
53
  color = theme.colors.secondaryText;
53
54
  }
54
55
  const actions = React.useCallback(()=>{
56
+ if(!open) return []
55
57
  const actions = prepareActions === false && Array.isArray(customActions)? customActions : [];
56
58
  if((prepareActions !== false || !actions.length)){
57
59
  Object.map(customActions,(act,i)=>{
@@ -62,6 +64,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
62
64
  a.small = typeof a.small =='boolean'? a.small : false;
63
65
  const {perm,isAllowed,primary,secondary,...restItem} = a;
64
66
  if(typeof isAllowed =='function' && isAllowed() === false) return null;
67
+ if(isNonNullString(perm) && !Auth.isAllowedFromStr(perm)) return false;
65
68
  if(primary){
66
69
  restItem.style = StyleSheet.flatten([restItem.style,{color:theme.colors.primaryText,backgroundColor:theme.colors.primary}])
67
70
  } else if(secondary){
@@ -72,7 +75,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
72
75
  });
73
76
  }
74
77
  return actions;
75
- },[customActions,prepareActions])();
78
+ },[customActions,prepareActions,open])();
76
79
 
77
80
  React.useEffect(()=>{
78
81
  React.setRef(innerRef,context);
@@ -85,7 +88,7 @@ const FabGroupComponent = React.forwardRef((props,innerRef)=>{
85
88
  {...rest}
86
89
  color = {color}
87
90
  style = {[rest.style,styles.container]}
88
- fabStyle = {[styles.fab,fabStyle,{backgroundColor},display?null: styles.hidden]}
91
+ fabStyle = {[styles.fab,fabStyle,{backgroundColor},!display && styles.hidden]}
89
92
  open={open ?true : false}
90
93
  icon={open ? openedIcon : closedIcon}
91
94
  actions={actions}
@@ -135,6 +138,12 @@ const styles = StyleSheet.create({
135
138
  },
136
139
  hidden : {
137
140
  display : 'none'
141
+ },
142
+ fab : {
143
+ position: 'absolute',
144
+ margin: 16,
145
+ right: 0,
146
+ bottom: 0,
138
147
  }
139
148
  })
140
149
 
@@ -13,6 +13,7 @@ import PropTypes from "prop-types";
13
13
  import { StylePropTypes } from '$theme';
14
14
  import Action from "$ecomponents/Form/Action";
15
15
  import { disabledStyle,cursorNotAllowed } from '$theme';
16
+ import {defaultStr} from "$utils";
16
17
 
17
18
 
18
19
 
@@ -181,7 +182,7 @@ const FABGroup = ({
181
182
  accessibilityComponentType="button"
182
183
  accessibilityRole="button"
183
184
  accessibilityState={{ expanded: open }}
184
- style={[styles.fab, fabStyle]}
185
+ style={StyleSheet.flatten([styles.fab, fabStyle])}
185
186
  visible={visible}
186
187
  testID={testID}
187
188
  />
@@ -278,8 +279,9 @@ FABGroup.propTypes = {
278
279
 
279
280
 
280
281
  export const FabItem = function(props){
281
- const {children,label,disabled:customDisabled,pointerEvents,open,close,testID,labelStyle,labelColor,accessibilityLabel,icon,backgroundColor,scale,opacity,color,style,small,onPress,...rest} = props;
282
+ const {children,label,disabled:customDisabled,pointerEvents,open,close,testID:customTestID,labelStyle,labelColor,accessibilityLabel,icon,backgroundColor,scale,opacity,color,style,small,onPress,...rest} = props;
282
283
  const disabled = typeof customDisabled =='boolean'? customDisabled : false;
284
+ const testID = defaultStr(customTestID,"RN_FabGroupComponent")
283
285
  const _onPress = ()=>{
284
286
  if(onPress){
285
287
  onPress();
@@ -289,8 +291,9 @@ export const FabItem = function(props){
289
291
  const dStyle = disabled ? disabledStyle : null;
290
292
  return <>
291
293
  {label ? (
292
- <View style={dStyle} pointerEvents={pointerEvents}>
294
+ <View testID = {testID+"_LabelContainer"} style={dStyle} pointerEvents={pointerEvents}>
293
295
  <Card
296
+ testID={testID+"_Card"}
294
297
  style={
295
298
  [
296
299
  styles.label,
@@ -311,7 +314,7 @@ export const FabItem = function(props){
311
314
  accessibilityComponentType="button"
312
315
  accessibilityRole="button"
313
316
  >
314
- <Text style={{ color : labelColor }}>
317
+ <Text testID={testID+"_Label"} style={{ color : labelColor }}>
315
318
  {label}
316
319
  </Text>
317
320
  </Card>
@@ -347,7 +350,7 @@ export const FabItem = function(props){
347
350
  accessibilityRole="button"
348
351
  testID={testID}
349
352
  visible={open}
350
- />
353
+ />
351
354
  </>
352
355
  }
353
356
 
@@ -11,7 +11,6 @@ import {sanitizeName} from "$escreens/utils";
11
11
  export * from "./utils";
12
12
 
13
13
  const FABContainer = React.forwardRef((props,ref)=>{
14
- return null;
15
14
  const {state,actions:customActions,screenName,...rest} = props;
16
15
  const sScreenName = sanitizeName(screenName);
17
16
  ref = ref || createFabRef(screenName);
@@ -55,6 +54,6 @@ const styles = StyleSheet.create({
55
54
  export default FABContainer;
56
55
 
57
56
  FABContainer.propTypes = {
58
- screenName : PropTypes.string.isRequired,
57
+ screenName : PropTypes.string,
59
58
  }
60
59
  FABContainer.displayName = "FABContainer";
@@ -83,9 +83,6 @@ export default function MainScreenScreenWithOrWithoutAuthContainer(props) {
83
83
  if(authRequired === false){
84
84
  withFab = false;
85
85
  }
86
- if(typeof withFab !=='boolean'){
87
- withFab = withDrawer;
88
- }
89
86
  React.useEffect(() => {
90
87
  if((title||subtitle) && navigation && navigation.setOptions){
91
88
  const appName = APP.getName().toUpperCase();
@@ -106,7 +103,7 @@ export default function MainScreenScreenWithOrWithoutAuthContainer(props) {
106
103
  }
107
104
  }, [title,subtitle]);
108
105
  const Wrapper = modal ? Portal : React.Fragment;
109
- const fab = withFab !== false ? <Fab
106
+ const fab = withFab ? <Fab
110
107
  {...fabProps}
111
108
  screenName={screenName}
112
109
  /> : null;