@atlaskit/smart-card 19.0.2 → 19.1.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 +23 -0
- package/dist/cjs/messages.js +16 -6
- package/dist/cjs/version.json +1 -1
- package/dist/cjs/view/CardWithUrl/component.js +2 -1
- package/dist/cjs/view/FlexibleCard/components/common/atlaskit-icon/index.js +13 -2
- package/dist/cjs/view/FlexibleCard/components/elements/date-time/index.js +32 -10
- package/dist/cjs/view/FlexibleCard/index.js +16 -2
- package/dist/cjs/view/HoverCard/index.js +10 -3
- package/dist/es2019/messages.js +16 -6
- package/dist/es2019/version.json +1 -1
- package/dist/es2019/view/CardWithUrl/component.js +2 -1
- package/dist/es2019/view/FlexibleCard/components/common/atlaskit-icon/index.js +13 -2
- package/dist/es2019/view/FlexibleCard/components/elements/date-time/index.js +33 -11
- package/dist/es2019/view/FlexibleCard/index.js +10 -2
- package/dist/es2019/view/HoverCard/index.js +12 -3
- package/dist/esm/messages.js +16 -6
- package/dist/esm/version.json +1 -1
- package/dist/esm/view/CardWithUrl/component.js +2 -1
- package/dist/esm/view/FlexibleCard/components/common/atlaskit-icon/index.js +13 -2
- package/dist/esm/view/FlexibleCard/components/elements/date-time/index.js +32 -10
- package/dist/esm/view/FlexibleCard/index.js +10 -2
- package/dist/esm/view/HoverCard/index.js +10 -3
- package/dist/types/messages.d.ts +1 -1
- package/dist/types/view/FlexibleCard/types.d.ts +5 -0
- package/package.json +5 -6
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
# @atlaskit/smart-card
|
|
2
2
|
|
|
3
|
+
## 19.1.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- [`6b7ba46a96b`](https://bitbucket.org/atlassian/atlassian-frontend/commits/6b7ba46a96b) - [MEX-1456] Remove unused infinite scroll from Media-UI and Remove lodash from Media package
|
|
8
|
+
|
|
9
|
+
### Patch Changes
|
|
10
|
+
|
|
11
|
+
- [`7c926026ca3`](https://bitbucket.org/atlassian/atlassian-frontend/commits/7c926026ca3) - Adds testId to FlexibleCard test.
|
|
12
|
+
- Updated dependencies
|
|
13
|
+
|
|
14
|
+
## 19.0.4
|
|
15
|
+
|
|
16
|
+
### Patch Changes
|
|
17
|
+
|
|
18
|
+
- [`3eea7c153d6`](https://bitbucket.org/atlassian/atlassian-frontend/commits/3eea7c153d6) - Handle onResolve prop from smart-card in flexible-card and use the prop inside hover-card to dynamically update popup positioning
|
|
19
|
+
|
|
20
|
+
## 19.0.3
|
|
21
|
+
|
|
22
|
+
### Patch Changes
|
|
23
|
+
|
|
24
|
+
- [`cae40e59c49`](https://bitbucket.org/atlassian/atlassian-frontend/commits/cae40e59c49) - Show relative date for dates less then 7 days away (flexible ui)
|
|
25
|
+
|
|
3
26
|
## 19.0.2
|
|
4
27
|
|
|
5
28
|
### Patch Changes
|
package/dist/cjs/messages.js
CHANGED
|
@@ -33,10 +33,15 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
33
33
|
defaultMessage: 'Created by {context}',
|
|
34
34
|
description: 'Indicates the person or entity that created the resource.'
|
|
35
35
|
},
|
|
36
|
-
|
|
37
|
-
id: 'fabric.linking.
|
|
36
|
+
created_on_relative: {
|
|
37
|
+
id: 'fabric.linking.create_on_relative',
|
|
38
38
|
defaultMessage: 'Created {context}',
|
|
39
|
-
description: 'Indicated when entity was created'
|
|
39
|
+
description: 'Indicated when entity was created (relative form)'
|
|
40
|
+
},
|
|
41
|
+
created_on_absolute: {
|
|
42
|
+
id: 'fabric.linking.create_on_absolute',
|
|
43
|
+
defaultMessage: 'Created on {context}',
|
|
44
|
+
description: 'Indicated when entity was created (absolute form)'
|
|
40
45
|
},
|
|
41
46
|
delete: {
|
|
42
47
|
id: 'fabric.linking.delete',
|
|
@@ -53,10 +58,15 @@ var messages = (0, _reactIntlNext.defineMessages)({
|
|
|
53
58
|
defaultMessage: 'Modified by {context}',
|
|
54
59
|
description: 'Indicates the person or entity that modified the resource.'
|
|
55
60
|
},
|
|
56
|
-
|
|
57
|
-
id: 'fabric.linking.
|
|
61
|
+
modified_on_relative: {
|
|
62
|
+
id: 'fabric.linking.modified_on_relative',
|
|
58
63
|
defaultMessage: 'Updated {context}',
|
|
59
|
-
description: 'Indicated when entity was modified'
|
|
64
|
+
description: 'Indicated when entity was modified (relative form)'
|
|
65
|
+
},
|
|
66
|
+
modified_on_absolute: {
|
|
67
|
+
id: 'fabric.linking.modified_on_absolute',
|
|
68
|
+
defaultMessage: 'Updated on {context}',
|
|
69
|
+
description: 'Indicated when entity was modified (absolute form)'
|
|
60
70
|
},
|
|
61
71
|
priority_blocker: {
|
|
62
72
|
id: 'fabric.linking.priority_blocker',
|
package/dist/cjs/version.json
CHANGED
|
@@ -136,7 +136,8 @@ function CardWithUrlContent(_ref) {
|
|
|
136
136
|
renderers: renderers,
|
|
137
137
|
ui: ui,
|
|
138
138
|
url: url,
|
|
139
|
-
testId: testId
|
|
139
|
+
testId: testId,
|
|
140
|
+
onResolve: onResolve
|
|
140
141
|
}, children);
|
|
141
142
|
} // We have to keep this last to prevent hook order from being violated
|
|
142
143
|
|
|
@@ -311,11 +311,22 @@ var AtlaskitIcon = function AtlaskitIcon(_ref3) {
|
|
|
311
311
|
|
|
312
312
|
switch (icon) {
|
|
313
313
|
case _constants.IconType.Confluence:
|
|
314
|
+
return /*#__PURE__*/_react.default.createElement(ImportedIcon, {
|
|
315
|
+
testId: testId,
|
|
316
|
+
textColor: (0, _tokens.token)('color.text.subtle', _colors.N700)
|
|
317
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
318
|
+
,
|
|
319
|
+
iconColor: _colors.B200,
|
|
320
|
+
iconGradientStart: _colors.B400,
|
|
321
|
+
iconGradientStop: _colors.B200
|
|
322
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
323
|
+
|
|
324
|
+
});
|
|
325
|
+
|
|
314
326
|
case _constants.IconType.Jira:
|
|
315
327
|
// Logo component has a different prop set from other icon components
|
|
316
328
|
return /*#__PURE__*/_react.default.createElement(ImportedIcon, {
|
|
317
|
-
|
|
318
|
-
,
|
|
329
|
+
testId: testId,
|
|
319
330
|
textColor: (0, _tokens.token)('color.text.subtle', _colors.N700)
|
|
320
331
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
321
332
|
,
|
|
@@ -29,8 +29,14 @@ var _templateObject;
|
|
|
29
29
|
|
|
30
30
|
var styles = (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)(1));
|
|
31
31
|
var typeToDescriptorMap = {
|
|
32
|
-
created:
|
|
33
|
-
|
|
32
|
+
created: {
|
|
33
|
+
relative: _messages.messages.created_on_relative,
|
|
34
|
+
absolute: _messages.messages.created_on_absolute
|
|
35
|
+
},
|
|
36
|
+
modified: {
|
|
37
|
+
relative: _messages.messages.modified_on_relative,
|
|
38
|
+
absolute: _messages.messages.modified_on_absolute
|
|
39
|
+
}
|
|
34
40
|
};
|
|
35
41
|
/**
|
|
36
42
|
* A base element that displays an ISO Timestamp in text.
|
|
@@ -48,25 +54,41 @@ var DateTime = function DateTime(_ref) {
|
|
|
48
54
|
testId = _ref$testId === void 0 ? 'smart-element-date-time' : _ref$testId;
|
|
49
55
|
|
|
50
56
|
var _useIntl = (0, _reactIntlNext.useIntl)(),
|
|
51
|
-
formatRelativeTime = _useIntl.formatRelativeTime
|
|
57
|
+
formatRelativeTime = _useIntl.formatRelativeTime,
|
|
58
|
+
formatDate = _useIntl.formatDate;
|
|
52
59
|
|
|
53
60
|
if (!type || !date) {
|
|
54
61
|
return null;
|
|
55
62
|
}
|
|
56
63
|
|
|
57
|
-
var
|
|
58
|
-
|
|
59
|
-
|
|
64
|
+
var isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
|
|
65
|
+
var context;
|
|
66
|
+
var typeVariant;
|
|
67
|
+
|
|
68
|
+
if (isLongerThenWeek) {
|
|
69
|
+
typeVariant = 'absolute';
|
|
70
|
+
context = formatDate(date, {
|
|
71
|
+
month: 'long',
|
|
72
|
+
day: 'numeric',
|
|
73
|
+
year: 'numeric'
|
|
74
|
+
});
|
|
75
|
+
} else {
|
|
76
|
+
var _selectUnit = (0, _intlUtils.selectUnit)(date, Date.now()),
|
|
77
|
+
value = _selectUnit.value,
|
|
78
|
+
unit = _selectUnit.unit;
|
|
79
|
+
|
|
80
|
+
typeVariant = 'relative';
|
|
81
|
+
context = formatRelativeTime(value, unit, {
|
|
82
|
+
numeric: 'auto'
|
|
83
|
+
});
|
|
84
|
+
}
|
|
60
85
|
|
|
61
|
-
var context = formatRelativeTime(value, unit, {
|
|
62
|
-
numeric: 'auto'
|
|
63
|
-
});
|
|
64
86
|
return (0, _core.jsx)("span", {
|
|
65
87
|
css: [styles, overrideCss],
|
|
66
88
|
"data-separator": true,
|
|
67
89
|
"data-smart-element-date-time": true,
|
|
68
90
|
"data-testid": testId
|
|
69
|
-
}, (0, _core.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, typeToDescriptorMap[type], {
|
|
91
|
+
}, (0, _core.jsx)(_reactIntlNext.FormattedMessage, (0, _extends2.default)({}, typeToDescriptorMap[type][typeVariant], {
|
|
70
92
|
values: {
|
|
71
93
|
context: context
|
|
72
94
|
}
|
|
@@ -2,6 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
4
|
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
5
7
|
Object.defineProperty(exports, "__esModule", {
|
|
6
8
|
value: true
|
|
7
9
|
});
|
|
@@ -9,7 +11,7 @@ exports.default = void 0;
|
|
|
9
11
|
|
|
10
12
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
13
|
|
|
12
|
-
var _react =
|
|
14
|
+
var _react = _interopRequireWildcard(require("react"));
|
|
13
15
|
|
|
14
16
|
var _container = _interopRequireDefault(require("./components/container"));
|
|
15
17
|
|
|
@@ -17,6 +19,10 @@ var _flexibleUiContext = require("../../state/flexible-ui-context");
|
|
|
17
19
|
|
|
18
20
|
var _utils = require("./utils");
|
|
19
21
|
|
|
22
|
+
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); }
|
|
23
|
+
|
|
24
|
+
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; }
|
|
25
|
+
|
|
20
26
|
/**
|
|
21
27
|
* This represents a Flexible Card: a link represented by a card with metadata.
|
|
22
28
|
* This is the container in which all Flexible UI Blocks and Elements exist.
|
|
@@ -31,12 +37,20 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
31
37
|
ui = _ref.ui,
|
|
32
38
|
url = _ref.url,
|
|
33
39
|
onClick = _ref.onClick,
|
|
34
|
-
testId = _ref.testId
|
|
40
|
+
testId = _ref.testId,
|
|
41
|
+
onResolve = _ref.onResolve;
|
|
35
42
|
var cardType = cardState.status,
|
|
36
43
|
details = cardState.details;
|
|
37
44
|
var status = cardType;
|
|
38
45
|
var context = (0, _utils.getContextByStatus)(url, status, details, renderers);
|
|
39
46
|
var retry = (0, _utils.getRetryOptions)(url, status, details, onAuthorize);
|
|
47
|
+
(0, _react.useEffect)(function () {
|
|
48
|
+
if (status === 'resolved' && onResolve) {
|
|
49
|
+
onResolve({
|
|
50
|
+
url: url
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}, [onResolve, status, url]);
|
|
40
54
|
return /*#__PURE__*/_react.default.createElement(_flexibleUiContext.FlexibleUiContext.Provider, {
|
|
41
55
|
value: context
|
|
42
56
|
}, /*#__PURE__*/_react.default.createElement(_container.default, (0, _extends2.default)({
|
|
@@ -138,7 +138,8 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
138
138
|
};
|
|
139
139
|
}, [url, definitionId, extensionKey, analytics]);
|
|
140
140
|
|
|
141
|
-
var CardComponent = function CardComponent() {
|
|
141
|
+
var CardComponent = function CardComponent(_ref2) {
|
|
142
|
+
var update = _ref2.update;
|
|
142
143
|
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
143
144
|
var metadataElements = (0, _extractMetadata.extractMetadata)((0, _utils.getSimulatedMetadata)(extensionKey));
|
|
144
145
|
return (0, _core.jsx)("div", {
|
|
@@ -151,7 +152,8 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
151
152
|
ui: {
|
|
152
153
|
hideElevation: true,
|
|
153
154
|
size: _constants.SmartLinkSize.Large
|
|
154
|
-
}
|
|
155
|
+
},
|
|
156
|
+
onResolve: update
|
|
155
157
|
}, (0, _core.jsx)(_blocks.TitleBlock, {
|
|
156
158
|
actions: [openAction]
|
|
157
159
|
}), (0, _core.jsx)(_blocks.MetadataBlock, {
|
|
@@ -170,7 +172,12 @@ var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
170
172
|
isOpen: isOpen,
|
|
171
173
|
onClose: onClose,
|
|
172
174
|
placement: "bottom-start",
|
|
173
|
-
content:
|
|
175
|
+
content: function content(_ref3) {
|
|
176
|
+
var update = _ref3.update;
|
|
177
|
+
return (0, _core.jsx)(CardComponent, {
|
|
178
|
+
update: update
|
|
179
|
+
});
|
|
180
|
+
},
|
|
174
181
|
trigger: function trigger(triggerProps) {
|
|
175
182
|
return (0, _core.jsx)("span", (0, _extends2.default)({}, triggerProps, {
|
|
176
183
|
onMouseEnter: initShowCard,
|
package/dist/es2019/messages.js
CHANGED
|
@@ -25,10 +25,15 @@ export const messages = defineMessages({
|
|
|
25
25
|
defaultMessage: 'Created by {context}',
|
|
26
26
|
description: 'Indicates the person or entity that created the resource.'
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
id: 'fabric.linking.
|
|
28
|
+
created_on_relative: {
|
|
29
|
+
id: 'fabric.linking.create_on_relative',
|
|
30
30
|
defaultMessage: 'Created {context}',
|
|
31
|
-
description: 'Indicated when entity was created'
|
|
31
|
+
description: 'Indicated when entity was created (relative form)'
|
|
32
|
+
},
|
|
33
|
+
created_on_absolute: {
|
|
34
|
+
id: 'fabric.linking.create_on_absolute',
|
|
35
|
+
defaultMessage: 'Created on {context}',
|
|
36
|
+
description: 'Indicated when entity was created (absolute form)'
|
|
32
37
|
},
|
|
33
38
|
delete: {
|
|
34
39
|
id: 'fabric.linking.delete',
|
|
@@ -45,10 +50,15 @@ export const messages = defineMessages({
|
|
|
45
50
|
defaultMessage: 'Modified by {context}',
|
|
46
51
|
description: 'Indicates the person or entity that modified the resource.'
|
|
47
52
|
},
|
|
48
|
-
|
|
49
|
-
id: 'fabric.linking.
|
|
53
|
+
modified_on_relative: {
|
|
54
|
+
id: 'fabric.linking.modified_on_relative',
|
|
50
55
|
defaultMessage: 'Updated {context}',
|
|
51
|
-
description: 'Indicated when entity was modified'
|
|
56
|
+
description: 'Indicated when entity was modified (relative form)'
|
|
57
|
+
},
|
|
58
|
+
modified_on_absolute: {
|
|
59
|
+
id: 'fabric.linking.modified_on_absolute',
|
|
60
|
+
defaultMessage: 'Updated on {context}',
|
|
61
|
+
description: 'Indicated when entity was modified (absolute form)'
|
|
52
62
|
},
|
|
53
63
|
priority_blocker: {
|
|
54
64
|
id: 'fabric.linking.priority_blocker',
|
package/dist/es2019/version.json
CHANGED
|
@@ -104,7 +104,8 @@ export function CardWithUrlContent({
|
|
|
104
104
|
renderers: renderers,
|
|
105
105
|
ui: ui,
|
|
106
106
|
url: url,
|
|
107
|
-
testId: testId
|
|
107
|
+
testId: testId,
|
|
108
|
+
onResolve: onResolve
|
|
108
109
|
}, children);
|
|
109
110
|
} // We have to keep this last to prevent hook order from being violated
|
|
110
111
|
|
|
@@ -224,11 +224,22 @@ const AtlaskitIcon = ({
|
|
|
224
224
|
|
|
225
225
|
switch (icon) {
|
|
226
226
|
case IconType.Confluence:
|
|
227
|
+
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
228
|
+
testId: testId,
|
|
229
|
+
textColor: token('color.text.subtle', N700)
|
|
230
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
231
|
+
,
|
|
232
|
+
iconColor: B200,
|
|
233
|
+
iconGradientStart: B400,
|
|
234
|
+
iconGradientStop: B200
|
|
235
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
236
|
+
|
|
237
|
+
});
|
|
238
|
+
|
|
227
239
|
case IconType.Jira:
|
|
228
240
|
// Logo component has a different prop set from other icon components
|
|
229
241
|
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
230
|
-
|
|
231
|
-
,
|
|
242
|
+
testId: testId,
|
|
232
243
|
textColor: token('color.text.subtle', N700)
|
|
233
244
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
234
245
|
,
|
|
@@ -15,8 +15,14 @@ const styles = css`
|
|
|
15
15
|
${getTruncateStyles(1)}
|
|
16
16
|
`;
|
|
17
17
|
const typeToDescriptorMap = {
|
|
18
|
-
created:
|
|
19
|
-
|
|
18
|
+
created: {
|
|
19
|
+
relative: messages.created_on_relative,
|
|
20
|
+
absolute: messages.created_on_absolute
|
|
21
|
+
},
|
|
22
|
+
modified: {
|
|
23
|
+
relative: messages.modified_on_relative,
|
|
24
|
+
absolute: messages.modified_on_absolute
|
|
25
|
+
}
|
|
20
26
|
};
|
|
21
27
|
/**
|
|
22
28
|
* A base element that displays an ISO Timestamp in text.
|
|
@@ -33,26 +39,42 @@ const DateTime = ({
|
|
|
33
39
|
testId = 'smart-element-date-time'
|
|
34
40
|
}) => {
|
|
35
41
|
const {
|
|
36
|
-
formatRelativeTime
|
|
42
|
+
formatRelativeTime,
|
|
43
|
+
formatDate
|
|
37
44
|
} = useIntl();
|
|
38
45
|
|
|
39
46
|
if (!type || !date) {
|
|
40
47
|
return null;
|
|
41
48
|
}
|
|
42
49
|
|
|
43
|
-
const
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
+
const isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
|
|
51
|
+
let context;
|
|
52
|
+
let typeVariant;
|
|
53
|
+
|
|
54
|
+
if (isLongerThenWeek) {
|
|
55
|
+
typeVariant = 'absolute';
|
|
56
|
+
context = formatDate(date, {
|
|
57
|
+
month: 'long',
|
|
58
|
+
day: 'numeric',
|
|
59
|
+
year: 'numeric'
|
|
60
|
+
});
|
|
61
|
+
} else {
|
|
62
|
+
const {
|
|
63
|
+
value,
|
|
64
|
+
unit
|
|
65
|
+
} = selectUnit(date, Date.now());
|
|
66
|
+
typeVariant = 'relative';
|
|
67
|
+
context = formatRelativeTime(value, unit, {
|
|
68
|
+
numeric: 'auto'
|
|
69
|
+
});
|
|
70
|
+
}
|
|
71
|
+
|
|
50
72
|
return jsx("span", {
|
|
51
73
|
css: [styles, overrideCss],
|
|
52
74
|
"data-separator": true,
|
|
53
75
|
"data-smart-element-date-time": true,
|
|
54
76
|
"data-testid": testId
|
|
55
|
-
}, jsx(FormattedMessage, _extends({}, typeToDescriptorMap[type], {
|
|
77
|
+
}, jsx(FormattedMessage, _extends({}, typeToDescriptorMap[type][typeVariant], {
|
|
56
78
|
values: {
|
|
57
79
|
context
|
|
58
80
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
3
|
import Container from './components/container';
|
|
4
4
|
import { FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
5
5
|
import { getContextByStatus, getRetryOptions } from './utils';
|
|
@@ -18,7 +18,8 @@ const FlexibleCard = ({
|
|
|
18
18
|
ui,
|
|
19
19
|
url,
|
|
20
20
|
onClick,
|
|
21
|
-
testId
|
|
21
|
+
testId,
|
|
22
|
+
onResolve
|
|
22
23
|
}) => {
|
|
23
24
|
const {
|
|
24
25
|
status: cardType,
|
|
@@ -27,6 +28,13 @@ const FlexibleCard = ({
|
|
|
27
28
|
const status = cardType;
|
|
28
29
|
const context = getContextByStatus(url, status, details, renderers);
|
|
29
30
|
const retry = getRetryOptions(url, status, details, onAuthorize);
|
|
31
|
+
useEffect(() => {
|
|
32
|
+
if (status === 'resolved' && onResolve) {
|
|
33
|
+
onResolve({
|
|
34
|
+
url
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
}, [onResolve, status, url]);
|
|
30
38
|
return /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
31
39
|
value: context
|
|
32
40
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
@@ -91,7 +91,9 @@ export const HoverCardComponent = ({
|
|
|
91
91
|
};
|
|
92
92
|
}, [url, definitionId, extensionKey, analytics]);
|
|
93
93
|
|
|
94
|
-
const CardComponent = (
|
|
94
|
+
const CardComponent = ({
|
|
95
|
+
update
|
|
96
|
+
}) => {
|
|
95
97
|
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
96
98
|
const metadataElements = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
97
99
|
return jsx("div", {
|
|
@@ -104,7 +106,8 @@ export const HoverCardComponent = ({
|
|
|
104
106
|
ui: {
|
|
105
107
|
hideElevation: true,
|
|
106
108
|
size: SmartLinkSize.Large
|
|
107
|
-
}
|
|
109
|
+
},
|
|
110
|
+
onResolve: update
|
|
108
111
|
}, jsx(TitleBlock, {
|
|
109
112
|
actions: [openAction]
|
|
110
113
|
}), jsx(MetadataBlock, {
|
|
@@ -121,7 +124,13 @@ export const HoverCardComponent = ({
|
|
|
121
124
|
isOpen: isOpen,
|
|
122
125
|
onClose: onClose,
|
|
123
126
|
placement: "bottom-start",
|
|
124
|
-
content:
|
|
127
|
+
content: ({
|
|
128
|
+
update
|
|
129
|
+
}) => {
|
|
130
|
+
return jsx(CardComponent, {
|
|
131
|
+
update: update
|
|
132
|
+
});
|
|
133
|
+
},
|
|
125
134
|
trigger: triggerProps => jsx("span", _extends({}, triggerProps, {
|
|
126
135
|
onMouseEnter: initShowCard,
|
|
127
136
|
onMouseLeave: initHideCard
|
package/dist/esm/messages.js
CHANGED
|
@@ -25,10 +25,15 @@ export var messages = defineMessages({
|
|
|
25
25
|
defaultMessage: 'Created by {context}',
|
|
26
26
|
description: 'Indicates the person or entity that created the resource.'
|
|
27
27
|
},
|
|
28
|
-
|
|
29
|
-
id: 'fabric.linking.
|
|
28
|
+
created_on_relative: {
|
|
29
|
+
id: 'fabric.linking.create_on_relative',
|
|
30
30
|
defaultMessage: 'Created {context}',
|
|
31
|
-
description: 'Indicated when entity was created'
|
|
31
|
+
description: 'Indicated when entity was created (relative form)'
|
|
32
|
+
},
|
|
33
|
+
created_on_absolute: {
|
|
34
|
+
id: 'fabric.linking.create_on_absolute',
|
|
35
|
+
defaultMessage: 'Created on {context}',
|
|
36
|
+
description: 'Indicated when entity was created (absolute form)'
|
|
32
37
|
},
|
|
33
38
|
delete: {
|
|
34
39
|
id: 'fabric.linking.delete',
|
|
@@ -45,10 +50,15 @@ export var messages = defineMessages({
|
|
|
45
50
|
defaultMessage: 'Modified by {context}',
|
|
46
51
|
description: 'Indicates the person or entity that modified the resource.'
|
|
47
52
|
},
|
|
48
|
-
|
|
49
|
-
id: 'fabric.linking.
|
|
53
|
+
modified_on_relative: {
|
|
54
|
+
id: 'fabric.linking.modified_on_relative',
|
|
50
55
|
defaultMessage: 'Updated {context}',
|
|
51
|
-
description: 'Indicated when entity was modified'
|
|
56
|
+
description: 'Indicated when entity was modified (relative form)'
|
|
57
|
+
},
|
|
58
|
+
modified_on_absolute: {
|
|
59
|
+
id: 'fabric.linking.modified_on_absolute',
|
|
60
|
+
defaultMessage: 'Updated on {context}',
|
|
61
|
+
description: 'Indicated when entity was modified (absolute form)'
|
|
52
62
|
},
|
|
53
63
|
priority_blocker: {
|
|
54
64
|
id: 'fabric.linking.priority_blocker',
|
package/dist/esm/version.json
CHANGED
|
@@ -110,7 +110,8 @@ export function CardWithUrlContent(_ref) {
|
|
|
110
110
|
renderers: renderers,
|
|
111
111
|
ui: ui,
|
|
112
112
|
url: url,
|
|
113
|
-
testId: testId
|
|
113
|
+
testId: testId,
|
|
114
|
+
onResolve: onResolve
|
|
114
115
|
}, children);
|
|
115
116
|
} // We have to keep this last to prevent hook order from being violated
|
|
116
117
|
|
|
@@ -291,11 +291,22 @@ var AtlaskitIcon = function AtlaskitIcon(_ref3) {
|
|
|
291
291
|
|
|
292
292
|
switch (icon) {
|
|
293
293
|
case IconType.Confluence:
|
|
294
|
+
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
295
|
+
testId: testId,
|
|
296
|
+
textColor: token('color.text.subtle', N700)
|
|
297
|
+
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
298
|
+
,
|
|
299
|
+
iconColor: B200,
|
|
300
|
+
iconGradientStart: B400,
|
|
301
|
+
iconGradientStop: B200
|
|
302
|
+
/* eslint-enable @atlaskit/design-system/ensure-design-token-usage */
|
|
303
|
+
|
|
304
|
+
});
|
|
305
|
+
|
|
294
306
|
case IconType.Jira:
|
|
295
307
|
// Logo component has a different prop set from other icon components
|
|
296
308
|
return /*#__PURE__*/React.createElement(ImportedIcon, {
|
|
297
|
-
|
|
298
|
-
,
|
|
309
|
+
testId: testId,
|
|
299
310
|
textColor: token('color.text.subtle', N700)
|
|
300
311
|
/* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
|
|
301
312
|
,
|
|
@@ -13,8 +13,14 @@ import { selectUnit } from '@formatjs/intl-utils';
|
|
|
13
13
|
import { messages } from '../../../../../messages';
|
|
14
14
|
var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), tokens.text, getTruncateStyles(1));
|
|
15
15
|
var typeToDescriptorMap = {
|
|
16
|
-
created:
|
|
17
|
-
|
|
16
|
+
created: {
|
|
17
|
+
relative: messages.created_on_relative,
|
|
18
|
+
absolute: messages.created_on_absolute
|
|
19
|
+
},
|
|
20
|
+
modified: {
|
|
21
|
+
relative: messages.modified_on_relative,
|
|
22
|
+
absolute: messages.modified_on_absolute
|
|
23
|
+
}
|
|
18
24
|
};
|
|
19
25
|
/**
|
|
20
26
|
* A base element that displays an ISO Timestamp in text.
|
|
@@ -32,25 +38,41 @@ var DateTime = function DateTime(_ref) {
|
|
|
32
38
|
testId = _ref$testId === void 0 ? 'smart-element-date-time' : _ref$testId;
|
|
33
39
|
|
|
34
40
|
var _useIntl = useIntl(),
|
|
35
|
-
formatRelativeTime = _useIntl.formatRelativeTime
|
|
41
|
+
formatRelativeTime = _useIntl.formatRelativeTime,
|
|
42
|
+
formatDate = _useIntl.formatDate;
|
|
36
43
|
|
|
37
44
|
if (!type || !date) {
|
|
38
45
|
return null;
|
|
39
46
|
}
|
|
40
47
|
|
|
41
|
-
var
|
|
42
|
-
|
|
43
|
-
|
|
48
|
+
var isLongerThenWeek = Math.abs(date.getTime() - Date.now()) > 1000 * 60 * 60 * 24 * 7;
|
|
49
|
+
var context;
|
|
50
|
+
var typeVariant;
|
|
51
|
+
|
|
52
|
+
if (isLongerThenWeek) {
|
|
53
|
+
typeVariant = 'absolute';
|
|
54
|
+
context = formatDate(date, {
|
|
55
|
+
month: 'long',
|
|
56
|
+
day: 'numeric',
|
|
57
|
+
year: 'numeric'
|
|
58
|
+
});
|
|
59
|
+
} else {
|
|
60
|
+
var _selectUnit = selectUnit(date, Date.now()),
|
|
61
|
+
value = _selectUnit.value,
|
|
62
|
+
unit = _selectUnit.unit;
|
|
63
|
+
|
|
64
|
+
typeVariant = 'relative';
|
|
65
|
+
context = formatRelativeTime(value, unit, {
|
|
66
|
+
numeric: 'auto'
|
|
67
|
+
});
|
|
68
|
+
}
|
|
44
69
|
|
|
45
|
-
var context = formatRelativeTime(value, unit, {
|
|
46
|
-
numeric: 'auto'
|
|
47
|
-
});
|
|
48
70
|
return jsx("span", {
|
|
49
71
|
css: [styles, overrideCss],
|
|
50
72
|
"data-separator": true,
|
|
51
73
|
"data-smart-element-date-time": true,
|
|
52
74
|
"data-testid": testId
|
|
53
|
-
}, jsx(FormattedMessage, _extends({}, typeToDescriptorMap[type], {
|
|
75
|
+
}, jsx(FormattedMessage, _extends({}, typeToDescriptorMap[type][typeVariant], {
|
|
54
76
|
values: {
|
|
55
77
|
context: context
|
|
56
78
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
-
import React from 'react';
|
|
2
|
+
import React, { useEffect } from 'react';
|
|
3
3
|
import Container from './components/container';
|
|
4
4
|
import { FlexibleUiContext } from '../../state/flexible-ui-context';
|
|
5
5
|
import { getContextByStatus, getRetryOptions } from './utils';
|
|
@@ -18,12 +18,20 @@ var FlexibleCard = function FlexibleCard(_ref) {
|
|
|
18
18
|
ui = _ref.ui,
|
|
19
19
|
url = _ref.url,
|
|
20
20
|
onClick = _ref.onClick,
|
|
21
|
-
testId = _ref.testId
|
|
21
|
+
testId = _ref.testId,
|
|
22
|
+
onResolve = _ref.onResolve;
|
|
22
23
|
var cardType = cardState.status,
|
|
23
24
|
details = cardState.details;
|
|
24
25
|
var status = cardType;
|
|
25
26
|
var context = getContextByStatus(url, status, details, renderers);
|
|
26
27
|
var retry = getRetryOptions(url, status, details, onAuthorize);
|
|
28
|
+
useEffect(function () {
|
|
29
|
+
if (status === 'resolved' && onResolve) {
|
|
30
|
+
onResolve({
|
|
31
|
+
url: url
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
}, [onResolve, status, url]);
|
|
27
35
|
return /*#__PURE__*/React.createElement(FlexibleUiContext.Provider, {
|
|
28
36
|
value: context
|
|
29
37
|
}, /*#__PURE__*/React.createElement(Container, _extends({
|
|
@@ -106,7 +106,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
106
106
|
};
|
|
107
107
|
}, [url, definitionId, extensionKey, analytics]);
|
|
108
108
|
|
|
109
|
-
var CardComponent = function CardComponent() {
|
|
109
|
+
var CardComponent = function CardComponent(_ref2) {
|
|
110
|
+
var update = _ref2.update;
|
|
110
111
|
//TODO: EDM-3224 deleted simulated and use real JsonLd
|
|
111
112
|
var metadataElements = extractMetadata(getSimulatedMetadata(extensionKey));
|
|
112
113
|
return jsx("div", {
|
|
@@ -119,7 +120,8 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
119
120
|
ui: {
|
|
120
121
|
hideElevation: true,
|
|
121
122
|
size: SmartLinkSize.Large
|
|
122
|
-
}
|
|
123
|
+
},
|
|
124
|
+
onResolve: update
|
|
123
125
|
}, jsx(TitleBlock, {
|
|
124
126
|
actions: [openAction]
|
|
125
127
|
}), jsx(MetadataBlock, {
|
|
@@ -138,7 +140,12 @@ export var HoverCardComponent = function HoverCardComponent(_ref) {
|
|
|
138
140
|
isOpen: isOpen,
|
|
139
141
|
onClose: onClose,
|
|
140
142
|
placement: "bottom-start",
|
|
141
|
-
content:
|
|
143
|
+
content: function content(_ref3) {
|
|
144
|
+
var update = _ref3.update;
|
|
145
|
+
return jsx(CardComponent, {
|
|
146
|
+
update: update
|
|
147
|
+
});
|
|
148
|
+
},
|
|
142
149
|
trigger: function trigger(triggerProps) {
|
|
143
150
|
return jsx("span", _extends({}, triggerProps, {
|
|
144
151
|
onMouseEnter: initShowCard,
|
package/dist/types/messages.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MessageDescriptor } from 'react-intl-next';
|
|
2
|
-
export declare type MessageKey = 'cannot_find_link' | 'click_to_join' | 'connect_link_account' | 'created_by' | '
|
|
2
|
+
export declare type MessageKey = 'cannot_find_link' | 'click_to_join' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'delete' | 'edit' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'priority_blocker' | 'priority_critical' | 'priority_high' | 'priority_highest' | 'priority_low' | 'priority_lowest' | 'priority_major' | 'priority_medium' | 'priority_minor' | 'priority_trivial' | 'priority_undefined' | 'forbidden_access' | 'pending_request' | 'restricted_link' | 'request_access' | 'request_denied';
|
|
3
3
|
declare type Messages = {
|
|
4
4
|
[K in MessageKey]: MessageDescriptor;
|
|
5
5
|
};
|
|
@@ -4,6 +4,7 @@ import { CardState } from '@atlaskit/linking-common';
|
|
|
4
4
|
import { CardProviderRenderers } from '@atlaskit/link-provider';
|
|
5
5
|
import { SmartLinkSize, SmartLinkTheme } from '../../constants';
|
|
6
6
|
import { CardAppearance } from '../../view/Card';
|
|
7
|
+
import { OnResolveCallback } from '../Card/types';
|
|
7
8
|
export declare type FlexibleCardProps = {
|
|
8
9
|
/**
|
|
9
10
|
* Determines the appearance of the Smart Link.
|
|
@@ -51,6 +52,10 @@ export declare type FlexibleCardProps = {
|
|
|
51
52
|
* Determines the URL of the Smart Link.
|
|
52
53
|
*/
|
|
53
54
|
url: string;
|
|
55
|
+
/**
|
|
56
|
+
* function to be called after a flexible card has rendered its resolved state
|
|
57
|
+
*/
|
|
58
|
+
onResolve?: OnResolveCallback;
|
|
54
59
|
};
|
|
55
60
|
export declare type FlexibleUiOptions = {
|
|
56
61
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/smart-card",
|
|
3
|
-
"version": "19.0
|
|
3
|
+
"version": "19.1.0",
|
|
4
4
|
"description": "Smart card component",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"registry": "https://registry.npmjs.org/"
|
|
@@ -34,10 +34,10 @@
|
|
|
34
34
|
"@atlaskit/icon-priority": "^6.3.0",
|
|
35
35
|
"@atlaskit/in-product-testing": "^0.1.0",
|
|
36
36
|
"@atlaskit/linking-common": "^1.1.0",
|
|
37
|
-
"@atlaskit/logo": "^13.
|
|
37
|
+
"@atlaskit/logo": "^13.6.0",
|
|
38
38
|
"@atlaskit/lozenge": "^11.1.0",
|
|
39
|
-
"@atlaskit/media-common": "^2.
|
|
40
|
-
"@atlaskit/media-ui": "^
|
|
39
|
+
"@atlaskit/media-common": "^2.13.0",
|
|
40
|
+
"@atlaskit/media-ui": "^22.0.0",
|
|
41
41
|
"@atlaskit/modal-dialog": "^12.2.0",
|
|
42
42
|
"@atlaskit/outbound-auth-flow-client": "^3.3.0",
|
|
43
43
|
"@atlaskit/popup": "^1.3.0",
|
|
@@ -74,7 +74,7 @@
|
|
|
74
74
|
"@atlaskit/inline-message": "^11.2.0",
|
|
75
75
|
"@atlaskit/lozenge": "^11.1.0",
|
|
76
76
|
"@atlaskit/media-integration-test-helpers": "^2.6.0",
|
|
77
|
-
"@atlaskit/media-test-helpers": "^
|
|
77
|
+
"@atlaskit/media-test-helpers": "^30.0.0",
|
|
78
78
|
"@atlaskit/page": "^12.1.0",
|
|
79
79
|
"@atlaskit/radio": "^5.3.0",
|
|
80
80
|
"@atlaskit/range": "^6.0.0",
|
|
@@ -90,7 +90,6 @@
|
|
|
90
90
|
"@testing-library/react-hooks": "^1.0.4",
|
|
91
91
|
"@testing-library/user-event": "10.4.0",
|
|
92
92
|
"@types/enzyme": "^3.1.15",
|
|
93
|
-
"@types/lodash": "^4.14.157",
|
|
94
93
|
"@types/lorem-ipsum": "^1.0.2",
|
|
95
94
|
"@types/react": "^16.8.0",
|
|
96
95
|
"@types/react-loadable": "^5.4.1",
|