@fto-consult/expo-ui 6.64.7 → 6.64.8
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/bin/create-app.js
CHANGED
@@ -69,10 +69,11 @@ module.exports = function(parsedArgs,{projectRoot:root}){
|
|
69
69
|
writeFile(mainPackagePath,JSON.stringify(mainPackage,null,2),{overwrite:true});
|
70
70
|
}
|
71
71
|
console.log("creating application .....");
|
72
|
-
[
|
73
|
-
|
74
|
-
|
75
|
-
|
72
|
+
["babel.config.js","metro.config.js","webpack.config.js"].map((p)=>{
|
73
|
+
const rP = path.join(projectRoot,p);
|
74
|
+
const pp = path.join(createAppDir,p);
|
75
|
+
if(!fs.existsSync(rP) && fs.existsSync(pp)){
|
76
|
+
copy(pp,rP,{overwrite:false}).catch((e)=>{});
|
76
77
|
}
|
77
78
|
});
|
78
79
|
createAPPJSONFile(projectRoot,{...mainPackage,name});
|
package/package.json
CHANGED
@@ -17,7 +17,7 @@ import {open,close} from "$preloader";
|
|
17
17
|
import {fields,getThemeData} from "$theme/utils";
|
18
18
|
import {modes} from "$ecomponents/TextField/utils";
|
19
19
|
import { useColorScheme } from "react-native";
|
20
|
-
import {createMaterial3Theme,
|
20
|
+
import {createMaterial3Theme,getMaterial3Theme} from "@pchmn/expo-material3-theme";
|
21
21
|
import notify from "$cnotify";
|
22
22
|
import appConfig from "$capp/config";
|
23
23
|
|
@@ -0,0 +1,8 @@
|
|
1
|
+
import React from "$react";
|
2
|
+
import appConfig from "$capp/config";
|
3
|
+
import {View,Text} from "react-native";
|
4
|
+
export default function Provider(props){
|
5
|
+
return <View style={{justifyContent:"center",flex:1,alignItems:"center"}}>
|
6
|
+
<Text style={{fontSize:16}}>La vie de material</Text>
|
7
|
+
</View>
|
8
|
+
}
|
@@ -0,0 +1,205 @@
|
|
1
|
+
import React from "$react";
|
2
|
+
import appConfig from "$capp/config";
|
3
|
+
import {MD3LightTheme,MD3DarkTheme} from "react-native-paper";
|
4
|
+
import { useMaterial3Theme,isDynamicThemeSupported} from '@pchmn/expo-material3-theme';
|
5
|
+
import { useColorScheme } from 'react-native';
|
6
|
+
import {colorsAlias,Colors} from "$theme";
|
7
|
+
import {isObj,isNonNullString,defaultStr,extendObj} from "$cutils";
|
8
|
+
import {getMainScreens} from "$escreens/mainScreens";
|
9
|
+
import {ExpoUIContext} from "./hooks";
|
10
|
+
import Login from "$eauth/Login";
|
11
|
+
import {modes} from "$ecomponents/TextField";
|
12
|
+
import {isMobileMedia} from "$cdimensions";
|
13
|
+
import { prepareScreens } from "./TableData";
|
14
|
+
import {extendFormFields} from "$ecomponents/Form/Fields";
|
15
|
+
|
16
|
+
|
17
|
+
/*****
|
18
|
+
les utilitaires disponibles à passer au provider :
|
19
|
+
FontsIconsFilter : (font{object},fontName{string},fontNameLower{string})=><boolean> //porte le nom de la props de appConfig dans lequel définir les filtres à utiliser pour charger l'iconSet désirée pour l'appication
|
20
|
+
///fonction de rappel appelée avant d'exit l'application, doit retourner une promesse que lorsque résolue, exit l'application
|
21
|
+
beforeExit : ()=><Promise>
|
22
|
+
getTableData : ()=>{object|array}
|
23
|
+
getStructData : ()=>{object|array}
|
24
|
+
tablesData : {object:{
|
25
|
+
table1:{drawerSortOrder:{number,l'ordre d'apparition dans le drawer},showInDrawer:{boolean|{funct<{boolean}>},si l'on affichera la table de données dans le drawers}},
|
26
|
+
table2:{},
|
27
|
+
table3:{},...[tableN]:{}}
|
28
|
+
}, la liste des tables de données
|
29
|
+
structsData : {object}, la liste des données de structures
|
30
|
+
handleHelpScreen : {boolean}, //si l'écran d'aide sera pris en compte, l'écran d'aide ainsi que les écrans des termes d'utilisations et autres
|
31
|
+
convertFiltersToSQL : {boolean}, si les filtres de datagrid ou filtres seront convertis au format SQL
|
32
|
+
components : {
|
33
|
+
logo : ReactNode | ReactComponent | object {
|
34
|
+
image{ReactComponent} :,
|
35
|
+
text {ReactComponent}
|
36
|
+
},
|
37
|
+
datagrid : {
|
38
|
+
///les props par défaut à passer au composant Datagrid
|
39
|
+
},
|
40
|
+
customFormFields{Object}, //les composant personalisés des forms fields
|
41
|
+
loginPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant Login,
|
42
|
+
tableLinkPropsMutator : ({object})=><{object}>, la fonction permettant de muter les props du composant TableLink,
|
43
|
+
TableDataScreen | TableDataScreenItem : {ReactComponent}, le composant TableDataScreenItem, à utiliser pour le rendu des écrans
|
44
|
+
TableDataScreenList | TableDataListScreen {ReactComponent}, le composant TableDataList à utiliser pour le rendu des écrans listants les éléments du table data
|
45
|
+
},
|
46
|
+
navigation : {
|
47
|
+
screens : {Array}, les écrans de navigation,
|
48
|
+
screenOptions : {object}, les options du composant Stack.Navigator, voir https://reactnavigation.org/docs/native-stack-navigator/
|
49
|
+
drawerItems : {object|array|function}, la fonction permettant d'obtenir les items du drawer principal de l'application, Chaque item du drawer doit avoir la chaine drawerSection, chaine de caractère determinant le code de la section dans lequel l'afficher
|
50
|
+
drawerSections : {object : {
|
51
|
+
[key{string}]:{string}} |
|
52
|
+
[key{string}] : {object { code:{string},label:{Node},order:{number, l'ordre de trie de la section}}}
|
53
|
+
} //les différentes sections à utiliser pour le rendu du drawer, deux sections par défaut existent :
|
54
|
+
les sectionis help et dashboard; help pour le rendu des items de la section Aide et Dashboard pour le rendu des items de la section Dashboard/Home
|
55
|
+
drawerItemsMutator : {function}, la fonction permettant de muter les drawerItems à chaque fois qu'on appelle la fonction de récupératioin des drawerItems
|
56
|
+
containerProps : {object}, les props à passer au composant NavigationContainer de react-navigation
|
57
|
+
},
|
58
|
+
realm : {}, //les options de configurations de la base de données realmdb
|
59
|
+
*/
|
60
|
+
const Provider = ({children,getTableData,handleHelpScreen,navigation,swrConfig,components:cComponents,convertFiltersToSQL,getStructData,tablesData,structsData,...props})=>{
|
61
|
+
const {extendAppTheme} = appConfig;
|
62
|
+
const { theme : pTheme } = useMaterial3Theme();
|
63
|
+
navigation = defaultObj(navigation);
|
64
|
+
const {customFormFields,...components} = defaultObj(cComponents);
|
65
|
+
extendFormFields(customFormFields);
|
66
|
+
structsData = isObj(structsData)? structsData : null;
|
67
|
+
appConfig.tablesData = tablesData;
|
68
|
+
handleHelpScreen = handleHelpScreen === false ? false : true;
|
69
|
+
appConfig.structsData = appConfig.structsData = isObj(structsData)? structsData : null;
|
70
|
+
getTableData = appConfig.getTable = appConfig.getTableData = getTableOrStructDataCall(tablesData,getTableData);
|
71
|
+
getStructData = appConfig.getStructData = getTableOrStructDataCall(structsData,getStructData);
|
72
|
+
appConfig.LoginComponent = Login;
|
73
|
+
swrConfig = defaultObj(swrConfig);
|
74
|
+
if(convertFiltersToSQL !== undefined){
|
75
|
+
appConfig.set("convertFiltersToSQL",convertFiltersToSQL);
|
76
|
+
}
|
77
|
+
const colorScheme = useColorScheme();
|
78
|
+
const isColorShemeDark = colorScheme ==="dark";
|
79
|
+
appConfig.extendAppTheme = (theme,Theme,...rest)=>{
|
80
|
+
if(!isObj(theme)) return;
|
81
|
+
const isDark = theme.dark || theme.isDark || isDynamicThemeSupported && isColorShemeDark ;
|
82
|
+
const elevation = defaultObj(theme.elevation,isDark ? pTheme.dark?.elevation : pTheme.light?.elevation)
|
83
|
+
const newTheme = isDark ? { ...MD3DarkTheme, colors: pTheme.dark } : { ...MD3LightTheme, colors: pTheme.light };
|
84
|
+
for(let i in newTheme){
|
85
|
+
if(i !== 'colors' && !(i in theme)){
|
86
|
+
theme[i] = newTheme[i];
|
87
|
+
}
|
88
|
+
}
|
89
|
+
if(isObj(theme.colors)){
|
90
|
+
colorsAlias.map((color)=>{
|
91
|
+
color = color.trim();
|
92
|
+
const cUpper = color.ucFirst();
|
93
|
+
//math theme colors to material desgin V3
|
94
|
+
const textA = `${color}Text`,onColor=`on${cUpper}`//,containerA = `${color}Container`,onColorContainer=`on${cUpper}Container`;
|
95
|
+
const c = Colors.isValid(theme.colors[onColor])? theme.colors[onColor] : (theme.colors[textA]) || undefined;
|
96
|
+
if(c){
|
97
|
+
theme.colors[onColor] = c;
|
98
|
+
}
|
99
|
+
});
|
100
|
+
for(let i in newTheme.colors){
|
101
|
+
if(!(i in theme.colors)){
|
102
|
+
theme.colors[i] = newTheme.colors[i];
|
103
|
+
}
|
104
|
+
}
|
105
|
+
}
|
106
|
+
theme.fonts = newTheme.fonts;
|
107
|
+
const r = typeof extendAppTheme == 'function'? extendAppTheme(theme,Theme,...rest) : theme;
|
108
|
+
const _theme = (isObj(r) ? r : theme);
|
109
|
+
const customCSS = _theme.customCSS;
|
110
|
+
extendObj(Theme,{
|
111
|
+
elevations : elevation,
|
112
|
+
elevation,
|
113
|
+
colorScheme,
|
114
|
+
isDynamicThemeSupported,
|
115
|
+
})
|
116
|
+
return {
|
117
|
+
..._theme,
|
118
|
+
get customCSS(){
|
119
|
+
const prevCSS = defaultStr(typeof customCSS ==='function'? customCSS(theme) : customCSS);
|
120
|
+
return `
|
121
|
+
#root {
|
122
|
+
overflow:hidden!important;
|
123
|
+
width : 100%!important;
|
124
|
+
height : 100%important;
|
125
|
+
left : 0!important;
|
126
|
+
top : 0!important;
|
127
|
+
}
|
128
|
+
.virtuoso-table-component,
|
129
|
+
.virtuoso-table-component th,
|
130
|
+
.virtuoso-table-component tr,
|
131
|
+
.virtuoso-table-component td{
|
132
|
+
border-collapse : collapse!important;
|
133
|
+
}
|
134
|
+
${prevCSS}
|
135
|
+
`;
|
136
|
+
},
|
137
|
+
get textFieldMode (){
|
138
|
+
/***** possibilité de charger le mode d'affichage par défaut des champs textuels dans le theme de l'application */
|
139
|
+
if(typeof theme.textFieldMode =='string' && theme.textFieldMode && modes[theme.textFieldMode]){
|
140
|
+
return modes[theme.textFieldMode];
|
141
|
+
}
|
142
|
+
return isMobileMedia()? modes.shadow : modes.flat;
|
143
|
+
}
|
144
|
+
}
|
145
|
+
}
|
146
|
+
const {screens} = navigation;
|
147
|
+
navigation.screens = React.useMemo(()=>{
|
148
|
+
const r = prepareScreens({
|
149
|
+
tables:tablesData,
|
150
|
+
screens,
|
151
|
+
TableDataScreen:components.TableDataScreen || components.TableDataScreenItem,
|
152
|
+
TableDataScreenList:components.TableDataScreenList||components.TableDataListScreen,
|
153
|
+
});
|
154
|
+
return [...r,...getMainScreens(handleHelpScreen)];
|
155
|
+
},[]);
|
156
|
+
navigation.containerProps = defaultObj(navigation.containerProps);
|
157
|
+
const {linking} = navigation;
|
158
|
+
return <ExpoUIContext.Provider
|
159
|
+
value={{
|
160
|
+
...props,
|
161
|
+
handleHelpScreen,
|
162
|
+
navigation,
|
163
|
+
convertFiltersToSQL,
|
164
|
+
components : {
|
165
|
+
...components,
|
166
|
+
loginPropsMutator : (props)=>{
|
167
|
+
return extendProps(components.loginPropsMutator,props);
|
168
|
+
},
|
169
|
+
tableLinkPropsMutator : (props)=>{
|
170
|
+
return extendProps(components.tableLinkPropsMutator,props);
|
171
|
+
},
|
172
|
+
datagrid : Object.assign({},components.datagrid),
|
173
|
+
},
|
174
|
+
getTableData,
|
175
|
+
getTable : getTableData,
|
176
|
+
getStructData,
|
177
|
+
tablesData,
|
178
|
+
structsData,
|
179
|
+
appConfig,
|
180
|
+
swrConfig,
|
181
|
+
}}
|
182
|
+
children={children}
|
183
|
+
/>;
|
184
|
+
}
|
185
|
+
const getTableOrStructDataCall = (tablesOrStructDatas,getTableOrStructDataFunc)=>{
|
186
|
+
return (tableName,...rest)=>{
|
187
|
+
if(!isNonNullString(tableName)) return null;
|
188
|
+
tableName = tableName.trim();
|
189
|
+
const ret2 = typeof getTableOrStructDataFunc ==='function' ? getTableOrStructDataFunc (tableName,...rest) : null;
|
190
|
+
if(isObj(ret2) && Object.size(ret2,true)) return ret2;
|
191
|
+
if(!isObj(tablesOrStructDatas)) return null;
|
192
|
+
const ret = tablesOrStructDatas[tableName] || tablesOrStructDatas[tableName.toLowerCase()] || tablesOrStructDatas[tableName.toUpperCase];
|
193
|
+
if(isObj(ret)) return ret;
|
194
|
+
return null;
|
195
|
+
}
|
196
|
+
}
|
197
|
+
const extendProps = (cb,props)=>{
|
198
|
+
const prs = defaultObj(props);
|
199
|
+
const o = typeof cb ==='function'? cb(props) : null;
|
200
|
+
if(isObj(o)){
|
201
|
+
return {...prs,...o};
|
202
|
+
}
|
203
|
+
return prs
|
204
|
+
}
|
205
|
+
export default Provider;
|