@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.
- package/CHANGELOG.md +28 -0
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/{delete-action → action}/index.js +40 -25
- package/dist/cjs/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
- package/dist/cjs/view/FlexibleCard/components/actions/index.js +3 -1
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +34 -6
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/element-group/index.js +7 -6
- package/dist/cjs/view/FlexibleCard/components/blocks/index.js +9 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/index.js +116 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/metadata-block/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +20 -10
- package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
- package/dist/cjs/view/FlexibleCard/components/elements/link/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +49 -40
- package/dist/cjs/view/FlexibleCard/components/utils.js +1 -1
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/{delete-action → action}/index.js +31 -15
- package/dist/es2019/view/FlexibleCard/components/actions/{types.js → action/types.js} +0 -0
- package/dist/es2019/view/FlexibleCard/components/actions/index.js +5 -3
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +27 -4
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/element-group/index.js +12 -5
- package/dist/es2019/view/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/metadata-block/index.js +97 -0
- package/dist/{esm/view/FlexibleCard/components/actions → es2019/view/FlexibleCard/components/blocks/metadata-block}/types.js +0 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +16 -9
- package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +28 -2
- package/dist/es2019/view/FlexibleCard/components/elements/link/index.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +49 -38
- package/dist/es2019/view/FlexibleCard/components/utils.js +0 -1
- package/dist/esm/index.js +1 -1
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +82 -0
- package/dist/esm/view/FlexibleCard/components/actions/action/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/actions/index.js +5 -3
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +26 -4
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/element-group/index.js +7 -6
- package/dist/esm/view/FlexibleCard/components/blocks/index.js +2 -1
- package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/index.js +97 -0
- package/dist/esm/view/FlexibleCard/components/blocks/metadata-block/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/blocks/title-block/errored/index.js +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +17 -10
- package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +24 -2
- package/dist/esm/view/FlexibleCard/components/elements/link/index.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +49 -40
- package/dist/esm/view/FlexibleCard/components/utils.js +1 -1
- package/dist/types/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/actions/action/index.d.ts +5 -0
- package/dist/types/view/FlexibleCard/components/actions/action/types.d.ts +18 -0
- package/dist/types/view/FlexibleCard/components/actions/index.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/actions/utils.d.ts +2 -1
- package/dist/types/view/FlexibleCard/components/blocks/element-group/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/blocks/metadata-block/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/metadata-block/types.d.ts +6 -0
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/elements/avatar-group/index.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +1 -2
- package/package.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/delete-action/index.js +0 -64
- package/dist/types/view/FlexibleCard/components/actions/delete-action/index.d.ts +0 -5
- package/dist/types/view/FlexibleCard/components/actions/types.d.ts +0 -10
|
@@ -67,15 +67,6 @@ const getContextKey = name => {
|
|
|
67
67
|
return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
|
|
68
68
|
};
|
|
69
69
|
|
|
70
|
-
const getFormattedMessage = (descriptor, value) => value ? {
|
|
71
|
-
message: {
|
|
72
|
-
descriptor,
|
|
73
|
-
values: {
|
|
74
|
-
context: value
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
} : undefined;
|
|
78
|
-
|
|
79
70
|
const getData = (elementName, contextKey, context) => {
|
|
80
71
|
if (!context) {
|
|
81
72
|
return undefined;
|
|
@@ -84,52 +75,72 @@ const getData = (elementName, contextKey, context) => {
|
|
|
84
75
|
const data = context[contextKey];
|
|
85
76
|
|
|
86
77
|
switch (elementName) {
|
|
78
|
+
case ElementName.AuthorGroup:
|
|
79
|
+
case ElementName.CollaboratorGroup:
|
|
80
|
+
return toAvatarGroupProps(data);
|
|
81
|
+
|
|
87
82
|
case ElementName.CommentCount:
|
|
88
83
|
case ElementName.ProgrammingLanguage:
|
|
89
84
|
case ElementName.SubscriberCount:
|
|
90
|
-
return
|
|
91
|
-
label: data
|
|
92
|
-
};
|
|
93
|
-
|
|
94
|
-
case ElementName.AuthorGroup:
|
|
95
|
-
return {
|
|
96
|
-
items: context.authorGroup
|
|
97
|
-
};
|
|
98
|
-
|
|
99
|
-
case ElementName.CollaboratorGroup:
|
|
100
|
-
return {
|
|
101
|
-
items: context.collaboratorGroup
|
|
102
|
-
};
|
|
85
|
+
return toBadgeProps(data);
|
|
103
86
|
|
|
104
87
|
case ElementName.CreatedBy:
|
|
105
|
-
return
|
|
88
|
+
return toFormattedTextProps(messages.created_by, context.createdBy);
|
|
89
|
+
|
|
90
|
+
case ElementName.CreatedOn:
|
|
91
|
+
return toDateTimeProps('created', context.createdOn);
|
|
106
92
|
|
|
107
93
|
case ElementName.ModifiedBy:
|
|
108
|
-
return
|
|
94
|
+
return toFormattedTextProps(messages.modified_by, context.modifiedBy);
|
|
109
95
|
|
|
110
96
|
case ElementName.ModifiedOn:
|
|
111
|
-
return context.modifiedOn
|
|
112
|
-
date: new Date(context.modifiedOn),
|
|
113
|
-
type: 'modified'
|
|
114
|
-
} : undefined;
|
|
115
|
-
|
|
116
|
-
case ElementName.CreatedOn:
|
|
117
|
-
return context.createdOn ? {
|
|
118
|
-
date: new Date(context.createdOn),
|
|
119
|
-
type: 'created'
|
|
120
|
-
} : undefined;
|
|
97
|
+
return toDateTimeProps('modified', context.modifiedOn);
|
|
121
98
|
|
|
122
99
|
case ElementName.Title:
|
|
123
|
-
return
|
|
124
|
-
text: context.title,
|
|
125
|
-
url: context.url
|
|
126
|
-
};
|
|
100
|
+
return toLinkProps(context.title, context.url);
|
|
127
101
|
|
|
128
102
|
default:
|
|
129
103
|
return data;
|
|
130
104
|
}
|
|
131
105
|
};
|
|
132
106
|
|
|
107
|
+
const toAvatarGroupProps = items => {
|
|
108
|
+
return items ? {
|
|
109
|
+
items
|
|
110
|
+
} : undefined;
|
|
111
|
+
};
|
|
112
|
+
|
|
113
|
+
const toBadgeProps = label => {
|
|
114
|
+
return label ? {
|
|
115
|
+
label
|
|
116
|
+
} : undefined;
|
|
117
|
+
};
|
|
118
|
+
|
|
119
|
+
const toDateTimeProps = (type, dateString) => {
|
|
120
|
+
return dateString ? {
|
|
121
|
+
date: new Date(dateString),
|
|
122
|
+
type
|
|
123
|
+
} : undefined;
|
|
124
|
+
};
|
|
125
|
+
|
|
126
|
+
const toFormattedTextProps = (descriptor, context) => {
|
|
127
|
+
return context ? {
|
|
128
|
+
message: {
|
|
129
|
+
descriptor,
|
|
130
|
+
values: {
|
|
131
|
+
context
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
} : undefined;
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
const toLinkProps = (text, url) => {
|
|
138
|
+
return text ? {
|
|
139
|
+
text,
|
|
140
|
+
url
|
|
141
|
+
} : undefined;
|
|
142
|
+
};
|
|
143
|
+
|
|
133
144
|
export const createElement = name => {
|
|
134
145
|
const {
|
|
135
146
|
component: BaseElement,
|
package/dist/esm/index.js
CHANGED
|
@@ -13,4 +13,4 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
|
|
|
13
13
|
export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback'; // Flexible UI
|
|
14
14
|
|
|
15
15
|
export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
|
|
16
|
-
export { TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
16
|
+
export { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
package/dist/esm/version.json
CHANGED
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
6
|
+
import React from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
8
|
+
import Button from '@atlaskit/button/custom-theme-button';
|
|
9
|
+
import { SmartLinkSize } from '../../../../../constants';
|
|
10
|
+
import Tooltip from '@atlaskit/tooltip';
|
|
11
|
+
import { getIconSizeStyles } from '../../utils';
|
|
12
|
+
import { tokens } from '../../../../../utils/token';
|
|
13
|
+
import { handleOnClick } from '../../../../../utils';
|
|
14
|
+
|
|
15
|
+
var getWidth = function getWidth(size) {
|
|
16
|
+
switch (size) {
|
|
17
|
+
case SmartLinkSize.XLarge:
|
|
18
|
+
case SmartLinkSize.Large:
|
|
19
|
+
return '1.5rem';
|
|
20
|
+
|
|
21
|
+
case SmartLinkSize.Medium:
|
|
22
|
+
case SmartLinkSize.Small:
|
|
23
|
+
default:
|
|
24
|
+
return '1rem';
|
|
25
|
+
}
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
var getIconStyles = function getIconStyles(size) {
|
|
29
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getWidth(size)));
|
|
30
|
+
};
|
|
31
|
+
|
|
32
|
+
var ActionIcon = function ActionIcon(_ref) {
|
|
33
|
+
var size = _ref.size,
|
|
34
|
+
testId = _ref.testId,
|
|
35
|
+
icon = _ref.icon;
|
|
36
|
+
return jsx("span", {
|
|
37
|
+
css: getIconStyles(size),
|
|
38
|
+
"data-testid": "".concat(testId, "-icon")
|
|
39
|
+
}, icon);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var Action = function Action(_ref2) {
|
|
43
|
+
var _ref2$appearance = _ref2.appearance,
|
|
44
|
+
appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
|
|
45
|
+
content = _ref2.content,
|
|
46
|
+
onClick = _ref2.onClick,
|
|
47
|
+
_ref2$size = _ref2.size,
|
|
48
|
+
size = _ref2$size === void 0 ? SmartLinkSize.Medium : _ref2$size,
|
|
49
|
+
_ref2$testId = _ref2.testId,
|
|
50
|
+
testId = _ref2$testId === void 0 ? 'smart-action' : _ref2$testId,
|
|
51
|
+
icon = _ref2.icon,
|
|
52
|
+
_ref2$iconPosition = _ref2.iconPosition,
|
|
53
|
+
iconPosition = _ref2$iconPosition === void 0 ? 'before' : _ref2$iconPosition,
|
|
54
|
+
tooltipMessage = _ref2.tooltipMessage;
|
|
55
|
+
|
|
56
|
+
if (!onClick) {
|
|
57
|
+
return null;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
var iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
|
|
61
|
+
size: size,
|
|
62
|
+
testId: testId,
|
|
63
|
+
icon: icon
|
|
64
|
+
}) : undefined;
|
|
65
|
+
var iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
|
|
66
|
+
size: size,
|
|
67
|
+
testId: testId,
|
|
68
|
+
icon: icon
|
|
69
|
+
}) : undefined;
|
|
70
|
+
return jsx(Tooltip, {
|
|
71
|
+
content: tooltipMessage
|
|
72
|
+
}, jsx(Button, {
|
|
73
|
+
spacing: "none",
|
|
74
|
+
appearance: appearance,
|
|
75
|
+
testId: testId,
|
|
76
|
+
onClick: handleOnClick(onClick),
|
|
77
|
+
iconBefore: iconBefore,
|
|
78
|
+
iconAfter: iconAfter
|
|
79
|
+
}, content));
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
export default Action;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import { ActionName } from '../../../../constants';
|
|
2
|
-
import {
|
|
3
|
-
// Attention: Keep the export name and action name the same.
|
|
2
|
+
import { createUIAction } from './utils'; // Attention: Keep the export name and action name the same.
|
|
4
3
|
// This will help reducing the code for mapping action inside
|
|
5
4
|
// createAction and renderActionItems
|
|
6
|
-
|
|
5
|
+
// UIActions infer that you do not need to get any data from the context.
|
|
6
|
+
// DataActions infer that the action depends on the data from the context.
|
|
7
|
+
|
|
8
|
+
export var DeleteAction = createUIAction(ActionName.DeleteAction);
|
|
@@ -3,10 +3,20 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
|
3
3
|
import { ActionName } from '../../../../constants';
|
|
4
4
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
5
5
|
import React, { useContext } from 'react';
|
|
6
|
-
import
|
|
6
|
+
import Action from './action';
|
|
7
|
+
import { FormattedMessage } from 'react-intl-next';
|
|
8
|
+
import { messages } from '../../../../messages';
|
|
9
|
+
import CrossIcon from '@atlaskit/icon/glyph/cross';
|
|
7
10
|
|
|
8
11
|
var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
|
|
9
|
-
component:
|
|
12
|
+
component: Action,
|
|
13
|
+
props: {
|
|
14
|
+
testId: 'smart-action-delete-action',
|
|
15
|
+
icon: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
16
|
+
label: "Delete"
|
|
17
|
+
}),
|
|
18
|
+
toolTipMessage: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete)
|
|
19
|
+
}
|
|
10
20
|
});
|
|
11
21
|
|
|
12
22
|
var getContextKey = function getContextKey(name) {
|
|
@@ -23,13 +33,12 @@ var getActionData = function getActionData(actionName, contextKey, context) {
|
|
|
23
33
|
var data = context[contextKey];
|
|
24
34
|
|
|
25
35
|
switch (actionName) {
|
|
26
|
-
case ActionName.DeleteAction:
|
|
27
36
|
default:
|
|
28
37
|
return data;
|
|
29
38
|
}
|
|
30
39
|
};
|
|
31
40
|
|
|
32
|
-
export var
|
|
41
|
+
export var createDataAction = function createDataAction(name) {
|
|
33
42
|
var _ref = actionMappings[name] || {},
|
|
34
43
|
BaseAction = _ref.component,
|
|
35
44
|
props = _ref.props;
|
|
@@ -45,4 +54,17 @@ export var createAction = function createAction(name) {
|
|
|
45
54
|
var data = getActionData(name, contextKey, context);
|
|
46
55
|
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, data, overrides));
|
|
47
56
|
};
|
|
57
|
+
};
|
|
58
|
+
export var createUIAction = function createUIAction(name) {
|
|
59
|
+
var _ref2 = actionMappings[name] || {},
|
|
60
|
+
BaseAction = _ref2.component,
|
|
61
|
+
props = _ref2.props;
|
|
62
|
+
|
|
63
|
+
if (!BaseAction) {
|
|
64
|
+
throw Error("Action ".concat(name, " does not exist."));
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
return function (overrides) {
|
|
68
|
+
return /*#__PURE__*/React.createElement(BaseAction, _extends({}, props, overrides));
|
|
69
|
+
};
|
|
48
70
|
};
|
|
@@ -7,7 +7,7 @@ import { css, jsx } from '@emotion/core';
|
|
|
7
7
|
import ButtonGroup from '@atlaskit/button/button-group';
|
|
8
8
|
import { renderActionItems } from '../utils';
|
|
9
9
|
import { SmartLinkSize } from '../../../../../constants';
|
|
10
|
-
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height:
|
|
10
|
+
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n line-height: 1rem;\n"])));
|
|
11
11
|
|
|
12
12
|
var ActionGroup = function ActionGroup(_ref) {
|
|
13
13
|
var _ref$items = _ref.items,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
2
|
|
|
3
|
-
var _templateObject;
|
|
3
|
+
var _templateObject, _templateObject2, _templateObject3;
|
|
4
4
|
|
|
5
5
|
/** @jsx jsx */
|
|
6
6
|
import React from 'react';
|
|
@@ -8,25 +8,26 @@ import { css, jsx } from '@emotion/core';
|
|
|
8
8
|
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkWidth } from '../../../../../constants';
|
|
9
9
|
import { getBaseStyles, renderChildren } from '../utils';
|
|
10
10
|
|
|
11
|
-
var
|
|
11
|
+
var getAlignmentStyles = function getAlignmentStyles(align) {
|
|
12
12
|
switch (align) {
|
|
13
13
|
case SmartLinkAlignment.Right:
|
|
14
|
-
return
|
|
14
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n justify-content: flex-end;\n text-align: right;\n "])));
|
|
15
15
|
|
|
16
16
|
case SmartLinkAlignment.Left:
|
|
17
17
|
default:
|
|
18
|
-
return
|
|
18
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n justify-content: flex-start;\n text-align: left;\n "])));
|
|
19
19
|
}
|
|
20
20
|
};
|
|
21
21
|
|
|
22
22
|
export var getElementGroupStyles = function getElementGroupStyles(direction, size, align, width) {
|
|
23
|
-
return css(
|
|
23
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n ", "\n ", "\n min-width: 10%;\n ", "\n"])), getBaseStyles(direction, size), getAlignmentStyles(align), width === SmartLinkWidth.Flexible ? "flex: 1 3;" : '');
|
|
24
24
|
};
|
|
25
25
|
|
|
26
26
|
var ElementGroup = function ElementGroup(_ref) {
|
|
27
27
|
var _ref$align = _ref.align,
|
|
28
28
|
align = _ref$align === void 0 ? SmartLinkAlignment.Left : _ref$align,
|
|
29
29
|
children = _ref.children,
|
|
30
|
+
css = _ref.css,
|
|
30
31
|
_ref$direction = _ref.direction,
|
|
31
32
|
direction = _ref$direction === void 0 ? SmartLinkDirection.Horizontal : _ref$direction,
|
|
32
33
|
_ref$size = _ref.size,
|
|
@@ -36,7 +37,7 @@ var ElementGroup = function ElementGroup(_ref) {
|
|
|
36
37
|
_ref$width = _ref.width,
|
|
37
38
|
width = _ref$width === void 0 ? SmartLinkWidth.FitToContent : _ref$width;
|
|
38
39
|
return jsx("div", {
|
|
39
|
-
css: getElementGroupStyles(direction, size, align, width),
|
|
40
|
+
css: [getElementGroupStyles(direction, size, align, width), css],
|
|
40
41
|
"data-smart-element-group": true,
|
|
41
42
|
"data-testid": testId
|
|
42
43
|
}, renderChildren(children, size));
|
|
@@ -1 +1,2 @@
|
|
|
1
|
-
export { default as TitleBlock } from './title-block';
|
|
1
|
+
export { default as TitleBlock } from './title-block';
|
|
2
|
+
export { default as MetadataBlock } from './metadata-block';
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
4
|
+
var _excluded = ["maxLines", "status", "testId", "primary", "secondary"];
|
|
5
|
+
|
|
6
|
+
var _templateObject;
|
|
7
|
+
|
|
8
|
+
import React from 'react';
|
|
9
|
+
import { css } from '@emotion/core';
|
|
10
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkSize, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
|
|
11
|
+
import { getGapSize, renderElementItems } from '../utils';
|
|
12
|
+
import Block from '../block';
|
|
13
|
+
import ElementGroup from '../element-group';
|
|
14
|
+
var DEFAULT_MAX_LINES = 2;
|
|
15
|
+
var MAXIMUM_MAX_LINES = 2;
|
|
16
|
+
var MINIMUM_MAX_LINES = 1;
|
|
17
|
+
|
|
18
|
+
var getElementGroupStyles = function getElementGroupStyles(size, maxLines) {
|
|
19
|
+
// MetadataBlock allows metadata elements to be displayed in
|
|
20
|
+
// multiple lines, with maximum of 2 lines.
|
|
21
|
+
// a) We need the height of the line to be equal on both left and right
|
|
22
|
+
// sides so they line up nicely.
|
|
23
|
+
// b) There is no way to truncate non-text elements nicely. Here
|
|
24
|
+
// it's fix max height of the element group so that anything that is
|
|
25
|
+
// overflown will not be visible.
|
|
26
|
+
var lineHeight = getLineHeight(size);
|
|
27
|
+
var gap = getGapSize(size);
|
|
28
|
+
var gapHeight = gap * (maxLines - 1);
|
|
29
|
+
var height = lineHeight * maxLines + gapHeight;
|
|
30
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n flex-wrap: wrap;\n line-height: ", "rem;\n max-height: ", "rem;\n > span,\n > div {\n min-height: ", "rem;\n max-height: ", "rem;\n line-height: ", "rem;\n }\n "])), lineHeight, height, lineHeight, lineHeight, lineHeight);
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var getLineHeight = function getLineHeight(size) {
|
|
34
|
+
// The maximum height of all elements in specific size.
|
|
35
|
+
// These heights belongs to AvatarGroup.
|
|
36
|
+
switch (size) {
|
|
37
|
+
case SmartLinkSize.XLarge:
|
|
38
|
+
case SmartLinkSize.Large:
|
|
39
|
+
return 1.75;
|
|
40
|
+
|
|
41
|
+
case SmartLinkSize.Medium:
|
|
42
|
+
case SmartLinkSize.Small:
|
|
43
|
+
default:
|
|
44
|
+
return 1.5;
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
var getMaxLines = function getMaxLines(maxLines) {
|
|
49
|
+
if (maxLines > MAXIMUM_MAX_LINES) {
|
|
50
|
+
return DEFAULT_MAX_LINES;
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
if (maxLines < MINIMUM_MAX_LINES) {
|
|
54
|
+
return MINIMUM_MAX_LINES;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
return maxLines;
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
var MetadataBlock = function MetadataBlock(_ref) {
|
|
61
|
+
var _ref$maxLines = _ref.maxLines,
|
|
62
|
+
maxLines = _ref$maxLines === void 0 ? DEFAULT_MAX_LINES : _ref$maxLines,
|
|
63
|
+
_ref$status = _ref.status,
|
|
64
|
+
status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
|
|
65
|
+
_ref$testId = _ref.testId,
|
|
66
|
+
testId = _ref$testId === void 0 ? 'smart-block-metadata' : _ref$testId,
|
|
67
|
+
_ref$primary = _ref.primary,
|
|
68
|
+
primary = _ref$primary === void 0 ? [] : _ref$primary,
|
|
69
|
+
_ref$secondary = _ref.secondary,
|
|
70
|
+
secondary = _ref$secondary === void 0 ? [] : _ref$secondary,
|
|
71
|
+
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
72
|
+
|
|
73
|
+
if (primary.length === 0 && secondary.length === 0 || status !== SmartLinkStatus.Resolved) {
|
|
74
|
+
return null;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
var primaryElements = renderElementItems(primary);
|
|
78
|
+
var secondaryElements = renderElementItems(secondary);
|
|
79
|
+
var _blockProps$size = blockProps.size,
|
|
80
|
+
size = _blockProps$size === void 0 ? SmartLinkSize.Medium : _blockProps$size;
|
|
81
|
+
var elementGroupStyles = getElementGroupStyles(size, getMaxLines(maxLines));
|
|
82
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
83
|
+
testId: "".concat(testId, "-resolved-view")
|
|
84
|
+
}), primaryElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
85
|
+
align: SmartLinkAlignment.Left,
|
|
86
|
+
css: elementGroupStyles,
|
|
87
|
+
direction: SmartLinkDirection.Horizontal,
|
|
88
|
+
width: SmartLinkWidth.Flexible
|
|
89
|
+
}, primaryElements), secondaryElements && /*#__PURE__*/React.createElement(ElementGroup, {
|
|
90
|
+
align: SmartLinkAlignment.Right,
|
|
91
|
+
css: elementGroupStyles,
|
|
92
|
+
direction: SmartLinkDirection.Horizontal,
|
|
93
|
+
width: SmartLinkWidth.Flexible
|
|
94
|
+
}, secondaryElements));
|
|
95
|
+
};
|
|
96
|
+
|
|
97
|
+
export default MetadataBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -19,7 +19,7 @@ var actionStyles = css(_templateObject || (_templateObject = _taggedTemplateLite
|
|
|
19
19
|
|
|
20
20
|
var getMessageStyles = function getMessageStyles(size, hasAction) {
|
|
21
21
|
var sizeStyles = getLinkSizeStyles(size);
|
|
22
|
-
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n justify-content: flex-end;\n ", "\n ", "\n ", "\n color: ", ";\n "])), hasAction ? actionStyles : '', sizeStyles, getTruncateStyles(1, getLinkLineHeight(size)), tokens.errorMessage);
|
|
22
|
+
return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n justify-content: flex-end;\n ", "\n ", "\n ", "\n color: ", ";\n "])), hasAction ? actionStyles : '', sizeStyles, getTruncateStyles(1, getLinkLineHeight(size)), tokens.errorMessage);
|
|
23
23
|
};
|
|
24
24
|
|
|
25
25
|
var TitleBlockErroredView = function TitleBlockErroredView(_ref) {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import _extends from "@babel/runtime/helpers/extends";
|
|
2
1
|
import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
|
|
2
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
3
3
|
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
5
|
var _excluded = ["name"],
|
|
@@ -27,31 +27,34 @@ var getDirectionStyles = function getDirectionStyles(direction) {
|
|
|
27
27
|
}
|
|
28
28
|
};
|
|
29
29
|
|
|
30
|
-
var getGapSize = function getGapSize(size) {
|
|
30
|
+
export var getGapSize = function getGapSize(size) {
|
|
31
31
|
switch (size) {
|
|
32
32
|
case SmartLinkSize.XLarge:
|
|
33
|
-
return
|
|
33
|
+
return 1.25;
|
|
34
34
|
|
|
35
35
|
case SmartLinkSize.Large:
|
|
36
|
-
return
|
|
36
|
+
return 1;
|
|
37
37
|
|
|
38
38
|
case SmartLinkSize.Medium:
|
|
39
|
-
return
|
|
39
|
+
return 0.5;
|
|
40
40
|
|
|
41
41
|
case SmartLinkSize.Small:
|
|
42
42
|
default:
|
|
43
|
-
return
|
|
43
|
+
return 0.25;
|
|
44
44
|
}
|
|
45
45
|
};
|
|
46
|
-
|
|
47
46
|
export var getBaseStyles = function getBaseStyles(direction, size) {
|
|
48
|
-
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", ";\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n overflow-y: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
|
|
47
|
+
return css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n display: flex;\n gap: ", "rem;\n line-height: 1rem;\n min-width: 0;\n overflow: hidden;\n overflow-y: hidden;\n ", ";\n &:empty {\n display: none;\n }\n & > * {\n min-width: 0;\n }\n & > [data-fit-to-content] {\n min-width: fit-content;\n }\n"])), getGapSize(size), getDirectionStyles(direction));
|
|
49
48
|
};
|
|
50
49
|
|
|
51
50
|
var isActionGroup = function isActionGroup(node) {
|
|
52
51
|
return /*#__PURE__*/React.isValidElement(node) && node.type === ActionGroup;
|
|
53
52
|
};
|
|
54
53
|
|
|
54
|
+
var isElementNull = function isElementNull(children) {
|
|
55
|
+
return Boolean(children.type() === null);
|
|
56
|
+
};
|
|
57
|
+
|
|
55
58
|
var isElementOrElementGroup = function isElementOrElementGroup(node) {
|
|
56
59
|
return /*#__PURE__*/React.isValidElement(node) && (isFlexibleUiElement(node) || node.type === ElementGroup);
|
|
57
60
|
};
|
|
@@ -78,9 +81,13 @@ export var renderElementItems = function renderElementItems() {
|
|
|
78
81
|
var Element = Elements[name];
|
|
79
82
|
|
|
80
83
|
if (Element) {
|
|
81
|
-
|
|
84
|
+
var element = /*#__PURE__*/React.createElement(Element, _extends({
|
|
82
85
|
key: idx
|
|
83
|
-
}, props))
|
|
86
|
+
}, props));
|
|
87
|
+
|
|
88
|
+
if (!isElementNull(element)) {
|
|
89
|
+
return [].concat(_toConsumableArray(acc), [element]);
|
|
90
|
+
}
|
|
84
91
|
}
|
|
85
92
|
|
|
86
93
|
return acc;
|
|
@@ -1,8 +1,28 @@
|
|
|
1
|
+
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
|
+
|
|
3
|
+
var _templateObject;
|
|
4
|
+
|
|
5
|
+
/** @jsx jsx */
|
|
1
6
|
import React from 'react';
|
|
7
|
+
import { css, jsx } from '@emotion/core';
|
|
2
8
|
import AtlaskitAvatarGroup from '@atlaskit/avatar-group';
|
|
3
9
|
import { SmartLinkSize } from '../../../../../constants';
|
|
4
10
|
var MAX_COUNT = 4;
|
|
5
11
|
|
|
12
|
+
var getStyles = function getStyles(size) {
|
|
13
|
+
switch (size) {
|
|
14
|
+
case SmartLinkSize.XLarge:
|
|
15
|
+
case SmartLinkSize.Large:
|
|
16
|
+
// Default AK small size
|
|
17
|
+
return;
|
|
18
|
+
|
|
19
|
+
case SmartLinkSize.Medium:
|
|
20
|
+
case SmartLinkSize.Small:
|
|
21
|
+
default:
|
|
22
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n li {\n span,\n svg {\n max-height: 1.25rem;\n max-width: 1.25rem;\n }\n }\n "])));
|
|
23
|
+
}
|
|
24
|
+
};
|
|
25
|
+
|
|
6
26
|
var AvatarGroup = function AvatarGroup(_ref) {
|
|
7
27
|
var _ref$items = _ref.items,
|
|
8
28
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
@@ -17,13 +37,15 @@ var AvatarGroup = function AvatarGroup(_ref) {
|
|
|
17
37
|
return null;
|
|
18
38
|
}
|
|
19
39
|
|
|
20
|
-
return
|
|
40
|
+
return jsx("span", {
|
|
41
|
+
css: getStyles(size)
|
|
42
|
+
}, jsx(AtlaskitAvatarGroup, {
|
|
21
43
|
maxCount: maxCount,
|
|
22
44
|
appearance: "stack",
|
|
23
45
|
size: "small",
|
|
24
46
|
data: items,
|
|
25
47
|
testId: testId
|
|
26
|
-
});
|
|
48
|
+
}));
|
|
27
49
|
};
|
|
28
50
|
|
|
29
51
|
export default AvatarGroup;
|
|
@@ -27,7 +27,7 @@ var getThemeStyles = function getThemeStyles(theme) {
|
|
|
27
27
|
|
|
28
28
|
var getAnchorStyles = function getAnchorStyles(size, theme, maxLines) {
|
|
29
29
|
var sizeStyles = getLinkSizeStyles(size);
|
|
30
|
-
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n ", "\n ", "\n // Theme should be last to be spread because it contains override values\n ", "\n "])), sizeStyles, getTruncateStyles(maxLines, getLinkLineHeight(size)), getThemeStyles(theme));
|
|
30
|
+
return css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n flex: 1 1 auto;\n ", "\n ", "\n // Theme should be last to be spread because it contains override values\n ", "\n "])), sizeStyles, getTruncateStyles(maxLines, getLinkLineHeight(size)), getThemeStyles(theme));
|
|
31
31
|
};
|
|
32
32
|
|
|
33
33
|
var getMaxLines = function getMaxLines(maxLines) {
|