@atlaskit/smart-card 26.5.6 → 26.5.8

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.5.8
4
+
5
+ ### Patch Changes
6
+
7
+ - [`27f4aa34132`](https://bitbucket.org/atlassian/atlassian-frontend/commits/27f4aa34132) - [ux] Fix for Hover Card in Flexible UI links: it will show only supported states, such as resolved and unauthorized based on the corresponding featureFlag ('showHoverPreview' and 'showAuthTooltip')
8
+
9
+ ## 26.5.7
10
+
11
+ ### Patch Changes
12
+
13
+ - [`5b5d7b22e80`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5b5d7b22e80) - [ux] Update feature discovery on lozenge action to display for 2s before marking it as discovered
14
+
3
15
  ## 26.5.6
4
16
 
5
17
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.6",
3
+ "version": "26.5.8",
4
4
  "sideEffects": false
5
5
  }
@@ -192,6 +192,7 @@ function Component(_ref) {
192
192
  renderers: renderers,
193
193
  ui: ui,
194
194
  showHoverPreview: showHoverPreview,
195
+ showAuthTooltip: showAuthTooltipProp,
195
196
  showServerActions: showServerActions,
196
197
  url: url,
197
198
  testId: testId,
@@ -12,7 +12,9 @@ var _styled = require("./styled");
12
12
 
13
13
  var LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/smart-card';
14
14
  var LOCAL_STORAGE_DISCOVERY_KEY = 'action-discovery-status';
15
+ var LOCAL_STORAGE_DISCOVERY_VALUE = 'discovered';
15
16
  var LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS = 15552000000; // 180 days
17
+ var LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME = 2000; // 2s
16
18
 
17
19
  /**
18
20
  * This is a hacky solution to help with the feature discovery.
@@ -24,17 +26,23 @@ var FeatureDiscovery = function FeatureDiscovery(_ref) {
24
26
  var appearance = _ref.appearance,
25
27
  children = _ref.children,
26
28
  testId = _ref.testId;
29
+ var renderedTime = (0, _react2.useRef)();
27
30
  var storageClient = (0, _react2.useMemo)(function () {
28
31
  return new _storageClient.StorageClient(LOCAL_STORAGE_CLIENT_KEY);
29
32
  }, []);
30
33
  var discovered = (0, _react2.useMemo)(function () {
31
- var _storageClient$getIte;
32
- return (_storageClient$getIte = storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY)) !== null && _storageClient$getIte !== void 0 ? _storageClient$getIte : false;
34
+ return storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY) === LOCAL_STORAGE_DISCOVERY_VALUE;
33
35
  }, [storageClient]);
34
36
  (0, _react2.useEffect)(function () {
35
- if (!discovered) {
36
- storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, true, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
37
- }
37
+ renderedTime.current = Date.now();
38
+ return function () {
39
+ if (!discovered && renderedTime.current) {
40
+ var duration = Date.now() - renderedTime.current;
41
+ if (duration > LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME) {
42
+ storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, LOCAL_STORAGE_DISCOVERY_VALUE, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
43
+ }
44
+ }
45
+ };
38
46
  }, [storageClient, discovered]);
39
47
  var component = (0, _react2.useMemo)(function () {
40
48
  if (!discovered) {
@@ -158,6 +158,8 @@ var Container = function Container(_ref3) {
158
158
  hidePadding = _ref3$hidePadding === void 0 ? false : _ref3$hidePadding,
159
159
  onClick = _ref3.onClick,
160
160
  retry = _ref3.retry,
161
+ _ref3$showAuthTooltip = _ref3.showAuthTooltip,
162
+ showAuthTooltip = _ref3$showAuthTooltip === void 0 ? false : _ref3$showAuthTooltip,
161
163
  _ref3$showHoverPrevie = _ref3.showHoverPreview,
162
164
  showHoverPreview = _ref3$showHoverPrevie === void 0 ? false : _ref3$showHoverPrevie,
163
165
  _ref3$showServerActio = _ref3.showServerActions,
@@ -183,7 +185,7 @@ var Container = function Container(_ref3) {
183
185
  "data-smart-link-container": true,
184
186
  "data-testid": testId
185
187
  }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick, showHoverPreview ? onActionMenuOpenChange : undefined));
186
- if (showHoverPreview && context !== null && context !== void 0 && context.url) {
188
+ if (context !== null && context !== void 0 && context.url && (showHoverPreview && status === 'resolved' || showAuthTooltip && status === 'unauthorized')) {
187
189
  return (0, _react2.jsx)(_HoverCard.HoverCard, {
188
190
  url: context === null || context === void 0 ? void 0 : context.url,
189
191
  canOpen: hoverCardCanOpen,
@@ -31,6 +31,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
31
31
  onError = _ref.onError,
32
32
  onResolve = _ref.onResolve,
33
33
  renderers = _ref.renderers,
34
+ showAuthTooltip = _ref.showAuthTooltip,
34
35
  showHoverPreview = _ref.showHoverPreview,
35
36
  showServerActions = _ref.showServerActions,
36
37
  testId = _ref.testId,
@@ -96,6 +97,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
96
97
  retry: retry,
97
98
  showHoverPreview: showHoverPreview,
98
99
  showServerActions: showServerActions,
100
+ showAuthTooltip: showAuthTooltip,
99
101
  status: status
100
102
  }), children))));
101
103
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.6",
3
+ "version": "26.5.8",
4
4
  "sideEffects": false
5
5
  }
@@ -179,6 +179,7 @@ function Component({
179
179
  renderers: renderers,
180
180
  ui: ui,
181
181
  showHoverPreview: showHoverPreview,
182
+ showAuthTooltip: showAuthTooltipProp,
182
183
  showServerActions: showServerActions,
183
184
  url: url,
184
185
  testId: testId,
@@ -1,11 +1,13 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
- import { useEffect, useMemo } from 'react';
3
+ import { useEffect, useMemo, useRef } from 'react';
4
4
  import { StorageClient } from '@atlaskit/frontend-utilities/storage-client';
5
5
  import { getPulseStyles } from './styled';
6
6
  const LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/smart-card';
7
7
  const LOCAL_STORAGE_DISCOVERY_KEY = 'action-discovery-status';
8
+ const LOCAL_STORAGE_DISCOVERY_VALUE = 'discovered';
8
9
  const LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS = 15552000000; // 180 days
10
+ const LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME = 2000; // 2s
9
11
 
10
12
  /**
11
13
  * This is a hacky solution to help with the feature discovery.
@@ -18,15 +20,19 @@ const FeatureDiscovery = ({
18
20
  children,
19
21
  testId
20
22
  }) => {
23
+ const renderedTime = useRef();
21
24
  const storageClient = useMemo(() => new StorageClient(LOCAL_STORAGE_CLIENT_KEY), []);
22
- const discovered = useMemo(() => {
23
- var _storageClient$getIte;
24
- return (_storageClient$getIte = storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY)) !== null && _storageClient$getIte !== void 0 ? _storageClient$getIte : false;
25
- }, [storageClient]);
25
+ const discovered = useMemo(() => storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY) === LOCAL_STORAGE_DISCOVERY_VALUE, [storageClient]);
26
26
  useEffect(() => {
27
- if (!discovered) {
28
- storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, true, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
29
- }
27
+ renderedTime.current = Date.now();
28
+ return () => {
29
+ if (!discovered && renderedTime.current) {
30
+ const duration = Date.now() - renderedTime.current;
31
+ if (duration > LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME) {
32
+ storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, LOCAL_STORAGE_DISCOVERY_VALUE, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
33
+ }
34
+ }
35
+ };
30
36
  }, [storageClient, discovered]);
31
37
  const component = useMemo(() => {
32
38
  if (!discovered) {
@@ -183,6 +183,7 @@ const Container = ({
183
183
  hidePadding = false,
184
184
  onClick,
185
185
  retry,
186
+ showAuthTooltip = false,
186
187
  showHoverPreview = false,
187
188
  showServerActions = false,
188
189
  size = SmartLinkSize.Medium,
@@ -199,7 +200,7 @@ const Container = ({
199
200
  "data-smart-link-container": true,
200
201
  "data-testid": testId
201
202
  }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick, showHoverPreview ? onActionMenuOpenChange : undefined));
202
- if (showHoverPreview && context !== null && context !== void 0 && context.url) {
203
+ if (context !== null && context !== void 0 && context.url && (showHoverPreview && status === 'resolved' || showAuthTooltip && status === 'unauthorized')) {
203
204
  return jsx(HoverCard, {
204
205
  url: context === null || context === void 0 ? void 0 : context.url,
205
206
  canOpen: hoverCardCanOpen,
@@ -22,6 +22,7 @@ const FlexibleCard = ({
22
22
  onError,
23
23
  onResolve,
24
24
  renderers,
25
+ showAuthTooltip,
25
26
  showHoverPreview,
26
27
  showServerActions,
27
28
  testId,
@@ -87,6 +88,7 @@ const FlexibleCard = ({
87
88
  retry: retry,
88
89
  showHoverPreview: showHoverPreview,
89
90
  showServerActions: showServerActions,
91
+ showAuthTooltip: showAuthTooltip,
90
92
  status: status
91
93
  }), children))));
92
94
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.6",
3
+ "version": "26.5.8",
4
4
  "sideEffects": false
5
5
  }
@@ -182,6 +182,7 @@ function Component(_ref) {
182
182
  renderers: renderers,
183
183
  ui: ui,
184
184
  showHoverPreview: showHoverPreview,
185
+ showAuthTooltip: showAuthTooltipProp,
185
186
  showServerActions: showServerActions,
186
187
  url: url,
187
188
  testId: testId,
@@ -1,11 +1,13 @@
1
1
  /** @jsx jsx */
2
2
  import { jsx } from '@emotion/react';
3
- import { useEffect, useMemo } from 'react';
3
+ import { useEffect, useMemo, useRef } from 'react';
4
4
  import { StorageClient } from '@atlaskit/frontend-utilities/storage-client';
5
5
  import { getPulseStyles } from './styled';
6
6
  var LOCAL_STORAGE_CLIENT_KEY = '@atlaskit/smart-card';
7
7
  var LOCAL_STORAGE_DISCOVERY_KEY = 'action-discovery-status';
8
+ var LOCAL_STORAGE_DISCOVERY_VALUE = 'discovered';
8
9
  var LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS = 15552000000; // 180 days
10
+ var LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME = 2000; // 2s
9
11
 
10
12
  /**
11
13
  * This is a hacky solution to help with the feature discovery.
@@ -17,17 +19,23 @@ var FeatureDiscovery = function FeatureDiscovery(_ref) {
17
19
  var appearance = _ref.appearance,
18
20
  children = _ref.children,
19
21
  testId = _ref.testId;
22
+ var renderedTime = useRef();
20
23
  var storageClient = useMemo(function () {
21
24
  return new StorageClient(LOCAL_STORAGE_CLIENT_KEY);
22
25
  }, []);
23
26
  var discovered = useMemo(function () {
24
- var _storageClient$getIte;
25
- return (_storageClient$getIte = storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY)) !== null && _storageClient$getIte !== void 0 ? _storageClient$getIte : false;
27
+ return storageClient.getItem(LOCAL_STORAGE_DISCOVERY_KEY) === LOCAL_STORAGE_DISCOVERY_VALUE;
26
28
  }, [storageClient]);
27
29
  useEffect(function () {
28
- if (!discovered) {
29
- storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, true, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
30
- }
30
+ renderedTime.current = Date.now();
31
+ return function () {
32
+ if (!discovered && renderedTime.current) {
33
+ var duration = Date.now() - renderedTime.current;
34
+ if (duration > LOCAL_STORAGE_DISCOVERY_REQUIRED_TIME) {
35
+ storageClient.setItemWithExpiry(LOCAL_STORAGE_DISCOVERY_KEY, LOCAL_STORAGE_DISCOVERY_VALUE, LOCAL_STORAGE_DISCOVERY_EXPIRY_IN_MS);
36
+ }
37
+ }
38
+ };
31
39
  }, [storageClient, discovered]);
32
40
  var component = useMemo(function () {
33
41
  if (!discovered) {
@@ -147,6 +147,8 @@ var Container = function Container(_ref3) {
147
147
  hidePadding = _ref3$hidePadding === void 0 ? false : _ref3$hidePadding,
148
148
  onClick = _ref3.onClick,
149
149
  retry = _ref3.retry,
150
+ _ref3$showAuthTooltip = _ref3.showAuthTooltip,
151
+ showAuthTooltip = _ref3$showAuthTooltip === void 0 ? false : _ref3$showAuthTooltip,
150
152
  _ref3$showHoverPrevie = _ref3.showHoverPreview,
151
153
  showHoverPreview = _ref3$showHoverPrevie === void 0 ? false : _ref3$showHoverPrevie,
152
154
  _ref3$showServerActio = _ref3.showServerActions,
@@ -172,7 +174,7 @@ var Container = function Container(_ref3) {
172
174
  "data-smart-link-container": true,
173
175
  "data-testid": testId
174
176
  }, clickableContainer ? getLayeredLink(testId, context, children, onClick) : null, renderChildren(children, size, theme, status, retry, onClick, showHoverPreview ? onActionMenuOpenChange : undefined));
175
- if (showHoverPreview && context !== null && context !== void 0 && context.url) {
177
+ if (context !== null && context !== void 0 && context.url && (showHoverPreview && status === 'resolved' || showAuthTooltip && status === 'unauthorized')) {
176
178
  return jsx(HoverCard, {
177
179
  url: context === null || context === void 0 ? void 0 : context.url,
178
180
  canOpen: hoverCardCanOpen,
@@ -22,6 +22,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
22
22
  onError = _ref.onError,
23
23
  onResolve = _ref.onResolve,
24
24
  renderers = _ref.renderers,
25
+ showAuthTooltip = _ref.showAuthTooltip,
25
26
  showHoverPreview = _ref.showHoverPreview,
26
27
  showServerActions = _ref.showServerActions,
27
28
  testId = _ref.testId,
@@ -87,6 +88,7 @@ var FlexibleCard = function FlexibleCard(_ref) {
87
88
  retry: retry,
88
89
  showHoverPreview: showHoverPreview,
89
90
  showServerActions: showServerActions,
91
+ showAuthTooltip: showAuthTooltip,
90
92
  status: status
91
93
  }), children))));
92
94
  };
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "onResolve" | "showAuthTooltip" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -1,6 +1,6 @@
1
1
  import { SmartLinkStatus } from '../../../../constants';
2
2
  import { FlexibleCardProps, FlexibleUiOptions, RetryOptions } from '../../types';
3
- export type ContainerProps = Pick<FlexibleCardProps, 'onClick' | 'showHoverPreview' | 'showServerActions'> & FlexibleUiOptions & {
3
+ export type ContainerProps = Pick<FlexibleCardProps, 'onClick' | 'showHoverPreview' | 'showServerActions' | 'showAuthTooltip'> & FlexibleUiOptions & {
4
4
  /**
5
5
  * The options that determine the retry behaviour when a Smart Link errors.
6
6
  */
@@ -81,6 +81,11 @@ export type FlexibleCardProps = {
81
81
  * over the smartlink. Default value is false.
82
82
  */
83
83
  showHoverPreview?: Boolean;
84
+ /**
85
+ * Determines whether to show an unauthorised view of the hover card
86
+ * when a user hovers over a smartlink.
87
+ */
88
+ showAuthTooltip?: Boolean;
84
89
  };
85
90
  export type FlexibleUiOptions = {
86
91
  /**
@@ -1,5 +1,5 @@
1
1
  import React from 'react';
2
2
  import { CardAppearance, CardPlatform, CardProps } from './types';
3
3
  import { WrappedComponentProps } from 'react-intl-next';
4
- export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "onResolve" | "showAuthTooltip" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
4
+ export declare const Card: React.ForwardRefExoticComponent<Pick<Omit<React.PropsWithChildren<import("react-intl-next").WithIntlProps<CardProps & WrappedComponentProps<"intl">>>, keyof import("@atlaskit/analytics-next").WithAnalyticsEventsProps> & React.RefAttributes<any> & import("@atlaskit/analytics-next").WithContextProps, "url" | "children" | "data" | "key" | "id" | "placeholder" | "onError" | "onClick" | "appearance" | "testId" | "analyticsContext" | "isSelected" | "inheritDimensions" | "ui" | "showActions" | "showHoverPreview" | "showServerActions" | "showAuthTooltip" | "onResolve" | "platform" | "frameStyle" | "embedIframeRef" | "inlinePreloaderStyle" | "isFrameVisible" | "importer" | "container" | "fallbackComponent" | "embedIframeUrlType" | "analyticsEvents" | "forwardedRef"> & React.RefAttributes<any>>;
5
5
  export type { CardAppearance, CardProps, CardPlatform };
@@ -1,6 +1,6 @@
1
1
  import { SmartLinkStatus } from '../../../../constants';
2
2
  import { FlexibleCardProps, FlexibleUiOptions, RetryOptions } from '../../types';
3
- export type ContainerProps = Pick<FlexibleCardProps, 'onClick' | 'showHoverPreview' | 'showServerActions'> & FlexibleUiOptions & {
3
+ export type ContainerProps = Pick<FlexibleCardProps, 'onClick' | 'showHoverPreview' | 'showServerActions' | 'showAuthTooltip'> & FlexibleUiOptions & {
4
4
  /**
5
5
  * The options that determine the retry behaviour when a Smart Link errors.
6
6
  */
@@ -81,6 +81,11 @@ export type FlexibleCardProps = {
81
81
  * over the smartlink. Default value is false.
82
82
  */
83
83
  showHoverPreview?: Boolean;
84
+ /**
85
+ * Determines whether to show an unauthorised view of the hover card
86
+ * when a user hovers over a smartlink.
87
+ */
88
+ showAuthTooltip?: Boolean;
84
89
  };
85
90
  export type FlexibleUiOptions = {
86
91
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.5.6",
3
+ "version": "26.5.8",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"