@espresso-lab/mantine-data-table 1.10.11 → 2.0.0
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/Context/DataTableContext.d.ts +4 -1
- package/dist/DataTable/DataTableInner.d.ts +2 -2
- package/dist/Hooks/useApi.d.ts +8 -108
- package/dist/index.d.ts +3 -2
- package/dist/index.es.js +3754 -7210
- package/dist/index.es.js.map +1 -1
- package/dist/index.umd.js +3 -16
- package/dist/index.umd.js.map +1 -1
- package/package.json +1 -2
- /package/dist/Hooks/{usePersitentState.d.ts → usePersistentState.d.ts} +0 -0
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
import { QueryClient } from '@tanstack/react-query';
|
|
2
2
|
import { ReactNode } from 'react';
|
|
3
|
+
export type GetHeaders = () => Promise<HeadersInit>;
|
|
3
4
|
export interface State {
|
|
4
5
|
baseUrl: string;
|
|
5
6
|
queryClient: QueryClient;
|
|
7
|
+
getHeaders: GetHeaders;
|
|
6
8
|
}
|
|
7
9
|
interface DataTableContextProps {
|
|
8
10
|
baseUrl: string;
|
|
9
11
|
queryClient: QueryClient;
|
|
12
|
+
getHeaders: GetHeaders;
|
|
10
13
|
children: ReactNode | ReactNode[];
|
|
11
14
|
}
|
|
12
15
|
export declare const DataTableContext: import('react').Context<State | undefined>;
|
|
13
|
-
export declare function DataTableProvider({ children, baseUrl, queryClient, }: DataTableContextProps): import("react/jsx-runtime").JSX.Element;
|
|
16
|
+
export declare function DataTableProvider({ children, baseUrl, queryClient, getHeaders, }: DataTableContextProps): import("react/jsx-runtime").JSX.Element;
|
|
14
17
|
export {};
|
|
@@ -86,8 +86,8 @@ export interface DataTableProps<T extends BaseEntity> {
|
|
|
86
86
|
allowMultiple?: boolean;
|
|
87
87
|
content: (record: T) => React.ReactNode;
|
|
88
88
|
expanded?: {
|
|
89
|
-
recordIds:
|
|
90
|
-
onRecordIdsChange: (recordIds:
|
|
89
|
+
recordIds: unknown[];
|
|
90
|
+
onRecordIdsChange: (recordIds: unknown[]) => void;
|
|
91
91
|
};
|
|
92
92
|
};
|
|
93
93
|
onRowClick?: (params: {
|
package/dist/Hooks/useApi.d.ts
CHANGED
|
@@ -1,119 +1,19 @@
|
|
|
1
|
+
import { GetHeaders } from '../Context/DataTableContext.tsx';
|
|
1
2
|
export declare function parseApiError(error: unknown): {
|
|
2
3
|
message: string;
|
|
3
4
|
code?: string;
|
|
4
|
-
details?:
|
|
5
|
+
details?: unknown;
|
|
5
6
|
};
|
|
6
7
|
export interface BaseEntity {
|
|
7
8
|
id: string | number;
|
|
8
9
|
}
|
|
9
10
|
type AtLeast<T, K extends keyof T> = Partial<T> & Pick<T, K>;
|
|
10
|
-
export declare function
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
push(...items: [string, string][]): number;
|
|
17
|
-
concat(...items: ConcatArray<[string, string]>[]): [string, string][];
|
|
18
|
-
concat(...items: ([string, string] | ConcatArray<[string, string]>)[]): [string, string][];
|
|
19
|
-
join(separator?: string): string;
|
|
20
|
-
reverse(): [string, string][];
|
|
21
|
-
shift(): [string, string] | undefined;
|
|
22
|
-
slice(start?: number, end?: number): [string, string][];
|
|
23
|
-
sort(compareFn?: ((a: [string, string], b: [string, string]) => number) | undefined): [string, string][];
|
|
24
|
-
splice(start: number, deleteCount?: number): [string, string][];
|
|
25
|
-
splice(start: number, deleteCount: number, ...items: [string, string][]): [string, string][];
|
|
26
|
-
unshift(...items: [string, string][]): number;
|
|
27
|
-
indexOf(searchElement: [string, string], fromIndex?: number): number;
|
|
28
|
-
lastIndexOf(searchElement: [string, string], fromIndex?: number): number;
|
|
29
|
-
every<S extends [string, string]>(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): this is S[];
|
|
30
|
-
every(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean;
|
|
31
|
-
some(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): boolean;
|
|
32
|
-
forEach(callbackfn: (value: [string, string], index: number, array: [string, string][]) => void, thisArg?: any): void;
|
|
33
|
-
map<U>(callbackfn: (value: [string, string], index: number, array: [string, string][]) => U, thisArg?: any): U[];
|
|
34
|
-
filter<S extends [string, string]>(predicate: (value: [string, string], index: number, array: [string, string][]) => value is S, thisArg?: any): S[];
|
|
35
|
-
filter(predicate: (value: [string, string], index: number, array: [string, string][]) => unknown, thisArg?: any): [string, string][];
|
|
36
|
-
reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string];
|
|
37
|
-
reduce(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string];
|
|
38
|
-
reduce<U>(callbackfn: (previousValue: U, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U, initialValue: U): U;
|
|
39
|
-
reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string]): [string, string];
|
|
40
|
-
reduceRight(callbackfn: (previousValue: [string, string], currentValue: [string, string], currentIndex: number, array: [string, string][]) => [string, string], initialValue: [string, string]): [string, string];
|
|
41
|
-
reduceRight<U>(callbackfn: (previousValue: U, currentValue: [string, string], currentIndex: number, array: [string, string][]) => U, initialValue: U): U;
|
|
42
|
-
find<S extends [string, string]>(predicate: (value: [string, string], index: number, obj: [string, string][]) => value is S, thisArg?: any): S | undefined;
|
|
43
|
-
find(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): [string, string] | undefined;
|
|
44
|
-
findIndex(predicate: (value: [string, string], index: number, obj: [string, string][]) => unknown, thisArg?: any): number;
|
|
45
|
-
fill(value: [string, string], start?: number, end?: number): [string, string][];
|
|
46
|
-
copyWithin(target: number, start: number, end?: number): [string, string][];
|
|
47
|
-
entries(): ArrayIterator<[number, [string, string]]>;
|
|
48
|
-
keys(): ArrayIterator<number>;
|
|
49
|
-
values(): ArrayIterator<[string, string]>;
|
|
50
|
-
includes(searchElement: [string, string], fromIndex?: number): boolean;
|
|
51
|
-
flatMap<U, This = undefined>(callback: (this: This, value: [string, string], index: number, array: [string, string][]) => U | readonly U[], thisArg?: This | undefined): U[];
|
|
52
|
-
flat<A, D extends number = 1>(this: A, depth?: D | undefined): FlatArray<A, D>[];
|
|
53
|
-
[Symbol.iterator](): ArrayIterator<[string, string]>;
|
|
54
|
-
[Symbol.unscopables]: {
|
|
55
|
-
[x: number]: boolean | undefined;
|
|
56
|
-
length?: boolean | undefined;
|
|
57
|
-
toString?: boolean | undefined;
|
|
58
|
-
toLocaleString?: boolean | undefined;
|
|
59
|
-
pop?: boolean | undefined;
|
|
60
|
-
push?: boolean | undefined;
|
|
61
|
-
concat?: boolean | undefined;
|
|
62
|
-
join?: boolean | undefined;
|
|
63
|
-
reverse?: boolean | undefined;
|
|
64
|
-
shift?: boolean | undefined;
|
|
65
|
-
slice?: boolean | undefined;
|
|
66
|
-
sort?: boolean | undefined;
|
|
67
|
-
splice?: boolean | undefined;
|
|
68
|
-
unshift?: boolean | undefined;
|
|
69
|
-
indexOf?: boolean | undefined;
|
|
70
|
-
lastIndexOf?: boolean | undefined;
|
|
71
|
-
every?: boolean | undefined;
|
|
72
|
-
some?: boolean | undefined;
|
|
73
|
-
forEach?: boolean | undefined;
|
|
74
|
-
map?: boolean | undefined;
|
|
75
|
-
filter?: boolean | undefined;
|
|
76
|
-
reduce?: boolean | undefined;
|
|
77
|
-
reduceRight?: boolean | undefined;
|
|
78
|
-
find?: boolean | undefined;
|
|
79
|
-
findIndex?: boolean | undefined;
|
|
80
|
-
fill?: boolean | undefined;
|
|
81
|
-
copyWithin?: boolean | undefined;
|
|
82
|
-
entries?: boolean | undefined;
|
|
83
|
-
keys?: boolean | undefined;
|
|
84
|
-
values?: boolean | undefined;
|
|
85
|
-
includes?: boolean | undefined;
|
|
86
|
-
flatMap?: boolean | undefined;
|
|
87
|
-
flat?: boolean | undefined;
|
|
88
|
-
[Symbol.iterator]?: boolean | undefined;
|
|
89
|
-
readonly [Symbol.unscopables]?: boolean | undefined;
|
|
90
|
-
};
|
|
91
|
-
"Content-Type": string;
|
|
92
|
-
Authorization: string;
|
|
93
|
-
} | {
|
|
94
|
-
"Content-Type": string;
|
|
95
|
-
Authorization: string;
|
|
96
|
-
} | {
|
|
97
|
-
append(name: string, value: string): void;
|
|
98
|
-
delete(name: string): void;
|
|
99
|
-
get(name: string): string | null;
|
|
100
|
-
getSetCookie(): string[];
|
|
101
|
-
has(name: string): boolean;
|
|
102
|
-
set(name: string, value: string): void;
|
|
103
|
-
forEach(callbackfn: (value: string, key: string, parent: Headers) => void, thisArg?: any): void;
|
|
104
|
-
entries(): HeadersIterator<[string, string]>;
|
|
105
|
-
keys(): HeadersIterator<string>;
|
|
106
|
-
values(): HeadersIterator<string>;
|
|
107
|
-
[Symbol.iterator](): HeadersIterator<[string, string]>;
|
|
108
|
-
"Content-Type": string;
|
|
109
|
-
Authorization: string;
|
|
110
|
-
}>;
|
|
111
|
-
export declare function getAll<T extends BaseEntity>(path: string): Promise<T[]>;
|
|
112
|
-
export declare function getOne<T extends BaseEntity>(path: string, id: string | number): Promise<T>;
|
|
113
|
-
export declare function deleteOne(path: string, id: string | number): Promise<void>;
|
|
114
|
-
export declare function createOne<C, T extends BaseEntity>(path: string, item: C): Promise<T>;
|
|
115
|
-
export declare function api<R, U>(method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", path: string, payload?: U): Promise<R>;
|
|
116
|
-
export declare function updateOne<T extends BaseEntity>(path: string, item: AtLeast<T, "id">): Promise<T>;
|
|
11
|
+
export declare function getAll<T extends BaseEntity>(path: string, getHeaders: GetHeaders): Promise<T[]>;
|
|
12
|
+
export declare function getOne<T extends BaseEntity>(path: string, id: string | number, getHeaders: GetHeaders): Promise<T>;
|
|
13
|
+
export declare function deleteOne(path: string, id: string | number, getHeaders: GetHeaders): Promise<void>;
|
|
14
|
+
export declare function createOne<C, T extends BaseEntity>(path: string, item: C, getHeaders: GetHeaders): Promise<T>;
|
|
15
|
+
export declare function api<R, U>(method: "GET" | "POST" | "PUT" | "DELETE" | "PATCH", path: string, getHeaders: GetHeaders, payload?: U): Promise<R>;
|
|
16
|
+
export declare function updateOne<T extends BaseEntity>(path: string, item: AtLeast<T, "id">, getHeaders: GetHeaders): Promise<T>;
|
|
117
17
|
export declare function useGetOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, id?: string | number): import('@tanstack/react-query').UseQueryResult<import('@tanstack/query-core').NoInfer<T>, Error>;
|
|
118
18
|
export declare function useGetAll<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<T[], Error>;
|
|
119
19
|
export declare function useAddOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<T, Error, Omit<T, "id">, unknown>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export type { BaseEntity } from './Hooks/useApi';
|
|
2
|
-
export {
|
|
2
|
+
export { parseApiError, api, useGetOne, useDeleteOne, useGetAll, useUpdateOne, deleteOne, createOne, getAll, updateOne, useAddOne, getOne, } from './Hooks/useApi';
|
|
3
3
|
export type { DataTableProps, FieldType, Field, StepConfig, TabOption, Action, } from './DataTable/DataTableInner.tsx';
|
|
4
4
|
export { DataTable } from './DataTable/DataTable.tsx';
|
|
5
5
|
export { CreateModal } from './DataTable/CreateModal.tsx';
|
|
@@ -9,7 +9,8 @@ export type { UpdateModalProps } from './DataTable/UpdateModal.tsx';
|
|
|
9
9
|
export { DeleteModal } from './DataTable/DeleteModal.tsx';
|
|
10
10
|
export type { DeleteModalProps } from './DataTable/DeleteModal.tsx';
|
|
11
11
|
export { MobileCardList } from './DataTable/MobileCardList.tsx';
|
|
12
|
-
export { usePersistentState } from './Hooks/
|
|
12
|
+
export { usePersistentState } from './Hooks/usePersistentState.ts';
|
|
13
13
|
export { useDataTable } from './Hooks/useDataTable.ts';
|
|
14
14
|
export { DataTableProvider } from './Context/DataTableContext.tsx';
|
|
15
|
+
export type { GetHeaders } from './Context/DataTableContext.tsx';
|
|
15
16
|
export { sortData } from './utils/sort.ts';
|