@espresso-lab/mantine-data-table 2.2.0 → 2.2.2

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.
@@ -4,8 +4,9 @@ export interface CreateModalProps<T> {
4
4
  fields: Field<T>[];
5
5
  onClose: () => void;
6
6
  queryKey: (string | number)[];
7
+ connectedQueryKeys?: (string | number)[][];
7
8
  apiPath: string;
8
9
  steps?: StepConfig[];
9
10
  onCreated?: (id: string | number) => void;
10
11
  }
11
- export declare function CreateModal<T extends BaseEntity>({ fields, onClose, queryKey, apiPath, steps, onCreated, }: CreateModalProps<T>): import("react/jsx-runtime").JSX.Element;
12
+ export declare function CreateModal<T extends BaseEntity>({ fields, onClose, queryKey, connectedQueryKeys, apiPath, steps, onCreated, }: CreateModalProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -3,8 +3,9 @@ import { ReactNode } from 'react';
3
3
  export interface DeleteModalProps<T> {
4
4
  onClose: () => void;
5
5
  queryKey: (string | number)[];
6
+ connectedQueryKeys?: (string | number)[][];
6
7
  apiPath: string;
7
8
  selectedRecords: T[];
8
9
  confirmMessage?: (records: T[]) => ReactNode;
9
10
  }
10
- export declare function DeleteModal<T extends BaseEntity>({ queryKey, apiPath, onClose, selectedRecords, confirmMessage, }: DeleteModalProps<T>): import("react/jsx-runtime").JSX.Element;
11
+ export declare function DeleteModal<T extends BaseEntity>({ queryKey, connectedQueryKeys, apiPath, onClose, selectedRecords, confirmMessage, }: DeleteModalProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -7,7 +7,7 @@ export interface EntityFormProps<T extends BaseEntity> {
7
7
  recordId?: string | number;
8
8
  submitting: boolean;
9
9
  error?: Error | null;
10
- onPersist: (values: T) => Promise<boolean>;
10
+ onPersist: (values: T) => Promise<void>;
11
11
  onClose: () => void;
12
12
  }
13
13
  export declare function EntityForm<T extends BaseEntity>({ fields, steps, record, recordId, submitting, error, onPersist, onClose, }: EntityFormProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -5,7 +5,8 @@ export interface UpdateModalProps<T> {
5
5
  steps?: StepConfig[];
6
6
  onClose: () => void;
7
7
  queryKey: (string | number)[];
8
+ connectedQueryKeys?: (string | number)[][];
8
9
  apiPath: string;
9
10
  id: string | number;
10
11
  }
11
- export declare function UpdateModal<T extends BaseEntity>({ fields, onClose, queryKey, apiPath, id, steps, }: UpdateModalProps<T>): import("react/jsx-runtime").JSX.Element;
12
+ export declare function UpdateModal<T extends BaseEntity>({ fields, onClose, queryKey, connectedQueryKeys, apiPath, id, steps, }: UpdateModalProps<T>): import("react/jsx-runtime").JSX.Element;
@@ -1,9 +1,14 @@
1
1
  import { GetHeaders } from '../Context/DataTableContext.tsx';
2
- export declare function parseApiError(error: unknown): {
2
+ export interface FieldViolation {
3
+ field: string;
3
4
  message: string;
4
- code?: string;
5
- details?: unknown;
6
- };
5
+ }
6
+ export declare class ApiError extends Error {
7
+ readonly status: number;
8
+ readonly violations?: FieldViolation[];
9
+ constructor(message: string, status: number, violations?: FieldViolation[]);
10
+ }
11
+ export declare function getFieldViolations(error: unknown): FieldViolation[] | undefined;
7
12
  export interface BaseEntity {
8
13
  id: string | number;
9
14
  }
@@ -16,7 +21,7 @@ export declare function api<R, U>(method: "GET" | "POST" | "PUT" | "DELETE" | "P
16
21
  export declare function updateOne<T extends BaseEntity>(path: string, item: AtLeast<T, "id">, getHeaders: GetHeaders): Promise<T>;
17
22
  export declare function useGetOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, id?: string | number): import('@tanstack/react-query').UseQueryResult<NoInfer<T>, Error>;
18
23
  export declare function useGetAll<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, enabled?: boolean): import('@tanstack/react-query').UseQueryResult<NoInfer<T[]>, Error>;
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>;
20
- export declare function useUpdateOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<T, Error, AtLeast<T, "id">, unknown>;
21
- export declare function useDeleteOne(apiPath: string, queryKey: Array<string | number>): import('@tanstack/react-query').UseMutationResult<void, Error, string | number, unknown>;
24
+ export declare function useAddOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, connectedQueryKeys?: Array<Array<string | number>>): import('@tanstack/react-query').UseMutationResult<T, Error, Omit<T, "id">, unknown>;
25
+ export declare function useUpdateOne<T extends BaseEntity>(apiPath: string, queryKey: Array<string | number>, connectedQueryKeys?: Array<Array<string | number>>): import('@tanstack/react-query').UseMutationResult<T, Error, AtLeast<T, "id">, unknown>;
26
+ export declare function useDeleteOne(apiPath: string, queryKey: Array<string | number>, connectedQueryKeys?: Array<Array<string | number>>): import('@tanstack/react-query').UseMutationResult<void, Error, string | number, unknown>;
22
27
  export {};
package/dist/index.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  export type { BaseEntity } from './Hooks/useApi';
2
- export { parseApiError, api, useGetOne, useDeleteOne, useGetAll, useUpdateOne, deleteOne, createOne, getAll, updateOne, useAddOne, getOne, } from './Hooks/useApi';
2
+ export { 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/DataTable.tsx';
4
4
  export { DataTable } from './DataTable/DataTable.tsx';
5
5
  export { CreateModal } from './DataTable/CreateModal.tsx';