@bit-sun/business-component 4.2.0-alpha.31-wyl → 4.2.0-alpha.32-wyl
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/components/Business/BsSulaQueryTable/clipboard.d.ts +8 -0
- package/dist/components/Business/BsSulaQueryTable/rangeCopy.d.ts +20 -0
- package/dist/components/Business/BsSulaQueryTable/useRangeCopy.d.ts +16 -0
- package/dist/index.esm.js +618 -54
- package/dist/index.js +618 -54
- package/package.json +1 -1
- package/src/components/Business/BsSulaQueryTable/__tests__/clipboard.test.ts +38 -0
- package/src/components/Business/BsSulaQueryTable/__tests__/rangeCopy.test.ts +109 -0
- package/src/components/Business/BsSulaQueryTable/__tests__/useRangeCopy.test.tsx +207 -0
- package/src/components/Business/BsSulaQueryTable/clipboard.ts +36 -0
- package/src/components/Business/BsSulaQueryTable/index.md +22 -0
- package/src/components/Business/BsSulaQueryTable/index.tsx +24 -1
- package/src/components/Business/BsSulaQueryTable/rangeCopy.less +25 -0
- package/src/components/Business/BsSulaQueryTable/rangeCopy.ts +92 -0
- package/src/components/Business/BsSulaQueryTable/useRangeCopy.tsx +520 -0
- package/src/components/Business/SearchSelect/BusinessUtils.tsx +17 -8
- package/src/components/Functional/SearchSelect/index.tsx +30 -1
- package/tsconfig.json +1 -0
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 写文本到剪贴板。
|
|
3
|
+
* 1)优先用异步 Clipboard API:不依赖 execCommand 的焦点/可见性限制,也不抢焦点;
|
|
4
|
+
* 2)非安全上下文或旧内核退回 execCommand:临时 textarea 真正移出视口,用完立即移除
|
|
5
|
+
* (避免"每次复制在 body 残留节点、并把键盘焦点留在残留节点上,之后按 Ctrl+C 复制到旧内容")。
|
|
6
|
+
* 返回是否写入成功;失败时调用方应保留选区并提示用户用 Ctrl+C 重试。
|
|
7
|
+
*/
|
|
8
|
+
export declare const writeClipboard: (text: string) => Promise<boolean>;
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* 表格「框选复制」的纯逻辑:单元格取值 → TSV,以及要排除的列判定。
|
|
3
|
+
* 零依赖、不碰 React,便于用 jsdom 做单测(见 __tests__/rangeCopy.test.ts)。
|
|
4
|
+
*/
|
|
5
|
+
export declare const DATA_ROW_SELECTOR = "tr.ant-table-row";
|
|
6
|
+
export interface RangeCopyResult {
|
|
7
|
+
/** 制表符分隔的文本,行间以 \r\n 分隔 */
|
|
8
|
+
text: string;
|
|
9
|
+
rowCount: number;
|
|
10
|
+
colCount: number;
|
|
11
|
+
}
|
|
12
|
+
/** 选区里真正会被复制的列(按列序);勾选列/操作列等被排除的列不占位 */
|
|
13
|
+
export declare const getIncludedCols: (colStart: number, colEnd: number, excludeCols?: Set<number>) => number[];
|
|
14
|
+
export declare const buildRangeCopy: (rows: HTMLTableRowElement[], colStart: number, colEnd: number, excludeCols?: Set<number>) => RangeCopyResult;
|
|
15
|
+
/**
|
|
16
|
+
* 判定要排除的列下标:勾选列始终排除,另外按表头文本排除(默认由调用方传入「操作」)。
|
|
17
|
+
* 用表头最后一行(叶子表头)定位,因此用户隐藏/调整列序后依然按当前渲染结果生效;
|
|
18
|
+
* 表头缺失时退化为用数据行找勾选列。
|
|
19
|
+
*/
|
|
20
|
+
export declare const resolveExcludeCols: (tbody: HTMLTableSectionElement, titles: string[]) => Set<number>;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/// <reference types="react" />
|
|
2
|
+
import './rangeCopy.less';
|
|
3
|
+
export interface UseRangeCopyOptions {
|
|
4
|
+
/** 是否启用(默认 true)。虚拟滚动表只渲染可视行、DOM 取不到整段选区,应传 false */
|
|
5
|
+
enabled?: boolean;
|
|
6
|
+
/** 按表头文本排除的列,默认排除「操作」列;勾选列始终排除 */
|
|
7
|
+
excludeTitles?: string[];
|
|
8
|
+
/** 框选结束是否自动写入剪贴板(默认 true);false 时仍支持框选后 Ctrl+C */
|
|
9
|
+
autoCopy?: boolean;
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* 表格「Excel 式框选复制」。返回容器 ref,挂到表格容器上即可(BsSulaQueryTable 挂在 #bs-sula-query-table)。
|
|
13
|
+
* 实现要点:事件委托 + 单个挂进滚动容器的高亮层(随内容滚动,不依赖 scroll 事件补帧),
|
|
14
|
+
* 全程只用 ref、不改表格内任何单元格、不触发 React 重渲染。
|
|
15
|
+
*/
|
|
16
|
+
export declare const useRangeCopy: (options?: UseRangeCopyOptions) => import("react").RefObject<HTMLDivElement>;
|