@idealyst/components 1.1.7 → 1.1.9

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 (129) hide show
  1. package/package.json +3 -3
  2. package/plugin/web.js +280 -532
  3. package/src/Accordion/Accordion.native.tsx +8 -6
  4. package/src/Accordion/Accordion.styles.old.tsx +298 -0
  5. package/src/Accordion/Accordion.styles.tsx +102 -236
  6. package/src/Accordion/Accordion.web.tsx +1 -3
  7. package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
  8. package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
  9. package/src/Alert/Alert.native.tsx +16 -6
  10. package/src/Alert/Alert.styles.old.tsx +209 -0
  11. package/src/Alert/Alert.styles.tsx +67 -149
  12. package/src/Alert/Alert.web.tsx +3 -4
  13. package/src/Avatar/Avatar.styles.old.tsx +99 -0
  14. package/src/Avatar/Avatar.styles.tsx +35 -80
  15. package/src/Badge/Badge.styles.old.tsx +157 -0
  16. package/src/Badge/Badge.styles.tsx +61 -121
  17. package/src/Badge/Badge.web.tsx +8 -15
  18. package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
  19. package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
  20. package/src/Breadcrumb/Breadcrumb.web.tsx +31 -30
  21. package/src/Button/Button.native.tsx +14 -21
  22. package/src/Button/Button.styles.tsx +103 -140
  23. package/src/Button/Button.web.tsx +9 -19
  24. package/src/Card/Card.native.tsx +7 -11
  25. package/src/Card/Card.styles.old.tsx +160 -0
  26. package/src/Card/Card.styles.tsx +105 -142
  27. package/src/Card/Card.web.tsx +5 -4
  28. package/src/Checkbox/Checkbox.native.tsx +9 -5
  29. package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
  30. package/src/Checkbox/Checkbox.styles.tsx +104 -216
  31. package/src/Checkbox/Checkbox.web.tsx +7 -8
  32. package/src/Chip/Chip.styles.old.tsx +184 -0
  33. package/src/Chip/Chip.styles.tsx +34 -72
  34. package/src/Chip/Chip.web.tsx +3 -5
  35. package/src/Dialog/Dialog.native.tsx +7 -4
  36. package/src/Dialog/Dialog.styles.old.tsx +202 -0
  37. package/src/Dialog/Dialog.styles.tsx +69 -133
  38. package/src/Dialog/Dialog.web.tsx +3 -3
  39. package/src/Dialog/types.ts +1 -1
  40. package/src/Divider/Divider.styles.old.tsx +172 -0
  41. package/src/Divider/Divider.styles.tsx +62 -84
  42. package/src/Icon/Icon.native.tsx +8 -8
  43. package/src/Icon/Icon.styles.old.tsx +81 -0
  44. package/src/Icon/Icon.styles.tsx +52 -66
  45. package/src/Icon/Icon.web.tsx +62 -21
  46. package/src/Icon/IconRegistry.native.ts +41 -0
  47. package/src/Icon/IconRegistry.ts +107 -0
  48. package/src/Icon/IconSvg/IconSvg.web.tsx +28 -5
  49. package/src/Icon/icon-resolver.ts +12 -43
  50. package/src/Icon/index.native.ts +2 -1
  51. package/src/Icon/index.ts +1 -0
  52. package/src/Icon/index.web.ts +1 -0
  53. package/src/Image/Image.styles.old.tsx +69 -0
  54. package/src/Image/Image.styles.tsx +46 -60
  55. package/src/Input/Input.native.tsx +138 -53
  56. package/src/Input/Input.styles.old.tsx +289 -0
  57. package/src/Input/Input.styles.tsx +134 -232
  58. package/src/Input/Input.web.tsx +5 -8
  59. package/src/List/List.native.tsx +5 -2
  60. package/src/List/List.styles.old.tsx +242 -0
  61. package/src/List/List.styles.tsx +179 -215
  62. package/src/List/ListItem.native.tsx +16 -11
  63. package/src/List/ListItem.web.tsx +26 -16
  64. package/src/Menu/Menu.styles.old.tsx +197 -0
  65. package/src/Menu/Menu.styles.tsx +68 -150
  66. package/src/Menu/MenuItem.native.tsx +5 -3
  67. package/src/Menu/MenuItem.styles.old.tsx +114 -0
  68. package/src/Menu/MenuItem.styles.tsx +57 -89
  69. package/src/Menu/MenuItem.web.tsx +10 -7
  70. package/src/Popover/Popover.native.tsx +10 -4
  71. package/src/Popover/Popover.styles.old.tsx +135 -0
  72. package/src/Popover/Popover.styles.tsx +51 -112
  73. package/src/Pressable/Pressable.styles.old.tsx +27 -0
  74. package/src/Pressable/Pressable.styles.tsx +35 -27
  75. package/src/Progress/Progress.styles.old.tsx +200 -0
  76. package/src/Progress/Progress.styles.tsx +75 -164
  77. package/src/RadioButton/RadioButton.native.tsx +4 -3
  78. package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
  79. package/src/RadioButton/RadioButton.styles.tsx +83 -154
  80. package/src/RadioButton/RadioButton.web.tsx +2 -2
  81. package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
  82. package/src/SVGImage/SVGImage.styles.tsx +35 -78
  83. package/src/Screen/Screen.native.tsx +19 -26
  84. package/src/Screen/Screen.styles.old.tsx +87 -0
  85. package/src/Screen/Screen.styles.tsx +103 -68
  86. package/src/Screen/Screen.web.tsx +2 -2
  87. package/src/Select/Select.native.tsx +42 -33
  88. package/src/Select/Select.styles.old.tsx +353 -0
  89. package/src/Select/Select.styles.tsx +214 -300
  90. package/src/Select/Select.web.tsx +45 -33
  91. package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
  92. package/src/Skeleton/Skeleton.styles.tsx +29 -53
  93. package/src/Slider/Slider.styles.old.tsx +259 -0
  94. package/src/Slider/Slider.styles.tsx +153 -234
  95. package/src/Slider/Slider.web.tsx +2 -4
  96. package/src/Switch/Switch.native.tsx +9 -7
  97. package/src/Switch/Switch.styles.old.tsx +203 -0
  98. package/src/Switch/Switch.styles.tsx +101 -174
  99. package/src/Switch/Switch.web.tsx +7 -8
  100. package/src/TabBar/TabBar.native.tsx +3 -2
  101. package/src/TabBar/TabBar.styles.old.tsx +343 -0
  102. package/src/TabBar/TabBar.styles.tsx +145 -279
  103. package/src/Table/Table.native.tsx +180 -68
  104. package/src/Table/Table.styles.old.tsx +311 -0
  105. package/src/Table/Table.styles.tsx +140 -281
  106. package/src/Table/Table.web.tsx +169 -70
  107. package/src/Text/Text.native.tsx +1 -3
  108. package/src/Text/Text.style.demo.tsx +16 -0
  109. package/src/Text/Text.styles.old.tsx +219 -0
  110. package/src/Text/Text.styles.tsx +94 -84
  111. package/src/Text/Text.web.tsx +3 -2
  112. package/src/Text/index.ts +1 -0
  113. package/src/TextArea/TextArea.native.tsx +21 -8
  114. package/src/TextArea/TextArea.styles.old.tsx +213 -0
  115. package/src/TextArea/TextArea.styles.tsx +87 -187
  116. package/src/TextArea/TextArea.web.tsx +17 -6
  117. package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
  118. package/src/Tooltip/Tooltip.styles.tsx +32 -56
  119. package/src/Video/Video.styles.old.tsx +51 -0
  120. package/src/Video/Video.styles.tsx +32 -44
  121. package/src/View/View.native.tsx +41 -13
  122. package/src/View/View.styles.old.tsx +125 -0
  123. package/src/View/View.styles.tsx +76 -106
  124. package/src/View/View.web.tsx +5 -21
  125. package/src/View/types.ts +31 -3
  126. package/src/examples/ButtonExamples.tsx +20 -0
  127. package/src/examples/CardExamples.tsx +0 -6
  128. package/src/extensions/extendComponent.ts +61 -0
  129. package/src/index.ts +1 -1
@@ -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
+ }));
@@ -3,7 +3,7 @@ import { getWebProps } from 'react-native-unistyles/web';
3
3
  import { switchStyles } from './Switch.styles';
4
4
  import type { SwitchProps } from './types';
5
5
  import { IconSvg } from '../Icon/IconSvg/IconSvg.web';
6
- import { resolveIconPath, isIconName } from '../Icon/icon-resolver';
6
+ import { isIconName } from '../Icon/icon-resolver';
7
7
  import useMergeRefs from '../hooks/useMergeRefs';
8
8
  import { getWebSelectionAriaProps, generateAccessibilityId } from '../utils/accessibility';
9
9
 
@@ -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 = () => {
@@ -93,10 +93,9 @@ const Switch = forwardRef<HTMLDivElement | HTMLButtonElement, SwitchProps>(({
93
93
  if (!iconToRender) return null;
94
94
 
95
95
  if (isIconName(iconToRender)) {
96
- const iconPath = resolveIconPath(iconToRender);
97
96
  return (
98
97
  <IconSvg
99
- path={iconPath}
98
+ name={iconToRender}
100
99
  {...thumbIconProps}
101
100
  aria-label={iconToRender}
102
101
  />
@@ -109,9 +108,9 @@ const Switch = forwardRef<HTMLDivElement | HTMLButtonElement, SwitchProps>(({
109
108
  };
110
109
 
111
110
  // Computed button props with dynamic styles
112
- const computedButtonProps = getWebProps(
113
- switchStyles.switchContainer
114
- );
111
+ const computedButtonProps = getWebProps([
112
+ (switchStyles.switchContainer as any)({})
113
+ ]);
115
114
 
116
115
  // Computed container props with dynamic styles (for when label exists)
117
116
  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
  );