@sia.soul/sia-react-ui 0.1.64 → 0.1.66
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/dist/index.cjs +14 -7
- package/dist/index.d.cts +7 -3
- package/dist/index.d.ts +7 -3
- package/dist/index.js +14 -7
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -13092,7 +13092,6 @@ function TableSelectedItemsPanel({
|
|
|
13092
13092
|
}
|
|
13093
13093
|
function createSelectionPlugin(options = {}) {
|
|
13094
13094
|
const { mode = "multiple", childrenColumnName = "children" } = options;
|
|
13095
|
-
const preservedRows = /* @__PURE__ */ new Map();
|
|
13096
13095
|
function selected(context) {
|
|
13097
13096
|
return options.selectedKeys ?? context.state.selectedKeys ?? [];
|
|
13098
13097
|
}
|
|
@@ -13103,6 +13102,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13103
13102
|
return flattenRecords(context.sourceData, childrenColumnName);
|
|
13104
13103
|
}
|
|
13105
13104
|
function entriesForKeys(keys, context) {
|
|
13105
|
+
const preservedRows = context.state.preservedRows;
|
|
13106
13106
|
const records = allRecords(context);
|
|
13107
13107
|
const currentRows = new Map(
|
|
13108
13108
|
records.map(
|
|
@@ -13117,6 +13117,10 @@ function createSelectionPlugin(options = {}) {
|
|
|
13117
13117
|
)
|
|
13118
13118
|
);
|
|
13119
13119
|
if (preserving(context)) {
|
|
13120
|
+
(options.selectedRows ?? []).forEach((record, index) => {
|
|
13121
|
+
const key = context.getRowKey(record, index);
|
|
13122
|
+
if (keys.includes(key)) preservedRows.set(key, record);
|
|
13123
|
+
});
|
|
13120
13124
|
for (const key of keys) {
|
|
13121
13125
|
const entry = currentRows.get(key);
|
|
13122
13126
|
if (entry) preservedRows.set(key, entry.record);
|
|
@@ -13137,7 +13141,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13137
13141
|
return entriesForKeys(keys, context).map((entry) => entry.record);
|
|
13138
13142
|
}
|
|
13139
13143
|
function setKeys(keys, context) {
|
|
13140
|
-
if (keys.length === 0) preservedRows.clear();
|
|
13144
|
+
if (keys.length === 0) context.state.preservedRows.clear();
|
|
13141
13145
|
context.setState((state) => ({
|
|
13142
13146
|
...state,
|
|
13143
13147
|
selectedKeys: keys,
|
|
@@ -13153,7 +13157,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13153
13157
|
(key) => pageKeys.has(key)
|
|
13154
13158
|
);
|
|
13155
13159
|
setKeys(currentPageKeys, context);
|
|
13156
|
-
preservedRows.clear();
|
|
13160
|
+
context.state.preservedRows.clear();
|
|
13157
13161
|
}
|
|
13158
13162
|
context.setState((state) => ({
|
|
13159
13163
|
...state,
|
|
@@ -13175,11 +13179,13 @@ function createSelectionPlugin(options = {}) {
|
|
|
13175
13179
|
return {
|
|
13176
13180
|
id: "selection",
|
|
13177
13181
|
order: 20,
|
|
13178
|
-
|
|
13182
|
+
// 用工厂给每个表格创建独立缓存,避免同一插件对象被多个表格复用时串数据。
|
|
13183
|
+
initialState: () => ({
|
|
13184
|
+
preservedRows: /* @__PURE__ */ new Map(),
|
|
13179
13185
|
selectedKeys: options.defaultSelectedKeys ?? [],
|
|
13180
13186
|
preserveSelectedRowKeys: options.preserveSelectedRowKeys ?? false,
|
|
13181
13187
|
panelOpen: false
|
|
13182
|
-
},
|
|
13188
|
+
}),
|
|
13183
13189
|
transformColumns(columns, context) {
|
|
13184
13190
|
if (mode === "row") return columns;
|
|
13185
13191
|
const selectionColumn = {
|
|
@@ -13264,6 +13270,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13264
13270
|
if (!options.showSelectedCount) return null;
|
|
13265
13271
|
const keys = selected(context);
|
|
13266
13272
|
const entries = entriesForKeys(keys, context);
|
|
13273
|
+
const selectedCount = preserving(context) ? new Set(keys).size : entries.length;
|
|
13267
13274
|
const columns = flattenTableColumns(context.columns).filter(
|
|
13268
13275
|
(column) => !column.hidden && column.meta?.plugin !== "selection"
|
|
13269
13276
|
).slice(0, Math.max(1, options.selectionPanelColumnCount ?? 4));
|
|
@@ -13301,7 +13308,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13301
13308
|
disabled: entries.length === 0,
|
|
13302
13309
|
children: [
|
|
13303
13310
|
"\u5DF2\u9009 ",
|
|
13304
|
-
|
|
13311
|
+
selectedCount,
|
|
13305
13312
|
" \u6761"
|
|
13306
13313
|
]
|
|
13307
13314
|
}
|
|
@@ -13327,7 +13334,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
13327
13334
|
const records = allRecords(context);
|
|
13328
13335
|
const record = records.find(
|
|
13329
13336
|
(item, index) => Object.is(context.getRowKey(item, index), key)
|
|
13330
|
-
) ?? preservedRows.get(key);
|
|
13337
|
+
) ?? context.state.preservedRows.get(key);
|
|
13331
13338
|
if (record) toggle(key, record, context, checked);
|
|
13332
13339
|
},
|
|
13333
13340
|
getSelectedRows: () => rowsForKeys(selected(context), context),
|
package/dist/index.d.cts
CHANGED
|
@@ -2408,6 +2408,8 @@ interface TableSelectionPluginOptions<T> {
|
|
|
2408
2408
|
mode?: TableSelectionMode;
|
|
2409
2409
|
/** 当前选中项目的标识集合;传入后由外部控制。 */
|
|
2410
2410
|
selectedKeys?: readonly TableKey[];
|
|
2411
|
+
/** 跨页保留时补充已选行数据,用于弹框重新挂载后恢复已选明细;按 Table.rowKey 匹配,仅缓存当前已选标识对应的行,当前数据源的同键行优先。不会添加选择或改变当前页列表。 */
|
|
2412
|
+
selectedRows?: readonly T[];
|
|
2411
2413
|
/** 非受控模式下初始选中的项目标识集合。 */
|
|
2412
2414
|
defaultSelectedKeys?: readonly TableKey[];
|
|
2413
2415
|
/** 值发生变化时调用;参数为新值及类型声明中列出的关联信息。 */
|
|
@@ -2430,7 +2432,9 @@ interface TableSelectionPluginOptions<T> {
|
|
|
2430
2432
|
childrenColumnName?: string;
|
|
2431
2433
|
}
|
|
2432
2434
|
/** 行勾选和已选面板状态。 */
|
|
2433
|
-
interface SelectionState {
|
|
2435
|
+
interface SelectionState<T> {
|
|
2436
|
+
/** 当前表格独立保存的跨页行缓存,重建插件时保留,表格卸载后释放。 */
|
|
2437
|
+
preservedRows: Map<TableKey, T>;
|
|
2434
2438
|
/** 当前选中的行标识。 */
|
|
2435
2439
|
selectedKeys: readonly TableKey[];
|
|
2436
2440
|
/** 是否跨页保留选中行。 */
|
|
@@ -2455,8 +2459,8 @@ interface TableSelectionApi<T> {
|
|
|
2455
2459
|
/** 设置是否跨页保留选中行。 */
|
|
2456
2460
|
setPreserveSelectedRowKeys: (preserve: boolean) => void;
|
|
2457
2461
|
}
|
|
2458
|
-
/** 创建表格行勾选插件。将返回值加入 Table 的 plugins
|
|
2459
|
-
declare function createSelectionPlugin<T extends Record<string, unknown>>(options?: TableSelectionPluginOptions<T>): TablePlugin<T, SelectionState
|
|
2462
|
+
/** 创建表格行勾选插件。将返回值加入 Table 的 plugins 后生效;跨页行缓存属于表格实例,重新创建插件不会清空缓存,不同表格互不共享。 */
|
|
2463
|
+
declare function createSelectionPlugin<T extends Record<string, unknown>>(options?: TableSelectionPluginOptions<T>): TablePlugin<T, SelectionState<T>, TableSelectionApi<T>>;
|
|
2460
2464
|
/** TableSort的插件配置。 */
|
|
2461
2465
|
interface TableSortPluginOptions {
|
|
2462
2466
|
/** 展示或交互模式;可选值见类型定义。 */
|
package/dist/index.d.ts
CHANGED
|
@@ -2408,6 +2408,8 @@ interface TableSelectionPluginOptions<T> {
|
|
|
2408
2408
|
mode?: TableSelectionMode;
|
|
2409
2409
|
/** 当前选中项目的标识集合;传入后由外部控制。 */
|
|
2410
2410
|
selectedKeys?: readonly TableKey[];
|
|
2411
|
+
/** 跨页保留时补充已选行数据,用于弹框重新挂载后恢复已选明细;按 Table.rowKey 匹配,仅缓存当前已选标识对应的行,当前数据源的同键行优先。不会添加选择或改变当前页列表。 */
|
|
2412
|
+
selectedRows?: readonly T[];
|
|
2411
2413
|
/** 非受控模式下初始选中的项目标识集合。 */
|
|
2412
2414
|
defaultSelectedKeys?: readonly TableKey[];
|
|
2413
2415
|
/** 值发生变化时调用;参数为新值及类型声明中列出的关联信息。 */
|
|
@@ -2430,7 +2432,9 @@ interface TableSelectionPluginOptions<T> {
|
|
|
2430
2432
|
childrenColumnName?: string;
|
|
2431
2433
|
}
|
|
2432
2434
|
/** 行勾选和已选面板状态。 */
|
|
2433
|
-
interface SelectionState {
|
|
2435
|
+
interface SelectionState<T> {
|
|
2436
|
+
/** 当前表格独立保存的跨页行缓存,重建插件时保留,表格卸载后释放。 */
|
|
2437
|
+
preservedRows: Map<TableKey, T>;
|
|
2434
2438
|
/** 当前选中的行标识。 */
|
|
2435
2439
|
selectedKeys: readonly TableKey[];
|
|
2436
2440
|
/** 是否跨页保留选中行。 */
|
|
@@ -2455,8 +2459,8 @@ interface TableSelectionApi<T> {
|
|
|
2455
2459
|
/** 设置是否跨页保留选中行。 */
|
|
2456
2460
|
setPreserveSelectedRowKeys: (preserve: boolean) => void;
|
|
2457
2461
|
}
|
|
2458
|
-
/** 创建表格行勾选插件。将返回值加入 Table 的 plugins
|
|
2459
|
-
declare function createSelectionPlugin<T extends Record<string, unknown>>(options?: TableSelectionPluginOptions<T>): TablePlugin<T, SelectionState
|
|
2462
|
+
/** 创建表格行勾选插件。将返回值加入 Table 的 plugins 后生效;跨页行缓存属于表格实例,重新创建插件不会清空缓存,不同表格互不共享。 */
|
|
2463
|
+
declare function createSelectionPlugin<T extends Record<string, unknown>>(options?: TableSelectionPluginOptions<T>): TablePlugin<T, SelectionState<T>, TableSelectionApi<T>>;
|
|
2460
2464
|
/** TableSort的插件配置。 */
|
|
2461
2465
|
interface TableSortPluginOptions {
|
|
2462
2466
|
/** 展示或交互模式;可选值见类型定义。 */
|
package/dist/index.js
CHANGED
|
@@ -5719,7 +5719,6 @@ function TableSelectedItemsPanel({
|
|
|
5719
5719
|
}
|
|
5720
5720
|
function createSelectionPlugin(options = {}) {
|
|
5721
5721
|
const { mode = "multiple", childrenColumnName = "children" } = options;
|
|
5722
|
-
const preservedRows = /* @__PURE__ */ new Map();
|
|
5723
5722
|
function selected(context) {
|
|
5724
5723
|
return options.selectedKeys ?? context.state.selectedKeys ?? [];
|
|
5725
5724
|
}
|
|
@@ -5730,6 +5729,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5730
5729
|
return flattenRecords(context.sourceData, childrenColumnName);
|
|
5731
5730
|
}
|
|
5732
5731
|
function entriesForKeys(keys, context) {
|
|
5732
|
+
const preservedRows = context.state.preservedRows;
|
|
5733
5733
|
const records = allRecords(context);
|
|
5734
5734
|
const currentRows = new Map(
|
|
5735
5735
|
records.map(
|
|
@@ -5744,6 +5744,10 @@ function createSelectionPlugin(options = {}) {
|
|
|
5744
5744
|
)
|
|
5745
5745
|
);
|
|
5746
5746
|
if (preserving(context)) {
|
|
5747
|
+
(options.selectedRows ?? []).forEach((record, index) => {
|
|
5748
|
+
const key = context.getRowKey(record, index);
|
|
5749
|
+
if (keys.includes(key)) preservedRows.set(key, record);
|
|
5750
|
+
});
|
|
5747
5751
|
for (const key of keys) {
|
|
5748
5752
|
const entry = currentRows.get(key);
|
|
5749
5753
|
if (entry) preservedRows.set(key, entry.record);
|
|
@@ -5764,7 +5768,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5764
5768
|
return entriesForKeys(keys, context).map((entry) => entry.record);
|
|
5765
5769
|
}
|
|
5766
5770
|
function setKeys(keys, context) {
|
|
5767
|
-
if (keys.length === 0) preservedRows.clear();
|
|
5771
|
+
if (keys.length === 0) context.state.preservedRows.clear();
|
|
5768
5772
|
context.setState((state) => ({
|
|
5769
5773
|
...state,
|
|
5770
5774
|
selectedKeys: keys,
|
|
@@ -5780,7 +5784,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5780
5784
|
(key) => pageKeys.has(key)
|
|
5781
5785
|
);
|
|
5782
5786
|
setKeys(currentPageKeys, context);
|
|
5783
|
-
preservedRows.clear();
|
|
5787
|
+
context.state.preservedRows.clear();
|
|
5784
5788
|
}
|
|
5785
5789
|
context.setState((state) => ({
|
|
5786
5790
|
...state,
|
|
@@ -5802,11 +5806,13 @@ function createSelectionPlugin(options = {}) {
|
|
|
5802
5806
|
return {
|
|
5803
5807
|
id: "selection",
|
|
5804
5808
|
order: 20,
|
|
5805
|
-
|
|
5809
|
+
// 用工厂给每个表格创建独立缓存,避免同一插件对象被多个表格复用时串数据。
|
|
5810
|
+
initialState: () => ({
|
|
5811
|
+
preservedRows: /* @__PURE__ */ new Map(),
|
|
5806
5812
|
selectedKeys: options.defaultSelectedKeys ?? [],
|
|
5807
5813
|
preserveSelectedRowKeys: options.preserveSelectedRowKeys ?? false,
|
|
5808
5814
|
panelOpen: false
|
|
5809
|
-
},
|
|
5815
|
+
}),
|
|
5810
5816
|
transformColumns(columns, context) {
|
|
5811
5817
|
if (mode === "row") return columns;
|
|
5812
5818
|
const selectionColumn = {
|
|
@@ -5891,6 +5897,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5891
5897
|
if (!options.showSelectedCount) return null;
|
|
5892
5898
|
const keys = selected(context);
|
|
5893
5899
|
const entries = entriesForKeys(keys, context);
|
|
5900
|
+
const selectedCount = preserving(context) ? new Set(keys).size : entries.length;
|
|
5894
5901
|
const columns = flattenTableColumns(context.columns).filter(
|
|
5895
5902
|
(column) => !column.hidden && column.meta?.plugin !== "selection"
|
|
5896
5903
|
).slice(0, Math.max(1, options.selectionPanelColumnCount ?? 4));
|
|
@@ -5928,7 +5935,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5928
5935
|
disabled: entries.length === 0,
|
|
5929
5936
|
children: [
|
|
5930
5937
|
"\u5DF2\u9009 ",
|
|
5931
|
-
|
|
5938
|
+
selectedCount,
|
|
5932
5939
|
" \u6761"
|
|
5933
5940
|
]
|
|
5934
5941
|
}
|
|
@@ -5954,7 +5961,7 @@ function createSelectionPlugin(options = {}) {
|
|
|
5954
5961
|
const records = allRecords(context);
|
|
5955
5962
|
const record = records.find(
|
|
5956
5963
|
(item, index) => Object.is(context.getRowKey(item, index), key)
|
|
5957
|
-
) ?? preservedRows.get(key);
|
|
5964
|
+
) ?? context.state.preservedRows.get(key);
|
|
5958
5965
|
if (record) toggle(key, record, context, checked);
|
|
5959
5966
|
},
|
|
5960
5967
|
getSelectedRows: () => rowsForKeys(selected(context), context),
|