@fairys/taro-valtio-form-basic 1.0.1 → 1.0.2
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/esm/form.item.js +8 -2
- package/package.json +2 -2
- package/src/form.item.tsx +11 -1
package/esm/form.item.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { jsx, jsxs } from "react/jsx-runtime";
|
|
2
2
|
import { View } from "@tarojs/components";
|
|
3
3
|
import { Fragment } from "react";
|
|
4
|
-
import { FairysValtioFormParentAttrsContext, useFairysValtioFormInstanceContextHideState, useFairysValtioFormItemAttrs, useFairysValtioFormItemNoStyleAttrs } from "@fairys/valtio-form-basic";
|
|
4
|
+
import { FairysValtioFormParentAttrsContext, useFairysValtioFormInstanceContextHideState, useFairysValtioFormItemAttrs, useFairysValtioFormItemHideAttrs, useFairysValtioFormItemNoStyleAttrs } from "@fairys/valtio-form-basic";
|
|
5
5
|
function FairysTaroValtioFormItemBase(props) {
|
|
6
6
|
const { label, extra, helpText } = props;
|
|
7
7
|
const { itemClassName, itemStyle, containerClassName, itemLabelClassName, itemLabelStyle, itemBodyClassName, itemBodyStyle, itemInputClassName, itemExtraClassName, errorClassName, helpClassName, isInvalid, itemBorderType, children, error, formAttrsNameInstance } = useFairysValtioFormItemAttrs(props);
|
|
@@ -51,10 +51,16 @@ function FairysTaroValtioFormItemBase(props) {
|
|
|
51
51
|
]
|
|
52
52
|
});
|
|
53
53
|
}
|
|
54
|
+
function FairysTaroValtioFormHideItemEmpty(props) {
|
|
55
|
+
useFairysValtioFormItemHideAttrs(props);
|
|
56
|
+
return /*#__PURE__*/ jsx(Fragment, {});
|
|
57
|
+
}
|
|
54
58
|
function FairysTaroValtioFormHideItem(props) {
|
|
55
59
|
const [state] = useFairysValtioFormInstanceContextHideState();
|
|
56
60
|
const isHide = state[props.name];
|
|
57
|
-
if (isHide) return /*#__PURE__*/ jsx(
|
|
61
|
+
if (isHide) return /*#__PURE__*/ jsx(FairysTaroValtioFormHideItemEmpty, {
|
|
62
|
+
...props
|
|
63
|
+
});
|
|
58
64
|
return /*#__PURE__*/ jsx(FairysTaroValtioFormItemBase, {
|
|
59
65
|
...props
|
|
60
66
|
});
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"author": "SunLxy <1011771396@qq.com>",
|
|
4
4
|
"description": "taro表单框架组件",
|
|
5
5
|
"homepage": "https://github.com/autumn-fairy-tales/valtio-form-basic",
|
|
6
|
-
"version": "1.0.
|
|
6
|
+
"version": "1.0.2",
|
|
7
7
|
"main": "lib/index.js",
|
|
8
8
|
"types": "esm/index.d.ts",
|
|
9
9
|
"module": "esm/index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"esm"
|
|
26
26
|
],
|
|
27
27
|
"dependencies": {
|
|
28
|
-
"@fairys/valtio-form-basic": "^1.0.
|
|
28
|
+
"@fairys/valtio-form-basic": "^1.0.2"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@types/react": "~18.2.21",
|
package/src/form.item.tsx
CHANGED
|
@@ -9,6 +9,7 @@ import {
|
|
|
9
9
|
useFairysValtioFormInstanceContextHideState,
|
|
10
10
|
useFairysValtioFormItemNoStyleAttrs,
|
|
11
11
|
FairysValtioFormParentAttrsContext,
|
|
12
|
+
useFairysValtioFormItemHideAttrs,
|
|
12
13
|
} from '@fairys/valtio-form-basic';
|
|
13
14
|
|
|
14
15
|
export interface FairysTaroValtioFormItemProps<T extends MObject<T> = Record<string, any>>
|
|
@@ -67,6 +68,15 @@ export function FairysTaroValtioFormItemBase<T extends MObject<T> = Record<strin
|
|
|
67
68
|
</View>
|
|
68
69
|
);
|
|
69
70
|
}
|
|
71
|
+
|
|
72
|
+
/**隐藏表单项的空组件*/
|
|
73
|
+
function FairysTaroValtioFormHideItemEmpty<T extends MObject<T> = Record<string, any>>(
|
|
74
|
+
props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
|
|
75
|
+
) {
|
|
76
|
+
useFairysValtioFormItemHideAttrs(props);
|
|
77
|
+
return <Fragment />;
|
|
78
|
+
}
|
|
79
|
+
|
|
70
80
|
/**控制隐藏的表单项*/
|
|
71
81
|
export function FairysTaroValtioFormHideItem<T extends MObject<T> = Record<string, any>>(
|
|
72
82
|
props: Omit<FairysTaroValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
|
|
@@ -74,7 +84,7 @@ export function FairysTaroValtioFormHideItem<T extends MObject<T> = Record<strin
|
|
|
74
84
|
const [state] = useFairysValtioFormInstanceContextHideState();
|
|
75
85
|
const isHide = state[props.name];
|
|
76
86
|
if (isHide) {
|
|
77
|
-
return <
|
|
87
|
+
return <FairysTaroValtioFormHideItemEmpty<T> {...props} />;
|
|
78
88
|
}
|
|
79
89
|
return <FairysTaroValtioFormItemBase<T> {...props} />;
|
|
80
90
|
}
|