@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
package/dist/esm/utils/token.js
CHANGED
|
@@ -1,23 +1,16 @@
|
|
|
1
|
-
import { token } from '@atlaskit/tokens';
|
|
2
|
-
|
|
3
|
-
export var safeToken = function 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 var 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/esm/version.json
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
1
2
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
2
3
|
|
|
3
|
-
var _templateObject;
|
|
4
|
+
var _templateObject, _templateObject2, _sizeToSpacing;
|
|
4
5
|
|
|
5
6
|
/** @jsx jsx */
|
|
6
7
|
import React from 'react';
|
|
@@ -12,7 +13,7 @@ import { getIconSizeStyles } from '../../utils';
|
|
|
12
13
|
import { tokens } from '../../../../../utils/token';
|
|
13
14
|
import { handleOnClick } from '../../../../../utils';
|
|
14
15
|
|
|
15
|
-
var
|
|
16
|
+
var getIconWidth = function getIconWidth(size) {
|
|
16
17
|
switch (size) {
|
|
17
18
|
case SmartLinkSize.XLarge:
|
|
18
19
|
case SmartLinkSize.Large:
|
|
@@ -26,7 +27,11 @@ var getWidth = function getWidth(size) {
|
|
|
26
27
|
};
|
|
27
28
|
|
|
28
29
|
var getIconStyles = function getIconStyles(size) {
|
|
29
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(
|
|
30
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n ", ";\n"])), tokens.actionIcon, getIconSizeStyles(getIconWidth(size)));
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
var getButtonStyle = function getButtonStyle(size, iconOnly) {
|
|
34
|
+
return size === SmartLinkSize.Small ? css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n line-height: 1rem;\n button,\n button:hover,\n button:focus,\n button:active {\n line-height: 1rem;\n ", "\n }\n "])), iconOnly ? "\n padding: 0.125rem;\n " : "\n padding-left: 0.25rem;\n padding-right: 0.25rem;\n ") : '';
|
|
30
35
|
};
|
|
31
36
|
|
|
32
37
|
var ActionIcon = function ActionIcon(_ref) {
|
|
@@ -39,6 +44,8 @@ var ActionIcon = function ActionIcon(_ref) {
|
|
|
39
44
|
}, icon);
|
|
40
45
|
};
|
|
41
46
|
|
|
47
|
+
var sizeToSpacing = (_sizeToSpacing = {}, _defineProperty(_sizeToSpacing, SmartLinkSize.Small, 'none'), _defineProperty(_sizeToSpacing, SmartLinkSize.Medium, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.Large, 'compact'), _defineProperty(_sizeToSpacing, SmartLinkSize.XLarge, 'default'), _sizeToSpacing);
|
|
48
|
+
|
|
42
49
|
var Action = function Action(_ref2) {
|
|
43
50
|
var _ref2$appearance = _ref2.appearance,
|
|
44
51
|
appearance = _ref2$appearance === void 0 ? 'subtle' : _ref2$appearance,
|
|
@@ -57,26 +64,29 @@ var Action = function Action(_ref2) {
|
|
|
57
64
|
return null;
|
|
58
65
|
}
|
|
59
66
|
|
|
60
|
-
var iconBefore = iconPosition === 'before' ? jsx(ActionIcon, {
|
|
67
|
+
var iconBefore = icon && iconPosition === 'before' ? jsx(ActionIcon, {
|
|
61
68
|
size: size,
|
|
62
69
|
testId: testId,
|
|
63
70
|
icon: icon
|
|
64
71
|
}) : undefined;
|
|
65
|
-
var iconAfter = iconPosition === 'after' ? jsx(ActionIcon, {
|
|
72
|
+
var iconAfter = icon && iconPosition === 'after' ? jsx(ActionIcon, {
|
|
66
73
|
size: size,
|
|
67
74
|
testId: testId,
|
|
68
75
|
icon: icon
|
|
69
76
|
}) : undefined;
|
|
77
|
+
var iconOnly = !content;
|
|
70
78
|
return jsx(Tooltip, {
|
|
71
79
|
content: tooltipMessage
|
|
80
|
+
}, jsx("div", {
|
|
81
|
+
css: getButtonStyle(size, iconOnly)
|
|
72
82
|
}, jsx(Button, {
|
|
73
|
-
spacing:
|
|
83
|
+
spacing: sizeToSpacing[size],
|
|
74
84
|
appearance: appearance,
|
|
75
85
|
testId: testId,
|
|
76
86
|
onClick: handleOnClick(onClick),
|
|
77
87
|
iconBefore: iconBefore,
|
|
78
88
|
iconAfter: iconAfter
|
|
79
|
-
}, content));
|
|
89
|
+
}, content)));
|
|
80
90
|
};
|
|
81
91
|
|
|
82
92
|
export default Action;
|
|
@@ -1,5 +1,10 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
2
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
3
|
+
|
|
4
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
5
|
+
|
|
6
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
7
|
+
|
|
3
8
|
import { ActionName } from '../../../../constants';
|
|
4
9
|
import { FlexibleUiContext } from '../../../../state/flexible-ui-context';
|
|
5
10
|
import React, { useContext } from 'react';
|
|
@@ -12,6 +17,7 @@ var actionMappings = _defineProperty({}, ActionName.DeleteAction, {
|
|
|
12
17
|
component: Action,
|
|
13
18
|
props: {
|
|
14
19
|
testId: 'smart-action-delete-action',
|
|
20
|
+
content: /*#__PURE__*/React.createElement(FormattedMessage, messages.delete),
|
|
15
21
|
icon: /*#__PURE__*/React.createElement(CrossIcon, {
|
|
16
22
|
label: "Delete"
|
|
17
23
|
}),
|
|
@@ -65,6 +71,8 @@ export var createUIAction = function createUIAction(name) {
|
|
|
65
71
|
}
|
|
66
72
|
|
|
67
73
|
return function (overrides) {
|
|
68
|
-
|
|
74
|
+
var combinedProps = _objectSpread(_objectSpread({}, props), overrides);
|
|
75
|
+
|
|
76
|
+
return /*#__PURE__*/React.createElement(BaseAction, combinedProps);
|
|
69
77
|
};
|
|
70
78
|
};
|
|
@@ -13,12 +13,13 @@ var ActionGroup = function ActionGroup(_ref) {
|
|
|
13
13
|
var _ref$items = _ref.items,
|
|
14
14
|
items = _ref$items === void 0 ? [] : _ref$items,
|
|
15
15
|
_ref$size = _ref.size,
|
|
16
|
-
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size
|
|
16
|
+
size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
|
|
17
|
+
appearance = _ref.appearance;
|
|
17
18
|
// Currently we only have delete action available, this prevents others from adding more delete actions
|
|
18
19
|
var actionsToRender = items.slice(0, 1);
|
|
19
20
|
return jsx("div", {
|
|
20
21
|
css: styles
|
|
21
|
-
}, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size)));
|
|
22
|
+
}, jsx(ButtonGroup, null, renderActionItems(actionsToRender, size, appearance)));
|
|
22
23
|
};
|
|
23
24
|
|
|
24
25
|
export default ActionGroup;
|
|
@@ -0,0 +1,34 @@
|
|
|
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
|
+
var FooterBlock = function FooterBlock(props) {
|
|
10
|
+
var status = props.status,
|
|
11
|
+
actions = props.actions,
|
|
12
|
+
_props$testId = props.testId,
|
|
13
|
+
testId = _props$testId === void 0 ? 'smart-footer-block' : _props$testId;
|
|
14
|
+
|
|
15
|
+
if (status !== SmartLinkStatus.Resolved) {
|
|
16
|
+
return null;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, props, {
|
|
20
|
+
testId: "".concat(testId, "-resolved-view")
|
|
21
|
+
}), /*#__PURE__*/React.createElement(Provider, {
|
|
22
|
+
testId: "".concat(testId, "-provider")
|
|
23
|
+
}), actions && actions.length > 0 ? /*#__PURE__*/React.createElement(ElementGroup, {
|
|
24
|
+
testId: "smart-element-group-actions",
|
|
25
|
+
align: SmartLinkAlignment.Right,
|
|
26
|
+
direction: SmartLinkDirection.Horizontal,
|
|
27
|
+
width: SmartLinkWidth.Flexible
|
|
28
|
+
}, /*#__PURE__*/React.createElement(ActionGroup, {
|
|
29
|
+
items: actions,
|
|
30
|
+
appearance: "default"
|
|
31
|
+
})) : null);
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
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,34 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
3
|
+
var _excluded = ["maxLines", "status", "testId"];
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import Block from '../block';
|
|
6
|
+
import { SmartLinkStatus } from '../../../../../constants';
|
|
7
|
+
import { Snippet } from '../../elements';
|
|
8
|
+
import { getMaxLines } from '../../utils';
|
|
9
|
+
var DEFAULT_MAX_LINES = 3;
|
|
10
|
+
var MAXIMUM_MAX_LINES = 3;
|
|
11
|
+
var MINIMUM_MAX_LINES = 1;
|
|
12
|
+
|
|
13
|
+
var SnippetBlock = function SnippetBlock(_ref) {
|
|
14
|
+
var _ref$maxLines = _ref.maxLines,
|
|
15
|
+
maxLines = _ref$maxLines === void 0 ? DEFAULT_MAX_LINES : _ref$maxLines,
|
|
16
|
+
_ref$status = _ref.status,
|
|
17
|
+
status = _ref$status === void 0 ? SmartLinkStatus.Fallback : _ref$status,
|
|
18
|
+
_ref$testId = _ref.testId,
|
|
19
|
+
testId = _ref$testId === void 0 ? 'smart-block-snippet' : _ref$testId,
|
|
20
|
+
blockProps = _objectWithoutProperties(_ref, _excluded);
|
|
21
|
+
|
|
22
|
+
if (status !== SmartLinkStatus.Resolved) {
|
|
23
|
+
return null;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
var snippetMaxLines = getMaxLines(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
|
|
27
|
+
return /*#__PURE__*/React.createElement(Block, _extends({}, blockProps, {
|
|
28
|
+
testId: "".concat(testId, "-resolved-view")
|
|
29
|
+
}), /*#__PURE__*/React.createElement(Snippet, {
|
|
30
|
+
maxLines: snippetMaxLines
|
|
31
|
+
}));
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
export default SnippetBlock;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -4,10 +4,14 @@ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProper
|
|
|
4
4
|
import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
|
|
5
5
|
import _defineProperty from "@babel/runtime/helpers/defineProperty";
|
|
6
6
|
var _excluded = ["name"],
|
|
7
|
-
_excluded2 = ["name"];
|
|
7
|
+
_excluded2 = ["name", "hideContent", "hideIcon", "onClick"];
|
|
8
8
|
|
|
9
9
|
var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3;
|
|
10
10
|
|
|
11
|
+
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
12
|
+
|
|
13
|
+
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
14
|
+
|
|
11
15
|
import React from 'react';
|
|
12
16
|
import { css } from '@emotion/core';
|
|
13
17
|
import { ElementName, SmartLinkDirection, SmartLinkSize } from '../../../../constants';
|
|
@@ -15,8 +19,7 @@ import * as Elements from '../elements';
|
|
|
15
19
|
import * as Actions from '../actions';
|
|
16
20
|
import { isFlexibleUiElement } from '../../../../utils/flexible';
|
|
17
21
|
import ActionGroup from './action-group';
|
|
18
|
-
import ElementGroup from './element-group';
|
|
19
|
-
|
|
22
|
+
import ElementGroup from './element-group';
|
|
20
23
|
export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _ElementDisplaySchema);
|
|
21
24
|
|
|
22
25
|
var getDirectionStyles = function getDirectionStyles(direction) {
|
|
@@ -110,17 +113,33 @@ export var renderElementItems = function renderElementItems() {
|
|
|
110
113
|
export var renderActionItems = function renderActionItems() {
|
|
111
114
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
112
115
|
var size = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : SmartLinkSize.Medium;
|
|
116
|
+
var appearance = arguments.length > 2 ? arguments[2] : undefined;
|
|
113
117
|
var actions = items.reduce(function (acc, curr, idx) {
|
|
114
118
|
var name = curr.name,
|
|
119
|
+
hideContent = curr.hideContent,
|
|
120
|
+
hideIcon = curr.hideIcon,
|
|
121
|
+
onClick = curr.onClick,
|
|
115
122
|
props = _objectWithoutProperties(curr, _excluded2);
|
|
116
123
|
|
|
117
124
|
var Action = Actions[name];
|
|
118
125
|
|
|
126
|
+
var actionProps = _objectSpread({}, props);
|
|
127
|
+
|
|
128
|
+
if (hideContent) {
|
|
129
|
+
actionProps.content = '';
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (hideIcon) {
|
|
133
|
+
actionProps.icon = undefined;
|
|
134
|
+
}
|
|
135
|
+
|
|
119
136
|
if (Action) {
|
|
120
137
|
return [].concat(_toConsumableArray(acc), [/*#__PURE__*/React.createElement(Action, _extends({
|
|
121
138
|
size: size,
|
|
122
|
-
key: idx
|
|
123
|
-
|
|
139
|
+
key: idx,
|
|
140
|
+
appearance: appearance,
|
|
141
|
+
onClick: onClick
|
|
142
|
+
}, actionProps))]);
|
|
124
143
|
}
|
|
125
144
|
|
|
126
145
|
return acc;
|
|
@@ -281,7 +281,7 @@ var AtlaskitIcon = function AtlaskitIcon(_ref3) {
|
|
|
281
281
|
case IconType.Jira:
|
|
282
282
|
// Logo component has a different prop set from other icon components
|
|
283
283
|
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
284
|
-
"data-
|
|
284
|
+
"data-testid": testId // Confluence and Jira imports don't have native testId prop
|
|
285
285
|
,
|
|
286
286
|
textColor: N700,
|
|
287
287
|
iconColor: B200,
|
|
@@ -8,12 +8,14 @@ import { css, jsx } from '@emotion/core';
|
|
|
8
8
|
import { getFormattedMessage, getTruncateStyles } from '../../utils';
|
|
9
9
|
import { tokens } from '../../../../../utils/token';
|
|
10
10
|
|
|
11
|
-
var getStyles = function getStyles(maxLines) {
|
|
12
|
-
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])),
|
|
11
|
+
var getStyles = function getStyles(maxLines, color) {
|
|
12
|
+
return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), color, getTruncateStyles(maxLines));
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
var Text = function Text(_ref) {
|
|
16
|
-
var
|
|
16
|
+
var _ref$color = _ref.color,
|
|
17
|
+
color = _ref$color === void 0 ? tokens.text : _ref$color,
|
|
18
|
+
content = _ref.content,
|
|
17
19
|
_ref$maxLines = _ref.maxLines,
|
|
18
20
|
maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
|
|
19
21
|
message = _ref.message,
|
|
@@ -25,7 +27,7 @@ var Text = function Text(_ref) {
|
|
|
25
27
|
}
|
|
26
28
|
|
|
27
29
|
return jsx("span", {
|
|
28
|
-
css: getStyles(maxLines),
|
|
30
|
+
css: getStyles(maxLines, color),
|
|
29
31
|
"data-smart-element-text": true,
|
|
30
32
|
"data-testid": testId
|
|
31
33
|
}, getFormattedMessage(message) || content);
|
|
@@ -14,6 +14,8 @@ import AvatarGroup from './avatar-group';
|
|
|
14
14
|
import Text from './text';
|
|
15
15
|
import { messages } from '../../../../messages';
|
|
16
16
|
import DateTime from './date-time';
|
|
17
|
+
import { tokens } from '../../../../utils/token';
|
|
18
|
+
var SNIPPET_DEFAULT_MAX_LINES = 3;
|
|
17
19
|
var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings, ElementName.AuthorGroup, {
|
|
18
20
|
component: AvatarGroup
|
|
19
21
|
}), _defineProperty(_elementMappings, ElementName.CollaboratorGroup, {
|
|
@@ -39,7 +41,8 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
|
|
|
39
41
|
}), _defineProperty(_elementMappings, ElementName.Snippet, {
|
|
40
42
|
component: Text,
|
|
41
43
|
props: {
|
|
42
|
-
|
|
44
|
+
color: tokens.snippet,
|
|
45
|
+
maxLines: SNIPPET_DEFAULT_MAX_LINES
|
|
43
46
|
}
|
|
44
47
|
}), _defineProperty(_elementMappings, ElementName.State, {
|
|
45
48
|
component: Lozenge
|
|
@@ -51,6 +51,17 @@ export var getLinkSizeStyles = function getLinkSizeStyles(size) {
|
|
|
51
51
|
return css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n font-size: 0.75rem;\n font-weight: 500;\n letter-spacing: 0em;\n line-height: ", ";\n "])), getLinkLineHeight(size));
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
+
export var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
|
|
55
|
+
if (value > max) {
|
|
56
|
+
return defaultValue;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
if (value < min) {
|
|
60
|
+
return min;
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
return value;
|
|
64
|
+
};
|
|
54
65
|
export var getTruncateStyles = function getTruncateStyles(maxLines) {
|
|
55
66
|
var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
|
|
56
67
|
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);
|
|
@@ -1,21 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The alignment of Flexible UI component.
|
|
3
|
+
*/
|
|
1
4
|
export declare enum SmartLinkAlignment {
|
|
2
5
|
Left = "left",
|
|
3
6
|
Right = "right"
|
|
4
7
|
}
|
|
8
|
+
/**
|
|
9
|
+
* The direction of Flexible UI components. It establish the main-axis
|
|
10
|
+
* or how the child components laid out inside the parent component.
|
|
11
|
+
* Similar to flex's flex-direction concept.
|
|
12
|
+
*/
|
|
5
13
|
export declare enum SmartLinkDirection {
|
|
6
14
|
Horizontal = "horizontal",
|
|
7
15
|
Vertical = "vertical"
|
|
8
16
|
}
|
|
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
|
export declare enum SmartLinkPosition {
|
|
10
22
|
Top = "top",
|
|
11
23
|
Center = "center"
|
|
12
24
|
}
|
|
25
|
+
/**
|
|
26
|
+
* The sizing options of the Flexible UI component. Every component
|
|
27
|
+
* has or inherits the sizing props. Implementation varies
|
|
28
|
+
* as per component.
|
|
29
|
+
*/
|
|
13
30
|
export declare enum SmartLinkSize {
|
|
14
31
|
XLarge = "xlarge",
|
|
15
32
|
Large = "large",
|
|
16
33
|
Medium = "medium",
|
|
17
34
|
Small = "small"
|
|
18
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Smart Links link request status
|
|
38
|
+
*/
|
|
19
39
|
export declare enum SmartLinkStatus {
|
|
20
40
|
Pending = "pending",
|
|
21
41
|
Resolving = "resolving",
|
|
@@ -26,14 +46,39 @@ export declare enum SmartLinkStatus {
|
|
|
26
46
|
Unauthorized = "unauthorized",
|
|
27
47
|
Fallback = "fallback"
|
|
28
48
|
}
|
|
49
|
+
/**
|
|
50
|
+
* Flexible UI theme available on the Card level.
|
|
51
|
+
* This determine the styling of the link.
|
|
52
|
+
*/
|
|
29
53
|
export declare enum SmartLinkTheme {
|
|
30
54
|
Black = "black",
|
|
31
55
|
Link = "link"
|
|
32
56
|
}
|
|
57
|
+
/**
|
|
58
|
+
* Determines whether the container size will fit to the content
|
|
59
|
+
* or expand to the available width or the parent component.
|
|
60
|
+
* Similar to flex's flex-grow concept.
|
|
61
|
+
*/
|
|
33
62
|
export declare enum SmartLinkWidth {
|
|
34
63
|
FitToContent = "fit-to-content",
|
|
35
64
|
Flexible = "flexible"
|
|
36
65
|
}
|
|
66
|
+
/**
|
|
67
|
+
* Flexible UI element name - each reflecting the link data its represented.
|
|
68
|
+
* When adding an element...
|
|
69
|
+
* 1) Create base element if it doesn't already existed.
|
|
70
|
+
* Base element are inside src/view/FlexibleCard/components/elements.
|
|
71
|
+
* E.g. Badge,DateTime, Icon, Lozenge, etc.
|
|
72
|
+
* 2) Update FlexibleUiContext with the new prop for data representing
|
|
73
|
+
* the element, preferably with the same name as the element itself.
|
|
74
|
+
* (src/state/flexible-ui-context/types.ts)
|
|
75
|
+
* 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
|
|
76
|
+
* 4) Set base element and data mapping
|
|
77
|
+
* (src/view/FlexibleCard/components/elements/utils.tsx)
|
|
78
|
+
* 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
|
|
79
|
+
* 6) Update element ElementDisplaySchema for inline/block display
|
|
80
|
+
* (src/view/FlexibleCard/components/blocks/utils.tsx)
|
|
81
|
+
*/
|
|
37
82
|
export declare enum ElementName {
|
|
38
83
|
AuthorGroup = "AuthorGroup",
|
|
39
84
|
CollaboratorGroup = "CollaboratorGroup",
|
|
@@ -51,9 +96,15 @@ export declare enum ElementName {
|
|
|
51
96
|
Title = "Title",
|
|
52
97
|
Provider = "Provider"
|
|
53
98
|
}
|
|
99
|
+
/**
|
|
100
|
+
* Flexible UI action (button)
|
|
101
|
+
*/
|
|
54
102
|
export declare enum ActionName {
|
|
55
103
|
DeleteAction = "DeleteAction"
|
|
56
104
|
}
|
|
105
|
+
/**
|
|
106
|
+
* Flexible UI icons - each mapped to AK icons.
|
|
107
|
+
*/
|
|
57
108
|
export declare enum IconType {
|
|
58
109
|
Archive = "FileType:Archive",
|
|
59
110
|
Audio = "FileType:Audio",
|
package/dist/types/index.d.ts
CHANGED
|
@@ -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 { MetadataBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
|
|
20
|
+
export { MetadataBlock, SnippetBlock, TitleBlock, } from './view/FlexibleCard/components/blocks';
|
|
21
21
|
export type { ActionItem, ElementItem, } from './view/FlexibleCard/components/blocks/types';
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
export declare const safeToken: (path: string, fallback?: string | undefined) => any;
|
|
2
1
|
export declare const tokens: {
|
|
3
|
-
actionIcon:
|
|
4
|
-
background:
|
|
5
|
-
badgeIcon:
|
|
6
|
-
badgeText:
|
|
7
|
-
blackLink:
|
|
8
|
-
blackLinkPressed:
|
|
9
|
-
blueLink:
|
|
10
|
-
blueLinkPressed:
|
|
11
|
-
elevation:
|
|
12
|
-
errorMessage:
|
|
13
|
-
errorMessageHover:
|
|
14
|
-
|
|
2
|
+
actionIcon: "var(--ds-icon)";
|
|
3
|
+
background: "var(--ds-surface)";
|
|
4
|
+
badgeIcon: "var(--ds-icon-subtle)";
|
|
5
|
+
badgeText: "var(--ds-text-subtlest)";
|
|
6
|
+
blackLink: "var(--ds-text-subtle)";
|
|
7
|
+
blackLinkPressed: "var(--ds-text)";
|
|
8
|
+
blueLink: "var(--ds-link)";
|
|
9
|
+
blueLinkPressed: "var(--ds-link-pressed)";
|
|
10
|
+
elevation: "var(--ds-shadow-raised)";
|
|
11
|
+
errorMessage: "var(--ds-text-disabled)";
|
|
12
|
+
errorMessageHover: "var(--ds-text-subtle)";
|
|
13
|
+
snippet: "var(--ds-text)";
|
|
14
|
+
text: "var(--ds-text-subtlest)";
|
|
15
15
|
};
|
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { SmartLinkSize, SmartLinkDirection } from '../../../../../constants';
|
|
2
2
|
import { ActionItem } from '../types';
|
|
3
|
+
import { Appearance } from '@atlaskit/button';
|
|
3
4
|
export declare type ActionGroupProps = {
|
|
4
5
|
items: ActionItem[];
|
|
5
6
|
size?: SmartLinkSize;
|
|
6
7
|
direction?: SmartLinkDirection;
|
|
7
8
|
testId?: string;
|
|
9
|
+
appearance?: Appearance;
|
|
8
10
|
};
|
|
@@ -1,2 +1,4 @@
|
|
|
1
|
-
export { default as
|
|
1
|
+
export { default as FooterBlock } from './footer-block';
|
|
2
2
|
export { default as MetadataBlock } from './metadata-block';
|
|
3
|
+
export { default as SnippetBlock } from './snippet-block';
|
|
4
|
+
export { default as TitleBlock } from './title-block';
|
|
@@ -8,4 +8,4 @@ export declare const getGapSize: (size: SmartLinkSize) => number;
|
|
|
8
8
|
export declare const getBaseStyles: (direction: SmartLinkDirection, size: SmartLinkSize) => SerializedStyles;
|
|
9
9
|
export declare const renderChildren: (children: React.ReactNode, size: SmartLinkSize) => React.ReactNode;
|
|
10
10
|
export declare const renderElementItems: (items?: ElementItem[], display?: ElementDisplaySchemaType) => React.ReactNode | undefined;
|
|
11
|
-
export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize) => React.ReactNode | undefined;
|
|
11
|
+
export declare const renderActionItems: (items?: ActionItem[], size?: SmartLinkSize, appearance?: "link" | "default" | "danger" | "primary" | "subtle" | "subtle-link" | "warning" | undefined) => React.ReactNode | undefined;
|
|
@@ -6,4 +6,5 @@ export declare const getFormattedMessage: (message?: MessageProps | undefined) =
|
|
|
6
6
|
export declare const getIconSizeStyles: (width: string) => SerializedStyles;
|
|
7
7
|
export declare const getLinkLineHeight: (size: SmartLinkSize) => string;
|
|
8
8
|
export declare const getLinkSizeStyles: (size: SmartLinkSize) => SerializedStyles;
|
|
9
|
+
export declare const getMaxLines: (value: number, defaultValue: number, max: number, min: number) => number;
|
|
9
10
|
export declare const getTruncateStyles: (maxLines: number, lineHeight?: string) => SerializedStyles;
|