@luck-design-biz/luckda 1.0.2-2 → 1.0.2-4

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 (47) hide show
  1. package/es/lowcode/constants/event-topics.js +2 -0
  2. package/es/lowcode/engine/meta/box.props.default.json +1 -1
  3. package/es/lowcode/engine/meta/box.props.json +1 -1
  4. package/es/lowcode/engine/meta/fielddatadic.props.default.json +16 -0
  5. package/es/lowcode/engine/meta/fielddatadic.props.json +73 -0
  6. package/es/lowcode/engine/meta/layout.props.default.json +1 -1
  7. package/es/lowcode/engine/meta/layout.props.json +1 -1
  8. package/es/lowcode/painter/DesignOperator.js +8 -3
  9. package/es/lowcode/painter/DesignToolbar.js +27 -28
  10. package/es/lowcode/painter/Panel.js +1 -1
  11. package/es/lowcode/painter/components/DragDrop/DragDropContext.js +10 -3
  12. package/es/lowcode/painter/components/TreeEditor.js +76 -8
  13. package/es/lowcode/painter/components/code-editor/BaseEditor.js +10 -6
  14. package/es/lowcode/painter/panel-section/JSEditor.js +55 -33
  15. package/es/lowcode/painter/panel-section/StylePanel/MainPanel.js +37 -26
  16. package/es/lowcode/painter/style/components.less +1 -1
  17. package/es/lowcode/view/{errorBoundary.js → ErrorBoundary.js} +24 -6
  18. package/es/lowcode/view/Page.js +3 -3
  19. package/es/lowcode/view/lc-components/Box/FunctionDesign.js +4 -2
  20. package/es/lowcode/view/lc-components/Box/index.less +2 -2
  21. package/es/lowcode/view/lc-components/Box/meta.json +1 -1
  22. package/es/lowcode/view/lc-components/JSX/RuntimeComp.js +32 -16
  23. package/es/lowcode/view/lc-components/Layout/meta.json +1 -1
  24. package/lib/lowcode/constants/event-topics.js +3 -1
  25. package/lib/lowcode/engine/meta/box.props.default.json +1 -1
  26. package/lib/lowcode/engine/meta/box.props.json +1 -1
  27. package/lib/lowcode/engine/meta/fielddatadic.props.default.json +16 -0
  28. package/lib/lowcode/engine/meta/fielddatadic.props.json +73 -0
  29. package/lib/lowcode/engine/meta/layout.props.default.json +1 -1
  30. package/lib/lowcode/engine/meta/layout.props.json +1 -1
  31. package/lib/lowcode/painter/DesignOperator.js +8 -3
  32. package/lib/lowcode/painter/DesignToolbar.js +27 -28
  33. package/lib/lowcode/painter/Panel.js +1 -1
  34. package/lib/lowcode/painter/components/DragDrop/DragDropContext.js +10 -3
  35. package/lib/lowcode/painter/components/TreeEditor.js +76 -8
  36. package/lib/lowcode/painter/components/code-editor/BaseEditor.js +10 -6
  37. package/lib/lowcode/painter/panel-section/JSEditor.js +54 -32
  38. package/lib/lowcode/painter/panel-section/StylePanel/MainPanel.js +37 -26
  39. package/lib/lowcode/painter/style/components.less +1 -1
  40. package/lib/lowcode/view/{errorBoundary.js → ErrorBoundary.js} +23 -5
  41. package/lib/lowcode/view/Page.js +4 -4
  42. package/lib/lowcode/view/lc-components/Box/FunctionDesign.js +4 -2
  43. package/lib/lowcode/view/lc-components/Box/index.less +2 -2
  44. package/lib/lowcode/view/lc-components/Box/meta.json +1 -1
  45. package/lib/lowcode/view/lc-components/JSX/RuntimeComp.js +31 -16
  46. package/lib/lowcode/view/lc-components/Layout/meta.json +1 -1
  47. package/package.json +1 -1
@@ -30,6 +30,8 @@ export var COMPONENT_MODAL_TOGGLE = 'component-modal-toggle';
30
30
  export var COMPONENT_DRAG_OVER = 'component-drag-over';
31
31
  // 组件拖放完成时的事件
32
32
  export var COMPONENT_DRAG_END = 'component-drag-end';
33
+ // 保存事件
34
+ export var DESIGN_OPERATE_SAVE = 'design-operate-save';
33
35
 
34
36
  /******************************* Design Topic结束 *******************************/
35
37
 
@@ -6,7 +6,7 @@
6
6
  "group": "container",
7
7
  "groupName": "布局",
8
8
  "order": 3,
9
- "css": "height:100%; width: auto; background-color: #fff;",
9
+ "css": "height:auto; width: auto; background-color: #fff;",
10
10
  "advance": {
11
11
  "events": {}
12
12
  }
@@ -14,7 +14,7 @@
14
14
  "disabled": true
15
15
  }
16
16
  ],
17
- "css": "height:100%; width: auto; background-color: #fff;",
17
+ "css": "height:auto; width: auto; background-color: #fff;",
18
18
  "advance": {
19
19
  "events": [
20
20
  {
@@ -0,0 +1,16 @@
1
+ {
2
+ "component": "FieldDatadic",
3
+ "name": "数据字典",
4
+ "group": "field",
5
+ "desc": "数据字典类型表单项",
6
+ "icon": "icon-fieldstring",
7
+ "groupName": "表单项",
8
+ "order": 1,
9
+ "display": "select",
10
+ "multiple": false,
11
+ "isTree": false,
12
+ "allowClear": false,
13
+ "advance": {
14
+ "events": {}
15
+ }
16
+ }
@@ -0,0 +1,73 @@
1
+ {
2
+ "component": "FieldDatadic",
3
+ "name": "数据字典",
4
+ "group": "field",
5
+ "desc": "数据字典类型表单项",
6
+ "icon": "icon-fieldstring",
7
+ "groupName": "表单项",
8
+ "order": 1,
9
+ "props": [
10
+ {
11
+ "key": "alias",
12
+ "name": "字典key",
13
+ "type": "string"
14
+ },
15
+ {
16
+ "key": "valueField",
17
+ "name": "实际值字段",
18
+ "type": "string"
19
+ },
20
+ {
21
+ "key": "labelField",
22
+ "name": "翻译值字段",
23
+ "type": "string"
24
+ },
25
+ {
26
+ "key": "display",
27
+ "name": "展现形式",
28
+ "type": "segmented",
29
+ "options": [
30
+ {
31
+ "label": "Select",
32
+ "value": "select"
33
+ },
34
+ {
35
+ "label": "Radio",
36
+ "value": "radio"
37
+ }
38
+ ],
39
+ "default": "select"
40
+ },
41
+ {
42
+ "key": "multiple",
43
+ "name": "多选",
44
+ "desc": "仅在展现形式为Select时有效",
45
+ "type": "switch",
46
+ "default": false
47
+ },
48
+ {
49
+ "key": "isTree",
50
+ "name": "树形结构",
51
+ "desc": "用于规定树形结构的数据字典,仅在展现形式为Select时有效",
52
+ "type": "switch",
53
+ "default": false
54
+ },
55
+ {
56
+ "key": "allowClear",
57
+ "name": "允许清除",
58
+ "desc": "仅在展现形式为Select时有效",
59
+ "type": "switch",
60
+ "default": false
61
+ }
62
+ ],
63
+ "advance": {
64
+ "events": [
65
+ {
66
+ "key": "onChange",
67
+ "name": "数据变化事件",
68
+ "desc": "在数据变化事件时,执行方法",
69
+ "func": "function onChange(data) {\n\t\n}"
70
+ }
71
+ ]
72
+ }
73
+ }
@@ -6,7 +6,7 @@
6
6
  "groupName": "布局",
7
7
  "desc": "布局容器是一种提供列比例、列间距、行间距和样式等配置选项的元素,用于创建灵活的页面布局。它使用户能够轻松组织和排列组件,并实现各种复杂的布局需求。",
8
8
  "order": 1,
9
- "css": "background-color: transparent;",
9
+ "css": "height:auto; background-color: transparent;",
10
10
  "columnRatio": "12:3:9",
11
11
  "columnSpacing": 16,
12
12
  "lineSpacing": 16,
@@ -87,7 +87,7 @@
87
87
  "default": 16
88
88
  }
89
89
  ],
90
- "css": "background-color: transparent;",
90
+ "css": "height:auto; background-color: transparent;",
91
91
  "advance": {
92
92
  "events": [
93
93
  {
@@ -114,10 +114,10 @@ var DesignOperator = function DesignOperator(_ref) {
114
114
  };
115
115
  }, [operatorId.selector]);
116
116
  var activeDomPosition = useCreation(function () {
117
- var _getElement;
117
+ var _getElement, _canvas$current;
118
118
  if (!operatorId.selector && !operatorId.selectorTarget) return null;
119
119
  var targetTop = (_getElement = getElement(isNil(operatorId.selectorTarget) ? operatorId.selector : operatorId.selectorTarget.element)) === null || _getElement === void 0 ? void 0 : _getElement.getBoundingClientRect().top;
120
- var delat = targetTop - canvas.current.getBoundingClientRect().top;
120
+ var delat = targetTop - (((_canvas$current = canvas.current) === null || _canvas$current === void 0 ? void 0 : _canvas$current.getBoundingClientRect().top) || 0);
121
121
  return {
122
122
  top: delat > 24 ? -24 : 0
123
123
  };
@@ -135,6 +135,10 @@ var DesignOperator = function DesignOperator(_ref) {
135
135
  }, {
136
136
  target: canvas
137
137
  });
138
+ useKeyPress('ctrl.s', function (e) {
139
+ e.preventDefault();
140
+ context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
141
+ });
138
142
  useEventListener('mousemove', function (event) {
139
143
  var elem = event.target;
140
144
  var targetFormItem = elem.closest("[".concat(LC_COMPONENT_UNIT_KEY, "=\"").concat(LC_FORMITEM_UNIT, "\"]"));
@@ -268,7 +272,8 @@ var DesignOperator = function DesignOperator(_ref) {
268
272
  _modal.api.doOpen();
269
273
  currentModal.current = id;
270
274
  } else if (!toggle) {
271
- canvas.current.style.removeProperty('overflow');
275
+ var _canvas$current2;
276
+ (_canvas$current2 = canvas.current) === null || _canvas$current2 === void 0 || _canvas$current2.style.removeProperty('overflow');
272
277
  var _id = id || currentModal.current;
273
278
  if (_id) {
274
279
  var _modal2 = context.componentMap.get(_id);
@@ -86,20 +86,6 @@ var DesignToolbar = function DesignToolbar(_ref) {
86
86
  }),
87
87
  updatePageDataLoading = _useRequest2.loading,
88
88
  runAsync = _useRequest2.runAsync;
89
- useEffect(function () {
90
- var topicId = context.$subscriber(context.topics.LANG_SETTING_SELECT).on(function (_ref2) {
91
- var _langList = _ref2.langList;
92
- return setLangList(_langList);
93
- }).watch();
94
- return function () {
95
- return context.$unsubscriber(context.topics.LANG_SETTING_SELECT, topicId);
96
- };
97
- }, []);
98
- useEffect(function () {
99
- if (!showPreview) {
100
- setUserId(void 0);
101
- }
102
- }, [showPreview]);
103
89
  var handleSave = useMemoizedFn( /*#__PURE__*/_asyncToGenerator( /*#__PURE__*/_regeneratorRuntime().mark(function _callee() {
104
90
  var _yield$runAsync, code;
105
91
  return _regeneratorRuntime().wrap(function _callee$(_context) {
@@ -144,6 +130,23 @@ var DesignToolbar = function DesignToolbar(_ref) {
144
130
  }
145
131
  }, _callee);
146
132
  })), []);
133
+ useEffect(function () {
134
+ var lssid = context.$subscriber(context.topics.LANG_SETTING_SELECT).on(function (_ref3) {
135
+ var _langList = _ref3.langList;
136
+ setLangList(_langList);
137
+ console.log(11111, _langList);
138
+ }).watch();
139
+ var dasid = context.$subscriber(context.topics.DESIGN_OPERATE_SAVE).on(handleSave).watch();
140
+ return function () {
141
+ context.$unsubscriber(context.topics.LANG_SETTING_SELECT, lssid);
142
+ context.$unsubscriber(context.topics.DESIGN_OPERATE_SAVE, dasid);
143
+ };
144
+ }, []);
145
+ useEffect(function () {
146
+ if (!showPreview) {
147
+ setUserId(void 0);
148
+ }
149
+ }, [showPreview]);
147
150
  var handleClearCache = useMemoizedFn(function () {
148
151
  Modal.confirm({
149
152
  title: formatMessage({
@@ -325,20 +328,14 @@ var DesignToolbar = function DesignToolbar(_ref) {
325
328
  return _regeneratorRuntime().wrap(function _callee3$(_context3) {
326
329
  while (1) switch (_context3.prev = _context3.next) {
327
330
  case 0:
328
- if (updatePageDataLoading) {
329
- _context3.next = 6;
330
- break;
331
- }
332
- if (!getNeedPrompt()) {
333
- _context3.next = 4;
334
- break;
331
+ if (!updatePageDataLoading) {
332
+ if (getNeedPrompt()) {
333
+ context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
334
+ }
335
+ context.$publisher(context.topics.COMPONENT_ACTIVE, null);
336
+ setShowPreview(true);
335
337
  }
336
- _context3.next = 4;
337
- return handleSave();
338
- case 4:
339
- context.$publisher(context.topics.COMPONENT_ACTIVE, null);
340
- setShowPreview(true);
341
- case 6:
338
+ case 1:
342
339
  case "end":
343
340
  return _context3.stop();
344
341
  }
@@ -377,7 +374,9 @@ var DesignToolbar = function DesignToolbar(_ref) {
377
374
  fontSize: 14,
378
375
  margin: '0 11px 0 5px'
379
376
  },
380
- onClick: handleSave
377
+ onClick: function onClick() {
378
+ return context.$publisher(context.topics.DESIGN_OPERATE_SAVE);
379
+ }
381
380
  })), /*#__PURE__*/React.createElement(Modal, {
382
381
  visible: show,
383
382
  width: 1024,
@@ -109,7 +109,7 @@ var Panel = function Panel() {
109
109
  oldValue: oldValue,
110
110
  newValue: newValue
111
111
  });
112
- if (repositioning) context.$publisher(context.topics.COMPONENT_REPOSITIONING, {
112
+ if (repositioning || field === 'css') context.$publisher(context.topics.COMPONENT_REPOSITIONING, {
113
113
  id: _id
114
114
  });
115
115
  });
@@ -45,9 +45,16 @@ export default function (_ref) {
45
45
  break;
46
46
  case 'add':
47
47
  {
48
- var compName = fromComp.component.toLowerCase();
49
- var json = require("../../../engine/meta/".concat(compName, ".props.default.json"));
50
- moveNode(null, id, actionSide, "".concat(compName, "_").concat(suid()), json);
48
+ ctx.$subscriber(ctx.topics.COMPONENT_ACTIVE).once(function () {
49
+ var compName = fromComp.component.toLowerCase();
50
+ var json = require("../../../engine/meta/".concat(compName, ".props.default.json"));
51
+ ctx.$publisher(ctx.topics.COMPONENT_SETTING_CLICK, {
52
+ data: json
53
+ });
54
+ }).watch();
55
+ ctx.$publisher(ctx.topics.COMPONENT_ACTIVE, {
56
+ target: id
57
+ });
51
58
  }
52
59
  break;
53
60
  }
@@ -1,13 +1,81 @@
1
- import React from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useState, useCallback, useEffect, useRef } from 'react';
2
3
  import TreeDragDropWrapper from "./DragDrop/TreeDragDropWrapper";
4
+ import { Input } from 'luck-design/antd';
5
+ import { modifyNode } from "../../engine/provider/ContextProvider";
6
+
7
+ /**
8
+ * 树节点组件
9
+ * @param {Object} props - 组件属性
10
+ * @param {Object} props.item - 代表树节点的对象
11
+ * @returns {React.Component} 返回包裹在拖拽功能中的节点编辑组件
12
+ */
3
13
  export default function (_ref) {
4
14
  var item = _ref.item;
5
- var EditorNode = function EditorNode() {
6
- return /*#__PURE__*/React.createElement("div", {
7
- className: "item"
8
- }, item.name);
9
- };
10
15
  return /*#__PURE__*/React.createElement(TreeDragDropWrapper, {
11
16
  item: item
12
- }, /*#__PURE__*/React.createElement(EditorNode, null));
13
- }
17
+ }, /*#__PURE__*/React.createElement(EditorNode, {
18
+ item: item
19
+ }));
20
+ }
21
+
22
+ /**
23
+ * 编辑节点组件,提供查看和编辑树节点名称的功能
24
+ * @param {Object} props - 组件属性
25
+ * @param {Object} props.item - 代表树节点的对象
26
+ * @returns {React.Component} 根据编辑状态渲染输入框或仅文本
27
+ */
28
+ var EditorNode = function EditorNode(_ref2) {
29
+ var item = _ref2.item;
30
+ // console.log('item', item)
31
+ var _useState = useState(false),
32
+ _useState2 = _slicedToArray(_useState, 2),
33
+ edited = _useState2[0],
34
+ setEdited = _useState2[1];
35
+ var _useState3 = useState(item.name),
36
+ _useState4 = _slicedToArray(_useState3, 2),
37
+ editedValue = _useState4[0],
38
+ setEditedValue = _useState4[1];
39
+ var inputRef = useRef(null); // 创建一个 ref 来引用输入框
40
+
41
+ var handleDoubleClick = useCallback(function () {
42
+ if (!item.buildIn) setEdited(true);
43
+ }, []);
44
+ var handleBlur = useCallback(function () {
45
+ setEdited(false);
46
+ }, []);
47
+ var handPressEnter = useCallback(function (e) {
48
+ modifyNode(item.id, {
49
+ name: e.target.value
50
+ });
51
+ setEdited(false);
52
+ });
53
+ var handleInputChange = useCallback(function (e) {
54
+ setEditedValue(e.target.value);
55
+ });
56
+
57
+ // 使用 useEffect 钩子来处理聚焦逻辑
58
+ useEffect(function () {
59
+ if (edited) {
60
+ // 如果 edited 为 true,聚焦到输入框
61
+ inputRef.current && inputRef.current.focus();
62
+ }
63
+ }, [edited]); // 依赖 edited 状态变化
64
+
65
+ return /*#__PURE__*/React.createElement("div", {
66
+ className: "item",
67
+ onDoubleClick: handleDoubleClick
68
+ }, edited ? /*#__PURE__*/React.createElement("div", {
69
+ className: "treenode-editor"
70
+ }, /*#__PURE__*/React.createElement(Input, {
71
+ ref: inputRef // 将 ref 应用到 Input 组件
72
+ ,
73
+ onChange: handleInputChange,
74
+ value: editedValue,
75
+ size: "small",
76
+ onBlur: handleBlur,
77
+ onPressEnter: handPressEnter
78
+ })) : /*#__PURE__*/React.createElement("div", {
79
+ className: "treenode-info"
80
+ }, item.name));
81
+ };
@@ -1,7 +1,7 @@
1
1
  import _extends from "@babel/runtime/helpers/esm/extends";
2
2
  import _objectSpread from "@babel/runtime/helpers/esm/objectSpread2";
3
3
  import _objectWithoutProperties from "@babel/runtime/helpers/esm/objectWithoutProperties";
4
- var _excluded = ["onChange", "onLayoutChange", "isFullscreen", "style"],
4
+ var _excluded = ["onChange", "isFullscreen", "style", "onLoad"],
5
5
  _excluded2 = ["children", "language", "options"];
6
6
  import React, { useEffect, useRef, useImperativeHandle, forwardRef } from 'react';
7
7
  import * as monaco from 'monaco-editor';
@@ -41,9 +41,9 @@ import * as monaco from 'monaco-editor';
41
41
  */
42
42
  var BaseEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
43
43
  var onChange = _ref.onChange,
44
- onLayoutChange = _ref.onLayoutChange,
45
44
  isFullscreen = _ref.isFullscreen,
46
45
  style = _ref.style,
46
+ onLoad = _ref.onLoad,
47
47
  props = _objectWithoutProperties(_ref, _excluded);
48
48
  var children = props.children,
49
49
  _props$language = props.language,
@@ -53,6 +53,9 @@ var BaseEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
53
53
  rest = _objectWithoutProperties(props, _excluded2);
54
54
  var editorRef = useRef(null);
55
55
  var editorInstance = useRef(null);
56
+ useEffect(function () {
57
+ if (onLoad) onLoad();
58
+ }, []);
56
59
 
57
60
  // 初始化编辑器实例
58
61
  useEffect(function () {
@@ -80,10 +83,11 @@ var BaseEditor = /*#__PURE__*/forwardRef(function (_ref, ref) {
80
83
  editorInstance.current.onDidChangeModelContent(function (event) {
81
84
  if (onChange) onChange(editorInstance.current.getValue(), event);
82
85
  });
83
- // 监听布局变化,重新赋值,解决编辑器全屏切换时,编辑器内容不会更新的问题
84
- editorInstance.current.onDidLayoutChange(function (event) {
85
- if (onLayoutChange) onLayoutChange(editorInstance.current.getValue(), event);
86
- });
86
+
87
+ // 监听布局变化,重新赋值,解决编辑器全屏切换时,编辑器空白的问题
88
+ // editorInstance.current.onDidLayoutChange((event) => {
89
+ // if (onChange) onChange(editorInstance.current.getValue(), event);
90
+ // });
87
91
  }
88
92
  return function () {
89
93
  var _editorInstance$curre;
@@ -1,49 +1,71 @@
1
- import React, { useRef } from 'react';
2
- import { useMemoizedFn } from 'ahooks';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useRef, useState } from 'react';
3
+ import { useBoolean, useDebounceFn, useMemoizedFn } from 'ahooks';
3
4
  import { Button } from 'luck-design/antd';
4
- import { debounce } from 'lodash';
5
+ import { LuckModal, SplitPane } from 'luck-design';
5
6
  import { formatMessage } from '@luck-design-biz/base/utils';
6
- import PopConfirm from "../components/PopConfirm";
7
- import FullScreenEditor from "../components/code-editor/FullScreenEditor";
7
+ import RuntimeComp from "../../view/lc-components/JSX/RuntimeComp";
8
8
  import JSEditor from "../components/code-editor/JSEditor";
9
9
  var _JSEditor = function _JSEditor(_ref) {
10
10
  var defaultValue = _ref.defaultValue,
11
11
  defaultCode = _ref.defaultCode,
12
12
  onChange = _ref.onChange,
13
- mustConfirm = _ref.mustConfirm,
14
13
  children = _ref.children;
15
14
  var editorRef = useRef();
16
- var handleCodeChange = useRef(debounce(function (code) {
17
- if (!mustConfirm) onChange(code);
18
- }, 400));
19
- var handleConfirm = useMemoizedFn(function () {
20
- onChange(editorRef.current.editor.getValue());
21
- });
22
- var handleEditorLoad = useMemoizedFn(function () {
23
- editorRef.current.editor.setValue(defaultValue || defaultCode);
24
- });
25
- return /*#__PURE__*/React.createElement(PopConfirm, {
26
- placement: "left",
27
- title: /*#__PURE__*/React.createElement(FullScreenEditor, {
28
- ref: editorRef,
29
- EditorComponent: JSEditor,
30
- width: "600px",
31
- height: "400px",
32
- onChange: handleCodeChange.current,
33
- onLoad: handleEditorLoad
15
+ var _useState = useState(defaultValue || defaultCode),
16
+ _useState2 = _slicedToArray(_useState, 2),
17
+ code = _useState2[0],
18
+ setCode = _useState2[1];
19
+ var _useDebounceFn = useDebounceFn(function (_code) {
20
+ setCode(_code);
21
+ }, {
22
+ wait: 500
34
23
  }),
35
- showBtn: mustConfirm,
36
- onConfirm: handleConfirm
37
- }, children !== null && children !== void 0 ? children : /*#__PURE__*/React.createElement("div", {
38
- style: {
39
- padding: '0 16px'
40
- }
41
- }, /*#__PURE__*/React.createElement(Button, {
24
+ run = _useDebounceFn.run;
25
+ var _useBoolean = useBoolean(false),
26
+ _useBoolean2 = _slicedToArray(_useBoolean, 2),
27
+ visible = _useBoolean2[0],
28
+ _useBoolean2$ = _useBoolean2[1],
29
+ show = _useBoolean2$.setTrue,
30
+ hidden = _useBoolean2$.setFalse;
31
+ var _useBoolean3 = useBoolean(false),
32
+ _useBoolean4 = _slicedToArray(_useBoolean3, 2),
33
+ hasError = _useBoolean4[0],
34
+ _useBoolean4$ = _useBoolean4[1],
35
+ hasErrorOn = _useBoolean4$.setTrue,
36
+ hasErrorOff = _useBoolean4$.setFalse;
37
+ var handleErrorCatch = useMemoizedFn(function (error) {
38
+ console.log(12121212, error);
39
+ });
40
+ return /*#__PURE__*/React.createElement(React.Fragment, null, children || /*#__PURE__*/React.createElement(Button, {
42
41
  block: true,
43
- size: "small"
42
+ size: "small",
43
+ onClick: show
44
44
  }, formatMessage({
45
45
  id: 'luckda.lowcode.painter.panel-section.style-panel.sourceedit',
46
46
  label: '源码编辑'
47
- }))));
47
+ })), /*#__PURE__*/React.createElement(LuckModal, {
48
+ title: formatMessage({
49
+ id: 'luckda.lowcode.painter.panel-section.style-panel.sourceedit',
50
+ label: '源码编辑'
51
+ }),
52
+ width: "80vw",
53
+ height: "80vh",
54
+ fullScreen: true,
55
+ mask: false,
56
+ maskClosable: false,
57
+ closable: false,
58
+ visible: visible,
59
+ onClose: hidden
60
+ }, /*#__PURE__*/React.createElement(SplitPane, {
61
+ split: "vertical"
62
+ }, /*#__PURE__*/React.createElement(JSEditor, {
63
+ ref: editorRef,
64
+ onChange: run
65
+ }, defaultValue || defaultCode), /*#__PURE__*/React.createElement(SplitPane.Pane, {
66
+ minSize: "400px"
67
+ }, /*#__PURE__*/React.createElement(RuntimeComp, {
68
+ onErrorCatch: handleErrorCatch
69
+ }, code)))));
48
70
  };
49
71
  export default _JSEditor;
@@ -1,10 +1,10 @@
1
- import React, { useCallback } from 'react';
1
+ import _slicedToArray from "@babel/runtime/helpers/esm/slicedToArray";
2
+ import React, { useCallback, useState } from 'react';
2
3
  import { formatMessage } from '@luck-design-biz/base/utils';
4
+ import { useLatest } from 'ahooks';
3
5
  import { Button } from 'luck-design/antd';
4
6
  import Collapse from "../../components/Collapse";
5
- import PopConfirm from "../../components/PopConfirm";
6
7
  import CssEditor from "../../components/code-editor/CssEditor";
7
- import FullScreenEditor from "../../components/code-editor/FullScreenEditor";
8
8
  import styles from "../../style/style-panel.less";
9
9
  import { useStyle, useStyleDispatch, useEditor, styleToEditor } from "./StyleContext";
10
10
  import WidthHeight from "./WidthHeight";
@@ -18,6 +18,7 @@ import BorderRadius from "./BorderRadius";
18
18
  import Shadow from "./Shadow";
19
19
  import Opacity from "./Opacity";
20
20
  import Pointer from "./Pointer";
21
+ import { LuckModal } from 'luck-design';
21
22
 
22
23
  /**
23
24
  * 主样式面板
@@ -26,21 +27,20 @@ var MainPanel = function MainPanel() {
26
27
  var style = useStyle(true);
27
28
  var dispatch = useStyleDispatch();
28
29
  var editorRef = useEditor();
30
+ var _useState = useState(false),
31
+ _useState2 = _slicedToArray(_useState, 2),
32
+ show = _useState2[0],
33
+ setShow = _useState2[1];
34
+ var lasestStyle = useLatest(style);
29
35
  var handleCodeChange = useCallback(function (code) {
30
36
  dispatch({
31
37
  type: 'code',
32
38
  payload: code
33
39
  });
40
+ // editorRef.current.editor.setValue(code)
34
41
  }, []);
35
- var handleEditorLayoutChange = useCallback(function (code) {
36
- dispatch({
37
- type: 'code',
38
- payload: code
39
- });
40
- editorRef.current.editor.setValue(code);
41
- }, []);
42
- var handleEditorLoad = useCallback(function () {
43
- styleToEditor(style).then(function (css) {
42
+ var handleOnload = useCallback(function () {
43
+ styleToEditor(lasestStyle.current).then(function (css) {
44
44
  editorRef.current.editor.setValue(css);
45
45
  });
46
46
  }, []);
@@ -53,24 +53,35 @@ var MainPanel = function MainPanel() {
53
53
  })
54
54
  }, /*#__PURE__*/React.createElement("div", {
55
55
  className: styles['style-editor']
56
- }, /*#__PURE__*/React.createElement(PopConfirm, {
57
- placement: "bottomRight",
58
- title: /*#__PURE__*/React.createElement(FullScreenEditor, {
59
- ref: editorRef,
60
- EditorComponent: CssEditor,
61
- width: "280px",
62
- height: "300px",
63
- onChange: handleCodeChange,
64
- onLayoutChange: handleEditorLayoutChange,
65
- onLoad: handleEditorLoad
66
- })
67
- }, /*#__PURE__*/React.createElement(Button, {
56
+ }, /*#__PURE__*/React.createElement(LuckModal, {
57
+ title: formatMessage({
58
+ id: 'luckda.lowcode.painter.panel-section.style-panel.sourceedit',
59
+ label: '源码编辑'
60
+ }),
61
+ visible: show,
62
+ fullScreen: true,
63
+ mask: false,
64
+ footer: null,
65
+ maskClosable: false,
66
+ onClose: function onClose() {
67
+ setShow(false);
68
+ }
69
+ }, /*#__PURE__*/React.createElement(CssEditor, {
70
+ ref: editorRef,
71
+ width: "100%",
72
+ height: "100%",
73
+ onChange: handleCodeChange,
74
+ onLoad: handleOnload
75
+ })), /*#__PURE__*/React.createElement(Button, {
68
76
  type: "primary",
69
- size: "small"
77
+ size: "small",
78
+ onClick: function onClick() {
79
+ setShow(true);
80
+ }
70
81
  }, formatMessage({
71
82
  id: 'luckda.lowcode.painter.panel-section.style-panel.sourceedit',
72
83
  label: '源码编辑'
73
- })))), /*#__PURE__*/React.createElement(WidthHeight, {
84
+ }))), /*#__PURE__*/React.createElement(WidthHeight, {
74
85
  field: "width",
75
86
  label: formatMessage({
76
87
  id: 'luckda.lowcode.painter.panel-section.style-panel.width',
@@ -66,7 +66,7 @@
66
66
 
67
67
  span {
68
68
  font-size: 12px;
69
- color: #333;
69
+ color: var(--font-color);
70
70
  white-space: nowrap; // 防止文字换行
71
71
  overflow: hidden; // 隐藏溢出的文字
72
72
  text-overflow: ellipsis; // 使用省略号表示溢出