@fto-consult/expo-ui 5.11.14 → 5.11.16
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/electron/utils/parseArgs.js +18 -18
- package/package.json +4 -4
- package/src/App.js +9 -0
- package/src/components/AutoSizer/Vertical.js +9 -8
- package/src/components/Form/Fields/IDField.js +3 -2
- package/src/components/Form/FormData/FieldsContent.js +81 -0
- package/src/components/Form/FormData/FormData.js +16 -79
- package/src/components/HeavyScreen/index.js +6 -5
- package/src/components/Resizable/index.web.js +1 -3
- package/src/layouts/Screen/FormData/FormData.js +8 -10
- package/src/layouts/Screen/TableData.js +11 -16
- package/src/components/ScrollView/index copy.js +0 -38
- package/src/components/ScrollView/index.back.js +0 -84
- package/src/components/ScrollView/index.withWeb.js +0 -83
|
@@ -1,21 +1,21 @@
|
|
|
1
1
|
module.exports = (argv,supportedScript)=>{
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
if(!Array.isArray(argv)) {
|
|
3
|
+
argv = process.argv.slice(0);
|
|
4
|
+
}
|
|
5
|
+
const args = {};
|
|
6
|
+
supportedScript = typeof supportedScript =='object' && supportedScript || null;
|
|
7
|
+
argv.map(arg=>{
|
|
8
|
+
if(!arg || typeof arg != 'string') return;
|
|
9
|
+
arg = arg.trim();
|
|
10
|
+
if(supportedScript && arg in supportedScript){
|
|
11
|
+
args.script = arg;
|
|
12
|
+
} else if(arg.includes("=")){
|
|
13
|
+
const split = arg.split("=");
|
|
14
|
+
if(split.length !=2) return;
|
|
15
|
+
args[split[0].trim()] = split[1].trim();
|
|
16
|
+
} else {
|
|
17
|
+
args[arg] = true;
|
|
4
18
|
}
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
argv.map(arg=>{
|
|
8
|
-
if(!arg || typeof arg != 'string') return;
|
|
9
|
-
arg = arg.trim();
|
|
10
|
-
if(supportedScript && arg in supportedScript){
|
|
11
|
-
args.script = arg;
|
|
12
|
-
} else if(arg.includes("=")){
|
|
13
|
-
const split = arg.split("=");
|
|
14
|
-
if(split.length !=2) return;
|
|
15
|
-
args[split[0].trim()] = split[1].trim();
|
|
16
|
-
} else {
|
|
17
|
-
args[arg] = true;
|
|
18
|
-
}
|
|
19
|
-
})
|
|
20
|
-
return args;
|
|
19
|
+
});
|
|
20
|
+
return args;
|
|
21
21
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fto-consult/expo-ui",
|
|
3
|
-
"version": "5.11.
|
|
3
|
+
"version": "5.11.16",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -61,7 +61,7 @@
|
|
|
61
61
|
"@emotion/native": "^11.11.0",
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/vector-icons": "^13.0.0",
|
|
64
|
-
"@fto-consult/common": "^3.18.
|
|
64
|
+
"@fto-consult/common": "^3.18.27",
|
|
65
65
|
"@gorhom/portal": "^1.0.14",
|
|
66
66
|
"@react-native-async-storage/async-storage": "^1.17.11",
|
|
67
67
|
"@react-native-community/datetimepicker": "^6.7.3",
|
|
@@ -96,8 +96,8 @@
|
|
|
96
96
|
"react-native-gesture-handler": "~2.9.0",
|
|
97
97
|
"react-native-iphone-x-helper": "^1.3.1",
|
|
98
98
|
"react-native-mime-types": "^2.3.0",
|
|
99
|
-
"react-native-paper": "^5.
|
|
100
|
-
"react-native-paper-dates": "^0.
|
|
99
|
+
"react-native-paper": "^5.9.0",
|
|
100
|
+
"react-native-paper-dates": "^0.18.12",
|
|
101
101
|
"react-native-reanimated": "~2.14.4",
|
|
102
102
|
"react-native-safe-area-context": "^4.5.3",
|
|
103
103
|
"react-native-screens": "^3.20.0",
|
package/src/App.js
CHANGED
|
@@ -18,12 +18,21 @@ import { timeout as SWR_REFRESH_TIMEOUT} from '$ecomponents/Datagrid/SWRDatagrid
|
|
|
18
18
|
import { Dimensions,Keyboard } from 'react-native';
|
|
19
19
|
import {isTouchDevice} from "$platform";
|
|
20
20
|
import * as Utils from "$cutils";
|
|
21
|
+
import {extendObj} from "$utils";
|
|
22
|
+
import {fontConfig} from "$theme/fonts";
|
|
23
|
+
|
|
24
|
+
import { configureFonts} from 'react-native-paper';
|
|
21
25
|
Object.map(Utils,(v,i)=>{
|
|
22
26
|
if(typeof v =='function' && typeof window !='undefined' && window && !window[i]){
|
|
23
27
|
window[i] = v;
|
|
24
28
|
}
|
|
25
29
|
});
|
|
26
30
|
export default function getIndex({onMount,onUnmount,swrConfig,onRender,...rest}){
|
|
31
|
+
const {extendAppTheme} = appConfig;
|
|
32
|
+
appConfig.extendAppTheme = (theme)=>{
|
|
33
|
+
extendObj(theme,{fonts:configureFonts({config:fontConfig,isV3:true})});
|
|
34
|
+
return typeof extendAppTheme == 'function'? extendAppTheme(theme) : theme;
|
|
35
|
+
}
|
|
27
36
|
const isScreenFocusedRef = React.useRef(true);
|
|
28
37
|
///garde pour chaque écran sa date de dernière activité
|
|
29
38
|
const screensRef = React.useRef({});//la liste des écrans actifs
|
|
@@ -6,7 +6,6 @@ import theme from "$theme";
|
|
|
6
6
|
import {defaultStr,defaultObj,defaultNumber} from "$cutils";
|
|
7
7
|
import APP from "$capp/instance";
|
|
8
8
|
import ActivityIndicator from "$ecomponents/ActivityIndicator";
|
|
9
|
-
import {isWeb} from "$cplatform";
|
|
10
9
|
|
|
11
10
|
/***
|
|
12
11
|
* ce composant a pour but de définir la taille d'un contenu en se basant sur sa positin top, de manière à ce que, le contentu du composant fit
|
|
@@ -37,20 +36,22 @@ const AutoSizerVerticalComponent = React.forwardRef(({onLayout,isScrollView,scre
|
|
|
37
36
|
})
|
|
38
37
|
}
|
|
39
38
|
React.setRef(ref,{
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
});
|
|
39
|
+
updateLayout,
|
|
40
|
+
layoutRef,
|
|
41
|
+
ref : layoutRef
|
|
42
|
+
});
|
|
44
43
|
React.useEffect(()=>{
|
|
45
44
|
const onResizePage = ()=>{
|
|
46
45
|
setTimeout(()=>{
|
|
47
46
|
updateLayout();
|
|
48
|
-
},
|
|
47
|
+
},500);
|
|
49
48
|
}
|
|
50
|
-
|
|
49
|
+
const dim = Dimensions.addEventListener("change",onResizePage);
|
|
50
|
+
//APP.on(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
51
51
|
return ()=>{
|
|
52
|
-
APP.off(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
52
|
+
//APP.off(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
53
53
|
React.setRef(ref,null);
|
|
54
|
+
dim?.remove();
|
|
54
55
|
}
|
|
55
56
|
},[]);
|
|
56
57
|
const hasUpdateLayout = hasUpdateLayoutRef.current;
|
|
@@ -72,12 +72,13 @@ export default class FormIDField extends TextField {
|
|
|
72
72
|
}
|
|
73
73
|
_render(props,setRef){
|
|
74
74
|
delete props.validType;
|
|
75
|
+
const upper = props.upper !== false ? UPPER_CASE : "";
|
|
75
76
|
if(isNonNullString(this.name) && isObj(props.data) && isNonNullString(props.data[this.name])){
|
|
76
77
|
props.disabled = true;
|
|
77
|
-
props.validType =
|
|
78
|
+
props.validType = upper;
|
|
78
79
|
props.defaultValue = props.data[this.name];
|
|
79
80
|
} else {
|
|
80
|
-
props.validType = 'required|'+
|
|
81
|
+
props.validType = 'required|'+upper;
|
|
81
82
|
}
|
|
82
83
|
if(typeof props.minLength !=='number'){
|
|
83
84
|
props.minLength = 2;
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import React from "$react";
|
|
2
|
+
import Divider from "$components/Divider";
|
|
3
|
+
import {isObj,isNonNullString,defaultStr,defaultObj} from "$utils";
|
|
4
|
+
import getComponentFromType from "./componentsTypes";
|
|
5
|
+
import appConfig from "$capp/config";
|
|
6
|
+
import {flattenStyle,Colors} from "$theme";
|
|
7
|
+
|
|
8
|
+
export default function FieldsContent({fields,formName,disabled,archived,archivable,fieldProps,primaryKeyFields,responsiveProps,responsive,style,data,windowWidth}){
|
|
9
|
+
windowWidth = typeof windowWidth ==='number' && windowWidth > 100?windowWidth : undefined;
|
|
10
|
+
return React.useStableMemo(()=>{
|
|
11
|
+
const content = [];
|
|
12
|
+
style = defaultObj(flattenStyle(style));
|
|
13
|
+
primaryKeyFields = Array.isArray(primaryKeyFields) ? primaryKeyFields: [];
|
|
14
|
+
fieldProps = defaultObj(fieldProps);
|
|
15
|
+
Object.map(fields,(field,index,i)=>{//on ignore tous les champs supposés être à ignorer
|
|
16
|
+
if(field === 'divider'){
|
|
17
|
+
content.push(<Divider key = {index} style={theme.styles.w100}/>)
|
|
18
|
+
} else if(isObj(field) && field.form !== false) {
|
|
19
|
+
const name = defaultStr(field.name,field.field,index);
|
|
20
|
+
const type = defaultStr(field.jsType,field.type,"text").trim().toLowerCase().replaceAll(" ","").replaceAll("-","").replaceAll("_","");
|
|
21
|
+
const isDate = (type.contains('date') || type.contains('time'));
|
|
22
|
+
const Component = getComponentFromType(defaultStr(field.jsType,field.type,"text"));
|
|
23
|
+
let {defaultValue,useDefaultValueFromData,primaryKey,hidden,renderFormDataField,getMediaQueryStyle,printLabels,queryLimit,selected,value,dataFilesInterest,perm,ignore,form,responsiveProps:customResponsiveProps,...rest} = field;
|
|
24
|
+
delete rest.import;
|
|
25
|
+
delete rest.export;
|
|
26
|
+
if(primaryKey === true && name && !field.filter){
|
|
27
|
+
primaryKeyFields[name] = field;
|
|
28
|
+
}
|
|
29
|
+
if(form === false || ignore || (isNonNullString(perm) && !Auth.isAllowedFromStr(perm))){
|
|
30
|
+
return null;
|
|
31
|
+
}
|
|
32
|
+
if(rest.nullable === false){
|
|
33
|
+
rest.required = true;
|
|
34
|
+
}
|
|
35
|
+
if(primaryKey === true && typeof rest.required !=='boolean'){
|
|
36
|
+
rest.required = true;
|
|
37
|
+
}
|
|
38
|
+
if(typeof rest.filter !=='function'){
|
|
39
|
+
delete rest.filter;
|
|
40
|
+
}
|
|
41
|
+
if(name){
|
|
42
|
+
rest.defaultValue = useDefaultValueFromData === false ? defaultValue : (name in data && data[name] !== undefined && data[name] !== null? data[name]: defaultValue);
|
|
43
|
+
if((type == 'selecttabledata' || type == 'datafile')){
|
|
44
|
+
rest._defaultValue = data[rest.name];
|
|
45
|
+
}
|
|
46
|
+
} else {
|
|
47
|
+
rest.defaultValue = defaultValue;
|
|
48
|
+
}
|
|
49
|
+
if(rest.defaultValue === null){
|
|
50
|
+
rest.defaultValue = undefined;
|
|
51
|
+
}
|
|
52
|
+
// les champs de type date par défaut qui sont requis, auront comme valeur par défaut la date actuelle s'il ne sont pas définies
|
|
53
|
+
if(rest.autoSetDefaultValue !== false && (!rest.defaultValue && typeof rest.defaultValue !=='boolean' && typeof rest.defaultValue !=='number')){
|
|
54
|
+
if(isDate && rest.required === true ){
|
|
55
|
+
rest.defaultValue = new Date();
|
|
56
|
+
} else if(!isDate && isNonNullString(rest.appConfigDefaultValueKey)){
|
|
57
|
+
rest.defaultValue = appConfig.get(rest.appConfigDefaultValueKey);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
customResponsiveProps = defaultObj(customResponsiveProps);
|
|
61
|
+
content.push(<Component
|
|
62
|
+
data = {data}
|
|
63
|
+
windowWidth = {windowWidth}
|
|
64
|
+
index = {index}
|
|
65
|
+
disabled = {disabled || archived}
|
|
66
|
+
archived = {archived}
|
|
67
|
+
{...fieldProps}
|
|
68
|
+
{...rest}
|
|
69
|
+
style = {[fieldProps.style,Colors.isValid(style.backgroundColor) && {backgroundColor:style.backgroundColor},rest.style]}
|
|
70
|
+
formName = {formName}
|
|
71
|
+
key={index}
|
|
72
|
+
archivable = {archivable}
|
|
73
|
+
name = {name}
|
|
74
|
+
responsive = {responsive}
|
|
75
|
+
responsiveProps = {{...responsiveProps,...customResponsiveProps,style:[responsiveProps.style,customResponsiveProps.style]}}
|
|
76
|
+
/>);
|
|
77
|
+
}
|
|
78
|
+
});
|
|
79
|
+
return content;
|
|
80
|
+
},[formName,archived,archivable,disabled,fields,data,windowWidth,responsive,responsiveProps])
|
|
81
|
+
}
|
|
@@ -10,9 +10,8 @@ import PropTypes from "prop-types";
|
|
|
10
10
|
import {renderActions} from "$ecomponents/Dialog/utils";
|
|
11
11
|
import {handleBeforeSaveCallback} from "./utils";
|
|
12
12
|
import isDbDocEditing,{checkPrimaryKey} from "../utils/isDocEditing";
|
|
13
|
-
import getComponentFromType from "./componentsTypes";
|
|
14
13
|
import keyboardShortcuts from "../utils/keyboardShortcuts";
|
|
15
|
-
import
|
|
14
|
+
import FieldsContent from "./FieldsContent";
|
|
16
15
|
|
|
17
16
|
export default class FormDataComponent extends AppComponent{
|
|
18
17
|
constructor(props){
|
|
@@ -182,85 +181,23 @@ export default class FormDataComponent extends AppComponent{
|
|
|
182
181
|
}
|
|
183
182
|
getFieldsContent = (formProps)=>{
|
|
184
183
|
formProps = defaultObj(formProps);
|
|
185
|
-
const fieldProps = defaultObj(formProps.fieldProps,this.props.fieldProps);
|
|
186
|
-
formProps.style = flattenStyle(formProps.style);
|
|
187
184
|
this.formDataPrimaryKeyFields = {};
|
|
188
|
-
const content = [];
|
|
189
|
-
const fields = defaultObj(formProps.fields,this.props.fields);
|
|
190
185
|
const data = isObj(formProps.data) ? formProps.data : typeof this.props.data =='object' && this.props.data ? this.props.data : {};
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
delete rest.export;
|
|
207
|
-
if(primaryKey === true && name && !field.filter){
|
|
208
|
-
this.formDataPrimaryKeyFields[name] = field;
|
|
209
|
-
}
|
|
210
|
-
if(form === false || ignore || (isNonNullString(perm) && !Auth.isAllowedFromStr(perm))){
|
|
211
|
-
return null;
|
|
212
|
-
}
|
|
213
|
-
if(rest.nullable === false){
|
|
214
|
-
rest.required = true;
|
|
215
|
-
}
|
|
216
|
-
if(primaryKey === true && typeof rest.required !=='boolean'){
|
|
217
|
-
rest.required = true;
|
|
218
|
-
}
|
|
219
|
-
if(typeof rest.filter !=='function'){
|
|
220
|
-
delete rest.filter;
|
|
221
|
-
}
|
|
222
|
-
if(name){
|
|
223
|
-
rest.defaultValue = useDefaultValueFromData === false ? defaultValue : (name in data && data[name] !== undefined && data[name] !== null? data[name]: defaultValue);
|
|
224
|
-
if((type == 'selecttabledata' || type == 'datafile')){
|
|
225
|
-
rest._defaultValue = data[rest.name];
|
|
226
|
-
}
|
|
227
|
-
} else {
|
|
228
|
-
rest.defaultValue = defaultValue;
|
|
229
|
-
}
|
|
230
|
-
if(rest.defaultValue === null){
|
|
231
|
-
rest.defaultValue = undefined;
|
|
232
|
-
}
|
|
233
|
-
// les champs de type date par défaut qui sont requis, auront comme valeur par défaut la date actuelle s'il ne sont pas définies
|
|
234
|
-
if(rest.autoSetDefaultValue !== false && (!rest.defaultValue && typeof rest.defaultValue !=='boolean' && typeof rest.defaultValue !=='number')){
|
|
235
|
-
if(isDate && rest.required === true ){
|
|
236
|
-
rest.defaultValue = new Date();
|
|
237
|
-
} else if(!isDate && isNonNullString(rest.appConfigDefaultValueKey)){
|
|
238
|
-
rest.defaultValue = appConfig.get(rest.appConfigDefaultValueKey);
|
|
239
|
-
}
|
|
240
|
-
}
|
|
241
|
-
customResponsiveProps = defaultObj(customResponsiveProps);
|
|
242
|
-
content.push(<Component
|
|
243
|
-
data = {data}
|
|
244
|
-
windowWidth = {windowWidth}
|
|
245
|
-
//withBottomSheet = {this.props.withBottomSheet}
|
|
246
|
-
index = {index}
|
|
247
|
-
disabled = {this.props.disabled || archived}
|
|
248
|
-
archived = {this.props.archived || archived}
|
|
249
|
-
//ignoreFields = {ignoreFields}
|
|
250
|
-
//getFieldProps = {this.props.getFieldProps}
|
|
251
|
-
{...fieldProps}
|
|
252
|
-
{...rest}
|
|
253
|
-
style = {[fieldProps.style,formProps.style.backgroundColor&& {backgroundColor:formProps.style.backgroundColor},rest.style]}
|
|
254
|
-
formName = {this.getFormName()}
|
|
255
|
-
key={index}
|
|
256
|
-
archivable = {this.props.archivable || this.isArchivable()}
|
|
257
|
-
name = {name}
|
|
258
|
-
responsive = {responsive}
|
|
259
|
-
responsiveProps = {{...responsiveProps,...customResponsiveProps,style:[responsiveProps.style,customResponsiveProps.style]}}
|
|
260
|
-
/>);
|
|
261
|
-
}
|
|
262
|
-
});
|
|
263
|
-
return content;
|
|
186
|
+
return <FieldsContent
|
|
187
|
+
{...formProps}
|
|
188
|
+
fields = {defaultObj(formProps.fields,this.props.fields)}
|
|
189
|
+
fieldProps = {defaultObj(formProps.fieldProps,this.props.fieldProps)}
|
|
190
|
+
style = {flattenStyle(formProps.style)}
|
|
191
|
+
data = {data}
|
|
192
|
+
responsive = {typeof formProps.responsive =='boolean' ? formProps.responsive : this.props.responsive !== false ? true : false}
|
|
193
|
+
responsiveProps = {extendObj({},this.props.responsiveProps,formProps.responsiveProps)}
|
|
194
|
+
windowWidth = {defaultNumber(formProps.windowWidth,this.props.windowWidth) || undefined}
|
|
195
|
+
primaryKeyFields = {this.formDataPrimaryKeyFields}
|
|
196
|
+
formName = {this.getFormName()}
|
|
197
|
+
disabled = {this.props.disabled}
|
|
198
|
+
archived = {this.props.archived || data?.archived && true || false}
|
|
199
|
+
archivable = {this.props.archivable || this.isArchivable()}
|
|
200
|
+
/>
|
|
264
201
|
}
|
|
265
202
|
getActions (){
|
|
266
203
|
return renderActions(this.getAppBarActionsProps());
|
|
@@ -6,12 +6,10 @@ import { StylePropTypes } from '$theme';
|
|
|
6
6
|
import {isNumber,defaultStr} from "$cutils";
|
|
7
7
|
|
|
8
8
|
const OptimizedHeavyScreen = React.forwardRef(({
|
|
9
|
-
transition = (
|
|
10
|
-
<Transition.Together>
|
|
9
|
+
transition = (<Transition.Together>
|
|
11
10
|
<Transition.Change interpolation="easeInOut" />
|
|
12
11
|
<Transition.In type="fade" />
|
|
13
|
-
</Transition.Together>
|
|
14
|
-
),
|
|
12
|
+
</Transition.Together>),
|
|
15
13
|
style,
|
|
16
14
|
children:cChildren,
|
|
17
15
|
isLoading,
|
|
@@ -19,11 +17,13 @@ const OptimizedHeavyScreen = React.forwardRef(({
|
|
|
19
17
|
testID,
|
|
20
18
|
transitionTimeout,
|
|
21
19
|
placeholder,
|
|
20
|
+
enabled,
|
|
22
21
|
},ref) => {
|
|
23
22
|
timeout = isNumber(timeout)? timeout : isNumber(transitionTimeout)? transitionTimeout : undefined;
|
|
24
23
|
const { transitionRef, areInteractionsComplete } = useAfterInteractions(timeout);
|
|
25
24
|
let Placeholder = placeholder;
|
|
26
|
-
const children = React.useStableMemo(()=>cChildren,[cChildren])
|
|
25
|
+
const children = React.useStableMemo(()=>cChildren,[cChildren]);
|
|
26
|
+
if(enabled === false) return children;
|
|
27
27
|
placeholder = React.isComponent(Placeholder)? <Placeholder /> : React.isValidElement(Placeholder)? Placeholder : null;
|
|
28
28
|
return (
|
|
29
29
|
<Transitioning.View
|
|
@@ -42,6 +42,7 @@ export default OptimizedHeavyScreen;
|
|
|
42
42
|
OptimizedHeavyScreen.propTypes = {
|
|
43
43
|
transition: PropTypes.any,
|
|
44
44
|
children : PropTypes.node,
|
|
45
|
+
enabled : PropTypes.bool,//if heavry screen will be enabled
|
|
45
46
|
style: StylePropTypes,
|
|
46
47
|
timeout : PropTypes.number,
|
|
47
48
|
transitionTimeout : PropTypes.number,
|
|
@@ -57,22 +57,20 @@ export default class FormDataLayout extends FormDataActions {
|
|
|
57
57
|
return !!(this.props.isLoading)
|
|
58
58
|
}
|
|
59
59
|
wrapRenderingContent(content,wProps){
|
|
60
|
-
|
|
60
|
+
const {
|
|
61
61
|
withHeavyScreen,
|
|
62
62
|
preloader,
|
|
63
63
|
preloaderProps,
|
|
64
|
-
testID,
|
|
65
64
|
} = this.props;
|
|
66
65
|
const isLoading = this.isLoading();
|
|
67
66
|
wProps = defaultObj(wProps);
|
|
68
|
-
const
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
</Wrapper>
|
|
67
|
+
const testID = defaultStr(wProps.testID,this.props.testID,"RN_FormDataScren");
|
|
68
|
+
return <HeavyScreen {...wProps}
|
|
69
|
+
testID={testID+"_HeavyScreen"}
|
|
70
|
+
placeholder={React.isValidElement(preloader)? preloader : <FormLoader {...defaultObj(preloaderProps)}/>}
|
|
71
|
+
enabled={(withHeavyScreen === false)?false:isLoading}
|
|
72
|
+
isLoading={isLoading}
|
|
73
|
+
>{content}</HeavyScreen>
|
|
76
74
|
}
|
|
77
75
|
_render (content){
|
|
78
76
|
const {testID,...props} = this.props;
|
|
@@ -89,7 +89,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
89
89
|
}
|
|
90
90
|
});
|
|
91
91
|
Object.defineProperties(this,{
|
|
92
|
-
INITIAL_STATE : {value : {}},
|
|
93
92
|
tableName : { value : defaultStr(table.table,table.tableName)},
|
|
94
93
|
fields : {value : fields},
|
|
95
94
|
table : {value : table},
|
|
@@ -120,11 +119,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
120
119
|
isCurrentDocEditingUpdate(){
|
|
121
120
|
return this.isDocEditingRef.current === true ? true : false;
|
|
122
121
|
}
|
|
123
|
-
|
|
124
|
-
Object.map(this.INITIAL_STATE,(s,k)=>{
|
|
125
|
-
delete this.INITIAL_STATE[k];
|
|
126
|
-
})
|
|
127
|
-
}
|
|
122
|
+
|
|
128
123
|
getDatas(){
|
|
129
124
|
return this.state.datas;
|
|
130
125
|
}
|
|
@@ -175,13 +170,15 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
175
170
|
*/
|
|
176
171
|
prepareComponentProps(props){
|
|
177
172
|
const obj = typeof this.props.prepareComponentProps =='function'? this.props.prepareComponentProps(props) : null;
|
|
178
|
-
if(isObj(obj)){
|
|
173
|
+
if(isObj(obj) && Object.size(obj,true)){
|
|
179
174
|
return extendObj({},props,obj);
|
|
180
175
|
}
|
|
181
176
|
return props;
|
|
182
177
|
}
|
|
178
|
+
getSessionName (){
|
|
179
|
+
return defaultStr(this.props.sessionName,"table-form-data"+this.getTableName())
|
|
180
|
+
}
|
|
183
181
|
getComponentProps(props){
|
|
184
|
-
this.resetState();
|
|
185
182
|
const table = this.table;
|
|
186
183
|
const {datas,currentIndex,data} = this.state;
|
|
187
184
|
const tableName = this.tableName;
|
|
@@ -189,8 +186,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
189
186
|
this.isDocEditingRef.current = !!isUpdated;
|
|
190
187
|
const isMobOrTab = isMobileOrTabletMedia();
|
|
191
188
|
let archived = this.isArchived();
|
|
192
|
-
this.INITIAL_STATE.archived = archived;
|
|
193
|
-
this.INITIAL_STATE.tableName = tableName;
|
|
194
189
|
const fields = {};
|
|
195
190
|
const fieldsToPrepare = extendObj({},true,this.fields,customFields);
|
|
196
191
|
const {
|
|
@@ -224,7 +219,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
224
219
|
prepareComponentProps,
|
|
225
220
|
...rest
|
|
226
221
|
} = this.prepareComponentProps({...props,tableName,fields:fieldsToPrepare,isUpdated,isUpdate:isUpdated,data,datas,currentIndex});
|
|
227
|
-
const sessionName = this.
|
|
222
|
+
const sessionName = this.getSessionName();
|
|
228
223
|
const prepareCb = typeof prepareField =='function'? prepareField : x=> x;
|
|
229
224
|
///on effectue une mutator sur le champ en cours de modification
|
|
230
225
|
Object.map(fieldsToPrepare,(field,i,counterIndex)=>{
|
|
@@ -386,7 +381,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
386
381
|
if(!isMobileOrTabletMedia()){
|
|
387
382
|
tabsProps.withScrollView = false;
|
|
388
383
|
}
|
|
389
|
-
},isMobile,sessionName:this.
|
|
384
|
+
},isMobile,sessionName:this.getSessionName(),props:restProps,tabProps,tabsProps,context,tabKey};
|
|
390
385
|
const hasTabs = Object.size(tabs,true);
|
|
391
386
|
let mainContent = undefined;
|
|
392
387
|
testID = defaultStr(testID,"RN_TableDataScreenItem_"+restProps.tableName);
|
|
@@ -453,7 +448,7 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
453
448
|
}
|
|
454
449
|
isArchived(data){
|
|
455
450
|
data = defaultObj(data,this.state.data);
|
|
456
|
-
return this.isArchivable() && this.isDocEditing(data) && (!!data.archived || !!data.wasTransferred)? true : !!this.
|
|
451
|
+
return this.isArchivable() && this.isDocEditing(data) && (!!data.archived || !!data.wasTransferred)? true : !!this.props.archived || false;
|
|
457
452
|
}
|
|
458
453
|
goToPreviousData(){
|
|
459
454
|
const currentIndex = this.getCurrentIndex(),datas = this.state.datas;
|
|
@@ -790,9 +785,9 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
|
790
785
|
copyToClipboard(){
|
|
791
786
|
return copyToClipboard({
|
|
792
787
|
data : this.getCurrentData(),
|
|
793
|
-
fields : this.
|
|
794
|
-
sessionName : this.
|
|
795
|
-
})
|
|
788
|
+
fields : this.getCurrentRenderingProps()?.fields,
|
|
789
|
+
sessionName : this.getSessionName(),
|
|
790
|
+
});
|
|
796
791
|
}
|
|
797
792
|
renderDatagridActions(args){
|
|
798
793
|
args = defaultObj(args);
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import React from '$react';
|
|
2
|
-
import { ScrollView} from 'react-native';
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import {defaultStr,defaultObj} from "$cutils";
|
|
5
|
-
import {Vertical as AutoSizeVertical} from "$ecomponents/AutoSizer";
|
|
6
|
-
|
|
7
|
-
const ScrollViewComponent = React.forwardRef(({withAutoSizer,autoSizerProps,testID,...rest},ref) => {
|
|
8
|
-
testID = defaultStr(testID,'RN_ScrollViewComponent');
|
|
9
|
-
const autoSize = React.useRef(withAutoSizer).current;
|
|
10
|
-
if(!autoSize || rest.horizontal === true || rest.vertical === false){
|
|
11
|
-
return <ScrollView testID={testID} ref={ref} {...rest}/>
|
|
12
|
-
}
|
|
13
|
-
autoSizerProps = defaultObj(autoSizerProps);
|
|
14
|
-
const autoSizeRef = React.useRef(null);
|
|
15
|
-
return <AutoSizeVertical {...autoSizerProps} ref = {autoSizeRef} testID={testID+"_ScrollViewContainer"}>
|
|
16
|
-
<ScrollView
|
|
17
|
-
ref={ref}
|
|
18
|
-
{...rest}
|
|
19
|
-
testID={testID}
|
|
20
|
-
onContentSizeChange = {(a,b,c,d)=>{
|
|
21
|
-
if(rest.onContentSizeChange && rest.onContentSizeChange(a,b,c,d)===false) return;
|
|
22
|
-
if(autoSizeRef.current && autoSizeRef.current.updateLayout){
|
|
23
|
-
return autoSizeRef.current.updateLayout();
|
|
24
|
-
}
|
|
25
|
-
}}
|
|
26
|
-
/>
|
|
27
|
-
</AutoSizeVertical>
|
|
28
|
-
});
|
|
29
|
-
|
|
30
|
-
ScrollViewComponent.displayName = "ScrollViewComponent";
|
|
31
|
-
export default ScrollViewComponent;
|
|
32
|
-
|
|
33
|
-
ScrollViewComponent.propTypes = {
|
|
34
|
-
...defaultObj(ScrollView.propTypes),
|
|
35
|
-
withAutoSizer : PropTypes.bool,//si le contenu du scrollView sera wrap par le composant AutoSizer
|
|
36
|
-
maxHeight : PropTypes.number,
|
|
37
|
-
minHeight : PropTypes.number,
|
|
38
|
-
}
|
|
@@ -1,84 +0,0 @@
|
|
|
1
|
-
import React from '$react';
|
|
2
|
-
import { ScrollView,Dimensions} from 'react-native';
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import View from "$ecomponents/View";
|
|
5
|
-
import theme from "$theme";
|
|
6
|
-
import {defaultStr,defaultObj,defaultNumber} from "$cutils";
|
|
7
|
-
import APP from "$capp/instance";
|
|
8
|
-
import ActivityIndicator from "$ecomponents/ActivityIndicator";
|
|
9
|
-
const ScrollViewComponent = React.forwardRef(({withAutoSizer,containerProps,maxHeight,minHeight,testID:customTestID,children:cChildren,...rest},ref) => {
|
|
10
|
-
const testID = defaultStr(customTestID,'RN_ScrollViewComponent');
|
|
11
|
-
const autoSizeRef = React.useRef(withAutoSizer);
|
|
12
|
-
if(!autoSizeRef.current || rest.horizontal === true || rest.vertical === false){
|
|
13
|
-
return <ScrollView testID={testID} ref={ref} {...rest} children={cChildren}/>
|
|
14
|
-
}
|
|
15
|
-
containerProps = defaultObj(containerProps)
|
|
16
|
-
const hasUpdateLayoutRef = React.useRef(false);
|
|
17
|
-
const isKeyboardOpenRef = React.useRef(false);
|
|
18
|
-
const layoutRef = React.useRef(null);
|
|
19
|
-
const [layout,setLayout] = React.useState(Dimensions.get("window"));
|
|
20
|
-
const {height} = layout;
|
|
21
|
-
const hasInitializedRef = React.useRef(false);
|
|
22
|
-
const children = React.useStableMemo(()=>cChildren,[cChildren]);
|
|
23
|
-
const updateLayout = ()=>{
|
|
24
|
-
return new Promise((resolve)=>{
|
|
25
|
-
hasUpdateLayoutRef.current = true;
|
|
26
|
-
if(layoutRef.current && layoutRef.current.measureInWindow){
|
|
27
|
-
layoutRef.current.measureInWindow((x, y, width, height) => {
|
|
28
|
-
const r = {...Dimensions.get("window"),layout:{ x, y, width, height }};
|
|
29
|
-
setLayout(r);
|
|
30
|
-
hasInitializedRef.current = true;
|
|
31
|
-
resolve(r);
|
|
32
|
-
});
|
|
33
|
-
} else {
|
|
34
|
-
setLayout(Dimensions.get("window"))
|
|
35
|
-
}
|
|
36
|
-
})
|
|
37
|
-
}
|
|
38
|
-
React.useEffect(()=>{
|
|
39
|
-
const onKeyboardToggle = ({visible})=>{
|
|
40
|
-
isKeyboardOpenRef.current = visible;
|
|
41
|
-
};
|
|
42
|
-
const onResizePage = ()=>{
|
|
43
|
-
setTimeout(()=>{
|
|
44
|
-
if(isKeyboardOpenRef.current) return;
|
|
45
|
-
updateLayout();
|
|
46
|
-
},300);
|
|
47
|
-
}
|
|
48
|
-
APP.on(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
49
|
-
APP.on(APP.EVENTS.KEYBOARD_DID_TOGGLE,onKeyboardToggle)
|
|
50
|
-
return ()=>{
|
|
51
|
-
APP.off(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
52
|
-
APP.off(APP.EVENTS.KEYBOARD_DID_TOGGLE,onKeyboardToggle);
|
|
53
|
-
}
|
|
54
|
-
},[]);
|
|
55
|
-
const hasUpdateLayout = hasUpdateLayoutRef.current;
|
|
56
|
-
const cStyle ={width:'100%',maxHeight:Math.max(height-100,250)};
|
|
57
|
-
const contentLayout = defaultObj(layout.layout);
|
|
58
|
-
cStyle.minHeight = Math.min(Math.max(layout.height-defaultNumber(contentLayout.y),250));
|
|
59
|
-
const contentContainerStyle = ([cStyle,rest.contentContainerStyle]);
|
|
60
|
-
const fStyle = !hasUpdateLayout && {flex:1,maxWidth:layout.width - defaultNumber(contentLayout.x)};
|
|
61
|
-
return <View ref={layoutRef} onLayout={()=>{
|
|
62
|
-
if(!hasInitializedRef.current){
|
|
63
|
-
updateLayout();
|
|
64
|
-
}
|
|
65
|
-
}} {...containerProps} style={[theme.styles.w100,containerProps.style,fStyle]} testID={testID+"_ScrollViewContainer"}>
|
|
66
|
-
<ScrollView
|
|
67
|
-
ref={ref} {...rest}
|
|
68
|
-
testID={testID}
|
|
69
|
-
children={hasUpdateLayout?children : <ActivityIndicator size={'large'}
|
|
70
|
-
style={[{flex:1}]}/>}
|
|
71
|
-
contentContainerStyle = {[contentContainerStyle,fStyle]}
|
|
72
|
-
/>
|
|
73
|
-
</View>
|
|
74
|
-
});
|
|
75
|
-
|
|
76
|
-
ScrollViewComponent.displayName = "ScrollViewComponent";
|
|
77
|
-
export default ScrollViewComponent;
|
|
78
|
-
|
|
79
|
-
ScrollViewComponent.propTypes = {
|
|
80
|
-
...defaultObj(ScrollView.propTypes),
|
|
81
|
-
withAutoSizer : PropTypes.bool,//si la taille du scrollView sera withAutoSizer
|
|
82
|
-
maxHeight : PropTypes.number,
|
|
83
|
-
minHeight : PropTypes.number,
|
|
84
|
-
}
|
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
import React from '$react';
|
|
2
|
-
import { ScrollView,Dimensions } from 'react-native';
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
import View from "$ecomponents/View";
|
|
5
|
-
import theme from "$theme";
|
|
6
|
-
import {defaultStr,defaultObj} from "$cutils";
|
|
7
|
-
import APP from "$capp/instance";
|
|
8
|
-
import {isWeb as isw} from "$cplatform";
|
|
9
|
-
const ScrollViewComponent = React.forwardRef(({containerProps,withAutoSizer,testID,...rest},ref) => {
|
|
10
|
-
testID = defaultStr(testID,'RN_ScrollViewComponent');
|
|
11
|
-
const autoSize = React.useRef(withAutoSizer).current;
|
|
12
|
-
if(!autoSize || rest.horizontal === true || rest.vertical === false){
|
|
13
|
-
return <ScrollView testID={testID} ref={ref} {...rest}/>
|
|
14
|
-
}
|
|
15
|
-
containerProps = defaultObj(containerProps)
|
|
16
|
-
const isWeb = isw();
|
|
17
|
-
const isKeyboardOpenRef = React.useRef(false);
|
|
18
|
-
const layoutRef = React.useRef(null);
|
|
19
|
-
const [layout,setLayout] = React.useState(Dimensions.get("window"));
|
|
20
|
-
const {height} = layout;
|
|
21
|
-
const hasInitializedRef = React.useRef(false);
|
|
22
|
-
const children = React.useStableMemo(()=>rest.children,[rest.children]);
|
|
23
|
-
const updateLayout = ()=>{
|
|
24
|
-
return new Promise((resolve)=>{
|
|
25
|
-
if(layoutRef.current && layoutRef.current.measureInWindow){
|
|
26
|
-
layoutRef.current.measureInWindow((x, y, width, height) => {
|
|
27
|
-
const r = {...Dimensions.get("window"),layout:{ x, y, width, height }};
|
|
28
|
-
setLayout(r);
|
|
29
|
-
hasInitializedRef.current = true;
|
|
30
|
-
resolve(r);
|
|
31
|
-
});
|
|
32
|
-
}
|
|
33
|
-
})
|
|
34
|
-
}
|
|
35
|
-
React.useEffect(()=>{
|
|
36
|
-
const onKeyboardToggle = ({visible})=>{
|
|
37
|
-
isKeyboardOpenRef.current = visible;
|
|
38
|
-
};
|
|
39
|
-
const onResizePage = ()=>{
|
|
40
|
-
setTimeout(()=>{
|
|
41
|
-
if(isKeyboardOpenRef.current) return;
|
|
42
|
-
updateLayout();
|
|
43
|
-
},300);
|
|
44
|
-
}
|
|
45
|
-
APP.on(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
46
|
-
APP.on(APP.EVENTS.KEYBOARD_DID_TOGGLE,onKeyboardToggle)
|
|
47
|
-
return ()=>{
|
|
48
|
-
APP.off(APP.EVENTS.RESIZE_PAGE,onResizePage);
|
|
49
|
-
APP.off(APP.EVENTS.KEYBOARD_DID_TOGGLE,onKeyboardToggle);
|
|
50
|
-
}
|
|
51
|
-
},[]);
|
|
52
|
-
|
|
53
|
-
const cStyle = {maxHeight:Math.max(height-100,250),width:'100%'};
|
|
54
|
-
if(isObj(layout.layout) && typeof layout.layout.y =='number' && layout.layout.y>=10){
|
|
55
|
-
const {layout : {x,y}} = layout;
|
|
56
|
-
const minHeight = height - y;
|
|
57
|
-
if(minHeight> 0){
|
|
58
|
-
cStyle.minHeight = minHeight;
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
const contentContainerStyle = [cStyle,rest.contentContainerStyle];
|
|
62
|
-
return <View ref={layoutRef} onLayout={()=>{
|
|
63
|
-
if(!hasInitializedRef.current){
|
|
64
|
-
updateLayout();
|
|
65
|
-
}
|
|
66
|
-
}} {...containerProps} style={[theme.styles.w100,containerProps.style]} testID={testID+"_ScrollViewContainer"}>
|
|
67
|
-
<ScrollView
|
|
68
|
-
ref={ref}
|
|
69
|
-
{...rest}
|
|
70
|
-
testID={testID}
|
|
71
|
-
children={children}
|
|
72
|
-
contentContainerStyle = {contentContainerStyle}
|
|
73
|
-
/>
|
|
74
|
-
</View>
|
|
75
|
-
});
|
|
76
|
-
|
|
77
|
-
ScrollViewComponent.displayName = "ScrollViewComponent";
|
|
78
|
-
export default ScrollViewComponent;
|
|
79
|
-
|
|
80
|
-
ScrollViewComponent.propTypes = {
|
|
81
|
-
...defaultObj(ScrollView.propTypes),
|
|
82
|
-
withAutoSizer : PropTypes.bool,
|
|
83
|
-
}
|