@yuntijs/ui 1.0.0-beta.81 → 1.0.0-beta.82

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 (34) hide show
  1. package/es/ChatInputArea/desktop/ChatInputArea.d.ts +1 -1
  2. package/es/Form/collapse-list/index.d.ts +1 -1
  3. package/es/Mentions/index.d.ts +4 -0
  4. package/es/Mentions/index.js +23 -9
  5. package/es/Mentions/plugins/mention-node/component.js +1 -1
  6. package/es/Mentions/plugins/mention-node/node.d.ts +1 -2
  7. package/es/Mentions/plugins/mention-node/node.js +5 -2
  8. package/es/Mentions/plugins/mention-picker/hooks.js +17 -10
  9. package/es/Mentions/plugins/mention-picker/index.d.ts +3 -0
  10. package/es/Mentions/plugins/mention-picker/index.js +57 -8
  11. package/es/Mentions/plugins/mention-picker/menu-item.d.ts +3 -3
  12. package/es/Mentions/plugins/mention-picker/menu-item.js +2 -2
  13. package/es/Mentions/plugins/mention-picker/menu.d.ts +5 -4
  14. package/es/Mentions/plugins/mention-picker/menu.js +2 -1
  15. package/es/Mentions/plugins/mention-picker/style.js +3 -3
  16. package/es/Mentions/plugins/mention-picker/utils.d.ts +16 -9
  17. package/es/Mentions/plugins/mention-picker/utils.js +29 -8
  18. package/es/Mentions/plugins/on-blur-or-focus-block.js +1 -1
  19. package/es/Mentions/types.d.ts +5 -10
  20. package/es/MonacoEditor/base/index.d.ts +6 -2
  21. package/es/MonacoEditor/base/index.js +4 -2
  22. package/es/MonacoEditor/base/style.d.ts +1 -0
  23. package/es/MonacoEditor/base/style.js +23 -6
  24. package/es/MonacoEditor/index.d.ts +3 -0
  25. package/es/Page/Page.d.ts +1 -1
  26. package/es/Radio/index.js +1 -2
  27. package/es/Table/index.d.ts +1 -1
  28. package/es/Typography/index.d.ts +1 -1
  29. package/es/styles/colors/generateColorPalette.d.ts +1 -1
  30. package/package.json +6 -6
  31. package/umd/index.min.js +1 -1
  32. package/umd/index.min.js.map +1 -1
  33. package/es/MonacoEditor/style.d.ts +0 -10
  34. package/es/MonacoEditor/style.js +0 -25
@@ -1,5 +1,5 @@
1
1
  import { type ChatInputAreaInnerProps, type DraggablePanelProps } from '@lobehub/ui';
2
- import { TextAreaRef } from 'antd/es/input/TextArea';
2
+ import type { TextAreaRef } from 'antd/es/input/TextArea';
3
3
  import { ReactNode } from 'react';
4
4
  export interface ChatInputAreaProps extends Omit<ChatInputAreaInnerProps, 'classNames'> {
5
5
  bottomAddons?: ReactNode;
@@ -1,5 +1,5 @@
1
1
  import type { FormItemProps, FormListFieldData, TableColumnProps } from 'antd';
2
- import { FormListProps as AntFormListProps } from 'antd/es/form';
2
+ import type { FormListProps as AntFormListProps } from 'antd/es/form';
3
3
  import React from 'react';
4
4
  import { CollapseGroupProps } from '../../CollapseGroup';
5
5
  export interface FormCollapseListColumnItem extends Omit<FormItemProps, 'dependencies' | 'rules' | 'tooltip' | 'labelAlign' | 'labelCol' | 'colon' | 'children'> {
@@ -3,6 +3,10 @@ import { type MentionPickerPluginProps } from './plugins/mention-picker';
3
3
  import type { AutoSize } from './types';
4
4
  export interface MentionsProps extends MentionPickerPluginProps {
5
5
  className?: string;
6
+ classNames?: {
7
+ wrapper?: string;
8
+ menuOverlay?: string;
9
+ };
6
10
  wrapperClassname?: string;
7
11
  placeholder?: string;
8
12
  style?: React.CSSProperties;
@@ -7,6 +7,7 @@ import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
7
7
  import { HistoryPlugin } from '@lexical/react/LexicalHistoryPlugin';
8
8
  import { OnChangePlugin } from '@lexical/react/LexicalOnChangePlugin';
9
9
  import { RichTextPlugin } from '@lexical/react/LexicalRichTextPlugin';
10
+ import { ConfigProvider } from 'antd';
10
11
  import { $getRoot, TextNode } from 'lexical';
11
12
  import React, { useMemo } from 'react';
12
13
  import { isBrowser } from "../utils/tools";
@@ -21,15 +22,14 @@ import { jsx as _jsx } from "react/jsx-runtime";
21
22
  import { jsxs as _jsxs } from "react/jsx-runtime";
22
23
  export var Mentions = function Mentions(_ref) {
23
24
  var className = _ref.className,
24
- wrapperClassname = _ref.wrapperClassname,
25
+ classNames = _ref.classNames,
25
26
  placeholder = _ref.placeholder,
26
27
  style = _ref.style,
27
28
  value = _ref.value,
28
29
  defaultValue = _ref.defaultValue,
29
30
  _ref$readOnly = _ref.readOnly,
30
31
  readOnly = _ref$readOnly === void 0 ? false : _ref$readOnly,
31
- _ref$disabled = _ref.disabled,
32
- disabled = _ref$disabled === void 0 ? false : _ref$disabled,
32
+ customDisabled = _ref.disabled,
33
33
  onChange = _ref.onChange,
34
34
  onBlur = _ref.onBlur,
35
35
  onFocus = _ref.onFocus,
@@ -44,11 +44,14 @@ export var Mentions = function Mentions(_ref) {
44
44
  punctuation = _ref.punctuation,
45
45
  preTriggerChars = _ref.preTriggerChars,
46
46
  onSelect = _ref.onSelect;
47
+ var _ConfigProvider$useCo = ConfigProvider.useConfig(),
48
+ componentDisabled = _ConfigProvider$useCo.componentDisabled;
47
49
  var _useStyles = useStyles({
48
50
  autoSize: autoSize
49
51
  }),
50
52
  styles = _useStyles.styles,
51
53
  cx = _useStyles.cx;
54
+ var disabled = customDisabled !== null && customDisabled !== void 0 ? customDisabled : componentDisabled;
52
55
  var editable = !readOnly && !disabled;
53
56
  var initialConfig = useMemo(function () {
54
57
  return {
@@ -80,14 +83,24 @@ export var Mentions = function Mentions(_ref) {
80
83
  // }, [value])
81
84
 
82
85
  var optionsMap = useMemo(function () {
83
- return options.reduce(function (acc, option) {
84
- acc[option.value] = option;
85
- return acc;
86
- }, {});
86
+ var buildMap = function buildMap(_options, parentIcon) {
87
+ return _options.reduce(function (acc, option) {
88
+ acc[option.value] = option;
89
+ if (!acc[option.value].icon) {
90
+ acc[option.value].icon = parentIcon;
91
+ }
92
+ if (option.children && option.children.length > 0) {
93
+ var childrenMap = buildMap(option.children, option.icon);
94
+ Object.assign(acc, childrenMap);
95
+ }
96
+ return acc;
97
+ }, {});
98
+ };
99
+ return buildMap(options);
87
100
  }, [options]);
88
101
  if (!isBrowser) {
89
102
  return /*#__PURE__*/_jsxs("div", {
90
- className: cx(styles.wrapper, wrapperClassname),
103
+ className: cx(styles.wrapper, classNames === null || classNames === void 0 ? void 0 : classNames.wrapper),
91
104
  children: [/*#__PURE__*/_jsx("div", {
92
105
  className: cx(_defineProperty(_defineProperty(_defineProperty(_defineProperty({}, styles.root, true), styles.filled, variant === 'filled'), styles.borderless, variant === 'borderless'), styles.disabled, disabled), className),
93
106
  style: style || {}
@@ -106,7 +119,7 @@ export var Mentions = function Mentions(_ref) {
106
119
  optionsMap: optionsMap
107
120
  },
108
121
  children: /*#__PURE__*/_jsxs("div", {
109
- className: cx(styles.wrapper, wrapperClassname),
122
+ className: cx(styles.wrapper, classNames === null || classNames === void 0 ? void 0 : classNames.wrapper),
110
123
  children: [/*#__PURE__*/_jsx(RichTextPlugin, {
111
124
  ErrorBoundary: LexicalErrorBoundary,
112
125
  contentEditable: /*#__PURE__*/_jsx(ContentEditable, {
@@ -121,6 +134,7 @@ export var Mentions = function Mentions(_ref) {
121
134
  allowSpaces: allowSpaces,
122
135
  onSelect: onSelect,
123
136
  options: options,
137
+ overlayClassName: classNames === null || classNames === void 0 ? void 0 : classNames.menuOverlay,
124
138
  preTriggerChars: preTriggerChars,
125
139
  punctuation: punctuation,
126
140
  triggers: triggers
@@ -49,7 +49,7 @@ export var MentionNodeComponent = /*#__PURE__*/memo(function (_ref) {
49
49
  gap: 2,
50
50
  title: (option === null || option === void 0 ? void 0 : option.label) || variable,
51
51
  children: /*#__PURE__*/_jsx("span", {
52
- children: (option === null || option === void 0 ? void 0 : option.label) || variable
52
+ children: (option === null || option === void 0 ? void 0 : option.selectedLabel) || (option === null || option === void 0 ? void 0 : option.label) || variable
53
53
  })
54
54
  })]
55
55
  })
@@ -1,7 +1,6 @@
1
1
  /// <reference types="react" />
2
2
  import type { LexicalNode, NodeKey, SerializedLexicalNode } from 'lexical';
3
3
  import { DecoratorNode } from 'lexical';
4
- import type { MentionsOptionsMap } from '../../types';
5
4
  export type SerializedNode = SerializedLexicalNode & {
6
5
  variable: string;
7
6
  };
@@ -10,7 +9,7 @@ export declare class MentionNode extends DecoratorNode<JSX.Element> {
10
9
  static getType(): string;
11
10
  static clone(node: MentionNode): MentionNode;
12
11
  isInline(): boolean;
13
- constructor(variable: string, optionsMap?: MentionsOptionsMap, key?: NodeKey);
12
+ constructor(variable: string, key?: NodeKey);
14
13
  createDOM(): HTMLElement;
15
14
  updateDOM(): false;
16
15
  decorate(): JSX.Element;
@@ -9,12 +9,15 @@ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflec
9
9
  function _isNativeReflectConstruct() { if (typeof Reflect === "undefined" || !Reflect.construct) return false; if (Reflect.construct.sham) return false; if (typeof Proxy === "function") return true; try { Boolean.prototype.valueOf.call(Reflect.construct(Boolean, [], function () {})); return true; } catch (e) { return false; } }
10
10
  import { DecoratorNode } from 'lexical';
11
11
  import React from 'react';
12
+
13
+ // import type { MentionsOptionsMap } from '../../types';
12
14
  import { MentionNodeComponent } from "./component";
13
15
  import { jsx as _jsx } from "react/jsx-runtime";
14
16
  export var MentionNode = /*#__PURE__*/function (_DecoratorNode) {
15
17
  _inherits(MentionNode, _DecoratorNode);
16
18
  var _super = _createSuper(MentionNode);
17
- function MentionNode(variable, optionsMap, key) {
19
+ // constructor(variable: string, optionsMap?: MentionsOptionsMap, key?: NodeKey) {
20
+ function MentionNode(variable, key) {
18
21
  var _this;
19
22
  _classCallCheck(this, MentionNode);
20
23
  _this = _super.call(this, key);
@@ -77,7 +80,7 @@ export var MentionNode = /*#__PURE__*/function (_DecoratorNode) {
77
80
  }, {
78
81
  key: "clone",
79
82
  value: function clone(node) {
80
- return new MentionNode(node.__variable);
83
+ return new MentionNode(node.__variable, node.__key);
81
84
  }
82
85
  }, {
83
86
  key: "importJSON",
@@ -1,4 +1,7 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
1
2
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
3
+ function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
4
+ function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
2
5
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
6
  import { escapeRegExp } from 'lodash-es';
4
7
  import { useMemo } from 'react';
@@ -9,18 +12,22 @@ export var useOptions = function useOptions(allOptions, queryString) {
9
12
  _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
10
13
  editor = _useLexicalComposerCo2[0];
11
14
  var options = useMemo(function () {
12
- var menuOptions = allOptions.map(function (o) {
13
- return new MentionMenuOption(o.value, o.label, {
14
- icon: o.icon,
15
+ var _addOnselect = function _addOnselect(option) {
16
+ var menuOption = _objectSpread(_objectSpread({}, option), {}, {
17
+ children: undefined,
15
18
  onSelect: function onSelect() {
16
- editor.dispatchCommand(INSERT_MENTION_COMMAND, o.value);
17
- },
18
- disabled: o.disabled,
19
- data: o.data,
20
- extraElement: o.extraElement,
21
- keywords: o.keywords,
22
- keyboardShortcut: o.keyboardShortcut
19
+ editor.dispatchCommand(INSERT_MENTION_COMMAND, option.value);
20
+ }
23
21
  });
22
+ if (option.children) {
23
+ menuOption.children = option.children.map(function (o) {
24
+ return _addOnselect(o);
25
+ });
26
+ }
27
+ return menuOption;
28
+ };
29
+ var menuOptions = allOptions.map(function (o) {
30
+ return new MentionMenuOption(_addOnselect(o));
24
31
  });
25
32
  if (!queryString) {
26
33
  return menuOptions;
@@ -2,6 +2,9 @@ import React from 'react';
2
2
  import type { MentionOption } from '../../types';
3
3
  import { type MentionMenuOption } from './utils';
4
4
  export interface MentionPickerPluginProps {
5
+ /** The className of menu overlay */
6
+ overlayClassName?: string;
7
+ /** The options of menu */
5
8
  options?: MentionOption[];
6
9
  /**
7
10
  * The characters that trigger the mention menu. Needed to tell the plugin
@@ -1,16 +1,24 @@
1
1
  import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
2
  import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
3
  import { LexicalTypeaheadMenuPlugin } from '@lexical/react/LexicalTypeaheadMenuPlugin';
4
+ import { ConfigProvider, Tree } from 'antd';
5
+ // @Todo: 目前不支持上下键选中 children,后续支持可能需要定制 menu 和 plugin
6
+ // import type { MenuRenderFn } from '../LexicalTypeaheadMenuPlugin';
7
+ // import { LexicalTypeaheadMenuPlugin } from '../LexicalTypeaheadMenuPlugin';
8
+
4
9
  import React, { memo, useCallback, useState } from 'react';
5
10
  import ReactDOM from 'react-dom';
6
11
  import { DEFAULT_PUNCTUATION, PRE_TRIGGER_CHARS } from "../../constants";
7
12
  import { useCheckForMentionMatch } from "../../hooks";
13
+ import { CLEAR_HIDE_MENU_TIMEOUT } from "../mention-node";
8
14
  import { useOptions } from "./hooks";
9
15
  import { MentionMenu } from "./menu";
16
+ import { MentionMenuItem } from "./menu-item";
10
17
  import { useStyles } from "./style";
11
18
  import { jsx as _jsx } from "react/jsx-runtime";
12
19
  export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
13
- var triggers = _ref.triggers,
20
+ var overlayClassName = _ref.overlayClassName,
21
+ triggers = _ref.triggers,
14
22
  _ref$options = _ref.options,
15
23
  allOptions = _ref$options === void 0 ? [] : _ref$options,
16
24
  _ref$allowSpaces = _ref.allowSpaces,
@@ -21,6 +29,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
21
29
  preTriggerChars = _ref$preTriggerChars === void 0 ? PRE_TRIGGER_CHARS : _ref$preTriggerChars,
22
30
  onSelect = _ref.onSelect;
23
31
  var _useStyles = useStyles({}),
32
+ cx = _useStyles.cx,
24
33
  styles = _useStyles.styles;
25
34
  var _useLexicalComposerCo = useLexicalComposerContext(),
26
35
  _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
@@ -50,15 +59,55 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
50
59
  closeMenu();
51
60
  });
52
61
  }, [editor, onSelect, queryString, trigger]);
53
- var renderMenu = useCallback(function (anchorElementRef, _ref2) {
54
- var selectedIndex = _ref2.selectedIndex,
55
- selectOptionAndCleanUp = _ref2.selectOptionAndCleanUp,
56
- setHighlightedIndex = _ref2.setHighlightedIndex;
62
+ var renderMenuTree = useCallback(function (itemProps) {
63
+ var selectedIndex = itemProps.selectedIndex,
64
+ selectOptionAndCleanUp = itemProps.selectOptionAndCleanUp;
65
+ return /*#__PURE__*/_jsx(ConfigProvider, {
66
+ theme: {
67
+ components: {
68
+ Tree: {
69
+ indentSize: 16,
70
+ lineHeight: 32,
71
+ titleHeight: 32,
72
+ paddingXS: 0
73
+ }
74
+ }
75
+ },
76
+ children: /*#__PURE__*/_jsx(Tree, {
77
+ blockNode: true,
78
+ defaultExpandAll: true,
79
+ onExpand: function onExpand(_keys, _ref2) {
80
+ var nativeEvent = _ref2.nativeEvent;
81
+ nativeEvent.stopPropagation();
82
+ // 阻止 menu-picker 隐藏
83
+ editor.dispatchCommand(CLEAR_HIDE_MENU_TIMEOUT, {});
84
+ },
85
+ onSelect: function onSelect(_keys, info) {
86
+ selectOptionAndCleanUp(info.node);
87
+ },
88
+ titleRender: function titleRender(option) {
89
+ var _options;
90
+ return /*#__PURE__*/_jsx(MentionMenuItem, {
91
+ isSelected: ((_options = options[selectedIndex]) === null || _options === void 0 ? void 0 : _options.value) === option.value,
92
+ option: option,
93
+ queryString: queryString
94
+ });
95
+ },
96
+ treeData: options
97
+ })
98
+ });
99
+ }, [options, editor, queryString]);
100
+ var renderMenu = useCallback(function (anchorElementRef, itemProps, _matchingString) {
101
+ var selectedIndex = itemProps.selectedIndex,
102
+ selectOptionAndCleanUp = itemProps.selectOptionAndCleanUp,
103
+ setHighlightedIndex = itemProps.setHighlightedIndex;
57
104
  if (anchorElementRef.current) {
58
105
  return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx("div", {
59
- className: styles.menuOverlay,
106
+ className: cx(styles.menuOverlay, overlayClassName),
60
107
  role: "menu",
61
- children: /*#__PURE__*/_jsx(MentionMenu, {
108
+ children: options.some(function (o) {
109
+ return (o.children || []).length > 0;
110
+ }) ? renderMenuTree(itemProps) : /*#__PURE__*/_jsx(MentionMenu, {
62
111
  onClick: function onClick(index, option) {
63
112
  if (option.disabled) return;
64
113
  setHighlightedIndex(index);
@@ -75,7 +124,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
75
124
  }), anchorElementRef.current);
76
125
  }
77
126
  return null;
78
- }, [options, queryString, styles.menuOverlay]);
127
+ }, [cx, options, overlayClassName, queryString, renderMenuTree, styles.menuOverlay]);
79
128
  return /*#__PURE__*/_jsx(LexicalTypeaheadMenuPlugin, {
80
129
  anchorClassName: styles.anchor,
81
130
  menuRenderFn: renderMenu,
@@ -1,10 +1,10 @@
1
1
  import React from 'react';
2
2
  import { MentionMenuOption } from './utils';
3
3
  export interface MentionMenuItemProps {
4
- index: number;
4
+ index?: number;
5
5
  isSelected: boolean;
6
- onClick: (index: number, option: MentionMenuOption) => void;
7
- onMouseEnter: (index: number, option: MentionMenuOption) => void;
6
+ onClick?: (index: number, option: MentionMenuOption) => void;
7
+ onMouseEnter?: (index: number, option: MentionMenuOption) => void;
8
8
  option: MentionMenuOption;
9
9
  queryString: string | null;
10
10
  }
@@ -46,10 +46,10 @@ export var MentionMenuItem = /*#__PURE__*/memo(function (_ref) {
46
46
  className: styles.menuItem,
47
47
  gap: 4,
48
48
  onClick: function onClick() {
49
- return _onClick(index, option);
49
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick(index, option);
50
50
  },
51
51
  onMouseEnter: function onMouseEnter() {
52
- return _onMouseEnter(index, option);
52
+ return _onMouseEnter === null || _onMouseEnter === void 0 ? void 0 : _onMouseEnter(index, option);
53
53
  },
54
54
  ref: option.setRefElement,
55
55
  tabIndex: -1,
@@ -1,9 +1,10 @@
1
1
  import React from 'react';
2
+ import { MentionMenuOption } from './utils';
2
3
  export interface MentionMenuProps {
3
- selectedIndex: number | null;
4
- options: any[];
5
- onClick: (index: number, option: any) => void;
6
- onMouseEnter: (index: number, option: any) => void;
4
+ selectedIndex?: number | null;
5
+ options: MentionMenuOption[];
6
+ onClick?: (index: number, option: MentionMenuOption) => void;
7
+ onMouseEnter?: (index: number, option: MentionMenuOption) => void;
7
8
  queryString: string | null;
8
9
  }
9
10
  export declare const MentionMenu: React.FC<MentionMenuProps>;
@@ -15,7 +15,8 @@ export var MentionMenu = /*#__PURE__*/memo(function (_ref) {
15
15
  styles = _useStyles.styles;
16
16
  return /*#__PURE__*/_jsxs(_Fragment, {
17
17
  children: [options.length === 0 && /*#__PURE__*/_jsx(Empty, {
18
- className: styles.menuEmpty
18
+ className: styles.menuEmpty,
19
+ image: Empty.PRESENTED_IMAGE_SIMPLE
19
20
  }), options.map(function (option, index) {
20
21
  return /*#__PURE__*/_jsx(MentionMenuItem, {
21
22
  index: index,
@@ -7,12 +7,12 @@ export var useStyles = createStyles(function (_ref, _ref2) {
7
7
  prefixCls = _ref.prefixCls;
8
8
  var isSelected = _ref2.isSelected,
9
9
  disabled = _ref2.disabled;
10
- var selectedBg = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillTertiary);
10
+ var selectedBg = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillSecondary);
11
11
  return {
12
12
  anchor: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n z-index: 9999;\n "]))),
13
13
  menuEmpty: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: ", "px;\n "])), token.padding),
14
- menuOverlay: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow: auto;\n\n width: 240px;\n max-height: 320px;\n margin-top: ", "px;\n\n background: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n "])), token.marginXXS, token.colorBgElevated, token.borderRadius, token.boxShadow),
15
- menuItem: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n cursor: ", ";\n pointer-events: ", ";\n\n padding: ", "px ", "px;\n\n position: relative;\n\n border-radius: ", "px;\n\n color: ", ";\n font-size: ", "px;\n line-height: ", ";\n ", "\n &:hover {\n ", "\n }\n "])), disabled ? 'not-allowed' : 'pointer', disabled ? 'none' : 'all', token.paddingSM / 2, token.paddingSM, token.borderRadius, disabled ? token.colorTextDisabled : token.colorText, token.fontSize, token.lineHeight, isSelected && selectedBg, selectedBg),
14
+ menuOverlay: css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n overflow: auto;\n\n width: 260px;\n max-height: 360px;\n margin-top: ", "px;\n padding: ", "px;\n\n background: ", ";\n border-radius: ", "px;\n box-shadow: ", ";\n .", "-tree {\n &-switcher {\n margin: 2px 0;\n }\n }\n "])), token.marginXXS, token.paddingXXS, token.colorBgElevated, token.borderRadius, token.boxShadow, prefixCls),
15
+ menuItem: css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n cursor: ", ";\n pointer-events: ", ";\n\n padding: 0 ", "px;\n margin: 2px;\n\n position: relative;\n\n border-radius: ", "px;\n\n color: ", ";\n font-size: ", "px;\n line-height: 32px;\n ", "\n &:hover {\n ", "\n }\n "])), disabled ? 'not-allowed' : 'pointer', disabled ? 'none' : 'all', token.paddingXS, token.borderRadius, disabled ? token.colorTextDisabled : token.colorText, token.fontSize, isSelected && selectedBg, selectedBg),
16
16
  menuItemIcon: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorInfoText),
17
17
  menuItemLabel: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: inline-block;\n text-overflow: ellipsis;\n white-space: nowrap;\n "])))
18
18
  };
@@ -1,8 +1,22 @@
1
1
  /// <reference types="react" />
2
2
  import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
3
+ export interface MentionMenuOptionInitParams {
4
+ label: string;
5
+ value: string;
6
+ data?: any;
7
+ icon?: JSX.Element;
8
+ extraElement?: JSX.Element;
9
+ keywords?: Array<string>;
10
+ keyboardShortcut?: string;
11
+ disabled?: boolean;
12
+ onSelect: (queryString: string) => void;
13
+ children?: MentionMenuOptionInitParams[];
14
+ }
3
15
  export declare class MentionMenuOption extends MenuOption {
4
16
  label: string;
5
17
  value: string;
18
+ title: string;
19
+ key: string;
6
20
  icon?: JSX.Element;
7
21
  extraElement?: JSX.Element;
8
22
  keywords: Array<string>;
@@ -10,13 +24,6 @@ export declare class MentionMenuOption extends MenuOption {
10
24
  onSelect: (queryString: string) => void;
11
25
  disabled?: boolean;
12
26
  data?: any;
13
- constructor(value: string, label: string, options: {
14
- icon?: JSX.Element;
15
- extraElement?: JSX.Element;
16
- keywords?: Array<string>;
17
- keyboardShortcut?: string;
18
- onSelect: (queryString: string) => void;
19
- disabled?: boolean;
20
- data?: any;
21
- });
27
+ children?: MentionMenuOption[];
28
+ constructor({ label, value, data, icon, extraElement, keywords, keyboardShortcut, disabled, onSelect, children, }: MentionMenuOptionInitParams);
22
29
  }
@@ -11,12 +11,26 @@ import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
11
11
  export var MentionMenuOption = /*#__PURE__*/function (_MenuOption) {
12
12
  _inherits(MentionMenuOption, _MenuOption);
13
13
  var _super = _createSuper(MentionMenuOption);
14
- function MentionMenuOption(value, label, options) {
14
+ function MentionMenuOption(_ref) {
15
15
  var _this;
16
+ var label = _ref.label,
17
+ value = _ref.value,
18
+ data = _ref.data,
19
+ icon = _ref.icon,
20
+ extraElement = _ref.extraElement,
21
+ keywords = _ref.keywords,
22
+ keyboardShortcut = _ref.keyboardShortcut,
23
+ disabled = _ref.disabled,
24
+ onSelect = _ref.onSelect,
25
+ children = _ref.children;
16
26
  _classCallCheck(this, MentionMenuOption);
17
27
  _this = _super.call(this, value);
18
28
  _defineProperty(_assertThisInitialized(_this), "label", void 0);
19
29
  _defineProperty(_assertThisInitialized(_this), "value", void 0);
30
+ // for Tree, the same as label
31
+ _defineProperty(_assertThisInitialized(_this), "title", void 0);
32
+ // for Tree, the same as value
33
+ _defineProperty(_assertThisInitialized(_this), "key", void 0);
20
34
  _defineProperty(_assertThisInitialized(_this), "icon", void 0);
21
35
  _defineProperty(_assertThisInitialized(_this), "extraElement", void 0);
22
36
  _defineProperty(_assertThisInitialized(_this), "keywords", void 0);
@@ -24,15 +38,22 @@ export var MentionMenuOption = /*#__PURE__*/function (_MenuOption) {
24
38
  _defineProperty(_assertThisInitialized(_this), "onSelect", void 0);
25
39
  _defineProperty(_assertThisInitialized(_this), "disabled", void 0);
26
40
  _defineProperty(_assertThisInitialized(_this), "data", void 0);
41
+ _defineProperty(_assertThisInitialized(_this), "children", void 0);
27
42
  _this.value = value;
28
43
  _this.label = label;
29
- _this.keywords = options.keywords || [];
30
- _this.icon = options.icon;
31
- _this.extraElement = options.extraElement;
32
- _this.keyboardShortcut = options.keyboardShortcut;
33
- _this.onSelect = options.onSelect.bind(_assertThisInitialized(_this));
34
- _this.disabled = options.disabled;
35
- _this.data = options.data;
44
+ _this.title = label;
45
+ _this.key = value;
46
+ _this.keywords = keywords || [];
47
+ _this.icon = icon;
48
+ _this.extraElement = extraElement;
49
+ _this.keyboardShortcut = keyboardShortcut;
50
+ _this.onSelect = onSelect.bind(_assertThisInitialized(_this));
51
+ _this.disabled = disabled;
52
+ _this.data = data;
53
+ _this.children = children === null || children === void 0 ? void 0 : children.map(function (m) {
54
+ // const
55
+ return new MentionMenuOption(m);
56
+ });
36
57
  return _this;
37
58
  }
38
59
  return _createClass(MentionMenuOption);
@@ -18,7 +18,7 @@ var OnBlurBlock = function OnBlurBlock(_ref) {
18
18
  ref.current = null;
19
19
  }
20
20
  return true;
21
- }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(BLUR_COMMAND, function () {
21
+ }, COMMAND_PRIORITY_EDITOR), editor.registerCommand(BLUR_COMMAND, function (_payload, _editor) {
22
22
  ref.current = setTimeout(function () {
23
23
  editor.dispatchCommand(KEY_ESCAPE_COMMAND, new KeyboardEvent('keydown', {
24
24
  key: 'Escape'
@@ -1,14 +1,9 @@
1
- /// <reference types="react" />
2
- export interface MentionOption {
3
- label: string;
4
- value: string;
5
- data?: any;
6
- icon?: JSX.Element;
7
- extraElement?: JSX.Element;
8
- keywords?: Array<string>;
9
- keyboardShortcut?: string;
1
+ import { MentionMenuOptionInitParams } from './plugins/mention-picker/utils';
2
+ export interface MentionOption extends Omit<MentionMenuOptionInitParams, 'onSelect' | 'children'> {
3
+ /** 选中后展示的 label 名称,不指定则直接使用 label */
4
+ selectedLabel?: string;
10
5
  error?: string;
11
- disabled?: boolean;
6
+ children?: MentionOption[];
12
7
  }
13
8
  export type MentionsOptionsMap = Record<string, MentionOption>;
14
9
  export interface AutoSize {
@@ -4,7 +4,9 @@ import { IDiffMonacoEditorProps, ISingleMonacoEditorProps } from './helper';
4
4
  export * from './controller';
5
5
  export * from './monaco';
6
6
  declare function noop(): void;
7
- export declare const SingleMonacoEditorComponent: React.FC<ISingleMonacoEditorProps> & {
7
+ export declare const SingleMonacoEditorComponent: React.FC<ISingleMonacoEditorProps & {
8
+ variant?: "filled" | "borderless" | "outlined" | undefined;
9
+ }> & {
8
10
  displayName: string;
9
11
  defaultProps: {
10
12
  width: string;
@@ -17,7 +19,9 @@ export declare const SingleMonacoEditorComponent: React.FC<ISingleMonacoEditorPr
17
19
  onChange: typeof noop;
18
20
  requireConfig: {};
19
21
  };
20
- MonacoDiffEditor: React.FC<IDiffMonacoEditorProps> & {
22
+ MonacoDiffEditor: React.FC<IDiffMonacoEditorProps & {
23
+ variant?: "filled" | "borderless" | "outlined" | undefined;
24
+ }> & {
21
25
  displayName: string;
22
26
  defaultProps: {
23
27
  width: string;
@@ -32,7 +32,8 @@ var SingleMonacoEditor = function SingleMonacoEditor(props) {
32
32
  fullScreen = _useFullScreen.fullScreen;
33
33
  var _useStyles = useStyles({
34
34
  isFullScreen: isFullScreen,
35
- minimapEnabled: (_props$options = props.options) === null || _props$options === void 0 || (_props$options = _props$options.minimap) === null || _props$options === void 0 ? void 0 : _props$options.enabled
35
+ minimapEnabled: (_props$options = props.options) === null || _props$options === void 0 || (_props$options = _props$options.minimap) === null || _props$options === void 0 ? void 0 : _props$options.enabled,
36
+ variant: props.variant
36
37
  }),
37
38
  cx = _useStyles.cx,
38
39
  styles = _useStyles.styles;
@@ -129,7 +130,8 @@ var DiffMonacoEditor = function DiffMonacoEditor(props) {
129
130
  fullScreen = _useFullScreen2.fullScreen;
130
131
  var _useStyles2 = useStyles({
131
132
  isFullScreen: isFullScreen,
132
- diff: true
133
+ diff: true,
134
+ variant: props.variant
133
135
  }),
134
136
  cx = _useStyles2.cx,
135
137
  styles = _useStyles2.styles;
@@ -5,6 +5,7 @@ export declare const useStyles: (props?: {
5
5
  minimapEnabled?: boolean | undefined;
6
6
  isFullScreen?: boolean | undefined;
7
7
  diff?: boolean | undefined;
8
+ variant?: "filled" | "borderless" | "outlined" | undefined;
8
9
  } | undefined) => import("antd-style").ReturnStyles<{
9
10
  base: import("antd-style").SerializedStyles;
10
11
  fullScreenBtn: import("antd-style").SerializedStyles;