@idealyst/components 1.2.132 → 1.2.133
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.
|
|
3
|
+
"version": "1.2.133",
|
|
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.133",
|
|
60
60
|
"@mdi/js": ">=7.0.0",
|
|
61
61
|
"@mdi/react": ">=1.0.0",
|
|
62
62
|
"@react-native-vector-icons/common": ">=12.0.0",
|
|
@@ -111,8 +111,8 @@
|
|
|
111
111
|
},
|
|
112
112
|
"devDependencies": {
|
|
113
113
|
"@idealyst/blur": "^1.2.40",
|
|
114
|
-
"@idealyst/theme": "^1.2.
|
|
115
|
-
"@idealyst/tooling": "^1.2.
|
|
114
|
+
"@idealyst/theme": "^1.2.133",
|
|
115
|
+
"@idealyst/tooling": "^1.2.133",
|
|
116
116
|
"@mdi/react": "^1.6.1",
|
|
117
117
|
"@types/react": "^19.1.0",
|
|
118
118
|
"react": "^19.1.0",
|
|
@@ -4,6 +4,7 @@ import MaterialDesignIcons from '@react-native-vector-icons/material-design-icon
|
|
|
4
4
|
import Svg, { Defs, LinearGradient, Stop, Rect } from 'react-native-svg';
|
|
5
5
|
import { buttonStyles } from './Button.styles';
|
|
6
6
|
import { ButtonProps } from './types';
|
|
7
|
+
import { createPressEvent } from '../utils/events';
|
|
7
8
|
import { getNativeInteractiveAccessibilityProps } from '../utils/accessibility';
|
|
8
9
|
import type { IdealystElement } from '../utils/refTypes';
|
|
9
10
|
|
|
@@ -169,7 +170,7 @@ const Button = forwardRef<IdealystElement, ButtonProps>((props, ref) => {
|
|
|
169
170
|
// TouchableOpacity types don't include nativeID but it's a valid RN prop
|
|
170
171
|
const touchableProps = {
|
|
171
172
|
ref,
|
|
172
|
-
onPress: pressHandler,
|
|
173
|
+
onPress: pressHandler ? (e: any) => pressHandler(createPressEvent(e)) : undefined,
|
|
173
174
|
disabled: isDisabled,
|
|
174
175
|
testID,
|
|
175
176
|
nativeID: id,
|
|
@@ -3,6 +3,7 @@ import { getWebProps } from 'react-native-unistyles/web';
|
|
|
3
3
|
import { ButtonProps } from './types';
|
|
4
4
|
import { buttonStyles } from './Button.styles';
|
|
5
5
|
import { IconSvg } from '../Icon/IconSvg/IconSvg.web';
|
|
6
|
+
import { createPressEvent } from '../utils/events';
|
|
6
7
|
import useMergeRefs from '../hooks/useMergeRefs';
|
|
7
8
|
import { getWebInteractiveAriaProps, generateAccessibilityId } from '../utils/accessibility';
|
|
8
9
|
import type { IdealystElement } from '../utils/refTypes';
|
|
@@ -67,7 +68,7 @@ const Button = forwardRef<IdealystElement, ButtonProps>((props, ref) => {
|
|
|
67
68
|
e.preventDefault();
|
|
68
69
|
e.stopPropagation();
|
|
69
70
|
if (!isDisabled && pressHandler) {
|
|
70
|
-
pressHandler();
|
|
71
|
+
pressHandler(createPressEvent(e));
|
|
71
72
|
}
|
|
72
73
|
};
|
|
73
74
|
|
package/src/Button/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import type { IconName } from '../Icon/icon-types';
|
|
4
|
+
import type { PressEvent } from '../utils/events';
|
|
4
5
|
import { Intent, Size } from '@idealyst/theme';
|
|
5
6
|
import { BaseProps } from '../utils/viewStyleProps';
|
|
6
7
|
import { InteractiveAccessibilityProps } from '../utils/accessibility';
|
|
@@ -31,13 +32,13 @@ export interface ButtonProps extends BaseProps, InteractiveAccessibilityProps {
|
|
|
31
32
|
/**
|
|
32
33
|
* Called when the button is pressed
|
|
33
34
|
*/
|
|
34
|
-
onPress?: () => void;
|
|
35
|
+
onPress?: (event: PressEvent) => void;
|
|
35
36
|
|
|
36
37
|
/**
|
|
37
38
|
* @deprecated Use `onPress` instead. This prop exists for web compatibility only.
|
|
38
39
|
* Using onClick will log a deprecation warning in development.
|
|
39
40
|
*/
|
|
40
|
-
onClick?: () => void;
|
|
41
|
+
onClick?: (event: PressEvent) => void;
|
|
41
42
|
|
|
42
43
|
/**
|
|
43
44
|
* Whether the button is disabled
|
|
@@ -2,6 +2,7 @@ import { forwardRef } from 'react';
|
|
|
2
2
|
import { TouchableWithoutFeedback, View } from 'react-native';
|
|
3
3
|
import { PressableProps } from './types';
|
|
4
4
|
import { pressableStyles } from './Pressable.styles';
|
|
5
|
+
import { createPressEvent } from '../utils/events';
|
|
5
6
|
import type { IdealystElement } from '../utils/refTypes';
|
|
6
7
|
|
|
7
8
|
const Pressable = forwardRef<IdealystElement, PressableProps>(({
|
|
@@ -31,9 +32,9 @@ const Pressable = forwardRef<IdealystElement, PressableProps>(({
|
|
|
31
32
|
|
|
32
33
|
return (
|
|
33
34
|
<TouchableWithoutFeedback
|
|
34
|
-
onPress={disabled ? undefined : onPress}
|
|
35
|
-
onPressIn={disabled ? undefined : onPressIn}
|
|
36
|
-
onPressOut={disabled ? undefined : onPressOut}
|
|
35
|
+
onPress={disabled ? undefined : (e) => onPress?.(createPressEvent(e))}
|
|
36
|
+
onPressIn={disabled ? undefined : (e) => onPressIn?.(createPressEvent(e, 'pressIn'))}
|
|
37
|
+
onPressOut={disabled ? undefined : (e) => onPressOut?.(createPressEvent(e, 'pressOut'))}
|
|
37
38
|
disabled={disabled}
|
|
38
39
|
testID={testID}
|
|
39
40
|
accessibilityLabel={accessibilityLabel}
|
|
@@ -2,6 +2,8 @@ import React, { useCallback, useState, forwardRef } from 'react';
|
|
|
2
2
|
import { getWebProps } from 'react-native-unistyles/web';
|
|
3
3
|
import { PressableProps } from './types';
|
|
4
4
|
import { pressableStyles } from './Pressable.styles';
|
|
5
|
+
import { createPressEvent, createBaseSyntheticEvent } from '../utils/events';
|
|
6
|
+
import type { PressEvent } from '../utils/events';
|
|
5
7
|
import useMergeRefs from '../hooks/useMergeRefs';
|
|
6
8
|
import type { IdealystElement } from '../utils/refTypes';
|
|
7
9
|
import { flattenStyle } from '../utils/flattenStyle';
|
|
@@ -29,7 +31,7 @@ const Pressable = forwardRef<IdealystElement, PressableProps>(({
|
|
|
29
31
|
e.stopPropagation();
|
|
30
32
|
if (disabled) return;
|
|
31
33
|
setIsPressed(true);
|
|
32
|
-
onPressIn?.();
|
|
34
|
+
onPressIn?.(createPressEvent(e as React.MouseEvent<HTMLElement>, 'pressIn'));
|
|
33
35
|
}, [disabled, onPressIn]);
|
|
34
36
|
|
|
35
37
|
const handleMouseUp = useCallback((e: React.MouseEvent) => {
|
|
@@ -37,14 +39,14 @@ const Pressable = forwardRef<IdealystElement, PressableProps>(({
|
|
|
37
39
|
e.stopPropagation();
|
|
38
40
|
if (disabled) return;
|
|
39
41
|
setIsPressed(false);
|
|
40
|
-
onPressOut?.();
|
|
42
|
+
onPressOut?.(createPressEvent(e as React.MouseEvent<HTMLElement>, 'pressOut'));
|
|
41
43
|
}, [disabled, onPressOut]);
|
|
42
44
|
|
|
43
45
|
const handleClick = useCallback((e: React.MouseEvent) => {
|
|
44
46
|
e.preventDefault();
|
|
45
47
|
e.stopPropagation();
|
|
46
48
|
if (disabled) return;
|
|
47
|
-
onPress?.();
|
|
49
|
+
onPress?.(createPressEvent(e as React.MouseEvent<HTMLElement>));
|
|
48
50
|
}, [disabled, onPress]);
|
|
49
51
|
|
|
50
52
|
const handleKeyDown = useCallback((event: React.KeyboardEvent) => {
|
|
@@ -52,7 +54,11 @@ const Pressable = forwardRef<IdealystElement, PressableProps>(({
|
|
|
52
54
|
if (event.key === 'Enter' || event.key === ' ') {
|
|
53
55
|
event.preventDefault();
|
|
54
56
|
event.stopPropagation();
|
|
55
|
-
|
|
57
|
+
const pressEvent: PressEvent = {
|
|
58
|
+
...createBaseSyntheticEvent(event.nativeEvent),
|
|
59
|
+
type: 'press',
|
|
60
|
+
};
|
|
61
|
+
onPress?.(pressEvent);
|
|
56
62
|
}
|
|
57
63
|
}, [disabled, onPress]);
|
|
58
64
|
|
package/src/Pressable/types.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { ReactNode } from 'react';
|
|
2
2
|
import type { StyleProp, ViewStyle } from 'react-native';
|
|
3
3
|
import { PressableSpacingStyleProps } from '../utils/viewStyleProps';
|
|
4
|
+
import type { PressEvent } from '../utils/events';
|
|
4
5
|
|
|
5
6
|
export interface PressableProps extends PressableSpacingStyleProps {
|
|
6
7
|
/**
|
|
@@ -11,17 +12,17 @@ export interface PressableProps extends PressableSpacingStyleProps {
|
|
|
11
12
|
/**
|
|
12
13
|
* Called when the press gesture is activated
|
|
13
14
|
*/
|
|
14
|
-
onPress?: () => void;
|
|
15
|
+
onPress?: (event: PressEvent) => void;
|
|
15
16
|
|
|
16
17
|
/**
|
|
17
18
|
* Called when the press gesture starts
|
|
18
19
|
*/
|
|
19
|
-
onPressIn?: () => void;
|
|
20
|
+
onPressIn?: (event: PressEvent) => void;
|
|
20
21
|
|
|
21
22
|
/**
|
|
22
23
|
* Called when the press gesture ends
|
|
23
24
|
*/
|
|
24
|
-
onPressOut?: () => void;
|
|
25
|
+
onPressOut?: (event: PressEvent) => void;
|
|
25
26
|
|
|
26
27
|
/**
|
|
27
28
|
* Whether the pressable is disabled
|