@onehat/ui 0.3.74 → 0.3.76
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 +42 -37
- package/src/Components/Form/Field/Input.js +2 -0
- package/src/Components/Form/Form.js +29 -8
- package/src/Components/Hoc/withPdfButton.js +13 -9
- package/src/Components/Icons/Bookmark.js +20 -0
- package/src/Components/Icons/ClipboardList.js +20 -0
- package/src/Components/Messages/Loading.js +5 -1
- package/src/Constants/AppStates.js +3 -0
- package/src/Constants/MimeTypes.js +2126 -0
- package/src/PlatformImports/Web/Attachments.js +7 -2
package/package.json
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import React, { useState, useEffect, useRef, } from 'react';
|
|
2
2
|
import {
|
|
3
|
+
Icon,
|
|
3
4
|
Modal,
|
|
4
5
|
Popover,
|
|
5
6
|
Pressable,
|
|
@@ -43,6 +44,7 @@ export function ComboComponent(props) {
|
|
|
43
44
|
tooltipPlacement = 'bottom',
|
|
44
45
|
placeholder,
|
|
45
46
|
onRowPress,
|
|
47
|
+
icon,
|
|
46
48
|
|
|
47
49
|
// withComponent
|
|
48
50
|
self,
|
|
@@ -215,10 +217,10 @@ export function ComboComponent(props) {
|
|
|
215
217
|
// showMenu();
|
|
216
218
|
// selectNext();
|
|
217
219
|
// setTimeout(() => {
|
|
218
|
-
// if (!self.children?.
|
|
220
|
+
// if (!self.children?.grid?.selectPrev) {
|
|
219
221
|
// debugger;
|
|
220
222
|
// }
|
|
221
|
-
// self.children.
|
|
223
|
+
// self.children.grid.selectNext();
|
|
222
224
|
// }, 10);
|
|
223
225
|
// break;
|
|
224
226
|
// case 'ArrowUp':
|
|
@@ -226,7 +228,7 @@ export function ComboComponent(props) {
|
|
|
226
228
|
// showMenu();
|
|
227
229
|
// selectPrev();
|
|
228
230
|
// setTimeout(() => {
|
|
229
|
-
// self.children.
|
|
231
|
+
// self.children.grid.selectPrev();
|
|
230
232
|
// }, 10);
|
|
231
233
|
// break;
|
|
232
234
|
default:
|
|
@@ -285,13 +287,13 @@ export function ComboComponent(props) {
|
|
|
285
287
|
resetTextInputValue();
|
|
286
288
|
hideMenu();
|
|
287
289
|
},
|
|
288
|
-
|
|
289
|
-
setTextInputValue('');
|
|
290
|
+
onXButtonPress = () => {
|
|
290
291
|
setValue(null);
|
|
292
|
+
clearGridFilters();
|
|
293
|
+
clearGridSelection();
|
|
291
294
|
},
|
|
292
|
-
|
|
295
|
+
onCheckButtonPress = () => {
|
|
293
296
|
hideMenu();
|
|
294
|
-
setValue(null);
|
|
295
297
|
},
|
|
296
298
|
isEventStillInComponent = (e) => {
|
|
297
299
|
const {
|
|
@@ -341,6 +343,11 @@ export function ComboComponent(props) {
|
|
|
341
343
|
setFilteredData(data);
|
|
342
344
|
}
|
|
343
345
|
},
|
|
346
|
+
clearGridSelection = () => {
|
|
347
|
+
if (self?.children.grid?.deselectAll) {
|
|
348
|
+
self?.children.grid?.deselectAll();
|
|
349
|
+
}
|
|
350
|
+
},
|
|
344
351
|
searchForMatches = async (value) => {
|
|
345
352
|
if (!isMenuShown) {
|
|
346
353
|
showMenu();
|
|
@@ -427,13 +434,10 @@ export function ComboComponent(props) {
|
|
|
427
434
|
return null;
|
|
428
435
|
}
|
|
429
436
|
|
|
430
|
-
|
|
431
|
-
self.clear = onClearBtn;
|
|
432
|
-
}
|
|
433
|
-
|
|
437
|
+
const inputIconElement = icon ? <Icon as={icon} color="trueGray.300" size="md" ml={2} mr={3} /> : null;
|
|
434
438
|
let xButton = null,
|
|
435
439
|
inputAndTrigger = null,
|
|
436
|
-
|
|
440
|
+
checkButton = null,
|
|
437
441
|
grid = null,
|
|
438
442
|
dropdownMenu = null,
|
|
439
443
|
assembledComponents = null;
|
|
@@ -446,7 +450,7 @@ export function ComboComponent(props) {
|
|
|
446
450
|
size: 'sm',
|
|
447
451
|
}}
|
|
448
452
|
isDisabled={isDisabled}
|
|
449
|
-
onPress={
|
|
453
|
+
onPress={onXButtonPress}
|
|
450
454
|
h="100%"
|
|
451
455
|
bg={styles.FORM_COMBO_TRIGGER_BG}
|
|
452
456
|
_hover={{
|
|
@@ -462,25 +466,24 @@ export function ComboComponent(props) {
|
|
|
462
466
|
onPress={toggleMenu}
|
|
463
467
|
flex={1}
|
|
464
468
|
h="100%"
|
|
469
|
+
flexDirection="row"
|
|
470
|
+
borderWidth={1}
|
|
471
|
+
borderColor="trueGray.400"
|
|
472
|
+
borderTopRightRadius={0}
|
|
473
|
+
borderBottomRightRadius={0}
|
|
474
|
+
bg={styles.FORM_COMBO_INPUT_BG}
|
|
475
|
+
m={0}
|
|
476
|
+
p={2}
|
|
465
477
|
>
|
|
478
|
+
{inputIconElement}
|
|
466
479
|
<Text
|
|
467
480
|
ref={inputRef}
|
|
468
481
|
flex={1}
|
|
469
482
|
h="100%"
|
|
470
483
|
numberOfLines={1}
|
|
471
484
|
ellipsizeMode="head"
|
|
472
|
-
m={0}
|
|
473
|
-
p={2}
|
|
474
|
-
borderWidth={1}
|
|
475
|
-
borderColor="trueGray.400"
|
|
476
|
-
borderTopRightRadius={0}
|
|
477
|
-
borderBottomRightRadius={0}
|
|
478
485
|
fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
|
|
479
486
|
color={_.isEmpty(textInputValue) ? 'trueGray.400' : '#000'}
|
|
480
|
-
bg={styles.FORM_COMBO_INPUT_BG}
|
|
481
|
-
_focus={{
|
|
482
|
-
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
483
|
-
}}
|
|
484
487
|
>{_.isEmpty(textInputValue) ? placeholder : textInputValue}</Text>
|
|
485
488
|
</Pressable> :
|
|
486
489
|
<Input
|
|
@@ -496,6 +499,7 @@ export function ComboComponent(props) {
|
|
|
496
499
|
flex={1}
|
|
497
500
|
h="100%"
|
|
498
501
|
m={0}
|
|
502
|
+
InputLeftElement={inputIconElement}
|
|
499
503
|
autoSubmitDelay={0}
|
|
500
504
|
borderTopRightRadius={0}
|
|
501
505
|
borderBottomRightRadius={0}
|
|
@@ -539,24 +543,23 @@ export function ComboComponent(props) {
|
|
|
539
543
|
<Pressable
|
|
540
544
|
onPress={showMenu}
|
|
541
545
|
flex={1}
|
|
546
|
+
flexDirection="row"
|
|
547
|
+
borderWidth={1}
|
|
548
|
+
borderColor="trueGray.400"
|
|
549
|
+
borderTopRightRadius={0}
|
|
550
|
+
borderBottomRightRadius={0}
|
|
551
|
+
bg={styles.FORM_COMBO_INPUT_BG}
|
|
552
|
+
m={0}
|
|
553
|
+
p={2}
|
|
542
554
|
>
|
|
555
|
+
{inputIconElement}
|
|
543
556
|
<Text
|
|
544
557
|
flex={1}
|
|
545
558
|
h="100%"
|
|
546
559
|
numberOfLines={1}
|
|
547
560
|
ellipsizeMode="head"
|
|
548
|
-
m={0}
|
|
549
|
-
p={2}
|
|
550
|
-
borderWidth={1}
|
|
551
|
-
borderColor="trueGray.400"
|
|
552
|
-
borderTopRightRadius={0}
|
|
553
|
-
borderBottomRightRadius={0}
|
|
554
561
|
color={_.isEmpty(displayValue) ? 'trueGray.400' : '#000'}
|
|
555
562
|
fontSize={styles.FORM_COMBO_INPUT_FONTSIZE}
|
|
556
|
-
bg={styles.FORM_COMBO_INPUT_BG}
|
|
557
|
-
_focus={{
|
|
558
|
-
bg: styles.FORM_COMBO_INPUT_FOCUS_BG,
|
|
559
|
-
}}
|
|
560
563
|
>{_.isEmpty(displayValue) ? placeholder : displayValue}</Text>
|
|
561
564
|
</Pressable>
|
|
562
565
|
<IconButton
|
|
@@ -614,7 +617,7 @@ export function ComboComponent(props) {
|
|
|
614
617
|
autoAdjustPageSizeToHeight={false}
|
|
615
618
|
{...gridProps}
|
|
616
619
|
data={filteredData}
|
|
617
|
-
reference="
|
|
620
|
+
reference="grid"
|
|
618
621
|
parent={self}
|
|
619
622
|
h={UiGlobals.mode === UI_MODE_WEB ? styles.FORM_COMBO_MENU_HEIGHT + 'px' : null}
|
|
620
623
|
newEntityDisplayValue={newEntityDisplayValue}
|
|
@@ -737,13 +740,14 @@ export function ComboComponent(props) {
|
|
|
737
740
|
if (UiGlobals.mode === UI_MODE_REACT_NATIVE) {
|
|
738
741
|
if (isEditor) {
|
|
739
742
|
// in RN, an editor has no way to accept the selection of the grid, so we need to add a check button to do this
|
|
740
|
-
|
|
743
|
+
checkButton = <IconButton
|
|
741
744
|
_icon={{
|
|
742
745
|
as: Check,
|
|
743
746
|
color: 'trueGray.600',
|
|
744
747
|
size: 'sm',
|
|
745
748
|
}}
|
|
746
|
-
onPress={
|
|
749
|
+
onPress={onCheckButtonPress}
|
|
750
|
+
isDisabled={!value}
|
|
747
751
|
h="100%"
|
|
748
752
|
borderWidth={1}
|
|
749
753
|
borderColor="#bbb"
|
|
@@ -789,6 +793,7 @@ export function ComboComponent(props) {
|
|
|
789
793
|
flex={1}
|
|
790
794
|
h="100%"
|
|
791
795
|
m={0}
|
|
796
|
+
InputLeftElement={inputIconElement}
|
|
792
797
|
autoSubmitDelay={0}
|
|
793
798
|
borderTopRightRadius={0}
|
|
794
799
|
borderBottomRightRadius={0}
|
|
@@ -819,7 +824,7 @@ export function ComboComponent(props) {
|
|
|
819
824
|
bg: styles.FORM_COMBO_TRIGGER_HOVER_BG,
|
|
820
825
|
}}
|
|
821
826
|
/>
|
|
822
|
-
{
|
|
827
|
+
{checkButton}
|
|
823
828
|
</Row>;
|
|
824
829
|
dropdownMenu = <Modal
|
|
825
830
|
isOpen={true}
|
|
@@ -17,6 +17,7 @@ function InputElement(props) {
|
|
|
17
17
|
setValue,
|
|
18
18
|
autoSubmit = true, // automatically setValue after user stops typing for autoSubmitDelay
|
|
19
19
|
autoSubmitDelay = AUTO_SUBMIT_DELAY,
|
|
20
|
+
autoCapitalize = 'none',
|
|
20
21
|
maxLength,
|
|
21
22
|
onKeyPress,
|
|
22
23
|
onChangeText,
|
|
@@ -82,6 +83,7 @@ function InputElement(props) {
|
|
|
82
83
|
_focus={{
|
|
83
84
|
bg: styles.FORM_INPUT_FOCUS_BG,
|
|
84
85
|
}}
|
|
86
|
+
autoCapitalize={autoCapitalize}
|
|
85
87
|
{...sizeProps}
|
|
86
88
|
{...props}
|
|
87
89
|
value={localValue}
|
|
@@ -393,7 +393,11 @@ function Form(props) {
|
|
|
393
393
|
if (defaults?.labelWidth) {
|
|
394
394
|
labelProps.w = defaults.labelWidth;
|
|
395
395
|
}
|
|
396
|
-
|
|
396
|
+
if (containerWidth > 400) {
|
|
397
|
+
element = <><Label {...labelProps}>{label}</Label>{element}</>;
|
|
398
|
+
} else {
|
|
399
|
+
element = <Column><Label {...labelProps}>{label}</Label>{element}</Column>;
|
|
400
|
+
}
|
|
397
401
|
}
|
|
398
402
|
return <Row key={ix} px={2} pb={1}>{element}</Row>;
|
|
399
403
|
}
|
|
@@ -495,8 +499,18 @@ function Form(props) {
|
|
|
495
499
|
</Row>;
|
|
496
500
|
}
|
|
497
501
|
|
|
498
|
-
let
|
|
499
|
-
|
|
502
|
+
let isRequired = false,
|
|
503
|
+
requiredIndicator = null;
|
|
504
|
+
if (editorType === EDITOR_TYPE__PLAIN) {
|
|
505
|
+
// submitted validator
|
|
506
|
+
if (validator?.fields && validator.fields[name]?.exclusiveTests?.required) {
|
|
507
|
+
isRequired = true;
|
|
508
|
+
}
|
|
509
|
+
} else if (propertyDef?.validator?.spec && !propertyDef.validator.spec.optional) {
|
|
510
|
+
// property definition
|
|
511
|
+
isRequired = true;
|
|
512
|
+
}
|
|
513
|
+
if (isRequired) {
|
|
500
514
|
requiredIndicator = <Text color="#f00" fontSize="30px" pr={1}>*</Text>;
|
|
501
515
|
}
|
|
502
516
|
if (!disableLabels && label && editorType !== EDITOR_TYPE__INLINE) {
|
|
@@ -504,10 +518,17 @@ function Form(props) {
|
|
|
504
518
|
if (defaults?.labelWidth) {
|
|
505
519
|
labelProps.w = defaults.labelWidth;
|
|
506
520
|
}
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
521
|
+
if (containerWidth > 400) {
|
|
522
|
+
element = <Row w="100%" py={1}>
|
|
523
|
+
<Label {...labelProps}>{requiredIndicator}{label}</Label>
|
|
524
|
+
{element}
|
|
525
|
+
</Row>;
|
|
526
|
+
} else {
|
|
527
|
+
element = <Column w="100%" py={1} mt={3}>
|
|
528
|
+
<Label {...labelProps}>{requiredIndicator}{label}</Label>
|
|
529
|
+
{element}
|
|
530
|
+
</Column>;
|
|
531
|
+
}
|
|
511
532
|
} else if (disableLabels && requiredIndicator) {
|
|
512
533
|
element = <Row w="100%" py={1}>
|
|
513
534
|
{requiredIndicator}
|
|
@@ -761,7 +782,7 @@ function Form(props) {
|
|
|
761
782
|
}
|
|
762
783
|
}
|
|
763
784
|
|
|
764
|
-
return <Column {...sizeProps}
|
|
785
|
+
return <Column {...sizeProps} onLayout={onLayoutDecorated} ref={formRef}>
|
|
765
786
|
{!!containerWidth && <>
|
|
766
787
|
{editorType === EDITOR_TYPE__INLINE &&
|
|
767
788
|
<ScrollView
|
|
@@ -43,6 +43,7 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
43
43
|
} = props,
|
|
44
44
|
[isModalShown, setIsModalShown] = useState(false),
|
|
45
45
|
[width, height] = useAdjustedWindowSize(500, 800),
|
|
46
|
+
propertyNames = [],
|
|
46
47
|
buildModalItems = () => {
|
|
47
48
|
const modalItems = _.map(_.cloneDeep(items), (item, ix) => buildNextLayer(item, ix, columnDefaults)); // clone, as we don't want to alter the item by reference
|
|
48
49
|
|
|
@@ -57,10 +58,8 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
57
58
|
} else {
|
|
58
59
|
name = ancillaryItem.title;
|
|
59
60
|
}
|
|
60
|
-
if (!inArray(name, ['Photos', 'Videos', 'Files'])) {
|
|
61
|
-
return;
|
|
62
|
-
}
|
|
63
61
|
name = 'ancillary___' + name;
|
|
62
|
+
propertyNames.push(name); // for validator
|
|
64
63
|
items.push({
|
|
65
64
|
title: ancillaryItem.title,
|
|
66
65
|
label: ancillaryItem.title,
|
|
@@ -77,6 +76,7 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
77
76
|
items,
|
|
78
77
|
showToggleAllCheckbox: true,
|
|
79
78
|
isCollapsible: false,
|
|
79
|
+
ml: 3, // since it's not in a column, which normally adds pl: 3
|
|
80
80
|
});
|
|
81
81
|
}
|
|
82
82
|
|
|
@@ -112,14 +112,18 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
112
112
|
item.title = propertyDef.title;
|
|
113
113
|
}
|
|
114
114
|
}
|
|
115
|
+
if (name) {
|
|
116
|
+
propertyNames.push(name); // for validator
|
|
117
|
+
}
|
|
115
118
|
item.type = 'Checkbox';
|
|
116
119
|
return item;
|
|
117
120
|
},
|
|
118
|
-
buildValidator = (
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
121
|
+
buildValidator = () => {
|
|
122
|
+
const propertyValidatorDefs = {};
|
|
123
|
+
_.each(propertyNames, (name) => {
|
|
124
|
+
propertyValidatorDefs[name] = yup.boolean().required();
|
|
125
|
+
});
|
|
126
|
+
return yup.object(propertyValidatorDefs);
|
|
123
127
|
},
|
|
124
128
|
getStartingValues = (modalItems) => {
|
|
125
129
|
const startingValues = {};
|
|
@@ -171,7 +175,7 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
171
175
|
const
|
|
172
176
|
modalItems = buildModalItems(),
|
|
173
177
|
startingValues = getStartingValues(modalItems),
|
|
174
|
-
validator = buildValidator(
|
|
178
|
+
validator = buildValidator();
|
|
175
179
|
modal = <Modal
|
|
176
180
|
isOpen={true}
|
|
177
181
|
onClose={() => setIsModalShown(false)}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
height={16}
|
|
11
|
+
width={12}
|
|
12
|
+
viewBox="0 0 384 512"
|
|
13
|
+
{...props}
|
|
14
|
+
>
|
|
15
|
+
<Path d="M0 48v439.7C0 501.1 10.9 512 24.3 512c5 0 9.9-1.5 14-4.4L192 400l153.7 107.6c4.1 2.9 9 4.4 14 4.4 13.4 0 24.3-10.9 24.3-24.3V48c0-26.5-21.5-48-48-48H48C21.5 0 0 21.5 0 48z" />
|
|
16
|
+
</Icon>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default SvgComponent
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
// Font Awesome Pro 6.2.1 by @fontawesome - https://fontawesome.com License - https://fontawesome.com/license (Commercial License) Copyright 2022 Fonticons, Inc.
|
|
2
|
+
import * as React from "react"
|
|
3
|
+
import Svg, { Path } from "react-native-svg"
|
|
4
|
+
import { Icon } from 'native-base';
|
|
5
|
+
|
|
6
|
+
function SvgComponent(props) {
|
|
7
|
+
return (
|
|
8
|
+
<Icon
|
|
9
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
10
|
+
viewBox="0 0 384 512"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<Path
|
|
14
|
+
d="M192 0c-41.8 0-77.4 26.7-90.5 64H64C28.7 64 0 92.7 0 128v320c0 35.3 28.7 64 64 64h256c35.3 0 64-28.7 64-64V128c0-35.3-28.7-64-64-64h-37.5C269.4 26.7 233.8 0 192 0zm0 64a32 32 0 110 64 32 32 0 110-64zM72 272a24 24 0 1148 0 24 24 0 11-48 0zm104-16h128c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16s7.2-16 16-16zM72 368a24 24 0 1148 0 24 24 0 11-48 0zm88 0c0-8.8 7.2-16 16-16h128c8.8 0 16 7.2 16 16s-7.2 16-16 16H176c-8.8 0-16-7.2-16-16z"
|
|
15
|
+
/>
|
|
16
|
+
</Icon>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default SvgComponent
|
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Row,
|
|
3
3
|
Spinner,
|
|
4
|
+
Text,
|
|
4
5
|
} from 'native-base';
|
|
5
6
|
import ScreenContainer from '../Container/ScreenContainer.js';
|
|
6
7
|
|
|
7
8
|
export default function Loading(props) {
|
|
8
9
|
if (props.isScreen) {
|
|
9
10
|
return <ScreenContainer {...props}>
|
|
10
|
-
<
|
|
11
|
+
<Row flex={1} justifyContent="center" alignItems="center">
|
|
12
|
+
<Spinner color="primary.500" mr={2} />
|
|
13
|
+
<Text>Loading</Text>
|
|
14
|
+
</Row>
|
|
11
15
|
</ScreenContainer>;
|
|
12
16
|
}
|
|
13
17
|
return <Row justifyContent="center" minHeight={100} {...props}>
|