react-kd-grid 5.0.8 → 5.0.9
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/components/ui/Badge.d.ts +14 -0
- package/dist/components/ui/Dropdown.d.ts +21 -0
- package/dist/components/ui/Modal.d.ts +17 -0
- package/dist/components/ui/Tooltip.d.ts +14 -0
- package/dist/grid/components/Shared/PaginationControls.d.ts +1 -1
- package/dist/grid/hooks/useGridServerData.d.ts +89 -0
- package/dist/grid/hooks/usePagination.d.ts +2 -1
- package/dist/grid/theme/KDGridProvider.d.ts +17 -0
- package/dist/grid/theme/defaultTheme.d.ts +6 -0
- package/dist/grid/theme/types.d.ts +28 -0
- package/dist/grid/theme/utils.d.ts +8 -0
- package/dist/grid/types.d.ts +5 -0
- package/dist/icons/index.d.ts +7 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.esm.js +1 -1
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export type BadgeVariant = "default" | "primary" | "success" | "warning" | "destructive" | "outline";
|
|
3
|
+
interface BadgeProps {
|
|
4
|
+
children: React.ReactNode;
|
|
5
|
+
variant?: BadgeVariant;
|
|
6
|
+
className?: string;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Badge Component
|
|
10
|
+
*
|
|
11
|
+
* A pill-shaped label for status markers and indicators.
|
|
12
|
+
*/
|
|
13
|
+
export declare const Badge: ({ children, variant, className, }: BadgeProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
export interface DropdownItem {
|
|
3
|
+
label: string;
|
|
4
|
+
onClick: () => void;
|
|
5
|
+
icon?: React.ReactNode;
|
|
6
|
+
variant?: "default" | "destructive";
|
|
7
|
+
disabled?: boolean;
|
|
8
|
+
}
|
|
9
|
+
interface DropdownProps {
|
|
10
|
+
trigger: React.ReactNode;
|
|
11
|
+
items: DropdownItem[];
|
|
12
|
+
align?: "left" | "right";
|
|
13
|
+
className?: string;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Dropdown Component
|
|
17
|
+
*
|
|
18
|
+
* A flexible menu component for actions and options, with theme-aware styling.
|
|
19
|
+
*/
|
|
20
|
+
export declare const Dropdown: ({ trigger, items, align, className, }: DropdownProps) => import("react/jsx-runtime").JSX.Element;
|
|
21
|
+
export {};
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface ModalProps {
|
|
3
|
+
isOpen: boolean;
|
|
4
|
+
onClose: () => void;
|
|
5
|
+
title?: string;
|
|
6
|
+
children: React.ReactNode;
|
|
7
|
+
footer?: React.ReactNode;
|
|
8
|
+
size?: "sm" | "md" | "lg" | "xl" | "full";
|
|
9
|
+
showCloseButton?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* Modal Component
|
|
13
|
+
*
|
|
14
|
+
* A premium, theme-aware dialog component with blurred backdrop and smooth transitions.
|
|
15
|
+
*/
|
|
16
|
+
export declare const Modal: ({ isOpen, onClose, title, children, footer, size, showCloseButton, }: ModalProps) => React.ReactPortal;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
interface TooltipProps {
|
|
3
|
+
content: React.ReactNode;
|
|
4
|
+
children: React.ReactElement;
|
|
5
|
+
position?: "top" | "bottom" | "left" | "right";
|
|
6
|
+
delay?: number;
|
|
7
|
+
}
|
|
8
|
+
/**
|
|
9
|
+
* Tooltip Component
|
|
10
|
+
*
|
|
11
|
+
* A lightweight, portal-rendered hover overlay for contextual information.
|
|
12
|
+
*/
|
|
13
|
+
export declare const Tooltip: ({ content, children, position, delay, }: TooltipProps) => import("react/jsx-runtime").JSX.Element;
|
|
14
|
+
export {};
|
|
@@ -12,7 +12,7 @@ interface PaginationControlsProps {
|
|
|
12
12
|
showNoDataMessage?: boolean;
|
|
13
13
|
}
|
|
14
14
|
export declare const PaginationControls: import("react").MemoExoticComponent<{
|
|
15
|
-
({ paginationConfig, currentPage, isServerLoading, selectedRowsCount, totalDataLength,
|
|
15
|
+
({ paginationConfig, currentPage, isServerLoading, selectedRowsCount, totalDataLength, paginationMode, onPageChange, onPageSizeChange, }: PaginationControlsProps): import("react/jsx-runtime").JSX.Element;
|
|
16
16
|
displayName: string;
|
|
17
17
|
}>;
|
|
18
18
|
export {};
|
|
@@ -0,0 +1,89 @@
|
|
|
1
|
+
import { GridRow, ActiveFilters, ServerFilterChangePayload, SortDirection, PaginationOptions } from "../types";
|
|
2
|
+
/**
|
|
3
|
+
* Internal state representation for server-side requests.
|
|
4
|
+
*/
|
|
5
|
+
export interface GridServerParams {
|
|
6
|
+
page: number;
|
|
7
|
+
pageSize: number;
|
|
8
|
+
sortField: string | null;
|
|
9
|
+
sortOrder: SortDirection;
|
|
10
|
+
globalFilter: string;
|
|
11
|
+
columnFilters: ActiveFilters;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* Options for the useGridServerData hook.
|
|
15
|
+
*/
|
|
16
|
+
export interface UseGridServerDataOptions<T> {
|
|
17
|
+
/** The base API endpoint URL. */
|
|
18
|
+
url: string;
|
|
19
|
+
/** Initial number of rows per page. Default: 25. */
|
|
20
|
+
initialPageSize?: number;
|
|
21
|
+
/** Initial sorting configuration. */
|
|
22
|
+
initialSort?: {
|
|
23
|
+
key: string | null;
|
|
24
|
+
direction: SortDirection;
|
|
25
|
+
};
|
|
26
|
+
/** Debounce delay for search and filter changes in ms. Default: 300ms. */
|
|
27
|
+
debounceMs?: number;
|
|
28
|
+
/**
|
|
29
|
+
* Custom mapping from internal grid state to API query parameters.
|
|
30
|
+
* If not provided, standard query params are used.
|
|
31
|
+
*/
|
|
32
|
+
mapParams?: (params: GridServerParams) => Record<string, any>;
|
|
33
|
+
/**
|
|
34
|
+
* Post-process the API response.
|
|
35
|
+
* Expected to return the row data and total count.
|
|
36
|
+
*/
|
|
37
|
+
mapResponse?: (response: any) => {
|
|
38
|
+
data: T[];
|
|
39
|
+
total: number;
|
|
40
|
+
};
|
|
41
|
+
/** Additional static headers for the fetch request. */
|
|
42
|
+
headers?: Record<string, string>;
|
|
43
|
+
/** Optional static params to always include in every request. */
|
|
44
|
+
staticParams?: Record<string, any>;
|
|
45
|
+
/** Custom fetch implementation. Defaults to window.fetch. */
|
|
46
|
+
fetcher?: (url: string, init?: RequestInit) => Promise<Response>;
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Standardized hook for orchestrating server-side data fetching for KDGrid.
|
|
50
|
+
*
|
|
51
|
+
* Handles:
|
|
52
|
+
* - Pagination (mode: server)
|
|
53
|
+
* - Sorting
|
|
54
|
+
* - Filtering (Global & Column)
|
|
55
|
+
* - Debouncing
|
|
56
|
+
* - Loading & Error States
|
|
57
|
+
*/
|
|
58
|
+
export declare const useGridServerData: <T extends GridRow>({ url, initialPageSize, initialSort, debounceMs, mapParams, mapResponse, headers, staticParams, fetcher, }: UseGridServerDataOptions<T>) => {
|
|
59
|
+
data: T[];
|
|
60
|
+
loading: boolean;
|
|
61
|
+
error: Error;
|
|
62
|
+
totalCount: number;
|
|
63
|
+
gridProps: {
|
|
64
|
+
data: T[];
|
|
65
|
+
loading: boolean;
|
|
66
|
+
pagination: PaginationOptions;
|
|
67
|
+
onSort: (key: string, direction: SortDirection) => void;
|
|
68
|
+
onFilterChange: (payload: ServerFilterChangePayload) => void;
|
|
69
|
+
};
|
|
70
|
+
params: {
|
|
71
|
+
page: number;
|
|
72
|
+
pageSize: number;
|
|
73
|
+
sortConfig: {
|
|
74
|
+
key: string | null;
|
|
75
|
+
direction: SortDirection;
|
|
76
|
+
};
|
|
77
|
+
globalFilter: string;
|
|
78
|
+
columnFilters: ActiveFilters;
|
|
79
|
+
};
|
|
80
|
+
refresh: () => Promise<void>;
|
|
81
|
+
setPage: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
82
|
+
setPageSize: import("react").Dispatch<import("react").SetStateAction<number>>;
|
|
83
|
+
setSortConfig: import("react").Dispatch<import("react").SetStateAction<{
|
|
84
|
+
key: string | null;
|
|
85
|
+
direction: SortDirection;
|
|
86
|
+
}>>;
|
|
87
|
+
setGlobalFilter: import("react").Dispatch<import("react").SetStateAction<string>>;
|
|
88
|
+
setColumnFilters: import("react").Dispatch<import("react").SetStateAction<ActiveFilters>>;
|
|
89
|
+
};
|
|
@@ -15,8 +15,9 @@ interface UsePaginationProps {
|
|
|
15
15
|
totalRows: number;
|
|
16
16
|
};
|
|
17
17
|
};
|
|
18
|
+
isLoading?: boolean;
|
|
18
19
|
}
|
|
19
|
-
export declare const usePagination: ({ data, pagination }: UsePaginationProps) => {
|
|
20
|
+
export declare const usePagination: ({ data, pagination, isLoading }: UsePaginationProps) => {
|
|
20
21
|
currentPage: number;
|
|
21
22
|
resetPage: () => void;
|
|
22
23
|
paginationConfig: PaginationConfig;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KDGridTheme, ThemeContextValue, ThemeMode } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Hook to access the current grid theme and mode.
|
|
5
|
+
*/
|
|
6
|
+
export declare const useKDGridTheme: () => ThemeContextValue;
|
|
7
|
+
interface KDGridProviderProps {
|
|
8
|
+
theme?: KDGridTheme;
|
|
9
|
+
defaultMode?: ThemeMode;
|
|
10
|
+
children: React.ReactNode;
|
|
11
|
+
}
|
|
12
|
+
/**
|
|
13
|
+
* Centralize theming provider for the Data Grid ecosystem.
|
|
14
|
+
* Injects CSS variables and manages light/dark mode logic.
|
|
15
|
+
*/
|
|
16
|
+
export declare const KDGridProvider: React.FC<KDGridProviderProps>;
|
|
17
|
+
export {};
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
export type ThemeMode = "light" | "dark" | "system";
|
|
2
|
+
export interface KDGridColors {
|
|
3
|
+
primary: string;
|
|
4
|
+
primaryForeground: string;
|
|
5
|
+
accent: string;
|
|
6
|
+
accentForeground: string;
|
|
7
|
+
background: string;
|
|
8
|
+
foreground: string;
|
|
9
|
+
muted: string;
|
|
10
|
+
mutedForeground: string;
|
|
11
|
+
border: string;
|
|
12
|
+
ring: string;
|
|
13
|
+
}
|
|
14
|
+
export interface KDGridTheme {
|
|
15
|
+
name: string;
|
|
16
|
+
colors: {
|
|
17
|
+
light: KDGridColors;
|
|
18
|
+
dark: KDGridColors;
|
|
19
|
+
};
|
|
20
|
+
radius: string;
|
|
21
|
+
shadow: string;
|
|
22
|
+
}
|
|
23
|
+
export interface ThemeContextValue {
|
|
24
|
+
theme: KDGridTheme;
|
|
25
|
+
mode: ThemeMode;
|
|
26
|
+
resolvedMode: "light" | "dark";
|
|
27
|
+
setMode: (mode: ThemeMode) => void;
|
|
28
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import React from "react";
|
|
2
|
+
import { KDGridColors } from "./types";
|
|
3
|
+
/**
|
|
4
|
+
* Generates an object of CSS variables from theme colors.
|
|
5
|
+
* These are injected into the root container to allow child components
|
|
6
|
+
* to use theme-based colors without explicit context lookups in CSS.
|
|
7
|
+
*/
|
|
8
|
+
export declare const generateCssVars: (colors: KDGridColors, radius: string) => React.CSSProperties;
|
package/dist/grid/types.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { CSSProperties, MouseEvent, ReactNode } from "react";
|
|
2
|
+
import { KDGridTheme, ThemeMode } from "./theme/types";
|
|
2
3
|
/** Used internally by useVirtualization and GridRows. Not part of the public API. */
|
|
3
4
|
export interface VirtualizedRange {
|
|
4
5
|
startIndex: number;
|
|
@@ -533,6 +534,10 @@ export interface KDGridProps {
|
|
|
533
534
|
* Pair with `onCellEdit` to receive the committed values.
|
|
534
535
|
*/
|
|
535
536
|
editable?: boolean;
|
|
537
|
+
/** Custom theme configuration. Falls back to default blue theme. */
|
|
538
|
+
theme?: KDGridTheme;
|
|
539
|
+
/** Theme mode: "light", "dark", or "system". Default "system". */
|
|
540
|
+
themeMode?: ThemeMode;
|
|
536
541
|
}
|
|
537
542
|
export interface KDGridRef {
|
|
538
543
|
/** Replace the entire ordered grouping key list. */
|
package/dist/icons/index.d.ts
CHANGED
|
@@ -44,6 +44,13 @@ export declare const FileText: (p: IconProps) => import("react/jsx-runtime").JSX
|
|
|
44
44
|
export declare const Table: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
45
45
|
export declare const Columns: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
46
46
|
export declare const Users: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
|
+
export declare const User: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
|
+
export declare const Plus: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
|
+
export declare const LogOut: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
50
|
+
export declare const Info: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
51
|
+
export declare const CheckCircle2: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
52
|
+
export declare const AlertTriangle: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
53
|
+
export declare const XCircle: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
47
54
|
export declare const LocateFixed: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
48
55
|
export declare const Loader2: (p: IconProps) => import("react/jsx-runtime").JSX.Element;
|
|
49
56
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
export { KDGrid } from "./grid/core/DataGrid";
|
|
2
2
|
export { default } from "./grid/core/DataGrid";
|
|
3
|
+
export { KDGridProvider, useKDGridTheme } from "./grid/theme/KDGridProvider";
|
|
4
|
+
export { useGridServerData } from "./grid/hooks/useGridServerData";
|
|
5
|
+
export type { UseGridServerDataOptions, GridServerParams, } from "./grid/hooks/useGridServerData";
|
|
6
|
+
export { defaultTheme } from "./grid/theme/defaultTheme";
|
|
7
|
+
export type { KDGridTheme, ThemeMode, KDGridColors } from "./grid/theme/types";
|
|
3
8
|
export { Button } from "./components/ui/Button";
|
|
4
9
|
export { TextField } from "./components/ui/TextField";
|
|
5
10
|
export { Checkbox } from "./components/ui/Checkbox";
|
|
6
11
|
export { Popover } from "./components/ui/Popover";
|
|
7
12
|
export { CustomSelect } from "./components/ui/CustomSelect";
|
|
8
13
|
export { DatePicker } from "./components/ui/DatePicker";
|
|
14
|
+
export { Modal } from "./components/ui/Modal";
|
|
15
|
+
export { Badge } from "./components/ui/Badge";
|
|
16
|
+
export { Tooltip } from "./components/ui/Tooltip";
|
|
17
|
+
export { Dropdown } from "./components/ui/Dropdown";
|
|
18
|
+
export type { DropdownItem } from "./components/ui/Dropdown";
|
|
9
19
|
export type { KDGridProps, KDGridRef, GridColumn, GridRow, Density, SortConfig, SortDirection, PaginationConfig, PaginationOptions, ExportOptions, PerformanceConfig, InfiniteScrollOptions, GroupConfig, ActiveFilters, ColumnFilterValue, ColumnFilter, FilterType, ColumnConfig, ContextMenuItem, BulkActionOption, SavedFilter, SearchMode, ExportFormat, RowEventParams, CellClickParams, CellContextMenuParams, CellFocusParams, CellEditParams, CellSelectionPayload, CopyCellsPayload, } from "./grid/types";
|
|
10
20
|
export { usePagination } from "./grid/hooks/usePagination";
|
|
11
21
|
export { useVirtualization } from "./grid/hooks/useVirtualization";
|