@atlaskit/smart-card 17.4.1 → 17.5.0
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 +18 -0
- package/dist/cjs/constants.js +61 -13
- package/dist/cjs/index.js +6 -0
- package/dist/cjs/utils/token.js +14 -23
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/FlexibleCard/components/actions/action/index.js +18 -7
- package/dist/cjs/view/FlexibleCard/components/actions/utils.js +8 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/index.js +50 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/footer-block/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/index.js +18 -2
- package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +51 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/types.js +5 -0
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +23 -3
- package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +6 -4
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +5 -1
- package/dist/cjs/view/FlexibleCard/components/utils.js +15 -1
- package/dist/es2019/constants.js +52 -13
- package/dist/es2019/index.js +1 -1
- package/dist/es2019/utils/token.js +14 -21
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/FlexibleCard/components/actions/action/index.js +34 -6
- package/dist/es2019/view/FlexibleCard/components/actions/utils.js +5 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/index.js +35 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/footer-block/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/index.js +4 -2
- package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +29 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +19 -5
- package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +4 -3
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +4 -1
- package/dist/es2019/view/FlexibleCard/components/utils.js +11 -0
- package/dist/esm/constants.js +52 -13
- package/dist/esm/index.js +1 -1
- package/dist/esm/utils/token.js +14 -21
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/FlexibleCard/components/actions/action/index.js +17 -7
- package/dist/esm/view/FlexibleCard/components/actions/utils.js +9 -1
- package/dist/esm/view/FlexibleCard/components/blocks/action-group/index.js +3 -2
- package/dist/esm/view/FlexibleCard/components/blocks/footer-block/index.js +34 -0
- package/dist/esm/view/FlexibleCard/components/blocks/footer-block/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/blocks/index.js +4 -2
- package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +34 -0
- package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +24 -5
- package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +1 -1
- package/dist/esm/view/FlexibleCard/components/elements/text/index.js +6 -4
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +4 -1
- package/dist/esm/view/FlexibleCard/components/utils.js +11 -0
- package/dist/types/constants.d.ts +51 -0
- package/dist/types/index.d.ts +1 -1
- package/dist/types/utils/token.d.ts +13 -13
- package/dist/types/view/FlexibleCard/components/blocks/action-group/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/blocks/footer-block/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/footer-block/types.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +3 -1
- package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
- package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +1 -1
- package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -0
- package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
- package/package.json +1 -1
|
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
|
|
|
5
5
|
Object.defineProperty(exports, "__esModule", {
|
|
6
6
|
value: true
|
|
7
7
|
});
|
|
8
|
-
exports.getTruncateStyles = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconSizeStyles = exports.getFormattedMessage = void 0;
|
|
8
|
+
exports.getTruncateStyles = exports.getMaxLines = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconSizeStyles = exports.getFormattedMessage = void 0;
|
|
9
9
|
|
|
10
10
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
11
|
|
|
@@ -76,6 +76,20 @@ var getLinkSizeStyles = function getLinkSizeStyles(size) {
|
|
|
76
76
|
|
|
77
77
|
exports.getLinkSizeStyles = getLinkSizeStyles;
|
|
78
78
|
|
|
79
|
+
var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
|
|
80
|
+
if (value > max) {
|
|
81
|
+
return defaultValue;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
if (value < min) {
|
|
85
|
+
return min;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
return value;
|
|
89
|
+
};
|
|
90
|
+
|
|
91
|
+
exports.getMaxLines = getMaxLines;
|
|
92
|
+
|
|
79
93
|
var getTruncateStyles = function getTruncateStyles(maxLines) {
|
|
80
94
|
var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
|
|
81
95
|
return (0, _core.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\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);
|
package/dist/es2019/constants.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The alignment of Flexible UI component.
|
|
3
|
+
*/
|
|
1
4
|
export let SmartLinkAlignment;
|
|
5
|
+
/**
|
|
6
|
+
* The direction of Flexible UI components. It establish the main-axis
|
|
7
|
+
* or how the child components laid out inside the parent component.
|
|
8
|
+
* Similar to flex's flex-direction concept.
|
|
9
|
+
*/
|
|
2
10
|
|
|
3
11
|
(function (SmartLinkAlignment) {
|
|
4
12
|
SmartLinkAlignment["Left"] = "left";
|
|
@@ -6,6 +14,10 @@ export let SmartLinkAlignment;
|
|
|
6
14
|
})(SmartLinkAlignment || (SmartLinkAlignment = {}));
|
|
7
15
|
|
|
8
16
|
export let SmartLinkDirection;
|
|
17
|
+
/**
|
|
18
|
+
* The positioning of the component within the parent component.
|
|
19
|
+
* Similar to flex's align-items or align-self concept.
|
|
20
|
+
*/
|
|
9
21
|
|
|
10
22
|
(function (SmartLinkDirection) {
|
|
11
23
|
SmartLinkDirection["Horizontal"] = "horizontal";
|
|
@@ -13,6 +25,11 @@ export let SmartLinkDirection;
|
|
|
13
25
|
})(SmartLinkDirection || (SmartLinkDirection = {}));
|
|
14
26
|
|
|
15
27
|
export let SmartLinkPosition;
|
|
28
|
+
/**
|
|
29
|
+
* The sizing options of the Flexible UI component. Every component
|
|
30
|
+
* has or inherits the sizing props. Implementation varies
|
|
31
|
+
* as per component.
|
|
32
|
+
*/
|
|
16
33
|
|
|
17
34
|
(function (SmartLinkPosition) {
|
|
18
35
|
SmartLinkPosition["Top"] = "top";
|
|
@@ -20,6 +37,9 @@ export let SmartLinkPosition;
|
|
|
20
37
|
})(SmartLinkPosition || (SmartLinkPosition = {}));
|
|
21
38
|
|
|
22
39
|
export let SmartLinkSize;
|
|
40
|
+
/**
|
|
41
|
+
* Smart Links link request status
|
|
42
|
+
*/
|
|
23
43
|
|
|
24
44
|
(function (SmartLinkSize) {
|
|
25
45
|
SmartLinkSize["XLarge"] = "xlarge";
|
|
@@ -29,6 +49,10 @@ export let SmartLinkSize;
|
|
|
29
49
|
})(SmartLinkSize || (SmartLinkSize = {}));
|
|
30
50
|
|
|
31
51
|
export let SmartLinkStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Flexible UI theme available on the Card level.
|
|
54
|
+
* This determine the styling of the link.
|
|
55
|
+
*/
|
|
32
56
|
|
|
33
57
|
(function (SmartLinkStatus) {
|
|
34
58
|
SmartLinkStatus["Pending"] = "pending";
|
|
@@ -42,25 +66,34 @@ export let SmartLinkStatus;
|
|
|
42
66
|
})(SmartLinkStatus || (SmartLinkStatus = {}));
|
|
43
67
|
|
|
44
68
|
export let SmartLinkTheme;
|
|
69
|
+
/**
|
|
70
|
+
* Determines whether the container size will fit to the content
|
|
71
|
+
* or expand to the available width or the parent component.
|
|
72
|
+
* Similar to flex's flex-grow concept.
|
|
73
|
+
*/
|
|
45
74
|
|
|
46
75
|
(function (SmartLinkTheme) {
|
|
47
76
|
SmartLinkTheme["Black"] = "black";
|
|
48
77
|
SmartLinkTheme["Link"] = "link";
|
|
49
78
|
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
50
79
|
|
|
51
|
-
export let SmartLinkWidth;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
export let SmartLinkWidth;
|
|
81
|
+
/**
|
|
82
|
+
* Flexible UI element name - each reflecting the link data its represented.
|
|
83
|
+
* When adding an element...
|
|
84
|
+
* 1) Create base element if it doesn't already existed.
|
|
85
|
+
* Base element are inside src/view/FlexibleCard/components/elements.
|
|
86
|
+
* E.g. Badge,DateTime, Icon, Lozenge, etc.
|
|
87
|
+
* 2) Update FlexibleUiContext with the new prop for data representing
|
|
88
|
+
* the element, preferably with the same name as the element itself.
|
|
89
|
+
* (src/state/flexible-ui-context/types.ts)
|
|
90
|
+
* 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
|
|
91
|
+
* 4) Set base element and data mapping
|
|
92
|
+
* (src/view/FlexibleCard/components/elements/utils.tsx)
|
|
93
|
+
* 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
|
|
94
|
+
* 6) Update element ElementDisplaySchema for inline/block display
|
|
95
|
+
* (src/view/FlexibleCard/components/blocks/utils.tsx)
|
|
96
|
+
*/
|
|
64
97
|
|
|
65
98
|
(function (SmartLinkWidth) {
|
|
66
99
|
SmartLinkWidth["FitToContent"] = "fit-to-content";
|
|
@@ -68,6 +101,9 @@ export let SmartLinkWidth; // When adding an element...
|
|
|
68
101
|
})(SmartLinkWidth || (SmartLinkWidth = {}));
|
|
69
102
|
|
|
70
103
|
export let ElementName;
|
|
104
|
+
/**
|
|
105
|
+
* Flexible UI action (button)
|
|
106
|
+
*/
|
|
71
107
|
|
|
72
108
|
(function (ElementName) {
|
|
73
109
|
ElementName["AuthorGroup"] = "AuthorGroup";
|
|
@@ -88,6 +124,9 @@ export let ElementName;
|
|
|
88
124
|
})(ElementName || (ElementName = {}));
|
|
89
125
|
|
|
90
126
|
export let ActionName;
|
|
127
|
+
/**
|
|
128
|
+
* Flexible UI icons - each mapped to AK icons.
|
|
129
|
+
*/
|
|
91
130
|
|
|
92
131
|
(function (ActionName) {
|
|
93
132
|
ActionName["DeleteAction"] = "DeleteAction";
|
package/dist/es2019/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 { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
16
|
+
export { MetadataBlock, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import { token } from '@atlaskit/tokens';
|
|
2
|
-
|
|
3
|
-
export const safeToken = (path, fallback) => {
|
|
4
|
-
try {
|
|
5
|
-
return token(path, fallback);
|
|
6
|
-
} catch (e) {
|
|
7
|
-
return fallback;
|
|
8
|
-
}
|
|
9
|
-
};
|
|
1
|
+
import { token } from '@atlaskit/tokens';
|
|
10
2
|
export const tokens = {
|
|
11
|
-
actionIcon:
|
|
12
|
-
background:
|
|
13
|
-
badgeIcon:
|
|
14
|
-
badgeText:
|
|
15
|
-
blackLink:
|
|
16
|
-
blackLinkPressed:
|
|
17
|
-
blueLink:
|
|
18
|
-
blueLinkPressed:
|
|
19
|
-
elevation:
|
|
20
|
-
errorMessage:
|
|
21
|
-
errorMessageHover:
|
|
22
|
-
|
|
3
|
+
actionIcon: token('color.icon', '#44546F'),
|
|
4
|
+
background: token('elevation.surface', '#FFFFFF'),
|
|
5
|
+
badgeIcon: token('color.icon.subtle', '#626F86'),
|
|
6
|
+
badgeText: token('color.text.subtlest', '#626F86'),
|
|
7
|
+
blackLink: token('color.text.subtle', '#44546F'),
|
|
8
|
+
blackLinkPressed: token('color.text', '#172B4D'),
|
|
9
|
+
blueLink: token('color.link', '#0C66E4'),
|
|
10
|
+
blueLinkPressed: token('color.link.pressed', '#0055CC'),
|
|
11
|
+
elevation: token('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
|
|
12
|
+
errorMessage: token('color.text.disabled', '#6B778C'),
|
|
13
|
+
errorMessageHover: token('color.text.subtle', '#8993A4'),
|
|
14
|
+
snippet: token('color.text', '#172B4D'),
|
|
15
|
+
text: token('color.text.subtlest', '#626F86')
|
|
23
16
|
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -8,7 +8,7 @@ import { getIconSizeStyles } from '../../utils';
|
|
|
8
8
|
import { tokens } from '../../../../../utils/token';
|
|
9
9
|
import { handleOnClick } from '../../../../../utils';
|
|
10
10
|
|
|
11
|
-
const
|
|
11
|
+
const getIconWidth = size => {
|
|
12
12
|
switch (size) {
|
|
13
13
|
case SmartLinkSize.XLarge:
|
|
14
14
|
case SmartLinkSize.Large:
|
|
@@ -23,9 +23,27 @@ const getWidth = size => {
|
|
|
23
23
|
|
|
24
24
|
const getIconStyles = size => css`
|
|
25
25
|
color: ${tokens.actionIcon};
|
|
26
|
-
${getIconSizeStyles(
|
|
26
|
+
${getIconSizeStyles(getIconWidth(size))};
|
|
27
27
|
`;
|
|
28
28
|
|
|
29
|
+
const getButtonStyle = (size, iconOnly) => size === SmartLinkSize.Small ? css`
|
|
30
|
+
font-size: 0.75rem;
|
|
31
|
+
font-weight: 500;
|
|
32
|
+
line-height: 1rem;
|
|
33
|
+
button,
|
|
34
|
+
button:hover,
|
|
35
|
+
button:focus,
|
|
36
|
+
button:active {
|
|
37
|
+
line-height: 1rem;
|
|
38
|
+
${iconOnly ? `
|
|
39
|
+
padding: 0.125rem;
|
|
40
|
+
` : `
|
|
41
|
+
padding-left: 0.25rem;
|
|
42
|
+
padding-right: 0.25rem;
|
|
43
|
+
`}
|
|
44
|
+
}
|
|
45
|
+
` : '';
|
|
46
|
+
|
|
29
47
|
const ActionIcon = ({
|
|
30
48
|
size,
|
|
31
49
|
testId,
|
|
@@ -35,6 +53,13 @@ const ActionIcon = ({
|
|
|
35
53
|
"data-testid": `${testId}-icon`
|
|
36
54
|
}, icon);
|
|
37
55
|
|
|
56
|
+
const sizeToSpacing = {
|
|
57
|
+
[SmartLinkSize.Small]: 'none',
|
|
58
|
+
[SmartLinkSize.Medium]: 'compact',
|
|
59
|
+
[SmartLinkSize.Large]: 'compact',
|
|
60
|
+
[SmartLinkSize.XLarge]: 'default'
|
|
61
|
+
};
|
|
62
|
+
|
|
38
63
|
const Action = ({
|
|
39
64
|
appearance = 'subtle',
|
|
40
65
|
content,
|
|
@@ -49,26 +74,29 @@ const Action = ({
|
|
|
49
74
|
return null;
|
|
50
75
|
}
|
|
51
76
|
|
|
52
|
-
const iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
|
|
77
|
+
const iconBefore = icon && iconPosition === 'before' ? jsx(ActionIcon, {
|
|
53
78
|
size: size,
|
|
54
79
|
testId: testId,
|
|
55
80
|
icon: icon
|
|
56
81
|
}) : undefined;
|
|
57
|
-
const iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
|
|
82
|
+
const iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
|
|
58
83
|
size: size,
|
|
59
84
|
testId: testId,
|
|
60
85
|
icon: icon
|
|
61
86
|
}) : undefined;
|
|
87
|
+
const iconOnly = !content;
|
|
62
88
|
return jsx(Tooltip, {
|
|
63
89
|
content: tooltipMessage
|
|
90
|
+
}, jsx("div", {
|
|
91
|
+
css: getButtonStyle(size, iconOnly)
|
|
64
92
|
}, jsx(Button, {
|
|
65
|
-
spacing:
|
|
93
|
+
spacing: sizeToSpacing[size],
|
|
66
94
|
appearance: appearance,
|
|
67
95
|
testId: testId,
|
|
68
96
|
onClick: handleOnClick(onClick),
|
|
69
97
|
iconBefore: iconBefore,
|
|
70
98
|
iconAfter: iconAfter
|
|
71
|
-
}, content));
|
|
99
|
+
}, content)));
|
|
72
100
|
};
|
|
73
101
|
|
|
74
102
|
export default Action;
|
|
@@ -11,6 +11,7 @@ const actionMappings = {
|
|
|
11
11
|
component: Action,
|
|
12
12
|
props: {
|
|
13
13
|
testId: 'smart-action-delete-action',
|
|
14
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
|
|
14
15
|
icon: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
15
16
|
label: "Delete"
|
|
16
17
|
}),
|
|
@@ -66,6 +67,9 @@ export const createUIAction = name => {
|
|
|
66
67
|
}
|
|
67
68
|
|
|
68
69
|
return overrides => {
|
|
69
|
-
|
|
70
|
+
const combinedProps = { ...props,
|
|
71
|
+
...overrides
|
|
72
|
+
};
|
|
73
|
+
return /*#__PURE__*/React.createElement(BaseAction, combinedProps);
|
|
70
74
|
};
|
|
71
75
|
};
|
|
@@ -10,13 +10,14 @@ const styles = css`
|
|
|
10
10
|
|
|
11
11
|
const ActionGroup = ({
|
|
12
12
|
items = [],
|
|
13
|
-
size = SmartLinkSize.Medium
|
|
13
|
+
size = SmartLinkSize.Medium,
|
|
14
|
+
appearance
|
|
14
15
|
}) => {
|
|
15
16
|
// Currently we only have delete action available, this prevents others from adding more delete actions
|
|
16
17
|
const actionsToRender = items.slice(0, 1);
|
|
17
18
|
return jsx("div", {
|
|
18
19
|
css: styles
|
|
19
|
-
}, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size)));
|
|
20
|
+
}, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
|
|
20
21
|
};
|
|
21
22
|
|
|
22
23
|
export default ActionGroup;
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import { SmartLinkAlignment, SmartLinkDirection, SmartLinkStatus, SmartLinkWidth } from '../../../../../constants';
|
|
4
|
+
import Block from '../block';
|
|
5
|
+
import ElementGroup from '../element-group';
|
|
6
|
+
import { Provider } from '../../elements';
|
|
7
|
+
import ActionGroup from '../action-group';
|
|
8
|
+
|
|
9
|
+
const FooterBlock = props => {
|
|
10
|
+
const {
|
|
11
|
+
status,
|
|
12
|
+
actions,
|
|
13
|
+
testId = 'smart-footer-block'
|
|
14
|
+
} = props;
|
|
15
|
+
|
|
16
|
+
if (status !== SmartLinkStatus.Resolved) {
|
|
17
|
+
return null;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
|
|
21
|
+
testId: `${testId}-resolved-view`
|
|
22
|
+
}), /*#__PURE__*/React.createElement(Provider, {
|
|
23
|
+
testId: `${testId}-provider`
|
|
24
|
+
}), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
|
|
25
|
+
testId: "smart-element-group-actions",
|
|
26
|
+
align: SmartLinkAlignment.Right,
|
|
27
|
+
direction: SmartLinkDirection.Horizontal,
|
|
28
|
+
width: SmartLinkWidth.Flexible
|
|
29
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
30
|
+
items: actions,
|
|
31
|
+
appearance: "default"
|
|
32
|
+
})) : null);
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
export default FooterBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
2
|
-
export { default as MetadataBlock } from './metadata-block';
|
|
1
|
+
export { default as FooterBlock } from './footer-block';
|
|
2
|
+
export { default as MetadataBlock } from './metadata-block';
|
|
3
|
+
export { default as SnippetBlock } from './snippet-block';
|
|
4
|
+
export { default as TitleBlock } from './title-block';
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import React from 'react';
|
|
3
|
+
import Block from '../block';
|
|
4
|
+
import { SmartLinkStatus } from '../../../../../constants';
|
|
5
|
+
import { Snippet } from '../../elements';
|
|
6
|
+
import { getMaxLines } from '../../utils';
|
|
7
|
+
const DEFAULT_MAX_LINES = 3;
|
|
8
|
+
const MAXIMUM_MAX_LINES = 3;
|
|
9
|
+
const MINIMUM_MAX_LINES = 1;
|
|
10
|
+
|
|
11
|
+
const SnippetBlock = ({
|
|
12
|
+
maxLines = DEFAULT_MAX_LINES,
|
|
13
|
+
status = SmartLinkStatus.Fallback,
|
|
14
|
+
testId = 'smart-block-snippet',
|
|
15
|
+
...blockProps
|
|
16
|
+
}) => {
|
|
17
|
+
if (status !== SmartLinkStatus.Resolved) {
|
|
18
|
+
return null;
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
const snippetMaxLines = getMaxLines(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
|
|
22
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
23
|
+
testId: `${testId}-resolved-view`
|
|
24
|
+
}), /*#__PURE__*/React.createElement(Snippet, {
|
|
25
|
+
maxLines: snippetMaxLines
|
|
26
|
+
}));
|
|
27
|
+
};
|
|
28
|
+
|
|
29
|
+
export default SnippetBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -6,8 +6,7 @@ import * as Elements from '../elements';
|
|
|
6
6
|
import * as Actions from '../actions';
|
|
7
7
|
import { isFlexibleUiElement } from '../../../../utils/flexible';
|
|
8
8
|
import ActionGroup from './action-group';
|
|
9
|
-
import ElementGroup from './element-group';
|
|
10
|
-
|
|
9
|
+
import ElementGroup from './element-group';
|
|
11
10
|
export const ElementDisplaySchema = {
|
|
12
11
|
[ElementName.AuthorGroup]: ['inline'],
|
|
13
12
|
[ElementName.CollaboratorGroup]: ['inline'],
|
|
@@ -130,19 +129,34 @@ export const renderElementItems = (items = [], display = 'inline') => {
|
|
|
130
129
|
return elements;
|
|
131
130
|
}
|
|
132
131
|
};
|
|
133
|
-
export const renderActionItems = (items = [], size = SmartLinkSize.Medium) => {
|
|
132
|
+
export const renderActionItems = (items = [], size = SmartLinkSize.Medium, appearance) => {
|
|
134
133
|
const actions = items.reduce((acc, curr, idx) => {
|
|
135
134
|
const {
|
|
136
135
|
name,
|
|
136
|
+
hideContent,
|
|
137
|
+
hideIcon,
|
|
138
|
+
onClick,
|
|
137
139
|
...props
|
|
138
140
|
} = curr;
|
|
139
141
|
const Action = Actions[name];
|
|
142
|
+
const actionProps = { ...props
|
|
143
|
+
};
|
|
144
|
+
|
|
145
|
+
if (hideContent) {
|
|
146
|
+
actionProps.content = '';
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
if (hideIcon) {
|
|
150
|
+
actionProps.icon = undefined;
|
|
151
|
+
}
|
|
140
152
|
|
|
141
153
|
if (Action) {
|
|
142
154
|
return [...acc, /*#__PURE__*/React.createElement(Action, _extends({
|
|
143
155
|
size: size,
|
|
144
|
-
key: idx
|
|
145
|
-
|
|
156
|
+
key: idx,
|
|
157
|
+
appearance: appearance,
|
|
158
|
+
onClick: onClick
|
|
159
|
+
}, actionProps))];
|
|
146
160
|
}
|
|
147
161
|
|
|
148
162
|
return acc;
|
|
@@ -217,7 +217,7 @@ const AtlaskitIcon = ({
|
|
|
217
217
|
case IconType.Jira:
|
|
218
218
|
// Logo component has a different prop set from other icon components
|
|
219
219
|
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
220
|
-
"data-
|
|
220
|
+
"data-testid": testId // Confluence and Jira imports don't have native testId prop
|
|
221
221
|
,
|
|
222
222
|
textColor: N700,
|
|
223
223
|
iconColor: B200,
|
|
@@ -4,14 +4,15 @@ import { css, jsx } from '@emotion/core';
|
|
|
4
4
|
import { getFormattedMessage, getTruncateStyles } from '../../utils';
|
|
5
5
|
import { tokens } from '../../../../../utils/token';
|
|
6
6
|
|
|
7
|
-
const getStyles = maxLines => css`
|
|
8
|
-
color: ${
|
|
7
|
+
const getStyles = (maxLines, color) => css`
|
|
8
|
+
color: ${color};
|
|
9
9
|
font-size: 0.75rem;
|
|
10
10
|
line-height: 1rem;
|
|
11
11
|
${getTruncateStyles(maxLines)}
|
|
12
12
|
`;
|
|
13
13
|
|
|
14
14
|
const Text = ({
|
|
15
|
+
color = tokens.text,
|
|
15
16
|
content,
|
|
16
17
|
maxLines = 1,
|
|
17
18
|
message,
|
|
@@ -22,7 +23,7 @@ const Text = ({
|
|
|
22
23
|
}
|
|
23
24
|
|
|
24
25
|
return jsx("span", {
|
|
25
|
-
css: getStyles(maxLines),
|
|
26
|
+
css: getStyles(maxLines, color),
|
|
26
27
|
"data-smart-element-text": true,
|
|
27
28
|
"data-testid": testId
|
|
28
29
|
}, getFormattedMessage(message) || content);
|
|
@@ -10,6 +10,8 @@ import AvatarGroup from './avatar-group';
|
|
|
10
10
|
import Text from './text';
|
|
11
11
|
import { messages } from '../../../../messages';
|
|
12
12
|
import DateTime from './date-time';
|
|
13
|
+
import { tokens } from '../../../../utils/token';
|
|
14
|
+
const SNIPPET_DEFAULT_MAX_LINES = 3;
|
|
13
15
|
const elementMappings = {
|
|
14
16
|
[ElementName.AuthorGroup]: {
|
|
15
17
|
component: AvatarGroup
|
|
@@ -44,7 +46,8 @@ const elementMappings = {
|
|
|
44
46
|
[ElementName.Snippet]: {
|
|
45
47
|
component: Text,
|
|
46
48
|
props: {
|
|
47
|
-
|
|
49
|
+
color: tokens.snippet,
|
|
50
|
+
maxLines: SNIPPET_DEFAULT_MAX_LINES
|
|
48
51
|
}
|
|
49
52
|
},
|
|
50
53
|
[ElementName.State]: {
|
|
@@ -80,6 +80,17 @@ export const getLinkSizeStyles = size => {
|
|
|
80
80
|
`;
|
|
81
81
|
}
|
|
82
82
|
};
|
|
83
|
+
export const getMaxLines = (value, defaultValue, max, min) => {
|
|
84
|
+
if (value > max) {
|
|
85
|
+
return defaultValue;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
if (value < min) {
|
|
89
|
+
return min;
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return value;
|
|
93
|
+
};
|
|
83
94
|
export const getTruncateStyles = (maxLines, lineHeight = '1rem') => css`
|
|
84
95
|
display: -webkit-box;
|
|
85
96
|
overflow: hidden;
|
package/dist/esm/constants.js
CHANGED
|
@@ -1,4 +1,12 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The alignment of Flexible UI component.
|
|
3
|
+
*/
|
|
1
4
|
export var SmartLinkAlignment;
|
|
5
|
+
/**
|
|
6
|
+
* The direction of Flexible UI components. It establish the main-axis
|
|
7
|
+
* or how the child components laid out inside the parent component.
|
|
8
|
+
* Similar to flex's flex-direction concept.
|
|
9
|
+
*/
|
|
2
10
|
|
|
3
11
|
(function (SmartLinkAlignment) {
|
|
4
12
|
SmartLinkAlignment["Left"] = "left";
|
|
@@ -6,6 +14,10 @@ export var SmartLinkAlignment;
|
|
|
6
14
|
})(SmartLinkAlignment || (SmartLinkAlignment = {}));
|
|
7
15
|
|
|
8
16
|
export var SmartLinkDirection;
|
|
17
|
+
/**
|
|
18
|
+
* The positioning of the component within the parent component.
|
|
19
|
+
* Similar to flex's align-items or align-self concept.
|
|
20
|
+
*/
|
|
9
21
|
|
|
10
22
|
(function (SmartLinkDirection) {
|
|
11
23
|
SmartLinkDirection["Horizontal"] = "horizontal";
|
|
@@ -13,6 +25,11 @@ export var SmartLinkDirection;
|
|
|
13
25
|
})(SmartLinkDirection || (SmartLinkDirection = {}));
|
|
14
26
|
|
|
15
27
|
export var SmartLinkPosition;
|
|
28
|
+
/**
|
|
29
|
+
* The sizing options of the Flexible UI component. Every component
|
|
30
|
+
* has or inherits the sizing props. Implementation varies
|
|
31
|
+
* as per component.
|
|
32
|
+
*/
|
|
16
33
|
|
|
17
34
|
(function (SmartLinkPosition) {
|
|
18
35
|
SmartLinkPosition["Top"] = "top";
|
|
@@ -20,6 +37,9 @@ export var SmartLinkPosition;
|
|
|
20
37
|
})(SmartLinkPosition || (SmartLinkPosition = {}));
|
|
21
38
|
|
|
22
39
|
export var SmartLinkSize;
|
|
40
|
+
/**
|
|
41
|
+
* Smart Links link request status
|
|
42
|
+
*/
|
|
23
43
|
|
|
24
44
|
(function (SmartLinkSize) {
|
|
25
45
|
SmartLinkSize["XLarge"] = "xlarge";
|
|
@@ -29,6 +49,10 @@ export var SmartLinkSize;
|
|
|
29
49
|
})(SmartLinkSize || (SmartLinkSize = {}));
|
|
30
50
|
|
|
31
51
|
export var SmartLinkStatus;
|
|
52
|
+
/**
|
|
53
|
+
* Flexible UI theme available on the Card level.
|
|
54
|
+
* This determine the styling of the link.
|
|
55
|
+
*/
|
|
32
56
|
|
|
33
57
|
(function (SmartLinkStatus) {
|
|
34
58
|
SmartLinkStatus["Pending"] = "pending";
|
|
@@ -42,25 +66,34 @@ export var SmartLinkStatus;
|
|
|
42
66
|
})(SmartLinkStatus || (SmartLinkStatus = {}));
|
|
43
67
|
|
|
44
68
|
export var SmartLinkTheme;
|
|
69
|
+
/**
|
|
70
|
+
* Determines whether the container size will fit to the content
|
|
71
|
+
* or expand to the available width or the parent component.
|
|
72
|
+
* Similar to flex's flex-grow concept.
|
|
73
|
+
*/
|
|
45
74
|
|
|
46
75
|
(function (SmartLinkTheme) {
|
|
47
76
|
SmartLinkTheme["Black"] = "black";
|
|
48
77
|
SmartLinkTheme["Link"] = "link";
|
|
49
78
|
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
50
79
|
|
|
51
|
-
export var SmartLinkWidth;
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
80
|
+
export var SmartLinkWidth;
|
|
81
|
+
/**
|
|
82
|
+
* Flexible UI element name - each reflecting the link data its represented.
|
|
83
|
+
* When adding an element...
|
|
84
|
+
* 1) Create base element if it doesn't already existed.
|
|
85
|
+
* Base element are inside src/view/FlexibleCard/components/elements.
|
|
86
|
+
* E.g. Badge,DateTime, Icon, Lozenge, etc.
|
|
87
|
+
* 2) Update FlexibleUiContext with the new prop for data representing
|
|
88
|
+
* the element, preferably with the same name as the element itself.
|
|
89
|
+
* (src/state/flexible-ui-context/types.ts)
|
|
90
|
+
* 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
|
|
91
|
+
* 4) Set base element and data mapping
|
|
92
|
+
* (src/view/FlexibleCard/components/elements/utils.tsx)
|
|
93
|
+
* 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
|
|
94
|
+
* 6) Update element ElementDisplaySchema for inline/block display
|
|
95
|
+
* (src/view/FlexibleCard/components/blocks/utils.tsx)
|
|
96
|
+
*/
|
|
64
97
|
|
|
65
98
|
(function (SmartLinkWidth) {
|
|
66
99
|
SmartLinkWidth["FitToContent"] = "fit-to-content";
|
|
@@ -68,6 +101,9 @@ export var SmartLinkWidth; // When adding an element...
|
|
|
68
101
|
})(SmartLinkWidth || (SmartLinkWidth = {}));
|
|
69
102
|
|
|
70
103
|
export var ElementName;
|
|
104
|
+
/**
|
|
105
|
+
* Flexible UI action (button)
|
|
106
|
+
*/
|
|
71
107
|
|
|
72
108
|
(function (ElementName) {
|
|
73
109
|
ElementName["AuthorGroup"] = "AuthorGroup";
|
|
@@ -88,6 +124,9 @@ export var ElementName;
|
|
|
88
124
|
})(ElementName || (ElementName = {}));
|
|
89
125
|
|
|
90
126
|
export var ActionName;
|
|
127
|
+
/**
|
|
128
|
+
* Flexible UI icons - each mapped to AK icons.
|
|
129
|
+
*/
|
|
91
130
|
|
|
92
131
|
(function (ActionName) {
|
|
93
132
|
ActionName["DeleteAction"] = "DeleteAction";
|
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 { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|
|
16
|
+
export { MetadataBlock, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
|