@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,107 +1,86 @@
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 { TextAreaIntentVariant } from './types';
10
- import { applyExtensions } from '../extensions/applyExtension';
11
-
12
-
13
1
  /**
14
- * Create size variants for textarea
2
+ * TextArea styles using defineStyle with dynamic props.
15
3
  */
16
- function createTextareaSizeVariants(theme: Theme) {
17
- return buildSizeVariants(theme, 'textarea', (size) => ({
18
- fontSize: size.fontSize,
19
- padding: size.padding,
20
- lineHeight: size.lineHeight,
21
- minHeight: size.minHeight,
22
- }));
23
- }
4
+ import { StyleSheet } from 'react-native-unistyles';
5
+ import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme, Intent, Size } from '@idealyst/theme';
7
+ import { ViewStyleSize } from '../utils/viewStyleProps';
8
+
9
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
10
+ void StyleSheet;
11
+
12
+ // Wrap theme for $iterator support
13
+ type Theme = ThemeStyleWrapper<BaseTheme>;
14
+
15
+ type ResizeMode = 'none' | 'vertical' | 'horizontal' | 'both';
16
+
17
+ export type TextAreaDynamicProps = {
18
+ size?: Size;
19
+ intent?: Intent;
20
+ disabled?: boolean;
21
+ hasError?: boolean;
22
+ resize?: ResizeMode;
23
+ isNearLimit?: boolean;
24
+ isAtLimit?: boolean;
25
+ margin?: ViewStyleSize;
26
+ marginVertical?: ViewStyleSize;
27
+ marginHorizontal?: ViewStyleSize;
28
+ };
24
29
 
25
30
  /**
26
- * Get textarea styles based on intent, disabled, and hasError state
31
+ * TextArea styles with intent/disabled/error handling.
27
32
  */
28
- function getTextareaIntentStyles(theme: Theme, intent: TextAreaIntentVariant, disabled: boolean, hasError: boolean) {
29
- if (disabled || hasError) {
30
- return {} as const;
31
- }
32
-
33
- const intentValue = theme.intents[intent];
34
- const baseStyles: any = {};
35
-
36
- // For success and warning, set border color
37
- if (intent === 'success' || intent === 'warning') {
38
- baseStyles.borderColor = intentValue.primary;
39
- }
40
-
41
- // Focus styles for all intents when not disabled and not in error
42
- baseStyles._web = {
43
- _focus: {
44
- borderColor: intentValue.primary,
45
- boxShadow: `0 0 0 2px ${intentValue.primary}33`,
33
+ export const textAreaStyles = defineStyle('TextArea', (theme: Theme) => ({
34
+ container: (_props: TextAreaDynamicProps) => ({
35
+ display: 'flex' as const,
36
+ flexDirection: 'column' as const,
37
+ gap: 4,
38
+ borderWidth: 1,
39
+ borderColor: theme.colors.border.primary,
40
+ borderRadius: theme.radii.md,
41
+ variants: {
42
+ margin: {
43
+ margin: theme.sizes.$view.padding,
44
+ },
45
+ marginVertical: {
46
+ marginVertical: theme.sizes.$view.padding,
47
+ },
48
+ marginHorizontal: {
49
+ marginHorizontal: theme.sizes.$view.padding,
50
+ },
46
51
  },
47
- };
52
+ }),
48
53
 
49
- return baseStyles;
50
- }
54
+ label: ({ disabled = false }: TextAreaDynamicProps) => ({
55
+ fontSize: 14,
56
+ fontWeight: '500' as const,
57
+ color: theme.colors.text.primary,
58
+ }),
51
59
 
52
- const createTextareaStyles = (theme: Theme) => {
53
- return ({ intent, disabled, hasError }: { intent: TextAreaIntentVariant, disabled: boolean, hasError: boolean }) => {
54
- const intentStyles = getTextareaIntentStyles(theme, intent, disabled, hasError);
60
+ textareaContainer: (_props: TextAreaDynamicProps) => ({
61
+ position: 'relative' as const,
62
+ variants: {
63
+ disabled: {
64
+ true: {
65
+ opacity: 1,
66
+ },
67
+ false: {
68
+ opacity: 0.8,
69
+ },
70
+ },
71
+ }
72
+ }),
55
73
 
56
- return {
74
+ textarea: ({ disabled = false, resize = 'none' }: TextAreaDynamicProps) => ({
57
75
  width: '100%',
58
76
  color: theme.colors.text.primary,
59
- backgroundColor: theme.colors.surface.primary,
60
- borderWidth: 1,
61
- borderStyle: 'solid',
62
- borderColor: theme.colors.border.primary,
63
- borderRadius: 8,
64
- lineHeight: 'normal',
65
- ...intentStyles,
77
+ opacity: disabled ? 0.5 : 1,
66
78
  variants: {
67
- size: createTextareaSizeVariants(theme),
68
- disabled: {
69
- true: {
70
- opacity: 0.5,
71
- backgroundColor: theme.colors.surface.secondary,
72
- _web: {
73
- cursor: 'not-allowed',
74
- },
75
- },
76
- false: {},
77
- },
78
- hasError: {
79
- true: {
80
- borderColor: theme.intents.error.primary,
81
- },
82
- false: {},
83
- },
84
- resize: {
85
- none: {
86
- _web: {
87
- resize: 'none',
88
- },
89
- },
90
- vertical: {
91
- _web: {
92
- resize: 'vertical',
93
- },
94
- },
95
- horizontal: {
96
- _web: {
97
- resize: 'horizontal',
98
- },
99
- },
100
- both: {
101
- _web: {
102
- resize: 'both',
103
- },
104
- },
79
+ size: {
80
+ fontSize: theme.sizes.$textarea.fontSize,
81
+ padding: theme.sizes.$textarea.padding,
82
+ lineHeight: theme.sizes.$textarea.lineHeight,
83
+ minHeight: theme.sizes.$textarea.minHeight,
105
84
  },
106
85
  },
107
86
  _web: {
@@ -110,109 +89,30 @@ const createTextareaStyles = (theme: Theme) => {
110
89
  transition: 'border-color 0.2s ease, box-shadow 0.2s ease',
111
90
  boxSizing: 'border-box',
112
91
  overflowY: 'hidden',
92
+ cursor: disabled ? 'not-allowed' : 'text',
93
+ resize: resize,
113
94
  },
114
- } as const;
115
- }
116
- }
95
+ }),
117
96
 
118
- // Helper functions to create static styles wrapped in dynamic functions
119
- function createContainerStyles(theme: Theme) {
120
- return () => ({
121
- display: 'flex' as const,
122
- flexDirection: 'column' as const,
123
- gap: 4,
124
- variants: {
125
- // Spacing variants from FormInputStyleProps
126
- margin: buildMarginVariants(theme),
127
- marginVertical: buildMarginVerticalVariants(theme),
128
- marginHorizontal: buildMarginHorizontalVariants(theme),
129
- },
130
- });
131
- }
132
-
133
- function createLabelStyles(theme: Theme) {
134
- return () => ({
135
- fontSize: 14,
136
- fontWeight: '500' as const,
137
- color: theme.colors.text.primary,
138
- variants: {
139
- disabled: {
140
- true: {
141
- opacity: 0.5,
142
- },
143
- false: {},
144
- },
145
- },
146
- });
147
- }
148
-
149
- function createTextareaContainerStyles() {
150
- return () => ({
151
- position: 'relative' as const,
152
- });
153
- }
154
-
155
- function createHelperTextStyles(theme: Theme) {
156
- return () => ({
97
+ helperText: ({ hasError = false }: TextAreaDynamicProps) => ({
157
98
  fontSize: 12,
158
- color: theme.colors.text.secondary,
159
- variants: {
160
- hasError: {
161
- true: {
162
- color: theme.intents.error.primary,
163
- },
164
- false: {},
165
- },
166
- },
167
- });
168
- }
99
+ color: hasError ? theme.intents.error.primary : theme.colors.text.secondary,
100
+ }),
169
101
 
170
- function createFooterStyles() {
171
- return () => ({
102
+ footer: (_props: TextAreaDynamicProps) => ({
172
103
  display: 'flex' as const,
173
104
  flexDirection: 'row' as const,
174
105
  justifyContent: 'space-between' as const,
175
106
  alignItems: 'center' as const,
176
107
  gap: 4,
177
- });
178
- }
108
+ }),
179
109
 
180
- function createCharacterCountStyles(theme: Theme) {
181
- return () => ({
110
+ characterCount: ({ isNearLimit = false, isAtLimit = false }: TextAreaDynamicProps) => ({
182
111
  fontSize: 12,
183
- color: theme.colors.text.secondary,
184
- variants: {
185
- isNearLimit: {
186
- true: {
187
- color: theme.intents.warning.primary,
188
- },
189
- false: {},
190
- },
191
- isAtLimit: {
192
- true: {
193
- color: theme.intents.error.primary,
194
- },
195
- false: {},
196
- },
197
- },
198
- });
199
- }
200
-
201
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
202
- export const textAreaStyles = StyleSheet.create((theme: Theme) => {
203
- // Apply extensions to main visual elements
204
- const extended = applyExtensions('TextArea', theme, {
205
- container: createContainerStyles(theme),
206
- textarea: createTextareaStyles(theme),
207
- });
208
-
209
- return {
210
- ...extended,
211
- // Minor utility styles (not extended)
212
- label: createLabelStyles(theme)(),
213
- textareaContainer: createTextareaContainerStyles()(),
214
- helperText: createHelperTextStyles(theme)(),
215
- footer: createFooterStyles()(),
216
- characterCount: createCharacterCountStyles(theme)(),
217
- };
218
- });
112
+ color: isAtLimit
113
+ ? theme.intents.error.primary
114
+ : isNearLimit
115
+ ? theme.intents.warning.primary
116
+ : theme.colors.text.secondary,
117
+ }),
118
+ }));
@@ -127,12 +127,23 @@ const TextArea = forwardRef<HTMLDivElement, TextAreaProps>(({
127
127
  marginHorizontal,
128
128
  });
129
129
 
130
- const containerProps = getWebProps([textAreaStyles.container, style as any]);
131
- const labelProps = getWebProps([textAreaStyles.label]);
132
- const textareaContainerProps = getWebProps([textAreaStyles.textareaContainer]);
133
- const footerProps = getWebProps([textAreaStyles.footer]);
134
- const helperTextProps = getWebProps([textAreaStyles.helperText]);
135
- const characterCountProps = getWebProps([textAreaStyles.characterCount]);
130
+ // Get dynamic styles - call as functions for theme reactivity
131
+ const containerStyle = (textAreaStyles.container as any)({});
132
+ const labelStyle = (textAreaStyles.label as any)({ disabled });
133
+ const textareaContainerStyle = (textAreaStyles.textareaContainer as any)({});
134
+ const footerStyle = (textAreaStyles.footer as any)({});
135
+ const helperTextStyle = (textAreaStyles.helperText as any)({ hasError });
136
+ const characterCountStyle = (textAreaStyles.characterCount as any)({
137
+ isNearLimit: maxLength ? value.length >= maxLength * 0.9 : false,
138
+ isAtLimit: maxLength ? value.length >= maxLength : false,
139
+ });
140
+
141
+ const containerProps = getWebProps([containerStyle, style as any]);
142
+ const labelProps = getWebProps([labelStyle]);
143
+ const textareaContainerProps = getWebProps([textareaContainerStyle]);
144
+ const footerProps = getWebProps([footerStyle]);
145
+ const helperTextProps = getWebProps([helperTextStyle]);
146
+ const characterCountProps = getWebProps([characterCountStyle]);
136
147
 
137
148
  const adjustHeight = () => {
138
149
  if (!autoGrow || !textareaRef.current) return;
@@ -0,0 +1,82 @@
1
+ import { StyleSheet } from 'react-native-unistyles';
2
+ import { Theme, StylesheetStyles, Intent, Size } from '@idealyst/theme';
3
+ import { buildSizeVariants } from '../utils/buildSizeVariants';
4
+ import { applyExtensions } from '../extensions/applyExtension';
5
+
6
+ type TooltipSize = Size;
7
+ type TooltipIntent = Intent;
8
+
9
+ type TooltipTooltipVariants = {
10
+ size: TooltipSize;
11
+ intent: TooltipIntent;
12
+ }
13
+
14
+ export type ExpandedTooltipTooltipStyles = StylesheetStyles<keyof TooltipTooltipVariants>;
15
+ export type ExpandedTooltipStyles = StylesheetStyles<never>;
16
+
17
+ export type TooltipStylesheet = {
18
+ container: ExpandedTooltipStyles;
19
+ tooltip: ExpandedTooltipTooltipStyles;
20
+ }
21
+
22
+ function createTooltipSizeVariants(theme: Theme) {
23
+ return buildSizeVariants(theme, 'tooltip', (size) => ({
24
+ fontSize: size.fontSize,
25
+ padding: size.padding,
26
+ }));
27
+ }
28
+
29
+ function createTooltipIntentVariants(theme: Theme) {
30
+ const intents: Record<string, any> = {};
31
+
32
+ for (const [intentName, intentValue] of Object.entries(theme.intents)) {
33
+ intents[intentName] = {
34
+ backgroundColor: intentValue.primary,
35
+ color: intentValue.contrast,
36
+ };
37
+ }
38
+
39
+ return intents;
40
+ }
41
+
42
+ // Style creators for extension support
43
+ function createContainerStyles() {
44
+ return () => ({
45
+ position: 'relative' as const,
46
+ _web: {
47
+ display: 'inline-flex',
48
+ width: 'fit-content',
49
+ },
50
+ });
51
+ }
52
+
53
+ function createTooltipStyles(theme: Theme) {
54
+ return () => ({
55
+ borderRadius: 8,
56
+ maxWidth: 300,
57
+ shadowColor: '#000',
58
+ shadowOffset: { width: 0, height: 2 },
59
+ shadowOpacity: 0.15,
60
+ shadowRadius: 8,
61
+ elevation: 4,
62
+ variants: {
63
+ size: createTooltipSizeVariants(theme),
64
+ intent: createTooltipIntentVariants(theme),
65
+ },
66
+ _web: {
67
+ boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
68
+ pointerEvents: 'none',
69
+ width: 'max-content',
70
+ wordWrap: 'break-word',
71
+ },
72
+ });
73
+ }
74
+
75
+ // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
76
+ // transform on native cannot resolve function calls to extract variant structures.
77
+ export const tooltipStyles = StyleSheet.create((theme: Theme) => {
78
+ return applyExtensions('Tooltip', theme, {
79
+ container: createContainerStyles(),
80
+ tooltip: createTooltipStyles(theme),
81
+ });
82
+ });
@@ -1,57 +1,34 @@
1
+ /**
2
+ * Tooltip styles using defineStyle with $iterator expansion.
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 { applyExtensions } from '../extensions/applyExtension';
5
+ import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme, Intent, Size } from '@idealyst/theme';
5
7
 
6
- type TooltipSize = Size;
7
- type TooltipIntent = Intent;
8
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
9
+ void StyleSheet;
8
10
 
9
- type TooltipTooltipVariants = {
10
- size: TooltipSize;
11
- intent: TooltipIntent;
12
- }
11
+ // Wrap theme for $iterator support
12
+ type Theme = ThemeStyleWrapper<BaseTheme>;
13
13
 
14
- export type ExpandedTooltipTooltipStyles = StylesheetStyles<keyof TooltipTooltipVariants>;
15
- export type ExpandedTooltipStyles = StylesheetStyles<never>;
14
+ export type TooltipDynamicProps = {
15
+ size?: Size;
16
+ intent?: Intent;
17
+ };
16
18
 
17
- export type TooltipStylesheet = {
18
- container: ExpandedTooltipStyles;
19
- tooltip: ExpandedTooltipTooltipStyles;
20
- }
21
-
22
- function createTooltipSizeVariants(theme: Theme) {
23
- return buildSizeVariants(theme, 'tooltip', (size) => ({
24
- fontSize: size.fontSize,
25
- padding: size.padding,
26
- }));
27
- }
28
-
29
- function createTooltipIntentVariants(theme: Theme) {
30
- const intents: Record<string, any> = {};
31
-
32
- for (const [intentName, intentValue] of Object.entries(theme.intents)) {
33
- intents[intentName] = {
34
- backgroundColor: intentValue.primary,
35
- color: intentValue.contrast,
36
- };
37
- }
38
-
39
- return intents;
40
- }
41
-
42
- // Style creators for extension support
43
- function createContainerStyles() {
44
- return () => ({
19
+ /**
20
+ * Tooltip styles with size and intent variants.
21
+ */
22
+ export const tooltipStyles = defineStyle('Tooltip', (theme: Theme) => ({
23
+ container: (_props: TooltipDynamicProps) => ({
45
24
  position: 'relative' as const,
46
25
  _web: {
47
26
  display: 'inline-flex',
48
27
  width: 'fit-content',
49
28
  },
50
- });
51
- }
29
+ }),
52
30
 
53
- function createTooltipStyles(theme: Theme) {
54
- return () => ({
31
+ tooltip: (_props: TooltipDynamicProps) => ({
55
32
  borderRadius: 8,
56
33
  maxWidth: 300,
57
34
  shadowColor: '#000',
@@ -60,8 +37,16 @@ function createTooltipStyles(theme: Theme) {
60
37
  shadowRadius: 8,
61
38
  elevation: 4,
62
39
  variants: {
63
- size: createTooltipSizeVariants(theme),
64
- intent: createTooltipIntentVariants(theme),
40
+ // $iterator expands for each tooltip size
41
+ size: {
42
+ fontSize: theme.sizes.$tooltip.fontSize,
43
+ padding: theme.sizes.$tooltip.padding,
44
+ },
45
+ // $iterator expands for each intent
46
+ intent: {
47
+ backgroundColor: theme.$intents.primary,
48
+ color: theme.$intents.contrast,
49
+ },
65
50
  },
66
51
  _web: {
67
52
  boxShadow: '0 2px 8px rgba(0, 0, 0, 0.15)',
@@ -69,14 +54,5 @@ function createTooltipStyles(theme: Theme) {
69
54
  width: 'max-content',
70
55
  wordWrap: 'break-word',
71
56
  },
72
- });
73
- }
74
-
75
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
76
- // transform on native cannot resolve function calls to extract variant structures.
77
- export const tooltipStyles = StyleSheet.create((theme: Theme) => {
78
- return applyExtensions('Tooltip', theme, {
79
- container: createContainerStyles(),
80
- tooltip: createTooltipStyles(theme),
81
- });
82
- });
57
+ }),
58
+ }));
@@ -0,0 +1,51 @@
1
+ import { StyleSheet } from 'react-native-unistyles';
2
+ import { Theme, StylesheetStyles} from '@idealyst/theme';
3
+ import { applyExtensions } from '../extensions/applyExtension';
4
+
5
+ export type ExpandedVideoStyles = StylesheetStyles<never>;
6
+
7
+ export type VideoStylesheet = {
8
+ container: ExpandedVideoStyles;
9
+ video: ExpandedVideoStyles;
10
+ fallback: ExpandedVideoStyles;
11
+ }
12
+
13
+ // Style creators for extension support
14
+ function createContainerStyles(theme: Theme) {
15
+ return () => ({
16
+ position: 'relative' as const,
17
+ overflow: 'hidden' as const,
18
+ backgroundColor: theme.colors['black'],
19
+ });
20
+ }
21
+
22
+ function createVideoStyles() {
23
+ return () => ({
24
+ width: '100%' as const,
25
+ height: '100%' as const,
26
+ });
27
+ }
28
+
29
+ // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
30
+ // transform on native cannot resolve function calls to extract variant structures.
31
+ // @ts-ignore - TS language server needs restart to pick up theme structure changes
32
+ export const videoStyles = StyleSheet.create((theme: Theme) => {
33
+ // Apply extensions to main visual elements
34
+
35
+ return applyExtensions('Video', theme, {container: createContainerStyles(theme),
36
+ video: createVideoStyles(),
37
+ // Additional styles (merged from return)
38
+ // Minor utility styles (not extended)
39
+ fallback: {
40
+ position: 'absolute',
41
+ top: 0,
42
+ left: 0,
43
+ right: 0,
44
+ bottom: 0,
45
+ display: 'flex',
46
+ alignItems: 'center',
47
+ justifyContent: 'center',
48
+ backgroundColor: theme.colors['gray.300'],
49
+ color: theme.colors['gray.600'],
50
+ }});
51
+ });
@@ -1,55 +1,43 @@
1
+ /**
2
+ * Video styles using defineStyle.
3
+ */
1
4
  import { StyleSheet } from 'react-native-unistyles';
2
- import { Theme, StylesheetStyles} from '@idealyst/theme';
3
- import { applyExtensions } from '../extensions/applyExtension';
5
+ import { defineStyle, ThemeStyleWrapper } from '@idealyst/theme';
6
+ import type { Theme as BaseTheme } from '@idealyst/theme';
4
7
 
5
- export type ExpandedVideoStyles = StylesheetStyles<never>;
8
+ // Required: Unistyles must see StyleSheet usage in original source to process this file
9
+ void StyleSheet;
6
10
 
7
- export type VideoStylesheet = {
8
- container: ExpandedVideoStyles;
9
- video: ExpandedVideoStyles;
10
- fallback: ExpandedVideoStyles;
11
- }
11
+ // Wrap theme for $iterator support
12
+ type Theme = ThemeStyleWrapper<BaseTheme>;
12
13
 
13
- // Style creators for extension support
14
- function createContainerStyles(theme: Theme) {
15
- return () => ({
14
+ export type VideoDynamicProps = {};
15
+
16
+ /**
17
+ * Video styles - container, video element, and fallback.
18
+ */
19
+ export const videoStyles = defineStyle('Video', (theme: Theme) => ({
20
+ container: (_props: VideoDynamicProps) => ({
16
21
  position: 'relative' as const,
17
22
  overflow: 'hidden' as const,
18
23
  backgroundColor: theme.colors['black'],
19
- });
20
- }
24
+ }),
21
25
 
22
- function createVideoStyles() {
23
- return () => ({
26
+ video: (_props: VideoDynamicProps) => ({
24
27
  width: '100%' as const,
25
28
  height: '100%' as const,
26
- });
27
- }
28
-
29
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel
30
- // transform on native cannot resolve function calls to extract variant structures.
31
- // @ts-ignore - TS language server needs restart to pick up theme structure changes
32
- export const videoStyles = StyleSheet.create((theme: Theme) => {
33
- // Apply extensions to main visual elements
34
- const extended = applyExtensions('Video', theme, {
35
- container: createContainerStyles(theme),
36
- video: createVideoStyles(),
37
- });
29
+ }),
38
30
 
39
- return {
40
- ...extended,
41
- // Minor utility styles (not extended)
42
- fallback: {
43
- position: 'absolute',
44
- top: 0,
45
- left: 0,
46
- right: 0,
47
- bottom: 0,
48
- display: 'flex',
49
- alignItems: 'center',
50
- justifyContent: 'center',
51
- backgroundColor: theme.colors['gray.300'],
52
- color: theme.colors['gray.600'],
53
- },
54
- };
55
- });
31
+ fallback: (_props: VideoDynamicProps) => ({
32
+ position: 'absolute' as const,
33
+ top: 0,
34
+ left: 0,
35
+ right: 0,
36
+ bottom: 0,
37
+ display: 'flex' as const,
38
+ alignItems: 'center' as const,
39
+ justifyContent: 'center' as const,
40
+ backgroundColor: theme.colors['gray.300'],
41
+ color: theme.colors['gray.600'],
42
+ }),
43
+ }));