react-native-ui-lib 7.43.0-snapshot.7041 → 7.43.0-snapshot.7054

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": "react-native-ui-lib",
3
- "version": "7.43.0-snapshot.7041",
3
+ "version": "7.43.0-snapshot.7054",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -1,5 +1,4 @@
1
- import _get from "lodash/get";
2
- import React, { useCallback } from 'react';
1
+ import React, { useCallback, useMemo } from 'react';
3
2
  import { StyleSheet } from 'react-native';
4
3
  import Assets from "../../assets";
5
4
  import { asBaseComponent } from "../../commons/new";
@@ -57,8 +56,8 @@ const Chip = ({
57
56
  }, [badgeProps]);
58
57
  const renderOnDismiss = useCallback(() => {
59
58
  return <TouchableOpacity style={[getMargins('dismiss'), dismissContainerStyle]} onPress={onDismiss} hitSlop={{
60
- top: 10,
61
- bottom: 10,
59
+ top: 16,
60
+ bottom: 16,
62
61
  left: 10,
63
62
  right: 10
64
63
  }} testID={`${testID}.dismiss`}>
@@ -138,23 +137,47 @@ const Chip = ({
138
137
  }
139
138
  }
140
139
  }, [avatarProps, badgeProps, iconSource, rightIconSource, onDismiss]);
141
- const getContainerSize = useCallback(() => {
142
- const width = useSizeAsMinimum ? 'minWidth' : 'width';
143
- const height = useSizeAsMinimum ? 'minHeight' : 'height';
144
- return typeof size === 'object' ? {
145
- [width]: _get(size, 'width'),
146
- [height]: _get(size, 'height')
147
- } : {
148
- [width]: size,
149
- [height]: size
140
+ const chipSize = useMemo(() => {
141
+ const width = typeof size === 'object' ? size.width : size;
142
+ const height = typeof size === 'object' ? size.height : size;
143
+ return {
144
+ width,
145
+ height
150
146
  };
151
147
  }, [size]);
148
+ const containerSizeStyle = useMemo(() => {
149
+ const {
150
+ width,
151
+ height
152
+ } = chipSize;
153
+ return useSizeAsMinimum ? {
154
+ minWidth: width,
155
+ minHeight: height
156
+ } : {
157
+ width,
158
+ height
159
+ };
160
+ }, [chipSize]);
152
161
  const Container = onPress ? TouchableOpacity : View;
162
+ const hitSlop = useMemo(() => {
163
+ const {
164
+ width = 48,
165
+ height = 48
166
+ } = chipSize;
167
+ const verticalHitSlop = Math.max(0, (48 - height) / 2);
168
+ const horizontalHitSlop = Math.max(0, (48 - width) / 2);
169
+ return {
170
+ top: verticalHitSlop,
171
+ bottom: verticalHitSlop,
172
+ left: horizontalHitSlop,
173
+ right: horizontalHitSlop
174
+ };
175
+ }, [chipSize]);
153
176
  return <Container activeOpacity={1} onPress={onPress} style={[styles.container, {
154
177
  backgroundColor
155
178
  }, {
156
179
  borderRadius
157
- }, containerStyle, getContainerSize()]} testID={testID} {...others}>
180
+ }, containerStyle, containerSizeStyle]} testID={testID} hitSlop={hitSlop} {...others}>
158
181
  {avatarProps && renderAvatar()}
159
182
  {iconSource && renderIcon('left')}
160
183
  {leftElement}