Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions README.de.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Ersetzen Sie `path/to/avalynx-datatable.js` und `path/to/avalynx-datatable.css`
AvalynxDataTable ist auch über [jsDelivr](https://www.jsdelivr.com/) verfügbar. Sie können es so in Ihr Projekt einbinden:

```html
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.2/dist/css/avalynx-datatable.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.2/dist/js/avalynx-datatable.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/css/avalynx-datatable.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/js/avalynx-datatable.min.js"></script>
```

Stellen Sie sicher, dass Sie auch die JS/CSS-Dateien von Bootstrap in Ihr Projekt einbinden, damit AvalynxDataTable korrekt angezeigt wird.
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,8 @@ Replace `path/to/avalynx-datatable.js` and `path/to/avalynx-datatable.css` with
AvalynxDataTable is also available via [jsDelivr](https://www.jsdelivr.com/). You can include it in your project like this:

```html
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.2/dist/css/avalynx-datatable.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.2/dist/js/avalynx-datatable.min.js"></script>
<link href="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/css/avalynx-datatable.min.css" rel="stylesheet">
<script src="https://cdn.jsdelivr.net/npm/avalynx-datatable@1.0.3/dist/js/avalynx-datatable.min.js"></script>
```

Make sure to also include Bootstrap's JS/CSS in your project to ensure AvalynxDataTable displays correctly.
Expand Down
32 changes: 32 additions & 0 deletions __tests__/avalynx-datatable.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ describe('AvalynxDataTable', () => {
expect(dt.options.listPerPage).toEqual([10, 25, 50, 100]);
expect(dt.options.paginationPrevNext).toBe(true);
expect(dt.options.paginationRange).toBe(2);
expect(dt.options.md).toBe('md');
});

test('should merge custom options with defaults', () => {
Expand Down Expand Up @@ -208,6 +209,37 @@ describe('AvalynxDataTable', () => {
expect(searchInput).not.toBeNull();
});

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

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

const container = document.getElementById('test-datatable');
const topSection = container.querySelector('.avalynx-datatable-top');
const bottomSection = container.querySelector('.avalynx-datatable-bottom');

expect(topSection.classList.contains('flex-md-row')).toBe(true);
expect(bottomSection.classList.contains('flex-md-row')).toBe(true);
});

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

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

const container = document.getElementById('test-datatable');
const topSection = container.querySelector('.avalynx-datatable-top');
const bottomSection = container.querySelector('.avalynx-datatable-bottom');

expect(topSection.classList.contains('flex-lg-row')).toBe(true);
expect(bottomSection.classList.contains('flex-lg-row')).toBe(true);
expect(topSection.classList.contains('flex-md-row')).toBe(false);
expect(bottomSection.classList.contains('flex-md-row')).toBe(false);
});

test('should create table with proper structure and ID', async () => {
new AvalynxDataTable('test-datatable', { apiUrl: 'http://test.com/api' });

Expand Down
2 changes: 1 addition & 1 deletion dist/css/avalynx-datatable.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
*
* @version 1.0.2
* @version 1.0.3
* @license MIT
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
* @website https://github.com/avalynx/
Expand Down
2 changes: 1 addition & 1 deletion dist/js/avalynx-datatable.esm.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
*
* @version 1.0.2
* @version 1.0.3
* @license MIT
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
* @website https://github.com/avalynx/
Expand Down
2 changes: 1 addition & 1 deletion dist/js/avalynx-datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
*
* @version 1.0.2
* @version 1.0.3
* @license MIT
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
* @website https://github.com/avalynx/
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "avalynx-datatable",
"title": "AvalynxDataTable",
"description": "AvalynxDataTable is a simple, lightweight, and customizable datatable for the web. Based on Bootstrap >=5.3 without any framework dependencies.",
"version": "1.0.2",
"version": "1.0.3",
"license": "MIT",
"main": "dist/js/avalynx-datatable.js",
"module": "dist/js/avalynx-datatable.esm.js",
Expand Down
2 changes: 1 addition & 1 deletion src/css/avalynx-datatable.css
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
*
* A simple, lightweight, and customizable data table for the web. Based on Bootstrap >=5.3 without any framework dependencies.
*
* @version 1.0.2
* @version 1.0.3
* @license MIT
* @author https://github.com/avalynx/avalynx-datatable/graphs/contributors
* @website https://github.com/avalynx/
Expand Down
10 changes: 8 additions & 2 deletions src/js/avalynx-datatable.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
* @param {array} options.listPerPage - The list of options for the per-page dropdown (default: [10, 25, 50, 100]).
* @param {number} options.perPage - The initial number of items per page (default: 10).
* @param {string} options.className - The CSS classes to apply to the table (default: 'table table-striped table-bordered table-responsive').
* @param {string} options.md - Bootstrap breakpoint used for top/bottom row layout (default: 'md').
* @param {boolean} options.paginationPrevNext - Whether to show the previous and next buttons in the pagination (default: true).
* @param {number} options.paginationRange - The number of pages to show on either side of the current page in the pagination (default: 2).
* @param {object} options.loader - An instance of AvalynxLoader to use as the loader for the table (default: null).
Expand Down Expand Up @@ -56,6 +57,7 @@ class AvalynxDataTable {
listPerPage: [10, 25, 50, 100],
perPage: 10,
className: 'table table-striped table-bordered table-responsive align-middle',
md: 'md',
paginationPrevNext: true,
paginationRange: 2,
loader: null,
Expand Down Expand Up @@ -97,6 +99,10 @@ class AvalynxDataTable {
const tableTemplate = document.getElementById("avalynx-datatable-table").content.cloneNode(true);
const bottomTemplate = document.getElementById("avalynx-datatable-bottom").content.cloneNode(true);

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

const table = tableTemplate.querySelector("table");
table.className = `${this.options.className} avalynx-datatable-table`;
table.id = `${this.id}-table`;
Expand Down Expand Up @@ -191,7 +197,7 @@ class AvalynxDataTable {
ensureTemplatesExist() {
const templates = {
"avalynx-datatable-top": `
<div class="d-flex flex-column flex-md-row avalynx-datatable-top">
<div class="d-flex flex-column avalynx-datatable-top">
<div class="d-flex align-self-center pb-2 avalynx-datatable-top-entries">
<label class="align-self-center"></label>
<div class="align-self-center px-2">
Expand All @@ -211,7 +217,7 @@ class AvalynxDataTable {
<tbody></tbody>
</table>`,
"avalynx-datatable-bottom": `
<div class="d-flex flex-column flex-md-row avalynx-datatable-bottom">
<div class="d-flex flex-column avalynx-datatable-bottom">
<div class="d-flex avalynx-datatable-bottom-entries pb-2"></div>
<div class="flex-grow-1"></div>
<nav class="align-self-center avalynx-datatable-bottom-pagination">
Expand Down