raccoon-tables 1.0.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.
package/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Fazzini Pierluigi
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,187 @@
1
+ <p align="center">
2
+ <img src="raccoon_tables_logo.png" alt="Raccoon Tables" width="120">
3
+ </p>
4
+
5
+ # Raccoon Tables
6
+
7
+ High-performance TypeScript data grid with virtual scrolling, client-side and server-side data modes, row grouping, and full jQuery support.
8
+
9
+ ## Features
10
+
11
+ - **Page-scroll mode by default** — the grid grows with its data; the user scrolls the page; the header sticks to the viewport; set `height: N` to get an internal-scroll container instead
12
+ - Virtual scrolling — only visible rows in DOM, constant memory regardless of dataset size
13
+ - Client-side mode: sort, filter, group, paginate in-memory (TypedArray-accelerated sort)
14
+ - Server-side mode: all interactions via AJAX with debounced requests and AbortController cancellation
15
+ - Cell range selection (click-drag)
16
+ - Multi-column sort (Ctrl+click header)
17
+ - 15 filter operators per column; boolean columns use a dropdown select automatically; foreign-key columns support a **lookup (dropdown) filter** loaded from a static array or AJAX endpoint
18
+ - Row grouping with nested levels, expand/collapse, aggregations (sum/avg/min/max/custom)
19
+ - Global search bar
20
+ - Pagination (client and server) — works in both page-scroll and fixed-height mode
21
+ - Column resize, drag-reorder, show/hide via context menu
22
+ - Column groups (multi-level header)
23
+ - Row checkbox selection
24
+ - Keyboard navigation (arrow keys, Page Up/Down, Home/End, Ctrl+A)
25
+ - Touch scroll with inertia (with synchronized header)
26
+ - Boolean columns auto-render as a checkbox — no custom `render` callback needed
27
+ - `cellOverflow: true` on a column allows cell content to escape cell boundaries (e.g. action dropdowns)
28
+ - 4 built-in themes: **Raccoon** (default) · **Material Design** · **Microsoft Fluent** · **Tabler**; each has light/dark variants and respects `prefers-color-scheme`
29
+ - `themeVars` config option — override individual CSS tokens to extend a theme or build a fully custom one; `setThemeVars()` for runtime updates
30
+ - CSS custom properties for full theming, dark mode via `prefers-color-scheme`
31
+ - Zero runtime dependencies
32
+ - jQuery plugin (`$.fn.raccoonGrid`) included as separate bundle
33
+ - Full TypeScript generics (`RaccoonGrid<T>`)
34
+
35
+ ## Output formats
36
+
37
+ | File | Format | Use case |
38
+ |------|--------|---------|
39
+ | `raccoon-tables.esm.js` | ES module | Vite, webpack, Rollup |
40
+ | `raccoon-tables.cjs.js` | CommonJS | Node.js, Jest |
41
+ | `raccoon-tables.iife.js` | IIFE | `<script>` tag, CDN |
42
+ | `raccoon-tables.min.iife.js` | IIFE minified | Production CDN |
43
+ | `raccoon-tables.jquery.*.js` | ESM/CJS/IIFE | jQuery projects |
44
+ | `*.d.ts` / `*.d.cts` | TypeScript declarations | TypeScript projects |
45
+
46
+ ## Installation
47
+
48
+ ```bash
49
+ npm install raccoon-tables
50
+ ```
51
+
52
+ ## Quick start
53
+
54
+ ```typescript
55
+ import { RaccoonGrid } from 'raccoon-tables';
56
+ import 'raccoon-tables/styles/raccoon-tables.css';
57
+
58
+ interface Employee {
59
+ id: number;
60
+ name: string;
61
+ department: string;
62
+ salary: number;
63
+ }
64
+
65
+ const grid = new RaccoonGrid<Employee>({
66
+ columns: [
67
+ { id: 'name', index: 'name', text: 'Name', type: 'string', flex: 1 },
68
+ { id: 'department', index: 'department', text: 'Department', type: 'string' },
69
+ { id: 'salary', index: 'salary', text: 'Salary', type: 'currency', currency: 'EUR' },
70
+ ],
71
+ data: [
72
+ { id: 1, name: 'Alice', department: 'Engineering', salary: 95000 },
73
+ { id: 2, name: 'Bob', department: 'Marketing', salary: 72000 },
74
+ ],
75
+ // No `height` → page-scroll mode (user scrolls the page, header sticks to top).
76
+ // Pass `height: 400` to get a fixed-height container with an internal scrollbar instead.
77
+ filterBar: true,
78
+ pagination: { enabled: true, pageSize: 25, pageSizeOptions: [10, 25, 50, 100] },
79
+ });
80
+
81
+ grid.render('#my-grid');
82
+ ```
83
+
84
+ ## Server-side mode
85
+
86
+ ```typescript
87
+ const grid = new RaccoonGrid({
88
+ columns: [...],
89
+ height: 500,
90
+ serverAdapter: {
91
+ url: '/api/data',
92
+ method: 'POST',
93
+ prepareRequest: (params) => ({
94
+ // rename fields to match your API
95
+ offset: params.start,
96
+ count: params.limit,
97
+ sortBy: params.sort?.[0]?.index,
98
+ sortDir: params.sort?.[0]?.dir,
99
+ }),
100
+ parseResponse: (raw) => ({
101
+ data: raw.items as RowData[],
102
+ total: raw.totalCount as number,
103
+ }),
104
+ },
105
+ pagination: { enabled: true, pageSize: 50 },
106
+ });
107
+
108
+ grid.render('#my-grid');
109
+ ```
110
+
111
+ ## jQuery
112
+
113
+ ```html
114
+ <script src="jquery.min.js"></script>
115
+ <script src="raccoon-tables.jquery.iife.js"></script>
116
+ <script>
117
+ // Init
118
+ $('#grid').raccoonGrid({ columns: [...], data: [...] });
119
+
120
+ // Call method
121
+ $('#grid').raccoonGrid('setData', newData);
122
+
123
+ // Get instance
124
+ const grid = $('#grid').data('raccoonGrid');
125
+ </script>
126
+ ```
127
+
128
+ ## Internationalisation (i18n)
129
+
130
+ Built-in translations for **English** (default), **Italian**, **Spanish**, **French**, and **German**.
131
+ Pass `locale` in the config:
132
+
133
+ ```typescript
134
+ const grid = new RaccoonGrid({
135
+ locale: 'it', // 'en' | 'it' | 'es' | 'fr' | 'de'
136
+ columns: [...],
137
+ });
138
+ ```
139
+
140
+ Override individual strings without replacing the whole locale:
141
+
142
+ ```typescript
143
+ const grid = new RaccoonGrid({
144
+ locale: 'en',
145
+ localeOverride: { rowsPerPage: 'Items per page: ' },
146
+ columns: [...],
147
+ });
148
+ ```
149
+
150
+ ### Adding a new locale (contributor guide)
151
+
152
+ 1. Open `src/utils/i18n.ts`.
153
+ 2. Copy the `en` entry inside `LOCALES` and paste it with your locale code as the key (e.g. `'pt'`).
154
+ 3. Translate every string value. **All keys must be present** — TypeScript will error if any are missing.
155
+ 4. The `pageInfo` value uses `{start}`, `{end}`, and `{total}` as placeholders — keep them exactly as-is.
156
+ 5. Update the JSDoc comment at the top of the file (`Supported locales: ...`).
157
+ 6. Run `npm run typecheck && npm run build` — both must pass with zero errors.
158
+ 7. Add a demo entry in `demo/i18n.html` and open a PR. 🎉
159
+
160
+ ## Build
161
+
162
+ ```bash
163
+ npm run build # full build → dist/
164
+ npm run build:watch # watch mode
165
+ npm run typecheck # tsc --noEmit
166
+ ```
167
+
168
+ ## Demo
169
+
170
+ Open `demo/index.html` in a browser (no server needed, uses IIFE build).
171
+ See `demo/` for individual feature examples:
172
+
173
+ | File | What it demonstrates |
174
+ |------|---------------------|
175
+ | `demo/index.html` | Full-featured grid with all options |
176
+ | `demo/client-side.html` | Client-side data, sort, filter, pagination |
177
+ | `demo/server-side.html` | Server-side mode with mock fetch |
178
+ | `demo/row-grouping.html` | Row grouping, expand/collapse, aggregations |
179
+ | `demo/selection.html` | Row checkbox + cell range selection |
180
+ | `demo/column-features.html` | Column resize, drag, hide, column groups, action column |
181
+ | `demo/themes.html` | Theme switcher: Raccoon, Material, Fluent, Tabler; `themeVars` live customiser |
182
+ | `demo/i18n.html` | Internationalisation — switch locale at runtime |
183
+ | `demo/page-scroll.html` | Page-scroll mode (default) — no fixed height, page scrolls |
184
+
185
+ ## License
186
+
187
+ MIT