@onehat/ui 0.3.60 → 0.3.66
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 +1 -1
- package/src/Components/Form/Field/Combo/Combo.js +11 -6
- package/src/Components/Form/Field/Input.js +6 -1
- package/src/Components/Form/Field/TextArea.js +3 -0
- package/src/Components/Form/Form.js +7 -3
- package/src/Components/Grid/Grid.js +36 -34
- package/src/Components/Hoc/withAlert.js +1 -1
- package/src/Components/index.js +2 -0
- package/src/PlatformImports/Web/Attachments.js +1 -0
package/package.json
CHANGED
|
@@ -38,6 +38,7 @@ export function ComboComponent(props) {
|
|
|
38
38
|
isEditor = false,
|
|
39
39
|
isDisabled = false,
|
|
40
40
|
tooltipPlacement = 'bottom',
|
|
41
|
+
placeholder,
|
|
41
42
|
onRowPress,
|
|
42
43
|
|
|
43
44
|
// withComponent
|
|
@@ -470,11 +471,12 @@ export function ComboComponent(props) {
|
|
|
470
471
|
borderTopRightRadius={0}
|
|
471
472
|
borderBottomRightRadius={0}
|
|
472
473
|
fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
|
|
474
|
+
color={_.isEmpty(textInputValue) ? 'trueGray.400' : '#000'}
|
|
473
475
|
bg={styles.FORM_COMBO_INPUT_BG}
|
|
474
476
|
_focus={{
|
|
475
477
|
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
476
478
|
}}
|
|
477
|
-
>{textInputValue}</Text>
|
|
479
|
+
>{_.isEmpty(textInputValue) ? placeholder : textInputValue}</Text>
|
|
478
480
|
</Pressable> :
|
|
479
481
|
<Input
|
|
480
482
|
ref={inputRef}
|
|
@@ -504,6 +506,7 @@ export function ComboComponent(props) {
|
|
|
504
506
|
_focus={{
|
|
505
507
|
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
506
508
|
}}
|
|
509
|
+
placeholder={placeholder}
|
|
507
510
|
{..._input}
|
|
508
511
|
/>}
|
|
509
512
|
<IconButton
|
|
@@ -549,12 +552,13 @@ export function ComboComponent(props) {
|
|
|
549
552
|
borderColor="trueGray.400"
|
|
550
553
|
borderTopRightRadius={0}
|
|
551
554
|
borderBottomRightRadius={0}
|
|
555
|
+
color={_.isEmpty(textInputValue) ? 'trueGray.400' : '#000'}
|
|
552
556
|
fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
|
|
553
557
|
bg={styles.FORM_COMBO_INPUT_BG}
|
|
554
558
|
_focus={{
|
|
555
559
|
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
556
560
|
}}
|
|
557
|
-
>{textInputValue}</Text>
|
|
561
|
+
>{_.isEmpty(textInputValue) ? placeholder : textInputValue}</Text>
|
|
558
562
|
</Pressable>
|
|
559
563
|
<IconButton
|
|
560
564
|
ref={triggerRef}
|
|
@@ -717,8 +721,6 @@ export function ComboComponent(props) {
|
|
|
717
721
|
minWidth={menuMinWidth}
|
|
718
722
|
overflow="auto"
|
|
719
723
|
bg="#fff"
|
|
720
|
-
|
|
721
|
-
h={200}
|
|
722
724
|
>
|
|
723
725
|
<Popover.Body
|
|
724
726
|
ref={menuRef}
|
|
@@ -774,6 +776,7 @@ export function ComboComponent(props) {
|
|
|
774
776
|
_focus={{
|
|
775
777
|
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
776
778
|
}}
|
|
779
|
+
placeholder={placeholder}
|
|
777
780
|
{..._input}
|
|
778
781
|
/>}
|
|
779
782
|
<IconButton
|
|
@@ -798,11 +801,13 @@ export function ComboComponent(props) {
|
|
|
798
801
|
</Row>;
|
|
799
802
|
dropdownMenu = <Modal
|
|
800
803
|
isOpen={true}
|
|
804
|
+
safeAreaTop={true}
|
|
801
805
|
onClose={() => setIsMenuShown(false)}
|
|
802
|
-
|
|
806
|
+
mt="auto"
|
|
807
|
+
mb="auto"
|
|
803
808
|
w="100%"
|
|
804
809
|
h={400}
|
|
805
|
-
|
|
810
|
+
p={5}
|
|
806
811
|
>
|
|
807
812
|
{inputAndTriggerClone}
|
|
808
813
|
{grid}
|
|
@@ -65,6 +65,11 @@ function InputElement(props) {
|
|
|
65
65
|
if (localValue === null || typeof localValue === 'undefined') {
|
|
66
66
|
localValue = ''; // If the value is null or undefined, don't let this be an uncontrolled input
|
|
67
67
|
}
|
|
68
|
+
|
|
69
|
+
const sizeProps = {};
|
|
70
|
+
if (!props.flex && !props.w) {
|
|
71
|
+
sizeProps.flex = 1;
|
|
72
|
+
}
|
|
68
73
|
|
|
69
74
|
let component = <Input
|
|
70
75
|
ref={props.outerRef}
|
|
@@ -72,12 +77,12 @@ function InputElement(props) {
|
|
|
72
77
|
_input={{
|
|
73
78
|
onKeyPress: onKeyPressLocal,
|
|
74
79
|
}}
|
|
75
|
-
flex={1}
|
|
76
80
|
fontSize={styles.FORM_INPUT_FONTSIZE}
|
|
77
81
|
bg={styles.FORM_INPUT_BG}
|
|
78
82
|
_focus={{
|
|
79
83
|
bg: styles.FORM_INPUT_FOCUS_BG,
|
|
80
84
|
}}
|
|
85
|
+
{...sizeProps}
|
|
81
86
|
{...props}
|
|
82
87
|
value={localValue}
|
|
83
88
|
/>;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState, useRef, isValidElement, } from 'react';
|
|
1
|
+
import React, { useEffect, useState, useRef, isValidElement, } from 'react';
|
|
2
2
|
import { View, } from 'react-native';
|
|
3
3
|
import {
|
|
4
4
|
Box,
|
|
@@ -72,6 +72,7 @@ function Form(props) {
|
|
|
72
72
|
buttonGroupProps = {}, // buttons in footer
|
|
73
73
|
checkIsEditingDisabled = true,
|
|
74
74
|
disableLabels = false,
|
|
75
|
+
disableDirtyIcon = false,
|
|
75
76
|
onBack,
|
|
76
77
|
onReset,
|
|
77
78
|
onViewMode,
|
|
@@ -267,7 +268,7 @@ function Form(props) {
|
|
|
267
268
|
// </Column>;
|
|
268
269
|
// }
|
|
269
270
|
|
|
270
|
-
const dirtyIcon = isDirty ? <Icon as={Pencil} size="2xs" color="trueGray.300" position="absolute" top="2px" left="2px" /> : null;
|
|
271
|
+
const dirtyIcon = isDirty && !disableDirtyIcon ? <Icon as={Pencil} size="2xs" color="trueGray.300" position="absolute" top="2px" left="2px" /> : null;
|
|
271
272
|
return <Row key={ix} bg={error ? '#fdd' : '#fff'} w={w} flex={flex} {...columnProps}>{dirtyIcon}{element}</Row>;
|
|
272
273
|
}}
|
|
273
274
|
/>);
|
|
@@ -279,6 +280,9 @@ function Form(props) {
|
|
|
279
280
|
return _.map(items, (item, ix) => buildFromItem(item, ix, columnDefaults));
|
|
280
281
|
},
|
|
281
282
|
buildFromItem = (item, ix, defaults) => {
|
|
283
|
+
if (React.isValidElement(item)) {
|
|
284
|
+
return item;
|
|
285
|
+
}
|
|
282
286
|
let {
|
|
283
287
|
type,
|
|
284
288
|
title,
|
|
@@ -510,7 +514,7 @@ function Form(props) {
|
|
|
510
514
|
</Row>;
|
|
511
515
|
}
|
|
512
516
|
|
|
513
|
-
const dirtyIcon = isDirty ? <Icon as={Pencil} size="2xs" color="trueGray.300" position="absolute" top="2px" left="2px" /> : null;
|
|
517
|
+
const dirtyIcon = isDirty && !disableDirtyIcon ? <Icon as={Pencil} size="2xs" color="trueGray.300" position="absolute" top="2px" left="2px" /> : null;
|
|
514
518
|
return <Row key={ix} px={2} pb={1} bg={error ? '#fdd' : null}>{dirtyIcon}{element}</Row>;
|
|
515
519
|
}}
|
|
516
520
|
/>;
|
|
@@ -868,6 +868,41 @@ function GridComponent(props) {
|
|
|
868
868
|
sizeProps.flex = flex ?? 1;
|
|
869
869
|
}
|
|
870
870
|
|
|
871
|
+
let grid = <FlatList
|
|
872
|
+
ref={gridRef}
|
|
873
|
+
scrollEnabled={CURRENT_MODE === UI_MODE_WEB}
|
|
874
|
+
nestedScrollEnabled={true}
|
|
875
|
+
contentContainerStyle={{
|
|
876
|
+
overflow: 'auto',
|
|
877
|
+
borderWidth: isDragMode ? styles.REORDER_BORDER_WIDTH : 0,
|
|
878
|
+
borderColor: isDragMode ? styles.REORDER_BORDER_COLOR : null,
|
|
879
|
+
borderStyle: styles.REORDER_BORDER_STYLE,
|
|
880
|
+
flex: 1,
|
|
881
|
+
}}
|
|
882
|
+
refreshing={isLoading}
|
|
883
|
+
onRefresh={pullToRefresh ? onRefresh : null}
|
|
884
|
+
progressViewOffset={100}
|
|
885
|
+
data={rowData}
|
|
886
|
+
keyExtractor={(item) => {
|
|
887
|
+
let id;
|
|
888
|
+
if (item.id) {
|
|
889
|
+
id = item.id;
|
|
890
|
+
} else if (fields) {
|
|
891
|
+
id = item[idIx];
|
|
892
|
+
}
|
|
893
|
+
return String(id);
|
|
894
|
+
}}
|
|
895
|
+
initialNumToRender={initialNumToRender}
|
|
896
|
+
initialScrollIndex={0}
|
|
897
|
+
renderItem={renderRow}
|
|
898
|
+
bg="trueGray.100"
|
|
899
|
+
{...flatListProps}
|
|
900
|
+
/>
|
|
901
|
+
if (CURRENT_MODE === UI_MODE_REACT_NATIVE) {
|
|
902
|
+
grid = <ScrollView flex={1} w="100%">{grid}</ScrollView>
|
|
903
|
+
}
|
|
904
|
+
|
|
905
|
+
|
|
871
906
|
return <Column
|
|
872
907
|
{...testProps('Grid')}
|
|
873
908
|
ref={containerRef}
|
|
@@ -885,40 +920,7 @@ function GridComponent(props) {
|
|
|
885
920
|
deselectAll();
|
|
886
921
|
}
|
|
887
922
|
}}>
|
|
888
|
-
{!entities?.length ?
|
|
889
|
-
<NoRecordsFound text={noneFoundText} onRefresh={onRefresh} /> :
|
|
890
|
-
<ScrollView flex={1} w="100%">
|
|
891
|
-
<FlatList
|
|
892
|
-
ref={gridRef}
|
|
893
|
-
scrollEnabled={false}
|
|
894
|
-
nestedScrollEnabled={true}
|
|
895
|
-
contentContainerStyle={{
|
|
896
|
-
overflow: 'auto',
|
|
897
|
-
borderWidth: isDragMode ? styles.REORDER_BORDER_WIDTH : 0,
|
|
898
|
-
borderColor: isDragMode ? styles.REORDER_BORDER_COLOR : null,
|
|
899
|
-
borderStyle: styles.REORDER_BORDER_STYLE,
|
|
900
|
-
flex: 1,
|
|
901
|
-
}}
|
|
902
|
-
refreshing={isLoading}
|
|
903
|
-
onRefresh={pullToRefresh ? onRefresh : null}
|
|
904
|
-
progressViewOffset={100}
|
|
905
|
-
data={rowData}
|
|
906
|
-
keyExtractor={(item) => {
|
|
907
|
-
let id;
|
|
908
|
-
if (item.id) {
|
|
909
|
-
id = item.id;
|
|
910
|
-
} else if (fields) {
|
|
911
|
-
id = item[idIx];
|
|
912
|
-
}
|
|
913
|
-
return String(id);
|
|
914
|
-
}}
|
|
915
|
-
initialNumToRender={initialNumToRender}
|
|
916
|
-
initialScrollIndex={0}
|
|
917
|
-
renderItem={renderRow}
|
|
918
|
-
bg="trueGray.100"
|
|
919
|
-
{...flatListProps}
|
|
920
|
-
/>
|
|
921
|
-
</ScrollView>}
|
|
923
|
+
{!entities?.length ? <NoRecordsFound text={noneFoundText} onRefresh={onRefresh} /> : grid}
|
|
922
924
|
</Column>
|
|
923
925
|
|
|
924
926
|
{listFooterComponent}
|
|
@@ -66,7 +66,7 @@ export default function withAlert(WrappedComponent) {
|
|
|
66
66
|
},
|
|
67
67
|
onConfirm = (message, callback, includeCancel = false) => {
|
|
68
68
|
clearAll();
|
|
69
|
-
setMode(ALERT_MODE_YES_NO);
|
|
69
|
+
setMode(includeCancel ? ALERT_MODE_YES : ALERT_MODE_YES_NO);
|
|
70
70
|
setTitle('Confirm');
|
|
71
71
|
setMessage(message);
|
|
72
72
|
setIncludeCancel(includeCancel);
|
package/src/Components/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Column,
|
|
3
|
+
Row,
|
|
3
4
|
} from 'native-base';
|
|
4
5
|
// import AccordionGridPanel from '../Components/Panel/AccordionGridPanel.js';
|
|
5
6
|
import ArrayCheckboxGroup from './Form/Field/Checkbox/ArrayCheckboxGroup.js';
|
|
@@ -90,6 +91,7 @@ const components = {
|
|
|
90
91
|
// Picker,
|
|
91
92
|
PlusMinusButton,
|
|
92
93
|
RadioGroup,
|
|
94
|
+
Row,
|
|
93
95
|
SquareButton,
|
|
94
96
|
TabPanel,
|
|
95
97
|
Tag,
|