@micromag/element-visual 0.3.541 → 0.3.569

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.
Files changed (2) hide show
  1. package/package.json +6 -7
  2. package/lib/index.js +0 -168
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-visual",
3
- "version": "0.3.541",
3
+ "version": "0.3.569",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -30,11 +30,10 @@
30
30
  }
31
31
  ],
32
32
  "license": "ISC",
33
- "main": "lib/index.js",
33
+ "type": "module",
34
34
  "module": "es/index.js",
35
35
  "exports": {
36
36
  ".": {
37
- "require": "./lib/index.js",
38
37
  "import": "./es/index.js"
39
38
  },
40
39
  "./assets/css/styles": "./assets/css/styles.css",
@@ -61,9 +60,9 @@
61
60
  "dependencies": {
62
61
  "@babel/runtime": "^7.13.10",
63
62
  "@folklore/size": "^0.1.20",
64
- "@micromag/core": "^0.3.541",
65
- "@micromag/element-image": "^0.3.541",
66
- "@micromag/element-video": "^0.3.541",
63
+ "@micromag/core": "^0.3.569",
64
+ "@micromag/element-image": "^0.3.569",
65
+ "@micromag/element-video": "^0.3.569",
67
66
  "classnames": "^2.2.6",
68
67
  "prop-types": "^15.7.2",
69
68
  "uuid": "^9.0.0"
@@ -72,5 +71,5 @@
72
71
  "access": "public",
73
72
  "registry": "https://registry.npmjs.org/"
74
73
  },
75
- "gitHead": "6c04a7e327b5fbc096785c11320b3fbd3c5751c8"
74
+ "gitHead": "ceb71f23a32ab8df4a1563a1e5cd5598e539de4d"
76
75
  }
package/lib/index.js DELETED
@@ -1,168 +0,0 @@
1
- 'use strict';
2
-
3
- var _defineProperty = require('@babel/runtime/helpers/defineProperty');
4
- var _objectSpread = require('@babel/runtime/helpers/objectSpread2');
5
- var _objectWithoutProperties = require('@babel/runtime/helpers/objectWithoutProperties');
6
- var size = require('@folklore/size');
7
- var classNames = require('classnames');
8
- var PropTypes = require('prop-types');
9
- var React = require('react');
10
- var core = require('@micromag/core');
11
- var Image = require('@micromag/element-image');
12
- var Video = require('@micromag/element-video');
13
-
14
- var styles = {"container":"micromag-element-visual-container","videoContainer":"micromag-element-visual-videoContainer","videoTag":"micromag-element-visual-videoTag","videoTouchOverlay":"micromag-element-visual-videoTouchOverlay"};
15
-
16
- var _excluded = ["media", "mediaRef", "width", "height", "resolution", "objectFit", "playing", "muted", "shouldLoad", "videoLoop", "videoInitialMuted", "onLoaded", "className", "imageClassName", "videoClassName", "withoutVideo"];
17
- var propTypes = {
18
- media: core.PropTypes.media,
19
- mediaRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
20
- // eslint-disable-next-line react/forbid-prop-types
21
- current: PropTypes.any
22
- })]),
23
- width: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
24
- height: PropTypes.oneOfType([PropTypes.number, PropTypes.string]),
25
- resolution: PropTypes.number,
26
- objectFit: core.PropTypes.objectFit,
27
- playing: PropTypes.bool,
28
- muted: PropTypes.bool,
29
- shouldLoad: PropTypes.bool,
30
- videoLoop: PropTypes.bool,
31
- withoutVideo: PropTypes.bool,
32
- videoInitialMuted: PropTypes.bool,
33
- onLoaded: PropTypes.func,
34
- className: PropTypes.string,
35
- imageClassName: PropTypes.string,
36
- videoClassName: PropTypes.string
37
- };
38
- var defaultProps = {
39
- media: null,
40
- mediaRef: null,
41
- width: null,
42
- height: null,
43
- resolution: 1,
44
- objectFit: null,
45
- playing: true,
46
- muted: true,
47
- shouldLoad: true,
48
- videoLoop: true,
49
- withoutVideo: false,
50
- videoInitialMuted: true,
51
- onLoaded: null,
52
- className: null,
53
- imageClassName: null,
54
- videoClassName: null
55
- };
56
- var Visual = function Visual(_ref) {
57
- var media = _ref.media,
58
- mediaRef = _ref.mediaRef,
59
- width = _ref.width,
60
- height = _ref.height,
61
- resolution = _ref.resolution,
62
- objectFit = _ref.objectFit,
63
- playing = _ref.playing,
64
- muted = _ref.muted,
65
- shouldLoad = _ref.shouldLoad,
66
- videoLoop = _ref.videoLoop;
67
- _ref.videoInitialMuted;
68
- var onParentLoaded = _ref.onLoaded,
69
- className = _ref.className,
70
- imageClassName = _ref.imageClassName,
71
- videoClassName = _ref.videoClassName,
72
- withoutVideo = _ref.withoutVideo,
73
- props = _objectWithoutProperties(_ref, _excluded);
74
- var _ref2 = media || {},
75
- _ref2$type = _ref2.type,
76
- type = _ref2$type === void 0 ? null : _ref2$type,
77
- _ref2$thumbnail_url = _ref2.thumbnail_url,
78
- thumbnailUrl = _ref2$thumbnail_url === void 0 ? null : _ref2$thumbnail_url,
79
- _ref2$url = _ref2.url,
80
- url = _ref2$url === void 0 ? null : _ref2$url;
81
- var isVideo = type === 'video';
82
- var elProps = React.useMemo(function () {
83
- return _objectSpread(_objectSpread({}, props), {}, {
84
- media: media
85
- });
86
- }, [props, media]);
87
- var imageElProps = React.useMemo(function () {
88
- var tmpProps = (!shouldLoad || withoutVideo) && isVideo ? _objectSpread(_objectSpread({}, elProps), {}, {
89
- media: {
90
- url: thumbnailUrl
91
- }
92
- }) : elProps;
93
- return shouldLoad && !withoutVideo ? _objectSpread(_objectSpread({}, elProps), {}, {
94
- media: _objectSpread(_objectSpread({}, media), {}, {
95
- url: url
96
- })
97
- }) : tmpProps;
98
- }, [isVideo, elProps, thumbnailUrl, url, shouldLoad]);
99
- var videoContainerStyle = null;
100
- if (type === 'video' && objectFit !== null && shouldLoad) {
101
- var _ref3 = objectFit || {},
102
- _ref3$fit = _ref3.fit,
103
- fit = _ref3$fit === void 0 ? 'cover' : _ref3$fit;
104
- var _ref4 = media || {},
105
- _ref4$metadata = _ref4.metadata,
106
- videoMetadata = _ref4$metadata === void 0 ? null : _ref4$metadata;
107
- var _ref5 = videoMetadata || {},
108
- _ref5$width = _ref5.width,
109
- videoWidth = _ref5$width === void 0 ? 0 : _ref5$width,
110
- _ref5$height = _ref5.height,
111
- videoHeight = _ref5$height === void 0 ? 0 : _ref5$height;
112
- var _getSizeWithinBounds = size.getSizeWithinBounds(videoWidth, videoHeight, width, height, {
113
- cover: fit === 'cover'
114
- }),
115
- resizedVideoWidth = _getSizeWithinBounds.width,
116
- resizedVideoHeight = _getSizeWithinBounds.height;
117
- var resizedVideoLeft = -(resizedVideoWidth - width) / 2;
118
- var resizedVideoTop = -(resizedVideoHeight - height) / 2;
119
- videoContainerStyle = {
120
- width: resizedVideoWidth,
121
- height: resizedVideoHeight,
122
- left: resizedVideoLeft,
123
- top: resizedVideoTop
124
- };
125
- }
126
- var onLoaded = React.useCallback(function (e) {
127
- if (onParentLoaded !== null) {
128
- onParentLoaded(e);
129
- }
130
- }, []);
131
- return type !== null ? /*#__PURE__*/React.createElement(React.Fragment, null, type === 'image' || !shouldLoad || withoutVideo ? /*#__PURE__*/React.createElement(Image, Object.assign({}, imageElProps, {
132
- objectFit: objectFit,
133
- width: width,
134
- height: height,
135
- resolution: resolution,
136
- shouldLoad: shouldLoad,
137
- onLoaded: onLoaded,
138
- className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
139
- imageClassName: imageClassName
140
- })) : null, type === 'video' && shouldLoad && !withoutVideo ? /*#__PURE__*/React.createElement("div", {
141
- className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
142
- style: {
143
- width: width,
144
- height: height
145
- }
146
- }, /*#__PURE__*/React.createElement("div", {
147
- className: classNames([styles.videoContainer, _defineProperty({}, videoClassName, videoClassName !== null)]),
148
- style: videoContainerStyle
149
- }, /*#__PURE__*/React.createElement(Video, Object.assign({}, elProps, {
150
- innerClassName: styles.videoTag,
151
- mediaRef: mediaRef,
152
- width: objectFit === null ? width : null,
153
- height: objectFit === null ? height : null,
154
- paused: !playing,
155
- muted: muted,
156
- loop: videoLoop,
157
- shouldLoad: shouldLoad,
158
- onReady: onLoaded,
159
- autoPlay: true
160
- })), /*#__PURE__*/React.createElement("div", {
161
- className: styles.videoTouchOverlay
162
- }))) : null) : null;
163
- };
164
- Visual.propTypes = propTypes;
165
- Visual.defaultProps = defaultProps;
166
- var Visual$1 = Visual;
167
-
168
- module.exports = Visual$1;