@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,24 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Pressable styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
buildPaddingVerticalVariants,
|
|
6
|
-
buildPaddingHorizontalVariants,
|
|
7
|
-
} from '../utils/buildViewStyleVariants';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme } from '@idealyst/theme';
|
|
7
|
+
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
8
8
|
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
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
|
+
export type PressableDynamicProps = {
|
|
16
|
+
padding?: ViewStyleSize;
|
|
17
|
+
paddingVertical?: ViewStyleSize;
|
|
18
|
+
paddingHorizontal?: ViewStyleSize;
|
|
18
19
|
};
|
|
19
20
|
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
21
|
+
/**
|
|
22
|
+
* Pressable styles with spacing variants.
|
|
23
|
+
*/
|
|
24
|
+
export const pressableStyles = defineStyle('Pressable', (theme: Theme) => ({
|
|
25
|
+
pressable: (_props: PressableDynamicProps) => ({
|
|
26
|
+
variants: {
|
|
27
|
+
// $iterator expands for each view size
|
|
28
|
+
padding: {
|
|
29
|
+
padding: theme.sizes.$view.padding,
|
|
30
|
+
},
|
|
31
|
+
paddingVertical: {
|
|
32
|
+
paddingVertical: theme.sizes.$view.padding,
|
|
33
|
+
},
|
|
34
|
+
paddingHorizontal: {
|
|
35
|
+
paddingHorizontal: theme.sizes.$view.padding,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
}),
|
|
39
|
+
}));
|
|
@@ -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 && (
|
|
@@ -0,0 +1,200 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, Intent, Size } from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
+
|
|
6
|
+
type ProgressSize = Size;
|
|
7
|
+
type ProgressIntent = Intent;
|
|
8
|
+
|
|
9
|
+
export type ProgressVariants = {
|
|
10
|
+
size: ProgressSize;
|
|
11
|
+
intent: ProgressIntent;
|
|
12
|
+
rounded: boolean;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
type ProgressDynamicProps = {
|
|
16
|
+
intent?: ProgressIntent;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
function createLinearTrackSizeVariants(theme: Theme) {
|
|
20
|
+
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
21
|
+
height: size.linearHeight,
|
|
22
|
+
}));
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function createCircularContainerSizeVariants(theme: Theme) {
|
|
26
|
+
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
27
|
+
width: size.circularSize,
|
|
28
|
+
height: size.circularSize,
|
|
29
|
+
}));
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
function createLabelSizeVariants(theme: Theme) {
|
|
33
|
+
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
34
|
+
fontSize: size.labelFontSize,
|
|
35
|
+
}));
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
function createCircularLabelSizeVariants(theme: Theme) {
|
|
39
|
+
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
40
|
+
fontSize: size.circularLabelFontSize,
|
|
41
|
+
}));
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Get bar background color based on intent
|
|
46
|
+
*/
|
|
47
|
+
function getBarBackgroundColor(theme: Theme, intent: ProgressIntent): string {
|
|
48
|
+
return theme.intents[intent].primary;
|
|
49
|
+
}
|
|
50
|
+
|
|
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
|
+
},
|
|
64
|
+
},
|
|
65
|
+
_web: {
|
|
66
|
+
transition: 'width 0.3s ease' as const,
|
|
67
|
+
},
|
|
68
|
+
} as const;
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
|
|
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 },
|
|
86
|
+
},
|
|
87
|
+
},
|
|
88
|
+
} as const;
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
|
|
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
|
+
};
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* Create container styles
|
|
107
|
+
*/
|
|
108
|
+
function createContainerStyles() {
|
|
109
|
+
return () => ({
|
|
110
|
+
gap: 4 as const,
|
|
111
|
+
});
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
/**
|
|
115
|
+
* Create linear track styles
|
|
116
|
+
*/
|
|
117
|
+
function createLinearTrackStyles(theme: Theme) {
|
|
118
|
+
return () => ({
|
|
119
|
+
backgroundColor: theme.colors.border.secondary,
|
|
120
|
+
overflow: 'hidden' as const,
|
|
121
|
+
position: 'relative' as const,
|
|
122
|
+
variants: {
|
|
123
|
+
size: createLinearTrackSizeVariants(theme),
|
|
124
|
+
rounded: {
|
|
125
|
+
true: { borderRadius: 9999 },
|
|
126
|
+
false: { borderRadius: 0 },
|
|
127
|
+
},
|
|
128
|
+
},
|
|
129
|
+
});
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Create circular container styles
|
|
134
|
+
*/
|
|
135
|
+
function createCircularContainerStyles(theme: Theme) {
|
|
136
|
+
return () => ({
|
|
137
|
+
alignItems: 'center' as const,
|
|
138
|
+
justifyContent: 'center' as const,
|
|
139
|
+
position: 'relative' as const,
|
|
140
|
+
variants: {
|
|
141
|
+
size: createCircularContainerSizeVariants(theme),
|
|
142
|
+
} as const,
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
/**
|
|
147
|
+
* Create circular track styles
|
|
148
|
+
*/
|
|
149
|
+
function createCircularTrackStyles(theme: Theme) {
|
|
150
|
+
return () => ({
|
|
151
|
+
_web: {
|
|
152
|
+
stroke: theme.colors.border.secondary,
|
|
153
|
+
},
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/**
|
|
158
|
+
* Create label styles
|
|
159
|
+
*/
|
|
160
|
+
function createLabelStyles(theme: Theme) {
|
|
161
|
+
return () => ({
|
|
162
|
+
color: theme.colors.text.primary,
|
|
163
|
+
textAlign: 'center' as const,
|
|
164
|
+
variants: {
|
|
165
|
+
size: createLabelSizeVariants(theme),
|
|
166
|
+
},
|
|
167
|
+
});
|
|
168
|
+
}
|
|
169
|
+
|
|
170
|
+
/**
|
|
171
|
+
* Create circular label styles
|
|
172
|
+
*/
|
|
173
|
+
function createCircularLabelStyles(theme: Theme) {
|
|
174
|
+
return () => ({
|
|
175
|
+
position: 'absolute' as const,
|
|
176
|
+
fontWeight: '600' as const,
|
|
177
|
+
color: theme.colors.text.primary,
|
|
178
|
+
variants: {
|
|
179
|
+
size: createCircularLabelSizeVariants(theme),
|
|
180
|
+
},
|
|
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
|
+
|
|
189
|
+
return applyExtensions('Progress', theme, {container: createContainerStyles(),
|
|
190
|
+
linearTrack: createLinearTrackStyles(theme),
|
|
191
|
+
linearBar: createLinearBarStyles(theme),
|
|
192
|
+
// Additional styles (merged from return)
|
|
193
|
+
// Minor utility styles (not extended)
|
|
194
|
+
indeterminateBar: createIndeterminateBarStyles(theme),
|
|
195
|
+
circularContainer: createCircularContainerStyles(theme)(),
|
|
196
|
+
circularTrack: createCircularTrackStyles(theme)(),
|
|
197
|
+
circularBar: createCircularBarStyles(theme),
|
|
198
|
+
label: createLabelStyles(theme)(),
|
|
199
|
+
circularLabel: createCircularLabelStyles(theme)()});
|
|
200
|
+
});
|
|
@@ -1,164 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Progress styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
width: size.circularSize,
|
|
23
|
-
height: size.circularSize,
|
|
24
|
-
}));
|
|
25
|
-
}
|
|
26
|
-
|
|
27
|
-
function createLabelSizeVariants(theme: Theme) {
|
|
28
|
-
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
29
|
-
fontSize: size.labelFontSize,
|
|
30
|
-
}));
|
|
31
|
-
}
|
|
32
|
-
|
|
33
|
-
function createCircularLabelSizeVariants(theme: Theme) {
|
|
34
|
-
return buildSizeVariants(theme, 'progress', (size) => ({
|
|
35
|
-
fontSize: size.circularLabelFontSize,
|
|
36
|
-
}));
|
|
37
|
-
}
|
|
38
|
-
|
|
39
|
-
function createIntentVariants(theme: Theme) {
|
|
40
|
-
const variants: any = {};
|
|
41
|
-
for (const intent in theme.intents) {
|
|
42
|
-
variants[intent] = {};
|
|
43
|
-
}
|
|
44
|
-
return variants;
|
|
45
|
-
}
|
|
46
|
-
|
|
47
|
-
function createLinearBarCompoundVariants(theme: Theme) {
|
|
48
|
-
const compoundVariants: CompoundVariants<keyof ProgressVariants> = [];
|
|
49
|
-
|
|
50
|
-
for (const intent in theme.intents) {
|
|
51
|
-
const intentValue = theme.intents[intent as Intent];
|
|
52
|
-
|
|
53
|
-
compoundVariants.push({
|
|
54
|
-
intent,
|
|
55
|
-
styles: {
|
|
56
|
-
backgroundColor: intentValue.primary,
|
|
57
|
-
},
|
|
58
|
-
});
|
|
59
|
-
}
|
|
60
|
-
|
|
61
|
-
return compoundVariants;
|
|
62
|
-
}
|
|
63
|
-
|
|
64
|
-
function createCircularBarCompoundVariants(theme: Theme) {
|
|
65
|
-
const compoundVariants: CompoundVariants<keyof ProgressVariants> = [];
|
|
66
|
-
|
|
67
|
-
for (const intent in theme.intents) {
|
|
68
|
-
const intentValue = theme.intents[intent as Intent];
|
|
69
|
-
|
|
70
|
-
compoundVariants.push({
|
|
71
|
-
intent,
|
|
72
|
-
styles: {
|
|
73
|
-
_web: {
|
|
74
|
-
stroke: intentValue.primary,
|
|
75
|
-
},
|
|
76
|
-
},
|
|
77
|
-
});
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
return compoundVariants;
|
|
81
|
-
}
|
|
82
|
-
|
|
83
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
84
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
85
|
-
export const progressStyles = StyleSheet.create((theme: Theme) => {
|
|
86
|
-
return {
|
|
87
|
-
container: {
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Intent, Size } from '@idealyst/theme';
|
|
7
|
+
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
10
|
+
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
13
|
+
|
|
14
|
+
export type ProgressDynamicProps = {
|
|
15
|
+
size?: Size;
|
|
16
|
+
intent?: Intent;
|
|
17
|
+
rounded?: boolean;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Progress styles with intent-based coloring.
|
|
22
|
+
*/
|
|
23
|
+
export const progressStyles = defineStyle('Progress', (theme: Theme) => ({
|
|
24
|
+
container: (_props: ProgressDynamicProps) => ({
|
|
88
25
|
gap: 4 as const,
|
|
89
|
-
},
|
|
90
|
-
|
|
26
|
+
}),
|
|
27
|
+
|
|
28
|
+
linearTrack: (_props: ProgressDynamicProps) => ({
|
|
91
29
|
backgroundColor: theme.colors.border.secondary,
|
|
92
30
|
overflow: 'hidden' as const,
|
|
93
31
|
position: 'relative' as const,
|
|
94
32
|
variants: {
|
|
95
|
-
size
|
|
33
|
+
// $iterator expands for each progress size
|
|
34
|
+
size: {
|
|
35
|
+
height: theme.sizes.$progress.linearHeight,
|
|
36
|
+
},
|
|
96
37
|
rounded: {
|
|
97
38
|
true: { borderRadius: 9999 },
|
|
98
39
|
false: { borderRadius: 0 },
|
|
99
40
|
},
|
|
100
41
|
},
|
|
101
|
-
},
|
|
102
|
-
|
|
42
|
+
}),
|
|
43
|
+
|
|
44
|
+
linearBar: ({ intent = 'primary' }: ProgressDynamicProps) => ({
|
|
103
45
|
height: '100%' as const,
|
|
46
|
+
backgroundColor: theme.intents[intent].primary,
|
|
104
47
|
variants: {
|
|
105
|
-
intent: createIntentVariants(theme),
|
|
106
48
|
rounded: {
|
|
107
49
|
true: { borderRadius: 9999 },
|
|
108
50
|
false: { borderRadius: 0 },
|
|
109
51
|
},
|
|
110
52
|
},
|
|
111
|
-
compoundVariants: createLinearBarCompoundVariants(theme),
|
|
112
53
|
_web: {
|
|
113
54
|
transition: 'width 0.3s ease' as const,
|
|
114
55
|
},
|
|
115
|
-
},
|
|
116
|
-
|
|
56
|
+
}),
|
|
57
|
+
|
|
58
|
+
indeterminateBar: ({ intent = 'primary' }: ProgressDynamicProps) => ({
|
|
117
59
|
position: 'absolute' as const,
|
|
118
60
|
height: '100%' as const,
|
|
119
61
|
width: '40%' as const,
|
|
62
|
+
backgroundColor: theme.intents[intent].primary,
|
|
120
63
|
variants: {
|
|
121
|
-
intent: createIntentVariants(theme),
|
|
122
64
|
rounded: {
|
|
123
65
|
true: { borderRadius: 9999 },
|
|
124
66
|
false: { borderRadius: 0 },
|
|
125
67
|
},
|
|
126
68
|
},
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
circularContainer: {
|
|
69
|
+
}),
|
|
70
|
+
|
|
71
|
+
circularContainer: (_props: ProgressDynamicProps) => ({
|
|
130
72
|
alignItems: 'center' as const,
|
|
131
73
|
justifyContent: 'center' as const,
|
|
132
74
|
position: 'relative' as const,
|
|
133
75
|
variants: {
|
|
134
|
-
size:
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
76
|
+
size: {
|
|
77
|
+
width: theme.sizes.$progress.circularSize,
|
|
78
|
+
height: theme.sizes.$progress.circularSize,
|
|
79
|
+
},
|
|
80
|
+
},
|
|
81
|
+
}),
|
|
82
|
+
|
|
83
|
+
circularTrack: (_props: ProgressDynamicProps) => ({
|
|
138
84
|
_web: {
|
|
139
85
|
stroke: theme.colors.border.secondary,
|
|
140
|
-
}
|
|
141
|
-
},
|
|
142
|
-
circularBar: {
|
|
143
|
-
variants: {
|
|
144
|
-
intent: createIntentVariants(theme),
|
|
145
86
|
},
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
87
|
+
}),
|
|
88
|
+
|
|
89
|
+
circularBar: ({ intent = 'primary' }: ProgressDynamicProps) => ({
|
|
90
|
+
_web: {
|
|
91
|
+
stroke: theme.intents[intent].primary,
|
|
92
|
+
},
|
|
93
|
+
}),
|
|
94
|
+
|
|
95
|
+
label: (_props: ProgressDynamicProps) => ({
|
|
149
96
|
color: theme.colors.text.primary,
|
|
150
97
|
textAlign: 'center' as const,
|
|
151
98
|
variants: {
|
|
152
|
-
size:
|
|
99
|
+
size: {
|
|
100
|
+
fontSize: theme.sizes.$progress.labelFontSize,
|
|
101
|
+
},
|
|
153
102
|
},
|
|
154
|
-
},
|
|
155
|
-
|
|
103
|
+
}),
|
|
104
|
+
|
|
105
|
+
circularLabel: (_props: ProgressDynamicProps) => ({
|
|
156
106
|
position: 'absolute' as const,
|
|
157
107
|
fontWeight: '600' as const,
|
|
158
108
|
color: theme.colors.text.primary,
|
|
159
109
|
variants: {
|
|
160
|
-
size:
|
|
110
|
+
size: {
|
|
111
|
+
fontSize: theme.sizes.$progress.circularLabelFontSize,
|
|
112
|
+
},
|
|
161
113
|
},
|
|
162
|
-
},
|
|
163
|
-
|
|
164
|
-
});
|
|
114
|
+
}),
|
|
115
|
+
}));
|
|
@@ -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,26 @@ const RadioButton = forwardRef<ComponentRef<typeof Pressable>, RadioButtonProps>
|
|
|
101
101
|
outputRange: [0, 1],
|
|
102
102
|
});
|
|
103
103
|
|
|
104
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
105
|
+
const containerStyle = (radioButtonStyles.container as any)({});
|
|
106
|
+
const radioStyle = (radioButtonStyles.radio as any)({ intent, checked, disabled });
|
|
107
|
+
const radioDotStyle = (radioButtonStyles.radioDot as any)({ intent });
|
|
108
|
+
const labelStyle = (radioButtonStyles.label as any)({ disabled });
|
|
109
|
+
|
|
104
110
|
return (
|
|
105
111
|
<Pressable
|
|
106
112
|
ref={ref}
|
|
107
113
|
nativeID={id}
|
|
108
114
|
onPress={handlePress}
|
|
109
115
|
disabled={disabled}
|
|
110
|
-
style={[
|
|
116
|
+
style={[containerStyle, style]}
|
|
111
117
|
testID={testID}
|
|
112
118
|
{...nativeA11yProps}
|
|
113
119
|
>
|
|
114
|
-
<View style={
|
|
120
|
+
<View style={radioStyle}>
|
|
115
121
|
<Animated.View
|
|
116
122
|
style={[
|
|
117
|
-
|
|
123
|
+
radioDotStyle,
|
|
118
124
|
{
|
|
119
125
|
transform: [{ scale: dotScale }],
|
|
120
126
|
},
|
|
@@ -122,7 +128,7 @@ const RadioButton = forwardRef<ComponentRef<typeof Pressable>, RadioButtonProps>
|
|
|
122
128
|
/>
|
|
123
129
|
</View>
|
|
124
130
|
{label && (
|
|
125
|
-
<Text style={
|
|
131
|
+
<Text style={labelStyle}>
|
|
126
132
|
{label}
|
|
127
133
|
</Text>
|
|
128
134
|
)}
|