@atlaskit/editor-plugin-type-ahead 11.3.5 → 12.0.0

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 (72) hide show
  1. package/CHANGELOG.md +37 -0
  2. package/commands/package.json +1 -8
  3. package/dist/cjs/pm-plugins/commands/update-section-title.js +6 -9
  4. package/dist/cjs/ui/TypeAheadList.js +75 -48
  5. package/dist/cjs/ui/TypeAheadPopup.js +1 -0
  6. package/dist/cjs/ui/hooks/build-sectioned-result.js +8 -4
  7. package/dist/es2019/pm-plugins/commands/update-section-title.js +5 -5
  8. package/dist/es2019/ui/TypeAheadList.js +42 -11
  9. package/dist/es2019/ui/TypeAheadPopup.js +1 -0
  10. package/dist/es2019/ui/hooks/build-sectioned-result.js +8 -4
  11. package/dist/esm/pm-plugins/commands/update-section-title.js +6 -8
  12. package/dist/esm/ui/TypeAheadList.js +75 -48
  13. package/dist/esm/ui/TypeAheadPopup.js +1 -0
  14. package/dist/esm/ui/hooks/build-sectioned-result.js +8 -4
  15. package/dist/types/pm-plugins/commands/update-section-title.d.ts +1 -1
  16. package/dist/types/typeAheadPluginType.d.ts +2 -2
  17. package/dist/types/types/index.d.ts +4 -4
  18. package/dist/types/ui/TypeAheadList.d.ts +4 -1
  19. package/package.json +20 -28
  20. package/type-ahead-plugin/package.json +1 -8
  21. package/type-ahead-plugin-type/package.json +1 -8
  22. package/types/package.json +1 -8
  23. package/dist/types-ts4.5/entry-points/commands.d.ts +0 -1
  24. package/dist/types-ts4.5/entry-points/type-ahead-plugin-type.d.ts +0 -1
  25. package/dist/types-ts4.5/entry-points/type-ahead-plugin.d.ts +0 -1
  26. package/dist/types-ts4.5/entry-points/types.d.ts +0 -1
  27. package/dist/types-ts4.5/index.d.ts +0 -3
  28. package/dist/types-ts4.5/pm-plugins/actions.d.ts +0 -12
  29. package/dist/types-ts4.5/pm-plugins/analytics.d.ts +0 -8
  30. package/dist/types-ts4.5/pm-plugins/api.d.ts +0 -60
  31. package/dist/types-ts4.5/pm-plugins/commands/clear-list-error.d.ts +0 -2
  32. package/dist/types-ts4.5/pm-plugins/commands/close-type-ahead.d.ts +0 -2
  33. package/dist/types-ts4.5/pm-plugins/commands/insert-type-ahead-item.d.ts +0 -12
  34. package/dist/types-ts4.5/pm-plugins/commands/insert-utils.d.ts +0 -18
  35. package/dist/types-ts4.5/pm-plugins/commands/open-typeahead-at-cursor.d.ts +0 -5
  36. package/dist/types-ts4.5/pm-plugins/commands/set-selection-before-query.d.ts +0 -2
  37. package/dist/types-ts4.5/pm-plugins/commands/update-list-error.d.ts +0 -2
  38. package/dist/types-ts4.5/pm-plugins/commands/update-list-items.d.ts +0 -3
  39. package/dist/types-ts4.5/pm-plugins/commands/update-query.d.ts +0 -2
  40. package/dist/types-ts4.5/pm-plugins/commands/update-section-title.d.ts +0 -2
  41. package/dist/types-ts4.5/pm-plugins/commands/update-selected-index.d.ts +0 -3
  42. package/dist/types-ts4.5/pm-plugins/constants.d.ts +0 -8
  43. package/dist/types-ts4.5/pm-plugins/decorations.d.ts +0 -17
  44. package/dist/types-ts4.5/pm-plugins/input-rules.d.ts +0 -6
  45. package/dist/types-ts4.5/pm-plugins/insert-item-plugin.d.ts +0 -2
  46. package/dist/types-ts4.5/pm-plugins/isInsertionTransaction.d.ts +0 -4
  47. package/dist/types-ts4.5/pm-plugins/item-is-disabled.d.ts +0 -3
  48. package/dist/types-ts4.5/pm-plugins/key.d.ts +0 -3
  49. package/dist/types-ts4.5/pm-plugins/main.d.ts +0 -18
  50. package/dist/types-ts4.5/pm-plugins/reducer.d.ts +0 -10
  51. package/dist/types-ts4.5/pm-plugins/stats-modifier.d.ts +0 -20
  52. package/dist/types-ts4.5/pm-plugins/utils.d.ts +0 -42
  53. package/dist/types-ts4.5/typeAheadPlugin.d.ts +0 -10
  54. package/dist/types-ts4.5/typeAheadPluginType.d.ts +0 -52
  55. package/dist/types-ts4.5/types/index.d.ts +0 -114
  56. package/dist/types-ts4.5/ui/ContentComponent.d.ts +0 -12
  57. package/dist/types-ts4.5/ui/InputQuery.d.ts +0 -31
  58. package/dist/types-ts4.5/ui/ListRow.d.ts +0 -21
  59. package/dist/types-ts4.5/ui/MoreOptions.d.ts +0 -16
  60. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/EmptyState.d.ts +0 -9
  61. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/GenericErrorSVG.d.ts +0 -6
  62. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/MinHeightContainer.d.ts +0 -10
  63. package/dist/types-ts4.5/ui/TypeAheadErrorFallback/index.d.ts +0 -6
  64. package/dist/types-ts4.5/ui/TypeAheadList.d.ts +0 -55
  65. package/dist/types-ts4.5/ui/TypeAheadListItem.d.ts +0 -25
  66. package/dist/types-ts4.5/ui/TypeAheadMenu.d.ts +0 -14
  67. package/dist/types-ts4.5/ui/TypeAheadPopup.d.ts +0 -38
  68. package/dist/types-ts4.5/ui/WrapperTypeAhead.d.ts +0 -21
  69. package/dist/types-ts4.5/ui/hooks/build-sectioned-result.d.ts +0 -11
  70. package/dist/types-ts4.5/ui/hooks/use-item-insert.d.ts +0 -9
  71. package/dist/types-ts4.5/ui/hooks/use-load-items.d.ts +0 -5
  72. package/dist/types-ts4.5/ui/hooks/use-on-force-select.d.ts +0 -11
package/CHANGELOG.md CHANGED
@@ -1,5 +1,42 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 12.0.0
4
+
5
+ ### Major Changes
6
+
7
+ - [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
8
+ Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
9
+
10
+ Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
11
+
12
+ Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
13
+
14
+ ```diff
15
+ - "typesVersions": {
16
+ - ">=4.5 <4.9": {
17
+ - "*": [
18
+ - "dist/types-ts4.5/*",
19
+ - "dist/types-ts4.5/index.d.ts"
20
+ - ]
21
+ - }
22
+ - },
23
+ ```
24
+
25
+ ### Minor Changes
26
+
27
+ - [`78adaba64ee33`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/78adaba64ee33) -
28
+ Add opt-in section title display controls for typeahead sections
29
+
30
+ ### Patch Changes
31
+
32
+ - Updated dependencies
33
+
34
+ ## 11.3.6
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies
39
+
3
40
  ## 11.3.5
4
41
 
5
42
  ### Patch Changes
@@ -6,12 +6,5 @@
6
6
  "sideEffects": [
7
7
  "*.compiled.css"
8
8
  ],
9
- "types": "../dist/types/entry-points/commands.d.ts",
10
- "typesVersions": {
11
- ">=4.5 <5.9": {
12
- "*": [
13
- "../dist/types-ts4.5/entry-points/commands.d.ts"
14
- ]
15
- }
16
- }
9
+ "types": "../dist/types/entry-points/commands.d.ts"
17
10
  }
@@ -1,30 +1,27 @@
1
1
  "use strict";
2
2
 
3
- var _interopRequireDefault = require("@babel/runtime/helpers/interopRequireDefault");
4
3
  Object.defineProperty(exports, "__esModule", {
5
4
  value: true
6
5
  });
7
6
  exports.updateSectionTitle = void 0;
8
- var _defineProperty2 = _interopRequireDefault(require("@babel/runtime/helpers/defineProperty"));
9
7
  var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
10
8
  var _actions = require("../actions");
11
9
  var _key = require("../key");
12
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
13
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { (0, _defineProperty2.default)(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
14
10
  var updateSectionTitle = exports.updateSectionTitle = function updateSectionTitle(_ref) {
15
11
  var id = _ref.id,
16
12
  title = _ref.title,
17
- showTitleWhenOnlySection = _ref.showTitleWhenOnlySection;
13
+ sectionTitleDisplay = _ref.sectionTitleDisplay;
18
14
  return function (state, dispatch) {
19
15
  if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) || !dispatch) {
20
16
  return false;
21
17
  }
22
18
  var tr = state.tr;
23
- var update = _objectSpread({
19
+ var update = {
24
20
  title: title
25
- }, showTitleWhenOnlySection !== undefined ? {
26
- showTitleWhenOnlySection: showTitleWhenOnlySection
27
- } : {});
21
+ };
22
+ if (sectionTitleDisplay !== undefined) {
23
+ update.sectionTitleDisplay = sectionTitleDisplay;
24
+ }
28
25
  tr.setMeta(_key.pluginKey, {
29
26
  action: _actions.ACTIONS.UPDATE_SECTION_TITLE,
30
27
  params: {
@@ -20,7 +20,7 @@ var _ui = require("@atlaskit/editor-common/ui");
20
20
  var _menu = require("@atlaskit/menu");
21
21
  var _compiled = require("@atlaskit/primitives/compiled");
22
22
  var _expValEquals = require("@atlaskit/tmp-editor-statsig/exp-val-equals");
23
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
23
+ var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
24
24
  var _closeTypeAhead = require("../pm-plugins/commands/close-type-ahead");
25
25
  var _updateSelectedIndex = require("../pm-plugins/commands/update-selected-index");
26
26
  var _constants = require("../pm-plugins/constants");
@@ -44,9 +44,34 @@ var list = (0, _react2.css)({
44
44
  padding: "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-150, 12px)")
45
45
  }
46
46
  });
47
- var buildTypeAheadRows = exports.buildTypeAheadRows = function buildTypeAheadRows(_ref) {
48
- var itemsLength = _ref.itemsLength,
49
- sections = _ref.sections;
47
+ /**
48
+ * Resolves section title visibility before rows are built so hidden titles do not
49
+ * occupy virtualized list rows. A single populated section keeps the existing
50
+ * no-title behaviour unless it opts in with `showWhenOnlySection`; multiple
51
+ * populated sections show titles by default. `showWhenQueryPresent: false`
52
+ * takes precedence once the query is non-empty.
53
+ */
54
+ var shouldRenderSectionTitle = function shouldRenderSectionTitle(_ref) {
55
+ var _section$sectionTitle;
56
+ var isEmptyQuery = _ref.isEmptyQuery,
57
+ populatedSectionCount = _ref.populatedSectionCount,
58
+ section = _ref.section;
59
+ if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false)) {
60
+ return populatedSectionCount > 1;
61
+ }
62
+ if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
63
+ return false;
64
+ }
65
+ if (populatedSectionCount === 1) {
66
+ var _section$sectionTitle2;
67
+ return ((_section$sectionTitle2 = section.sectionTitleDisplay) === null || _section$sectionTitle2 === void 0 ? void 0 : _section$sectionTitle2.showWhenOnlySection) === true;
68
+ }
69
+ return true;
70
+ };
71
+ var buildTypeAheadRows = exports.buildTypeAheadRows = function buildTypeAheadRows(_ref2) {
72
+ var isEmptyQuery = _ref2.isEmptyQuery,
73
+ itemsLength = _ref2.itemsLength,
74
+ sections = _ref2.sections;
50
75
  if (sections.length === 0) {
51
76
  return Array.from({
52
77
  length: itemsLength
@@ -64,13 +89,21 @@ var buildTypeAheadRows = exports.buildTypeAheadRows = function buildTypeAheadRow
64
89
  return [section.startIndex, section];
65
90
  }));
66
91
  var rows = [];
92
+ var populatedSectionCount = sortedSections.length;
67
93
  for (var itemIndex = 0; itemIndex < itemsLength; itemIndex++) {
68
94
  var section = sectionsByStartIndex.get(itemIndex);
69
95
  if (section) {
70
- rows.push({
71
- type: 'section',
96
+ var shouldRenderTitle = shouldRenderSectionTitle({
97
+ isEmptyQuery: isEmptyQuery,
98
+ populatedSectionCount: populatedSectionCount,
72
99
  section: section
73
100
  });
101
+ if (shouldRenderTitle) {
102
+ rows.push({
103
+ type: 'section',
104
+ section: section
105
+ });
106
+ }
74
107
  }
75
108
  rows.push({
76
109
  type: 'item',
@@ -79,8 +112,8 @@ var buildTypeAheadRows = exports.buildTypeAheadRows = function buildTypeAheadRow
79
112
  }
80
113
  return rows;
81
114
  };
82
- var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/_react.default.memo(function (_ref2) {
83
- var numberOfResults = _ref2.numberOfResults;
115
+ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
116
+ var numberOfResults = _ref3.numberOfResults;
84
117
  var intl = (0, _reactIntl.useIntl)();
85
118
  return (0, _react2.jsx)(_ui.AssistiveText, {
86
119
  assistiveText: intl.formatMessage(_typeAhead.typeAheadListMessages.searchResultsLabel, {
@@ -92,22 +125,24 @@ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/_react.default.memo(funct
92
125
  id: _constants.TYPE_AHEAD_DECORATION_ELEMENT_ID + '__popup'
93
126
  });
94
127
  });
95
- var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
128
+ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref4) {
96
129
  var _itemRowIndexByItemIn, _triggerHandler$getMo, _decorationElement$qu2;
97
- var items = _ref3.items,
98
- sections = _ref3.sections,
99
- emptyItem = _ref3.emptyItem,
100
- selectedIndex = _ref3.selectedIndex,
101
- editorView = _ref3.editorView,
102
- onItemClick = _ref3.onItemClick,
103
- intl = _ref3.intl,
104
- fitHeight = _ref3.fitHeight,
105
- decorationElement = _ref3.decorationElement,
106
- triggerHandler = _ref3.triggerHandler,
107
- moreElementsInQuickInsertViewEnabled = _ref3.moreElementsInQuickInsertViewEnabled,
108
- api = _ref3.api,
109
- showMoreOptionsButton = _ref3.showMoreOptionsButton,
110
- onMoreOptionsClicked = _ref3.onMoreOptionsClicked;
130
+ var items = _ref4.items,
131
+ sections = _ref4.sections,
132
+ emptyItem = _ref4.emptyItem,
133
+ selectedIndex = _ref4.selectedIndex,
134
+ _ref4$isEmptyQuery = _ref4.isEmptyQuery,
135
+ isEmptyQuery = _ref4$isEmptyQuery === void 0 ? true : _ref4$isEmptyQuery,
136
+ editorView = _ref4.editorView,
137
+ onItemClick = _ref4.onItemClick,
138
+ intl = _ref4.intl,
139
+ fitHeight = _ref4.fitHeight,
140
+ decorationElement = _ref4.decorationElement,
141
+ triggerHandler = _ref4.triggerHandler,
142
+ moreElementsInQuickInsertViewEnabled = _ref4.moreElementsInQuickInsertViewEnabled,
143
+ api = _ref4.api,
144
+ showMoreOptionsButton = _ref4.showMoreOptionsButton,
145
+ onMoreOptionsClicked = _ref4.onMoreOptionsClicked;
111
146
  var listRef = (0, _react.useRef)();
112
147
  var listContainerRef = (0, _react.useRef)(null);
113
148
  var lastInputMethodRef = (0, _react.useRef)('keyboard');
@@ -136,10 +171,11 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
136
171
  setCache = _useState4[1];
137
172
  var listRows = (0, _react.useMemo)(function () {
138
173
  return buildTypeAheadRows({
174
+ isEmptyQuery: isEmptyQuery,
139
175
  itemsLength: itemsLength,
140
176
  sections: sections || []
141
177
  });
142
- }, [itemsLength, sections]);
178
+ }, [isEmptyQuery, itemsLength, sections]);
143
179
  var itemRowIndexByItemIndex = (0, _react.useMemo)(function () {
144
180
  var rowIndexByItemIndex = new Map();
145
181
  listRows.forEach(function (row, rowIndex) {
@@ -150,11 +186,6 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
150
186
  return rowIndexByItemIndex;
151
187
  }, [listRows]);
152
188
  var selectedItemRowIndex = selectedIndex >= 0 ? (_itemRowIndexByItemIn = itemRowIndexByItemIndex.get(selectedIndex)) !== null && _itemRowIndexByItemIn !== void 0 ? _itemRowIndexByItemIn : -1 : -1;
153
- var populatedSectionCount = (0, _react.useMemo)(function () {
154
- return listRows.filter(function (row) {
155
- return row.type === 'section';
156
- }).length;
157
- }, [listRows]);
158
189
  var onItemsRendered = (0, _react.useCallback)(function (props) {
159
190
  lastVisibleIndexes.current = props;
160
191
  }, []);
@@ -191,8 +222,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
191
222
  var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
192
223
  var onScroll = (0, _react.useCallback)(
193
224
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
194
- function (_ref4) {
195
- var scrollUpdateWasRequested = _ref4.scrollUpdateWasRequested;
225
+ function (_ref5) {
226
+ var scrollUpdateWasRequested = _ref5.scrollUpdateWasRequested;
196
227
  if (!scrollUpdateWasRequested) {
197
228
  return;
198
229
  }
@@ -278,7 +309,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
278
309
  }, [items, sections]);
279
310
  (0, _react.useLayoutEffect)(function () {
280
311
  // Exclude view more item from the count
281
- var itemsToRender = (0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
312
+ var itemsToRender = (0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
282
313
  var height = Math.min(
283
314
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
284
315
  itemsToRender.reduce(function (prevValue, currentValue, index) {
@@ -350,8 +381,8 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
350
381
  if (onMoreOptionsClicked) {
351
382
  onMoreOptionsClicked();
352
383
  }
353
- api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
354
- var tr = _ref5.tr;
384
+ api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
385
+ var tr = _ref6.tr;
355
386
  (0, _closeTypeAhead.closeTypeAhead)(tr);
356
387
  config === null || config === void 0 || config.onClick({
357
388
  tr: tr
@@ -359,26 +390,25 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
359
390
  return tr;
360
391
  });
361
392
  };
362
- var renderRow = function renderRow(_ref6) {
363
- var index = _ref6.index,
364
- key = _ref6.key,
365
- style = _ref6.style,
366
- parent = _ref6.parent,
367
- isScrolling = _ref6.isScrolling,
368
- isVisible = _ref6.isVisible;
393
+ var renderRow = function renderRow(_ref7) {
394
+ var index = _ref7.index,
395
+ key = _ref7.key,
396
+ style = _ref7.style,
397
+ parent = _ref7.parent,
398
+ isScrolling = _ref7.isScrolling,
399
+ isVisible = _ref7.isVisible;
369
400
  var currentRow = listRows[index];
370
401
  if (!currentRow) {
371
402
  return null;
372
403
  }
373
- var shouldHideSingleSectionTitle = currentRow.type === 'section' && populatedSectionCount === 1 && !currentRow.section.showTitleWhenOnlySection;
374
404
  return (0, _react2.jsx)(_CellMeasurer.CellMeasurer, {
375
405
  key: key,
376
406
  cache: cache,
377
407
  parent: parent,
378
408
  columnIndex: 0,
379
409
  rowIndex: index
380
- }, function (_ref7) {
381
- var measure = _ref7.measure;
410
+ }, function (_ref8) {
411
+ var measure = _ref8.measure;
382
412
  return (0, _react2.jsx)(_ListRow.ListRow, {
383
413
  measure: measure,
384
414
  index: index
@@ -392,10 +422,7 @@ var TypeAheadListComponent = /*#__PURE__*/_react.default.memo(function (_ref3) {
392
422
  onMouseMove: function onMouseMove(e) {
393
423
  return _onMouseMove(e, currentRow);
394
424
  }
395
- }, currentRow.type === 'section' ?
396
- // Preserve the existing collapsed-title behaviour for single-section results unless
397
- // the gated section title API explicitly asks for the title to remain visible.
398
- shouldHideSingleSectionTitle ? null : (0, _react2.jsx)(_compiled.Box, {
425
+ }, currentRow.type === 'section' ? (0, _react2.jsx)(_compiled.Box, {
399
426
  paddingInline: "space.150",
400
427
  paddingBlock: "space.050"
401
428
  }, (0, _react2.jsx)(_compiled.Text, {
@@ -351,6 +351,7 @@ var TypeAheadPopup = exports.TypeAheadPopup = /*#__PURE__*/_react.default.memo(f
351
351
  triggerHandler: triggerHandler
352
352
  }), (0, _react2.jsx)(_TypeAheadList.TypeAheadList, {
353
353
  items: items,
354
+ isEmptyQuery: isEmptyQuery,
354
355
  sections: sections,
355
356
  emptyItem: emptyItem,
356
357
  selectedIndex: selectedIndex
@@ -6,7 +6,7 @@ Object.defineProperty(exports, "__esModule", {
6
6
  });
7
7
  exports.buildSectionedResult = void 0;
8
8
  var _toConsumableArray2 = _interopRequireDefault(require("@babel/runtime/helpers/toConsumableArray"));
9
- var _experiments = require("@atlaskit/tmp-editor-statsig/experiments");
9
+ var _expVal = require("@atlaskit/tmp-editor-statsig/expVal");
10
10
  function _createForOfIteratorHelper(r, e) { var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"]; if (!t) { if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e && r && "number" == typeof r.length) { t && (r = t); var _n = 0, F = function F() {}; return { s: F, n: function n() { return _n >= r.length ? { done: !0 } : { done: !1, value: r[_n++] }; }, e: function e(r) { throw r; }, f: F }; } throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); } var o, a = !0, u = !1; return { s: function s() { t = t.call(r); }, n: function n() { var r = t.next(); return a = r.done, r; }, e: function e(r) { u = !0, o = r; }, f: function f() { try { a || null == t.return || t.return(); } finally { if (u) throw o; } } }; }
11
11
  function _unsupportedIterableToArray(r, a) { if (r) { if ("string" == typeof r) return _arrayLikeToArray(r, a); var t = {}.toString.call(r).slice(8, -1); return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0; } }
12
12
  function _arrayLikeToArray(r, a) { (null == a || a > r.length) && (a = r.length); for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e]; return n; }
@@ -15,7 +15,7 @@ var buildSectionedResult = exports.buildSectionedResult = function buildSectione
15
15
  var items = _ref.items,
16
16
  triggerHandler = _ref.triggerHandler,
17
17
  intl = _ref.intl;
18
- if (!(0, _experiments.editorExperiment)('platform_editor_agent_mentions', true) || !intl) {
18
+ if (!(0, _expVal.expVal)('platform_editor_agent_mentions', 'isEnabled', false) || !intl) {
19
19
  return {
20
20
  items: items,
21
21
  sections: []
@@ -105,12 +105,16 @@ var buildSectionedResult = exports.buildSectionedResult = function buildSectione
105
105
  return items[i];
106
106
  })));
107
107
  var endIndex = flattenedItems.length - 1;
108
- sections.push({
108
+ var resolvedSection = {
109
109
  endIndex: endIndex,
110
110
  id: _section.id,
111
111
  startIndex: startIndex,
112
112
  title: _section.title
113
- });
113
+ };
114
+ if (_section.sectionTitleDisplay) {
115
+ resolvedSection.sectionTitleDisplay = _section.sectionTitleDisplay;
116
+ }
117
+ sections.push(resolvedSection);
114
118
  }
115
119
 
116
120
  // Append items not claimed by any section and not excluded by a limit
@@ -4,7 +4,7 @@ import { pluginKey as typeAheadPluginKey } from '../key';
4
4
  export const updateSectionTitle = ({
5
5
  id,
6
6
  title,
7
- showTitleWhenOnlySection
7
+ sectionTitleDisplay
8
8
  }) => {
9
9
  return (state, dispatch) => {
10
10
  if (!expVal('platform_editor_agent_mentions', 'isEnabled', false) || !dispatch) {
@@ -12,11 +12,11 @@ export const updateSectionTitle = ({
12
12
  }
13
13
  const tr = state.tr;
14
14
  const update = {
15
- title,
16
- ...(showTitleWhenOnlySection !== undefined ? {
17
- showTitleWhenOnlySection
18
- } : {})
15
+ title
19
16
  };
17
+ if (sectionTitleDisplay !== undefined) {
18
+ update.sectionTitleDisplay = sectionTitleDisplay;
19
+ }
20
20
  tr.setMeta(typeAheadPluginKey, {
21
21
  action: ACTIONS.UPDATE_SECTION_TITLE,
22
22
  params: {
@@ -17,7 +17,7 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
17
17
  import { MenuGroup } from '@atlaskit/menu';
18
18
  import { Text, Box } from '@atlaskit/primitives/compiled';
19
19
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
20
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
20
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
21
21
  import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
22
22
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
23
23
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
@@ -33,7 +33,33 @@ const list = css({
33
33
  padding: `${"var(--ds-space-100, 8px)"} ${"var(--ds-space-150, 12px)"}`
34
34
  }
35
35
  });
36
+ /**
37
+ * Resolves section title visibility before rows are built so hidden titles do not
38
+ * occupy virtualized list rows. A single populated section keeps the existing
39
+ * no-title behaviour unless it opts in with `showWhenOnlySection`; multiple
40
+ * populated sections show titles by default. `showWhenQueryPresent: false`
41
+ * takes precedence once the query is non-empty.
42
+ */
43
+ const shouldRenderSectionTitle = ({
44
+ isEmptyQuery,
45
+ populatedSectionCount,
46
+ section
47
+ }) => {
48
+ var _section$sectionTitle;
49
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
50
+ return populatedSectionCount > 1;
51
+ }
52
+ if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
53
+ return false;
54
+ }
55
+ if (populatedSectionCount === 1) {
56
+ var _section$sectionTitle2;
57
+ return ((_section$sectionTitle2 = section.sectionTitleDisplay) === null || _section$sectionTitle2 === void 0 ? void 0 : _section$sectionTitle2.showWhenOnlySection) === true;
58
+ }
59
+ return true;
60
+ };
36
61
  export const buildTypeAheadRows = ({
62
+ isEmptyQuery,
37
63
  itemsLength,
38
64
  sections
39
65
  }) => {
@@ -48,13 +74,21 @@ export const buildTypeAheadRows = ({
48
74
  const sortedSections = [...sections].sort((left, right) => left.startIndex - right.startIndex);
49
75
  const sectionsByStartIndex = new Map(sortedSections.map(section => [section.startIndex, section]));
50
76
  const rows = [];
77
+ const populatedSectionCount = sortedSections.length;
51
78
  for (let itemIndex = 0; itemIndex < itemsLength; itemIndex++) {
52
79
  const section = sectionsByStartIndex.get(itemIndex);
53
80
  if (section) {
54
- rows.push({
55
- type: 'section',
81
+ const shouldRenderTitle = shouldRenderSectionTitle({
82
+ isEmptyQuery,
83
+ populatedSectionCount,
56
84
  section
57
85
  });
86
+ if (shouldRenderTitle) {
87
+ rows.push({
88
+ type: 'section',
89
+ section
90
+ });
91
+ }
58
92
  }
59
93
  rows.push({
60
94
  type: 'item',
@@ -82,6 +116,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
82
116
  sections,
83
117
  emptyItem,
84
118
  selectedIndex,
119
+ isEmptyQuery = true,
85
120
  editorView,
86
121
  onItemClick,
87
122
  intl,
@@ -115,9 +150,10 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
115
150
  defaultHeight: LIST_ITEM_ESTIMATED_HEIGHT
116
151
  }));
117
152
  const listRows = useMemo(() => buildTypeAheadRows({
153
+ isEmptyQuery,
118
154
  itemsLength,
119
155
  sections: sections || []
120
- }), [itemsLength, sections]);
156
+ }), [isEmptyQuery, itemsLength, sections]);
121
157
  const itemRowIndexByItemIndex = useMemo(() => {
122
158
  const rowIndexByItemIndex = new Map();
123
159
  listRows.forEach((row, rowIndex) => {
@@ -128,7 +164,6 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
128
164
  return rowIndexByItemIndex;
129
165
  }, [listRows]);
130
166
  const selectedItemRowIndex = selectedIndex >= 0 ? (_itemRowIndexByItemIn = itemRowIndexByItemIndex.get(selectedIndex)) !== null && _itemRowIndexByItemIn !== void 0 ? _itemRowIndexByItemIn : -1 : -1;
131
- const populatedSectionCount = useMemo(() => listRows.filter(row => row.type === 'section').length, [listRows]);
132
167
  const onItemsRendered = useCallback(props => {
133
168
  lastVisibleIndexes.current = props;
134
169
  }, []);
@@ -247,7 +282,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
247
282
  }, [items, sections]);
248
283
  useLayoutEffect(() => {
249
284
  // Exclude view more item from the count
250
- const itemsToRender = editorExperiment('platform_editor_agent_mentions', true) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
285
+ const itemsToRender = expVal('platform_editor_agent_mentions', 'isEnabled', false) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
251
286
  const height = Math.min(
252
287
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
253
288
  itemsToRender.reduce((prevValue, currentValue, index) => {
@@ -341,7 +376,6 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
341
376
  if (!currentRow) {
342
377
  return null;
343
378
  }
344
- const shouldHideSingleSectionTitle = currentRow.type === 'section' && populatedSectionCount === 1 && !currentRow.section.showTitleWhenOnlySection;
345
379
  return jsx(CellMeasurer, {
346
380
  key: key,
347
381
  cache: cache,
@@ -361,10 +395,7 @@ const TypeAheadListComponent = /*#__PURE__*/React.memo(({
361
395
  // eslint-disable-next-line @atlassian/perf-linting/no-unstable-inline-props -- Ignored via go/ees017 (to be fixed)
362
396
  ,
363
397
  onMouseMove: e => onMouseMove(e, currentRow)
364
- }, currentRow.type === 'section' ?
365
- // Preserve the existing collapsed-title behaviour for single-section results unless
366
- // the gated section title API explicitly asks for the title to remain visible.
367
- shouldHideSingleSectionTitle ? null : jsx(Box, {
398
+ }, currentRow.type === 'section' ? jsx(Box, {
368
399
  paddingInline: "space.150",
369
400
  paddingBlock: "space.050"
370
401
  }, jsx(Text, {
@@ -346,6 +346,7 @@ export const TypeAheadPopup = /*#__PURE__*/React.memo(props => {
346
346
  triggerHandler: triggerHandler
347
347
  }), jsx(TypeAheadList, {
348
348
  items: items,
349
+ isEmptyQuery: isEmptyQuery,
349
350
  sections: sections,
350
351
  emptyItem: emptyItem,
351
352
  selectedIndex: selectedIndex
@@ -1,11 +1,11 @@
1
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
1
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
2
2
  export const buildSectionedResult = ({
3
3
  items,
4
4
  triggerHandler,
5
5
  intl
6
6
  }) => {
7
7
  var _triggerHandler$getSe;
8
- if (!editorExperiment('platform_editor_agent_mentions', true) || !intl) {
8
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false) || !intl) {
9
9
  return {
10
10
  items,
11
11
  sections: []
@@ -62,12 +62,16 @@ export const buildSectionedResult = ({
62
62
  const startIndex = flattenedItems.length;
63
63
  flattenedItems.push(...grouped.indexes.map(i => items[i]));
64
64
  const endIndex = flattenedItems.length - 1;
65
- sections.push({
65
+ const resolvedSection = {
66
66
  endIndex,
67
67
  id: section.id,
68
68
  startIndex,
69
69
  title: section.title
70
- });
70
+ };
71
+ if (section.sectionTitleDisplay) {
72
+ resolvedSection.sectionTitleDisplay = section.sectionTitleDisplay;
73
+ }
74
+ sections.push(resolvedSection);
71
75
  }
72
76
 
73
77
  // Append items not claimed by any section and not excluded by a limit
@@ -1,23 +1,21 @@
1
- import _defineProperty from "@babel/runtime/helpers/defineProperty";
2
- function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
3
- function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
4
1
  import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
5
2
  import { ACTIONS } from '../actions';
6
3
  import { pluginKey as typeAheadPluginKey } from '../key';
7
4
  export var updateSectionTitle = function updateSectionTitle(_ref) {
8
5
  var id = _ref.id,
9
6
  title = _ref.title,
10
- showTitleWhenOnlySection = _ref.showTitleWhenOnlySection;
7
+ sectionTitleDisplay = _ref.sectionTitleDisplay;
11
8
  return function (state, dispatch) {
12
9
  if (!expVal('platform_editor_agent_mentions', 'isEnabled', false) || !dispatch) {
13
10
  return false;
14
11
  }
15
12
  var tr = state.tr;
16
- var update = _objectSpread({
13
+ var update = {
17
14
  title: title
18
- }, showTitleWhenOnlySection !== undefined ? {
19
- showTitleWhenOnlySection: showTitleWhenOnlySection
20
- } : {});
15
+ };
16
+ if (sectionTitleDisplay !== undefined) {
17
+ update.sectionTitleDisplay = sectionTitleDisplay;
18
+ }
21
19
  tr.setMeta(typeAheadPluginKey, {
22
20
  action: ACTIONS.UPDATE_SECTION_TITLE,
23
21
  params: {