@atlaskit/smart-card 17.1.0 → 17.3.1

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 (68) hide show
  1. package/CHANGELOG.md +28 -0
  2. package/dist/cjs/index.js +6 -0
  3. package/dist/cjs/version.json +1 -1
  4. package/dist/cjs/view/FlexibleCard/components/actions/{delete-action → action}/index.js +40 -25
  5. package/dist/cjs/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
  6. package/dist/cjs/view/FlexibleCard/components/actions/index.js +3 -1
  7. package/dist/cjs/view/FlexibleCard/components/actions/utils.js +34 -6
  8. package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  9. package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +7 -6
  10. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +9 -1
  11. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +116 -0
  12. package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/types.js +5 -0
  13. package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -1
  14. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +20 -10
  15. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  16. package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +1 -1
  17. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +49 -40
  18. package/dist/cjs/view/FlexibleCard/components/utils.js +1 -1
  19. package/dist/es2019/index.js +1 -1
  20. package/dist/es2019/version.json +1 -1
  21. package/dist/es2019/view/FlexibleCard/components/actions/{delete-action → action}/index.js +31 -15
  22. package/dist/es2019/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
  23. package/dist/es2019/view/FlexibleCard/components/actions/index.js +5 -3
  24. package/dist/es2019/view/FlexibleCard/components/actions/utils.js +27 -4
  25. package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  26. package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +12 -5
  27. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +2 -1
  28. package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +97 -0
  29. package/dist/{esm/view/FlexibleCard/components/actions → es2019/view/FlexibleCard/components/blocks/metadata-block}/types.js +0 -0
  30. package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -0
  31. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +16 -9
  32. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +28 -2
  33. package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +1 -0
  34. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +49 -38
  35. package/dist/es2019/view/FlexibleCard/components/utils.js +0 -1
  36. package/dist/esm/index.js +1 -1
  37. package/dist/esm/version.json +1 -1
  38. package/dist/esm/view/FlexibleCard/components/actions/action/index.js +82 -0
  39. package/dist/esm/view/FlexibleCard/components/actions/action/types.js +1 -0
  40. package/dist/esm/view/FlexibleCard/components/actions/index.js +5 -3
  41. package/dist/esm/view/FlexibleCard/components/actions/utils.js +26 -4
  42. package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
  43. package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +7 -6
  44. package/dist/esm/view/FlexibleCard/components/blocks/index.js +2 -1
  45. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +97 -0
  46. package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/types.js +1 -0
  47. package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -1
  48. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +17 -10
  49. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
  50. package/dist/esm/view/FlexibleCard/components/elements/link/index.js +1 -1
  51. package/dist/esm/view/FlexibleCard/components/elements/utils.js +49 -40
  52. package/dist/esm/view/FlexibleCard/components/utils.js +1 -1
  53. package/dist/types/index.d.ts +1 -1
  54. package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +5 -0
  55. package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +18 -0
  56. package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -1
  57. package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +2 -1
  58. package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +2 -0
  59. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
  60. package/dist/types/view/FlexibleCard/components/blocks/metadata-block/index.d.ts +4 -0
  61. package/dist/types/view/FlexibleCard/components/blocks/metadata-block/types.d.ts +6 -0
  62. package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -0
  63. package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +1 -0
  64. package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +1 -2
  65. package/package.json +1 -1
  66. package/dist/esm/view/FlexibleCard/components/actions/delete-action/index.js +0 -64
  67. package/dist/types/view/FlexibleCard/components/actions/delete-action/index.d.ts +0 -5
  68. package/dist/types/view/FlexibleCard/components/actions/types.d.ts +0 -10
@@ -57,17 +57,6 @@ var getContextKey = function getContextKey(name) {
57
57
  return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
58
58
  };
59
59
 
60
- var getFormattedMessage = function getFormattedMessage(descriptor, value) {
61
- return value ? {
62
- message: {
63
- descriptor: descriptor,
64
- values: {
65
- context: value
66
- }
67
- }
68
- } : undefined;
69
- };
70
-
71
60
  var getData = function getData(elementName, contextKey, context) {
72
61
  if (!context) {
73
62
  return undefined;
@@ -76,52 +65,72 @@ var getData = function getData(elementName, contextKey, context) {
76
65
  var data = context[contextKey];
77
66
 
78
67
  switch (elementName) {
68
+ case ElementName.AuthorGroup:
69
+ case ElementName.CollaboratorGroup:
70
+ return toAvatarGroupProps(data);
71
+
79
72
  case ElementName.CommentCount:
80
73
  case ElementName.ProgrammingLanguage:
81
74
  case ElementName.SubscriberCount:
82
- return {
83
- label: data
84
- };
85
-
86
- case ElementName.AuthorGroup:
87
- return {
88
- items: context.authorGroup
89
- };
90
-
91
- case ElementName.CollaboratorGroup:
92
- return {
93
- items: context.collaboratorGroup
94
- };
75
+ return toBadgeProps(data);
95
76
 
96
77
  case ElementName.CreatedBy:
97
- return getFormattedMessage(messages.created_by, context.createdBy);
78
+ return toFormattedTextProps(messages.created_by, context.createdBy);
79
+
80
+ case ElementName.CreatedOn:
81
+ return toDateTimeProps('created', context.createdOn);
98
82
 
99
83
  case ElementName.ModifiedBy:
100
- return getFormattedMessage(messages.modified_by, context.modifiedBy);
84
+ return toFormattedTextProps(messages.modified_by, context.modifiedBy);
101
85
 
102
86
  case ElementName.ModifiedOn:
103
- return context.modifiedOn ? {
104
- date: new Date(context.modifiedOn),
105
- type: 'modified'
106
- } : undefined;
107
-
108
- case ElementName.CreatedOn:
109
- return context.createdOn ? {
110
- date: new Date(context.createdOn),
111
- type: 'created'
112
- } : undefined;
87
+ return toDateTimeProps('modified', context.modifiedOn);
113
88
 
114
89
  case ElementName.Title:
115
- return {
116
- text: context.title,
117
- url: context.url
118
- };
90
+ return toLinkProps(context.title, context.url);
119
91
 
120
92
  default:
121
93
  return data;
122
94
  }
123
95
  };
124
96
 
97
+ var toAvatarGroupProps = function toAvatarGroupProps(items) {
98
+ return items ? {
99
+ items: items
100
+ } : undefined;
101
+ };
102
+
103
+ var toBadgeProps = function toBadgeProps(label) {
104
+ return label ? {
105
+ label: label
106
+ } : undefined;
107
+ };
108
+
109
+ var toDateTimeProps = function toDateTimeProps(type, dateString) {
110
+ return dateString ? {
111
+ date: new Date(dateString),
112
+ type: type
113
+ } : undefined;
114
+ };
115
+
116
+ var toFormattedTextProps = function toFormattedTextProps(descriptor, context) {
117
+ return context ? {
118
+ message: {
119
+ descriptor: descriptor,
120
+ values: {
121
+ context: context
122
+ }
123
+ }
124
+ } : undefined;
125
+ };
126
+
127
+ var toLinkProps = function toLinkProps(text, url) {
128
+ return text ? {
129
+ text: text,
130
+ url: url
131
+ } : undefined;
132
+ };
133
+
125
134
  export var createElement = function createElement(name) {
126
135
  var _ref = elementMappings[name] || {},
127
136
  BaseElement = _ref.component,
@@ -53,5 +53,5 @@ export var getLinkSizeStyles = function getLinkSizeStyles(size) {
53
53
  };
54
54
  export var getTruncateStyles = function getTruncateStyles(maxLines) {
55
55
  var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
56
- return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: -webkit-box;\n flex: 1 1 auto;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n max-height: calc(", " * ", ");\n "])), maxLines, maxLines, lineHeight);
56
+ return css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n display: -webkit-box;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n max-height: calc(", " * ", ");\n "])), maxLines, maxLines, lineHeight);
57
57
  };
@@ -17,5 +17,5 @@ export { useSmartLinkEvents } from './view/SmartLinkEvents/useSmartLinkEvents';
17
17
  export { contentFooterClassName, metadataListClassName, blockCardResolvingViewClassName, blockCardResolvedViewClassName, blockCardForbiddenViewClassName, blockCardIconImageClassName, blockCardResolvedViewByClassName, blockCardForbiddenViewLinkClassName, blockCardContentClassName, blockCardContentHeaderClassName, blockCardContentHeaderNameClassName, blockCardNotFoundViewClassName, blockCardErroredViewClassName, } from './classNames';
18
18
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback';
19
19
  export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme, } from './constants';
20
- export { TitleBlock } from './view/FlexibleCard/components/blocks';
20
+ export { MetadataBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
21
21
  export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
@@ -0,0 +1,5 @@
1
+ /** @jsx jsx */
2
+ import React from 'react';
3
+ import { ActionProps } from './types';
4
+ declare const Action: React.FC<ActionProps>;
5
+ export default Action;
@@ -0,0 +1,18 @@
1
+ import { SmartLinkSize } from '../../../../../constants';
2
+ import { Appearance } from '@atlaskit/button/types';
3
+ import { ReactChild } from 'react';
4
+ export declare type ActionProps = {
5
+ size?: SmartLinkSize;
6
+ testId?: string;
7
+ content?: React.ReactNode;
8
+ appearance?: Appearance;
9
+ onClick: () => any;
10
+ icon?: ReactChild;
11
+ iconPosition?: 'before' | 'after';
12
+ tooltipMessage?: React.ReactNode;
13
+ };
14
+ export declare type ActionIconProps = {
15
+ size?: SmartLinkSize;
16
+ testId?: string;
17
+ icon?: ReactChild;
18
+ };
@@ -1,3 +1,3 @@
1
1
  /// <reference types="react" />
2
- import { ActionProps } from './types';
2
+ import { ActionProps } from './action/types';
3
3
  export declare const DeleteAction: import("react").FC<ActionProps>;
@@ -1,3 +1,4 @@
1
1
  import { ActionName } from '../../../../constants';
2
2
  import React from 'react';
3
- export declare const createAction: <P extends {}>(name: ActionName) => React.FC<P>;
3
+ export declare const createDataAction: <P extends {}>(name: ActionName) => React.FC<P>;
4
+ export declare const createUIAction: <P extends {}>(name: ActionName) => React.FC<P>;
@@ -1,6 +1,8 @@
1
+ import { Interpolation } from '@emotion/core';
1
2
  import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
2
3
  export declare type ElementGroupProps = {
3
4
  align?: SmartLinkAlignment;
5
+ css?: Interpolation;
4
6
  direction?: SmartLinkDirection;
5
7
  size?: SmartLinkSize;
6
8
  testId?: string;
@@ -1 +1,2 @@
1
1
  export { default as TitleBlock } from './title-block';
2
+ export { default as MetadataBlock } from './metadata-block';
@@ -0,0 +1,4 @@
1
+ import React from 'react';
2
+ import { MetadataBlockProps } from './types';
3
+ declare const MetadataBlock: React.FC<MetadataBlockProps>;
4
+ export default MetadataBlock;
@@ -0,0 +1,6 @@
1
+ import { BlockProps, ElementItem } from '../types';
2
+ export declare type MetadataBlockProps = BlockProps & {
3
+ maxLines?: number;
4
+ primary?: ElementItem[];
5
+ secondary?: ElementItem[];
6
+ };
@@ -2,6 +2,7 @@ import React from 'react';
2
2
  import { SerializedStyles } from '@emotion/core';
3
3
  import { ActionItem, ElementItem } from './types';
4
4
  import { SmartLinkDirection, SmartLinkSize } from '../../../../constants';
5
+ export declare const getGapSize: (size: SmartLinkSize) => number;
5
6
  export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
6
7
  export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
7
8
  export declare const renderElementItems: (items?: ElementItem[]) => React.ReactNode | undefined;
@@ -1,3 +1,4 @@
1
+ /** @jsx jsx */
1
2
  import React from 'react';
2
3
  import { AvatarGroupProps } from './types';
3
4
  declare const AvatarGroup: React.FC<AvatarGroupProps>;
@@ -1,5 +1,5 @@
1
1
  import { ElementProps } from '../types';
2
- declare type AvatarItemProps = {
2
+ export declare type AvatarItemProps = {
3
3
  src?: string;
4
4
  name: string;
5
5
  };
@@ -7,4 +7,3 @@ export declare type AvatarGroupProps = ElementProps & {
7
7
  items?: AvatarItemProps[];
8
8
  maxCount?: number;
9
9
  };
10
- export {};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.1.0",
3
+ "version": "17.3.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -1,64 +0,0 @@
1
- import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
- var _templateObject;
4
-
5
- /** @jsx jsx */
6
- import React from 'react';
7
- import { FormattedMessage } from 'react-intl-next';
8
- import { css, jsx } from '@emotion/core';
9
- import Button from '@atlaskit/button/custom-theme-button';
10
- import CrossIcon from '@atlaskit/icon/glyph/cross';
11
- import { SmartLinkSize } from '../../../../../constants';
12
- import Tooltip from '@atlaskit/tooltip';
13
- import { getIconSizeStyles } from '../../utils';
14
- import { messages } from '../../../../../messages';
15
- import { tokens } from '../../../../../utils/token';
16
- import { handleOnClick } from '../../../../../utils';
17
-
18
- var getWidth = function getWidth(size) {
19
- switch (size) {
20
- case SmartLinkSize.XLarge:
21
- case SmartLinkSize.Large:
22
- return '1.5rem';
23
-
24
- case SmartLinkSize.Medium:
25
- case SmartLinkSize.Small:
26
- default:
27
- return '1rem';
28
- }
29
- };
30
-
31
- var getStyles = function getStyles(size) {
32
- return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
33
- };
34
-
35
- var DeleteAction = function DeleteAction(_ref) {
36
- var _ref$appearance = _ref.appearance,
37
- appearance = _ref$appearance === void 0 ? 'subtle' : _ref$appearance,
38
- content = _ref.content,
39
- onClick = _ref.onClick,
40
- _ref$size = _ref.size,
41
- size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
42
- _ref$testId = _ref.testId,
43
- testId = _ref$testId === void 0 ? 'smart-action-delete-action' : _ref$testId;
44
-
45
- if (!onClick) {
46
- return null;
47
- }
48
-
49
- return jsx(Tooltip, {
50
- content: jsx(FormattedMessage, messages.delete)
51
- }, jsx(Button, {
52
- spacing: "none",
53
- appearance: appearance,
54
- testId: testId,
55
- onClick: handleOnClick(onClick)
56
- }, content || jsx("span", {
57
- css: getStyles(size),
58
- "data-testid": "".concat(testId, "-icon")
59
- }, jsx(CrossIcon, {
60
- label: "Delete"
61
- }))));
62
- };
63
-
64
- export default DeleteAction;
@@ -1,5 +0,0 @@
1
- /** @jsx jsx */
2
- import React from 'react';
3
- import { ActionProps } from '../types';
4
- declare const DeleteAction: React.FC<ActionProps>;
5
- export default DeleteAction;
@@ -1,10 +0,0 @@
1
- /// <reference types="react" />
2
- import { SmartLinkSize } from '../../../../constants';
3
- import { Appearance } from '@atlaskit/button/types';
4
- export declare type ActionProps = {
5
- size?: SmartLinkSize;
6
- testId?: string;
7
- content?: React.ReactNode;
8
- appearance?: Appearance;
9
- onClick: () => any;
10
- };