@fto-consult/expo-ui 8.72.0 → 8.73.1
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/dependencies.js +3 -3
- package/package.json +4 -4
- package/src/components/BottomSheet/Sheet.js +0 -6
- package/src/components/Datagrid/Accordion/index.js +3 -3
- package/src/components/Dialog/Dialog.js +5 -2
- package/src/components/Dropdown/index.js +35 -23
- package/src/components/Form/Fields/SelectField.js +1 -1
- package/src/components/Form/Fields/SelectTableData/Component.js +23 -6
- package/src/components/Form/utils/FormsManager.js +11 -5
- package/src/components/List/hooks.js +2 -2
- package/src/components/Menu/Menu.js +5 -3
- package/src/layouts/Screen/TableData.js +1 -2
- package/src/media/Assets/utils.js +9 -2
- package/src/pdf/Reader/index.js +6 -0
- package/src/pdf/Reader/index.web.js +16 -173
- package/src/pdf/Reader/index.web.old.js +178 -0
- package/src/pdf/Reader/web/Viewer.js +20 -0
- package/src/pdf/Reader/web/script.js +334 -0
- package/src/screens/Help/openLibraries.js +5 -5
- package/src/table-data/importer/parser.js +1824 -0
- package/src/table-data/importer/run.js +0 -1
@@ -11,8 +11,8 @@
|
|
11
11
|
"@react-navigation/native-stack": "^6.9.26",
|
12
12
|
"@react-navigation/stack": "^6.3.29",
|
13
13
|
"@shopify/flash-list": "1.6.3",
|
14
|
-
"expo": "^50.0.
|
15
|
-
"expo-camera": "~14.1.
|
14
|
+
"expo": "^50.0.17",
|
15
|
+
"expo-camera": "~14.1.3",
|
16
16
|
"expo-clipboard": "~5.0.1",
|
17
17
|
"expo-font": "~11.10.3",
|
18
18
|
"expo-image-picker": "~14.7.1",
|
@@ -20,7 +20,7 @@
|
|
20
20
|
"expo-sharing": "~11.10.0",
|
21
21
|
"expo-sqlite": "~13.4.0",
|
22
22
|
"expo-status-bar": "~1.11.1",
|
23
|
-
"expo-system-ui": "~2.9.
|
23
|
+
"expo-system-ui": "~2.9.4",
|
24
24
|
"expo-web-browser": "~12.8.2",
|
25
25
|
"react": "18.2.0",
|
26
26
|
"react-native": "0.73.6",
|
package/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@fto-consult/expo-ui",
|
3
|
-
"version": "8.
|
3
|
+
"version": "8.73.1",
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
5
5
|
"react-native-paper-doc": "https://github.com/callstack/react-native-paper/tree/main/docs/docs/guides",
|
6
6
|
"scripts": {
|
@@ -70,7 +70,7 @@
|
|
70
70
|
"dependencies": {
|
71
71
|
"@emotion/react": "^11.11.1",
|
72
72
|
"@faker-js/faker": "^8.0.2",
|
73
|
-
"@fto-consult/common": "^4.
|
73
|
+
"@fto-consult/common": "^4.45.0",
|
74
74
|
"apexcharts": "^3.48.0",
|
75
75
|
"file-saver": "^2.0.5",
|
76
76
|
"google-libphonenumber": "^3.2.34",
|
@@ -85,9 +85,9 @@
|
|
85
85
|
"react-native-iphone-x-helper": "^1.3.1",
|
86
86
|
"react-native-mime-types": "^2.5.0",
|
87
87
|
"react-native-paper": "^5.12.3",
|
88
|
-
"react-native-paper-dates": "^0.22.
|
88
|
+
"react-native-paper-dates": "^0.22.7",
|
89
89
|
"react-native-web": "^0.19.10",
|
90
|
-
"react-virtuoso": "^4.7.
|
90
|
+
"react-virtuoso": "^4.7.9",
|
91
91
|
"readable-stream": "^4.5.2",
|
92
92
|
"sanitize-filename": "^1.6.3",
|
93
93
|
"tippy.js": "^6.3.7",
|
@@ -59,7 +59,6 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
59
59
|
modalProps,
|
60
60
|
titleProps : _titleProps,
|
61
61
|
withScrollView,
|
62
|
-
bindResizeEvent,
|
63
62
|
scrollViewProps : _scrollViewProps,
|
64
63
|
actionTitle,
|
65
64
|
elevation:customElevation,
|
@@ -228,12 +227,8 @@ const BottomSheetComponent = React.forwardRef((props,ref)=> {
|
|
228
227
|
|
229
228
|
React.setRef(ref,{close:closeModal,open})
|
230
229
|
React.useEffect(()=>{
|
231
|
-
if(bindResizeEvent){
|
232
|
-
APP.on(APP.EVENTS.RESIZE_PAGE,closeModal);
|
233
|
-
}
|
234
230
|
return ()=>{
|
235
231
|
removeListeners();
|
236
|
-
APP.off(APP.EVENTS.RESIZE_PAGE,closeModal);
|
237
232
|
React.setRef(ref,null);
|
238
233
|
}
|
239
234
|
},[]);
|
@@ -326,7 +321,6 @@ BottomSheetComponent.propTypes = {
|
|
326
321
|
|
327
322
|
BottomSheetComponent.defaultProps = {
|
328
323
|
withScrollView : PropTypes.bool,
|
329
|
-
bindResizeEvent : PropTypes.bool,
|
330
324
|
animationType: isNativeMobile ? "slide" : "fade",//Background animation ("none", "fade", "slide")
|
331
325
|
height:undefined,//Height of Bottom Sheet
|
332
326
|
minClosingHeight: 0,//Minimum height of Bottom Sheet before close
|
@@ -21,8 +21,8 @@ import BackToTop from "$ecomponents/BackToTop";
|
|
21
21
|
import FiltersAccordionComponent from "./Filters";
|
22
22
|
import RenderType from "../RenderType";
|
23
23
|
import { flatMode} from "$ecomponents/TextField";
|
24
|
-
|
25
|
-
import List from "$ecomponents/List/FlashList";
|
24
|
+
import List from "$ecomponents/Table/List";
|
25
|
+
//import List from "$ecomponents/List/FlashList";
|
26
26
|
import theme,{Colors} from "$theme";
|
27
27
|
import {styles as rStyles} from "../utils";
|
28
28
|
import Avatar from "$ecomponents/Avatar";
|
@@ -552,7 +552,7 @@ const DatagridFactory = (Factory)=>{
|
|
552
552
|
extraData = {this.state.refresh}
|
553
553
|
contentInset={{ right: 10, top: 10, left: 10, bottom: 10 }}
|
554
554
|
itemHeight = {undefined}
|
555
|
-
responsive = {defaultBool(responsive,rest.responsive,accordionProps.responsive,true)}
|
555
|
+
responsive = {defaultBool(this.hasSectionListData()? false : undefined,responsive,rest.responsive,accordionProps.responsive,true)}
|
556
556
|
filter = {filter}
|
557
557
|
getItemType = {this.getFlashListItemType.bind(this)}
|
558
558
|
renderItem = {this.renderItem.bind(this)}
|
@@ -177,8 +177,11 @@ const DialogComponent = React.forwardRef((props,ref)=>{
|
|
177
177
|
containerProps.mediaQueryUpdateStyle = (...rest)=>{
|
178
178
|
const r = typeof mediaQueryUpdateStyle =="function"? mediaQueryUpdateStyle(...rest) : undefined;
|
179
179
|
const {width,height} = rest[0];
|
180
|
-
|
181
|
-
|
180
|
+
let rW = setDimensions !== false ? {width,height} : {};
|
181
|
+
if(setDimensions !== false && isFullScreenDialog()){
|
182
|
+
rW = {width:'100%',height:'100%',minHeight:height,maxWidth:"100%",maxHeight:"100%"};
|
183
|
+
}
|
184
|
+
return isFullScreenDialog()? [r,rW] : [r,setDimensions !== false && {maxHeight:getMaxHeight(),maxWidth:getMaxWidth()}];
|
182
185
|
}
|
183
186
|
}
|
184
187
|
return containerProps;
|
@@ -35,6 +35,11 @@ const MAX_SELECTED_ITEMS = 2;
|
|
35
35
|
|
36
36
|
export const isValidValueKey = valueKey => isNonNullString(valueKey);
|
37
37
|
|
38
|
+
/***
|
39
|
+
au cas où les données sont chargées depuis la bd,
|
40
|
+
la props isLoading doit être passée à true à ce compossant
|
41
|
+
elle devra être remise à false une fois le chargement des données terminé
|
42
|
+
*/
|
38
43
|
class DropdownComponent extends AppComponent {
|
39
44
|
constructor(props){
|
40
45
|
super(props);
|
@@ -106,7 +111,7 @@ class DropdownComponent extends AppComponent {
|
|
106
111
|
return index;
|
107
112
|
}, override : false, writable : false
|
108
113
|
},
|
109
|
-
|
114
|
+
isDefaultMultiplePropEnabled : {
|
110
115
|
value : !!multiple,
|
111
116
|
override : false, writable : false,
|
112
117
|
},
|
@@ -120,6 +125,7 @@ class DropdownComponent extends AppComponent {
|
|
120
125
|
|
121
126
|
extendObj(this.state,{
|
122
127
|
initialized : false,
|
128
|
+
selected : this.prepareSelected({defaultValue}),
|
123
129
|
filterText : "",
|
124
130
|
anchorHeight : undefined,
|
125
131
|
isMobileMedia : isMobileOrTabletMedia(),
|
@@ -134,6 +140,9 @@ class DropdownComponent extends AppComponent {
|
|
134
140
|
this.inputRef = React.createRef(null);
|
135
141
|
this.listRef = React.createRef(null);
|
136
142
|
}
|
143
|
+
canHandleMultiple (){
|
144
|
+
return !!this.props.multiple;
|
145
|
+
}
|
137
146
|
updateSelected (nState,force){
|
138
147
|
nState = defaultObj(nState);
|
139
148
|
//this.countEee = defaultNumber(this.countEee)+1;
|
@@ -148,7 +157,7 @@ class DropdownComponent extends AppComponent {
|
|
148
157
|
let selectedItem = null;
|
149
158
|
const valueKey = this.getValueKey(this.state.selected);
|
150
159
|
if(this.state.initialized && !force){
|
151
|
-
if(!this.canHandleMultiple){
|
160
|
+
if(!this.canHandleMultiple()){
|
152
161
|
if(valueKey && this.state.valuesKeys[valueKey]){
|
153
162
|
selectedItem = this.state.valuesKeys[valueKey].item;
|
154
163
|
}
|
@@ -185,9 +194,9 @@ class DropdownComponent extends AppComponent {
|
|
185
194
|
},force);
|
186
195
|
}
|
187
196
|
selectItem ({value,select,valueKey}){
|
188
|
-
let selected = this.canHandleMultiple ? [...this.state.selected] : undefined;
|
197
|
+
let selected = this.canHandleMultiple() ? [...this.state.selected] : undefined;
|
189
198
|
let selectedValuesKeys = {...this.state.selectedValuesKeys};
|
190
|
-
if(this.canHandleMultiple){
|
199
|
+
if(this.canHandleMultiple()){
|
191
200
|
if(!select){
|
192
201
|
if(valueKey in selectedValuesKeys){
|
193
202
|
const newS = [];
|
@@ -215,7 +224,7 @@ class DropdownComponent extends AppComponent {
|
|
215
224
|
}
|
216
225
|
this.willHandleFilter = false;
|
217
226
|
let nState = {};
|
218
|
-
if(!this.canHandleMultiple){
|
227
|
+
if(!this.canHandleMultiple()){
|
219
228
|
nState.visible = false;
|
220
229
|
}
|
221
230
|
this.updateSelected({...nState,data:!this.isBigList?[...this.state.data]: this.state.data,selected,selectedValuesKeys});
|
@@ -234,7 +243,7 @@ class DropdownComponent extends AppComponent {
|
|
234
243
|
if(valueKey && forceCheck !== true){
|
235
244
|
return valueKey in this.state.selectedValuesKeys ? true : false;
|
236
245
|
}
|
237
|
-
if(this.canHandleMultiple) {
|
246
|
+
if(this.canHandleMultiple()) {
|
238
247
|
currentSelected = Array.isArray(currentSelected)? currentSelected : this.state.selected;
|
239
248
|
for(let i in currentSelected){
|
240
249
|
if(this.compare(currentValue,currentSelected[i])) return true;
|
@@ -246,7 +255,7 @@ class DropdownComponent extends AppComponent {
|
|
246
255
|
}
|
247
256
|
prepareSelected({defaultValue}){
|
248
257
|
let s = defaultValue !== undefined ? defaultValue : undefined;
|
249
|
-
if(this.canHandleMultiple){
|
258
|
+
if(this.canHandleMultiple()){
|
250
259
|
if(isNonNullString(s)){
|
251
260
|
s = s.split(",");//si c'est un tableau, ça doit être séparé de virgule
|
252
261
|
} else {
|
@@ -291,7 +300,7 @@ class DropdownComponent extends AppComponent {
|
|
291
300
|
if(isObj(valuesKeys[valueKey])){
|
292
301
|
const node = valuesKeys[valueKey];
|
293
302
|
const text = node.text;
|
294
|
-
if(!this.canHandleMultiple){
|
303
|
+
if(!this.canHandleMultiple()){
|
295
304
|
sDText = text;
|
296
305
|
} else {
|
297
306
|
counter++;
|
@@ -306,7 +315,7 @@ class DropdownComponent extends AppComponent {
|
|
306
315
|
for(let i in selectedValues){
|
307
316
|
const text = selectedValues[i];
|
308
317
|
if(!isNonNullString(text) && typeof text !=="number") continue;
|
309
|
-
if(!this.canHandleMultiple){
|
318
|
+
if(!this.canHandleMultiple()){
|
310
319
|
sDText = String(text);
|
311
320
|
} else {
|
312
321
|
counter++;
|
@@ -322,13 +331,13 @@ class DropdownComponent extends AppComponent {
|
|
322
331
|
} else {
|
323
332
|
this.toggleHasNoValidSelectedValue(false);
|
324
333
|
}
|
325
|
-
if(this.canHandleMultiple && counter > maxCount && sDText){
|
334
|
+
if(this.canHandleMultiple() && counter > maxCount && sDText){
|
326
335
|
sDText+= ", et "+((counter-maxCount).formatNumber()+" de plus")
|
327
336
|
}
|
328
337
|
return sDText;
|
329
338
|
}
|
330
339
|
pushSelectedValue(value,selectedStateValue){
|
331
|
-
if(this.canHandleMultiple){
|
340
|
+
if(this.canHandleMultiple()){
|
332
341
|
selectedStateValue = Array.isArray(selectedStateValue)?selectedStateValue : [];
|
333
342
|
selectedStateValue.push(value);
|
334
343
|
return selectedStateValue;
|
@@ -349,7 +358,7 @@ class DropdownComponent extends AppComponent {
|
|
349
358
|
const valuesKeys = {};
|
350
359
|
const {filter} = this.props;
|
351
360
|
const currentSelected = this.prepareSelected({defaultValue:this.props.defaultValue,...args});
|
352
|
-
let selected = this.canHandleMultiple ? []:undefined,selectedValuesKeys={};
|
361
|
+
let selected = this.canHandleMultiple() ? []:undefined,selectedValuesKeys={};
|
353
362
|
const itemProps = defaultObj(this.props.itemProps);
|
354
363
|
const itemsData = this.getItemsData(args);
|
355
364
|
Object.map(itemsData,(item,index,_index)=>{
|
@@ -402,12 +411,12 @@ class DropdownComponent extends AppComponent {
|
|
402
411
|
let hasChanged = false;
|
403
412
|
selectOnlyOne = selectOnlyOne === true ? true : false;
|
404
413
|
let newSelected = undefined;
|
405
|
-
if(this.canHandleMultiple){
|
414
|
+
if(this.canHandleMultiple()){
|
406
415
|
newSelected = selectOnlyOne ? [] : [...this.state.selected];
|
407
416
|
}
|
408
417
|
const selectedValuesKeys = selectOnlyOne?{}:{...this.state.selectedValuesKeys};
|
409
418
|
const sVal = this.prepareSelected({defaultValue:value});
|
410
|
-
if(this.canHandleMultiple){
|
419
|
+
if(this.canHandleMultiple()){
|
411
420
|
if(sVal.length !== this.state.selected.length){
|
412
421
|
hasChanged = true;
|
413
422
|
}
|
@@ -436,7 +445,7 @@ class DropdownComponent extends AppComponent {
|
|
436
445
|
}
|
437
446
|
|
438
447
|
selectAll (){
|
439
|
-
if(!this.canHandleMultiple) return;
|
448
|
+
if(!this.canHandleMultiple()) return;
|
440
449
|
const newSelected = [],selectedValuesKeys={};
|
441
450
|
this.state.data.map((item,_index)=>{
|
442
451
|
const key = this.keysRefs[_index];
|
@@ -447,11 +456,11 @@ class DropdownComponent extends AppComponent {
|
|
447
456
|
this.updateSelected({selected:newSelected,selectedValuesKeys,selectedText:this.getSelectedText(newSelected,selectedValuesKeys)});
|
448
457
|
}
|
449
458
|
unselectAll() {
|
450
|
-
if(!this.canHandleMultiple) return;
|
459
|
+
if(!this.canHandleMultiple()) return;
|
451
460
|
this.updateSelected({selected:[],selectedValuesKeys:{},selectedText:''})
|
452
461
|
}
|
453
462
|
unselect (oState){
|
454
|
-
this.updateSelected({...defaultObj(oState),selected:this.canHandleMultiple ?[]:undefined,selectedValuesKeys:{},selectedText:""});
|
463
|
+
this.updateSelected({...defaultObj(oState),selected:this.canHandleMultiple() ?[]:undefined,selectedValuesKeys:{},selectedText:""});
|
455
464
|
}
|
456
465
|
getSelectedValue (){
|
457
466
|
return this.getSelected();
|
@@ -461,7 +470,7 @@ class DropdownComponent extends AppComponent {
|
|
461
470
|
}
|
462
471
|
getSelectedItems (){
|
463
472
|
let ret = {};
|
464
|
-
if(this.canHandleMultiple){
|
473
|
+
if(this.canHandleMultiple()){
|
465
474
|
Object.map(this.state.selected,(value)=>{
|
466
475
|
const nodeKey = this.getNodeFromValue(value);
|
467
476
|
if(!nodeKey.valueKey) return;
|
@@ -654,15 +663,18 @@ class DropdownComponent extends AppComponent {
|
|
654
663
|
UNSAFE_componentWillReceiveProps(nextProps){
|
655
664
|
const {items,defaultValue,selected} = nextProps;
|
656
665
|
const isFunc = typeof nextProps.items == "function";
|
666
|
+
if(nextProps.isLoading === true) return;
|
657
667
|
if(isFunc || !React.areEquals(items,this.props.items)){
|
658
668
|
const nState = this.prepareItems({items,defaultValue,selected});
|
659
669
|
return this.updateSelected(nState,!isFunc);
|
660
670
|
}
|
661
671
|
let value = this.prepareSelected({defaultValue});
|
662
|
-
let areEquals = !this.canHandleMultiple ? this.compare(value,this.state.selected) : false;
|
663
|
-
if(areEquals)
|
664
|
-
|
665
|
-
|
672
|
+
let areEquals = !this.canHandleMultiple() ? this.compare(value,this.state.selected) : false;
|
673
|
+
if(areEquals) {
|
674
|
+
return;
|
675
|
+
}
|
676
|
+
let selectedValuesKeys = {}, newSelected = this.canHandleMultiple() ? [] : value;
|
677
|
+
if(this.canHandleMultiple()){
|
666
678
|
areEquals = value.length === this.state.selected.length;
|
667
679
|
if(areEquals && !value.length){
|
668
680
|
areEquals = true;
|
@@ -771,7 +783,7 @@ class DropdownComponent extends AppComponent {
|
|
771
783
|
const flattenStyle = StyleSheet.flatten(dropdownProps.style) || {};
|
772
784
|
itemContainerProps = defaultObj(itemContainerProps);
|
773
785
|
dropdownProps = defaultObj(dropdownProps);
|
774
|
-
const multiple = this.canHandleMultiple;
|
786
|
+
const multiple = this.canHandleMultiple();
|
775
787
|
const renderTag = multiple && (display == 'tags' || display === 'tag' )? true : false;
|
776
788
|
this.willRenderTag = renderTag;
|
777
789
|
|
@@ -108,7 +108,7 @@ export default class FormSelectField extends Field{
|
|
108
108
|
args.selectedItems = this._field.getSelectedItems();
|
109
109
|
}
|
110
110
|
args.value = this._field.prepareSelected({defaultValue:args.value})
|
111
|
-
if(!this._field.canHandleMultiple && !args.selectedItem){
|
111
|
+
if(!(typeof this._field.canHandleMultiple =='function' && this._field.canHandleMultiple()) && !args.selectedItem){
|
112
112
|
const valueKey = this._field.getValueKey(args.value);
|
113
113
|
if(valueKey && isObj(this._field.state.valuesKeys) && this._field.state.valuesKeys[valueKey]){
|
114
114
|
args.selectedItem = args.item = this._field.state.valuesKeys[valueKey].item;
|
@@ -81,7 +81,6 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,swrOptions,fore
|
|
81
81
|
defaultFields.push(foreignKeyLabel);
|
82
82
|
}
|
83
83
|
const foreignKeyColumnValue = props.defaultValue;
|
84
|
-
const defaultValueRef = React.useRef(props.multiple ? Object.toArray(foreignKeyColumnValue) : foreignKeyColumnValue);
|
85
84
|
let isDisabled = defaultBool(props.disabled,props.readOnly,false);
|
86
85
|
if(!isDisabled && props.readOnly === true){
|
87
86
|
isDisabled = true;
|
@@ -112,17 +111,26 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,swrOptions,fore
|
|
112
111
|
const fetchItemsRef = React.useRef(customFetchItem);
|
113
112
|
fetchItemsRef.current = customFetchItem;
|
114
113
|
swrOptions = Object.assign({},swrOptions);
|
114
|
+
const itemsRef = React.useRef([]);
|
115
|
+
const restOptionsRef = React.useRef({});
|
116
|
+
const fetchedResultRef = React.useRef({});
|
117
|
+
const isMountedRef = React.useRef(false);
|
115
118
|
///@see : https://swr.vercel.app/docs/revalidation#disable-automatic-revalidations
|
116
119
|
const canDisable = isFilter || isDisabled;
|
117
120
|
swrOptions.revalidateOnFocus = canDisable? false : typeof swrOptions.revalidateOnFocus === "boolean" ? swrOptions.revalidateOnFocus : false;
|
121
|
+
swrOptions.revalidateOnMount = typeof swrOptions.revalidateOnMount =="boolean"? swrOptions.revalidateOnMount : true;
|
118
122
|
swrOptions.revalidateIfStale = canDisable? false : typeof swrOptions.revalidateIfStale ==="boolean"? swrOptions.revalidateIfStale : false;
|
119
123
|
swrOptions.revalidateOnReconnect = canDisable ? false : typeof swrOptions.revalidateOnReconnect ==="boolean"? swrOptions.revalidateOnReconnect : false;
|
120
124
|
swrOptions.refreshWhenHidden = canDisable ? false : typeof swrOptions.refreshWhenHidden =="boolean"? swrOptions.refreshWhenHidden : false;
|
125
|
+
swrOptions.dedupingInterval = canDisable ? 24*60*1000 : typeof swrOptions.dedupingInterval ==="number"? dedupingInterval : isMountedRef.current ? 60*1000:undefined;
|
121
126
|
if(canDisable){
|
122
127
|
swrOptions.refreshInterval = 30000*1000*60;
|
123
128
|
}
|
124
|
-
|
125
|
-
|
129
|
+
if(canDisable || typeof swrOptions.isVisible !="function"){
|
130
|
+
swrOptions.isVisible = () =>{
|
131
|
+
return canDisable ? false : !!!Object.size(itemsRef.current,true); //on rafraichit au focus uniquement lorsque la liste des items est vide
|
132
|
+
};
|
133
|
+
}
|
126
134
|
restOptionsRef.current = {foreignKeyTable,foreignKeyColumn,foreignKeyLabel,foreignKeyColumnValue,sort,sortColumn,sortDir,foreignKeyTableObj:fKeyTable};
|
127
135
|
const queryPathKey = isNonNullString(queryPath) ? setQueryParams(queryPath,{isstabledata:1,"stabledathkey":hashKey,foreignKeyColumn:defaultStr(foreignKeyColumn).toLowerCase()}) : null;
|
128
136
|
const onFetchItemsRef = React.useRef();
|
@@ -131,6 +139,8 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,swrOptions,fore
|
|
131
139
|
const fkeyFields = defaultObj(fKeyTable.fields);
|
132
140
|
mutateFetchedItemsRef.current = mutateFetchedItems;
|
133
141
|
const {isLoading:cIsLoading,data:fetchedItems,isValidating,refresh} = useSWR(hasErrors?null:queryPathKey,{
|
142
|
+
isSelectField : true,
|
143
|
+
fieldName : props.name,
|
134
144
|
fetcher : (url,opts1)=>{
|
135
145
|
if(typeof beforeFetchItems ==='function' && beforeFetchItems({fetchOptions}) === false) return Promise.resolve(fetchedResultRef.current);
|
136
146
|
let opts = Object.clone(fetchOptions);
|
@@ -171,11 +181,17 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,swrOptions,fore
|
|
171
181
|
});
|
172
182
|
const isLoading = cIsLoading || isValidating;
|
173
183
|
const items = React.useMemo(()=>{
|
184
|
+
if(isLoading) return itemsRef.current;
|
174
185
|
const fItems = isObj(fetchedItems)? fetchedItems: fetchedResultRef.current;
|
175
|
-
if(!isObj(fItems) || !Array.isArray(fItems.items))
|
176
|
-
|
177
|
-
|
186
|
+
if(!isObj(fItems) || !Array.isArray(fItems.items)) {
|
187
|
+
itemsRef.current = [];
|
188
|
+
} else {
|
189
|
+
itemsRef.current = fItems.items;
|
190
|
+
}
|
191
|
+
return itemsRef.current;
|
192
|
+
},[fetchedItems,isLoading]);
|
178
193
|
React.useEffect(()=>{
|
194
|
+
isMountedRef.current = true;
|
179
195
|
if(!isLoading && !Object.size(items,true)){
|
180
196
|
refresh();
|
181
197
|
}
|
@@ -261,6 +277,7 @@ const TableDataSelectField = React.forwardRef(({foreignKeyColumn,swrOptions,fore
|
|
261
277
|
dialogProps.title = ttitle;
|
262
278
|
return <Dropdown
|
263
279
|
{...props}
|
280
|
+
fetchOptions = {fetchOptions}
|
264
281
|
items = {items}
|
265
282
|
isFilter = {isFilter}
|
266
283
|
showAdd = {showAdd}
|
@@ -20,14 +20,17 @@ if(!isObj(APP.FormsManager)){
|
|
20
20
|
});
|
21
21
|
observable(APP.FormsManager);
|
22
22
|
addObserver(APP.FormsManager);
|
23
|
+
const fManager = APP.FormsManager;
|
23
24
|
APP.FormsManager.on("mount",(formName,formObject)=>{
|
24
25
|
formObject._fields = defaultObj(formObject._fields);
|
25
26
|
formObject._actions= defaultObj(formObject._actions);
|
26
27
|
APP.FormsManager.forms[formName] = formObject;
|
27
28
|
APP.trigger("MOUNT_FORM",formName);
|
28
|
-
})
|
29
|
+
});
|
30
|
+
fManager.on("unmount",(formName)=>{
|
29
31
|
delete APP.FormsManager.forms[formName];
|
30
|
-
})
|
32
|
+
});
|
33
|
+
fManager.on("registerField",(fieldName,formName,fieldObj)=>{
|
31
34
|
if(fieldObj && isObservable(fieldObj)){
|
32
35
|
APP.FormsManager.forms[formName] = defaultObj(APP.FormsManager.forms[formName]);
|
33
36
|
APP.FormsManager.forms[formName]._fields = defaultObj(APP.FormsManager.forms[formName]._fields);
|
@@ -36,13 +39,15 @@ if(!isObj(APP.FormsManager)){
|
|
36
39
|
let formField = form._fields[fieldName];
|
37
40
|
if(isFunction(formField.onRegister)) formField.onRegister(fieldName,fieldObj);
|
38
41
|
}
|
39
|
-
})
|
42
|
+
});
|
43
|
+
fManager.on("unregisterField",(fieldName,formName)=>{
|
40
44
|
if(isNonNullString(fieldName) && isNonNullString(formName)){
|
41
45
|
APP.FormsManager.forms[formName] = defaultObj(APP.FormsManager.forms[formName]);
|
42
46
|
APP.FormsManager.forms[formName]._fields = defaultObj(APP.FormsManager.forms[formName]._fields);
|
43
47
|
delete APP.FormsManager.forms[formName]._fields[fieldName];
|
44
48
|
}
|
45
|
-
})
|
49
|
+
});
|
50
|
+
fManager.on("mountAction",(formName,actionObj)=>{
|
46
51
|
if(!isNonNullString(formName) || !isObj(actionObj)) {
|
47
52
|
console.error("MSForm Action, l'action, nom du formulaire non définit ",formName,actionObj)
|
48
53
|
return;
|
@@ -50,7 +55,8 @@ if(!isObj(APP.FormsManager)){
|
|
50
55
|
APP.FormsManager.actions = defaultObj(APP.FormsManager.actions);
|
51
56
|
APP.FormsManager.actions[formName] = defaultObj(APP.FormsManager.actions[formName]);
|
52
57
|
APP.FormsManager.actions[formName][actionObj.getId()] = actionObj;
|
53
|
-
})
|
58
|
+
});
|
59
|
+
fManager.on("unmountAction",(formName,actionId)=>{
|
54
60
|
if(!isNonNullString(formName) || !isNonNullString(actionId)) return;
|
55
61
|
if(!isObj(APP.FormsManager.actions) || !isObj(APP.FormsManager.actions[formName])) return;
|
56
62
|
delete APP.FormsManager.actions[formName][actionId]
|
@@ -1,7 +1,7 @@
|
|
1
1
|
import React from "$react";
|
2
2
|
import { prepareItems as customPrepareItems} from "./utils";
|
3
3
|
import {defaultFunc,defaultBool,defaultDecimal} from "$cutils";
|
4
|
-
import Dimensions,{
|
4
|
+
import Dimensions,{usePageDimensions} from "$cdimensions";
|
5
5
|
import {grid} from "$theme";
|
6
6
|
/**** retourne le contexte associé au composant List
|
7
7
|
|
@@ -25,7 +25,7 @@ export const useList = ({items,filter,prepareItems,...props})=>{
|
|
25
25
|
|
26
26
|
export const useGetNumColumns = ({windowWidth,numColumns,responsive})=>{
|
27
27
|
responsive = defaultBool(responsive,false);
|
28
|
-
const dimensions = responsive
|
28
|
+
const dimensions = usePageDimensions(responsive)["window"];
|
29
29
|
if(responsive){
|
30
30
|
numColumns = grid.numColumns(windowWidth);
|
31
31
|
} else {
|
@@ -56,7 +56,11 @@ class _Menu extends AppComponent {
|
|
56
56
|
opacityAnimation: new Animated.Value(0),
|
57
57
|
scaleAnimation: new Animated.ValueXY({ x: 0, y: 0 }),
|
58
58
|
});
|
59
|
-
this._events
|
59
|
+
Object.defineProperties(this._events,{
|
60
|
+
RESIZE_PAGE : {
|
61
|
+
value : this.handleDismiss.bind(this),
|
62
|
+
}
|
63
|
+
});
|
60
64
|
}
|
61
65
|
|
62
66
|
componentDidUpdate(prevProps) {
|
@@ -153,10 +157,8 @@ class _Menu extends AppComponent {
|
|
153
157
|
} else {
|
154
158
|
BackHandler.removeEventListener('hardwareBackPress', this.handleDismiss);
|
155
159
|
}
|
156
|
-
|
157
160
|
APP.off(RESIZE_PAGE,this._events.RESIZE_PAGE);
|
158
161
|
this.clearEvents();
|
159
|
-
|
160
162
|
this.isBrowser() &&
|
161
163
|
document.removeEventListener('keyup', this.handleKeypress);
|
162
164
|
};
|
@@ -1,4 +1,4 @@
|
|
1
|
-
import {defaultStr,isNumber,isPromise,defaultVal,extendObj,defaultObj,uniqid,isObj,isObjOrArray} from "$cutils";
|
1
|
+
import {defaultStr,isNumber,isPromise,defaultVal,extendObj,defaultObj,uniqid,isObj,isPlainObject,isObjOrArray} from "$cutils";
|
2
2
|
import {FormData} from "$ecomponents/Form";
|
3
3
|
import FormDataScreen from "./FormData";
|
4
4
|
import ScreenContainer from "./Screen";
|
@@ -319,7 +319,6 @@ export default class TableDataScreenComponent extends FormDataScreen{
|
|
319
319
|
delete fields[i];
|
320
320
|
return;
|
321
321
|
}
|
322
|
-
|
323
322
|
}
|
324
323
|
if(rest.archived === true){
|
325
324
|
currentField.readOnly = true;
|
@@ -1,8 +1,8 @@
|
|
1
1
|
import { Asset} from 'expo-asset';
|
2
|
-
import {isObj,isNonNullString} from "$cutils";
|
2
|
+
import {isObj,isNonNullString,defaultStr} from "$cutils";
|
3
3
|
|
4
4
|
export const loadAsset = async (asset)=>{
|
5
|
-
if(isObj(asset) && isAssets(asset)){
|
5
|
+
if(isObj(asset) && (isAssets(asset) || isDocumentPickerAsset(asset))){
|
6
6
|
return Promise.resolve(asset);
|
7
7
|
}
|
8
8
|
return await new Promise((resolve,reject)=>{
|
@@ -24,5 +24,12 @@ export const load = loadAsset;
|
|
24
24
|
export const isAssets = (asset,staticAssets)=>{
|
25
25
|
return isObj(asset) && "width" in (asset) && "height" in (asset) && isNonNullString(asset.uri) && (staticAssets ? asset.uri.contains("/static/"):true);
|
26
26
|
}
|
27
|
+
export const isDocumentPickerAsset = (asset)=>{
|
28
|
+
if(isObj(asset) && assets.lastModified && assets.mimeType && assets.name && isNonNullString(assets.uri)){
|
29
|
+
asset.localUri = defaultStr(asset.localUri,asset.uri);
|
30
|
+
return true;
|
31
|
+
}
|
32
|
+
return false;
|
33
|
+
}
|
27
34
|
export const isValid = isAssets;
|
28
35
|
export const isValidAssets = isAssets;
|