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.
Files changed (173) hide show
  1. package/README.md +45 -345
  2. package/lib/commonjs/components/Anchor/index.js +5 -5
  3. package/lib/commonjs/components/Anchor/index.js.map +1 -1
  4. package/lib/commonjs/components/Avatar/index.js +3 -3
  5. package/lib/commonjs/components/Avatar/index.js.map +1 -1
  6. package/lib/commonjs/components/BackgroundImage/index.js +1 -1
  7. package/lib/commonjs/components/BackgroundImage/index.js.map +1 -1
  8. package/lib/commonjs/components/Badge/index.js +5 -5
  9. package/lib/commonjs/components/Badge/index.js.map +1 -1
  10. package/lib/commonjs/components/Blockquote/index.js +2 -2
  11. package/lib/commonjs/components/Blockquote/index.js.map +1 -1
  12. package/lib/commonjs/components/Button/index.js +6 -6
  13. package/lib/commonjs/components/Button/index.js.map +1 -1
  14. package/lib/commonjs/components/Card/index.js +3 -3
  15. package/lib/commonjs/components/Card/index.js.map +1 -1
  16. package/lib/commonjs/components/Checkbox/index.js +3 -3
  17. package/lib/commonjs/components/Checkbox/index.js.map +1 -1
  18. package/lib/commonjs/components/Chip/index.js +6 -6
  19. package/lib/commonjs/components/Chip/index.js.map +1 -1
  20. package/lib/commonjs/components/CloseButton/index.js +3 -3
  21. package/lib/commonjs/components/CloseButton/index.js.map +1 -1
  22. package/lib/commonjs/components/ColorSwatch/index.js +4 -4
  23. package/lib/commonjs/components/ColorSwatch/index.js.map +1 -1
  24. package/lib/commonjs/components/Dialog/index.js +1 -1
  25. package/lib/commonjs/components/Dialog/index.js.map +1 -1
  26. package/lib/commonjs/components/Divider/index.js +4 -4
  27. package/lib/commonjs/components/Divider/index.js.map +1 -1
  28. package/lib/commonjs/components/Grid/index.js +6 -6
  29. package/lib/commonjs/components/Grid/index.js.map +1 -1
  30. package/lib/commonjs/components/Image/index.js +2 -2
  31. package/lib/commonjs/components/Image/index.js.map +1 -1
  32. package/lib/commonjs/components/Indicator/index.js +8 -8
  33. package/lib/commonjs/components/Indicator/index.js.map +1 -1
  34. package/lib/commonjs/components/List/index.js +2 -2
  35. package/lib/commonjs/components/List/index.js.map +1 -1
  36. package/lib/commonjs/components/Menu/index.js +2 -2
  37. package/lib/commonjs/components/Menu/index.js.map +1 -1
  38. package/lib/commonjs/components/Overlay/index.js +5 -5
  39. package/lib/commonjs/components/Overlay/index.js.map +1 -1
  40. package/lib/commonjs/components/Paper/index.js +2 -2
  41. package/lib/commonjs/components/Paper/index.js.map +1 -1
  42. package/lib/commonjs/components/RingProgress/index.js +78 -55
  43. package/lib/commonjs/components/RingProgress/index.js.map +1 -1
  44. package/lib/commonjs/components/SimpleGrid/index.js +1 -1
  45. package/lib/commonjs/components/SimpleGrid/index.js.map +1 -1
  46. package/lib/commonjs/components/Stepper/index.js +1 -1
  47. package/lib/commonjs/components/Stepper/index.js.map +1 -1
  48. package/lib/commonjs/components/Table/index.js +257 -273
  49. package/lib/commonjs/components/Table/index.js.map +1 -1
  50. package/lib/commonjs/components/ThemeIcon/index.js +4 -4
  51. package/lib/commonjs/components/ThemeIcon/index.js.map +1 -1
  52. package/lib/commonjs/components/Timeline/index.js +1 -1
  53. package/lib/commonjs/components/Timeline/index.js.map +1 -1
  54. package/lib/commonjs/components/index.js +29 -29
  55. package/lib/commonjs/components/index.js.map +1 -1
  56. package/lib/commonjs/theme/create-styles.js +35 -0
  57. package/lib/commonjs/theme/create-styles.js.map +1 -1
  58. package/lib/module/components/Anchor/index.js +5 -5
  59. package/lib/module/components/Anchor/index.js.map +1 -1
  60. package/lib/module/components/Avatar/index.js +3 -3
  61. package/lib/module/components/Avatar/index.js.map +1 -1
  62. package/lib/module/components/BackgroundImage/index.js +1 -1
  63. package/lib/module/components/BackgroundImage/index.js.map +1 -1
  64. package/lib/module/components/Badge/index.js +5 -5
  65. package/lib/module/components/Badge/index.js.map +1 -1
  66. package/lib/module/components/Blockquote/index.js +2 -2
  67. package/lib/module/components/Blockquote/index.js.map +1 -1
  68. package/lib/module/components/Button/index.js +6 -6
  69. package/lib/module/components/Button/index.js.map +1 -1
  70. package/lib/module/components/Card/index.js +3 -3
  71. package/lib/module/components/Card/index.js.map +1 -1
  72. package/lib/module/components/Checkbox/index.js +3 -3
  73. package/lib/module/components/Checkbox/index.js.map +1 -1
  74. package/lib/module/components/Chip/index.js +6 -6
  75. package/lib/module/components/Chip/index.js.map +1 -1
  76. package/lib/module/components/CloseButton/index.js +3 -3
  77. package/lib/module/components/CloseButton/index.js.map +1 -1
  78. package/lib/module/components/ColorSwatch/index.js +4 -4
  79. package/lib/module/components/ColorSwatch/index.js.map +1 -1
  80. package/lib/module/components/Dialog/index.js +1 -1
  81. package/lib/module/components/Dialog/index.js.map +1 -1
  82. package/lib/module/components/Divider/index.js +4 -4
  83. package/lib/module/components/Divider/index.js.map +1 -1
  84. package/lib/module/components/Grid/index.js +6 -6
  85. package/lib/module/components/Grid/index.js.map +1 -1
  86. package/lib/module/components/Image/index.js +2 -2
  87. package/lib/module/components/Image/index.js.map +1 -1
  88. package/lib/module/components/Indicator/index.js +8 -8
  89. package/lib/module/components/Indicator/index.js.map +1 -1
  90. package/lib/module/components/List/index.js +2 -2
  91. package/lib/module/components/List/index.js.map +1 -1
  92. package/lib/module/components/Menu/index.js +2 -2
  93. package/lib/module/components/Menu/index.js.map +1 -1
  94. package/lib/module/components/Overlay/index.js +5 -5
  95. package/lib/module/components/Overlay/index.js.map +1 -1
  96. package/lib/module/components/Paper/index.js +2 -2
  97. package/lib/module/components/Paper/index.js.map +1 -1
  98. package/lib/module/components/RingProgress/index.js +79 -56
  99. package/lib/module/components/RingProgress/index.js.map +1 -1
  100. package/lib/module/components/SimpleGrid/index.js +1 -1
  101. package/lib/module/components/SimpleGrid/index.js.map +1 -1
  102. package/lib/module/components/Stepper/index.js +1 -1
  103. package/lib/module/components/Stepper/index.js.map +1 -1
  104. package/lib/module/components/Table/index.js +257 -274
  105. package/lib/module/components/Table/index.js.map +1 -1
  106. package/lib/module/components/ThemeIcon/index.js +4 -4
  107. package/lib/module/components/ThemeIcon/index.js.map +1 -1
  108. package/lib/module/components/Timeline/index.js +1 -1
  109. package/lib/module/components/Timeline/index.js.map +1 -1
  110. package/lib/module/components/index.js +3 -1
  111. package/lib/module/components/index.js.map +1 -1
  112. package/lib/module/theme/create-styles.js +36 -0
  113. package/lib/module/theme/create-styles.js.map +1 -1
  114. package/lib/typescript/commonjs/src/components/Button/Button.styles.d.ts +35 -10
  115. package/lib/typescript/commonjs/src/components/Button/Button.styles.d.ts.map +1 -1
  116. package/lib/typescript/commonjs/src/components/RingProgress/index.d.ts.map +1 -1
  117. package/lib/typescript/commonjs/src/components/Table/index.d.ts +17 -83
  118. package/lib/typescript/commonjs/src/components/Table/index.d.ts.map +1 -1
  119. package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.styles.d.ts +14 -3
  120. package/lib/typescript/commonjs/src/components/UnstyledButton/UnstyledButton.styles.d.ts.map +1 -1
  121. package/lib/typescript/commonjs/src/components/index.d.ts +1 -1
  122. package/lib/typescript/commonjs/src/components/index.d.ts.map +1 -1
  123. package/lib/typescript/commonjs/src/theme/create-styles.d.ts +36 -2
  124. package/lib/typescript/commonjs/src/theme/create-styles.d.ts.map +1 -1
  125. package/lib/typescript/module/src/components/Button/Button.styles.d.ts +35 -10
  126. package/lib/typescript/module/src/components/Button/Button.styles.d.ts.map +1 -1
  127. package/lib/typescript/module/src/components/RingProgress/index.d.ts.map +1 -1
  128. package/lib/typescript/module/src/components/Table/index.d.ts +17 -83
  129. package/lib/typescript/module/src/components/Table/index.d.ts.map +1 -1
  130. package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.styles.d.ts +14 -3
  131. package/lib/typescript/module/src/components/UnstyledButton/UnstyledButton.styles.d.ts.map +1 -1
  132. package/lib/typescript/module/src/components/index.d.ts +1 -1
  133. package/lib/typescript/module/src/components/index.d.ts.map +1 -1
  134. package/lib/typescript/module/src/theme/create-styles.d.ts +36 -2
  135. package/lib/typescript/module/src/theme/create-styles.d.ts.map +1 -1
  136. package/package.json +1 -1
  137. package/src/components/Anchor/index.tsx +2 -2
  138. package/src/components/Avatar/index.tsx +1 -1
  139. package/src/components/BackgroundImage/index.tsx +1 -1
  140. package/src/components/Badge/index.tsx +2 -2
  141. package/src/components/Blockquote/index.tsx +1 -1
  142. package/src/components/Button/index.tsx +6 -6
  143. package/src/components/Card/index.tsx +3 -3
  144. package/src/components/Checkbox/index.tsx +1 -1
  145. package/src/components/Chip/index.tsx +2 -2
  146. package/src/components/CloseButton/index.tsx +1 -1
  147. package/src/components/ColorSwatch/index.tsx +1 -1
  148. package/src/components/Dialog/index.tsx +1 -1
  149. package/src/components/Divider/index.tsx +1 -1
  150. package/src/components/Grid/index.tsx +2 -2
  151. package/src/components/Image/index.tsx +1 -1
  152. package/src/components/Indicator/index.tsx +1 -1
  153. package/src/components/List/index.tsx +1 -1
  154. package/src/components/Menu/index.tsx +1 -1
  155. package/src/components/Overlay/index.tsx +1 -1
  156. package/src/components/Paper/index.tsx +1 -1
  157. package/src/components/RingProgress/index.tsx +89 -56
  158. package/src/components/SimpleGrid/index.tsx +1 -1
  159. package/src/components/Stepper/index.tsx +1 -1
  160. package/src/components/Table/index.tsx +333 -413
  161. package/src/components/ThemeIcon/index.tsx +1 -1
  162. package/src/components/Timeline/index.tsx +1 -1
  163. package/src/components/index.tsx +3 -1
  164. package/src/theme/create-styles.ts +44 -6
  165. package/lib/commonjs/components/Table/Table.example.js +0 -323
  166. package/lib/commonjs/components/Table/Table.example.js.map +0 -1
  167. package/lib/module/components/Table/Table.example.js +0 -318
  168. package/lib/module/components/Table/Table.example.js.map +0 -1
  169. package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts +0 -13
  170. package/lib/typescript/commonjs/src/components/Table/Table.example.d.ts.map +0 -1
  171. package/lib/typescript/module/src/components/Table/Table.example.d.ts +0 -13
  172. package/lib/typescript/module/src/components/Table/Table.example.d.ts.map +0 -1
  173. 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 TableContext = /*#__PURE__*/(0, _react.createContext)(null);
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
- isHeader,
95
- width
22
+ striped
96
23
  }) => {
97
- const getVerticalPadding = () => {
98
- if (typeof verticalSpacing === 'number') return (0, _rem.rem)(verticalSpacing);
99
- return theme.spacing[verticalSpacing] || theme.spacing.xs;
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 getHorizontalPadding = () => {
102
- if (typeof horizontalSpacing === 'number') return (0, _rem.rem)(horizontalSpacing);
103
- return theme.spacing[horizontalSpacing] || theme.spacing.xs;
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
- cell: {
107
- // Remove flex: 1 to prevent equal spacing
108
- // Use explicit width when available for column alignment
109
- ...(width && {
110
- width
111
- }),
112
- paddingVertical: getVerticalPadding(),
113
- paddingHorizontal: getHorizontalPadding(),
114
- fontSize: fontSizes[fontSize],
115
- color: theme.colorScheme === 'dark' ? theme.white : theme.black,
116
- textAlign: 'left',
117
- ...(withColumnBorders && {
118
- borderRightWidth: 1,
119
- borderRightColor: theme.colorScheme === 'dark' ? theme.colors.dark?.[4] : theme.colors.gray?.[3]
120
- }),
121
- ...(isHeader && {
122
- fontWeight: '600'
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
- captionSide: 'top'
128
+ horizontallyScrollable: false
136
129
  };
137
- const Table = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
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
- } = (0, _themeProvider.useComponentDefaultProps)('Table', defaultProps, props);
148
+ } = props;
156
149
  const {
157
150
  styles,
158
151
  sx
159
- } = useTableStyles({
160
- withBorder,
161
- captionSide,
162
- flex,
163
- flexGrow,
164
- flexShrink,
165
- flexBasis
166
- }, {
167
- name: 'Table'
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
- const Thead = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
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
- } = useTableHeadStyles({}, {
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
- const Tbody = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
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 childrenArray = _react.default.Children.toArray(children);
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: childrenArray.map((child, index) => {
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
- const Tfoot = /*#__PURE__*/(0, _react.forwardRef)((props, ref) => {
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
- } = useTableRowStyles({
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: childrenWithColumnIndex
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
- withTextWrapper: shouldWrapInText = true,
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
- } = useTableCellStyles({
311
- fontSize: context?.fontSize ?? 'sm',
312
- verticalSpacing: context?.verticalSpacing ?? 'xs',
313
- horizontalSpacing: context?.horizontalSpacing ?? 'xs',
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(styles.cell, style),
331
- onLayout: handleLayout,
276
+ style: sx(...cellStyle),
332
277
  ...others,
333
- children: (0, _withTextWrapper.withTextWrapper)(children, shouldWrapInText, styles.cell)
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
- withTextWrapper: shouldWrapInText = true,
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
- } = useTableCellStyles({
351
- fontSize: context?.fontSize ?? 'sm',
352
- verticalSpacing: context?.verticalSpacing ?? 'xs',
353
- horizontalSpacing: context?.horizontalSpacing ?? 'xs',
354
- withColumnBorders: context?.withColumnBorders ?? false,
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(styles.cell, style),
371
- onLayout: handleLayout,
304
+ style: sx(...cellStyle),
372
305
  ...others,
373
- children: (0, _withTextWrapper.withTextWrapper)(children, shouldWrapInText, styles.cell)
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
- // Attach sub-components with proper typing
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
- const TableWithSubComponents = exports.Table = Table;
387
- TableWithSubComponents.Thead = Thead;
388
- TableWithSubComponents.Tbody = Tbody;
389
- TableWithSubComponents.Tfoot = Tfoot;
390
- TableWithSubComponents.Tr = Tr;
391
- TableWithSubComponents.Th = Th;
392
- TableWithSubComponents.Td = Td;
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