@dodlhuat/basix 1.3.5 → 1.4.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/README.md +83 -7
- package/css/checkbox.scss +15 -2
- package/css/color-picker.scss +278 -0
- package/css/datepicker.scss +5 -3
- package/css/push-menu.scss +7 -0
- package/css/stepper.scss +1 -1
- package/css/style.css +291 -6
- package/css/style.css.map +1 -1
- package/css/style.min.css +1 -1
- package/css/style.min.css.map +1 -1
- package/css/style.scss +1 -0
- package/css/table.scss +33 -0
- package/js/bottom-sheet.d.ts +0 -2
- package/js/bottom-sheet.js +0 -2
- package/js/calendar.d.ts +9 -17
- package/js/calendar.js +4 -7
- package/js/carousel.d.ts +0 -2
- package/js/carousel.js +1 -3
- package/js/chart.d.ts +6 -14
- package/js/chart.js +3 -5
- package/js/code-viewer.d.ts +2 -1
- package/js/code-viewer.js +8 -2
- package/js/color-picker.d.ts +50 -0
- package/js/color-picker.js +291 -0
- package/js/context-menu.d.ts +0 -3
- package/js/context-menu.js +0 -3
- package/js/datepicker.d.ts +0 -4
- package/js/datepicker.js +0 -1
- package/js/docs-nav.js +1 -0
- package/js/dropdown.d.ts +1 -4
- package/js/dropdown.js +0 -1
- package/js/editor.d.ts +0 -4
- package/js/editor.js +3 -5
- package/js/file-uploader.d.ts +0 -4
- package/js/file-uploader.js +0 -1
- package/js/flyout-menu.d.ts +0 -2
- package/js/flyout-menu.js +0 -1
- package/js/gallery.d.ts +1 -4
- package/js/gallery.js +18 -23
- package/js/group-picker.d.ts +0 -5
- package/js/group-picker.js +6 -8
- package/js/lightbox.d.ts +1 -4
- package/js/lightbox.js +6 -10
- package/js/modal.d.ts +0 -2
- package/js/modal.js +0 -1
- package/js/popover.d.ts +0 -3
- package/js/popover.js +0 -2
- package/js/position.d.ts +0 -13
- package/js/position.js +0 -12
- package/js/push-menu.d.ts +0 -3
- package/js/push-menu.js +6 -11
- package/js/range-slider.d.ts +0 -1
- package/js/range-slider.js +2 -3
- package/js/scroll.d.ts +0 -2
- package/js/scroll.js +5 -6
- package/js/scrollbar.d.ts +2 -10
- package/js/scrollbar.js +25 -42
- package/js/select.d.ts +2 -3
- package/js/select.js +6 -9
- package/js/sidebar-nav.d.ts +4 -15
- package/js/sidebar-nav.js +21 -35
- package/js/stepper.d.ts +5 -2
- package/js/stepper.js +42 -6
- package/js/table.d.ts +1 -56
- package/js/table.js +4 -56
- package/js/tabs.d.ts +1 -32
- package/js/tabs.js +7 -39
- package/js/theme.d.ts +0 -44
- package/js/theme.js +0 -44
- package/js/timepicker.d.ts +1 -4
- package/js/timepicker.js +1 -2
- package/js/toast.d.ts +0 -2
- package/js/toast.js +0 -1
- package/js/tooltip.d.ts +0 -4
- package/js/tooltip.js +0 -1
- package/js/tree.d.ts +0 -3
- package/js/tree.js +9 -11
- package/js/utils.d.ts +0 -10
- package/js/utils.js +2 -42
- package/js/virtual-dropdown.d.ts +3 -5
- package/js/virtual-dropdown.js +17 -66
- package/package.json +1 -1
package/js/sidebar-nav.d.ts
CHANGED
|
@@ -1,29 +1,18 @@
|
|
|
1
|
-
/** Configuration options for a SidebarNav instance. */
|
|
2
1
|
interface SidebarNavOptions {
|
|
3
|
-
/** Selector for the toggle button. Default: '.sidebar-toggle' */
|
|
4
2
|
toggleSelector?: string;
|
|
5
|
-
/** Breakpoint (px) above which the sidebar is always visible. Default: 768 */
|
|
6
3
|
breakpoint?: number;
|
|
7
|
-
/** Minimum horizontal swipe distance (px) to trigger open/close. Default: 60 */
|
|
8
4
|
swipeThreshold?: number;
|
|
9
|
-
/** Width of the left-edge zone (px) that triggers open on swipe-right. Default: 20 */
|
|
10
5
|
swipeEdge?: number;
|
|
11
6
|
}
|
|
12
|
-
/** Collapsible sidebar navigation with backdrop, swipe gestures, and responsive breakpoint support. */
|
|
13
7
|
declare class SidebarNav {
|
|
14
8
|
private nav;
|
|
15
9
|
private backdrop;
|
|
16
10
|
private toggleBtn;
|
|
17
11
|
private closeBtn;
|
|
18
12
|
private opts;
|
|
19
|
-
private
|
|
20
|
-
private
|
|
21
|
-
private
|
|
22
|
-
private _onBackdrop;
|
|
23
|
-
private _onResize;
|
|
24
|
-
private _onClose;
|
|
25
|
-
private _onTouchStart;
|
|
26
|
-
private _onTouchEnd;
|
|
13
|
+
private touchStartX;
|
|
14
|
+
private touchStartY;
|
|
15
|
+
private abortController;
|
|
27
16
|
constructor(containerOrSelector: string | HTMLElement, options?: SidebarNavOptions);
|
|
28
17
|
open(): void;
|
|
29
18
|
close(): void;
|
|
@@ -31,4 +20,4 @@ declare class SidebarNav {
|
|
|
31
20
|
isOpen(): boolean;
|
|
32
21
|
destroy(): void;
|
|
33
22
|
}
|
|
34
|
-
export { SidebarNav, SidebarNavOptions };
|
|
23
|
+
export { SidebarNav, type SidebarNavOptions };
|
package/js/sidebar-nav.js
CHANGED
|
@@ -1,18 +1,12 @@
|
|
|
1
|
-
/** Collapsible sidebar navigation with backdrop, swipe gestures, and responsive breakpoint support. */
|
|
2
1
|
class SidebarNav {
|
|
3
2
|
nav;
|
|
4
3
|
backdrop;
|
|
5
4
|
toggleBtn;
|
|
6
5
|
closeBtn = null;
|
|
7
6
|
opts;
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
_onBackdrop;
|
|
12
|
-
_onResize;
|
|
13
|
-
_onClose;
|
|
14
|
-
_onTouchStart;
|
|
15
|
-
_onTouchEnd;
|
|
7
|
+
touchStartX = 0;
|
|
8
|
+
touchStartY = 0;
|
|
9
|
+
abortController = new AbortController();
|
|
16
10
|
constructor(containerOrSelector, options = {}) {
|
|
17
11
|
const container = typeof containerOrSelector === 'string'
|
|
18
12
|
? document.querySelector(containerOrSelector)
|
|
@@ -26,39 +20,36 @@ class SidebarNav {
|
|
|
26
20
|
this.nav = container?.querySelector('.sidebar-nav') ?? null;
|
|
27
21
|
this.backdrop = container?.querySelector('.sidebar-backdrop') ?? null;
|
|
28
22
|
this.toggleBtn = document.querySelector(this.opts.toggleSelector);
|
|
29
|
-
|
|
30
|
-
this.
|
|
31
|
-
this.
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
23
|
+
const sig = { signal: this.abortController.signal };
|
|
24
|
+
this.toggleBtn?.addEventListener('click', () => this.toggle(), sig);
|
|
25
|
+
this.backdrop?.addEventListener('click', () => this.close(), sig);
|
|
26
|
+
window.addEventListener('resize', () => {
|
|
27
|
+
if (window.innerWidth > this.opts.breakpoint)
|
|
28
|
+
this.close();
|
|
29
|
+
}, sig);
|
|
30
|
+
document.addEventListener('touchstart', (e) => {
|
|
31
|
+
this.touchStartX = e.touches[0].clientX;
|
|
32
|
+
this.touchStartY = e.touches[0].clientY;
|
|
33
|
+
}, { passive: true, signal: this.abortController.signal });
|
|
34
|
+
document.addEventListener('touchend', (e) => {
|
|
39
35
|
if (window.innerWidth > this.opts.breakpoint)
|
|
40
36
|
return;
|
|
41
|
-
const dx = e.changedTouches[0].clientX - this.
|
|
42
|
-
const dy = e.changedTouches[0].clientY - this.
|
|
37
|
+
const dx = e.changedTouches[0].clientX - this.touchStartX;
|
|
38
|
+
const dy = e.changedTouches[0].clientY - this.touchStartY;
|
|
43
39
|
if (Math.abs(dx) < Math.abs(dy))
|
|
44
40
|
return;
|
|
45
|
-
if (!this.isOpen() && this.
|
|
41
|
+
if (!this.isOpen() && this.touchStartX <= this.opts.swipeEdge && dx >= this.opts.swipeThreshold) {
|
|
46
42
|
this.open();
|
|
47
43
|
}
|
|
48
44
|
else if (this.isOpen() && dx <= -this.opts.swipeThreshold) {
|
|
49
45
|
this.close();
|
|
50
46
|
}
|
|
51
|
-
};
|
|
52
|
-
this.toggleBtn?.addEventListener('click', this._onToggle);
|
|
53
|
-
this.backdrop?.addEventListener('click', this._onBackdrop);
|
|
54
|
-
window.addEventListener('resize', this._onResize);
|
|
55
|
-
document.addEventListener('touchstart', this._onTouchStart, { passive: true });
|
|
56
|
-
document.addEventListener('touchend', this._onTouchEnd, { passive: true });
|
|
47
|
+
}, { passive: true, signal: this.abortController.signal });
|
|
57
48
|
this.closeBtn = document.createElement('button');
|
|
58
49
|
this.closeBtn.className = 'sidebar-close';
|
|
59
50
|
this.closeBtn.setAttribute('aria-label', 'Close navigation');
|
|
60
51
|
this.closeBtn.innerHTML = '<div class="icon icon-close"></div>';
|
|
61
|
-
this.closeBtn.addEventListener('click', this.
|
|
52
|
+
this.closeBtn.addEventListener('click', () => this.close(), sig);
|
|
62
53
|
this.nav?.append(this.closeBtn);
|
|
63
54
|
}
|
|
64
55
|
open() {
|
|
@@ -76,13 +67,8 @@ class SidebarNav {
|
|
|
76
67
|
return this.nav?.classList.contains('is-open') ?? false;
|
|
77
68
|
}
|
|
78
69
|
destroy() {
|
|
79
|
-
this.
|
|
80
|
-
this.backdrop?.removeEventListener('click', this._onBackdrop);
|
|
81
|
-
window.removeEventListener('resize', this._onResize);
|
|
82
|
-
this.closeBtn?.removeEventListener('click', this._onClose);
|
|
70
|
+
this.abortController.abort();
|
|
83
71
|
this.closeBtn?.remove();
|
|
84
|
-
document.removeEventListener('touchstart', this._onTouchStart);
|
|
85
|
-
document.removeEventListener('touchend', this._onTouchEnd);
|
|
86
72
|
}
|
|
87
73
|
}
|
|
88
74
|
export { SidebarNav };
|
package/js/stepper.d.ts
CHANGED
|
@@ -1,18 +1,21 @@
|
|
|
1
|
-
/** Configuration options for a Stepper instance. */
|
|
2
1
|
interface StepperOptions {
|
|
3
2
|
defaultStep?: number;
|
|
4
3
|
clickable?: boolean;
|
|
5
4
|
onChange?: (current: number, previous: number) => void;
|
|
5
|
+
iconBasePath?: string;
|
|
6
6
|
}
|
|
7
|
-
/** Multi-step progress indicator with clickable steps and connector state. */
|
|
8
7
|
declare class Stepper {
|
|
9
8
|
private container;
|
|
10
9
|
private steps;
|
|
11
10
|
private connectors;
|
|
12
11
|
private current;
|
|
13
12
|
private readonly onChange?;
|
|
13
|
+
private readonly iconBasePath;
|
|
14
14
|
private abortController;
|
|
15
|
+
private injectedConnectors;
|
|
15
16
|
constructor(elementOrSelector: string | HTMLElement, options?: StepperOptions);
|
|
17
|
+
private injectConnectors;
|
|
18
|
+
private checkSvg;
|
|
16
19
|
private render;
|
|
17
20
|
next(): void;
|
|
18
21
|
prev(): void;
|
package/js/stepper.js
CHANGED
|
@@ -1,26 +1,29 @@
|
|
|
1
|
-
/** Multi-step progress indicator with clickable steps and connector state. */
|
|
2
1
|
class Stepper {
|
|
3
2
|
container;
|
|
4
3
|
steps;
|
|
5
4
|
connectors;
|
|
6
5
|
current;
|
|
7
6
|
onChange;
|
|
7
|
+
iconBasePath;
|
|
8
8
|
abortController = new AbortController();
|
|
9
|
+
injectedConnectors = false;
|
|
9
10
|
constructor(elementOrSelector, options = {}) {
|
|
10
11
|
const element = typeof elementOrSelector === 'string'
|
|
11
12
|
? document.querySelector(elementOrSelector)
|
|
12
13
|
: elementOrSelector;
|
|
13
14
|
if (!element)
|
|
14
|
-
throw new Error(
|
|
15
|
+
throw new Error('Stepper: element not found');
|
|
15
16
|
this.container = element;
|
|
16
17
|
this.steps = Array.from(this.container.querySelectorAll('.stepper-step'));
|
|
17
|
-
this.connectors = Array.from(this.container.querySelectorAll('.stepper-connector'));
|
|
18
18
|
this.onChange = options.onChange;
|
|
19
|
+
this.iconBasePath = options.iconBasePath ?? 'svg-icons/';
|
|
19
20
|
this.current = options.defaultStep ?? 0;
|
|
20
21
|
if (this.steps.length === 0) {
|
|
21
22
|
console.warn('Stepper: no .stepper-step elements found');
|
|
23
|
+
this.connectors = [];
|
|
22
24
|
return;
|
|
23
25
|
}
|
|
26
|
+
this.connectors = this.injectConnectors();
|
|
24
27
|
if (options.clickable) {
|
|
25
28
|
this.container.classList.add('stepper-clickable');
|
|
26
29
|
this.steps.forEach((step, i) => {
|
|
@@ -29,13 +32,41 @@ class Stepper {
|
|
|
29
32
|
}
|
|
30
33
|
this.render();
|
|
31
34
|
}
|
|
35
|
+
injectConnectors() {
|
|
36
|
+
const injected = [];
|
|
37
|
+
for (let i = 0; i < this.steps.length - 1; i++) {
|
|
38
|
+
const connector = document.createElement('div');
|
|
39
|
+
connector.className = 'stepper-connector';
|
|
40
|
+
this.steps[i].insertAdjacentElement('afterend', connector);
|
|
41
|
+
injected.push(connector);
|
|
42
|
+
}
|
|
43
|
+
this.injectedConnectors = true;
|
|
44
|
+
return injected;
|
|
45
|
+
}
|
|
46
|
+
checkSvg() {
|
|
47
|
+
return `<svg class="icon-svg" aria-hidden="true"><use href="${this.iconBasePath}icons.svg#check"/></svg>`;
|
|
48
|
+
}
|
|
32
49
|
render() {
|
|
33
50
|
this.steps.forEach((step, i) => {
|
|
34
|
-
step.classList.remove('active', 'completed');
|
|
35
|
-
|
|
51
|
+
step.classList.remove('active', 'completed', 'error');
|
|
52
|
+
const indicator = step.querySelector('.stepper-indicator');
|
|
53
|
+
if (i < this.current) {
|
|
36
54
|
step.classList.add('completed');
|
|
37
|
-
|
|
55
|
+
step.removeAttribute('aria-current');
|
|
56
|
+
if (indicator)
|
|
57
|
+
indicator.innerHTML = this.checkSvg();
|
|
58
|
+
}
|
|
59
|
+
else if (i === this.current) {
|
|
38
60
|
step.classList.add('active');
|
|
61
|
+
step.setAttribute('aria-current', 'step');
|
|
62
|
+
if (indicator)
|
|
63
|
+
indicator.textContent = String(i + 1);
|
|
64
|
+
}
|
|
65
|
+
else {
|
|
66
|
+
step.removeAttribute('aria-current');
|
|
67
|
+
if (indicator)
|
|
68
|
+
indicator.textContent = String(i + 1);
|
|
69
|
+
}
|
|
39
70
|
});
|
|
40
71
|
this.connectors.forEach((connector, i) => {
|
|
41
72
|
connector.classList.toggle('completed', i < this.current);
|
|
@@ -85,6 +116,11 @@ class Stepper {
|
|
|
85
116
|
}
|
|
86
117
|
destroy() {
|
|
87
118
|
this.abortController.abort();
|
|
119
|
+
if (this.injectedConnectors) {
|
|
120
|
+
this.connectors.forEach(c => c.remove());
|
|
121
|
+
this.connectors = [];
|
|
122
|
+
}
|
|
123
|
+
this.steps.forEach(step => step.removeAttribute('aria-current'));
|
|
88
124
|
}
|
|
89
125
|
}
|
|
90
126
|
export { Stepper };
|
package/js/table.d.ts
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
/** Descriptor for a single table column. */
|
|
2
1
|
interface TableColumn {
|
|
3
2
|
key: string;
|
|
4
3
|
label: string;
|
|
5
4
|
sortable?: boolean;
|
|
6
5
|
}
|
|
7
|
-
/** A single data row, keyed by column key. */
|
|
8
6
|
interface TableRow {
|
|
9
7
|
[key: string]: string | number | boolean;
|
|
10
8
|
}
|
|
11
|
-
/** Configuration options for a Table instance. */
|
|
12
9
|
interface TableOptions {
|
|
13
10
|
data?: TableRow[];
|
|
14
11
|
columns?: TableColumn[];
|
|
15
12
|
pageSize?: number;
|
|
16
13
|
}
|
|
17
|
-
/** Dynamic data table with sorting, filtering, and pagination. */
|
|
18
14
|
declare class Table {
|
|
19
15
|
private container;
|
|
20
16
|
private data;
|
|
@@ -29,74 +25,23 @@ declare class Table {
|
|
|
29
25
|
private paginationContainer;
|
|
30
26
|
private abortController;
|
|
31
27
|
constructor(elementOrSelector: string | HTMLElement, options?: TableOptions);
|
|
32
|
-
/**
|
|
33
|
-
* Parses an existing HTML table in the DOM to extract data and columns
|
|
34
|
-
*/
|
|
35
28
|
private parseTableFromDOM;
|
|
36
|
-
/**
|
|
37
|
-
* Initializes the table by rendering controls, structure, and content
|
|
38
|
-
*/
|
|
39
29
|
private init;
|
|
40
|
-
/**
|
|
41
|
-
* Renders the search and page size controls
|
|
42
|
-
*/
|
|
43
30
|
private renderControls;
|
|
44
|
-
/**
|
|
45
|
-
* Creates the table structure (table, thead, tbody, pagination container)
|
|
46
|
-
*/
|
|
47
31
|
private renderTableStructure;
|
|
48
|
-
/**
|
|
49
|
-
* Returns filtered and sorted data based on current state
|
|
50
|
-
*/
|
|
51
32
|
private getFilteredAndSortedData;
|
|
52
|
-
/**
|
|
53
|
-
* Renders the table body, pagination, and header sort indicators
|
|
54
|
-
*/
|
|
55
33
|
private render;
|
|
56
|
-
/**
|
|
57
|
-
* Renders the table body rows
|
|
58
|
-
*/
|
|
59
34
|
private renderBody;
|
|
60
|
-
/**
|
|
61
|
-
* Updates the sort direction indicators in table headers
|
|
62
|
-
*/
|
|
63
35
|
private updateHeaderSortIcons;
|
|
64
|
-
/**
|
|
65
|
-
* Renders pagination controls and info
|
|
66
|
-
*/
|
|
67
36
|
private renderPagination;
|
|
68
|
-
/**
|
|
69
|
-
* Handles search input changes
|
|
70
|
-
*/
|
|
71
37
|
private handleSearch;
|
|
72
|
-
/**
|
|
73
|
-
* Handles column header clicks for sorting
|
|
74
|
-
*/
|
|
75
38
|
private handleSort;
|
|
76
|
-
/**
|
|
77
|
-
* Handles page size changes
|
|
78
|
-
*/
|
|
79
39
|
private handlePageSizeChange;
|
|
80
|
-
/**
|
|
81
|
-
* Sets the current page and re-renders
|
|
82
|
-
*/
|
|
83
40
|
private setPage;
|
|
84
|
-
/**
|
|
85
|
-
* Assigns a unique ID to an element, incrementing if necessary
|
|
86
|
-
*/
|
|
87
41
|
private assignUniqueId;
|
|
88
|
-
/**
|
|
89
|
-
* Public API: Updates the table data and re-renders
|
|
90
|
-
*/
|
|
91
42
|
setData(data: TableRow[]): void;
|
|
92
|
-
/**
|
|
93
|
-
* Public API: Updates the columns and re-renders
|
|
94
|
-
*/
|
|
95
43
|
setColumns(columns: TableColumn[]): void;
|
|
96
|
-
/**
|
|
97
|
-
* Public API: Gets the current filtered and sorted data
|
|
98
|
-
*/
|
|
99
44
|
getData(): TableRow[];
|
|
100
45
|
destroy(): void;
|
|
101
46
|
}
|
|
102
|
-
export { Table, TableRow, TableColumn, TableOptions };
|
|
47
|
+
export { Table, type TableRow, type TableColumn, type TableOptions };
|
package/js/table.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import { Select } from
|
|
2
|
-
/** Dynamic data table with sorting, filtering, and pagination. */
|
|
1
|
+
import { Select } from './select.js';
|
|
3
2
|
class Table {
|
|
4
3
|
container;
|
|
5
4
|
data;
|
|
@@ -21,9 +20,9 @@ class Table {
|
|
|
21
20
|
throw new Error(`Table: Element not found for selector "${elementOrSelector}"`);
|
|
22
21
|
}
|
|
23
22
|
this.container = element;
|
|
24
|
-
this.data = options.data
|
|
25
|
-
this.columns = options.columns
|
|
26
|
-
this.pageSize = options.pageSize
|
|
23
|
+
this.data = options.data ?? [];
|
|
24
|
+
this.columns = options.columns ?? [];
|
|
25
|
+
this.pageSize = options.pageSize ?? 10;
|
|
27
26
|
this.currentPage = 1;
|
|
28
27
|
this.sortColumn = null;
|
|
29
28
|
this.sortDirection = 'asc';
|
|
@@ -33,9 +32,6 @@ class Table {
|
|
|
33
32
|
}
|
|
34
33
|
this.init();
|
|
35
34
|
}
|
|
36
|
-
/**
|
|
37
|
-
* Parses an existing HTML table in the DOM to extract data and columns
|
|
38
|
-
*/
|
|
39
35
|
parseTableFromDOM() {
|
|
40
36
|
const table = this.container.querySelector('table');
|
|
41
37
|
if (!table)
|
|
@@ -63,17 +59,11 @@ class Table {
|
|
|
63
59
|
});
|
|
64
60
|
this.container.innerHTML = '';
|
|
65
61
|
}
|
|
66
|
-
/**
|
|
67
|
-
* Initializes the table by rendering controls, structure, and content
|
|
68
|
-
*/
|
|
69
62
|
init() {
|
|
70
63
|
this.renderControls();
|
|
71
64
|
this.renderTableStructure();
|
|
72
65
|
this.render();
|
|
73
66
|
}
|
|
74
|
-
/**
|
|
75
|
-
* Renders the search and page size controls
|
|
76
|
-
*/
|
|
77
67
|
renderControls() {
|
|
78
68
|
const controlsDiv = document.createElement('div');
|
|
79
69
|
controlsDiv.className = 'table-controls';
|
|
@@ -108,9 +98,6 @@ class Table {
|
|
|
108
98
|
this.container.appendChild(controlsDiv);
|
|
109
99
|
new Select('#' + pageSizeSelect.id);
|
|
110
100
|
}
|
|
111
|
-
/**
|
|
112
|
-
* Creates the table structure (table, thead, tbody, pagination container)
|
|
113
|
-
*/
|
|
114
101
|
renderTableStructure() {
|
|
115
102
|
const wrapper = document.createElement('div');
|
|
116
103
|
wrapper.className = 'table-wrapper';
|
|
@@ -140,9 +127,6 @@ class Table {
|
|
|
140
127
|
this.tableHeader = thead;
|
|
141
128
|
this.paginationContainer = paginationDiv;
|
|
142
129
|
}
|
|
143
|
-
/**
|
|
144
|
-
* Returns filtered and sorted data based on current state
|
|
145
|
-
*/
|
|
146
130
|
getFilteredAndSortedData() {
|
|
147
131
|
let processedData = [...this.data];
|
|
148
132
|
if (this.filterText) {
|
|
@@ -173,9 +157,6 @@ class Table {
|
|
|
173
157
|
}
|
|
174
158
|
return processedData;
|
|
175
159
|
}
|
|
176
|
-
/**
|
|
177
|
-
* Renders the table body, pagination, and header sort indicators
|
|
178
|
-
*/
|
|
179
160
|
render() {
|
|
180
161
|
const processedData = this.getFilteredAndSortedData();
|
|
181
162
|
const totalItems = processedData.length;
|
|
@@ -193,9 +174,6 @@ class Table {
|
|
|
193
174
|
this.renderPagination(totalItems, totalPages, startIndex, endIndex);
|
|
194
175
|
this.updateHeaderSortIcons();
|
|
195
176
|
}
|
|
196
|
-
/**
|
|
197
|
-
* Renders the table body rows
|
|
198
|
-
*/
|
|
199
177
|
renderBody(data) {
|
|
200
178
|
this.tableBody.innerHTML = '';
|
|
201
179
|
if (data.length === 0) {
|
|
@@ -219,9 +197,6 @@ class Table {
|
|
|
219
197
|
this.tableBody.appendChild(tr);
|
|
220
198
|
});
|
|
221
199
|
}
|
|
222
|
-
/**
|
|
223
|
-
* Updates the sort direction indicators in table headers
|
|
224
|
-
*/
|
|
225
200
|
updateHeaderSortIcons() {
|
|
226
201
|
const ths = this.tableHeader.querySelectorAll('th');
|
|
227
202
|
ths.forEach(th => {
|
|
@@ -231,9 +206,6 @@ class Table {
|
|
|
231
206
|
}
|
|
232
207
|
});
|
|
233
208
|
}
|
|
234
|
-
/**
|
|
235
|
-
* Renders pagination controls and info
|
|
236
|
-
*/
|
|
237
209
|
renderPagination(totalItems, totalPages, startIndex, endIndex) {
|
|
238
210
|
this.paginationContainer.innerHTML = '';
|
|
239
211
|
if (totalItems === 0)
|
|
@@ -270,17 +242,11 @@ class Table {
|
|
|
270
242
|
buttonsDiv.appendChild(nextBtn);
|
|
271
243
|
this.paginationContainer.appendChild(buttonsDiv);
|
|
272
244
|
}
|
|
273
|
-
/**
|
|
274
|
-
* Handles search input changes
|
|
275
|
-
*/
|
|
276
245
|
handleSearch(text) {
|
|
277
246
|
this.filterText = text;
|
|
278
247
|
this.currentPage = 1;
|
|
279
248
|
this.render();
|
|
280
249
|
}
|
|
281
|
-
/**
|
|
282
|
-
* Handles column header clicks for sorting
|
|
283
|
-
*/
|
|
284
250
|
handleSort(key) {
|
|
285
251
|
if (this.sortColumn === key) {
|
|
286
252
|
this.sortDirection = this.sortDirection === 'asc' ? 'desc' : 'asc';
|
|
@@ -291,24 +257,15 @@ class Table {
|
|
|
291
257
|
}
|
|
292
258
|
this.render();
|
|
293
259
|
}
|
|
294
|
-
/**
|
|
295
|
-
* Handles page size changes
|
|
296
|
-
*/
|
|
297
260
|
handlePageSizeChange(size) {
|
|
298
261
|
this.pageSize = size;
|
|
299
262
|
this.currentPage = 1;
|
|
300
263
|
this.render();
|
|
301
264
|
}
|
|
302
|
-
/**
|
|
303
|
-
* Sets the current page and re-renders
|
|
304
|
-
*/
|
|
305
265
|
setPage(page) {
|
|
306
266
|
this.currentPage = page;
|
|
307
267
|
this.render();
|
|
308
268
|
}
|
|
309
|
-
/**
|
|
310
|
-
* Assigns a unique ID to an element, incrementing if necessary
|
|
311
|
-
*/
|
|
312
269
|
assignUniqueId(element, baseId) {
|
|
313
270
|
if (!element || !baseId)
|
|
314
271
|
return null;
|
|
@@ -327,25 +284,16 @@ class Table {
|
|
|
327
284
|
element.id = uniqueId;
|
|
328
285
|
return uniqueId;
|
|
329
286
|
}
|
|
330
|
-
/**
|
|
331
|
-
* Public API: Updates the table data and re-renders
|
|
332
|
-
*/
|
|
333
287
|
setData(data) {
|
|
334
288
|
this.data = data;
|
|
335
289
|
this.currentPage = 1;
|
|
336
290
|
this.render();
|
|
337
291
|
}
|
|
338
|
-
/**
|
|
339
|
-
* Public API: Updates the columns and re-renders
|
|
340
|
-
*/
|
|
341
292
|
setColumns(columns) {
|
|
342
293
|
this.columns = columns;
|
|
343
294
|
this.container.innerHTML = '';
|
|
344
295
|
this.init();
|
|
345
296
|
}
|
|
346
|
-
/**
|
|
347
|
-
* Public API: Gets the current filtered and sorted data
|
|
348
|
-
*/
|
|
349
297
|
getData() {
|
|
350
298
|
return this.getFilteredAndSortedData();
|
|
351
299
|
}
|
package/js/tabs.d.ts
CHANGED
|
@@ -1,59 +1,28 @@
|
|
|
1
1
|
type TabLayout = 'horizontal' | 'vertical';
|
|
2
2
|
type MenuPosition = 'top' | 'bottom' | 'left' | 'right';
|
|
3
|
-
/** Configuration options for a Tabs instance. */
|
|
4
3
|
interface TabsOptions {
|
|
5
4
|
layout?: TabLayout;
|
|
6
5
|
defaultTab?: number;
|
|
7
6
|
menuPos?: MenuPosition;
|
|
8
7
|
onChange?: (index: number) => void;
|
|
9
8
|
}
|
|
10
|
-
/** Tabbed content component with horizontal/vertical layouts and keyboard navigation. */
|
|
11
9
|
declare class Tabs {
|
|
12
10
|
private container;
|
|
13
11
|
private options;
|
|
14
12
|
private tabItems;
|
|
15
13
|
private tabPanels;
|
|
16
14
|
private currentTab;
|
|
15
|
+
private abortController;
|
|
17
16
|
constructor(elementOrSelector: string | HTMLElement, options?: TabsOptions);
|
|
18
|
-
/**
|
|
19
|
-
* Initializes the tabs component
|
|
20
|
-
*/
|
|
21
17
|
private init;
|
|
22
|
-
/**
|
|
23
|
-
* Binds click events to tab items
|
|
24
|
-
*/
|
|
25
18
|
private bindEvents;
|
|
26
|
-
/**
|
|
27
|
-
* Handles keyboard navigation (Arrow keys, Home, End)
|
|
28
|
-
*/
|
|
29
19
|
private handleKeyboardNavigation;
|
|
30
|
-
/**
|
|
31
|
-
* Activates a tab by index
|
|
32
|
-
*/
|
|
33
20
|
private activateTab;
|
|
34
|
-
/**
|
|
35
|
-
* Public API: Programmatically activate a tab
|
|
36
|
-
*/
|
|
37
21
|
goToTab(index: number): void;
|
|
38
|
-
/**
|
|
39
|
-
* Public API: Get the currently active tab index
|
|
40
|
-
*/
|
|
41
22
|
getCurrentTab(): number;
|
|
42
|
-
/**
|
|
43
|
-
* Public API: Get the total number of tabs
|
|
44
|
-
*/
|
|
45
23
|
getTabCount(): number;
|
|
46
|
-
/**
|
|
47
|
-
* Public API: Enable a tab
|
|
48
|
-
*/
|
|
49
24
|
enableTab(index: number): void;
|
|
50
|
-
/**
|
|
51
|
-
* Public API: Disable a tab
|
|
52
|
-
*/
|
|
53
25
|
disableTab(index: number): void;
|
|
54
|
-
/**
|
|
55
|
-
* Public API: Destroy the tabs instance and clean up
|
|
56
|
-
*/
|
|
57
26
|
destroy(): void;
|
|
58
27
|
}
|
|
59
28
|
export { Tabs };
|