@antscorp/antsomi-ui 2.0.86-text-editor-beta.5 → 2.0.86
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/es/assets/css/main.scss +2 -4
- package/es/components/molecules/EmojiPopover/EmojiPopover.js +1 -5
- package/es/components/molecules/VirtualizedMenu/VirtualizedMenu.d.ts +3 -6
- package/es/components/molecules/VirtualizedMenu/__mocks__/index.js +982 -2594
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.d.ts +3 -13
- package/es/components/molecules/VirtualizedMenu/components/Item/Item.js +25 -53
- package/es/components/molecules/VirtualizedMenu/components/Item/index.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/MenuInline.js +46 -289
- package/es/components/molecules/VirtualizedMenu/components/MenuInline/index.js +0 -1
- package/es/components/molecules/VirtualizedMenu/styled.d.ts +1 -1
- package/es/components/molecules/VirtualizedMenu/styled.js +4 -23
- package/es/components/molecules/VirtualizedMenu/types.d.ts +9 -6
- package/es/components/molecules/VirtualizedMenu/utils.d.ts +5 -8
- package/es/components/molecules/VirtualizedMenu/utils.js +18 -13
- package/es/components/molecules/index.d.ts +0 -1
- package/es/components/molecules/index.js +0 -1
- package/es/components/organism/index.d.ts +0 -1
- package/es/components/organism/index.js +0 -1
- package/es/components/template/Layout/constants/permission.d.ts +1 -0
- package/es/components/template/Layout/constants/permission.js +1 -1
- package/es/hooks/index.d.ts +0 -1
- package/es/hooks/index.js +0 -1
- package/es/utils/common.d.ts +9 -6
- package/es/utils/common.js +23 -44
- package/es/utils/index.d.ts +0 -1
- package/es/utils/index.js +0 -1
- package/es/utils/web.d.ts +0 -4
- package/es/utils/web.js +0 -25
- package/package.json +3 -29
- package/es/components/index.scss +0 -2
- package/es/components/molecules/FontSizeInput/FontSizeInput.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/FontSizeInput.js +0 -128
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.d.ts +0 -8
- package/es/components/molecules/FontSizeInput/components/FontSizeControl.js +0 -14
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.d.ts +0 -20
- package/es/components/molecules/FontSizeInput/components/FontSizeDropdown.js +0 -17
- package/es/components/molecules/FontSizeInput/constants.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/constants.js +0 -5
- package/es/components/molecules/FontSizeInput/index.d.ts +0 -2
- package/es/components/molecules/FontSizeInput/index.js +0 -1
- package/es/components/molecules/FontSizeInput/styled.d.ts +0 -3
- package/es/components/molecules/FontSizeInput/styled.js +0 -22
- package/es/components/molecules/FontSizeInput/styles.scss +0 -15
- package/es/components/molecules/FontSizeInput/types.d.ts +0 -24
- package/es/components/molecules/FontSizeInput/types.js +0 -1
- package/es/components/molecules/FontSizeInput/utils.d.ts +0 -7
- package/es/components/molecules/FontSizeInput/utils.js +0 -9
- package/es/components/molecules/index.scss +0 -1
- package/es/components/organism/ActivityTimeline/__mocks__/event_tracking.json +0 -1290
- package/es/components/organism/ActivityTimeline/__mocks__/timeline.json +0 -3059
- package/es/components/organism/TextEditor/TextEditor.d.ts +0 -3
- package/es/components/organism/TextEditor/TextEditor.js +0 -251
- package/es/components/organism/TextEditor/__mocks__/text-block.settings.json +0 -320
- package/es/components/organism/TextEditor/__mocks__/text-contennt.d.ts +0 -1
- package/es/components/organism/TextEditor/__mocks__/text-contennt.js +0 -38
- package/es/components/organism/TextEditor/constants.d.ts +0 -135
- package/es/components/organism/TextEditor/constants.js +0 -280
- package/es/components/organism/TextEditor/extensions/BackgroundColor.d.ts +0 -25
- package/es/components/organism/TextEditor/extensions/BackgroundColor.js +0 -46
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.d.ts +0 -130
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu-plugin.js +0 -247
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/BubbleMenu/bubble-menu.js +0 -31
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.d.ts +0 -2
- package/es/components/organism/TextEditor/extensions/BubbleMenu/index.js +0 -2
- package/es/components/organism/TextEditor/extensions/Color.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Color.js +0 -41
- package/es/components/organism/TextEditor/extensions/Emoji.d.ts +0 -57
- package/es/components/organism/TextEditor/extensions/Emoji.js +0 -184
- package/es/components/organism/TextEditor/extensions/FontFamily.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/FontFamily.js +0 -43
- package/es/components/organism/TextEditor/extensions/FontSize.d.ts +0 -32
- package/es/components/organism/TextEditor/extensions/FontSize.js +0 -47
- package/es/components/organism/TextEditor/extensions/FontWeight.d.ts +0 -23
- package/es/components/organism/TextEditor/extensions/FontWeight.js +0 -41
- package/es/components/organism/TextEditor/extensions/Highlight.d.ts +0 -1
- package/es/components/organism/TextEditor/extensions/Highlight.js +0 -14
- package/es/components/organism/TextEditor/extensions/Indent.d.ts +0 -28
- package/es/components/organism/TextEditor/extensions/Indent.js +0 -68
- package/es/components/organism/TextEditor/extensions/LineHeight.d.ts +0 -20
- package/es/components/organism/TextEditor/extensions/LineHeight.js +0 -36
- package/es/components/organism/TextEditor/extensions/Link.d.ts +0 -15
- package/es/components/organism/TextEditor/extensions/Link.js +0 -50
- package/es/components/organism/TextEditor/extensions/ListItemMarker.d.ts +0 -13
- package/es/components/organism/TextEditor/extensions/ListItemMarker.js +0 -174
- package/es/components/organism/TextEditor/extensions/Selection.d.ts +0 -6
- package/es/components/organism/TextEditor/extensions/Selection.js +0 -40
- package/es/components/organism/TextEditor/extensions/SmartTag.d.ts +0 -39
- package/es/components/organism/TextEditor/extensions/SmartTag.js +0 -167
- package/es/components/organism/TextEditor/extensions/StyleMemory.d.ts +0 -36
- package/es/components/organism/TextEditor/extensions/StyleMemory.js +0 -163
- package/es/components/organism/TextEditor/extensions/TextTransform.d.ts +0 -31
- package/es/components/organism/TextEditor/extensions/TextTransform.js +0 -37
- package/es/components/organism/TextEditor/hooks/index.d.ts +0 -7
- package/es/components/organism/TextEditor/hooks/index.js +0 -7
- package/es/components/organism/TextEditor/hooks/useColorSet.d.ts +0 -4
- package/es/components/organism/TextEditor/hooks/useColorSet.js +0 -6
- package/es/components/organism/TextEditor/hooks/useDocumentState.d.ts +0 -18
- package/es/components/organism/TextEditor/hooks/useDocumentState.js +0 -42
- package/es/components/organism/TextEditor/hooks/useLinkHandler.d.ts +0 -10
- package/es/components/organism/TextEditor/hooks/useLinkHandler.js +0 -223
- package/es/components/organism/TextEditor/hooks/useMarkTracking.d.ts +0 -26
- package/es/components/organism/TextEditor/hooks/useMarkTracking.js +0 -68
- package/es/components/organism/TextEditor/hooks/usePersistence.d.ts +0 -31
- package/es/components/organism/TextEditor/hooks/usePersistence.js +0 -169
- package/es/components/organism/TextEditor/hooks/useStyleMemory.d.ts +0 -6
- package/es/components/organism/TextEditor/hooks/useStyleMemory.js +0 -42
- package/es/components/organism/TextEditor/hooks/useStylePresets.d.ts +0 -34
- package/es/components/organism/TextEditor/hooks/useStylePresets.js +0 -83
- package/es/components/organism/TextEditor/index.d.ts +0 -14
- package/es/components/organism/TextEditor/index.js +0 -6
- package/es/components/organism/TextEditor/index.scss +0 -61
- package/es/components/organism/TextEditor/provider.d.ts +0 -12
- package/es/components/organism/TextEditor/provider.js +0 -34
- package/es/components/organism/TextEditor/store.d.ts +0 -13
- package/es/components/organism/TextEditor/store.js +0 -20
- package/es/components/organism/TextEditor/styled.d.ts +0 -8
- package/es/components/organism/TextEditor/styled.js +0 -90
- package/es/components/organism/TextEditor/types.d.ts +0 -92
- package/es/components/organism/TextEditor/types.js +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/BubbleMenu/BubbleMenu.js +0 -78
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/BubbleMenu/index.js +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.d.ts +0 -43
- package/es/components/organism/TextEditor/ui/ColorPicker/ColorPicker.js +0 -132
- package/es/components/organism/TextEditor/ui/ColorPicker/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/ColorPicker/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.d.ts +0 -11
- package/es/components/organism/TextEditor/ui/Emoji/EmojiList.js +0 -66
- package/es/components/organism/TextEditor/ui/Emoji/index.d.ts +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/index.js +0 -2
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Emoji/suggestion.js +0 -71
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.d.ts +0 -12
- package/es/components/organism/TextEditor/ui/FontPopover/FontPopover.js +0 -69
- package/es/components/organism/TextEditor/ui/FontPopover/styled.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/FontPopover/styled.js +0 -20
- package/es/components/organism/TextEditor/ui/Popover/Popover.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Popover/Popover.js +0 -7
- package/es/components/organism/TextEditor/ui/Popover/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Popover/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Select/Select.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Select/Select.js +0 -7
- package/es/components/organism/TextEditor/ui/Select/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Select/index.js +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.d.ts +0 -30
- package/es/components/organism/TextEditor/ui/TextAlignSelect/TextAlignSelect.js +0 -49
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/TextAlignSelect/index.js +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.d.ts +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/Toolbar.js +0 -42
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BoldAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/BulletListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ClearFormattingAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.d.ts +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/EmojiAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontFamilyAction.js +0 -18
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/FontSizeAction.js +0 -37
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/HighlightAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/IndentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/ItalicAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/LinkAction.js +0 -4
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OrderedListAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/OutdentAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SmartTagAction.js +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.d.ts +0 -9
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SpacingAction.js +0 -22
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/StrikeAction.js +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SubscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/SuperscriptAction.js +0 -13
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextAlignAction.js +0 -3
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.d.ts +0 -7
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextBackgroundColorAction.js +0 -19
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.d.ts +0 -15
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextColorAction.js +0 -14
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/TextTransformAction.js +0 -30
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.d.ts +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnderlineAction.js +0 -5
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.d.ts +0 -6
- package/es/components/organism/TextEditor/ui/Toolbar/actions/UnsetLink.js +0 -10
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.d.ts +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/actions/index.js +0 -20
- package/es/components/organism/TextEditor/ui/Toolbar/index.d.ts +0 -1
- package/es/components/organism/TextEditor/ui/Toolbar/index.js +0 -1
- package/es/components/organism/TextEditor/utils/documentState.d.ts +0 -57
- package/es/components/organism/TextEditor/utils/documentState.js +0 -100
- package/es/components/organism/TextEditor/utils/font.d.ts +0 -84
- package/es/components/organism/TextEditor/utils/font.js +0 -175
- package/es/components/organism/TextEditor/utils/htmlProcessing.d.ts +0 -63
- package/es/components/organism/TextEditor/utils/htmlProcessing.js +0 -319
- package/es/components/organism/TextEditor/utils/index.d.ts +0 -8
- package/es/components/organism/TextEditor/utils/index.js +0 -16
- package/es/components/organism/TextEditor/utils/link.d.ts +0 -100
- package/es/components/organism/TextEditor/utils/link.js +0 -149
- package/es/components/organism/TextEditor/utils/menu.d.ts +0 -134
- package/es/components/organism/TextEditor/utils/menu.js +0 -317
- package/es/components/organism/TextEditor/utils/selection.d.ts +0 -25
- package/es/components/organism/TextEditor/utils/selection.js +0 -57
- package/es/components/organism/TextEditor/utils/smartTag.d.ts +0 -49
- package/es/components/organism/TextEditor/utils/smartTag.js +0 -89
- package/es/components/organism/TextEditor/utils/style.d.ts +0 -78
- package/es/components/organism/TextEditor/utils/style.js +0 -193
- package/es/components/organism/index.scss +0 -1
- package/es/hooks/useBroadcastedLocalStorage.d.ts +0 -5
- package/es/hooks/useBroadcastedLocalStorage.js +0 -71
- package/es/hooks/useElementSize.d.ts +0 -7
- package/es/hooks/useElementSize.js +0 -56
- package/es/utils/tree.d.ts +0 -225
- package/es/utils/tree.js +0 -469
|
@@ -1,24 +1,14 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
|
-
import { ItemType, MenuInlineProps } from '../../types';
|
|
2
|
+
import { ItemType, MenuInlineProps, SerializedItemType } from '../../types';
|
|
3
3
|
import { ListChildComponentProps } from 'react-window';
|
|
4
|
-
import { NormalizedNode } from '@antscorp/antsomi-ui/es/utils/tree';
|
|
5
4
|
export type MemoryData = {
|
|
6
5
|
itemSpacing: number;
|
|
7
6
|
inlineIndent: number;
|
|
8
7
|
inlinePadding: number;
|
|
8
|
+
items: SerializedItemType[];
|
|
9
9
|
selectedKeys: Set<string>;
|
|
10
10
|
expandedKeys: Set<string>;
|
|
11
|
-
items: NormalizedNode<ItemType & {
|
|
12
|
-
ref: (el: HTMLLIElement) => void;
|
|
13
|
-
}>[];
|
|
14
|
-
normalizeTreeItems: Map<string, NormalizedNode<ItemType>>;
|
|
15
11
|
action: MenuInlineProps['action'];
|
|
16
|
-
|
|
17
|
-
onClick: (args: {
|
|
18
|
-
item: NormalizedNode<ItemType>;
|
|
19
|
-
index: number;
|
|
20
|
-
elKey: 'item' | 'item-expand-el';
|
|
21
|
-
domEvent: React.MouseEvent;
|
|
22
|
-
}) => void;
|
|
12
|
+
onClick: (item: ItemType, index: number) => void;
|
|
23
13
|
};
|
|
24
14
|
export declare const Item: React.MemoExoticComponent<(props: ListChildComponentProps<MemoryData>) => import("react/jsx-runtime").JSX.Element>;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { jsx as _jsx,
|
|
2
|
-
import { memo
|
|
1
|
+
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
|
2
|
+
import { memo } from 'react';
|
|
3
3
|
import { Typography } from '../../../../atoms/Typography';
|
|
4
4
|
import { MenuItemRoot } from '../../styled';
|
|
5
5
|
import clsx from 'clsx';
|
|
@@ -8,18 +8,11 @@ import { isEmpty } from 'lodash';
|
|
|
8
8
|
import { CLS } from '../../utils';
|
|
9
9
|
import { ExpandMoreIcon } from '@antscorp/antsomi-ui/es/components/icons';
|
|
10
10
|
import { globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
11
|
-
import { isDescendant } from '@antscorp/antsomi-ui/es/utils/tree';
|
|
12
11
|
export const Item = memo((props) => {
|
|
13
12
|
const { style = {}, data, index = 0 } = props;
|
|
14
|
-
const { inlineIndent, itemSpacing, inlinePadding, items, selectedKeys, expandedKeys,
|
|
15
|
-
const itemRef = useRef(null);
|
|
13
|
+
const { inlineIndent, itemSpacing, inlinePadding, items, selectedKeys, expandedKeys, action, onClick, } = data || {};
|
|
16
14
|
const item = items[index];
|
|
17
|
-
const
|
|
18
|
-
const isFocused = item.id === focusId;
|
|
19
|
-
const expanded = hasChildren && expandedKeys.has(item.data.key);
|
|
20
|
-
const selected = selectedKeys.has(item.data.key);
|
|
21
|
-
const disabled = item.data?.disabled;
|
|
22
|
-
const indentSize = item.level * inlineIndent;
|
|
15
|
+
const indentSize = ((item.level || 0) - 1) * inlineIndent;
|
|
23
16
|
const itemStyle = {
|
|
24
17
|
...style,
|
|
25
18
|
paddingLeft: indentSize + inlinePadding,
|
|
@@ -28,50 +21,29 @@ export const Item = memo((props) => {
|
|
|
28
21
|
height: index === 0 ? Number(style.height) : Number(style.height) - itemSpacing,
|
|
29
22
|
};
|
|
30
23
|
const itemClassName = clsx(CLS.Item.default, {
|
|
31
|
-
[CLS.Item.selected]:
|
|
32
|
-
[CLS.Item.expanded]:
|
|
33
|
-
[CLS.Item.disabled]: disabled,
|
|
34
|
-
}, item.
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
24
|
+
[CLS.Item.selected]: selectedKeys.has(item.key),
|
|
25
|
+
[CLS.Item.expanded]: expandedKeys.has(item.key),
|
|
26
|
+
[CLS.Item.disabled]: item?.disabled,
|
|
27
|
+
}, item.className);
|
|
28
|
+
const handleOnClick = () => {
|
|
29
|
+
if (!onClick || item?.disabled)
|
|
37
30
|
return;
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
31
|
+
onClick(item, index);
|
|
32
|
+
};
|
|
33
|
+
const renderLabel = () => {
|
|
34
|
+
if (typeof item?.label === 'string') {
|
|
35
|
+
return _jsx(Typography.Text, { ellipsis: { tooltip: true }, children: item.label });
|
|
36
|
+
}
|
|
37
|
+
return item?.label;
|
|
45
38
|
};
|
|
46
|
-
const
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
}, children: item.data.label })) : (item.data?.label);
|
|
51
|
-
const expandEl = (_jsx(ExpandMoreIcon, { size: 20, "aria-hidden": "true", color: globalToken?.colorIcon, className: CLS.IconExpand.default, onClick: e => {
|
|
52
|
-
e.stopPropagation();
|
|
53
|
-
handleOnClick(e, 'item-expand-el');
|
|
54
|
-
} }));
|
|
55
|
-
let actionContent = hasChildren ? _jsx("div", { className: CLS.ItemAction.default, children: expandEl }) : null;
|
|
56
|
-
if (action) {
|
|
57
|
-
actionContent = (_jsx("div", { className: CLS.ItemAction.default, children: typeof action === 'function' ? (action(item.data, { expandEl })) : (_jsxs(_Fragment, { children: [expandEl, action] })) }));
|
|
58
|
-
}
|
|
59
|
-
const isSelectedDescendant = useMemo(() => {
|
|
60
|
-
let result = false;
|
|
61
|
-
for (const selectedKey of selectedKeys) {
|
|
62
|
-
if (result)
|
|
63
|
-
break;
|
|
64
|
-
result = isDescendant(item.id, selectedKey, normalizeTreeItems);
|
|
39
|
+
const renderAction = () => {
|
|
40
|
+
if (action) {
|
|
41
|
+
return (_jsx("div", { className: CLS.ItemAction.default, children: typeof action === 'function' ? action(item) : action }));
|
|
65
42
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
const className = clsx(itemClassName, {
|
|
69
|
-
[CLS.Item.selectedDescendant]: isSelectedDescendant,
|
|
70
|
-
});
|
|
71
|
-
useEffect(() => {
|
|
72
|
-
if (isFocused) {
|
|
73
|
-
itemRef.current?.focus({ preventScroll: true });
|
|
43
|
+
if (!isEmpty(item.children)) {
|
|
44
|
+
return (_jsx("div", { className: CLS.ItemAction.default, children: _jsx(ExpandMoreIcon, { color: globalToken?.colorIcon, size: 20, className: CLS.IconExpand.default }) }));
|
|
74
45
|
}
|
|
75
|
-
|
|
76
|
-
|
|
46
|
+
return null;
|
|
47
|
+
};
|
|
48
|
+
return (_jsxs(MenuItemRoot, { className: itemClassName, style: itemStyle, onClick: handleOnClick, children: [_jsx("div", { className: CLS.ItemLabel.default, children: renderLabel() }), renderAction()] }));
|
|
77
49
|
}, areEqual);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { Item
|
|
1
|
+
export { Item } from './Item';
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import React from 'react';
|
|
2
2
|
import { ItemType } from '../../types';
|
|
3
|
-
export declare const MenuInline: React.
|
|
3
|
+
export declare const MenuInline: React.ForwardRefExoticComponent<Partial<{
|
|
4
4
|
items: ItemType[];
|
|
5
5
|
inlineIndent: number;
|
|
6
6
|
inlinePadding: number;
|
|
@@ -8,16 +8,13 @@ export declare const MenuInline: React.MemoExoticComponent<React.ForwardRefExoti
|
|
|
8
8
|
selectable: boolean;
|
|
9
9
|
className: string;
|
|
10
10
|
itemSize: number;
|
|
11
|
-
selected: string
|
|
11
|
+
selected: string[];
|
|
12
12
|
expanded: string[];
|
|
13
13
|
onClick: (args: {
|
|
14
14
|
item: ItemType;
|
|
15
|
-
|
|
16
|
-
elKey: "item" | "item-expand-el";
|
|
15
|
+
pathKey: import("../../types").PathKey;
|
|
17
16
|
}) => void;
|
|
18
|
-
action: React.ReactNode | ((item: ItemType
|
|
19
|
-
expandEl: React.ReactNode;
|
|
20
|
-
}) => React.ReactNode);
|
|
17
|
+
action: React.ReactNode | ((item: ItemType) => React.ReactNode);
|
|
21
18
|
}> & {
|
|
22
19
|
mode?: "inline" | undefined;
|
|
23
|
-
} & React.RefAttributes<import("../../types").VirtualizedMenuBaseHandle
|
|
20
|
+
} & React.RefAttributes<import("../../types").VirtualizedMenuBaseHandle>>;
|
|
@@ -1,121 +1,17 @@
|
|
|
1
1
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
2
|
-
import { forwardRef, useEffect, useImperativeHandle,
|
|
2
|
+
import React, { forwardRef, useEffect, useImperativeHandle, useState, } from 'react';
|
|
3
3
|
import { StyledAutoSizer, VirtualizedMenuContainer } from '../../styled';
|
|
4
4
|
import { INLINE_INDENT, INLINE_PADDING, ITEM_SIZE, ITEM_SPACING } from '../../config';
|
|
5
|
-
import { CLS,
|
|
5
|
+
import { CLS, getFlattenItems, getItemSize } from '../../utils';
|
|
6
6
|
import { Item } from '../Item';
|
|
7
7
|
import { useDeepCompareEffect } from '@antscorp/antsomi-ui/es/hooks';
|
|
8
8
|
import clsx from 'clsx';
|
|
9
|
-
|
|
10
|
-
const
|
|
11
|
-
|
|
12
|
-
* Optimized function to compute visible items using breadth-first traversal
|
|
13
|
-
* instead of filtering all items
|
|
14
|
-
*/
|
|
15
|
-
const computeVisibleItemsOptimized = (normalizeTreeItems, rootItemIds, expandedKeys) => {
|
|
16
|
-
const visibleItems = [];
|
|
17
|
-
const queue = Array.from(rootItemIds);
|
|
18
|
-
// Process queue in breadth-first manner
|
|
19
|
-
let index = 0;
|
|
20
|
-
while (index < queue.length) {
|
|
21
|
-
const itemId = queue[index++];
|
|
22
|
-
const item = normalizeTreeItems.get(itemId);
|
|
23
|
-
if (!item)
|
|
24
|
-
continue;
|
|
25
|
-
visibleItems.push(item);
|
|
26
|
-
// Add children to queue only if this item is expanded
|
|
27
|
-
if (expandedKeys.has(item.id) && item.childIds.length > 0) {
|
|
28
|
-
queue.push(...item.childIds);
|
|
29
|
-
}
|
|
30
|
-
}
|
|
31
|
-
return visibleItems;
|
|
32
|
-
};
|
|
33
|
-
/**
|
|
34
|
-
* Alternative: Path-based optimization with memoization
|
|
35
|
-
* Caches path calculations to avoid redundant work
|
|
36
|
-
*/
|
|
37
|
-
const computeVisibleItemsWithPathCache = (normalizeTreeItems, expandedKeys, pathCache) => {
|
|
38
|
-
const visibleItems = [];
|
|
39
|
-
for (const item of normalizeTreeItems.values()) {
|
|
40
|
-
const isRootItem = item.level === 0;
|
|
41
|
-
if (isRootItem) {
|
|
42
|
-
visibleItems.push(item);
|
|
43
|
-
continue;
|
|
44
|
-
}
|
|
45
|
-
if (!item.parentId)
|
|
46
|
-
continue;
|
|
47
|
-
// Use cached path or compute and cache
|
|
48
|
-
let pathToParent = pathCache.get(item.parentId);
|
|
49
|
-
if (!pathToParent) {
|
|
50
|
-
pathToParent = getPathToNode(item.parentId, normalizeTreeItems);
|
|
51
|
-
pathCache.set(item.parentId, pathToParent);
|
|
52
|
-
}
|
|
53
|
-
// Check if all parents are expanded
|
|
54
|
-
const allParentExpanded = pathToParent.every(parent => expandedKeys.has(parent.id));
|
|
55
|
-
if (allParentExpanded) {
|
|
56
|
-
visibleItems.push(item);
|
|
57
|
-
}
|
|
58
|
-
}
|
|
59
|
-
return visibleItems;
|
|
60
|
-
};
|
|
61
|
-
/**
|
|
62
|
-
* Level-based optimization: Process items level by level
|
|
63
|
-
* More efficient for deep trees with many collapsed branches
|
|
64
|
-
*/
|
|
65
|
-
const computeVisibleItemsByLevel = (normalizeTreeItems, rootItemIds, expandedKeys) => {
|
|
66
|
-
const visibleItems = [];
|
|
67
|
-
const expandedParents = new Set();
|
|
68
|
-
// Add root items and track expanded ones
|
|
69
|
-
for (const rootId of rootItemIds) {
|
|
70
|
-
const rootItem = normalizeTreeItems.get(rootId);
|
|
71
|
-
if (rootItem) {
|
|
72
|
-
visibleItems.push(rootItem);
|
|
73
|
-
if (expandedKeys.has(rootId)) {
|
|
74
|
-
expandedParents.add(rootId);
|
|
75
|
-
}
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
// Process each level
|
|
79
|
-
let currentLevelParents = expandedParents;
|
|
80
|
-
let currentLevel = 1;
|
|
81
|
-
while (currentLevelParents.size > 0) {
|
|
82
|
-
const nextLevelParents = new Set();
|
|
83
|
-
// Process all items at current level
|
|
84
|
-
for (const parentId of currentLevelParents) {
|
|
85
|
-
const parent = normalizeTreeItems.get(parentId);
|
|
86
|
-
if (!parent)
|
|
87
|
-
continue;
|
|
88
|
-
// Add all children of this expanded parent
|
|
89
|
-
for (const childId of parent.childIds) {
|
|
90
|
-
const child = normalizeTreeItems.get(childId);
|
|
91
|
-
if (child && child.level === currentLevel) {
|
|
92
|
-
visibleItems.push(child);
|
|
93
|
-
// Track if this child is expanded for next level
|
|
94
|
-
if (expandedKeys.has(childId)) {
|
|
95
|
-
nextLevelParents.add(childId);
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
currentLevelParents = nextLevelParents;
|
|
101
|
-
currentLevel++;
|
|
102
|
-
}
|
|
103
|
-
return visibleItems;
|
|
104
|
-
};
|
|
105
|
-
const MenuInlineInner = forwardRef((props, ref) => {
|
|
106
|
-
const { items: itemsProp = [], expanded: expandedProp = [], selected: selectedProp = [], inlineIndent = INLINE_INDENT, inlinePadding = INLINE_PADDING, itemSize = ITEM_SIZE, itemSpacing = ITEM_SPACING, selectable = false, action, className, onClick, } = props;
|
|
107
|
-
const [focusId, setFocusId] = useState(null);
|
|
9
|
+
const innerElementType = forwardRef(({ style, ...rest }, ref) => _jsx("div", { ref: ref, style: style, ...rest }));
|
|
10
|
+
const MenuInlineInner = (props, ref) => {
|
|
11
|
+
const { items: itemsProp = [], inlineIndent = INLINE_INDENT, inlinePadding = INLINE_PADDING, itemSize = ITEM_SIZE, itemSpacing = ITEM_SPACING, selectable = false, expanded: expandedProp = [], selected: selectedProp = [], action, className, onClick, } = props;
|
|
108
12
|
const [expandedKeys, setExpandedKeys] = useState(new Set());
|
|
109
13
|
const [selectedKeys, setSelectedKeys] = useState(new Set());
|
|
110
|
-
const
|
|
111
|
-
const itemRefs = useRef(new Map());
|
|
112
|
-
const [{ items: normalizeTreeItems, rootItemIds }, setTreeState] = useState({
|
|
113
|
-
items: new Map(),
|
|
114
|
-
rootItemIds: new Set(),
|
|
115
|
-
});
|
|
116
|
-
// Cache for path calculations to avoid redundant work
|
|
117
|
-
const pathCache = useMemo(() => new Map(), []);
|
|
118
|
-
const rootNodes = useMemo(() => findNodes(node => rootItemIds.has(node.id), normalizeTreeItems), [normalizeTreeItems, rootItemIds]);
|
|
14
|
+
const [flattenItems, setFlattenItems] = useState([]);
|
|
119
15
|
useDeepCompareEffect(() => {
|
|
120
16
|
setSelectedKeys(new Set(selectedProp));
|
|
121
17
|
}, [selectedProp]);
|
|
@@ -123,185 +19,54 @@ const MenuInlineInner = forwardRef((props, ref) => {
|
|
|
123
19
|
setExpandedKeys(new Set(expandedProp));
|
|
124
20
|
}, [expandedProp]);
|
|
125
21
|
useEffect(() => {
|
|
126
|
-
|
|
127
|
-
items: itemsProp,
|
|
128
|
-
}));
|
|
22
|
+
setFlattenItems(getFlattenItems({ items: itemsProp }));
|
|
129
23
|
}, [itemsProp]);
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
const
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
const expandedCount = expandedKeys.size;
|
|
142
|
-
// Strategy selection heuristics:
|
|
143
|
-
// - For shallow trees with many expanded items: use breadth-first
|
|
144
|
-
// - For deep trees with few expanded items: use level-based
|
|
145
|
-
// - For medium trees: use path-cache optimization
|
|
146
|
-
if (treeDepth <= 3 && expandedCount > totalItems * 0.3) {
|
|
147
|
-
// Shallow tree with many expanded items
|
|
148
|
-
return computeVisibleItemsOptimized(normalizeTreeItems, rootItemIds, expandedKeys);
|
|
149
|
-
}
|
|
150
|
-
if (treeDepth > 5 && expandedCount < totalItems * 0.2) {
|
|
151
|
-
// Deep tree with few expanded items
|
|
152
|
-
return computeVisibleItemsByLevel(normalizeTreeItems, rootItemIds, expandedKeys);
|
|
153
|
-
}
|
|
154
|
-
// Medium complexity - use cached path approach
|
|
155
|
-
return computeVisibleItemsWithPathCache(normalizeTreeItems, expandedKeys, pathCache);
|
|
156
|
-
}, [expandedKeys, normalizeTreeItems, rootItemIds, pathCache]);
|
|
157
|
-
const handleCollapseItems = useCallback((items) => {
|
|
158
|
-
setExpandedKeys(prev => {
|
|
159
|
-
const newOpenKeys = new Set(prev);
|
|
160
|
-
items.forEach(({ data }) => {
|
|
161
|
-
if (prev.has(data.key)) {
|
|
162
|
-
newOpenKeys.delete(data.key);
|
|
163
|
-
}
|
|
164
|
-
});
|
|
165
|
-
return newOpenKeys;
|
|
166
|
-
});
|
|
167
|
-
}, []);
|
|
168
|
-
useEffect(() => {
|
|
169
|
-
if (focusId && listRef.current) {
|
|
170
|
-
const index = visibleItems.findIndex(item => item.id === focusId);
|
|
171
|
-
if (index !== -1) {
|
|
172
|
-
listRef.current.scrollToItem(index, 'auto');
|
|
24
|
+
const visibleItems = flattenItems.filter(item => {
|
|
25
|
+
const isRootItem = item.level === 1;
|
|
26
|
+
const isParentExpand = item.parent && expandedKeys.has(String(item.parent.key));
|
|
27
|
+
return isRootItem || isParentExpand;
|
|
28
|
+
});
|
|
29
|
+
const handleCollapseItems = (items) => {
|
|
30
|
+
const newOpenKeys = new Set(expandedKeys);
|
|
31
|
+
getFlattenItems({ items }).forEach(i => {
|
|
32
|
+
const { key } = i;
|
|
33
|
+
if (expandedKeys.has(key)) {
|
|
34
|
+
newOpenKeys.delete(key);
|
|
173
35
|
}
|
|
174
|
-
}
|
|
175
|
-
}, [focusId, visibleItems]);
|
|
176
|
-
const handleExpandItems = useCallback((items, deep = 0) => {
|
|
177
|
-
setExpandedKeys(prev => {
|
|
178
|
-
const updatedExpandedKeys = new Set(prev);
|
|
179
|
-
items.forEach(item => {
|
|
180
|
-
const normalizeItem = normalizeTreeItems.get(item.data.key);
|
|
181
|
-
if (normalizeItem) {
|
|
182
|
-
updatedExpandedKeys.add(normalizeItem.id);
|
|
183
|
-
if (deep > 0) {
|
|
184
|
-
getChildrenRecursively(normalizeItem.id, normalizeTreeItems, normalizeItem.level + deep).forEach(v => updatedExpandedKeys.add(v.id));
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
});
|
|
188
|
-
return updatedExpandedKeys;
|
|
189
36
|
});
|
|
190
|
-
|
|
37
|
+
setExpandedKeys(newOpenKeys);
|
|
38
|
+
};
|
|
39
|
+
const handleExpandItems = (items) => {
|
|
40
|
+
const updatedExpandedKeys = new Set(expandedKeys);
|
|
41
|
+
items.forEach(item => {
|
|
42
|
+
if (!item.children?.length)
|
|
43
|
+
return;
|
|
44
|
+
updatedExpandedKeys.add(item.key);
|
|
45
|
+
});
|
|
46
|
+
setExpandedKeys(updatedExpandedKeys);
|
|
47
|
+
};
|
|
191
48
|
useImperativeHandle(ref, () => ({
|
|
192
49
|
expandAll: () => {
|
|
193
|
-
handleExpandItems(
|
|
50
|
+
handleExpandItems(flattenItems);
|
|
194
51
|
},
|
|
195
52
|
}));
|
|
196
|
-
const
|
|
197
|
-
const { key } = item
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
}, [selectable, selectedKeys]);
|
|
202
|
-
const handleToggleExpandItem = useCallback((item) => {
|
|
203
|
-
const { key } = item.data;
|
|
204
|
-
const isExpanded = expandedKeys.has(key);
|
|
205
|
-
if (isExpanded) {
|
|
53
|
+
const handleClickItem = (item, idx) => {
|
|
54
|
+
const { key } = item;
|
|
55
|
+
const isOpen = expandedKeys.has(key);
|
|
56
|
+
const hasChilren = !!item.children?.length;
|
|
57
|
+
if (hasChilren && isOpen) {
|
|
206
58
|
handleCollapseItems([item]);
|
|
207
59
|
}
|
|
208
|
-
|
|
60
|
+
if (hasChilren && !isOpen) {
|
|
209
61
|
handleExpandItems([item]);
|
|
210
62
|
}
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
const { item, elKey, domEvent } = args;
|
|
214
|
-
const node = normalizeTreeItems.get(item.id);
|
|
215
|
-
if (!node)
|
|
216
|
-
return;
|
|
217
|
-
const hasChilren = node.childIds.length > 0;
|
|
218
|
-
handleSelectItem(node);
|
|
219
|
-
if (hasChilren) {
|
|
220
|
-
handleToggleExpandItem(node);
|
|
221
|
-
}
|
|
222
|
-
setFocusId(node.id);
|
|
223
|
-
onClick?.({ item: node.data, elKey, domEvent });
|
|
224
|
-
}, [normalizeTreeItems, handleSelectItem, handleToggleExpandItem, onClick]);
|
|
225
|
-
const handleKeyDown = useCallback((e) => {
|
|
226
|
-
if (visibleItems.length === 0)
|
|
227
|
-
return;
|
|
228
|
-
e.preventDefault();
|
|
229
|
-
const currentFocusIndex = visibleItems.findIndex(item => item.id === focusId);
|
|
230
|
-
if (currentFocusIndex === -1) {
|
|
231
|
-
setFocusId(visibleItems[0]?.id ?? null);
|
|
232
|
-
return;
|
|
233
|
-
}
|
|
234
|
-
const currentFocusItem = visibleItems[currentFocusIndex];
|
|
235
|
-
switch (e.key) {
|
|
236
|
-
case 'ArrowDown': {
|
|
237
|
-
const nextFocusIndex = Math.min(visibleItems.length - 1, currentFocusIndex + 1);
|
|
238
|
-
setFocusId(visibleItems[nextFocusIndex].id);
|
|
239
|
-
break;
|
|
240
|
-
}
|
|
241
|
-
case 'ArrowUp': {
|
|
242
|
-
const nextFocusIndex = Math.max(0, currentFocusIndex - 1);
|
|
243
|
-
setFocusId(visibleItems[nextFocusIndex].id);
|
|
244
|
-
break;
|
|
245
|
-
}
|
|
246
|
-
case 'ArrowRight': {
|
|
247
|
-
if (currentFocusItem.childIds.length > 0 && !expandedKeys.has(currentFocusItem.id)) {
|
|
248
|
-
handleExpandItems([currentFocusItem]);
|
|
249
|
-
}
|
|
250
|
-
break;
|
|
251
|
-
}
|
|
252
|
-
case 'ArrowLeft': {
|
|
253
|
-
if (currentFocusItem.childIds.length > 0 && expandedKeys.has(currentFocusItem.id)) {
|
|
254
|
-
handleCollapseItems([currentFocusItem]);
|
|
255
|
-
}
|
|
256
|
-
else if (currentFocusItem?.parentId) {
|
|
257
|
-
setFocusId(currentFocusItem.parentId);
|
|
258
|
-
}
|
|
259
|
-
break;
|
|
260
|
-
}
|
|
261
|
-
case 'Home': {
|
|
262
|
-
setFocusId(visibleItems[0].id);
|
|
263
|
-
break;
|
|
264
|
-
}
|
|
265
|
-
case 'End': {
|
|
266
|
-
setFocusId(visibleItems[visibleItems.length - 1].id);
|
|
267
|
-
break;
|
|
268
|
-
}
|
|
269
|
-
case 'Enter': {
|
|
270
|
-
if (currentFocusItem) {
|
|
271
|
-
handleSelectItem(currentFocusItem);
|
|
272
|
-
if (currentFocusItem.childIds.length > 0) {
|
|
273
|
-
handleToggleExpandItem(currentFocusItem);
|
|
274
|
-
}
|
|
275
|
-
onClick?.({
|
|
276
|
-
item: currentFocusItem.data,
|
|
277
|
-
elKey: 'item',
|
|
278
|
-
});
|
|
279
|
-
}
|
|
280
|
-
break;
|
|
281
|
-
}
|
|
282
|
-
default:
|
|
283
|
-
break;
|
|
284
|
-
}
|
|
285
|
-
}, [
|
|
286
|
-
visibleItems,
|
|
287
|
-
focusId,
|
|
288
|
-
expandedKeys,
|
|
289
|
-
onClick,
|
|
290
|
-
handleExpandItems,
|
|
291
|
-
handleCollapseItems,
|
|
292
|
-
handleSelectItem,
|
|
293
|
-
handleToggleExpandItem,
|
|
294
|
-
]);
|
|
295
|
-
const handleFocus = (e) => {
|
|
296
|
-
let isClickFont = false;
|
|
297
|
-
for (const itemEl of itemRefs.current.values()) {
|
|
298
|
-
if (isClickFont)
|
|
299
|
-
break;
|
|
300
|
-
isClickFont = itemEl.isSameNode(e.target) || itemEl.contains(e.target);
|
|
301
|
-
}
|
|
302
|
-
if (!isClickFont && !focusId && visibleItems.length > 0) {
|
|
303
|
-
setFocusId(visibleItems.at(0)?.id || null);
|
|
63
|
+
if (selectable && !hasChilren && !selectedKeys.has(key)) {
|
|
64
|
+
setSelectedKeys(new Set([item.key]));
|
|
304
65
|
}
|
|
66
|
+
onClick?.({
|
|
67
|
+
item,
|
|
68
|
+
pathKey: visibleItems[idx].pathKey,
|
|
69
|
+
});
|
|
305
70
|
};
|
|
306
71
|
const itemData = {
|
|
307
72
|
itemSpacing,
|
|
@@ -310,17 +75,9 @@ const MenuInlineInner = forwardRef((props, ref) => {
|
|
|
310
75
|
selectedKeys,
|
|
311
76
|
expandedKeys,
|
|
312
77
|
action,
|
|
313
|
-
|
|
314
|
-
normalizeTreeItems,
|
|
315
|
-
items: visibleItems.map(item => ({
|
|
316
|
-
...item,
|
|
317
|
-
data: {
|
|
318
|
-
...item.data,
|
|
319
|
-
ref: el => itemRefs.current.set(item.id, el),
|
|
320
|
-
},
|
|
321
|
-
})),
|
|
78
|
+
items: visibleItems,
|
|
322
79
|
onClick: handleClickItem,
|
|
323
80
|
};
|
|
324
|
-
return (_jsx(StyledAutoSizer, { className: clsx(CLS.Root.default, className),
|
|
325
|
-
}
|
|
326
|
-
export const MenuInline =
|
|
81
|
+
return (_jsx(StyledAutoSizer, { className: clsx(CLS.Root.default, className), children: autoSize => (_jsx(VirtualizedMenuContainer, { className: clsx(CLS.MenuInline.default), itemSize: getItemSize(itemSize, itemSpacing), itemCount: visibleItems.length, height: autoSize.height, width: autoSize.width, innerElementType: innerElementType, itemData: itemData, useIsScrolling: true, children: Item })) }));
|
|
82
|
+
};
|
|
83
|
+
export const MenuInline = React.forwardRef(MenuInlineInner);
|
|
@@ -3,7 +3,7 @@ import { VariableSizeList } from 'react-window';
|
|
|
3
3
|
import { MemoryData } from './components/Item/Item';
|
|
4
4
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
5
5
|
export declare const MenuItemWrapper: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
6
|
-
export declare const MenuItemRoot: import("styled-components").StyledComponent<"
|
|
6
|
+
export declare const MenuItemRoot: import("styled-components").StyledComponent<"div", any, {}, never>;
|
|
7
7
|
export declare const VirtualizedMenuContainer: import("styled-components").StyledComponent<{
|
|
8
8
|
new (props: import("react-window").VariableSizeListProps<MemoryData>): VariableSizeList<MemoryData>;
|
|
9
9
|
new (props: import("react-window").VariableSizeListProps<MemoryData>, context: any): VariableSizeList<MemoryData>;
|
|
@@ -3,7 +3,6 @@ import { VariableSizeList } from 'react-window';
|
|
|
3
3
|
import { THEME, globalToken } from '@antscorp/antsomi-ui/es/constants';
|
|
4
4
|
import AutoSizer from 'react-virtualized-auto-sizer';
|
|
5
5
|
import { CLS } from './utils';
|
|
6
|
-
import tinycolor from 'tinycolor2';
|
|
7
6
|
export const MenuItemWrapper = styled.div `
|
|
8
7
|
width: 100%;
|
|
9
8
|
height: 100%;
|
|
@@ -16,7 +15,7 @@ export const MenuItemWrapper = styled.div `
|
|
|
16
15
|
|
|
17
16
|
.icon-expand {
|
|
18
17
|
font-size: 14px;
|
|
19
|
-
flex-
|
|
18
|
+
flex-shirnk: 0;
|
|
20
19
|
}
|
|
21
20
|
|
|
22
21
|
.title-wrapper {
|
|
@@ -25,23 +24,17 @@ export const MenuItemWrapper = styled.div `
|
|
|
25
24
|
white-space: nowrap;
|
|
26
25
|
}
|
|
27
26
|
`;
|
|
28
|
-
export const MenuItemRoot = styled.
|
|
27
|
+
export const MenuItemRoot = styled.div `
|
|
29
28
|
&.${CLS.Item.default} {
|
|
30
29
|
cursor: pointer;
|
|
31
30
|
display: flex;
|
|
32
31
|
align-items: center;
|
|
33
32
|
overflow: hidden;
|
|
34
|
-
|
|
35
|
-
&:focus {
|
|
36
|
-
outline: none;
|
|
37
|
-
}
|
|
33
|
+
border-radius: ${THEME.components?.Menu?.itemBorderRadius}px;
|
|
38
34
|
|
|
39
35
|
> .${CLS.ItemLabel.default} {
|
|
40
|
-
display: flex;
|
|
41
36
|
flex: 1;
|
|
42
37
|
overflow: hidden;
|
|
43
|
-
align-self: stretch;
|
|
44
|
-
align-items: center;
|
|
45
38
|
}
|
|
46
39
|
|
|
47
40
|
> .${CLS.ItemAction.default} {
|
|
@@ -68,14 +61,7 @@ export const MenuItemRoot = styled.li `
|
|
|
68
61
|
}
|
|
69
62
|
}
|
|
70
63
|
|
|
71
|
-
|
|
72
|
-
background-color: ${tinycolor(THEME.components?.Menu?.itemActiveBg)
|
|
73
|
-
.lighten(4)
|
|
74
|
-
.toString('rgb')};
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
&:focus:not(.${CLS.Item.disabled}, .${CLS.Item.selected}, .${CLS.Item.selectedDescendant}),
|
|
78
|
-
&:hover:not(.${CLS.Item.disabled}, .${CLS.Item.selected}, .${CLS.Item.selectedDescendant}) {
|
|
64
|
+
&:hover:not(.${CLS.Item.disabled}, .${CLS.Item.selected}) {
|
|
79
65
|
background-color: ${THEME.components?.Menu?.itemHoverBg};
|
|
80
66
|
}
|
|
81
67
|
}
|
|
@@ -83,11 +69,6 @@ export const MenuItemRoot = styled.li `
|
|
|
83
69
|
export const VirtualizedMenuContainer = styled((VariableSizeList)) `
|
|
84
70
|
font-size: ${globalToken?.fontSize}px;
|
|
85
71
|
scrollbar-gutter: stable;
|
|
86
|
-
|
|
87
|
-
ul {
|
|
88
|
-
padding: 0;
|
|
89
|
-
margin: 0;
|
|
90
|
-
}
|
|
91
72
|
`;
|
|
92
73
|
export const StyledAutoSizer = styled(AutoSizer) `
|
|
93
74
|
flex: 1;
|
|
@@ -11,6 +11,11 @@ export type ItemType = {
|
|
|
11
11
|
errorMessage?: string | undefined;
|
|
12
12
|
disabled?: boolean;
|
|
13
13
|
};
|
|
14
|
+
export type SerializedItemType = ItemType & {
|
|
15
|
+
level: number;
|
|
16
|
+
pathKey: PathKey;
|
|
17
|
+
parent: ItemType | null;
|
|
18
|
+
};
|
|
14
19
|
type VirtualizedMenuBaseProps = Partial<{
|
|
15
20
|
items: ItemType[];
|
|
16
21
|
inlineIndent: number;
|
|
@@ -19,20 +24,18 @@ type VirtualizedMenuBaseProps = Partial<{
|
|
|
19
24
|
selectable: boolean;
|
|
20
25
|
className: string;
|
|
21
26
|
itemSize: number;
|
|
22
|
-
selected: string
|
|
27
|
+
selected: string[];
|
|
23
28
|
expanded: string[];
|
|
24
29
|
onClick: (args: {
|
|
25
30
|
item: ItemType;
|
|
26
|
-
|
|
27
|
-
elKey: 'item' | 'item-expand-el';
|
|
31
|
+
pathKey: PathKey;
|
|
28
32
|
}) => void;
|
|
29
|
-
action: React.ReactNode | ((item: ItemType
|
|
30
|
-
expandEl: React.ReactNode;
|
|
31
|
-
}) => React.ReactNode);
|
|
33
|
+
action: React.ReactNode | ((item: ItemType) => React.ReactNode);
|
|
32
34
|
}>;
|
|
33
35
|
export type VirtualizedMenuBaseHandle = {
|
|
34
36
|
expandAll: () => void;
|
|
35
37
|
};
|
|
38
|
+
export type PathKey = (string | number)[];
|
|
36
39
|
export type MenuInlineHandle = VirtualizedMenuBaseHandle;
|
|
37
40
|
export type MenuInlineProps = VirtualizedMenuBaseProps & {
|
|
38
41
|
mode?: typeof MODE.Inline;
|