@hw-component/form 1.10.21 → 1.10.22

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 (53) hide show
  1. package/.eslintcache +1 -1
  2. package/es/Form/FormItem/BasicItem.js +1 -1
  3. package/es/Form/hooks/useAddFormat.d.ts +1 -1
  4. package/es/RichEditor/hooks.d.ts +1 -1
  5. package/es/RichEditor/modal.d.ts +3 -3
  6. package/es/Select/TagSelect/Content.d.ts +1 -1
  7. package/es/Select/TagSelect/hooks.d.ts +1 -1
  8. package/es/Select/hooks/norHooks.js +8 -3
  9. package/es/TDPicker/TimeRangePicker.d.ts +1 -1
  10. package/es/TDPicker/TimeRangePicker.js +1 -1
  11. package/es/TDPicker/index.js +4 -4
  12. package/es/TDPicker/modal.d.ts +2 -2
  13. package/es/Upload/modal.d.ts +1 -1
  14. package/lib/Form/FormItem/BasicItem.js +1 -1
  15. package/lib/Form/hooks/useAddFormat.d.ts +1 -1
  16. package/lib/RichEditor/hooks.d.ts +1 -1
  17. package/lib/RichEditor/modal.d.ts +3 -3
  18. package/lib/Select/TagSelect/Content.d.ts +1 -1
  19. package/lib/Select/TagSelect/hooks.d.ts +1 -1
  20. package/lib/Select/hooks/norHooks.js +7 -2
  21. package/lib/TDPicker/TimeRangePicker.d.ts +1 -1
  22. package/lib/TDPicker/TimeRangePicker.js +1 -1
  23. package/lib/TDPicker/index.js +4 -4
  24. package/lib/TDPicker/modal.d.ts +2 -2
  25. package/lib/Upload/modal.d.ts +1 -1
  26. package/package.json +1 -1
  27. package/src/components/Form/Basic.tsx +4 -2
  28. package/src/components/Form/FormItem/BasicItem.tsx +5 -1
  29. package/src/components/Form/hooks/useAddFormat.tsx +1 -1
  30. package/src/components/Form/hooks/useDefaultRender.tsx +1 -1
  31. package/src/components/Form/hooks/useHForm.ts +3 -3
  32. package/src/components/Form/index.tsx +3 -3
  33. package/src/components/Form/modal.ts +2 -2
  34. package/src/components/InputGroup/index.less +12 -12
  35. package/src/components/InputGroup/index.tsx +13 -13
  36. package/src/components/RichEditor/hooks.ts +3 -2
  37. package/src/components/RichEditor/index.tsx +3 -2
  38. package/src/components/RichEditor/modal.ts +3 -3
  39. package/src/components/Select/TagSelect/Content.tsx +1 -1
  40. package/src/components/Select/TagSelect/hooks.ts +1 -1
  41. package/src/components/Select/TagSelect/index.tsx +2 -2
  42. package/src/components/Select/hooks/norHooks.ts +7 -2
  43. package/src/components/TDPicker/TimePicker.tsx +25 -21
  44. package/src/components/TDPicker/TimeRangePicker.tsx +60 -48
  45. package/src/components/TDPicker/hooks.ts +8 -8
  46. package/src/components/TDPicker/index.tsx +42 -32
  47. package/src/components/TDPicker/modal.ts +14 -13
  48. package/src/components/Text/index.tsx +6 -2
  49. package/src/components/Upload/modal.ts +1 -1
  50. package/src/pages/DatePicker/index.tsx +37 -32
  51. package/src/pages/Form/index.tsx +18 -19
  52. package/src/pages/Select/index.tsx +2 -0
  53. package/src/pages/Upload/index.tsx +6 -2
@@ -1,56 +1,68 @@
1
- import { TimePicker } from 'antd';
1
+ import { TimePicker } from "antd";
2
2
  import React from "react";
3
3
  import HFormConnect from "@/components/Form/HFormConnect";
4
- import {HTimeRangePickerProps} from "@/components/TDPicker/modal";
5
- import {HItemProps} from "@/components/Form/modal";
4
+ import type { HTimeRangePickerProps } from "@/components/TDPicker/modal";
5
+ import type { HItemProps } from "@/components/Form/modal";
6
6
  import moment from "moment";
7
- const HTimePicker:React.FC<HTimeRangePickerProps>=({value,format="HH:mm:ss",addFormat,valueMap={},onChange,order=false,...props})=>{
8
- const {start="startTime",end="endTime"}=valueMap;
9
- addFormat?.({
10
- float: {
11
- inputValue: (item, initValue) => {
12
- const {[start]:initStart,[end]:initEnd}=initValue;
13
- const {name}=item;
14
- if (initStart&&initEnd){
15
- return {
16
- [(name as string)]:[
17
- moment(initStart,format),
18
- moment(initEnd,format)
19
- ]
20
- }
21
- }
22
- return {
23
- [(name as string)]:[]
24
- };
25
- },
26
- outputValue: (item, outputValue) => {
27
- const { name: valueName = "" } = item;
28
- const { [valueName as string]: itemVal } = outputValue;
29
- const [startVal,endVal]=itemVal||[];
30
- return {
31
- [start]:startVal?.format(format),
32
- [end]:endVal?.format(format)
33
- };
34
- },
35
- },
36
- });
7
+ const HTimePicker: React.FC<HTimeRangePickerProps> = ({
8
+ value,
9
+ format = "HH:mm:ss",
10
+ addFormat,
11
+ valueMap = {},
12
+ onChange,
13
+ order = false,
14
+ ...props
15
+ }) => {
16
+ const { start = "startTime", end = "endTime" } = valueMap;
17
+ addFormat?.({
18
+ float: {
19
+ inputValue: (item, initValue) => {
20
+ const { [start]: initStart, [end]: initEnd } = initValue;
21
+ const { name } = item;
22
+ if (initStart && initEnd) {
23
+ return {
24
+ [name as string]: [
25
+ moment(initStart, format),
26
+ moment(initEnd, format),
27
+ ],
28
+ };
29
+ }
30
+ return {
31
+ [name as string]: [],
32
+ };
33
+ },
34
+ outputValue: (item, outputValue) => {
35
+ const { name: valueName = "" } = item;
36
+ const { [valueName as string]: itemVal } = outputValue;
37
+ const [startVal, endVal] = itemVal || [];
38
+ return {
39
+ [start]: startVal?.format(format),
40
+ [end]: endVal?.format(format),
41
+ };
42
+ },
43
+ },
44
+ });
37
45
 
38
- return <TimePicker.RangePicker value={value}
39
- onChange={onChange}
40
- order={order}
41
- format={format}
42
- style={{ width: '100%' }}
43
- {...props}/>;
44
- }
46
+ return (
47
+ <TimePicker.RangePicker
48
+ value={value}
49
+ onChange={onChange}
50
+ order={order}
51
+ format={format}
52
+ style={{ width: "100%" }}
53
+ {...props}
54
+ />
55
+ );
56
+ };
45
57
 
46
- const Index=HFormConnect(HTimePicker);
58
+ const Index = HFormConnect(HTimePicker);
47
59
 
48
60
  export default {
49
- Component: Index,
50
- placeholder: ({ label }: HItemProps) => {
51
- return [`请选择开始${label}`, `请选择结束${label}`];
52
- },
53
- requiredErrMsg: ({ label }: HItemProps) => {
54
- return `请选择${label}`;
55
- },
61
+ Component: Index,
62
+ placeholder: ({ label }: HItemProps) => {
63
+ return [`请选择开始${label}`, `请选择结束${label}`];
64
+ },
65
+ requiredErrMsg: ({ label }: HItemProps) => {
66
+ return `请选择${label}`;
67
+ },
56
68
  };
@@ -22,7 +22,7 @@ interface UseTimeChangeParams {
22
22
  showTime?: HDatePickerProps["showTime"];
23
23
  showSecond?: boolean;
24
24
  }
25
- export const useTimeVal = ({ value, format="X" }: UseTimeValParams) => {
25
+ export const useTimeVal = ({ value, format = "X" }: UseTimeValParams) => {
26
26
  return useMemo(() => {
27
27
  if (!value || !format) {
28
28
  return value;
@@ -60,7 +60,7 @@ const timeProvider = (
60
60
  return value;
61
61
  };
62
62
  export const useTimeChange = ({
63
- format="X",
63
+ format = "X",
64
64
  onChange,
65
65
  showTime,
66
66
  showSecond = true,
@@ -83,12 +83,12 @@ const formatMap = {
83
83
  X: "s",
84
84
  x: "ms",
85
85
  };
86
- export const usePropsFormat=({format}:UseTimePickerValParams)=>{
87
- if (!format){
88
- return format;
89
- }
90
- return formatMap[format]?undefined:format;
91
- }
86
+ export const usePropsFormat = ({ format }: UseTimePickerValParams) => {
87
+ if (!format) {
88
+ return format;
89
+ }
90
+ return formatMap[format] ? undefined : format;
91
+ };
92
92
  export const useTimePickerValue = ({
93
93
  value,
94
94
  format,
@@ -1,9 +1,9 @@
1
- import {DatePicker, Input} from "antd";
1
+ import { DatePicker, Input } from "antd";
2
2
  import type { HDatePickerProps } from "./modal";
3
3
  import { useTimeChange, useTimeVal } from "./hooks";
4
4
  import React, { useMemo } from "react";
5
5
  import HFormConnect from "../Form/HFormConnect";
6
- import {useClassName} from "@/components/hooks";
6
+ import { useClassName } from "@/components/hooks";
7
7
  const Picker = DatePicker as any;
8
8
  const Index: React.FC<HDatePickerProps> = ({
9
9
  value,
@@ -14,53 +14,63 @@ const Index: React.FC<HDatePickerProps> = ({
14
14
  addFormat,
15
15
  style = { width: "100%" },
16
16
  showSecond = true,
17
- addonBefore,
18
- addonAfter,
19
- className,
17
+ addonBefore,
18
+ addonAfter,
19
+ className,
20
20
  ...props
21
21
  }) => {
22
22
  addFormat?.({});
23
23
  const timeVal = useTimeVal({ value, format });
24
- const addonClassName=useClassName("hw-addon")
24
+ const addonClassName = useClassName("hw-addon");
25
25
  const change = useTimeChange({ format, onChange, showTime, showSecond });
26
- const {format:pickerFormat,showTime:propsShowTime} = useMemo(() => {
26
+ const { format: pickerFormat, showTime: propsShowTime } = useMemo(() => {
27
27
  if (!showTime) {
28
28
  return {
29
- format:"YYYY-MM-DD",
30
- showTime
31
- }
29
+ format: "YYYY-MM-DD",
30
+ showTime,
31
+ };
32
32
  }
33
33
  if (showSecond) {
34
- const sPropsShowTime=typeof showTime==="boolean"?{ format: 'HH:mm:ss' }:{format: 'HH:mm:ss' ,...showTime };
34
+ const sPropsShowTime =
35
+ typeof showTime === "boolean"
36
+ ? { format: "HH:mm:ss" }
37
+ : { format: "HH:mm:ss", ...showTime };
35
38
 
36
39
  return {
37
40
  format: "YYYY-MM-DD HH:mm:ss",
38
- showTime:sPropsShowTime
39
- }
41
+ showTime: sPropsShowTime,
42
+ };
40
43
  }
41
- const mPropsShowTime=typeof showTime==="boolean"?{ format: 'HH:mm' }:{format: 'HH:mm' ,...showTime };
44
+ const mPropsShowTime =
45
+ typeof showTime === "boolean"
46
+ ? { format: "HH:mm" }
47
+ : { format: "HH:mm", ...showTime };
42
48
  return {
43
49
  format: "YYYY-MM-DD HH:mm",
44
- showTime:mPropsShowTime
45
- }
50
+ showTime: mPropsShowTime,
51
+ };
46
52
  }, [showSecond, showTime]);
47
53
  return (
48
- <Input.Group compact style={{display:"flex",...style}} className={className}>
49
- {addonBefore? <div className={addonClassName}>{addonBefore}</div>:null}
50
- <Picker
51
- value={timeVal}
52
- onChange={change}
53
- showTime={propsShowTime}
54
- format={format||pickerFormat}
55
- style={{flex:1}}
56
- showSecond={showSecond}
57
- disabledDate={(currentDate) => {
58
- return !!disabledDate?.(currentDate, timeVal);
59
- }}
60
- {...props}
61
- />
62
- {addonAfter? <div className={addonClassName}>{addonAfter}</div>:null}
63
- </Input.Group>
54
+ <Input.Group
55
+ compact
56
+ style={{ display: "flex", ...style }}
57
+ className={className}
58
+ >
59
+ {addonBefore ? <div className={addonClassName}>{addonBefore}</div> : null}
60
+ <Picker
61
+ value={timeVal}
62
+ onChange={change}
63
+ showTime={propsShowTime}
64
+ format={format || pickerFormat}
65
+ style={{ flex: 1 }}
66
+ showSecond={showSecond}
67
+ disabledDate={(currentDate) => {
68
+ return !!disabledDate?.(currentDate, timeVal);
69
+ }}
70
+ {...props}
71
+ />
72
+ {addonAfter ? <div className={addonClassName}>{addonAfter}</div> : null}
73
+ </Input.Group>
64
74
  );
65
75
  };
66
76
  export default HFormConnect(Index);
@@ -6,8 +6,8 @@ import type { TimePickerProps } from "antd";
6
6
  import type { DurationInputArg2 } from "moment";
7
7
  import type { DateRangePickerValueMapModal } from "../modal";
8
8
  import type { addFormatItemModal } from "../Form/modal";
9
- import {TimeRangePickerProps} from "antd/lib/time-picker";
10
- import React from "react";
9
+ import type { TimeRangePickerProps } from "antd/lib/time-picker";
10
+ import type React from "react";
11
11
  interface DisabledDateFnModal<T = Moment | undefined> {
12
12
  (currentDate: Moment, value: T): boolean;
13
13
  }
@@ -23,8 +23,8 @@ export interface HDatePickerProps
23
23
  disabledDate?: DisabledDateFnModal;
24
24
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
25
25
  showSecond?: boolean;
26
- addonBefore?:React.ReactNode;
27
- addonAfter?:React.ReactNode;
26
+ addonBefore?: React.ReactNode;
27
+ addonAfter?: React.ReactNode;
28
28
  }
29
29
  export interface HRangePickerProps
30
30
  extends Omit<
@@ -50,15 +50,16 @@ export interface HTimePickerProps
50
50
  format?: DurationInputArg2 | string;
51
51
  disabledDate?: DisabledDateFnModal;
52
52
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
53
- addonBefore?:React.ReactNode;
54
- addonAfter?:React.ReactNode;
53
+ addonBefore?: React.ReactNode;
54
+ addonAfter?: React.ReactNode;
55
55
  }
56
56
 
57
- export interface HTimeRangePickerProps extends Omit<TimeRangePickerProps, "format">{
58
- valueMap?:{
59
- start:string;
60
- end:string;
61
- }
62
- format?:string;
57
+ export interface HTimeRangePickerProps
58
+ extends Omit<TimeRangePickerProps, "format"> {
59
+ valueMap?: {
60
+ start: string;
61
+ end: string;
62
+ };
63
+ format?: string;
63
64
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
64
- }
65
+ }
@@ -16,8 +16,12 @@ export default ({
16
16
  ...props
17
17
  }: HFormTextProps) => {
18
18
  const text = useMemo(() => {
19
- const relVal=value?.toString();
20
- if (typeof value === "undefined" || value === null||relVal?.trim()==="") {
19
+ const relVal = value?.toString();
20
+ if (
21
+ typeof value === "undefined" ||
22
+ value === null ||
23
+ relVal?.trim() === ""
24
+ ) {
21
25
  return "-";
22
26
  }
23
27
  return value;
@@ -5,7 +5,7 @@ import type { UploadChangeParam } from "antd/lib/upload/interface";
5
5
  import type { MediaTypeEnum } from "@/components/Upload/enums";
6
6
  import type { addFormatItemModal } from "@/components/Form/modal";
7
7
  import type React from "react";
8
- import { UploadListType } from "antd/lib/upload/interface";
8
+ import type { UploadListType } from "antd/lib/upload/interface";
9
9
 
10
10
  export interface IUpLoadProps
11
11
  extends Omit<UploadProps, "onChange" | "listType" | "onPreview"> {
@@ -1,5 +1,10 @@
1
- import { Space ,DatePicker} from "antd";
2
- import {HDatePicker, HRangePicker, HTimePicker, HTimeRangePicker} from "../../components";
1
+ import { Space, DatePicker } from "antd";
2
+ import {
3
+ HDatePicker,
4
+ HRangePicker,
5
+ HTimePicker,
6
+ HTimeRangePicker,
7
+ } from "../../components";
3
8
  import { useState } from "react";
4
9
  export default () => {
5
10
  const [timeVal, setTimeVal] = useState({
@@ -8,35 +13,35 @@ export default () => {
8
13
  });
9
14
  const [timeVal1, setTimeVal1] = useState(1692070068);
10
15
  return (
11
- <div style={{padding:20}}>
12
- <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
13
- <HDatePicker
14
- value={timeVal1}
15
- showTime={false}
16
- addonBefore="你好"
17
- onChange={(val) => {
18
- console.log(val);
19
- setTimeVal1(val);
20
- }}
21
- />
22
- <HRangePicker
23
- value={timeVal}
24
- valueMap={{ start: "start", end: "end" }}
25
- onChange={(val) => {
26
- console.log(val);
27
- setTimeVal(val);
28
- }}
29
- />
30
- <HTimePicker
31
- value={55135}
32
- addonBefore="你好"
33
- addonAfter="我很好"
34
- onChange={(val) => {
35
- console.log(val);
36
- }}
37
- />
38
- <HTimeRangePicker format="HH:mm"/>
39
- </Space>
40
- </div>
16
+ <div style={{ padding: 20 }}>
17
+ <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
18
+ <HDatePicker
19
+ value={timeVal1}
20
+ showTime={false}
21
+ addonBefore="你好"
22
+ onChange={(val) => {
23
+ console.log(val);
24
+ setTimeVal1(val);
25
+ }}
26
+ />
27
+ <HRangePicker
28
+ value={timeVal}
29
+ valueMap={{ start: "start", end: "end" }}
30
+ onChange={(val) => {
31
+ console.log(val);
32
+ setTimeVal(val);
33
+ }}
34
+ />
35
+ <HTimePicker
36
+ value={55135}
37
+ addonBefore="你好"
38
+ addonAfter="我很好"
39
+ onChange={(val) => {
40
+ console.log(val);
41
+ }}
42
+ />
43
+ <HTimeRangePicker format="HH:mm" />
44
+ </Space>
45
+ </div>
41
46
  );
42
47
  };
@@ -1,8 +1,9 @@
1
1
  import {
2
- HForm,
3
- HFormConfigProvider,
4
- useHForm,
5
- HSelect, HBasicForm,
2
+ HForm,
3
+ HFormConfigProvider,
4
+ useHForm,
5
+ HSelect,
6
+ HBasicForm,
6
7
  } from "../../components";
7
8
  import { useState } from "react";
8
9
  import { Button, Form, Input, Space } from "antd";
@@ -101,12 +102,12 @@ export default () => {
101
102
  {
102
103
  label: "文字1",
103
104
  name: "wz1",
104
- type:"datePicker",
105
- rules:[{required:true}],
106
- itemProps:{
107
- format:"HH:mm",
108
- addonAfter:"测试"
109
- }
105
+ type: "datePicker",
106
+ rules: [{ required: true }],
107
+ itemProps: {
108
+ format: "HH:mm",
109
+ addonAfter: "测试",
110
+ },
110
111
  },
111
112
  // {
112
113
  // label: "inputSelect",
@@ -122,13 +123,11 @@ export default () => {
122
123
  // ],
123
124
  // },
124
125
  {
125
- hideLabel:true,
126
- itemProps:{
127
-
128
- },
129
- render:()=>{
130
- return <div>11</div>
131
- }
126
+ hideLabel: true,
127
+ itemProps: {},
128
+ render: () => {
129
+ return <div>11</div>;
130
+ },
132
131
  },
133
132
  // {
134
133
  // label: "运营商账号",
@@ -237,8 +236,8 @@ export default () => {
237
236
  form={form}
238
237
  initialValues={{
239
238
  richEditor: "1312312",
240
- startTime:'07:00:00' ,
241
- endTime:"14:00:00"
239
+ startTime: "07:00:00",
240
+ endTime: "14:00:00",
242
241
  }}
243
242
  labelAlign={"left"}
244
243
  onFinish={(value) => {
@@ -40,11 +40,13 @@ export default () => {
40
40
  />
41
41
  <HSelect
42
42
  value={val}
43
+
43
44
  onChange={(v, opts) => {
44
45
  console.log(v, opts);
45
46
  setVal(v);
46
47
  }}
47
48
  mode="multiple"
49
+ showSearch={false}
48
50
  />
49
51
  <div
50
52
  onClick={() => {
@@ -11,7 +11,9 @@ export default () => {
11
11
  <HUpload
12
12
  value={files}
13
13
  exFiles={["MP4"]}
14
- thumbUrl={"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"}
14
+ thumbUrl={
15
+ "https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"
16
+ }
15
17
  onPreview={null}
16
18
  request={() => {
17
19
  return {
@@ -27,7 +29,9 @@ export default () => {
27
29
  />
28
30
  <HUpload
29
31
  value={files1}
30
- thumbUrl={"https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"}
32
+ thumbUrl={
33
+ "https://inews.gtimg.com/om_bt/OGlQWfsaAoKkuCcMZ2o9IVEPqd-72DQy5EAN02XBHUwfYAA/641"
34
+ }
31
35
  mediaType={MediaTypeEnum.file}
32
36
  onChange={setFiles1}
33
37
  >