@idealyst/components 1.1.6 → 1.1.7
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 +15 -9
- package/src/Accordion/Accordion.styles.tsx +193 -168
- package/src/Accordion/Accordion.web.tsx +12 -7
- package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -2
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +22 -11
- package/src/ActivityIndicator/ActivityIndicator.web.tsx +2 -2
- package/src/Alert/Alert.native.tsx +11 -10
- package/src/Alert/Alert.styles.tsx +162 -253
- package/src/Alert/Alert.web.tsx +6 -10
- package/src/Avatar/Avatar.native.tsx +5 -2
- package/src/Avatar/Avatar.styles.tsx +48 -18
- package/src/Avatar/Avatar.web.tsx +2 -2
- package/src/Badge/Badge.native.tsx +2 -2
- package/src/Badge/Badge.styles.tsx +37 -16
- package/src/Badge/Badge.web.tsx +6 -6
- package/src/Breadcrumb/Breadcrumb.native.tsx +12 -5
- package/src/Breadcrumb/Breadcrumb.styles.tsx +59 -58
- package/src/Breadcrumb/Breadcrumb.web.tsx +13 -6
- package/src/Button/Button.native.tsx +39 -14
- package/src/Button/Button.styles.tsx +106 -208
- package/src/Button/Button.web.tsx +10 -8
- package/src/Card/Card.native.tsx +14 -6
- package/src/Card/Card.styles.tsx +64 -62
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +7 -3
- package/src/Checkbox/Checkbox.styles.tsx +49 -25
- package/src/Checkbox/Checkbox.web.tsx +3 -3
- package/src/Chip/Chip.native.tsx +5 -5
- package/src/Chip/Chip.styles.tsx +71 -21
- package/src/Chip/Chip.web.tsx +5 -5
- package/src/Dialog/Dialog.native.tsx +10 -4
- package/src/Dialog/Dialog.styles.tsx +130 -90
- package/src/Dialog/Dialog.web.tsx +4 -4
- package/src/Divider/Divider.native.tsx +29 -42
- package/src/Divider/Divider.styles.tsx +138 -242
- package/src/Divider/Divider.web.tsx +17 -14
- package/src/Icon/Icon.native.tsx +11 -3
- package/src/Icon/Icon.styles.tsx +10 -4
- package/src/Image/Image.styles.tsx +53 -37
- package/src/Input/Input.native.tsx +6 -7
- package/src/Input/Input.styles.tsx +194 -174
- package/src/Input/Input.web.tsx +5 -8
- package/src/Link/Link.native.tsx +4 -1
- package/src/List/List.styles.tsx +79 -105
- package/src/List/ListItem.native.tsx +5 -3
- package/src/List/ListItem.web.tsx +4 -3
- package/src/Menu/Menu.native.tsx +1 -1
- package/src/Menu/Menu.styles.tsx +53 -37
- package/src/Menu/Menu.web.tsx +2 -2
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.tsx +68 -69
- package/src/Menu/MenuItem.web.tsx +16 -3
- package/src/Popover/Popover.native.tsx +1 -1
- package/src/Popover/Popover.styles.tsx +40 -29
- package/src/Popover/Popover.web.tsx +1 -1
- package/src/Pressable/Pressable.native.tsx +3 -1
- package/src/Pressable/Pressable.styles.tsx +20 -13
- package/src/Pressable/Pressable.web.tsx +1 -1
- package/src/Progress/Progress.native.tsx +15 -6
- package/src/Progress/Progress.styles.tsx +125 -85
- package/src/Progress/Progress.web.tsx +10 -9
- package/src/RadioButton/RadioButton.native.tsx +8 -3
- package/src/RadioButton/RadioButton.styles.tsx +44 -37
- package/src/RadioButton/RadioButton.web.tsx +3 -3
- package/src/SVGImage/SVGImage.styles.tsx +28 -16
- package/src/Screen/Screen.native.tsx +23 -13
- package/src/Screen/Screen.styles.tsx +57 -46
- package/src/Screen/Screen.web.tsx +1 -1
- package/src/Select/Select.native.tsx +11 -5
- package/src/Select/Select.styles.tsx +72 -52
- package/src/Select/Select.web.tsx +5 -5
- package/src/Skeleton/Skeleton.styles.tsx +26 -14
- package/src/Slider/Slider.native.tsx +9 -5
- package/src/Slider/Slider.styles.tsx +59 -48
- package/src/Slider/Slider.web.tsx +5 -5
- package/src/Switch/Switch.native.tsx +6 -2
- package/src/Switch/Switch.styles.tsx +46 -19
- package/src/Switch/Switch.web.tsx +4 -4
- package/src/TabBar/TabBar.native.tsx +23 -31
- package/src/TabBar/TabBar.styles.tsx +215 -371
- package/src/TabBar/TabBar.web.tsx +21 -33
- package/src/Table/Table.native.tsx +1 -1
- package/src/Table/Table.styles.tsx +11 -4
- package/src/Table/Table.web.tsx +1 -1
- package/src/Text/Text.native.tsx +3 -4
- package/src/Text/Text.styles.tsx +7 -1
- package/src/Text/Text.web.tsx +1 -1
- package/src/TextArea/TextArea.styles.tsx +90 -58
- package/src/Tooltip/Tooltip.native.tsx +2 -2
- package/src/Tooltip/Tooltip.styles.tsx +21 -12
- package/src/Tooltip/Tooltip.web.tsx +2 -2
- package/src/Video/Video.styles.tsx +39 -23
- package/src/View/View.native.tsx +4 -2
- package/src/View/View.styles.tsx +33 -22
- package/src/View/View.web.tsx +13 -2
- package/src/extensions/applyExtension.ts +210 -0
- package/src/extensions/extendComponent.ts +377 -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
|
@@ -154,7 +154,7 @@ const Popover = forwardRef<View, PopoverProps>(({
|
|
|
154
154
|
left={popoverPosition.left}
|
|
155
155
|
width={Math.min(popoverPosition.width || 200, maxPopoverWidth)}
|
|
156
156
|
maxHeight={500}
|
|
157
|
-
style={[popoverStyles.container, style]}
|
|
157
|
+
style={[(popoverStyles.container as any)({}), style]}
|
|
158
158
|
onLayout={handlePopoverLayout}
|
|
159
159
|
{...nativeA11yProps}
|
|
160
160
|
>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, StylesheetStyles} from '@idealyst/theme';
|
|
2
|
+
import { Theme, StylesheetStyles } from '@idealyst/theme';
|
|
3
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
3
4
|
|
|
4
5
|
type PopoverPlacement = 'top' | 'top-start' | 'top-end' | 'bottom' | 'bottom-start' | 'bottom-end' | 'left' | 'left-start' | 'left-end' | 'right' | 'right-start' | 'right-end';
|
|
5
6
|
|
|
@@ -81,17 +82,14 @@ function createArrowPlacementVariants(theme: Theme) {
|
|
|
81
82
|
};
|
|
82
83
|
}
|
|
83
84
|
|
|
84
|
-
//
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
export const popoverStyles = StyleSheet.create((theme: Theme) => {
|
|
88
|
-
return {
|
|
89
|
-
container: {
|
|
85
|
+
// Style creators for extension support
|
|
86
|
+
function createContainerStyles(theme: Theme) {
|
|
87
|
+
return () => ({
|
|
90
88
|
backgroundColor: theme.colors.surface.primary,
|
|
91
89
|
borderRadius: 8,
|
|
92
90
|
borderWidth: 1,
|
|
93
91
|
borderColor: theme.colors.border.primary,
|
|
94
|
-
borderStyle: 'solid',
|
|
92
|
+
borderStyle: 'solid' as const,
|
|
95
93
|
shadowColor: '#000',
|
|
96
94
|
shadowOffset: { width: 0, height: 4 },
|
|
97
95
|
shadowOpacity: 0.1,
|
|
@@ -103,26 +101,39 @@ export const popoverStyles = StyleSheet.create((theme: Theme) => {
|
|
|
103
101
|
transition: 'opacity 150ms ease-out, transform 150ms ease-out',
|
|
104
102
|
transformOrigin: 'center center',
|
|
105
103
|
},
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
108
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
109
|
+
export const popoverStyles = StyleSheet.create((theme: Theme) => {
|
|
110
|
+
// Apply extensions to main visual elements
|
|
111
|
+
const extended = applyExtensions('Popover', theme, {
|
|
112
|
+
container: createContainerStyles(theme),
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
return {
|
|
116
|
+
...extended,
|
|
117
|
+
// Minor utility styles (not extended)
|
|
118
|
+
content: {
|
|
119
|
+
padding: 16,
|
|
117
120
|
},
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
121
|
+
arrow: {
|
|
122
|
+
position: 'absolute',
|
|
123
|
+
width: 12,
|
|
124
|
+
height: 12,
|
|
125
|
+
backgroundColor: theme.colors.surface.primary,
|
|
126
|
+
variants: {
|
|
127
|
+
placement: createArrowPlacementVariants(theme),
|
|
128
|
+
},
|
|
129
|
+
_web: {
|
|
130
|
+
transform: 'rotate(45deg)',
|
|
131
|
+
boxShadow: '-2px 2px 4px rgba(0, 0, 0, 0.1)',
|
|
132
|
+
},
|
|
133
|
+
},
|
|
134
|
+
backdrop: {
|
|
135
|
+
flex: 1,
|
|
136
|
+
backgroundColor: 'transparent',
|
|
137
|
+
},
|
|
138
|
+
};
|
|
128
139
|
});
|
|
@@ -44,7 +44,7 @@ const Popover = forwardRef<HTMLDivElement, PopoverProps>(({
|
|
|
44
44
|
|
|
45
45
|
popoverStyles.useVariants({});
|
|
46
46
|
|
|
47
|
-
const containerProps = getWebProps([popoverStyles.container]);
|
|
47
|
+
const containerProps = getWebProps([(popoverStyles.container as any)({})]);
|
|
48
48
|
const contentProps = getWebProps([popoverStyles.content]);
|
|
49
49
|
|
|
50
50
|
const mergedPopoverRef = useMergeRefs(ref, popoverRef);
|
|
@@ -26,6 +26,8 @@ const Pressable = forwardRef<View, PressableProps>(({
|
|
|
26
26
|
paddingHorizontal,
|
|
27
27
|
});
|
|
28
28
|
|
|
29
|
+
const pressableStyle = (pressableStyles.pressable as any)({});
|
|
30
|
+
|
|
29
31
|
return (
|
|
30
32
|
<TouchableWithoutFeedback
|
|
31
33
|
onPress={disabled ? undefined : onPress}
|
|
@@ -35,7 +37,7 @@ const Pressable = forwardRef<View, PressableProps>(({
|
|
|
35
37
|
testID={testID}
|
|
36
38
|
accessibilityLabel={accessibilityLabel}
|
|
37
39
|
>
|
|
38
|
-
<View ref={ref} nativeID={id} style={[
|
|
40
|
+
<View ref={ref} nativeID={id} style={[pressableStyle, style]}>
|
|
39
41
|
{children}
|
|
40
42
|
</View>
|
|
41
43
|
</TouchableWithoutFeedback>
|
|
@@ -5,20 +5,27 @@ import {
|
|
|
5
5
|
buildPaddingVerticalVariants,
|
|
6
6
|
buildPaddingHorizontalVariants,
|
|
7
7
|
} from '../utils/buildViewStyleVariants';
|
|
8
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
8
9
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
};
|
|
10
|
+
// Style creators for extension support
|
|
11
|
+
function createPressableStyles(theme: Theme) {
|
|
12
|
+
return () => ({
|
|
13
|
+
variants: {
|
|
14
|
+
// Spacing variants from PressableSpacingStyleProps
|
|
15
|
+
padding: buildPaddingVariants(theme),
|
|
16
|
+
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
17
|
+
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
18
|
+
},
|
|
19
|
+
});
|
|
20
|
+
}
|
|
19
21
|
|
|
20
22
|
export const pressableStyles = StyleSheet.create((theme: Theme) => {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
23
|
+
// Apply extensions to main visual elements
|
|
24
|
+
const extended = applyExtensions('Pressable', theme, {
|
|
25
|
+
pressable: createPressableStyles(theme),
|
|
26
|
+
});
|
|
27
|
+
|
|
28
|
+
return {
|
|
29
|
+
...extended,
|
|
30
|
+
};
|
|
24
31
|
});
|
|
@@ -54,7 +54,7 @@ const Pressable = forwardRef<HTMLDivElement, PressableProps>(({
|
|
|
54
54
|
paddingHorizontal,
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
-
const webProps = getWebProps([pressableStyles.pressable, style as any]);
|
|
57
|
+
const webProps = getWebProps([(pressableStyles.pressable as any)({}), style as any]);
|
|
58
58
|
|
|
59
59
|
const baseStyle: React.CSSProperties = {
|
|
60
60
|
cursor: disabled ? 'default' : 'pointer',
|
|
@@ -34,13 +34,18 @@ const Progress = forwardRef<View, ProgressProps>(({
|
|
|
34
34
|
const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
|
|
35
35
|
const { theme }: { theme: Theme } = useUnistyles();
|
|
36
36
|
|
|
37
|
-
// Apply variants
|
|
37
|
+
// Apply variants (for size and rounded)
|
|
38
38
|
progressStyles.useVariants({
|
|
39
39
|
size,
|
|
40
|
-
intent,
|
|
41
40
|
rounded,
|
|
42
41
|
});
|
|
43
42
|
|
|
43
|
+
// Compute dynamic styles with intent
|
|
44
|
+
const dynamicProps = { intent };
|
|
45
|
+
const linearBarStyle = (progressStyles.linearBar as any)(dynamicProps);
|
|
46
|
+
const indeterminateBarStyle = (progressStyles.indeterminateBar as any)(dynamicProps);
|
|
47
|
+
const circularBarStyle = (progressStyles.circularBar as any)(dynamicProps);
|
|
48
|
+
|
|
44
49
|
// Animation values
|
|
45
50
|
const animatedValue = useSharedValue(0);
|
|
46
51
|
const slideAnimation = useSharedValue(0);
|
|
@@ -157,13 +162,17 @@ const Progress = forwardRef<View, ProgressProps>(({
|
|
|
157
162
|
};
|
|
158
163
|
});
|
|
159
164
|
|
|
165
|
+
// Get dynamic styles for extended styles
|
|
166
|
+
const containerStyle = (progressStyles.container as any)({});
|
|
167
|
+
const linearTrackStyle = (progressStyles.linearTrack as any)({});
|
|
168
|
+
|
|
160
169
|
return (
|
|
161
|
-
<View ref={ref} nativeID={id} style={[
|
|
162
|
-
<View style={
|
|
170
|
+
<View ref={ref} nativeID={id} style={[containerStyle, style]} testID={testID} accessibilityRole="progressbar">
|
|
171
|
+
<View style={linearTrackStyle}>
|
|
163
172
|
{indeterminate ? (
|
|
164
|
-
<Animated.View style={[
|
|
173
|
+
<Animated.View style={[indeterminateBarStyle, indeterminateAnimatedStyle]} />
|
|
165
174
|
) : (
|
|
166
|
-
<Animated.View style={[
|
|
175
|
+
<Animated.View style={[linearBarStyle, barAnimatedStyle]} />
|
|
167
176
|
)}
|
|
168
177
|
</View>
|
|
169
178
|
{showLabel && (
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import { Theme, Intent, Size
|
|
2
|
+
import { Theme, Intent, Size } from '@idealyst/theme';
|
|
3
3
|
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
4
5
|
|
|
5
6
|
type ProgressSize = Size;
|
|
6
7
|
type ProgressIntent = Intent;
|
|
@@ -11,6 +12,10 @@ export type ProgressVariants = {
|
|
|
11
12
|
rounded: boolean;
|
|
12
13
|
}
|
|
13
14
|
|
|
15
|
+
type ProgressDynamicProps = {
|
|
16
|
+
intent?: ProgressIntent;
|
|
17
|
+
};
|
|
18
|
+
|
|
14
19
|
function createLinearTrackSizeVariants(theme: Theme) {
|
|
15
20
|
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
16
21
|
height: size.linearHeight,
|
|
@@ -36,58 +41,81 @@ function createCircularLabelSizeVariants(theme: Theme) {
|
|
|
36
41
|
}));
|
|
37
42
|
}
|
|
38
43
|
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
return variants;
|
|
44
|
+
/**
|
|
45
|
+
* Get bar background color based on intent
|
|
46
|
+
*/
|
|
47
|
+
function getBarBackgroundColor(theme: Theme, intent: ProgressIntent): string {
|
|
48
|
+
return theme.intents[intent].primary;
|
|
45
49
|
}
|
|
46
50
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
intent,
|
|
55
|
-
|
|
56
|
-
|
|
51
|
+
/**
|
|
52
|
+
* Create dynamic linear bar styles
|
|
53
|
+
*/
|
|
54
|
+
function createLinearBarStyles(theme: Theme) {
|
|
55
|
+
return ({ intent = 'primary' }: ProgressDynamicProps) => {
|
|
56
|
+
return {
|
|
57
|
+
height: '100%' as const,
|
|
58
|
+
backgroundColor: getBarBackgroundColor(theme, intent),
|
|
59
|
+
variants: {
|
|
60
|
+
rounded: {
|
|
61
|
+
true: { borderRadius: 9999 },
|
|
62
|
+
false: { borderRadius: 0 },
|
|
63
|
+
},
|
|
57
64
|
},
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
65
|
+
_web: {
|
|
66
|
+
transition: 'width 0.3s ease' as const,
|
|
67
|
+
},
|
|
68
|
+
} as const;
|
|
69
|
+
};
|
|
62
70
|
}
|
|
63
71
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
72
|
+
/**
|
|
73
|
+
* Create dynamic indeterminate bar styles
|
|
74
|
+
*/
|
|
75
|
+
function createIndeterminateBarStyles(theme: Theme) {
|
|
76
|
+
return ({ intent = 'primary' }: ProgressDynamicProps) => {
|
|
77
|
+
return {
|
|
78
|
+
position: 'absolute' as const,
|
|
79
|
+
height: '100%' as const,
|
|
80
|
+
width: '40%' as const,
|
|
81
|
+
backgroundColor: getBarBackgroundColor(theme, intent),
|
|
82
|
+
variants: {
|
|
83
|
+
rounded: {
|
|
84
|
+
true: { borderRadius: 9999 },
|
|
85
|
+
false: { borderRadius: 0 },
|
|
75
86
|
},
|
|
76
87
|
},
|
|
77
|
-
}
|
|
78
|
-
}
|
|
88
|
+
} as const;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
79
91
|
|
|
80
|
-
|
|
92
|
+
/**
|
|
93
|
+
* Create dynamic circular bar styles
|
|
94
|
+
*/
|
|
95
|
+
function createCircularBarStyles(theme: Theme) {
|
|
96
|
+
return ({ intent = 'primary' }: ProgressDynamicProps) => {
|
|
97
|
+
return {
|
|
98
|
+
_web: {
|
|
99
|
+
stroke: getBarBackgroundColor(theme, intent),
|
|
100
|
+
},
|
|
101
|
+
} as const;
|
|
102
|
+
};
|
|
81
103
|
}
|
|
82
104
|
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
105
|
+
/**
|
|
106
|
+
* Create container styles
|
|
107
|
+
*/
|
|
108
|
+
function createContainerStyles() {
|
|
109
|
+
return () => ({
|
|
88
110
|
gap: 4 as const,
|
|
89
|
-
}
|
|
90
|
-
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create linear track styles
|
|
116
|
+
*/
|
|
117
|
+
function createLinearTrackStyles(theme: Theme) {
|
|
118
|
+
return () => ({
|
|
91
119
|
backgroundColor: theme.colors.border.secondary,
|
|
92
120
|
overflow: 'hidden' as const,
|
|
93
121
|
position: 'relative' as const,
|
|
@@ -98,67 +126,79 @@ export const progressStyles = StyleSheet.create((theme: Theme) => {
|
|
|
98
126
|
false: { borderRadius: 0 },
|
|
99
127
|
},
|
|
100
128
|
},
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
},
|
|
110
|
-
},
|
|
111
|
-
compoundVariants: createLinearBarCompoundVariants(theme),
|
|
112
|
-
_web: {
|
|
113
|
-
transition: 'width 0.3s ease' as const,
|
|
114
|
-
},
|
|
115
|
-
},
|
|
116
|
-
indeterminateBar: {
|
|
117
|
-
position: 'absolute' as const,
|
|
118
|
-
height: '100%' as const,
|
|
119
|
-
width: '40%' as const,
|
|
120
|
-
variants: {
|
|
121
|
-
intent: createIntentVariants(theme),
|
|
122
|
-
rounded: {
|
|
123
|
-
true: { borderRadius: 9999 },
|
|
124
|
-
false: { borderRadius: 0 },
|
|
125
|
-
},
|
|
126
|
-
},
|
|
127
|
-
compoundVariants: createLinearBarCompoundVariants(theme),
|
|
128
|
-
},
|
|
129
|
-
circularContainer: {
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Create circular container styles
|
|
134
|
+
*/
|
|
135
|
+
function createCircularContainerStyles(theme: Theme) {
|
|
136
|
+
return () => ({
|
|
130
137
|
alignItems: 'center' as const,
|
|
131
138
|
justifyContent: 'center' as const,
|
|
132
139
|
position: 'relative' as const,
|
|
133
140
|
variants: {
|
|
134
141
|
size: createCircularContainerSizeVariants(theme),
|
|
135
142
|
} as const,
|
|
136
|
-
}
|
|
137
|
-
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Create circular track styles
|
|
148
|
+
*/
|
|
149
|
+
function createCircularTrackStyles(theme: Theme) {
|
|
150
|
+
return () => ({
|
|
138
151
|
_web: {
|
|
139
152
|
stroke: theme.colors.border.secondary,
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
circularBar: {
|
|
143
|
-
variants: {
|
|
144
|
-
intent: createIntentVariants(theme),
|
|
145
153
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Create label styles
|
|
159
|
+
*/
|
|
160
|
+
function createLabelStyles(theme: Theme) {
|
|
161
|
+
return () => ({
|
|
149
162
|
color: theme.colors.text.primary,
|
|
150
163
|
textAlign: 'center' as const,
|
|
151
164
|
variants: {
|
|
152
165
|
size: createLabelSizeVariants(theme),
|
|
153
166
|
},
|
|
154
|
-
}
|
|
155
|
-
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Create circular label styles
|
|
172
|
+
*/
|
|
173
|
+
function createCircularLabelStyles(theme: Theme) {
|
|
174
|
+
return () => ({
|
|
156
175
|
position: 'absolute' as const,
|
|
157
176
|
fontWeight: '600' as const,
|
|
158
177
|
color: theme.colors.text.primary,
|
|
159
178
|
variants: {
|
|
160
179
|
size: createCircularLabelSizeVariants(theme),
|
|
161
180
|
},
|
|
162
|
-
}
|
|
181
|
+
});
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
185
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
186
|
+
export const progressStyles = StyleSheet.create((theme: Theme) => {
|
|
187
|
+
// Apply extensions to main visual elements
|
|
188
|
+
const extended = applyExtensions('Progress', theme, {
|
|
189
|
+
container: createContainerStyles(),
|
|
190
|
+
linearTrack: createLinearTrackStyles(theme),
|
|
191
|
+
linearBar: createLinearBarStyles(theme),
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
return {
|
|
195
|
+
...extended,
|
|
196
|
+
// Minor utility styles (not extended)
|
|
197
|
+
indeterminateBar: createIndeterminateBarStyles(theme),
|
|
198
|
+
circularContainer: createCircularContainerStyles(theme)(),
|
|
199
|
+
circularTrack: createCircularTrackStyles(theme)(),
|
|
200
|
+
circularBar: createCircularBarStyles(theme),
|
|
201
|
+
label: createLabelStyles(theme)(),
|
|
202
|
+
circularLabel: createCircularLabelStyles(theme)(),
|
|
163
203
|
};
|
|
164
|
-
});
|
|
204
|
+
});
|
|
@@ -19,18 +19,20 @@ const Progress: React.FC<ProgressProps> = ({
|
|
|
19
19
|
}) => {
|
|
20
20
|
const percentage = Math.min(Math.max((value / max) * 100, 0), 100);
|
|
21
21
|
|
|
22
|
-
// Apply variants
|
|
22
|
+
// Apply variants (for size and rounded)
|
|
23
23
|
progressStyles.useVariants({
|
|
24
24
|
size,
|
|
25
|
-
intent,
|
|
26
25
|
rounded,
|
|
27
26
|
});
|
|
28
27
|
|
|
29
|
-
|
|
30
|
-
const
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
const
|
|
28
|
+
// Compute dynamic styles with intent
|
|
29
|
+
const dynamicProps = { intent };
|
|
30
|
+
|
|
31
|
+
// Linear progress
|
|
32
|
+
const containerProps = getWebProps([(progressStyles.container as any)({}), style as any]);
|
|
33
|
+
const trackProps = getWebProps([(progressStyles.linearTrack as any)({})]);
|
|
34
|
+
const barProps = getWebProps([(progressStyles.linearBar as any)(dynamicProps), { width: `${percentage}%` }]);
|
|
35
|
+
const indeterminateProps = getWebProps([(progressStyles.indeterminateBar as any)(dynamicProps)]);
|
|
34
36
|
const labelProps = getWebProps([progressStyles.label]);
|
|
35
37
|
|
|
36
38
|
const getCircularSize = () => {
|
|
@@ -53,8 +55,7 @@ const Progress: React.FC<ProgressProps> = ({
|
|
|
53
55
|
]);
|
|
54
56
|
const labelProps = getWebProps([progressStyles.circularLabel]);
|
|
55
57
|
const trackColorProps = getWebProps([progressStyles.circularTrack]);
|
|
56
|
-
const barColorProps = getWebProps([progressStyles.circularBar]);
|
|
57
|
-
console.log(trackColorProps)
|
|
58
|
+
const barColorProps = getWebProps([(progressStyles.circularBar as any)(dynamicProps)]);
|
|
58
59
|
|
|
59
60
|
return (
|
|
60
61
|
<div {...computedContainerProps} id={id} data-testid={testID}>
|
|
@@ -101,20 +101,25 @@ const RadioButton = forwardRef<ComponentRef<typeof Pressable>, RadioButtonProps>
|
|
|
101
101
|
outputRange: [0, 1],
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
// Get dynamic styles
|
|
105
|
+
const containerStyle = (radioButtonStyles.container as any)({});
|
|
106
|
+
const radioStyle = (radioButtonStyles.radio as any)({ intent });
|
|
107
|
+
const radioDotStyle = (radioButtonStyles.radioDot as any)({ intent });
|
|
108
|
+
|
|
104
109
|
return (
|
|
105
110
|
<Pressable
|
|
106
111
|
ref={ref}
|
|
107
112
|
nativeID={id}
|
|
108
113
|
onPress={handlePress}
|
|
109
114
|
disabled={disabled}
|
|
110
|
-
style={[
|
|
115
|
+
style={[containerStyle, style]}
|
|
111
116
|
testID={testID}
|
|
112
117
|
{...nativeA11yProps}
|
|
113
118
|
>
|
|
114
|
-
<View style={
|
|
119
|
+
<View style={radioStyle}>
|
|
115
120
|
<Animated.View
|
|
116
121
|
style={[
|
|
117
|
-
|
|
122
|
+
radioDotStyle,
|
|
118
123
|
{
|
|
119
124
|
transform: [{ scale: dotScale }],
|
|
120
125
|
},
|
|
@@ -6,6 +6,7 @@ import {
|
|
|
6
6
|
buildMarginVerticalVariants,
|
|
7
7
|
buildMarginHorizontalVariants,
|
|
8
8
|
} from '../utils/buildViewStyleVariants';
|
|
9
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
9
10
|
|
|
10
11
|
type RadioButtonSize = Size;
|
|
11
12
|
type RadioButtonIntent = Intent;
|
|
@@ -117,56 +118,62 @@ function createRadioDotStyles(theme: Theme) {
|
|
|
117
118
|
}
|
|
118
119
|
}
|
|
119
120
|
|
|
120
|
-
//
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
flexDirection: 'row',
|
|
126
|
-
alignItems: 'center',
|
|
121
|
+
// Container style creator for extension support
|
|
122
|
+
function createContainerStyles(theme: Theme) {
|
|
123
|
+
return () => ({
|
|
124
|
+
flexDirection: 'row' as const,
|
|
125
|
+
alignItems: 'center' as const,
|
|
127
126
|
paddingVertical: 4,
|
|
128
127
|
variants: {
|
|
129
128
|
size: buildSizeVariants(theme, 'radioButton', (size) => ({
|
|
130
129
|
gap: size.gap,
|
|
131
130
|
})),
|
|
132
|
-
// Spacing variants from FormInputStyleProps
|
|
133
131
|
margin: buildMarginVariants(theme),
|
|
134
132
|
marginVertical: buildMarginVerticalVariants(theme),
|
|
135
133
|
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
136
134
|
} as const,
|
|
137
|
-
}
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
135
|
+
});
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
139
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
140
|
+
export const radioButtonStyles = StyleSheet.create((theme: Theme) => {
|
|
141
|
+
// Apply extensions to main visual elements
|
|
142
|
+
const extended = applyExtensions('RadioButton', theme, {
|
|
143
|
+
container: createContainerStyles(theme),
|
|
144
|
+
radio: createRadioStyles(theme),
|
|
145
|
+
radioDot: createRadioDotStyles(theme),
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
return {
|
|
149
|
+
...extended,
|
|
150
|
+
// Minor utility styles
|
|
151
|
+
label: {
|
|
152
|
+
color: theme.colors.text.primary,
|
|
153
|
+
variants: {
|
|
154
|
+
size: buildSizeVariants(theme, 'radioButton', (size) => ({
|
|
155
|
+
fontSize: size.fontSize,
|
|
156
|
+
})),
|
|
157
|
+
disabled: {
|
|
158
|
+
true: { opacity: 0.5 },
|
|
159
|
+
false: { opacity: 1 },
|
|
152
160
|
},
|
|
153
161
|
},
|
|
154
162
|
},
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
groupContainer: {
|
|
164
|
+
gap: 4,
|
|
165
|
+
variants: {
|
|
166
|
+
orientation: {
|
|
167
|
+
horizontal: {
|
|
168
|
+
flexDirection: 'row',
|
|
169
|
+
flexWrap: 'wrap',
|
|
170
|
+
gap: 16,
|
|
171
|
+
},
|
|
172
|
+
vertical: {
|
|
173
|
+
flexDirection: 'column',
|
|
174
|
+
},
|
|
167
175
|
},
|
|
168
176
|
},
|
|
169
177
|
},
|
|
170
|
-
}
|
|
171
|
-
};
|
|
178
|
+
};
|
|
172
179
|
});
|