@atlaskit/link-picker 1.16.8 → 1.16.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (154) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/analytics.codegen.js +3 -4
  3. package/dist/cjs/common/analytics/context.js +11 -36
  4. package/dist/cjs/common/analytics/experiences.js +0 -13
  5. package/dist/cjs/common/analytics/index.js +0 -2
  6. package/dist/cjs/common/analytics/input-field-tracking.js +16 -35
  7. package/dist/cjs/common/generic-error-svg/index.js +1 -7
  8. package/dist/cjs/common/generic-error-svg/styled.js +0 -6
  9. package/dist/cjs/common/utils/errors.js +0 -15
  10. package/dist/cjs/controllers/session-provider/index.js +1 -17
  11. package/dist/cjs/controllers/use-fix-height/index.js +0 -3
  12. package/dist/cjs/i18n/cs.js +0 -1
  13. package/dist/cjs/i18n/da.js +0 -1
  14. package/dist/cjs/i18n/de.js +0 -1
  15. package/dist/cjs/i18n/en.js +0 -1
  16. package/dist/cjs/i18n/en_GB.js +0 -1
  17. package/dist/cjs/i18n/es.js +0 -1
  18. package/dist/cjs/i18n/fi.js +0 -1
  19. package/dist/cjs/i18n/fr.js +0 -1
  20. package/dist/cjs/i18n/hu.js +0 -1
  21. package/dist/cjs/i18n/it.js +0 -1
  22. package/dist/cjs/i18n/ja.js +0 -1
  23. package/dist/cjs/i18n/ko.js +0 -1
  24. package/dist/cjs/i18n/nb.js +0 -1
  25. package/dist/cjs/i18n/nl.js +0 -1
  26. package/dist/cjs/i18n/pl.js +0 -1
  27. package/dist/cjs/i18n/pt_BR.js +0 -1
  28. package/dist/cjs/i18n/ru.js +0 -1
  29. package/dist/cjs/i18n/sv.js +0 -1
  30. package/dist/cjs/i18n/th.js +0 -1
  31. package/dist/cjs/i18n/tr.js +0 -1
  32. package/dist/cjs/i18n/uk.js +0 -1
  33. package/dist/cjs/i18n/vi.js +0 -1
  34. package/dist/cjs/i18n/zh.js +0 -1
  35. package/dist/cjs/i18n/zh_TW.js +0 -1
  36. package/dist/cjs/index.js +0 -2
  37. package/dist/cjs/services/use-plugins/index.js +13 -44
  38. package/dist/cjs/services/use-plugins/reducer.js +0 -13
  39. package/dist/cjs/services/use-plugins/utils.js +9 -35
  40. package/dist/cjs/services/use-search-query/index.js +3 -9
  41. package/dist/cjs/ui/error-boundary/error-boundary-base/index.js +2 -22
  42. package/dist/cjs/ui/error-boundary/error-boundary-fallback/index.js +1 -9
  43. package/dist/cjs/ui/error-boundary/index.js +3 -18
  44. package/dist/cjs/ui/index.js +0 -13
  45. package/dist/cjs/ui/link-picker/announcer.js +15 -25
  46. package/dist/cjs/ui/link-picker/browser.js +0 -1
  47. package/dist/cjs/ui/link-picker/form-footer/index.js +6 -26
  48. package/dist/cjs/ui/link-picker/form-footer/styled.js +0 -5
  49. package/dist/cjs/ui/link-picker/form-footer/utils.js +2 -8
  50. package/dist/cjs/ui/link-picker/index.js +44 -111
  51. package/dist/cjs/ui/link-picker/link-search-error/index.js +1 -10
  52. package/dist/cjs/ui/link-picker/link-search-list/index.js +12 -38
  53. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/index.js +1 -9
  54. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +1 -5
  55. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/styled.js +0 -6
  56. package/dist/cjs/ui/link-picker/link-search-list/link-search-no-results/styled.js +0 -5
  57. package/dist/cjs/ui/link-picker/link-search-list/styled.js +0 -7
  58. package/dist/cjs/ui/link-picker/link-search-list/use-track-results-shown/index.js +11 -21
  59. package/dist/cjs/ui/link-picker/list-item/index.js +11 -32
  60. package/dist/cjs/ui/link-picker/list-item/styled.js +0 -13
  61. package/dist/cjs/ui/link-picker/messages.js +0 -2
  62. package/dist/cjs/ui/link-picker/styled.js +1 -8
  63. package/dist/cjs/ui/link-picker/text-input/index.js +9 -26
  64. package/dist/cjs/ui/link-picker/text-input/styled.js +0 -7
  65. package/dist/cjs/ui/link-picker/track-mount/index.js +1 -11
  66. package/dist/cjs/ui/link-picker/track-tab-viewed/index.js +2 -10
  67. package/dist/cjs/ui/link-picker/transformTimeStamp.js +0 -13
  68. package/dist/cjs/ui/link-picker/utils.js +11 -19
  69. package/dist/cjs/ui/loader-fallback/index.js +1 -5
  70. package/dist/cjs/ui/scrolling-tabs/index.js +6 -44
  71. package/dist/cjs/ui/scrolling-tabs/scrolling-tabs.js +4 -33
  72. package/dist/cjs/ui/scrolling-tabs/styles.js +0 -3
  73. package/dist/cjs/version.json +1 -1
  74. package/dist/es2019/analytics.codegen.js +3 -3
  75. package/dist/es2019/common/analytics/context.js +11 -13
  76. package/dist/es2019/common/analytics/experiences.js +0 -1
  77. package/dist/es2019/common/analytics/input-field-tracking.js +13 -12
  78. package/dist/es2019/common/generic-error-svg/index.js +0 -4
  79. package/dist/es2019/common/utils/errors.js +0 -1
  80. package/dist/es2019/controllers/session-provider/index.js +0 -4
  81. package/dist/es2019/controllers/use-fix-height/index.js +0 -2
  82. package/dist/es2019/services/use-plugins/index.js +2 -8
  83. package/dist/es2019/services/use-plugins/reducer.js +8 -8
  84. package/dist/es2019/services/use-plugins/utils.js +5 -6
  85. package/dist/es2019/services/use-search-query/index.js +3 -6
  86. package/dist/es2019/ui/error-boundary/error-boundary-base/index.js +0 -5
  87. package/dist/es2019/ui/error-boundary/index.js +2 -4
  88. package/dist/es2019/ui/index.js +1 -2
  89. package/dist/es2019/ui/link-picker/announcer.js +6 -1
  90. package/dist/es2019/ui/link-picker/browser.js +0 -2
  91. package/dist/es2019/ui/link-picker/form-footer/index.js +0 -5
  92. package/dist/es2019/ui/link-picker/form-footer/utils.js +2 -5
  93. package/dist/es2019/ui/link-picker/index.js +21 -37
  94. package/dist/es2019/ui/link-picker/link-search-error/index.js +0 -3
  95. package/dist/es2019/ui/link-picker/link-search-list/index.js +2 -6
  96. package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/index.js +0 -2
  97. package/dist/es2019/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +0 -3
  98. package/dist/es2019/ui/link-picker/link-search-list/styled.js +2 -2
  99. package/dist/es2019/ui/link-picker/link-search-list/use-track-results-shown/index.js +7 -5
  100. package/dist/es2019/ui/link-picker/list-item/index.js +0 -14
  101. package/dist/es2019/ui/link-picker/list-item/styled.js +2 -4
  102. package/dist/es2019/ui/link-picker/styled.js +1 -1
  103. package/dist/es2019/ui/link-picker/text-input/index.js +0 -6
  104. package/dist/es2019/ui/link-picker/track-mount/index.js +1 -2
  105. package/dist/es2019/ui/link-picker/track-tab-viewed/index.js +0 -2
  106. package/dist/es2019/ui/link-picker/transformTimeStamp.js +0 -7
  107. package/dist/es2019/ui/link-picker/utils.js +7 -5
  108. package/dist/es2019/ui/scrolling-tabs/index.js +2 -14
  109. package/dist/es2019/ui/scrolling-tabs/scrolling-tabs.js +0 -14
  110. package/dist/es2019/version.json +1 -1
  111. package/dist/esm/analytics.codegen.js +3 -3
  112. package/dist/esm/common/analytics/context.js +11 -21
  113. package/dist/esm/common/analytics/experiences.js +0 -3
  114. package/dist/esm/common/analytics/input-field-tracking.js +16 -22
  115. package/dist/esm/common/generic-error-svg/index.js +0 -4
  116. package/dist/esm/common/generic-error-svg/styled.js +0 -2
  117. package/dist/esm/common/utils/errors.js +0 -8
  118. package/dist/esm/controllers/session-provider/index.js +1 -7
  119. package/dist/esm/controllers/use-fix-height/index.js +0 -2
  120. package/dist/esm/services/use-plugins/index.js +13 -31
  121. package/dist/esm/services/use-plugins/reducer.js +0 -7
  122. package/dist/esm/services/use-plugins/utils.js +9 -22
  123. package/dist/esm/services/use-search-query/index.js +3 -6
  124. package/dist/esm/ui/error-boundary/error-boundary-base/index.js +2 -13
  125. package/dist/esm/ui/error-boundary/index.js +3 -5
  126. package/dist/esm/ui/index.js +1 -2
  127. package/dist/esm/ui/link-picker/announcer.js +20 -17
  128. package/dist/esm/ui/link-picker/browser.js +0 -2
  129. package/dist/esm/ui/link-picker/form-footer/index.js +6 -12
  130. package/dist/esm/ui/link-picker/form-footer/styled.js +0 -2
  131. package/dist/esm/ui/link-picker/form-footer/utils.js +2 -5
  132. package/dist/esm/ui/link-picker/index.js +44 -74
  133. package/dist/esm/ui/link-picker/link-search-error/index.js +0 -3
  134. package/dist/esm/ui/link-picker/link-search-list/index.js +12 -20
  135. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/index.js +0 -2
  136. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/index.js +0 -3
  137. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/no-results-svg/styled.js +0 -2
  138. package/dist/esm/ui/link-picker/link-search-list/link-search-no-results/styled.js +0 -2
  139. package/dist/esm/ui/link-picker/link-search-list/styled.js +2 -4
  140. package/dist/esm/ui/link-picker/link-search-list/use-track-results-shown/index.js +11 -11
  141. package/dist/esm/ui/link-picker/list-item/index.js +10 -25
  142. package/dist/esm/ui/link-picker/list-item/styled.js +2 -6
  143. package/dist/esm/ui/link-picker/styled.js +1 -3
  144. package/dist/esm/ui/link-picker/text-input/index.js +9 -16
  145. package/dist/esm/ui/link-picker/text-input/styled.js +0 -2
  146. package/dist/esm/ui/link-picker/track-mount/index.js +2 -4
  147. package/dist/esm/ui/link-picker/track-tab-viewed/index.js +1 -5
  148. package/dist/esm/ui/link-picker/transformTimeStamp.js +0 -7
  149. package/dist/esm/ui/link-picker/utils.js +11 -9
  150. package/dist/esm/ui/scrolling-tabs/index.js +6 -28
  151. package/dist/esm/ui/scrolling-tabs/scrolling-tabs.js +4 -19
  152. package/dist/esm/version.json +1 -1
  153. package/dist/types/analytics.codegen.d.ts +2 -2
  154. package/package.json +8 -13
@@ -1,7 +1,6 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  var _excluded = ["isLoading", "error", "state", "items", "isEditing", "onCancel"];
4
-
5
4
  /** @jsx jsx */
6
5
  import { jsx } from '@emotion/react';
7
6
  import { memo } from 'react';
@@ -31,22 +30,18 @@ export var testIds = {
31
30
  insertButton: 'link-picker-insert-button',
32
31
  cancelButton: 'link-picker-cancel-button'
33
32
  };
34
-
35
33
  var FormFooter = function FormFooter(_ref) {
36
34
  var isLoading = _ref.isLoading,
37
- error = _ref.error,
38
- state = _ref.state,
39
- items = _ref.items,
40
- isEditing = _ref.isEditing,
41
- onCancel = _ref.onCancel,
42
- restProps = _objectWithoutProperties(_ref, _excluded);
43
-
35
+ error = _ref.error,
36
+ state = _ref.state,
37
+ items = _ref.items,
38
+ isEditing = _ref.isEditing,
39
+ onCancel = _ref.onCancel,
40
+ restProps = _objectWithoutProperties(_ref, _excluded);
44
41
  var intl = useIntl();
45
-
46
42
  if (error && error instanceof UnauthenticatedError) {
47
43
  return null;
48
44
  }
49
-
50
45
  var isSubmitDisabled = checkSubmitDisabled(isLoading, error, state, items);
51
46
  var insertButtonMsg = isEditing ? messages.saveButton : messages.insertButton;
52
47
  return jsx("footer", _extends({
@@ -62,5 +57,4 @@ var FormFooter = function FormFooter(_ref) {
62
57
  isDisabled: isSubmitDisabled
63
58
  }, intl.formatMessage(insertButtonMsg))));
64
59
  };
65
-
66
60
  export default /*#__PURE__*/memo(FormFooter);
@@ -1,6 +1,4 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject;
4
-
5
3
  import { css } from '@emotion/react';
6
4
  export var formFooterStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n justify-content: flex-end;\n"])));
@@ -7,24 +7,21 @@ export var checkSubmitDisabled = function checkSubmitDisabled(isLoading, error,
7
7
  if (state && normalizeUrl(state.query)) {
8
8
  return false;
9
9
  }
10
+
10
11
  /*
11
12
  * Disable insert button when plugin returns no results,
12
13
  * but not if it is a valid url
13
14
  */
14
-
15
-
16
15
  if (state && (items === null || items === void 0 ? void 0 : items.length) === 0) {
17
16
  return true;
18
17
  }
18
+
19
19
  /*
20
20
  * Disable insert button when is plugin is loading or
21
21
  * for any search error
22
22
  */
23
-
24
-
25
23
  if (isLoading || error) {
26
24
  return true;
27
25
  }
28
-
29
26
  return false;
30
27
  };
@@ -3,11 +3,8 @@ import _extends from "@babel/runtime/helpers/extends";
3
3
  import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
4
4
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
5
5
  var _excluded = ["component"];
6
-
7
6
  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; }
8
-
9
7
  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) { _defineProperty(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; }
10
-
11
8
  /** @jsx jsx */
12
9
  import { Fragment, useCallback, useLayoutEffect, useReducer, memo } from 'react';
13
10
  import { jsx } from '@emotion/react';
@@ -55,7 +52,6 @@ var initState = {
55
52
  activeTab: 0,
56
53
  preventHidingRecents: false
57
54
  };
58
-
59
55
  function reducer(state, payload) {
60
56
  if (payload.url && state.url !== payload.url) {
61
57
  return _objectSpread(_objectSpread({}, state), {}, {
@@ -63,80 +59,68 @@ function reducer(state, payload) {
63
59
  selectedIndex: isSafeUrl(payload.url) && payload.url.length ? -1 : state.selectedIndex
64
60
  }, payload);
65
61
  }
66
-
67
62
  return _objectSpread(_objectSpread({}, state), payload);
68
63
  }
64
+
69
65
  /**
70
66
  * Bind input fields to analytics tracking
71
67
  */
72
68
 
73
-
74
69
  var getLinkFieldContent = function getLinkFieldContent(value) {
75
70
  if (!Boolean(value)) {
76
71
  return null;
77
72
  }
78
-
79
73
  return isSafeUrl(value) ? 'url' : 'text_string';
80
74
  };
81
-
82
75
  var LinkInputField = withInputFieldTracking(TextInput, 'link', function (event, attributes) {
83
76
  return _objectSpread(_objectSpread({}, attributes), {}, {
84
77
  linkFieldContent: getLinkFieldContent(event.currentTarget.value)
85
78
  });
86
79
  });
87
80
  var DisplayTextInputField = withInputFieldTracking(TextInput, 'displayText');
88
-
89
81
  function LinkPicker(_ref) {
90
82
  var _errorFallback;
91
-
92
83
  var onSubmit = _ref.onSubmit,
93
- onCancel = _ref.onCancel,
94
- onContentResize = _ref.onContentResize,
95
- plugins = _ref.plugins,
96
- initUrl = _ref.url,
97
- initDisplayText = _ref.displayText,
98
- hideDisplayText = _ref.hideDisplayText,
99
- featureFlags = _ref.featureFlags;
100
-
84
+ onCancel = _ref.onCancel,
85
+ onContentResize = _ref.onContentResize,
86
+ plugins = _ref.plugins,
87
+ initUrl = _ref.url,
88
+ initDisplayText = _ref.displayText,
89
+ hideDisplayText = _ref.hideDisplayText,
90
+ featureFlags = _ref.featureFlags;
101
91
  var _useAnalyticsEvents = useAnalyticsEvents(),
102
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
103
-
92
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
104
93
  var _useReducer = useReducer(reducer, _objectSpread(_objectSpread({}, initState), {}, {
105
- url: normalizeUrl(initUrl) || '',
106
- displayText: initDisplayText || ''
107
- })),
108
- _useReducer2 = _slicedToArray(_useReducer, 2),
109
- state = _useReducer2[0],
110
- dispatch = _useReducer2[1];
111
-
94
+ url: normalizeUrl(initUrl) || '',
95
+ displayText: initDisplayText || ''
96
+ })),
97
+ _useReducer2 = _slicedToArray(_useReducer, 2),
98
+ state = _useReducer2[0],
99
+ dispatch = _useReducer2[1];
112
100
  var activeIndex = state.activeIndex,
113
- selectedIndex = state.selectedIndex,
114
- url = state.url,
115
- displayText = state.displayText,
116
- invalidUrl = state.invalidUrl,
117
- activeTab = state.activeTab;
101
+ selectedIndex = state.selectedIndex,
102
+ url = state.url,
103
+ displayText = state.displayText,
104
+ invalidUrl = state.invalidUrl,
105
+ activeTab = state.activeTab;
118
106
  var intl = useIntl();
119
107
  var queryState = useSearchQuery(state);
120
-
121
108
  var _usePlugins = usePlugins(queryState, activeTab, plugins),
122
- items = _usePlugins.items,
123
- isLoading = _usePlugins.isLoading,
124
- isActivePlugin = _usePlugins.isActivePlugin,
125
- activePlugin = _usePlugins.activePlugin,
126
- tabs = _usePlugins.tabs,
127
- error = _usePlugins.error,
128
- retry = _usePlugins.retry,
129
- errorFallback = _usePlugins.errorFallback;
130
-
109
+ items = _usePlugins.items,
110
+ isLoading = _usePlugins.isLoading,
111
+ isActivePlugin = _usePlugins.isActivePlugin,
112
+ activePlugin = _usePlugins.activePlugin,
113
+ tabs = _usePlugins.tabs,
114
+ error = _usePlugins.error,
115
+ retry = _usePlugins.retry,
116
+ errorFallback = _usePlugins.errorFallback;
131
117
  var fixListHeightProps = useFixHeight(isLoading);
132
118
  var isEditing = !!initUrl;
133
119
  var selectedItem = items === null || items === void 0 ? void 0 : items[selectedIndex];
134
120
  var isSelectedItem = (selectedItem === null || selectedItem === void 0 ? void 0 : selectedItem.url) === url;
135
-
136
121
  var _useLinkPickerAnalyti = useLinkPickerAnalytics(),
137
- trackAttribute = _useLinkPickerAnalyti.trackAttribute,
138
- getAttributes = _useLinkPickerAnalyti.getAttributes;
139
-
122
+ trackAttribute = _useLinkPickerAnalyti.trackAttribute,
123
+ getAttributes = _useLinkPickerAnalyti.getAttributes;
140
124
  useLayoutEffect(function () {
141
125
  if (onContentResize) {
142
126
  onContentResize();
@@ -160,29 +144,23 @@ function LinkPicker(_ref) {
160
144
  var key = event.key;
161
145
  var KEY_ARROW_DOWN = 'ArrowDown';
162
146
  var KEY_ARROW_UP = 'ArrowUp';
163
-
164
147
  if (!items || !items.length) {
165
148
  return;
166
149
  }
167
-
168
150
  var updatedIndex = activeIndex;
169
-
170
151
  switch (key) {
171
152
  case KEY_ARROW_DOWN:
172
153
  // down
173
154
  event.preventDefault();
174
155
  updatedIndex = (activeIndex + 1) % items.length;
175
156
  break;
176
-
177
157
  case KEY_ARROW_UP:
178
158
  // up
179
159
  event.preventDefault();
180
160
  updatedIndex = activeIndex > 0 ? activeIndex - 1 : items.length - 1;
181
161
  break;
182
162
  }
183
-
184
163
  var item = items[updatedIndex];
185
-
186
164
  if ([KEY_ARROW_DOWN, KEY_ARROW_UP].includes(key) && item) {
187
165
  /**
188
166
  * Manually track that the url has been updated using searchResult method
@@ -216,8 +194,8 @@ function LinkPicker(_ref) {
216
194
  var handleMouseLeaveResultItem = useCallback(function (objectId) {
217
195
  var index = items === null || items === void 0 ? void 0 : items.findIndex(function (item) {
218
196
  return item.objectId === objectId;
219
- }); // This is to avoid updating index that was set by other mouseenter event
220
-
197
+ });
198
+ // This is to avoid updating index that was set by other mouseenter event
221
199
  if (activeIndex === index) {
222
200
  dispatch({
223
201
  activeIndex: -1
@@ -225,16 +203,17 @@ function LinkPicker(_ref) {
225
203
  }
226
204
  }, [dispatch, activeIndex, items]);
227
205
  var handleInsert = useCallback(function (url, title, inputType) {
228
- var event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {})); // Clone the event so that it can be emitted for consumer usage
229
- // This must happen BEFORE the original event is fired!
206
+ var event = createAnalyticsEvent(createEventPayload('ui.form.submitted.linkPicker', {}));
230
207
 
231
- var consumerEvent = event.clone(); // Cloned event doesnt have the attributes that are added by
208
+ // Clone the event so that it can be emitted for consumer usage
209
+ // This must happen BEFORE the original event is fired!
210
+ var consumerEvent = event.clone();
211
+ // Cloned event doesnt have the attributes that are added by
232
212
  // the analytics listener in the LinkPickerAnalyticsContext, add them here
233
-
234
213
  consumerEvent === null || consumerEvent === void 0 ? void 0 : consumerEvent.update({
235
214
  attributes: getAttributes()
236
- }); // Dispatch the original event to our channel
237
-
215
+ });
216
+ // Dispatch the original event to our channel
238
217
  event.fire(ANALYTICS_CHANNEL);
239
218
  onSubmit(_objectSpread({
240
219
  url: url,
@@ -251,14 +230,12 @@ function LinkPicker(_ref) {
251
230
  var selectedItem = items === null || items === void 0 ? void 0 : items.find(function (item) {
252
231
  return item.objectId === objectId;
253
232
  });
254
-
255
233
  if (selectedItem) {
256
234
  var _url = selectedItem.url,
257
- name = selectedItem.name;
235
+ name = selectedItem.name;
258
236
  /**
259
237
  * Manually track that the url has been updated using searchResult method
260
238
  */
261
-
262
239
  dispatchEvent(new Event('submit'));
263
240
  trackAttribute('linkFieldContent', getLinkFieldContent(_url));
264
241
  trackAttribute('linkFieldContentInputMethod', 'searchResult');
@@ -268,24 +245,19 @@ function LinkPicker(_ref) {
268
245
  }, [handleInsert, trackAttribute, items, activePlugin]);
269
246
  var handleSubmit = useCallback(function (event) {
270
247
  event.preventDefault();
271
-
272
248
  if (isSelectedItem && selectedItem) {
273
249
  return handleInsert(selectedItem.url, selectedItem.name, 'typeAhead');
274
250
  }
275
-
276
251
  var normalized = normalizeUrl(url);
277
-
278
252
  if (normalized) {
279
253
  return handleInsert(normalized, null, 'manual');
280
254
  }
281
-
282
255
  return dispatch({
283
256
  invalidUrl: true
284
257
  });
285
258
  }, [dispatch, handleInsert, isSelectedItem, selectedItem, url]);
286
259
  var handleTabChange = useCallback(function (activeTab) {
287
260
  var _plugins$activeTab$ta, _plugins$activeTab;
288
-
289
261
  dispatch({
290
262
  // We don't want any selection to exist after changing tab, as the selection
291
263
  // wouldn't mean anything.
@@ -301,10 +273,11 @@ function LinkPicker(_ref) {
301
273
  var messages = isActivePlugin ? searchMessages : linkMessages;
302
274
  var screenReaderDescriptionId = 'search-recent-links-field-description';
303
275
  var linkSearchListId = 'link-picker-search-list';
304
- var ariaActiveDescendant = selectedIndex > -1 ? "link-search-list-item-".concat(selectedIndex) : ''; // Added workaround with a screen reader Announcer specifically for VoiceOver + Safari
276
+ var ariaActiveDescendant = selectedIndex > -1 ? "link-search-list-item-".concat(selectedIndex) : '';
277
+
278
+ // Added workaround with a screen reader Announcer specifically for VoiceOver + Safari
305
279
  // as the Aria design pattern for combobox does not work in this case
306
280
  // for details: https://a11y-internal.atlassian.net/browse/AK-740
307
-
308
281
  var screenReaderText = browser.safari && getScreenReaderText(items !== null && items !== void 0 ? items : [], selectedIndex, intl);
309
282
  var searchIcon = isActivePlugin && jsx("span", {
310
283
  css: searchIconStyles,
@@ -394,18 +367,15 @@ function LinkPicker(_ref) {
394
367
  css: !queryState || !(plugins !== null && plugins !== void 0 && plugins.length) ? formFooterMargin : undefined
395
368
  }));
396
369
  }
397
-
398
370
  var DefaultRootComponent = function DefaultRootComponent(_ref2) {
399
371
  var children = _ref2.children;
400
372
  return jsx("div", {
401
373
  "data-testid": testIds.linkPickerRoot
402
374
  }, children);
403
375
  };
404
-
405
376
  export default withLinkPickerAnalyticsContext( /*#__PURE__*/memo(function (_ref3) {
406
377
  var component = _ref3.component,
407
- props = _objectWithoutProperties(_ref3, _excluded);
408
-
378
+ props = _objectWithoutProperties(_ref3, _excluded);
409
379
  var RootComponent = component !== null && component !== void 0 ? component : DefaultRootComponent;
410
380
  return jsx(RootComponent, _extends({}, props, {
411
381
  "data-testid": testIds.linkPickerRoot
@@ -1,5 +1,4 @@
1
1
  import _extends from "@babel/runtime/helpers/extends";
2
-
3
2
  /** @jsx jsx */
4
3
  import { jsx } from '@emotion/react';
5
4
  import { useIntl, FormattedMessage, defineMessages } from 'react-intl-next';
@@ -22,7 +21,6 @@ export var messages = defineMessages({
22
21
  export var testIds = {
23
22
  searchError: 'link-search-error'
24
23
  };
25
-
26
24
  var LinkSearchError = function LinkSearchError() {
27
25
  var intl = useIntl();
28
26
  return jsx(EmptyState, {
@@ -46,5 +44,4 @@ var LinkSearchError = function LinkSearchError() {
46
44
  }
47
45
  });
48
46
  };
49
-
50
47
  export default LinkSearchError;
@@ -2,11 +2,8 @@ import _extends from "@babel/runtime/helpers/extends";
2
2
  import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
3
3
  import _defineProperty from "@babel/runtime/helpers/defineProperty";
4
4
  var _excluded = ["onSelect", "onMouseEnter", "onMouseLeave", "items", "activeIndex", "selectedIndex", "isLoading", "ariaControls", "ariaLabelledBy", "role", "id", "hasSearchTerm"];
5
-
6
5
  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; }
7
-
8
6
  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) { _defineProperty(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; }
9
-
10
7
  /** @jsx jsx */
11
8
  import { forwardRef, Fragment } from 'react';
12
9
  import { jsx } from '@emotion/react';
@@ -42,28 +39,25 @@ export var testIds = _objectSpread(_objectSpread({}, noResultsTestIds), {}, {
42
39
  });
43
40
  var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
44
41
  var onSelect = _ref.onSelect,
45
- onMouseEnter = _ref.onMouseEnter,
46
- onMouseLeave = _ref.onMouseLeave,
47
- items = _ref.items,
48
- activeIndex = _ref.activeIndex,
49
- selectedIndex = _ref.selectedIndex,
50
- isLoading = _ref.isLoading,
51
- ariaControls = _ref.ariaControls,
52
- ariaLabelledBy = _ref.ariaLabelledBy,
53
- role = _ref.role,
54
- id = _ref.id,
55
- hasSearchTerm = _ref.hasSearchTerm,
56
- restProps = _objectWithoutProperties(_ref, _excluded);
57
-
42
+ onMouseEnter = _ref.onMouseEnter,
43
+ onMouseLeave = _ref.onMouseLeave,
44
+ items = _ref.items,
45
+ activeIndex = _ref.activeIndex,
46
+ selectedIndex = _ref.selectedIndex,
47
+ isLoading = _ref.isLoading,
48
+ ariaControls = _ref.ariaControls,
49
+ ariaLabelledBy = _ref.ariaLabelledBy,
50
+ role = _ref.role,
51
+ id = _ref.id,
52
+ hasSearchTerm = _ref.hasSearchTerm,
53
+ restProps = _objectWithoutProperties(_ref, _excluded);
58
54
  var itemsContent;
59
55
  var loadingContent;
60
56
  var linkListTitle = hasSearchTerm ? messages.titleResults : messages.titleRecentlyViewed;
61
57
  useTrackResultsShown(isLoading, items, hasSearchTerm);
62
-
63
58
  if ((items === null || items === void 0 ? void 0 : items.length) === 0) {
64
59
  return jsx(LinkSearchNoResults, null);
65
60
  }
66
-
67
61
  if (items && items.length > 0) {
68
62
  itemsContent = jsx(Fragment, null, jsx("div", {
69
63
  css: listTitleStyles,
@@ -98,7 +92,6 @@ var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
98
92
  });
99
93
  })));
100
94
  }
101
-
102
95
  if (isLoading) {
103
96
  loadingContent = jsx("div", {
104
97
  css: spinnerContainerStyles
@@ -107,7 +100,6 @@ var LinkSearchList = /*#__PURE__*/forwardRef(function (_ref, ref) {
107
100
  size: "medium"
108
101
  }));
109
102
  }
110
-
111
103
  return jsx("div", _extends({
112
104
  ref: ref,
113
105
  css: listContainerStyles
@@ -19,7 +19,6 @@ export var messages = defineMessages({
19
19
  export var testIds = {
20
20
  emptyResultPage: 'link-search-no-results'
21
21
  };
22
-
23
22
  var NoResults = function NoResults() {
24
23
  var intl = useIntl();
25
24
  return jsx("div", {
@@ -33,5 +32,4 @@ var NoResults = function NoResults() {
33
32
  }
34
33
  }));
35
34
  };
36
-
37
35
  export default NoResults;
@@ -1,9 +1,7 @@
1
1
  /* eslint-disable @atlaskit/design-system/ensure-design-token-usage */
2
-
3
2
  /** @jsx jsx */
4
3
  import { jsx } from '@emotion/react';
5
4
  import { noResultsSVGStyles } from './styled';
6
-
7
5
  var NoResultsSVG = function NoResultsSVG() {
8
6
  var id = 'link-picker-ui-no-results-svg';
9
7
  return jsx("svg", {
@@ -56,5 +54,4 @@ var NoResultsSVG = function NoResultsSVG() {
56
54
  d: "M0 0h207.16v189.87H0z"
57
55
  }))));
58
56
  };
59
-
60
57
  export default NoResultsSVG;
@@ -1,7 +1,5 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject;
4
-
5
3
  import { gridSize as getGridSize } from '@atlaskit/theme/constants';
6
4
  import { css } from '@emotion/react';
7
5
  var HEIGHT = 120;
@@ -1,6 +1,4 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject;
4
-
5
3
  import { css } from '@emotion/react';
6
4
  export var emptyStateWrapperStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n & p {\n margin: 0;\n }\n"])));
@@ -1,10 +1,8 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject, _templateObject2, _templateObject3, _templateObject4;
4
-
5
- import { css } from '@emotion/react'; // AFP-2532 TODO: Fix automatic suppressions below
3
+ import { css } from '@emotion/react';
4
+ // AFP-2532 TODO: Fix automatic suppressions below
6
5
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
7
-
8
6
  import { typography } from '@atlaskit/theme';
9
7
  import { gridSize as getGridSize } from '@atlaskit/theme/constants';
10
8
  var gridSize = getGridSize();
@@ -7,28 +7,28 @@ import createEventPayload from '../../../../analytics.codegen';
7
7
  var DEBOUNCE_MS = 400;
8
8
  export var useTrackResultsShown = function useTrackResultsShown(isLoading, items, hasSearchTerm) {
9
9
  var _useAnalyticsEvents = useAnalyticsEvents(),
10
- createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
11
-
12
- var hasSearchTermRef = useRef(hasSearchTerm); // Using ref so that not required in the dependency array
10
+ createAnalyticsEvent = _useAnalyticsEvents.createAnalyticsEvent;
11
+ var hasSearchTermRef = useRef(hasSearchTerm);
12
+ // Using ref so that not required in the dependency array
13
13
  // Analytics should be entirely dependent on change of items being viewed
14
-
15
14
  useEffect(function () {
16
15
  hasSearchTermRef.current = hasSearchTerm;
17
- }, [hasSearchTerm]); // Filters isLoading/items to only return the array of items if no longer loading more items
16
+ }, [hasSearchTerm]);
17
+
18
+ // Filters isLoading/items to only return the array of items if no longer loading more items
18
19
  // Loading state IS a factor here because some tabs will
19
20
  // load intermediate results whilst loading additional results (Atlassian tab)
20
21
  // Considered to only have "shown" results once we are in a final state (no longer loading)
21
-
22
22
  var finalItems = useMemo(function () {
23
23
  return !isLoading ? items : null;
24
- }, [isLoading, items]); // Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
24
+ }, [isLoading, items]);
25
+
26
+ // Because Atlassian tab resolves intermediate results on every keystroke (may never be loading)
25
27
  // Debounce the items so that we only consider the results to have been shown
26
28
  // after they have been stable for DEBOUNCE_MS
27
-
28
29
  var _useDebounce = useDebounce(finalItems, DEBOUNCE_MS),
29
- _useDebounce2 = _slicedToArray(_useDebounce, 1),
30
- debouncedItems = _useDebounce2[0];
31
-
30
+ _useDebounce2 = _slicedToArray(_useDebounce, 1),
31
+ debouncedItems = _useDebounce2[0];
32
32
  useEffect(function () {
33
33
  if (debouncedItems) {
34
34
  var event = !hasSearchTermRef.current ? 'ui.searchResults.shown.preQuerySearchResults' : 'ui.searchResults.shown.postQuerySearchResults';
@@ -5,30 +5,25 @@ import { injectIntl } from 'react-intl-next';
5
5
  import { transformTimeStamp } from '../transformTimeStamp';
6
6
  import { itemNameStyles, itemIconStyles, listItemContextStyles, listItemNameStyles, composeListItemStyles, imgStyles, listItemContainerStyles, listItemContainerInnerStyles } from './styled';
7
7
  import { testIds } from '..';
8
-
9
8
  var LinkSearchListItem = function LinkSearchListItem(_ref) {
10
9
  var item = _ref.item,
11
- selected = _ref.selected,
12
- active = _ref.active,
13
- id = _ref.id,
14
- role = _ref.role,
15
- intl = _ref.intl,
16
- onSelect = _ref.onSelect,
17
- onMouseEnter = _ref.onMouseEnter,
18
- onMouseLeave = _ref.onMouseLeave;
19
-
10
+ selected = _ref.selected,
11
+ active = _ref.active,
12
+ id = _ref.id,
13
+ role = _ref.role,
14
+ intl = _ref.intl,
15
+ onSelect = _ref.onSelect,
16
+ onMouseEnter = _ref.onMouseEnter,
17
+ onMouseLeave = _ref.onMouseLeave;
20
18
  var handleSelect = function handleSelect() {
21
19
  return onSelect(item.objectId);
22
20
  };
23
-
24
21
  var handleMouseEnter = function handleMouseEnter() {
25
22
  return onMouseEnter(item.objectId);
26
23
  };
27
-
28
24
  var handleMouseLeave = function handleMouseLeave() {
29
25
  return onMouseLeave(item.objectId);
30
26
  };
31
-
32
27
  var container = item.container || null;
33
28
  var date = transformTimeStamp(intl, item.lastViewedDate, item.lastUpdatedDate);
34
29
  return jsx("div", {
@@ -59,35 +54,26 @@ var LinkSearchListItem = function LinkSearchListItem(_ref) {
59
54
  css: listItemContainerInnerStyles
60
55
  }, container && jsx(Fragment, null, "\xA0 \u2022\xA0 "), jsx(Fragment, null, formatDate(date))))));
61
56
  };
62
-
63
57
  export default injectIntl(LinkSearchListItem);
64
-
65
58
  var formatDate = function formatDate(date) {
66
59
  return [date.pageAction, date.dateString, date.timeSince].filter(Boolean).join(' ');
67
60
  };
68
-
69
61
  var isSVG = function isSVG(icon) {
70
62
  return icon.startsWith('<svg') && icon.endsWith('</svg>');
71
63
  };
72
-
73
64
  var base64SVG = function base64SVG(icon) {
74
65
  return "data:image/svg+xml;base64,".concat(Buffer.from(icon).toString('base64'));
75
66
  };
76
-
77
67
  var testId = 'link-search-list-item-icon';
78
-
79
68
  var ListItemIcon = function ListItemIcon(props) {
80
69
  var item = props.item,
81
- intl = props.intl;
70
+ intl = props.intl;
82
71
  var icon = item.icon,
83
- iconAlt = item.iconAlt;
84
-
72
+ iconAlt = item.iconAlt;
85
73
  if (!icon) {
86
74
  return null;
87
75
  }
88
-
89
76
  var alt = typeof iconAlt === 'string' ? iconAlt : intl.formatMessage(iconAlt);
90
-
91
77
  if (typeof icon !== 'string') {
92
78
  var Glyph = icon;
93
79
  return jsx("span", {
@@ -97,7 +83,6 @@ var ListItemIcon = function ListItemIcon(props) {
97
83
  "data-testid": testId
98
84
  }));
99
85
  }
100
-
101
86
  return jsx("span", {
102
87
  css: itemIconStyles
103
88
  }, jsx("img", {
@@ -1,22 +1,18 @@
1
1
  import _taggedTemplateLiteral from "@babel/runtime/helpers/taggedTemplateLiteral";
2
-
3
2
  var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7, _templateObject8, _templateObject9, _templateObject10, _templateObject11, _templateObject12;
4
-
5
3
  import { css } from '@emotion/react';
6
4
  import { B50, N300, N800, N20, B400 } from '@atlaskit/theme/colors';
7
- import { gridSize } from '@atlaskit/theme/constants'; // AFP-2532 TODO: Fix automatic suppressions below
5
+ import { gridSize } from '@atlaskit/theme/constants';
6
+ // AFP-2532 TODO: Fix automatic suppressions below
8
7
  // eslint-disable-next-line @atlassian/tangerine/import/entry-points
9
-
10
8
  import { fontSizeSmall, fontSize } from '@atlaskit/theme';
11
9
  export var relativeFontSizeToBase16 = function relativeFontSizeToBase16(px) {
12
10
  if (typeof px === 'string') {
13
11
  px = parseInt(px);
14
12
  }
15
-
16
13
  if (isNaN(px)) {
17
14
  throw new Error("Invalid font size: '".concat(px, "'"));
18
15
  }
19
-
20
16
  return "".concat(px / 16, "rem");
21
17
  };
22
18
  var listItemBaseStyles = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n display: flex;\n padding: ", "px ", "px;\n margin: 0 -", "px;\n cursor: pointer;\n"])), gridSize(), gridSize() * 2, gridSize() * 2);