creevey 0.9.0-non-webpack.0 → 0.9.0-non-webpack.1

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 (56) hide show
  1. package/lib/cjs/client/addon/Manager.js +121 -275
  2. package/lib/cjs/client/addon/components/Addon.js +17 -38
  3. package/lib/cjs/client/addon/components/Icons.js +10 -6
  4. package/lib/cjs/client/addon/components/Panel.js +17 -13
  5. package/lib/cjs/client/addon/components/TestSelect.js +11 -9
  6. package/lib/cjs/client/addon/components/Tools.js +21 -40
  7. package/lib/cjs/client/addon/decorator.js +1 -1
  8. package/lib/cjs/client/addon/index.js +2 -2
  9. package/lib/cjs/client/addon/preset.js +11 -30
  10. package/lib/cjs/client/addon/register.js +45 -73
  11. package/lib/cjs/client/addon/utils.js +1 -1
  12. package/lib/cjs/client/addon/withCreevey.js +153 -360
  13. package/lib/cjs/client/shared/components/ImagesView/BlendView.js +23 -21
  14. package/lib/cjs/client/shared/components/ImagesView/ImagesView.js +21 -17
  15. package/lib/cjs/client/shared/components/ImagesView/SideBySideView.js +42 -64
  16. package/lib/cjs/client/shared/components/ImagesView/SlideView.js +35 -48
  17. package/lib/cjs/client/shared/components/ImagesView/SwapView.js +24 -43
  18. package/lib/cjs/client/shared/components/ImagesView/index.js +5 -5
  19. package/lib/cjs/client/shared/components/PageFooter/PageFooter.js +12 -8
  20. package/lib/cjs/client/shared/components/PageFooter/Paging.js +14 -18
  21. package/lib/cjs/client/shared/components/PageHeader/ImagePreview.js +22 -18
  22. package/lib/cjs/client/shared/components/PageHeader/PageHeader.js +42 -67
  23. package/lib/cjs/client/shared/components/ResultsPage.js +38 -68
  24. package/lib/cjs/client/shared/creeveyClientApi.js +55 -86
  25. package/lib/cjs/client/shared/helpers.js +123 -194
  26. package/lib/cjs/client/shared/viewMode.js +4 -4
  27. package/lib/cjs/shared/index.js +26 -14
  28. package/lib/cjs/shared/serializeRegExp.js +5 -4
  29. package/lib/esm/client/addon/Manager.js +121 -275
  30. package/lib/esm/client/addon/components/Addon.js +15 -34
  31. package/lib/esm/client/addon/components/Icons.js +10 -6
  32. package/lib/esm/client/addon/components/Panel.js +17 -13
  33. package/lib/esm/client/addon/components/TestSelect.js +11 -9
  34. package/lib/esm/client/addon/components/Tools.js +19 -36
  35. package/lib/esm/client/addon/decorator.js +1 -1
  36. package/lib/esm/client/addon/preset.js +9 -24
  37. package/lib/esm/client/addon/register.js +42 -70
  38. package/lib/esm/client/addon/utils.js +1 -1
  39. package/lib/esm/client/addon/withCreevey.js +148 -357
  40. package/lib/esm/client/shared/components/ImagesView/BlendView.js +21 -17
  41. package/lib/esm/client/shared/components/ImagesView/ImagesView.js +21 -17
  42. package/lib/esm/client/shared/components/ImagesView/SideBySideView.js +40 -60
  43. package/lib/esm/client/shared/components/ImagesView/SlideView.js +33 -44
  44. package/lib/esm/client/shared/components/ImagesView/SwapView.js +22 -39
  45. package/lib/esm/client/shared/components/PageFooter/PageFooter.js +12 -8
  46. package/lib/esm/client/shared/components/PageFooter/Paging.js +14 -18
  47. package/lib/esm/client/shared/components/PageHeader/ImagePreview.js +22 -18
  48. package/lib/esm/client/shared/components/PageHeader/PageHeader.js +37 -60
  49. package/lib/esm/client/shared/components/ResultsPage.js +36 -64
  50. package/lib/esm/client/shared/creeveyClientApi.js +57 -88
  51. package/lib/esm/client/shared/helpers.js +123 -194
  52. package/lib/esm/client/shared/viewMode.js +4 -4
  53. package/lib/esm/shared/index.js +26 -14
  54. package/lib/esm/shared/serializeRegExp.js +5 -4
  55. package/package.json +1 -1
  56. package/preset.js +1 -1
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -17,25 +15,27 @@ var _helpers = require("../../helpers");
17
15
 
18
16
  var _readyForCapture = require("../../../addon/readyForCapture");
19
17
 
20
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
18
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
21
19
 
22
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
20
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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
21
 
24
- var Container = _theming.styled.div({
22
+ const Container = _theming.styled.div({
25
23
  position: 'relative',
26
24
  display: 'flex',
27
25
  filter: 'invert(100%)'
28
26
  });
29
27
 
30
- var ImageContainer = _theming.styled.div({
28
+ const ImageContainer = _theming.styled.div({
31
29
  position: 'absolute',
32
30
  width: '100%',
33
31
  height: '100%',
34
32
  display: 'flex'
35
33
  });
36
34
 
37
- var Image = _theming.styled.img(function (_ref) {
38
- var borderColor = _ref.borderColor;
35
+ const Image = _theming.styled.img(_ref => {
36
+ let {
37
+ borderColor
38
+ } = _ref;
39
39
  return {
40
40
  boxSizing: 'border-box',
41
41
  border: "1px solid ".concat(borderColor),
@@ -44,25 +44,27 @@ var Image = _theming.styled.img(function (_ref) {
44
44
  };
45
45
  });
46
46
 
47
- var ActualImage = (0, _theming.styled)(Image)({
47
+ const ActualImage = (0, _theming.styled)(Image)({
48
48
  mixBlendMode: 'difference'
49
49
  });
50
- var DiffImage = (0, _theming.styled)(Image)({
50
+ const DiffImage = (0, _theming.styled)(Image)({
51
51
  opacity: '0'
52
52
  });
53
- var BlendView = (0, _theming.withTheme)(function (_ref2) {
54
- var actual = _ref2.actual,
55
- diff = _ref2.diff,
56
- expect = _ref2.expect,
57
- theme = _ref2.theme;
58
- var expectImageRef = (0, _react.useRef)(null);
59
- var diffImageRef = (0, _react.useRef)(null);
60
- var actualImageRef = (0, _react.useRef)(null);
61
- var loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
62
- var scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
53
+ const BlendView = (0, _theming.withTheme)(_ref2 => {
54
+ let {
55
+ actual,
56
+ diff,
57
+ expect,
58
+ theme
59
+ } = _ref2;
60
+ const expectImageRef = (0, _react.useRef)(null);
61
+ const diffImageRef = (0, _react.useRef)(null);
62
+ const actualImageRef = (0, _react.useRef)(null);
63
+ const loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
64
+ const scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
63
65
  (0, _helpers.useApplyScale)(expectImageRef, scale, loaded);
64
66
  (0, _helpers.useApplyScale)(actualImageRef, scale, loaded);
65
- (0, _react.useEffect)(function () {
67
+ (0, _react.useEffect)(() => {
66
68
  if (loaded) (0, _readyForCapture.readyForCapture)();
67
69
  }, [loaded]);
68
70
  return /*#__PURE__*/_react.default.createElement(Container, null, /*#__PURE__*/_react.default.createElement(ImageContainer, null, /*#__PURE__*/_react.default.createElement(Image, {
@@ -21,29 +21,27 @@ var _theming = require("@storybook/theming");
21
21
 
22
22
  function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
23
23
 
24
- var themeBorderColors = {
24
+ const themeBorderColors = {
25
25
  actual: 'negative',
26
26
  expect: 'positive',
27
27
  diff: 'secondary'
28
28
  };
29
29
  exports.themeBorderColors = themeBorderColors;
30
30
 
31
- var isColor = function isColor(theme, color) {
32
- return color in theme.color;
33
- };
31
+ const isColor = (theme, color) => color in theme.color;
34
32
 
35
33
  function getBorderColor(theme, color) {
36
34
  return isColor(theme, color) ? theme.color[color] : color;
37
35
  }
38
36
 
39
- var views = {
37
+ const views = {
40
38
  'side-by-side': _SideBySideView.SideBySideView,
41
39
  swap: _SwapView.SwapView,
42
40
  slide: _SlideView.SlideView,
43
41
  blend: _BlendView.BlendView
44
42
  };
45
43
 
46
- var Container = _theming.styled.div({
44
+ const Container = _theming.styled.div({
47
45
  height: '100%',
48
46
  display: 'flex',
49
47
  textAlign: 'center',
@@ -52,12 +50,14 @@ var Container = _theming.styled.div({
52
50
  padding: '0 20px'
53
51
  });
54
52
 
55
- var ImageLink = _theming.styled.a({
53
+ const ImageLink = _theming.styled.a({
56
54
  lineHeight: 0
57
55
  });
58
56
 
59
- var ActualImage = (0, _theming.withTheme)(_theming.styled.img(function (_ref) {
60
- var theme = _ref.theme;
57
+ const ActualImage = (0, _theming.withTheme)(_theming.styled.img(_ref => {
58
+ let {
59
+ theme
60
+ } = _ref;
61
61
  return {
62
62
  border: "1px solid ".concat(getBorderColor(theme, themeBorderColors.expect)),
63
63
  maxWidth: '100%'
@@ -65,14 +65,18 @@ var ActualImage = (0, _theming.withTheme)(_theming.styled.img(function (_ref) {
65
65
  }));
66
66
 
67
67
  function ImagesView(_ref2) {
68
- var url = _ref2.url,
69
- image = _ref2.image,
70
- canApprove = _ref2.canApprove,
71
- mode = _ref2.mode;
72
- var ViewComponent = views[mode];
73
- var actual = image.actual,
74
- diff = image.diff,
75
- expect = image.expect;
68
+ let {
69
+ url,
70
+ image,
71
+ canApprove,
72
+ mode
73
+ } = _ref2;
74
+ const ViewComponent = views[mode];
75
+ const {
76
+ actual,
77
+ diff,
78
+ expect
79
+ } = image;
76
80
  return /*#__PURE__*/_react.default.createElement(Container, null, canApprove && diff && expect ? /*#__PURE__*/_react.default.createElement(ViewComponent, {
77
81
  actual: "".concat(url, "/").concat(actual),
78
82
  diff: "".concat(url, "/").concat(diff),
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -19,23 +17,11 @@ var _components = require("@storybook/components");
19
17
 
20
18
  var _readyForCapture = require("../../../addon/readyForCapture");
21
19
 
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
25
-
26
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
-
28
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
29
21
 
30
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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
23
 
32
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
33
-
34
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
-
36
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- var Container = _theming.styled.div({
24
+ const Container = _theming.styled.div({
39
25
  display: 'flex',
40
26
  flexWrap: 'nowrap',
41
27
  alignItems: 'center',
@@ -44,8 +30,10 @@ var Container = _theming.styled.div({
44
30
  width: '100%'
45
31
  });
46
32
 
47
- var ImagesLayout = _theming.styled.div(function (_ref) {
48
- var layout = _ref.layout;
33
+ const ImagesLayout = _theming.styled.div(_ref => {
34
+ let {
35
+ layout
36
+ } = _ref;
49
37
  return {
50
38
  display: 'flex',
51
39
  alignItems: 'flex-start',
@@ -58,17 +46,19 @@ var ImagesLayout = _theming.styled.div(function (_ref) {
58
46
  };
59
47
  });
60
48
 
61
- var ImageLink = _theming.styled.a({
49
+ const ImageLink = _theming.styled.a({
62
50
  lineHeight: 0,
63
51
  flexShrink: 0
64
52
  });
65
53
 
66
- var ImageDiffLink = _theming.styled.a({
54
+ const ImageDiffLink = _theming.styled.a({
67
55
  lineHeight: 0
68
56
  });
69
57
 
70
- var Image = _theming.styled.img(function (_ref2) {
71
- var borderColor = _ref2.borderColor;
58
+ const Image = _theming.styled.img(_ref2 => {
59
+ let {
60
+ borderColor
61
+ } = _ref2;
72
62
  return {
73
63
  boxSizing: 'border-box',
74
64
  border: "1px solid ".concat(borderColor),
@@ -77,65 +67,53 @@ var Image = _theming.styled.img(function (_ref2) {
77
67
  };
78
68
  });
79
69
 
80
- var DiffImage = (0, _theming.styled)(Image)({
70
+ const DiffImage = (0, _theming.styled)(Image)({
81
71
  flexShrink: 1
82
72
  });
83
- var SideBySideView = (0, _theming.withTheme)(function (_ref3) {
84
- var actual = _ref3.actual,
85
- diff = _ref3.diff,
86
- expect = _ref3.expect,
87
- theme = _ref3.theme;
88
-
89
- var _useState = (0, _react.useState)('horizontal'),
90
- _useState2 = _slicedToArray(_useState, 2),
91
- layout = _useState2[0],
92
- setLayout = _useState2[1];
93
-
94
- var _useState3 = (0, _react.useState)(1),
95
- _useState4 = _slicedToArray(_useState3, 2),
96
- scale = _useState4[0],
97
- setScale = _useState4[1];
98
-
99
- var containerRef = (0, _react.useRef)(null);
100
- var expectImageRef = (0, _react.useRef)(null);
101
- var diffImageRef = (0, _react.useRef)(null);
102
- var actualImageRef = (0, _react.useRef)(null);
103
- var loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
104
- var calcScale = (0, _react.useCallback)(function () {
105
- var containerElement = containerRef.current;
106
- var expectImage = expectImageRef.current;
107
- var diffImage = diffImageRef.current;
108
- var actualImage = actualImageRef.current;
73
+ const SideBySideView = (0, _theming.withTheme)(_ref3 => {
74
+ let {
75
+ actual,
76
+ diff,
77
+ expect,
78
+ theme
79
+ } = _ref3;
80
+ const [layout, setLayout] = (0, _react.useState)('horizontal');
81
+ const [scale, setScale] = (0, _react.useState)(1);
82
+ const containerRef = (0, _react.useRef)(null);
83
+ const expectImageRef = (0, _react.useRef)(null);
84
+ const diffImageRef = (0, _react.useRef)(null);
85
+ const actualImageRef = (0, _react.useRef)(null);
86
+ const loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
87
+ const calcScale = (0, _react.useCallback)(() => {
88
+ const containerElement = containerRef.current;
89
+ const expectImage = expectImageRef.current;
90
+ const diffImage = diffImageRef.current;
91
+ const actualImage = actualImageRef.current;
109
92
  if (!containerElement || !expectImage || !actualImage || !diffImage || !loaded) return setScale(1);
110
- var borderSize = (0, _helpers.getBorderSize)(diffImage);
93
+ const borderSize = (0, _helpers.getBorderSize)(diffImage);
111
94
 
112
95
  if (layout == 'vertical') {
113
- var ratio = (diffImage.getBoundingClientRect().width - borderSize * 2) / diffImage.naturalWidth;
96
+ const ratio = (diffImage.getBoundingClientRect().width - borderSize * 2) / diffImage.naturalWidth;
114
97
  setScale(Math.min(1, ratio));
115
98
  }
116
99
 
117
100
  if (layout == 'horizontal') {
118
- var _ratio = // NOTE: 40px because we have two margins by 20px and 6px for borders
119
- (containerElement.getBoundingClientRect().width - 40 - borderSize * 6) / [expectImage, diffImage, actualImage].map(function (image) {
120
- return image.naturalWidth;
121
- }).reduce(function (a, b) {
122
- return a + b;
123
- }, 0);
124
-
125
- setScale(Math.min(1, _ratio));
101
+ const ratio = // NOTE: 40px because we have two margins by 20px and 6px for borders
102
+ (containerElement.getBoundingClientRect().width - 40 - borderSize * 6) / [expectImage, diffImage, actualImage].map(image => image.naturalWidth).reduce((a, b) => a + b, 0);
103
+ setScale(Math.min(1, ratio));
126
104
  }
127
105
  }, [loaded, layout]);
128
106
  (0, _helpers.useResizeObserver)(containerRef, calcScale);
129
107
  (0, _react.useLayoutEffect)(calcScale, [calcScale]);
130
- (0, _react.useLayoutEffect)(function () {
131
- var diffImage = diffImageRef.current;
108
+ (0, _react.useLayoutEffect)(() => {
109
+ const diffImage = diffImageRef.current;
132
110
  if (!diffImage || !loaded) return;
133
- var ratio = diffImage.naturalWidth / diffImage.naturalHeight;
111
+ const ratio = diffImage.naturalWidth / diffImage.naturalHeight;
134
112
  setLayout(ratio >= 2 ? 'vertical' : 'horizontal');
135
113
  }, [loaded]);
136
114
  (0, _helpers.useApplyScale)(expectImageRef, scale);
137
115
  (0, _helpers.useApplyScale)(actualImageRef, scale);
138
- (0, _react.useEffect)(function () {
116
+ (0, _react.useEffect)(() => {
139
117
  if (loaded) (0, _readyForCapture.readyForCapture)();
140
118
  }, [loaded]);
141
119
  return /*#__PURE__*/_react.default.createElement(Container, {
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -19,28 +17,16 @@ var _components = require("@storybook/components");
19
17
 
20
18
  var _readyForCapture = require("../../../addon/readyForCapture");
21
19
 
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
25
-
26
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
-
28
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
29
-
30
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
21
 
32
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
33
23
 
34
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
-
36
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- var Container = _theming.styled.div({
24
+ const Container = _theming.styled.div({
39
25
  position: 'relative',
40
26
  display: 'flex'
41
27
  });
42
28
 
43
- var Input = _theming.styled.input({
29
+ const Input = _theming.styled.input({
44
30
  position: 'absolute',
45
31
  cursor: 'ew-resize',
46
32
  appearance: 'none',
@@ -74,15 +60,17 @@ var Input = _theming.styled.input({
74
60
  }
75
61
  });
76
62
 
77
- var ImageContainer = _theming.styled.div({
63
+ const ImageContainer = _theming.styled.div({
78
64
  position: 'absolute',
79
65
  width: '100%',
80
66
  height: '100%',
81
67
  overflow: 'hidden'
82
68
  });
83
69
 
84
- var ImageWrapper = (0, _theming.withTheme)(_theming.styled.div(function (_ref) {
85
- var theme = _ref.theme;
70
+ const ImageWrapper = (0, _theming.withTheme)(_theming.styled.div(_ref => {
71
+ let {
72
+ theme
73
+ } = _ref;
86
74
  return {
87
75
  background: theme.base == 'light' ? theme.color.mediumlight : theme.color.darker,
88
76
  position: 'relative',
@@ -92,8 +80,10 @@ var ImageWrapper = (0, _theming.withTheme)(_theming.styled.div(function (_ref) {
92
80
  };
93
81
  }));
94
82
 
95
- var BaseImage = _theming.styled.img(function (_ref2) {
96
- var borderColor = _ref2.borderColor;
83
+ const BaseImage = _theming.styled.img(_ref2 => {
84
+ let {
85
+ borderColor
86
+ } = _ref2;
97
87
  return {
98
88
  boxSizing: 'border-box',
99
89
  border: "1px solid ".concat(borderColor),
@@ -101,48 +91,45 @@ var BaseImage = _theming.styled.img(function (_ref2) {
101
91
  };
102
92
  });
103
93
 
104
- var Image = (0, _theming.styled)(BaseImage)({
94
+ const Image = (0, _theming.styled)(BaseImage)({
105
95
  position: 'absolute'
106
96
  });
107
- var DiffImage = (0, _theming.styled)(BaseImage)({
97
+ const DiffImage = (0, _theming.styled)(BaseImage)({
108
98
  opacity: '0'
109
99
  });
110
- var SlideView = (0, _theming.withTheme)(function (_ref3) {
111
- var actual = _ref3.actual,
112
- diff = _ref3.diff,
113
- expect = _ref3.expect,
114
- theme = _ref3.theme;
115
-
116
- var _useState = (0, _react.useState)(0),
117
- _useState2 = _slicedToArray(_useState, 2),
118
- step = _useState2[0],
119
- setStep = _useState2[1];
120
-
121
- var expectedImageContainerRef = (0, _react.useRef)(null);
122
- var expectedImageWrapperRef = (0, _react.useRef)(null);
123
- var expectImageRef = (0, _react.useRef)(null);
124
- var diffImageRef = (0, _react.useRef)(null);
125
- var actualImageRef = (0, _react.useRef)(null);
126
- var loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
127
- var scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
100
+ const SlideView = (0, _theming.withTheme)(_ref3 => {
101
+ let {
102
+ actual,
103
+ diff,
104
+ expect,
105
+ theme
106
+ } = _ref3;
107
+ const [step, setStep] = (0, _react.useState)(0);
108
+ const expectedImageContainerRef = (0, _react.useRef)(null);
109
+ const expectedImageWrapperRef = (0, _react.useRef)(null);
110
+ const expectImageRef = (0, _react.useRef)(null);
111
+ const diffImageRef = (0, _react.useRef)(null);
112
+ const actualImageRef = (0, _react.useRef)(null);
113
+ const loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
114
+ const scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
128
115
  (0, _helpers.useApplyScale)(expectImageRef, scale);
129
116
  (0, _helpers.useApplyScale)(actualImageRef, scale);
130
- var handleSlide = (0, _react.useCallback)(function (event) {
117
+ const handleSlide = (0, _react.useCallback)(event => {
131
118
  if (!expectedImageContainerRef.current || !expectedImageWrapperRef.current) return;
132
- var offset = Number(event.target.value);
119
+ const offset = Number(event.target.value);
133
120
  expectedImageContainerRef.current.style.right = "".concat(100 - offset, "%");
134
121
  expectedImageWrapperRef.current.style.left = "".concat(100 - offset, "%");
135
122
  }, []);
136
- (0, _react.useLayoutEffect)(function () {
123
+ (0, _react.useLayoutEffect)(() => {
137
124
  if (loaded && diffImageRef.current) setStep(100 / diffImageRef.current.getBoundingClientRect().width);
138
125
  }, [loaded, scale]);
139
- (0, _react.useLayoutEffect)(function () {
126
+ (0, _react.useLayoutEffect)(() => {
140
127
  if (loaded && expectedImageContainerRef.current && expectedImageWrapperRef.current) {
141
128
  expectedImageContainerRef.current.style.right = '100%';
142
129
  expectedImageWrapperRef.current.style.left = '100%';
143
130
  }
144
131
  }, [loaded]);
145
- (0, _react.useEffect)(function () {
132
+ (0, _react.useEffect)(() => {
146
133
  if (loaded) (0, _readyForCapture.readyForCapture)();
147
134
  }, [loaded]);
148
135
  return loaded ? /*#__PURE__*/_react.default.createElement(Container, null, /*#__PURE__*/_react.default.createElement(Input, {
@@ -1,7 +1,5 @@
1
1
  "use strict";
2
2
 
3
- function _typeof(obj) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (obj) { return typeof obj; } : function (obj) { return obj && "function" == typeof Symbol && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; }, _typeof(obj); }
4
-
5
3
  Object.defineProperty(exports, "__esModule", {
6
4
  value: true
7
5
  });
@@ -19,29 +17,19 @@ var _components = require("@storybook/components");
19
17
 
20
18
  var _readyForCapture = require("../../../addon/readyForCapture");
21
19
 
22
- function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
23
-
24
- function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
25
-
26
- function _slicedToArray(arr, i) { return _arrayWithHoles(arr) || _iterableToArrayLimit(arr, i) || _unsupportedIterableToArray(arr, i) || _nonIterableRest(); }
27
-
28
- function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
29
-
30
- function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
20
+ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function (nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
31
21
 
32
- function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
22
+ function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || typeof obj !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && 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; }
33
23
 
34
- function _iterableToArrayLimit(arr, i) { var _i = arr == null ? null : typeof Symbol !== "undefined" && arr[Symbol.iterator] || arr["@@iterator"]; if (_i == null) return; var _arr = []; var _n = true; var _d = false; var _s, _e; try { for (_i = _i.call(arr); !(_n = (_s = _i.next()).done); _n = true) { _arr.push(_s.value); if (i && _arr.length === i) break; } } catch (err) { _d = true; _e = err; } finally { try { if (!_n && _i["return"] != null) _i["return"](); } finally { if (_d) throw _e; } } return _arr; }
35
-
36
- function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
37
-
38
- var Container = _theming.styled.div({
24
+ const Container = _theming.styled.div({
39
25
  position: 'relative',
40
26
  display: 'flex'
41
27
  });
42
28
 
43
- var BaseImage = _theming.styled.img(function (_ref) {
44
- var borderColor = _ref.borderColor;
29
+ const BaseImage = _theming.styled.img(_ref => {
30
+ let {
31
+ borderColor
32
+ } = _ref;
45
33
  return {
46
34
  boxSizing: 'border-box',
47
35
  border: "1px solid ".concat(borderColor),
@@ -49,39 +37,32 @@ var BaseImage = _theming.styled.img(function (_ref) {
49
37
  };
50
38
  });
51
39
 
52
- var Image = (0, _theming.styled)(BaseImage)({
40
+ const Image = (0, _theming.styled)(BaseImage)({
53
41
  position: 'absolute'
54
42
  });
55
- var DiffImage = (0, _theming.styled)(BaseImage)({
43
+ const DiffImage = (0, _theming.styled)(BaseImage)({
56
44
  cursor: 'pointer',
57
45
  outline: 'none',
58
46
  opacity: 0,
59
47
  zIndex: 1
60
48
  });
61
- var SwapView = (0, _theming.withTheme)(function (_ref2) {
62
- var theme = _ref2.theme,
63
- expect = _ref2.expect,
64
- actual = _ref2.actual,
65
- diff = _ref2.diff;
66
-
67
- var _useState = (0, _react.useState)('actual'),
68
- _useState2 = _slicedToArray(_useState, 2),
69
- image = _useState2[0],
70
- setImage = _useState2[1];
71
-
72
- var expectImageRef = (0, _react.useRef)(null);
73
- var diffImageRef = (0, _react.useRef)(null);
74
- var actualImageRef = (0, _react.useRef)(null);
75
- var loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
76
- var scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
49
+ const SwapView = (0, _theming.withTheme)(_ref2 => {
50
+ let {
51
+ theme,
52
+ expect,
53
+ actual,
54
+ diff
55
+ } = _ref2;
56
+ const [image, setImage] = (0, _react.useState)('actual');
57
+ const expectImageRef = (0, _react.useRef)(null);
58
+ const diffImageRef = (0, _react.useRef)(null);
59
+ const actualImageRef = (0, _react.useRef)(null);
60
+ const loaded = (0, _helpers.useLoadImages)(expect, diff, actual);
61
+ const scale = (0, _helpers.useCalcScale)(diffImageRef, loaded);
77
62
  (0, _helpers.useApplyScale)(expectImageRef, scale, image);
78
63
  (0, _helpers.useApplyScale)(actualImageRef, scale, image);
79
- var handleChangeView = (0, _react.useCallback)(function () {
80
- return setImage(function (prevImage) {
81
- return prevImage == 'actual' ? 'expect' : 'actual';
82
- });
83
- }, []);
84
- (0, _react.useEffect)(function () {
64
+ const handleChangeView = (0, _react.useCallback)(() => setImage(prevImage => prevImage == 'actual' ? 'expect' : 'actual'), []);
65
+ (0, _react.useEffect)(() => {
85
66
  if (loaded) (0, _readyForCapture.readyForCapture)();
86
67
  }, [loaded]);
87
68
  return loaded ? /*#__PURE__*/_react.default.createElement(Container, null, /*#__PURE__*/_react.default.createElement(Image, {
@@ -5,31 +5,31 @@ Object.defineProperty(exports, "__esModule", {
5
5
  });
6
6
  Object.defineProperty(exports, "BlendView", {
7
7
  enumerable: true,
8
- get: function get() {
8
+ get: function () {
9
9
  return _BlendView.BlendView;
10
10
  }
11
11
  });
12
12
  Object.defineProperty(exports, "ImagesView", {
13
13
  enumerable: true,
14
- get: function get() {
14
+ get: function () {
15
15
  return _ImagesView.ImagesView;
16
16
  }
17
17
  });
18
18
  Object.defineProperty(exports, "SideBySideView", {
19
19
  enumerable: true,
20
- get: function get() {
20
+ get: function () {
21
21
  return _SideBySideView.SideBySideView;
22
22
  }
23
23
  });
24
24
  Object.defineProperty(exports, "SlideView", {
25
25
  enumerable: true,
26
- get: function get() {
26
+ get: function () {
27
27
  return _SlideView.SlideView;
28
28
  }
29
29
  });
30
30
  Object.defineProperty(exports, "SwapView", {
31
31
  enumerable: true,
32
- get: function get() {
32
+ get: function () {
33
33
  return _SwapView.SwapView;
34
34
  }
35
35
  });