@hw-component/form 1.7.6 → 1.7.7
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 +3 -2
- package/es/Form/FormItem/hooks.d.ts +2 -1
- package/es/Form/FormItem/hooks.js +4 -1
- package/es/Form/modal.d.ts +2 -1
- package/lib/Form/FormItem/BasicItem.js +2 -1
- package/lib/Form/FormItem/hooks.d.ts +2 -1
- package/lib/Form/FormItem/hooks.js +4 -0
- package/lib/Form/modal.d.ts +2 -1
- package/package.json +1 -1
- package/src/components/Form/FormItem/BasicItem.tsx +3 -2
- package/src/components/Form/FormItem/hooks.tsx +8 -1
- package/src/components/Form/modal.ts +2 -1
- package/src/pages/Form/index.tsx +6 -0
|
@@ -15,7 +15,7 @@ import { Col, Form, Space } from 'antd';
|
|
|
15
15
|
import React from 'react';
|
|
16
16
|
import Index$2 from './Helper.js';
|
|
17
17
|
import { useClassName } from '../../hooks/index.js';
|
|
18
|
-
import { usePositionClassName, useHide, useFormItemLabel } from './hooks.js';
|
|
18
|
+
import { usePositionClassName, useHide, useFormItemLabel, useFormItemHover } from './hooks.js';
|
|
19
19
|
import { useFormContext } from '../Context/index.js';
|
|
20
20
|
import { useDefaultRender } from '../hooks/useDefaultRender.js';
|
|
21
21
|
import { useDefaultComponents } from '../hooks/index.js';
|
|
@@ -93,6 +93,7 @@ var Index = function Index(props) {
|
|
|
93
93
|
form: form
|
|
94
94
|
});
|
|
95
95
|
var formItemLabel = useFormItemLabel(form, label);
|
|
96
|
+
var itemHover = useFormItemHover(form, hover);
|
|
96
97
|
if (hideItem) {
|
|
97
98
|
return null;
|
|
98
99
|
}
|
|
@@ -101,7 +102,7 @@ var Index = function Index(props) {
|
|
|
101
102
|
children: jsx(Form.Item, _objectSpread(_objectSpread({
|
|
102
103
|
className: className,
|
|
103
104
|
label: !hideLabel && jsx(Index$1, {
|
|
104
|
-
hover:
|
|
105
|
+
hover: itemHover,
|
|
105
106
|
labelWidth: labelWidth,
|
|
106
107
|
required: required,
|
|
107
108
|
colon: colon,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { HFormInstance, HItemProps } from "../modal";
|
|
2
|
+
import type { HFormInstance, HItemProps, HoverFn, HoverModal } from "../modal";
|
|
3
3
|
import type { LabelAlignModal } from "../modal";
|
|
4
4
|
import type { HelperModal } from "../modal";
|
|
5
5
|
export declare const useFormItemDomControl: ({ shouldUpdate, hide, dependencies, }: HItemProps) => ({ shouldUpdate, dependencies, hide, itemSpan, ...props }: import("../modal").HFormItemProps) => JSX.Element;
|
|
@@ -10,4 +10,5 @@ export declare const useShouldUpdate: ({ hide, shouldUpdate, }: Omit<HItemProps,
|
|
|
10
10
|
export declare const useHide: ({ hide, form }: UseHideUpItemModal) => boolean;
|
|
11
11
|
export declare const usePositionClassName: (position: LabelAlignModal) => string;
|
|
12
12
|
export declare const useFormItemLabel: (form: HFormInstance, label?: React.ReactNode | HelperModal) => any;
|
|
13
|
+
export declare const useFormItemHover: (form: HFormInstance, hover?: string | HoverModal | HoverFn) => string | HoverModal | undefined;
|
|
13
14
|
export {};
|
|
@@ -48,6 +48,9 @@ var usePositionClassName = function usePositionClassName(position) {
|
|
|
48
48
|
var useFormItemLabel = function useFormItemLabel(form, label) {
|
|
49
49
|
return typeof label === "function" ? label(form) : label;
|
|
50
50
|
};
|
|
51
|
+
var useFormItemHover = function useFormItemHover(form, hover) {
|
|
52
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
53
|
+
};
|
|
51
54
|
|
|
52
|
-
export { useFormItemDomControl, useFormItemLabel, useHide, usePositionClassName, useShouldUpdate };
|
|
55
|
+
export { useFormItemDomControl, useFormItemHover, useFormItemLabel, useHide, usePositionClassName, useShouldUpdate };
|
|
53
56
|
// powered by hdj
|
package/es/Form/modal.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface HoverModal {
|
|
|
23
23
|
text?: string;
|
|
24
24
|
icon?: React.ReactNode;
|
|
25
25
|
}
|
|
26
|
+
export type HoverFn = (form: HFormInstance) => string | HoverModal;
|
|
26
27
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
27
28
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
28
29
|
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
@@ -39,7 +40,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
39
40
|
itemProps?: ItemPropsType;
|
|
40
41
|
render?: RenderFun;
|
|
41
42
|
helper?: HelperModal | React.ReactNode;
|
|
42
|
-
hover?: string | HoverModal;
|
|
43
|
+
hover?: string | HoverModal | HoverFn;
|
|
43
44
|
labelWidth?: number;
|
|
44
45
|
hide?: boolean | HideModal;
|
|
45
46
|
placeholder?: string | string[];
|
|
@@ -96,6 +96,7 @@ var Index = function Index(props) {
|
|
|
96
96
|
form: form
|
|
97
97
|
});
|
|
98
98
|
var formItemLabel = hooks.useFormItemLabel(form, label);
|
|
99
|
+
var itemHover = hooks.useFormItemHover(form, hover);
|
|
99
100
|
if (hideItem) {
|
|
100
101
|
return null;
|
|
101
102
|
}
|
|
@@ -104,7 +105,7 @@ var Index = function Index(props) {
|
|
|
104
105
|
children: jsxRuntime.jsx(antd.Form.Item, _objectSpread(_objectSpread({
|
|
105
106
|
className: className,
|
|
106
107
|
label: !hideLabel && jsxRuntime.jsx(Label.default, {
|
|
107
|
-
hover:
|
|
108
|
+
hover: itemHover,
|
|
108
109
|
labelWidth: labelWidth,
|
|
109
110
|
required: required,
|
|
110
111
|
colon: colon,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type React from "react";
|
|
2
|
-
import type { HFormInstance, HItemProps } from "../modal";
|
|
2
|
+
import type { HFormInstance, HItemProps, HoverFn, HoverModal } from "../modal";
|
|
3
3
|
import type { LabelAlignModal } from "../modal";
|
|
4
4
|
import type { HelperModal } from "../modal";
|
|
5
5
|
export declare const useFormItemDomControl: ({ shouldUpdate, hide, dependencies, }: HItemProps) => ({ shouldUpdate, dependencies, hide, itemSpan, ...props }: import("../modal").HFormItemProps) => JSX.Element;
|
|
@@ -10,4 +10,5 @@ export declare const useShouldUpdate: ({ hide, shouldUpdate, }: Omit<HItemProps,
|
|
|
10
10
|
export declare const useHide: ({ hide, form }: UseHideUpItemModal) => boolean;
|
|
11
11
|
export declare const usePositionClassName: (position: LabelAlignModal) => string;
|
|
12
12
|
export declare const useFormItemLabel: (form: HFormInstance, label?: React.ReactNode | HelperModal) => any;
|
|
13
|
+
export declare const useFormItemHover: (form: HFormInstance, hover?: string | HoverModal | HoverFn) => string | HoverModal | undefined;
|
|
13
14
|
export {};
|
|
@@ -49,8 +49,12 @@ var usePositionClassName = function usePositionClassName(position) {
|
|
|
49
49
|
var useFormItemLabel = function useFormItemLabel(form, label) {
|
|
50
50
|
return typeof label === "function" ? label(form) : label;
|
|
51
51
|
};
|
|
52
|
+
var useFormItemHover = function useFormItemHover(form, hover) {
|
|
53
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
54
|
+
};
|
|
52
55
|
|
|
53
56
|
exports.useFormItemDomControl = useFormItemDomControl;
|
|
57
|
+
exports.useFormItemHover = useFormItemHover;
|
|
54
58
|
exports.useFormItemLabel = useFormItemLabel;
|
|
55
59
|
exports.useHide = useHide;
|
|
56
60
|
exports.usePositionClassName = usePositionClassName;
|
package/lib/Form/modal.d.ts
CHANGED
|
@@ -23,6 +23,7 @@ export interface HoverModal {
|
|
|
23
23
|
text?: string;
|
|
24
24
|
icon?: React.ReactNode;
|
|
25
25
|
}
|
|
26
|
+
export type HoverFn = (form: HFormInstance) => string | HoverModal;
|
|
26
27
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
27
28
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
28
29
|
export type AddDispatchListenerFn = (action: ActionModal, fn: argsFn) => void;
|
|
@@ -39,7 +40,7 @@ export interface HItemProps extends Omit<FormItemProps, "name" | "labelAlign" |
|
|
|
39
40
|
itemProps?: ItemPropsType;
|
|
40
41
|
render?: RenderFun;
|
|
41
42
|
helper?: HelperModal | React.ReactNode;
|
|
42
|
-
hover?: string | HoverModal;
|
|
43
|
+
hover?: string | HoverModal | HoverFn;
|
|
43
44
|
labelWidth?: number;
|
|
44
45
|
hide?: boolean | HideModal;
|
|
45
46
|
placeholder?: string | string[];
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@ import { Form, Space, Col } from "antd";
|
|
|
3
3
|
import React from "react";
|
|
4
4
|
import Helper from "./Helper";
|
|
5
5
|
import { useClassName } from "../../hooks";
|
|
6
|
-
import { useFormItemLabel, useHide, usePositionClassName
|
|
6
|
+
import {useFormItemHover, useFormItemLabel, useHide, usePositionClassName} from "./hooks";
|
|
7
7
|
import { useFormContext } from "../Context";
|
|
8
8
|
import type { HItemProps } from "../modal";
|
|
9
9
|
import { useDefaultRender } from "../hooks/useDefaultRender";
|
|
@@ -68,6 +68,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
68
68
|
const className = usePositionClassName(align);
|
|
69
69
|
const hideItem = useHide({ hide, form });
|
|
70
70
|
const formItemLabel = useFormItemLabel(form, label);
|
|
71
|
+
const itemHover=useFormItemHover(form,hover)
|
|
71
72
|
if (hideItem) {
|
|
72
73
|
return null;
|
|
73
74
|
}
|
|
@@ -78,7 +79,7 @@ const Index: React.FC<HFormItemProps> = (props) => {
|
|
|
78
79
|
label={
|
|
79
80
|
!hideLabel && (
|
|
80
81
|
<Label
|
|
81
|
-
hover={
|
|
82
|
+
hover={itemHover}
|
|
82
83
|
labelWidth={labelWidth}
|
|
83
84
|
required={required}
|
|
84
85
|
colon={colon}
|
|
@@ -2,7 +2,7 @@ import UpFormItem from "./UpFormItem";
|
|
|
2
2
|
import RegularFormItem from "./RegularFormItem";
|
|
3
3
|
import type React from "react";
|
|
4
4
|
import { useMemo } from "react";
|
|
5
|
-
import type {
|
|
5
|
+
import type {HFormInstance, HItemProps, HoverFn, HoverModal} from "../modal";
|
|
6
6
|
import type { LabelAlignModal } from "../modal";
|
|
7
7
|
import { useClassName } from "../../hooks";
|
|
8
8
|
import type { HelperModal } from "../modal";
|
|
@@ -61,3 +61,10 @@ export const useFormItemLabel = (
|
|
|
61
61
|
) => {
|
|
62
62
|
return typeof label === "function" ? label(form) : label;
|
|
63
63
|
};
|
|
64
|
+
|
|
65
|
+
export const useFormItemHover = (
|
|
66
|
+
form: HFormInstance,
|
|
67
|
+
hover?:string|HoverModal|HoverFn
|
|
68
|
+
) => {
|
|
69
|
+
return typeof hover === "function" ? hover(form) : hover;
|
|
70
|
+
};
|
|
@@ -62,6 +62,7 @@ export interface HoverModal {
|
|
|
62
62
|
text?: string;
|
|
63
63
|
icon?: React.ReactNode;
|
|
64
64
|
}
|
|
65
|
+
export type HoverFn=(form: HFormInstance)=>string|HoverModal
|
|
65
66
|
export type HelperModal = (form: HFormInstance) => React.ReactNode | string;
|
|
66
67
|
|
|
67
68
|
export type HideModal = (form: HFormInstance) => boolean;
|
|
@@ -85,7 +86,7 @@ export interface HItemProps
|
|
|
85
86
|
itemProps?: ItemPropsType;
|
|
86
87
|
render?: RenderFun;
|
|
87
88
|
helper?: HelperModal | React.ReactNode;
|
|
88
|
-
hover?: string | HoverModal;
|
|
89
|
+
hover?: string | HoverModal|HoverFn;
|
|
89
90
|
// formItems?: HItemProps[]; 保留感觉没必要
|
|
90
91
|
labelWidth?: number;
|
|
91
92
|
hide?: boolean | HideModal;
|
package/src/pages/Form/index.tsx
CHANGED