@refinedev/antd
Advanced tools
Comparing version 5.13.2 to 5.14.0
@@ -1,3 +0,6 @@ | ||
import type { RefineThemedLayoutV2SiderProps, RefineThemedLayoutV2HeaderProps, RefineThemedLayoutV2Props, RefineLayoutThemedTitleProps } from "@refinedev/ui-types"; | ||
import type { RefineThemedLayoutV2SiderProps as BaseRefineThemedLayoutV2SiderProps, RefineThemedLayoutV2HeaderProps, RefineThemedLayoutV2Props, RefineLayoutThemedTitleProps } from "@refinedev/ui-types"; | ||
declare type RefineThemedLayoutV2SiderProps = BaseRefineThemedLayoutV2SiderProps & { | ||
fixed?: boolean; | ||
}; | ||
export type { RefineLayoutThemedTitleProps, RefineThemedLayoutV2SiderProps, RefineThemedLayoutV2HeaderProps, RefineThemedLayoutV2Props, }; | ||
//# sourceMappingURL=types.d.ts.map |
import { FormInstance, FormProps, ModalProps } from "antd"; | ||
import { UseModalFormConfig as UseModalFormConfigSF } from "sunflower-antd"; | ||
import { HttpError, UseFormProps as UseFormPropsCore, BaseRecord, LiveModeProps, BaseKey, FormWithSyncWithLocationParams } from "@refinedev/core"; | ||
@@ -25,3 +24,7 @@ import { UseFormProps, UseFormReturnType } from "../useForm"; | ||
export declare type UseModalFormReturnType<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = Omit<UseFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>, "saveButtonProps" | "deleteButtonProps"> & useModalFormFromSFReturnType<TResponse, TVariables>; | ||
export declare type UseModalFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = UseFormPropsCore<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & UseModalFormConfigSF & useModalFormConfig & LiveModeProps & FormWithSyncWithLocationParams; | ||
export declare type UseModalFormProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError> = UseFormPropsCore<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & UseFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError> & useModalFormConfig & LiveModeProps & FormWithSyncWithLocationParams & { | ||
defaultVisible?: boolean; | ||
autoSubmitClose?: boolean; | ||
autoResetForm?: boolean; | ||
}; | ||
/** | ||
@@ -38,4 +41,4 @@ * `useModalForm` hook allows you to manage a form within a modal. It returns Ant Design {@link https://ant.design/components/form/ Form} and {@link https://ant.design/components/modal/ Modal} components props. | ||
*/ | ||
export declare const useModalForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ syncWithLocation, ...rest }: UseModalFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseModalFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>; | ||
export declare const useModalForm: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TData extends BaseRecord = TQueryFnData, TResponse extends BaseRecord = TData, TResponseError extends HttpError = TError>({ syncWithLocation, defaultVisible, autoSubmitClose, autoResetForm, ...rest }: UseModalFormProps<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>) => UseModalFormReturnType<TQueryFnData, TError, TVariables, TData, TResponse, TResponseError>; | ||
export {}; | ||
//# sourceMappingURL=useModalForm.d.ts.map |
@@ -17,3 +17,8 @@ import { BaseKey, BaseRecord, HttpError, UseFormProps } from "@refinedev/core"; | ||
}; | ||
declare type useEditableTableProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSearchVariables = unknown, TData extends BaseRecord = TQueryFnData> = Omit<useTableProps<TQueryFnData, TError, TSearchVariables, TData>, "successNotification" | "errorNotification"> & UseFormProps<TQueryFnData, TError, TVariables>; | ||
declare type useEditableTableProps<TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSearchVariables = unknown, TData extends BaseRecord = TQueryFnData> = Omit<useTableProps<TQueryFnData, TError, TSearchVariables, TData>, "successNotification" | "errorNotification"> & UseFormProps<TQueryFnData, TError, TVariables> & { | ||
/** | ||
* When true, row will be closed after successful submit. | ||
*/ | ||
autoSubmitClose?: boolean; | ||
}; | ||
/** | ||
@@ -34,4 +39,4 @@ * `useEditeableTable` allows you to implement edit feature on the table with ease, | ||
*/ | ||
export declare const useEditableTable: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSearchVariables = unknown, TData extends BaseRecord = TQueryFnData>(props?: useEditableTableProps<TQueryFnData, TError, TVariables, TSearchVariables, TData>) => useEditableTableReturnType<TQueryFnData, TError, TVariables, TSearchVariables, TData>; | ||
export declare const useEditableTable: <TQueryFnData extends BaseRecord = BaseRecord, TError extends HttpError = HttpError, TVariables = {}, TSearchVariables = unknown, TData extends BaseRecord = TQueryFnData>({ autoSubmitClose, ...props }?: useEditableTableProps<TQueryFnData, TError, TVariables, TSearchVariables, TData>) => useEditableTableReturnType<TQueryFnData, TError, TVariables, TSearchVariables, TData>; | ||
export {}; | ||
//# sourceMappingURL=useEditableTable.d.ts.map |
{ | ||
"name": "@refinedev/antd", | ||
"version": "5.13.2", | ||
"version": "5.14.0", | ||
"description": "refine is a React-based framework for building internal tools, rapidly. It ships with Ant Design System, an enterprise-level UI toolkit.", | ||
@@ -28,3 +28,3 @@ "private": false, | ||
"@refinedev/ui-tests": "^1.3.2", | ||
"@refinedev/core": "^4.14.0", | ||
"@refinedev/core": "^4.14.1", | ||
"@esbuild-plugins/node-resolve": "^0.1.4", | ||
@@ -31,0 +31,0 @@ "@testing-library/jest-dom": "^5.16.4", |
import type { | ||
RefineThemedLayoutV2SiderProps, | ||
RefineThemedLayoutV2SiderProps as BaseRefineThemedLayoutV2SiderProps, | ||
RefineThemedLayoutV2HeaderProps, | ||
@@ -8,2 +8,6 @@ RefineThemedLayoutV2Props, | ||
type RefineThemedLayoutV2SiderProps = BaseRefineThemedLayoutV2SiderProps & { | ||
fixed?: boolean; | ||
}; | ||
export type { | ||
@@ -10,0 +14,0 @@ RefineLayoutThemedTitleProps, |
@@ -211,17 +211,7 @@ import React, { useCallback } from "react"; | ||
const submit = async () => { | ||
await onFinish(form.getFieldsValue()); | ||
if (autoSubmitClose) { | ||
close(); | ||
} | ||
if (autoResetForm) { | ||
form.resetFields(); | ||
} | ||
}; | ||
const saveButtonProps = { | ||
disabled: formLoading, | ||
onClick: submit, | ||
onClick: () => { | ||
form.submit(); | ||
}, | ||
loading: formLoading, | ||
@@ -282,3 +272,13 @@ }; | ||
onKeyUp: formProps?.onKeyUp, | ||
onFinish: formProps.onFinish, | ||
onFinish: async (values) => { | ||
await onFinish(values); | ||
if (autoSubmitClose) { | ||
close(); | ||
} | ||
if (autoResetForm) { | ||
form.resetFields(); | ||
} | ||
}, | ||
}, | ||
@@ -285,0 +285,0 @@ drawerProps: { |
import React, { useCallback } from "react"; | ||
import { FormInstance, FormProps, ModalProps } from "antd"; | ||
import { | ||
useModalForm as useModalFormSF, | ||
UseModalFormConfig as UseModalFormConfigSF, | ||
} from "sunflower-antd"; | ||
@@ -23,2 +19,3 @@ import { | ||
import { useForm, UseFormProps, UseFormReturnType } from "../useForm"; | ||
import { useModal } from "@hooks/modal"; | ||
@@ -89,6 +86,9 @@ export type useModalFormFromSFReturnType<TResponse, TVariables> = { | ||
> & | ||
UseModalFormConfigSF & | ||
useModalFormConfig & | ||
LiveModeProps & | ||
FormWithSyncWithLocationParams; | ||
FormWithSyncWithLocationParams & { | ||
defaultVisible?: boolean; | ||
autoSubmitClose?: boolean; | ||
autoResetForm?: boolean; | ||
}; | ||
/** | ||
@@ -114,2 +114,5 @@ * `useModalForm` hook allows you to manage a form within a modal. It returns Ant Design {@link https://ant.design/components/form/ Form} and {@link https://ant.design/components/modal/ Modal} components props. | ||
syncWithLocation, | ||
defaultVisible = false, | ||
autoSubmitClose = true, | ||
autoResetForm = true, | ||
...rest | ||
@@ -167,14 +170,27 @@ }: UseModalFormProps< | ||
const sunflowerUseModal = useModalFormSF<TResponse, TVariables>({ | ||
...rest, | ||
form: form, | ||
submit: onFinish as any, | ||
const { show, close, modalProps } = useModal({ | ||
modalProps: { | ||
open: defaultVisible, | ||
}, | ||
}); | ||
const { | ||
const visible = modalProps.open || false; | ||
const sunflowerUseModal: useModalFormFromSFReturnType< | ||
TResponse, | ||
TVariables | ||
> = { | ||
modalProps, | ||
form, | ||
formLoading, | ||
formProps, | ||
formResult: undefined, | ||
formValues: form.getFieldsValue, | ||
defaultFormValuesLoading: false, | ||
initialValues: {}, | ||
submit: onFinish as any, | ||
close, | ||
open: modalProps.open || false, | ||
show, | ||
visible, | ||
show, | ||
formProps: modalFormProps, | ||
modalProps, | ||
} = sunflowerUseModal; | ||
}; | ||
@@ -234,2 +250,5 @@ React.useEffect(() => { | ||
loading: formLoading, | ||
onClick: () => { | ||
form.submit(); | ||
}, | ||
}; | ||
@@ -282,7 +301,17 @@ | ||
formProps: { | ||
...modalFormProps, | ||
...formProps, | ||
...useFormProps.formProps, | ||
onValuesChange: formProps?.onValuesChange, | ||
onKeyUp: formProps?.onKeyUp, | ||
onFinish: formProps.onFinish, | ||
onFinish: async (values) => { | ||
await onFinish(values); | ||
if (autoSubmitClose) { | ||
close(); | ||
} | ||
if (autoResetForm) { | ||
form.resetFields(); | ||
} | ||
}, | ||
}, | ||
@@ -289,0 +318,0 @@ modalProps: { |
@@ -38,3 +38,8 @@ import { useTable } from "@hooks"; | ||
> & | ||
UseFormProps<TQueryFnData, TError, TVariables>; | ||
UseFormProps<TQueryFnData, TError, TVariables> & { | ||
/** | ||
* When true, row will be closed after successful submit. | ||
*/ | ||
autoSubmitClose?: boolean; | ||
}; | ||
@@ -62,11 +67,6 @@ /** | ||
TData extends BaseRecord = TQueryFnData, | ||
>( | ||
props: useEditableTableProps< | ||
TQueryFnData, | ||
TError, | ||
TVariables, | ||
TSearchVariables, | ||
TData | ||
> = {}, | ||
): useEditableTableReturnType< | ||
>({ | ||
autoSubmitClose = true, | ||
...props | ||
}: useEditableTableProps< | ||
TQueryFnData, | ||
@@ -77,2 +77,8 @@ TError, | ||
TData | ||
> = {}): useEditableTableReturnType< | ||
TQueryFnData, | ||
TError, | ||
TVariables, | ||
TSearchVariables, | ||
TData | ||
> => { | ||
@@ -109,2 +115,12 @@ const table = useTable<TQueryFnData, TError, TSearchVariables, TData>({ | ||
...edit, | ||
formProps: { | ||
...edit.formProps, | ||
onFinish: async (values) => { | ||
const result = await edit.onFinish(values); | ||
if (autoSubmitClose) { | ||
setId(undefined); | ||
} | ||
return result; | ||
}, | ||
}, | ||
saveButtonProps, | ||
@@ -111,0 +127,0 @@ cancelButtonProps, |
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is too big to display
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2518337
10814