@sia.soul/sia-react-ui 0.1.130 → 0.1.131
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 +20 -1
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +20 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -16879,6 +16879,25 @@ function TableInner(props, ref) {
|
|
|
16879
16879
|
getColumns: () => pipeline.columns,
|
|
16880
16880
|
getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
|
|
16881
16881
|
scrollTo: (options) => scrollRef.current?.scrollTo(options),
|
|
16882
|
+
scrollToRow: (key) => {
|
|
16883
|
+
const viewport = scrollRef.current;
|
|
16884
|
+
const table = tableRef.current;
|
|
16885
|
+
const index = pipeline.rows.findIndex((row2) => row2.key === key);
|
|
16886
|
+
if (!viewport || !table || !viewport.clientHeight || index < 0) return false;
|
|
16887
|
+
const row = Array.from(table.tBodies[0]?.rows ?? []).find((element) => element.dataset.rowKey === String(key));
|
|
16888
|
+
const headerHeight = table.tHead?.offsetHeight ?? headerRows.length * rowHeight;
|
|
16889
|
+
const top = row ? row.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop : headerHeight + index * rowHeight;
|
|
16890
|
+
const height2 = row?.offsetHeight ?? rowHeight;
|
|
16891
|
+
const headerInset = stickyHeader ? headerHeight : 0;
|
|
16892
|
+
const footerInset = table.tFoot?.offsetHeight ?? 0;
|
|
16893
|
+
const visibleTop = viewport.scrollTop + headerInset;
|
|
16894
|
+
const visibleBottom = viewport.scrollTop + viewport.clientHeight - footerInset;
|
|
16895
|
+
if (top < visibleTop || height2 > visibleBottom - visibleTop) viewport.scrollTop = Math.max(0, top - headerInset);
|
|
16896
|
+
else if (top + height2 > visibleBottom) viewport.scrollTop = top + height2 - viewport.clientHeight + footerInset;
|
|
16897
|
+
if (shouldVirtualize) setScrollTop(viewport.scrollTop);
|
|
16898
|
+
updateScrollMetrics();
|
|
16899
|
+
return true;
|
|
16900
|
+
},
|
|
16882
16901
|
setLoading: setInternalLoading,
|
|
16883
16902
|
getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
|
|
16884
16903
|
setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
|
|
@@ -16892,7 +16911,7 @@ function TableInner(props, ref) {
|
|
|
16892
16911
|
requestCount: async (model) => {
|
|
16893
16912
|
await pluginApisRef.current.pagination?.requestCount?.(model);
|
|
16894
16913
|
}
|
|
16895
|
-
}), [dataSource.length, pipeline.columns, pipeline.rows]);
|
|
16914
|
+
}), [dataSource.length, pipeline.columns, pipeline.rows, headerRows.length, rowHeight, stickyHeader, shouldVirtualize, updateScrollMetrics]);
|
|
16896
16915
|
const coreContext = {
|
|
16897
16916
|
pluginId: "core",
|
|
16898
16917
|
sourceData: dataSource,
|
package/dist/index.d.cts
CHANGED
|
@@ -2359,6 +2359,8 @@ interface TableRef<T> {
|
|
|
2359
2359
|
getPluginApi: <Api = unknown>(pluginId: string) => Api | undefined;
|
|
2360
2360
|
/** 滚动到指定位置。 */
|
|
2361
2361
|
scrollTo: (options: ScrollToOptions) => void;
|
|
2362
|
+
/** 按 rowKey 定位当前筛选、排序、分页及树展开后列表中的行,仅在该行被遮挡时立即纵向滚动,使其避开吸顶表头和合计行;支持虚拟列表,不改变横向位置或焦点。返回是否找到目标且视口可见;目标被筛掉、位于其他页、表格隐藏或未挂载时返回 false,不自动切页。应在数据提交和弹框显示后调用。 */
|
|
2363
|
+
scrollToRow: (key: TableKey) => boolean;
|
|
2362
2364
|
/** 切换加载状态。 */
|
|
2363
2365
|
setLoading: (loading: boolean) => void;
|
|
2364
2366
|
/** 读取当前分页状态。 */
|
package/dist/index.d.ts
CHANGED
|
@@ -2359,6 +2359,8 @@ interface TableRef<T> {
|
|
|
2359
2359
|
getPluginApi: <Api = unknown>(pluginId: string) => Api | undefined;
|
|
2360
2360
|
/** 滚动到指定位置。 */
|
|
2361
2361
|
scrollTo: (options: ScrollToOptions) => void;
|
|
2362
|
+
/** 按 rowKey 定位当前筛选、排序、分页及树展开后列表中的行,仅在该行被遮挡时立即纵向滚动,使其避开吸顶表头和合计行;支持虚拟列表,不改变横向位置或焦点。返回是否找到目标且视口可见;目标被筛掉、位于其他页、表格隐藏或未挂载时返回 false,不自动切页。应在数据提交和弹框显示后调用。 */
|
|
2363
|
+
scrollToRow: (key: TableKey) => boolean;
|
|
2362
2364
|
/** 切换加载状态。 */
|
|
2363
2365
|
setLoading: (loading: boolean) => void;
|
|
2364
2366
|
/** 读取当前分页状态。 */
|
package/dist/index.js
CHANGED
|
@@ -8803,6 +8803,25 @@ function TableInner(props, ref) {
|
|
|
8803
8803
|
getColumns: () => pipeline.columns,
|
|
8804
8804
|
getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
|
|
8805
8805
|
scrollTo: (options) => scrollRef.current?.scrollTo(options),
|
|
8806
|
+
scrollToRow: (key) => {
|
|
8807
|
+
const viewport = scrollRef.current;
|
|
8808
|
+
const table = tableRef.current;
|
|
8809
|
+
const index = pipeline.rows.findIndex((row2) => row2.key === key);
|
|
8810
|
+
if (!viewport || !table || !viewport.clientHeight || index < 0) return false;
|
|
8811
|
+
const row = Array.from(table.tBodies[0]?.rows ?? []).find((element) => element.dataset.rowKey === String(key));
|
|
8812
|
+
const headerHeight = table.tHead?.offsetHeight ?? headerRows.length * rowHeight;
|
|
8813
|
+
const top = row ? row.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop : headerHeight + index * rowHeight;
|
|
8814
|
+
const height2 = row?.offsetHeight ?? rowHeight;
|
|
8815
|
+
const headerInset = stickyHeader ? headerHeight : 0;
|
|
8816
|
+
const footerInset = table.tFoot?.offsetHeight ?? 0;
|
|
8817
|
+
const visibleTop = viewport.scrollTop + headerInset;
|
|
8818
|
+
const visibleBottom = viewport.scrollTop + viewport.clientHeight - footerInset;
|
|
8819
|
+
if (top < visibleTop || height2 > visibleBottom - visibleTop) viewport.scrollTop = Math.max(0, top - headerInset);
|
|
8820
|
+
else if (top + height2 > visibleBottom) viewport.scrollTop = top + height2 - viewport.clientHeight + footerInset;
|
|
8821
|
+
if (shouldVirtualize) setScrollTop(viewport.scrollTop);
|
|
8822
|
+
updateScrollMetrics();
|
|
8823
|
+
return true;
|
|
8824
|
+
},
|
|
8806
8825
|
setLoading: setInternalLoading,
|
|
8807
8826
|
getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
|
|
8808
8827
|
setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
|
|
@@ -8816,7 +8835,7 @@ function TableInner(props, ref) {
|
|
|
8816
8835
|
requestCount: async (model) => {
|
|
8817
8836
|
await pluginApisRef.current.pagination?.requestCount?.(model);
|
|
8818
8837
|
}
|
|
8819
|
-
}), [dataSource.length, pipeline.columns, pipeline.rows]);
|
|
8838
|
+
}), [dataSource.length, pipeline.columns, pipeline.rows, headerRows.length, rowHeight, stickyHeader, shouldVirtualize, updateScrollMetrics]);
|
|
8820
8839
|
const coreContext = {
|
|
8821
8840
|
pluginId: "core",
|
|
8822
8841
|
sourceData: dataSource,
|