lu-lowcode-package-form 0.8.2 → 0.8.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.
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-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}.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))}
package/package.json CHANGED
@@ -1,12 +1,13 @@
1
1
  {
2
2
  "name": "lu-lowcode-package-form",
3
- "version": "0.8.2",
3
+ "version": "0.8.4",
4
4
  "dependencies": {
5
5
  "@ant-design/icons": "^4.8.1",
6
6
  "@testing-library/jest-dom": "^5.17.0",
7
7
  "@testing-library/react": "^13.4.0",
8
8
  "@testing-library/user-event": "^13.5.0",
9
9
  "antd": "^5.13.2",
10
+ "dayjs": "^1.11.11",
10
11
  "postcss-modules": "^6.0.0",
11
12
  "web-vitals": "^2.1.4"
12
13
  },
package/src/App.jsx CHANGED
@@ -1,63 +1,91 @@
1
- import { FormContainer, Field,FormContainerWrapper , Layout } from './components';
1
+ import { FormContainer, Field, FormContainerWrapper, Layout, Setter } from './components';
2
2
  import './App.css';
3
3
  import { Button } from 'antd';
4
4
  import React from 'react';
5
5
 
6
6
  const treeData = [
7
- {
8
- title: '0-1',
9
- key: '0-1',
10
- children: [
11
- { title: '0-1-0-0', key: '0-1-0-0' },
12
- { title: '0-1-0-1', key: '0-1-0-1' },
13
- { title: '0-1-0-2', key: '0-1-0-2' },
14
- ],
15
- },
16
- {
17
- title: '0-2',
18
- key: '0-2',
19
- },
7
+ {
8
+ title: '0-1',
9
+ key: '0-1',
10
+ children: [
11
+ { title: '0-1-0-0', key: '0-1-0-0' },
12
+ { title: '0-1-0-1', key: '0-1-0-1' },
13
+ { title: '0-1-0-2', key: '0-1-0-2' },
14
+ ],
15
+ },
16
+ {
17
+ title: '0-2',
18
+ key: '0-2',
19
+ },
20
20
  ];
21
21
 
22
22
  function App() {
23
23
  const formRef = React.createRef();
24
- const [cols, setCols] = React.useState(1);
24
+ const [cols, setCols] = React.useState(3);
25
25
 
26
26
  const getFormFields = () => {
27
- console.log("formRef?.current",formRef)
27
+ console.log("formRef?.current", formRef)
28
28
  const formData = formRef?.current?.formRef?.getFieldsValue();
29
- console.log("formData",formData);
29
+ console.log("formData", formData);
30
30
  }
31
31
  const setFormFields = () => {
32
32
  formRef?.current?.formRef?.setFieldsValue({
33
- remark11:"{\"label\": \"解决方案部1112\", \"value\": 11}",
34
- remark12:"[{\"label\": \"水电费\", \"value\": 2}]",
33
+ select1:"1",
34
+ select2:"[\"1\",\"2\"]",
35
+ switch:"1",
36
+ datetime: "2021-12-12",
37
+ datetime2: "2021-12-12",
38
+ datetime3: "2021-12-12",
39
+ datetime4: "2021-12-12",
40
+ remark11: "{\"label\": \"解决方案部1112\", \"value\": 11}",
41
+ remark12: "[{\"label\": \"水电费\", \"value\": 2}]",
35
42
  })
36
43
  }
37
44
  const handleCols = () => {
38
- setCols(cols + 1)
45
+ setCols(cols - 1)
39
46
  }
40
47
  return (
41
48
 
42
49
  <div className="App fflex fflex-col fitems-center">
50
+
51
+ <div className='fw-full fp-4'>
52
+ <Setter.OptionSetter />
53
+ </div>
43
54
  <div className='fw-[960px] frounded fbg-slate-100 fflex fflex-col fitems-center fpb-10'>
44
55
  <FormContainerWrapper cols={cols} className="" ref={formRef} >
45
56
  <Field.Input label="分组名" __id="title" />
57
+ <Field.SingleSelect mode="single" label="测试单选" __id="select1" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.SingleSelect>
58
+ <Field.MultipleSelect mode="multiple" label="测多选" __id="select2" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]}></Field.MultipleSelect>
46
59
  <Field.TreeSelect label="分组名" __id="title11"></Field.TreeSelect>
60
+ <Field.Switch label="开关" __id="switch"></Field.Switch>
47
61
  <Field.CodeMachine label="角色编号" prompt="" __id="code" />
62
+ <Field.DatePicker label="日期时间" prompt="" datetype="month" value='2022-10-22' __id="datetime" />
63
+ <Field.DatePicker label="日期时间" prompt="" datetype="date" value='2022-10-22' __id="datetime2" />
64
+ <Field.DatePicker label="日期时间" prompt="" datetype="datetime" value={'2022-10-22'} __id="datetime3" />
65
+ <Field.DatePicker label="年" prompt="" datetype="year" value={'2022-10-22'} __id="datetime4" />
48
66
  <Field.Input label="角色名称" __id="name" />
49
67
  <Layout.FormRow _componentName="Layout.FormRow" layout={'1,1,1'}>
50
68
  <Field.Input label="角色名称布局" __id="name1" />
51
69
  <Field.Input label="角色名称布局2" __id="name2" />
52
70
  <Field.Input label="角色名称布局3" __id="name3" />
53
- </Layout.FormRow>
71
+ </Layout.FormRow>
54
72
  <Field.CheckboxTree label="角色权限" __id="permissions" addRoot={false} treeData={treeData} />
55
- <Layout.FormGroupTitle _componentName="Layout.FormGroupTitle" title={"关联信息"}/>
73
+ <Layout.FormGroupTitle _componentName="Layout.FormGroupTitle" title={"关联信息"} />
56
74
  <Field.WithSingleSelect label="测试关联单选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark11" />
57
75
  <Field.WithMultipleSelect label="测试关联多选" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} __id="remark12" />
58
76
  <Layout.FormRow _componentName="Layout.FormRow"> <Field.TextArea label="备注" __id="remark" /></Layout.FormRow>
59
-
77
+
78
+ <Layout.FormRow _componentName="Layout.FormRow" layout={'1'}>
79
+ <Field.RadioGroup _componentName="Field.RadioGroup" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="单选框" __id="radio" ></Field.RadioGroup>
80
+ </Layout.FormRow>
81
+ <Layout.FormRow _componentName="Layout.FormRow" layout={'1'}>
82
+ <Field.CheckboxGroup _componentName="Field.CheckboxGroup" options={[{ label: '选项1', value: '1' }, { label: '选项2', value: '2' }]} label="多选框" __id="CheckboxGroup" ></Field.CheckboxGroup>
83
+ </Layout.FormRow>
84
+ <Field.UploadFile _componentName="Field.UploadFile" label="上传文件" __id="UploadFile" ></Field.UploadFile>
85
+ <Field.UploadImage _componentName="Field.UploadImage" label="上传图片" __id="UploadImage" ></Field.UploadImage>
86
+
60
87
  </FormContainerWrapper>
88
+
61
89
  <Button type="primary" onClick={getFormFields}>GetValues</Button>
62
90
  <Button type="primary" onClick={setFormFields}>SetValues</Button>
63
91
  <Button type="primary" onClick={handleCols}>UpdateCol</Button>
@@ -69,4 +97,4 @@ function App() {
69
97
 
70
98
  export default App;
71
99
 
72
- export {FormContainer, Field ,FormContainerWrapper} from './components'
100
+ export { FormContainer, Field, FormContainerWrapper } from './components'
@@ -11,4 +11,13 @@ export const Checkbox = (props) =>{
11
11
  );
12
12
  }
13
13
 
14
+ export const CheckboxGroup = (props) => {
15
+ return (
16
+ <BaseWrapper {...props}>
17
+ <OriginalCheckbox.Group {...props} />
18
+ </BaseWrapper>
19
+ );
20
+ }
21
+
22
+
14
23
  export {default as CheckboxTree } from './checkbox-tree.jsx';
@@ -0,0 +1,64 @@
1
+ import React, { useEffect, useState } from 'react';
2
+ import { DatePicker as OriginalDatePicker, Button } from 'antd';
3
+ import { BaseWrapper } from "../base.jsx"
4
+ import dayjs from 'dayjs';
5
+ const DatePicker = ({ datetype, value, onChange, ...props }) => {
6
+ datetype = datetype || "date"
7
+ const [picker, setPicker] = useState(props?.picker)
8
+ const [format, setFormat] = useState(props?.format)
9
+ const [nValue, setNValue] = useState(null)
10
+ const [showTime, setShowTime] = useState(false)
11
+ const [needConfirm, setNeedConfirm] = useState(false)
12
+ useEffect(() => {
13
+ if (value) {
14
+ const format_date = dayjs(value)
15
+ setNValue(format_date)
16
+ }
17
+ }, [value, format, picker])
18
+
19
+ const handleChange = (value, dateString) => {
20
+ onChange(dateString)
21
+ }
22
+
23
+ useEffect(() => {
24
+ setPicker("date")
25
+ setShowTime(false)
26
+ switch (datetype) {
27
+ case "date":
28
+ setPicker("date")
29
+ setFormat("YYYY-MM-DD")
30
+ setNeedConfirm(false)
31
+ break;
32
+ case "datetime":
33
+ setShowTime(true)
34
+ setPicker("datetime")
35
+ setFormat("YYYY-MM-DD HH:mm:ss")
36
+ setNeedConfirm(true)
37
+ break;
38
+ // case "week":
39
+ // setPicker("week")
40
+ // setNeedConfirm(false)
41
+ // break;
42
+ case "month":
43
+ setPicker("month")
44
+ setNeedConfirm(false)
45
+ break;
46
+ // case "quarter":
47
+ // setPicker("quarter")
48
+ // setNeedConfirm(false)
49
+ // break;
50
+ case "year":
51
+ setPicker("year")
52
+ setNeedConfirm(false)
53
+ break;
54
+ }
55
+ }, [datetype])
56
+ return (
57
+ <BaseWrapper {...props}>
58
+ <OriginalDatePicker {...props} picker={picker} format={format} style={{ width: '100%' }} onChange={handleChange} value={nValue} showTime={showTime} needConfirm={needConfirm} />
59
+ </BaseWrapper>
60
+ );
61
+ }
62
+
63
+ export default DatePicker
64
+
@@ -1,4 +1,4 @@
1
1
  export { default as TreeSelect } from './tree-select.jsx';
2
- export { Select, WithSingleSelect,WithMultipleSelect } from './select.jsx';
2
+ export { Select, WithSingleSelect,WithMultipleSelect , MultipleSelect, SingleSelect} from './select.jsx';
3
3
 
4
4
 
@@ -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 {*}
@@ -95,4 +121,4 @@ const WithMultipleSelect = ({ onChange, value, ...props }) => {
95
121
  )
96
122
  }
97
123
 
98
- export { WithSingleSelect, WithMultipleSelect, Select };
124
+ export { WithSingleSelect, WithMultipleSelect, MultipleSelect, SingleSelect, Select };
@@ -0,0 +1,27 @@
1
+ import React, { useEffect } from 'react';
2
+ import { Switch as OriginalSwitch } from 'antd';
3
+ import { BaseWrapper } from "../base.jsx"
4
+ const Switch = ({value, ...props}) => {
5
+
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])
19
+ return (
20
+ <BaseWrapper {...props}>
21
+ <OriginalSwitch {...props} value={nValue} />
22
+ </BaseWrapper>
23
+ );
24
+ }
25
+
26
+ export default Switch
27
+
@@ -0,0 +1,2 @@
1
+ export {default as UploadFile } from './upload-file'
2
+ export {default as UploadImage } from './upload-image'
@@ -0,0 +1,37 @@
1
+ import { Upload as OriginalUpload, Button } from "antd";
2
+
3
+ import { BaseWrapper } from "../base.jsx"
4
+ import { UploadOutlined } from "@ant-design/icons";
5
+ import React, { useEffect, useState } from "react";
6
+
7
+ const UploadFile = ({value, maxLen,onChange,...props}) => {
8
+ useEffect(() => {
9
+ if (value) setFileList(value)
10
+ }, [value]);
11
+ maxLen = maxLen || 9;
12
+ const [fileList, setFileList] = React.useState([]);
13
+ const handleChange = ({ fileList: newFileList }) => {
14
+ console.log(newFileList)
15
+ setFileList(newFileList);
16
+ onChange(fileList.map((file) => {
17
+ return {
18
+ uid: file.uid,
19
+ name: file.name,
20
+ status: file.status,
21
+ url: file.url || ""
22
+ }
23
+ }))
24
+ }
25
+ return (
26
+ <BaseWrapper {...props}>
27
+ <OriginalUpload {...props}
28
+ listType="text"
29
+ onChange={handleChange}
30
+ defaultFileList={fileList}>
31
+ <Button icon={<UploadOutlined />}>点击上传文件</Button>
32
+ </OriginalUpload>
33
+ </BaseWrapper>
34
+ );
35
+ }
36
+
37
+ export default UploadFile;
@@ -0,0 +1,66 @@
1
+ import { Upload as OriginalUpload, Button } from "antd";
2
+
3
+ import { BaseWrapper } from "../base.jsx"
4
+ import { PlusOutlined } from "@ant-design/icons";
5
+ import React,{ useEffect, useState} from "react";
6
+
7
+ const UploadImage = ({ maxLen, value, onChange, ...props }) => {
8
+ useEffect(() => {
9
+ if (value) setFileList(value)
10
+ }, [value]);
11
+ maxLen = maxLen || 9;
12
+ const [fileList, setFileList] = React.useState([]);
13
+ const [previewImage, setPreviewImage] = useState('');
14
+ const [previewOpen, setPreviewOpen] = useState(false);
15
+ const handlePreview = async (file) => {
16
+ if (!file.url && !file.preview) {
17
+ file.preview = await getBase64(file.originFileObj);
18
+ }
19
+
20
+ setPreviewImage(file.url || (file.preview));
21
+ setPreviewOpen(true);
22
+ };
23
+ const uploadButton = (
24
+ <button style={{ border: 0, background: 'none' }} type="button">
25
+ <PlusOutlined />
26
+ <div style={{ marginTop: 8 }}>点击上传</div>
27
+ </button>
28
+ );
29
+ const handleChange= ({ fileList: newFileList }) => {
30
+ setFileList(newFileList);
31
+ onChange(fileList.map((file) => {
32
+ return {
33
+ uid:file.uid,
34
+ name:file.name,
35
+ status:file.status,
36
+ url:file.url||""
37
+ }
38
+ }))
39
+ }
40
+ return (
41
+ <BaseWrapper {...props}>
42
+ <OriginalUpload
43
+ {...props}
44
+ listType="picture-card"
45
+ fileList={fileList}
46
+ onPreview={handlePreview}
47
+ onChange={handleChange}
48
+ >
49
+ {fileList.length >= 8 ? null : uploadButton}
50
+ </OriginalUpload>
51
+ {previewImage && (
52
+ <Image
53
+ wrapperStyle={{ display: 'none' }}
54
+ preview={{
55
+ visible: previewOpen,
56
+ onVisibleChange: (visible) => setPreviewOpen(visible),
57
+ afterOpenChange: (visible) => !visible && setPreviewImage(''),
58
+ }}
59
+ src={previewImage}
60
+ />
61
+ )}
62
+ </BaseWrapper>
63
+ );
64
+ }
65
+
66
+ export default UploadImage;
@@ -1,10 +1,13 @@
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
- import { Checkbox ,CheckboxTree } from './field/checkbox/index.jsx'
7
- import { default as RadioGrop } from './field/radio/index.jsx'
6
+ import { Checkbox ,CheckboxTree, CheckboxGroup } from './field/checkbox/index.jsx'
7
+ import { default as RadioGroup } from './field/radio/index.jsx'
8
+ import { UploadFile,UploadImage } from './field/upload'
9
+ import {default as Switch} from './field/switch'
10
+ import {default as DatePicker } from './field/date-picker'
8
11
  const Field = {
9
12
  Input,
10
13
  TextArea,
@@ -14,14 +17,26 @@ const Field = {
14
17
  Select,
15
18
  WithSingleSelect,
16
19
  WithMultipleSelect,
20
+ SingleSelect,
21
+ MultipleSelect,
17
22
  CodeMachine,
18
23
  Checkbox,
19
24
  CheckboxTree,
20
- RadioGrop,
25
+ CheckboxGroup,
26
+ RadioGroup,
27
+ UploadFile,
28
+ UploadImage,
29
+ Switch,
30
+ DatePicker,
21
31
  Custom,
22
32
  }
23
33
  const Layout = {
24
34
  FormRow: LayoutFormRow,
25
35
  FormGroupTitle: LayoutFormGroupTitle
26
36
  }
27
- export { FormContainer, Field ,FormContainerWrapper,Layout }
37
+ export { FormContainer, Field ,FormContainerWrapper,Layout }
38
+ import { default as OptionSetter} from './setter/optionsetter'
39
+ const Setter = {
40
+ OptionSetter
41
+ }
42
+ export { Setter }
@@ -0,0 +1,9 @@
1
+ import React, { useEffect } from 'react';
2
+
3
+ const OptionSetter = ({value, onChange, ...props}) => {
4
+ return (
5
+ <div>sdfsdfsdf</div>
6
+ )
7
+ }
8
+
9
+ export default OptionSetter