@quintype/native-components 2.20.26-beta.1 → 2.20.27
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/CHANGELOG.md +4 -0
- package/README.md +1 -20
- package/bin-dev-scripts/standard-version-release.sh +10 -10
- package/jest-setup.js +5 -0
- package/package.json +14 -10
- package/src/components/References/index.js +2 -1
- package/src/components/Story/index.js +12 -30
- package/src/components/Story/styles.js +0 -3
- package/src/components/StoryImage/index.js +2 -1
- package/src/components/StorySlideshow/index.js +2 -1
- package/src/components/Table/index.js +2 -1
- package/src/components/YouTubePlayer/index.js +39 -1
- package/src/utils/colorUtils.js +1 -0
- package/src/utils/story.js +4 -34
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,10 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [2.20.27](https://github.com/quintype/native-components/compare/v2.20.26...v2.20.27) (2024-05-17)
|
|
6
|
+
|
|
7
|
+
### [2.20.26](https://github.com/quintype/native-components/compare/v2.20.25...v2.20.26) (2024-05-17)
|
|
8
|
+
|
|
5
9
|
### [2.20.25](https://github.com/quintype/native-components/compare/v2.20.24...v2.20.25) (2024-03-14)
|
|
6
10
|
|
|
7
11
|
|
package/README.md
CHANGED
|
@@ -4,26 +4,7 @@
|
|
|
4
4
|
|
|
5
5
|
`$ npm install @quintype/native-components --save`
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
### Publishing a version with beta tag:
|
|
10
|
-
1. Add, commit and push beta changes on a new branch.
|
|
11
|
-
2. Run `npm i --legacy-peer-deps` (Using **node@16.19.0**, **npm@8.19.3**)
|
|
12
|
-
3. Run `npm cache clean --force` in case the above command fails.
|
|
13
|
-
4. Create a tag by running `npm version 2.21.0-beta.0` (add **\`-beta.*iteration*\`** (where ***iteration*** can just be incremented (+1) for subsequent beta-versions on the same development branch)
|
|
14
|
-
5. Publish the tag by running `npm publish --tag beta`
|
|
15
|
-
6. Make sure to commit and push the new beta versioning changes.
|
|
16
|
-
|
|
17
|
-
### Installing a version with beta tag on host app:
|
|
18
|
-
npm install @quintype/native-components@beta
|
|
19
|
-
|
|
20
|
-
### Note:
|
|
21
|
-
- `prePublishOnly` script that was in use before is incompatible with recent node/npm versions. Hence `standard-version-release.sh` is not used.
|
|
22
|
-
- Revert `"version"` changes from `package.json` before creating PR (for merging to `master`).
|
|
23
|
-
- Access all versions [here](https://www.npmjs.com/package/@quintype/native-components?activeTab=versions).
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
## Linking
|
|
7
|
+
### Linking
|
|
27
8
|
|
|
28
9
|
This library has both js only as well as native components. Please check the instructions for the respective components for more details.
|
|
29
10
|
|
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
#!/bin/bash -e
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
3
|
+
npm install
|
|
4
|
+
git diff --quiet
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
BRANCH=$(git symbolic-ref --short HEAD)
|
|
7
7
|
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
8
|
+
if [ "$BRANCH" == 'master' ]
|
|
9
|
+
then
|
|
10
|
+
npx standard-version
|
|
11
|
+
else
|
|
12
|
+
npx standard-version --prerelease "$(git symbolic-ref --short HEAD | sed s:/:-:g )" --skip.changelog=true
|
|
13
|
+
fi
|
|
14
14
|
|
|
15
|
-
|
|
15
|
+
git push --follow-tags origin "$BRANCH"
|
package/jest-setup.js
CHANGED
|
@@ -2,6 +2,11 @@ jest.mock('@react-navigation/native', () => ({
|
|
|
2
2
|
useNavigation: () => jest.fn(),
|
|
3
3
|
}));
|
|
4
4
|
|
|
5
|
+
jest.mock('rn-fetch-blob', () => ({
|
|
6
|
+
DocumentDir: () => { },
|
|
7
|
+
polyfill: () => { },
|
|
8
|
+
}));
|
|
9
|
+
|
|
5
10
|
jest.mock('react-native-device-info', () => ({
|
|
6
11
|
DocumentDir: () => { },
|
|
7
12
|
polyfill: () => { },
|
package/package.json
CHANGED
|
@@ -1,12 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@quintype/native-components",
|
|
3
|
-
"version": "2.20.
|
|
3
|
+
"version": "2.20.27",
|
|
4
4
|
"description": "",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"scripts": {
|
|
7
7
|
"test": "jest --detectOpenHandles",
|
|
8
8
|
"lint": "npx eslint './src/**/*.{js,jsx}'",
|
|
9
|
-
"lint:ci": "npx eslint $(git diff --pretty='' --diff-filter=d --name-only origin/master..HEAD -- '*.js' '*.jsx') ./start.js"
|
|
9
|
+
"lint:ci": "npx eslint $(git diff --pretty='' --diff-filter=d --name-only origin/master..HEAD -- '*.js' '*.jsx') ./start.js",
|
|
10
|
+
"prepublishOnly": "./bin-dev-scripts/standard-version-release.sh"
|
|
10
11
|
},
|
|
11
12
|
"dependencies": {
|
|
12
13
|
"atob": "^2.1.2",
|
|
@@ -19,26 +20,27 @@
|
|
|
19
20
|
"react-native-fast-image": "8.3.2",
|
|
20
21
|
"react-native-image-pan-zoom": "^2.1.12",
|
|
21
22
|
"react-native-lightbox": "0.8.1",
|
|
23
|
+
"react-native-pdf": "^5.1.4",
|
|
22
24
|
"react-native-render-html": "^4.2.3",
|
|
23
|
-
"react-native-share": "^8.1.0"
|
|
25
|
+
"react-native-share": "^8.1.0",
|
|
26
|
+
"rn-fetch-blob": "^0.10.16"
|
|
24
27
|
},
|
|
25
28
|
"peerDependencies": {
|
|
26
|
-
"@react-navigation/native": ">=
|
|
29
|
+
"@react-navigation/native": ">=5.7.3",
|
|
27
30
|
"lodash": ">=4.17.20",
|
|
28
31
|
"react": ">=17.0.2",
|
|
29
32
|
"react-native": ">=0.67.5",
|
|
30
33
|
"react-native-fast-image": ">=8.3.2",
|
|
31
|
-
"react-native-pdf": ">=6.
|
|
32
|
-
"react-native-blob-util": ">=6.7.4",
|
|
34
|
+
"react-native-pdf": ">=6.2.0",
|
|
33
35
|
"react-native-webview": ">=11.0.0",
|
|
34
36
|
"rn-fetch-blob": ">=0.12.0",
|
|
35
|
-
"react-native-vector-icons": "^10.0.0"
|
|
36
|
-
"react-native-linear-gradient": "^2.8.3"
|
|
37
|
+
"react-native-vector-icons": "^10.0.0"
|
|
37
38
|
},
|
|
38
39
|
"devDependencies": {
|
|
39
40
|
"@babel/core": "^7.11.1",
|
|
40
41
|
"@babel/runtime": "^7.11.2",
|
|
41
42
|
"@react-native-community/eslint-config": "^2.0.0",
|
|
43
|
+
"@react-navigation/native": "^5.7.1",
|
|
42
44
|
"@testing-library/jest-native": "^3.4.3",
|
|
43
45
|
"@testing-library/react-native": "^7.1.0",
|
|
44
46
|
"babel-jest": "^26.3.0",
|
|
@@ -51,9 +53,10 @@
|
|
|
51
53
|
"husky": "^4.2.5",
|
|
52
54
|
"jest": "^26.4.0",
|
|
53
55
|
"metro-react-native-babel-preset": "^0.62.0",
|
|
54
|
-
"react": "
|
|
55
|
-
"react-native": "0.
|
|
56
|
+
"react": "17.0.2",
|
|
57
|
+
"react-native": "0.67.4",
|
|
56
58
|
"react-native-device-info": "^5.6.5",
|
|
59
|
+
"react-native-gesture-handler": "^1.9.0",
|
|
57
60
|
"react-native-svg": "^12.3.0",
|
|
58
61
|
"react-navigation-hooks": "^1.1.0",
|
|
59
62
|
"react-test-renderer": "16.13.1"
|
|
@@ -62,6 +65,7 @@
|
|
|
62
65
|
"preset": "react-native",
|
|
63
66
|
"setupFilesAfterEnv": [
|
|
64
67
|
"./jest-setup.js",
|
|
68
|
+
"./node_modules/react-native-gesture-handler/jestSetup.js",
|
|
65
69
|
"@testing-library/jest-native/extend-expect"
|
|
66
70
|
],
|
|
67
71
|
"moduleNameMapper": {
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { get } from 'lodash';
|
|
2
2
|
import PropTypes from 'prop-types';
|
|
3
3
|
import React, { useContext } from 'react';
|
|
4
|
-
import { Linking, View
|
|
4
|
+
import { Linking, View } from 'react-native';
|
|
5
|
+
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
5
6
|
import { AppTheme } from '../../utils';
|
|
6
7
|
import { Text } from '../Text';
|
|
7
8
|
import { styles } from './styles';
|
|
@@ -14,8 +14,6 @@ import { ClockIcon } from '../../Icons/ClockIcon';
|
|
|
14
14
|
import { storyStyles } from './styles';
|
|
15
15
|
import { isStoryFree, mutateDataBeforeAccess, getFirstVideoElement } from '../../utils/story';
|
|
16
16
|
import { isMiddleIndexOfArray } from '../../utils/arrayUtils';
|
|
17
|
-
import LinearGradient from "react-native-linear-gradient";
|
|
18
|
-
import { hexToRgb } from '@quintype/native-components/src/utils/colorUtils';
|
|
19
17
|
|
|
20
18
|
const getLiveBlogTimeStamp = (card, DATE_FORMAT, share, styles, locale) => {
|
|
21
19
|
const slug = `?cardId=${card.id}`;
|
|
@@ -79,7 +77,7 @@ const getStoryCards = (
|
|
|
79
77
|
getAd,
|
|
80
78
|
locale,
|
|
81
79
|
) => cards.map((card, index, source) => (
|
|
82
|
-
<View key={card?.id}>
|
|
80
|
+
<View key={card?.id}>
|
|
83
81
|
{isLiveBlog
|
|
84
82
|
&& getLiveBlogTimeStamp(card, DATE_FORMAT, share, styles, locale)}
|
|
85
83
|
|
|
@@ -109,6 +107,7 @@ const getStoryCards = (
|
|
|
109
107
|
{/* ^ In the case of a story having just 1 card,
|
|
110
108
|
requesting mid-content-Ad if there are > 1 story-elements in that card
|
|
111
109
|
(> 2 story-elements in case of video story since the 1st story-element gets rendered in header). */}
|
|
110
|
+
|
|
112
111
|
<StoryContent
|
|
113
112
|
testID={contentTestID}
|
|
114
113
|
key={storyElement?.id}
|
|
@@ -145,15 +144,15 @@ export const Story = ({
|
|
|
145
144
|
storyHasAccess = 'loading',
|
|
146
145
|
currentLayout,
|
|
147
146
|
getAd,
|
|
148
|
-
showWall,
|
|
149
|
-
userObjectLength,
|
|
150
|
-
numberOfVisibleStoryCard,
|
|
151
|
-
linkedStories
|
|
152
147
|
}) => {
|
|
153
148
|
const { theme } = useContext(AppTheme);
|
|
154
|
-
const { COLORS, FONT_SIZE, locale
|
|
149
|
+
const { COLORS, FONT_SIZE, locale } = theme;
|
|
155
150
|
const styles = storyStyles(COLORS, FONT_SIZE);
|
|
156
|
-
|
|
151
|
+
|
|
152
|
+
const {
|
|
153
|
+
cards = [],
|
|
154
|
+
'linked-stories': linkedStories,
|
|
155
|
+
} = mutateDataBeforeAccess(story, storyHasAccess);
|
|
157
156
|
|
|
158
157
|
const firstVideoElement = story['story-template'] === STORY_TYPES.VIDEO_STORY
|
|
159
158
|
? getFirstVideoElement(cards)
|
|
@@ -182,21 +181,12 @@ export const Story = ({
|
|
|
182
181
|
return null;
|
|
183
182
|
};
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
colors={[
|
|
189
|
-
DARK_MODE ? hexToRgb("#252525", 0) : hexToRgb(COLORS.BRAND_WHITE, 0),
|
|
190
|
-
DARK_MODE ? hexToRgb("#252525", 1) : hexToRgb(COLORS.BRAND_WHITE, 1),
|
|
191
|
-
]}
|
|
192
|
-
style={{ height: 200}}
|
|
193
|
-
></LinearGradient>
|
|
194
|
-
);
|
|
195
|
-
};
|
|
184
|
+
useEffect(() => {
|
|
185
|
+
checkStoryAccess(story);
|
|
186
|
+
}, []);
|
|
196
187
|
|
|
197
188
|
return (
|
|
198
189
|
<>
|
|
199
|
-
<View>
|
|
200
190
|
<StoryHeader
|
|
201
191
|
firstVideoElement={firstVideoElement}
|
|
202
192
|
testID={headerTestID}
|
|
@@ -206,8 +196,6 @@ export const Story = ({
|
|
|
206
196
|
onSectionPress={onSectionPress}
|
|
207
197
|
/>
|
|
208
198
|
|
|
209
|
-
|
|
210
|
-
|
|
211
199
|
{getAd()}
|
|
212
200
|
|
|
213
201
|
{getStoryCards(
|
|
@@ -231,13 +219,7 @@ export const Story = ({
|
|
|
231
219
|
locale,
|
|
232
220
|
)}
|
|
233
221
|
|
|
234
|
-
{(
|
|
235
|
-
<GradientView />
|
|
236
|
-
</View>
|
|
237
|
-
}
|
|
238
|
-
</View>
|
|
239
|
-
{accessComponent(story, storyHasAccess, showWall)}
|
|
240
|
-
|
|
222
|
+
{accessComponent(story, storyHasAccess)}
|
|
241
223
|
|
|
242
224
|
{shouldShowComments()}
|
|
243
225
|
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext } from 'react';
|
|
3
|
-
import { View
|
|
3
|
+
import { View } from 'react-native';
|
|
4
|
+
import { TouchableOpacity } from 'react-native-gesture-handler';
|
|
4
5
|
import { ShareIcon } from '../../Icons/ShareIcon';
|
|
5
6
|
import { AppTheme, getScreenPercentageWidth, stripHTML } from '../../utils';
|
|
6
7
|
import { Text } from '../index';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import PropTypes from 'prop-types';
|
|
2
2
|
import React, { useContext, useRef, useState } from 'react';
|
|
3
|
-
import { TouchableOpacity, View
|
|
3
|
+
import { TouchableOpacity, View } from 'react-native';
|
|
4
|
+
import { FlatList } from 'react-native-gesture-handler';
|
|
4
5
|
import Icon from 'react-native-vector-icons/AntDesign';
|
|
5
6
|
import { AppTheme } from '../../utils';
|
|
6
7
|
import { SlideshowStoryCard } from '../SlideshowStoryCard';
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React, { useContext } from 'react';
|
|
2
|
-
import { View
|
|
2
|
+
import { View } from 'react-native';
|
|
3
3
|
import get from 'lodash/get';
|
|
4
|
+
import { ScrollView } from 'react-native-gesture-handler';
|
|
4
5
|
import { formatData } from '../../utils/tableUtils';
|
|
5
6
|
import { tableStyles } from './styles';
|
|
6
7
|
import { Text } from '../index';
|
|
@@ -10,12 +10,50 @@ export const YouTubePlayer = ({ card = {} }) => {
|
|
|
10
10
|
const windowWidth = Dimensions.get("window").width;
|
|
11
11
|
const styles = webviewStyles(windowWidth);
|
|
12
12
|
|
|
13
|
+
const getYoutubeIframe = (ytEmbedURL) => {
|
|
14
|
+
const videoId = ytEmbedURL.split('/').pop();
|
|
15
|
+
const width = windowWidth - 20;
|
|
16
|
+
const height = (9/16)*(windowWidth - 20);
|
|
17
|
+
const htmlContent = `
|
|
18
|
+
<iframe
|
|
19
|
+
width="1280"
|
|
20
|
+
height="720"
|
|
21
|
+
src="https://www.youtube.com/embed/${videoId}"
|
|
22
|
+
frameborder="0"
|
|
23
|
+
allow="accelerometer;
|
|
24
|
+
autoplay;
|
|
25
|
+
clipboard-write;
|
|
26
|
+
encrypted-media;
|
|
27
|
+
gyroscope;
|
|
28
|
+
picture-in-picture;
|
|
29
|
+
web-share"
|
|
30
|
+
referrerpolicy="strict-origin-when-cross-origin"
|
|
31
|
+
allowfullscreen
|
|
32
|
+
></iframe>`;
|
|
33
|
+
|
|
34
|
+
return `
|
|
35
|
+
<html>
|
|
36
|
+
<head>
|
|
37
|
+
<meta name="viewport" content="width=device-width, initial-scale=1">
|
|
38
|
+
<style>
|
|
39
|
+
iframe{
|
|
40
|
+
width:${width}px;
|
|
41
|
+
height:${height}px;
|
|
42
|
+
}
|
|
43
|
+
</style>
|
|
44
|
+
</head>
|
|
45
|
+
<body>
|
|
46
|
+
${htmlContent}
|
|
47
|
+
</body>
|
|
48
|
+
</html>`;
|
|
49
|
+
}
|
|
50
|
+
|
|
13
51
|
return (
|
|
14
52
|
<View style={styles.container} testID="youtube-player-id">
|
|
15
53
|
<WebView
|
|
16
54
|
mediaPlaybackRequiresUserAction
|
|
17
55
|
style={styles.webViewContainer}
|
|
18
|
-
source={{
|
|
56
|
+
source={{ html: getYoutubeIframe(ytEmbedURL), baseUrl:'https://www.youtube.com'}}
|
|
19
57
|
javaScriptEnabled
|
|
20
58
|
domStorageEnabled
|
|
21
59
|
startInLoadingState
|
package/src/utils/colorUtils.js
CHANGED
|
@@ -2,6 +2,7 @@ export const hexToRgb = (hex, alpha=1) => {
|
|
|
2
2
|
let rgbCode = hex.replace(/^#?([a-f\d])([a-f\d])([a-f\d])$/i,(m, r, g, b) => '#' + r + r + g + g + b + b)
|
|
3
3
|
.substring(1).match(/.{2}/g)
|
|
4
4
|
.map(x => parseInt(x, 16));
|
|
5
|
+
console.log('risi - color', `rgb(${rgbCode[0]}, ${rgbCode[1]}, ${rgbCode[2]}, ${alpha})`)
|
|
5
6
|
return `rgba(${rgbCode[0]}, ${rgbCode[1]}, ${rgbCode[2]}, ${alpha})`;
|
|
6
7
|
}
|
|
7
8
|
|
package/src/utils/story.js
CHANGED
|
@@ -42,51 +42,21 @@ export const getFirstVideoElement = (cards) => cards
|
|
|
42
42
|
|| (type === 'jsembed' && subtype === 'dailymotion-video'),
|
|
43
43
|
) || {};
|
|
44
44
|
|
|
45
|
-
export const mutateDataBeforeAccess = (item, storyHasAccess
|
|
45
|
+
export const mutateDataBeforeAccess = (item, storyHasAccess) => {
|
|
46
46
|
if (isStoryFree(item) === 0 || storyHasAccess === 'granted') {
|
|
47
47
|
return item;
|
|
48
48
|
}
|
|
49
49
|
if (storyHasAccess !== 'loading' && storyHasAccess === 'granted') {
|
|
50
50
|
return item;
|
|
51
51
|
}
|
|
52
|
-
|
|
52
|
+
/* The following steps are necessary to keep argument mutation at bay */
|
|
53
|
+
const firstCardObject = get(item, ['cards', 0], {});
|
|
53
54
|
const firstCardElement = get(firstCardObject, !STORY_TYPES.VIDEO_STORY && ['story-elements', 0], {});
|
|
54
|
-
let visibleContentsForBlockedStory = [];
|
|
55
|
-
let showBlockingWall = false;
|
|
56
|
-
let visibleStoryCount = 0;
|
|
57
|
-
// visibleCardCountForBlockedStories = 0;
|
|
58
|
-
if(!visibleCardCountForBlockedStories){
|
|
59
|
-
return {
|
|
60
|
-
cards: visibleContentsForBlockedStory,
|
|
61
|
-
showBlockingWall: true
|
|
62
|
-
}
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
if(item.cards && item.cards.length > 0){
|
|
66
|
-
for(let i = 0; i < item.cards.length; i++){
|
|
67
|
-
let storyElement = [];
|
|
68
|
-
for(let j=0; j<item.cards[i]['story-elements'].length; j++){
|
|
69
|
-
let tempStoryElement = item.cards[i]['story-elements'][j];
|
|
70
|
-
if(visibleStoryCount < visibleCardCountForBlockedStories-1){
|
|
71
|
-
storyElement.push(tempStoryElement);
|
|
72
|
-
visibleStoryCount++;
|
|
73
|
-
} else {
|
|
74
|
-
showBlockingWall = true;
|
|
75
|
-
storyElement.push(tempStoryElement);
|
|
76
|
-
break;
|
|
77
|
-
}
|
|
78
|
-
}
|
|
79
|
-
|
|
80
|
-
visibleContentsForBlockedStory.push({...item.cards[i],'story-elements' : storyElement});
|
|
81
|
-
if(showBlockingWall) break;
|
|
82
|
-
}
|
|
83
|
-
}
|
|
84
55
|
|
|
85
56
|
return {
|
|
86
57
|
...item,
|
|
87
58
|
...{
|
|
88
|
-
cards:
|
|
59
|
+
cards: [{ ...firstCardObject, 'story-elements': [firstCardElement] }],
|
|
89
60
|
},
|
|
90
|
-
showBlockingWall
|
|
91
61
|
};
|
|
92
62
|
};
|