@parasutcom/fds 0.1.22 → 0.1.23
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/index.d.ts +240 -0
- package/dist/index.js +7594 -7098
- package/dist/styles.css +1 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,7 @@ import { Checkbox as Checkbox_2 } from '@base-ui/react/checkbox';
|
|
|
5
5
|
import { ClassProp } from 'class-variance-authority/types';
|
|
6
6
|
import { ClassValue } from 'clsx';
|
|
7
7
|
import { Collapsible as Collapsible_2 } from '@base-ui/react/collapsible';
|
|
8
|
+
import { ColumnDef } from '@tanstack/react-table';
|
|
8
9
|
import { Combobox as Combobox_2 } from '@base-ui/react';
|
|
9
10
|
import { Command as Command_2 } from 'cmdk';
|
|
10
11
|
import { DayButton } from 'react-day-picker';
|
|
@@ -20,10 +21,14 @@ import { Radio } from '@base-ui/react/radio';
|
|
|
20
21
|
import { RadioGroup as RadioGroup_2 } from '@base-ui/react/radio-group';
|
|
21
22
|
import * as React_2 from 'react';
|
|
22
23
|
import { ReactElement } from 'react';
|
|
24
|
+
import { ReactNode } from 'react';
|
|
23
25
|
import * as RechartsPrimitive from 'recharts';
|
|
26
|
+
import { Row } from '@tanstack/react-table';
|
|
24
27
|
import { Select as Select_2 } from '@base-ui/react/select';
|
|
25
28
|
import { Separator as Separator_2 } from '@base-ui/react/separator';
|
|
26
29
|
import { Switch as Switch_2 } from '@base-ui/react/switch';
|
|
30
|
+
import { Table as Table_2 } from '@tanstack/react-table';
|
|
31
|
+
import { TableOptions } from '@tanstack/react-table';
|
|
27
32
|
import { Tabs as Tabs_2 } from '@base-ui/react/tabs';
|
|
28
33
|
import { toast } from 'sonner';
|
|
29
34
|
import { ToasterProps } from 'sonner';
|
|
@@ -275,6 +280,190 @@ export declare function CommandSeparator({ className, ...props }: React_2.Compon
|
|
|
275
280
|
|
|
276
281
|
export declare function CommandShortcut({ className, ...props }: React_2.ComponentProps<"span">): JSX.Element;
|
|
277
282
|
|
|
283
|
+
export declare const DataTable: typeof DataTableRoot & {
|
|
284
|
+
Toolbar: typeof DataTableToolbar;
|
|
285
|
+
Content: typeof DataTableContent;
|
|
286
|
+
Footer: typeof DataTableFooter;
|
|
287
|
+
Pagination: typeof DataTablePaginationComponent;
|
|
288
|
+
RowCount: typeof DataTableRowCount;
|
|
289
|
+
Summary: typeof DataTableSummary;
|
|
290
|
+
ColumnVisibility: typeof DataTableColumnVisibility;
|
|
291
|
+
EmptyState: typeof DataTableEmptyState;
|
|
292
|
+
};
|
|
293
|
+
|
|
294
|
+
/**
|
|
295
|
+
* Action definition for table rows
|
|
296
|
+
* Pure data/behavior definition — no UI opinions
|
|
297
|
+
*
|
|
298
|
+
* Handle confirmations, modals, and other business logic in onClick handler
|
|
299
|
+
*/
|
|
300
|
+
export declare interface DataTableAction<TData> {
|
|
301
|
+
/** Unique action identifier */
|
|
302
|
+
id: string;
|
|
303
|
+
/** Action label (used for aria-label and dropdown text) */
|
|
304
|
+
label: string;
|
|
305
|
+
/** Icon component */
|
|
306
|
+
icon?: ReactNode;
|
|
307
|
+
/**
|
|
308
|
+
* Click handler — receives the row data
|
|
309
|
+
* Handle confirmations, modals, API calls, etc. here
|
|
310
|
+
*/
|
|
311
|
+
onClick: (row: TData) => void | Promise<void>;
|
|
312
|
+
/** Button variant */
|
|
313
|
+
variant?: 'default' | 'destructive' | 'outline' | 'ghost' | 'secondary';
|
|
314
|
+
/** Show as primary button (outside dropdown) */
|
|
315
|
+
primary?: boolean;
|
|
316
|
+
/** Hide from dropdown menu */
|
|
317
|
+
hideInMenu?: boolean;
|
|
318
|
+
/** Disable action based on row data or static boolean */
|
|
319
|
+
disabled?: boolean | ((row: TData) => boolean);
|
|
320
|
+
/** Show separator before this action in dropdown */
|
|
321
|
+
separator?: boolean;
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
declare function DataTableColumnVisibility<TData>({ label, }: DataTableColumnVisibilityProps): JSX.Element;
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* DataTable.ColumnVisibility — column visibility toggle
|
|
328
|
+
*/
|
|
329
|
+
declare interface DataTableColumnVisibilityProps {
|
|
330
|
+
/** Button label (if not icon-only) */
|
|
331
|
+
label?: string;
|
|
332
|
+
}
|
|
333
|
+
|
|
334
|
+
declare function DataTableContent<TData>({ stickyHeader, error, errorAction, emptyAction, emptyMessage, renderEmpty, emptyHeight, }: DataTableContentProps): JSX.Element;
|
|
335
|
+
|
|
336
|
+
/**
|
|
337
|
+
* DataTable.Content — the main content area (table header, rows, empty/error states)
|
|
338
|
+
*/
|
|
339
|
+
declare interface DataTableContentProps {
|
|
340
|
+
/** Make table header sticky. Pass the top offset (e.g., '0px', '48px', '3rem') */
|
|
341
|
+
stickyHeader?: string;
|
|
342
|
+
/** Error message — shows error state with library default design. Takes priority over empty state. */
|
|
343
|
+
error?: string | null;
|
|
344
|
+
/** Action element for error state (e.g., retry button). Developer controls text and behavior. */
|
|
345
|
+
errorAction?: ReactNode;
|
|
346
|
+
/** Action element for empty state (e.g., add new button). Developer controls text and behavior. */
|
|
347
|
+
emptyAction?: ReactNode;
|
|
348
|
+
/** Override the default empty state message */
|
|
349
|
+
emptyMessage?: string;
|
|
350
|
+
/** Full custom empty/error state (escape hatch — overrides all built-in states) */
|
|
351
|
+
renderEmpty?: () => ReactNode;
|
|
352
|
+
/** Explicit height for empty/error state (e.g., '400px', '50vh') */
|
|
353
|
+
emptyHeight?: string;
|
|
354
|
+
}
|
|
355
|
+
|
|
356
|
+
/**
|
|
357
|
+
* Custom options handled by the hook (not standard TanStack Table options)
|
|
358
|
+
*/
|
|
359
|
+
declare interface DataTableCustomOptions<TData> {
|
|
360
|
+
/** Actions configuration — automatically injects actions column */
|
|
361
|
+
actions?: DataTableAction<TData>[];
|
|
362
|
+
/** Custom actions renderer (escape hatch for full control) */
|
|
363
|
+
renderActions?: (row: Row<TData>) => ReactNode;
|
|
364
|
+
/** Selected rows as domain objects — injects selection column + manages state */
|
|
365
|
+
selectedRows?: TData[];
|
|
366
|
+
/** Callback when selected rows change */
|
|
367
|
+
onSelectedRowsChange?: (rows: TData[]) => void;
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
declare function DataTableEmptyState({ icon, title, description, action, variant, }: DataTableEmptyStateProps): JSX.Element;
|
|
371
|
+
|
|
372
|
+
/**
|
|
373
|
+
* DataTable.EmptyState — consistent layout for empty and error states
|
|
374
|
+
*
|
|
375
|
+
* Use inside renderEmpty to show a centered message with optional icon and action.
|
|
376
|
+
* Works for both "no data" and "error" scenarios with the same visual design.
|
|
377
|
+
*
|
|
378
|
+
* @example
|
|
379
|
+
* <DataTable.Content
|
|
380
|
+
* renderEmpty={() => (
|
|
381
|
+
* <DataTable.EmptyState
|
|
382
|
+
* icon={<AlertTriangle className="size-8 text-destructive" />}
|
|
383
|
+
* title="Something went wrong"
|
|
384
|
+
* description="Could not load data"
|
|
385
|
+
* variant="destructive"
|
|
386
|
+
* action={<Button onClick={retry}>Retry</Button>}
|
|
387
|
+
* />
|
|
388
|
+
* )}
|
|
389
|
+
* />
|
|
390
|
+
*/
|
|
391
|
+
declare interface DataTableEmptyStateProps {
|
|
392
|
+
/** Icon or media element displayed above the title */
|
|
393
|
+
icon?: ReactNode;
|
|
394
|
+
/** Main heading text */
|
|
395
|
+
title: string;
|
|
396
|
+
/** Supporting description text */
|
|
397
|
+
description?: string;
|
|
398
|
+
/** Action element (e.g., retry button) */
|
|
399
|
+
action?: ReactNode;
|
|
400
|
+
/** Visual variant — 'destructive' applies error styling to the title */
|
|
401
|
+
variant?: 'default' | 'destructive';
|
|
402
|
+
}
|
|
403
|
+
|
|
404
|
+
declare function DataTableFooter<TData>({ children, className, sticky }: DataTableFooterProps): JSX.Element | null;
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* DataTable.Footer — layout container for the bottom section
|
|
408
|
+
* Automatically hidden when the table has no rows (empty/error states).
|
|
409
|
+
*/
|
|
410
|
+
declare interface DataTableFooterProps {
|
|
411
|
+
children: ReactNode;
|
|
412
|
+
className?: string;
|
|
413
|
+
/** Stick footer to the bottom of the scroll area. Pass a bottom offset (e.g., '0px') */
|
|
414
|
+
sticky?: string;
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* DataTable.Pagination — pagination controls
|
|
419
|
+
*/
|
|
420
|
+
declare function DataTablePaginationComponent<TData>(): JSX.Element;
|
|
421
|
+
|
|
422
|
+
declare interface DataTableProps<TData> {
|
|
423
|
+
/** TanStack Table instance from useDataTable() */
|
|
424
|
+
table: Table_2<TData>;
|
|
425
|
+
/** Child compound components */
|
|
426
|
+
children: ReactNode;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
/**
|
|
430
|
+
* DataTable — compound component renderer
|
|
431
|
+
* Accepts a table instance and provides context for child components.
|
|
432
|
+
* All configuration happens in useDataTable(), not here.
|
|
433
|
+
*/
|
|
434
|
+
declare function DataTableRoot<TData>({ table, children }: DataTableProps<TData>): JSX.Element;
|
|
435
|
+
|
|
436
|
+
declare function DataTableRowCount<TData>({ count }?: DataTableRowCountProps): JSX.Element;
|
|
437
|
+
|
|
438
|
+
/**
|
|
439
|
+
* DataTable.RowCount — displays record count
|
|
440
|
+
* Auto-detects from table when count is not provided
|
|
441
|
+
*/
|
|
442
|
+
declare interface DataTableRowCountProps {
|
|
443
|
+
/** Explicit count — when provided, overrides the auto-detected value */
|
|
444
|
+
count?: number;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/**
|
|
448
|
+
* DataTable.Summary — slot for custom summary content
|
|
449
|
+
*/
|
|
450
|
+
declare function DataTableSummary({ children, className }: {
|
|
451
|
+
children: ReactNode;
|
|
452
|
+
className?: string;
|
|
453
|
+
}): JSX.Element;
|
|
454
|
+
|
|
455
|
+
declare function DataTableToolbar({ children, className, sticky }: DataTableToolbarProps): JSX.Element;
|
|
456
|
+
|
|
457
|
+
/**
|
|
458
|
+
* DataTable.Toolbar — layout container for toolbar items
|
|
459
|
+
*/
|
|
460
|
+
declare interface DataTableToolbarProps {
|
|
461
|
+
children: ReactNode;
|
|
462
|
+
className?: string;
|
|
463
|
+
/** Make toolbar sticky. Pass a top value (e.g., '0px', '64px') to set the sticky offset */
|
|
464
|
+
sticky?: string;
|
|
465
|
+
}
|
|
466
|
+
|
|
278
467
|
export declare function DeleteDialog({ onConfirm, children, mode, count, open: controlledOpen, onOpenChange: controlledOnOpenChange, title, description, }: DeleteDialogProps): JSX.Element;
|
|
279
468
|
|
|
280
469
|
declare interface DeleteDialogProps {
|
|
@@ -824,6 +1013,57 @@ export declare function TooltipTrigger({ ...props }: Tooltip_2.Trigger.Props): J
|
|
|
824
1013
|
|
|
825
1014
|
export declare function useComboboxAnchor(): React_2.RefObject<HTMLDivElement | null>;
|
|
826
1015
|
|
|
1016
|
+
/**
|
|
1017
|
+
* Creates a TanStack Table instance with automatic column injection
|
|
1018
|
+
*
|
|
1019
|
+
* Handles:
|
|
1020
|
+
* - Selection column injection (when selectedRows or enableRowSelection is provided)
|
|
1021
|
+
* - Actions column injection (when actions or renderActions is provided)
|
|
1022
|
+
* - High-level selection API (selectedRows ↔ RowSelectionState conversion)
|
|
1023
|
+
*
|
|
1024
|
+
* All TanStack Table options are accepted directly — no abstraction layer.
|
|
1025
|
+
* The developer configures pagination, sorting, filtering, manual modes, etc. here.
|
|
1026
|
+
*/
|
|
1027
|
+
export declare function useDataTable<TData>({ actions, renderActions, selectedRows, onSelectedRowsChange, columns: userColumns, getRowId, data, ...restTableOptions }: UseDataTableOptions<TData>): Table_2<TData>;
|
|
1028
|
+
|
|
1029
|
+
/**
|
|
1030
|
+
* useDataTable options = our custom options + any TanStack Table option
|
|
1031
|
+
*/
|
|
1032
|
+
export declare type UseDataTableOptions<TData> = DataTableCustomOptions<TData> & {
|
|
1033
|
+
data: TData[];
|
|
1034
|
+
columns: ColumnDef<TData, unknown>[];
|
|
1035
|
+
} & Partial<Omit<TableOptions<TData>, 'data' | 'columns'>>;
|
|
1036
|
+
|
|
1037
|
+
/**
|
|
1038
|
+
* Access row selection state from within the DataTable compound component tree.
|
|
1039
|
+
*
|
|
1040
|
+
* Must be called inside a component rendered within <DataTable>.
|
|
1041
|
+
* When used with the high-level selection API (selectedRows/onSelectedRowsChange),
|
|
1042
|
+
* clear() automatically syncs back to the external state.
|
|
1043
|
+
*
|
|
1044
|
+
* @example
|
|
1045
|
+
* function BulkActions({ onBulkDelete }: Props) {
|
|
1046
|
+
* const { rows, count, hasSelection, clear } = useDataTableSelection<Account>()
|
|
1047
|
+
* if (!hasSelection) return null
|
|
1048
|
+
* return (
|
|
1049
|
+
* <>
|
|
1050
|
+
* <Button onClick={() => onBulkDelete(rows)}>Delete ({count})</Button>
|
|
1051
|
+
* <Button onClick={clear}>Clear</Button>
|
|
1052
|
+
* </>
|
|
1053
|
+
* )
|
|
1054
|
+
* }
|
|
1055
|
+
*/
|
|
1056
|
+
export declare function useDataTableSelection<TData>(): {
|
|
1057
|
+
/** The original data objects of the selected rows */
|
|
1058
|
+
rows: TData[];
|
|
1059
|
+
/** Number of currently selected rows */
|
|
1060
|
+
count: number;
|
|
1061
|
+
/** Whether at least one row is selected */
|
|
1062
|
+
hasSelection: boolean;
|
|
1063
|
+
/** Deselect all rows. Syncs with onSelectedRowsChange when provided. */
|
|
1064
|
+
clear: () => void;
|
|
1065
|
+
};
|
|
1066
|
+
|
|
827
1067
|
export declare function useIsMobile(): boolean;
|
|
828
1068
|
|
|
829
1069
|
export declare function useSidebar(): SidebarContextProps;
|