@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.
Files changed (105) hide show
  1. package/package.json +3 -3
  2. package/src/Accordion/Accordion.native.tsx +8 -6
  3. package/src/Accordion/Accordion.styles.old.tsx +298 -0
  4. package/src/Accordion/Accordion.styles.tsx +102 -236
  5. package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
  6. package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
  7. package/src/Alert/Alert.native.tsx +16 -6
  8. package/src/Alert/Alert.styles.old.tsx +209 -0
  9. package/src/Alert/Alert.styles.tsx +67 -149
  10. package/src/Avatar/Avatar.styles.old.tsx +99 -0
  11. package/src/Avatar/Avatar.styles.tsx +35 -80
  12. package/src/Badge/Badge.styles.old.tsx +157 -0
  13. package/src/Badge/Badge.styles.tsx +61 -121
  14. package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
  15. package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
  16. package/src/Breadcrumb/Breadcrumb.web.tsx +28 -23
  17. package/src/Button/Button.styles.tsx +89 -141
  18. package/src/Card/Card.native.tsx +7 -11
  19. package/src/Card/Card.styles.old.tsx +160 -0
  20. package/src/Card/Card.styles.tsx +105 -142
  21. package/src/Card/Card.web.tsx +5 -4
  22. package/src/Checkbox/Checkbox.native.tsx +9 -5
  23. package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
  24. package/src/Checkbox/Checkbox.styles.tsx +104 -216
  25. package/src/Checkbox/Checkbox.web.tsx +6 -6
  26. package/src/Chip/Chip.styles.old.tsx +184 -0
  27. package/src/Chip/Chip.styles.tsx +34 -72
  28. package/src/Dialog/Dialog.native.tsx +7 -4
  29. package/src/Dialog/Dialog.styles.old.tsx +202 -0
  30. package/src/Dialog/Dialog.styles.tsx +69 -133
  31. package/src/Divider/Divider.styles.old.tsx +172 -0
  32. package/src/Divider/Divider.styles.tsx +62 -84
  33. package/src/Icon/Icon.native.tsx +8 -8
  34. package/src/Icon/Icon.styles.old.tsx +81 -0
  35. package/src/Icon/Icon.styles.tsx +52 -66
  36. package/src/Icon/Icon.web.tsx +43 -7
  37. package/src/Icon/IconSvg/IconSvg.web.tsx +2 -0
  38. package/src/Image/Image.styles.old.tsx +69 -0
  39. package/src/Image/Image.styles.tsx +46 -60
  40. package/src/Input/Input.native.tsx +138 -53
  41. package/src/Input/Input.styles.old.tsx +289 -0
  42. package/src/Input/Input.styles.tsx +127 -198
  43. package/src/List/List.native.tsx +5 -2
  44. package/src/List/List.styles.old.tsx +242 -0
  45. package/src/List/List.styles.tsx +179 -215
  46. package/src/List/ListItem.native.tsx +12 -6
  47. package/src/List/ListItem.web.tsx +23 -13
  48. package/src/Menu/Menu.styles.old.tsx +197 -0
  49. package/src/Menu/Menu.styles.tsx +68 -150
  50. package/src/Menu/MenuItem.native.tsx +5 -3
  51. package/src/Menu/MenuItem.styles.old.tsx +114 -0
  52. package/src/Menu/MenuItem.styles.tsx +57 -89
  53. package/src/Menu/MenuItem.web.tsx +8 -3
  54. package/src/Popover/Popover.native.tsx +10 -4
  55. package/src/Popover/Popover.styles.old.tsx +135 -0
  56. package/src/Popover/Popover.styles.tsx +51 -112
  57. package/src/Pressable/Pressable.styles.old.tsx +27 -0
  58. package/src/Pressable/Pressable.styles.tsx +35 -27
  59. package/src/Progress/Progress.styles.old.tsx +200 -0
  60. package/src/Progress/Progress.styles.tsx +75 -164
  61. package/src/RadioButton/RadioButton.native.tsx +4 -3
  62. package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
  63. package/src/RadioButton/RadioButton.styles.tsx +83 -154
  64. package/src/RadioButton/RadioButton.web.tsx +2 -2
  65. package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
  66. package/src/SVGImage/SVGImage.styles.tsx +35 -78
  67. package/src/Screen/Screen.native.tsx +18 -25
  68. package/src/Screen/Screen.styles.old.tsx +87 -0
  69. package/src/Screen/Screen.styles.tsx +105 -67
  70. package/src/Screen/Screen.web.tsx +1 -1
  71. package/src/Select/Select.native.tsx +42 -33
  72. package/src/Select/Select.styles.old.tsx +353 -0
  73. package/src/Select/Select.styles.tsx +223 -292
  74. package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
  75. package/src/Skeleton/Skeleton.styles.tsx +29 -53
  76. package/src/Slider/Slider.styles.old.tsx +259 -0
  77. package/src/Slider/Slider.styles.tsx +153 -234
  78. package/src/Switch/Switch.native.tsx +7 -5
  79. package/src/Switch/Switch.styles.old.tsx +203 -0
  80. package/src/Switch/Switch.styles.tsx +101 -174
  81. package/src/Switch/Switch.web.tsx +5 -5
  82. package/src/TabBar/TabBar.native.tsx +3 -2
  83. package/src/TabBar/TabBar.styles.old.tsx +343 -0
  84. package/src/TabBar/TabBar.styles.tsx +145 -279
  85. package/src/Table/Table.native.tsx +18 -9
  86. package/src/Table/Table.styles.old.tsx +311 -0
  87. package/src/Table/Table.styles.tsx +152 -286
  88. package/src/Text/Text.native.tsx +1 -3
  89. package/src/Text/Text.style.demo.tsx +16 -0
  90. package/src/Text/Text.styles.old.tsx +219 -0
  91. package/src/Text/Text.styles.tsx +94 -84
  92. package/src/Text/Text.web.tsx +2 -2
  93. package/src/Text/index.ts +1 -0
  94. package/src/TextArea/TextArea.styles.old.tsx +213 -0
  95. package/src/TextArea/TextArea.styles.tsx +93 -181
  96. package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
  97. package/src/Tooltip/Tooltip.styles.tsx +32 -56
  98. package/src/Video/Video.styles.old.tsx +51 -0
  99. package/src/Video/Video.styles.tsx +32 -44
  100. package/src/View/View.native.tsx +12 -14
  101. package/src/View/View.styles.old.tsx +125 -0
  102. package/src/View/View.styles.tsx +76 -106
  103. package/src/View/View.web.tsx +1 -0
  104. package/src/examples/CardExamples.tsx +0 -6
  105. package/src/extensions/extendComponent.ts +61 -0
@@ -1,46 +1,77 @@
1
+ /**
2
+ * Screen styles using defineStyle with $iterator expansion.
3
+ */
1
4
  import { StyleSheet } from 'react-native-unistyles';
2
- import { Theme } from '@idealyst/theme';
3
- import {
4
- buildGapVariants,
5
- buildPaddingVariants,
6
- buildPaddingVerticalVariants,
7
- buildPaddingHorizontalVariants,
8
- buildMarginVariants,
9
- buildMarginVerticalVariants,
10
- buildMarginHorizontalVariants,
11
- } from '../utils/buildViewStyleVariants';
12
- import { applyExtensions } from '../extensions/applyExtension';
5
+ import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme } from '@idealyst/theme';
7
+ import { ViewStyleSize } from '../utils/viewStyleProps';
13
8
 
14
- function generateBackgroundVariants(theme: Theme) {
15
- return {
16
- primary: { backgroundColor: theme.colors.surface.primary },
17
- secondary: { backgroundColor: theme.colors.surface.secondary },
18
- tertiary: { backgroundColor: theme.colors.surface.tertiary },
19
- inverse: { backgroundColor: theme.colors.surface.inverse },
20
- 'inverse-secondary': { backgroundColor: theme.colors.surface['inverse-secondary'] },
21
- 'inverse-tertiary': { backgroundColor: theme.colors.surface['inverse-tertiary'] },
22
- transparent: { backgroundColor: 'transparent' },
23
- };
24
- }
9
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
10
+ void StyleSheet;
25
11
 
26
- // Style creators for extension support
27
- function createScreenStyles(theme: Theme) {
28
- return () => ({
12
+ // Wrap theme for $iterator support
13
+ type Theme = ThemeStyleWrapper<BaseTheme>;
14
+
15
+ type ScreenBackground = 'primary' | 'secondary' | 'tertiary' | 'inverse' | 'inverse-secondary' | 'inverse-tertiary' | 'transparent';
16
+
17
+ export type ScreenDynamicProps = {
18
+ background?: ScreenBackground;
19
+ safeArea?: boolean;
20
+ gap?: ViewStyleSize;
21
+ padding?: ViewStyleSize;
22
+ paddingVertical?: ViewStyleSize;
23
+ paddingHorizontal?: ViewStyleSize;
24
+ margin?: ViewStyleSize;
25
+ marginVertical?: ViewStyleSize;
26
+ marginHorizontal?: ViewStyleSize;
27
+ };
28
+
29
+ /**
30
+ * Screen styles with $iterator expansion for spacing variants.
31
+ *
32
+ * NOTE: Top-level theme access required for Unistyles reactivity.
33
+ */
34
+ export const screenStyles = defineStyle('Screen', (theme: Theme) => ({
35
+ screen: (_props: ScreenDynamicProps) => ({
29
36
  flex: 1,
37
+ // Theme marker for Unistyles reactivity
38
+ backgroundColor: theme.colors.surface.primary,
30
39
  variants: {
31
- background: generateBackgroundVariants(theme),
40
+ background: {
41
+ primary: { backgroundColor: theme.colors.surface.primary },
42
+ secondary: { backgroundColor: theme.colors.surface.secondary },
43
+ tertiary: { backgroundColor: theme.colors.surface.tertiary },
44
+ inverse: { backgroundColor: theme.colors.surface.inverse },
45
+ 'inverse-secondary': { backgroundColor: theme.colors.surface['inverse-secondary'] },
46
+ 'inverse-tertiary': { backgroundColor: theme.colors.surface['inverse-tertiary'] },
47
+ transparent: { backgroundColor: 'transparent' },
48
+ },
32
49
  safeArea: {
33
50
  true: {},
34
51
  false: {},
35
52
  },
36
- // Spacing variants from ContainerStyleProps
37
- gap: buildGapVariants(theme),
38
- padding: buildPaddingVariants(theme),
39
- paddingVertical: buildPaddingVerticalVariants(theme),
40
- paddingHorizontal: buildPaddingHorizontalVariants(theme),
41
- margin: buildMarginVariants(theme),
42
- marginVertical: buildMarginVerticalVariants(theme),
43
- marginHorizontal: buildMarginHorizontalVariants(theme),
53
+ // $iterator expands for each view size
54
+ gap: {
55
+ gap: theme.sizes.$view.spacing,
56
+ },
57
+ padding: {
58
+ padding: theme.sizes.$view.padding,
59
+ },
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,
74
+ },
44
75
  },
45
76
  _web: {
46
77
  overflow: 'auto',
@@ -49,39 +80,46 @@ function createScreenStyles(theme: Theme) {
49
80
  minHeight: '100%',
50
81
  boxSizing: 'border-box',
51
82
  },
52
- });
53
- }
54
-
55
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
56
- // transform on native cannot resolve function calls to extract variant structures.
57
- // @ts-ignore - TS language server needs restart to pick up theme structure changes
58
- export const screenStyles = StyleSheet.create((theme: Theme) => {
59
- // Apply extensions to main visual elements
60
- const extended = applyExtensions('Screen', theme, {
61
- screen: createScreenStyles(theme),
62
- });
83
+ }),
63
84
 
64
- return {
65
- ...extended,
66
- // Minor utility styles (not extended)
67
- // Content style for ScrollView - no flex: 1 so content can grow
68
- screenContent: {
69
- backgroundColor: theme.colors.surface.primary,
70
- variants: {
71
- background: generateBackgroundVariants(theme),
72
- safeArea: {
73
- true: {},
74
- false: {},
75
- },
76
- // Spacing variants from ContainerStyleProps
77
- gap: buildGapVariants(theme),
78
- padding: buildPaddingVariants(theme),
79
- paddingVertical: buildPaddingVerticalVariants(theme),
80
- paddingHorizontal: buildPaddingHorizontalVariants(theme),
81
- margin: buildMarginVariants(theme),
82
- marginVertical: buildMarginVerticalVariants(theme),
83
- marginHorizontal: buildMarginHorizontalVariants(theme),
85
+ screenContent: (_props: ScreenDynamicProps) => ({
86
+ // Theme marker for Unistyles reactivity
87
+ backgroundColor: theme.colors.surface.primary,
88
+ variants: {
89
+ background: {
90
+ primary: { backgroundColor: theme.colors.surface.primary },
91
+ secondary: { backgroundColor: theme.colors.surface.secondary },
92
+ tertiary: { backgroundColor: theme.colors.surface.tertiary },
93
+ inverse: { backgroundColor: theme.colors.surface.inverse },
94
+ 'inverse-secondary': { backgroundColor: theme.colors.surface['inverse-secondary'] },
95
+ 'inverse-tertiary': { backgroundColor: theme.colors.surface['inverse-tertiary'] },
96
+ transparent: { backgroundColor: 'transparent' },
97
+ },
98
+ safeArea: {
99
+ true: {},
100
+ false: {},
101
+ },
102
+ gap: {
103
+ gap: theme.sizes.$view.spacing,
104
+ },
105
+ padding: {
106
+ padding: theme.sizes.$view.padding,
107
+ },
108
+ paddingVertical: {
109
+ paddingVertical: theme.sizes.$view.padding,
110
+ },
111
+ paddingHorizontal: {
112
+ paddingHorizontal: theme.sizes.$view.padding,
113
+ },
114
+ margin: {
115
+ margin: theme.sizes.$view.padding,
116
+ },
117
+ marginVertical: {
118
+ marginVertical: theme.sizes.$view.padding,
119
+ },
120
+ marginHorizontal: {
121
+ marginHorizontal: theme.sizes.$view.padding,
84
122
  },
85
123
  },
86
- };
87
- });
124
+ }),
125
+ }));
@@ -32,7 +32,7 @@ const Screen = forwardRef<HTMLDivElement, ScreenProps>(({
32
32
  marginHorizontal,
33
33
  });
34
34
 
35
- // Use getWebProps to generate className and ref for web
35
+ // Call style as function to get theme-reactive styles
36
36
  const webProps = getWebProps([(screenStyles.screen as any)({}), style as any]);
37
37
 
38
38
  const mergedRef = useMergeRefs(ref, webProps.ref);
@@ -86,6 +86,27 @@ const Select = forwardRef<View, SelectProps>(({
86
86
  marginHorizontal,
87
87
  });
88
88
 
89
+ // Get dynamic styles - call as functions for theme reactivity
90
+ const containerStyle = (selectStyles.container as any)({});
91
+ const labelStyle = (selectStyles.label as any)({});
92
+ const triggerStyle = (selectStyles.trigger as any)({ type, intent, disabled, error, focused: isOpen });
93
+ const triggerContentStyle = (selectStyles.triggerContent as any)({});
94
+ const triggerTextStyle = (selectStyles.triggerText as any)({});
95
+ const placeholderStyle = (selectStyles.placeholder as any)({});
96
+ const iconStyle = (selectStyles.icon as any)({});
97
+ const chevronStyle = (selectStyles.chevron as any)({});
98
+ const dropdownStyle = (selectStyles.dropdown as any)({});
99
+ const searchContainerStyle = (selectStyles.searchContainer as any)({});
100
+ const searchInputStyle = (selectStyles.searchInput as any)({});
101
+ const optionsListStyle = (selectStyles.optionsList as any)({});
102
+ const optionStyle = (selectStyles.option as any)({});
103
+ const optionContentStyle = (selectStyles.optionContent as any)({});
104
+ const optionIconStyle = (selectStyles.optionIcon as any)({});
105
+ const optionTextStyle = (selectStyles.optionText as any)({});
106
+ const optionTextDisabledStyle = (selectStyles.optionTextDisabled as any)({});
107
+ const helperTextStyle = (selectStyles.helperText as any)({ error });
108
+ const overlayStyle = (selectStyles.overlay as any)({});
109
+
89
110
  const handleTriggerPress = () => {
90
111
  if (disabled) return;
91
112
 
@@ -158,10 +179,10 @@ const Select = forwardRef<View, SelectProps>(({
158
179
 
159
180
  const renderChevron = () => {
160
181
  return (
161
- <View style={selectStyles.chevron}>
182
+ <View style={chevronStyle}>
162
183
  <MaterialCommunityIcons
163
184
  name="chevron-down"
164
- style={selectStyles.chevron}
185
+ style={chevronStyle}
165
186
  />
166
187
  </View>
167
188
  );
@@ -172,7 +193,6 @@ const Select = forwardRef<View, SelectProps>(({
172
193
 
173
194
  // If it's a string, render as MaterialCommunityIcons
174
195
  if (typeof icon === 'string') {
175
- const iconStyle = selectStyles.icon;
176
196
  return (
177
197
  <View style={iconStyle}>
178
198
  <MaterialCommunityIcons
@@ -184,7 +204,7 @@ const Select = forwardRef<View, SelectProps>(({
184
204
  }
185
205
 
186
206
  // Otherwise render the React element directly
187
- return <View style={selectStyles.icon}>{icon}</View>;
207
+ return <View style={iconStyle}>{icon}</View>;
188
208
  };
189
209
 
190
210
  const renderOptionIcon = (icon: any) => {
@@ -192,11 +212,10 @@ const Select = forwardRef<View, SelectProps>(({
192
212
 
193
213
  // If it's a string, render as MaterialCommunityIcons
194
214
  if (typeof icon === 'string') {
195
- const iconStyle = selectStyles.optionIcon;
196
215
  return (
197
- <View style={iconStyle}>
216
+ <View style={optionIconStyle}>
198
217
  <MaterialCommunityIcons
199
- style={iconStyle}
218
+ style={optionIconStyle}
200
219
  name={icon}
201
220
  />
202
221
  </View>
@@ -204,7 +223,7 @@ const Select = forwardRef<View, SelectProps>(({
204
223
  }
205
224
 
206
225
  // Otherwise render the React element directly
207
- return <View style={selectStyles.optionIcon}>{icon}</View>;
226
+ return <View style={optionIconStyle}>{icon}</View>;
208
227
  };
209
228
 
210
229
  const renderDropdown = () => {
@@ -222,7 +241,7 @@ const Select = forwardRef<View, SelectProps>(({
222
241
  onRequestClose={closeDropdown}
223
242
  >
224
243
  <Pressable
225
- style={selectStyles.overlay}
244
+ style={overlayStyle}
226
245
  onPress={closeDropdown}
227
246
  >
228
247
  <BoundedModalContent
@@ -233,7 +252,7 @@ const Select = forwardRef<View, SelectProps>(({
233
252
  >
234
253
  <Animated.View
235
254
  style={[
236
- (selectStyles.dropdown as any)({}),
255
+ dropdownStyle,
237
256
  {
238
257
  position: 'relative', // Override absolute positioning from styles
239
258
  top: 0, // Override top: '100%' from styles
@@ -246,9 +265,9 @@ const Select = forwardRef<View, SelectProps>(({
246
265
  onLayout={handleDropdownLayout}
247
266
  >
248
267
  {searchable && (
249
- <View style={selectStyles.searchContainer}>
268
+ <View style={searchContainerStyle}>
250
269
  <TextInput
251
- style={selectStyles.searchInput}
270
+ style={searchInputStyle}
252
271
  placeholder="Search options..."
253
272
  value={searchTerm}
254
273
  onChangeText={handleSearchChange}
@@ -258,23 +277,23 @@ const Select = forwardRef<View, SelectProps>(({
258
277
  )}
259
278
 
260
279
  <ScrollView
261
- style={selectStyles.optionsList}
280
+ style={optionsListStyle}
262
281
  showsVerticalScrollIndicator={true}
263
282
  >
264
283
  {filteredOptions.map((option) => (
265
284
  <Pressable
266
285
  key={option.value}
267
- style={(selectStyles.option as any)({})}
286
+ style={optionStyle}
268
287
  onPress={() => handleOptionSelect(option)}
269
288
  disabled={option.disabled}
270
289
  android_ripple={{ color: 'rgba(0, 0, 0, 0.1)' }}
271
290
  >
272
- <View style={selectStyles.optionContent}>
291
+ <View style={optionContentStyle}>
273
292
  {renderOptionIcon(option.icon)}
274
293
  <Text
275
294
  style={[
276
- selectStyles.optionText,
277
- option.disabled && selectStyles.optionTextDisabled,
295
+ optionTextStyle,
296
+ option.disabled && optionTextDisabledStyle,
278
297
  ]}
279
298
  >
280
299
  {option.label}
@@ -284,8 +303,8 @@ const Select = forwardRef<View, SelectProps>(({
284
303
  ))}
285
304
 
286
305
  {filteredOptions.length === 0 && (
287
- <View style={(selectStyles.option as any)({})}>
288
- <Text style={selectStyles.optionText}>
306
+ <View style={optionStyle}>
307
+ <Text style={optionTextStyle}>
289
308
  No options found
290
309
  </Text>
291
310
  </View>
@@ -298,16 +317,10 @@ const Select = forwardRef<View, SelectProps>(({
298
317
  );
299
318
  };
300
319
 
301
- // Get dynamic styles
302
- const containerStyle = (selectStyles.container as any)({});
303
- const triggerStyle = (selectStyles.trigger as any)({ type, intent });
304
- const dropdownStyle = (selectStyles.dropdown as any)({});
305
- const optionStyle = (selectStyles.option as any)({});
306
-
307
320
  return (
308
321
  <View ref={ref} nativeID={id} style={[containerStyle, style]} testID={testID}>
309
322
  {label && (
310
- <Text style={selectStyles.label}>
323
+ <Text style={labelStyle}>
311
324
  {label}
312
325
  </Text>
313
326
  )}
@@ -325,11 +338,11 @@ const Select = forwardRef<View, SelectProps>(({
325
338
  }}
326
339
  android_ripple={{ color: 'rgba(0, 0, 0, 0.1)' }}
327
340
  >
328
- <View style={selectStyles.triggerContent}>
341
+ <View style={triggerContentStyle}>
329
342
  {renderTriggerIcon(selectedOption?.icon)}
330
343
  <Text
331
344
  style={[
332
- selectedOption ? selectStyles.triggerText : selectStyles.placeholder,
345
+ selectedOption ? triggerTextStyle : placeholderStyle,
333
346
  ]}
334
347
  numberOfLines={1}
335
348
  >
@@ -344,11 +357,7 @@ const Select = forwardRef<View, SelectProps>(({
344
357
  {!(Platform.OS === 'ios' && presentationMode === 'actionSheet') && renderDropdown()}
345
358
 
346
359
  {helperText && (
347
- <Text
348
- style={[
349
- selectStyles.helperText,
350
- ]}
351
- >
360
+ <Text style={helperTextStyle}>
352
361
  {helperText}
353
362
  </Text>
354
363
  )}