@atlaskit/smart-card 17.4.0 → 17.4.3

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 (47) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/dist/cjs/constants.js +61 -13
  3. package/dist/cjs/index.js +6 -0
  4. package/dist/cjs/utils/flexible.js +2 -2
  5. package/dist/cjs/utils/token.js +14 -23
  6. package/dist/cjs/version.json +1 -1
  7. package/dist/cjs/view/CardWithUrl/component.js +1 -1
  8. package/dist/cjs/view/FlexibleCard/components/blocks/index.js +10 -2
  9. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/index.js +51 -0
  10. package/dist/cjs/view/FlexibleCard/components/blocks/snippet-block/types.js +5 -0
  11. package/dist/cjs/view/FlexibleCard/components/elements/text/index.js +6 -4
  12. package/dist/cjs/view/FlexibleCard/components/elements/utils.js +5 -1
  13. package/dist/cjs/view/FlexibleCard/components/utils.js +15 -1
  14. package/dist/es2019/constants.js +52 -13
  15. package/dist/es2019/index.js +1 -1
  16. package/dist/es2019/utils/flexible.js +2 -2
  17. package/dist/es2019/utils/token.js +14 -21
  18. package/dist/es2019/version.json +1 -1
  19. package/dist/es2019/view/CardWithUrl/component.js +1 -1
  20. package/dist/es2019/view/FlexibleCard/components/blocks/index.js +3 -2
  21. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/index.js +29 -0
  22. package/dist/es2019/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  23. package/dist/es2019/view/FlexibleCard/components/elements/text/index.js +4 -3
  24. package/dist/es2019/view/FlexibleCard/components/elements/utils.js +4 -1
  25. package/dist/es2019/view/FlexibleCard/components/utils.js +11 -0
  26. package/dist/esm/constants.js +52 -13
  27. package/dist/esm/index.js +1 -1
  28. package/dist/esm/utils/flexible.js +2 -2
  29. package/dist/esm/utils/token.js +14 -21
  30. package/dist/esm/version.json +1 -1
  31. package/dist/esm/view/CardWithUrl/component.js +1 -1
  32. package/dist/esm/view/FlexibleCard/components/blocks/index.js +3 -2
  33. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/index.js +34 -0
  34. package/dist/esm/view/FlexibleCard/components/blocks/snippet-block/types.js +1 -0
  35. package/dist/esm/view/FlexibleCard/components/elements/text/index.js +6 -4
  36. package/dist/esm/view/FlexibleCard/components/elements/utils.js +4 -1
  37. package/dist/esm/view/FlexibleCard/components/utils.js +11 -0
  38. package/dist/types/constants.d.ts +51 -0
  39. package/dist/types/index.d.ts +1 -1
  40. package/dist/types/utils/flexible.d.ts +1 -2
  41. package/dist/types/utils/token.d.ts +13 -13
  42. package/dist/types/view/FlexibleCard/components/blocks/index.d.ts +2 -1
  43. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/index.d.ts +4 -0
  44. package/dist/types/view/FlexibleCard/components/blocks/snippet-block/types.d.ts +4 -0
  45. package/dist/types/view/FlexibleCard/components/elements/text/types.d.ts +1 -0
  46. package/dist/types/view/FlexibleCard/components/utils.d.ts +1 -0
  47. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atlaskit/smart-card
2
2
 
3
+ ## 17.4.3
4
+
5
+ ### Patch Changes
6
+
7
+ - [`5a50882a528`](https://bitbucket.org/atlassian/atlassian-frontend/commits/5a50882a528) - Flexible UI: Remove safeToken function
8
+
9
+ ## 17.4.2
10
+
11
+ ### Patch Changes
12
+
13
+ - [`c8285bdcde4`](https://bitbucket.org/atlassian/atlassian-frontend/commits/c8285bdcde4) - Flexible UI: Add SnippetBlock
14
+
15
+ ## 17.4.1
16
+
17
+ ### Patch Changes
18
+
19
+ - [`ecf130ca7d8`](https://bitbucket.org/atlassian/atlassian-frontend/commits/ecf130ca7d8) - Flexible UI: Remove check on Smart Links appearance
20
+
3
21
  ## 17.4.0
4
22
 
5
23
  ### Minor Changes
@@ -4,7 +4,17 @@ Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
6
  exports.SmartLinkWidth = exports.SmartLinkTheme = exports.SmartLinkStatus = exports.SmartLinkSize = exports.SmartLinkPosition = exports.SmartLinkDirection = exports.SmartLinkAlignment = exports.IconType = exports.ElementName = exports.ActionName = void 0;
7
+
8
+ /**
9
+ * The alignment of Flexible UI component.
10
+ */
7
11
  var SmartLinkAlignment;
12
+ /**
13
+ * The direction of Flexible UI components. It establish the main-axis
14
+ * or how the child components laid out inside the parent component.
15
+ * Similar to flex's flex-direction concept.
16
+ */
17
+
8
18
  exports.SmartLinkAlignment = SmartLinkAlignment;
9
19
 
10
20
  (function (SmartLinkAlignment) {
@@ -13,6 +23,11 @@ exports.SmartLinkAlignment = SmartLinkAlignment;
13
23
  })(SmartLinkAlignment || (exports.SmartLinkAlignment = SmartLinkAlignment = {}));
14
24
 
15
25
  var SmartLinkDirection;
26
+ /**
27
+ * The positioning of the component within the parent component.
28
+ * Similar to flex's align-items or align-self concept.
29
+ */
30
+
16
31
  exports.SmartLinkDirection = SmartLinkDirection;
17
32
 
18
33
  (function (SmartLinkDirection) {
@@ -21,6 +36,12 @@ exports.SmartLinkDirection = SmartLinkDirection;
21
36
  })(SmartLinkDirection || (exports.SmartLinkDirection = SmartLinkDirection = {}));
22
37
 
23
38
  var SmartLinkPosition;
39
+ /**
40
+ * The sizing options of the Flexible UI component. Every component
41
+ * has or inherits the sizing props. Implementation varies
42
+ * as per component.
43
+ */
44
+
24
45
  exports.SmartLinkPosition = SmartLinkPosition;
25
46
 
26
47
  (function (SmartLinkPosition) {
@@ -29,6 +50,10 @@ exports.SmartLinkPosition = SmartLinkPosition;
29
50
  })(SmartLinkPosition || (exports.SmartLinkPosition = SmartLinkPosition = {}));
30
51
 
31
52
  var SmartLinkSize;
53
+ /**
54
+ * Smart Links link request status
55
+ */
56
+
32
57
  exports.SmartLinkSize = SmartLinkSize;
33
58
 
34
59
  (function (SmartLinkSize) {
@@ -39,6 +64,11 @@ exports.SmartLinkSize = SmartLinkSize;
39
64
  })(SmartLinkSize || (exports.SmartLinkSize = SmartLinkSize = {}));
40
65
 
41
66
  var SmartLinkStatus;
67
+ /**
68
+ * Flexible UI theme available on the Card level.
69
+ * This determine the styling of the link.
70
+ */
71
+
42
72
  exports.SmartLinkStatus = SmartLinkStatus;
43
73
 
44
74
  (function (SmartLinkStatus) {
@@ -53,6 +83,12 @@ exports.SmartLinkStatus = SmartLinkStatus;
53
83
  })(SmartLinkStatus || (exports.SmartLinkStatus = SmartLinkStatus = {}));
54
84
 
55
85
  var SmartLinkTheme;
86
+ /**
87
+ * Determines whether the container size will fit to the content
88
+ * or expand to the available width or the parent component.
89
+ * Similar to flex's flex-grow concept.
90
+ */
91
+
56
92
  exports.SmartLinkTheme = SmartLinkTheme;
57
93
 
58
94
  (function (SmartLinkTheme) {
@@ -60,19 +96,23 @@ exports.SmartLinkTheme = SmartLinkTheme;
60
96
  SmartLinkTheme["Link"] = "link";
61
97
  })(SmartLinkTheme || (exports.SmartLinkTheme = SmartLinkTheme = {}));
62
98
 
63
- var SmartLinkWidth; // When adding an element...
64
- // 1) Create base element if it doesn't already existed.
65
- // Base element are inside src/view/FlexibleCard/components/elements.
66
- // E.g. Badge,DateTime, Icon, Lozenge, etc.
67
- // 2) Update FlexibleUiContext with the new prop for data representing
68
- // the element, preferably with the same name as the element itself.
69
- // (src/state/flexible-ui-context/types.ts)
70
- // 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
71
- // 4) Set base element and data mapping.
72
- // (src/view/FlexibleCard/components/elements/utils.tsx)
73
- // 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
74
- // 6) Update element ElementDisplaySchema for inline/block display
75
- // (src/view/FlexibleCard/components/blocks/utils.tsx)
99
+ var SmartLinkWidth;
100
+ /**
101
+ * Flexible UI element name - each reflecting the link data its represented.
102
+ * When adding an element...
103
+ * 1) Create base element if it doesn't already existed.
104
+ * Base element are inside src/view/FlexibleCard/components/elements.
105
+ * E.g. Badge,DateTime, Icon, Lozenge, etc.
106
+ * 2) Update FlexibleUiContext with the new prop for data representing
107
+ * the element, preferably with the same name as the element itself.
108
+ * (src/state/flexible-ui-context/types.ts)
109
+ * 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
110
+ * 4) Set base element and data mapping
111
+ * (src/view/FlexibleCard/components/elements/utils.tsx)
112
+ * 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
113
+ * 6) Update element ElementDisplaySchema for inline/block display
114
+ * (src/view/FlexibleCard/components/blocks/utils.tsx)
115
+ */
76
116
 
77
117
  exports.SmartLinkWidth = SmartLinkWidth;
78
118
 
@@ -82,6 +122,10 @@ exports.SmartLinkWidth = SmartLinkWidth;
82
122
  })(SmartLinkWidth || (exports.SmartLinkWidth = SmartLinkWidth = {}));
83
123
 
84
124
  var ElementName;
125
+ /**
126
+ * Flexible UI action (button)
127
+ */
128
+
85
129
  exports.ElementName = ElementName;
86
130
 
87
131
  (function (ElementName) {
@@ -103,6 +147,10 @@ exports.ElementName = ElementName;
103
147
  })(ElementName || (exports.ElementName = ElementName = {}));
104
148
 
105
149
  var ActionName;
150
+ /**
151
+ * Flexible UI icons - each mapped to AK icons.
152
+ */
153
+
106
154
  exports.ActionName = ActionName;
107
155
 
108
156
  (function (ActionName) {
package/dist/cjs/index.js CHANGED
@@ -101,6 +101,12 @@ Object.defineProperty(exports, "SmartLinkTheme", {
101
101
  return _constants.SmartLinkTheme;
102
102
  }
103
103
  });
104
+ Object.defineProperty(exports, "SnippetBlock", {
105
+ enumerable: true,
106
+ get: function get() {
107
+ return _blocks.SnippetBlock;
108
+ }
109
+ });
104
110
  Object.defineProperty(exports, "TitleBlock", {
105
111
  enumerable: true,
106
112
  get: function get() {
@@ -19,8 +19,8 @@ function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "functio
19
19
 
20
20
  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; }
21
21
 
22
- var isFlexibleUiCard = function isFlexibleUiCard(appearance, children) {
23
- if ((appearance === 'inline' || appearance === 'block') && children && _react.default.Children.toArray(children).some(function (child) {
22
+ var isFlexibleUiCard = function isFlexibleUiCard(children) {
23
+ if (children && _react.default.Children.toArray(children).some(function (child) {
24
24
  return isFlexibleUiBlock(child);
25
25
  })) {
26
26
  return true;
@@ -3,32 +3,23 @@
3
3
  Object.defineProperty(exports, "__esModule", {
4
4
  value: true
5
5
  });
6
- exports.tokens = exports.safeToken = void 0;
6
+ exports.tokens = void 0;
7
7
 
8
8
  var _tokens = require("@atlaskit/tokens");
9
9
 
10
- // Temporary safeguard while @atlaskit/tokens is being developed
11
- var safeToken = function safeToken(path, fallback) {
12
- try {
13
- return (0, _tokens.token)(path, fallback);
14
- } catch (e) {
15
- return fallback;
16
- }
17
- };
18
-
19
- exports.safeToken = safeToken;
20
10
  var tokens = {
21
- actionIcon: safeToken('color.icon', '#44546F'),
22
- background: safeToken('elevation.surface', '#FFFFFF'),
23
- badgeIcon: safeToken('color.icon.subtle', '#626F86'),
24
- badgeText: safeToken('color.text.subtlest', '#626F86'),
25
- blackLink: safeToken('color.text.subtle', '#44546F'),
26
- blackLinkPressed: safeToken('color.text', '#172B4D'),
27
- blueLink: safeToken('color.link', '#0C66E4'),
28
- blueLinkPressed: safeToken('color.link.pressed', '#0055CC'),
29
- elevation: safeToken('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
30
- errorMessage: safeToken('color.text.disabled', '#6B778C'),
31
- errorMessageHover: safeToken('color.text.subtle', '#8993A4'),
32
- text: safeToken('color.text.subtlest', '#626F86')
11
+ actionIcon: (0, _tokens.token)('color.icon', '#44546F'),
12
+ background: (0, _tokens.token)('elevation.surface', '#FFFFFF'),
13
+ badgeIcon: (0, _tokens.token)('color.icon.subtle', '#626F86'),
14
+ badgeText: (0, _tokens.token)('color.text.subtlest', '#626F86'),
15
+ blackLink: (0, _tokens.token)('color.text.subtle', '#44546F'),
16
+ blackLinkPressed: (0, _tokens.token)('color.text', '#172B4D'),
17
+ blueLink: (0, _tokens.token)('color.link', '#0C66E4'),
18
+ blueLinkPressed: (0, _tokens.token)('color.link.pressed', '#0055CC'),
19
+ elevation: (0, _tokens.token)('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
20
+ errorMessage: (0, _tokens.token)('color.text.disabled', '#6B778C'),
21
+ errorMessageHover: (0, _tokens.token)('color.text.subtle', '#8993A4'),
22
+ snippet: (0, _tokens.token)('color.text', '#172B4D'),
23
+ text: (0, _tokens.token)('color.text.subtlest', '#626F86')
33
24
  };
34
25
  exports.tokens = tokens;
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.4.0",
3
+ "version": "17.4.3",
4
4
  "sideEffects": false
5
5
  }
@@ -109,7 +109,7 @@ function CardWithUrlContent(_ref) {
109
109
  throw error;
110
110
  }
111
111
 
112
- if ((0, _flexible.isFlexibleUiCard)(appearance, children)) {
112
+ if ((0, _flexible.isFlexibleUiCard)(children)) {
113
113
  return /*#__PURE__*/_react.default.createElement(_FlexibleCard.default, {
114
114
  cardState: state,
115
115
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -11,6 +11,12 @@ Object.defineProperty(exports, "MetadataBlock", {
11
11
  return _metadataBlock.default;
12
12
  }
13
13
  });
14
+ Object.defineProperty(exports, "SnippetBlock", {
15
+ enumerable: true,
16
+ get: function get() {
17
+ return _snippetBlock.default;
18
+ }
19
+ });
14
20
  Object.defineProperty(exports, "TitleBlock", {
15
21
  enumerable: true,
16
22
  get: function get() {
@@ -18,6 +24,8 @@ Object.defineProperty(exports, "TitleBlock", {
18
24
  }
19
25
  });
20
26
 
21
- var _titleBlock = _interopRequireDefault(require("./title-block"));
27
+ var _metadataBlock = _interopRequireDefault(require("./metadata-block"));
28
+
29
+ var _snippetBlock = _interopRequireDefault(require("./snippet-block"));
22
30
 
23
- var _metadataBlock = _interopRequireDefault(require("./metadata-block"));
31
+ var _titleBlock = _interopRequireDefault(require("./title-block"));
@@ -0,0 +1,51 @@
1
+ "use strict";
2
+
3
+ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
+
5
+ Object.defineProperty(exports, "__esModule", {
6
+ value: true
7
+ });
8
+ exports.default = void 0;
9
+
10
+ var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
11
+
12
+ var _objectWithoutProperties2 = _interopRequireDefault(require("@babel/runtime/helpers/objectWithoutProperties"));
13
+
14
+ var _react = _interopRequireDefault(require("react"));
15
+
16
+ var _block = _interopRequireDefault(require("../block"));
17
+
18
+ var _constants = require("../../../../../constants");
19
+
20
+ var _elements = require("../../elements");
21
+
22
+ var _utils = require("../../utils");
23
+
24
+ var _excluded = ["maxLines", "status", "testId"];
25
+ var DEFAULT_MAX_LINES = 3;
26
+ var MAXIMUM_MAX_LINES = 3;
27
+ var MINIMUM_MAX_LINES = 1;
28
+
29
+ var SnippetBlock = function SnippetBlock(_ref) {
30
+ var _ref$maxLines = _ref.maxLines,
31
+ maxLines = _ref$maxLines === void 0 ? DEFAULT_MAX_LINES : _ref$maxLines,
32
+ _ref$status = _ref.status,
33
+ status = _ref$status === void 0 ? _constants.SmartLinkStatus.Fallback : _ref$status,
34
+ _ref$testId = _ref.testId,
35
+ testId = _ref$testId === void 0 ? 'smart-block-snippet' : _ref$testId,
36
+ blockProps = (0, _objectWithoutProperties2.default)(_ref, _excluded);
37
+
38
+ if (status !== _constants.SmartLinkStatus.Resolved) {
39
+ return null;
40
+ }
41
+
42
+ var snippetMaxLines = (0, _utils.getMaxLines)(maxLines, DEFAULT_MAX_LINES, MAXIMUM_MAX_LINES, MINIMUM_MAX_LINES);
43
+ return /*#__PURE__*/_react.default.createElement(_block.default, (0, _extends2.default)({}, blockProps, {
44
+ testId: "".concat(testId, "-resolved-view")
45
+ }), /*#__PURE__*/_react.default.createElement(_elements.Snippet, {
46
+ maxLines: snippetMaxLines
47
+ }));
48
+ };
49
+
50
+ var _default = SnippetBlock;
51
+ exports.default = _default;
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+
3
+ Object.defineProperty(exports, "__esModule", {
4
+ value: true
5
+ });
@@ -19,12 +19,14 @@ var _token = require("../../../../../utils/token");
19
19
 
20
20
  var _templateObject;
21
21
 
22
- var getStyles = function getStyles(maxLines) {
23
- return (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), _token.tokens.text, (0, _utils.getTruncateStyles)(maxLines));
22
+ var getStyles = function getStyles(maxLines, color) {
23
+ return (0, _core.css)(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 0.75rem;\n line-height: 1rem;\n ", "\n"])), color, (0, _utils.getTruncateStyles)(maxLines));
24
24
  };
25
25
 
26
26
  var Text = function Text(_ref) {
27
- var content = _ref.content,
27
+ var _ref$color = _ref.color,
28
+ color = _ref$color === void 0 ? _token.tokens.text : _ref$color,
29
+ content = _ref.content,
28
30
  _ref$maxLines = _ref.maxLines,
29
31
  maxLines = _ref$maxLines === void 0 ? 1 : _ref$maxLines,
30
32
  message = _ref.message,
@@ -36,7 +38,7 @@ var Text = function Text(_ref) {
36
38
  }
37
39
 
38
40
  return (0, _core.jsx)("span", {
39
- css: getStyles(maxLines),
41
+ css: getStyles(maxLines, color),
40
42
  "data-smart-element-text": true,
41
43
  "data-testid": testId
42
44
  }, (0, _utils.getFormattedMessage)(message) || content);
@@ -35,12 +35,15 @@ var _messages = require("../../../../messages");
35
35
 
36
36
  var _dateTime = _interopRequireDefault(require("./date-time"));
37
37
 
38
+ var _token = require("../../../../utils/token");
39
+
38
40
  var _elementMappings;
39
41
 
40
42
  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); }
41
43
 
42
44
  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; }
43
45
 
46
+ var SNIPPET_DEFAULT_MAX_LINES = 3;
44
47
  var elementMappings = (_elementMappings = {}, (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.AuthorGroup, {
45
48
  component: _avatarGroup.default
46
49
  }), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.CollaboratorGroup, {
@@ -66,7 +69,8 @@ var elementMappings = (_elementMappings = {}, (0, _defineProperty2.default)(_ele
66
69
  }), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.Snippet, {
67
70
  component: _text.default,
68
71
  props: {
69
- maxLines: 3
72
+ color: _token.tokens.snippet,
73
+ maxLines: SNIPPET_DEFAULT_MAX_LINES
70
74
  }
71
75
  }), (0, _defineProperty2.default)(_elementMappings, _constants.ElementName.State, {
72
76
  component: _lozenge.default
@@ -5,7 +5,7 @@ var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefau
5
5
  Object.defineProperty(exports, "__esModule", {
6
6
  value: true
7
7
  });
8
- exports.getTruncateStyles = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconSizeStyles = exports.getFormattedMessage = void 0;
8
+ exports.getTruncateStyles = exports.getMaxLines = exports.getLinkSizeStyles = exports.getLinkLineHeight = exports.getIconSizeStyles = exports.getFormattedMessage = void 0;
9
9
 
10
10
  var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
11
11
 
@@ -76,6 +76,20 @@ var getLinkSizeStyles = function getLinkSizeStyles(size) {
76
76
 
77
77
  exports.getLinkSizeStyles = getLinkSizeStyles;
78
78
 
79
+ var getMaxLines = function getMaxLines(value, defaultValue, max, min) {
80
+ if (value > max) {
81
+ return defaultValue;
82
+ }
83
+
84
+ if (value < min) {
85
+ return min;
86
+ }
87
+
88
+ return value;
89
+ };
90
+
91
+ exports.getMaxLines = getMaxLines;
92
+
79
93
  var getTruncateStyles = function getTruncateStyles(maxLines) {
80
94
  var lineHeight = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '1rem';
81
95
  return (0, _core.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n display: -webkit-box;\n overflow: hidden;\n text-overflow: ellipsis;\n word-break: break-word;\n -webkit-line-clamp: ", ";\n -webkit-box-orient: vertical;\n // Fallback options\n max-height: calc(", " * ", ");\n "])), maxLines, maxLines, lineHeight);
@@ -1,4 +1,12 @@
1
+ /**
2
+ * The alignment of Flexible UI component.
3
+ */
1
4
  export let SmartLinkAlignment;
5
+ /**
6
+ * The direction of Flexible UI components. It establish the main-axis
7
+ * or how the child components laid out inside the parent component.
8
+ * Similar to flex's flex-direction concept.
9
+ */
2
10
 
3
11
  (function (SmartLinkAlignment) {
4
12
  SmartLinkAlignment["Left"] = "left";
@@ -6,6 +14,10 @@ export let SmartLinkAlignment;
6
14
  })(SmartLinkAlignment || (SmartLinkAlignment = {}));
7
15
 
8
16
  export let SmartLinkDirection;
17
+ /**
18
+ * The positioning of the component within the parent component.
19
+ * Similar to flex's align-items or align-self concept.
20
+ */
9
21
 
10
22
  (function (SmartLinkDirection) {
11
23
  SmartLinkDirection["Horizontal"] = "horizontal";
@@ -13,6 +25,11 @@ export let SmartLinkDirection;
13
25
  })(SmartLinkDirection || (SmartLinkDirection = {}));
14
26
 
15
27
  export let SmartLinkPosition;
28
+ /**
29
+ * The sizing options of the Flexible UI component. Every component
30
+ * has or inherits the sizing props. Implementation varies
31
+ * as per component.
32
+ */
16
33
 
17
34
  (function (SmartLinkPosition) {
18
35
  SmartLinkPosition["Top"] = "top";
@@ -20,6 +37,9 @@ export let SmartLinkPosition;
20
37
  })(SmartLinkPosition || (SmartLinkPosition = {}));
21
38
 
22
39
  export let SmartLinkSize;
40
+ /**
41
+ * Smart Links link request status
42
+ */
23
43
 
24
44
  (function (SmartLinkSize) {
25
45
  SmartLinkSize["XLarge"] = "xlarge";
@@ -29,6 +49,10 @@ export let SmartLinkSize;
29
49
  })(SmartLinkSize || (SmartLinkSize = {}));
30
50
 
31
51
  export let SmartLinkStatus;
52
+ /**
53
+ * Flexible UI theme available on the Card level.
54
+ * This determine the styling of the link.
55
+ */
32
56
 
33
57
  (function (SmartLinkStatus) {
34
58
  SmartLinkStatus["Pending"] = "pending";
@@ -42,25 +66,34 @@ export let SmartLinkStatus;
42
66
  })(SmartLinkStatus || (SmartLinkStatus = {}));
43
67
 
44
68
  export let SmartLinkTheme;
69
+ /**
70
+ * Determines whether the container size will fit to the content
71
+ * or expand to the available width or the parent component.
72
+ * Similar to flex's flex-grow concept.
73
+ */
45
74
 
46
75
  (function (SmartLinkTheme) {
47
76
  SmartLinkTheme["Black"] = "black";
48
77
  SmartLinkTheme["Link"] = "link";
49
78
  })(SmartLinkTheme || (SmartLinkTheme = {}));
50
79
 
51
- export let SmartLinkWidth; // When adding an element...
52
- // 1) Create base element if it doesn't already existed.
53
- // Base element are inside src/view/FlexibleCard/components/elements.
54
- // E.g. Badge,DateTime, Icon, Lozenge, etc.
55
- // 2) Update FlexibleUiContext with the new prop for data representing
56
- // the element, preferably with the same name as the element itself.
57
- // (src/state/flexible-ui-context/types.ts)
58
- // 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
59
- // 4) Set base element and data mapping.
60
- // (src/view/FlexibleCard/components/elements/utils.tsx)
61
- // 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
62
- // 6) Update element ElementDisplaySchema for inline/block display
63
- // (src/view/FlexibleCard/components/blocks/utils.tsx)
80
+ export let SmartLinkWidth;
81
+ /**
82
+ * Flexible UI element name - each reflecting the link data its represented.
83
+ * When adding an element...
84
+ * 1) Create base element if it doesn't already existed.
85
+ * Base element are inside src/view/FlexibleCard/components/elements.
86
+ * E.g. Badge,DateTime, Icon, Lozenge, etc.
87
+ * 2) Update FlexibleUiContext with the new prop for data representing
88
+ * the element, preferably with the same name as the element itself.
89
+ * (src/state/flexible-ui-context/types.ts)
90
+ * 3) Update Flexible UI extractor (src/extractors/flexible/index.ts)
91
+ * 4) Set base element and data mapping
92
+ * (src/view/FlexibleCard/components/elements/utils.tsx)
93
+ * 5) Create element. (src/view/FlexibleCard/components/elements/index.ts)
94
+ * 6) Update element ElementDisplaySchema for inline/block display
95
+ * (src/view/FlexibleCard/components/blocks/utils.tsx)
96
+ */
64
97
 
65
98
  (function (SmartLinkWidth) {
66
99
  SmartLinkWidth["FitToContent"] = "fit-to-content";
@@ -68,6 +101,9 @@ export let SmartLinkWidth; // When adding an element...
68
101
  })(SmartLinkWidth || (SmartLinkWidth = {}));
69
102
 
70
103
  export let ElementName;
104
+ /**
105
+ * Flexible UI action (button)
106
+ */
71
107
 
72
108
  (function (ElementName) {
73
109
  ElementName["AuthorGroup"] = "AuthorGroup";
@@ -88,6 +124,9 @@ export let ElementName;
88
124
  })(ElementName || (ElementName = {}));
89
125
 
90
126
  export let ActionName;
127
+ /**
128
+ * Flexible UI icons - each mapped to AK icons.
129
+ */
91
130
 
92
131
  (function (ActionName) {
93
132
  ActionName["DeleteAction"] = "DeleteAction";
@@ -13,4 +13,4 @@ export { contentFooterClassName, metadataListClassName, blockCardResolvingViewCl
13
13
  export { loadingPlaceholderClassName } from './view/CardWithUrl/component-lazy/LazyFallback'; // Flexible UI
14
14
 
15
15
  export { ActionName, ElementName, SmartLinkDirection, SmartLinkPosition, SmartLinkSize, SmartLinkTheme } from './constants';
16
- export { MetadataBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
16
+ export { MetadataBlock, SnippetBlock, TitleBlock } from './view/FlexibleCard/components/blocks';
@@ -2,8 +2,8 @@ import React from 'react';
2
2
  import * as Blocks from '../view/FlexibleCard/components/blocks';
3
3
  import { TitleBlock } from '../view/FlexibleCard/components/blocks';
4
4
  import * as Elements from '../view/FlexibleCard/components/elements';
5
- export const isFlexibleUiCard = (appearance, children) => {
6
- if ((appearance === 'inline' || appearance === 'block') && children && React.Children.toArray(children).some(child => isFlexibleUiBlock(child))) {
5
+ export const isFlexibleUiCard = children => {
6
+ if (children && React.Children.toArray(children).some(child => isFlexibleUiBlock(child))) {
7
7
  return true;
8
8
  }
9
9
 
@@ -1,23 +1,16 @@
1
- import { token } from '@atlaskit/tokens'; // Temporary safeguard while @atlaskit/tokens is being developed
2
-
3
- export const safeToken = (path, fallback) => {
4
- try {
5
- return token(path, fallback);
6
- } catch (e) {
7
- return fallback;
8
- }
9
- };
1
+ import { token } from '@atlaskit/tokens';
10
2
  export const tokens = {
11
- actionIcon: safeToken('color.icon', '#44546F'),
12
- background: safeToken('elevation.surface', '#FFFFFF'),
13
- badgeIcon: safeToken('color.icon.subtle', '#626F86'),
14
- badgeText: safeToken('color.text.subtlest', '#626F86'),
15
- blackLink: safeToken('color.text.subtle', '#44546F'),
16
- blackLinkPressed: safeToken('color.text', '#172B4D'),
17
- blueLink: safeToken('color.link', '#0C66E4'),
18
- blueLinkPressed: safeToken('color.link.pressed', '#0055CC'),
19
- elevation: safeToken('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
20
- errorMessage: safeToken('color.text.disabled', '#6B778C'),
21
- errorMessageHover: safeToken('color.text.subtle', '#8993A4'),
22
- text: safeToken('color.text.subtlest', '#626F86')
3
+ actionIcon: token('color.icon', '#44546F'),
4
+ background: token('elevation.surface', '#FFFFFF'),
5
+ badgeIcon: token('color.icon.subtle', '#626F86'),
6
+ badgeText: token('color.text.subtlest', '#626F86'),
7
+ blackLink: token('color.text.subtle', '#44546F'),
8
+ blackLinkPressed: token('color.text', '#172B4D'),
9
+ blueLink: token('color.link', '#0C66E4'),
10
+ blueLinkPressed: token('color.link.pressed', '#0055CC'),
11
+ elevation: token('elevation.shadow.raised', '0px 1px 1px #091E4240, 0px 0px 1px #091E424F'),
12
+ errorMessage: token('color.text.disabled', '#6B778C'),
13
+ errorMessageHover: token('color.text.subtle', '#8993A4'),
14
+ snippet: token('color.text', '#172B4D'),
15
+ text: token('color.text.subtlest', '#626F86')
23
16
  };
@@ -1,5 +1,5 @@
1
1
  {
2
2
  "name": "@atlaskit/smart-card",
3
- "version": "17.4.0",
3
+ "version": "17.4.3",
4
4
  "sideEffects": false
5
5
  }
@@ -80,7 +80,7 @@ export function CardWithUrlContent({
80
80
  throw error;
81
81
  }
82
82
 
83
- if (isFlexibleUiCard(appearance, children)) {
83
+ if (isFlexibleUiCard(children)) {
84
84
  return /*#__PURE__*/React.createElement(FlexibleCard, {
85
85
  cardState: state,
86
86
  onAuthorize: services.length && handleAuthorize || undefined,
@@ -1,2 +1,3 @@
1
- export { default as TitleBlock } from './title-block';
2
- export { default as MetadataBlock } from './metadata-block';
1
+ export { default as MetadataBlock } from './metadata-block';
2
+ export { default as SnippetBlock } from './snippet-block';
3
+ export { default as TitleBlock } from './title-block';