cloudinary-react
Advanced tools
Comparing version 1.2.1 to 1.3.0
@@ -0,2 +1,9 @@ | ||
1.3.0 / 2019-12-26 | ||
================== | ||
* Add support for innerRef to the Image & Video components | ||
* Fix compile script | ||
* Fix photo album sample app startup | ||
1.2.1 / 2019-09-30 | ||
@@ -3,0 +10,0 @@ ================== |
@@ -20,3 +20,3 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -23,0 +23,0 @@ function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } |
@@ -24,3 +24,3 @@ "use strict"; | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(source, true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(source).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
@@ -27,0 +27,0 @@ function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } |
"use strict"; | ||
function _typeof(obj) { if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { _typeof = function _typeof(obj) { return typeof obj; }; } else { _typeof = function _typeof(obj) { return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }; } return _typeof(obj); } | ||
Object.defineProperty(exports, "__esModule", { | ||
@@ -12,5 +14,5 @@ value: true | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
var CloudinaryContextType = (0, _react.createContext)(); | ||
exports.CloudinaryContextType = CloudinaryContextType; |
@@ -18,3 +18,3 @@ "use strict"; | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; if (obj != null) { var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { "default": obj }; } var cache = _getRequireWildcardCache(); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj["default"] = obj; if (cache) { cache.set(obj, newObj); } return newObj; } | ||
@@ -31,2 +31,8 @@ function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { "default": obj }; } | ||
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); keys.push.apply(keys, symbols); } return keys; } | ||
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; } | ||
function _defineProperty(obj, key, value) { if (key in obj) { Object.defineProperty(obj, key, { value: value, enumerable: true, configurable: true, writable: true }); } else { obj[key] = value; } return obj; } | ||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } } | ||
@@ -69,3 +75,3 @@ | ||
_this.handleResize = _this.handleResize.bind(_assertThisInitialized(_this)); | ||
_this.state = {}; | ||
_this.attachRef = _this.attachRef.bind(_assertThisInitialized(_this)); | ||
var state = { | ||
@@ -76,3 +82,3 @@ responsive: false, | ||
}; | ||
_this.state = Object.assign(state, _this.prepareState(props, context)); | ||
_this.state = _objectSpread({}, state, {}, _this.prepareState(props, context)); | ||
return _this; | ||
@@ -119,2 +125,16 @@ } | ||
}, { | ||
key: "attachRef", | ||
value: function attachRef(element) { | ||
this.element = element; | ||
var innerRef = this.props.innerRef; | ||
if (innerRef) { | ||
if (innerRef instanceof Function) { | ||
innerRef(element); | ||
} else { | ||
innerRef.current = element; | ||
} | ||
} | ||
} | ||
}, { | ||
key: "handleResize", | ||
@@ -172,4 +192,2 @@ value: function handleResize() { | ||
value: function render() { | ||
var _this3 = this; | ||
var _CloudinaryComponent$ = _CloudinaryComponent2["default"].normalizeOptions(this.props, this.getContext()), | ||
@@ -180,3 +198,4 @@ publicId = _CloudinaryComponent$.publicId, | ||
children = _CloudinaryComponent$.children, | ||
options = _objectWithoutProperties(_CloudinaryComponent$, ["publicId", "responsive", "responsiveDebounce", "children"]); | ||
innerRef = _CloudinaryComponent$.innerRef, | ||
options = _objectWithoutProperties(_CloudinaryComponent$, ["publicId", "responsive", "responsiveDebounce", "children", "innerRef"]); | ||
@@ -188,5 +207,3 @@ var attributes = _cloudinaryCore["default"].Transformation["new"](options).toHtmlAttributes(); | ||
src: url, | ||
ref: function ref(e) { | ||
_this3.element = e; | ||
} | ||
ref: this.attachRef | ||
})); | ||
@@ -193,0 +210,0 @@ } // Methods from cloudinary_js |
@@ -20,2 +20,4 @@ "use strict"; | ||
function _extends() { _extends = Object.assign || function (target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i]; for (var key in source) { if (Object.prototype.hasOwnProperty.call(source, key)) { target[key] = source[key]; } } } return target; }; return _extends.apply(this, arguments); } | ||
function _objectWithoutProperties(source, excluded) { if (source == null) return {}; var target = _objectWithoutPropertiesLoose(source, excluded); var key, i; if (Object.getOwnPropertySymbols) { var sourceSymbolKeys = Object.getOwnPropertySymbols(source); for (i = 0; i < sourceSymbolKeys.length; i++) { key = sourceSymbolKeys[i]; if (excluded.indexOf(key) >= 0) continue; if (!Object.prototype.propertyIsEnumerable.call(source, key)) continue; target[key] = source[key]; } } return target; } | ||
@@ -73,3 +75,4 @@ | ||
sourceTransformations = _Object$assign.sourceTransformation, | ||
options = _objectWithoutProperties(_Object$assign, ["publicId", "poster", "sourceTypes", "fallback", "sourceTransformation"]); | ||
innerRef = _Object$assign.innerRef, | ||
options = _objectWithoutProperties(_Object$assign, ["publicId", "poster", "sourceTypes", "fallback", "sourceTransformation", "innerRef"]); | ||
@@ -123,3 +126,5 @@ sourceTransformations = sourceTransformations || {}; | ||
return _react["default"].createElement("video", tagAttributes, sources, fallback, this.props.children); | ||
return _react["default"].createElement("video", _extends({ | ||
ref: innerRef | ||
}, tagAttributes), sources, fallback, this.props.children); | ||
} | ||
@@ -126,0 +131,0 @@ }]); |
@@ -17,4 +17,4 @@ "use strict"; | ||
function debounce(func, wait, immediate) { | ||
var _this = this, | ||
_arguments = arguments; | ||
var _arguments = arguments, | ||
_this = this; | ||
@@ -21,0 +21,0 @@ var timeout = null; |
{ | ||
"name": "cloudinary-react", | ||
"version": "1.2.1", | ||
"version": "1.3.0", | ||
"description": "Present Cloudinary images and videos using React components", | ||
@@ -11,3 +11,3 @@ "main": "lib/index.js", | ||
"test-lib": "TEST_SUBJECT=lib node_modules/.bin/mocha --require @babel/register test/.setup.js --recursive test", | ||
"compile": "node_modules/.bin/babel -v --copy-files src -d lib ", | ||
"compile": "node_modules/.bin/babel src --out-dir lib --copy-files ", | ||
"dist": "node_modules/.bin/webpack", | ||
@@ -14,0 +14,0 @@ "storybook": "start-storybook -p 6006", |
@@ -17,7 +17,6 @@ import React from 'react'; | ||
this.handleResize = this.handleResize.bind(this); | ||
this.attachRef = this.attachRef.bind(this); | ||
this.state = {}; | ||
let state = {responsive: false, url: undefined, breakpoints: defaultBreakpoints}; | ||
this.state = Object.assign(state, this.prepareState(props, context)); | ||
this.state = {...state, ...this.prepareState(props, context)}; | ||
} | ||
@@ -64,2 +63,15 @@ | ||
attachRef(element) { | ||
this.element = element; | ||
const {innerRef} = this.props; | ||
if (innerRef) { | ||
if (innerRef instanceof Function) { | ||
innerRef(element); | ||
} else { | ||
innerRef.current = element; | ||
} | ||
} | ||
} | ||
handleResize() { | ||
@@ -103,3 +115,3 @@ if (!this.props.responsive || this.rqf) return; | ||
render() { | ||
const {publicId, responsive, responsiveDebounce, children, ...options} = | ||
const {publicId, responsive, responsiveDebounce, children, innerRef, ...options} = | ||
CloudinaryComponent.normalizeOptions(this.props, this.getContext()); | ||
@@ -109,5 +121,3 @@ const attributes = cloudinary.Transformation.new(options).toHtmlAttributes(); | ||
return ( | ||
<img {...attributes} src={url} ref={(e) => { | ||
this.element = e; | ||
}}/> | ||
<img {...attributes} src={url} ref={this.attachRef}/> | ||
); | ||
@@ -114,0 +124,0 @@ } |
@@ -21,3 +21,3 @@ import React from 'react'; | ||
render() { | ||
let {publicId, poster, sourceTypes, fallback, sourceTransformation: sourceTransformations, ...options} = Object.assign({}, | ||
let {publicId, poster, sourceTypes, fallback, sourceTransformation: sourceTransformations, innerRef, ...options} = Object.assign({}, | ||
this.getContext(), | ||
@@ -57,3 +57,3 @@ this.props); | ||
return ( | ||
<video {...tagAttributes}> | ||
<video ref={innerRef} {...tagAttributes}> | ||
{sources} | ||
@@ -60,0 +60,0 @@ {fallback} |
Sorry, the diff of this file is too big to display
246518
47
1957