@idealyst/components 1.2.13 → 1.2.14

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 (47) hide show
  1. package/package.json +3 -3
  2. package/src/ActivityIndicator/ActivityIndicator.native.tsx +3 -3
  3. package/src/ActivityIndicator/ActivityIndicator.web.tsx +3 -3
  4. package/src/Avatar/Avatar.native.tsx +1 -1
  5. package/src/Breadcrumb/Breadcrumb.native.tsx +20 -21
  6. package/src/Dialog/Dialog.native.tsx +2 -2
  7. package/src/Icon/types.ts +3 -0
  8. package/src/Skeleton/Skeleton.native.tsx +3 -3
  9. package/src/Skeleton/Skeleton.web.tsx +3 -3
  10. package/src/Slider/Slider.native.tsx +2 -2
  11. package/src/TabBar/TabBar.native.tsx +2 -2
  12. package/src/index.native.ts +1 -1
  13. package/src/index.ts +1 -1
  14. package/src/Accordion/Accordion.styles.old.tsx +0 -298
  15. package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +0 -94
  16. package/src/Alert/Alert.styles.old.tsx +0 -209
  17. package/src/Avatar/Avatar.styles.old.tsx +0 -99
  18. package/src/Badge/Badge.styles.old.tsx +0 -157
  19. package/src/Breadcrumb/Breadcrumb.styles.old.tsx +0 -231
  20. package/src/Card/Card.styles.old.tsx +0 -160
  21. package/src/Checkbox/Checkbox.styles.old.tsx +0 -271
  22. package/src/Chip/Chip.styles.old.tsx +0 -184
  23. package/src/Dialog/Dialog.styles.old.tsx +0 -202
  24. package/src/Divider/Divider.styles.old.tsx +0 -172
  25. package/src/Icon/Icon.styles.old.tsx +0 -81
  26. package/src/Image/Image.styles.old.tsx +0 -69
  27. package/src/Input/Input.styles.old.tsx +0 -289
  28. package/src/List/List.styles.old.tsx +0 -242
  29. package/src/Menu/Menu.styles.old.tsx +0 -197
  30. package/src/Menu/MenuItem.styles.old.tsx +0 -114
  31. package/src/Popover/Popover.styles.old.tsx +0 -135
  32. package/src/Pressable/Pressable.styles.old.tsx +0 -27
  33. package/src/Progress/Progress.styles.old.tsx +0 -200
  34. package/src/RadioButton/RadioButton.styles.old.tsx +0 -175
  35. package/src/SVGImage/SVGImage.styles.old.tsx +0 -86
  36. package/src/Screen/Screen.styles.old.tsx +0 -87
  37. package/src/Select/Select.styles.old.tsx +0 -353
  38. package/src/Skeleton/Skeleton.styles.old.tsx +0 -67
  39. package/src/Slider/Slider.styles.old.tsx +0 -259
  40. package/src/Switch/Switch.styles.old.tsx +0 -203
  41. package/src/TabBar/TabBar.styles.old.tsx +0 -343
  42. package/src/Table/Table.styles.old.tsx +0 -311
  43. package/src/Text/Text.styles.old.tsx +0 -219
  44. package/src/TextArea/TextArea.styles.old.tsx +0 -213
  45. package/src/Tooltip/Tooltip.styles.old.tsx +0 -82
  46. package/src/Video/Video.styles.old.tsx +0 -51
  47. package/src/View/View.styles.old.tsx +0 -125
@@ -1,219 +0,0 @@
1
- import { StyleSheet } from "react-native-unistyles";
2
- import { Theme, Typography } from '@idealyst/theme';
3
- import { TextAlignVariant, TextColorVariant, TextWeightVariant, TextTypographyVariant } from "./types";
4
- import { applyExtensions } from '../extensions/applyExtension';
5
-
6
- export type TextVariants = {
7
- typography: TextTypographyVariant;
8
- weight: TextWeightVariant;
9
- align: TextAlignVariant;
10
- }
11
-
12
- type TextStyleParams = {
13
- color?: TextColorVariant;
14
- }
15
-
16
- /**
17
- * Create typography variants from theme
18
- */
19
- function createTypographyVariants(theme: Theme) {
20
- const variants: Record<string, object> = {};
21
- for (const key in theme.sizes.typography) {
22
- const typo = theme.sizes.typography[key as Typography];
23
- variants[key] = {
24
- fontSize: typo.fontSize,
25
- lineHeight: typo.lineHeight,
26
- fontWeight: typo.fontWeight,
27
- };
28
- }
29
- return variants;
30
- }
31
-
32
- /**
33
- * Create spacing variants from theme
34
- */
35
- function createSpacingVariants(theme: Theme) {
36
- return {
37
- gap: {
38
- xs: { gap: theme.sizes.view.xs.spacing },
39
- sm: { gap: theme.sizes.view.sm.spacing },
40
- md: { gap: theme.sizes.view.md.spacing },
41
- lg: { gap: theme.sizes.view.lg.spacing },
42
- xl: { gap: theme.sizes.view.xl.spacing },
43
- },
44
- padding: {
45
- xs: { padding: theme.sizes.view.xs.padding },
46
- sm: { padding: theme.sizes.view.sm.padding },
47
- md: { padding: theme.sizes.view.md.padding },
48
- lg: { padding: theme.sizes.view.lg.padding },
49
- xl: { padding: theme.sizes.view.xl.padding },
50
- },
51
- paddingVertical: {
52
- xs: { paddingVertical: theme.sizes.view.xs.padding },
53
- sm: { paddingVertical: theme.sizes.view.sm.padding },
54
- md: { paddingVertical: theme.sizes.view.md.padding },
55
- lg: { paddingVertical: theme.sizes.view.lg.padding },
56
- xl: { paddingVertical: theme.sizes.view.xl.padding },
57
- },
58
- paddingHorizontal: {
59
- xs: { paddingHorizontal: theme.sizes.view.xs.padding },
60
- sm: { paddingHorizontal: theme.sizes.view.sm.padding },
61
- md: { paddingHorizontal: theme.sizes.view.md.padding },
62
- lg: { paddingHorizontal: theme.sizes.view.lg.padding },
63
- xl: { paddingHorizontal: theme.sizes.view.xl.padding },
64
- },
65
- };
66
- }
67
-
68
- /**
69
- * Create text styles
70
- */
71
- function createTextStyles(theme: Theme) {
72
- const spacingVariants = createSpacingVariants(theme);
73
-
74
- return ({ color }: TextStyleParams) => ({
75
- margin: 0,
76
- padding: 0,
77
- color: theme.colors.text[color ?? 'primary'] || theme.colors.text.primary,
78
- variants: {
79
- typography: createTypographyVariants(theme),
80
- weight: {
81
- light: { fontWeight: '300' },
82
- normal: { fontWeight: '400' },
83
- medium: { fontWeight: '500' },
84
- semibold: { fontWeight: '600' },
85
- bold: { fontWeight: '700' },
86
- } as const,
87
- align: {
88
- left: { textAlign: 'left' },
89
- center: { textAlign: 'center' },
90
- right: { textAlign: 'right' },
91
- } as const,
92
- ...spacingVariants,
93
- } as const,
94
- _web: {
95
- fontFamily: 'inherit',
96
- },
97
- });
98
- }
99
-
100
- // Babel plugin transforms applyExtensions to inline theme.__extensions access
101
- export const textStyles = StyleSheet.create((theme: Theme) => {
102
- return applyExtensions('Text', theme, {
103
- text: createTextStyles(theme),
104
- });
105
- });
106
-
107
- // =============================================================================
108
- // TEST: buildStyles approach
109
- // =============================================================================
110
-
111
- // This is what DEVELOPERS would write (nice API with helpers):
112
- // export const textStylesDef = buildStyles('Text', (theme) => ({
113
- // text: createTextStyles(theme),
114
- // }));
115
-
116
- // This is what BABEL would generate (flat ObjectExpression, direct theme access):
117
- // The key is ALL theme accesses are directly visible - no function calls hiding them
118
- export const testTextStyles = StyleSheet.create((theme: Theme) => ({
119
- text: ({ color }: TextStyleParams) => ({
120
- margin: 0,
121
- padding: 0,
122
- // Direct theme access - Unistyles can trace this
123
- color: theme.colors.text[color ?? 'primary'] || theme.colors.text.primary,
124
- variants: {
125
- // Typography variants - all expanded inline
126
- typography: {
127
- h1: {
128
- fontSize: theme.sizes.typography.h1.fontSize,
129
- lineHeight: theme.sizes.typography.h1.lineHeight,
130
- fontWeight: theme.sizes.typography.h1.fontWeight,
131
- },
132
- h2: {
133
- fontSize: theme.sizes.typography.h2.fontSize,
134
- lineHeight: theme.sizes.typography.h2.lineHeight,
135
- fontWeight: theme.sizes.typography.h2.fontWeight,
136
- },
137
- h3: {
138
- fontSize: theme.sizes.typography.h3.fontSize,
139
- lineHeight: theme.sizes.typography.h3.lineHeight,
140
- fontWeight: theme.sizes.typography.h3.fontWeight,
141
- },
142
- h4: {
143
- fontSize: theme.sizes.typography.h4.fontSize,
144
- lineHeight: theme.sizes.typography.h4.lineHeight,
145
- fontWeight: theme.sizes.typography.h4.fontWeight,
146
- },
147
- h5: {
148
- fontSize: theme.sizes.typography.h5.fontSize,
149
- lineHeight: theme.sizes.typography.h5.lineHeight,
150
- fontWeight: theme.sizes.typography.h5.fontWeight,
151
- },
152
- h6: {
153
- fontSize: theme.sizes.typography.h6.fontSize,
154
- lineHeight: theme.sizes.typography.h6.lineHeight,
155
- fontWeight: theme.sizes.typography.h6.fontWeight,
156
- },
157
- body1: {
158
- fontSize: theme.sizes.typography.body1.fontSize,
159
- lineHeight: theme.sizes.typography.body1.lineHeight,
160
- fontWeight: theme.sizes.typography.body1.fontWeight,
161
- },
162
- body2: {
163
- fontSize: theme.sizes.typography.body2.fontSize,
164
- lineHeight: theme.sizes.typography.body2.lineHeight,
165
- fontWeight: theme.sizes.typography.body2.fontWeight,
166
- },
167
- caption: {
168
- fontSize: theme.sizes.typography.caption.fontSize,
169
- lineHeight: theme.sizes.typography.caption.lineHeight,
170
- fontWeight: theme.sizes.typography.caption.fontWeight,
171
- },
172
- },
173
- weight: {
174
- light: { fontWeight: '300' },
175
- normal: { fontWeight: '400' },
176
- medium: { fontWeight: '500' },
177
- semibold: { fontWeight: '600' },
178
- bold: { fontWeight: '700' },
179
- } as const,
180
- align: {
181
- left: { textAlign: 'left' },
182
- center: { textAlign: 'center' },
183
- right: { textAlign: 'right' },
184
- } as const,
185
- // Spacing variants - all expanded inline
186
- gap: {
187
- xs: { gap: theme.sizes.view.xs.spacing },
188
- sm: { gap: theme.sizes.view.sm.spacing },
189
- md: { gap: theme.sizes.view.md.spacing },
190
- lg: { gap: theme.sizes.view.lg.spacing },
191
- xl: { gap: theme.sizes.view.xl.spacing },
192
- },
193
- padding: {
194
- xs: { padding: theme.sizes.view.xs.padding },
195
- sm: { padding: theme.sizes.view.sm.padding },
196
- md: { padding: theme.sizes.view.md.padding },
197
- lg: { padding: theme.sizes.view.lg.padding },
198
- xl: { padding: theme.sizes.view.xl.padding },
199
- },
200
- paddingVertical: {
201
- xs: { paddingVertical: theme.sizes.view.xs.padding },
202
- sm: { paddingVertical: theme.sizes.view.sm.padding },
203
- md: { paddingVertical: theme.sizes.view.md.padding },
204
- lg: { paddingVertical: theme.sizes.view.lg.padding },
205
- xl: { paddingVertical: theme.sizes.view.xl.padding },
206
- },
207
- paddingHorizontal: {
208
- xs: { paddingHorizontal: theme.sizes.view.xs.padding },
209
- sm: { paddingHorizontal: theme.sizes.view.sm.padding },
210
- md: { paddingHorizontal: theme.sizes.view.md.padding },
211
- lg: { paddingHorizontal: theme.sizes.view.lg.padding },
212
- xl: { paddingHorizontal: theme.sizes.view.xl.padding },
213
- },
214
- } as const,
215
- _web: {
216
- fontFamily: 'inherit',
217
- },
218
- }),
219
- }));
@@ -1,213 +0,0 @@
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
- * Create size variants for textarea
14
- */
15
- function createTextareaSizeVariants(theme: Theme) {
16
- return buildSizeVariants(theme, 'textarea', (size) => ({
17
- fontSize: size.fontSize,
18
- padding: size.padding,
19
- lineHeight: size.lineHeight,
20
- minHeight: size.minHeight,
21
- }));
22
- }
23
-
24
- /**
25
- * Get textarea styles based on intent, disabled, and hasError state
26
- */
27
- function getTextareaIntentStyles(theme: Theme, intent: TextAreaIntentVariant, disabled: boolean, hasError: boolean) {
28
- if (disabled || hasError) {
29
- return {} as const;
30
- }
31
-
32
- const intentValue = theme.intents[intent];
33
- const baseStyles: any = {};
34
-
35
- // For success and warning, set border color
36
- if (intent === 'success' || intent === 'warning') {
37
- baseStyles.borderColor = intentValue.primary;
38
- }
39
-
40
- // Focus styles for all intents when not disabled and not in error
41
- baseStyles._web = {
42
- _focus: {
43
- borderColor: intentValue.primary,
44
- boxShadow: `0 0 0 2px ${intentValue.primary}33`,
45
- },
46
- };
47
-
48
- return baseStyles;
49
- }
50
-
51
- const createTextareaStyles = (theme: Theme) => {
52
- return ({ intent, disabled, hasError }: { intent: TextAreaIntentVariant, disabled: boolean, hasError: boolean }) => {
53
- const intentStyles = getTextareaIntentStyles(theme, intent, disabled, hasError);
54
-
55
- return {
56
- width: '100%',
57
- color: theme.colors.text.primary,
58
- backgroundColor: theme.colors.surface.primary,
59
- borderWidth: 1,
60
- borderStyle: 'solid',
61
- borderColor: theme.colors.border.primary,
62
- borderRadius: 8,
63
- lineHeight: 'normal',
64
- ...intentStyles,
65
- variants: {
66
- size: createTextareaSizeVariants(theme),
67
- disabled: {
68
- true: {
69
- opacity: 0.5,
70
- backgroundColor: theme.colors.surface.secondary,
71
- _web: {
72
- cursor: 'not-allowed',
73
- },
74
- },
75
- false: {},
76
- },
77
- hasError: {
78
- true: {
79
- borderColor: theme.intents.error.primary,
80
- },
81
- false: {},
82
- },
83
- resize: {
84
- none: {
85
- _web: {
86
- resize: 'none',
87
- },
88
- },
89
- vertical: {
90
- _web: {
91
- resize: 'vertical',
92
- },
93
- },
94
- horizontal: {
95
- _web: {
96
- resize: 'horizontal',
97
- },
98
- },
99
- both: {
100
- _web: {
101
- resize: 'both',
102
- },
103
- },
104
- },
105
- },
106
- _web: {
107
- fontFamily: 'inherit',
108
- outline: 'none',
109
- transition: 'border-color 0.2s ease, box-shadow 0.2s ease',
110
- boxSizing: 'border-box',
111
- overflowY: 'hidden',
112
- },
113
- } as const;
114
- }
115
- }
116
-
117
- // Helper functions to create static styles wrapped in dynamic functions
118
- function createContainerStyles(theme: Theme) {
119
- return () => ({
120
- display: 'flex' as const,
121
- flexDirection: 'column' as const,
122
- gap: 4,
123
- variants: {
124
- // Spacing variants from FormInputStyleProps
125
- margin: buildMarginVariants(theme),
126
- marginVertical: buildMarginVerticalVariants(theme),
127
- marginHorizontal: buildMarginHorizontalVariants(theme),
128
- },
129
- });
130
- }
131
-
132
- function createLabelStyles(theme: Theme) {
133
- return () => ({
134
- fontSize: 14,
135
- fontWeight: '500' as const,
136
- color: theme.colors.text.primary,
137
- variants: {
138
- disabled: {
139
- true: {
140
- opacity: 0.5,
141
- },
142
- false: {},
143
- },
144
- },
145
- });
146
- }
147
-
148
- function createTextareaContainerStyles() {
149
- return () => ({
150
- position: 'relative' as const,
151
- });
152
- }
153
-
154
- function createHelperTextStyles(theme: Theme) {
155
- return () => ({
156
- fontSize: 12,
157
- color: theme.colors.text.secondary,
158
- variants: {
159
- hasError: {
160
- true: {
161
- color: theme.intents.error.primary,
162
- },
163
- false: {},
164
- },
165
- },
166
- });
167
- }
168
-
169
- function createFooterStyles() {
170
- return () => ({
171
- display: 'flex' as const,
172
- flexDirection: 'row' as const,
173
- justifyContent: 'space-between' as const,
174
- alignItems: 'center' as const,
175
- gap: 4,
176
- });
177
- }
178
-
179
- function createCharacterCountStyles(theme: Theme) {
180
- return () => ({
181
- fontSize: 12,
182
- color: theme.colors.text.secondary,
183
- variants: {
184
- isNearLimit: {
185
- true: {
186
- color: theme.intents.warning.primary,
187
- },
188
- false: {},
189
- },
190
- isAtLimit: {
191
- true: {
192
- color: theme.intents.error.primary,
193
- },
194
- false: {},
195
- },
196
- },
197
- });
198
- }
199
-
200
- // Styles are inlined here instead of in @idealyst/theme because Unistyles' Babel transform on native cannot resolve function calls to extract variant structures.
201
- export const textAreaStyles = StyleSheet.create((theme: Theme) => {
202
- // Apply extensions to main visual elements
203
-
204
- return applyExtensions('TextArea', theme, {container: createContainerStyles(theme),
205
- textarea: createTextareaStyles(theme),
206
- // Additional styles (merged from return)
207
- // Minor utility styles (not extended)
208
- label: createLabelStyles(theme)(),
209
- textareaContainer: createTextareaContainerStyles()(),
210
- helperText: createHelperTextStyles(theme)(),
211
- footer: createFooterStyles()(),
212
- characterCount: createCharacterCountStyles(theme)()});
213
- });
@@ -1,82 +0,0 @@
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,51 +0,0 @@
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,125 +0,0 @@
1
- import { StyleSheet } from 'react-native-unistyles';
2
- import { Theme, StylesheetStyles, Surface } 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 { ViewBackgroundVariant, ViewBorderVariant, ViewRadiusVariant } from './types';
13
- import { ViewStyleSize } from '../utils/viewStyleProps';
14
- import { applyExtensions } from '../extensions/applyExtension';
15
-
16
- type ViewVariants = {
17
- background: ViewBackgroundVariant;
18
- radius: ViewRadiusVariant;
19
- border: ViewBorderVariant;
20
- gap: ViewStyleSize;
21
- padding: ViewStyleSize;
22
- paddingVertical: ViewStyleSize;
23
- paddingHorizontal: ViewStyleSize;
24
- margin: ViewStyleSize;
25
- marginVertical: ViewStyleSize;
26
- marginHorizontal: ViewStyleSize;
27
- };
28
-
29
- export type ExpandedViewStyles = StylesheetStyles<keyof ViewVariants>;
30
-
31
- export type ViewStylesheet = {
32
- view: ExpandedViewStyles;
33
- };
34
-
35
- /**
36
- * Create background variants for view
37
- */
38
- function createBackgroundVariants(theme: Theme) {
39
- const variants: any = {
40
- transparent: {
41
- backgroundColor: 'transparent',
42
- },
43
- };
44
-
45
- // Add all surface colors programmatically
46
- for (const surface in theme.colors.surface) {
47
- variants[surface] = {
48
- backgroundColor: theme.colors.surface[surface as Surface],
49
- };
50
- }
51
-
52
- return variants;
53
- }
54
-
55
- /**
56
- * Create radius variants for view
57
- */
58
- function createRadiusVariants() {
59
- return {
60
- none: { borderRadius: 0 },
61
- xs: { borderRadius: 2 },
62
- sm: { borderRadius: 4 },
63
- md: { borderRadius: 8 },
64
- lg: { borderRadius: 12 },
65
- xl: { borderRadius: 16 },
66
- } as const;
67
- }
68
-
69
- /**
70
- * Create border variants for view
71
- */
72
- function createBorderVariants(theme: Theme) {
73
- return {
74
- none: {
75
- borderWidth: 0,
76
- },
77
- thin: {
78
- borderWidth: 1,
79
- borderStyle: 'solid',
80
- borderColor: theme.colors['gray.300'],
81
- },
82
- thick: {
83
- borderWidth: 2,
84
- borderStyle: 'solid',
85
- borderColor: theme.colors['gray.300'],
86
- },
87
- } as const;
88
- }
89
-
90
- /**
91
- * Create dynamic view styles.
92
- * Returns a function to ensure Unistyles can track theme changes.
93
- * All styles must be dynamic functions (not static objects) to work with
94
- * Unistyles' Babel transform and theme reactivity on native.
95
- */
96
- function createViewStyles(theme: Theme) {
97
- return (_props?: {}) => ({
98
- display: 'flex' as const,
99
- variants: {
100
- background: createBackgroundVariants(theme),
101
- radius: createRadiusVariants(),
102
- border: createBorderVariants(theme),
103
- gap: buildGapVariants(theme),
104
- padding: buildPaddingVariants(theme),
105
- paddingVertical: buildPaddingVerticalVariants(theme),
106
- paddingHorizontal: buildPaddingHorizontalVariants(theme),
107
- margin: buildMarginVariants(theme),
108
- marginVertical: buildMarginVerticalVariants(theme),
109
- marginHorizontal: buildMarginHorizontalVariants(theme),
110
- },
111
- _web: {
112
- display: 'flex',
113
- flexDirection: 'column',
114
- boxSizing: 'border-box',
115
- },
116
- });
117
- }
118
-
119
- // Styles use applyExtensions to enable theme extensions and ensure proper
120
- // reactivity with Unistyles' native Shadow Tree updates.
121
- export const viewStyles = StyleSheet.create((theme: Theme) => {
122
- return applyExtensions('View', theme, {
123
- view: createViewStyles(theme),
124
- });
125
- });