@next-libs/visual-builder 1.1.0
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/CHANGELOG.md +11 -0
- package/README.md +13 -0
- package/dist/cjs/index.js +45 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/interfaces/brick-visualization.js +22 -0
- package/dist/cjs/interfaces/brick-visualization.js.map +1 -0
- package/dist/cjs/interfaces/index.js +19 -0
- package/dist/cjs/interfaces/index.js.map +1 -0
- package/dist/cjs/visual-property-form/VisualPropertyForm.js +282 -0
- package/dist/cjs/visual-property-form/VisualPropertyForm.js.map +1 -0
- package/dist/cjs/visual-property-form/components/CodeEditor/CodeEditorFormItem.js +64 -0
- package/dist/cjs/visual-property-form/components/CodeEditor/CodeEditorFormItem.js.map +1 -0
- package/dist/cjs/visual-property-form/components/ColorEditor/ColorEditorItem.js +100 -0
- package/dist/cjs/visual-property-form/components/ColorEditor/ColorEditorItem.js.map +1 -0
- package/dist/cjs/visual-property-form/components/IconSelect/IconSelectFormItem.js +35 -0
- package/dist/cjs/visual-property-form/components/IconSelect/IconSelectFormItem.js.map +1 -0
- package/dist/cjs/visual-property-form/components/MenuEditor/MenuEditorItem.js +83 -0
- package/dist/cjs/visual-property-form/components/MenuEditor/MenuEditorItem.js.map +1 -0
- package/dist/cjs/visual-property-form/constant.js +54 -0
- package/dist/cjs/visual-property-form/constant.js.map +1 -0
- package/dist/cjs/visual-property-form/processor.js +204 -0
- package/dist/cjs/visual-property-form/processor.js.map +1 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/interfaces/brick-visualization.js +14 -0
- package/dist/esm/interfaces/brick-visualization.js.map +1 -0
- package/dist/esm/interfaces/index.js +2 -0
- package/dist/esm/interfaces/index.js.map +1 -0
- package/dist/esm/visual-property-form/VisualPropertyForm.js +253 -0
- package/dist/esm/visual-property-form/VisualPropertyForm.js.map +1 -0
- package/dist/esm/visual-property-form/VisualPropertyForm.module.css +33 -0
- package/dist/esm/visual-property-form/components/CodeEditor/CodeEditorFormItem.js +58 -0
- package/dist/esm/visual-property-form/components/CodeEditor/CodeEditorFormItem.js.map +1 -0
- package/dist/esm/visual-property-form/components/ColorEditor/ColorEditor.module.css +32 -0
- package/dist/esm/visual-property-form/components/ColorEditor/ColorEditorItem.js +81 -0
- package/dist/esm/visual-property-form/components/ColorEditor/ColorEditorItem.js.map +1 -0
- package/dist/esm/visual-property-form/components/IconSelect/IconSelectFormItem.js +23 -0
- package/dist/esm/visual-property-form/components/IconSelect/IconSelectFormItem.js.map +1 -0
- package/dist/esm/visual-property-form/components/MenuEditor/MenuEditorItem.js +77 -0
- package/dist/esm/visual-property-form/components/MenuEditor/MenuEditorItem.js.map +1 -0
- package/dist/esm/visual-property-form/constant.js +43 -0
- package/dist/esm/visual-property-form/constant.js.map +1 -0
- package/dist/esm/visual-property-form/images/empty-dark.svg +54 -0
- package/dist/esm/visual-property-form/processor.js +183 -0
- package/dist/esm/visual-property-form/processor.js.map +1 -0
- package/dist/types/index.d.ts +3 -0
- package/dist/types/interfaces/brick-visualization.d.ts +32 -0
- package/dist/types/interfaces/index.d.ts +1 -0
- package/dist/types/visual-property-form/VisualPropertyForm.d.ts +22 -0
- package/dist/types/visual-property-form/VisualPropertyForm.spec.d.ts +1 -0
- package/dist/types/visual-property-form/components/CodeEditor/CodeEditorFormItem.d.ts +7 -0
- package/dist/types/visual-property-form/components/CodeEditor/CodeEditorFormItem.spec.d.ts +1 -0
- package/dist/types/visual-property-form/components/ColorEditor/ColorEditorItem.d.ts +17 -0
- package/dist/types/visual-property-form/components/ColorEditor/ColorEditorItem.spec.d.ts +1 -0
- package/dist/types/visual-property-form/components/IconSelect/IconSelectFormItem.d.ts +3 -0
- package/dist/types/visual-property-form/components/IconSelect/IconSelectFormItem.spec.d.ts +1 -0
- package/dist/types/visual-property-form/components/MenuEditor/MenuEditorItem.d.ts +11 -0
- package/dist/types/visual-property-form/components/MenuEditor/MenuEditorItem.spec.d.ts +1 -0
- package/dist/types/visual-property-form/constant.d.ts +31 -0
- package/dist/types/visual-property-form/processor.d.ts +27 -0
- package/package.json +39 -0
|
@@ -0,0 +1,253 @@
|
|
|
1
|
+
import _objectSpread from "@babel/runtime/helpers/objectSpread2";
|
|
2
|
+
import React, { useEffect, useImperativeHandle, useState } from "react";
|
|
3
|
+
import { Form, Input, InputNumber, Radio, Select, Tooltip, Collapse, Empty } from "antd";
|
|
4
|
+
import { useCurrentTheme } from "@next-core/brick-kit";
|
|
5
|
+
import { GeneralIcon } from "@next-libs/basic-components";
|
|
6
|
+
import update from "immutability-helper";
|
|
7
|
+
import { isNil, pick, upperFirst, isEmpty } from "lodash";
|
|
8
|
+
import styles from "./VisualPropertyForm.module.css";
|
|
9
|
+
import { CodeEditorFormItem } from "./components/CodeEditor/CodeEditorFormItem";
|
|
10
|
+
import { IconSelectFormItem } from "./components/IconSelect/IconSelectFormItem";
|
|
11
|
+
import { ColorEditorItem } from "./components/ColorEditor/ColorEditorItem";
|
|
12
|
+
import { MenuEditorItem } from "./components/MenuEditor/MenuEditorItem";
|
|
13
|
+
import { ReactComponent as DarkEmpty } from "./images/empty-dark.svg";
|
|
14
|
+
import { mergeProperties, calculateValue, groupByType, yamlStringify } from "./processor";
|
|
15
|
+
import { OTHER_FORM_ITEM_FIELD, supportMenuType } from "./constant";
|
|
16
|
+
import { matchNoramlMenuValue } from "./processor";
|
|
17
|
+
import { ItemModeType, Required } from "../interfaces";
|
|
18
|
+
export function LegacyVisualPropertyForm(props, ref) {
|
|
19
|
+
var _groupByType;
|
|
20
|
+
|
|
21
|
+
var theme = useCurrentTheme();
|
|
22
|
+
var {
|
|
23
|
+
projectId,
|
|
24
|
+
labelIcon,
|
|
25
|
+
propertyTypeList,
|
|
26
|
+
brickProperties,
|
|
27
|
+
brickInfo,
|
|
28
|
+
emptyConfig,
|
|
29
|
+
menuSettingClick
|
|
30
|
+
} = props;
|
|
31
|
+
var [form] = Form.useForm();
|
|
32
|
+
var [typeList, setTypeList] = useState(mergeProperties(propertyTypeList, brickProperties));
|
|
33
|
+
useImperativeHandle(ref, () => ({
|
|
34
|
+
validateFields: form.validateFields,
|
|
35
|
+
resetPropertyFields: (typeList, properties) => {
|
|
36
|
+
var restValue = mergeProperties(typeList, properties);
|
|
37
|
+
setTypeList(restValue);
|
|
38
|
+
form.resetFields();
|
|
39
|
+
},
|
|
40
|
+
getCurTypeList: () => {
|
|
41
|
+
return typeList === null || typeList === void 0 ? void 0 : typeList.map(item => pick(item, ["name", "type", "mode"]));
|
|
42
|
+
}
|
|
43
|
+
}));
|
|
44
|
+
useEffect(() => {
|
|
45
|
+
var newTypeList = mergeProperties(propertyTypeList, brickProperties);
|
|
46
|
+
setTypeList(newTypeList);
|
|
47
|
+
var newValue = calculateValue(propertyTypeList, brickProperties, newTypeList);
|
|
48
|
+
form.setFieldsValue(newValue);
|
|
49
|
+
}, [propertyTypeList, brickProperties]);
|
|
50
|
+
|
|
51
|
+
var handleLabelClick = name => {
|
|
52
|
+
var selected = typeList.find(item => item.name === name);
|
|
53
|
+
var index = typeList.findIndex(item => item.name === name);
|
|
54
|
+
var nextMode = selected.mode === ItemModeType.Advanced ? ItemModeType.Normal : ItemModeType.Advanced;
|
|
55
|
+
var value = selected.value;
|
|
56
|
+
|
|
57
|
+
if (nextMode === ItemModeType.Normal) {
|
|
58
|
+
if (supportMenuType.includes(selected.type)) {
|
|
59
|
+
value = matchNoramlMenuValue(value);
|
|
60
|
+
}
|
|
61
|
+
} else if (isNil(selected.value)) {
|
|
62
|
+
value = "";
|
|
63
|
+
} else {
|
|
64
|
+
value = yamlStringify(selected.value);
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
form.setFieldsValue({
|
|
68
|
+
[name]: value
|
|
69
|
+
});
|
|
70
|
+
var newTypeList = update(typeList, {
|
|
71
|
+
$splice: [[index, 1, _objectSpread(_objectSpread({}, selected), {}, {
|
|
72
|
+
mode: nextMode
|
|
73
|
+
})]]
|
|
74
|
+
});
|
|
75
|
+
setTypeList(newTypeList);
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
var renderLabel = (item, hideIcon) => {
|
|
79
|
+
return /*#__PURE__*/React.createElement("span", null, /*#__PURE__*/React.createElement(Tooltip, {
|
|
80
|
+
title: item.description
|
|
81
|
+
}, item.name), " ", !hideIcon && labelIcon && /*#__PURE__*/React.createElement("span", {
|
|
82
|
+
className: styles.iconContainer,
|
|
83
|
+
onClick: () => handleLabelClick(item.name)
|
|
84
|
+
}, /*#__PURE__*/React.createElement(GeneralIcon, {
|
|
85
|
+
icon: item.mode === ItemModeType.Advanced ? labelIcon === null || labelIcon === void 0 ? void 0 : labelIcon.advanced : labelIcon.normal
|
|
86
|
+
})));
|
|
87
|
+
};
|
|
88
|
+
|
|
89
|
+
var renderEditorItem = (item, hideIcon) => {
|
|
90
|
+
return /*#__PURE__*/React.createElement(CodeEditorFormItem, {
|
|
91
|
+
key: item.name,
|
|
92
|
+
name: item.name,
|
|
93
|
+
label: renderLabel(item, hideIcon),
|
|
94
|
+
required: item.required === Required.True,
|
|
95
|
+
theme: theme === "dark-v2" ? "monokai" : "tomorrow",
|
|
96
|
+
jsonSchema: item === null || item === void 0 ? void 0 : item.jsonSchema,
|
|
97
|
+
schemaRef: item === null || item === void 0 ? void 0 : item.schemaRef,
|
|
98
|
+
mode: "brick_next_yaml"
|
|
99
|
+
});
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
var renderStringItem = item => {
|
|
103
|
+
return item.mode === ItemModeType.Advanced ? renderEditorItem(item) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
104
|
+
key: item.name,
|
|
105
|
+
label: renderLabel(item),
|
|
106
|
+
name: item.name,
|
|
107
|
+
rules: [{
|
|
108
|
+
required: item.required === Required.True,
|
|
109
|
+
message: "\u8BF7\u8F93\u5165".concat(item.name)
|
|
110
|
+
}]
|
|
111
|
+
}, /*#__PURE__*/React.createElement(Input, null));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
var renderBooleanItem = item => {
|
|
115
|
+
return item.mode === ItemModeType.Advanced ? renderEditorItem(item) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
116
|
+
key: item.name,
|
|
117
|
+
label: renderLabel(item),
|
|
118
|
+
name: item.name,
|
|
119
|
+
rules: [{
|
|
120
|
+
required: item.required === Required.True,
|
|
121
|
+
message: "\u8BF7\u8F93\u5165".concat(item.name)
|
|
122
|
+
}]
|
|
123
|
+
}, /*#__PURE__*/React.createElement(Radio.Group, null, /*#__PURE__*/React.createElement(Radio, {
|
|
124
|
+
value: true
|
|
125
|
+
}, "true"), /*#__PURE__*/React.createElement(Radio, {
|
|
126
|
+
value: false
|
|
127
|
+
}, "false")));
|
|
128
|
+
};
|
|
129
|
+
|
|
130
|
+
var renderInputNumberItem = item => {
|
|
131
|
+
return item.mode === ItemModeType.Advanced ? renderEditorItem(item) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
132
|
+
key: item.name,
|
|
133
|
+
label: renderLabel(item),
|
|
134
|
+
name: item.name,
|
|
135
|
+
rules: [{
|
|
136
|
+
required: item.required === Required.True,
|
|
137
|
+
message: "\u8BF7\u8F93\u5165".concat(item.name)
|
|
138
|
+
}]
|
|
139
|
+
}, /*#__PURE__*/React.createElement(InputNumber, null));
|
|
140
|
+
};
|
|
141
|
+
|
|
142
|
+
var renderStringListItem = item => {
|
|
143
|
+
return item.mode === ItemModeType.Advanced ? renderEditorItem(item) : /*#__PURE__*/React.createElement(Form.Item, {
|
|
144
|
+
key: item.name,
|
|
145
|
+
label: renderLabel(item),
|
|
146
|
+
name: item.name,
|
|
147
|
+
rules: [{
|
|
148
|
+
required: item.required === Required.True,
|
|
149
|
+
message: "\u8BF7\u8F93\u5165".concat(item.name)
|
|
150
|
+
}]
|
|
151
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
152
|
+
mode: "tags"
|
|
153
|
+
}));
|
|
154
|
+
};
|
|
155
|
+
|
|
156
|
+
var renderIconItem = item => {
|
|
157
|
+
return /*#__PURE__*/React.createElement(IconSelectFormItem, {
|
|
158
|
+
key: item.name,
|
|
159
|
+
name: item.name,
|
|
160
|
+
label: renderLabel(item, true),
|
|
161
|
+
required: item.required === Required.True
|
|
162
|
+
});
|
|
163
|
+
};
|
|
164
|
+
|
|
165
|
+
var renderCodeEditorItem = item => {
|
|
166
|
+
return renderEditorItem(item, true);
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
var renderColorItem = item => {
|
|
170
|
+
return /*#__PURE__*/React.createElement(ColorEditorItem, {
|
|
171
|
+
key: item.name,
|
|
172
|
+
name: item.name,
|
|
173
|
+
label: renderLabel(item, true),
|
|
174
|
+
required: item.required === Required.True
|
|
175
|
+
});
|
|
176
|
+
};
|
|
177
|
+
|
|
178
|
+
var renderMenuItem = item => {
|
|
179
|
+
return item.mode === ItemModeType.Advanced ? renderEditorItem(item) : /*#__PURE__*/React.createElement(MenuEditorItem, {
|
|
180
|
+
projectId: projectId,
|
|
181
|
+
key: item.name,
|
|
182
|
+
name: item.name,
|
|
183
|
+
label: renderLabel(item),
|
|
184
|
+
required: item.required === Required.True,
|
|
185
|
+
menuSettingClick: menuSettingClick
|
|
186
|
+
});
|
|
187
|
+
};
|
|
188
|
+
|
|
189
|
+
var getFormItem = item => {
|
|
190
|
+
switch (item.type) {
|
|
191
|
+
case "string":
|
|
192
|
+
return renderStringItem(item);
|
|
193
|
+
|
|
194
|
+
case "string[]":
|
|
195
|
+
return renderStringListItem(item);
|
|
196
|
+
|
|
197
|
+
case "number":
|
|
198
|
+
return renderInputNumberItem(item);
|
|
199
|
+
|
|
200
|
+
case "boolean":
|
|
201
|
+
return renderBooleanItem(item);
|
|
202
|
+
|
|
203
|
+
case "MenuIcon":
|
|
204
|
+
return renderIconItem(item);
|
|
205
|
+
|
|
206
|
+
case "Color":
|
|
207
|
+
return renderColorItem(item);
|
|
208
|
+
|
|
209
|
+
case "Menu":
|
|
210
|
+
case "SidebarSubMenu":
|
|
211
|
+
return renderMenuItem(item);
|
|
212
|
+
|
|
213
|
+
default:
|
|
214
|
+
return renderCodeEditorItem(item);
|
|
215
|
+
}
|
|
216
|
+
};
|
|
217
|
+
|
|
218
|
+
return isEmpty(typeList) ? /*#__PURE__*/React.createElement(Empty, {
|
|
219
|
+
className: styles.empty,
|
|
220
|
+
description: emptyConfig === null || emptyConfig === void 0 ? void 0 : emptyConfig.description,
|
|
221
|
+
image: theme === "dark-v2" ? /*#__PURE__*/React.createElement(DarkEmpty, null) : Empty.PRESENTED_IMAGE_SIMPLE,
|
|
222
|
+
imageStyle: emptyConfig === null || emptyConfig === void 0 ? void 0 : emptyConfig.imageStyle
|
|
223
|
+
}) : /*#__PURE__*/React.createElement(Form, {
|
|
224
|
+
name: "propertyForm",
|
|
225
|
+
layout: "vertical",
|
|
226
|
+
form: form,
|
|
227
|
+
onValuesChange: props.onValuesChange,
|
|
228
|
+
initialValues: calculateValue(propertyTypeList, brickProperties, typeList)
|
|
229
|
+
}, /*#__PURE__*/React.createElement(Collapse, {
|
|
230
|
+
ghost: true,
|
|
231
|
+
defaultActiveKey: "0",
|
|
232
|
+
className: styles.panelContainer
|
|
233
|
+
}, (_groupByType = groupByType(typeList)) === null || _groupByType === void 0 ? void 0 : _groupByType.map((_ref, index) => {
|
|
234
|
+
var [category, list] = _ref;
|
|
235
|
+
return /*#__PURE__*/React.createElement(Collapse.Panel, {
|
|
236
|
+
header: upperFirst(category),
|
|
237
|
+
key: index,
|
|
238
|
+
forceRender: true
|
|
239
|
+
}, list.map(item => getFormItem(item)));
|
|
240
|
+
}), /*#__PURE__*/React.createElement(Collapse.Panel, {
|
|
241
|
+
className: styles.otherPanel,
|
|
242
|
+
forceRender: true,
|
|
243
|
+
header: upperFirst(OTHER_FORM_ITEM_FIELD),
|
|
244
|
+
key: OTHER_FORM_ITEM_FIELD
|
|
245
|
+
}, /*#__PURE__*/React.createElement(CodeEditorFormItem, {
|
|
246
|
+
name: OTHER_FORM_ITEM_FIELD,
|
|
247
|
+
label: (brickInfo === null || brickInfo === void 0 ? void 0 : brickInfo.type) === "template" ? "other params" : "other properties",
|
|
248
|
+
mode: "brick_next_yaml",
|
|
249
|
+
maxLines: Infinity
|
|
250
|
+
}))));
|
|
251
|
+
}
|
|
252
|
+
export var VisualPropertyForm = /*#__PURE__*/React.forwardRef(LegacyVisualPropertyForm);
|
|
253
|
+
//# sourceMappingURL=VisualPropertyForm.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VisualPropertyForm.js","names":["React","useEffect","useImperativeHandle","useState","Form","Input","InputNumber","Radio","Select","Tooltip","Collapse","Empty","useCurrentTheme","GeneralIcon","update","isNil","pick","upperFirst","isEmpty","styles","CodeEditorFormItem","IconSelectFormItem","ColorEditorItem","MenuEditorItem","ReactComponent","DarkEmpty","mergeProperties","calculateValue","groupByType","yamlStringify","OTHER_FORM_ITEM_FIELD","supportMenuType","matchNoramlMenuValue","ItemModeType","Required","LegacyVisualPropertyForm","props","ref","theme","projectId","labelIcon","propertyTypeList","brickProperties","brickInfo","emptyConfig","menuSettingClick","form","useForm","typeList","setTypeList","validateFields","resetPropertyFields","properties","restValue","resetFields","getCurTypeList","map","item","newTypeList","newValue","setFieldsValue","handleLabelClick","name","selected","find","index","findIndex","nextMode","mode","Advanced","Normal","value","includes","type","$splice","renderLabel","hideIcon","description","iconContainer","advanced","normal","renderEditorItem","required","True","jsonSchema","schemaRef","renderStringItem","message","renderBooleanItem","renderInputNumberItem","renderStringListItem","renderIconItem","renderCodeEditorItem","renderColorItem","renderMenuItem","getFormItem","empty","PRESENTED_IMAGE_SIMPLE","imageStyle","onValuesChange","panelContainer","category","list","otherPanel","Infinity","VisualPropertyForm","forwardRef"],"sources":["../../../src/visual-property-form/VisualPropertyForm.tsx"],"sourcesContent":["import React, { useEffect, useImperativeHandle, useState } from \"react\";\nimport {\n Form,\n Input,\n InputNumber,\n Radio,\n Select,\n Tooltip,\n Collapse,\n Empty,\n} from \"antd\";\nimport { EmptyProps } from \"antd/lib/empty\";\nimport { useCurrentTheme } from \"@next-core/brick-kit\";\nimport { MenuIcon } from \"@next-core/brick-types\";\nimport { GeneralIcon } from \"@next-libs/basic-components\";\nimport update from \"immutability-helper\";\nimport { isNil, pick, upperFirst, isEmpty } from \"lodash\";\nimport styles from \"./VisualPropertyForm.module.css\";\nimport { FormProps } from \"antd/lib/form\";\nimport { CodeEditorFormItem } from \"./components/CodeEditor/CodeEditorFormItem\";\nimport { IconSelectFormItem } from \"./components/IconSelect/IconSelectFormItem\";\nimport { ColorEditorItem } from \"./components/ColorEditor/ColorEditorItem\";\nimport { MenuEditorItem } from \"./components/MenuEditor/MenuEditorItem\";\nimport { ReactComponent as DarkEmpty } from \"./images/empty-dark.svg\";\nimport {\n mergeProperties,\n calculateValue,\n groupByType,\n yamlStringify,\n} from \"./processor\";\nimport { OTHER_FORM_ITEM_FIELD, supportMenuType } from \"./constant\";\nimport { matchNoramlMenuValue } from \"./processor\";\nimport {\n PropertyType,\n BrickProperties,\n visualFormUtils,\n ItemModeType,\n UnionPropertyType,\n Required,\n} from \"../interfaces\";\n\nexport interface VisualPropertyFormProps {\n projectId?: string;\n propertyTypeList: PropertyType[];\n labelIcon: {\n normal?: MenuIcon;\n advanced?: MenuIcon;\n };\n brickProperties: BrickProperties;\n onValuesChange?: FormProps[\"onValuesChange\"];\n brickInfo?: {\n type: \"brick\" | \"provider\" | \"template\";\n };\n emptyConfig?: EmptyProps;\n menuSettingClick?: () => void;\n}\n\nexport function LegacyVisualPropertyForm(\n props: VisualPropertyFormProps,\n ref: React.Ref<visualFormUtils>\n): React.ReactElement {\n const theme = useCurrentTheme();\n const {\n projectId,\n labelIcon,\n propertyTypeList,\n brickProperties,\n brickInfo,\n emptyConfig,\n menuSettingClick,\n } = props;\n const [form] = Form.useForm();\n const [typeList, setTypeList] = useState<UnionPropertyType[]>(\n mergeProperties(propertyTypeList, brickProperties)\n );\n\n useImperativeHandle(ref, () => ({\n validateFields: form.validateFields,\n resetPropertyFields: (\n typeList: PropertyType[],\n properties: BrickProperties\n ) => {\n const restValue = mergeProperties(typeList, properties);\n setTypeList(restValue);\n form.resetFields();\n },\n getCurTypeList: (): UnionPropertyType[] => {\n return typeList?.map((item) => pick(item, [\"name\", \"type\", \"mode\"]));\n },\n }));\n\n useEffect(() => {\n const newTypeList = mergeProperties(propertyTypeList, brickProperties);\n setTypeList(newTypeList);\n\n const newValue = calculateValue(\n propertyTypeList,\n brickProperties,\n newTypeList\n );\n form.setFieldsValue(newValue);\n }, [propertyTypeList, brickProperties]);\n\n const handleLabelClick = (name: string): void => {\n const selected = typeList.find((item) => item.name === name);\n const index = typeList.findIndex((item) => item.name === name);\n const nextMode =\n selected.mode === ItemModeType.Advanced\n ? ItemModeType.Normal\n : ItemModeType.Advanced;\n\n let value = selected.value;\n if (nextMode === ItemModeType.Normal) {\n if (supportMenuType.includes(selected.type as string)) {\n value = matchNoramlMenuValue(value);\n }\n } else if (isNil(selected.value)) {\n value = \"\";\n } else {\n value = yamlStringify(selected.value);\n }\n form.setFieldsValue({\n [name]: value,\n });\n const newTypeList = update(typeList, {\n $splice: [[index, 1, { ...selected, mode: nextMode }]],\n });\n setTypeList(newTypeList);\n };\n\n const renderLabel = (\n item: UnionPropertyType,\n hideIcon?: boolean\n ): React.ReactElement => {\n return (\n <span>\n <Tooltip title={item.description}>{item.name}</Tooltip>{\" \"}\n {!hideIcon && labelIcon && (\n <span\n className={styles.iconContainer}\n onClick={() => handleLabelClick(item.name)}\n >\n <GeneralIcon\n icon={\n item.mode === ItemModeType.Advanced\n ? labelIcon?.advanced\n : labelIcon.normal\n }\n />\n </span>\n )}\n </span>\n );\n };\n\n const renderEditorItem = (item: UnionPropertyType, hideIcon?: boolean) => {\n return (\n <CodeEditorFormItem\n key={item.name}\n name={item.name}\n label={renderLabel(item, hideIcon) as any}\n required={item.required === Required.True}\n theme={theme === \"dark-v2\" ? \"monokai\" : \"tomorrow\"}\n jsonSchema={item?.jsonSchema}\n schemaRef={item?.schemaRef}\n mode=\"brick_next_yaml\"\n />\n );\n };\n\n const renderStringItem = (item: UnionPropertyType): React.ReactElement => {\n return item.mode === ItemModeType.Advanced ? (\n renderEditorItem(item)\n ) : (\n <Form.Item\n key={item.name}\n label={renderLabel(item)}\n name={item.name}\n rules={[\n {\n required: item.required === Required.True,\n message: `请输入${item.name}`,\n },\n ]}\n >\n <Input />\n </Form.Item>\n );\n };\n\n const renderBooleanItem = (item: UnionPropertyType): React.ReactElement => {\n return item.mode === ItemModeType.Advanced ? (\n renderEditorItem(item)\n ) : (\n <Form.Item\n key={item.name}\n label={renderLabel(item)}\n name={item.name}\n rules={[\n {\n required: item.required === Required.True,\n message: `请输入${item.name}`,\n },\n ]}\n >\n <Radio.Group>\n <Radio value={true}>true</Radio>\n <Radio value={false}>false</Radio>\n </Radio.Group>\n </Form.Item>\n );\n };\n\n const renderInputNumberItem = (\n item: UnionPropertyType\n ): React.ReactElement => {\n return item.mode === ItemModeType.Advanced ? (\n renderEditorItem(item)\n ) : (\n <Form.Item\n key={item.name}\n label={renderLabel(item)}\n name={item.name}\n rules={[\n {\n required: item.required === Required.True,\n message: `请输入${item.name}`,\n },\n ]}\n >\n <InputNumber />\n </Form.Item>\n );\n };\n\n const renderStringListItem = (\n item: UnionPropertyType\n ): React.ReactElement => {\n return item.mode === ItemModeType.Advanced ? (\n renderEditorItem(item)\n ) : (\n <Form.Item\n key={item.name}\n label={renderLabel(item)}\n name={item.name}\n rules={[\n {\n required: item.required === Required.True,\n message: `请输入${item.name}`,\n },\n ]}\n >\n <Select mode=\"tags\" />\n </Form.Item>\n );\n };\n\n const renderIconItem = (item: UnionPropertyType): React.ReactElement => {\n return (\n <IconSelectFormItem\n key={item.name}\n name={item.name}\n label={renderLabel(item, true) as any}\n required={item.required === Required.True}\n />\n );\n };\n\n const renderCodeEditorItem = (item: PropertyType): React.ReactElement => {\n return renderEditorItem(item, true);\n };\n\n const renderColorItem = (item: PropertyType): React.ReactElement => {\n return (\n <ColorEditorItem\n key={item.name}\n name={item.name}\n label={renderLabel(item, true)}\n required={item.required === Required.True}\n />\n );\n };\n\n const renderMenuItem = (item: UnionPropertyType): React.ReactElement => {\n return item.mode === ItemModeType.Advanced ? (\n renderEditorItem(item)\n ) : (\n <MenuEditorItem\n projectId={projectId}\n key={item.name}\n name={item.name}\n label={renderLabel(item)}\n required={item.required === Required.True}\n menuSettingClick={menuSettingClick}\n />\n );\n };\n\n const getFormItem = (item: PropertyType): React.ReactElement => {\n switch (item.type) {\n case \"string\":\n return renderStringItem(item);\n case \"string[]\":\n return renderStringListItem(item);\n case \"number\":\n return renderInputNumberItem(item);\n case \"boolean\":\n return renderBooleanItem(item);\n case \"MenuIcon\":\n return renderIconItem(item);\n case \"Color\":\n return renderColorItem(item);\n case \"Menu\":\n case \"SidebarSubMenu\":\n return renderMenuItem(item);\n default:\n return renderCodeEditorItem(item);\n }\n };\n\n return isEmpty(typeList) ? (\n <Empty\n className={styles.empty}\n description={emptyConfig?.description}\n image={theme === \"dark-v2\" ? <DarkEmpty /> : Empty.PRESENTED_IMAGE_SIMPLE}\n imageStyle={emptyConfig?.imageStyle}\n />\n ) : (\n <Form\n name=\"propertyForm\"\n layout=\"vertical\"\n form={form}\n onValuesChange={props.onValuesChange}\n initialValues={calculateValue(\n propertyTypeList,\n brickProperties,\n typeList\n )}\n >\n <Collapse ghost defaultActiveKey=\"0\" className={styles.panelContainer}>\n {groupByType(typeList)?.map(([category, list], index) => {\n return (\n <Collapse.Panel\n header={upperFirst(category)}\n key={index}\n forceRender={true}\n >\n {list.map((item) => getFormItem(item))}\n </Collapse.Panel>\n );\n })}\n\n <Collapse.Panel\n className={styles.otherPanel}\n forceRender={true}\n header={upperFirst(OTHER_FORM_ITEM_FIELD)}\n key={OTHER_FORM_ITEM_FIELD}\n >\n <CodeEditorFormItem\n name={OTHER_FORM_ITEM_FIELD}\n label={\n brickInfo?.type === \"template\"\n ? \"other params\"\n : \"other properties\"\n }\n mode=\"brick_next_yaml\"\n maxLines={Infinity}\n />\n </Collapse.Panel>\n </Collapse>\n </Form>\n );\n}\n\nexport const VisualPropertyForm = React.forwardRef(LegacyVisualPropertyForm);\n"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,SAAhB,EAA2BC,mBAA3B,EAAgDC,QAAhD,QAAgE,OAAhE;AACA,SACEC,IADF,EAEEC,KAFF,EAGEC,WAHF,EAIEC,KAJF,EAKEC,MALF,EAMEC,OANF,EAOEC,QAPF,EAQEC,KARF,QASO,MATP;AAWA,SAASC,eAAT,QAAgC,sBAAhC;AAEA,SAASC,WAAT,QAA4B,6BAA5B;AACA,OAAOC,MAAP,MAAmB,qBAAnB;AACA,SAASC,KAAT,EAAgBC,IAAhB,EAAsBC,UAAtB,EAAkCC,OAAlC,QAAiD,QAAjD;AACA,OAAOC,MAAP,MAAmB,iCAAnB;AAEA,SAASC,kBAAT,QAAmC,4CAAnC;AACA,SAASC,kBAAT,QAAmC,4CAAnC;AACA,SAASC,eAAT,QAAgC,0CAAhC;AACA,SAASC,cAAT,QAA+B,wCAA/B;AACA,SAASC,cAAc,IAAIC,SAA3B,QAA4C,yBAA5C;AACA,SACEC,eADF,EAEEC,cAFF,EAGEC,WAHF,EAIEC,aAJF,QAKO,aALP;AAMA,SAASC,qBAAT,EAAgCC,eAAhC,QAAuD,YAAvD;AACA,SAASC,oBAAT,QAAqC,aAArC;AACA,SAIEC,YAJF,EAMEC,QANF,QAOO,eAPP;AAyBA,OAAO,SAASC,wBAAT,CACLC,KADK,EAELC,GAFK,EAGe;EAAA;;EACpB,IAAMC,KAAK,GAAG1B,eAAe,EAA7B;EACA,IAAM;IACJ2B,SADI;IAEJC,SAFI;IAGJC,gBAHI;IAIJC,eAJI;IAKJC,SALI;IAMJC,WANI;IAOJC;EAPI,IAQFT,KARJ;EASA,IAAM,CAACU,IAAD,IAAS1C,IAAI,CAAC2C,OAAL,EAAf;EACA,IAAM,CAACC,QAAD,EAAWC,WAAX,IAA0B9C,QAAQ,C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AAC,QAAD;IAAU,KAAK,MAAf;IAAgB,gBAAgB,EAAC,GAAjC;IAAqC,SAAS,EAAE7B,MAAM,CAACiF;EAAvD,mBACGxE,WAAW,CAACoB,QAAD,CADd,iDACG,aAAuBQ,GAAvB,CAA2B,OAAmBS,KAAnB,KAA6B;IAAA,IAA5B,CAACoC,QAAD,EAAWC,IAAX,CAA4B;IACvD,oBACE,oBAAC,QAAD,CAAU,KAAV;MACE,MAAM,EAAErF,UAAU,CAACoF,QAAD,CADpB;MAEE,GAAG,EAAEpC,KAFP;MAGE,WAAW,EAAE;IAHf,GAKGqC,IAAI,CAAC9C,GAAL,CAAUC,IAAD,IAAUsC,WAAW,CAACtC,IAAD,CAA9B,CALH,CADF;EASD,CAVA,CADH,eAaE,oBAAC,QAAD,CAAU,KAAV;IACE,SAAS,EAAEtC,MAAM,CAACoF,UADpB;IAEE,WAAW,EAAE,IAFf;IAGE,MAAM,EAAEtF,UAAU,CAACa,qBAAD,CAHpB;IAIE,GAAG,EAAEA;EAJP,gBAME,oBAAC,kBAAD;IACE,IAAI,EAAEA,qBADR;IAEE,KAAK,EACH,CAAAa,SAAS,SAAT,IAAAA,SAAS,WAAT,YAAAA,SAAS,CAAE8B,IAAX,MAAoB,UAApB,GACI,cADJ,GAEI,kBALR;IAOE,IAAI,EAAC,iBAPP;IAQE,QAAQ,EAAE+B;EARZ,EANF,CAbF,CAXF,CARF;AAoDD;AAED,OAAO,IAAMC,kBAAkB,gBAAGzG,KAAK,CAAC0G,UAAN,CAAiBvE,wBAAjB,CAA3B"}
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
.iconContainer {
|
|
2
|
+
cursor: pointer;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
.panelContainer {
|
|
6
|
+
> :global(.ant-collapse-item) {
|
|
7
|
+
> :global(.ant-collapse-header) {
|
|
8
|
+
font-size: 16px;
|
|
9
|
+
font-weight: 500;
|
|
10
|
+
> :global(.ant-collapse-arrow) {
|
|
11
|
+
top: 6px;
|
|
12
|
+
color: var(--antd-btn-default-color);
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
> :global(.ant-collapse-content) {
|
|
17
|
+
> :global(.ant-collapse-content-box) {
|
|
18
|
+
padding: 0 20px;
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
.otherPanel {
|
|
25
|
+
/* hiden temporary */
|
|
26
|
+
display: none;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
.empty {
|
|
30
|
+
:global(.ant-empty-description) {
|
|
31
|
+
color: var(--color-disabled-text);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import _extends from "@babel/runtime/helpers/extends";
|
|
2
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
3
|
+
import _objectWithoutProperties from "@babel/runtime/helpers/objectWithoutProperties";
|
|
4
|
+
var _excluded = ["name", "label"];
|
|
5
|
+
import React, { useState } from "react";
|
|
6
|
+
import { some } from "lodash";
|
|
7
|
+
import { Form } from "antd";
|
|
8
|
+
import { CodeEditorItem } from "@next-libs/code-editor-components";
|
|
9
|
+
export function CodeEditorFormItem(props) {
|
|
10
|
+
var {
|
|
11
|
+
name,
|
|
12
|
+
label
|
|
13
|
+
} = props,
|
|
14
|
+
rest = _objectWithoutProperties(props, _excluded);
|
|
15
|
+
|
|
16
|
+
var [hasError, setHasError] = useState(false);
|
|
17
|
+
|
|
18
|
+
var handleValidate = err => {
|
|
19
|
+
var error = some(err, ["type", "error"]);
|
|
20
|
+
setHasError(error);
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
var validatorFn = /*#__PURE__*/function () {
|
|
24
|
+
var _ref = _asyncToGenerator(function* () {
|
|
25
|
+
if (!hasError) {
|
|
26
|
+
return Promise.resolve();
|
|
27
|
+
} else {
|
|
28
|
+
return Promise.reject("请填写正确的 yaml 语法");
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
return function validatorFn() {
|
|
33
|
+
return _ref.apply(this, arguments);
|
|
34
|
+
};
|
|
35
|
+
}();
|
|
36
|
+
|
|
37
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
38
|
+
key: props.name,
|
|
39
|
+
name: props.name,
|
|
40
|
+
label: props.label,
|
|
41
|
+
rules: [{
|
|
42
|
+
required: props.required,
|
|
43
|
+
message: "\u8BF7\u8F93\u5165".concat(props.name)
|
|
44
|
+
}, {
|
|
45
|
+
validator: validatorFn
|
|
46
|
+
}]
|
|
47
|
+
}, /*#__PURE__*/React.createElement(CodeEditorItem, _extends({
|
|
48
|
+
tabSize: 2,
|
|
49
|
+
minLines: 5,
|
|
50
|
+
maxLines: 12,
|
|
51
|
+
printMargin: false,
|
|
52
|
+
showLineNumbers: false,
|
|
53
|
+
theme: "tomorrow",
|
|
54
|
+
enableLiveAutocompletion: true,
|
|
55
|
+
onValidate: handleValidate
|
|
56
|
+
}, rest)));
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=CodeEditorFormItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CodeEditorFormItem.js","names":["React","useState","some","Form","CodeEditorItem","CodeEditorFormItem","props","name","label","rest","hasError","setHasError","handleValidate","err","error","validatorFn","Promise","resolve","reject","required","message","validator"],"sources":["../../../../../src/visual-property-form/components/CodeEditor/CodeEditorFormItem.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { some } from \"lodash\";\nimport { Form } from \"antd\";\nimport { FormItemWrapperProps } from \"@next-libs/forms\";\nimport {\n CodeEditorProps,\n CodeEditorItem,\n Error,\n} from \"@next-libs/code-editor-components\";\n\ninterface CodeEditorItemProps extends CodeEditorProps, FormItemWrapperProps {}\n\nexport function CodeEditorFormItem(\n props: CodeEditorItemProps\n): React.ReactElement {\n const { name, label, ...rest } = props;\n const [hasError, setHasError] = useState(false);\n\n const handleValidate = (err: Error[\"err\"]): void => {\n const error = some(err, [\"type\", \"error\"]);\n setHasError(error);\n };\n\n const validatorFn = async () => {\n if (!hasError) {\n return Promise.resolve();\n } else {\n return Promise.reject(\"请填写正确的 yaml 语法\");\n }\n };\n\n return (\n <Form.Item\n key={props.name}\n name={props.name}\n label={props.label}\n rules={[\n { required: props.required, message: `请输入${props.name}` },\n { validator: validatorFn },\n ]}\n >\n <CodeEditorItem\n tabSize={2}\n minLines={5}\n maxLines={12}\n printMargin={false}\n showLineNumbers={false}\n theme=\"tomorrow\"\n enableLiveAutocompletion={true}\n onValidate={handleValidate}\n {...rest}\n ></CodeEditorItem>\n </Form.Item>\n );\n}\n"],"mappings":";;;;AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,QAAqB,QAArB;AACA,SAASC,IAAT,QAAqB,MAArB;AAEA,SAEEC,cAFF,QAIO,mCAJP;AAQA,OAAO,SAASC,kBAAT,CACLC,KADK,EAEe;EACpB,IAAM;IAAEC,IAAF;IAAQC;EAAR,IAA2BF,KAAjC;EAAA,IAAwBG,IAAxB,4BAAiCH,KAAjC;;EACA,IAAM,CAACI,QAAD,EAAWC,WAAX,IAA0BV,QAAQ,CAAC,KAAD,CAAxC;;EAEA,IAAMW,cAAc,GAAIC,GAAD,IAA6B;IAClD,IAAMC,KAAK,GAAGZ,IAAI,CAACW,GAAD,EAAM,CAAC,MAAD,EAAS,OAAT,CAAN,CAAlB;IACAF,WAAW,CAACG,KAAD,CAAX;EACD,CAHD;;EAKA,IAAMC,WAAW;IAAA,6BAAG,aAAY;MAC9B,IAAI,CAACL,QAAL,EAAe;QACb,OAAOM,OAAO,CAACC,OAAR,EAAP;MACD,CAFD,MAEO;QACL,OAAOD,OAAO,CAACE,MAAR,CAAe,gBAAf,CAAP;MACD;IACF,CANgB;;IAAA,gBAAXH,WAAW;MAAA;IAAA;EAAA,GAAjB;;EAQA,oBACE,oBAAC,IAAD,CAAM,IAAN;IACE,GAAG,EAAET,KAAK,CAACC,IADb;IAEE,IAAI,EAAED,KAAK,CAACC,IAFd;IAGE,KAAK,EAAED,KAAK,CAACE,KAHf;IAIE,KAAK,EAAE,CACL;MAAEW,QAAQ,EAAEb,KAAK,CAACa,QAAlB;MAA4BC,OAAO,8BAAQd,KAAK,CAACC,IAAd;IAAnC,CADK,EAEL;MAAEc,SAAS,EAAEN;IAAb,CAFK;EAJT,gBASE,oBAAC,cAAD;IACE,OAAO,EAAE,CADX;IAEE,QAAQ,EAAE,CAFZ;IAGE,QAAQ,EAAE,EAHZ;IAIE,WAAW,EAAE,KAJf;IAKE,eAAe,EAAE,KALnB;IAME,KAAK,EAAC,UANR;IAOE,wBAAwB,EAAE,IAP5B;IAQE,UAAU,EAAEH;EARd,GASMH,IATN,EATF,CADF;AAuBD"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
.colorContainer {
|
|
2
|
+
position: relative;
|
|
3
|
+
|
|
4
|
+
> .colorCube {
|
|
5
|
+
display: inline-block;
|
|
6
|
+
padding: 5px;
|
|
7
|
+
border-radius: 1px;
|
|
8
|
+
box-shadow: rgb(0 0 0 / 10%) 0px 0px 0px 1px;
|
|
9
|
+
cursor: pointer;
|
|
10
|
+
|
|
11
|
+
> .colorContent {
|
|
12
|
+
width: 36px;
|
|
13
|
+
height: 14px;
|
|
14
|
+
border-radius: 2px;
|
|
15
|
+
}
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
> .popover {
|
|
19
|
+
position: absolute;
|
|
20
|
+
z-index: 2;
|
|
21
|
+
left: 55px;
|
|
22
|
+
top: -130px;
|
|
23
|
+
|
|
24
|
+
> .cover {
|
|
25
|
+
position: fixed;
|
|
26
|
+
top: 0;
|
|
27
|
+
right: 0;
|
|
28
|
+
bottom: 0;
|
|
29
|
+
left: 0;
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
import { SketchPicker } from "react-color";
|
|
2
|
+
import { COLORS_MAP } from "@next-libs/basic-components";
|
|
3
|
+
import { Form } from "antd";
|
|
4
|
+
import React, { useEffect, useState, forwardRef } from "react";
|
|
5
|
+
import styles from "./ColorEditor.module.css";
|
|
6
|
+
export function getPresetColors(colorMap) {
|
|
7
|
+
var colorList = [];
|
|
8
|
+
|
|
9
|
+
var _loop = function (group) {
|
|
10
|
+
["color", "background", "borderColor"].forEach(name => {
|
|
11
|
+
var _name;
|
|
12
|
+
|
|
13
|
+
var result = (_name = group[name]) === null || _name === void 0 ? void 0 : _name.match(/^var\((.+)\)/);
|
|
14
|
+
|
|
15
|
+
if (result) {
|
|
16
|
+
var _window$getComputedSt;
|
|
17
|
+
|
|
18
|
+
var colorHex = (_window$getComputedSt = window.getComputedStyle(document.documentElement).getPropertyValue(result[1])) === null || _window$getComputedSt === void 0 ? void 0 : _window$getComputedSt.trim();
|
|
19
|
+
colorHex && colorList.push(colorHex);
|
|
20
|
+
}
|
|
21
|
+
});
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
for (var [, group] of Object.entries(colorMap)) {
|
|
25
|
+
_loop(group);
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
return colorList;
|
|
29
|
+
}
|
|
30
|
+
export function LegacyColorPick(props, ref) {
|
|
31
|
+
var [value, setValue] = useState(props.value);
|
|
32
|
+
var [visible, setVisible] = useState(false);
|
|
33
|
+
useEffect(() => {
|
|
34
|
+
setValue(props.value);
|
|
35
|
+
}, [props.value]);
|
|
36
|
+
|
|
37
|
+
var handleChangeComplete = color => {
|
|
38
|
+
setValue(color.hex);
|
|
39
|
+
props.onChange(color.hex);
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
var handleClick = () => {
|
|
43
|
+
setVisible(true);
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
47
|
+
className: styles.colorContainer
|
|
48
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
49
|
+
className: styles.colorCube,
|
|
50
|
+
onClick: handleClick
|
|
51
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
52
|
+
className: styles.colorContent,
|
|
53
|
+
style: {
|
|
54
|
+
backgroundColor: value
|
|
55
|
+
}
|
|
56
|
+
})), visible && /*#__PURE__*/React.createElement("div", {
|
|
57
|
+
className: styles.popover
|
|
58
|
+
}, /*#__PURE__*/React.createElement("div", {
|
|
59
|
+
className: styles.cover,
|
|
60
|
+
onClick: () => setVisible(false)
|
|
61
|
+
}), /*#__PURE__*/React.createElement(SketchPicker, {
|
|
62
|
+
width: "230px",
|
|
63
|
+
ref: ref,
|
|
64
|
+
color: value,
|
|
65
|
+
onChangeComplete: handleChangeComplete,
|
|
66
|
+
presetColors: getPresetColors(COLORS_MAP)
|
|
67
|
+
})));
|
|
68
|
+
}
|
|
69
|
+
export var ColorPick = /*#__PURE__*/forwardRef(LegacyColorPick);
|
|
70
|
+
export function ColorEditorItem(props) {
|
|
71
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
72
|
+
key: props.name,
|
|
73
|
+
name: props.name,
|
|
74
|
+
label: props.label,
|
|
75
|
+
rules: [{
|
|
76
|
+
required: props.required,
|
|
77
|
+
message: "\u8BF7\u8F93\u5165".concat(props.name)
|
|
78
|
+
}]
|
|
79
|
+
}, /*#__PURE__*/React.createElement(ColorPick, null));
|
|
80
|
+
}
|
|
81
|
+
//# sourceMappingURL=ColorEditorItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ColorEditorItem.js","names":["SketchPicker","COLORS_MAP","Form","React","useEffect","useState","forwardRef","styles","getPresetColors","colorMap","colorList","group","forEach","name","result","match","colorHex","window","getComputedStyle","document","documentElement","getPropertyValue","trim","push","Object","entries","LegacyColorPick","props","ref","value","setValue","visible","setVisible","handleChangeComplete","color","hex","onChange","handleClick","colorContainer","colorCube","colorContent","backgroundColor","popover","cover","ColorPick","ColorEditorItem","label","required","message"],"sources":["../../../../../src/visual-property-form/components/ColorEditor/ColorEditorItem.tsx"],"sourcesContent":["import { ColorResult, SketchPicker } from \"react-color\";\nimport { COLORS_MAP, Colors } from \"@next-libs/basic-components\";\nimport { Form } from \"antd\";\nimport React, { useEffect, useState, forwardRef } from \"react\";\nimport styles from \"./ColorEditor.module.css\";\n\nexport interface ColorEditorItemProps {\n name?: string;\n label?: string | React.ReactElement;\n required?: boolean;\n value?: any;\n onChange?: (value: string) => void;\n}\n\nexport function getPresetColors(\n colorMap: Record<\n Colors,\n {\n color: string;\n background: string;\n borderColor: string;\n }\n >\n): string[] {\n const colorList: string[] = [];\n for (const [, group] of Object.entries(colorMap)) {\n [\"color\", \"background\", \"borderColor\"].forEach((name) => {\n const result = (group as Record<string, any>)[name]?.match(\n /^var\\((.+)\\)/\n );\n if (result) {\n const colorHex = window\n .getComputedStyle(document.documentElement)\n .getPropertyValue(result[1])\n ?.trim();\n colorHex && colorList.push(colorHex);\n }\n });\n }\n\n return colorList;\n}\n\nexport function LegacyColorPick(\n props: ColorEditorItemProps,\n ref: React.Ref<any>\n) {\n const [value, setValue] = useState(props.value);\n const [visible, setVisible] = useState(false);\n\n useEffect(() => {\n setValue(props.value);\n }, [props.value]);\n\n const handleChangeComplete = (color: ColorResult) => {\n setValue(color.hex);\n props.onChange(color.hex);\n };\n\n const handleClick = () => {\n setVisible(true);\n };\n\n return (\n <div className={styles.colorContainer}>\n <div className={styles.colorCube} onClick={handleClick}>\n <div\n className={styles.colorContent}\n style={{ backgroundColor: value }}\n />\n </div>\n {visible && (\n <div className={styles.popover}>\n <div className={styles.cover} onClick={() => setVisible(false)} />\n <SketchPicker\n width=\"230px\"\n ref={ref}\n color={value}\n onChangeComplete={handleChangeComplete}\n presetColors={getPresetColors(COLORS_MAP)}\n />\n </div>\n )}\n </div>\n );\n}\n\nexport const ColorPick = forwardRef(LegacyColorPick);\n\nexport function ColorEditorItem(props: ColorEditorItemProps) {\n return (\n <Form.Item\n key={props.name}\n name={props.name}\n label={props.label}\n rules={[{ required: props.required, message: `请输入${props.name}` }]}\n >\n <ColorPick />\n </Form.Item>\n );\n}\n"],"mappings":"AAAA,SAAsBA,YAAtB,QAA0C,aAA1C;AACA,SAASC,UAAT,QAAmC,6BAAnC;AACA,SAASC,IAAT,QAAqB,MAArB;AACA,OAAOC,KAAP,IAAgBC,SAAhB,EAA2BC,QAA3B,EAAqCC,UAArC,QAAuD,OAAvD;AACA,OAAOC,MAAP,MAAmB,0BAAnB;AAUA,OAAO,SAASC,eAAT,CACLC,QADK,EASK;EACV,IAAMC,SAAmB,GAAG,EAA5B;;EADU,sBAEIC,KAFJ;IAGR,CAAC,OAAD,EAAU,YAAV,EAAwB,aAAxB,EAAuCC,OAAvC,CAAgDC,IAAD,IAAU;MAAA;;MACvD,IAAMC,MAAM,YAAIH,KAAD,CAA+BE,IAA/B,CAAH,0CAAG,MAAsCE,KAAtC,CACb,cADa,CAAf;;MAGA,IAAID,MAAJ,EAAY;QAAA;;QACV,IAAME,QAAQ,4BAAGC,MAAM,CACpBC,gBADc,CACGC,QAAQ,CAACC,eADZ,EAEdC,gBAFc,CAEGP,MAAM,CAAC,CAAD,CAFT,CAAH,0DAAG,sBAGbQ,IAHa,EAAjB;QAIAN,QAAQ,IAAIN,SAAS,CAACa,IAAV,CAAeP,QAAf,CAAZ;MACD;IACF,CAXD;EAHQ;;EAEV,KAAK,IAAM,GAAGL,KAAH,CAAX,IAAwBa,MAAM,CAACC,OAAP,CAAehB,QAAf,CAAxB,EAAkD;IAAA,MAApCE,KAAoC;EAajD;;EAED,OAAOD,SAAP;AACD;AAED,OAAO,SAASgB,eAAT,CACLC,KADK,EAELC,GAFK,EAGL;EACA,IAAM,CAACC,KAAD,EAAQC,QAAR,IAAoBzB,QAAQ,CAACsB,KAAK,CAACE,KAAP,CAAlC;EACA,IAAM,CAACE,OAAD,EAAUC,UAAV,IAAwB3B,QAAQ,CAAC,KAAD,CAAtC;EAEAD,SAAS,CAAC,MAAM;IACd0B,QAAQ,CAACH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AO,8BAAQrB,KAAK,CAACd,IAAd;IAAnC,CAAD;EAJT,gBAME,oBAAC,SAAD,OANF,CADF;AAUD"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import React, { useState } from "react";
|
|
2
|
+
import { Form } from "antd";
|
|
3
|
+
import { IconSelectItem } from "@next-libs/forms";
|
|
4
|
+
export function IconSelectFormItem(props) {
|
|
5
|
+
var [visible, setVisible] = useState(false);
|
|
6
|
+
return /*#__PURE__*/React.createElement(Form.Item, {
|
|
7
|
+
key: props.name,
|
|
8
|
+
name: props.name,
|
|
9
|
+
label: props.label,
|
|
10
|
+
rules: [{
|
|
11
|
+
required: props.required,
|
|
12
|
+
message: "\u8BF7\u8F93\u5165".concat(props.name)
|
|
13
|
+
}]
|
|
14
|
+
}, /*#__PURE__*/React.createElement(IconSelectItem, {
|
|
15
|
+
setColor: true,
|
|
16
|
+
bg: true,
|
|
17
|
+
visible: visible,
|
|
18
|
+
openModal: () => setVisible(true),
|
|
19
|
+
handleCancel: () => setVisible(false),
|
|
20
|
+
onChange: () => setVisible(false)
|
|
21
|
+
}));
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=IconSelectFormItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IconSelectFormItem.js","names":["React","useState","Form","IconSelectItem","IconSelectFormItem","props","visible","setVisible","name","label","required","message"],"sources":["../../../../../src/visual-property-form/components/IconSelect/IconSelectFormItem.tsx"],"sourcesContent":["import React, { useState } from \"react\";\nimport { Form } from \"antd\";\nimport { IconSelectProps, IconSelectItem } from \"@next-libs/forms\";\n\nexport function IconSelectFormItem(props: IconSelectProps): React.ReactElement {\n const [visible, setVisible] = useState(false);\n\n return (\n <Form.Item\n key={props.name}\n name={props.name}\n label={props.label}\n rules={[{ required: props.required, message: `请输入${props.name}` }]}\n >\n <IconSelectItem\n setColor={true}\n bg={true}\n visible={visible}\n openModal={() => setVisible(true)}\n handleCancel={() => setVisible(false)}\n onChange={() => setVisible(false)}\n />\n </Form.Item>\n );\n}\n"],"mappings":"AAAA,OAAOA,KAAP,IAAgBC,QAAhB,QAAgC,OAAhC;AACA,SAASC,IAAT,QAAqB,MAArB;AACA,SAA0BC,cAA1B,QAAgD,kBAAhD;AAEA,OAAO,SAASC,kBAAT,CAA4BC,KAA5B,EAAwE;EAC7E,IAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBN,QAAQ,CAAC,KAAD,CAAtC;EAEA,oBACE,oBAAC,IAAD,CAAM,IAAN;IACE,GAAG,EAAEI,KAAK,CAACG,IADb;IAEE,IAAI,EAAEH,KAAK,CAACG,IAFd;IAGE,KAAK,EAAEH,KAAK,CAACI,KAHf;IAIE,KAAK,EAAE,CAAC;MAAEC,QAAQ,EAAEL,KAAK,CAACK,QAAlB;MAA4BC,OAAO,8BAAQN,KAAK,CAACG,IAAd;IAAnC,CAAD;EAJT,gBAME,oBAAC,cAAD;IACE,QAAQ,EAAE,IADZ;IAEE,EAAE,EAAE,IAFN;IAGE,OAAO,EAAEF,OAHX;IAIE,SAAS,EAAE,MAAMC,UAAU,CAAC,IAAD,CAJ7B;IAKE,YAAY,EAAE,MAAMA,UAAU,CAAC,KAAD,CALhC;IAME,QAAQ,EAAE,MAAMA,UAAU,CAAC,KAAD;EAN5B,EANF,CADF;AAiBD"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import _asyncToGenerator from "@babel/runtime/helpers/asyncToGenerator";
|
|
2
|
+
import React, { useState, useEffect } from "react";
|
|
3
|
+
import { Form, Select, Tooltip } from "antd";
|
|
4
|
+
import { GeneralIcon } from "@next-libs/basic-components";
|
|
5
|
+
import { InstanceApi_getDetail } from "@next-sdk/cmdb-sdk";
|
|
6
|
+
export function MenuEditorItem(props) {
|
|
7
|
+
var [options, setOptions] = useState([]);
|
|
8
|
+
|
|
9
|
+
var getMenu = /*#__PURE__*/function () {
|
|
10
|
+
var _ref = _asyncToGenerator(function* () {
|
|
11
|
+
var result = yield InstanceApi_getDetail("PROJECT_MICRO_APP", props.projectId, {
|
|
12
|
+
fields: "menus.menuId"
|
|
13
|
+
});
|
|
14
|
+
var options = result.menus.map(item => ({
|
|
15
|
+
value: item.menuId,
|
|
16
|
+
label: item.menuId
|
|
17
|
+
}));
|
|
18
|
+
setOptions(options);
|
|
19
|
+
});
|
|
20
|
+
|
|
21
|
+
return function getMenu() {
|
|
22
|
+
return _ref.apply(this, arguments);
|
|
23
|
+
};
|
|
24
|
+
}();
|
|
25
|
+
|
|
26
|
+
var handleMenuSettingClick = () => {
|
|
27
|
+
props.menuSettingClick();
|
|
28
|
+
};
|
|
29
|
+
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
if (props.projectId) {
|
|
32
|
+
getMenu();
|
|
33
|
+
}
|
|
34
|
+
}, []);
|
|
35
|
+
return /*#__PURE__*/React.createElement("div", {
|
|
36
|
+
style: {
|
|
37
|
+
display: "flex",
|
|
38
|
+
alignItems: "center"
|
|
39
|
+
}
|
|
40
|
+
}, /*#__PURE__*/React.createElement(Form.Item, {
|
|
41
|
+
key: props.name,
|
|
42
|
+
name: props.name,
|
|
43
|
+
label: props.label,
|
|
44
|
+
rules: [{
|
|
45
|
+
required: props.required,
|
|
46
|
+
message: "\u8BF7\u8F93\u5165".concat(props.name)
|
|
47
|
+
}]
|
|
48
|
+
}, /*#__PURE__*/React.createElement(Select, {
|
|
49
|
+
style: {
|
|
50
|
+
width: "300px"
|
|
51
|
+
},
|
|
52
|
+
options: options,
|
|
53
|
+
showSearch: true,
|
|
54
|
+
allowClear: true,
|
|
55
|
+
placeholder: "Select a menu id",
|
|
56
|
+
filterOption: (input, option) => option.label.toLocaleLowerCase().indexOf(input.toLocaleLowerCase()) >= 0 || option.value.toLocaleLowerCase().indexOf(input.toLocaleLowerCase()) >= 0
|
|
57
|
+
})), /*#__PURE__*/React.createElement("div", {
|
|
58
|
+
style: {
|
|
59
|
+
fontSize: "18px",
|
|
60
|
+
marginTop: "10px",
|
|
61
|
+
marginLeft: "10px",
|
|
62
|
+
cursor: "pointer",
|
|
63
|
+
display: "inline-block"
|
|
64
|
+
}
|
|
65
|
+
}, /*#__PURE__*/React.createElement(Tooltip, {
|
|
66
|
+
title: "\u914D\u7F6E\u83DC\u5355\u6570\u636E"
|
|
67
|
+
}, " ", /*#__PURE__*/React.createElement(GeneralIcon, {
|
|
68
|
+
icon: {
|
|
69
|
+
category: "app",
|
|
70
|
+
color: "blue",
|
|
71
|
+
icon: "launchpad-setting",
|
|
72
|
+
lib: "easyops"
|
|
73
|
+
},
|
|
74
|
+
onClick: handleMenuSettingClick
|
|
75
|
+
}))));
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=MenuEditorItem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"MenuEditorItem.js","names":["React","useState","useEffect","Form","Select","Tooltip","GeneralIcon","InstanceApi_getDetail","MenuEditorItem","props","options","setOptions","getMenu","result","projectId","fields","menus","map","item","value","menuId","label","handleMenuSettingClick","menuSettingClick","display","alignItems","name","required","message","width","input","option","toLocaleLowerCase","indexOf","fontSize","marginTop","marginLeft","cursor","category","color","icon","lib"],"sources":["../../../../../src/visual-property-form/components/MenuEditor/MenuEditorItem.tsx"],"sourcesContent":["import React, { useState, useEffect } from \"react\";\nimport { Form, Select, Tooltip } from \"antd\";\nimport { GeneralIcon } from \"@next-libs/basic-components\";\nimport { InstanceApi_getDetail } from \"@next-sdk/cmdb-sdk\";\n\ninterface MenuEditorItemProps {\n name?: string;\n label?: string | React.ReactElement;\n value?: string;\n required?: boolean;\n projectId?: string;\n menuSettingClick?: () => void;\n}\n\nexport function MenuEditorItem(props: MenuEditorItemProps): React.ReactElement {\n const [options, setOptions] = useState([]);\n\n const getMenu = async () => {\n const result = await InstanceApi_getDetail(\n \"PROJECT_MICRO_APP\",\n props.projectId,\n {\n fields: \"menus.menuId\",\n }\n );\n\n const options = result.menus.map((item: Record<string, any>) => ({\n value: item.menuId,\n label: item.menuId,\n }));\n setOptions(options);\n };\n\n const handleMenuSettingClick = () => {\n props.menuSettingClick();\n };\n\n useEffect(() => {\n if (props.projectId) {\n getMenu();\n }\n }, []);\n\n return (\n <div\n style={{\n display: \"flex\",\n alignItems: \"center\",\n }}\n >\n <Form.Item\n key={props.name}\n name={props.name}\n label={props.label}\n rules={[{ required: props.required, message: `请输入${props.name}` }]}\n >\n <Select\n style={{\n width: \"300px\",\n }}\n options={options}\n showSearch\n allowClear\n placeholder=\"Select a menu id\"\n filterOption={(input, option) =>\n (option.label as string)\n .toLocaleLowerCase()\n .indexOf(input.toLocaleLowerCase()) >= 0 ||\n (option.value as string)\n .toLocaleLowerCase()\n .indexOf(input.toLocaleLowerCase()) >= 0\n }\n />\n </Form.Item>\n <div\n style={{\n fontSize: \"18px\",\n marginTop: \"10px\",\n marginLeft: \"10px\",\n cursor: \"pointer\",\n display: \"inline-block\",\n }}\n >\n <Tooltip title=\"配置菜单数据\">\n {\" \"}\n <GeneralIcon\n icon={{\n category: \"app\",\n color: \"blue\",\n icon: \"launchpad-setting\",\n lib: \"easyops\",\n }}\n onClick={handleMenuSettingClick}\n />\n </Tooltip>\n </div>\n </div>\n );\n}\n"],"mappings":";AAAA,OAAOA,KAAP,IAAgBC,QAAhB,EAA0BC,SAA1B,QAA2C,OAA3C;AACA,SAASC,IAAT,EAAeC,MAAf,EAAuBC,OAAvB,QAAsC,MAAtC;AACA,SAASC,WAAT,QAA4B,6BAA5B;AACA,SAASC,qBAAT,QAAsC,oBAAtC;AAWA,OAAO,SAASC,cAAT,CAAwBC,KAAxB,EAAwE;EAC7E,IAAM,CAACC,OAAD,EAAUC,UAAV,IAAwBV,QAAQ,CAAC,EAAD,CAAtC;;EAEA,IAAMW,OAAO;IAAA,6BAAG,aAAY;MAC1B,IAAMC,MAAM,SAASN,qBAAqB,CACxC,mBADwC,EAExCE,KAAK,CAACK,SAFkC,EAGxC;QACEC,MAAM,EAAE;MADV,CAHwC,CAA1C;MAQA,IAAML,OAAO,GAAGG,MAAM,CA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