@onehat/ui 0.3.33 → 0.3.35
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/Form.js +7 -2
- package/src/Components/Grid/Grid.js +6 -1
- package/src/Components/Hoc/withComponent.js +8 -1
- package/src/Components/Hoc/withInlineEditor.js +1 -0
- package/src/Components/Hoc/withPdfButton.js +4 -2
- package/src/Components/Hoc/withSideEditor.js +1 -0
- package/src/Components/Hoc/withWindowedEditor.js +1 -0
- package/src/Components/Icons/Certificate.js +14 -0
- package/src/Components/Icons/ClipboardCheck.js +21 -0
- package/src/Components/Icons/Gauge.js +21 -0
- package/src/Components/Icons/Video.js +20 -0
- package/src/Components/Toolbar/Pagination.js +15 -0
- package/src/Components/Viewer/Viewer.js +7 -1
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { useEffect, useState, isValidElement, } from 'react';
|
|
1
|
+
import { useEffect, useState, useRef, isValidElement, } from 'react';
|
|
2
2
|
import {
|
|
3
3
|
Box,
|
|
4
4
|
Column,
|
|
@@ -106,6 +106,7 @@ function Form(props) {
|
|
|
106
106
|
// withAlert
|
|
107
107
|
alert,
|
|
108
108
|
} = props,
|
|
109
|
+
formRef = useRef(),
|
|
109
110
|
styles = UiGlobals.styles,
|
|
110
111
|
record = props.record?.length === 1 ? props.record[0] : props.record,
|
|
111
112
|
isMultiple = _.isArray(record),
|
|
@@ -565,6 +566,10 @@ function Form(props) {
|
|
|
565
566
|
if (!_.isNil(editorStateRef)) {
|
|
566
567
|
editorStateRef.current = formState; // Update state so HOC can know what's going on
|
|
567
568
|
}
|
|
569
|
+
|
|
570
|
+
if (self) {
|
|
571
|
+
self.ref = formRef;
|
|
572
|
+
}
|
|
568
573
|
|
|
569
574
|
const sizeProps = {};
|
|
570
575
|
if (!flex && !h && !w) {
|
|
@@ -655,7 +660,7 @@ function Form(props) {
|
|
|
655
660
|
|
|
656
661
|
const additionalButtons = buildAdditionalButtons(additionalEditButtons);
|
|
657
662
|
|
|
658
|
-
return <Column {...sizeProps} onLayout={onLayout}>
|
|
663
|
+
return <Column {...sizeProps} onLayout={onLayout} ref={formRef}>
|
|
659
664
|
|
|
660
665
|
<Row px={4} pt={4} alignItems="center" justifyContent="flex-end">
|
|
661
666
|
{isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
|
|
@@ -145,6 +145,7 @@ function GridComponent(props) {
|
|
|
145
145
|
} = props,
|
|
146
146
|
styles = UiGlobals.styles,
|
|
147
147
|
forceUpdate = useForceUpdate(),
|
|
148
|
+
containerRef = useRef(),
|
|
148
149
|
gridRef = useRef(),
|
|
149
150
|
isAddingRef = useRef(),
|
|
150
151
|
[isReady, setIsReady] = useState(false),
|
|
@@ -774,6 +775,9 @@ function GridComponent(props) {
|
|
|
774
775
|
|
|
775
776
|
}, [selectorId, selectorSelected]);
|
|
776
777
|
|
|
778
|
+
if (self) {
|
|
779
|
+
self.ref = containerRef;
|
|
780
|
+
}
|
|
777
781
|
|
|
778
782
|
isAddingRef.current = isAdding;
|
|
779
783
|
|
|
@@ -798,7 +802,7 @@ function GridComponent(props) {
|
|
|
798
802
|
let listFooterComponent = null;
|
|
799
803
|
if (!disableBottomToolbar) {
|
|
800
804
|
if (Repository && bottomToolbar === 'pagination' && !disablePagination && Repository.isPaginated) {
|
|
801
|
-
listFooterComponent = <PaginationToolbar Repository={Repository} toolbarItems={footerToolbarItemComponents} disablePageSize={!disableAdjustingPageSizeToHeight} />;
|
|
805
|
+
listFooterComponent = <PaginationToolbar Repository={Repository} self={self} toolbarItems={footerToolbarItemComponents} disablePageSize={!disableAdjustingPageSizeToHeight} />;
|
|
802
806
|
} else if (footerToolbarItemComponents.length) {
|
|
803
807
|
listFooterComponent = <Toolbar>{footerToolbarItemComponents}</Toolbar>;
|
|
804
808
|
}
|
|
@@ -813,6 +817,7 @@ function GridComponent(props) {
|
|
|
813
817
|
|
|
814
818
|
return <Column
|
|
815
819
|
{...testProps('Grid')}
|
|
820
|
+
ref={containerRef}
|
|
816
821
|
w="100%"
|
|
817
822
|
bg={bg}
|
|
818
823
|
borderWidth={styles.GRID_BORDER_WIDTH}
|
|
@@ -18,6 +18,13 @@ export default function withComponent(WrappedComponent) {
|
|
|
18
18
|
selfRef = useRef({
|
|
19
19
|
parent,
|
|
20
20
|
reference,
|
|
21
|
+
hasChild: (childRef) => {
|
|
22
|
+
const {
|
|
23
|
+
reference,
|
|
24
|
+
} = childRef,
|
|
25
|
+
found = _.find(childrenRef.current, (ref, ix) => ix === reference);
|
|
26
|
+
return !!found;
|
|
27
|
+
},
|
|
21
28
|
registerChild: (childRef) => {
|
|
22
29
|
const {
|
|
23
30
|
reference,
|
|
@@ -44,7 +51,7 @@ export default function withComponent(WrappedComponent) {
|
|
|
44
51
|
selfRef.current[name] = method;
|
|
45
52
|
});
|
|
46
53
|
}
|
|
47
|
-
if (parent && reference) {
|
|
54
|
+
if (parent && reference && !parent.hasChild(selfRef.current)) {
|
|
48
55
|
parent.registerChild(selfRef.current);
|
|
49
56
|
}
|
|
50
57
|
return () => {
|
|
@@ -158,8 +158,10 @@ export default function withPdfButton(WrappedComponent) {
|
|
|
158
158
|
setIsModalShown(true);
|
|
159
159
|
},
|
|
160
160
|
};
|
|
161
|
-
|
|
162
|
-
|
|
161
|
+
if (!_.find(additionalEditButtons, btn => button.key === btn.key)) {
|
|
162
|
+
additionalEditButtons.push(button);
|
|
163
|
+
}
|
|
164
|
+
if (!_.find(additionalViewButtons, btn => button.key === btn.key)) {
|
|
163
165
|
additionalViewButtons.push(button);
|
|
164
166
|
}
|
|
165
167
|
|
|
@@ -0,0 +1,14 @@
|
|
|
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 xmlns="http://www.w3.org/2000/svg" viewBox="0 0 512 512" {...props}>
|
|
9
|
+
<Path d="M211 7.3C205 1 196-1.4 187.6.8s-14.9 8.9-17.1 17.3l-15.8 62.5-62-17.5c-8.4-2.4-17.4 0-23.5 6.1s-8.5 15.1-6.1 23.5l17.5 62-62.5 15.9c-8.4 2.1-15 8.7-17.3 17.1S1 205 7.3 211l46.2 45-46.2 45c-6.3 6-8.7 15-6.5 23.4s8.9 14.9 17.3 17.1l62.5 15.8-17.5 62c-2.4 8.4 0 17.4 6.1 23.5s15.1 8.5 23.5 6.1l62-17.5 15.8 62.5c2.1 8.4 8.7 15 17.1 17.3s17.3-.2 23.4-6.4l45-46.2 45 46.2c6.1 6.2 15 8.7 23.4 6.4s14.9-8.9 17.1-17.3l15.8-62.5 62 17.5c8.4 2.4 17.4 0 23.5-6.1s8.5-15.1 6.1-23.5l-17.5-62 62.5-15.8c8.4-2.1 15-8.7 17.3-17.1s-.2-17.3-6.4-23.4l-46.2-45 46.2-45c6.2-6.1 8.7-15 6.4-23.4s-8.9-14.9-17.3-17.1l-62.5-15.8 17.5-62c2.4-8.4 0-17.4-6.1-23.5s-15.1-8.5-23.5-6.1l-62 17.5-15.9-62.5c-2.1-8.4-8.7-15-17.1-17.3S307 1 301 7.3l-45 46.2-45-46.2z" />
|
|
10
|
+
</Icon>
|
|
11
|
+
)
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export default SvgComponent
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
id="Layer_2"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
viewBox="0 0 9.51 12.68"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<Path
|
|
15
|
+
d="M4.76 0C3.72 0 2.84.66 2.52 1.59h-.93C.72 1.59 0 2.3 0 3.18v7.93c0 .87.71 1.59 1.59 1.59h6.34c.87 0 1.59-.71 1.59-1.59V3.17c0-.87-.71-1.59-1.59-1.59H7A2.384 2.384 0 004.76-.01zm0 1.59c.44 0 .79.35.79.79s-.35.79-.79.79-.79-.35-.79-.79.35-.79.79-.79zm2.8 5.18L4.39 9.94c-.23.23-.61.23-.84 0L1.96 8.35c-.23-.23-.23-.61 0-.84s.61-.23.84 0l1.16 1.16 2.75-2.75c.23-.23.61-.23.84 0s.23.61 0 .84z"
|
|
16
|
+
/>
|
|
17
|
+
</Icon>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export default SvgComponent
|
|
@@ -0,0 +1,21 @@
|
|
|
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
|
+
id="Layer_2"
|
|
10
|
+
xmlns="http://www.w3.org/2000/svg"
|
|
11
|
+
viewBox="0 0 10.46 10.46"
|
|
12
|
+
{...props}
|
|
13
|
+
>
|
|
14
|
+
<Path
|
|
15
|
+
d="M0 5.23C0 2.34 2.34 0 5.23 0s5.23 2.34 5.23 5.23-2.34 5.23-5.23 5.23S0 8.12 0 5.23zm5.89-3.27c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65zM5.24 8.5c.72 0 1.31-.59 1.31-1.31 0-.36-.14-.68-.37-.91L7.49 3.3c.11-.25 0-.54-.25-.65s-.54 0-.65.25L5.28 5.88h-.04c-.72 0-1.31.59-1.31 1.31S4.52 8.5 5.24 8.5zM3.6 2.94c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65zM1.96 5.88c.36 0 .65-.29.65-.65s-.29-.65-.65-.65-.65.29-.65.65.29.65.65.65zm7.19-.65c0-.36-.29-.65-.65-.65s-.65.29-.65.65.29.65.65.65.65-.29.65-.65z"
|
|
16
|
+
/>
|
|
17
|
+
</Icon>
|
|
18
|
+
)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
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 11.77 7.85"
|
|
11
|
+
{...props}
|
|
12
|
+
>
|
|
13
|
+
<Path
|
|
14
|
+
d="M0 1.31C0 .59.59 0 1.31 0h5.23c.72 0 1.31.59 1.31 1.31v5.23c0 .72-.59 1.31-1.31 1.31H1.31C.59 7.85 0 7.26 0 6.54V1.31zM11.43.73c.21.11.35.34.35.58v5.23c0 .24-.13.46-.35.58s-.47.1-.67-.03L8.8 5.78l-.29-.19V2.27l.29-.19L10.76.77c.2-.13.46-.15.67-.03z"
|
|
15
|
+
/>
|
|
16
|
+
</Icon>
|
|
17
|
+
)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export default SvgComponent
|
|
@@ -18,6 +18,9 @@ export default function Pagination(props) {
|
|
|
18
18
|
const {
|
|
19
19
|
minimize = false,
|
|
20
20
|
disablePageSize = false,
|
|
21
|
+
|
|
22
|
+
// withComponent
|
|
23
|
+
self,
|
|
21
24
|
|
|
22
25
|
// withData
|
|
23
26
|
Repository,
|
|
@@ -56,6 +59,8 @@ export default function Pagination(props) {
|
|
|
56
59
|
isDisabled = page === 1;
|
|
57
60
|
items.push(<IconButton
|
|
58
61
|
key="first"
|
|
62
|
+
parent={self}
|
|
63
|
+
reference="firstPageBtn"
|
|
59
64
|
{...iconButtonProps}
|
|
60
65
|
isDisabled={isDisabled}
|
|
61
66
|
icon={<Icon as={AnglesLeft} {...iconProps} color={isDisabled ? 'disabled' : 'trueGray.600'} />}
|
|
@@ -64,6 +69,8 @@ export default function Pagination(props) {
|
|
|
64
69
|
/>);
|
|
65
70
|
items.push(<IconButton
|
|
66
71
|
key="prev"
|
|
72
|
+
parent={self}
|
|
73
|
+
reference="prevPageBtn"
|
|
67
74
|
{...iconButtonProps}
|
|
68
75
|
isDisabled={isDisabled}
|
|
69
76
|
icon={<Icon as={AngleLeft} {...iconProps} color={isDisabled ? 'disabled' : 'trueGray.600'} />}
|
|
@@ -79,6 +86,8 @@ export default function Pagination(props) {
|
|
|
79
86
|
>
|
|
80
87
|
<Text mr={2}>Page</Text>
|
|
81
88
|
<Input
|
|
89
|
+
parent={self}
|
|
90
|
+
reference="pageInput"
|
|
82
91
|
keyboardType="numeric"
|
|
83
92
|
value={page?.toString()}
|
|
84
93
|
onChangeValue={(value) => Repository.setPage(value)}
|
|
@@ -94,6 +103,8 @@ export default function Pagination(props) {
|
|
|
94
103
|
isDisabled = page === totalPages || totalPages <= 1;
|
|
95
104
|
items.push(<IconButton
|
|
96
105
|
key="next"
|
|
106
|
+
parent={self}
|
|
107
|
+
reference="nextPageBtn"
|
|
97
108
|
{...iconButtonProps}
|
|
98
109
|
isDisabled={isDisabled}
|
|
99
110
|
icon={<Icon as={AngleRight} {...iconProps} color={isDisabled ? 'disabled' : 'trueGray.600'} />}
|
|
@@ -102,6 +113,8 @@ export default function Pagination(props) {
|
|
|
102
113
|
/>);
|
|
103
114
|
items.push(<IconButton
|
|
104
115
|
key="last"
|
|
116
|
+
parent={self}
|
|
117
|
+
reference="lastPageBtn"
|
|
105
118
|
{...iconButtonProps}
|
|
106
119
|
isDisabled={isDisabled}
|
|
107
120
|
icon={<Icon as={AnglesRight} {...iconProps} color={isDisabled ? 'disabled' : 'trueGray.600'} />}
|
|
@@ -111,6 +124,8 @@ export default function Pagination(props) {
|
|
|
111
124
|
if (!Repository.isLocal) {
|
|
112
125
|
items.push(<IconButton
|
|
113
126
|
key="reload"
|
|
127
|
+
parent={self}
|
|
128
|
+
reference="reloadPageBtn"
|
|
114
129
|
{...iconButtonProps}
|
|
115
130
|
icon={<Icon as={Rotate} {...iconProps} color="trueGray.600" />}
|
|
116
131
|
onPress={() => Repository.reload()}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useRef, } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
Column,
|
|
3
4
|
Icon,
|
|
@@ -45,6 +46,7 @@ function Viewer(props) {
|
|
|
45
46
|
selectorSelected,
|
|
46
47
|
|
|
47
48
|
} = props,
|
|
49
|
+
scrollViewRef = useRef(),
|
|
48
50
|
isMultiple = _.isArray(record),
|
|
49
51
|
isSideEditor = editorType === EDITOR_TYPE__SIDE,
|
|
50
52
|
styles = UiGlobals.styles,
|
|
@@ -205,13 +207,17 @@ function Viewer(props) {
|
|
|
205
207
|
return additionalButtons;
|
|
206
208
|
};
|
|
207
209
|
|
|
210
|
+
if (self) {
|
|
211
|
+
self.ref = scrollViewRef;
|
|
212
|
+
}
|
|
213
|
+
|
|
208
214
|
const
|
|
209
215
|
showDeleteBtn = onDelete && viewerCanDelete,
|
|
210
216
|
showCloseBtn = !isSideEditor,
|
|
211
217
|
additionalButtons = buildAdditionalButtons();
|
|
212
218
|
|
|
213
219
|
return <Column flex={flex} {...props}>
|
|
214
|
-
<ScrollView width="100%" _web={{ height: 1 }}>
|
|
220
|
+
<ScrollView width="100%" _web={{ height: 1 }} ref={scrollViewRef}>
|
|
215
221
|
<Column p={4}>
|
|
216
222
|
{onEditMode && <Row mb={4} justifyContent="flex-end">
|
|
217
223
|
<Button
|