@atlaskit/smart-card 18.0.10 → 18.0.11

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,28 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 18.0.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [`ec98e2d8ebc`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ec98e2d8ebc) - feat: Expose `useSmartLinkReload` hook.
8
+
9
+ ### Example Usage
10
+
11
+ As a consumer if you want to be able to reload the data backing a Smart Link, you may do:
12
+
13
+ ```tsx
14
+ export const MyComponent = () => {
15
+ const reloader = useSmartLinkReload(url, analytics);
16
+
17
+ return (
18
+ <MyInterfaceItem>
19
+ <Card />
20
+ <Button text="Retry" onClick={reloader} />
21
+ </MyInterfaceItem>
22
+ );
23
+ };
24
+ ```
25
+
3
26
  ## 18.0.10
4
27
 
5
28
  ### Patch Changes
package/dist/cjs/hooks.js CHANGED
@@ -9,5 +9,13 @@ Object.defineProperty(exports, "useSmartLinkActions", {
9
9
  return _useSmartLinkActions.useSmartLinkActions;
10
10
  }
11
11
  });
12
+ Object.defineProperty(exports, "useSmartLinkReload", {
13
+ enumerable: true,
14
+ get: function get() {
15
+ return _useSmartLinkReload.useSmartLinkReload;
16
+ }
17
+ });
18
+
19
+ var _useSmartLinkActions = require("./state/hooks-external/useSmartLinkActions");
12
20
 
13
- var _useSmartLinkActions = require("./state/hooks-external/useSmartLinkActions");
21
+ var _useSmartLinkReload = require("./state/hooks-external/useSmartLinkReload");
@@ -0,0 +1,32 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.useSmartLinkReload = useSmartLinkReload;
9
+
10
+ var _react = require("react");
11
+
12
+ var _uuid = _interopRequireDefault(require("uuid"));
13
+
14
+ var _actions = require("../actions");
15
+
16
+ var _analytics = require("../analytics");
17
+
18
+ /**
19
+ * Exposes a programmatic way to reload the data being used to render a Smart Link.
20
+ * @param
21
+ * @returns
22
+ */
23
+ function useSmartLinkReload(_ref) {
24
+ var url = _ref.url,
25
+ analyticsHandler = _ref.analyticsHandler;
26
+ var id = (0, _react.useMemo)(function () {
27
+ return (0, _uuid.default)();
28
+ }, []);
29
+ var linkAnalytics = (0, _analytics.useSmartLinkAnalytics)(analyticsHandler);
30
+ var linkActions = (0, _actions.useSmartCardActions)(id, url, linkAnalytics);
31
+ return linkActions.reload;
32
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.10",
3
+ "version": "18.0.11",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
- export { useSmartLinkActions } from './state/hooks-external/useSmartLinkActions';
1
+ export { useSmartLinkActions } from './state/hooks-external/useSmartLinkActions';
2
+ export { useSmartLinkReload } from './state/hooks-external/useSmartLinkReload';
@@ -0,0 +1,19 @@
1
+ import { useMemo } from 'react';
2
+ import uuid from 'uuid';
3
+ import { useSmartCardActions as useLinkActions } from '../actions';
4
+ import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
5
+
6
+ /**
7
+ * Exposes a programmatic way to reload the data being used to render a Smart Link.
8
+ * @param
9
+ * @returns
10
+ */
11
+ export function useSmartLinkReload({
12
+ url,
13
+ analyticsHandler
14
+ }) {
15
+ const id = useMemo(() => uuid(), []);
16
+ const linkAnalytics = useLinkAnalytics(analyticsHandler);
17
+ const linkActions = useLinkActions(id, url, linkAnalytics);
18
+ return linkActions.reload;
19
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.10",
3
+ "version": "18.0.11",
4
4
  "sideEffects": false
5
5
  }
package/dist/esm/hooks.js CHANGED
@@ -1 +1,2 @@
1
- export { useSmartLinkActions } from './state/hooks-external/useSmartLinkActions';
1
+ export { useSmartLinkActions } from './state/hooks-external/useSmartLinkActions';
2
+ export { useSmartLinkReload } from './state/hooks-external/useSmartLinkReload';
@@ -0,0 +1,20 @@
1
+ import { useMemo } from 'react';
2
+ import uuid from 'uuid';
3
+ import { useSmartCardActions as useLinkActions } from '../actions';
4
+ import { useSmartLinkAnalytics as useLinkAnalytics } from '../analytics';
5
+
6
+ /**
7
+ * Exposes a programmatic way to reload the data being used to render a Smart Link.
8
+ * @param
9
+ * @returns
10
+ */
11
+ export function useSmartLinkReload(_ref) {
12
+ var url = _ref.url,
13
+ analyticsHandler = _ref.analyticsHandler;
14
+ var id = useMemo(function () {
15
+ return uuid();
16
+ }, []);
17
+ var linkAnalytics = useLinkAnalytics(analyticsHandler);
18
+ var linkActions = useLinkActions(id, url, linkAnalytics);
19
+ return linkActions.reload;
20
+ }
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.10",
3
+ "version": "18.0.11",
4
4
  "sideEffects": false
5
5
  }
@@ -1 +1,2 @@
1
1
  export { useSmartLinkActions } from './state/hooks-external/useSmartLinkActions';
2
+ export { useSmartLinkReload } from './state/hooks-external/useSmartLinkReload';
@@ -0,0 +1,19 @@
1
+ import type { AnalyticsHandler } from '../../utils/types';
2
+ export interface UseSmartLinkReloadOpts {
3
+ /**
4
+ * Smart Link URL for which the reload will be invoked.
5
+ * @example https://start.atlassian.com
6
+ */
7
+ url: string;
8
+ /**
9
+ * Callback for sending analytics events.
10
+ * @description Accepts an analytics payload and fires it to a system.
11
+ */
12
+ analyticsHandler: AnalyticsHandler;
13
+ }
14
+ /**
15
+ * Exposes a programmatic way to reload the data being used to render a Smart Link.
16
+ * @param
17
+ * @returns
18
+ */
19
+ export declare function useSmartLinkReload({ url, analyticsHandler, }: UseSmartLinkReloadOpts): () => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "18.0.10",
3
+ "version": "18.0.11",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"