@onehat/ui 0.3.61 → 0.3.67
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 +64 -57
- 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/Hoc/withAlert.js +1 -1
- package/src/Components/Hoc/withComponent.js +5 -1
- package/src/Components/Hoc/withPdfButton.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
|
|
@@ -60,7 +61,7 @@ export function ComboComponent(props) {
|
|
|
60
61
|
inputRef = useRef(),
|
|
61
62
|
triggerRef = useRef(),
|
|
62
63
|
menuRef = useRef(),
|
|
63
|
-
displayValueRef = useRef(
|
|
64
|
+
displayValueRef = useRef(),
|
|
64
65
|
typingTimeout = useRef(),
|
|
65
66
|
[isMenuShown, setIsMenuShown] = useState(false),
|
|
66
67
|
[isRendered, setIsRendered] = useState(false),
|
|
@@ -117,6 +118,58 @@ export function ComboComponent(props) {
|
|
|
117
118
|
toggleMenu = () => {
|
|
118
119
|
setIsMenuShown(!isMenuShown);
|
|
119
120
|
},
|
|
121
|
+
getDisplayValue = () => {
|
|
122
|
+
return displayValueRef.current;
|
|
123
|
+
},
|
|
124
|
+
setDisplayValue = async (value) => {
|
|
125
|
+
let displayValue = '';
|
|
126
|
+
if (_.isNil(value)) {
|
|
127
|
+
// do nothing
|
|
128
|
+
} else if (_.isArray(value)) {
|
|
129
|
+
displayValue = [];
|
|
130
|
+
if (Repository) {
|
|
131
|
+
if (!Repository.isLoaded) {
|
|
132
|
+
throw Error('Not yet implemented'); // Would a Combo ever have multiple remote selections? Shouldn't that be a Tag field??
|
|
133
|
+
}
|
|
134
|
+
if (Repository.isLoading) {
|
|
135
|
+
await Repository.waitUntilDoneLoading();
|
|
136
|
+
}
|
|
137
|
+
displayValue = _.each(value, (id) => {
|
|
138
|
+
const entity = Repository.getById(id);
|
|
139
|
+
if (entity) {
|
|
140
|
+
displayValue.push(entity.displayValue)
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
} else {
|
|
144
|
+
displayValue = _.each(value, (id) => {
|
|
145
|
+
const item = _.find(data, (datum) => datum[idIx] === id);
|
|
146
|
+
if (item) {
|
|
147
|
+
displayValue.push(item[displayIx]);
|
|
148
|
+
}
|
|
149
|
+
});
|
|
150
|
+
}
|
|
151
|
+
displayValue = displayValue.join(', ');
|
|
152
|
+
} else {
|
|
153
|
+
if (Repository) {
|
|
154
|
+
let entity;
|
|
155
|
+
if (!Repository.isLoaded) {
|
|
156
|
+
entity = await Repository.getSingleEntityFromServer(value);
|
|
157
|
+
} else {
|
|
158
|
+
if (Repository.isLoading) {
|
|
159
|
+
await Repository.waitUntilDoneLoading();
|
|
160
|
+
}
|
|
161
|
+
entity = Repository.getById(value);
|
|
162
|
+
}
|
|
163
|
+
displayValue = entity?.displayValue || '';
|
|
164
|
+
} else {
|
|
165
|
+
const item = _.find(data, (datum) => datum[idIx] === value);
|
|
166
|
+
displayValue = (item && item[displayIx]) || '';
|
|
167
|
+
}
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
displayValueRef.current = displayValue;
|
|
171
|
+
resetInputTextValue();
|
|
172
|
+
},
|
|
120
173
|
resetInputTextValue = () => {
|
|
121
174
|
setTextInputValue(getDisplayValue());
|
|
122
175
|
},
|
|
@@ -343,57 +396,6 @@ export function ComboComponent(props) {
|
|
|
343
396
|
// setTextInputValue(newTextValue);
|
|
344
397
|
// }
|
|
345
398
|
}
|
|
346
|
-
},
|
|
347
|
-
getDisplayValue = () => {
|
|
348
|
-
return displayValueRef.current;
|
|
349
|
-
},
|
|
350
|
-
setDisplayValue = async (value) => {
|
|
351
|
-
let displayValue = '';
|
|
352
|
-
if (_.isNil(value)) {
|
|
353
|
-
// do nothing
|
|
354
|
-
} else if (_.isArray(value)) {
|
|
355
|
-
displayValue = [];
|
|
356
|
-
if (Repository) {
|
|
357
|
-
if (!Repository.isLoaded) {
|
|
358
|
-
throw Error('Not yet implemented'); // Would a Combo ever have multiple remote selections? Shouldn't that be a Tag field??
|
|
359
|
-
}
|
|
360
|
-
if (Repository.isLoading) {
|
|
361
|
-
await Repository.waitUntilDoneLoading();
|
|
362
|
-
}
|
|
363
|
-
displayValue = _.each(value, (id) => {
|
|
364
|
-
const entity = Repository.getById(id);
|
|
365
|
-
if (entity) {
|
|
366
|
-
displayValue.push(entity.displayValue)
|
|
367
|
-
}
|
|
368
|
-
});
|
|
369
|
-
} else {
|
|
370
|
-
displayValue = _.each(value, (id) => {
|
|
371
|
-
const item = _.find(data, (datum) => datum[idIx] === id);
|
|
372
|
-
if (item) {
|
|
373
|
-
displayValue.push(item[displayIx]);
|
|
374
|
-
}
|
|
375
|
-
});
|
|
376
|
-
}
|
|
377
|
-
displayValue = displayValue.join(', ');
|
|
378
|
-
} else {
|
|
379
|
-
if (Repository) {
|
|
380
|
-
let entity;
|
|
381
|
-
if (!Repository.isLoaded) {
|
|
382
|
-
entity = await Repository.getSingleEntityFromServer(value);
|
|
383
|
-
} else {
|
|
384
|
-
if (Repository.isLoading) {
|
|
385
|
-
await Repository.waitUntilDoneLoading();
|
|
386
|
-
}
|
|
387
|
-
entity = Repository.getById(value);
|
|
388
|
-
}
|
|
389
|
-
displayValue = entity?.displayValue || '';
|
|
390
|
-
} else {
|
|
391
|
-
const item = _.find(data, (datum) => datum[idIx] === value);
|
|
392
|
-
displayValue = (item && item[displayIx]) || '';
|
|
393
|
-
}
|
|
394
|
-
}
|
|
395
|
-
|
|
396
|
-
displayValueRef.current = displayValue;
|
|
397
399
|
};
|
|
398
400
|
|
|
399
401
|
useEffect(() => {
|
|
@@ -411,7 +413,6 @@ export function ComboComponent(props) {
|
|
|
411
413
|
(async () => {
|
|
412
414
|
setIsSearchMode(false);
|
|
413
415
|
await setDisplayValue(value);
|
|
414
|
-
resetInputTextValue();
|
|
415
416
|
if (!isReady) {
|
|
416
417
|
setIsReady(true);
|
|
417
418
|
}
|
|
@@ -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}
|
|
@@ -772,6 +776,7 @@ export function ComboComponent(props) {
|
|
|
772
776
|
_focus={{
|
|
773
777
|
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
774
778
|
}}
|
|
779
|
+
placeholder={placeholder}
|
|
775
780
|
{..._input}
|
|
776
781
|
/>}
|
|
777
782
|
<IconButton
|
|
@@ -796,11 +801,13 @@ export function ComboComponent(props) {
|
|
|
796
801
|
</Row>;
|
|
797
802
|
dropdownMenu = <Modal
|
|
798
803
|
isOpen={true}
|
|
804
|
+
safeAreaTop={true}
|
|
799
805
|
onClose={() => setIsMenuShown(false)}
|
|
800
|
-
|
|
806
|
+
mt="auto"
|
|
807
|
+
mb="auto"
|
|
801
808
|
w="100%"
|
|
802
809
|
h={400}
|
|
803
|
-
|
|
810
|
+
p={5}
|
|
804
811
|
>
|
|
805
812
|
{inputAndTriggerClone}
|
|
806
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
|
/>;
|
|
@@ -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);
|
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
import React, { useState, useRef, useEffect, } from 'react';
|
|
2
|
+
import {
|
|
3
|
+
v4 as uuid,
|
|
4
|
+
} from 'uuid';
|
|
2
5
|
import _ from 'lodash';
|
|
3
6
|
|
|
4
7
|
// This HOC establishes a parent-child relationship between components.
|
|
@@ -7,13 +10,14 @@ import _ from 'lodash';
|
|
|
7
10
|
|
|
8
11
|
export default function withComponent(WrappedComponent) {
|
|
9
12
|
return (props) => {
|
|
13
|
+
|
|
10
14
|
const {
|
|
11
15
|
// self: parent,
|
|
12
16
|
parent,
|
|
13
17
|
componentMethods,
|
|
14
18
|
...propsToPass
|
|
15
19
|
} = props,
|
|
16
|
-
|
|
20
|
+
reference = _.isEmpty(props.reference) ? uuid() : props.reference,
|
|
17
21
|
childrenRef = useRef({}),
|
|
18
22
|
selfRef = useRef({
|
|
19
23
|
parent,
|
|
@@ -187,7 +187,7 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
187
187
|
startingValues={startingValues}
|
|
188
188
|
validator={validator}
|
|
189
189
|
checkIsEditingDisabled={false}
|
|
190
|
-
|
|
190
|
+
onClose={(e) => {
|
|
191
191
|
setIsModalShown(false);
|
|
192
192
|
}}
|
|
193
193
|
onSubmit={(data, e) => {
|
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,
|