@atlaskit/smart-card 26.11.0 → 26.12.0

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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.12.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`5eea09cd864`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5eea09cd864) - Standalone Hover Preview: Add zIndex prop to pass to DS Popup
8
+
9
+ ## 26.11.1
10
+
11
+ ### Patch Changes
12
+
13
+ - [`b37a26be833`](https://bitbucket.org/atlassian/atlassian-frontend/commits/b37a26be833) - Prevent LinkUrl from throwing error on validation
14
+
3
15
  ## 26.11.0
4
16
 
5
17
  ### Minor Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.11.0",
3
+ "version": "26.12.0",
4
4
  "sideEffects": false
5
5
  }
@@ -43,7 +43,9 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
43
43
  _ref$showServerAction = _ref.showServerActions,
44
44
  showServerActions = _ref$showServerAction === void 0 ? false : _ref$showServerAction,
45
45
  _ref$allowEventPropag = _ref.allowEventPropagation,
46
- allowEventPropagation = _ref$allowEventPropag === void 0 ? false : _ref$allowEventPropag;
46
+ allowEventPropagation = _ref$allowEventPropag === void 0 ? false : _ref$allowEventPropag,
47
+ _ref$zIndex = _ref.zIndex,
48
+ zIndex = _ref$zIndex === void 0 ? _styled.HOVER_CARD_Z_INDEX : _ref$zIndex;
47
49
  var _React$useState = _react2.default.useState(false),
48
50
  _React$useState2 = (0, _slicedToArray2.default)(_React$useState, 2),
49
51
  isOpen = _React$useState2[0],
@@ -222,7 +224,7 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
222
224
  autoFocus: false,
223
225
  content: content,
224
226
  trigger: trigger,
225
- zIndex: _styled.HOVER_CARD_Z_INDEX
227
+ zIndex: zIndex
226
228
  });
227
229
  };
228
230
  exports.HoverCardComponent = HoverCardComponent;
@@ -10,6 +10,13 @@ var _react = require("react");
10
10
  var _url = require("@atlaskit/linking-common/url");
11
11
  var _analyticsNext = require("@atlaskit/analytics-next");
12
12
  var _analytics = require("../../../../utils/analytics");
13
+ var toUrl = function toUrl(url, base) {
14
+ try {
15
+ return new URL(url, base);
16
+ } catch (_unused) {
17
+ return undefined;
18
+ }
19
+ };
13
20
  var useLinkWarningModal = function useLinkWarningModal() {
14
21
  var _useState = (0, _react.useState)(null),
15
22
  _useState2 = (0, _slicedToArray2.default)(_useState, 2),
@@ -57,8 +64,9 @@ var useLinkWarningModal = function useLinkWarningModal() {
57
64
  return true;
58
65
  }
59
66
  var anchorLinkRegex = new RegExp(/^#/im);
60
- var isAnchorLink = anchorLinkRegex.test(linkText);
61
- if (isAnchorLink) {
67
+ var isLinkTextAnchorLink = anchorLinkRegex.test(linkText);
68
+ var isAnchorLink = anchorLinkRegex.test(href);
69
+ if (isAnchorLink || isLinkTextAnchorLink) {
62
70
  return true;
63
71
  }
64
72
  var relativeLinkRegex = new RegExp(/^\//im);
@@ -66,8 +74,11 @@ var useLinkWarningModal = function useLinkWarningModal() {
66
74
  if (isRelativeHrefLink) {
67
75
  return true;
68
76
  }
69
- var hrefUrl = new URL(href, window.location.origin);
70
- var linkTextUrl = new URL(normalisedUrlFromLinkText, hrefUrl.origin);
77
+ var hrefUrl = toUrl(href, window.location.origin);
78
+ var linkTextUrl = toUrl(normalisedUrlFromLinkText, hrefUrl === null || hrefUrl === void 0 ? void 0 : hrefUrl.origin);
79
+ if (!hrefUrl || !linkTextUrl) {
80
+ return true;
81
+ }
71
82
  var httpProtocols = ['http:', 'https:'];
72
83
  var areProtocolsEquivalent;
73
84
  if (httpProtocols.includes(linkTextUrl.protocol) && httpProtocols.includes(hrefUrl.protocol)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.11.0",
3
+ "version": "26.12.0",
4
4
  "sideEffects": false
5
5
  }
@@ -25,7 +25,8 @@ export const HoverCardComponent = ({
25
25
  closeOnChildClick = false,
26
26
  hidePreviewButton = false,
27
27
  showServerActions = false,
28
- allowEventPropagation = false
28
+ allowEventPropagation = false,
29
+ zIndex = HOVER_CARD_Z_INDEX
29
30
  }) => {
30
31
  const [isOpen, setIsOpen] = React.useState(false);
31
32
  const fadeOutTimeoutId = useRef();
@@ -195,6 +196,6 @@ export const HoverCardComponent = ({
195
196
  autoFocus: false,
196
197
  content: content,
197
198
  trigger: trigger,
198
- zIndex: HOVER_CARD_Z_INDEX
199
+ zIndex: zIndex
199
200
  });
200
201
  };
@@ -2,6 +2,13 @@ import { useState } from 'react';
2
2
  import { normalizeUrl } from '@atlaskit/linking-common/url';
3
3
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
4
4
  import { ANALYTICS_CHANNEL } from '../../../../utils/analytics';
5
+ const toUrl = (url, base) => {
6
+ try {
7
+ return new URL(url, base);
8
+ } catch {
9
+ return undefined;
10
+ }
11
+ };
5
12
  export const useLinkWarningModal = () => {
6
13
  const [unsafeLinkText, setUnsafeLinkText] = useState(null);
7
14
  const [url, setUrl] = useState(null);
@@ -41,8 +48,9 @@ export const useLinkWarningModal = () => {
41
48
  return true;
42
49
  }
43
50
  const anchorLinkRegex = new RegExp(/^#/im);
44
- const isAnchorLink = anchorLinkRegex.test(linkText);
45
- if (isAnchorLink) {
51
+ const isLinkTextAnchorLink = anchorLinkRegex.test(linkText);
52
+ const isAnchorLink = anchorLinkRegex.test(href);
53
+ if (isAnchorLink || isLinkTextAnchorLink) {
46
54
  return true;
47
55
  }
48
56
  const relativeLinkRegex = new RegExp(/^\//im);
@@ -50,8 +58,11 @@ export const useLinkWarningModal = () => {
50
58
  if (isRelativeHrefLink) {
51
59
  return true;
52
60
  }
53
- const hrefUrl = new URL(href, window.location.origin);
54
- const linkTextUrl = new URL(normalisedUrlFromLinkText, hrefUrl.origin);
61
+ const hrefUrl = toUrl(href, window.location.origin);
62
+ const linkTextUrl = toUrl(normalisedUrlFromLinkText, hrefUrl === null || hrefUrl === void 0 ? void 0 : hrefUrl.origin);
63
+ if (!hrefUrl || !linkTextUrl) {
64
+ return true;
65
+ }
55
66
  const httpProtocols = ['http:', 'https:'];
56
67
  let areProtocolsEquivalent;
57
68
  if (httpProtocols.includes(linkTextUrl.protocol) && httpProtocols.includes(hrefUrl.protocol)) {
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.11.0",
3
+ "version": "26.12.0",
4
4
  "sideEffects": false
5
5
  }
@@ -32,7 +32,9 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
32
32
  _ref$showServerAction = _ref.showServerActions,
33
33
  showServerActions = _ref$showServerAction === void 0 ? false : _ref$showServerAction,
34
34
  _ref$allowEventPropag = _ref.allowEventPropagation,
35
- allowEventPropagation = _ref$allowEventPropag === void 0 ? false : _ref$allowEventPropag;
35
+ allowEventPropagation = _ref$allowEventPropag === void 0 ? false : _ref$allowEventPropag,
36
+ _ref$zIndex = _ref.zIndex,
37
+ zIndex = _ref$zIndex === void 0 ? HOVER_CARD_Z_INDEX : _ref$zIndex;
36
38
  var _React$useState = React.useState(false),
37
39
  _React$useState2 = _slicedToArray(_React$useState, 2),
38
40
  isOpen = _React$useState2[0],
@@ -211,6 +213,6 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
211
213
  autoFocus: false,
212
214
  content: content,
213
215
  trigger: trigger,
214
- zIndex: HOVER_CARD_Z_INDEX
216
+ zIndex: zIndex
215
217
  });
216
218
  };
@@ -3,6 +3,13 @@ import { useState } from 'react';
3
3
  import { normalizeUrl } from '@atlaskit/linking-common/url';
4
4
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
5
5
  import { ANALYTICS_CHANNEL } from '../../../../utils/analytics';
6
+ var toUrl = function toUrl(url, base) {
7
+ try {
8
+ return new URL(url, base);
9
+ } catch (_unused) {
10
+ return undefined;
11
+ }
12
+ };
6
13
  export var useLinkWarningModal = function useLinkWarningModal() {
7
14
  var _useState = useState(null),
8
15
  _useState2 = _slicedToArray(_useState, 2),
@@ -50,8 +57,9 @@ export var useLinkWarningModal = function useLinkWarningModal() {
50
57
  return true;
51
58
  }
52
59
  var anchorLinkRegex = new RegExp(/^#/im);
53
- var isAnchorLink = anchorLinkRegex.test(linkText);
54
- if (isAnchorLink) {
60
+ var isLinkTextAnchorLink = anchorLinkRegex.test(linkText);
61
+ var isAnchorLink = anchorLinkRegex.test(href);
62
+ if (isAnchorLink || isLinkTextAnchorLink) {
55
63
  return true;
56
64
  }
57
65
  var relativeLinkRegex = new RegExp(/^\//im);
@@ -59,8 +67,11 @@ export var useLinkWarningModal = function useLinkWarningModal() {
59
67
  if (isRelativeHrefLink) {
60
68
  return true;
61
69
  }
62
- var hrefUrl = new URL(href, window.location.origin);
63
- var linkTextUrl = new URL(normalisedUrlFromLinkText, hrefUrl.origin);
70
+ var hrefUrl = toUrl(href, window.location.origin);
71
+ var linkTextUrl = toUrl(normalisedUrlFromLinkText, hrefUrl === null || hrefUrl === void 0 ? void 0 : hrefUrl.origin);
72
+ if (!hrefUrl || !linkTextUrl) {
73
+ return true;
74
+ }
64
75
  var httpProtocols = ['http:', 'https:'];
65
76
  var areProtocolsEquivalent;
66
77
  if (httpProtocols.includes(linkTextUrl.protocol) && httpProtocols.includes(hrefUrl.protocol)) {
@@ -43,6 +43,11 @@ export interface HoverCardProps extends WithAnalyticsEventsProps {
43
43
  * Determines whether to show available server actions.
44
44
  */
45
45
  showServerActions?: boolean;
46
+ /**
47
+ * Z-index that the hover card should be displayed in.
48
+ * This is passed to the portal component.
49
+ */
50
+ zIndex?: number;
46
51
  }
47
52
  /**
48
53
  * An internal props that internal smart-card components can use to configure
@@ -43,6 +43,11 @@ export interface HoverCardProps extends WithAnalyticsEventsProps {
43
43
  * Determines whether to show available server actions.
44
44
  */
45
45
  showServerActions?: boolean;
46
+ /**
47
+ * Z-index that the hover card should be displayed in.
48
+ * This is passed to the portal component.
49
+ */
50
+ zIndex?: number;
46
51
  }
47
52
  /**
48
53
  * An internal props that internal smart-card components can use to configure
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.11.0",
3
+ "version": "26.12.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"