@hw-component/form 0.0.9-beta-v3 → 0.0.9-beta-v4
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/index.js +3 -1
- package/es/CheckboxGroup/modal.d.ts +1 -0
- package/es/TDPicker/index.js +6 -1
- package/lib/CheckboxGroup/index.js +3 -1
- package/lib/CheckboxGroup/modal.d.ts +1 -0
- package/lib/TDPicker/index.js +6 -1
- package/package.json +1 -1
- package/src/components/CheckboxGroup/index.tsx +2 -1
- package/src/components/CheckboxGroup/modal.ts +1 -0
- package/src/components/Form/hooks/useHForm.ts +13 -13
- package/src/components/Form/modal.ts +1 -1
- package/src/components/TDPicker/index.tsx +2 -0
- package/src/pages/Form/index.tsx +6 -5
|
@@ -27,7 +27,8 @@ var Index = function Index(_ref) {
|
|
|
27
27
|
disabled = _ref.disabled,
|
|
28
28
|
_ref$keyInValue = _ref.keyInValue,
|
|
29
29
|
keyInValue = _ref$keyInValue === void 0 ? true : _ref$keyInValue,
|
|
30
|
-
addFormat = _ref.addFormat
|
|
30
|
+
addFormat = _ref.addFormat,
|
|
31
|
+
direction = _ref.direction;
|
|
31
32
|
var _useMatchConfigProps = useMatchConfigProps({
|
|
32
33
|
fieldNames: fieldNames,
|
|
33
34
|
valueCheckMap: valueMap
|
|
@@ -74,6 +75,7 @@ var Index = function Index(_ref) {
|
|
|
74
75
|
}
|
|
75
76
|
});
|
|
76
77
|
return jsx(Space, {
|
|
78
|
+
direction: direction,
|
|
77
79
|
children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
|
|
78
80
|
var label = item.label,
|
|
79
81
|
itemVal = item.value;
|
|
@@ -11,4 +11,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
|
|
|
11
11
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
12
12
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
13
13
|
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
14
|
+
direction?: 'horizontal' | 'vertical';
|
|
14
15
|
}
|
package/es/TDPicker/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import { DatePicker } from 'antd';
|
|
|
13
13
|
import { useTimeVal, useTimeChange } from './hooks.js';
|
|
14
14
|
import HFormConnect from '../Form/HFormConnect.js';
|
|
15
15
|
|
|
16
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
|
|
16
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style"];
|
|
17
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; }
|
|
18
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; }
|
|
19
19
|
var Picker = DatePicker;
|
|
@@ -26,6 +26,10 @@ var Index = function Index(_ref) {
|
|
|
26
26
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
27
27
|
_disabledDate = _ref.disabledDate,
|
|
28
28
|
addFormat = _ref.addFormat,
|
|
29
|
+
_ref$style = _ref.style,
|
|
30
|
+
style = _ref$style === void 0 ? {
|
|
31
|
+
width: "100%"
|
|
32
|
+
} : _ref$style,
|
|
29
33
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
30
34
|
addFormat === null || addFormat === void 0 || addFormat({});
|
|
31
35
|
var timeVal = useTimeVal({
|
|
@@ -40,6 +44,7 @@ var Index = function Index(_ref) {
|
|
|
40
44
|
value: timeVal,
|
|
41
45
|
onChange: change,
|
|
42
46
|
showTime: showTime,
|
|
47
|
+
style: style,
|
|
43
48
|
disabledDate: function disabledDate(currentDate) {
|
|
44
49
|
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
45
50
|
}
|
|
@@ -30,7 +30,8 @@ var Index = function Index(_ref) {
|
|
|
30
30
|
disabled = _ref.disabled,
|
|
31
31
|
_ref$keyInValue = _ref.keyInValue,
|
|
32
32
|
keyInValue = _ref$keyInValue === void 0 ? true : _ref$keyInValue,
|
|
33
|
-
addFormat = _ref.addFormat
|
|
33
|
+
addFormat = _ref.addFormat,
|
|
34
|
+
direction = _ref.direction;
|
|
34
35
|
var _useMatchConfigProps = index.useMatchConfigProps({
|
|
35
36
|
fieldNames: fieldNames,
|
|
36
37
|
valueCheckMap: valueMap
|
|
@@ -77,6 +78,7 @@ var Index = function Index(_ref) {
|
|
|
77
78
|
}
|
|
78
79
|
});
|
|
79
80
|
return jsxRuntime.jsx(antd.Space, {
|
|
81
|
+
direction: direction,
|
|
80
82
|
children: checkOptions === null || checkOptions === void 0 ? void 0 : checkOptions.map(function (item) {
|
|
81
83
|
var label = item.label,
|
|
82
84
|
itemVal = item.value;
|
|
@@ -11,4 +11,5 @@ export interface HCheckboxProps extends Omit<CheckboxProps, "value" | "onChange"
|
|
|
11
11
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
12
12
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
13
13
|
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
14
|
+
direction?: 'horizontal' | 'vertical';
|
|
14
15
|
}
|
package/lib/TDPicker/index.js
CHANGED
|
@@ -16,7 +16,7 @@ var antd = require('antd');
|
|
|
16
16
|
var hooks = require('./hooks.js');
|
|
17
17
|
var HFormConnect = require('../Form/HFormConnect.js');
|
|
18
18
|
|
|
19
|
-
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat"];
|
|
19
|
+
var _excluded = ["value", "onChange", "showTime", "format", "disabledDate", "addFormat", "style"];
|
|
20
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; }
|
|
21
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; }
|
|
22
22
|
var Picker = antd.DatePicker;
|
|
@@ -29,6 +29,10 @@ var Index = function Index(_ref) {
|
|
|
29
29
|
format = _ref$format === void 0 ? "X" : _ref$format,
|
|
30
30
|
_disabledDate = _ref.disabledDate,
|
|
31
31
|
addFormat = _ref.addFormat,
|
|
32
|
+
_ref$style = _ref.style,
|
|
33
|
+
style = _ref$style === void 0 ? {
|
|
34
|
+
width: "100%"
|
|
35
|
+
} : _ref$style,
|
|
32
36
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
33
37
|
addFormat === null || addFormat === void 0 || addFormat({});
|
|
34
38
|
var timeVal = hooks.useTimeVal({
|
|
@@ -43,6 +47,7 @@ var Index = function Index(_ref) {
|
|
|
43
47
|
value: timeVal,
|
|
44
48
|
onChange: change,
|
|
45
49
|
showTime: showTime,
|
|
50
|
+
style: style,
|
|
46
51
|
disabledDate: function disabledDate(currentDate) {
|
|
47
52
|
return !!(_disabledDate !== null && _disabledDate !== void 0 && _disabledDate(currentDate, timeVal));
|
|
48
53
|
}
|
package/package.json
CHANGED
|
@@ -15,6 +15,7 @@ const Index = ({
|
|
|
15
15
|
disabled,
|
|
16
16
|
keyInValue = true,
|
|
17
17
|
addFormat,
|
|
18
|
+
direction
|
|
18
19
|
}: HCheckboxProps) => {
|
|
19
20
|
const { valueCheckMap: resultValueCheckMap, fieldNames: resultFieldNames } =
|
|
20
21
|
useMatchConfigProps({ fieldNames, valueCheckMap: valueMap }); //匹配全局
|
|
@@ -59,7 +60,7 @@ const Index = ({
|
|
|
59
60
|
},
|
|
60
61
|
});
|
|
61
62
|
return (
|
|
62
|
-
<Space>
|
|
63
|
+
<Space direction={direction}>
|
|
63
64
|
{checkOptions?.map((item) => {
|
|
64
65
|
const { label, value: itemVal } = item;
|
|
65
66
|
const checked = val[itemVal];
|
|
@@ -13,4 +13,5 @@ export interface HCheckboxProps
|
|
|
13
13
|
onChange?: (value: Record<string, any> | any[]) => void;
|
|
14
14
|
addFormat?: (config: Record<string, addFormatItemModal>) => void;
|
|
15
15
|
subParams?: (formatValue: Record<string, any>, sourceValue: any[]) => any;
|
|
16
|
+
direction?:'horizontal' | 'vertical'
|
|
16
17
|
}
|
|
@@ -16,7 +16,7 @@ export default () => {
|
|
|
16
16
|
const initDispatch: Record<string, argsFn> = {};
|
|
17
17
|
let cacheValues: Record<string, any> = {};
|
|
18
18
|
let isLoading = false;
|
|
19
|
-
let initSaveValue={};
|
|
19
|
+
let initSaveValue = {};
|
|
20
20
|
const norAddItemDispatch = (name, manual, fn) => {
|
|
21
21
|
if (manual === false && name) {
|
|
22
22
|
initDispatch[name] = fn;
|
|
@@ -42,7 +42,7 @@ export default () => {
|
|
|
42
42
|
let newValue = {};
|
|
43
43
|
if (cacheValues) {
|
|
44
44
|
newValue = this.formatValues(cacheValues);
|
|
45
|
-
initSaveValue=newValue;
|
|
45
|
+
initSaveValue = newValue;
|
|
46
46
|
form.setFieldsValue(newValue);
|
|
47
47
|
}
|
|
48
48
|
const initKeys = Object.keys(initDispatch);
|
|
@@ -161,17 +161,17 @@ export default () => {
|
|
|
161
161
|
});
|
|
162
162
|
});
|
|
163
163
|
},
|
|
164
|
-
resetFieldsInitValue:()=>{
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
164
|
+
resetFieldsInitValue: () => {
|
|
165
|
+
const oldValue = form.getFieldsValue();
|
|
166
|
+
const keys = Object.keys(oldValue);
|
|
167
|
+
const newVale = {};
|
|
168
|
+
keys.forEach((key) => {
|
|
169
|
+
newVale[key] = undefined;
|
|
170
|
+
});
|
|
171
|
+
form.setFieldsValue({
|
|
172
|
+
...newVale,
|
|
173
|
+
...initSaveValue,
|
|
174
|
+
});
|
|
175
175
|
},
|
|
176
176
|
clear: () => {
|
|
177
177
|
form.resetFields();
|
|
@@ -160,7 +160,7 @@ export interface HFormInstance extends FormInstance {
|
|
|
160
160
|
removeDispatchListener: (action?: ActionModal, fn?: argsFn) => void;
|
|
161
161
|
reload: PromiseFnResult;
|
|
162
162
|
clear: VoidFunction;
|
|
163
|
-
resetFieldsInitValue:VoidFunction;
|
|
163
|
+
resetFieldsInitValue: VoidFunction;
|
|
164
164
|
}
|
|
165
165
|
|
|
166
166
|
export interface ConnectConfigModal {
|
|
@@ -11,6 +11,7 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
11
11
|
format = "X",
|
|
12
12
|
disabledDate,
|
|
13
13
|
addFormat,
|
|
14
|
+
style={width:"100%"},
|
|
14
15
|
...props
|
|
15
16
|
}) => {
|
|
16
17
|
addFormat?.({});
|
|
@@ -21,6 +22,7 @@ const Index: React.FC<HDatePickerProps> = ({
|
|
|
21
22
|
value={timeVal}
|
|
22
23
|
onChange={change}
|
|
23
24
|
showTime={showTime}
|
|
25
|
+
style={style}
|
|
24
26
|
disabledDate={(currentDate) => {
|
|
25
27
|
return !!disabledDate?.(currentDate, timeVal);
|
|
26
28
|
}}
|
package/src/pages/Form/index.tsx
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HForm, HFormConfigProvider, useHForm } from "../../components";
|
|
2
2
|
import { useState } from "react";
|
|
3
|
-
import {Button, DatePicker, Form, Input} from "antd";
|
|
3
|
+
import { Button, DatePicker, Form, Input } from "antd";
|
|
4
4
|
|
|
5
5
|
const formData = (options) => {
|
|
6
6
|
const op = [
|
|
@@ -77,6 +77,7 @@ const formData = (options) => {
|
|
|
77
77
|
{ value: "选择1", key: "check1" },
|
|
78
78
|
{ value: "选择2", key: "check2" },
|
|
79
79
|
],
|
|
80
|
+
direction:"vertical"
|
|
80
81
|
},
|
|
81
82
|
{
|
|
82
83
|
label: "开关",
|
|
@@ -241,12 +242,12 @@ const Test = (props) => {
|
|
|
241
242
|
export default () => {
|
|
242
243
|
const form = useHForm();
|
|
243
244
|
const [options, setOptions] = useState([{ label: "1", value: 1 }]);
|
|
244
|
-
const [aForm]=Form.useForm();
|
|
245
|
+
const [aForm] = Form.useForm();
|
|
245
246
|
return (
|
|
246
247
|
<div style={{ overflow: "auto", height: "90vh" }}>
|
|
247
|
-
<Form
|
|
248
|
-
<Form.Item name="ttim" rules={[{required:true}]}>
|
|
249
|
-
<Input/>
|
|
248
|
+
<Form form={aForm} initialValues={{ ttim: "132123" }}>
|
|
249
|
+
<Form.Item name="ttim" rules={[{ required: true }]}>
|
|
250
|
+
<Input />
|
|
250
251
|
</Form.Item>
|
|
251
252
|
</Form>
|
|
252
253
|
<HFormConfigProvider
|