@atlaskit/quick-search 8.0.13 → 8.0.15
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 +12 -0
- package/README.md +1 -0
- package/dist/cjs/components/QuickSearch.js +65 -100
- package/dist/cjs/components/ResultItem/ResultItem.js +0 -22
- package/dist/cjs/components/ResultItem/ResultItemGroup.js +2 -20
- package/dist/cjs/components/ResultItem/styled.js +4 -27
- package/dist/cjs/components/Results/ContainerResult.js +6 -31
- package/dist/cjs/components/Results/ObjectResult.js +9 -36
- package/dist/cjs/components/Results/PersonResult.js +8 -34
- package/dist/cjs/components/Results/ResultBase.js +22 -52
- package/dist/cjs/components/Results/index.js +0 -5
- package/dist/cjs/components/Search/Search.js +7 -36
- package/dist/cjs/components/Search/styled.js +6 -31
- package/dist/cjs/components/constants.js +0 -1
- package/dist/cjs/components/context.js +0 -7
- package/dist/cjs/components/decorateWithAnalyticsData.js +0 -22
- package/dist/cjs/components/isReactElement.js +0 -2
- package/dist/cjs/index.js +0 -14
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/components/QuickSearch.js +71 -95
- package/dist/es2019/components/ResultItem/ResultItem.js +0 -4
- package/dist/es2019/components/ResultItem/ResultItemGroup.js +0 -1
- package/dist/es2019/components/ResultItem/styled.js +6 -7
- package/dist/es2019/components/Results/ContainerResult.js +0 -5
- package/dist/es2019/components/Results/ObjectResult.js +0 -8
- package/dist/es2019/components/Results/PersonResult.js +0 -7
- package/dist/es2019/components/Results/ResultBase.js +5 -16
- package/dist/es2019/components/Search/Search.js +0 -9
- package/dist/es2019/components/Search/styled.js +7 -8
- package/dist/es2019/components/decorateWithAnalyticsData.js +0 -4
- package/dist/es2019/index.js +6 -3
- package/dist/es2019/version.json +1 -1
- package/dist/esm/components/QuickSearch.js +66 -104
- package/dist/esm/components/ResultItem/ResultItem.js +0 -11
- package/dist/esm/components/ResultItem/ResultItemGroup.js +2 -12
- package/dist/esm/components/ResultItem/styled.js +4 -7
- package/dist/esm/components/Results/ContainerResult.js +6 -22
- package/dist/esm/components/Results/ObjectResult.js +9 -27
- package/dist/esm/components/Results/PersonResult.js +8 -27
- package/dist/esm/components/Results/ResultBase.js +23 -44
- package/dist/esm/components/Search/Search.js +7 -28
- package/dist/esm/components/Search/styled.js +7 -10
- package/dist/esm/components/decorateWithAnalyticsData.js +0 -13
- package/dist/esm/index.js +6 -3
- package/dist/esm/version.json +1 -1
- package/dist/types/components/Search/styled.d.ts +1 -1
- package/package.json +8 -14
- package/report.api.md +33 -14
- package/tmp/api-report-tmp.d.ts +263 -0
- package/dist/types-ts4.0/components/QuickSearch.d.ts +0 -122
- package/dist/types-ts4.0/components/ResultItem/ResultItem.d.ts +0 -38
- package/dist/types-ts4.0/components/ResultItem/ResultItemGroup.d.ts +0 -11
- package/dist/types-ts4.0/components/ResultItem/styled.d.ts +0 -13
- package/dist/types-ts4.0/components/Results/ContainerResult.d.ts +0 -19
- package/dist/types-ts4.0/components/Results/ObjectResult.d.ts +0 -22
- package/dist/types-ts4.0/components/Results/PersonResult.d.ts +0 -20
- package/dist/types-ts4.0/components/Results/ResultBase.d.ts +0 -37
- package/dist/types-ts4.0/components/Results/index.d.ts +0 -4
- package/dist/types-ts4.0/components/Results/types.d.ts +0 -34
- package/dist/types-ts4.0/components/Search/Search.d.ts +0 -31
- package/dist/types-ts4.0/components/Search/styled.d.ts +0 -10
- package/dist/types-ts4.0/components/constants.d.ts +0 -6
- package/dist/types-ts4.0/components/context.d.ts +0 -22
- package/dist/types-ts4.0/components/decorateWithAnalyticsData.d.ts +0 -3
- package/dist/types-ts4.0/components/isReactElement.d.ts +0 -6
- package/dist/types-ts4.0/index.d.ts +0 -17
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/quick-search
|
|
2
2
|
|
|
3
|
+
## 8.0.15
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`be610dca836`](https://bitbucket.org/atlassian/atlassian-frontend/commits/be610dca836) - [ux] replace deprecated placeholder theme with tokens
|
|
8
|
+
|
|
9
|
+
## 8.0.14
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`1378b2a7308`](https://bitbucket.org/atlassian/atlassian-frontend/commits/1378b2a7308) - Migrated use of `gridSize` to space tokens where possible. There is no expected visual or behaviour change.
|
|
14
|
+
|
|
3
15
|
## 8.0.13
|
|
4
16
|
|
|
5
17
|
### Patch Changes
|
package/README.md
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
This package has been deprecated. Please use the `search-dialog` package instead.
|
|
@@ -1,48 +1,28 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = exports.QuickSearch = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _assertThisInitialized2 = _interopRequireDefault(require("@babel/runtime/helpers/assertThisInitialized"));
|
|
15
|
-
|
|
16
11
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
17
|
-
|
|
18
12
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
19
|
-
|
|
20
13
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
21
|
-
|
|
22
14
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
23
|
-
|
|
24
15
|
var _react = _interopRequireDefault(require("react"));
|
|
25
|
-
|
|
26
16
|
var _keycode = _interopRequireDefault(require("keycode"));
|
|
27
|
-
|
|
28
17
|
var _analytics = require("@atlaskit/analytics");
|
|
29
|
-
|
|
30
18
|
var _Search = _interopRequireDefault(require("./Search/Search"));
|
|
31
|
-
|
|
32
19
|
var _context = require("./context");
|
|
33
|
-
|
|
34
20
|
var _decorateWithAnalyticsData = _interopRequireDefault(require("./decorateWithAnalyticsData"));
|
|
35
|
-
|
|
36
21
|
var _constants = require("./constants");
|
|
37
|
-
|
|
38
22
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
39
|
-
|
|
40
23
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { (0, _defineProperty2.default)(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
41
|
-
|
|
42
24
|
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); }; }
|
|
43
|
-
|
|
44
25
|
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; } }
|
|
45
|
-
|
|
46
26
|
/**
|
|
47
27
|
* Get the result ID of a result by its index in the flatResults array
|
|
48
28
|
* Returns null for a failed index or if resultId is empty|undefined
|
|
@@ -51,153 +31,170 @@ var getResultIdByIndex = function getResultIdByIndex(array, index) {
|
|
|
51
31
|
if (array && index !== null && array[index] && array[index].props && array[index].props.resultId) {
|
|
52
32
|
return array[index].props.resultId;
|
|
53
33
|
}
|
|
54
|
-
|
|
55
34
|
return null;
|
|
56
35
|
};
|
|
36
|
+
|
|
57
37
|
/**
|
|
58
38
|
* Find a result in the flatResults array by its ID
|
|
59
39
|
* Returns the result object or null
|
|
60
40
|
*/
|
|
61
|
-
|
|
62
|
-
|
|
63
41
|
var getResultById = function getResultById(array, id) {
|
|
64
42
|
return array && array.find(function (result) {
|
|
65
43
|
return result.props && result.props.resultId === id;
|
|
66
44
|
}) || null;
|
|
67
45
|
};
|
|
46
|
+
|
|
68
47
|
/**
|
|
69
48
|
* Get a result's index in the flatResults array by its ID
|
|
70
49
|
* Returns a numeric index or null
|
|
71
50
|
*/
|
|
72
|
-
|
|
73
|
-
|
|
74
51
|
var getResultIndexById = function getResultIndexById(array, id) {
|
|
75
52
|
if (!array) {
|
|
76
53
|
return null;
|
|
77
54
|
}
|
|
78
|
-
|
|
79
55
|
var result = getResultById(array, id);
|
|
80
|
-
|
|
81
56
|
if (!result) {
|
|
82
57
|
return null;
|
|
83
58
|
}
|
|
84
|
-
|
|
85
59
|
var index = array.indexOf(result);
|
|
86
60
|
return index >= 0 ? index : null;
|
|
87
61
|
};
|
|
88
|
-
|
|
89
62
|
var adjustIndex = function adjustIndex(arrayLength, currentIndex, adjustment) {
|
|
90
63
|
if (arrayLength === 0) {
|
|
91
64
|
return null;
|
|
92
65
|
}
|
|
93
|
-
|
|
94
66
|
if (adjustment === 0) {
|
|
95
67
|
return currentIndex;
|
|
96
|
-
}
|
|
97
|
-
|
|
68
|
+
}
|
|
98
69
|
|
|
70
|
+
// If nothing is selected, select the element on the end
|
|
99
71
|
if (currentIndex === null) {
|
|
100
72
|
return adjustment > 0 ? 0 : arrayLength - 1;
|
|
101
|
-
}
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
73
|
+
}
|
|
74
|
+
// Adjust current index, wrapping around if necessary
|
|
75
|
+
var adjustedIndex = (currentIndex + adjustment) % arrayLength;
|
|
76
|
+
// Correct for negative indices
|
|
106
77
|
return adjustedIndex >= 0 ? adjustedIndex : adjustedIndex + arrayLength;
|
|
107
78
|
};
|
|
108
|
-
|
|
109
79
|
var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
110
80
|
(0, _inherits2.default)(QuickSearch, _React$Component);
|
|
111
|
-
|
|
112
81
|
var _super = _createSuper(QuickSearch);
|
|
113
|
-
|
|
114
82
|
function QuickSearch(props) {
|
|
115
83
|
var _this;
|
|
116
|
-
|
|
117
84
|
(0, _classCallCheck2.default)(this, QuickSearch);
|
|
118
85
|
_this = _super.call(this, props);
|
|
119
86
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "flatResults", []);
|
|
120
87
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasSearchQueryEventFired", false);
|
|
121
88
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "hasKeyDownEventFired", false);
|
|
122
89
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "lastKeyPressed", '');
|
|
90
|
+
/**
|
|
91
|
+
* Uses the virtual list, this.flatResults, to move the selection across grouped results as if
|
|
92
|
+
* results were in a single, circular list.
|
|
93
|
+
*
|
|
94
|
+
* Process:
|
|
95
|
+
* 1. Finds the index of the selected result in the flatResults array,
|
|
96
|
+
* 2. Increments or decrements this index by the supplied adjustment amount,
|
|
97
|
+
* 3. Sets the new selectedResultId based on the modifed index
|
|
98
|
+
*/
|
|
123
99
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "adjustSelectedResultIndex", function (adjustment) {
|
|
124
100
|
var currentIndex = getResultIndexById(_this.flatResults, _this.state.selectedResultId);
|
|
125
101
|
var newIndex = adjustIndex(_this.flatResults.length, currentIndex, adjustment);
|
|
126
102
|
var selectedResultId = getResultIdByIndex(_this.flatResults, newIndex);
|
|
127
|
-
|
|
128
103
|
_this.setState({
|
|
129
104
|
selectedResultId: selectedResultId
|
|
130
105
|
});
|
|
131
|
-
|
|
132
106
|
if (selectedResultId) {
|
|
133
107
|
_this.fireKeyboardControlEvent(selectedResultId);
|
|
134
108
|
}
|
|
135
|
-
|
|
136
109
|
if (_this.props.onSelectedResultIdChanged) {
|
|
137
110
|
_this.props.onSelectedResultIdChanged(selectedResultId);
|
|
138
111
|
}
|
|
139
112
|
});
|
|
113
|
+
/** Select next result */
|
|
140
114
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectNext", function () {
|
|
141
115
|
_this.adjustSelectedResultIndex(+1);
|
|
142
116
|
});
|
|
117
|
+
/** Select previous result */
|
|
143
118
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "selectPrevious", function () {
|
|
144
119
|
_this.adjustSelectedResultIndex(-1);
|
|
145
120
|
});
|
|
121
|
+
/**
|
|
122
|
+
* Callback for register results in flatResults
|
|
123
|
+
*/
|
|
146
124
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleRegisterResult", function (result) {
|
|
147
125
|
if (!getResultById(_this.flatResults, result.props.resultId)) {
|
|
148
126
|
_this.flatResults.push(result);
|
|
149
127
|
}
|
|
150
128
|
});
|
|
129
|
+
/**
|
|
130
|
+
* Callback for unregister results in flatResults
|
|
131
|
+
* It will reconcile a list of results for keyboard navigation after every update.
|
|
132
|
+
* 1. Component starts with an empty list of results
|
|
133
|
+
* 2. componentDidMount / componentDidUpdate lifecycle methods in ResultBase will be invoked
|
|
134
|
+
* 3. All ResultBase components call registerResult() in order to register itself in quick search
|
|
135
|
+
* 4. All ResultBase components call unregisterResult() in order to unregister itself in quick search
|
|
136
|
+
*/
|
|
151
137
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleUnregisterResult", function (result) {
|
|
152
138
|
var resultIndex = getResultIndexById(_this.flatResults, result.props.resultId);
|
|
153
|
-
|
|
154
139
|
if (resultIndex !== null && +resultIndex >= 0) {
|
|
155
140
|
_this.flatResults.splice(resultIndex, 1);
|
|
156
141
|
}
|
|
157
142
|
});
|
|
143
|
+
/**
|
|
144
|
+
* Callback for mouseEnter events on individual results
|
|
145
|
+
* Move selection to hovered result
|
|
146
|
+
*/
|
|
158
147
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResultMouseEnter", function (resultData) {
|
|
159
148
|
_this.setState({
|
|
160
149
|
selectedResultId: resultData && resultData.resultId
|
|
161
150
|
});
|
|
162
151
|
});
|
|
152
|
+
/**
|
|
153
|
+
* Callback for mouseLeave events on individual results
|
|
154
|
+
* Clear result selection
|
|
155
|
+
*/
|
|
163
156
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleResultMouseLeave", function () {
|
|
164
157
|
_this.setState({
|
|
165
158
|
selectedResultId: null
|
|
166
159
|
});
|
|
167
160
|
});
|
|
161
|
+
/**
|
|
162
|
+
* Clear result selection when search input is blurred
|
|
163
|
+
*/
|
|
168
164
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSearchBlur", function (event) {
|
|
169
165
|
_this.props.onSearchBlur(event);
|
|
170
|
-
|
|
171
166
|
_this.setState({
|
|
172
167
|
selectedResultId: null
|
|
173
168
|
});
|
|
174
169
|
});
|
|
175
170
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "onInput", function (event) {
|
|
176
171
|
var onSearchInput = _this.props.onSearchInput;
|
|
177
|
-
|
|
178
172
|
_this.setState({
|
|
179
173
|
value: event.currentTarget.value
|
|
180
174
|
});
|
|
181
|
-
|
|
182
175
|
if (onSearchInput) {
|
|
183
176
|
onSearchInput(event);
|
|
184
177
|
}
|
|
185
178
|
});
|
|
179
|
+
/**
|
|
180
|
+
* Keyboard controls
|
|
181
|
+
* Up - Select previous result
|
|
182
|
+
* Down - Select next result
|
|
183
|
+
* Enter - Submit selected result
|
|
184
|
+
* Tab / ArrowRight - Accept autocomplete
|
|
185
|
+
*/
|
|
186
186
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "handleSearchKeyDown", function (event) {
|
|
187
187
|
var firePrivateAnalyticsEvent = _this.props.firePrivateAnalyticsEvent;
|
|
188
|
-
|
|
189
188
|
_this.props.onSearchKeyDown(event);
|
|
189
|
+
_this.lastKeyPressed = event.key;
|
|
190
190
|
|
|
191
|
-
|
|
191
|
+
// Need to check for keyCode for up/down/enter in case user is composing using an IME
|
|
192
192
|
// fixes https://ecosystem.atlassian.net/browse/DS-6518
|
|
193
|
-
|
|
194
193
|
if (event.key === 'ArrowUp' && event.keyCode === (0, _keycode.default)('up')) {
|
|
195
194
|
event.preventDefault(); // Don't move cursor around in search input field
|
|
196
|
-
|
|
197
195
|
_this.selectPrevious();
|
|
198
196
|
} else if (event.key === 'ArrowDown' && event.keyCode === (0, _keycode.default)('down')) {
|
|
199
197
|
event.preventDefault(); // Don't move cursor around in search input field
|
|
200
|
-
|
|
201
198
|
_this.selectNext();
|
|
202
199
|
} else if (event.key === 'Enter' && event.keyCode === (0, _keycode.default)('enter')) {
|
|
203
200
|
// shift key pressed or no result selected
|
|
@@ -210,21 +207,17 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
210
207
|
method: 'shortcut'
|
|
211
208
|
});
|
|
212
209
|
}
|
|
213
|
-
|
|
214
210
|
_this.props.onSearchSubmit(event);
|
|
215
211
|
} else {
|
|
216
212
|
event.preventDefault(); // Don't fire submit event from input
|
|
217
|
-
|
|
218
213
|
var result = getResultById(_this.flatResults, _this.state.selectedResultId);
|
|
219
|
-
|
|
220
214
|
if (!result || !result.props) {
|
|
221
215
|
return;
|
|
222
|
-
}
|
|
223
|
-
|
|
216
|
+
}
|
|
224
217
|
|
|
218
|
+
// Capture when users are using the keyboard to submit
|
|
225
219
|
if (typeof firePrivateAnalyticsEvent === 'function') {
|
|
226
220
|
_this.fireKeyboardControlEvent(_this.state.selectedResultId);
|
|
227
|
-
|
|
228
221
|
firePrivateAnalyticsEvent(_constants.QS_ANALYTICS_EV_SUBMIT, _objectSpread(_objectSpread({}, result.getAnalyticsData()), {}, {
|
|
229
222
|
method: 'returnKey',
|
|
230
223
|
newTab: false,
|
|
@@ -232,9 +225,7 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
232
225
|
resultCount: _this.flatResults.length
|
|
233
226
|
}));
|
|
234
227
|
}
|
|
235
|
-
|
|
236
228
|
var _preventDefault = false;
|
|
237
|
-
|
|
238
229
|
if (result.props.onClick) {
|
|
239
230
|
result.props.onClick({
|
|
240
231
|
resultId: result.props.resultId,
|
|
@@ -247,18 +238,16 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
247
238
|
})
|
|
248
239
|
});
|
|
249
240
|
}
|
|
250
|
-
|
|
251
241
|
if (result.props.href && !_preventDefault) {
|
|
252
242
|
window.location.assign(result.props.href);
|
|
253
243
|
}
|
|
254
244
|
}
|
|
255
245
|
} else if (event.key === 'Tab' || event.key === 'ArrowRight') {
|
|
256
246
|
var autocompleteText = _this.props.autocompleteText;
|
|
257
|
-
|
|
258
|
-
|
|
247
|
+
if (autocompleteText && autocompleteText.length > 0 &&
|
|
248
|
+
// multiple Tab or ArrowRight
|
|
259
249
|
autocompleteText.slice(-1) !== ' ') {
|
|
260
250
|
_this.acceptAutocomplete(event, autocompleteText);
|
|
261
|
-
|
|
262
251
|
event.preventDefault();
|
|
263
252
|
}
|
|
264
253
|
}
|
|
@@ -266,16 +255,13 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
266
255
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "acceptAutocomplete", function (event, text) {
|
|
267
256
|
var onSearchInput = _this.props.onSearchInput;
|
|
268
257
|
var newValue = "".concat(text, " ");
|
|
269
|
-
|
|
270
258
|
if (_this.inputSearchRef) {
|
|
271
259
|
_this.setState({
|
|
272
260
|
value: newValue
|
|
273
|
-
});
|
|
274
|
-
|
|
275
|
-
|
|
261
|
+
});
|
|
262
|
+
// @ts-ignore unchecked
|
|
276
263
|
_this.inputSearchRef.value = newValue;
|
|
277
264
|
}
|
|
278
|
-
|
|
279
265
|
if (onSearchInput) {
|
|
280
266
|
onSearchInput(event, true);
|
|
281
267
|
}
|
|
@@ -286,7 +272,8 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
286
272
|
}
|
|
287
273
|
});
|
|
288
274
|
(0, _defineProperty2.default)((0, _assertThisInitialized2.default)(_this), "focusSearchInput", function () {
|
|
289
|
-
if (_this.inputSearchRef &&
|
|
275
|
+
if (_this.inputSearchRef &&
|
|
276
|
+
// @ts-ignore unchecked
|
|
290
277
|
typeof _this.inputSearchRef.focus === 'function') {
|
|
291
278
|
// @ts-ignore unchecked
|
|
292
279
|
_this.inputSearchRef.focus();
|
|
@@ -310,12 +297,10 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
310
297
|
};
|
|
311
298
|
return _this;
|
|
312
299
|
}
|
|
313
|
-
|
|
314
300
|
(0, _createClass2.default)(QuickSearch, [{
|
|
315
301
|
key: "componentDidMount",
|
|
316
302
|
value: function componentDidMount() {
|
|
317
303
|
var firePrivateAnalyticsEvent = this.props.firePrivateAnalyticsEvent;
|
|
318
|
-
|
|
319
304
|
if (firePrivateAnalyticsEvent) {
|
|
320
305
|
firePrivateAnalyticsEvent(_constants.QS_ANALYTICS_EV_OPEN, {});
|
|
321
306
|
}
|
|
@@ -324,7 +309,6 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
324
309
|
key: "componentWillUnmount",
|
|
325
310
|
value: function componentWillUnmount() {
|
|
326
311
|
var firePrivateAnalyticsEvent = this.props.firePrivateAnalyticsEvent;
|
|
327
|
-
|
|
328
312
|
if (firePrivateAnalyticsEvent) {
|
|
329
313
|
firePrivateAnalyticsEvent(_constants.QS_ANALYTICS_EV_CLOSE, {});
|
|
330
314
|
}
|
|
@@ -340,13 +324,12 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
340
324
|
this.setState({
|
|
341
325
|
selectedResultId: nextProps.selectedResultId || null
|
|
342
326
|
});
|
|
343
|
-
}
|
|
344
|
-
|
|
327
|
+
}
|
|
345
328
|
|
|
329
|
+
// keep context state in sync
|
|
346
330
|
var _this$state$context = this.state.context,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
331
|
+
sendAnalytics = _this$state$context.sendAnalytics,
|
|
332
|
+
linkComponent = _this$state$context.linkComponent;
|
|
350
333
|
if (sendAnalytics !== nextProps.firePrivateAnalyticsEvent || linkComponent !== nextProps.linkComponent) {
|
|
351
334
|
this.setState({
|
|
352
335
|
context: _objectSpread(_objectSpread({}, this.state.context), {}, {
|
|
@@ -355,17 +338,15 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
355
338
|
})
|
|
356
339
|
});
|
|
357
340
|
}
|
|
341
|
+
|
|
358
342
|
/**
|
|
359
343
|
* Capture whether user needed to query in order to find their target result.
|
|
360
344
|
* Only fire once per mount. Only fire when a search term is entered and the previous search
|
|
361
345
|
* term was empty.
|
|
362
346
|
*/
|
|
363
|
-
|
|
364
|
-
|
|
365
347
|
if (!this.hasSearchQueryEventFired && !this.props.value && nextProps.value) {
|
|
366
348
|
this.hasSearchQueryEventFired = true;
|
|
367
349
|
var firePrivateAnalyticsEvent = this.props.firePrivateAnalyticsEvent;
|
|
368
|
-
|
|
369
350
|
if (firePrivateAnalyticsEvent) {
|
|
370
351
|
firePrivateAnalyticsEvent(_constants.QS_ANALYTICS_EV_QUERY_ENTERED, {});
|
|
371
352
|
}
|
|
@@ -375,10 +356,8 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
375
356
|
key: "fireKeyboardControlEvent",
|
|
376
357
|
value: function fireKeyboardControlEvent(selectedResultId) {
|
|
377
358
|
var firePrivateAnalyticsEvent = this.props.firePrivateAnalyticsEvent;
|
|
378
|
-
|
|
379
359
|
if (firePrivateAnalyticsEvent) {
|
|
380
360
|
var result = getResultById(this.flatResults, selectedResultId);
|
|
381
|
-
|
|
382
361
|
if (result) {
|
|
383
362
|
firePrivateAnalyticsEvent(_constants.QS_ANALYTICS_EV_KB_CTRLS_USED, _objectSpread(_objectSpread({}, result.getAnalyticsData()), {}, {
|
|
384
363
|
key: this.lastKeyPressed,
|
|
@@ -386,19 +365,8 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
386
365
|
}));
|
|
387
366
|
}
|
|
388
367
|
}
|
|
389
|
-
|
|
390
368
|
this.lastKeyPressed = '';
|
|
391
369
|
}
|
|
392
|
-
/**
|
|
393
|
-
* Uses the virtual list, this.flatResults, to move the selection across grouped results as if
|
|
394
|
-
* results were in a single, circular list.
|
|
395
|
-
*
|
|
396
|
-
* Process:
|
|
397
|
-
* 1. Finds the index of the selected result in the flatResults array,
|
|
398
|
-
* 2. Increments or decrements this index by the supplied adjustment amount,
|
|
399
|
-
* 3. Sets the new selectedResultId based on the modifed index
|
|
400
|
-
*/
|
|
401
|
-
|
|
402
370
|
}, {
|
|
403
371
|
key: "render",
|
|
404
372
|
value: function render() {
|
|
@@ -427,8 +395,6 @@ var QuickSearch = /*#__PURE__*/function (_React$Component) {
|
|
|
427
395
|
* `withAnalytics` - Injects analytics firing methods that are picked up by
|
|
428
396
|
* @atlaskit/analytics/AnalyticsListener.
|
|
429
397
|
*/
|
|
430
|
-
|
|
431
|
-
|
|
432
398
|
exports.QuickSearch = QuickSearch;
|
|
433
399
|
(0, _defineProperty2.default)(QuickSearch, "defaultProps", {
|
|
434
400
|
children: [],
|
|
@@ -440,8 +406,7 @@ exports.QuickSearch = QuickSearch;
|
|
|
440
406
|
placeholder: 'Search',
|
|
441
407
|
value: ''
|
|
442
408
|
});
|
|
443
|
-
|
|
444
|
-
|
|
409
|
+
var _default = (0, _decorateWithAnalyticsData.default)(
|
|
410
|
+
// @ts-ignore
|
|
445
411
|
(0, _analytics.withAnalytics)(QuickSearch, {}, {}));
|
|
446
|
-
|
|
447
412
|
exports.default = _default;
|
|
@@ -1,54 +1,33 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
var _typeof = require("@babel/runtime/helpers/typeof");
|
|
6
|
-
|
|
7
5
|
Object.defineProperty(exports, "__esModule", {
|
|
8
6
|
value: true
|
|
9
7
|
});
|
|
10
8
|
exports.default = void 0;
|
|
11
|
-
|
|
12
9
|
var _extends2 = _interopRequireDefault(require("@babel/runtime/helpers/extends"));
|
|
13
|
-
|
|
14
10
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
15
|
-
|
|
16
11
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
17
|
-
|
|
18
12
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
19
|
-
|
|
20
13
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
21
|
-
|
|
22
14
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
23
|
-
|
|
24
15
|
var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
|
|
25
|
-
|
|
26
16
|
var _react = _interopRequireDefault(require("react"));
|
|
27
|
-
|
|
28
17
|
var _item = _interopRequireWildcard(require("@atlaskit/item"));
|
|
29
|
-
|
|
30
18
|
var _styled = require("./styled");
|
|
31
|
-
|
|
32
19
|
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); }
|
|
33
|
-
|
|
34
20
|
function _interopRequireWildcard(obj, nodeInterop) { if (!nodeInterop && obj && obj.__esModule) { return obj; } if (obj === null || _typeof(obj) !== "object" && typeof obj !== "function") { return { default: obj }; } var cache = _getRequireWildcardCache(nodeInterop); if (cache && cache.has(obj)) { return cache.get(obj); } var newObj = {}; var hasPropertyDescriptor = Object.defineProperty && Object.getOwnPropertyDescriptor; for (var key in obj) { if (key !== "default" && Object.prototype.hasOwnProperty.call(obj, key)) { var desc = hasPropertyDescriptor ? Object.getOwnPropertyDescriptor(obj, key) : null; if (desc && (desc.get || desc.set)) { Object.defineProperty(newObj, key, desc); } else { newObj[key] = obj[key]; } } } newObj.default = obj; if (cache) { cache.set(obj, newObj); } return newObj; }
|
|
35
|
-
|
|
36
21
|
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
22
|
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
23
|
var Item = (0, _item.withItemClick)((0, _item.withItemFocus)(_item.default));
|
|
41
|
-
|
|
42
24
|
var ResultItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
43
25
|
(0, _inherits2.default)(ResultItem, _React$PureComponent);
|
|
44
|
-
|
|
45
26
|
var _super = _createSuper(ResultItem);
|
|
46
|
-
|
|
47
27
|
function ResultItem() {
|
|
48
28
|
(0, _classCallCheck2.default)(this, ResultItem);
|
|
49
29
|
return _super.apply(this, arguments);
|
|
50
30
|
}
|
|
51
|
-
|
|
52
31
|
(0, _createClass2.default)(ResultItem, [{
|
|
53
32
|
key: "render",
|
|
54
33
|
value: function render() {
|
|
@@ -78,7 +57,6 @@ var ResultItem = /*#__PURE__*/function (_React$PureComponent) {
|
|
|
78
57
|
}]);
|
|
79
58
|
return ResultItem;
|
|
80
59
|
}(_react.default.PureComponent);
|
|
81
|
-
|
|
82
60
|
(0, _defineProperty2.default)(ResultItem, "defaultProps", {
|
|
83
61
|
isSelected: false,
|
|
84
62
|
isMouseSelected: false
|
|
@@ -1,51 +1,34 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.default = void 0;
|
|
9
|
-
|
|
10
8
|
var _classCallCheck2 = _interopRequireDefault(require("@babel/runtime/helpers/classCallCheck"));
|
|
11
|
-
|
|
12
9
|
var _createClass2 = _interopRequireDefault(require("@babel/runtime/helpers/createClass"));
|
|
13
|
-
|
|
14
10
|
var _inherits2 = _interopRequireDefault(require("@babel/runtime/helpers/inherits"));
|
|
15
|
-
|
|
16
11
|
var _possibleConstructorReturn2 = _interopRequireDefault(require("@babel/runtime/helpers/possibleConstructorReturn"));
|
|
17
|
-
|
|
18
12
|
var _getPrototypeOf2 = _interopRequireDefault(require("@babel/runtime/helpers/getPrototypeOf"));
|
|
19
|
-
|
|
20
13
|
var _react = _interopRequireDefault(require("react"));
|
|
21
|
-
|
|
22
14
|
var _item = require("@atlaskit/item");
|
|
23
|
-
|
|
24
15
|
var _styled = require("./styled");
|
|
25
|
-
|
|
26
16
|
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); }; }
|
|
27
|
-
|
|
28
17
|
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; } }
|
|
29
|
-
|
|
30
18
|
var ResultItemGroup = /*#__PURE__*/function (_React$Component) {
|
|
31
19
|
(0, _inherits2.default)(ResultItemGroup, _React$Component);
|
|
32
|
-
|
|
33
20
|
var _super = _createSuper(ResultItemGroup);
|
|
34
|
-
|
|
35
21
|
function ResultItemGroup() {
|
|
36
22
|
(0, _classCallCheck2.default)(this, ResultItemGroup);
|
|
37
23
|
return _super.apply(this, arguments);
|
|
38
24
|
}
|
|
39
|
-
|
|
40
25
|
(0, _createClass2.default)(ResultItemGroup, [{
|
|
41
26
|
key: "render",
|
|
42
27
|
value: function render() {
|
|
43
28
|
var _this$props = this.props,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
29
|
+
title = _this$props.title,
|
|
30
|
+
children = _this$props.children;
|
|
47
31
|
var wrappedTitle = /*#__PURE__*/_react.default.createElement(_styled.ResultItemGroupHeader, null, /*#__PURE__*/_react.default.createElement(_styled.ResultItemGroupTitle, null, title));
|
|
48
|
-
|
|
49
32
|
return /*#__PURE__*/_react.default.createElement(_item.ItemGroup, {
|
|
50
33
|
title: wrappedTitle
|
|
51
34
|
}, children);
|
|
@@ -53,5 +36,4 @@ var ResultItemGroup = /*#__PURE__*/function (_React$Component) {
|
|
|
53
36
|
}]);
|
|
54
37
|
return ResultItemGroup;
|
|
55
38
|
}(_react.default.Component);
|
|
56
|
-
|
|
57
39
|
exports.default = ResultItemGroup;
|
|
@@ -1,53 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
|
|
3
3
|
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
-
|
|
5
4
|
Object.defineProperty(exports, "__esModule", {
|
|
6
5
|
value: true
|
|
7
6
|
});
|
|
8
7
|
exports.ResultItemTextAfter = exports.ResultItemSubText = exports.ResultItemIcon = exports.ResultItemGroupTitle = exports.ResultItemGroupHeader = exports.ResultItemCaption = exports.ResultItemAfterWrapper = exports.ResultItemAfter = void 0;
|
|
9
|
-
|
|
10
8
|
var _taggedTemplateLiteral2 = _interopRequireDefault(require("@babel/runtime/helpers/taggedTemplateLiteral"));
|
|
11
|
-
|
|
12
9
|
var _styledComponents = _interopRequireDefault(require("styled-components"));
|
|
13
|
-
|
|
14
|
-
var _constants = require("@atlaskit/theme/constants");
|
|
15
|
-
|
|
16
10
|
var _colors = require("@atlaskit/theme/colors");
|
|
17
|
-
|
|
18
11
|
var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8;
|
|
19
|
-
|
|
20
|
-
var ResultItemGroupHeader = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin-left: -", "px;\n margin-top: ", "px;\n"])), (0, _constants.gridSize)() * 1.5, (0, _constants.gridSize)() * 1.5);
|
|
21
|
-
|
|
12
|
+
var ResultItemGroupHeader = _styledComponents.default.div(_templateObject || (_templateObject = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n margin-left: calc(-1 * ", ");\n margin-top: ", ";\n"])), "var(--ds-space-150, 12px)", "var(--ds-space-150, 12px)");
|
|
22
13
|
exports.ResultItemGroupHeader = ResultItemGroupHeader;
|
|
23
|
-
|
|
24
|
-
var ResultItemGroupTitle = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 11px;\n line-height: ", "px;\n font-weight: 600;\n"])), (0, _constants.gridSize)() * 2);
|
|
25
|
-
|
|
14
|
+
var ResultItemGroupTitle = _styledComponents.default.div(_templateObject2 || (_templateObject2 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 11px;\n line-height: ", ";\n font-weight: 600;\n"])), "var(--ds-font-lineHeight-100, 16px)");
|
|
26
15
|
exports.ResultItemGroupTitle = ResultItemGroupTitle;
|
|
27
|
-
|
|
28
16
|
var ResultItemAfter = _styledComponents.default.div(_templateObject3 || (_templateObject3 = (0, _taggedTemplateLiteral2.default)(["\n min-width: ", ";\n"])), function (_ref) {
|
|
29
17
|
var shouldTakeSpace = _ref.shouldTakeSpace;
|
|
30
18
|
return shouldTakeSpace ? '24px' : 0;
|
|
31
19
|
});
|
|
32
|
-
|
|
33
20
|
exports.ResultItemAfter = ResultItemAfter;
|
|
34
|
-
|
|
35
21
|
var ResultItemAfterWrapper = _styledComponents.default.div(_templateObject4 || (_templateObject4 = (0, _taggedTemplateLiteral2.default)(["\n display: flex;\n"])));
|
|
36
|
-
|
|
37
22
|
exports.ResultItemAfterWrapper = ResultItemAfterWrapper;
|
|
38
|
-
|
|
39
|
-
var ResultItemCaption = _styledComponents.default.span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 12px;\n margin-left: ", "px;\n"])), _colors.N200, (0, _constants.gridSize)());
|
|
40
|
-
|
|
23
|
+
var ResultItemCaption = _styledComponents.default.span(_templateObject5 || (_templateObject5 = (0, _taggedTemplateLiteral2.default)(["\n color: ", ";\n font-size: 12px;\n margin-left: ", ";\n"])), _colors.N200, "var(--ds-space-100, 8px)");
|
|
41
24
|
exports.ResultItemCaption = ResultItemCaption;
|
|
42
|
-
|
|
43
25
|
var ResultItemSubText = _styledComponents.default.span(_templateObject6 || (_templateObject6 = (0, _taggedTemplateLiteral2.default)(["\n font-size: 12px;\n color: ", ";\n"])), _colors.N200);
|
|
44
|
-
|
|
45
26
|
exports.ResultItemSubText = ResultItemSubText;
|
|
46
|
-
|
|
47
|
-
var ResultItemIcon = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\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"])), (0, _constants.gridSize)() * 3, (0, _constants.gridSize)() * 3);
|
|
48
|
-
|
|
27
|
+
var ResultItemIcon = _styledComponents.default.div(_templateObject7 || (_templateObject7 = (0, _taggedTemplateLiteral2.default)(["\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: ", ";\n width: ", ";\n }\n"])), "var(--ds-space-300, 24px)", "var(--ds-space-300, 24px)");
|
|
49
28
|
exports.ResultItemIcon = ResultItemIcon;
|
|
50
|
-
|
|
51
29
|
var ResultItemTextAfter = _styledComponents.default.div(_templateObject8 || (_templateObject8 = (0, _taggedTemplateLiteral2.default)(["\n position: relative;\n z-index: 1;\n"])));
|
|
52
|
-
|
|
53
30
|
exports.ResultItemTextAfter = ResultItemTextAfter;
|