@micromag/element-image 0.3.801 → 0.3.807

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/es/index.js +17 -6
  2. package/package.json +3 -3
package/es/index.js CHANGED
@@ -4,7 +4,7 @@ import _slicedToArray from '@babel/runtime/helpers/slicedToArray';
4
4
  import { getSizeWithinBounds } from '@folklore/size';
5
5
  import classNames from 'classnames';
6
6
  import PropTypes from 'prop-types';
7
- import React, { useState, useRef, useCallback } from 'react';
7
+ import React, { forwardRef, useState, useRef, useCallback } from 'react';
8
8
  import { PropTypes as PropTypes$1 } from '@micromag/core';
9
9
  import { getOptimalImageUrl } from '@micromag/core/utils';
10
10
 
@@ -23,7 +23,10 @@ var propTypes = {
23
23
  imageClassName: PropTypes.string,
24
24
  onLoaded: PropTypes.func,
25
25
  loadingMode: PropTypes.string,
26
- shouldLoad: PropTypes.bool
26
+ shouldLoad: PropTypes.bool,
27
+ containerRef: PropTypes.oneOfType([PropTypes.func, PropTypes.shape({
28
+ current: PropTypes.any
29
+ })])
27
30
  };
28
31
  var defaultProps = {
29
32
  media: null,
@@ -39,7 +42,8 @@ var defaultProps = {
39
42
  imageClassName: null,
40
43
  onLoaded: null,
41
44
  loadingMode: 'lazy',
42
- shouldLoad: true
45
+ shouldLoad: true,
46
+ containerRef: null
43
47
  };
44
48
  var Image = function Image(_ref) {
45
49
  var media = _ref.media,
@@ -54,7 +58,8 @@ var Image = function Image(_ref) {
54
58
  imageClassName = _ref.imageClassName,
55
59
  onLoaded = _ref.onLoaded,
56
60
  loadingMode = _ref.loadingMode,
57
- shouldLoad = _ref.shouldLoad;
61
+ shouldLoad = _ref.shouldLoad,
62
+ containerRef = _ref.containerRef;
58
63
  var _ref2 = media || {},
59
64
  _ref2$metadata = _ref2.metadata,
60
65
  metadata = _ref2$metadata === void 0 ? null : _ref2$metadata;
@@ -183,7 +188,8 @@ var Image = function Image(_ref) {
183
188
 
184
189
  return /*#__PURE__*/React.createElement("div", {
185
190
  className: classNames([styles.container, _defineProperty({}, className, className !== null)]),
186
- style: finalContainerStyle
191
+ style: finalContainerStyle,
192
+ ref: containerRef
187
193
  }, finalUrl !== null && finalShouldLoad ? /*#__PURE__*/React.createElement("img", {
188
194
  src: finalUrl,
189
195
  alt: alt || description,
@@ -195,5 +201,10 @@ var Image = function Image(_ref) {
195
201
  };
196
202
  Image.propTypes = propTypes;
197
203
  Image.defaultProps = defaultProps;
204
+ var Image_default = /*#__PURE__*/forwardRef(function (props, ref) {
205
+ return /*#__PURE__*/React.createElement(Image, Object.assign({
206
+ containerRef: ref
207
+ }, props));
208
+ });
198
209
 
199
- export { Image as default };
210
+ export { Image_default as default };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@micromag/element-image",
3
- "version": "0.3.801",
3
+ "version": "0.3.807",
4
4
  "private": false,
5
5
  "description": "",
6
6
  "keywords": [
@@ -60,7 +60,7 @@
60
60
  "dependencies": {
61
61
  "@babel/runtime": "^7.13.10",
62
62
  "@folklore/size": "^0.1.20",
63
- "@micromag/core": "^0.3.801",
63
+ "@micromag/core": "^0.3.807",
64
64
  "classnames": "^2.2.6",
65
65
  "prop-types": "^15.7.2",
66
66
  "react-intl": "^6.6.4",
@@ -70,5 +70,5 @@
70
70
  "access": "public",
71
71
  "registry": "https://registry.npmjs.org/"
72
72
  },
73
- "gitHead": "0ce6f19eff38a6fff58c0f156d3f53d741f5113e"
73
+ "gitHead": "5aee5186c7e3b3dc6fe0f11e848943f21c33a195"
74
74
  }