@meta-1/design 0.0.168 → 0.0.169

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@meta-1/design",
3
- "version": "0.0.168",
3
+ "version": "0.0.169",
4
4
  "keywords": [
5
5
  "easykit",
6
6
  "design",
@@ -57,6 +57,7 @@ export interface DataTableProps<TData> {
57
57
  showColumnVisibility?: boolean;
58
58
  stickyColumns?: StickyColumnProps[];
59
59
  checkbox?: boolean;
60
+ onRowSelectionChange?: (selectedRows: TData[]) => void;
60
61
  rowActions?: DropdownMenuItemProps[] | ((cell: TData) => DropdownMenuItemProps[]);
61
62
  onRowActionClick?: (item: DropdownMenuItemProps, row: Row<TData>) => void;
62
63
  loading?: boolean;
@@ -161,6 +162,7 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
161
162
  showColumnVisibility = true,
162
163
  rowActions,
163
164
  checkbox = false,
165
+ onRowSelectionChange,
164
166
  stickyColumns = [],
165
167
  onRowActionClick,
166
168
  filter,
@@ -284,6 +286,14 @@ export function DataTable<TData>(props: DataTableProps<TData>) {
284
286
  },
285
287
  });
286
288
 
289
+ // 当行选中状态改变时,通知外部
290
+ useEffect(() => {
291
+ if (checkbox && onRowSelectionChange) {
292
+ const selectedRows = table.getSelectedRowModel().rows.map((row) => row.original);
293
+ onRowSelectionChange(selectedRows);
294
+ }
295
+ }, [rowSelection, checkbox, onRowSelectionChange, table]);
296
+
287
297
  const leftStickyColumns = useMemo<StickyColumnProps[]>(() => {
288
298
  const columns: StickyColumnProps[] = [];
289
299
  if (checkbox) {