@atlaskit/smart-card 26.16.1 → 26.17.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.
Files changed (25) hide show
  1. package/CHANGELOG.md +6 -0
  2. package/dist/cjs/extractors/hover/extractMetadata.js +10 -2
  3. package/dist/cjs/utils/analytics/analytics.js +1 -1
  4. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +38 -4
  5. package/dist/cjs/view/FlexibleCard/components/utils.js +8 -1
  6. package/dist/cjs/view/LinkUrl/index.js +1 -1
  7. package/dist/es2019/extractors/hover/extractMetadata.js +6 -1
  8. package/dist/es2019/utils/analytics/analytics.js +1 -1
  9. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +33 -4
  10. package/dist/es2019/view/FlexibleCard/components/utils.js +8 -0
  11. package/dist/es2019/view/LinkUrl/index.js +1 -1
  12. package/dist/esm/extractors/hover/extractMetadata.js +9 -2
  13. package/dist/esm/utils/analytics/analytics.js +1 -1
  14. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +36 -4
  15. package/dist/esm/view/FlexibleCard/components/utils.js +6 -0
  16. package/dist/esm/view/LinkUrl/index.js +1 -1
  17. package/dist/types/view/FlexibleCard/components/blocks/types.d.ts +12 -0
  18. package/dist/types/view/FlexibleCard/components/elements/avatar-group/types.d.ts +4 -0
  19. package/dist/types/view/FlexibleCard/components/utils.d.ts +2 -0
  20. package/dist/types-ts4.5/view/FlexibleCard/components/blocks/types.d.ts +12 -0
  21. package/dist/types-ts4.5/view/FlexibleCard/components/elements/avatar-group/types.d.ts +4 -0
  22. package/dist/types-ts4.5/view/FlexibleCard/components/utils.d.ts +2 -0
  23. package/package.json +2 -2
  24. package/report.api.md +3 -0
  25. package/tmp/api-report-tmp.d.ts +3 -0
package/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 26.17.0
4
+
5
+ ### Minor Changes
6
+
7
+ - [`efc2669bc13`](https://bitbucket.org/atlassian/atlassian-frontend/commits/efc2669bc13) - We are testing adding a prefix to the Avatar name tooltip in the Hover Card behind the "platform.linking-platform.smart-card.enable-better-metadata_iojwg" feature flag. You can turn it on by passing new showNamePrefix prop to the Flexible UI elements such us AssignedToGroup, OwnedByGroup and AuthorGroup. If this fix is successful it will be available in a later release.
8
+
3
9
  ## 26.16.1
4
10
 
5
11
  ### Patch Changes
@@ -1,18 +1,26 @@
1
1
  "use strict";
2
2
 
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
3
4
  Object.defineProperty(exports, "__esModule", {
4
5
  value: true
5
6
  });
6
7
  exports.extractMetadata = exports.elementNamesToItems = void 0;
8
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
7
9
  var _constants = require("../../constants");
10
+ var _platformFeatureFlags = require("@atlaskit/platform-feature-flags");
11
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
12
+ 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) { (0, _defineProperty2.default)(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; }
13
+ var AvatarGroupsWithNamePrefix = [_constants.ElementName.AssignedToGroup, _constants.ElementName.OwnedByGroup, _constants.ElementName.AuthorGroup];
8
14
  var elementNamesToItems = function elementNamesToItems(elementNames) {
9
15
  return elementNames.filter(function (element) {
10
16
  return element in _constants.ElementName;
11
17
  }).map(function (elementName) {
12
- return {
18
+ return _objectSpread({
13
19
  name: elementName,
14
20
  testId: "".concat(elementName.toLowerCase(), "-metadata-element")
15
- };
21
+ }, (0, _platformFeatureFlags.getBooleanFF)('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && AvatarGroupsWithNamePrefix.includes(elementName) && {
22
+ showNamePrefix: true
23
+ });
16
24
  });
17
25
  };
18
26
  exports.elementNamesToItems = elementNamesToItems;
@@ -21,7 +21,7 @@ exports.ANALYTICS_CHANNEL = ANALYTICS_CHANNEL;
21
21
  var context = {
22
22
  componentName: 'smart-cards',
23
23
  packageName: "@atlaskit/smart-card",
24
- packageVersion: "26.16.1"
24
+ packageVersion: "26.17.0"
25
25
  };
26
26
  exports.context = context;
27
27
  var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
@@ -1,17 +1,26 @@
1
1
  "use strict";
2
2
 
3
3
  var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+ var _typeof = require("@babel/runtime/helpers/typeof");
4
5
  Object.defineProperty(exports, "__esModule", {
5
6
  value: true
6
7
  });
7
8
  exports.default = void 0;
9
+ var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
8
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
- var _react = _interopRequireDefault(require("react"));
11
+ var _react = _interopRequireWildcard(require("react"));
10
12
  var _react2 = require("@emotion/react");
11
13
  var _avatarGroup = _interopRequireDefault(require("@atlaskit/avatar-group"));
12
14
  var _constants = require("../../../../../constants");
15
+ var _messages = require("../../../../../messages");
16
+ var _reactIntlNext = require("react-intl-next");
17
+ var _utils = require("../../utils");
13
18
  var _templateObject, _templateObject2;
14
19
  /** @jsx jsx */
20
+ 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); }
21
+ 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; }
22
+ 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; }
23
+ 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) { (0, _defineProperty2.default)(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; }
15
24
  var MAX_COUNT = 4;
16
25
  var getStyles = function getStyles(size) {
17
26
  var styles = (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: inline-flex;\n ul,\n ul {\n margin-right: 0.5rem;\n margin-top: 0;\n }\n "])));
@@ -26,6 +35,18 @@ var getStyles = function getStyles(size) {
26
35
  return (0, _react2.css)(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n ", "\n li {\n span,\n svg {\n max-height: 1.25rem;\n max-width: 1.25rem;\n }\n }\n "])), styles);
27
36
  }
28
37
  };
38
+ var getPersonNameWithPrefix = function getPersonNameWithPrefix(elementName, personName, intl) {
39
+ switch (elementName) {
40
+ case _constants.ElementName.AssignedToGroup:
41
+ return (0, _utils.getFormattedMessageAsString)(intl, _messages.messages.assigned_to, personName);
42
+ case _constants.ElementName.OwnedByGroup:
43
+ return (0, _utils.getFormattedMessageAsString)(intl, _messages.messages.owned_by, personName);
44
+ case _constants.ElementName.AuthorGroup:
45
+ return (0, _utils.getFormattedMessageAsString)(intl, _messages.messages.created_by, personName);
46
+ default:
47
+ return personName;
48
+ }
49
+ };
29
50
 
30
51
  /**
31
52
  * A base element that displays a group of avatars.
@@ -44,8 +65,21 @@ var AvatarGroup = function AvatarGroup(_ref) {
44
65
  _ref$size = _ref.size,
45
66
  size = _ref$size === void 0 ? _constants.SmartLinkSize.Medium : _ref$size,
46
67
  _ref$testId = _ref.testId,
47
- testId = _ref$testId === void 0 ? 'smart-element-avatar-group' : _ref$testId;
48
- if (!items.length) {
68
+ testId = _ref$testId === void 0 ? 'smart-element-avatar-group' : _ref$testId,
69
+ _ref$showNamePrefix = _ref.showNamePrefix,
70
+ showNamePrefix = _ref$showNamePrefix === void 0 ? false : _ref$showNamePrefix;
71
+ var intl = (0, _reactIntlNext.useIntl)();
72
+ var data = (0, _react.useMemo)(function () {
73
+ if (name && showNamePrefix) {
74
+ return items.map(function (person) {
75
+ return _objectSpread(_objectSpread({}, person), {}, {
76
+ name: getPersonNameWithPrefix(name, person.name, intl) || person.name
77
+ });
78
+ });
79
+ }
80
+ return items;
81
+ }, [name, items, showNamePrefix, intl]);
82
+ if (!data.length) {
49
83
  return null;
50
84
  }
51
85
  return (0, _react2.jsx)("span", {
@@ -58,7 +92,7 @@ var AvatarGroup = function AvatarGroup(_ref) {
58
92
  maxCount: maxCount,
59
93
  appearance: "stack",
60
94
  size: "small",
61
- data: items,
95
+ data: data,
62
96
  testId: testId
63
97
  }));
64
98
  };
@@ -4,7 +4,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
4
4
  Object.defineProperty(exports, "__esModule", {
5
5
  value: true
6
6
  });
7
- exports.sizeToButtonSpacing = exports.openEmbedModalWithFlexibleUiIcon = exports.hasWhiteSpace = exports.getTruncateStyles = exports.getMaxLines = exports.getMaxLineHeight = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconWidth = exports.getIconSizeStyles = exports.getFormattedMessage = void 0;
7
+ exports.sizeToButtonSpacing = exports.openEmbedModalWithFlexibleUiIcon = exports.hasWhiteSpace = exports.getTruncateStyles = exports.getMaxLines = exports.getMaxLineHeight = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconWidth = exports.getIconSizeStyles = exports.getFormattedMessageAsString = exports.getFormattedMessage = void 0;
8
8
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
9
9
  var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
10
10
  var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
@@ -27,6 +27,13 @@ var getFormattedMessage = function getFormattedMessage(message) {
27
27
  }
28
28
  };
29
29
  exports.getFormattedMessage = getFormattedMessage;
30
+ var getFormattedMessageAsString = function getFormattedMessageAsString(intl, message, context) {
31
+ var formatMessage = intl.formatMessage;
32
+ return message ? formatMessage(message, {
33
+ context: context
34
+ }) : null;
35
+ };
36
+ exports.getFormattedMessageAsString = getFormattedMessageAsString;
30
37
  var getIconDimensionStyles = function getIconDimensionStyles(value) {
31
38
  return (0, _react2.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n height: ", ";\n min-height: ", ";\n max-height: ", ";\n width: ", ";\n min-width: ", ";\n max-width: ", ";\n"])), value, value, value, value, value, value);
32
39
  };
@@ -18,7 +18,7 @@ var _excluded = ["href", "children", "checkSafety", "onClick", "testId"],
18
18
  _excluded2 = ["isLinkSafe", "showSafetyWarningModal"];
19
19
  var PACKAGE_DATA = {
20
20
  packageName: "@atlaskit/smart-card",
21
- packageVersion: "26.16.1",
21
+ packageVersion: "26.17.0",
22
22
  componentName: 'linkUrl'
23
23
  };
24
24
  var Link = (0, _click.withLinkClickedEvent)('a');
@@ -1,8 +1,13 @@
1
1
  import { ElementName } from '../../constants';
2
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
3
+ const AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
2
4
  export const elementNamesToItems = elementNames => {
3
5
  return elementNames.filter(element => element in ElementName).map(elementName => ({
4
6
  name: elementName,
5
- testId: `${elementName.toLowerCase()}-metadata-element`
7
+ testId: `${elementName.toLowerCase()}-metadata-element`,
8
+ ...(getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && AvatarGroupsWithNamePrefix.includes(elementName) && {
9
+ showNamePrefix: true
10
+ })
6
11
  }));
7
12
  };
8
13
  export const extractMetadata = jsonLd => {
@@ -3,7 +3,7 @@ export const ANALYTICS_CHANNEL = 'media';
3
3
  export const context = {
4
4
  componentName: 'smart-cards',
5
5
  packageName: "@atlaskit/smart-card",
6
- packageVersion: "26.16.1"
6
+ packageVersion: "26.17.0"
7
7
  };
8
8
  export let TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
9
9
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,8 +1,12 @@
1
1
  /** @jsx jsx */
2
- import React from 'react';
2
+ import React, { useMemo } from 'react';
3
3
  import { css, jsx } from '@emotion/react';
4
4
  import AtlaskitAvatarGroup from '@atlaskit/avatar-group';
5
5
  import { SmartLinkSize } from '../../../../../constants';
6
+ import { messages } from '../../../../../messages';
7
+ import { useIntl } from 'react-intl-next';
8
+ import { ElementName } from '../../../../../constants';
9
+ import { getFormattedMessageAsString } from '../../utils';
6
10
  const MAX_COUNT = 4;
7
11
  const getStyles = size => {
8
12
  const styles = css`
@@ -33,6 +37,18 @@ const getStyles = size => {
33
37
  `;
34
38
  }
35
39
  };
40
+ const getPersonNameWithPrefix = (elementName, personName, intl) => {
41
+ switch (elementName) {
42
+ case ElementName.AssignedToGroup:
43
+ return getFormattedMessageAsString(intl, messages.assigned_to, personName);
44
+ case ElementName.OwnedByGroup:
45
+ return getFormattedMessageAsString(intl, messages.owned_by, personName);
46
+ case ElementName.AuthorGroup:
47
+ return getFormattedMessageAsString(intl, messages.created_by, personName);
48
+ default:
49
+ return personName;
50
+ }
51
+ };
36
52
 
37
53
  /**
38
54
  * A base element that displays a group of avatars.
@@ -47,9 +63,22 @@ const AvatarGroup = ({
47
63
  name,
48
64
  overrideCss,
49
65
  size = SmartLinkSize.Medium,
50
- testId = 'smart-element-avatar-group'
66
+ testId = 'smart-element-avatar-group',
67
+ showNamePrefix = false
51
68
  }) => {
52
- if (!items.length) {
69
+ const intl = useIntl();
70
+ const data = useMemo(() => {
71
+ if (name && showNamePrefix) {
72
+ return items.map(person => {
73
+ return {
74
+ ...person,
75
+ name: getPersonNameWithPrefix(name, person.name, intl) || person.name
76
+ };
77
+ });
78
+ }
79
+ return items;
80
+ }, [name, items, showNamePrefix, intl]);
81
+ if (!data.length) {
53
82
  return null;
54
83
  }
55
84
  return jsx("span", {
@@ -62,7 +91,7 @@ const AvatarGroup = ({
62
91
  maxCount: maxCount,
63
92
  appearance: "stack",
64
93
  size: "small",
65
- data: items,
94
+ data: data,
66
95
  testId: testId
67
96
  }));
68
97
  };
@@ -22,6 +22,14 @@ export const getFormattedMessage = message => {
22
22
  }));
23
23
  }
24
24
  };
25
+ export const getFormattedMessageAsString = (intl, message, context) => {
26
+ const {
27
+ formatMessage
28
+ } = intl;
29
+ return message ? formatMessage(message, {
30
+ context
31
+ }) : null;
32
+ };
25
33
  const getIconDimensionStyles = value => css`
26
34
  height: ${value};
27
35
  min-height: ${value};
@@ -8,7 +8,7 @@ import LinkWarningModal from './LinkWarningModal';
8
8
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
9
9
  const PACKAGE_DATA = {
10
10
  packageName: "@atlaskit/smart-card",
11
- packageVersion: "26.16.1",
11
+ packageVersion: "26.17.0",
12
12
  componentName: 'linkUrl'
13
13
  };
14
14
  const Link = withLinkClickedEvent('a');
@@ -1,12 +1,19 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
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
+ 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; }
1
4
  import { ElementName } from '../../constants';
5
+ import { getBooleanFF } from '@atlaskit/platform-feature-flags';
6
+ var AvatarGroupsWithNamePrefix = [ElementName.AssignedToGroup, ElementName.OwnedByGroup, ElementName.AuthorGroup];
2
7
  export var elementNamesToItems = function elementNamesToItems(elementNames) {
3
8
  return elementNames.filter(function (element) {
4
9
  return element in ElementName;
5
10
  }).map(function (elementName) {
6
- return {
11
+ return _objectSpread({
7
12
  name: elementName,
8
13
  testId: "".concat(elementName.toLowerCase(), "-metadata-element")
9
- };
14
+ }, getBooleanFF('platform.linking-platform.smart-card.enable-better-metadata_iojwg') && AvatarGroupsWithNamePrefix.includes(elementName) && {
15
+ showNamePrefix: true
16
+ });
10
17
  });
11
18
  };
12
19
  export var extractMetadata = function extractMetadata(jsonLd) {
@@ -13,7 +13,7 @@ export var ANALYTICS_CHANNEL = 'media';
13
13
  export var context = {
14
14
  componentName: 'smart-cards',
15
15
  packageName: "@atlaskit/smart-card",
16
- packageVersion: "26.16.1"
16
+ packageVersion: "26.17.0"
17
17
  };
18
18
  export var TrackQuickActionType = /*#__PURE__*/function (TrackQuickActionType) {
19
19
  TrackQuickActionType["StatusUpdate"] = "StatusUpdate";
@@ -1,10 +1,17 @@
1
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
1
2
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
3
  var _templateObject, _templateObject2;
4
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
5
+ 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; }
3
6
  /** @jsx jsx */
4
- import React from 'react';
7
+ import React, { useMemo } from 'react';
5
8
  import { css, jsx } from '@emotion/react';
6
9
  import AtlaskitAvatarGroup from '@atlaskit/avatar-group';
7
10
  import { SmartLinkSize } from '../../../../../constants';
11
+ import { messages } from '../../../../../messages';
12
+ import { useIntl } from 'react-intl-next';
13
+ import { ElementName } from '../../../../../constants';
14
+ import { getFormattedMessageAsString } from '../../utils';
8
15
  var MAX_COUNT = 4;
9
16
  var getStyles = function getStyles(size) {
10
17
  var styles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: inline-flex;\n ul,\n ul {\n margin-right: 0.5rem;\n margin-top: 0;\n }\n "])));
@@ -19,6 +26,18 @@ var getStyles = function getStyles(size) {
19
26
  return css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n li {\n span,\n svg {\n max-height: 1.25rem;\n max-width: 1.25rem;\n }\n }\n "])), styles);
20
27
  }
21
28
  };
29
+ var getPersonNameWithPrefix = function getPersonNameWithPrefix(elementName, personName, intl) {
30
+ switch (elementName) {
31
+ case ElementName.AssignedToGroup:
32
+ return getFormattedMessageAsString(intl, messages.assigned_to, personName);
33
+ case ElementName.OwnedByGroup:
34
+ return getFormattedMessageAsString(intl, messages.owned_by, personName);
35
+ case ElementName.AuthorGroup:
36
+ return getFormattedMessageAsString(intl, messages.created_by, personName);
37
+ default:
38
+ return personName;
39
+ }
40
+ };
22
41
 
23
42
  /**
24
43
  * A base element that displays a group of avatars.
@@ -37,8 +56,21 @@ var AvatarGroup = function AvatarGroup(_ref) {
37
56
  _ref$size = _ref.size,
38
57
  size = _ref$size === void 0 ? SmartLinkSize.Medium : _ref$size,
39
58
  _ref$testId = _ref.testId,
40
- testId = _ref$testId === void 0 ? 'smart-element-avatar-group' : _ref$testId;
41
- if (!items.length) {
59
+ testId = _ref$testId === void 0 ? 'smart-element-avatar-group' : _ref$testId,
60
+ _ref$showNamePrefix = _ref.showNamePrefix,
61
+ showNamePrefix = _ref$showNamePrefix === void 0 ? false : _ref$showNamePrefix;
62
+ var intl = useIntl();
63
+ var data = useMemo(function () {
64
+ if (name && showNamePrefix) {
65
+ return items.map(function (person) {
66
+ return _objectSpread(_objectSpread({}, person), {}, {
67
+ name: getPersonNameWithPrefix(name, person.name, intl) || person.name
68
+ });
69
+ });
70
+ }
71
+ return items;
72
+ }, [name, items, showNamePrefix, intl]);
73
+ if (!data.length) {
42
74
  return null;
43
75
  }
44
76
  return jsx("span", {
@@ -51,7 +83,7 @@ var AvatarGroup = function AvatarGroup(_ref) {
51
83
  maxCount: maxCount,
52
84
  appearance: "stack",
53
85
  size: "small",
54
- data: items,
86
+ data: data,
55
87
  testId: testId
56
88
  }));
57
89
  };
@@ -18,6 +18,12 @@ export var getFormattedMessage = function getFormattedMessage(message) {
18
18
  }));
19
19
  }
20
20
  };
21
+ export var getFormattedMessageAsString = function getFormattedMessageAsString(intl, message, context) {
22
+ var formatMessage = intl.formatMessage;
23
+ return message ? formatMessage(message, {
24
+ context: context
25
+ }) : null;
26
+ };
21
27
  var getIconDimensionStyles = function getIconDimensionStyles(value) {
22
28
  return css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: ", ";\n min-height: ", ";\n max-height: ", ";\n width: ", ";\n min-width: ", ";\n max-width: ", ";\n"])), value, value, value, value, value, value);
23
29
  };
@@ -11,7 +11,7 @@ import LinkWarningModal from './LinkWarningModal';
11
11
  import { getBooleanFF } from '@atlaskit/platform-feature-flags';
12
12
  var PACKAGE_DATA = {
13
13
  packageName: "@atlaskit/smart-card",
14
- packageVersion: "26.16.1",
14
+ packageVersion: "26.17.0",
15
15
  componentName: 'linkUrl'
16
16
  };
17
17
  var Link = withLinkClickedEvent('a');
@@ -182,6 +182,10 @@ export type AttachmentCount = {
182
182
  */
183
183
  export type AuthorGroup = {
184
184
  name: ElementName.AuthorGroup;
185
+ /**
186
+ * Shows a name prefix Created by in the Avatar tooltip.
187
+ */
188
+ showNamePrefix?: boolean;
185
189
  };
186
190
  /**
187
191
  * Represents the props available for an OwnedByGroup element.
@@ -189,6 +193,10 @@ export type AuthorGroup = {
189
193
  */
190
194
  export type OwnedByGroup = {
191
195
  name: ElementName.OwnedByGroup;
196
+ /**
197
+ * Shows a name prefix Owned by in the Avatar tooltip.
198
+ */
199
+ showNamePrefix?: boolean;
192
200
  };
193
201
  /**
194
202
  * Represents the props available for an AssignedToGroup element.
@@ -196,6 +204,10 @@ export type OwnedByGroup = {
196
204
  */
197
205
  export type AssignedToGroup = {
198
206
  name: ElementName.AssignedToGroup;
207
+ /**
208
+ * Shows a name prefix Assigned To in the Avatar tooltip.
209
+ */
210
+ showNamePrefix?: boolean;
199
211
  };
200
212
  /**
201
213
  * Represents the props available for an ChecklistProgress element.
@@ -18,4 +18,8 @@ export type AvatarGroupProps = ElementProps & {
18
18
  * The maximum number of Avatars to show in the AvatarGroup
19
19
  */
20
20
  maxCount?: number;
21
+ /**
22
+ * Shows a name prefix in the Avatar tooltip (Created by, Assigned To, Owned by)
23
+ */
24
+ showNamePrefix?: boolean;
21
25
  };
@@ -5,8 +5,10 @@ import { SmartLinkSize } from '../../../constants';
5
5
  import { MessageProps } from './types';
6
6
  import { AnalyticsFacade } from '../../../state/analytics';
7
7
  import { PreviewActionData } from '../../../state/flexible-ui-context/types';
8
+ import { IntlShape, MessageDescriptor } from 'react-intl-next';
8
9
  export declare const sizeToButtonSpacing: Record<SmartLinkSize, Spacing>;
9
10
  export declare const getFormattedMessage: (message?: MessageProps) => JSX.Element | undefined;
11
+ export declare const getFormattedMessageAsString: (intl: IntlShape, message: MessageDescriptor, context?: string) => string | null;
10
12
  export declare const getIconSizeStyles: (width: string) => SerializedStyles;
11
13
  export declare const getIconWidth: (size?: SmartLinkSize) => string;
12
14
  export declare const getLinkLineHeight: (size: SmartLinkSize) => string;
@@ -182,6 +182,10 @@ export type AttachmentCount = {
182
182
  */
183
183
  export type AuthorGroup = {
184
184
  name: ElementName.AuthorGroup;
185
+ /**
186
+ * Shows a name prefix Created by in the Avatar tooltip.
187
+ */
188
+ showNamePrefix?: boolean;
185
189
  };
186
190
  /**
187
191
  * Represents the props available for an OwnedByGroup element.
@@ -189,6 +193,10 @@ export type AuthorGroup = {
189
193
  */
190
194
  export type OwnedByGroup = {
191
195
  name: ElementName.OwnedByGroup;
196
+ /**
197
+ * Shows a name prefix Owned by in the Avatar tooltip.
198
+ */
199
+ showNamePrefix?: boolean;
192
200
  };
193
201
  /**
194
202
  * Represents the props available for an AssignedToGroup element.
@@ -196,6 +204,10 @@ export type OwnedByGroup = {
196
204
  */
197
205
  export type AssignedToGroup = {
198
206
  name: ElementName.AssignedToGroup;
207
+ /**
208
+ * Shows a name prefix Assigned To in the Avatar tooltip.
209
+ */
210
+ showNamePrefix?: boolean;
199
211
  };
200
212
  /**
201
213
  * Represents the props available for an ChecklistProgress element.
@@ -18,4 +18,8 @@ export type AvatarGroupProps = ElementProps & {
18
18
  * The maximum number of Avatars to show in the AvatarGroup
19
19
  */
20
20
  maxCount?: number;
21
+ /**
22
+ * Shows a name prefix in the Avatar tooltip (Created by, Assigned To, Owned by)
23
+ */
24
+ showNamePrefix?: boolean;
21
25
  };
@@ -5,8 +5,10 @@ import { SmartLinkSize } from '../../../constants';
5
5
  import { MessageProps } from './types';
6
6
  import { AnalyticsFacade } from '../../../state/analytics';
7
7
  import { PreviewActionData } from '../../../state/flexible-ui-context/types';
8
+ import { IntlShape, MessageDescriptor } from 'react-intl-next';
8
9
  export declare const sizeToButtonSpacing: Record<SmartLinkSize, Spacing>;
9
10
  export declare const getFormattedMessage: (message?: MessageProps) => JSX.Element | undefined;
11
+ export declare const getFormattedMessageAsString: (intl: IntlShape, message: MessageDescriptor, context?: string) => string | null;
10
12
  export declare const getIconSizeStyles: (width: string) => SerializedStyles;
11
13
  export declare const getIconWidth: (size?: SmartLinkSize) => string;
12
14
  export declare const getLinkLineHeight: (size: SmartLinkSize) => string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "26.16.1",
3
+ "version": "26.17.0",
4
4
  "description": "Smart card component",
5
5
  "publishConfig": {
6
6
  "registry": "https://registry.npmjs.org/"
@@ -48,7 +48,7 @@
48
48
  "@atlaskit/popup": "^1.9.0",
49
49
  "@atlaskit/spinner": "^15.5.0",
50
50
  "@atlaskit/theme": "^12.5.0",
51
- "@atlaskit/tokens": "^1.16.0",
51
+ "@atlaskit/tokens": "^1.17.0",
52
52
  "@atlaskit/tooltip": "^17.8.0",
53
53
  "@atlaskit/ufo": "^0.2.0",
54
54
  "@babel/runtime": "^7.0.0",
package/report.api.md CHANGED
@@ -156,6 +156,7 @@ type AssignedTo = {
156
156
  // @public
157
157
  type AssignedToGroup = {
158
158
  name: ElementName.AssignedToGroup;
159
+ showNamePrefix?: boolean;
159
160
  };
160
161
 
161
162
  // @public
@@ -166,6 +167,7 @@ type AttachmentCount = {
166
167
  // @public
167
168
  type AuthorGroup = {
168
169
  name: ElementName.AuthorGroup;
170
+ showNamePrefix?: boolean;
169
171
  };
170
172
 
171
173
  // @public
@@ -738,6 +740,7 @@ type OwnedBy = {
738
740
  // @public
739
741
  type OwnedByGroup = {
740
742
  name: ElementName.OwnedByGroup;
743
+ showNamePrefix?: boolean;
741
744
  };
742
745
 
743
746
  // @public
@@ -109,6 +109,7 @@ type AssignedTo = {
109
109
  // @public
110
110
  type AssignedToGroup = {
111
111
  name: ElementName.AssignedToGroup;
112
+ showNamePrefix?: boolean;
112
113
  };
113
114
 
114
115
  // @public
@@ -119,6 +120,7 @@ type AttachmentCount = {
119
120
  // @public
120
121
  type AuthorGroup = {
121
122
  name: ElementName.AuthorGroup;
123
+ showNamePrefix?: boolean;
122
124
  };
123
125
 
124
126
  // @public
@@ -590,6 +592,7 @@ type OwnedBy = {
590
592
  // @public
591
593
  type OwnedByGroup = {
592
594
  name: ElementName.OwnedByGroup;
595
+ showNamePrefix?: boolean;
593
596
  };
594
597
 
595
598
  // @public