@shoutem/ui 5.2.3 → 5.3.0

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.
@@ -0,0 +1,55 @@
1
+ import React from 'react';
2
+ import renderer from 'react-test-renderer';
3
+ import { View } from '../components/View';
4
+
5
+ test('View renders correctly', () => {
6
+ const tree = renderer.create(
7
+ <View style={{ height: 40, width: 40, backgroundColor: 'red' }} />,
8
+ ).toJSON();
9
+
10
+ expect(tree).toMatchSnapshot();
11
+ });
12
+
13
+ test('View renders children vertically with vertical styleName', () => {
14
+ const tree = renderer.create(
15
+ <View styleName="vertical">
16
+ <View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
17
+ <View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
18
+ </View>
19
+ );
20
+ });
21
+
22
+ test('View centers children horizontally with h-center styleName', () => {
23
+ const tree = renderer.create(
24
+ <View style={{ width: 100 }} styleName="vertical h-center">
25
+ <View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
26
+ <View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
27
+ </View>
28
+ );
29
+ });
30
+
31
+ test('View renders children horizontally with horizontal styleName', () => {
32
+ const tree = renderer.create(
33
+ <View styleName="horizontal">
34
+ <View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
35
+ <View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
36
+ </View>
37
+ );
38
+ });
39
+
40
+ test('View centers children vertically with v-center styleName', () => {
41
+ const tree = renderer.create(
42
+ <View style={{ height: 100 }} styleName="horizontal v-center">
43
+ <View style={{ height: 40, width: 40, backgroundColor: 'red' }} />
44
+ <View style={{ height: 40, width: 40, backgroundColor: 'green' }} />
45
+ </View>
46
+ );
47
+ });
48
+
49
+ test('View fills parent with fill-parent styleName', () => {
50
+ const tree = renderer.create(
51
+ <View style={{ height: 40, width: 40 }}>
52
+ <View style={{ backgroundColor: 'red' }} styleName="fill-parent" />
53
+ </View>
54
+ );
55
+ });
@@ -0,0 +1,15 @@
1
+ // Jest Snapshot v1, https://goo.gl/fbAQLP
2
+
3
+ exports[`View renders correctly 1`] = `
4
+ <View
5
+ animationOptions={Object {}}
6
+ onLayout={[Function]}
7
+ style={
8
+ Object {
9
+ "backgroundColor": "red",
10
+ "height": 40,
11
+ "width": 40,
12
+ }
13
+ }
14
+ />
15
+ `;
package/const.js CHANGED
@@ -1,22 +1,30 @@
1
- const IPHONE_X_HOME_INDICATOR_PADDING = 34;
2
- const IPHONE_X_LONG_SIDE = 812;
3
- const IPHONE_X_NOTCH_PADDING = 30;
4
-
5
- const IPHONE_XR_LONG_SIDE = 896;
6
- const IPHONE_XR_NOTCH_PADDING = 34;
7
-
8
- const IPHONE_12_LONG_SIDE = 844;
9
- const IPHONE_12_MAX_LONG_SIDE = 926;
10
-
11
- const NAVIGATION_HEADER_HEIGHT = 64;
12
-
13
- module.exports = {
1
+ import { Platform, StatusBar } from 'react-native';
2
+ import {
3
+ IPHONE_12_LONG_SIDE,
4
+ IPHONE_12_MAX_LONG_SIDE,
14
5
  IPHONE_X_HOME_INDICATOR_PADDING,
15
6
  IPHONE_X_LONG_SIDE,
16
7
  IPHONE_X_NOTCH_PADDING,
17
8
  IPHONE_XR_LONG_SIDE,
18
9
  IPHONE_XR_NOTCH_PADDING,
10
+ NAVIGATION_BAR_HEIGHT,
11
+ NAVIGATION_HEADER_HEIGHT,
12
+ } from './helpers';
13
+
14
+ const STATUS_BAR_OFFSET =
15
+ Platform.OS === 'android' ? -StatusBar.currentHeight : 0;
16
+
17
+ // TODO: Deprecate and remove exports from here
18
+ // Currently leaving for backwards compatibility
19
+ export {
19
20
  IPHONE_12_LONG_SIDE,
20
21
  IPHONE_12_MAX_LONG_SIDE,
22
+ IPHONE_X_HOME_INDICATOR_PADDING,
23
+ IPHONE_X_LONG_SIDE,
24
+ IPHONE_X_NOTCH_PADDING,
25
+ IPHONE_XR_LONG_SIDE,
26
+ IPHONE_XR_NOTCH_PADDING,
27
+ NAVIGATION_BAR_HEIGHT,
21
28
  NAVIGATION_HEADER_HEIGHT,
29
+ STATUS_BAR_OFFSET,
22
30
  };
@@ -1,16 +1,22 @@
1
- import { Dimensions, Platform } from 'react-native';
1
+ import { Dimensions, Platform, StatusBar } from 'react-native';
2
2
  import { hasNotch } from 'react-native-device-info';
3
3
  import _ from 'lodash';
4
- import {
5
- IPHONE_12_LONG_SIDE,
6
- IPHONE_12_MAX_LONG_SIDE,
7
- IPHONE_X_LONG_SIDE,
8
- IPHONE_XR_LONG_SIDE,
9
- } from '../const';
10
4
 
11
5
  const { OS, isPad, isTVOS } = Platform;
12
6
  const { width, height } = Dimensions.get('window');
13
7
 
8
+ export const IPHONE_X_HOME_INDICATOR_PADDING = 34;
9
+ export const IPHONE_X_LONG_SIDE = 812;
10
+ export const IPHONE_X_NOTCH_PADDING = 30;
11
+
12
+ export const IPHONE_XR_LONG_SIDE = 896;
13
+ export const IPHONE_XR_NOTCH_PADDING = 34;
14
+
15
+ export const IPHONE_12_LONG_SIDE = 844;
16
+ export const IPHONE_12_MAX_LONG_SIDE = 926;
17
+
18
+ export const NAVIGATION_HEADER_HEIGHT = 64;
19
+
14
20
  const xDimensionsMatch =
15
21
  height === IPHONE_X_LONG_SIDE || width === IPHONE_X_LONG_SIDE;
16
22
 
@@ -58,6 +64,13 @@ function select(settings) {
58
64
  return _.get(settings, 'default');
59
65
  }
60
66
 
67
+ export const NAVIGATION_BAR_HEIGHT = select({
68
+ iPhoneX: NAVIGATION_HEADER_HEIGHT + IPHONE_X_NOTCH_PADDING,
69
+ iPhoneXR: NAVIGATION_HEADER_HEIGHT + IPHONE_XR_NOTCH_PADDING,
70
+ notchedAndroid: NAVIGATION_HEADER_HEIGHT + StatusBar.currentHeight,
71
+ default: NAVIGATION_HEADER_HEIGHT,
72
+ });
73
+
61
74
  export const Device = {
62
75
  isIphoneX,
63
76
  isIphoneXR,
package/helpers/index.js CHANGED
@@ -1,4 +1,13 @@
1
- import { Device } from './device-selector';
2
- import Keyboard from './keyboard';
3
-
4
- export { Device, Keyboard };
1
+ export {
2
+ Device,
3
+ IPHONE_12_LONG_SIDE,
4
+ IPHONE_12_MAX_LONG_SIDE,
5
+ IPHONE_X_HOME_INDICATOR_PADDING,
6
+ IPHONE_X_LONG_SIDE,
7
+ IPHONE_X_NOTCH_PADDING,
8
+ IPHONE_XR_LONG_SIDE,
9
+ IPHONE_XR_NOTCH_PADDING,
10
+ NAVIGATION_BAR_HEIGHT,
11
+ NAVIGATION_HEADER_HEIGHT,
12
+ } from './device-selector';
13
+ export { calculateKeyboardOffset, default as Keyboard } from './keyboard';
@@ -1,5 +1,5 @@
1
1
  import { Platform, StatusBar } from 'react-native';
2
- import { NAVIGATION_BAR_HEIGHT } from '../theme';
2
+ import { NAVIGATION_BAR_HEIGHT } from './device-selector';
3
3
 
4
4
  export function calculateKeyboardOffset(extraOffset = 0) {
5
5
  const resolvedOffset = NAVIGATION_BAR_HEIGHT + extraOffset;
@@ -11,4 +11,8 @@ export function calculateKeyboardOffset(extraOffset = 0) {
11
11
  return StatusBar.currentHeight + resolvedOffset;
12
12
  }
13
13
 
14
+ // TODO: Deprecate and remove Keyboard.calculateKeyboardOffset
15
+ // Replace with direct function call. It's cleaner for any practical use of this
16
+ // because we will usually import Keyboard from react-native alongside this, so
17
+ // we're forced to rename imports.
14
18
  export default { calculateKeyboardOffset };
package/index.js CHANGED
@@ -1,12 +1,4 @@
1
1
  import { setDefaultThemeStyle } from './init';
2
- import getTheme, {
3
- calculateLineHeight,
4
- defaultThemeVariables,
5
- dimensionRelativeToIphone,
6
- resolveFontFamily,
7
- resolveFontStyle,
8
- resolveFontWeight,
9
- } from './theme';
10
2
 
11
3
  setDefaultThemeStyle();
12
4
 
@@ -15,12 +7,13 @@ export {
15
7
  calculateLineHeight,
16
8
  defaultThemeVariables,
17
9
  dimensionRelativeToIphone,
18
- getTheme,
10
+ default as getTheme,
19
11
  resolveFontFamily,
20
12
  resolveFontStyle,
21
13
  resolveFontWeight,
22
- };
14
+ } from './theme';
23
15
 
16
+ // Services
24
17
  export {
25
18
  createScopedResolver,
26
19
  resolveVariable,
@@ -76,8 +69,14 @@ export { TouchableOpacity } from './components/TouchableOpacity';
76
69
  export { Video } from './components/Video';
77
70
  export { View } from './components/View';
78
71
  export { YearRangePicker } from './components/YearRangePicker';
72
+
73
+ // Examples
79
74
  export { Examples } from './examples/components';
80
- export { Device, Keyboard } from './helpers';
75
+
76
+ // Helpers
77
+ export { calculateKeyboardOffset, Device, Keyboard } from './helpers';
78
+
79
+ // HTML
81
80
  export { Html } from './html';
82
81
  export { SimpleHtml } from './html';
83
82
 
@@ -89,5 +88,7 @@ export {
89
88
  IPHONE_XR_LONG_SIDE,
90
89
  IPHONE_XR_NOTCH_PADDING,
91
90
  nativeDependencies,
91
+ NAVIGATION_BAR_HEIGHT,
92
92
  NAVIGATION_HEADER_HEIGHT,
93
+ STATUS_BAR_OFFSET,
93
94
  } from './const';
package/package.json CHANGED
@@ -1,15 +1,15 @@
1
1
  {
2
2
  "name": "@shoutem/ui",
3
- "version": "5.2.3",
3
+ "version": "5.3.0",
4
4
  "description": "Styleable set of components for React Native applications",
5
5
  "scripts": {
6
6
  "lint": "eslint .",
7
7
  "lint-fix": "eslint . --fix",
8
8
  "postinstall": "node ./scripts/add-native-deps",
9
- "test": "mocha '_tests_/*.js' --require react-native-mock-render/mock --require @babel/register"
9
+ "test": "jest"
10
10
  },
11
11
  "dependencies": {
12
- "@react-native-community/datetimepicker": "3.5.2",
12
+ "@react-native-community/datetimepicker": "6.2.0",
13
13
  "@shoutem/animation": "~0.15.0",
14
14
  "@shoutem/eslint-config-react": "~1.0.6",
15
15
  "@shoutem/theme": "~0.13.0",
@@ -21,26 +21,26 @@
21
21
  "html-entities": "1.3.1",
22
22
  "htmlparser2": "3.10.1",
23
23
  "lodash": "4.17.21",
24
- "lottie-react-native": "5.0.1",
24
+ "lottie-react-native": "5.1.3",
25
25
  "prop-types": "15.8.1",
26
26
  "qs": "6.9.3",
27
- "react-native-device-info": "8.4.8",
27
+ "react-native-device-info": "9.0.2",
28
28
  "react-native-lightbox": "github:shoutem/react-native-lightbox#v0.7.2",
29
- "react-native-linear-gradient": "2.5.6",
29
+ "react-native-linear-gradient": "2.6.2",
30
30
  "react-native-modal": "11.7.0",
31
- "react-native-photo-view": "github:shoutem/react-native-photo-view#e7f0003",
31
+ "react-native-photo-view": "github:shoutem/react-native-photo-view#8f88667",
32
32
  "react-native-render-html": "4.2.5",
33
33
  "react-native-render-html-table-bridge": "0.6.0",
34
- "react-native-svg": "12.1.1",
35
- "react-native-svg-transformer": "0.14.3",
34
+ "react-native-svg": "12.3.0",
35
+ "react-native-svg-transformer": "1.0.0",
36
36
  "react-native-transformable-image": "github:shoutem/react-native-transformable-image#v0.0.20",
37
- "react-native-webview": "11.0.3",
38
- "react-native-youtube-iframe": "2.1.2",
37
+ "react-native-webview": "11.22.7",
38
+ "react-native-youtube-iframe": "2.2.2",
39
39
  "stream": "0.0.2",
40
40
  "tinycolor2": "1.4.1"
41
41
  },
42
42
  "peerDependencies": {
43
- "react": "^16.9.0",
43
+ "react": ">=16.9.0",
44
44
  "react-native": ">=0.61.5"
45
45
  },
46
46
  "devDependencies": {
@@ -49,8 +49,6 @@
49
49
  "@babel/plugin-proposal-decorators": "7.16.7",
50
50
  "@shoutem/eslint-config-react-native": "~1.0.2",
51
51
  "babel-eslint": "10.1.0",
52
- "chai": "4.2.0",
53
- "deep-freeze": "0.0.1",
54
52
  "eslint": "6.8.0",
55
53
  "eslint-plugin-import": "2.25.4",
56
54
  "eslint-plugin-jsx-a11y": "6.5.1",
@@ -59,18 +57,19 @@
59
57
  "eslint-plugin-react-hooks": "4.2.0",
60
58
  "eslint-plugin-react-native": "3.11.0",
61
59
  "eslint-plugin-simple-import-sort": "7.0.0",
60
+ "jest": "27.5.1",
62
61
  "metro-react-native-babel-preset": "0.66.2",
63
- "mocha": "7.1.2",
64
62
  "prettier": "1.19.1",
65
- "react-addons-test-utils": "15.6.2",
66
- "react-dom": "16.14.0",
67
- "react-native-mock-render": "0.1.9"
63
+ "react": "17.0.2",
64
+ "react-dom": "16.9.0",
65
+ "react-native": "0.68.2",
66
+ "react-test-renderer": "17.0.2"
68
67
  },
69
68
  "nativeDependencies": [
70
69
  "@react-native-community/datetimepicker",
70
+ "lottie-react-native",
71
71
  "react-native-device-info",
72
72
  "react-native-linear-gradient",
73
- "lottie-react-native",
74
73
  "react-native-photo-view",
75
74
  "react-native-svg",
76
75
  "react-native-webview"
@@ -115,5 +114,15 @@
115
114
  "jsxBracketSameLine": false,
116
115
  "singleQuote": true,
117
116
  "trailingComma": "all"
117
+ },
118
+ "jest": {
119
+ "preset": "react-native",
120
+ "testPathIgnorePatterns": [
121
+ "/node_modules/",
122
+ "examples/"
123
+ ],
124
+ "transformIgnorePatterns": [
125
+ "!/node_modules/@shoutem"
126
+ ]
118
127
  }
119
128
  }
package/theme.js CHANGED
@@ -11,22 +11,15 @@ import {
11
11
  IPHONE_X_HOME_INDICATOR_PADDING,
12
12
  IPHONE_X_NOTCH_PADDING,
13
13
  IPHONE_XR_NOTCH_PADDING,
14
+ NAVIGATION_BAR_HEIGHT,
14
15
  NAVIGATION_HEADER_HEIGHT,
16
+ STATUS_BAR_OFFSET,
15
17
  } from './const';
16
18
  import { Device } from './helpers';
17
19
  import { resolveVariable } from './services';
18
20
 
19
21
  const window = Dimensions.get('window');
20
22
 
21
- const STATUS_BAR_OFFSET =
22
- Platform.OS === 'android' ? -StatusBar.currentConfig : 0;
23
- export const NAVIGATION_BAR_HEIGHT = Device.select({
24
- iPhoneX: NAVIGATION_HEADER_HEIGHT + IPHONE_X_NOTCH_PADDING,
25
- iPhoneXR: NAVIGATION_HEADER_HEIGHT + IPHONE_XR_NOTCH_PADDING,
26
- notchedAndroid: NAVIGATION_HEADER_HEIGHT + StatusBar.currentHeight,
27
- default: NAVIGATION_HEADER_HEIGHT,
28
- });
29
-
30
23
  export const sizeVariants = [
31
24
  '',
32
25
  'left',