@yuntijs/ui 1.0.0-beta.9 → 1.0.0-beta.90

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 (241) hide show
  1. package/es/App/index.d.ts +7 -0
  2. package/es/App/index.js +19 -0
  3. package/es/ButtonGroup/index.d.ts +24 -0
  4. package/es/ButtonGroup/index.js +66 -0
  5. package/es/Card/index.d.ts +1 -0
  6. package/es/Card/index.js +1 -0
  7. package/es/CardList/Item/index.d.ts +4 -0
  8. package/es/CardList/Item/index.js +43 -0
  9. package/es/CardList/Item/style.d.ts +0 -0
  10. package/es/CardList/Item/style.js +0 -0
  11. package/es/CardList/index.d.ts +2 -0
  12. package/es/CardList/index.js +39 -0
  13. package/es/ChatInputArea/desktop/ChatInputArea.d.ts +19 -0
  14. package/es/ChatInputArea/desktop/ChatInputArea.js +72 -0
  15. package/es/ChatInputArea/index.d.ts +6 -0
  16. package/es/ChatInputArea/index.js +6 -0
  17. package/es/ChatItem/components/Actions.d.ts +10 -0
  18. package/es/ChatItem/components/Actions.js +23 -0
  19. package/es/ChatItem/components/MessageContent.d.ts +21 -0
  20. package/es/ChatItem/components/MessageContent.js +59 -0
  21. package/es/ChatItem/index.d.ts +4 -0
  22. package/es/ChatItem/index.js +120 -0
  23. package/es/ChatItem/style.d.ts +25 -0
  24. package/es/ChatItem/style.js +39 -0
  25. package/es/ChatItem/type.d.ts +86 -0
  26. package/es/ChatItem/type.js +1 -0
  27. package/es/CollapseGroup/index.d.ts +4 -0
  28. package/es/CollapseGroup/index.js +23 -0
  29. package/es/CollapseGroup/style.d.ts +3 -0
  30. package/es/CollapseGroup/style.js +11 -0
  31. package/es/ConfigProvider/index.d.ts +3 -0
  32. package/es/ConfigProvider/index.js +17 -11
  33. package/es/Descriptions/index.d.ts +14 -0
  34. package/es/Descriptions/index.js +31 -0
  35. package/es/Descriptions/style.d.ts +4 -0
  36. package/es/Descriptions/style.js +24 -0
  37. package/es/Divider/index.d.ts +38 -0
  38. package/es/Divider/index.js +66 -0
  39. package/es/Divider/style.d.ts +3 -0
  40. package/es/Divider/style.js +12 -0
  41. package/es/DragPanel/index.d.ts +10 -0
  42. package/es/DragPanel/index.js +97 -0
  43. package/es/DragPanel/style.d.ts +7 -0
  44. package/es/DragPanel/style.js +15 -0
  45. package/es/Drawer/index.d.ts +13 -0
  46. package/es/Drawer/index.js +20 -0
  47. package/es/Drawer/style.d.ts +4 -0
  48. package/es/Drawer/style.js +16 -0
  49. package/es/Dropdown/index.d.ts +14 -0
  50. package/es/Dropdown/index.js +59 -0
  51. package/es/Dropdown/style.d.ts +7 -0
  52. package/es/Dropdown/style.js +13 -0
  53. package/es/EditableMessage/index.d.ts +75 -0
  54. package/es/EditableMessage/index.js +99 -0
  55. package/es/Form/collapse-list/index.d.ts +40 -0
  56. package/es/Form/collapse-list/index.js +209 -0
  57. package/es/Form/collapse-list/style.d.ts +5 -0
  58. package/es/Form/collapse-list/style.js +13 -0
  59. package/es/Form/index.d.ts +8 -0
  60. package/es/Form/index.js +5 -0
  61. package/es/FormHelper/autoFocus.d.ts +10 -0
  62. package/es/FormHelper/autoFocus.js +38 -0
  63. package/es/FormHelper/index.d.ts +13 -0
  64. package/es/FormHelper/index.js +41 -0
  65. package/es/Highlighter/FullFeatured.d.ts +18 -0
  66. package/es/Highlighter/FullFeatured.js +102 -0
  67. package/es/Highlighter/SyntaxHighlighter/index.d.ts +7 -0
  68. package/es/Highlighter/SyntaxHighlighter/index.js +51 -0
  69. package/es/Highlighter/SyntaxHighlighter/style.d.ts +5 -0
  70. package/es/Highlighter/SyntaxHighlighter/style.js +16 -0
  71. package/es/Highlighter/index.d.ts +50 -0
  72. package/es/Highlighter/index.js +77 -0
  73. package/es/Highlighter/style.d.ts +9 -0
  74. package/es/Highlighter/style.js +23 -0
  75. package/es/Highlighter/theme.d.ts +1 -0
  76. package/es/Highlighter/theme.js +1661 -0
  77. package/es/JsonViewer/index.d.ts +21 -0
  78. package/es/JsonViewer/index.js +120 -0
  79. package/es/JsonViewer/style.d.ts +7 -0
  80. package/es/JsonViewer/style.js +19 -0
  81. package/es/LogViewer/index.d.ts +10 -0
  82. package/es/LogViewer/index.js +141 -0
  83. package/es/LogViewer/style.d.ts +6 -0
  84. package/es/LogViewer/style.js +16 -0
  85. package/es/LogViewer/types.d.ts +235 -0
  86. package/es/LogViewer/types.js +1 -0
  87. package/es/Mentions/constants.d.ts +6 -0
  88. package/es/Mentions/constants.js +28 -0
  89. package/es/Mentions/hooks.d.ts +20 -0
  90. package/es/Mentions/hooks.js +133 -0
  91. package/es/Mentions/index.d.ts +23 -0
  92. package/es/Mentions/index.js +157 -0
  93. package/es/Mentions/plugins/OnBlurBlockPlugin.d.ts +7 -0
  94. package/es/Mentions/plugins/OnBlurBlockPlugin.js +35 -0
  95. package/es/Mentions/plugins/custom-text/node.d.ts +11 -0
  96. package/es/Mentions/plugins/custom-text/node.js +72 -0
  97. package/es/Mentions/plugins/editable.d.ts +4 -0
  98. package/es/Mentions/plugins/editable.js +13 -0
  99. package/es/Mentions/plugins/mention-node/component.d.ts +6 -0
  100. package/es/Mentions/plugins/mention-node/component.js +64 -0
  101. package/es/Mentions/plugins/mention-node/index.d.ts +9 -0
  102. package/es/Mentions/plugins/mention-node/index.js +32 -0
  103. package/es/Mentions/plugins/mention-node/node.d.ts +22 -0
  104. package/es/Mentions/plugins/mention-node/node.js +100 -0
  105. package/es/Mentions/plugins/mention-node/replacement.d.ts +5 -0
  106. package/es/Mentions/plugins/mention-node/replacement.js +43 -0
  107. package/es/Mentions/plugins/mention-node/style.d.ts +8 -0
  108. package/es/Mentions/plugins/mention-node/style.js +47 -0
  109. package/es/Mentions/plugins/mention-node/utils.d.ts +4 -0
  110. package/es/Mentions/plugins/mention-node/utils.js +10 -0
  111. package/es/Mentions/plugins/mention-picker/hooks.d.ts +5 -0
  112. package/es/Mentions/plugins/mention-picker/hooks.js +65 -0
  113. package/es/Mentions/plugins/mention-picker/index.d.ts +39 -0
  114. package/es/Mentions/plugins/mention-picker/index.js +137 -0
  115. package/es/Mentions/plugins/mention-picker/menu-item.d.ts +12 -0
  116. package/es/Mentions/plugins/mention-picker/menu-item.js +73 -0
  117. package/es/Mentions/plugins/mention-picker/menu.d.ts +10 -0
  118. package/es/Mentions/plugins/mention-picker/menu.js +31 -0
  119. package/es/Mentions/plugins/mention-picker/style.d.ts +11 -0
  120. package/es/Mentions/plugins/mention-picker/style.js +19 -0
  121. package/es/Mentions/plugins/mention-picker/utils.d.ts +31 -0
  122. package/es/Mentions/plugins/mention-picker/utils.js +66 -0
  123. package/es/Mentions/provider.d.ts +12 -0
  124. package/es/Mentions/provider.js +15 -0
  125. package/es/Mentions/style.d.ts +11 -0
  126. package/es/Mentions/style.js +22 -0
  127. package/es/Mentions/types.d.ts +12 -0
  128. package/es/Mentions/types.js +1 -0
  129. package/es/Mentions/utils.d.ts +9 -0
  130. package/es/Mentions/utils.js +95 -0
  131. package/es/Modal/index.d.ts +19 -0
  132. package/es/Modal/index.js +36 -0
  133. package/es/Modal/style.d.ts +4 -0
  134. package/es/Modal/style.js +17 -0
  135. package/es/MonacoEditor/base/controller.d.ts +17 -0
  136. package/es/MonacoEditor/base/controller.js +49 -0
  137. package/es/MonacoEditor/base/helper.d.ts +65 -0
  138. package/es/MonacoEditor/base/helper.js +324 -0
  139. package/es/MonacoEditor/base/index.d.ts +39 -0
  140. package/es/MonacoEditor/base/index.js +238 -0
  141. package/es/MonacoEditor/base/monaco.d.ts +6 -0
  142. package/es/MonacoEditor/base/monaco.js +64 -0
  143. package/es/MonacoEditor/{style.d.ts → base/style.d.ts} +4 -1
  144. package/es/MonacoEditor/base/style.js +43 -0
  145. package/es/MonacoEditor/index.d.ts +5 -4
  146. package/es/MonacoEditor/index.js +26 -62
  147. package/es/Page/Breadcrumb/index.d.ts +9 -0
  148. package/es/Page/Breadcrumb/index.js +56 -0
  149. package/es/Page/Content/index.d.ts +4 -0
  150. package/es/Page/Content/index.js +59 -0
  151. package/es/Page/Content/style.d.ts +3 -0
  152. package/es/Page/Content/style.js +12 -0
  153. package/es/Page/Footer/index.d.ts +2 -0
  154. package/es/Page/Footer/index.js +6 -0
  155. package/es/Page/Header/Icon.d.ts +17 -0
  156. package/es/Page/Header/Icon.js +42 -0
  157. package/es/Page/Header/index.d.ts +43 -0
  158. package/es/Page/Header/index.js +202 -0
  159. package/es/Page/Header/style.d.ts +12 -0
  160. package/es/Page/Header/style.js +21 -0
  161. package/es/Page/Page.d.ts +9 -0
  162. package/es/Page/Page.js +49 -0
  163. package/es/Page/PageContext.d.ts +15 -0
  164. package/es/Page/PageContext.js +21 -0
  165. package/es/Page/Title/index.d.ts +5 -0
  166. package/es/Page/Title/index.js +18 -0
  167. package/es/Page/Title/style.d.ts +3 -0
  168. package/es/Page/Title/style.js +10 -0
  169. package/es/Page/index.d.ts +18 -0
  170. package/es/Page/index.js +15 -0
  171. package/es/Page/style.d.ts +3 -0
  172. package/es/Page/style.js +10 -0
  173. package/es/ProCard/Card/index.d.ts +6 -0
  174. package/es/ProCard/Card/index.js +25 -0
  175. package/es/ProCard/Card/style.d.ts +7 -0
  176. package/es/ProCard/Card/style.js +15 -0
  177. package/es/ProCard/Content/index.d.ts +4 -0
  178. package/es/ProCard/Content/index.js +24 -0
  179. package/es/ProCard/Content/style.d.ts +3 -0
  180. package/es/ProCard/Content/style.js +10 -0
  181. package/es/ProCard/Descriptions/index.d.ts +4 -0
  182. package/es/ProCard/Descriptions/index.js +28 -0
  183. package/es/ProCard/Descriptions/style.d.ts +3 -0
  184. package/es/ProCard/Descriptions/style.js +12 -0
  185. package/es/ProCard/Header/index.d.ts +15 -0
  186. package/es/ProCard/Header/index.js +86 -0
  187. package/es/ProCard/Header/style.d.ts +12 -0
  188. package/es/ProCard/Header/style.js +21 -0
  189. package/es/ProCard/index.d.ts +13 -0
  190. package/es/ProCard/index.js +8 -0
  191. package/es/SelectCard/index.d.ts +33 -0
  192. package/es/SelectCard/index.js +132 -0
  193. package/es/SelectCard/style.d.ts +10 -0
  194. package/es/SelectCard/style.js +42 -0
  195. package/es/SliderInput/index.js +2 -2
  196. package/es/Status/index.d.ts +7 -0
  197. package/es/Status/index.js +39 -0
  198. package/es/Status/style.d.ts +4 -0
  199. package/es/Status/style.js +14 -0
  200. package/es/Table/collapse/index.d.ts +9 -0
  201. package/es/Table/collapse/index.js +39 -0
  202. package/es/Table/collapse/style.d.ts +3 -0
  203. package/es/Table/collapse/style.js +11 -0
  204. package/es/Table/index.d.ts +20 -0
  205. package/es/Table/index.js +56 -0
  206. package/es/Typography/index.d.ts +32 -0
  207. package/es/Typography/index.js +77 -0
  208. package/es/WaveformIcon/index.d.ts +9 -0
  209. package/es/WaveformIcon/index.js +51 -0
  210. package/es/hooks/languageMap.d.ts +1 -0
  211. package/es/hooks/languageMap.js +1 -0
  212. package/es/hooks/useHighlight.d.ts +5 -0
  213. package/es/hooks/useHighlight.js +78 -0
  214. package/es/index.d.ts +38 -3
  215. package/es/index.js +48 -3
  216. package/es/notification/index.d.ts +24 -0
  217. package/es/notification/index.js +237 -0
  218. package/es/notification/style.d.ts +2 -0
  219. package/es/notification/style.js +28 -0
  220. package/es/styles/colors/colors.d.ts +39 -0
  221. package/es/styles/colors/colors.js +86 -0
  222. package/es/styles/colors/generateColorPalette.d.ts +11 -0
  223. package/es/styles/colors/generateColorPalette.js +31 -0
  224. package/es/styles/colors/neutralColors.d.ts +9 -0
  225. package/es/styles/colors/neutralColors.js +32 -0
  226. package/es/styles/index.d.ts +4 -0
  227. package/es/styles/index.js +4 -0
  228. package/es/useSpeechSynthes/const/polyfill.d.ts +3 -0
  229. package/es/useSpeechSynthes/const/polyfill.js +21 -0
  230. package/es/useSpeechSynthes/index.d.ts +13 -0
  231. package/es/useSpeechSynthes/index.js +69 -0
  232. package/es/utils/constants.d.ts +1 -0
  233. package/es/utils/constants.js +1 -0
  234. package/es/utils/tools.d.ts +1 -0
  235. package/es/utils/tools.js +1 -0
  236. package/package.json +31 -9
  237. package/umd/index.min.css +2 -0
  238. package/umd/index.min.css.map +1 -0
  239. package/umd/index.min.js +1 -1
  240. package/umd/index.min.js.map +1 -1
  241. package/es/MonacoEditor/style.js +0 -24
@@ -0,0 +1,100 @@
1
+ import _classCallCheck from "@babel/runtime/helpers/esm/classCallCheck";
2
+ import _createClass from "@babel/runtime/helpers/esm/createClass";
3
+ import _assertThisInitialized from "@babel/runtime/helpers/esm/assertThisInitialized";
4
+ import _inherits from "@babel/runtime/helpers/esm/inherits";
5
+ import _possibleConstructorReturn from "@babel/runtime/helpers/esm/possibleConstructorReturn";
6
+ import _getPrototypeOf from "@babel/runtime/helpers/esm/getPrototypeOf";
7
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
8
+ function _createSuper(Derived) { var hasNativeReflectConstruct = _isNativeReflectConstruct(); return function _createSuperInternal() { var Super = _getPrototypeOf(Derived), result; if (hasNativeReflectConstruct) { var NewTarget = _getPrototypeOf(this).constructor; result = Reflect.construct(Super, arguments, NewTarget); } else { result = Super.apply(this, arguments); } return _possibleConstructorReturn(this, result); }; }
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
+ import { DecoratorNode } from 'lexical';
11
+ import React from 'react';
12
+
13
+ // import type { MentionsOptionsMap } from '../../types';
14
+ import { MentionNodeComponent } from "./component";
15
+ import { jsx as _jsx } from "react/jsx-runtime";
16
+ export var MentionNode = /*#__PURE__*/function (_DecoratorNode) {
17
+ _inherits(MentionNode, _DecoratorNode);
18
+ var _super = _createSuper(MentionNode);
19
+ // constructor(variable: string, optionsMap?: MentionsOptionsMap, key?: NodeKey) {
20
+ function MentionNode(variable, key) {
21
+ var _this;
22
+ _classCallCheck(this, MentionNode);
23
+ _this = _super.call(this, key);
24
+ _defineProperty(_assertThisInitialized(_this), "__variable", void 0);
25
+ _this.__variable = variable;
26
+ return _this;
27
+ }
28
+ _createClass(MentionNode, [{
29
+ key: "isInline",
30
+ value: function isInline() {
31
+ return true;
32
+ }
33
+ }, {
34
+ key: "createDOM",
35
+ value: function createDOM() {
36
+ var div = document.createElement('div');
37
+ div.style.display = 'inline-flex';
38
+ div.style.alignItems = 'center';
39
+ div.style.verticalAlign = 'middle';
40
+ return div;
41
+ }
42
+ }, {
43
+ key: "updateDOM",
44
+ value: function updateDOM() {
45
+ return false;
46
+ }
47
+ }, {
48
+ key: "decorate",
49
+ value: function decorate() {
50
+ return /*#__PURE__*/_jsx(MentionNodeComponent, {
51
+ nodeKey: this.getKey(),
52
+ variable: this.__variable
53
+ });
54
+ }
55
+ }, {
56
+ key: "exportJSON",
57
+ value: function exportJSON() {
58
+ return {
59
+ type: 'mention-node',
60
+ version: 1,
61
+ variable: this.getVariable()
62
+ };
63
+ }
64
+ }, {
65
+ key: "getVariable",
66
+ value: function getVariable() {
67
+ var self = this.getLatest();
68
+ return self.__variable;
69
+ }
70
+ }, {
71
+ key: "getTextContent",
72
+ value: function getTextContent() {
73
+ return "{{".concat(this.getVariable(), "}}");
74
+ }
75
+ }], [{
76
+ key: "getType",
77
+ value: function getType() {
78
+ return 'mention-node';
79
+ }
80
+ }, {
81
+ key: "clone",
82
+ value: function clone(node) {
83
+ return new MentionNode(node.__variable, node.__key);
84
+ }
85
+ }, {
86
+ key: "importJSON",
87
+ value: function importJSON(serializedNode) {
88
+ // eslint-disable-next-line @typescript-eslint/no-use-before-define
89
+ var node = $createMentionNode(serializedNode.variable);
90
+ return node;
91
+ }
92
+ }]);
93
+ return MentionNode;
94
+ }(DecoratorNode);
95
+ export function $createMentionNode(variable) {
96
+ return new MentionNode(variable);
97
+ }
98
+ export function $isMentionNode(node) {
99
+ return node instanceof MentionNode;
100
+ }
@@ -0,0 +1,5 @@
1
+ import React from 'react';
2
+ export interface MentionNodePluginReplacementProps {
3
+ onInsert?: () => void;
4
+ }
5
+ export declare const MentionNodePluginReplacement: React.FC<MentionNodePluginReplacementProps>;
@@ -0,0 +1,43 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
3
+ import { mergeRegister } from '@lexical/utils';
4
+ import { $applyNodeReplacement } from 'lexical';
5
+ import { memo, useCallback, useEffect } from 'react';
6
+ import { decoratorTransform } from "../../utils";
7
+ import { CustomTextNode } from "../custom-text/node";
8
+ import { $createMentionNode, MentionNode } from "./node";
9
+ import { MENTION_REGEX } from "./utils";
10
+ export var MentionNodePluginReplacement = /*#__PURE__*/memo(function (_ref) {
11
+ var onInsert = _ref.onInsert;
12
+ var _useLexicalComposerCo = useLexicalComposerContext(),
13
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
14
+ editor = _useLexicalComposerCo2[0];
15
+ useEffect(function () {
16
+ if (!editor.hasNodes([MentionNode])) throw new Error('MentionNodePlugin: MentionNode not registered on editor');
17
+ }, [editor]);
18
+ var createMentionNode = useCallback(function (textNode) {
19
+ if (onInsert) onInsert();
20
+ var nodePathString = textNode.getTextContent().slice(2, -2);
21
+ return $applyNodeReplacement($createMentionNode(nodePathString));
22
+ }, [onInsert]);
23
+ var getMatch = useCallback(function (text) {
24
+ var matchArr = MENTION_REGEX.exec(text);
25
+ if (matchArr === null) return null;
26
+ var startOffset = matchArr.index;
27
+ var endOffset = startOffset + matchArr[0].length;
28
+ return {
29
+ end: endOffset,
30
+ start: startOffset
31
+ };
32
+ }, []);
33
+ var transformListener = useCallback(function (textNode) {
34
+ MENTION_REGEX.lastIndex = 0;
35
+ return decoratorTransform(textNode, getMatch, createMentionNode);
36
+ }, [createMentionNode, getMatch]);
37
+ useEffect(function () {
38
+ MENTION_REGEX.lastIndex = 0;
39
+ return mergeRegister(editor.registerNodeTransform(CustomTextNode, transformListener));
40
+ // eslint-disable-next-line react-hooks/exhaustive-deps
41
+ }, []);
42
+ return null;
43
+ });
@@ -0,0 +1,8 @@
1
+ export declare const useStyles: (props?: {
2
+ isSelected?: boolean | undefined;
3
+ isError?: boolean | undefined;
4
+ } | undefined) => import("antd-style").ReturnStyles<{
5
+ root: import("antd-style").SerializedStyles;
6
+ text: import("antd-style").SerializedStyles;
7
+ error: import("antd-style").SerializedStyles;
8
+ }>;
@@ -0,0 +1,47 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
+ var css = _ref.css,
6
+ token = _ref.token,
7
+ prefixCls = _ref.prefixCls;
8
+ var isSelected = _ref2.isSelected,
9
+ isError = _ref2.isError;
10
+ var getColors = function getColors() {
11
+ if (isError) {
12
+ if (isSelected) {
13
+ return {
14
+ background: token.colorErrorBgActive,
15
+ border: token.colorErrorBorderHover,
16
+ color: token.colorErrorTextActive
17
+ };
18
+ }
19
+ return {
20
+ background: token.colorErrorBg,
21
+ border: token.colorErrorBorder,
22
+ color: token.colorErrorText
23
+ };
24
+ }
25
+ if (isSelected) {
26
+ return {
27
+ background: token.colorInfoBgHover,
28
+ border: token.colorInfoBorder,
29
+ color: token.colorInfoText
30
+ };
31
+ }
32
+ return {
33
+ background: token.colorFillTertiary,
34
+ border: 'transparent',
35
+ color: token.colorInfoText
36
+ };
37
+ };
38
+ var _getColors = getColors(),
39
+ background = _getColors.background,
40
+ border = _getColors.border,
41
+ color = _getColors.color;
42
+ return {
43
+ root: css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n user-select: none;\n\n margin: 1px 2px;\n padding: 0 4px;\n\n font-family: ", ";\n color: ", ";\n\n background-color: ", ";\n border: 1px solid ", ";\n border-radius: ", "px;\n "])), token.fontFamilyCode, color, background, border, token.borderRadius),
44
+ text: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: inline-block;\n\n max-width: 200px;\n\n color: ", ";\n text-overflow: ellipsis;\n white-space: nowrap;\n "])), token.colorTextSecondary),
45
+ error: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorErrorText)
46
+ };
47
+ });
@@ -0,0 +1,4 @@
1
+ export declare const INSERT_MENTION_COMMAND: import("lexical").LexicalCommand<unknown>;
2
+ export declare const DELETE_MENTION_COMMAND: import("lexical").LexicalCommand<unknown>;
3
+ export declare const CLEAR_HIDE_MENU_TIMEOUT: import("lexical").LexicalCommand<unknown>;
4
+ export declare const MENTION_REGEX: RegExp;
@@ -0,0 +1,10 @@
1
+ import { createCommand } from 'lexical';
2
+ export var INSERT_MENTION_COMMAND = createCommand('INSERT_MENTION_COMMAND');
3
+ export var DELETE_MENTION_COMMAND = createCommand('DELETE_MENTION_COMMAND');
4
+ export var CLEAR_HIDE_MENU_TIMEOUT = createCommand('CLEAR_HIDE_MENU_TIMEOUT');
5
+
6
+ // export const MENTION_REGEX = /{{([\w-]{1,50}(\.[_a-z]\w{0,29}){1,10})}}/gi;
7
+ // export const MENTION_REGEX = /{{(.+?)}}/g;
8
+ // {{plugin-m67m66l8-794.json."id"}}
9
+ // {{plugin-m67m66l8-794.json."tags"[0]."id"}}
10
+ export var MENTION_REGEX = /{{([\w-]{1,50}(\."?[_a-z][\w"[\]]*){1,10})}}/gi;
@@ -0,0 +1,5 @@
1
+ import type { MentionOption } from '../../types';
2
+ import { MentionMenuOption } from './utils';
3
+ export declare const useOptions: (allOptions: MentionOption[], queryString: string | null) => {
4
+ options: MentionMenuOption[];
5
+ };
@@ -0,0 +1,65 @@
1
+ import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
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; }
5
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
6
+ import { escapeRegExp } from 'lodash-es';
7
+ import { useCallback, useMemo } from 'react';
8
+ import { INSERT_MENTION_COMMAND } from "../mention-node";
9
+ import { MentionMenuOption } from "./utils";
10
+ var filterOptionWithChildren = function filterOptionWithChildren(option, filterOption) {
11
+ var _option$children;
12
+ option.children = (_option$children = option.children) === null || _option$children === void 0 ? void 0 : _option$children.filter(function (o) {
13
+ if (!o.children) {
14
+ return filterOption(o);
15
+ }
16
+ var newO = filterOptionWithChildren(o, filterOption);
17
+ return filterOption(o) || (newO.children || []).length > 0;
18
+ });
19
+ return option;
20
+ };
21
+ export var useOptions = function useOptions(allOptions, queryString) {
22
+ var _useLexicalComposerCo = useLexicalComposerContext(),
23
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
24
+ editor = _useLexicalComposerCo2[0];
25
+ var filterOption = useCallback(function (option) {
26
+ var _option$keywords;
27
+ var regex = new RegExp(escapeRegExp(queryString), 'i');
28
+ return regex.test(option.label) || ((_option$keywords = option.keywords) === null || _option$keywords === void 0 ? void 0 : _option$keywords.some(function (keyword) {
29
+ return regex.test(keyword);
30
+ })) || false;
31
+ }, [queryString]);
32
+ var options = useMemo(function () {
33
+ var _addOnselect = function _addOnselect(option) {
34
+ var menuOption = _objectSpread(_objectSpread({}, option), {}, {
35
+ children: undefined,
36
+ onSelect: function onSelect() {
37
+ editor.dispatchCommand(INSERT_MENTION_COMMAND, option.value);
38
+ }
39
+ });
40
+ if (option.children) {
41
+ menuOption.children = option.children.map(function (o) {
42
+ return _addOnselect(o);
43
+ });
44
+ }
45
+ return menuOption;
46
+ };
47
+ var menuOptions = allOptions.map(function (o) {
48
+ return new MentionMenuOption(_addOnselect(o));
49
+ });
50
+ if (!queryString) {
51
+ return menuOptions;
52
+ }
53
+ return menuOptions.map(function (o) {
54
+ if (!o.children) {
55
+ return o;
56
+ }
57
+ return filterOptionWithChildren(o, filterOption);
58
+ }).filter(function (o) {
59
+ return filterOption(o) || (o.children || []).length > 0;
60
+ });
61
+ }, [allOptions, queryString, editor, filterOption]);
62
+ return {
63
+ options: options
64
+ };
65
+ };
@@ -0,0 +1,39 @@
1
+ import React from 'react';
2
+ import type { MentionOption } from '../../types';
3
+ import { type MentionMenuOption } from './utils';
4
+ export interface MentionPickerPluginProps {
5
+ /** The className of menu overlay */
6
+ overlayClassName?: string;
7
+ /** The options of menu */
8
+ options?: MentionOption[];
9
+ /**
10
+ * The characters that trigger the mention menu. Needed to tell the plugin
11
+ * when to call the query function.
12
+ */
13
+ triggers: string[];
14
+ /**
15
+ * If `true`, mentions can contain spaces.
16
+ * @default true
17
+ */
18
+ allowSpaces?: boolean;
19
+ /**
20
+ * Regular expression that matches punctuation characters when looking for
21
+ * mentions.
22
+ *
23
+ * In addition to spaces, these characters can appear directly after a mention.
24
+ * E.g. `@John!` or `@John,`.
25
+ * @default \.,\*\?\$\|#{}\(\)\^\[\]\/!%'\"~=<>_:;
26
+ */
27
+ punctuation?: string;
28
+ /**
29
+ * Regular expression that matches characters that can appear directly
30
+ * before the trigger character.
31
+ * @default \(
32
+ */
33
+ preTriggerChars?: string;
34
+ /**
35
+ * When mention selected, this func will be called
36
+ */
37
+ onSelect?: (option: MentionMenuOption, trigger: string | null, queryString: string | null) => void;
38
+ }
39
+ export declare const MentionPickerPlugin: React.FC<MentionPickerPluginProps>;
@@ -0,0 +1,137 @@
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import { useLexicalComposerContext } from '@lexical/react/LexicalComposerContext';
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
+
9
+ import React, { memo, useCallback, useState } from 'react';
10
+ import ReactDOM from 'react-dom';
11
+ import { DEFAULT_PUNCTUATION, PRE_TRIGGER_CHARS } from "../../constants";
12
+ import { useCheckForMentionMatch } from "../../hooks";
13
+ import { CLEAR_HIDE_MENU_TIMEOUT } from "../mention-node";
14
+ import { useOptions } from "./hooks";
15
+ import { MentionMenu } from "./menu";
16
+ import { MentionMenuItem } from "./menu-item";
17
+ import { useStyles } from "./style";
18
+ import { jsx as _jsx } from "react/jsx-runtime";
19
+ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
20
+ var overlayClassName = _ref.overlayClassName,
21
+ triggers = _ref.triggers,
22
+ _ref$options = _ref.options,
23
+ allOptions = _ref$options === void 0 ? [] : _ref$options,
24
+ _ref$allowSpaces = _ref.allowSpaces,
25
+ allowSpaces = _ref$allowSpaces === void 0 ? true : _ref$allowSpaces,
26
+ _ref$punctuation = _ref.punctuation,
27
+ punctuation = _ref$punctuation === void 0 ? DEFAULT_PUNCTUATION : _ref$punctuation,
28
+ _ref$preTriggerChars = _ref.preTriggerChars,
29
+ preTriggerChars = _ref$preTriggerChars === void 0 ? PRE_TRIGGER_CHARS : _ref$preTriggerChars,
30
+ onSelect = _ref.onSelect;
31
+ var _useStyles = useStyles({}),
32
+ cx = _useStyles.cx,
33
+ styles = _useStyles.styles;
34
+ var _useLexicalComposerCo = useLexicalComposerContext(),
35
+ _useLexicalComposerCo2 = _slicedToArray(_useLexicalComposerCo, 1),
36
+ editor = _useLexicalComposerCo2[0];
37
+ var _useCheckForMentionMa = useCheckForMentionMatch(triggers, {
38
+ punctuation: punctuation,
39
+ preTriggerChars: preTriggerChars,
40
+ allowSpaces: allowSpaces
41
+ }),
42
+ trigger = _useCheckForMentionMa.trigger,
43
+ checkForMentionMatch = _useCheckForMentionMa.checkForMentionMatch;
44
+ var _useState = useState(null),
45
+ _useState2 = _slicedToArray(_useState, 2),
46
+ queryString = _useState2[0],
47
+ setQueryString = _useState2[1];
48
+ var _useOptions = useOptions(allOptions, queryString),
49
+ options = _useOptions.options;
50
+ var onSelectOption = useCallback(function (selectedOption, nodeToRemove, closeMenu, matchingString) {
51
+ onSelect === null || onSelect === void 0 || onSelect(selectedOption, trigger, queryString);
52
+ editor.update(function () {
53
+ if (nodeToRemove && selectedOption !== null && selectedOption !== void 0 && selectedOption.key) {
54
+ nodeToRemove.remove();
55
+ }
56
+ if (selectedOption !== null && selectedOption !== void 0 && selectedOption.onSelect) {
57
+ selectedOption.onSelect(matchingString);
58
+ }
59
+ closeMenu();
60
+ });
61
+ }, [editor, onSelect, queryString, trigger]);
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
+ showIcon: !option.isChild
95
+ });
96
+ },
97
+ treeData: options
98
+ })
99
+ });
100
+ }, [options, editor, queryString]);
101
+ var renderMenu = useCallback(function (anchorElementRef, itemProps, _matchingString) {
102
+ var selectedIndex = itemProps.selectedIndex,
103
+ selectOptionAndCleanUp = itemProps.selectOptionAndCleanUp,
104
+ setHighlightedIndex = itemProps.setHighlightedIndex;
105
+ if (anchorElementRef.current) {
106
+ return /*#__PURE__*/ReactDOM.createPortal( /*#__PURE__*/_jsx("div", {
107
+ className: cx(styles.menuOverlay, overlayClassName),
108
+ role: "menu",
109
+ children: options.some(function (o) {
110
+ return (o.children || []).length > 0;
111
+ }) ? renderMenuTree(itemProps) : /*#__PURE__*/_jsx(MentionMenu, {
112
+ onClick: function onClick(index, option) {
113
+ if (option.disabled) return;
114
+ setHighlightedIndex(index);
115
+ selectOptionAndCleanUp(option);
116
+ },
117
+ onMouseEnter: function onMouseEnter(index, option) {
118
+ if (option.disabled) return;
119
+ setHighlightedIndex(index);
120
+ },
121
+ options: options,
122
+ queryString: queryString,
123
+ selectedIndex: selectedIndex
124
+ })
125
+ }), anchorElementRef.current);
126
+ }
127
+ return null;
128
+ }, [cx, options, overlayClassName, queryString, renderMenuTree, styles.menuOverlay]);
129
+ return /*#__PURE__*/_jsx(LexicalTypeaheadMenuPlugin, {
130
+ anchorClassName: styles.anchor,
131
+ menuRenderFn: renderMenu,
132
+ onQueryChange: setQueryString,
133
+ onSelectOption: onSelectOption,
134
+ options: options,
135
+ triggerFn: checkForMentionMatch
136
+ });
137
+ });
@@ -0,0 +1,12 @@
1
+ import React from 'react';
2
+ import { MentionMenuOption } from './utils';
3
+ export interface MentionMenuItemProps {
4
+ index?: number;
5
+ isSelected: boolean;
6
+ onClick?: (index: number, option: MentionMenuOption) => void;
7
+ onMouseEnter?: (index: number, option: MentionMenuOption) => void;
8
+ option: MentionMenuOption;
9
+ queryString: string | null;
10
+ showIcon?: boolean;
11
+ }
12
+ export declare const MentionMenuItem: React.FC<MentionMenuItemProps>;
@@ -0,0 +1,73 @@
1
+ import { Flex } from 'antd';
2
+ import { escapeRegExp } from 'lodash-es';
3
+ import React, { memo, useMemo } from 'react';
4
+ import Typography from "../../../Typography";
5
+ import { useStyles } from "./style";
6
+ import { jsx as _jsx } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ var Text = Typography.Text;
9
+ export var MentionMenuItem = /*#__PURE__*/memo(function (_ref) {
10
+ var index = _ref.index,
11
+ isSelected = _ref.isSelected,
12
+ _onClick = _ref.onClick,
13
+ _onMouseEnter = _ref.onMouseEnter,
14
+ option = _ref.option,
15
+ queryString = _ref.queryString,
16
+ _ref$showIcon = _ref.showIcon,
17
+ showIcon = _ref$showIcon === void 0 ? true : _ref$showIcon;
18
+ var _useStyles = useStyles({
19
+ isSelected: isSelected,
20
+ disabled: option.disabled
21
+ }),
22
+ styles = _useStyles.styles;
23
+ var label = option.label;
24
+ var _useMemo = useMemo(function () {
25
+ var before = label;
26
+ var middle = '';
27
+ var after = '';
28
+ if (queryString) {
29
+ var regex = new RegExp(escapeRegExp(queryString), 'i');
30
+ var match = regex.exec(option.label);
31
+ if (match) {
32
+ before = label.slice(0, Math.max(0, match.index));
33
+ middle = match[0];
34
+ after = label.slice(Math.max(0, match.index + match[0].length));
35
+ }
36
+ }
37
+ return {
38
+ before: before,
39
+ middle: middle,
40
+ after: after
41
+ };
42
+ }, [option.label, queryString, label]),
43
+ before = _useMemo.before,
44
+ middle = _useMemo.middle,
45
+ after = _useMemo.after;
46
+ return /*#__PURE__*/_jsxs(Flex, {
47
+ align: "center",
48
+ className: styles.menuItem,
49
+ gap: 4,
50
+ onClick: function onClick() {
51
+ return _onClick === null || _onClick === void 0 ? void 0 : _onClick(index, option);
52
+ },
53
+ onMouseEnter: function onMouseEnter() {
54
+ return _onMouseEnter === null || _onMouseEnter === void 0 ? void 0 : _onMouseEnter(index, option);
55
+ },
56
+ ref: option.setRefElement,
57
+ tabIndex: -1,
58
+ children: [showIcon && /*#__PURE__*/_jsx(Flex, {
59
+ className: styles.menuItemIcon,
60
+ children: option.icon
61
+ }), /*#__PURE__*/_jsxs("div", {
62
+ className: styles.menuItemLabel,
63
+ title: option.label,
64
+ children: [before, /*#__PURE__*/_jsx(Text, {
65
+ mark: true,
66
+ children: middle
67
+ }), after]
68
+ }), /*#__PURE__*/_jsx(Flex, {
69
+ children: option.extraElement
70
+ })]
71
+ }, option.key);
72
+ });
73
+ MentionMenuItem.displayName = 'MentionMenuItem';
@@ -0,0 +1,10 @@
1
+ import React from 'react';
2
+ import { MentionMenuOption } from './utils';
3
+ export interface MentionMenuProps {
4
+ selectedIndex?: number | null;
5
+ options: MentionMenuOption[];
6
+ onClick?: (index: number, option: MentionMenuOption) => void;
7
+ onMouseEnter?: (index: number, option: MentionMenuOption) => void;
8
+ queryString: string | null;
9
+ }
10
+ export declare const MentionMenu: React.FC<MentionMenuProps>;
@@ -0,0 +1,31 @@
1
+ import { Empty } from 'antd';
2
+ import React, { memo } from 'react';
3
+ import { MentionMenuItem } from "./menu-item";
4
+ import { useStyles } from "./style";
5
+ import { jsx as _jsx } from "react/jsx-runtime";
6
+ import { Fragment as _Fragment } from "react/jsx-runtime";
7
+ import { jsxs as _jsxs } from "react/jsx-runtime";
8
+ export var MentionMenu = /*#__PURE__*/memo(function (_ref) {
9
+ var selectedIndex = _ref.selectedIndex,
10
+ options = _ref.options,
11
+ onClick = _ref.onClick,
12
+ onMouseEnter = _ref.onMouseEnter,
13
+ queryString = _ref.queryString;
14
+ var _useStyles = useStyles({}),
15
+ styles = _useStyles.styles;
16
+ return /*#__PURE__*/_jsxs(_Fragment, {
17
+ children: [options.length === 0 && /*#__PURE__*/_jsx(Empty, {
18
+ className: styles.menuEmpty,
19
+ image: Empty.PRESENTED_IMAGE_SIMPLE
20
+ }), options.map(function (option, index) {
21
+ return /*#__PURE__*/_jsx(MentionMenuItem, {
22
+ index: index,
23
+ isSelected: selectedIndex === index,
24
+ onClick: onClick,
25
+ onMouseEnter: onMouseEnter,
26
+ option: option,
27
+ queryString: queryString
28
+ }, option.key);
29
+ })]
30
+ });
31
+ });
@@ -0,0 +1,11 @@
1
+ export declare const useStyles: (props?: {
2
+ isSelected?: boolean | undefined;
3
+ disabled?: boolean | undefined;
4
+ } | undefined) => import("antd-style").ReturnStyles<{
5
+ anchor: import("antd-style").SerializedStyles;
6
+ menuEmpty: import("antd-style").SerializedStyles;
7
+ menuOverlay: import("antd-style").SerializedStyles;
8
+ menuItem: import("antd-style").SerializedStyles;
9
+ menuItemIcon: import("antd-style").SerializedStyles;
10
+ menuItemLabel: import("antd-style").SerializedStyles;
11
+ }>;
@@ -0,0 +1,19 @@
1
+ import _taggedTemplateLiteral from "@babel/runtime/helpers/esm/taggedTemplateLiteral";
2
+ var _templateObject, _templateObject2, _templateObject3, _templateObject4, _templateObject5, _templateObject6, _templateObject7;
3
+ import { createStyles } from 'antd-style';
4
+ export var useStyles = createStyles(function (_ref, _ref2) {
5
+ var css = _ref.css,
6
+ token = _ref.token,
7
+ prefixCls = _ref.prefixCls;
8
+ var isSelected = _ref2.isSelected,
9
+ disabled = _ref2.disabled;
10
+ var selectedBg = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n background-color: ", ";\n "])), token.colorFillSecondary);
11
+ return {
12
+ anchor: css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n z-index: 9999;\n "]))),
13
+ menuEmpty: css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n padding: ", "px;\n "])), token.padding),
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
+ menuItemIcon: css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n color: ", ";\n "])), token.colorInfoText),
17
+ menuItemLabel: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n overflow: hidden;\n display: inline-block;\n text-overflow: ellipsis;\n white-space: nowrap;\n "])))
18
+ };
19
+ });