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