@idealyst/components 1.2.13 → 1.2.14
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/ActivityIndicator/ActivityIndicator.native.tsx +3 -3
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +3 -3
- package/src/Avatar/Avatar.native.tsx +1 -1
- package/src/Breadcrumb/Breadcrumb.native.tsx +20 -21
- package/src/Dialog/Dialog.native.tsx +2 -2
- package/src/Icon/types.ts +3 -0
- 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/TabBar/TabBar.native.tsx +2 -2
- package/src/index.native.ts +1 -1
- package/src/index.ts +1 -1
- 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
|
@@ -1,231 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles, Size } from '@idealyst/theme';
|
|
3
|
-
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
-
|
|
6
|
-
type BreadcrumbSize = Size;
|
|
7
|
-
type BreadcrumbIntent = 'primary' | 'neutral';
|
|
8
|
-
|
|
9
|
-
type BreadcrumbVariants = {
|
|
10
|
-
size: BreadcrumbSize;
|
|
11
|
-
intent: BreadcrumbIntent;
|
|
12
|
-
disabled: boolean;
|
|
13
|
-
isLast: boolean;
|
|
14
|
-
clickable: boolean;
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
export type ExpandedBreadcrumbStyles = StylesheetStyles<keyof BreadcrumbVariants>;
|
|
18
|
-
|
|
19
|
-
export type BreadcrumbStylesheet = {
|
|
20
|
-
container: ExpandedBreadcrumbStyles;
|
|
21
|
-
item: ExpandedBreadcrumbStyles;
|
|
22
|
-
itemText: ExpandedBreadcrumbStyles;
|
|
23
|
-
icon: ExpandedBreadcrumbStyles;
|
|
24
|
-
separator: ExpandedBreadcrumbStyles;
|
|
25
|
-
ellipsis: ExpandedBreadcrumbStyles;
|
|
26
|
-
ellipsisIcon: ExpandedBreadcrumbStyles;
|
|
27
|
-
menuButton: ExpandedBreadcrumbStyles;
|
|
28
|
-
menuButtonIcon: ExpandedBreadcrumbStyles;
|
|
29
|
-
}
|
|
30
|
-
|
|
31
|
-
type ItemTextDynamicProps = {
|
|
32
|
-
intent?: BreadcrumbIntent;
|
|
33
|
-
isLast?: boolean;
|
|
34
|
-
disabled?: boolean;
|
|
35
|
-
clickable?: boolean;
|
|
36
|
-
};
|
|
37
|
-
|
|
38
|
-
/**
|
|
39
|
-
* Create size variants for item text
|
|
40
|
-
*/
|
|
41
|
-
function createItemTextSizeVariants(theme: Theme) {
|
|
42
|
-
return buildSizeVariants(theme, 'breadcrumb', (size) => ({
|
|
43
|
-
fontSize: size.fontSize,
|
|
44
|
-
lineHeight: size.lineHeight,
|
|
45
|
-
}));
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Get item text color based on state
|
|
50
|
-
*/
|
|
51
|
-
function getItemTextColor(theme: Theme, intent: BreadcrumbIntent, isLast: boolean, disabled: boolean, clickable: boolean): string {
|
|
52
|
-
if (disabled) {
|
|
53
|
-
return theme.colors.text.secondary;
|
|
54
|
-
}
|
|
55
|
-
if (isLast) {
|
|
56
|
-
return theme.colors.text.primary;
|
|
57
|
-
}
|
|
58
|
-
if (clickable) {
|
|
59
|
-
return intent === 'primary' ? theme.intents.primary.primary : theme.colors.text.secondary;
|
|
60
|
-
}
|
|
61
|
-
return theme.colors.text.secondary;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
/**
|
|
65
|
-
* Create size variants for icons
|
|
66
|
-
*/
|
|
67
|
-
function createIconSizeVariants(theme: Theme) {
|
|
68
|
-
return buildSizeVariants(theme, 'breadcrumb', (size) => ({
|
|
69
|
-
width: size.iconSize,
|
|
70
|
-
height: size.iconSize,
|
|
71
|
-
}));
|
|
72
|
-
}
|
|
73
|
-
|
|
74
|
-
/**
|
|
75
|
-
* Get icon color based on intent
|
|
76
|
-
*/
|
|
77
|
-
function getIconColor(theme: Theme, intent: BreadcrumbIntent) {
|
|
78
|
-
if (intent === 'primary') {
|
|
79
|
-
return theme.intents.primary.primary;
|
|
80
|
-
}
|
|
81
|
-
return theme.colors.text.secondary;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
const createItemTextStyles = (theme: Theme) => {
|
|
85
|
-
return ({ intent = 'primary', isLast = false, disabled = false, clickable = true }: ItemTextDynamicProps) => {
|
|
86
|
-
const color = getItemTextColor(theme, intent, isLast, disabled, clickable);
|
|
87
|
-
return {
|
|
88
|
-
color,
|
|
89
|
-
opacity: disabled ? 0.5 : 1,
|
|
90
|
-
variants: {
|
|
91
|
-
size: createItemTextSizeVariants(theme),
|
|
92
|
-
},
|
|
93
|
-
} as const;
|
|
94
|
-
};
|
|
95
|
-
}
|
|
96
|
-
|
|
97
|
-
const createIconStyles = (theme: Theme) => {
|
|
98
|
-
return {
|
|
99
|
-
variants: {
|
|
100
|
-
size: createIconSizeVariants(theme),
|
|
101
|
-
},
|
|
102
|
-
} as const;
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
const createSeparatorStyles = (theme: Theme) => {
|
|
106
|
-
return {
|
|
107
|
-
color: theme.colors.text.tertiary,
|
|
108
|
-
variants: {
|
|
109
|
-
size: createItemTextSizeVariants(theme),
|
|
110
|
-
},
|
|
111
|
-
} as const;
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
const createEllipsisIconStyles = (theme: Theme) => {
|
|
115
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
116
|
-
return {
|
|
117
|
-
color: getIconColor(theme, intent),
|
|
118
|
-
variants: {
|
|
119
|
-
size: createIconSizeVariants(theme),
|
|
120
|
-
},
|
|
121
|
-
} as const;
|
|
122
|
-
}
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
const createMenuButtonIconStyles = (theme: Theme) => {
|
|
126
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
127
|
-
return {
|
|
128
|
-
color: getIconColor(theme, intent),
|
|
129
|
-
variants: {
|
|
130
|
-
size: createIconSizeVariants(theme),
|
|
131
|
-
},
|
|
132
|
-
} as const;
|
|
133
|
-
}
|
|
134
|
-
}
|
|
135
|
-
|
|
136
|
-
// Style creators for extension support
|
|
137
|
-
function createContainerStyles() {
|
|
138
|
-
return () => ({
|
|
139
|
-
display: 'flex' as const,
|
|
140
|
-
flexDirection: 'row' as const,
|
|
141
|
-
alignItems: 'center' as const,
|
|
142
|
-
flexWrap: 'wrap' as const,
|
|
143
|
-
gap: 8,
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
function createItemStyles() {
|
|
148
|
-
return () => ({
|
|
149
|
-
display: 'flex' as const,
|
|
150
|
-
flexDirection: 'row' as const,
|
|
151
|
-
alignItems: 'center' as const,
|
|
152
|
-
gap: 4,
|
|
153
|
-
});
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
157
|
-
export const breadcrumbStyles = StyleSheet.create((theme: Theme) => {
|
|
158
|
-
// Apply extensions to main visual elements
|
|
159
|
-
|
|
160
|
-
return applyExtensions('Breadcrumb', theme, {container: createContainerStyles(),
|
|
161
|
-
item: createItemStyles(),
|
|
162
|
-
itemText: createItemTextStyles(theme),
|
|
163
|
-
// Additional styles (merged from return)
|
|
164
|
-
// Minor utility styles (not extended)
|
|
165
|
-
icon: createIconStyles(theme),
|
|
166
|
-
separator: createSeparatorStyles(theme),
|
|
167
|
-
ellipsis: {
|
|
168
|
-
display: 'flex',
|
|
169
|
-
alignItems: 'center',
|
|
170
|
-
justifyContent: 'center',
|
|
171
|
-
},
|
|
172
|
-
ellipsisIcon: createEllipsisIconStyles(theme),
|
|
173
|
-
menuButton: {
|
|
174
|
-
paddingVertical: 4,
|
|
175
|
-
paddingHorizontal: 8,
|
|
176
|
-
},
|
|
177
|
-
menuButtonIcon: createMenuButtonIconStyles(theme)});
|
|
178
|
-
});
|
|
179
|
-
|
|
180
|
-
// Export individual style sheets for backwards compatibility
|
|
181
|
-
export const breadcrumbContainerStyles = StyleSheet.create((theme: Theme) => {
|
|
182
|
-
return {
|
|
183
|
-
container: {
|
|
184
|
-
display: 'flex',
|
|
185
|
-
flexDirection: 'row',
|
|
186
|
-
alignItems: 'center',
|
|
187
|
-
flexWrap: 'wrap',
|
|
188
|
-
gap: 8,
|
|
189
|
-
},
|
|
190
|
-
};
|
|
191
|
-
});
|
|
192
|
-
|
|
193
|
-
export const breadcrumbItemStyles = StyleSheet.create((theme: Theme) => {
|
|
194
|
-
return {
|
|
195
|
-
item: {
|
|
196
|
-
display: 'flex',
|
|
197
|
-
flexDirection: 'row',
|
|
198
|
-
alignItems: 'center',
|
|
199
|
-
gap: 4,
|
|
200
|
-
},
|
|
201
|
-
itemText: createItemTextStyles(theme),
|
|
202
|
-
icon: createIconStyles(theme),
|
|
203
|
-
} as const;
|
|
204
|
-
});
|
|
205
|
-
|
|
206
|
-
export const breadcrumbSeparatorStyles = StyleSheet.create((theme: Theme) => {
|
|
207
|
-
return {
|
|
208
|
-
separator: createSeparatorStyles(theme),
|
|
209
|
-
} as const;
|
|
210
|
-
});
|
|
211
|
-
|
|
212
|
-
export const breadcrumbEllipsisStyles = StyleSheet.create((theme: Theme) => {
|
|
213
|
-
return {
|
|
214
|
-
ellipsis: {
|
|
215
|
-
display: 'flex',
|
|
216
|
-
alignItems: 'center',
|
|
217
|
-
justifyContent: 'center',
|
|
218
|
-
},
|
|
219
|
-
icon: createEllipsisIconStyles(theme),
|
|
220
|
-
} as const;
|
|
221
|
-
});
|
|
222
|
-
|
|
223
|
-
export const breadcrumbMenuButtonStyles = StyleSheet.create((theme: Theme) => {
|
|
224
|
-
return {
|
|
225
|
-
button: {
|
|
226
|
-
paddingVertical: 4,
|
|
227
|
-
paddingHorizontal: 8,
|
|
228
|
-
},
|
|
229
|
-
icon: createMenuButtonIconStyles(theme),
|
|
230
|
-
} as const;
|
|
231
|
-
});
|
|
@@ -1,160 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, Intent, Radius } from '@idealyst/theme';
|
|
3
|
-
import {
|
|
4
|
-
buildGapVariants,
|
|
5
|
-
buildPaddingVariants,
|
|
6
|
-
buildPaddingVerticalVariants,
|
|
7
|
-
buildPaddingHorizontalVariants,
|
|
8
|
-
buildMarginVariants,
|
|
9
|
-
buildMarginVerticalVariants,
|
|
10
|
-
buildMarginHorizontalVariants,
|
|
11
|
-
} from '../utils/buildViewStyleVariants';
|
|
12
|
-
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
13
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
14
|
-
|
|
15
|
-
type CardType = 'outlined' | 'elevated' | 'filled';
|
|
16
|
-
type CardRadius = Radius;
|
|
17
|
-
type CardIntent = Intent | 'info' | 'neutral';
|
|
18
|
-
|
|
19
|
-
/**
|
|
20
|
-
* Get border radius value from theme
|
|
21
|
-
*/
|
|
22
|
-
export function getCardBorderRadius(theme: Theme, radius: CardRadius): number {
|
|
23
|
-
return theme.radii[radius];
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
export type CardVariants = {
|
|
27
|
-
type: CardType;
|
|
28
|
-
radius: CardRadius;
|
|
29
|
-
intent: CardIntent;
|
|
30
|
-
clickable: boolean;
|
|
31
|
-
disabled: boolean;
|
|
32
|
-
// Spacing variants from ContainerStyleProps
|
|
33
|
-
gap: ViewStyleSize;
|
|
34
|
-
padding: ViewStyleSize;
|
|
35
|
-
paddingVertical: ViewStyleSize;
|
|
36
|
-
paddingHorizontal: ViewStyleSize;
|
|
37
|
-
margin: ViewStyleSize;
|
|
38
|
-
marginVertical: ViewStyleSize;
|
|
39
|
-
marginHorizontal: ViewStyleSize;
|
|
40
|
-
};
|
|
41
|
-
|
|
42
|
-
type CardDynamicProps = {
|
|
43
|
-
intent?: CardIntent;
|
|
44
|
-
type?: CardType;
|
|
45
|
-
};
|
|
46
|
-
|
|
47
|
-
/**
|
|
48
|
-
* Get the border color based on intent (only used for outlined type)
|
|
49
|
-
*/
|
|
50
|
-
function getBorderColor(theme: Theme, intent: CardIntent): string {
|
|
51
|
-
if (intent === 'info' || intent === 'neutral') {
|
|
52
|
-
return theme.colors.border.secondary;
|
|
53
|
-
}
|
|
54
|
-
if (intent in theme.intents) {
|
|
55
|
-
return theme.intents[intent as Intent].primary;
|
|
56
|
-
}
|
|
57
|
-
return theme.colors.border.secondary;
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* Get type-specific styles
|
|
62
|
-
*/
|
|
63
|
-
function getTypeStyles(theme: Theme, type: CardType, intent: CardIntent) {
|
|
64
|
-
switch (type) {
|
|
65
|
-
case 'outlined':
|
|
66
|
-
return {
|
|
67
|
-
backgroundColor: 'transparent',
|
|
68
|
-
borderWidth: 1,
|
|
69
|
-
borderStyle: 'solid' as const,
|
|
70
|
-
borderColor: getBorderColor(theme, intent),
|
|
71
|
-
};
|
|
72
|
-
case 'elevated':
|
|
73
|
-
return {
|
|
74
|
-
backgroundColor: theme.colors.surface.primary,
|
|
75
|
-
borderWidth: 0,
|
|
76
|
-
...theme.shadows.md,
|
|
77
|
-
};
|
|
78
|
-
case 'filled':
|
|
79
|
-
return {
|
|
80
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
81
|
-
borderWidth: 0,
|
|
82
|
-
};
|
|
83
|
-
default:
|
|
84
|
-
return {};
|
|
85
|
-
}
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
/**
|
|
89
|
-
* Create dynamic card styles
|
|
90
|
-
*/
|
|
91
|
-
function createCardStyles(theme: Theme) {
|
|
92
|
-
return ({ intent = 'neutral', type = 'elevated' }: CardDynamicProps) => {
|
|
93
|
-
const typeStyles = getTypeStyles(theme, type, intent);
|
|
94
|
-
return {
|
|
95
|
-
...typeStyles,
|
|
96
|
-
position: 'relative',
|
|
97
|
-
overflow: 'hidden',
|
|
98
|
-
variants: {
|
|
99
|
-
radius: {
|
|
100
|
-
none: { borderRadius: 0 },
|
|
101
|
-
xs: { borderRadius: 2 },
|
|
102
|
-
sm: { borderRadius: 4 },
|
|
103
|
-
md: { borderRadius: 8 },
|
|
104
|
-
lg: { borderRadius: 12 },
|
|
105
|
-
xl: { borderRadius: 16 },
|
|
106
|
-
},
|
|
107
|
-
clickable: {
|
|
108
|
-
true: {
|
|
109
|
-
_web: {
|
|
110
|
-
cursor: 'pointer',
|
|
111
|
-
transition: 'all 0.2s ease',
|
|
112
|
-
_hover: {
|
|
113
|
-
transform: 'translateY(-2px)',
|
|
114
|
-
boxShadow:
|
|
115
|
-
'0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06)',
|
|
116
|
-
},
|
|
117
|
-
},
|
|
118
|
-
},
|
|
119
|
-
false: {
|
|
120
|
-
_web: {
|
|
121
|
-
cursor: 'default',
|
|
122
|
-
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
disabled: {
|
|
126
|
-
true: {
|
|
127
|
-
opacity: 0.6,
|
|
128
|
-
_web: {
|
|
129
|
-
cursor: 'not-allowed',
|
|
130
|
-
},
|
|
131
|
-
},
|
|
132
|
-
false: {
|
|
133
|
-
opacity: 1,
|
|
134
|
-
},
|
|
135
|
-
},
|
|
136
|
-
// Spacing variants from ContainerStyleProps
|
|
137
|
-
gap: buildGapVariants(theme),
|
|
138
|
-
padding: buildPaddingVariants(theme),
|
|
139
|
-
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
140
|
-
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
141
|
-
margin: buildMarginVariants(theme),
|
|
142
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
143
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
144
|
-
},
|
|
145
|
-
_web: {
|
|
146
|
-
display: 'flex',
|
|
147
|
-
flexDirection: 'column',
|
|
148
|
-
boxSizing: 'border-box',
|
|
149
|
-
},
|
|
150
|
-
} as const;
|
|
151
|
-
};
|
|
152
|
-
}
|
|
153
|
-
|
|
154
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
155
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
156
|
-
export const cardStyles = StyleSheet.create((theme: Theme) => {
|
|
157
|
-
return applyExtensions('Card', theme, {
|
|
158
|
-
card: createCardStyles(theme),
|
|
159
|
-
});
|
|
160
|
-
});
|
|
@@ -1,271 +0,0 @@
|
|
|
1
|
-
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles, Intent, Size } from '@idealyst/theme';
|
|
3
|
-
import {
|
|
4
|
-
buildMarginVariants,
|
|
5
|
-
buildMarginVerticalVariants,
|
|
6
|
-
buildMarginHorizontalVariants,
|
|
7
|
-
} from '../utils/buildViewStyleVariants';
|
|
8
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
9
|
-
|
|
10
|
-
type CheckboxSize = Size;
|
|
11
|
-
type CheckboxIntent = Intent | 'info';
|
|
12
|
-
type CheckboxType = 'default' | 'outlined';
|
|
13
|
-
|
|
14
|
-
type CheckboxVariants = {
|
|
15
|
-
size: CheckboxSize;
|
|
16
|
-
intent: CheckboxIntent;
|
|
17
|
-
type: CheckboxType;
|
|
18
|
-
checked: boolean;
|
|
19
|
-
disabled: boolean;
|
|
20
|
-
visible: boolean;
|
|
21
|
-
error: boolean;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
export type ExpandedCheckboxStyles = StylesheetStyles<keyof CheckboxVariants>;
|
|
25
|
-
|
|
26
|
-
export type CheckboxStylesheet = {
|
|
27
|
-
wrapper: ExpandedCheckboxStyles;
|
|
28
|
-
container: ExpandedCheckboxStyles;
|
|
29
|
-
checkbox: ExpandedCheckboxStyles;
|
|
30
|
-
label: ExpandedCheckboxStyles;
|
|
31
|
-
checkmark: ExpandedCheckboxStyles;
|
|
32
|
-
helperText: ExpandedCheckboxStyles;
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
/**
|
|
36
|
-
* Helper to get intent colors, mapping 'info' to 'primary'
|
|
37
|
-
*/
|
|
38
|
-
function getIntentColors(theme: Theme, intent: CheckboxIntent) {
|
|
39
|
-
const actualIntent = intent === 'info' ? 'primary' : intent;
|
|
40
|
-
return theme.intents[actualIntent as Intent];
|
|
41
|
-
}
|
|
42
|
-
|
|
43
|
-
/**
|
|
44
|
-
* Create size variants for checkbox
|
|
45
|
-
*/
|
|
46
|
-
function createCheckboxSizeVariants() {
|
|
47
|
-
return {
|
|
48
|
-
xs: { width: 14, height: 14 },
|
|
49
|
-
sm: { width: 16, height: 16 },
|
|
50
|
-
md: { width: 20, height: 20 },
|
|
51
|
-
lg: { width: 24, height: 24 },
|
|
52
|
-
xl: { width: 28, height: 28 },
|
|
53
|
-
} as const;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
/**
|
|
57
|
-
* Create type variants for checkbox
|
|
58
|
-
*/
|
|
59
|
-
function createCheckboxTypeVariants(theme: Theme) {
|
|
60
|
-
return {
|
|
61
|
-
default: {
|
|
62
|
-
borderWidth: 1,
|
|
63
|
-
borderColor: theme.colors.border.primary,
|
|
64
|
-
_web: {
|
|
65
|
-
border: `1px solid ${theme.colors.border.primary}`,
|
|
66
|
-
},
|
|
67
|
-
},
|
|
68
|
-
outlined: {
|
|
69
|
-
borderWidth: 2,
|
|
70
|
-
borderColor: theme.colors.border.primary,
|
|
71
|
-
_web: {
|
|
72
|
-
border: `2px solid ${theme.colors.border.primary}`,
|
|
73
|
-
},
|
|
74
|
-
},
|
|
75
|
-
} as const;
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
/**
|
|
79
|
-
* Create checked state variants dynamically based on intent
|
|
80
|
-
*/
|
|
81
|
-
function createCheckedVariants(theme: Theme, intent: CheckboxIntent) {
|
|
82
|
-
const colors = getIntentColors(theme, intent);
|
|
83
|
-
|
|
84
|
-
return {
|
|
85
|
-
true: {
|
|
86
|
-
backgroundColor: colors.primary,
|
|
87
|
-
borderColor: colors.primary,
|
|
88
|
-
_web: {
|
|
89
|
-
border: `1px solid ${colors.primary}`,
|
|
90
|
-
},
|
|
91
|
-
},
|
|
92
|
-
false: {
|
|
93
|
-
backgroundColor: 'transparent',
|
|
94
|
-
},
|
|
95
|
-
} as const;
|
|
96
|
-
}
|
|
97
|
-
|
|
98
|
-
/**
|
|
99
|
-
* Create size variants for label
|
|
100
|
-
*/
|
|
101
|
-
function createLabelSizeVariants() {
|
|
102
|
-
return {
|
|
103
|
-
xs: { fontSize: 12 },
|
|
104
|
-
sm: { fontSize: 14 },
|
|
105
|
-
md: { fontSize: 16 },
|
|
106
|
-
lg: { fontSize: 18 },
|
|
107
|
-
xl: { fontSize: 20 },
|
|
108
|
-
} as const;
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
/**
|
|
112
|
-
* Create size variants for checkmark
|
|
113
|
-
*/
|
|
114
|
-
function createCheckmarkSizeVariants() {
|
|
115
|
-
return {
|
|
116
|
-
xs: { width: 10, height: 10 },
|
|
117
|
-
sm: { width: 12, height: 12 },
|
|
118
|
-
md: { width: 14, height: 14 },
|
|
119
|
-
lg: { width: 16, height: 16 },
|
|
120
|
-
xl: { width: 20, height: 20 },
|
|
121
|
-
} as const;
|
|
122
|
-
}
|
|
123
|
-
|
|
124
|
-
function createCheckboxStyles(theme: Theme) {
|
|
125
|
-
return ({ intent }: Partial<CheckboxVariants>) => {
|
|
126
|
-
return {
|
|
127
|
-
alignItems: 'center',
|
|
128
|
-
justifyContent: 'center',
|
|
129
|
-
borderRadius: 4,
|
|
130
|
-
position: 'relative',
|
|
131
|
-
backgroundColor: 'transparent',
|
|
132
|
-
borderColor: theme.colors.border.primary,
|
|
133
|
-
variants: {
|
|
134
|
-
size: createCheckboxSizeVariants(),
|
|
135
|
-
type: createCheckboxTypeVariants(theme),
|
|
136
|
-
checked: createCheckedVariants(theme, intent),
|
|
137
|
-
disabled: {
|
|
138
|
-
true: {
|
|
139
|
-
opacity: 0.5,
|
|
140
|
-
_web: {
|
|
141
|
-
cursor: 'not-allowed',
|
|
142
|
-
},
|
|
143
|
-
},
|
|
144
|
-
false: {
|
|
145
|
-
opacity: 1,
|
|
146
|
-
_web: {
|
|
147
|
-
cursor: 'pointer',
|
|
148
|
-
_hover: { opacity: 0.8 },
|
|
149
|
-
_active: { opacity: 0.6 },
|
|
150
|
-
},
|
|
151
|
-
},
|
|
152
|
-
},
|
|
153
|
-
},
|
|
154
|
-
_web: {
|
|
155
|
-
outline: 'none',
|
|
156
|
-
display: 'flex',
|
|
157
|
-
boxSizing: 'border-box',
|
|
158
|
-
userSelect: 'none',
|
|
159
|
-
WebkitAppearance: 'none',
|
|
160
|
-
MozAppearance: 'none',
|
|
161
|
-
appearance: 'none',
|
|
162
|
-
transition: 'all 0.2s ease',
|
|
163
|
-
_focus: {
|
|
164
|
-
outline: `2px solid ${theme.intents.primary.primary}`,
|
|
165
|
-
outlineOffset: '2px',
|
|
166
|
-
},
|
|
167
|
-
},
|
|
168
|
-
} as const;
|
|
169
|
-
}
|
|
170
|
-
}
|
|
171
|
-
|
|
172
|
-
function createCheckmarkStyles(_theme: Theme) {
|
|
173
|
-
return () => ({
|
|
174
|
-
position: 'absolute' as const,
|
|
175
|
-
display: 'flex' as const,
|
|
176
|
-
alignItems: 'center' as const,
|
|
177
|
-
justifyContent: 'center' as const,
|
|
178
|
-
color: '#ffffff',
|
|
179
|
-
variants: {
|
|
180
|
-
size: createCheckmarkSizeVariants(),
|
|
181
|
-
visible: {
|
|
182
|
-
true: { opacity: 1 },
|
|
183
|
-
false: { opacity: 0 },
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
});
|
|
187
|
-
}
|
|
188
|
-
|
|
189
|
-
// Helper functions to create static styles wrapped in dynamic functions
|
|
190
|
-
function createWrapperStyles(theme: Theme) {
|
|
191
|
-
return () => ({
|
|
192
|
-
flexDirection: 'column' as const,
|
|
193
|
-
gap: 4,
|
|
194
|
-
variants: {
|
|
195
|
-
// Spacing variants from FormInputStyleProps
|
|
196
|
-
margin: buildMarginVariants(theme),
|
|
197
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
198
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
199
|
-
},
|
|
200
|
-
_web: {
|
|
201
|
-
display: 'flex',
|
|
202
|
-
flexDirection: 'column',
|
|
203
|
-
alignItems: 'flex-start',
|
|
204
|
-
width: 'auto',
|
|
205
|
-
},
|
|
206
|
-
});
|
|
207
|
-
}
|
|
208
|
-
|
|
209
|
-
function createContainerStyles() {
|
|
210
|
-
return () => ({
|
|
211
|
-
flexDirection: 'row' as const,
|
|
212
|
-
alignItems: 'center' as const,
|
|
213
|
-
gap: 8,
|
|
214
|
-
_web: {
|
|
215
|
-
display: 'flex',
|
|
216
|
-
flexDirection: 'row',
|
|
217
|
-
alignItems: 'center',
|
|
218
|
-
gap: 8,
|
|
219
|
-
width: 'fit-content',
|
|
220
|
-
cursor: 'pointer',
|
|
221
|
-
},
|
|
222
|
-
});
|
|
223
|
-
}
|
|
224
|
-
|
|
225
|
-
function createLabelStyles(theme: Theme) {
|
|
226
|
-
return () => ({
|
|
227
|
-
color: theme.colors.text.primary,
|
|
228
|
-
variants: {
|
|
229
|
-
size: createLabelSizeVariants(),
|
|
230
|
-
disabled: {
|
|
231
|
-
true: { opacity: 0.5 },
|
|
232
|
-
false: { opacity: 1 },
|
|
233
|
-
},
|
|
234
|
-
},
|
|
235
|
-
_web: {
|
|
236
|
-
display: 'block',
|
|
237
|
-
textAlign: 'left',
|
|
238
|
-
margin: 0,
|
|
239
|
-
padding: 0,
|
|
240
|
-
},
|
|
241
|
-
});
|
|
242
|
-
}
|
|
243
|
-
|
|
244
|
-
function createHelperTextStyles(theme: Theme) {
|
|
245
|
-
return () => ({
|
|
246
|
-
fontSize: 14,
|
|
247
|
-
color: theme.colors.text.secondary,
|
|
248
|
-
marginTop: 2,
|
|
249
|
-
variants: {
|
|
250
|
-
error: {
|
|
251
|
-
true: { color: theme.intents.error.primary },
|
|
252
|
-
false: { color: theme.colors.text.secondary },
|
|
253
|
-
},
|
|
254
|
-
},
|
|
255
|
-
});
|
|
256
|
-
}
|
|
257
|
-
|
|
258
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
259
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
260
|
-
export const checkboxStyles = StyleSheet.create((theme: Theme) => {
|
|
261
|
-
// Apply extensions to main visual elements
|
|
262
|
-
|
|
263
|
-
return applyExtensions('Checkbox', theme, {container: createContainerStyles(),
|
|
264
|
-
checkbox: createCheckboxStyles(theme),
|
|
265
|
-
checkmark: createCheckmarkStyles(theme),
|
|
266
|
-
// Additional styles (merged from return)
|
|
267
|
-
// Minor utility styles (not extended)
|
|
268
|
-
wrapper: createWrapperStyles(theme)(),
|
|
269
|
-
label: createLabelStyles(theme)(),
|
|
270
|
-
helperText: createHelperTextStyles(theme)()});
|
|
271
|
-
});
|