@hw-component/form 0.0.1-bate → 0.0.1-beta
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/CheckboxGroup/CheckBox/index.js +24 -16
- package/es/CheckboxGroup/hooks.d.ts +9 -3
- package/es/CheckboxGroup/hooks.js +115 -64
- package/es/CheckboxGroup/index.d.ts +6 -1
- package/es/CheckboxGroup/index.js +117 -56
- package/es/CheckboxGroup/modal.d.ts +9 -8
- package/es/Form/Context/FormConfigProvider.js +64 -19
- package/es/Form/Context/index.d.ts +4 -1
- package/es/Form/Context/index.js +3 -3
- package/es/Form/FormItem/BasicItem.js +80 -42
- package/es/Form/FormItem/Helper.d.ts +1 -1
- package/es/Form/FormItem/Helper.js +17 -9
- package/es/Form/FormItem/RegularFormItem.js +11 -8
- package/es/Form/FormItem/UpFormItem.d.ts +6 -1
- package/es/Form/FormItem/UpFormItem.js +27 -17
- package/es/Form/FormItem/hooks.d.ts +21 -4
- package/es/Form/FormItem/hooks.js +12 -9
- package/es/Form/FormItem/index.js +5 -5
- package/es/Form/HFormConnect.d.ts +9 -1
- package/es/Form/HFormConnect.js +94 -26
- package/es/Form/InitSet.d.ts +1 -1
- package/es/Form/InitSet.js +5 -5
- package/es/Form/Label.d.ts +4 -4
- package/es/Form/Label.js +36 -19
- package/es/Form/config.d.ts +100 -22
- package/es/Form/config.js +19 -19
- package/es/Form/hooks/index.d.ts +12 -5
- package/es/Form/hooks/index.js +65 -49
- package/es/Form/hooks/useHForm.js +233 -95
- package/es/Form/hooks/useInitConfigData.d.ts +4 -1
- package/es/Form/hooks/useInitConfigData.js +143 -61
- package/es/Form/index.d.ts +11 -1
- package/es/Form/index.js +71 -40
- package/es/Form/modal.d.ts +92 -51
- package/es/Input/ButtonInput.js +73 -51
- package/es/Input/InputNumber.js +21 -12
- package/es/Input/SelectInput.d.ts +16 -4
- package/es/Input/SelectInput.js +113 -56
- package/es/Input/defaultConfig.d.ts +3 -3
- package/es/Input/defaultConfig.js +2 -2
- package/es/Input/index.js +7 -7
- package/es/Input/modal.d.ts +15 -11
- package/es/PageHandler/ErrorComponent.js +47 -25
- package/es/PageHandler/LoadingComponent.js +17 -13
- package/es/PageHandler/index.js +7 -7
- package/es/PageHandler/modal.d.ts +4 -4
- package/es/RadioGroup/index.d.ts +12 -5
- package/es/RadioGroup/index.js +46 -33
- package/es/Select/components/AllSelect.d.ts +1 -1
- package/es/Select/components/AllSelect.js +40 -18
- package/es/Select/components/CheckBoxOption.d.ts +6 -3
- package/es/Select/components/CheckBoxOption.js +12 -7
- package/es/Select/components/DropdownComponent.d.ts +4 -4
- package/es/Select/components/DropdownComponent.js +30 -17
- package/es/Select/components/NoFindItem.d.ts +1 -1
- package/es/Select/components/NoFindItem.js +11 -7
- package/es/Select/components/NotFoundContent.d.ts +2 -2
- package/es/Select/components/NotFoundContent.js +49 -27
- package/es/Select/defaultConfig.d.ts +1 -1
- package/es/Select/defaultConfig.js +20 -16
- package/es/Select/hooks/changeHooks.d.ts +2 -2
- package/es/Select/hooks/changeHooks.js +147 -71
- package/es/Select/hooks/norHooks.d.ts +27 -9
- package/es/Select/hooks/norHooks.js +51 -39
- package/es/Select/index.d.ts +22 -1
- package/es/Select/index.js +124 -65
- package/es/Select/modal.d.ts +15 -15
- package/es/Select/utils.js +60 -15
- package/es/Submit/index.d.ts +9 -3
- package/es/Submit/index.js +18 -13
- package/es/Switch/index.d.ts +4 -4
- package/es/Switch/index.js +46 -20
- package/es/TDPicker/RangePicker.d.ts +8 -3
- package/es/TDPicker/RangePicker.js +138 -62
- package/es/TDPicker/TimePicker.d.ts +6 -1
- package/es/TDPicker/TimePicker.js +19 -13
- package/es/TDPicker/hooks.d.ts +42 -22
- package/es/TDPicker/hooks.js +106 -72
- package/es/TDPicker/index.d.ts +7 -1
- package/es/TDPicker/index.js +20 -14
- package/es/TDPicker/modal.d.ts +21 -16
- package/es/Upload/Btn.d.ts +5 -1
- package/es/Upload/Btn.js +35 -19
- package/es/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/es/Upload/MediaTypeEle/TypeEle.js +31 -23
- package/es/Upload/MediaTypeEle/index.d.ts +5 -1
- package/es/Upload/MediaTypeEle/index.js +21 -18
- package/es/Upload/Preview/index.d.ts +5 -1
- package/es/Upload/Preview/index.js +17 -13
- package/es/Upload/UrlUpload/index.d.ts +7 -1
- package/es/Upload/UrlUpload/index.js +72 -51
- package/es/Upload/enums.d.ts +3 -3
- package/es/Upload/enums.js +3 -3
- package/es/Upload/hooks/change.d.ts +8 -1
- package/es/Upload/hooks/change.js +115 -58
- package/es/Upload/hooks/customRequest.d.ts +5 -1
- package/es/Upload/hooks/customRequest.js +63 -46
- package/es/Upload/hooks/propsMaker.d.ts +5 -1
- package/es/Upload/hooks/propsMaker.js +52 -13
- package/es/Upload/index.d.ts +3 -1
- package/es/Upload/index.js +131 -61
- package/es/Upload/modal.d.ts +17 -15
- package/es/Upload/util.d.ts +8 -2
- package/es/Upload/util.js +15 -7
- package/es/config.js +34 -31
- package/es/hooks/index.d.ts +14 -7
- package/es/hooks/index.js +124 -49
- package/es/index.d.ts +98 -16
- package/es/index.js +22 -5
- package/es/modal.d.ts +6 -6
- package/lib/CheckboxGroup/CheckBox/index.js +26 -18
- package/lib/CheckboxGroup/hooks.d.ts +9 -3
- package/lib/CheckboxGroup/hooks.js +116 -65
- package/lib/CheckboxGroup/index.d.ts +6 -1
- package/lib/CheckboxGroup/index.js +119 -58
- package/lib/CheckboxGroup/modal.d.ts +9 -8
- package/lib/Form/Context/FormConfigProvider.js +66 -21
- package/lib/Form/Context/index.d.ts +4 -1
- package/lib/Form/Context/index.js +4 -4
- package/lib/Form/FormItem/BasicItem.js +82 -44
- package/lib/Form/FormItem/Helper.d.ts +1 -1
- package/lib/Form/FormItem/Helper.js +19 -11
- package/lib/Form/FormItem/RegularFormItem.js +13 -10
- package/lib/Form/FormItem/UpFormItem.d.ts +6 -1
- package/lib/Form/FormItem/UpFormItem.js +29 -19
- package/lib/Form/FormItem/hooks.d.ts +21 -4
- package/lib/Form/FormItem/hooks.js +13 -10
- package/lib/Form/FormItem/index.js +7 -7
- package/lib/Form/HFormConnect.d.ts +9 -1
- package/lib/Form/HFormConnect.js +96 -28
- package/lib/Form/InitSet.d.ts +1 -1
- package/lib/Form/InitSet.js +7 -7
- package/lib/Form/Label.d.ts +4 -4
- package/lib/Form/Label.js +41 -21
- package/lib/Form/config.d.ts +100 -22
- package/lib/Form/config.js +21 -21
- package/lib/Form/hooks/index.d.ts +12 -5
- package/lib/Form/hooks/index.js +66 -50
- package/lib/Form/hooks/useHForm.js +235 -97
- package/lib/Form/hooks/useInitConfigData.d.ts +4 -1
- package/lib/Form/hooks/useInitConfigData.js +144 -63
- package/lib/Form/index.d.ts +11 -1
- package/lib/Form/index.js +73 -42
- package/lib/Form/modal.d.ts +92 -51
- package/lib/Input/ButtonInput.js +75 -53
- package/lib/Input/InputNumber.js +23 -14
- package/lib/Input/SelectInput.d.ts +16 -4
- package/lib/Input/SelectInput.js +125 -60
- package/lib/Input/defaultConfig.d.ts +3 -3
- package/lib/Input/defaultConfig.js +3 -3
- package/lib/Input/index.js +9 -9
- package/lib/Input/modal.d.ts +15 -11
- package/lib/PageHandler/ErrorComponent.js +49 -27
- package/lib/PageHandler/LoadingComponent.js +19 -15
- package/lib/PageHandler/index.js +9 -9
- package/lib/PageHandler/modal.d.ts +4 -4
- package/lib/RadioGroup/index.d.ts +12 -5
- package/lib/RadioGroup/index.js +48 -35
- package/lib/Select/components/AllSelect.d.ts +1 -1
- package/lib/Select/components/AllSelect.js +42 -20
- package/lib/Select/components/CheckBoxOption.d.ts +6 -3
- package/lib/Select/components/CheckBoxOption.js +14 -9
- package/lib/Select/components/DropdownComponent.d.ts +4 -4
- package/lib/Select/components/DropdownComponent.js +32 -19
- package/lib/Select/components/NoFindItem.d.ts +1 -1
- package/lib/Select/components/NoFindItem.js +13 -9
- package/lib/Select/components/NotFoundContent.d.ts +2 -2
- package/lib/Select/components/NotFoundContent.js +51 -29
- package/lib/Select/defaultConfig.d.ts +1 -1
- package/lib/Select/defaultConfig.js +21 -17
- package/lib/Select/hooks/changeHooks.d.ts +2 -2
- package/lib/Select/hooks/changeHooks.js +148 -72
- package/lib/Select/hooks/norHooks.d.ts +27 -9
- package/lib/Select/hooks/norHooks.js +52 -40
- package/lib/Select/index.d.ts +22 -1
- package/lib/Select/index.js +128 -67
- package/lib/Select/modal.d.ts +15 -15
- package/lib/Select/utils.js +61 -16
- package/lib/Submit/index.d.ts +9 -3
- package/lib/Submit/index.js +20 -15
- package/lib/Switch/index.d.ts +4 -4
- package/lib/Switch/index.js +48 -22
- package/lib/TDPicker/RangePicker.d.ts +8 -3
- package/lib/TDPicker/RangePicker.js +136 -64
- package/lib/TDPicker/TimePicker.d.ts +6 -1
- package/lib/TDPicker/TimePicker.js +21 -15
- package/lib/TDPicker/hooks.d.ts +42 -22
- package/lib/TDPicker/hooks.js +98 -72
- package/lib/TDPicker/index.d.ts +7 -1
- package/lib/TDPicker/index.js +22 -16
- package/lib/TDPicker/modal.d.ts +21 -16
- package/lib/Upload/Btn.d.ts +5 -1
- package/lib/Upload/Btn.js +37 -21
- package/lib/Upload/MediaTypeEle/TypeEle.d.ts +10 -5
- package/lib/Upload/MediaTypeEle/TypeEle.js +33 -25
- package/lib/Upload/MediaTypeEle/index.d.ts +5 -1
- package/lib/Upload/MediaTypeEle/index.js +23 -20
- package/lib/Upload/Preview/index.d.ts +5 -1
- package/lib/Upload/Preview/index.js +19 -15
- package/lib/Upload/UrlUpload/index.d.ts +7 -1
- package/lib/Upload/UrlUpload/index.js +74 -53
- package/lib/Upload/enums.d.ts +3 -3
- package/lib/Upload/enums.js +4 -4
- package/lib/Upload/hooks/change.d.ts +8 -1
- package/lib/Upload/hooks/change.js +116 -59
- package/lib/Upload/hooks/customRequest.d.ts +5 -1
- package/lib/Upload/hooks/customRequest.js +64 -47
- package/lib/Upload/hooks/propsMaker.d.ts +5 -1
- package/lib/Upload/hooks/propsMaker.js +55 -15
- package/lib/Upload/index.d.ts +3 -1
- package/lib/Upload/index.js +133 -63
- package/lib/Upload/modal.d.ts +17 -15
- package/lib/Upload/util.d.ts +8 -2
- package/lib/Upload/util.js +16 -8
- package/lib/config.js +35 -32
- package/lib/hooks/index.d.ts +14 -7
- package/lib/hooks/index.js +125 -50
- package/lib/index.d.ts +98 -16
- package/lib/index.js +5 -5
- package/lib/modal.d.ts +6 -6
- package/package.json +2 -2
- package/src/components/CheckboxGroup/index.tsx +2 -2
- package/src/components/Form/FormItem/Helper.tsx +3 -4
- package/src/components/Form/HFormConnect.tsx +6 -2
- package/src/components/Form/hooks/useHForm.ts +59 -10
- package/src/components/Form/modal.ts +12 -8
- package/src/components/TDPicker/RangePicker.tsx +7 -5
- package/src/components/TDPicker/modal.ts +1 -0
- package/src/pages/Form/index.tsx +2 -2
|
@@ -1,29 +1,76 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
|
|
5
|
-
var _Object$
|
|
6
|
-
var
|
|
7
|
-
var
|
|
8
|
-
var _Object$
|
|
9
|
-
var _Object$
|
|
10
|
-
var _Object$
|
|
11
|
-
var
|
|
12
|
-
var
|
|
13
|
-
var
|
|
14
|
-
var
|
|
15
|
-
var
|
|
16
|
-
var _Object$
|
|
17
|
-
var _mapInstanceProperty = require(
|
|
18
|
-
var antd = require(
|
|
19
|
-
var hooks = require(
|
|
20
|
-
var React = require(
|
|
21
|
-
var index = require(
|
|
22
|
-
var HFormConnect = require(
|
|
5
|
+
var _Object$getOwnPropertySymbols = require("@babel/runtime-corejs3/core-js/object/get-own-property-symbols");
|
|
6
|
+
var _filterInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/filter");
|
|
7
|
+
var _Object$getOwnPropertyDescriptor = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptor");
|
|
8
|
+
var _Object$getOwnPropertyDescriptors = require("@babel/runtime-corejs3/core-js/object/get-own-property-descriptors");
|
|
9
|
+
var _Object$defineProperties = require("@babel/runtime-corejs3/core-js/object/define-properties");
|
|
10
|
+
var _Object$defineProperty = require("@babel/runtime-corejs3/core-js/object/define-property");
|
|
11
|
+
var _extends = require("@babel/runtime-corejs3/helpers/extends");
|
|
12
|
+
var _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty");
|
|
13
|
+
var _objectWithoutProperties = require("@babel/runtime-corejs3/helpers/objectWithoutProperties");
|
|
14
|
+
var _forEachInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/for-each");
|
|
15
|
+
var _Object$values = require("@babel/runtime-corejs3/core-js/object/values");
|
|
16
|
+
var _Object$keys = require("@babel/runtime-corejs3/core-js/object/keys");
|
|
17
|
+
var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/map");
|
|
18
|
+
var antd = require("antd");
|
|
19
|
+
var hooks = require("./hooks.js");
|
|
20
|
+
var React = require("react");
|
|
21
|
+
var index = require("../hooks/index.js");
|
|
22
|
+
var HFormConnect = require("../Form/HFormConnect.js");
|
|
23
23
|
|
|
24
|
-
var _excluded = [
|
|
25
|
-
|
|
26
|
-
|
|
24
|
+
var _excluded = [
|
|
25
|
+
"value",
|
|
26
|
+
"onChange",
|
|
27
|
+
"showTime",
|
|
28
|
+
"format",
|
|
29
|
+
"valueMap",
|
|
30
|
+
"ranges",
|
|
31
|
+
"name",
|
|
32
|
+
"addFormat",
|
|
33
|
+
];
|
|
34
|
+
function ownKeys(object, enumerableOnly) {
|
|
35
|
+
var keys = _Object$keys(object);
|
|
36
|
+
if (_Object$getOwnPropertySymbols) {
|
|
37
|
+
var symbols = _Object$getOwnPropertySymbols(object);
|
|
38
|
+
enumerableOnly &&
|
|
39
|
+
(symbols = _filterInstanceProperty(symbols).call(symbols, function (sym) {
|
|
40
|
+
return _Object$getOwnPropertyDescriptor(object, sym).enumerable;
|
|
41
|
+
})),
|
|
42
|
+
keys.push.apply(keys, symbols);
|
|
43
|
+
}
|
|
44
|
+
return keys;
|
|
45
|
+
}
|
|
46
|
+
function _objectSpread(target) {
|
|
47
|
+
for (var i = 1; i < arguments.length; i++) {
|
|
48
|
+
var _context2, _context3;
|
|
49
|
+
var source = null != arguments[i] ? arguments[i] : {};
|
|
50
|
+
i % 2
|
|
51
|
+
? _forEachInstanceProperty(
|
|
52
|
+
(_context2 = ownKeys(Object(source), !0))
|
|
53
|
+
).call(_context2, function (key) {
|
|
54
|
+
_defineProperty(target, key, source[key]);
|
|
55
|
+
})
|
|
56
|
+
: _Object$getOwnPropertyDescriptors
|
|
57
|
+
? _Object$defineProperties(
|
|
58
|
+
target,
|
|
59
|
+
_Object$getOwnPropertyDescriptors(source)
|
|
60
|
+
)
|
|
61
|
+
: _forEachInstanceProperty((_context3 = ownKeys(Object(source)))).call(
|
|
62
|
+
_context3,
|
|
63
|
+
function (key) {
|
|
64
|
+
_Object$defineProperty(
|
|
65
|
+
target,
|
|
66
|
+
key,
|
|
67
|
+
_Object$getOwnPropertyDescriptor(source, key)
|
|
68
|
+
);
|
|
69
|
+
}
|
|
70
|
+
);
|
|
71
|
+
}
|
|
72
|
+
return target;
|
|
73
|
+
}
|
|
27
74
|
var RangePicker = antd.DatePicker.RangePicker;
|
|
28
75
|
var HRangePicker = function HRangePicker(_ref) {
|
|
29
76
|
var value = _ref.value,
|
|
@@ -40,51 +87,65 @@ var HRangePicker = function HRangePicker(_ref) {
|
|
|
40
87
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
41
88
|
var _useMatchConfigProps = index.useMatchConfigProps({
|
|
42
89
|
valueRangePickerValueMap: valueMap,
|
|
43
|
-
dateRanges: undefined
|
|
90
|
+
dateRanges: undefined,
|
|
44
91
|
}),
|
|
45
92
|
_useMatchConfigProps$ = _useMatchConfigProps.valueRangePickerValueMap,
|
|
46
|
-
valueRangePickerValueMap =
|
|
93
|
+
valueRangePickerValueMap =
|
|
94
|
+
_useMatchConfigProps$ === void 0 ? {} : _useMatchConfigProps$,
|
|
47
95
|
dateRanges = _useMatchConfigProps.dateRanges;
|
|
48
96
|
var dateMapKeys = hooks.useGetTimeKey({
|
|
49
97
|
valueMap: valueRangePickerValueMap,
|
|
50
|
-
name: name
|
|
98
|
+
name: name,
|
|
51
99
|
});
|
|
52
100
|
var paramsProvider = hooks.useRangeValueProvider({
|
|
53
|
-
valueMap: dateMapKeys
|
|
101
|
+
valueMap: dateMapKeys,
|
|
54
102
|
});
|
|
55
103
|
var timeVal = hooks.useRangePickerTimeVal({
|
|
56
104
|
value: value,
|
|
57
105
|
format: format,
|
|
58
|
-
valueMap: dateMapKeys
|
|
106
|
+
valueMap: dateMapKeys,
|
|
59
107
|
});
|
|
60
|
-
var defaultRanges = React.useMemo(
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
if (ranges === true) {
|
|
65
|
-
return dateRanges;
|
|
66
|
-
}
|
|
67
|
-
return ranges;
|
|
68
|
-
}, [ranges]);
|
|
69
|
-
addFormat === null || addFormat === void 0 ? void 0 : addFormat({
|
|
70
|
-
"float": {
|
|
71
|
-
inputValue: function inputValue(item, initValue) {
|
|
72
|
-
var _context;
|
|
73
|
-
var valueName = item.name;
|
|
74
|
-
var resultObj = {};
|
|
75
|
-
_forEachInstanceProperty(_context = _Object$values(dateMapKeys)).call(_context, function (key) {
|
|
76
|
-
resultObj[key] = initValue[key];
|
|
77
|
-
});
|
|
78
|
-
return _defineProperty({}, valueName, resultObj);
|
|
79
|
-
},
|
|
80
|
-
outputValue: function outputValue(item, _outputValue) {
|
|
81
|
-
var valueName = item.name;
|
|
82
|
-
var _outputValue$valueNam = _outputValue[valueName],
|
|
83
|
-
itemVal = _outputValue$valueNam === void 0 ? {} : _outputValue$valueNam;
|
|
84
|
-
return _objectSpread({}, itemVal);
|
|
108
|
+
var defaultRanges = React.useMemo(
|
|
109
|
+
function () {
|
|
110
|
+
if (!ranges) {
|
|
111
|
+
return null;
|
|
85
112
|
}
|
|
86
|
-
|
|
87
|
-
|
|
113
|
+
if (ranges === true) {
|
|
114
|
+
return dateRanges;
|
|
115
|
+
}
|
|
116
|
+
return ranges;
|
|
117
|
+
},
|
|
118
|
+
[ranges]
|
|
119
|
+
);
|
|
120
|
+
addFormat === null || addFormat === void 0
|
|
121
|
+
? void 0
|
|
122
|
+
: addFormat({
|
|
123
|
+
float: {
|
|
124
|
+
inputValue: function inputValue(item, initValue) {
|
|
125
|
+
var _context;
|
|
126
|
+
var _item$name = item.name,
|
|
127
|
+
valueName = _item$name === void 0 ? "" : _item$name;
|
|
128
|
+
var resultObj = {};
|
|
129
|
+
_forEachInstanceProperty(
|
|
130
|
+
(_context = _Object$values(dateMapKeys))
|
|
131
|
+
).call(_context, function (key) {
|
|
132
|
+
if (initValue[key]) {
|
|
133
|
+
resultObj[key] = initValue[key];
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
var hasKeys = _Object$keys(resultObj).length !== 0;
|
|
137
|
+
return _defineProperty({}, valueName, hasKeys ? resultObj : null);
|
|
138
|
+
},
|
|
139
|
+
outputValue: function outputValue(item, _outputValue) {
|
|
140
|
+
var _item$name2 = item.name,
|
|
141
|
+
valueName = _item$name2 === void 0 ? "" : _item$name2;
|
|
142
|
+
var _outputValue$valueNam = _outputValue[valueName],
|
|
143
|
+
itemVal =
|
|
144
|
+
_outputValue$valueNam === void 0 ? {} : _outputValue$valueNam;
|
|
145
|
+
return _objectSpread({}, itemVal);
|
|
146
|
+
},
|
|
147
|
+
},
|
|
148
|
+
});
|
|
88
149
|
var change = function change(val) {
|
|
89
150
|
if (!format || !val) {
|
|
90
151
|
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
@@ -93,26 +154,37 @@ var HRangePicker = function HRangePicker(_ref) {
|
|
|
93
154
|
var subVal = _mapInstanceProperty(val).call(val, function (item) {
|
|
94
155
|
return item === null || item === void 0 ? void 0 : item.format(format);
|
|
95
156
|
});
|
|
96
|
-
onChange === null || onChange === void 0
|
|
157
|
+
onChange === null || onChange === void 0
|
|
158
|
+
? void 0
|
|
159
|
+
: onChange(paramsProvider(subVal));
|
|
97
160
|
};
|
|
98
|
-
return /*#__PURE__*/React.createElement(
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
161
|
+
return /*#__PURE__*/ React.createElement(
|
|
162
|
+
RangePicker,
|
|
163
|
+
_extends(
|
|
164
|
+
{
|
|
165
|
+
value: timeVal,
|
|
166
|
+
onChange: change,
|
|
167
|
+
showTime: showTime,
|
|
168
|
+
ranges: defaultRanges,
|
|
169
|
+
},
|
|
170
|
+
props
|
|
171
|
+
)
|
|
172
|
+
);
|
|
104
173
|
};
|
|
105
174
|
var Index = HFormConnect.default(HRangePicker);
|
|
106
175
|
var HRangePicker$1 = {
|
|
107
176
|
Component: Index,
|
|
108
177
|
placeholder: function placeholder(_ref3) {
|
|
109
178
|
var label = _ref3.label;
|
|
110
|
-
return [
|
|
179
|
+
return [
|
|
180
|
+
"\u8BF7\u9009\u62E9\u5F00\u59CB".concat(label),
|
|
181
|
+
"\u8BF7\u9009\u62E9\u7ED3\u675F".concat(label),
|
|
182
|
+
];
|
|
111
183
|
},
|
|
112
184
|
requiredErrMsg: function requiredErrMsg(_ref4) {
|
|
113
185
|
var label = _ref4.label;
|
|
114
186
|
return "\u8BF7\u9009\u62E9".concat(label);
|
|
115
|
-
}
|
|
187
|
+
},
|
|
116
188
|
};
|
|
117
189
|
|
|
118
190
|
exports.default = HRangePicker$1;
|
|
@@ -1,4 +1,9 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HTimePickerProps } from "./modal";
|
|
3
|
-
declare const _default: ({
|
|
3
|
+
declare const _default: ({
|
|
4
|
+
value,
|
|
5
|
+
format,
|
|
6
|
+
onChange,
|
|
7
|
+
...props
|
|
8
|
+
}: HTimePickerProps) => JSX.Element;
|
|
4
9
|
export default _default;
|
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
Object.defineProperty(exports,
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
4
|
|
|
5
|
-
var React = require(
|
|
6
|
-
var _extends = require(
|
|
7
|
-
var _objectWithoutProperties = require(
|
|
8
|
-
var antd = require(
|
|
9
|
-
var hooks = require(
|
|
5
|
+
var React = require("react");
|
|
6
|
+
var _extends = require("@babel/runtime-corejs3/helpers/extends");
|
|
7
|
+
var _objectWithoutProperties = require("@babel/runtime-corejs3/helpers/objectWithoutProperties");
|
|
8
|
+
var antd = require("antd");
|
|
9
|
+
var hooks = require("./hooks.js");
|
|
10
10
|
|
|
11
11
|
var _excluded = ["value", "format", "onChange"];
|
|
12
|
-
var HTimePicker =
|
|
12
|
+
var HTimePicker = function (_ref) {
|
|
13
13
|
var value = _ref.value,
|
|
14
14
|
_ref$format = _ref.format,
|
|
15
15
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
@@ -17,18 +17,24 @@ var HTimePicker = (function (_ref) {
|
|
|
17
17
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
18
18
|
var timeVal = hooks.useTimePickerValue({
|
|
19
19
|
value: value,
|
|
20
|
-
format: format
|
|
20
|
+
format: format,
|
|
21
21
|
});
|
|
22
22
|
var change = hooks.useTimePickerChange({
|
|
23
23
|
value: value,
|
|
24
24
|
format: format,
|
|
25
|
-
onChange: onChange
|
|
25
|
+
onChange: onChange,
|
|
26
26
|
});
|
|
27
|
-
return /*#__PURE__*/React.createElement(
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
27
|
+
return /*#__PURE__*/ React.createElement(
|
|
28
|
+
antd.TimePicker,
|
|
29
|
+
_extends(
|
|
30
|
+
{
|
|
31
|
+
value: timeVal,
|
|
32
|
+
onChange: change,
|
|
33
|
+
},
|
|
34
|
+
props
|
|
35
|
+
)
|
|
36
|
+
);
|
|
37
|
+
};
|
|
32
38
|
|
|
33
39
|
exports.default = HTimePicker;
|
|
34
40
|
// powered by h
|
package/lib/TDPicker/hooks.d.ts
CHANGED
|
@@ -2,32 +2,52 @@ import type { Moment, DurationInputArg2 } from "moment";
|
|
|
2
2
|
import type { HRangePickerProps } from "./modal";
|
|
3
3
|
import type { DateRangePickerValueMapModal } from "../modal";
|
|
4
4
|
interface UseTimeValParams {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
5
|
+
value?: any | [any, any];
|
|
6
|
+
format?: string;
|
|
7
|
+
valueMap?: DateRangePickerValueMapModal;
|
|
8
8
|
}
|
|
9
9
|
interface UseTimePickerValParams {
|
|
10
|
-
|
|
11
|
-
|
|
10
|
+
value?: any;
|
|
11
|
+
format?: string | DurationInputArg2;
|
|
12
12
|
}
|
|
13
13
|
interface UseTimeChangeParams {
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
format?: string;
|
|
15
|
+
onChange?: (time?: Moment | string | number) => void;
|
|
16
|
+
value?: any;
|
|
17
17
|
}
|
|
18
18
|
export declare const useTimeVal: ({ value, format }: UseTimeValParams) => any;
|
|
19
|
-
export declare const useGetTimeKey: ({ valueMap, name
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
export declare const
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
};
|
|
32
|
-
export declare const
|
|
19
|
+
export declare const useGetTimeKey: ({ valueMap, name }: HRangePickerProps) =>
|
|
20
|
+
| {
|
|
21
|
+
start?: undefined;
|
|
22
|
+
end?: undefined;
|
|
23
|
+
}
|
|
24
|
+
| {
|
|
25
|
+
start: string;
|
|
26
|
+
end: string;
|
|
27
|
+
};
|
|
28
|
+
export declare const useTimeChange: ({
|
|
29
|
+
format,
|
|
30
|
+
onChange,
|
|
31
|
+
}: UseTimeChangeParams) => (value: any) => void;
|
|
32
|
+
export declare const useTimePickerValue: ({
|
|
33
|
+
value,
|
|
34
|
+
format,
|
|
35
|
+
}: UseTimePickerValParams) => any;
|
|
36
|
+
export declare const useTimePickerChange: ({
|
|
37
|
+
value,
|
|
38
|
+
format,
|
|
39
|
+
onChange,
|
|
40
|
+
}: UseTimeChangeParams) => (val: any) => void;
|
|
41
|
+
export declare const useRangeValueProvider: ({
|
|
42
|
+
valueMap,
|
|
43
|
+
}: HRangePickerProps) => (val: any[]) =>
|
|
44
|
+
| any[]
|
|
45
|
+
| {
|
|
46
|
+
[x: string]: any;
|
|
47
|
+
};
|
|
48
|
+
export declare const useRangePickerTimeVal: ({
|
|
49
|
+
value,
|
|
50
|
+
format,
|
|
51
|
+
valueMap,
|
|
52
|
+
}: UseTimeValParams) => any;
|
|
33
53
|
export {};
|
package/lib/TDPicker/hooks.js
CHANGED
|
@@ -1,20 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
"use strict";
|
|
2
2
|
|
|
3
|
-
var _defineProperty = require(
|
|
4
|
-
var _Array$isArray = require(
|
|
5
|
-
var _mapInstanceProperty = require(
|
|
6
|
-
var React = require(
|
|
7
|
-
var moment = require(
|
|
3
|
+
var _defineProperty = require("@babel/runtime-corejs3/helpers/defineProperty");
|
|
4
|
+
var _Array$isArray = require("@babel/runtime-corejs3/core-js/array/is-array");
|
|
5
|
+
var _mapInstanceProperty = require("@babel/runtime-corejs3/core-js/instance/map");
|
|
6
|
+
var React = require("react");
|
|
7
|
+
var moment = require("moment");
|
|
8
8
|
|
|
9
9
|
var useTimeVal = function useTimeVal(_ref) {
|
|
10
10
|
var value = _ref.value,
|
|
11
11
|
format = _ref.format;
|
|
12
|
-
return React.useMemo(
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
12
|
+
return React.useMemo(
|
|
13
|
+
function () {
|
|
14
|
+
if (!value || !format) {
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
return moment(value, format);
|
|
18
|
+
},
|
|
19
|
+
[value, format]
|
|
20
|
+
);
|
|
18
21
|
};
|
|
19
22
|
var useGetTimeKey = function useGetTimeKey(_ref2) {
|
|
20
23
|
var _ref2$valueMap = _ref2.valueMap,
|
|
@@ -30,57 +33,72 @@ var useGetTimeKey = function useGetTimeKey(_ref2) {
|
|
|
30
33
|
var endKey = typeof end === "string" ? end : end(name);
|
|
31
34
|
return {
|
|
32
35
|
start: startKey,
|
|
33
|
-
end: endKey
|
|
36
|
+
end: endKey,
|
|
34
37
|
};
|
|
35
38
|
};
|
|
36
39
|
var useTimeChange = function useTimeChange(_ref3) {
|
|
37
40
|
var format = _ref3.format,
|
|
38
41
|
onChange = _ref3.onChange;
|
|
39
|
-
return React.useCallback(
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
42
|
+
return React.useCallback(
|
|
43
|
+
function (value) {
|
|
44
|
+
if (!format) {
|
|
45
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(value);
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
var subVal =
|
|
49
|
+
value === null || value === void 0 ? void 0 : value.format(format);
|
|
50
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(subVal);
|
|
51
|
+
},
|
|
52
|
+
[format, onChange]
|
|
53
|
+
);
|
|
47
54
|
};
|
|
48
55
|
var formatMap = {
|
|
49
56
|
X: "s",
|
|
50
|
-
x: "ms"
|
|
57
|
+
x: "ms",
|
|
51
58
|
};
|
|
52
59
|
var useTimePickerValue = function useTimePickerValue(_ref4) {
|
|
53
60
|
var value = _ref4.value,
|
|
54
61
|
format = _ref4.format;
|
|
55
|
-
return React.useMemo(
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
62
|
+
return React.useMemo(
|
|
63
|
+
function () {
|
|
64
|
+
if (!value || !format) {
|
|
65
|
+
return value;
|
|
66
|
+
}
|
|
67
|
+
if (formatMap[format]) {
|
|
68
|
+
var timeStr = moment()
|
|
69
|
+
.startOf("days")
|
|
70
|
+
.add(value, formatMap[format])
|
|
71
|
+
.format("HH:mm:ss");
|
|
72
|
+
return moment(timeStr, "HH:mm:ss");
|
|
73
|
+
}
|
|
74
|
+
return moment(value, format);
|
|
75
|
+
},
|
|
76
|
+
[value, format]
|
|
77
|
+
);
|
|
65
78
|
};
|
|
66
79
|
var useTimePickerChange = function useTimePickerChange(_ref5) {
|
|
67
80
|
var value = _ref5.value,
|
|
68
81
|
format = _ref5.format,
|
|
69
82
|
onChange = _ref5.onChange;
|
|
70
|
-
return React.useCallback(
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
83
|
+
return React.useCallback(
|
|
84
|
+
function (val) {
|
|
85
|
+
if (!format || !val) {
|
|
86
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(val);
|
|
87
|
+
return;
|
|
88
|
+
}
|
|
89
|
+
if (formatMap[format]) {
|
|
90
|
+
var startTime = moment().startOf("days").format(format);
|
|
91
|
+
var nowTime = val.format(format);
|
|
92
|
+
onChange === null || onChange === void 0
|
|
93
|
+
? void 0
|
|
94
|
+
: onChange(nowTime - startTime);
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
var subVal = val === null || val === void 0 ? void 0 : val.format(format);
|
|
98
|
+
onChange === null || onChange === void 0 ? void 0 : onChange(subVal);
|
|
99
|
+
},
|
|
100
|
+
[format, onChange, value]
|
|
101
|
+
);
|
|
84
102
|
};
|
|
85
103
|
var useRangeValueProvider = function useRangeValueProvider(_ref6) {
|
|
86
104
|
var _ref6$valueMap = _ref6.valueMap,
|
|
@@ -92,7 +110,12 @@ var useRangeValueProvider = function useRangeValueProvider(_ref6) {
|
|
|
92
110
|
if (!start || !end) {
|
|
93
111
|
return val;
|
|
94
112
|
}
|
|
95
|
-
return
|
|
113
|
+
return (
|
|
114
|
+
(_ref7 = {}),
|
|
115
|
+
_defineProperty(_ref7, start, val[0]),
|
|
116
|
+
_defineProperty(_ref7, end, val[1]),
|
|
117
|
+
_ref7
|
|
118
|
+
);
|
|
96
119
|
};
|
|
97
120
|
};
|
|
98
121
|
var useRangePickerTimeVal = function useRangePickerTimeVal(_ref8) {
|
|
@@ -100,33 +123,36 @@ var useRangePickerTimeVal = function useRangePickerTimeVal(_ref8) {
|
|
|
100
123
|
format = _ref8.format,
|
|
101
124
|
_ref8$valueMap = _ref8.valueMap,
|
|
102
125
|
valueMap = _ref8$valueMap === void 0 ? {} : _ref8$valueMap;
|
|
103
|
-
return React.useMemo(
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
if (!_Array$isArray(value)) {
|
|
108
|
-
var start = valueMap.start,
|
|
109
|
-
end = valueMap.end;
|
|
110
|
-
if (!start || !end) {
|
|
111
|
-
console.error("日期value格式错误!");
|
|
112
|
-
return;
|
|
126
|
+
return React.useMemo(
|
|
127
|
+
function () {
|
|
128
|
+
if (!value || !format) {
|
|
129
|
+
return value;
|
|
113
130
|
}
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
131
|
+
if (!_Array$isArray(value)) {
|
|
132
|
+
var start = valueMap.start,
|
|
133
|
+
end = valueMap.end;
|
|
134
|
+
if (!start || !end) {
|
|
135
|
+
console.error("日期value格式错误!");
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
var startTime = value[start],
|
|
139
|
+
endTime = value[end];
|
|
140
|
+
if (!startTime && !endTime) {
|
|
141
|
+
return [];
|
|
142
|
+
}
|
|
143
|
+
var startMoment = moment(startTime, format);
|
|
144
|
+
var endMoment = moment(endTime, format);
|
|
145
|
+
return [startMoment, endMoment];
|
|
126
146
|
}
|
|
127
|
-
return
|
|
128
|
-
|
|
129
|
-
|
|
147
|
+
return _mapInstanceProperty(value).call(value, function (item) {
|
|
148
|
+
if (!item) {
|
|
149
|
+
return item;
|
|
150
|
+
}
|
|
151
|
+
return moment(item, format);
|
|
152
|
+
});
|
|
153
|
+
},
|
|
154
|
+
[value, format, valueMap]
|
|
155
|
+
);
|
|
130
156
|
};
|
|
131
157
|
|
|
132
158
|
exports.useGetTimeKey = useGetTimeKey;
|
package/lib/TDPicker/index.d.ts
CHANGED
|
@@ -1,4 +1,10 @@
|
|
|
1
1
|
/// <reference types="react" />
|
|
2
2
|
import type { HDatePickerProps } from "./modal";
|
|
3
|
-
declare const _default: ({
|
|
3
|
+
declare const _default: ({
|
|
4
|
+
value,
|
|
5
|
+
onChange,
|
|
6
|
+
showTime,
|
|
7
|
+
format,
|
|
8
|
+
...props
|
|
9
|
+
}: HDatePickerProps) => JSX.Element;
|
|
4
10
|
export default _default;
|