react-native-ui-lib 7.38.0-snapshot.6267 → 7.38.0-snapshot.6268
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
|
@@ -17,4 +17,10 @@ export declare const MIN_WIDTH: {
|
|
|
17
17
|
MEDIUM: number;
|
|
18
18
|
LARGE: number;
|
|
19
19
|
};
|
|
20
|
+
export declare const SIZE_TO_VERTICAL_HITSLOP: {
|
|
21
|
+
readonly xSmall: 30;
|
|
22
|
+
readonly small: 25;
|
|
23
|
+
readonly medium: 20;
|
|
24
|
+
readonly large: 15;
|
|
25
|
+
};
|
|
20
26
|
export declare const DEFAULT_SIZE = ButtonSize.large;
|
|
@@ -17,4 +17,10 @@ export const MIN_WIDTH = {
|
|
|
17
17
|
MEDIUM: 77,
|
|
18
18
|
LARGE: 90
|
|
19
19
|
};
|
|
20
|
+
export const SIZE_TO_VERTICAL_HITSLOP = {
|
|
21
|
+
[ButtonSize.xSmall]: 30,
|
|
22
|
+
[ButtonSize.small]: 25,
|
|
23
|
+
[ButtonSize.medium]: 20,
|
|
24
|
+
[ButtonSize.large]: 15
|
|
25
|
+
};
|
|
20
26
|
export const DEFAULT_SIZE = ButtonSize.large;
|
|
@@ -11,9 +11,7 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
11
11
|
static sizes: typeof ButtonSize;
|
|
12
12
|
static animationDirection: typeof ButtonAnimationDirection;
|
|
13
13
|
constructor(props: Props);
|
|
14
|
-
state:
|
|
15
|
-
size: undefined;
|
|
16
|
-
};
|
|
14
|
+
state: Record<'size', undefined | number>;
|
|
17
15
|
styles: {
|
|
18
16
|
container: {
|
|
19
17
|
backgroundColor: string;
|
|
@@ -370,7 +368,14 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
370
368
|
getLabelColor(): string | undefined;
|
|
371
369
|
getIconColor(): string | undefined;
|
|
372
370
|
getLabelSizeStyle(): TextStyle | undefined;
|
|
373
|
-
getContainerSizeStyle():
|
|
371
|
+
getContainerSizeStyle(): Partial<{
|
|
372
|
+
height: number;
|
|
373
|
+
width: number;
|
|
374
|
+
padding: number;
|
|
375
|
+
paddingVertical: number;
|
|
376
|
+
paddingHorizontal: number;
|
|
377
|
+
minWidth: number;
|
|
378
|
+
}>;
|
|
374
379
|
getOutlineStyle(): {
|
|
375
380
|
borderWidth: number;
|
|
376
381
|
borderColor: string;
|
|
@@ -391,10 +396,18 @@ declare class Button extends PureComponent<Props, ButtonState> {
|
|
|
391
396
|
})[] | undefined;
|
|
392
397
|
getIconStyle(): [ImageStyle, StyleProp<ImageStyle>];
|
|
393
398
|
getAnimationDirectionStyle(): {
|
|
394
|
-
alignSelf:
|
|
399
|
+
readonly alignSelf: "flex-start";
|
|
400
|
+
} | {
|
|
401
|
+
readonly alignSelf: "flex-end";
|
|
395
402
|
} | undefined;
|
|
396
403
|
renderIcon(): React.JSX.Element | null;
|
|
397
404
|
renderLabel(): React.JSX.Element | null;
|
|
405
|
+
getAccessibleHitSlop(): {
|
|
406
|
+
top: number;
|
|
407
|
+
bottom: number;
|
|
408
|
+
left: number;
|
|
409
|
+
right: number;
|
|
410
|
+
};
|
|
398
411
|
render(): React.JSX.Element;
|
|
399
412
|
}
|
|
400
413
|
export { Button };
|
|
@@ -7,7 +7,7 @@ import TouchableOpacity from "../touchableOpacity";
|
|
|
7
7
|
import Text from "../text";
|
|
8
8
|
import Icon from "../icon";
|
|
9
9
|
import { ButtonSize, ButtonAnimationDirection, ButtonProps, DEFAULT_PROPS } from "./types";
|
|
10
|
-
import { PADDINGS, HORIZONTAL_PADDINGS, MIN_WIDTH, DEFAULT_SIZE } from "./ButtonConstants";
|
|
10
|
+
import { PADDINGS, HORIZONTAL_PADDINGS, MIN_WIDTH, DEFAULT_SIZE, SIZE_TO_VERTICAL_HITSLOP } from "./ButtonConstants";
|
|
11
11
|
export { ButtonSize, ButtonAnimationDirection, ButtonProps };
|
|
12
12
|
class Button extends PureComponent {
|
|
13
13
|
static displayName = 'Button';
|
|
@@ -351,6 +351,20 @@ class Button extends PureComponent {
|
|
|
351
351
|
}
|
|
352
352
|
return null;
|
|
353
353
|
}
|
|
354
|
+
getAccessibleHitSlop() {
|
|
355
|
+
const containerStyle = this.getContainerSizeStyle();
|
|
356
|
+
const isWidthSet = containerStyle.width !== undefined || containerStyle.minWidth !== undefined;
|
|
357
|
+
const width = containerStyle.width || containerStyle.minWidth || 0;
|
|
358
|
+
const widthWithPadding = width + (containerStyle.paddingHorizontal || containerStyle.padding || 0) * 2;
|
|
359
|
+
const horizontalHitslop = isWidthSet ? Math.max(0, (48 - widthWithPadding) / 2) : 10;
|
|
360
|
+
const verticalHitslop = (containerStyle.height ? Math.max(0, 48 - containerStyle.height) : SIZE_TO_VERTICAL_HITSLOP[this.props.size || DEFAULT_SIZE]) / 2;
|
|
361
|
+
return {
|
|
362
|
+
top: verticalHitslop,
|
|
363
|
+
bottom: verticalHitslop,
|
|
364
|
+
left: horizontalHitslop,
|
|
365
|
+
right: horizontalHitslop
|
|
366
|
+
};
|
|
367
|
+
}
|
|
354
368
|
render() {
|
|
355
369
|
const {
|
|
356
370
|
onPress,
|
|
@@ -373,7 +387,7 @@ class Button extends PureComponent {
|
|
|
373
387
|
const borderRadiusStyle = this.getBorderRadiusStyle();
|
|
374
388
|
return <TouchableOpacity row centerV style={[this.styles.container, animateLayout && this.getAnimationDirectionStyle(), containerSizeStyle, this.isLink && this.styles.innerContainerLink, shadowStyle, margins, paddings, {
|
|
375
389
|
backgroundColor
|
|
376
|
-
}, borderRadiusStyle, outlineStyle, style]} activeOpacity={0.6} activeBackgroundColor={this.getActiveBackgroundColor()} onLayout={this.onLayout} onPress={onPress} disabled={disabled} testID={testID} {...others} ref={forwardedRef}>
|
|
390
|
+
}, borderRadiusStyle, outlineStyle, style]} activeOpacity={0.6} activeBackgroundColor={this.getActiveBackgroundColor()} onLayout={this.onLayout} onPress={onPress} disabled={disabled} testID={testID} {...others} ref={forwardedRef} hitSlop={this.getAccessibleHitSlop()}>
|
|
377
391
|
{this.props.children}
|
|
378
392
|
{this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
|
|
379
393
|
{this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}
|
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import _isEqual from "lodash/isEqual";
|
|
2
|
-
import { useState, useCallback, useRef } from 'react';
|
|
2
|
+
import { useState, useCallback, useRef, useEffect } from 'react';
|
|
3
|
+
import { SafeAreaInsetsManager } from 'uilib-native';
|
|
4
|
+
import { Constants } from "../../../commons/new";
|
|
3
5
|
export default function useHintLayout({
|
|
4
6
|
onBackgroundPress,
|
|
5
7
|
targetFrame
|
|
6
8
|
}) {
|
|
7
9
|
const [targetLayoutState, setTargetLayout] = useState(targetFrame);
|
|
8
|
-
const [targetLayoutInWindowState, setTargetLayoutInWindow] = useState(
|
|
10
|
+
const [targetLayoutInWindowState, setTargetLayoutInWindow] = useState();
|
|
9
11
|
const [hintMessageWidth, setHintMessageWidth] = useState();
|
|
10
12
|
const targetRef = useRef(null);
|
|
13
|
+
useEffect(() => {
|
|
14
|
+
if (targetFrame) {
|
|
15
|
+
if (!onBackgroundPress) {
|
|
16
|
+
setTargetLayoutInWindow(targetFrame);
|
|
17
|
+
} else {
|
|
18
|
+
SafeAreaInsetsManager.getSafeAreaInsets().then(insets => {
|
|
19
|
+
setTargetLayoutInWindow({
|
|
20
|
+
...targetFrame,
|
|
21
|
+
y: targetFrame.y + (insets?.top ?? 0) + Constants.getSafeAreaInsets().top
|
|
22
|
+
});
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
}, []);
|
|
11
27
|
const onTargetLayout = useCallback(({
|
|
12
28
|
nativeEvent: {
|
|
13
29
|
layout
|