@onehat/ui 0.3.33 → 0.3.34
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
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 &&
|
|
@@ -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
|
|
|
@@ -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
|