@fto-consult/expo-ui 4.0.1 → 4.0.4

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.
@@ -1,8 +1,8 @@
1
- const getDirName = require('path').dirname;
2
1
  const fs = require("fs");
3
2
  module.exports = function createDir(path,cb) {
4
3
  if(!path || typeof path !='string') return false;
5
- const p = getDirName(path);
4
+ const p = require("./getDirname")(path);
5
+ if(!p) return false;
6
6
  if(!fs.existsSync(p)){
7
7
  try {
8
8
  fs.mkdirSync(p,{ recursive: true});
@@ -0,0 +1,14 @@
1
+ ///retourne le nom du repertoire d'un chemin passé en paramètre
2
+ const path = require("path");
3
+ function isFile(pathItem) {
4
+ return !!path.extname(pathItem);
5
+ }
6
+ module.exports = (path_string)=>{
7
+ if(!path_string || typeof path_string !=='string'){
8
+ return null;
9
+ }
10
+ if(isFile(path_string)){
11
+ return path.dirname(path_string);
12
+ }
13
+ return path.resolve(path_string);
14
+ }
@@ -0,0 +1,24 @@
1
+ const isWindow = process.platform =="win32",
2
+ isMac = process.platform =='darwin',
3
+ isLinux = process.platform =="linux";
4
+ const fs = require("fs");
5
+ const getDirname = require("./getDirname");
6
+ const path = require("path");
7
+ module.exports = (p)=>{
8
+ if(Array.isArray(p)){
9
+ for(let i in p){
10
+ const r = getIcon(p[i]);
11
+ if(r) return r;
12
+ }
13
+ } else if(typeof p =='string' && p && fs.existsSync(p)){
14
+ const ext = isWindow ? ".ico" : isMac ? ".incs" : ".png";
15
+ const possibles = ["icon","logo","favicon"];
16
+ for(let i in possibles){
17
+ const ico = path.join(getDirname(p),possibles[i]+ext);
18
+ if(fs.existsSync(ico)){
19
+ return ico;
20
+ }
21
+ }
22
+ }
23
+ return undefined;
24
+ };
package/electron/index.js CHANGED
@@ -4,6 +4,7 @@ const session = require("./session");
4
4
  const path = require("path");
5
5
  const fs = require("fs");
6
6
  const ePath = path.resolve(__dirname);
7
+ const getDirname = require("./getDirname");
7
8
  if(!fs.existsSync(path.resolve(ePath,"paths.json"))){
8
9
  throw {message : 'Chemin de noms, fichier paths.json introuvable!! Exécutez l\'application en enviornnement web|mobile|android|ios puis re-essayez'}
9
10
  }
@@ -18,37 +19,11 @@ const mainProcess = mainProcessRequired && typeof mainProcessRequired =='object'
18
19
  // Gardez une reference globale de l'objet window, si vous ne le faites pas, la fenetre sera
19
20
  // fermee automatiquement quand l'objet JavaScript sera garbage collected.
20
21
  let win = undefined;
21
- const isWindow = process.platform =="win32",
22
- isMac = process.platform =='darwin',
23
- isLinux = process.platform =="linux";
24
- const getIcon = (p)=>{
25
- if(Array.isArray(p)){
26
- for(let i in p){
27
- const r = getIcon(p[i]);
28
- if(r) return r;
29
- }
30
- } else if(typeof p =='string' && p && fs.existsSync(p)){
31
- const ext = isWindow ? ".ico" : isMac ? ".incs" : ".png";
32
- const possibles = ["icon","logo","favicon"];
33
- for(let i in possibles){
34
- const icon = path.join(p,possibles[i]+ext);
35
- if(fs.existsSync(icon)){
36
- return icon;
37
- }
38
- }
39
- }
40
- return undefined;
41
- }
42
- const icon = isLinux && logo && fs.existsSync(logo) && logo || getIcon(
43
- logo && fs.existsSync(logo) && path.dirname(logo),
44
- images,
45
- assets,
46
- )
47
- /*console.log(icon," is iccccccc");
48
- console.log(logo," is logo ",images,assets);
49
- throw {
50
- message : "icon is "+icon+" logo is "+logo+" image is "+images+" assets is "+assets
51
- }*/
22
+ const icon = require("./getIcon")(
23
+ logo && fs.existsSync(logo) && getDirname(logo),
24
+ images && getDirname(images) || '',
25
+ assets && getDirname(assets) || '',
26
+ );
52
27
  Menu.setApplicationMenu(null);
53
28
  let clipboadContextMenu = (_, props) => {
54
29
  if (props.isEditable || props.selectionText) {
@@ -149,6 +124,10 @@ function createWindow () {
149
124
  devTools : true,
150
125
  }
151
126
  });
127
+
128
+ const log = (message)=>{
129
+ return win != null && win && win.webContents.send("console.log",message);
130
+ }
152
131
  // create a new `splash`-Window
153
132
  /*** @see : http://leftstick.github.io/splash-screen/ */
154
133
  let splash = new BrowserWindow({
@@ -188,6 +167,7 @@ function createWindow () {
188
167
  splash = null;
189
168
  win.restore();
190
169
  win.show();
170
+ //log(icon," is consooleeeee")
191
171
  })
192
172
 
193
173
  win.on('close', (e) => {
@@ -319,6 +319,9 @@ ipcRenderer.on("main-app-restaured",()=>{
319
319
  message : "TRACK_IDLE",
320
320
  });
321
321
  });
322
+ ipcRenderer.on('console.log',(event,...message)=>{
323
+ console.log(...message);
324
+ })
322
325
  ipcRenderer.on('appReady',()=>{})
323
326
  ipcRenderer.on("main-window-focus",()=>{
324
327
  postMessage("WINDOW_FOCUS");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@fto-consult/expo-ui",
3
- "version": "4.0.1",
3
+ "version": "4.0.4",
4
4
  "description": "Bibliothèque de composants UI Expo,react-native",
5
5
  "main": "index.js",
6
6
  "scripts": {
@@ -105,7 +105,7 @@
105
105
  "react-native-svg": "13.4.0",
106
106
  "react-native-web": "~0.18.7",
107
107
  "react-native-webview": "11.23.1",
108
- "react-virtuoso": "^4.0.6",
108
+ "react-virtuoso": "^4.0.9",
109
109
  "sharp-cli": "^2.1.0",
110
110
  "tippy.js": "^6.3.7",
111
111
  "use-event-callback": "^0.1.0",
@@ -12,7 +12,7 @@ import {isWeb} from "$cplatform";
12
12
  * 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
13
13
  * le reste de la taille de la page, avec comme valeur de la props minHeight
14
14
  */
15
- const AutoSizerVerticalComponent = React.forwardRef(({onLayout,isScrollView,withActivityIndicator,testID,withPadding,maxHeight,minHeight,style,children:cChildren,...rest},ref) => {
15
+ const AutoSizerVerticalComponent = React.forwardRef(({onLayout,isScrollView,screenIndent,getRenderingStyle,withActivityIndicator,testID,withPadding,paddingBottom,maxHeight,minHeight,style,children:cChildren,...rest},ref) => {
16
16
  testID = defaultStr(testID,'RN_AutoSizerVerticalComponent');
17
17
  const hasUpdateLayoutRef = React.useRef(false);
18
18
  const layoutRef = React.useRef(null);
@@ -56,15 +56,32 @@ const AutoSizerVerticalComponent = React.forwardRef(({onLayout,isScrollView,with
56
56
  const hasUpdateLayout = hasUpdateLayoutRef.current;
57
57
  const cStyle ={width:'100%',maxHeight:Math.max(height-100,250)};
58
58
  const contentLayout = defaultObj(layout.layout);
59
- cStyle.minHeight = Math.min(Math.max(layout.height-defaultNumber(contentLayout.y),minHeight && minHeight ||250));
60
- const cMaxHeight = layout.height-defaultNumber(contentLayout.y);
61
- if(cMaxHeight>=250){
59
+ screenIndent = typeof screenIndent =='number' && screenIndent > 50 ? screenIndent : 100;
60
+ const y = Math.abs(defaultNumber(contentLayout.y));
61
+ const heightY = y < height - screenIndent ? y : height - screenIndent;
62
+ cStyle.minHeight = Math.min(Math.max(layout.height-heightY,minHeight && minHeight ||250));
63
+ const cMaxHeight = layout.height-heightY;
64
+ if(cMaxHeight>=200){
62
65
  cStyle.maxHeight = cMaxHeight;
63
66
  }
64
- if(withPadding !== false){
65
- cStyle.paddingBottom = 50;
67
+ if(typeof paddingBottom =='number'){
68
+ cStyle.paddingBottom = paddingBottom; //: 50;
69
+ }
70
+ if(cStyle.minHeight && cStyle.maxHeight && cStyle.minHeight > cStyle.maxHeight){
71
+ cStyle.minHeight = cStyle.maxHeight;
72
+ }
73
+ const restStyle = {};
74
+ const canUpdate = hasUpdateLayout || hasUpdateLayout || withActivityIndicator === false;
75
+ const fStyle = !canUpdate && {flex:1,flexDirection:'column',maxHeight:cStyle.maxHeight,maxWidth : Math.max(layout.width-defaultNumber(contentLayout.x)),justifyContent:'center',alignItems:'center'} || {};
76
+ if(maxHeight){
77
+ restStyle.maxHeight = maxHeight;
78
+ }
79
+ if(minHeight){
80
+ restStyle.minHeight = minHeight;
81
+ }
82
+ if(canUpdate && typeof getRenderingStyle ==='function'){
83
+ getRenderingStyle({...cStyle,...restStyle});
66
84
  }
67
- const fStyle = !hasUpdateLayout && withActivityIndicator !== false && {flex:1,flexDirection:'column',maxHeight:cStyle.maxHeight,maxWidth : Math.max(layout.width-defaultNumber(contentLayout.x)),justifyContent:'center',alignItems:'center'} || {};
68
85
  return <View ref={layoutRef}
69
86
  onLayout={(a,b,c)=>{
70
87
  if(onLayout && onLayout(a,b,c) === false) return;
@@ -73,8 +90,8 @@ const AutoSizerVerticalComponent = React.forwardRef(({onLayout,isScrollView,with
73
90
  }
74
91
  }}
75
92
  {...rest}
76
- style={[theme.styles.w100,cStyle,style,fStyle,maxHeight && {maxHeight}, minHeight && {minHeight}]} testID={testID+"_ScrollViewContainer"}>
77
- {hasUpdateLayout || withActivityIndicator === false ?children : <ActivityIndicator size={'large'}/>}
93
+ style={[theme.styles.w100,cStyle,style,fStyle,restStyle]} testID={testID+"_ScrollViewContainer"}>
94
+ { canUpdate?children : <ActivityIndicator size={'large'}/>}
78
95
  </View>
79
96
  });
80
97
 
@@ -86,4 +103,5 @@ AutoSizerVerticalComponent.propTypes = {
86
103
  withActivityIndicator : PropTypes.bool,//si l'on utilisera l'activity indicator pour le chargement du contentu
87
104
  maxHeight : PropTypes.number,
88
105
  minHeight : PropTypes.number,
106
+ paddingBottom : PropTypes.number,
89
107
  }
@@ -187,7 +187,6 @@ const DatagridFactory = (Factory)=>{
187
187
  });
188
188
  }
189
189
  }
190
- const maxHeight = this.getMaxListHeight();
191
190
  const rPagination = showPagination ? <View style={[styles.paginationContainer]}>
192
191
  <ScrollView testID={testID+"_Datagrid_Headers"} horizontal style={styles.paginationContainerStyle} contentContainerStyle={styles.minW100}>
193
192
  <View testID={testID+"_HeaderPaginationContent"} style={[styles.paginationContent]}>
@@ -292,7 +291,7 @@ const DatagridFactory = (Factory)=>{
292
291
  </View>
293
292
  </ScrollView>
294
293
  </View> : null;
295
- return <View style={[styles.container,{flex:1,maxHeight}]} testID={testID+"_TableContainer"} pointerEvents={pointerEvents}>
294
+ return <View style={[styles.container,{flex:1}]} testID={testID+"_TableContainer"} pointerEvents={pointerEvents}>
296
295
  <View ref={this.layoutRef} testID={testID+"_LayoutContainer"}>
297
296
  {this.props.showActions !== false ? <DatagridActions
298
297
  pointerEvents = {pointerEvents}
@@ -26,7 +26,7 @@ const propTypes = {
26
26
  isScrolling : PropTypes.func,
27
27
  };
28
28
  /***@see : https://virtuoso.dev/virtuoso-api-reference/ */
29
- const VirtuosoListComponent = React.forwardRef(({items,onRender,testID,renderItem,onEndReached,onLayout,onContentSizeChange,onScroll,isScrolling,estimatedItemSize,onEndReachedThreshold,containerProps,style,...props},ref)=>{
29
+ const VirtuosoListComponent = React.forwardRef(({items,onRender,testID,renderItem,onEndReached,onLayout,onContentSizeChange,onScroll,isScrolling,estimatedItemSize,onEndReachedThreshold,containerProps,style,autoSizedStyle,...props},ref)=>{
30
30
  const r2 = {};
31
31
  for(let i in propTypes){
32
32
  if(i in props){
@@ -80,6 +80,7 @@ const VirtuosoListComponent = React.forwardRef(({items,onRender,testID,renderIte
80
80
  if(isDOMElement(target) && onContentSizeChange){
81
81
  const {nativeEvent:{contentSize}} = normalizeEvent({target});
82
82
  setTimeout(()=>{
83
+ target.style.paddingBottom = "50px";
83
84
  if(contentSize.width !== listSize.width || contentSize.height != listSize.height){
84
85
  sizeRef.current = contentSize;
85
86
  onContentSizeChange(contentSize.width,contentSize.height);
@@ -87,16 +88,15 @@ const VirtuosoListComponent = React.forwardRef(({items,onRender,testID,renderIte
87
88
  },100)
88
89
  }
89
90
  }
90
- React.useEffect(()=>{
91
- checkSize();
92
- },[props])
93
91
  React.useEffect(()=>{
94
92
  return ()=>{
95
93
  React.setRef(ref,null);
96
94
  }
97
95
  },[]);
98
- React.useOnRender(onRender,Math.max(Array.isArray(items) && items.length/10 || 0,500))
99
- return <View {...containerProps} {...props} style={[{flex:1},containerProps.style,style,{minWidth:'100%',height:'100%',maxWidth:'100%'}]} onLayout={onLayout} testID={testID}>
96
+ React.useOnRender((a,b,c)=>{
97
+ if(onRender && onRender(a,b,c));
98
+ },Math.max(Array.isArray(items) && items.length/10 || 0,500))
99
+ return <View {...containerProps} {...props} style={[{flex:1},containerProps.style,style,autoSizedStyle,{minWidth:'100%',height:'100%',maxWidth:'100%'}]} onLayout={onLayout} testID={testID}>
100
100
  <Virtuoso
101
101
  {...r2}
102
102
  style = {listStyle}
@@ -120,6 +120,9 @@ const VirtuosoListComponent = React.forwardRef(({items,onRender,testID,renderIte
120
120
  return isScrolling(isC);
121
121
  }
122
122
  }}
123
+ totalListHeightChanged = {(height)=>{
124
+ checkSize();
125
+ }}
123
126
  defaultItemHeight = {typeof estimatedItemSize=='number' && estimatedItemSize || undefined}
124
127
  />
125
128
  </View>
@@ -1,12 +1,21 @@
1
1
  import React from "$react";
2
2
  import {Vertical as AutoSizeVertical} from "$ecomponents/AutoSizer";
3
3
  import List from "./List";
4
- import {defaultStr,defaultObj} from "$utils";
4
+ import {defaultStr,isObj,defaultObj} from "$utils";
5
+ const normalize = (size)=>{
6
+ if(isObj(size)){
7
+ ["padding","paddingBottom","paddingTop","paddingLeft","paddingRight"].map(p=>{
8
+ delete size[p];
9
+ })
10
+ return size;
11
+ }
12
+ return {};
13
+ }
5
14
  const AutoSizeVerticalList = React.forwardRef(({testID,autoSizerProps,...props},ref)=>{
6
15
  testID = defaultStr(testID,"RN_AutoSizeVerticalListComponent")
7
16
  autoSizerProps = defaultObj(autoSizerProps);
8
- return <AutoSizeVertical testID={testID+"_AutoSizerVertical"} {...autoSizerProps} >
9
- <List {...props} ref={ref}/>
17
+ return <AutoSizeVertical withPadding={false} testID={testID+"_AutoSizerVertical"} {...autoSizerProps} >
18
+ <List {...props} style={[props.style]} ref={ref}/>
10
19
  </AutoSizeVertical>
11
20
  })
12
21