@onehat/ui 0.3.130 → 0.3.132
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
|
@@ -51,6 +51,7 @@ export function ComboComponent(props) {
|
|
|
51
51
|
onRowPress,
|
|
52
52
|
icon,
|
|
53
53
|
Editor, // only used for the eyeButton
|
|
54
|
+
onSave, // to hook into when menu saves (ComboEditor only)
|
|
54
55
|
|
|
55
56
|
// withComponent
|
|
56
57
|
self,
|
|
@@ -81,6 +82,7 @@ export function ComboComponent(props) {
|
|
|
81
82
|
[isRendered, setIsRendered] = useState(false),
|
|
82
83
|
[isReady, setIsReady] = useState(false),
|
|
83
84
|
[isSearchMode, setIsSearchMode] = useState(false),
|
|
85
|
+
[containerWidth, setContainerWidth] = useState(),
|
|
84
86
|
[gridSelection, setGridSelection] = useState(null),
|
|
85
87
|
[textInputValue, setTextInputValue] = useState(''),
|
|
86
88
|
[newEntityDisplayValue, setNewEntityDisplayValue] = useState(null),
|
|
@@ -88,6 +90,10 @@ export function ComboComponent(props) {
|
|
|
88
90
|
[width, setWidth] = useState(0),
|
|
89
91
|
[top, setTop] = useState(0),
|
|
90
92
|
[left, setLeft] = useState(0),
|
|
93
|
+
onLayout = (e) => {
|
|
94
|
+
setIsRendered(true);
|
|
95
|
+
setContainerWidth(e.nativeEvent.layout.width);
|
|
96
|
+
},
|
|
91
97
|
showMenu = async () => {
|
|
92
98
|
if (isMenuShown) {
|
|
93
99
|
return;
|
|
@@ -738,6 +744,9 @@ export function ComboComponent(props) {
|
|
|
738
744
|
const id = entity.id;
|
|
739
745
|
setValue(id);
|
|
740
746
|
}
|
|
747
|
+
if (onSave) {
|
|
748
|
+
onSave(selection);
|
|
749
|
+
}
|
|
741
750
|
}}
|
|
742
751
|
onRowPress={(item, e) => {
|
|
743
752
|
if (onRowPress) {
|
|
@@ -896,13 +905,31 @@ export function ComboComponent(props) {
|
|
|
896
905
|
if (tooltipRef) {
|
|
897
906
|
refProps.ref = tooltipRef;
|
|
898
907
|
}
|
|
899
|
-
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
908
|
+
|
|
909
|
+
if (isRendered && additionalButtons?.length && containerWidth < 500) {
|
|
910
|
+
// be responsive for small screen sizes and bump additionalButtons to the next line
|
|
911
|
+
assembledComponents =
|
|
912
|
+
<Column>
|
|
913
|
+
<Row {...refProps} justifyContent="center" alignItems="center" h={styles.FORM_COMBO_HEIGHT} flex={1}>
|
|
914
|
+
{xButton}
|
|
915
|
+
{eyeButton}
|
|
916
|
+
{inputAndTrigger}
|
|
917
|
+
{dropdownMenu}
|
|
918
|
+
</Row>
|
|
919
|
+
<Row mt={2}>
|
|
920
|
+
{additionalButtons}
|
|
921
|
+
</Row>
|
|
922
|
+
</Column>;
|
|
923
|
+
} else {
|
|
924
|
+
assembledComponents =
|
|
925
|
+
<Row {...refProps} justifyContent="center" alignItems="center" h={styles.FORM_COMBO_HEIGHT} flex={1} onLayout={onLayout}>
|
|
926
|
+
{xButton}
|
|
927
|
+
{eyeButton}
|
|
928
|
+
{inputAndTrigger}
|
|
929
|
+
{additionalButtons}
|
|
930
|
+
{dropdownMenu}
|
|
931
|
+
</Row>;
|
|
932
|
+
}
|
|
906
933
|
|
|
907
934
|
if (isViewerShown && Editor) {
|
|
908
935
|
const propsForViewer = _.pick(props, [
|
|
@@ -521,10 +521,20 @@ function Form(props) {
|
|
|
521
521
|
}
|
|
522
522
|
|
|
523
523
|
if (item.additionalEditButtons) {
|
|
524
|
-
|
|
524
|
+
const buttons = buildAdditionalButtons(item.additionalEditButtons, self, { fieldState, formSetValue, formGetValues, formState });
|
|
525
|
+
if (containerWidth > 400) {
|
|
526
|
+
element = <Row flex={1} flexWrap="wrap">
|
|
527
|
+
{element}
|
|
528
|
+
{buttons}
|
|
529
|
+
</Row>;
|
|
530
|
+
} else {
|
|
531
|
+
element = <Column flex={1} w="100%">
|
|
525
532
|
{element}
|
|
526
|
-
{
|
|
527
|
-
|
|
533
|
+
<Row flex={1} w="100%" mt={2} flexWrap="wrap">
|
|
534
|
+
{buttons}
|
|
535
|
+
</Row>
|
|
536
|
+
</Column>;
|
|
537
|
+
}
|
|
528
538
|
}
|
|
529
539
|
|
|
530
540
|
let isRequired = false,
|