@hw-component/form 1.9.93 → 1.9.96

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.
@@ -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 jsx(Picker, _objectSpread({
51
- value: timeVal,
52
- onChange: change,
53
- showTime: showTime,
54
- format: pickerFormat,
55
- style: style,
56
- showSecond: showSecond,
57
- disabledDate: function disabledDate(currentDate) {
58
- return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
59
- }
60
- }, props));
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
 
@@ -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>;
@@ -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.jsx(Picker, _objectSpread({
54
- value: timeVal,
55
- onChange: change,
56
- showTime: showTime,
57
- format: pickerFormat,
58
- style: style,
59
- showSecond: showSecond,
60
- disabledDate: function disabledDate(currentDate) {
61
- return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
62
- }
63
- }, props));
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
 
@@ -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,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.9.93",
3
+ "version": "1.9.96",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -1,8 +1,9 @@
1
- import { DatePicker } 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
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
- <Picker
32
- value={timeVal}
33
- onChange={change}
34
- showTime={showTime}
35
- format={pickerFormat}
36
- style={style}
37
- showSecond={showSecond}
38
- disabledDate={(currentDate) => {
39
- return !!disabledDate?.(currentDate, timeVal);
40
- }}
41
- {...props}
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
- <Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
12
- <HDatePicker
13
- value={timeVal1}
14
- showTime={false}
15
- onChange={(val) => {
16
- console.log(val);
17
- setTimeVal1(val);
18
- }}
19
- />
20
- <HRangePicker
21
- value={timeVal}
22
- valueMap={{ start: "start", end: "end" }}
23
- onChange={(val) => {
24
- console.log(val);
25
- setTimeVal(val);
26
- }}
27
- />
28
- <HTimePicker
29
- value={55135}
30
- onChange={(val) => {
31
- console.log(val);
32
- }}
33
- />
34
- </Space>
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
  };