@faasjs/ant-design 6.3.0 → 6.3.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/dist/index.cjs CHANGED
@@ -562,7 +562,7 @@ function FormItem(props) {
562
562
  }, [props]);
563
563
  if (!computedProps) return null;
564
564
  if (hidden)
565
- return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { hidden: true }) });
565
+ return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsxRuntime.jsx(antd.Input, { type: "hidden", hidden: true }) });
566
566
  if (extendTypes?.[computedProps.type])
567
567
  return /* @__PURE__ */ jsxRuntime.jsx(antd.Form.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
568
568
  if (computedProps.formChildren === null) return null;
@@ -772,7 +772,7 @@ function Form(props) {
772
772
  const [extendTypes, setExtendTypes] = react$1.useState();
773
773
  const [form] = antd.Form.useForm(props.form);
774
774
  const [initialValues, setInitialValues] = react$1.useState(
775
- props.initialValues
775
+ props.initialValues || /* @__PURE__ */ Object.create(null)
776
776
  );
777
777
  react$1.useEffect(() => {
778
778
  const { submit: submit2, ...propsCopy } = {
@@ -783,21 +783,18 @@ function Form(props) {
783
783
  if (propsCopy.initialValues && propsCopy.items?.length) {
784
784
  for (const key in propsCopy.initialValues) {
785
785
  propsCopy.initialValues[key] = transferValue(
786
- propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)?.type,
786
+ propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type,
787
787
  propsCopy.initialValues[key]
788
788
  );
789
- const item = propsCopy.items.find(
790
- (item2) => isFormItemProps(item2) && item2.id === key
791
- );
792
- if (item?.if) item.hidden = !item.if(propsCopy.initialValues);
793
- }
794
- for (const item of propsCopy.items) {
795
- if (isFormItemProps(item) && item.if)
796
- item.hidden = !item.if(propsCopy.initialValues);
797
789
  }
798
790
  setInitialValues(propsCopy.initialValues);
799
791
  delete propsCopy.initialValues;
800
792
  }
793
+ if (propsCopy.items?.length)
794
+ for (const item of propsCopy.items) {
795
+ if (isFormItemProps(item) && item.if)
796
+ item.hidden = !item.if(initialValues || /* @__PURE__ */ Object.create(null));
797
+ }
801
798
  if (propsCopy.onFinish) {
802
799
  propsCopy.onFinish = async (values) => {
803
800
  setLoading(true);
package/dist/index.mjs CHANGED
@@ -558,7 +558,7 @@ function FormItem(props) {
558
558
  }, [props]);
559
559
  if (!computedProps) return null;
560
560
  if (hidden)
561
- return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsx(Input, { hidden: true }) });
561
+ return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, noStyle: true, rules: [], children: /* @__PURE__ */ jsx(Input, { type: "hidden", hidden: true }) });
562
562
  if (extendTypes?.[computedProps.type])
563
563
  return /* @__PURE__ */ jsx(Form$1.Item, { ...computedProps, children: extendTypes[computedProps.type].children });
564
564
  if (computedProps.formChildren === null) return null;
@@ -768,7 +768,7 @@ function Form(props) {
768
768
  const [extendTypes, setExtendTypes] = useState();
769
769
  const [form] = Form$1.useForm(props.form);
770
770
  const [initialValues, setInitialValues] = useState(
771
- props.initialValues
771
+ props.initialValues || /* @__PURE__ */ Object.create(null)
772
772
  );
773
773
  useEffect(() => {
774
774
  const { submit: submit2, ...propsCopy } = {
@@ -779,21 +779,18 @@ function Form(props) {
779
779
  if (propsCopy.initialValues && propsCopy.items?.length) {
780
780
  for (const key in propsCopy.initialValues) {
781
781
  propsCopy.initialValues[key] = transferValue(
782
- propsCopy.items.find((item2) => isFormItemProps(item2) && item2.id === key)?.type,
782
+ propsCopy.items.find((item) => isFormItemProps(item) && item.id === key)?.type,
783
783
  propsCopy.initialValues[key]
784
784
  );
785
- const item = propsCopy.items.find(
786
- (item2) => isFormItemProps(item2) && item2.id === key
787
- );
788
- if (item?.if) item.hidden = !item.if(propsCopy.initialValues);
789
- }
790
- for (const item of propsCopy.items) {
791
- if (isFormItemProps(item) && item.if)
792
- item.hidden = !item.if(propsCopy.initialValues);
793
785
  }
794
786
  setInitialValues(propsCopy.initialValues);
795
787
  delete propsCopy.initialValues;
796
788
  }
789
+ if (propsCopy.items?.length)
790
+ for (const item of propsCopy.items) {
791
+ if (isFormItemProps(item) && item.if)
792
+ item.hidden = !item.if(initialValues || /* @__PURE__ */ Object.create(null));
793
+ }
797
794
  if (propsCopy.onFinish) {
798
795
  propsCopy.onFinish = async (values) => {
799
796
  setLoading(true);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "6.3.0",
3
+ "version": "6.3.2",
4
4
  "license": "MIT",
5
5
  "type": "module",
6
6
  "main": "dist/index.cjs",
@@ -30,7 +30,7 @@
30
30
  "dist"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@faasjs/react": "6.3.0",
33
+ "@faasjs/react": "6.3.2",
34
34
  "antd": "*",
35
35
  "@ant-design/icons": "*",
36
36
  "lodash-es": "*",
@@ -40,7 +40,7 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/lodash-es": "*",
43
- "@faasjs/react": "6.3.0",
43
+ "@faasjs/react": "6.3.2",
44
44
  "antd": "*",
45
45
  "@ant-design/icons": "*",
46
46
  "lodash-es": "*",