react-native-ui-lib 7.38.0-snapshot.6290 → 7.38.0-snapshot.6291

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.38.0-snapshot.6290",
3
+ "version": "7.38.0-snapshot.6291",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -387,7 +387,7 @@ class Button extends PureComponent {
387
387
  const borderRadiusStyle = this.getBorderRadiusStyle();
388
388
  return <TouchableOpacity row centerV style={[this.styles.container, animateLayout && this.getAnimationDirectionStyle(), containerSizeStyle, this.isLink && this.styles.innerContainerLink, shadowStyle, margins, paddings, {
389
389
  backgroundColor
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()}>
390
+ }, borderRadiusStyle, outlineStyle, style]} activeOpacity={0.6} activeBackgroundColor={this.getActiveBackgroundColor()} onLayout={this.onLayout} onPress={onPress} disabled={disabled} testID={testID} hitSlop={this.getAccessibleHitSlop()} {...others} ref={forwardedRef}>
391
391
  {this.props.children}
392
392
  {this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
393
393
  {this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}
@@ -117,6 +117,7 @@ declare class Checkbox extends Component<CheckboxProps, CheckboxState> {
117
117
  getLabelStyle: () => {
118
118
  color: string;
119
119
  };
120
+ getAccessibleHitSlop(size: number): number;
120
121
  renderCheckbox(): React.JSX.Element;
121
122
  render(): React.JSX.Element;
122
123
  validate: () => void;
@@ -144,6 +144,9 @@ class Checkbox extends Component {
144
144
  color: this.props.disabled ? Colors.$textDisabled : this.state.showError ? Colors.$textDangerLight : Colors.$textDefault
145
145
  };
146
146
  };
147
+ getAccessibleHitSlop(size) {
148
+ return Math.max(0, (48 - size) / 2);
149
+ }
147
150
  renderCheckbox() {
148
151
  const {
149
152
  selectedIcon,
@@ -156,7 +159,7 @@ class Checkbox extends Component {
156
159
  } = this.props;
157
160
  return (
158
161
  //@ts-ignore
159
- <TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress}>
162
+ <TouchableOpacity {...this.getAccessibilityProps()} activeOpacity={1} testID={testID} {...others} style={[this.getBorderStyle(), style, !label && containerStyle]} onPress={this.onPress} hitSlop={this.getAccessibleHitSlop(this.props.size || DEFAULT_SIZE)}>
160
163
  {<Animated.View style={[this.styles.container, {
161
164
  opacity: this.animationStyle.opacity
162
165
  }, {
@@ -1,21 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
3
  import { DialogProps } from '../../incubator/dialog';
4
- import { ButtonProps } from '../button';
5
- type ColorPickerHeaderButtonProps = {
6
- /**
7
- * Ok (v) button color
8
- */
9
- doneButtonColor?: string;
10
- /**
11
- * Done button props
12
- */
13
- doneButtonProps?: Pick<ButtonProps, 'iconSource' | 'iconStyle'>;
14
- /**
15
- * Dismiss button props
16
- */
17
- dismissButtonProps?: Pick<ButtonProps, 'iconSource' | 'iconStyle'>;
18
- };
19
4
  export interface ColorPickerDialogProps extends DialogProps {
20
5
  /**
21
6
  * The initial color to pass the picker dialog
@@ -36,21 +21,15 @@ export interface ColorPickerDialogProps extends DialogProps {
36
21
  /**
37
22
  * Accessibility labels as an object of strings, ex. {addButton: 'add custom color using hex code', dismissButton: 'dismiss', doneButton: 'done', input: 'custom hex color code'}
38
23
  */
24
+ /**
25
+ * Ok (v) button color
26
+ */
27
+ doneButtonColor?: string;
39
28
  accessibilityLabels?: {
40
29
  dismissButton?: string;
41
30
  doneButton?: string;
42
31
  input?: string;
43
32
  };
44
- /**
45
- * @deprecated
46
- * Ok (v) button color
47
- * Pass doneButtonColor via colorPickerHeaderProps
48
- */
49
- doneButtonColor?: string;
50
- /**
51
- * Color Picker header button props, done and dismiss button customize props
52
- */
53
- colorPickerHeaderProps?: ColorPickerHeaderButtonProps;
54
33
  /**
55
34
  * Whether to use the new Slider implementation using Reanimated
56
35
  */
@@ -8,9 +8,6 @@ import { getColorValue, getValidColorString, getTextColor, BORDER_RADIUS } from
8
8
  import ColorPickerDialogHeader from "./ColorPickerDialogHeader";
9
9
  import ColorPickerPreview from "./ColorPickerPreview";
10
10
  import ColorPickerDialogSliders from "./ColorPickerDialogSliders";
11
-
12
- // TODO: deprecate doneButtonColor prop
13
-
14
11
  const KEYBOARD_HEIGHT = 216;
15
12
  const MODAL_PROPS = {
16
13
  supportedOrientations: ['portrait', 'landscape', 'landscape-left', 'landscape-right'] // iOS only
@@ -30,8 +27,7 @@ const ColorPickerDialog = props => {
30
27
  accessibilityLabels,
31
28
  doneButtonColor,
32
29
  previewInputStyle,
33
- migrate,
34
- colorPickerHeaderProps
30
+ migrate
35
31
  } = props;
36
32
  const [keyboardHeight, setKeyboardHeight] = useState(KEYBOARD_HEIGHT);
37
33
  const [color, setColor] = useState(Colors.getHSL(initialColor));
@@ -115,7 +111,7 @@ const ColorPickerDialog = props => {
115
111
  }, []);
116
112
  return <Dialog visible={visible} //TODO: pass all Dialog props instead
117
113
  width="100%" bottom centerH onDismiss={onDismiss} containerStyle={styles.dialog} testID={`${testID}.dialog`} modalProps={MODAL_PROPS} {...dialogProps}>
118
- <ColorPickerDialogHeader accessibilityLabels={accessibilityLabels} valid={valid} onDonePressed={onDonePressed} testID={testID} doneButtonColor={doneButtonColor} onDismiss={onDismiss} colorPickerHeaderProps={colorPickerHeaderProps} />
114
+ <ColorPickerDialogHeader accessibilityLabels={accessibilityLabels} valid={valid} onDonePressed={onDonePressed} testID={testID} doneButtonColor={doneButtonColor} onDismiss={onDismiss} />
119
115
  <ColorPickerPreview color={color} text={text} valid={valid} accessibilityLabels={accessibilityLabels} previewInputStyle={previewInputStyle} testID={testID} onFocus={onFocus} onChangeText={onChangeText} />
120
116
  <ColorPickerDialogSliders keyboardHeight={keyboardHeight} color={color} onSliderValueChange={updateColor} migrate={migrate} />
121
117
  </Dialog>;
@@ -1,6 +1,6 @@
1
1
  import React from 'react';
2
2
  import { ColorPickerDialogProps } from './ColorPickerDialog';
3
- type HeaderProps = Pick<ColorPickerDialogProps, 'doneButtonColor' | 'accessibilityLabels' | 'testID' | 'colorPickerHeaderProps'> & {
3
+ type HeaderProps = Pick<ColorPickerDialogProps, 'doneButtonColor' | 'accessibilityLabels' | 'testID'> & {
4
4
  valid: boolean;
5
5
  onDismiss: () => void;
6
6
  onDonePressed: () => void;
@@ -13,19 +13,13 @@ const ColorPickerDialogHeader = props => {
13
13
  testID,
14
14
  doneButtonColor,
15
15
  valid,
16
- onDonePressed,
17
- colorPickerHeaderProps
16
+ onDonePressed
18
17
  } = props;
19
- const {
20
- doneButtonProps,
21
- dismissButtonProps,
22
- doneButtonColor: doneButtonHeaderColorProp
23
- } = colorPickerHeaderProps || {};
24
18
  return <View row spread bg-$backgroundDefault paddingH-20 style={styles.header}>
25
19
  <Button link iconSource={Assets.icons.x} iconStyle={{
26
20
  tintColor: Colors.$iconDefault
27
- }} onPress={onDismiss} accessibilityLabel={_get(accessibilityLabels, 'dismissButton')} testID={`${testID}.dialog.cancel`} {...dismissButtonProps} />
28
- <Button color={doneButtonColor || doneButtonHeaderColorProp} disabled={!valid} link iconSource={Assets.icons.check} onPress={onDonePressed} accessibilityLabel={_get(accessibilityLabels, 'doneButton')} testID={`${testID}.dialog.done`} {...doneButtonProps} />
21
+ }} onPress={onDismiss} accessibilityLabel={_get(accessibilityLabels, 'dismissButton')} testID={`${testID}.dialog.cancel`} />
22
+ <Button color={doneButtonColor} disabled={!valid} link iconSource={Assets.icons.check} onPress={onDonePressed} accessibilityLabel={_get(accessibilityLabels, 'doneButton')} testID={`${testID}.dialog.done`} />
29
23
  </View>;
30
24
  };
31
25
  export default ColorPickerDialogHeader;
@@ -1,7 +1,6 @@
1
1
  import React from 'react';
2
2
  import { StyleProp, ViewStyle } from 'react-native';
3
3
  import { ColorsModifiers } from '../../commons/new';
4
- import { ImageProps } from '../image';
5
4
  export interface ColorInfo {
6
5
  index?: number;
7
6
  tintColor?: string;
@@ -43,10 +42,6 @@ interface Props {
43
42
  * Color swatch size
44
43
  */
45
44
  size?: number;
46
- /**
47
- * Icon image source
48
- */
49
- selectedIconSource?: ImageProps['source'];
50
45
  }
51
46
  export type ColorSwatchProps = Props & ColorsModifiers;
52
47
  export declare const SWATCH_MARGIN = 12;
@@ -124,7 +124,6 @@ class ColorSwatch extends PureComponent {
124
124
  onPress,
125
125
  unavailable,
126
126
  size = DEFAULT_SIZE,
127
- selectedIconSource,
128
127
  ...others
129
128
  } = this.props;
130
129
  const {
@@ -145,7 +144,7 @@ class ColorSwatch extends PureComponent {
145
144
  {Colors.isTransparent(this.color) && <Image source={transparentImage} style={this.styles.transparentImage} resizeMode={'cover'} />}
146
145
  {unavailable ? <View style={[this.styles.unavailable, {
147
146
  backgroundColor: tintColor
148
- }]} /> : <Animated.Image source={selectedIconSource || Assets.icons.check} style={{
147
+ }]} /> : <Animated.Image source={Assets.icons.check} style={{
149
148
  tintColor,
150
149
  opacity: isSelected,
151
150
  transform: [{
@@ -1,29 +1,13 @@
1
1
  import _isEqual from "lodash/isEqual";
2
- import { useState, useCallback, useRef, useEffect } from 'react';
3
- import { SafeAreaInsetsManager } from 'uilib-native';
4
- import { Constants } from "../../../commons/new";
2
+ import { useState, useCallback, useRef } from 'react';
5
3
  export default function useHintLayout({
6
4
  onBackgroundPress,
7
5
  targetFrame
8
6
  }) {
9
7
  const [targetLayoutState, setTargetLayout] = useState(targetFrame);
10
- const [targetLayoutInWindowState, setTargetLayoutInWindow] = useState();
8
+ const [targetLayoutInWindowState, setTargetLayoutInWindow] = useState(targetFrame);
11
9
  const [hintMessageWidth, setHintMessageWidth] = useState();
12
10
  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
- }, []);
27
11
  const onTargetLayout = useCallback(({
28
12
  nativeEvent: {
29
13
  layout
@@ -179,6 +179,13 @@ class RadioButton extends PureComponent {
179
179
  }]} />
180
180
  </View>;
181
181
  }
182
+ getAccessibleHitSlop(size) {
183
+ const verticalPadding = Math.max(0, (48 - size) / 2);
184
+ return {
185
+ top: verticalPadding,
186
+ bottom: verticalPadding
187
+ };
188
+ }
182
189
  render() {
183
190
  const {
184
191
  onPress,
@@ -190,7 +197,7 @@ class RadioButton extends PureComponent {
190
197
  const Container = onPress || onValueChange ? TouchableOpacity : View;
191
198
  return (
192
199
  // @ts-ignore
193
- <Container row centerV activeOpacity={1} {...others} style={containerStyle} onPress={this.onPress} {...this.getAccessibilityProps()}>
200
+ <Container row centerV activeOpacity={1} {...others} style={containerStyle} onPress={this.onPress} {...this.getAccessibilityProps()} hitSlop={this.getAccessibleHitSlop(this.props.size || DEFAULT_SIZE)}>
194
201
  {!contentOnLeft && this.renderButton()}
195
202
  {this.props.iconOnRight ? this.renderLabel() : this.renderIcon()}
196
203
  {this.props.iconOnRight ? this.renderIcon() : this.renderLabel()}