@atlaskit/smart-card 19.1.7 → 19.1.10

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 (34) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/utils/index.js +8 -2
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/cjs/view/CardWithUrl/component-lazy/index.js +3 -3
  5. package/dist/cjs/view/EmbedCard/components/styled.js +29 -13
  6. package/dist/cjs/view/FlexibleCard/components/container/index.js +3 -2
  7. package/dist/cjs/view/FlexibleCard/components/container/layered-link/index.js +3 -1
  8. package/dist/cjs/view/FlexibleCard/components/elements/media/index.js +1 -1
  9. package/dist/es2019/utils/index.js +2 -1
  10. package/dist/es2019/version.json +1 -1
  11. package/dist/es2019/view/CardWithUrl/component-lazy/index.js +1 -1
  12. package/dist/es2019/view/EmbedCard/components/styled.js +22 -4
  13. package/dist/es2019/view/FlexibleCard/components/container/index.js +3 -2
  14. package/dist/es2019/view/FlexibleCard/components/container/layered-link/index.js +2 -0
  15. package/dist/es2019/view/FlexibleCard/components/elements/media/index.js +1 -0
  16. package/dist/esm/state/actions/index.js +1 -1
  17. package/dist/esm/state/hooks/usePrefetch.js +1 -1
  18. package/dist/esm/utils/index.js +3 -0
  19. package/dist/esm/utils/mocks.js +1 -1
  20. package/dist/esm/version.json +1 -1
  21. package/dist/esm/view/BlockCard/actions/DownloadAction.js +1 -1
  22. package/dist/esm/view/BlockCard/actions/PreviewAction.js +1 -1
  23. package/dist/esm/view/BlockCard/actions/RetryAction.js +1 -1
  24. package/dist/esm/view/BlockCard/actions/ViewAction.js +1 -1
  25. package/dist/esm/view/CardWithUrl/component-lazy/index.js +1 -1
  26. package/dist/esm/view/EmbedCard/components/styled.js +14 -4
  27. package/dist/esm/view/FlexibleCard/components/container/index.js +3 -2
  28. package/dist/esm/view/FlexibleCard/components/container/layered-link/index.js +3 -1
  29. package/dist/esm/view/FlexibleCard/components/elements/media/index.js +1 -1
  30. package/dist/types/utils/index.d.ts +1 -0
  31. package/dist/types/view/EmbedCard/components/styled.d.ts +3 -0
  32. package/dist/types/view/FlexibleCard/components/container/layered-link/types.d.ts +6 -0
  33. package/dist/types/view/__mocks__/intersection-observer.mock.d.ts +12 -0
  34. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 19.1.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [`009e3475b29`](https://bitbucket.org/atlassian/atlassian-frontend/commits/009e3475b29) - Duplicate isIntersectionObserverSupported from media-ui to smart-card
8
+
9
+ ## 19.1.9
10
+
11
+ ### Patch Changes
12
+
13
+ - [`003ac36263e`](https://bitbucket.org/atlassian/atlassian-frontend/commits/003ac36263e) - Flexible UI: Fix preview block showing white space below image in Safari
14
+
15
+ ## 19.1.8
16
+
17
+ ### Patch Changes
18
+
19
+ - [`81968c216ce`](https://bitbucket.org/atlassian/atlassian-frontend/commits/81968c216ce) - Flexible UI: Fix clickableContainer not triggering analytics event
20
+
3
21
  ## 19.1.7
4
22
 
5
23
  ### Patch Changes
@@ -7,7 +7,7 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.isSpecialKey = exports.isSpecialEvent = exports.isSpecialClick = exports.isIframe = exports.isCardWithData = exports.handleOnClick = exports.getLabelForFileType = exports.getIframeSandboxAttribute = exports.getIconForFileType = void 0;
10
+ exports.isSpecialKey = exports.isSpecialEvent = exports.isSpecialClick = exports.isIntersectionObserverSupported = exports.isIframe = exports.isCardWithData = exports.handleOnClick = exports.getLabelForFileType = exports.getIframeSandboxAttribute = exports.getIconForFileType = void 0;
11
11
 
12
12
  var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
13
13
 
@@ -368,4 +368,10 @@ var handleOnClick = function handleOnClick(handler) {
368
368
  };
369
369
  };
370
370
 
371
- exports.handleOnClick = handleOnClick;
371
+ exports.handleOnClick = handleOnClick;
372
+
373
+ var isIntersectionObserverSupported = function isIntersectionObserverSupported() {
374
+ return typeof IntersectionObserver !== 'undefined';
375
+ };
376
+
377
+ exports.isIntersectionObserverSupported = isIntersectionObserverSupported;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.7",
3
+ "version": "19.1.10",
4
4
  "sideEffects": false
5
5
  }
@@ -9,14 +9,14 @@ exports.default = LazyCardWithUrlContent;
9
9
 
10
10
  var _react = _interopRequireDefault(require("react"));
11
11
 
12
- var _mediaUi = require("@atlaskit/media-ui");
13
-
14
12
  var _LazyLazilyRenderCard = require("./LazyLazilyRenderCard");
15
13
 
16
14
  var _LazyIntersectionObserverCard = require("./LazyIntersectionObserverCard");
17
15
 
16
+ var _utils = require("../../../utils");
17
+
18
18
  function LazyCardWithUrlContent(props) {
19
- if ((0, _mediaUi.isIntersectionObserverSupported)()) {
19
+ if ((0, _utils.isIntersectionObserverSupported)()) {
20
20
  return /*#__PURE__*/_react.default.createElement(_LazyIntersectionObserverCard.LazyIntersectionObserverCard, props);
21
21
  } else {
22
22
  return /*#__PURE__*/_react.default.createElement(_LazyLazilyRenderCard.LazyLazilyRenderCard, props);
@@ -7,14 +7,12 @@ var _typeof = require("@babel/runtime/helpers/typeof");
7
7
  Object.defineProperty(exports, "__esModule", {
8
8
  value: true
9
9
  });
10
- exports.maxAvatarCount = exports.embedHeaderHeight = exports.className = exports.cardShadow = exports.Wrapper = exports.UsersWrapper = exports.Title = exports.Thumbnail = exports.TextWrapper = exports.ResolvedViewIconWrapper = exports.LinkWrapper = exports.Image = exports.IconWrapper = exports.Header = exports.Description = exports.ContentWrapper = exports.Content = exports.Byline = exports.AlertWrapper = exports.ActionsWrapper = void 0;
10
+ exports.maxAvatarCount = exports.embedHeaderHeight = exports.ellipsis = exports.csssize = exports.className = exports.cardShadow = exports.borderRadius = exports.Wrapper = exports.UsersWrapper = exports.Title = exports.Thumbnail = exports.TextWrapper = exports.ResolvedViewIconWrapper = exports.LinkWrapper = exports.Image = exports.IconWrapper = exports.Header = exports.Description = exports.ContentWrapper = exports.Content = exports.Byline = exports.AlertWrapper = exports.ActionsWrapper = void 0;
11
11
 
12
12
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
13
13
 
14
14
  var _styled = _interopRequireDefault(require("@emotion/styled"));
15
15
 
16
- var _mediaUi = require("@atlaskit/media-ui");
17
-
18
16
  var _constants = require("@atlaskit/theme/constants");
19
17
 
20
18
  var colors = _interopRequireWildcard(require("@atlaskit/theme/colors"));
@@ -33,6 +31,24 @@ var className = 'media-card-frame';
33
31
  exports.className = className;
34
32
  var cardShadow = "";
35
33
  exports.cardShadow = cardShadow;
34
+ var borderRadius = "\n border-radius: ".concat((0, _constants.borderRadius)(), "px;\n");
35
+ exports.borderRadius = borderRadius;
36
+
37
+ var ellipsis = function ellipsis() {
38
+ var maxWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '100%';
39
+ var unit = typeof maxWidth === 'number' ? 'px' : '';
40
+ return "\n max-width: ".concat(maxWidth).concat(unit, ";\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n ");
41
+ };
42
+
43
+ exports.ellipsis = ellipsis;
44
+
45
+ var csssize = function csssize() {
46
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '100%';
47
+ var unit = typeof value === 'number' ? 'px' : '';
48
+ return "\n width: ".concat(value).concat(unit, ";\n height: ").concat(value).concat(unit, ";\n ");
49
+ };
50
+
51
+ exports.csssize = csssize;
36
52
 
37
53
  function minWidth(_ref) {
38
54
  var minWidth = _ref.minWidth;
@@ -64,7 +80,7 @@ function getinteractiveStyles(_ref3) {
64
80
 
65
81
  function selected(_ref4) {
66
82
  var isSelected = _ref4.isSelected;
67
- return isSelected ? "\n ".concat(visibleStyles, "\n &::after {\n cursor: pointer;\n box-shadow: 0 0 0 3px ").concat((0, _tokens.token)('color.border.selected', colors.B100), ";\n content: '';\n outline: none;\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n ").concat(_mediaUi.borderRadius, "\n }\n ") : '';
83
+ return isSelected ? "\n ".concat(visibleStyles, "\n &::after {\n cursor: pointer;\n box-shadow: 0 0 0 3px ").concat((0, _tokens.token)('color.border.selected', colors.B100), ";\n content: '';\n outline: none;\n position: absolute;\n height: 100%;\n width: 100%;\n left: 0;\n ").concat(borderRadius, "\n }\n ") : '';
68
84
  }
69
85
 
70
86
  var height = function height(_ref5) {
@@ -73,7 +89,7 @@ var height = function height(_ref5) {
73
89
  };
74
90
 
75
91
  var wrapperStyles = function wrapperStyles(props) {
76
- return "\n ".concat(_mediaUi.borderRadius, "\n ").concat(minWidth(props), "\n ").concat(maxWidth(props), "\n ").concat(getinteractiveStyles(props), "\n ").concat(visible(props), "\n display: inline-flex;\n flex-direction: column;\n box-sizing: border-box;\n font-family: ").concat((0, _constants.fontFamily)(), ";\n width: 100%;\n user-select: none;\n line-height: initial;\n transition: background 0.3s;\n position: relative;\n ").concat(height(props), ";\n ").concat(selected(props), "\n\n &:after {\n content: '';\n background: transparent;\n transition: background 0.3s, box-shadow 0.3s;\n position: absolute;\n width: calc(100% + ").concat((0, _utils.gs)(2), ");\n height: calc(100% + ").concat((0, _utils.gs)(1), ");\n left: -").concat((0, _utils.gs)(1), ";\n ").concat(_mediaUi.borderRadius, "\n }\n");
92
+ return "\n ".concat(borderRadius, "\n ").concat(minWidth(props), "\n ").concat(maxWidth(props), "\n ").concat(getinteractiveStyles(props), "\n ").concat(visible(props), "\n display: inline-flex;\n flex-direction: column;\n box-sizing: border-box;\n font-family: ").concat((0, _constants.fontFamily)(), ";\n width: 100%;\n user-select: none;\n line-height: initial;\n transition: background 0.3s;\n position: relative;\n ").concat(height(props), ";\n ").concat(selected(props), "\n\n &:after {\n content: '';\n background: transparent;\n transition: background 0.3s, box-shadow 0.3s;\n position: absolute;\n width: calc(100% + ").concat((0, _utils.gs)(2), ");\n height: calc(100% + ").concat((0, _utils.gs)(1), ");\n left: -").concat((0, _utils.gs)(1), ";\n ").concat(borderRadius, "\n }\n");
77
93
  };
78
94
 
79
95
  var visibleStyles = "\n background-color: ".concat((0, _tokens.token)('color.background.neutral.subtle', colors.N30), ";\n\n &:after {\n background: ").concat((0, _tokens.token)('color.background.neutral', colors.N30), " !important;\n }\n .embed-header {\n opacity: 1;\n }");
@@ -101,7 +117,7 @@ var Header = _styled.default.div(_templateObject3 || (_templateObject3 = (0, _ta
101
117
 
102
118
  exports.Header = Header;
103
119
 
104
- var IconWrapper = _styled.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n ", " margin-right: 4px;\n"])), _mediaUi.borderRadius, (0, _mediaUi.size)(16), function (_ref7) {
120
+ var IconWrapper = _styled.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n ", " margin-right: 4px;\n"])), borderRadius, csssize(16), function (_ref7) {
105
121
  var isPlaceholder = _ref7.isPlaceholder;
106
122
 
107
123
  if (isPlaceholder) {
@@ -117,18 +133,18 @@ var TextWrapper = _styled.default.div(_templateObject5 || (_templateObject5 = (0
117
133
  var isPlaceholder = _ref8.isPlaceholder;
118
134
 
119
135
  if (isPlaceholder) {
120
- return "\n ".concat(_mediaUi.borderRadius, "\n width: 125px;\n height: 12px;\n background-color: ").concat((0, _tokens.token)('color.skeleton', colors.N30), ";\n ");
136
+ return "\n ".concat(borderRadius, "\n width: 125px;\n height: 12px;\n background-color: ").concat((0, _tokens.token)('color.skeleton', colors.N30), ";\n ");
121
137
  } else {
122
138
  return '';
123
139
  }
124
- }, (0, _tokens.token)('color.text.subtlest', colors.N300), (0, _mediaUi.ellipsis)('none'));
140
+ }, (0, _tokens.token)('color.text.subtlest', colors.N300), ellipsis('none'));
125
141
 
126
142
  exports.TextWrapper = TextWrapper;
127
143
 
128
144
  // NB: `overflow` is kept as `hidden` since
129
145
  // the internal contents of the `iframe` should
130
146
  // manage scrolling behaviour.
131
- var Content = _styled.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n background-color: ", ";\n position: absolute;\n z-index: 1;\n width: 100%;\n top: ", ";\n overflow: hidden;\n height: calc(100% - ", ");\n transition: box-shadow 0.3s;\n\n > .calc-height > div > div {\n left: unset !important;\n width: unset !important;\n height: unset !important;\n position: initial !important;\n padding-bottom: unset !important;\n }\n > .embed-preview > div {\n margin: 0 auto;\n }\n\n ", ";\n"])), _mediaUi.borderRadius, cardShadow, (0, _tokens.token)('elevation.surface', 'white'), (0, _utils.gs)(4), (0, _utils.gs)(4), function (_ref9) {
147
+ var Content = _styled.default.div(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n background-color: ", ";\n position: absolute;\n z-index: 1;\n width: 100%;\n top: ", ";\n overflow: hidden;\n height: calc(100% - ", ");\n transition: box-shadow 0.3s;\n\n > .calc-height > div > div {\n left: unset !important;\n width: unset !important;\n height: unset !important;\n position: initial !important;\n padding-bottom: unset !important;\n }\n > .embed-preview > div {\n margin: 0 auto;\n }\n\n ", ";\n"])), borderRadius, cardShadow, (0, _tokens.token)('elevation.surface', 'white'), (0, _utils.gs)(4), (0, _utils.gs)(4), function (_ref9) {
132
148
  var isInteractive = _ref9.isInteractive;
133
149
 
134
150
  if (isInteractive) {
@@ -142,8 +158,8 @@ exports.Content = Content;
142
158
 
143
159
  var Image = _styled.default.img(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n\n /* hide the alt text when the image cannot be found */\n overflow: hidden;\n"])), function (_ref10) {
144
160
  var size = _ref10.size;
145
- return (0, _mediaUi.size)(size);
146
- }, _mediaUi.borderRadius);
161
+ return csssize(size);
162
+ }, borderRadius);
147
163
 
148
164
  exports.Image = Image;
149
165
  var maxAvatarCount = 6;
@@ -157,7 +173,7 @@ var Title = _styled.default.div(_templateObject9 || (_templateObject9 = (0, _tag
157
173
 
158
174
  exports.Title = Title;
159
175
 
160
- var Byline = _styled.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n margin-top: 4px;\n color: ", ";\n font-size: 12px;\n font-weight: normal;\n line-height: ", ";\n ", ";\n"])), (0, _tokens.token)('color.text.subtlest', colors.N300), 16 / 12, (0, _mediaUi.ellipsis)('100%'));
176
+ var Byline = _styled.default.div(_templateObject10 || (_templateObject10 = (0, _taggedTemplateLiteral2.default)(["\n margin-top: 4px;\n color: ", ";\n font-size: 12px;\n font-weight: normal;\n line-height: ", ";\n ", ";\n"])), (0, _tokens.token)('color.text.subtlest', colors.N300), 16 / 12, ellipsis('100%'));
161
177
 
162
178
  exports.Byline = Byline;
163
179
 
@@ -169,7 +185,7 @@ var ResolvedViewIconWrapper = _styled.default.div(_templateObject12 || (_templat
169
185
 
170
186
  exports.ResolvedViewIconWrapper = ResolvedViewIconWrapper;
171
187
 
172
- var Thumbnail = _styled.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n float: right;\n margin: 4px 0 12px 12px;\n background-color: ", ";\n background-image: url(", ");\n background-size: cover;\n"])), _mediaUi.borderRadius, (0, _mediaUi.size)(48), (0, _tokens.token)('color.skeleton', colors.N30), function (_ref11) {
188
+ var Thumbnail = _styled.default.div(_templateObject13 || (_templateObject13 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n ", "\n float: right;\n margin: 4px 0 12px 12px;\n background-color: ", ";\n background-image: url(", ");\n background-size: cover;\n"])), borderRadius, csssize(48), (0, _tokens.token)('color.skeleton', colors.N30), function (_ref11) {
173
189
  var src = _ref11.src;
174
190
  return src;
175
191
  });
@@ -109,7 +109,7 @@ var getTitleBlockProps = function getTitleBlockProps(children) {
109
109
  }
110
110
  };
111
111
 
112
- var getLayeredLink = function getLayeredLink(testId, context, children) {
112
+ var getLayeredLink = function getLayeredLink(testId, context, children, onClick) {
113
113
  var _ref = context || {},
114
114
  title = _ref.title,
115
115
  _ref$url = _ref.url,
@@ -120,6 +120,7 @@ var getLayeredLink = function getLayeredLink(testId, context, children) {
120
120
  text = _ref2.text;
121
121
 
122
122
  return (0, _core.jsx)(_layeredLink.default, {
123
+ onClick: onClick,
123
124
  target: target,
124
125
  testId: testId,
125
126
  text: text || title,
@@ -160,7 +161,7 @@ var Container = function Container(_ref3) {
160
161
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
161
162
  "data-smart-link-container": true,
162
163
  "data-testid": testId
163
- }, clickableContainer ? getLayeredLink(testId, context, children) : null, renderChildren(children, size, theme, status, retry, onClick));
164
+ }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
164
165
  };
165
166
 
166
167
  var _default = Container;
@@ -23,7 +23,8 @@ var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTem
23
23
  */
24
24
 
25
25
  var LayeredLink = function LayeredLink(_ref) {
26
- var target = _ref.target,
26
+ var onClick = _ref.onClick,
27
+ target = _ref.target,
27
28
  testId = _ref.testId,
28
29
  text = _ref.text,
29
30
  url = _ref.url;
@@ -32,6 +33,7 @@ var LayeredLink = function LayeredLink(_ref) {
32
33
  css: styles,
33
34
  "data-testid": "".concat(testId, "-layered-link"),
34
35
  href: url,
36
+ onClick: onClick,
35
37
  target: target,
36
38
  tabIndex: -1 // Hide tab index and let the title link be the link.
37
39
 
@@ -27,7 +27,7 @@ var _templateObject;
27
27
  * [object-position] Center alignment of the selected replaced element's
28
28
  * contents within the element's box.
29
29
  */
30
- var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
30
+ var styles = (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n height: fit-content; // Fix Safari height not respecting aspect-ratio\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
31
31
  /**
32
32
  * A base element that displays a Media.
33
33
  * @internal
@@ -99,4 +99,5 @@ export const handleOnClick = handler => e => {
99
99
  e.preventDefault();
100
100
  e.stopPropagation();
101
101
  handler();
102
- };
102
+ };
103
+ export const isIntersectionObserverSupported = () => typeof IntersectionObserver !== 'undefined';
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.7",
3
+ "version": "19.1.10",
4
4
  "sideEffects": false
5
5
  }
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { isIntersectionObserverSupported } from '@atlaskit/media-ui';
3
2
  import { LazyLazilyRenderCard } from './LazyLazilyRenderCard';
4
3
  import { LazyIntersectionObserverCard } from './LazyIntersectionObserverCard';
4
+ import { isIntersectionObserverSupported } from '../../../utils';
5
5
  export default function LazyCardWithUrlContent(props) {
6
6
  if (isIntersectionObserverSupported()) {
7
7
  return /*#__PURE__*/React.createElement(LazyIntersectionObserverCard, props);
@@ -1,11 +1,29 @@
1
1
  import styled from '@emotion/styled';
2
- import { size as csssize, borderRadius, size, ellipsis } from '@atlaskit/media-ui';
3
- import { fontFamily } from '@atlaskit/theme/constants';
2
+ import { borderRadius as akBorderRadius, fontFamily } from '@atlaskit/theme/constants';
4
3
  import * as colors from '@atlaskit/theme/colors';
5
4
  import { token } from '@atlaskit/tokens';
6
5
  import { gs as gridSize } from '../../common/utils';
7
6
  export const className = 'media-card-frame';
8
7
  export const cardShadow = ``;
8
+ export const borderRadius = `
9
+ border-radius: ${akBorderRadius()}px;
10
+ `;
11
+ export const ellipsis = (maxWidth = '100%') => {
12
+ const unit = typeof maxWidth === 'number' ? 'px' : '';
13
+ return `
14
+ max-width: ${maxWidth}${unit};
15
+ overflow: hidden;
16
+ text-overflow: ellipsis;
17
+ white-space: nowrap;
18
+ `;
19
+ };
20
+ export const csssize = (value = '100%') => {
21
+ const unit = typeof value === 'number' ? 'px' : '';
22
+ return `
23
+ width: ${value}${unit};
24
+ height: ${value}${unit};
25
+ `;
26
+ };
9
27
 
10
28
  function minWidth({
11
29
  minWidth
@@ -135,7 +153,7 @@ export const Header = styled.div`
135
153
  `;
136
154
  export const IconWrapper = styled.div`
137
155
  ${borderRadius}
138
- ${size(16)}
156
+ ${csssize(16)}
139
157
  ${({
140
158
  isPlaceholder
141
159
  }) => {
@@ -253,7 +271,7 @@ export const ResolvedViewIconWrapper = styled.div`
253
271
  `;
254
272
  export const Thumbnail = styled.div`
255
273
  ${borderRadius}
256
- ${size(48)}
274
+ ${csssize(48)}
257
275
  float: right;
258
276
  margin: 4px 0 12px 12px;
259
277
  background-color: ${token('color.skeleton', colors.N30)};
@@ -108,7 +108,7 @@ const getTitleBlockProps = children => {
108
108
  }
109
109
  };
110
110
 
111
- const getLayeredLink = (testId, context, children) => {
111
+ const getLayeredLink = (testId, context, children, onClick) => {
112
112
  const {
113
113
  title,
114
114
  url = ''
@@ -118,6 +118,7 @@ const getLayeredLink = (testId, context, children) => {
118
118
  text
119
119
  } = getTitleBlockProps(children) || {};
120
120
  return jsx(LayeredLink, {
121
+ onClick: onClick,
121
122
  target: target,
122
123
  testId: testId,
123
124
  text: text || title,
@@ -152,7 +153,7 @@ const Container = ({
152
153
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
153
154
  "data-smart-link-container": true,
154
155
  "data-testid": testId
155
- }, clickableContainer ? getLayeredLink(testId, context, children) : null, renderChildren(children, size, theme, status, retry, onClick));
156
+ }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
156
157
  };
157
158
 
158
159
  export default Container;
@@ -42,6 +42,7 @@ const styles = css`
42
42
  */
43
43
 
44
44
  const LayeredLink = ({
45
+ onClick,
45
46
  target,
46
47
  testId,
47
48
  text,
@@ -51,6 +52,7 @@ const LayeredLink = ({
51
52
  css: styles,
52
53
  "data-testid": `${testId}-layered-link`,
53
54
  href: url,
55
+ onClick: onClick,
54
56
  target: target,
55
57
  tabIndex: -1 // Hide tab index and let the title link be the link.
56
58
 
@@ -17,6 +17,7 @@ const styles = css`
17
17
  aspect-ratio: 16 / 9;
18
18
  display: flex;
19
19
  width: 100%;
20
+ height: fit-content; // Fix Safari height not respecting aspect-ratio
20
21
 
21
22
  // fallback
22
23
  @supports not (aspect-ratio: auto) {
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import { useMemo, useCallback } from 'react';
4
4
  import { auth } from '@atlaskit/outbound-auth-flow-client';
5
5
  import { APIError } from '@atlaskit/linking-common';
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import { useCallback } from 'react';
4
4
  import { useSmartLinkContext } from '@atlaskit/link-provider';
5
5
  export function usePrefetch(url) {
@@ -224,4 +224,7 @@ export var handleOnClick = function handleOnClick(handler) {
224
224
  e.stopPropagation();
225
225
  handler();
226
226
  };
227
+ };
228
+ export var isIntersectionObserverSupported = function isIntersectionObserverSupported() {
229
+ return typeof IntersectionObserver !== 'undefined';
227
230
  };
@@ -1,10 +1,10 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
2
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
3
  import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
4
  import _createClass from "@babel/runtime/helpers/createClass";
4
5
  import _inherits from "@babel/runtime/helpers/inherits";
5
6
  import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
7
  import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
 
9
9
  function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
10
 
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.7",
3
+ "version": "19.1.10",
4
4
  "sideEffects": false
5
5
  }
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import React from 'react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
5
  import { downloadUrl } from '@atlaskit/media-common';
@@ -1,10 +1,10 @@
1
+ import _regeneratorRuntime from "@babel/runtime/regenerator";
1
2
  import _extends from "@babel/runtime/helpers/extends";
2
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
3
4
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
4
5
  import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
5
6
  var _excluded = ["popupMountPointId", "onClose"],
6
7
  _excluded2 = ["details"];
7
- import _regeneratorRuntime from "@babel/runtime/regenerator";
8
8
 
9
9
  function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
10
10
 
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import React from 'react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
5
  import { messages } from '@atlaskit/media-ui/messages';
@@ -1,5 +1,5 @@
1
- import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
2
1
  import _regeneratorRuntime from "@babel/runtime/regenerator";
2
+ import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
3
3
  import React from 'react';
4
4
  import { FormattedMessage } from 'react-intl-next';
5
5
  import { messages } from '@atlaskit/media-ui/messages';
@@ -1,7 +1,7 @@
1
1
  import React from 'react';
2
- import { isIntersectionObserverSupported } from '@atlaskit/media-ui';
3
2
  import { LazyLazilyRenderCard } from './LazyLazilyRenderCard';
4
3
  import { LazyIntersectionObserverCard } from './LazyIntersectionObserverCard';
4
+ import { isIntersectionObserverSupported } from '../../../utils';
5
5
  export default function LazyCardWithUrlContent(props) {
6
6
  if (isIntersectionObserverSupported()) {
7
7
  return /*#__PURE__*/React.createElement(LazyIntersectionObserverCard, props);
@@ -3,13 +3,23 @@ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral
3
3
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12, _templateObject13, _templateObject14, _templateObject15, _templateObject16;
4
4
 
5
5
  import styled from '@emotion/styled';
6
- import { size as csssize, borderRadius, size, ellipsis } from '@atlaskit/media-ui';
7
- import { fontFamily } from '@atlaskit/theme/constants';
6
+ import { borderRadius as akBorderRadius, fontFamily } from '@atlaskit/theme/constants';
8
7
  import * as colors from '@atlaskit/theme/colors';
9
8
  import { token } from '@atlaskit/tokens';
10
9
  import { gs as gridSize } from '../../common/utils';
11
10
  export var className = 'media-card-frame';
12
11
  export var cardShadow = "";
12
+ export var borderRadius = "\n border-radius: ".concat(akBorderRadius(), "px;\n");
13
+ export var ellipsis = function ellipsis() {
14
+ var maxWidth = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '100%';
15
+ var unit = typeof maxWidth === 'number' ? 'px' : '';
16
+ return "\n max-width: ".concat(maxWidth).concat(unit, ";\n overflow: hidden;\n text-overflow: ellipsis;\n white-space: nowrap;\n ");
17
+ };
18
+ export var csssize = function csssize() {
19
+ var value = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '100%';
20
+ var unit = typeof value === 'number' ? 'px' : '';
21
+ return "\n width: ".concat(value).concat(unit, ";\n height: ").concat(value).concat(unit, ";\n ");
22
+ };
13
23
 
14
24
  function minWidth(_ref) {
15
25
  var minWidth = _ref.minWidth;
@@ -68,7 +78,7 @@ export var Wrapper = styled.div(_templateObject2 || (_templateObject2 = _taggedT
68
78
  });
69
79
  export var embedHeaderHeight = 32;
70
80
  export var Header = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n height: ", "px;\n position: absolute;\n z-index: 1;\n width: 100%;\n display: flex;\n align-items: center;\n color: ", ";\n opacity: 0;\n transition: 300ms opacity cubic-bezier(0.15, 1, 0.3, 1);\n"])), embedHeaderHeight, token('color.icon', colors.N300));
71
- export var IconWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n ", "\n ", " margin-right: 4px;\n"])), borderRadius, size(16), function (_ref7) {
81
+ export var IconWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n ", "\n ", " margin-right: 4px;\n"])), borderRadius, csssize(16), function (_ref7) {
72
82
  var isPlaceholder = _ref7.isPlaceholder;
73
83
 
74
84
  if (isPlaceholder) {
@@ -108,7 +118,7 @@ export var Title = styled.div(_templateObject9 || (_templateObject9 = _taggedTem
108
118
  export var Byline = styled.div(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n margin-top: 4px;\n color: ", ";\n font-size: 12px;\n font-weight: normal;\n line-height: ", ";\n ", ";\n"])), token('color.text.subtlest', colors.N300), 16 / 12, ellipsis('100%'));
109
119
  export var Description = styled.div(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n margin-top: 7px;\n color: ", ";\n font-size: 12px;\n font-weight: normal;\n line-height: ", ";\n max-height: ", "px;\n overflow: hidden;\n"])), token('color.text', colors.N800), 18 / 12, 18 * 3);
110
120
  export var ResolvedViewIconWrapper = styled.div(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n margin-top: 4px;\n"])));
111
- export var Thumbnail = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n ", "\n ", "\n float: right;\n margin: 4px 0 12px 12px;\n background-color: ", ";\n background-image: url(", ");\n background-size: cover;\n"])), borderRadius, size(48), token('color.skeleton', colors.N30), function (_ref11) {
121
+ export var Thumbnail = styled.div(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n ", "\n ", "\n float: right;\n margin: 4px 0 12px 12px;\n background-color: ", ";\n background-image: url(", ");\n background-size: cover;\n"])), borderRadius, csssize(48), token('color.skeleton', colors.N30), function (_ref11) {
112
122
  var src = _ref11.src;
113
123
  return src;
114
124
  });
@@ -85,7 +85,7 @@ var getTitleBlockProps = function getTitleBlockProps(children) {
85
85
  }
86
86
  };
87
87
 
88
- var getLayeredLink = function getLayeredLink(testId, context, children) {
88
+ var getLayeredLink = function getLayeredLink(testId, context, children, onClick) {
89
89
  var _ref = context || {},
90
90
  title = _ref.title,
91
91
  _ref$url = _ref.url,
@@ -96,6 +96,7 @@ var getLayeredLink = function getLayeredLink(testId, context, children) {
96
96
  text = _ref2.text;
97
97
 
98
98
  return jsx(LayeredLink, {
99
+ onClick: onClick,
99
100
  target: target,
100
101
  testId: testId,
101
102
  text: text || title,
@@ -136,7 +137,7 @@ var Container = function Container(_ref3) {
136
137
  css: getContainerStyles(size, hideBackground, hideElevation, hidePadding, clickableContainer),
137
138
  "data-smart-link-container": true,
138
139
  "data-testid": testId
139
- }, clickableContainer ? getLayeredLink(testId, context, children) : null, renderChildren(children, size, theme, status, retry, onClick));
140
+ }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick));
140
141
  };
141
142
 
142
143
  export default Container;
@@ -13,7 +13,8 @@ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["
13
13
  */
14
14
 
15
15
  var LayeredLink = function LayeredLink(_ref) {
16
- var target = _ref.target,
16
+ var onClick = _ref.onClick,
17
+ target = _ref.target,
17
18
  testId = _ref.testId,
18
19
  text = _ref.text,
19
20
  url = _ref.url;
@@ -22,6 +23,7 @@ var LayeredLink = function LayeredLink(_ref) {
22
23
  css: styles,
23
24
  "data-testid": "".concat(testId, "-layered-link"),
24
25
  href: url,
26
+ onClick: onClick,
25
27
  target: target,
26
28
  tabIndex: -1 // Hide tab index and let the title link be the link.
27
29
 
@@ -17,7 +17,7 @@ import ImageIcon from '../../common/image-icon';
17
17
  * [object-position] Center alignment of the selected replaced element's
18
18
  * contents within the element's box.
19
19
  */
20
- var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
20
+ var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n aspect-ratio: 16 / 9;\n display: flex;\n width: 100%;\n height: fit-content; // Fix Safari height not respecting aspect-ratio\n\n // fallback\n @supports not (aspect-ratio: auto) {\n padding-top: 56.25%; // 16:9 ratio (9 / 16 = 0.5625)\n height: 0;\n position: relative;\n overflow: hidden;\n }\n\n > img {\n min-height: 100%;\n min-width: 100%;\n max-height: 100%;\n max-width: 100%;\n object-fit: cover;\n object-position: center center;\n\n // fallback\n @supports not (aspect-ratio: auto) {\n position: absolute;\n transform: translate(-50%, -50%);\n left: 50%;\n top: 50%;\n width: auto;\n height: auto;\n }\n }\n"])));
21
21
  /**
22
22
  * A base element that displays a Media.
23
23
  * @internal
@@ -9,3 +9,4 @@ export declare const getIconForFileType: (fileMimeType: string) => React.ReactNo
9
9
  export declare const getLabelForFileType: (fileMimeType: string) => React.ReactNode | undefined;
10
10
  export declare const getIframeSandboxAttribute: (isTrusted: boolean) => "allow-downloads allow-forms allow-popups allow-popups-to-escape-sandbox allow-presentation allow-same-origin allow-scripts" | undefined;
11
11
  export declare const handleOnClick: (handler: Function) => (e: React.BaseSyntheticEvent) => void;
12
+ export declare const isIntersectionObserverSupported: () => boolean;
@@ -10,6 +10,9 @@ export interface WrapperProps {
10
10
  isVisible?: boolean;
11
11
  inheritDimensions?: boolean;
12
12
  }
13
+ export declare const borderRadius: string;
14
+ export declare const ellipsis: (maxWidth?: string | number) => string;
15
+ export declare const csssize: (value?: string | number) => string;
13
16
  export declare const LinkWrapper: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, WrapperProps, any>;
14
17
  export declare const Wrapper: import("@emotion/styled-base").StyledComponent<import("react").DetailedHTMLProps<import("react").HTMLAttributes<HTMLDivElement>, HTMLDivElement>, WrapperProps, any>;
15
18
  export declare const embedHeaderHeight = 32;
@@ -1,4 +1,10 @@
1
+ /// <reference types="react" />
1
2
  export declare type LayeredLinkProps = {
3
+ /**
4
+ * Determines the onClick behaviour of the Link. By default used for analytics.
5
+ * @internal
6
+ */
7
+ onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
2
8
  target?: '_blank' | '_self' | '_top' | '_parent';
3
9
  testId?: string;
4
10
  text?: string;
@@ -0,0 +1,12 @@
1
+ /// <reference types="jest" />
2
+ export declare class MockIntersectionObserver implements IntersectionObserver {
3
+ callback: IntersectionObserverCallback;
4
+ readonly root: Element | null;
5
+ readonly rootMargin: string;
6
+ readonly thresholds: ReadonlyArray<number>;
7
+ constructor(callback: IntersectionObserverCallback);
8
+ observe(_element: HTMLElement): void;
9
+ disconnect: jest.Mock<any, any>;
10
+ takeRecords: jest.Mock<any, any>;
11
+ unobserve: jest.Mock<any, any>;
12
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "19.1.7",
3
+ "version": "19.1.10",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"