@hw-component/form 1.9.93 → 1.9.94
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/es/TDPicker/index.js +32 -14
- package/es/TDPicker/modal.d.ts +3 -0
- package/lib/TDPicker/index.js +30 -12
- package/lib/TDPicker/modal.d.ts +3 -0
- package/package.json +1 -1
- package/src/components/TDPicker/index.tsx +21 -13
- package/src/components/TDPicker/modal.ts +3 -0
- package/src/pages/DatePicker/index.tsx +28 -24
package/es/TDPicker/index.js
CHANGED
|
@@ -1,13 +1,14 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
2
|
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
3
3
|
import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
|
|
4
|
-
import { jsx } from 'react/jsx-runtime';
|
|
5
|
-
import { DatePicker } from 'antd';
|
|
4
|
+
import { jsxs, jsx } from 'react/jsx-runtime';
|
|
5
|
+
import { Input, DatePicker } from 'antd';
|
|
6
6
|
import { useTimeVal, useTimeChange } from './hooks.js';
|
|
7
7
|
import { useMemo } from 'react';
|
|
8
8
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
9
|
+
import { useClassName } from '../hooks/index.js';
|
|
9
10
|
|
|
10
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style", "showSecond"];
|
|
11
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style", "showSecond", "addonBefore", "addonAfter"];
|
|
11
12
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
12
13
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
13
14
|
var Picker = DatePicker;
|
|
@@ -26,12 +27,15 @@ var Index = function Index(_ref) {
|
|
|
26
27
|
} : _ref$style,
|
|
27
28
|
_ref$showSecond = _ref.showSecond,
|
|
28
29
|
showSecond = _ref$showSecond === void 0 ? true : _ref$showSecond,
|
|
30
|
+
addonBefore = _ref.addonBefore,
|
|
31
|
+
addonAfter = _ref.addonAfter,
|
|
29
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
33
|
addFormat === null || addFormat === void 0 || addFormat({});
|
|
31
34
|
var timeVal = useTimeVal({
|
|
32
35
|
value: value,
|
|
33
36
|
format: format
|
|
34
37
|
});
|
|
38
|
+
var addonClassName = useClassName("hw-addon");
|
|
35
39
|
var change = useTimeChange({
|
|
36
40
|
format: format,
|
|
37
41
|
onChange: onChange,
|
|
@@ -47,17 +51,31 @@ var Index = function Index(_ref) {
|
|
|
47
51
|
}
|
|
48
52
|
return "YYYY-MM-DD HH:mm";
|
|
49
53
|
}, [showSecond, showTime]);
|
|
50
|
-
return
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
54
|
+
return jsxs(Input.Group, {
|
|
55
|
+
compact: true,
|
|
56
|
+
style: _objectSpread({
|
|
57
|
+
display: "flex"
|
|
58
|
+
}, style),
|
|
59
|
+
children: [addonBefore ? jsx("div", {
|
|
60
|
+
className: addonClassName,
|
|
61
|
+
children: addonBefore
|
|
62
|
+
}) : null, jsx(Picker, _objectSpread({
|
|
63
|
+
value: timeVal,
|
|
64
|
+
onChange: change,
|
|
65
|
+
showTime: showTime,
|
|
66
|
+
format: pickerFormat,
|
|
67
|
+
style: {
|
|
68
|
+
flex: 1
|
|
69
|
+
},
|
|
70
|
+
showSecond: showSecond,
|
|
71
|
+
disabledDate: function disabledDate(currentDate) {
|
|
72
|
+
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
73
|
+
}
|
|
74
|
+
}, props)), addonAfter ? jsx("div", {
|
|
75
|
+
className: addonClassName,
|
|
76
|
+
children: addonAfter
|
|
77
|
+
}) : null]
|
|
78
|
+
});
|
|
61
79
|
};
|
|
62
80
|
var HDatePicker = HFormConnect(Index);
|
|
63
81
|
|
package/es/TDPicker/modal.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { DurationInputArg2 } from "moment";
|
|
|
7
7
|
import type { DateRangePickerValueMapModal } from "../modal";
|
|
8
8
|
import type { addFormatItemModal } from "../Form/modal";
|
|
9
9
|
import { TimeRangePickerProps } from "antd/lib/time-picker";
|
|
10
|
+
import React from "react";
|
|
10
11
|
interface DisabledDateFnModal<T = Moment | undefined> {
|
|
11
12
|
(currentDate: Moment, value: T): boolean;
|
|
12
13
|
}
|
|
@@ -17,6 +18,8 @@ export interface HDatePickerProps extends Omit<DatePickerProps, "onChange" | "fo
|
|
|
17
18
|
disabledDate?: DisabledDateFnModal;
|
|
18
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
19
20
|
showSecond?: boolean;
|
|
21
|
+
addonBefore?: React.ReactNode;
|
|
22
|
+
addonAfter?: React.ReactNode;
|
|
20
23
|
}
|
|
21
24
|
export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "format" | "ranges" | "value" | "disabledDate"> {
|
|
22
25
|
value?: [any, any] | Record<string, any>;
|
package/lib/TDPicker/index.js
CHANGED
|
@@ -9,8 +9,9 @@ var antd = require('antd');
|
|
|
9
9
|
var hooks = require('./hooks.js');
|
|
10
10
|
var React = require('react');
|
|
11
11
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
12
|
+
var index = require('../hooks/index.js');
|
|
12
13
|
|
|
13
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style", "showSecond"];
|
|
14
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style", "showSecond", "addonBefore", "addonAfter"];
|
|
14
15
|
function ownKeys(e, r) { var t = Object.keys(e); if (Object.getOwnPropertySymbols) { var o = Object.getOwnPropertySymbols(e); r && (o = o.filter(function (r) { return Object.getOwnPropertyDescriptor(e, r).enumerable; })), t.push.apply(t, o); } return t; }
|
|
15
16
|
function _objectSpread(e) { for (var r = 1; r < arguments.length; r++) { var t = null != arguments[r] ? arguments[r] : {}; r % 2 ? ownKeys(Object(t), !0).forEach(function (r) { _defineProperty(e, r, t[r]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) { Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r)); }); } return e; }
|
|
16
17
|
var Picker = antd.DatePicker;
|
|
@@ -29,12 +30,15 @@ var Index = function Index(_ref) {
|
|
|
29
30
|
} : _ref$style,
|
|
30
31
|
_ref$showSecond = _ref.showSecond,
|
|
31
32
|
showSecond = _ref$showSecond === void 0 ? true : _ref$showSecond,
|
|
33
|
+
addonBefore = _ref.addonBefore,
|
|
34
|
+
addonAfter = _ref.addonAfter,
|
|
32
35
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
36
|
addFormat === null || addFormat === void 0 || addFormat({});
|
|
34
37
|
var timeVal = hooks.useTimeVal({
|
|
35
38
|
value: value,
|
|
36
39
|
format: format
|
|
37
40
|
});
|
|
41
|
+
var addonClassName = index.useClassName("hw-addon");
|
|
38
42
|
var change = hooks.useTimeChange({
|
|
39
43
|
format: format,
|
|
40
44
|
onChange: onChange,
|
|
@@ -50,17 +54,31 @@ var Index = function Index(_ref) {
|
|
|
50
54
|
}
|
|
51
55
|
return "YYYY-MM-DD HH:mm";
|
|
52
56
|
}, [showSecond, showTime]);
|
|
53
|
-
return jsxRuntime.
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
57
|
+
return jsxRuntime.jsxs(antd.Input.Group, {
|
|
58
|
+
compact: true,
|
|
59
|
+
style: _objectSpread({
|
|
60
|
+
display: "flex"
|
|
61
|
+
}, style),
|
|
62
|
+
children: [addonBefore ? jsxRuntime.jsx("div", {
|
|
63
|
+
className: addonClassName,
|
|
64
|
+
children: addonBefore
|
|
65
|
+
}) : null, jsxRuntime.jsx(Picker, _objectSpread({
|
|
66
|
+
value: timeVal,
|
|
67
|
+
onChange: change,
|
|
68
|
+
showTime: showTime,
|
|
69
|
+
format: pickerFormat,
|
|
70
|
+
style: {
|
|
71
|
+
flex: 1
|
|
72
|
+
},
|
|
73
|
+
showSecond: showSecond,
|
|
74
|
+
disabledDate: function disabledDate(currentDate) {
|
|
75
|
+
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
76
|
+
}
|
|
77
|
+
}, props)), addonAfter ? jsxRuntime.jsx("div", {
|
|
78
|
+
className: addonClassName,
|
|
79
|
+
children: addonAfter
|
|
80
|
+
}) : null]
|
|
81
|
+
});
|
|
64
82
|
};
|
|
65
83
|
var HDatePicker = HFormConnect.default(Index);
|
|
66
84
|
|
package/lib/TDPicker/modal.d.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type { DurationInputArg2 } from "moment";
|
|
|
7
7
|
import type { DateRangePickerValueMapModal } from "../modal";
|
|
8
8
|
import type { addFormatItemModal } from "../Form/modal";
|
|
9
9
|
import { TimeRangePickerProps } from "antd/lib/time-picker";
|
|
10
|
+
import React from "react";
|
|
10
11
|
interface DisabledDateFnModal<T = Moment | undefined> {
|
|
11
12
|
(currentDate: Moment, value: T): boolean;
|
|
12
13
|
}
|
|
@@ -17,6 +18,8 @@ export interface HDatePickerProps extends Omit<DatePickerProps, "onChange" | "fo
|
|
|
17
18
|
disabledDate?: DisabledDateFnModal;
|
|
18
19
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
19
20
|
showSecond?: boolean;
|
|
21
|
+
addonBefore?: React.ReactNode;
|
|
22
|
+
addonAfter?: React.ReactNode;
|
|
20
23
|
}
|
|
21
24
|
export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "format" | "ranges" | "value" | "disabledDate"> {
|
|
22
25
|
value?: [any, any] | Record<string, any>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import {
|
|
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
7
|
const Picker = DatePicker as any;
|
|
7
8
|
const Index: React.FC<HDatePickerProps> = ({
|
|
8
9
|
value,
|
|
@@ -13,10 +14,13 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
13
14
|
addFormat,
|
|
14
15
|
style = { width: "100%" },
|
|
15
16
|
showSecond = true,
|
|
17
|
+
addonBefore,
|
|
18
|
+
addonAfter,
|
|
16
19
|
...props
|
|
17
20
|
}) => {
|
|
18
21
|
addFormat?.({});
|
|
19
22
|
const timeVal = useTimeVal({ value, format });
|
|
23
|
+
const addonClassName=useClassName("hw-addon")
|
|
20
24
|
const change = useTimeChange({ format, onChange, showTime, showSecond });
|
|
21
25
|
const pickerFormat = useMemo(() => {
|
|
22
26
|
if (!showTime) {
|
|
@@ -28,18 +32,22 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
28
32
|
return "YYYY-MM-DD HH:mm";
|
|
29
33
|
}, [showSecond, showTime]);
|
|
30
34
|
return (
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
35
|
+
<Input.Group compact style={{display:"flex",...style}}>
|
|
36
|
+
{addonBefore? <div className={addonClassName}>{addonBefore}</div>:null}
|
|
37
|
+
<Picker
|
|
38
|
+
value={timeVal}
|
|
39
|
+
onChange={change}
|
|
40
|
+
showTime={showTime}
|
|
41
|
+
format={pickerFormat}
|
|
42
|
+
style={{flex:1}}
|
|
43
|
+
showSecond={showSecond}
|
|
44
|
+
disabledDate={(currentDate) => {
|
|
45
|
+
return !!disabledDate?.(currentDate, timeVal);
|
|
46
|
+
}}
|
|
47
|
+
{...props}
|
|
48
|
+
/>
|
|
49
|
+
{addonAfter? <div className={addonClassName}>{addonAfter}</div>:null}
|
|
50
|
+
</Input.Group>
|
|
43
51
|
);
|
|
44
52
|
};
|
|
45
53
|
export default HFormConnect(Index);
|
|
@@ -7,6 +7,7 @@ import type { DurationInputArg2 } from "moment";
|
|
|
7
7
|
import type { DateRangePickerValueMapModal } from "../modal";
|
|
8
8
|
import type { addFormatItemModal } from "../Form/modal";
|
|
9
9
|
import {TimeRangePickerProps} from "antd/lib/time-picker";
|
|
10
|
+
import React from "react";
|
|
10
11
|
interface DisabledDateFnModal<T = Moment | undefined> {
|
|
11
12
|
(currentDate: Moment, value: T): boolean;
|
|
12
13
|
}
|
|
@@ -22,6 +23,8 @@ export interface HDatePickerProps
|
|
|
22
23
|
disabledDate?: DisabledDateFnModal;
|
|
23
24
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
24
25
|
showSecond?: boolean;
|
|
26
|
+
addonBefore?:React.ReactNode;
|
|
27
|
+
addonAfter?:React.ReactNode;
|
|
25
28
|
}
|
|
26
29
|
export interface HRangePickerProps
|
|
27
30
|
extends Omit<
|
|
@@ -8,29 +8,33 @@ export default () => {
|
|
|
8
8
|
});
|
|
9
9
|
const [timeVal1, setTimeVal1] = useState(1692070068);
|
|
10
10
|
return (
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
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
|
+
addonAfter="我很好"
|
|
18
|
+
onChange={(val) => {
|
|
19
|
+
console.log(val);
|
|
20
|
+
setTimeVal1(val);
|
|
21
|
+
}}
|
|
22
|
+
/>
|
|
23
|
+
<HRangePicker
|
|
24
|
+
value={timeVal}
|
|
25
|
+
valueMap={{ start: "start", end: "end" }}
|
|
26
|
+
onChange={(val) => {
|
|
27
|
+
console.log(val);
|
|
28
|
+
setTimeVal(val);
|
|
29
|
+
}}
|
|
30
|
+
/>
|
|
31
|
+
<HTimePicker
|
|
32
|
+
value={55135}
|
|
33
|
+
onChange={(val) => {
|
|
34
|
+
console.log(val);
|
|
35
|
+
}}
|
|
36
|
+
/>
|
|
37
|
+
</Space>
|
|
38
|
+
</div>
|
|
35
39
|
);
|
|
36
40
|
};
|