@faasjs/ant-design 3.0.0-canary.3 → 3.0.0

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.mts CHANGED
@@ -393,7 +393,7 @@ declare namespace FaasDataWrapper {
393
393
  * const MyComponent = withFaasData(({ data }) => <div>{data.name}</div>, { action: 'test', params: { a: 1 } })
394
394
  * ```
395
395
  */
396
- declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): react.FC<Omit<any, keyof FaasDataInjection$1<any>> & Record<string, any>>;
396
+ declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): react.FC<Omit<any, keyof FaasDataInjection$1<PathOrData_1>> & Record<string, any>>;
397
397
 
398
398
  interface ExtendDescriptionTypeProps<T = any> {
399
399
  children?: UnionFaasItemElement<T>;
package/dist/index.d.ts CHANGED
@@ -393,7 +393,7 @@ declare namespace FaasDataWrapper {
393
393
  * const MyComponent = withFaasData(({ data }) => <div>{data.name}</div>, { action: 'test', params: { a: 1 } })
394
394
  * ```
395
395
  */
396
- declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): react.FC<Omit<any, keyof FaasDataInjection$1<any>> & Record<string, any>>;
396
+ declare function withFaasData<TComponent extends React.FC<any>, PathOrData extends FaasAction>(Component: TComponent, faasProps: FaasDataWrapperProps<PathOrData>): react.FC<Omit<any, keyof FaasDataInjection$1<PathOrData_1>> & Record<string, any>>;
397
397
 
398
398
  interface ExtendDescriptionTypeProps<T = any> {
399
399
  children?: UnionFaasItemElement<T>;
package/dist/index.js CHANGED
@@ -523,10 +523,9 @@ function FormItem(props) {
523
523
  const { theme } = useConfigContext();
524
524
  const [hidden, setHidden] = react$1.useState(props.hidden || false);
525
525
  react$1.useEffect(() => {
526
- const propsCopy = { ...props };
527
- if (propsCopy.extendTypes) {
528
- setExtendTypes(propsCopy.extendTypes);
529
- delete propsCopy.extendTypes;
526
+ const { extendTypes: extendTypes2, ...propsCopy } = { ...props };
527
+ if (extendTypes2) {
528
+ setExtendTypes(extendTypes2);
530
529
  }
531
530
  if (propsCopy.if) {
532
531
  const condition = propsCopy.if;
@@ -750,6 +749,7 @@ function isFormItemProps(item) {
750
749
  function Form(props) {
751
750
  const [loading, setLoading] = react$1.useState(false);
752
751
  const [computedProps, setComputedProps] = react$1.useState();
752
+ const [submit, setSubmit] = react$1.useState();
753
753
  const config = useConfigContext();
754
754
  const [extendTypes, setExtendTypes] = react$1.useState();
755
755
  const [form] = antd.Form.useForm(props.form);
@@ -757,10 +757,11 @@ function Form(props) {
757
757
  props.initialValues
758
758
  );
759
759
  react$1.useEffect(() => {
760
- const propsCopy = {
760
+ const { submit: submit2, ...propsCopy } = {
761
761
  ...props,
762
762
  form
763
763
  };
764
+ if (typeof submit2 !== "undefined") setSubmit(submit2);
764
765
  if (propsCopy.initialValues && propsCopy.items?.length) {
765
766
  for (const key in propsCopy.initialValues) {
766
767
  propsCopy.initialValues[key] = transferValue(
@@ -783,14 +784,14 @@ function Form(props) {
783
784
  propsCopy.onFinish = async (values) => {
784
785
  setLoading(true);
785
786
  try {
786
- if (propsCopy.submit?.to?.action) {
787
+ if (submit2?.to?.action) {
787
788
  await props.onFinish(
788
789
  values,
789
790
  async (values2) => react.faas(
790
- propsCopy.submit.to.action,
791
- propsCopy.submit.to.params ? {
791
+ submit2.to.action,
792
+ submit2.to.params ? {
792
793
  ...values2,
793
- ...propsCopy.submit.to.params
794
+ ...submit2.to.params
794
795
  } : values2
795
796
  )
796
797
  );
@@ -800,26 +801,26 @@ function Form(props) {
800
801
  }
801
802
  setLoading(false);
802
803
  };
803
- } else if (propsCopy.submit && propsCopy.submit.to?.action) {
804
+ } else if (submit2 && submit2.to?.action) {
804
805
  propsCopy.onFinish = async (values) => {
805
806
  setLoading(true);
806
807
  return react.faas(
807
- propsCopy.submit.to.action,
808
- propsCopy.submit.to.params ? {
808
+ submit2.to.action,
809
+ submit2.to.params ? {
809
810
  ...values,
810
- ...propsCopy.submit.to.params
811
+ ...submit2.to.params
811
812
  } : values
812
813
  ).then((result) => {
813
- if (propsCopy.submit.to.then)
814
- propsCopy.submit.to.then(result);
814
+ if (submit2.to.then)
815
+ submit2.to.then(result);
815
816
  return result;
816
817
  }).catch((error) => {
817
- if (propsCopy.submit.to.catch)
818
- propsCopy.submit.to.catch(error);
818
+ if (submit2.to.catch)
819
+ submit2.to.catch(error);
819
820
  return Promise.reject(error);
820
821
  }).finally(() => {
821
- if (propsCopy.submit.to.finally)
822
- propsCopy.submit.to.finally();
822
+ if (submit2.to.finally)
823
+ submit2.to.finally();
823
824
  setLoading(false);
824
825
  });
825
826
  };
@@ -862,7 +863,7 @@ function Form(props) {
862
863
  return item;
863
864
  }),
864
865
  computedProps.children,
865
- computedProps.submit !== false && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: computedProps.submit?.text || config.theme.Form.submit.text }),
866
+ typeof submit !== "boolean" && /* @__PURE__ */ jsxRuntime.jsx(antd.Button, { htmlType: "submit", type: "primary", loading, children: submit?.text || config.theme.Form.submit.text }),
866
867
  computedProps.footer
867
868
  ] });
868
869
  }
package/dist/index.mjs CHANGED
@@ -519,10 +519,9 @@ function FormItem(props) {
519
519
  const { theme } = useConfigContext();
520
520
  const [hidden, setHidden] = useState(props.hidden || false);
521
521
  useEffect(() => {
522
- const propsCopy = { ...props };
523
- if (propsCopy.extendTypes) {
524
- setExtendTypes(propsCopy.extendTypes);
525
- delete propsCopy.extendTypes;
522
+ const { extendTypes: extendTypes2, ...propsCopy } = { ...props };
523
+ if (extendTypes2) {
524
+ setExtendTypes(extendTypes2);
526
525
  }
527
526
  if (propsCopy.if) {
528
527
  const condition = propsCopy.if;
@@ -746,6 +745,7 @@ function isFormItemProps(item) {
746
745
  function Form(props) {
747
746
  const [loading, setLoading] = useState(false);
748
747
  const [computedProps, setComputedProps] = useState();
748
+ const [submit, setSubmit] = useState();
749
749
  const config = useConfigContext();
750
750
  const [extendTypes, setExtendTypes] = useState();
751
751
  const [form] = Form$1.useForm(props.form);
@@ -753,10 +753,11 @@ function Form(props) {
753
753
  props.initialValues
754
754
  );
755
755
  useEffect(() => {
756
- const propsCopy = {
756
+ const { submit: submit2, ...propsCopy } = {
757
757
  ...props,
758
758
  form
759
759
  };
760
+ if (typeof submit2 !== "undefined") setSubmit(submit2);
760
761
  if (propsCopy.initialValues && propsCopy.items?.length) {
761
762
  for (const key in propsCopy.initialValues) {
762
763
  propsCopy.initialValues[key] = transferValue(
@@ -779,14 +780,14 @@ function Form(props) {
779
780
  propsCopy.onFinish = async (values) => {
780
781
  setLoading(true);
781
782
  try {
782
- if (propsCopy.submit?.to?.action) {
783
+ if (submit2?.to?.action) {
783
784
  await props.onFinish(
784
785
  values,
785
786
  async (values2) => faas(
786
- propsCopy.submit.to.action,
787
- propsCopy.submit.to.params ? {
787
+ submit2.to.action,
788
+ submit2.to.params ? {
788
789
  ...values2,
789
- ...propsCopy.submit.to.params
790
+ ...submit2.to.params
790
791
  } : values2
791
792
  )
792
793
  );
@@ -796,26 +797,26 @@ function Form(props) {
796
797
  }
797
798
  setLoading(false);
798
799
  };
799
- } else if (propsCopy.submit && propsCopy.submit.to?.action) {
800
+ } else if (submit2 && submit2.to?.action) {
800
801
  propsCopy.onFinish = async (values) => {
801
802
  setLoading(true);
802
803
  return faas(
803
- propsCopy.submit.to.action,
804
- propsCopy.submit.to.params ? {
804
+ submit2.to.action,
805
+ submit2.to.params ? {
805
806
  ...values,
806
- ...propsCopy.submit.to.params
807
+ ...submit2.to.params
807
808
  } : values
808
809
  ).then((result) => {
809
- if (propsCopy.submit.to.then)
810
- propsCopy.submit.to.then(result);
810
+ if (submit2.to.then)
811
+ submit2.to.then(result);
811
812
  return result;
812
813
  }).catch((error) => {
813
- if (propsCopy.submit.to.catch)
814
- propsCopy.submit.to.catch(error);
814
+ if (submit2.to.catch)
815
+ submit2.to.catch(error);
815
816
  return Promise.reject(error);
816
817
  }).finally(() => {
817
- if (propsCopy.submit.to.finally)
818
- propsCopy.submit.to.finally();
818
+ if (submit2.to.finally)
819
+ submit2.to.finally();
819
820
  setLoading(false);
820
821
  });
821
822
  };
@@ -858,7 +859,7 @@ function Form(props) {
858
859
  return item;
859
860
  }),
860
861
  computedProps.children,
861
- computedProps.submit !== false && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: computedProps.submit?.text || config.theme.Form.submit.text }),
862
+ typeof submit !== "boolean" && /* @__PURE__ */ jsx(Button, { htmlType: "submit", type: "primary", loading, children: submit?.text || config.theme.Form.submit.text }),
862
863
  computedProps.footer
863
864
  ] });
864
865
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "3.0.0-canary.3",
3
+ "version": "3.0.0",
4
4
  "license": "MIT",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -38,7 +38,7 @@
38
38
  "lodash-es": "*"
39
39
  },
40
40
  "peerDependencies": {
41
- "@faasjs/react": "3.0.0-canary.3",
41
+ "@faasjs/react": "3.0.0",
42
42
  "antd": "*",
43
43
  "react": "*",
44
44
  "react-dom": "*",
@@ -46,7 +46,7 @@
46
46
  },
47
47
  "devDependencies": {
48
48
  "@types/lodash-es": "*",
49
- "@faasjs/react": "3.0.0-canary.3",
49
+ "@faasjs/react": "3.0.0",
50
50
  "antd": "*",
51
51
  "react": "*",
52
52
  "react-dom": "*",