jtable-pro 1.0.0 → 1.0.2

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.
Files changed (2) hide show
  1. package/README.md +457 -184
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -1,221 +1,494 @@
1
1
  # jtable-pro
2
2
 
3
- A premium, app-like jQuery data-table plugin: a floating soft-shadow card,
4
- sticky blurred header, rounded controls and circular hover action buttons —
5
- with **global search**, **per-column search**, **column sorting**,
6
- **dropdown filters**, **client-side pagination** and **row selection**, all
7
- built in.
3
+ <p align="center">
4
+ <strong>Powerful, lightweight and flexible JavaScript data table.</strong>
5
+ </p>
8
6
 
9
- Ships as a single UMD file (no build step of its own) — works via a plain
10
- `<script>` tag, any bundler (Vite/webpack/Rollup), or AMD.
7
+ <p align="center">
8
+ Sorting · Filtering · Pagination · Search · Responsive · Customizable
9
+ </p>
10
+
11
+ <p align="center">
12
+ <a href="https://www.npmjs.com/package/jtable-pro">
13
+ <img src="https://img.shields.io/npm/v/jtable-pro.svg" alt="npm version">
14
+ </a>
15
+ <a href="https://www.npmjs.com/package/jtable-pro">
16
+ <img src="https://img.shields.io/npm/dm/jtable-pro.svg" alt="npm downloads">
17
+ </a>
18
+ <a href="https://www.npmjs.com/package/jtable-pro">
19
+ <img src="https://img.shields.io/npm/l/jtable-pro.svg" alt="license">
20
+ </a>
21
+ </p>
22
+
23
+ ---
24
+
25
+ ## ✨ What is jtable-pro?
26
+
27
+ **jtable-pro** is a lightweight and flexible JavaScript table component designed for modern web applications.
28
+
29
+ It provides common data-table functionality without forcing you to use a specific frontend framework.
30
+
31
+ Whether you're building a simple HTML application, a Laravel admin panel, a Vue application, or a custom JavaScript project, jtable-pro can help you display and manage tabular data efficiently.
32
+
33
+ ### Why jtable-pro?
34
+
35
+ * 🚀 Lightweight and fast
36
+ * 🔍 Built-in search and filtering
37
+ * ↕️ Column sorting
38
+ * 📄 Pagination support
39
+ * 📱 Responsive design
40
+ * 🎨 Easy to customize
41
+ * ⚡ Works with modern JavaScript
42
+ * 🧩 Framework-friendly
43
+ * 🔌 Easy API integration
44
+ * 🛠️ Great for admin panels and dashboards
45
+
46
+ ---
47
+
48
+ ## 📦 Installation
49
+
50
+ Install the package using npm:
51
+
52
+ ```bash
53
+ npm install jtable-pro
54
+ ```
55
+
56
+ Or with yarn:
57
+
58
+ ```bash
59
+ yarn add jtable-pro
60
+ ```
61
+
62
+ Or with pnpm:
63
+
64
+ ```bash
65
+ pnpm add jtable-pro
66
+ ```
67
+
68
+ ---
69
+
70
+ ## 🚀 Quick Start
71
+
72
+ Import `jtable-pro` into your JavaScript application:
73
+
74
+ ```javascript
75
+ import JTable from 'jtable-pro';
76
+ ```
77
+
78
+ Then initialize the table:
79
+
80
+ ```javascript
81
+ const table = new JTable('#users-table', {
82
+ data: [
83
+ {
84
+ id: 1,
85
+ name: 'John Doe',
86
+ email: 'john@example.com'
87
+ },
88
+ {
89
+ id: 2,
90
+ name: 'Jane Doe',
91
+ email: 'jane@example.com'
92
+ }
93
+ ],
11
94
 
12
- ```js
13
- $("#myTable").jtable({
14
95
  columns: [
15
- { key: "name", label: "Name", sortable: true, columnSearch: true },
16
- { key: "price", label: "Price", sortable: true, align: "right" },
96
+ {
97
+ key: 'id',
98
+ label: 'ID'
99
+ },
100
+ {
101
+ key: 'name',
102
+ label: 'Name'
103
+ },
104
+ {
105
+ key: 'email',
106
+ label: 'Email'
107
+ }
108
+ ]
109
+ });
110
+ ```
111
+
112
+ HTML:
113
+
114
+ ```html
115
+ <div id="users-table"></div>
116
+ ```
117
+
118
+ > The exact initialization options may vary depending on the version of jtable-pro you are using. See the API documentation below for the complete configuration.
119
+
120
+ ---
121
+
122
+ # 🎯 Features
123
+
124
+ ## 🔍 Search
125
+
126
+ Search through table data quickly.
127
+
128
+ ```javascript
129
+ const table = new JTable('#users-table', {
130
+ searchable: true,
131
+ data: users
132
+ });
133
+ ```
134
+
135
+ ---
136
+
137
+ ## ↕️ Sorting
138
+
139
+ Enable column sorting:
140
+
141
+ ```javascript
142
+ const table = new JTable('#users-table', {
143
+ sortable: true,
144
+ data: users
145
+ });
146
+ ```
147
+
148
+ ---
149
+
150
+ ## 📄 Pagination
151
+
152
+ Handle large datasets using pagination:
153
+
154
+ ```javascript
155
+ const table = new JTable('#users-table', {
156
+ pagination: true,
157
+ pageSize: 20,
158
+ data: users
159
+ });
160
+ ```
161
+
162
+ ---
163
+
164
+ ## 🎨 Custom Columns
165
+
166
+ Define exactly how your columns should appear:
167
+
168
+ ```javascript
169
+ const table = new JTable('#users-table', {
170
+ columns: [
171
+ {
172
+ key: 'name',
173
+ label: 'User Name'
174
+ },
175
+ {
176
+ key: 'email',
177
+ label: 'Email Address'
178
+ },
179
+ {
180
+ key: 'status',
181
+ label: 'Status'
182
+ }
17
183
  ],
18
- data: rows, // or url: "/api/rows"
19
- idField: "id",
184
+
185
+ data: users
20
186
  });
21
187
  ```
22
188
 
23
- ## Requirements
24
-
25
- - **jQuery 3+** (peer dependency — bring your own, this package doesn't bundle it).
26
- - **Tailwind CSS**, v4-style (this plugin's markup uses opacity-modifier
27
- classes like `bg-primary/10` and arbitrary-value classes like
28
- `shadow-[0_1px_2px_rgba(16,24,40,0.04)]`).
29
- - A handful of **semantic design tokens** the rendered markup references by
30
- name — these are not stock Tailwind colors/sizes, so add them to your
31
- `@theme` (Tailwind v4) if they don't already exist in your project:
32
-
33
- ```css
34
- @theme {
35
- --color-primary: #004ac6;
36
- --color-on-primary: #ffffff;
37
- --color-surface: #ffffff;
38
- --color-surface-container-lowest: #ffffff;
39
- --color-surface-container: #f3f4f6;
40
- --color-surface-container-high: #e5e7eb;
41
- --color-on-surface: #1f2937;
42
- --color-on-surface-variant: #6b7280;
43
- --color-outline-variant: #d1d5db;
44
-
45
- --text-body-sm: 0.8125rem;
46
- --text-body-md: 0.875rem;
47
- --text-label-md: 0.75rem;
48
- }
49
- ```
50
-
51
- Rename/retint these to match your own brand — jtable-pro only cares that
52
- the token *names* resolve to something, not their exact values. (If your
53
- project already has a Material-3-style semantic palette — `primary`,
54
- `on-surface`, `surface-container*`, `outline-variant` — you very likely
55
- already have all of these and can skip this step.)
189
+ ---
190
+
191
+ # 🌐 API / Server-Side Data
192
+
193
+ jtable-pro can be used with APIs and server-side applications.
194
+
195
+ Example:
196
+
197
+ ```javascript
198
+ const table = new JTable('#users-table', {
199
+ url: '/api/users',
200
+
201
+ pagination: true,
202
+ searchable: true,
203
+ sortable: true
204
+ });
205
+ ```
206
+
207
+ This makes jtable-pro suitable for applications where table data comes from a backend API.
208
+
209
+ ---
210
+
211
+ # 🇱🇦 Laravel
212
+
213
+ jtable-pro works well with Laravel applications and Laravel APIs.
56
214
 
57
215
  ## Install
58
216
 
59
217
  ```bash
60
- npm install jtable-pro jquery
218
+ npm install jtable-pro
61
219
  ```
62
220
 
63
- ```js
64
- import $ from "jquery";
65
- import "jtable-pro"; // registers $.fn.jtable
221
+ Import it into your JavaScript:
66
222
 
67
- $("#myTable").jtable({ /* ... */ });
223
+ ```javascript
224
+ import JTable from 'jtable-pro';
68
225
  ```
69
226
 
70
- Or a plain `<script>` tag, with jQuery loaded first:
227
+ Example Laravel API:
71
228
 
72
- ```html
73
- <script src="https://code.jquery.com/jquery-3.7.1.min.js"></script>
74
- <script src="https://unpkg.com/jtable-pro/src/jtable.js"></script>
75
- <script>
76
- $("#myTable").jtable({ /* ... */ });
77
- </script>
229
+ ```php
230
+ public function index()
231
+ {
232
+ return response()->json([
233
+ 'data' => User::paginate(20)
234
+ ]);
235
+ }
236
+ ```
237
+
238
+ Then use the endpoint:
239
+
240
+ ```javascript
241
+ const table = new JTable('#users-table', {
242
+ url: '/api/users',
243
+ pagination: true,
244
+ searchable: true,
245
+ sortable: true
246
+ });
78
247
  ```
79
248
 
80
- ## Markup
249
+ This makes jtable-pro a convenient option for:
81
250
 
82
- jtable-pro takes over an **empty container element** — a plain `<div>` —
83
- and renders the toolbar (search box, dropdown filters), the table, and the
84
- footer (summary + pagination) inside it:
251
+ * Laravel Admin Panels
252
+ * Laravel Dashboards
253
+ * CRUD applications
254
+ * User management systems
255
+ * Product management
256
+ * Order management
257
+ * Reporting systems
85
258
 
86
- ```html
87
- <div id="myTable"></div>
88
- ```
89
-
90
- Don't hand-write `<table>`/`<thead>`/`<tbody>` the plugin builds all of it.
91
- If the container already has children when `.jtable()` is called, they're
92
- replaced.
93
-
94
- ## Options
95
-
96
- | Option | Type | Default | Description |
97
- |---|---|---|---|
98
- | `columns` | `Column[]` | `[]` | See **Column definition** below. |
99
- | `data` | `array` | `null` | Static array of row objects. Use this or `url`, not both. |
100
- | `url` | `string` | `null` | Fetched once via `$.ajax` on init and on `reload()`. The response is unwrapped by `responseAdapter` into a row array. |
101
- | `requestParams` | `object` | `{}` | Extra query params/body sent with the `url` request. |
102
- | `requestMethod` | `string` | `"GET"` | HTTP method for the `url` request. |
103
- | `responseAdapter` | `function(json) => array` | handles a plain array, `{data:[...]}`, `{data:{data:[...]}}` (Laravel paginator shape), `{items:[...]}`, `{data:{items:[...]}}` | Customize this if your API returns rows some other way. |
104
- | `idField` | `string` | `"id"` | Row identifier field (supports dot paths, e.g. `"product.id"`). Used by selection. |
105
- | `search` | `boolean` | `true` | Show the global search box. Matches any column not marked `searchable: false`. |
106
- | `searchPlaceholder` | `string` | `"Search..."` | |
107
- | `columnSearch` | `boolean` | `false` | Turns on a per-column filter-input row under the header for every column that has a `key` and hasn't opted out (`column.columnSearch: false`). A column can also opt **in** individually with `column.columnSearch: true` while this stays `false`. |
108
- | `filters` | `Filter[]` | `[]` | Toolbar dropdown filters (category/status-style selects). See below. |
109
- | `selectable` | `false \| "single" \| "multi"` | `false` | `"single"`: click a row to select it (one at a time, left accent bar). `"multi"`: adds a checkbox column with a header select-all. |
110
- | `onSelectionChange` | `function(rows, idSet)` | `null` | Fires after any selection change. |
111
- | `onRowClick` | `function(row, event)` | `null` | Fires on any row click (besides clicks on buttons/links/inputs inside the row), regardless of `selectable`. |
112
- | `pagination` | `boolean` | `true` | `false` renders every filtered row with no paging controls. |
113
- | `pageSize` | `number` | `10` | Rows per page. |
114
- | `pageSizes` | `number[]` | `null` | If set, renders a page-size `<select>` in the footer (e.g. `[10, 25, 50]`). |
115
- | `rowClass` | `function(row) => string` | `null` | Extra classes appended to a row's `<tr>`. |
116
- | `emptyText` / `loadingText` / `errorText` | `string` | English defaults | Shown in place of rows. |
117
- | `summaryTemplate` | `string` | `":count records"` | Footer left-hand text. `:count` is replaced with the filtered total. |
118
- | `pageTemplate` | `string` | `":page / :total"` | Footer page indicator. |
119
- | `prevLabel` / `nextLabel` | `string` | English defaults | `aria-label`s for the pagination buttons. |
120
- | `toolbar` | `function($slot, instance)` | `null` | Called once at init with a jQuery element appended to the toolbar row — use it to inject bespoke controls that don't fit the generic `filters` shape. |
121
-
122
- ### Column definition
123
-
124
- ```js
125
- {
126
- key: "price", // dot-path into the row object; omit for a pure render-only column (e.g. actions)
127
- label: "Price", // header text
128
- sortable: true, // default: true when `key` is set (unless options.sortable === false, or this column sets false)
129
- searchable: true, // default: true when `key` is set — whether the global search box matches this column
130
- columnSearch: true, // opt this column into (or out of, with false) the per-column filter row
131
- align: "right", // "left" (default) | "right" | "center"
132
- sortValue: (row) => row.price_cents, // optional: sort by a computed value instead of the raw `key` lookup
133
- render: (row, value) => `<span class="...">${value}</span>`, // optional: custom cell HTML; omit to just escape-and-print `value`
134
- cellClass: "whitespace-nowrap",
259
+ ---
260
+
261
+ # 💚 Vue
262
+
263
+ jtable-pro can also be integrated into Vue applications.
264
+
265
+ ```javascript
266
+ import JTable from 'jtable-pro';
267
+
268
+ const table = new JTable('#users-table', {
269
+ data: users,
270
+ pagination: true,
271
+ searchable: true
272
+ });
273
+ ```
274
+
275
+ ---
276
+
277
+ # ⚛️ React
278
+
279
+ Because jtable-pro is JavaScript-based, it can also be integrated into React applications.
280
+
281
+ Example:
282
+
283
+ ```javascript
284
+ import { useEffect } from 'react';
285
+ import JTable from 'jtable-pro';
286
+
287
+ function UsersTable() {
288
+
289
+ useEffect(() => {
290
+ const table = new JTable('#users-table', {
291
+ data: users,
292
+ pagination: true,
293
+ searchable: true
294
+ });
295
+
296
+ return () => {
297
+ // Cleanup if required
298
+ };
299
+ }, []);
300
+
301
+ return (
302
+ <div id="users-table"></div>
303
+ );
135
304
  }
305
+
306
+ export default UsersTable;
136
307
  ```
137
308
 
138
- `render` receives the **raw row** as well as the already-looked-up `value`,
139
- so a render function can pull in other fields too (e.g. a thumbnail column
140
- reading both `row.image` and `row.name`).
141
-
142
- **Action columns** (edit/delete buttons) are just a normal column with
143
- `sortable: false`, no `columnSearch`, and a `render` that returns whatever
144
- button markup you need — jtable-pro renders that HTML as-is and does
145
- **not** wire up clicks on it. Wire those yourself (e.g. `$(document).on("click", ".my-edit-btn", ...)`)
146
- against whatever stable class/attribute your `render` function emits.
147
-
148
- ### Filter definition (toolbar dropdowns)
149
-
150
- ```js
151
- filters: [
152
- {
153
- key: "category_id", // matched with strict-string equality against getValue(row, key)
154
- label: "Category", // fallback text if allLabel is omitted
155
- allLabel: "All categories",
156
- options: [
157
- { value: "3", label: "Dairy" },
158
- { value: "7", label: "Produce" },
159
- ],
160
- },
161
- ],
162
- ```
163
-
164
- Selecting an option filters rows where `String(getValue(row, key)) ===
165
- String(option.value)`; selecting the "all" entry clears that filter.
166
-
167
- ## Methods
168
-
169
- Call these the usual jQuery-plugin way — `$("#myTable").jtable("methodName", ...args)`:
170
-
171
- | Method | Description |
172
- |---|---|
173
- | `"setData"`, `data` | Replaces the row set and re-renders (resets to page 1). Use this after your own `$.ajax`/`fetch` call when you're not using the plugin's built-in `url` option. |
174
- | `"getData"` | Returns the current raw row array (unfiltered). |
175
- | `"reload"` | Re-runs the pipeline; if `url` was configured, re-fetches from the server first. |
176
- | `"getSelected"` | Returns the array of currently-selected row objects. |
177
- | `"clearSelection"` | Clears selection and re-renders. |
178
- | `"destroy"` | Unbinds events and empties the container. |
179
-
180
- ```js
181
- // Fetch yourself and hand the plugin the rows:
182
- $.get("/api/products").done((response) => {
183
- $("#myTable").jtable("setData", response.data);
309
+ ---
310
+
311
+ # 📊 Example Use Cases
312
+
313
+ jtable-pro is suitable for many types of web applications.
314
+
315
+ ### Admin Panels
316
+
317
+ ```text
318
+ Users
319
+ Products
320
+ Orders
321
+ Customers
322
+ Invoices
323
+ Payments
324
+ ```
325
+
326
+ ### Dashboards
327
+
328
+ ```text
329
+ Analytics
330
+ Reports
331
+ Statistics
332
+ Logs
333
+ Transactions
334
+ ```
335
+
336
+ ### Business Applications
337
+
338
+ ```text
339
+ Inventory
340
+ Employees
341
+ Customers
342
+ Projects
343
+ Tasks
344
+ Orders
345
+ ```
346
+
347
+ ---
348
+
349
+ # ⚙️ Configuration
350
+
351
+ Example configuration:
352
+
353
+ ```javascript
354
+ const table = new JTable('#users-table', {
355
+ data: users,
356
+
357
+ searchable: true,
358
+
359
+ sortable: true,
360
+
361
+ pagination: true,
362
+
363
+ pageSize: 20,
364
+
365
+ columns: [
366
+ {
367
+ key: 'id',
368
+ label: 'ID'
369
+ },
370
+ {
371
+ key: 'name',
372
+ label: 'Name'
373
+ },
374
+ {
375
+ key: 'email',
376
+ label: 'Email'
377
+ }
378
+ ]
184
379
  });
380
+ ```
381
+
382
+ ---
383
+
384
+ # 🧩 Browser Support
385
+
386
+ jtable-pro is designed for modern browsers that support modern JavaScript.
387
+
388
+ Recommended browsers:
389
+
390
+ * Google Chrome
391
+ * Mozilla Firefox
392
+ * Microsoft Edge
393
+ * Safari
394
+
395
+ ---
396
+
397
+ # 📚 Documentation
398
+
399
+ Full documentation and examples:
400
+
401
+ **Coming soon**
402
+
403
+ ---
404
+
405
+ # 🖥️ Demo
406
+
407
+ Try jtable-pro in your browser:
408
+
409
+ **Coming soon**
410
+
411
+ > A live demo is highly recommended so developers can see the component before installing it.
412
+
413
+ ---
414
+
415
+ # 🤝 Contributing
185
416
 
186
- // Read the bulk-action selection:
187
- const selectedIds = $("#myTable").jtable("getSelected").map((row) => row.id);
417
+ Contributions are welcome!
418
+
419
+ If you find a bug or have an idea for a new feature:
420
+
421
+ 1. Fork the repository
422
+ 2. Create a new branch
423
+ 3. Make your changes
424
+ 4. Commit your changes
425
+ 5. Open a Pull Request
426
+
427
+ Example:
428
+
429
+ ```bash
430
+ git clone https://github.com/YOUR_USERNAME/jtable-pro.git
431
+
432
+ cd jtable-pro
433
+
434
+ npm install
435
+
436
+ npm run dev
188
437
  ```
189
438
 
190
- ## Selection & row identity
439
+ ---
440
+
441
+ # 🐛 Bug Reports
442
+
443
+ Found a bug?
444
+
445
+ Please open an issue on GitHub and include:
446
+
447
+ * Browser
448
+ * Operating system
449
+ * jtable-pro version
450
+ * Steps to reproduce
451
+ * Expected behavior
452
+ * Actual behavior
453
+
454
+ ---
455
+
456
+ # 🗺️ Roadmap
457
+
458
+ Planned improvements may include:
459
+
460
+ * [ ] Server-side pagination
461
+ * [ ] Advanced filtering
462
+ * [ ] Column resizing
463
+ * [ ] Column visibility
464
+ * [ ] Row selection
465
+ * [ ] Export to CSV
466
+ * [ ] Export to Excel
467
+ * [ ] Custom cell rendering
468
+ * [ ] Virtual scrolling
469
+ * [ ] Better mobile support
470
+ * [ ] Vue integration
471
+ * [ ] React integration
472
+ * [ ] TypeScript support
473
+
474
+ ---
475
+
476
+ # 📄 License
477
+
478
+ This project is licensed under the **MIT License**.
191
479
 
192
- Row identity for selection is always the **string** form of
193
- `getValue(row, idField)` (`idField` supports dot-paths, e.g.
194
- `"product.id"`). DOM reads use `.attr("data-jtable-id")` rather than
195
- jQuery's auto-coercing `.data()`, so a row's identity stays consistent
196
- whether real ids are numeric, UUIDs, or codes that merely *look* numeric
197
- (e.g. `"007"`, which jQuery's `.data()` would otherwise silently mis-coerce
198
- into the number `7`).
480
+ See the `LICENSE` file for more information.
199
481
 
200
- ## i18n
482
+ ---
201
483
 
202
- Every user-facing string is a plain option — `searchPlaceholder`,
203
- `emptyText`, `loadingText`, `errorText`, `summaryTemplate`, `prevLabel`,
204
- `nextLabel`, column `label`s, filter `label`/`allLabel`/option `label`s.
205
- There's no bundled translation system; pass whatever locale strings your own
206
- app already has.
484
+ # Support the Project
207
485
 
208
- ## What it doesn't do
486
+ If you find **jtable-pro** useful, consider giving the project a ⭐ on GitHub.
209
487
 
210
- - No CSS is bundled you provide Tailwind. There's no fallback/plain-CSS
211
- mode.
212
- - No server-side pagination/sorting/filtering — `url` mode fetches once and
213
- everything after that runs client-side. For very large datasets, fetch a
214
- bounded page yourself and call `setData()` again as the user paginates on
215
- your end, or filter server-side and reload.
216
- - No built-in row-action wiring (edit/delete/etc.) — a render-only "actions"
217
- column plus your own click handlers, same as any other column.
488
+ Your support helps the project grow and motivates further development.
218
489
 
219
- ## License
490
+ ---
220
491
 
221
- MIT
492
+ <p align="center">
493
+ Made with ❤️ for JavaScript developers
494
+ </p>
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "jtable-pro",
3
- "version": "1.0.0",
3
+ "version": "1.0.2",
4
4
  "description": "Premium, app-like jQuery data-table plugin: global search, per-column search, sortable columns, dropdown filters, client-side pagination and row selection — one file, no build step.",
5
5
  "main": "src/jtable.js",
6
6
  "module": "src/jtable.js",