@fto-consult/expo-ui 2.2.0 → 2.2.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.2.
|
|
3
|
+
"version": "2.2.2",
|
|
4
4
|
"description": "Bibliothèque de composants UI Expo,react-native",
|
|
5
5
|
"main": "index.js",
|
|
6
6
|
"scripts": {
|
|
@@ -62,7 +62,7 @@
|
|
|
62
62
|
"@expo/html-elements": "^0.2.0",
|
|
63
63
|
"@expo/metro-config": "^0.4.0",
|
|
64
64
|
"@expo/webpack-config": "^0.17.2",
|
|
65
|
-
"@fto-consult/common": "^1.11.
|
|
65
|
+
"@fto-consult/common": "^1.11.2",
|
|
66
66
|
"@gorhom/portal": "^1.0.14",
|
|
67
67
|
"@react-native-async-storage/async-storage": "~1.17.3",
|
|
68
68
|
"@react-native-community/datetimepicker": "6.5.2",
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
// license that can be found in the LICENSE file.
|
|
4
4
|
|
|
5
5
|
import Date from "./DatePickerInput";
|
|
6
|
-
import Time from "./Time";
|
|
6
|
+
import Time,{parseTime} from "./Time";
|
|
7
7
|
import React from "$react";
|
|
8
8
|
import PropTypes from "prop-types";
|
|
9
9
|
import {defaultObj,isNumber,defaultNumber,defaultStr,defaultBool,isNonNullString} from "$utils";
|
|
@@ -17,8 +17,7 @@ export default function DateTimePickerComponent({left,withSeconds,right,format,d
|
|
|
17
17
|
testID = defaultStr(testID,"RN_DateTimeComponent")
|
|
18
18
|
const anchorTimeProps = defaultObj(timeProps.anchorProps);
|
|
19
19
|
const timePropsContainerProps = defaultObj(timeProps.containerProps);
|
|
20
|
-
const
|
|
21
|
-
const dateObj = defaultValueRef.current;
|
|
20
|
+
const dateObj = toDateObj(defaultValue);
|
|
22
21
|
if(isNonNullString(format)){
|
|
23
22
|
format = format.trim().split(" ");
|
|
24
23
|
if(!isNonNullString(dateFormat)){
|
|
@@ -28,9 +27,18 @@ export default function DateTimePickerComponent({left,withSeconds,right,format,d
|
|
|
28
27
|
timeFormat = format[1].trim();
|
|
29
28
|
}
|
|
30
29
|
}
|
|
31
|
-
const changeDateArgsRef = React.useRef({
|
|
32
|
-
|
|
30
|
+
const changeDateArgsRef = React.useRef({
|
|
31
|
+
date : dateObj,
|
|
32
|
+
});
|
|
33
|
+
const getTimeValue = (date)=>{
|
|
34
|
+
date = DateLib.isValid(date)? date : new Date();
|
|
35
|
+
const sqlTime = date.toSQLTimeFormat();
|
|
36
|
+
return sqlTime.substring(0,withSeconds ?sqlTime.length :5);
|
|
37
|
+
}
|
|
38
|
+
const timeDefaultValue = getTimeValue(dateObj);
|
|
39
|
+
const changedTimeArgsRef = React.useRef({...defaultObj(parseTime(timeDefaultValue,withSeconds))});
|
|
33
40
|
withSeconds = defaultBool(timeProps.withSeconds,withSeconds,true);
|
|
41
|
+
|
|
34
42
|
const maxWidth = 120;//withSeconds ? 120 : 120;
|
|
35
43
|
const callOnChange = ()=>{
|
|
36
44
|
if(onChange){
|
|
@@ -40,11 +48,12 @@ export default function DateTimePickerComponent({left,withSeconds,right,format,d
|
|
|
40
48
|
const date = dObj.date;
|
|
41
49
|
date.setHours(tObj.hours);
|
|
42
50
|
date.setMinutes(tObj.minutes);
|
|
43
|
-
date.setSeconds(defaultNumber(tObj.seconds))
|
|
51
|
+
date.setSeconds(withSeconds?defaultNumber(tObj.seconds):0);
|
|
52
|
+
const sqlDate = date.toSQLDateFormat();
|
|
44
53
|
const sqlTime = date.toSQLTimeFormat();
|
|
45
|
-
const time =
|
|
54
|
+
const time = getTimeValue(date);
|
|
46
55
|
const value = date.toFormat(defaultStr(dateFormat,DateLib.SQLDateFormat))+" "+time;
|
|
47
|
-
const args = {...dObj,...tObj,dateObject:date,date,sqlDateTime:date.toSQLDateTimeFormat(),value,sqlTime,time};
|
|
56
|
+
const args = {...dObj,...tObj,dateObject:date,sqlDate,date,sqlDateTime:date.toSQLDateTimeFormat(),value,sqlTime,time};
|
|
48
57
|
onChange(args);
|
|
49
58
|
}
|
|
50
59
|
}
|
|
@@ -67,7 +76,7 @@ export default function DateTimePickerComponent({left,withSeconds,right,format,d
|
|
|
67
76
|
const r = typeof right =='function'? right(p): React.isValidElement(right)? right : null;
|
|
68
77
|
return <>
|
|
69
78
|
<Time
|
|
70
|
-
defaultValue = {
|
|
79
|
+
defaultValue = {timeDefaultValue}
|
|
71
80
|
disabled = {disabled}
|
|
72
81
|
readOnly = {readOnly}
|
|
73
82
|
testID={testID+"_Time"}
|
|
@@ -7,15 +7,15 @@ import PropTypes from "prop-types";
|
|
|
7
7
|
import theme,{styles} from "$theme";
|
|
8
8
|
import { locale } from "./utils";
|
|
9
9
|
import { TouchableRipple } from "react-native-paper";
|
|
10
|
-
const getDate = (hours,minutes,seconds)=>{
|
|
10
|
+
export const getDate = (hours,minutes,seconds)=>{
|
|
11
11
|
return new Date(2000, 1, 1, defaultDecimal(hours), defaultDecimal(minutes),defaultDecimal(seconds))
|
|
12
12
|
}
|
|
13
|
-
const compareTimeState = (a,b,ignoreVisible)=>{
|
|
13
|
+
export const compareTimeState = (a,b,ignoreVisible)=>{
|
|
14
14
|
if(!a || !b) return false;
|
|
15
15
|
if(ignoreVisible !== true && a.visible !== b.visible) return false;
|
|
16
16
|
return a.hours === b.hours && a.minutes === b.minutes;
|
|
17
17
|
}
|
|
18
|
-
|
|
18
|
+
export const parseTime = (value,withSeconds)=>{
|
|
19
19
|
if(!isNonNullString(value)) return undefined;
|
|
20
20
|
let split = value.trim().split(":");
|
|
21
21
|
let ret = {
|
|
@@ -29,7 +29,7 @@ const compareTimeState = (a,b,ignoreVisible)=>{
|
|
|
29
29
|
ret.value = timeToString(ret,withSeconds);
|
|
30
30
|
return ret;
|
|
31
31
|
}
|
|
32
|
-
|
|
32
|
+
export const timeToString = (value,withSeconds)=>{
|
|
33
33
|
if(!isObj(value)) return undefined;
|
|
34
34
|
let {hours,minutes,seconds} = value;
|
|
35
35
|
if(hours ===undefined && minutes === undefined) return undefined;
|
|
@@ -43,7 +43,7 @@ const compareTimeState = (a,b,ignoreVisible)=>{
|
|
|
43
43
|
}
|
|
44
44
|
return value.substring(0,5);
|
|
45
45
|
}
|
|
46
|
-
|
|
46
|
+
export default function TimePickerComponent (props){
|
|
47
47
|
let {right:customRight,upper,anchorProps,dialogProps,withLabel,containerProps,mode,onChange,withSeconds,cancelLabel,confirmLabel,label,text,upperCase,defaultValue,disabled,editable,withModal,readOnly,...rest} = props;
|
|
48
48
|
rest = defaultObj(rest);
|
|
49
49
|
const isEditable = disabled !== true && readOnly !== true && editable !== false?true : false;
|
|
@@ -386,7 +386,9 @@ export const prepareFilters = (filtersToPrepare,opts)=>{
|
|
|
386
386
|
let sp = defaultStr(f.value);
|
|
387
387
|
if(sp){
|
|
388
388
|
sp = sp.split("=>");
|
|
389
|
-
|
|
389
|
+
const isValid1 = DateLib.isValidSQLDate(sp[0]) || DateLib.isValidSQLDateTime(sp[0]);
|
|
390
|
+
const isValid2 = DateLib.isValidSQLDate(sp[1]) || DateLib.isValidSQLDateTime(sp[1]);
|
|
391
|
+
if(isValid1 && isValid2){
|
|
390
392
|
filters[f.operator].push({
|
|
391
393
|
[f.field] : {$gte:sp[0]}
|
|
392
394
|
})
|