@uncinc/uncinc-react-kitchen-sink 2.8.16 → 2.8.20

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.
@@ -6,8 +6,9 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import React from 'react';
8
8
  import c from 'classnames';
9
- import './style.scss';
9
+ import urlParse from 'url';
10
10
  import { isValidImage, useImageLoader, calculateTargetSrc } from '../helpers';
11
+ import './style.scss';
11
12
 
12
13
  // extend html img props
13
14
 
@@ -44,19 +45,30 @@ var AdaptivePicture = function AdaptivePicture(_ref) {
44
45
  if (!container) return;
45
46
  var resizeObserver = new ResizeObserver(function (entries) {
46
47
  var widthAfterResize = entries[0].contentRect.width;
48
+ var newSrcRequired = false;
47
49
  if (image.width < widthAfterResize) {
48
50
  var newTargetSrc = calculateTargetSrc(image.width, validatedSources, fallbackImage);
49
51
  if (targetSrc !== newTargetSrc) {
50
52
  setTargetSrc(newTargetSrc);
53
+ newSrcRequired = true;
51
54
  }
52
55
  } else {
53
56
  var _newTargetSrc = calculateTargetSrc(widthAfterResize, validatedSources, fallbackImage);
54
57
  if (targetSrc !== _newTargetSrc) {
55
58
  setTargetSrc(_newTargetSrc);
59
+ newSrcRequired = true;
56
60
  }
57
61
  }
58
62
  if (status === 'PENDING') {
59
63
  setStatus('INITIAL_BREAKPOINT_CALCULATED');
64
+
65
+ // We always load the smallest source. If that's also the source we need
66
+ // set INITIAL_LOADED directly.
67
+ // With caching turned on, the onLoad function on the img would only trigger once
68
+ // and thus never unblur the smallest
69
+ if (!newSrcRequired) {
70
+ setStatus('INITIAL_LOADED');
71
+ }
60
72
  }
61
73
  });
62
74
  resizeObserver.observe(container);
@@ -86,7 +98,11 @@ var AdaptivePicture = function AdaptivePicture(_ref) {
86
98
  if (_onLoad) {
87
99
  _onLoad(e);
88
100
  }
89
- if (status === 'INITIAL_BREAKPOINT_CALCULATED' && e.target.src === targetSrc) {
101
+
102
+ // To handle relative URLs
103
+ var current = urlParse.parse(e.target.src);
104
+ var target = urlParse.parse(targetSrc);
105
+ if (status === 'INITIAL_BREAKPOINT_CALCULATED' && current.pathname === target.pathname) {
90
106
  setStatus('INITIAL_LOADED');
91
107
  }
92
108
  },
@@ -6,7 +6,7 @@ function _iterableToArrayLimit(arr, i) { var _i = null == arr ? null : "undefine
6
6
  function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
7
7
  import path from 'path';
8
8
  import { useEffect, useState } from 'react';
9
- var breakpoints = [0, 256, 512, 1024, 2048];
9
+ var breakpoints = [256, 512, 1024, 2048];
10
10
  var mimeTypes = {
11
11
  '.gif': 'image/gif',
12
12
  '.png': 'image/png',
@@ -1,17 +1,21 @@
1
1
  export default WysiwygField;
2
- declare function WysiwygField({ html, customElementHandler, ...props }: {
2
+ declare function WysiwygField({ html, customElementHandler, className, ...props }: {
3
3
  [x: string]: any;
4
4
  html: any;
5
5
  customElementHandler?: (() => void) | undefined;
6
+ className?: string | undefined;
6
7
  }): React.JSX.Element;
7
8
  declare namespace WysiwygField {
8
9
  namespace propTypes {
9
10
  let html: PropTypes.Validator<string>;
10
11
  let customElementHandler: PropTypes.Requireable<(...args: any[]) => any>;
12
+ let className: PropTypes.Requireable<string>;
11
13
  }
12
14
  namespace defaultProps {
13
15
  export function customElementHandler_1(): void;
14
16
  export { customElementHandler_1 as customElementHandler };
17
+ let className_1: string;
18
+ export { className_1 as className };
15
19
  }
16
20
  }
17
21
  import React from 'react';
@@ -1,16 +1,20 @@
1
- var _excluded = ["html", "customElementHandler"];
1
+ var _excluded = ["html", "customElementHandler", "className"];
2
2
  function _extends() { _extends = Object.assign ? Object.assign.bind() : 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); }
3
3
  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; }
4
4
  function _objectWithoutPropertiesLoose(source, excluded) { if (source == null) return {}; var target = {}; var sourceKeys = Object.keys(source); var key, i; for (i = 0; i < sourceKeys.length; i++) { key = sourceKeys[i]; if (excluded.indexOf(key) >= 0) continue; target[key] = source[key]; } return target; }
5
5
  import React from 'react';
6
6
  import PropTypes from 'prop-types';
7
7
  import ReactHtmlParser from 'react-html-parser';
8
+ import c from 'classnames';
8
9
  import Button from '../Button';
9
10
  var WysiwygField = function WysiwygField(_ref) {
10
11
  var html = _ref.html,
11
12
  _ref$customElementHan = _ref.customElementHandler,
12
13
  customElementHandler = _ref$customElementHan === void 0 ? function () {} : _ref$customElementHan,
14
+ _ref$className = _ref.className,
15
+ className = _ref$className === void 0 ? '' : _ref$className,
13
16
  props = _objectWithoutProperties(_ref, _excluded);
17
+ var classes = c('WysiwygField', className);
14
18
  var parsedHtml = ReactHtmlParser(html, {
15
19
  transform: function transform(node) {
16
20
  var customHandler = customElementHandler(node);
@@ -42,14 +46,16 @@ var WysiwygField = function WysiwygField(_ref) {
42
46
  }
43
47
  });
44
48
  return /*#__PURE__*/React.createElement("div", _extends({
45
- className: "WysiwygField"
49
+ className: classes
46
50
  }, props), parsedHtml);
47
51
  };
48
52
  WysiwygField.propTypes = {
49
53
  html: PropTypes.string.isRequired,
50
- customElementHandler: PropTypes.func
54
+ customElementHandler: PropTypes.func,
55
+ className: PropTypes.string
51
56
  };
52
57
  WysiwygField.defaultProps = {
53
- customElementHandler: function customElementHandler() {}
58
+ customElementHandler: function customElementHandler() {},
59
+ className: ''
54
60
  };
55
61
  export default WysiwygField;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@uncinc/uncinc-react-kitchen-sink",
3
- "version": "2.8.16",
3
+ "version": "2.8.20",
4
4
  "description": "Default React components that are easily extended.",
5
5
  "author": "uncinc",
6
6
  "license": "MIT",