@draftbit/core 48.0.3-8fa13e.2 → 48.0.3-b432fe.2
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/src/components/Progress/CircularProgress/CircularProgress.d.ts +3 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/lib/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/lib/src/components/Progress/CircularProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/CircularProgress/index.js +14 -0
- package/lib/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/lib/src/components/Progress/IndeterminateProgress.d.ts +7 -0
- package/lib/src/components/Progress/IndeterminateProgress.js +39 -0
- package/lib/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.d.ts +3 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/lib/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/lib/src/components/Progress/LinearProgress/index.d.ts +6 -0
- package/lib/src/components/Progress/LinearProgress/index.js +14 -0
- package/lib/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/lib/src/components/Progress/ProgressCommon.d.ts +39 -0
- package/lib/src/components/Progress/ProgressCommon.js +2 -0
- package/lib/src/components/Progress/ProgressCommon.js.map +1 -0
- package/lib/src/components/Table/TableCell.d.ts +1 -0
- package/lib/src/components/Table/TableCell.js +4 -2
- package/lib/src/components/Table/TableCell.js.map +1 -1
- package/lib/src/components/Table/TableRow.d.ts +1 -0
- package/lib/src/components/Table/TableRow.js +4 -2
- package/lib/src/components/Table/TableRow.js.map +1 -1
- package/lib/src/index.d.ts +2 -1
- package/lib/src/index.js +2 -1
- package/lib/src/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +4 -19
- package/src/components/Progress/CircularProgress/CircularProgress.js +101 -0
- package/src/components/Progress/CircularProgress/CircularProgress.js.map +1 -0
- package/src/components/Progress/CircularProgress/CircularProgress.tsx +198 -0
- package/src/components/Progress/CircularProgress/index.js +14 -0
- package/src/components/Progress/CircularProgress/index.js.map +1 -0
- package/src/components/Progress/CircularProgress/index.tsx +28 -0
- package/src/components/Progress/IndeterminateProgress.js +39 -0
- package/src/components/Progress/IndeterminateProgress.js.map +1 -0
- package/src/components/Progress/IndeterminateProgress.tsx +73 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js +54 -0
- package/src/components/Progress/LinearProgress/LinearProgress.js.map +1 -0
- package/src/components/Progress/LinearProgress/LinearProgress.tsx +130 -0
- package/src/components/Progress/LinearProgress/index.js +14 -0
- package/src/components/Progress/LinearProgress/index.js.map +1 -0
- package/src/components/Progress/LinearProgress/index.tsx +25 -0
- package/src/components/Progress/ProgressCommon.js +2 -0
- package/src/components/Progress/ProgressCommon.js.map +1 -0
- package/src/components/Progress/ProgressCommon.ts +43 -0
- package/src/components/Table/TableCell.js +4 -2
- package/src/components/Table/TableCell.js.map +1 -1
- package/src/components/Table/TableCell.tsx +8 -2
- package/src/components/Table/TableRow.js +4 -2
- package/src/components/Table/TableRow.js.map +1 -1
- package/src/components/Table/TableRow.tsx +8 -2
- package/src/index.js +2 -1
- package/src/index.js.map +1 -1
- package/src/index.tsx +2 -1
- package/lib/src/components/SectionList/SectionHeader.d.ts +0 -15
- package/lib/src/components/SectionList/SectionHeader.js +0 -14
- package/lib/src/components/SectionList/SectionHeader.js.map +0 -1
- package/lib/src/components/SectionList/SectionList.d.ts +0 -20
- package/lib/src/components/SectionList/SectionList.js +0 -95
- package/lib/src/components/SectionList/SectionList.js.map +0 -1
- package/lib/src/components/SectionList/index.d.ts +0 -2
- package/lib/src/components/SectionList/index.js +0 -3
- package/lib/src/components/SectionList/index.js.map +0 -1
- package/src/components/SectionList/SectionHeader.js +0 -14
- package/src/components/SectionList/SectionHeader.js.map +0 -1
- package/src/components/SectionList/SectionHeader.tsx +0 -37
- package/src/components/SectionList/SectionList.js +0 -95
- package/src/components/SectionList/SectionList.js.map +0 -1
- package/src/components/SectionList/SectionList.tsx +0 -171
- package/src/components/SectionList/index.js +0 -3
- package/src/components/SectionList/index.js.map +0 -1
- package/src/components/SectionList/index.tsx +0 -2
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import Svg, { Line, LineProps } from "react-native-svg";
|
|
3
|
+
import Animated, {
|
|
4
|
+
useAnimatedProps,
|
|
5
|
+
useSharedValue,
|
|
6
|
+
withTiming,
|
|
7
|
+
} from "react-native-reanimated";
|
|
8
|
+
import {
|
|
9
|
+
DEFAULT_ANIMATION_DURATION,
|
|
10
|
+
ValueProgressProps,
|
|
11
|
+
} from "../ProgressCommon";
|
|
12
|
+
|
|
13
|
+
const AnimatedLine = Animated.createAnimatedComponent(Line);
|
|
14
|
+
|
|
15
|
+
export const LinearProgress: React.FC<ValueProgressProps> = ({
|
|
16
|
+
theme,
|
|
17
|
+
minimumValue = 0,
|
|
18
|
+
maximumValue = 100,
|
|
19
|
+
value = minimumValue,
|
|
20
|
+
thickness = 10,
|
|
21
|
+
trackThickness = thickness,
|
|
22
|
+
color = theme.colors.primary,
|
|
23
|
+
trackColor = theme.colors.divider,
|
|
24
|
+
trackOpacity = 1,
|
|
25
|
+
showTrack = true,
|
|
26
|
+
animationDuration = DEFAULT_ANIMATION_DURATION,
|
|
27
|
+
isAnimated = true,
|
|
28
|
+
lineCap = "round",
|
|
29
|
+
trackLineCap = lineCap,
|
|
30
|
+
dashWidth,
|
|
31
|
+
trackDashWidth,
|
|
32
|
+
dashGap,
|
|
33
|
+
trackDashGap,
|
|
34
|
+
dashOffset,
|
|
35
|
+
trackDashOffset,
|
|
36
|
+
customDashArray,
|
|
37
|
+
trackCustomDashArray,
|
|
38
|
+
onFullPathWidth,
|
|
39
|
+
style,
|
|
40
|
+
}) => {
|
|
41
|
+
const [svgContainerWidth, setSvgContainerWidth] = React.useState(0);
|
|
42
|
+
|
|
43
|
+
const dashArray =
|
|
44
|
+
dashWidth !== undefined
|
|
45
|
+
? `${dashWidth} ${dashGap || dashWidth}`
|
|
46
|
+
: undefined;
|
|
47
|
+
const trackDashArray =
|
|
48
|
+
trackDashWidth !== undefined
|
|
49
|
+
? `${trackDashWidth} ${trackDashGap || trackDashWidth}`
|
|
50
|
+
: undefined;
|
|
51
|
+
|
|
52
|
+
const maxThickness = Math.max(thickness, trackThickness);
|
|
53
|
+
const thicknessOffset = maxThickness / 2; // This offset guarantees nothing is cut off by view bounds
|
|
54
|
+
|
|
55
|
+
const progressLineWidth = svgContainerWidth - thicknessOffset;
|
|
56
|
+
const trackProgressLineWidth = svgContainerWidth - thicknessOffset;
|
|
57
|
+
|
|
58
|
+
const currentFillPercentage = value / (maximumValue + minimumValue);
|
|
59
|
+
const currentProgressLineWidth = useSharedValue(
|
|
60
|
+
currentFillPercentage * progressLineWidth
|
|
61
|
+
);
|
|
62
|
+
|
|
63
|
+
const progressLineAnimatedProps = useAnimatedProps<LineProps>(() => {
|
|
64
|
+
const isBelowMinWidth = currentProgressLineWidth.value <= thicknessOffset;
|
|
65
|
+
return {
|
|
66
|
+
x2: Math.min(progressLineWidth, currentProgressLineWidth.value), //Prevents going beyond the max width
|
|
67
|
+
strokeOpacity: isBelowMinWidth ? 0.0 : 1.0,
|
|
68
|
+
};
|
|
69
|
+
});
|
|
70
|
+
|
|
71
|
+
React.useEffect(() => {
|
|
72
|
+
currentProgressLineWidth.value = withTiming(
|
|
73
|
+
progressLineWidth * currentFillPercentage,
|
|
74
|
+
{
|
|
75
|
+
duration: isAnimated ? animationDuration : 0,
|
|
76
|
+
}
|
|
77
|
+
);
|
|
78
|
+
}, [
|
|
79
|
+
value,
|
|
80
|
+
progressLineWidth,
|
|
81
|
+
currentFillPercentage,
|
|
82
|
+
animationDuration,
|
|
83
|
+
currentProgressLineWidth,
|
|
84
|
+
maximumValue,
|
|
85
|
+
minimumValue,
|
|
86
|
+
isAnimated,
|
|
87
|
+
]);
|
|
88
|
+
|
|
89
|
+
return (
|
|
90
|
+
<Svg
|
|
91
|
+
onLayout={(event) => {
|
|
92
|
+
const width = event.nativeEvent.layout.width;
|
|
93
|
+
setSvgContainerWidth(width);
|
|
94
|
+
onFullPathWidth?.(width);
|
|
95
|
+
}}
|
|
96
|
+
style={[
|
|
97
|
+
{
|
|
98
|
+
height: maxThickness,
|
|
99
|
+
},
|
|
100
|
+
style,
|
|
101
|
+
]}
|
|
102
|
+
>
|
|
103
|
+
{showTrack && (
|
|
104
|
+
<Line
|
|
105
|
+
x1={thicknessOffset}
|
|
106
|
+
y1={thicknessOffset}
|
|
107
|
+
x2={trackProgressLineWidth}
|
|
108
|
+
y2={thicknessOffset}
|
|
109
|
+
stroke={trackColor}
|
|
110
|
+
strokeWidth={trackThickness}
|
|
111
|
+
strokeOpacity={trackOpacity}
|
|
112
|
+
strokeLinecap={trackLineCap}
|
|
113
|
+
strokeDasharray={trackCustomDashArray || trackDashArray}
|
|
114
|
+
strokeDashoffset={trackDashOffset}
|
|
115
|
+
/>
|
|
116
|
+
)}
|
|
117
|
+
<AnimatedLine
|
|
118
|
+
animatedProps={progressLineAnimatedProps}
|
|
119
|
+
x1={thicknessOffset}
|
|
120
|
+
y1={thicknessOffset}
|
|
121
|
+
y2={thicknessOffset}
|
|
122
|
+
stroke={color}
|
|
123
|
+
strokeWidth={thickness}
|
|
124
|
+
strokeLinecap={lineCap}
|
|
125
|
+
strokeDasharray={customDashArray || dashArray}
|
|
126
|
+
strokeDashoffset={dashOffset}
|
|
127
|
+
/>
|
|
128
|
+
</Svg>
|
|
129
|
+
);
|
|
130
|
+
};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IndeterminateProgress from "../IndeterminateProgress";
|
|
3
|
+
import { LinearProgress as LinearProgressComponent } from "./LinearProgress";
|
|
4
|
+
import { withTheme } from "../../../theming";
|
|
5
|
+
const LinearProgress = (props) => {
|
|
6
|
+
if (props.indeterminate) {
|
|
7
|
+
return (React.createElement(IndeterminateProgress, { ProgressComponent: LinearProgressComponent, ...props }));
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
return React.createElement(LinearProgressComponent, { ...props });
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
export default withTheme(LinearProgress);
|
|
14
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,qBAAqB,MAAM,0BAA0B,CAAC;AAK7D,OAAO,EAAE,cAAc,IAAI,uBAAuB,EAAE,MAAM,kBAAkB,CAAC;AAC7E,OAAO,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAE7C,MAAM,cAAc,GAEhB,CAAC,KAAK,EAAE,EAAE;IACZ,IAAI,KAAK,CAAC,aAAa,EAAE;QACvB,OAAO,CACL,oBAAC,qBAAqB,IACpB,iBAAiB,EAAE,uBAAuB,KACtC,KAAK,GACT,CACH,CAAC;KACH;SAAM;QACL,OAAO,oBAAC,uBAAuB,OAAK,KAAK,GAAI,CAAC;KAC/C;AACH,CAAC,CAAC;AAEF,eAAe,SAAS,CAAC,cAAc,CAAC,CAAC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import IndeterminateProgress from "../IndeterminateProgress";
|
|
3
|
+
import {
|
|
4
|
+
IndeterminateProgressProps,
|
|
5
|
+
ValueProgressProps,
|
|
6
|
+
} from "../ProgressCommon";
|
|
7
|
+
import { LinearProgress as LinearProgressComponent } from "./LinearProgress";
|
|
8
|
+
import { withTheme } from "../../../theming";
|
|
9
|
+
|
|
10
|
+
const LinearProgress: React.FC<
|
|
11
|
+
ValueProgressProps & IndeterminateProgressProps
|
|
12
|
+
> = (props) => {
|
|
13
|
+
if (props.indeterminate) {
|
|
14
|
+
return (
|
|
15
|
+
<IndeterminateProgress
|
|
16
|
+
ProgressComponent={LinearProgressComponent}
|
|
17
|
+
{...props}
|
|
18
|
+
/>
|
|
19
|
+
);
|
|
20
|
+
} else {
|
|
21
|
+
return <LinearProgressComponent {...props} />;
|
|
22
|
+
}
|
|
23
|
+
};
|
|
24
|
+
|
|
25
|
+
export default withTheme(LinearProgress);
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ProgressCommon.js","sourceRoot":"","sources":["ProgressCommon.ts"],"names":[],"mappings":"AAKA,MAAM,CAAC,MAAM,0BAA0B,GAAG,GAAG,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { StyleProp, ViewStyle } from "react-native";
|
|
2
|
+
import { Theme } from "../../styles/DefaultTheme";
|
|
3
|
+
|
|
4
|
+
type LineCap = "round" | "square";
|
|
5
|
+
|
|
6
|
+
export const DEFAULT_ANIMATION_DURATION = 500;
|
|
7
|
+
|
|
8
|
+
export interface BaseProgressProps {
|
|
9
|
+
thickness?: number;
|
|
10
|
+
trackThickness?: number;
|
|
11
|
+
color?: string;
|
|
12
|
+
trackColor?: string;
|
|
13
|
+
trackOpacity?: number;
|
|
14
|
+
showTrack?: boolean;
|
|
15
|
+
animationDuration?: number;
|
|
16
|
+
isAnimated?: boolean;
|
|
17
|
+
lineCap?: LineCap;
|
|
18
|
+
trackLineCap?: LineCap;
|
|
19
|
+
dashWidth?: string | number;
|
|
20
|
+
trackDashWidth?: string | number;
|
|
21
|
+
dashGap?: string | number;
|
|
22
|
+
trackDashGap?: string | number;
|
|
23
|
+
dashOffset?: string | number;
|
|
24
|
+
trackDashOffset?: string | number;
|
|
25
|
+
customDashArray?: string;
|
|
26
|
+
trackCustomDashArray?: string;
|
|
27
|
+
onFullPathWidth?: (width: number) => void;
|
|
28
|
+
style?: StyleProp<ViewStyle>;
|
|
29
|
+
theme: Theme;
|
|
30
|
+
}
|
|
31
|
+
export interface ValueProgressProps extends BaseProgressProps {
|
|
32
|
+
value?: number;
|
|
33
|
+
minimumValue?: number;
|
|
34
|
+
maximumValue?: number;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export interface IndeterminateProgressProps extends BaseProgressProps {
|
|
38
|
+
indeterminate?: boolean;
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export interface CircularProgressProps {
|
|
42
|
+
startPosition?: "left" | "top" | "right" | "bottom";
|
|
43
|
+
}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import React from "react";
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
import { generateBorderStyles, TableStyleContext, } from "./TableCommon";
|
|
4
|
-
|
|
4
|
+
import Pressable from "../Pressable";
|
|
5
|
+
const TableCell = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = false, drawStartBorder = false, drawEndBorder = true, cellVerticalPadding, cellHorizontalPadding, children, onPress, style, }) => {
|
|
5
6
|
const parentContextValue = React.useContext(TableStyleContext);
|
|
6
7
|
const borderViewStyle = generateBorderStyles({
|
|
7
8
|
borderColor: borderColor || parentContextValue.borderColor,
|
|
@@ -12,7 +13,8 @@ const TableCell = ({ borderWidth, borderColor, borderStyle, drawTopBorder = fals
|
|
|
12
13
|
drawStartBorder,
|
|
13
14
|
drawEndBorder,
|
|
14
15
|
});
|
|
15
|
-
|
|
16
|
+
const ContainerComponent = onPress ? Pressable : View;
|
|
17
|
+
return (React.createElement(ContainerComponent, { onPress: onPress, style: [
|
|
16
18
|
styles.cellContainer,
|
|
17
19
|
borderViewStyle,
|
|
18
20
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableCell.js","sourceRoot":"","sources":["TableCell.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,oBAAoB,EAEpB,iBAAiB,GAClB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"TableCell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U,CAAC,MAAM,CAAC;IAC/B,aAAa,EAAE;QACb,IAAI,EAAE,CAAC;QACP,aAAa,EAAE,KAAK;KACrB;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC"}
|
|
@@ -5,8 +5,10 @@ import {
|
|
|
5
5
|
TableProps,
|
|
6
6
|
TableStyleContext,
|
|
7
7
|
} from "./TableCommon";
|
|
8
|
+
import Pressable from "../Pressable";
|
|
8
9
|
|
|
9
10
|
export interface Props extends TableProps {
|
|
11
|
+
onPress?: () => void;
|
|
10
12
|
style?: StyleProp<ViewStyle>;
|
|
11
13
|
}
|
|
12
14
|
|
|
@@ -21,6 +23,7 @@ const TableCell: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
21
23
|
cellVerticalPadding,
|
|
22
24
|
cellHorizontalPadding,
|
|
23
25
|
children,
|
|
26
|
+
onPress,
|
|
24
27
|
style,
|
|
25
28
|
}) => {
|
|
26
29
|
const parentContextValue = React.useContext(TableStyleContext);
|
|
@@ -34,8 +37,11 @@ const TableCell: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
34
37
|
drawStartBorder,
|
|
35
38
|
drawEndBorder,
|
|
36
39
|
});
|
|
40
|
+
|
|
41
|
+
const ContainerComponent = onPress ? Pressable : View;
|
|
37
42
|
return (
|
|
38
|
-
<
|
|
43
|
+
<ContainerComponent
|
|
44
|
+
onPress={onPress}
|
|
39
45
|
style={[
|
|
40
46
|
styles.cellContainer,
|
|
41
47
|
borderViewStyle,
|
|
@@ -49,7 +55,7 @@ const TableCell: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
49
55
|
]}
|
|
50
56
|
>
|
|
51
57
|
{children}
|
|
52
|
-
</
|
|
58
|
+
</ContainerComponent>
|
|
53
59
|
);
|
|
54
60
|
};
|
|
55
61
|
|
|
@@ -2,7 +2,8 @@ import React from "react";
|
|
|
2
2
|
import { View, StyleSheet } from "react-native";
|
|
3
3
|
import { generateBorderStyles, TableStyleContext, } from "./TableCommon";
|
|
4
4
|
import { withTheme } from "../../theming";
|
|
5
|
-
|
|
5
|
+
import Pressable from "../Pressable";
|
|
6
|
+
const TableRow = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false, drawBottomBorder = true, drawStartBorder = true, drawEndBorder = false, cellVerticalPadding, cellHorizontalPadding, isTableHeader = false, children, onPress, style, theme, }) => {
|
|
6
7
|
const parentContextValue = React.useContext(TableStyleContext);
|
|
7
8
|
//Create context to use and pass to children based on own props or fall back to parent provided context
|
|
8
9
|
const contextValue = {
|
|
@@ -21,8 +22,9 @@ const TableRow = ({ borderWidth, borderColor, borderStyle, drawTopBorder = false
|
|
|
21
22
|
drawStartBorder,
|
|
22
23
|
drawEndBorder,
|
|
23
24
|
});
|
|
25
|
+
const ContainerComponent = onPress ? Pressable : View;
|
|
24
26
|
return (React.createElement(TableStyleContext.Provider, { value: contextValue },
|
|
25
|
-
React.createElement(
|
|
27
|
+
React.createElement(ContainerComponent, { onPress: onPress, style: [
|
|
26
28
|
borderViewStyle,
|
|
27
29
|
isTableHeader ? { backgroundColor: theme.colors.primary } : {},
|
|
28
30
|
style,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TableRow.js","sourceRoot":"","sources":["TableRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,oBAAoB,EAEpB,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"TableRow.js","sourceRoot":"","sources":["TableRow.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAwB,UAAU,EAAE,MAAM,cAAc,CAAC;AACtE,OAAO,EACL,oBAAoB,EAEpB,iBAAiB,GAElB,MAAM,eAAe,CAAC;AAE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,EAAE,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC,EAAE;gBAC9D,KAAK;gBACL,MAAM,CAAC,cAAc;aACtB,IAEA,QAAQ,CACU,CACM,CAC9B,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,CAAC,MAAM,CAAC;IAC/B,cAAc,EAAE;QACd,aAAa,EAAE,KAAK;KACrB;CACF,CAAC,CAAC;AAEH,eAAe,SAAS,CAAC,QAAQ,CAAC,CAAC"}
|
|
@@ -8,8 +8,10 @@ import {
|
|
|
8
8
|
} from "./TableCommon";
|
|
9
9
|
import { Theme } from "../../styles/DefaultTheme";
|
|
10
10
|
import { withTheme } from "../../theming";
|
|
11
|
+
import Pressable from "../Pressable";
|
|
11
12
|
|
|
12
13
|
export interface Props extends TableProps {
|
|
14
|
+
onPress?: () => void;
|
|
13
15
|
isTableHeader?: boolean;
|
|
14
16
|
style?: StyleProp<ViewStyle>;
|
|
15
17
|
theme: Theme;
|
|
@@ -27,6 +29,7 @@ const TableRow: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
27
29
|
cellHorizontalPadding,
|
|
28
30
|
isTableHeader = false,
|
|
29
31
|
children,
|
|
32
|
+
onPress,
|
|
30
33
|
style,
|
|
31
34
|
theme,
|
|
32
35
|
}) => {
|
|
@@ -52,9 +55,12 @@ const TableRow: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
52
55
|
drawStartBorder,
|
|
53
56
|
drawEndBorder,
|
|
54
57
|
});
|
|
58
|
+
|
|
59
|
+
const ContainerComponent = onPress ? Pressable : View;
|
|
55
60
|
return (
|
|
56
61
|
<TableStyleContext.Provider value={contextValue}>
|
|
57
|
-
<
|
|
62
|
+
<ContainerComponent
|
|
63
|
+
onPress={onPress}
|
|
58
64
|
style={[
|
|
59
65
|
borderViewStyle,
|
|
60
66
|
isTableHeader ? { backgroundColor: theme.colors.primary } : {},
|
|
@@ -63,7 +69,7 @@ const TableRow: React.FC<React.PropsWithChildren<Props>> = ({
|
|
|
63
69
|
]}
|
|
64
70
|
>
|
|
65
71
|
{children}
|
|
66
|
-
</
|
|
72
|
+
</ContainerComponent>
|
|
67
73
|
</TableStyleContext.Provider>
|
|
68
74
|
);
|
|
69
75
|
};
|
package/src/index.js
CHANGED
|
@@ -35,7 +35,8 @@ export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
|
35
35
|
export { default as Picker } from "./components/Picker/Picker";
|
|
36
36
|
export { default as Slider } from "./components/Slider";
|
|
37
37
|
export { default as Stepper } from "./components/Stepper";
|
|
38
|
-
export {
|
|
38
|
+
export { default as LinearProgress } from "./components/Progress/LinearProgress";
|
|
39
|
+
export { default as CircularProgress } from "./components/Progress/CircularProgress";
|
|
39
40
|
/* Deprecated: Fix or Delete! */
|
|
40
41
|
export { default as AccordionItem } from "./deprecated-components/AccordionItem";
|
|
41
42
|
export { default as AvatarEdit } from "./deprecated-components/AvatarEdit";
|
package/src/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAC/C,OAAO,EAAE,SAAS,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AACrD,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAChE,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,OAAO,EAAE,MAAM,EAAE,MAAM,qBAAqB,CAAC;AAC7C,OAAO,EAAE,QAAQ,EAAE,WAAW,EAAE,MAAM,uBAAuB,CAAC;AAC9D,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,yBAAyB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EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mCAAmC,CAAC;AACzE,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,6BAA6B,CAAC;AAC7D,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAC3F,OAAO,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAC;AACjD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,sCAAsC,CAAC;AAC/E,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,cAAc,EAAE,MAAM,wCAAwC,CAAC;AACnF,OAAO,EAAE,OAAO,IAAI,qBAAqB,EAAE,MAAM,+CAA+C,CAAC;AACjG,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,qCAAqC,CAAC;AAC7E,OAAO,EAAE,OAAO,IAAI,uBAAuB,EAAE,MAAM,iDAAiD,CAAC;AACrG,OAAO,EAAE,OAAO,IAAI,oBAAoB,EAAE,MAAM,8CAA8C,CAAC;AAC/F,OAAO,EAAE,YAAY,EAAE,MAAM,2BAA2B,CAAC"}
|
package/src/index.tsx
CHANGED
|
@@ -50,7 +50,8 @@ export { default as DatePicker } from "./components/DatePicker/DatePicker";
|
|
|
50
50
|
export { default as Picker } from "./components/Picker/Picker";
|
|
51
51
|
export { default as Slider } from "./components/Slider";
|
|
52
52
|
export { default as Stepper } from "./components/Stepper";
|
|
53
|
-
export {
|
|
53
|
+
export { default as LinearProgress } from "./components/Progress/LinearProgress";
|
|
54
|
+
export { default as CircularProgress } from "./components/Progress/CircularProgress";
|
|
54
55
|
|
|
55
56
|
/* Deprecated: Fix or Delete! */
|
|
56
57
|
export { default as AccordionItem } from "./deprecated-components/AccordionItem";
|
|
@@ -1,15 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { StyleProp, ViewStyle } from "react-native";
|
|
3
|
-
import type { Theme } from "../../styles/DefaultTheme";
|
|
4
|
-
interface SectionHeaderProps {
|
|
5
|
-
style?: StyleProp<ViewStyle>;
|
|
6
|
-
}
|
|
7
|
-
declare const SectionHeader: React.FC<React.PropsWithChildren<SectionHeaderProps>>;
|
|
8
|
-
interface DefaultSectionHeaderProps {
|
|
9
|
-
title: string;
|
|
10
|
-
theme: Theme;
|
|
11
|
-
}
|
|
12
|
-
export declare const DefaultSectionHeader: React.ComponentType<import("@draftbit/react-theme-provider").$Without<DefaultSectionHeaderProps, "theme"> & {
|
|
13
|
-
theme?: import("@draftbit/react-theme-provider").$DeepPartial<any> | undefined;
|
|
14
|
-
}> & import("@draftbit/react-theme-provider/typings/hoist-non-react-statics").NonReactStatics<React.ComponentType<DefaultSectionHeaderProps> & (({ title, theme }: DefaultSectionHeaderProps) => JSX.Element), {}>;
|
|
15
|
-
export default SectionHeader;
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, Text } from "react-native";
|
|
3
|
-
import { withTheme } from "../../theming";
|
|
4
|
-
const SectionHeader = ({ style, children, }) => React.createElement(View, { style: [style] }, children);
|
|
5
|
-
export const DefaultSectionHeader = withTheme(({ title, theme }) => {
|
|
6
|
-
return (React.createElement(Text, { testID: "default-section-header", style: {
|
|
7
|
-
color: theme.colors.background,
|
|
8
|
-
backgroundColor: theme.colors.primary,
|
|
9
|
-
fontSize: 16,
|
|
10
|
-
padding: 10,
|
|
11
|
-
} }, title));
|
|
12
|
-
});
|
|
13
|
-
export default SectionHeader;
|
|
14
|
-
//# sourceMappingURL=SectionHeader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SectionHeader.js","sourceRoot":"","sources":["../../../../src/components/SectionList/SectionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAwB,IAAI,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO1C,MAAM,aAAa,GAA0D,CAAC,EAC5E,KAAK,EACL,QAAQ,GACT,EAAE,EAAE,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAG,QAAQ,CAAQ,CAAC;AAM9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAC3C,CAAC,EAAE,KAAK,EAAE,KAAK,EAA6B,EAAE,EAAE;IAC9C,OAAO,CACL,oBAAC,IAAI,IACH,MAAM,EAAC,wBAAwB,EAC/B,KAAK,EAAE;YACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU;YAC9B,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;YACrC,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;SACZ,IAEA,KAAK,CACD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
/// <reference types="react" />
|
|
2
|
-
import { FlashListProps } from "@shopify/flash-list";
|
|
3
|
-
import { FlatListProps } from "react-native";
|
|
4
|
-
declare type ListComponentType = "FlatList" | "FlashList";
|
|
5
|
-
interface AdditionalSectionListProps<T> {
|
|
6
|
-
sectionKey: string;
|
|
7
|
-
renderItem: (itemInfo: {
|
|
8
|
-
item?: T;
|
|
9
|
-
index: number;
|
|
10
|
-
section: string;
|
|
11
|
-
}) => JSX.Element;
|
|
12
|
-
listComponent?: ListComponentType;
|
|
13
|
-
}
|
|
14
|
-
declare type FlatListSectionListProps<T> = Omit<FlatListProps<T>, "renderItem"> & AdditionalSectionListProps<T>;
|
|
15
|
-
declare type FlashListSectionListProps<T> = Omit<FlashListProps<T>, "renderItem"> & AdditionalSectionListProps<T>;
|
|
16
|
-
export declare const DEFAULT_SECTION = "Uncategorized";
|
|
17
|
-
declare const SectionList: <T extends {
|
|
18
|
-
[key: string]: any;
|
|
19
|
-
}>({ sectionKey, listComponent, data: dataProp, renderItem: renderItemProp, ...rest }: FlatListSectionListProps<T> | FlashListSectionListProps<T>) => JSX.Element;
|
|
20
|
-
export default SectionList;
|
|
@@ -1,95 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { FlashList } from "@shopify/flash-list";
|
|
3
|
-
import { FlatList } from "react-native";
|
|
4
|
-
import SectionHeader, { DefaultSectionHeader } from "./SectionHeader";
|
|
5
|
-
export const DEFAULT_SECTION = "Uncategorized";
|
|
6
|
-
const SectionList = ({ sectionKey, listComponent = "FlatList", data: dataProp, renderItem: renderItemProp, ...rest }) => {
|
|
7
|
-
const data = React.useMemo(() => (dataProp || []), [dataProp]);
|
|
8
|
-
const dataWithSections = React.useMemo(() => {
|
|
9
|
-
var _a;
|
|
10
|
-
const result = [];
|
|
11
|
-
const sectionDataItems = {};
|
|
12
|
-
for (const item of data) {
|
|
13
|
-
const section = ((_a = item[sectionKey]) === null || _a === void 0 ? void 0 : _a.toString()) || DEFAULT_SECTION;
|
|
14
|
-
if (sectionDataItems[section]) {
|
|
15
|
-
sectionDataItems[section].push(item);
|
|
16
|
-
}
|
|
17
|
-
else {
|
|
18
|
-
sectionDataItems[section] = [item];
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
for (const section in sectionDataItems) {
|
|
22
|
-
result.push({ type: "SECTION_ITEM", title: section });
|
|
23
|
-
const sectionItems = sectionDataItems[section].map((item) => ({ type: "DATA_ITEM", data: item }));
|
|
24
|
-
result.push(...sectionItems);
|
|
25
|
-
}
|
|
26
|
-
return result;
|
|
27
|
-
}, [data, sectionKey]);
|
|
28
|
-
const extractSectionHeader = (element) => {
|
|
29
|
-
if (!element) {
|
|
30
|
-
return null;
|
|
31
|
-
}
|
|
32
|
-
const props = element.props || {};
|
|
33
|
-
const children = React.Children.toArray(props.children).map((child) => child);
|
|
34
|
-
if (element.type === SectionHeader) {
|
|
35
|
-
return element;
|
|
36
|
-
}
|
|
37
|
-
else {
|
|
38
|
-
for (const child of children) {
|
|
39
|
-
if (child.type === SectionHeader) {
|
|
40
|
-
return child;
|
|
41
|
-
}
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
return null;
|
|
45
|
-
};
|
|
46
|
-
const extractRemainingNonSectionHeader = (element) => {
|
|
47
|
-
if (!element) {
|
|
48
|
-
return null;
|
|
49
|
-
}
|
|
50
|
-
const props = element.props || {};
|
|
51
|
-
const children = React.Children.toArray(props.children).map((child) => child);
|
|
52
|
-
if (element.type === SectionHeader) {
|
|
53
|
-
return null;
|
|
54
|
-
}
|
|
55
|
-
else {
|
|
56
|
-
const newChildren = [];
|
|
57
|
-
for (const child of children) {
|
|
58
|
-
if (child.type !== SectionHeader) {
|
|
59
|
-
newChildren.push(child);
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return React.cloneElement(element, {
|
|
63
|
-
...props,
|
|
64
|
-
children: newChildren,
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
};
|
|
68
|
-
const renderItem = ({ item, index, }) => {
|
|
69
|
-
switch (item.type) {
|
|
70
|
-
case "SECTION_ITEM": {
|
|
71
|
-
const renderedItem = renderItemProp({
|
|
72
|
-
index,
|
|
73
|
-
section: item.title,
|
|
74
|
-
});
|
|
75
|
-
return (extractSectionHeader(renderedItem) || (React.createElement(DefaultSectionHeader, { title: item.title })));
|
|
76
|
-
}
|
|
77
|
-
case "DATA_ITEM": {
|
|
78
|
-
const renderedItem = renderItemProp({
|
|
79
|
-
item: item.data,
|
|
80
|
-
index,
|
|
81
|
-
section: item.data[sectionKey] || DEFAULT_SECTION,
|
|
82
|
-
});
|
|
83
|
-
return extractRemainingNonSectionHeader(renderedItem);
|
|
84
|
-
}
|
|
85
|
-
}
|
|
86
|
-
};
|
|
87
|
-
switch (listComponent) {
|
|
88
|
-
case "FlatList":
|
|
89
|
-
return (React.createElement(FlatList, { ...rest, data: dataWithSections, renderItem: renderItem }));
|
|
90
|
-
case "FlashList":
|
|
91
|
-
return (React.createElement(FlashList, { ...rest, data: dataWithSections, renderItem: renderItem }));
|
|
92
|
-
}
|
|
93
|
-
};
|
|
94
|
-
export default SectionList;
|
|
95
|
-
//# sourceMappingURL=SectionList.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SectionList.js","sourceRoot":"","sources":["../../../../src/components/SectionList/SectionList.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAkB,SAAS,EAAE,MAAM,qBAAqB,CAAC;AAChE,OAAO,EAAiB,QAAQ,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,aAAa,EAAE,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAgCtE,MAAM,CAAC,MAAM,eAAe,GAAG,eAAe,CAAC;AAE/C,MAAM,WAAW,GAAG,CAAmC,EACrD,UAAU,EACV,aAAa,GAAG,UAAU,EAC1B,IAAI,EAAE,QAAQ,EACd,UAAU,EAAE,cAAc,EAC1B,GAAG,IAAI,EACoD,EAAE,EAAE;IAC/D,MAAM,IAAI,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,IAAI,EAAE,CAAQ,EAAE,CAAC,QAAQ,CAAC,CAAC,CAAC;IAEtE,MAAM,gBAAgB,GAAG,KAAK,CAAC,OAAO,CAAC,GAAG,EAAE;;QAC1C,MAAM,MAAM,GAAyB,EAAE,CAAC;QACxC,MAAM,gBAAgB,GAA2B,EAAE,CAAC;QAEpD,KAAK,MAAM,IAAI,IAAI,IAAI,EAAE;YACvB,MAAM,OAAO,GAAG,CAAA,MAAA,IAAI,CAAC,UAAU,CAAC,0CAAE,QAAQ,EAAE,KAAI,eAAe,CAAC;YAChE,IAAI,gBAAgB,CAAC,OAAO,CAAC,EAAE;gBAC7B,gBAAgB,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;aACtC;iBAAM;gBACL,gBAAgB,CAAC,OA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CAAC,CAAC;IAEF,QAAQ,aAAa,EAAE;QACrB,KAAK,UAAU;YACb,OAAO,CACL,oBAAC,QAAQ,OACF,IAA0C,EAC/C,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;QACJ,KAAK,WAAW;YACd,OAAO,CACL,oBAAC,SAAS,OACH,IAA2C,EAChD,IAAI,EAAE,gBAAgB,EACtB,UAAU,EAAE,UAAU,GACtB,CACH,CAAC;KACL;AACH,CAAC,CAAC;AAEF,eAAe,WAAW,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../src/components/SectionList/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,WAAW,EAAE,MAAM,eAAe,CAAC;AACvD,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,iBAAiB,CAAC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, Text } from "react-native";
|
|
3
|
-
import { withTheme } from "../../theming";
|
|
4
|
-
const SectionHeader = ({ style, children, }) => React.createElement(View, { style: [style] }, children);
|
|
5
|
-
export const DefaultSectionHeader = withTheme(({ title, theme }) => {
|
|
6
|
-
return (React.createElement(Text, { testID: "default-section-header", style: {
|
|
7
|
-
color: theme.colors.background,
|
|
8
|
-
backgroundColor: theme.colors.primary,
|
|
9
|
-
fontSize: 16,
|
|
10
|
-
padding: 10,
|
|
11
|
-
} }, title));
|
|
12
|
-
});
|
|
13
|
-
export default SectionHeader;
|
|
14
|
-
//# sourceMappingURL=SectionHeader.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"SectionHeader.js","sourceRoot":"","sources":["SectionHeader.tsx"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAC1B,OAAO,EAAE,IAAI,EAAwB,IAAI,EAAE,MAAM,cAAc,CAAC;AAChE,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAO1C,MAAM,aAAa,GAA0D,CAAC,EAC5E,KAAK,EACL,QAAQ,GACT,EAAE,EAAE,CAAC,oBAAC,IAAI,IAAC,KAAK,EAAE,CAAC,KAAK,CAAC,IAAG,QAAQ,CAAQ,CAAC;AAM9C,MAAM,CAAC,MAAM,oBAAoB,GAAG,SAAS,CAC3C,CAAC,EAAE,KAAK,EAAE,KAAK,EAA6B,EAAE,EAAE;IAC9C,OAAO,CACL,oBAAC,IAAI,IACH,MAAM,EAAC,wBAAwB,EAC/B,KAAK,EAAE;YACL,KAAK,EAAE,KAAK,CAAC,MAAM,CAAC,UAAU;YAC9B,eAAe,EAAE,KAAK,CAAC,MAAM,CAAC,OAAO;YACrC,QAAQ,EAAE,EAAE;YACZ,OAAO,EAAE,EAAE;SACZ,IAEA,KAAK,CACD,CACR,CAAC;AACJ,CAAC,CACF,CAAC;AAEF,eAAe,aAAa,CAAC"}
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
import React from "react";
|
|
2
|
-
import { View, StyleProp, ViewStyle, Text } from "react-native";
|
|
3
|
-
import { withTheme } from "../../theming";
|
|
4
|
-
import type { Theme } from "../../styles/DefaultTheme";
|
|
5
|
-
|
|
6
|
-
interface SectionHeaderProps {
|
|
7
|
-
style?: StyleProp<ViewStyle>;
|
|
8
|
-
}
|
|
9
|
-
|
|
10
|
-
const SectionHeader: React.FC<React.PropsWithChildren<SectionHeaderProps>> = ({
|
|
11
|
-
style,
|
|
12
|
-
children,
|
|
13
|
-
}) => <View style={[style]}>{children}</View>;
|
|
14
|
-
|
|
15
|
-
interface DefaultSectionHeaderProps {
|
|
16
|
-
title: string;
|
|
17
|
-
theme: Theme;
|
|
18
|
-
}
|
|
19
|
-
export const DefaultSectionHeader = withTheme(
|
|
20
|
-
({ title, theme }: DefaultSectionHeaderProps) => {
|
|
21
|
-
return (
|
|
22
|
-
<Text
|
|
23
|
-
testID="default-section-header"
|
|
24
|
-
style={{
|
|
25
|
-
color: theme.colors.background,
|
|
26
|
-
backgroundColor: theme.colors.primary,
|
|
27
|
-
fontSize: 16,
|
|
28
|
-
padding: 10,
|
|
29
|
-
}}
|
|
30
|
-
>
|
|
31
|
-
{title}
|
|
32
|
-
</Text>
|
|
33
|
-
);
|
|
34
|
-
}
|
|
35
|
-
);
|
|
36
|
-
|
|
37
|
-
export default SectionHeader;
|