@atlaskit/smart-card 25.5.7 → 25.6.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.
Files changed (55) hide show
  1. package/CHANGELOG.md +16 -0
  2. package/dist/cjs/constants.js +1 -0
  3. package/dist/cjs/extractors/flexible/index.js +1 -0
  4. package/dist/cjs/extractors/flexible/utils.js +8 -1
  5. package/dist/cjs/messages.js +5 -0
  6. package/dist/cjs/ssr.js +9 -6
  7. package/dist/cjs/state/hooks/useSmartLink.js +6 -1
  8. package/dist/cjs/version.json +1 -1
  9. package/dist/cjs/view/BlockCard/views/flexible/FlexibleResolvedView.js +27 -21
  10. package/dist/cjs/view/FlexibleCard/components/blocks/utils.js +1 -1
  11. package/dist/cjs/view/FlexibleCard/components/elements/index.js +8 -2
  12. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +4 -0
  13. package/dist/cjs/view/HoverCard/components/HoverCardContent.js +1 -3
  14. package/dist/cjs/view/HoverCard/components/views/resolved/index.js +1 -1
  15. package/dist/cjs/view/HoverCard/utils.js +8 -4
  16. package/dist/es2019/constants.js +1 -0
  17. package/dist/es2019/extractors/flexible/index.js +2 -1
  18. package/dist/es2019/extractors/flexible/utils.js +7 -1
  19. package/dist/es2019/messages.js +5 -0
  20. package/dist/es2019/ssr.js +11 -6
  21. package/dist/es2019/state/hooks/useSmartLink.js +6 -1
  22. package/dist/es2019/version.json +1 -1
  23. package/dist/es2019/view/BlockCard/views/flexible/FlexibleResolvedView.js +27 -22
  24. package/dist/es2019/view/FlexibleCard/components/blocks/utils.js +1 -0
  25. package/dist/es2019/view/FlexibleCard/components/elements/index.js +5 -0
  26. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +5 -0
  27. package/dist/es2019/view/HoverCard/components/HoverCardContent.js +1 -3
  28. package/dist/es2019/view/HoverCard/components/views/resolved/index.js +1 -1
  29. package/dist/es2019/view/HoverCard/utils.js +8 -4
  30. package/dist/esm/constants.js +1 -0
  31. package/dist/esm/extractors/flexible/index.js +2 -1
  32. package/dist/esm/extractors/flexible/utils.js +7 -1
  33. package/dist/esm/messages.js +5 -0
  34. package/dist/esm/ssr.js +9 -6
  35. package/dist/esm/state/hooks/useSmartLink.js +6 -1
  36. package/dist/esm/version.json +1 -1
  37. package/dist/esm/view/BlockCard/views/flexible/FlexibleResolvedView.js +27 -22
  38. package/dist/esm/view/FlexibleCard/components/blocks/utils.js +1 -1
  39. package/dist/esm/view/FlexibleCard/components/elements/index.js +5 -0
  40. package/dist/esm/view/FlexibleCard/components/elements/utils.js +4 -0
  41. package/dist/esm/view/HoverCard/components/HoverCardContent.js +1 -3
  42. package/dist/esm/view/HoverCard/components/views/resolved/index.js +1 -1
  43. package/dist/esm/view/HoverCard/utils.js +8 -4
  44. package/dist/types/constants.d.ts +1 -0
  45. package/dist/types/extractors/flexible/utils.d.ts +1 -0
  46. package/dist/types/messages.d.ts +1 -1
  47. package/dist/types/state/flexible-ui-context/types.d.ts +6 -0
  48. package/dist/types/state/hooks/useSmartLink.d.ts +6 -1
  49. package/dist/types/view/CardWithUrl/types.d.ts +5 -1
  50. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +8 -1
  51. package/dist/types/view/FlexibleCard/components/elements/index.d.ts +5 -0
  52. package/dist/types/view/HoverCard/utils.d.ts +1 -1
  53. package/package.json +6 -6
  54. package/report.api.md +9 -1
  55. package/tmp/api-report-tmp.d.ts +8 -1
@@ -1,9 +1,12 @@
1
1
  import { ElementName } from '../../constants';
2
- export const getSimulatedMetadata = (extensionKey = '', types = []) => {
2
+ import { extractType } from '@atlaskit/linking-common/extractors';
3
+ import { extractOwnedBy } from '../../extractors/flexible/utils';
4
+ export const getSimulatedMetadata = (extensionKey = '', data) => {
5
+ const types = data ? extractType(data) : undefined;
3
6
  switch (extensionKey) {
4
7
  case 'bitbucket-object-provider':
5
8
  case 'native-bitbucket-object-provider':
6
- if (types.includes('atlassian:SourceCodePullRequest')) {
9
+ if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
7
10
  return {
8
11
  metadata: {
9
12
  primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
@@ -20,9 +23,10 @@ export const getSimulatedMetadata = (extensionKey = '', types = []) => {
20
23
  }
21
24
  };
22
25
  case 'confluence-object-provider':
26
+ const primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedBy : ElementName.CreatedBy;
23
27
  return {
24
28
  metadata: {
25
- primary: [ElementName.AuthorGroup, ElementName.CreatedBy],
29
+ primary: [ElementName.AuthorGroup, primaryAttribution],
26
30
  secondary: [ElementName.CommentCount, ElementName.ReactCount],
27
31
  subtitle: []
28
32
  }
@@ -44,7 +48,7 @@ export const getSimulatedMetadata = (extensionKey = '', types = []) => {
44
48
  }
45
49
  };
46
50
  case 'watermelon-object-provider':
47
- if (types.includes('atlassian:Project')) {
51
+ if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
48
52
  return {
49
53
  metadata: {
50
54
  primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
@@ -112,6 +112,7 @@ export var ElementName;
112
112
  ElementName["LinkIcon"] = "LinkIcon";
113
113
  ElementName["ModifiedBy"] = "ModifiedBy";
114
114
  ElementName["ModifiedOn"] = "ModifiedOn";
115
+ ElementName["OwnedBy"] = "OwnedBy";
115
116
  ElementName["Preview"] = "Preview";
116
117
  ElementName["Priority"] = "Priority";
117
118
  ElementName["ProgrammingLanguage"] = "ProgrammingLanguage";
@@ -1,6 +1,6 @@
1
1
  import { extractSummary } from '../common/primitives';
2
2
  import { extractLinkIcon } from './icon';
3
- import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn } from './utils';
3
+ import { extractAttachmentCount, extractChecklistProgress, extractCommentCount, extractCreatedBy, extractModifiedBy, extractProgrammingLanguage, extractSubscriberCount, extractViewCount, extractReactCount, extractVoteCount, extractSourceBranch, extractTargetBranch, extractDueOn, extractOwnedBy } from './utils';
4
4
  import { extractPersonsUpdatedBy } from './collaboratorGroup';
5
5
  import { extractPersonCreatedBy, extractTitle, extractDateUpdated, extractDateCreated, extractLink } from '@atlaskit/linking-common/extractors';
6
6
  import extractPriority from './extract-priority';
@@ -34,6 +34,7 @@ var extractFlexibleUiContext = function extractFlexibleUiContext() {
34
34
  voteCount: extractVoteCount(data),
35
35
  checklistProgress: extractChecklistProgress(data),
36
36
  createdBy: extractCreatedBy(data),
37
+ ownedBy: extractOwnedBy(data),
37
38
  createdOn: extractDateCreated(data),
38
39
  dueOn: extractDueOn(data),
39
40
  previewAction: extractPreviewAction(response),
@@ -1,5 +1,5 @@
1
1
  import _typeof from "@babel/runtime/helpers/typeof";
2
- import { extractPersonCreatedBy, extractPersonUpdatedBy } from '@atlaskit/linking-common/extractors';
2
+ import { extractPersonOwnedBy, extractPersonCreatedBy, extractPersonUpdatedBy } from '@atlaskit/linking-common/extractors';
3
3
  var extractLinkName = function extractLinkName(link) {
4
4
  if (link && _typeof(link) === 'object' && link['@type'] === 'Link') {
5
5
  return link.name;
@@ -23,6 +23,12 @@ export var extractReactCount = function extractReactCount(data) {
23
23
  export var extractVoteCount = function extractVoteCount(data) {
24
24
  return extractValue(data, 'atlassian:voteCount');
25
25
  };
26
+ export var extractOwnedBy = function extractOwnedBy(data) {
27
+ var persons = extractPersonOwnedBy(data);
28
+ if (persons && persons.length) {
29
+ return persons[0].name;
30
+ }
31
+ };
26
32
  export var extractCreatedBy = function extractCreatedBy(data) {
27
33
  var persons = extractPersonCreatedBy(data);
28
34
  if (persons && persons.length) {
@@ -205,6 +205,11 @@ export var messages = defineMessages({
205
205
  defaultMessage: 'Open link in a new tab',
206
206
  description: 'Click to open link in a new tab'
207
207
  },
208
+ owned_by: {
209
+ id: 'fabric.linking.owned_by',
210
+ defaultMessage: 'Owned by {context}',
211
+ description: 'Indicates the person or entity that owns or maintains the resource.'
212
+ },
208
213
  preview: {
209
214
  id: 'fabric.linking.preview',
210
215
  defaultMessage: 'Full screen view',
package/dist/esm/ssr.js CHANGED
@@ -6,25 +6,28 @@ import React from 'react';
6
6
  import { useState } from 'react';
7
7
  import uuid from 'uuid';
8
8
  import { ErrorBoundary } from 'react-error-boundary';
9
+ import { AnalyticsContext } from '@atlaskit/analytics-next';
9
10
  import { CardWithUrlContent } from './view/CardWithUrl/component';
10
11
  import { LoadingCardLink } from './view/CardWithUrl/component-lazy/LazyFallback';
12
+ import { context } from './utils/analytics/analytics';
11
13
  // SSR friendly version of smart-card
12
14
  // simplifies the logic around rendering and loading placeholders and
13
15
  // only contains whats necessary to render the card on SSR mode
14
16
  export var CardSSR = function CardSSR(props) {
15
17
  var _useState = useState(function () {
16
- return uuid();
18
+ var _props$id;
19
+ return (_props$id = props.id) !== null && _props$id !== void 0 ? _props$id : uuid();
17
20
  }),
18
21
  _useState2 = _slicedToArray(_useState, 1),
19
22
  id = _useState2[0];
20
- var dispatchAnalytics = function dispatchAnalytics() {}; // we can't dispatch events on SSR, after hydration the we will provide the real callback
21
23
  var cardProps = _objectSpread(_objectSpread({}, props), {}, {
22
- id: id,
23
- dispatchAnalytics: dispatchAnalytics
24
+ id: id
24
25
  });
25
- return /*#__PURE__*/React.createElement(ErrorBoundary, {
26
+ return /*#__PURE__*/React.createElement(AnalyticsContext, {
27
+ data: context
28
+ }, /*#__PURE__*/React.createElement(ErrorBoundary, {
26
29
  FallbackComponent: function FallbackComponent() {
27
30
  return /*#__PURE__*/React.createElement(LoadingCardLink, cardProps);
28
31
  }
29
- }, /*#__PURE__*/React.createElement(CardWithUrlContent, cardProps));
32
+ }, /*#__PURE__*/React.createElement(CardWithUrlContent, cardProps)));
30
33
  };
@@ -6,7 +6,12 @@ import { useSmartLinkConfig } from '../config';
6
6
  import { useSmartLinkAnalytics } from '../analytics';
7
7
  import { useSmartLinkRenderers } from '../renderers';
8
8
  import { useSmartLinkContext } from '@atlaskit/link-provider';
9
- export function useSmartLink(id, url, dispatchAnalytics) {
9
+ export function useSmartLink(id, url,
10
+ /**
11
+ * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
12
+ * Avoid prop drilling analytics handlers. Continue passing a handler for now if there's already one in place.
13
+ */
14
+ dispatchAnalytics) {
10
15
  var state = useSmartLinkState(url);
11
16
  var _useSmartLinkContext = useSmartLinkContext(),
12
17
  store = _useSmartLinkContext.store;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.5.7",
3
+ "version": "25.6.1",
4
4
  "sideEffects": false
5
5
  }
@@ -5,13 +5,14 @@ import TitleBlock from '../../../FlexibleCard/components/blocks/title-block';
5
5
  import { FooterBlock, MetadataBlock, PreviewBlock, SnippetBlock } from '../../../FlexibleCard/components/blocks';
6
6
  import { ActionName, CardDisplay, ElementName, MediaPlacement, SmartLinkPosition } from '../../../../constants';
7
7
  import uuid from 'uuid';
8
-
8
+ import { extractOwnedBy } from '../../../../extractors/flexible/utils';
9
9
  /**
10
10
  * This view represents a Block card that has an 'Resolved' status.
11
11
  * @see SmartLinkStatus
12
12
  * @see FlexibleCardProps
13
13
  */
14
14
  var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
15
+ var _cardState$details, _cardState$details2;
15
16
  var id = _ref.id,
16
17
  cardState = _ref.cardState,
17
18
  onClick = _ref.onClick,
@@ -35,6 +36,30 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
35
36
  }),
36
37
  _useState4 = _slicedToArray(_useState3, 1),
37
38
  analyticsId = _useState4[0];
39
+ var baseMetadata = [{
40
+ name: ElementName.ModifiedOn
41
+ }, {
42
+ name: ElementName.AttachmentCount
43
+ }, {
44
+ name: ElementName.CommentCount
45
+ }, {
46
+ name: ElementName.ReactCount
47
+ }, {
48
+ name: ElementName.SubscriberCount
49
+ }, {
50
+ name: ElementName.ViewCount
51
+ }, {
52
+ name: ElementName.VoteCount
53
+ }, {
54
+ name: ElementName.ChecklistProgress
55
+ }, {
56
+ name: ElementName.DueOn
57
+ }];
58
+ var metadata = cardState !== null && cardState !== void 0 && (_cardState$details = cardState.details) !== null && _cardState$details !== void 0 && _cardState$details.data && extractOwnedBy(cardState === null || cardState === void 0 ? void 0 : (_cardState$details2 = cardState.details) === null || _cardState$details2 === void 0 ? void 0 : _cardState$details2.data) ? [{
59
+ name: ElementName.OwnedBy
60
+ }].concat(baseMetadata) : [{
61
+ name: ElementName.ModifiedBy
62
+ }].concat(baseMetadata);
38
63
  return /*#__PURE__*/React.createElement(FlexibleCard, {
39
64
  appearance: "block",
40
65
  cardState: cardState,
@@ -56,27 +81,7 @@ var FlexibleResolvedView = function FlexibleResolvedView(_ref) {
56
81
  }],
57
82
  hideRetry: true
58
83
  }), /*#__PURE__*/React.createElement(MetadataBlock, {
59
- primary: [{
60
- name: ElementName.ModifiedBy
61
- }, {
62
- name: ElementName.ModifiedOn
63
- }, {
64
- name: ElementName.AttachmentCount
65
- }, {
66
- name: ElementName.CommentCount
67
- }, {
68
- name: ElementName.ReactCount
69
- }, {
70
- name: ElementName.SubscriberCount
71
- }, {
72
- name: ElementName.ViewCount
73
- }, {
74
- name: ElementName.VoteCount
75
- }, {
76
- name: ElementName.ChecklistProgress
77
- }, {
78
- name: ElementName.DueOn
79
- }],
84
+ primary: metadata,
80
85
  maxLines: 1
81
86
  }), /*#__PURE__*/React.createElement(SnippetBlock, null), !isPreviewBlockErrored ? /*#__PURE__*/React.createElement(PreviewBlock, {
82
87
  placement: MediaPlacement.Right,
@@ -15,7 +15,7 @@ import ElementGroup from './element-group';
15
15
 
16
16
  // Determine whether the element can be display as inline/block.
17
17
 
18
- export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _ElementDisplaySchema);
18
+ export var ElementDisplaySchema = (_ElementDisplaySchema = {}, _defineProperty(_ElementDisplaySchema, ElementName.AttachmentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.AuthorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ChecklistProgress, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CollaboratorGroup, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CommentCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ViewCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ReactCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.VoteCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.CreatedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.DueOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LatestCommit, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.LinkIcon, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ModifiedOn, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.OwnedBy, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Preview, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.Priority, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.ProgrammingLanguage, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Provider, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Snippet, ['block']), _defineProperty(_ElementDisplaySchema, ElementName.SourceBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.State, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.SubscriberCount, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.TargetBranch, ['inline']), _defineProperty(_ElementDisplaySchema, ElementName.Title, ['inline']), _ElementDisplaySchema);
19
19
  var getDirectionStyles = function getDirectionStyles(direction) {
20
20
  switch (direction) {
21
21
  case SmartLinkDirection.Vertical:
@@ -62,6 +62,11 @@ export var ModifiedBy = createElement(ElementName.ModifiedBy);
62
62
  * @see DateTime
63
63
  */
64
64
  export var ModifiedOn = createElement(ElementName.ModifiedOn);
65
+ /**
66
+ * Creates a OwnedBy text element using the data from OwnedBy in the Flexible UI Context.
67
+ * @see Text
68
+ */
69
+ export var OwnedBy = createElement(ElementName.OwnedBy);
65
70
  /**
66
71
  * Creates a Preview element using the data from Preview in the Flexible UI Context.
67
72
  * @see Preview
@@ -54,6 +54,8 @@ var elementMappings = (_elementMappings = {}, _defineProperty(_elementMappings,
54
54
  }
55
55
  }), _defineProperty(_elementMappings, ElementName.CreatedBy, {
56
56
  component: Text
57
+ }), _defineProperty(_elementMappings, ElementName.OwnedBy, {
58
+ component: Text
57
59
  }), _defineProperty(_elementMappings, ElementName.CreatedOn, {
58
60
  component: DateTime
59
61
  }), _defineProperty(_elementMappings, ElementName.DueOn, {
@@ -126,6 +128,8 @@ var getData = function getData(elementName, contextKey, context) {
126
128
  return toBadgeProps(data);
127
129
  case ElementName.CreatedBy:
128
130
  return toFormattedTextProps(messages.created_by, context.createdBy);
131
+ case ElementName.OwnedBy:
132
+ return toFormattedTextProps(messages.owned_by, context.ownedBy);
129
133
  case ElementName.CreatedOn:
130
134
  return toDateTimeProps('created', context.createdOn);
131
135
  case ElementName.DueOn:
@@ -5,7 +5,6 @@ function _regeneratorRuntime() { "use strict"; /*! regenerator-runtime -- Copyri
5
5
  import { jsx } from '@emotion/react';
6
6
  import ShortcutIcon from '@atlaskit/icon/glyph/shortcut';
7
7
  import CopyIcon from '@atlaskit/icon/glyph/copy';
8
- import { extractType } from '@atlaskit/linking-common/extractors';
9
8
  import { useAnalyticsEvents } from '@atlaskit/analytics-next';
10
9
  import React, { useCallback, useEffect, useMemo } from 'react';
11
10
  import { ActionName, CardDisplay, SmartLinkPosition, SmartLinkSize } from '../../../constants';
@@ -115,8 +114,7 @@ var HoverCardContent = function HoverCardContent(_ref) {
115
114
  return [getCopyAction(url), getOpenAction(url, analytics, onActionClick)];
116
115
  }, [url, analytics, onActionClick]);
117
116
  var data = (_cardState$details = cardState.details) === null || _cardState$details === void 0 ? void 0 : _cardState$details.data;
118
- var types = data ? extractType(data) : undefined;
119
- var _extractMetadata = extractMetadata(getSimulatedMetadata(extensionKey, types)),
117
+ var _extractMetadata = extractMetadata(getSimulatedMetadata(extensionKey, data)),
120
118
  subtitle = _extractMetadata.subtitle;
121
119
  var titleMaxLines = subtitle && subtitle.length > 0 ? 1 : 2;
122
120
  var titleBlockProps = {
@@ -52,7 +52,7 @@ var HoverCardResolvedView = function HoverCardResolvedView(_ref) {
52
52
  var _useMemo = useMemo(function () {
53
53
  var types = data ? extractType(data) : undefined;
54
54
  //TODO: EDM-3224 deleted simulated and use real JsonLd
55
- var metadata = extractMetadata(getSimulatedMetadata(extensionKey, types));
55
+ var metadata = extractMetadata(getSimulatedMetadata(extensionKey, data));
56
56
  var primary = showActionableElement ? toActionableMetadata(onActionClick, extensionKey, types, cardActions, metadata.primary) : metadata.primary;
57
57
  return {
58
58
  primary: primary,
@@ -2,13 +2,16 @@ import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
2
  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; }
3
3
  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; }
4
4
  import { ElementName } from '../../constants';
5
+ import { extractType } from '@atlaskit/linking-common/extractors';
6
+ import { extractOwnedBy } from '../../extractors/flexible/utils';
5
7
  export var getSimulatedMetadata = function getSimulatedMetadata() {
6
8
  var extensionKey = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : '';
7
- var types = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
9
+ var data = arguments.length > 1 ? arguments[1] : undefined;
10
+ var types = data ? extractType(data) : undefined;
8
11
  switch (extensionKey) {
9
12
  case 'bitbucket-object-provider':
10
13
  case 'native-bitbucket-object-provider':
11
- if (types.includes('atlassian:SourceCodePullRequest')) {
14
+ if (types !== null && types !== void 0 && types.includes('atlassian:SourceCodePullRequest')) {
12
15
  return {
13
16
  metadata: {
14
17
  primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.SubscriberCount, ElementName.State],
@@ -25,9 +28,10 @@ export var getSimulatedMetadata = function getSimulatedMetadata() {
25
28
  }
26
29
  };
27
30
  case 'confluence-object-provider':
31
+ var primaryAttribution = data && extractOwnedBy(data) ? ElementName.OwnedBy : ElementName.CreatedBy;
28
32
  return {
29
33
  metadata: {
30
- primary: [ElementName.AuthorGroup, ElementName.CreatedBy],
34
+ primary: [ElementName.AuthorGroup, primaryAttribution],
31
35
  secondary: [ElementName.CommentCount, ElementName.ReactCount],
32
36
  subtitle: []
33
37
  }
@@ -49,7 +53,7 @@ export var getSimulatedMetadata = function getSimulatedMetadata() {
49
53
  }
50
54
  };
51
55
  case 'watermelon-object-provider':
52
- if (types.includes('atlassian:Project')) {
56
+ if (types !== null && types !== void 0 && types.includes('atlassian:Project')) {
53
57
  return {
54
58
  metadata: {
55
59
  primary: [ElementName.AuthorGroup, ElementName.ModifiedOn, ElementName.State, ElementName.DueOn],
@@ -92,6 +92,7 @@ export declare enum ElementName {
92
92
  LinkIcon = "LinkIcon",
93
93
  ModifiedBy = "ModifiedBy",
94
94
  ModifiedOn = "ModifiedOn",
95
+ OwnedBy = "OwnedBy",
95
96
  Preview = "Preview",
96
97
  Priority = "Priority",
97
98
  ProgrammingLanguage = "ProgrammingLanguage",
@@ -4,6 +4,7 @@ export declare const extractDueOn: (data: JsonLd.Data.BaseData) => string | unde
4
4
  export declare const extractViewCount: (data: JsonLd.Data.BaseData) => number | undefined;
5
5
  export declare const extractReactCount: (data: JsonLd.Data.BaseData) => number | undefined;
6
6
  export declare const extractVoteCount: (data: JsonLd.Data.BaseData) => number | undefined;
7
+ export declare const extractOwnedBy: (data: JsonLd.Data.BaseData) => string | undefined;
7
8
  export declare const extractCreatedBy: (data: JsonLd.Data.BaseData) => string | undefined;
8
9
  export declare const extractModifiedBy: (data: JsonLd.Data.BaseData) => string | undefined;
9
10
  export declare const extractProgrammingLanguage: (data: JsonLd.Data.BaseData) => string | undefined;
@@ -1,6 +1,6 @@
1
1
  import { MessageDescriptor } from 'react-intl-next';
2
2
  export declare type RequestAccessMessageKey = 'click_to_join' | 'click_to_join_description' | 'forbidden_description' | 'request_access' | 'request_access_description' | 'request_access_pending' | 'request_access_pending_description' | 'request_denied_description';
3
- export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'continue' | 'copy_url_to_clipboard' | 'could_not_load_link' | 'download' | 'go_back' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'check_this_link' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'link_safety_warning_message' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_link_in_a_new_tab' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | '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_to_view' | 'request_denied' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
3
+ export declare type MessageKey = 'cannot_find_link' | 'connect_link_account_card' | 'connect_link_account_card_name' | 'connect_link_account_card_description' | 'connect_unauthorised_account_action' | 'connect_unauthorised_account_description' | 'connect_unauthorised_account_description_no_provider' | 'continue' | 'copy_url_to_clipboard' | 'could_not_load_link' | 'download' | 'go_back' | 'invalid_permissions' | 'invalid_permissions_description' | 'join_to_view' | 'connect_link_account' | 'created_by' | 'created_on_relative' | 'created_on_absolute' | 'check_this_link' | 'delete' | 'edit' | 'learn_more_about_smart_links' | 'loading' | 'link_safety_warning_message' | 'modified_by' | 'modified_on_relative' | 'modified_on_absolute' | 'more_actions' | 'not_found_title' | 'not_found_description' | 'open_link_in_a_new_tab' | 'owned_by' | 'preview' | 'preview_close' | 'preview_max_size' | 'preview_min_size' | '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_to_view' | 'request_denied' | 'try_again' | 'try_another_account' | 'view' | 'viewIn' | 'viewOriginal' | 'actions' | 'add_account' | 'cancel' | 'close' | 'connect_to' | 'connect_account_description' | 'retry' | 'save' | 'unlink_account' | RequestAccessMessageKey;
4
4
  declare type Messages = {
5
5
  [K in MessageKey]: MessageDescriptor;
6
6
  };
@@ -64,6 +64,12 @@ export declare type FlexibleUiDataContext = {
64
64
  * @see CreatedBy
65
65
  */
66
66
  createdBy?: string;
67
+ /**
68
+ * Contains the name of the entity that owns the resource.
69
+ * @type string
70
+ * @see OwnedBy
71
+ */
72
+ ownedBy?: string;
67
73
  /**
68
74
  * Contains the ISO timestamp of when the resource was created.
69
75
  * @type string - ISO Timestamp
@@ -1,5 +1,10 @@
1
1
  import { AnalyticsHandler } from '../../utils/types';
2
- export declare function useSmartLink(id: string, url: string, dispatchAnalytics: AnalyticsHandler): {
2
+ export declare function useSmartLink(id: string, url: string,
3
+ /**
4
+ * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
5
+ * Avoid prop drilling analytics handlers. Continue passing a handler for now if there's already one in place.
6
+ */
7
+ dispatchAnalytics?: AnalyticsHandler): {
3
8
  state: import("@atlaskit/linking-common").CardState;
4
9
  actions: {
5
10
  register: () => Promise<void>;
@@ -15,7 +15,11 @@ export declare type CardWithUrlContentProps = {
15
15
  isFrameVisible?: boolean;
16
16
  frameStyle?: FrameStyle;
17
17
  container?: HTMLElement;
18
- dispatchAnalytics: AnalyticsHandler;
18
+ /**
19
+ * @deprecated {@link https://hello.atlassian.net/browse/ENGHEALTH-2681 Internal documentation for deprecation (no external access)}
20
+ * Avoid prop drilling analytics handlers
21
+ */
22
+ dispatchAnalytics?: AnalyticsHandler;
19
23
  testId?: string;
20
24
  onResolve?: OnResolveCallback;
21
25
  onError?: OnErrorCallback;
@@ -168,7 +168,7 @@ export declare type OnActionMenuOpenChangeOptions = {
168
168
  /**
169
169
  * A type that contains all the possible combinations of elements with their corresponding props.
170
170
  */
171
- export declare type ElementItemProps = AttachmentCount | AuthorGroup | ChecklistProgress | CollaboratorGroup | CommentCount | CreatedBy | CreatedOn | DueOn | LatestCommit | LinkIcon | ModifiedBy | ModifiedOn | Preview | Priority | ProgrammingLanguage | Provider | ReactCount | Snippet | SourceBranch | State | SubscriberCount | TargetBranch | Title | ViewCount | VoteCount;
171
+ export declare type ElementItemProps = AttachmentCount | AuthorGroup | ChecklistProgress | CollaboratorGroup | CommentCount | CreatedBy | CreatedOn | DueOn | LatestCommit | LinkIcon | ModifiedBy | ModifiedOn | OwnedBy | Preview | Priority | ProgrammingLanguage | Provider | ReactCount | Snippet | SourceBranch | State | SubscriberCount | TargetBranch | Title | ViewCount | VoteCount;
172
172
  /**
173
173
  * Represents the props available for an AttachmentCount element.
174
174
  * @see AttachmentCount
@@ -211,6 +211,13 @@ export declare type CommentCount = {
211
211
  export declare type CreatedBy = {
212
212
  name: ElementName.CreatedBy;
213
213
  };
214
+ /**
215
+ * Represents the props available for an OwnedBy element.
216
+ * @see OwnedBy
217
+ */
218
+ export declare type OwnedBy = {
219
+ name: ElementName.OwnedBy;
220
+ };
214
221
  /**
215
222
  * Represents the props available for an CreatedOn element.
216
223
  * @see CreatedOn
@@ -66,6 +66,11 @@ export declare const ModifiedBy: import("react").FC<TextProps>;
66
66
  * @see DateTime
67
67
  */
68
68
  export declare const ModifiedOn: import("react").FC<DateTimeProps>;
69
+ /**
70
+ * Creates a OwnedBy text element using the data from OwnedBy in the Flexible UI Context.
71
+ * @see Text
72
+ */
73
+ export declare const OwnedBy: import("react").FC<TextProps>;
69
74
  /**
70
75
  * Creates a Preview element using the data from Preview in the Flexible UI Context.
71
76
  * @see Preview
@@ -1,5 +1,5 @@
1
1
  import { JsonLd } from 'json-ld-types';
2
2
  import { LinkAction } from '../../state/hooks-external/useSmartLinkActions';
3
3
  import { ElementItem } from '../FlexibleCard/components/blocks/types';
4
- export declare const getSimulatedMetadata: (extensionKey?: string, types?: JsonLd.Primitives.ObjectType[]) => JsonLd.Primitives.Property<any>;
4
+ export declare const getSimulatedMetadata: (extensionKey: string | undefined, data: JsonLd.Data.BaseData) => JsonLd.Primitives.Property<any>;
5
5
  export declare const toActionableMetadata: (onActionClick: (actionId: string) => void, extensionKey?: string | undefined, types?: JsonLd.Primitives.ObjectType[], cardActions?: LinkAction[], elementItems?: ElementItem[]) => ElementItem[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "25.5.7",
3
+ "version": "25.6.1",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -34,8 +34,8 @@
34
34
  "@atlaskit/icon-priority": "^6.3.0",
35
35
  "@atlaskit/in-product-testing": "^0.1.0",
36
36
  "@atlaskit/link-client-extension": "^0.4.0",
37
- "@atlaskit/linking-common": "^2.5.0",
38
- "@atlaskit/linking-types": "^1.0.0",
37
+ "@atlaskit/linking-common": "^2.6.0",
38
+ "@atlaskit/linking-types": "^1.1.0",
39
39
  "@atlaskit/logo": "^13.13.0",
40
40
  "@atlaskit/lozenge": "^11.3.0",
41
41
  "@atlaskit/media-common": "^4.0.0",
@@ -52,7 +52,7 @@
52
52
  "@emotion/styled": "^11.0.0",
53
53
  "@formatjs/intl-utils": "^3.8.4",
54
54
  "facepaint": "^1.2.1",
55
- "json-ld-types": "3.6.0",
55
+ "json-ld-types": "3.7.0",
56
56
  "react-error-boundary": "^3.1.3",
57
57
  "react-lazily-render": "^1.2.0",
58
58
  "react-loadable": "^5.1.0",
@@ -60,7 +60,7 @@
60
60
  "uuid": "^3.1.0"
61
61
  },
62
62
  "peerDependencies": {
63
- "@atlaskit/link-provider": "^1.5.3",
63
+ "@atlaskit/link-provider": "^1.5.4",
64
64
  "react": "^16.8.0",
65
65
  "react-dom": "^16.8.0",
66
66
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -71,7 +71,7 @@
71
71
  "@atlaskit/code": "^14.5.0",
72
72
  "@atlaskit/css-reset": "^6.4.0",
73
73
  "@atlaskit/docs": "*",
74
- "@atlaskit/field-base": "^15.0.6",
74
+ "@atlaskit/field-base": "^15.1.0",
75
75
  "@atlaskit/form": "^8.9.0",
76
76
  "@atlaskit/inline-message": "^11.4.0",
77
77
  "@atlaskit/link-test-helpers": "^2.2.0",
package/report.api.md CHANGED
@@ -442,6 +442,7 @@ type ElementItemProps =
442
442
  | LinkIcon
443
443
  | ModifiedBy
444
444
  | ModifiedOn
445
+ | OwnedBy
445
446
  | Preview
446
447
  | Priority
447
448
  | ProgrammingLanguage
@@ -483,6 +484,8 @@ export enum ElementName {
483
484
  // (undocumented)
484
485
  ModifiedOn = 'ModifiedOn',
485
486
  // (undocumented)
487
+ OwnedBy = 'OwnedBy',
488
+ // (undocumented)
486
489
  Preview = 'Preview',
487
490
  // (undocumented)
488
491
  Priority = 'Priority',
@@ -670,6 +673,11 @@ type OnResolveCallback = (data: {
670
673
  aspectRatio?: number;
671
674
  }) => void;
672
675
 
676
+ // @public
677
+ type OwnedBy = {
678
+ name: ElementName.OwnedBy;
679
+ };
680
+
673
681
  // @public
674
682
  type Preview = {
675
683
  name: ElementName.Preview;
@@ -1228,7 +1236,7 @@ type VoteCount = {
1228
1236
 
1229
1237
  ```json
1230
1238
  {
1231
- "@atlaskit/link-provider": "^1.5.3",
1239
+ "@atlaskit/link-provider": "^1.5.4",
1232
1240
  "react": "^16.8.0",
1233
1241
  "react-dom": "^16.8.0",
1234
1242
  "react-intl-next": "npm:react-intl@^5.18.1"
@@ -333,7 +333,7 @@ export type ElementItem = {
333
333
  } & ElementItemProps;
334
334
 
335
335
  // @public
336
- type ElementItemProps = AttachmentCount | AuthorGroup | ChecklistProgress | CollaboratorGroup | CommentCount | CreatedBy | CreatedOn | DueOn | LatestCommit | LinkIcon | ModifiedBy | ModifiedOn | Preview | Priority | ProgrammingLanguage | Provider_2 | ReactCount | Snippet | SourceBranch | State_2 | SubscriberCount | TargetBranch | Title | ViewCount | VoteCount;
336
+ type ElementItemProps = AttachmentCount | AuthorGroup | ChecklistProgress | CollaboratorGroup | CommentCount | CreatedBy | CreatedOn | DueOn | LatestCommit | LinkIcon | ModifiedBy | ModifiedOn | OwnedBy | Preview | Priority | ProgrammingLanguage | Provider_2 | ReactCount | Snippet | SourceBranch | State_2 | SubscriberCount | TargetBranch | Title | ViewCount | VoteCount;
337
337
 
338
338
  // @public
339
339
  export enum ElementName {
@@ -362,6 +362,8 @@ export enum ElementName {
362
362
  // (undocumented)
363
363
  ModifiedOn = "ModifiedOn",
364
364
  // (undocumented)
365
+ OwnedBy = "OwnedBy",
366
+ // (undocumented)
365
367
  Preview = "Preview",
366
368
  // (undocumented)
367
369
  Priority = "Priority",
@@ -536,6 +538,11 @@ type OnResolveCallback = (data: {
536
538
  aspectRatio?: number;
537
539
  }) => void;
538
540
 
541
+ // @public
542
+ type OwnedBy = {
543
+ name: ElementName.OwnedBy;
544
+ };
545
+
539
546
  // @public
540
547
  type Preview = {
541
548
  name: ElementName.Preview;