react-native-ui-lib 7.38.1-snapshot.6335 → 7.38.1-snapshot.6339

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/.eslintrc.js CHANGED
@@ -8,6 +8,13 @@ module.exports = {
8
8
  'no-undef': 'off',
9
9
  /* Other Rules */
10
10
  'no-unused-expressions': 'off',
11
+ 'no-restricted-syntax': [
12
+ 'error',
13
+ {
14
+ selector: `CallExpression[callee.object.name='console'][callee.property.name='error']`,
15
+ message: 'Using console.error is not allowed as it is sent to Sentry, please use LogService.error instead'
16
+ }
17
+ ],
11
18
  'arrow-parens': 'off',
12
19
  // TODO: remove after migration of legacy lifecycle methods
13
20
  camelcase: 'off',
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "react-native-ui-lib",
3
- "version": "7.38.1-snapshot.6335",
3
+ "version": "7.38.1-snapshot.6339",
4
4
  "main": "src/index.js",
5
5
  "types": "src/index.d.ts",
6
6
  "author": "Ethan Sharabi <ethan.shar@gmail.com>",
@@ -15,6 +15,7 @@ import { BlurViewPackage } from "../../optionalDependencies";
15
15
  import Assets from "../../assets";
16
16
  import CardContext from "./CardContext";
17
17
  import * as CardPresenter from "./CardPresenter";
18
+ import { LogService } from "../../services";
18
19
  const BlurView = BlurViewPackage?.BlurView;
19
20
  const DEFAULT_BORDER_RADIUS = BorderRadiuses.br40;
20
21
  const DEFAULT_SELECTION_PROPS = {
@@ -47,7 +48,8 @@ class Card extends PureComponent {
47
48
  };
48
49
  this.styles = createStyles(this.props);
49
50
  if (props.enableBlur && !BlurView) {
50
- console.error(`RNUILib Card's "enableBlur" prop requires installing "@react-native-community/blur" dependency`);
51
+ // eslint-disable-next-line max-len
52
+ LogService.error(`RNUILib Card's "enableBlur" prop requires installing "@react-native-community/blur" dependency`);
51
53
  }
52
54
  }
53
55
  componentDidUpdate(prevProps) {
@@ -7,6 +7,7 @@ import { Colors, Typography } from "../../style";
7
7
  import TouchableOpacity from "../touchableOpacity";
8
8
  import View from "../view";
9
9
  import { Constants, asBaseComponent } from "../../commons/new";
10
+ import { LogService } from "../../services";
10
11
  import { ConnectionStatusBarProps, DEFAULT_PROPS } from "./types";
11
12
  export { ConnectionStatusBarProps };
12
13
 
@@ -36,7 +37,8 @@ class ConnectionStatusBar extends PureComponent {
36
37
  if (NetInfo) {
37
38
  this.getInitialConnectionState();
38
39
  } else {
39
- console.error(`RNUILib ConnectionStatusBar component requires installing "@react-native-community/netinfo" dependency`);
40
+ // eslint-disable-next-line max-len
41
+ LogService.error(`RNUILib ConnectionStatusBar component requires installing "@react-native-community/netinfo" dependency`);
40
42
  }
41
43
  }
42
44
  generateStyles() {
@@ -11,6 +11,7 @@ import Button from "../button";
11
11
  import ExpandableOverlay from "../../incubator/expandableOverlay";
12
12
  import useOldApi from "./useOldApi";
13
13
  import { isSameDate, isSameHourAndMinute } from "../../utils/dateUtils";
14
+ import { LogService } from "../../services";
14
15
  /*eslint-disable*/
15
16
  /**
16
17
  * @description: Date and Time Picker Component that wraps RNDateTimePicker for date and time modes.
@@ -64,7 +65,7 @@ const DateTimePicker = forwardRef((props, ref) => {
64
65
  useEffect(() => {
65
66
  if (!RNDateTimePicker) {
66
67
  // eslint-disable-next-line max-len
67
- console.error(`RNUILib DateTimePicker component requires installing "@react-native-community/datetimepicker" dependency`);
68
+ LogService.error(`RNUILib DateTimePicker component requires installing "@react-native-community/datetimepicker" dependency`);
68
69
  }
69
70
  }, []);
70
71
  useDidUpdate(() => {
@@ -1,6 +1,7 @@
1
1
  // TODO: delete whole file in v8
2
2
  import { useEffect } from 'react';
3
3
  import { MomentPackage as moment } from "../../optionalDependencies";
4
+ import { LogService } from "../../services";
4
5
 
5
6
  // This file will be deleted in the next major version,
6
7
  // duplicating these here will make this less complicated
@@ -15,7 +16,8 @@ const useOldApi = props => {
15
16
  } = props;
16
17
  useEffect(() => {
17
18
  if (!moment && (dateFormat || timeFormat)) {
18
- console.error(`RNUILib DateTimePicker component with date/time format requires installing "moment" dependency`);
19
+ // eslint-disable-next-line max-len
20
+ LogService.error(`RNUILib DateTimePicker component with date/time format requires installing "moment" dependency`);
19
21
  }
20
22
  }, [dateFormat, timeFormat]);
21
23
  const getStringValue = (value, mode) => {
@@ -6,6 +6,7 @@ import { BlurViewPackage } from "../../optionalDependencies";
6
6
  import { Constants, asBaseComponent } from "../../commons/new";
7
7
  import TopBar, { ModalTopBarProps } from "./TopBar";
8
8
  import View from "../../components/view";
9
+ import { LogService } from "../../services";
9
10
  const BlurView = BlurViewPackage?.BlurView;
10
11
  export { ModalTopBarProps };
11
12
  /**
@@ -20,7 +21,8 @@ class Modal extends Component {
20
21
  constructor(props) {
21
22
  super(props);
22
23
  if (props.enableModalBlur && !BlurView) {
23
- console.error(`RNUILib Modal's "enableModalBlur" prop requires installing "@react-native-community/blur" dependency`);
24
+ // eslint-disable-next-line max-len
25
+ LogService.error(`RNUILib Modal's "enableModalBlur" prop requires installing "@react-native-community/blur" dependency`);
24
26
  }
25
27
  }
26
28
  renderTouchableOverlay() {
@@ -6,6 +6,7 @@ const {
6
6
  Svg,
7
7
  Path
8
8
  } = SvgPackage;
9
+ import { LogService } from "../../services";
9
10
  const DEFAULT_DIAMETER = 144;
10
11
  const PieChart = props => {
11
12
  const {
@@ -14,7 +15,7 @@ const PieChart = props => {
14
15
  ...others
15
16
  } = props;
16
17
  if (!Svg || !Path) {
17
- console.error(`RNUILib PieChart requires installing "@react-native-svg" dependency`);
18
+ LogService.error(`RNUILib PieChart requires installing "@react-native-svg" dependency`);
18
19
  return null;
19
20
  }
20
21
  const renderPieSegments = () => {
@@ -9,6 +9,7 @@ import { BorderRadiuses, Colors, Dividers, Spacings } from "../../style";
9
9
  import { createShimmerPlaceholder, LinearGradientPackage } from "../../optionalDependencies";
10
10
  import View from "../view";
11
11
  import { Constants } from "../../commons/new";
12
+ import { LogService } from "../../services";
12
13
  const LinearGradient = LinearGradientPackage?.default;
13
14
  let ShimmerPlaceholder;
14
15
  const ANIMATION_DURATION = 400;
@@ -62,9 +63,9 @@ class SkeletonView extends Component {
62
63
  opacity: new Animated.Value(0)
63
64
  };
64
65
  if (_isUndefined(LinearGradientPackage?.default)) {
65
- console.error(`RNUILib SkeletonView's requires installing "react-native-linear-gradient" dependency`);
66
+ LogService.error(`RNUILib SkeletonView's requires installing "react-native-linear-gradient" dependency`);
66
67
  } else if (_isUndefined(createShimmerPlaceholder)) {
67
- console.error(`RNUILib SkeletonView's requires installing "react-native-shimmer-placeholder" dependency`);
68
+ LogService.error(`RNUILib SkeletonView's requires installing "react-native-shimmer-placeholder" dependency`);
68
69
  } else if (ShimmerPlaceholder === undefined) {
69
70
  ShimmerPlaceholder = createShimmerPlaceholder(LinearGradient);
70
71
  }
@@ -1,6 +1,7 @@
1
1
  import React from 'react';
2
2
  import { isSvg, isSvgUri } from "../../utils/imageUtils";
3
3
  import { SvgPackage, SvgCssUri } from "../../optionalDependencies";
4
+ import { LogService } from "../../services";
4
5
  const SvgXml = SvgPackage?.SvgXml;
5
6
  // const SvgProps = SvgPackage?.SvgProps; TODO: not sure how (or if) we can use their props
6
7
 
@@ -14,7 +15,7 @@ function SvgImage(props) {
14
15
  } = props;
15
16
  if (!SvgXml) {
16
17
  // eslint-disable-next-line max-len
17
- console.error(`RNUILib Image "svg" prop requires installing "react-native-svg" and "react-native-svg-transformer" dependencies`);
18
+ LogService.error(`RNUILib Image "svg" prop requires installing "react-native-svg" and "react-native-svg-transformer" dependencies`);
18
19
  return null;
19
20
  }
20
21
  if (isSvgUri(data)) {
@@ -1,4 +1,5 @@
1
1
  import { interpolate } from 'react-native-reanimated';
2
+ import { LogService } from "../../services";
2
3
  export function getOffsetForValue(value, span, minimumValue = 0, maximumValue = 1) {
3
4
  const range = maximumValue - minimumValue;
4
5
  const relativeValue = minimumValue - value;
@@ -43,15 +44,21 @@ export function validateValues(props) {
43
44
  initialMaximumValue
44
45
  } = props;
45
46
  if (minimumValue > maximumValue || useRange && initialMinimumValue && initialMaximumValue && initialMinimumValue > initialMaximumValue) {
46
- console.error('Your passed values are invalid. Please check if minimum values are not higher than maximum values');
47
+ LogService.forwardError({
48
+ message: 'Your passed values are invalid. Please check if minimum values are not higher than maximum values'
49
+ });
47
50
  }
48
51
  if (value !== undefined && minimumValue && maximumValue && !inRange(value, minimumValue, maximumValue)) {
49
- console.error(`Your passed value (${value}) is invalid.
50
- Please check that it is in range of the minimum (${minimumValue}) and maximum (${maximumValue}) values`);
52
+ LogService.forwardError({
53
+ message: `Your passed value (${value}) is invalid.
54
+ Please check that it is in range of the minimum (${minimumValue}) and maximum (${maximumValue}) values`
55
+ });
51
56
  }
52
57
  if (useRange && initialMinimumValue && initialMaximumValue) {
53
58
  if (!inRange(initialMinimumValue, minimumValue, maximumValue) || !inRange(initialMaximumValue, minimumValue, maximumValue)) {
54
- console.error('Your passed values are invalid. Please check that they are in range of the minimum and maximum values');
59
+ LogService.forwardError({
60
+ message: 'Your passed values are invalid. Please check that they are in range of the minimum and maximum values'
61
+ });
55
62
  }
56
63
  }
57
64
  }
@@ -1,4 +1,5 @@
1
1
  import { HapticFeedbackPackage } from "../optionalDependencies";
2
+ import { LogService } from "./";
2
3
  const options = {
3
4
  enableVibrateFallback: false,
4
5
  ignoreAndroidSystemSettings: false
@@ -17,7 +18,7 @@ function triggerHaptic(hapticType, componentName) {
17
18
  if (HapticFeedbackPackage) {
18
19
  HapticFeedbackPackage.trigger(hapticType, options);
19
20
  } else {
20
- console.error(`RNUILib ${componentName}'s requires installing "react-native-haptic-feedback" dependency`);
21
+ LogService.error(`RNUILib ${componentName}'s requires installing "react-native-haptic-feedback" dependency`);
21
22
  }
22
23
  }
23
24
  export default {
@@ -1,12 +1,15 @@
1
1
  interface BILogger {
2
2
  log: (event: any) => void;
3
3
  }
4
- declare class LogService {
4
+ declare class LogService<ErrorInfo extends {
5
+ message: string;
6
+ }> {
5
7
  private biLogger;
6
8
  injectBILogger: (biLogger: BILogger) => void;
7
9
  logBI: (event: any) => void;
8
10
  warn: (message?: any, ...optionalParams: any[]) => void;
9
11
  error: (message?: any, ...optionalParams: any[]) => void;
12
+ forwardError: (errorInfo: ErrorInfo) => void;
10
13
  deprecationWarn: ({ component, oldProp, newProp }: {
11
14
  component: string;
12
15
  oldProp: string;
@@ -26,5 +29,7 @@ declare class LogService {
26
29
  newComponent: string;
27
30
  }) => void;
28
31
  }
29
- declare const _default: LogService;
32
+ declare const _default: LogService<{
33
+ message: string;
34
+ }>;
30
35
  export default _default;
@@ -12,9 +12,14 @@ class LogService {
12
12
  };
13
13
  error = (message, ...optionalParams) => {
14
14
  if (__DEV__) {
15
+ // eslint-disable-next-line no-restricted-syntax
15
16
  console.error(message, ...optionalParams);
16
17
  }
17
18
  };
19
+ forwardError = errorInfo => {
20
+ // eslint-disable-next-line no-restricted-syntax
21
+ console.error(errorInfo.message);
22
+ };
18
23
  deprecationWarn = ({
19
24
  component,
20
25
  oldProp,