@fto-consult/expo-ui 7.21.0 → 7.22.0

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": "7.21.0",
3
+ "version": "7.22.0",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "scripts": {
6
6
  "clear-npx-cache": "npx clear-npx-cache",
@@ -3,7 +3,7 @@ import Dialog from "./Dialog";
3
3
  import { createProviderRef } from "$ecomponents/Dialog/Provider";
4
4
  import {isMobileOrTabletMedia} from "$cplatform/dimensions";
5
5
  import {MAX_WIDTH} from "$ecomponents/Dialog/utils";
6
- import {extendObj,defaultObj,isObj,defaultBool,defaultStr} from "$cutils";
6
+ import {extendObj,defaultObj,isObj,defaultBool,defaultStr,defaultVal} from "$cutils";
7
7
  import grid from "$theme/grid";
8
8
  import theme from "$theme";
9
9
  import {isDesktopMedia} from "$cdimensions";
@@ -11,6 +11,9 @@ import {isDesktopMedia} from "$cdimensions";
11
11
  let dialogProviderRef = null;
12
12
 
13
13
 
14
+ /*** l'on peut override par défaut l'action ok par les props ok|yes
15
+ l'on peut override par défaut l'acction cancel par les props closeAction|no
16
+ */
14
17
  const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
15
18
  innerRef = innerRef || createProviderRef((eRef)=>{
16
19
  dialogProviderRef = eRef;
@@ -59,22 +62,27 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
59
62
  isProvider
60
63
  ref={formRef}
61
64
  windowWidth = {MAX_WIDTH}
62
- propsMutator = {(rest)=>{
65
+ propsMutator = {({cancelButton,...rest})=>{
63
66
  const isMob = isMobileOrTabletMedia();
64
67
  if(closeAction === true || state.closeAction === true) return rest;
65
68
  rest.windowWidth = !isMob ? MAX_WIDTH : undefined;
69
+ const no = extendObj({},props.no,state.no);
66
70
  rest.actions = Array.isArray(rest.actions)? Object.clone(rest.actions) : isObj(rest.actions)? Object.clone(rest.actions) : null;
71
+ const closeAction = defaultObj(closeAction);
67
72
  rest.cancelButton = false;
68
- if(rest.actions && (!isMob || rest.fullScreen === false)){
73
+ if(cancelButton !== false && rest.actions && (!isMob || rest.fullScreen === false) && state.no !== false){
69
74
  if(isDesktopMedia() && typeof rest.maxActions !=='number'){
70
75
  rest.maxActions = 2;
71
76
  }
77
+ const noText = defaultVal(no.text,no.label,closeAction.text,closeAction.label,'Annuler')
72
78
  const closeBtn ={
73
- text : 'Annuler',
74
- icon : 'close',
79
+ ...closeAction,
80
+ ...no,
81
+ text : noText,
82
+ label : noText,
83
+ icon : defaultVal(no.icon,closeAction.icon,'close'),
75
84
  isCancelButton : true,
76
85
  error : true,
77
- ...defaultObj(closeAction),
78
86
  onPress : context.close,
79
87
  isAction : false,
80
88
  }
@@ -1,4 +1,4 @@
1
- import {isNonNullString,isObj,defaultObj,isPromise,isFunction,defaultStr,isObjOrArray,defaultFunc} from "$cutils";
1
+ import {isNonNullString,isObj,defaultObj,extendObj,defaultVal,isPromise,isFunction,defaultStr,isObjOrArray,defaultFunc} from "$cutils";
2
2
  import notify from "$notify";
3
3
  import { getFormData } from "../utils/FormsManager";
4
4
  import {isMobileBrowser,isMobileNative} from "$cplatform";
@@ -15,21 +15,25 @@ export const canHandleShurtCut = x=> !isMobileNative(true) && !isMobileBrowser()
15
15
 
16
16
  const canHandleS = canHandleShurtCut();
17
17
  export const getAppBarActionsProps = function(_props){
18
- let {actions,formName,save,cancel,actionMutator,saveButton,saveButtonIcon,data,style,...props} = defaultObj(_props);
18
+ let {actions,formName,save,cancel,actionMutator,saveButton,saveButtonIcon,data,style,yes,ok,...props} = defaultObj(_props);
19
19
  props = Object.assign({},props);
20
20
  cancel = defaultFunc(cancel);
21
21
  save = defaultFunc(save);
22
22
  saveButton = isNonNullString(saveButton)? saveButton : Object.size(data,true) > 0 && (isNonNullString(data.code) || isNonNullString(data._id))? "Modifier":'Enregister';
23
- saveButtonIcon = defaultStr(saveButtonIcon,'check')
23
+ saveButtonIcon = defaultStr(saveButtonIcon,'check');
24
+ const yesOk = extendObj({},yes,ok);
24
25
  if(typeof actions =='function'){
25
26
  actions = actions(props);
26
27
  }
27
- if(actions === undefined){
28
+ if(actions === undefined && yes !== false && ok !== false){
29
+ const yesOKText = defaultVal(yesOk.text,yesOk.label);
28
30
  actions = [{
29
31
  formName,
30
- text : saveButton,
31
- icon : saveButtonIcon,
32
32
  isAction: true,
33
+ ...yesOk,
34
+ text : yesOKText,
35
+ label: yesOKText,
36
+ icon : defaultVal(yesOk.icon,saveButtonIcon),
33
37
  }]
34
38
  } else {
35
39
  actions = (isObjOrArray(actions))?actions : [];