@fairys/pc-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 CHANGED
@@ -1,6 +1,6 @@
1
1
  import { jsx, jsxs } from "react/jsx-runtime";
2
2
  import { Fragment } from "react";
3
- import { FairysValtioFormParentAttrsContext, useFairysValtioFormInstanceContextHideState, useFairysValtioFormItemAttrs, useFairysValtioFormItemNoStyleAttrs } from "@fairys/valtio-form-basic";
3
+ import { FairysValtioFormParentAttrsContext, useFairysValtioFormInstanceContextHideState, useFairysValtioFormItemAttrs, useFairysValtioFormItemHideAttrs, useFairysValtioFormItemNoStyleAttrs } from "@fairys/valtio-form-basic";
4
4
  function FairysPCValtioFormItemBase(props) {
5
5
  const { label, extra, helpText } = props;
6
6
  const { itemClassName, itemStyle, containerClassName, itemLabelClassName, itemLabelStyle, itemBodyClassName, itemBodyStyle, itemInputClassName, itemExtraClassName, errorClassName, helpClassName, isInvalid, children, error, formAttrsNameInstance, id } = useFairysValtioFormItemAttrs(props);
@@ -47,10 +47,16 @@ function FairysPCValtioFormItemBase(props) {
47
47
  ]
48
48
  });
49
49
  }
50
+ function FairysPCValtioFormHideItemEmpty(props) {
51
+ useFairysValtioFormItemHideAttrs(props);
52
+ return /*#__PURE__*/ jsx(Fragment, {});
53
+ }
50
54
  function FairysPCValtioFormHideItem(props) {
51
55
  const [state] = useFairysValtioFormInstanceContextHideState();
52
56
  const isHide = state[props.name];
53
- if (isHide) return /*#__PURE__*/ jsx(Fragment, {});
57
+ if (isHide) return /*#__PURE__*/ jsx(FairysPCValtioFormHideItemEmpty, {
58
+ ...props
59
+ });
54
60
  return /*#__PURE__*/ jsx(FairysPCValtioFormItemBase, {
55
61
  ...props
56
62
  });
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "author": "SunLxy <1011771396@qq.com>",
4
4
  "description": "pc表单框架组件",
5
5
  "homepage": "https://github.com/autumn-fairy-tales/valtio-form-basic",
6
- "version": "1.0.1",
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.1"
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
@@ -7,6 +7,7 @@ import {
7
7
  useFairysValtioFormInstanceContextHideState,
8
8
  useFairysValtioFormItemNoStyleAttrs,
9
9
  FairysValtioFormParentAttrsContext,
10
+ useFairysValtioFormItemHideAttrs,
10
11
  } from '@fairys/valtio-form-basic';
11
12
 
12
13
  export interface FairysPCValtioFormItemProps<T extends MObject<T> = Record<string, any>>
@@ -64,6 +65,15 @@ export function FairysPCValtioFormItemBase<T extends MObject<T> = Record<string,
64
65
  </div>
65
66
  );
66
67
  }
68
+
69
+ /**隐藏表单项的空组件*/
70
+ function FairysPCValtioFormHideItemEmpty<T extends MObject<T> = Record<string, any>>(
71
+ props: Omit<FairysPCValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
72
+ ) {
73
+ useFairysValtioFormItemHideAttrs(props);
74
+ return <Fragment />;
75
+ }
76
+
67
77
  /**控制隐藏的表单项*/
68
78
  export function FairysPCValtioFormHideItem<T extends MObject<T> = Record<string, any>>(
69
79
  props: Omit<FairysPCValtioFormItemProps<T>, 'isHide' | 'noStyle'>,
@@ -71,7 +81,7 @@ export function FairysPCValtioFormHideItem<T extends MObject<T> = Record<string,
71
81
  const [state] = useFairysValtioFormInstanceContextHideState();
72
82
  const isHide = state[props.name];
73
83
  if (isHide) {
74
- return <Fragment />;
84
+ return <FairysPCValtioFormHideItemEmpty<T> {...props} />;
75
85
  }
76
86
  return <FairysPCValtioFormItemBase<T> {...props} />;
77
87
  }