@idealyst/components 1.2.101 → 1.2.103

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 CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@idealyst/components",
3
- "version": "1.2.101",
3
+ "version": "1.2.103",
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.101",
59
+ "@idealyst/theme": "^1.2.103",
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.101",
111
- "@idealyst/tooling": "^1.2.101",
110
+ "@idealyst/theme": "^1.2.103",
111
+ "@idealyst/tooling": "^1.2.103",
112
112
  "@mdi/react": "^1.6.1",
113
113
  "@types/react": "^19.1.0",
114
114
  "react": "^19.1.0",
@@ -62,7 +62,7 @@ const Grid = forwardRef<IdealystElement, GridProps>(({
62
62
  marginHorizontal,
63
63
  });
64
64
 
65
- const webProps = getWebProps([gridStyles.grid, flattenStyle(style)]);
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
- ...webProps.style,
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={switchContainerStyle}
130
+ style={switchStyles.switchContainer as any}
137
131
  testID={testID}
138
132
  {...nativeA11yProps}
139
133
  >
140
- <Animated.View style={switchTrackStyle}>
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={[containerStyle, style]}
164
+ style={[switchStyles.container as any, style]}
171
165
  >
172
166
  {labelPosition === 'left' && (
173
- <Text style={labelStyle}>{label}</Text>
167
+ <Text style={switchStyles.label as any}>{label}</Text>
174
168
  )}
175
169
  {switchElement}
176
170
  {labelPosition === 'right' && (
177
- <Text style={labelStyle}>{label}</Text>
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([(switchStyles.switchTrack as any)({ checked, intent, disabled })]);
97
- const thumbProps = getWebProps([(switchStyles.switchThumb as any)({ size, checked })]);
98
- const thumbIconProps = getWebProps([(switchStyles.thumbIcon as any)({ checked, intent })]);
99
- const labelProps = getWebProps([(switchStyles.label as any)({ disabled, labelPosition })]);
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 dynamic styles
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 with dynamic styles (for when label exists)
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);
@@ -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
  >
@@ -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
+ }
@@ -1,3 +1,4 @@
1
1
  // React Native-specific Text export
2
2
  export { default } from './Text.native';
3
- export * from './types';
3
+ export * from './types';
4
+ export { setTextDefaults } from './defaults';
package/src/Text/index.ts CHANGED
@@ -3,4 +3,5 @@ import TextComponent from './Text.web';
3
3
  export default TextComponent;
4
4
  export { TextComponent as Text };
5
5
  export * from './types';
6
+ export { setTextDefaults } from './defaults';
6
7
  export type { TextStyleDef, TextStyleParams, TextVariants } from './Text.styles';
@@ -3,3 +3,4 @@ import TextComponent from './Text.web';
3
3
  export default TextComponent;
4
4
  export { TextComponent as Text };
5
5
  export * from './types';
6
+ export { setTextDefaults } from './defaults';
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';