jp-composter 0.1.0

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 (194) hide show
  1. package/dist/index.d.mts +997 -0
  2. package/dist/index.d.ts +997 -0
  3. package/dist/index.js +36837 -0
  4. package/dist/index.js.map +1 -0
  5. package/dist/index.mjs +36778 -0
  6. package/dist/index.mjs.map +1 -0
  7. package/package.json +66 -0
  8. package/src/SliceUI/IconMoon.tsx +33 -0
  9. package/src/SliceUI/assets/Anatomy diagram copy.svg +19 -0
  10. package/src/SliceUI/assets/Anatomy diagram.svg +19 -0
  11. package/src/SliceUI/assets/Anatomycheck.svg +15 -0
  12. package/src/SliceUI/assets/Anatomyinput.svg +32 -0
  13. package/src/SliceUI/assets/Checkbox.jpg +0 -0
  14. package/src/SliceUI/assets/Diagram copy.svg +15 -0
  15. package/src/SliceUI/assets/Diagram.jpg +0 -0
  16. package/src/SliceUI/assets/Diagram.svg +15 -0
  17. package/src/SliceUI/assets/Frame 5 copy.png +0 -0
  18. package/src/SliceUI/assets/Frame 5.png +0 -0
  19. package/src/SliceUI/assets/Frame 65.png +0 -0
  20. package/src/SliceUI/assets/Frame_65.png +0 -0
  21. package/src/SliceUI/assets/Icon copy.svg +3 -0
  22. package/src/SliceUI/assets/Icon.svg +3 -0
  23. package/src/SliceUI/assets/Icon_Bridging copy.svg +39 -0
  24. package/src/SliceUI/assets/Icon_Bridging.svg +39 -0
  25. package/src/SliceUI/assets/Icon_Consistent copy.svg +39 -0
  26. package/src/SliceUI/assets/Icon_Consistent.svg +39 -0
  27. package/src/SliceUI/assets/Icon_Plug copy.svg +38 -0
  28. package/src/SliceUI/assets/Icon_Plug.svg +38 -0
  29. package/src/SliceUI/assets/Icon_Reusable copy.svg +39 -0
  30. package/src/SliceUI/assets/Icon_Reusable.svg +39 -0
  31. package/src/SliceUI/assets/Layer_1.png +0 -0
  32. package/src/SliceUI/assets/accessibility.png +0 -0
  33. package/src/SliceUI/assets/accessibility.svg +1 -0
  34. package/src/SliceUI/assets/addon-library.png +0 -0
  35. package/src/SliceUI/assets/assets.png +0 -0
  36. package/src/SliceUI/assets/avif-test-image.avif +0 -0
  37. package/src/SliceUI/assets/bridging.svg +13 -0
  38. package/src/SliceUI/assets/consistent.svg +11 -0
  39. package/src/SliceUI/assets/context.png +0 -0
  40. package/src/SliceUI/assets/discord.svg +1 -0
  41. package/src/SliceUI/assets/docs.png +0 -0
  42. package/src/SliceUI/assets/figma-plugin.png +0 -0
  43. package/src/SliceUI/assets/github.svg +1 -0
  44. package/src/SliceUI/assets/resources/Anatomy diagram.svg +19 -0
  45. package/src/SliceUI/assets/resources/Anatomycheck.svg +15 -0
  46. package/src/SliceUI/assets/resources/Anatomyinput.svg +32 -0
  47. package/src/SliceUI/assets/resources/Diagram.svg +15 -0
  48. package/src/SliceUI/assets/resources/Frame 5.png +0 -0
  49. package/src/SliceUI/assets/resources/Frame 65.png +0 -0
  50. package/src/SliceUI/assets/resources/Icon.svg +3 -0
  51. package/src/SliceUI/assets/resources/Icon_Bridging.svg +39 -0
  52. package/src/SliceUI/assets/resources/Icon_Consistent.svg +39 -0
  53. package/src/SliceUI/assets/resources/Icon_Plug.svg +38 -0
  54. package/src/SliceUI/assets/resources/Icon_Reusable.svg +39 -0
  55. package/src/SliceUI/assets/resources/fonts/FontIcon.json +150 -0
  56. package/src/SliceUI/assets/resources/fonts/Lato-Black.ttf +0 -0
  57. package/src/SliceUI/assets/resources/fonts/Lato-Bold.ttf +0 -0
  58. package/src/SliceUI/assets/resources/fonts/Lato-Heavy.ttf +0 -0
  59. package/src/SliceUI/assets/resources/fonts/Lato-Medium.ttf +0 -0
  60. package/src/SliceUI/assets/resources/fonts/Lato-Regular.ttf +0 -0
  61. package/src/SliceUI/assets/resources/fonts/Lato.woff2 +0 -0
  62. package/src/SliceUI/assets/resources/fonts/icomoon.eot +0 -0
  63. package/src/SliceUI/assets/resources/fonts/icomoon.svg +601 -0
  64. package/src/SliceUI/assets/resources/fonts/icomoon.ttf +0 -0
  65. package/src/SliceUI/assets/resources/fonts/icomoon.woff +0 -0
  66. package/src/SliceUI/assets/resources/fonts/selection.json +1 -0
  67. package/src/SliceUI/assets/share.png +0 -0
  68. package/src/SliceUI/assets/styling.png +0 -0
  69. package/src/SliceUI/assets/testing.png +0 -0
  70. package/src/SliceUI/assets/theming.png +0 -0
  71. package/src/SliceUI/assets/tutorials.svg +1 -0
  72. package/src/SliceUI/assets/youtube.svg +1 -0
  73. package/src/SliceUI/automation/helper.ts +29 -0
  74. package/src/SliceUI/avatar/Avatar.tsx +237 -0
  75. package/src/SliceUI/avatar/Token.ts +116 -0
  76. package/src/SliceUI/avatar/Type.ts +36 -0
  77. package/src/SliceUI/avatar/helper.ts +53 -0
  78. package/src/SliceUI/badge/Badge.tsx +308 -0
  79. package/src/SliceUI/badge/Token.ts +202 -0
  80. package/src/SliceUI/badge/Type.ts +46 -0
  81. package/src/SliceUI/badge/helper.ts +39 -0
  82. package/src/SliceUI/button/Button.tsx +243 -0
  83. package/src/SliceUI/button/Token.ts +138 -0
  84. package/src/SliceUI/button/Type.ts +34 -0
  85. package/src/SliceUI/button/helper.ts +125 -0
  86. package/src/SliceUI/checkbox/Checkbox.tsx +176 -0
  87. package/src/SliceUI/checkbox/Token.ts +128 -0
  88. package/src/SliceUI/checkbox/Type.ts +35 -0
  89. package/src/SliceUI/chip/Chip.tsx +290 -0
  90. package/src/SliceUI/chip/Token.ts +151 -0
  91. package/src/SliceUI/chip/Type.ts +43 -0
  92. package/src/SliceUI/chip/helper.ts +40 -0
  93. package/src/SliceUI/colors/Pallete.ts +151 -0
  94. package/src/SliceUI/colors/Token.ts +110 -0
  95. package/src/SliceUI/colors/Type.ts +56 -0
  96. package/src/SliceUI/contextProvider/context.tsx +108 -0
  97. package/src/SliceUI/divider/Divider.tsx +109 -0
  98. package/src/SliceUI/divider/Token.ts +18 -0
  99. package/src/SliceUI/divider/Type.ts +26 -0
  100. package/src/SliceUI/icon/CustomIcon.ts +4 -0
  101. package/src/SliceUI/icon/IcoMoonIcon.tsx +11 -0
  102. package/src/SliceUI/icon/Icon.tsx +38 -0
  103. package/src/SliceUI/icon/Token.ts +14 -0
  104. package/src/SliceUI/icon/Type.ts +13 -0
  105. package/src/SliceUI/icon/selection.json +1 -0
  106. package/src/SliceUI/input/Input.tsx +573 -0
  107. package/src/SliceUI/input/ToDo.md +99 -0
  108. package/src/SliceUI/input/Token.ts +372 -0
  109. package/src/SliceUI/input/Type.ts +109 -0
  110. package/src/SliceUI/input/components/InputPortal.tsx +211 -0
  111. package/src/SliceUI/input/components/NativeBottomSheet.tsx +296 -0
  112. package/src/SliceUI/input/components/SelectChip.tsx +185 -0
  113. package/src/SliceUI/input/components/SelectList.tsx +173 -0
  114. package/src/SliceUI/input/components/SelectListItem.tsx +377 -0
  115. package/src/SliceUI/input/components/SelectScrollbarStyle.ts +44 -0
  116. package/src/SliceUI/input/hooks/useCustomScrollbar.ts +17 -0
  117. package/src/SliceUI/input/hooks/useInputState.ts +41 -0
  118. package/src/SliceUI/input/hooks/useLabelAnimation.ts +132 -0
  119. package/src/SliceUI/input/hooks/useOutsideClick.ts +38 -0
  120. package/src/SliceUI/input/hooks/useSelectLogic.ts +338 -0
  121. package/src/SliceUI/input/utils/inputUtils.ts +120 -0
  122. package/src/SliceUI/input/utils/selectUtils.ts +85 -0
  123. package/src/SliceUI/input/utils/styleUtils.ts +50 -0
  124. package/src/SliceUI/input/variants/CurrencyInput/CurrencyInput.tsx +16 -0
  125. package/src/SliceUI/input/variants/CurrencyInput/NativeCurrencyInput.tsx +181 -0
  126. package/src/SliceUI/input/variants/CurrencyInput/WebCurrencyInput.tsx +163 -0
  127. package/src/SliceUI/input/variants/CurrencyInput/types.ts +17 -0
  128. package/src/SliceUI/input/variants/PhoneInput/NativePhoneInput.tsx +189 -0
  129. package/src/SliceUI/input/variants/PhoneInput/PhoneInput.tsx +16 -0
  130. package/src/SliceUI/input/variants/PhoneInput/WebPhoneInput.tsx +291 -0
  131. package/src/SliceUI/input/variants/PhoneInput/types.ts +22 -0
  132. package/src/SliceUI/input/variants/SelectInput/SelectInput.tsx +407 -0
  133. package/src/SliceUI/input/variants/SelectInput/types.ts +34 -0
  134. package/src/SliceUI/input/variants/TextInput.tsx +68 -0
  135. package/src/SliceUI/layout/Box.tsx +38 -0
  136. package/src/SliceUI/layout/Center.tsx +38 -0
  137. package/src/SliceUI/layout/Divider.tsx +37 -0
  138. package/src/SliceUI/layout/Grid.tsx +75 -0
  139. package/src/SliceUI/layout/PageContainer.tsx +60 -0
  140. package/src/SliceUI/layout/ScrollContainer.tsx +72 -0
  141. package/src/SliceUI/layout/Spacer.tsx +54 -0
  142. package/src/SliceUI/layout/Stack.tsx +97 -0
  143. package/src/SliceUI/layout/StickyHeader.tsx +71 -0
  144. package/src/SliceUI/radio/RadioButton.tsx +130 -0
  145. package/src/SliceUI/radio/Token.ts +197 -0
  146. package/src/SliceUI/radio/Type.ts +35 -0
  147. package/src/SliceUI/react-native.config.js +3 -0
  148. package/src/SliceUI/responsive/Type.ts +7 -0
  149. package/src/SliceUI/responsive/helper.ts +53 -0
  150. package/src/SliceUI/switch/Switch.tsx +119 -0
  151. package/src/SliceUI/switch/Token.ts +205 -0
  152. package/src/SliceUI/switch/Type.ts +26 -0
  153. package/src/SliceUI/tab/TabItem.tsx +204 -0
  154. package/src/SliceUI/tab/Tabs.tsx +110 -0
  155. package/src/SliceUI/tab/Token.ts +282 -0
  156. package/src/SliceUI/tab/Type.ts +66 -0
  157. package/src/SliceUI/tab/helper.ts +53 -0
  158. package/src/SliceUI/table/Table.tsx +388 -0
  159. package/src/SliceUI/table/TableCell.tsx +158 -0
  160. package/src/SliceUI/table/TableFooter.tsx +353 -0
  161. package/src/SliceUI/table/TableHeader.tsx +247 -0
  162. package/src/SliceUI/table/TableRow.tsx +218 -0
  163. package/src/SliceUI/table/Token.ts +252 -0
  164. package/src/SliceUI/table/Type.ts +213 -0
  165. package/src/SliceUI/table/helper.ts +376 -0
  166. package/src/SliceUI/table/index.ts +53 -0
  167. package/src/SliceUI/theme/dummyColors.tsx +7 -0
  168. package/src/SliceUI/theme/theme.ts +107 -0
  169. package/src/SliceUI/typography/BaseTypographyToken.ts +62 -0
  170. package/src/SliceUI/typography/FoundationToken.ts +48 -0
  171. package/src/SliceUI/typography/Token.ts +228 -0
  172. package/src/SliceUI/typography/Type.ts +20 -0
  173. package/src/SliceUI/typography/Typography.tsx +99 -0
  174. package/src/SliceUI/values/BorderRadius.ts +17 -0
  175. package/src/SliceUI/values/BorderWidth.ts +7 -0
  176. package/src/SliceUI/values/Dimension.ts +35 -0
  177. package/src/SliceUI/values/IconSizes.ts +13 -0
  178. package/src/SliceUI/values/Spacing.ts +22 -0
  179. package/src/declarations.d.ts +8 -0
  180. package/src/index.tsx +119 -0
  181. package/src/stories/Colors.mdx +1418 -0
  182. package/src/stories/Dimensions.mdx +60 -0
  183. package/src/stories/GetStarted.mdx +90 -0
  184. package/src/stories/Introduction.mdx +136 -0
  185. package/src/stories/Shape.mdx +126 -0
  186. package/src/stories/Spacing.mdx +104 -0
  187. package/src/stories/Typography.mdx +454 -0
  188. package/src/stories/Utils.mdx +277 -0
  189. package/src/stories/story-components/AddIcon.js +13 -0
  190. package/src/stories/story-components/RectangleWithBox.jsx +51 -0
  191. package/src/stories/story-components/RoundedRectangle.jsx +18 -0
  192. package/src/stories/story-components/RoundedWithWhiteInside.jsx +33 -0
  193. package/src/stories/story-components/WhiteRoundedRectangle.jsx +107 -0
  194. package/src/stories/story-components/svgPaths.js +126 -0
@@ -0,0 +1,218 @@
1
+ import React, {useMemo, useState} from 'react';
2
+ import {
3
+ View,
4
+ StyleSheet,
5
+ Pressable,
6
+ Platform,
7
+ type ViewStyle,
8
+ } from 'react-native';
9
+ import {useSliceTheme} from '../contextProvider/context';
10
+ import {setTestId} from '../automation/helper';
11
+ import {
12
+ getTableBackgroundColor,
13
+ getTableBorderColor,
14
+ getRowKey,
15
+ } from './helper';
16
+ import type {TableRowProps} from './Type';
17
+ import type {ExtendedTheme} from '../colors/Type';
18
+ import TableCell from './TableCell';
19
+ import Checkbox from '../checkbox/Checkbox';
20
+ import Typography from '../typography/Typography';
21
+
22
+ const isWeb = Platform.OS === 'web';
23
+
24
+ const TableRow: React.FC<TableRowProps> = ({
25
+ record,
26
+ index,
27
+ columns,
28
+ selection,
29
+ selected = false,
30
+ onSelect,
31
+ onRow,
32
+ style,
33
+ hover = true,
34
+ striped = false,
35
+ }) => {
36
+ const {theme} = useSliceTheme();
37
+ const {isDebugBuildType, automationBaseid} = theme;
38
+ const [isHovered, setIsHovered] = useState(false);
39
+
40
+ const rowStyle = useMemo((): ViewStyle => {
41
+ let backgroundColor = theme.colors?.colorBackgroundPrimary || '#ffffff';
42
+
43
+ if (selected) {
44
+ backgroundColor = theme.colors?.colorBackgroundAccentAlpha || '#e3f2fd';
45
+ } else if (isHovered && hover) {
46
+ backgroundColor = theme.colors?.colorBackgroundLight || '#f9f9f9';
47
+ } else if (striped && index % 2 === 1) {
48
+ backgroundColor = theme.colors?.colorBackgroundLight || '#f9f9f9';
49
+ }
50
+
51
+ const borderColor = theme.colors?.colorBorderSubtle || '#e0e0e0';
52
+
53
+ return {
54
+ flexDirection: 'row',
55
+ alignItems: 'center',
56
+ backgroundColor,
57
+ borderBottomWidth: 1,
58
+ borderBottomColor: borderColor,
59
+ minHeight: 60,
60
+ paddingHorizontal: 16,
61
+ paddingVertical: 16,
62
+ };
63
+ }, [theme, selected, isHovered, hover, striped, index]);
64
+
65
+ const handleRowPress = () => {
66
+ const rowHandlers = onRow?.(record, index);
67
+ rowHandlers?.onClick?.();
68
+ };
69
+
70
+ const handleRowDoublePress = () => {
71
+ const rowHandlers = onRow?.(record, index);
72
+ rowHandlers?.onDoubleClick?.();
73
+ };
74
+
75
+ const handleSelect = () => {
76
+ if (onSelect) {
77
+ onSelect(!selected);
78
+ }
79
+ };
80
+
81
+ const renderSelectionColumn = () => {
82
+ if (!selection) return null;
83
+
84
+ const checkboxProps = selection.getCheckboxProps?.(record) || {};
85
+
86
+ return (
87
+ <View style={[styles.selectionCell, {width: 48, minWidth: 48}]}>
88
+ <Checkbox
89
+ checked={selected}
90
+ onChange={handleSelect}
91
+ size="medium"
92
+ disabled={checkboxProps.disabled}
93
+ style={styles.checkbox}
94
+ />
95
+ </View>
96
+ );
97
+ };
98
+
99
+ const renderDataCell = (column: any, cellIndex: number) => {
100
+ const value = column.dataIndex
101
+ ? record[column.dataIndex]
102
+ : record[column.key];
103
+ const cellStyle = column.onCell?.(record, index);
104
+
105
+ let cellContent = value;
106
+ if (column.render) {
107
+ cellContent = column.render(value, record, index);
108
+ }
109
+
110
+ const alignStyle = {
111
+ justifyContent:
112
+ column.align === 'center'
113
+ ? 'center'
114
+ : column.align === 'right'
115
+ ? 'flex-end'
116
+ : 'flex-start',
117
+ };
118
+
119
+ return (
120
+ <View
121
+ key={column.key}
122
+ style={[
123
+ styles.dataCell,
124
+ {
125
+ width: column.width || 'auto',
126
+ minWidth: column.minWidth || 100,
127
+ flex: column.width ? 0 : 1,
128
+ },
129
+ alignStyle,
130
+ cellStyle,
131
+ ]}>
132
+ {typeof cellContent === 'string' || typeof cellContent === 'number' ? (
133
+ <Typography
134
+ variant="body2"
135
+ style={{textAlign: column.align || 'left', flex: 1}}>
136
+ {String(cellContent)}
137
+ </Typography>
138
+ ) : (
139
+ <View style={{flex: 1}}>{cellContent}</View>
140
+ )}
141
+ </View>
142
+ );
143
+ };
144
+
145
+ const combinedRowStyle = useMemo(
146
+ () => StyleSheet.flatten([rowStyle, style]),
147
+ [rowStyle, style],
148
+ );
149
+
150
+ const rowHandlers = onRow?.(record, index);
151
+ const hasRowHandlers =
152
+ rowHandlers && (rowHandlers.onClick || rowHandlers.onDoubleClick);
153
+
154
+ if (hasRowHandlers) {
155
+ return (
156
+ <Pressable
157
+ onPress={handleRowPress}
158
+ onLongPress={handleRowDoublePress}
159
+ style={({pressed}) => [combinedRowStyle, pressed && styles.pressedRow]}
160
+ {...(isWeb && {
161
+ onMouseEnter: () => {
162
+ setIsHovered(true);
163
+ rowHandlers?.onMouseEnter?.();
164
+ },
165
+ onMouseLeave: () => {
166
+ setIsHovered(false);
167
+ rowHandlers?.onMouseLeave?.();
168
+ },
169
+ })}
170
+ {...(isDebugBuildType && automationBaseid
171
+ ? setTestId(automationBaseid, 'table', `row-${index}`)
172
+ : {})}>
173
+ {renderSelectionColumn()}
174
+ {columns.map(renderDataCell)}
175
+ </Pressable>
176
+ );
177
+ }
178
+
179
+ return (
180
+ <View
181
+ style={combinedRowStyle}
182
+ {...(isWeb && {
183
+ onMouseEnter: () => setIsHovered(true),
184
+ onMouseLeave: () => setIsHovered(false),
185
+ })}
186
+ {...(isDebugBuildType && automationBaseid
187
+ ? setTestId(automationBaseid, 'table', `row-${index}`)
188
+ : {})}>
189
+ {renderSelectionColumn()}
190
+ {columns.map(renderDataCell)}
191
+ </View>
192
+ );
193
+ };
194
+
195
+ const styles = StyleSheet.create({
196
+ selectionCell: {
197
+ justifyContent: 'center',
198
+ alignItems: 'center',
199
+ paddingHorizontal: 8,
200
+ },
201
+ checkbox: {
202
+ margin: 0,
203
+ },
204
+ dataCell: {
205
+ paddingHorizontal: 8,
206
+ paddingVertical: 0,
207
+ flexDirection: 'row',
208
+ alignItems: 'center',
209
+ overflow: 'hidden',
210
+ minHeight: 60,
211
+ justifyContent: 'flex-start',
212
+ },
213
+ pressedRow: {
214
+ opacity: 0.7,
215
+ },
216
+ });
217
+
218
+ export default React.memo(TableRow);
@@ -0,0 +1,252 @@
1
+ import {spacing} from '../values/Spacing';
2
+ import {borderRadius} from '../values/BorderRadius';
3
+ import type {TableThemeSize, TableSize, TableVariant} from './Type';
4
+ import {TYPOGRAPHY_STYLES} from '../typography/Token';
5
+ import type {ViewStyle, TextStyle} from 'react-native';
6
+
7
+ // Base table styles
8
+ const baseTableStyles = {
9
+ container: {
10
+ borderRadius: borderRadius.borderRadius40,
11
+ overflow: 'hidden' as const,
12
+ },
13
+ header: {
14
+ flexDirection: 'row' as const,
15
+ alignItems: 'center' as const,
16
+ borderBottomWidth: 1,
17
+ },
18
+ headerCell: {
19
+ flex: 1,
20
+ flexDirection: 'row' as const,
21
+ alignItems: 'center' as const,
22
+ justifyContent: 'space-between' as const,
23
+ },
24
+ headerText: {
25
+ fontWeight: '600' as const,
26
+ },
27
+ body: {
28
+ flex: 1,
29
+ },
30
+ row: {
31
+ flexDirection: 'row' as const,
32
+ alignItems: 'center' as const,
33
+ borderBottomWidth: 1,
34
+ },
35
+ cell: {
36
+ flex: 1,
37
+ flexDirection: 'row' as const,
38
+ alignItems: 'center' as const,
39
+ },
40
+ cellText: {
41
+ flex: 1,
42
+ },
43
+ footer: {
44
+ flexDirection: 'row' as const,
45
+ alignItems: 'center' as const,
46
+ justifyContent: 'space-between' as const,
47
+ borderTopWidth: 1,
48
+ },
49
+ sortIcon: {
50
+ marginLeft: spacing.space50,
51
+ },
52
+ checkbox: {
53
+ marginRight: spacing.space100,
54
+ },
55
+ loading: {
56
+ position: 'absolute' as const,
57
+ top: 0,
58
+ left: 0,
59
+ right: 0,
60
+ bottom: 0,
61
+ alignItems: 'center' as const,
62
+ justifyContent: 'center' as const,
63
+ backgroundColor: 'rgba(255, 255, 255, 0.8)',
64
+ },
65
+ empty: {
66
+ alignItems: 'center' as const,
67
+ justifyContent: 'center' as const,
68
+ minHeight: 200,
69
+ },
70
+ emptyText: {
71
+ textAlign: 'center' as const,
72
+ opacity: 0.6,
73
+ },
74
+ } as const;
75
+
76
+ // Size-specific padding and dimensions
77
+ const sizePaddings = {
78
+ small: {
79
+ paddingVertical: spacing.space100,
80
+ paddingHorizontal: spacing.space150,
81
+ minHeight: 32,
82
+ },
83
+ medium: {
84
+ paddingVertical: spacing.space150,
85
+ paddingHorizontal: spacing.space200,
86
+ minHeight: 40,
87
+ },
88
+ large: {
89
+ paddingVertical: spacing.space200,
90
+ paddingHorizontal: spacing.space250,
91
+ minHeight: 48,
92
+ },
93
+ } as const;
94
+
95
+ // Typography variants for different sizes
96
+ const sizeTypography = {
97
+ small: {
98
+ headerText: TYPOGRAPHY_STYLES.captionBold,
99
+ cellText: TYPOGRAPHY_STYLES.caption,
100
+ emptyText: TYPOGRAPHY_STYLES.body2,
101
+ },
102
+ medium: {
103
+ headerText: TYPOGRAPHY_STYLES.body2Bold,
104
+ cellText: TYPOGRAPHY_STYLES.body2,
105
+ emptyText: TYPOGRAPHY_STYLES.body1,
106
+ },
107
+ large: {
108
+ headerText: TYPOGRAPHY_STYLES.body1Bold,
109
+ cellText: TYPOGRAPHY_STYLES.body1,
110
+ emptyText: TYPOGRAPHY_STYLES.heading6,
111
+ },
112
+ } as const;
113
+
114
+ // Helper function to create styles for a given size and variant
115
+ const createTableTheme = (size: TableSize, variant: TableVariant) => {
116
+ const sizePadding = sizePaddings[size];
117
+ const typography = sizeTypography[size];
118
+
119
+ const baseTheme = {
120
+ container: {
121
+ ...baseTableStyles.container,
122
+ ...(variant === 'bordered' && {
123
+ borderWidth: 1,
124
+ }),
125
+ },
126
+ header: {
127
+ ...baseTableStyles.header,
128
+ ...sizePadding,
129
+ },
130
+ headerCell: {
131
+ ...baseTableStyles.headerCell,
132
+ },
133
+ headerText: {
134
+ ...baseTableStyles.headerText,
135
+ ...typography.headerText,
136
+ } as TextStyle,
137
+ body: {
138
+ ...baseTableStyles.body,
139
+ },
140
+ row: {
141
+ ...baseTableStyles.row,
142
+ ...sizePadding,
143
+ ...(variant === 'striped' && {
144
+ '&:nth-child(even)': {
145
+ backgroundColor: 'rgba(0, 0, 0, 0.02)',
146
+ },
147
+ }),
148
+ },
149
+ cell: {
150
+ ...baseTableStyles.cell,
151
+ },
152
+ cellText: {
153
+ ...baseTableStyles.cellText,
154
+ ...typography.cellText,
155
+ } as TextStyle,
156
+ footer: {
157
+ ...baseTableStyles.footer,
158
+ ...sizePadding,
159
+ },
160
+ sortIcon: {
161
+ ...baseTableStyles.sortIcon,
162
+ },
163
+ checkbox: {
164
+ ...baseTableStyles.checkbox,
165
+ },
166
+ loading: {
167
+ ...baseTableStyles.loading,
168
+ },
169
+ empty: {
170
+ ...baseTableStyles.empty,
171
+ },
172
+ emptyText: {
173
+ ...baseTableStyles.emptyText,
174
+ ...typography.emptyText,
175
+ } as TextStyle,
176
+ };
177
+
178
+ return baseTheme;
179
+ };
180
+
181
+ // Generate all size and variant combinations
182
+ const createAllTableStyles = (): TableThemeSize => {
183
+ const sizes: TableSize[] = ['small', 'medium', 'large'];
184
+ const variants: TableVariant[] = ['default', 'bordered', 'striped'];
185
+
186
+ const result = {} as TableThemeSize;
187
+
188
+ sizes.forEach(size => {
189
+ result[size] = {} as any;
190
+ variants.forEach(variant => {
191
+ result[size][variant] = createTableTheme(size, variant);
192
+ });
193
+ });
194
+
195
+ return result;
196
+ };
197
+
198
+ export const TABLE_STYLES: TableThemeSize = createAllTableStyles();
199
+
200
+ // Export individual style tokens for customization
201
+ export const TABLE_SPACING = {
202
+ cellPadding: {
203
+ small: sizePaddings.small,
204
+ medium: sizePaddings.medium,
205
+ large: sizePaddings.large,
206
+ },
207
+ borderRadius: borderRadius.borderRadius40,
208
+ borderWidth: 1,
209
+ } as const;
210
+
211
+ export const TABLE_TYPOGRAPHY = sizeTypography;
212
+
213
+ // Color tokens will be handled by the theme system
214
+ export const TABLE_COLOR_TOKENS = {
215
+ default: {
216
+ background: 'colorBackgroundPrimary',
217
+ headerBackground: 'colorBackgroundSecondary',
218
+ border: 'colorBorderSubtle',
219
+ text: 'colorForegroundPrimary',
220
+ headerText: 'colorForegroundPrimary',
221
+ hoverBackground: 'colorBackgroundLight',
222
+ selectedBackground: 'colorBackgroundAccentAlpha',
223
+ stripedBackground: 'colorBackgroundLight',
224
+ },
225
+ bordered: {
226
+ background: 'colorBackgroundPrimary',
227
+ headerBackground: 'colorBackgroundSecondary',
228
+ border: 'colorBorderMedium',
229
+ text: 'colorForegroundPrimary',
230
+ headerText: 'colorForegroundPrimary',
231
+ hoverBackground: 'colorBackgroundLight',
232
+ selectedBackground: 'colorBackgroundAccentAlpha',
233
+ stripedBackground: 'colorBackgroundLight',
234
+ },
235
+ striped: {
236
+ background: 'colorBackgroundPrimary',
237
+ headerBackground: 'colorBackgroundSecondary',
238
+ border: 'colorBorderSubtle',
239
+ text: 'colorForegroundPrimary',
240
+ headerText: 'colorForegroundPrimary',
241
+ hoverBackground: 'colorBackgroundLight',
242
+ selectedBackground: 'colorBackgroundAccentAlpha',
243
+ stripedBackground: 'colorBackgroundLight',
244
+ },
245
+ } as const;
246
+
247
+ // Animation tokens
248
+ export const TABLE_ANIMATIONS = {
249
+ sortTransition: 200,
250
+ hoverTransition: 150,
251
+ expandTransition: 300,
252
+ } as const;
@@ -0,0 +1,213 @@
1
+ import type {ViewStyle, TextStyle} from 'react-native';
2
+ import type {ReactNode} from 'react';
3
+
4
+ export type TableSize = 'small' | 'medium' | 'large';
5
+ export type TableVariant = 'default' | 'bordered' | 'striped';
6
+ export type ColumnAlign = 'left' | 'center' | 'right';
7
+ export type SortDirection = 'asc' | 'desc' | null;
8
+
9
+ export interface TableColumn<T = any> {
10
+ key: string;
11
+ title: string;
12
+ dataIndex?: keyof T;
13
+ sortable?: boolean;
14
+ align?: ColumnAlign;
15
+ width?: number | string;
16
+ minWidth?: number;
17
+ maxWidth?: number;
18
+ fixed?: 'left' | 'right';
19
+ render?: (value: any, record: T, index: number) => ReactNode;
20
+ headerRender?: () => ReactNode;
21
+ sorter?: boolean | ((a: T, b: T) => number);
22
+ onHeaderCell?: () => ViewStyle;
23
+ onCell?: (record: T, index: number) => ViewStyle;
24
+ }
25
+
26
+ export interface TableRowData {
27
+ key?: string | number;
28
+ [key: string]: any;
29
+ }
30
+
31
+ export interface TableSelection<T = any> {
32
+ selectedRowKeys?: (string | number)[];
33
+ onChange?: (selectedRowKeys: (string | number)[], selectedRows: T[]) => void;
34
+ onSelect?: (record: T, selected: boolean, selectedRows: T[], nativeEvent: any) => void;
35
+ onSelectAll?: (selected: boolean, selectedRows: T[], changeRows: T[]) => void;
36
+ getCheckboxProps?: (record: T) => {disabled?: boolean};
37
+ type?: 'checkbox' | 'radio';
38
+ fixed?: boolean;
39
+ columnWidth?: number | string;
40
+ columnTitle?: string | ReactNode;
41
+ hideSelectAll?: boolean;
42
+ }
43
+
44
+ export interface TablePagination {
45
+ current?: number;
46
+ pageSize?: number;
47
+ total?: number;
48
+ showSizeChanger?: boolean;
49
+ pageSizeOptions?: string[];
50
+ showQuickJumper?: boolean;
51
+ showTotal?: (total: number, range: [number, number]) => ReactNode;
52
+ onChange?: (page: number, pageSize?: number) => void;
53
+ onShowSizeChange?: (current: number, size: number) => void;
54
+ position?: 'topLeft' | 'topCenter' | 'topRight' | 'bottomLeft' | 'bottomCenter' | 'bottomRight';
55
+ size?: 'default' | 'small';
56
+ }
57
+
58
+ export interface TableProps<T = any> {
59
+ screenName?: string;
60
+ id?: string | number;
61
+ columns: TableColumn<T>[];
62
+ dataSource: T[];
63
+ size?: TableSize;
64
+ variant?: TableVariant;
65
+ loading?: boolean;
66
+ pagination?: false | TablePagination;
67
+ rowSelection?: TableSelection<T>;
68
+ scroll?: {
69
+ x?: number | string | true;
70
+ y?: number | string;
71
+ };
72
+ bordered?: boolean;
73
+ showHeader?: boolean;
74
+ title?: () => ReactNode;
75
+ footer?: () => ReactNode;
76
+ expandable?: {
77
+ expandedRowRender?: (record: T, index: number, indent: number, expanded: boolean) => ReactNode;
78
+ expandedRowKeys?: (string | number)[];
79
+ defaultExpandedRowKeys?: (string | number)[];
80
+ onExpand?: (expanded: boolean, record: T) => void;
81
+ onExpandedRowsChange?: (expandedKeys: (string | number)[]) => void;
82
+ };
83
+ rowKey?: string | ((record: T) => string | number);
84
+ onRow?: (record: T, index?: number) => {
85
+ onClick?: () => void;
86
+ onDoubleClick?: () => void;
87
+ onContextMenu?: () => void;
88
+ onMouseEnter?: () => void;
89
+ onMouseLeave?: () => void;
90
+ };
91
+ onHeaderRow?: (columns: TableColumn<T>[], index?: number) => {
92
+ onClick?: () => void;
93
+ onDoubleClick?: () => void;
94
+ onContextMenu?: () => void;
95
+ onMouseEnter?: () => void;
96
+ onMouseLeave?: () => void;
97
+ };
98
+ sortDirections?: SortDirection[];
99
+ defaultSortOrder?: SortDirection;
100
+ showSorterTooltip?: boolean;
101
+ tableStyle?: ViewStyle;
102
+ headerStyle?: ViewStyle;
103
+ bodyStyle?: ViewStyle;
104
+ footerStyle?: ViewStyle;
105
+ rowStyle?: ViewStyle;
106
+ cellStyle?: ViewStyle;
107
+ emptyText?: ReactNode;
108
+ locale?: {
109
+ emptyText?: string;
110
+ filterTitle?: string;
111
+ filterConfirm?: string;
112
+ filterReset?: string;
113
+ selectAll?: string;
114
+ selectInvert?: string;
115
+ selectionAll?: string;
116
+ sortTitle?: string;
117
+ expand?: string;
118
+ collapse?: string;
119
+ };
120
+ }
121
+
122
+ export interface TableCellProps {
123
+ children?: ReactNode;
124
+ align?: ColumnAlign;
125
+ style?: ViewStyle;
126
+ textStyle?: TextStyle;
127
+ width?: number | string;
128
+ minWidth?: number;
129
+ maxWidth?: number;
130
+ fixed?: 'left' | 'right';
131
+ ellipsis?: boolean;
132
+ onPress?: () => void;
133
+ }
134
+
135
+ export interface TableHeaderProps {
136
+ columns: TableColumn[];
137
+ selection?: TableSelection;
138
+ sortedInfo?: {
139
+ columnKey?: string;
140
+ order?: SortDirection;
141
+ };
142
+ onSort?: (columnKey: string, direction: SortDirection) => void;
143
+ onSelectAll?: (selected: boolean) => void;
144
+ allSelected?: boolean;
145
+ indeterminate?: boolean;
146
+ style?: ViewStyle;
147
+ }
148
+
149
+ export interface TableRowProps<T = any> {
150
+ record: T;
151
+ index: number;
152
+ columns: TableColumn<T>[];
153
+ selection?: TableSelection<T>;
154
+ selected?: boolean;
155
+ onSelect?: (selected: boolean) => void;
156
+ onRow?: (record: T, index?: number) => any;
157
+ style?: ViewStyle;
158
+ hover?: boolean;
159
+ striped?: boolean;
160
+ }
161
+
162
+ export interface TableFooterProps {
163
+ pagination?: TablePagination;
164
+ style?: ViewStyle;
165
+ }
166
+
167
+ // Theme-related types
168
+ export interface TableTheme {
169
+ container: ViewStyle;
170
+ header: ViewStyle;
171
+ headerCell: ViewStyle;
172
+ headerText: TextStyle;
173
+ body: ViewStyle;
174
+ row: ViewStyle;
175
+ cell: ViewStyle;
176
+ cellText: TextStyle;
177
+ footer: ViewStyle;
178
+ sortIcon: ViewStyle;
179
+ checkbox: ViewStyle;
180
+ loading: ViewStyle;
181
+ empty: ViewStyle;
182
+ emptyText: TextStyle;
183
+ }
184
+
185
+ export type TableThemeVariant = {
186
+ [key in TableVariant]: TableTheme;
187
+ };
188
+
189
+ export type TableThemeSize = {
190
+ [key in TableSize]: TableThemeVariant;
191
+ };
192
+
193
+ export interface TableSortState {
194
+ columnKey?: string;
195
+ order?: SortDirection;
196
+ }
197
+
198
+ export interface TableFilterState {
199
+ [key: string]: any;
200
+ }
201
+
202
+ export interface TableState<T = any> {
203
+ sortedInfo: TableSortState;
204
+ filteredInfo: TableFilterState;
205
+ selectedRowKeys: (string | number)[];
206
+ selectedRows: T[];
207
+ expandedRowKeys: (string | number)[];
208
+ pagination: {
209
+ current: number;
210
+ pageSize: number;
211
+ total: number;
212
+ };
213
+ }