@faasjs/ant-design 0.0.2-beta.441 → 0.0.2-beta.443

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.d.ts CHANGED
@@ -268,7 +268,7 @@ declare type FormItemProps<T = any> = {
268
268
  */
269
269
  declare function FormItem<T = any>(props: FormItemProps<T>): JSX.Element;
270
270
 
271
- declare type FormProps<Values = any, ExtendItemProps = any> = {
271
+ declare type FormProps<Values extends Record<string, any> = any, ExtendItemProps = any> = {
272
272
  items?: (FormItemProps | ExtendItemProps)[];
273
273
  /** Default: { text: 'Submit' }, set false to disable it */
274
274
  submit?: false | {
package/dist/index.js CHANGED
@@ -157,7 +157,7 @@ function transferOptions(options) {
157
157
  });
158
158
  }
159
159
  function transferValue(type, value) {
160
- if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
160
+ if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined" || Array.isArray(value) && !value.length)
161
161
  return null;
162
162
  if (!type)
163
163
  type = "string";
@@ -199,7 +199,7 @@ function DescriptionItemContent(props) {
199
199
  propsCopy.item.options = transferOptions(propsCopy.item.options);
200
200
  }
201
201
  propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
202
- if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
202
+ if (propsCopy.item.options && propsCopy.value !== null) {
203
203
  if (propsCopy.item.type.endsWith("[]"))
204
204
  propsCopy.value = propsCopy.value.map((v) => {
205
205
  var _a3;
@@ -750,6 +750,8 @@ function Form(props) {
750
750
  const [form] = import_antd6.Form.useForm(props.form);
751
751
  (0, import_react9.useEffect)(() => {
752
752
  var _a2, _b2;
753
+ if (!props.items)
754
+ return;
753
755
  const propsCopy = {
754
756
  ...props,
755
757
  form
@@ -757,7 +759,7 @@ function Form(props) {
757
759
  if (propsCopy.initialValues)
758
760
  for (const key in propsCopy.initialValues)
759
761
  propsCopy.initialValues[key] = transferValue(
760
- (_a2 = propsCopy.items.find((i) => i.id === key)) == null ? void 0 : _a2.type,
762
+ (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
761
763
  propsCopy.initialValues[key]
762
764
  );
763
765
  if (propsCopy.onFinish) {
@@ -796,8 +798,6 @@ function Form(props) {
796
798
  propsCopy.onValuesChange = (changedValues, allValues) => {
797
799
  if (originValuesChange)
798
800
  originValuesChange(changedValues, allValues);
799
- if (!propsCopy.items)
800
- return;
801
801
  for (const key in changedValues) {
802
802
  const item = propsCopy.items.find((i) => i.id === key);
803
803
  if (item == null ? void 0 : item.onValueChange)
@@ -805,7 +805,7 @@ function Form(props) {
805
805
  }
806
806
  };
807
807
  setComputedProps(propsCopy);
808
- }, []);
808
+ }, [props]);
809
809
  if (!computedProps)
810
810
  return null;
811
811
  return /* @__PURE__ */ (0, import_jsx_runtime7.jsxs)(import_antd6.Form, {
package/dist/index.mjs CHANGED
@@ -110,7 +110,7 @@ function transferOptions(options) {
110
110
  });
111
111
  }
112
112
  function transferValue(type, value) {
113
- if (typeof value === "undefined" || value === null || value === "" || Array.isArray(value) && !value.length)
113
+ if (typeof value === "undefined" || value === null || value === "" || value === "null" || value === "undefined" || Array.isArray(value) && !value.length)
114
114
  return null;
115
115
  if (!type)
116
116
  type = "string";
@@ -160,7 +160,7 @@ function DescriptionItemContent(props) {
160
160
  propsCopy.item.options = transferOptions(propsCopy.item.options);
161
161
  }
162
162
  propsCopy.value = transferValue(propsCopy.item.type, propsCopy.value);
163
- if (propsCopy.item.options && typeof propsCopy.value !== "undefined" && propsCopy.value !== null) {
163
+ if (propsCopy.item.options && propsCopy.value !== null) {
164
164
  if (propsCopy.item.type.endsWith("[]"))
165
165
  propsCopy.value = propsCopy.value.map((v) => {
166
166
  var _a3;
@@ -729,6 +729,8 @@ function Form(props) {
729
729
  const [form] = AntdForm2.useForm(props.form);
730
730
  useEffect4(() => {
731
731
  var _a2, _b2;
732
+ if (!props.items)
733
+ return;
732
734
  const propsCopy = {
733
735
  ...props,
734
736
  form
@@ -736,7 +738,7 @@ function Form(props) {
736
738
  if (propsCopy.initialValues)
737
739
  for (const key in propsCopy.initialValues)
738
740
  propsCopy.initialValues[key] = transferValue(
739
- (_a2 = propsCopy.items.find((i) => i.id === key)) == null ? void 0 : _a2.type,
741
+ (_a2 = propsCopy.items.find((item) => item.id === key)) == null ? void 0 : _a2.type,
740
742
  propsCopy.initialValues[key]
741
743
  );
742
744
  if (propsCopy.onFinish) {
@@ -775,8 +777,6 @@ function Form(props) {
775
777
  propsCopy.onValuesChange = (changedValues, allValues) => {
776
778
  if (originValuesChange)
777
779
  originValuesChange(changedValues, allValues);
778
- if (!propsCopy.items)
779
- return;
780
780
  for (const key in changedValues) {
781
781
  const item = propsCopy.items.find((i) => i.id === key);
782
782
  if (item == null ? void 0 : item.onValueChange)
@@ -784,7 +784,7 @@ function Form(props) {
784
784
  }
785
785
  };
786
786
  setComputedProps(propsCopy);
787
- }, []);
787
+ }, [props]);
788
788
  if (!computedProps)
789
789
  return null;
790
790
  return /* @__PURE__ */ jsxs2(AntdForm2, {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.441",
3
+ "version": "0.0.2-beta.443",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -28,7 +28,7 @@
28
28
  "lodash": "*",
29
29
  "react": "*",
30
30
  "react-dom": "*",
31
- "@faasjs/react": "^0.0.2-beta.441",
31
+ "@faasjs/react": "^0.0.2-beta.443",
32
32
  "react-router-dom": "*",
33
33
  "dayjs": "*"
34
34
  },