@atlaskit/link-picker 1.13.0 → 1.13.2
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/dist/cjs/analytics.codegen.js +1 -1
- package/dist/cjs/common/analytics/context.js +3 -1
- package/dist/cjs/ui/link-picker/index.js +7 -7
- package/dist/cjs/ui/link-picker/link-search-list/index.js +3 -0
- package/dist/cjs/ui/link-picker/link-search-list/use-track-results-shown/index.js +58 -0
- package/dist/cjs/version.json +1 -1
- package/dist/es2019/analytics.codegen.js +1 -1
- package/dist/es2019/common/analytics/context.js +5 -1
- package/dist/es2019/ui/link-picker/index.js +7 -7
- package/dist/es2019/ui/link-picker/link-search-list/index.js +2 -0
- package/dist/es2019/ui/link-picker/link-search-list/use-track-results-shown/index.js +34 -0
- package/dist/es2019/version.json +1 -1
- package/dist/esm/analytics.codegen.js +1 -1
- package/dist/esm/common/analytics/context.js +3 -1
- package/dist/esm/ui/link-picker/index.js +7 -7
- package/dist/esm/ui/link-picker/link-search-list/index.js +2 -0
- package/dist/esm/ui/link-picker/link-search-list/use-track-results-shown/index.js +40 -0
- package/dist/esm/version.json +1 -1
- package/dist/types/analytics.codegen.d.ts +9 -1
- package/dist/types/common/analytics/context.d.ts +2 -1
- package/dist/types/ui/link-picker/link-search-list/use-track-results-shown/index.d.ts +2 -0
- package/package.json +6 -13
- package/report.api.md +3 -3
- package/dist/types-ts4.0/analytics.codegen.d.ts +0 -55
- package/dist/types-ts4.0/common/analytics/context.d.ts +0 -28
- package/dist/types-ts4.0/common/analytics/experiences.d.ts +0 -11
- package/dist/types-ts4.0/common/analytics/index.d.ts +0 -2
- package/dist/types-ts4.0/common/analytics/input-field-tracking.d.ts +0 -17
- package/dist/types-ts4.0/common/constants.d.ts +0 -2
- package/dist/types-ts4.0/common/generic-error-svg/index.d.ts +0 -4
- package/dist/types-ts4.0/common/generic-error-svg/styled.d.ts +0 -1
- package/dist/types-ts4.0/common/utils/url.d.ts +0 -5
- package/dist/types-ts4.0/controllers/session-provider/index.d.ts +0 -10
- package/dist/types-ts4.0/controllers/use-fix-height/index.d.ts +0 -8
- package/dist/types-ts4.0/index.d.ts +0 -3
- package/dist/types-ts4.0/services/use-plugins/index.d.ts +0 -14
- package/dist/types-ts4.0/services/use-plugins/reducer.d.ts +0 -33
- package/dist/types-ts4.0/services/use-plugins/utils.d.ts +0 -18
- package/dist/types-ts4.0/services/use-search-query/index.d.ts +0 -3
- package/dist/types-ts4.0/ui/error-boundary/error-boundary-base/index.d.ts +0 -18
- package/dist/types-ts4.0/ui/error-boundary/error-boundary-fallback/index.d.ts +0 -3
- package/dist/types-ts4.0/ui/error-boundary/index.d.ts +0 -7
- package/dist/types-ts4.0/ui/index.d.ts +0 -5
- package/dist/types-ts4.0/ui/link-picker/announcer.d.ts +0 -22
- package/dist/types-ts4.0/ui/link-picker/browser.d.ts +0 -15
- package/dist/types-ts4.0/ui/link-picker/form-footer/index.d.ts +0 -13
- package/dist/types-ts4.0/ui/link-picker/form-footer/styled.d.ts +0 -1
- package/dist/types-ts4.0/ui/link-picker/index.d.ts +0 -75
- package/dist/types-ts4.0/ui/link-picker/link-search-error/index.d.ts +0 -20
- package/dist/types-ts4.0/ui/link-picker/link-search-list/index.d.ts +0 -42
- package/dist/types-ts4.0/ui/link-picker/link-search-list/link-search-no-results/index.d.ts +0 -19
- package/dist/types-ts4.0/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.d.ts +0 -4
- package/dist/types-ts4.0/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/styled.d.ts +0 -1
- package/dist/types-ts4.0/ui/link-picker/link-search-list/link-search-no-results/styled.d.ts +0 -1
- package/dist/types-ts4.0/ui/link-picker/link-search-list/styled.d.ts +0 -4
- package/dist/types-ts4.0/ui/link-picker/list-item/index.d.ts +0 -17
- package/dist/types-ts4.0/ui/link-picker/list-item/styled.d.ts +0 -9
- package/dist/types-ts4.0/ui/link-picker/messages.d.ts +0 -85
- package/dist/types-ts4.0/ui/link-picker/styled.d.ts +0 -9
- package/dist/types-ts4.0/ui/link-picker/text-input/index.d.ts +0 -18
- package/dist/types-ts4.0/ui/link-picker/text-input/styled.d.ts +0 -2
- package/dist/types-ts4.0/ui/link-picker/track-mount/index.d.ts +0 -5
- package/dist/types-ts4.0/ui/link-picker/track-tab-viewed/index.d.ts +0 -4
- package/dist/types-ts4.0/ui/link-picker/transformTimeStamp.d.ts +0 -3
- package/dist/types-ts4.0/ui/link-picker/utils.d.ts +0 -10
- package/dist/types-ts4.0/ui/loader-fallback/index.d.ts +0 -3
- package/dist/types-ts4.0/ui/scrolling-tabs/index.d.ts +0 -7
- package/dist/types-ts4.0/ui/scrolling-tabs/scrolling-tabs.d.ts +0 -11
- package/dist/types-ts4.0/ui/scrolling-tabs/styles.d.ts +0 -6
- package/dist/types-ts4.0/ui/types.d.ts +0 -59
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,17 @@
|
|
|
1
1
|
# @atlaskit/link-picker
|
|
2
2
|
|
|
3
|
+
## 1.13.2
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
|
|
9
|
+
## 1.13.1
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [`2933e4ddeb0`](https://bitbucket.org/atlassian/atlassian-frontend/commits/2933e4ddeb0) - Add searchResults shown analytic event for pre-query and post-query results
|
|
14
|
+
|
|
3
15
|
## 1.13.0
|
|
4
16
|
|
|
5
17
|
### Minor Changes
|
|
@@ -10,7 +10,7 @@ exports.default = void 0;
|
|
|
10
10
|
*
|
|
11
11
|
* Generates analytics utilities from the package analytics spec yaml
|
|
12
12
|
*
|
|
13
|
-
* @codegen <<SignedSource::
|
|
13
|
+
* @codegen <<SignedSource::758b8a20cae1b6d410cecd4493453a21>>
|
|
14
14
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
15
15
|
*/
|
|
16
16
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -132,8 +132,10 @@ function withLinkPickerAnalyticsContext(WrappedComponent) {
|
|
|
132
132
|
getAttributes = _useLinkPickerAnalyti.getAttributes;
|
|
133
133
|
|
|
134
134
|
var onEvent = (0, _react.useCallback)(function (event) {
|
|
135
|
+
var _event$payload$attrib;
|
|
136
|
+
|
|
135
137
|
event.update({
|
|
136
|
-
attributes: getAttributes()
|
|
138
|
+
attributes: _objectSpread(_objectSpread({}, getAttributes()), (_event$payload$attrib = event.payload.attributes) !== null && _event$payload$attrib !== void 0 ? _event$payload$attrib : {})
|
|
137
139
|
});
|
|
138
140
|
}, [getAttributes]);
|
|
139
141
|
return /*#__PURE__*/_react.default.createElement(_analyticsNext.AnalyticsListener, {
|
|
@@ -194,12 +194,12 @@ function LinkPicker(_ref) {
|
|
|
194
194
|
dispatch({
|
|
195
195
|
url: e.currentTarget.value
|
|
196
196
|
});
|
|
197
|
-
}, [trackAttribute]);
|
|
197
|
+
}, [dispatch, trackAttribute]);
|
|
198
198
|
var handleChangeText = (0, _react.useCallback)(function (e) {
|
|
199
199
|
dispatch({
|
|
200
200
|
displayText: e.currentTarget.value
|
|
201
201
|
});
|
|
202
|
-
}, []);
|
|
202
|
+
}, [dispatch]);
|
|
203
203
|
var handleKeyDown = (0, _react.useCallback)(function (event) {
|
|
204
204
|
var key = event.key;
|
|
205
205
|
var KEY_ARROW_DOWN = 'ArrowDown';
|
|
@@ -241,10 +241,10 @@ function LinkPicker(_ref) {
|
|
|
241
241
|
invalidUrl: false
|
|
242
242
|
});
|
|
243
243
|
}
|
|
244
|
-
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
244
|
+
}, [dispatch, activeIndex, items, trackAttribute, activePlugin]);
|
|
245
245
|
var handleClear = (0, _react.useCallback)(function (field) {
|
|
246
246
|
dispatch((0, _defineProperty2.default)({}, field, ''));
|
|
247
|
-
}, []);
|
|
247
|
+
}, [dispatch]);
|
|
248
248
|
var handleUrlClear = (0, _react.useCallback)(function () {
|
|
249
249
|
trackAttribute('linkFieldContentInputSource', null);
|
|
250
250
|
handleClear('url');
|
|
@@ -256,7 +256,7 @@ function LinkPicker(_ref) {
|
|
|
256
256
|
dispatch({
|
|
257
257
|
activeIndex: index !== null && index !== void 0 ? index : -1
|
|
258
258
|
});
|
|
259
|
-
}, [items]);
|
|
259
|
+
}, [dispatch, items]);
|
|
260
260
|
var handleMouseLeaveResultItem = (0, _react.useCallback)(function (objectId) {
|
|
261
261
|
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
262
262
|
return item.objectId === objectId;
|
|
@@ -267,7 +267,7 @@ function LinkPicker(_ref) {
|
|
|
267
267
|
activeIndex: -1
|
|
268
268
|
});
|
|
269
269
|
}
|
|
270
|
-
}, [activeIndex, items]);
|
|
270
|
+
}, [dispatch, activeIndex, items]);
|
|
271
271
|
var handleInsert = (0, _react.useCallback)(function (url, title, inputType) {
|
|
272
272
|
var event = createAnalyticsEvent((0, _analytics.default)('ui.form.submitted.linkPicker', {})); // Clone the event so that it can be emitted for consumer usage
|
|
273
273
|
// This must happen BEFORE the original event is fired!
|
|
@@ -326,7 +326,7 @@ function LinkPicker(_ref) {
|
|
|
326
326
|
return dispatch({
|
|
327
327
|
invalidUrl: true
|
|
328
328
|
});
|
|
329
|
-
}, [handleInsert, isSelectedItem, selectedItem, url]);
|
|
329
|
+
}, [dispatch, handleInsert, isSelectedItem, selectedItem, url]);
|
|
330
330
|
var handleTabChange = (0, _react.useCallback)(function (activeTab) {
|
|
331
331
|
var _plugins$activeTab$ta, _plugins$activeTab;
|
|
332
332
|
|
|
@@ -31,6 +31,8 @@ var _styled = require("./styled");
|
|
|
31
31
|
|
|
32
32
|
var _linkSearchNoResults = _interopRequireWildcard(require("./link-search-no-results"));
|
|
33
33
|
|
|
34
|
+
var _useTrackResultsShown = require("./use-track-results-shown");
|
|
35
|
+
|
|
34
36
|
var _excluded = ["onSelect", "onMouseEnter", "onMouseLeave", "items", "activeIndex", "selectedIndex", "isLoading", "ariaControls", "ariaLabelledBy", "role", "id", "hasSearchTerm"];
|
|
35
37
|
|
|
36
38
|
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); }
|
|
@@ -85,6 +87,7 @@ var LinkSearchList = /*#__PURE__*/(0, _react.forwardRef)(function (_ref, ref) {
|
|
|
85
87
|
var itemsContent;
|
|
86
88
|
var loadingContent;
|
|
87
89
|
var linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
|
|
90
|
+
(0, _useTrackResultsShown.useTrackResultsShown)(isLoading, items, hasSearchTerm);
|
|
88
91
|
|
|
89
92
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
90
93
|
return (0, _react2.jsx)(_linkSearchNoResults.default, null);
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
|
|
4
|
+
|
|
5
|
+
Object.defineProperty(exports, "__esModule", {
|
|
6
|
+
value: true
|
|
7
|
+
});
|
|
8
|
+
exports.useTrackResultsShown = void 0;
|
|
9
|
+
|
|
10
|
+
var _slicedToArray2 = _interopRequireDefault(require("@babel/runtime/helpers/slicedToArray"));
|
|
11
|
+
|
|
12
|
+
var _react = require("react");
|
|
13
|
+
|
|
14
|
+
var _useDebounce3 = require("use-debounce");
|
|
15
|
+
|
|
16
|
+
var _analyticsNext = require("@atlaskit/analytics-next");
|
|
17
|
+
|
|
18
|
+
var _constants = require("../../../../common/constants");
|
|
19
|
+
|
|
20
|
+
var _analytics = _interopRequireDefault(require("../../../../analytics.codegen"));
|
|
21
|
+
|
|
22
|
+
var DEBOUNCE_MS = 400;
|
|
23
|
+
|
|
24
|
+
var useTrackResultsShown = function useTrackResultsShown(isLoading, items, hasSearchTerm) {
|
|
25
|
+
var _useAnalyticsEvents = (0, _analyticsNext.useAnalyticsEvents)(),
|
|
26
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
27
|
+
|
|
28
|
+
var hasSearchTermRef = (0, _react.useRef)(hasSearchTerm); // Using ref so that not required in the dependency array
|
|
29
|
+
// Analytics should be entirely dependent on change of items being viewed
|
|
30
|
+
|
|
31
|
+
(0, _react.useEffect)(function () {
|
|
32
|
+
hasSearchTermRef.current = hasSearchTerm;
|
|
33
|
+
}, [hasSearchTerm]); // Filters isLoading/items to only return the array of items if no longer loading more items
|
|
34
|
+
// Loading state IS a factor here because some tabs will
|
|
35
|
+
// load intermediate results whilst loading additional results (Atlassian tab)
|
|
36
|
+
// Considered to only have "shown" results once we are in a final state (no longer loading)
|
|
37
|
+
|
|
38
|
+
var finalItems = (0, _react.useMemo)(function () {
|
|
39
|
+
return !isLoading ? items : null;
|
|
40
|
+
}, [isLoading, items]); // Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
|
|
41
|
+
// Debounce the items so that we only consider the results to have been shown
|
|
42
|
+
// after they have been stable for DEBOUNCE_MS
|
|
43
|
+
|
|
44
|
+
var _useDebounce = (0, _useDebounce3.useDebounce)(finalItems, DEBOUNCE_MS),
|
|
45
|
+
_useDebounce2 = (0, _slicedToArray2.default)(_useDebounce, 1),
|
|
46
|
+
debouncedItems = _useDebounce2[0];
|
|
47
|
+
|
|
48
|
+
(0, _react.useEffect)(function () {
|
|
49
|
+
if (debouncedItems) {
|
|
50
|
+
var event = !hasSearchTermRef.current ? 'ui.searchResults.shown.preQuerySearchResults' : 'ui.searchResults.shown.postQuerySearchResults';
|
|
51
|
+
createAnalyticsEvent((0, _analytics.default)(event, {
|
|
52
|
+
resultCount: debouncedItems.length
|
|
53
|
+
})).fire(_constants.ANALYTICS_CHANNEL);
|
|
54
|
+
}
|
|
55
|
+
}, [debouncedItems, createAnalyticsEvent]);
|
|
56
|
+
};
|
|
57
|
+
|
|
58
|
+
exports.useTrackResultsShown = useTrackResultsShown;
|
package/dist/cjs/version.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::758b8a20cae1b6d410cecd4493453a21>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -90,8 +90,12 @@ export function withLinkPickerAnalyticsContext(WrappedComponent) {
|
|
|
90
90
|
getAttributes
|
|
91
91
|
} = useLinkPickerAnalytics();
|
|
92
92
|
const onEvent = useCallback(event => {
|
|
93
|
+
var _event$payload$attrib;
|
|
94
|
+
|
|
93
95
|
event.update({
|
|
94
|
-
attributes: getAttributes()
|
|
96
|
+
attributes: { ...getAttributes(),
|
|
97
|
+
...((_event$payload$attrib = event.payload.attributes) !== null && _event$payload$attrib !== void 0 ? _event$payload$attrib : {})
|
|
98
|
+
}
|
|
95
99
|
});
|
|
96
100
|
}, [getAttributes]);
|
|
97
101
|
return /*#__PURE__*/React.createElement(AnalyticsListener, {
|
|
@@ -138,12 +138,12 @@ function LinkPicker({
|
|
|
138
138
|
dispatch({
|
|
139
139
|
url: e.currentTarget.value
|
|
140
140
|
});
|
|
141
|
-
}, [trackAttribute]);
|
|
141
|
+
}, [dispatch, trackAttribute]);
|
|
142
142
|
const handleChangeText = useCallback(e => {
|
|
143
143
|
dispatch({
|
|
144
144
|
displayText: e.currentTarget.value
|
|
145
145
|
});
|
|
146
|
-
}, []);
|
|
146
|
+
}, [dispatch]);
|
|
147
147
|
const handleKeyDown = useCallback(event => {
|
|
148
148
|
const {
|
|
149
149
|
key
|
|
@@ -187,12 +187,12 @@ function LinkPicker({
|
|
|
187
187
|
invalidUrl: false
|
|
188
188
|
});
|
|
189
189
|
}
|
|
190
|
-
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
190
|
+
}, [dispatch, activeIndex, items, trackAttribute, activePlugin]);
|
|
191
191
|
const handleClear = useCallback(field => {
|
|
192
192
|
dispatch({
|
|
193
193
|
[field]: ''
|
|
194
194
|
});
|
|
195
|
-
}, []);
|
|
195
|
+
}, [dispatch]);
|
|
196
196
|
const handleUrlClear = useCallback(() => {
|
|
197
197
|
trackAttribute('linkFieldContentInputSource', null);
|
|
198
198
|
handleClear('url');
|
|
@@ -202,7 +202,7 @@ function LinkPicker({
|
|
|
202
202
|
dispatch({
|
|
203
203
|
activeIndex: index !== null && index !== void 0 ? index : -1
|
|
204
204
|
});
|
|
205
|
-
}, [items]);
|
|
205
|
+
}, [dispatch, items]);
|
|
206
206
|
const handleMouseLeaveResultItem = useCallback(objectId => {
|
|
207
207
|
const index = items === null || items === void 0 ? void 0 : items.findIndex(item => item.objectId === objectId); // This is to avoid updating index that was set by other mouseenter event
|
|
208
208
|
|
|
@@ -211,7 +211,7 @@ function LinkPicker({
|
|
|
211
211
|
activeIndex: -1
|
|
212
212
|
});
|
|
213
213
|
}
|
|
214
|
-
}, [activeIndex, items]);
|
|
214
|
+
}, [dispatch, activeIndex, items]);
|
|
215
215
|
const handleInsert = useCallback((url, title, inputType) => {
|
|
216
216
|
const event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {})); // Clone the event so that it can be emitted for consumer usage
|
|
217
217
|
// This must happen BEFORE the original event is fired!
|
|
@@ -271,7 +271,7 @@ function LinkPicker({
|
|
|
271
271
|
return dispatch({
|
|
272
272
|
invalidUrl: true
|
|
273
273
|
});
|
|
274
|
-
}, [handleInsert, isSelectedItem, selectedItem, url]);
|
|
274
|
+
}, [dispatch, handleInsert, isSelectedItem, selectedItem, url]);
|
|
275
275
|
const handleTabChange = useCallback(activeTab => {
|
|
276
276
|
var _plugins$activeTab$ta, _plugins$activeTab;
|
|
277
277
|
|
|
@@ -9,6 +9,7 @@ import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
|
9
9
|
import LinkSearchListItem from '../list-item';
|
|
10
10
|
import { listContainerStyles, spinnerContainerStyles, listStyles, listTitleStyles } from './styled';
|
|
11
11
|
import LinkSearchNoResults, { testIds as noResultsTestIds } from './link-search-no-results';
|
|
12
|
+
import { useTrackResultsShown } from './use-track-results-shown';
|
|
12
13
|
export const messages = defineMessages({
|
|
13
14
|
titleRecentlyViewed: {
|
|
14
15
|
id: 'fabric.linkPicker.listTitle.recentlyViewed',
|
|
@@ -50,6 +51,7 @@ const LinkSearchList = /*#__PURE__*/forwardRef(({
|
|
|
50
51
|
let itemsContent;
|
|
51
52
|
let loadingContent;
|
|
52
53
|
const linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
|
|
54
|
+
useTrackResultsShown(isLoading, items, hasSearchTerm);
|
|
53
55
|
|
|
54
56
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
55
57
|
return jsx(LinkSearchNoResults, null);
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
2
|
+
import { useDebounce } from 'use-debounce';
|
|
3
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
4
|
+
import { ANALYTICS_CHANNEL } from '../../../../common/constants';
|
|
5
|
+
import createEventPayload from '../../../../analytics.codegen';
|
|
6
|
+
const DEBOUNCE_MS = 400;
|
|
7
|
+
export const useTrackResultsShown = (isLoading, items, hasSearchTerm) => {
|
|
8
|
+
const {
|
|
9
|
+
createAnalyticsEvent
|
|
10
|
+
} = useAnalyticsEvents();
|
|
11
|
+
const hasSearchTermRef = useRef(hasSearchTerm); // Using ref so that not required in the dependency array
|
|
12
|
+
// Analytics should be entirely dependent on change of items being viewed
|
|
13
|
+
|
|
14
|
+
useEffect(() => {
|
|
15
|
+
hasSearchTermRef.current = hasSearchTerm;
|
|
16
|
+
}, [hasSearchTerm]); // Filters isLoading/items to only return the array of items if no longer loading more items
|
|
17
|
+
// Loading state IS a factor here because some tabs will
|
|
18
|
+
// load intermediate results whilst loading additional results (Atlassian tab)
|
|
19
|
+
// Considered to only have "shown" results once we are in a final state (no longer loading)
|
|
20
|
+
|
|
21
|
+
const finalItems = useMemo(() => !isLoading ? items : null, [isLoading, items]); // Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
|
|
22
|
+
// Debounce the items so that we only consider the results to have been shown
|
|
23
|
+
// after they have been stable for DEBOUNCE_MS
|
|
24
|
+
|
|
25
|
+
const [debouncedItems] = useDebounce(finalItems, DEBOUNCE_MS);
|
|
26
|
+
useEffect(() => {
|
|
27
|
+
if (debouncedItems) {
|
|
28
|
+
const event = !hasSearchTermRef.current ? 'ui.searchResults.shown.preQuerySearchResults' : 'ui.searchResults.shown.postQuerySearchResults';
|
|
29
|
+
createAnalyticsEvent(createEventPayload(event, {
|
|
30
|
+
resultCount: debouncedItems.length
|
|
31
|
+
})).fire(ANALYTICS_CHANNEL);
|
|
32
|
+
}
|
|
33
|
+
}, [debouncedItems, createAnalyticsEvent]);
|
|
34
|
+
};
|
package/dist/es2019/version.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::758b8a20cae1b6d410cecd4493453a21>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
function createEventPayload(eventKey, attributes) {
|
|
@@ -105,8 +105,10 @@ export function withLinkPickerAnalyticsContext(WrappedComponent) {
|
|
|
105
105
|
getAttributes = _useLinkPickerAnalyti.getAttributes;
|
|
106
106
|
|
|
107
107
|
var onEvent = useCallback(function (event) {
|
|
108
|
+
var _event$payload$attrib;
|
|
109
|
+
|
|
108
110
|
event.update({
|
|
109
|
-
attributes: getAttributes()
|
|
111
|
+
attributes: _objectSpread(_objectSpread({}, getAttributes()), (_event$payload$attrib = event.payload.attributes) !== null && _event$payload$attrib !== void 0 ? _event$payload$attrib : {})
|
|
110
112
|
});
|
|
111
113
|
}, [getAttributes]);
|
|
112
114
|
return /*#__PURE__*/React.createElement(AnalyticsListener, {
|
|
@@ -146,12 +146,12 @@ function LinkPicker(_ref) {
|
|
|
146
146
|
dispatch({
|
|
147
147
|
url: e.currentTarget.value
|
|
148
148
|
});
|
|
149
|
-
}, [trackAttribute]);
|
|
149
|
+
}, [dispatch, trackAttribute]);
|
|
150
150
|
var handleChangeText = useCallback(function (e) {
|
|
151
151
|
dispatch({
|
|
152
152
|
displayText: e.currentTarget.value
|
|
153
153
|
});
|
|
154
|
-
}, []);
|
|
154
|
+
}, [dispatch]);
|
|
155
155
|
var handleKeyDown = useCallback(function (event) {
|
|
156
156
|
var key = event.key;
|
|
157
157
|
var KEY_ARROW_DOWN = 'ArrowDown';
|
|
@@ -193,10 +193,10 @@ function LinkPicker(_ref) {
|
|
|
193
193
|
invalidUrl: false
|
|
194
194
|
});
|
|
195
195
|
}
|
|
196
|
-
}, [activeIndex, items, trackAttribute, activePlugin]);
|
|
196
|
+
}, [dispatch, activeIndex, items, trackAttribute, activePlugin]);
|
|
197
197
|
var handleClear = useCallback(function (field) {
|
|
198
198
|
dispatch(_defineProperty({}, field, ''));
|
|
199
|
-
}, []);
|
|
199
|
+
}, [dispatch]);
|
|
200
200
|
var handleUrlClear = useCallback(function () {
|
|
201
201
|
trackAttribute('linkFieldContentInputSource', null);
|
|
202
202
|
handleClear('url');
|
|
@@ -208,7 +208,7 @@ function LinkPicker(_ref) {
|
|
|
208
208
|
dispatch({
|
|
209
209
|
activeIndex: index !== null && index !== void 0 ? index : -1
|
|
210
210
|
});
|
|
211
|
-
}, [items]);
|
|
211
|
+
}, [dispatch, items]);
|
|
212
212
|
var handleMouseLeaveResultItem = useCallback(function (objectId) {
|
|
213
213
|
var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
|
|
214
214
|
return item.objectId === objectId;
|
|
@@ -219,7 +219,7 @@ function LinkPicker(_ref) {
|
|
|
219
219
|
activeIndex: -1
|
|
220
220
|
});
|
|
221
221
|
}
|
|
222
|
-
}, [activeIndex, items]);
|
|
222
|
+
}, [dispatch, activeIndex, items]);
|
|
223
223
|
var handleInsert = useCallback(function (url, title, inputType) {
|
|
224
224
|
var event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {})); // Clone the event so that it can be emitted for consumer usage
|
|
225
225
|
// This must happen BEFORE the original event is fired!
|
|
@@ -278,7 +278,7 @@ function LinkPicker(_ref) {
|
|
|
278
278
|
return dispatch({
|
|
279
279
|
invalidUrl: true
|
|
280
280
|
});
|
|
281
|
-
}, [handleInsert, isSelectedItem, selectedItem, url]);
|
|
281
|
+
}, [dispatch, handleInsert, isSelectedItem, selectedItem, url]);
|
|
282
282
|
var handleTabChange = useCallback(function (activeTab) {
|
|
283
283
|
var _plugins$activeTab$ta, _plugins$activeTab;
|
|
284
284
|
|
|
@@ -16,6 +16,7 @@ import VisuallyHidden from '@atlaskit/visually-hidden';
|
|
|
16
16
|
import LinkSearchListItem from '../list-item';
|
|
17
17
|
import { listContainerStyles, spinnerContainerStyles, listStyles, listTitleStyles } from './styled';
|
|
18
18
|
import LinkSearchNoResults, { testIds as noResultsTestIds } from './link-search-no-results';
|
|
19
|
+
import { useTrackResultsShown } from './use-track-results-shown';
|
|
19
20
|
export var messages = defineMessages({
|
|
20
21
|
titleRecentlyViewed: {
|
|
21
22
|
id: 'fabric.linkPicker.listTitle.recentlyViewed',
|
|
@@ -57,6 +58,7 @@ var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
57
58
|
var itemsContent;
|
|
58
59
|
var loadingContent;
|
|
59
60
|
var linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
|
|
61
|
+
useTrackResultsShown(isLoading, items, hasSearchTerm);
|
|
60
62
|
|
|
61
63
|
if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
|
|
62
64
|
return jsx(LinkSearchNoResults, null);
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
|
|
2
|
+
import { useEffect, useMemo, useRef } from 'react';
|
|
3
|
+
import { useDebounce } from 'use-debounce';
|
|
4
|
+
import { useAnalyticsEvents } from '@atlaskit/analytics-next';
|
|
5
|
+
import { ANALYTICS_CHANNEL } from '../../../../common/constants';
|
|
6
|
+
import createEventPayload from '../../../../analytics.codegen';
|
|
7
|
+
var DEBOUNCE_MS = 400;
|
|
8
|
+
export var useTrackResultsShown = function useTrackResultsShown(isLoading, items, hasSearchTerm) {
|
|
9
|
+
var _useAnalyticsEvents = useAnalyticsEvents(),
|
|
10
|
+
createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
|
|
11
|
+
|
|
12
|
+
var hasSearchTermRef = useRef(hasSearchTerm); // Using ref so that not required in the dependency array
|
|
13
|
+
// Analytics should be entirely dependent on change of items being viewed
|
|
14
|
+
|
|
15
|
+
useEffect(function () {
|
|
16
|
+
hasSearchTermRef.current = hasSearchTerm;
|
|
17
|
+
}, [hasSearchTerm]); // Filters isLoading/items to only return the array of items if no longer loading more items
|
|
18
|
+
// Loading state IS a factor here because some tabs will
|
|
19
|
+
// load intermediate results whilst loading additional results (Atlassian tab)
|
|
20
|
+
// Considered to only have "shown" results once we are in a final state (no longer loading)
|
|
21
|
+
|
|
22
|
+
var finalItems = useMemo(function () {
|
|
23
|
+
return !isLoading ? items : null;
|
|
24
|
+
}, [isLoading, items]); // Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
|
|
25
|
+
// Debounce the items so that we only consider the results to have been shown
|
|
26
|
+
// after they have been stable for DEBOUNCE_MS
|
|
27
|
+
|
|
28
|
+
var _useDebounce = useDebounce(finalItems, DEBOUNCE_MS),
|
|
29
|
+
_useDebounce2 = _slicedToArray(_useDebounce, 1),
|
|
30
|
+
debouncedItems = _useDebounce2[0];
|
|
31
|
+
|
|
32
|
+
useEffect(function () {
|
|
33
|
+
if (debouncedItems) {
|
|
34
|
+
var event = !hasSearchTermRef.current ? 'ui.searchResults.shown.preQuerySearchResults' : 'ui.searchResults.shown.postQuerySearchResults';
|
|
35
|
+
createAnalyticsEvent(createEventPayload(event, {
|
|
36
|
+
resultCount: debouncedItems.length
|
|
37
|
+
})).fire(ANALYTICS_CHANNEL);
|
|
38
|
+
}
|
|
39
|
+
}, [debouncedItems, createAnalyticsEvent]);
|
|
40
|
+
};
|
package/dist/esm/version.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Generates analytics utilities from the package analytics spec yaml
|
|
5
5
|
*
|
|
6
|
-
* @codegen <<SignedSource::
|
|
6
|
+
* @codegen <<SignedSource::758b8a20cae1b6d410cecd4493453a21>>
|
|
7
7
|
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
8
|
*/
|
|
9
9
|
export declare type PackageMetaDataType = {
|
|
@@ -32,6 +32,12 @@ export declare type LinkPickerUnhandledErrorCaughtAttributesType = {
|
|
|
32
32
|
error: string;
|
|
33
33
|
componentStack: string | null;
|
|
34
34
|
};
|
|
35
|
+
export declare type SearchResultsShownPreQuerySearchResultsAttributesType = {
|
|
36
|
+
resultCount: number;
|
|
37
|
+
};
|
|
38
|
+
export declare type SearchResultsShownPostQuerySearchResultsAttributesType = {
|
|
39
|
+
resultCount: number;
|
|
40
|
+
};
|
|
35
41
|
export declare type ResultsResolveFailedAttributesType = {
|
|
36
42
|
error: string;
|
|
37
43
|
};
|
|
@@ -43,6 +49,8 @@ declare type AnalyticsEventAttributes = {
|
|
|
43
49
|
'ui.textField.updated.displayTextField': TextFieldUpdatedDisplayTextFieldAttributesType;
|
|
44
50
|
'ui.tab.viewed': TabViewedAttributesType;
|
|
45
51
|
'ui.linkPicker.unhandledErrorCaught': LinkPickerUnhandledErrorCaughtAttributesType;
|
|
52
|
+
'ui.searchResults.shown.preQuerySearchResults': SearchResultsShownPreQuerySearchResultsAttributesType;
|
|
53
|
+
'ui.searchResults.shown.postQuerySearchResults': SearchResultsShownPostQuerySearchResultsAttributesType;
|
|
46
54
|
'operational.resultsResolve.failed': ResultsResolveFailedAttributesType;
|
|
47
55
|
};
|
|
48
56
|
declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { LinkPickerAnalyticsContextType } from '../../analytics.codegen';
|
|
3
|
-
|
|
3
|
+
declare type AnalyticsContextAttributesType = LinkPickerAnalyticsContextType;
|
|
4
|
+
export declare type TrackAttribute = <K extends keyof LinkPickerAnalyticsContextType>(attribute: K, value: AnalyticsContextAttributesType[K]) => void;
|
|
4
5
|
interface AnalyticsContextType {
|
|
5
6
|
/**
|
|
6
7
|
* Update a single attribute in the analytics context
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@atlaskit/link-picker",
|
|
3
|
-
"version": "1.13.
|
|
3
|
+
"version": "1.13.2",
|
|
4
4
|
"description": "Standalone link picker",
|
|
5
5
|
"author": "Atlassian Pty Ltd",
|
|
6
6
|
"publishConfig": {
|
|
@@ -20,14 +20,6 @@
|
|
|
20
20
|
"module": "dist/esm/index.js",
|
|
21
21
|
"module:es2019": "dist/es2019/index.js",
|
|
22
22
|
"types": "dist/types/index.d.ts",
|
|
23
|
-
"typesVersions": {
|
|
24
|
-
">=4.0 <4.5": {
|
|
25
|
-
"*": [
|
|
26
|
-
"dist/types-ts4.0/*",
|
|
27
|
-
"dist/types-ts4.0/index.d.ts"
|
|
28
|
-
]
|
|
29
|
-
}
|
|
30
|
-
},
|
|
31
23
|
"sideEffects": false,
|
|
32
24
|
"atlaskit:src": "src/index.ts",
|
|
33
25
|
"af:exports": {
|
|
@@ -43,13 +35,13 @@
|
|
|
43
35
|
"@atlaskit/button": "^16.4.0",
|
|
44
36
|
"@atlaskit/empty-state": "^7.4.0",
|
|
45
37
|
"@atlaskit/form": "^8.7.0",
|
|
46
|
-
"@atlaskit/frontend-utilities": "^2.
|
|
38
|
+
"@atlaskit/frontend-utilities": "^2.1.0",
|
|
47
39
|
"@atlaskit/icon": "^21.11.0",
|
|
48
40
|
"@atlaskit/spinner": "^15.2.0",
|
|
49
41
|
"@atlaskit/tabs": "^13.3.0",
|
|
50
42
|
"@atlaskit/textfield": "^5.3.0",
|
|
51
43
|
"@atlaskit/theme": "^12.2.0",
|
|
52
|
-
"@atlaskit/tokens": "^0.
|
|
44
|
+
"@atlaskit/tokens": "^0.11.0",
|
|
53
45
|
"@atlaskit/tooltip": "^17.6.0",
|
|
54
46
|
"@atlaskit/ufo": "^0.1.0",
|
|
55
47
|
"@atlaskit/visually-hidden": "^1.1.0",
|
|
@@ -59,6 +51,7 @@
|
|
|
59
51
|
"date-fns": "^2.17.0",
|
|
60
52
|
"linkify-it": "^2.0.3",
|
|
61
53
|
"react-loosely-lazy": "^1.0.0",
|
|
54
|
+
"use-debounce": "^3.4.0",
|
|
62
55
|
"uuid": "^3.1.0"
|
|
63
56
|
},
|
|
64
57
|
"peerDependencies": {
|
|
@@ -81,7 +74,7 @@
|
|
|
81
74
|
"@atlaskit/webdriver-runner": "*",
|
|
82
75
|
"@atlassian/atlassian-frontend-prettier-config-1.0.0": "npm:@atlassian/atlassian-frontend-prettier-config@1.0.0",
|
|
83
76
|
"@atlassian/link-picker-atlassian-plugin": "^23.0.0",
|
|
84
|
-
"@atlassian/link-picker-plugins": "^11.
|
|
77
|
+
"@atlassian/link-picker-plugins": "^11.1.0",
|
|
85
78
|
"@atlassian/recent-work-client": "^1.6.0",
|
|
86
79
|
"@atlassian/search-provider": "^2.3.0",
|
|
87
80
|
"@testing-library/dom": "^8.17.1",
|
|
@@ -97,7 +90,7 @@
|
|
|
97
90
|
"lodash": "^4.17.21",
|
|
98
91
|
"mockdate": "^3.0.2",
|
|
99
92
|
"node-fetch": "^2.6.7",
|
|
100
|
-
"prettier": "^2.
|
|
93
|
+
"prettier": "^2.7.0",
|
|
101
94
|
"react-dom": "^16.8.0",
|
|
102
95
|
"sinon": "^2.2.0",
|
|
103
96
|
"typescript": "4.5.5"
|
package/report.api.md
CHANGED
|
@@ -25,9 +25,9 @@ import { UIAnalyticsEvent } from '@atlaskit/analytics-next';
|
|
|
25
25
|
export type LinkInputType = 'manual' | 'typeAhead';
|
|
26
26
|
|
|
27
27
|
// @public (undocumented)
|
|
28
|
-
export const LinkPicker: React_2.MemoExoticComponent<
|
|
29
|
-
props: LinkPickerProps
|
|
30
|
-
|
|
28
|
+
export const LinkPicker: React_2.MemoExoticComponent<
|
|
29
|
+
(props: LinkPickerProps) => JSX.Element
|
|
30
|
+
>;
|
|
31
31
|
|
|
32
32
|
// @public (undocumented)
|
|
33
33
|
export interface LinkPickerPlugin {
|
|
@@ -1,55 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* THIS FILE WAS CREATED VIA CODEGEN DO NOT MODIFY {@see http://go/af-codegen}
|
|
3
|
-
*
|
|
4
|
-
* Generates analytics utilities from the package analytics spec yaml
|
|
5
|
-
*
|
|
6
|
-
* @codegen <<SignedSource::c0fb3bb39f50f3a7c35ebd90e8903280>>
|
|
7
|
-
* @codegenCommand yarn workspace @atlaskit/link-picker run codegen-analytics
|
|
8
|
-
*/
|
|
9
|
-
export declare type PackageMetaDataType = {
|
|
10
|
-
packageName: '@atlaskit/link-picker';
|
|
11
|
-
packageVersion: string;
|
|
12
|
-
source: 'linkPicker';
|
|
13
|
-
componentName: 'linkPicker';
|
|
14
|
-
};
|
|
15
|
-
export declare type LinkPickerAnalyticsContextType = {
|
|
16
|
-
linkState: 'editLink' | 'newLink';
|
|
17
|
-
linkFieldContent: 'url' | 'text_string' | null;
|
|
18
|
-
linkFieldContentInputMethod: 'manual' | 'paste' | 'searchResult' | null;
|
|
19
|
-
linkFieldContentInputSource: string | null;
|
|
20
|
-
displayTextFieldContent: 'text_string' | null;
|
|
21
|
-
displayTextFieldContentInputMethod: 'manual' | 'paste' | null;
|
|
22
|
-
tab: string | null;
|
|
23
|
-
};
|
|
24
|
-
export declare type FormSubmittedLinkPickerAttributesType = {};
|
|
25
|
-
export declare type InlineDialogViewedLinkPickerAttributesType = {};
|
|
26
|
-
export declare type InlineDialogClosedLinkPickerAttributesType = {};
|
|
27
|
-
export declare type TextFieldUpdatedLinkFieldAttributesType = {};
|
|
28
|
-
export declare type TextFieldUpdatedDisplayTextFieldAttributesType = {};
|
|
29
|
-
export declare type TabViewedAttributesType = {};
|
|
30
|
-
export declare type LinkPickerUnhandledErrorCaughtAttributesType = {
|
|
31
|
-
browserInfo: string;
|
|
32
|
-
error: string;
|
|
33
|
-
componentStack: string | null;
|
|
34
|
-
};
|
|
35
|
-
export declare type ResultsResolveFailedAttributesType = {
|
|
36
|
-
error: string;
|
|
37
|
-
};
|
|
38
|
-
declare type AnalyticsEventAttributes = {
|
|
39
|
-
'ui.form.submitted.linkPicker': FormSubmittedLinkPickerAttributesType;
|
|
40
|
-
'ui.inlineDialog.viewed.linkPicker': InlineDialogViewedLinkPickerAttributesType;
|
|
41
|
-
'ui.inlineDialog.closed.linkPicker': InlineDialogClosedLinkPickerAttributesType;
|
|
42
|
-
'ui.textField.updated.linkField': TextFieldUpdatedLinkFieldAttributesType;
|
|
43
|
-
'ui.textField.updated.displayTextField': TextFieldUpdatedDisplayTextFieldAttributesType;
|
|
44
|
-
'ui.tab.viewed': TabViewedAttributesType;
|
|
45
|
-
'ui.linkPicker.unhandledErrorCaught': LinkPickerUnhandledErrorCaughtAttributesType;
|
|
46
|
-
'operational.resultsResolve.failed': ResultsResolveFailedAttributesType;
|
|
47
|
-
};
|
|
48
|
-
declare function createEventPayload<K extends keyof AnalyticsEventAttributes>(eventKey: K, attributes: AnalyticsEventAttributes[K]): {
|
|
49
|
-
eventType: string;
|
|
50
|
-
actionSubject: string;
|
|
51
|
-
action: string;
|
|
52
|
-
actionSubjectId: string;
|
|
53
|
-
attributes: AnalyticsEventAttributes[K];
|
|
54
|
-
};
|
|
55
|
-
export default createEventPayload;
|