react-native-mantine 0.15.0 → 0.16.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/README.md +45 -345
- package/lib/commonjs/components/Anchor/index.js +5 -5
- package/lib/commonjs/components/Anchor/index.js.map +1 -1
- package/lib/commonjs/components/Avatar/index.js +3 -3
- package/lib/commonjs/components/Avatar/index.js.map +1 -1
- package/lib/commonjs/components/BackgroundImage/index.js +1 -1
- package/lib/commonjs/components/BackgroundImage/index.js.map +1 -1
- package/lib/commonjs/components/Badge/index.js +5 -5
- package/lib/commonjs/components/Badge/index.js.map +1 -1
- package/lib/commonjs/components/Blockquote/index.js +2 -2
- package/lib/commonjs/components/Blockquote/index.js.map +1 -1
- package/lib/commonjs/components/Button/index.js +6 -6
- package/lib/commonjs/components/Button/index.js.map +1 -1
- package/lib/commonjs/components/Card/index.js +3 -3
- package/lib/commonjs/components/Card/index.js.map +1 -1
- package/lib/commonjs/components/Checkbox/index.js +3 -3
- package/lib/commonjs/components/Checkbox/index.js.map +1 -1
- package/lib/commonjs/components/Chip/index.js +6 -6
- package/lib/commonjs/components/Chip/index.js.map +1 -1
- package/lib/commonjs/components/CloseButton/index.js +3 -3
- package/lib/commonjs/components/CloseButton/index.js.map +1 -1
- package/lib/commonjs/components/ColorSwatch/index.js +4 -4
- package/lib/commonjs/components/ColorSwatch/index.js.map +1 -1
- package/lib/commonjs/components/Dialog/index.js +1 -1
- package/lib/commonjs/components/Dialog/index.js.map +1 -1
- package/lib/commonjs/components/Divider/index.js +4 -4
- package/lib/commonjs/components/Divider/index.js.map +1 -1
- package/lib/commonjs/components/Grid/index.js +6 -6
- package/lib/commonjs/components/Grid/index.js.map +1 -1
- package/lib/commonjs/components/Image/index.js +2 -2
- package/lib/commonjs/components/Image/index.js.map +1 -1
- package/lib/commonjs/components/Indicator/index.js +8 -8
- package/lib/commonjs/components/Indicator/index.js.map +1 -1
- package/lib/commonjs/components/List/index.js +2 -2
- package/lib/commonjs/components/List/index.js.map +1 -1
- package/lib/commonjs/components/Menu/index.js +2 -2
- package/lib/commonjs/components/Menu/index.js.map +1 -1
- package/lib/commonjs/components/Overlay/index.js +5 -5
- package/lib/commonjs/components/Overlay/index.js.map +1 -1
- package/lib/commonjs/components/Paper/index.js +2 -2
- package/lib/commonjs/components/Paper/index.js.map +1 -1
- package/lib/commonjs/components/RingProgress/index.js +78 -55
- package/lib/commonjs/components/RingProgress/index.js.map +1 -1
- package/lib/commonjs/components/SimpleGrid/index.js +1 -1
- package/lib/commonjs/components/SimpleGrid/index.js.map +1 -1
- package/lib/commonjs/components/Stepper/index.js +1 -1
- package/lib/commonjs/components/Stepper/index.js.map +1 -1
- package/lib/commonjs/components/Table/index.js +257 -273
- package/lib/commonjs/components/Table/index.js.map +1 -1
- package/lib/commonjs/components/ThemeIcon/index.js +4 -4
- package/lib/commonjs/components/ThemeIcon/index.js.map +1 -1
- package/lib/commonjs/components/Timeline/index.js +1 -1
- package/lib/commonjs/components/Timeline/index.js.map +1 -1
- package/lib/commonjs/components/index.js +29 -29
- package/lib/commonjs/components/index.js.map +1 -1
- package/lib/commonjs/theme/create-styles.js +35 -0
- package/lib/commonjs/theme/create-styles.js.map +1 -1
- package/lib/module/components/Anchor/index.js +5 -5
- package/lib/module/components/Anchor/index.js.map +1 -1
- package/lib/module/components/Avatar/index.js +3 -3
- package/lib/module/components/Avatar/index.js.map +1 -1
- package/lib/module/components/BackgroundImage/index.js +1 -1
- package/lib/module/components/BackgroundImage/index.js.map +1 -1
- package/lib/module/components/Badge/index.js +5 -5
- package/lib/module/components/Badge/index.js.map +1 -1
- package/lib/module/components/Blockquote/index.js +2 -2
- package/lib/module/components/Blockquote/index.js.map +1 -1
- package/lib/module/components/Button/index.js +6 -6
- package/lib/module/components/Button/index.js.map +1 -1
- package/lib/module/components/Card/index.js +3 -3
- package/lib/module/components/Card/index.js.map +1 -1
- package/lib/module/components/Checkbox/index.js +3 -3
- package/lib/module/components/Checkbox/index.js.map +1 -1
- package/lib/module/components/Chip/index.js +6 -6
- package/lib/module/components/Chip/index.js.map +1 -1
- package/lib/module/components/CloseButton/index.js +3 -3
- package/lib/module/components/CloseButton/index.js.map +1 -1
- package/lib/module/components/ColorSwatch/index.js +4 -4
- package/lib/module/components/ColorSwatch/index.js.map +1 -1
- package/lib/module/components/Dialog/index.js +1 -1
- package/lib/module/components/Dialog/index.js.map +1 -1
- package/lib/module/components/Divider/index.js +4 -4
- package/lib/module/components/Divider/index.js.map +1 -1
- package/lib/module/components/Grid/index.js +6 -6
- package/lib/module/components/Grid/index.js.map +1 -1
- package/lib/module/components/Image/index.js +2 -2
- package/lib/module/components/Image/index.js.map +1 -1
- package/lib/module/components/Indicator/index.js +8 -8
- package/lib/module/components/Indicator/index.js.map +1 -1
- package/lib/module/components/List/index.js +2 -2
- package/lib/module/components/List/index.js.map +1 -1
- package/lib/module/components/Menu/index.js +2 -2
- package/lib/module/components/Menu/index.js.map +1 -1
- package/lib/module/components/Overlay/index.js +5 -5
- package/lib/module/components/Overlay/index.js.map +1 -1
- package/lib/module/components/Paper/index.js +2 -2
- package/lib/module/components/Paper/index.js.map +1 -1
- package/lib/module/components/RingProgress/index.js +79 -56
- package/lib/module/components/RingProgress/index.js.map +1 -1
- package/lib/module/components/SimpleGrid/index.js +1 -1
- package/lib/module/components/SimpleGrid/index.js.map +1 -1
- package/lib/module/components/Stepper/index.js +1 -1
- package/lib/module/components/Stepper/index.js.map +1 -1
- package/lib/module/components/Table/index.js +257 -274
- package/lib/module/components/Table/index.js.map +1 -1
- package/lib/module/components/ThemeIcon/index.js +4 -4
- package/lib/module/components/ThemeIcon/index.js.map +1 -1
- package/lib/module/components/Timeline/index.js +1 -1
- package/lib/module/components/Timeline/index.js.map +1 -1
- package/lib/module/components/index.js +3 -1
- package/lib/module/components/index.js.map +1 -1
- package/lib/module/theme/create-styles.js +36 -0
- package/lib/module/theme/create-styles.js.map +1 -1
- package/lib/typescript/commonjs/src/components/Button/Button.styles.d.ts +35 -10
- package/lib/typescript/commonjs/src/components/Button/Button.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/RingProgress/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/Table/index.d.ts +17 -83
- package/lib/typescript/commonjs/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.styles.d.ts +14 -3
- package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.styles.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/components/index.d.ts +1 -1
- package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
- package/lib/typescript/commonjs/src/theme/create-styles.d.ts +36 -2
- package/lib/typescript/commonjs/src/theme/create-styles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Button/Button.styles.d.ts +35 -10
- package/lib/typescript/module/src/components/Button/Button.styles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/RingProgress/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/Table/index.d.ts +17 -83
- package/lib/typescript/module/src/components/Table/index.d.ts.map +1 -1
- package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.styles.d.ts +14 -3
- package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.styles.d.ts.map +1 -1
- package/lib/typescript/module/src/components/index.d.ts +1 -1
- package/lib/typescript/module/src/components/index.d.ts.map +1 -1
- package/lib/typescript/module/src/theme/create-styles.d.ts +36 -2
- package/lib/typescript/module/src/theme/create-styles.d.ts.map +1 -1
- package/package.json +1 -1
- package/src/components/Anchor/index.tsx +2 -2
- package/src/components/Avatar/index.tsx +1 -1
- package/src/components/BackgroundImage/index.tsx +1 -1
- package/src/components/Badge/index.tsx +2 -2
- package/src/components/Blockquote/index.tsx +1 -1
- package/src/components/Button/index.tsx +6 -6
- package/src/components/Card/index.tsx +3 -3
- package/src/components/Checkbox/index.tsx +1 -1
- package/src/components/Chip/index.tsx +2 -2
- package/src/components/CloseButton/index.tsx +1 -1
- package/src/components/ColorSwatch/index.tsx +1 -1
- package/src/components/Dialog/index.tsx +1 -1
- package/src/components/Divider/index.tsx +1 -1
- package/src/components/Grid/index.tsx +2 -2
- package/src/components/Image/index.tsx +1 -1
- package/src/components/Indicator/index.tsx +1 -1
- package/src/components/List/index.tsx +1 -1
- package/src/components/Menu/index.tsx +1 -1
- package/src/components/Overlay/index.tsx +1 -1
- package/src/components/Paper/index.tsx +1 -1
- package/src/components/RingProgress/index.tsx +89 -56
- package/src/components/SimpleGrid/index.tsx +1 -1
- package/src/components/Stepper/index.tsx +1 -1
- package/src/components/Table/index.tsx +333 -413
- package/src/components/ThemeIcon/index.tsx +1 -1
- package/src/components/Timeline/index.tsx +1 -1
- package/src/components/index.tsx +3 -1
- package/src/theme/create-styles.ts +44 -6
- package/lib/commonjs/components/Table/Table.example.js +0 -323
- package/lib/commonjs/components/Table/Table.example.js.map +0 -1
- package/lib/module/components/Table/Table.example.js +0 -318
- package/lib/module/components/Table/Table.example.js.map +0 -1
- package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts +0 -13
- package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts.map +0 -1
- package/lib/typescript/module/src/components/Table/Table.example.d.ts +0 -13
- package/lib/typescript/module/src/components/Table/Table.example.d.ts.map +0 -1
- package/src/components/Table/Table.example.tsx +0 -215
|
@@ -1,208 +1,164 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
|
-
import React, { forwardRef
|
|
3
|
+
import React, { forwardRef } from 'react';
|
|
4
4
|
import { ScrollView } from 'react-native';
|
|
5
5
|
import { BoxView } from "../BoxView/index.js";
|
|
6
6
|
import { Text } from "../Text/index.js";
|
|
7
7
|
import { useComponentDefaultProps } from "../../theme/theme-provider.js";
|
|
8
8
|
import { createStyles } from "../../theme/index.js";
|
|
9
9
|
import { rem } from "../../theme/utils/rem.js";
|
|
10
|
-
import { withTextWrapper } from "../../theme/utils/withTextWrapper.js";
|
|
11
10
|
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
12
|
-
const
|
|
13
|
-
const useTableContext = () => {
|
|
14
|
-
const context = useContext(TableContext);
|
|
15
|
-
return context;
|
|
16
|
-
};
|
|
17
|
-
const fontSizes = {
|
|
18
|
-
xs: rem(10),
|
|
19
|
-
sm: rem(12),
|
|
20
|
-
md: rem(14),
|
|
21
|
-
lg: rem(16),
|
|
22
|
-
xl: rem(18)
|
|
23
|
-
};
|
|
24
|
-
const useTableStyles = createStyles((theme, {
|
|
25
|
-
withBorder,
|
|
26
|
-
captionSide,
|
|
27
|
-
flex,
|
|
28
|
-
flexGrow,
|
|
29
|
-
flexShrink,
|
|
30
|
-
flexBasis
|
|
31
|
-
}) => ({
|
|
32
|
-
wrapper: {
|
|
33
|
-
// Apply flex properties to allow table to expand in container
|
|
34
|
-
...(flex !== undefined && {
|
|
35
|
-
flex
|
|
36
|
-
}),
|
|
37
|
-
...(flexGrow !== undefined && {
|
|
38
|
-
flexGrow
|
|
39
|
-
}),
|
|
40
|
-
...(flexShrink !== undefined && {
|
|
41
|
-
flexShrink
|
|
42
|
-
}),
|
|
43
|
-
...(flexBasis !== undefined && {
|
|
44
|
-
flexBasis
|
|
45
|
-
})
|
|
46
|
-
},
|
|
47
|
-
root: {
|
|
48
|
-
width: '100%',
|
|
49
|
-
borderCollapse: 'collapse',
|
|
50
|
-
...(withBorder && {
|
|
51
|
-
borderWidth: 1,
|
|
52
|
-
borderColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[3]
|
|
53
|
-
})
|
|
54
|
-
},
|
|
55
|
-
caption: {
|
|
56
|
-
fontSize: theme.fontSizes.sm,
|
|
57
|
-
color: theme.colorScheme === 'dark' ? theme.colors.dark?.[2] : theme.colors.gray?.[6],
|
|
58
|
-
paddingVertical: theme.spacing.xs,
|
|
59
|
-
textAlign: 'center',
|
|
60
|
-
...(captionSide === 'bottom' && {
|
|
61
|
-
order: 1
|
|
62
|
-
})
|
|
63
|
-
}
|
|
64
|
-
}));
|
|
65
|
-
const useTableHeadStyles = createStyles(theme => ({
|
|
66
|
-
thead: {
|
|
67
|
-
borderBottomWidth: 1,
|
|
68
|
-
borderBottomColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[3]
|
|
69
|
-
}
|
|
70
|
-
}));
|
|
71
|
-
const useTableRowStyles = createStyles((theme, {
|
|
72
|
-
striped,
|
|
73
|
-
isEven
|
|
74
|
-
}) => ({
|
|
75
|
-
tr: {
|
|
76
|
-
flexDirection: 'row',
|
|
77
|
-
borderBottomWidth: 1,
|
|
78
|
-
borderBottomColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[3],
|
|
79
|
-
...(striped && isEven && {
|
|
80
|
-
backgroundColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[6] : theme.colors.gray?.[0]
|
|
81
|
-
})
|
|
82
|
-
}
|
|
83
|
-
}));
|
|
84
|
-
const useTableCellStyles = createStyles((theme, {
|
|
85
|
-
fontSize,
|
|
86
|
-
verticalSpacing,
|
|
11
|
+
const useStyles = createStyles((theme, {
|
|
87
12
|
horizontalSpacing,
|
|
13
|
+
verticalSpacing,
|
|
14
|
+
fontSize,
|
|
15
|
+
withBorder,
|
|
88
16
|
withColumnBorders,
|
|
89
|
-
|
|
90
|
-
width
|
|
17
|
+
striped
|
|
91
18
|
}) => {
|
|
92
|
-
const
|
|
93
|
-
|
|
94
|
-
|
|
19
|
+
const borderColor = theme.colorScheme === 'dark' ? (theme.colors.dark || [])[4] : (theme.colors.gray || [])[3];
|
|
20
|
+
const getSpacing = size => {
|
|
21
|
+
if (typeof size === 'number') return rem(size);
|
|
22
|
+
return theme.spacing[size] || theme.spacing.xs;
|
|
95
23
|
};
|
|
96
|
-
const
|
|
97
|
-
if (typeof
|
|
98
|
-
return theme.
|
|
24
|
+
const getFontSize = size => {
|
|
25
|
+
if (typeof size === 'number') return size;
|
|
26
|
+
return theme.fontSizes[size] || theme.fontSizes.sm;
|
|
99
27
|
};
|
|
28
|
+
const hPadding = getSpacing(horizontalSpacing);
|
|
29
|
+
const vPadding = getSpacing(verticalSpacing);
|
|
30
|
+
const cellFontSize = getFontSize(fontSize);
|
|
100
31
|
return {
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
32
|
+
root: {
|
|
33
|
+
width: '100%',
|
|
34
|
+
backgroundColor: 'transparent'
|
|
35
|
+
},
|
|
36
|
+
scrollView: {
|
|
37
|
+
width: '100%'
|
|
38
|
+
},
|
|
39
|
+
container: {
|
|
40
|
+
flexDirection: 'column',
|
|
41
|
+
borderWidth: withBorder ? 1 : 0,
|
|
42
|
+
borderColor: withBorder ? borderColor : 'transparent',
|
|
43
|
+
borderStyle: 'solid'
|
|
44
|
+
},
|
|
45
|
+
caption: {
|
|
46
|
+
paddingHorizontal: hPadding,
|
|
47
|
+
paddingVertical: theme.spacing.xs,
|
|
48
|
+
fontSize: theme.fontSizes.sm,
|
|
49
|
+
color: theme.colorScheme === 'dark' ? (theme.colors.dark || [])[2] : (theme.colors.gray || [])[6],
|
|
50
|
+
textAlign: 'left'
|
|
51
|
+
},
|
|
52
|
+
captionTop: {
|
|
53
|
+
marginBottom: 0
|
|
54
|
+
},
|
|
55
|
+
captionBottom: {
|
|
56
|
+
marginTop: 0
|
|
57
|
+
},
|
|
58
|
+
thead: {
|
|
59
|
+
flexDirection: 'column'
|
|
60
|
+
},
|
|
61
|
+
tbody: {
|
|
62
|
+
flexDirection: 'column'
|
|
63
|
+
},
|
|
64
|
+
tfoot: {
|
|
65
|
+
flexDirection: 'column'
|
|
66
|
+
},
|
|
67
|
+
tr: {
|
|
68
|
+
flexDirection: 'row'
|
|
69
|
+
},
|
|
70
|
+
th: {
|
|
71
|
+
flex: 1,
|
|
72
|
+
paddingHorizontal: hPadding,
|
|
73
|
+
paddingVertical: vPadding,
|
|
74
|
+
borderBottomWidth: 1,
|
|
75
|
+
borderBottomColor: borderColor,
|
|
76
|
+
borderBottomStyle: 'solid',
|
|
77
|
+
borderRightWidth: withColumnBorders ? 1 : 0,
|
|
78
|
+
borderRightColor: withColumnBorders ? borderColor : 'transparent',
|
|
79
|
+
borderRightStyle: 'solid',
|
|
80
|
+
justifyContent: 'center'
|
|
81
|
+
},
|
|
82
|
+
thText: {
|
|
83
|
+
fontWeight: 'bold',
|
|
84
|
+
color: theme.colorScheme === 'dark' ? (theme.colors.dark || [])[0] : (theme.colors.gray || [])[7],
|
|
85
|
+
fontSize: cellFontSize
|
|
86
|
+
},
|
|
87
|
+
td: {
|
|
88
|
+
flex: 1,
|
|
89
|
+
paddingHorizontal: hPadding,
|
|
90
|
+
paddingVertical: vPadding,
|
|
91
|
+
borderTopWidth: 1,
|
|
92
|
+
borderTopColor: borderColor,
|
|
93
|
+
borderTopStyle: 'solid',
|
|
94
|
+
borderRightWidth: withColumnBorders ? 1 : 0,
|
|
95
|
+
borderRightColor: withColumnBorders ? borderColor : 'transparent',
|
|
96
|
+
borderRightStyle: 'solid',
|
|
97
|
+
justifyContent: 'center'
|
|
98
|
+
},
|
|
99
|
+
tdText: {
|
|
100
|
+
color: theme.colorScheme === 'dark' ? (theme.colors.dark || [])[0] : theme.black,
|
|
101
|
+
fontSize: cellFontSize
|
|
102
|
+
},
|
|
103
|
+
firstBodyRow: {
|
|
104
|
+
borderTopWidth: 0
|
|
105
|
+
},
|
|
106
|
+
lastCell: {
|
|
107
|
+
borderRightWidth: 0
|
|
108
|
+
},
|
|
109
|
+
stripedRow: striped ? {
|
|
110
|
+
backgroundColor: theme.colorScheme === 'dark' ? (theme.colors.dark || [])[6] : (theme.colors.gray || [])[0]
|
|
111
|
+
} : {}
|
|
120
112
|
};
|
|
121
113
|
});
|
|
122
114
|
const defaultProps = {
|
|
123
|
-
horizontalSpacing: 'xs',
|
|
124
|
-
verticalSpacing: 'xs',
|
|
125
|
-
fontSize: 'sm',
|
|
126
115
|
striped: false,
|
|
127
116
|
highlightOnHover: false,
|
|
117
|
+
captionSide: 'top',
|
|
118
|
+
horizontalSpacing: 'xs',
|
|
119
|
+
fontSize: 'sm',
|
|
120
|
+
verticalSpacing: 7,
|
|
128
121
|
withBorder: false,
|
|
129
122
|
withColumnBorders: false,
|
|
130
|
-
|
|
123
|
+
horizontallyScrollable: false
|
|
131
124
|
};
|
|
132
|
-
|
|
125
|
+
|
|
126
|
+
// Context to share table configuration with child components
|
|
127
|
+
|
|
128
|
+
const TableContext = /*#__PURE__*/React.createContext(null);
|
|
129
|
+
const useTableContext = () => {
|
|
130
|
+
const context = React.useContext(TableContext);
|
|
131
|
+
if (!context) {
|
|
132
|
+
throw new Error('Table compound components must be used within Table');
|
|
133
|
+
}
|
|
134
|
+
return context;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// Table Caption Component
|
|
138
|
+
const TableCaption = /*#__PURE__*/forwardRef((props, ref) => {
|
|
133
139
|
const {
|
|
134
140
|
children,
|
|
135
|
-
horizontalSpacing,
|
|
136
|
-
verticalSpacing,
|
|
137
|
-
fontSize,
|
|
138
|
-
striped,
|
|
139
|
-
highlightOnHover: _highlightOnHover,
|
|
140
|
-
withBorder,
|
|
141
|
-
withColumnBorders,
|
|
142
|
-
captionSide,
|
|
143
|
-
caption,
|
|
144
|
-
flex,
|
|
145
|
-
flexGrow,
|
|
146
|
-
flexShrink,
|
|
147
|
-
flexBasis,
|
|
148
141
|
style,
|
|
149
142
|
...others
|
|
150
|
-
} =
|
|
143
|
+
} = props;
|
|
151
144
|
const {
|
|
152
145
|
styles,
|
|
153
146
|
sx
|
|
154
|
-
} =
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
});
|
|
164
|
-
|
|
165
|
-
// Track column widths to ensure alignment across rows
|
|
166
|
-
const [columnWidths, setColumnWidths] = useState([]);
|
|
167
|
-
const onCellLayout = useCallback((columnIndex, width) => {
|
|
168
|
-
setColumnWidths(prevWidths => {
|
|
169
|
-
const newWidths = [...prevWidths];
|
|
170
|
-
// Store the maximum width for each column to ensure all cells in that column have the same width
|
|
171
|
-
if (!newWidths[columnIndex] || width > newWidths[columnIndex]) {
|
|
172
|
-
newWidths[columnIndex] = width;
|
|
173
|
-
}
|
|
174
|
-
return newWidths;
|
|
175
|
-
});
|
|
176
|
-
}, []);
|
|
177
|
-
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
|
178
|
-
value: {
|
|
179
|
-
striped: striped,
|
|
180
|
-
highlightOnHover: _highlightOnHover,
|
|
181
|
-
withBorder: withBorder,
|
|
182
|
-
withColumnBorders: withColumnBorders,
|
|
183
|
-
fontSize: fontSize,
|
|
184
|
-
verticalSpacing: verticalSpacing,
|
|
185
|
-
horizontalSpacing: horizontalSpacing,
|
|
186
|
-
columnWidths,
|
|
187
|
-
onCellLayout
|
|
188
|
-
},
|
|
189
|
-
children: /*#__PURE__*/_jsx(ScrollView, {
|
|
190
|
-
horizontal: true,
|
|
191
|
-
style: styles.wrapper,
|
|
192
|
-
showsHorizontalScrollIndicator: true,
|
|
193
|
-
children: /*#__PURE__*/_jsxs(BoxView, {
|
|
194
|
-
ref: ref,
|
|
195
|
-
style: sx(styles.root, style),
|
|
196
|
-
...others,
|
|
197
|
-
children: [caption && /*#__PURE__*/_jsx(Text, {
|
|
198
|
-
style: styles.caption,
|
|
199
|
-
children: caption
|
|
200
|
-
}), children]
|
|
201
|
-
})
|
|
202
|
-
})
|
|
147
|
+
} = useTableContext();
|
|
148
|
+
return /*#__PURE__*/_jsx(BoxView, {
|
|
149
|
+
ref: ref,
|
|
150
|
+
style: sx(styles.caption, style),
|
|
151
|
+
...others,
|
|
152
|
+
children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
153
|
+
style: styles.caption,
|
|
154
|
+
children: children
|
|
155
|
+
}) : children
|
|
203
156
|
});
|
|
204
157
|
});
|
|
205
|
-
|
|
158
|
+
TableCaption.displayName = 'Table.Caption';
|
|
159
|
+
|
|
160
|
+
// Table Head Component
|
|
161
|
+
const THead = /*#__PURE__*/forwardRef((props, ref) => {
|
|
206
162
|
const {
|
|
207
163
|
children,
|
|
208
164
|
style,
|
|
@@ -211,9 +167,7 @@ const Thead = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
211
167
|
const {
|
|
212
168
|
styles,
|
|
213
169
|
sx
|
|
214
|
-
} =
|
|
215
|
-
name: 'Thead'
|
|
216
|
-
});
|
|
170
|
+
} = useTableContext();
|
|
217
171
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
218
172
|
ref: ref,
|
|
219
173
|
style: sx(styles.thead, style),
|
|
@@ -221,169 +175,198 @@ const Thead = /*#__PURE__*/forwardRef((props, ref) => {
|
|
|
221
175
|
children: children
|
|
222
176
|
});
|
|
223
177
|
});
|
|
224
|
-
|
|
178
|
+
THead.displayName = 'Table.THead';
|
|
179
|
+
|
|
180
|
+
// Table Body Component
|
|
181
|
+
const TBody = /*#__PURE__*/forwardRef((props, ref) => {
|
|
225
182
|
const {
|
|
226
183
|
children,
|
|
227
184
|
style,
|
|
228
185
|
...others
|
|
229
186
|
} = props;
|
|
230
|
-
const
|
|
187
|
+
const {
|
|
188
|
+
styles,
|
|
189
|
+
sx,
|
|
190
|
+
striped
|
|
191
|
+
} = useTableContext();
|
|
192
|
+
|
|
193
|
+
// Process children to add row styling
|
|
194
|
+
const processedChildren = React.Children.map(children, (child, index) => {
|
|
195
|
+
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
196
|
+
const isOddRow = index % 2 === 1;
|
|
197
|
+
const childProps = child.props;
|
|
198
|
+
const rowStyle = [childProps.style, striped && isOddRow && styles.stripedRow].filter(Boolean);
|
|
199
|
+
return /*#__PURE__*/React.cloneElement(child, {
|
|
200
|
+
'style': rowStyle.length > 0 ? rowStyle : childProps.style,
|
|
201
|
+
'data-index': index,
|
|
202
|
+
'data-first': index === 0
|
|
203
|
+
});
|
|
204
|
+
});
|
|
231
205
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
232
206
|
ref: ref,
|
|
233
|
-
style: style,
|
|
207
|
+
style: sx(styles.tbody, style),
|
|
234
208
|
...others,
|
|
235
|
-
children:
|
|
236
|
-
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
237
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
238
|
-
key: index,
|
|
239
|
-
__index: index
|
|
240
|
-
});
|
|
241
|
-
})
|
|
209
|
+
children: processedChildren
|
|
242
210
|
});
|
|
243
211
|
});
|
|
244
|
-
|
|
212
|
+
TBody.displayName = 'Table.TBody';
|
|
213
|
+
|
|
214
|
+
// Table Footer Component
|
|
215
|
+
const TFoot = /*#__PURE__*/forwardRef((props, ref) => {
|
|
245
216
|
const {
|
|
246
217
|
children,
|
|
247
218
|
style,
|
|
248
219
|
...others
|
|
249
220
|
} = props;
|
|
221
|
+
const {
|
|
222
|
+
styles,
|
|
223
|
+
sx
|
|
224
|
+
} = useTableContext();
|
|
250
225
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
251
226
|
ref: ref,
|
|
252
|
-
style: style,
|
|
227
|
+
style: sx(styles.tfoot, style),
|
|
253
228
|
...others,
|
|
254
229
|
children: children
|
|
255
230
|
});
|
|
256
231
|
});
|
|
232
|
+
TFoot.displayName = 'Table.TFoot';
|
|
233
|
+
|
|
234
|
+
// Table Row Component
|
|
257
235
|
const Tr = /*#__PURE__*/forwardRef((props, ref) => {
|
|
258
236
|
const {
|
|
259
237
|
children,
|
|
260
238
|
style,
|
|
261
|
-
__index,
|
|
262
239
|
...others
|
|
263
240
|
} = props;
|
|
264
|
-
const context = useTableContext();
|
|
265
241
|
const {
|
|
266
242
|
styles,
|
|
267
243
|
sx
|
|
268
|
-
} =
|
|
269
|
-
striped: context?.striped ?? false,
|
|
270
|
-
highlightOnHover: context?.highlightOnHover ?? false,
|
|
271
|
-
isEven: (__index ?? 0) % 2 === 0
|
|
272
|
-
}, {
|
|
273
|
-
name: 'Tr'
|
|
274
|
-
});
|
|
275
|
-
|
|
276
|
-
// Add column indices to children (Th and Td components)
|
|
277
|
-
const childrenArray = React.Children.toArray(children);
|
|
278
|
-
const childrenWithColumnIndex = childrenArray.map((child, index) => {
|
|
279
|
-
if (! /*#__PURE__*/React.isValidElement(child)) return child;
|
|
280
|
-
return /*#__PURE__*/React.cloneElement(child, {
|
|
281
|
-
__columnIndex: index
|
|
282
|
-
});
|
|
283
|
-
});
|
|
244
|
+
} = useTableContext();
|
|
284
245
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
285
246
|
ref: ref,
|
|
286
247
|
style: sx(styles.tr, style),
|
|
287
248
|
...others,
|
|
288
|
-
children:
|
|
249
|
+
children: children
|
|
289
250
|
});
|
|
290
251
|
});
|
|
252
|
+
Tr.displayName = 'Table.Tr';
|
|
253
|
+
|
|
254
|
+
// Table Header Cell Component
|
|
291
255
|
const Th = /*#__PURE__*/forwardRef((props, ref) => {
|
|
292
256
|
const {
|
|
293
257
|
children,
|
|
294
258
|
style,
|
|
295
|
-
|
|
296
|
-
__columnIndex,
|
|
259
|
+
colSpan,
|
|
297
260
|
...others
|
|
298
261
|
} = props;
|
|
299
|
-
const context = useTableContext();
|
|
300
|
-
const columnIndex = __columnIndex ?? 0;
|
|
301
|
-
const columnWidth = context?.columnWidths?.[columnIndex];
|
|
302
262
|
const {
|
|
303
263
|
styles,
|
|
304
264
|
sx
|
|
305
|
-
} =
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
withColumnBorders: context?.withColumnBorders ?? false,
|
|
310
|
-
isHeader: true,
|
|
311
|
-
width: columnWidth
|
|
312
|
-
}, {
|
|
313
|
-
name: 'Th'
|
|
314
|
-
});
|
|
315
|
-
const handleLayout = useCallback(event => {
|
|
316
|
-
const {
|
|
317
|
-
width
|
|
318
|
-
} = event.nativeEvent.layout;
|
|
319
|
-
if (context?.onCellLayout && width > 0) {
|
|
320
|
-
context.onCellLayout(columnIndex, width);
|
|
321
|
-
}
|
|
322
|
-
}, [context, columnIndex]);
|
|
265
|
+
} = useTableContext();
|
|
266
|
+
const cellStyle = [styles.th, colSpan && {
|
|
267
|
+
flex: colSpan
|
|
268
|
+
}, style].filter(Boolean);
|
|
323
269
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
324
270
|
ref: ref,
|
|
325
|
-
style: sx(
|
|
326
|
-
onLayout: handleLayout,
|
|
271
|
+
style: sx(...cellStyle),
|
|
327
272
|
...others,
|
|
328
|
-
children:
|
|
273
|
+
children: typeof children === 'string' ? /*#__PURE__*/_jsx(Text, {
|
|
274
|
+
style: styles.thText,
|
|
275
|
+
children: children
|
|
276
|
+
}) : children
|
|
329
277
|
});
|
|
330
278
|
});
|
|
279
|
+
Th.displayName = 'Table.Th';
|
|
280
|
+
|
|
281
|
+
// Table Data Cell Component
|
|
331
282
|
const Td = /*#__PURE__*/forwardRef((props, ref) => {
|
|
332
283
|
const {
|
|
333
284
|
children,
|
|
334
285
|
style,
|
|
335
|
-
|
|
336
|
-
__columnIndex,
|
|
286
|
+
colSpan,
|
|
337
287
|
...others
|
|
338
288
|
} = props;
|
|
339
|
-
const context = useTableContext();
|
|
340
|
-
const columnIndex = __columnIndex ?? 0;
|
|
341
|
-
const columnWidth = context?.columnWidths?.[columnIndex];
|
|
342
289
|
const {
|
|
343
290
|
styles,
|
|
344
291
|
sx
|
|
345
|
-
} =
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
isHeader: false,
|
|
351
|
-
width: columnWidth
|
|
352
|
-
}, {
|
|
353
|
-
name: 'Td'
|
|
354
|
-
});
|
|
355
|
-
const handleLayout = useCallback(event => {
|
|
356
|
-
const {
|
|
357
|
-
width
|
|
358
|
-
} = event.nativeEvent.layout;
|
|
359
|
-
if (context?.onCellLayout && width > 0) {
|
|
360
|
-
context.onCellLayout(columnIndex, width);
|
|
361
|
-
}
|
|
362
|
-
}, [context, columnIndex]);
|
|
292
|
+
} = useTableContext();
|
|
293
|
+
const isFirstRow = others['data-first'];
|
|
294
|
+
const cellStyle = [styles.td, isFirstRow && styles.firstBodyRow, colSpan && {
|
|
295
|
+
flex: colSpan
|
|
296
|
+
}, style].filter(Boolean);
|
|
363
297
|
return /*#__PURE__*/_jsx(BoxView, {
|
|
364
298
|
ref: ref,
|
|
365
|
-
style: sx(
|
|
366
|
-
onLayout: handleLayout,
|
|
299
|
+
style: sx(...cellStyle),
|
|
367
300
|
...others,
|
|
368
|
-
children:
|
|
301
|
+
children: /*#__PURE__*/_jsx(Text, {
|
|
302
|
+
style: styles.tdText,
|
|
303
|
+
children: children
|
|
304
|
+
})
|
|
369
305
|
});
|
|
370
306
|
});
|
|
371
|
-
Table.displayName = 'Table';
|
|
372
|
-
Thead.displayName = 'Table.Thead';
|
|
373
|
-
Tbody.displayName = 'Table.Tbody';
|
|
374
|
-
Tfoot.displayName = 'Table.Tfoot';
|
|
375
|
-
Tr.displayName = 'Table.Tr';
|
|
376
|
-
Th.displayName = 'Table.Th';
|
|
377
307
|
Td.displayName = 'Table.Td';
|
|
378
308
|
|
|
379
|
-
//
|
|
309
|
+
// Main Table Component
|
|
310
|
+
export const _Table = /*#__PURE__*/forwardRef((props, ref) => {
|
|
311
|
+
const {
|
|
312
|
+
striped,
|
|
313
|
+
highlightOnHover,
|
|
314
|
+
captionSide,
|
|
315
|
+
horizontalSpacing,
|
|
316
|
+
verticalSpacing,
|
|
317
|
+
fontSize,
|
|
318
|
+
withBorder,
|
|
319
|
+
withColumnBorders,
|
|
320
|
+
children,
|
|
321
|
+
style,
|
|
322
|
+
horizontallyScrollable,
|
|
323
|
+
...others
|
|
324
|
+
} = useComponentDefaultProps('Table', defaultProps, props);
|
|
325
|
+
const {
|
|
326
|
+
styles,
|
|
327
|
+
sx
|
|
328
|
+
} = useStyles({
|
|
329
|
+
horizontalSpacing: horizontalSpacing,
|
|
330
|
+
verticalSpacing: verticalSpacing,
|
|
331
|
+
fontSize: fontSize,
|
|
332
|
+
withBorder: withBorder,
|
|
333
|
+
withColumnBorders: withColumnBorders,
|
|
334
|
+
striped: striped
|
|
335
|
+
}, {
|
|
336
|
+
name: 'Table'
|
|
337
|
+
});
|
|
338
|
+
const contextValue = {
|
|
339
|
+
styles,
|
|
340
|
+
sx,
|
|
341
|
+
striped: striped || false,
|
|
342
|
+
highlightOnHover: highlightOnHover || false
|
|
343
|
+
};
|
|
344
|
+
const tableContent = /*#__PURE__*/_jsxs(BoxView, {
|
|
345
|
+
ref: ref,
|
|
346
|
+
style: sx(styles.container, style),
|
|
347
|
+
...others,
|
|
348
|
+
children: [captionSide === 'top' && React.Children.toArray(children).find(child => /*#__PURE__*/React.isValidElement(child) && child.type.displayName === 'Table.Caption'), React.Children.toArray(children).filter(child => /*#__PURE__*/React.isValidElement(child) && child.type.displayName !== 'Table.Caption'), captionSide === 'bottom' && React.Children.toArray(children).find(child => /*#__PURE__*/React.isValidElement(child) && child.type.displayName === 'Table.Caption')]
|
|
349
|
+
});
|
|
350
|
+
return /*#__PURE__*/_jsx(TableContext.Provider, {
|
|
351
|
+
value: contextValue,
|
|
352
|
+
children: horizontallyScrollable ? /*#__PURE__*/_jsx(ScrollView, {
|
|
353
|
+
horizontal: true,
|
|
354
|
+
style: styles.scrollView,
|
|
355
|
+
showsHorizontalScrollIndicator: true,
|
|
356
|
+
children: tableContent
|
|
357
|
+
}) : tableContent
|
|
358
|
+
});
|
|
359
|
+
});
|
|
360
|
+
_Table.displayName = 'Table';
|
|
380
361
|
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
362
|
+
// Attach compound components
|
|
363
|
+
export const Table = Object.assign(_Table, {
|
|
364
|
+
Caption: TableCaption,
|
|
365
|
+
THead,
|
|
366
|
+
TBody,
|
|
367
|
+
TFoot,
|
|
368
|
+
Tr,
|
|
369
|
+
Th,
|
|
370
|
+
Td
|
|
371
|
+
});
|
|
389
372
|
//# sourceMappingURL=index.js.map
|