@atlaskit/smart-card 26.9.16 → 26.9.18

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 (89) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/version.json +1 -1
  3. package/dist/cjs/view/CardWithUrl/component.js +5 -2
  4. package/dist/cjs/view/FlexibleCard/components/elements/avatar-group/index.js +1 -2
  5. package/dist/cjs/view/InlineCard/Icon.js +0 -2
  6. package/dist/cjs/view/RedesignedInlineCard/ErroredView/index.js +90 -0
  7. package/dist/cjs/view/RedesignedInlineCard/ForbiddenView/index.js +129 -0
  8. package/dist/cjs/view/RedesignedInlineCard/Frame/index.js +63 -0
  9. package/dist/cjs/view/RedesignedInlineCard/Frame/styled.js +70 -0
  10. package/dist/cjs/view/RedesignedInlineCard/Icon.js +43 -0
  11. package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/index.js +151 -0
  12. package/dist/cjs/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +56 -0
  13. package/dist/cjs/view/RedesignedInlineCard/ResolvedView/index.js +83 -0
  14. package/dist/cjs/view/RedesignedInlineCard/ResolvingView/index.js +69 -0
  15. package/dist/cjs/view/RedesignedInlineCard/ResolvingView/styled.js +13 -0
  16. package/dist/cjs/view/RedesignedInlineCard/UnauthorisedView/index.js +113 -0
  17. package/dist/cjs/view/RedesignedInlineCard/index.js +183 -0
  18. package/dist/cjs/view/RedesignedInlineCard/styled.js +31 -0
  19. package/dist/cjs/view/RedesignedInlineCard/types.js +5 -0
  20. package/dist/cjs/view/RedesignedInlineCard/utils/withFrameStyleControl.js +42 -0
  21. package/dist/es2019/version.json +1 -1
  22. package/dist/es2019/view/CardWithUrl/component.js +5 -2
  23. package/dist/es2019/view/FlexibleCard/components/elements/avatar-group/index.js +3 -2
  24. package/dist/es2019/view/InlineCard/Icon.js +0 -2
  25. package/dist/es2019/view/RedesignedInlineCard/ErroredView/index.js +66 -0
  26. package/dist/es2019/view/RedesignedInlineCard/ForbiddenView/index.js +107 -0
  27. package/dist/es2019/view/RedesignedInlineCard/Frame/index.js +55 -0
  28. package/dist/es2019/view/RedesignedInlineCard/Frame/styled.js +107 -0
  29. package/dist/es2019/view/RedesignedInlineCard/Icon.js +45 -0
  30. package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/index.js +124 -0
  31. package/dist/es2019/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +97 -0
  32. package/dist/es2019/view/RedesignedInlineCard/ResolvedView/index.js +55 -0
  33. package/dist/es2019/view/RedesignedInlineCard/ResolvingView/index.js +44 -0
  34. package/dist/es2019/view/RedesignedInlineCard/ResolvingView/styled.js +6 -0
  35. package/dist/es2019/view/RedesignedInlineCard/UnauthorisedView/index.js +86 -0
  36. package/dist/es2019/view/RedesignedInlineCard/index.js +149 -0
  37. package/dist/es2019/view/RedesignedInlineCard/styled.js +52 -0
  38. package/dist/es2019/view/RedesignedInlineCard/types.js +1 -0
  39. package/dist/es2019/view/RedesignedInlineCard/utils/withFrameStyleControl.js +33 -0
  40. package/dist/esm/version.json +1 -1
  41. package/dist/esm/view/CardWithUrl/component.js +5 -2
  42. package/dist/esm/view/FlexibleCard/components/elements/avatar-group/index.js +1 -2
  43. package/dist/esm/view/InlineCard/Icon.js +0 -2
  44. package/dist/esm/view/RedesignedInlineCard/ErroredView/index.js +82 -0
  45. package/dist/esm/view/RedesignedInlineCard/ForbiddenView/index.js +121 -0
  46. package/dist/esm/view/RedesignedInlineCard/Frame/index.js +53 -0
  47. package/dist/esm/view/RedesignedInlineCard/Frame/styled.js +61 -0
  48. package/dist/esm/view/RedesignedInlineCard/Icon.js +34 -0
  49. package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/index.js +143 -0
  50. package/dist/esm/view/RedesignedInlineCard/IconAndTitleLayout/styled.js +38 -0
  51. package/dist/esm/view/RedesignedInlineCard/ResolvedView/index.js +75 -0
  52. package/dist/esm/view/RedesignedInlineCard/ResolvingView/index.js +61 -0
  53. package/dist/esm/view/RedesignedInlineCard/ResolvingView/styled.js +5 -0
  54. package/dist/esm/view/RedesignedInlineCard/UnauthorisedView/index.js +105 -0
  55. package/dist/esm/view/RedesignedInlineCard/index.js +146 -0
  56. package/dist/esm/view/RedesignedInlineCard/styled.js +20 -0
  57. package/dist/esm/view/RedesignedInlineCard/types.js +1 -0
  58. package/dist/esm/view/RedesignedInlineCard/utils/withFrameStyleControl.js +35 -0
  59. package/dist/types/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
  60. package/dist/types/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
  61. package/dist/types/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
  62. package/dist/types/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
  63. package/dist/types/view/RedesignedInlineCard/Icon.d.ts +12 -0
  64. package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
  65. package/dist/types/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
  66. package/dist/types/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
  67. package/dist/types/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
  68. package/dist/types/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
  69. package/dist/types/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
  70. package/dist/types/view/RedesignedInlineCard/index.d.ts +9 -0
  71. package/dist/types/view/RedesignedInlineCard/styled.d.ts +17 -0
  72. package/dist/types/view/RedesignedInlineCard/types.d.ts +25 -0
  73. package/dist/types/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
  74. package/dist/types-ts4.5/view/RedesignedInlineCard/ErroredView/index.d.ts +22 -0
  75. package/dist/types-ts4.5/view/RedesignedInlineCard/ForbiddenView/index.d.ts +29 -0
  76. package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/index.d.ts +15 -0
  77. package/dist/types-ts4.5/view/RedesignedInlineCard/Frame/styled.d.ts +15 -0
  78. package/dist/types-ts4.5/view/RedesignedInlineCard/Icon.d.ts +12 -0
  79. package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/index.d.ts +28 -0
  80. package/dist/types-ts4.5/view/RedesignedInlineCard/IconAndTitleLayout/styled.d.ts +36 -0
  81. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvedView/index.d.ts +32 -0
  82. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/index.d.ts +17 -0
  83. package/dist/types-ts4.5/view/RedesignedInlineCard/ResolvingView/styled.d.ts +9 -0
  84. package/dist/types-ts4.5/view/RedesignedInlineCard/UnauthorisedView/index.d.ts +32 -0
  85. package/dist/types-ts4.5/view/RedesignedInlineCard/index.d.ts +9 -0
  86. package/dist/types-ts4.5/view/RedesignedInlineCard/styled.d.ts +17 -0
  87. package/dist/types-ts4.5/view/RedesignedInlineCard/types.d.ts +25 -0
  88. package/dist/types-ts4.5/view/RedesignedInlineCard/utils/withFrameStyleControl.d.ts +9 -0
  89. package/package.json +6 -3
@@ -0,0 +1,53 @@
1
+ import React, { useCallback, forwardRef } from 'react';
2
+ import { useGlobalTheme } from '@atlaskit/theme/components';
3
+ import { WrapperAnchor, WrapperSpan } from './styled';
4
+ import { useMouseDownEvent } from '../../../state/analytics/useLinkClicked';
5
+ export var Frame = /*#__PURE__*/forwardRef(function (props, ref) {
6
+ var isSelected = props.isSelected,
7
+ children = props.children,
8
+ onClick = props.onClick,
9
+ link = props.link,
10
+ withoutBackground = props.withoutBackground,
11
+ testId = props.testId,
12
+ className = props.className;
13
+ var handleClick = useCallback(function (event) {
14
+ if (onClick) {
15
+ event.preventDefault();
16
+ event.stopPropagation();
17
+ onClick(event);
18
+ }
19
+ }, [onClick]);
20
+ var handleKeyPress = useCallback(function (event) {
21
+ if (event.key !== ' ' && event.key !== 'Enter') {
22
+ return;
23
+ }
24
+ if (onClick) {
25
+ event.preventDefault();
26
+ event.stopPropagation();
27
+ onClick(event);
28
+ }
29
+ }, [onClick]);
30
+ var handleMouseDown = useMouseDownEvent();
31
+ var isInteractive = Boolean(onClick);
32
+
33
+ // Depending on whenever Frame was given onClick or link itself we display span or anchor elements
34
+ var Wrapper = link || onClick ? WrapperAnchor : WrapperSpan;
35
+
36
+ // TODO Theming doesn't work right now in editor. Required React context does not trickle down atm.
37
+ // It will be worked as part of https://product-fabric.atlassian.net/jira/servicedesk/projects/DTR/queues/issue/DTR-154
38
+ return /*#__PURE__*/React.createElement(Wrapper, {
39
+ theme: useGlobalTheme(),
40
+ href: link,
41
+ withoutBackground: withoutBackground,
42
+ isSelected: isSelected,
43
+ isInteractive: isInteractive,
44
+ tabIndex: isInteractive ? 0 : undefined,
45
+ role: isInteractive ? 'button' : undefined,
46
+ onClick: handleClick,
47
+ onMouseDown: handleMouseDown,
48
+ onKeyPress: handleKeyPress,
49
+ "data-testid": testId,
50
+ className: className,
51
+ ref: ref
52
+ }, children);
53
+ });
@@ -0,0 +1,61 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2;
3
+ import styled from '@emotion/styled';
4
+ import { B50, B100, B200, B400, N20, N40, N500 } from '@atlaskit/theme/colors';
5
+ import { themed } from '@atlaskit/theme/components';
6
+ var BACKGROUND_COLOR_DARK = '#262B31';
7
+ var selected = "\n cursor: pointer;\n box-shadow: 0 0 0 2px ".concat("var(--ds-border-selected, ".concat(B100, ")"), ";\n outline: none;\n user-select: none;\n &, :hover, :focus, :active {\n text-decoration: none;\n }\n &:hover {\n border: 1px solid ", "var(--ds-border-input, ".concat(N40, ")"), ";\n }\n");
8
+ var isInteractive = function isInteractive(_ref) {
9
+ var isInteractive = _ref.isInteractive;
10
+ if (isInteractive) {
11
+ return "\n :hover {\n background-color: ".concat(themed({
12
+ light: "var(--ds-background-neutral-subtle-hovered, ".concat(N20, ")"),
13
+ dark: "var(--ds-background-neutral-subtle-hovered, ".concat(BACKGROUND_COLOR_DARK, ")")
14
+ }), ";\n }\n :active {\n background-color: ").concat(themed({
15
+ light: "var(--ds-background-selected, ".concat(B50, ")"),
16
+ dark: "var(--ds-background-selected, ".concat(BACKGROUND_COLOR_DARK, ")")
17
+ }), ";\n }\n :focus {\n ").concat(selected, "\n }\n ");
18
+ } else {
19
+ return '';
20
+ }
21
+ };
22
+ var isSelected = function isSelected(_ref2) {
23
+ var isSelected = _ref2.isSelected;
24
+ if (isSelected) {
25
+ return selected;
26
+ } else {
27
+ return 'user-select: text';
28
+ }
29
+ };
30
+
31
+ /*
32
+ Inline smart cards should have the following layout:
33
+ ------------------------------------
34
+ | icon | title | action OR lozenge |
35
+ ------------------------------------
36
+ The aim is to ensure (1) all children are
37
+ in line with each other, (2) are vertically
38
+ centered.
39
+ */
40
+ // NB: `padding` consistent with @mentions.
41
+ // NB: `display: inline` required for `box-decoration-break` to work.
42
+ // NB: `box-decoration-break` required for retaining properties (border-radius) on wrap.
43
+ var baseWrapperStyle = function baseWrapperStyle(props) {
44
+ return "\n line-height: 22px;\n padding: 2px 0px;\n ".concat(props.withoutBackground ? "padding-left: 0; margin-left:-2px;" : '', "\n display: inline;\n box-decoration-break: clone;\n border-radius: ", "var(--ds-border-radius-100, 3px)", ";\n color: ").concat(themed({
45
+ light: "var(--ds-link, ".concat(B400, ")"),
46
+ dark: "var(--ds-link, #4794FF)"
47
+ })(props), ";\n\n background-color: ").concat(props.withoutBackground ? '' : themed({
48
+ light: "var(--ds-surface-raised, white)",
49
+ dark: "var(--ds-surface-raised, ".concat(BACKGROUND_COLOR_DARK, ")")
50
+ })(props), ";\n\n ").concat(isSelected(props), ";\n\n ").concat(props.withoutBackground ? '' : themed({
51
+ light: "border: 1px solid ".concat("var(--ds-border-input, ".concat(N40, ")"), ";"),
52
+ dark: "border: 1px solid ".concat("var(--ds-border-input, ".concat(N500, ")"), ";")
53
+ })(props), "\n &:hover {\n ").concat(themed({
54
+ light: "border-color: ".concat("var(--ds-border-accent-blue, ".concat(B200, ")"), ";"),
55
+ dark: "border-color: ".concat("var(--ds-border-accent-blue, ".concat(B200, ")"), ";")
56
+ })(props), "\n }\n &, :hover, :focus, :active {\n ").concat(props.withoutBackground ? '' : 'text-decoration: none;', "\n }\n transition: 0.1s all ease-in-out;\n -moz-user-select: none;\n");
57
+ };
58
+ export var WrapperAnchor = styled.a(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n ", "\n ", "\n"])), baseWrapperStyle, isInteractive);
59
+ WrapperAnchor.displayName = 'WrapperAnchor';
60
+ export var WrapperSpan = styled.span(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n ", "\n"])), baseWrapperStyle);
61
+ WrapperSpan.displayName = 'WrapperSpan';
@@ -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);