@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
package/src/List/List.styles.tsx
CHANGED
|
@@ -1,274 +1,212 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* List styles using defineStyle with dynamic props.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
buildMarginHorizontalVariants,
|
|
12
|
-
} from '../utils/buildViewStyleVariants';
|
|
13
|
-
import { ListSizeVariant, ListType } from './types';
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Size } from '@idealyst/theme';
|
|
7
|
+
import { ViewStyleSize } from '../utils/viewStyleProps';
|
|
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
|
-
type
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
15
|
+
type ListType = 'default' | 'bordered' | 'divided';
|
|
16
|
+
|
|
17
|
+
export type ListDynamicProps = {
|
|
18
|
+
size?: Size;
|
|
19
|
+
type?: ListType;
|
|
20
|
+
scrollable?: boolean;
|
|
21
|
+
active?: boolean;
|
|
22
|
+
selected?: boolean;
|
|
23
|
+
disabled?: boolean;
|
|
24
|
+
clickable?: boolean;
|
|
25
|
+
gap?: ViewStyleSize;
|
|
26
|
+
padding?: ViewStyleSize;
|
|
27
|
+
paddingVertical?: ViewStyleSize;
|
|
28
|
+
paddingHorizontal?: ViewStyleSize;
|
|
29
|
+
margin?: ViewStyleSize;
|
|
30
|
+
marginVertical?: ViewStyleSize;
|
|
31
|
+
marginHorizontal?: ViewStyleSize;
|
|
23
32
|
};
|
|
24
33
|
|
|
25
34
|
/**
|
|
26
|
-
*
|
|
35
|
+
* List styles with type/state handling.
|
|
27
36
|
*/
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
backgroundColor: 'transparent',
|
|
32
|
-
},
|
|
33
|
-
bordered: {
|
|
37
|
+
export const listStyles = defineStyle('List', (theme: Theme) => ({
|
|
38
|
+
container: ({ type = 'default', scrollable = false }: ListDynamicProps) => {
|
|
39
|
+
const typeStyles = type === 'bordered' ? {
|
|
34
40
|
backgroundColor: theme.colors.surface.primary,
|
|
35
41
|
borderWidth: 1,
|
|
36
42
|
borderColor: theme.colors.border.primary,
|
|
37
43
|
borderRadius: 8,
|
|
38
|
-
|
|
39
|
-
overflow: 'hidden',
|
|
40
|
-
border: `1px solid ${theme.colors.border.primary}`,
|
|
41
|
-
},
|
|
42
|
-
},
|
|
43
|
-
divided: {
|
|
44
|
+
} : {
|
|
44
45
|
backgroundColor: 'transparent',
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
}
|
|
48
|
-
|
|
46
|
+
};
|
|
49
47
|
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
_web: {
|
|
59
|
-
':last-child': {
|
|
60
|
-
borderBottom: 'none',
|
|
61
|
-
},
|
|
48
|
+
return {
|
|
49
|
+
display: 'flex' as const,
|
|
50
|
+
flexDirection: 'column' as const,
|
|
51
|
+
width: '100%',
|
|
52
|
+
...typeStyles,
|
|
53
|
+
variants: {
|
|
54
|
+
gap: {
|
|
55
|
+
gap: theme.sizes.$view.padding,
|
|
62
56
|
},
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
{
|
|
66
|
-
disabled: true,
|
|
67
|
-
styles: {
|
|
68
|
-
_web: {
|
|
69
|
-
_hover: {
|
|
70
|
-
backgroundColor: 'transparent',
|
|
71
|
-
borderRadius: 0,
|
|
72
|
-
},
|
|
57
|
+
padding: {
|
|
58
|
+
padding: theme.sizes.$view.padding,
|
|
73
59
|
},
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
60
|
+
paddingVertical: {
|
|
61
|
+
paddingVertical: theme.sizes.$view.padding,
|
|
62
|
+
},
|
|
63
|
+
paddingHorizontal: {
|
|
64
|
+
paddingHorizontal: theme.sizes.$view.padding,
|
|
65
|
+
},
|
|
66
|
+
margin: {
|
|
67
|
+
margin: theme.sizes.$view.padding,
|
|
68
|
+
},
|
|
69
|
+
marginVertical: {
|
|
70
|
+
marginVertical: theme.sizes.$view.padding,
|
|
71
|
+
},
|
|
72
|
+
marginHorizontal: {
|
|
73
|
+
marginHorizontal: theme.sizes.$view.padding,
|
|
84
74
|
},
|
|
85
75
|
},
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
}
|
|
76
|
+
_web: {
|
|
77
|
+
overflow: type === 'bordered' ? 'hidden' : (scrollable ? 'auto' : undefined),
|
|
78
|
+
border: type === 'bordered' ? `1px solid ${theme.colors.border.primary}` : undefined,
|
|
79
|
+
},
|
|
80
|
+
} as const;
|
|
81
|
+
},
|
|
89
82
|
|
|
83
|
+
item: ({ type = 'default', active = false, selected = false, disabled = false, clickable = true }: ListDynamicProps) => {
|
|
84
|
+
const baseStyles = {
|
|
85
|
+
display: 'flex' as const,
|
|
86
|
+
flexDirection: 'row' as const,
|
|
87
|
+
alignItems: 'center' as const,
|
|
88
|
+
backgroundColor: active ? theme.colors.surface.secondary : 'transparent',
|
|
89
|
+
textAlign: 'left' as const,
|
|
90
|
+
opacity: disabled ? 0.5 : 1,
|
|
91
|
+
};
|
|
90
92
|
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
93
|
+
const dividerStyles = type === 'divided' ? {
|
|
94
|
+
borderBottomWidth: 1,
|
|
95
|
+
borderBottomColor: theme.colors.border.primary,
|
|
96
|
+
} : {};
|
|
97
|
+
|
|
98
|
+
const selectedStyles = selected ? {
|
|
99
|
+
backgroundColor: theme.intents.primary.light + '20',
|
|
100
|
+
borderLeftWidth: 3,
|
|
101
|
+
borderLeftColor: theme.intents.primary.primary,
|
|
102
|
+
} : {};
|
|
103
|
+
|
|
104
|
+
return {
|
|
105
|
+
...baseStyles,
|
|
106
|
+
...dividerStyles,
|
|
107
|
+
...selectedStyles,
|
|
97
108
|
variants: {
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
overflow: 'auto',
|
|
103
|
-
},
|
|
104
|
-
},
|
|
105
|
-
false: {},
|
|
109
|
+
size: {
|
|
110
|
+
paddingVertical: theme.sizes.$list.paddingVertical,
|
|
111
|
+
paddingHorizontal: theme.sizes.$list.paddingHorizontal,
|
|
112
|
+
minHeight: theme.sizes.$list.minHeight,
|
|
106
113
|
},
|
|
107
|
-
// Spacing variants from ContainerStyleProps
|
|
108
|
-
gap: buildGapVariants(theme),
|
|
109
|
-
padding: buildPaddingVariants(theme),
|
|
110
|
-
paddingVertical: buildPaddingVerticalVariants(theme),
|
|
111
|
-
paddingHorizontal: buildPaddingHorizontalVariants(theme),
|
|
112
|
-
margin: buildMarginVariants(theme),
|
|
113
|
-
marginVertical: buildMarginVerticalVariants(theme),
|
|
114
|
-
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
115
114
|
},
|
|
116
|
-
},
|
|
117
|
-
item: {
|
|
118
|
-
display: 'flex',
|
|
119
|
-
flexDirection: 'row',
|
|
120
|
-
alignItems: 'center',
|
|
121
|
-
backgroundColor: 'transparent',
|
|
122
|
-
textAlign: 'left',
|
|
123
|
-
variants: {
|
|
124
|
-
size: buildSizeVariants(theme, 'list', (size) => ({
|
|
125
|
-
paddingVertical: size.paddingVertical,
|
|
126
|
-
paddingHorizontal: size.paddingHorizontal,
|
|
127
|
-
minHeight: size.minHeight,
|
|
128
|
-
})),
|
|
129
|
-
type: {
|
|
130
|
-
default: {},
|
|
131
|
-
bordered: {},
|
|
132
|
-
divided: {
|
|
133
|
-
borderBottomWidth: 1,
|
|
134
|
-
borderBottomStyle: 'solid',
|
|
135
|
-
borderBottomColor: theme.colors.border.primary,
|
|
136
|
-
_web: {
|
|
137
|
-
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
138
|
-
},
|
|
139
|
-
},
|
|
140
|
-
},
|
|
141
|
-
active: {
|
|
142
|
-
true: {
|
|
143
|
-
backgroundColor: theme.colors.surface.secondary,
|
|
144
|
-
},
|
|
145
|
-
false: {},
|
|
146
|
-
},
|
|
147
|
-
selected: {
|
|
148
|
-
true: {
|
|
149
|
-
backgroundColor: theme.intents.primary.light + '20',
|
|
150
|
-
borderLeftWidth: 3,
|
|
151
|
-
borderLeftColor: theme.intents.primary.primary,
|
|
152
|
-
_web: {
|
|
153
|
-
borderLeft: `3px solid ${theme.intents.primary.primary}`,
|
|
154
|
-
},
|
|
155
|
-
},
|
|
156
|
-
false: {},
|
|
157
|
-
},
|
|
158
|
-
disabled: {
|
|
159
|
-
true: {
|
|
160
|
-
opacity: 0.5,
|
|
161
|
-
_web: {
|
|
162
|
-
cursor: 'not-allowed',
|
|
163
|
-
},
|
|
164
|
-
},
|
|
165
|
-
false: {},
|
|
166
|
-
},
|
|
167
|
-
clickable: {
|
|
168
|
-
true: {},
|
|
169
|
-
false: {
|
|
170
|
-
_web: {
|
|
171
|
-
cursor: 'default',
|
|
172
|
-
},
|
|
173
|
-
},
|
|
174
|
-
},
|
|
175
|
-
} as const,
|
|
176
|
-
compoundVariants: createItemCompoundVariants(theme),
|
|
177
115
|
_web: {
|
|
178
116
|
border: 'none',
|
|
179
|
-
cursor: 'pointer',
|
|
117
|
+
cursor: disabled ? 'not-allowed' : (clickable ? 'pointer' : 'default'),
|
|
180
118
|
outline: 'none',
|
|
181
119
|
transition: 'background-color 0.2s ease, border-color 0.2s ease',
|
|
182
|
-
|
|
120
|
+
borderBottom: type === 'divided' ? `1px solid ${theme.colors.border.primary}` : undefined,
|
|
121
|
+
borderLeft: selected ? `3px solid ${theme.intents.primary.primary}` : undefined,
|
|
122
|
+
_hover: (disabled || !clickable) ? {} : {
|
|
183
123
|
backgroundColor: theme.colors.surface.secondary,
|
|
184
124
|
borderRadius: 4,
|
|
185
125
|
},
|
|
186
126
|
},
|
|
187
|
-
} as const
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
flex: 1,
|
|
210
|
-
display: 'flex',
|
|
211
|
-
flexDirection: 'column',
|
|
212
|
-
},
|
|
213
|
-
label: {
|
|
214
|
-
fontWeight: '500',
|
|
215
|
-
color: theme.colors.text.primary,
|
|
216
|
-
variants: {
|
|
217
|
-
size: buildSizeVariants(theme, 'list', (size) => ({
|
|
218
|
-
fontSize: size.labelFontSize,
|
|
219
|
-
lineHeight: size.labelLineHeight,
|
|
220
|
-
})),
|
|
221
|
-
disabled: {
|
|
222
|
-
true: {
|
|
223
|
-
color: theme.colors.text.secondary,
|
|
224
|
-
},
|
|
225
|
-
false: {},
|
|
226
|
-
},
|
|
227
|
-
selected: {
|
|
228
|
-
true: {
|
|
229
|
-
color: theme.intents.primary.primary,
|
|
230
|
-
fontWeight: '600',
|
|
231
|
-
},
|
|
232
|
-
false: {},
|
|
127
|
+
} as const;
|
|
128
|
+
},
|
|
129
|
+
|
|
130
|
+
itemContent: (_props: ListDynamicProps) => ({
|
|
131
|
+
display: 'flex' as const,
|
|
132
|
+
flexDirection: 'row' as const,
|
|
133
|
+
alignItems: 'center' as const,
|
|
134
|
+
flex: 1,
|
|
135
|
+
gap: 8,
|
|
136
|
+
}),
|
|
137
|
+
|
|
138
|
+
leading: (_props: ListDynamicProps) => ({
|
|
139
|
+
display: 'flex' as const,
|
|
140
|
+
alignItems: 'center' as const,
|
|
141
|
+
justifyContent: 'center' as const,
|
|
142
|
+
marginRight: 8,
|
|
143
|
+
color: theme.colors.text.secondary,
|
|
144
|
+
variants: {
|
|
145
|
+
size: {
|
|
146
|
+
width: theme.sizes.$list.iconSize,
|
|
147
|
+
height: theme.sizes.$list.iconSize,
|
|
148
|
+
fontSize: theme.sizes.$list.iconSize,
|
|
233
149
|
},
|
|
234
150
|
},
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
width: size.iconSize,
|
|
251
|
-
height: size.iconSize,
|
|
252
|
-
})),
|
|
151
|
+
}),
|
|
152
|
+
|
|
153
|
+
labelContainer: (_props: ListDynamicProps) => ({
|
|
154
|
+
flex: 1,
|
|
155
|
+
display: 'flex' as const,
|
|
156
|
+
flexDirection: 'column' as const,
|
|
157
|
+
}),
|
|
158
|
+
|
|
159
|
+
label: ({ disabled = false, selected = false }: ListDynamicProps) => ({
|
|
160
|
+
fontWeight: selected ? ('600' as const) : ('500' as const),
|
|
161
|
+
color: selected ? theme.intents.primary.primary : (disabled ? theme.colors.text.secondary : theme.colors.text.primary),
|
|
162
|
+
variants: {
|
|
163
|
+
size: {
|
|
164
|
+
fontSize: theme.sizes.$list.labelFontSize,
|
|
165
|
+
lineHeight: theme.sizes.$list.labelLineHeight,
|
|
253
166
|
},
|
|
254
167
|
},
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
168
|
+
}),
|
|
169
|
+
|
|
170
|
+
trailing: (_props: ListDynamicProps) => ({
|
|
171
|
+
display: 'flex' as const,
|
|
172
|
+
alignItems: 'center' as const,
|
|
173
|
+
justifyContent: 'center' as const,
|
|
174
|
+
marginLeft: 8,
|
|
175
|
+
color: theme.colors.text.secondary,
|
|
176
|
+
flexShrink: 0,
|
|
177
|
+
}),
|
|
178
|
+
|
|
179
|
+
trailingIcon: (_props: ListDynamicProps) => ({
|
|
180
|
+
display: 'flex' as const,
|
|
181
|
+
alignItems: 'center' as const,
|
|
182
|
+
justifyContent: 'center' as const,
|
|
183
|
+
variants: {
|
|
184
|
+
size: {
|
|
185
|
+
width: theme.sizes.$list.iconSize,
|
|
186
|
+
height: theme.sizes.$list.iconSize,
|
|
187
|
+
fontSize: theme.sizes.$list.iconSize,
|
|
188
|
+
},
|
|
272
189
|
},
|
|
273
|
-
}
|
|
274
|
-
|
|
190
|
+
}),
|
|
191
|
+
|
|
192
|
+
section: (_props: ListDynamicProps) => ({
|
|
193
|
+
display: 'flex' as const,
|
|
194
|
+
flexDirection: 'column' as const,
|
|
195
|
+
}),
|
|
196
|
+
|
|
197
|
+
sectionTitle: (_props: ListDynamicProps) => ({
|
|
198
|
+
fontWeight: '600' as const,
|
|
199
|
+
fontSize: 12,
|
|
200
|
+
lineHeight: 16,
|
|
201
|
+
textTransform: 'uppercase' as const,
|
|
202
|
+
letterSpacing: 0.5,
|
|
203
|
+
color: theme.colors.text.secondary,
|
|
204
|
+
padding: 8,
|
|
205
|
+
paddingBottom: 4,
|
|
206
|
+
}),
|
|
207
|
+
|
|
208
|
+
sectionContent: (_props: ListDynamicProps) => ({
|
|
209
|
+
display: 'flex' as const,
|
|
210
|
+
flexDirection: 'column' as const,
|
|
211
|
+
}),
|
|
212
|
+
}));
|
|
@@ -51,15 +51,23 @@ const ListItem = forwardRef<ComponentRef<typeof View> | ComponentRef<typeof Pres
|
|
|
51
51
|
const effectiveSize = size ?? listContext.size ?? 'md';
|
|
52
52
|
const effectiveVariant = listContext.type ?? 'default';
|
|
53
53
|
|
|
54
|
-
// Apply
|
|
54
|
+
// Apply variants (for size, active, selected, disabled on label)
|
|
55
55
|
listStyles.useVariants({
|
|
56
56
|
size: effectiveSize,
|
|
57
57
|
active,
|
|
58
58
|
selected,
|
|
59
59
|
disabled,
|
|
60
|
-
clickable: isClickable,
|
|
61
60
|
});
|
|
62
61
|
|
|
62
|
+
// Get dynamic styles - call as functions to get theme-reactive styles
|
|
63
|
+
const itemStyle = (listStyles.item as any)({ type: effectiveVariant, disabled, clickable: isClickable });
|
|
64
|
+
const labelStyle = (listStyles.label as any)({ disabled, selected });
|
|
65
|
+
const leadingStyle = (listStyles.leading as any)({});
|
|
66
|
+
const trailingStyle = (listStyles.trailing as any)({});
|
|
67
|
+
const trailingIconStyle = (listStyles.trailingIcon as any)({});
|
|
68
|
+
const labelContainerStyle = (listStyles.labelContainer as any)({});
|
|
69
|
+
const itemContentStyle = (listStyles.itemContent as any)({});
|
|
70
|
+
|
|
63
71
|
// Resolve icon color - check intents first, then color palette
|
|
64
72
|
const resolvedIconColor = (() => {
|
|
65
73
|
if (!iconColor) return undefined;
|
|
@@ -77,7 +85,7 @@ const ListItem = forwardRef<ComponentRef<typeof View> | ComponentRef<typeof Pres
|
|
|
77
85
|
|
|
78
86
|
// If it's a string, treat it as an icon name
|
|
79
87
|
if (typeof element === 'string') {
|
|
80
|
-
const iconStyle = styleKey === 'leading' ?
|
|
88
|
+
const iconStyle = styleKey === 'leading' ? leadingStyle : trailingIconStyle;
|
|
81
89
|
return (
|
|
82
90
|
<MaterialCommunityIcons
|
|
83
91
|
name={element}
|
|
@@ -96,20 +104,20 @@ const ListItem = forwardRef<ComponentRef<typeof View> | ComponentRef<typeof Pres
|
|
|
96
104
|
const content = (
|
|
97
105
|
<>
|
|
98
106
|
{leading && (
|
|
99
|
-
<View style={
|
|
107
|
+
<View style={leadingStyle}>
|
|
100
108
|
{renderElement(leading, 'leading')}
|
|
101
109
|
</View>
|
|
102
110
|
)}
|
|
103
111
|
|
|
104
|
-
<View style={
|
|
112
|
+
<View style={labelContainerStyle}>
|
|
105
113
|
{label && (
|
|
106
|
-
<Text style={
|
|
114
|
+
<Text style={labelStyle}>{label}</Text>
|
|
107
115
|
)}
|
|
108
116
|
{children}
|
|
109
117
|
</View>
|
|
110
118
|
|
|
111
119
|
{trailing && (
|
|
112
|
-
<View style={
|
|
120
|
+
<View style={trailingStyle}>
|
|
113
121
|
{renderElement(trailing, 'trailingIcon')}
|
|
114
122
|
</View>
|
|
115
123
|
)}
|
|
@@ -117,7 +125,7 @@ const ListItem = forwardRef<ComponentRef<typeof View> | ComponentRef<typeof Pres
|
|
|
117
125
|
);
|
|
118
126
|
|
|
119
127
|
const indentStyle = indent > 0 ? { paddingLeft: indent * 16 } : {};
|
|
120
|
-
const combinedStyle = [
|
|
128
|
+
const combinedStyle = [itemStyle, indentStyle, style];
|
|
121
129
|
|
|
122
130
|
if (isClickable) {
|
|
123
131
|
return (
|
|
@@ -32,20 +32,27 @@ const ListItem: React.FC<ListItemProps> = ({
|
|
|
32
32
|
const effectiveSize = size ?? listContext.size ?? 'md';
|
|
33
33
|
const effectiveVariant = listContext.type ?? 'default';
|
|
34
34
|
|
|
35
|
-
// Apply
|
|
35
|
+
// Apply variants (for size, active, selected, disabled on label)
|
|
36
36
|
listStyles.useVariants({
|
|
37
37
|
size: effectiveSize,
|
|
38
38
|
active,
|
|
39
39
|
selected,
|
|
40
40
|
disabled,
|
|
41
|
-
clickable: isClickable,
|
|
42
41
|
});
|
|
43
42
|
|
|
44
|
-
|
|
45
|
-
const
|
|
46
|
-
const
|
|
47
|
-
const
|
|
48
|
-
const
|
|
43
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
44
|
+
const itemStyle = (listStyles.item as any)({ type: effectiveVariant, disabled, clickable: isClickable });
|
|
45
|
+
const labelStyle = (listStyles.label as any)({ disabled, selected });
|
|
46
|
+
const leadingStyle = (listStyles.leading as any)({});
|
|
47
|
+
const trailingStyle = (listStyles.trailing as any)({});
|
|
48
|
+
const trailingIconStyle = (listStyles.trailingIcon as any)({});
|
|
49
|
+
const labelContainerStyle = (listStyles.labelContainer as any)({});
|
|
50
|
+
|
|
51
|
+
const itemProps = getWebProps([itemStyle, style]);
|
|
52
|
+
const labelProps = getWebProps([labelStyle]);
|
|
53
|
+
const leadingProps = getWebProps([leadingStyle]);
|
|
54
|
+
const trailingProps = getWebProps([trailingStyle]);
|
|
55
|
+
const trailingIconProps = getWebProps([trailingStyle, trailingIconStyle]);
|
|
49
56
|
|
|
50
57
|
const handleClick = () => {
|
|
51
58
|
if (!disabled && onPress) {
|
|
@@ -65,18 +72,16 @@ const ListItem: React.FC<ListItemProps> = ({
|
|
|
65
72
|
})();
|
|
66
73
|
|
|
67
74
|
// Helper to render leading/trailing icons
|
|
68
|
-
|
|
75
|
+
// IconSvg uses size="1em" by default, sized by container's fontSize from styles
|
|
76
|
+
const renderElement = (element: typeof leading | typeof trailing, isTrailing = false) => {
|
|
69
77
|
if (!element) return null;
|
|
70
78
|
|
|
71
79
|
if (isIconName(element)) {
|
|
72
80
|
const iconPath = resolveIconPath(element);
|
|
73
|
-
// Use trailingIconProps for trailing icons to apply size constraints
|
|
74
|
-
const iconPropsToUse = isTrailing ? trailingIconProps : props;
|
|
75
81
|
return (
|
|
76
82
|
<IconSvg
|
|
77
83
|
path={iconPath}
|
|
78
|
-
{
|
|
79
|
-
color={resolvedIconColor}
|
|
84
|
+
color={resolvedIconColor || 'currentColor'}
|
|
80
85
|
aria-label={element}
|
|
81
86
|
/>
|
|
82
87
|
);
|
|
@@ -87,11 +92,17 @@ const ListItem: React.FC<ListItemProps> = ({
|
|
|
87
92
|
return null;
|
|
88
93
|
};
|
|
89
94
|
|
|
95
|
+
const labelContainerProps = getWebProps([labelContainerStyle]);
|
|
96
|
+
|
|
90
97
|
const content = (
|
|
91
98
|
<>
|
|
92
|
-
{leading &&
|
|
99
|
+
{leading && (
|
|
100
|
+
<span {...leadingProps}>
|
|
101
|
+
{renderElement(leading)}
|
|
102
|
+
</span>
|
|
103
|
+
)}
|
|
93
104
|
|
|
94
|
-
<div {...
|
|
105
|
+
<div {...labelContainerProps}>
|
|
95
106
|
{label && (
|
|
96
107
|
<span {...labelProps}>{label}</span>
|
|
97
108
|
)}
|
|
@@ -100,7 +111,7 @@ const ListItem: React.FC<ListItemProps> = ({
|
|
|
100
111
|
|
|
101
112
|
{trailing && (
|
|
102
113
|
<div {...trailingProps}>
|
|
103
|
-
{renderElement(trailing,
|
|
114
|
+
{renderElement(trailing, true)}
|
|
104
115
|
</div>
|
|
105
116
|
)}
|
|
106
117
|
</>
|
package/src/Menu/Menu.native.tsx
CHANGED