lu-lowcode-package-form 0.9.26 → 0.9.29
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/dist/index.cjs.js +55 -55
- package/dist/index.es.js +4555 -4505
- package/package.json +1 -1
- package/src/App.jsx +11 -4
- package/src/components/field/select/index.jsx +2 -2
- package/src/components/field/select/select.jsx +17 -2
- package/src/components/form-container/index.jsx +21 -15
- package/src/components/index.jsx +4 -1
package/package.json
CHANGED
package/src/App.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang } from './components';
|
|
2
2
|
import './App.css';
|
|
3
|
-
import { Button } from 'antd';
|
|
3
|
+
import { Button , Input , Select } from 'antd';
|
|
4
4
|
import React, { useState } from 'react';
|
|
5
5
|
import Draggable from 'react-draggable';
|
|
6
6
|
|
|
@@ -88,11 +88,17 @@ function App() {
|
|
|
88
88
|
<EditorQuill value={"[{\"insert\":\"sdfsd\"}]"} />
|
|
89
89
|
</div>
|
|
90
90
|
<div className='fw-full fp-4'>
|
|
91
|
+
<Select
|
|
92
|
+
mode="tags"
|
|
93
|
+
style={{ width: '100%' }}
|
|
94
|
+
placeholder="Tags Mode"
|
|
95
|
+
options={[ { label: '标签1', value: '1' }, { label: '标签2', value: '2' }]}
|
|
96
|
+
/>
|
|
91
97
|
<Setter.OptionSetter />
|
|
92
98
|
</div>
|
|
93
99
|
<div className='fw-[960px] frounded fbg-slate-50 fflex fflex-col fitems-center fpb-10'>
|
|
94
100
|
|
|
95
|
-
|
|
101
|
+
|
|
96
102
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
|
97
103
|
<Layout.FormGroupTitle title={"基本信息"} />
|
|
98
104
|
<Layout.FormRow layout={'1'}>
|
|
@@ -170,11 +176,12 @@ function App() {
|
|
|
170
176
|
]
|
|
171
177
|
}}
|
|
172
178
|
/>
|
|
179
|
+
<Field.UserSelect label="选择用户" __id="userselect" customComponent={Input} />
|
|
173
180
|
<Field.SearchSelect isRequired={true} label="搜组件" __id="searchuser" option_search="username" option_label="username" setValue={() => { }} option_value="id"></Field.SearchSelect>
|
|
174
|
-
<Field.Input rules={"^(1[3-9]\\d{9})$"}
|
|
181
|
+
<Field.Input rules={"^(1[3-9]\\d{9})$"} isRequired={true} label="商品价格" __id="product_price" />
|
|
175
182
|
<Field.Input label="商品数量" __id="product_num" />
|
|
176
183
|
<Field.NumberRange label="数量范围" __id="product_num_range" />
|
|
177
|
-
<Field.Input rules={"^(1[3-9]\\d{9})$"} label="商品总价" __id="product_sum"
|
|
184
|
+
<Field.Input rules={["^(1[3-9]\\d{9})$","^\\d+$"]} label="商品总价" __id="product_sum"
|
|
178
185
|
withIds={["product_price", "product_num"]}
|
|
179
186
|
withFill={{
|
|
180
187
|
"value": [
|
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
export { default as TreeSelect } from './tree-select.jsx';
|
|
2
|
-
export
|
|
3
|
-
export
|
|
2
|
+
export * from './select.jsx';
|
|
3
|
+
export * from './search-select.jsx'
|
|
4
4
|
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { Select as OriginalSelect } from "antd";
|
|
1
|
+
import { Select as OriginalSelect, Tree } from "antd";
|
|
2
2
|
|
|
3
3
|
import { BaseWrapper } from "../base"
|
|
4
4
|
import React, { useEffect, useState } from 'react';
|
|
5
|
+
import TreeSelect from './tree-select'
|
|
5
6
|
|
|
6
7
|
const Select = ({ request, option_label = "label", option_value = "id", disabledValue, callError, options, addWrapper = true, ...props }) => {
|
|
7
8
|
// const [firstLoad, setFirstLoad] = React.useState(false)
|
|
@@ -124,4 +125,18 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
|
|
|
124
125
|
)
|
|
125
126
|
}
|
|
126
127
|
|
|
127
|
-
|
|
128
|
+
// 选择用户组件
|
|
129
|
+
const UserSelect = ({customComponent:CustomComponent,...props})=>{
|
|
130
|
+
if (!CustomComponent) return <BaseWrapper {...props}><div className="fflex fitems-center fh-8">未配置组件内容</div></BaseWrapper>
|
|
131
|
+
else return <BaseWrapper {...props}><CustomComponent {...props} /></BaseWrapper>
|
|
132
|
+
}
|
|
133
|
+
// 选择部门组件
|
|
134
|
+
const DeptSelect = ({FetchDeptList,...props})=>{
|
|
135
|
+
return <TreeSelect {...props} title={"deptName"} request={FetchDeptList} />
|
|
136
|
+
}
|
|
137
|
+
// 选择岗位组件
|
|
138
|
+
const PostSelect = ({FetchPostList,...props})=>{
|
|
139
|
+
return <TreeSelect {...props} title={"postName"} request={FetchPostList} />
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export { WithSingleSelect, WithMultipleSelect, MultipleSelect, SingleSelect, Select,UserSelect,DeptSelect,PostSelect };
|
|
@@ -32,7 +32,7 @@ function batchElements(elements, groupSize) {
|
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
}
|
|
35
|
-
|
|
35
|
+
|
|
36
36
|
if (tempArray.length > 0) {
|
|
37
37
|
fillWithReactElement(groupSize, tempArray);
|
|
38
38
|
groupedElements.push(tempArray);
|
|
@@ -42,7 +42,7 @@ function batchElements(elements, groupSize) {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
|
|
45
|
-
const FormContainer = forwardRef(({ cols = 1, children
|
|
45
|
+
const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) => {
|
|
46
46
|
const [form] = Form.useForm();
|
|
47
47
|
const [formContent, setFormContent] = React.useState(null);
|
|
48
48
|
const dependencyMap = React.useRef(null);
|
|
@@ -62,14 +62,14 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
62
62
|
function traverse(currentNode) {
|
|
63
63
|
var componentName = currentNode.type?.displayName || currentNode.props?._componentName;
|
|
64
64
|
const { props } = currentNode;
|
|
65
|
-
if (componentName && (componentName.startsWith('Field.') || componentName.startsWith('Layout.')
|
|
65
|
+
if (componentName && (componentName.startsWith('Field.') || componentName.startsWith('Layout.'))) {
|
|
66
66
|
fields.push(currentNode);
|
|
67
67
|
}
|
|
68
|
-
|
|
69
|
-
if (props?.children){
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
}
|
|
68
|
+
|
|
69
|
+
if (props?.children) {
|
|
70
|
+
let children = React.Children.toArray(props?.children)
|
|
71
|
+
children.forEach(child => traverse(child));
|
|
72
|
+
}
|
|
73
73
|
}
|
|
74
74
|
dependencyMap.current = new Map();
|
|
75
75
|
const childrenArray = React.Children.toArray(children);
|
|
@@ -81,7 +81,7 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
81
81
|
const { componentId, __id, ...props } = child?.props;
|
|
82
82
|
const identifier = componentId || __id;
|
|
83
83
|
dependencyMap.current.set(identifier, {
|
|
84
|
-
children: childrenArray.filter(item => item.props.withId === identifier || item.props.withIds?.some(item=>{
|
|
84
|
+
children: childrenArray.filter(item => item.props.withId === identifier || item.props.withIds?.some(item => {
|
|
85
85
|
return identifier == item || item.startsWith(identifier + '.')
|
|
86
86
|
})),
|
|
87
87
|
show: true,
|
|
@@ -183,7 +183,7 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
183
183
|
return result
|
|
184
184
|
})
|
|
185
185
|
}
|
|
186
|
-
console.log("formula",formula)
|
|
186
|
+
console.log("formula", formula)
|
|
187
187
|
if (formula && formula.length > 0) {
|
|
188
188
|
const childIdentifier = child.props.componentId || child.props.__id;
|
|
189
189
|
form.setFieldValue(childIdentifier, evalFormula(formula))
|
|
@@ -197,7 +197,7 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
197
197
|
if (id.indexOf(".") >= 0) {
|
|
198
198
|
const [parentKey, childKey] = id.split(".");
|
|
199
199
|
const parentValue = fieldValues?.[parentKey] || [];
|
|
200
|
-
if (Array.isArray(parentValue))
|
|
200
|
+
if (Array.isArray(parentValue))
|
|
201
201
|
result = parentValue.map(item => {
|
|
202
202
|
return item?.[childKey] || ""
|
|
203
203
|
})
|
|
@@ -249,10 +249,16 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
249
249
|
const identifier = componentId || __id;
|
|
250
250
|
const isLayoutComponent = componentName && componentName.startsWith('Layout.');
|
|
251
251
|
const rules = []
|
|
252
|
-
if (props.isRequired)
|
|
252
|
+
if (props.isRequired)
|
|
253
253
|
rules.push({ required: true, message: `${props.label}必须填写` });
|
|
254
|
-
if (props.rules)
|
|
255
|
-
|
|
254
|
+
if (props.rules)
|
|
255
|
+
if (Array.isArray(props.rules)) {
|
|
256
|
+
const pattern = props.rules.join("|")
|
|
257
|
+
rules.push({ pattern: new RegExp(pattern), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
|
|
258
|
+
}
|
|
259
|
+
else {
|
|
260
|
+
rules.push({ pattern: new RegExp(props.rules), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
|
|
261
|
+
}
|
|
256
262
|
return (
|
|
257
263
|
<Col key={identifier || `col-${index}`} span={isLayoutComponent ? 24 : 24 / group.length} style={{ marginBottom: 0 }}>
|
|
258
264
|
{isLayoutComponent ? (
|
|
@@ -275,7 +281,7 @@ const FormContainer = forwardRef(({ cols = 1, children , mode="view" }, ref) =>
|
|
|
275
281
|
};
|
|
276
282
|
|
|
277
283
|
return (
|
|
278
|
-
<Form form={form} className={"form-container fp-0 fw-full fh-full box-border" + (mode == "desgin" ?" fp-6":"")} onFieldsChange={handleFieldsChange}>
|
|
284
|
+
<Form form={form} className={"form-container fp-0 fw-full fh-full box-border" + (mode == "desgin" ? " fp-6" : "")} onFieldsChange={handleFieldsChange}>
|
|
279
285
|
{formContent}
|
|
280
286
|
</Form>
|
|
281
287
|
);
|
package/src/components/index.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Input, TextArea, Password, Search ,CodeMachine, Number, NumberRange} from './field/input/index.jsx'
|
|
2
2
|
import '../App.css';
|
|
3
|
-
import { TreeSelect, Select, WithSingleSelect,WithMultipleSelect, SingleSelect, MultipleSelect, SearchSelect } from './field/select/index.jsx'
|
|
3
|
+
import { TreeSelect, Select, WithSingleSelect,WithMultipleSelect, SingleSelect, MultipleSelect, SearchSelect, UserSelect, DeptSelect, PostSelect } from './field/select/index.jsx'
|
|
4
4
|
import Custom from './field/custom/index.jsx'
|
|
5
5
|
import { FormContainer, FormContainerWrapper,LayoutFormRow,LayoutFormGroupTitle } from './form-container/index.jsx'
|
|
6
6
|
import { Checkbox ,CheckboxTree, CheckboxGroup } from './field/checkbox/index.jsx'
|
|
@@ -34,6 +34,9 @@ const Field = {
|
|
|
34
34
|
DatePicker,
|
|
35
35
|
Table,
|
|
36
36
|
Custom,
|
|
37
|
+
UserSelect,
|
|
38
|
+
DeptSelect,
|
|
39
|
+
PostSelect,
|
|
37
40
|
}
|
|
38
41
|
Object.keys(Field).forEach(key => {
|
|
39
42
|
Field[key].displayName = `Field.${key}`;
|