@atlaskit/editor-common
Version:
A package that contains common classes and components for editor and renderer
815 lines (808 loc) • 31.8 kB
JavaScript
import _extends from "@babel/runtime/helpers/extends";
import _slicedToArray from "@babel/runtime/helpers/slicedToArray";
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
var _excluded = ["items", "mode", "selectedItemIndex", "focusedItemIndex", "columnCount", "setColumnCount", "createAnalyticsEvent", "emptyStateHandler", "selectedCategory", "selectedCategoryIndex", "searchTerm", "setFocusedCategoryIndex", "setFocusedItemIndex"],
_excluded2 = ["items", "mode", "selectedItemIndex", "focusedItemIndex", "columnCount", "setColumnCount", "createAnalyticsEvent", "emptyStateHandler", "selectedCategory", "selectedCategoryIndex", "searchTerm", "setFocusedCategoryIndex", "setFocusedItemIndex"];
/**
* @jsxRuntime classic
* @jsx jsx
*/
import React, { Fragment, memo, useCallback, useEffect, useMemo, useState } from 'react';
// eslint-disable-next-line @atlaskit/ui-styling-standard/use-compiled -- Ignored via go/DSP-18766
import { css, jsx } from '@emotion/react';
import { Grid, List } from 'react-virtualized';
import { AutoSizer } from 'react-virtualized/dist/commonjs/AutoSizer';
import { CellMeasurer, CellMeasurerCache } from 'react-virtualized/dist/commonjs/CellMeasurer';
import withAnalyticsContext from '@atlaskit/analytics-next/withAnalyticsContext';
import { relativeFontSizeToBase16 } from '@atlaskit/editor-shared-styles';
import { shortcutStyle } from '@atlaskit/editor-shared-styles/shortcut';
import { ButtonItem } from '@atlaskit/menu';
import { fg } from '@atlaskit/platform-feature-flags';
import { Stack, Text } from '@atlaskit/primitives';
import Tooltip from '@atlaskit/tooltip';
import { ACTION, ACTION_SUBJECT, EVENT_TYPE, fireAnalyticsEvent } from '../../../analytics';
import { IconFallback } from '../../../quick-insert';
import { ELEMENT_ITEM_HEIGHT, ELEMENT_ITEM_PADDING, ELEMENT_LIST_PADDING, SCROLLBAR_WIDTH } from '../../constants';
import useContainerWidth from '../../hooks/use-container-width';
import useFocus from '../../hooks/use-focus';
import { Modes } from '../../types';
import EmptyState from './EmptyState';
import { getColumnCount, getScrollbarWidth } from './utils';
export var ICON_HEIGHT = 40;
export var ICON_WIDTH = 40;
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-exported-styles -- Ignored via go/DSP-18766
export var itemIcon = css({
width: "".concat(ICON_WIDTH, "px"),
height: "".concat(ICON_HEIGHT, "px"),
overflow: 'hidden',
border: "1px solid ".concat("var(--ds-border, rgba(223, 225, 229, 0.5))"),
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
borderRadius: "var(--ds-border-radius, 3px)",
boxSizing: 'border-box',
display: 'flex',
justifyContent: 'center',
alignItems: 'center',
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
div: {
width: "".concat(ICON_WIDTH, "px"),
height: "".concat(ICON_HEIGHT, "px")
}
});
function ElementListOld(_ref) {
var items = _ref.items,
mode = _ref.mode,
selectedItemIndex = _ref.selectedItemIndex,
focusedItemIndex = _ref.focusedItemIndex,
columnCount = _ref.columnCount,
setColumnCount = _ref.setColumnCount,
createAnalyticsEvent = _ref.createAnalyticsEvent,
emptyStateHandler = _ref.emptyStateHandler,
selectedCategory = _ref.selectedCategory,
selectedCategoryIndex = _ref.selectedCategoryIndex,
searchTerm = _ref.searchTerm,
setFocusedCategoryIndex = _ref.setFocusedCategoryIndex,
setFocusedItemIndex = _ref.setFocusedItemIndex,
props = _objectWithoutProperties(_ref, _excluded);
var _useContainerWidth = useContainerWidth(),
containerWidth = _useContainerWidth.containerWidth,
ContainerWidthMonitor = _useContainerWidth.ContainerWidthMonitor;
var _useState = useState(SCROLLBAR_WIDTH),
_useState2 = _slicedToArray(_useState, 2),
scrollbarWidth = _useState2[0],
setScrollbarWidth = _useState2[1];
var fullMode = mode === Modes.full;
useEffect(function () {
/**
* More of an optimization condition.
* Initially the containerWidths are reported 0 twice.
**/
if (fullMode && containerWidth > 0) {
setColumnCount(getColumnCount(containerWidth));
var updatedScrollbarWidth = getScrollbarWidth();
if (updatedScrollbarWidth > 0) {
setScrollbarWidth(updatedScrollbarWidth);
}
}
}, [fullMode, containerWidth, setColumnCount, scrollbarWidth]);
var onExternalLinkClick = useCallback(function () {
fireAnalyticsEvent(createAnalyticsEvent)({
payload: {
action: ACTION.VISITED,
actionSubject: ACTION_SUBJECT.SMART_LINK,
eventType: EVENT_TYPE.TRACK
}
});
}, [createAnalyticsEvent]);
var cache = useMemo(function () {
return new CellMeasurerCache({
fixedWidth: true,
defaultHeight: 75,
minHeight: 75
});
}, []);
var columnWidth = (containerWidth - ELEMENT_ITEM_PADDING * 2) / columnCount;
var rowCount = Math.ceil(items.length / columnCount);
var rowHeight = function rowHeight(_ref2) {
var index = _ref2.index;
return cache.rowHeight({
index: index
}) <= 75 ? 75 : cache.rowHeight({
index: index
}) + ELEMENT_ITEM_PADDING * 2;
};
var cellRenderer = useMemo(function () {
return function (_ref3) {
var columnIndex = _ref3.columnIndex,
key = _ref3.key,
parent = _ref3.parent,
rowIndex = _ref3.rowIndex,
style = _ref3.style;
var index = rowIndex * columnCount + columnIndex;
if (items[index] == null) {
return;
}
return index > items.length - 1 ? null : jsx(CellMeasurer, {
cache: cache,
key: key,
rowIndex: rowIndex,
columnIndex: columnIndex,
parent: parent
}, jsx("div", {
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
style: style,
key: key
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 -- Ignored via go/DSP-18766
,
className: "element-item-wrapper",
css: elementItemWrapper,
onKeyDown: function onKeyDown(e) {
if (e.key === 'Tab') {
if (e.shiftKey && index === 0) {
if (setFocusedCategoryIndex) {
if (!!selectedCategoryIndex) {
setFocusedCategoryIndex(selectedCategoryIndex);
} else {
setFocusedCategoryIndex(0);
}
e.preventDefault();
}
}
// before focus jumps from elements list we need to rerender react-virtualized grid.
// Otherwise on the next render 'scrollToCell' will have same cached value
// and grid will not be scrolled to top.
// So Tab press on category will not work anymore due to invisible 1-t element.
else if (index === items.length - 2) {
setFocusedItemIndex(items.length - 1);
}
}
}
}, jsx(MemoizedElementItem, _extends({
inlineMode: !fullMode,
index: index,
item: items[index],
selected: selectedItemIndex === index,
focus: focusedItemIndex === index,
setFocusedItemIndex: setFocusedItemIndex
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, props))));
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[cache, items, fullMode, selectedItemIndex, columnCount, focusedItemIndex, selectedCategoryIndex, setFocusedCategoryIndex, setFocusedItemIndex, props]);
return jsx(Fragment, null, jsx(ContainerWidthMonitor, null), jsx("div", {
css: elementItemsWrapper,
"data-testid": "element-items",
id: selectedCategory ? "browse-category-".concat(selectedCategory, "-tab") : 'browse-category-tab',
"aria-labelledby": selectedCategory ? "browse-category--".concat(selectedCategory, "-button") : 'browse-category-button',
role: "tabpanel",
tabIndex: items.length === 0 ? 0 : undefined
}, !items.length ? emptyStateHandler ? emptyStateHandler({
mode: mode,
selectedCategory: selectedCategory,
searchTerm: searchTerm
}) : jsx(EmptyState, {
onExternalLinkClick: onExternalLinkClick
}) : jsx(Fragment, null, containerWidth > 0 && jsx(AutoSizer, {
disableWidth: true
}, function (_ref4) {
var height = _ref4.height;
return jsx(Grid, _extends({
cellRenderer: cellRenderer,
height: height,
width: containerWidth - ELEMENT_LIST_PADDING * 2 // containerWidth - padding on Left/Right (for focus outline)
/**
* Refresh Grid on WidthObserver value change.
* Length of the items used to force re-render to solve Firefox bug with react-virtualized retaining
* scroll position after updating the data. If new data has different number of cells, a re-render
* is forced to prevent the scroll position render bug.
*/,
key: containerWidth + items.length,
rowHeight: rowHeight,
rowCount: rowCount,
columnCount: columnCount,
columnWidth: columnWidth,
deferredMeasurementCache: cache
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, selectedItemIndex !== undefined && {
scrollToRow: Math.floor(selectedItemIndex / columnCount)
}));
}))));
}
function ElementListNew(_ref5) {
var items = _ref5.items,
mode = _ref5.mode,
selectedItemIndex = _ref5.selectedItemIndex,
focusedItemIndex = _ref5.focusedItemIndex,
columnCount = _ref5.columnCount,
setColumnCount = _ref5.setColumnCount,
createAnalyticsEvent = _ref5.createAnalyticsEvent,
emptyStateHandler = _ref5.emptyStateHandler,
selectedCategory = _ref5.selectedCategory,
selectedCategoryIndex = _ref5.selectedCategoryIndex,
searchTerm = _ref5.searchTerm,
setFocusedCategoryIndex = _ref5.setFocusedCategoryIndex,
setFocusedItemIndex = _ref5.setFocusedItemIndex,
cache = _ref5.cache,
onInsertItem = _ref5.onInsertItem;
var _useContainerWidth2 = useContainerWidth(),
containerWidth = _useContainerWidth2.containerWidth,
ContainerWidthMonitor = _useContainerWidth2.ContainerWidthMonitor;
var _useState3 = useState(SCROLLBAR_WIDTH),
_useState4 = _slicedToArray(_useState3, 2),
scrollbarWidth = _useState4[0],
setScrollbarWidth = _useState4[1];
var fullMode = mode === Modes.full;
useEffect(function () {
/**
* More of an optimization condition.
* Initially the containerWidths are reported 0 twice.
**/
if (fullMode && containerWidth > 0) {
setColumnCount(getColumnCount(containerWidth));
var updatedScrollbarWidth = getScrollbarWidth();
if (updatedScrollbarWidth > 0) {
setScrollbarWidth(updatedScrollbarWidth);
}
}
}, [fullMode, containerWidth, setColumnCount, scrollbarWidth]);
var onExternalLinkClick = useCallback(function () {
fireAnalyticsEvent(createAnalyticsEvent)({
payload: {
action: ACTION.VISITED,
actionSubject: ACTION_SUBJECT.SMART_LINK,
eventType: EVENT_TYPE.TRACK
}
});
}, [createAnalyticsEvent]);
var listCache = useMemo(function () {
return cache !== null && cache !== void 0 ? cache : new CellMeasurerCache({
fixedWidth: true,
defaultHeight: ELEMENT_ITEM_HEIGHT,
minHeight: ELEMENT_ITEM_HEIGHT
});
}, [cache]);
useEffect(function () {
// need to recalculate values if we have the same items, but they're reordered
listCache.clearAll();
}, [listCache, searchTerm]);
var rowHeight = function rowHeight(_ref6) {
var index = _ref6.index;
return listCache.rowHeight({
index: index
});
};
return jsx(Fragment, null, jsx(ContainerWidthMonitor, null), jsx("div", {
css: elementItemsWrapper,
"data-testid": "element-items",
id: selectedCategory ? "browse-category-".concat(selectedCategory, "-tab") : 'browse-category-tab',
"aria-labelledby": selectedCategory ? "browse-category--".concat(selectedCategory, "-button") : 'browse-category-button',
role: "tabpanel",
tabIndex: items.length === 0 ? 0 : undefined
}, !items.length ? emptyStateHandler ? emptyStateHandler({
mode: mode,
selectedCategory: selectedCategory,
searchTerm: searchTerm
}) : jsx(EmptyState, {
onExternalLinkClick: onExternalLinkClick
}) : jsx(Fragment, null, containerWidth > 0 && jsx(AutoSizer, {
disableWidth: true
}, function (_ref7) {
var height = _ref7.height;
return columnCount === 1 ? jsx(ElementListSingleColumn, {
cache: listCache,
setFocusedCategoryIndex: setFocusedCategoryIndex,
selectedCategoryIndex: selectedCategoryIndex,
items: items,
setFocusedItemIndex: setFocusedItemIndex,
fullMode: fullMode,
selectedItemIndex: selectedItemIndex,
focusedItemIndex: focusedItemIndex,
rowHeight: rowHeight,
containerWidth: containerWidth,
height: height,
onInsertItem: onInsertItem
}) : jsx(ElementListMultipleColumns, {
columnCount: columnCount,
cache: listCache,
setFocusedCategoryIndex: setFocusedCategoryIndex,
selectedCategoryIndex: selectedCategoryIndex,
items: items,
setFocusedItemIndex: setFocusedItemIndex,
fullMode: fullMode,
selectedItemIndex: selectedItemIndex,
focusedItemIndex: focusedItemIndex,
rowHeight: rowHeight,
containerWidth: containerWidth,
height: height,
onInsertItem: onInsertItem
});
}))));
}
var ElementListSingleColumn = function ElementListSingleColumn(props) {
var items = props.items,
fullMode = props.fullMode,
setFocusedItemIndex = props.setFocusedItemIndex,
rowHeight = props.rowHeight,
containerWidth = props.containerWidth,
height = props.height,
onInsertItem = props.onInsertItem,
cache = props.cache,
focusedItemIndex = props.focusedItemIndex,
setFocusedCategoryIndex = props.setFocusedCategoryIndex,
selectedCategoryIndex = props.selectedCategoryIndex,
selectedItemIndex = props.selectedItemIndex;
var rowRenderer = useMemo(function () {
return function (_ref8) {
var index = _ref8.index,
key = _ref8.key,
style = _ref8.style,
parent = _ref8.parent;
return jsx(CellMeasurer, {
key: key,
cache: cache,
parent: parent,
columnIndex: 0,
rowIndex: index
}, jsx("div", {
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
style: style,
key: key
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 -- Ignored via go/DSP-18766
,
className: "element-item-wrapper",
css: elementItemWrapperSingle,
onKeyDown: function onKeyDown(e) {
if (e.key === 'Tab') {
if (e.shiftKey && index === 0) {
if (setFocusedCategoryIndex) {
if (!!selectedCategoryIndex) {
setFocusedCategoryIndex(selectedCategoryIndex);
} else {
setFocusedCategoryIndex(0);
}
e.preventDefault();
}
}
// before focus jumps from elements list we need to rerender react-virtualized grid.
// Otherwise on the next render 'scrollToCell' will have same cached value
// and grid will not be scrolled to top.
// So Tab press on category will not work anymore due to invisible 1-t element.
else if (index === items.length - 2) {
setFocusedItemIndex(items.length - 1);
}
}
}
}, jsx(MemoizedElementItem, {
inlineMode: !fullMode,
index: index,
item: items[index],
selected: selectedItemIndex === index,
focus: focusedItemIndex === index,
setFocusedItemIndex: setFocusedItemIndex,
onInsertItem: onInsertItem
})));
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[cache, items, fullMode, selectedItemIndex, focusedItemIndex, selectedCategoryIndex, setFocusedCategoryIndex, setFocusedItemIndex, props]);
return jsx(List, _extends({
rowRenderer: rowRenderer,
rowCount: items.length,
rowHeight: rowHeight,
width: containerWidth - ELEMENT_LIST_PADDING * 2,
height: height,
overscanRowCount: 3,
containerRole: "presentation",
role: "listbox"
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, selectedItemIndex !== undefined && {
scrollToIndex: selectedItemIndex
}));
};
var ElementListMultipleColumns = function ElementListMultipleColumns(props) {
var columnCount = props.columnCount,
items = props.items,
fullMode = props.fullMode,
setFocusedItemIndex = props.setFocusedItemIndex,
rowHeight = props.rowHeight,
containerWidth = props.containerWidth,
height = props.height,
onInsertItem = props.onInsertItem,
cache = props.cache,
focusedItemIndex = props.focusedItemIndex,
setFocusedCategoryIndex = props.setFocusedCategoryIndex,
selectedCategoryIndex = props.selectedCategoryIndex,
selectedItemIndex = props.selectedItemIndex;
var columnWidth = (containerWidth - ELEMENT_ITEM_PADDING * 2) / columnCount;
var rowCount = Math.ceil(items.length / columnCount);
var cellRenderer = useMemo(function () {
return function (_ref9) {
var columnIndex = _ref9.columnIndex,
key = _ref9.key,
parent = _ref9.parent,
rowIndex = _ref9.rowIndex,
style = _ref9.style;
var index = rowIndex * columnCount + columnIndex;
if (items[index] == null) {
return;
}
return index > items.length - 1 ? null : jsx(CellMeasurer, {
cache: cache,
key: key,
rowIndex: rowIndex,
columnIndex: columnIndex,
parent: parent
}, jsx("div", {
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
style: style,
key: key
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766 -- Ignored via go/DSP-18766
,
className: "element-item-wrapper",
css: elementItemWrapper,
onKeyDown: function onKeyDown(e) {
if (e.key === 'Tab') {
if (e.shiftKey && index === 0) {
if (setFocusedCategoryIndex) {
if (!!selectedCategoryIndex) {
setFocusedCategoryIndex(selectedCategoryIndex);
} else {
setFocusedCategoryIndex(0);
}
e.preventDefault();
}
}
// before focus jumps from elements list we need to rerender react-virtualized grid.
// Otherwise on the next render 'scrollToCell' will have same cached value
// and grid will not be scrolled to top.
// So Tab press on category will not work anymore due to invisible 1-t element.
else if (index === items.length - 2) {
setFocusedItemIndex(items.length - 1);
}
}
}
}, jsx(MemoizedElementItem, {
inlineMode: !fullMode,
index: index,
item: items[index],
selected: selectedItemIndex === index,
focus: focusedItemIndex === index,
setFocusedItemIndex: setFocusedItemIndex,
onInsertItem: onInsertItem
})));
};
},
// eslint-disable-next-line react-hooks/exhaustive-deps
[cache, items, fullMode, selectedItemIndex, columnCount, focusedItemIndex, selectedCategoryIndex, setFocusedCategoryIndex, setFocusedItemIndex, props]);
return jsx(Grid, _extends({
cellRenderer: cellRenderer,
height: height,
width: containerWidth - ELEMENT_LIST_PADDING * 2 // containerWidth - padding on Left/Right (for focus outline)
/**
* Refresh Grid on WidthObserver value change.
* Length of the items used to force re-render to solve Firefox bug with react-virtualized retaining
* scroll position after updating the data. If new data has different number of cells, a re-render
* is forced to prevent the scroll position render bug.
*/,
key: containerWidth + items.length,
rowHeight: rowHeight,
rowCount: rowCount,
columnCount: columnCount,
columnWidth: columnWidth,
deferredMeasurementCache: cache
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, selectedItemIndex !== undefined && {
scrollToRow: Math.floor(selectedItemIndex / columnCount)
}));
};
var MemoizedElementItem = /*#__PURE__*/memo(ElementItem);
MemoizedElementItem.displayName = 'MemoizedElementItem';
export function ElementItem(_ref10) {
var inlineMode = _ref10.inlineMode,
selected = _ref10.selected,
item = _ref10.item,
index = _ref10.index,
onInsertItem = _ref10.onInsertItem,
focus = _ref10.focus,
setFocusedItemIndex = _ref10.setFocusedItemIndex;
var ref = useFocus(focus);
/**
* Note: props.onSelectItem(item) is not called here as the StatelessElementBrowser's
* useEffect would trigger it on selectedItemIndex change. (Line 106-110)
* This implementation was changed for keyboard/click selection to work with `onInsertItem`.
*/
var onClick = useCallback(function (e) {
e.preventDefault();
e.stopPropagation();
setFocusedItemIndex(index);
switch (e.nativeEvent.detail) {
case 0:
onInsertItem(item);
break;
case 1:
if (inlineMode) {
onInsertItem(item);
}
break;
case 2:
if (!inlineMode) {
onInsertItem(item);
}
break;
default:
return;
}
}, [index, inlineMode, item, onInsertItem, setFocusedItemIndex]);
var icon = item.icon,
title = item.title,
description = item.description,
keyshortcut = item.keyshortcut,
isDisabled = item.isDisabled;
return jsx(Tooltip, {
content: description,
testId: "element-item-tooltip-".concat(index)
}, jsx(ButtonItem, {
onClick: onClick,
iconBefore: jsx(ElementBefore, {
icon: icon,
title: title
}),
isSelected: selected,
"aria-describedby": title,
ref: ref,
testId: "element-item-".concat(index),
id: "searched-item-".concat(index),
isDisabled: isDisabled
}, jsx(ItemContent
// eslint-disable-next-line @atlaskit/ui-styling-standard/enforce-style-prop -- Ignored via go/DSP-18766
, {
style: inlineMode ? null : itemStyleOverrides,
tabIndex: 0,
title: title,
description: description,
keyshortcut: keyshortcut,
isDisabled: isDisabled
})));
}
/**
* Inline mode should use the existing Align-items:center value.
*/
var itemStyleOverrides = {
alignItems: 'flex-start'
};
var ElementBefore = /*#__PURE__*/memo(function (_ref11) {
var icon = _ref11.icon;
return jsx("div", {
css: [itemIcon, itemIconStyle]
}, icon ? icon() : jsx(IconFallback, null));
});
var ItemContent = /*#__PURE__*/memo(function (_ref12) {
var title = _ref12.title,
description = _ref12.description,
keyshortcut = _ref12.keyshortcut,
isDisabled = _ref12.isDisabled;
if (fg('platform_editor_typography_ugc')) {
return (
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
jsx("div", {
css: itemBody,
className: "item-body"
}, jsx("div", {
css: itemText
}, jsx(Stack, {
space: "space.025"
}, jsx("div", {
css: itemTitleWrapper
}, jsx(Text, {
color: isDisabled ? 'color.text.disabled' : undefined,
maxLines: 1
}, title), jsx("div", {
css: itemAfter
}, keyshortcut && jsx("div", {
css: shortcutStyle
}, keyshortcut))), description && jsx(Text, {
color: isDisabled ? 'color.text.disabled' : 'color.text.subtle',
size: "small",
maxLines: 2
}, description))))
);
} else {
return (
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-classname-prop -- Ignored via go/DSP-18766
jsx("div", {
css: itemBody,
className: "item-body"
}, jsx("div", {
css: itemText
}, jsx("div", {
css: itemTitleWrapper
}, jsx("p", {
css: isDisabled ? itemTitleDisabled : itemTitle
}, title), jsx("div", {
css: itemAfter
}, keyshortcut && jsx("div", {
css: shortcutStyle
}, keyshortcut))), description &&
// eslint-disable-next-line @atlaskit/design-system/use-primitives-text
jsx("p", {
css: isDisabled ? itemDescriptionDisabled : itemDescription
}, description)))
);
}
});
var elementItemsWrapper = css({
flex: 1,
flexFlow: 'row wrap',
alignItems: 'flex-start',
justifyContent: 'flex-start',
overflow: 'hidden',
padding: "var(--ds-space-025, 2px)",
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
'.ReactVirtualized__Grid': {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values -- Ignored via go/DSP-18766
borderRadius: '3px',
outline: 'none',
'&:focus': {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
boxShadow: "0 0 0 ".concat(ELEMENT_LIST_PADDING, "px ", "var(--ds-border-focused, #388BFF)")
}
},
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
'.ReactVirtualized__Grid__innerScrollContainer': {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors, @atlaskit/ui-styling-standard/no-unsafe-selectors -- Ignored via go/DSP-18766
"div[class='element-item-wrapper']:last-child": {
paddingBottom: "var(--ds-space-050, 4px)"
}
}
});
var elementItemWrapperSingle = css({
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
div: {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
button: {
minHeight: '60px',
alignItems: 'flex-start',
padding: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-150, 12px)", " 11px")
}
}
});
var elementItemWrapper = css({
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
div: {
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
button: {
minHeight: '75px',
alignItems: 'flex-start',
padding: "var(--ds-space-150, 12px)".concat(" ", "var(--ds-space-150, 12px)", " 11px")
}
}
});
var itemBody = css({
display: 'flex',
flexDirection: 'row',
flexWrap: 'nowrap',
justifyContent: 'space-between',
// eslint-disable-next-line @atlaskit/design-system/use-tokens-typography
lineHeight: 1.4,
width: '100%',
marginTop: "var(--ds-space-negative-025, -2px)"
});
/*
* -webkit-line-clamp is also supported by firefox 🎉
* https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/68#CSS
*/
var multilineStyle = css({
display: '-webkit-box',
WebkitLineClamp: 2,
WebkitBoxOrient: 'vertical'
});
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
var itemDescription = css(multilineStyle, {
overflow: 'hidden',
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
fontSize: relativeFontSizeToBase16(11.67),
color: "var(--ds-text-subtle, #44546F)",
marginTop: "var(--ds-space-025, 2px)"
});
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-unsafe-values, @atlaskit/design-system/consistent-css-prop-usage -- Ignored via go/DSP-18766
var itemDescriptionDisabled = css(multilineStyle, {
overflow: 'hidden',
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-imported-style-values, @atlaskit/ui-styling-standard/no-unsafe-values -- Ignored via go/DSP-18766
fontSize: relativeFontSizeToBase16(11.67),
color: "var(--ds-text-disabled, #091E424F)",
marginTop: "var(--ds-space-025, 2px)"
});
var itemText = css({
width: 'inherit',
whiteSpace: 'initial'
});
var itemTitleWrapper = css({
display: 'flex',
justifyContent: 'space-between'
});
var itemTitle = css({
width: '100%',
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis'
});
var itemTitleDisabled = css({
width: '100%',
overflow: 'hidden',
whiteSpace: 'nowrap',
textOverflow: 'ellipsis',
color: "var(--ds-text-disabled, #091E424F)"
});
var itemAfter = css({
flex: '0 0 auto',
paddingTop: "var(--ds-space-025, 2px)",
marginBottom: "var(--ds-space-negative-025, -2px)"
});
var itemIconStyle = css({
// eslint-disable-next-line @atlaskit/ui-styling-standard/no-nested-selectors -- Ignored via go/DSP-18766
img: {
height: '40px',
width: '40px',
objectFit: 'cover'
}
});
function ElementList(_ref13) {
var items = _ref13.items,
mode = _ref13.mode,
selectedItemIndex = _ref13.selectedItemIndex,
focusedItemIndex = _ref13.focusedItemIndex,
columnCount = _ref13.columnCount,
setColumnCount = _ref13.setColumnCount,
createAnalyticsEvent = _ref13.createAnalyticsEvent,
emptyStateHandler = _ref13.emptyStateHandler,
selectedCategory = _ref13.selectedCategory,
selectedCategoryIndex = _ref13.selectedCategoryIndex,
searchTerm = _ref13.searchTerm,
setFocusedCategoryIndex = _ref13.setFocusedCategoryIndex,
setFocusedItemIndex = _ref13.setFocusedItemIndex,
props = _objectWithoutProperties(_ref13, _excluded2);
if (fg('platform_editor_reduce_element_browser_padding')) {
return jsx(ElementListNew, _extends({
items: items,
mode: mode,
selectedItemIndex: selectedItemIndex,
focusedItemIndex: focusedItemIndex,
columnCount: columnCount,
setColumnCount: setColumnCount,
createAnalyticsEvent: createAnalyticsEvent,
emptyStateHandler: emptyStateHandler,
selectedCategory: selectedCategory,
selectedCategoryIndex: selectedCategoryIndex,
searchTerm: searchTerm,
setFocusedCategoryIndex: setFocusedCategoryIndex,
setFocusedItemIndex: setFocusedItemIndex
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, props));
}
return jsx(ElementListOld, _extends({
items: items,
mode: mode,
selectedItemIndex: selectedItemIndex,
focusedItemIndex: focusedItemIndex,
columnCount: columnCount,
setColumnCount: setColumnCount,
createAnalyticsEvent: createAnalyticsEvent,
emptyStateHandler: emptyStateHandler,
selectedCategory: selectedCategory,
selectedCategoryIndex: selectedCategoryIndex,
searchTerm: searchTerm,
setFocusedCategoryIndex: setFocusedCategoryIndex,
setFocusedItemIndex: setFocusedItemIndex
// Ignored via go/ees005
// eslint-disable-next-line react/jsx-props-no-spreading
}, props));
}
var MemoizedElementListWithAnalytics = /*#__PURE__*/memo(withAnalyticsContext({
component: 'ElementList'
})(ElementList));
export default MemoizedElementListWithAnalytics;