@worknice/whiteboard 0.10.0-rc.4 → 0.10.0-rc.5
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.
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import type { RowData } from "@tanstack/react-table";
|
|
2
|
-
import { type SortingColumnDef } from "@tanstack/react-table";
|
|
1
|
+
import type { RowData, SortingColumnDef } from "@tanstack/react-table";
|
|
3
2
|
import { type ReactNode } from "react";
|
|
4
3
|
import { type ZodTypeAny } from "zod";
|
|
5
4
|
type PrimitiveValue = boolean | string | undefined | number;
|
|
@@ -7,7 +7,6 @@ import * as __WEBPACK_EXTERNAL_MODULE_clsx__ from "clsx";
|
|
|
7
7
|
import * as __WEBPACK_EXTERNAL_MODULE_react__ from "react";
|
|
8
8
|
import * as __WEBPACK_EXTERNAL_MODULE_utf8__ from "utf8";
|
|
9
9
|
import * as __WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__ from "../controls/Button.js";
|
|
10
|
-
import * as __WEBPACK_EXTERNAL_MODULE__controls_ButtonLink_js_1677d8df__ from "../controls/ButtonLink.js";
|
|
11
10
|
import * as __WEBPACK_EXTERNAL_MODULE__controls_Disclosure_js_6e4cc59c__ from "../controls/Disclosure.js";
|
|
12
11
|
import * as __WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__ from "../controls/MenuButton.js";
|
|
13
12
|
import * as __WEBPACK_EXTERNAL_MODULE__fields_SelectField_js_8b78efe2__ from "../fields/SelectField.js";
|
|
@@ -167,18 +166,21 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
|
|
|
167
166
|
width: 1920
|
|
168
167
|
}
|
|
169
168
|
});
|
|
170
|
-
const
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
169
|
+
const createCsvDataUrl = (columns, rows)=>{
|
|
170
|
+
const csvContent = (0, __WEBPACK_EXTERNAL_MODULE__utils_encodeCsv_js_1d824629__["default"])([
|
|
171
|
+
columns.map((col)=>col.header),
|
|
172
|
+
...rows.map((row)=>columns.map((col)=>row.getValue(col.id)))
|
|
173
|
+
]);
|
|
174
|
+
return `data:text/csv;charset=utf-8,${__WEBPACK_EXTERNAL_MODULE_utf8__["default"].encode(csvContent)}`;
|
|
175
|
+
};
|
|
176
|
+
const handleDownloadCsv = (columns, rows)=>{
|
|
177
|
+
if (!csvFilename) return;
|
|
178
|
+
const csvDataUrl = createCsvDataUrl(columns, rows);
|
|
179
|
+
const a = document.createElement("a");
|
|
180
|
+
a.href = csvDataUrl;
|
|
181
|
+
a.download = csvFilename.endsWith(".csv") ? csvFilename : `${csvFilename}.csv`;
|
|
182
|
+
a.click();
|
|
183
|
+
};
|
|
182
184
|
const throttledSetGlobalFilter = (0, __WEBPACK_EXTERNAL_MODULE__react_hook_throttle_d66151d4__.useThrottleCallback)((value)=>table.setGlobalFilter(value), 4);
|
|
183
185
|
const showSearchReset = columnFiltersInitialState.some((filter, index)=>filter.value !== table.getState().columnFilters[index].value) || table.initialState.globalFilter !== table.getState().globalFilter;
|
|
184
186
|
const validPrimaryBulkActions = bulkActions.filter((bulkAction)=>table.getFilteredSelectedRowModel().rows.some((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true));
|
|
@@ -231,18 +233,26 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
|
|
|
231
233
|
}),
|
|
232
234
|
children: bulkAction.label
|
|
233
235
|
}, bulkAction.key)),
|
|
234
|
-
validSecondaryBulkActions.length > 0 ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
|
|
236
|
+
validSecondaryBulkActions.length > 0 || csvExportableColumns && csvFilename ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_MenuButton_js_b23cdd05__["default"], {
|
|
235
237
|
id: "bulkActionOverflow",
|
|
236
|
-
options:
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
238
|
+
options: [
|
|
239
|
+
...validSecondaryBulkActions.map((bulkAction)=>({
|
|
240
|
+
id: bulkAction.key,
|
|
241
|
+
label: bulkAction.label,
|
|
242
|
+
type: "render",
|
|
243
|
+
render: (onClose)=>bulkAction.render({
|
|
244
|
+
rows: table.getFilteredSelectedRowModel().flatRows.filter((row)=>bulkAction.predicate ? bulkAction.predicate(row.original) : true).map((row)=>row.original),
|
|
245
|
+
resetRowSelection: ()=>table.resetRowSelection(),
|
|
246
|
+
onClose: onClose
|
|
247
|
+
})
|
|
248
|
+
})),
|
|
249
|
+
{
|
|
250
|
+
id: "download-selected-rows",
|
|
251
|
+
label: "Download selected rows as CSV",
|
|
252
|
+
type: "onClick",
|
|
253
|
+
onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getSelectedRowModel().rows)
|
|
254
|
+
}
|
|
255
|
+
],
|
|
246
256
|
icon: /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__Icon_js_0d271bb6__["default"], {
|
|
247
257
|
symbol: "Plus"
|
|
248
258
|
}),
|
|
@@ -439,7 +449,7 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
|
|
|
439
449
|
]
|
|
440
450
|
})
|
|
441
451
|
}),
|
|
442
|
-
showRowCount || csvExportableColumns && csvFilename
|
|
452
|
+
showRowCount || csvExportableColumns && csvFilename ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("div", {
|
|
443
453
|
className: __WEBPACK_EXTERNAL_MODULE__Table_module_js_1c0e33be__["default"].downloadLink,
|
|
444
454
|
children: [
|
|
445
455
|
/*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsxs)("p", {
|
|
@@ -451,10 +461,10 @@ const Table = ({ data, columns, bulkActions = [], secondaryBulkActions = [], csv
|
|
|
451
461
|
table.getPreFilteredRowModel().flatRows.length
|
|
452
462
|
]
|
|
453
463
|
}),
|
|
454
|
-
csvExportableColumns && csvFilename
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
children: "Download CSV"
|
|
464
|
+
csvExportableColumns && csvFilename ? /*#__PURE__*/ (0, __WEBPACK_EXTERNAL_MODULE_react_jsx_runtime_225474f2__.jsx)(__WEBPACK_EXTERNAL_MODULE__controls_Button_js_f591ba2e__["default"], {
|
|
465
|
+
type: "secondary",
|
|
466
|
+
onClick: ()=>handleDownloadCsv(csvExportableColumns, table.getRowModel().rows),
|
|
467
|
+
children: "Download all rows as CSV"
|
|
458
468
|
}) : null
|
|
459
469
|
]
|
|
460
470
|
}) : null
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@worknice/whiteboard",
|
|
3
3
|
"description": "",
|
|
4
|
-
"version": "0.10.0-rc.
|
|
4
|
+
"version": "0.10.0-rc.5",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"private": false,
|
|
7
7
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"react-markdown": "^10.1.0",
|
|
39
39
|
"utf8": "^3.0.0",
|
|
40
40
|
"zod": "^3.22.3",
|
|
41
|
-
"@worknice/utils": "^0.4.6-rc.
|
|
41
|
+
"@worknice/utils": "^0.4.6-rc.5"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@anolilab/semantic-release-pnpm": "^1.1.10",
|