@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.
- package/CHANGELOG.md +763 -0
- package/LICENSE +13 -0
- package/build/tsconfig.json +17 -0
- package/dist/cjs/components/QuickSearch.js +447 -0
- package/dist/cjs/components/ResultItem/ResultItem.js +87 -0
- package/dist/cjs/components/ResultItem/ResultItemGroup.js +57 -0
- package/dist/cjs/components/ResultItem/styled.js +53 -0
- package/dist/cjs/components/Results/ContainerResult.js +93 -0
- package/dist/cjs/components/Results/ObjectResult.js +108 -0
- package/dist/cjs/components/Results/PersonResult.js +99 -0
- package/dist/cjs/components/Results/ResultBase.js +206 -0
- package/dist/cjs/components/Results/index.js +39 -0
- package/dist/cjs/components/Results/types.js +5 -0
- package/dist/cjs/components/Search/Search.js +124 -0
- package/dist/cjs/components/Search/styled.js +61 -0
- package/dist/cjs/components/constants.js +20 -0
- package/dist/cjs/components/context.js +29 -0
- package/dist/cjs/components/decorateWithAnalyticsData.js +80 -0
- package/dist/cjs/components/isReactElement.js +19 -0
- package/dist/cjs/index.js +94 -0
- package/dist/cjs/version.json +4 -0
- package/dist/es2019/components/QuickSearch.js +417 -0
- package/dist/es2019/components/ResultItem/ResultItem.js +41 -0
- package/dist/es2019/components/ResultItem/ResultItemGroup.js +16 -0
- package/dist/es2019/components/ResultItem/styled.js +54 -0
- package/dist/es2019/components/Results/ContainerResult.js +45 -0
- package/dist/es2019/components/Results/ObjectResult.js +60 -0
- package/dist/es2019/components/Results/PersonResult.js +50 -0
- package/dist/es2019/components/Results/ResultBase.js +149 -0
- package/dist/es2019/components/Results/index.js +4 -0
- package/dist/es2019/components/Results/types.js +1 -0
- package/dist/es2019/components/Search/Search.js +80 -0
- package/dist/es2019/components/Search/styled.js +76 -0
- package/dist/es2019/components/constants.js +7 -0
- package/dist/es2019/components/context.js +11 -0
- package/dist/es2019/components/decorateWithAnalyticsData.js +33 -0
- package/dist/es2019/components/isReactElement.js +10 -0
- package/dist/es2019/index.js +23 -0
- package/dist/es2019/version.json +4 -0
- package/dist/esm/components/QuickSearch.js +442 -0
- package/dist/esm/components/ResultItem/ResultItem.js +65 -0
- package/dist/esm/components/ResultItem/ResultItemGroup.js +42 -0
- package/dist/esm/components/ResultItem/styled.js +18 -0
- package/dist/esm/components/Results/ContainerResult.js +78 -0
- package/dist/esm/components/Results/ObjectResult.js +93 -0
- package/dist/esm/components/Results/PersonResult.js +86 -0
- package/dist/esm/components/Results/ResultBase.js +189 -0
- package/dist/esm/components/Results/index.js +4 -0
- package/dist/esm/components/Results/types.js +1 -0
- package/dist/esm/components/Search/Search.js +108 -0
- package/dist/esm/components/Search/styled.js +20 -0
- package/dist/esm/components/constants.js +7 -0
- package/dist/esm/components/context.js +13 -0
- package/dist/esm/components/decorateWithAnalyticsData.js +64 -0
- package/dist/esm/components/isReactElement.js +10 -0
- package/dist/esm/index.js +23 -0
- package/dist/esm/version.json +4 -0
- package/dist/types/components/QuickSearch.d.ts +122 -0
- package/dist/types/components/ResultItem/ResultItem.d.ts +38 -0
- package/dist/types/components/ResultItem/ResultItemGroup.d.ts +11 -0
- package/dist/types/components/ResultItem/styled.d.ts +13 -0
- package/dist/types/components/Results/ContainerResult.d.ts +19 -0
- package/dist/types/components/Results/ObjectResult.d.ts +22 -0
- package/dist/types/components/Results/PersonResult.d.ts +20 -0
- package/dist/types/components/Results/ResultBase.d.ts +37 -0
- package/dist/types/components/Results/index.d.ts +4 -0
- package/dist/types/components/Results/types.d.ts +34 -0
- package/dist/types/components/Search/Search.d.ts +31 -0
- package/dist/types/components/Search/styled.d.ts +10 -0
- package/dist/types/components/constants.d.ts +6 -0
- package/dist/types/components/context.d.ts +22 -0
- package/dist/types/components/decorateWithAnalyticsData.d.ts +3 -0
- package/dist/types/components/isReactElement.d.ts +6 -0
- package/dist/types/index.d.ts +17 -0
- package/docs/0-intro.tsx +53 -0
- package/package.json +52 -0
- package/tsconfig.json +11 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.ResultBase = void 0;
|
|
9
|
+
|
|
10
|
+
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
11
|
+
|
|
12
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
13
|
+
|
|
14
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
15
|
+
|
|
16
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
17
|
+
|
|
18
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
+
|
|
20
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
+
|
|
22
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
+
|
|
24
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _constants = require("../constants");
|
|
29
|
+
|
|
30
|
+
var _ResultItem = _interopRequireDefault(require("../ResultItem/ResultItem"));
|
|
31
|
+
|
|
32
|
+
var _context = require("../context");
|
|
33
|
+
|
|
34
|
+
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; }
|
|
35
|
+
|
|
36
|
+
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) { (0, _defineProperty2.default)(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; }
|
|
37
|
+
|
|
38
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
39
|
+
|
|
40
|
+
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; } }
|
|
41
|
+
|
|
42
|
+
var ResultBase = /*#__PURE__*/function (_React$PureComponent) {
|
|
43
|
+
(0, _inherits2.default)(ResultBase, _React$PureComponent);
|
|
44
|
+
|
|
45
|
+
var _super = _createSuper(ResultBase);
|
|
46
|
+
|
|
47
|
+
function ResultBase() {
|
|
48
|
+
var _this;
|
|
49
|
+
|
|
50
|
+
(0, _classCallCheck2.default)(this, ResultBase);
|
|
51
|
+
|
|
52
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
53
|
+
args[_key] = arguments[_key];
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
57
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "state", {
|
|
58
|
+
isMouseSelected: false
|
|
59
|
+
});
|
|
60
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleClick", function (e) {
|
|
61
|
+
var _this$props = _this.props,
|
|
62
|
+
onClick = _this$props.onClick,
|
|
63
|
+
resultId = _this$props.resultId,
|
|
64
|
+
type = _this$props.type,
|
|
65
|
+
context = _this$props.context;
|
|
66
|
+
|
|
67
|
+
if (context.sendAnalytics) {
|
|
68
|
+
context.sendAnalytics(_constants.QS_ANALYTICS_EV_SUBMIT, _objectSpread(_objectSpread({}, _this.getAnalyticsData()), {}, {
|
|
69
|
+
method: 'click',
|
|
70
|
+
newTab: e && (e.metaKey || e.shiftKey || e.ctrlKey)
|
|
71
|
+
}));
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
if (onClick) {
|
|
75
|
+
onClick({
|
|
76
|
+
resultId: resultId,
|
|
77
|
+
type: type,
|
|
78
|
+
event: e
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseEnter", function (event) {
|
|
83
|
+
_this.props.context.onMouseEnter({
|
|
84
|
+
resultId: _this.props.resultId,
|
|
85
|
+
type: _this.props.type,
|
|
86
|
+
event: event
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
_this.setState({
|
|
90
|
+
isMouseSelected: true
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleMouseLeave", function () {
|
|
94
|
+
_this.props.context.onMouseLeave();
|
|
95
|
+
|
|
96
|
+
_this.setState({
|
|
97
|
+
isMouseSelected: false
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
return _this;
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
(0, _createClass2.default)(ResultBase, [{
|
|
104
|
+
key: "registerResult",
|
|
105
|
+
value: function registerResult() {
|
|
106
|
+
var context = this.props.context;
|
|
107
|
+
context.registerResult(this);
|
|
108
|
+
}
|
|
109
|
+
}, {
|
|
110
|
+
key: "componentDidMount",
|
|
111
|
+
value: function componentDidMount() {
|
|
112
|
+
this.registerResult();
|
|
113
|
+
}
|
|
114
|
+
}, {
|
|
115
|
+
key: "componentDidUpdate",
|
|
116
|
+
value: function componentDidUpdate() {
|
|
117
|
+
this.registerResult();
|
|
118
|
+
}
|
|
119
|
+
}, {
|
|
120
|
+
key: "componentWillUnmount",
|
|
121
|
+
value: function componentWillUnmount() {
|
|
122
|
+
var context = this.props.context;
|
|
123
|
+
context.unregisterResult(this);
|
|
124
|
+
}
|
|
125
|
+
}, {
|
|
126
|
+
key: "getAnalyticsData",
|
|
127
|
+
value: function getAnalyticsData() {
|
|
128
|
+
var _this$props2 = this.props,
|
|
129
|
+
resultId = _this$props2.resultId,
|
|
130
|
+
analyticsData = _this$props2.analyticsData,
|
|
131
|
+
type = _this$props2.type,
|
|
132
|
+
context = _this$props2.context;
|
|
133
|
+
return _objectSpread({
|
|
134
|
+
index: context.getIndex(resultId),
|
|
135
|
+
type: type,
|
|
136
|
+
resultId: resultId
|
|
137
|
+
}, analyticsData instanceof Function ? analyticsData() : analyticsData);
|
|
138
|
+
}
|
|
139
|
+
}, {
|
|
140
|
+
key: "render",
|
|
141
|
+
value: function render() {
|
|
142
|
+
var _this2 = this;
|
|
143
|
+
|
|
144
|
+
var _this$props3 = this.props,
|
|
145
|
+
caption = _this$props3.caption,
|
|
146
|
+
elemAfter = _this$props3.elemAfter,
|
|
147
|
+
selectedIcon = _this$props3.selectedIcon,
|
|
148
|
+
href = _this$props3.href,
|
|
149
|
+
target = _this$props3.target,
|
|
150
|
+
icon = _this$props3.icon,
|
|
151
|
+
isCompact = _this$props3.isCompact,
|
|
152
|
+
subText = _this$props3.subText,
|
|
153
|
+
text = _this$props3.text,
|
|
154
|
+
resultId = _this$props3.resultId,
|
|
155
|
+
context = _this$props3.context;
|
|
156
|
+
var isMouseSelected = this.state.isMouseSelected;
|
|
157
|
+
return /*#__PURE__*/_react.default.createElement(_context.SelectedResultIdContext.Consumer, null, function (selectedResultId) {
|
|
158
|
+
return /*#__PURE__*/_react.default.createElement(_ResultItem.default, {
|
|
159
|
+
caption: caption,
|
|
160
|
+
href: href,
|
|
161
|
+
target: target,
|
|
162
|
+
icon: icon,
|
|
163
|
+
isCompact: isCompact,
|
|
164
|
+
isSelected: resultId === selectedResultId,
|
|
165
|
+
onClick: _this2.handleClick,
|
|
166
|
+
onMouseEnter: _this2.handleMouseEnter,
|
|
167
|
+
onMouseLeave: _this2.handleMouseLeave,
|
|
168
|
+
isMouseSelected: isMouseSelected,
|
|
169
|
+
subText: subText,
|
|
170
|
+
text: text,
|
|
171
|
+
textAfter: elemAfter,
|
|
172
|
+
selectedIcon: selectedIcon,
|
|
173
|
+
linkComponent: context.linkComponent
|
|
174
|
+
});
|
|
175
|
+
});
|
|
176
|
+
}
|
|
177
|
+
}]);
|
|
178
|
+
return ResultBase;
|
|
179
|
+
}(_react.default.PureComponent);
|
|
180
|
+
|
|
181
|
+
exports.ResultBase = ResultBase;
|
|
182
|
+
(0, _defineProperty2.default)(ResultBase, "defaultProps", {
|
|
183
|
+
type: 'base',
|
|
184
|
+
context: {
|
|
185
|
+
registerResult: function registerResult(result) {},
|
|
186
|
+
unregisterResult: function unregisterResult(result) {},
|
|
187
|
+
onMouseEnter: function onMouseEnter(resultData) {},
|
|
188
|
+
onMouseLeave: function onMouseLeave() {},
|
|
189
|
+
// @ts-ignore
|
|
190
|
+
sendAnalytics: function sendAnalytics(string, data) {},
|
|
191
|
+
getIndex: function getIndex() {
|
|
192
|
+
return null;
|
|
193
|
+
}
|
|
194
|
+
},
|
|
195
|
+
analyticsData: {}
|
|
196
|
+
});
|
|
197
|
+
|
|
198
|
+
var _default = function _default(props) {
|
|
199
|
+
return /*#__PURE__*/_react.default.createElement(_context.ResultContext.Consumer, null, function (context) {
|
|
200
|
+
return /*#__PURE__*/_react.default.createElement(ResultBase, (0, _extends2.default)({
|
|
201
|
+
context: context
|
|
202
|
+
}, props));
|
|
203
|
+
});
|
|
204
|
+
};
|
|
205
|
+
|
|
206
|
+
exports.default = _default;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
Object.defineProperty(exports, "ContainerResult", {
|
|
9
|
+
enumerable: true,
|
|
10
|
+
get: function get() {
|
|
11
|
+
return _ContainerResult.default;
|
|
12
|
+
}
|
|
13
|
+
});
|
|
14
|
+
Object.defineProperty(exports, "ObjectResult", {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function get() {
|
|
17
|
+
return _ObjectResult.default;
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
Object.defineProperty(exports, "PersonResult", {
|
|
21
|
+
enumerable: true,
|
|
22
|
+
get: function get() {
|
|
23
|
+
return _PersonResult.default;
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
Object.defineProperty(exports, "ResultBase", {
|
|
27
|
+
enumerable: true,
|
|
28
|
+
get: function get() {
|
|
29
|
+
return _ResultBase.default;
|
|
30
|
+
}
|
|
31
|
+
});
|
|
32
|
+
|
|
33
|
+
var _ContainerResult = _interopRequireDefault(require("./ContainerResult"));
|
|
34
|
+
|
|
35
|
+
var _ObjectResult = _interopRequireDefault(require("./ObjectResult"));
|
|
36
|
+
|
|
37
|
+
var _PersonResult = _interopRequireDefault(require("./PersonResult"));
|
|
38
|
+
|
|
39
|
+
var _ResultBase = _interopRequireDefault(require("./ResultBase"));
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.default = exports.controlKeys = void 0;
|
|
9
|
+
|
|
10
|
+
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
+
|
|
12
|
+
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
+
|
|
14
|
+
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
+
|
|
16
|
+
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
+
|
|
18
|
+
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
+
|
|
20
|
+
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
+
|
|
22
|
+
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
+
|
|
24
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
25
|
+
|
|
26
|
+
var _react = _interopRequireDefault(require("react"));
|
|
27
|
+
|
|
28
|
+
var _spinner = _interopRequireDefault(require("@atlaskit/spinner"));
|
|
29
|
+
|
|
30
|
+
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
31
|
+
|
|
32
|
+
var _styled = require("./styled");
|
|
33
|
+
|
|
34
|
+
var _templateObject;
|
|
35
|
+
|
|
36
|
+
function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = (0, _getPrototypeOf2.default)(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = (0, _getPrototypeOf2.default)(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return (0, _possibleConstructorReturn2.default)(this, result); }; }
|
|
37
|
+
|
|
38
|
+
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; } }
|
|
39
|
+
|
|
40
|
+
var controlKeys = ['ArrowUp', 'ArrowDown', 'Enter', 'Tab', 'ArrowRight'];
|
|
41
|
+
exports.controlKeys = controlKeys;
|
|
42
|
+
|
|
43
|
+
var SpinnerParent = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n height: 20px;\n margin-left: 10px;\n margin-top: 10px;\n"])));
|
|
44
|
+
|
|
45
|
+
var Search = /*#__PURE__*/function (_React$PureComponent) {
|
|
46
|
+
(0, _inherits2.default)(Search, _React$PureComponent);
|
|
47
|
+
|
|
48
|
+
var _super = _createSuper(Search);
|
|
49
|
+
|
|
50
|
+
function Search() {
|
|
51
|
+
var _this;
|
|
52
|
+
|
|
53
|
+
(0, _classCallCheck2.default)(this, Search);
|
|
54
|
+
|
|
55
|
+
for (var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++) {
|
|
56
|
+
args[_key] = arguments[_key];
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
_this = _super.call.apply(_super, [this].concat(args));
|
|
60
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInputKeyDown", function (event) {
|
|
61
|
+
var onKeyDown = _this.props.onKeyDown;
|
|
62
|
+
|
|
63
|
+
if (!controlKeys.includes(event.key)) {
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if (onKeyDown) {
|
|
68
|
+
onKeyDown(event);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
event.stopPropagation();
|
|
72
|
+
});
|
|
73
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "setInputRef", function (ref) {
|
|
74
|
+
_this.inputRef = ref;
|
|
75
|
+
});
|
|
76
|
+
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "renderInputControls", function () {
|
|
77
|
+
return _this.props.inputControls ? /*#__PURE__*/_react.default.createElement(_styled.SearchInputControlsContainer, null, _this.props.inputControls) : null;
|
|
78
|
+
});
|
|
79
|
+
return _this;
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
(0, _createClass2.default)(Search, [{
|
|
83
|
+
key: "render",
|
|
84
|
+
value: function render() {
|
|
85
|
+
var _this$props = this.props,
|
|
86
|
+
children = _this$props.children,
|
|
87
|
+
onBlur = _this$props.onBlur,
|
|
88
|
+
onInput = _this$props.onInput,
|
|
89
|
+
placeholder = _this$props.placeholder,
|
|
90
|
+
isLoading = _this$props.isLoading,
|
|
91
|
+
value = _this$props.value,
|
|
92
|
+
autocomplete = _this$props.autocompleteText;
|
|
93
|
+
return /*#__PURE__*/_react.default.createElement(_styled.SearchInner, null, /*#__PURE__*/_react.default.createElement(_styled.SearchBox, null, /*#__PURE__*/_react.default.createElement(_styled.SearchFieldBaseOuter, null, /*#__PURE__*/_react.default.createElement(_styled.SearchFieldBaseInner, null, autocomplete && /*#__PURE__*/_react.default.createElement(_styled.SearchInputTypeAhead, {
|
|
94
|
+
spellCheck: false,
|
|
95
|
+
type: "text",
|
|
96
|
+
value: "".concat(autocomplete),
|
|
97
|
+
readOnly: true,
|
|
98
|
+
tabIndex: -1
|
|
99
|
+
}), /*#__PURE__*/_react.default.createElement(_styled.SearchInput, {
|
|
100
|
+
autoFocus: true,
|
|
101
|
+
innerRef: this.setInputRef,
|
|
102
|
+
onBlur: onBlur,
|
|
103
|
+
onInput: onInput,
|
|
104
|
+
placeholder: placeholder,
|
|
105
|
+
spellCheck: false,
|
|
106
|
+
type: "text",
|
|
107
|
+
value: value,
|
|
108
|
+
onChange: function onChange() {} // Suppresses the console warning, we handle onChange by using onKeyDown instead.
|
|
109
|
+
,
|
|
110
|
+
onKeyDown: this.onInputKeyDown
|
|
111
|
+
}), isLoading && /*#__PURE__*/_react.default.createElement(SpinnerParent, null, /*#__PURE__*/_react.default.createElement(_spinner.default, {
|
|
112
|
+
size: "small"
|
|
113
|
+
})))), this.renderInputControls()), children);
|
|
114
|
+
}
|
|
115
|
+
}]);
|
|
116
|
+
return Search;
|
|
117
|
+
}(_react.default.PureComponent);
|
|
118
|
+
|
|
119
|
+
exports.default = Search;
|
|
120
|
+
(0, _defineProperty2.default)(Search, "defaultProps", {
|
|
121
|
+
isLoading: false,
|
|
122
|
+
onBlur: function onBlur() {},
|
|
123
|
+
placeholder: 'Search'
|
|
124
|
+
});
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
+
|
|
7
|
+
Object.defineProperty(exports, "__esModule", {
|
|
8
|
+
value: true
|
|
9
|
+
});
|
|
10
|
+
exports.SearchInputControlsContainer = exports.SearchInputTypeAhead = exports.SearchInput = exports.getPlaceholderColor = exports.getPlaceholderStyle = exports.SearchInner = exports.SearchFieldBaseInner = exports.SearchFieldBaseOuter = exports.SearchBox = void 0;
|
|
11
|
+
|
|
12
|
+
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
13
|
+
|
|
14
|
+
var _styledComponents = _interopRequireWildcard(require("styled-components"));
|
|
15
|
+
|
|
16
|
+
var _constants = require("@atlaskit/theme/constants");
|
|
17
|
+
|
|
18
|
+
var _colors = require("@atlaskit/theme/colors");
|
|
19
|
+
|
|
20
|
+
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9;
|
|
21
|
+
|
|
22
|
+
function _getRequireWildcardCache(nodeInterop) { if (typeof WeakMap !== "function") return null; var cacheBabelInterop = new WeakMap(); var cacheNodeInterop = new WeakMap(); return (_getRequireWildcardCache = function _getRequireWildcardCache(nodeInterop) { return nodeInterop ? cacheNodeInterop : cacheBabelInterop; })(nodeInterop); }
|
|
23
|
+
|
|
24
|
+
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
25
|
+
|
|
26
|
+
var inputRightPadding = (0, _constants.gridSize)() * 2;
|
|
27
|
+
|
|
28
|
+
var SearchBox = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n position: sticky;\n top: 0;\n z-index: 1; /* required to keep the search box on top of icons in results when sticky */\n background-color: ", ";\n color: ", ";\n display: flex;\n height: 36px;\n z-index: 10;\n"])), _colors.N0, _colors.N500);
|
|
29
|
+
|
|
30
|
+
exports.SearchBox = SearchBox;
|
|
31
|
+
|
|
32
|
+
var SearchFieldBaseOuter = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n flex: 1;\n margin-right: auto;\n padding-bottom: 2px;\n border-bottom: 2px solid ", ";\n"])), _colors.B200);
|
|
33
|
+
|
|
34
|
+
exports.SearchFieldBaseOuter = SearchFieldBaseOuter;
|
|
35
|
+
|
|
36
|
+
var SearchFieldBaseInner = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n align-items: center;\n padding-right: ", "px; /* pad search text from FieldBase's isLoading spinner */\n display: flex;\n flex-grow: 1;\n"])), inputRightPadding);
|
|
37
|
+
|
|
38
|
+
exports.SearchFieldBaseInner = SearchFieldBaseInner;
|
|
39
|
+
|
|
40
|
+
var SearchInner = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n padding-right: ", "px;\n"])), (0, _constants.gridSize)() * 3);
|
|
41
|
+
|
|
42
|
+
exports.SearchInner = SearchInner;
|
|
43
|
+
|
|
44
|
+
var getPlaceholderStyle = function getPlaceholderStyle(style) {
|
|
45
|
+
return (0, _styledComponents.css)(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n &::-webkit-input-placeholder {\n ", ";\n }\n &::-moz-placeholder {\n /* Mozilla Firefox 19+ */\n ", " opacity: 1;\n }\n &::-ms-input-placeholder {\n /* Microsoft Edge */\n ", ";\n }\n &:-moz-placeholder {\n /* Mozilla Firefox 4 to 18 */\n ", " opacity: 1;\n }\n &:-ms-input-placeholder {\n /* Internet Explorer 10-11 */\n ", ";\n }\n"])), style, style, style, style, style);
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
exports.getPlaceholderStyle = getPlaceholderStyle;
|
|
49
|
+
var getPlaceholderColor = (0, _styledComponents.css)(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n"])), _colors.placeholderText);
|
|
50
|
+
exports.getPlaceholderColor = getPlaceholderColor;
|
|
51
|
+
|
|
52
|
+
var SearchInput = _styledComponents.default.input(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\n background-color: transparent;\n border: 0;\n color: ", ";\n flex-grow: 1;\n font-size: 1.4em;\n outline: 0;\n // Safari adds 2px margin-left\n margin-left: 0;\n ", ";\n"])), _colors.N500, getPlaceholderStyle(getPlaceholderColor));
|
|
53
|
+
|
|
54
|
+
exports.SearchInput = SearchInput;
|
|
55
|
+
var SearchInputTypeAhead = (0, _styledComponents.default)(SearchInput)(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n position: absolute;\n width: calc(100% - ", "px);\n z-index: -1;\n"])), _colors.N50, inputRightPadding);
|
|
56
|
+
exports.SearchInputTypeAhead = SearchInputTypeAhead;
|
|
57
|
+
|
|
58
|
+
var SearchInputControlsContainer = _styledComponents.default.span(_templateObject9 || (_templateObject9 = (0, _taggedTemplateLiteral2.default)(["\n padding-left: ", "px;\n"])), (0, _constants.gridSize)() * 3);
|
|
59
|
+
|
|
60
|
+
exports.SearchInputControlsContainer = SearchInputControlsContainer;
|
|
61
|
+
SearchInputControlsContainer.displayName = 'SearchInputControlsContainer'; // required for testing
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
Object.defineProperty(exports, "__esModule", {
|
|
4
|
+
value: true
|
|
5
|
+
});
|
|
6
|
+
exports.QS_ANALYTICS_EV_SUBMIT = exports.QS_ANALYTICS_EV_QUERY_ENTERED = exports.QS_ANALYTICS_EV_OPEN = exports.QS_ANALYTICS_EV_KB_CTRLS_USED = exports.QS_ANALYTICS_EV_CLOSE = exports.ATLASKIT_QUICKSEARCH_NS = void 0;
|
|
7
|
+
|
|
8
|
+
/* eslint-disable import/prefer-default-export */
|
|
9
|
+
var ATLASKIT_QUICKSEARCH_NS = 'atlaskit.navigation.quick-search';
|
|
10
|
+
exports.ATLASKIT_QUICKSEARCH_NS = ATLASKIT_QUICKSEARCH_NS;
|
|
11
|
+
var QS_ANALYTICS_EV_CLOSE = "".concat(ATLASKIT_QUICKSEARCH_NS, ".close");
|
|
12
|
+
exports.QS_ANALYTICS_EV_CLOSE = QS_ANALYTICS_EV_CLOSE;
|
|
13
|
+
var QS_ANALYTICS_EV_KB_CTRLS_USED = "".concat(ATLASKIT_QUICKSEARCH_NS, ".keyboard-controls-used");
|
|
14
|
+
exports.QS_ANALYTICS_EV_KB_CTRLS_USED = QS_ANALYTICS_EV_KB_CTRLS_USED;
|
|
15
|
+
var QS_ANALYTICS_EV_OPEN = "".concat(ATLASKIT_QUICKSEARCH_NS, ".open");
|
|
16
|
+
exports.QS_ANALYTICS_EV_OPEN = QS_ANALYTICS_EV_OPEN;
|
|
17
|
+
var QS_ANALYTICS_EV_QUERY_ENTERED = "".concat(ATLASKIT_QUICKSEARCH_NS, ".query-entered");
|
|
18
|
+
exports.QS_ANALYTICS_EV_QUERY_ENTERED = QS_ANALYTICS_EV_QUERY_ENTERED;
|
|
19
|
+
var QS_ANALYTICS_EV_SUBMIT = "".concat(ATLASKIT_QUICKSEARCH_NS, ".submit");
|
|
20
|
+
exports.QS_ANALYTICS_EV_SUBMIT = QS_ANALYTICS_EV_SUBMIT;
|