@idealyst/components 1.2.143 → 1.2.145

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.145",
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.145",
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.145",
115
+ "@idealyst/tooling": "^1.2.145",
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,73 @@ 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
+ paddingVertical: theme.sizes.$table.headerPadding,
112
+ paddingHorizontal: theme.sizes.$table.padding,
113
+ fontSize: theme.sizes.$table.headerFontSize,
114
+ lineHeight: theme.sizes.$table.headerLineHeight,
115
+ },
116
+ },
117
+ _web: {
118
+ borderTop: `1px solid ${theme.colors.border.primary}`,
119
+ },
120
+ }),
107
121
 
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,
122
+ row: (_props: TableDynamicProps) => ({
123
+ variants: {
124
+ type: {
125
+ striped: {
126
+ _web: {
127
+ ':nth-child(even)': {
128
+ backgroundColor: theme.colors.surface.secondary,
129
+ },
130
+ },
122
131
  },
123
132
  },
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' } : {},
133
+ clickable: {
134
+ true: { _web: { cursor: 'pointer' } },
128
135
  },
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: {
136
+ dividers: {
137
+ true: {
138
+ borderBottomWidth: 1,
139
+ borderBottomColor: theme.colors.border.primary,
140
+ _web: {
141
+ borderBottom: `1px solid ${theme.colors.border.primary}`,
142
+ },
143
+ },
144
+ },
145
+ },
146
+ compoundVariants: [
147
+ {
148
+ type: 'striped',
149
+ even: true,
150
+ styles: {
148
151
  backgroundColor: theme.colors.surface.secondary,
149
152
  },
150
- // Striped rows handled via CSS pseudo-selector
151
- ...(type === 'striped' ? {
152
- ':nth-child(even)': {
153
- backgroundColor: theme.colors.surface.secondary,
154
- },
155
- } : {}),
156
153
  },
157
- } as const;
158
- },
154
+ ],
155
+ _web: {
156
+ transition: 'background-color 0.15s ease',
157
+ _hover: {
158
+ backgroundColor: theme.colors.surface.hover,
159
+ },
160
+ },
161
+ }),
159
162
 
160
- headerCell: ({ type = 'standard', align: _align = 'left' }: TableDynamicProps) => ({
163
+ headerCell: (_props: TableDynamicProps) => ({
161
164
  flexDirection: 'row' as const,
162
165
  alignItems: 'center' as const,
163
166
  fontWeight: '600' as const,
@@ -165,57 +168,39 @@ export const tableStyles = defineStyle('Table', (theme: Theme) => ({
165
168
  borderBottomWidth: 1,
166
169
  borderBottomColor: theme.colors.border.primary,
167
170
  variants: {
168
- type: {
169
- bordered: { borderRightWidth: 1, borderRightColor: theme.colors.border.primary },
170
- },
171
171
  align: {
172
172
  left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
173
173
  center: { textAlign: 'center' as const, justifyContent: 'center' as const },
174
174
  right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
175
175
  },
176
176
  size: {
177
- padding: theme.sizes.$table.padding,
177
+ paddingVertical: theme.sizes.$table.headerPadding,
178
+ paddingHorizontal: theme.sizes.$table.padding,
178
179
  fontSize: theme.sizes.$table.headerFontSize,
179
180
  lineHeight: theme.sizes.$table.headerLineHeight,
180
181
  },
181
182
  },
182
183
  _web: {
183
184
  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' } : {},
185
+ borderBottom: `1px solid ${theme.colors.border.primary}`,
187
186
  },
188
187
  }),
189
188
 
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
- },
189
+ cell: (_props: TableDynamicProps) => ({
190
+ flexDirection: 'row' as const,
191
+ alignItems: 'center' as const,
192
+ color: theme.colors.text.primary,
193
+ variants: {
194
+ align: {
195
+ left: { textAlign: 'left' as const, justifyContent: 'flex-start' as const },
196
+ center: { textAlign: 'center' as const, justifyContent: 'center' as const },
197
+ right: { textAlign: 'right' as const, justifyContent: 'flex-end' as const },
214
198
  },
215
- _web: {
216
- borderRight: type === 'bordered' ? `1px solid ${theme.colors.border.primary}` : undefined,
217
- ':last-child': type === 'bordered' ? { borderRight: 'none' } : {},
199
+ size: {
200
+ padding: theme.sizes.$table.padding,
201
+ fontSize: theme.sizes.$table.fontSize,
202
+ lineHeight: theme.sizes.$table.lineHeight,
218
203
  },
219
- } as const;
220
- },
204
+ },
205
+ }),
221
206
  }));
@@ -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>