@atlaskit/editor-plugin-quick-insert 29.0.4 → 30.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 +24 -0
- package/dist/cjs/quickInsertPlugin.js +10 -5
- package/dist/cjs/ui/QuickInsertRecommendedSlot.js +11 -8
- package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowser.js +31 -7
- package/dist/cjs/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +13 -7
- package/dist/cjs/ui/RegistryElementBrowser/model.js +31 -18
- package/dist/cjs/ui/getQuickInsertComponents.js +28 -16
- package/dist/cjs/ui/getRecommendedComponents.js +2 -2
- package/dist/cjs/ui/registered-menu/QuickInsertEmptyState.compiled.css +11 -0
- package/dist/cjs/ui/registered-menu/QuickInsertEmptyState.js +61 -0
- package/dist/cjs/ui/registered-menu/QuickInsertMenuRoot.js +220 -0
- package/dist/cjs/ui/registered-menu/QuickInsertMenuSection.js +23 -0
- package/dist/cjs/ui/registered-menu/QuickInsertSearchResultsSection.js +19 -0
- package/dist/cjs/ui/registered-menu/RegisteredQuickInsertMenuItem.js +42 -0
- package/dist/cjs/ui/registered-menu/ToolbarQuickInsertMenu.compiled.css +11 -0
- package/dist/cjs/ui/registered-menu/ToolbarQuickInsertMenu.js +128 -0
- package/dist/cjs/ui/registered-menu/TypeAheadQuickInsertMenu.compiled.css +3 -0
- package/dist/cjs/ui/registered-menu/TypeAheadQuickInsertMenu.js +90 -0
- package/dist/cjs/ui/registered-menu/assets/no-results.js +36 -0
- package/dist/cjs/ui/registered-menu/get-quick-insert-menu-model.js +254 -0
- package/dist/cjs/ui/registered-menu/getQuickInsertMenuItemId.js +9 -0
- package/dist/cjs/ui/registered-menu/selectQuickInsertCategoryItems.js +27 -0
- package/dist/cjs/ui/registered-menu/useQuickInsertSearchAnalytics.js +100 -0
- package/dist/es2019/quickInsertPlugin.js +10 -5
- package/dist/es2019/ui/QuickInsertRecommendedSlot.js +10 -5
- package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowser.js +19 -2
- package/dist/es2019/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +12 -7
- package/dist/es2019/ui/RegistryElementBrowser/model.js +27 -16
- package/dist/es2019/ui/getQuickInsertComponents.js +24 -10
- package/dist/es2019/ui/getRecommendedComponents.js +2 -2
- package/dist/es2019/ui/registered-menu/QuickInsertEmptyState.compiled.css +11 -0
- package/dist/es2019/ui/registered-menu/QuickInsertEmptyState.js +47 -0
- package/dist/es2019/ui/registered-menu/QuickInsertMenuRoot.js +191 -0
- package/dist/es2019/ui/registered-menu/QuickInsertMenuSection.js +15 -0
- package/dist/es2019/ui/registered-menu/QuickInsertSearchResultsSection.js +14 -0
- package/dist/es2019/ui/registered-menu/RegisteredQuickInsertMenuItem.js +34 -0
- package/dist/es2019/ui/registered-menu/ToolbarQuickInsertMenu.compiled.css +11 -0
- package/dist/es2019/ui/registered-menu/ToolbarQuickInsertMenu.js +116 -0
- package/dist/es2019/ui/registered-menu/TypeAheadQuickInsertMenu.compiled.css +3 -0
- package/dist/es2019/ui/registered-menu/TypeAheadQuickInsertMenu.js +78 -0
- package/dist/es2019/ui/registered-menu/assets/no-results.js +30 -0
- package/dist/es2019/ui/registered-menu/get-quick-insert-menu-model.js +191 -0
- package/dist/es2019/ui/registered-menu/getQuickInsertMenuItemId.js +1 -0
- package/dist/es2019/ui/registered-menu/selectQuickInsertCategoryItems.js +19 -0
- package/dist/es2019/ui/registered-menu/useQuickInsertSearchAnalytics.js +91 -0
- package/dist/esm/quickInsertPlugin.js +10 -5
- package/dist/esm/ui/QuickInsertRecommendedSlot.js +11 -8
- package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowser.js +30 -6
- package/dist/esm/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.js +12 -7
- package/dist/esm/ui/RegistryElementBrowser/model.js +31 -18
- package/dist/esm/ui/getQuickInsertComponents.js +27 -15
- package/dist/esm/ui/getRecommendedComponents.js +2 -2
- package/dist/esm/ui/registered-menu/QuickInsertEmptyState.compiled.css +11 -0
- package/dist/esm/ui/registered-menu/QuickInsertEmptyState.js +50 -0
- package/dist/esm/ui/registered-menu/QuickInsertMenuRoot.js +211 -0
- package/dist/esm/ui/registered-menu/QuickInsertMenuSection.js +16 -0
- package/dist/esm/ui/registered-menu/QuickInsertSearchResultsSection.js +12 -0
- package/dist/esm/ui/registered-menu/RegisteredQuickInsertMenuItem.js +34 -0
- package/dist/esm/ui/registered-menu/ToolbarQuickInsertMenu.compiled.css +11 -0
- package/dist/esm/ui/registered-menu/ToolbarQuickInsertMenu.js +120 -0
- package/dist/esm/ui/registered-menu/TypeAheadQuickInsertMenu.compiled.css +3 -0
- package/dist/esm/ui/registered-menu/TypeAheadQuickInsertMenu.js +82 -0
- package/dist/esm/ui/registered-menu/assets/no-results.js +29 -0
- package/dist/esm/ui/registered-menu/get-quick-insert-menu-model.js +247 -0
- package/dist/esm/ui/registered-menu/getQuickInsertMenuItemId.js +3 -0
- package/dist/esm/ui/registered-menu/selectQuickInsertCategoryItems.js +21 -0
- package/dist/esm/ui/registered-menu/useQuickInsertSearchAnalytics.js +93 -0
- package/dist/types/quickInsertPluginType.d.ts +1 -1
- package/dist/types/ui/QuickInsertRecommendedSlot.d.ts +3 -3
- package/dist/types/ui/RegistryElementBrowser/RegistryElementBrowserSearchResults.d.ts +5 -2
- package/dist/types/ui/RegistryElementBrowser/model.d.ts +3 -2
- package/dist/types/ui/getQuickInsertComponents.d.ts +8 -2
- package/dist/types/ui/registered-menu/QuickInsertEmptyState.d.ts +7 -0
- package/dist/types/ui/registered-menu/QuickInsertMenuRoot.d.ts +11 -0
- package/dist/types/ui/registered-menu/QuickInsertMenuSection.d.ts +4 -0
- package/dist/types/ui/registered-menu/QuickInsertSearchResultsSection.d.ts +2 -0
- package/dist/types/ui/registered-menu/RegisteredQuickInsertMenuItem.d.ts +3 -0
- package/dist/types/ui/registered-menu/ToolbarQuickInsertMenu.d.ts +28 -0
- package/dist/types/ui/registered-menu/TypeAheadQuickInsertMenu.d.ts +27 -0
- package/dist/types/ui/registered-menu/assets/no-results.d.ts +7 -0
- package/dist/types/ui/registered-menu/get-quick-insert-menu-model.d.ts +19 -0
- package/dist/types/ui/registered-menu/getQuickInsertMenuItemId.d.ts +1 -0
- package/dist/types/ui/registered-menu/selectQuickInsertCategoryItems.d.ts +7 -0
- package/dist/types/ui/registered-menu/useQuickInsertSearchAnalytics.d.ts +12 -0
- package/package.json +15 -12
- package/registered-menu/model/package.json +10 -0
- package/registered-menu/search-analytics/package.json +10 -0
|
@@ -10,19 +10,17 @@ const compareRanks = (left, right) => {
|
|
|
10
10
|
}
|
|
11
11
|
return 0;
|
|
12
12
|
};
|
|
13
|
-
const
|
|
14
|
-
var
|
|
15
|
-
return ((
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
var _component$parents;
|
|
19
|
-
return isVisible(component) && ((_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : _component$parents.some(parent => parent.key === parentKey));
|
|
13
|
+
const getChildren = (components, parentKey, surfaceContext) => components.filter(component => {
|
|
14
|
+
var _component$parents, _component$isHidden;
|
|
15
|
+
return ((_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : _component$parents.some(parent => parent.key === parentKey)) && ((_component$isHidden = component.isHidden) === null || _component$isHidden === void 0 ? void 0 : _component$isHidden.call(component, {
|
|
16
|
+
surfaceContext
|
|
17
|
+
})) !== true;
|
|
20
18
|
});
|
|
21
19
|
const getParentRank = (registration, parentKey) => {
|
|
22
20
|
var _registration$parents, _registration$parents2, _registration$parents3;
|
|
23
21
|
return (_registration$parents = (_registration$parents2 = registration.parents) === null || _registration$parents2 === void 0 ? void 0 : (_registration$parents3 = _registration$parents2.find(parent => parent.key === parentKey)) === null || _registration$parents3 === void 0 ? void 0 : _registration$parents3.rank) !== null && _registration$parents !== void 0 ? _registration$parents : Number.MAX_SAFE_INTEGER;
|
|
24
22
|
};
|
|
25
|
-
const getDescendantItems = (components, parentKey, ancestorRanks, sectionKey) => getChildren(components, parentKey).flatMap(component => {
|
|
23
|
+
const getDescendantItems = (components, parentKey, ancestorRanks, sectionKey, surfaceContext) => getChildren(components, parentKey, surfaceContext).flatMap(component => {
|
|
26
24
|
const ranks = [...ancestorRanks, getParentRank(component, parentKey)];
|
|
27
25
|
if (component.type === 'menu-item') {
|
|
28
26
|
return component.component ? [{
|
|
@@ -31,7 +29,7 @@ const getDescendantItems = (components, parentKey, ancestorRanks, sectionKey) =>
|
|
|
31
29
|
sectionKeys: [sectionKey]
|
|
32
30
|
}] : [];
|
|
33
31
|
}
|
|
34
|
-
return getDescendantItems(components, component.key, ranks, sectionKey);
|
|
32
|
+
return getDescendantItems(components, component.key, ranks, sectionKey, surfaceContext);
|
|
35
33
|
});
|
|
36
34
|
|
|
37
35
|
/**
|
|
@@ -42,17 +40,18 @@ export const createRegistryElementBrowserModel = (components, {
|
|
|
42
40
|
footerKey,
|
|
43
41
|
overflowKeys,
|
|
44
42
|
recommendedSectionKey,
|
|
45
|
-
rootKey
|
|
43
|
+
rootKey,
|
|
44
|
+
surfaceContext
|
|
46
45
|
}) => {
|
|
47
46
|
const excludedKeys = new Set([footerKey, recommendedSectionKey, ...overflowKeys]);
|
|
48
|
-
const visibleComponents = components.filter(component =>
|
|
49
|
-
const sections = getChildren(visibleComponents, rootKey).filter(component => component.type === 'menu-section').map(section => ({
|
|
47
|
+
const visibleComponents = components.filter(component => !excludedKeys.has(component.key));
|
|
48
|
+
const sections = getChildren(visibleComponents, rootKey, surfaceContext).filter(component => component.type === 'menu-section').map(section => ({
|
|
50
49
|
key: section.key,
|
|
51
50
|
rank: getParentRank(section, rootKey)
|
|
52
51
|
})).sort((left, right) => left.rank - right.rank);
|
|
53
52
|
const itemByKey = new Map();
|
|
54
53
|
sections.forEach(section => {
|
|
55
|
-
getDescendantItems(visibleComponents, section.key, [section.rank], section.key).forEach(item => {
|
|
54
|
+
getDescendantItems(visibleComponents, section.key, [section.rank], section.key, surfaceContext).forEach(item => {
|
|
56
55
|
const existing = itemByKey.get(item.registration.key);
|
|
57
56
|
if (!existing) {
|
|
58
57
|
itemByKey.set(item.registration.key, item);
|
|
@@ -97,18 +96,30 @@ export const getRegistryElementBrowserItems = ({
|
|
|
97
96
|
if (!normalizedQuery) {
|
|
98
97
|
return itemsWithDescriptions;
|
|
99
98
|
}
|
|
100
|
-
|
|
99
|
+
const matches = itemsWithDescriptions.flatMap(item => {
|
|
101
100
|
var _item$registration$ma, _item$registration;
|
|
102
101
|
const result = (_item$registration$ma = (_item$registration = item.registration).match) === null || _item$registration$ma === void 0 ? void 0 : _item$registration$ma.call(_item$registration, {
|
|
103
102
|
formatMessage,
|
|
103
|
+
itemKey: item.registration.key,
|
|
104
104
|
query: normalizedQuery
|
|
105
105
|
});
|
|
106
106
|
return result ? [{
|
|
107
107
|
...item,
|
|
108
|
+
priorityGroup: result.priorityGroup !== undefined && Number.isFinite(result.priorityGroup) ? result.priorityGroup : undefined,
|
|
108
109
|
score: Math.min(1, Math.max(0, result.score))
|
|
109
110
|
}] : [];
|
|
110
|
-
})
|
|
111
|
+
});
|
|
112
|
+
const prioritized = matches.filter(({
|
|
113
|
+
priorityGroup
|
|
114
|
+
}) => priorityGroup !== undefined);
|
|
115
|
+
const unprioritized = matches.filter(({
|
|
116
|
+
priorityGroup
|
|
117
|
+
}) => priorityGroup === undefined);
|
|
118
|
+
return [...prioritized.sort((left, right) => {
|
|
119
|
+
var _right$priorityGroup, _left$priorityGroup;
|
|
120
|
+
return ((_right$priorityGroup = right.priorityGroup) !== null && _right$priorityGroup !== void 0 ? _right$priorityGroup : 0) - ((_left$priorityGroup = left.priorityGroup) !== null && _left$priorityGroup !== void 0 ? _left$priorityGroup : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
121
|
+
}), ...unprioritized.sort((left, right) => {
|
|
111
122
|
var _left$ranks$, _right$ranks$;
|
|
112
123
|
return ((_left$ranks$ = left.ranks[0]) !== null && _left$ranks$ !== void 0 ? _left$ranks$ : 0) - ((_right$ranks$ = right.ranks[0]) !== null && _right$ranks$ !== void 0 ? _right$ranks$ : 0) || left.score - right.score || compareRanks(left.ranks, right.ranks) || left.registration.key.localeCompare(right.registration.key);
|
|
113
|
-
});
|
|
124
|
+
})];
|
|
114
125
|
};
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { useIntl } from 'react-intl';
|
|
3
3
|
import { BLOCK_TEMPLATES_SECTION, CREATE_SECTION, DATA_AND_CHARTS_SECTION, EMBED_SECTION, MEDIA_SECTION, MENU, OTHER_SECTION, RECOMMENDED_SECTION, ROVO_SECTION, STRUCTURE_SECTION, TEXT_FORMATTING_SECTION, VIEW_ALL_ELEMENTS_MENU_ITEM } from '@atlaskit/editor-common/quick-insert/keys';
|
|
4
|
-
import { QuickInsertMenuRoot } from '@atlaskit/editor-common/quick-insert/menu-root';
|
|
5
|
-
import { QuickInsertMenuSection } from '@atlaskit/editor-common/quick-insert/menu-section';
|
|
6
4
|
import { messages } from '@atlaskit/editor-common/quick-insert/messages';
|
|
7
5
|
import { CATEGORY_VIEW_MORE_RANK, QUICK_INSERT_MENU_RANK } from '@atlaskit/editor-common/quick-insert/rank';
|
|
8
6
|
import { getMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-get-menu-footer-section-key';
|
|
@@ -11,6 +9,8 @@ import { createRecommendedSnapshotCache, MAX_RECOMMENDED_ITEMS, RECOMMENDED_SLOT
|
|
|
11
9
|
import { QuickInsertMenuFooterItem } from './QuickInsertMenuFooterItem';
|
|
12
10
|
import { QuickInsertRecommendedSlot } from './QuickInsertRecommendedSlot';
|
|
13
11
|
import { QuickInsertSectionOverflowMenuItem } from './QuickInsertSectionOverflowMenuItem';
|
|
12
|
+
import QuickInsertMenuRoot from './registered-menu/QuickInsertMenuRoot';
|
|
13
|
+
import { QuickInsertMenuSection } from './registered-menu/QuickInsertMenuSection';
|
|
14
14
|
const categories = [{
|
|
15
15
|
message: messages.categoryRecommended,
|
|
16
16
|
section: RECOMMENDED_SECTION
|
|
@@ -59,7 +59,10 @@ export const getQuickInsertComponents = ({
|
|
|
59
59
|
api,
|
|
60
60
|
includeElementBrowserItems,
|
|
61
61
|
isRecommendedItem,
|
|
62
|
-
maxRecommendedItems
|
|
62
|
+
maxRecommendedItems,
|
|
63
|
+
getItemRank,
|
|
64
|
+
emptyStateHandler,
|
|
65
|
+
fireAnalyticsEvent
|
|
63
66
|
}) => {
|
|
64
67
|
const recommendedSnapshot = createRecommendedSnapshotCache({
|
|
65
68
|
api,
|
|
@@ -80,16 +83,27 @@ export const getQuickInsertComponents = ({
|
|
|
80
83
|
isHidden: ({
|
|
81
84
|
surfaceContext
|
|
82
85
|
} = {}) => !recommendedSnapshot.getSnapshot(surfaceContext)[index],
|
|
83
|
-
component:
|
|
84
|
-
|
|
85
|
-
|
|
86
|
+
component: ({
|
|
87
|
+
children,
|
|
88
|
+
parents,
|
|
89
|
+
surfaceContext
|
|
90
|
+
}) => /*#__PURE__*/React.createElement(QuickInsertRecommendedSlot, {
|
|
91
|
+
parents: parents,
|
|
92
|
+
surfaceContext: surfaceContext,
|
|
93
|
+
index: index,
|
|
86
94
|
getSnapshot: recommendedSnapshot.getSnapshot
|
|
87
|
-
})
|
|
95
|
+
}, children)
|
|
88
96
|
}));
|
|
89
97
|
return [{
|
|
90
98
|
key: MENU.key,
|
|
91
99
|
type: MENU.type,
|
|
92
|
-
component:
|
|
100
|
+
component: ({
|
|
101
|
+
children
|
|
102
|
+
}) => /*#__PURE__*/React.createElement(QuickInsertMenuRoot, {
|
|
103
|
+
getItemRank: getItemRank,
|
|
104
|
+
emptyStateHandler: emptyStateHandler,
|
|
105
|
+
fireAnalyticsEvent: fireAnalyticsEvent
|
|
106
|
+
}, children)
|
|
93
107
|
}, ...recommendedSlots, ...categories.flatMap(({
|
|
94
108
|
message,
|
|
95
109
|
section
|
|
@@ -114,7 +128,7 @@ export const getQuickInsertComponents = ({
|
|
|
114
128
|
rank: CATEGORY_VIEW_MORE_RANK
|
|
115
129
|
}],
|
|
116
130
|
component: () => /*#__PURE__*/React.createElement(QuickInsertSectionOverflowMenuItem, {
|
|
117
|
-
api,
|
|
131
|
+
api: api,
|
|
118
132
|
category: section.key
|
|
119
133
|
})
|
|
120
134
|
}] : [])]), ...(includeElementBrowserItems ? [{
|
|
@@ -134,7 +148,7 @@ export const getQuickInsertComponents = ({
|
|
|
134
148
|
rank: 100
|
|
135
149
|
}],
|
|
136
150
|
component: () => /*#__PURE__*/React.createElement(QuickInsertMenuFooterItem, {
|
|
137
|
-
api
|
|
151
|
+
api: api
|
|
138
152
|
})
|
|
139
153
|
}] : [])];
|
|
140
154
|
};
|
|
@@ -2,9 +2,9 @@ import { logException } from '@atlaskit/editor-common/monitoring/error';
|
|
|
2
2
|
import { quickInsertProviderMenuItemKey } from '@atlaskit/editor-common/quick-insert/get-provider-menu-item-key';
|
|
3
3
|
import { defaultIsRecommendedItem } from '@atlaskit/editor-common/quick-insert/is-recommended-item';
|
|
4
4
|
import { MENU } from '@atlaskit/editor-common/quick-insert/keys';
|
|
5
|
+
import { REGISTERED_MENU_SURFACE_CONTEXT } from '@atlaskit/editor-common/registered-menu/surface-context';
|
|
5
6
|
import { isMenuFooterSectionKey } from '@atlaskit/editor-common/type-ahead-is-menu-footer-section-key';
|
|
6
7
|
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
7
|
-
import { TYPE_AHEAD_SURFACE_CONTEXT } from '@atlaskit/editor-common/type-ahead-surface-context';
|
|
8
8
|
export const MAX_RECOMMENDED_ITEMS = 5;
|
|
9
9
|
export const RECOMMENDED_SLOT_KEY_PREFIX = 'quick-insert-recommended-slot-';
|
|
10
10
|
export const isRecommendedSlotKey = key => key.startsWith(RECOMMENDED_SLOT_KEY_PREFIX);
|
|
@@ -68,7 +68,7 @@ export const createRecommendedSnapshotCache = ({
|
|
|
68
68
|
let snapshot;
|
|
69
69
|
const getSnapshot = surfaceContext => {
|
|
70
70
|
var _surfaceContext$get, _snapshot;
|
|
71
|
-
const menuOpenId = surfaceContext === null || surfaceContext === void 0 ? void 0 : (_surfaceContext$get = surfaceContext.get(
|
|
71
|
+
const menuOpenId = surfaceContext === null || surfaceContext === void 0 ? void 0 : (_surfaceContext$get = surfaceContext.get(REGISTERED_MENU_SURFACE_CONTEXT)) === null || _surfaceContext$get === void 0 ? void 0 : _surfaceContext$get.menuOpenId;
|
|
72
72
|
if (!surfaceContext || !menuOpenId) {
|
|
73
73
|
return [];
|
|
74
74
|
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
._zulp1ejb{gap:var(--ds-space-300,24px)}
|
|
2
|
+
._1rjcoahv{padding-block:var(--ds-space-600,3pc)}
|
|
3
|
+
._1rjcxy5q{padding-block:var(--ds-space-400,2pc)}._1bah1h6o{justify-content:center}
|
|
4
|
+
._1bsb1mcy{width:57px}
|
|
5
|
+
._1bsb1osq{width:100%}
|
|
6
|
+
._1bsbtudo{width:76px}
|
|
7
|
+
._1e0c1txw{display:flex}
|
|
8
|
+
._2lx21bp4{flex-direction:column}
|
|
9
|
+
._4cvr1h6o{align-items:center}
|
|
10
|
+
._4t3i1h39{height:63px}
|
|
11
|
+
._4t3io7ol{height:84px}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
/* QuickInsertEmptyState.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import "./QuickInsertEmptyState.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React from 'react';
|
|
5
|
+
import { useIntl } from 'react-intl';
|
|
6
|
+
import { lazy, LazySuspense } from 'react-loosely-lazy';
|
|
7
|
+
import { cx } from '@atlaskit/css';
|
|
8
|
+
import { messages } from '@atlaskit/editor-common/quick-insert/messages';
|
|
9
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
10
|
+
import { Text } from '@atlaskit/primitives/compiled/text';
|
|
11
|
+
const NoResultsIllustration = lazy(() => import( /* webpackChunkName: "@atlaskit-internal_editor-quick-insert-no-results" */
|
|
12
|
+
'./assets/no-results').then(module => module.default));
|
|
13
|
+
const styles = {
|
|
14
|
+
base: "_zulp1ejb _4cvr1h6o _1e0c1txw _2lx21bp4 _1bah1h6o _1bsb1osq",
|
|
15
|
+
compact: "_1rjcxy5q",
|
|
16
|
+
spacious: "_1rjcoahv",
|
|
17
|
+
inlineIllustration: "_4t3i1h39 _1bsb1mcy",
|
|
18
|
+
fullIllustration: "_4t3io7ol _1bsbtudo"
|
|
19
|
+
};
|
|
20
|
+
export const QuickInsertEmptyState = ({
|
|
21
|
+
mode,
|
|
22
|
+
spacing = mode === 'full' ? 'spacious' : 'compact'
|
|
23
|
+
}) => {
|
|
24
|
+
const {
|
|
25
|
+
formatMessage
|
|
26
|
+
} = useIntl();
|
|
27
|
+
const illustrationSize = mode === 'full' ? {
|
|
28
|
+
width: 76,
|
|
29
|
+
height: 84
|
|
30
|
+
} : {
|
|
31
|
+
width: 57,
|
|
32
|
+
height: 63
|
|
33
|
+
};
|
|
34
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
35
|
+
testId: "quick-insert-empty-state",
|
|
36
|
+
xcss: cx(styles.base, styles[spacing])
|
|
37
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
38
|
+
xcss: mode === 'full' ? styles.fullIllustration : styles.inlineIllustration
|
|
39
|
+
}, /*#__PURE__*/React.createElement(LazySuspense, {
|
|
40
|
+
fallback: null
|
|
41
|
+
}, /*#__PURE__*/React.createElement(NoResultsIllustration, {
|
|
42
|
+
width: illustrationSize.width,
|
|
43
|
+
height: illustrationSize.height
|
|
44
|
+
}))), /*#__PURE__*/React.createElement(Text, {
|
|
45
|
+
align: "center"
|
|
46
|
+
}, formatMessage(messages.noSearchResults)));
|
|
47
|
+
};
|
|
@@ -0,0 +1,191 @@
|
|
|
1
|
+
import React, { useCallback, useId, useLayoutEffect, useMemo, useRef, useState } from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { INPUT_METHOD } from '@atlaskit/editor-common/analytics/types/enums';
|
|
4
|
+
import { toolbarInsertBlockMessages } from '@atlaskit/editor-common/messages/insert-block';
|
|
5
|
+
import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
|
|
6
|
+
import { useRegisteredMenuContext } from '@atlaskit/editor-common/registered-menu/context';
|
|
7
|
+
import { REGISTERED_MENU_SURFACE_CONTEXT } from '@atlaskit/editor-common/registered-menu/surface-context';
|
|
8
|
+
import { useRegisteredMenu } from '@atlaskit/editor-common/registered-menu/use-registered-menu';
|
|
9
|
+
import { isSectionOverflowItemKey } from '@atlaskit/editor-common/type-ahead-is-section-overflow-item-key';
|
|
10
|
+
import { typeAheadListMessages } from '@atlaskit/editor-common/type-ahead/messages';
|
|
11
|
+
import MenuGroup from '@atlaskit/menu/menu-group';
|
|
12
|
+
import { getQuickInsertMenuModel } from './get-quick-insert-menu-model';
|
|
13
|
+
import { getQuickInsertMenuItemId } from './getQuickInsertMenuItemId';
|
|
14
|
+
import { RegisteredQuickInsertMenuItem } from './RegisteredQuickInsertMenuItem';
|
|
15
|
+
import { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
|
|
16
|
+
import { ToolbarQuickInsertMenu } from './ToolbarQuickInsertMenu';
|
|
17
|
+
import { TypeAheadQuickInsertMenu } from './TypeAheadQuickInsertMenu';
|
|
18
|
+
import { useQuickInsertSearchAnalytics } from './useQuickInsertSearchAnalytics';
|
|
19
|
+
const DEFAULT_MENU_MAX_HEIGHT = 480;
|
|
20
|
+
const isImeEnter = event => event.isComposing || event.keyCode === 229;
|
|
21
|
+
const QuickInsertMenuRoot = ({
|
|
22
|
+
emptyStateHandler,
|
|
23
|
+
fireAnalyticsEvent,
|
|
24
|
+
getItemRank
|
|
25
|
+
}) => {
|
|
26
|
+
var _surfaceContext$get, _registeredMenu$maxHe;
|
|
27
|
+
const registeredMenu = useRegisteredMenuContext();
|
|
28
|
+
const {
|
|
29
|
+
query = '',
|
|
30
|
+
select: selectFromHost,
|
|
31
|
+
surfaceContext
|
|
32
|
+
} = registeredMenu;
|
|
33
|
+
const surface = (_surfaceContext$get = surfaceContext.get(REGISTERED_MENU_SURFACE_CONTEXT)) === null || _surfaceContext$get === void 0 ? void 0 : _surfaceContext$get.surface;
|
|
34
|
+
if (!selectFromHost || !surface || surface === 'element-browser') {
|
|
35
|
+
throw new Error('QuickInsertMenuRoot requires a selection action and registered menu surface');
|
|
36
|
+
}
|
|
37
|
+
const {
|
|
38
|
+
formatMessage
|
|
39
|
+
} = useIntl();
|
|
40
|
+
const {
|
|
41
|
+
components,
|
|
42
|
+
getItemRank: runtimeItemRank,
|
|
43
|
+
rootComponent
|
|
44
|
+
} = registeredMenu;
|
|
45
|
+
const model = useMemo(() => getQuickInsertMenuModel({
|
|
46
|
+
components,
|
|
47
|
+
formatMessage,
|
|
48
|
+
getItemRank: runtimeItemRank !== null && runtimeItemRank !== void 0 ? runtimeItemRank : getItemRank,
|
|
49
|
+
query,
|
|
50
|
+
rootComponent,
|
|
51
|
+
selectCategoryItems: components.some(({
|
|
52
|
+
key
|
|
53
|
+
}) => isSectionOverflowItemKey(key)) ? selectQuickInsertCategoryItems : undefined,
|
|
54
|
+
surfaceContext
|
|
55
|
+
}), [components, formatMessage, getItemRank, query, rootComponent, runtimeItemRank, surfaceContext]);
|
|
56
|
+
const resultCount = useMemo(() => model.sections.reduce((count, [, ...items]) => count + items.filter(({
|
|
57
|
+
key
|
|
58
|
+
}) => !isSectionOverflowItemKey(key)).length, 0), [model.sections]);
|
|
59
|
+
const flushSearchAnalytics = useQuickInsertSearchAnalytics({
|
|
60
|
+
surface,
|
|
61
|
+
fireAnalyticsEvent,
|
|
62
|
+
query,
|
|
63
|
+
resultCount
|
|
64
|
+
});
|
|
65
|
+
const selectItem = useCallback(selection => {
|
|
66
|
+
flushSearchAnalytics();
|
|
67
|
+
selectFromHost(insert => selection({
|
|
68
|
+
insert,
|
|
69
|
+
source: surface === 'toolbar' ? INPUT_METHOD.INSERT_MENU : INPUT_METHOD.QUICK_INSERT
|
|
70
|
+
}));
|
|
71
|
+
}, [flushSearchAnalytics, selectFromHost, surface]);
|
|
72
|
+
const menuContextValue = useMemo(() => ({
|
|
73
|
+
editorView: registeredMenu.editorView,
|
|
74
|
+
isOffline: registeredMenu.isOffline,
|
|
75
|
+
popupsMountPoint: registeredMenu.portalMountPoint,
|
|
76
|
+
select: selectItem,
|
|
77
|
+
surfaceContext: registeredMenu.surfaceContext
|
|
78
|
+
}), [registeredMenu.editorView, registeredMenu.isOffline, registeredMenu.portalMountPoint, registeredMenu.surfaceContext, selectItem]);
|
|
79
|
+
const listLabel = formatMessage(surface === 'typeahead' ? typeAheadListMessages.quickInsertInputLabel : toolbarInsertBlockMessages.insertMenu);
|
|
80
|
+
const {
|
|
81
|
+
rows,
|
|
82
|
+
selectableItems,
|
|
83
|
+
selectedItemIndex,
|
|
84
|
+
activeItemKey,
|
|
85
|
+
...listEvents
|
|
86
|
+
} = useRegisteredMenu({
|
|
87
|
+
model,
|
|
88
|
+
resetKey: query
|
|
89
|
+
});
|
|
90
|
+
const listId = useId();
|
|
91
|
+
const [renderedItems, setRenderedItems] = useState({
|
|
92
|
+
startIndex: -1,
|
|
93
|
+
stopIndex: -1
|
|
94
|
+
});
|
|
95
|
+
const menuRef = useRef(null);
|
|
96
|
+
const maxHeight = (_registeredMenu$maxHe = registeredMenu.maxHeight) !== null && _registeredMenu$maxHe !== void 0 ? _registeredMenu$maxHe : DEFAULT_MENU_MAX_HEIGHT;
|
|
97
|
+
const itemCount = selectableItems.length + (model.footer ? 1 : 0);
|
|
98
|
+
const activeItemId = selectedItemIndex >= 0 && selectedItemIndex < itemCount ? getQuickInsertMenuItemId(listId, selectedItemIndex) : undefined;
|
|
99
|
+
const isActiveItemMounted = selectedItemIndex >= 0 && selectedItemIndex < itemCount && (selectedItemIndex >= renderedItems.startIndex && selectedItemIndex <= renderedItems.stopIndex || Boolean(model.footer) && selectedItemIndex === itemCount - 1);
|
|
100
|
+
const selectActiveItem = useCallback(() => {
|
|
101
|
+
if (isActiveItemMounted && activeItemId) {
|
|
102
|
+
var _menuRef$current, _menuRef$current$owne;
|
|
103
|
+
(_menuRef$current = menuRef.current) === null || _menuRef$current === void 0 ? void 0 : (_menuRef$current$owne = _menuRef$current.ownerDocument.getElementById(activeItemId)) === null || _menuRef$current$owne === void 0 ? void 0 : _menuRef$current$owne.click();
|
|
104
|
+
}
|
|
105
|
+
}, [activeItemId, isActiveItemMounted]);
|
|
106
|
+
const onMenuKeyDown = useCallback(event => {
|
|
107
|
+
if (event.key === 'ArrowDown') {
|
|
108
|
+
listEvents.selectNext();
|
|
109
|
+
return true;
|
|
110
|
+
}
|
|
111
|
+
if (event.key === 'ArrowUp') {
|
|
112
|
+
listEvents.selectPrevious();
|
|
113
|
+
return true;
|
|
114
|
+
}
|
|
115
|
+
if (event.key === 'Enter') {
|
|
116
|
+
if (isImeEnter(event)) {
|
|
117
|
+
return false;
|
|
118
|
+
}
|
|
119
|
+
selectActiveItem();
|
|
120
|
+
return true;
|
|
121
|
+
}
|
|
122
|
+
return false;
|
|
123
|
+
}, [listEvents.selectNext, listEvents.selectPrevious, selectActiveItem]);
|
|
124
|
+
const containsTarget = useCallback(target => {
|
|
125
|
+
var _menuRef$current2;
|
|
126
|
+
return Boolean((_menuRef$current2 = menuRef.current) === null || _menuRef$current2 === void 0 ? void 0 : _menuRef$current2.contains(target));
|
|
127
|
+
}, []);
|
|
128
|
+
const interaction = useMemo(() => ({
|
|
129
|
+
activeDescendantId: isActiveItemMounted ? activeItemId : undefined,
|
|
130
|
+
containsTarget,
|
|
131
|
+
expanded: itemCount > 0,
|
|
132
|
+
label: listLabel,
|
|
133
|
+
listId,
|
|
134
|
+
onKeyDown: onMenuKeyDown,
|
|
135
|
+
onClose: flushSearchAnalytics,
|
|
136
|
+
optionCount: itemCount,
|
|
137
|
+
selectNext: listEvents.selectNext,
|
|
138
|
+
selectPrevious: listEvents.selectPrevious
|
|
139
|
+
}), [activeItemId, containsTarget, flushSearchAnalytics, isActiveItemMounted, itemCount, listId, listLabel, listEvents.selectNext, listEvents.selectPrevious, onMenuKeyDown]);
|
|
140
|
+
useLayoutEffect(() => {
|
|
141
|
+
if (!model.root) {
|
|
142
|
+
return;
|
|
143
|
+
}
|
|
144
|
+
return registeredMenu.registerInteraction(interaction);
|
|
145
|
+
}, [model.root, interaction, registeredMenu.registerInteraction]);
|
|
146
|
+
if (!model.root) {
|
|
147
|
+
return null;
|
|
148
|
+
}
|
|
149
|
+
return /*#__PURE__*/React.createElement(QuickInsertProvider, {
|
|
150
|
+
value: menuContextValue
|
|
151
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
152
|
+
ref: menuRef
|
|
153
|
+
}, /*#__PURE__*/React.createElement(MenuGroup, null, surface === 'typeahead' ? /*#__PURE__*/React.createElement(TypeAheadQuickInsertMenu, {
|
|
154
|
+
Item: RegisteredQuickInsertMenuItem,
|
|
155
|
+
activeItemKey: activeItemKey,
|
|
156
|
+
hasScrollPadding: true,
|
|
157
|
+
itemCount: itemCount,
|
|
158
|
+
listId: listId,
|
|
159
|
+
listLabel: listLabel,
|
|
160
|
+
maxHeight: maxHeight,
|
|
161
|
+
model: model,
|
|
162
|
+
onItemBlur: listEvents.onItemBlur,
|
|
163
|
+
onItemFocus: listEvents.onItemFocus,
|
|
164
|
+
onItemHover: listEvents.onItemHover,
|
|
165
|
+
onItemLeave: listEvents.onItemLeave,
|
|
166
|
+
onItemVisibilityChange: listEvents.onItemVisibilityChange,
|
|
167
|
+
onRenderedItemsChange: setRenderedItems,
|
|
168
|
+
query: query,
|
|
169
|
+
rows: rows,
|
|
170
|
+
selectedItemIndex: selectedItemIndex
|
|
171
|
+
}) : /*#__PURE__*/React.createElement(ToolbarQuickInsertMenu, {
|
|
172
|
+
Item: RegisteredQuickInsertMenuItem,
|
|
173
|
+
activePreviewItemKey: activeItemKey,
|
|
174
|
+
emptyStateHandler: emptyStateHandler,
|
|
175
|
+
itemCount: itemCount,
|
|
176
|
+
listId: listId,
|
|
177
|
+
listLabel: listLabel,
|
|
178
|
+
maxHeight: maxHeight,
|
|
179
|
+
model: model,
|
|
180
|
+
onItemBlur: listEvents.onItemBlur,
|
|
181
|
+
onItemFocus: listEvents.onItemFocus,
|
|
182
|
+
onItemHover: listEvents.onItemHover,
|
|
183
|
+
onItemLeave: listEvents.onItemLeave,
|
|
184
|
+
onItemVisibilityChange: listEvents.onItemVisibilityChange,
|
|
185
|
+
onRenderedItemsChange: setRenderedItems,
|
|
186
|
+
query: query,
|
|
187
|
+
rows: rows,
|
|
188
|
+
selectedItemIndex: selectedItemIndex
|
|
189
|
+
}))));
|
|
190
|
+
};
|
|
191
|
+
export default QuickInsertMenuRoot;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import HeadingItem from '@atlaskit/menu/heading-item';
|
|
3
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
4
|
+
export const QuickInsertMenuSection = ({
|
|
5
|
+
children,
|
|
6
|
+
title
|
|
7
|
+
}) => /*#__PURE__*/React.createElement(Box, {
|
|
8
|
+
role: "group",
|
|
9
|
+
"aria-label": title
|
|
10
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
11
|
+
paddingBlockStart: "space.150",
|
|
12
|
+
paddingBlockEnd: "space.050"
|
|
13
|
+
}, /*#__PURE__*/React.createElement(HeadingItem, {
|
|
14
|
+
"aria-hidden": true
|
|
15
|
+
}, title)), children);
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from 'react';
|
|
2
|
+
import { useIntl } from 'react-intl';
|
|
3
|
+
import { messages } from '@atlaskit/editor-common/quick-insert/messages';
|
|
4
|
+
import { QuickInsertMenuSection } from './QuickInsertMenuSection';
|
|
5
|
+
export const QuickInsertSearchResultsSection = ({
|
|
6
|
+
children
|
|
7
|
+
}) => {
|
|
8
|
+
const {
|
|
9
|
+
formatMessage
|
|
10
|
+
} = useIntl();
|
|
11
|
+
return /*#__PURE__*/React.createElement(QuickInsertMenuSection, {
|
|
12
|
+
title: formatMessage(messages.searchResults)
|
|
13
|
+
}, children);
|
|
14
|
+
};
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import React, { useMemo } from 'react';
|
|
2
|
+
import { QuickInsertProvider } from '@atlaskit/editor-common/quick-insert/provider';
|
|
3
|
+
import { useQuickInsertContext } from '@atlaskit/editor-common/quick-insert/use-quick-insert-context';
|
|
4
|
+
export const RegisteredQuickInsertMenuItem = ({
|
|
5
|
+
id,
|
|
6
|
+
isSelected,
|
|
7
|
+
isActive,
|
|
8
|
+
registration
|
|
9
|
+
}) => {
|
|
10
|
+
var _registration$compone;
|
|
11
|
+
const {
|
|
12
|
+
editorView,
|
|
13
|
+
isOffline,
|
|
14
|
+
popupsMountPoint,
|
|
15
|
+
select,
|
|
16
|
+
surfaceContext
|
|
17
|
+
} = useQuickInsertContext();
|
|
18
|
+
const value = useMemo(() => ({
|
|
19
|
+
editorView,
|
|
20
|
+
isOffline,
|
|
21
|
+
item: {
|
|
22
|
+
id,
|
|
23
|
+
isSelected,
|
|
24
|
+
isPreviewActive: isActive
|
|
25
|
+
},
|
|
26
|
+
popupsMountPoint,
|
|
27
|
+
select,
|
|
28
|
+
surfaceContext
|
|
29
|
+
}), [editorView, isOffline, popupsMountPoint, select, surfaceContext, isActive, id, isSelected]);
|
|
30
|
+
const Component = (_registration$compone = registration.component) !== null && _registration$compone !== void 0 ? _registration$compone : React.Fragment;
|
|
31
|
+
return /*#__PURE__*/React.createElement(QuickInsertProvider, {
|
|
32
|
+
value: value
|
|
33
|
+
}, /*#__PURE__*/React.createElement(Component, null, null));
|
|
34
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
._15a5nqa1{border-top-style:solid}
|
|
2
|
+
._16jlkb7n{flex-grow:1}
|
|
3
|
+
._18m91wug{overflow-y:auto}
|
|
4
|
+
._1e0c1txw{display:flex}
|
|
5
|
+
._1i531l7x{border-top-color:var(--ds-border,#0b120e24)}
|
|
6
|
+
._1o9zidpf{flex-shrink:0}
|
|
7
|
+
._1q51u2gc{padding-block-start:var(--ds-space-100,8px)}
|
|
8
|
+
._1tkeidpf{min-height:0}
|
|
9
|
+
._2lx21bp4{flex-direction:column}
|
|
10
|
+
._85i5u2gc{padding-block-end:var(--ds-space-100,8px)}
|
|
11
|
+
._uwhke4h9{border-top-width:var(--ds-border-width,1px)}
|
|
@@ -0,0 +1,116 @@
|
|
|
1
|
+
/* ToolbarQuickInsertMenu.tsx generated by @compiled/babel-plugin v3.0.2 */
|
|
2
|
+
import "./ToolbarQuickInsertMenu.compiled.css";
|
|
3
|
+
import { ax, ix } from "@compiled/react/runtime";
|
|
4
|
+
import React, { useCallback } from 'react';
|
|
5
|
+
import { RegisteredMenuList } from '@atlaskit/editor-common/registered-menu/list';
|
|
6
|
+
import { Box } from '@atlaskit/primitives/compiled/box';
|
|
7
|
+
import { getQuickInsertMenuItemId } from './getQuickInsertMenuItemId';
|
|
8
|
+
import { QuickInsertEmptyState } from './QuickInsertEmptyState';
|
|
9
|
+
const MENU_FOOTER_HEIGHT = 45;
|
|
10
|
+
const LIST_WIDTH = 350;
|
|
11
|
+
const styles = {
|
|
12
|
+
content: "_1e0c1txw _2lx21bp4 _1tkeidpf",
|
|
13
|
+
scrollable: "_16jlkb7n _1tkeidpf _18m91wug",
|
|
14
|
+
footer: "_1o9zidpf",
|
|
15
|
+
externalControls: "_1i531l7x _15a5nqa1 _uwhke4h9 _1q51u2gc _85i5u2gc",
|
|
16
|
+
footerDivider: "_1i531l7x _15a5nqa1 _uwhke4h9 _1o9zidpf"
|
|
17
|
+
};
|
|
18
|
+
export const ToolbarQuickInsertMenu = ({
|
|
19
|
+
Item,
|
|
20
|
+
model,
|
|
21
|
+
emptyStateHandler,
|
|
22
|
+
listLabel,
|
|
23
|
+
activePreviewItemKey,
|
|
24
|
+
itemCount,
|
|
25
|
+
listId,
|
|
26
|
+
maxHeight,
|
|
27
|
+
rows,
|
|
28
|
+
onItemBlur,
|
|
29
|
+
onItemFocus,
|
|
30
|
+
onItemHover,
|
|
31
|
+
onItemLeave,
|
|
32
|
+
onItemVisibilityChange,
|
|
33
|
+
onRenderedItemsChange,
|
|
34
|
+
query,
|
|
35
|
+
selectedItemIndex
|
|
36
|
+
}) => {
|
|
37
|
+
const footerItemIndex = itemCount - 1;
|
|
38
|
+
const footerItemId = getQuickInsertMenuItemId(listId, footerItemIndex);
|
|
39
|
+
const isEmptySearch = query !== '' && model.sections.length === 0;
|
|
40
|
+
const hasNoSearchResults = model.sections.length === 0 && model.fallbackItems.length === 0;
|
|
41
|
+
const externalControls = isEmptySearch ? emptyStateHandler === null || emptyStateHandler === void 0 ? void 0 : emptyStateHandler({
|
|
42
|
+
mode: 'inline',
|
|
43
|
+
searchTerm: query,
|
|
44
|
+
showNoResultsMessage: false
|
|
45
|
+
}) : null;
|
|
46
|
+
const onFooterItemFocus = useCallback(() => onItemFocus(footerItemIndex), [footerItemIndex, onItemFocus]);
|
|
47
|
+
const onFooterItemHover = useCallback(() => onItemHover(footerItemIndex), [footerItemIndex, onItemHover]);
|
|
48
|
+
const listMaxHeight = Math.max(0, maxHeight - (model.footer ? MENU_FOOTER_HEIGHT : 0));
|
|
49
|
+
const contentStyle = {
|
|
50
|
+
maxHeight: maxHeight
|
|
51
|
+
};
|
|
52
|
+
const getItemId = useCallback(({
|
|
53
|
+
itemIndex
|
|
54
|
+
}) => getQuickInsertMenuItemId(listId, itemIndex), [listId]);
|
|
55
|
+
const onScrollableContentScroll = useCallback(event => {
|
|
56
|
+
if (event.target === event.currentTarget && activePreviewItemKey) {
|
|
57
|
+
onItemVisibilityChange(activePreviewItemKey, false);
|
|
58
|
+
}
|
|
59
|
+
}, [activePreviewItemKey, onItemVisibilityChange]);
|
|
60
|
+
if (!model.root) {
|
|
61
|
+
return null;
|
|
62
|
+
}
|
|
63
|
+
return /*#__PURE__*/React.createElement(Box, {
|
|
64
|
+
xcss: styles.content,
|
|
65
|
+
style: contentStyle
|
|
66
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
67
|
+
xcss: styles.scrollable,
|
|
68
|
+
onScroll: onScrollableContentScroll
|
|
69
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
70
|
+
"aria-label": listLabel,
|
|
71
|
+
"aria-owns": model.footer ? footerItemId : undefined,
|
|
72
|
+
id: listId,
|
|
73
|
+
role: "listbox"
|
|
74
|
+
}, rows.length > 0 && /*#__PURE__*/React.createElement(RegisteredMenuList, {
|
|
75
|
+
rows: rows,
|
|
76
|
+
Item: Item,
|
|
77
|
+
width: LIST_WIDTH,
|
|
78
|
+
maxHeight: listMaxHeight,
|
|
79
|
+
getItemId: getItemId,
|
|
80
|
+
activeItemKey: activePreviewItemKey,
|
|
81
|
+
selectedItemIndex: selectedItemIndex,
|
|
82
|
+
scrollResetKey: query,
|
|
83
|
+
onItemHover: onItemHover,
|
|
84
|
+
onItemFocus: onItemFocus,
|
|
85
|
+
onItemBlur: onItemBlur,
|
|
86
|
+
onItemLeave: onItemLeave,
|
|
87
|
+
onItemVisibilityChange: onItemVisibilityChange,
|
|
88
|
+
onRenderedItemsChange: onRenderedItemsChange,
|
|
89
|
+
role: "group",
|
|
90
|
+
tabIndex: null,
|
|
91
|
+
omitAriaReadonly: true,
|
|
92
|
+
lastRowPadding: "space.100",
|
|
93
|
+
scrollTo: "top-on-reset"
|
|
94
|
+
})), query !== '' && hasNoSearchResults && /*#__PURE__*/React.createElement(QuickInsertEmptyState, {
|
|
95
|
+
mode: "inline"
|
|
96
|
+
}), externalControls && /*#__PURE__*/React.createElement(Box, {
|
|
97
|
+
testId: "registered-insert-menu-external-controls",
|
|
98
|
+
xcss: styles.externalControls
|
|
99
|
+
}, externalControls)), model.footer && /*#__PURE__*/React.createElement(Box, {
|
|
100
|
+
xcss: styles.footer
|
|
101
|
+
}, /*#__PURE__*/React.createElement(Box, {
|
|
102
|
+
testId: "registered-insert-menu-footer",
|
|
103
|
+
xcss: styles.footer
|
|
104
|
+
}, !isEmptySearch || !hasNoSearchResults || Boolean(externalControls) ? /*#__PURE__*/React.createElement(Box, {
|
|
105
|
+
"aria-hidden": "true",
|
|
106
|
+
xcss: styles.footerDivider
|
|
107
|
+
}) : null, /*#__PURE__*/React.createElement(Box, {
|
|
108
|
+
onFocus: onFooterItemFocus,
|
|
109
|
+
onMouseMove: onFooterItemHover
|
|
110
|
+
}, /*#__PURE__*/React.createElement(Item, {
|
|
111
|
+
id: footerItemId,
|
|
112
|
+
isSelected: selectedItemIndex === footerItemIndex,
|
|
113
|
+
isActive: false,
|
|
114
|
+
registration: model.footer
|
|
115
|
+
})))));
|
|
116
|
+
};
|