@fto-consult/expo-ui 2.29.0 → 2.29.2

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.29.0",
3
+ "version": "2.29.2",
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.10.0",
62
62
  "@expo/html-elements": "^0.2.0",
63
63
  "@expo/vector-icons": "^13.0.0",
64
- "@fto-consult/common": "^1.25.4",
64
+ "@fto-consult/common": "^1.25.9",
65
65
  "@gorhom/portal": "^1.0.14",
66
66
  "@react-native-async-storage/async-storage": "~1.17.3",
67
67
  "@react-native-community/datetimepicker": "6.5.2",
@@ -356,8 +356,8 @@ const DatagridFactory = (Factory)=>{
356
356
  }
357
357
 
358
358
  const titleProps = isObj(accordionProps.titleProps)? Object.assign({},accordionProps.titleProps) : {};
359
- const titleStyle = Object.assign({},StyleSheet.flatten(titleProps.style));
360
- const titleColor = Colors.isValid(titleStyle.color)? titleStyle.color : Colors.isValid(titleProps.color)? titleProps.color : Colors.setAlpha(theme.colors.text,0.87);
359
+ const labelStyle = Object.assign({},StyleSheet.flatten(titleProps.style));
360
+ const titleColor = Colors.isValid(labelStyle.color)? labelStyle.color : Colors.isValid(titleProps.color)? titleProps.color : Colors.setAlpha(theme.colors.text,0.87);
361
361
  this.accordionTitleProps = {
362
362
  selectable: true,
363
363
  ellipsizeMode: EllipsizeMode.tail,
@@ -388,8 +388,6 @@ const DatagridFactory = (Factory)=>{
388
388
 
389
389
  filter = defaultFunc(filter,x=>true);
390
390
  const showFooters = this.canShowFooters();
391
- const showFilters = this.canShowFilters();
392
- let max = this.getMaxSelectableRows();
393
391
  let restItems = [];
394
392
 
395
393
  /*if(max && this.isSelectableMultiple()){
@@ -473,6 +471,7 @@ const DatagridFactory = (Factory)=>{
473
471
  }}
474
472
  />
475
473
  </View> : null}
474
+
476
475
  {this.isFilterable() ? <View>
477
476
  <FiltersAccordionComponent
478
477
  testID={testID+"_HeaderFilters"}
@@ -485,9 +484,6 @@ const DatagridFactory = (Factory)=>{
485
484
  context = {this}
486
485
  />
487
486
  </View> : null}
488
- {this.renderSectionListMenu()}
489
- {this.renderDisplayTypes()}
490
- {this.renderAggregatorFunctionsMenu()}
491
487
  <View pointerEvents={pointerEvents} testID={testID+"_HeaderPagination"} style = {styles.paginationItem}>
492
488
  <Menu
493
489
  testID={testID+"_HeaderMenus"}
@@ -524,9 +520,10 @@ const DatagridFactory = (Factory)=>{
524
520
  ]}
525
521
  />
526
522
  </View>
527
- <View>
528
- <RenderType />
529
- </View>
523
+ {this.renderSectionListMenu()}
524
+ {this.renderDisplayTypes()}
525
+ {this.renderAggregatorFunctionsMenu()}
526
+ {!canRenderChart ? <RenderType /> : null}
530
527
 
531
528
  {/*exportable && exportTableProps.pdf && (exportTableProps.pdf.footer) ? (
532
529
  <td width="40px">
@@ -228,7 +228,6 @@ export default class CommonDatagridComponent extends AppComponent {
228
228
  sectionListHeaderFooters : {value : {}},
229
229
  sectionListDataSize : {value : {current : 0}},
230
230
  enablePointerEventsRef : {value : {current:false}},
231
- configureSectionListSelectedValues : {value : {}},
232
231
  chartIdPrefix : {value : uniqid("datagrid-chart-id-prefix")},
233
232
  ///la liste des fonctions d'aggregations supportées
234
233
  aggregatorFunctions : {value : extendAggreagatorFunctions(this.props.aggregatorFunctions)},
@@ -238,7 +237,15 @@ export default class CommonDatagridComponent extends AppComponent {
238
237
  })
239
238
  const sessionAggregator = defaultStr(this.getSessionData("aggregatorFunction")).trim();
240
239
  const aggregatorProps = defaultStr(this.props.aggregatorFunction).trim();
241
- this.state.aggregatorFunction= aggregatorProps && isValidAggregator(this.aggregatorFunctions[aggregatorProps]) ? aggregatorProps ? isNonNullString(sessionAggregator) && isValidAggregator(this.aggregatorFunctions[sessionAggregator]) : sessionAggregator : Object.keys(this.aggregatorFunctions)[0];
240
+ let aggregatorFunction = null;
241
+ if(aggregatorProps && isValidAggregator(this.aggregatorFunctions[aggregatorProps])){
242
+ aggregatorFunction = aggregatorProps;
243
+ } else if(isNonNullString(sessionAggregator) && isValidAggregator(this.aggregatorFunctions[sessionAggregator])){
244
+ aggregatorFunction = sessionAggregator;
245
+ } else {
246
+ aggregatorFunction = Object.keys(this.aggregatorFunctions)[0];
247
+ }
248
+ this.state.aggregatorFunction= aggregatorFunction;
242
249
  this.isLoading = this.isLoading.bind(this);
243
250
  this.getProgressBar = this.getProgressBar.bind(this);
244
251
  this.sortRef.current.dir = defaultStr(this.sortRef.current.dir,this.sortRef.current.column == "date"?"desc":'asc')
@@ -1134,10 +1141,25 @@ export default class CommonDatagridComponent extends AppComponent {
1134
1141
  const type = defaultStr(column.jsType,column.type).toLowerCase();
1135
1142
  return type.contains("date") || type =='time' ? true : false;
1136
1143
  }
1144
+ setConfiguratedValue(key,value){
1145
+ const val = this.getConfiguratedValues();
1146
+ if(isObj(key)){
1147
+ extendObj(val,key);
1148
+ } else if(isNonNullString(key)){
1149
+ val[key] = value;
1150
+ }
1151
+ return this.setSessionData("configuratedSectionListColumns",val);
1152
+ }
1153
+ getConfiguratedValues(key){
1154
+ this.configureSectionListSelectedValues = defaultObj(this.getSessionData("configuratedSectionListColumns"),this.configureSectionListSelectedValues);
1155
+ if(isNonNullString(key)) return this.configureSectionListSelectedValues[key];
1156
+ return this.configureSectionListSelectedValues;
1157
+ }
1137
1158
  /*** configure la */
1138
1159
  configureSectionListColumn(column,toggleSectionList){
1139
1160
  if(!this.isSectionListColumnConfigurable(column)) return Promise.reject({message : 'type de colonne invalide, impossible de configurer la colonne, pour permettre qu\elle soit ajoutée dans les colonnes de groupe du tableau'});
1140
- const format = defaultStr(defaultObj(this.configureSectionListSelectedValues[column.field]).format,column.format,"dd/mm/yyyy")
1161
+ const confV = defaultObj(this.getConfiguratedValues(column.field));
1162
+ const format = defaultStr(confV.format,column.format,"dd/mm/yyyy")
1141
1163
  return new Promise((resolve,reject)=>{
1142
1164
  DialogProvider.open({
1143
1165
  title : 'Format de date',
@@ -1159,7 +1181,7 @@ export default class CommonDatagridComponent extends AppComponent {
1159
1181
  icon : "check",
1160
1182
  onPress : ({data})=>{
1161
1183
  column.format = data.dateFormat;
1162
- this.configureSectionListSelectedValues[column.field] = {format:column.format}
1184
+ this.setConfiguratedValue(column.field,{format:column.format});
1163
1185
  DialogProvider.close();
1164
1186
  setTimeout(()=>{
1165
1187
  resolve(column);
@@ -1473,7 +1495,7 @@ export default class CommonDatagridComponent extends AppComponent {
1473
1495
  });
1474
1496
  if(m.length <= 1 || !activeType) return null;
1475
1497
  if(!isMobileOrTabletMedia()){
1476
- m.unshift({text:"Type d'affichage des données",divider:true});
1498
+ m.unshift({text:"Type d'affichage des données",divider:true,textBold:true});
1477
1499
  }
1478
1500
  return <Menu
1479
1501
  title = "Type d'affichage"
@@ -1805,6 +1827,7 @@ export default class CommonDatagridComponent extends AppComponent {
1805
1827
  icon : "group",
1806
1828
  closeOnPress : false,
1807
1829
  divider : true,
1830
+ style : theme.styles.bold,
1808
1831
  },
1809
1832
  this.canDisplayOnlySectionListHeaders() && {
1810
1833
  text : "Afficher uniquement totaux",
@@ -1996,7 +2019,7 @@ export default class CommonDatagridComponent extends AppComponent {
1996
2019
  width,
1997
2020
  type,
1998
2021
  ...sListColumns[field],
1999
- ...defaultObj(this.configureSectionListSelectedValues[field]),
2022
+ ...defaultObj(this.getConfiguratedValues(field)),
2000
2023
  };///les colonnes de sections
2001
2024
  this.sectionListColumnsSize.current++;
2002
2025
  }
@@ -2089,19 +2112,19 @@ export default class CommonDatagridComponent extends AppComponent {
2089
2112
  this.hasFoundSectionData.current = false;
2090
2113
  this.sectionListDataSize.current = 0;
2091
2114
  const isSList = this.isSectionList(sectionListColumns);
2092
- if(this.canAutoSort() && isNonNullString(this.sortRef.current.column)){
2093
- if(isObj(this.state.columns) && this.state.columns[this.sortRef.current.column]){
2094
- let field = this.state.columns[this.sortRef.current.column];
2095
- const sortConfig = Object.assign({},this.sortRef.current);
2096
- sortConfig.getItem = (item,columnName,{getItem})=>{
2097
- if(isObj(item) && (field.type =='decimal' || field.type =="number")){
2098
- const v = item[columnName];
2099
- return isDecimal(v)? v : isNonNullString(v)? parseDecimal(v) : 0;
2100
- }
2101
- return getItem(item,columnName);
2115
+ const sortingField = isNonNullString(this.sortRef.current.column) && isObj(this.state.columns) && this.state.columns[this.sortRef.current.column] || {};
2116
+ const hasSortField = Object.size(sortingField,true);
2117
+ if(this.canAutoSort() && isNonNullString(this.sortRef.current.column) && hasSortField){
2118
+ let field = sortingField;
2119
+ const sortConfig = Object.assign({},this.sortRef.current);
2120
+ sortConfig.getItem = (item,columnName,{getItem})=>{
2121
+ if(isObj(item) && (field.type =='decimal' || field.type =="number")){
2122
+ const v = item[columnName];
2123
+ return isDecimal(v)? v : isNonNullString(v)? parseDecimal(v) : 0;
2102
2124
  }
2103
- data = sortBy(data,sortConfig);//on trie tout d'abord les données
2125
+ return getItem(item,columnName);
2104
2126
  }
2127
+ data = sortBy(data,sortConfig);//on trie tout d'abord les données
2105
2128
  }
2106
2129
  if(hasLocalFilter || !isArr || canUpdateFooters || isSList) {
2107
2130
  if(canUpdateFooters){
@@ -2123,7 +2146,7 @@ export default class CommonDatagridComponent extends AppComponent {
2123
2146
  }
2124
2147
  }
2125
2148
  let currentSectionListFooter = null;
2126
- const sectionListData = this.sectionListData;//l'ensemble des données de sectionList
2149
+ let sectionListData = {};//l'ensemble des données de sectionList
2127
2150
  Object.map(data,(d,i,rowIndex)=>{
2128
2151
  if(!isObj(d) || (hasLocalFilter && this.doLocalFilter({rowData:d,rowIndex:i}) === false)){
2129
2152
  return;
@@ -2149,6 +2172,7 @@ export default class CommonDatagridComponent extends AppComponent {
2149
2172
  }
2150
2173
  this.hasFoundSectionData.current = true;
2151
2174
  }
2175
+
2152
2176
  if(canUpdateFooters){
2153
2177
  const result = [this.___evaluatedFootersValues]
2154
2178
  if(currentSectionListFooter){
@@ -2161,6 +2185,12 @@ export default class CommonDatagridComponent extends AppComponent {
2161
2185
  newData.push(d);
2162
2186
  //push(d,i);
2163
2187
  });
2188
+ if(this.hasFoundSectionData.current && hasSortField && defaultStr(sortingField.type).toLowerCase().contains("date")){
2189
+ DateLib.sort(Object.keys(sectionListData)).map((k)=>{
2190
+ this.sectionListData[k] = sectionListData[k];
2191
+ return k;
2192
+ });
2193
+ }
2164
2194
  data = newData;
2165
2195
  }
2166
2196
  this.INITIAL_STATE.data = data;
@@ -2276,7 +2306,7 @@ export default class CommonDatagridComponent extends AppComponent {
2276
2306
  });
2277
2307
  }
2278
2308
  }
2279
- return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,isA && theme.styles.ph2,theme.styles.justifyContentCenter,theme.styles.alignItemsCenter,theme.styles.pb1,!cells && theme.styles.ml1,theme.styles.mr1,cStyle]}>
2309
+ return <View testID={testID+"_ContentContainer"} style={[theme.styles.w100,isA ? theme.styles.ph2 : theme.styles.pt1,theme.styles.justifyContentCenter,theme.styles.alignItemsCenter,theme.styles.pb1,!cells && theme.styles.ml1,theme.styles.mr1,cStyle]}>
2280
2310
  <Label testID={testID+"_Label"} splitText numberOfLines={3} textBold style={[theme.styles.w100,{color:theme.colors.primaryOnSurface,fontSize:isA?15 :16},lStyle]}>{label}</Label>
2281
2311
  {cells ? <View testID={testID+"_TableRow"} style = {[theme.styles.w100,theme.styles.row,theme.styles.alignItemsFlexStart,isA && theme.styles.mt05]}
2282
2312
  >{cells}</View> : null}
@@ -89,12 +89,22 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
89
89
  handleQueryLimit,
90
90
  onFetchData,
91
91
  beforeFetchData,
92
+ sort,
93
+ defaultSortColumn,
92
94
  ...rest
93
95
  } = props;
94
96
  rest = defaultObj(rest);
95
97
  rest.exportTableProps = defaultObj(rest.exportTableProps)
96
98
  const firstPage = 1;
97
99
  const tableName = defaultStr(table.tableName,table.table).trim().toUpperCase();
100
+ defaultSortColumn = defaultStr(defaultSortColumn,table.defaultSortColumn);
101
+ sort = isNonNullString(sort)? {column:sort} : isObj(sort)?sort : {};
102
+ const sColumn = defaultStr(sort.column,defaultSortColumn);
103
+ if(sColumn){
104
+ sort.column = sColumn;
105
+ } else {
106
+ delete sort.column;
107
+ }
98
108
  canMakePhoneCall = defaultBool(canMakePhoneCall,table.canMakePhoneCall);
99
109
  makePhoneCallProps = defaultObj(makePhoneCallProps,rest.makePhoneCallProps,table.makePhoneCallProps);
100
110
  const isExportable = !!Auth.isTableDataAllowed({table:tableName,action:'export'});
@@ -272,6 +282,7 @@ const SWRDatagridComponent = React.forwardRef((props,ref)=>{
272
282
  testID = {testID}
273
283
  {...defaultObj(table.datagrid)}
274
284
  {...rest}
285
+ sort = {sort}
275
286
  onSort = {({sort})=>{
276
287
  if(!canSortRemotely()) return;
277
288
  fetchOptionsRef.current.sort = sort;
@@ -423,6 +434,8 @@ SWRDatagridComponent.displayName = "SWRDatagridComponent";
423
434
 
424
435
  SWRDatagridComponent.propTypes = {
425
436
  ...Datagrid.propTypes,
437
+ /*** le nom de la colonne de trie par défaut */
438
+ defaultSortColumn : PropTypes.string,
426
439
  fetchPath : PropTypes.string,
427
440
  fetchPathKey : PropTypes.string,//la clé permettant de suffixer l'url fecherPath afin que ce ne soit pas unique pour certaines tables
428
441
  fetchData : PropTypes.func,
@@ -315,7 +315,7 @@ const DatagridFactory = (Factory)=>{
315
315
  />
316
316
  </View>
317
317
  {/*filters !== false && <td className="datagrid-local-filter-wrapper" ><LocalFilter title = {this.props.title} fields ={this.state.columns} onChange={this.onLocalFiltersChange.bind(this)}/></td>*/}
318
- <RenderType/>
318
+ {!canRenderChart && <RenderType/> || null}
319
319
  </View>
320
320
  </ScrollView>
321
321
  </View> : null;
@@ -532,6 +532,7 @@ export default class Filter extends AppComponent {
532
532
  text : !isMob ? 'Options' : ("Options de filtre ["+label+"]"),
533
533
  icon : 'cog',
534
534
  items : options,
535
+ style : styles.bold,
535
536
  },
536
537
  {divider:true},
537
538
  ...[hasFilterVal /*&& type !== 'select'*/?
@@ -25,6 +25,8 @@ const MenuItemComponent = React.forwardRef(({
25
25
  disabled,
26
26
  onPress,
27
27
  style,
28
+ textBold,
29
+ bold,
28
30
  contentStyle,
29
31
  testID,
30
32
  labelStyle,
@@ -34,9 +36,11 @@ const MenuItemComponent = React.forwardRef(({
34
36
  isBottomSheetItem,
35
37
  accessibilityLabel,
36
38
  right,
39
+ labelProps,
37
40
  contentContainerProps,
38
41
  ...rest
39
42
  },ref) => {
43
+ labelProps = defaultObj(labelProps);
40
44
  contentContainerProps = defaultObj(contentContainerProps);
41
45
  title = defaultVal(label,text,title);
42
46
  const disabledColor = color(theme.dark ? white : black)
@@ -52,7 +56,10 @@ const MenuItemComponent = React.forwardRef(({
52
56
  ? disabledColor
53
57
  : color(theme.colors.text).alpha(theme.ALPHA).rgb().string();
54
58
  iconProps = defaultObj(iconProps);
55
- labelStyle = Object.assign({},StyleSheet.flatten(labelStyle));
59
+ labelStyle = Object.assign({},StyleSheet.flatten([labelProps.style,labelStyle]));
60
+ if(textBold || bold){
61
+ labelStyle.fontWeight = "bold";
62
+ }
56
63
  style = Object.assign({},StyleSheet.flatten(style));
57
64
 
58
65
  if(Colors.isValid(labelStyle.color)){
@@ -107,6 +114,7 @@ const MenuItemComponent = React.forwardRef(({
107
114
  selectable={false}
108
115
  numberOfLines={1}
109
116
  ellipsizeMode = {"tail"}
117
+ {...labelProps}
110
118
  style={[styles.title, { color: titleColor }, labelStyle,styles.noMargin,!right ? maxWidthTextStyle : null]}
111
119
  >
112
120
  {title}
@@ -61,7 +61,7 @@ export const renderItems = (props)=>{
61
61
  index,
62
62
  _index,
63
63
  };
64
- itProps.titleStyle = [StyleSheet.flatten(itemProps.style),StyleSheet.flatten(rest.style),cursorPointer];
64
+ itProps.labelStyle = StyleSheet.flatten([itemProps.style,rest.style,cursorPointer]);
65
65
 
66
66
  if(typeof renderItem ==='function'){
67
67
  _render = renderItem(itProps);
@@ -7,7 +7,7 @@ import theme from "$theme";
7
7
  import PropTypes from "prop-types";
8
8
 
9
9
  export const title = 'Statistiques en BD';
10
- export default function DatabaseStatisticScreen ({withScreen,title:customTitle,contentProps,containerProps,tables,Component,...props}){
10
+ export default function DatabaseStatisticScreen ({withScreen,tableFilter,fetchCount,title:customTitle,contentProps,containerProps,tables,Component,...props}){
11
11
  Component = React.isComponent(Component)? Component : Grid;
12
12
  containerProps = defaultObj(containerProps);
13
13
  const title = containerProps.title = defaultStr(containerProps.title,DatabaseStatisticScreen.title);
@@ -18,8 +18,9 @@ export default function DatabaseStatisticScreen ({withScreen,title:customTitle,c
18
18
  containerProps.phoneSize = defaultNumber(containerProps.phoneSize,4);
19
19
  }
20
20
  let content = [];
21
+ tableFilter = typeof tableFilter ==="function"? tableFilter : x=>true;
21
22
  Object.map(tables,(table,index,suffix)=>{
22
- if(isObj(table) && table.databaseStatistic !== false && table.databaseStatistics !== false){
23
+ if(isObj(table) && table.databaseStatistic !== false && table.databaseStatistics !== false && tableFilter(table) !== false){
23
24
  content.push(
24
25
  <Cell elevation = {5} withSurface mobileSize={12} desktopSize={3} tabletSize={4} {...contentProps} key = {index} >
25
26
  <DatabaseStatistic
@@ -27,7 +28,10 @@ export default function DatabaseStatisticScreen ({withScreen,title:customTitle,c
27
28
  key = {index}
28
29
  table = {table}
29
30
  index = {suffix}
30
- title = {table.text|| table.title}
31
+ title = {defaultStr(table.text,table.label,table.title)}
32
+ fetchCount = {table.fetchCount|| typeof fetchCount =='function'? (a,b)=>{
33
+ return fetchCount({table,tableName:defaultStr(table.tableName,table.table)})
34
+ }:undefined}
31
35
  ></DatabaseStatistic>
32
36
  </Cell>
33
37
  )
@@ -50,5 +54,7 @@ DatabaseStatisticScreen.propTypes = {
50
54
  tables : PropTypes.oneOfType([
51
55
  PropTypes.arrayOf(PropTypes.object),
52
56
  PropTypes.objectOf(PropTypes.object)
53
- ]).isRequired
57
+ ]).isRequired,
58
+ /*** la fonction de filtre utilisée pour filtrer les table devant figurer sur le databaseStatistics */
59
+ tableFilter : PropTypes.func,
54
60
  }