openxiangda 1.0.216 → 1.0.217

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.
@@ -2722,6 +2722,9 @@ interface AdminListProps<Row> {
2722
2722
  fixedFilters?: Record<string, unknown>;
2723
2723
  lockedPreference?: AdminListLockedPreference;
2724
2724
  selectable?: boolean;
2725
+ selectedRowKeys?: Key[];
2726
+ rowSelectable?: (row: Row) => boolean;
2727
+ rowSelectionReason?: (row: Row) => string | undefined;
2725
2728
  preserveSelectionAcrossPages?: boolean;
2726
2729
  exportable?: boolean;
2727
2730
  fileName?: string;
@@ -2722,6 +2722,9 @@ interface AdminListProps<Row> {
2722
2722
  fixedFilters?: Record<string, unknown>;
2723
2723
  lockedPreference?: AdminListLockedPreference;
2724
2724
  selectable?: boolean;
2725
+ selectedRowKeys?: Key[];
2726
+ rowSelectable?: (row: Row) => boolean;
2727
+ rowSelectionReason?: (row: Row) => string | undefined;
2725
2728
  preserveSelectionAcrossPages?: boolean;
2726
2729
  exportable?: boolean;
2727
2730
  fileName?: string;
@@ -43586,8 +43586,11 @@ function AdminList(props) {
43586
43586
  preserveSelectionAcrossPages = true,
43587
43587
  rowActions = [],
43588
43588
  rowKey,
43589
+ rowSelectable,
43590
+ rowSelectionReason,
43589
43591
  searchFields = [],
43590
43592
  selectable = true,
43593
+ selectedRowKeys: controlledSelectedKeys,
43591
43594
  style,
43592
43595
  toolbar
43593
43596
  } = props;
@@ -43670,6 +43673,40 @@ function AdminList(props) {
43670
43673
  },
43671
43674
  [messageApi, onSelectionChange]
43672
43675
  );
43676
+ useEffect14(() => {
43677
+ if (!controlledSelectedKeys) return;
43678
+ const nextKeys = [...controlledSelectedKeys];
43679
+ const nextKeySet = new Set(nextKeys);
43680
+ for (const key of selectedRowsRef.current.keys()) {
43681
+ if (!nextKeySet.has(key)) selectedRowsRef.current.delete(key);
43682
+ }
43683
+ for (const row of rows) {
43684
+ const key = getRowKey(rowKey, row);
43685
+ if (nextKeySet.has(key)) selectedRowsRef.current.set(key, row);
43686
+ }
43687
+ selectedKeysRef.current = nextKeys;
43688
+ setSelectedKeys(nextKeys);
43689
+ }, [controlledSelectedKeys, rowKey, rows]);
43690
+ useEffect14(() => {
43691
+ if (!rowSelectable || !selectedKeysRef.current.length || !rows.length) {
43692
+ return;
43693
+ }
43694
+ const disabledKeys = new Set(
43695
+ rows.filter((row) => !rowSelectable(row)).map((row) => getRowKey(rowKey, row))
43696
+ );
43697
+ if (!disabledKeys.size) return;
43698
+ const nextKeys = selectedKeysRef.current.filter(
43699
+ (key) => !disabledKeys.has(key)
43700
+ );
43701
+ if (nextKeys.length === selectedKeysRef.current.length) return;
43702
+ for (const key of disabledKeys) selectedRowsRef.current.delete(key);
43703
+ selectedKeysRef.current = nextKeys;
43704
+ setSelectedKeys(nextKeys);
43705
+ onSelectionChange?.({
43706
+ rowKeys: nextKeys,
43707
+ rows: nextKeys.map((key) => selectedRowsRef.current.get(key)).filter(Boolean)
43708
+ });
43709
+ }, [onSelectionChange, rowKey, rowSelectable, rows]);
43673
43710
  useEffect14(() => {
43674
43711
  let active = true;
43675
43712
  setReady(false);
@@ -44653,6 +44690,10 @@ function AdminList(props) {
44653
44690
  rowSelection: selectable ? {
44654
44691
  preserveSelectedRowKeys: preserveSelectionAcrossPages,
44655
44692
  selectedRowKeys: selectedKeys,
44693
+ getCheckboxProps: (row) => ({
44694
+ disabled: rowSelectable ? !rowSelectable(row) : false,
44695
+ title: rowSelectionReason?.(row)
44696
+ }),
44656
44697
  onChange: handleSelectionChange
44657
44698
  } : void 0,
44658
44699
  scroll: { x: "max-content" },