@fto-consult/expo-ui 2.3.5 → 2.4.0
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
|
@@ -20,6 +20,7 @@ import {ACTION_ICON_SIZE} from "$ecomponents/AppBar";
|
|
|
20
20
|
import DialogFooter from "./DialogFooter";
|
|
21
21
|
import { Dimensions } from "react-native";
|
|
22
22
|
import Surface from "$ecomponents/Surface";
|
|
23
|
+
import stableHash from "stable-hash";
|
|
23
24
|
|
|
24
25
|
export const FOOTER_HEIGHT = 50;
|
|
25
26
|
export const HEADER_HEIGHT = 50;
|
|
@@ -307,14 +308,14 @@ DialogComponent.propTypes= {
|
|
|
307
308
|
}
|
|
308
309
|
|
|
309
310
|
|
|
310
|
-
export const DialogControlledComponent = React.forwardRef((props,ref)=>{
|
|
311
|
-
const [visible,setVisible] = React.useStateIfMounted(defaultBool(
|
|
311
|
+
export const DialogControlledComponent = React.forwardRef(({visible:dVisible,...props},ref)=>{
|
|
312
|
+
const [visible,setVisible] = React.useStateIfMounted(defaultBool(dVisible,false));
|
|
312
313
|
const {onDismiss,onClose,onVisibilityChanged,...rest} = props;
|
|
313
314
|
React.useEffect(()=>{
|
|
314
|
-
if(typeof
|
|
315
|
-
setVisible(
|
|
315
|
+
if(typeof dVisible =='boolean' && dVisible !== visible){
|
|
316
|
+
setVisible(dVisible);
|
|
316
317
|
}
|
|
317
|
-
},[
|
|
318
|
+
},[dVisible])
|
|
318
319
|
const close = x=> setVisible(false);
|
|
319
320
|
const open = x => setVisible(true);
|
|
320
321
|
const isOpen=x=>visible,isClosed = x=>!visible;
|
|
@@ -88,6 +88,12 @@ export default class Filter extends AppComponent {
|
|
|
88
88
|
Object.defineProperties(this,{
|
|
89
89
|
fireFilterSearch : {
|
|
90
90
|
value : this.filterValidationTimeout ? debounce(this.fireValueChanged.bind(this),this.filterValidationTimeout) : this.fireValueChanged.bind(this),
|
|
91
|
+
},
|
|
92
|
+
isInitializedRef : {
|
|
93
|
+
value : {current:false}
|
|
94
|
+
},
|
|
95
|
+
previousRef : {
|
|
96
|
+
value : {current : null}
|
|
91
97
|
}
|
|
92
98
|
})
|
|
93
99
|
extendObj(this.state,{
|
|
@@ -134,7 +140,7 @@ export default class Filter extends AppComponent {
|
|
|
134
140
|
if(JSON.stringify(this.state.defaultValue) === JSON.stringify(arg.value)){
|
|
135
141
|
return;
|
|
136
142
|
}
|
|
137
|
-
this.setState({
|
|
143
|
+
this.setState({defaultValue:arg.value},()=>{
|
|
138
144
|
this.callOnValidate(arg);
|
|
139
145
|
if(!isNumber(this.filterValidationTimeout)){
|
|
140
146
|
this.filterValidationTimeout = 0;
|
|
@@ -178,7 +184,7 @@ export default class Filter extends AppComponent {
|
|
|
178
184
|
}
|
|
179
185
|
fireValueChanged (forceRun){
|
|
180
186
|
if(this.willRunManually() && !forceRun) return;
|
|
181
|
-
let {defaultValue:value,
|
|
187
|
+
let {defaultValue:value,action,ignoreCase,operator} = this.state;
|
|
182
188
|
let force = forceRun ===true ? true : false;
|
|
183
189
|
if(!isObjOrArray(value) && (isNullOrEmpty(value,true) || value ==='undefined') ){
|
|
184
190
|
value = undefined;
|
|
@@ -189,18 +195,17 @@ export default class Filter extends AppComponent {
|
|
|
189
195
|
if(action =="$today" || action =='$yesterday'){
|
|
190
196
|
force = true;
|
|
191
197
|
}
|
|
192
|
-
|
|
193
|
-
current = {value,operator,action,ignoreCase};
|
|
198
|
+
const prev = JSON.stringify(defaultObj(this.previousRef.current)), current = {value,operator,action,ignoreCase};
|
|
194
199
|
let tV = isArray(value) && value.length <= 0 ? undefined : value;
|
|
195
|
-
|
|
196
|
-
if(prev == "{}" && (isNullOrEmpty(tV) || value === 0) && (!
|
|
200
|
+
this.isInitializedRef.current = this.props.dynamicRendered || this.isInitializedRef.current;
|
|
201
|
+
if(prev == "{}" && (isNullOrEmpty(tV) || value === 0) && (!this.isInitializedRef.current) && (force !== true)) {
|
|
197
202
|
return this;
|
|
198
203
|
}
|
|
199
204
|
if(prev == JSON.stringify(current) && (force !== true)){
|
|
200
205
|
return this;
|
|
201
206
|
}
|
|
202
|
-
this.
|
|
203
|
-
this.
|
|
207
|
+
this.isInitializedRef.current = true;
|
|
208
|
+
this.previousRef.current = current;
|
|
204
209
|
if(isFunction(this.props.onChange)){
|
|
205
210
|
let selector = {};
|
|
206
211
|
selector[this.props.field] = action;
|
|
@@ -353,7 +358,7 @@ export default class Filter extends AppComponent {
|
|
|
353
358
|
})
|
|
354
359
|
}
|
|
355
360
|
clearFilter(event){
|
|
356
|
-
this.setState({defaultValue:undefined
|
|
361
|
+
this.setState({defaultValue:undefined},()=>{
|
|
357
362
|
this.callOnValidate();
|
|
358
363
|
this.fireValueChanged(true);
|
|
359
364
|
let {onClearFilter,onResetFilter} = this.props;
|
|
@@ -21,6 +21,7 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
|
|
|
21
21
|
const {closeAction,onDismiss} = props;
|
|
22
22
|
const context = {
|
|
23
23
|
open : (props)=>{
|
|
24
|
+
if(state.visible) return;
|
|
24
25
|
let sData = {};
|
|
25
26
|
if(formRef.current && formRef.current.formDataContext && formRef.current.formDataContext.getData){
|
|
26
27
|
sData.data = formRef.current.formDataContext.getData();
|
|
@@ -28,6 +29,7 @@ const FormDataDialogProvider = React.forwardRef((props,innerRef)=>{
|
|
|
28
29
|
return setState({...state,...sData,onDismiss:undefined,...defaultObj(props),visible:true})
|
|
29
30
|
},
|
|
30
31
|
close : (props)=>{
|
|
32
|
+
if(!state.visible) return;
|
|
31
33
|
setState({...state,...defaultObj(props),visible:false});
|
|
32
34
|
},
|
|
33
35
|
};
|