@itrocks/table 0.0.22 → 0.1.1
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/column-reorder.d.ts +2 -2
- package/column-reorder.js +2 -2
- package/edit/lock.d.ts +6 -6
- package/edit/lock.js +9 -11
- package/edit/move.d.ts +3 -3
- package/edit/move.js +2 -3
- package/edit-freeze/hide.d.ts +5 -5
- package/edit-freeze/hide.js +6 -7
- package/edit-freeze/scroll.d.ts +2 -2
- package/edit-freeze/scroll.js +3 -4
- package/edit.d.ts +2 -2
- package/feed.d.ts +2 -2
- package/feed.js +3 -4
- package/freeze/inherit-background.d.ts +0 -2
- package/freeze/inherit-background.js +1 -4
- package/freeze/inherit-border.d.ts +1 -5
- package/freeze/inherit-border.js +7 -13
- package/freeze.d.ts +1 -2
- package/freeze.js +1 -4
- package/link.d.ts +31 -0
- package/link.js +76 -0
- package/package.json +1 -1
- package/table.d.ts +1 -1
package/column-reorder.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
2
2
|
import { HTMLTableFreezeElement } from './freeze.js';
|
|
3
3
|
import { Table } from './table.js';
|
|
4
4
|
export declare class TableColumnReorder extends Plugin<Table> {
|
|
5
5
|
reorderCells: NodeListOf<HTMLTableFreezeElement>;
|
|
6
|
-
|
|
6
|
+
init(): void;
|
|
7
7
|
protected getReorderCells(): NodeListOf<HTMLTableFreezeElement>;
|
|
8
8
|
}
|
package/column-reorder.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { Plugin } from '../plugin/plugin.js';
|
|
2
2
|
export class TableColumnReorder extends Plugin {
|
|
3
3
|
reorderCells;
|
|
4
|
-
|
|
5
|
-
super(table);
|
|
4
|
+
init() {
|
|
6
5
|
this.reorderCells = this.getReorderCells();
|
|
7
6
|
let downed;
|
|
8
7
|
let dragging;
|
|
9
8
|
let mouse = new DOMRect;
|
|
10
9
|
let mouseFrom = new DOMRect;
|
|
10
|
+
const table = this.of;
|
|
11
11
|
for (const cell of Array.from(this.reorderCells)) {
|
|
12
12
|
table.addEventListener(cell, 'mousedown', event => {
|
|
13
13
|
console.log('mousedown', event.target);
|
package/edit/lock.d.ts
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
2
|
+
import { PluginOptions } from '../../plugin/plugin.js';
|
|
2
3
|
import { Table } from '../table.js';
|
|
3
|
-
declare class Options {
|
|
4
|
+
declare class Options extends PluginOptions {
|
|
4
5
|
nonEditableConditions: {
|
|
5
6
|
[index: string]: string;
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
|
-
export declare class TableEditLock extends Plugin<Table> {
|
|
9
|
-
options: Options;
|
|
10
|
-
constructor(table: Table, options?: Partial<Options>);
|
|
9
|
+
export declare class TableEditLock extends Plugin<Table, Options> {
|
|
11
10
|
colCell(cell: HTMLTableCellElement): HTMLTableCellElement | HTMLTableColElement;
|
|
12
11
|
closestEditableCell(editable?: HTMLTableCellElement): HTMLTableCellElement | undefined;
|
|
13
|
-
|
|
12
|
+
defaultOptions(): Options;
|
|
13
|
+
init(): void;
|
|
14
14
|
}
|
|
15
15
|
export {};
|
package/edit/lock.js
CHANGED
|
@@ -1,19 +1,12 @@
|
|
|
1
1
|
import { Plugin } from '../../plugin/plugin.js';
|
|
2
|
-
|
|
2
|
+
import { PluginOptions } from '../../plugin/plugin.js';
|
|
3
|
+
class Options extends PluginOptions {
|
|
3
4
|
nonEditableConditions = {
|
|
4
5
|
'closest': 'tfoot, thead, [data-lock]',
|
|
5
6
|
'col': '[data-lock]'
|
|
6
7
|
};
|
|
7
8
|
}
|
|
8
9
|
export class TableEditLock extends Plugin {
|
|
9
|
-
options = new Options;
|
|
10
|
-
constructor(table, options = {}) {
|
|
11
|
-
super(table);
|
|
12
|
-
Object.assign(this.options, options);
|
|
13
|
-
const tableEdit = table.plugins.TableEdit;
|
|
14
|
-
const superClosestEditableCell = tableEdit.closestEditableCell;
|
|
15
|
-
tableEdit.closestEditableCell = target => this.closestEditableCell(superClosestEditableCell.call(tableEdit, target));
|
|
16
|
-
}
|
|
17
10
|
colCell(cell) {
|
|
18
11
|
const table = cell.closest('table');
|
|
19
12
|
const position = this.of.cellColumnNumber(cell);
|
|
@@ -61,7 +54,12 @@ export class TableEditLock extends Plugin {
|
|
|
61
54
|
}
|
|
62
55
|
return editable;
|
|
63
56
|
}
|
|
64
|
-
|
|
65
|
-
return new Options;
|
|
57
|
+
defaultOptions() {
|
|
58
|
+
return new Options();
|
|
59
|
+
}
|
|
60
|
+
init() {
|
|
61
|
+
const tableEdit = this.of.plugins.TableEdit;
|
|
62
|
+
const superClosestEditableCell = tableEdit.closestEditableCell;
|
|
63
|
+
tableEdit.closestEditableCell = target => this.closestEditableCell(superClosestEditableCell.call(tableEdit, target));
|
|
66
64
|
}
|
|
67
65
|
}
|
package/edit/move.d.ts
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
3
3
|
import { TableEdit } from '../edit.js';
|
|
4
4
|
import { Table } from '../table.js';
|
|
5
5
|
export declare class TableEditMove extends Plugin<Table> {
|
|
6
6
|
tableEdit: TableEdit;
|
|
7
|
-
|
|
7
|
+
init(): void;
|
|
8
8
|
selectNextColumn(): void;
|
|
9
9
|
selectNextRow(): void;
|
|
10
10
|
selectPreviousColumn(): void;
|
package/edit/move.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { Plugin } from '../../plugin/plugin.js';
|
|
2
2
|
export class TableEditMove extends Plugin {
|
|
3
3
|
tableEdit;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
this.tableEdit = table.plugins.TableEdit;
|
|
4
|
+
init() {
|
|
5
|
+
this.tableEdit = this.of.plugins.TableEdit;
|
|
7
6
|
const superCreateEditable = this.tableEdit.createEditable;
|
|
8
7
|
this.tableEdit.createEditable = (selected, selectedStyle) => this.setEditableKeydownListener(superCreateEditable.call(this.tableEdit, selected, selectedStyle));
|
|
9
8
|
}
|
package/edit-freeze/hide.d.ts
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
3
3
|
import { TableEdit } from '../edit.js';
|
|
4
4
|
import { TableFreeze } from '../freeze.js';
|
|
5
5
|
import { Table } from '../table.js';
|
|
6
6
|
export declare class TableEditFreezeHide extends Plugin<Table> {
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
tableFreeze: TableFreeze;
|
|
8
|
+
tableEdit: TableEdit;
|
|
9
|
+
init(): void;
|
|
10
10
|
addEditableEventListeners(editable: HTMLEditableElement): HTMLEditableElement;
|
|
11
11
|
autoHide(): void;
|
|
12
12
|
goAhead(): void;
|
package/edit-freeze/hide.js
CHANGED
|
@@ -7,17 +7,16 @@ const zIndex = {
|
|
|
7
7
|
export class TableEditFreezeHide extends Plugin {
|
|
8
8
|
tableFreeze;
|
|
9
9
|
tableEdit;
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
const
|
|
13
|
-
const
|
|
14
|
-
const scrollable = this.tableFreeze.closestScrollable(table.element);
|
|
10
|
+
init() {
|
|
11
|
+
const tableEdit = this.tableEdit = this.of.plugins.TableEdit;
|
|
12
|
+
const tableFreeze = this.tableFreeze = this.of.plugins.TableFreeze;
|
|
13
|
+
const scrollable = this.tableFreeze.closestScrollable(this.of.element);
|
|
15
14
|
if (!scrollable)
|
|
16
15
|
return;
|
|
17
16
|
tableFreeze.full = { column: '2', corner: '6', row: '4' };
|
|
18
17
|
tableEdit.zIndex = '7';
|
|
19
|
-
|
|
20
|
-
|
|
18
|
+
this.of.addEventListener(scrollable, 'scroll', () => this.autoHide());
|
|
19
|
+
this.of.addEventListener(window, 'resize', () => this.autoHide());
|
|
21
20
|
const superCreateEditable = tableEdit.createEditable;
|
|
22
21
|
tableEdit.createEditable = (selected, selectedStyle) => this.addEditableEventListeners(superCreateEditable.call(tableEdit, selected, selectedStyle));
|
|
23
22
|
}
|
package/edit-freeze/scroll.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
2
2
|
import { TableFreeze } from '../freeze.js';
|
|
3
3
|
import { Table } from '../table.js';
|
|
4
4
|
export declare class TableEditFreezeScroll extends Plugin<Table> {
|
|
5
5
|
tableFreeze: TableFreeze;
|
|
6
|
-
|
|
6
|
+
init(): void;
|
|
7
7
|
scrollToCell(cell: HTMLTableCellElement): HTMLTableCellElement;
|
|
8
8
|
}
|
package/edit-freeze/scroll.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
1
|
import { Plugin } from '../../plugin/plugin.js';
|
|
2
2
|
export class TableEditFreezeScroll extends Plugin {
|
|
3
3
|
tableFreeze;
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
const tableEdit = table.plugins.TableEdit;
|
|
4
|
+
init() {
|
|
5
|
+
this.tableFreeze = this.of.plugins.TableFreeze;
|
|
6
|
+
const tableEdit = this.of.plugins.TableEdit;
|
|
8
7
|
const superSetSelectedCell = tableEdit.setSelectedCell;
|
|
9
8
|
tableEdit.setSelectedCell = cell => superSetSelectedCell.call(tableEdit, this.scrollToCell(cell));
|
|
10
9
|
}
|
package/edit.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HTMLEditableElement } from '
|
|
2
|
-
import { Plugin } from '
|
|
1
|
+
import { HTMLEditableElement } from '../contenteditable/contenteditable.js';
|
|
2
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
3
3
|
import { Table } from './table.js';
|
|
4
4
|
export declare class RangeCopy {
|
|
5
5
|
commonAncestorContainer: Node;
|
package/feed.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
2
2
|
import { Table } from './table.js';
|
|
3
3
|
export declare class TableFeed extends Plugin<Table> {
|
|
4
4
|
observer: IntersectionObserver | undefined;
|
|
5
|
-
constructor(table: Table);
|
|
6
5
|
feed(): Promise<void>;
|
|
6
|
+
init(): void;
|
|
7
7
|
observe(): void;
|
|
8
8
|
}
|
package/feed.js
CHANGED
|
@@ -1,10 +1,6 @@
|
|
|
1
1
|
import { Plugin } from '../plugin/plugin.js';
|
|
2
2
|
export class TableFeed extends Plugin {
|
|
3
3
|
observer = undefined;
|
|
4
|
-
constructor(table) {
|
|
5
|
-
super(table);
|
|
6
|
-
this.observe();
|
|
7
|
-
}
|
|
8
4
|
async feed() {
|
|
9
5
|
const table = this.of.element;
|
|
10
6
|
const tbody = table.querySelector(':scope > tbody');
|
|
@@ -25,6 +21,9 @@ export class TableFeed extends Plugin {
|
|
|
25
21
|
}
|
|
26
22
|
this.observe();
|
|
27
23
|
}
|
|
24
|
+
init() {
|
|
25
|
+
this.observe();
|
|
26
|
+
}
|
|
28
27
|
observe() {
|
|
29
28
|
const table = this.of.element;
|
|
30
29
|
const lastCell = table.querySelector(':scope > tbody > tr:last-child')
|
|
@@ -1,10 +1,8 @@
|
|
|
1
1
|
import { TableFreeze } from '../freeze.js';
|
|
2
|
-
import { Table } from '../table';
|
|
3
2
|
/**
|
|
4
3
|
* This plugin has no use and no effect if your table has border-collapse: collapse
|
|
5
4
|
*/
|
|
6
5
|
export declare class TableFreezeInheritBackground extends TableFreeze {
|
|
7
6
|
tableStyle: CSSStyleDeclaration;
|
|
8
|
-
constructor(table: Table);
|
|
9
7
|
init(): void;
|
|
10
8
|
}
|
|
@@ -4,11 +4,8 @@ import { TableFreeze } from '../freeze.js';
|
|
|
4
4
|
*/
|
|
5
5
|
export class TableFreezeInheritBackground extends TableFreeze {
|
|
6
6
|
tableStyle;
|
|
7
|
-
constructor(table) {
|
|
8
|
-
super(table);
|
|
9
|
-
this.tableStyle = getComputedStyle(table.element);
|
|
10
|
-
}
|
|
11
7
|
init() {
|
|
8
|
+
this.tableStyle = getComputedStyle(this.of.element);
|
|
12
9
|
if (this.tableStyle.borderCollapse !== 'separate')
|
|
13
10
|
return;
|
|
14
11
|
const table = this.of;
|
|
@@ -1,14 +1,10 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
2
|
-
import { TableFreeze } from '../freeze.js';
|
|
1
|
+
import { Plugin } from '../../plugin/plugin.js';
|
|
3
2
|
import { HTMLTableFreezeElement } from '../freeze.js';
|
|
4
3
|
import { Table } from '../table.js';
|
|
5
4
|
/**
|
|
6
5
|
* This plugin has no use and no effect if your table has border-collapse: separate (default)
|
|
7
6
|
*/
|
|
8
7
|
export declare class TableFreezeInheritBorder extends Plugin<Table> {
|
|
9
|
-
tableStyle: CSSStyleDeclaration;
|
|
10
|
-
tableFreeze: TableFreeze;
|
|
11
|
-
constructor(table: Table);
|
|
12
8
|
init(): void;
|
|
13
9
|
position(position: number, counter: number, colCell: HTMLTableFreezeElement, side: 'bottom' | 'left' | 'right' | 'top'): number;
|
|
14
10
|
}
|
package/freeze/inherit-border.js
CHANGED
|
@@ -3,21 +3,15 @@ import { Plugin } from '../../plugin/plugin.js';
|
|
|
3
3
|
* This plugin has no use and no effect if your table has border-collapse: separate (default)
|
|
4
4
|
*/
|
|
5
5
|
export class TableFreezeInheritBorder extends Plugin {
|
|
6
|
-
tableStyle;
|
|
7
|
-
tableFreeze;
|
|
8
|
-
constructor(table) {
|
|
9
|
-
super(table);
|
|
10
|
-
this.tableFreeze = table.plugins.TableFreeze;
|
|
11
|
-
this.tableStyle = getComputedStyle(table.element);
|
|
12
|
-
if (this.tableStyle.borderCollapse !== 'collapse')
|
|
13
|
-
return;
|
|
14
|
-
const superPosition = this.tableFreeze.position;
|
|
15
|
-
this.tableFreeze.position = (position, counter, colCell, side) => superPosition.call(this.of.plugins.TableFreeze, this.position(position, counter, colCell, side), counter, colCell, side);
|
|
16
|
-
}
|
|
17
6
|
init() {
|
|
18
|
-
|
|
7
|
+
const tableFreeze = this.of.plugins.TableFreeze;
|
|
8
|
+
const tableStyle = getComputedStyle(this.of.element);
|
|
9
|
+
if (tableStyle.borderCollapse !== 'collapse')
|
|
10
|
+
return;
|
|
11
|
+
const superPosition = tableFreeze.position;
|
|
12
|
+
tableFreeze.position = (position, counter, colCell, side) => superPosition.call(this.of.plugins.TableFreeze, this.position(position, counter, colCell, side), counter, colCell, side);
|
|
13
|
+
if (tableStyle.borderCollapse !== 'collapse')
|
|
19
14
|
return;
|
|
20
|
-
const tableFreeze = this.tableFreeze;
|
|
21
15
|
const table = this.of;
|
|
22
16
|
// table
|
|
23
17
|
table.styleSheet.push(`
|
package/freeze.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Plugin } from '
|
|
1
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
2
2
|
import { Table } from './table.js';
|
|
3
3
|
export type HTMLTableFreezeElement = HTMLTableCellElement | HTMLTableColElement;
|
|
4
4
|
interface FullIndex {
|
|
@@ -12,7 +12,6 @@ export declare class TableFreeze extends Plugin<Table> {
|
|
|
12
12
|
leftColumnCount: number;
|
|
13
13
|
rightColumnCount: number;
|
|
14
14
|
zIndex: string;
|
|
15
|
-
constructor(table: Table);
|
|
16
15
|
init(): void;
|
|
17
16
|
closestScrollable(element: Element): HTMLElement | (Window & typeof globalThis) | undefined;
|
|
18
17
|
protected countLeftColumns(): number;
|
package/freeze.js
CHANGED
|
@@ -5,13 +5,10 @@ export class TableFreeze extends Plugin {
|
|
|
5
5
|
leftColumnCount;
|
|
6
6
|
rightColumnCount;
|
|
7
7
|
zIndex = '1';
|
|
8
|
-
|
|
9
|
-
super(table);
|
|
8
|
+
init() {
|
|
10
9
|
this.columns = this.getColumns();
|
|
11
10
|
this.leftColumnCount = this.countLeftColumns();
|
|
12
11
|
this.rightColumnCount = this.countRightColumns();
|
|
13
|
-
}
|
|
14
|
-
init() {
|
|
15
12
|
this.freezeFootRows();
|
|
16
13
|
this.freezeHeadRows();
|
|
17
14
|
this.freezeLeftColumns();
|
package/link.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
2
|
+
import { PluginOptions } from '../plugin/plugin.js';
|
|
3
|
+
import { Table } from './table.js';
|
|
4
|
+
type ValueCallback = (element: Element) => ({
|
|
5
|
+
element: Element;
|
|
6
|
+
value: string;
|
|
7
|
+
} | undefined);
|
|
8
|
+
declare class Options extends PluginOptions {
|
|
9
|
+
call: (url: string) => void;
|
|
10
|
+
href: string | ValueCallback;
|
|
11
|
+
id: string | ValueCallback;
|
|
12
|
+
link: (href: string, id?: string) => string;
|
|
13
|
+
}
|
|
14
|
+
export declare class TableLink extends Plugin<Table, Options> {
|
|
15
|
+
constructor(options?: Partial<Options>);
|
|
16
|
+
defaultOptions(): Options;
|
|
17
|
+
protected getCell(row: HTMLTableRowElement, columnIndex: number): HTMLTableCellElement | undefined;
|
|
18
|
+
protected getCol(columnIndex: number): HTMLElement | undefined;
|
|
19
|
+
protected getHeadCell(columnIndex: number): HTMLElement | undefined;
|
|
20
|
+
protected getHref(target: Element, attribute: string, cell: HTMLTableCellElement, idElement?: Element): {
|
|
21
|
+
element: Element;
|
|
22
|
+
value: string;
|
|
23
|
+
} | undefined;
|
|
24
|
+
protected getId(target: Element, attribute: string): {
|
|
25
|
+
element: Element;
|
|
26
|
+
value: string | null;
|
|
27
|
+
} | undefined;
|
|
28
|
+
init(): void;
|
|
29
|
+
onClick(event: MouseEvent): void;
|
|
30
|
+
}
|
|
31
|
+
export {};
|
package/link.js
ADDED
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { Plugin } from '../plugin/plugin.js';
|
|
2
|
+
import { PluginOptions } from '../plugin/plugin.js';
|
|
3
|
+
class Options extends PluginOptions {
|
|
4
|
+
call = function (url) { window.location.href = url; };
|
|
5
|
+
href = 'data-href';
|
|
6
|
+
id = 'data-id';
|
|
7
|
+
link = function (href, id) {
|
|
8
|
+
return id ? (href + ((href[href.length - 1] === '/') ? '' : '/') + id) : href;
|
|
9
|
+
};
|
|
10
|
+
}
|
|
11
|
+
export class TableLink extends Plugin {
|
|
12
|
+
constructor(options) {
|
|
13
|
+
super(options);
|
|
14
|
+
}
|
|
15
|
+
defaultOptions() {
|
|
16
|
+
return new Options();
|
|
17
|
+
}
|
|
18
|
+
getCell(row, columnIndex) {
|
|
19
|
+
let current = -1;
|
|
20
|
+
for (const cell of Array.from(row.cells)) {
|
|
21
|
+
const start = current + 1;
|
|
22
|
+
const end = start + Math.max(1, cell.colSpan || 1) - 1;
|
|
23
|
+
if (columnIndex >= start && columnIndex <= end) {
|
|
24
|
+
return cell;
|
|
25
|
+
}
|
|
26
|
+
current = end;
|
|
27
|
+
}
|
|
28
|
+
}
|
|
29
|
+
getCol(columnIndex) {
|
|
30
|
+
return this.of.element.querySelector('colgroup')?.querySelectorAll('col')?.[columnIndex];
|
|
31
|
+
}
|
|
32
|
+
getHeadCell(columnIndex) {
|
|
33
|
+
const row = this.of.element.tHead?.rows[0];
|
|
34
|
+
return row ? this.getCell(row, columnIndex) : undefined;
|
|
35
|
+
}
|
|
36
|
+
getHref(target, attribute, cell, idElement) {
|
|
37
|
+
let element = target.closest('[' + attribute + ']') ?? undefined;
|
|
38
|
+
if (element && idElement?.contains(element))
|
|
39
|
+
element = undefined;
|
|
40
|
+
if (!element)
|
|
41
|
+
for (const getFunc of [this.getHeadCell, this.getCol]) {
|
|
42
|
+
element = getFunc.call(this, cell.cellIndex);
|
|
43
|
+
if (element?.hasAttribute(attribute))
|
|
44
|
+
break;
|
|
45
|
+
}
|
|
46
|
+
if (element)
|
|
47
|
+
return { element, value: element.getAttribute(attribute) ?? '' };
|
|
48
|
+
}
|
|
49
|
+
getId(target, attribute) {
|
|
50
|
+
const element = target.closest('[' + attribute + ']');
|
|
51
|
+
if (element)
|
|
52
|
+
return { element, value: element.getAttribute(attribute) };
|
|
53
|
+
}
|
|
54
|
+
init() {
|
|
55
|
+
for (const tBody of Array.from(this.of.element.tBodies)) {
|
|
56
|
+
tBody.addEventListener('click', event => this.onClick(event));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
onClick(event) {
|
|
60
|
+
const target = event.target;
|
|
61
|
+
if (!(target instanceof Element))
|
|
62
|
+
return;
|
|
63
|
+
const cell = target.closest('td, th');
|
|
64
|
+
if (!cell || cell.querySelector('input, select, textarea'))
|
|
65
|
+
return;
|
|
66
|
+
const id = (typeof this.options.id === 'function')
|
|
67
|
+
? this.options.id.call(this, target)
|
|
68
|
+
: this.getId(target, this.options.id);
|
|
69
|
+
const href = (typeof this.options.href === 'function')
|
|
70
|
+
? this.options.href.call(this, target)
|
|
71
|
+
: this.getHref(target, this.options.href, cell, id?.element);
|
|
72
|
+
if (!href)
|
|
73
|
+
return;
|
|
74
|
+
this.options.call(href.value + (id ? (href.value.endsWith('/') ? '' : '/') + id.value : ''));
|
|
75
|
+
}
|
|
76
|
+
}
|
package/package.json
CHANGED
package/table.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { HasPlugins, Options as PluginOptions } from '
|
|
1
|
+
import { HasPlugins, Options as PluginOptions } from '../plugin/plugin.js';
|
|
2
2
|
export declare function applyStyleSheets(): void;
|
|
3
3
|
export declare function garbageCollector(): void;
|
|
4
4
|
export declare function getTables(): Table[];
|