@hw-component/form 0.0.9-beta-v18 → 0.0.9-beta-v20
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/FormItem/BasicItem.js +10 -3
- package/es/Form/index.d.ts +1 -1
- package/es/Form/index.js +8 -2
- package/es/Form/modal.d.ts +3 -1
- package/es/Select/modal.d.ts +1 -3
- package/es/config.js +2 -1
- package/lib/Form/FormItem/BasicItem.js +10 -3
- package/lib/Form/index.d.ts +1 -1
- package/lib/Form/index.js +8 -2
- package/lib/Form/modal.d.ts +3 -1
- package/lib/Select/modal.d.ts +1 -3
- package/lib/config.js +2 -1
- package/package.json +1 -1
- package/src/components/Form/FormItem/BasicItem.tsx +10 -4
- package/src/components/Form/index.tsx +8 -0
- package/src/components/Form/modal.ts +4 -2
- package/src/components/Select/modal.ts +1 -3
- package/src/components/config.ts +2 -1
- package/src/pages/Form/index.tsx +16 -8
|
@@ -20,8 +20,8 @@ import { useDefaultRender } from '../hooks/useDefaultRender.js';
|
|
|
20
20
|
import { useDefaultComponents } from '../hooks/index.js';
|
|
21
21
|
import { useFormConfigContext } from '../Context/FormConfigProvider.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["hover", "labelWidth", "required", "colon", "label", "itemProps", "children", "helper", "hide", "render", "itemSpan", "hideLabel", "labelAlign", "style"],
|
|
24
|
-
_excluded2 = ["labelAlign"];
|
|
23
|
+
var _excluded = ["hover", "labelWidth", "required", "colon", "label", "itemProps", "children", "helper", "hide", "render", "itemSpan", "hideLabel", "labelAlign", "style", "className"],
|
|
24
|
+
_excluded2 = ["labelAlign", "itemProps"];
|
|
25
25
|
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; }
|
|
26
26
|
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; }
|
|
27
27
|
var Content = function Content(_ref) {
|
|
@@ -68,15 +68,21 @@ var Index = function Index(props) {
|
|
|
68
68
|
hideLabel = _props$hideLabel === void 0 ? false : _props$hideLabel;
|
|
69
69
|
props.labelAlign;
|
|
70
70
|
var style = props.style,
|
|
71
|
+
colClassName = props.className,
|
|
71
72
|
oProps = _objectWithoutProperties(props, _excluded);
|
|
72
73
|
var _props$labelAlign = props.labelAlign,
|
|
73
74
|
align = _props$labelAlign === void 0 ? "right" : _props$labelAlign,
|
|
75
|
+
itemProps = props.itemProps,
|
|
74
76
|
inProps = _objectWithoutProperties(props, _excluded2);
|
|
75
77
|
var _useFormContext = useFormContext(),
|
|
76
78
|
form = _useFormContext.form;
|
|
77
79
|
var defaultComponent = useDefaultComponents();
|
|
78
80
|
var formItemStyle = useFormConfigContext("formItemStyle");
|
|
79
|
-
var
|
|
81
|
+
var ctxItemProps = useFormConfigContext("itemProps");
|
|
82
|
+
var defaultItemProps = _objectSpread(_objectSpread({}, ctxItemProps), itemProps);
|
|
83
|
+
var defaultRender = useDefaultRender(_objectSpread(_objectSpread({}, inProps), {}, {
|
|
84
|
+
itemProps: defaultItemProps
|
|
85
|
+
}), defaultComponent);
|
|
80
86
|
var className = usePositionClassName(align);
|
|
81
87
|
var hideItem = useHide({
|
|
82
88
|
hide: hide,
|
|
@@ -86,6 +92,7 @@ var Index = function Index(props) {
|
|
|
86
92
|
return null;
|
|
87
93
|
}
|
|
88
94
|
return jsx(Col, _objectSpread(_objectSpread({}, itemSpan), {}, {
|
|
95
|
+
className: colClassName,
|
|
89
96
|
children: jsx(Form.Item, _objectSpread(_objectSpread({
|
|
90
97
|
className: className,
|
|
91
98
|
label: !hideLabel && jsx(Index$1, {
|
package/es/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/es/Form/index.js
CHANGED
|
@@ -20,7 +20,7 @@ import Index from '../PageHandler/index.js';
|
|
|
20
20
|
import useInitConfigData from './hooks/useInitConfigData.js';
|
|
21
21
|
import InitSet from './InitSet.js';
|
|
22
22
|
|
|
23
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle"];
|
|
23
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps"];
|
|
24
24
|
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; }
|
|
25
25
|
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; }
|
|
26
26
|
var HForm = (function (_ref) {
|
|
@@ -43,6 +43,8 @@ var HForm = (function (_ref) {
|
|
|
43
43
|
submitLoading = _ref.submitLoading,
|
|
44
44
|
formLabelAlign = _ref.labelAlign,
|
|
45
45
|
formItemStyle = _ref.formItemStyle,
|
|
46
|
+
_ref$itemProps = _ref.itemProps,
|
|
47
|
+
formItemProps = _ref$itemProps === void 0 ? {} : _ref$itemProps,
|
|
46
48
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
47
49
|
var hForm = useCurrentForm(form);
|
|
48
50
|
var _useInitConfigData = useInitConfigData({
|
|
@@ -104,11 +106,15 @@ var HForm = (function (_ref) {
|
|
|
104
106
|
labelAlign = _itemData$labelAlign === void 0 ? formLabelAlign : _itemData$labelAlign,
|
|
105
107
|
name = itemData.name,
|
|
106
108
|
_itemData$style = itemData.style,
|
|
107
|
-
style = _itemData$style === void 0 ? formItemStyle : _itemData$style
|
|
109
|
+
style = _itemData$style === void 0 ? formItemStyle : _itemData$style,
|
|
110
|
+
_itemData$itemProps = itemData.itemProps,
|
|
111
|
+
itemProps = _itemData$itemProps === void 0 ? {} : _itemData$itemProps;
|
|
112
|
+
var defaultItemProps = _objectSpread(_objectSpread({}, formItemProps), itemProps);
|
|
108
113
|
return /*#__PURE__*/createElement(Item, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
109
114
|
labelAlign: labelAlign,
|
|
110
115
|
key: name || index,
|
|
111
116
|
style: style,
|
|
117
|
+
itemProps: defaultItemProps,
|
|
112
118
|
hideLabel: hideLabel,
|
|
113
119
|
itemSpan: itemSpan,
|
|
114
120
|
labelWidth: itemLabelWidth || labelWidth
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { DataFnProvider } from "../modal";
|
|
|
17
17
|
import type { ColProps } from "antd/lib/grid/col";
|
|
18
18
|
import type { Gutter } from "antd/lib/grid/row";
|
|
19
19
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => React.ReactNode;
|
|
20
|
-
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
20
|
+
export type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
21
21
|
export interface HoverModal {
|
|
22
22
|
text?: string;
|
|
23
23
|
icon?: React.ReactNode;
|
|
@@ -63,6 +63,7 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "
|
|
|
63
63
|
submitLoading?: boolean;
|
|
64
64
|
labelAlign?: LabelAlignModal;
|
|
65
65
|
formItemStyle?: React.CSSProperties;
|
|
66
|
+
itemProps?: ItemPropsType;
|
|
66
67
|
}
|
|
67
68
|
export interface HFormItemProps extends HItemProps {
|
|
68
69
|
required?: boolean;
|
|
@@ -101,6 +102,7 @@ export interface IFormConfigContextProps {
|
|
|
101
102
|
uploadProps?: ConfigUploadProps;
|
|
102
103
|
defaultComponent?: DefaultComponentModal;
|
|
103
104
|
formItemStyle?: React.CSSProperties;
|
|
105
|
+
itemProps?: ItemPropsType;
|
|
104
106
|
}
|
|
105
107
|
interface ActionModal {
|
|
106
108
|
key: string;
|
package/es/Select/modal.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
-
import type { argsFn } from "
|
|
5
|
-
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
|
-
import type { DispatchModal } from "@/components/Form/modal";
|
|
4
|
+
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
7
5
|
export type OptionType = Record<string, any>;
|
|
8
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
9
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
package/es/config.js
CHANGED
|
@@ -23,8 +23,8 @@ var useDefaultRender = require('../hooks/useDefaultRender.js');
|
|
|
23
23
|
var index$1 = require('../hooks/index.js');
|
|
24
24
|
var FormConfigProvider = require('../Context/FormConfigProvider.js');
|
|
25
25
|
|
|
26
|
-
var _excluded = ["hover", "labelWidth", "required", "colon", "label", "itemProps", "children", "helper", "hide", "render", "itemSpan", "hideLabel", "labelAlign", "style"],
|
|
27
|
-
_excluded2 = ["labelAlign"];
|
|
26
|
+
var _excluded = ["hover", "labelWidth", "required", "colon", "label", "itemProps", "children", "helper", "hide", "render", "itemSpan", "hideLabel", "labelAlign", "style", "className"],
|
|
27
|
+
_excluded2 = ["labelAlign", "itemProps"];
|
|
28
28
|
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; }
|
|
29
29
|
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; }
|
|
30
30
|
var Content = function Content(_ref) {
|
|
@@ -71,15 +71,21 @@ var Index = function Index(props) {
|
|
|
71
71
|
hideLabel = _props$hideLabel === void 0 ? false : _props$hideLabel;
|
|
72
72
|
props.labelAlign;
|
|
73
73
|
var style = props.style,
|
|
74
|
+
colClassName = props.className,
|
|
74
75
|
oProps = _objectWithoutProperties(props, _excluded);
|
|
75
76
|
var _props$labelAlign = props.labelAlign,
|
|
76
77
|
align = _props$labelAlign === void 0 ? "right" : _props$labelAlign,
|
|
78
|
+
itemProps = props.itemProps,
|
|
77
79
|
inProps = _objectWithoutProperties(props, _excluded2);
|
|
78
80
|
var _useFormContext = index.useFormContext(),
|
|
79
81
|
form = _useFormContext.form;
|
|
80
82
|
var defaultComponent = index$1.useDefaultComponents();
|
|
81
83
|
var formItemStyle = FormConfigProvider.useFormConfigContext("formItemStyle");
|
|
82
|
-
var
|
|
84
|
+
var ctxItemProps = FormConfigProvider.useFormConfigContext("itemProps");
|
|
85
|
+
var defaultItemProps = _objectSpread(_objectSpread({}, ctxItemProps), itemProps);
|
|
86
|
+
var defaultRender = useDefaultRender.useDefaultRender(_objectSpread(_objectSpread({}, inProps), {}, {
|
|
87
|
+
itemProps: defaultItemProps
|
|
88
|
+
}), defaultComponent);
|
|
83
89
|
var className = hooks.usePositionClassName(align);
|
|
84
90
|
var hideItem = hooks.useHide({
|
|
85
91
|
hide: hide,
|
|
@@ -89,6 +95,7 @@ var Index = function Index(props) {
|
|
|
89
95
|
return null;
|
|
90
96
|
}
|
|
91
97
|
return jsxRuntime.jsx(antd.Col, _objectSpread(_objectSpread({}, itemSpan), {}, {
|
|
98
|
+
className: colClassName,
|
|
92
99
|
children: jsxRuntime.jsx(antd.Form.Item, _objectSpread(_objectSpread({
|
|
93
100
|
className: className,
|
|
94
101
|
label: !hideLabel && jsxRuntime.jsx(Label.default, {
|
package/lib/Form/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import type { HFormProps } from "./modal";
|
|
2
|
-
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, ...props }: HFormProps) => JSX.Element;
|
|
2
|
+
declare const _default: ({ configData, labelWidth, form, request, onFinish, infoRequest, valueType, initialValues, params, onValuesChange, itemSpan, hideLabel: formHideLabel, gutter, submitLoading, labelAlign: formLabelAlign, formItemStyle, itemProps: formItemProps, ...props }: HFormProps) => JSX.Element;
|
|
3
3
|
export default _default;
|
package/lib/Form/index.js
CHANGED
|
@@ -23,7 +23,7 @@ var index$1 = require('../PageHandler/index.js');
|
|
|
23
23
|
var useInitConfigData = require('./hooks/useInitConfigData.js');
|
|
24
24
|
var InitSet = require('./InitSet.js');
|
|
25
25
|
|
|
26
|
-
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle"];
|
|
26
|
+
var _excluded = ["configData", "labelWidth", "form", "request", "onFinish", "infoRequest", "valueType", "initialValues", "params", "onValuesChange", "itemSpan", "hideLabel", "gutter", "submitLoading", "labelAlign", "formItemStyle", "itemProps"];
|
|
27
27
|
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; }
|
|
28
28
|
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; }
|
|
29
29
|
var HForm = (function (_ref) {
|
|
@@ -46,6 +46,8 @@ var HForm = (function (_ref) {
|
|
|
46
46
|
submitLoading = _ref.submitLoading,
|
|
47
47
|
formLabelAlign = _ref.labelAlign,
|
|
48
48
|
formItemStyle = _ref.formItemStyle,
|
|
49
|
+
_ref$itemProps = _ref.itemProps,
|
|
50
|
+
formItemProps = _ref$itemProps === void 0 ? {} : _ref$itemProps,
|
|
49
51
|
props = _objectWithoutProperties(_ref, _excluded);
|
|
50
52
|
var hForm = index.useCurrentForm(form);
|
|
51
53
|
var _useInitConfigData = useInitConfigData.default({
|
|
@@ -107,11 +109,15 @@ var HForm = (function (_ref) {
|
|
|
107
109
|
labelAlign = _itemData$labelAlign === void 0 ? formLabelAlign : _itemData$labelAlign,
|
|
108
110
|
name = itemData.name,
|
|
109
111
|
_itemData$style = itemData.style,
|
|
110
|
-
style = _itemData$style === void 0 ? formItemStyle : _itemData$style
|
|
112
|
+
style = _itemData$style === void 0 ? formItemStyle : _itemData$style,
|
|
113
|
+
_itemData$itemProps = itemData.itemProps,
|
|
114
|
+
itemProps = _itemData$itemProps === void 0 ? {} : _itemData$itemProps;
|
|
115
|
+
var defaultItemProps = _objectSpread(_objectSpread({}, formItemProps), itemProps);
|
|
111
116
|
return /*#__PURE__*/React.createElement(index$3.default, _objectSpread(_objectSpread({}, itemData), {}, {
|
|
112
117
|
labelAlign: labelAlign,
|
|
113
118
|
key: name || index,
|
|
114
119
|
style: style,
|
|
120
|
+
itemProps: defaultItemProps,
|
|
115
121
|
hideLabel: hideLabel,
|
|
116
122
|
itemSpan: itemSpan,
|
|
117
123
|
labelWidth: itemLabelWidth || labelWidth
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -17,7 +17,7 @@ import type { DataFnProvider } from "../modal";
|
|
|
17
17
|
import type { ColProps } from "antd/lib/grid/col";
|
|
18
18
|
import type { Gutter } from "antd/lib/grid/row";
|
|
19
19
|
type RenderFun = (props: HItemProps, node: React.ReactNode, form: FormInstance) => React.ReactNode;
|
|
20
|
-
type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
20
|
+
export type ItemPropsType = HCheckboxProps | HInputProps | HSelectInputProps | HButtonProps | HRadioGroupProps | HSelectProps | ButtonProps | HSwitchProps | HDatePickerProps | HRangePickerProps | HTimePickerProps | TextAreaProps | IUpLoadProps | CascaderProps<any>;
|
|
21
21
|
export interface HoverModal {
|
|
22
22
|
text?: string;
|
|
23
23
|
icon?: React.ReactNode;
|
|
@@ -63,6 +63,7 @@ export interface HFormProps<T = any, R = any> extends Omit<FormProps, "form" | "
|
|
|
63
63
|
submitLoading?: boolean;
|
|
64
64
|
labelAlign?: LabelAlignModal;
|
|
65
65
|
formItemStyle?: React.CSSProperties;
|
|
66
|
+
itemProps?: ItemPropsType;
|
|
66
67
|
}
|
|
67
68
|
export interface HFormItemProps extends HItemProps {
|
|
68
69
|
required?: boolean;
|
|
@@ -101,6 +102,7 @@ export interface IFormConfigContextProps {
|
|
|
101
102
|
uploadProps?: ConfigUploadProps;
|
|
102
103
|
defaultComponent?: DefaultComponentModal;
|
|
103
104
|
formItemStyle?: React.CSSProperties;
|
|
105
|
+
itemProps?: ItemPropsType;
|
|
104
106
|
}
|
|
105
107
|
interface ActionModal {
|
|
106
108
|
key: string;
|
package/lib/Select/modal.d.ts
CHANGED
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
-
import type { argsFn } from "
|
|
5
|
-
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
|
-
import type { DispatchModal } from "@/components/Form/modal";
|
|
4
|
+
import type { addFormatItemModal, argsFn, DispatchModal } from "../Form/modal";
|
|
7
5
|
export type OptionType = Record<string, any>;
|
|
8
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
9
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
package/lib/config.js
CHANGED
package/package.json
CHANGED
|
@@ -38,7 +38,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
38
38
|
required,
|
|
39
39
|
colon = true,
|
|
40
40
|
label,
|
|
41
|
-
itemProps,
|
|
41
|
+
itemProps:colItemProps,
|
|
42
42
|
children,
|
|
43
43
|
helper,
|
|
44
44
|
hide,
|
|
@@ -47,20 +47,26 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
47
47
|
hideLabel = false,
|
|
48
48
|
labelAlign,
|
|
49
49
|
style,
|
|
50
|
+
className:colClassName,
|
|
50
51
|
...oProps
|
|
51
52
|
} = props;
|
|
52
|
-
const { labelAlign: align = "right", ...inProps } = props;
|
|
53
|
+
const { labelAlign: align = "right",itemProps, ...inProps } = props;
|
|
53
54
|
const { form } = useFormContext();
|
|
54
55
|
const defaultComponent = useDefaultComponents();
|
|
55
56
|
const formItemStyle = useFormConfigContext("formItemStyle");
|
|
56
|
-
const
|
|
57
|
+
const ctxItemProps = useFormConfigContext("itemProps");
|
|
58
|
+
const defaultItemProps={
|
|
59
|
+
...ctxItemProps,
|
|
60
|
+
...itemProps
|
|
61
|
+
}
|
|
62
|
+
const defaultRender = useDefaultRender({...inProps,itemProps:defaultItemProps}, defaultComponent);
|
|
57
63
|
const className = usePositionClassName(align);
|
|
58
64
|
const hideItem = useHide({ hide, form });
|
|
59
65
|
if (hideItem) {
|
|
60
66
|
return null;
|
|
61
67
|
}
|
|
62
68
|
return (
|
|
63
|
-
<Col {...itemSpan}>
|
|
69
|
+
<Col {...itemSpan} className={colClassName}>
|
|
64
70
|
<Form.Item
|
|
65
71
|
className={className}
|
|
66
72
|
label={
|
|
@@ -7,6 +7,7 @@ import PageHandler from "../PageHandler";
|
|
|
7
7
|
import useInitConfigData from "./hooks/useInitConfigData";
|
|
8
8
|
import { useEffect } from "react";
|
|
9
9
|
import InitSet from "./InitSet";
|
|
10
|
+
import {ItemPropsType} from "./modal";
|
|
10
11
|
|
|
11
12
|
export default ({
|
|
12
13
|
configData,
|
|
@@ -25,6 +26,7 @@ export default ({
|
|
|
25
26
|
submitLoading,
|
|
26
27
|
labelAlign: formLabelAlign,
|
|
27
28
|
formItemStyle,
|
|
29
|
+
itemProps:formItemProps={},
|
|
28
30
|
...props
|
|
29
31
|
}: HFormProps) => {
|
|
30
32
|
const hForm = useCurrentForm(form);
|
|
@@ -83,13 +85,19 @@ export default ({
|
|
|
83
85
|
labelAlign = formLabelAlign,
|
|
84
86
|
name,
|
|
85
87
|
style=formItemStyle,
|
|
88
|
+
itemProps={},
|
|
86
89
|
} = itemData;
|
|
90
|
+
const defaultItemProps={
|
|
91
|
+
...formItemProps,
|
|
92
|
+
...itemProps
|
|
93
|
+
}
|
|
87
94
|
return (
|
|
88
95
|
<Item
|
|
89
96
|
{...itemData}
|
|
90
97
|
labelAlign={labelAlign}
|
|
91
98
|
key={name||index}
|
|
92
99
|
style={style}
|
|
100
|
+
itemProps={(defaultItemProps as ItemPropsType)}
|
|
93
101
|
hideLabel={hideLabel}
|
|
94
102
|
itemSpan={itemSpan}
|
|
95
103
|
labelWidth={itemLabelWidth || labelWidth}
|
|
@@ -40,7 +40,7 @@ type RenderFun = (
|
|
|
40
40
|
node: React.ReactNode,
|
|
41
41
|
form: FormInstance
|
|
42
42
|
) => React.ReactNode;
|
|
43
|
-
type ItemPropsType =
|
|
43
|
+
export type ItemPropsType =
|
|
44
44
|
| HCheckboxProps
|
|
45
45
|
| HInputProps
|
|
46
46
|
| HSelectInputProps
|
|
@@ -110,6 +110,7 @@ export interface HFormProps<T = any, R = any>
|
|
|
110
110
|
submitLoading?: boolean;
|
|
111
111
|
labelAlign?: LabelAlignModal;
|
|
112
112
|
formItemStyle?:React.CSSProperties;
|
|
113
|
+
itemProps?:ItemPropsType
|
|
113
114
|
}
|
|
114
115
|
export interface HFormItemProps extends HItemProps {
|
|
115
116
|
required?: boolean;
|
|
@@ -151,7 +152,8 @@ export interface IFormConfigContextProps {
|
|
|
151
152
|
dateRanges?: RangePickerProps["ranges"];
|
|
152
153
|
uploadProps?: ConfigUploadProps;
|
|
153
154
|
defaultComponent?: DefaultComponentModal;
|
|
154
|
-
formItemStyle?:React.CSSProperties
|
|
155
|
+
formItemStyle?:React.CSSProperties;
|
|
156
|
+
itemProps?:ItemPropsType
|
|
155
157
|
}
|
|
156
158
|
interface ActionModal {
|
|
157
159
|
key: string;
|
|
@@ -1,9 +1,7 @@
|
|
|
1
1
|
import type { SelectProps } from "antd";
|
|
2
2
|
import type React from "react";
|
|
3
3
|
import type { PromiseFnResult } from "../modal";
|
|
4
|
-
import type { argsFn
|
|
5
|
-
import type { addFormatItemModal } from "@/components/Form/modal";
|
|
6
|
-
import type { DispatchModal } from "@/components/Form/modal";
|
|
4
|
+
import type { addFormatItemModal ,argsFn,DispatchModal} from "../Form/modal";
|
|
7
5
|
export type OptionType = Record<string, any>;
|
|
8
6
|
export type PartialHSelectProps = Partial<HSelectProps>;
|
|
9
7
|
export type RenderFn = (data: OptionType) => React.ReactNode;
|
package/src/components/config.ts
CHANGED
package/src/pages/Form/index.tsx
CHANGED
|
@@ -14,6 +14,18 @@ const formData = (options) => {
|
|
|
14
14
|
},
|
|
15
15
|
];
|
|
16
16
|
return [
|
|
17
|
+
{
|
|
18
|
+
label: "测试",
|
|
19
|
+
className:"hdjd",
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
label: "测试1",
|
|
23
|
+
type:"select"
|
|
24
|
+
},
|
|
25
|
+
{
|
|
26
|
+
label: "测试1",
|
|
27
|
+
type:"inputNumber"
|
|
28
|
+
},
|
|
17
29
|
{
|
|
18
30
|
label: "选择",
|
|
19
31
|
name: "checkboxGroup",
|
|
@@ -26,9 +38,6 @@ const formData = (options) => {
|
|
|
26
38
|
],
|
|
27
39
|
direction: "vertical",
|
|
28
40
|
labelAlign: "topLeft",
|
|
29
|
-
style:{
|
|
30
|
-
marginBottom:200
|
|
31
|
-
}
|
|
32
41
|
},
|
|
33
42
|
{
|
|
34
43
|
label: "开关",
|
|
@@ -113,8 +122,10 @@ export default () => {
|
|
|
113
122
|
defaultComponent={{
|
|
114
123
|
test: Test,
|
|
115
124
|
}}
|
|
116
|
-
|
|
117
|
-
|
|
125
|
+
itemProps={{
|
|
126
|
+
style:{
|
|
127
|
+
borderRadius:10
|
|
128
|
+
}
|
|
118
129
|
}}
|
|
119
130
|
fieldNames={{
|
|
120
131
|
label: "value",
|
|
@@ -125,9 +136,6 @@ export default () => {
|
|
|
125
136
|
configData={formData(options)}
|
|
126
137
|
labelWidth={200}
|
|
127
138
|
form={form}
|
|
128
|
-
formItemStyle={{
|
|
129
|
-
marginBottom:10
|
|
130
|
-
}}
|
|
131
139
|
labelAlign={"right"}
|
|
132
140
|
submitLoading={true}
|
|
133
141
|
onFinish={(value) => {
|