@idealyst/components 1.2.13 → 1.2.15
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 +3 -3
- package/src/Accordion/Accordion.web.tsx +1 -1
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -3
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +3 -3
- package/src/Alert/Alert.native.tsx +1 -1
- package/src/Alert/Alert.web.tsx +1 -1
- package/src/Avatar/Avatar.native.tsx +1 -1
- package/src/Badge/Badge.web.tsx +6 -2
- package/src/Badge/types.ts +5 -0
- package/src/Breadcrumb/Breadcrumb.native.tsx +20 -21
- package/src/Button/Button.native.tsx +3 -3
- package/src/Button/Button.web.tsx +5 -1
- package/src/Button/types.ts +5 -0
- package/src/Card/Card.web.tsx +4 -1
- package/src/Card/types.ts +5 -0
- package/src/Dialog/Dialog.native.tsx +3 -3
- package/src/Divider/Divider.web.tsx +2 -2
- package/src/Icon/Icon.web.tsx +2 -2
- package/src/Icon/types.ts +3 -0
- package/src/Image/Image.styles.tsx +5 -5
- package/src/Image/Image.web.tsx +3 -3
- package/src/List/List.native.tsx +1 -2
- package/src/List/List.web.tsx +1 -2
- package/src/List/ListSection.web.tsx +3 -3
- package/src/Menu/Menu.web.tsx +8 -10
- package/src/Menu/MenuItem.web.tsx +1 -1
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.styles.tsx +76 -30
- package/src/Progress/Progress.web.tsx +13 -15
- package/src/SVGImage/SVGImage.web.tsx +1 -1
- package/src/Select/Select.web.tsx +2 -2
- package/src/Skeleton/Skeleton.native.tsx +3 -3
- package/src/Skeleton/Skeleton.web.tsx +3 -3
- package/src/Slider/Slider.native.tsx +2 -2
- package/src/Slider/Slider.styles.tsx +131 -44
- package/src/Slider/Slider.web.tsx +22 -22
- package/src/TabBar/TabBar.native.tsx +2 -2
- package/src/Text/Text.web.tsx +29 -3
- package/src/Text/types.ts +14 -1
- package/src/TextArea/TextArea.styles.tsx +96 -57
- package/src/TextArea/TextArea.web.tsx +19 -28
- package/src/Tooltip/Tooltip.web.tsx +3 -3
- package/src/Video/Video.styles.tsx +3 -3
- package/src/Video/Video.web.tsx +1 -1
- package/src/View/View.styles.tsx +2 -2
- package/src/View/View.web.tsx +93 -9
- package/src/View/types.ts +5 -1
- package/src/examples/ViewExamples.tsx +34 -0
- package/src/extensions/index.ts +0 -7
- package/src/hooks/useMergeRefs.ts +12 -6
- package/src/index.native.ts +1 -1
- package/src/index.ts +1 -1
- package/src/utils/accessibility/keyboardPatterns.ts +4 -0
- package/src/utils/accessibility/types.ts +5 -1
- package/src/utils/accessibility/useAnnounce.ts +1 -1
- package/src/utils/accessibility/useKeyboardNavigation.ts +1 -1
- package/src/utils/index.ts +0 -3
- package/src/utils/viewStyleProps.ts +2 -0
- package/src/Accordion/Accordion.styles.old.tsx +0 -298
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +0 -94
- package/src/Alert/Alert.styles.old.tsx +0 -209
- package/src/Avatar/Avatar.styles.old.tsx +0 -99
- package/src/Badge/Badge.styles.old.tsx +0 -157
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +0 -231
- package/src/Card/Card.styles.old.tsx +0 -160
- package/src/Checkbox/Checkbox.styles.old.tsx +0 -271
- package/src/Chip/Chip.styles.old.tsx +0 -184
- package/src/Dialog/Dialog.styles.old.tsx +0 -202
- package/src/Divider/Divider.styles.old.tsx +0 -172
- package/src/Icon/Icon.styles.old.tsx +0 -81
- package/src/Image/Image.styles.old.tsx +0 -69
- package/src/Input/Input.styles.old.tsx +0 -289
- package/src/List/List.styles.old.tsx +0 -242
- package/src/Menu/Menu.styles.old.tsx +0 -197
- package/src/Menu/MenuItem.styles.old.tsx +0 -114
- package/src/Popover/Popover.styles.old.tsx +0 -135
- package/src/Pressable/Pressable.styles.old.tsx +0 -27
- package/src/Progress/Progress.styles.old.tsx +0 -200
- package/src/RadioButton/RadioButton.styles.old.tsx +0 -175
- package/src/SVGImage/SVGImage.styles.old.tsx +0 -86
- package/src/Screen/Screen.styles.old.tsx +0 -87
- package/src/Select/Select.styles.old.tsx +0 -353
- package/src/Skeleton/Skeleton.styles.old.tsx +0 -67
- package/src/Slider/Slider.styles.old.tsx +0 -259
- package/src/Switch/Switch.styles.old.tsx +0 -203
- package/src/TabBar/TabBar.styles.old.tsx +0 -343
- package/src/Table/Table.styles.old.tsx +0 -311
- package/src/Text/Text.styles.old.tsx +0 -219
- package/src/TextArea/TextArea.styles.old.tsx +0 -213
- package/src/Tooltip/Tooltip.styles.old.tsx +0 -82
- package/src/Video/Video.styles.old.tsx +0 -51
- package/src/View/View.styles.old.tsx +0 -125
- package/src/extensions/applyExtension.ts +0 -210
- package/src/utils/buildSizeVariants.ts +0 -16
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme } from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import {
|
|
5
|
-
buildGapVariants,
|
|
6
|
-
buildPaddingVariants,
|
|
7
|
-
buildPaddingVerticalVariants,
|
|
8
|
-
buildPaddingHorizontalVariants,
|
|
9
|
-
buildMarginVariants,
|
|
10
|
-
buildMarginVerticalVariants,
|
|
11
|
-
buildMarginHorizontalVariants,
|
|
12
|
-
} from '../utils/buildViewStyleVariants';
|
|
13
|
-
import { TabBarPillMode, TabBarSizeVariant, TabBarType, TabBarIconPosition, TabBarJustify } from './types';
|
|
14
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
15
|
-
|
|
16
|
-
type ContainerDynamicProps = {
|
|
17
|
-
type?: TabBarType;
|
|
18
|
-
pillMode?: TabBarPillMode;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
type TabDynamicProps = {
|
|
22
|
-
type?: TabBarType;
|
|
23
|
-
size?: TabBarSizeVariant;
|
|
24
|
-
active?: boolean;
|
|
25
|
-
pillMode?: TabBarPillMode;
|
|
26
|
-
};
|
|
27
|
-
|
|
28
|
-
type LabelDynamicProps = {
|
|
29
|
-
type?: TabBarType;
|
|
30
|
-
active?: boolean;
|
|
31
|
-
pillMode?: TabBarPillMode;
|
|
32
|
-
};
|
|
33
|
-
|
|
34
|
-
type IndicatorDynamicProps = {
|
|
35
|
-
type?: TabBarType;
|
|
36
|
-
pillMode?: TabBarPillMode;
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
/**
|
|
40
|
-
* Get container background color based on type and pillMode
|
|
41
|
-
*/
|
|
42
|
-
function getContainerBackgroundColor(theme: Theme, type: TabBarType, pillMode: TabBarPillMode): string | undefined {
|
|
43
|
-
if (type === 'pills') {
|
|
44
|
-
return pillMode === 'dark' ? theme.colors.surface.inverse : theme.colors.surface.secondary;
|
|
45
|
-
}
|
|
46
|
-
return undefined;
|
|
47
|
-
}
|
|
48
|
-
|
|
49
|
-
/**
|
|
50
|
-
* Get tab padding based on type and size (pills have compact padding)
|
|
51
|
-
*/
|
|
52
|
-
function getTabPadding(type: TabBarType, size: TabBarSizeVariant): { paddingVertical?: number; paddingHorizontal?: number } {
|
|
53
|
-
if (type !== 'pills') return {};
|
|
54
|
-
|
|
55
|
-
const paddingMap: Record<TabBarSizeVariant, { paddingVertical: number; paddingHorizontal: number }> = {
|
|
56
|
-
xs: { paddingVertical: 2, paddingHorizontal: 10 },
|
|
57
|
-
sm: { paddingVertical: 4, paddingHorizontal: 12 },
|
|
58
|
-
md: { paddingVertical: 6, paddingHorizontal: 16 },
|
|
59
|
-
lg: { paddingVertical: 8, paddingHorizontal: 20 },
|
|
60
|
-
xl: { paddingVertical: 10, paddingHorizontal: 24 },
|
|
61
|
-
};
|
|
62
|
-
return paddingMap[size] || paddingMap.md;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
/**
|
|
66
|
-
* Get tab text color based on type and active state
|
|
67
|
-
*/
|
|
68
|
-
function getTabColor(theme: Theme, type: TabBarType, active: boolean): string | undefined {
|
|
69
|
-
if (!active) return undefined;
|
|
70
|
-
if (type === 'pills') return theme.intents.primary.contrast;
|
|
71
|
-
if (type === 'underline') return theme.intents.primary.primary;
|
|
72
|
-
return theme.colors.text.primary;
|
|
73
|
-
}
|
|
74
|
-
|
|
75
|
-
/**
|
|
76
|
-
* Get label color based on type, pillMode, and active state
|
|
77
|
-
*/
|
|
78
|
-
function getLabelColor(theme: Theme, type: TabBarType, pillMode: TabBarPillMode, active: boolean): string | undefined {
|
|
79
|
-
if (!active) return undefined;
|
|
80
|
-
if (type === 'pills') return theme.colors.text.primary;
|
|
81
|
-
if (type === 'underline') return theme.intents.primary.primary;
|
|
82
|
-
return theme.colors.text.primary;
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get indicator background color based on type and pillMode
|
|
87
|
-
*/
|
|
88
|
-
function getIndicatorBackgroundColor(theme: Theme, type: TabBarType, pillMode: TabBarPillMode): string | undefined {
|
|
89
|
-
if (type === 'pills') {
|
|
90
|
-
return pillMode === 'dark' ? theme.colors.surface.secondary : theme.colors.surface.tertiary;
|
|
91
|
-
}
|
|
92
|
-
return undefined;
|
|
93
|
-
}
|
|
94
|
-
|
|
95
|
-
/**
|
|
96
|
-
* Create size variants for tab
|
|
97
|
-
*/
|
|
98
|
-
function createTabSizeVariants(theme: Theme) {
|
|
99
|
-
return buildSizeVariants(theme, 'tabBar', (size) => ({
|
|
100
|
-
fontSize: size.fontSize,
|
|
101
|
-
padding: size.padding,
|
|
102
|
-
lineHeight: size.lineHeight,
|
|
103
|
-
}));
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Create size variants for label
|
|
108
|
-
*/
|
|
109
|
-
function createLabelSizeVariants(theme: Theme) {
|
|
110
|
-
return buildSizeVariants(theme, 'tabBar', (size) => ({
|
|
111
|
-
fontSize: size.fontSize,
|
|
112
|
-
lineHeight: size.lineHeight,
|
|
113
|
-
}));
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Create size variants for icon
|
|
118
|
-
*/
|
|
119
|
-
function createIconSizeVariants(theme: Theme) {
|
|
120
|
-
return buildSizeVariants(theme, 'tabBar', (size) => ({
|
|
121
|
-
width: size.fontSize,
|
|
122
|
-
height: size.fontSize,
|
|
123
|
-
}));
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
/**
|
|
127
|
-
* Create dynamic container styles
|
|
128
|
-
*/
|
|
129
|
-
function createContainerStyles(theme: Theme) {
|
|
130
|
-
return ({ type = 'standard', pillMode = 'light' }: ContainerDynamicProps) => {
|
|
131
|
-
const bgColor = getContainerBackgroundColor(theme, type, pillMode);
|
|
132
|
-
|
|
133
|
-
return {
|
|
134
|
-
display: 'flex',
|
|
135
|
-
flexDirection: 'row',
|
|
136
|
-
gap: type === 'pills' ? 4 : 0,
|
|
137
|
-
position: 'relative',
|
|
138
|
-
borderBottomWidth: type === 'pills' ? 0 : 1,
|
|
139
|
-
borderBottomStyle: 'solid' as const,
|
|
140
|
-
borderBottomColor: theme.colors.border.primary,
|
|
141
|
-
padding: type === 'pills' ? 4 : undefined,
|
|
142
|
-
backgroundColor: bgColor || (type === 'pills' ? theme.colors.surface.secondary : undefined),
|
|
143
|
-
overflow: type === 'pills' ? 'hidden' as const : undefined,
|
|
144
|
-
alignSelf: type === 'pills' ? 'flex-start' as const : undefined,
|
|
145
|
-
width: type === 'pills' ? undefined : '100%',
|
|
146
|
-
borderRadius: type === 'pills' ? 9999 : undefined,
|
|
147
|
-
variants: {
|
|
148
|
-
justify: {
|
|
149
|
-
start: { justifyContent: 'flex-start' },
|
|
150
|
-
center: { justifyContent: 'center' },
|
|
151
|
-
equal: { justifyContent: 'stretch', width: '100%' },
|
|
152
|
-
'space-between': { justifyContent: 'space-between', width: '100%' },
|
|
153
|
-
},
|
|
154
|
-
// Spacing variants from ContainerStyleProps
|
|
155
|
-
gap: buildGapVariants(theme),
|
|
156
|
-
padding: buildPaddingVariants(theme),
|
|
157
|
-
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
158
|
-
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
159
|
-
margin: buildMarginVariants(theme),
|
|
160
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
161
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
162
|
-
} as const,
|
|
163
|
-
} as const;
|
|
164
|
-
};
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
/**
|
|
168
|
-
* Create dynamic tab styles
|
|
169
|
-
*/
|
|
170
|
-
function createTabStyles(theme: Theme) {
|
|
171
|
-
return ({ type = 'standard', size = 'md', active = false, pillMode = 'light', justify = 'start' }: TabDynamicProps) => {
|
|
172
|
-
const tabPadding = getTabPadding(type, size);
|
|
173
|
-
const color = getTabColor(theme, type, active);
|
|
174
|
-
|
|
175
|
-
return {
|
|
176
|
-
display: 'flex',
|
|
177
|
-
flexDirection: 'row',
|
|
178
|
-
alignItems: 'center',
|
|
179
|
-
justifyContent: 'center',
|
|
180
|
-
fontWeight: '500',
|
|
181
|
-
flex: justify === 'equal' ? 1 : undefined,
|
|
182
|
-
color: color || (active ? theme.colors.text.primary : theme.colors.text.secondary),
|
|
183
|
-
position: 'relative',
|
|
184
|
-
zIndex: 2,
|
|
185
|
-
backgroundColor: 'transparent',
|
|
186
|
-
gap: 6,
|
|
187
|
-
borderRadius: type === 'pills' ? 9999 : undefined,
|
|
188
|
-
...tabPadding,
|
|
189
|
-
variants: {
|
|
190
|
-
size: createTabSizeVariants(theme),
|
|
191
|
-
disabled: {
|
|
192
|
-
true: {
|
|
193
|
-
opacity: 0.5,
|
|
194
|
-
_web: { cursor: 'not-allowed' },
|
|
195
|
-
},
|
|
196
|
-
false: {
|
|
197
|
-
_web: { _hover: { color: theme.colors.text.primary } },
|
|
198
|
-
},
|
|
199
|
-
},
|
|
200
|
-
iconPosition: {
|
|
201
|
-
left: { flexDirection: 'row' },
|
|
202
|
-
top: { flexDirection: 'column' },
|
|
203
|
-
},
|
|
204
|
-
justify: {
|
|
205
|
-
start: {},
|
|
206
|
-
center: {},
|
|
207
|
-
equal: { flex: 1 },
|
|
208
|
-
'space-between': {},
|
|
209
|
-
},
|
|
210
|
-
} as const,
|
|
211
|
-
_web: {
|
|
212
|
-
border: 'none',
|
|
213
|
-
cursor: 'pointer',
|
|
214
|
-
outline: 'none',
|
|
215
|
-
transition: 'color 0.2s ease',
|
|
216
|
-
},
|
|
217
|
-
} as const;
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
|
|
221
|
-
/**
|
|
222
|
-
* Create dynamic tab label styles
|
|
223
|
-
*/
|
|
224
|
-
function createTabLabelStyles(theme: Theme) {
|
|
225
|
-
return ({ type = 'standard', active = false, pillMode = 'light' }: LabelDynamicProps) => {
|
|
226
|
-
const color = getLabelColor(theme, type, pillMode, active);
|
|
227
|
-
|
|
228
|
-
return {
|
|
229
|
-
position: 'relative',
|
|
230
|
-
zIndex: 3,
|
|
231
|
-
fontWeight: '500',
|
|
232
|
-
color: color || (active ? theme.colors.text.primary : theme.colors.text.secondary),
|
|
233
|
-
variants: {
|
|
234
|
-
size: createLabelSizeVariants(theme),
|
|
235
|
-
disabled: {
|
|
236
|
-
true: { opacity: 0.5 },
|
|
237
|
-
false: {},
|
|
238
|
-
},
|
|
239
|
-
},
|
|
240
|
-
} as const;
|
|
241
|
-
};
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
/**
|
|
245
|
-
* Create dynamic indicator styles
|
|
246
|
-
*/
|
|
247
|
-
function createIndicatorStyles(theme: Theme) {
|
|
248
|
-
return ({ type = 'standard', pillMode = 'light' }: IndicatorDynamicProps) => {
|
|
249
|
-
const bgColor = getIndicatorBackgroundColor(theme, type, pillMode);
|
|
250
|
-
|
|
251
|
-
const typeStyles = type === 'pills' ? {
|
|
252
|
-
borderRadius: 9999,
|
|
253
|
-
bottom: 4,
|
|
254
|
-
top: 4,
|
|
255
|
-
left: 0,
|
|
256
|
-
backgroundColor: bgColor,
|
|
257
|
-
} : {
|
|
258
|
-
bottom: -1,
|
|
259
|
-
height: 2,
|
|
260
|
-
backgroundColor: theme.intents.primary.primary,
|
|
261
|
-
};
|
|
262
|
-
|
|
263
|
-
return {
|
|
264
|
-
position: 'absolute',
|
|
265
|
-
pointerEvents: 'none',
|
|
266
|
-
zIndex: 1,
|
|
267
|
-
...typeStyles,
|
|
268
|
-
_web: {
|
|
269
|
-
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
270
|
-
},
|
|
271
|
-
} as const;
|
|
272
|
-
};
|
|
273
|
-
}
|
|
274
|
-
|
|
275
|
-
/**
|
|
276
|
-
* Create icon styles (static, no compound variants)
|
|
277
|
-
*/
|
|
278
|
-
function createIconStyles(theme: Theme) {
|
|
279
|
-
return {
|
|
280
|
-
display: 'flex',
|
|
281
|
-
alignItems: 'center',
|
|
282
|
-
justifyContent: 'center',
|
|
283
|
-
variants: {
|
|
284
|
-
size: createIconSizeVariants(theme),
|
|
285
|
-
active: {
|
|
286
|
-
true: {},
|
|
287
|
-
false: {},
|
|
288
|
-
},
|
|
289
|
-
disabled: {
|
|
290
|
-
true: { opacity: 0.5 },
|
|
291
|
-
false: {},
|
|
292
|
-
},
|
|
293
|
-
iconPosition: {
|
|
294
|
-
left: {},
|
|
295
|
-
top: { marginBottom: 2 },
|
|
296
|
-
},
|
|
297
|
-
} as const,
|
|
298
|
-
} as const;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
302
|
-
export const tabBarStyles = StyleSheet.create((theme: Theme) => {
|
|
303
|
-
// Apply extensions to main visual elements
|
|
304
|
-
|
|
305
|
-
return applyExtensions('TabBar', theme, {container: createContainerStyles(theme),
|
|
306
|
-
tab: createTabStyles(theme),
|
|
307
|
-
indicator: createIndicatorStyles(theme),
|
|
308
|
-
// Additional styles (merged from return)
|
|
309
|
-
// Minor utility styles (not extended)
|
|
310
|
-
tabLabel: createTabLabelStyles(theme),
|
|
311
|
-
tabIcon: createIconStyles(theme)});
|
|
312
|
-
});
|
|
313
|
-
|
|
314
|
-
// Export individual style sheets for backwards compatibility
|
|
315
|
-
export const tabBarContainerStyles = StyleSheet.create((theme: Theme) => {
|
|
316
|
-
return {
|
|
317
|
-
container: createContainerStyles(theme),
|
|
318
|
-
} as const;
|
|
319
|
-
});
|
|
320
|
-
|
|
321
|
-
export const tabBarTabStyles = StyleSheet.create((theme: Theme) => {
|
|
322
|
-
return {
|
|
323
|
-
tab: createTabStyles(theme),
|
|
324
|
-
} as const;
|
|
325
|
-
});
|
|
326
|
-
|
|
327
|
-
export const tabBarLabelStyles = StyleSheet.create((theme: Theme) => {
|
|
328
|
-
return {
|
|
329
|
-
tabLabel: createTabLabelStyles(theme),
|
|
330
|
-
} as const;
|
|
331
|
-
});
|
|
332
|
-
|
|
333
|
-
export const tabBarIndicatorStyles = StyleSheet.create((theme: Theme) => {
|
|
334
|
-
return {
|
|
335
|
-
indicator: createIndicatorStyles(theme),
|
|
336
|
-
} as const;
|
|
337
|
-
});
|
|
338
|
-
|
|
339
|
-
export const tabBarIconStyles = StyleSheet.create((theme: Theme) => {
|
|
340
|
-
return {
|
|
341
|
-
tabIcon: createIconStyles(theme),
|
|
342
|
-
} as const;
|
|
343
|
-
});
|
|
@@ -1,311 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles, CompoundVariants, Size } from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import {
|
|
5
|
-
buildGapVariants,
|
|
6
|
-
buildPaddingVariants,
|
|
7
|
-
buildPaddingVerticalVariants,
|
|
8
|
-
buildPaddingHorizontalVariants,
|
|
9
|
-
buildMarginVariants,
|
|
10
|
-
buildMarginVerticalVariants,
|
|
11
|
-
buildMarginHorizontalVariants,
|
|
12
|
-
} from '../utils/buildViewStyleVariants';
|
|
13
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
14
|
-
|
|
15
|
-
type TableType = 'default' | 'bordered' | 'striped';
|
|
16
|
-
|
|
17
|
-
type TableRowVariants = {
|
|
18
|
-
type: TableType;
|
|
19
|
-
clickable: boolean;
|
|
20
|
-
}
|
|
21
|
-
/**
|
|
22
|
-
* Create type variants for container
|
|
23
|
-
*/
|
|
24
|
-
function createContainerTypeVariants(theme: Theme) {
|
|
25
|
-
return {
|
|
26
|
-
standard: {
|
|
27
|
-
borderWidth: 1,
|
|
28
|
-
borderStyle: 'solid',
|
|
29
|
-
borderColor: theme.colors.border.primary,
|
|
30
|
-
borderRadius: 8,
|
|
31
|
-
overflow: 'hidden',
|
|
32
|
-
_web: {
|
|
33
|
-
border: `1px solid ${theme.colors.border.primary}`,
|
|
34
|
-
},
|
|
35
|
-
},
|
|
36
|
-
bordered: {
|
|
37
|
-
borderWidth: 1,
|
|
38
|
-
borderStyle: 'solid',
|
|
39
|
-
borderColor: theme.colors.border.primary,
|
|
40
|
-
borderRadius: 8,
|
|
41
|
-
overflow: 'hidden',
|
|
42
|
-
_web: {
|
|
43
|
-
border: `1px solid ${theme.colors.border.primary}`,
|
|
44
|
-
},
|
|
45
|
-
},
|
|
46
|
-
striped: {
|
|
47
|
-
borderWidth: 1,
|
|
48
|
-
borderStyle: 'solid',
|
|
49
|
-
borderColor: theme.colors.border.primary,
|
|
50
|
-
borderRadius: 8,
|
|
51
|
-
overflow: 'hidden',
|
|
52
|
-
_web: {
|
|
53
|
-
border: `1px solid ${theme.colors.border.primary}`,
|
|
54
|
-
},
|
|
55
|
-
},
|
|
56
|
-
} as const;
|
|
57
|
-
}
|
|
58
|
-
|
|
59
|
-
/**
|
|
60
|
-
* Create type variants for row
|
|
61
|
-
*/
|
|
62
|
-
function createRowTypeVariants(theme: Theme) {
|
|
63
|
-
return {
|
|
64
|
-
standard: {},
|
|
65
|
-
bordered: {
|
|
66
|
-
borderBottomWidth: 1,
|
|
67
|
-
borderBottomStyle: 'solid',
|
|
68
|
-
borderBottomColor: theme.colors.border.primary,
|
|
69
|
-
_web: {
|
|
70
|
-
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
71
|
-
},
|
|
72
|
-
},
|
|
73
|
-
striped: {
|
|
74
|
-
borderBottomWidth: 1,
|
|
75
|
-
borderBottomStyle: 'solid',
|
|
76
|
-
borderBottomColor: theme.colors.border.primary,
|
|
77
|
-
_web: {
|
|
78
|
-
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
79
|
-
':nth-child(even)': {
|
|
80
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
81
|
-
},
|
|
82
|
-
},
|
|
83
|
-
},
|
|
84
|
-
} as const;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
|
-
/**
|
|
88
|
-
* Create compound variants for row
|
|
89
|
-
*/
|
|
90
|
-
function createRowCompoundVariants(theme: Theme): CompoundVariants<keyof TableRowVariants> {
|
|
91
|
-
return [
|
|
92
|
-
{
|
|
93
|
-
type: 'striped',
|
|
94
|
-
clickable: true,
|
|
95
|
-
styles: {
|
|
96
|
-
_web: {
|
|
97
|
-
_hover: {
|
|
98
|
-
backgroundColor: theme.colors.surface.tertiary,
|
|
99
|
-
},
|
|
100
|
-
},
|
|
101
|
-
},
|
|
102
|
-
},
|
|
103
|
-
] as const;
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
/**
|
|
107
|
-
* Create size variants for header cell
|
|
108
|
-
*/
|
|
109
|
-
function createHeaderCellSizeVariants(theme: Theme) {
|
|
110
|
-
return buildSizeVariants(theme, 'table', (size) => ({
|
|
111
|
-
padding: size.padding,
|
|
112
|
-
fontSize: size.fontSize,
|
|
113
|
-
lineHeight: size.lineHeight,
|
|
114
|
-
}));
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
/**
|
|
118
|
-
* Create type variants for header cell
|
|
119
|
-
*/
|
|
120
|
-
function createHeaderCellTypeVariants(theme: Theme) {
|
|
121
|
-
return {
|
|
122
|
-
standard: {},
|
|
123
|
-
bordered: {
|
|
124
|
-
borderRightWidth: 1,
|
|
125
|
-
borderRightStyle: 'solid',
|
|
126
|
-
borderRightColor: theme.colors.border.primary,
|
|
127
|
-
_web: {
|
|
128
|
-
borderRight: `1px solid ${theme.colors.border.primary}`,
|
|
129
|
-
':last-child': {
|
|
130
|
-
borderRight: 'none',
|
|
131
|
-
},
|
|
132
|
-
},
|
|
133
|
-
},
|
|
134
|
-
striped: {},
|
|
135
|
-
} as const;
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
/**
|
|
139
|
-
* Create size variants for cell
|
|
140
|
-
*/
|
|
141
|
-
function createCellSizeVariants(theme: Theme) {
|
|
142
|
-
return buildSizeVariants(theme, 'table', (size) => ({
|
|
143
|
-
padding: size.padding,
|
|
144
|
-
fontSize: size.fontSize,
|
|
145
|
-
lineHeight: size.lineHeight,
|
|
146
|
-
}));
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
/**
|
|
150
|
-
* Create type variants for cell
|
|
151
|
-
*/
|
|
152
|
-
function createCellTypeVariants(theme: Theme) {
|
|
153
|
-
return {
|
|
154
|
-
standard: {},
|
|
155
|
-
bordered: {
|
|
156
|
-
borderRightWidth: 1,
|
|
157
|
-
borderRightStyle: 'solid',
|
|
158
|
-
borderRightColor: theme.colors.border.primary,
|
|
159
|
-
_web: {
|
|
160
|
-
borderRight: `1px solid ${theme.colors.border.primary}`,
|
|
161
|
-
':last-child': {
|
|
162
|
-
borderRight: 'none',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
},
|
|
166
|
-
striped: {},
|
|
167
|
-
} as const;
|
|
168
|
-
}
|
|
169
|
-
|
|
170
|
-
function createContainerStyles(theme: Theme) {
|
|
171
|
-
return () => ({
|
|
172
|
-
width: '100%',
|
|
173
|
-
_web: {
|
|
174
|
-
overflow: 'auto',
|
|
175
|
-
},
|
|
176
|
-
variants: {
|
|
177
|
-
type: createContainerTypeVariants(theme),
|
|
178
|
-
// Spacing variants from ContainerStyleProps
|
|
179
|
-
gap: buildGapVariants(theme),
|
|
180
|
-
padding: buildPaddingVariants(theme),
|
|
181
|
-
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
182
|
-
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
183
|
-
margin: buildMarginVariants(theme),
|
|
184
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
185
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
186
|
-
},
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
const createTableStyles = (theme: Theme) => {
|
|
191
|
-
return {
|
|
192
|
-
width: '100%',
|
|
193
|
-
_web: {
|
|
194
|
-
borderCollapse: 'collapse',
|
|
195
|
-
},
|
|
196
|
-
} as const;
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
const createTheadStyles = (theme: Theme) => {
|
|
200
|
-
return {
|
|
201
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
202
|
-
variants: {
|
|
203
|
-
sticky: {
|
|
204
|
-
true: {
|
|
205
|
-
_web: {
|
|
206
|
-
position: 'sticky',
|
|
207
|
-
top: 0,
|
|
208
|
-
zIndex: 10,
|
|
209
|
-
}
|
|
210
|
-
},
|
|
211
|
-
false: {},
|
|
212
|
-
},
|
|
213
|
-
},
|
|
214
|
-
} as const;
|
|
215
|
-
}
|
|
216
|
-
|
|
217
|
-
const createRowStyles = (theme: Theme) => {
|
|
218
|
-
return {
|
|
219
|
-
variants: {
|
|
220
|
-
type: createRowTypeVariants(theme),
|
|
221
|
-
clickable: {
|
|
222
|
-
true: {
|
|
223
|
-
_web: {
|
|
224
|
-
cursor: 'pointer',
|
|
225
|
-
_hover: {
|
|
226
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
227
|
-
},
|
|
228
|
-
},
|
|
229
|
-
},
|
|
230
|
-
false: {},
|
|
231
|
-
},
|
|
232
|
-
},
|
|
233
|
-
compoundVariants: createRowCompoundVariants(theme),
|
|
234
|
-
_web: {
|
|
235
|
-
transition: 'background-color 0.2s ease',
|
|
236
|
-
},
|
|
237
|
-
} as const;
|
|
238
|
-
}
|
|
239
|
-
|
|
240
|
-
const createHeaderCellStyles = (theme: Theme) => {
|
|
241
|
-
return {
|
|
242
|
-
flexDirection: 'row',
|
|
243
|
-
alignItems: 'center',
|
|
244
|
-
textAlign: 'left',
|
|
245
|
-
fontWeight: '600',
|
|
246
|
-
color: theme.colors.text.primary,
|
|
247
|
-
borderBottomWidth: 2,
|
|
248
|
-
borderBottomStyle: 'solid',
|
|
249
|
-
borderBottomColor: theme.colors.border.primary,
|
|
250
|
-
_web: {
|
|
251
|
-
borderBottom: `2px solid ${theme.colors.border.primary}`,
|
|
252
|
-
},
|
|
253
|
-
variants: {
|
|
254
|
-
size: createHeaderCellSizeVariants(theme),
|
|
255
|
-
align: {
|
|
256
|
-
left: {
|
|
257
|
-
textAlign: 'left',
|
|
258
|
-
justifyContent: 'flex-start',
|
|
259
|
-
},
|
|
260
|
-
center: {
|
|
261
|
-
textAlign: 'center',
|
|
262
|
-
justifyContent: 'center',
|
|
263
|
-
},
|
|
264
|
-
right: {
|
|
265
|
-
textAlign: 'right',
|
|
266
|
-
justifyContent: 'flex-end',
|
|
267
|
-
},
|
|
268
|
-
},
|
|
269
|
-
type: createHeaderCellTypeVariants(theme),
|
|
270
|
-
},
|
|
271
|
-
} as const;
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
const createCellStyles = (theme: Theme) => {
|
|
275
|
-
return {
|
|
276
|
-
flexDirection: 'row',
|
|
277
|
-
alignItems: 'center',
|
|
278
|
-
textAlign: 'left',
|
|
279
|
-
color: theme.colors.text.primary,
|
|
280
|
-
variants: {
|
|
281
|
-
size: createCellSizeVariants(theme),
|
|
282
|
-
align: {
|
|
283
|
-
left: {
|
|
284
|
-
textAlign: 'left',
|
|
285
|
-
justifyContent: 'flex-start',
|
|
286
|
-
},
|
|
287
|
-
center: {
|
|
288
|
-
textAlign: 'center',
|
|
289
|
-
justifyContent: 'center',
|
|
290
|
-
},
|
|
291
|
-
right: {
|
|
292
|
-
textAlign: 'right',
|
|
293
|
-
justifyContent: 'flex-end',
|
|
294
|
-
},
|
|
295
|
-
},
|
|
296
|
-
type: createCellTypeVariants(theme),
|
|
297
|
-
},
|
|
298
|
-
} as const;
|
|
299
|
-
}
|
|
300
|
-
|
|
301
|
-
export const tableStyles = StyleSheet.create((theme: Theme) => {
|
|
302
|
-
return applyExtensions('Table', theme, {
|
|
303
|
-
container: createContainerStyles(theme),
|
|
304
|
-
table: createTableStyles(theme),
|
|
305
|
-
thead: createTheadStyles(theme),
|
|
306
|
-
tbody: {},
|
|
307
|
-
row: createRowStyles(theme),
|
|
308
|
-
headerCell: createHeaderCellStyles(theme),
|
|
309
|
-
cell: createCellStyles(theme),
|
|
310
|
-
});
|
|
311
|
-
});
|