UNPKG

@refinedev/core

Version:

Refine is a React meta-framework for building enterprise-level, data-intensive applications rapidly with support for modern UI libraries and headless integrations.

87 lines 3.01 kB
import papaparse from "papaparse"; import type { BaseRecord, CrudFilter, CrudSort, MetaQuery } from "../../contexts/data/types"; import type { MapDataFn } from "./types"; type UseExportOptionsType<TData extends BaseRecord = BaseRecord, TVariables = any> = { /** * Resource name for API data interactions * @default Resource name that it reads from route */ resource?: string; /** * A mapping function that runs for every record. Mapped data will be included in the file contents */ mapData?: MapDataFn<TData, TVariables>; /** * Sorts records */ sorters?: CrudSort[]; /** * Filters records */ filters?: CrudFilter[]; maxItemCount?: number; /** * Requests to fetch data are made as batches by page size. By default, it is 20. Used for `getList` method of `DataProvider` */ pageSize?: number; /** * Used for exporting options * @type [UnparseConfig](https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/papaparse) */ unparseConfig?: papaparse.UnparseConfig; /** * Metadata query for `dataProvider` */ meta?: MetaQuery; /** * If there is more than one `dataProvider`, you should use the `dataProviderName` that you will use. */ dataProviderName?: string; /** * Callback to handle error events of this hook */ onError?: (error: any) => void; /** * Whether to generate download of the CSV in browser environments, defaults to true. */ download?: boolean; /** * Custom filename for the export file */ filename?: string; /** * Whether to use text file format instead of CSV * @default false */ useTextFile?: boolean; /** * Whether to include BOM (Byte Order Mark) in the file * @default true */ useBom?: boolean; /** * Title to be shown at the top of the exported file */ title?: string; /** * Whether to show the title in the exported file * @default false */ showTitle?: boolean; }; type UseExportReturnType = { isLoading: boolean; triggerExport: () => Promise<string | undefined>; }; /** * `useExport` hook allows you to make your resources exportable. * * @see {@link https://refine.dev/docs/api-reference/core/hooks/import-export/useExport} for more details. * * @typeParam TData - Result data of the query extends {@link https://refine.dev/docs/api-reference/core/interfaceReferences#baserecord `BaseRecord`} * @typeParam TVariables - Values for params. * */ export declare const useExport: <TData extends BaseRecord = BaseRecord, TVariables = any>({ resource: resourceFromProps, sorters, filters, maxItemCount, pageSize, mapData, unparseConfig, meta, dataProviderName, onError, download, filename: customFilename, useTextFile, useBom, title, showTitle, }?: UseExportOptionsType<TData, TVariables>) => UseExportReturnType; export {}; //# sourceMappingURL=index.d.ts.map