@yuntijs/ui 1.1.0-beta.9 → 1.2.0-beta.1
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/ChatItem/style.js +3 -3
- package/es/Form/collapse-list/index.js +16 -9
- package/es/Form/collapse-list/utils.d.ts +1 -0
- package/es/Form/collapse-list/utils.js +2 -1
- package/es/Mentions/index.d.ts +5 -0
- package/es/Mentions/index.js +9 -2
- package/es/Mentions/plugins/mention-picker/index.d.ts +2 -1
- package/es/Mentions/plugins/mention-picker/index.js +2 -0
- package/es/Mentions/plugins/shift-enter-key.js +14 -3
- package/es/MonacoEditor/MonacoEditor2.d.ts +11 -0
- package/es/MonacoEditor/MonacoEditor2.js +103 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +1 -0
- package/package.json +3 -2
- package/umd/index.min.js +1 -1
- package/umd/index.min.js.map +1 -1
package/es/ChatItem/style.js
CHANGED
|
@@ -16,7 +16,7 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
16
16
|
editing = _ref2.editing,
|
|
17
17
|
time = _ref2.time,
|
|
18
18
|
isLatest = _ref2.isLatest;
|
|
19
|
-
var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n
|
|
19
|
+
var blockStylish = css(_templateObject || (_templateObject = _taggedTemplateLiteral(["\n padding-block: 4px;\n padding-inline: 8px;\n\n background-color: ", ";\n border-radius: ", "px;\n\n transition: background-color 100ms ", ";\n "])), primary ? isDarkMode ? token.colorFill : '#F6F6F6' : isDarkMode ? token.colorFillSecondary : token.colorBgContainer, token.borderRadius, token.motionEaseOut);
|
|
20
20
|
var pureStylish = css(_templateObject2 || (_templateObject2 = _taggedTemplateLiteral(["\n padding-block-start: ", ";\n "])), title ? 0 : '6px');
|
|
21
21
|
var pureContainerStylish = css(_templateObject3 || (_templateObject3 = _taggedTemplateLiteral(["\n margin-block-end: -16px;\n transition: background-color 100ms ", ";\n "])), token.motionEaseOut);
|
|
22
22
|
var typeStylish = type === 'block' ? blockStylish : pureStylish;
|
|
@@ -26,13 +26,13 @@ export var useStyles = createStyles(function (_ref, _ref2) {
|
|
|
26
26
|
actions: cx(css(_templateObject5 || (_templateObject5 = _taggedTemplateLiteral(["\n flex: none;\n align-self: ", ";\n justify-content: ", ";\n "])), placement === 'left' ? 'flex-start' : 'flex-end', placement === 'left' ? 'flex-end' : 'flex-start'), editing && css(_templateObject6 || (_templateObject6 = _taggedTemplateLiteral(["\n pointer-events: none !important;\n opacity: 0 !important;\n "])))),
|
|
27
27
|
avatarContainer: css(_templateObject7 || (_templateObject7 = _taggedTemplateLiteral(["\n position: relative;\n flex: none;\n width: ", "px;\n height: ", "px;\n "])), avatarSize, avatarSize),
|
|
28
28
|
avatarGroupContainer: css(_templateObject8 || (_templateObject8 = _taggedTemplateLiteral(["\n width: ", "px;\n "])), avatarSize),
|
|
29
|
-
container: cx(type === 'pure' && pureContainerStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n max-width: 100vw;\n padding: 16px;\n\n time {\n display: inline-block;\n white-space: nowrap;\n }\n\n div[role='menubar'] {\n display: flex;\n }\n\n time,\n div[role='menubar'] {\n pointer-events: ", ";\n opacity: ", ";\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='menubar'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n\n ", " {\n padding-block: ", ";\n padding-inline: 8px;\n }\n "])), isLatest ? 'unset' : 'none', isLatest ? 1 : 0, token.motionEaseOut, responsive.mobile, type === 'pure' ? '12px' : '6px')),
|
|
29
|
+
container: cx(type === 'pure' && pureContainerStylish, css(_templateObject9 || (_templateObject9 = _taggedTemplateLiteral(["\n position: relative;\n width: 100%;\n max-width: 100vw;\n padding: 16px;\n\n time {\n display: inline-block;\n padding: 0 8px;\n white-space: nowrap;\n }\n\n div[role='menubar'] {\n display: flex;\n padding-inline: 8px;\n }\n\n time,\n div[role='menubar'] {\n pointer-events: ", ";\n opacity: ", ";\n transition: opacity 200ms ", ";\n }\n\n &:hover {\n time,\n div[role='menubar'] {\n pointer-events: unset;\n opacity: 1;\n }\n }\n\n ", " {\n padding-block: ", ";\n padding-inline: 8px;\n }\n "])), isLatest ? 'unset' : 'none', isLatest ? 1 : 0, token.motionEaseOut, responsive.mobile, type === 'pure' ? '12px' : '6px')),
|
|
30
30
|
editingContainer: cx(editingStylish, css(_templateObject10 || (_templateObject10 = _taggedTemplateLiteral(["\n padding-block: 8px 12px;\n padding-inline: 12px;\n border: 1px solid ", ";\n\n &:active,\n &:hover {\n border-color: ", ";\n }\n "])), token.colorBorderSecondary, token.colorBorder), type === 'pure' && css(_templateObject11 || (_templateObject11 = _taggedTemplateLiteral(["\n background: ", ";\n border-radius: ", "px;\n "])), token.colorFillQuaternary, token.borderRadius)),
|
|
31
31
|
editingInput: css(_templateObject12 || (_templateObject12 = _taggedTemplateLiteral(["\n width: 100%;\n "]))),
|
|
32
32
|
errorContainer: css(_templateObject13 || (_templateObject13 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n width: 100%;\n "]))),
|
|
33
33
|
loading: css(_templateObject14 || (_templateObject14 = _taggedTemplateLiteral(["\n position: absolute;\n inset-block-end: 0;\n inset-inline: ", ";\n\n width: 16px;\n height: 16px;\n\n color: ", ";\n\n background: ", ";\n border-radius: 50%;\n "])), insetInline, token.colorBgLayout, token.colorPrimary),
|
|
34
34
|
message: cx(typeStylish, css(_templateObject15 || (_templateObject15 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n max-width: 100%;\n\n ", " {\n width: 100%;\n }\n "])), responsive.mobile)),
|
|
35
|
-
messageContainer: cx(editingStylish, css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n max-width:
|
|
35
|
+
messageContainer: cx(editingStylish, css(_templateObject16 || (_templateObject16 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n max-width: 96%;\n margin-block-start: ", "px;\n\n ", " {\n overflow-x: auto;\n }\n "])), time ? -16 : 0, responsive.mobile)),
|
|
36
36
|
messageContent: cx(editingStylish, css(_templateObject17 || (_templateObject17 = _taggedTemplateLiteral(["\n position: relative;\n overflow: hidden;\n max-width: 100%;\n\n ", " {\n flex-direction: column !important;\n }\n "])), responsive.mobile)),
|
|
37
37
|
messageExtra: cx('message-extra'),
|
|
38
38
|
name: css(_templateObject18 || (_templateObject18 = _taggedTemplateLiteral(["\n pointer-events: none;\n\n margin-block-end: 6px;\n\n font-size: 12px;\n line-height: 1;\n color: ", ";\n text-align: ", ";\n "])), token.colorTextDescription, placement === 'left' ? 'left' : 'right')
|
|
@@ -19,7 +19,7 @@ import { CollapseGroup } from "../../CollapseGroup";
|
|
|
19
19
|
import { FormCollapseListFieldsWatcher } from "./FieldsWatcher";
|
|
20
20
|
import { useFormCollapseListHooks } from "./hooks";
|
|
21
21
|
import { useStyles } from "./style";
|
|
22
|
-
import { FIELD_KEY_PATH, toRowKey } from "./utils";
|
|
22
|
+
import { FIELD_KEY_PATH, TEXT_INPUT_COMPOENT_TYPES, toRowKey } from "./utils";
|
|
23
23
|
import { jsx as _jsx } from "react/jsx-runtime";
|
|
24
24
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
25
25
|
var Text = Typography.Text;
|
|
@@ -222,14 +222,21 @@ export var FormCollapseList = /*#__PURE__*/memo(function (_ref) {
|
|
|
222
222
|
chidrenProps.disabled = disabled;
|
|
223
223
|
}
|
|
224
224
|
if (readOnly === true) {
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
225
|
+
var _props, _type;
|
|
226
|
+
chidrenProps.disabled = true;
|
|
227
|
+
if (children !== null && children !== void 0 && (_props = children.props) !== null && _props !== void 0 && _props.showCount) {
|
|
228
|
+
chidrenProps.showCount = undefined;
|
|
229
|
+
}
|
|
230
|
+
if (TEXT_INPUT_COMPOENT_TYPES.includes(children === null || children === void 0 || (_type = children.type) === null || _type === void 0 ? void 0 : _type.displayName)) {
|
|
231
|
+
return /*#__PURE__*/_jsx(Flex, {
|
|
232
|
+
align: "center",
|
|
233
|
+
className: cx(styles.readOnlyItem, className),
|
|
234
|
+
children: text !== null && text !== void 0 ? text : /*#__PURE__*/_jsx(Text, {
|
|
235
|
+
type: "secondary",
|
|
236
|
+
children: "-"
|
|
237
|
+
})
|
|
238
|
+
});
|
|
239
|
+
}
|
|
233
240
|
}
|
|
234
241
|
return /*#__PURE__*/_jsx(Form.Item, _objectSpread(_objectSpread(_objectSpread({
|
|
235
242
|
className: className
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export var FIELD_KEY_PATH = '__YUNTI_FORM_COLLAPSE_LIST_FIELD_KEY_PATH';
|
|
2
2
|
export var toRowKey = function toRowKey(keyPath) {
|
|
3
3
|
return keyPath.join('-');
|
|
4
|
-
};
|
|
4
|
+
};
|
|
5
|
+
export var TEXT_INPUT_COMPOENT_TYPES = ['Input', 'InputNumber', 'AutoComplete', 'Mentions', 'Radio', 'RadioGroup', 'CheckBox', 'CheckBoxGroup', 'Rate', 'Slider', 'Switch'];
|
package/es/Mentions/index.d.ts
CHANGED
|
@@ -3,6 +3,7 @@ import { type MentionPickerPluginProps } from './plugins/mention-picker';
|
|
|
3
3
|
import { AutoSize, MentionsEditor } from './types';
|
|
4
4
|
export * from './types';
|
|
5
5
|
export * from './utils';
|
|
6
|
+
export { CLEAR_EDITOR_COMMAND } from 'lexical';
|
|
6
7
|
export interface MentionsProps extends MentionPickerPluginProps {
|
|
7
8
|
className?: string;
|
|
8
9
|
classNames?: {
|
|
@@ -25,6 +26,10 @@ export interface MentionsProps extends MentionPickerPluginProps {
|
|
|
25
26
|
onPressEnter?: (value: string, { event }: {
|
|
26
27
|
event: KeyboardEvent | null;
|
|
27
28
|
}) => void;
|
|
29
|
+
/**
|
|
30
|
+
* 用户输入 trigger 后的回调
|
|
31
|
+
*/
|
|
32
|
+
onTrigger?: (trigger: string) => void;
|
|
28
33
|
variant?: 'outlined' | 'filled' | 'borderless';
|
|
29
34
|
autoSize?: AutoSize;
|
|
30
35
|
code?: boolean;
|
package/es/Mentions/index.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
2
|
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; }
|
|
3
3
|
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; }
|
|
4
|
+
import { ClearEditorPlugin } from '@lexical/react/LexicalClearEditorPlugin';
|
|
4
5
|
import { LexicalComposer } from '@lexical/react/LexicalComposer';
|
|
5
6
|
import { ContentEditable } from '@lexical/react/LexicalContentEditable';
|
|
6
7
|
import { LexicalErrorBoundary } from '@lexical/react/LexicalErrorBoundary';
|
|
@@ -26,6 +27,7 @@ import { jsx as _jsx } from "react/jsx-runtime";
|
|
|
26
27
|
import { jsxs as _jsxs } from "react/jsx-runtime";
|
|
27
28
|
export * from "./types";
|
|
28
29
|
export * from "./utils";
|
|
30
|
+
export { CLEAR_EDITOR_COMMAND } from 'lexical';
|
|
29
31
|
export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
30
32
|
var className = _ref.className,
|
|
31
33
|
classNames = _ref.classNames,
|
|
@@ -53,7 +55,8 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
53
55
|
_ref$code = _ref.code,
|
|
54
56
|
code = _ref$code === void 0 ? false : _ref$code,
|
|
55
57
|
getPopContainer = _ref.getPopContainer,
|
|
56
|
-
onPressEnter = _ref.onPressEnter
|
|
58
|
+
onPressEnter = _ref.onPressEnter,
|
|
59
|
+
onTrigger = _ref.onTrigger;
|
|
57
60
|
var _ConfigProvider$useCo = ConfigProvider.useConfig(),
|
|
58
61
|
componentDisabled = _ConfigProvider$useCo.componentDisabled;
|
|
59
62
|
var _useStyles = useStyles({
|
|
@@ -146,6 +149,10 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
146
149
|
})
|
|
147
150
|
}), editable && /*#__PURE__*/_jsx(MentionPickerPlugin, {
|
|
148
151
|
allowSpaces: allowSpaces,
|
|
152
|
+
onOpen: function onOpen(resolution) {
|
|
153
|
+
var _resolution$match$rep, _resolution$match;
|
|
154
|
+
return onTrigger === null || onTrigger === void 0 ? void 0 : onTrigger((_resolution$match$rep = (_resolution$match = resolution.match) === null || _resolution$match === void 0 ? void 0 : _resolution$match.replaceableString) !== null && _resolution$match$rep !== void 0 ? _resolution$match$rep : triggers[0]);
|
|
155
|
+
},
|
|
149
156
|
onSelect: onSelect,
|
|
150
157
|
options: options,
|
|
151
158
|
overlayClassName: classNames === null || classNames === void 0 ? void 0 : classNames.menuOverlay,
|
|
@@ -162,7 +169,7 @@ export var Mentions = /*#__PURE__*/forwardRef(function (_ref, ref) {
|
|
|
162
169
|
editable: editable
|
|
163
170
|
}), /*#__PURE__*/_jsx(EditorRefPlugin, {
|
|
164
171
|
editorRef: ref
|
|
165
|
-
}), onPressEnter && /*#__PURE__*/_jsx(ShiftEnterKeyPlugin, {
|
|
172
|
+
}), /*#__PURE__*/_jsx(ClearEditorPlugin, {}), onPressEnter && /*#__PURE__*/_jsx(ShiftEnterKeyPlugin, {
|
|
166
173
|
onPressEnter: onPressEnter
|
|
167
174
|
})]
|
|
168
175
|
})
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
+
import type { MenuOption, TypeaheadMenuPluginProps } from '@lexical/react/LexicalTypeaheadMenuPlugin';
|
|
1
2
|
import React from 'react';
|
|
2
3
|
import type { MentionOption } from '../../types';
|
|
3
4
|
import { type MentionMenuOption } from './utils';
|
|
4
|
-
export interface MentionPickerPluginProps {
|
|
5
|
+
export interface MentionPickerPluginProps extends Pick<TypeaheadMenuPluginProps<MenuOption>, 'onOpen'> {
|
|
5
6
|
/** The className of menu overlay */
|
|
6
7
|
overlayClassName?: string;
|
|
7
8
|
/** The options of menu */
|
|
@@ -27,6 +27,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
27
27
|
_ref$preTriggerChars = _ref.preTriggerChars,
|
|
28
28
|
preTriggerChars = _ref$preTriggerChars === void 0 ? PRE_TRIGGER_CHARS : _ref$preTriggerChars,
|
|
29
29
|
onSelect = _ref.onSelect,
|
|
30
|
+
onOpen = _ref.onOpen,
|
|
30
31
|
parent = _ref.parent;
|
|
31
32
|
var _useStyles = useStyles({}),
|
|
32
33
|
cx = _useStyles.cx,
|
|
@@ -169,6 +170,7 @@ export var MentionPickerPlugin = /*#__PURE__*/memo(function (_ref) {
|
|
|
169
170
|
,
|
|
170
171
|
commandPriority: COMMAND_PRIORITY_NORMAL,
|
|
171
172
|
menuRenderFn: renderMenu,
|
|
173
|
+
onOpen: onOpen,
|
|
172
174
|
onQueryChange: setQueryString,
|
|
173
175
|
onSelectOption: onSelectOption,
|
|
174
176
|
options: flatOptions,
|
|
@@ -36,9 +36,20 @@ export var ShiftEnterKeyPlugin = function ShiftEnterKeyPlugin(_ref) {
|
|
|
36
36
|
return $getRoot().getTextContent();
|
|
37
37
|
});
|
|
38
38
|
var value = text.replaceAll('\n\n', '\n');
|
|
39
|
-
onPressEnter
|
|
40
|
-
|
|
41
|
-
|
|
39
|
+
// 这里把 onPressEnter 放在下一次事件循环中触发,是为了避免跟 Lexical 还未结束的输入等事务发生冲突
|
|
40
|
+
if (window.queueMicrotask === undefined) {
|
|
41
|
+
setTimeout(function () {
|
|
42
|
+
onPressEnter(value, {
|
|
43
|
+
event: event
|
|
44
|
+
});
|
|
45
|
+
}, 0);
|
|
46
|
+
} else {
|
|
47
|
+
queueMicrotask(function () {
|
|
48
|
+
onPressEnter(value, {
|
|
49
|
+
event: event
|
|
50
|
+
});
|
|
51
|
+
});
|
|
52
|
+
}
|
|
42
53
|
return true;
|
|
43
54
|
},
|
|
44
55
|
// 优先级要低于 MentionPickerPlugin
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import type { EditorProps } from '@monaco-editor/react';
|
|
3
|
+
import type { Variant } from 'antd/es/config-provider';
|
|
4
|
+
export interface EditorProps2 extends EditorProps {
|
|
5
|
+
onBlur?: (input: string, event: any) => void;
|
|
6
|
+
placeholder?: string;
|
|
7
|
+
variant?: Variant;
|
|
8
|
+
enableOutline?: boolean;
|
|
9
|
+
version?: string;
|
|
10
|
+
}
|
|
11
|
+
export declare const MonacoEditor2: React.FC<EditorProps2>;
|
|
@@ -0,0 +1,103 @@
|
|
|
1
|
+
import _defineProperty from "@babel/runtime/helpers/esm/defineProperty";
|
|
2
|
+
import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["language", "theme", "placeholder", "variant", "onBlur", "enableOutline", "className", "version", "options", "onMount"];
|
|
5
|
+
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; }
|
|
6
|
+
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; }
|
|
7
|
+
import Editor, { loader } from '@monaco-editor/react';
|
|
8
|
+
import { Spin } from 'antd';
|
|
9
|
+
import { useEffect, useRef, useState } from 'react';
|
|
10
|
+
import { useCdnFn } from "../ConfigProvider";
|
|
11
|
+
import { useStyles } from "./base/style";
|
|
12
|
+
import { jsx as _jsx } from "react/jsx-runtime";
|
|
13
|
+
export var MonacoEditor2 = function MonacoEditor2(_ref) {
|
|
14
|
+
var _options$minimap;
|
|
15
|
+
var language = _ref.language,
|
|
16
|
+
theme = _ref.theme,
|
|
17
|
+
placeholder = _ref.placeholder,
|
|
18
|
+
variant = _ref.variant,
|
|
19
|
+
onBlur = _ref.onBlur,
|
|
20
|
+
enableOutline = _ref.enableOutline,
|
|
21
|
+
className = _ref.className,
|
|
22
|
+
_ref$version = _ref.version,
|
|
23
|
+
version = _ref$version === void 0 ? '0.52.2' : _ref$version,
|
|
24
|
+
_ref$options = _ref.options,
|
|
25
|
+
options = _ref$options === void 0 ? {} : _ref$options,
|
|
26
|
+
onMount = _ref.onMount,
|
|
27
|
+
props = _objectWithoutProperties(_ref, _excluded);
|
|
28
|
+
var _useState = useState(false),
|
|
29
|
+
_useState2 = _slicedToArray(_useState, 2),
|
|
30
|
+
isFocus = _useState2[0],
|
|
31
|
+
setIsFocus = _useState2[1];
|
|
32
|
+
var editorRef = useRef(null);
|
|
33
|
+
var _useState3 = useState(false),
|
|
34
|
+
_useState4 = _slicedToArray(_useState3, 2),
|
|
35
|
+
isMounted = _useState4[0],
|
|
36
|
+
setIsMounted = _useState4[1];
|
|
37
|
+
var _useState5 = useState(false),
|
|
38
|
+
_useState6 = _slicedToArray(_useState5, 2),
|
|
39
|
+
configed = _useState6[0],
|
|
40
|
+
setConfiged = _useState6[1];
|
|
41
|
+
var _useStyles = useStyles({
|
|
42
|
+
minimapEnabled: options === null || options === void 0 || (_options$minimap = options.minimap) === null || _options$minimap === void 0 ? void 0 : _options$minimap.enabled,
|
|
43
|
+
variant: variant
|
|
44
|
+
}),
|
|
45
|
+
cx = _useStyles.cx,
|
|
46
|
+
styles = _useStyles.styles;
|
|
47
|
+
var classnames = cx(styles.base, className, {
|
|
48
|
+
've-focused': isFocus,
|
|
49
|
+
've-outline': enableOutline
|
|
50
|
+
});
|
|
51
|
+
var genCdnUrl = useCdnFn();
|
|
52
|
+
useEffect(function () {
|
|
53
|
+
loader.config({
|
|
54
|
+
paths: {
|
|
55
|
+
vs: genCdnUrl({
|
|
56
|
+
path: 'min/vs',
|
|
57
|
+
pkg: 'monaco-editor',
|
|
58
|
+
version: version
|
|
59
|
+
})
|
|
60
|
+
}
|
|
61
|
+
});
|
|
62
|
+
setConfiged(true);
|
|
63
|
+
}, [genCdnUrl, version]);
|
|
64
|
+
var handleEditorDidMount = function handleEditorDidMount(editor, monaco) {
|
|
65
|
+
editorRef.current = editor;
|
|
66
|
+
editor.onDidFocusEditorText(function () {
|
|
67
|
+
setIsFocus(true);
|
|
68
|
+
});
|
|
69
|
+
editor.onDidBlurEditorText(function (event) {
|
|
70
|
+
var _editorRef$current;
|
|
71
|
+
setIsFocus(false);
|
|
72
|
+
var value = (_editorRef$current = editorRef.current) === null || _editorRef$current === void 0 || (_editorRef$current = _editorRef$current.getModel()) === null || _editorRef$current === void 0 ? void 0 : _editorRef$current.getValue();
|
|
73
|
+
onBlur === null || onBlur === void 0 || onBlur(value !== null && value !== void 0 ? value : '', event);
|
|
74
|
+
});
|
|
75
|
+
monaco.editor.setTheme('default-theme'); // Fix: sometimes not load the default theme
|
|
76
|
+
onMount === null || onMount === void 0 || onMount(editor, monaco);
|
|
77
|
+
setIsMounted(true);
|
|
78
|
+
};
|
|
79
|
+
return /*#__PURE__*/_jsx(Spin, {
|
|
80
|
+
spinning: !configed,
|
|
81
|
+
children: configed ? /*#__PURE__*/_jsx(Editor, _objectSpread({
|
|
82
|
+
className: classnames,
|
|
83
|
+
language: language || 'text',
|
|
84
|
+
onMount: handleEditorDidMount,
|
|
85
|
+
options: _objectSpread({
|
|
86
|
+
domReadOnly: true,
|
|
87
|
+
quickSuggestions: false,
|
|
88
|
+
minimap: {
|
|
89
|
+
enabled: false
|
|
90
|
+
},
|
|
91
|
+
lineNumbersMinChars: 1,
|
|
92
|
+
// would change line num width
|
|
93
|
+
wordWrap: 'on',
|
|
94
|
+
// auto line wrap
|
|
95
|
+
unicodeHighlight: {
|
|
96
|
+
ambiguousCharacters: false
|
|
97
|
+
},
|
|
98
|
+
placeholder: placeholder
|
|
99
|
+
}, options),
|
|
100
|
+
theme: isMounted ? theme : 'default-theme' // sometimes not load the default theme
|
|
101
|
+
}, props)) : null
|
|
102
|
+
});
|
|
103
|
+
};
|
package/es/index.d.ts
CHANGED
package/es/index.js
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@yuntijs/ui",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0-beta.1",
|
|
4
4
|
"description": "☁️ Yunti UI - an open-source UI component library for building Cloud Native web apps",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"yuntijs",
|
|
@@ -89,7 +89,8 @@
|
|
|
89
89
|
"@lobehub/tts": "^1.25.1",
|
|
90
90
|
"@lobehub/ui": "^1.164.2",
|
|
91
91
|
"@melloware/react-logviewer": "^5.2.0",
|
|
92
|
-
"@monaco-editor/loader": "^1.
|
|
92
|
+
"@monaco-editor/loader": "^1.5.0",
|
|
93
|
+
"@monaco-editor/react": "^4.7.0",
|
|
93
94
|
"@shikijs/transformers": "^3.2.1",
|
|
94
95
|
"leva": "^0",
|
|
95
96
|
"lexical": "^0.23.1",
|