athena-ui-js 2.0.1 → 2.2.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 +58 -4
- package/docs/migration-2.0.md +1 -1
- package/docs/styling.md +24 -7
- package/package.json +5 -1
- package/src/athena-ui.js +2 -1
- package/src/libs/config/config.js +1 -1
- package/src/libs/core/motion.js +358 -0
- package/src/libs/core/popover.js +96 -0
- package/src/libs/core/theme.js +12 -0
- package/src/libs/hephaestus/chartGenerator/chartGenerator.js +9 -5
- package/src/libs/hephaestus/componentGenerator/componentGenerator.js +43 -2
- package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +2 -1
- package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +3 -1
- package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +45 -9
- package/src/libs/hephaestus/router/router.js +18 -9
- package/src/libs/hephaestus/tableGenerator/tableGenerator.js +25 -0
- package/src/motion.js +6 -0
- package/src/res/themes/default/style.css +260 -10
- package/src/res/themes/tokens.css +25 -0
- package/types/athena-ui.d.ts +97 -96
- package/types/libs/config/config.d.ts +3 -3
- package/types/libs/core/motion.d.ts +123 -0
- package/types/libs/core/popover.d.ts +36 -0
- package/types/libs/core/theme.d.ts +41 -39
- package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +2 -0
- package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -222
- package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +4 -1
- package/types/libs/hephaestus/router/router.d.ts +71 -67
- package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +123 -120
- package/types/motion.d.ts +1 -0
|
@@ -1,120 +1,123 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Generates a table (optional filter box, sortable headers, pagination, row selection, inline
|
|
3
|
-
* editing, resizable columns, virtual scrolling, CSV export) and appends it to its parent.
|
|
4
|
-
*
|
|
5
|
-
* @param {object} options
|
|
6
|
-
* @param {string|Element} [options.parent] id or element, defaults to "wrapper"
|
|
7
|
-
* @param {string} [options.id] id of the table wrapper (default: "table")
|
|
8
|
-
* @param {string} [options.class] extra CSS class of the table
|
|
9
|
-
* @param {string} [options.caption]
|
|
10
|
-
* @param {{key: string, label?: string, width?: number, sortable?: boolean, editable?: boolean, format?: (value, row) => string}[]} options.columns
|
|
11
|
-
* @param {object[]} [options.rows] row objects, read by column key
|
|
12
|
-
* @param {boolean} [options.sortable=true] click on a header sorts by it
|
|
13
|
-
* @param {boolean} [options.filter=false] show a text filter above the table
|
|
14
|
-
* @param {number} [options.pageSize=0] rows per page, 0 disables pagination
|
|
15
|
-
* @param {boolean} [options.selectable=false] checkbox column; the header checkbox selects every filtered row
|
|
16
|
-
* @param {boolean} [options.resizableColumns=false] drag the edge of a header (or use the arrow keys on it) to resize;
|
|
17
|
-
* double click resets the width
|
|
18
|
-
* @param {{height?: number, rowHeight?: number, overscan?: number}|boolean} [options.virtual] render only the rows
|
|
19
|
-
* in view, for lists of thousands of rows. Rows have a fixed height (default 36 px) and the table scrolls
|
|
20
|
-
* inside `height` (default 400 px). Replaces pagination.
|
|
21
|
-
* @param {(key: string, width: number) => void} [options.onColumnResize]
|
|
22
|
-
* @param {(rows: object[]) => void} [options.onSelectionChange]
|
|
23
|
-
* @param {(row: object, key: string, value, oldValue) => (boolean|void)} [options.onEdit] called after an edit
|
|
24
|
-
* of an `editable` column (double click, or Enter / F2 on the focused cell). Return false to reject it.
|
|
25
|
-
* @param {(row: object) => void} [options.onRowClick]
|
|
26
|
-
* @param {string} [options.emptyText]
|
|
27
|
-
* @param {(row: object, column: object) => (string|string[]|null|undefined)} [options.cellClass] CSS class(es) for a cell
|
|
28
|
-
* @param {(row: object) => (string|string[]|null|undefined)} [options.rowClass] CSS class(es) for a row
|
|
29
|
-
* @param {boolean} [options.focusableRows=false] rows are reachable with Tab and, with `onRowClick`, opened with Enter and Space
|
|
30
|
-
* @param {(row: object) => string} [options.rowLabel] aria-label of a focusable row
|
|
31
|
-
* @param {"normal"|"compact"} [options.density="normal"]
|
|
32
|
-
* @param {boolean} [options.wrap] true lets long text wrap, false keeps one line with an ellipsis (default: wrap, except in virtual tables)
|
|
33
|
-
* @param {(query: {page: number, pageSize: number, cursor: *, sort: ({key: string, descending: boolean}|null), filter: string}) =>
|
|
34
|
-
* Promise<{rows: object[], total?: number, nextCursor?: *}>} [options.dataSource] load the rows from a server instead of
|
|
35
|
-
* keeping them all in the browser. Sorting, the filter box and the pager call it again. Answer with `total` for numbered pages
|
|
36
|
-
* (`page` is 0-based), or with `nextCursor` for a "Load more" button (`cursor` is what the last answer gave, undefined for the
|
|
37
|
-
* first request; the rows are appended). A failed request shows the error with a Retry button.
|
|
38
|
-
* Together with `virtual` the list scrolls like one of `total` rows (every answer must carry `total`): the rows in view are asked for
|
|
39
|
-
* in chunks of `chunkSize` (`page` is the chunk number), rows that have not arrived yet show a placeholder, and sorting or the filter
|
|
40
|
-
* start again from the top.
|
|
41
|
-
* @param {number} [options.chunkSize=50] rows per request of a data source with `virtual`
|
|
42
|
-
* @param {
|
|
43
|
-
*
|
|
44
|
-
*
|
|
45
|
-
*
|
|
46
|
-
*
|
|
47
|
-
*
|
|
48
|
-
*
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
};
|
|
1
|
+
/**
|
|
2
|
+
* Generates a table (optional filter box, sortable headers, pagination, row selection, inline
|
|
3
|
+
* editing, resizable columns, virtual scrolling, CSV export) and appends it to its parent.
|
|
4
|
+
*
|
|
5
|
+
* @param {object} options
|
|
6
|
+
* @param {string|Element} [options.parent] id or element, defaults to "wrapper"
|
|
7
|
+
* @param {string} [options.id] id of the table wrapper (default: "table")
|
|
8
|
+
* @param {string} [options.class] extra CSS class of the table
|
|
9
|
+
* @param {string} [options.caption]
|
|
10
|
+
* @param {{key: string, label?: string, width?: number, sortable?: boolean, editable?: boolean, format?: (value, row) => string}[]} options.columns
|
|
11
|
+
* @param {object[]} [options.rows] row objects, read by column key
|
|
12
|
+
* @param {boolean} [options.sortable=true] click on a header sorts by it
|
|
13
|
+
* @param {boolean} [options.filter=false] show a text filter above the table
|
|
14
|
+
* @param {number} [options.pageSize=0] rows per page, 0 disables pagination
|
|
15
|
+
* @param {boolean} [options.selectable=false] checkbox column; the header checkbox selects every filtered row
|
|
16
|
+
* @param {boolean} [options.resizableColumns=false] drag the edge of a header (or use the arrow keys on it) to resize;
|
|
17
|
+
* double click resets the width
|
|
18
|
+
* @param {{height?: number, rowHeight?: number, overscan?: number}|boolean} [options.virtual] render only the rows
|
|
19
|
+
* in view, for lists of thousands of rows. Rows have a fixed height (default 36 px) and the table scrolls
|
|
20
|
+
* inside `height` (default 400 px). Replaces pagination.
|
|
21
|
+
* @param {(key: string, width: number) => void} [options.onColumnResize]
|
|
22
|
+
* @param {(rows: object[]) => void} [options.onSelectionChange]
|
|
23
|
+
* @param {(row: object, key: string, value, oldValue) => (boolean|void)} [options.onEdit] called after an edit
|
|
24
|
+
* of an `editable` column (double click, or Enter / F2 on the focused cell). Return false to reject it.
|
|
25
|
+
* @param {(row: object) => void} [options.onRowClick]
|
|
26
|
+
* @param {string} [options.emptyText]
|
|
27
|
+
* @param {(row: object, column: object) => (string|string[]|null|undefined)} [options.cellClass] CSS class(es) for a cell
|
|
28
|
+
* @param {(row: object) => (string|string[]|null|undefined)} [options.rowClass] CSS class(es) for a row
|
|
29
|
+
* @param {boolean} [options.focusableRows=false] rows are reachable with Tab and, with `onRowClick`, opened with Enter and Space
|
|
30
|
+
* @param {(row: object) => string} [options.rowLabel] aria-label of a focusable row
|
|
31
|
+
* @param {"normal"|"compact"} [options.density="normal"]
|
|
32
|
+
* @param {boolean} [options.wrap] true lets long text wrap, false keeps one line with an ellipsis (default: wrap, except in virtual tables)
|
|
33
|
+
* @param {(query: {page: number, pageSize: number, cursor: *, sort: ({key: string, descending: boolean}|null), filter: string}) =>
|
|
34
|
+
* Promise<{rows: object[], total?: number, nextCursor?: *}>} [options.dataSource] load the rows from a server instead of
|
|
35
|
+
* keeping them all in the browser. Sorting, the filter box and the pager call it again. Answer with `total` for numbered pages
|
|
36
|
+
* (`page` is 0-based), or with `nextCursor` for a "Load more" button (`cursor` is what the last answer gave, undefined for the
|
|
37
|
+
* first request; the rows are appended). A failed request shows the error with a Retry button.
|
|
38
|
+
* Together with `virtual` the list scrolls like one of `total` rows (every answer must carry `total`): the rows in view are asked for
|
|
39
|
+
* in chunks of `chunkSize` (`page` is the chunk number), rows that have not arrived yet show a placeholder, and sorting or the filter
|
|
40
|
+
* start again from the top.
|
|
41
|
+
* @param {number} [options.chunkSize=50] rows per request of a data source with `virtual`
|
|
42
|
+
* @param {boolean} [options.animateRows=false] rows slide to their new place when the table is sorted, filtered or changes page, and new rows fade in
|
|
43
|
+
* (at most 60 rows are animated, none under reduced motion, none in a virtual table)
|
|
44
|
+
* @param {number} [options.filterDelay=300] ms to wait after typing before the data source is asked
|
|
45
|
+
* @param {{label: string, onclick: (row: object) => void, danger?: boolean, hidden?: (row: object) => boolean, ariaLabel?: (row: object) => string}[]} [options.rowActions]
|
|
46
|
+
* a column of buttons at the end of every row
|
|
47
|
+
* Column extras: `render(row, value)` returns text or a Node (built by the caller, so safe by construction), `align`
|
|
48
|
+
* ("left" | "center" | "right"), `title` (false switches the tooltip with the full text off).
|
|
49
|
+
* @returns {{element: HTMLElement, update: Function, destroy: Function, setRows: Function, getSelected: () => object[], clearSelection: Function,
|
|
50
|
+
* getColumnWidths: () => Object<string, number>, toCsv: () => string, exportCsv: (filename?: string) => void}}
|
|
51
|
+
*/
|
|
52
|
+
export function generateTable(options?: {
|
|
53
|
+
parent?: string | Element;
|
|
54
|
+
id?: string;
|
|
55
|
+
class?: string;
|
|
56
|
+
caption?: string;
|
|
57
|
+
columns: {
|
|
58
|
+
key: string;
|
|
59
|
+
label?: string;
|
|
60
|
+
width?: number;
|
|
61
|
+
sortable?: boolean;
|
|
62
|
+
editable?: boolean;
|
|
63
|
+
format?: (value: any, row: any) => string;
|
|
64
|
+
}[];
|
|
65
|
+
rows?: object[];
|
|
66
|
+
sortable?: boolean;
|
|
67
|
+
filter?: boolean;
|
|
68
|
+
pageSize?: number;
|
|
69
|
+
selectable?: boolean;
|
|
70
|
+
resizableColumns?: boolean;
|
|
71
|
+
virtual?: {
|
|
72
|
+
height?: number;
|
|
73
|
+
rowHeight?: number;
|
|
74
|
+
overscan?: number;
|
|
75
|
+
} | boolean;
|
|
76
|
+
onColumnResize?: (key: string, width: number) => void;
|
|
77
|
+
onSelectionChange?: (rows: object[]) => void;
|
|
78
|
+
onEdit?: (row: object, key: string, value: any, oldValue: any) => (boolean | void);
|
|
79
|
+
onRowClick?: (row: object) => void;
|
|
80
|
+
emptyText?: string;
|
|
81
|
+
cellClass?: (row: object, column: object) => (string | string[] | null | undefined);
|
|
82
|
+
rowClass?: (row: object) => (string | string[] | null | undefined);
|
|
83
|
+
focusableRows?: boolean;
|
|
84
|
+
rowLabel?: (row: object) => string;
|
|
85
|
+
density?: "normal" | "compact";
|
|
86
|
+
wrap?: boolean;
|
|
87
|
+
dataSource?: (query: {
|
|
88
|
+
page: number;
|
|
89
|
+
pageSize: number;
|
|
90
|
+
cursor: any;
|
|
91
|
+
sort: ({
|
|
92
|
+
key: string;
|
|
93
|
+
descending: boolean;
|
|
94
|
+
} | null);
|
|
95
|
+
filter: string;
|
|
96
|
+
}) => Promise<{
|
|
97
|
+
rows: object[];
|
|
98
|
+
total?: number;
|
|
99
|
+
nextCursor?: any;
|
|
100
|
+
}>;
|
|
101
|
+
chunkSize?: number;
|
|
102
|
+
animateRows?: boolean;
|
|
103
|
+
filterDelay?: number;
|
|
104
|
+
rowActions?: {
|
|
105
|
+
label: string;
|
|
106
|
+
onclick: (row: object) => void;
|
|
107
|
+
danger?: boolean;
|
|
108
|
+
hidden?: (row: object) => boolean;
|
|
109
|
+
ariaLabel?: (row: object) => string;
|
|
110
|
+
}[];
|
|
111
|
+
}): {
|
|
112
|
+
element: HTMLElement;
|
|
113
|
+
update: Function;
|
|
114
|
+
destroy: Function;
|
|
115
|
+
setRows: Function;
|
|
116
|
+
getSelected: () => object[];
|
|
117
|
+
clearSelection: Function;
|
|
118
|
+
getColumnWidths: () => {
|
|
119
|
+
[x: string]: number;
|
|
120
|
+
};
|
|
121
|
+
toCsv: () => string;
|
|
122
|
+
exportCsv: (filename?: string) => void;
|
|
123
|
+
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./libs/core/motion.js";
|