@draftbit/core 43.4.5-312b1d.1 → 43.4.5-4e19aa.1
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/lib/commonjs/components/Elevation.js +14 -3
- package/lib/commonjs/components/Elevation.js.map +1 -1
- package/lib/commonjs/components/FieldSearchBarFull.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButton.js +6 -9
- package/lib/commonjs/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js +8 -18
- package/lib/commonjs/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js +9 -14
- package/lib/commonjs/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/commonjs/components/Table/index.js +56 -0
- package/lib/commonjs/components/Table/index.js.map +1 -0
- package/lib/commonjs/components/Table/table.js +36 -0
- package/lib/commonjs/components/Table/table.js.map +1 -0
- package/lib/commonjs/components/Table/tableCell.js +44 -0
- package/lib/commonjs/components/Table/tableCell.js.map +1 -0
- package/lib/commonjs/components/Table/tableHeader.js +42 -0
- package/lib/commonjs/components/Table/tableHeader.js.map +1 -0
- package/lib/commonjs/components/Table/tablePaginator.js +18 -0
- package/lib/commonjs/components/Table/tablePaginator.js.map +1 -0
- package/lib/commonjs/components/Table/tableRow.js +48 -0
- package/lib/commonjs/components/Table/tableRow.js.map +1 -0
- package/lib/commonjs/components/Table/tableTitle.js +61 -0
- package/lib/commonjs/components/Table/tableTitle.js.map +1 -0
- package/lib/commonjs/index.js +38 -0
- package/lib/commonjs/index.js.map +1 -1
- package/lib/commonjs/mappings/Table.js +99 -0
- package/lib/commonjs/mappings/Table.js.map +1 -0
- package/lib/commonjs/utilities.js +7 -16
- package/lib/commonjs/utilities.js.map +1 -1
- package/lib/module/components/DatePicker/DatePickerComponentType.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButton.js +6 -8
- package/lib/module/components/RadioButton/RadioButton.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonGroup.js +8 -17
- package/lib/module/components/RadioButton/RadioButtonGroup.js.map +1 -1
- package/lib/module/components/RadioButton/RadioButtonRow.js +10 -15
- package/lib/module/components/RadioButton/RadioButtonRow.js.map +1 -1
- package/lib/module/components/ResizeMode.js +2 -2
- package/lib/module/components/ResizeMode.js.map +1 -1
- package/lib/module/components/Table/index.js +7 -0
- package/lib/module/components/Table/index.js.map +1 -0
- package/lib/module/components/Table/table.js +24 -0
- package/lib/module/components/Table/table.js.map +1 -0
- package/lib/module/components/Table/tableCell.js +32 -0
- package/lib/module/components/Table/tableCell.js.map +1 -0
- package/lib/module/components/Table/tableHeader.js +28 -0
- package/lib/module/components/Table/tableHeader.js.map +1 -0
- package/lib/module/components/Table/tablePaginator.js +7 -0
- package/lib/module/components/Table/tablePaginator.js.map +1 -0
- package/lib/module/components/Table/tableRow.js +34 -0
- package/lib/module/components/Table/tableRow.js.map +1 -0
- package/lib/module/components/Table/tableTitle.js +48 -0
- package/lib/module/components/Table/tableTitle.js.map +1 -0
- package/lib/module/index.js +1 -0
- package/lib/module/index.js.map +1 -1
- package/lib/module/mappings/BlurView.js.map +1 -1
- package/lib/module/mappings/Table.js +90 -0
- package/lib/module/mappings/Table.js.map +1 -0
- package/lib/module/utilities.js +4 -14
- package/lib/module/utilities.js.map +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButton.d.ts +2 -2
- package/lib/typescript/src/components/RadioButton/RadioButtonGroup.d.ts +1 -1
- package/lib/typescript/src/components/RadioButton/RadioButtonRow.d.ts +1 -1
- package/lib/typescript/src/components/Table/index.d.ts +6 -0
- package/lib/typescript/src/components/Table/table.d.ts +8 -0
- package/lib/typescript/src/components/Table/tableCell.d.ts +10 -0
- package/lib/typescript/src/components/Table/tableHeader.d.ts +12 -0
- package/lib/typescript/src/components/Table/tablePaginator.d.ts +3 -0
- package/lib/typescript/src/components/Table/tableRow.d.ts +12 -0
- package/lib/typescript/src/components/Table/tableTitle.d.ts +12 -0
- package/lib/typescript/src/index.d.ts +1 -0
- package/lib/typescript/src/utilities.d.ts +4 -4
- package/package.json +2 -2
- package/src/components/RadioButton/RadioButton.js +5 -9
- package/src/components/RadioButton/RadioButton.tsx +10 -13
- package/src/components/RadioButton/RadioButtonGroup.js +8 -14
- package/src/components/RadioButton/RadioButtonGroup.tsx +12 -21
- package/src/components/RadioButton/RadioButtonRow.js +9 -15
- package/src/components/RadioButton/RadioButtonRow.tsx +13 -19
- package/src/components/Table/index.js +6 -0
- package/src/components/Table/index.tsx +6 -0
- package/src/components/Table/table.js +10 -0
- package/src/components/Table/table.tsx +22 -0
- package/src/components/Table/tableCell.js +17 -0
- package/src/components/Table/tableCell.tsx +37 -0
- package/src/components/Table/tableHeader.js +11 -0
- package/src/components/Table/tableHeader.tsx +28 -0
- package/src/components/Table/tablePaginator.js +5 -0
- package/src/components/Table/tablePaginator.tsx +10 -0
- package/src/components/Table/tableRow.js +16 -0
- package/src/components/Table/tableRow.tsx +31 -0
- package/src/components/Table/tableTitle.js +28 -0
- package/src/components/Table/tableTitle.tsx +59 -0
- package/src/index.js +1 -0
- package/src/index.tsx +9 -0
- package/src/mappings/Table.js +102 -0
- package/src/utilities.js +6 -16
- package/src/utilities.ts +6 -14
|
@@ -3,7 +3,6 @@ import { StyleProp, ViewStyle } from "react-native";
|
|
|
3
3
|
|
|
4
4
|
import Config from "../Config";
|
|
5
5
|
import IconButton from "../IconButton";
|
|
6
|
-
import { getValueForRadioButton } from "../../utilities";
|
|
7
6
|
import { useRadioButtonGroupContext } from "./context";
|
|
8
7
|
|
|
9
8
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
@@ -12,9 +11,9 @@ export type RadioButtonProps = {
|
|
|
12
11
|
selected?: boolean;
|
|
13
12
|
disabled?: boolean;
|
|
14
13
|
color?: string;
|
|
15
|
-
value?: string
|
|
14
|
+
value?: string;
|
|
16
15
|
unselectedColor?: string;
|
|
17
|
-
onPress?: (
|
|
16
|
+
onPress?: () => void;
|
|
18
17
|
style?: StyleProp<ViewStyle>;
|
|
19
18
|
size?: number;
|
|
20
19
|
selectedIcon?: string;
|
|
@@ -28,7 +27,7 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
28
27
|
value,
|
|
29
28
|
selected,
|
|
30
29
|
unselectedColor,
|
|
31
|
-
onPress,
|
|
30
|
+
onPress = () => {},
|
|
32
31
|
size = Config.radioButtonSize,
|
|
33
32
|
selectedIcon = "MaterialIcons/radio-button-checked",
|
|
34
33
|
unselectedIcon = "MaterialIcons/radio-button-unchecked",
|
|
@@ -37,19 +36,17 @@ const RadioButton: React.FC<RadioButtonProps> = ({
|
|
|
37
36
|
}) => {
|
|
38
37
|
const { value: contextValue, onValueChange } = useRadioButtonGroupContext();
|
|
39
38
|
|
|
40
|
-
const realValue = getValueForRadioButton(value);
|
|
41
|
-
const realContextValue = getValueForRadioButton(contextValue);
|
|
42
|
-
const isSelected =
|
|
43
|
-
selected ??
|
|
44
|
-
(realContextValue && realValue && realContextValue === realValue);
|
|
45
|
-
|
|
46
39
|
const handlePress = () => {
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
40
|
+
onPress && onPress();
|
|
41
|
+
|
|
42
|
+
if (onValueChange && value) {
|
|
43
|
+
onValueChange(value);
|
|
50
44
|
}
|
|
51
45
|
};
|
|
52
46
|
|
|
47
|
+
const isSelected =
|
|
48
|
+
selected || (contextValue != null && contextValue === value);
|
|
49
|
+
|
|
53
50
|
return (
|
|
54
51
|
<IconButton
|
|
55
52
|
Icon={Icon}
|
|
@@ -1,28 +1,22 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View } from "react-native";
|
|
3
|
-
import { getValueForRadioButton } from "../../utilities";
|
|
4
3
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
5
4
|
const { Provider } = radioButtonGroupContext;
|
|
6
|
-
const RadioButtonGroup = ({ direction = Direction.Vertical, value, onValueChange, defaultValue, style, children, ...rest }) => {
|
|
7
|
-
const [internalValue, setInternalValue] = React.useState();
|
|
5
|
+
const RadioButtonGroup = ({ direction = Direction.Vertical, value, onValueChange = () => { }, defaultValue, style, children, ...rest }) => {
|
|
6
|
+
const [internalValue, setInternalValue] = React.useState(value || defaultValue);
|
|
8
7
|
React.useEffect(() => {
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
setInternalValue(realValue);
|
|
8
|
+
if (value != null) {
|
|
9
|
+
setInternalValue(value);
|
|
12
10
|
}
|
|
13
11
|
}, [value]);
|
|
14
12
|
React.useEffect(() => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
setInternalValue(realDefaultValue);
|
|
13
|
+
if (defaultValue != null) {
|
|
14
|
+
setInternalValue(defaultValue);
|
|
18
15
|
}
|
|
19
16
|
}, [defaultValue]);
|
|
20
17
|
const handleValueChange = (newValue) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
setInternalValue(realNewValue);
|
|
24
|
-
onValueChange?.(realNewValue);
|
|
25
|
-
}
|
|
18
|
+
setInternalValue(newValue);
|
|
19
|
+
onValueChange(newValue);
|
|
26
20
|
};
|
|
27
21
|
const _containerStyle = [
|
|
28
22
|
{
|
|
@@ -1,14 +1,13 @@
|
|
|
1
1
|
import * as React from "react";
|
|
2
2
|
import { View, StyleProp, ViewStyle } from "react-native";
|
|
3
3
|
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
-
import { getValueForRadioButton } from "../../utilities";
|
|
5
4
|
import { radioButtonGroupContext, Direction } from "./context";
|
|
6
5
|
export interface RadioButtonGroupProps {
|
|
7
6
|
direction?: Direction;
|
|
8
7
|
style?: StyleProp<ViewStyle>;
|
|
9
8
|
value?: string;
|
|
10
9
|
onValueChange?: (value: string) => void;
|
|
11
|
-
defaultValue?: string
|
|
10
|
+
defaultValue?: string;
|
|
12
11
|
theme: Theme;
|
|
13
12
|
children: React.ReactNode;
|
|
14
13
|
}
|
|
@@ -18,39 +17,31 @@ const { Provider } = radioButtonGroupContext;
|
|
|
18
17
|
const RadioButtonGroup: React.FC<RadioButtonGroupProps> = ({
|
|
19
18
|
direction = Direction.Vertical,
|
|
20
19
|
value,
|
|
21
|
-
onValueChange,
|
|
20
|
+
onValueChange = () => {},
|
|
22
21
|
defaultValue,
|
|
23
22
|
style,
|
|
24
23
|
children,
|
|
25
24
|
...rest
|
|
26
25
|
}) => {
|
|
27
|
-
const [internalValue, setInternalValue] = React.useState<
|
|
28
|
-
|
|
29
|
-
|
|
26
|
+
const [internalValue, setInternalValue] = React.useState<string | undefined>(
|
|
27
|
+
value || defaultValue
|
|
28
|
+
);
|
|
30
29
|
|
|
31
30
|
React.useEffect(() => {
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
if (realValue) {
|
|
35
|
-
setInternalValue(realValue);
|
|
31
|
+
if (value != null) {
|
|
32
|
+
setInternalValue(value);
|
|
36
33
|
}
|
|
37
34
|
}, [value]);
|
|
38
35
|
|
|
39
36
|
React.useEffect(() => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
if (realDefaultValue) {
|
|
43
|
-
setInternalValue(realDefaultValue);
|
|
37
|
+
if (defaultValue != null) {
|
|
38
|
+
setInternalValue(defaultValue);
|
|
44
39
|
}
|
|
45
40
|
}, [defaultValue]);
|
|
46
41
|
|
|
47
|
-
const handleValueChange = (newValue
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
if (realNewValue) {
|
|
51
|
-
setInternalValue(realNewValue);
|
|
52
|
-
onValueChange?.(realNewValue);
|
|
53
|
-
}
|
|
42
|
+
const handleValueChange = (newValue: string) => {
|
|
43
|
+
setInternalValue(newValue);
|
|
44
|
+
onValueChange(newValue);
|
|
54
45
|
};
|
|
55
46
|
|
|
56
47
|
const _containerStyle: StyleProp<ViewStyle> = [
|
|
@@ -5,7 +5,7 @@ import Text from "../Text";
|
|
|
5
5
|
import { useRadioButtonGroupContext } from "./context";
|
|
6
6
|
import { Direction as GroupDirection } from "./context";
|
|
7
7
|
import Touchable from "../Touchable";
|
|
8
|
-
import { extractStyles
|
|
8
|
+
import { extractStyles } from "../../utilities";
|
|
9
9
|
export var Direction;
|
|
10
10
|
(function (Direction) {
|
|
11
11
|
Direction["Row"] = "row";
|
|
@@ -22,25 +22,19 @@ const getRadioButtonAlignment = (parentDirection, direction) => {
|
|
|
22
22
|
return "flex-end";
|
|
23
23
|
}
|
|
24
24
|
};
|
|
25
|
-
const renderLabel = (
|
|
26
|
-
if (typeof
|
|
27
|
-
return React.createElement(Text, { style: [labelStyle, textStyle] },
|
|
25
|
+
const renderLabel = (value, labelStyle, textStyle) => {
|
|
26
|
+
if (typeof value === "string") {
|
|
27
|
+
return React.createElement(Text, { style: [labelStyle, textStyle] }, value);
|
|
28
28
|
}
|
|
29
29
|
else {
|
|
30
|
-
return React.createElement(React.Fragment, null,
|
|
30
|
+
return React.createElement(React.Fragment, null, value);
|
|
31
31
|
}
|
|
32
32
|
};
|
|
33
|
-
const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
|
|
33
|
+
const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress = () => { }, labelContainerStyle, labelStyle, radioButtonStyle, direction = Direction.Row, selected, disabled, style, ...rest }) => {
|
|
34
34
|
const { value: contextValue, onValueChange, direction: parentDirection, } = useRadioButtonGroupContext();
|
|
35
|
-
const realValue = getValueForRadioButton(value);
|
|
36
|
-
const realContextValue = getValueForRadioButton(contextValue);
|
|
37
|
-
const isSelected = selected ??
|
|
38
|
-
(realContextValue && realValue && realContextValue === realValue);
|
|
39
35
|
const handlePress = () => {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
onValueChange?.(realValue);
|
|
43
|
-
}
|
|
36
|
+
onPress(value);
|
|
37
|
+
onValueChange && onValueChange(value);
|
|
44
38
|
};
|
|
45
39
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
46
40
|
return (React.createElement(Touchable, { onPress: handlePress, style: [styles.mainParent, { flexDirection: direction }, viewStyles], disabled: disabled, ...rest },
|
|
@@ -55,7 +49,7 @@ const RadioButtonRow = ({ Icon, label, value, color, unselectedColor, onPress, l
|
|
|
55
49
|
flex: 1,
|
|
56
50
|
alignItems: getRadioButtonAlignment(parentDirection, direction),
|
|
57
51
|
} },
|
|
58
|
-
React.createElement(RadioButton, { Icon: Icon, selected:
|
|
52
|
+
React.createElement(RadioButton, { Icon: Icon, selected: selected || (contextValue != null && contextValue === value), color: color, unselectedColor: unselectedColor, onPress: handlePress, style: radioButtonStyle }))));
|
|
59
53
|
};
|
|
60
54
|
const styles = StyleSheet.create({
|
|
61
55
|
mainParent: {
|
|
@@ -13,7 +13,7 @@ import { useRadioButtonGroupContext } from "./context";
|
|
|
13
13
|
import type { IconSlot } from "../../interfaces/Icon";
|
|
14
14
|
import { Direction as GroupDirection } from "./context";
|
|
15
15
|
import Touchable from "../Touchable";
|
|
16
|
-
import { extractStyles
|
|
16
|
+
import { extractStyles } from "../../utilities";
|
|
17
17
|
|
|
18
18
|
export enum Direction {
|
|
19
19
|
Row = "row",
|
|
@@ -22,7 +22,7 @@ export enum Direction {
|
|
|
22
22
|
|
|
23
23
|
export interface RadioButtonRowProps extends Omit<RadioButtonProps, "onPress"> {
|
|
24
24
|
label: string | React.ReactNode;
|
|
25
|
-
value: string
|
|
25
|
+
value: string; // A string that this radio button row represents when selected
|
|
26
26
|
color?: string;
|
|
27
27
|
unselectedColor?: string;
|
|
28
28
|
labelContainerStyle: StyleProp<ViewStyle>;
|
|
@@ -46,14 +46,14 @@ const getRadioButtonAlignment = (
|
|
|
46
46
|
};
|
|
47
47
|
|
|
48
48
|
const renderLabel = (
|
|
49
|
-
|
|
49
|
+
value: string | React.ReactNode,
|
|
50
50
|
labelStyle: StyleProp<TextStyle>,
|
|
51
51
|
textStyle: StyleProp<TextStyle>
|
|
52
52
|
) => {
|
|
53
|
-
if (typeof
|
|
54
|
-
return <Text style={[labelStyle, textStyle]}>{
|
|
53
|
+
if (typeof value === "string") {
|
|
54
|
+
return <Text style={[labelStyle, textStyle]}>{value}</Text>;
|
|
55
55
|
} else {
|
|
56
|
-
return <>{
|
|
56
|
+
return <>{value}</>;
|
|
57
57
|
}
|
|
58
58
|
};
|
|
59
59
|
|
|
@@ -63,7 +63,7 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
|
63
63
|
value,
|
|
64
64
|
color,
|
|
65
65
|
unselectedColor,
|
|
66
|
-
onPress,
|
|
66
|
+
onPress = () => {},
|
|
67
67
|
labelContainerStyle,
|
|
68
68
|
labelStyle,
|
|
69
69
|
radioButtonStyle,
|
|
@@ -79,17 +79,9 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
|
79
79
|
direction: parentDirection,
|
|
80
80
|
} = useRadioButtonGroupContext();
|
|
81
81
|
|
|
82
|
-
const realValue = getValueForRadioButton(value);
|
|
83
|
-
const realContextValue = getValueForRadioButton(contextValue);
|
|
84
|
-
const isSelected =
|
|
85
|
-
selected ??
|
|
86
|
-
(realContextValue && realValue && realContextValue === realValue);
|
|
87
|
-
|
|
88
82
|
const handlePress = () => {
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
onValueChange?.(realValue);
|
|
92
|
-
}
|
|
83
|
+
onPress(value);
|
|
84
|
+
onValueChange && onValueChange(value);
|
|
93
85
|
};
|
|
94
86
|
|
|
95
87
|
const { textStyles, viewStyles } = extractStyles(style);
|
|
@@ -120,10 +112,12 @@ const RadioButtonRow: React.FC<RadioButtonRowProps & IconSlot> = ({
|
|
|
120
112
|
>
|
|
121
113
|
<RadioButton
|
|
122
114
|
Icon={Icon}
|
|
123
|
-
selected={
|
|
124
|
-
|
|
115
|
+
selected={
|
|
116
|
+
selected || (contextValue != null && contextValue === value)
|
|
117
|
+
}
|
|
125
118
|
color={color}
|
|
126
119
|
unselectedColor={unselectedColor}
|
|
120
|
+
onPress={handlePress}
|
|
127
121
|
style={radioButtonStyle}
|
|
128
122
|
/>
|
|
129
123
|
</View>
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Table } from "./table";
|
|
2
|
+
export { default as TableHeader } from "./tableHeader";
|
|
3
|
+
export { default as TablePaginator } from "./tablePaginator";
|
|
4
|
+
export { default as TableRow } from "./tableRow";
|
|
5
|
+
export { default as TableCell } from "./tableCell";
|
|
6
|
+
export { default as TableTitle } from "./tableTitle";
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export { default as Table } from "./table";
|
|
2
|
+
export { default as TableHeader } from "./tableHeader";
|
|
3
|
+
export { default as TablePaginator } from "./tablePaginator";
|
|
4
|
+
export { default as TableRow } from "./tableRow";
|
|
5
|
+
export { default as TableCell } from "./tableCell";
|
|
6
|
+
export { default as TableTitle } from "./tableTitle";
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
const Table = ({ children, style, ...rest }) => (React.createElement(View, { ...rest, style: [styles.wrapper, style] }, children));
|
|
4
|
+
const styles = StyleSheet.create({
|
|
5
|
+
wrapper: {
|
|
6
|
+
display: "flex",
|
|
7
|
+
flexDirection: "column",
|
|
8
|
+
},
|
|
9
|
+
});
|
|
10
|
+
export default Table;
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface TableProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
style?: StyleProp<ViewStyle>;
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
const Table = ({ children, style, ...rest }: TableProps) => (
|
|
10
|
+
<View {...rest} style={[styles.wrapper, style]}>
|
|
11
|
+
{children}
|
|
12
|
+
</View>
|
|
13
|
+
);
|
|
14
|
+
|
|
15
|
+
const styles = StyleSheet.create({
|
|
16
|
+
wrapper: {
|
|
17
|
+
display: "flex",
|
|
18
|
+
flexDirection: "column",
|
|
19
|
+
},
|
|
20
|
+
});
|
|
21
|
+
|
|
22
|
+
export default Table;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
3
|
+
const TableCell = ({ children, style, numeric, value, ...rest }) => (React.createElement(View, { ...rest, style: [styles.wrapper, numeric && styles.right, style] },
|
|
4
|
+
React.createElement(Text, { numberOfLines: 1 },
|
|
5
|
+
children,
|
|
6
|
+
value)));
|
|
7
|
+
const styles = StyleSheet.create({
|
|
8
|
+
wrapper: {
|
|
9
|
+
flex: 1,
|
|
10
|
+
display: "flex",
|
|
11
|
+
flexDirection: "row",
|
|
12
|
+
},
|
|
13
|
+
right: {
|
|
14
|
+
justifyContent: "flex-end",
|
|
15
|
+
},
|
|
16
|
+
});
|
|
17
|
+
export default TableCell;
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
|
|
4
|
+
export interface TableCellProps {
|
|
5
|
+
children: React.ReactNode;
|
|
6
|
+
numeric?: boolean;
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
value: string;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const TableCell = ({
|
|
12
|
+
children,
|
|
13
|
+
style,
|
|
14
|
+
numeric,
|
|
15
|
+
value,
|
|
16
|
+
...rest
|
|
17
|
+
}: TableCellProps) => (
|
|
18
|
+
<View {...rest} style={[styles.wrapper, numeric && styles.right, style]}>
|
|
19
|
+
<Text numberOfLines={1}>
|
|
20
|
+
{children}
|
|
21
|
+
{value}
|
|
22
|
+
</Text>
|
|
23
|
+
</View>
|
|
24
|
+
);
|
|
25
|
+
|
|
26
|
+
const styles = StyleSheet.create({
|
|
27
|
+
wrapper: {
|
|
28
|
+
flex: 1,
|
|
29
|
+
display: "flex",
|
|
30
|
+
flexDirection: "row",
|
|
31
|
+
},
|
|
32
|
+
right: {
|
|
33
|
+
justifyContent: "flex-end",
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
export default TableCell;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { withTheme } from "../../theming";
|
|
4
|
+
const TableHeader = ({ children, style, theme, ...rest }) => (React.createElement(View, { ...rest, style: [styles.wrapper, { borderBottomColor: theme.colors.medium }, style] }, children));
|
|
5
|
+
const styles = StyleSheet.create({
|
|
6
|
+
wrapper: {
|
|
7
|
+
display: "flex",
|
|
8
|
+
flexDirection: "row",
|
|
9
|
+
},
|
|
10
|
+
});
|
|
11
|
+
export default withTheme(TableHeader);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
|
|
6
|
+
export interface TableHeaderProps {
|
|
7
|
+
children: React.ReactNode;
|
|
8
|
+
style?: StyleProp<ViewStyle>;
|
|
9
|
+
theme: Theme;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
const TableHeader = ({ children, style, theme, ...rest }: TableHeaderProps) => (
|
|
13
|
+
<View
|
|
14
|
+
{...rest}
|
|
15
|
+
style={[styles.wrapper, { borderBottomColor: theme.colors.medium }, style]}
|
|
16
|
+
>
|
|
17
|
+
{children}
|
|
18
|
+
</View>
|
|
19
|
+
);
|
|
20
|
+
|
|
21
|
+
const styles = StyleSheet.create({
|
|
22
|
+
wrapper: {
|
|
23
|
+
display: "flex",
|
|
24
|
+
flexDirection: "row",
|
|
25
|
+
},
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
export default withTheme(TableHeader);
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleSheet } from "react-native";
|
|
3
|
+
import { withTheme } from "../../theming";
|
|
4
|
+
const TableRow = ({ children, style, theme, ...rest }) => (React.createElement(View, { ...rest, style: [styles.container, { borderBottomColor: theme.colors.light }, style] },
|
|
5
|
+
React.createElement(View, { style: styles.content }, children)));
|
|
6
|
+
const styles = StyleSheet.create({
|
|
7
|
+
container: {
|
|
8
|
+
display: "flex",
|
|
9
|
+
flexDirection: "row",
|
|
10
|
+
},
|
|
11
|
+
content: {
|
|
12
|
+
flex: 1,
|
|
13
|
+
flexDirection: "row",
|
|
14
|
+
},
|
|
15
|
+
});
|
|
16
|
+
export default withTheme(TableRow);
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
4
|
+
import { withTheme } from "../../theming";
|
|
5
|
+
export interface TableRowProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
style?: StyleProp<ViewStyle>;
|
|
8
|
+
theme: Theme;
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const TableRow = ({ children, style, theme, ...rest }: TableRowProps) => (
|
|
12
|
+
<View
|
|
13
|
+
{...rest}
|
|
14
|
+
style={[styles.container, { borderBottomColor: theme.colors.light }, style]}
|
|
15
|
+
>
|
|
16
|
+
<View style={styles.content}>{children}</View>
|
|
17
|
+
</View>
|
|
18
|
+
);
|
|
19
|
+
|
|
20
|
+
const styles = StyleSheet.create({
|
|
21
|
+
container: {
|
|
22
|
+
display: "flex",
|
|
23
|
+
flexDirection: "row",
|
|
24
|
+
},
|
|
25
|
+
content: {
|
|
26
|
+
flex: 1,
|
|
27
|
+
flexDirection: "row",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
export default withTheme(TableRow);
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleSheet } from "react-native";
|
|
3
|
+
import { extractStyles } from "../../utilities";
|
|
4
|
+
const TableTitle = ({ children, style, numeric = false, isAscending = false, numberOfLines = 1, title, ...rest }) => {
|
|
5
|
+
const { textStyles, viewStyles } = extractStyles(style);
|
|
6
|
+
return (React.createElement(View, { ...rest, style: [styles.wrapper, numeric && styles.right, viewStyles] },
|
|
7
|
+
React.createElement(Text, { style: [isAscending ? styles.sorted : { color: "gray" }, textStyles], numberOfLines: numberOfLines },
|
|
8
|
+
children,
|
|
9
|
+
title)));
|
|
10
|
+
};
|
|
11
|
+
const styles = StyleSheet.create({
|
|
12
|
+
wrapper: {
|
|
13
|
+
flex: 1,
|
|
14
|
+
display: "flex",
|
|
15
|
+
flexDirection: "row",
|
|
16
|
+
},
|
|
17
|
+
right: {
|
|
18
|
+
justifyContent: "flex-end",
|
|
19
|
+
},
|
|
20
|
+
sorted: {
|
|
21
|
+
// marginLeft: 8,
|
|
22
|
+
},
|
|
23
|
+
icon: {
|
|
24
|
+
height: 24,
|
|
25
|
+
justifyContent: "center",
|
|
26
|
+
},
|
|
27
|
+
});
|
|
28
|
+
export default TableTitle;
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { View, Text, StyleProp, ViewStyle, StyleSheet } from "react-native";
|
|
3
|
+
import { extractStyles } from "../../utilities";
|
|
4
|
+
|
|
5
|
+
export interface TableCellProps {
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
numeric?: boolean;
|
|
8
|
+
isAscending: boolean;
|
|
9
|
+
numberOfLines?: number;
|
|
10
|
+
title?: string;
|
|
11
|
+
style?: StyleProp<ViewStyle>;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
const TableTitle = ({
|
|
15
|
+
children,
|
|
16
|
+
style,
|
|
17
|
+
numeric = false,
|
|
18
|
+
isAscending = false,
|
|
19
|
+
numberOfLines = 1,
|
|
20
|
+
title,
|
|
21
|
+
...rest
|
|
22
|
+
}: TableCellProps) => {
|
|
23
|
+
const { textStyles, viewStyles } = extractStyles(style);
|
|
24
|
+
|
|
25
|
+
return (
|
|
26
|
+
<View
|
|
27
|
+
{...rest}
|
|
28
|
+
style={[styles.wrapper, numeric && styles.right, viewStyles]}
|
|
29
|
+
>
|
|
30
|
+
<Text
|
|
31
|
+
style={[isAscending ? styles.sorted : { color: "gray" }, textStyles]}
|
|
32
|
+
numberOfLines={numberOfLines}
|
|
33
|
+
>
|
|
34
|
+
{children}
|
|
35
|
+
{title}
|
|
36
|
+
</Text>
|
|
37
|
+
</View>
|
|
38
|
+
);
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
const styles = StyleSheet.create({
|
|
42
|
+
wrapper: {
|
|
43
|
+
flex: 1,
|
|
44
|
+
display: "flex",
|
|
45
|
+
flexDirection: "row",
|
|
46
|
+
},
|
|
47
|
+
right: {
|
|
48
|
+
justifyContent: "flex-end",
|
|
49
|
+
},
|
|
50
|
+
sorted: {
|
|
51
|
+
// marginLeft: 8,
|
|
52
|
+
},
|
|
53
|
+
icon: {
|
|
54
|
+
height: 24,
|
|
55
|
+
justifyContent: "center",
|
|
56
|
+
},
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
export default TableTitle;
|
package/src/index.js
CHANGED
|
@@ -29,6 +29,7 @@ export { ActionSheet, ActionSheetItem, ActionSheetCancel, } from "./components/A
|
|
|
29
29
|
export { Swiper, SwiperItem } from "./components/Swiper";
|
|
30
30
|
export { Center, Circle, Square, Row, Stack, Spacer, } from "./components/Layout";
|
|
31
31
|
export { RadioButton, RadioButtonGroup, RadioButtonRow, RadioButtonFieldGroup, } from "./components/RadioButton/index";
|
|
32
|
+
export { Table, TableRow, TablePaginator, TableHeader, TableCell, TableTitle, } from "./components/Table";
|
|
32
33
|
/* Deprecated: Fix or Delete! */
|
|
33
34
|
export { default as Button } from "./components/DeprecatedButton";
|
|
34
35
|
export { default as CardBlock } from "./components/CardBlock";
|
package/src/index.tsx
CHANGED
|
@@ -49,6 +49,15 @@ export {
|
|
|
49
49
|
RadioButtonFieldGroup,
|
|
50
50
|
} from "./components/RadioButton/index";
|
|
51
51
|
|
|
52
|
+
export {
|
|
53
|
+
Table,
|
|
54
|
+
TableRow,
|
|
55
|
+
TablePaginator,
|
|
56
|
+
TableHeader,
|
|
57
|
+
TableCell,
|
|
58
|
+
TableTitle,
|
|
59
|
+
} from "./components/Table";
|
|
60
|
+
|
|
52
61
|
/* Deprecated: Fix or Delete! */
|
|
53
62
|
export { default as Button } from "./components/DeprecatedButton";
|
|
54
63
|
export { default as CardBlock } from "./components/CardBlock";
|