@idealyst/components 1.1.7 → 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 +3 -3
- package/src/Accordion/Accordion.native.tsx +8 -6
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +102 -236
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
- package/src/Alert/Alert.native.tsx +16 -6
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +67 -149
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +35 -80
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +61 -121
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
- package/src/Breadcrumb/Breadcrumb.web.tsx +28 -23
- package/src/Button/Button.styles.tsx +89 -141
- package/src/Card/Card.native.tsx +7 -11
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +105 -142
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +9 -5
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +104 -216
- package/src/Checkbox/Checkbox.web.tsx +6 -6
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -72
- package/src/Dialog/Dialog.native.tsx +7 -4
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +69 -133
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +62 -84
- package/src/Icon/Icon.native.tsx +8 -8
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -66
- 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 +46 -60
- package/src/Input/Input.native.tsx +138 -53
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +127 -198
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +179 -215
- package/src/List/ListItem.native.tsx +12 -6
- package/src/List/ListItem.web.tsx +23 -13
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +68 -150
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +57 -89
- package/src/Menu/MenuItem.web.tsx +8 -3
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +51 -112
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -27
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +75 -164
- package/src/RadioButton/RadioButton.native.tsx +4 -3
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +83 -154
- package/src/RadioButton/RadioButton.web.tsx +2 -2
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -78
- package/src/Screen/Screen.native.tsx +18 -25
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +105 -67
- package/src/Screen/Screen.web.tsx +1 -1
- package/src/Select/Select.native.tsx +42 -33
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +223 -292
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +29 -53
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +153 -234
- package/src/Switch/Switch.native.tsx +7 -5
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +101 -174
- package/src/Switch/Switch.web.tsx +5 -5
- package/src/TabBar/TabBar.native.tsx +3 -2
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +145 -279
- package/src/Table/Table.native.tsx +18 -9
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +152 -286
- package/src/Text/Text.native.tsx +1 -3
- 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 -84
- 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 +93 -181
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +32 -56
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -44
- package/src/View/View.native.tsx +12 -14
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +76 -106
- package/src/View/View.web.tsx +1 -0
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/extendComponent.ts +61 -0
package/src/Card/Card.styles.tsx
CHANGED
|
@@ -1,160 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Card styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
buildGapVariants,
|
|
5
|
-
buildPaddingVariants,
|
|
6
|
-
buildPaddingVerticalVariants,
|
|
7
|
-
buildPaddingHorizontalVariants,
|
|
8
|
-
buildMarginVariants,
|
|
9
|
-
buildMarginVerticalVariants,
|
|
10
|
-
buildMarginHorizontalVariants,
|
|
11
|
-
} from '../utils/buildViewStyleVariants';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Intent, Radius } from '@idealyst/theme';
|
|
12
7
|
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
13
|
-
|
|
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
14
|
|
|
15
15
|
type CardType = 'outlined' | 'elevated' | 'filled';
|
|
16
|
-
type CardRadius = Radius;
|
|
17
16
|
type CardIntent = Intent | 'info' | 'neutral';
|
|
18
17
|
|
|
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
18
|
export type CardVariants = {
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
marginHorizontal: ViewStyleSize;
|
|
19
|
+
type: CardType;
|
|
20
|
+
radius: Radius;
|
|
21
|
+
intent: CardIntent;
|
|
22
|
+
clickable: boolean;
|
|
23
|
+
disabled: boolean;
|
|
24
|
+
gap: ViewStyleSize;
|
|
25
|
+
padding: ViewStyleSize;
|
|
26
|
+
paddingVertical: ViewStyleSize;
|
|
27
|
+
paddingHorizontal: ViewStyleSize;
|
|
28
|
+
margin: ViewStyleSize;
|
|
29
|
+
marginVertical: ViewStyleSize;
|
|
30
|
+
marginHorizontal: ViewStyleSize;
|
|
40
31
|
};
|
|
41
32
|
|
|
42
|
-
type CardDynamicProps = {
|
|
43
|
-
|
|
44
|
-
|
|
33
|
+
export type CardDynamicProps = {
|
|
34
|
+
intent?: CardIntent;
|
|
35
|
+
type?: CardType;
|
|
45
36
|
};
|
|
46
37
|
|
|
47
38
|
/**
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
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
|
|
39
|
+
* Card styles with dynamic type/intent handling.
|
|
40
|
+
*
|
|
41
|
+
* NOTE: Top-level theme access required for Unistyles reactivity.
|
|
62
42
|
*/
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
borderWidth: 1,
|
|
69
|
-
borderStyle: 'solid' as const,
|
|
70
|
-
borderColor: getBorderColor(theme, intent),
|
|
71
|
-
};
|
|
72
|
-
case 'elevated':
|
|
73
|
-
return {
|
|
43
|
+
export const cardStyles = defineStyle('Card', (theme: Theme) => ({
|
|
44
|
+
card: (_props: CardDynamicProps) => ({
|
|
45
|
+
position: 'relative' as const,
|
|
46
|
+
overflow: 'hidden' as const,
|
|
47
|
+
// Theme marker for Unistyles reactivity
|
|
74
48
|
backgroundColor: theme.colors.surface.primary,
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
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
|
-
},
|
|
49
|
+
borderColor: theme.colors.border.secondary,
|
|
50
|
+
variants: {
|
|
51
|
+
type: {
|
|
52
|
+
outlined: {
|
|
53
|
+
backgroundColor: 'transparent',
|
|
54
|
+
borderWidth: 1,
|
|
55
|
+
borderStyle: 'solid' as const,
|
|
56
|
+
},
|
|
57
|
+
elevated: {
|
|
58
|
+
backgroundColor: theme.colors.surface.primary,
|
|
59
|
+
borderWidth: 0,
|
|
60
|
+
...theme.shadows.md,
|
|
61
|
+
},
|
|
62
|
+
filled: {
|
|
63
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
64
|
+
borderWidth: 0,
|
|
65
|
+
},
|
|
117
66
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
67
|
+
radius: {
|
|
68
|
+
none: { borderRadius: 0 },
|
|
69
|
+
xs: { borderRadius: 2 },
|
|
70
|
+
sm: { borderRadius: 4 },
|
|
71
|
+
md: { borderRadius: 8 },
|
|
72
|
+
lg: { borderRadius: 12 },
|
|
73
|
+
xl: { borderRadius: 16 },
|
|
74
|
+
},
|
|
75
|
+
clickable: {
|
|
76
|
+
true: {
|
|
77
|
+
_web: {
|
|
78
|
+
cursor: 'pointer',
|
|
79
|
+
transition: 'all 0.2s ease',
|
|
80
|
+
_hover: {
|
|
81
|
+
transform: 'translateY(-2px)',
|
|
82
|
+
boxShadow: '0 4px 12px rgba(0, 0, 0, 0.08), 0 2px 4px rgba(0, 0, 0, 0.06)',
|
|
83
|
+
},
|
|
84
|
+
},
|
|
85
|
+
},
|
|
86
|
+
false: {
|
|
87
|
+
_web: { cursor: 'default' },
|
|
88
|
+
},
|
|
89
|
+
},
|
|
90
|
+
disabled: {
|
|
91
|
+
true: { opacity: 0.6, _web: { cursor: 'not-allowed' } },
|
|
92
|
+
false: { opacity: 1 },
|
|
93
|
+
},
|
|
94
|
+
// $iterator expands for each view size
|
|
95
|
+
gap: {
|
|
96
|
+
gap: theme.sizes.$view.spacing,
|
|
97
|
+
},
|
|
98
|
+
padding: {
|
|
99
|
+
padding: theme.sizes.$view.padding,
|
|
100
|
+
},
|
|
101
|
+
paddingVertical: {
|
|
102
|
+
paddingVertical: theme.sizes.$view.padding,
|
|
103
|
+
},
|
|
104
|
+
paddingHorizontal: {
|
|
105
|
+
paddingHorizontal: theme.sizes.$view.padding,
|
|
106
|
+
},
|
|
107
|
+
margin: {
|
|
108
|
+
margin: theme.sizes.$view.padding,
|
|
109
|
+
},
|
|
110
|
+
marginVertical: {
|
|
111
|
+
marginVertical: theme.sizes.$view.padding,
|
|
112
|
+
},
|
|
113
|
+
marginHorizontal: {
|
|
114
|
+
marginHorizontal: theme.sizes.$view.padding,
|
|
115
|
+
},
|
|
122
116
|
},
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
disabled: {
|
|
126
|
-
true: {
|
|
127
|
-
opacity: 0.6,
|
|
128
117
|
_web: {
|
|
129
|
-
|
|
118
|
+
display: 'flex',
|
|
119
|
+
flexDirection: 'column',
|
|
120
|
+
boxSizing: 'border-box',
|
|
130
121
|
},
|
|
131
|
-
|
|
132
|
-
|
|
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
|
-
});
|
|
122
|
+
}),
|
|
123
|
+
}));
|
package/src/Card/Card.web.tsx
CHANGED
|
@@ -49,10 +49,11 @@ const Card = forwardRef<HTMLDivElement | HTMLButtonElement, CardProps>(({
|
|
|
49
49
|
}
|
|
50
50
|
};
|
|
51
51
|
|
|
52
|
-
// Apply variants
|
|
52
|
+
// Apply variants
|
|
53
53
|
cardStyles.useVariants({
|
|
54
|
-
|
|
54
|
+
type,
|
|
55
55
|
radius,
|
|
56
|
+
clickable,
|
|
56
57
|
disabled,
|
|
57
58
|
gap,
|
|
58
59
|
padding,
|
|
@@ -63,8 +64,8 @@ const Card = forwardRef<HTMLDivElement | HTMLButtonElement, CardProps>(({
|
|
|
63
64
|
marginHorizontal,
|
|
64
65
|
});
|
|
65
66
|
|
|
66
|
-
// Get
|
|
67
|
-
const cardStyle = (cardStyles.card as any)({
|
|
67
|
+
// Get card style
|
|
68
|
+
const cardStyle = (cardStyles.card as any)({});
|
|
68
69
|
|
|
69
70
|
// Generate web props
|
|
70
71
|
const webProps = getWebProps([cardStyle, style as any]);
|
|
@@ -99,12 +99,16 @@ const Checkbox = forwardRef<View, CheckboxProps>(({
|
|
|
99
99
|
const labelContent = children || label;
|
|
100
100
|
const displayHelperText = error || helperText;
|
|
101
101
|
|
|
102
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
103
|
+
const wrapperStyle = (checkboxStyles.wrapper as any)({});
|
|
102
104
|
const containerStyle = (checkboxStyles.container as any)({});
|
|
103
|
-
const checkboxStyle = (checkboxStyles.checkbox as any)({ intent });
|
|
104
|
-
const checkmarkStyle = (checkboxStyles.checkmark as any)({});
|
|
105
|
+
const checkboxStyle = (checkboxStyles.checkbox as any)({ intent, checked: internalChecked, disabled, type: variant });
|
|
106
|
+
const checkmarkStyle = (checkboxStyles.checkmark as any)({ checked: internalChecked });
|
|
107
|
+
const labelStyle = (checkboxStyles.label as any)({ disabled });
|
|
108
|
+
const helperTextStyle = (checkboxStyles.helperText as any)({ error: !!error });
|
|
105
109
|
|
|
106
110
|
return (
|
|
107
|
-
<View ref={ref} nativeID={id} style={[
|
|
111
|
+
<View ref={ref} nativeID={id} style={[wrapperStyle, style]}>
|
|
108
112
|
<Pressable
|
|
109
113
|
onPress={handlePress}
|
|
110
114
|
disabled={disabled}
|
|
@@ -123,13 +127,13 @@ const Checkbox = forwardRef<View, CheckboxProps>(({
|
|
|
123
127
|
)}
|
|
124
128
|
</View>
|
|
125
129
|
{labelContent && (
|
|
126
|
-
<Text style={
|
|
130
|
+
<Text style={labelStyle}>
|
|
127
131
|
{labelContent}
|
|
128
132
|
</Text>
|
|
129
133
|
)}
|
|
130
134
|
</Pressable>
|
|
131
135
|
{displayHelperText && (
|
|
132
|
-
<Text style={
|
|
136
|
+
<Text style={helperTextStyle}>
|
|
133
137
|
{error || helperText}
|
|
134
138
|
</Text>
|
|
135
139
|
)}
|
|
@@ -0,0 +1,271 @@
|
|
|
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
|
+
});
|