@apia/table2-controller 4.0.102 → 5.0.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/dist/data/TableController.d.ts +174 -0
- package/dist/data/TableController.d.ts.map +1 -0
- package/dist/data/TableController.js +348 -0
- package/dist/data/TableController.js.map +1 -0
- package/dist/data/body/TableBody.d.ts +16 -0
- package/dist/data/body/TableBody.d.ts.map +1 -0
- package/dist/data/body/TableBody.js +35 -0
- package/dist/data/body/TableBody.js.map +1 -0
- package/dist/data/filter/ComboFilter.d.ts +18 -0
- package/dist/data/filter/ComboFilter.d.ts.map +1 -0
- package/dist/data/filter/ComboFilter.js +32 -0
- package/dist/data/filter/ComboFilter.js.map +1 -0
- package/dist/data/filter/DateFilter.d.ts +7 -0
- package/dist/data/filter/DateFilter.d.ts.map +1 -0
- package/dist/data/filter/DateFilter.js +7 -0
- package/dist/data/filter/DateFilter.js.map +1 -0
- package/dist/data/filter/DateRangeFilter.d.ts +52 -0
- package/dist/data/filter/DateRangeFilter.d.ts.map +1 -0
- package/dist/data/filter/DateRangeFilter.js +208 -0
- package/dist/data/filter/DateRangeFilter.js.map +1 -0
- package/dist/data/filter/DateTimeRangeFilter.d.ts +23 -0
- package/dist/data/filter/DateTimeRangeFilter.d.ts.map +1 -0
- package/dist/data/filter/DateTimeRangeFilter.js +87 -0
- package/dist/data/filter/DateTimeRangeFilter.js.map +1 -0
- package/dist/data/filter/Filter.d.ts +49 -0
- package/dist/data/filter/Filter.d.ts.map +1 -0
- package/dist/data/filter/Filter.js +63 -0
- package/dist/data/filter/Filter.js.map +1 -0
- package/dist/data/head/Column.d.ts +23 -0
- package/dist/data/head/Column.d.ts.map +1 -0
- package/dist/data/head/Column.js +26 -0
- package/dist/data/head/Column.js.map +1 -0
- package/dist/data/head/Columns.d.ts +16 -0
- package/dist/data/head/Columns.d.ts.map +1 -0
- package/dist/data/head/Columns.js +57 -0
- package/dist/data/head/Columns.js.map +1 -0
- package/dist/data/head/Filters.d.ts +20 -0
- package/dist/data/head/Filters.d.ts.map +1 -0
- package/dist/data/head/Filters.js +132 -0
- package/dist/data/head/Filters.js.map +1 -0
- package/dist/data/head/NullFilter.js +25 -0
- package/dist/data/head/NullFilter.js.map +1 -0
- package/dist/data/head/TableHead.d.ts +26 -0
- package/dist/data/head/TableHead.d.ts.map +1 -0
- package/dist/data/head/TableHead.js +59 -0
- package/dist/data/head/TableHead.js.map +1 -0
- package/dist/data/plugins/FocusControllerPlugin/index.d.ts +26 -0
- package/dist/data/plugins/FocusControllerPlugin/index.d.ts.map +1 -0
- package/dist/data/plugins/FocusControllerPlugin/index.js +130 -0
- package/dist/data/plugins/FocusControllerPlugin/index.js.map +1 -0
- package/dist/data/plugins/FocusControllerPlugin/useFocusByClick.js +80 -0
- package/dist/data/plugins/FocusControllerPlugin/useFocusByClick.js.map +1 -0
- package/dist/data/plugins/FocusControllerPlugin/useFocusByKey.js +156 -0
- package/dist/data/plugins/FocusControllerPlugin/useFocusByKey.js.map +1 -0
- package/dist/data/plugins/TablePlugin.d.ts +30 -0
- package/dist/data/plugins/TablePlugin.d.ts.map +1 -0
- package/dist/data/plugins/TablePlugin.js +10 -0
- package/dist/data/plugins/TablePlugin.js.map +1 -0
- package/dist/data/plugins/WaiAriaPlugin.d.ts +42 -0
- package/dist/data/plugins/WaiAriaPlugin.d.ts.map +1 -0
- package/dist/data/plugins/WaiAriaPlugin.js +29 -0
- package/dist/data/plugins/WaiAriaPlugin.js.map +1 -0
- package/dist/data/primitive/AdditionalCell.d.ts +11 -0
- package/dist/data/primitive/AdditionalCell.d.ts.map +1 -0
- package/dist/data/primitive/AdditionalCell.js +38 -0
- package/dist/data/primitive/AdditionalCell.js.map +1 -0
- package/dist/data/primitive/AdditionalRow.d.ts +12 -0
- package/dist/data/primitive/AdditionalRow.d.ts.map +1 -0
- package/dist/data/primitive/AdditionalRow.js +16 -0
- package/dist/data/primitive/AdditionalRow.js.map +1 -0
- package/dist/data/primitive/Cell.d.ts +39 -0
- package/dist/data/primitive/Cell.d.ts.map +1 -0
- package/dist/data/primitive/Cell.js +41 -0
- package/dist/data/primitive/Cell.js.map +1 -0
- package/dist/data/primitive/Element.d.ts +18 -0
- package/dist/data/primitive/Element.d.ts.map +1 -0
- package/dist/data/primitive/Element.js +40 -0
- package/dist/data/primitive/Element.js.map +1 -0
- package/dist/data/primitive/Row.d.ts +58 -0
- package/dist/data/primitive/Row.d.ts.map +1 -0
- package/dist/data/primitive/Row.js +193 -0
- package/dist/data/primitive/Row.js.map +1 -0
- package/dist/data/primitive/RowsGroup.d.ts +29 -0
- package/dist/data/primitive/RowsGroup.d.ts.map +1 -0
- package/dist/data/primitive/RowsGroup.js +86 -0
- package/dist/data/primitive/RowsGroup.js.map +1 -0
- package/dist/index.d.ts +20 -425
- package/dist/index.js +20 -1255
- package/dist/index.js.map +1 -1
- package/package.json +3 -4
- package/LICENSE.md +0 -6
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
import { Cell, CellState } from './primitive/Cell.js';
|
|
2
|
+
import { EventEmitter, TBasicAction, ITableController, ILabelsContainer, TLoadStructure, TSortType } from '@apia/util';
|
|
3
|
+
import { Row } from './primitive/Row.js';
|
|
4
|
+
import { TableBody, TBuildBody } from './body/TableBody.js';
|
|
5
|
+
import { TableHead, TBuildHead } from './head/TableHead.js';
|
|
6
|
+
import { TablePlugin } from './plugins/TablePlugin.js';
|
|
7
|
+
import { Column } from './head/Column.js';
|
|
8
|
+
import { Filter } from './filter/Filter.js';
|
|
9
|
+
import { ReactNode } from 'react';
|
|
10
|
+
|
|
11
|
+
type TableState = {
|
|
12
|
+
allowEdition: boolean;
|
|
13
|
+
allowResize: boolean;
|
|
14
|
+
allowSelection: boolean;
|
|
15
|
+
avoidExecuteFirstRefresh?: boolean;
|
|
16
|
+
customLabel?: string;
|
|
17
|
+
editionMode: boolean;
|
|
18
|
+
fetchRowExpand: boolean;
|
|
19
|
+
focusedCell: Cell | null;
|
|
20
|
+
isSelectionMultiple: boolean;
|
|
21
|
+
onRowExpand?: (row: Row) => Promise<false | ReactNode>;
|
|
22
|
+
plugins: TablePlugin[];
|
|
23
|
+
selection: Set<Row>;
|
|
24
|
+
registersToShow: number | null;
|
|
25
|
+
tableName: string;
|
|
26
|
+
};
|
|
27
|
+
type TBuildTable = TBuildHead & TBuildBody;
|
|
28
|
+
type TableEvents = {
|
|
29
|
+
cellFocus: {
|
|
30
|
+
cell: Cell;
|
|
31
|
+
doFocus: boolean;
|
|
32
|
+
};
|
|
33
|
+
columnSort: Column;
|
|
34
|
+
editionMode: boolean;
|
|
35
|
+
filterChange: Filter<any>;
|
|
36
|
+
filterValueChange: Filter<any>;
|
|
37
|
+
filterPressEnter: Filter<any>;
|
|
38
|
+
filterBlur: Filter<any>;
|
|
39
|
+
keyEnter: null;
|
|
40
|
+
rowDelete: Row;
|
|
41
|
+
scrollIntoRow: Row;
|
|
42
|
+
selectionChange: Row[];
|
|
43
|
+
rowDblClick: {
|
|
44
|
+
action: TBasicAction;
|
|
45
|
+
ev: React.KeyboardEvent | React.MouseEvent;
|
|
46
|
+
};
|
|
47
|
+
rowClick: {
|
|
48
|
+
action: TBasicAction;
|
|
49
|
+
ev: React.KeyboardEvent | React.MouseEvent;
|
|
50
|
+
};
|
|
51
|
+
};
|
|
52
|
+
type TTableEnvironment = {
|
|
53
|
+
labels: ILabelsContainer['labels'];
|
|
54
|
+
getDateFromString?: (str: string, timeFormat?: boolean) => Date | undefined;
|
|
55
|
+
getStringFromDate?: (str: Date, timeFormat?: boolean) => string | undefined;
|
|
56
|
+
};
|
|
57
|
+
declare class TableController extends EventEmitter<TableEvents> implements ITableController {
|
|
58
|
+
context: TTableEnvironment;
|
|
59
|
+
protected state: TableState;
|
|
60
|
+
constructor(context: TTableEnvironment, props?: Partial<Omit<TableState, 'selection'>>);
|
|
61
|
+
body: TableBody;
|
|
62
|
+
head: TableHead;
|
|
63
|
+
/**
|
|
64
|
+
* Clears all data in the table, except for the events
|
|
65
|
+
* listeners and recreates the structure based on the passed data.
|
|
66
|
+
*/
|
|
67
|
+
build(data: TBuildTable): void;
|
|
68
|
+
fromGenericTable(table: TLoadStructure, context?: Required<Pick<TTableEnvironment, 'getDateFromString' | 'getStringFromDate'>>): void;
|
|
69
|
+
getColumn(name: string): Column | undefined;
|
|
70
|
+
getColumns(): Column[];
|
|
71
|
+
getFilter(name: string): Filter<any> | undefined;
|
|
72
|
+
getFilters(): Filter<any>[];
|
|
73
|
+
getRowById(id: string | number): Row | undefined;
|
|
74
|
+
hasAdditionalContent(): boolean | ((row: Row) => Promise<false | ReactNode>);
|
|
75
|
+
static readonly RENDER_ADDITIONAL_CELLS_CONTENT: Readonly<{}>;
|
|
76
|
+
onRowExpand(row: Row): Promise<Readonly<{}> | null | undefined>;
|
|
77
|
+
/**
|
|
78
|
+
* EDITION MODE
|
|
79
|
+
*/
|
|
80
|
+
get isEditionMode(): boolean;
|
|
81
|
+
toggleEditionMode(force?: boolean): void;
|
|
82
|
+
changeAmountOfRegisters(amount: number): void;
|
|
83
|
+
/**
|
|
84
|
+
* SELECTION
|
|
85
|
+
*/
|
|
86
|
+
clearSelection(): void;
|
|
87
|
+
/**
|
|
88
|
+
* Returns the selected rows.
|
|
89
|
+
*/
|
|
90
|
+
getSelectedRows(): Row[];
|
|
91
|
+
isSelected(row: Row): boolean;
|
|
92
|
+
shoutSelection(): void;
|
|
93
|
+
toggleColumnVisibility(colName: string, isVisible?: boolean): void;
|
|
94
|
+
toggleFiltersRowVisibility(): void;
|
|
95
|
+
/**
|
|
96
|
+
* Toggles the selection state of a given row.
|
|
97
|
+
*
|
|
98
|
+
* If the `isSelected` parameter is provided, it explicitly sets the selection
|
|
99
|
+
* state of the row to the given value (`true` for selected, `false` for deselected).
|
|
100
|
+
* If `isSelected` is not provided, the method will toggle the current selection state
|
|
101
|
+
* of the row (i.e., select it if it's currently not selected, or deselect it if it is).
|
|
102
|
+
*
|
|
103
|
+
* @param row - The row to toggle selection for.
|
|
104
|
+
* @param isSelected - Optional. A boolean indicating whether the row should be selected (`true`)
|
|
105
|
+
* or deselected (`false`). If not provided, the selection state will be toggled.
|
|
106
|
+
*/
|
|
107
|
+
toggleRowSelection(row: Row, isSelected?: boolean, fireEvent?: boolean): void;
|
|
108
|
+
protected restoreFocus(): void;
|
|
109
|
+
removeRow(row: Row): void;
|
|
110
|
+
/**
|
|
111
|
+
* FOCUS
|
|
112
|
+
*/
|
|
113
|
+
/**
|
|
114
|
+
* @returns The currently focused cell in the table.
|
|
115
|
+
*/
|
|
116
|
+
getFocusedCell(): Cell<CellState<any>> | null;
|
|
117
|
+
setFocusedCell(cell: Cell, doFocus?: boolean): void;
|
|
118
|
+
setSelection(indices: number[]): void;
|
|
119
|
+
scrollRowIntoView(row: Row): void;
|
|
120
|
+
/**
|
|
121
|
+
* STATE
|
|
122
|
+
*/
|
|
123
|
+
/**
|
|
124
|
+
* Returns the current state of the `TableController` instance.
|
|
125
|
+
*
|
|
126
|
+
* @param prop - The property of the state to retrieve.
|
|
127
|
+
*/
|
|
128
|
+
getState<K extends keyof TableState>(prop: K): TableState[K];
|
|
129
|
+
/**
|
|
130
|
+
* Updates the state of the `TableController` instance.
|
|
131
|
+
*
|
|
132
|
+
* This method provides two overloads:
|
|
133
|
+
* 1. A callback function that takes the current state and returns a new state.
|
|
134
|
+
* 2. A key-value pair where the key is a property of the state, and the value is the new value for that property.
|
|
135
|
+
*
|
|
136
|
+
* @param prop - Either a callback function to update the state or the key of the state property to update.
|
|
137
|
+
* @param value - (Optional) The new value for the specified state property. This is required if `prop` is a key.
|
|
138
|
+
*
|
|
139
|
+
* @returns The `TableController` instance for method chaining.
|
|
140
|
+
*
|
|
141
|
+
* ### Usage:
|
|
142
|
+
*
|
|
143
|
+
* **Using a callback function:**
|
|
144
|
+
* ```tsx
|
|
145
|
+
* tableController.setState((state) => ({
|
|
146
|
+
* ...state,
|
|
147
|
+
* allowEdition: false,
|
|
148
|
+
* }));
|
|
149
|
+
* ```
|
|
150
|
+
*
|
|
151
|
+
* **Using a key-value pair:**
|
|
152
|
+
* ```tsx
|
|
153
|
+
* tableController.setState('allowEdition', false);
|
|
154
|
+
* ```
|
|
155
|
+
*/
|
|
156
|
+
setState(cb: (s: TableState) => TableState): this;
|
|
157
|
+
setState<K extends keyof TableState>(prop: K, value: TableState[K]): this;
|
|
158
|
+
sortColumn(col: Column, sortState?: TSortType): void;
|
|
159
|
+
/**
|
|
160
|
+
* PLUGINS
|
|
161
|
+
*/
|
|
162
|
+
getPluginOfType<T extends TablePlugin>(clazz: new (...args: any[]) => T): T | undefined;
|
|
163
|
+
/**
|
|
164
|
+
* Sets the plugins for the table.
|
|
165
|
+
*/
|
|
166
|
+
setPlugins(cb: (currentPlugins: TablePlugin[]) => TablePlugin[]): void;
|
|
167
|
+
getApplicablePlugins<K extends keyof TablePlugin>(method: K): ((...args: Parameters<NonNullable<TablePlugin[K]>> extends [
|
|
168
|
+
any,
|
|
169
|
+
...infer Rest
|
|
170
|
+
] ? Rest : void[]) => ReturnType<NonNullable<TablePlugin[K]>>)[];
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
export { type TBuildTable, type TTableEnvironment, TableController, type TableEvents, type TableState };
|
|
174
|
+
//# sourceMappingURL=TableController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableController.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,348 @@
|
|
|
1
|
+
import { EventEmitter, arrayOrArray } from '@apia/util';
|
|
2
|
+
import { TableBody } from './body/TableBody.js';
|
|
3
|
+
import { TableHead } from './head/TableHead.js';
|
|
4
|
+
import { makeObservable, observable, action, computed } from 'mobx';
|
|
5
|
+
import { defaultPlugins } from './plugins/TablePlugin.js';
|
|
6
|
+
|
|
7
|
+
var __defProp = Object.defineProperty;
|
|
8
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
9
|
+
var __publicField = (obj, key, value) => {
|
|
10
|
+
__defNormalProp(obj, typeof key !== "symbol" ? key + "" : key, value);
|
|
11
|
+
return value;
|
|
12
|
+
};
|
|
13
|
+
const _TableController = class _TableController extends EventEmitter {
|
|
14
|
+
constructor(context, props) {
|
|
15
|
+
super();
|
|
16
|
+
this.context = context;
|
|
17
|
+
__publicField(this, "state", {
|
|
18
|
+
allowEdition: true,
|
|
19
|
+
allowResize: true,
|
|
20
|
+
allowSelection: true,
|
|
21
|
+
editionMode: false,
|
|
22
|
+
fetchRowExpand: false,
|
|
23
|
+
focusedCell: null,
|
|
24
|
+
plugins: [],
|
|
25
|
+
isSelectionMultiple: true,
|
|
26
|
+
selection: /* @__PURE__ */ new Set(),
|
|
27
|
+
registersToShow: null,
|
|
28
|
+
tableName: ""
|
|
29
|
+
});
|
|
30
|
+
__publicField(this, "body", new TableBody(this));
|
|
31
|
+
__publicField(this, "head", new TableHead(this));
|
|
32
|
+
Object.assign(this.state, props || {});
|
|
33
|
+
if (!props?.plugins) {
|
|
34
|
+
this.state.plugins.push(...defaultPlugins());
|
|
35
|
+
}
|
|
36
|
+
makeObservable(this, {
|
|
37
|
+
build: action,
|
|
38
|
+
clearSelection: action,
|
|
39
|
+
fromGenericTable: action,
|
|
40
|
+
isEditionMode: computed,
|
|
41
|
+
setState: action,
|
|
42
|
+
setFocusedCell: action,
|
|
43
|
+
state: observable,
|
|
44
|
+
toggleRowSelection: action,
|
|
45
|
+
toggleEditionMode: action,
|
|
46
|
+
head: observable,
|
|
47
|
+
body: observable
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Clears all data in the table, except for the events
|
|
52
|
+
* listeners and recreates the structure based on the passed data.
|
|
53
|
+
*/
|
|
54
|
+
build(data) {
|
|
55
|
+
this.head.build(data);
|
|
56
|
+
this.body.build(data);
|
|
57
|
+
this.restoreFocus();
|
|
58
|
+
this.shoutSelection();
|
|
59
|
+
}
|
|
60
|
+
fromGenericTable(table, context) {
|
|
61
|
+
if (context) {
|
|
62
|
+
Object.assign(this.context, context);
|
|
63
|
+
}
|
|
64
|
+
this.setState("allowEdition", table.behavior.allowEdition);
|
|
65
|
+
this.setState("allowSelection", table.behavior.allowSelection);
|
|
66
|
+
this.setState("isSelectionMultiple", table.behavior.isMultipleSelection);
|
|
67
|
+
this.setState("fetchRowExpand", !!table.behavior.fetchRowExpand);
|
|
68
|
+
const columns = arrayOrArray(table.columns);
|
|
69
|
+
this.build({
|
|
70
|
+
columns: columns.map(({ attributes, ...c }) => {
|
|
71
|
+
return {
|
|
72
|
+
...c,
|
|
73
|
+
adjustWidthToTitle: c.adjustWidthToTitle,
|
|
74
|
+
colName: c.name,
|
|
75
|
+
asAdditional: c.showAsAdditional,
|
|
76
|
+
sortable: c.isSortable,
|
|
77
|
+
isHidden: c.isHidden,
|
|
78
|
+
properties: c,
|
|
79
|
+
content: c.title,
|
|
80
|
+
className: c.className,
|
|
81
|
+
sortState: c.sortType,
|
|
82
|
+
showInAccordionTitle: c.showInAccordionTitle,
|
|
83
|
+
domProperties: {
|
|
84
|
+
style: {
|
|
85
|
+
width: c.width
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
}),
|
|
90
|
+
filters: arrayOrArray(table.filters).map(({ attributes, ...f }) => {
|
|
91
|
+
return {
|
|
92
|
+
...f,
|
|
93
|
+
name: f.name,
|
|
94
|
+
title: f.title,
|
|
95
|
+
tooltip: "no tooltip",
|
|
96
|
+
type: f.type,
|
|
97
|
+
isRequired: f.isRequired,
|
|
98
|
+
properties: f,
|
|
99
|
+
runAutomatically: f.runAutomatically,
|
|
100
|
+
columnName: f.columnName,
|
|
101
|
+
value: f.initialValue,
|
|
102
|
+
asAdditional: f.asAdditional,
|
|
103
|
+
showAsInteger: attributes?.showAsInteger === true
|
|
104
|
+
};
|
|
105
|
+
}),
|
|
106
|
+
rows: arrayOrArray(table.rows).map(({ attributes, ...row }) => {
|
|
107
|
+
const onDoubleClickEvent = (ev) => {
|
|
108
|
+
if (ev.type === "dblclick" && row.action.actionSource === "DOUBLE_CLICK") {
|
|
109
|
+
this.emit("rowDblClick", {
|
|
110
|
+
action: {
|
|
111
|
+
...row.action,
|
|
112
|
+
action: attributes.openUrl
|
|
113
|
+
},
|
|
114
|
+
ev
|
|
115
|
+
});
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
const onClickEvent = (ev) => {
|
|
119
|
+
if (ev.type === "click" && row.action.actionSource === "CLICK") {
|
|
120
|
+
this.emit("rowClick", {
|
|
121
|
+
action: {
|
|
122
|
+
...row.action,
|
|
123
|
+
action: attributes.openUrl
|
|
124
|
+
},
|
|
125
|
+
ev
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
};
|
|
129
|
+
const returnValue = {
|
|
130
|
+
id: row.id,
|
|
131
|
+
cells: arrayOrArray(row.cells).map((cell) => {
|
|
132
|
+
const returnValue2 = {
|
|
133
|
+
content: cell.text,
|
|
134
|
+
isHtml: cell.isHtml,
|
|
135
|
+
documentUrl: cell.documentUrl,
|
|
136
|
+
isDocument: cell.isDocument,
|
|
137
|
+
Renderer: cell.Renderer,
|
|
138
|
+
className: cell.className
|
|
139
|
+
};
|
|
140
|
+
return returnValue2;
|
|
141
|
+
}),
|
|
142
|
+
isExpandible: false,
|
|
143
|
+
isSelectable: !row.isDisabled,
|
|
144
|
+
isSelected: row.isSelected,
|
|
145
|
+
isDisabled: row.isDisabled,
|
|
146
|
+
domProperties: {
|
|
147
|
+
onDoubleClick: (ev) => onDoubleClickEvent(ev),
|
|
148
|
+
onClick: (ev) => onClickEvent(ev),
|
|
149
|
+
className: row.isDisabled ? "locked non-selectable" : ""
|
|
150
|
+
},
|
|
151
|
+
properties: row
|
|
152
|
+
};
|
|
153
|
+
return returnValue;
|
|
154
|
+
})
|
|
155
|
+
});
|
|
156
|
+
}
|
|
157
|
+
getColumn(name) {
|
|
158
|
+
return this.head.getColumns()?.getColumn(name);
|
|
159
|
+
}
|
|
160
|
+
getColumns() {
|
|
161
|
+
return [...this.head.getColumns()?.columns.values() || []];
|
|
162
|
+
}
|
|
163
|
+
getFilter(name) {
|
|
164
|
+
return this.head.getFilters()?.get(name);
|
|
165
|
+
}
|
|
166
|
+
getFilters() {
|
|
167
|
+
return [...this.head.getFilters()?.getAll() || []];
|
|
168
|
+
}
|
|
169
|
+
getRowById(id) {
|
|
170
|
+
return this.head.getRowById(id) || this.body.getRowById(id);
|
|
171
|
+
}
|
|
172
|
+
hasAdditionalContent() {
|
|
173
|
+
return !!this.head.getHeaderRow()?.getColumns().find((c) => c.asAdditional) || this.getState("onRowExpand") || this.getState("fetchRowExpand");
|
|
174
|
+
}
|
|
175
|
+
async onRowExpand(row) {
|
|
176
|
+
const onExpand = this.getState("onRowExpand");
|
|
177
|
+
if (onExpand) {
|
|
178
|
+
return onExpand(row);
|
|
179
|
+
}
|
|
180
|
+
return _TableController.RENDER_ADDITIONAL_CELLS_CONTENT;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* EDITION MODE
|
|
184
|
+
*/
|
|
185
|
+
get isEditionMode() {
|
|
186
|
+
return this.state.editionMode;
|
|
187
|
+
}
|
|
188
|
+
toggleEditionMode(force) {
|
|
189
|
+
if (this.state.allowEdition) {
|
|
190
|
+
this.state.editionMode = force ?? !this.state.editionMode;
|
|
191
|
+
this.emit("editionMode", this.state.editionMode);
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
changeAmountOfRegisters(amount) {
|
|
195
|
+
this.state.registersToShow = amount;
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* SELECTION
|
|
199
|
+
*/
|
|
200
|
+
clearSelection() {
|
|
201
|
+
this.state.selection.clear();
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Returns the selected rows.
|
|
205
|
+
*/
|
|
206
|
+
getSelectedRows() {
|
|
207
|
+
return [...this.state.selection];
|
|
208
|
+
}
|
|
209
|
+
isSelected(row) {
|
|
210
|
+
return this.state.selection.has(row);
|
|
211
|
+
}
|
|
212
|
+
shoutSelection() {
|
|
213
|
+
this.emit("selectionChange", [...this.state.selection]);
|
|
214
|
+
}
|
|
215
|
+
toggleColumnVisibility(colName, isVisible) {
|
|
216
|
+
isVisible = isVisible ?? this.head.getHeaderRow()?.getColumn(colName).getState("isHidden");
|
|
217
|
+
if (this.head.getHeaderRow()) {
|
|
218
|
+
this.head.getHeaderRow()?.getColumn(colName).setState("isHidden", isVisible);
|
|
219
|
+
} else {
|
|
220
|
+
this.head.rows[0]?.cells?.find((c) => c.getState("colName") === colName)?.setState("isHidden", !isVisible);
|
|
221
|
+
}
|
|
222
|
+
}
|
|
223
|
+
toggleFiltersRowVisibility() {
|
|
224
|
+
this.head.getFiltersRow()?.setState("isHidden", !this.head.getFiltersRow()?.getState("isHidden"));
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* Toggles the selection state of a given row.
|
|
228
|
+
*
|
|
229
|
+
* If the `isSelected` parameter is provided, it explicitly sets the selection
|
|
230
|
+
* state of the row to the given value (`true` for selected, `false` for deselected).
|
|
231
|
+
* If `isSelected` is not provided, the method will toggle the current selection state
|
|
232
|
+
* of the row (i.e., select it if it's currently not selected, or deselect it if it is).
|
|
233
|
+
*
|
|
234
|
+
* @param row - The row to toggle selection for.
|
|
235
|
+
* @param isSelected - Optional. A boolean indicating whether the row should be selected (`true`)
|
|
236
|
+
* or deselected (`false`). If not provided, the selection state will be toggled.
|
|
237
|
+
*/
|
|
238
|
+
toggleRowSelection(row, isSelected, fireEvent = true) {
|
|
239
|
+
if (this.state.allowSelection) {
|
|
240
|
+
isSelected = isSelected ?? !this.state.selection.has(row);
|
|
241
|
+
if (isSelected) {
|
|
242
|
+
if (row.getState("isSelectable") !== false) {
|
|
243
|
+
this.state.selection.add(row);
|
|
244
|
+
}
|
|
245
|
+
} else {
|
|
246
|
+
this.state.selection.delete(row);
|
|
247
|
+
}
|
|
248
|
+
if (fireEvent) {
|
|
249
|
+
this.shoutSelection();
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
restoreFocus() {
|
|
254
|
+
if (!this.state.focusedCell || this.state.focusedCell.getTable() !== this) {
|
|
255
|
+
this.state.focusedCell = this.body.getState("rows").values().next().value?.cells[0] || this.head.getState("rows").values().next().value?.cells[0] || null;
|
|
256
|
+
}
|
|
257
|
+
if (this.state.focusedCell) {
|
|
258
|
+
this.emit("cellFocus", { cell: this.state.focusedCell, doFocus: false });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
removeRow(row) {
|
|
262
|
+
if (row.getTable() === this) {
|
|
263
|
+
row.setTable(null);
|
|
264
|
+
this.head.removeRow(row);
|
|
265
|
+
this.body.removeRow(row);
|
|
266
|
+
if (this.state.selection.has(row)) {
|
|
267
|
+
this.state.selection.delete(row);
|
|
268
|
+
this.shoutSelection();
|
|
269
|
+
}
|
|
270
|
+
if (this.state.focusedCell?.getRow() === row) {
|
|
271
|
+
this.restoreFocus();
|
|
272
|
+
}
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
/**
|
|
276
|
+
* FOCUS
|
|
277
|
+
*/
|
|
278
|
+
/**
|
|
279
|
+
* @returns The currently focused cell in the table.
|
|
280
|
+
*/
|
|
281
|
+
getFocusedCell() {
|
|
282
|
+
return this.state.focusedCell;
|
|
283
|
+
}
|
|
284
|
+
setFocusedCell(cell, doFocus = true) {
|
|
285
|
+
this.state.focusedCell = cell;
|
|
286
|
+
this.emit("cellFocus", { cell, doFocus });
|
|
287
|
+
}
|
|
288
|
+
setSelection(indices) {
|
|
289
|
+
this.clearSelection();
|
|
290
|
+
indices.forEach((index) => {
|
|
291
|
+
const row = this.body.getRowByIndex(index);
|
|
292
|
+
if (row) {
|
|
293
|
+
this.toggleRowSelection(row, true, false);
|
|
294
|
+
}
|
|
295
|
+
});
|
|
296
|
+
}
|
|
297
|
+
scrollRowIntoView(row) {
|
|
298
|
+
this.emit("scrollIntoRow", row);
|
|
299
|
+
}
|
|
300
|
+
/**
|
|
301
|
+
* STATE
|
|
302
|
+
*/
|
|
303
|
+
/**
|
|
304
|
+
* Returns the current state of the `TableController` instance.
|
|
305
|
+
*
|
|
306
|
+
* @param prop - The property of the state to retrieve.
|
|
307
|
+
*/
|
|
308
|
+
getState(prop) {
|
|
309
|
+
return this.state[prop];
|
|
310
|
+
}
|
|
311
|
+
setState(prop, value) {
|
|
312
|
+
if (typeof prop === "function") {
|
|
313
|
+
this.state = prop(this.state);
|
|
314
|
+
} else {
|
|
315
|
+
this.state[prop] = value;
|
|
316
|
+
}
|
|
317
|
+
return this;
|
|
318
|
+
}
|
|
319
|
+
sortColumn(col, sortState) {
|
|
320
|
+
this.getColumns().forEach((c) => {
|
|
321
|
+
if (c.getColumnName() !== col.getColumnName()) {
|
|
322
|
+
c.sort("NONE");
|
|
323
|
+
}
|
|
324
|
+
});
|
|
325
|
+
col.sort(sortState);
|
|
326
|
+
this.emit("columnSort", col);
|
|
327
|
+
}
|
|
328
|
+
/**
|
|
329
|
+
* PLUGINS
|
|
330
|
+
*/
|
|
331
|
+
getPluginOfType(clazz) {
|
|
332
|
+
return this.state.plugins.find((plugin) => plugin instanceof clazz);
|
|
333
|
+
}
|
|
334
|
+
/**
|
|
335
|
+
* Sets the plugins for the table.
|
|
336
|
+
*/
|
|
337
|
+
setPlugins(cb) {
|
|
338
|
+
this.state.plugins = cb(this.state.plugins);
|
|
339
|
+
}
|
|
340
|
+
getApplicablePlugins(method) {
|
|
341
|
+
return this.state.plugins.filter((c) => c[method] !== void 0).map((c) => c[method].bind(c, this));
|
|
342
|
+
}
|
|
343
|
+
};
|
|
344
|
+
__publicField(_TableController, "RENDER_ADDITIONAL_CELLS_CONTENT", Object.freeze({}));
|
|
345
|
+
let TableController = _TableController;
|
|
346
|
+
|
|
347
|
+
export { TableController };
|
|
348
|
+
//# sourceMappingURL=TableController.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableController.js","sources":["../../src/data/TableController.ts"],"sourcesContent":["import {\r\n arrayOrArray,\r\n EventEmitter,\r\n ILabelsContainer,\r\n ITableController,\r\n TBasicAction,\r\n TLoadStructure,\r\n TSortType,\r\n} from '@apia/util';\r\nimport type { Cell } from './primitive/Cell';\r\nimport type { Row } from './primitive/Row';\r\nimport { TableBody, type TBuildBody } from './body/TableBody';\r\nimport { TableHead, type TBuildHead } from './head/TableHead';\r\nimport { action, computed, makeObservable, observable } from 'mobx';\r\nimport { defaultPlugins, type TablePlugin } from './plugins/TablePlugin';\r\nimport type { Column } from './head/Column';\r\nimport type { Filter } from './filter/Filter';\r\nimport type { MouseEventHandler, ReactNode } from 'react';\r\n\r\nexport type TableState = {\r\n allowEdition: boolean;\r\n allowResize: boolean;\r\n allowSelection: boolean;\r\n avoidExecuteFirstRefresh?: boolean;\r\n customLabel?: string;\r\n editionMode: boolean;\r\n fetchRowExpand: boolean;\r\n focusedCell: Cell | null;\r\n isSelectionMultiple: boolean;\r\n onRowExpand?: (row: Row) => Promise<false | ReactNode>;\r\n plugins: TablePlugin[];\r\n selection: Set<Row>;\r\n registersToShow: number | null;\r\n tableName: string;\r\n};\r\n\r\nexport type TBuildTable = TBuildHead & TBuildBody;\r\n\r\nexport type TableEvents = {\r\n cellFocus: { cell: Cell; doFocus: boolean };\r\n columnSort: Column;\r\n editionMode: boolean;\r\n filterChange: Filter<any>;\r\n filterValueChange: Filter<any>;\r\n filterPressEnter: Filter<any>;\r\n filterBlur: Filter<any>;\r\n keyEnter: null;\r\n rowDelete: Row;\r\n scrollIntoRow: Row;\r\n selectionChange: Row[];\r\n rowDblClick: {\r\n action: TBasicAction;\r\n ev: React.KeyboardEvent | React.MouseEvent;\r\n };\r\n\r\n rowClick: {\r\n action: TBasicAction;\r\n ev: React.KeyboardEvent | React.MouseEvent;\r\n };\r\n};\r\n\r\nexport type TTableEnvironment = {\r\n labels: ILabelsContainer['labels'];\r\n getDateFromString?: (str: string, timeFormat?: boolean) => Date | undefined;\r\n getStringFromDate?: (str: Date, timeFormat?: boolean) => string | undefined;\r\n};\r\n\r\nexport class TableController\r\n extends EventEmitter<TableEvents>\r\n implements ITableController\r\n{\r\n protected state: TableState = {\r\n allowEdition: true,\r\n allowResize: true,\r\n allowSelection: true,\r\n editionMode: false,\r\n fetchRowExpand: false,\r\n focusedCell: null,\r\n plugins: [],\r\n isSelectionMultiple: true,\r\n selection: new Set(),\r\n registersToShow: null,\r\n tableName: '',\r\n };\r\n\r\n constructor(\r\n public context: TTableEnvironment,\r\n props?: Partial<Omit<TableState, 'selection'>>,\r\n ) {\r\n super();\r\n Object.assign(this.state, props || {});\r\n if (!props?.plugins) {\r\n this.state.plugins.push(...defaultPlugins());\r\n }\r\n makeObservable<TableController, 'state'>(this, {\r\n build: action,\r\n clearSelection: action,\r\n fromGenericTable: action,\r\n isEditionMode: computed,\r\n setState: action,\r\n setFocusedCell: action,\r\n state: observable,\r\n toggleRowSelection: action,\r\n toggleEditionMode: action,\r\n head: observable,\r\n body: observable,\r\n });\r\n }\r\n\r\n public body = new TableBody(this);\r\n public head = new TableHead(this);\r\n\r\n /**\r\n * Clears all data in the table, except for the events\r\n * listeners and recreates the structure based on the passed data.\r\n */\r\n public build(data: TBuildTable) {\r\n this.head.build(data);\r\n this.body.build(data);\r\n\r\n this.restoreFocus();\r\n this.shoutSelection();\r\n }\r\n\r\n public fromGenericTable(\r\n table: TLoadStructure,\r\n context?: Required<\r\n Pick<TTableEnvironment, 'getDateFromString' | 'getStringFromDate'>\r\n >,\r\n ) {\r\n if (context) {\r\n Object.assign(this.context, context);\r\n }\r\n\r\n this.setState('allowEdition', table.behavior.allowEdition);\r\n this.setState('allowSelection', table.behavior.allowSelection);\r\n this.setState('isSelectionMultiple', table.behavior.isMultipleSelection);\r\n this.setState('fetchRowExpand', !!table.behavior.fetchRowExpand);\r\n const columns = arrayOrArray(table.columns);\r\n\r\n this.build({\r\n columns: columns.map(({ attributes, ...c }) => {\r\n return {\r\n ...c,\r\n adjustWidthToTitle: c.adjustWidthToTitle,\r\n colName: c.name,\r\n asAdditional: c.showAsAdditional,\r\n sortable: c.isSortable,\r\n isHidden: c.isHidden,\r\n properties: c,\r\n content: c.title,\r\n className: c.className,\r\n sortState: c.sortType,\r\n showInAccordionTitle: c.showInAccordionTitle,\r\n domProperties: {\r\n style: {\r\n width: c.width,\r\n },\r\n },\r\n };\r\n }),\r\n filters: arrayOrArray(table.filters).map(({ attributes, ...f }) => {\r\n return {\r\n ...f,\r\n name: f.name,\r\n title: f.title,\r\n tooltip: 'no tooltip',\r\n type: f.type,\r\n isRequired: f.isRequired,\r\n properties: f,\r\n runAutomatically: f.runAutomatically,\r\n columnName: f.columnName,\r\n value: f.initialValue,\r\n asAdditional: f.asAdditional,\r\n showAsInteger: attributes?.showAsInteger === true,\r\n };\r\n }),\r\n rows: arrayOrArray(table.rows).map(({ attributes, ...row }) => {\r\n const onDoubleClickEvent: MouseEventHandler<HTMLTableRowElement> = (\r\n ev,\r\n ) => {\r\n if (\r\n ev.type === 'dblclick' &&\r\n row.action.actionSource === 'DOUBLE_CLICK'\r\n ) {\r\n this.emit('rowDblClick', {\r\n action: {\r\n ...row.action,\r\n action: attributes.openUrl as string,\r\n },\r\n ev: ev,\r\n });\r\n }\r\n };\r\n const onClickEvent: MouseEventHandler<HTMLTableRowElement> = (ev) => {\r\n if (ev.type === 'click' && row.action.actionSource === 'CLICK') {\r\n this.emit('rowClick', {\r\n action: {\r\n ...row.action,\r\n action: attributes.openUrl as string,\r\n },\r\n ev: ev,\r\n });\r\n }\r\n };\r\n\r\n const returnValue: TBuildTable['rows'][0] = {\r\n id: row.id,\r\n cells: arrayOrArray(row.cells).map((cell) => {\r\n const returnValue: TBuildTable['rows'][0]['cells'][0] = {\r\n content: cell.text,\r\n isHtml: cell.isHtml,\r\n documentUrl: cell.documentUrl,\r\n isDocument: cell.isDocument,\r\n Renderer: cell.Renderer,\r\n className: cell.className,\r\n };\r\n return returnValue;\r\n }),\r\n isExpandible: false,\r\n isSelectable: !row.isDisabled,\r\n isSelected: row.isSelected,\r\n isDisabled: row.isDisabled,\r\n domProperties: {\r\n onDoubleClick: (ev) => onDoubleClickEvent(ev),\r\n onClick: (ev) => onClickEvent(ev),\r\n className: '' + (row.isDisabled ? 'locked non-selectable' : ''),\r\n },\r\n properties: row,\r\n };\r\n\r\n return returnValue;\r\n }),\r\n });\r\n }\r\n\r\n public getColumn(name: string) {\r\n return this.head.getColumns()?.getColumn(name);\r\n }\r\n\r\n public getColumns() {\r\n return [...(this.head.getColumns()?.columns.values() || [])];\r\n }\r\n\r\n public getFilter(name: string) {\r\n return this.head.getFilters()?.get(name);\r\n }\r\n\r\n public getFilters() {\r\n return [...(this.head.getFilters()?.getAll() || [])];\r\n }\r\n\r\n public getRowById(id: string | number) {\r\n return this.head.getRowById(id) || this.body.getRowById(id);\r\n }\r\n\r\n public hasAdditionalContent() {\r\n return (\r\n !!this.head\r\n .getHeaderRow()\r\n ?.getColumns()\r\n .find((c) => c.asAdditional) ||\r\n this.getState('onRowExpand') ||\r\n this.getState('fetchRowExpand')\r\n );\r\n }\r\n\r\n public static readonly RENDER_ADDITIONAL_CELLS_CONTENT = Object.freeze({});\r\n\r\n public async onRowExpand(row: Row) {\r\n const onExpand = this.getState('onRowExpand');\r\n if (onExpand) {\r\n return onExpand(row);\r\n }\r\n\r\n return TableController.RENDER_ADDITIONAL_CELLS_CONTENT;\r\n }\r\n\r\n /**\r\n * EDITION MODE\r\n */\r\n\r\n public get isEditionMode() {\r\n return this.state.editionMode;\r\n }\r\n\r\n toggleEditionMode(force?: boolean) {\r\n if (this.state.allowEdition) {\r\n this.state.editionMode = force ?? !this.state.editionMode;\r\n this.emit('editionMode', this.state.editionMode);\r\n }\r\n }\r\n\r\n changeAmountOfRegisters(amount: number) {\r\n this.state.registersToShow = amount;\r\n }\r\n\r\n /**\r\n * SELECTION\r\n */\r\n\r\n clearSelection() {\r\n this.state.selection.clear();\r\n }\r\n\r\n /**\r\n * Returns the selected rows.\r\n */\r\n public getSelectedRows() {\r\n return [...this.state.selection];\r\n }\r\n\r\n public isSelected(row: Row): boolean {\r\n return this.state.selection.has(row);\r\n }\r\n\r\n shoutSelection() {\r\n this.emit('selectionChange', [...this.state.selection]);\r\n }\r\n\r\n public toggleColumnVisibility(colName: string, isVisible?: boolean) {\r\n isVisible =\r\n isVisible ??\r\n this.head.getHeaderRow()?.getColumn(colName).getState('isHidden');\r\n\r\n if (this.head.getHeaderRow()) {\r\n this.head\r\n .getHeaderRow()\r\n ?.getColumn(colName)\r\n .setState('isHidden', isVisible);\r\n } else {\r\n this.head.rows[0]?.cells\r\n ?.find((c) => c.getState('colName') === colName)\r\n ?.setState('isHidden', !isVisible);\r\n }\r\n }\r\n\r\n public toggleFiltersRowVisibility() {\r\n this.head\r\n .getFiltersRow()\r\n ?.setState('isHidden', !this.head.getFiltersRow()?.getState('isHidden'));\r\n }\r\n\r\n /**\r\n * Toggles the selection state of a given row.\r\n *\r\n * If the `isSelected` parameter is provided, it explicitly sets the selection\r\n * state of the row to the given value (`true` for selected, `false` for deselected).\r\n * If `isSelected` is not provided, the method will toggle the current selection state\r\n * of the row (i.e., select it if it's currently not selected, or deselect it if it is).\r\n *\r\n * @param row - The row to toggle selection for.\r\n * @param isSelected - Optional. A boolean indicating whether the row should be selected (`true`)\r\n * or deselected (`false`). If not provided, the selection state will be toggled.\r\n */\r\n public toggleRowSelection(row: Row, isSelected?: boolean, fireEvent = true) {\r\n if (this.state.allowSelection) {\r\n isSelected = isSelected ?? !this.state.selection.has(row);\r\n\r\n if (isSelected) {\r\n if (row.getState('isSelectable') !== false) {\r\n this.state.selection.add(row);\r\n }\r\n } else {\r\n this.state.selection.delete(row);\r\n }\r\n\r\n if (fireEvent) {\r\n this.shoutSelection();\r\n }\r\n }\r\n }\r\n\r\n protected restoreFocus() {\r\n if (!this.state.focusedCell || this.state.focusedCell.getTable() !== this) {\r\n this.state.focusedCell =\r\n this.body.getState('rows').values().next().value?.cells[0] ||\r\n this.head.getState('rows').values().next().value?.cells[0] ||\r\n null;\r\n }\r\n if (this.state.focusedCell) {\r\n this.emit('cellFocus', { cell: this.state.focusedCell, doFocus: false });\r\n }\r\n }\r\n\r\n removeRow(row: Row) {\r\n if (row.getTable() === this) {\r\n row.setTable(null);\r\n\r\n this.head.removeRow(row);\r\n this.body.removeRow(row);\r\n\r\n if (this.state.selection.has(row)) {\r\n this.state.selection.delete(row);\r\n this.shoutSelection();\r\n }\r\n\r\n if (this.state.focusedCell?.getRow() === row) {\r\n this.restoreFocus();\r\n }\r\n }\r\n }\r\n\r\n /**\r\n * FOCUS\r\n */\r\n\r\n /**\r\n * @returns The currently focused cell in the table.\r\n */\r\n public getFocusedCell() {\r\n return this.state.focusedCell;\r\n }\r\n\r\n public setFocusedCell(cell: Cell, doFocus: boolean = true) {\r\n this.state.focusedCell = cell;\r\n this.emit('cellFocus', { cell, doFocus });\r\n }\r\n\r\n public setSelection(indices: number[]) {\r\n this.clearSelection();\r\n indices.forEach((index) => {\r\n const row = this.body.getRowByIndex(index);\r\n if (row) {\r\n this.toggleRowSelection(row, true, false);\r\n }\r\n });\r\n }\r\n\r\n public scrollRowIntoView(row: Row) {\r\n this.emit('scrollIntoRow', row);\r\n }\r\n\r\n /**\r\n * STATE\r\n */\r\n\r\n /**\r\n * Returns the current state of the `TableController` instance.\r\n *\r\n * @param prop - The property of the state to retrieve.\r\n */\r\n public getState<K extends keyof TableState>(prop: K) {\r\n return this.state[prop];\r\n }\r\n\r\n /**\r\n * Updates the state of the `TableController` instance.\r\n *\r\n * This method provides two overloads:\r\n * 1. A callback function that takes the current state and returns a new state.\r\n * 2. A key-value pair where the key is a property of the state, and the value is the new value for that property.\r\n *\r\n * @param prop - Either a callback function to update the state or the key of the state property to update.\r\n * @param value - (Optional) The new value for the specified state property. This is required if `prop` is a key.\r\n *\r\n * @returns The `TableController` instance for method chaining.\r\n *\r\n * ### Usage:\r\n *\r\n * **Using a callback function:**\r\n * ```tsx\r\n * tableController.setState((state) => ({\r\n * ...state,\r\n * allowEdition: false,\r\n * }));\r\n * ```\r\n *\r\n * **Using a key-value pair:**\r\n * ```tsx\r\n * tableController.setState('allowEdition', false);\r\n * ```\r\n */\r\n public setState(cb: (s: TableState) => TableState): this;\r\n public setState<K extends keyof TableState>(\r\n prop: K,\r\n value: TableState[K],\r\n ): this;\r\n public setState<K extends keyof TableState>(\r\n prop: K | ((s: TableState) => TableState),\r\n value?: TableState[K],\r\n ) {\r\n if (typeof prop === 'function') {\r\n this.state = prop(this.state);\r\n } else {\r\n this.state[prop] = value!;\r\n }\r\n return this;\r\n }\r\n\r\n public sortColumn(col: Column, sortState?: TSortType) {\r\n this.getColumns().forEach((c) => {\r\n if (c.getColumnName() !== col.getColumnName()) {\r\n c.sort('NONE');\r\n }\r\n });\r\n col.sort(sortState);\r\n\r\n this.emit('columnSort', col);\r\n }\r\n\r\n /**\r\n * PLUGINS\r\n */\r\n\r\n getPluginOfType<T extends TablePlugin>(\r\n clazz: new (...args: any[]) => T,\r\n ): T | undefined {\r\n return this.state.plugins.find((plugin) => plugin instanceof clazz) as\r\n | T\r\n | undefined;\r\n }\r\n\r\n /**\r\n * Sets the plugins for the table.\r\n */\r\n public setPlugins(cb: (currentPlugins: TablePlugin[]) => TablePlugin[]) {\r\n this.state.plugins = cb(this.state.plugins);\r\n }\r\n\r\n public getApplicablePlugins<K extends keyof TablePlugin>(\r\n method: K,\r\n ): ((\r\n ...args: Parameters<NonNullable<TablePlugin[K]>> extends [\r\n any,\r\n ...infer Rest,\r\n ]\r\n ? Rest\r\n : void[]\r\n ) => ReturnType<NonNullable<TablePlugin[K]>>)[] {\r\n return this.state.plugins\r\n .filter((c) => c[method] !== undefined)\r\n .map((c) => (c[method]! as any).bind(c, this)) as any;\r\n }\r\n}\r\n"],"names":["returnValue"],"mappings":";;;;;;;;;;;;AAmEO,MAAM,gBAAA,GAAN,MAAM,gBAAA,SACH,YAAA,CAEV;AAAA,EAeE,WAAA,CACS,SACP,KAAA,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A;AAAA;AAC7B;AAAA;AAAA;AAAA,EAMA,gBACE,KAAA,EACe;AACf,IAAA,OAAO,KAAK,KAAA,CAAM,OAAA,CAAQ,KAAK,CAAC,MAAA,KAAW,kBAAkB,KAAK,CAAA;AAAA;AAGpE;AAAA;AAAA;AAAA,EAKO,WAAW,EAAA,EAAsD;AACtE,IAAA,IAAA,CAAK,KAAA,CAAM,OAAA,GAAU,EAAA,CAAG,IAAA,CAAK,MAAM,OAAO,CAAA;AAAA;AAC5C,EAEO,qBACL,MAAA,EAQ8C;AAC9C,IAAA,OAAO,IAAA,CAAK,MAAM,OAAA,CACf,MAAA,CAAO,CAAC,CAAA,KAAM,CAAA,CAAE,MAAM,CAAA,KAAM,MAAS,EACrC,GAAA,CAAI,CAAC,MAAO,CAAA,CAAE,MAAM,EAAW,IAAA,CAAK,CAAA,EAAG,IAAI,CAAC,CAAA;AAAA;AAEnD,CAAA;AA3QE,aAAA,CAxMW,gBAAA,EAwMY,iCAAA,EAAkC,MAAA,CAAO,MAAA,CAAO,EAAE,CAAA,CAAA;AAxMpE,IAAM,eAAA,GAAN;;;;"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { ElementBaseState } from '../primitive/Element.js';
|
|
2
|
+
import { RowsGroup, RowsGroupBaseState } from '../primitive/RowsGroup.js';
|
|
3
|
+
import { TBuildRow } from '../primitive/Row.js';
|
|
4
|
+
import { TableController } from '../TableController.js';
|
|
5
|
+
|
|
6
|
+
type TableBodyState = ElementBaseState & RowsGroupBaseState & {};
|
|
7
|
+
type TBuildBody = {
|
|
8
|
+
rows: TBuildRow[];
|
|
9
|
+
};
|
|
10
|
+
declare class TableBody extends RowsGroup<TableBodyState> {
|
|
11
|
+
constructor(table: TableController);
|
|
12
|
+
build(data: TBuildBody): void;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
export { type TBuildBody, TableBody, type TableBodyState };
|
|
16
|
+
//# sourceMappingURL=TableBody.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { RowsGroup } from '../primitive/RowsGroup.js';
|
|
2
|
+
import { Row } from '../primitive/Row.js';
|
|
3
|
+
import { AdditionalRow } from '../primitive/AdditionalRow.js';
|
|
4
|
+
|
|
5
|
+
class TableBody extends RowsGroup {
|
|
6
|
+
constructor(table) {
|
|
7
|
+
super(table, { rows: [] });
|
|
8
|
+
}
|
|
9
|
+
build(data) {
|
|
10
|
+
let i = 0;
|
|
11
|
+
const selection = [];
|
|
12
|
+
for (const row of data.rows) {
|
|
13
|
+
if (row.isSelected) {
|
|
14
|
+
selection.push(i);
|
|
15
|
+
}
|
|
16
|
+
let currentRow = this.rows[i++];
|
|
17
|
+
if (currentRow instanceof AdditionalRow) {
|
|
18
|
+
currentRow.remove();
|
|
19
|
+
currentRow = void 0;
|
|
20
|
+
}
|
|
21
|
+
const bodyRow = currentRow ?? new Row(row.id);
|
|
22
|
+
if (!currentRow) {
|
|
23
|
+
this.addRow(bodyRow);
|
|
24
|
+
}
|
|
25
|
+
bodyRow.build(row);
|
|
26
|
+
}
|
|
27
|
+
this.rows.splice(data.rows.length);
|
|
28
|
+
if (selection.length) {
|
|
29
|
+
this.table.setSelection(selection);
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
export { TableBody };
|
|
35
|
+
//# sourceMappingURL=TableBody.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"TableBody.js","sources":["../../../src/data/body/TableBody.ts"],"sourcesContent":["import type { ElementBaseState } from '../primitive/Element';\r\nimport { RowsGroup, type RowsGroupBaseState } from '../primitive/RowsGroup';\r\nimport { Row, type TBuildRow } from '../primitive/Row';\r\nimport type { TableController } from '../TableController';\r\nimport { AdditionalRow } from '../primitive/AdditionalRow';\r\n\r\n// eslint-disable-next-line @typescript-eslint/ban-types\r\nexport type TableBodyState = ElementBaseState & RowsGroupBaseState & {};\r\n\r\nexport type TBuildBody = {\r\n rows: TBuildRow[];\r\n};\r\n\r\nexport class TableBody extends RowsGroup<TableBodyState> {\r\n constructor(table: TableController) {\r\n super(table, { rows: [] });\r\n }\r\n\r\n build(data: TBuildBody) {\r\n let i = 0;\r\n\r\n const selection: number[] = [];\r\n\r\n for (const row of data.rows) {\r\n if (row.isSelected) {\r\n selection.push(i);\r\n }\r\n\r\n let currentRow: Row | undefined = this.rows[i++];\r\n if (currentRow instanceof AdditionalRow) {\r\n currentRow.remove();\r\n currentRow = undefined;\r\n }\r\n const bodyRow = currentRow ?? new Row(row.id);\r\n\r\n if (!currentRow) {\r\n this.addRow(bodyRow);\r\n }\r\n bodyRow.build(row);\r\n }\r\n\r\n this.rows.splice(data.rows.length);\r\n\r\n if (selection.length) {\r\n this.table.setSelection(selection);\r\n }\r\n }\r\n}\r\n"],"names":[],"mappings":";;;;AAaO,MAAM,kBAAkB,SAAA,CAA0B;AAAA,EACvD,YAAY,KAAA,EAAwB;AAClC,IAAA,KAAA,CAAM,KAAA,EAAO,EAAE,IAAA,EAAM,IAAI,CAAA;AAAA;AAC3B,EAEA,MAAM,IAAA,EAAkB;AACtB,IAAA,IAAI,CAAA,GAAI,CAAA;AAER,IAAA,MAAM,YAAsB,EAAC;AAE7B,IAAA,KAAA,MAAW,GAAA,IAAO,KAAK,IAAA,EAAM;AAC3B,MAAA,IAAI,IAAI,UAAA,EAAY;AAClB,QAAA,SAAA,CAAU,KAAK,CAAC,CAAA;AAAA;AAGlB,MAAA,IAAI,UAAA,GAA8B,IAAA,CAAK,IAAA,CAAK,CAAA,EAAG,CAAA;AAC/C,MAAA,IAAI,sBAAsB,aAAA,EAAe;AACvC,QAAA,UAAA,CAAW,MAAA,EAAO;AAClB,QAAA,UAAA,GAAa,MAAA;AAAA;AAEf,MAAA,MAAM,OAAA,GAAU,UAAA,IAAc,IAAI,GAAA,CAAI,IAAI,EAAE,CAAA;AAE5C,MAAA,IAAI,CAAC,UAAA,EAAY;AACf,QAAA,IAAA,CAAK,OAAO,OAAO,CAAA;AAAA;AAErB,MAAA,OAAA,CAAQ,MAAM,GAAG,CAAA;AAAA;AAGnB,IAAA,IAAA,CAAK,IAAA,CAAK,MAAA,CAAO,IAAA,CAAK,IAAA,CAAK,MAAM,CAAA;AAEjC,IAAA,IAAI,UAAU,MAAA,EAAQ;AACpB,MAAA,IAAA,CAAK,KAAA,CAAM,aAAa,SAAS,CAAA;AAAA;AACnC;AAEJ;;;;"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { Filter, FilterState } from './Filter.js';
|
|
2
|
+
import { TOption } from '@apia/util';
|
|
3
|
+
|
|
4
|
+
type ComboFilterState<T> = FilterState<T> & {
|
|
5
|
+
options: TOption[];
|
|
6
|
+
sorted: boolean;
|
|
7
|
+
};
|
|
8
|
+
type ComboFilterValueType = string | null;
|
|
9
|
+
declare class ComboFilter extends Filter<ComboFilterValueType> {
|
|
10
|
+
protected state: ComboFilterState<ComboFilterValueType>;
|
|
11
|
+
constructor(state: ComboFilterState<ComboFilterValueType>);
|
|
12
|
+
getOptions(): TOption[];
|
|
13
|
+
set options(options: TOption[]);
|
|
14
|
+
getSelected(): string | undefined;
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export { ComboFilter, type ComboFilterState, type ComboFilterValueType };
|
|
18
|
+
//# sourceMappingURL=ComboFilter.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ComboFilter.d.ts","sources":[],"sourcesContent":[],"names":[],"mappings":""}
|