@visactor/vtable-plugins 1.19.0-alpha.0 → 1.19.0
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/cjs/fillHandleUtils/autoFillHandle.d.ts +11 -0
- package/cjs/fillHandleUtils/autoFillHandle.js +112 -0
- package/cjs/fillHandleUtils/autoFillHandle.js.map +1 -0
- package/cjs/fillHandleUtils/translateRowObj.d.ts +5 -0
- package/cjs/fillHandleUtils/translateRowObj.js +15 -0
- package/cjs/fillHandleUtils/translateRowObj.js.map +1 -0
- package/cjs/index.d.ts +1 -0
- package/cjs/index.js +1 -1
- package/cjs/index.js.map +1 -1
- package/cjs/wps-fill-handle.d.ts +21 -0
- package/cjs/wps-fill-handle.js +100 -0
- package/cjs/wps-fill-handle.js.map +1 -0
- package/dist/vtable-plugins.js +3611 -128
- package/dist/vtable-plugins.min.js +1 -1
- package/es/fillHandleUtils/autoFillHandle.d.ts +11 -0
- package/es/fillHandleUtils/autoFillHandle.js +106 -0
- package/es/fillHandleUtils/autoFillHandle.js.map +1 -0
- package/es/fillHandleUtils/translateRowObj.d.ts +5 -0
- package/es/fillHandleUtils/translateRowObj.js +8 -0
- package/es/fillHandleUtils/translateRowObj.js.map +1 -0
- package/es/index.d.ts +1 -0
- package/es/index.js +2 -0
- package/es/index.js.map +1 -1
- package/es/wps-fill-handle.d.ts +21 -0
- package/es/wps-fill-handle.js +69 -0
- package/es/wps-fill-handle.js.map +1 -0
- package/package.json +9 -6
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { RowObject, RowData } from './translateRowObj';
|
|
2
|
+
import type * as VTable from '@visactor/vtable';
|
|
3
|
+
export declare const generateAutoFillData: (originalData: RowObject[] | RowData[][], columns: VTable.TYPES.CellInfo[], startRange: {
|
|
4
|
+
startRow: number;
|
|
5
|
+
startCol: number;
|
|
6
|
+
endRow: number;
|
|
7
|
+
endCol: number;
|
|
8
|
+
}, currentEnd: {
|
|
9
|
+
row: number;
|
|
10
|
+
col: number;
|
|
11
|
+
}) => RowObject[] | RowData[][];
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __importDefault = this && this.__importDefault || function(mod) {
|
|
4
|
+
return mod && mod.__esModule ? mod : {
|
|
5
|
+
default: mod
|
|
6
|
+
};
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
Object.defineProperty(exports, "__esModule", {
|
|
10
|
+
value: !0
|
|
11
|
+
}), exports.generateAutoFillData = void 0;
|
|
12
|
+
|
|
13
|
+
const big_js_1 = __importDefault(require("big.js")), isEqual_1 = __importDefault(require("lodash/isEqual")), isNumber_1 = __importDefault(require("lodash/isNumber")), isObject_1 = __importDefault(require("lodash/isObject")), translateRowObj_1 = require("./translateRowObj"), bigFunc = (a, b, func) => {
|
|
14
|
+
if ("number" != typeof a && (a = Number(a)), "number" != typeof b && (b = Number(b)),
|
|
15
|
+
Number.isNaN(a) || Number.isNaN(b)) throw new Error(`${func}(a, b), a or b is NaN`);
|
|
16
|
+
return new big_js_1.default(a)[func](b).toNumber();
|
|
17
|
+
}, add = (a = 0, b = 0) => bigFunc(a, b, "plus"), minus = (a = 0, b = 0) => bigFunc(a, b, "minus");
|
|
18
|
+
|
|
19
|
+
function splitOnLastNumber(str) {
|
|
20
|
+
const match = str.match(/((\d+)(\.\d+)?)(?!.*(\d+)(\.\d+)?)/);
|
|
21
|
+
if (!match || void 0 === match.index) return [ str ];
|
|
22
|
+
const index = match.index, number = match[0];
|
|
23
|
+
return [ str.slice(0, index), number, str.slice(index + number.length) ].filter((item => "" !== item));
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
const parseValue = value => {
|
|
27
|
+
if ("number" == typeof value) return {
|
|
28
|
+
prefix: "",
|
|
29
|
+
number: value,
|
|
30
|
+
full: value
|
|
31
|
+
};
|
|
32
|
+
const match = splitOnLastNumber(value), numberIndex = match.findIndex((str => !isNaN(Number(str)) && "" !== str && !isNaN(parseFloat(str)) && isFinite(Number(str))));
|
|
33
|
+
return 1 === match.length ? 0 === numberIndex ? {
|
|
34
|
+
prefix: "",
|
|
35
|
+
number: Number(match[0]),
|
|
36
|
+
suffix: "",
|
|
37
|
+
full: value
|
|
38
|
+
} : {
|
|
39
|
+
prefix: value,
|
|
40
|
+
number: null,
|
|
41
|
+
suffix: "",
|
|
42
|
+
full: value
|
|
43
|
+
} : match.length > 1 ? 0 === numberIndex ? {
|
|
44
|
+
prefix: "",
|
|
45
|
+
number: Number(match[0]),
|
|
46
|
+
suffix: match[1],
|
|
47
|
+
full: value
|
|
48
|
+
} : {
|
|
49
|
+
prefix: match[0],
|
|
50
|
+
number: Number(match[1]),
|
|
51
|
+
suffix: null == match ? void 0 : match[2],
|
|
52
|
+
full: value
|
|
53
|
+
} : {
|
|
54
|
+
prefix: null,
|
|
55
|
+
number: null,
|
|
56
|
+
suffix: null,
|
|
57
|
+
full: value
|
|
58
|
+
};
|
|
59
|
+
}, generateAutoFillData = (originalData, columns, startRange, currentEnd) => {
|
|
60
|
+
if (!originalData || originalData.length < startRange.endRow - 1) return [];
|
|
61
|
+
let newData = [];
|
|
62
|
+
if (Array.isArray(null == originalData ? void 0 : originalData[0]) ? newData = originalData.map((row => [ ...row ])) : columns.length && (0,
|
|
63
|
+
isObject_1.default)(null == originalData ? void 0 : originalData[0]) && (newData = (0,
|
|
64
|
+
translateRowObj_1.translateRowObjToArray)(originalData, columns)), !(null == newData ? void 0 : newData.length)) return originalData;
|
|
65
|
+
const verticalDelta = currentEnd.row - startRange.endRow, horizontalDelta = currentEnd.col - startRange.endCol, isVertical = Math.abs(verticalDelta) >= Math.abs(horizontalDelta), fillSteps = isVertical ? verticalDelta : horizontalDelta, [sampleStartRow, sampleEndRow] = [ startRange.startRow, startRange.endRow ].sort(((a, b) => a - b)), [sampleStartCol, sampleEndCol] = [ startRange.startCol, startRange.endCol ].sort(((a, b) => a - b)), sampleValues = [];
|
|
66
|
+
for (let r = sampleStartRow; r <= sampleEndRow; r++) for (let c = sampleStartCol; c <= sampleEndCol; c++) sampleValues.push(newData[r][c]);
|
|
67
|
+
const samples = sampleValues.map(parseValue), validSequence = samples.every((s => null !== s.number)) && samples.slice(1).every(((s, i) => s.prefix === samples[i].prefix)) && samples.length < 3 && !(2 === samples.length && (0,
|
|
68
|
+
isEqual_1.default)(samples[0], samples[1]));
|
|
69
|
+
let step;
|
|
70
|
+
if (1 === samples.length && null !== samples[0].number) step = 1; else if (validSequence && samples.length > 1) {
|
|
71
|
+
const numbers = samples.map((s => s.number));
|
|
72
|
+
step = minus(numbers[numbers.length - 1], numbers[numbers.length - 2]);
|
|
73
|
+
}
|
|
74
|
+
const positionInEdges = curPos => isVertical && verticalDelta > 0 ? curPos.row <= currentEnd.row : isVertical && verticalDelta < 0 ? curPos.row >= currentEnd.row : !isVertical && horizontalDelta > 0 ? curPos.col <= currentEnd.col : !isVertical && horizontalDelta < 0 && curPos.col >= currentEnd.col, totalSteps = Math.abs(fillSteps), direction = fillSteps > 0 ? 1 : -1, sampLength = samples.length;
|
|
75
|
+
if (1 === samples.length) {
|
|
76
|
+
const sample = samples[0];
|
|
77
|
+
for (let i = 1; i <= totalSteps; i++) {
|
|
78
|
+
const pos = {
|
|
79
|
+
row: isVertical ? startRange.endRow + direction * i : startRange.startRow,
|
|
80
|
+
col: isVertical ? startRange.startCol : startRange.endCol + direction * i
|
|
81
|
+
};
|
|
82
|
+
if (pos.row >= 0 && pos.col >= 0 && positionInEdges(pos)) {
|
|
83
|
+
let tempRes = (0, isNumber_1.default)(sample.number) ? `${sample.prefix || ""}${((null == sample ? void 0 : sample.number) || 0) + (direction > 0 ? i : -i)}${sample.suffix || ""}` : sample.full;
|
|
84
|
+
(0, isNumber_1.default)(sample.full) && (tempRes = ((null == sample ? void 0 : sample.number) || 0) + (direction > 0 ? i : -i)),
|
|
85
|
+
newData[pos.row][pos.col] = tempRes;
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
} else if (samples.length >= 2) for (let i = 1; i <= totalSteps; i++) {
|
|
89
|
+
let sample;
|
|
90
|
+
const pos = {
|
|
91
|
+
row: 0,
|
|
92
|
+
col: 0
|
|
93
|
+
};
|
|
94
|
+
if (1 === direction ? (pos.row = isVertical ? startRange.endRow + direction * i : startRange.endRow,
|
|
95
|
+
pos.col = isVertical ? startRange.endCol : startRange.endCol + direction * i, sample = samples[(i - 1) % sampLength]) : (pos.row = isVertical ? startRange.startRow + direction * i : startRange.startRow,
|
|
96
|
+
pos.col = isVertical ? startRange.startCol : startRange.startCol + direction * i,
|
|
97
|
+
sample = samples[Math.abs(sampLength - i) % sampLength]), pos.row >= 0 && pos.col >= 0 && positionInEdges(pos)) {
|
|
98
|
+
let tempRes;
|
|
99
|
+
if ((0, isNumber_1.default)(sample.full) || Number(sample.full) === Number(sample.number) && 2 === sampLength) {
|
|
100
|
+
const deltaLength = sampLength + Math.floor((i - 1) / sampLength) * sampLength;
|
|
101
|
+
tempRes = add((null == sample ? void 0 : sample.number) || 0, direction > 0 ? (step || 1) * deltaLength : -(step || 1) * deltaLength);
|
|
102
|
+
} else tempRes = validSequence ? `${sample.prefix || ""}${add((null == sample ? void 0 : sample.number) || 0, direction > 0 ? (step || 1) * sampLength : -(step || 1) * sampLength)}${sample.suffix || ""}` : (0,
|
|
103
|
+
isNumber_1.default)(null == sample ? void 0 : sample.number) ? `${sample.prefix || ""}${add((null == sample ? void 0 : sample.number) || 0, direction > 0 ? Math.floor((i - 1) / sampLength) + 1 : -(Math.floor((i - 1) / sampLength) + 1))}${sample.suffix || ""}` : sample.full;
|
|
104
|
+
newData[pos.row][pos.col] = tempRes;
|
|
105
|
+
}
|
|
106
|
+
}
|
|
107
|
+
return Array.isArray(null == originalData ? void 0 : originalData[0]) ? newData : (0,
|
|
108
|
+
translateRowObj_1.translateRowArrayToObj)(newData, columns);
|
|
109
|
+
};
|
|
110
|
+
|
|
111
|
+
exports.generateAutoFillData = generateAutoFillData;
|
|
112
|
+
//# sourceMappingURL=autoFill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AAsB,EAAC,OAAO,EAAE,OAAO,CAAC,CAAC;AAClD,CAAC,CAAC;AApIW,QAAA,oBAAoB,wBAoI/B","file":"autoFillHandle.js","sourcesContent":["/**\n * 生成填充柄自动填充数据,引入big.js是为了处理大数填充的问题,防止溢出,引入lodash为了处理records中值为数字、文本的不同情况\n */\n// @ts-ignore no need check\nimport Big from 'big.js';\nimport isEqual from 'lodash/isEqual';\nimport isNumber from 'lodash/isNumber';\nimport isObject from 'lodash/isObject';\nimport type { RowObject, RowData } from './translateRowObj';\nimport { translateRowArrayToObj, translateRowObjToArray } from './translateRowObj';\nimport type * as VTable from '@visactor/vtable';\n\nconst bigFunc = (a: string | number, b: string | number, func: 'plus' | 'minus' | 'times' | 'div') => {\n if (typeof a !== 'number') {\n a = Number(a);\n }\n if (typeof b !== 'number') {\n b = Number(b);\n }\n if (Number.isNaN(a) || Number.isNaN(b)) {\n throw new Error(`${func}(a, b), a or b is NaN`);\n }\n\n const bigA = new Big(a);\n return bigA[func](b).toNumber();\n};\nconst add = (a: number | string = 0, b: number | string = 0) => bigFunc(a, b, 'plus');\nconst minus = (a: number | string = 0, b: number | string = 0) => bigFunc(a, b, 'minus');\n\n/**\n * 将字符串拆为前缀,数字部分,后缀,方便填充柄的自增/减计算\n * @example\n * splitOnLastNumber('ab12.4c') => ['ab', '12.4', 'c']\n * splitOnLastNumber('ab12c') => ['ab', '12', 'c']\n * splitOnLastNumber('abc') => ['abc']\n * splitOnLastNumber('12abc') => ['','12','abc']\n * @param {string} str\n * @returns {string[]} [prefix, number, suffix]\n */\nfunction splitOnLastNumber(str: string) {\n const regex = /((\\d+)(\\.\\d+)?)(?!.*(\\d+)(\\.\\d+)?)/;\n const match = str.match(regex);\n if (!match || match.index === undefined) {\n return [str];\n } // 无数字时返回原字符串\n\n const index = match.index;\n const number = match[0];\n const prefix = str.slice(0, index);\n const suffix = str.slice(index + number.length);\n\n return [prefix, number, suffix].filter(item => item !== '');\n}\n\n/**\n * 解析字符串为 prefix, number, suffix三个部分,如\"ab12.4c\" 将被解析为{ prefix: 'ab', number: 12.4, suffix: 'c', full: 'ab12.4c' }\n * @param {string} value - 需要解析的字符串\n * @returns {Object} { prefix, number, suffix, full }\n * - prefix: 字符串前缀\n * - number: 字符串中的数字部分,可能为null\n * - suffix: 字符串后缀\n * - full: 原始字符串\n */\nconst parseValue = (value: RowData) => {\n if (typeof value === 'number') {\n return { prefix: '', number: value, full: value };\n }\n const match = splitOnLastNumber(value);\n const numberIndex = match.findIndex(str => {\n return !isNaN(Number(str)) && str !== '' && !isNaN(parseFloat(str)) && isFinite(Number(str));\n });\n if (match.length === 1) {\n if (numberIndex === 0) {\n // \"12\"这种类型字符串\n return { prefix: '', number: Number(match[0]), suffix: '', full: value };\n }\n // \"ab\"这种类型字符串\n return { prefix: value, number: null, suffix: '', full: value };\n } else if (match.length > 1) {\n if (numberIndex === 0) {\n // \"12abc\"这种字符串\n return { prefix: '', number: Number(match[0]), suffix: match[1], full: value };\n }\n // “ab12.3”或者“ab12.3bc”这种字符串\n return { prefix: match[0], number: Number(match[1]), suffix: match?.[2], full: value };\n }\n return { prefix: null, number: null, suffix: null, full: value };\n};\n\n/**\n * VTable模仿excel填充柄\n * @param originalData 表格原始数据,可能为数组形式或者对象形式,比如[[dataIndex1,dataIndex2],[dataIndex1,dataIndex2]],[{dataIndex1,dataIndex2},{dataIndex3,dataIndex4}]\n * @param columns 列信息\n * @param startRange 填充柄选区\n * @param currentEnd 填充柄待填充终点\n * @returns 经填充柄填充后的数据\n */\n\nexport const generateAutoFillData = (\n originalData: RowObject[] | RowData[][],\n columns: VTable.TYPES.CellInfo[],\n startRange: { startRow: number; startCol: number; endRow: number; endCol: number }, // 初始选区 { startRow, startCol, endRow, endCol }\n currentEnd: { row: number; col: number } // 当前拖拽终点 { row, col },\n) => {\n if (!originalData || originalData.length < startRange.endRow - 1) {\n return [];\n }\n // 深拷贝原始数据,并且将行数据转换为数组形式,方便后续处理\n let newData: RowData[][] = [];\n if (Array.isArray(originalData?.[0])) {\n newData = (originalData as RowData[][]).map(row => [...row]);\n } else if (columns.length && isObject(originalData?.[0])) {\n newData = translateRowObjToArray(originalData as RowObject[], columns);\n }\n if (!newData?.length) {\n return originalData;\n }\n\n // 方向计算\n const verticalDelta = currentEnd.row - startRange.endRow;\n const horizontalDelta = currentEnd.col - startRange.endCol;\n const isVertical = Math.abs(verticalDelta) >= Math.abs(horizontalDelta);\n const fillSteps = isVertical ? verticalDelta : horizontalDelta;\n\n // 样本数据提取\n const [sampleStartRow, sampleEndRow] = [startRange.startRow, startRange.endRow].sort((a, b) => a - b);\n const [sampleStartCol, sampleEndCol] = [startRange.startCol, startRange.endCol].sort((a, b) => a - b);\n const sampleValues = [];\n for (let r = sampleStartRow; r <= sampleEndRow; r++) {\n for (let c = sampleStartCol; c <= sampleEndCol; c++) {\n sampleValues.push(newData[r][c]);\n }\n }\n\n // 验证数字序列\n const samples = sampleValues.map(parseValue);\n const validSequence =\n samples.every(s => s.number !== null) &&\n samples.slice(1).every((s, i) => s.prefix === samples[i].prefix) &&\n samples.length < 3 &&\n !(samples.length === 2 && isEqual(samples[0], samples[1]));\n\n // 计算步长\n let step;\n if (samples.length === 1 && samples[0].number !== null) {\n step = 1;\n } else if (validSequence && samples.length > 1) {\n const numbers = samples.map(s => s.number);\n step = minus(numbers[numbers.length - 1], numbers[numbers.length - 2]);\n }\n // 边界检测\n const positionInEdges = (curPos: { row: number; col: number }) => {\n if (isVertical && verticalDelta > 0) {\n return curPos.row <= currentEnd.row;\n } else if (isVertical && verticalDelta < 0) {\n return curPos.row >= currentEnd.row;\n } else if (!isVertical && horizontalDelta > 0) {\n return curPos.col <= currentEnd.col;\n } else if (!isVertical && horizontalDelta < 0) {\n return curPos.col >= currentEnd.col;\n }\n return false;\n };\n\n // 执行填充\n const totalSteps = Math.abs(fillSteps);\n const direction = fillSteps > 0 ? 1 : -1;\n\n const sampLength = samples.length;\n if (samples.length === 1) {\n // 选中单个单元格的填充,有数字直接+1或-1,无数字直接复制文本\n const sample = samples[0];\n for (let i = 1; i <= totalSteps; i++) {\n const pos = {\n row: isVertical ? startRange.endRow + direction * i : startRange.startRow,\n col: isVertical ? startRange.startCol : startRange.endCol + direction * i\n };\n if (pos.row >= 0 && pos.col >= 0 && positionInEdges(pos)) {\n let tempRes = isNumber(sample.number)\n ? `${sample.prefix || ''}${(sample?.number || 0) + (direction > 0 ? i : -i)}${sample.suffix || ''}`\n : sample.full;\n if (isNumber(sample.full)) {\n tempRes = (sample?.number || 0) + (direction > 0 ? i : -i);\n }\n\n newData[pos.row][pos.col] = tempRes; // 直接复制最后一个值\n }\n }\n } else if (samples.length >= 2) {\n for (let i = 1; i <= totalSteps; i++) {\n let sample;\n const pos: { row: number; col: number } = { row: 0, col: 0 };\n if (direction === 1) {\n // 向下、向右填充计算位置和基准值\n pos.row = isVertical ? startRange.endRow + direction * i : startRange.endRow;\n pos.col = isVertical ? startRange.endCol : startRange.endCol + direction * i;\n sample = samples[(i - 1) % sampLength];\n } else {\n // 向上、向左填充计算位置和基准值\n pos.row = isVertical ? startRange.startRow + direction * i : startRange.startRow;\n pos.col = isVertical ? startRange.startCol : startRange.startCol + direction * i;\n sample = samples[Math.abs(sampLength - i) % sampLength];\n }\n if (pos.row >= 0 && pos.col >= 0 && positionInEdges(pos)) {\n let tempRes;\n if (isNumber(sample.full) || (Number(sample.full) === Number(sample.number) && sampLength === 2)) {\n const deltaLength = sampLength + Math.floor((i - 1) / sampLength) * sampLength;\n tempRes = add(sample?.number || 0, direction > 0 ? (step || 1) * deltaLength : -(step || 1) * deltaLength);\n } else {\n tempRes = validSequence\n ? `${sample.prefix || ''}${add(\n sample?.number || 0,\n direction > 0 ? (step || 1) * sampLength : -(step || 1) * sampLength\n )}${sample.suffix || ''}`\n : isNumber(sample?.number)\n ? `${sample.prefix || ''}${add(\n sample?.number || 0,\n direction > 0 ? Math.floor((i - 1) / sampLength) + 1 : -(Math.floor((i - 1) / sampLength) + 1)\n )}${sample.suffix || ''}`\n : sample.full; // 直接复制最后一个值\n }\n newData[pos.row][pos.col] = tempRes;\n }\n }\n }\n\n if (Array.isArray(originalData?.[0])) {\n return newData;\n }\n return translateRowArrayToObj(newData, columns);\n};\n"]}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type * as VTable from '@visactor/vtable';
|
|
2
|
+
export type RowData = number | string;
|
|
3
|
+
export type RowObject = Record<string, RowData>;
|
|
4
|
+
export declare function translateRowObjToArray(dataSource: RowObject[], columns: VTable.TYPES.CellInfo[]): RowData[][];
|
|
5
|
+
export declare function translateRowArrayToObj(dataSource: RowData[][], columns: VTable.TYPES.CellInfo[]): RowObject[];
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
function translateRowObjToArray(dataSource, columns) {
|
|
4
|
+
return dataSource.map((item => columns.map((column => item[column.field]))));
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function translateRowArrayToObj(dataSource, columns) {
|
|
8
|
+
return dataSource.map((item => columns.reduce(((pre, cur, index) => (pre[cur.field] = item[index],
|
|
9
|
+
pre)), {})));
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
Object.defineProperty(exports, "__esModule", {
|
|
13
|
+
value: !0
|
|
14
|
+
}), exports.translateRowArrayToObj = exports.translateRowObjToArray = void 0, exports.translateRowObjToArray = translateRowObjToArray,
|
|
15
|
+
exports.translateRowArrayToObj = translateRowArrayToObj;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["fillHandleUtils/translateRowObj.ts"],"names":[],"mappings":";;;AAMA,SAAgB,sBAAsB,CAAC,UAAuB,EAAE,OAAgC;IAC9F,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC3B,OAAO,OAAO,CAAC,GAAG,CAAC,MAAM,CAAC,EAAE;YAC1B,OAAO,IAAI,CAAC,MAAM,CAAC,KAAe,CAAC,CAAC;QACtC,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;AACL,CAAC;AAND,wDAMC;AAKD,SAAgB,sBAAsB,CAAC,UAAuB,EAAE,OAAgC;IAC9F,OAAO,UAAU,CAAC,GAAG,CAAC,IAAI,CAAC,EAAE;QAC3B,OAAO,OAAO,CAAC,MAAM,CAAC,CAAC,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;YACxC,GAAG,CAAC,GAAG,CAAC,KAAe,CAAC,GAAG,IAAI,CAAC,KAAK,CAAC,CAAC;YACvC,OAAO,GAAG,CAAC;QACb,CAAC,EAAE,EAAe,CAAC,CAAC;IACtB,CAAC,CAAC,CAAC;AACL,CAAC;AAPD,wDAOC","file":"translateRowObj.js","sourcesContent":["import type * as VTable from '@visactor/vtable';\nexport type RowData = number | string;\nexport type RowObject = Record<string, RowData>;\n/**\n * 将 dataSource中的{field1:xx1,field2:xx2,field3:xx3} 转换成 [xx1,xx2,xx3]\n */\nexport function translateRowObjToArray(dataSource: RowObject[], columns: VTable.TYPES.CellInfo[]) {\n return dataSource.map(item => {\n return columns.map(column => {\n return item[column.field as string];\n });\n });\n}\n\n/**\n * 将 dataSource中的[xx1,xx2,xx3] 转换成 {field1:xx1,field2:xx2,field3:xx3}\n */\nexport function translateRowArrayToObj(dataSource: RowData[][], columns: VTable.TYPES.CellInfo[]) {\n return dataSource.map(item => {\n return columns.reduce((pre, cur, index) => {\n pre[cur.field as string] = item[index];\n return pre;\n }, {} as RowObject);\n });\n}\n"]}
|
package/cjs/index.d.ts
CHANGED
package/cjs/index.js
CHANGED
|
@@ -23,5 +23,5 @@ __exportStar(require("./column-series"), exports), __exportStar(require("./row-s
|
|
|
23
23
|
__exportStar(require("./highlight-header-when-select-cell"), exports), __exportStar(require("./excel-edit-cell-keyboard"), exports),
|
|
24
24
|
__exportStar(require("./types"), exports), __exportStar(require("./focus-highlight"), exports),
|
|
25
25
|
__exportStar(require("./table-carousel-animation"), exports), __exportStar(require("./rotate-table"), exports),
|
|
26
|
-
__exportStar(require("./gantt-export-image"), exports);
|
|
26
|
+
__exportStar(require("./gantt-export-image"), exports), __exportStar(require("./wps-fill-handle"), exports);
|
|
27
27
|
//# sourceMappingURL=index.js.map
|
package/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,qDAAmC;AACnC,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,sEAAoD;AACpD,6DAA2C;AAC3C,0CAAwB;AACxB,oDAAkC;AAClC,6DAA2C;AAC3C,iDAA+B;AAC/B,uDAAqC","file":"index.js","sourcesContent":["export * from './carousel-animation';\nexport * from './invert-highlight';\nexport * from './header-highlight';\nexport * from './add-row-column';\nexport * from './column-series';\nexport * from './row-series';\nexport * from './highlight-header-when-select-cell';\nexport * from './excel-edit-cell-keyboard';\nexport * from './types';\nexport * from './focus-highlight';\nexport * from './table-carousel-animation';\nexport * from './rotate-table';\nexport * from './gantt-export-image';\n"]}
|
|
1
|
+
{"version":3,"sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAqC;AACrC,qDAAmC;AACnC,qDAAmC;AACnC,mDAAiC;AACjC,kDAAgC;AAChC,+CAA6B;AAC7B,sEAAoD;AACpD,6DAA2C;AAC3C,0CAAwB;AACxB,oDAAkC;AAClC,6DAA2C;AAC3C,iDAA+B;AAC/B,uDAAqC;AACrC,oDAAkC","file":"index.js","sourcesContent":["export * from './carousel-animation';\nexport * from './invert-highlight';\nexport * from './header-highlight';\nexport * from './add-row-column';\nexport * from './column-series';\nexport * from './row-series';\nexport * from './highlight-header-when-select-cell';\nexport * from './excel-edit-cell-keyboard';\nexport * from './types';\nexport * from './focus-highlight';\nexport * from './table-carousel-animation';\nexport * from './rotate-table';\nexport * from './gantt-export-image';\nexport * from './wps-fill-handle';\n"]}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
import * as VTable from '@visactor/vtable';
|
|
2
|
+
import type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';
|
|
3
|
+
import type { EventArg } from './types';
|
|
4
|
+
export type IWpsFillHandlePluginOptions = {
|
|
5
|
+
id?: string;
|
|
6
|
+
};
|
|
7
|
+
export declare class WpsFillHandlePlugin implements VTable.plugins.IVTablePlugin {
|
|
8
|
+
id: string;
|
|
9
|
+
name: string;
|
|
10
|
+
runTime: ("mousedown_fill_handle" | "drag_fill_handle_end")[];
|
|
11
|
+
table: VTable.ListTable;
|
|
12
|
+
pluginOptions: IWpsFillHandlePluginOptions;
|
|
13
|
+
beforeDragMinCol: number;
|
|
14
|
+
beforeDragMinRow: number;
|
|
15
|
+
beforeDragMaxCol: number;
|
|
16
|
+
beforeDragMaxRow: number;
|
|
17
|
+
constructor(pluginOptions?: IWpsFillHandlePluginOptions);
|
|
18
|
+
run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], VTable.BaseTableAPI]): void;
|
|
19
|
+
handleKeyDown(): void;
|
|
20
|
+
release(): void;
|
|
21
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
|
|
3
|
+
var __createBinding = this && this.__createBinding || (Object.create ? function(o, m, k, k2) {
|
|
4
|
+
void 0 === k2 && (k2 = k);
|
|
5
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
6
|
+
desc && !("get" in desc ? !m.__esModule : desc.writable || desc.configurable) || (desc = {
|
|
7
|
+
enumerable: !0,
|
|
8
|
+
get: function() {
|
|
9
|
+
return m[k];
|
|
10
|
+
}
|
|
11
|
+
}), Object.defineProperty(o, k2, desc);
|
|
12
|
+
} : function(o, m, k, k2) {
|
|
13
|
+
void 0 === k2 && (k2 = k), o[k2] = m[k];
|
|
14
|
+
}), __setModuleDefault = this && this.__setModuleDefault || (Object.create ? function(o, v) {
|
|
15
|
+
Object.defineProperty(o, "default", {
|
|
16
|
+
enumerable: !0,
|
|
17
|
+
value: v
|
|
18
|
+
});
|
|
19
|
+
} : function(o, v) {
|
|
20
|
+
o.default = v;
|
|
21
|
+
}), __importStar = this && this.__importStar || function(mod) {
|
|
22
|
+
if (mod && mod.__esModule) return mod;
|
|
23
|
+
var result = {};
|
|
24
|
+
if (null != mod) for (var k in mod) "default" !== k && Object.prototype.hasOwnProperty.call(mod, k) && __createBinding(result, mod, k);
|
|
25
|
+
return __setModuleDefault(result, mod), result;
|
|
26
|
+
};
|
|
27
|
+
|
|
28
|
+
Object.defineProperty(exports, "__esModule", {
|
|
29
|
+
value: !0
|
|
30
|
+
}), exports.WpsFillHandlePlugin = void 0;
|
|
31
|
+
|
|
32
|
+
const VTable = __importStar(require("@visactor/vtable")), autoFillHandle_1 = require("./fillHandleUtils/autoFillHandle");
|
|
33
|
+
|
|
34
|
+
class WpsFillHandlePlugin {
|
|
35
|
+
constructor(pluginOptions) {
|
|
36
|
+
var _a;
|
|
37
|
+
this.id = `wps-fill-handle-${Date.now()}`, this.name = "WPS Fill Handle", this.runTime = [ VTable.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE, VTable.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END ],
|
|
38
|
+
this.beforeDragMinCol = 0, this.beforeDragMinRow = 0, this.beforeDragMaxCol = 0,
|
|
39
|
+
this.beforeDragMaxRow = 0, this.id = null !== (_a = null == pluginOptions ? void 0 : pluginOptions.id) && void 0 !== _a ? _a : this.id,
|
|
40
|
+
this.pluginOptions = pluginOptions;
|
|
41
|
+
}
|
|
42
|
+
run(...args) {
|
|
43
|
+
var _a, _b, _c, _d, _e;
|
|
44
|
+
if (args[1] === VTable.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE) {
|
|
45
|
+
args[0];
|
|
46
|
+
const table = args[2];
|
|
47
|
+
this.table = table;
|
|
48
|
+
const startSelectCellRange = null === (_a = this.table) || void 0 === _a ? void 0 : _a.getSelectedCellRanges()[0];
|
|
49
|
+
if (!startSelectCellRange) return;
|
|
50
|
+
this.beforeDragMaxCol = Math.max(startSelectCellRange.start.col, startSelectCellRange.end.col),
|
|
51
|
+
this.beforeDragMinCol = Math.min(startSelectCellRange.start.col, startSelectCellRange.end.col),
|
|
52
|
+
this.beforeDragMaxRow = Math.max(startSelectCellRange.start.row, startSelectCellRange.end.row),
|
|
53
|
+
this.beforeDragMinRow = Math.min(startSelectCellRange.start.row, startSelectCellRange.end.row);
|
|
54
|
+
} else if (args[1] === VTable.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END) {
|
|
55
|
+
const direction = args[0].direction;
|
|
56
|
+
let endChangeCellCol, endChangeCellRow;
|
|
57
|
+
const endSelectCellRange = null === (_b = this.table) || void 0 === _b ? void 0 : _b.getSelectedCellRanges()[0];
|
|
58
|
+
if (!endSelectCellRange) return;
|
|
59
|
+
"bottom" === direction ? (endChangeCellCol = this.beforeDragMaxCol, endChangeCellRow = endSelectCellRange.end.row) : "right" === direction ? (endChangeCellCol = endSelectCellRange.end.col,
|
|
60
|
+
endChangeCellRow = this.beforeDragMaxRow) : "top" === direction ? (endChangeCellCol = this.beforeDragMaxCol,
|
|
61
|
+
endChangeCellRow = endSelectCellRange.end.row) : "left" === direction && (endChangeCellCol = endSelectCellRange.end.col,
|
|
62
|
+
endChangeCellRow = this.beforeDragMaxRow);
|
|
63
|
+
const rowDatas = null === (_c = this.table) || void 0 === _c ? void 0 : _c.records, tableColumns = (null === (_d = this.table) || void 0 === _d ? void 0 : _d.getAllColumnHeaderCells()) || [];
|
|
64
|
+
let highestColumns = [];
|
|
65
|
+
(null == tableColumns ? void 0 : tableColumns.length) && (highestColumns = tableColumns[tableColumns.length - 1]);
|
|
66
|
+
const newDatas = (0, autoFillHandle_1.generateAutoFillData)(rowDatas, highestColumns, {
|
|
67
|
+
startRow: this.beforeDragMinRow - tableColumns.length,
|
|
68
|
+
startCol: this.beforeDragMinCol,
|
|
69
|
+
endRow: this.beforeDragMaxRow - tableColumns.length,
|
|
70
|
+
endCol: this.beforeDragMaxCol
|
|
71
|
+
}, {
|
|
72
|
+
row: endChangeCellRow - tableColumns.length,
|
|
73
|
+
col: endChangeCellCol
|
|
74
|
+
});
|
|
75
|
+
null === (_e = this.table) || void 0 === _e || _e.setRecords(newDatas);
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
handleKeyDown() {
|
|
79
|
+
var _a;
|
|
80
|
+
if (this.table.editorManager) {
|
|
81
|
+
const startSelectCellRange = null === (_a = this.table) || void 0 === _a ? void 0 : _a.getSelectedCellRanges()[0];
|
|
82
|
+
if (!startSelectCellRange) return;
|
|
83
|
+
this.beforeDragMaxCol = Math.max(startSelectCellRange.start.col, startSelectCellRange.end.col),
|
|
84
|
+
this.beforeDragMinCol = Math.min(startSelectCellRange.start.col, startSelectCellRange.end.col),
|
|
85
|
+
this.beforeDragMaxRow = Math.max(startSelectCellRange.start.row, startSelectCellRange.end.row),
|
|
86
|
+
this.beforeDragMinRow = Math.min(startSelectCellRange.start.row, startSelectCellRange.end.row);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
release() {
|
|
90
|
+
this.beforeDragMinCol = 0, this.beforeDragMinRow = 0, this.beforeDragMaxCol = 0,
|
|
91
|
+
this.beforeDragMaxRow = 0;
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
function deleteSelectRange(selectCells, tableInstance) {
|
|
96
|
+
for (let i = 0; i < selectCells.length; i++) for (let j = 0; j < selectCells[i].length; j++) tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, "");
|
|
97
|
+
}
|
|
98
|
+
|
|
99
|
+
//# sourceMappingURL=wps-fill-handle.js.map
|
|
100
|
+
exports.WpsFillHandlePlugin = WpsFillHandlePlugin;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["wps-fill-handle.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,yDAA2C;AAG3C,qEAAwE;AAQx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AoB,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/F,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;YAC/F,IAAI,CAAC,gBAAgB,GAAG,IAAI,CAAC,GAAG,CAAC,oBAAoB,CAAC,KAAK,CAAC,GAAG,EAAE,oBAAoB,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;SAChG;IACH,CAAC;IAED,OAAO;QACL,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;QAC1B,IAAI,CAAC,gBAAgB,GAAG,CAAC,CAAC;IAG5B,CAAC;CACF;AAjGD,kDAiGC;AAED,SAAS,iBAAiB,CAAC,WAAsC,EAAE,aAA+B;IAChG,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;QAC3C,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,EAAE,CAAC,EAAE,EAAE;YAC9C,aAAa,CAAC,eAAe,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,CAAC;SACjF;KACF;AACH,CAAC","file":"wps-fill-handle.js","sourcesContent":["import * as VTable from '@visactor/vtable';\nimport type { TableEvents } from '@visactor/vtable/src/core/TABLE_EVENT_TYPE';\nimport type { EventArg } from './types';\nimport { generateAutoFillData } from './fillHandleUtils/autoFillHandle';\n//备用 插件配置项 目前感觉都走默认逻辑就行\nexport type IWpsFillHandlePluginOptions = {\n id?: string;\n // 是否响应删除\n // enableDeleteKey?: boolean;\n};\n\nexport class WpsFillHandlePlugin implements VTable.plugins.IVTablePlugin {\n id = `wps-fill-handle-${Date.now()}`;\n name = 'WPS Fill Handle';\n runTime = [VTable.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE, VTable.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END];\n table: VTable.ListTable;\n pluginOptions: IWpsFillHandlePluginOptions;\n\n beforeDragMinCol = 0;\n beforeDragMinRow = 0;\n beforeDragMaxCol = 0;\n beforeDragMaxRow = 0;\n\n constructor(pluginOptions?: IWpsFillHandlePluginOptions) {\n this.id = pluginOptions?.id ?? this.id;\n this.pluginOptions = pluginOptions;\n }\n run(...args: [EventArg, TableEvents[keyof TableEvents] | TableEvents[keyof TableEvents][], VTable.BaseTableAPI]) {\n if (args[1] === VTable.TABLE_EVENT_TYPE.MOUSEDOWN_FILL_HANDLE) {\n const eventArgs = args[0];\n const table: VTable.BaseTableAPI = args[2];\n this.table = table as VTable.ListTable;\n const startSelectCellRange = this.table?.getSelectedCellRanges()[0];\n if (!startSelectCellRange) {\n return;\n }\n this.beforeDragMaxCol = Math.max(startSelectCellRange.start.col, startSelectCellRange.end.col);\n this.beforeDragMinCol = Math.min(startSelectCellRange.start.col, startSelectCellRange.end.col);\n this.beforeDragMaxRow = Math.max(startSelectCellRange.start.row, startSelectCellRange.end.row);\n this.beforeDragMinRow = Math.min(startSelectCellRange.start.row, startSelectCellRange.end.row);\n } else if (args[1] === VTable.TABLE_EVENT_TYPE.DRAG_FILL_HANDLE_END) {\n const direction = (args[0] as { direction?: 'bottom' | 'right' | 'top' | 'left' }).direction;\n let endChangeCellCol;\n let endChangeCellRow;\n const endSelectCellRange = this.table?.getSelectedCellRanges()[0];\n if (!endSelectCellRange) {\n return;\n }\n //根据填充方向 确定需要填充值的范围\n if (direction === 'bottom') {\n endChangeCellCol = this.beforeDragMaxCol;\n endChangeCellRow = endSelectCellRange.end.row;\n } else if (direction === 'right') {\n endChangeCellCol = endSelectCellRange.end.col;\n endChangeCellRow = this.beforeDragMaxRow;\n } else if (direction === 'top') {\n endChangeCellCol = this.beforeDragMaxCol;\n endChangeCellRow = endSelectCellRange.end.row;\n } else if (direction === 'left') {\n endChangeCellCol = endSelectCellRange.end.col;\n endChangeCellRow = this.beforeDragMaxRow;\n }\n const rowDatas = this.table?.records;\n const tableColumns = this.table?.getAllColumnHeaderCells() || [];\n let highestColumns: VTable.TYPES.CellInfo[] = [];\n if (tableColumns?.length) {\n highestColumns = tableColumns[tableColumns.length - 1];\n }\n const newDatas = generateAutoFillData(\n rowDatas,\n highestColumns,\n {\n startRow: this.beforeDragMinRow - tableColumns.length,\n startCol: this.beforeDragMinCol,\n endRow: this.beforeDragMaxRow - tableColumns.length,\n endCol: this.beforeDragMaxCol\n },\n {\n row: endChangeCellRow - tableColumns.length,\n col: endChangeCellCol\n }\n );\n this.table?.setRecords(newDatas);\n }\n }\n\n handleKeyDown() {\n if (this.table.editorManager) {\n //判断是键盘触发编辑单元格的情况下,那么在编辑状态中切换方向需要选中下一个继续编辑\n const startSelectCellRange = this.table?.getSelectedCellRanges()[0];\n if (!startSelectCellRange) {\n return;\n }\n this.beforeDragMaxCol = Math.max(startSelectCellRange.start.col, startSelectCellRange.end.col);\n this.beforeDragMinCol = Math.min(startSelectCellRange.start.col, startSelectCellRange.end.col);\n this.beforeDragMaxRow = Math.max(startSelectCellRange.start.row, startSelectCellRange.end.row);\n this.beforeDragMinRow = Math.min(startSelectCellRange.start.row, startSelectCellRange.end.row);\n }\n }\n\n release() {\n this.beforeDragMinCol = 0;\n this.beforeDragMinRow = 0;\n this.beforeDragMaxCol = 0;\n this.beforeDragMaxRow = 0;\n // document.removeEventListener('mousedown_fill_handle', this.handleKeyDown, true);\n // document.removeEventListener('drag_fill_handle_end', this.handleDragEnd, true);\n }\n}\n//将选中单元格的值设置为空\nfunction deleteSelectRange(selectCells: VTable.TYPES.CellInfo[][], tableInstance: VTable.ListTable) {\n for (let i = 0; i < selectCells.length; i++) {\n for (let j = 0; j < selectCells[i].length; j++) {\n tableInstance.changeCellValue(selectCells[i][j].col, selectCells[i][j].row, '');\n }\n }\n}\n"]}
|