@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
package/README.md
CHANGED
|
@@ -1,29 +1,13 @@
|
|
|
1
1
|
[![@wq/material][logo]][docs]
|
|
2
2
|
|
|
3
|
-
**@wq/material-native** provides [React Native]
|
|
3
|
+
**@wq/material-native** provides [React Native] / [Expo] bindings for [@wq/material], via the [React Native Paper] library.
|
|
4
4
|
|
|
5
5
|
### [Documentation][docs]
|
|
6
6
|
|
|
7
|
-
[**Installation**][installation]
|
|
8
|
-
•
|
|
9
|
-
[**API**][api]
|
|
10
|
-
•
|
|
11
|
-
[**Components**][components]
|
|
12
|
-
•
|
|
13
|
-
[Icons][icons]
|
|
14
|
-
•
|
|
15
|
-
[Inputs][inputs]
|
|
16
|
-
|
|
17
7
|
[logo]: https://wq.io/images/@wq/material.svg
|
|
18
|
-
[docs]: https://wq.io/@wq/material
|
|
19
|
-
[
|
|
20
|
-
[
|
|
21
|
-
[components]: https://wq.io/components/
|
|
22
|
-
[icons]: https://wq.io/icons
|
|
23
|
-
[inputs]: https://wq.io/inputs/
|
|
24
|
-
|
|
25
|
-
[@wq/material]: https://wq.io/@wq/material
|
|
26
|
-
[React]: https://reactjs.org/
|
|
8
|
+
[docs]: https://material.wq.io/@wq/material-native
|
|
9
|
+
[@wq/material]: https://material.wq.io/
|
|
10
|
+
[React]: https://react.dev/
|
|
27
11
|
[React Native]: https://reactnative.dev/
|
|
28
|
-
[Expo]: https://expo.
|
|
29
|
-
[React Native Paper]: https://
|
|
12
|
+
[Expo]: https://expo.dev/
|
|
13
|
+
[React Native Paper]: https://reactnativepaper.com/
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wq/material-native",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0-alpha.0",
|
|
4
4
|
"description": "React Native and Expo bindings for @wq/material",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -12,7 +12,7 @@
|
|
|
12
12
|
},
|
|
13
13
|
"repository": {
|
|
14
14
|
"type": "git",
|
|
15
|
-
"url": "git+https://github.com/wq/
|
|
15
|
+
"url": "git+https://github.com/wq/material.git",
|
|
16
16
|
"directory": "packages/material-native"
|
|
17
17
|
},
|
|
18
18
|
"keywords": [
|
|
@@ -24,34 +24,17 @@
|
|
|
24
24
|
"author": "S. Andrew Sheppard",
|
|
25
25
|
"license": "MIT",
|
|
26
26
|
"bugs": {
|
|
27
|
-
"url": "https://github.com/wq/
|
|
27
|
+
"url": "https://github.com/wq/material/issues"
|
|
28
28
|
},
|
|
29
|
-
"homepage": "https://wq.io/@wq/material",
|
|
29
|
+
"homepage": "https://material.wq.io/@wq/material-native",
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@wq/react": "^
|
|
32
|
-
"date-fns": "^2.30.0"
|
|
31
|
+
"@wq/react": "^3.0.0-alpha.0"
|
|
33
32
|
},
|
|
34
33
|
"peerDependencies": {
|
|
35
|
-
"
|
|
36
|
-
"@react-native-community/netinfo": "*",
|
|
37
|
-
"@react-navigation/stack": "*",
|
|
38
|
-
"expo-application": "*",
|
|
39
|
-
"expo-document-picker": "*",
|
|
40
|
-
"expo-image-picker": "*",
|
|
41
|
-
"react-native-modal-datetime-picker": "*",
|
|
42
|
-
"react-native-paper": "*",
|
|
43
|
-
"react-native-picker-select": "*"
|
|
34
|
+
"react-native-paper": "*"
|
|
44
35
|
},
|
|
45
36
|
"devDependencies": {
|
|
46
|
-
"
|
|
47
|
-
"
|
|
48
|
-
"@react-navigation/stack": "^6.3.17",
|
|
49
|
-
"expo-application": "^5.3.0",
|
|
50
|
-
"expo-document-picker": "^11.5.4",
|
|
51
|
-
"expo-image-picker": "^14.3.2",
|
|
52
|
-
"jest-expo": "^49.0.0",
|
|
53
|
-
"react-native-modal-datetime-picker": "^17.0.0",
|
|
54
|
-
"react-native-paper": "^5.10.1",
|
|
55
|
-
"react-native-picker-select": "github:Expensify/react-native-picker-select#eae0585"
|
|
37
|
+
"jest-expo": "^52.0.6",
|
|
38
|
+
"react-native-paper": "^5.14.5"
|
|
56
39
|
}
|
|
57
40
|
}
|
package/src/Root.js
ADDED
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
import React, { useMemo } from "react";
|
|
2
|
+
import { withWQ } from "@wq/react";
|
|
3
|
+
import {
|
|
4
|
+
MD2LightTheme,
|
|
5
|
+
MD3LightTheme,
|
|
6
|
+
MD2DarkTheme,
|
|
7
|
+
MD3DarkTheme,
|
|
8
|
+
Provider as PaperProvider,
|
|
9
|
+
} from "react-native-paper";
|
|
10
|
+
import * as components from "./components/index.js";
|
|
11
|
+
import { useMinWidth } from "./hooks.js";
|
|
12
|
+
import * as icons from "./icons.js";
|
|
13
|
+
|
|
14
|
+
const THEMES = {
|
|
15
|
+
"light-2": MD2LightTheme,
|
|
16
|
+
"light-3": MD3LightTheme,
|
|
17
|
+
"dark-2": MD2DarkTheme,
|
|
18
|
+
"dark-3": MD3DarkTheme,
|
|
19
|
+
};
|
|
20
|
+
|
|
21
|
+
const defaultTheme = {
|
|
22
|
+
type: "light",
|
|
23
|
+
version: 3,
|
|
24
|
+
primary: "#7500ae",
|
|
25
|
+
secondary: "#0088bd",
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
function Root({ children, theme }) {
|
|
29
|
+
if (theme) {
|
|
30
|
+
return <ThemeRoot theme={theme}>{children}</ThemeRoot>;
|
|
31
|
+
} else {
|
|
32
|
+
return children || null;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
function ThemeRoot({ children, theme }) {
|
|
37
|
+
const paperTheme = useMemo(() => createTheme(theme), [theme]);
|
|
38
|
+
return <PaperProvider theme={paperTheme}>{children}</PaperProvider>;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export default withWQ(Root, {
|
|
42
|
+
defaults: {
|
|
43
|
+
components: { ...components, useMinWidth },
|
|
44
|
+
icons: { ...icons, List: icons.ListIcon, Menu: icons.MenuIcon },
|
|
45
|
+
},
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
function createTheme(theme) {
|
|
49
|
+
if (theme === true) {
|
|
50
|
+
theme = defaultTheme;
|
|
51
|
+
}
|
|
52
|
+
const {
|
|
53
|
+
type = "light",
|
|
54
|
+
version = 3,
|
|
55
|
+
primary,
|
|
56
|
+
secondary,
|
|
57
|
+
background,
|
|
58
|
+
} = theme || {},
|
|
59
|
+
colors = {},
|
|
60
|
+
base = THEMES[`${type}-${version}`];
|
|
61
|
+
if (!base) {
|
|
62
|
+
console.warn(`Unknown base theme type=${type} version=${version}`);
|
|
63
|
+
}
|
|
64
|
+
if (primary) {
|
|
65
|
+
colors.primary = primary;
|
|
66
|
+
}
|
|
67
|
+
if (secondary) {
|
|
68
|
+
colors.accent = secondary;
|
|
69
|
+
}
|
|
70
|
+
if (background) {
|
|
71
|
+
colors.background = background;
|
|
72
|
+
}
|
|
73
|
+
return {
|
|
74
|
+
...base,
|
|
75
|
+
colors: {
|
|
76
|
+
...(base || {}).colors,
|
|
77
|
+
...colors,
|
|
78
|
+
},
|
|
79
|
+
};
|
|
80
|
+
}
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { List } from "react-native-paper";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function Accordion({ summary, children, open, onToggle }) {
|
|
6
7
|
let handleToggle;
|
|
7
8
|
if (onToggle) {
|
|
8
9
|
handleToggle = () => onToggle(!open);
|
|
@@ -20,3 +21,5 @@ Accordion.propTypes = {
|
|
|
20
21
|
open: PropTypes.bool,
|
|
21
22
|
onToggle: PropTypes.func,
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export default withWQ(Accordion);
|
package/src/components/Button.js
CHANGED
|
@@ -1,17 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { useIcon } from "@wq/react";
|
|
2
|
+
import { useIcon, withWQ } from "@wq/react";
|
|
3
3
|
import { Button as PaperButton, useTheme } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
onClick,
|
|
8
|
-
onPress,
|
|
9
|
-
variant,
|
|
10
|
-
mode,
|
|
11
|
-
icon,
|
|
12
|
-
color,
|
|
13
|
-
...rest
|
|
14
|
-
}) {
|
|
6
|
+
function Button({ onClick, onPress, variant, mode, icon, color, ...rest }) {
|
|
15
7
|
const Icon = useIcon(icon),
|
|
16
8
|
theme = useTheme();
|
|
17
9
|
if (!onPress) {
|
|
@@ -44,3 +36,5 @@ Button.propTypes = {
|
|
|
44
36
|
icon: PropTypes.string,
|
|
45
37
|
color: PropTypes.string,
|
|
46
38
|
};
|
|
39
|
+
|
|
40
|
+
export default withWQ(Button);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
3
|
-
import { useNav } from "
|
|
2
|
+
import { useComponents, withWQ } from "@wq/react";
|
|
3
|
+
import { useNav } from "./Link.js";
|
|
4
|
+
import Button from "./Button.js";
|
|
4
5
|
import PropTypes from "prop-types";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const ButtonLinkFallback = {
|
|
8
|
+
components: {
|
|
9
|
+
useNav,
|
|
10
|
+
Button,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function ButtonLink({ to, children }) {
|
|
15
|
+
const { useNav, Button } = useComponents();
|
|
7
16
|
const onPress = useNav(to);
|
|
8
17
|
return <Button onPress={onPress}>{children}</Button>;
|
|
9
18
|
}
|
|
@@ -12,3 +21,5 @@ ButtonLink.propTypes = {
|
|
|
12
21
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
13
22
|
children: PropTypes.node,
|
|
14
23
|
};
|
|
24
|
+
|
|
25
|
+
export default withWQ(ButtonLink, { fallback: ButtonLinkFallback });
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { Checkbox
|
|
2
|
+
import { Checkbox, useTheme } from "react-native-paper";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
6
|
const STATUSES = {
|
|
6
7
|
true: "checked",
|
|
@@ -9,7 +10,7 @@ const STATUSES = {
|
|
|
9
10
|
null: "indeterminate",
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
function CheckboxButton({ checked, color, ...props }) {
|
|
13
14
|
const status = STATUSES[checked],
|
|
14
15
|
theme = useTheme();
|
|
15
16
|
if (color === "primary") {
|
|
@@ -17,10 +18,12 @@ export default function Checkbox({ checked, color, ...props }) {
|
|
|
17
18
|
} else if (color === "secondary") {
|
|
18
19
|
color = theme.colors.accent;
|
|
19
20
|
}
|
|
20
|
-
return <
|
|
21
|
+
return <Checkbox status={status} {...props} />;
|
|
21
22
|
}
|
|
22
23
|
|
|
23
|
-
|
|
24
|
+
CheckboxButton.propTypes = {
|
|
24
25
|
checked: PropTypes.bool,
|
|
25
26
|
color: PropTypes.string,
|
|
26
27
|
};
|
|
28
|
+
|
|
29
|
+
export default withWQ(CheckboxButton);
|
package/src/components/Chip.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { useIcon } from "@wq/react";
|
|
2
|
+
import { useIcon, withWQ } from "@wq/react";
|
|
3
3
|
import { Chip as PaperChip, useTheme } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function Chip({
|
|
7
7
|
label,
|
|
8
8
|
icon,
|
|
9
9
|
color,
|
|
@@ -65,3 +65,5 @@ Chip.propTypes = {
|
|
|
65
65
|
onDelete: PropTypes.func,
|
|
66
66
|
onClose: PropTypes.func,
|
|
67
67
|
};
|
|
68
|
+
|
|
69
|
+
export default withWQ(Chip);
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React, { useState } from "react";
|
|
2
|
-
import { useIcon } from "@wq/react";
|
|
2
|
+
import { useIcon, withWQ } from "@wq/react";
|
|
3
3
|
import { List } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function ExpandableListItem({
|
|
7
7
|
children,
|
|
8
8
|
description,
|
|
9
9
|
icon,
|
|
@@ -44,3 +44,5 @@ ExpandableListItem.propTypes = {
|
|
|
44
44
|
open: PropTypes.bool,
|
|
45
45
|
onToggle: PropTypes.func,
|
|
46
46
|
};
|
|
47
|
+
|
|
48
|
+
export default withWQ(ExpandableListItem);
|
package/src/components/Fab.js
CHANGED
|
@@ -1,9 +1,17 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { FAB } from "react-native-paper";
|
|
3
|
-
import {
|
|
3
|
+
import { useComponents, useIcon, withWQ } from "@wq/react";
|
|
4
|
+
import { useNav } from "./Link.js";
|
|
4
5
|
import PropTypes from "prop-types";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const FabFallback = {
|
|
8
|
+
components: {
|
|
9
|
+
useNav,
|
|
10
|
+
},
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
function Fab({ icon, to, ...rest }) {
|
|
14
|
+
const { useNav } = useComponents();
|
|
7
15
|
const onPress = useNav(to),
|
|
8
16
|
Icon = useIcon(icon);
|
|
9
17
|
|
|
@@ -26,3 +34,5 @@ Fab.propTypes = {
|
|
|
26
34
|
icon: PropTypes.string,
|
|
27
35
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
28
36
|
};
|
|
37
|
+
|
|
38
|
+
export default withWQ(Fab, { fallback: FabFallback });
|
package/src/components/Footer.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Text, ScrollView } from "react-native";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function FormatJson({ json }) {
|
|
6
7
|
return (
|
|
7
8
|
<ScrollView style={{ height: 128 }}>
|
|
8
9
|
<Text>{JSON.stringify(json, null, 4)}</Text>
|
|
@@ -13,3 +14,5 @@ export default function FormatJson({ json }) {
|
|
|
13
14
|
FormatJson.propTypes = {
|
|
14
15
|
json: PropTypes.object,
|
|
15
16
|
};
|
|
17
|
+
|
|
18
|
+
export default withWQ(FormatJson);
|
package/src/components/Header.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Appbar } from "react-native-paper";
|
|
3
|
-
import {
|
|
3
|
+
import { useComponents, withWQ, createFallbackComponent } from "@wq/react";
|
|
4
|
+
import { useNav } from "./Link.js";
|
|
4
5
|
import PropTypes from "prop-types";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
const HeaderFallback = {
|
|
8
|
+
components: {
|
|
9
|
+
useNav,
|
|
10
|
+
useBreadcrumbs: createFallbackComponent("useBreadcrumbs", "@wq/router"),
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function Header({ options, route }) {
|
|
15
|
+
const { useNav, useBreadcrumbs } = useComponents();
|
|
7
16
|
const title = options.title || route.name,
|
|
8
17
|
breadcrumbs = useBreadcrumbs() || [],
|
|
9
18
|
previous = breadcrumbs[breadcrumbs.length - 2],
|
|
@@ -20,3 +29,5 @@ Header.propTypes = {
|
|
|
20
29
|
options: PropTypes.object,
|
|
21
30
|
route: PropTypes.object,
|
|
22
31
|
};
|
|
32
|
+
|
|
33
|
+
export default withWQ(Header, { fallback: HeaderFallback });
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function HorizontalView({ style, ...rest }) {
|
|
6
7
|
return (
|
|
7
8
|
<View
|
|
8
9
|
style={{
|
|
@@ -20,3 +21,5 @@ export default function HorizontalView({ style, ...rest }) {
|
|
|
20
21
|
HorizontalView.propTypes = {
|
|
21
22
|
style: PropTypes.object,
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export default withWQ(HorizontalView);
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { useIcon } from "@wq/react";
|
|
2
|
+
import { useIcon, withWQ } from "@wq/react";
|
|
3
3
|
import { IconButton as PaperIconButton, useTheme } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
|
|
7
|
-
const Icon = useIcon(icon),
|
|
6
|
+
function IconButton({ icon, onClick, onPress, color, ...rest }) {
|
|
7
|
+
const Icon = useIcon(icon) || "cancel",
|
|
8
8
|
theme = useTheme();
|
|
9
9
|
if (!onPress) {
|
|
10
10
|
onPress = onClick;
|
|
@@ -18,7 +18,7 @@ export default function IconButton({ icon, onClick, onPress, color, ...rest }) {
|
|
|
18
18
|
<PaperIconButton
|
|
19
19
|
icon={Icon}
|
|
20
20
|
onPress={onPress}
|
|
21
|
-
|
|
21
|
+
iconColor={color}
|
|
22
22
|
{...rest}
|
|
23
23
|
/>
|
|
24
24
|
);
|
|
@@ -30,3 +30,5 @@ IconButton.propTypes = {
|
|
|
30
30
|
onPress: PropTypes.func,
|
|
31
31
|
color: PropTypes.string,
|
|
32
32
|
};
|
|
33
|
+
|
|
34
|
+
export default withWQ(IconButton);
|
package/src/components/Img.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React, { useState, useEffect } from "react";
|
|
2
2
|
import { Image, TouchableOpacity, Dimensions } from "react-native";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function Img({ src, onPress, onClick, style, ...props }) {
|
|
6
7
|
const [source, setSource] = useState(src ? { uri: src } : null);
|
|
7
8
|
useEffect(() => {
|
|
8
9
|
if (!src) {
|
|
@@ -93,10 +94,12 @@ export default function Img({ src, onPress, onClick, style, ...props }) {
|
|
|
93
94
|
}
|
|
94
95
|
|
|
95
96
|
Img.propTypes = {
|
|
96
|
-
src: PropTypes.oneOfType(PropTypes.string, PropTypes.number),
|
|
97
|
+
src: PropTypes.oneOfType([PropTypes.string, PropTypes.number]),
|
|
97
98
|
width: PropTypes.number,
|
|
98
99
|
height: PropTypes.number,
|
|
99
100
|
onPress: PropTypes.func,
|
|
100
101
|
onClick: PropTypes.func,
|
|
101
102
|
style: PropTypes.object,
|
|
102
103
|
};
|
|
104
|
+
|
|
105
|
+
export default withWQ(Img);
|
package/src/components/Link.js
CHANGED
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
+
import { useComponents, withWQ, createFallbackComponent } from "@wq/react";
|
|
2
3
|
import { Button } from "react-native";
|
|
3
|
-
import { useNav } from "@wq/react";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
export
|
|
6
|
+
export const useNav = createFallbackComponent("useNav", "@wq/router");
|
|
7
|
+
|
|
8
|
+
const LinkFallback = {
|
|
9
|
+
components: {
|
|
10
|
+
useNav,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function Link({ to, children }) {
|
|
15
|
+
const { useNav } = useComponents();
|
|
7
16
|
const onPress = useNav(to);
|
|
8
17
|
// FIXME: Use styled text instead?
|
|
9
18
|
return <Button title={children} onPress={onPress} />;
|
|
@@ -13,3 +22,5 @@ Link.propTypes = {
|
|
|
13
22
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
14
23
|
children: PropTypes.node,
|
|
15
24
|
};
|
|
25
|
+
|
|
26
|
+
export default withWQ(Link, { fallback: LinkFallback });
|
package/src/components/List.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import { useIcon } from "@wq/react";
|
|
2
|
+
import { useIcon, withWQ } from "@wq/react";
|
|
3
3
|
import { List } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
function ListItem({
|
|
7
7
|
children,
|
|
8
8
|
description,
|
|
9
9
|
icon,
|
|
@@ -36,3 +36,5 @@ ListItem.propTypes = {
|
|
|
36
36
|
style: PropTypes.object,
|
|
37
37
|
onClick: PropTypes.func,
|
|
38
38
|
};
|
|
39
|
+
|
|
40
|
+
export default withWQ(ListItem);
|
|
@@ -1,9 +1,18 @@
|
|
|
1
1
|
import React from "react";
|
|
2
|
-
import {
|
|
2
|
+
import { useComponents, withWQ } from "@wq/react";
|
|
3
|
+
import { useNav } from "./Link.js";
|
|
4
|
+
import ListItem from "./ListItem.js";
|
|
3
5
|
import PropTypes from "prop-types";
|
|
4
6
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
+
const ListItemLinkFallback = {
|
|
8
|
+
components: {
|
|
9
|
+
useNav,
|
|
10
|
+
ListItem,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
|
|
14
|
+
function ListItemLink({ to, ...rest }) {
|
|
15
|
+
const { useNav, ListItem } = useComponents(),
|
|
7
16
|
onPress = useNav(to);
|
|
8
17
|
return <ListItem onPress={onPress} {...rest} />;
|
|
9
18
|
}
|
|
@@ -11,3 +20,5 @@ export default function ListItemLink({ to, ...rest }) {
|
|
|
11
20
|
ListItemLink.propTypes = {
|
|
12
21
|
to: PropTypes.oneOfType([PropTypes.string, PropTypes.object]),
|
|
13
22
|
};
|
|
23
|
+
|
|
24
|
+
export default withWQ(ListItemLink, { fallback: ListItemLinkFallback });
|
package/src/components/Main.js
CHANGED
package/src/components/Popup.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { Modal, Portal } from "react-native-paper";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
function Popup({ open, onClose, children, ...rest }) {
|
|
6
7
|
return (
|
|
7
8
|
<Portal>
|
|
8
9
|
<Modal visible={open} onDismiss={onClose} {...rest}>
|
|
@@ -17,3 +18,5 @@ Popup.propTypes = {
|
|
|
17
18
|
onClose: PropTypes.func,
|
|
18
19
|
children: PropTypes.node,
|
|
19
20
|
};
|
|
21
|
+
|
|
22
|
+
export default withWQ(Popup);
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { RadioButton as PaperRadioButton, useTheme } from "react-native-paper";
|
|
3
3
|
import PropTypes from "prop-types";
|
|
4
|
+
import { withWQ } from "@wq/react";
|
|
4
5
|
|
|
5
6
|
const STATUSES = {
|
|
6
7
|
true: "checked",
|
|
@@ -9,7 +10,7 @@ const STATUSES = {
|
|
|
9
10
|
null: "unchecked",
|
|
10
11
|
};
|
|
11
12
|
|
|
12
|
-
|
|
13
|
+
function RadioButton({ checked, color, ...rest }) {
|
|
13
14
|
const status = STATUSES[checked],
|
|
14
15
|
theme = useTheme();
|
|
15
16
|
if (color === "primary") {
|
|
@@ -24,3 +25,5 @@ RadioButton.propTypes = {
|
|
|
24
25
|
checked: PropTypes.bool,
|
|
25
26
|
color: PropTypes.string,
|
|
26
27
|
};
|
|
28
|
+
|
|
29
|
+
export default withWQ(RadioButton);
|
|
@@ -2,8 +2,9 @@ import React from "react";
|
|
|
2
2
|
import { ScrollView as PaperScrollView } from "react-native";
|
|
3
3
|
import { useTheme } from "react-native-paper";
|
|
4
4
|
import PropTypes from "prop-types";
|
|
5
|
+
import { withWQ } from "@wq/react";
|
|
5
6
|
|
|
6
|
-
|
|
7
|
+
function ScrollView({ style, ...rest }) {
|
|
7
8
|
const theme = useTheme();
|
|
8
9
|
return (
|
|
9
10
|
<PaperScrollView
|
|
@@ -20,3 +21,5 @@ export default function ScrollView({ style, ...rest }) {
|
|
|
20
21
|
ScrollView.propTypes = {
|
|
21
22
|
style: PropTypes.object,
|
|
22
23
|
};
|
|
24
|
+
|
|
25
|
+
export default withWQ(ScrollView);
|