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.
Files changed (30) hide show
  1. package/README.md +58 -4
  2. package/docs/migration-2.0.md +1 -1
  3. package/docs/styling.md +24 -7
  4. package/package.json +5 -1
  5. package/src/athena-ui.js +2 -1
  6. package/src/libs/config/config.js +1 -1
  7. package/src/libs/core/motion.js +358 -0
  8. package/src/libs/core/popover.js +96 -0
  9. package/src/libs/core/theme.js +12 -0
  10. package/src/libs/hephaestus/chartGenerator/chartGenerator.js +9 -5
  11. package/src/libs/hephaestus/componentGenerator/componentGenerator.js +43 -2
  12. package/src/libs/hephaestus/dialogGenerator/dialogGenerator.js +2 -1
  13. package/src/libs/hephaestus/feedbackGenerator/feedbackGenerator.js +3 -1
  14. package/src/libs/hephaestus/navigationGenerator/navigationGenerator.js +45 -9
  15. package/src/libs/hephaestus/router/router.js +18 -9
  16. package/src/libs/hephaestus/tableGenerator/tableGenerator.js +25 -0
  17. package/src/motion.js +6 -0
  18. package/src/res/themes/default/style.css +260 -10
  19. package/src/res/themes/tokens.css +25 -0
  20. package/types/athena-ui.d.ts +97 -96
  21. package/types/libs/config/config.d.ts +3 -3
  22. package/types/libs/core/motion.d.ts +123 -0
  23. package/types/libs/core/popover.d.ts +36 -0
  24. package/types/libs/core/theme.d.ts +41 -39
  25. package/types/libs/hephaestus/chartGenerator/chartGenerator.d.ts +2 -0
  26. package/types/libs/hephaestus/componentGenerator/componentGenerator.d.ts +238 -222
  27. package/types/libs/hephaestus/navigationGenerator/navigationGenerator.d.ts +4 -1
  28. package/types/libs/hephaestus/router/router.d.ts +71 -67
  29. package/types/libs/hephaestus/tableGenerator/tableGenerator.d.ts +123 -120
  30. 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 {number} [options.filterDelay=300] ms to wait after typing before the data source is asked
43
- * @param {{label: string, onclick: (row: object) => void, danger?: boolean, hidden?: (row: object) => boolean, ariaLabel?: (row: object) => string}[]} [options.rowActions]
44
- * a column of buttons at the end of every row
45
- * Column extras: `render(row, value)` returns text or a Node (built by the caller, so safe by construction), `align`
46
- * ("left" | "center" | "right"), `title` (false switches the tooltip with the full text off).
47
- * @returns {{element: HTMLElement, update: Function, destroy: Function, setRows: Function, getSelected: () => object[], clearSelection: Function,
48
- * getColumnWidths: () => Object<string, number>, toCsv: () => string, exportCsv: (filename?: string) => void}}
49
- */
50
- export function generateTable(options?: {
51
- parent?: string | Element;
52
- id?: string;
53
- class?: string;
54
- caption?: string;
55
- columns: {
56
- key: string;
57
- label?: string;
58
- width?: number;
59
- sortable?: boolean;
60
- editable?: boolean;
61
- format?: (value: any, row: any) => string;
62
- }[];
63
- rows?: object[];
64
- sortable?: boolean;
65
- filter?: boolean;
66
- pageSize?: number;
67
- selectable?: boolean;
68
- resizableColumns?: boolean;
69
- virtual?: {
70
- height?: number;
71
- rowHeight?: number;
72
- overscan?: number;
73
- } | boolean;
74
- onColumnResize?: (key: string, width: number) => void;
75
- onSelectionChange?: (rows: object[]) => void;
76
- onEdit?: (row: object, key: string, value: any, oldValue: any) => (boolean | void);
77
- onRowClick?: (row: object) => void;
78
- emptyText?: string;
79
- cellClass?: (row: object, column: object) => (string | string[] | null | undefined);
80
- rowClass?: (row: object) => (string | string[] | null | undefined);
81
- focusableRows?: boolean;
82
- rowLabel?: (row: object) => string;
83
- density?: "normal" | "compact";
84
- wrap?: boolean;
85
- dataSource?: (query: {
86
- page: number;
87
- pageSize: number;
88
- cursor: any;
89
- sort: ({
90
- key: string;
91
- descending: boolean;
92
- } | null);
93
- filter: string;
94
- }) => Promise<{
95
- rows: object[];
96
- total?: number;
97
- nextCursor?: any;
98
- }>;
99
- chunkSize?: number;
100
- filterDelay?: number;
101
- rowActions?: {
102
- label: string;
103
- onclick: (row: object) => void;
104
- danger?: boolean;
105
- hidden?: (row: object) => boolean;
106
- ariaLabel?: (row: object) => string;
107
- }[];
108
- }): {
109
- element: HTMLElement;
110
- update: Function;
111
- destroy: Function;
112
- setRows: Function;
113
- getSelected: () => object[];
114
- clearSelection: Function;
115
- getColumnWidths: () => {
116
- [x: string]: number;
117
- };
118
- toCsv: () => string;
119
- exportCsv: (filename?: string) => void;
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";