@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,207 +1,134 @@
1
+ /**
2
+ * Switch styles using defineStyle with dynamic props.
3
+ */
1
4
  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 { 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
- function createTrackSizeVariants(theme: Theme) {
13
- return buildSizeVariants(theme, 'switch', (size) => ({
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
- function getTrackBackgroundColor(theme: Theme, checked: boolean, intent: SwitchIntentVariant) {
20
- if (checked) {
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
- function createThumbSizeVariants(theme: Theme) {
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
- function getThumbTransform(theme: Theme, size: SwitchSizeVariant, checked: boolean) {
35
- const sizeValue = theme.sizes.switch[size];
36
- const translateX = checked ? sizeValue.translateX : 0;
37
- return `translateY(-50%) translateX(${translateX}px)`;
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
- function createThumbIconSizeVariants(theme: Theme) {
41
- return buildSizeVariants(theme, 'switch', (size) => ({
42
- width: size.thumbIconSize,
43
- height: size.thumbIconSize,
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
- function getThumbIconColor(theme: Theme, checked: boolean, intent: SwitchIntentVariant) {
48
- if (checked) {
49
- return theme.intents[intent].primary;
50
- }
51
- return theme.colors.border.secondary;
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
- function createSwitchTrackStyles(theme: Theme) {
55
- return ({ checked, intent }: { checked: boolean, intent: SwitchIntentVariant }) => {
56
- return {
57
- borderRadius: 9999,
58
- position: 'relative',
59
- backgroundColor: getTrackBackgroundColor(theme, checked, intent),
60
- variants: {
61
- size: createTrackSizeVariants(theme),
62
- disabled: {
63
- true: {
64
- opacity: 0.5,
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
- } as const;
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: createThumbSizeVariants(theme),
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: getThumbTransform(theme, size, checked),
107
+ transform: `translateY(-50%) translateX(${translateX}px)`,
112
108
  },
113
109
  } as const;
114
- }
115
- }
110
+ },
116
111
 
117
- function createThumbIconStyles(theme: Theme) {
118
- return ({ checked, intent }: { checked: boolean, intent: SwitchIntentVariant }) => {
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
- _web: {
154
- border: 'none',
155
- padding: 0,
156
- backgroundColor: 'transparent',
157
- width: 'fit-content',
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
- variants: {
170
- disabled: {
171
- true: {
172
- opacity: 0.5,
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={tabBarIconStyles.tabIcon as any}>{icon}</View>}
203
+ {icon && <View style={iconContainerStyle}>{icon}</View>}
203
204
  <Text style={labelStyle}>{item.label}</Text>
204
205
  </TouchableOpacity>
205
206
  );