@hw-component/form 1.11.1 → 1.11.2

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,10 +1,11 @@
1
1
  // welcome to hoo hoo hoo
2
2
  import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
3
+ import _slicedToArray from '@babel/runtime-corejs3/helpers/slicedToArray';
3
4
  import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWithoutProperties';
4
5
  import { jsx } from 'react/jsx-runtime';
5
6
  import { DatePicker } from 'antd';
6
7
  import { useGetTimeKey, useRangeValueProvider, useRangePickerTimeVal } from './hooks.js';
7
- import React, { useMemo } from 'react';
8
+ import React, { useState, useMemo } from 'react';
8
9
  import { useMatchConfigProps } from '../hooks/index.js';
9
10
  import HFormConnect from '../Form/HFormConnect.js';
10
11
  import Index$1 from '../InputGroup/index.js';
@@ -36,6 +37,10 @@ var PickerContent = function PickerContent(_ref, ref) {
36
37
  _useMatchConfigProps$ = _useMatchConfigProps.valueRangePickerValueMap,
37
38
  valueRangePickerValueMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$,
38
39
  dateRanges = _useMatchConfigProps.dateRanges;
40
+ var _useState = useState([null, null]),
41
+ _useState2 = _slicedToArray(_useState, 2),
42
+ dates = _useState2[0],
43
+ setDates = _useState2[1];
39
44
  var dateMapKeys = useGetTimeKey({
40
45
  valueMap: valueRangePickerValueMap,
41
46
  name: name
@@ -100,6 +105,13 @@ var PickerContent = function PickerContent(_ref, ref) {
100
105
  });
101
106
  onChange === null || onChange === void 0 || onChange(paramsProvider(subVal));
102
107
  };
108
+ var onOpenChange = function onOpenChange(open) {
109
+ if (open) {
110
+ setDates(timeVal);
111
+ } else {
112
+ setDates([null, null]);
113
+ }
114
+ };
103
115
  return jsx(RangePicker, _objectSpread({
104
116
  value: timeVal,
105
117
  ref: ref,
@@ -108,10 +120,13 @@ var PickerContent = function PickerContent(_ref, ref) {
108
120
  }, style),
109
121
  onChange: change,
110
122
  showTime: showTime,
111
- onCalendarChange: change,
123
+ onCalendarChange: function onCalendarChange(val) {
124
+ return setDates(val);
125
+ },
126
+ onOpenChange: onOpenChange,
112
127
  ranges: defaultRanges,
113
128
  disabledDate: function disabledDate(currentDate) {
114
- return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
129
+ return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, dates));
115
130
  }
116
131
  }, props));
117
132
  };
@@ -31,7 +31,7 @@ export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "
31
31
  valueMap?: DateRangePickerValueMapModal;
32
32
  ranges?: RangePickerProps["ranges"] | boolean;
33
33
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
34
- disabledDate?: DisabledDateFnModal<Moment[] | undefined>;
34
+ disabledDate?: DisabledDateFnModal<(Moment | null)[]>;
35
35
  }
36
36
  export interface HTimePickerProps extends Omit<TimePickerProps, "onChange" | "format" | "ranges" | "disabledDate"> {
37
37
  onChange?: (time?: Moment | string | number) => void;
@@ -3,6 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
6
+ var _slicedToArray = require('@babel/runtime-corejs3/helpers/slicedToArray');
6
7
  var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWithoutProperties');
7
8
  var jsxRuntime = require('react/jsx-runtime');
8
9
  var antd = require('antd');
@@ -39,6 +40,10 @@ var PickerContent = function PickerContent(_ref, ref) {
39
40
  _useMatchConfigProps$ = _useMatchConfigProps.valueRangePickerValueMap,
40
41
  valueRangePickerValueMap = _useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$,
41
42
  dateRanges = _useMatchConfigProps.dateRanges;
43
+ var _useState = React.useState([null, null]),
44
+ _useState2 = _slicedToArray(_useState, 2),
45
+ dates = _useState2[0],
46
+ setDates = _useState2[1];
42
47
  var dateMapKeys = hooks.useGetTimeKey({
43
48
  valueMap: valueRangePickerValueMap,
44
49
  name: name
@@ -103,6 +108,13 @@ var PickerContent = function PickerContent(_ref, ref) {
103
108
  });
104
109
  onChange === null || onChange === void 0 || onChange(paramsProvider(subVal));
105
110
  };
111
+ var onOpenChange = function onOpenChange(open) {
112
+ if (open) {
113
+ setDates(timeVal);
114
+ } else {
115
+ setDates([null, null]);
116
+ }
117
+ };
106
118
  return jsxRuntime.jsx(RangePicker, _objectSpread({
107
119
  value: timeVal,
108
120
  ref: ref,
@@ -111,10 +123,13 @@ var PickerContent = function PickerContent(_ref, ref) {
111
123
  }, style),
112
124
  onChange: change,
113
125
  showTime: showTime,
114
- onCalendarChange: change,
126
+ onCalendarChange: function onCalendarChange(val) {
127
+ return setDates(val);
128
+ },
129
+ onOpenChange: onOpenChange,
115
130
  ranges: defaultRanges,
116
131
  disabledDate: function disabledDate(currentDate) {
117
- return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
132
+ return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, dates));
118
133
  }
119
134
  }, props));
120
135
  };
@@ -31,7 +31,7 @@ export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "
31
31
  valueMap?: DateRangePickerValueMapModal;
32
32
  ranges?: RangePickerProps["ranges"] | boolean;
33
33
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
34
- disabledDate?: DisabledDateFnModal<Moment[] | undefined>;
34
+ disabledDate?: DisabledDateFnModal<(Moment | null)[]>;
35
35
  }
36
36
  export interface HTimePickerProps extends Omit<TimePickerProps, "onChange" | "format" | "ranges" | "disabledDate"> {
37
37
  onChange?: (time?: Moment | string | number) => void;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@hw-component/form",
3
- "version": "1.11.1",
3
+ "version": "1.11.2",
4
4
  "description": "基于antd二次开发",
5
5
  "repository": {
6
6
  "type": "git",
@@ -82,14 +82,13 @@ const Index: React.FC<HInputGroupProps> = ({
82
82
  }
83
83
  return "";
84
84
  }, [addonAfter, addonBefore]);
85
-
86
85
  return (
87
86
  <Input.Group compact className={`${contentClassname} ${className}`}>
88
87
  <Addon value={value} onChange={onChange} style={addonBeforeStyle}>
89
88
  {addonBefore}
90
89
  </Addon>
91
90
  <div className={`${bodyClassname} ${cuBodyClassName}`}>
92
- {React.cloneElement(children as any, { value, onChange, ...props })}
91
+ {React.cloneElement(children as any, { value, onChange,...props})}
93
92
  </div>
94
93
  <Addon value={value} onChange={onChange} style={addonAfterStyle}>
95
94
  {addonAfter}
@@ -5,7 +5,7 @@ import {
5
5
  useRangePickerTimeVal,
6
6
  useRangeValueProvider,
7
7
  } from "./hooks";
8
- import React, { useMemo } from "react";
8
+ import React, {useMemo, useState} from "react";
9
9
  import type { RangePickerProps } from "antd/es/date-picker";
10
10
  import { useMatchConfigProps } from "../hooks";
11
11
  import type { HItemProps } from "../Form/modal";
@@ -15,6 +15,8 @@ import InputGroup from "../InputGroup";
15
15
 
16
16
  const RangePicker = DatePicker.RangePicker as any;
17
17
 
18
+ type RangeValue = (Moment|null) [];
19
+
18
20
  const PickerContent: React.ForwardRefRenderFunction<
19
21
  HRangePickerPropsRef,
20
22
  HRangePickerProps
@@ -38,6 +40,7 @@ const PickerContent: React.ForwardRefRenderFunction<
38
40
  valueRangePickerValueMap: valueMap,
39
41
  dateRanges: undefined,
40
42
  });
43
+ const [dates, setDates] = useState<RangeValue>([null,null]);
41
44
  const dateMapKeys = useGetTimeKey({
42
45
  valueMap: valueRangePickerValueMap,
43
46
  name,
@@ -102,6 +105,13 @@ const PickerContent: React.ForwardRefRenderFunction<
102
105
  });
103
106
  onChange?.(paramsProvider(subVal));
104
107
  };
108
+ const onOpenChange = (open: boolean) => {
109
+ if (open) {
110
+ setDates(timeVal);
111
+ } else {
112
+ setDates([null,null]);
113
+ }
114
+ };
105
115
  return (
106
116
  <RangePicker
107
117
  value={timeVal}
@@ -109,10 +119,11 @@ const PickerContent: React.ForwardRefRenderFunction<
109
119
  style={{ width: "100%", ...style }}
110
120
  onChange={change}
111
121
  showTime={showTime}
112
- onCalendarChange={change}
122
+ onCalendarChange={val => setDates(val)}
123
+ onOpenChange={onOpenChange}
113
124
  ranges={defaultRanges as RangePickerProps["ranges"]}
114
125
  disabledDate={(currentDate) => {
115
- return !!disabledDate?.(currentDate, timeVal);
126
+ return !!disabledDate?.(currentDate, dates);
116
127
  }}
117
128
  {...props}
118
129
  />
@@ -126,7 +137,7 @@ const HRangePicker: React.ForwardRefRenderFunction<
126
137
  > = (props, ref) => {
127
138
  return (
128
139
  <InputGroup {...props}>
129
- <Content ref={ref} />
140
+ <Content ref={ref}/>
130
141
  </InputGroup>
131
142
  );
132
143
  };
@@ -38,7 +38,7 @@ export interface HRangePickerProps
38
38
  valueMap?: DateRangePickerValueMapModal;
39
39
  ranges?: RangePickerProps["ranges"] | boolean;
40
40
  addFormat?: (config: Record<string, addFormatItemModal>) => void;
41
- disabledDate?: DisabledDateFnModal<Moment[] | undefined>;
41
+ disabledDate?: DisabledDateFnModal<(Moment|null) []>;
42
42
  }
43
43
 
44
44
  export interface HTimePickerProps
@@ -26,7 +26,8 @@ export default () => {
26
26
  />
27
27
  <HRangePicker
28
28
  value={timeVal}
29
- addonBefore="你好"
29
+ allowEmpty={[true, false]}
30
+ addonBefore="你好1"
30
31
  valueMap={{ start: "start1", end: "end2" }}
31
32
  onChange={(val) => {
32
33
  console.log(val);