@atlaskit/editor-common 133.7.2 → 134.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 (142) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/cjs/insert/index.js +1 -0
  3. package/dist/cjs/monitoring/error.js +1 -1
  4. package/dist/cjs/quick-insert/QuickInsertContext.js +4 -0
  5. package/dist/cjs/quick-insert/QuickInsertMenuItem.js +4 -1
  6. package/dist/cjs/registered-menu/ActiveMenuItemKeyContext.js +11 -0
  7. package/dist/cjs/registered-menu/MeasuredRow.js +41 -0
  8. package/dist/cjs/registered-menu/RegisteredMenuContext.js +15 -0
  9. package/dist/cjs/registered-menu/RegisteredMenuList.js +224 -0
  10. package/dist/cjs/registered-menu/RegisteredMenuListItemRow.js +62 -0
  11. package/dist/cjs/registered-menu/RegisteredMenuSurfaceContext.js +12 -0
  12. package/dist/cjs/registered-menu/getRegisteredMenuRows.js +11 -0
  13. package/dist/cjs/registered-menu/types.js +5 -0
  14. package/dist/cjs/{quick-insert/use-menu-list-height.js → registered-menu/useMenuListHeight.js} +15 -11
  15. package/dist/cjs/{quick-insert/use-menu-popup-sizing.js → registered-menu/useMenuPopupSizing.js} +5 -1
  16. package/dist/cjs/registered-menu/useRegisteredMenu.js +133 -0
  17. package/dist/cjs/registered-menu/useRegisteredMenuSelection.js +53 -0
  18. package/dist/cjs/ui/DropList/index.js +1 -1
  19. package/dist/es2019/insert/index.js +3 -0
  20. package/dist/es2019/monitoring/error.js +1 -1
  21. package/dist/es2019/quick-insert/QuickInsertContext.js +4 -0
  22. package/dist/es2019/quick-insert/QuickInsertMenuItem.js +4 -1
  23. package/dist/es2019/registered-menu/ActiveMenuItemKeyContext.js +5 -0
  24. package/dist/es2019/registered-menu/MeasuredRow.js +32 -0
  25. package/dist/es2019/registered-menu/RegisteredMenuContext.js +9 -0
  26. package/dist/es2019/registered-menu/RegisteredMenuList.js +177 -0
  27. package/dist/es2019/registered-menu/RegisteredMenuListItemRow.js +47 -0
  28. package/dist/es2019/registered-menu/RegisteredMenuSurfaceContext.js +4 -0
  29. package/dist/es2019/registered-menu/getRegisteredMenuRows.js +1 -0
  30. package/dist/es2019/registered-menu/types.js +1 -0
  31. package/dist/es2019/{quick-insert/use-menu-list-height.js → registered-menu/useMenuListHeight.js} +14 -10
  32. package/dist/es2019/{quick-insert/use-menu-popup-sizing.js → registered-menu/useMenuPopupSizing.js} +5 -1
  33. package/dist/es2019/registered-menu/useRegisteredMenu.js +120 -0
  34. package/dist/es2019/registered-menu/useRegisteredMenuSelection.js +39 -0
  35. package/dist/es2019/ui/DropList/index.js +1 -1
  36. package/dist/esm/insert/index.js +3 -0
  37. package/dist/esm/monitoring/error.js +1 -1
  38. package/dist/esm/quick-insert/QuickInsertContext.js +4 -0
  39. package/dist/esm/quick-insert/QuickInsertMenuItem.js +4 -1
  40. package/dist/esm/registered-menu/ActiveMenuItemKeyContext.js +5 -0
  41. package/dist/esm/registered-menu/MeasuredRow.js +33 -0
  42. package/dist/esm/registered-menu/RegisteredMenuContext.js +9 -0
  43. package/dist/esm/registered-menu/RegisteredMenuList.js +215 -0
  44. package/dist/esm/registered-menu/RegisteredMenuListItemRow.js +54 -0
  45. package/dist/esm/registered-menu/RegisteredMenuSurfaceContext.js +6 -0
  46. package/dist/esm/registered-menu/getRegisteredMenuRows.js +4 -0
  47. package/dist/esm/registered-menu/types.js +1 -0
  48. package/dist/esm/{quick-insert/use-menu-list-height.js → registered-menu/useMenuListHeight.js} +15 -11
  49. package/dist/esm/{quick-insert/use-menu-popup-sizing.js → registered-menu/useMenuPopupSizing.js} +5 -1
  50. package/dist/esm/registered-menu/useRegisteredMenu.js +126 -0
  51. package/dist/esm/registered-menu/useRegisteredMenuSelection.js +46 -0
  52. package/dist/esm/ui/DropList/index.js +1 -1
  53. package/dist/types/insert/index.d.ts +5 -1
  54. package/dist/types/quick-insert/QuickInsertContext.d.ts +6 -5
  55. package/dist/types/quick-insert/QuickInsertMenuItem.d.ts +2 -2
  56. package/dist/types/quick-insert/quick-insert-rank.d.ts +1 -1
  57. package/dist/types/registered-menu/ActiveMenuItemKeyContext.d.ts +2 -0
  58. package/dist/types/registered-menu/MeasuredRow.d.ts +10 -0
  59. package/dist/types/registered-menu/RegisteredMenuContext.d.ts +4 -0
  60. package/dist/types/registered-menu/RegisteredMenuList.d.ts +31 -0
  61. package/dist/types/registered-menu/RegisteredMenuListItemRow.d.ts +28 -0
  62. package/dist/types/registered-menu/RegisteredMenuSurfaceContext.d.ts +7 -0
  63. package/dist/types/registered-menu/getRegisteredMenuRows.d.ts +4 -0
  64. package/dist/types/registered-menu/types.d.ts +55 -0
  65. package/dist/types/{quick-insert/use-menu-list-height.d.ts → registered-menu/useMenuListHeight.d.ts} +5 -1
  66. package/dist/types/{quick-insert/use-menu-popup-sizing.d.ts → registered-menu/useMenuPopupSizing.d.ts} +5 -1
  67. package/dist/types/registered-menu/useRegisteredMenu.d.ts +28 -0
  68. package/dist/types/registered-menu/useRegisteredMenuSelection.d.ts +16 -0
  69. package/dist/types/type-ahead/index.d.ts +0 -1
  70. package/dist/types/types/index.d.ts +1 -1
  71. package/dist/types/types/quick-insert.d.ts +1 -1
  72. package/dist/types/types/type-ahead.d.ts +9 -6
  73. package/package.json +9 -9
  74. package/registered-menu/context/package.json +10 -0
  75. package/registered-menu/item-rank/package.json +10 -0
  76. package/registered-menu/list/package.json +10 -0
  77. package/registered-menu/list-height/package.json +10 -0
  78. package/registered-menu/package.json +10 -0
  79. package/registered-menu/popup-sizing/package.json +10 -0
  80. package/registered-menu/rows/package.json +10 -0
  81. package/registered-menu/surface-context/package.json +10 -0
  82. package/registered-menu/use-registered-menu/package.json +10 -0
  83. package/dist/cjs/quick-insert/QuickInsertEmptyState.compiled.css +0 -11
  84. package/dist/cjs/quick-insert/QuickInsertEmptyState.js +0 -61
  85. package/dist/cjs/quick-insert/QuickInsertMenuRoot.js +0 -13
  86. package/dist/cjs/quick-insert/QuickInsertMenuSection.js +0 -23
  87. package/dist/cjs/quick-insert/QuickInsertSearchResultsSection.js +0 -19
  88. package/dist/cjs/quick-insert/assets/no-results.js +0 -36
  89. package/dist/cjs/quick-insert/get-quick-insert-menu-model.js +0 -234
  90. package/dist/cjs/quick-insert/getQuickInsertMenuRows.js +0 -12
  91. package/dist/cjs/quick-insert/registered-menu-model.js +0 -33
  92. package/dist/cjs/quick-insert/selectQuickInsertCategoryItems.js +0 -27
  93. package/dist/cjs/quick-insert/useQuickInsertSearchAnalytics.js +0 -100
  94. package/dist/cjs/type-ahead/TypeAheadSurfaceContext.js +0 -11
  95. package/dist/es2019/quick-insert/QuickInsertEmptyState.compiled.css +0 -11
  96. package/dist/es2019/quick-insert/QuickInsertEmptyState.js +0 -47
  97. package/dist/es2019/quick-insert/QuickInsertMenuRoot.js +0 -5
  98. package/dist/es2019/quick-insert/QuickInsertMenuSection.js +0 -15
  99. package/dist/es2019/quick-insert/QuickInsertSearchResultsSection.js +0 -14
  100. package/dist/es2019/quick-insert/assets/no-results.js +0 -30
  101. package/dist/es2019/quick-insert/get-quick-insert-menu-model.js +0 -174
  102. package/dist/es2019/quick-insert/getQuickInsertMenuRows.js +0 -4
  103. package/dist/es2019/quick-insert/registered-menu-model.js +0 -6
  104. package/dist/es2019/quick-insert/selectQuickInsertCategoryItems.js +0 -19
  105. package/dist/es2019/quick-insert/useQuickInsertSearchAnalytics.js +0 -91
  106. package/dist/es2019/type-ahead/TypeAheadSurfaceContext.js +0 -5
  107. package/dist/esm/quick-insert/QuickInsertEmptyState.compiled.css +0 -11
  108. package/dist/esm/quick-insert/QuickInsertEmptyState.js +0 -50
  109. package/dist/esm/quick-insert/QuickInsertMenuRoot.js +0 -6
  110. package/dist/esm/quick-insert/QuickInsertMenuSection.js +0 -16
  111. package/dist/esm/quick-insert/QuickInsertSearchResultsSection.js +0 -12
  112. package/dist/esm/quick-insert/assets/no-results.js +0 -29
  113. package/dist/esm/quick-insert/get-quick-insert-menu-model.js +0 -227
  114. package/dist/esm/quick-insert/getQuickInsertMenuRows.js +0 -5
  115. package/dist/esm/quick-insert/registered-menu-model.js +0 -6
  116. package/dist/esm/quick-insert/selectQuickInsertCategoryItems.js +0 -21
  117. package/dist/esm/quick-insert/useQuickInsertSearchAnalytics.js +0 -93
  118. package/dist/esm/type-ahead/TypeAheadSurfaceContext.js +0 -5
  119. package/dist/types/quick-insert/QuickInsertEmptyState.d.ts +0 -7
  120. package/dist/types/quick-insert/QuickInsertMenuRoot.d.ts +0 -2
  121. package/dist/types/quick-insert/QuickInsertMenuSection.d.ts +0 -4
  122. package/dist/types/quick-insert/QuickInsertSearchResultsSection.d.ts +0 -2
  123. package/dist/types/quick-insert/assets/no-results.d.ts +0 -7
  124. package/dist/types/quick-insert/get-quick-insert-menu-model.d.ts +0 -29
  125. package/dist/types/quick-insert/getQuickInsertMenuRows.d.ts +0 -3
  126. package/dist/types/quick-insert/registered-menu-model.d.ts +0 -6
  127. package/dist/types/quick-insert/selectQuickInsertCategoryItems.d.ts +0 -7
  128. package/dist/types/quick-insert/useQuickInsertSearchAnalytics.d.ts +0 -12
  129. package/dist/types/type-ahead/TypeAheadSurfaceContext.d.ts +0 -8
  130. package/quick-insert/empty-state/package.json +0 -10
  131. package/quick-insert/menu-root/package.json +0 -10
  132. package/quick-insert/menu-section/package.json +0 -10
  133. package/quick-insert/registered-menu-model/package.json +0 -10
  134. package/quick-insert/use-menu-list-height/package.json +0 -10
  135. package/quick-insert/use-menu-popup-sizing/package.json +0 -10
  136. package/quick-insert/use-search-analytics/package.json +0 -10
  137. package/type-ahead/item-rank/package.json +0 -10
  138. package/type-ahead-surface-context/package.json +0 -10
  139. /package/dist/cjs/{type-ahead → registered-menu}/item-rank.js +0 -0
  140. /package/dist/es2019/{type-ahead → registered-menu}/item-rank.js +0 -0
  141. /package/dist/esm/{type-ahead → registered-menu}/item-rank.js +0 -0
  142. /package/dist/types/{type-ahead → registered-menu}/item-rank.d.ts +0 -0
@@ -1,11 +0,0 @@
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}
@@ -1,47 +0,0 @@
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 { Box } from '@atlaskit/primitives/compiled/box';
9
- import { Text } from '@atlaskit/primitives/compiled/text';
10
- import { messages } from './messages';
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
- };
@@ -1,5 +0,0 @@
1
- import React from 'react';
2
- import MenuGroup from '@atlaskit/menu/menu-group';
3
- export const QuickInsertMenuRoot = ({
4
- children
5
- }) => /*#__PURE__*/React.createElement(MenuGroup, null, children);
@@ -1,15 +0,0 @@
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);
@@ -1,14 +0,0 @@
1
- import React from 'react';
2
- import { useIntl } from 'react-intl';
3
- import { messages } from './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
- };
@@ -1,30 +0,0 @@
1
- import React from 'react';
2
- export default function NoResultsIllustration({
3
- height,
4
- width
5
- }) {
6
- return /*#__PURE__*/React.createElement("svg", {
7
- width: width,
8
- height: height,
9
- viewBox: "0 0 57 63",
10
- fill: "none",
11
- xmlns: "http://www.w3.org/2000/svg",
12
- "aria-hidden": "true",
13
- focusable: "false"
14
- }, /*#__PURE__*/React.createElement("path", {
15
- fill: "#dddee1",
16
- d: "M23.5 49.223c-5.196 0-10.166-1.955-14.442-5.814a30 30 0 0 1-3.545-3.85 29.6 29.6 0 0 1-2.868-4.456c-4.56-8.775-3.179-18.124 3.79-25.647a32.6 32.6 0 0 1 3.942-3.593 32 32 0 0 1 4.287-2.81c9.017-4.89 18.424-3.869 25.803 2.8a30.3 30.3 0 0 1 3.59 3.897 29.7 29.7 0 0 1 2.837 4.396C51.5 22.96 50.12 32.324 43.106 39.83a31.5 31.5 0 0 1-3.797 3.442 33 33 0 0 1-4.468 2.912c-3.777 2.03-7.62 3.036-11.341 3.036zm2.478-44.539c-2.957 0-6.02.824-9.082 2.489a28 28 0 0 0-3.658 2.396 27.5 27.5 0 0 0-3.37 3.07C4.24 18.711 3.15 25.92 6.798 32.941a25 25 0 0 0 2.42 3.75 25 25 0 0 0 2.981 3.24c5.866 5.299 13.119 6.054 20.427 2.13a27.4 27.4 0 0 0 3.818-2.492 27.5 27.5 0 0 0 3.24-2.936c5.658-6.054 6.741-13.27 3.06-20.318a25 25 0 0 0-2.39-3.698 25.3 25.3 0 0 0-3.021-3.289c-3.418-3.086-7.288-4.645-11.348-4.645z"
17
- }), /*#__PURE__*/React.createElement("path", {
18
- fill: "#dddee1",
19
- d: "M42.822 42.291c-1.21-1.685-2.509-1.675-3.777-.694-1.19.92-1.507 2.164-.24 3.801l1.45 1.873 4.017-3.107z"
20
- }), /*#__PURE__*/React.createElement("path", {
21
- fill: "#dddee1",
22
- d: "m45.28 43.385-6.03 4.663 11.332 14.657 6.03-4.663z"
23
- }), /*#__PURE__*/React.createElement("path", {
24
- fill: "#b7b9be",
25
- d: "m44.31 44.134-4.091 3.163 3.843 4.97 4.091-3.163z"
26
- }), /*#__PURE__*/React.createElement("path", {
27
- fill: "#dddee1",
28
- d: "M26.834 30.328h-3.42v-.217c-.116-2.432 1.264-5.066 3.227-6.143l.037-.02q.08-.042.154-.093c1.071-.69 1.68-1.88 1.643-3.189-.037-1.298-.707-2.439-1.791-3.052a4.5 4.5 0 0 0-2.21-.592c-2.315 0-4.198 1.897-4.198 4.229h-3.42c0-4.23 3.417-7.672 7.618-7.672a7.9 7.9 0 0 1 3.884 1.033c2.14 1.211 3.462 3.437 3.534 5.955.073 2.53-1.125 4.84-3.203 6.18q-.211.139-.424.251c-.815.458-1.497 1.868-1.434 2.97zM24.795 32.303a3.4 3.4 0 0 1 1.096-.004c1.115.183 2.021.965 2.241 2.182l.002.01.002.009a3.4 3.4 0 0 1-.002 1.103v.004c-.216 1.23-1.136 2.009-2.247 2.19a3.417 3.417 0 0 1-1.085-.003c-1.117-.18-2.027-.961-2.249-2.179l-.002-.01-.001-.01a3.3 3.3 0 0 1 0-1.095l.002-.01.001-.01c.223-1.223 1.137-1.992 2.24-2.177z"
29
- }));
30
- }
@@ -1,174 +0,0 @@
1
- import { getComponentIdentity, resolveSurface, willComponentRender } from '@atlaskit/editor-ui-control-model/surface-renderer';
2
- import { isMenuFooterSectionKey } from '../type-ahead/isMenuFooterSectionKey';
3
- import { isSectionOverflowItemKey } from '../type-ahead/isSectionOverflowItemKey';
4
- import { applyRegisteredItemRanks } from '../type-ahead/item-rank';
5
- import { ASK_ROVO_MENU_ITEM, MENU, SEARCH_RESULTS_SECTION } from './keys';
6
- import { QuickInsertSearchResultsSection } from './QuickInsertSearchResultsSection';
7
- const SEARCH_TOP_MATCH_LIMIT = 5;
8
- const SEARCH_RESULTS_HEADING = {
9
- key: SEARCH_RESULTS_SECTION.key,
10
- type: SEARCH_RESULTS_SECTION.type,
11
- component: QuickInsertSearchResultsSection,
12
- parents: [{
13
- key: MENU.key,
14
- type: MENU.type,
15
- rank: 0
16
- }]
17
- };
18
- const getParentRank = (component, parentKey) => {
19
- var _component$parents$fi, _component$parents, _component$parents$fi2;
20
- return (_component$parents$fi = (_component$parents = component.parents) === null || _component$parents === void 0 ? void 0 : (_component$parents$fi2 = _component$parents.find(parent => parent.key === parentKey)) === null || _component$parents$fi2 === void 0 ? void 0 : _component$parents$fi2.rank) !== null && _component$parents$fi !== void 0 ? _component$parents$fi : Number.MAX_SAFE_INTEGER;
21
- };
22
- const compareMatchedItems = (a, b) => a.sectionRank - b.sectionRank || a.score - b.score || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
23
- const compareSearchResults = (a, b) => a.score - b.score || a.sectionRank - b.sectionRank || a.itemRank - b.itemRank || a.sourceIndex - b.sourceIndex || a.identity.localeCompare(b.identity);
24
- const getSearchResults = matches => {
25
- const topMatches = Array.from(matches).sort(compareSearchResults).slice(0, SEARCH_TOP_MATCH_LIMIT);
26
- const topMatchIdentities = new Set(topMatches.map(({
27
- identity
28
- }) => identity));
29
- const tailMatches = matches.filter(({
30
- identity
31
- }) => !topMatchIdentities.has(identity));
32
- return [...topMatches, ...tailMatches].map(({
33
- item
34
- }) => item);
35
- };
36
- const getRenderedMenuItems = (section, childrenMap, surfaceContext) => {
37
- var _childrenMap$get;
38
- return ((_childrenMap$get = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get !== void 0 ? _childrenMap$get : []).filter(child => child.type === 'menu-item' && willComponentRender(child, childrenMap, surfaceContext));
39
- };
40
- const buildBrowseSections = ({
41
- childrenMap,
42
- contentSections,
43
- selectCategoryItems,
44
- surfaceContext
45
- }) => {
46
- const sections = [];
47
- for (const section of contentSections) {
48
- const children = getRenderedMenuItems(section, childrenMap, surfaceContext);
49
- const overflowItems = children.filter(child => isSectionOverflowItemKey(child.key));
50
- const viewMoreItem = overflowItems[overflowItems.length - 1];
51
- const items = children.filter(child => !isSectionOverflowItemKey(child.key));
52
- if (items.length === 0) {
53
- continue;
54
- }
55
- const selectedItems = viewMoreItem !== undefined && selectCategoryItems !== undefined ? selectCategoryItems(items) : items;
56
- if (selectedItems.length < items.length && viewMoreItem !== undefined) {
57
- sections.push([section, ...selectedItems, viewMoreItem]);
58
- } else {
59
- sections.push([section, ...selectedItems]);
60
- }
61
- }
62
- return {
63
- sections
64
- };
65
- };
66
- const buildSearchSections = ({
67
- childrenMap,
68
- components,
69
- contentSections,
70
- formatMessage,
71
- query,
72
- root,
73
- surfaceContext
74
- }) => {
75
- const matches = new Map();
76
- const sourceIndexByComponent = new Map(components.map((component, index) => [component, index]));
77
- for (const section of contentSections) {
78
- for (const item of getRenderedMenuItems(section, childrenMap, surfaceContext)) {
79
- var _item$match, _match$score, _sourceIndexByCompone;
80
- if (isSectionOverflowItemKey(item.key)) {
81
- continue;
82
- }
83
- const match = (_item$match = item.match) === null || _item$match === void 0 ? void 0 : _item$match.call(item, {
84
- formatMessage,
85
- query
86
- });
87
- if (item.match && match === null) {
88
- continue;
89
- }
90
- const candidate = {
91
- identity: `${item.type}:${item.key}`,
92
- item,
93
- itemRank: getParentRank(item, section.key),
94
- score: Math.min(1, Math.max(0, (_match$score = match === null || match === void 0 ? void 0 : match.score) !== null && _match$score !== void 0 ? _match$score : 0)),
95
- sourceIndex: (_sourceIndexByCompone = sourceIndexByComponent.get(item)) !== null && _sourceIndexByCompone !== void 0 ? _sourceIndexByCompone : Number.MAX_SAFE_INTEGER,
96
- sectionRank: getParentRank(section, root.key)
97
- };
98
- const existing = matches.get(candidate.identity);
99
- if (!existing || compareMatchedItems(candidate, existing) < 0) {
100
- matches.set(candidate.identity, candidate);
101
- }
102
- }
103
- }
104
- const uniqueMatches = Array.from(matches.values()).sort(compareMatchedItems);
105
- const searchResults = getSearchResults(uniqueMatches);
106
- if (searchResults.length > 0) {
107
- return {
108
- sections: [[SEARCH_RESULTS_HEADING, ...searchResults]]
109
- };
110
- }
111
- const fallbackItem = contentSections.flatMap(section => {
112
- var _childrenMap$get2;
113
- return (_childrenMap$get2 = childrenMap.get(getComponentIdentity(section))) !== null && _childrenMap$get2 !== void 0 ? _childrenMap$get2 : [];
114
- }).find(component => component.type === ASK_ROVO_MENU_ITEM.type && component.key === ASK_ROVO_MENU_ITEM.key && willComponentRender(component, childrenMap, surfaceContext));
115
- return {
116
- fallbackItems: fallbackItem ? [fallbackItem] : [],
117
- sections: []
118
- };
119
- };
120
-
121
- /**
122
- * Builds the registered quick-insert menu model. An empty query browses every
123
- * category; a non-empty query returns ranked matches. The footer is shared by both.
124
- */
125
- export const getQuickInsertMenuModel = ({
126
- components,
127
- formatMessage,
128
- getItemRank,
129
- query,
130
- rootComponent,
131
- selectCategoryItems,
132
- surfaceContext
133
- }) => {
134
- const rankedComponents = applyRegisteredItemRanks(components, getItemRank);
135
- const {
136
- childrenMap,
137
- root,
138
- topLevelChildren = []
139
- } = resolveSurface(rankedComponents, rootComponent);
140
- if (!root || !willComponentRender(root, childrenMap, surfaceContext)) {
141
- return {
142
- footer: undefined,
143
- root: undefined,
144
- sections: []
145
- };
146
- }
147
- const renderedSections = topLevelChildren.filter(section => section.type === 'menu-section' && willComponentRender(section, childrenMap, surfaceContext));
148
- const footerSection = renderedSections.find(({
149
- key
150
- }) => isMenuFooterSectionKey(key));
151
- const contentSections = renderedSections.filter(({
152
- key
153
- }) => !isMenuFooterSectionKey(key));
154
- const content = query === '' ? buildBrowseSections({
155
- childrenMap,
156
- contentSections,
157
- selectCategoryItems,
158
- surfaceContext
159
- }) : buildSearchSections({
160
- childrenMap,
161
- components: rankedComponents,
162
- contentSections,
163
- formatMessage,
164
- query,
165
- root,
166
- surfaceContext
167
- });
168
- const footer = footerSection ? getRenderedMenuItems(footerSection, childrenMap, surfaceContext)[0] : undefined;
169
- return {
170
- ...content,
171
- footer,
172
- root
173
- };
174
- };
@@ -1,4 +0,0 @@
1
- export const getQuickInsertMenuRows = model => {
2
- var _model$fallbackItems;
3
- return [...model.sections.flat(), ...((_model$fallbackItems = model.fallbackItems) !== null && _model$fallbackItems !== void 0 ? _model$fallbackItems : [])];
4
- };
@@ -1,6 +0,0 @@
1
- /* eslint-disable @atlaskit/editor/no-re-export */
2
-
3
- export { getQuickInsertMenuModel } from './get-quick-insert-menu-model';
4
- export { getQuickInsertMenuRows } from './getQuickInsertMenuRows';
5
- export { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
6
- export { selectQuickInsertCategoryItems } from './selectQuickInsertCategoryItems';
@@ -1,19 +0,0 @@
1
- import { quickInsertProviderMenuItemKey } from './getQuickInsertProviderMenuItemKey';
2
- const DEFAULT_ITEM_LIMIT = 30;
3
- const ECOSYSTEM_ITEM_LIMIT = 10;
4
- const isEcosystemQuickInsertItem = item => quickInsertProviderMenuItemKey.isEcosystem(item.key);
5
-
6
- /**
7
- * Keeps the initial native and ecosystem results while ensuring ecosystem registrations
8
- * remain discoverable beyond the default category item limit.
9
- */
10
- export const selectQuickInsertCategoryItems = items => {
11
- let ecosystemItemCount = 0;
12
- return items.filter((item, index) => {
13
- const isEcosystemItem = isEcosystemQuickInsertItem(item);
14
- if (isEcosystemItem) {
15
- ecosystemItemCount++;
16
- }
17
- return index < DEFAULT_ITEM_LIMIT || isEcosystemItem && ecosystemItemCount <= ECOSYSTEM_ITEM_LIMIT;
18
- });
19
- };
@@ -1,91 +0,0 @@
1
- import { useCallback, useEffect, useRef } from 'react';
2
- import { ACTION, ACTION_SUBJECT, EVENT_TYPE } from '../analytics/types/enums';
3
- const SEARCH_DEBOUNCE_MS = 1000;
4
- export const useQuickInsertSearchAnalytics = ({
5
- query,
6
- resultCount,
7
- surface,
8
- category,
9
- isOpen = true,
10
- fireAnalyticsEvent
11
- }) => {
12
- const latestOptions = useRef({
13
- query,
14
- resultCount,
15
- surface,
16
- category,
17
- fireAnalyticsEvent
18
- });
19
- latestOptions.current = {
20
- query,
21
- resultCount,
22
- surface,
23
- category,
24
- fireAnalyticsEvent
25
- };
26
- const pendingSearch = useRef(null);
27
- const effectVersion = useRef(0);
28
- const flush = useCallback(() => {
29
- const pending = pendingSearch.current;
30
- if (!pending) {
31
- return;
32
- }
33
- clearTimeout(pending.timer);
34
- pendingSearch.current = null;
35
- const current = latestOptions.current;
36
- if (current.query.trim() !== pending.query || !current.fireAnalyticsEvent) {
37
- return;
38
- }
39
- const attributes = {
40
- ...(current.surface === 'element-browser' && current.category !== undefined ? {
41
- category: current.category
42
- } : {}),
43
- isEmpty: current.resultCount === 0,
44
- queryLength: current.query.trim().length,
45
- resultCount: current.resultCount,
46
- surface: current.surface
47
- };
48
- const payload = {
49
- action: ACTION.SEARCHED,
50
- actionSubject: ACTION_SUBJECT.QUICK_INSERT,
51
- eventType: EVENT_TYPE.TRACK,
52
- attributes
53
- };
54
- current.fireAnalyticsEvent(payload);
55
- }, []);
56
- useEffect(() => {
57
- const currentVersion = ++effectVersion.current;
58
- if (!isOpen) {
59
- flush();
60
- return;
61
- }
62
- const trimmedQuery = query.trim();
63
- if (!trimmedQuery) {
64
- if (pendingSearch.current) {
65
- clearTimeout(pendingSearch.current.timer);
66
- pendingSearch.current = null;
67
- }
68
- return;
69
- }
70
- if (pendingSearch.current) {
71
- clearTimeout(pendingSearch.current.timer);
72
- }
73
- const timer = setTimeout(flush, SEARCH_DEBOUNCE_MS);
74
- pendingSearch.current = {
75
- query: trimmedQuery,
76
- timer
77
- };
78
- return () => {
79
- if (pendingSearch.current) {
80
- clearTimeout(pendingSearch.current.timer);
81
- }
82
- Promise.resolve().then(() => {
83
- // oxlint-disable-next-line react-hooks/exhaustive-deps -- The live effect version distinguishes dependency cleanup from a real unmount.
84
- if (effectVersion.current === currentVersion) {
85
- flush();
86
- }
87
- });
88
- };
89
- }, [query, surface, category, isOpen, flush]);
90
- return flush;
91
- };
@@ -1,5 +0,0 @@
1
- /**
2
- * Immutable context used while resolving a TypeAhead surface.
3
- */
4
-
5
- export const TYPE_AHEAD_SURFACE_CONTEXT = Symbol('type-ahead-surface-context');
@@ -1,11 +0,0 @@
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}
@@ -1,50 +0,0 @@
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 { Box } from '@atlaskit/primitives/compiled/box';
9
- import { Text } from '@atlaskit/primitives/compiled/text';
10
- import { messages } from './messages';
11
- var NoResultsIllustration = lazy(function () {
12
- return import( /* webpackChunkName: "@atlaskit-internal_editor-quick-insert-no-results" */
13
- './assets/no-results').then(function (module) {
14
- return module.default;
15
- });
16
- });
17
- var styles = {
18
- base: "_zulp1ejb _4cvr1h6o _1e0c1txw _2lx21bp4 _1bah1h6o _1bsb1osq",
19
- compact: "_1rjcxy5q",
20
- spacious: "_1rjcoahv",
21
- inlineIllustration: "_4t3i1h39 _1bsb1mcy",
22
- fullIllustration: "_4t3io7ol _1bsbtudo"
23
- };
24
- export var QuickInsertEmptyState = function QuickInsertEmptyState(_ref) {
25
- var mode = _ref.mode,
26
- _ref$spacing = _ref.spacing,
27
- spacing = _ref$spacing === void 0 ? mode === 'full' ? 'spacious' : 'compact' : _ref$spacing;
28
- var _useIntl = useIntl(),
29
- formatMessage = _useIntl.formatMessage;
30
- var illustrationSize = mode === 'full' ? {
31
- width: 76,
32
- height: 84
33
- } : {
34
- width: 57,
35
- height: 63
36
- };
37
- return /*#__PURE__*/React.createElement(Box, {
38
- testId: "quick-insert-empty-state",
39
- xcss: cx(styles.base, styles[spacing])
40
- }, /*#__PURE__*/React.createElement(Box, {
41
- xcss: mode === 'full' ? styles.fullIllustration : styles.inlineIllustration
42
- }, /*#__PURE__*/React.createElement(LazySuspense, {
43
- fallback: null
44
- }, /*#__PURE__*/React.createElement(NoResultsIllustration, {
45
- width: illustrationSize.width,
46
- height: illustrationSize.height
47
- }))), /*#__PURE__*/React.createElement(Text, {
48
- align: "center"
49
- }, formatMessage(messages.noSearchResults)));
50
- };
@@ -1,6 +0,0 @@
1
- import React from 'react';
2
- import MenuGroup from '@atlaskit/menu/menu-group';
3
- export var QuickInsertMenuRoot = function QuickInsertMenuRoot(_ref) {
4
- var children = _ref.children;
5
- return /*#__PURE__*/React.createElement(MenuGroup, null, children);
6
- };
@@ -1,16 +0,0 @@
1
- import React from 'react';
2
- import HeadingItem from '@atlaskit/menu/heading-item';
3
- import { Box } from '@atlaskit/primitives/compiled/box';
4
- export var QuickInsertMenuSection = function QuickInsertMenuSection(_ref) {
5
- var children = _ref.children,
6
- title = _ref.title;
7
- return /*#__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);
16
- };
@@ -1,12 +0,0 @@
1
- import React from 'react';
2
- import { useIntl } from 'react-intl';
3
- import { messages } from './messages';
4
- import { QuickInsertMenuSection } from './QuickInsertMenuSection';
5
- export var QuickInsertSearchResultsSection = function QuickInsertSearchResultsSection(_ref) {
6
- var children = _ref.children;
7
- var _useIntl = useIntl(),
8
- formatMessage = _useIntl.formatMessage;
9
- return /*#__PURE__*/React.createElement(QuickInsertMenuSection, {
10
- title: formatMessage(messages.searchResults)
11
- }, children);
12
- };
@@ -1,29 +0,0 @@
1
- import React from 'react';
2
- export default function NoResultsIllustration(_ref) {
3
- var height = _ref.height,
4
- width = _ref.width;
5
- return /*#__PURE__*/React.createElement("svg", {
6
- width: width,
7
- height: height,
8
- viewBox: "0 0 57 63",
9
- fill: "none",
10
- xmlns: "http://www.w3.org/2000/svg",
11
- "aria-hidden": "true",
12
- focusable: "false"
13
- }, /*#__PURE__*/React.createElement("path", {
14
- fill: "#dddee1",
15
- d: "M23.5 49.223c-5.196 0-10.166-1.955-14.442-5.814a30 30 0 0 1-3.545-3.85 29.6 29.6 0 0 1-2.868-4.456c-4.56-8.775-3.179-18.124 3.79-25.647a32.6 32.6 0 0 1 3.942-3.593 32 32 0 0 1 4.287-2.81c9.017-4.89 18.424-3.869 25.803 2.8a30.3 30.3 0 0 1 3.59 3.897 29.7 29.7 0 0 1 2.837 4.396C51.5 22.96 50.12 32.324 43.106 39.83a31.5 31.5 0 0 1-3.797 3.442 33 33 0 0 1-4.468 2.912c-3.777 2.03-7.62 3.036-11.341 3.036zm2.478-44.539c-2.957 0-6.02.824-9.082 2.489a28 28 0 0 0-3.658 2.396 27.5 27.5 0 0 0-3.37 3.07C4.24 18.711 3.15 25.92 6.798 32.941a25 25 0 0 0 2.42 3.75 25 25 0 0 0 2.981 3.24c5.866 5.299 13.119 6.054 20.427 2.13a27.4 27.4 0 0 0 3.818-2.492 27.5 27.5 0 0 0 3.24-2.936c5.658-6.054 6.741-13.27 3.06-20.318a25 25 0 0 0-2.39-3.698 25.3 25.3 0 0 0-3.021-3.289c-3.418-3.086-7.288-4.645-11.348-4.645z"
16
- }), /*#__PURE__*/React.createElement("path", {
17
- fill: "#dddee1",
18
- d: "M42.822 42.291c-1.21-1.685-2.509-1.675-3.777-.694-1.19.92-1.507 2.164-.24 3.801l1.45 1.873 4.017-3.107z"
19
- }), /*#__PURE__*/React.createElement("path", {
20
- fill: "#dddee1",
21
- d: "m45.28 43.385-6.03 4.663 11.332 14.657 6.03-4.663z"
22
- }), /*#__PURE__*/React.createElement("path", {
23
- fill: "#b7b9be",
24
- d: "m44.31 44.134-4.091 3.163 3.843 4.97 4.091-3.163z"
25
- }), /*#__PURE__*/React.createElement("path", {
26
- fill: "#dddee1",
27
- d: "M26.834 30.328h-3.42v-.217c-.116-2.432 1.264-5.066 3.227-6.143l.037-.02q.08-.042.154-.093c1.071-.69 1.68-1.88 1.643-3.189-.037-1.298-.707-2.439-1.791-3.052a4.5 4.5 0 0 0-2.21-.592c-2.315 0-4.198 1.897-4.198 4.229h-3.42c0-4.23 3.417-7.672 7.618-7.672a7.9 7.9 0 0 1 3.884 1.033c2.14 1.211 3.462 3.437 3.534 5.955.073 2.53-1.125 4.84-3.203 6.18q-.211.139-.424.251c-.815.458-1.497 1.868-1.434 2.97zM24.795 32.303a3.4 3.4 0 0 1 1.096-.004c1.115.183 2.021.965 2.241 2.182l.002.01.002.009a3.4 3.4 0 0 1-.002 1.103v.004c-.216 1.23-1.136 2.009-2.247 2.19a3.417 3.417 0 0 1-1.085-.003c-1.117-.18-2.027-.961-2.249-2.179l-.002-.01-.001-.01a3.3 3.3 0 0 1 0-1.095l.002-.01.001-.01c.223-1.223 1.137-1.992 2.24-2.177z"
28
- }));
29
- }