@idealyst/components 1.2.19 → 1.2.20
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/src/Text/Text.web.tsx +2 -28
- package/src/Text/types.ts +0 -7
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.20",
|
|
4
4
|
"description": "Shared component library for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/IdealystIO/idealyst-framework/tree/main/packages/components#readme",
|
|
6
6
|
"readme": "README.md",
|
|
@@ -56,7 +56,7 @@
|
|
|
56
56
|
"publish:npm": "npm publish"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
|
-
"@idealyst/theme": "^1.2.
|
|
59
|
+
"@idealyst/theme": "^1.2.20",
|
|
60
60
|
"@mdi/js": ">=7.0.0",
|
|
61
61
|
"@mdi/react": ">=1.0.0",
|
|
62
62
|
"@react-native-vector-icons/common": ">=12.0.0",
|
|
@@ -106,7 +106,7 @@
|
|
|
106
106
|
}
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
|
-
"@idealyst/theme": "^1.2.
|
|
109
|
+
"@idealyst/theme": "^1.2.20",
|
|
110
110
|
"@idealyst/tooling": "^1.2.4",
|
|
111
111
|
"@mdi/react": "^1.6.1",
|
|
112
112
|
"@types/react": "^19.1.0",
|
package/src/Text/Text.web.tsx
CHANGED
|
@@ -1,40 +1,16 @@
|
|
|
1
1
|
import React, { forwardRef } from 'react';
|
|
2
2
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
|
-
import
|
|
4
|
-
import { TextProps, TextSizeVariant } from './types';
|
|
3
|
+
import { TextProps } from './types';
|
|
5
4
|
import { textStyles } from './Text.styles';
|
|
6
5
|
import useMergeRefs from '../hooks/useMergeRefs';
|
|
7
6
|
|
|
8
|
-
// Map Size values to Typography values
|
|
9
|
-
const SIZE_TO_TYPOGRAPHY: Record<Size, Typography> = {
|
|
10
|
-
'xs': 'caption',
|
|
11
|
-
'sm': 'body2',
|
|
12
|
-
'md': 'body1',
|
|
13
|
-
'lg': 'subtitle1',
|
|
14
|
-
'xl': 'h5',
|
|
15
|
-
'2xl': 'h4',
|
|
16
|
-
'3xl': 'h3',
|
|
17
|
-
};
|
|
18
|
-
|
|
19
|
-
// Convert TextSizeVariant to Typography (handles both Size and Typography values)
|
|
20
|
-
function resolveTypography(value: TextSizeVariant | undefined): Typography {
|
|
21
|
-
if (!value) return 'body1';
|
|
22
|
-
// If it's a Size value, map it to Typography
|
|
23
|
-
if (value in SIZE_TO_TYPOGRAPHY) {
|
|
24
|
-
return SIZE_TO_TYPOGRAPHY[value as Size];
|
|
25
|
-
}
|
|
26
|
-
// Otherwise it's already a Typography value
|
|
27
|
-
return value as Typography;
|
|
28
|
-
}
|
|
29
|
-
|
|
30
7
|
/**
|
|
31
8
|
* Typography component for displaying text with predefined styles and semantic variants.
|
|
32
9
|
* Supports multiple typography scales, colors, weights, and alignments.
|
|
33
10
|
*/
|
|
34
11
|
const Text = forwardRef<HTMLSpanElement, TextProps>(({
|
|
35
12
|
children,
|
|
36
|
-
typography
|
|
37
|
-
size,
|
|
13
|
+
typography,
|
|
38
14
|
weight,
|
|
39
15
|
color = 'primary',
|
|
40
16
|
align = 'left',
|
|
@@ -47,8 +23,6 @@ const Text = forwardRef<HTMLSpanElement, TextProps>(({
|
|
|
47
23
|
testID,
|
|
48
24
|
id,
|
|
49
25
|
}, ref) => {
|
|
50
|
-
// size is an alias for typography - size takes precedence if both are set
|
|
51
|
-
const typography = resolveTypography(size ?? typographyProp);
|
|
52
26
|
|
|
53
27
|
textStyles.useVariants({
|
|
54
28
|
typography,
|
package/src/Text/types.ts
CHANGED
|
@@ -31,13 +31,6 @@ export interface TextProps extends TextSpacingStyleProps {
|
|
|
31
31
|
*/
|
|
32
32
|
typography?: TextTypographyVariant;
|
|
33
33
|
|
|
34
|
-
/**
|
|
35
|
-
* Text size - accepts Typography names or Size shorthand.
|
|
36
|
-
* Typography: 'h1', 'h2', 'body1', 'caption', etc.
|
|
37
|
-
* Size: 'xs', 'sm', 'md', 'lg', 'xl', '2xl', '3xl'
|
|
38
|
-
*/
|
|
39
|
-
size?: TextSizeVariant;
|
|
40
|
-
|
|
41
34
|
/**
|
|
42
35
|
* The weight of the text.
|
|
43
36
|
* Overrides the weight from typography if both are set.
|