@superdangerous/app-framework 4.16.35 → 4.16.37

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.
@@ -1,122 +0,0 @@
1
- /**
2
- * PaginationControls - Compact inline pagination for table headers
3
- *
4
- * A condensed version of pagination controls designed to sit alongside
5
- * search/filter controls in a table header bar.
6
- */
7
-
8
- import {
9
- ChevronLeft,
10
- ChevronRight,
11
- } from 'lucide-react';
12
- import { Button } from '../../components/base/button';
13
- import {
14
- Select,
15
- SelectContent,
16
- SelectItem,
17
- SelectTrigger,
18
- SelectValue,
19
- } from '../../components/base/select';
20
- import { cn } from '../../src/utils/cn';
21
-
22
- export interface PaginationControlsProps {
23
- page: number;
24
- pageSize: number;
25
- totalPages: number;
26
- totalItems: number;
27
- startIndex: number;
28
- endIndex: number;
29
- canGoNext: boolean;
30
- canGoPrev: boolean;
31
- pageSizeOptions: number[];
32
- setPage: (page: number) => void;
33
- setPageSize: (size: number) => void;
34
- nextPage: () => void;
35
- prevPage: () => void;
36
- className?: string;
37
- }
38
-
39
- export function PaginationControls({
40
- page,
41
- pageSize,
42
- totalPages,
43
- totalItems,
44
- startIndex,
45
- endIndex,
46
- canGoNext,
47
- canGoPrev,
48
- pageSizeOptions,
49
- setPage: _setPage,
50
- setPageSize,
51
- nextPage,
52
- prevPage,
53
- className,
54
- }: PaginationControlsProps) {
55
- // Note: setPage is included for API compatibility with usePagination but not used
56
- // as this component only provides prev/next navigation
57
- void _setPage;
58
- if (totalItems === 0) {
59
- return null;
60
- }
61
-
62
- return (
63
- <div className={cn('flex items-center gap-3 text-sm', className)}>
64
- {/* Page size selector - hidden on small screens */}
65
- <div className="hidden md:flex items-center gap-1.5">
66
- <span className="text-muted-foreground hidden lg:inline">Rows:</span>
67
- <Select
68
- value={String(pageSize)}
69
- onValueChange={(v) => setPageSize(Number(v))}
70
- >
71
- <SelectTrigger className="w-16 h-8 text-xs">
72
- <SelectValue />
73
- </SelectTrigger>
74
- <SelectContent>
75
- {pageSizeOptions.map((size) => (
76
- <SelectItem key={size} value={String(size)}>
77
- {size}
78
- </SelectItem>
79
- ))}
80
- </SelectContent>
81
- </Select>
82
- </div>
83
-
84
- {/* Page navigation - always visible when there are multiple pages */}
85
- {totalPages > 1 && (
86
- <div className="flex items-center gap-1">
87
- <Button
88
- variant="outline"
89
- size="icon"
90
- className="h-8 w-8"
91
- onClick={prevPage}
92
- disabled={!canGoPrev}
93
- title="Previous page"
94
- >
95
- <ChevronLeft className="h-4 w-4" />
96
- </Button>
97
-
98
- {/* Page indicator - hidden on very small screens */}
99
- <span className="hidden sm:inline px-2 text-muted-foreground tabular-nums min-w-[60px] text-center">
100
- {page} / {totalPages}
101
- </span>
102
-
103
- <Button
104
- variant="outline"
105
- size="icon"
106
- className="h-8 w-8"
107
- onClick={nextPage}
108
- disabled={!canGoNext}
109
- title="Next page"
110
- >
111
- <ChevronRight className="h-4 w-4" />
112
- </Button>
113
- </div>
114
- )}
115
-
116
- {/* Items info - hidden on smaller screens */}
117
- <span className="text-muted-foreground whitespace-nowrap hidden lg:inline">
118
- Showing {startIndex}–{endIndex} of {totalItems}
119
- </span>
120
- </div>
121
- );
122
- }
@@ -1,145 +0,0 @@
1
- import React from 'react';
2
- import { Search, Filter, X } from 'lucide-react';
3
- import { Input } from '../../components/base/input';
4
- import { Button } from '../../components/base/button';
5
- import { Popover, PopoverContent, PopoverTrigger } from '../../components/base/popover';
6
- import { cn } from '../../src/utils/cn';
7
-
8
- export interface FilterOption {
9
- id: string;
10
- label: string;
11
- render: () => React.ReactNode;
12
- /** Filter type - 'multi' filters get more horizontal space */
13
- type?: 'single' | 'multi';
14
- }
15
-
16
- export interface TableFiltersProps {
17
- search?: string;
18
- onSearchChange?: (value: string) => void;
19
- searchPlaceholder?: string;
20
- filters?: FilterOption[];
21
- activeFilterCount?: number;
22
- onClearFilters?: () => void;
23
- className?: string;
24
- children?: React.ReactNode;
25
- }
26
-
27
- /**
28
- * TableFilters - Compact filter controls for data tables
29
- *
30
- * Features:
31
- * - Search input
32
- * - Popover filter menu with badge showing active count
33
- * - Clear all filters button
34
- * - Custom filter components via render prop
35
- * - Children slot for additional action buttons
36
- */
37
- export function TableFilters({
38
- search,
39
- onSearchChange,
40
- searchPlaceholder = 'Search...',
41
- filters,
42
- activeFilterCount = 0,
43
- onClearFilters,
44
- className,
45
- children,
46
- }: TableFiltersProps) {
47
- // Check if any filter needs wider layout (multi-select filters)
48
- const hasMultiFilters = filters?.some(f => f.type === 'multi');
49
- const popoverWidth = hasMultiFilters ? 'w-[420px]' : 'w-80';
50
-
51
- return (
52
- <div className={cn('flex items-center gap-3 flex-wrap', className)}>
53
- {/* Search Input */}
54
- {onSearchChange !== undefined && (
55
- <div className="relative flex-1 min-w-[200px] max-w-xs">
56
- <Search className="absolute left-3 top-1/2 transform -translate-y-1/2 h-4 w-4 text-muted-foreground pointer-events-none z-10" />
57
- <Input
58
- placeholder={searchPlaceholder}
59
- value={search || ''}
60
- onChange={(e) => onSearchChange(e.target.value)}
61
- className="pl-9 h-9"
62
- />
63
- {search && (
64
- <button
65
- type="button"
66
- onClick={() => onSearchChange('')}
67
- className="absolute right-2 top-1/2 transform -translate-y-1/2 p-1 rounded-sm hover:bg-muted"
68
- >
69
- <X className="h-3 w-3 text-muted-foreground" />
70
- </button>
71
- )}
72
- </div>
73
- )}
74
-
75
- {/* Filters Popover */}
76
- {filters && filters.length > 0 && (
77
- <Popover>
78
- <PopoverTrigger asChild>
79
- <Button variant="outline" size="sm" className="gap-2 h-9">
80
- <Filter className="h-4 w-4" />
81
- Filters
82
- {activeFilterCount > 0 && (
83
- <span className="ml-1 rounded-full bg-primary text-primary-foreground px-2 py-0.5 text-xs font-medium">
84
- {activeFilterCount}
85
- </span>
86
- )}
87
- </Button>
88
- </PopoverTrigger>
89
- <PopoverContent
90
- className={cn(popoverWidth, 'overflow-y-auto')}
91
- align="start"
92
- collisionPadding={16}
93
- style={{ maxHeight: 'var(--radix-popover-content-available-height)' }}
94
- >
95
- <div className="space-y-4">
96
- <div className="flex items-center justify-between">
97
- <h4 className="font-medium text-sm">Filters</h4>
98
- {activeFilterCount > 0 && onClearFilters && (
99
- <Button
100
- variant="ghost"
101
- size="sm"
102
- onClick={onClearFilters}
103
- className="h-auto p-0 text-xs text-destructive hover:text-destructive"
104
- >
105
- Clear all
106
- </Button>
107
- )}
108
- </div>
109
-
110
- <div className="space-y-4">
111
- {filters.map((filter) => (
112
- <div key={filter.id} className="space-y-1.5">
113
- <label className="text-xs font-medium text-muted-foreground">
114
- {filter.label}
115
- </label>
116
- {filter.render()}
117
- </div>
118
- ))}
119
- </div>
120
- </div>
121
- </PopoverContent>
122
- </Popover>
123
- )}
124
-
125
- {/* Clear filters button (visible when filters are active, outside popover) */}
126
- {activeFilterCount > 0 && onClearFilters && (
127
- <Button
128
- variant="ghost"
129
- size="sm"
130
- onClick={onClearFilters}
131
- className="h-9 gap-1.5 text-muted-foreground hover:text-foreground"
132
- >
133
- <X className="h-4 w-4" />
134
- Clear
135
- </Button>
136
- )}
137
-
138
- {/* Spacer to push children to the right */}
139
- <div className="flex-1" />
140
-
141
- {/* Custom children (e.g., export button, create button, etc.) */}
142
- {children}
143
- </div>
144
- );
145
- }
@@ -1,44 +0,0 @@
1
- /**
2
- * Data Table Components
3
- *
4
- * Reusable components for building data tables:
5
- * - DataTable: Full-featured generic data table
6
- * - DataTablePage: Full-page layout with header controls
7
- * - PaginationControls: Compact inline pagination
8
- * - Pagination: Full pagination with page numbers
9
- * - BatchActionsBar: Multi-select action bar
10
- * - ColumnVisibility: Column toggle dropdown
11
- * - TableFilters: Search and filter controls
12
- */
13
-
14
- export { DataTable } from './DataTable';
15
- export type {
16
- DataTableProps,
17
- ColumnDef,
18
- ColumnWidth,
19
- ColumnVisibility as ColumnVisibilityConfig,
20
- HeaderCellProps,
21
- CellProps,
22
- ExternalPaginationState,
23
- ColumnConfigCompat,
24
- ColumnSizeConfig,
25
- } from './types';
26
-
27
- export { DataTablePage } from './DataTablePage';
28
- export type { DataTablePageProps, FilterOption } from './DataTablePage';
29
-
30
- export { PaginationControls } from './PaginationControls';
31
- export type { PaginationControlsProps } from './PaginationControls';
32
-
33
- export { Pagination } from './Pagination';
34
-
35
- export { BatchActionsBar } from './BatchActionsBar';
36
- export type { BatchActionsBarProps } from './BatchActionsBar';
37
-
38
- export { ColumnVisibility } from './ColumnVisibility';
39
-
40
- export { TableFilters } from './TableFilters';
41
- export type { TableFiltersProps, FilterOption as TableFilterOption } from './TableFilters';
42
-
43
- export { MultiSelectFilter } from './MultiSelectFilter';
44
- export type { MultiSelectFilterProps, MultiSelectOption } from './MultiSelectFilter';
@@ -1,181 +0,0 @@
1
- import type { ReactNode } from 'react';
2
-
3
- /**
4
- * Column width configuration
5
- */
6
- export interface ColumnWidth {
7
- default: number;
8
- min: number;
9
- max?: number;
10
- }
11
-
12
- /**
13
- * Column visibility configuration
14
- */
15
- export interface ColumnVisibility {
16
- default: boolean;
17
- locked?: boolean; // If true, column cannot be hidden
18
- }
19
-
20
- /**
21
- * Props passed to header cell render function
22
- */
23
- export interface HeaderCellProps {
24
- columnId: string;
25
- isSorted: boolean;
26
- sortDirection?: 'asc' | 'desc';
27
- }
28
-
29
- /**
30
- * Props passed to cell render function
31
- */
32
- export interface CellProps {
33
- columnId: string;
34
- isDragging: boolean;
35
- }
36
-
37
- /**
38
- * Column definition for DataTable
39
- */
40
- export interface ColumnDef<T> {
41
- /** Unique column identifier */
42
- id: string;
43
-
44
- /** Header content - string or render function */
45
- header: string | ((props: HeaderCellProps) => ReactNode);
46
-
47
- /** Cell content render function */
48
- cell: (item: T, props: CellProps) => ReactNode;
49
-
50
- /** Key to use for sorting (if sortable) */
51
- sortKey?: string;
52
-
53
- /** Width configuration */
54
- width?: ColumnWidth;
55
-
56
- /** Visibility configuration */
57
- visibility?: ColumnVisibility;
58
-
59
- /** Additional CSS class for cells */
60
- className?: string;
61
-
62
- /** Whether this column should use column style from resize hook */
63
- resizable?: boolean;
64
- }
65
-
66
- // DragState is exported from ../hooks/useColumnOrder
67
-
68
- /**
69
- * External pagination state (from usePagination hook)
70
- */
71
- export interface ExternalPaginationState<T> {
72
- paginatedData: T[];
73
- page: number;
74
- pageSize: number;
75
- totalPages: number;
76
- totalItems: number;
77
- startIndex: number;
78
- endIndex: number;
79
- canGoNext: boolean;
80
- canGoPrev: boolean;
81
- pageSizeOptions: number[];
82
- setPage: (page: number) => void;
83
- setPageSize: (size: number) => void;
84
- nextPage: () => void;
85
- prevPage: () => void;
86
- }
87
-
88
- /**
89
- * DataTable props
90
- */
91
- export interface DataTableProps<T> {
92
- /** Data array to display */
93
- data: T[];
94
-
95
- /** Column definitions */
96
- columns: ColumnDef<T>[];
97
-
98
- /** Storage key for persisting table state (column widths, order, visibility) */
99
- storageKey: string;
100
-
101
- /** Function to get unique ID from item */
102
- getRowId: (item: T) => string;
103
-
104
- // Selection
105
- /** Enable row selection with checkboxes */
106
- selectable?: boolean;
107
- /** Set of selected row IDs */
108
- selectedIds?: Set<string>;
109
- /** Callback when selection changes */
110
- onSelectionChange?: (ids: Set<string>) => void;
111
-
112
- // Row interactions
113
- /** Callback when row is clicked */
114
- onRowClick?: (item: T) => void;
115
- /** Callback when row is right-clicked (for context menu) */
116
- onRowContextMenu?: (item: T, position: { x: number; y: number }) => void;
117
-
118
- // Sorting
119
- /** Current sort field */
120
- sortField?: string;
121
- /** Current sort order */
122
- sortOrder?: 'asc' | 'desc';
123
- /** Callback when sort changes */
124
- onSort?: (field: string) => void;
125
-
126
- // Actions column
127
- /** Render function for actions column (always last, sticky) */
128
- actionsColumn?: (item: T) => ReactNode;
129
- /** Width for actions column */
130
- actionsColumnWidth?: number;
131
-
132
- // Pagination
133
- /** Page size for pagination (used when no external pagination provided) */
134
- pageSize?: number;
135
- /** External pagination state from usePagination hook (overrides internal pagination) */
136
- pagination?: ExternalPaginationState<T>;
137
- /** Hide the built-in pagination controls (use when pagination is shown elsewhere) */
138
- hidePagination?: boolean;
139
-
140
- // Styling
141
- /** Additional CSS class for table container */
142
- className?: string;
143
- /** Function to compute row CSS class */
144
- rowClassName?: (item: T) => string;
145
-
146
- // Features
147
- /** Enable header right-click for column visibility menu */
148
- enableHeaderContextMenu?: boolean;
149
- /** Columns that cannot be reordered */
150
- lockedColumns?: string[];
151
- /** Default column order (if not persisted) */
152
- defaultColumnOrder?: string[];
153
-
154
- // Loading state
155
- /** Show loading indicator */
156
- loading?: boolean;
157
-
158
- // Empty state
159
- /** Content to show when no data */
160
- emptyState?: ReactNode;
161
- }
162
-
163
- /**
164
- * Column config for visibility hook (for compatibility)
165
- */
166
- export interface ColumnConfigCompat {
167
- id: string;
168
- label: string;
169
- defaultVisible?: boolean;
170
- locked?: boolean;
171
- }
172
-
173
- /**
174
- * Column config for resize hook (for compatibility)
175
- */
176
- export interface ColumnSizeConfig {
177
- key: string;
178
- defaultWidth: number;
179
- minWidth: number;
180
- maxWidth?: number;
181
- }
@@ -1,17 +0,0 @@
1
- /**
2
- * Data Table Hooks
3
- *
4
- * Comprehensive hooks for building data tables with:
5
- * - Pagination with localStorage persistence
6
- * - Column visibility toggling
7
- * - Column resizing with drag handles
8
- * - Column reordering with drag-and-drop
9
- */
10
-
11
- export { usePagination } from './usePagination';
12
- export { useColumnVisibility } from './useColumnVisibility';
13
- export type { ColumnConfig, ColumnVisibilityState } from './useColumnVisibility';
14
- export { useResizableColumns } from './useResizableColumns';
15
- export type { ResizableColumnResult } from './useResizableColumns';
16
- export { useColumnOrder, useColumnDragDrop } from './useColumnOrder';
17
- export type { ColumnOrderConfig, DragState } from './useColumnOrder';