@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
|
@@ -0,0 +1,353 @@
|
|
|
1
|
+
import { StyleSheet } from 'react-native-unistyles';
|
|
2
|
+
import { Theme, StylesheetStyles, Intent, Size } from '@idealyst/theme';
|
|
3
|
+
import { buildSizeVariants } from '../utils/buildSizeVariants';
|
|
4
|
+
import {
|
|
5
|
+
buildMarginVariants,
|
|
6
|
+
buildMarginVerticalVariants,
|
|
7
|
+
buildMarginHorizontalVariants,
|
|
8
|
+
} from '../utils/buildViewStyleVariants';
|
|
9
|
+
import { SelectIntentVariant } from './types';
|
|
10
|
+
import { applyExtensions } from '../extensions/applyExtension';
|
|
11
|
+
|
|
12
|
+
// Type definitions
|
|
13
|
+
type SelectSize = Size;
|
|
14
|
+
type SelectType = 'outlined' | 'filled';
|
|
15
|
+
|
|
16
|
+
type SelectTriggerVariants = {
|
|
17
|
+
type: SelectType;
|
|
18
|
+
size: SelectSize;
|
|
19
|
+
intent: SelectIntentVariant;
|
|
20
|
+
disabled: boolean;
|
|
21
|
+
error: boolean;
|
|
22
|
+
focused: boolean;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
export type ExpandedSelectTriggerStyles = StylesheetStyles<keyof SelectTriggerVariants>;
|
|
27
|
+
export type ExpandedSelectStyles = StylesheetStyles<never>;
|
|
28
|
+
|
|
29
|
+
function createTriggerTypeVariants(theme: Theme) {
|
|
30
|
+
return {
|
|
31
|
+
outlined: {
|
|
32
|
+
backgroundColor: theme.colors.surface.primary,
|
|
33
|
+
borderColor: theme.colors.border.primary,
|
|
34
|
+
_web: {
|
|
35
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
36
|
+
},
|
|
37
|
+
},
|
|
38
|
+
filled: {
|
|
39
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
40
|
+
borderColor: 'transparent',
|
|
41
|
+
_web: {
|
|
42
|
+
border: '1px solid transparent',
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
} as const;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
function createTriggerSizeVariants(theme: Theme) {
|
|
49
|
+
return buildSizeVariants(theme, 'select', (size) => ({
|
|
50
|
+
paddingHorizontal: size.paddingHorizontal,
|
|
51
|
+
minHeight: size.minHeight,
|
|
52
|
+
}));
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
function createIntentVariants(theme: Theme, type: SelectType, intent: SelectIntentVariant) {
|
|
56
|
+
if (intent === 'neutral') {
|
|
57
|
+
return {};
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
const intentValue = (theme.intents as any)[intent];
|
|
61
|
+
|
|
62
|
+
if (type === 'outlined') {
|
|
63
|
+
return {
|
|
64
|
+
borderColor: intentValue.primary,
|
|
65
|
+
_web: {
|
|
66
|
+
border: `1px solid ${intentValue.primary}`,
|
|
67
|
+
},
|
|
68
|
+
} as const;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
return {} as const;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function buildDynamicTriggerStyles(theme: Theme) {
|
|
75
|
+
return ({ type, intent }: Partial<SelectTriggerVariants>) => {
|
|
76
|
+
const intentStyles = createIntentVariants(theme, type, intent);
|
|
77
|
+
|
|
78
|
+
return {
|
|
79
|
+
position: 'relative',
|
|
80
|
+
flexDirection: 'row',
|
|
81
|
+
alignItems: 'center',
|
|
82
|
+
justifyContent: 'space-between',
|
|
83
|
+
borderRadius: 8,
|
|
84
|
+
borderWidth: 1,
|
|
85
|
+
borderStyle: 'solid',
|
|
86
|
+
...intentStyles,
|
|
87
|
+
variants: {
|
|
88
|
+
type: createTriggerTypeVariants(theme),
|
|
89
|
+
size: createTriggerSizeVariants(theme),
|
|
90
|
+
disabled: {
|
|
91
|
+
true: {
|
|
92
|
+
opacity: 0.6,
|
|
93
|
+
_web: {
|
|
94
|
+
cursor: 'not-allowed',
|
|
95
|
+
},
|
|
96
|
+
},
|
|
97
|
+
false: {
|
|
98
|
+
_web: {
|
|
99
|
+
cursor: 'pointer',
|
|
100
|
+
_hover: {
|
|
101
|
+
opacity: 0.9,
|
|
102
|
+
},
|
|
103
|
+
_active: {
|
|
104
|
+
opacity: 0.8,
|
|
105
|
+
},
|
|
106
|
+
},
|
|
107
|
+
},
|
|
108
|
+
},
|
|
109
|
+
error: {
|
|
110
|
+
true: {
|
|
111
|
+
borderColor: theme.intents.error.primary,
|
|
112
|
+
_web: {
|
|
113
|
+
border: `1px solid ${theme.intents.error.primary}`,
|
|
114
|
+
},
|
|
115
|
+
},
|
|
116
|
+
false: {},
|
|
117
|
+
},
|
|
118
|
+
focused: {
|
|
119
|
+
true: {
|
|
120
|
+
borderColor: theme.intents.primary.primary,
|
|
121
|
+
_web: {
|
|
122
|
+
border: `1px solid ${theme.intents.primary.primary}`,
|
|
123
|
+
boxShadow: `0 0 0 2px ${theme.intents.primary.primary}20`,
|
|
124
|
+
outline: 'none',
|
|
125
|
+
},
|
|
126
|
+
},
|
|
127
|
+
false: {},
|
|
128
|
+
},
|
|
129
|
+
},
|
|
130
|
+
_web: {
|
|
131
|
+
display: 'flex',
|
|
132
|
+
boxSizing: 'border-box',
|
|
133
|
+
_focus: {
|
|
134
|
+
outline: 'none',
|
|
135
|
+
},
|
|
136
|
+
},
|
|
137
|
+
} as const;
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
// Main element style creators (wrapped for extension support)
|
|
142
|
+
function createContainerStyles(theme: Theme) {
|
|
143
|
+
return () => ({
|
|
144
|
+
position: 'relative' as const,
|
|
145
|
+
variants: {
|
|
146
|
+
margin: buildMarginVariants(theme),
|
|
147
|
+
marginVertical: buildMarginVerticalVariants(theme),
|
|
148
|
+
marginHorizontal: buildMarginHorizontalVariants(theme),
|
|
149
|
+
},
|
|
150
|
+
});
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
function createDropdownStyles(theme: Theme) {
|
|
154
|
+
return () => ({
|
|
155
|
+
position: 'absolute' as const,
|
|
156
|
+
top: '100%',
|
|
157
|
+
left: 0,
|
|
158
|
+
right: 0,
|
|
159
|
+
backgroundColor: theme.colors.surface.primary,
|
|
160
|
+
borderRadius: 8,
|
|
161
|
+
borderWidth: 1,
|
|
162
|
+
borderStyle: 'solid' as const,
|
|
163
|
+
borderColor: theme.colors.border.primary,
|
|
164
|
+
shadowColor: '#000',
|
|
165
|
+
shadowOffset: { width: 0, height: 8 },
|
|
166
|
+
shadowOpacity: 0.1,
|
|
167
|
+
shadowRadius: 24,
|
|
168
|
+
elevation: 8,
|
|
169
|
+
zIndex: 9999,
|
|
170
|
+
maxHeight: 240,
|
|
171
|
+
minWidth: 200,
|
|
172
|
+
overflow: 'hidden' as const,
|
|
173
|
+
_web: {
|
|
174
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
175
|
+
boxShadow: '0 8px 24px rgba(0, 0, 0, 0.1), 0 4px 8px rgba(0, 0, 0, 0.06)',
|
|
176
|
+
overflowY: 'auto',
|
|
177
|
+
},
|
|
178
|
+
});
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
function createOptionStyles(theme: Theme) {
|
|
182
|
+
return () => ({
|
|
183
|
+
paddingHorizontal: 8,
|
|
184
|
+
paddingVertical: 4,
|
|
185
|
+
flexDirection: 'row' as const,
|
|
186
|
+
alignItems: 'center' as const,
|
|
187
|
+
minHeight: 36,
|
|
188
|
+
_web: {
|
|
189
|
+
display: 'flex',
|
|
190
|
+
cursor: 'pointer',
|
|
191
|
+
_hover: {
|
|
192
|
+
backgroundColor: theme.colors.surface.secondary,
|
|
193
|
+
},
|
|
194
|
+
_active: {
|
|
195
|
+
opacity: 0.8,
|
|
196
|
+
},
|
|
197
|
+
},
|
|
198
|
+
});
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
// Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
|
|
202
|
+
// transform on native cannot resolve function calls to extract variant structures.
|
|
203
|
+
export const selectStyles = StyleSheet.create((theme: Theme) => {
|
|
204
|
+
return applyExtensions('Select', theme, {
|
|
205
|
+
container: createContainerStyles(theme),
|
|
206
|
+
trigger: buildDynamicTriggerStyles(theme),
|
|
207
|
+
dropdown: createDropdownStyles(theme),
|
|
208
|
+
option: createOptionStyles(theme),
|
|
209
|
+
// Minor utility styles
|
|
210
|
+
label: {
|
|
211
|
+
fontSize: 14,
|
|
212
|
+
fontWeight: '500',
|
|
213
|
+
color: theme.colors.text.primary,
|
|
214
|
+
marginBottom: 4,
|
|
215
|
+
},
|
|
216
|
+
triggerContent: {
|
|
217
|
+
flex: 1,
|
|
218
|
+
flexDirection: 'row',
|
|
219
|
+
alignItems: 'center',
|
|
220
|
+
},
|
|
221
|
+
triggerText: {
|
|
222
|
+
color: theme.colors.text.primary,
|
|
223
|
+
flex: 1,
|
|
224
|
+
variants: {
|
|
225
|
+
size: buildSizeVariants(theme, 'select', (size: any) => ({
|
|
226
|
+
fontSize: size.fontSize,
|
|
227
|
+
})),
|
|
228
|
+
},
|
|
229
|
+
},
|
|
230
|
+
placeholder: {
|
|
231
|
+
color: theme.colors.text.secondary,
|
|
232
|
+
variants: {
|
|
233
|
+
size: buildSizeVariants(theme, 'select', (size: any) => ({
|
|
234
|
+
fontSize: size.fontSize,
|
|
235
|
+
})),
|
|
236
|
+
},
|
|
237
|
+
},
|
|
238
|
+
icon: {
|
|
239
|
+
marginLeft: 4,
|
|
240
|
+
color: theme.colors.text.secondary,
|
|
241
|
+
},
|
|
242
|
+
chevron: {
|
|
243
|
+
display: 'flex',
|
|
244
|
+
alignItems: 'center',
|
|
245
|
+
justifyContent: 'center',
|
|
246
|
+
marginLeft: 4,
|
|
247
|
+
color: theme.colors.text.secondary,
|
|
248
|
+
variants: {
|
|
249
|
+
size: buildSizeVariants(theme, 'select', (size: any) => ({
|
|
250
|
+
width: size.iconSize,
|
|
251
|
+
height: size.iconSize,
|
|
252
|
+
})),
|
|
253
|
+
},
|
|
254
|
+
_web: {
|
|
255
|
+
transition: 'transform 0.2s ease',
|
|
256
|
+
},
|
|
257
|
+
},
|
|
258
|
+
chevronOpen: {
|
|
259
|
+
_web: {
|
|
260
|
+
transform: 'rotate(180deg)',
|
|
261
|
+
}
|
|
262
|
+
},
|
|
263
|
+
searchContainer: {
|
|
264
|
+
padding: 8,
|
|
265
|
+
borderBottomWidth: 1,
|
|
266
|
+
borderBottomStyle: 'solid',
|
|
267
|
+
borderBottomColor: theme.colors.border.primary,
|
|
268
|
+
_web: {
|
|
269
|
+
borderBottom: `1px solid ${theme.colors.border.primary}`,
|
|
270
|
+
},
|
|
271
|
+
},
|
|
272
|
+
searchInput: {
|
|
273
|
+
padding: 4,
|
|
274
|
+
borderRadius: 4,
|
|
275
|
+
borderWidth: 1,
|
|
276
|
+
borderStyle: 'solid',
|
|
277
|
+
borderColor: theme.colors.border.primary,
|
|
278
|
+
backgroundColor: theme.colors.surface.primary,
|
|
279
|
+
variants: {
|
|
280
|
+
size: buildSizeVariants(theme, 'select', (size: any) => ({
|
|
281
|
+
fontSize: size.fontSize,
|
|
282
|
+
})),
|
|
283
|
+
},
|
|
284
|
+
_web: {
|
|
285
|
+
border: `1px solid ${theme.colors.border.primary}`,
|
|
286
|
+
outline: 'none',
|
|
287
|
+
_focus: {
|
|
288
|
+
borderColor: theme.intents.primary.primary,
|
|
289
|
+
},
|
|
290
|
+
},
|
|
291
|
+
},
|
|
292
|
+
optionsList: {
|
|
293
|
+
paddingVertical: 4,
|
|
294
|
+
},
|
|
295
|
+
optionFocused: {
|
|
296
|
+
backgroundColor: theme.interaction.focusedBackground,
|
|
297
|
+
_web: {
|
|
298
|
+
outline: `1px solid ${theme.interaction.focusBorder}`,
|
|
299
|
+
outlineOffset: -1,
|
|
300
|
+
},
|
|
301
|
+
},
|
|
302
|
+
optionDisabled: {
|
|
303
|
+
opacity: theme.interaction.opacity.disabled,
|
|
304
|
+
_web: {
|
|
305
|
+
cursor: 'not-allowed',
|
|
306
|
+
},
|
|
307
|
+
},
|
|
308
|
+
optionContent: {
|
|
309
|
+
flexDirection: 'row',
|
|
310
|
+
alignItems: 'center',
|
|
311
|
+
flex: 1,
|
|
312
|
+
},
|
|
313
|
+
optionIcon: {
|
|
314
|
+
marginRight: 4,
|
|
315
|
+
},
|
|
316
|
+
optionText: {
|
|
317
|
+
color: theme.colors.text.primary,
|
|
318
|
+
flex: 1,
|
|
319
|
+
variants: {
|
|
320
|
+
size: buildSizeVariants(theme, 'select', (size: any) => ({
|
|
321
|
+
fontSize: size.fontSize,
|
|
322
|
+
})),
|
|
323
|
+
},
|
|
324
|
+
},
|
|
325
|
+
optionTextDisabled: {
|
|
326
|
+
color: theme.colors.text.secondary,
|
|
327
|
+
},
|
|
328
|
+
helperText: {
|
|
329
|
+
fontSize: 12,
|
|
330
|
+
marginTop: 4,
|
|
331
|
+
color: theme.colors.text.secondary,
|
|
332
|
+
variants: {
|
|
333
|
+
error: {
|
|
334
|
+
true: {
|
|
335
|
+
color: theme.intents.error.primary,
|
|
336
|
+
},
|
|
337
|
+
false: {},
|
|
338
|
+
},
|
|
339
|
+
},
|
|
340
|
+
},
|
|
341
|
+
overlay: {
|
|
342
|
+
position: 'absolute',
|
|
343
|
+
top: 0,
|
|
344
|
+
left: 0,
|
|
345
|
+
right: 0,
|
|
346
|
+
bottom: 0,
|
|
347
|
+
zIndex: 999,
|
|
348
|
+
_web: {
|
|
349
|
+
position: 'fixed',
|
|
350
|
+
},
|
|
351
|
+
},
|
|
352
|
+
});
|
|
353
|
+
});
|