@wq/material-native 2.0.0-alpha.2 → 3.0.0-alpha.0
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/README.md +6 -22
- package/package.json +8 -25
- package/src/Root.js +80 -0
- package/src/components/Accordion.js +4 -1
- package/src/components/Badge.js +3 -0
- package/src/components/Button.js +4 -10
- package/src/components/ButtonLink.js +14 -3
- package/src/components/CheckboxButton.js +7 -4
- package/src/components/Chip.js +4 -2
- package/src/components/Container.js +2 -1
- package/src/components/Divider.js +2 -1
- package/src/components/ExpandableListItem.js +4 -2
- package/src/components/Fab.js +12 -2
- package/src/components/Footer.js +2 -1
- package/src/components/FooterContent.js +2 -1
- package/src/components/FormatJson.js +4 -1
- package/src/components/Grid.js +3 -0
- package/src/components/Header.js +13 -2
- package/src/components/HorizontalView.js +4 -1
- package/src/components/IconButton.js +6 -4
- package/src/components/Img.js +5 -2
- package/src/components/Link.js +13 -2
- package/src/components/List.js +2 -1
- package/src/components/ListItem.js +4 -2
- package/src/components/ListItemLink.js +14 -3
- package/src/components/ListSubheader.js +2 -1
- package/src/components/Main.js +2 -1
- package/src/components/Menu.js +3 -0
- package/src/components/MenuItem.js +3 -0
- package/src/components/Popup.js +4 -1
- package/src/components/RadioButton.js +4 -1
- package/src/components/ScrollView.js +4 -1
- package/src/components/SidePanel.js +4 -2
- package/src/components/Switch.js +4 -1
- package/src/components/TabGroup.js +5 -3
- package/src/components/TabItem.js +5 -1
- package/src/components/Table.js +2 -1
- package/src/components/TableBody.js +2 -1
- package/src/components/TableCell.js +4 -1
- package/src/components/TableContainer.js +3 -1
- package/src/components/TableHead.js +2 -1
- package/src/components/TableRow.js +2 -1
- package/src/components/TableTitle.js +2 -1
- package/src/components/Text.js +2 -1
- package/src/components/Typography.js +4 -1
- package/src/components/View.js +2 -1
- package/src/components/index.js +7 -26
- package/src/icons.js +3 -2
- package/src/index.js +3 -43
- package/src/App.js +0 -48
- package/src/components/CancelButton.js +0 -3
- package/src/components/DeleteForm.js +0 -64
- package/src/components/Fieldset.js +0 -3
- package/src/components/FieldsetArray.js +0 -21
- package/src/components/FileArray.js +0 -12
- package/src/components/FlatFieldset.js +0 -3
- package/src/components/FormError.js +0 -15
- package/src/components/FormRoot.js +0 -3
- package/src/components/IconSubmitButton.js +0 -12
- package/src/components/Spinner.js +0 -16
- package/src/components/SubmitButton.js +0 -17
- package/src/inputs/Checkbox.js +0 -47
- package/src/inputs/DateTime.js +0 -64
- package/src/inputs/File.js +0 -176
- package/src/inputs/HelperText.js +0 -29
- package/src/inputs/Hidden.js +0 -23
- package/src/inputs/Image.js +0 -6
- package/src/inputs/Input.js +0 -78
- package/src/inputs/Radio.js +0 -32
- package/src/inputs/Select.js +0 -58
- package/src/inputs/Toggle.js +0 -38
- package/src/inputs/date-utils.js +0 -21
- package/src/inputs/index.js +0 -30
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
|
-
import { useComponents } from "@wq/react";
|
|
2
|
+
import { useComponents, withWQ } from "@wq/react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { useTheme } from "react-native-paper";
|
|
5
5
|
import { useMinWidth } from "../hooks.js";
|
|
6
6
|
import PropTypes from "prop-types";
|
|
7
7
|
|
|
8
|
-
|
|
8
|
+
function SidePanel({
|
|
9
9
|
anchor: anchorSpec = "top-left",
|
|
10
10
|
children,
|
|
11
11
|
compactChildren,
|
|
@@ -92,3 +92,5 @@ SidePanel.propTypes = {
|
|
|
92
92
|
onChange: PropTypes.func,
|
|
93
93
|
anchor: PropTypes.string,
|
|
94
94
|
};
|
|
95
|
+
|
|
96
|
+
export default withWQ(SidePanel);
|
package/src/components/Switch.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Switch as PaperSwitch, useTheme } from "react-native-paper";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function Switch({ checked: value, color, ...rest }) {
|
|
6
7
|
const theme = useTheme();
|
|
7
8
|
if (color === "primary") {
|
|
8
9
|
color = theme.colors.primary;
|
|
@@ -16,3 +17,5 @@ Switch.propTypes = {
|
|
|
16
17
|
checked: PropTypes.bool,
|
|
17
18
|
color: PropTypes.string,
|
|
18
19
|
};
|
|
20
|
+
|
|
21
|
+
export default withWQ(Switch);
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useWQ, withWQ } from "@wq/react";
|
|
3
3
|
import { View } from "react-native";
|
|
4
4
|
import { SegmentedButtons } from "react-native-paper";
|
|
5
5
|
import PropTypes from "prop-types";
|
|
6
6
|
|
|
7
|
-
|
|
7
|
+
function TabGroup({ children, style, ...rest }) {
|
|
8
8
|
const tabs = React.Children.toArray(children),
|
|
9
9
|
[value, setValue] = useState(tabs[0].props.value),
|
|
10
10
|
activeTab = tabs.find((tab) => tab.props.value === value),
|
|
11
11
|
handleChange = (tab) => setValue(tab),
|
|
12
|
-
icons =
|
|
12
|
+
icons = useWQ("icons", true),
|
|
13
13
|
buttons = tabs.map((tab) => ({
|
|
14
14
|
value: tab.props.value,
|
|
15
15
|
label: tab.props.label,
|
|
@@ -36,3 +36,5 @@ TabGroup.propTypes = {
|
|
|
36
36
|
children: PropTypes.node,
|
|
37
37
|
style: PropTypes.object,
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export default withWQ(TabGroup);
|
|
@@ -1,14 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import PropTypes from "prop-types";
|
|
3
3
|
|
|
4
|
-
export default function TabItem({ value, icon, label, children }) {
|
|
4
|
+
export default function TabItem({ wq, value, icon, label, children }) {
|
|
5
5
|
/* eslint no-unused-vars: off */
|
|
6
6
|
|
|
7
7
|
// All rendering handled by TabGroup
|
|
8
|
+
if (wq) {
|
|
9
|
+
console.warn("wq prop has no effect in TabItem");
|
|
10
|
+
}
|
|
8
11
|
return null;
|
|
9
12
|
}
|
|
10
13
|
|
|
11
14
|
TabItem.propTypes = {
|
|
15
|
+
wq: PropTypes.object,
|
|
12
16
|
value: PropTypes.string,
|
|
13
17
|
icon: PropTypes.string,
|
|
14
18
|
label: PropTypes.string,
|
package/src/components/Table.js
CHANGED
|
@@ -2,8 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import { DataTable } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
+
import { withWQ } from "@wq/react";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function TableCell({ interactive, children, ...rest }) {
|
|
7
8
|
const Cell = interactive ? InteractiveCell : DataTable.Cell;
|
|
8
9
|
return <Cell {...rest}>{children}</Cell>;
|
|
9
10
|
}
|
|
@@ -23,3 +24,5 @@ function InteractiveCell(props) {
|
|
|
23
24
|
}
|
|
24
25
|
|
|
25
26
|
TableCell.propTypes = { interactive: PropTypes.bool, children: PropTypes.node };
|
|
27
|
+
|
|
28
|
+
export default withWQ(TableCell);
|
package/src/components/Text.js
CHANGED
|
@@ -8,6 +8,7 @@ import {
|
|
|
8
8
|
Caption,
|
|
9
9
|
} from "react-native-paper";
|
|
10
10
|
import PropTypes from "prop-types";
|
|
11
|
+
import { withWQ } from "@wq/react";
|
|
11
12
|
|
|
12
13
|
const variants = {
|
|
13
14
|
default: Text,
|
|
@@ -25,7 +26,7 @@ const variants = {
|
|
|
25
26
|
overline: Caption,
|
|
26
27
|
};
|
|
27
28
|
|
|
28
|
-
|
|
29
|
+
function Typography({ variant, children, ...rest }) {
|
|
29
30
|
const Component = variants[variant] || variants.default;
|
|
30
31
|
if (variant === "overline" && typeof children === "string") {
|
|
31
32
|
children = children.toUpperCase();
|
|
@@ -37,3 +38,5 @@ Typography.propTypes = {
|
|
|
37
38
|
variant: PropTypes.string,
|
|
38
39
|
children: PropTypes.node,
|
|
39
40
|
};
|
|
41
|
+
|
|
42
|
+
export default withWQ(Typography);
|
package/src/components/View.js
CHANGED
package/src/components/index.js
CHANGED
|
@@ -45,23 +45,16 @@ import TableCell from "./TableCell.js";
|
|
|
45
45
|
import TableContainer from "./TableContainer.js";
|
|
46
46
|
import TablePagination from "./TablePagination.js";
|
|
47
47
|
|
|
48
|
-
import FormRoot from "./FormRoot.js";
|
|
49
|
-
import FormError from "./FormError.js";
|
|
50
|
-
import Fieldset from "./Fieldset.js";
|
|
51
|
-
import FlatFieldset from "./FlatFieldset.js";
|
|
52
|
-
import FieldsetArray from "./FieldsetArray.js";
|
|
53
|
-
import FileArray from "./FileArray.js";
|
|
54
|
-
import CancelButton from "./CancelButton.js";
|
|
55
|
-
import SubmitButton from "./SubmitButton.js";
|
|
56
|
-
import IconSubmitButton from "./IconSubmitButton.js";
|
|
57
|
-
import DeleteForm from "./DeleteForm.js";
|
|
58
|
-
|
|
59
|
-
import Spinner from "./Spinner.js";
|
|
60
48
|
import Popup from "./Popup.js";
|
|
61
49
|
import SidePanel from "./SidePanel.js";
|
|
62
50
|
import Breadcrumbs from "./Breadcrumbs.js";
|
|
63
51
|
import Pagination from "./Pagination.js";
|
|
64
52
|
|
|
53
|
+
import Badge from "./Badge.js";
|
|
54
|
+
import Grid from "./Grid.js";
|
|
55
|
+
import Menu from "./Menu.js";
|
|
56
|
+
import MenuItem from "./MenuItem.js";
|
|
57
|
+
|
|
65
58
|
export {
|
|
66
59
|
Container,
|
|
67
60
|
Header,
|
|
@@ -102,7 +95,6 @@ export {
|
|
|
102
95
|
ListItemLink,
|
|
103
96
|
ListSubheader,
|
|
104
97
|
Accordion,
|
|
105
|
-
Accordion as ExpansionPanel,
|
|
106
98
|
ExpandableListItem,
|
|
107
99
|
Divider,
|
|
108
100
|
};
|
|
@@ -118,17 +110,6 @@ export {
|
|
|
118
110
|
TablePagination,
|
|
119
111
|
};
|
|
120
112
|
|
|
121
|
-
export {
|
|
122
|
-
FormRoot,
|
|
123
|
-
FormError,
|
|
124
|
-
Fieldset,
|
|
125
|
-
FlatFieldset,
|
|
126
|
-
FieldsetArray,
|
|
127
|
-
FileArray,
|
|
128
|
-
CancelButton,
|
|
129
|
-
SubmitButton,
|
|
130
|
-
IconSubmitButton,
|
|
131
|
-
DeleteForm,
|
|
132
|
-
};
|
|
113
|
+
export { Popup, SidePanel, Breadcrumbs, Pagination };
|
|
133
114
|
|
|
134
|
-
export {
|
|
115
|
+
export { Badge, Grid, Menu, MenuItem };
|
package/src/icons.js
CHANGED
|
@@ -5,6 +5,7 @@ export const Add = "plus",
|
|
|
5
5
|
Error = "alert-circle",
|
|
6
6
|
Pending = "sync",
|
|
7
7
|
Close = "close",
|
|
8
|
+
Cancel = "cancel",
|
|
8
9
|
Expand = "chevron-down",
|
|
9
10
|
Collapse = "chevron-up",
|
|
10
11
|
PanelOpen = "chevron-right",
|
|
@@ -12,12 +13,12 @@ export const Add = "plus",
|
|
|
12
13
|
GpsStart = "crosshairs-gps",
|
|
13
14
|
GpsStop = "crosshairs-off",
|
|
14
15
|
Search = "magnify",
|
|
15
|
-
|
|
16
|
+
ListIcon = "view-list",
|
|
16
17
|
Detail = "information",
|
|
17
18
|
Map = "map",
|
|
18
19
|
Home = "home",
|
|
19
20
|
BreadcrumbSeparator = "chevron-right",
|
|
20
|
-
|
|
21
|
+
MenuIcon = "menu",
|
|
21
22
|
Login = "login",
|
|
22
23
|
Logout = "logout",
|
|
23
24
|
Config = "cog",
|
package/src/index.js
CHANGED
|
@@ -1,45 +1,5 @@
|
|
|
1
|
-
import
|
|
2
|
-
|
|
3
|
-
import * as components from "./components/index.js";
|
|
4
|
-
import * as inputs from "./inputs/index.js";
|
|
5
|
-
import * as icons from "./icons.js";
|
|
6
|
-
import { format, parse } from "./inputs/date-utils.js";
|
|
7
|
-
|
|
8
|
-
export default {
|
|
9
|
-
name: "material",
|
|
10
|
-
dependencies: [react],
|
|
11
|
-
|
|
12
|
-
config: {
|
|
13
|
-
theme: {
|
|
14
|
-
primary: "#7500ae",
|
|
15
|
-
secondary: "#0088bd",
|
|
16
|
-
},
|
|
17
|
-
inputFormat: {
|
|
18
|
-
date: "yyyy-MM-dd",
|
|
19
|
-
time: "HH:mm",
|
|
20
|
-
datetime: "yyyy-MM-dd HH:mm",
|
|
21
|
-
},
|
|
22
|
-
},
|
|
23
|
-
|
|
24
|
-
components: { App, ...components },
|
|
25
|
-
inputs: { ...inputs },
|
|
26
|
-
icons: { ...icons },
|
|
27
|
-
|
|
28
|
-
init(config) {
|
|
29
|
-
if (!config) {
|
|
30
|
-
return;
|
|
31
|
-
}
|
|
32
|
-
if (config.theme) {
|
|
33
|
-
Object.assign(this.config.theme, config.theme);
|
|
34
|
-
}
|
|
35
|
-
if (config.inputFormat) {
|
|
36
|
-
Object.assign(this.config.inputFormat, config.inputFormat);
|
|
37
|
-
}
|
|
38
|
-
},
|
|
39
|
-
};
|
|
40
|
-
|
|
41
|
-
export { App };
|
|
1
|
+
import Root from "./Root.js";
|
|
2
|
+
export { Root };
|
|
42
3
|
export * from "./components/index.js";
|
|
43
|
-
export * from "./
|
|
4
|
+
export * from "./icons.js";
|
|
44
5
|
export * from "./hooks.js";
|
|
45
|
-
export { format, parse };
|
package/src/App.js
DELETED
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { App as DefaultApp, usePlugin } from "@wq/react";
|
|
3
|
-
import {
|
|
4
|
-
DefaultTheme,
|
|
5
|
-
DarkTheme,
|
|
6
|
-
Provider as PaperProvider,
|
|
7
|
-
} from "react-native-paper";
|
|
8
|
-
|
|
9
|
-
export default function App() {
|
|
10
|
-
const { theme: configTheme } = usePlugin("material").config,
|
|
11
|
-
theme = useMemo(() => createTheme(configTheme), [configTheme]),
|
|
12
|
-
options = useMemo(
|
|
13
|
-
() => ({
|
|
14
|
-
navigator: { theme },
|
|
15
|
-
screen: {
|
|
16
|
-
cardStyle: { backgroundColor: theme.colors.background },
|
|
17
|
-
},
|
|
18
|
-
}),
|
|
19
|
-
[theme]
|
|
20
|
-
);
|
|
21
|
-
|
|
22
|
-
return (
|
|
23
|
-
<PaperProvider theme={theme}>
|
|
24
|
-
<DefaultApp options={options} />
|
|
25
|
-
</PaperProvider>
|
|
26
|
-
);
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
function createTheme({ type, primary, secondary, background }) {
|
|
30
|
-
const colors = {},
|
|
31
|
-
base = type === "dark" ? DarkTheme : DefaultTheme;
|
|
32
|
-
if (primary) {
|
|
33
|
-
colors.primary = primary;
|
|
34
|
-
}
|
|
35
|
-
if (secondary) {
|
|
36
|
-
colors.accent = secondary;
|
|
37
|
-
}
|
|
38
|
-
if (background) {
|
|
39
|
-
colors.background = background;
|
|
40
|
-
}
|
|
41
|
-
return {
|
|
42
|
-
...base,
|
|
43
|
-
colors: {
|
|
44
|
-
...base.colors,
|
|
45
|
-
...colors,
|
|
46
|
-
},
|
|
47
|
-
};
|
|
48
|
-
}
|
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import Alert from "react-native";
|
|
3
|
-
import { useComponents, useMessages } from "@wq/react";
|
|
4
|
-
import PropTypes from "prop-types";
|
|
5
|
-
|
|
6
|
-
export default function DeleteForm({ action }) {
|
|
7
|
-
const { Form, SubmitButton, View, HorizontalView } = useComponents(),
|
|
8
|
-
{
|
|
9
|
-
CONFIRM_DELETE,
|
|
10
|
-
CONFIRM_DELETE_TITLE,
|
|
11
|
-
CONFIRM_DELETE_OK,
|
|
12
|
-
CONFIRM_DELETE_CANCEL,
|
|
13
|
-
} = useMessages();
|
|
14
|
-
|
|
15
|
-
async function confirmSubmit() {
|
|
16
|
-
return new Promise((resolve) => {
|
|
17
|
-
Alert.alert(
|
|
18
|
-
CONFIRM_DELETE_TITLE,
|
|
19
|
-
CONFIRM_DELETE,
|
|
20
|
-
[
|
|
21
|
-
{
|
|
22
|
-
text: CONFIRM_DELETE_CANCEL,
|
|
23
|
-
onPress() {
|
|
24
|
-
resolve(false);
|
|
25
|
-
},
|
|
26
|
-
style: "cancel",
|
|
27
|
-
},
|
|
28
|
-
{
|
|
29
|
-
text: CONFIRM_DELETE_OK,
|
|
30
|
-
onPress() {
|
|
31
|
-
resolve(true);
|
|
32
|
-
},
|
|
33
|
-
style: "destructive",
|
|
34
|
-
},
|
|
35
|
-
],
|
|
36
|
-
{
|
|
37
|
-
onDismiss() {
|
|
38
|
-
resolve(false);
|
|
39
|
-
},
|
|
40
|
-
}
|
|
41
|
-
);
|
|
42
|
-
});
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
return (
|
|
46
|
-
<Form
|
|
47
|
-
action={action}
|
|
48
|
-
method="DELETE"
|
|
49
|
-
backgroundSync={false}
|
|
50
|
-
onSubmit={confirmSubmit}
|
|
51
|
-
>
|
|
52
|
-
<HorizontalView>
|
|
53
|
-
<View />
|
|
54
|
-
<SubmitButton icon="delete" variant="text" color="secondary">
|
|
55
|
-
Delete
|
|
56
|
-
</SubmitButton>
|
|
57
|
-
</HorizontalView>
|
|
58
|
-
</Form>
|
|
59
|
-
);
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
DeleteForm.propTypes = {
|
|
63
|
-
action: PropTypes.string,
|
|
64
|
-
};
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useComponents } from "@wq/react";
|
|
3
|
-
import PropTypes from "prop-types";
|
|
4
|
-
|
|
5
|
-
export default function FieldsetArray({ label, children, addRow }) {
|
|
6
|
-
const { View, Button } = useComponents();
|
|
7
|
-
return (
|
|
8
|
-
<View>
|
|
9
|
-
{children}
|
|
10
|
-
{addRow && (
|
|
11
|
-
<Button onClick={() => addRow()}>{`Add ${label}`}</Button>
|
|
12
|
-
)}
|
|
13
|
-
</View>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
FieldsetArray.propTypes = {
|
|
18
|
-
label: PropTypes.string,
|
|
19
|
-
children: PropTypes.node,
|
|
20
|
-
addRow: PropTypes.func,
|
|
21
|
-
};
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { List } from "react-native-paper";
|
|
3
|
-
import FieldsetArray from "./FieldsetArray.js";
|
|
4
|
-
|
|
5
|
-
export default function FileArray(props) {
|
|
6
|
-
return (
|
|
7
|
-
<>
|
|
8
|
-
{props.label && <List.Subheader>{props.label}</List.Subheader>}
|
|
9
|
-
<FieldsetArray {...props} />
|
|
10
|
-
</>
|
|
11
|
-
);
|
|
12
|
-
}
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useField } from "formik";
|
|
3
|
-
import { HelperText } from "react-native-paper";
|
|
4
|
-
|
|
5
|
-
export default function FormError(props) {
|
|
6
|
-
const [, { error }] = useField("__other__");
|
|
7
|
-
if (!error) {
|
|
8
|
-
return null;
|
|
9
|
-
}
|
|
10
|
-
return (
|
|
11
|
-
<HelperText type="error" {...props}>
|
|
12
|
-
{error}
|
|
13
|
-
</HelperText>
|
|
14
|
-
);
|
|
15
|
-
}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useComponents } from "@wq/react";
|
|
3
|
-
import { useFormikContext } from "formik";
|
|
4
|
-
|
|
5
|
-
export default function IconSubmitButton(props) {
|
|
6
|
-
const { IconButton } = useComponents(),
|
|
7
|
-
{ isSubmitting, submitForm } = useFormikContext();
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<IconButton disabled={isSubmitting} onPress={submitForm} {...props} />
|
|
11
|
-
);
|
|
12
|
-
}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { ActivityIndicator, Modal, Portal } from "react-native-paper";
|
|
3
|
-
import { useSpinner } from "@wq/react";
|
|
4
|
-
|
|
5
|
-
export default function Spinner() {
|
|
6
|
-
const { active } = useSpinner();
|
|
7
|
-
|
|
8
|
-
// FIXME: text, type
|
|
9
|
-
return (
|
|
10
|
-
<Portal>
|
|
11
|
-
<Modal visible={active}>
|
|
12
|
-
<ActivityIndicator />
|
|
13
|
-
</Modal>
|
|
14
|
-
</Portal>
|
|
15
|
-
);
|
|
16
|
-
}
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useComponents } from "@wq/react";
|
|
3
|
-
import { useFormikContext } from "formik";
|
|
4
|
-
|
|
5
|
-
export default function SubmitButton(props) {
|
|
6
|
-
const { Button } = useComponents(),
|
|
7
|
-
{ isSubmitting, submitForm } = useFormikContext();
|
|
8
|
-
|
|
9
|
-
return (
|
|
10
|
-
<Button
|
|
11
|
-
mode="contained"
|
|
12
|
-
disabled={isSubmitting}
|
|
13
|
-
onPress={submitForm}
|
|
14
|
-
{...props}
|
|
15
|
-
/>
|
|
16
|
-
);
|
|
17
|
-
}
|
package/src/inputs/Checkbox.js
DELETED
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { useField } from "formik";
|
|
3
|
-
import { Checkbox as PaperCheckbox, useTheme } from "react-native-paper";
|
|
4
|
-
import { Text, View } from "react-native";
|
|
5
|
-
import HelperText from "./HelperText.js";
|
|
6
|
-
import PropTypes from "prop-types";
|
|
7
|
-
|
|
8
|
-
export default function Checkbox({ name, label, hint }) {
|
|
9
|
-
const theme = useTheme(),
|
|
10
|
-
[, meta, helpers] = useField(name),
|
|
11
|
-
{ value } = meta,
|
|
12
|
-
{ setValue } = helpers;
|
|
13
|
-
|
|
14
|
-
function toggleChecked() {
|
|
15
|
-
setValue(!value);
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
return (
|
|
19
|
-
<View>
|
|
20
|
-
<View
|
|
21
|
-
style={{
|
|
22
|
-
flexDirection: "row",
|
|
23
|
-
alignItems: "center",
|
|
24
|
-
padding: 8,
|
|
25
|
-
}}
|
|
26
|
-
>
|
|
27
|
-
<PaperCheckbox.Android
|
|
28
|
-
status={value ? "checked" : "unchecked"}
|
|
29
|
-
onPress={toggleChecked}
|
|
30
|
-
/>
|
|
31
|
-
<Text
|
|
32
|
-
style={{ color: theme.colors.text, fontSize: 16, flex: 1 }}
|
|
33
|
-
onPress={toggleChecked}
|
|
34
|
-
>
|
|
35
|
-
{label}
|
|
36
|
-
</Text>
|
|
37
|
-
</View>
|
|
38
|
-
<HelperText name={name} hint={hint} />
|
|
39
|
-
</View>
|
|
40
|
-
);
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
Checkbox.propTypes = {
|
|
44
|
-
name: PropTypes.string,
|
|
45
|
-
label: PropTypes.string,
|
|
46
|
-
hint: PropTypes.string,
|
|
47
|
-
};
|
package/src/inputs/DateTime.js
DELETED
|
@@ -1,64 +0,0 @@
|
|
|
1
|
-
import React, { useState } from "react";
|
|
2
|
-
import DateTimePickerModal from "react-native-modal-datetime-picker";
|
|
3
|
-
import { Text, View } from "react-native";
|
|
4
|
-
import { TouchableRipple, TextInput } from "react-native-paper";
|
|
5
|
-
import { useField } from "formik";
|
|
6
|
-
import { format, parse } from "./date-utils.js";
|
|
7
|
-
import HelperText from "./HelperText.js";
|
|
8
|
-
import PropTypes from "prop-types";
|
|
9
|
-
|
|
10
|
-
const displayFormat = {
|
|
11
|
-
date: (value) => parse.date(value).toLocaleDateString(),
|
|
12
|
-
time: (value) => parse.time(value).toLocaleTimeString(),
|
|
13
|
-
datetime: (value) => parse.datetime(value).toLocaleString(),
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export default function DateTime({ name, type, label, hint }) {
|
|
17
|
-
type = type.toLowerCase();
|
|
18
|
-
|
|
19
|
-
const [, meta, helpers] = useField(name),
|
|
20
|
-
{ value } = meta,
|
|
21
|
-
{ setValue } = helpers;
|
|
22
|
-
|
|
23
|
-
const [show, setShow] = useState(false);
|
|
24
|
-
|
|
25
|
-
function showPicker() {
|
|
26
|
-
setShow(true);
|
|
27
|
-
}
|
|
28
|
-
function hidePicker() {
|
|
29
|
-
setShow(false);
|
|
30
|
-
}
|
|
31
|
-
function onConfirm(val) {
|
|
32
|
-
hidePicker();
|
|
33
|
-
setValue(format[type](val));
|
|
34
|
-
}
|
|
35
|
-
|
|
36
|
-
return (
|
|
37
|
-
<View>
|
|
38
|
-
<TextInput
|
|
39
|
-
label={label}
|
|
40
|
-
value={value ? displayFormat[type](value) : ""}
|
|
41
|
-
render={({ style, value }) => (
|
|
42
|
-
<TouchableRipple onPress={showPicker}>
|
|
43
|
-
<Text style={style}>{value}</Text>
|
|
44
|
-
</TouchableRipple>
|
|
45
|
-
)}
|
|
46
|
-
/>
|
|
47
|
-
<HelperText name={name} hint={hint} />
|
|
48
|
-
<DateTimePickerModal
|
|
49
|
-
isVisible={show}
|
|
50
|
-
mode={type}
|
|
51
|
-
date={parse[type](value) || new Date()}
|
|
52
|
-
onConfirm={onConfirm}
|
|
53
|
-
onCancel={hidePicker}
|
|
54
|
-
/>
|
|
55
|
-
</View>
|
|
56
|
-
);
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
DateTime.propTypes = {
|
|
60
|
-
name: PropTypes.string,
|
|
61
|
-
type: PropTypes.string,
|
|
62
|
-
label: PropTypes.string,
|
|
63
|
-
hint: PropTypes.string,
|
|
64
|
-
};
|