lu-lowcode-package-form 0.10.36 → 0.10.37

Sign up to get free protection for your applications and to get access to all the features.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.10.36",
3
+ "version": "0.10.37",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@dnd-kit/core": "^6.1.0",
package/src/App.jsx CHANGED
@@ -1,4 +1,4 @@
1
- import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang, EditorWang2, EditorWang3, WangEditor, WangEditorNext } from './components';
1
+ import { FormContainer, Field, FormContainerWrapper, Layout, Setter, EditorQuill, EditorWang, EditorWang2, EditorWang3, WangEditor, WangEditorNext, Show } from './components';
2
2
  import './App.css';
3
3
  import { Button, Input, Select } from 'antd';
4
4
  import React, { useEffect, useState } from 'react';
@@ -179,7 +179,7 @@ function App() {
179
179
 
180
180
  <FormContainerWrapper cols={cols} className="" ref={formRef} >
181
181
  <Layout.FormRow layout={'1'}>
182
- <Field.WithTable label="测试关联子表" __id="withtable1"
182
+ <Show.WithTable label="测试关联子表" __id="withtable1"
183
183
  filterRules={[
184
184
  {
185
185
  "value": {
@@ -489,7 +489,7 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
489
489
  let childComponent
490
490
  if (isTable || isLayoutComponent)
491
491
  childComponent = React.cloneElement(child, { onTableAddRow: handleTableAddRow, onTableRemoveRow: handleTableRemoveRow, form: form, fieldName: identifier, onCustomChange,initializeFormRender,mode })
492
- else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Field.WithTable") {
492
+ else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Show.WithTable") {
493
493
  childComponent = <Form.Item
494
494
  hidden={hidden}
495
495
  style={{ margin: 0 }}
@@ -519,13 +519,14 @@ const FormContainer = forwardRef(({ cols = 1, children, mode = "view" }, ref) =>
519
519
  >
520
520
  {({getFieldsValue}) => {
521
521
  const fieldsValue = getFieldsValue();
522
- return <Form.Item
522
+ let element = React.cloneElement(child, { onTableAddRow: handleTableAddRow, onTableRemoveRow: handleTableRemoveRow, form: form, fieldName: identifier, onCustomChange, fieldsValue,initializeFormRender })
523
+ return componentName === "show.WithTable" ? <>{element}</> : <Form.Item
523
524
  style={{ marginBottom: 0 }}
524
525
  label=""
525
526
  name={identifier}
526
527
  rules={rules}
527
528
  >
528
- {React.cloneElement(child, { onTableAddRow: handleTableAddRow, onTableRemoveRow: handleTableRemoveRow, form: form, fieldName: identifier, onCustomChange, fieldsValue,initializeFormRender })}
529
+ {element}
529
530
  </Form.Item>
530
531
  }}
531
532
  </Form.Item>
@@ -41,7 +41,7 @@ const LayoutFormRow = ({ children, layout, onTableAddRow, onTableRemoveRow, form
41
41
  let childComponent = null
42
42
  if (componentName == 'Field.Table')
43
43
  childComponent = React.cloneElement(child, { onTableAddRow: onTableAddRow, onTableRemoveRow: onTableRemoveRow, form: form, fieldName: name, initializeFormRender, mode })
44
- else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Field.WithTable") {
44
+ else if (componentName === "Field.WithSingleSelect" || componentName === "Field.WithMultipleSelect" || componentName === "Show.WithTable") {
45
45
  childComponent = <Form.Item
46
46
  hidden={hidden}
47
47
  style={{ margin: 0 }}
@@ -68,13 +68,14 @@ const LayoutFormRow = ({ children, layout, onTableAddRow, onTableRemoveRow, form
68
68
  >
69
69
  {({ getFieldsValue }) => {
70
70
  const fieldsValue = getFieldsValue();
71
- return <Form.Item
71
+ let element = React.cloneElement(child, { onTableAddRow: onTableAddRow, onTableRemoveRow: onTableRemoveRow, form: form, fieldName: identifier, onCustomChange, fieldsValue, initializeFormRender })
72
+ return componentName === "Show.WithTable" ? <>{element}</> : <Form.Item
72
73
  style={{ marginBottom: 0 }}
73
74
  label=""
74
75
  name={identifier}
75
76
  rules={rules}
76
77
  >
77
- {React.cloneElement(child, { onTableAddRow: onTableAddRow, onTableRemoveRow: onTableRemoveRow, form: form, fieldName: identifier, onCustomChange, fieldsValue, initializeFormRender })}
78
+ {element}
78
79
  </Form.Item>
79
80
  }}
80
81
  </Form.Item>
@@ -99,38 +100,6 @@ const LayoutFormRow = ({ children, layout, onTableAddRow, onTableRemoveRow, form
99
100
  );
100
101
 
101
102
 
102
- if (name) {
103
- const rules = []
104
- if (props.isRequired)
105
- rules.push({ required: true, message: `${props.label}必须填写` });
106
- if (props.rules)
107
- if (Array.isArray(props.rules)) {
108
- const pattern = props.rules.join("|")
109
- rules.push({ pattern: new RegExp(pattern), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
110
- }
111
- else {
112
- rules.push({ pattern: new RegExp(props.rules), message: props.rulesFailMessage ? props.rulesFailMessage : `${props.label}格式错误` })
113
- }
114
- return (
115
- colSpans?.[index] && <Col span={colSpans[index]} key={index}>
116
- <Form.Item
117
- style={{ marginBottom: 0 }}
118
- label=""
119
- key={`${name}-form-item`}
120
- name={name}
121
- rules={rules}
122
- >
123
- {childComponent}
124
- </Form.Item>
125
- </Col>
126
- );
127
- } else {
128
- return (
129
- colSpans?.[index] && <Col span={colSpans[index]} key={index}>
130
- {childComponent}
131
- </Col>
132
- );
133
- }
134
103
  });
135
104
  }, [children, colSpans]);
136
105
 
@@ -36,8 +36,7 @@ const Field = {
36
36
  Custom,
37
37
  UserSelect,
38
38
  DeptSelect,
39
- PostSelect,
40
- WithTable
39
+ PostSelect
41
40
  }
42
41
  Object.keys(Field).forEach(key => {
43
42
  Field[key].displayName = `Field.${key}`;
@@ -50,10 +49,19 @@ const Layout = {
50
49
  FormGroupTitle: LayoutFormGroupTitle,
51
50
  TableCol
52
51
  }
52
+
53
53
  Object.keys(Layout).forEach(key => {
54
54
  Layout[key].displayName = `Layout.${key}`;
55
55
  });
56
- export { FormContainer, Field ,FormContainerWrapper,Layout }
56
+ // 纯显示类型的组件
57
+ const Show = {
58
+ WithTable
59
+ }
60
+ Object.keys(Show).forEach(key => {
61
+ Show[key].displayName = `Show.${key}`;
62
+ });
63
+
64
+ export { FormContainer, Field ,FormContainerWrapper,Layout,Show }
57
65
  import { default as OptionSetter} from './setter/optionsetter'
58
66
  const Setter = {
59
67
  OptionSetter