@atlaskit/smart-card 17.3.0 → 17.4.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 +24 -0
- package/dist/cjs/constants.js +16 -1
- package/dist/cjs/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/cjs/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/cjs/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/cjs/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/cjs/extractors/flexible/icon/extract-provider-icon.js +20 -3
- package/dist/cjs/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/cjs/extractors/flexible/icon/index.js +11 -20
- package/dist/cjs/extractors/flexible/index.js +5 -0
- package/dist/cjs/utils/flexible.js +2 -2
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +1 -1
- package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +27 -7
- package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/cjs/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/cjs/view/FlexibleCard/components/elements/index.js +6 -2
- package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +6 -2
- package/dist/cjs/view/FlexibleCard/components/elements/utils.js +64 -39
- package/dist/es2019/constants.js +15 -1
- package/dist/es2019/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/es2019/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/es2019/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/es2019/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/es2019/extractors/flexible/icon/extract-provider-icon.js +19 -3
- package/dist/es2019/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/es2019/extractors/flexible/icon/index.js +6 -9
- package/dist/es2019/extractors/flexible/index.js +5 -1
- package/dist/es2019/utils/flexible.js +2 -2
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +1 -1
- package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +38 -6
- package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/es2019/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/es2019/view/FlexibleCard/components/elements/index.js +3 -1
- package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +5 -3
- package/dist/es2019/view/FlexibleCard/components/elements/utils.js +66 -37
- package/dist/esm/constants.js +15 -1
- package/dist/esm/extractors/flexible/icon/extract-document-type-icon.js +28 -7
- package/dist/esm/extractors/flexible/icon/extract-file-formatIcon.js +88 -22
- package/dist/esm/extractors/flexible/icon/extract-jira-task-icon.js +36 -9
- package/dist/esm/extractors/flexible/icon/extract-jsonld-data-icon.js +33 -9
- package/dist/esm/extractors/flexible/icon/extract-provider-icon.js +19 -3
- package/dist/esm/extractors/flexible/icon/extract-url-icon.js +4 -1
- package/dist/esm/extractors/flexible/icon/index.js +12 -20
- package/dist/esm/extractors/flexible/index.js +5 -1
- package/dist/esm/utils/flexible.js +2 -2
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +1 -1
- package/dist/esm/view/FlexibleCard/components/blocks/utils.js +25 -7
- package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +2 -0
- package/dist/esm/view/FlexibleCard/components/elements/badge/index.js +2 -4
- package/dist/esm/view/FlexibleCard/components/elements/index.js +3 -1
- package/dist/esm/view/FlexibleCard/components/elements/text/index.js +7 -2
- package/dist/esm/view/FlexibleCard/components/elements/utils.js +64 -39
- package/dist/types/__fixtures__/flexible-ui-data-context.d.ts +3 -0
- package/dist/types/constants.d.ts +3 -1
- package/dist/types/extractors/flexible/icon/extract-provider-icon.d.ts +1 -1
- package/dist/types/extractors/flexible/icon/index.d.ts +3 -3
- package/dist/types/extractors/flexible/icon/types.d.ts +5 -1
- package/dist/types/state/flexible-ui-context/types.d.ts +4 -2
- package/dist/types/utils/flexible.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/blocks/utils.d.ts +4 -2
- package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +1 -2
- package/dist/types/view/FlexibleCard/components/elements/index.d.ts +2 -0
- package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -7,16 +7,18 @@ var _typeof = require("@babel/runtime/helpers/typeof");
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", {
|
|
8
8
|
value: true
|
|
9
9
|
});
|
|
10
|
-
exports.renderElementItems = exports.renderChildren = exports.renderActionItems = exports.getGapSize = exports.getBaseStyles = void 0;
|
|
11
|
-
|
|
12
|
-
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
10
|
+
exports.renderElementItems = exports.renderChildren = exports.renderActionItems = exports.getGapSize = exports.getBaseStyles = exports.ElementDisplaySchema = void 0;
|
|
13
11
|
|
|
14
12
|
var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
|
|
15
13
|
|
|
14
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
15
|
+
|
|
16
16
|
var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
|
|
17
17
|
|
|
18
18
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
19
19
|
|
|
20
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
21
|
+
|
|
20
22
|
var _react = _interopRequireDefault(require("react"));
|
|
21
23
|
|
|
22
24
|
var _core = require("@emotion/core");
|
|
@@ -36,12 +38,15 @@ var _elementGroup = _interopRequireDefault(require("./element-group"));
|
|
|
36
38
|
var _excluded = ["name"],
|
|
37
39
|
_excluded2 = ["name"];
|
|
38
40
|
|
|
39
|
-
var _templateObject, _templateObject2, _templateObject3;
|
|
41
|
+
var _ElementDisplaySchema, _templateObject, _templateObject2, _templateObject3;
|
|
40
42
|
|
|
41
43
|
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
42
44
|
|
|
43
45
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
44
46
|
|
|
47
|
+
var ElementDisplaySchema = (_ElementDisplaySchema = {}, (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.AuthorGroup, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.CollaboratorGroup, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.CommentCount, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.CreatedBy, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.CreatedOn, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.LinkIcon, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.ModifiedBy, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.ModifiedOn, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.Priority, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.ProgrammingLanguage, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.Snippet, ['block']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.State, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.SubscriberCount, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.Title, ['inline']), (0, _defineProperty2.default)(_ElementDisplaySchema, _constants.ElementName.Provider, ['inline']), _ElementDisplaySchema);
|
|
48
|
+
exports.ElementDisplaySchema = ElementDisplaySchema;
|
|
49
|
+
|
|
45
50
|
var getDirectionStyles = function getDirectionStyles(direction) {
|
|
46
51
|
switch (direction) {
|
|
47
52
|
case _constants.SmartLinkDirection.Vertical:
|
|
@@ -82,6 +87,16 @@ var isActionGroup = function isActionGroup(node) {
|
|
|
82
87
|
return /*#__PURE__*/_react.default.isValidElement(node) && node.type === _actionGroup.default;
|
|
83
88
|
};
|
|
84
89
|
|
|
90
|
+
var isElementDisplayValid = function isElementDisplayValid(name, display) {
|
|
91
|
+
var _ElementDisplaySchema2, _ElementDisplaySchema3;
|
|
92
|
+
|
|
93
|
+
return (_ElementDisplaySchema2 = (_ElementDisplaySchema3 = ElementDisplaySchema[name]) === null || _ElementDisplaySchema3 === void 0 ? void 0 : _ElementDisplaySchema3.includes(display)) !== null && _ElementDisplaySchema2 !== void 0 ? _ElementDisplaySchema2 : false;
|
|
94
|
+
};
|
|
95
|
+
|
|
96
|
+
var isElementNull = function isElementNull(children) {
|
|
97
|
+
return Boolean(children.type() === null);
|
|
98
|
+
};
|
|
99
|
+
|
|
85
100
|
var isElementOrElementGroup = function isElementOrElementGroup(node) {
|
|
86
101
|
return /*#__PURE__*/_react.default.isValidElement(node) && ((0, _flexible.isFlexibleUiElement)(node) || node.type === _elementGroup.default);
|
|
87
102
|
};
|
|
@@ -104,15 +119,20 @@ exports.renderChildren = renderChildren;
|
|
|
104
119
|
|
|
105
120
|
var renderElementItems = function renderElementItems() {
|
|
106
121
|
var items = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
|
|
122
|
+
var display = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'inline';
|
|
107
123
|
var elements = items.reduce(function (acc, curr, idx) {
|
|
108
124
|
var name = curr.name,
|
|
109
125
|
props = (0, _objectWithoutProperties2.default)(curr, _excluded);
|
|
110
126
|
var Element = Elements[name];
|
|
111
127
|
|
|
112
|
-
if (Element) {
|
|
113
|
-
|
|
128
|
+
if (Element && isElementDisplayValid(name, display)) {
|
|
129
|
+
var element = /*#__PURE__*/_react.default.createElement(Element, (0, _extends2.default)({
|
|
114
130
|
key: idx
|
|
115
|
-
}, props))
|
|
131
|
+
}, props));
|
|
132
|
+
|
|
133
|
+
if (!isElementNull(element)) {
|
|
134
|
+
return [].concat((0, _toConsumableArray2.default)(acc), [element]);
|
|
135
|
+
}
|
|
116
136
|
}
|
|
117
137
|
|
|
118
138
|
return acc;
|
|
@@ -300,6 +300,8 @@ var AtlaskitIcon = function AtlaskitIcon(_ref3) {
|
|
|
300
300
|
case _constants.IconType.Jira:
|
|
301
301
|
// Logo component has a different prop set from other icon components
|
|
302
302
|
return /*#__PURE__*/_react.default.createElement(ImportedIcon, {
|
|
303
|
+
"data-testId": testId // Confluence and Jira imports don't have native testId prop
|
|
304
|
+
,
|
|
303
305
|
textColor: _colors.N700,
|
|
304
306
|
iconColor: _colors.B200,
|
|
305
307
|
iconGradientStart: _colors.B400,
|
|
@@ -34,7 +34,7 @@ var iconStyles = (0, _core.css)(_templateObject2 || (_templateObject2 = (0, _tag
|
|
|
34
34
|
var labelStyles = (0, _core.css)(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n padding-left: 0.125rem;\n"])), _token.tokens.badgeText);
|
|
35
35
|
var messageMapper = (_messageMapper = {}, (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityBlocker, _messages.messages.priority_blocker), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityCritical, _messages.messages.priority_critical), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityHigh, _messages.messages.priority_high), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityHighest, _messages.messages.priority_highest), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityLow, _messages.messages.priority_low), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityLowest, _messages.messages.priority_lowest), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityMajor, _messages.messages.priority_major), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityMedium, _messages.messages.priority_medium), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityMinor, _messages.messages.priority_minor), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityTrivial, _messages.messages.priority_trivial), (0, _defineProperty2.default)(_messageMapper, _constants.IconType.PriorityUndefined, _messages.messages.priority_undefined), _messageMapper);
|
|
36
36
|
|
|
37
|
-
var
|
|
37
|
+
var getFormattedMessageFromIcon = function getFormattedMessageFromIcon(icon) {
|
|
38
38
|
if (icon) {
|
|
39
39
|
var descriptor = messageMapper[icon];
|
|
40
40
|
|
|
@@ -44,8 +44,6 @@ var getFormattedMessageOrLabel = function getFormattedMessageOrLabel(icon, conte
|
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
46
|
}
|
|
47
|
-
|
|
48
|
-
return content;
|
|
49
47
|
};
|
|
50
48
|
|
|
51
49
|
var renderAtlaskitIcon = function renderAtlaskitIcon(icon, testId) {
|
|
@@ -73,7 +71,7 @@ var Badge = function Badge(_ref) {
|
|
|
73
71
|
label = _ref.label,
|
|
74
72
|
_ref$testId = _ref.testId,
|
|
75
73
|
testId = _ref$testId === void 0 ? 'smart-element-badge' : _ref$testId;
|
|
76
|
-
var formattedMessageOrLabel =
|
|
74
|
+
var formattedMessageOrLabel = getFormattedMessageFromIcon(icon) || label;
|
|
77
75
|
var badgeIcon = renderAtlaskitIcon(icon, testId) || renderImageIcon(url, testId);
|
|
78
76
|
|
|
79
77
|
if (!formattedMessageOrLabel || !badgeIcon) {
|
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, "__esModule", {
|
|
4
4
|
value: true
|
|
5
5
|
});
|
|
6
|
-
exports.Title = exports.SubscriberCount = exports.State = exports.ProgrammingLanguage = exports.Priority = exports.ModifiedOn = exports.ModifiedBy = exports.LinkIcon = exports.CreatedOn = exports.CreatedBy = exports.CommentCount = exports.CollaboratorGroup = exports.AuthorGroup = void 0;
|
|
6
|
+
exports.Title = exports.SubscriberCount = exports.State = exports.Snippet = exports.Provider = exports.ProgrammingLanguage = exports.Priority = exports.ModifiedOn = exports.ModifiedBy = exports.LinkIcon = exports.CreatedOn = exports.CreatedBy = exports.CommentCount = exports.CollaboratorGroup = exports.AuthorGroup = void 0;
|
|
7
7
|
|
|
8
8
|
var _utils = require("./utils");
|
|
9
9
|
|
|
@@ -32,9 +32,13 @@ var Priority = (0, _utils.createElement)(_constants.ElementName.Priority);
|
|
|
32
32
|
exports.Priority = Priority;
|
|
33
33
|
var ProgrammingLanguage = (0, _utils.createElement)(_constants.ElementName.ProgrammingLanguage);
|
|
34
34
|
exports.ProgrammingLanguage = ProgrammingLanguage;
|
|
35
|
+
var Snippet = (0, _utils.createElement)(_constants.ElementName.Snippet);
|
|
36
|
+
exports.Snippet = Snippet;
|
|
35
37
|
var State = (0, _utils.createElement)(_constants.ElementName.State);
|
|
36
38
|
exports.State = State;
|
|
37
39
|
var SubscriberCount = (0, _utils.createElement)(_constants.ElementName.SubscriberCount);
|
|
38
40
|
exports.SubscriberCount = SubscriberCount;
|
|
39
41
|
var Title = (0, _utils.createElement)(_constants.ElementName.Title);
|
|
40
|
-
exports.Title = Title;
|
|
42
|
+
exports.Title = Title;
|
|
43
|
+
var Provider = (0, _utils.createElement)(_constants.ElementName.Provider);
|
|
44
|
+
exports.Provider = Provider;
|
|
@@ -19,10 +19,14 @@ var _token = require("../../../../../utils/token");
|
|
|
19
19
|
|
|
20
20
|
var _templateObject;
|
|
21
21
|
|
|
22
|
-
var
|
|
22
|
+
var getStyles = function getStyles(maxLines) {
|
|
23
|
+
return (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), _token.tokens.text, (0, _utils.getTruncateStyles)(maxLines));
|
|
24
|
+
};
|
|
23
25
|
|
|
24
26
|
var Text = function Text(_ref) {
|
|
25
27
|
var content = _ref.content,
|
|
28
|
+
_ref$maxLines = _ref.maxLines,
|
|
29
|
+
maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
|
|
26
30
|
message = _ref.message,
|
|
27
31
|
_ref$testId = _ref.testId,
|
|
28
32
|
testId = _ref$testId === void 0 ? 'smart-element-text' : _ref$testId;
|
|
@@ -32,7 +36,7 @@ var Text = function Text(_ref) {
|
|
|
32
36
|
}
|
|
33
37
|
|
|
34
38
|
return (0, _core.jsx)("span", {
|
|
35
|
-
css:
|
|
39
|
+
css: getStyles(maxLines),
|
|
36
40
|
"data-smart-element-text": true,
|
|
37
41
|
"data-testid": testId
|
|
38
42
|
}, (0, _utils.getFormattedMessage)(message) || content);
|
|
@@ -63,6 +63,11 @@ var elementMappings = (_elementMappings = {}, (0, _defineProperty2.default)(_ele
|
|
|
63
63
|
props: {
|
|
64
64
|
icon: _constants.IconType.ProgrammingLanguage
|
|
65
65
|
}
|
|
66
|
+
}), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.Snippet, {
|
|
67
|
+
component: _text.default,
|
|
68
|
+
props: {
|
|
69
|
+
maxLines: 3
|
|
70
|
+
}
|
|
66
71
|
}), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.State, {
|
|
67
72
|
component: _lozenge.default
|
|
68
73
|
}), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.SubscriberCount, {
|
|
@@ -76,6 +81,8 @@ var elementMappings = (_elementMappings = {}, (0, _defineProperty2.default)(_ele
|
|
|
76
81
|
component: _dateTime.default
|
|
77
82
|
}), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.ModifiedOn, {
|
|
78
83
|
component: _dateTime.default
|
|
84
|
+
}), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.Provider, {
|
|
85
|
+
component: _badge.default
|
|
79
86
|
}), _elementMappings);
|
|
80
87
|
|
|
81
88
|
var getContextKey = function getContextKey(name) {
|
|
@@ -84,17 +91,6 @@ var getContextKey = function getContextKey(name) {
|
|
|
84
91
|
return name.length > 0 ? name.charAt(0).toLowerCase() + name.slice(1) : undefined;
|
|
85
92
|
};
|
|
86
93
|
|
|
87
|
-
var getFormattedMessage = function getFormattedMessage(descriptor, value) {
|
|
88
|
-
return value ? {
|
|
89
|
-
message: {
|
|
90
|
-
descriptor: descriptor,
|
|
91
|
-
values: {
|
|
92
|
-
context: value
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
} : undefined;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
94
|
var getData = function getData(elementName, contextKey, context) {
|
|
99
95
|
if (!context) {
|
|
100
96
|
return undefined;
|
|
@@ -103,52 +99,81 @@ var getData = function getData(elementName, contextKey, context) {
|
|
|
103
99
|
var data = context[contextKey];
|
|
104
100
|
|
|
105
101
|
switch (elementName) {
|
|
102
|
+
case _constants.ElementName.AuthorGroup:
|
|
103
|
+
case _constants.ElementName.CollaboratorGroup:
|
|
104
|
+
return toAvatarGroupProps(data);
|
|
105
|
+
|
|
106
106
|
case _constants.ElementName.CommentCount:
|
|
107
107
|
case _constants.ElementName.ProgrammingLanguage:
|
|
108
108
|
case _constants.ElementName.SubscriberCount:
|
|
109
|
-
return
|
|
110
|
-
label: data
|
|
111
|
-
};
|
|
112
|
-
|
|
113
|
-
case _constants.ElementName.AuthorGroup:
|
|
114
|
-
return {
|
|
115
|
-
items: context.authorGroup
|
|
116
|
-
};
|
|
117
|
-
|
|
118
|
-
case _constants.ElementName.CollaboratorGroup:
|
|
119
|
-
return {
|
|
120
|
-
items: context.collaboratorGroup
|
|
121
|
-
};
|
|
109
|
+
return toBadgeProps(data);
|
|
122
110
|
|
|
123
111
|
case _constants.ElementName.CreatedBy:
|
|
124
|
-
return
|
|
112
|
+
return toFormattedTextProps(_messages.messages.created_by, context.createdBy);
|
|
113
|
+
|
|
114
|
+
case _constants.ElementName.CreatedOn:
|
|
115
|
+
return toDateTimeProps('created', context.createdOn);
|
|
125
116
|
|
|
126
117
|
case _constants.ElementName.ModifiedBy:
|
|
127
|
-
return
|
|
118
|
+
return toFormattedTextProps(_messages.messages.modified_by, context.modifiedBy);
|
|
128
119
|
|
|
129
120
|
case _constants.ElementName.ModifiedOn:
|
|
130
|
-
return context.modifiedOn
|
|
131
|
-
date: new Date(context.modifiedOn),
|
|
132
|
-
type: 'modified'
|
|
133
|
-
} : undefined;
|
|
121
|
+
return toDateTimeProps('modified', context.modifiedOn);
|
|
134
122
|
|
|
135
|
-
case _constants.ElementName.
|
|
136
|
-
return
|
|
137
|
-
date: new Date(context.createdOn),
|
|
138
|
-
type: 'created'
|
|
139
|
-
} : undefined;
|
|
123
|
+
case _constants.ElementName.Snippet:
|
|
124
|
+
return toTextProps(data);
|
|
140
125
|
|
|
141
126
|
case _constants.ElementName.Title:
|
|
142
|
-
return
|
|
143
|
-
text: context.title,
|
|
144
|
-
url: context.url
|
|
145
|
-
};
|
|
127
|
+
return toLinkProps(context.title, context.url);
|
|
146
128
|
|
|
147
129
|
default:
|
|
148
130
|
return data;
|
|
149
131
|
}
|
|
150
132
|
};
|
|
151
133
|
|
|
134
|
+
var toAvatarGroupProps = function toAvatarGroupProps(items) {
|
|
135
|
+
return items ? {
|
|
136
|
+
items: items
|
|
137
|
+
} : undefined;
|
|
138
|
+
};
|
|
139
|
+
|
|
140
|
+
var toBadgeProps = function toBadgeProps(label) {
|
|
141
|
+
return label ? {
|
|
142
|
+
label: label
|
|
143
|
+
} : undefined;
|
|
144
|
+
};
|
|
145
|
+
|
|
146
|
+
var toDateTimeProps = function toDateTimeProps(type, dateString) {
|
|
147
|
+
return dateString ? {
|
|
148
|
+
date: new Date(dateString),
|
|
149
|
+
type: type
|
|
150
|
+
} : undefined;
|
|
151
|
+
};
|
|
152
|
+
|
|
153
|
+
var toFormattedTextProps = function toFormattedTextProps(descriptor, context) {
|
|
154
|
+
return context ? {
|
|
155
|
+
message: {
|
|
156
|
+
descriptor: descriptor,
|
|
157
|
+
values: {
|
|
158
|
+
context: context
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
} : undefined;
|
|
162
|
+
};
|
|
163
|
+
|
|
164
|
+
var toLinkProps = function toLinkProps(text, url) {
|
|
165
|
+
return text ? {
|
|
166
|
+
text: text,
|
|
167
|
+
url: url
|
|
168
|
+
} : undefined;
|
|
169
|
+
};
|
|
170
|
+
|
|
171
|
+
var toTextProps = function toTextProps(content) {
|
|
172
|
+
return content ? {
|
|
173
|
+
content: content
|
|
174
|
+
} : undefined;
|
|
175
|
+
};
|
|
176
|
+
|
|
152
177
|
var createElement = function createElement(name) {
|
|
153
178
|
var _ref = elementMappings[name] || {},
|
|
154
179
|
BaseElement = _ref.component,
|
package/dist/es2019/constants.js
CHANGED
|
@@ -48,7 +48,19 @@ export let SmartLinkTheme;
|
|
|
48
48
|
SmartLinkTheme["Link"] = "link";
|
|
49
49
|
})(SmartLinkTheme || (SmartLinkTheme = {}));
|
|
50
50
|
|
|
51
|
-
export let SmartLinkWidth;
|
|
51
|
+
export let SmartLinkWidth; // When adding an element...
|
|
52
|
+
// 1) Create base element if it doesn't already existed.
|
|
53
|
+
// Base element are inside src/view/FlexibleCard/components/elements.
|
|
54
|
+
// E.g. Badge,DateTime, Icon, Lozenge, etc.
|
|
55
|
+
// 2) Update FlexibleUiContext with the new prop for data representing
|
|
56
|
+
// the element, preferably with the same name as the element itself.
|
|
57
|
+
// (src/state/flexible-ui-context/types.ts)
|
|
58
|
+
// 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
|
|
59
|
+
// 4) Set base element and data mapping.
|
|
60
|
+
// (src/view/FlexibleCard/components/elements/utils.tsx)
|
|
61
|
+
// 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
|
|
62
|
+
// 6) Update element ElementDisplaySchema for inline/block display
|
|
63
|
+
// (src/view/FlexibleCard/components/blocks/utils.tsx)
|
|
52
64
|
|
|
53
65
|
(function (SmartLinkWidth) {
|
|
54
66
|
SmartLinkWidth["FitToContent"] = "fit-to-content";
|
|
@@ -68,9 +80,11 @@ export let ElementName;
|
|
|
68
80
|
ElementName["ModifiedOn"] = "ModifiedOn";
|
|
69
81
|
ElementName["Priority"] = "Priority";
|
|
70
82
|
ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
|
|
83
|
+
ElementName["Snippet"] = "Snippet";
|
|
71
84
|
ElementName["State"] = "State";
|
|
72
85
|
ElementName["SubscriberCount"] = "SubscriberCount";
|
|
73
86
|
ElementName["Title"] = "Title";
|
|
87
|
+
ElementName["Provider"] = "Provider";
|
|
74
88
|
})(ElementName || (ElementName = {}));
|
|
75
89
|
|
|
76
90
|
export let ActionName;
|
|
@@ -3,25 +3,46 @@ import { IconType } from '../../../constants';
|
|
|
3
3
|
const extractDocumentTypeIcon = (documentType, label) => {
|
|
4
4
|
switch (documentType) {
|
|
5
5
|
case 'schema:BlogPosting':
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
icon: IconType.Blog,
|
|
8
|
+
label: label || 'Blog'
|
|
9
|
+
};
|
|
7
10
|
|
|
8
11
|
case 'schema:DigitalDocument':
|
|
9
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
icon: IconType.File,
|
|
14
|
+
label: label || 'File'
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
case 'schema:TextDigitalDocument':
|
|
12
|
-
return
|
|
18
|
+
return {
|
|
19
|
+
icon: IconType.Document,
|
|
20
|
+
label: label || 'Document'
|
|
21
|
+
};
|
|
13
22
|
|
|
14
23
|
case 'schema:PresentationDigitalDocument':
|
|
15
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
icon: IconType.Presentation,
|
|
26
|
+
label: label || 'Presentation'
|
|
27
|
+
};
|
|
16
28
|
|
|
17
29
|
case 'schema:SpreadsheetDigitalDocument':
|
|
18
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
icon: IconType.Spreadsheet,
|
|
32
|
+
label: label || 'Spreadsheet'
|
|
33
|
+
};
|
|
19
34
|
|
|
20
35
|
case 'atlassian:Template':
|
|
21
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
icon: IconType.Template,
|
|
38
|
+
label: label || 'Template'
|
|
39
|
+
};
|
|
22
40
|
|
|
23
41
|
case 'atlassian:UndefinedLink':
|
|
24
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
icon: IconType.Document,
|
|
44
|
+
label: label || 'Undefined link'
|
|
45
|
+
};
|
|
25
46
|
|
|
26
47
|
default:
|
|
27
48
|
return undefined;
|
|
@@ -4,66 +4,111 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
4
4
|
switch (fileFormat) {
|
|
5
5
|
// Generic documents
|
|
6
6
|
case 'folder':
|
|
7
|
-
return
|
|
7
|
+
return {
|
|
8
|
+
icon: IconType.Folder,
|
|
9
|
+
label: 'Folder'
|
|
10
|
+
};
|
|
8
11
|
|
|
9
12
|
case 'text/plain':
|
|
10
13
|
case 'application/vnd.oasis.opendocument.text':
|
|
11
14
|
case 'application/vnd.apple.pages':
|
|
12
|
-
return
|
|
15
|
+
return {
|
|
16
|
+
icon: IconType.Document,
|
|
17
|
+
label: 'Document'
|
|
18
|
+
};
|
|
13
19
|
|
|
14
20
|
case 'application/pdf':
|
|
15
|
-
return
|
|
21
|
+
return {
|
|
22
|
+
icon: IconType.PDF,
|
|
23
|
+
label: 'PDF document'
|
|
24
|
+
};
|
|
16
25
|
|
|
17
26
|
case 'application/vnd.oasis.opendocument.presentation':
|
|
18
27
|
case 'application/vnd.apple.keynote':
|
|
19
|
-
return
|
|
28
|
+
return {
|
|
29
|
+
icon: IconType.Presentation,
|
|
30
|
+
label: 'Presentation'
|
|
31
|
+
};
|
|
20
32
|
|
|
21
33
|
case 'application/vnd.oasis.opendocument.spreadsheet':
|
|
22
34
|
case 'application/vnd.apple.numbers':
|
|
23
|
-
return
|
|
35
|
+
return {
|
|
36
|
+
icon: IconType.Spreadsheet,
|
|
37
|
+
label: 'Spreadsheet'
|
|
38
|
+
};
|
|
24
39
|
// Google Drive
|
|
25
40
|
|
|
26
41
|
case 'application/vnd.google-apps.document':
|
|
27
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
icon: IconType.GoogleDocs,
|
|
44
|
+
label: 'Google Docs'
|
|
45
|
+
};
|
|
28
46
|
|
|
29
47
|
case 'application/vnd.google-apps.form':
|
|
30
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
icon: IconType.GoogleForms,
|
|
50
|
+
label: 'Google Form'
|
|
51
|
+
};
|
|
31
52
|
|
|
32
53
|
case 'application/vnd.google-apps.spreadsheet':
|
|
33
|
-
return
|
|
54
|
+
return {
|
|
55
|
+
icon: IconType.GoogleSheets,
|
|
56
|
+
label: 'Google Sheets'
|
|
57
|
+
};
|
|
34
58
|
|
|
35
59
|
case 'application/vnd.google-apps.presentation':
|
|
36
|
-
return
|
|
60
|
+
return {
|
|
61
|
+
icon: IconType.GoogleSlides,
|
|
62
|
+
label: 'Google Slides'
|
|
63
|
+
};
|
|
37
64
|
// Microsoft
|
|
38
65
|
|
|
39
66
|
case 'application/vnd.ms-excel':
|
|
40
67
|
case 'application/vnd.openxmlformats-officedocument.spreadsheetml.sheet':
|
|
41
|
-
return
|
|
68
|
+
return {
|
|
69
|
+
icon: IconType.MSExcel,
|
|
70
|
+
label: 'Excel spreadsheet'
|
|
71
|
+
};
|
|
42
72
|
|
|
43
73
|
case 'application/vnd.ms-powerpoint':
|
|
44
74
|
case 'application/vnd.openxmlformats-officedocument.presentationml.presentation':
|
|
45
|
-
return
|
|
75
|
+
return {
|
|
76
|
+
icon: IconType.MSPowerpoint,
|
|
77
|
+
label: 'PowerPoint presentation'
|
|
78
|
+
};
|
|
46
79
|
|
|
47
80
|
case 'application/msword':
|
|
48
81
|
case 'application/vnd.openxmlformats-officedocument.wordprocessingml.document':
|
|
49
|
-
return
|
|
82
|
+
return {
|
|
83
|
+
icon: IconType.MSWord,
|
|
84
|
+
label: 'Word document'
|
|
85
|
+
};
|
|
50
86
|
|
|
51
87
|
case 'image/png':
|
|
52
88
|
case 'image/jpeg':
|
|
53
89
|
case 'image/bmp':
|
|
54
90
|
case 'image/webp':
|
|
55
91
|
case 'image/svg+xml':
|
|
56
|
-
return
|
|
92
|
+
return {
|
|
93
|
+
icon: IconType.Image,
|
|
94
|
+
label: 'Image'
|
|
95
|
+
};
|
|
57
96
|
|
|
58
97
|
case 'image/gif':
|
|
59
|
-
return
|
|
98
|
+
return {
|
|
99
|
+
icon: IconType.GIF,
|
|
100
|
+
label: 'GIF'
|
|
101
|
+
};
|
|
60
102
|
|
|
61
103
|
case 'audio/midi':
|
|
62
104
|
case 'audio/mpeg':
|
|
63
105
|
case 'audio/webm':
|
|
64
106
|
case 'audio/ogg':
|
|
65
107
|
case 'audio/wav':
|
|
66
|
-
return
|
|
108
|
+
return {
|
|
109
|
+
icon: IconType.Audio,
|
|
110
|
+
label: 'Audio'
|
|
111
|
+
};
|
|
67
112
|
|
|
68
113
|
case 'video/mp4':
|
|
69
114
|
case 'video/quicktime':
|
|
@@ -72,13 +117,19 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
72
117
|
case 'video/ogg':
|
|
73
118
|
case 'video/x-ms-wmv':
|
|
74
119
|
case 'video/x-msvideo':
|
|
75
|
-
return
|
|
120
|
+
return {
|
|
121
|
+
icon: IconType.Video,
|
|
122
|
+
label: 'Video'
|
|
123
|
+
};
|
|
76
124
|
// Others
|
|
77
125
|
|
|
78
126
|
case 'text/css':
|
|
79
127
|
case 'text/html':
|
|
80
128
|
case 'application/javascript':
|
|
81
|
-
return
|
|
129
|
+
return {
|
|
130
|
+
icon: IconType.Code,
|
|
131
|
+
label: 'Source Code'
|
|
132
|
+
};
|
|
82
133
|
|
|
83
134
|
case 'application/zip':
|
|
84
135
|
case 'application/x-tar':
|
|
@@ -86,19 +137,34 @@ const extractFileFormatIcon = fileFormat => {
|
|
|
86
137
|
case 'application/x-7z-compressed':
|
|
87
138
|
case 'application/x-apple-diskimage':
|
|
88
139
|
case 'application/vnd.rar':
|
|
89
|
-
return
|
|
140
|
+
return {
|
|
141
|
+
icon: IconType.Archive,
|
|
142
|
+
label: 'Archive'
|
|
143
|
+
};
|
|
90
144
|
|
|
91
145
|
case 'application/dmg':
|
|
92
|
-
return
|
|
146
|
+
return {
|
|
147
|
+
icon: IconType.Executable,
|
|
148
|
+
label: 'Executable'
|
|
149
|
+
};
|
|
93
150
|
|
|
94
151
|
case 'application/sketch':
|
|
95
|
-
return
|
|
152
|
+
return {
|
|
153
|
+
icon: IconType.Sketch,
|
|
154
|
+
label: 'Sketch'
|
|
155
|
+
};
|
|
96
156
|
|
|
97
157
|
case 'application/octet-stream':
|
|
98
|
-
return
|
|
158
|
+
return {
|
|
159
|
+
icon: IconType.Generic,
|
|
160
|
+
label: 'Binary file'
|
|
161
|
+
};
|
|
99
162
|
|
|
100
163
|
case 'application/invision.prototype':
|
|
101
|
-
return
|
|
164
|
+
return {
|
|
165
|
+
icon: IconType.Generic,
|
|
166
|
+
label: 'Prototype'
|
|
167
|
+
};
|
|
102
168
|
|
|
103
169
|
default:
|
|
104
170
|
return undefined;
|
|
@@ -3,32 +3,59 @@ import { IconType } from '../../../constants';
|
|
|
3
3
|
const extractJiraTaskIcon = (taskType, label = 'Task') => {
|
|
4
4
|
switch (taskType) {
|
|
5
5
|
case 'JiraBug':
|
|
6
|
-
return
|
|
6
|
+
return {
|
|
7
|
+
icon: IconType.Bug,
|
|
8
|
+
label
|
|
9
|
+
};
|
|
7
10
|
|
|
8
11
|
case 'JiraChange':
|
|
9
|
-
return
|
|
12
|
+
return {
|
|
13
|
+
icon: IconType.Change,
|
|
14
|
+
label
|
|
15
|
+
};
|
|
10
16
|
|
|
11
17
|
case 'JiraEpic':
|
|
12
|
-
return
|
|
18
|
+
return {
|
|
19
|
+
icon: IconType.Epic,
|
|
20
|
+
label
|
|
21
|
+
};
|
|
13
22
|
|
|
14
23
|
case 'JiraIncident':
|
|
15
|
-
return
|
|
24
|
+
return {
|
|
25
|
+
icon: IconType.Incident,
|
|
26
|
+
label
|
|
27
|
+
};
|
|
16
28
|
|
|
17
29
|
case 'JiraProblem':
|
|
18
|
-
return
|
|
30
|
+
return {
|
|
31
|
+
icon: IconType.Problem,
|
|
32
|
+
label
|
|
33
|
+
};
|
|
19
34
|
|
|
20
35
|
case 'JiraServiceRequest':
|
|
21
|
-
return
|
|
36
|
+
return {
|
|
37
|
+
icon: IconType.ServiceRequest,
|
|
38
|
+
label
|
|
39
|
+
};
|
|
22
40
|
|
|
23
41
|
case 'JiraStory':
|
|
24
|
-
return
|
|
42
|
+
return {
|
|
43
|
+
icon: IconType.Story,
|
|
44
|
+
label
|
|
45
|
+
};
|
|
25
46
|
|
|
26
47
|
case 'JiraSubTask':
|
|
27
|
-
return
|
|
48
|
+
return {
|
|
49
|
+
icon: IconType.SubTask,
|
|
50
|
+
label
|
|
51
|
+
};
|
|
28
52
|
|
|
29
53
|
case 'JiraTask':
|
|
30
54
|
default:
|
|
31
|
-
return
|
|
55
|
+
return {
|
|
56
|
+
icon: IconType.Task,
|
|
57
|
+
label
|
|
58
|
+
};
|
|
32
59
|
}
|
|
33
60
|
};
|
|
34
61
|
|