@faasjs/ant-design 0.0.2-beta.439 → 0.0.2-beta.440

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
@@ -1,6 +1,6 @@
1
1
  import * as antd_es_calendar_generateCalendar_js from 'antd/es/calendar/generateCalendar.js';
2
2
  import { Dayjs } from 'dayjs';
3
- import { CalendarProps as CalendarProps$1, DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, InputProps, InputNumberProps, SwitchProps, DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1, SelectProps, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, PageHeaderProps } from 'antd';
3
+ import { CalendarProps as CalendarProps$1, DescriptionsProps, DrawerProps as DrawerProps$1, FormItemProps as FormItemProps$1, FormInstance, InputProps, InputNumberProps, SwitchProps, DatePickerProps as DatePickerProps$1, TimePickerProps as TimePickerProps$1, SelectProps, FormProps as FormProps$1, ButtonProps, ModalProps as ModalProps$1, TableColumnProps, TablePaginationConfig, TableProps as TableProps$1, PageHeaderProps } from 'antd';
4
4
  export { Drawer, Modal } from 'antd';
5
5
  import * as react from 'react';
6
6
  import { CSSProperties, ReactNode, LazyExoticComponent, ComponentType } from 'react';
@@ -246,10 +246,12 @@ declare type ExtendTypes = {
246
246
  declare type ExtendFormItemProps = BaseItemProps & FormItemProps$1;
247
247
  declare type FormItemProps<T = any> = {
248
248
  children?: ReactNode;
249
- render?: (value?: any) => ReactNode | JSX.Element;
249
+ render?: (value?: T) => ReactNode | JSX.Element;
250
250
  rules?: RuleObject[];
251
251
  label?: string | false;
252
252
  extendTypes?: ExtendTypes;
253
+ /** trigger when current item's value changed */
254
+ onValueChange?: (value: T, values: any, form: FormInstance) => void;
253
255
  } & FormItemInputProps & FaasItemProps & Omit<FormItemProps$1<T>, 'children'>;
254
256
  /**
255
257
  * FormItem, can be used without Form.
@@ -318,7 +320,6 @@ declare type FormProps<Values = any, ExtendItemProps = any> = {
318
320
  declare function Form<Values = any>(props: FormProps<Values>): JSX.Element;
319
321
  declare namespace Form {
320
322
  var useForm: typeof antd_lib_form_Form.useForm;
321
- var Item: typeof FormItem;
322
323
  }
323
324
 
324
325
  declare type LinkProps = {
package/dist/index.js CHANGED
@@ -747,9 +747,13 @@ function Form(props) {
747
747
  const [computedProps, setComputedProps] = (0, import_react9.useState)();
748
748
  const config = useConfigContext();
749
749
  const [extendTypes, setExtendTypes] = (0, import_react9.useState)();
750
+ const [form] = import_antd6.Form.useForm(props.form);
750
751
  (0, import_react9.useEffect)(() => {
751
752
  var _a2, _b2;
752
- const propsCopy = { ...props };
753
+ const propsCopy = {
754
+ ...props,
755
+ form
756
+ };
753
757
  if (propsCopy.initialValues)
754
758
  for (const key in propsCopy.initialValues)
755
759
  propsCopy.initialValues[key] = transferValue(
@@ -786,6 +790,20 @@ function Form(props) {
786
790
  setExtendTypes(propsCopy.extendTypes);
787
791
  delete propsCopy.extendTypes;
788
792
  }
793
+ let originValuesChange;
794
+ if (propsCopy.onValuesChange)
795
+ originValuesChange = propsCopy.onValuesChange;
796
+ propsCopy.onValuesChange = (changedValues, allValues) => {
797
+ if (originValuesChange)
798
+ originValuesChange(changedValues, allValues);
799
+ if (!propsCopy.items)
800
+ return;
801
+ for (const key in changedValues) {
802
+ const item = propsCopy.items.find((i) => i.id === key);
803
+ if (item == null ? void 0 : item.onValueChange)
804
+ item.onValueChange(changedValues[key], allValues, form);
805
+ }
806
+ };
789
807
  setComputedProps(propsCopy);
790
808
  }, []);
791
809
  if (!computedProps)
@@ -810,7 +828,6 @@ function Form(props) {
810
828
  });
811
829
  }
812
830
  Form.useForm = import_antd6.Form.useForm;
813
- Form.Item = FormItem;
814
831
 
815
832
  // src/Link.tsx
816
833
  var import_react_router_dom = require("react-router-dom");
package/dist/index.mjs CHANGED
@@ -726,9 +726,13 @@ function Form(props) {
726
726
  const [computedProps, setComputedProps] = useState5();
727
727
  const config = useConfigContext();
728
728
  const [extendTypes, setExtendTypes] = useState5();
729
+ const [form] = AntdForm2.useForm(props.form);
729
730
  useEffect4(() => {
730
731
  var _a2, _b2;
731
- const propsCopy = { ...props };
732
+ const propsCopy = {
733
+ ...props,
734
+ form
735
+ };
732
736
  if (propsCopy.initialValues)
733
737
  for (const key in propsCopy.initialValues)
734
738
  propsCopy.initialValues[key] = transferValue(
@@ -765,6 +769,20 @@ function Form(props) {
765
769
  setExtendTypes(propsCopy.extendTypes);
766
770
  delete propsCopy.extendTypes;
767
771
  }
772
+ let originValuesChange;
773
+ if (propsCopy.onValuesChange)
774
+ originValuesChange = propsCopy.onValuesChange;
775
+ propsCopy.onValuesChange = (changedValues, allValues) => {
776
+ if (originValuesChange)
777
+ originValuesChange(changedValues, allValues);
778
+ if (!propsCopy.items)
779
+ return;
780
+ for (const key in changedValues) {
781
+ const item = propsCopy.items.find((i) => i.id === key);
782
+ if (item == null ? void 0 : item.onValueChange)
783
+ item.onValueChange(changedValues[key], allValues, form);
784
+ }
785
+ };
768
786
  setComputedProps(propsCopy);
769
787
  }, []);
770
788
  if (!computedProps)
@@ -789,7 +807,6 @@ function Form(props) {
789
807
  });
790
808
  }
791
809
  Form.useForm = AntdForm2.useForm;
792
- Form.Item = FormItem;
793
810
 
794
811
  // src/Link.tsx
795
812
  import { Link as RouterLink } from "react-router-dom";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@faasjs/ant-design",
3
- "version": "0.0.2-beta.439",
3
+ "version": "0.0.2-beta.440",
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.439",
31
+ "@faasjs/react": "^0.0.2-beta.440",
32
32
  "react-router-dom": "*",
33
33
  "dayjs": "*"
34
34
  },