@sia.soul/sia-react-ui 0.1.130 → 0.1.132

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 CHANGED
@@ -16524,6 +16524,12 @@ function TableInner(props, ref) {
16524
16524
  const rootRef = (0, import_react57.useRef)(null);
16525
16525
  const remainingHeight = useRemainingHeight(rootRef, height == null && tableHeight == null ? fillRemaining : false);
16526
16526
  const scrollRef = (0, import_react57.useRef)(null);
16527
+ const cellFocusRequest = (0, import_react57.useRef)(0);
16528
+ const cellGlow = (0, import_react57.useRef)(null);
16529
+ (0, import_react57.useEffect)(() => () => {
16530
+ cellFocusRequest.current++;
16531
+ cellGlow.current?.remove();
16532
+ }, []);
16527
16533
  const tableRef = (0, import_react57.useRef)(null);
16528
16534
  useScrollbarProximity();
16529
16535
  const scrollbarDragRef = (0, import_react57.useRef)(null);
@@ -16874,25 +16880,91 @@ function TableInner(props, ref) {
16874
16880
  scrollbarDragRef.current = null;
16875
16881
  if (rootRef.current) rootRef.current.dataset.scrollbarDragging = "false";
16876
16882
  }, []);
16877
- (0, import_react57.useImperativeHandle)(ref, () => ({
16878
- getRows: () => pipeline.rows.map((row) => row.record),
16879
- getColumns: () => pipeline.columns,
16880
- getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
16881
- scrollTo: (options) => scrollRef.current?.scrollTo(options),
16882
- setLoading: setInternalLoading,
16883
- getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
16884
- setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
16885
- clearSelection: () => pluginApisRef.current.selection?.clear?.(),
16886
- setSelectedKeys: (keys) => pluginApisRef.current.selection?.setSelectedKeys?.(keys),
16887
- getSelectedRows: () => pluginApisRef.current.selection?.getSelectedRows?.() ?? [],
16888
- getSortInfo: () => pluginApisRef.current.sort?.getSortInfo?.() ?? null,
16889
- getColumnSettings: () => pluginApisRef.current.columnSetting?.getSettings?.() ?? [],
16890
- openColumnSetting: () => pluginApisRef.current.columnSetting?.open?.(),
16891
- generatePageParams: (model) => pluginApisRef.current.pagination?.generatePageParams?.(model) ?? model,
16892
- requestCount: async (model) => {
16893
- await pluginApisRef.current.pagination?.requestCount?.(model);
16894
- }
16895
- }), [dataSource.length, pipeline.columns, pipeline.rows]);
16883
+ (0, import_react57.useImperativeHandle)(ref, () => {
16884
+ const api = {
16885
+ getRows: () => pipeline.rows.map((row) => row.record),
16886
+ getColumns: () => pipeline.columns,
16887
+ getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
16888
+ scrollTo: (options) => scrollRef.current?.scrollTo(options),
16889
+ scrollToRow: (key) => {
16890
+ const viewport = scrollRef.current;
16891
+ const table = tableRef.current;
16892
+ const index = pipeline.rows.findIndex((row2) => row2.key === key);
16893
+ if (!viewport || !table || !viewport.clientHeight || index < 0) return false;
16894
+ const row = Array.from(table.tBodies[0]?.rows ?? []).find((element) => element.dataset.rowKey === String(key));
16895
+ const headerHeight = table.tHead?.offsetHeight ?? headerRows.length * rowHeight;
16896
+ const top = row ? row.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop : headerHeight + index * rowHeight;
16897
+ const height2 = row?.offsetHeight ?? rowHeight;
16898
+ const headerInset = stickyHeader ? headerHeight : 0;
16899
+ const footerInset = table.tFoot?.offsetHeight ?? 0;
16900
+ const visibleTop = viewport.scrollTop + headerInset;
16901
+ const visibleBottom = viewport.scrollTop + viewport.clientHeight - footerInset;
16902
+ if (top < visibleTop || height2 > visibleBottom - visibleTop) viewport.scrollTop = Math.max(0, top - headerInset);
16903
+ else if (top + height2 > visibleBottom) viewport.scrollTop = top + height2 - viewport.clientHeight + footerInset;
16904
+ if (shouldVirtualize) setScrollTop(viewport.scrollTop);
16905
+ updateScrollMetrics();
16906
+ return true;
16907
+ },
16908
+ focusCell: async (key, columnKey, options) => {
16909
+ const request = ++cellFocusRequest.current;
16910
+ cellGlow.current?.remove();
16911
+ cellGlow.current = null;
16912
+ const viewport = scrollRef.current;
16913
+ const columnIndex = leafColumns.findIndex((column2) => column2.key === columnKey);
16914
+ if (!viewport || columnIndex < 0 || !api.scrollToRow(key)) return false;
16915
+ const column = leafColumns[columnIndex];
16916
+ if (!normalizeFixed(column.fixed)) {
16917
+ const start = leafColumns.slice(0, columnIndex).reduce((sum, item) => sum + (columnWidths.get(item.key) ?? DEFAULT_WIDTH), 0);
16918
+ const width = columnWidths.get(columnKey) ?? DEFAULT_WIDTH;
16919
+ const visibleWidth = viewport.clientWidth - left - right;
16920
+ if (start < viewport.scrollLeft + left || width > visibleWidth) viewport.scrollLeft = Math.max(0, start - left);
16921
+ else if (start + width > viewport.scrollLeft + viewport.clientWidth - right) viewport.scrollLeft = start + width - viewport.clientWidth + right;
16922
+ if (canvas) setScrollLeft(viewport.scrollLeft);
16923
+ }
16924
+ updateScrollMetrics();
16925
+ for (let frame = 0; frame < 12; frame++) {
16926
+ await new Promise((resolve) => requestAnimationFrame(() => resolve()));
16927
+ if (request !== cellFocusRequest.current || !viewport.isConnected || !viewport.clientHeight) return false;
16928
+ const row = Array.from(tableRef.current?.tBodies[0]?.rows ?? []).find((item) => item.dataset.rowKey === String(key));
16929
+ const cell = Array.from(row?.cells ?? []).find((item) => item.dataset.columnKey === columnKey);
16930
+ if (!cell || !cell.offsetWidth) continue;
16931
+ api.scrollToRow(key);
16932
+ const address = { rowKey: key, columnKey };
16933
+ pluginApisRef.current.cellSelection?.setRange({ anchor: address, focus: address });
16934
+ cell.tabIndex = -1;
16935
+ cell.focus({ preventScroll: true });
16936
+ if (options?.highlight !== false) {
16937
+ const glow = document.createElement("span");
16938
+ glow.className = "sia-table__cell-focus-glow";
16939
+ glow.setAttribute("aria-hidden", "true");
16940
+ cell.appendChild(glow);
16941
+ cellGlow.current = glow;
16942
+ glow.addEventListener("animationend", (event) => {
16943
+ if (event.target !== glow) return;
16944
+ glow.remove();
16945
+ if (cellGlow.current === glow) cellGlow.current = null;
16946
+ });
16947
+ }
16948
+ return true;
16949
+ }
16950
+ return false;
16951
+ },
16952
+ setLoading: setInternalLoading,
16953
+ getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
16954
+ setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
16955
+ clearSelection: () => pluginApisRef.current.selection?.clear?.(),
16956
+ setSelectedKeys: (keys) => pluginApisRef.current.selection?.setSelectedKeys?.(keys),
16957
+ getSelectedRows: () => pluginApisRef.current.selection?.getSelectedRows?.() ?? [],
16958
+ getSortInfo: () => pluginApisRef.current.sort?.getSortInfo?.() ?? null,
16959
+ getColumnSettings: () => pluginApisRef.current.columnSetting?.getSettings?.() ?? [],
16960
+ openColumnSetting: () => pluginApisRef.current.columnSetting?.open?.(),
16961
+ generatePageParams: (model) => pluginApisRef.current.pagination?.generatePageParams?.(model) ?? model,
16962
+ requestCount: async (model) => {
16963
+ await pluginApisRef.current.pagination?.requestCount?.(model);
16964
+ }
16965
+ };
16966
+ return api;
16967
+ }, [dataSource.length, pipeline.columns, pipeline.rows, headerRows.length, rowHeight, stickyHeader, shouldVirtualize, updateScrollMetrics, leafColumns, columnWidths, left, right, canvas]);
16896
16968
  const coreContext = {
16897
16969
  pluginId: "core",
16898
16970
  sourceData: dataSource,
package/dist/index.css CHANGED
@@ -11186,6 +11186,54 @@ body > .sia-title-tooltip[data-sia-popup-layer] {
11186
11186
  z-index: 5;
11187
11187
  }
11188
11188
 
11189
+ /* src/components/Table/cellFocus.css */
11190
+ .sia-table__cell-focus-glow {
11191
+ position: absolute;
11192
+ inset: 0;
11193
+ z-index: 2;
11194
+ overflow: hidden;
11195
+ pointer-events: none;
11196
+ box-shadow: inset 0 0 0 2px var(--sia-color-primary);
11197
+ background: color-mix(in srgb, var(--sia-color-primary) 16%, transparent);
11198
+ animation: sia-table-cell-focus-fade 900ms ease-out forwards;
11199
+ }
11200
+ .sia-table__cell-focus-glow::after {
11201
+ content: "";
11202
+ position: absolute;
11203
+ inset: 0;
11204
+ background:
11205
+ linear-gradient(
11206
+ 110deg,
11207
+ transparent 20%,
11208
+ color-mix(in srgb, var(--sia-color-primary) 55%, white) 50%,
11209
+ transparent 80%);
11210
+ animation: sia-table-cell-focus-sweep 500ms ease-out forwards;
11211
+ }
11212
+ @keyframes sia-table-cell-focus-sweep {
11213
+ from {
11214
+ transform: translateX(-100%);
11215
+ }
11216
+ to {
11217
+ transform: translateX(100%);
11218
+ }
11219
+ }
11220
+ @keyframes sia-table-cell-focus-fade {
11221
+ 0%, 45% {
11222
+ opacity: 1;
11223
+ }
11224
+ 100% {
11225
+ opacity: 0;
11226
+ }
11227
+ }
11228
+ @media (prefers-reduced-motion: reduce) {
11229
+ .sia-table__cell-focus-glow {
11230
+ animation-duration: 200ms;
11231
+ }
11232
+ .sia-table__cell-focus-glow::after {
11233
+ display: none;
11234
+ }
11235
+ }
11236
+
11189
11237
  /* src/components/Table/worksheet.css */
11190
11238
  .sia-table__worksheet-cell:not(.sia-table__cell--fixed) {
11191
11239
  position: relative;
package/dist/index.d.cts CHANGED
@@ -2359,6 +2359,13 @@ 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;
2364
+ /** 按稳定行键和叶子列键定位单元格,横纵滚动避开吸顶表头、固定列及合计行,选中并聚焦但不进入编辑。等待虚拟行挂载后返回是否成功;隐藏列、其它页、不可见表格或被后续定位取代时返回 false,不自动切页或显示隐藏列。应在数据更新及弹框关闭动画完成后调用。默认播放约 900 毫秒流光渐隐,减少动态效果偏好下仅淡出。 */
2365
+ focusCell: (rowKey: TableKey, columnKey: string, options?: {
2366
+ /** 是否播放一次流光渐隐,默认 true;false 仅滚动、选中和聚焦。 */
2367
+ highlight?: boolean;
2368
+ }) => Promise<boolean>;
2362
2369
  /** 切换加载状态。 */
2363
2370
  setLoading: (loading: boolean) => void;
2364
2371
  /** 读取当前分页状态。 */
package/dist/index.d.ts CHANGED
@@ -2359,6 +2359,13 @@ 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;
2364
+ /** 按稳定行键和叶子列键定位单元格,横纵滚动避开吸顶表头、固定列及合计行,选中并聚焦但不进入编辑。等待虚拟行挂载后返回是否成功;隐藏列、其它页、不可见表格或被后续定位取代时返回 false,不自动切页或显示隐藏列。应在数据更新及弹框关闭动画完成后调用。默认播放约 900 毫秒流光渐隐,减少动态效果偏好下仅淡出。 */
2365
+ focusCell: (rowKey: TableKey, columnKey: string, options?: {
2366
+ /** 是否播放一次流光渐隐,默认 true;false 仅滚动、选中和聚焦。 */
2367
+ highlight?: boolean;
2368
+ }) => Promise<boolean>;
2362
2369
  /** 切换加载状态。 */
2363
2370
  setLoading: (loading: boolean) => void;
2364
2371
  /** 读取当前分页状态。 */
package/dist/index.js CHANGED
@@ -8448,6 +8448,12 @@ function TableInner(props, ref) {
8448
8448
  const rootRef = useRef19(null);
8449
8449
  const remainingHeight = useRemainingHeight(rootRef, height == null && tableHeight == null ? fillRemaining : false);
8450
8450
  const scrollRef = useRef19(null);
8451
+ const cellFocusRequest = useRef19(0);
8452
+ const cellGlow = useRef19(null);
8453
+ useEffect15(() => () => {
8454
+ cellFocusRequest.current++;
8455
+ cellGlow.current?.remove();
8456
+ }, []);
8451
8457
  const tableRef = useRef19(null);
8452
8458
  useScrollbarProximity();
8453
8459
  const scrollbarDragRef = useRef19(null);
@@ -8798,25 +8804,91 @@ function TableInner(props, ref) {
8798
8804
  scrollbarDragRef.current = null;
8799
8805
  if (rootRef.current) rootRef.current.dataset.scrollbarDragging = "false";
8800
8806
  }, []);
8801
- useImperativeHandle(ref, () => ({
8802
- getRows: () => pipeline.rows.map((row) => row.record),
8803
- getColumns: () => pipeline.columns,
8804
- getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
8805
- scrollTo: (options) => scrollRef.current?.scrollTo(options),
8806
- setLoading: setInternalLoading,
8807
- getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
8808
- setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
8809
- clearSelection: () => pluginApisRef.current.selection?.clear?.(),
8810
- setSelectedKeys: (keys) => pluginApisRef.current.selection?.setSelectedKeys?.(keys),
8811
- getSelectedRows: () => pluginApisRef.current.selection?.getSelectedRows?.() ?? [],
8812
- getSortInfo: () => pluginApisRef.current.sort?.getSortInfo?.() ?? null,
8813
- getColumnSettings: () => pluginApisRef.current.columnSetting?.getSettings?.() ?? [],
8814
- openColumnSetting: () => pluginApisRef.current.columnSetting?.open?.(),
8815
- generatePageParams: (model) => pluginApisRef.current.pagination?.generatePageParams?.(model) ?? model,
8816
- requestCount: async (model) => {
8817
- await pluginApisRef.current.pagination?.requestCount?.(model);
8818
- }
8819
- }), [dataSource.length, pipeline.columns, pipeline.rows]);
8807
+ useImperativeHandle(ref, () => {
8808
+ const api = {
8809
+ getRows: () => pipeline.rows.map((row) => row.record),
8810
+ getColumns: () => pipeline.columns,
8811
+ getPluginApi: (pluginId) => pluginApisRef.current[pluginId],
8812
+ scrollTo: (options) => scrollRef.current?.scrollTo(options),
8813
+ scrollToRow: (key) => {
8814
+ const viewport = scrollRef.current;
8815
+ const table = tableRef.current;
8816
+ const index = pipeline.rows.findIndex((row2) => row2.key === key);
8817
+ if (!viewport || !table || !viewport.clientHeight || index < 0) return false;
8818
+ const row = Array.from(table.tBodies[0]?.rows ?? []).find((element) => element.dataset.rowKey === String(key));
8819
+ const headerHeight = table.tHead?.offsetHeight ?? headerRows.length * rowHeight;
8820
+ const top = row ? row.getBoundingClientRect().top - viewport.getBoundingClientRect().top - viewport.clientTop + viewport.scrollTop : headerHeight + index * rowHeight;
8821
+ const height2 = row?.offsetHeight ?? rowHeight;
8822
+ const headerInset = stickyHeader ? headerHeight : 0;
8823
+ const footerInset = table.tFoot?.offsetHeight ?? 0;
8824
+ const visibleTop = viewport.scrollTop + headerInset;
8825
+ const visibleBottom = viewport.scrollTop + viewport.clientHeight - footerInset;
8826
+ if (top < visibleTop || height2 > visibleBottom - visibleTop) viewport.scrollTop = Math.max(0, top - headerInset);
8827
+ else if (top + height2 > visibleBottom) viewport.scrollTop = top + height2 - viewport.clientHeight + footerInset;
8828
+ if (shouldVirtualize) setScrollTop(viewport.scrollTop);
8829
+ updateScrollMetrics();
8830
+ return true;
8831
+ },
8832
+ focusCell: async (key, columnKey, options) => {
8833
+ const request = ++cellFocusRequest.current;
8834
+ cellGlow.current?.remove();
8835
+ cellGlow.current = null;
8836
+ const viewport = scrollRef.current;
8837
+ const columnIndex = leafColumns.findIndex((column2) => column2.key === columnKey);
8838
+ if (!viewport || columnIndex < 0 || !api.scrollToRow(key)) return false;
8839
+ const column = leafColumns[columnIndex];
8840
+ if (!normalizeFixed(column.fixed)) {
8841
+ const start = leafColumns.slice(0, columnIndex).reduce((sum, item) => sum + (columnWidths.get(item.key) ?? DEFAULT_WIDTH), 0);
8842
+ const width = columnWidths.get(columnKey) ?? DEFAULT_WIDTH;
8843
+ const visibleWidth = viewport.clientWidth - left - right;
8844
+ if (start < viewport.scrollLeft + left || width > visibleWidth) viewport.scrollLeft = Math.max(0, start - left);
8845
+ else if (start + width > viewport.scrollLeft + viewport.clientWidth - right) viewport.scrollLeft = start + width - viewport.clientWidth + right;
8846
+ if (canvas) setScrollLeft(viewport.scrollLeft);
8847
+ }
8848
+ updateScrollMetrics();
8849
+ for (let frame = 0; frame < 12; frame++) {
8850
+ await new Promise((resolve) => requestAnimationFrame(() => resolve()));
8851
+ if (request !== cellFocusRequest.current || !viewport.isConnected || !viewport.clientHeight) return false;
8852
+ const row = Array.from(tableRef.current?.tBodies[0]?.rows ?? []).find((item) => item.dataset.rowKey === String(key));
8853
+ const cell = Array.from(row?.cells ?? []).find((item) => item.dataset.columnKey === columnKey);
8854
+ if (!cell || !cell.offsetWidth) continue;
8855
+ api.scrollToRow(key);
8856
+ const address = { rowKey: key, columnKey };
8857
+ pluginApisRef.current.cellSelection?.setRange({ anchor: address, focus: address });
8858
+ cell.tabIndex = -1;
8859
+ cell.focus({ preventScroll: true });
8860
+ if (options?.highlight !== false) {
8861
+ const glow = document.createElement("span");
8862
+ glow.className = "sia-table__cell-focus-glow";
8863
+ glow.setAttribute("aria-hidden", "true");
8864
+ cell.appendChild(glow);
8865
+ cellGlow.current = glow;
8866
+ glow.addEventListener("animationend", (event) => {
8867
+ if (event.target !== glow) return;
8868
+ glow.remove();
8869
+ if (cellGlow.current === glow) cellGlow.current = null;
8870
+ });
8871
+ }
8872
+ return true;
8873
+ }
8874
+ return false;
8875
+ },
8876
+ setLoading: setInternalLoading,
8877
+ getPage: () => pluginApisRef.current.pagination?.getPage?.() ?? { current: 1, pageSize: dataSource.length || 25 },
8878
+ setPage: (page) => pluginApisRef.current.pagination?.setPage?.(page),
8879
+ clearSelection: () => pluginApisRef.current.selection?.clear?.(),
8880
+ setSelectedKeys: (keys) => pluginApisRef.current.selection?.setSelectedKeys?.(keys),
8881
+ getSelectedRows: () => pluginApisRef.current.selection?.getSelectedRows?.() ?? [],
8882
+ getSortInfo: () => pluginApisRef.current.sort?.getSortInfo?.() ?? null,
8883
+ getColumnSettings: () => pluginApisRef.current.columnSetting?.getSettings?.() ?? [],
8884
+ openColumnSetting: () => pluginApisRef.current.columnSetting?.open?.(),
8885
+ generatePageParams: (model) => pluginApisRef.current.pagination?.generatePageParams?.(model) ?? model,
8886
+ requestCount: async (model) => {
8887
+ await pluginApisRef.current.pagination?.requestCount?.(model);
8888
+ }
8889
+ };
8890
+ return api;
8891
+ }, [dataSource.length, pipeline.columns, pipeline.rows, headerRows.length, rowHeight, stickyHeader, shouldVirtualize, updateScrollMetrics, leafColumns, columnWidths, left, right, canvas]);
8820
8892
  const coreContext = {
8821
8893
  pluginId: "core",
8822
8894
  sourceData: dataSource,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sia.soul/sia-react-ui",
3
- "version": "0.1.130",
3
+ "version": "0.1.132",
4
4
  "description": "Sia Design components and tokens for React",
5
5
  "publishConfig": {
6
6
  "access": "public",