@hw-component/form 1.6.2 → 1.6.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.
Files changed (33) hide show
  1. package/.eslintcache +1 -1
  2. package/es/Select/hooks/changeHooks.js +34 -143
  3. package/es/Select/hooks/norHooks.d.ts +6 -4
  4. package/es/Select/hooks/norHooks.js +137 -29
  5. package/es/Select/hooks/util.d.ts +10 -0
  6. package/es/Select/hooks/util.js +138 -0
  7. package/es/Select/index.js +17 -12
  8. package/es/Select/modal.d.ts +11 -2
  9. package/lib/Select/hooks/changeHooks.js +35 -144
  10. package/lib/Select/hooks/norHooks.d.ts +6 -4
  11. package/lib/Select/hooks/norHooks.js +136 -28
  12. package/lib/Select/hooks/util.d.ts +10 -0
  13. package/lib/Select/hooks/util.js +139 -0
  14. package/lib/Select/index.js +16 -11
  15. package/lib/Select/modal.d.ts +11 -2
  16. package/package.json +1 -1
  17. package/src/components/DialogForm/DrawerForm/index.tsx +1 -1
  18. package/src/components/DialogForm/ModalForm.tsx +1 -1
  19. package/src/components/Form/hooks/useDefaultRender.tsx +1 -1
  20. package/src/components/Form/hooks/useHForm.ts +1 -1
  21. package/src/components/Form/index.tsx +4 -4
  22. package/src/components/Input/ButtonInput.tsx +2 -2
  23. package/src/components/Select/hooks/changeHooks.tsx +30 -107
  24. package/src/components/Select/hooks/norHooks.ts +107 -17
  25. package/src/components/Select/hooks/util.ts +109 -0
  26. package/src/components/Select/index.tsx +7 -2
  27. package/src/components/Select/modal.ts +14 -2
  28. package/src/components/Submit/components.tsx +7 -3
  29. package/src/components/Upload/hooks/customRequest.ts +6 -6
  30. package/src/pages/DrawerForm/index.tsx +9 -9
  31. package/src/pages/Form/index.tsx +22 -29
  32. package/src/pages/Select/index.tsx +25 -3
  33. package/src/pages/Upload/index.tsx +16 -13
@@ -2,8 +2,8 @@ import type { SelectProps } from "antd";
2
2
  import type React from "react";
3
3
  import type { PromiseFnResult } from "../modal";
4
4
  import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
5
+
5
6
  export type OptionType = Record<string, any>;
6
- export type PartialHSelectProps = Partial<HSelectProps>;
7
7
  export type RenderFn = (data: OptionType) => React.ReactNode;
8
8
 
9
9
  interface ModeConfigItem {
@@ -15,10 +15,20 @@ export interface ModeConfig {
15
15
  tags?: ModeConfigItem;
16
16
  }
17
17
  type FilterProviderFn = (item: any) => string;
18
+ type OptionsListType = OptionType[];
19
+ export interface OptionsPageResultModal {
20
+ page: number;
21
+ size: number;
22
+ data: OptionsListType;
23
+ total:number;
24
+ }
25
+ export type OptionsDataType =
26
+ | OptionsListType
27
+ | OptionsPageResultModal
18
28
  export interface HSelectProps
19
29
  extends Omit<SelectProps, "options" | "placeholder"> {
20
30
  style?: React.CSSProperties;
21
- request?: PromiseFnResult<any, OptionType[]>;
31
+ request?: PromiseFnResult<any, OptionsDataType>;
22
32
  manual?: boolean;
23
33
  modeConfig?: ModeConfig;
24
34
  filterProvider?: FilterProviderFn | string; //筛选字段默认为label
@@ -30,8 +40,10 @@ export interface HSelectProps
30
40
  addFormat?: (format: Record<string, addFormatItemModal>) => void;
31
41
  placeholder?: string;
32
42
  dispatch?: DispatchModal;
43
+ isList?:boolean
33
44
  }
34
45
  export interface FilterDataModal {
35
46
  value: any;
36
47
  index: number;
37
48
  }
49
+ export type PartialHSelectProps = Partial<HSelectProps>;
@@ -7,9 +7,13 @@ import type {
7
7
  } from "@/components/Submit/index";
8
8
  interface ControlFooterProps extends ISubmitProps {
9
9
  action: SubmitBarExtraType;
10
- style?:React.CSSProperties
10
+ style?: React.CSSProperties;
11
11
  }
12
- function ResetBtn({ form, style={borderRadius:4},...props }:Omit<ControlFooterProps, 'action'>) {
12
+ function ResetBtn({
13
+ form,
14
+ style = { borderRadius: 4 },
15
+ ...props
16
+ }: Omit<ControlFooterProps, "action">) {
13
17
  return (
14
18
  <Button
15
19
  {...props}
@@ -28,7 +32,7 @@ function SubBtn({
28
32
  form,
29
33
  text = "提交",
30
34
  loading,
31
- style={borderRadius:4},
35
+ style = { borderRadius: 4 },
32
36
  ...props
33
37
  }: ISubmitProps) {
34
38
  const { loading: formSubLoading = loading } = useFormContext();
@@ -9,14 +9,14 @@ import { message } from "antd";
9
9
  interface SubReqParamsModal {
10
10
  request?: (
11
11
  file: Exclude<BeforeUploadFileType, File | boolean> | RcFile
12
- ) => Promise<{ url: string ,thumbUrl?:string}>;
12
+ ) => Promise<{ url: string; thumbUrl?: string }>;
13
13
  file: RcFile;
14
14
  }
15
15
  interface ResultModal {
16
16
  url: string;
17
17
  status: UploadFileStatus;
18
18
  uid?: string;
19
- thumbUrl?:string;
19
+ thumbUrl?: string;
20
20
  }
21
21
  const subReq = async ({
22
22
  request,
@@ -29,7 +29,7 @@ const subReq = async ({
29
29
  };
30
30
  }
31
31
  try {
32
- const { url ,thumbUrl} = await request(file);
32
+ const { url, thumbUrl } = await request(file);
33
33
  return {
34
34
  url,
35
35
  thumbUrl,
@@ -44,19 +44,19 @@ const subReq = async ({
44
44
  }
45
45
  };
46
46
  const fileListProvider = (changeFile: ResultModal, files?: UploadFile[]) => {
47
- const { status, url, uid,thumbUrl } = changeFile;
47
+ const { status, url, uid, thumbUrl } = changeFile;
48
48
  if (status === "error") {
49
49
  return files?.filter((item) => {
50
50
  return item.uid !== uid;
51
51
  });
52
52
  }
53
53
  return files?.map((item) => {
54
- const fileDefaultThumbUrl=item.thumbUrl||thumbUrl;
54
+ const fileDefaultThumbUrl = item.thumbUrl || thumbUrl;
55
55
  const resultUrl = url || item.thumbUrl;
56
56
  if (item.uid === uid) {
57
57
  item.status = status;
58
58
  item.response = { url: resultUrl };
59
- item.thumbUrl=fileDefaultThumbUrl;
59
+ item.thumbUrl = fileDefaultThumbUrl;
60
60
  return item;
61
61
  }
62
62
  return item;
@@ -19,12 +19,12 @@ const data = [
19
19
  type: "select",
20
20
  helper: "select",
21
21
  itemProps: {
22
- mode:"tags",
23
- options:[
24
- { label: "选择1", value: 0 },
25
- { label: "选择2", value: 1 },
26
- ]
27
- }
22
+ mode: "tags",
23
+ options: [
24
+ { label: "选择1", value: 0 },
25
+ { label: "选择2", value: 1 },
26
+ ],
27
+ },
28
28
  },
29
29
  {
30
30
  label: "地址文件",
@@ -85,9 +85,9 @@ export default () => {
85
85
  <Button
86
86
  onClick={() => {
87
87
  modalForm.show({
88
- initialValues:{
89
- select:null
90
- }
88
+ initialValues: {
89
+ select: null,
90
+ },
91
91
  });
92
92
  }}
93
93
  >
@@ -24,16 +24,6 @@ const Test3 = ({ value, onChange }) => {
24
24
  );
25
25
  };
26
26
  const formData = (options) => {
27
- const op = [
28
- {
29
- key: 1,
30
- value: "是",
31
- },
32
- {
33
- key: 0,
34
- value: "否",
35
- },
36
- ];
37
27
  return [
38
28
  {
39
29
  label: "12321",
@@ -45,29 +35,32 @@ const formData = (options) => {
45
35
  },
46
36
  },
47
37
  {
48
- label: "测试12312",
38
+ label: "下拉",
49
39
  className: "hdjd",
50
40
  type: "select",
51
41
  name: "test321",
52
- itemProps: {
53
- options:[{
54
- value:"选项1",
55
- key:1
56
- },{
57
- value:"选项2",
58
- key:2
59
- }],
60
- showSearch:true
61
- }
62
- },
63
- {
64
- label: "测试12312",
65
- className: "hdjd",
66
- name: "test123",
67
- },
68
- {
69
- type: "submit"
42
+ itemProps: {
43
+ options: [
44
+ {
45
+ value: "选项1",
46
+ key: 1,
47
+ },
48
+ {
49
+ value: "选项2",
50
+ key: 2,
51
+ },
52
+ ],
53
+ showSearch: true,
70
54
  },
55
+ },
56
+ {
57
+ label: "测试12312",
58
+ className: "hdjd",
59
+ name: "test123",
60
+ },
61
+ {
62
+ type: "submit",
63
+ },
71
64
  ];
72
65
  };
73
66
  function Ttta({ form }) {
@@ -1,5 +1,5 @@
1
1
  import { HSelect } from "../../components";
2
- import { Space } from "antd";
2
+ import {Space} from "antd";
3
3
  import { useState } from "react";
4
4
  export default () => {
5
5
  const [selectVal, setSelectVal] = useState(null);
@@ -7,7 +7,7 @@ export default () => {
7
7
  <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
8
8
  <HSelect
9
9
  options={[{ label: "测试", value: 1 }]}
10
- value={100}
10
+ value={1}
11
11
  placeholder="基础"
12
12
  allowClear={true}
13
13
  />
@@ -18,7 +18,7 @@ export default () => {
18
18
  { name: "测试2", value: 20, userId: 112321 },
19
19
  ]}
20
20
  placeholder="多选"
21
- value={selectVal}
21
+ value={[10,20]}
22
22
  onChange={(val, option) => {
23
23
  setSelectVal(val);
24
24
  }}
@@ -37,6 +37,28 @@ export default () => {
37
37
  { label: "测试2", value: 20 },
38
38
  ]}
39
39
  />
40
+ <HSelect
41
+ placeholder="分页"
42
+ serviceSearch
43
+ allowClear={true}
44
+ labelInValue
45
+ mode="multiple"
46
+ value={["21321312"]}
47
+ request={(params)=>{
48
+ const {page,size}=params
49
+ const op=[];
50
+ for (let i=0;i<size;i+=1){
51
+ op.push( { label: `第${page}页第${i}条`, value:i+page })
52
+ }
53
+ return {
54
+ page,
55
+ size:100,
56
+ total:1000,
57
+ data:op
58
+ }
59
+ }}
60
+ isList
61
+ />
40
62
  <HSelect
41
63
  serviceSearch={true}
42
64
  request={(params) => {
@@ -6,21 +6,24 @@ import { MediaTypeEnum } from "../../components/Upload/enums";
6
6
  export default () => {
7
7
  const [files, setFiles] = useState([]);
8
8
  const [files1, setFiles1] = useState([]);
9
- console.log(files)
9
+ console.log(files);
10
10
  return (
11
11
  <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
12
- <HUpload exFiles={null}
13
- value={files}
14
- request={()=>{
15
- return {
16
- url:"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641",
17
- thumbUrl:"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"
18
- }
19
- }}
20
- onChange={setFiles}
21
- multiple={true}
22
- maxCount={3}
23
- maxSize={Number.MAX_SAFE_INTEGER}/>
12
+ <HUpload
13
+ exFiles={null}
14
+ value={files}
15
+ request={() => {
16
+ return {
17
+ url: "https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641",
18
+ thumbUrl:
19
+ "https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641",
20
+ };
21
+ }}
22
+ onChange={setFiles}
23
+ multiple={true}
24
+ maxCount={3}
25
+ maxSize={Number.MAX_SAFE_INTEGER}
26
+ />
24
27
  <HUrlUpload
25
28
  value={files1}
26
29
  mediaType={MediaTypeEnum.file}