@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.
- package/package.json +3 -3
- package/plugin/web.js +280 -532
- package/src/Accordion/Accordion.native.tsx +8 -6
- package/src/Accordion/Accordion.styles.old.tsx +298 -0
- package/src/Accordion/Accordion.styles.tsx +102 -236
- package/src/Accordion/Accordion.web.tsx +1 -3
- package/src/ActivityIndicator/ActivityIndicator.styles.old.tsx +94 -0
- package/src/ActivityIndicator/ActivityIndicator.styles.tsx +44 -74
- package/src/Alert/Alert.native.tsx +16 -6
- package/src/Alert/Alert.styles.old.tsx +209 -0
- package/src/Alert/Alert.styles.tsx +67 -149
- package/src/Alert/Alert.web.tsx +3 -4
- package/src/Avatar/Avatar.styles.old.tsx +99 -0
- package/src/Avatar/Avatar.styles.tsx +35 -80
- package/src/Badge/Badge.styles.old.tsx +157 -0
- package/src/Badge/Badge.styles.tsx +61 -121
- package/src/Badge/Badge.web.tsx +8 -15
- package/src/Breadcrumb/Breadcrumb.styles.old.tsx +231 -0
- package/src/Breadcrumb/Breadcrumb.styles.tsx +83 -200
- package/src/Breadcrumb/Breadcrumb.web.tsx +31 -30
- package/src/Button/Button.native.tsx +14 -21
- package/src/Button/Button.styles.tsx +103 -140
- package/src/Button/Button.web.tsx +9 -19
- package/src/Card/Card.native.tsx +7 -11
- package/src/Card/Card.styles.old.tsx +160 -0
- package/src/Card/Card.styles.tsx +105 -142
- package/src/Card/Card.web.tsx +5 -4
- package/src/Checkbox/Checkbox.native.tsx +9 -5
- package/src/Checkbox/Checkbox.styles.old.tsx +271 -0
- package/src/Checkbox/Checkbox.styles.tsx +104 -216
- package/src/Checkbox/Checkbox.web.tsx +7 -8
- package/src/Chip/Chip.styles.old.tsx +184 -0
- package/src/Chip/Chip.styles.tsx +34 -72
- package/src/Chip/Chip.web.tsx +3 -5
- package/src/Dialog/Dialog.native.tsx +7 -4
- package/src/Dialog/Dialog.styles.old.tsx +202 -0
- package/src/Dialog/Dialog.styles.tsx +69 -133
- package/src/Dialog/Dialog.web.tsx +3 -3
- package/src/Dialog/types.ts +1 -1
- package/src/Divider/Divider.styles.old.tsx +172 -0
- package/src/Divider/Divider.styles.tsx +62 -84
- package/src/Icon/Icon.native.tsx +8 -8
- package/src/Icon/Icon.styles.old.tsx +81 -0
- package/src/Icon/Icon.styles.tsx +52 -66
- package/src/Icon/Icon.web.tsx +62 -21
- package/src/Icon/IconRegistry.native.ts +41 -0
- package/src/Icon/IconRegistry.ts +107 -0
- package/src/Icon/IconSvg/IconSvg.web.tsx +28 -5
- package/src/Icon/icon-resolver.ts +12 -43
- package/src/Icon/index.native.ts +2 -1
- package/src/Icon/index.ts +1 -0
- package/src/Icon/index.web.ts +1 -0
- package/src/Image/Image.styles.old.tsx +69 -0
- package/src/Image/Image.styles.tsx +46 -60
- package/src/Input/Input.native.tsx +138 -53
- package/src/Input/Input.styles.old.tsx +289 -0
- package/src/Input/Input.styles.tsx +134 -232
- package/src/Input/Input.web.tsx +5 -8
- package/src/List/List.native.tsx +5 -2
- package/src/List/List.styles.old.tsx +242 -0
- package/src/List/List.styles.tsx +179 -215
- package/src/List/ListItem.native.tsx +16 -11
- package/src/List/ListItem.web.tsx +26 -16
- package/src/Menu/Menu.styles.old.tsx +197 -0
- package/src/Menu/Menu.styles.tsx +68 -150
- package/src/Menu/MenuItem.native.tsx +5 -3
- package/src/Menu/MenuItem.styles.old.tsx +114 -0
- package/src/Menu/MenuItem.styles.tsx +57 -89
- package/src/Menu/MenuItem.web.tsx +10 -7
- package/src/Popover/Popover.native.tsx +10 -4
- package/src/Popover/Popover.styles.old.tsx +135 -0
- package/src/Popover/Popover.styles.tsx +51 -112
- package/src/Pressable/Pressable.styles.old.tsx +27 -0
- package/src/Pressable/Pressable.styles.tsx +35 -27
- package/src/Progress/Progress.styles.old.tsx +200 -0
- package/src/Progress/Progress.styles.tsx +75 -164
- package/src/RadioButton/RadioButton.native.tsx +4 -3
- package/src/RadioButton/RadioButton.styles.old.tsx +175 -0
- package/src/RadioButton/RadioButton.styles.tsx +83 -154
- package/src/RadioButton/RadioButton.web.tsx +2 -2
- package/src/SVGImage/SVGImage.styles.old.tsx +86 -0
- package/src/SVGImage/SVGImage.styles.tsx +35 -78
- package/src/Screen/Screen.native.tsx +19 -26
- package/src/Screen/Screen.styles.old.tsx +87 -0
- package/src/Screen/Screen.styles.tsx +103 -68
- package/src/Screen/Screen.web.tsx +2 -2
- package/src/Select/Select.native.tsx +42 -33
- package/src/Select/Select.styles.old.tsx +353 -0
- package/src/Select/Select.styles.tsx +214 -300
- package/src/Select/Select.web.tsx +45 -33
- package/src/Skeleton/Skeleton.styles.old.tsx +67 -0
- package/src/Skeleton/Skeleton.styles.tsx +29 -53
- package/src/Slider/Slider.styles.old.tsx +259 -0
- package/src/Slider/Slider.styles.tsx +153 -234
- package/src/Slider/Slider.web.tsx +2 -4
- package/src/Switch/Switch.native.tsx +9 -7
- package/src/Switch/Switch.styles.old.tsx +203 -0
- package/src/Switch/Switch.styles.tsx +101 -174
- package/src/Switch/Switch.web.tsx +7 -8
- package/src/TabBar/TabBar.native.tsx +3 -2
- package/src/TabBar/TabBar.styles.old.tsx +343 -0
- package/src/TabBar/TabBar.styles.tsx +145 -279
- package/src/Table/Table.native.tsx +180 -68
- package/src/Table/Table.styles.old.tsx +311 -0
- package/src/Table/Table.styles.tsx +140 -281
- package/src/Table/Table.web.tsx +169 -70
- package/src/Text/Text.native.tsx +1 -3
- package/src/Text/Text.style.demo.tsx +16 -0
- package/src/Text/Text.styles.old.tsx +219 -0
- package/src/Text/Text.styles.tsx +94 -84
- package/src/Text/Text.web.tsx +3 -2
- package/src/Text/index.ts +1 -0
- package/src/TextArea/TextArea.native.tsx +21 -8
- package/src/TextArea/TextArea.styles.old.tsx +213 -0
- package/src/TextArea/TextArea.styles.tsx +87 -187
- package/src/TextArea/TextArea.web.tsx +17 -6
- package/src/Tooltip/Tooltip.styles.old.tsx +82 -0
- package/src/Tooltip/Tooltip.styles.tsx +32 -56
- package/src/Video/Video.styles.old.tsx +51 -0
- package/src/Video/Video.styles.tsx +32 -44
- package/src/View/View.native.tsx +41 -13
- package/src/View/View.styles.old.tsx +125 -0
- package/src/View/View.styles.tsx +76 -106
- package/src/View/View.web.tsx +5 -21
- package/src/View/types.ts +31 -3
- package/src/examples/ButtonExamples.tsx +20 -0
- package/src/examples/CardExamples.tsx +0 -6
- package/src/extensions/extendComponent.ts +61 -0
- package/src/index.ts +1 -1
package/src/Table/Table.web.tsx
CHANGED
|
@@ -1,9 +1,135 @@
|
|
|
1
|
-
import React, { useMemo } from 'react';
|
|
1
|
+
import React, { useMemo, ReactNode } from 'react';
|
|
2
2
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
3
|
import { tableStyles } from './Table.styles';
|
|
4
|
-
import type { TableProps, TableColumn } from './types';
|
|
4
|
+
import type { TableProps, TableColumn, TableType, TableSizeVariant, TableAlignVariant } from './types';
|
|
5
5
|
import { getWebAriaProps } from '../utils/accessibility';
|
|
6
6
|
|
|
7
|
+
// ============================================================================
|
|
8
|
+
// Sub-component Props
|
|
9
|
+
// ============================================================================
|
|
10
|
+
|
|
11
|
+
interface TRProps {
|
|
12
|
+
children: ReactNode;
|
|
13
|
+
size?: TableSizeVariant;
|
|
14
|
+
type?: TableType;
|
|
15
|
+
clickable?: boolean;
|
|
16
|
+
onClick?: () => void;
|
|
17
|
+
testID?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
interface THProps {
|
|
21
|
+
children: ReactNode;
|
|
22
|
+
size?: TableSizeVariant;
|
|
23
|
+
type?: TableType;
|
|
24
|
+
align?: TableAlignVariant;
|
|
25
|
+
width?: number | string;
|
|
26
|
+
accessibilitySort?: 'ascending' | 'descending' | 'none' | 'other';
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
interface TDProps {
|
|
30
|
+
children: ReactNode;
|
|
31
|
+
size?: TableSizeVariant;
|
|
32
|
+
type?: TableType;
|
|
33
|
+
align?: TableAlignVariant;
|
|
34
|
+
width?: number | string;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
// ============================================================================
|
|
38
|
+
// TR Component
|
|
39
|
+
// ============================================================================
|
|
40
|
+
|
|
41
|
+
function TR({
|
|
42
|
+
children,
|
|
43
|
+
size = 'md',
|
|
44
|
+
type = 'standard',
|
|
45
|
+
clickable = false,
|
|
46
|
+
onClick,
|
|
47
|
+
testID,
|
|
48
|
+
}: TRProps) {
|
|
49
|
+
tableStyles.useVariants({
|
|
50
|
+
size,
|
|
51
|
+
type,
|
|
52
|
+
clickable,
|
|
53
|
+
});
|
|
54
|
+
|
|
55
|
+
const rowProps = getWebProps([(tableStyles.row as any)({})]);
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<tr
|
|
59
|
+
{...rowProps}
|
|
60
|
+
onClick={onClick}
|
|
61
|
+
data-testid={testID}
|
|
62
|
+
>
|
|
63
|
+
{children}
|
|
64
|
+
</tr>
|
|
65
|
+
);
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
// ============================================================================
|
|
69
|
+
// TH Component
|
|
70
|
+
// ============================================================================
|
|
71
|
+
|
|
72
|
+
function TH({
|
|
73
|
+
children,
|
|
74
|
+
size = 'md',
|
|
75
|
+
type = 'standard',
|
|
76
|
+
align = 'left',
|
|
77
|
+
width,
|
|
78
|
+
accessibilitySort,
|
|
79
|
+
}: THProps) {
|
|
80
|
+
tableStyles.useVariants({
|
|
81
|
+
size,
|
|
82
|
+
type,
|
|
83
|
+
align,
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const headerCellProps = getWebProps([(tableStyles.headerCell as any)({})]);
|
|
87
|
+
|
|
88
|
+
return (
|
|
89
|
+
<th
|
|
90
|
+
{...headerCellProps}
|
|
91
|
+
scope="col"
|
|
92
|
+
aria-sort={accessibilitySort}
|
|
93
|
+
style={{ width }}
|
|
94
|
+
>
|
|
95
|
+
{children}
|
|
96
|
+
</th>
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// ============================================================================
|
|
101
|
+
// TD Component
|
|
102
|
+
// ============================================================================
|
|
103
|
+
|
|
104
|
+
function TD({
|
|
105
|
+
children,
|
|
106
|
+
size = 'md',
|
|
107
|
+
type = 'standard',
|
|
108
|
+
align = 'left',
|
|
109
|
+
width,
|
|
110
|
+
}: TDProps) {
|
|
111
|
+
tableStyles.useVariants({
|
|
112
|
+
size,
|
|
113
|
+
type,
|
|
114
|
+
align,
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const cellProps = getWebProps([(tableStyles.cell as any)({})]);
|
|
118
|
+
|
|
119
|
+
return (
|
|
120
|
+
<td
|
|
121
|
+
{...cellProps}
|
|
122
|
+
style={{ width }}
|
|
123
|
+
>
|
|
124
|
+
{children}
|
|
125
|
+
</td>
|
|
126
|
+
);
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// ============================================================================
|
|
130
|
+
// Main Table Component
|
|
131
|
+
// ============================================================================
|
|
132
|
+
|
|
7
133
|
function Table<T = any>({
|
|
8
134
|
columns,
|
|
9
135
|
data,
|
|
@@ -37,7 +163,8 @@ function Table<T = any>({
|
|
|
37
163
|
accessibilityHidden,
|
|
38
164
|
});
|
|
39
165
|
}, [accessibilityLabel, accessibilityHint, accessibilityRole, accessibilityHidden]);
|
|
40
|
-
|
|
166
|
+
|
|
167
|
+
// Apply variants for container
|
|
41
168
|
tableStyles.useVariants({
|
|
42
169
|
type,
|
|
43
170
|
size,
|
|
@@ -51,7 +178,7 @@ function Table<T = any>({
|
|
|
51
178
|
});
|
|
52
179
|
|
|
53
180
|
const containerProps = getWebProps([(tableStyles.container as any)({}), style as any]);
|
|
54
|
-
const tableProps = getWebProps([tableStyles.table]);
|
|
181
|
+
const tableProps = getWebProps([(tableStyles.table as any)({})]);
|
|
55
182
|
|
|
56
183
|
// Helper to get cell value
|
|
57
184
|
const getCellValue = (column: TableColumn<T>, row: T, rowIndex: number) => {
|
|
@@ -67,79 +194,51 @@ function Table<T = any>({
|
|
|
67
194
|
return (
|
|
68
195
|
<div {...containerProps} {...ariaProps} id={id} data-testid={testID}>
|
|
69
196
|
<table {...tableProps} role="table">
|
|
70
|
-
<thead {...getWebProps([tableStyles.thead])}>
|
|
197
|
+
<thead {...getWebProps([(tableStyles.thead as any)({})])}>
|
|
71
198
|
<tr>
|
|
72
|
-
{columns.map((column) =>
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
type
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
{...headerCellProps}
|
|
85
|
-
scope="col"
|
|
86
|
-
aria-sort={column.accessibilitySort}
|
|
87
|
-
style={{
|
|
88
|
-
width: column.width,
|
|
89
|
-
}}
|
|
90
|
-
>
|
|
91
|
-
{column.title}
|
|
92
|
-
</th>
|
|
93
|
-
);
|
|
94
|
-
})}
|
|
199
|
+
{columns.map((column) => (
|
|
200
|
+
<TH
|
|
201
|
+
key={column.key}
|
|
202
|
+
size={size}
|
|
203
|
+
type={type}
|
|
204
|
+
align={column.align}
|
|
205
|
+
width={column.width}
|
|
206
|
+
accessibilitySort={column.accessibilitySort}
|
|
207
|
+
>
|
|
208
|
+
{column.title}
|
|
209
|
+
</TH>
|
|
210
|
+
))}
|
|
95
211
|
</tr>
|
|
96
212
|
</thead>
|
|
97
|
-
<tbody {...getWebProps([tableStyles.tbody])}>
|
|
98
|
-
{data.map((row, rowIndex) =>
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
type
|
|
103
|
-
clickable
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
});
|
|
121
|
-
|
|
122
|
-
const cellProps = getWebProps([tableStyles.cell]);
|
|
123
|
-
|
|
124
|
-
return (
|
|
125
|
-
<td
|
|
126
|
-
key={column.key}
|
|
127
|
-
{...cellProps}
|
|
128
|
-
style={{
|
|
129
|
-
width: column.width,
|
|
130
|
-
}}
|
|
131
|
-
>
|
|
132
|
-
{getCellValue(column, row, rowIndex)}
|
|
133
|
-
</td>
|
|
134
|
-
);
|
|
135
|
-
})}
|
|
136
|
-
</tr>
|
|
137
|
-
);
|
|
138
|
-
})}
|
|
213
|
+
<tbody {...getWebProps([(tableStyles.tbody as any)({})])}>
|
|
214
|
+
{data.map((row, rowIndex) => (
|
|
215
|
+
<TR
|
|
216
|
+
key={rowIndex}
|
|
217
|
+
size={size}
|
|
218
|
+
type={type}
|
|
219
|
+
clickable={isClickable}
|
|
220
|
+
onClick={() => onRowPress?.(row, rowIndex)}
|
|
221
|
+
testID={testID ? `${testID}-row-${rowIndex}` : undefined}
|
|
222
|
+
>
|
|
223
|
+
{columns.map((column) => (
|
|
224
|
+
<TD
|
|
225
|
+
key={column.key}
|
|
226
|
+
size={size}
|
|
227
|
+
type={type}
|
|
228
|
+
align={column.align}
|
|
229
|
+
width={column.width}
|
|
230
|
+
>
|
|
231
|
+
{getCellValue(column, row, rowIndex)}
|
|
232
|
+
</TD>
|
|
233
|
+
))}
|
|
234
|
+
</TR>
|
|
235
|
+
))}
|
|
139
236
|
</tbody>
|
|
140
237
|
</table>
|
|
141
238
|
</div>
|
|
142
239
|
);
|
|
143
240
|
}
|
|
144
241
|
|
|
242
|
+
|
|
243
|
+
|
|
145
244
|
export default Table;
|
package/src/Text/Text.native.tsx
CHANGED
|
@@ -28,13 +28,11 @@ const Text = forwardRef<RNText, TextProps>(({
|
|
|
28
28
|
paddingHorizontal,
|
|
29
29
|
});
|
|
30
30
|
|
|
31
|
-
const textStyle = (textStyles.text as any)({ color });
|
|
32
|
-
|
|
33
31
|
return (
|
|
34
32
|
<RNText
|
|
35
33
|
ref={ref}
|
|
36
34
|
nativeID={id}
|
|
37
|
-
style={[
|
|
35
|
+
style={[textStyles.text({ color, typography, weight, align }), style]}
|
|
38
36
|
testID={testID}
|
|
39
37
|
>
|
|
40
38
|
{children}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ThemeStyleWrapper } from '@idealyst/theme';
|
|
2
|
+
import type { Theme as BaseTheme } from '@idealyst/theme';
|
|
3
|
+
|
|
4
|
+
type Theme = ThemeStyleWrapper<BaseTheme>;
|
|
5
|
+
|
|
6
|
+
const defineStyle = {} as any
|
|
7
|
+
defineStyle('Text', (theme: Theme) => ({
|
|
8
|
+
text: {
|
|
9
|
+
margin: 0,
|
|
10
|
+
padding: 0,
|
|
11
|
+
color: theme.colors.text.primary,
|
|
12
|
+
variants: {
|
|
13
|
+
// Typography variants
|
|
14
|
+
|
|
15
|
+
}}
|
|
16
|
+
}))
|
|
@@ -0,0 +1,219 @@
|
|
|
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
|
+
}));
|