@yuntijs/ui 1.0.0-beta.110 → 1.0.0-beta.111
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/Mentions/index.d.ts +1 -0
- package/es/Mentions/index.js +5 -2
- package/es/Mentions/plugins/mention-node/component.js +1 -1
- package/es/Mentions/plugins/mention-picker/hooks.js +1 -0
- package/es/Mentions/plugins/mention-picker/index.js +17 -10
- package/es/Mentions/plugins/mention-picker/menu-item.js +1 -1
- package/es/Mentions/plugins/mention-picker/style.js +1 -1
- package/es/Mentions/plugins/mention-picker/utils.d.ts +3 -1
- package/es/Mentions/plugins/mention-picker/utils.js +3 -0
- package/es/Mentions/style.d.ts +1 -0
- package/es/Mentions/style.js +4 -4
- package/es/Mentions/types.d.ts +1 -1
- package/package.json +1 -1
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
package/es/Mentions/index.d.ts
CHANGED
package/es/Mentions/index.js
CHANGED
|
@@ -44,11 +44,14 @@ export var Mentions = function Mentions(_ref) {
|
|
|
44
44
|
allowSpaces = _ref.allowSpaces,
|
|
45
45
|
punctuation = _ref.punctuation,
|
|
46
46
|
preTriggerChars = _ref.preTriggerChars,
|
|
47
|
-
onSelect = _ref.onSelect
|
|
47
|
+
onSelect = _ref.onSelect,
|
|
48
|
+
_ref$code = _ref.code,
|
|
49
|
+
code = _ref$code === void 0 ? false : _ref$code;
|
|
48
50
|
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
49
51
|
componentDisabled = _ConfigProvider$useCo.componentDisabled;
|
|
50
52
|
var _useStyles = useStyles({
|
|
51
|
-
autoSize: autoSize
|
|
53
|
+
autoSize: autoSize,
|
|
54
|
+
code: code
|
|
52
55
|
}),
|
|
53
56
|
styles = _useStyles.styles,
|
|
54
57
|
cx = _useStyles.cx;
|
|
@@ -47,7 +47,7 @@ export var MentionNodeComponent = /*#__PURE__*/memo(function (_ref) {
|
|
|
47
47
|
}), /*#__PURE__*/_jsx(Flex, {
|
|
48
48
|
className: styles.text,
|
|
49
49
|
gap: 2,
|
|
50
|
-
title: (option === null || option === void 0 ? void 0 : option.label) || variable,
|
|
50
|
+
title: (option === null || option === void 0 ? void 0 : option.selectedLabel) || (option === null || option === void 0 ? void 0 : option.label) || variable,
|
|
51
51
|
children: /*#__PURE__*/_jsx("span", {
|
|
52
52
|
children: (option === null || option === void 0 ? void 0 : option.selectedLabel) || (option === null || option === void 0 ? void 0 : option.label) || variable
|
|
53
53
|
})
|
|
@@ -32,6 +32,7 @@ export var useOptions = function useOptions(allOptions, queryString) {
|
|
|
32
32
|
var options = useMemo(function () {
|
|
33
33
|
var _addOnselect = function _addOnselect(option) {
|
|
34
34
|
var menuOption = _objectSpread(_objectSpread({}, option), {}, {
|
|
35
|
+
title: option.selectedLabel,
|
|
35
36
|
children: undefined,
|
|
36
37
|
onSelect: function onSelect() {
|
|
37
38
|
editor.dispatchCommand(INSERT_MENTION_COMMAND, option.value);
|
|
@@ -1,12 +1,10 @@
|
|
|
1
|
+
import _toConsumableArray from "@babel/runtime/helpers/esm/toConsumableArray";
|
|
1
2
|
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
2
3
|
import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
|
|
3
4
|
import { LexicalTypeaheadMenuPlugin } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
4
5
|
import { ConfigProvider, Tree } from 'antd';
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
// import { LexicalTypeaheadMenuPlugin } from '../LexicalTypeaheadMenuPlugin';
|
|
8
|
-
|
|
9
|
-
import React, { memo, useCallback, useState } from 'react';
|
|
6
|
+
import { flatMap } from 'lodash-es';
|
|
7
|
+
import React, { memo, useCallback, useMemo, useState } from 'react';
|
|
10
8
|
import ReactDOM from 'react-dom';
|
|
11
9
|
import { DEFAULT_PUNCTUATION, PRE_TRIGGER_CHARS } from "../../constants";
|
|
12
10
|
import { useCheckForMentionMatch } from "../../hooks";
|
|
@@ -47,6 +45,14 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
47
45
|
setQueryString = _useState2[1];
|
|
48
46
|
var _useOptions = useOptions(allOptions, queryString),
|
|
49
47
|
options = _useOptions.options;
|
|
48
|
+
var flatOptions = useMemo(function () {
|
|
49
|
+
var _flattenTree = function _flattenTree(nodes) {
|
|
50
|
+
return flatMap(nodes, function (node) {
|
|
51
|
+
return [node].concat(_toConsumableArray(node.children ? _flattenTree(node.children) : []));
|
|
52
|
+
});
|
|
53
|
+
};
|
|
54
|
+
return _flattenTree(options);
|
|
55
|
+
}, [options]);
|
|
50
56
|
var onSelectOption = useCallback(function (selectedOption, nodeToRemove, closeMenu, matchingString) {
|
|
51
57
|
onSelect === null || onSelect === void 0 || onSelect(selectedOption, trigger, queryString);
|
|
52
58
|
editor.update(function () {
|
|
@@ -69,7 +75,8 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
69
75
|
indentSize: 16,
|
|
70
76
|
lineHeight: 32,
|
|
71
77
|
titleHeight: 32,
|
|
72
|
-
paddingXS: 0
|
|
78
|
+
paddingXS: 0,
|
|
79
|
+
nodeHoverBg: 'transparent'
|
|
73
80
|
}
|
|
74
81
|
}
|
|
75
82
|
},
|
|
@@ -86,9 +93,9 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
86
93
|
selectOptionAndCleanUp(info.node);
|
|
87
94
|
},
|
|
88
95
|
titleRender: function titleRender(option) {
|
|
89
|
-
var
|
|
96
|
+
var _flatOptions;
|
|
90
97
|
return /*#__PURE__*/_jsx(MentionMenuItem, {
|
|
91
|
-
isSelected: ((
|
|
98
|
+
isSelected: ((_flatOptions = flatOptions[selectedIndex]) === null || _flatOptions === void 0 ? void 0 : _flatOptions.value) === option.value,
|
|
92
99
|
option: option,
|
|
93
100
|
queryString: queryString,
|
|
94
101
|
showIcon: !option.isChild
|
|
@@ -97,7 +104,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
97
104
|
treeData: options
|
|
98
105
|
})
|
|
99
106
|
});
|
|
100
|
-
}, [options, editor, queryString]);
|
|
107
|
+
}, [options, editor, flatOptions, queryString]);
|
|
101
108
|
var renderMenu = useCallback(function (anchorElementRef, itemProps, _matchingString) {
|
|
102
109
|
var selectedIndex = itemProps.selectedIndex,
|
|
103
110
|
selectOptionAndCleanUp = itemProps.selectOptionAndCleanUp,
|
|
@@ -131,7 +138,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
131
138
|
menuRenderFn: renderMenu,
|
|
132
139
|
onQueryChange: setQueryString,
|
|
133
140
|
onSelectOption: onSelectOption,
|
|
134
|
-
options:
|
|
141
|
+
options: flatOptions,
|
|
135
142
|
triggerFn: checkForMentionMatch
|
|
136
143
|
});
|
|
137
144
|
});
|
|
@@ -55,12 +55,12 @@ export var MentionMenuItem = /*#__PURE__*/memo(function (_ref) {
|
|
|
55
55
|
},
|
|
56
56
|
ref: option.setRefElement,
|
|
57
57
|
tabIndex: -1,
|
|
58
|
+
title: option.htmlTitle || option.label,
|
|
58
59
|
children: [showIcon && /*#__PURE__*/_jsx(Flex, {
|
|
59
60
|
className: styles.menuItemIcon,
|
|
60
61
|
children: option.icon
|
|
61
62
|
}), /*#__PURE__*/_jsxs("div", {
|
|
62
63
|
className: styles.menuItemLabel,
|
|
63
|
-
title: option.label,
|
|
64
64
|
children: [before, /*#__PURE__*/_jsx(Text, {
|
|
65
65
|
mark: true,
|
|
66
66
|
children: middle
|
|
@@ -7,7 +7,7 @@ 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.
|
|
10
|
+
var selectedBg = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillTertiary);
|
|
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),
|
|
@@ -3,6 +3,7 @@ import { MenuOption } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
|
3
3
|
export interface MentionMenuOptionInitParams {
|
|
4
4
|
label: string;
|
|
5
5
|
value: string;
|
|
6
|
+
title?: string;
|
|
6
7
|
data?: any;
|
|
7
8
|
icon?: JSX.Element;
|
|
8
9
|
extraElement?: JSX.Element;
|
|
@@ -16,6 +17,7 @@ export interface MentionMenuOptionInitParams {
|
|
|
16
17
|
export declare class MentionMenuOption extends MenuOption {
|
|
17
18
|
label: string;
|
|
18
19
|
value: string;
|
|
20
|
+
htmlTitle?: string;
|
|
19
21
|
title: string;
|
|
20
22
|
key: string;
|
|
21
23
|
icon?: JSX.Element;
|
|
@@ -27,5 +29,5 @@ export declare class MentionMenuOption extends MenuOption {
|
|
|
27
29
|
data?: any;
|
|
28
30
|
children?: MentionMenuOption[];
|
|
29
31
|
isChild?: boolean;
|
|
30
|
-
constructor({ label, value, data, icon, extraElement, keywords, keyboardShortcut, disabled, onSelect, children, isChild, }: MentionMenuOptionInitParams);
|
|
32
|
+
constructor({ label, value, title, data, icon, extraElement, keywords, keyboardShortcut, disabled, onSelect, children, isChild, }: MentionMenuOptionInitParams);
|
|
31
33
|
}
|
|
@@ -17,6 +17,7 @@ export var MentionMenuOption = /*#__PURE__*/function (_MenuOption) {
|
|
|
17
17
|
var _this;
|
|
18
18
|
var label = _ref.label,
|
|
19
19
|
value = _ref.value,
|
|
20
|
+
title = _ref.title,
|
|
20
21
|
data = _ref.data,
|
|
21
22
|
icon = _ref.icon,
|
|
22
23
|
extraElement = _ref.extraElement,
|
|
@@ -30,6 +31,7 @@ export var MentionMenuOption = /*#__PURE__*/function (_MenuOption) {
|
|
|
30
31
|
_this = _super.call(this, value);
|
|
31
32
|
_defineProperty(_assertThisInitialized(_this), "label", void 0);
|
|
32
33
|
_defineProperty(_assertThisInitialized(_this), "value", void 0);
|
|
34
|
+
_defineProperty(_assertThisInitialized(_this), "htmlTitle", void 0);
|
|
33
35
|
// for Tree, the same as label
|
|
34
36
|
_defineProperty(_assertThisInitialized(_this), "title", void 0);
|
|
35
37
|
// for Tree, the same as value
|
|
@@ -45,6 +47,7 @@ export var MentionMenuOption = /*#__PURE__*/function (_MenuOption) {
|
|
|
45
47
|
_defineProperty(_assertThisInitialized(_this), "isChild", void 0);
|
|
46
48
|
_this.value = value;
|
|
47
49
|
_this.label = label;
|
|
50
|
+
_this.htmlTitle = title;
|
|
48
51
|
_this.title = label;
|
|
49
52
|
_this.key = value;
|
|
50
53
|
_this.keywords = keywords || [];
|
package/es/Mentions/style.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { AutoSize } from './types';
|
|
2
2
|
export declare const useStyles: (props?: {
|
|
3
3
|
autoSize?: AutoSize | undefined;
|
|
4
|
+
code: boolean;
|
|
4
5
|
} | undefined) => import("antd-style").ReturnStyles<{
|
|
5
6
|
wrapper: import("antd-style").SerializedStyles;
|
|
6
7
|
placeholder: import("antd-style").SerializedStyles;
|
package/es/Mentions/style.js
CHANGED
|
@@ -8,13 +8,13 @@ var calculateHeight = function calculateHeight(rows) {
|
|
|
8
8
|
};
|
|
9
9
|
export var useStyles = createStyles(function (_ref, _ref2) {
|
|
10
10
|
var css = _ref.css,
|
|
11
|
-
token = _ref.token
|
|
12
|
-
|
|
13
|
-
|
|
11
|
+
token = _ref.token;
|
|
12
|
+
var autoSize = _ref2.autoSize,
|
|
13
|
+
code = _ref2.code;
|
|
14
14
|
return {
|
|
15
15
|
wrapper: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n position: relative;\n display: inline-block;\n width: 100%;\n min-width: 0;\n "]))),
|
|
16
16
|
placeholder: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n pointer-events: none;\n user-select: none;\n\n position: absolute;\n top: 0;\n left: 13px;\n\n height: ", "px;\n\n font-size: ", "px;\n line-height: ", "px;\n color: ", ";\n "])), inputHeight, token.fontSize, inputHeight, token.colorTextPlaceholder),
|
|
17
|
-
root: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n outline: none;\n border: 1px solid ", ";\n border-radius: ", "px;\n\n margin: 0;\n padding: 4px 11px;\n\n color: ", ";\n font-size: ", "px;\n font-family: ", ";\n\n display: inline-block;\n\n width: 100%;\n min-width: 0;\n\n ", "\n ", "\n overflow: auto;\n\n transition: all ", ";\n &:focus {\n border-color: ", ";\n }\n p {\n margin-bottom: 0;\n margin-block: 0 0;\n line-height: ", "px;\n }\n "])), token.colorBorder, token.borderRadius, token.colorText, token.fontSize, token.fontFamily, (autoSize === null || autoSize === void 0 ? void 0 : autoSize.minRows) && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n min-height: ", "px;\n "])), calculateHeight(autoSize.minRows)), (autoSize === null || autoSize === void 0 ? void 0 : autoSize.maxRows) && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-height: ", "px;\n "])), calculateHeight(autoSize.maxRows)), token.motionDurationMid, token.colorPrimaryBorder, lineHeight),
|
|
17
|
+
root: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n outline: none;\n border: 1px solid ", ";\n border-radius: ", "px;\n\n margin: 0;\n padding: 4px 11px;\n\n color: ", ";\n font-size: ", "px;\n .align-middle {\n vertical-align: middle;\n }\n font-family: ", ";\n\n display: inline-block;\n\n width: 100%;\n min-width: 0;\n\n ", "\n ", "\n overflow: auto;\n\n transition: all ", ";\n &:focus {\n border-color: ", ";\n }\n p {\n margin-bottom: 0;\n margin-block: 0 0;\n line-height: ", "px;\n }\n "])), token.colorBorder, token.borderRadius, token.colorText, token.fontSize, code ? token.fontFamilyCode : token.fontFamily, (autoSize === null || autoSize === void 0 ? void 0 : autoSize.minRows) && css(_templateObject4 || (_templateObject4 = _taggedTemplateLiteral(["\n min-height: ", "px;\n "])), calculateHeight(autoSize.minRows)), (autoSize === null || autoSize === void 0 ? void 0 : autoSize.maxRows) && css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n max-height: ", "px;\n "])), calculateHeight(autoSize.maxRows)), token.motionDurationMid, token.colorPrimaryBorder, lineHeight),
|
|
18
18
|
filled: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n background: ", ";\n border-color: transparent;\n &:hover {\n background: ", ";\n }\n &:focus {\n background: ", ";\n }\n "])), token.colorFillTertiary, token.colorFillSecondary, token.colorBgBase),
|
|
19
19
|
borderless: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n background: transparent;\n border: none;\n "]))),
|
|
20
20
|
disabled: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n cursor: not-allowed;\n color: ", ";\n background: ", ";\n "])), token.colorTextDisabled, token.colorBgContainerDisabled)
|
package/es/Mentions/types.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MentionMenuOptionInitParams } from './plugins/mention-picker/utils';
|
|
2
|
-
export interface MentionOption extends Omit<MentionMenuOptionInitParams, 'onSelect' | 'children'> {
|
|
2
|
+
export interface MentionOption extends Omit<MentionMenuOptionInitParams, 'onSelect' | 'children' | 'title'> {
|
|
3
3
|
/** 选中后展示的 label 名称,不指定则直接使用 label */
|
|
4
4
|
selectedLabel?: string;
|
|
5
5
|
error?: string;
|