Skip to content

Commit 885c803

Browse files
committed
Add breakpoint option for responsive layout customization and bump version to 1.0.4
1 parent 03df5a2 commit 885c803

9 files changed

Lines changed: 38 additions & 20 deletions

README.de.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Ersetzen Sie `path/to/avalynx-datatable.js` und `path/to/avalynx-datatable.css`
5555
AvalynxDataTable ist auch über [jsDelivr](https://www.jsdelivr.com/) verfügbar. Sie können es so in Ihr Projekt einbinden:
5656

5757
```html
58-
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/css/avalynx-datatable.min.css" rel="stylesheet">
59-
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/js/avalynx-datatable.min.js"></script>
58+
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.4/dist/css/avalynx-datatable.min.css" rel="stylesheet">
59+
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.4/dist/js/avalynx-datatable.min.js"></script>
6060
```
6161

6262
Stellen Sie sicher, dass Sie auch die JS/CSS-Dateien von Bootstrap in Ihr Projekt einbinden, damit AvalynxDataTable korrekt angezeigt wird.
@@ -134,6 +134,7 @@ new AvalynxDataTable("avalynx-datatable", {
134134
apiUrl: "result.php",
135135
perPage: 10,
136136
search: "",
137+
breakpoint: "md",
137138
sorting: {
138139
"name": "asc",
139140
"age": "desc"
@@ -275,6 +276,7 @@ AvalynxDataTable ermöglicht die folgenden Optionen zur Anpassung:
275276
- `listPerPage` (array): Die Liste der Optionen für das Pro-Seite-Dropdown (Standard: `[10, 25, 50, 100]`).
276277
- `perPage` (number): Die anfängliche Anzahl der Elemente pro Seite (Standard: `10`).
277278
- `className` (string): Die CSS-Klassen, die auf die Tabelle angewendet werden sollen (Standard: `'table table-striped table-bordered table-responsive'`).
279+
- `breakpoint` (string): Bootstrap-Breakpoint für das Top/Bottom-Layout (`flex-{breakpoint}-row`, Standard: `'md'`).
278280
- `paginationPrevNext` (boolean): Ob die Vorherige- und Nächste-Buttons in der Pagination angezeigt werden sollen (Standard: `true`).
279281
- `paginationRange` (number): Die Anzahl der Seiten, die auf jeder Seite der aktuellen Seite in der Pagination angezeigt werden sollen (Standard: `2`).
280282
- `loader` (object): Eine Instanz von AvalynxLoader, die als Loader für die Tabelle verwendet werden soll (Standard: `null`).

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,8 +55,8 @@ Replace `path/to/avalynx-datatable.js` and `path/to/avalynx-datatable.css` with
5555
AvalynxDataTable is also available via [jsDelivr](https://www.jsdelivr.com/). You can include it in your project like this:
5656

5757
```html
58-
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/css/avalynx-datatable.min.css" rel="stylesheet">
59-
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/js/avalynx-datatable.min.js"></script>
58+
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.4/dist/css/avalynx-datatable.min.css" rel="stylesheet">
59+
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.4/dist/js/avalynx-datatable.min.js"></script>
6060
```
6161

6262
Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxDataTable displays correctly.
@@ -134,6 +134,7 @@ new AvalynxDataTable("avalynx-datatable", {
134134
apiUrl: "result.php",
135135
perPage: 10,
136136
search: "",
137+
breakpoint: "md",
137138
sorting: {
138139
"name": "asc",
139140
"age": "desc"
@@ -275,6 +276,7 @@ AvalynxDataTable allows the following options for customization:
275276
- `listPerPage` (array): The list of options for the per-page dropdown (default: `[10, 25, 50, 100]`).
276277
- `perPage` (number): The initial number of items per page (default: `10`).
277278
- `className` (string): The CSS classes to apply to the table (default: `'table table-striped table-bordered table-responsive'`).
279+
- `breakpoint` (string): Bootstrap breakpoint used for top/bottom row layout (`flex-{breakpoint}-row`, default: `'md'`).
278280
- `paginationPrevNext` (boolean): Whether to show the previous and next buttons in the pagination (default: `true`).
279281
- `paginationRange` (number): The number of pages to show on either side of the current page in the pagination (default: `2`).
280282
- `loader` (object): An instance of AvalynxLoader to use as the loader for the table (default: `null`).

__tests__/avalynx-datatable.test.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ describe('AvalynxDataTable', () => {
9494
expect(dt.options.listPerPage).toEqual([10, 25, 50, 100]);
9595
expect(dt.options.paginationPrevNext).toBe(true);
9696
expect(dt.options.paginationRange).toBe(2);
97-
expect(dt.options.md).toBe('md');
97+
expect(dt.options.breakpoint).toBe('md');
9898
});
9999

100100
test('should merge custom options with defaults', () => {
@@ -209,7 +209,7 @@ describe('AvalynxDataTable', () => {
209209
expect(searchInput).not.toBeNull();
210210
});
211211

212-
test('should apply default md breakpoint class to top and bottom sections', async () => {
212+
test('should apply default breakpoint class to top and bottom sections', async () => {
213213
new AvalynxDataTable('test-datatable', { apiUrl: 'http://test.com/api' });
214214

215215
await new Promise(resolve => setTimeout(resolve, 10));
@@ -225,7 +225,7 @@ describe('AvalynxDataTable', () => {
225225
test('should apply custom breakpoint class to top and bottom sections', async () => {
226226
new AvalynxDataTable('test-datatable', {
227227
apiUrl: 'http://test.com/api',
228-
md: 'lg'
228+
breakpoint: 'lg'
229229
});
230230

231231
await new Promise(resolve => setTimeout(resolve, 10));

dist/css/avalynx-datatable.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
55
*
6-
* @version 1.0.3
6+
* @version 1.0.4
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
99
* @website https://github.com/avalynx/

dist/js/avalynx-datatable.esm.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
55
*
6-
* @version 1.0.3
6+
* @version 1.0.4
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
99
* @website https://github.com/avalynx/
@@ -22,6 +22,7 @@
2222
* @param {array} options.listPerPage - The list of options for the per-page dropdown (default: [10, 25, 50, 100]).
2323
* @param {number} options.perPage - The initial number of items per page (default: 10).
2424
* @param {string} options.className - The CSS classes to apply to the table (default: 'table table-striped table-bordered table-responsive').
25+
* @param {string} options.breakpoint - Bootstrap breakpoint used for top/bottom row layout (default: 'md').
2526
* @param {boolean} options.paginationPrevNext - Whether to show the previous and next buttons in the pagination (default: true).
2627
* @param {number} options.paginationRange - The number of pages to show on either side of the current page in the pagination (default: 2).
2728
* @param {object} options.loader - An instance of AvalynxLoader to use as the loader for the table (default: null).
@@ -58,6 +59,7 @@ export class AvalynxDataTable {
5859
listPerPage: [10, 25, 50, 100],
5960
perPage: 10,
6061
className: 'table table-striped table-bordered table-responsive align-middle',
62+
breakpoint: 'md',
6163
paginationPrevNext: true,
6264
paginationRange: 2,
6365
loader: null,
@@ -99,6 +101,10 @@ export class AvalynxDataTable {
99101
const tableTemplate = document.getElementById("avalynx-datatable-table").content.cloneNode(true);
100102
const bottomTemplate = document.getElementById("avalynx-datatable-bottom").content.cloneNode(true);
101103

104+
const responsiveClass = `flex-${this.options.breakpoint}-row`;
105+
topTemplate.querySelector(".avalynx-datatable-top").classList.add(responsiveClass);
106+
bottomTemplate.querySelector(".avalynx-datatable-bottom").classList.add(responsiveClass);
107+
102108
const table = tableTemplate.querySelector("table");
103109
table.className = `${this.options.className} avalynx-datatable-table`;
104110
table.id = `${this.id}-table`;
@@ -193,7 +199,7 @@ export class AvalynxDataTable {
193199
ensureTemplatesExist() {
194200
const templates = {
195201
"avalynx-datatable-top": `
196-
<div class="d-flex flex-column flex-md-row avalynx-datatable-top">
202+
<div class="d-flex flex-column avalynx-datatable-top">
197203
<div class="d-flex align-self-center pb-2 avalynx-datatable-top-entries">
198204
<label class="align-self-center"></label>
199205
<div class="align-self-center px-2">
@@ -213,7 +219,7 @@ export class AvalynxDataTable {
213219
<tbody></tbody>
214220
</table>`,
215221
"avalynx-datatable-bottom": `
216-
<div class="d-flex flex-column flex-md-row avalynx-datatable-bottom">
222+
<div class="d-flex flex-column avalynx-datatable-bottom">
217223
<div class="d-flex avalynx-datatable-bottom-entries pb-2"></div>
218224
<div class="flex-grow-1"></div>
219225
<nav class="align-self-center avalynx-datatable-bottom-pagination">
@@ -485,6 +491,7 @@ export class AvalynxDataTable {
485491
this.avalynxTableInstance = null;
486492
}
487493
}
494+
488495
/* istanbul ignore next */
489496
if (typeof module !== 'undefined' && module.exports) {
490497
module.exports = AvalynxDataTable;

dist/js/avalynx-datatable.js

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
55
*
6-
* @version 1.0.3
6+
* @version 1.0.4
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
99
* @website https://github.com/avalynx/
@@ -22,6 +22,7 @@
2222
* @param {array} options.listPerPage - The list of options for the per-page dropdown (default: [10, 25, 50, 100]).
2323
* @param {number} options.perPage - The initial number of items per page (default: 10).
2424
* @param {string} options.className - The CSS classes to apply to the table (default: 'table table-striped table-bordered table-responsive').
25+
* @param {string} options.breakpoint - Bootstrap breakpoint used for top/bottom row layout (default: 'md').
2526
* @param {boolean} options.paginationPrevNext - Whether to show the previous and next buttons in the pagination (default: true).
2627
* @param {number} options.paginationRange - The number of pages to show on either side of the current page in the pagination (default: 2).
2728
* @param {object} options.loader - An instance of AvalynxLoader to use as the loader for the table (default: null).
@@ -56,6 +57,7 @@ class AvalynxDataTable {
5657
listPerPage: [10, 25, 50, 100],
5758
perPage: 10,
5859
className: 'table table-striped table-bordered table-responsive align-middle',
60+
breakpoint: 'md',
5961
paginationPrevNext: true,
6062
paginationRange: 2,
6163
loader: null,
@@ -97,6 +99,10 @@ class AvalynxDataTable {
9799
const tableTemplate = document.getElementById("avalynx-datatable-table").content.cloneNode(true);
98100
const bottomTemplate = document.getElementById("avalynx-datatable-bottom").content.cloneNode(true);
99101

102+
const responsiveClass = `flex-${this.options.breakpoint}-row`;
103+
topTemplate.querySelector(".avalynx-datatable-top").classList.add(responsiveClass);
104+
bottomTemplate.querySelector(".avalynx-datatable-bottom").classList.add(responsiveClass);
105+
100106
const table = tableTemplate.querySelector("table");
101107
table.className = `${this.options.className} avalynx-datatable-table`;
102108
table.id = `${this.id}-table`;
@@ -191,7 +197,7 @@ class AvalynxDataTable {
191197
ensureTemplatesExist() {
192198
const templates = {
193199
"avalynx-datatable-top": `
194-
<div class="d-flex flex-column flex-md-row avalynx-datatable-top">
200+
<div class="d-flex flex-column avalynx-datatable-top">
195201
<div class="d-flex align-self-center pb-2 avalynx-datatable-top-entries">
196202
<label class="align-self-center"></label>
197203
<div class="align-self-center px-2">
@@ -211,7 +217,7 @@ class AvalynxDataTable {
211217
<tbody></tbody>
212218
</table>`,
213219
"avalynx-datatable-bottom": `
214-
<div class="d-flex flex-column flex-md-row avalynx-datatable-bottom">
220+
<div class="d-flex flex-column avalynx-datatable-bottom">
215221
<div class="d-flex avalynx-datatable-bottom-entries pb-2"></div>
216222
<div class="flex-grow-1"></div>
217223
<nav class="align-self-center avalynx-datatable-bottom-pagination">
@@ -483,6 +489,7 @@ class AvalynxDataTable {
483489
this.avalynxTableInstance = null;
484490
}
485491
}
492+
486493
/* istanbul ignore next */
487494
if (typeof module !== 'undefined' && module.exports) {
488495
module.exports = AvalynxDataTable;

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"name": "avalynx-datatable",
33
"title": "AvalynxDataTable",
44
"description": "AvalynxDataTable is a simple, lightweight, and customizable datatable for the web. Based on Bootstrap >=5.3 without any framework dependencies.",
5-
"version": "1.0.3",
5+
"version": "1.0.4",
66
"license": "MIT",
77
"main": "dist/js/avalynx-datatable.js",
88
"module": "dist/js/avalynx-datatable.esm.js",

src/css/avalynx-datatable.css

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
55
*
6-
* @version 1.0.3
6+
* @version 1.0.4
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
99
* @website https://github.com/avalynx/

src/js/avalynx-datatable.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
*
44
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
55
*
6-
* @version 1.0.2
6+
* @version 1.0.4
77
* @license MIT
88
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
99
* @website https://github.com/avalynx/
@@ -22,7 +22,7 @@
2222
* @param {array} options.listPerPage - The list of options for the per-page dropdown (default: [10, 25, 50, 100]).
2323
* @param {number} options.perPage - The initial number of items per page (default: 10).
2424
* @param {string} options.className - The CSS classes to apply to the table (default: 'table table-striped table-bordered table-responsive').
25-
* @param {string} options.md - Bootstrap breakpoint used for top/bottom row layout (default: 'md').
25+
* @param {string} options.breakpoint - Bootstrap breakpoint used for top/bottom row layout (default: 'md').
2626
* @param {boolean} options.paginationPrevNext - Whether to show the previous and next buttons in the pagination (default: true).
2727
* @param {number} options.paginationRange - The number of pages to show on either side of the current page in the pagination (default: 2).
2828
* @param {object} options.loader - An instance of AvalynxLoader to use as the loader for the table (default: null).
@@ -57,7 +57,7 @@ class AvalynxDataTable {
5757
listPerPage: [10, 25, 50, 100],
5858
perPage: 10,
5959
className: 'table table-striped table-bordered table-responsive align-middle',
60-
md: 'md',
60+
breakpoint: 'md',
6161
paginationPrevNext: true,
6262
paginationRange: 2,
6363
loader: null,
@@ -99,7 +99,7 @@ class AvalynxDataTable {
9999
const tableTemplate = document.getElementById("avalynx-datatable-table").content.cloneNode(true);
100100
const bottomTemplate = document.getElementById("avalynx-datatable-bottom").content.cloneNode(true);
101101

102-
const responsiveClass = `flex-${this.options.md}-row`;
102+
const responsiveClass = `flex-${this.options.breakpoint}-row`;
103103
topTemplate.querySelector(".avalynx-datatable-top").classList.add(responsiveClass);
104104
bottomTemplate.querySelector(".avalynx-datatable-bottom").classList.add(responsiveClass);
105105

0 commit comments

Comments
 (0)