@idealyst/components 1.2.143 → 1.2.144

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/components",
3
- "version": "1.2.143",
3
+ "version": "1.2.144",
4
4
  "description": "Shared component library for React and React Native",
5
5
  "documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
6
6
  "readme": "README.md",
@@ -56,7 +56,7 @@
56
56
  "publish:npm": "npm publish"
57
57
  },
58
58
  "peerDependencies": {
59
- "@idealyst/theme": "^1.2.143",
59
+ "@idealyst/theme": "^1.2.144",
60
60
  "@mdi/js": ">=7.0.0",
61
61
  "@mdi/react": ">=1.0.0",
62
62
  "@react-native-vector-icons/common": ">=12.0.0",
@@ -111,8 +111,8 @@
111
111
  },
112
112
  "devDependencies": {
113
113
  "@idealyst/blur": "^1.2.40",
114
- "@idealyst/theme": "^1.2.143",
115
- "@idealyst/tooling": "^1.2.143",
114
+ "@idealyst/theme": "^1.2.144",
115
+ "@idealyst/tooling": "^1.2.144",
116
116
  "@mdi/react": "^1.6.1",
117
117
  "@types/react": "^19.1.0",
118
118
  "react": "^19.1.0",
@@ -14,6 +14,7 @@ interface TRProps {
14
14
  type?: TableType;
15
15
  clickable?: boolean;
16
16
  dividers?: boolean;
17
+ even?: boolean;
17
18
  onPress?: () => void;
18
19
  testID?: string;
19
20
  }
@@ -44,6 +45,7 @@ function TR({
44
45
  type = 'standard',
45
46
  clickable = false,
46
47
  dividers = false,
48
+ even = false,
47
49
  onPress,
48
50
  testID,
49
51
  }: TRProps) {
@@ -52,6 +54,7 @@ function TR({
52
54
  type,
53
55
  clickable,
54
56
  dividers,
57
+ even,
55
58
  });
56
59
 
57
60
  const rowStyle = (tableStyles.row as any)({});
@@ -293,7 +296,8 @@ function TableInner<T = any>({
293
296
  size={size}
294
297
  type={type}
295
298
  clickable={isClickable}
296
- dividers={dividers}
299
+ dividers={dividers && rowIndex < data.length - 1}
300
+ even={rowIndex % 2 === 1}
297
301
  onPress={() => onRowPress?.(row, rowIndex)}
298
302
  testID={testID ? `${testID}-row-${rowIndex}` : undefined}
299
303
  >
@@ -12,7 +12,7 @@ void StyleSheet;
12
12
  // Wrap theme for $iterator support
13
13
  type Theme = ThemeStyleWrapper<BaseTheme>;
14
14
 
15
- type TableType = 'standard' | 'bordered' | 'striped';
15
+ type TableType = 'standard' | 'striped';
16
16
  type CellAlign = 'left' | 'center' | 'right';
17
17
 
18
18
  export type TableDynamicProps = {
@@ -20,6 +20,7 @@ export type TableDynamicProps = {
20
20
  type?: TableType;
21
21
  clickable?: boolean;
22
22
  dividers?: boolean;
23
+ even?: boolean;
23
24
  sticky?: boolean;
24
25
  align?: CellAlign;
25
26
  gap?: ViewStyleSize;
@@ -93,71 +94,72 @@ export const tableStyles = defineStyle('Table', (theme: Theme) => ({
93
94
  backgroundColor: theme.colors.surface.secondary,
94
95
  }),
95
96
 
96
- footerCell: ({ type = 'standard', align = 'left' }: TableDynamicProps) => {
97
- const alignStyles = {
98
- left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
99
- center: { textAlign: 'center' as const, justifyContent: 'center' as const },
100
- right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
101
- }[align];
102
-
103
- const borderStyles = type === 'bordered' ? {
104
- borderRightWidth: 1,
105
- borderRightColor: theme.colors.border.primary,
106
- } : {};
97
+ footerCell: (_props: TableDynamicProps) => ({
98
+ flexDirection: 'row' as const,
99
+ alignItems: 'center' as const,
100
+ fontWeight: '600' as const,
101
+ color: theme.colors.text.primary,
102
+ borderTopWidth: 1,
103
+ borderTopColor: theme.colors.border.primary,
104
+ variants: {
105
+ align: {
106
+ left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
107
+ center: { textAlign: 'center' as const, justifyContent: 'center' as const },
108
+ right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
109
+ },
110
+ size: {
111
+ padding: theme.sizes.$table.padding,
112
+ fontSize: theme.sizes.$table.headerFontSize,
113
+ lineHeight: theme.sizes.$table.headerLineHeight,
114
+ },
115
+ },
116
+ _web: {
117
+ borderTop: `1px solid ${theme.colors.border.primary}`,
118
+ },
119
+ }),
107
120
 
108
- return {
109
- flexDirection: 'row' as const,
110
- alignItems: 'center' as const,
111
- fontWeight: '600' as const,
112
- color: theme.colors.text.primary,
113
- borderTopWidth: 2,
114
- borderTopColor: theme.colors.border.primary,
115
- ...alignStyles,
116
- ...borderStyles,
117
- variants: {
118
- size: {
119
- padding: theme.sizes.$table.padding,
120
- fontSize: theme.sizes.$table.headerFontSize,
121
- lineHeight: theme.sizes.$table.headerLineHeight,
121
+ row: (_props: TableDynamicProps) => ({
122
+ variants: {
123
+ type: {
124
+ striped: {
125
+ _web: {
126
+ ':nth-child(even)': {
127
+ backgroundColor: theme.colors.surface.secondary,
128
+ },
129
+ },
122
130
  },
123
131
  },
124
- _web: {
125
- borderTop: `2px solid ${theme.colors.border.primary}`,
126
- borderRight: type === 'bordered' ? `1px solid ${theme.colors.border.primary}` : undefined,
127
- ':last-child': type === 'bordered' ? { borderRight: 'none' } : {},
132
+ clickable: {
133
+ true: { _web: { cursor: 'pointer' } },
128
134
  },
129
- } as const;
130
- },
131
-
132
- row: ({ type = 'standard', clickable = false, dividers = false }: TableDynamicProps) => {
133
- const showBorder = type === 'bordered' || type === 'striped' || dividers;
134
- const typeStyles = showBorder ? {
135
- borderBottomWidth: 1,
136
- borderBottomColor: theme.colors.border.primary,
137
- } : {};
138
-
139
- return {
140
- ...typeStyles,
141
- _web: {
142
- transition: 'background-color 0.15s ease',
143
- borderBottom: showBorder
144
- ? `1px solid ${theme.colors.border.primary}`
145
- : undefined,
146
- cursor: clickable ? 'pointer' : undefined,
147
- _hover: {
135
+ dividers: {
136
+ true: {
137
+ borderBottomWidth: 1,
138
+ borderBottomColor: theme.colors.border.primary,
139
+ _web: {
140
+ borderBottom: `1px solid ${theme.colors.border.primary}`,
141
+ },
142
+ },
143
+ },
144
+ },
145
+ compoundVariants: [
146
+ {
147
+ type: 'striped',
148
+ even: true,
149
+ styles: {
148
150
  backgroundColor: theme.colors.surface.secondary,
149
151
  },
150
- // Striped rows handled via CSS pseudo-selector
151
- ...(type === 'striped' ? {
152
- ':nth-child(even)': {
153
- backgroundColor: theme.colors.surface.secondary,
154
- },
155
- } : {}),
156
152
  },
157
- } as const;
158
- },
153
+ ],
154
+ _web: {
155
+ transition: 'background-color 0.15s ease',
156
+ _hover: {
157
+ backgroundColor: theme.colors.surface.hover,
158
+ },
159
+ },
160
+ }),
159
161
 
160
- headerCell: ({ type = 'standard', align: _align = 'left' }: TableDynamicProps) => ({
162
+ headerCell: (_props: TableDynamicProps) => ({
161
163
  flexDirection: 'row' as const,
162
164
  alignItems: 'center' as const,
163
165
  fontWeight: '600' as const,
@@ -165,9 +167,6 @@ export const tableStyles = defineStyle('Table', (theme: Theme) => ({
165
167
  borderBottomWidth: 1,
166
168
  borderBottomColor: theme.colors.border.primary,
167
169
  variants: {
168
- type: {
169
- bordered: { borderRightWidth: 1, borderRightColor: theme.colors.border.primary },
170
- },
171
170
  align: {
172
171
  left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
173
172
  center: { textAlign: 'center' as const, justifyContent: 'center' as const },
@@ -181,41 +180,25 @@ export const tableStyles = defineStyle('Table', (theme: Theme) => ({
181
180
  },
182
181
  _web: {
183
182
  position: 'relative',
184
- borderBottom: `2px solid ${theme.colors.border.primary}`,
185
- borderRight: type === 'bordered' ? `1px solid ${theme.colors.border.primary}` : undefined,
186
- ':last-child': type === 'bordered' ? { borderRight: 'none' } : {},
183
+ borderBottom: `1px solid ${theme.colors.border.primary}`,
187
184
  },
188
185
  }),
189
186
 
190
- cell: ({ type = 'standard', align = 'left' }: TableDynamicProps) => {
191
- const alignStyles = {
192
- left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
193
- center: { textAlign: 'center' as const, justifyContent: 'center' as const },
194
- right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
195
- }[align];
196
-
197
- const borderStyles = type === 'bordered' ? {
198
- borderRightWidth: 1,
199
- borderRightColor: theme.colors.border.primary,
200
- } : {};
201
-
202
- return {
203
- flexDirection: 'row' as const,
204
- alignItems: 'center' as const,
205
- color: theme.colors.text.primary,
206
- ...alignStyles,
207
- ...borderStyles,
208
- variants: {
209
- size: {
210
- padding: theme.sizes.$table.padding,
211
- fontSize: theme.sizes.$table.fontSize,
212
- lineHeight: theme.sizes.$table.lineHeight,
213
- },
187
+ cell: (_props: TableDynamicProps) => ({
188
+ flexDirection: 'row' as const,
189
+ alignItems: 'center' as const,
190
+ color: theme.colors.text.primary,
191
+ variants: {
192
+ align: {
193
+ left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
194
+ center: { textAlign: 'center' as const, justifyContent: 'center' as const },
195
+ right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
214
196
  },
215
- _web: {
216
- borderRight: type === 'bordered' ? `1px solid ${theme.colors.border.primary}` : undefined,
217
- ':last-child': type === 'bordered' ? { borderRight: 'none' } : {},
197
+ size: {
198
+ padding: theme.sizes.$table.padding,
199
+ fontSize: theme.sizes.$table.fontSize,
200
+ lineHeight: theme.sizes.$table.lineHeight,
218
201
  },
219
- } as const;
220
- },
202
+ },
203
+ }),
221
204
  }));
@@ -398,7 +398,7 @@ function Table<T = any>({
398
398
  size={size}
399
399
  type={type}
400
400
  clickable={isClickable}
401
- dividers={dividers}
401
+ dividers={dividers && rowIndex < data.length - 1}
402
402
  onClick={() => onRowPress?.(row, rowIndex)}
403
403
  testID={testID ? `${testID}-row-${rowIndex}` : undefined}
404
404
  >
@@ -6,7 +6,7 @@ import { AccessibilityProps, SortableAccessibilityProps } from '../utils/accessi
6
6
 
7
7
  // Component-specific type aliases for future extensibility
8
8
  export type TableSizeVariant = Size;
9
- export type TableType = 'standard' | 'bordered' | 'striped';
9
+ export type TableType = 'standard' | 'striped';
10
10
  export type TableAlignVariant = 'left' | 'center' | 'right';
11
11
 
12
12
  export interface TableColumn<T = any> extends SortableAccessibilityProps {
@@ -156,19 +156,34 @@ export const TableExamples: React.FC = () => {
156
156
  />
157
157
  </View>
158
158
  <View gap="xs">
159
- <Text typography="body2">Bordered</Text>
159
+ <Text typography="body2">Striped</Text>
160
+ <Table
161
+ columns={userColumns}
162
+ data={users}
163
+ type="striped"
164
+ />
165
+ </View>
166
+ </View>
167
+ </View>
168
+
169
+ <View gap="md">
170
+ <Text typography="h5">With Dividers</Text>
171
+ <View gap="sm">
172
+ <View gap="xs">
173
+ <Text typography="body2">Standard + Dividers</Text>
160
174
  <Table
161
175
  columns={userColumns}
162
176
  data={users}
163
- type="bordered"
177
+ dividers
164
178
  />
165
179
  </View>
166
180
  <View gap="xs">
167
- <Text typography="body2">Striped</Text>
181
+ <Text typography="body2">Striped + Dividers</Text>
168
182
  <Table
169
183
  columns={userColumns}
170
184
  data={users}
171
185
  type="striped"
186
+ dividers
172
187
  />
173
188
  </View>
174
189
  </View>
@@ -183,7 +198,7 @@ export const TableExamples: React.FC = () => {
183
198
  columns={userColumns}
184
199
  data={users.slice(0, 2)}
185
200
  size="sm"
186
- type="bordered"
201
+ dividers
187
202
  />
188
203
  </View>
189
204
  <View gap="xs">
@@ -192,7 +207,7 @@ export const TableExamples: React.FC = () => {
192
207
  columns={userColumns}
193
208
  data={users.slice(0, 2)}
194
209
  size="md"
195
- type="bordered"
210
+ dividers
196
211
  />
197
212
  </View>
198
213
  <View gap="xs">
@@ -201,7 +216,7 @@ export const TableExamples: React.FC = () => {
201
216
  columns={userColumns}
202
217
  data={users.slice(0, 2)}
203
218
  size="lg"
204
- type="bordered"
219
+ dividers
205
220
  />
206
221
  </View>
207
222
  </View>