@idealyst/components 1.2.102 → 1.2.104
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 +4 -4
- package/src/Grid/Grid.web.tsx +2 -2
- package/src/Switch/Switch.native.tsx +5 -11
- package/src/Switch/Switch.web.tsx +8 -12
- package/src/Text/Text.native.tsx +8 -0
- package/src/Text/Text.styles.tsx +4 -3
- package/src/Text/Text.web.tsx +18 -0
- package/src/Text/defaults.ts +33 -0
- package/src/Text/index.native.ts +2 -1
- package/src/Text/index.ts +1 -0
- package/src/Text/index.web.ts +1 -0
- package/src/Text/types.ts +14 -0
- package/src/index.ts +1 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.104",
|
|
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.104",
|
|
60
60
|
"@mdi/js": ">=7.0.0",
|
|
61
61
|
"@mdi/react": ">=1.0.0",
|
|
62
62
|
"@react-native-vector-icons/common": ">=12.0.0",
|
|
@@ -107,8 +107,8 @@
|
|
|
107
107
|
},
|
|
108
108
|
"devDependencies": {
|
|
109
109
|
"@idealyst/blur": "^1.2.40",
|
|
110
|
-
"@idealyst/theme": "^1.2.
|
|
111
|
-
"@idealyst/tooling": "^1.2.
|
|
110
|
+
"@idealyst/theme": "^1.2.104",
|
|
111
|
+
"@idealyst/tooling": "^1.2.104",
|
|
112
112
|
"@mdi/react": "^1.6.1",
|
|
113
113
|
"@types/react": "^19.1.0",
|
|
114
114
|
"react": "^19.1.0",
|
package/src/Grid/Grid.web.tsx
CHANGED
|
@@ -62,7 +62,7 @@ const Grid = forwardRef<IdealystElement, GridProps>(({
|
|
|
62
62
|
marginHorizontal,
|
|
63
63
|
});
|
|
64
64
|
|
|
65
|
-
const webProps = getWebProps(
|
|
65
|
+
const webProps = getWebProps(gridStyles.grid);
|
|
66
66
|
const mergedRef = useMergeRefs(ref, webProps.ref, layoutRef);
|
|
67
67
|
|
|
68
68
|
const gridTemplateColumns = `repeat(${resolvedColumns}, 1fr)`;
|
|
@@ -74,7 +74,7 @@ const Grid = forwardRef<IdealystElement, GridProps>(({
|
|
|
74
74
|
id={id}
|
|
75
75
|
data-testid={testID}
|
|
76
76
|
style={{
|
|
77
|
-
...
|
|
77
|
+
...flattenStyle(style),
|
|
78
78
|
gridTemplateColumns,
|
|
79
79
|
}}
|
|
80
80
|
>
|
|
@@ -121,23 +121,17 @@ const Switch = forwardRef<IdealystElement, SwitchProps>(({
|
|
|
121
121
|
};
|
|
122
122
|
});
|
|
123
123
|
|
|
124
|
-
// Get dynamic styles - call as functions for theme reactivity
|
|
125
|
-
const switchTrackStyle = (switchStyles.switchTrack as any)({ checked, intent, disabled });
|
|
126
|
-
const containerStyle = (switchStyles.container as any)({});
|
|
127
|
-
const switchContainerStyle = (switchStyles.switchContainer as any)({});
|
|
128
|
-
const labelStyle = (switchStyles.label as any)({ disabled, labelPosition });
|
|
129
|
-
|
|
130
124
|
const switchElement = (
|
|
131
125
|
<Pressable
|
|
132
126
|
ref={!label ? ref : undefined}
|
|
133
127
|
nativeID={!label ? id : undefined}
|
|
134
128
|
onPress={handlePress}
|
|
135
129
|
disabled={disabled}
|
|
136
|
-
style={
|
|
130
|
+
style={switchStyles.switchContainer as any}
|
|
137
131
|
testID={testID}
|
|
138
132
|
{...nativeA11yProps}
|
|
139
133
|
>
|
|
140
|
-
<Animated.View style={
|
|
134
|
+
<Animated.View style={switchStyles.switchTrack as any}>
|
|
141
135
|
<Animated.View
|
|
142
136
|
style={[
|
|
143
137
|
{
|
|
@@ -167,14 +161,14 @@ const Switch = forwardRef<IdealystElement, SwitchProps>(({
|
|
|
167
161
|
nativeID={id}
|
|
168
162
|
onPress={handlePress}
|
|
169
163
|
disabled={disabled}
|
|
170
|
-
style={[
|
|
164
|
+
style={[switchStyles.container as any, style]}
|
|
171
165
|
>
|
|
172
166
|
{labelPosition === 'left' && (
|
|
173
|
-
<Text style={
|
|
167
|
+
<Text style={switchStyles.label as any}>{label}</Text>
|
|
174
168
|
)}
|
|
175
169
|
{switchElement}
|
|
176
170
|
{labelPosition === 'right' && (
|
|
177
|
-
<Text style={
|
|
171
|
+
<Text style={switchStyles.label as any}>{label}</Text>
|
|
178
172
|
)}
|
|
179
173
|
</Pressable>
|
|
180
174
|
);
|
|
@@ -93,10 +93,10 @@ const Switch = forwardRef<IdealystElement, SwitchProps>(({
|
|
|
93
93
|
marginHorizontal,
|
|
94
94
|
});
|
|
95
95
|
|
|
96
|
-
const trackProps = getWebProps([
|
|
97
|
-
const thumbProps = getWebProps([
|
|
98
|
-
const thumbIconProps = getWebProps([
|
|
99
|
-
const labelProps = getWebProps([
|
|
96
|
+
const trackProps = getWebProps([switchStyles.switchTrack as any]);
|
|
97
|
+
const thumbProps = getWebProps([switchStyles.switchThumb as any]);
|
|
98
|
+
const thumbIconProps = getWebProps([switchStyles.thumbIcon as any]);
|
|
99
|
+
const labelProps = getWebProps([switchStyles.label as any]);
|
|
100
100
|
|
|
101
101
|
// Helper to render icon
|
|
102
102
|
const renderIcon = () => {
|
|
@@ -118,15 +118,11 @@ const Switch = forwardRef<IdealystElement, SwitchProps>(({
|
|
|
118
118
|
return null;
|
|
119
119
|
};
|
|
120
120
|
|
|
121
|
-
// Computed button props with
|
|
122
|
-
const computedButtonProps = getWebProps([
|
|
123
|
-
(switchStyles.switchContainer as any)({})
|
|
124
|
-
]);
|
|
121
|
+
// Computed button props with static style references
|
|
122
|
+
const computedButtonProps = getWebProps([switchStyles.switchContainer as any]);
|
|
125
123
|
|
|
126
|
-
// Computed container props
|
|
127
|
-
const computedContainerProps = getWebProps([
|
|
128
|
-
(switchStyles.container as any)({ disabled }),
|
|
129
|
-
]);
|
|
124
|
+
// Computed container props (for when label exists)
|
|
125
|
+
const computedContainerProps = getWebProps([switchStyles.container as any]);
|
|
130
126
|
|
|
131
127
|
const mergedButtonRef = useMergeRefs(ref as React.Ref<HTMLButtonElement>, computedButtonProps.ref);
|
|
132
128
|
const mergedContainerRef = useMergeRefs(ref as React.Ref<HTMLDivElement>, computedContainerProps.ref);
|
package/src/Text/Text.native.tsx
CHANGED
|
@@ -2,6 +2,8 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
import { Text as RNText } from 'react-native';
|
|
3
3
|
import { TextProps } from './types';
|
|
4
4
|
import { textStyles } from './Text.styles';
|
|
5
|
+
import { getTextDefaults } from './defaults';
|
|
6
|
+
import { getDefaultMaxFontSizeMultiplier } from '@idealyst/theme';
|
|
5
7
|
import type { IdealystElement } from '../utils/refTypes';
|
|
6
8
|
|
|
7
9
|
const Text = forwardRef<IdealystElement, TextProps>(({
|
|
@@ -10,6 +12,8 @@ const Text = forwardRef<IdealystElement, TextProps>(({
|
|
|
10
12
|
weight,
|
|
11
13
|
color,
|
|
12
14
|
align = 'left',
|
|
15
|
+
numberOfLines,
|
|
16
|
+
maxFontSizeMultiplier,
|
|
13
17
|
// Spacing variants from TextSpacingStyleProps
|
|
14
18
|
gap,
|
|
15
19
|
padding,
|
|
@@ -29,10 +33,14 @@ const Text = forwardRef<IdealystElement, TextProps>(({
|
|
|
29
33
|
paddingHorizontal,
|
|
30
34
|
});
|
|
31
35
|
|
|
36
|
+
const resolvedMaxFontSizeMultiplier = maxFontSizeMultiplier ?? getTextDefaults().maxFontSizeMultiplier ?? getDefaultMaxFontSizeMultiplier();
|
|
37
|
+
|
|
32
38
|
return (
|
|
33
39
|
<RNText
|
|
34
40
|
ref={ref as any}
|
|
35
41
|
nativeID={id}
|
|
42
|
+
numberOfLines={numberOfLines}
|
|
43
|
+
maxFontSizeMultiplier={resolvedMaxFontSizeMultiplier}
|
|
36
44
|
style={[textStyles.text({ color, typography, weight, align }), style]}
|
|
37
45
|
testID={testID}
|
|
38
46
|
>
|
package/src/Text/Text.styles.tsx
CHANGED
|
@@ -20,8 +20,8 @@ export type TextVariants = {
|
|
|
20
20
|
}
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Parameters for the internal Text dynamic style function.
|
|
24
|
+
* Used by the defineStyle implementation to resolve styles at runtime.
|
|
25
25
|
*/
|
|
26
26
|
export type TextStyleParams = {
|
|
27
27
|
/** Text color variant */
|
|
@@ -36,9 +36,10 @@ export type TextStyleParams = {
|
|
|
36
36
|
|
|
37
37
|
/**
|
|
38
38
|
* Text style definition type for use with extendStyle/overrideStyle.
|
|
39
|
+
* Extensions are plain style objects — functions are NOT supported.
|
|
39
40
|
*/
|
|
40
41
|
export interface TextStyleDef {
|
|
41
|
-
text:
|
|
42
|
+
text: TextStyle & {
|
|
42
43
|
variants?: {
|
|
43
44
|
typography?: Record<string, TextStyle>;
|
|
44
45
|
weight?: Record<string, TextStyle>;
|
package/src/Text/Text.web.tsx
CHANGED
|
@@ -16,6 +16,7 @@ const Text = forwardRef<IdealystElement, TextProps>(({
|
|
|
16
16
|
weight,
|
|
17
17
|
color = 'primary',
|
|
18
18
|
align = 'left',
|
|
19
|
+
numberOfLines,
|
|
19
20
|
// Spacing variants from TextSpacingStyleProps
|
|
20
21
|
gap,
|
|
21
22
|
padding,
|
|
@@ -36,9 +37,26 @@ const Text = forwardRef<IdealystElement, TextProps>(({
|
|
|
36
37
|
paddingHorizontal,
|
|
37
38
|
});
|
|
38
39
|
|
|
40
|
+
// Build numberOfLines truncation styles for web
|
|
41
|
+
const truncationStyle: React.CSSProperties | undefined = numberOfLines != null
|
|
42
|
+
? numberOfLines === 1
|
|
43
|
+
? {
|
|
44
|
+
overflow: 'hidden',
|
|
45
|
+
textOverflow: 'ellipsis',
|
|
46
|
+
whiteSpace: 'nowrap',
|
|
47
|
+
}
|
|
48
|
+
: {
|
|
49
|
+
overflow: 'hidden',
|
|
50
|
+
display: '-webkit-box',
|
|
51
|
+
WebkitBoxOrient: 'vertical' as const,
|
|
52
|
+
WebkitLineClamp: numberOfLines,
|
|
53
|
+
}
|
|
54
|
+
: undefined;
|
|
55
|
+
|
|
39
56
|
// Create the style array - pass all style-affecting props to dynamic style function
|
|
40
57
|
const textStyleArray = [
|
|
41
58
|
(textStyles.text as any)({ color, typography, weight, align }),
|
|
59
|
+
truncationStyle,
|
|
42
60
|
flattenStyle(style),
|
|
43
61
|
];
|
|
44
62
|
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Module-level defaults for the Text component.
|
|
3
|
+
*
|
|
4
|
+
* Configure once at app startup:
|
|
5
|
+
* import { setTextDefaults } from '@idealyst/components';
|
|
6
|
+
* setTextDefaults({ maxFontSizeMultiplier: 1.2 });
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
export interface TextDefaults {
|
|
10
|
+
/**
|
|
11
|
+
* Default maximum font scale factor for accessibility text sizing.
|
|
12
|
+
* Applied to all Text components unless overridden by the prop.
|
|
13
|
+
* Set to 0 to disable scaling limits. undefined means no limit.
|
|
14
|
+
*/
|
|
15
|
+
maxFontSizeMultiplier?: number;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let defaults: TextDefaults = {};
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Set default values for all Text components.
|
|
22
|
+
* Call once at app startup before rendering.
|
|
23
|
+
*/
|
|
24
|
+
export function setTextDefaults(newDefaults: TextDefaults): void {
|
|
25
|
+
defaults = { ...defaults, ...newDefaults };
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
/**
|
|
29
|
+
* Get current Text defaults. Used internally by Text components.
|
|
30
|
+
*/
|
|
31
|
+
export function getTextDefaults(): TextDefaults {
|
|
32
|
+
return defaults;
|
|
33
|
+
}
|
package/src/Text/index.native.ts
CHANGED
package/src/Text/index.ts
CHANGED
package/src/Text/index.web.ts
CHANGED
package/src/Text/types.ts
CHANGED
|
@@ -47,6 +47,20 @@ export interface TextProps extends TextSpacingStyleProps {
|
|
|
47
47
|
*/
|
|
48
48
|
align?: TextAlignVariant;
|
|
49
49
|
|
|
50
|
+
/**
|
|
51
|
+
* Number of lines to display before truncating with ellipsis.
|
|
52
|
+
* On native, maps directly to React Native's numberOfLines prop.
|
|
53
|
+
* On web, uses CSS line-clamp for multi-line and text-overflow for single-line.
|
|
54
|
+
*/
|
|
55
|
+
numberOfLines?: number;
|
|
56
|
+
|
|
57
|
+
/**
|
|
58
|
+
* Maximum font scale factor for accessibility text sizing.
|
|
59
|
+
* Limits how large text can grow when the user increases their device font size.
|
|
60
|
+
* Set to 0 to disable scaling limits. Only applies on native (iOS & Android).
|
|
61
|
+
*/
|
|
62
|
+
maxFontSizeMultiplier?: number;
|
|
63
|
+
|
|
50
64
|
/**
|
|
51
65
|
* Additional styles (platform-specific)
|
|
52
66
|
*/
|
package/src/index.ts
CHANGED
|
@@ -9,7 +9,7 @@ export * from './Button/types';
|
|
|
9
9
|
export { default as IconButton } from './IconButton';
|
|
10
10
|
export * from './IconButton/types';
|
|
11
11
|
|
|
12
|
-
export { default as Text } from './Text';
|
|
12
|
+
export { default as Text, setTextDefaults } from './Text';
|
|
13
13
|
export * from './Text/types';
|
|
14
14
|
|
|
15
15
|
export { default as View } from './View';
|