@atlaskit/quick-search 8.0.9

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 (77) hide show
  1. package/CHANGELOG.md +763 -0
  2. package/LICENSE +13 -0
  3. package/build/tsconfig.json +17 -0
  4. package/dist/cjs/components/QuickSearch.js +447 -0
  5. package/dist/cjs/components/ResultItem/ResultItem.js +87 -0
  6. package/dist/cjs/components/ResultItem/ResultItemGroup.js +57 -0
  7. package/dist/cjs/components/ResultItem/styled.js +53 -0
  8. package/dist/cjs/components/Results/ContainerResult.js +93 -0
  9. package/dist/cjs/components/Results/ObjectResult.js +108 -0
  10. package/dist/cjs/components/Results/PersonResult.js +99 -0
  11. package/dist/cjs/components/Results/ResultBase.js +206 -0
  12. package/dist/cjs/components/Results/index.js +39 -0
  13. package/dist/cjs/components/Results/types.js +5 -0
  14. package/dist/cjs/components/Search/Search.js +124 -0
  15. package/dist/cjs/components/Search/styled.js +61 -0
  16. package/dist/cjs/components/constants.js +20 -0
  17. package/dist/cjs/components/context.js +29 -0
  18. package/dist/cjs/components/decorateWithAnalyticsData.js +80 -0
  19. package/dist/cjs/components/isReactElement.js +19 -0
  20. package/dist/cjs/index.js +94 -0
  21. package/dist/cjs/version.json +4 -0
  22. package/dist/es2019/components/QuickSearch.js +417 -0
  23. package/dist/es2019/components/ResultItem/ResultItem.js +41 -0
  24. package/dist/es2019/components/ResultItem/ResultItemGroup.js +16 -0
  25. package/dist/es2019/components/ResultItem/styled.js +54 -0
  26. package/dist/es2019/components/Results/ContainerResult.js +45 -0
  27. package/dist/es2019/components/Results/ObjectResult.js +60 -0
  28. package/dist/es2019/components/Results/PersonResult.js +50 -0
  29. package/dist/es2019/components/Results/ResultBase.js +149 -0
  30. package/dist/es2019/components/Results/index.js +4 -0
  31. package/dist/es2019/components/Results/types.js +1 -0
  32. package/dist/es2019/components/Search/Search.js +80 -0
  33. package/dist/es2019/components/Search/styled.js +76 -0
  34. package/dist/es2019/components/constants.js +7 -0
  35. package/dist/es2019/components/context.js +11 -0
  36. package/dist/es2019/components/decorateWithAnalyticsData.js +33 -0
  37. package/dist/es2019/components/isReactElement.js +10 -0
  38. package/dist/es2019/index.js +23 -0
  39. package/dist/es2019/version.json +4 -0
  40. package/dist/esm/components/QuickSearch.js +442 -0
  41. package/dist/esm/components/ResultItem/ResultItem.js +65 -0
  42. package/dist/esm/components/ResultItem/ResultItemGroup.js +42 -0
  43. package/dist/esm/components/ResultItem/styled.js +18 -0
  44. package/dist/esm/components/Results/ContainerResult.js +78 -0
  45. package/dist/esm/components/Results/ObjectResult.js +93 -0
  46. package/dist/esm/components/Results/PersonResult.js +86 -0
  47. package/dist/esm/components/Results/ResultBase.js +189 -0
  48. package/dist/esm/components/Results/index.js +4 -0
  49. package/dist/esm/components/Results/types.js +1 -0
  50. package/dist/esm/components/Search/Search.js +108 -0
  51. package/dist/esm/components/Search/styled.js +20 -0
  52. package/dist/esm/components/constants.js +7 -0
  53. package/dist/esm/components/context.js +13 -0
  54. package/dist/esm/components/decorateWithAnalyticsData.js +64 -0
  55. package/dist/esm/components/isReactElement.js +10 -0
  56. package/dist/esm/index.js +23 -0
  57. package/dist/esm/version.json +4 -0
  58. package/dist/types/components/QuickSearch.d.ts +122 -0
  59. package/dist/types/components/ResultItem/ResultItem.d.ts +38 -0
  60. package/dist/types/components/ResultItem/ResultItemGroup.d.ts +11 -0
  61. package/dist/types/components/ResultItem/styled.d.ts +13 -0
  62. package/dist/types/components/Results/ContainerResult.d.ts +19 -0
  63. package/dist/types/components/Results/ObjectResult.d.ts +22 -0
  64. package/dist/types/components/Results/PersonResult.d.ts +20 -0
  65. package/dist/types/components/Results/ResultBase.d.ts +37 -0
  66. package/dist/types/components/Results/index.d.ts +4 -0
  67. package/dist/types/components/Results/types.d.ts +34 -0
  68. package/dist/types/components/Search/Search.d.ts +31 -0
  69. package/dist/types/components/Search/styled.d.ts +10 -0
  70. package/dist/types/components/constants.d.ts +6 -0
  71. package/dist/types/components/context.d.ts +22 -0
  72. package/dist/types/components/decorateWithAnalyticsData.d.ts +3 -0
  73. package/dist/types/components/isReactElement.d.ts +6 -0
  74. package/dist/types/index.d.ts +17 -0
  75. package/docs/0-intro.tsx +53 -0
  76. package/package.json +52 -0
  77. package/tsconfig.json +11 -0
@@ -0,0 +1,65 @@
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 _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
+
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
+
11
+ 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; } }
12
+
13
+ import React from 'react';
14
+ import baseItem, { withItemClick, withItemFocus } from '@atlaskit/item';
15
+ import { ResultItemAfter, ResultItemAfterWrapper, ResultItemCaption, ResultItemIcon, ResultItemTextAfter, ResultItemSubText } from './styled';
16
+ var Item = withItemClick(withItemFocus(baseItem));
17
+
18
+ var ResultItem = /*#__PURE__*/function (_React$PureComponent) {
19
+ _inherits(ResultItem, _React$PureComponent);
20
+
21
+ var _super = _createSuper(ResultItem);
22
+
23
+ function ResultItem() {
24
+ _classCallCheck(this, ResultItem);
25
+
26
+ return _super.apply(this, arguments);
27
+ }
28
+
29
+ _createClass(ResultItem, [{
30
+ key: "render",
31
+ value: function render() {
32
+ var icon = this.props.icon ? /*#__PURE__*/React.createElement(ResultItemIcon, null, this.props.icon) : null;
33
+ var textAfter = this.props.textAfter ? /*#__PURE__*/React.createElement(ResultItemTextAfter, null, this.props.textAfter) : null;
34
+ var after = this.props.textAfter || this.props.selectedIcon ? /*#__PURE__*/React.createElement(ResultItemAfterWrapper, null, /*#__PURE__*/React.createElement(ResultItemAfter, {
35
+ shouldTakeSpace: !!this.props.textAfter
36
+ }, textAfter, this.props.isSelected && !this.props.isMouseSelected ? this.props.selectedIcon : null)) : null;
37
+ var wrappedCaption = this.props.caption ? /*#__PURE__*/React.createElement(ResultItemCaption, null, this.props.caption) : null;
38
+ var wrappedSubText = this.props.subText ? /*#__PURE__*/React.createElement(ResultItemSubText, null, this.props.subText) : null;
39
+ var interactiveWrapperProps = {
40
+ onClick: this.props.onClick,
41
+ onMouseEnter: this.props.onMouseEnter,
42
+ onMouseLeave: this.props.onMouseLeave,
43
+ href: this.props.href
44
+ };
45
+ return /*#__PURE__*/React.createElement(Item, _extends({
46
+ elemBefore: icon,
47
+ elemAfter: after,
48
+ description: wrappedSubText,
49
+ isSelected: this.props.isSelected,
50
+ isCompact: this.props.isCompact,
51
+ target: this.props.target,
52
+ linkComponent: this.props.linkComponent
53
+ }, interactiveWrapperProps), this.props.text, wrappedCaption);
54
+ }
55
+ }]);
56
+
57
+ return ResultItem;
58
+ }(React.PureComponent);
59
+
60
+ _defineProperty(ResultItem, "defaultProps", {
61
+ isSelected: false,
62
+ isMouseSelected: false
63
+ });
64
+
65
+ export default ResultItem;
@@ -0,0 +1,42 @@
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
+
7
+ 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); }; }
8
+
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
+
11
+ import React from 'react';
12
+ import { ItemGroup } from '@atlaskit/item';
13
+ import { ResultItemGroupTitle, ResultItemGroupHeader } from './styled';
14
+
15
+ var ResultItemGroup = /*#__PURE__*/function (_React$Component) {
16
+ _inherits(ResultItemGroup, _React$Component);
17
+
18
+ var _super = _createSuper(ResultItemGroup);
19
+
20
+ function ResultItemGroup() {
21
+ _classCallCheck(this, ResultItemGroup);
22
+
23
+ return _super.apply(this, arguments);
24
+ }
25
+
26
+ _createClass(ResultItemGroup, [{
27
+ key: "render",
28
+ value: function render() {
29
+ var _this$props = this.props,
30
+ title = _this$props.title,
31
+ children = _this$props.children;
32
+ var wrappedTitle = /*#__PURE__*/React.createElement(ResultItemGroupHeader, null, /*#__PURE__*/React.createElement(ResultItemGroupTitle, null, title));
33
+ return /*#__PURE__*/React.createElement(ItemGroup, {
34
+ title: wrappedTitle
35
+ }, children);
36
+ }
37
+ }]);
38
+
39
+ return ResultItemGroup;
40
+ }(React.Component);
41
+
42
+ export { ResultItemGroup as default };
@@ -0,0 +1,18 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
+
3
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
4
+
5
+ import styled from 'styled-components';
6
+ import { gridSize } from '@atlaskit/theme/constants';
7
+ import { N200 } from '@atlaskit/theme/colors';
8
+ export var ResultItemGroupHeader = styled.div(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n margin-left: -", "px;\n margin-top: ", "px;\n"])), gridSize() * 1.5, gridSize() * 1.5);
9
+ export var ResultItemGroupTitle = styled.div(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n font-size: 11px;\n line-height: ", "px;\n font-weight: 600;\n"])), gridSize() * 2);
10
+ export var ResultItemAfter = styled.div(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n min-width: ", ";\n"])), function (_ref) {
11
+ var shouldTakeSpace = _ref.shouldTakeSpace;
12
+ return shouldTakeSpace ? '24px' : 0;
13
+ });
14
+ export var ResultItemAfterWrapper = styled.div(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n display: flex;\n"])));
15
+ export var ResultItemCaption = styled.span(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n color: ", ";\n font-size: 12px;\n margin-left: ", "px;\n"])), N200, gridSize());
16
+ export var ResultItemSubText = styled.span(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n font-size: 12px;\n color: ", ";\n"])), N200);
17
+ export var ResultItemIcon = styled.div(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n display: flex;\n align-items: center;\n justify-content: center;\n flex-shrink: 0;\n transition: padding 200ms;\n\n > * {\n flex: 1 0 auto;\n }\n\n /* We need to ensure that any image passed in as a child (<img/>, <svg/>\n etc.) receives the correct width, height and border radius. We don't\n currently assume that the image passed in is the correct dimensions, or has\n width / height 100% */\n > img {\n height: ", "px;\n width: ", "px;\n }\n"])), gridSize() * 3, gridSize() * 3);
18
+ export var ResultItemTextAfter = styled.div(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n position: relative;\n z-index: 1;\n"])));
@@ -0,0 +1,78 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+
11
+ 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); }; }
12
+
13
+ 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; } }
14
+
15
+ import React from 'react';
16
+ import Avatar from '@atlaskit/avatar';
17
+ import ResultBase from './ResultBase';
18
+
19
+ /**
20
+ * Generic result type for Atlassian containers.
21
+ */
22
+ var ContainerResult = /*#__PURE__*/function (_React$PureComponent) {
23
+ _inherits(ContainerResult, _React$PureComponent);
24
+
25
+ var _super = _createSuper(ContainerResult);
26
+
27
+ function ContainerResult() {
28
+ var _this;
29
+
30
+ _classCallCheck(this, ContainerResult);
31
+
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
34
+ }
35
+
36
+ _this = _super.call.apply(_super, [this].concat(args));
37
+
38
+ _defineProperty(_assertThisInitialized(_this), "getAvatar", function () {
39
+ if (_this.props.avatar) {
40
+ return _this.props.avatar;
41
+ }
42
+
43
+ return /*#__PURE__*/React.createElement(Avatar, {
44
+ borderColor: "transparent",
45
+ src: _this.props.avatarUrl,
46
+ appearance: "square",
47
+ size: "small",
48
+ status: _this.props.isPrivate ? 'locked' : null
49
+ });
50
+ });
51
+
52
+ return _this;
53
+ }
54
+
55
+ _createClass(ContainerResult, [{
56
+ key: "render",
57
+ value: function render() {
58
+ var _this$props = this.props,
59
+ name = _this$props.name,
60
+ isPrivate = _this$props.isPrivate,
61
+ _this$props$type = _this$props.type,
62
+ type = _this$props$type === void 0 ? 'container' : _this$props$type,
63
+ subText = _this$props.subText,
64
+ commonResultProps = _objectWithoutProperties(_this$props, ["name", "isPrivate", "type", "subText"]);
65
+
66
+ return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
67
+ type: type,
68
+ text: name,
69
+ subText: subText,
70
+ icon: this.getAvatar()
71
+ }));
72
+ }
73
+ }]);
74
+
75
+ return ContainerResult;
76
+ }(React.PureComponent);
77
+
78
+ export { ContainerResult as default };
@@ -0,0 +1,93 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+
11
+ 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); }; }
12
+
13
+ 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; } }
14
+
15
+ import React from 'react';
16
+ import Avatar from '@atlaskit/avatar';
17
+ import ResultBase from './ResultBase';
18
+
19
+ /**
20
+ * Generic result type for Atlassian objects.
21
+ */
22
+ var ObjectResult = /*#__PURE__*/function (_React$PureComponent) {
23
+ _inherits(ObjectResult, _React$PureComponent);
24
+
25
+ var _super = _createSuper(ObjectResult);
26
+
27
+ function ObjectResult() {
28
+ var _this;
29
+
30
+ _classCallCheck(this, ObjectResult);
31
+
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
34
+ }
35
+
36
+ _this = _super.call.apply(_super, [this].concat(args));
37
+
38
+ _defineProperty(_assertThisInitialized(_this), "getAvatar", function () {
39
+ if (_this.props.avatar) {
40
+ return _this.props.avatar;
41
+ }
42
+
43
+ return /*#__PURE__*/React.createElement(Avatar, {
44
+ borderColor: "transparent",
45
+ src: _this.props.avatarUrl,
46
+ appearance: "square",
47
+ size: "small",
48
+ status: _this.props.isPrivate ? 'locked' : null,
49
+ testId: "object-result"
50
+ });
51
+ });
52
+
53
+ return _this;
54
+ }
55
+
56
+ _createClass(ObjectResult, [{
57
+ key: "getSubtext",
58
+ value: function getSubtext() {
59
+ var _this$props = this.props,
60
+ objectKey = _this$props.objectKey,
61
+ containerName = _this$props.containerName;
62
+
63
+ if (objectKey && containerName) {
64
+ return /*#__PURE__*/React.createElement("span", null, objectKey, " \xB7 ", containerName);
65
+ }
66
+
67
+ return containerName || objectKey;
68
+ }
69
+ }, {
70
+ key: "render",
71
+ value: function render() {
72
+ var _this$props2 = this.props,
73
+ name = _this$props2.name,
74
+ containerName = _this$props2.containerName,
75
+ isPrivate = _this$props2.isPrivate,
76
+ objectKey = _this$props2.objectKey,
77
+ _this$props2$type = _this$props2.type,
78
+ type = _this$props2$type === void 0 ? 'object' : _this$props2$type,
79
+ commonResultProps = _objectWithoutProperties(_this$props2, ["name", "containerName", "isPrivate", "objectKey", "type"]);
80
+
81
+ return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
82
+ type: type,
83
+ text: name,
84
+ subText: this.getSubtext(),
85
+ icon: this.getAvatar()
86
+ }));
87
+ }
88
+ }]);
89
+
90
+ return ObjectResult;
91
+ }(React.PureComponent);
92
+
93
+ export { ObjectResult as default };
@@ -0,0 +1,86 @@
1
+ import _extends from "@babel/runtime/helpers/extends";
2
+ import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
+ import _classCallCheck from "@babel/runtime/helpers/classCallCheck";
4
+ import _createClass from "@babel/runtime/helpers/createClass";
5
+ import _assertThisInitialized from "@babel/runtime/helpers/assertThisInitialized";
6
+ import _inherits from "@babel/runtime/helpers/inherits";
7
+ import _possibleConstructorReturn from "@babel/runtime/helpers/possibleConstructorReturn";
8
+ import _getPrototypeOf from "@babel/runtime/helpers/getPrototypeOf";
9
+ import _defineProperty from "@babel/runtime/helpers/defineProperty";
10
+
11
+ 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); }; }
12
+
13
+ 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; } }
14
+
15
+ import React from 'react';
16
+ import Avatar from '@atlaskit/avatar';
17
+ import ResultBase from './ResultBase';
18
+
19
+ var PersonResult = /*#__PURE__*/function (_React$PureComponent) {
20
+ _inherits(PersonResult, _React$PureComponent);
21
+
22
+ var _super = _createSuper(PersonResult);
23
+
24
+ function PersonResult() {
25
+ var _this;
26
+
27
+ _classCallCheck(this, PersonResult);
28
+
29
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
30
+ args[_key] = arguments[_key];
31
+ }
32
+
33
+ _this = _super.call.apply(_super, [this].concat(args));
34
+
35
+ _defineProperty(_assertThisInitialized(_this), "getMention", function () {
36
+ return _this.props.mentionName ? "".concat(_this.props.mentionPrefix).concat(_this.props.mentionName) : undefined;
37
+ });
38
+
39
+ _defineProperty(_assertThisInitialized(_this), "getAvatar", function () {
40
+ if (_this.props.avatar) {
41
+ return _this.props.avatar;
42
+ }
43
+
44
+ return /*#__PURE__*/React.createElement(Avatar, {
45
+ presence: _this.props.presenceState,
46
+ size: "small",
47
+ src: _this.props.avatarUrl
48
+ });
49
+ });
50
+
51
+ return _this;
52
+ }
53
+
54
+ _createClass(PersonResult, [{
55
+ key: "render",
56
+ value: function render() {
57
+ var _this$props = this.props,
58
+ name = _this$props.name,
59
+ mentionName = _this$props.mentionName,
60
+ mentionPrefix = _this$props.mentionPrefix,
61
+ presenceMessage = _this$props.presenceMessage,
62
+ presenceState = _this$props.presenceState,
63
+ _this$props$type = _this$props.type,
64
+ type = _this$props$type === void 0 ? 'person' : _this$props$type,
65
+ commonResultProps = _objectWithoutProperties(_this$props, ["name", "mentionName", "mentionPrefix", "presenceMessage", "presenceState", "type"]);
66
+
67
+ return /*#__PURE__*/React.createElement(ResultBase, _extends({}, commonResultProps, {
68
+ type: type,
69
+ text: name,
70
+ subText: presenceMessage,
71
+ caption: this.getMention(),
72
+ icon: this.getAvatar()
73
+ }));
74
+ }
75
+ }]);
76
+
77
+ return PersonResult;
78
+ }(React.PureComponent);
79
+
80
+ _defineProperty(PersonResult, "defaultProps", {
81
+ mentionPrefix: '@',
82
+ presenceState: null // No presence indicator by default
83
+
84
+ });
85
+
86
+ export { PersonResult as default };
@@ -0,0 +1,189 @@
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
+
10
+ function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); if (enumerableOnly) { symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; }); } keys.push.apply(keys, symbols); } return keys; }
11
+
12
+ function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = arguments[i] != null ? arguments[i] : {}; if (i % 2) { ownKeys(Object(source), true).forEach(function (key) { _defineProperty(target, key, source[key]); }); } else if (Object.getOwnPropertyDescriptors) { Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)); } else { ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } } return target; }
13
+
14
+ 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); }; }
15
+
16
+ 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; } }
17
+
18
+ import React from 'react';
19
+ import { QS_ANALYTICS_EV_SUBMIT } from '../constants';
20
+ import ResultItem from '../ResultItem/ResultItem';
21
+ import { ResultContext, SelectedResultIdContext } from '../context';
22
+ export var ResultBase = /*#__PURE__*/function (_React$PureComponent) {
23
+ _inherits(ResultBase, _React$PureComponent);
24
+
25
+ var _super = _createSuper(ResultBase);
26
+
27
+ function ResultBase() {
28
+ var _this;
29
+
30
+ _classCallCheck(this, ResultBase);
31
+
32
+ for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
33
+ args[_key] = arguments[_key];
34
+ }
35
+
36
+ _this = _super.call.apply(_super, [this].concat(args));
37
+
38
+ _defineProperty(_assertThisInitialized(_this), "state", {
39
+ isMouseSelected: false
40
+ });
41
+
42
+ _defineProperty(_assertThisInitialized(_this), "handleClick", function (e) {
43
+ var _this$props = _this.props,
44
+ onClick = _this$props.onClick,
45
+ resultId = _this$props.resultId,
46
+ type = _this$props.type,
47
+ context = _this$props.context;
48
+
49
+ if (context.sendAnalytics) {
50
+ context.sendAnalytics(QS_ANALYTICS_EV_SUBMIT, _objectSpread(_objectSpread({}, _this.getAnalyticsData()), {}, {
51
+ method: 'click',
52
+ newTab: e && (e.metaKey || e.shiftKey || e.ctrlKey)
53
+ }));
54
+ }
55
+
56
+ if (onClick) {
57
+ onClick({
58
+ resultId: resultId,
59
+ type: type,
60
+ event: e
61
+ });
62
+ }
63
+ });
64
+
65
+ _defineProperty(_assertThisInitialized(_this), "handleMouseEnter", function (event) {
66
+ _this.props.context.onMouseEnter({
67
+ resultId: _this.props.resultId,
68
+ type: _this.props.type,
69
+ event: event
70
+ });
71
+
72
+ _this.setState({
73
+ isMouseSelected: true
74
+ });
75
+ });
76
+
77
+ _defineProperty(_assertThisInitialized(_this), "handleMouseLeave", function () {
78
+ _this.props.context.onMouseLeave();
79
+
80
+ _this.setState({
81
+ isMouseSelected: false
82
+ });
83
+ });
84
+
85
+ return _this;
86
+ }
87
+
88
+ _createClass(ResultBase, [{
89
+ key: "registerResult",
90
+ value: function registerResult() {
91
+ var context = this.props.context;
92
+ context.registerResult(this);
93
+ }
94
+ }, {
95
+ key: "componentDidMount",
96
+ value: function componentDidMount() {
97
+ this.registerResult();
98
+ }
99
+ }, {
100
+ key: "componentDidUpdate",
101
+ value: function componentDidUpdate() {
102
+ this.registerResult();
103
+ }
104
+ }, {
105
+ key: "componentWillUnmount",
106
+ value: function componentWillUnmount() {
107
+ var context = this.props.context;
108
+ context.unregisterResult(this);
109
+ }
110
+ }, {
111
+ key: "getAnalyticsData",
112
+ value: function getAnalyticsData() {
113
+ var _this$props2 = this.props,
114
+ resultId = _this$props2.resultId,
115
+ analyticsData = _this$props2.analyticsData,
116
+ type = _this$props2.type,
117
+ context = _this$props2.context;
118
+ return _objectSpread({
119
+ index: context.getIndex(resultId),
120
+ type: type,
121
+ resultId: resultId
122
+ }, analyticsData instanceof Function ? analyticsData() : analyticsData);
123
+ }
124
+ }, {
125
+ key: "render",
126
+ value: function render() {
127
+ var _this2 = this;
128
+
129
+ var _this$props3 = this.props,
130
+ caption = _this$props3.caption,
131
+ elemAfter = _this$props3.elemAfter,
132
+ selectedIcon = _this$props3.selectedIcon,
133
+ href = _this$props3.href,
134
+ target = _this$props3.target,
135
+ icon = _this$props3.icon,
136
+ isCompact = _this$props3.isCompact,
137
+ subText = _this$props3.subText,
138
+ text = _this$props3.text,
139
+ resultId = _this$props3.resultId,
140
+ context = _this$props3.context;
141
+ var isMouseSelected = this.state.isMouseSelected;
142
+ return /*#__PURE__*/React.createElement(SelectedResultIdContext.Consumer, null, function (selectedResultId) {
143
+ return /*#__PURE__*/React.createElement(ResultItem, {
144
+ caption: caption,
145
+ href: href,
146
+ target: target,
147
+ icon: icon,
148
+ isCompact: isCompact,
149
+ isSelected: resultId === selectedResultId,
150
+ onClick: _this2.handleClick,
151
+ onMouseEnter: _this2.handleMouseEnter,
152
+ onMouseLeave: _this2.handleMouseLeave,
153
+ isMouseSelected: isMouseSelected,
154
+ subText: subText,
155
+ text: text,
156
+ textAfter: elemAfter,
157
+ selectedIcon: selectedIcon,
158
+ linkComponent: context.linkComponent
159
+ });
160
+ });
161
+ }
162
+ }]);
163
+
164
+ return ResultBase;
165
+ }(React.PureComponent);
166
+
167
+ _defineProperty(ResultBase, "defaultProps", {
168
+ type: 'base',
169
+ context: {
170
+ registerResult: function registerResult(result) {},
171
+ unregisterResult: function unregisterResult(result) {},
172
+ onMouseEnter: function onMouseEnter(resultData) {},
173
+ onMouseLeave: function onMouseLeave() {},
174
+ // @ts-ignore
175
+ sendAnalytics: function sendAnalytics(string, data) {},
176
+ getIndex: function getIndex() {
177
+ return null;
178
+ }
179
+ },
180
+ analyticsData: {}
181
+ });
182
+
183
+ export default (function (props) {
184
+ return /*#__PURE__*/React.createElement(ResultContext.Consumer, null, function (context) {
185
+ return /*#__PURE__*/React.createElement(ResultBase, _extends({
186
+ context: context
187
+ }, props));
188
+ });
189
+ });