@hw-component/form 0.0.8-beta-v4 → 0.0.8-beta-v6
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/Form/HFormConnect.js +21 -14
- package/es/Form/config.js +4 -4
- package/es/Form/hooks/useHForm.js +2 -1
- package/es/Form/modal.d.ts +4 -2
- package/es/TDPicker/TimePicker.d.ts +2 -2
- package/es/TDPicker/TimePicker.js +7 -3
- package/es/TDPicker/index.d.ts +2 -3
- package/es/TDPicker/index.js +6 -2
- package/es/TDPicker/modal.d.ts +2 -0
- package/lib/Form/HFormConnect.js +21 -14
- package/lib/Form/hooks/useHForm.js +2 -1
- package/lib/Form/modal.d.ts +4 -2
- package/lib/TDPicker/TimePicker.d.ts +2 -2
- package/lib/TDPicker/TimePicker.js +7 -3
- package/lib/TDPicker/index.d.ts +2 -3
- package/lib/TDPicker/index.js +6 -2
- package/lib/TDPicker/modal.d.ts +2 -0
- package/package.json +1 -1
- package/src/components/CheckboxGroup/hooks.ts +3 -3
- package/src/components/CheckboxGroup/index.tsx +4 -4
- package/src/components/Form/HFormConnect.tsx +19 -12
- package/src/components/Form/hooks/useHForm.ts +2 -1
- package/src/components/Form/modal.ts +4 -2
- package/src/components/TDPicker/TimePicker.tsx +5 -1
- package/src/components/TDPicker/index.tsx +4 -1
- package/src/components/TDPicker/modal.ts +2 -0
- package/src/pages/Checkbox/index.tsx +0 -7
- package/src/pages/Form/index.tsx +13 -1
package/es/Form/HFormConnect.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
// welcome to hoo hoo hoo
|
|
2
|
+
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
2
3
|
import 'core-js/modules/es.object.keys.js';
|
|
4
|
+
import 'core-js/modules/es.function.name.js';
|
|
3
5
|
import 'core-js/modules/es.symbol.js';
|
|
4
6
|
import 'core-js/modules/es.array.filter.js';
|
|
5
7
|
import 'core-js/modules/es.object.to-string.js';
|
|
6
8
|
import 'core-js/modules/es.object.get-own-property-descriptor.js';
|
|
7
9
|
import 'core-js/modules/web.dom-collections.for-each.js';
|
|
8
10
|
import 'core-js/modules/es.object.get-own-property-descriptors.js';
|
|
9
|
-
import _defineProperty from '@babel/runtime-corejs3/helpers/defineProperty';
|
|
10
|
-
import 'core-js/modules/es.function.name.js';
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
import { useFormContext } from './Context/index.js';
|
|
13
13
|
import React, { useEffect } from 'react';
|
|
@@ -15,19 +15,26 @@ import React, { useEffect } from 'react';
|
|
|
15
15
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
16
16
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
17
17
|
var formatMaker = function formatMaker(itemProps, formats) {
|
|
18
|
-
|
|
19
|
-
|
|
18
|
+
var _ref = formats || {},
|
|
19
|
+
inputValue = _ref.inputValue,
|
|
20
|
+
outputValue = _ref.outputValue;
|
|
21
|
+
var _itemProps$initValueP = itemProps.initValueProvider,
|
|
22
|
+
initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
|
|
23
|
+
_itemProps$subProvide = itemProps.subProvider,
|
|
24
|
+
subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
|
|
25
|
+
var resultObj = {};
|
|
26
|
+
if (initValueProvider) {
|
|
27
|
+
resultObj.inputValue = function (value) {
|
|
28
|
+
return initValueProvider(itemProps, value);
|
|
29
|
+
};
|
|
20
30
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
return _outputValue(itemProps, value);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
+
if (subProvider) {
|
|
32
|
+
resultObj.outputValue = function (value) {
|
|
33
|
+
return subProvider(itemProps, value);
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
var keysLen = Object.keys(resultObj).length;
|
|
37
|
+
return keysLen === 0 ? undefined : resultObj;
|
|
31
38
|
};
|
|
32
39
|
var HFormConnect = (function (component) {
|
|
33
40
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
package/es/Form/config.js
CHANGED
|
@@ -8,11 +8,11 @@ import HCheckboxGroup from '../CheckboxGroup/index.js';
|
|
|
8
8
|
import Index$1 from '../CheckboxGroup/CheckBox/index.js';
|
|
9
9
|
import HRadioGroup from '../RadioGroup/index.js';
|
|
10
10
|
import Index$2 from '../Switch/index.js';
|
|
11
|
-
import
|
|
11
|
+
import HDatePicker from '../TDPicker/index.js';
|
|
12
12
|
import HRangePicker from '../TDPicker/RangePicker.js';
|
|
13
13
|
import HTimePicker from '../TDPicker/TimePicker.js';
|
|
14
14
|
import HUpload from '../Upload/index.js';
|
|
15
|
-
import Index$
|
|
15
|
+
import Index$3 from '../Upload/UrlUpload/index.js';
|
|
16
16
|
import HSubmit from '../Submit/index.js';
|
|
17
17
|
import TextArea from '../TextArea/index.js';
|
|
18
18
|
import ColorInput from '../Input/ColorInput/index.js';
|
|
@@ -32,12 +32,12 @@ var componentConfig = {
|
|
|
32
32
|
checkBox: Index$1,
|
|
33
33
|
radioGroup: HRadioGroup,
|
|
34
34
|
switch: Index$2,
|
|
35
|
-
datePicker:
|
|
35
|
+
datePicker: HDatePicker,
|
|
36
36
|
rangePicker: HRangePicker,
|
|
37
37
|
timePicker: HTimePicker,
|
|
38
38
|
input: HInput,
|
|
39
39
|
upload: HUpload,
|
|
40
|
-
urlUpload: Index$
|
|
40
|
+
urlUpload: Index$3,
|
|
41
41
|
submit: HSubmit,
|
|
42
42
|
textArea: TextArea,
|
|
43
43
|
colorInput: ColorInput,
|
|
@@ -165,7 +165,8 @@ var useHForm = (function () {
|
|
|
165
165
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
166
166
|
},
|
|
167
167
|
outputValues: function outputValues(value) {
|
|
168
|
-
|
|
168
|
+
var val = value || form.getFieldsValue();
|
|
169
|
+
return this.formatValues(val, "outputValue");
|
|
169
170
|
}
|
|
170
171
|
}, form), {}, {
|
|
171
172
|
setFieldsValue: function setFieldsValue(values) {
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface HFormItemProps extends HItemProps {
|
|
|
60
60
|
value?: any;
|
|
61
61
|
onChange?: (val: any, item: any) => void;
|
|
62
62
|
itemSpan?: ColProps;
|
|
63
|
+
initValueProvider?: AddValueFormat;
|
|
64
|
+
subProvider?: AddValueFormat;
|
|
63
65
|
}
|
|
64
66
|
export type argsFn = (...args: any[]) => void;
|
|
65
67
|
export interface FormContextProps {
|
|
@@ -110,8 +112,8 @@ export interface ConnectConfigModal {
|
|
|
110
112
|
}
|
|
111
113
|
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
112
114
|
export interface FormatItemModal {
|
|
113
|
-
inputValue
|
|
114
|
-
outputValue
|
|
115
|
+
inputValue?: ValueFormat;
|
|
116
|
+
outputValue?: ValueFormat;
|
|
115
117
|
}
|
|
116
118
|
type AddValueFormat = (item: HFormItemProps, value: Record<string, any>) => Record<string, any>;
|
|
117
119
|
export interface addFormatItemModal {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: (
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
|
@@ -11,17 +11,20 @@ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWitho
|
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
import { TimePicker } from 'antd';
|
|
13
13
|
import { useTimePickerValue, useTimePickerChange } from './hooks.js';
|
|
14
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
14
15
|
|
|
15
|
-
var _excluded = ["value", "format", "onChange", "disabledDate"];
|
|
16
|
+
var _excluded = ["value", "format", "onChange", "addFormat", "disabledDate"];
|
|
16
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
|
-
var
|
|
19
|
+
var Index = function Index(_ref) {
|
|
19
20
|
var value = _ref.value,
|
|
20
21
|
_ref$format = _ref.format,
|
|
21
22
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
22
23
|
onChange = _ref.onChange,
|
|
24
|
+
addFormat = _ref.addFormat,
|
|
23
25
|
_disabledDate = _ref.disabledDate,
|
|
24
26
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
27
|
+
addFormat === null || addFormat === void 0 || addFormat({});
|
|
25
28
|
var timeVal = useTimePickerValue({
|
|
26
29
|
value: value,
|
|
27
30
|
format: format
|
|
@@ -38,7 +41,8 @@ var HTimePicker = (function (_ref) {
|
|
|
38
41
|
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
39
42
|
}
|
|
40
43
|
}, props));
|
|
41
|
-
}
|
|
44
|
+
};
|
|
45
|
+
var HTimePicker = HFormConnect(Index);
|
|
42
46
|
|
|
43
47
|
export { HTimePicker as default };
|
|
44
48
|
// powered by hdj
|
package/es/TDPicker/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HDatePickerProps } from "./modal";
|
|
2
1
|
import React from "react";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
3
|
+
export default _default;
|
package/es/TDPicker/index.js
CHANGED
|
@@ -11,8 +11,9 @@ import _objectWithoutProperties from '@babel/runtime-corejs3/helpers/objectWitho
|
|
|
11
11
|
import { jsx } from 'react/jsx-runtime';
|
|
12
12
|
import { DatePicker } from 'antd';
|
|
13
13
|
import { useTimeVal, useTimeChange } from './hooks.js';
|
|
14
|
+
import HFormConnect from '../Form/HFormConnect.js';
|
|
14
15
|
|
|
15
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate"];
|
|
16
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
|
|
16
17
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
17
18
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
18
19
|
var Picker = DatePicker;
|
|
@@ -24,7 +25,9 @@ var Index = function Index(_ref) {
|
|
|
24
25
|
_ref$format = _ref.format,
|
|
25
26
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
26
27
|
_disabledDate = _ref.disabledDate,
|
|
28
|
+
addFormat = _ref.addFormat,
|
|
27
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
addFormat === null || addFormat === void 0 || addFormat({});
|
|
28
31
|
var timeVal = useTimeVal({
|
|
29
32
|
value: value,
|
|
30
33
|
format: format
|
|
@@ -42,6 +45,7 @@ var Index = function Index(_ref) {
|
|
|
42
45
|
}
|
|
43
46
|
}, props));
|
|
44
47
|
};
|
|
48
|
+
var HDatePicker = HFormConnect(Index);
|
|
45
49
|
|
|
46
|
-
export {
|
|
50
|
+
export { HDatePicker as default };
|
|
47
51
|
// powered by hdj
|
package/es/TDPicker/modal.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface HDatePickerProps extends Omit<DatePickerProps, "onChange" | "fo
|
|
|
14
14
|
format?: string;
|
|
15
15
|
showTime?: boolean | SharedTimeProps<Moment>;
|
|
16
16
|
disabledDate?: DisabledDateFnModal;
|
|
17
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
17
18
|
}
|
|
18
19
|
export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "format" | "ranges" | "value" | "disabledDate"> {
|
|
19
20
|
value?: [any, any] | Record<string, any>;
|
|
@@ -31,5 +32,6 @@ export interface HTimePickerProps extends Omit<TimePickerProps, "onChange" | "fo
|
|
|
31
32
|
onChange?: (time?: Moment | string | number) => void;
|
|
32
33
|
format?: DurationInputArg2 | string;
|
|
33
34
|
disabledDate?: DisabledDateFnModal;
|
|
35
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
34
36
|
}
|
|
35
37
|
export {};
|
package/lib/Form/HFormConnect.js
CHANGED
|
@@ -2,15 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
|
+
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
5
6
|
require('core-js/modules/es.object.keys.js');
|
|
7
|
+
require('core-js/modules/es.function.name.js');
|
|
6
8
|
require('core-js/modules/es.symbol.js');
|
|
7
9
|
require('core-js/modules/es.array.filter.js');
|
|
8
10
|
require('core-js/modules/es.object.to-string.js');
|
|
9
11
|
require('core-js/modules/es.object.get-own-property-descriptor.js');
|
|
10
12
|
require('core-js/modules/web.dom-collections.for-each.js');
|
|
11
13
|
require('core-js/modules/es.object.get-own-property-descriptors.js');
|
|
12
|
-
var _defineProperty = require('@babel/runtime-corejs3/helpers/defineProperty');
|
|
13
|
-
require('core-js/modules/es.function.name.js');
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
var index = require('./Context/index.js');
|
|
16
16
|
var React = require('react');
|
|
@@ -18,19 +18,26 @@ var React = require('react');
|
|
|
18
18
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
19
19
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
20
20
|
var formatMaker = function formatMaker(itemProps, formats) {
|
|
21
|
-
|
|
22
|
-
|
|
21
|
+
var _ref = formats || {},
|
|
22
|
+
inputValue = _ref.inputValue,
|
|
23
|
+
outputValue = _ref.outputValue;
|
|
24
|
+
var _itemProps$initValueP = itemProps.initValueProvider,
|
|
25
|
+
initValueProvider = _itemProps$initValueP === void 0 ? inputValue : _itemProps$initValueP,
|
|
26
|
+
_itemProps$subProvide = itemProps.subProvider,
|
|
27
|
+
subProvider = _itemProps$subProvide === void 0 ? outputValue : _itemProps$subProvide;
|
|
28
|
+
var resultObj = {};
|
|
29
|
+
if (initValueProvider) {
|
|
30
|
+
resultObj.inputValue = function (value) {
|
|
31
|
+
return initValueProvider(itemProps, value);
|
|
32
|
+
};
|
|
23
33
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
return _outputValue(itemProps, value);
|
|
32
|
-
}
|
|
33
|
-
};
|
|
34
|
+
if (subProvider) {
|
|
35
|
+
resultObj.outputValue = function (value) {
|
|
36
|
+
return subProvider(itemProps, value);
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
var keysLen = Object.keys(resultObj).length;
|
|
40
|
+
return keysLen === 0 ? undefined : resultObj;
|
|
34
41
|
};
|
|
35
42
|
var HFormConnect = (function (component) {
|
|
36
43
|
var config = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : {};
|
|
@@ -168,7 +168,8 @@ var useHForm = (function () {
|
|
|
168
168
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
169
169
|
},
|
|
170
170
|
outputValues: function outputValues(value) {
|
|
171
|
-
|
|
171
|
+
var val = value || form.getFieldsValue();
|
|
172
|
+
return this.formatValues(val, "outputValue");
|
|
172
173
|
}
|
|
173
174
|
}, form), {}, {
|
|
174
175
|
setFieldsValue: function setFieldsValue(values) {
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -60,6 +60,8 @@ export interface HFormItemProps extends HItemProps {
|
|
|
60
60
|
value?: any;
|
|
61
61
|
onChange?: (val: any, item: any) => void;
|
|
62
62
|
itemSpan?: ColProps;
|
|
63
|
+
initValueProvider?: AddValueFormat;
|
|
64
|
+
subProvider?: AddValueFormat;
|
|
63
65
|
}
|
|
64
66
|
export type argsFn = (...args: any[]) => void;
|
|
65
67
|
export interface FormContextProps {
|
|
@@ -110,8 +112,8 @@ export interface ConnectConfigModal {
|
|
|
110
112
|
}
|
|
111
113
|
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
112
114
|
export interface FormatItemModal {
|
|
113
|
-
inputValue
|
|
114
|
-
outputValue
|
|
115
|
+
inputValue?: ValueFormat;
|
|
116
|
+
outputValue?: ValueFormat;
|
|
115
117
|
}
|
|
116
118
|
type AddValueFormat = (item: HFormItemProps, value: Record<string, any>) => Record<string, any>;
|
|
117
119
|
export interface addFormatItemModal {
|
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
|
|
2
|
-
declare const _default: (
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
declare const _default: import("react").ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & import("react").RefAttributes<any>>;
|
|
3
3
|
export default _default;
|
|
@@ -14,17 +14,20 @@ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWit
|
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
var antd = require('antd');
|
|
16
16
|
var hooks = require('./hooks.js');
|
|
17
|
+
var HFormConnect = require('../Form/HFormConnect.js');
|
|
17
18
|
|
|
18
|
-
var _excluded = ["value", "format", "onChange", "disabledDate"];
|
|
19
|
+
var _excluded = ["value", "format", "onChange", "addFormat", "disabledDate"];
|
|
19
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
21
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
|
-
var
|
|
22
|
+
var Index = function Index(_ref) {
|
|
22
23
|
var value = _ref.value,
|
|
23
24
|
_ref$format = _ref.format,
|
|
24
25
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
25
26
|
onChange = _ref.onChange,
|
|
27
|
+
addFormat = _ref.addFormat,
|
|
26
28
|
_disabledDate = _ref.disabledDate,
|
|
27
29
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
|
+
addFormat === null || addFormat === void 0 || addFormat({});
|
|
28
31
|
var timeVal = hooks.useTimePickerValue({
|
|
29
32
|
value: value,
|
|
30
33
|
format: format
|
|
@@ -41,7 +44,8 @@ var HTimePicker = (function (_ref) {
|
|
|
41
44
|
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
42
45
|
}
|
|
43
46
|
}, props));
|
|
44
|
-
}
|
|
47
|
+
};
|
|
48
|
+
var HTimePicker = HFormConnect.default(Index);
|
|
45
49
|
|
|
46
50
|
exports.default = HTimePicker;
|
|
47
51
|
// powered by h
|
package/lib/TDPicker/index.d.ts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import type { HDatePickerProps } from "./modal";
|
|
2
1
|
import React from "react";
|
|
3
|
-
declare const
|
|
4
|
-
export default
|
|
2
|
+
declare const _default: React.ForwardRefExoticComponent<import("../Form/modal").HFormItemProps & React.RefAttributes<any>>;
|
|
3
|
+
export default _default;
|
package/lib/TDPicker/index.js
CHANGED
|
@@ -14,8 +14,9 @@ var _objectWithoutProperties = require('@babel/runtime-corejs3/helpers/objectWit
|
|
|
14
14
|
var jsxRuntime = require('react/jsx-runtime');
|
|
15
15
|
var antd = require('antd');
|
|
16
16
|
var hooks = require('./hooks.js');
|
|
17
|
+
var HFormConnect = require('../Form/HFormConnect.js');
|
|
17
18
|
|
|
18
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate"];
|
|
19
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
|
|
19
20
|
function ownKeys(object, enumerableOnly) { var keys = Object.keys(object); if (Object.getOwnPropertySymbols) { var symbols = Object.getOwnPropertySymbols(object); enumerableOnly && (symbols = symbols.filter(function (sym) { return Object.getOwnPropertyDescriptor(object, sym).enumerable; })), keys.push.apply(keys, symbols); } return keys; }
|
|
20
21
|
function _objectSpread(target) { for (var i = 1; i < arguments.length; i++) { var source = null != arguments[i] ? arguments[i] : {}; i % 2 ? ownKeys(Object(source), !0).forEach(function (key) { _defineProperty(target, key, source[key]); }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(target, Object.getOwnPropertyDescriptors(source)) : ownKeys(Object(source)).forEach(function (key) { Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key)); }); } return target; }
|
|
21
22
|
var Picker = antd.DatePicker;
|
|
@@ -27,7 +28,9 @@ var Index = function Index(_ref) {
|
|
|
27
28
|
_ref$format = _ref.format,
|
|
28
29
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
29
30
|
_disabledDate = _ref.disabledDate,
|
|
31
|
+
addFormat = _ref.addFormat,
|
|
30
32
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
|
+
addFormat === null || addFormat === void 0 || addFormat({});
|
|
31
34
|
var timeVal = hooks.useTimeVal({
|
|
32
35
|
value: value,
|
|
33
36
|
format: format
|
|
@@ -45,6 +48,7 @@ var Index = function Index(_ref) {
|
|
|
45
48
|
}
|
|
46
49
|
}, props));
|
|
47
50
|
};
|
|
51
|
+
var HDatePicker = HFormConnect.default(Index);
|
|
48
52
|
|
|
49
|
-
exports.default =
|
|
53
|
+
exports.default = HDatePicker;
|
|
50
54
|
// powered by h
|
package/lib/TDPicker/modal.d.ts
CHANGED
|
@@ -14,6 +14,7 @@ export interface HDatePickerProps extends Omit<DatePickerProps, "onChange" | "fo
|
|
|
14
14
|
format?: string;
|
|
15
15
|
showTime?: boolean | SharedTimeProps<Moment>;
|
|
16
16
|
disabledDate?: DisabledDateFnModal;
|
|
17
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
17
18
|
}
|
|
18
19
|
export interface HRangePickerProps extends Omit<RangePickerProps, "onChange" | "format" | "ranges" | "value" | "disabledDate"> {
|
|
19
20
|
value?: [any, any] | Record<string, any>;
|
|
@@ -31,5 +32,6 @@ export interface HTimePickerProps extends Omit<TimePickerProps, "onChange" | "fo
|
|
|
31
32
|
onChange?: (time?: Moment | string | number) => void;
|
|
32
33
|
format?: DurationInputArg2 | string;
|
|
33
34
|
disabledDate?: DisabledDateFnModal;
|
|
35
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
34
36
|
}
|
|
35
37
|
export {};
|
package/package.json
CHANGED
|
@@ -58,7 +58,7 @@ export const useValueProvider = ({
|
|
|
58
58
|
}, [valueMap]);
|
|
59
59
|
|
|
60
60
|
useEffect(() => {
|
|
61
|
-
const { checked
|
|
61
|
+
const { checked, noChecked } = oldValueCheckMap.valueMap;
|
|
62
62
|
if (!value) {
|
|
63
63
|
return;
|
|
64
64
|
}
|
|
@@ -68,8 +68,8 @@ export const useValueProvider = ({
|
|
|
68
68
|
}
|
|
69
69
|
setVal((oldVal) => {
|
|
70
70
|
const newVal = { ...oldVal };
|
|
71
|
-
Object.keys(newVal).forEach((key)=>{
|
|
72
|
-
newVal[key]=noChecked
|
|
71
|
+
Object.keys(newVal).forEach((key) => {
|
|
72
|
+
newVal[key] = noChecked;
|
|
73
73
|
});
|
|
74
74
|
value.forEach((itemVal) => {
|
|
75
75
|
newVal[itemVal] = checked;
|
|
@@ -47,10 +47,10 @@ const Index = ({
|
|
|
47
47
|
outputValue: (item, outputValue) => {
|
|
48
48
|
const { name = "" } = item;
|
|
49
49
|
const { [name]: itemVal = {} } = outputValue;
|
|
50
|
-
if (Array.isArray(itemVal)){
|
|
51
|
-
return
|
|
52
|
-
[name]:itemVal
|
|
53
|
-
}
|
|
50
|
+
if (Array.isArray(itemVal)) {
|
|
51
|
+
return {
|
|
52
|
+
[name]: itemVal,
|
|
53
|
+
};
|
|
54
54
|
}
|
|
55
55
|
return {
|
|
56
56
|
...itemVal,
|
|
@@ -5,23 +5,30 @@ import type { ConnectConfigModal } from "@/components/Form/modal";
|
|
|
5
5
|
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
6
|
import type { ConnectResultProps } from "@/components/Form/modal";
|
|
7
7
|
import type { argsFn } from "@/components/Form/modal";
|
|
8
|
-
|
|
8
|
+
interface ResultModal {
|
|
9
|
+
inputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
10
|
+
outputValue?: (value: Record<string, any>) => Record<string, any>;
|
|
11
|
+
}
|
|
9
12
|
const formatMaker = (
|
|
10
13
|
itemProps: HFormItemProps,
|
|
11
14
|
formats?: addFormatItemModal
|
|
12
15
|
) => {
|
|
13
|
-
|
|
14
|
-
|
|
16
|
+
const { inputValue, outputValue } = formats || {};
|
|
17
|
+
const { initValueProvider = inputValue, subProvider = outputValue } =
|
|
18
|
+
itemProps;
|
|
19
|
+
const resultObj: ResultModal = {};
|
|
20
|
+
if (initValueProvider) {
|
|
21
|
+
resultObj.inputValue = (value) => {
|
|
22
|
+
return initValueProvider(itemProps, value);
|
|
23
|
+
};
|
|
15
24
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
},
|
|
24
|
-
};
|
|
25
|
+
if (subProvider) {
|
|
26
|
+
resultObj.outputValue = (value) => {
|
|
27
|
+
return subProvider(itemProps, value);
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
const keysLen = Object.keys(resultObj).length;
|
|
31
|
+
return keysLen === 0 ? undefined : resultObj;
|
|
25
32
|
};
|
|
26
33
|
|
|
27
34
|
export default (
|
|
@@ -140,7 +140,8 @@ export default () => {
|
|
|
140
140
|
Reflect.deleteProperty(dispatchSourceData, key);
|
|
141
141
|
},
|
|
142
142
|
outputValues(value) {
|
|
143
|
-
|
|
143
|
+
const val = value || form.getFieldsValue();
|
|
144
|
+
return this.formatValues(val, "outputValue");
|
|
144
145
|
},
|
|
145
146
|
...form,
|
|
146
147
|
setFieldsValue(values) {
|
|
@@ -107,6 +107,8 @@ export interface HFormItemProps extends HItemProps {
|
|
|
107
107
|
value?: any;
|
|
108
108
|
onChange?: (val: any, item: any) => void;
|
|
109
109
|
itemSpan?: ColProps;
|
|
110
|
+
initValueProvider?: AddValueFormat;
|
|
111
|
+
subProvider?: AddValueFormat;
|
|
110
112
|
}
|
|
111
113
|
export type argsFn = (...args: any[]) => void;
|
|
112
114
|
export interface FormContextProps {
|
|
@@ -167,8 +169,8 @@ export interface ConnectConfigModal {
|
|
|
167
169
|
type ValueFormat = (value: Record<string, any>) => Record<string, any>;
|
|
168
170
|
|
|
169
171
|
export interface FormatItemModal {
|
|
170
|
-
inputValue
|
|
171
|
-
outputValue
|
|
172
|
+
inputValue?: ValueFormat;
|
|
173
|
+
outputValue?: ValueFormat;
|
|
172
174
|
}
|
|
173
175
|
|
|
174
176
|
type AddValueFormat = (
|
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { TimePicker } from "antd";
|
|
2
2
|
import type { HTimePickerProps } from "./modal";
|
|
3
3
|
import { useTimePickerChange, useTimePickerValue } from "./hooks";
|
|
4
|
+
import HFormConnect from "../Form/HFormConnect";
|
|
4
5
|
|
|
5
|
-
|
|
6
|
+
const Index = ({
|
|
6
7
|
value,
|
|
7
8
|
format = "X",
|
|
8
9
|
onChange,
|
|
10
|
+
addFormat,
|
|
9
11
|
disabledDate,
|
|
10
12
|
...props
|
|
11
13
|
}: HTimePickerProps) => {
|
|
14
|
+
addFormat?.({});
|
|
12
15
|
const timeVal = useTimePickerValue({ value, format });
|
|
13
16
|
const change = useTimePickerChange({ value, format, onChange });
|
|
14
17
|
|
|
@@ -23,3 +26,4 @@ export default ({
|
|
|
23
26
|
/>
|
|
24
27
|
);
|
|
25
28
|
};
|
|
29
|
+
export default HFormConnect(Index);
|
|
@@ -2,6 +2,7 @@ import { DatePicker } from "antd";
|
|
|
2
2
|
import type { HDatePickerProps } from "./modal";
|
|
3
3
|
import { useTimeChange, useTimeVal } from "./hooks";
|
|
4
4
|
import React from "react";
|
|
5
|
+
import HFormConnect from "../Form/HFormConnect";
|
|
5
6
|
const Picker = DatePicker as any;
|
|
6
7
|
const Index: React.FC<HDatePickerProps> = ({
|
|
7
8
|
value,
|
|
@@ -9,8 +10,10 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
9
10
|
showTime = true,
|
|
10
11
|
format = "X",
|
|
11
12
|
disabledDate,
|
|
13
|
+
addFormat,
|
|
12
14
|
...props
|
|
13
15
|
}) => {
|
|
16
|
+
addFormat?.({});
|
|
14
17
|
const timeVal = useTimeVal({ value, format });
|
|
15
18
|
const change = useTimeChange({ format, onChange });
|
|
16
19
|
return (
|
|
@@ -25,4 +28,4 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
25
28
|
/>
|
|
26
29
|
);
|
|
27
30
|
};
|
|
28
|
-
export default Index;
|
|
31
|
+
export default HFormConnect(Index);
|
|
@@ -19,6 +19,7 @@ export interface HDatePickerProps
|
|
|
19
19
|
format?: string;
|
|
20
20
|
showTime?: boolean | SharedTimeProps<Moment>;
|
|
21
21
|
disabledDate?: DisabledDateFnModal;
|
|
22
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
22
23
|
}
|
|
23
24
|
export interface HRangePickerProps
|
|
24
25
|
extends Omit<
|
|
@@ -43,4 +44,5 @@ export interface HTimePickerProps
|
|
|
43
44
|
onChange?: (time?: Moment | string | number) => void;
|
|
44
45
|
format?: DurationInputArg2 | string;
|
|
45
46
|
disabledDate?: DisabledDateFnModal;
|
|
47
|
+
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
46
48
|
}
|
|
@@ -1,8 +1,6 @@
|
|
|
1
1
|
import { Space } from "antd";
|
|
2
2
|
import { HCheckboxGroup } from "../../components";
|
|
3
|
-
import {useState} from "react";
|
|
4
3
|
export default () => {
|
|
5
|
-
const [val,setVal]=useState();
|
|
6
4
|
return (
|
|
7
5
|
<Space size={"large"} direction={"vertical"} style={{ width: "100%" }}>
|
|
8
6
|
<HCheckboxGroup
|
|
@@ -10,11 +8,6 @@ export default () => {
|
|
|
10
8
|
{ label: "测试", value: "uu" },
|
|
11
9
|
{ label: "测试1", value: "uu1" },
|
|
12
10
|
]}
|
|
13
|
-
value={val}
|
|
14
|
-
|
|
15
|
-
onChange={(val)=>{
|
|
16
|
-
setVal(val)
|
|
17
|
-
}}
|
|
18
11
|
/>
|
|
19
12
|
</Space>
|
|
20
13
|
);
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -76,7 +76,6 @@ const formData = (options) => {
|
|
|
76
76
|
{ value: "选择1", key: "check1" },
|
|
77
77
|
{ value: "选择2", key: "check2" },
|
|
78
78
|
],
|
|
79
|
-
keyInValue:false
|
|
80
79
|
},
|
|
81
80
|
{
|
|
82
81
|
label: "开关",
|
|
@@ -90,6 +89,19 @@ const formData = (options) => {
|
|
|
90
89
|
type: "datePicker",
|
|
91
90
|
hover: "时间选择",
|
|
92
91
|
helper: "帮助我",
|
|
92
|
+
itemProps: {
|
|
93
|
+
subProvider: (item, val) => {
|
|
94
|
+
return {
|
|
95
|
+
datePicker: "fakfjkfjsklfjskljsak",
|
|
96
|
+
};
|
|
97
|
+
},
|
|
98
|
+
initValueProvider: (item, val) => {
|
|
99
|
+
console.log(val, "vvv");
|
|
100
|
+
return {
|
|
101
|
+
datePicker: 1706510695,
|
|
102
|
+
};
|
|
103
|
+
},
|
|
104
|
+
},
|
|
93
105
|
rules: [{ required: true }],
|
|
94
106
|
},
|
|
95
107
|
{
|