@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,234 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Breadcrumb styles using defineStyle with $iterator expansion.
|
|
3
|
+
*/
|
|
1
4
|
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
|
|
5
|
-
type BreadcrumbSize = Size;
|
|
6
|
-
type BreadcrumbIntent = 'primary' | 'neutral';
|
|
7
|
-
|
|
8
|
-
type BreadcrumbVariants = {
|
|
9
|
-
size: BreadcrumbSize;
|
|
10
|
-
intent: BreadcrumbIntent;
|
|
11
|
-
disabled: boolean;
|
|
12
|
-
isLast: boolean;
|
|
13
|
-
clickable: boolean;
|
|
14
|
-
}
|
|
5
|
+
import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
|
|
6
|
+
import type { Theme as BaseTheme, Size } from '@idealyst/theme';
|
|
15
7
|
|
|
16
|
-
|
|
8
|
+
// Required: Unistyles must see StyleSheet usage in original source to process this file
|
|
9
|
+
void StyleSheet;
|
|
17
10
|
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
item: ExpandedBreadcrumbStyles;
|
|
21
|
-
itemText: ExpandedBreadcrumbStyles;
|
|
22
|
-
icon: ExpandedBreadcrumbStyles;
|
|
23
|
-
separator: ExpandedBreadcrumbStyles;
|
|
24
|
-
ellipsis: ExpandedBreadcrumbStyles;
|
|
25
|
-
ellipsisIcon: ExpandedBreadcrumbStyles;
|
|
26
|
-
menuButton: ExpandedBreadcrumbStyles;
|
|
27
|
-
menuButtonIcon: ExpandedBreadcrumbStyles;
|
|
28
|
-
}
|
|
11
|
+
// Wrap theme for $iterator support
|
|
12
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
29
13
|
|
|
30
|
-
|
|
31
|
-
* Create size variants for item text
|
|
32
|
-
*/
|
|
33
|
-
function createItemTextSizeVariants(theme: Theme) {
|
|
34
|
-
return buildSizeVariants(theme, 'breadcrumb', (size) => ({
|
|
35
|
-
fontSize: size.fontSize,
|
|
36
|
-
lineHeight: size.lineHeight,
|
|
37
|
-
}));
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
/**
|
|
41
|
-
* Create compound variants for item text
|
|
42
|
-
*/
|
|
43
|
-
function createItemTextCompoundVariants(theme: Theme): CompoundVariants<keyof BreadcrumbVariants> {
|
|
44
|
-
return [
|
|
45
|
-
{
|
|
46
|
-
clickable: true,
|
|
47
|
-
intent: 'primary',
|
|
48
|
-
isLast: false,
|
|
49
|
-
disabled: false,
|
|
50
|
-
styles: { color: theme.intents.primary.primary },
|
|
51
|
-
},
|
|
52
|
-
{
|
|
53
|
-
clickable: true,
|
|
54
|
-
intent: 'neutral',
|
|
55
|
-
isLast: false,
|
|
56
|
-
disabled: false,
|
|
57
|
-
styles: { color: theme.colors.text.secondary },
|
|
58
|
-
},
|
|
59
|
-
{
|
|
60
|
-
clickable: false,
|
|
61
|
-
isLast: false,
|
|
62
|
-
disabled: false,
|
|
63
|
-
styles: { color: theme.colors.text.secondary },
|
|
64
|
-
},
|
|
65
|
-
];
|
|
66
|
-
}
|
|
14
|
+
type BreadcrumbIntent = 'primary' | 'neutral';
|
|
67
15
|
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
}));
|
|
76
|
-
}
|
|
16
|
+
export type BreadcrumbDynamicProps = {
|
|
17
|
+
size?: Size;
|
|
18
|
+
intent?: BreadcrumbIntent;
|
|
19
|
+
disabled?: boolean;
|
|
20
|
+
isLast?: boolean;
|
|
21
|
+
clickable?: boolean;
|
|
22
|
+
};
|
|
77
23
|
|
|
78
24
|
/**
|
|
79
|
-
*
|
|
25
|
+
* Breadcrumb styles with intent and state handling.
|
|
80
26
|
*/
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
27
|
+
export const breadcrumbStyles = defineStyle('Breadcrumb', (theme: Theme) => ({
|
|
28
|
+
container: (_props: BreadcrumbDynamicProps) => ({
|
|
29
|
+
display: 'flex' as const,
|
|
30
|
+
flexDirection: 'row' as const,
|
|
31
|
+
alignItems: 'center' as const,
|
|
32
|
+
flexWrap: 'wrap' as const,
|
|
33
|
+
gap: 8,
|
|
34
|
+
}),
|
|
35
|
+
|
|
36
|
+
item: (_props: BreadcrumbDynamicProps) => ({
|
|
37
|
+
display: 'flex' as const,
|
|
38
|
+
flexDirection: 'row' as const,
|
|
39
|
+
alignItems: 'center' as const,
|
|
40
|
+
gap: 4,
|
|
41
|
+
}),
|
|
42
|
+
|
|
43
|
+
itemText: ({ intent = 'primary', isLast = false, disabled = false, clickable = true }: BreadcrumbDynamicProps) => {
|
|
44
|
+
// Get color based on state - inline for Unistyles to trace
|
|
45
|
+
const color = disabled
|
|
46
|
+
? theme.colors.text.secondary
|
|
47
|
+
: isLast
|
|
48
|
+
? theme.colors.text.primary
|
|
49
|
+
: clickable
|
|
50
|
+
? (intent === 'primary' ? theme.intents.primary.primary : theme.colors.text.secondary)
|
|
51
|
+
: theme.colors.text.secondary;
|
|
87
52
|
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
color: theme.colors.text.secondary,
|
|
53
|
+
return {
|
|
54
|
+
color,
|
|
55
|
+
opacity: disabled ? 0.5 : 1,
|
|
56
|
+
variants: {
|
|
57
|
+
// $iterator expands for each breadcrumb size
|
|
58
|
+
size: {
|
|
59
|
+
fontSize: theme.sizes.$breadcrumb.fontSize,
|
|
60
|
+
lineHeight: theme.sizes.$breadcrumb.lineHeight,
|
|
97
61
|
},
|
|
98
|
-
false: {},
|
|
99
|
-
},
|
|
100
|
-
isLast: {
|
|
101
|
-
true: { color: theme.colors.text.primary },
|
|
102
|
-
false: {},
|
|
103
62
|
},
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
compoundVariants: createItemTextCompoundVariants(theme),
|
|
107
|
-
} as const;
|
|
108
|
-
}
|
|
63
|
+
} as const;
|
|
64
|
+
},
|
|
109
65
|
|
|
110
|
-
|
|
111
|
-
return {
|
|
66
|
+
icon: (_props: BreadcrumbDynamicProps) => ({
|
|
112
67
|
variants: {
|
|
113
|
-
size:
|
|
68
|
+
size: {
|
|
69
|
+
width: theme.sizes.$breadcrumb.iconSize,
|
|
70
|
+
height: theme.sizes.$breadcrumb.iconSize,
|
|
71
|
+
fontSize: theme.sizes.$breadcrumb.iconSize,
|
|
72
|
+
},
|
|
114
73
|
},
|
|
115
|
-
}
|
|
116
|
-
}
|
|
74
|
+
}),
|
|
117
75
|
|
|
118
|
-
|
|
119
|
-
return {
|
|
76
|
+
separator: (_props: BreadcrumbDynamicProps) => ({
|
|
120
77
|
color: theme.colors.text.tertiary,
|
|
121
78
|
variants: {
|
|
122
|
-
size:
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
|
|
127
|
-
const createEllipsisIconStyles = (theme: Theme) => {
|
|
128
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
129
|
-
return {
|
|
130
|
-
color: getIconColor(theme, intent),
|
|
131
|
-
variants: {
|
|
132
|
-
size: createIconSizeVariants(theme),
|
|
79
|
+
size: {
|
|
80
|
+
fontSize: theme.sizes.$breadcrumb.fontSize,
|
|
81
|
+
lineHeight: theme.sizes.$breadcrumb.lineHeight,
|
|
133
82
|
},
|
|
134
|
-
} as const;
|
|
135
|
-
}
|
|
136
|
-
}
|
|
137
|
-
|
|
138
|
-
const createMenuButtonIconStyles = (theme: Theme) => {
|
|
139
|
-
return ({ intent }: Partial<BreadcrumbVariants>) => {
|
|
140
|
-
return {
|
|
141
|
-
color: getIconColor(theme, intent),
|
|
142
|
-
variants: {
|
|
143
|
-
size: createIconSizeVariants(theme),
|
|
144
|
-
},
|
|
145
|
-
} as const;
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
|
|
150
|
-
// @ts-ignore - TS language server needs restart to pick up theme structure changes
|
|
151
|
-
export const breadcrumbStyles = StyleSheet.create((theme: Theme) => {
|
|
152
|
-
return {
|
|
153
|
-
container: {
|
|
154
|
-
display: 'flex',
|
|
155
|
-
flexDirection: 'row',
|
|
156
|
-
alignItems: 'center',
|
|
157
|
-
flexWrap: 'wrap',
|
|
158
|
-
gap: 8,
|
|
159
|
-
},
|
|
160
|
-
item: {
|
|
161
|
-
display: 'flex',
|
|
162
|
-
flexDirection: 'row',
|
|
163
|
-
alignItems: 'center',
|
|
164
|
-
gap: 4,
|
|
165
|
-
},
|
|
166
|
-
itemText: createItemTextStyles(theme),
|
|
167
|
-
icon: createIconStyles(theme),
|
|
168
|
-
separator: createSeparatorStyles(theme),
|
|
169
|
-
ellipsis: {
|
|
170
|
-
display: 'flex',
|
|
171
|
-
alignItems: 'center',
|
|
172
|
-
justifyContent: 'center',
|
|
173
83
|
},
|
|
174
|
-
|
|
175
|
-
menuButton: {
|
|
176
|
-
paddingVertical: 4,
|
|
177
|
-
paddingHorizontal: 8,
|
|
178
|
-
},
|
|
179
|
-
menuButtonIcon: createMenuButtonIconStyles(theme),
|
|
180
|
-
};
|
|
181
|
-
});
|
|
84
|
+
}),
|
|
182
85
|
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
flexDirection: 'row',
|
|
189
|
-
alignItems: 'center',
|
|
190
|
-
flexWrap: 'wrap',
|
|
191
|
-
gap: 8,
|
|
192
|
-
},
|
|
193
|
-
};
|
|
194
|
-
});
|
|
86
|
+
ellipsis: (_props: BreadcrumbDynamicProps) => ({
|
|
87
|
+
display: 'flex' as const,
|
|
88
|
+
alignItems: 'center' as const,
|
|
89
|
+
justifyContent: 'center' as const,
|
|
90
|
+
}),
|
|
195
91
|
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
92
|
+
ellipsisIcon: ({ intent = 'primary' }: BreadcrumbDynamicProps) => ({
|
|
93
|
+
color: intent === 'primary' ? theme.intents.primary.primary : theme.colors.text.secondary,
|
|
94
|
+
variants: {
|
|
95
|
+
size: {
|
|
96
|
+
width: theme.sizes.$breadcrumb.iconSize,
|
|
97
|
+
height: theme.sizes.$breadcrumb.iconSize,
|
|
98
|
+
fontSize: theme.sizes.$breadcrumb.iconSize,
|
|
99
|
+
},
|
|
203
100
|
},
|
|
204
|
-
|
|
205
|
-
icon: createIconStyles(theme),
|
|
206
|
-
} as const;
|
|
207
|
-
});
|
|
208
|
-
|
|
209
|
-
export const breadcrumbSeparatorStyles = StyleSheet.create((theme: Theme) => {
|
|
210
|
-
return {
|
|
211
|
-
separator: createSeparatorStyles(theme),
|
|
212
|
-
} as const;
|
|
213
|
-
});
|
|
101
|
+
}),
|
|
214
102
|
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
alignItems: 'center',
|
|
220
|
-
justifyContent: 'center',
|
|
221
|
-
},
|
|
222
|
-
icon: createEllipsisIconStyles(theme),
|
|
223
|
-
} as const;
|
|
224
|
-
});
|
|
103
|
+
menuButton: (_props: BreadcrumbDynamicProps) => ({
|
|
104
|
+
paddingVertical: 4,
|
|
105
|
+
paddingHorizontal: 8,
|
|
106
|
+
}),
|
|
225
107
|
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
108
|
+
menuButtonIcon: ({ intent = 'primary' }: BreadcrumbDynamicProps) => ({
|
|
109
|
+
color: intent === 'primary' ? theme.intents.primary.primary : theme.colors.text.secondary,
|
|
110
|
+
variants: {
|
|
111
|
+
size: {
|
|
112
|
+
width: theme.sizes.$breadcrumb.iconSize,
|
|
113
|
+
height: theme.sizes.$breadcrumb.iconSize,
|
|
114
|
+
fontSize: theme.sizes.$breadcrumb.iconSize,
|
|
115
|
+
},
|
|
231
116
|
},
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
});
|
|
117
|
+
}),
|
|
118
|
+
}));
|
|
@@ -1,12 +1,6 @@
|
|
|
1
|
-
import React, { isValidElement, useState
|
|
1
|
+
import React, { isValidElement, useState } from 'react';
|
|
2
2
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
|
-
import {
|
|
4
|
-
breadcrumbContainerStyles,
|
|
5
|
-
breadcrumbItemStyles,
|
|
6
|
-
breadcrumbSeparatorStyles,
|
|
7
|
-
breadcrumbEllipsisStyles,
|
|
8
|
-
breadcrumbMenuButtonStyles
|
|
9
|
-
} from './Breadcrumb.styles';
|
|
3
|
+
import { breadcrumbStyles } from './Breadcrumb.styles';
|
|
10
4
|
import type { BreadcrumbProps, BreadcrumbItem as BreadcrumbItemType } from './types';
|
|
11
5
|
import { IconSvg } from '../Icon/IconSvg/IconSvg.web';
|
|
12
6
|
import { resolveIconPath, isIconName } from '../Icon/icon-resolver';
|
|
@@ -22,18 +16,27 @@ interface BreadcrumbItemProps {
|
|
|
22
16
|
}
|
|
23
17
|
|
|
24
18
|
const BreadcrumbItem: React.FC<BreadcrumbItemProps> = ({ item, isLast, size, intent, itemStyle }) => {
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const isClickable = !!item.onPress && !item.disabled;
|
|
20
|
+
const isDisabled = item.disabled || false;
|
|
21
|
+
|
|
22
|
+
// Apply size variant
|
|
23
|
+
breadcrumbStyles.useVariants({
|
|
27
24
|
size,
|
|
25
|
+
});
|
|
26
|
+
|
|
27
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
28
|
+
const itemStyle_ = (breadcrumbStyles.item as any)({});
|
|
29
|
+
const itemTextStyle = (breadcrumbStyles.itemText as any)({
|
|
28
30
|
intent,
|
|
29
|
-
disabled: item.disabled || false,
|
|
30
31
|
isLast,
|
|
31
|
-
|
|
32
|
+
disabled: isDisabled,
|
|
33
|
+
clickable: isClickable,
|
|
32
34
|
});
|
|
35
|
+
const iconStyle = (breadcrumbStyles.icon as any)({});
|
|
33
36
|
|
|
34
|
-
const itemProps = getWebProps([
|
|
35
|
-
const itemTextProps = getWebProps([
|
|
36
|
-
const iconProps = getWebProps([
|
|
37
|
+
const itemProps = getWebProps([itemStyle_]);
|
|
38
|
+
const itemTextProps = getWebProps([itemTextStyle, itemStyle]);
|
|
39
|
+
const iconProps = getWebProps([iconStyle]);
|
|
37
40
|
|
|
38
41
|
const handleClick = () => {
|
|
39
42
|
if (!item.disabled && item.onPress) {
|
|
@@ -46,10 +49,10 @@ const BreadcrumbItem: React.FC<BreadcrumbItemProps> = ({ item, isLast, size, int
|
|
|
46
49
|
|
|
47
50
|
if (isIconName(item.icon)) {
|
|
48
51
|
const iconPath = resolveIconPath(item.icon);
|
|
52
|
+
// IconSvg uses size="1em" by default, sized by container's fontSize from styles
|
|
49
53
|
return (
|
|
50
54
|
<IconSvg
|
|
51
55
|
path={iconPath}
|
|
52
|
-
{...iconProps}
|
|
53
56
|
aria-label={item.icon}
|
|
54
57
|
/>
|
|
55
58
|
);
|
|
@@ -80,7 +83,7 @@ const BreadcrumbItem: React.FC<BreadcrumbItemProps> = ({ item, isLast, size, int
|
|
|
80
83
|
</div>
|
|
81
84
|
);
|
|
82
85
|
|
|
83
|
-
if (
|
|
86
|
+
if (isClickable) {
|
|
84
87
|
return (
|
|
85
88
|
<button
|
|
86
89
|
onClick={handleClick}
|
|
@@ -91,7 +94,7 @@ const BreadcrumbItem: React.FC<BreadcrumbItemProps> = ({ item, isLast, size, int
|
|
|
91
94
|
cursor: 'pointer',
|
|
92
95
|
textDecoration: 'none',
|
|
93
96
|
}}
|
|
94
|
-
disabled={
|
|
97
|
+
disabled={isDisabled}
|
|
95
98
|
aria-current={isLast ? 'page' : undefined}
|
|
96
99
|
>
|
|
97
100
|
{content}
|
|
@@ -113,8 +116,9 @@ interface BreadcrumbSeparatorProps {
|
|
|
113
116
|
}
|
|
114
117
|
|
|
115
118
|
const BreadcrumbSeparator: React.FC<BreadcrumbSeparatorProps> = ({ separator, size, separatorStyle }) => {
|
|
116
|
-
|
|
117
|
-
const
|
|
119
|
+
breadcrumbStyles.useVariants({ size });
|
|
120
|
+
const separatorStyle_ = (breadcrumbStyles.separator as any)({});
|
|
121
|
+
const separatorProps = getWebProps([separatorStyle_, separatorStyle]);
|
|
118
122
|
|
|
119
123
|
return (
|
|
120
124
|
<span {...separatorProps} aria-hidden="true">
|
|
@@ -129,9 +133,11 @@ interface BreadcrumbEllipsisProps {
|
|
|
129
133
|
}
|
|
130
134
|
|
|
131
135
|
const BreadcrumbEllipsis: React.FC<BreadcrumbEllipsisProps> = ({ size, intent }) => {
|
|
132
|
-
|
|
133
|
-
const
|
|
134
|
-
const
|
|
136
|
+
breadcrumbStyles.useVariants({ size });
|
|
137
|
+
const ellipsisStyle = (breadcrumbStyles.ellipsis as any)({});
|
|
138
|
+
const ellipsisIconStyle = (breadcrumbStyles.ellipsisIcon as any)({ intent });
|
|
139
|
+
const ellipsisProps = getWebProps([ellipsisStyle]);
|
|
140
|
+
const iconProps = getWebProps([ellipsisIconStyle]);
|
|
135
141
|
const ellipsisIconPath = resolveIconPath('dots-horizontal');
|
|
136
142
|
|
|
137
143
|
return (
|
|
@@ -160,13 +166,19 @@ const Breadcrumb: React.FC<BreadcrumbProps> = ({
|
|
|
160
166
|
id,
|
|
161
167
|
}) => {
|
|
162
168
|
const [menuOpen, setMenuOpen] = useState(false);
|
|
163
|
-
|
|
169
|
+
|
|
170
|
+
// Get dynamic styles - call as functions for theme reactivity
|
|
171
|
+
const containerStyle = (breadcrumbStyles.container as any)({});
|
|
172
|
+
const menuButtonStyle = (breadcrumbStyles.menuButton as any)({});
|
|
173
|
+
const menuButtonIconStyle = (breadcrumbStyles.menuButtonIcon as any)({ intent });
|
|
174
|
+
|
|
175
|
+
const containerProps = getWebProps([containerStyle, style as any]);
|
|
164
176
|
const menuIconPath = resolveIconPath('dots-horizontal');
|
|
165
177
|
|
|
166
178
|
// Apply variants for menu button
|
|
167
|
-
|
|
168
|
-
const menuButtonProps = getWebProps([
|
|
169
|
-
const menuIconProps = getWebProps([
|
|
179
|
+
breadcrumbStyles.useVariants({ size });
|
|
180
|
+
const menuButtonProps = getWebProps([menuButtonStyle]);
|
|
181
|
+
const menuIconProps = getWebProps([menuButtonIconStyle]);
|
|
170
182
|
|
|
171
183
|
// Handle responsive collapsing
|
|
172
184
|
let displayItems = items;
|
|
@@ -34,29 +34,30 @@ const Button = forwardRef<ComponentRef<typeof TouchableOpacity>, ButtonProps>((p
|
|
|
34
34
|
accessibilityPressed,
|
|
35
35
|
} = props;
|
|
36
36
|
|
|
37
|
-
// Apply variants
|
|
37
|
+
// Apply variants for size, disabled, gradient
|
|
38
38
|
buttonStyles.useVariants({
|
|
39
|
-
type,
|
|
40
|
-
intent,
|
|
41
39
|
size,
|
|
42
40
|
disabled,
|
|
43
41
|
gradient,
|
|
44
42
|
});
|
|
45
43
|
|
|
46
|
-
// Compute dynamic styles
|
|
47
|
-
const
|
|
48
|
-
const
|
|
49
|
-
const
|
|
44
|
+
// Compute dynamic styles with all props for full flexibility
|
|
45
|
+
const dynamicProps = { intent, type, size, disabled, gradient };
|
|
46
|
+
const buttonStyle = (buttonStyles.button as any)(dynamicProps);
|
|
47
|
+
const textStyle = (buttonStyles.text as any)(dynamicProps);
|
|
48
|
+
const iconStyle = (buttonStyles.icon as any)(dynamicProps);
|
|
49
|
+
const iconContainerStyle = (buttonStyles.iconContainer as any)(dynamicProps);
|
|
50
50
|
|
|
51
51
|
// Gradient is only applicable to contained buttons
|
|
52
52
|
const showGradient = gradient && type === 'contained';
|
|
53
53
|
|
|
54
54
|
// Get gradient overlay colors (transparent to semi-transparent black/white)
|
|
55
|
+
// Note: Use explicit rgba(0,0,0,0) instead of 'transparent' for RN SVG compatibility
|
|
55
56
|
const getGradientColors = (): [string, string] => {
|
|
56
57
|
switch (gradient) {
|
|
57
|
-
case 'darken': return ['
|
|
58
|
-
case 'lighten': return ['
|
|
59
|
-
default: return ['
|
|
58
|
+
case 'darken': return ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0.15)'];
|
|
59
|
+
case 'lighten': return ['rgba(255, 255, 255, 0)', 'rgba(255, 255, 255, 0.2)'];
|
|
60
|
+
default: return ['rgba(0, 0, 0, 0)', 'rgba(0, 0, 0, 0)'];
|
|
60
61
|
}
|
|
61
62
|
};
|
|
62
63
|
|
|
@@ -133,14 +134,38 @@ const Button = forwardRef<ComponentRef<typeof TouchableOpacity>, ButtonProps>((p
|
|
|
133
134
|
const renderGradientLayer = () => {
|
|
134
135
|
if (!showGradient) return null;
|
|
135
136
|
|
|
136
|
-
const [startColor, endColor] =
|
|
137
|
+
const [startColor, endColor] = useMemo(() => {
|
|
138
|
+
switch (gradient) {
|
|
139
|
+
case 'darken': return [{
|
|
140
|
+
stopColor: 'black',
|
|
141
|
+
stopOpacity: 0,
|
|
142
|
+
}, {
|
|
143
|
+
stopColor: 'black',
|
|
144
|
+
stopOpacity: 0.15,
|
|
145
|
+
}];
|
|
146
|
+
case 'lighten': return [{
|
|
147
|
+
stopColor: 'white',
|
|
148
|
+
stopOpacity: 0,
|
|
149
|
+
}, {
|
|
150
|
+
stopColor: 'white',
|
|
151
|
+
stopOpacity: 0.2,
|
|
152
|
+
}];
|
|
153
|
+
default: return [{
|
|
154
|
+
stopColor: 'black',
|
|
155
|
+
stopOpacity: 0,
|
|
156
|
+
}, {
|
|
157
|
+
stopColor: 'black',
|
|
158
|
+
stopOpacity: 0,
|
|
159
|
+
}];
|
|
160
|
+
}
|
|
161
|
+
}, [gradient]);
|
|
137
162
|
|
|
138
163
|
return (
|
|
139
164
|
<Svg style={RNStyleSheet.absoluteFill}>
|
|
140
165
|
<Defs>
|
|
141
166
|
<LinearGradient id="buttonGradient" x1="0%" y1="0%" x2="100%" y2="100%">
|
|
142
|
-
<Stop offset="0%"
|
|
143
|
-
<Stop offset="100%"
|
|
167
|
+
<Stop offset="0%" {...startColor} />
|
|
168
|
+
<Stop offset="100%" {...endColor} />
|
|
144
169
|
</LinearGradient>
|
|
145
170
|
</Defs>
|
|
146
171
|
<Rect
|
|
@@ -174,7 +199,7 @@ const Button = forwardRef<ComponentRef<typeof TouchableOpacity>, ButtonProps>((p
|
|
|
174
199
|
<TouchableOpacity {...touchableProps as any}>
|
|
175
200
|
{renderGradientLayer()}
|
|
176
201
|
{hasIcons ? (
|
|
177
|
-
<View style={
|
|
202
|
+
<View style={iconContainerStyle}>
|
|
178
203
|
{leftIcon && renderIcon(leftIcon)}
|
|
179
204
|
<Text style={textStyle}>
|
|
180
205
|
{buttonContent}
|