@onehat/ui 0.2.47 → 0.2.49
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/Number.js +7 -1
- package/src/Components/Form/Field/Toggle.js +3 -1
- package/src/Components/Form/Form.js +17 -3
- package/src/Components/Hoc/withFilters.js +30 -20
- package/src/Components/Toolbar/Pagination.js +26 -19
- package/src/Components/Toolbar/PaginationToolbar.js +23 -2
package/package.json
CHANGED
|
@@ -54,10 +54,16 @@ function NumberElement(props) {
|
|
|
54
54
|
}
|
|
55
55
|
},
|
|
56
56
|
onChangeText = (value) => {
|
|
57
|
+
if (value.match(/\.$/)) { // if value ends with a decimal point
|
|
58
|
+
setLocalValue(value);
|
|
59
|
+
return;
|
|
60
|
+
}
|
|
61
|
+
|
|
57
62
|
if (value === '') {
|
|
58
63
|
value = null; // empty string makes value null
|
|
64
|
+
} else {
|
|
65
|
+
value = parseFloat(value, 10);
|
|
59
66
|
}
|
|
60
|
-
value = parseFloat(value, 10);
|
|
61
67
|
setLocalValue(value);
|
|
62
68
|
debouncedSetValueRef.current(value);
|
|
63
69
|
},
|
|
@@ -67,7 +67,9 @@ const
|
|
|
67
67
|
{...propsToPass}
|
|
68
68
|
/>
|
|
69
69
|
</Pressable>
|
|
70
|
-
<
|
|
70
|
+
<Pressable onPress={onToggle}>
|
|
71
|
+
<Text ml={2} fontSize={styles.FORM_TOGGLE_FONTSIZE}>{_.isNil(value) ? 'N/A' : (!!value ? 'Yes' : 'No')}</Text>
|
|
72
|
+
</Pressable>
|
|
71
73
|
</Row>;
|
|
72
74
|
},
|
|
73
75
|
ToggleField = withValue(ToggleElement);
|
|
@@ -28,6 +28,7 @@ import inArray from '../../Functions/inArray.js';
|
|
|
28
28
|
import getComponentFromType from '../../Functions/getComponentFromType.js';
|
|
29
29
|
import IconButton from '../Buttons/IconButton.js';
|
|
30
30
|
import AngleLeft from '../Icons/AngleLeft.js';
|
|
31
|
+
import Eye from '../Icons/Eye.js';
|
|
31
32
|
import Rotate from '../Icons/Rotate.js';
|
|
32
33
|
import Pencil from '../Icons/Pencil.js';
|
|
33
34
|
import Footer from '../Panel/Footer.js';
|
|
@@ -61,7 +62,9 @@ function Form(props) {
|
|
|
61
62
|
validator, // custom validator, mainly for EDITOR_TYPE__PLAIN
|
|
62
63
|
footerProps = {},
|
|
63
64
|
buttonGroupProps = {}, // buttons in footer
|
|
64
|
-
onBack,
|
|
65
|
+
onBack,
|
|
66
|
+
onViewMode,
|
|
67
|
+
additionalButtons = [],
|
|
65
68
|
ancillaryComponents = [],
|
|
66
69
|
|
|
67
70
|
// sizing of outer container
|
|
@@ -476,7 +479,8 @@ function Form(props) {
|
|
|
476
479
|
|
|
477
480
|
return <Column {...sizeProps} onLayout={onLayout}>
|
|
478
481
|
|
|
479
|
-
<Row p={2} alignItems="center">
|
|
482
|
+
<Row p={2} alignItems="center" justifyContent="flex-end">
|
|
483
|
+
{/* <Text mr={2} fontSize={18}>{editorModeF} Mode</Text> */}
|
|
480
484
|
{isSingle && editorMode === EDITOR_MODE__EDIT && onBack &&
|
|
481
485
|
<Button
|
|
482
486
|
key="backBtn"
|
|
@@ -484,8 +488,18 @@ function Form(props) {
|
|
|
484
488
|
leftIcon={<Icon as={AngleLeft} color="#fff" size="sm" />}
|
|
485
489
|
color="#fff"
|
|
486
490
|
>Back</Button>}
|
|
487
|
-
|
|
491
|
+
{isSingle && editorMode === EDITOR_MODE__EDIT && onViewMode &&
|
|
492
|
+
<Button
|
|
493
|
+
key="viewBtn"
|
|
494
|
+
onPress={onViewMode}
|
|
495
|
+
leftIcon={<Icon as={Eye} color="#fff" size="sm" />}
|
|
496
|
+
color="#fff"
|
|
497
|
+
>View</Button>}
|
|
488
498
|
</Row>
|
|
499
|
+
{!_.isEmpty(additionalButtons) &&
|
|
500
|
+
<Row p={2} alignItems="center" justifyContent="flex-end">
|
|
501
|
+
{additionalButtons}
|
|
502
|
+
</Row>}
|
|
489
503
|
|
|
490
504
|
{editor}
|
|
491
505
|
|
|
@@ -234,25 +234,6 @@ export default function withFilters(WrappedComponent) {
|
|
|
234
234
|
if (filter5Field) {
|
|
235
235
|
addFilter(filter5Field, 4);
|
|
236
236
|
}
|
|
237
|
-
|
|
238
|
-
filterElements.push(<IconButton
|
|
239
|
-
key="clear"
|
|
240
|
-
_icon={{
|
|
241
|
-
as: Ban,
|
|
242
|
-
}}
|
|
243
|
-
ml={1}
|
|
244
|
-
onPress={onClearFilters}
|
|
245
|
-
tooltip="Clear all filters"
|
|
246
|
-
/>);
|
|
247
|
-
filterElements.push(<IconButton
|
|
248
|
-
key="gear"
|
|
249
|
-
_icon={{
|
|
250
|
-
as: Gear,
|
|
251
|
-
}}
|
|
252
|
-
ml={1}
|
|
253
|
-
onPress={() => setIsFilterSelectorShown(true)}
|
|
254
|
-
tooltip="Swap filters"
|
|
255
|
-
/>);
|
|
256
237
|
|
|
257
238
|
return filterElements;
|
|
258
239
|
},
|
|
@@ -314,6 +295,9 @@ export default function withFilters(WrappedComponent) {
|
|
|
314
295
|
const q = 'q';
|
|
315
296
|
newFilterFields.push(q);
|
|
316
297
|
filters.push({ name: q, value: filterQValue, });
|
|
298
|
+
if (Repository.searchAncillary && !Repository.hasBaseParam('searchAncillary')) {
|
|
299
|
+
Repository.setBaseParam('searchAncillary', true);
|
|
300
|
+
}
|
|
317
301
|
}
|
|
318
302
|
setFilterFields(newFilterFields);
|
|
319
303
|
|
|
@@ -348,7 +332,33 @@ export default function withFilters(WrappedComponent) {
|
|
|
348
332
|
filterComboProps.data.push([fieldName, title]);
|
|
349
333
|
}
|
|
350
334
|
});
|
|
351
|
-
|
|
335
|
+
const
|
|
336
|
+
renderedFilters = renderFilters(),
|
|
337
|
+
hasFilters = !!renderedFilters.length;
|
|
338
|
+
topToolbar = <Toolbar justifyContent="space-between" alignItems="center">
|
|
339
|
+
<Text pr={2} userSelect="none">Filters:{hasFilters ? '' : ' None'}</Text>
|
|
340
|
+
{renderedFilters}
|
|
341
|
+
<Row flex={hasFilters ? null : 1} justifyContent="flex-end">
|
|
342
|
+
<IconButton
|
|
343
|
+
key="clear"
|
|
344
|
+
_icon={{
|
|
345
|
+
as: Ban,
|
|
346
|
+
}}
|
|
347
|
+
ml={1}
|
|
348
|
+
onPress={onClearFilters}
|
|
349
|
+
tooltip="Clear all filters"
|
|
350
|
+
/>
|
|
351
|
+
<IconButton
|
|
352
|
+
key="gear"
|
|
353
|
+
_icon={{
|
|
354
|
+
as: Gear,
|
|
355
|
+
}}
|
|
356
|
+
ml={1}
|
|
357
|
+
onPress={() => setIsFilterSelectorShown(true)}
|
|
358
|
+
tooltip="Swap filters"
|
|
359
|
+
/>
|
|
360
|
+
</Row>
|
|
361
|
+
</Toolbar>;
|
|
352
362
|
}
|
|
353
363
|
|
|
354
364
|
if (isFilterSelectorShown) {
|
|
@@ -16,6 +16,8 @@ import PageSizeCombo from '../Form/Field/Combo/PageSizeCombo.js';
|
|
|
16
16
|
|
|
17
17
|
export default function Pagination(props) {
|
|
18
18
|
const {
|
|
19
|
+
minimize = false,
|
|
20
|
+
|
|
19
21
|
// withData
|
|
20
22
|
Repository,
|
|
21
23
|
} = props,
|
|
@@ -70,23 +72,25 @@ export default function Pagination(props) {
|
|
|
70
72
|
onPress={() => Repository.prevPage()}
|
|
71
73
|
tooltip="Previous Page"
|
|
72
74
|
/>);
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
75
|
+
if (!minimize) {
|
|
76
|
+
items.push(<Row
|
|
77
|
+
key="pageSelector"
|
|
78
|
+
mx={3}
|
|
79
|
+
justifyContent="center"
|
|
80
|
+
alignItems="center"
|
|
81
|
+
>
|
|
82
|
+
<Text mr={2}>Page</Text>
|
|
83
|
+
<Input
|
|
84
|
+
value={page}
|
|
85
|
+
onChangeValue={(value) => Repository.setPage(value)}
|
|
86
|
+
maxValue={totalPages}
|
|
87
|
+
isDisabled={totalPages === 1}
|
|
88
|
+
w={10}
|
|
89
|
+
tooltip="Set Page"
|
|
90
|
+
/>
|
|
91
|
+
<Text ml={2}>of {totalPages}</Text>
|
|
92
|
+
</Row>);
|
|
93
|
+
}
|
|
90
94
|
|
|
91
95
|
isDisabled = page === totalPages || totalPages <= 1;
|
|
92
96
|
items.push(<IconButton
|
|
@@ -115,7 +119,9 @@ export default function Pagination(props) {
|
|
|
115
119
|
/>);
|
|
116
120
|
}
|
|
117
121
|
|
|
118
|
-
|
|
122
|
+
if (!minimize) {
|
|
123
|
+
items.push(<PageSizeCombo key="pageSize" pageSize={pageSize} Repository={Repository} />);
|
|
124
|
+
}
|
|
119
125
|
|
|
120
126
|
let pageSpan = `${pageStart} – ${pageEnd}`;
|
|
121
127
|
if (pageStart === pageEnd) {
|
|
@@ -130,7 +136,7 @@ export default function Pagination(props) {
|
|
|
130
136
|
{...props}
|
|
131
137
|
>
|
|
132
138
|
{items}
|
|
133
|
-
<Text ml={3}>Displaying {pageSpan} of {total}</Text>
|
|
139
|
+
{!minimize && <Text ml={3}>Displaying {pageSpan} of {total}</Text>}
|
|
134
140
|
</Row>;
|
|
135
141
|
}, [
|
|
136
142
|
// Repository,
|
|
@@ -140,6 +146,7 @@ export default function Pagination(props) {
|
|
|
140
146
|
totalPages,
|
|
141
147
|
pageStart,
|
|
142
148
|
pageEnd,
|
|
149
|
+
minimize,
|
|
143
150
|
])
|
|
144
151
|
|
|
145
152
|
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { useState } from 'react';
|
|
1
2
|
import {
|
|
2
3
|
Row,
|
|
3
4
|
} from 'native-base';
|
|
@@ -9,14 +10,34 @@ export default function PaginationToolbar(props) {
|
|
|
9
10
|
const {
|
|
10
11
|
toolbarItems = [],
|
|
11
12
|
} = props,
|
|
12
|
-
|
|
13
|
+
[minimize, setMinimize] = useState(false),
|
|
14
|
+
propsToPass = _.omit(props, 'toolbarItems'),
|
|
15
|
+
onLayout = (e) => {
|
|
16
|
+
// Note to future self: this is using hard-coded values.
|
|
17
|
+
// Eventually might want to make it responsive to actual sizes
|
|
18
|
+
|
|
19
|
+
// Also, eventually might useMediaQuery from NativeBase, but ReactNative is not yet supported,
|
|
20
|
+
// so have to do things the long way.
|
|
21
|
+
const
|
|
22
|
+
width = e.nativeEvent.layout.width,
|
|
23
|
+
pagingToolbarMinwidth = 576,
|
|
24
|
+
toolbarItemsMinwidth = 45 * toolbarItems.length,
|
|
25
|
+
threshold = pagingToolbarMinwidth + toolbarItemsMinwidth,
|
|
26
|
+
shouldMinimize = width < threshold;
|
|
27
|
+
|
|
28
|
+
if (shouldMinimize !== minimize) {
|
|
29
|
+
setMinimize(shouldMinimize);
|
|
30
|
+
}
|
|
31
|
+
};
|
|
32
|
+
|
|
13
33
|
return <Toolbar
|
|
14
34
|
bg="trueGray.200"
|
|
15
35
|
borderTopWidth={1}
|
|
16
36
|
borderTopColor="trueGray.400"
|
|
17
37
|
w="100%"
|
|
38
|
+
onLayout={(e) => onLayout(e)}
|
|
18
39
|
>
|
|
19
|
-
<Pagination {...propsToPass} w={toolbarItems.length ? null : '100%'} />
|
|
40
|
+
<Pagination {...propsToPass} w={toolbarItems.length ? null : '100%'} minimize={minimize} />
|
|
20
41
|
{toolbarItems.length ? <Row flex={1} borderLeftWidth={1} borderLeftColor="trueGray.400" pl={3} ml={3}>{toolbarItems}</Row> : null}
|
|
21
42
|
</Toolbar>;
|
|
22
43
|
};
|