@mk-kit/ui 0.41.0 → 0.42.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 +3 -3
- package/fesm2022/mk-kit-ui-core.mjs +87 -0
- package/fesm2022/mk-kit-ui-core.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-data.mjs +368 -13
- package/fesm2022/mk-kit-ui-data.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-datetime.mjs +2 -2
- package/fesm2022/mk-kit-ui-datetime.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-directives.mjs +395 -2
- package/fesm2022/mk-kit-ui-directives.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-dnd.mjs +183 -29
- package/fesm2022/mk-kit-ui-dnd.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-forms.mjs +6 -4
- package/fesm2022/mk-kit-ui-forms.mjs.map +1 -1
- package/fesm2022/mk-kit-ui-table.mjs +26 -6
- package/fesm2022/mk-kit-ui-table.mjs.map +1 -1
- package/package.json +1 -1
- package/styles/mk-kit.css +604 -0
- package/types/mk-kit-ui-core.d.ts +48 -1
- package/types/mk-kit-ui-data.d.ts +158 -3
- package/types/mk-kit-ui-directives.d.ts +234 -3
- package/types/mk-kit-ui-dnd.d.ts +96 -14
- package/types/mk-kit-ui-forms.d.ts +6 -4
- package/types/mk-kit-ui-table.d.ts +38 -4
|
@@ -1001,12 +1001,22 @@ class MkTable {
|
|
|
1001
1001
|
}
|
|
1002
1002
|
// --- Export -----------------------------------------------------------------
|
|
1003
1003
|
/**
|
|
1004
|
-
* The
|
|
1005
|
-
*
|
|
1006
|
-
*
|
|
1007
|
-
* `
|
|
1004
|
+
* The rows and columns an export writes — exactly what {@link exportCsv}
|
|
1005
|
+
* serialises, for other formats (XLSX, PDF, the clipboard, …): rows in
|
|
1006
|
+
* display order with the current sort applied and tree children
|
|
1007
|
+
* (`childrenKey`) flattened under their parent whether or not they are
|
|
1008
|
+
* expanded, optionally only the selected ones; columns in the table's
|
|
1009
|
+
* current order, restricted to `options.columns` when given, each carrying
|
|
1010
|
+
* its header and `format` so what the user saw is what gets written.
|
|
1011
|
+
*
|
|
1012
|
+
* ```ts
|
|
1013
|
+
* const { rows, columns } = table.getExportRows({ selectedOnly: true });
|
|
1014
|
+
* const sheet = rows.map((row) =>
|
|
1015
|
+
* Object.fromEntries(columns.map((c) => [c.header ?? c.key, c.format ? c.format(row[c.key], row) : row[c.key]])),
|
|
1016
|
+
* );
|
|
1017
|
+
* ```
|
|
1008
1018
|
*/
|
|
1009
|
-
|
|
1019
|
+
getExportRows(options = {}) {
|
|
1010
1020
|
let rows = this.allRows();
|
|
1011
1021
|
if (options.selectedOnly) {
|
|
1012
1022
|
const keys = this.selectedKeys();
|
|
@@ -1016,7 +1026,17 @@ class MkTable {
|
|
|
1016
1026
|
const columns = this.orderedColumns()
|
|
1017
1027
|
.filter((c) => !only || only.has(c.key))
|
|
1018
1028
|
.map((c) => ({ key: c.key, header: c.header, format: c.format }));
|
|
1019
|
-
|
|
1029
|
+
return { rows, columns };
|
|
1030
|
+
}
|
|
1031
|
+
/**
|
|
1032
|
+
* The table's rows as CSV: current column order, column formatters applied,
|
|
1033
|
+
* sorted the way they are shown, tree children flattened under their parent
|
|
1034
|
+
* whether or not they are expanded. Downloads the file (default name
|
|
1035
|
+
* `table.csv`) and returns the text. Built on {@link getExportRows}.
|
|
1036
|
+
*/
|
|
1037
|
+
exportCsv(options = {}) {
|
|
1038
|
+
const { rows, columns } = this.getExportRows(options);
|
|
1039
|
+
// The rows are already flat, so no childrenKey is passed through.
|
|
1020
1040
|
const csv = mkToCsv(rows, columns, { ...options, childrenKey: undefined });
|
|
1021
1041
|
if (options.download !== false) {
|
|
1022
1042
|
let filename = options.filename ?? 'table.csv';
|