@espresso-lab/mantine-data-table 2.1.14 → 2.2.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.
@@ -0,0 +1,19 @@
1
+ type DatesRangeValue = [string | null, string | null];
2
+ interface DateFilter {
3
+ id: string | number;
4
+ type: "date";
5
+ value?: DatesRangeValue;
6
+ }
7
+ interface StringFilter {
8
+ id: string | number;
9
+ type: "query";
10
+ value?: string | string[];
11
+ }
12
+ interface BooleanFilter {
13
+ id: string | number;
14
+ type: "boolean";
15
+ value?: boolean;
16
+ }
17
+ export type Filter = DateFilter | StringFilter | BooleanFilter;
18
+ export declare function applyFilters<T>(data: T[], filters?: Filter[]): T[];
19
+ export {};
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "@espresso-lab/mantine-data-table",
3
3
  "private": false,
4
4
  "description": "Mantine UI Data Table component",
5
- "version": "2.1.14",
5
+ "version": "2.2.0",
6
6
  "type": "module",
7
7
  "main": "./dist/index.umd.js",
8
8
  "module": "./dist/index.es.js",
@@ -22,8 +22,7 @@
22
22
  "import": "./dist/index.es.js",
23
23
  "require": "./dist/index.umd.js",
24
24
  "default": "./dist/index.es.js"
25
- },
26
- "./styles": "./dist/style.css"
25
+ }
27
26
  },
28
27
  "files": [
29
28
  "dist"
@@ -1,104 +0,0 @@
1
- import { BaseEntity } from '../Hooks/useApi';
2
- import { default as React } from 'react';
3
- import { DataTableColumn } from 'mantine-datatable';
4
- type DatesRangeValue = [string | null, string | null];
5
- interface DateFilter {
6
- id: string | number;
7
- type: "date";
8
- value?: DatesRangeValue;
9
- }
10
- interface StringFilter {
11
- id: string | number;
12
- type: "query";
13
- value?: string | string[];
14
- }
15
- interface BooleanFilter {
16
- id: string | number;
17
- type: "boolean";
18
- value?: boolean;
19
- }
20
- type Filter = DateFilter | StringFilter | BooleanFilter;
21
- export type FieldType = "text" | "number" | "boolean" | "custom" | "date" | "textarea";
22
- export interface Field<T> {
23
- id: string;
24
- defaultValue?: T[keyof T];
25
- required?: boolean | ((values: Partial<T>) => boolean);
26
- step?: number;
27
- list: boolean;
28
- create: boolean;
29
- update: boolean;
30
- delete: boolean;
31
- type?: FieldType;
32
- placeholder?: string;
33
- conditional?: (values: Partial<T>) => boolean;
34
- render?: (values: T, setValues: (values: Partial<T>) => void, hideButtons: (value: boolean) => void, validationProps?: {
35
- error?: string;
36
- required?: boolean;
37
- }) => React.ReactNode;
38
- column: DataTableColumn<T>;
39
- }
40
- export interface Action<T extends BaseEntity> {
41
- icon?: React.ReactNode;
42
- label: string;
43
- onClick: (records: T[]) => void;
44
- disabled?: (records: T[]) => boolean;
45
- }
46
- export interface TabOption {
47
- value: string;
48
- label: string;
49
- icon?: React.ReactNode;
50
- queryParams?: Record<string, string | number | boolean | null>;
51
- apiPath?: string;
52
- mutationApiPath?: string;
53
- }
54
- export interface StepConfig {
55
- label: string;
56
- description?: string;
57
- }
58
- export interface DataTableProps<T extends BaseEntity> {
59
- title?: string | React.ReactNode;
60
- queryKey: (string | number)[];
61
- connectedQueryKeys?: (string | number)[][];
62
- apiPath: string;
63
- mutationApiPath?: string;
64
- queryParams?: Record<string, string | number | boolean | null>;
65
- filters?: Filter[];
66
- buttons?: React.ReactNode[];
67
- createButtonText?: string;
68
- actions?: Action<T>[];
69
- selection?: boolean;
70
- pagination?: boolean;
71
- steps?: StepConfig[];
72
- fields: Field<T>[];
73
- defaultSort?: {
74
- field: string;
75
- direction: "asc" | "desc";
76
- };
77
- onSortChange?: (field: string, direction: "asc" | "desc") => void;
78
- tabs?: TabOption[];
79
- defaultTab?: string;
80
- activeTab?: string | null;
81
- onActiveTabChange?: (tabValue: string | null) => void;
82
- canUpdate?: (record: T) => boolean;
83
- canDelete?: (record: T) => boolean;
84
- showRefresh?: boolean;
85
- rowExpansion?: {
86
- allowMultiple?: boolean;
87
- content: (record: T, isMobile: boolean) => React.ReactNode;
88
- expanded?: {
89
- recordIds: unknown[];
90
- onRecordIdsChange: (recordIds: unknown[]) => void;
91
- };
92
- };
93
- onRowClick?: (params: {
94
- record: T;
95
- index: number;
96
- event: React.MouseEvent;
97
- }) => void;
98
- mobileCards?: boolean;
99
- deleteConfirmMessage?: (records: T[]) => React.ReactNode;
100
- editRecordId?: string | null;
101
- onEditRecordIdChange?: (id: string | null) => void;
102
- }
103
- export declare function DataTableInner<T extends BaseEntity>({ title, queryKey, connectedQueryKeys, apiPath, mutationApiPath, buttons, fields, selection, pagination, filters, actions, steps, defaultSort, onSortChange, createButtonText, queryParams, tabs, defaultTab, activeTab: controlledActiveTab, onActiveTabChange, canUpdate, canDelete, showRefresh, rowExpansion, onRowClick, mobileCards, deleteConfirmMessage, editRecordId, onEditRecordIdChange, }: DataTableProps<T>): import("react/jsx-runtime").JSX.Element;
104
- export {};