@megafon/ui-shared 4.5.3 → 4.6.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.
package/CHANGELOG.md CHANGED
@@ -3,6 +3,20 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ # [4.6.0](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.5.3...@megafon/ui-shared@4.6.0) (2022-12-06)
7
+
8
+
9
+ ### Features
10
+
11
+ * **textwithicon:** fix playground ([44c4b6a](https://github.com/MegafonWebLab/megafon-ui/commit/44c4b6ad323a88f48d3b79191e3be4c44fa2ac14))
12
+ * **textwithiconitem:** add example and fix text ([3db8692](https://github.com/MegafonWebLab/megafon-ui/commit/3db869242615caacf1101e4fcff1877ee43c9c95))
13
+ * **textwithiconitem:** add render html and classes ([74e21bc](https://github.com/MegafonWebLab/megafon-ui/commit/74e21bcb78e3f4764ceb58d8fa102b6b000c5ae2))
14
+ * **videoblock:** add playsinline prop ([c383928](https://github.com/MegafonWebLab/megafon-ui/commit/c383928473596bb962e68a15125fa9574bce4a64))
15
+
16
+
17
+
18
+
19
+
6
20
  ## [4.5.3](https://github.com/MegafonWebLab/megafon-ui/compare/@megafon/ui-shared@4.5.2...@megafon/ui-shared@4.5.3) (2022-11-29)
7
21
 
8
22
 
@@ -1,6 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import './TextWithIconItem.less';
3
3
  export interface ITextWithIconItem {
4
+ /** Дополнительные классы для внутренних элементов */
5
+ classes?: {
6
+ icon?: string;
7
+ text?: string;
8
+ };
4
9
  /** Текст */
5
10
  text: string | string[];
6
11
  /** Иконка */
@@ -1,28 +1,41 @@
1
+ import "core-js/modules/es.array.is-array";
2
+ import "core-js/modules/es.array.map";
1
3
  import _extends from "@babel/runtime/helpers/extends";
2
4
  import * as React from 'react';
3
- import { cnCreate, filterDataAttrs } from '@megafon/ui-helpers';
5
+ import { cnCreate, convert, filterDataAttrs, textConvertConfig } from '@megafon/ui-helpers';
4
6
  import * as PropTypes from 'prop-types';
5
7
  import "./TextWithIconItem.css";
6
8
  var cn = cnCreate('mfui-text-with-icon-item');
7
9
 
8
10
  var TextWithIconItem = function TextWithIconItem(_ref) {
9
- var text = _ref.text,
11
+ var className = _ref.className,
12
+ _ref$classes = _ref.classes,
13
+ classes = _ref$classes === void 0 ? {} : _ref$classes,
14
+ text = _ref.text,
10
15
  icon = _ref.icon,
11
16
  rootRef = _ref.rootRef,
12
17
  dataAttrs = _ref.dataAttrs,
13
18
  _ref$centeringOnMobil = _ref.centeringOnMobile,
14
- centeringOnMobile = _ref$centeringOnMobil === void 0 ? true : _ref$centeringOnMobil,
15
- className = _ref.className;
19
+ centeringOnMobile = _ref$centeringOnMobil === void 0 ? true : _ref$centeringOnMobil;
20
+ var renderText = React.useMemo(function () {
21
+ if (Array.isArray(text)) {
22
+ return text.map(function (item) {
23
+ return convert(item, textConvertConfig);
24
+ });
25
+ }
26
+
27
+ return convert(text, textConvertConfig);
28
+ }, [text]);
16
29
  return /*#__PURE__*/React.createElement("div", _extends({
17
30
  className: cn({
18
31
  'centering-on-mobile': centeringOnMobile
19
32
  }, [className]),
20
33
  ref: rootRef
21
34
  }, filterDataAttrs(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
22
- className: cn('svg-icon')
35
+ className: cn('svg-icon', [classes.icon])
23
36
  }, icon), /*#__PURE__*/React.createElement("div", {
24
- className: cn('text')
25
- }, text));
37
+ className: cn('text', [classes.text])
38
+ }, renderText));
26
39
  };
27
40
 
28
41
  TextWithIconItem.propTypes = {
@@ -49,6 +49,8 @@ export interface IVideoBlockProps {
49
49
  poster?: string;
50
50
  /** Расположение контента справа от видео. Только для десктопа */
51
51
  contentPositionRight?: boolean;
52
+ /** Воспроизводит видео на iOS устройствах без перехода в полноэкранный режим */
53
+ playsinline?: boolean;
52
54
  }
53
55
  declare const VideoBlock: React.FC<IVideoBlockProps>;
54
56
  export default VideoBlock;
@@ -30,7 +30,9 @@ var VideoBlock = function VideoBlock(_ref) {
30
30
  isAutoplay = _ref$isAutoplay === void 0 ? false : _ref$isAutoplay,
31
31
  _ref$contentPositionR = _ref.contentPositionRight,
32
32
  contentPositionRight = _ref$contentPositionR === void 0 ? false : _ref$contentPositionR,
33
- poster = _ref.poster;
33
+ poster = _ref.poster,
34
+ _ref$playsinline = _ref.playsinline,
35
+ playsinline = _ref$playsinline === void 0 ? false : _ref$playsinline;
34
36
  var renderVideo = React.useCallback(function () {
35
37
  switch (videoType) {
36
38
  case VideoTypes.YOUTUBE:
@@ -44,7 +46,8 @@ var VideoBlock = function VideoBlock(_ref) {
44
46
  var showinfo = "&showinfo=0";
45
47
  var ivLoadPolicy = "&iv_load_policy=3";
46
48
  var playlist = "&playlist=".concat(videoSrc);
47
- var src = "".concat(url).concat(autoplay).concat(mute).concat(loop).concat(rel).concat(controls).concat(showinfo).concat(ivLoadPolicy).concat(playlist);
49
+ var playsinlineProp = "&playsinline=".concat(playsinline ? 1 : 0);
50
+ var src = "".concat(url).concat(autoplay).concat(mute).concat(loop).concat(rel).concat(controls).concat(showinfo).concat(ivLoadPolicy).concat(playlist).concat(playsinlineProp);
48
51
  return /*#__PURE__*/React.createElement("div", {
49
52
  className: cn('youtube')
50
53
  }, /*#__PURE__*/React.createElement("iframe", {
@@ -70,7 +73,8 @@ var VideoBlock = function VideoBlock(_ref) {
70
73
  muted: isMuted,
71
74
  controls: !isAutoplay,
72
75
  loop: true,
73
- poster: poster
76
+ poster: poster,
77
+ playsInline: playsinline
74
78
  }, /*#__PURE__*/React.createElement("source", {
75
79
  src: videoSrc,
76
80
  type: "video/mp4"
@@ -83,7 +87,7 @@ var VideoBlock = function VideoBlock(_ref) {
83
87
  return null;
84
88
  }
85
89
  }
86
- }, [videoType, videoSrc, isAutoplay, isMuted, poster]);
90
+ }, [videoType, videoSrc, isAutoplay, isMuted, poster, playsinline]);
87
91
  var renderContent = React.useCallback(function (_ref2) {
88
92
  var title = _ref2.title,
89
93
  description = _ref2.description,
@@ -175,6 +179,7 @@ VideoBlock.propTypes = {
175
179
  isMuted: PropTypes.bool,
176
180
  isAutoplay: PropTypes.bool,
177
181
  poster: PropTypes.string,
182
+ playsinline: PropTypes.bool,
178
183
  contentPositionRight: PropTypes.bool
179
184
  };
180
185
  export default VideoBlock;
@@ -1,6 +1,11 @@
1
1
  import * as React from 'react';
2
2
  import './TextWithIconItem.less';
3
3
  export interface ITextWithIconItem {
4
+ /** Дополнительные классы для внутренних элементов */
5
+ classes?: {
6
+ icon?: string;
7
+ text?: string;
8
+ };
4
9
  /** Текст */
5
10
  text: string | string[];
6
11
  /** Иконка */
@@ -7,6 +7,10 @@ Object.defineProperty(exports, "__esModule", {
7
7
  });
8
8
  exports["default"] = void 0;
9
9
 
10
+ require("core-js/modules/es.array.is-array");
11
+
12
+ require("core-js/modules/es.array.map");
13
+
10
14
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
15
 
12
16
  var React = _interopRequireWildcard(require("react"));
@@ -24,23 +28,34 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "d
24
28
  var cn = (0, _uiHelpers.cnCreate)('mfui-text-with-icon-item');
25
29
 
26
30
  var TextWithIconItem = function TextWithIconItem(_ref) {
27
- var text = _ref.text,
31
+ var className = _ref.className,
32
+ _ref$classes = _ref.classes,
33
+ classes = _ref$classes === void 0 ? {} : _ref$classes,
34
+ text = _ref.text,
28
35
  icon = _ref.icon,
29
36
  rootRef = _ref.rootRef,
30
37
  dataAttrs = _ref.dataAttrs,
31
38
  _ref$centeringOnMobil = _ref.centeringOnMobile,
32
- centeringOnMobile = _ref$centeringOnMobil === void 0 ? true : _ref$centeringOnMobil,
33
- className = _ref.className;
39
+ centeringOnMobile = _ref$centeringOnMobil === void 0 ? true : _ref$centeringOnMobil;
40
+ var renderText = React.useMemo(function () {
41
+ if (Array.isArray(text)) {
42
+ return text.map(function (item) {
43
+ return (0, _uiHelpers.convert)(item, _uiHelpers.textConvertConfig);
44
+ });
45
+ }
46
+
47
+ return (0, _uiHelpers.convert)(text, _uiHelpers.textConvertConfig);
48
+ }, [text]);
34
49
  return /*#__PURE__*/React.createElement("div", (0, _extends2["default"])({
35
50
  className: cn({
36
51
  'centering-on-mobile': centeringOnMobile
37
52
  }, [className]),
38
53
  ref: rootRef
39
54
  }, (0, _uiHelpers.filterDataAttrs)(dataAttrs === null || dataAttrs === void 0 ? void 0 : dataAttrs.root)), /*#__PURE__*/React.createElement("div", {
40
- className: cn('svg-icon')
55
+ className: cn('svg-icon', [classes.icon])
41
56
  }, icon), /*#__PURE__*/React.createElement("div", {
42
- className: cn('text')
43
- }, text));
57
+ className: cn('text', [classes.text])
58
+ }, renderText));
44
59
  };
45
60
 
46
61
  TextWithIconItem.propTypes = {
@@ -49,6 +49,8 @@ export interface IVideoBlockProps {
49
49
  poster?: string;
50
50
  /** Расположение контента справа от видео. Только для десктопа */
51
51
  contentPositionRight?: boolean;
52
+ /** Воспроизводит видео на iOS устройствах без перехода в полноэкранный режим */
53
+ playsinline?: boolean;
52
54
  }
53
55
  declare const VideoBlock: React.FC<IVideoBlockProps>;
54
56
  export default VideoBlock;
@@ -48,7 +48,9 @@ var VideoBlock = function VideoBlock(_ref) {
48
48
  isAutoplay = _ref$isAutoplay === void 0 ? false : _ref$isAutoplay,
49
49
  _ref$contentPositionR = _ref.contentPositionRight,
50
50
  contentPositionRight = _ref$contentPositionR === void 0 ? false : _ref$contentPositionR,
51
- poster = _ref.poster;
51
+ poster = _ref.poster,
52
+ _ref$playsinline = _ref.playsinline,
53
+ playsinline = _ref$playsinline === void 0 ? false : _ref$playsinline;
52
54
 
53
55
  var renderVideo = _react["default"].useCallback(function () {
54
56
  switch (videoType) {
@@ -63,7 +65,8 @@ var VideoBlock = function VideoBlock(_ref) {
63
65
  var showinfo = "&showinfo=0";
64
66
  var ivLoadPolicy = "&iv_load_policy=3";
65
67
  var playlist = "&playlist=".concat(videoSrc);
66
- var src = "".concat(url).concat(autoplay).concat(mute).concat(loop).concat(rel).concat(controls).concat(showinfo).concat(ivLoadPolicy).concat(playlist);
68
+ var playsinlineProp = "&playsinline=".concat(playsinline ? 1 : 0);
69
+ var src = "".concat(url).concat(autoplay).concat(mute).concat(loop).concat(rel).concat(controls).concat(showinfo).concat(ivLoadPolicy).concat(playlist).concat(playsinlineProp);
67
70
  return /*#__PURE__*/_react["default"].createElement("div", {
68
71
  className: cn('youtube')
69
72
  }, /*#__PURE__*/_react["default"].createElement("iframe", {
@@ -89,7 +92,8 @@ var VideoBlock = function VideoBlock(_ref) {
89
92
  muted: isMuted,
90
93
  controls: !isAutoplay,
91
94
  loop: true,
92
- poster: poster
95
+ poster: poster,
96
+ playsInline: playsinline
93
97
  }, /*#__PURE__*/_react["default"].createElement("source", {
94
98
  src: videoSrc,
95
99
  type: "video/mp4"
@@ -102,7 +106,7 @@ var VideoBlock = function VideoBlock(_ref) {
102
106
  return null;
103
107
  }
104
108
  }
105
- }, [videoType, videoSrc, isAutoplay, isMuted, poster]);
109
+ }, [videoType, videoSrc, isAutoplay, isMuted, poster, playsinline]);
106
110
 
107
111
  var renderContent = _react["default"].useCallback(function (_ref2) {
108
112
  var title = _ref2.title,
@@ -197,6 +201,7 @@ VideoBlock.propTypes = {
197
201
  isMuted: _propTypes["default"].bool,
198
202
  isAutoplay: _propTypes["default"].bool,
199
203
  poster: _propTypes["default"].string,
204
+ playsinline: _propTypes["default"].bool,
200
205
  contentPositionRight: _propTypes["default"].bool
201
206
  };
202
207
  var _default = VideoBlock;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@megafon/ui-shared",
3
- "version": "4.5.3",
3
+ "version": "4.6.0",
4
4
  "files": [
5
5
  "dist"
6
6
  ],
@@ -85,7 +85,7 @@
85
85
  },
86
86
  "dependencies": {
87
87
  "@babel/runtime": "^7.8.4",
88
- "@megafon/ui-core": "^4.9.0",
88
+ "@megafon/ui-core": "^4.9.1",
89
89
  "@megafon/ui-helpers": "^2.3.0",
90
90
  "core-js": "^3.6.4",
91
91
  "htmr": "^0.9.2",
@@ -93,5 +93,5 @@
93
93
  "prop-types": "^15.7.2",
94
94
  "swiper": "^6.5.6"
95
95
  },
96
- "gitHead": "ab9cb505dca6ae5f4e3db5d4a21add24d10a1be1"
96
+ "gitHead": "079e229d423944ab3643730e461d4d5b4342cff0"
97
97
  }