@wq/material-native 2.0.0 → 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 +5 -3
- package/src/components/Img.js +4 -1
- 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 -18
- package/src/icons.js +3 -2
- package/src/index.js +3 -43
- package/src/App.js +0 -66
- package/src/components/CancelButton.js +0 -3
- package/src/components/DeleteForm.js +0 -64
- 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/Fieldset.js +0 -3
- package/src/inputs/FieldsetArray.js +0 -21
- package/src/inputs/File.js +0 -176
- package/src/inputs/FileArray.js +0 -12
- package/src/inputs/FlatFieldset.js +0 -3
- 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 -38
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,19 +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 CancelButton from "./CancelButton.js";
|
|
51
|
-
import SubmitButton from "./SubmitButton.js";
|
|
52
|
-
import IconSubmitButton from "./IconSubmitButton.js";
|
|
53
|
-
import DeleteForm from "./DeleteForm.js";
|
|
54
|
-
|
|
55
|
-
import Spinner from "./Spinner.js";
|
|
56
48
|
import Popup from "./Popup.js";
|
|
57
49
|
import SidePanel from "./SidePanel.js";
|
|
58
50
|
import Breadcrumbs from "./Breadcrumbs.js";
|
|
59
51
|
import Pagination from "./Pagination.js";
|
|
60
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
|
+
|
|
61
58
|
export {
|
|
62
59
|
Container,
|
|
63
60
|
Header,
|
|
@@ -98,7 +95,6 @@ export {
|
|
|
98
95
|
ListItemLink,
|
|
99
96
|
ListSubheader,
|
|
100
97
|
Accordion,
|
|
101
|
-
Accordion as ExpansionPanel,
|
|
102
98
|
ExpandableListItem,
|
|
103
99
|
Divider,
|
|
104
100
|
};
|
|
@@ -114,13 +110,6 @@ export {
|
|
|
114
110
|
TablePagination,
|
|
115
111
|
};
|
|
116
112
|
|
|
117
|
-
export {
|
|
118
|
-
FormRoot,
|
|
119
|
-
FormError,
|
|
120
|
-
CancelButton,
|
|
121
|
-
SubmitButton,
|
|
122
|
-
IconSubmitButton,
|
|
123
|
-
DeleteForm,
|
|
124
|
-
};
|
|
113
|
+
export { Popup, SidePanel, Breadcrumbs, Pagination };
|
|
125
114
|
|
|
126
|
-
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,66 +0,0 @@
|
|
|
1
|
-
import React, { useMemo } from "react";
|
|
2
|
-
import { App as DefaultApp, usePlugin } from "@wq/react";
|
|
3
|
-
import {
|
|
4
|
-
MD2LightTheme,
|
|
5
|
-
MD3LightTheme,
|
|
6
|
-
MD2DarkTheme,
|
|
7
|
-
MD3DarkTheme,
|
|
8
|
-
Provider as PaperProvider,
|
|
9
|
-
} from "react-native-paper";
|
|
10
|
-
|
|
11
|
-
const THEMES = {
|
|
12
|
-
"light-2": MD2LightTheme,
|
|
13
|
-
"light-3": MD3LightTheme,
|
|
14
|
-
"dark-2": MD2DarkTheme,
|
|
15
|
-
"dark-3": MD3DarkTheme,
|
|
16
|
-
};
|
|
17
|
-
|
|
18
|
-
export default function App() {
|
|
19
|
-
const { theme: configTheme } = usePlugin("material").config,
|
|
20
|
-
theme = useMemo(() => createTheme(configTheme), [configTheme]),
|
|
21
|
-
options = useMemo(
|
|
22
|
-
() => ({
|
|
23
|
-
navigator: { theme },
|
|
24
|
-
screen: {
|
|
25
|
-
cardStyle: { backgroundColor: theme.colors.background },
|
|
26
|
-
},
|
|
27
|
-
}),
|
|
28
|
-
[theme]
|
|
29
|
-
);
|
|
30
|
-
|
|
31
|
-
return (
|
|
32
|
-
<PaperProvider theme={theme}>
|
|
33
|
-
<DefaultApp options={options} />
|
|
34
|
-
</PaperProvider>
|
|
35
|
-
);
|
|
36
|
-
}
|
|
37
|
-
|
|
38
|
-
function createTheme({
|
|
39
|
-
type = "light",
|
|
40
|
-
version = 3,
|
|
41
|
-
primary,
|
|
42
|
-
secondary,
|
|
43
|
-
background,
|
|
44
|
-
}) {
|
|
45
|
-
const colors = {},
|
|
46
|
-
base = THEMES[`${type}-${version}`];
|
|
47
|
-
if (!base) {
|
|
48
|
-
console.warn(`Unknown base theme type=${type} version=${version}`);
|
|
49
|
-
}
|
|
50
|
-
if (primary) {
|
|
51
|
-
colors.primary = primary;
|
|
52
|
-
}
|
|
53
|
-
if (secondary) {
|
|
54
|
-
colors.accent = secondary;
|
|
55
|
-
}
|
|
56
|
-
if (background) {
|
|
57
|
-
colors.background = background;
|
|
58
|
-
}
|
|
59
|
-
return {
|
|
60
|
-
...base,
|
|
61
|
-
colors: {
|
|
62
|
-
...(base || {}).colors,
|
|
63
|
-
...colors,
|
|
64
|
-
},
|
|
65
|
-
};
|
|
66
|
-
}
|
|
@@ -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,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
|
-
};
|
package/src/inputs/Fieldset.js
DELETED
|
@@ -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
|
-
};
|