@atlaskit/smart-card 23.4.1 → 23.4.2

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 (48) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/BlockCard/actions/flexible/AuthorizeAction.js +32 -0
  4. package/dist/cjs/view/BlockCard/actions/flexible/ForbiddenAction.js +32 -0
  5. package/dist/cjs/view/BlockCard/actions/flexible/RetryAction.js +32 -0
  6. package/dist/cjs/view/BlockCard/components/flexible/footer/index.js +69 -0
  7. package/dist/cjs/view/BlockCard/views/flexible/FlexibleErroredView.js +83 -0
  8. package/dist/cjs/view/BlockCard/views/flexible/FlexibleForbiddenView.js +85 -0
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleNotFoundView.js +73 -0
  10. package/dist/cjs/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +79 -0
  11. package/dist/cjs/view/BlockCard/views/flexible/types.js +5 -0
  12. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +9 -1
  13. package/dist/cjs/view/FlexibleCard/utils.js +5 -1
  14. package/dist/es2019/version.json +1 -1
  15. package/dist/es2019/view/BlockCard/actions/flexible/AuthorizeAction.js +16 -0
  16. package/dist/es2019/view/BlockCard/actions/flexible/ForbiddenAction.js +16 -0
  17. package/dist/es2019/view/BlockCard/actions/flexible/RetryAction.js +16 -0
  18. package/dist/es2019/view/BlockCard/components/flexible/footer/index.js +56 -0
  19. package/dist/es2019/view/BlockCard/views/flexible/FlexibleErroredView.js +55 -0
  20. package/dist/es2019/view/BlockCard/views/flexible/FlexibleForbiddenView.js +57 -0
  21. package/dist/es2019/view/BlockCard/views/flexible/FlexibleNotFoundView.js +54 -0
  22. package/dist/es2019/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +53 -0
  23. package/dist/es2019/view/BlockCard/views/flexible/types.js +1 -0
  24. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +2 -1
  25. package/dist/es2019/view/FlexibleCard/utils.js +4 -1
  26. package/dist/esm/version.json +1 -1
  27. package/dist/esm/view/BlockCard/actions/flexible/AuthorizeAction.js +18 -0
  28. package/dist/esm/view/BlockCard/actions/flexible/ForbiddenAction.js +18 -0
  29. package/dist/esm/view/BlockCard/actions/flexible/RetryAction.js +18 -0
  30. package/dist/esm/view/BlockCard/components/flexible/footer/index.js +54 -0
  31. package/dist/esm/view/BlockCard/views/flexible/FlexibleErroredView.js +57 -0
  32. package/dist/esm/view/BlockCard/views/flexible/FlexibleForbiddenView.js +59 -0
  33. package/dist/esm/view/BlockCard/views/flexible/FlexibleNotFoundView.js +54 -0
  34. package/dist/esm/view/BlockCard/views/flexible/FlexibleUnauthorisedView.js +56 -0
  35. package/dist/esm/view/BlockCard/views/flexible/types.js +1 -0
  36. package/dist/esm/view/FlexibleCard/components/blocks/index.js +2 -1
  37. package/dist/esm/view/FlexibleCard/utils.js +4 -1
  38. package/dist/types/view/BlockCard/actions/flexible/AuthorizeAction.d.ts +8 -0
  39. package/dist/types/view/BlockCard/actions/flexible/ForbiddenAction.d.ts +8 -0
  40. package/dist/types/view/BlockCard/actions/flexible/RetryAction.d.ts +8 -0
  41. package/dist/types/view/BlockCard/components/flexible/footer/index.d.ts +12 -0
  42. package/dist/types/view/BlockCard/views/flexible/FlexibleErroredView.d.ts +10 -0
  43. package/dist/types/view/BlockCard/views/flexible/FlexibleForbiddenView.d.ts +11 -0
  44. package/dist/types/view/BlockCard/views/flexible/FlexibleNotFoundView.d.ts +10 -0
  45. package/dist/types/view/BlockCard/views/flexible/FlexibleUnauthorisedView.d.ts +11 -0
  46. package/dist/types/view/BlockCard/views/flexible/types.d.ts +56 -0
  47. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  48. package/package.json +1 -1
@@ -2,4 +2,5 @@ export { default as FooterBlock } from './footer-block';
2
2
  export { default as MetadataBlock } from './metadata-block';
3
3
  export { default as PreviewBlock } from './preview-block';
4
4
  export { default as SnippetBlock } from './snippet-block';
5
- export { default as TitleBlock } from './title-block';
5
+ export { default as TitleBlock } from './title-block';
6
+ export { default as CustomBlock } from './block';
@@ -6,6 +6,7 @@ import extractFlexibleLinkContext from '../../extractors/flexible';
6
6
  import { extractErrorIcon } from '../../extractors/flexible/icon';
7
7
  import { handleOnClick } from '../../utils';
8
8
  import { extractProvider } from '@atlaskit/linking-common/extractors';
9
+ import extractProviderIcon from '../../extractors/flexible/icon/extract-provider-icon';
9
10
  export var getContextByStatus = function getContextByStatus(url, status, details, renderers) {
10
11
  switch (status) {
11
12
  case SmartLinkStatus.Pending:
@@ -25,10 +26,12 @@ export var getContextByStatus = function getContextByStatus(url, status, details
25
26
  case SmartLinkStatus.Fallback:
26
27
  default:
27
28
  var linkIcon = extractErrorIcon(details, status);
29
+ var provider = extractProviderIcon(details === null || details === void 0 ? void 0 : details.data);
28
30
  return {
29
31
  linkIcon: linkIcon,
30
32
  title: url,
31
- url: url
33
+ url: url,
34
+ provider: provider
32
35
  };
33
36
  }
34
37
  };
@@ -0,0 +1,8 @@
1
+ import { CustomActionItem } from '../../../FlexibleCard/components/blocks/types';
2
+ /**
3
+ * Returns a CustomActionItem with a "Connect" default message
4
+ *
5
+ * @see CustomActionItem
6
+ * @param onAuthorize a function that will be called on the click of the button
7
+ */
8
+ export declare const AuthorizeAction: (onAuthorize: () => void) => CustomActionItem;
@@ -0,0 +1,8 @@
1
+ import { CustomActionItem } from '../../../FlexibleCard/components/blocks/types';
2
+ /**
3
+ * Returns a CustomActionItem with a "Try Another Account" default message
4
+ *
5
+ * @see CustomActionItem
6
+ * @param onAuthorize a function that will be called on the click of the button
7
+ */
8
+ export declare const ForbiddenAction: (onAuthorize: () => void) => CustomActionItem;
@@ -0,0 +1,8 @@
1
+ import { CustomActionItem } from '../../../FlexibleCard/components/blocks/types';
2
+ /**
3
+ * Returns a CustomActionItem with a "Retry" default message
4
+ *
5
+ * @see CustomActionItem
6
+ * @param onRetry a function that will be called on the click of the "Retry" button
7
+ */
8
+ export declare const RetryAction: (onRetry: () => void) => CustomActionItem;
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { FooterBlockProps } from '../../../../FlexibleCard/components/blocks/footer-block/types';
3
+ /**
4
+ * This Components is a footer that is used in a Block Card with Flexible UI.
5
+ * It contains a provider icon if provider is present and an actions list if one is passed.
6
+ * To be shown as a part of Flexible UI, needs to be wrapped inside of a CustomBlock
7
+ *
8
+ * @see CustomBlock
9
+ * @param props are the data required for the block, such as actions to be displayed.
10
+ */
11
+ declare const Footer: React.FC<FooterBlockProps>;
12
+ export default Footer;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FlexibleBlockCardProps } from './types';
3
+ /**
4
+ * This view represents a Block Card with an 'Errored' status.
5
+ *
6
+ * @see SmartLinkStatus
7
+ * @see FlexibleCardProps
8
+ */
9
+ declare const FlexibleErroredView: ({ cardState, onAuthorize, onError, ui, url, onClick, testId, }: FlexibleBlockCardProps) => JSX.Element;
10
+ export default FlexibleErroredView;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { FlexibleBlockCardProps } from './types';
3
+ /**
4
+ * This view represent a Block Card with the 'Forbidden' status.
5
+ * It should have a "Try another account" button that will allow a user to connect another account and view the block card.
6
+ *
7
+ * @see SmartLinkStatus
8
+ * @see FlexibleCardProps
9
+ */
10
+ declare const FlexibleForbiddenView: ({ cardState, onAuthorize, onClick, onError, testId, ui, url, }: FlexibleBlockCardProps) => JSX.Element;
11
+ export default FlexibleForbiddenView;
@@ -0,0 +1,10 @@
1
+ /// <reference types="react" />
2
+ import { FlexibleBlockCardProps } from './types';
3
+ /**
4
+ * This view represents a Block Card with a 'Not_Found' status.
5
+ *
6
+ * @see SmartLinkStatus
7
+ * @see FlexibleCardProps
8
+ */
9
+ declare const FlexibleNotFoundView: ({ cardState, onAuthorize, onError, ui, url, onClick, testId, }: FlexibleBlockCardProps) => JSX.Element;
10
+ export default FlexibleNotFoundView;
@@ -0,0 +1,11 @@
1
+ /// <reference types="react" />
2
+ import { FlexibleBlockCardProps } from './types';
3
+ /**
4
+ * This view represents a Block card that has an 'Unauthorized' status .
5
+ * It should have a "Connect" button that will allow a user to connect their account and view the block card.
6
+ *
7
+ * @see SmartLinkStatus
8
+ * @see UnauthorisedViewProps
9
+ */
10
+ declare const FlexibleUnauthorisedView: ({ cardState, providerName, onAuthorize, onClick, onError, testId, ui, url, }: FlexibleBlockCardProps) => JSX.Element;
11
+ export default FlexibleUnauthorisedView;
@@ -0,0 +1,56 @@
1
+ /// <reference types="react" />
2
+ import { CardState } from '@atlaskit/linking-common';
3
+ import { OnErrorCallback } from '../../../types';
4
+ import { FlexibleUiOptions } from '../../../FlexibleCard/types';
5
+ import { OnResolveCallback } from '../../../Card/types';
6
+ import { CardProviderRenderers } from '@atlaskit/link-provider';
7
+ export declare type FlexibleBlockCardProps = {
8
+ /**
9
+ * Determines the status and data of the Smart Link.
10
+ * @internal
11
+ */
12
+ cardState: CardState;
13
+ /**
14
+ * function to be called after a flexible card has rendered its resolved state
15
+ */
16
+ onResolve?: OnResolveCallback;
17
+ /**
18
+ * Any additional renderers required by Flexible UI. Currently used by icon
19
+ * to render Emoji.
20
+ */
21
+ renderers?: CardProviderRenderers;
22
+ /**
23
+ * An additional action that can be performed when link is not resolved, e.g.
24
+ * connect account to gain access to 403 link.
25
+ * @internal
26
+ */
27
+ onAuthorize?: () => void;
28
+ /**
29
+ * Determines the onClick behaviour of Flexible UI. This will proxy to the
30
+ * TitleBlock if supplied.
31
+ */
32
+ onClick?: React.EventHandler<React.MouseEvent | React.KeyboardEvent>;
33
+ /**
34
+ * function to be called after a flexible card has rendered its error states
35
+ */
36
+ onError?: OnErrorCallback;
37
+ /**
38
+ * A name of the provider, needed to specify to user which account has to be connected
39
+ */
40
+ providerName?: string;
41
+ /**
42
+ * A `testId` prop is provided for specified elements, which is a unique
43
+ * string that appears as a data attribute `data-testid` in the rendered code,
44
+ * serving as a hook for automated tests
45
+ */
46
+ testId?: string;
47
+ /**
48
+ * Determines the appearance of Flexible UI.
49
+ * @see FlexibleUiOptions
50
+ */
51
+ ui?: FlexibleUiOptions;
52
+ /**
53
+ * Determines the URL of the Smart Link.
54
+ */
55
+ url: string;
56
+ };
@@ -3,3 +3,4 @@ export { default as MetadataBlock } from './metadata-block';
3
3
  export { default as PreviewBlock } from './preview-block';
4
4
  export { default as SnippetBlock } from './snippet-block';
5
5
  export { default as TitleBlock } from './title-block';
6
+ export { default as CustomBlock } from './block';
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "23.4.1",
3
+ "version": "23.4.2",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"