@megafon/ui-shared 6.7.0 → 6.8.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.
@@ -82,7 +82,9 @@ h5 {
82
82
  -webkit-filter: brightness(108.5%);
83
83
  filter: brightness(108.5%);
84
84
  }
85
- .mfui-v6-video-block__youtube {
85
+ .mfui-v6-video-block__youtube,
86
+ .mfui-v6-video-block__rutube,
87
+ .mfui-v6-video-block__vk {
86
88
  position: relative;
87
89
  padding-bottom: 56.25%;
88
90
  }
@@ -18,6 +18,8 @@ export interface IContent {
18
18
  }
19
19
  export declare const VideoTypes: {
20
20
  readonly YOUTUBE: "youtube";
21
+ readonly RUTUBE: "rutube";
22
+ readonly VK: "vk";
21
23
  readonly VIDEO: "video";
22
24
  };
23
25
  declare type VideoType = typeof VideoTypes[keyof typeof VideoTypes];
@@ -41,7 +43,7 @@ export interface IVideoBlockProps {
41
43
  content?: IContent;
42
44
  /** Тип видео */
43
45
  videoType?: VideoType;
44
- /** Источник видео. Если видео с youtube, то необходимо указать id */
46
+ /** Источник видео. Если видео с youtube или rutube, то необходимо указать id. Для видео из VK необходимо указать полный id вместе с _ (например: 22822305_456241864) */
45
47
  videoSrc: string;
46
48
  /** Наличие звука в видео */
47
49
  isMuted?: boolean;
@@ -1,5 +1,8 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
+ import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
2
3
  import "core-js/modules/es.array.concat.js";
4
+ import "core-js/modules/es.regexp.exec.js";
5
+ import "core-js/modules/es.string.split.js";
3
6
  import "core-js/modules/es.symbol.js";
4
7
  import "core-js/modules/es.symbol.description.js";
5
8
  import "core-js/modules/es.object.values.js";
@@ -10,6 +13,8 @@ import PropTypes from 'prop-types';
10
13
  import "./VideoBlock.css";
11
14
  export var VideoTypes = {
12
15
  YOUTUBE: 'youtube',
16
+ RUTUBE: 'rutube',
17
+ VK: 'vk',
13
18
  VIDEO: 'video'
14
19
  };
15
20
  export var testIdPrefix = 'VideoBlock';
@@ -36,6 +41,40 @@ var VideoBlock = function VideoBlock(_ref) {
36
41
  playsinline = _ref$playsinline === void 0 ? false : _ref$playsinline,
37
42
  _ref$fixWhiteVideoBac = _ref.fixWhiteVideoBackground,
38
43
  fixWhiteVideoBackground = _ref$fixWhiteVideoBac === void 0 ? false : _ref$fixWhiteVideoBac;
44
+ var rutubeRef = React.useRef(null);
45
+
46
+ var autoPlayRutube = function autoPlayRutube() {
47
+ var current = rutubeRef.current;
48
+
49
+ if (current == null) {
50
+ return;
51
+ }
52
+
53
+ window.IntersectionObserver && new window.IntersectionObserver(function (entries, obs) {
54
+ var _a;
55
+
56
+ var _entries = _slicedToArray(entries, 1),
57
+ entry = _entries[0];
58
+
59
+ if (entry && entry.isIntersecting) {
60
+ (_a = current.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify({
61
+ type: 'player:play',
62
+ data: {}
63
+ }), '*');
64
+ obs.disconnect();
65
+ }
66
+ }, {
67
+ threshold: 0.5
68
+ }).observe(current);
69
+ };
70
+
71
+ React.useEffect(function () {
72
+ if (!isAutoplay || videoType !== VideoTypes.RUTUBE) {
73
+ return;
74
+ }
75
+
76
+ autoPlayRutube();
77
+ }, [isAutoplay, videoType]);
39
78
  var renderVideo = React.useCallback(function () {
40
79
  switch (videoType) {
41
80
  case VideoTypes.YOUTUBE:
@@ -66,6 +105,54 @@ var VideoBlock = function VideoBlock(_ref) {
66
105
  }));
67
106
  }
68
107
 
108
+ case VideoTypes.RUTUBE:
109
+ {
110
+ var _src = "https://rutube.ru/play/embed/".concat(videoSrc, "?");
111
+
112
+ return /*#__PURE__*/React.createElement("div", {
113
+ className: cn('rutube')
114
+ }, /*#__PURE__*/React.createElement("iframe", {
115
+ className: cn('iframe'),
116
+ ref: rutubeRef,
117
+ src: _src,
118
+ width: "100%",
119
+ height: "100%",
120
+ frameBorder: "0",
121
+ allow: "autoplay",
122
+ title: "iframe",
123
+ allowFullScreen: true,
124
+ "data-testid": "".concat(testIdPrefix, "-iframe-video")
125
+ }));
126
+ }
127
+
128
+ case VideoTypes.VK:
129
+ {
130
+ var _videoSrc$split = videoSrc.split('_'),
131
+ _videoSrc$split2 = _slicedToArray(_videoSrc$split, 2),
132
+ oid = _videoSrc$split2[0],
133
+ id = _videoSrc$split2[1];
134
+
135
+ var _url = "https://vk.com/video_ext.php?oid=-".concat(oid, "}&id=").concat(id, "&");
136
+
137
+ var _autoplay = "&autoplay=".concat(isAutoplay ? 1 : 0);
138
+
139
+ var _src2 = "".concat(_url).concat(_autoplay);
140
+
141
+ return /*#__PURE__*/React.createElement("div", {
142
+ className: cn('vk')
143
+ }, /*#__PURE__*/React.createElement("iframe", {
144
+ className: cn('iframe'),
145
+ src: _src2,
146
+ width: "100%",
147
+ height: "100%",
148
+ frameBorder: "0",
149
+ allow: "autoplay",
150
+ title: "iframe",
151
+ allowFullScreen: true,
152
+ "data-testid": "".concat(testIdPrefix, "-iframe-video")
153
+ }));
154
+ }
155
+
69
156
  case VideoTypes.VIDEO:
70
157
  {
71
158
  return (
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
@@ -82,7 +82,9 @@ h5 {
82
82
  -webkit-filter: brightness(108.5%);
83
83
  filter: brightness(108.5%);
84
84
  }
85
- .mfui-v6-video-block__youtube {
85
+ .mfui-v6-video-block__youtube,
86
+ .mfui-v6-video-block__rutube,
87
+ .mfui-v6-video-block__vk {
86
88
  position: relative;
87
89
  padding-bottom: 56.25%;
88
90
  }
@@ -18,6 +18,8 @@ export interface IContent {
18
18
  }
19
19
  export declare const VideoTypes: {
20
20
  readonly YOUTUBE: "youtube";
21
+ readonly RUTUBE: "rutube";
22
+ readonly VK: "vk";
21
23
  readonly VIDEO: "video";
22
24
  };
23
25
  declare type VideoType = typeof VideoTypes[keyof typeof VideoTypes];
@@ -41,7 +43,7 @@ export interface IVideoBlockProps {
41
43
  content?: IContent;
42
44
  /** Тип видео */
43
45
  videoType?: VideoType;
44
- /** Источник видео. Если видео с youtube, то необходимо указать id */
46
+ /** Источник видео. Если видео с youtube или rutube, то необходимо указать id. Для видео из VK необходимо указать полный id вместе с _ (например: 22822305_456241864) */
45
47
  videoSrc: string;
46
48
  /** Наличие звука в видео */
47
49
  isMuted?: boolean;
@@ -7,8 +7,14 @@ exports["default"] = exports.testIdPrefix = exports.VideoTypes = void 0;
7
7
 
8
8
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
9
9
 
10
+ var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
11
+
10
12
  require("core-js/modules/es.array.concat.js");
11
13
 
14
+ require("core-js/modules/es.regexp.exec.js");
15
+
16
+ require("core-js/modules/es.string.split.js");
17
+
12
18
  require("core-js/modules/es.symbol.js");
13
19
 
14
20
  require("core-js/modules/es.symbol.description.js");
@@ -27,6 +33,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
27
33
 
28
34
  var VideoTypes = {
29
35
  YOUTUBE: 'youtube',
36
+ RUTUBE: 'rutube',
37
+ VK: 'vk',
30
38
  VIDEO: 'video'
31
39
  };
32
40
  exports.VideoTypes = VideoTypes;
@@ -56,6 +64,41 @@ var VideoBlock = function VideoBlock(_ref) {
56
64
  _ref$fixWhiteVideoBac = _ref.fixWhiteVideoBackground,
57
65
  fixWhiteVideoBackground = _ref$fixWhiteVideoBac === void 0 ? false : _ref$fixWhiteVideoBac;
58
66
 
67
+ var rutubeRef = _react["default"].useRef(null);
68
+
69
+ var autoPlayRutube = function autoPlayRutube() {
70
+ var current = rutubeRef.current;
71
+
72
+ if (current == null) {
73
+ return;
74
+ }
75
+
76
+ window.IntersectionObserver && new window.IntersectionObserver(function (entries, obs) {
77
+ var _a;
78
+
79
+ var _entries = (0, _slicedToArray2["default"])(entries, 1),
80
+ entry = _entries[0];
81
+
82
+ if (entry && entry.isIntersecting) {
83
+ (_a = current.contentWindow) === null || _a === void 0 ? void 0 : _a.postMessage(JSON.stringify({
84
+ type: 'player:play',
85
+ data: {}
86
+ }), '*');
87
+ obs.disconnect();
88
+ }
89
+ }, {
90
+ threshold: 0.5
91
+ }).observe(current);
92
+ };
93
+
94
+ _react["default"].useEffect(function () {
95
+ if (!isAutoplay || videoType !== VideoTypes.RUTUBE) {
96
+ return;
97
+ }
98
+
99
+ autoPlayRutube();
100
+ }, [isAutoplay, videoType]);
101
+
59
102
  var renderVideo = _react["default"].useCallback(function () {
60
103
  switch (videoType) {
61
104
  case VideoTypes.YOUTUBE:
@@ -86,6 +129,54 @@ var VideoBlock = function VideoBlock(_ref) {
86
129
  }));
87
130
  }
88
131
 
132
+ case VideoTypes.RUTUBE:
133
+ {
134
+ var _src = "https://rutube.ru/play/embed/".concat(videoSrc, "?");
135
+
136
+ return /*#__PURE__*/_react["default"].createElement("div", {
137
+ className: cn('rutube')
138
+ }, /*#__PURE__*/_react["default"].createElement("iframe", {
139
+ className: cn('iframe'),
140
+ ref: rutubeRef,
141
+ src: _src,
142
+ width: "100%",
143
+ height: "100%",
144
+ frameBorder: "0",
145
+ allow: "autoplay",
146
+ title: "iframe",
147
+ allowFullScreen: true,
148
+ "data-testid": "".concat(testIdPrefix, "-iframe-video")
149
+ }));
150
+ }
151
+
152
+ case VideoTypes.VK:
153
+ {
154
+ var _videoSrc$split = videoSrc.split('_'),
155
+ _videoSrc$split2 = (0, _slicedToArray2["default"])(_videoSrc$split, 2),
156
+ oid = _videoSrc$split2[0],
157
+ id = _videoSrc$split2[1];
158
+
159
+ var _url = "https://vk.com/video_ext.php?oid=-".concat(oid, "}&id=").concat(id, "&");
160
+
161
+ var _autoplay = "&autoplay=".concat(isAutoplay ? 1 : 0);
162
+
163
+ var _src2 = "".concat(_url).concat(_autoplay);
164
+
165
+ return /*#__PURE__*/_react["default"].createElement("div", {
166
+ className: cn('vk')
167
+ }, /*#__PURE__*/_react["default"].createElement("iframe", {
168
+ className: cn('iframe'),
169
+ src: _src2,
170
+ width: "100%",
171
+ height: "100%",
172
+ frameBorder: "0",
173
+ allow: "autoplay",
174
+ title: "iframe",
175
+ allowFullScreen: true,
176
+ "data-testid": "".concat(testIdPrefix, "-iframe-video")
177
+ }));
178
+ }
179
+
89
180
  case VideoTypes.VIDEO:
90
181
  {
91
182
  return (
@@ -1,2 +1,2 @@
1
1
  import React from 'react';
2
- export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("@megafon/ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
2
+ export declare const getColumnConfig: (isFullWidth: boolean) => Pick<React.PropsWithChildren<import("../../../ui-core/dist/lib/components/Grid/GridColumn").IGridColumn>, "all" | "wide" | "mobile" | "desktop" | "tablet">;
package/package.json CHANGED
@@ -1,94 +1,94 @@
1
1
  {
2
- "name": "@megafon/ui-shared",
3
- "version": "6.7.0",
4
- "files": [
5
- "dist"
6
- ],
7
- "main": "dist/lib/index.js",
8
- "module": "dist/es/index.js",
9
- "typings": "dist/lib/index.d.ts",
10
- "sideEffects": [
11
- "*.css",
12
- "*.less"
13
- ],
14
- "author": "MegaFon",
15
- "license": "MIT",
16
- "scripts": {
17
- "build": "gulp build",
18
- "cleanDist": "rm -rf dist",
19
- "coverage": "yarn coverage:unit",
20
- "coverage:unit": "jest --coverage",
21
- "typecheck": "tsc --noEmit -p .",
22
- "prettier:check": "prettier --list-different \"src/**/*.{js,jsx,ts,tsx}\"",
23
- "prettier:fix": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
24
- "lint": "yarn lint:ts && yarn lint:less",
25
- "lint:ts": "eslint --ext .js,.jsx,.ts,.tsx src --max-warnings=0",
26
- "lint:less": "stylelint --syntax less src/**/*.less src/**/**/*.less",
27
- "lint:less:fix": "yarn lint:less --fix",
28
- "test": "yarn test:unit",
29
- "test:unit": "jest",
30
- "test:update": "jest --updateSnapshot"
31
- },
32
- "publishConfig": {
33
- "access": "public"
34
- },
35
- "lint-staged": {
36
- "src/**/**/*.(js|jsx|ts|tsx)": [
37
- "eslint --max-warnings=0 --config ../../.eslintrc.json"
38
- ]
39
- },
40
- "peerDependencies": {
41
- "react": ">=16.13.0",
42
- "react-dom": ">=16.13.0"
43
- },
44
- "devDependencies": {
45
- "@babel/core": "^7.8.6",
46
- "@babel/plugin-transform-object-assign": "^7.8.3",
47
- "@babel/plugin-transform-runtime": "^7.8.3",
48
- "@babel/preset-env": "^7.8.6",
49
- "@babel/preset-react": "^7.8.3",
50
- "@babel/preset-typescript": "^7.8.3",
51
- "@megafon/ui-icons": "^2.29.0",
52
- "@svgr/core": "^2.4.1",
53
- "@testing-library/jest-dom": "5.16.2",
54
- "@testing-library/react": "12.1.2",
55
- "@testing-library/react-hooks": "^8.0.1",
56
- "@testing-library/user-event": "13.5.0",
57
- "@types/enzyme": "^3.10.5",
58
- "@types/enzyme-adapter-react-16": "^1.0.6",
59
- "@types/jest": "^25.1.3",
60
- "@types/prop-types": "^15.7.3",
61
- "@types/react": "^16.9.23",
62
- "@types/react-dom": "^16.9.5",
63
- "babel-plugin-module-resolver": "^3.2.0",
64
- "del": "^3.0.0",
65
- "enzyme": "^3.11.0",
66
- "enzyme-adapter-react-16": "^1.15.2",
67
- "enzyme-to-json": "^3.4.4",
68
- "glob": "^7.1.6",
69
- "gulp": "^4.0.2",
70
- "gulp-babel": "^8.0.0-beta.2",
71
- "gulp-imagemin": "^7.1.0",
72
- "gulp-less": "^4.0.1",
73
- "gulp-typescript": "^5.0.1",
74
- "jest": "^25.1.0",
75
- "less-plugin-autoprefix": "^2.0.0",
76
- "merge2": "^1.3.0",
77
- "react": "^16.13.0",
78
- "react-dom": "^16.13.0",
79
- "stylelint": "^9.10.1",
80
- "through2": "^2.0.5",
81
- "typescript": "^3.8.3"
82
- },
83
- "dependencies": {
84
- "@babel/runtime": "^7.8.4",
85
- "@megafon/ui-core": "^6.4.1",
86
- "@megafon/ui-helpers": "^2.6.0",
87
- "core-js": "^3.6.4",
88
- "htmr": "^0.9.2",
89
- "lodash.throttle": "^4.1.1",
90
- "prop-types": "^15.7.2",
91
- "swiper": "^6.5.6"
92
- },
93
- "gitHead": "45875cd1687c3cbd725b497b508cd33a083228d8"
2
+ "name": "@megafon/ui-shared",
3
+ "version": "6.8.0",
4
+ "files": [
5
+ "dist"
6
+ ],
7
+ "main": "dist/lib/index.js",
8
+ "module": "dist/es/index.js",
9
+ "typings": "dist/lib/index.d.ts",
10
+ "sideEffects": [
11
+ "*.css",
12
+ "*.less"
13
+ ],
14
+ "author": "MegaFon",
15
+ "license": "MIT",
16
+ "scripts": {
17
+ "build": "gulp build",
18
+ "cleanDist": "rm -rf dist",
19
+ "coverage": "yarn coverage:unit",
20
+ "coverage:unit": "jest --coverage",
21
+ "typecheck": "tsc --noEmit -p .",
22
+ "prettier:check": "prettier --list-different \"src/**/*.{js,jsx,ts,tsx}\"",
23
+ "prettier:fix": "prettier --write \"src/**/*.{js,jsx,ts,tsx}\"",
24
+ "lint": "yarn lint:ts && yarn lint:less",
25
+ "lint:ts": "eslint --ext .js,.jsx,.ts,.tsx src --max-warnings=0",
26
+ "lint:less": "stylelint --syntax less src/**/*.less src/**/**/*.less",
27
+ "lint:less:fix": "yarn lint:less --fix",
28
+ "test": "yarn test:unit",
29
+ "test:unit": "jest",
30
+ "test:update": "jest --updateSnapshot"
31
+ },
32
+ "publishConfig": {
33
+ "access": "public"
34
+ },
35
+ "lint-staged": {
36
+ "src/**/**/*.(js|jsx|ts|tsx)": [
37
+ "eslint --max-warnings=0 --config ../../.eslintrc.json"
38
+ ]
39
+ },
40
+ "peerDependencies": {
41
+ "react": ">=16.13.0",
42
+ "react-dom": ">=16.13.0"
43
+ },
44
+ "devDependencies": {
45
+ "@babel/core": "^7.8.6",
46
+ "@babel/plugin-transform-object-assign": "^7.8.3",
47
+ "@babel/plugin-transform-runtime": "^7.8.3",
48
+ "@babel/preset-env": "^7.8.6",
49
+ "@babel/preset-react": "^7.8.3",
50
+ "@babel/preset-typescript": "^7.8.3",
51
+ "@megafon/ui-icons": "^2.30.0",
52
+ "@svgr/core": "^2.4.1",
53
+ "@testing-library/jest-dom": "5.16.2",
54
+ "@testing-library/react": "12.1.2",
55
+ "@testing-library/react-hooks": "^8.0.1",
56
+ "@testing-library/user-event": "13.5.0",
57
+ "@types/enzyme": "^3.10.5",
58
+ "@types/enzyme-adapter-react-16": "^1.0.6",
59
+ "@types/jest": "^25.1.3",
60
+ "@types/prop-types": "^15.7.3",
61
+ "@types/react": "^16.9.23",
62
+ "@types/react-dom": "^16.9.5",
63
+ "babel-plugin-module-resolver": "^3.2.0",
64
+ "del": "^3.0.0",
65
+ "enzyme": "^3.11.0",
66
+ "enzyme-adapter-react-16": "^1.15.2",
67
+ "enzyme-to-json": "^3.4.4",
68
+ "glob": "^7.1.6",
69
+ "gulp": "^4.0.2",
70
+ "gulp-babel": "^8.0.0-beta.2",
71
+ "gulp-imagemin": "^7.1.0",
72
+ "gulp-less": "^4.0.1",
73
+ "gulp-typescript": "^5.0.1",
74
+ "jest": "^25.1.0",
75
+ "less-plugin-autoprefix": "^2.0.0",
76
+ "merge2": "^1.3.0",
77
+ "react": "^16.13.0",
78
+ "react-dom": "^16.13.0",
79
+ "stylelint": "^9.10.1",
80
+ "through2": "^2.0.5",
81
+ "typescript": "^3.8.3"
82
+ },
83
+ "dependencies": {
84
+ "@babel/runtime": "^7.8.4",
85
+ "@megafon/ui-core": "^6.4.2",
86
+ "@megafon/ui-helpers": "^2.6.0",
87
+ "core-js": "^3.6.4",
88
+ "htmr": "^0.9.2",
89
+ "lodash.throttle": "^4.1.1",
90
+ "prop-types": "^15.7.2",
91
+ "swiper": "^6.5.6"
92
+ },
93
+ "gitHead": "fea7e711b2427c835cd6ec8016df37d7996ef4de"
94
94
  }