@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
|
@@ -1,207 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Switch styles using defineStyle with dynamic props.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
buildMarginVariants,
|
|
6
|
-
buildMarginVerticalVariants,
|
|
7
|
-
buildMarginHorizontalVariants,
|
|
8
|
-
} from '../utils/buildViewStyleVariants';
|
|
9
|
-
import { SwitchIntentVariant, SwitchSizeVariant } from './types';
|
|
10
|
-
import { applyExtensions } from '../extensions/applyExtension';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Intent, Size } from '@idealyst/theme';
|
|
7
|
+
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
11
8
|
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
width: size.trackWidth,
|
|
15
|
-
height: size.trackHeight,
|
|
16
|
-
}));
|
|
17
|
-
}
|
|
9
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
10
|
+
void StyleSheet;
|
|
18
11
|
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
return theme.intents[intent].primary;
|
|
22
|
-
}
|
|
23
|
-
return theme.colors.border.secondary;
|
|
24
|
-
}
|
|
12
|
+
// Wrap theme for $iterator support
|
|
13
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
25
14
|
|
|
26
|
-
|
|
27
|
-
return buildSizeVariants(theme, 'switch', (size) => ({
|
|
28
|
-
width: size.thumbSize,
|
|
29
|
-
height: size.thumbSize,
|
|
30
|
-
left: 2,
|
|
31
|
-
}));
|
|
32
|
-
}
|
|
15
|
+
type LabelPosition = 'left' | 'right';
|
|
33
16
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
17
|
+
export type SwitchDynamicProps = {
|
|
18
|
+
size?: Size;
|
|
19
|
+
intent?: Intent;
|
|
20
|
+
checked?: boolean;
|
|
21
|
+
disabled?: boolean;
|
|
22
|
+
labelPosition?: LabelPosition;
|
|
23
|
+
margin?: ViewStyleSize;
|
|
24
|
+
marginVertical?: ViewStyleSize;
|
|
25
|
+
marginHorizontal?: ViewStyleSize;
|
|
26
|
+
};
|
|
39
27
|
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
28
|
+
/**
|
|
29
|
+
* Switch styles with intent/checked/disabled handling.
|
|
30
|
+
*/
|
|
31
|
+
export const switchStyles = defineStyle('Switch', (theme: Theme) => ({
|
|
32
|
+
container: (_props: SwitchDynamicProps) => ({
|
|
33
|
+
flexDirection: 'row' as const,
|
|
34
|
+
alignItems: 'center' as const,
|
|
35
|
+
gap: 8,
|
|
36
|
+
variants: {
|
|
37
|
+
margin: {
|
|
38
|
+
margin: theme.sizes.$view.padding,
|
|
39
|
+
},
|
|
40
|
+
marginVertical: {
|
|
41
|
+
marginVertical: theme.sizes.$view.padding,
|
|
42
|
+
},
|
|
43
|
+
marginHorizontal: {
|
|
44
|
+
marginHorizontal: theme.sizes.$view.padding,
|
|
45
|
+
},
|
|
46
|
+
},
|
|
47
|
+
}),
|
|
46
48
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
49
|
+
switchContainer: (_props: SwitchDynamicProps) => ({
|
|
50
|
+
justifyContent: 'center' as const,
|
|
51
|
+
_web: {
|
|
52
|
+
border: 'none',
|
|
53
|
+
padding: 0,
|
|
54
|
+
backgroundColor: 'transparent',
|
|
55
|
+
width: 'fit-content',
|
|
56
|
+
},
|
|
57
|
+
}),
|
|
53
58
|
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
_web: {
|
|
66
|
-
cursor: 'not-allowed',
|
|
67
|
-
},
|
|
68
|
-
},
|
|
69
|
-
false: {
|
|
70
|
-
opacity: 1,
|
|
71
|
-
_web: {
|
|
72
|
-
cursor: 'pointer',
|
|
73
|
-
_hover: {
|
|
74
|
-
opacity: 0.9,
|
|
75
|
-
},
|
|
76
|
-
_active: {
|
|
77
|
-
opacity: 0.8,
|
|
78
|
-
},
|
|
79
|
-
},
|
|
80
|
-
},
|
|
81
|
-
},
|
|
82
|
-
} as const,
|
|
83
|
-
_web: {
|
|
84
|
-
transition: 'background-color 0.2s ease',
|
|
59
|
+
switchTrack: ({ intent = 'primary', checked = false, disabled = false }: SwitchDynamicProps) => ({
|
|
60
|
+
borderRadius: 9999,
|
|
61
|
+
position: 'relative' as const,
|
|
62
|
+
backgroundColor: checked
|
|
63
|
+
? theme.intents[intent].primary
|
|
64
|
+
: theme.colors.border.secondary,
|
|
65
|
+
opacity: disabled ? 0.5 : 1,
|
|
66
|
+
variants: {
|
|
67
|
+
size: {
|
|
68
|
+
width: theme.sizes.$switch.trackWidth,
|
|
69
|
+
height: theme.sizes.$switch.trackHeight,
|
|
85
70
|
},
|
|
86
|
-
}
|
|
87
|
-
|
|
88
|
-
|
|
71
|
+
},
|
|
72
|
+
_web: {
|
|
73
|
+
transition: 'background-color 0.2s ease',
|
|
74
|
+
cursor: disabled ? 'not-allowed' : 'pointer',
|
|
75
|
+
_hover: disabled ? {} : { opacity: 0.9 },
|
|
76
|
+
_active: disabled ? {} : { opacity: 0.8 },
|
|
77
|
+
},
|
|
78
|
+
}),
|
|
79
|
+
|
|
80
|
+
switchThumb: ({ size = 'md', checked = false }: SwitchDynamicProps) => {
|
|
81
|
+
const sizeValue = theme.sizes.switch[size];
|
|
82
|
+
const translateX = checked ? sizeValue.translateX : 0;
|
|
89
83
|
|
|
90
|
-
function createSwitchThumbStyles(theme: Theme) {
|
|
91
|
-
return ({ size, checked }: { size: SwitchSizeVariant, checked: boolean }) => {
|
|
92
84
|
return {
|
|
93
|
-
position: 'absolute',
|
|
85
|
+
position: 'absolute' as const,
|
|
94
86
|
backgroundColor: theme.colors.surface.primary,
|
|
95
87
|
borderRadius: 9999,
|
|
96
88
|
top: '50%',
|
|
97
|
-
display: 'flex',
|
|
98
|
-
alignItems: 'center',
|
|
99
|
-
justifyContent: 'center',
|
|
89
|
+
display: 'flex' as const,
|
|
90
|
+
alignItems: 'center' as const,
|
|
91
|
+
justifyContent: 'center' as const,
|
|
100
92
|
shadowColor: '#000',
|
|
101
93
|
shadowOffset: { width: 0, height: 1 },
|
|
102
94
|
shadowOpacity: 0.2,
|
|
103
95
|
shadowRadius: 3,
|
|
104
96
|
elevation: 2,
|
|
105
97
|
variants: {
|
|
106
|
-
size:
|
|
98
|
+
size: {
|
|
99
|
+
width: theme.sizes.$switch.thumbSize,
|
|
100
|
+
height: theme.sizes.$switch.thumbSize,
|
|
101
|
+
left: 2,
|
|
102
|
+
},
|
|
107
103
|
},
|
|
108
104
|
_web: {
|
|
109
105
|
boxShadow: '0 1px 3px rgba(0, 0, 0, 0.2)',
|
|
110
106
|
transition: 'transform 0.2s ease',
|
|
111
|
-
transform:
|
|
107
|
+
transform: `translateY(-50%) translateX(${translateX}px)`,
|
|
112
108
|
},
|
|
113
109
|
} as const;
|
|
114
|
-
}
|
|
115
|
-
}
|
|
110
|
+
},
|
|
116
111
|
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return {
|
|
120
|
-
display: 'flex',
|
|
121
|
-
alignItems: 'center',
|
|
122
|
-
justifyContent: 'center',
|
|
123
|
-
color: getThumbIconColor(theme, checked, intent),
|
|
124
|
-
variants: {
|
|
125
|
-
size: createThumbIconSizeVariants(theme),
|
|
126
|
-
},
|
|
127
|
-
} as const;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
/**
|
|
132
|
-
* Create container styles
|
|
133
|
-
*/
|
|
134
|
-
function createContainerStyles(theme: Theme) {
|
|
135
|
-
return () => ({
|
|
136
|
-
flexDirection: 'row' as const,
|
|
112
|
+
thumbIcon: ({ intent = 'primary', checked = false }: SwitchDynamicProps) => ({
|
|
113
|
+
display: 'flex' as const,
|
|
137
114
|
alignItems: 'center' as const,
|
|
138
|
-
gap: 8,
|
|
139
|
-
variants: {
|
|
140
|
-
margin: buildMarginVariants(theme),
|
|
141
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
142
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
143
|
-
},
|
|
144
|
-
});
|
|
145
|
-
}
|
|
146
|
-
|
|
147
|
-
/**
|
|
148
|
-
* Create switch container styles
|
|
149
|
-
*/
|
|
150
|
-
function createSwitchContainerStyles() {
|
|
151
|
-
return () => ({
|
|
152
115
|
justifyContent: 'center' as const,
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
116
|
+
color: checked
|
|
117
|
+
? theme.intents[intent].primary
|
|
118
|
+
: theme.colors.border.secondary,
|
|
119
|
+
variants: {
|
|
120
|
+
size: {
|
|
121
|
+
width: theme.sizes.$switch.thumbIconSize,
|
|
122
|
+
height: theme.sizes.$switch.thumbIconSize,
|
|
123
|
+
},
|
|
158
124
|
},
|
|
159
|
-
})
|
|
160
|
-
}
|
|
125
|
+
}),
|
|
161
126
|
|
|
162
|
-
|
|
163
|
-
* Create label styles
|
|
164
|
-
*/
|
|
165
|
-
function createLabelStyles(theme: Theme) {
|
|
166
|
-
return () => ({
|
|
127
|
+
label: ({ disabled = false, labelPosition = 'right' }: SwitchDynamicProps) => ({
|
|
167
128
|
fontSize: 14,
|
|
168
129
|
color: theme.colors.text.primary,
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
false: {
|
|
175
|
-
opacity: 1,
|
|
176
|
-
},
|
|
177
|
-
},
|
|
178
|
-
position: {
|
|
179
|
-
left: {
|
|
180
|
-
marginRight: 8,
|
|
181
|
-
},
|
|
182
|
-
right: {
|
|
183
|
-
marginLeft: 8,
|
|
184
|
-
},
|
|
185
|
-
},
|
|
186
|
-
} as const,
|
|
187
|
-
});
|
|
188
|
-
}
|
|
189
|
-
|
|
190
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
191
|
-
// transform on native cannot resolve function calls to extract variant structures.
|
|
192
|
-
export const switchStyles = StyleSheet.create((theme: Theme) => {
|
|
193
|
-
// Apply extensions to main visual elements
|
|
194
|
-
const extended = applyExtensions('Switch', theme, {
|
|
195
|
-
container: createContainerStyles(theme),
|
|
196
|
-
switchTrack: createSwitchTrackStyles(theme),
|
|
197
|
-
switchThumb: createSwitchThumbStyles(theme),
|
|
198
|
-
});
|
|
199
|
-
|
|
200
|
-
return {
|
|
201
|
-
...extended,
|
|
202
|
-
// Minor utility styles (not extended)
|
|
203
|
-
switchContainer: createSwitchContainerStyles()(),
|
|
204
|
-
thumbIcon: createThumbIconStyles(theme),
|
|
205
|
-
label: createLabelStyles(theme)(),
|
|
206
|
-
};
|
|
207
|
-
});
|
|
130
|
+
opacity: disabled ? 0.5 : 1,
|
|
131
|
+
marginRight: labelPosition === 'left' ? 8 : 0,
|
|
132
|
+
marginLeft: labelPosition === 'right' ? 8 : 0,
|
|
133
|
+
}),
|
|
134
|
+
}));
|
|
@@ -82,10 +82,10 @@ const Switch = forwardRef<HTMLDivElement | HTMLButtonElement, SwitchProps>(({
|
|
|
82
82
|
marginHorizontal,
|
|
83
83
|
});
|
|
84
84
|
|
|
85
|
-
const trackProps = getWebProps([(switchStyles.switchTrack as any)({ checked, intent })]);
|
|
85
|
+
const trackProps = getWebProps([(switchStyles.switchTrack as any)({ checked, intent, disabled })]);
|
|
86
86
|
const thumbProps = getWebProps([(switchStyles.switchThumb as any)({ size, checked })]);
|
|
87
87
|
const thumbIconProps = getWebProps([(switchStyles.thumbIcon as any)({ checked, intent })]);
|
|
88
|
-
const labelProps = getWebProps([switchStyles.label]);
|
|
88
|
+
const labelProps = getWebProps([(switchStyles.label as any)({ disabled, labelPosition })]);
|
|
89
89
|
|
|
90
90
|
// Helper to render icon
|
|
91
91
|
const renderIcon = () => {
|
|
@@ -109,9 +109,9 @@ const Switch = forwardRef<HTMLDivElement | HTMLButtonElement, SwitchProps>(({
|
|
|
109
109
|
};
|
|
110
110
|
|
|
111
111
|
// Computed button props with dynamic styles
|
|
112
|
-
const computedButtonProps = getWebProps(
|
|
113
|
-
switchStyles.switchContainer
|
|
114
|
-
);
|
|
112
|
+
const computedButtonProps = getWebProps([
|
|
113
|
+
(switchStyles.switchContainer as any)({})
|
|
114
|
+
]);
|
|
115
115
|
|
|
116
116
|
// Computed container props with dynamic styles (for when label exists)
|
|
117
117
|
const computedContainerProps = getWebProps([
|
|
@@ -177,9 +177,10 @@ const TabBar = forwardRef<View, TabBarProps>(({
|
|
|
177
177
|
iconPosition,
|
|
178
178
|
});
|
|
179
179
|
|
|
180
|
-
// Compute dynamic styles for this tab
|
|
180
|
+
// Compute dynamic styles for this tab - call as functions for theme reactivity
|
|
181
181
|
const tabStyle = (tabBarTabStyles.tab as any)({ type, size, active: isActive, pillMode, justify });
|
|
182
182
|
const labelStyle = (tabBarLabelStyles.tabLabel as any)({ type, active: isActive, pillMode });
|
|
183
|
+
const iconContainerStyle = (tabBarIconStyles.tabIcon as any)({});
|
|
183
184
|
|
|
184
185
|
const icon = renderIcon(item.icon, isActive, iconSize);
|
|
185
186
|
|
|
@@ -199,7 +200,7 @@ const TabBar = forwardRef<View, TabBarProps>(({
|
|
|
199
200
|
accessibilityLabel={item.label}
|
|
200
201
|
accessibilityState={{ selected: isActive, disabled: item.disabled }}
|
|
201
202
|
>
|
|
202
|
-
{icon && <View style={
|
|
203
|
+
{icon && <View style={iconContainerStyle}>{icon}</View>}
|
|
203
204
|
<Text style={labelStyle}>{item.label}</Text>
|
|
204
205
|
</TouchableOpacity>
|
|
205
206
|
);
|