@fto-consult/expo-ui 2.3.2 → 2.3.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.
- package/index.js +3 -3
- package/package.json +1 -1
- package/src/components/Chip/index.js +11 -6
- package/src/components/Datagrid/Accordion/Row.js +1 -1
- package/src/components/Datagrid/Common/Common.js +2 -2
- package/src/components/Date/DateTime.js +3 -3
- package/src/components/Filter/index.js +4 -1
- package/src/components/Filter/utils.js +55 -0
package/index.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { registerRootComponent } from "expo";
|
|
2
|
-
import {Platform } from 'react-native';
|
|
2
|
+
import {AppRegistry, Platform } from 'react-native';
|
|
3
3
|
import { createRoot } from 'react-dom/client';
|
|
4
4
|
import appConfig from "$capp/config";
|
|
5
5
|
import { activateKeepAwake } from 'expo-keep-awake';
|
|
@@ -17,8 +17,8 @@ export default function ExpoUIApp (options){
|
|
|
17
17
|
options = options && typeof options =='object' && !Array.isArray(options)? options : {};
|
|
18
18
|
appConfig.current = options.config;
|
|
19
19
|
const App = require('./src/App').default(options);
|
|
20
|
-
if (Platform.OS === "web") {
|
|
21
|
-
const root = createRoot(document.getElementById("root")
|
|
20
|
+
if (false && Platform.OS === "web") {
|
|
21
|
+
const root = createRoot(document.getElementById("root") || document.getElementById("main"));
|
|
22
22
|
root.render(<App />);
|
|
23
23
|
} else {
|
|
24
24
|
registerRootComponent(App);
|
package/package.json
CHANGED
|
@@ -27,13 +27,15 @@ const ChipComponent = React.forwardRef(({
|
|
|
27
27
|
onLongPress,
|
|
28
28
|
onClose,
|
|
29
29
|
closeIcon,
|
|
30
|
-
|
|
30
|
+
labelStyle,
|
|
31
|
+
labelProps,
|
|
31
32
|
style,
|
|
32
33
|
testID,
|
|
33
34
|
selectedColor,
|
|
34
35
|
ellipsizeMode,
|
|
35
36
|
...rest
|
|
36
37
|
},ref) => {
|
|
38
|
+
labelProps = Object.assign({},labelProps);
|
|
37
39
|
testID =defaultStr(testID,"RN_ChipComponent");
|
|
38
40
|
const { current: elevation } = React.useRef(
|
|
39
41
|
new Animated.Value(0)
|
|
@@ -66,7 +68,7 @@ const ChipComponent = React.forwardRef(({
|
|
|
66
68
|
const borderColor =
|
|
67
69
|
mode === 'outlined'? (selectedColor !== undefined ? selectedColor : Colors.setAlpha(dark ? white : black,0.29)) : backgroundColor;
|
|
68
70
|
const textColor = Colors.isValid(customColor)?customColor
|
|
69
|
-
: Colors.setAlpha(selectedColor !== undefined ? selectedColor : colors.text,0.87);
|
|
71
|
+
: Colors.setAlpha(selectedColor !== undefined ? selectedColor : theme.colors.text,0.87);
|
|
70
72
|
const iconColor = Colors.setAlpha(textColor,theme.ALPHA);
|
|
71
73
|
|
|
72
74
|
const backgroundColorString = typeof backgroundColor === 'string' ? backgroundColor : defaultBackgroundColor;
|
|
@@ -173,7 +175,8 @@ const ChipComponent = React.forwardRef(({
|
|
|
173
175
|
selectable={false}
|
|
174
176
|
numberOfLines={1}
|
|
175
177
|
testID={testID+"_Text"}
|
|
176
|
-
|
|
178
|
+
{...labelProps}
|
|
179
|
+
style={StyleSheet.flatten([
|
|
177
180
|
styles.text,
|
|
178
181
|
{
|
|
179
182
|
...theme.fonts.regular,
|
|
@@ -181,8 +184,9 @@ const ChipComponent = React.forwardRef(({
|
|
|
181
184
|
marginHorizontal : 4,
|
|
182
185
|
marginLeft: avatar || icon || selected ? 4 : 8,
|
|
183
186
|
},
|
|
184
|
-
|
|
185
|
-
|
|
187
|
+
labelProps.style,
|
|
188
|
+
labelStyle,
|
|
189
|
+
])}
|
|
186
190
|
ellipsizeMode={ellipsizeMode}
|
|
187
191
|
>
|
|
188
192
|
{children}
|
|
@@ -332,7 +336,7 @@ ChipComponent.propTypes = {
|
|
|
332
336
|
/**
|
|
333
337
|
* Style of chip's text
|
|
334
338
|
*/
|
|
335
|
-
|
|
339
|
+
labelStyle: StyleProps,
|
|
336
340
|
style: StyleProps,
|
|
337
341
|
|
|
338
342
|
/**
|
|
@@ -347,4 +351,5 @@ ChipComponent.propTypes = {
|
|
|
347
351
|
* Ellipsize Mode for the children text
|
|
348
352
|
*/
|
|
349
353
|
ellipsizeMode: PropTypes.object,
|
|
354
|
+
labelProps : PropTypes.object,
|
|
350
355
|
};
|
|
@@ -1554,7 +1554,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1554
1554
|
v1.map((v)=>{
|
|
1555
1555
|
for(let i in columnDef.items){
|
|
1556
1556
|
let it = columnDef.items[i];
|
|
1557
|
-
if(isObj(it) &&
|
|
1557
|
+
if(isObj(it) && defaultVal(it.code,i) == v){
|
|
1558
1558
|
_render+=(_render?arrayValueSeparator:"")+defaultStr(it.label,it.text,v);
|
|
1559
1559
|
} else if(isNonNullString(it) && i == v){
|
|
1560
1560
|
_render+=(_render?arrayValueSeparator:"")+it;
|
|
@@ -1567,7 +1567,7 @@ export default class CommonDatagridComponent extends AppComponent {
|
|
|
1567
1567
|
} else {
|
|
1568
1568
|
for(let i in columnDef.items){
|
|
1569
1569
|
let it = columnDef.items[i];
|
|
1570
|
-
if(isObj(it) &&
|
|
1570
|
+
if(isObj(it) && defaultVal(it.code,i) == v1){
|
|
1571
1571
|
_render =defaultStr(it.label,it.text,v1);
|
|
1572
1572
|
break;
|
|
1573
1573
|
} else if(isNonNullString(it) && i == v1){
|
|
@@ -41,16 +41,16 @@ export default function DateTimePickerComponent({left,isPeriodAction,withSeconds
|
|
|
41
41
|
timeFormat = format[1].trim();
|
|
42
42
|
}
|
|
43
43
|
}
|
|
44
|
-
const changeDateArgsRef =
|
|
44
|
+
const changeDateArgsRef = {current:{
|
|
45
45
|
date : dateObj,
|
|
46
|
-
}
|
|
46
|
+
}}
|
|
47
47
|
const getTimeValue = (date)=>{
|
|
48
48
|
date = DateLib.isValid(date)? date : new Date();
|
|
49
49
|
const sqlTime = date.toSQLTimeFormat();
|
|
50
50
|
return sqlTime.substring(0,withSeconds ?sqlTime.length :5);
|
|
51
51
|
}
|
|
52
52
|
const timeDefaultValue = getTimeValue(dateObj);
|
|
53
|
-
const changedTimeArgsRef =
|
|
53
|
+
const changedTimeArgsRef = {current:{...defaultObj(parseTime(timeDefaultValue,withSeconds))}};
|
|
54
54
|
withSeconds = defaultBool(timeProps.withSeconds,withSeconds,true);
|
|
55
55
|
|
|
56
56
|
const maxWidth = 120;//withSeconds ? 120 : 120;
|
|
@@ -506,7 +506,10 @@ export default class Filter extends AppComponent {
|
|
|
506
506
|
style : [styles.bold,styles.noVerticalPadding],
|
|
507
507
|
}:null],
|
|
508
508
|
...Object.mapToArray(actions,(x,j)=>{
|
|
509
|
-
|
|
509
|
+
if(ignoreDefaultValue && !periodActions[j]){
|
|
510
|
+
return null;
|
|
511
|
+
}
|
|
512
|
+
let checked = j === action?true : false;
|
|
510
513
|
if(checked && (isNumber(defaultValue) || isNonNullString(defaultValue))) {
|
|
511
514
|
let hasS = false;
|
|
512
515
|
let act = defaultStr(action).toLowerCase();
|
|
@@ -402,6 +402,7 @@ export const prepareFilters = (filtersToPrepare,opts)=>{
|
|
|
402
402
|
filters[f.operator].push(ob)
|
|
403
403
|
}
|
|
404
404
|
});
|
|
405
|
+
const f = convertToSQL(filters);
|
|
405
406
|
return convToSQL ? convertToSQL(filters) : filters;
|
|
406
407
|
}
|
|
407
408
|
|
|
@@ -495,4 +496,58 @@ const operatorsMap = {
|
|
|
495
496
|
$nin : 'NOT IN',
|
|
496
497
|
$eq: '=',
|
|
497
498
|
$regex : "LIKE"
|
|
499
|
+
}
|
|
500
|
+
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
* @param {*} operand
|
|
504
|
+
* @param {*} operator
|
|
505
|
+
* @param {*} field
|
|
506
|
+
*
|
|
507
|
+
* Return the operand in right format
|
|
508
|
+
*/
|
|
509
|
+
export const getTyppedOperand = (operand, operator, field) => {
|
|
510
|
+
if (typeof operand === 'string') { // wrap strings in double quots
|
|
511
|
+
return "'" +(operand) + "'"
|
|
512
|
+
} else if (operator === 'IN' || operator =='NOT IN') { // wrap IN arguments in brackers
|
|
513
|
+
operand = Array.isArray(operand)? operand.map(op => getTyppedOperand(op, null, null))
|
|
514
|
+
.join(', '): operand;
|
|
515
|
+
return '(' + operand + ')'
|
|
516
|
+
} else if (!isNonNullString(field) && Array.isArray(operand)) { // AND or OR elements
|
|
517
|
+
// recursively call 'buildWhereElement' for nested elements
|
|
518
|
+
// join each element with operator AND or OR
|
|
519
|
+
return operand.reduce((prev, curr) => {
|
|
520
|
+
return [...prev, buildWhereElement(curr)]
|
|
521
|
+
}, []).join(' ' + operator + ' ')
|
|
522
|
+
} else {
|
|
523
|
+
return operand
|
|
524
|
+
}
|
|
525
|
+
}
|
|
526
|
+
|
|
527
|
+
/**
|
|
528
|
+
*
|
|
529
|
+
* @param {*} elem
|
|
530
|
+
*
|
|
531
|
+
* Return element of WHERE clause
|
|
532
|
+
*/
|
|
533
|
+
export const buildWhereElement = (elem) => {
|
|
534
|
+
const { field, operator, operand } = elem
|
|
535
|
+
if (!isNonNullString(field)) { // nested WHERE element
|
|
536
|
+
return '(' + getTyppedOperand(operand, operator, field) + ')'
|
|
537
|
+
} else { // simple WHERE element
|
|
538
|
+
return field + ' ' + operator + ' ' + getTyppedOperand(operand, operator, field)
|
|
539
|
+
}
|
|
540
|
+
}
|
|
541
|
+
|
|
542
|
+
/**** construit une requête Where à partir des filtres préparé dans le tableau whereClausePrepared
|
|
543
|
+
* @see : https://github.com/gordonBusyman/mongo-to-sql-converter
|
|
544
|
+
* @parm {array} whereClausePrepared, les filtres préparés avec la méthode prepareFilters puis convertis avec la fonction convertToSQL
|
|
545
|
+
@return {string}, la requête Where correspondante
|
|
546
|
+
*/
|
|
547
|
+
export const buildWhere = (whereClausePrepared)=>{
|
|
548
|
+
if(!Array.isArray(whereClausePrepared)) return null;
|
|
549
|
+
// build WHERE string clause by adding each element of array to it, separated with AND
|
|
550
|
+
return whereClausePrepared.reduce((prev, curr) => [
|
|
551
|
+
...prev, buildWhereElement(curr)
|
|
552
|
+
], []).join(' AND ');
|
|
498
553
|
}
|