@atlaskit/editor-plugin-type-ahead 11.3.6 → 12.0.1

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 CHANGED
@@ -1,5 +1,42 @@
1
1
  # @atlaskit/editor-plugin-type-ahead
2
2
 
3
+ ## 12.0.1
4
+
5
+ ### Patch Changes
6
+
7
+ - Updated dependencies
8
+
9
+ ## 12.0.0
10
+
11
+ ### Major Changes
12
+
13
+ - [`f2dc9097319f0`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/f2dc9097319f0) - ###
14
+ Dropped support for _legacy_ Typescript 4 types. **Typescript 5 is now the new minimum**.
15
+
16
+ Removes the `typesVersions` property and `dist/types-ts4.5` directory from the dist.
17
+
18
+ Types are now exclusively via the `"types": "dist/types/index.d.ts"` property.
19
+
20
+ ```diff
21
+ - "typesVersions": {
22
+ - ">=4.5 <4.9": {
23
+ - "*": [
24
+ - "dist/types-ts4.5/*",
25
+ - "dist/types-ts4.5/index.d.ts"
26
+ - ]
27
+ - }
28
+ - },
29
+ ```
30
+
31
+ ### Minor Changes
32
+
33
+ - [`78adaba64ee33`](https://bitbucket.org/atlassian/atlassian-frontend-monorepo/commits/78adaba64ee33) -
34
+ Add opt-in section title display controls for typeahead sections
35
+
36
+ ### Patch Changes
37
+
38
+ - Updated dependencies
39
+
3
40
  ## 11.3.6
4
41
 
5
42
  ### Patch Changes
@@ -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: {
@@ -19,7 +19,7 @@ import { AssistiveText } from '@atlaskit/editor-common/ui';
19
19
  import { MenuGroup } from '@atlaskit/menu';
20
20
  import { Text, Box } from '@atlaskit/primitives/compiled';
21
21
  import { expValEquals } from '@atlaskit/tmp-editor-statsig/exp-val-equals';
22
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
22
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
23
23
  import { closeTypeAhead } from '../pm-plugins/commands/close-type-ahead';
24
24
  import { updateSelectedIndex } from '../pm-plugins/commands/update-selected-index';
25
25
  import { TYPE_AHEAD_DECORATION_ELEMENT_ID } from '../pm-plugins/constants';
@@ -35,9 +35,34 @@ var list = css({
35
35
  padding: "var(--ds-space-100, 8px)".concat(" ", "var(--ds-space-150, 12px)")
36
36
  }
37
37
  });
38
- export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
39
- var itemsLength = _ref.itemsLength,
40
- sections = _ref.sections;
38
+ /**
39
+ * Resolves section title visibility before rows are built so hidden titles do not
40
+ * occupy virtualized list rows. A single populated section keeps the existing
41
+ * no-title behaviour unless it opts in with `showWhenOnlySection`; multiple
42
+ * populated sections show titles by default. `showWhenQueryPresent: false`
43
+ * takes precedence once the query is non-empty.
44
+ */
45
+ var shouldRenderSectionTitle = function shouldRenderSectionTitle(_ref) {
46
+ var _section$sectionTitle;
47
+ var isEmptyQuery = _ref.isEmptyQuery,
48
+ populatedSectionCount = _ref.populatedSectionCount,
49
+ section = _ref.section;
50
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false)) {
51
+ return populatedSectionCount > 1;
52
+ }
53
+ if (!isEmptyQuery && ((_section$sectionTitle = section.sectionTitleDisplay) === null || _section$sectionTitle === void 0 ? void 0 : _section$sectionTitle.showWhenQueryPresent) === false) {
54
+ return false;
55
+ }
56
+ if (populatedSectionCount === 1) {
57
+ var _section$sectionTitle2;
58
+ return ((_section$sectionTitle2 = section.sectionTitleDisplay) === null || _section$sectionTitle2 === void 0 ? void 0 : _section$sectionTitle2.showWhenOnlySection) === true;
59
+ }
60
+ return true;
61
+ };
62
+ export var buildTypeAheadRows = function buildTypeAheadRows(_ref2) {
63
+ var isEmptyQuery = _ref2.isEmptyQuery,
64
+ itemsLength = _ref2.itemsLength,
65
+ sections = _ref2.sections;
41
66
  if (sections.length === 0) {
42
67
  return Array.from({
43
68
  length: itemsLength
@@ -55,13 +80,21 @@ export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
55
80
  return [section.startIndex, section];
56
81
  }));
57
82
  var rows = [];
83
+ var populatedSectionCount = sortedSections.length;
58
84
  for (var itemIndex = 0; itemIndex < itemsLength; itemIndex++) {
59
85
  var section = sectionsByStartIndex.get(itemIndex);
60
86
  if (section) {
61
- rows.push({
62
- type: 'section',
87
+ var shouldRenderTitle = shouldRenderSectionTitle({
88
+ isEmptyQuery: isEmptyQuery,
89
+ populatedSectionCount: populatedSectionCount,
63
90
  section: section
64
91
  });
92
+ if (shouldRenderTitle) {
93
+ rows.push({
94
+ type: 'section',
95
+ section: section
96
+ });
97
+ }
65
98
  }
66
99
  rows.push({
67
100
  type: 'item',
@@ -70,8 +103,8 @@ export var buildTypeAheadRows = function buildTypeAheadRows(_ref) {
70
103
  }
71
104
  return rows;
72
105
  };
73
- var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref2) {
74
- var numberOfResults = _ref2.numberOfResults;
106
+ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref3) {
107
+ var numberOfResults = _ref3.numberOfResults;
75
108
  var intl = useIntl();
76
109
  return jsx(AssistiveText, {
77
110
  assistiveText: intl.formatMessage(typeAheadListMessages.searchResultsLabel, {
@@ -83,22 +116,24 @@ var TypeaheadAssistiveTextPureComponent = /*#__PURE__*/React.memo(function (_ref
83
116
  id: TYPE_AHEAD_DECORATION_ELEMENT_ID + '__popup'
84
117
  });
85
118
  });
86
- var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
119
+ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref4) {
87
120
  var _itemRowIndexByItemIn, _triggerHandler$getMo, _decorationElement$qu2;
88
- var items = _ref3.items,
89
- sections = _ref3.sections,
90
- emptyItem = _ref3.emptyItem,
91
- selectedIndex = _ref3.selectedIndex,
92
- editorView = _ref3.editorView,
93
- onItemClick = _ref3.onItemClick,
94
- intl = _ref3.intl,
95
- fitHeight = _ref3.fitHeight,
96
- decorationElement = _ref3.decorationElement,
97
- triggerHandler = _ref3.triggerHandler,
98
- moreElementsInQuickInsertViewEnabled = _ref3.moreElementsInQuickInsertViewEnabled,
99
- api = _ref3.api,
100
- showMoreOptionsButton = _ref3.showMoreOptionsButton,
101
- onMoreOptionsClicked = _ref3.onMoreOptionsClicked;
121
+ var items = _ref4.items,
122
+ sections = _ref4.sections,
123
+ emptyItem = _ref4.emptyItem,
124
+ selectedIndex = _ref4.selectedIndex,
125
+ _ref4$isEmptyQuery = _ref4.isEmptyQuery,
126
+ isEmptyQuery = _ref4$isEmptyQuery === void 0 ? true : _ref4$isEmptyQuery,
127
+ editorView = _ref4.editorView,
128
+ onItemClick = _ref4.onItemClick,
129
+ intl = _ref4.intl,
130
+ fitHeight = _ref4.fitHeight,
131
+ decorationElement = _ref4.decorationElement,
132
+ triggerHandler = _ref4.triggerHandler,
133
+ moreElementsInQuickInsertViewEnabled = _ref4.moreElementsInQuickInsertViewEnabled,
134
+ api = _ref4.api,
135
+ showMoreOptionsButton = _ref4.showMoreOptionsButton,
136
+ onMoreOptionsClicked = _ref4.onMoreOptionsClicked;
102
137
  var listRef = useRef();
103
138
  var listContainerRef = useRef(null);
104
139
  var lastInputMethodRef = useRef('keyboard');
@@ -127,10 +162,11 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
127
162
  setCache = _useState4[1];
128
163
  var listRows = useMemo(function () {
129
164
  return buildTypeAheadRows({
165
+ isEmptyQuery: isEmptyQuery,
130
166
  itemsLength: itemsLength,
131
167
  sections: sections || []
132
168
  });
133
- }, [itemsLength, sections]);
169
+ }, [isEmptyQuery, itemsLength, sections]);
134
170
  var itemRowIndexByItemIndex = useMemo(function () {
135
171
  var rowIndexByItemIndex = new Map();
136
172
  listRows.forEach(function (row, rowIndex) {
@@ -141,11 +177,6 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
141
177
  return rowIndexByItemIndex;
142
178
  }, [listRows]);
143
179
  var selectedItemRowIndex = selectedIndex >= 0 ? (_itemRowIndexByItemIn = itemRowIndexByItemIndex.get(selectedIndex)) !== null && _itemRowIndexByItemIn !== void 0 ? _itemRowIndexByItemIn : -1 : -1;
144
- var populatedSectionCount = useMemo(function () {
145
- return listRows.filter(function (row) {
146
- return row.type === 'section';
147
- }).length;
148
- }, [listRows]);
149
180
  var onItemsRendered = useCallback(function (props) {
150
181
  lastVisibleIndexes.current = props;
151
182
  }, []);
@@ -182,8 +213,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
182
213
  var lastVisibleStopIndex = lastVisibleIndexes.current.stopIndex;
183
214
  var onScroll = useCallback(
184
215
  // eslint-disable-next-line @typescript-eslint/no-explicit-any
185
- function (_ref4) {
186
- var scrollUpdateWasRequested = _ref4.scrollUpdateWasRequested;
216
+ function (_ref5) {
217
+ var scrollUpdateWasRequested = _ref5.scrollUpdateWasRequested;
187
218
  if (!scrollUpdateWasRequested) {
188
219
  return;
189
220
  }
@@ -269,7 +300,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
269
300
  }, [items, sections]);
270
301
  useLayoutEffect(function () {
271
302
  // Exclude view more item from the count
272
- var itemsToRender = editorExperiment('platform_editor_agent_mentions', true) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
303
+ var itemsToRender = expVal('platform_editor_agent_mentions', 'isEnabled', false) ? listRows : showMoreOptionsButton ? items.slice(0, -1) : items;
273
304
  var height = Math.min(
274
305
  // eslint-disable-next-line @atlassian/perf-linting/no-expensive-computations-in-render -- Ignored via go/ees017 (to be fixed)
275
306
  itemsToRender.reduce(function (prevValue, currentValue, index) {
@@ -341,8 +372,8 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
341
372
  if (onMoreOptionsClicked) {
342
373
  onMoreOptionsClicked();
343
374
  }
344
- api === null || api === void 0 || api.core.actions.execute(function (_ref5) {
345
- var tr = _ref5.tr;
375
+ api === null || api === void 0 || api.core.actions.execute(function (_ref6) {
376
+ var tr = _ref6.tr;
346
377
  closeTypeAhead(tr);
347
378
  config === null || config === void 0 || config.onClick({
348
379
  tr: tr
@@ -350,26 +381,25 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
350
381
  return tr;
351
382
  });
352
383
  };
353
- var renderRow = function renderRow(_ref6) {
354
- var index = _ref6.index,
355
- key = _ref6.key,
356
- style = _ref6.style,
357
- parent = _ref6.parent,
358
- isScrolling = _ref6.isScrolling,
359
- isVisible = _ref6.isVisible;
384
+ var renderRow = function renderRow(_ref7) {
385
+ var index = _ref7.index,
386
+ key = _ref7.key,
387
+ style = _ref7.style,
388
+ parent = _ref7.parent,
389
+ isScrolling = _ref7.isScrolling,
390
+ isVisible = _ref7.isVisible;
360
391
  var currentRow = listRows[index];
361
392
  if (!currentRow) {
362
393
  return null;
363
394
  }
364
- var shouldHideSingleSectionTitle = currentRow.type === 'section' && populatedSectionCount === 1 && !currentRow.section.showTitleWhenOnlySection;
365
395
  return jsx(CellMeasurer, {
366
396
  key: key,
367
397
  cache: cache,
368
398
  parent: parent,
369
399
  columnIndex: 0,
370
400
  rowIndex: index
371
- }, function (_ref7) {
372
- var measure = _ref7.measure;
401
+ }, function (_ref8) {
402
+ var measure = _ref8.measure;
373
403
  return jsx(ListRow, {
374
404
  measure: measure,
375
405
  index: index
@@ -383,10 +413,7 @@ var TypeAheadListComponent = /*#__PURE__*/React.memo(function (_ref3) {
383
413
  onMouseMove: function onMouseMove(e) {
384
414
  return _onMouseMove(e, currentRow);
385
415
  }
386
- }, currentRow.type === 'section' ?
387
- // Preserve the existing collapsed-title behaviour for single-section results unless
388
- // the gated section title API explicitly asks for the title to remain visible.
389
- shouldHideSingleSectionTitle ? null : jsx(Box, {
416
+ }, currentRow.type === 'section' ? jsx(Box, {
390
417
  paddingInline: "space.150",
391
418
  paddingBlock: "space.050"
392
419
  }, jsx(Text, {
@@ -341,6 +341,7 @@ export var TypeAheadPopup = /*#__PURE__*/React.memo(function (props) {
341
341
  triggerHandler: triggerHandler
342
342
  }), jsx(TypeAheadList, {
343
343
  items: items,
344
+ isEmptyQuery: isEmptyQuery,
344
345
  sections: sections,
345
346
  emptyItem: emptyItem,
346
347
  selectedIndex: selectedIndex
@@ -2,13 +2,13 @@ import _toConsumableArray from "@babel/runtime/helpers/toConsumableArray";
2
2
  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; } } }; }
3
3
  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; } }
4
4
  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; }
5
- import { editorExperiment } from '@atlaskit/tmp-editor-statsig/experiments';
5
+ import { expVal } from '@atlaskit/tmp-editor-statsig/expVal';
6
6
  export var buildSectionedResult = function buildSectionedResult(_ref) {
7
7
  var _triggerHandler$getSe;
8
8
  var items = _ref.items,
9
9
  triggerHandler = _ref.triggerHandler,
10
10
  intl = _ref.intl;
11
- if (!editorExperiment('platform_editor_agent_mentions', true) || !intl) {
11
+ if (!expVal('platform_editor_agent_mentions', 'isEnabled', false) || !intl) {
12
12
  return {
13
13
  items: items,
14
14
  sections: []
@@ -98,12 +98,16 @@ export var buildSectionedResult = function buildSectionedResult(_ref) {
98
98
  return items[i];
99
99
  })));
100
100
  var endIndex = flattenedItems.length - 1;
101
- sections.push({
101
+ var resolvedSection = {
102
102
  endIndex: endIndex,
103
103
  id: _section.id,
104
104
  startIndex: startIndex,
105
105
  title: _section.title
106
- });
106
+ };
107
+ if (_section.sectionTitleDisplay) {
108
+ resolvedSection.sectionTitleDisplay = _section.sectionTitleDisplay;
109
+ }
110
+ sections.push(resolvedSection);
107
111
  }
108
112
 
109
113
  // Append items not claimed by any section and not excluded by a limit
@@ -1,2 +1,2 @@
1
1
  import type { Command, TypeAheadSectionTitleUpdate } from '@atlaskit/editor-common/types';
2
- export declare const updateSectionTitle: ({ id, title, showTitleWhenOnlySection, }: TypeAheadSectionTitleUpdate) => Command;
2
+ export declare const updateSectionTitle: ({ id, title, sectionTitleDisplay, }: TypeAheadSectionTitleUpdate) => Command;
@@ -34,8 +34,8 @@ export type TypeAheadPlugin = NextEditorPlugin<'typeAhead', {
34
34
  /**
35
35
  * Updates the display title for an existing typeahead section in the current typeahead session.
36
36
  *
37
- * The optional `showTitleWhenOnlySection` flag keeps the title visible when this section is
38
- * the only populated section. It does not render titles for empty sections.
37
+ * Optional `sectionTitleDisplay` rules can control whether the title stays visible once
38
+ * there is a query, or keep the title visible when this section is the only populated section.
39
39
  */
40
40
  updateSectionTitle?: (props: TypeAheadSectionTitleUpdate) => boolean;
41
41
  };
@@ -1,6 +1,7 @@
1
1
  import type { INPUT_METHOD } from '@atlaskit/editor-common/analytics';
2
2
  import type { SelectItemMode } from '@atlaskit/editor-common/type-ahead';
3
3
  import type { TypeAheadHandler, TypeAheadItem, TypeAheadStats, UiComponentFactoryParams } from '@atlaskit/editor-common/types';
4
+ import type { TypeAheadSectionTitleDisplay } from '@atlaskit/editor-common/types/type-ahead';
4
5
  import type { EditorState, ReadonlyTransaction, Transaction } from '@atlaskit/editor-prosemirror/state';
5
6
  import type { DecorationSet } from '@atlaskit/editor-prosemirror/view';
6
7
  export type { TypeAheadHandler } from '@atlaskit/editor-common/types';
@@ -24,7 +25,7 @@ export interface TypeAheadStatsMobileModifier extends TypeAheadStatsSerializable
24
25
  closeTime: () => void;
25
26
  resetTime: () => void;
26
27
  }
27
- export type TypeAheadSectionTitleUpdateState = Pick<TypeAheadResolvedSection, 'showTitleWhenOnlySection' | 'title'>;
28
+ export type TypeAheadSectionTitleUpdateState = Pick<TypeAheadResolvedSection, 'sectionTitleDisplay' | 'title'>;
28
29
  export type TypeAheadPluginState = {
29
30
  decorationElement: HTMLElement | null;
30
31
  decorationSet: DecorationSet;
@@ -47,10 +48,9 @@ export type TypeAheadResolvedSection = {
47
48
  endIndex: number;
48
49
  id: string;
49
50
  /**
50
- * Keeps this section's title visible when it is the only section with matching items.
51
- * Does not render the title for an empty section.
51
+ * Section title display rules copied from the section definition and optional runtime updates.
52
52
  */
53
- showTitleWhenOnlySection?: boolean;
53
+ sectionTitleDisplay?: TypeAheadSectionTitleDisplay;
54
54
  startIndex: number;
55
55
  title: string;
56
56
  };
@@ -17,7 +17,8 @@ type TypeAheadRowEntry = {
17
17
  itemIndex: number;
18
18
  type: 'item';
19
19
  };
20
- export declare const buildTypeAheadRows: ({ itemsLength, sections, }: {
20
+ export declare const buildTypeAheadRows: ({ isEmptyQuery, itemsLength, sections, }: {
21
+ isEmptyQuery: boolean;
21
22
  itemsLength: number;
22
23
  sections: Array<TypeAheadResolvedSection>;
23
24
  }) => Array<TypeAheadRowEntry>;
@@ -27,6 +28,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
27
28
  editorView: EditorView;
28
29
  emptyItem?: TypeAheadItem;
29
30
  fitHeight: number;
31
+ isEmptyQuery?: boolean;
30
32
  items: Array<TypeAheadItem>;
31
33
  moreElementsInQuickInsertViewEnabled?: boolean;
32
34
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
@@ -42,6 +44,7 @@ export declare const TypeAheadList: React.FC<WithIntlProps<{
42
44
  editorView: EditorView;
43
45
  emptyItem?: TypeAheadItem;
44
46
  fitHeight: number;
47
+ isEmptyQuery?: boolean;
45
48
  items: Array<TypeAheadItem>;
46
49
  moreElementsInQuickInsertViewEnabled?: boolean;
47
50
  onItemClick: (mode: SelectItemMode, index: number, inputMethod?: InputMethodType) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atlaskit/editor-plugin-type-ahead",
3
- "version": "11.3.6",
3
+ "version": "12.0.1",
4
4
  "description": "Type-ahead plugin for @atlaskit/editor-core",
5
5
  "author": "Atlassian Pty Ltd",
6
6
  "license": "Apache-2.0",
@@ -16,37 +16,29 @@
16
16
  "module": "dist/esm/index.js",
17
17
  "module:es2019": "dist/es2019/index.js",
18
18
  "types": "dist/types/index.d.ts",
19
- "typesVersions": {
20
- ">=4.5 <4.9": {
21
- "*": [
22
- "dist/types-ts4.5/*",
23
- "dist/types-ts4.5/index.d.ts"
24
- ]
25
- }
26
- },
27
19
  "sideEffects": [
28
20
  "*.compiled.css"
29
21
  ],
30
22
  "atlaskit:src": "src/index.ts",
31
23
  "dependencies": {
32
- "@atlaskit/adf-schema": "^54.0.0",
33
- "@atlaskit/editor-plugin-analytics": "^11.0.0",
34
- "@atlaskit/editor-plugin-connectivity": "^11.0.0",
35
- "@atlaskit/editor-plugin-context-panel": "^13.0.0",
36
- "@atlaskit/editor-plugin-metrics": "^12.0.0",
37
- "@atlaskit/editor-prosemirror": "^7.3.0",
38
- "@atlaskit/editor-shared-styles": "^3.11.0",
39
- "@atlaskit/feature-gate-js-client": "^5.8.0",
40
- "@atlaskit/heading": "^5.4.0",
41
- "@atlaskit/insm": "^0.4.0",
42
- "@atlaskit/menu": "^8.5.0",
43
- "@atlaskit/platform-feature-flags": "^1.1.0",
44
- "@atlaskit/primitives": "^19.0.0",
45
- "@atlaskit/prosemirror-history": "^0.2.0",
46
- "@atlaskit/prosemirror-input-rules": "^3.7.0",
47
- "@atlaskit/tmp-editor-statsig": "^103.0.0",
48
- "@atlaskit/tokens": "^13.4.0",
49
- "@atlaskit/visually-hidden": "^3.1.0",
24
+ "@atlaskit/adf-schema": "^55.0.0",
25
+ "@atlaskit/editor-plugin-analytics": "^12.0.0",
26
+ "@atlaskit/editor-plugin-connectivity": "^12.0.0",
27
+ "@atlaskit/editor-plugin-context-panel": "^14.0.0",
28
+ "@atlaskit/editor-plugin-metrics": "^13.0.0",
29
+ "@atlaskit/editor-prosemirror": "^8.0.0",
30
+ "@atlaskit/editor-shared-styles": "^4.0.0",
31
+ "@atlaskit/feature-gate-js-client": "^6.0.0",
32
+ "@atlaskit/heading": "^6.0.0",
33
+ "@atlaskit/insm": "^1.0.0",
34
+ "@atlaskit/menu": "^9.0.0",
35
+ "@atlaskit/platform-feature-flags": "^2.0.0",
36
+ "@atlaskit/primitives": "^20.0.0",
37
+ "@atlaskit/prosemirror-history": "^1.0.0",
38
+ "@atlaskit/prosemirror-input-rules": "^4.0.0",
39
+ "@atlaskit/tmp-editor-statsig": "^105.0.0",
40
+ "@atlaskit/tokens": "^14.0.0",
41
+ "@atlaskit/visually-hidden": "^4.0.0",
50
42
  "@babel/runtime": "^7.0.0",
51
43
  "@emotion/react": "^11.7.1",
52
44
  "lodash": "^4.17.21",
@@ -56,7 +48,7 @@
56
48
  "w3c-keyname": "^2.1.8"
57
49
  },
58
50
  "peerDependencies": {
59
- "@atlaskit/editor-common": "^115.15.0",
51
+ "@atlaskit/editor-common": "^116.1.0",
60
52
  "react": "^18.2.0",
61
53
  "react-dom": "^18.2.0",
62
54
  "react-intl": "^5.25.1 || ^6.0.0 || ^7.0.0"