@idealyst/components 1.1.6 → 1.1.8
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 +8 -3
- package/src/Accordion/Accordion.native.tsx +22 -14
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +139 -248
- package/src/Accordion/Accordion.web.tsx +12 -7
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -2
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +43 -62
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +2 -2
- package/src/Alert/Alert.native.tsx +26 -15
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +108 -281
- package/src/Alert/Alert.web.tsx +6 -10
- package/src/Avatar/Avatar.native.tsx +5 -2
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +47 -62
- package/src/Avatar/Avatar.web.tsx +2 -2
- package/src/Badge/Badge.native.tsx +2 -2
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +69 -108
- package/src/Badge/Badge.web.tsx +6 -6
- package/src/Breadcrumb/Breadcrumb.native.tsx +12 -5
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +93 -209
- package/src/Breadcrumb/Breadcrumb.web.tsx +39 -27
- package/src/Button/Button.native.tsx +39 -14
- package/src/Button/Button.styles.tsx +99 -253
- package/src/Button/Button.web.tsx +10 -8
- package/src/Card/Card.native.tsx +8 -4
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +107 -142
- package/src/Card/Card.web.tsx +6 -4
- package/src/Checkbox/Checkbox.native.tsx +14 -6
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +109 -197
- package/src/Checkbox/Checkbox.web.tsx +7 -7
- package/src/Chip/Chip.native.tsx +5 -5
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -22
- package/src/Chip/Chip.web.tsx +5 -5
- package/src/Dialog/Dialog.native.tsx +16 -7
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +108 -132
- package/src/Dialog/Dialog.web.tsx +4 -4
- package/src/Divider/Divider.native.tsx +29 -42
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +116 -242
- package/src/Divider/Divider.web.tsx +17 -14
- package/src/Icon/Icon.native.tsx +12 -4
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -60
- package/src/Icon/Icon.web.tsx +43 -7
- package/src/Icon/IconSvg/IconSvg.web.tsx +2 -0
- package/src/Image/Image.styles.old.tsx +69 -0
- package/src/Image/Image.styles.tsx +45 -43
- package/src/Input/Input.native.tsx +140 -56
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +177 -228
- package/src/Input/Input.web.tsx +5 -8
- package/src/Link/Link.native.tsx +4 -1
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +178 -240
- package/src/List/ListItem.native.tsx +16 -8
- package/src/List/ListItem.web.tsx +26 -15
- package/src/Menu/Menu.native.tsx +1 -1
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +90 -156
- package/src/Menu/Menu.web.tsx +2 -2
- package/src/Menu/MenuItem.native.tsx +9 -5
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +71 -104
- package/src/Menu/MenuItem.web.tsx +23 -5
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +46 -96
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.native.tsx +3 -1
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -20
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.native.tsx +15 -6
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +69 -118
- package/src/Progress/Progress.web.tsx +10 -9
- package/src/RadioButton/RadioButton.native.tsx +10 -4
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +81 -145
- package/src/RadioButton/RadioButton.web.tsx +4 -4
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -66
- package/src/Screen/Screen.native.tsx +30 -27
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +120 -71
- package/src/Screen/Screen.web.tsx +2 -2
- package/src/Select/Select.native.tsx +44 -29
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +244 -293
- package/src/Select/Select.web.tsx +5 -5
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +31 -43
- package/src/Slider/Slider.native.tsx +9 -5
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +157 -227
- package/src/Slider/Slider.web.tsx +5 -5
- package/src/Switch/Switch.native.tsx +11 -5
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +103 -149
- package/src/Switch/Switch.web.tsx +8 -8
- package/src/TabBar/TabBar.native.tsx +24 -31
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +204 -494
- package/src/TabBar/TabBar.web.tsx +21 -33
- package/src/Table/Table.native.tsx +18 -9
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +151 -278
- package/src/Table/Table.web.tsx +1 -1
- package/src/Text/Text.native.tsx +1 -4
- package/src/Text/Text.style.demo.tsx +16 -0
- package/src/Text/Text.styles.old.tsx +219 -0
- package/src/Text/Text.styles.tsx +94 -78
- package/src/Text/Text.web.tsx +2 -2
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.styles.old.tsx +213 -0
- package/src/TextArea/TextArea.styles.tsx +101 -157
- package/src/Tooltip/Tooltip.native.tsx +2 -2
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +38 -53
- package/src/Tooltip/Tooltip.web.tsx +2 -2
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -28
- package/src/View/View.native.tsx +12 -12
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +84 -103
- package/src/View/View.web.tsx +14 -2
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/applyExtension.ts +210 -0
- package/src/extensions/extendComponent.ts +438 -0
- package/src/extensions/index.ts +102 -0
- package/src/extensions/types.ts +497 -0
- package/src/globals.ts +16 -0
- package/src/index.native.ts +4 -0
- package/src/index.ts +28 -0
- package/src/utils/deepMerge.ts +54 -2
|
@@ -1,503 +1,213 @@
|
|
|
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 { TabBarPillMode, TabBarSizeVariant, TabBarType, TabBarIconPosition, TabBarJustify } from './types';
|
|
14
|
-
|
|
15
|
-
type TabBarContainerVariants = {
|
|
16
|
-
type: TabBarType;
|
|
17
|
-
size: TabBarSizeVariant;
|
|
18
|
-
pillMode: TabBarPillMode;
|
|
19
|
-
justify: TabBarJustify;
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
type TabBarTabVariants = {
|
|
23
|
-
size: TabBarSizeVariant;
|
|
24
|
-
type: TabBarType;
|
|
25
|
-
active: boolean;
|
|
26
|
-
disabled: boolean;
|
|
27
|
-
pillMode: TabBarPillMode;
|
|
28
|
-
iconPosition: TabBarIconPosition;
|
|
29
|
-
justify: TabBarJustify;
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
type TabBarIconVariants = {
|
|
33
|
-
size: TabBarSizeVariant;
|
|
34
|
-
active: boolean;
|
|
35
|
-
disabled: boolean;
|
|
36
|
-
iconPosition: TabBarIconPosition;
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
type TabBarLabelVariants = {
|
|
40
|
-
size: TabBarSizeVariant;
|
|
41
|
-
type: TabBarType;
|
|
42
|
-
active: boolean;
|
|
43
|
-
disabled: boolean;
|
|
44
|
-
pillMode: TabBarPillMode;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
type TabBarIndicatorVariants = {
|
|
48
|
-
type: TabBarType;
|
|
49
|
-
pillMode: TabBarPillMode;
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Create compound variants for container
|
|
54
|
-
*/
|
|
55
|
-
function createContainerCompoundVariants(theme: Theme): CompoundVariants<keyof TabBarContainerVariants> {
|
|
56
|
-
return [
|
|
57
|
-
{
|
|
58
|
-
type: 'pills',
|
|
59
|
-
pillMode: 'light',
|
|
60
|
-
styles: {
|
|
61
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
62
|
-
},
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
type: 'pills',
|
|
66
|
-
pillMode: 'dark',
|
|
67
|
-
styles: {
|
|
68
|
-
backgroundColor: theme.colors.surface.inverse,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
];
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Create size variants for tab
|
|
76
|
-
*/
|
|
77
|
-
function createTabSizeVariants(theme: Theme) {
|
|
78
|
-
return buildSizeVariants(theme, 'tabBar', (size) => ({
|
|
79
|
-
fontSize: size.fontSize,
|
|
80
|
-
padding: size.padding,
|
|
81
|
-
lineHeight: size.lineHeight,
|
|
82
|
-
}));
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Create compound variants for tab
|
|
87
|
-
*/
|
|
88
|
-
function createTabCompoundVariants(theme: Theme): CompoundVariants<keyof TabBarTabVariants> {
|
|
89
|
-
return [
|
|
90
|
-
// Pills variant - compact padding for all sizes
|
|
91
|
-
{
|
|
92
|
-
type: 'pills',
|
|
93
|
-
size: 'xs',
|
|
94
|
-
styles: {
|
|
95
|
-
paddingVertical: 2,
|
|
96
|
-
paddingHorizontal: 10,
|
|
97
|
-
},
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
type: 'pills',
|
|
101
|
-
size: 'sm',
|
|
102
|
-
styles: {
|
|
103
|
-
paddingVertical: 4,
|
|
104
|
-
paddingHorizontal: 12,
|
|
105
|
-
},
|
|
106
|
-
},
|
|
107
|
-
{
|
|
108
|
-
type: 'pills',
|
|
109
|
-
size: 'md',
|
|
110
|
-
styles: {
|
|
111
|
-
paddingVertical: 6,
|
|
112
|
-
paddingHorizontal: 16,
|
|
113
|
-
},
|
|
114
|
-
},
|
|
115
|
-
{
|
|
116
|
-
type: 'pills',
|
|
117
|
-
size: 'lg',
|
|
118
|
-
styles: {
|
|
119
|
-
paddingVertical: 8,
|
|
120
|
-
paddingHorizontal: 20,
|
|
121
|
-
},
|
|
122
|
-
},
|
|
123
|
-
{
|
|
124
|
-
type: 'pills',
|
|
125
|
-
size: 'xl',
|
|
126
|
-
styles: {
|
|
127
|
-
paddingVertical: 10,
|
|
128
|
-
paddingHorizontal: 24,
|
|
129
|
-
},
|
|
130
|
-
},
|
|
131
|
-
// Pills variant - active text color
|
|
132
|
-
{
|
|
133
|
-
type: 'pills',
|
|
134
|
-
active: true,
|
|
135
|
-
styles: {
|
|
136
|
-
color: theme.intents.primary.contrast,
|
|
137
|
-
},
|
|
138
|
-
},
|
|
139
|
-
// Underline variant - active text color
|
|
140
|
-
{
|
|
141
|
-
type: 'underline',
|
|
142
|
-
active: true,
|
|
143
|
-
styles: {
|
|
144
|
-
color: theme.intents.primary.primary,
|
|
145
|
-
},
|
|
146
|
-
},
|
|
147
|
-
] as const;
|
|
148
|
-
}
|
|
149
|
-
|
|
150
1
|
/**
|
|
151
|
-
*
|
|
2
|
+
* TabBar styles using defineStyle with dynamic props.
|
|
152
3
|
*/
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
type: 'underline',
|
|
186
|
-
active: true,
|
|
187
|
-
styles: {
|
|
188
|
-
color: theme.intents.primary.primary,
|
|
189
|
-
},
|
|
190
|
-
},
|
|
191
|
-
] as const;
|
|
192
|
-
}
|
|
4
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Size } from '@idealyst/theme';
|
|
7
|
+
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
8
|
+
|
|
9
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
10
|
+
void StyleSheet;
|
|
11
|
+
|
|
12
|
+
// Wrap theme for $iterator support
|
|
13
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
14
|
+
|
|
15
|
+
type TabBarType = 'standard' | 'underline' | 'pills';
|
|
16
|
+
type TabBarPillMode = 'light' | 'dark';
|
|
17
|
+
type TabBarIconPosition = 'left' | 'top';
|
|
18
|
+
type TabBarJustify = 'start' | 'center' | 'equal' | 'space-between';
|
|
19
|
+
|
|
20
|
+
export type TabBarDynamicProps = {
|
|
21
|
+
size?: Size;
|
|
22
|
+
type?: TabBarType;
|
|
23
|
+
pillMode?: TabBarPillMode;
|
|
24
|
+
active?: boolean;
|
|
25
|
+
disabled?: boolean;
|
|
26
|
+
iconPosition?: TabBarIconPosition;
|
|
27
|
+
justify?: TabBarJustify;
|
|
28
|
+
gap?: ViewStyleSize;
|
|
29
|
+
padding?: ViewStyleSize;
|
|
30
|
+
paddingVertical?: ViewStyleSize;
|
|
31
|
+
paddingHorizontal?: ViewStyleSize;
|
|
32
|
+
margin?: ViewStyleSize;
|
|
33
|
+
marginVertical?: ViewStyleSize;
|
|
34
|
+
marginHorizontal?: ViewStyleSize;
|
|
35
|
+
};
|
|
193
36
|
|
|
194
37
|
/**
|
|
195
|
-
*
|
|
38
|
+
* TabBar styles with type/pillMode/active handling.
|
|
196
39
|
*/
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
40
|
+
export const tabBarStyles = defineStyle('TabBar', (theme: Theme) => ({
|
|
41
|
+
container: ({ type = 'standard', pillMode = 'light', justify = 'start' }: TabBarDynamicProps) => {
|
|
42
|
+
const backgroundColor = type === 'pills'
|
|
43
|
+
? (pillMode === 'dark' ? theme.colors.surface.inverse : theme.colors.surface.secondary)
|
|
44
|
+
: undefined;
|
|
45
|
+
|
|
46
|
+
const justifyContent = {
|
|
47
|
+
start: 'flex-start',
|
|
48
|
+
center: 'center',
|
|
49
|
+
equal: 'stretch',
|
|
50
|
+
'space-between': 'space-between',
|
|
51
|
+
}[justify];
|
|
52
|
+
|
|
53
|
+
return {
|
|
54
|
+
display: 'flex' as const,
|
|
55
|
+
flexDirection: 'row' as const,
|
|
56
|
+
gap: type === 'pills' ? 4 : 0,
|
|
57
|
+
position: 'relative' as const,
|
|
58
|
+
borderBottomWidth: type === 'pills' ? 0 : 1,
|
|
59
|
+
borderBottomStyle: 'solid' as const,
|
|
60
|
+
borderBottomColor: theme.colors.border.primary,
|
|
61
|
+
padding: type === 'pills' ? 4 : undefined,
|
|
62
|
+
backgroundColor: backgroundColor || (type === 'pills' ? theme.colors.surface.secondary : undefined),
|
|
63
|
+
overflow: type === 'pills' ? ('hidden' as const) : undefined,
|
|
64
|
+
alignSelf: type === 'pills' ? ('flex-start' as const) : undefined,
|
|
65
|
+
width: type === 'pills' ? undefined : '100%',
|
|
66
|
+
borderRadius: type === 'pills' ? 9999 : undefined,
|
|
67
|
+
justifyContent: justifyContent as any,
|
|
68
|
+
variants: {
|
|
69
|
+
gap: {
|
|
70
|
+
gap: theme.sizes.$view.padding,
|
|
71
|
+
},
|
|
72
|
+
padding: {
|
|
73
|
+
padding: theme.sizes.$view.padding,
|
|
74
|
+
},
|
|
75
|
+
paddingVertical: {
|
|
76
|
+
paddingVertical: theme.sizes.$view.padding,
|
|
77
|
+
},
|
|
78
|
+
paddingHorizontal: {
|
|
79
|
+
paddingHorizontal: theme.sizes.$view.padding,
|
|
80
|
+
},
|
|
81
|
+
margin: {
|
|
82
|
+
margin: theme.sizes.$view.padding,
|
|
83
|
+
},
|
|
84
|
+
marginVertical: {
|
|
85
|
+
marginVertical: theme.sizes.$view.padding,
|
|
86
|
+
},
|
|
87
|
+
marginHorizontal: {
|
|
88
|
+
marginHorizontal: theme.sizes.$view.padding,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
} as const;
|
|
92
|
+
},
|
|
93
|
+
|
|
94
|
+
tab: ({ type = 'standard', size = 'md', active = false, pillMode = 'light', disabled = false, iconPosition = 'left', justify = 'start' }: TabBarDynamicProps) => {
|
|
95
|
+
// Tab padding for pills
|
|
96
|
+
const paddingMap: Record<Size, { paddingVertical: number; paddingHorizontal: number }> = {
|
|
97
|
+
xs: { paddingVertical: 2, paddingHorizontal: 10 },
|
|
98
|
+
sm: { paddingVertical: 4, paddingHorizontal: 12 },
|
|
99
|
+
md: { paddingVertical: 6, paddingHorizontal: 16 },
|
|
100
|
+
lg: { paddingVertical: 8, paddingHorizontal: 20 },
|
|
101
|
+
xl: { paddingVertical: 10, paddingHorizontal: 24 },
|
|
102
|
+
};
|
|
103
|
+
const tabPadding = type === 'pills' ? paddingMap[size] : {};
|
|
104
|
+
|
|
105
|
+
// Color based on type and active state
|
|
106
|
+
let color = active ? theme.colors.text.primary : theme.colors.text.secondary;
|
|
107
|
+
if (active) {
|
|
108
|
+
if (type === 'pills') color = theme.intents.primary.contrast;
|
|
109
|
+
else if (type === 'underline') color = theme.intents.primary.primary;
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
return {
|
|
113
|
+
display: 'flex' as const,
|
|
114
|
+
flexDirection: iconPosition === 'top' ? ('column' as const) : ('row' as const),
|
|
115
|
+
alignItems: 'center' as const,
|
|
116
|
+
justifyContent: 'center' as const,
|
|
117
|
+
fontWeight: '500' as const,
|
|
118
|
+
flex: justify === 'equal' ? 1 : undefined,
|
|
119
|
+
color,
|
|
120
|
+
position: 'relative' as const,
|
|
121
|
+
zIndex: 2,
|
|
122
|
+
backgroundColor: 'transparent' as const,
|
|
123
|
+
gap: 6,
|
|
124
|
+
borderRadius: type === 'pills' ? 9999 : undefined,
|
|
125
|
+
opacity: disabled ? 0.5 : 1,
|
|
126
|
+
...tabPadding,
|
|
127
|
+
variants: {
|
|
128
|
+
size: {
|
|
129
|
+
fontSize: theme.sizes.$tabBar.fontSize,
|
|
130
|
+
padding: theme.sizes.$tabBar.padding,
|
|
131
|
+
lineHeight: theme.sizes.$tabBar.lineHeight,
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
_web: {
|
|
135
|
+
border: 'none',
|
|
136
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
137
|
+
outline: 'none',
|
|
138
|
+
transition: 'color 0.2s ease',
|
|
139
|
+
_hover: disabled ? {} : { color: theme.colors.text.primary },
|
|
140
|
+
},
|
|
141
|
+
} as const;
|
|
142
|
+
},
|
|
143
|
+
|
|
144
|
+
tabLabel: ({ type = 'standard', active = false, pillMode = 'light', disabled = false }: TabBarDynamicProps) => {
|
|
145
|
+
let color = active ? theme.colors.text.primary : theme.colors.text.secondary;
|
|
146
|
+
if (active) {
|
|
147
|
+
if (type === 'pills') color = theme.colors.text.primary;
|
|
148
|
+
else if (type === 'underline') color = theme.intents.primary.primary;
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
return {
|
|
152
|
+
position: 'relative' as const,
|
|
153
|
+
zIndex: 3,
|
|
154
|
+
fontWeight: '500' as const,
|
|
155
|
+
color,
|
|
156
|
+
opacity: disabled ? 0.5 : 1,
|
|
157
|
+
variants: {
|
|
158
|
+
size: {
|
|
159
|
+
fontSize: theme.sizes.$tabBar.fontSize,
|
|
160
|
+
lineHeight: theme.sizes.$tabBar.lineHeight,
|
|
161
|
+
},
|
|
162
|
+
},
|
|
163
|
+
} as const;
|
|
164
|
+
},
|
|
165
|
+
|
|
166
|
+
tabIcon: ({ active = false, disabled = false, iconPosition = 'left' }: TabBarDynamicProps) => ({
|
|
167
|
+
display: 'flex' as const,
|
|
168
|
+
alignItems: 'center' as const,
|
|
169
|
+
justifyContent: 'center' as const,
|
|
170
|
+
opacity: disabled ? 0.5 : 1,
|
|
171
|
+
marginBottom: iconPosition === 'top' ? 2 : 0,
|
|
227
172
|
variants: {
|
|
228
|
-
type: {
|
|
229
|
-
standard: {},
|
|
230
|
-
pills: {
|
|
231
|
-
borderBottomWidth: 0,
|
|
232
|
-
padding: 4,
|
|
233
|
-
gap: 4,
|
|
234
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
235
|
-
overflow: 'hidden',
|
|
236
|
-
alignSelf: 'flex-start',
|
|
237
|
-
},
|
|
238
|
-
underline: {},
|
|
239
|
-
},
|
|
240
173
|
size: {
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
275
|
-
} as const,
|
|
276
|
-
compoundVariants: createContainerCompoundVariants(theme),
|
|
277
|
-
} as const;
|
|
278
|
-
}
|
|
279
|
-
|
|
280
|
-
const createTabStyles = (theme: Theme) => {
|
|
281
|
-
return {
|
|
282
|
-
display: 'flex',
|
|
283
|
-
flexDirection: 'row',
|
|
284
|
-
alignItems: 'center',
|
|
285
|
-
justifyContent: 'center',
|
|
286
|
-
fontWeight: '500',
|
|
287
|
-
color: theme.colors.text.secondary,
|
|
288
|
-
position: 'relative',
|
|
289
|
-
zIndex: 2,
|
|
290
|
-
backgroundColor: 'transparent',
|
|
291
|
-
gap: 6,
|
|
292
|
-
variants: {
|
|
293
|
-
size: createTabSizeVariants(theme),
|
|
294
|
-
type: {
|
|
295
|
-
standard: {},
|
|
296
|
-
pills: {
|
|
297
|
-
borderRadius: 9999,
|
|
298
|
-
marginRight: 0,
|
|
299
|
-
backgroundColor: 'transparent',
|
|
300
|
-
},
|
|
301
|
-
underline: {},
|
|
302
|
-
},
|
|
303
|
-
active: {
|
|
304
|
-
true: {
|
|
305
|
-
color: theme.colors.text.primary,
|
|
306
|
-
},
|
|
307
|
-
false: {},
|
|
308
|
-
},
|
|
309
|
-
disabled: {
|
|
310
|
-
true: {
|
|
311
|
-
opacity: 0.5,
|
|
312
|
-
_web: {
|
|
313
|
-
cursor: 'not-allowed',
|
|
314
|
-
},
|
|
315
|
-
},
|
|
316
|
-
false: {
|
|
317
|
-
_web: {
|
|
318
|
-
_hover: {
|
|
319
|
-
color: theme.colors.text.primary,
|
|
320
|
-
},
|
|
321
|
-
},
|
|
322
|
-
},
|
|
323
|
-
},
|
|
324
|
-
pillMode: {
|
|
325
|
-
light: {},
|
|
326
|
-
dark: {},
|
|
327
|
-
},
|
|
328
|
-
iconPosition: {
|
|
329
|
-
left: {
|
|
330
|
-
flexDirection: 'row',
|
|
331
|
-
},
|
|
332
|
-
top: {
|
|
333
|
-
flexDirection: 'column',
|
|
334
|
-
},
|
|
335
|
-
},
|
|
336
|
-
justify: {
|
|
337
|
-
start: {},
|
|
338
|
-
center: {},
|
|
339
|
-
equal: {
|
|
340
|
-
flex: 1,
|
|
341
|
-
},
|
|
342
|
-
'space-between': {},
|
|
343
|
-
},
|
|
344
|
-
} as const,
|
|
345
|
-
compoundVariants: createTabCompoundVariants(theme),
|
|
346
|
-
_web: {
|
|
347
|
-
border: 'none',
|
|
348
|
-
cursor: 'pointer',
|
|
349
|
-
outline: 'none',
|
|
350
|
-
transition: 'color 0.2s ease',
|
|
351
|
-
},
|
|
352
|
-
} as const;
|
|
353
|
-
}
|
|
354
|
-
|
|
355
|
-
const createTabLabelStyles = (theme: Theme) => {
|
|
356
|
-
return {
|
|
357
|
-
position: 'relative',
|
|
358
|
-
zIndex: 3,
|
|
359
|
-
fontWeight: '500',
|
|
360
|
-
color: theme.colors.text.secondary,
|
|
361
|
-
variants: {
|
|
362
|
-
size: createLabelSizeVariants(theme),
|
|
363
|
-
type: {
|
|
364
|
-
standard: {},
|
|
365
|
-
pills: {},
|
|
366
|
-
underline: {},
|
|
367
|
-
},
|
|
368
|
-
active: {
|
|
369
|
-
true: {
|
|
370
|
-
color: theme.colors.text.primary,
|
|
371
|
-
},
|
|
372
|
-
false: {},
|
|
373
|
-
},
|
|
374
|
-
disabled: {
|
|
375
|
-
true: {
|
|
376
|
-
opacity: 0.5,
|
|
377
|
-
},
|
|
378
|
-
false: {},
|
|
379
|
-
},
|
|
380
|
-
pillMode: {
|
|
381
|
-
light: {},
|
|
382
|
-
dark: {},
|
|
383
|
-
},
|
|
384
|
-
},
|
|
385
|
-
compoundVariants: createLabelCompoundVariants(theme),
|
|
386
|
-
} as const;
|
|
387
|
-
}
|
|
388
|
-
|
|
389
|
-
const createIndicatorStyles = (theme: Theme) => {
|
|
390
|
-
return {
|
|
391
|
-
position: 'absolute',
|
|
392
|
-
pointerEvents: 'none',
|
|
393
|
-
zIndex: 1,
|
|
394
|
-
variants: {
|
|
395
|
-
type: {
|
|
396
|
-
standard: {
|
|
397
|
-
bottom: -1,
|
|
398
|
-
height: 2,
|
|
399
|
-
backgroundColor: theme.intents.primary.primary,
|
|
400
|
-
},
|
|
401
|
-
pills: {
|
|
402
|
-
borderRadius: 9999,
|
|
403
|
-
bottom: 4,
|
|
404
|
-
top: 4,
|
|
405
|
-
left: 0,
|
|
406
|
-
},
|
|
407
|
-
underline: {
|
|
408
|
-
bottom: -1,
|
|
409
|
-
height: 2,
|
|
410
|
-
backgroundColor: theme.intents.primary.primary,
|
|
411
|
-
},
|
|
412
|
-
},
|
|
413
|
-
pillMode: {
|
|
414
|
-
light: {},
|
|
415
|
-
dark: {},
|
|
416
|
-
},
|
|
417
|
-
},
|
|
418
|
-
compoundVariants: createIndicatorCompoundVariants(theme),
|
|
419
|
-
_web: {
|
|
420
|
-
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
421
|
-
},
|
|
422
|
-
} as const;
|
|
423
|
-
}
|
|
424
|
-
|
|
425
|
-
/**
|
|
426
|
-
* Create size variants for icon
|
|
427
|
-
*/
|
|
428
|
-
function createIconSizeVariants(theme: Theme) {
|
|
429
|
-
return buildSizeVariants(theme, 'tabBar', (size) => ({
|
|
430
|
-
width: size.iconSize || size.fontSize,
|
|
431
|
-
height: size.iconSize || size.fontSize,
|
|
432
|
-
}));
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
const createIconStyles = (theme: Theme) => {
|
|
436
|
-
return {
|
|
437
|
-
display: 'flex',
|
|
438
|
-
alignItems: 'center',
|
|
439
|
-
justifyContent: 'center',
|
|
440
|
-
variants: {
|
|
441
|
-
size: createIconSizeVariants(theme),
|
|
442
|
-
active: {
|
|
443
|
-
true: {},
|
|
444
|
-
false: {},
|
|
445
|
-
},
|
|
446
|
-
disabled: {
|
|
447
|
-
true: {
|
|
448
|
-
opacity: 0.5,
|
|
449
|
-
},
|
|
450
|
-
false: {},
|
|
451
|
-
},
|
|
452
|
-
iconPosition: {
|
|
453
|
-
left: {},
|
|
454
|
-
top: {
|
|
455
|
-
marginBottom: 2,
|
|
456
|
-
},
|
|
457
|
-
},
|
|
458
|
-
} as const,
|
|
459
|
-
} as const;
|
|
460
|
-
}
|
|
461
|
-
|
|
462
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
463
|
-
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
464
|
-
export const tabBarStyles = StyleSheet.create((theme: Theme) => {
|
|
465
|
-
return {
|
|
466
|
-
container: createContainerStyles(theme),
|
|
467
|
-
tab: createTabStyles(theme),
|
|
468
|
-
tabLabel: createTabLabelStyles(theme),
|
|
469
|
-
tabIcon: createIconStyles(theme),
|
|
470
|
-
indicator: createIndicatorStyles(theme),
|
|
471
|
-
};
|
|
472
|
-
});
|
|
174
|
+
width: theme.sizes.$tabBar.fontSize,
|
|
175
|
+
height: theme.sizes.$tabBar.fontSize,
|
|
176
|
+
},
|
|
177
|
+
},
|
|
178
|
+
}),
|
|
179
|
+
|
|
180
|
+
indicator: ({ type = 'standard', pillMode = 'light' }: TabBarDynamicProps) => {
|
|
181
|
+
const backgroundColor = type === 'pills'
|
|
182
|
+
? (pillMode === 'dark' ? theme.colors.surface.secondary : theme.colors.surface.tertiary)
|
|
183
|
+
: theme.intents.primary.primary;
|
|
184
|
+
|
|
185
|
+
const typeStyles = type === 'pills' ? {
|
|
186
|
+
borderRadius: 9999,
|
|
187
|
+
bottom: 4,
|
|
188
|
+
top: 4,
|
|
189
|
+
left: 0,
|
|
190
|
+
} : {
|
|
191
|
+
bottom: -1,
|
|
192
|
+
height: 2,
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
return {
|
|
196
|
+
position: 'absolute' as const,
|
|
197
|
+
pointerEvents: 'none' as const,
|
|
198
|
+
zIndex: 1,
|
|
199
|
+
backgroundColor,
|
|
200
|
+
...typeStyles,
|
|
201
|
+
_web: {
|
|
202
|
+
transition: 'all 0.3s cubic-bezier(0.4, 0, 0.2, 1)',
|
|
203
|
+
},
|
|
204
|
+
} as const;
|
|
205
|
+
},
|
|
206
|
+
}));
|
|
473
207
|
|
|
474
208
|
// Export individual style sheets for backwards compatibility
|
|
475
|
-
export const tabBarContainerStyles =
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
export const tabBarTabStyles = StyleSheet.create((theme: Theme) => {
|
|
482
|
-
return {
|
|
483
|
-
tab: createTabStyles(theme),
|
|
484
|
-
} as const;
|
|
485
|
-
});
|
|
486
|
-
|
|
487
|
-
export const tabBarLabelStyles = StyleSheet.create((theme: Theme) => {
|
|
488
|
-
return {
|
|
489
|
-
tabLabel: createTabLabelStyles(theme),
|
|
490
|
-
} as const;
|
|
491
|
-
});
|
|
492
|
-
|
|
493
|
-
export const tabBarIndicatorStyles = StyleSheet.create((theme: Theme) => {
|
|
494
|
-
return {
|
|
495
|
-
indicator: createIndicatorStyles(theme),
|
|
496
|
-
} as const;
|
|
497
|
-
});
|
|
498
|
-
|
|
499
|
-
export const tabBarIconStyles = StyleSheet.create((theme: Theme) => {
|
|
500
|
-
return {
|
|
501
|
-
tabIcon: createIconStyles(theme),
|
|
502
|
-
} as const;
|
|
503
|
-
});
|
|
209
|
+
export const tabBarContainerStyles = tabBarStyles;
|
|
210
|
+
export const tabBarTabStyles = tabBarStyles;
|
|
211
|
+
export const tabBarLabelStyles = tabBarStyles;
|
|
212
|
+
export const tabBarIndicatorStyles = tabBarStyles;
|
|
213
|
+
export const tabBarIconStyles = tabBarStyles;
|