Skip to content

Commit 3f49f85

Browse files
committed
Reformat code
1 parent e05feb3 commit 3f49f85

File tree

4 files changed

+1903
-1171
lines changed

4 files changed

+1903
-1171
lines changed

.github/copilot-instructions.md

Lines changed: 22 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,11 +5,13 @@ This is a dual-purpose repository containing both the **Mantine DataTable** comp
55
## Project Architecture
66

77
### Dual Repository Structure
8+
89
- **Package code**: `package/` - The actual DataTable component exported to npm
910
- **Documentation site**: `app/`, `components/` - Next.js app with examples and docs
1011
- **Build outputs**: Package builds to `dist/`, docs build for GitHub Pages deployment
1112

1213
### Package Development Flow
14+
1315
```bash
1416
# Core development commands (use pnpm, not yarn despite legacy docs)
1517
pnpm dev # Start Next.js dev server for docs/examples
@@ -20,6 +22,7 @@ pnpm lint # ESLint + TypeScript checks
2022
```
2123

2224
### Component Architecture Pattern
25+
2326
The DataTable follows a **composition-based architecture** with specialized sub-components:
2427

2528
```typescript
@@ -39,29 +42,36 @@ Each sub-component has its own `.tsx`, `.css`, and sometimes `.module.css` files
3942
## Development Conventions
4043

4144
### Import Alias Pattern
45+
4246
Examples use `import { DataTable } from '__PACKAGE__'` - this resolves to the local package during development. Never import from `mantine-datatable` in examples.
4347

4448
### TypeScript Patterns
49+
4550
- **Generic constraints**: `DataTable<T>` where T extends record type
4651
- **Prop composition**: Props inherit from base Mantine components (TableProps, etc.)
4752
- **Accessor pattern**: Use `idAccessor` prop for custom ID fields, defaults to `'id'`
4853

4954
### CSS Architecture
55+
5056
- **Layered imports**: `styles.css` imports all component styles
5157
- **CSS layers**: `@layer mantine, mantine-datatable` for proper specificity
5258
- **Utility classes**: Defined in `utilityClasses.css` for common patterns
5359
- **CSS variables**: Dynamic values injected via `cssVariables.ts`
5460

5561
### Hook Patterns
62+
5663
Custom hooks follow the pattern `useDataTable*` and are located in `package/hooks/`:
64+
5765
- `useDataTableColumns` - Column management and persistence
5866
- `useRowExpansion` - Row expansion state
5967
- `useLastSelectionChangeIndex` - Selection behavior
6068

6169
## Documentation Development
6270

6371
### Example Structure
72+
6473
Each example in `app/examples/` follows this pattern:
74+
6575
```
6676
feature-name/
6777
├── page.tsx # Next.js page with controls
@@ -70,50 +80,59 @@ feature-name/
7080
```
7181

7282
### Code Block Convention
83+
7384
Use the `CodeBlock` component for syntax highlighting. Example files should be minimal and focused on demonstrating a single feature clearly.
7485

7586
## Data Patterns
7687

7788
### Record Structure
89+
7890
Examples use consistent data shapes:
91+
7992
- `companies.json` - Basic company data with id, name, address
80-
- `employees.json` - Employee data with departments/relationships
93+
- `employees.json` - Employee data with departments/relationships
8194
- `async.ts` - Simulated API calls with delay/error simulation
8295

8396
### Selection Patterns
97+
8498
- **Gmail-style additive selection**: Shift+click for range selection
8599
- **Trigger modes**: `'checkbox'` | `'row'` | `'cell'`
86100
- **Custom selection logic**: Use `isRecordSelectable` for conditional selection
87101

88102
## Build System
89103

90104
### Package Build (tsup)
105+
91106
- **ESM**: `tsup.esm.ts` - Modern module format
92-
- **CJS**: `tsup.cjs.ts` - CommonJS compatibility
107+
- **CJS**: `tsup.cjs.ts` - CommonJS compatibility
93108
- **Types**: `tsup.dts.ts` - TypeScript declarations
94109
- **CSS**: PostCSS processes styles to `dist/`
95110

96111
### Documentation Deployment
112+
97113
- **GitHub Pages**: `output: 'export'` in `next.config.js`
98114
- **Base path**: `/mantine-datatable` when `GITHUB_PAGES=true`
99115
- **Environment injection**: Package version, NPM downloads via build-time fetch
100116

101117
## Common Patterns
102118

103119
### Adding New Features
120+
104121
1. Create component in `package/` with `.tsx` and `.css` files
105122
2. Add to main `DataTable.tsx` component composition
106123
3. Export new types from `package/types/index.ts`
107124
4. Create example in `app/examples/new-feature/`
108125
5. Update main navigation in `app/config.ts`
109126

110127
### Styling New Components
128+
111129
- Use CSS custom properties for theming
112130
- Follow existing naming: `.mantine-datatable-component-name`
113131
- Import CSS in `package/styles.css`
114132
- Add utility classes to `utilityClasses.css` if reusable
115133

116134
### TypeScript Integration
135+
117136
- Extend base Mantine props where possible
118137
- Use composition over inheritance for prop types
119138
- Export all public types from `package/types/index.ts`
@@ -124,4 +143,4 @@ Examples use consistent data shapes:
124143
- **Virtualization**: Not implemented - DataTable handles reasonable record counts (< 1000s)
125144
- **Memoization**: Use `useMemo` for expensive column calculations
126145
- **CSS-in-JS**: Avoided in favor of CSS modules for better performance
127-
- **Bundle size**: Keep dependencies minimal (only Mantine + React)
146+
- **Bundle size**: Keep dependencies minimal (only Mantine + React)

package/DataTable.css

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,8 @@
9292
/* Allow overflow for pinned cells so the ::after shadow pseudo-element is not clipped.
9393
This overrides overflow: hidden from resizable columns (th) and ellipsis (td). */
9494
.mantine-datatable-pin-first-column.mantine-datatable-resizable-columns th:first-of-type,
95-
.mantine-datatable-pin-first-column.mantine-datatable-selection-column-visible.mantine-datatable-resizable-columns th:nth-of-type(2),
95+
.mantine-datatable-pin-first-column.mantine-datatable-selection-column-visible.mantine-datatable-resizable-columns
96+
th:nth-of-type(2),
9697
.mantine-datatable-pin-last-column.mantine-datatable-resizable-columns th:last-of-type,
9798
.mantine-datatable-pin-first-column td:first-of-type,
9899
.mantine-datatable-pin-first-column.mantine-datatable-selection-column-visible td:nth-of-type(2),

package/utils.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import type { DropResult } from '@hello-pangea/dnd';
22
import type { DataTableColumn, DataTableColumnGroup } from './types';
33

4-
54
/**
65
* Utility function that returns a humanized version of a string, e.g. "camelCase" -> "Camel Case"
76
*/
@@ -138,7 +137,6 @@ export function calculateColSpan<T>(group: DataTableColumnGroup<T>, visibles?: (
138137
return 0;
139138
}
140139

141-
142140
/**
143141
* Gets all groups at a specific depth level
144142
*/
@@ -161,7 +159,6 @@ export function getGroupsAtDepth<T>(
161159
return result;
162160
}
163161

164-
165162
/**
166163
* Checks if a group needs a right border based on its position and context
167164
*/
@@ -173,4 +170,3 @@ export function needsRightBorder(
173170
if (!withColumnBorders) return false;
174171
return !isLastGroup || hasMoreColumnsAfter;
175172
}
176-

0 commit comments

Comments
 (0)