@idealyst/components 1.0.49 → 1.0.50
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 +2 -2
- package/plugin/web.js +1 -1
- package/src/Icon/Icon.native.tsx +12 -9
- package/src/Icon/Icon.styles.tsx +1 -0
- package/src/Icon/Icon.web.tsx +0 -1
- package/src/Icon/types.ts +1 -1
- package/src/Pressable/Pressable.native.tsx +32 -0
- package/src/Pressable/Pressable.web.tsx +71 -0
- package/src/Pressable/index.ts +2 -0
- package/src/Pressable/index.web.native.ts +2 -0
- package/src/Pressable/index.web.ts +2 -0
- package/src/Pressable/types.ts +48 -0
- package/src/index.ts +3 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@idealyst/components",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.50",
|
|
4
4
|
"description": "Shared component library for React and React Native",
|
|
5
5
|
"documentation": "https://github.com/your-username/idealyst-framework/tree/main/packages/components#readme",
|
|
6
6
|
"main": "src/index.ts",
|
|
@@ -40,7 +40,7 @@
|
|
|
40
40
|
"publish:npm": "npm publish"
|
|
41
41
|
},
|
|
42
42
|
"peerDependencies": {
|
|
43
|
-
"@idealyst/theme": "^1.0.
|
|
43
|
+
"@idealyst/theme": "^1.0.50",
|
|
44
44
|
"@mdi/js": "^7.4.47",
|
|
45
45
|
"@mdi/react": "^1.6.1",
|
|
46
46
|
"@react-native-vector-icons/common": "^12.0.1",
|
package/plugin/web.js
CHANGED
|
@@ -261,7 +261,7 @@ module.exports = function ({ types: t }, options = {}) {
|
|
|
261
261
|
|
|
262
262
|
if (iconNames.length === 0) {
|
|
263
263
|
// For dynamic expressions we can't resolve, leave a helpful comment
|
|
264
|
-
console.warn(`[mdi-auto-import] Cannot determine icon name for dynamic expression at ${path.node.loc ? `${path.node.loc.start.line}:${path.node.loc.start.column}` : 'unknown location'}. Consider adding icon names to manifest (${manifestPath}) for auto-import support.`);
|
|
264
|
+
console.warn(`[mdi-auto-import] Cannot determine icon name (${nameAttr.value.expression}) for dynamic expression at ${path.node.loc ? `${path.node.loc.start.line}:${path.node.loc.start.column}` : 'unknown location'}. Consider adding icon names to manifest (${manifestPath}) for auto-import support.`);
|
|
265
265
|
return;
|
|
266
266
|
}
|
|
267
267
|
}
|
package/src/Icon/Icon.native.tsx
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import React from 'react';
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
2
|
import MaterialCommunityIcons from 'react-native-vector-icons/MaterialCommunityIcons';
|
|
3
3
|
import { IconProps } from './types';
|
|
4
4
|
import iconStyles from './Icon.styles';
|
|
@@ -16,14 +16,17 @@ const Icon: React.FC<IconProps> = ({
|
|
|
16
16
|
const styles = iconStyles.useVariants({ color, size });
|
|
17
17
|
|
|
18
18
|
// Map size variants to pixel values
|
|
19
|
-
const
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
19
|
+
const iconSize = useMemo(() => {
|
|
20
|
+
if (typeof size === 'number') return size;
|
|
21
|
+
const sizeMap = {
|
|
22
|
+
xs: 12,
|
|
23
|
+
sm: 16,
|
|
24
|
+
md: 24,
|
|
25
|
+
lg: 32,
|
|
26
|
+
xl: 48,
|
|
27
|
+
};
|
|
28
|
+
return sizeMap[size];
|
|
29
|
+
}, [])
|
|
27
30
|
|
|
28
31
|
return (
|
|
29
32
|
<MaterialCommunityIcons
|
package/src/Icon/Icon.styles.tsx
CHANGED
package/src/Icon/Icon.web.tsx
CHANGED
|
@@ -22,7 +22,6 @@ const Icon: React.FC<IconProps> = (props: InternalIconProps) => {
|
|
|
22
22
|
|
|
23
23
|
// Use Unistyles v3 with color and size variants
|
|
24
24
|
const styles = iconStyles.useVariants({ color, size });
|
|
25
|
-
console.log(styles);
|
|
26
25
|
|
|
27
26
|
// Check if we have a path prop (from Babel plugin transformation)
|
|
28
27
|
const { path } = restProps as { path?: string };
|
package/src/Icon/types.ts
CHANGED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { Pressable as RNPressable } from 'react-native';
|
|
3
|
+
import { PressableProps } from './types';
|
|
4
|
+
|
|
5
|
+
const Pressable: React.FC<PressableProps> = ({
|
|
6
|
+
children,
|
|
7
|
+
onPress,
|
|
8
|
+
onPressIn,
|
|
9
|
+
onPressOut,
|
|
10
|
+
disabled = false,
|
|
11
|
+
style,
|
|
12
|
+
testID,
|
|
13
|
+
accessibilityLabel,
|
|
14
|
+
accessibilityRole,
|
|
15
|
+
}) => {
|
|
16
|
+
return (
|
|
17
|
+
<RNPressable
|
|
18
|
+
onPress={onPress}
|
|
19
|
+
onPressIn={onPressIn}
|
|
20
|
+
onPressOut={onPressOut}
|
|
21
|
+
disabled={disabled}
|
|
22
|
+
style={style}
|
|
23
|
+
testID={testID}
|
|
24
|
+
accessibilityLabel={accessibilityLabel}
|
|
25
|
+
accessibilityRole={accessibilityRole}
|
|
26
|
+
>
|
|
27
|
+
{children}
|
|
28
|
+
</RNPressable>
|
|
29
|
+
);
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
export default Pressable;
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
|
+
import { PressableProps } from './types';
|
|
3
|
+
|
|
4
|
+
const Pressable: React.FC<PressableProps> = ({
|
|
5
|
+
children,
|
|
6
|
+
onPress,
|
|
7
|
+
onPressIn,
|
|
8
|
+
onPressOut,
|
|
9
|
+
disabled = false,
|
|
10
|
+
style,
|
|
11
|
+
testID,
|
|
12
|
+
accessibilityLabel,
|
|
13
|
+
accessibilityRole = 'button',
|
|
14
|
+
}) => {
|
|
15
|
+
const [isPressed, setIsPressed] = useState(false);
|
|
16
|
+
|
|
17
|
+
const handleMouseDown = useCallback(() => {
|
|
18
|
+
if (disabled) return;
|
|
19
|
+
setIsPressed(true);
|
|
20
|
+
onPressIn?.();
|
|
21
|
+
}, [disabled, onPressIn]);
|
|
22
|
+
|
|
23
|
+
const handleMouseUp = useCallback(() => {
|
|
24
|
+
if (disabled) return;
|
|
25
|
+
setIsPressed(false);
|
|
26
|
+
onPressOut?.();
|
|
27
|
+
}, [disabled, onPressOut]);
|
|
28
|
+
|
|
29
|
+
const handleClick = useCallback(() => {
|
|
30
|
+
if (disabled) return;
|
|
31
|
+
onPress?.();
|
|
32
|
+
}, [disabled, onPress]);
|
|
33
|
+
|
|
34
|
+
const handleKeyDown = useCallback((event: React.KeyboardEvent) => {
|
|
35
|
+
if (disabled) return;
|
|
36
|
+
if (event.key === 'Enter' || event.key === ' ') {
|
|
37
|
+
event.preventDefault();
|
|
38
|
+
onPress?.();
|
|
39
|
+
}
|
|
40
|
+
}, [disabled, onPress]);
|
|
41
|
+
|
|
42
|
+
const webStyle = {
|
|
43
|
+
...style,
|
|
44
|
+
cursor: disabled ? 'default' : 'pointer',
|
|
45
|
+
outline: 'none',
|
|
46
|
+
userSelect: 'none' as const,
|
|
47
|
+
WebkitUserSelect: 'none' as const,
|
|
48
|
+
WebkitTapHighlightColor: 'transparent',
|
|
49
|
+
opacity: disabled ? 0.5 : 1,
|
|
50
|
+
};
|
|
51
|
+
|
|
52
|
+
return (
|
|
53
|
+
<div
|
|
54
|
+
role={accessibilityRole}
|
|
55
|
+
tabIndex={disabled ? -1 : 0}
|
|
56
|
+
style={webStyle}
|
|
57
|
+
onMouseDown={handleMouseDown}
|
|
58
|
+
onMouseUp={handleMouseUp}
|
|
59
|
+
onMouseLeave={handleMouseUp} // Handle mouse leave as press out
|
|
60
|
+
onClick={handleClick}
|
|
61
|
+
onKeyDown={handleKeyDown}
|
|
62
|
+
data-testid={testID}
|
|
63
|
+
aria-label={accessibilityLabel}
|
|
64
|
+
aria-disabled={disabled}
|
|
65
|
+
>
|
|
66
|
+
{children}
|
|
67
|
+
</div>
|
|
68
|
+
);
|
|
69
|
+
};
|
|
70
|
+
|
|
71
|
+
export default Pressable;
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { ReactNode } from 'react';
|
|
2
|
+
|
|
3
|
+
export interface PressableProps {
|
|
4
|
+
/**
|
|
5
|
+
* Content to render inside the pressable area
|
|
6
|
+
*/
|
|
7
|
+
children?: ReactNode;
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Called when the press gesture is activated
|
|
11
|
+
*/
|
|
12
|
+
onPress?: () => void;
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
* Called when the press gesture starts
|
|
16
|
+
*/
|
|
17
|
+
onPressIn?: () => void;
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Called when the press gesture ends
|
|
21
|
+
*/
|
|
22
|
+
onPressOut?: () => void;
|
|
23
|
+
|
|
24
|
+
/**
|
|
25
|
+
* Whether the pressable is disabled
|
|
26
|
+
*/
|
|
27
|
+
disabled?: boolean;
|
|
28
|
+
|
|
29
|
+
/**
|
|
30
|
+
* Additional styles to apply
|
|
31
|
+
*/
|
|
32
|
+
style?: any;
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* Test ID for testing
|
|
36
|
+
*/
|
|
37
|
+
testID?: string;
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Accessibility label for screen readers
|
|
41
|
+
*/
|
|
42
|
+
accessibilityLabel?: string;
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Accessibility role (web)
|
|
46
|
+
*/
|
|
47
|
+
accessibilityRole?: string;
|
|
48
|
+
}
|
package/src/index.ts
CHANGED
|
@@ -7,6 +7,9 @@ export * from './Text/types';
|
|
|
7
7
|
export { default as View } from './View';
|
|
8
8
|
export * from './View/types';
|
|
9
9
|
|
|
10
|
+
export { default as Pressable } from './Pressable';
|
|
11
|
+
export * from './Pressable/types';
|
|
12
|
+
|
|
10
13
|
export { default as Input } from './Input';
|
|
11
14
|
export * from './Input/types';
|
|
12
15
|
|