@espresso-lab/mantine-data-table 1.0.1 → 1.0.3
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/DataTable/CreateModal.d.ts +11 -0
- package/dist/DataTable/DataTable.d.ts +54 -0
- package/dist/DataTable/DeleteModal.d.ts +9 -0
- package/dist/DataTable/UpdateModal.d.ts +12 -0
- package/dist/Hooks/useApi.d.ts +15 -0
- package/dist/Hooks/usePersitentState.d.ts +1 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { BaseEntity } from '../Hooks/useApi';
|
|
2
|
+
import { Field, StepConfig } from './DataTable.tsx';
|
|
3
|
+
export interface CreateModalProps<T> {
|
|
4
|
+
fields: Field<T>[];
|
|
5
|
+
onClose: () => void;
|
|
6
|
+
queryKey: (string | number)[];
|
|
7
|
+
apiPath: string;
|
|
8
|
+
steps?: StepConfig[];
|
|
9
|
+
onCreated?: (id: string | number) => void;
|
|
10
|
+
}
|
|
11
|
+
export declare function CreateModal<T extends BaseEntity>({ fields, onClose, queryKey, apiPath, steps, onCreated, }: CreateModalProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
import { BaseEntity } from '../Hooks/useApi';
|
|
2
|
+
import { default as React } from 'react';
|
|
3
|
+
import { DataTableColumn } from 'mantine-datatable';
|
|
4
|
+
import { DatesRangeValue } from '@mantine/dates';
|
|
5
|
+
interface Filter {
|
|
6
|
+
id: string | number;
|
|
7
|
+
type: "query" | "date";
|
|
8
|
+
value?: string | DatesRangeValue;
|
|
9
|
+
}
|
|
10
|
+
export type FieldType = "text" | "number" | "boolean" | "custom" | "date";
|
|
11
|
+
export interface Field<T> {
|
|
12
|
+
id: string;
|
|
13
|
+
defaultValue?: T[keyof T];
|
|
14
|
+
required?: boolean;
|
|
15
|
+
step?: number;
|
|
16
|
+
list: boolean;
|
|
17
|
+
create: boolean;
|
|
18
|
+
update: boolean;
|
|
19
|
+
delete: boolean;
|
|
20
|
+
type?: FieldType;
|
|
21
|
+
placeholder?: string;
|
|
22
|
+
render?: (values: T, onChange: (value: T) => void, hideButtons: (value: boolean) => void, setValues: (values: T) => void) => React.ReactNode;
|
|
23
|
+
column: DataTableColumn<T>;
|
|
24
|
+
}
|
|
25
|
+
interface Action<T extends BaseEntity> {
|
|
26
|
+
icon?: React.ReactNode;
|
|
27
|
+
label: string;
|
|
28
|
+
onClick: (records: T[]) => void;
|
|
29
|
+
}
|
|
30
|
+
export interface StepConfig {
|
|
31
|
+
label: string;
|
|
32
|
+
description?: string;
|
|
33
|
+
}
|
|
34
|
+
export interface DataTableProps<T extends BaseEntity> {
|
|
35
|
+
title?: string | React.ReactNode;
|
|
36
|
+
queryKey: (string | number)[];
|
|
37
|
+
connectedQueryKeys?: (string | number)[][];
|
|
38
|
+
apiPath: string;
|
|
39
|
+
apiHeaders?: HeadersInit;
|
|
40
|
+
filters?: Filter[];
|
|
41
|
+
buttons?: React.ReactNode[];
|
|
42
|
+
createButtonText?: string;
|
|
43
|
+
actions?: Action<T>[];
|
|
44
|
+
selection?: boolean;
|
|
45
|
+
pagination?: boolean;
|
|
46
|
+
steps?: StepConfig[];
|
|
47
|
+
fields: Field<T>[];
|
|
48
|
+
defaultSort?: {
|
|
49
|
+
field: string;
|
|
50
|
+
direction: "asc" | "desc";
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
export declare function DataTable<T extends BaseEntity>({ title, queryKey, connectedQueryKeys, apiPath, buttons, fields, selection, pagination, filters, actions, steps, defaultSort, createButtonText, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
54
|
+
export {};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { BaseEntity } from '../Hooks/useApi';
|
|
2
|
+
interface DeleteModalProps<T> {
|
|
3
|
+
onClose: () => void;
|
|
4
|
+
queryKey: (string | number)[];
|
|
5
|
+
apiPath: string;
|
|
6
|
+
selectedRecords: T[];
|
|
7
|
+
}
|
|
8
|
+
export declare function DeleteModal<T extends BaseEntity>({ queryKey, apiPath, onClose, selectedRecords, }: DeleteModalProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
9
|
+
export {};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { BaseEntity } from '../Hooks/useApi';
|
|
2
|
+
import { Field, StepConfig } from './DataTable.tsx';
|
|
3
|
+
interface UpdateModalProps<T> {
|
|
4
|
+
fields: Field<T>[];
|
|
5
|
+
steps?: StepConfig[];
|
|
6
|
+
onClose: () => void;
|
|
7
|
+
queryKey: (string | number)[];
|
|
8
|
+
apiPath: string;
|
|
9
|
+
id: string | number;
|
|
10
|
+
}
|
|
11
|
+
export declare function UpdateModal<T extends BaseEntity>({ fields, onClose, queryKey, apiPath, id, steps, }: UpdateModalProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
12
|
+
export {};
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
export interface BaseEntity {
|
|
2
|
+
id: string | number;
|
|
3
|
+
}
|
|
4
|
+
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
|
5
|
+
export declare function getOne<T extends BaseEntity>(path: string, id: string | number, headers?: HeadersInit): Promise<T>;
|
|
6
|
+
export declare function useGetOne<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], id: string | number, headers?: HeadersInit): import('@tanstack/react-query').UseQueryResult<T, Error>;
|
|
7
|
+
export declare function useGetMany<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], ids: string[] | number[], headers?: HeadersInit): (unknown extends T | import('@tanstack/query-core').InitialDataFunction<T> ? import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : (T extends (unknown extends T ? T : T) ? import('@tanstack/react-query').DefinedUseQueryResult<unknown extends T ? T : T, Error> : T extends () => infer TInitialDataResult ? unknown extends TInitialDataResult ? import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : TInitialDataResult extends (unknown extends T ? T : T) ? import('@tanstack/react-query').DefinedUseQueryResult<unknown extends T ? T : T, Error> : import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error>) | (import('@tanstack/query-core').InitialDataFunction<T> extends infer T_1 ? T_1 extends import('@tanstack/query-core').InitialDataFunction<T> ? T_1 extends (unknown extends T ? T : T) ? import('@tanstack/react-query').DefinedUseQueryResult<unknown extends T ? T : T, Error> : T_1 extends () => infer TInitialDataResult ? unknown extends TInitialDataResult ? import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : TInitialDataResult extends (unknown extends T ? T : T) ? import('@tanstack/react-query').DefinedUseQueryResult<unknown extends T ? T : T, Error> : import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : import('@tanstack/react-query').UseQueryResult<unknown extends T ? T : T, Error> : never : never))[];
|
|
8
|
+
export declare function useGetAll<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], enabled?: boolean, headers?: HeadersInit): import('@tanstack/react-query').UseQueryResult<T[], Error>;
|
|
9
|
+
interface MutationContext<T> {
|
|
10
|
+
previousItems: T[] | undefined;
|
|
11
|
+
}
|
|
12
|
+
export declare function useAddOne<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], headers?: HeadersInit): import('@tanstack/react-query').UseMutationResult<T, Error, Omit<T, "id">, MutationContext<T>>;
|
|
13
|
+
export declare function useUpdateOne<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], headers?: HeadersInit): import('@tanstack/react-query').UseMutationResult<T, Error, AtLeast<T, "id">, MutationContext<T>>;
|
|
14
|
+
export declare function useDeleteOne<T extends BaseEntity>(apiPath: string, queryKey: (string | number)[], headers?: HeadersInit): import('@tanstack/react-query').UseMutationResult<void, Error, string | number, MutationContext<T>>;
|
|
15
|
+
export {};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export default function usePersistentState<T>(initialValue: T, key: string): [T, (value: T) => void];
|
package/dist/index.d.ts
ADDED