@atlaskit/smart-card 26.9.15 → 26.9.17

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 (94) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/dist/cjs/state/helpers.js +1 -21
  3. package/dist/cjs/state/hooks/use-resolve/index.js +1 -2
  4. package/dist/cjs/version.json +1 -1
  5. package/dist/cjs/view/CardWithUrl/component.js +5 -2
  6. package/dist/cjs/view/InlineCard/Icon.js +0 -2
  7. package/dist/cjs/view/RedesignedInlineCard/ErroredView/index.js +90 -0
  8. package/dist/cjs/view/RedesignedInlineCard/ForbiddenView/index.js +129 -0
  9. package/dist/cjs/view/RedesignedInlineCard/Frame/index.js +63 -0
  10. package/dist/cjs/view/RedesignedInlineCard/Frame/styled.js +70 -0
  11. package/dist/cjs/view/RedesignedInlineCard/Icon.js +43 -0
  12. package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/index.js +151 -0
  13. package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +56 -0
  14. package/dist/cjs/view/RedesignedInlineCard/ResolvedView/index.js +83 -0
  15. package/dist/cjs/view/RedesignedInlineCard/ResolvingView/index.js +69 -0
  16. package/dist/cjs/view/RedesignedInlineCard/ResolvingView/styled.js +13 -0
  17. package/dist/cjs/view/RedesignedInlineCard/UnauthorisedView/index.js +113 -0
  18. package/dist/cjs/view/RedesignedInlineCard/index.js +183 -0
  19. package/dist/cjs/view/RedesignedInlineCard/styled.js +31 -0
  20. package/dist/cjs/view/RedesignedInlineCard/types.js +5 -0
  21. package/dist/cjs/view/RedesignedInlineCard/utils/withFrameStyleControl.js +42 -0
  22. package/dist/es2019/state/helpers.js +0 -22
  23. package/dist/es2019/state/hooks/use-resolve/index.js +1 -2
  24. package/dist/es2019/version.json +1 -1
  25. package/dist/es2019/view/CardWithUrl/component.js +5 -2
  26. package/dist/es2019/view/InlineCard/Icon.js +0 -2
  27. package/dist/es2019/view/RedesignedInlineCard/ErroredView/index.js +66 -0
  28. package/dist/es2019/view/RedesignedInlineCard/ForbiddenView/index.js +107 -0
  29. package/dist/es2019/view/RedesignedInlineCard/Frame/index.js +55 -0
  30. package/dist/es2019/view/RedesignedInlineCard/Frame/styled.js +107 -0
  31. package/dist/es2019/view/RedesignedInlineCard/Icon.js +45 -0
  32. package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/index.js +124 -0
  33. package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +97 -0
  34. package/dist/es2019/view/RedesignedInlineCard/ResolvedView/index.js +55 -0
  35. package/dist/es2019/view/RedesignedInlineCard/ResolvingView/index.js +44 -0
  36. package/dist/es2019/view/RedesignedInlineCard/ResolvingView/styled.js +6 -0
  37. package/dist/es2019/view/RedesignedInlineCard/UnauthorisedView/index.js +86 -0
  38. package/dist/es2019/view/RedesignedInlineCard/index.js +149 -0
  39. package/dist/es2019/view/RedesignedInlineCard/styled.js +52 -0
  40. package/dist/es2019/view/RedesignedInlineCard/types.js +1 -0
  41. package/dist/es2019/view/RedesignedInlineCard/utils/withFrameStyleControl.js +33 -0
  42. package/dist/esm/state/helpers.js +0 -19
  43. package/dist/esm/state/hooks/use-resolve/index.js +1 -2
  44. package/dist/esm/version.json +1 -1
  45. package/dist/esm/view/CardWithUrl/component.js +5 -2
  46. package/dist/esm/view/InlineCard/Icon.js +0 -2
  47. package/dist/esm/view/RedesignedInlineCard/ErroredView/index.js +82 -0
  48. package/dist/esm/view/RedesignedInlineCard/ForbiddenView/index.js +121 -0
  49. package/dist/esm/view/RedesignedInlineCard/Frame/index.js +53 -0
  50. package/dist/esm/view/RedesignedInlineCard/Frame/styled.js +61 -0
  51. package/dist/esm/view/RedesignedInlineCard/Icon.js +34 -0
  52. package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/index.js +143 -0
  53. package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +38 -0
  54. package/dist/esm/view/RedesignedInlineCard/ResolvedView/index.js +75 -0
  55. package/dist/esm/view/RedesignedInlineCard/ResolvingView/index.js +61 -0
  56. package/dist/esm/view/RedesignedInlineCard/ResolvingView/styled.js +5 -0
  57. package/dist/esm/view/RedesignedInlineCard/UnauthorisedView/index.js +105 -0
  58. package/dist/esm/view/RedesignedInlineCard/index.js +146 -0
  59. package/dist/esm/view/RedesignedInlineCard/styled.js +20 -0
  60. package/dist/esm/view/RedesignedInlineCard/types.js +1 -0
  61. package/dist/esm/view/RedesignedInlineCard/utils/withFrameStyleControl.js +35 -0
  62. package/dist/types/state/helpers.d.ts +0 -1
  63. package/dist/types/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
  64. package/dist/types/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
  65. package/dist/types/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
  66. package/dist/types/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
  67. package/dist/types/view/RedesignedInlineCard/Icon.d.ts +12 -0
  68. package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
  69. package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
  70. package/dist/types/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
  71. package/dist/types/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
  72. package/dist/types/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
  73. package/dist/types/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
  74. package/dist/types/view/RedesignedInlineCard/index.d.ts +9 -0
  75. package/dist/types/view/RedesignedInlineCard/styled.d.ts +17 -0
  76. package/dist/types/view/RedesignedInlineCard/types.d.ts +25 -0
  77. package/dist/types/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
  78. package/dist/types-ts4.5/state/helpers.d.ts +0 -1
  79. package/dist/types-ts4.5/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
  80. package/dist/types-ts4.5/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
  81. package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
  82. package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
  83. package/dist/types-ts4.5/view/RedesignedInlineCard/Icon.d.ts +12 -0
  84. package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
  85. package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
  86. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
  87. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
  88. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
  89. package/dist/types-ts4.5/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
  90. package/dist/types-ts4.5/view/RedesignedInlineCard/index.d.ts +9 -0
  91. package/dist/types-ts4.5/view/RedesignedInlineCard/styled.d.ts +17 -0
  92. package/dist/types-ts4.5/view/RedesignedInlineCard/types.d.ts +25 -0
  93. package/dist/types-ts4.5/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
  94. package/package.json +7 -4
@@ -0,0 +1,34 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import styled from '@emotion/styled';
4
+ import { Skeleton } from '@atlaskit/linking-common';
5
+ import React from 'react';
6
+
7
+ // TODO: Figure out a more scalable/responsive solution
8
+ // for vertical alignment.
9
+ // Current rationale: vertically positioned at the top of
10
+ // the smart card container (when set to 0). Offset this
11
+ // to position it with appropriate whitespace from the top.
12
+ export var Icon = styled.img(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n height: 14px;\n width: 14px;\n margin-right: ", ";\n border-radius: 2px;\n user-select: none;\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n"])), "var(--ds-space-050, 4px)");
13
+
14
+ // Used for 'untrue' icons which claim to be 16x16 but
15
+ // are less than that in height/width.
16
+ // TODO: Replace this override with proper AtlasKit solution.
17
+ export var AKIconWrapper = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n margin-right: calc(-1 * ", ");\n"])), "var(--ds-space-025, 2px)");
18
+ export var Shimmer = function Shimmer(_ref) {
19
+ var testId = _ref.testId;
20
+ var skeletonCustomStyles = {
21
+ position: 'absolute',
22
+ top: '50%',
23
+ left: '50%',
24
+ transform: 'translate(-50%, -50%)',
25
+ marginRight: "var(--ds-space-050, 4px)"
26
+ };
27
+ return /*#__PURE__*/React.createElement(Skeleton, {
28
+ width: 14,
29
+ height: 14,
30
+ borderRadius: 2,
31
+ testId: testId,
32
+ style: skeletonCustomStyles
33
+ });
34
+ };
@@ -0,0 +1,143 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
9
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
+ import React from 'react';
11
+ import ImageLoader from 'react-render-image';
12
+ import { Icon, Shimmer } from '../Icon';
13
+ import { IconEmptyWrapper, IconPositionWrapper, IconTitleWrapper, IconWrapper, TitleWrapper, EmojiWrapper, TitleWrapperClassName } from './styled';
14
+ import LinkIcon from '@atlaskit/icon/glyph/link';
15
+ import { LinkAppearance, NoLinkAppearance } from '../styled';
16
+ export var IconAndTitleLayout = /*#__PURE__*/function (_React$Component) {
17
+ _inherits(IconAndTitleLayout, _React$Component);
18
+ var _super = _createSuper(IconAndTitleLayout);
19
+ function IconAndTitleLayout() {
20
+ var _this;
21
+ _classCallCheck(this, IconAndTitleLayout);
22
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
23
+ args[_key] = arguments[_key];
24
+ }
25
+ _this = _super.call.apply(_super, [this].concat(args));
26
+ _defineProperty(_assertThisInitialized(_this), "handleClick", function (event) {
27
+ var onClick = _this.props.onClick;
28
+ if (onClick) {
29
+ event.preventDefault();
30
+ event.stopPropagation();
31
+ onClick(event);
32
+ }
33
+ });
34
+ _defineProperty(_assertThisInitialized(_this), "handleKeyPress", function (event) {
35
+ var onClick = _this.props.onClick;
36
+ if (event.key !== ' ' && event.key !== 'Enter') {
37
+ return;
38
+ }
39
+ if (onClick) {
40
+ event.preventDefault();
41
+ event.stopPropagation();
42
+ onClick(event);
43
+ }
44
+ });
45
+ return _this;
46
+ }
47
+ _createClass(IconAndTitleLayout, [{
48
+ key: "renderAtlaskitIcon",
49
+ value: function renderAtlaskitIcon() {
50
+ var _this$props = this.props,
51
+ icon = _this$props.icon,
52
+ emoji = _this$props.emoji;
53
+ if (emoji) {
54
+ return /*#__PURE__*/React.createElement(EmojiWrapper, null, emoji);
55
+ }
56
+ if (!icon || typeof icon === 'string') {
57
+ return null;
58
+ }
59
+ return /*#__PURE__*/React.createElement(IconWrapper, null, icon);
60
+ }
61
+ }, {
62
+ key: "renderImageIcon",
63
+ value: function renderImageIcon(errored, testId) {
64
+ var url = this.props.icon;
65
+ if (!url || typeof url !== 'string') {
66
+ return null;
67
+ }
68
+ return /*#__PURE__*/React.createElement(ImageLoader, {
69
+ src: url,
70
+ loaded: /*#__PURE__*/React.createElement(Icon, {
71
+ className: "smart-link-icon",
72
+ src: url,
73
+ "data-testid": "".concat(testId, "-image")
74
+ }),
75
+ errored: errored,
76
+ loading: /*#__PURE__*/React.createElement(Shimmer, {
77
+ testId: "".concat(testId, "-loading")
78
+ })
79
+ });
80
+ }
81
+ }, {
82
+ key: "renderIconPlaceholder",
83
+ value: function renderIconPlaceholder(testId) {
84
+ var defaultIcon = this.props.defaultIcon;
85
+ if (defaultIcon) {
86
+ return /*#__PURE__*/React.createElement(IconWrapper, null, defaultIcon);
87
+ }
88
+ return /*#__PURE__*/React.createElement(IconWrapper, null, /*#__PURE__*/React.createElement(LinkIcon, {
89
+ label: "link",
90
+ size: "small",
91
+ testId: "".concat(testId, "-default")
92
+ }));
93
+ }
94
+ }, {
95
+ key: "renderIcon",
96
+ value: function renderIcon(testId) {
97
+ // We render two kinds of icons here:
98
+ // - Image: acquired from either DAC or Teamwork Platform Apps;
99
+ // - Atlaskit Icon: an Atlaskit SVG;
100
+ // Each of these are scaled down to 12x12.
101
+ var icon = this.renderAtlaskitIcon();
102
+ if (icon) {
103
+ return icon;
104
+ }
105
+ var placeholder = this.renderIconPlaceholder(testId);
106
+ var image = this.renderImageIcon(placeholder, testId);
107
+ return image || placeholder;
108
+ }
109
+ }, {
110
+ key: "render",
111
+ value: function render() {
112
+ var _this$props2 = this.props,
113
+ children = _this$props2.children,
114
+ title = _this$props2.title,
115
+ titleColor = _this$props2.titleColor,
116
+ titleTextColor = _this$props2.titleTextColor,
117
+ link = _this$props2.link,
118
+ rightSide = _this$props2.rightSide,
119
+ _this$props2$testId = _this$props2.testId,
120
+ testId = _this$props2$testId === void 0 ? 'inline-card-icon-and-title' : _this$props2$testId;
121
+ var titlePart = /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconPositionWrapper, null, children || /*#__PURE__*/React.createElement(React.Fragment, null, /*#__PURE__*/React.createElement(IconEmptyWrapper, null), this.renderIcon(testId))), /*#__PURE__*/React.createElement(TitleWrapper, {
122
+ style: {
123
+ color: titleTextColor
124
+ },
125
+ className: TitleWrapperClassName
126
+ }, title));
127
+ return /*#__PURE__*/React.createElement(IconTitleWrapper, {
128
+ style: {
129
+ color: titleColor
130
+ },
131
+ "data-testid": testId
132
+ }, link ? /*#__PURE__*/React.createElement(LinkAppearance, {
133
+ href: link,
134
+ onClick: this.handleClick,
135
+ onKeyPress: this.handleKeyPress
136
+ }, titlePart) : titlePart, rightSide ? /*#__PURE__*/React.createElement(NoLinkAppearance, null, rightSide) : null);
137
+ }
138
+ }]);
139
+ return IconAndTitleLayout;
140
+ }(React.Component);
141
+ _defineProperty(IconAndTitleLayout, "defaultProps", {
142
+ rightSideSpacer: true
143
+ });
@@ -0,0 +1,38 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
3
+ import styled from '@emotion/styled';
4
+ // TODO: remove this override behaviour for @atlaskit/icon-object
5
+ export var IconObjectOverrides = "\n & > span {\n height: 16px;\n width: 14px;\n position: absolute;\n top: 3px;\n left: 0;\n line-height: 14px;\n & > svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n }\n";
6
+ // TODO: remove this override behaviour for @atlaskit/icon
7
+ export var IconOverrides = "\n\n & > * > span {\n height: 16px;\n width: 14px;\n position: absolute;\n left: 0;\n & > svg {\n position: absolute;\n top: 50%;\n left: 50%;\n transform: translate(-50%, -50%);\n }\n }\n";
8
+
9
+ // Wraps all icons represented in Inline Links. Icons have three sources/types:
10
+ // - JSON-LD: from the generator.icon property coming back from ORS.
11
+ // - @atlaskit/icon: for lock icons, unauthorized, etc.
12
+ // - @atlaskit/icon-object: for object icons, e.g. repository, branch, etc.
13
+ // NB: the first set of overrides style icons imported from @atlaskit/icon-object correctly.
14
+ // NB: the second set of overrides style icons imported from @atlaskit/icon correctly.
15
+ export var IconWrapper = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n user-select: none;\n ", "\n ", "\n"])), IconOverrides, IconObjectOverrides);
16
+
17
+ // Wraps all emoji in Inline Links similar to icon
18
+ export var EmojiWrapper = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n display: inline-block;\n margin-right: ", ";\n user-select: none;\n ", "\n ", "\n"])), "var(--ds-space-025, 2px)", IconOverrides, IconObjectOverrides);
19
+
20
+ // The main 'wrapping' element, title of the content.
21
+ // NB: `white-space` adds little whitespace before wrapping.
22
+ // NB: `word-break` line breaks as soon as an overflow takes place.
23
+ export var IconTitleWrapper = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n white-space: pre-wrap;\n word-break: break-all;\n box-decoration-break: clone;\n padding: ", " ", ";\n"])), "var(--ds-space-025, 2px)", "var(--ds-space-050, 4px)");
24
+
25
+ // TODO: Replace overrides with proper AtlasKit solution.
26
+ export var LozengeWrapper = styled.span(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: inline-block;\n vertical-align: 1px;\n margin: 0 ", " 0 ", ";\n"])), "var(--ds-space-050, 4px)", "var(--ds-space-025, 2px)");
27
+ export var RightIconPositionWrapper = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n margin-left: ", ";\n position: relative;\n display: inline-block;\n"])), "var(--ds-space-025, 2px)");
28
+
29
+ // The following components are used to absolutely position icons in the vertical center.
30
+ // - IconPositionWrapper: the `relative` parent which has no height in itself.
31
+ // - IconEmptyWrapper: the child which forces `IconPositionWrapper` to have a height.
32
+ export var IconPositionWrapper = styled.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n margin-right: ", ";\n position: relative;\n display: inline-block;\n"])), "var(--ds-space-050, 4px)");
33
+ export var IconEmptyWrapper = styled.span(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n width: 14px;\n height: 100%;\n display: inline-block;\n opacity: 0;\n"])));
34
+
35
+ // With emotion it's not possible to use reference to `TitleWrapper` as part of a selector,
36
+ // To achieve same result we use classname instead.
37
+ export var TitleWrapperClassName = 'smart-link-title-wrapper';
38
+ export var TitleWrapper = styled.span(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral([""])));
@@ -0,0 +1,75 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
+ import React from 'react';
9
+ import { Frame } from '../Frame';
10
+ import Lozenge from '@atlaskit/lozenge';
11
+ import { IconAndTitleLayout } from '../IconAndTitleLayout';
12
+ import { LozengeWrapper } from '../IconAndTitleLayout/styled';
13
+ import { HoverCard } from '../../HoverCard/index';
14
+ export var InlineCardResolvedView = /*#__PURE__*/function (_React$Component) {
15
+ _inherits(InlineCardResolvedView, _React$Component);
16
+ var _super = _createSuper(InlineCardResolvedView);
17
+ function InlineCardResolvedView() {
18
+ _classCallCheck(this, InlineCardResolvedView);
19
+ return _super.apply(this, arguments);
20
+ }
21
+ _createClass(InlineCardResolvedView, [{
22
+ key: "renderLozenge",
23
+ value: function renderLozenge() {
24
+ var lozenge = this.props.lozenge;
25
+ if (!lozenge) {
26
+ return null;
27
+ }
28
+ return /*#__PURE__*/React.createElement(LozengeWrapper, null, /*#__PURE__*/React.createElement(Lozenge, {
29
+ testId: "inline-card-resolved-view-lozenge",
30
+ appearance: lozenge.appearance || 'default',
31
+ isBold: lozenge.isBold
32
+ }, lozenge.text));
33
+ }
34
+ }, {
35
+ key: "render",
36
+ value: function render() {
37
+ var _this$props = this.props,
38
+ id = _this$props.id,
39
+ _this$props$title = _this$props.title,
40
+ title = _this$props$title === void 0 ? '' : _this$props$title,
41
+ isSelected = _this$props.isSelected,
42
+ onClick = _this$props.onClick,
43
+ icon = _this$props.icon,
44
+ link = _this$props.link,
45
+ _this$props$testId = _this$props.testId,
46
+ testId = _this$props$testId === void 0 ? 'inline-card-resolved-view' : _this$props$testId,
47
+ titleTextColor = _this$props.titleTextColor,
48
+ titlePrefix = _this$props.titlePrefix,
49
+ _this$props$showHover = _this$props.showHoverPreview,
50
+ showHoverPreview = _this$props$showHover === void 0 ? false : _this$props$showHover,
51
+ _this$props$showServe = _this$props.showServerActions,
52
+ showServerActions = _this$props$showServe === void 0 ? false : _this$props$showServe;
53
+ var inlineCardResolvedView = /*#__PURE__*/React.createElement(Frame, {
54
+ testId: testId,
55
+ link: link,
56
+ isSelected: isSelected,
57
+ onClick: onClick
58
+ }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
59
+ emoji: titlePrefix,
60
+ icon: icon,
61
+ title: title,
62
+ titleTextColor: titleTextColor
63
+ }), this.renderLozenge());
64
+ if (showHoverPreview && link) {
65
+ return /*#__PURE__*/React.createElement(HoverCard, {
66
+ id: id,
67
+ showServerActions: showServerActions,
68
+ url: link
69
+ }, inlineCardResolvedView);
70
+ }
71
+ return inlineCardResolvedView;
72
+ }
73
+ }]);
74
+ return InlineCardResolvedView;
75
+ }(React.Component);
@@ -0,0 +1,61 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/createClass";
3
+ import _inherits from "@babel/runtime/helpers/inherits";
4
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
5
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
6
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
7
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
8
+ import React from 'react';
9
+ import { Frame } from '../Frame';
10
+ import Spinner from '@atlaskit/spinner';
11
+ import { IconAndTitleLayout } from '../IconAndTitleLayout';
12
+ import { SpinnerWrapper } from './styled';
13
+ import { IconTitleWrapper, RightIconPositionWrapper } from '../IconAndTitleLayout/styled';
14
+ export var InlineCardResolvingView = /*#__PURE__*/function (_React$Component) {
15
+ _inherits(InlineCardResolvingView, _React$Component);
16
+ var _super = _createSuper(InlineCardResolvingView);
17
+ function InlineCardResolvingView() {
18
+ _classCallCheck(this, InlineCardResolvingView);
19
+ return _super.apply(this, arguments);
20
+ }
21
+ _createClass(InlineCardResolvingView, [{
22
+ key: "render",
23
+ value: function render() {
24
+ var _this$props = this.props,
25
+ url = _this$props.url,
26
+ onClick = _this$props.onClick,
27
+ isSelected = _this$props.isSelected,
28
+ inlinePreloaderStyle = _this$props.inlinePreloaderStyle,
29
+ _this$props$testId = _this$props.testId,
30
+ testId = _this$props$testId === void 0 ? 'inline-card-resolving-view' : _this$props$testId,
31
+ titleTextColor = _this$props.titleTextColor;
32
+ if (inlinePreloaderStyle === 'on-right-without-skeleton') {
33
+ return /*#__PURE__*/React.createElement(Frame, {
34
+ withoutBackground: true,
35
+ testId: testId,
36
+ onClick: onClick,
37
+ isSelected: isSelected
38
+ }, /*#__PURE__*/React.createElement(IconTitleWrapper, null, url, /*#__PURE__*/React.createElement(RightIconPositionWrapper, null, /*#__PURE__*/React.createElement(SpinnerWrapper, {
39
+ className: "inline-resolving-spinner"
40
+ }, /*#__PURE__*/React.createElement(Spinner, {
41
+ size: 14
42
+ })))));
43
+ } else {
44
+ return /*#__PURE__*/React.createElement(Frame, {
45
+ testId: testId,
46
+ onClick: onClick,
47
+ isSelected: isSelected
48
+ }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
49
+ link: url,
50
+ title: url,
51
+ titleTextColor: titleTextColor
52
+ }, /*#__PURE__*/React.createElement(SpinnerWrapper, {
53
+ className: "inline-resolving-spinner"
54
+ }, /*#__PURE__*/React.createElement(Spinner, {
55
+ size: 14
56
+ }))));
57
+ }
58
+ }
59
+ }]);
60
+ return InlineCardResolvingView;
61
+ }(React.Component);
@@ -0,0 +1,5 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject;
3
+ import styled from '@emotion/styled';
4
+ import { IconTitleWrapper } from '../IconAndTitleLayout/styled';
5
+ export var SpinnerWrapper = styled(IconTitleWrapper)(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n vertical-align: text-bottom;\n padding: 0px;\n"])));
@@ -0,0 +1,105 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
3
+ import _createClass from "@babel/runtime/helpers/createClass";
4
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
5
+ import _inherits from "@babel/runtime/helpers/inherits";
6
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
7
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
8
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
9
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
10
+ function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
11
+ import Button from '@atlaskit/button/custom-theme-button';
12
+ import LockIcon from '@atlaskit/icon/glyph/lock-filled';
13
+ import { N500, R400 } from '@atlaskit/theme/colors';
14
+ import withFrameStyleControl from '../utils/withFrameStyleControl';
15
+ import React from 'react';
16
+ import { FormattedMessage } from 'react-intl-next';
17
+ import { messages } from '../../../messages';
18
+ import { Frame } from '../Frame';
19
+ import { AKIconWrapper } from '../Icon';
20
+ import { IconAndTitleLayout } from '../IconAndTitleLayout';
21
+ import { IconStyledButton } from '../styled';
22
+ import { HoverCard } from '../../HoverCard';
23
+ var FallbackUnauthorizedIcon = /*#__PURE__*/React.createElement(AKIconWrapper, null, /*#__PURE__*/React.createElement(LockIcon, {
24
+ label: "error",
25
+ size: "small",
26
+ primaryColor: "var(--ds-icon-danger, ".concat(R400, ")")
27
+ }));
28
+ export var InlineCardUnauthorizedView = /*#__PURE__*/function (_React$Component) {
29
+ _inherits(InlineCardUnauthorizedView, _React$Component);
30
+ var _super = _createSuper(InlineCardUnauthorizedView);
31
+ function InlineCardUnauthorizedView() {
32
+ var _this;
33
+ _classCallCheck(this, InlineCardUnauthorizedView);
34
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
35
+ args[_key] = arguments[_key];
36
+ }
37
+ _this = _super.call.apply(_super, [this].concat(args));
38
+ _defineProperty(_assertThisInitialized(_this), "frameRef", /*#__PURE__*/React.createRef());
39
+ _defineProperty(_assertThisInitialized(_this), "handleConnectAccount", function (event) {
40
+ var _this$props = _this.props,
41
+ analytics = _this$props.analytics,
42
+ extensionKey = _this$props.extensionKey,
43
+ onAuthorise = _this$props.onAuthorise;
44
+ event.preventDefault();
45
+ event.stopPropagation();
46
+ if (onAuthorise) {
47
+ analytics === null || analytics === void 0 ? void 0 : analytics.track.appAccountAuthStarted({
48
+ extensionKey: extensionKey
49
+ });
50
+ }
51
+ return onAuthorise();
52
+ });
53
+ _defineProperty(_assertThisInitialized(_this), "renderActionButton", function () {
54
+ var _this$props2 = _this.props,
55
+ onAuthorise = _this$props2.onAuthorise,
56
+ context = _this$props2.context;
57
+ var ActionButton = withFrameStyleControl(Button, _this.frameRef);
58
+ return onAuthorise ? /*#__PURE__*/React.createElement(ActionButton, {
59
+ spacing: "none",
60
+ component: IconStyledButton,
61
+ onClick: _this.handleConnectAccount,
62
+ testId: "button-connect-account"
63
+ }, /*#__PURE__*/React.createElement(FormattedMessage, _extends({}, messages.connect_link_account_card_name, {
64
+ values: {
65
+ context: context
66
+ }
67
+ }))) : undefined;
68
+ });
69
+ return _this;
70
+ }
71
+ _createClass(InlineCardUnauthorizedView, [{
72
+ key: "render",
73
+ value: function render() {
74
+ var _this$props3 = this.props,
75
+ url = _this$props3.url,
76
+ icon = _this$props3.icon,
77
+ onClick = _this$props3.onClick,
78
+ isSelected = _this$props3.isSelected,
79
+ _this$props3$testId = _this$props3.testId,
80
+ testId = _this$props3$testId === void 0 ? 'inline-card-unauthorized-view' : _this$props3$testId,
81
+ _this$props3$showAuth = _this$props3.showAuthTooltip,
82
+ showAuthTooltip = _this$props3$showAuth === void 0 ? false : _this$props3$showAuth;
83
+ var inlineCardUnauthenticatedView = /*#__PURE__*/React.createElement(Frame, {
84
+ testId: testId,
85
+ isSelected: isSelected,
86
+ ref: this.frameRef
87
+ }, /*#__PURE__*/React.createElement(IconAndTitleLayout, {
88
+ icon: icon ? icon : FallbackUnauthorizedIcon,
89
+ title: url,
90
+ link: url,
91
+ onClick: onClick,
92
+ titleColor: "var(--ds-text-subtle, ".concat(N500, ")")
93
+ }), this.renderActionButton());
94
+ if (showAuthTooltip) {
95
+ return /*#__PURE__*/React.createElement(HoverCard, {
96
+ url: url,
97
+ onAuthorize: this.props.onAuthorise,
98
+ id: this.props.id
99
+ }, inlineCardUnauthenticatedView);
100
+ }
101
+ return inlineCardUnauthenticatedView;
102
+ }
103
+ }]);
104
+ return InlineCardUnauthorizedView;
105
+ }(React.Component);
@@ -0,0 +1,146 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import React from 'react';
3
+ import { getEmptyJsonLd, getForbiddenJsonLd } from '../../utils/jsonld';
4
+ import { extractInlineProps } from '../../extractors/inline';
5
+ import { extractRequestAccessContext } from '../../extractors/common/context';
6
+ import { CardLinkView } from '../LinkView';
7
+ import { InlineCardErroredView } from './ErroredView';
8
+ import { InlineCardForbiddenView } from './ForbiddenView';
9
+ import { InlineCardResolvedView } from './ResolvedView';
10
+ import { InlineCardResolvingView } from './ResolvingView';
11
+ import { InlineCardUnauthorizedView } from './UnauthorisedView';
12
+ import { extractProvider } from '@atlaskit/link-extractors';
13
+ import { useFeatureFlag } from '@atlaskit/link-provider';
14
+ import { getExtensionKey } from '../../state/helpers';
15
+ export { InlineCardResolvedView, InlineCardResolvingView, InlineCardErroredView, InlineCardForbiddenView, InlineCardUnauthorizedView };
16
+ export var InlineCard = function InlineCard(_ref) {
17
+ var _details$meta;
18
+ var analytics = _ref.analytics,
19
+ id = _ref.id,
20
+ url = _ref.url,
21
+ cardState = _ref.cardState,
22
+ handleAuthorize = _ref.handleAuthorize,
23
+ handleFrameClick = _ref.handleFrameClick,
24
+ isSelected = _ref.isSelected,
25
+ renderers = _ref.renderers,
26
+ onResolve = _ref.onResolve,
27
+ onError = _ref.onError,
28
+ testId = _ref.testId,
29
+ inlinePreloaderStyle = _ref.inlinePreloaderStyle,
30
+ showHoverPreview = _ref.showHoverPreview,
31
+ showAuthTooltip = _ref.showAuthTooltip,
32
+ showServerActions = _ref.showServerActions;
33
+ var status = cardState.status,
34
+ details = cardState.details;
35
+ var cardDetails = details && details.data || getEmptyJsonLd();
36
+ var extensionKey = getExtensionKey(details);
37
+ var testIdWithStatus = testId ? "".concat(testId, "-").concat(status, "-view") : undefined;
38
+ var showHoverPreviewFlag = useFeatureFlag('showHoverPreview');
39
+ if (showHoverPreview === undefined && showHoverPreviewFlag !== undefined) {
40
+ showHoverPreview = Boolean(showHoverPreviewFlag);
41
+ }
42
+ switch (status) {
43
+ case 'pending':
44
+ case 'resolving':
45
+ return /*#__PURE__*/React.createElement(InlineCardResolvingView, {
46
+ url: url,
47
+ isSelected: isSelected,
48
+ onClick: handleFrameClick,
49
+ testId: testIdWithStatus,
50
+ inlinePreloaderStyle: inlinePreloaderStyle
51
+ });
52
+ case 'resolved':
53
+ var resolvedProps = extractInlineProps(cardDetails, renderers);
54
+ if (onResolve) {
55
+ onResolve({
56
+ url: url,
57
+ title: resolvedProps.title
58
+ });
59
+ }
60
+ return /*#__PURE__*/React.createElement(InlineCardResolvedView, _extends({}, resolvedProps, {
61
+ id: id,
62
+ showHoverPreview: showHoverPreview,
63
+ showServerActions: showServerActions,
64
+ link: url,
65
+ isSelected: isSelected,
66
+ onClick: handleFrameClick,
67
+ testId: testIdWithStatus
68
+ }));
69
+ case 'unauthorized':
70
+ if (onError) {
71
+ onError({
72
+ url: url,
73
+ status: status
74
+ });
75
+ }
76
+ var provider = extractProvider(cardDetails);
77
+ return /*#__PURE__*/React.createElement(InlineCardUnauthorizedView, {
78
+ icon: provider && provider.icon,
79
+ context: provider && provider.text,
80
+ url: url,
81
+ isSelected: isSelected,
82
+ onClick: handleFrameClick,
83
+ onAuthorise: handleAuthorize,
84
+ testId: testIdWithStatus,
85
+ showAuthTooltip: showAuthTooltip,
86
+ id: id,
87
+ analytics: analytics,
88
+ extensionKey: extensionKey
89
+ });
90
+ case 'forbidden':
91
+ if (onError) {
92
+ onError({
93
+ url: url,
94
+ status: status
95
+ });
96
+ }
97
+ var providerForbidden = extractProvider(cardDetails);
98
+ var cardMetadata = (_details$meta = details === null || details === void 0 ? void 0 : details.meta) !== null && _details$meta !== void 0 ? _details$meta : getForbiddenJsonLd().meta;
99
+ var requestAccessContext = extractRequestAccessContext({
100
+ jsonLd: cardMetadata,
101
+ url: url,
102
+ context: providerForbidden === null || providerForbidden === void 0 ? void 0 : providerForbidden.text
103
+ });
104
+ return /*#__PURE__*/React.createElement(InlineCardForbiddenView, {
105
+ url: url,
106
+ icon: providerForbidden && providerForbidden.icon,
107
+ context: providerForbidden === null || providerForbidden === void 0 ? void 0 : providerForbidden.text,
108
+ isSelected: isSelected,
109
+ onClick: handleFrameClick,
110
+ onAuthorise: handleAuthorize,
111
+ testId: testIdWithStatus,
112
+ requestAccessContext: requestAccessContext
113
+ });
114
+ case 'not_found':
115
+ if (onError) {
116
+ onError({
117
+ url: url,
118
+ status: status
119
+ });
120
+ }
121
+ var providerNotFound = extractProvider(cardDetails);
122
+ return /*#__PURE__*/React.createElement(InlineCardErroredView, {
123
+ url: url,
124
+ icon: providerNotFound && providerNotFound.icon,
125
+ isSelected: isSelected,
126
+ message: "Can't find link",
127
+ onClick: handleFrameClick,
128
+ testId: testIdWithStatus || 'inline-card-not-found-view'
129
+ });
130
+ case 'fallback':
131
+ case 'errored':
132
+ default:
133
+ if (onError) {
134
+ onError({
135
+ url: url,
136
+ status: status
137
+ });
138
+ }
139
+ return /*#__PURE__*/React.createElement(CardLinkView, {
140
+ link: url,
141
+ isSelected: isSelected,
142
+ onClick: handleFrameClick,
143
+ testId: testIdWithStatus || 'inline-card-errored-view'
144
+ });
145
+ }
146
+ };
@@ -0,0 +1,20 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4;
3
+ import styled from '@emotion/styled';
4
+ import { B400, N200 } from '@atlaskit/theme/colors';
5
+ import { themed } from '@atlaskit/theme/components';
6
+ var LINK_COLOR_DARK = '#4794FF';
7
+
8
+ // By default buttons will hide overflow and ellipsis content instead of wrapping.
9
+ // This basically turns the button back into inline content
10
+ // There is a workaround for negative token spacing suggested by the design system team. calc(${token} * -1)
11
+ export var IconStyledButton = styled.span(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n &&& {\n text-align: initial;\n display: inline;\n vertical-align: baseline;\n border-radius: ", ";\n border-top-left-radius: 0px;\n border-bottom-left-radius: 0px;\n padding: ", " ", ";\n background-clip: padding-box;\n box-decoration-break: clone;\n }\n > span {\n display: inline;\n overflow: initial;\n text-overflow: initial;\n white-space: initial;\n > span {\n overflow: initial;\n text-overflow: initial;\n white-space: initial;\n }\n }\n"])), "var(--ds-border-radius-100, 2px)", "var(--ds-space-025, 2px)", "var(--ds-space-075, 6px)");
12
+ export var NoLinkAppearance = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n color: ", ";\n margin-left: ", ";\n"])), themed({
13
+ light: "var(--ds-text-subtlest, ".concat(N200, ")"),
14
+ dark: "var(--ds-text-subtlest, ".concat(LINK_COLOR_DARK, ")")
15
+ }), "var(--ds-space-050, 4px)");
16
+ export var LowercaseAppearance = styled.span(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n text-transform: lowercase;\n"])));
17
+ export var LinkAppearance = styled.a(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n color: ", ";\n\n &:hover {\n text-decoration: none;\n }\n"])), themed({
18
+ light: "var(--ds-link, ".concat(B400, ")"),
19
+ dark: "var(--ds-link, ".concat(LINK_COLOR_DARK, ")")
20
+ }));
@@ -0,0 +1 @@
1
+ export {};