@espresso-lab/mantine-data-table 1.0.5 → 1.0.7
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 +1 -1
- package/dist/DataTable/DataTable.d.ts +3 -55
- package/dist/DataTable/DataTableInner.d.ts +55 -0
- package/dist/DataTable/UpdateModal.d.ts +1 -1
- package/dist/Hooks/useApi.d.ts +12 -10
- package/dist/index.d.ts +2 -2
- package/dist/index.es.js +5286 -5368
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +27 -27
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -1
|
@@ -1,55 +1,3 @@
|
|
|
1
|
-
import { BaseEntity } from '../Hooks/useApi';
|
|
2
|
-
import {
|
|
3
|
-
|
|
4
|
-
import { DatesRangeValue } from '@mantine/dates';
|
|
5
|
-
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
-
interface Filter {
|
|
7
|
-
id: string | number;
|
|
8
|
-
type: "query" | "date";
|
|
9
|
-
value?: string | DatesRangeValue;
|
|
10
|
-
}
|
|
11
|
-
export type FieldType = "text" | "number" | "boolean" | "custom" | "date";
|
|
12
|
-
export interface Field<T> {
|
|
13
|
-
id: string;
|
|
14
|
-
defaultValue?: T[keyof T];
|
|
15
|
-
required?: boolean;
|
|
16
|
-
step?: number;
|
|
17
|
-
list: boolean;
|
|
18
|
-
create: boolean;
|
|
19
|
-
update: boolean;
|
|
20
|
-
delete: boolean;
|
|
21
|
-
type?: FieldType;
|
|
22
|
-
placeholder?: string;
|
|
23
|
-
render?: (values: T, onChange: (value: T) => void, hideButtons: (value: boolean) => void, setValues: (values: T) => void) => React.ReactNode;
|
|
24
|
-
column: DataTableColumn<T>;
|
|
25
|
-
}
|
|
26
|
-
interface Action<T extends BaseEntity> {
|
|
27
|
-
icon?: React.ReactNode;
|
|
28
|
-
label: string;
|
|
29
|
-
onClick: (records: T[]) => void;
|
|
30
|
-
}
|
|
31
|
-
export interface StepConfig {
|
|
32
|
-
label: string;
|
|
33
|
-
description?: string;
|
|
34
|
-
}
|
|
35
|
-
export interface DataTableProps<T extends BaseEntity> {
|
|
36
|
-
title?: string | React.ReactNode;
|
|
37
|
-
queryKey: (string | number)[];
|
|
38
|
-
connectedQueryKeys?: (string | number)[][];
|
|
39
|
-
queryClient: QueryClient;
|
|
40
|
-
apiPath: string;
|
|
41
|
-
filters?: Filter[];
|
|
42
|
-
buttons?: React.ReactNode[];
|
|
43
|
-
createButtonText?: string;
|
|
44
|
-
actions?: Action<T>[];
|
|
45
|
-
selection?: boolean;
|
|
46
|
-
pagination?: boolean;
|
|
47
|
-
steps?: StepConfig[];
|
|
48
|
-
fields: Field<T>[];
|
|
49
|
-
defaultSort?: {
|
|
50
|
-
field: string;
|
|
51
|
-
direction: "asc" | "desc";
|
|
52
|
-
};
|
|
53
|
-
}
|
|
54
|
-
export declare function DataTable<T extends BaseEntity>({ title, queryKey, connectedQueryKeys, apiPath, queryClient, buttons, fields, selection, pagination, filters, actions, steps, defaultSort, createButtonText, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
55
|
-
export {};
|
|
1
|
+
import { BaseEntity } from '../Hooks/useApi.ts';
|
|
2
|
+
import { DataTableProps } from './DataTableInner.tsx';
|
|
3
|
+
export declare function DataTable<T extends BaseEntity>(props: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,55 @@
|
|
|
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
|
+
import { QueryClient } from '@tanstack/react-query';
|
|
6
|
+
interface Filter {
|
|
7
|
+
id: string | number;
|
|
8
|
+
type: "query" | "date";
|
|
9
|
+
value?: string | DatesRangeValue;
|
|
10
|
+
}
|
|
11
|
+
export type FieldType = "text" | "number" | "boolean" | "custom" | "date";
|
|
12
|
+
export interface Field<T> {
|
|
13
|
+
id: string;
|
|
14
|
+
defaultValue?: T[keyof T];
|
|
15
|
+
required?: boolean;
|
|
16
|
+
step?: number;
|
|
17
|
+
list: boolean;
|
|
18
|
+
create: boolean;
|
|
19
|
+
update: boolean;
|
|
20
|
+
delete: boolean;
|
|
21
|
+
type?: FieldType;
|
|
22
|
+
placeholder?: string;
|
|
23
|
+
render?: (values: T, onChange: (value: T) => void, hideButtons: (value: boolean) => void, setValues: (values: T) => void) => React.ReactNode;
|
|
24
|
+
column: DataTableColumn<T>;
|
|
25
|
+
}
|
|
26
|
+
interface Action<T extends BaseEntity> {
|
|
27
|
+
icon?: React.ReactNode;
|
|
28
|
+
label: string;
|
|
29
|
+
onClick: (records: T[]) => void;
|
|
30
|
+
}
|
|
31
|
+
export interface StepConfig {
|
|
32
|
+
label: string;
|
|
33
|
+
description?: string;
|
|
34
|
+
}
|
|
35
|
+
export interface DataTableProps<T extends BaseEntity> {
|
|
36
|
+
title?: string | React.ReactNode;
|
|
37
|
+
queryKey: (string | number)[];
|
|
38
|
+
connectedQueryKeys?: (string | number)[][];
|
|
39
|
+
queryClient: QueryClient;
|
|
40
|
+
apiPath: string;
|
|
41
|
+
filters?: Filter[];
|
|
42
|
+
buttons?: React.ReactNode[];
|
|
43
|
+
createButtonText?: string;
|
|
44
|
+
actions?: Action<T>[];
|
|
45
|
+
selection?: boolean;
|
|
46
|
+
pagination?: boolean;
|
|
47
|
+
steps?: StepConfig[];
|
|
48
|
+
fields: Field<T>[];
|
|
49
|
+
defaultSort?: {
|
|
50
|
+
field: string;
|
|
51
|
+
direction: "asc" | "desc";
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
export declare function DataTableInner<T extends BaseEntity>({ title, queryKey, connectedQueryKeys, apiPath, queryClient, buttons, fields, selection, pagination, filters, actions, steps, defaultSort, createButtonText, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
|
|
55
|
+
export {};
|
package/dist/Hooks/useApi.d.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export interface BaseEntity {
|
|
2
2
|
id: string | number;
|
|
3
3
|
}
|
|
4
|
+
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
|
4
5
|
export declare function getApiHeaders(): Promise<{
|
|
5
6
|
length: number;
|
|
6
7
|
toString(): string;
|
|
@@ -104,15 +105,16 @@ export declare function getApiHeaders(): Promise<{
|
|
|
104
105
|
"Content-Type": string;
|
|
105
106
|
Authorization: string;
|
|
106
107
|
}>;
|
|
107
|
-
|
|
108
|
+
export declare function getAll<T extends BaseEntity>(path: string): Promise<T[]>;
|
|
108
109
|
export declare function getOne<T extends BaseEntity>(path: string, id: string | number): Promise<T>;
|
|
109
|
-
export declare function
|
|
110
|
-
export declare function
|
|
111
|
-
export declare function
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
export declare function
|
|
116
|
-
export declare function
|
|
117
|
-
export declare function
|
|
110
|
+
export declare function deleteOne(path: string, id: string | number): Promise<void>;
|
|
111
|
+
export declare function createOne<C, T extends BaseEntity>(path: string, item: C): Promise<T>;
|
|
112
|
+
export declare function api<R, U>(method: "GET" | "POST" | "PUT" | "DELETE", path: string, payload?: U): Promise<R>;
|
|
113
|
+
export declare function updateOne<T extends BaseEntity>(path: string, item: AtLeast<T, "id">): Promise<T>;
|
|
114
|
+
export declare function useGetOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, id: string | number): import('@tanstack/react-query').UseQueryResult<T, Error>;
|
|
115
|
+
export declare function useGetMany<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, ids: string[] | number[]): (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))[];
|
|
116
|
+
export declare function useGetAll<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<T[], Error>;
|
|
117
|
+
export declare function useAddOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<T, Error, Omit<T, "id">, unknown>;
|
|
118
|
+
export declare function useUpdateOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<T, Error, AtLeast<T, "id">, unknown>;
|
|
119
|
+
export declare function useDeleteOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<void, Error, string | number, unknown>;
|
|
118
120
|
export {};
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
export type { BaseEntity } from './Hooks/useApi';
|
|
2
|
-
export type { DataTableProps } from './DataTable/
|
|
3
|
-
export { DataTable } from './DataTable/DataTable';
|
|
2
|
+
export type { DataTableProps } from './DataTable/DataTableInner.tsx';
|
|
3
|
+
export { DataTable } from './DataTable/DataTable.tsx';
|