lu-lowcode-package-form 0.8.3 → 0.8.5
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 +48 -48
- package/dist/index.es.js +2057 -1996
- package/dist/style.css +1 -1
- package/package.json +1 -1
- package/src/App.jsx +8 -2
- package/src/components/field/checkbox/checkbox-tree.jsx +6 -1
- package/src/components/field/checkbox/index.jsx +29 -15
- package/src/components/field/select/index.jsx +1 -1
- package/src/components/field/select/select.jsx +36 -7
- package/src/components/field/switch/index.jsx +15 -6
- package/src/components/form-container/layout/form-group-title.jsx +1 -1
- package/src/components/index.jsx +8 -6
package/dist/style.css
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.frelative{position:relative}.fflex{display:flex}.fh-11{height:2.75rem}.fh-8{height:2rem}.fh-full{height:100%}.fmin-h-5{min-height:1.25rem}.fw-\[960px\]{width:960px}.fw-full{width:100%}.fflex-col{flex-direction:column}.fitems-center{align-items:center}.fitems-stretch{align-items:stretch}.fjustify-between{justify-content:space-between}.frounded{border-radius:.25rem}.fbg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}.fp-4{padding:1rem}.fp-6{padding:1.5rem}.fpb-10{padding-bottom:2.5rem}.ftext-sm{font-size:.875rem;line-height:1.25rem}.ftext-xs{font-size:.75rem;line-height:1rem}.ftext-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}
|
|
1
|
+
*,:before,:after{box-sizing:border-box;border-width:0;border-style:solid;border-color:#e5e7eb}:before,:after{--tw-content: ""}html,:host{line-height:1.5;-webkit-text-size-adjust:100%;-moz-tab-size:4;tab-size:4;font-family:ui-sans-serif,system-ui,sans-serif,"Apple Color Emoji","Segoe UI Emoji",Segoe UI Symbol,"Noto Color Emoji";font-feature-settings:normal;font-variation-settings:normal;-webkit-tap-highlight-color:transparent}body{margin:0;line-height:inherit}hr{height:0;color:inherit;border-top-width:1px}abbr:where([title]){-webkit-text-decoration:underline dotted;text-decoration:underline dotted}h1,h2,h3,h4,h5,h6{font-size:inherit;font-weight:inherit}a{color:inherit;text-decoration:inherit}b,strong{font-weight:bolder}code,kbd,samp,pre{font-family:ui-monospace,SFMono-Regular,Menlo,Monaco,Consolas,Liberation Mono,Courier New,monospace;font-feature-settings:normal;font-variation-settings:normal;font-size:1em}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}table{text-indent:0;border-color:inherit;border-collapse:collapse}button,input,optgroup,select,textarea{font-family:inherit;font-feature-settings:inherit;font-variation-settings:inherit;font-size:100%;font-weight:inherit;line-height:inherit;letter-spacing:inherit;color:inherit;margin:0;padding:0}button,select{text-transform:none}button,input:where([type=button]),input:where([type=reset]),input:where([type=submit]){-webkit-appearance:button;background-color:transparent;background-image:none}:-moz-focusring{outline:auto}:-moz-ui-invalid{box-shadow:none}progress{vertical-align:baseline}::-webkit-inner-spin-button,::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}summary{display:list-item}blockquote,dl,dd,h1,h2,h3,h4,h5,h6,hr,figure,p,pre{margin:0}fieldset{margin:0;padding:0}legend{padding:0}ol,ul,menu{list-style:none;margin:0;padding:0}dialog{padding:0}textarea{resize:vertical}input::placeholder,textarea::placeholder{opacity:1;color:#9ca3af}button,[role=button]{cursor:pointer}:disabled{cursor:default}img,svg,video,canvas,audio,iframe,embed,object{display:block;vertical-align:middle}img,video{max-width:100%;height:auto}[hidden]{display:none}*,:before,:after{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }::backdrop{--tw-border-spacing-x: 0;--tw-border-spacing-y: 0;--tw-translate-x: 0;--tw-translate-y: 0;--tw-rotate: 0;--tw-skew-x: 0;--tw-skew-y: 0;--tw-scale-x: 1;--tw-scale-y: 1;--tw-pan-x: ;--tw-pan-y: ;--tw-pinch-zoom: ;--tw-scroll-snap-strictness: proximity;--tw-gradient-from-position: ;--tw-gradient-via-position: ;--tw-gradient-to-position: ;--tw-ordinal: ;--tw-slashed-zero: ;--tw-numeric-figure: ;--tw-numeric-spacing: ;--tw-numeric-fraction: ;--tw-ring-inset: ;--tw-ring-offset-width: 0px;--tw-ring-offset-color: #fff;--tw-ring-color: rgb(59 130 246 / .5);--tw-ring-offset-shadow: 0 0 #0000;--tw-ring-shadow: 0 0 #0000;--tw-shadow: 0 0 #0000;--tw-shadow-colored: 0 0 #0000;--tw-blur: ;--tw-brightness: ;--tw-contrast: ;--tw-grayscale: ;--tw-hue-rotate: ;--tw-invert: ;--tw-saturate: ;--tw-sepia: ;--tw-drop-shadow: ;--tw-backdrop-blur: ;--tw-backdrop-brightness: ;--tw-backdrop-contrast: ;--tw-backdrop-grayscale: ;--tw-backdrop-hue-rotate: ;--tw-backdrop-invert: ;--tw-backdrop-opacity: ;--tw-backdrop-saturate: ;--tw-backdrop-sepia: ;--tw-contain-size: ;--tw-contain-layout: ;--tw-contain-paint: ;--tw-contain-style: }.frelative{position:relative}.fmb-5{margin-bottom:1.25rem}.fflex{display:flex}.fh-11{height:2.75rem}.fh-8{height:2rem}.fh-full{height:100%}.fmin-h-5{min-height:1.25rem}.fw-\[960px\]{width:960px}.fw-full{width:100%}.fflex-col{flex-direction:column}.fitems-center{align-items:center}.fitems-stretch{align-items:stretch}.fjustify-between{justify-content:space-between}.frounded{border-radius:.25rem}.fborder-b{border-bottom-width:1px}.fbg-slate-100{--tw-bg-opacity: 1;background-color:rgb(241 245 249 / var(--tw-bg-opacity))}.fp-4{padding:1rem}.fp-6{padding:1.5rem}.fpb-10{padding-bottom:2.5rem}.ftext-lg{font-size:1.125rem;line-height:1.75rem}.ftext-sm{font-size:.875rem;line-height:1.25rem}.ftext-xs{font-size:.75rem;line-height:1rem}.ffont-medium{font-weight:500}.ftext-gray-500{--tw-text-opacity: 1;color:rgb(107 114 128 / var(--tw-text-opacity))}
|
package/package.json
CHANGED
package/src/App.jsx
CHANGED
|
@@ -21,7 +21,7 @@ const treeData = [
|
|
|
21
21
|
|
|
22
22
|
function App() {
|
|
23
23
|
const formRef = React.createRef();
|
|
24
|
-
const [cols, setCols] = React.useState(
|
|
24
|
+
const [cols, setCols] = React.useState(3);
|
|
25
25
|
|
|
26
26
|
const getFormFields = () => {
|
|
27
27
|
console.log("formRef?.current", formRef)
|
|
@@ -30,6 +30,10 @@ function App() {
|
|
|
30
30
|
}
|
|
31
31
|
const setFormFields = () => {
|
|
32
32
|
formRef?.current?.formRef?.setFieldsValue({
|
|
33
|
+
CheckboxGroup:"[\"1\",\"2\"]",
|
|
34
|
+
select1:"1",
|
|
35
|
+
select2:"[\"1\",\"2\"]",
|
|
36
|
+
switch:"1",
|
|
33
37
|
datetime: "2021-12-12",
|
|
34
38
|
datetime2: "2021-12-12",
|
|
35
39
|
datetime3: "2021-12-12",
|
|
@@ -39,7 +43,7 @@ function App() {
|
|
|
39
43
|
})
|
|
40
44
|
}
|
|
41
45
|
const handleCols = () => {
|
|
42
|
-
setCols(cols
|
|
46
|
+
setCols(cols - 1)
|
|
43
47
|
}
|
|
44
48
|
return (
|
|
45
49
|
|
|
@@ -51,6 +55,8 @@ function App() {
|
|
|
51
55
|
<div className='fw-[960px] frounded fbg-slate-100 fflex fflex-col fitems-center fpb-10'>
|
|
52
56
|
<FormContainerWrapper cols={cols} className="" ref={formRef} >
|
|
53
57
|
<Field.Input label="分组名" __id="title" />
|
|
58
|
+
<Field.SingleSelect mode="single" label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
|
|
59
|
+
<Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
|
|
54
60
|
<Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
|
|
55
61
|
<Field.Switch label="开关" __id="switch"></Field.Switch>
|
|
56
62
|
<Field.CodeMachine label="角色编号" prompt="" __id="code" />
|
|
@@ -58,7 +58,12 @@ const CheckboxTree = ({ request, value, onChange,callError,disabledValue, addRoo
|
|
|
58
58
|
useEffect(() => {
|
|
59
59
|
console.log("CheckboxTree value ", value)
|
|
60
60
|
if ( typeof value == 'string') {
|
|
61
|
-
|
|
61
|
+
try {
|
|
62
|
+
value = JSON.parse(value)
|
|
63
|
+
onChange(value)
|
|
64
|
+
} catch (error) {
|
|
65
|
+
|
|
66
|
+
}
|
|
62
67
|
}
|
|
63
68
|
|
|
64
69
|
if(Array.isArray(value))
|
|
@@ -1,23 +1,37 @@
|
|
|
1
1
|
import { Checkbox as OriginalCheckbox } from 'antd';
|
|
2
|
-
import {BaseWrapper } from "../base.jsx"
|
|
3
|
-
import React from 'react';
|
|
2
|
+
import { BaseWrapper } from "../base.jsx"
|
|
3
|
+
import React, { useEffect , useState} from 'react';
|
|
4
4
|
|
|
5
5
|
|
|
6
|
-
export const Checkbox = (props) =>{
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
6
|
+
export const Checkbox = (props) => {
|
|
7
|
+
return (
|
|
8
|
+
<BaseWrapper {...props}>
|
|
9
|
+
<OriginalCheckbox {...props} />
|
|
10
|
+
</BaseWrapper>
|
|
11
|
+
);
|
|
12
12
|
}
|
|
13
13
|
|
|
14
|
-
export const CheckboxGroup = (props) => {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
14
|
+
export const CheckboxGroup = ({value, onChange,...props}) => {
|
|
15
|
+
const [nValue, setNValue] = useState([])
|
|
16
|
+
|
|
17
|
+
useEffect(() => {
|
|
18
|
+
if (typeof value === "string") {
|
|
19
|
+
try {
|
|
20
|
+
value = JSON.parse(value)
|
|
21
|
+
onChange(value)
|
|
22
|
+
} catch (error) {
|
|
23
|
+
|
|
24
|
+
}
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
setNValue(value)
|
|
28
|
+
}, [value])
|
|
29
|
+
return (
|
|
30
|
+
<BaseWrapper {...props}>
|
|
31
|
+
<OriginalCheckbox.Group {...props} value={nValue} />
|
|
32
|
+
</BaseWrapper>
|
|
33
|
+
);
|
|
20
34
|
}
|
|
21
35
|
|
|
22
36
|
|
|
23
|
-
export {default as CheckboxTree } from './checkbox-tree.jsx';
|
|
37
|
+
export { default as CheckboxTree } from './checkbox-tree.jsx';
|
|
@@ -36,6 +36,32 @@ const Select = ({ request, option_label = "label", option_value = "id", disabled
|
|
|
36
36
|
)
|
|
37
37
|
}
|
|
38
38
|
|
|
39
|
+
const SingleSelect = ({ ...props }) => {
|
|
40
|
+
return (
|
|
41
|
+
<Select {...props} mode="single" />
|
|
42
|
+
)
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
const MultipleSelect = ({ onChange, value, ...props }) => {
|
|
46
|
+
const [nValue, setNValue] = React.useState([])
|
|
47
|
+
|
|
48
|
+
useEffect(()=>{
|
|
49
|
+
if (typeof value === "string") {
|
|
50
|
+
try {
|
|
51
|
+
value = JSON.parse(value)
|
|
52
|
+
onChange(value)
|
|
53
|
+
} catch (error) {
|
|
54
|
+
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
setNValue(value)
|
|
59
|
+
},[value])
|
|
60
|
+
|
|
61
|
+
return (
|
|
62
|
+
<Select {...props} onChange={onChange} mode="multiple" value={nValue} />
|
|
63
|
+
)
|
|
64
|
+
}
|
|
39
65
|
/**
|
|
40
66
|
* 关联单选组件
|
|
41
67
|
* @param {*}
|
|
@@ -45,19 +71,20 @@ const WithSingleSelect = ({ onChange, value, ...props }) => {
|
|
|
45
71
|
const [nValue, setNValue] = React.useState("")
|
|
46
72
|
|
|
47
73
|
React.useEffect(() => {
|
|
48
|
-
if(value) {
|
|
74
|
+
if (value && typeof value === "string") {
|
|
49
75
|
try {
|
|
50
76
|
value = JSON.parse(value)
|
|
51
|
-
|
|
77
|
+
onChange(value)
|
|
52
78
|
} catch (error) {
|
|
53
79
|
|
|
54
80
|
}
|
|
55
81
|
}
|
|
82
|
+
if(value) setNValue(value)
|
|
56
83
|
}, [value])
|
|
57
84
|
|
|
58
85
|
|
|
59
86
|
const onWithSelectChange = (_value, _option) => {
|
|
60
|
-
onChange && typeof onChange == "function" && onChange(
|
|
87
|
+
onChange && typeof onChange == "function" && onChange(_option)
|
|
61
88
|
setNValue(_option.label)
|
|
62
89
|
}
|
|
63
90
|
return (
|
|
@@ -75,18 +102,20 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
|
|
|
75
102
|
|
|
76
103
|
|
|
77
104
|
React.useEffect(() => {
|
|
78
|
-
if (value) {
|
|
105
|
+
if (value && typeof value === "string") {
|
|
79
106
|
try {
|
|
80
107
|
value = JSON.parse(value)
|
|
81
|
-
|
|
108
|
+
onChange(value)
|
|
82
109
|
} catch (error) {
|
|
83
110
|
|
|
84
111
|
}
|
|
85
112
|
}
|
|
113
|
+
|
|
114
|
+
if (Array.isArray(value)) setNValue(value)
|
|
86
115
|
}, [value])
|
|
87
116
|
|
|
88
117
|
const onWithSelectChange = (_value, _option) => {
|
|
89
|
-
onChange && typeof onChange == "function" && onChange(
|
|
118
|
+
onChange && typeof onChange == "function" && onChange(_option)
|
|
90
119
|
const selectLabels = _option.map(item => item.label);
|
|
91
120
|
setNValue(_option)
|
|
92
121
|
}
|
|
@@ -95,4 +124,4 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
|
|
|
95
124
|
)
|
|
96
125
|
}
|
|
97
126
|
|
|
98
|
-
export { WithSingleSelect, WithMultipleSelect, Select };
|
|
127
|
+
export { WithSingleSelect, WithMultipleSelect, MultipleSelect, SingleSelect, Select };
|
|
@@ -1,15 +1,24 @@
|
|
|
1
1
|
import React, { useEffect } from 'react';
|
|
2
2
|
import { Switch as OriginalSwitch } from 'antd';
|
|
3
3
|
import { BaseWrapper } from "../base.jsx"
|
|
4
|
-
const Switch = ({
|
|
5
|
-
defaultValue = defaultValue || false;
|
|
6
|
-
useEffect(() => {
|
|
7
|
-
props.onChange(defaultValue);
|
|
4
|
+
const Switch = ({value, ...props}) => {
|
|
8
5
|
|
|
9
|
-
|
|
6
|
+
const [nValue, setNValue] = React.useState(false)
|
|
7
|
+
useEffect(()=>{
|
|
8
|
+
let tem_value = false
|
|
9
|
+
if( typeof value === "boolean" )
|
|
10
|
+
tem_value = value
|
|
11
|
+
else if (typeof value === "string")
|
|
12
|
+
tem_value =value == "1" || value == "true"
|
|
13
|
+
else if (typeof value == "number")
|
|
14
|
+
tem_value = value == 1
|
|
15
|
+
setNValue(tem_value)
|
|
16
|
+
// 格式化form表单获取到的值
|
|
17
|
+
props?.onChange(tem_value)
|
|
18
|
+
},[value])
|
|
10
19
|
return (
|
|
11
20
|
<BaseWrapper {...props}>
|
|
12
|
-
<OriginalSwitch {...props} />
|
|
21
|
+
<OriginalSwitch {...props} value={nValue} />
|
|
13
22
|
</BaseWrapper>
|
|
14
23
|
);
|
|
15
24
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
const FormGroupTitle = ({ title }) => {
|
|
2
|
-
return (title? <div className="fh-11
|
|
2
|
+
return (title? <div className="fh-11 fborder-b fflex fitems-center ftext-lg ffont-medium fmb-5 ">{title}</div>: null )
|
|
3
3
|
};
|
|
4
4
|
|
|
5
5
|
export default FormGroupTitle;
|
package/src/components/index.jsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Input, TextArea, Password, Search ,CodeMachine} from './field/input/index.jsx'
|
|
2
2
|
import '../App.css';
|
|
3
|
-
import { TreeSelect, Select, WithSingleSelect,WithMultipleSelect } from './field/select/index.jsx'
|
|
3
|
+
import { TreeSelect, Select, WithSingleSelect,WithMultipleSelect, SingleSelect, MultipleSelect } 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'
|
|
@@ -17,6 +17,8 @@ const Field = {
|
|
|
17
17
|
Select,
|
|
18
18
|
WithSingleSelect,
|
|
19
19
|
WithMultipleSelect,
|
|
20
|
+
SingleSelect,
|
|
21
|
+
MultipleSelect,
|
|
20
22
|
CodeMachine,
|
|
21
23
|
Checkbox,
|
|
22
24
|
CheckboxTree,
|
|
@@ -33,8 +35,8 @@ const Layout = {
|
|
|
33
35
|
FormGroupTitle: LayoutFormGroupTitle
|
|
34
36
|
}
|
|
35
37
|
export { FormContainer, Field ,FormContainerWrapper,Layout }
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
38
|
+
import { default as OptionSetter} from './setter/optionsetter'
|
|
39
|
+
const Setter = {
|
|
40
|
+
OptionSetter
|
|
41
|
+
}
|
|
42
|
+
export { Setter }
|