@draftbit/core 48.0.3-fd9d4e.2 → 48.1.1-02a900.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 +6 -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 +6 -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 +40 -0
- package/lib/src/components/Progress/ProgressCommon.js +2 -0
- package/lib/src/components/Progress/ProgressCommon.js.map +1 -0
- package/lib/src/components/SectionList/SectionHeader.d.ts +15 -0
- package/lib/src/components/SectionList/SectionHeader.js +14 -0
- package/lib/src/components/SectionList/SectionHeader.js.map +1 -0
- package/lib/src/components/SectionList/SectionList.d.ts +20 -0
- package/lib/src/components/SectionList/SectionList.js +95 -0
- package/lib/src/components/SectionList/SectionList.js.map +1 -0
- package/lib/src/components/SectionList/index.d.ts +2 -0
- package/lib/src/components/SectionList/index.js +3 -0
- package/lib/src/components/SectionList/index.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 +3 -0
- package/lib/src/index.js +3 -0
- package/lib/src/index.js.map +1 -1
- package/lib/tsconfig.tsbuildinfo +1 -1
- package/package.json +22 -4
- 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 +200 -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 +74 -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 +132 -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 +44 -0
- package/src/components/SectionList/SectionHeader.js +14 -0
- package/src/components/SectionList/SectionHeader.js.map +1 -0
- package/src/components/SectionList/SectionHeader.tsx +37 -0
- package/src/components/SectionList/SectionList.js +95 -0
- package/src/components/SectionList/SectionList.js.map +1 -0
- package/src/components/SectionList/SectionList.tsx +171 -0
- package/src/components/SectionList/index.js +3 -0
- package/src/components/SectionList/index.js.map +1 -0
- package/src/components/SectionList/index.tsx +2 -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 +3 -0
- package/src/index.js.map +1 -1
- package/src/index.tsx +3 -0
|
@@ -0,0 +1,132 @@
|
|
|
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
|
+
export 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
|
+
testID,
|
|
41
|
+
}) => {
|
|
42
|
+
const [svgContainerWidth, setSvgContainerWidth] = React.useState(0);
|
|
43
|
+
|
|
44
|
+
const dashArray =
|
|
45
|
+
dashWidth !== undefined
|
|
46
|
+
? `${dashWidth} ${dashGap || dashWidth}`
|
|
47
|
+
: undefined;
|
|
48
|
+
const trackDashArray =
|
|
49
|
+
trackDashWidth !== undefined
|
|
50
|
+
? `${trackDashWidth} ${trackDashGap || trackDashWidth}`
|
|
51
|
+
: undefined;
|
|
52
|
+
|
|
53
|
+
const maxThickness = Math.max(thickness, trackThickness);
|
|
54
|
+
const thicknessOffset = maxThickness / 2; // This offset guarantees nothing is cut off by view bounds
|
|
55
|
+
|
|
56
|
+
const progressLineWidth = svgContainerWidth - thicknessOffset;
|
|
57
|
+
const trackProgressLineWidth = svgContainerWidth - thicknessOffset;
|
|
58
|
+
|
|
59
|
+
const currentFillPercentage = value / (maximumValue + minimumValue);
|
|
60
|
+
const currentProgressLineWidth = useSharedValue(
|
|
61
|
+
currentFillPercentage * progressLineWidth
|
|
62
|
+
);
|
|
63
|
+
|
|
64
|
+
const progressLineAnimatedProps = useAnimatedProps<LineProps>(() => {
|
|
65
|
+
const isBelowMinWidth = currentProgressLineWidth.value <= thicknessOffset;
|
|
66
|
+
return {
|
|
67
|
+
x2: Math.min(progressLineWidth, currentProgressLineWidth.value), //Prevents going beyond the max width
|
|
68
|
+
strokeOpacity: isBelowMinWidth ? 0.0 : 1.0,
|
|
69
|
+
};
|
|
70
|
+
});
|
|
71
|
+
|
|
72
|
+
React.useEffect(() => {
|
|
73
|
+
currentProgressLineWidth.value = withTiming(
|
|
74
|
+
progressLineWidth * currentFillPercentage,
|
|
75
|
+
{
|
|
76
|
+
duration: isAnimated ? animationDuration : 0,
|
|
77
|
+
}
|
|
78
|
+
);
|
|
79
|
+
}, [
|
|
80
|
+
value,
|
|
81
|
+
progressLineWidth,
|
|
82
|
+
currentFillPercentage,
|
|
83
|
+
animationDuration,
|
|
84
|
+
currentProgressLineWidth,
|
|
85
|
+
maximumValue,
|
|
86
|
+
minimumValue,
|
|
87
|
+
isAnimated,
|
|
88
|
+
]);
|
|
89
|
+
|
|
90
|
+
return (
|
|
91
|
+
<Svg
|
|
92
|
+
testID={testID ?? "linear-progress-component"}
|
|
93
|
+
onLayout={(event) => {
|
|
94
|
+
const width = event.nativeEvent.layout.width;
|
|
95
|
+
setSvgContainerWidth(width);
|
|
96
|
+
onFullPathWidth?.(width);
|
|
97
|
+
}}
|
|
98
|
+
style={[
|
|
99
|
+
{
|
|
100
|
+
height: maxThickness,
|
|
101
|
+
},
|
|
102
|
+
style,
|
|
103
|
+
]}
|
|
104
|
+
>
|
|
105
|
+
{showTrack && (
|
|
106
|
+
<Line
|
|
107
|
+
x1={thicknessOffset}
|
|
108
|
+
y1={thicknessOffset}
|
|
109
|
+
x2={trackProgressLineWidth}
|
|
110
|
+
y2={thicknessOffset}
|
|
111
|
+
stroke={trackColor}
|
|
112
|
+
strokeWidth={trackThickness}
|
|
113
|
+
strokeOpacity={trackOpacity}
|
|
114
|
+
strokeLinecap={trackLineCap}
|
|
115
|
+
strokeDasharray={trackCustomDashArray || trackDashArray}
|
|
116
|
+
strokeDashoffset={trackDashOffset}
|
|
117
|
+
/>
|
|
118
|
+
)}
|
|
119
|
+
<AnimatedLine
|
|
120
|
+
animatedProps={progressLineAnimatedProps}
|
|
121
|
+
x1={thicknessOffset}
|
|
122
|
+
y1={thicknessOffset}
|
|
123
|
+
y2={thicknessOffset}
|
|
124
|
+
stroke={color}
|
|
125
|
+
strokeWidth={thickness}
|
|
126
|
+
strokeLinecap={lineCap}
|
|
127
|
+
strokeDasharray={customDashArray || dashArray}
|
|
128
|
+
strokeDashoffset={dashOffset}
|
|
129
|
+
/>
|
|
130
|
+
</Svg>
|
|
131
|
+
);
|
|
132
|
+
};
|
|
@@ -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,44 @@
|
|
|
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
|
+
testID?: string;
|
|
31
|
+
}
|
|
32
|
+
export interface ValueProgressProps extends BaseProgressProps {
|
|
33
|
+
value?: number;
|
|
34
|
+
minimumValue?: number;
|
|
35
|
+
maximumValue?: number;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface IndeterminateProgressProps extends BaseProgressProps {
|
|
39
|
+
indeterminate?: boolean;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export interface CircularProgressProps {
|
|
43
|
+
startPosition?: "left" | "top" | "right" | "bottom";
|
|
44
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,37 @@
|
|
|
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;
|
|
@@ -0,0 +1,95 @@
|
|
|
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
|
+
//# sourceMappingUR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AAE,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"}
|
|
@@ -0,0 +1,171 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { FlashListProps, FlashList } from "@shopify/flash-list";
|
|
3
|
+
import { FlatListProps, FlatList } from "react-native";
|
|
4
|
+
import SectionHeader, { DefaultSectionHeader } from "./SectionHeader";
|
|
5
|
+
|
|
6
|
+
type ListComponentType = "FlatList" | "FlashList";
|
|
7
|
+
|
|
8
|
+
interface AdditionalSectionListProps<T> {
|
|
9
|
+
sectionKey: string;
|
|
10
|
+
renderItem: (itemInfo: {
|
|
11
|
+
item?: T;
|
|
12
|
+
index: number;
|
|
13
|
+
section: string;
|
|
14
|
+
}) => JSX.Element;
|
|
15
|
+
listComponent?: ListComponentType;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
type FlatListSectionListProps<T> = Omit<FlatListProps<T>, "renderItem"> &
|
|
19
|
+
AdditionalSectionListProps<T>;
|
|
20
|
+
|
|
21
|
+
type FlashListSectionListProps<T> = Omit<FlashListProps<T>, "renderItem"> &
|
|
22
|
+
AdditionalSectionListProps<T>;
|
|
23
|
+
|
|
24
|
+
interface SectionListDataItem<T> {
|
|
25
|
+
type: "DATA_ITEM";
|
|
26
|
+
data: T;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface SectionListSectionItem {
|
|
30
|
+
type: "SECTION_ITEM";
|
|
31
|
+
title: string;
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
type SectionListItem<T> = SectionListDataItem<T> | SectionListSectionItem;
|
|
35
|
+
|
|
36
|
+
export const DEFAULT_SECTION = "Uncategorized";
|
|
37
|
+
|
|
38
|
+
const SectionList = <T extends { [key: string]: any }>({
|
|
39
|
+
sectionKey,
|
|
40
|
+
listComponent = "FlatList",
|
|
41
|
+
data: dataProp,
|
|
42
|
+
renderItem: renderItemProp,
|
|
43
|
+
...rest
|
|
44
|
+
}: FlatListSectionListProps<T> | FlashListSectionListProps<T>) => {
|
|
45
|
+
const data = React.useMemo(() => (dataProp || []) as T[], [dataProp]);
|
|
46
|
+
|
|
47
|
+
const dataWithSections = React.useMemo(() => {
|
|
48
|
+
const result: SectionListItem<T>[] = [];
|
|
49
|
+
const sectionDataItems: { [key: string]: T[] } = {};
|
|
50
|
+
|
|
51
|
+
for (const item of data) {
|
|
52
|
+
const section = item[sectionKey]?.toString() || DEFAULT_SECTION;
|
|
53
|
+
if (sectionDataItems[section]) {
|
|
54
|
+
sectionDataItems[section].push(item);
|
|
55
|
+
} else {
|
|
56
|
+
sectionDataItems[section] = [item];
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
for (const section in sectionDataItems) {
|
|
61
|
+
result.push({ type: "SECTION_ITEM", title: section });
|
|
62
|
+
const sectionItems: SectionListDataItem<T>[] = sectionDataItems[
|
|
63
|
+
section
|
|
64
|
+
].map((item) => ({ type: "DATA_ITEM", data: item }));
|
|
65
|
+
result.push(...sectionItems);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
return result;
|
|
69
|
+
}, [data, sectionKey]);
|
|
70
|
+
|
|
71
|
+
const extractSectionHeader = (
|
|
72
|
+
element: JSX.Element | null
|
|
73
|
+
): JSX.Element | null => {
|
|
74
|
+
if (!element) {
|
|
75
|
+
return null;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const props = element.props || {};
|
|
79
|
+
const children = React.Children.toArray(props.children).map(
|
|
80
|
+
(child) => child as React.ReactElement
|
|
81
|
+
);
|
|
82
|
+
if (element.type === SectionHeader) {
|
|
83
|
+
return element;
|
|
84
|
+
} else {
|
|
85
|
+
for (const child of children) {
|
|
86
|
+
if (child.type === SectionHeader) {
|
|
87
|
+
return child;
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
return null;
|
|
92
|
+
};
|
|
93
|
+
|
|
94
|
+
const extractRemainingNonSectionHeader = (
|
|
95
|
+
element: JSX.Element | null
|
|
96
|
+
): JSX.Element | null => {
|
|
97
|
+
if (!element) {
|
|
98
|
+
return null;
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
const props = element.props || {};
|
|
102
|
+
const children = React.Children.toArray(props.children).map(
|
|
103
|
+
(child) => child as React.ReactElement
|
|
104
|
+
);
|
|
105
|
+
if (element.type === SectionHeader) {
|
|
106
|
+
return null;
|
|
107
|
+
} else {
|
|
108
|
+
const newChildren = [];
|
|
109
|
+
for (const child of children) {
|
|
110
|
+
if (child.type !== SectionHeader) {
|
|
111
|
+
newChildren.push(child);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
return React.cloneElement(element, {
|
|
115
|
+
...props,
|
|
116
|
+
children: newChildren,
|
|
117
|
+
});
|
|
118
|
+
}
|
|
119
|
+
};
|
|
120
|
+
|
|
121
|
+
const renderItem = ({
|
|
122
|
+
item,
|
|
123
|
+
index,
|
|
124
|
+
}: {
|
|
125
|
+
item: SectionListItem<T>;
|
|
126
|
+
index: number;
|
|
127
|
+
}) => {
|
|
128
|
+
switch (item.type) {
|
|
129
|
+
case "SECTION_ITEM": {
|
|
130
|
+
const renderedItem = renderItemProp({
|
|
131
|
+
index,
|
|
132
|
+
section: item.title,
|
|
133
|
+
});
|
|
134
|
+
return (
|
|
135
|
+
extractSectionHeader(renderedItem) || (
|
|
136
|
+
<DefaultSectionHeader title={item.title} />
|
|
137
|
+
)
|
|
138
|
+
);
|
|
139
|
+
}
|
|
140
|
+
case "DATA_ITEM": {
|
|
141
|
+
const renderedItem = renderItemProp({
|
|
142
|
+
item: item.data,
|
|
143
|
+
index,
|
|
144
|
+
section: item.data[sectionKey] || DEFAULT_SECTION,
|
|
145
|
+
});
|
|
146
|
+
return extractRemainingNonSectionHeader(renderedItem);
|
|
147
|
+
}
|
|
148
|
+
}
|
|
149
|
+
};
|
|
150
|
+
|
|
151
|
+
switch (listComponent) {
|
|
152
|
+
case "FlatList":
|
|
153
|
+
return (
|
|
154
|
+
<FlatList
|
|
155
|
+
{...(rest as FlatListProps<SectionListItem<T>>)}
|
|
156
|
+
data={dataWithSections}
|
|
157
|
+
renderItem={renderItem}
|
|
158
|
+
/>
|
|
159
|
+
);
|
|
160
|
+
case "FlashList":
|
|
161
|
+
return (
|
|
162
|
+
<FlashList
|
|
163
|
+
{...(rest as FlashListProps<SectionListItem<T>>)}
|
|
164
|
+
data={dataWithSections}
|
|
165
|
+
renderItem={renderItem}
|
|
166
|
+
/>
|
|
167
|
+
);
|
|
168
|
+
}
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
export default SectionList;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["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,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.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;AACvB,OAAO,SAAS,MAAM,cAAc,CAAC;AAOrC,MAAM,SAAS,GAA6C,CAAC,EAC3D,WAAW,EACX,WAAW,EACX,WAAW,EACX,aAAa,GAAG,KAAK,EACrB,gBAAgB,GAAG,KAAK,EACxB,eAAe,GAAG,KAAK,EACvB,aAAa,GAAG,IAAI,EACpB,mBAAmB,EACnB,qBAAqB,EACrB,QAAQ,EACR,OAAO,EACP,KAAK,GACN,EAAE,EAAE;IACH,MAAM,kBAAkB,GAAG,KAAK,CAAC,UAAU,CAAC,iBAAiB,CAAC,CAAC;IAE/D,MAAM,eAAe,GAAG,oBAAoB,CAAC;QAC3C,WAAW,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW;QAC1D,WAAW,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW;QAC1D,WAAW,EAAE,WAAW,IAAI,kBAAkB,CAAC,WAAW;QAC1D,aAAa;QACb,gBAAgB;QAChB,eAAe;QACf,aAAa;KACd,CAAC,CAAC;IAEH,MAAM,kBAAkB,GAAG,OAAO,CAAC,CAAC,CAAC,SAAS,CAAC,CAAC,CAAC,IAAI,CAAC;IACtD,OAAO,CACL,oBAAC,kBAAkB,IACjB,OAAO,EAAE,OAAO,EAChB,KAAK,EAAE;YACL,MAAM,CAAC,aAAa;YACpB,eAAe;YACf;gBACE,eAAe,EACb,mBAAmB,IAAI,kBAAkB,CAAC,mBAAmB;gBAC/D,iBAAiB,EACf,qBAAqB,IAAI,kBAAkB,CAAC,qBAAqB;aACpE;YACD,KAAK;SACN,IAEA,QAAQ,CACU,CACtB,CAAC;AACJ,CAAC,CAAC;AAEF,MAAM,MAAM,GAAG,UAAU,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":["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