yy-vue-easytable 2.27.2
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/LICENSE +22 -0
- package/README.md +187 -0
- package/libs/font/demo.css +539 -0
- package/libs/font/demo_index.html +400 -0
- package/libs/font/iconfont.css +57 -0
- package/libs/font/iconfont.eot +0 -0
- package/libs/font/iconfont.js +1 -0
- package/libs/font/iconfont.json +79 -0
- package/libs/font/iconfont.svg +56 -0
- package/libs/font/iconfont.ttf +0 -0
- package/libs/font/iconfont.woff +0 -0
- package/libs/font/iconfont.woff2 +0 -0
- package/libs/locale/lang/af-ZA.js +48 -0
- package/libs/locale/lang/en-US.js +48 -0
- package/libs/locale/lang/fr-FR.js +48 -0
- package/libs/locale/lang/ko-KR.js +48 -0
- package/libs/locale/lang/pt-BR.js +48 -0
- package/libs/locale/lang/ru-RU.js +48 -0
- package/libs/locale/lang/zh-CN.js +48 -0
- package/libs/locale/lang/zh-TW.js +48 -0
- package/libs/locale/lang/zu-ZA.js +48 -0
- package/libs/main.js +1 -0
- package/libs/theme-dark/base.css +1 -0
- package/libs/theme-dark/index.css +1253 -0
- package/libs/theme-dark/var.css +7 -0
- package/libs/theme-dark/ve-checkbox.css +150 -0
- package/libs/theme-dark/ve-contextmenu.css +71 -0
- package/libs/theme-dark/ve-dropdown.css +177 -0
- package/libs/theme-dark/ve-icon.css +10 -0
- package/libs/theme-dark/ve-loading.css +218 -0
- package/libs/theme-dark/ve-pagination.css +136 -0
- package/libs/theme-dark/ve-radio.css +111 -0
- package/libs/theme-dark/ve-select.css +50 -0
- package/libs/theme-dark/ve-table.css +385 -0
- package/libs/theme-default/base.css +1 -0
- package/libs/theme-default/index.css +1253 -0
- package/libs/theme-default/var.css +7 -0
- package/libs/theme-default/ve-checkbox.css +150 -0
- package/libs/theme-default/ve-contextmenu.css +71 -0
- package/libs/theme-default/ve-dropdown.css +177 -0
- package/libs/theme-default/ve-icon.css +10 -0
- package/libs/theme-default/ve-loading.css +218 -0
- package/libs/theme-default/ve-pagination.css +136 -0
- package/libs/theme-default/ve-radio.css +111 -0
- package/libs/theme-default/ve-select.css +50 -0
- package/libs/theme-default/ve-table.css +385 -0
- package/libs/umd/index.js +9 -0
- package/libs/ve-checkbox-group.js +1 -0
- package/libs/ve-checkbox.js +1 -0
- package/libs/ve-contextmenu.js +1 -0
- package/libs/ve-dropdown.js +1 -0
- package/libs/ve-icon.js +1 -0
- package/libs/ve-loading.js +1 -0
- package/libs/ve-locale.js +1 -0
- package/libs/ve-pagination.js +1 -0
- package/libs/ve-radio.js +1 -0
- package/libs/ve-select.js +1 -0
- package/libs/ve-table.js +1 -0
- package/package.json +142 -0
- package/packages/font/demo.css +539 -0
- package/packages/font/demo_index.html +400 -0
- package/packages/font/iconfont.css +57 -0
- package/packages/font/iconfont.eot +0 -0
- package/packages/font/iconfont.js +1 -0
- package/packages/font/iconfont.json +79 -0
- package/packages/font/iconfont.svg +56 -0
- package/packages/font/iconfont.ttf +0 -0
- package/packages/font/iconfont.woff +0 -0
- package/packages/font/iconfont.woff2 +0 -0
- package/packages/index.js +75 -0
- package/packages/src/comps/resize-observer/index.js +2 -0
- package/packages/src/comps/resize-observer/src/index.jsx +38 -0
- package/packages/src/directives/clickoutside.js +31 -0
- package/packages/src/directives/events-outside.js +79 -0
- package/packages/src/directives/focus.js +28 -0
- package/packages/src/locale/index.js +27 -0
- package/packages/src/locale/lang/af-ZA.js +29 -0
- package/packages/src/locale/lang/en-US.js +30 -0
- package/packages/src/locale/lang/fr-FR.js +29 -0
- package/packages/src/locale/lang/ko-KR.js +29 -0
- package/packages/src/locale/lang/pt-BR.js +29 -0
- package/packages/src/locale/lang/ru-RU.js +29 -0
- package/packages/src/locale/lang/zh-CN.js +30 -0
- package/packages/src/locale/lang/zh-TW.js +29 -0
- package/packages/src/locale/lang/zu-ZA.js +29 -0
- package/packages/src/mixins/emitter.js +39 -0
- package/packages/src/utils/animation-frame.js +39 -0
- package/packages/src/utils/auto-resize.js +179 -0
- package/packages/src/utils/constant.js +42 -0
- package/packages/src/utils/dom.js +239 -0
- package/packages/src/utils/event-key-codes.js +53 -0
- package/packages/src/utils/hooks-manager.js +76 -0
- package/packages/src/utils/index.js +161 -0
- package/packages/src/utils/mouse-event.js +24 -0
- package/packages/src/utils/random.js +6 -0
- package/packages/src/utils/request-animation-timeout.js +36 -0
- package/packages/src/utils/resize-event.js +40 -0
- package/packages/src/utils/scroll-bar.js +27 -0
- package/packages/style/ve-checkbox.less +179 -0
- package/packages/style/ve-contextmenu.less +76 -0
- package/packages/style/ve-dropdown.less +204 -0
- package/packages/style/ve-icon.less +3 -0
- package/packages/style/ve-loading.less +242 -0
- package/packages/style/ve-pagination.less +153 -0
- package/packages/style/ve-radio.less +126 -0
- package/packages/style/ve-select.less +48 -0
- package/packages/style/ve-table.less +539 -0
- package/packages/theme-dark/base.less +1 -0
- package/packages/theme-dark/index.less +12 -0
- package/packages/theme-dark/var.less +111 -0
- package/packages/theme-dark/ve-checkbox.less +2 -0
- package/packages/theme-dark/ve-contextmenu.less +2 -0
- package/packages/theme-dark/ve-dropdown.less +2 -0
- package/packages/theme-dark/ve-icon.less +2 -0
- package/packages/theme-dark/ve-loading.less +2 -0
- package/packages/theme-dark/ve-pagination.less +2 -0
- package/packages/theme-dark/ve-radio.less +2 -0
- package/packages/theme-dark/ve-select.less +2 -0
- package/packages/theme-dark/ve-table.less +2 -0
- package/packages/theme-default/base.less +1 -0
- package/packages/theme-default/index.less +12 -0
- package/packages/theme-default/var.less +111 -0
- package/packages/theme-default/ve-checkbox.less +2 -0
- package/packages/theme-default/ve-contextmenu.less +2 -0
- package/packages/theme-default/ve-dropdown.less +2 -0
- package/packages/theme-default/ve-icon.less +2 -0
- package/packages/theme-default/ve-loading.less +2 -0
- package/packages/theme-default/ve-pagination.less +2 -0
- package/packages/theme-default/ve-radio.less +2 -0
- package/packages/theme-default/ve-select.less +2 -0
- package/packages/theme-default/ve-table.less +2 -0
- package/packages/ve-checkbox/index.js +7 -0
- package/packages/ve-checkbox/src/index.jsx +175 -0
- package/packages/ve-checkbox/src/util/constant.js +14 -0
- package/packages/ve-checkbox/src/util/index.js +10 -0
- package/packages/ve-checkbox-group/index.js +7 -0
- package/packages/ve-checkbox-group/src/index.jsx +53 -0
- package/packages/ve-checkbox-group/src/util/constant.js +14 -0
- package/packages/ve-checkbox-group/src/util/index.js +10 -0
- package/packages/ve-contextmenu/index.js +7 -0
- package/packages/ve-contextmenu/src/index.jsx +731 -0
- package/packages/ve-contextmenu/src/util/constant.js +29 -0
- package/packages/ve-contextmenu/src/util/index.js +10 -0
- package/packages/ve-dropdown/index.js +7 -0
- package/packages/ve-dropdown/src/index.jsx +720 -0
- package/packages/ve-dropdown/src/util/constant.js +15 -0
- package/packages/ve-dropdown/src/util/index.js +10 -0
- package/packages/ve-icon/index.js +7 -0
- package/packages/ve-icon/src/index.jsx +52 -0
- package/packages/ve-icon/src/util/constant.js +10 -0
- package/packages/ve-icon/src/util/index.js +10 -0
- package/packages/ve-loading/index.js +8 -0
- package/packages/ve-loading/src/bounce.jsx +50 -0
- package/packages/ve-loading/src/flow.jsx +51 -0
- package/packages/ve-loading/src/grid.jsx +57 -0
- package/packages/ve-loading/src/index.js +106 -0
- package/packages/ve-loading/src/loading.jsx +63 -0
- package/packages/ve-loading/src/plane.jsx +38 -0
- package/packages/ve-loading/src/pulse.jsx +38 -0
- package/packages/ve-loading/src/util/constant.js +31 -0
- package/packages/ve-loading/src/util/index.js +10 -0
- package/packages/ve-loading/src/wave.jsx +53 -0
- package/packages/ve-locale/index.js +28 -0
- package/packages/ve-pagination/index.js +7 -0
- package/packages/ve-pagination/src/index.jsx +304 -0
- package/packages/ve-pagination/src/pager.jsx +166 -0
- package/packages/ve-pagination/src/util/constant.js +16 -0
- package/packages/ve-pagination/src/util/index.js +10 -0
- package/packages/ve-radio/index.js +7 -0
- package/packages/ve-radio/src/index.jsx +121 -0
- package/packages/ve-radio/src/util/constant.js +13 -0
- package/packages/ve-radio/src/util/index.js +10 -0
- package/packages/ve-select/index.js +7 -0
- package/packages/ve-select/src/index.jsx +193 -0
- package/packages/ve-select/src/util/constant.js +13 -0
- package/packages/ve-select/src/util/index.js +10 -0
- package/packages/ve-table/index.js +7 -0
- package/packages/ve-table/src/body/body-checkbox-content.jsx +126 -0
- package/packages/ve-table/src/body/body-radio-content.jsx +113 -0
- package/packages/ve-table/src/body/body-td.jsx +671 -0
- package/packages/ve-table/src/body/body-tr-scrolling.jsx +38 -0
- package/packages/ve-table/src/body/body-tr.jsx +383 -0
- package/packages/ve-table/src/body/expand-tr-icon.jsx +80 -0
- package/packages/ve-table/src/body/expand-tr.jsx +147 -0
- package/packages/ve-table/src/body/index.jsx +943 -0
- package/packages/ve-table/src/colgroup/index.jsx +48 -0
- package/packages/ve-table/src/column-resizer/index.jsx +318 -0
- package/packages/ve-table/src/editor/constant.js +5 -0
- package/packages/ve-table/src/editor/index.jsx +533 -0
- package/packages/ve-table/src/footer/footer-td.jsx +396 -0
- package/packages/ve-table/src/footer/footer-tr.jsx +249 -0
- package/packages/ve-table/src/footer/index.jsx +108 -0
- package/packages/ve-table/src/header/header-checkbox-content.jsx +69 -0
- package/packages/ve-table/src/header/header-filter-content.jsx +100 -0
- package/packages/ve-table/src/header/header-filter-custom-content.jsx +110 -0
- package/packages/ve-table/src/header/header-th.jsx +664 -0
- package/packages/ve-table/src/header/header-tr.jsx +255 -0
- package/packages/ve-table/src/header/index.jsx +195 -0
- package/packages/ve-table/src/index.jsx +4196 -0
- package/packages/ve-table/src/selection/constant.js +5 -0
- package/packages/ve-table/src/selection/index.jsx +1643 -0
- package/packages/ve-table/src/util/clipboard.js +428 -0
- package/packages/ve-table/src/util/constant.js +269 -0
- package/packages/ve-table/src/util/index.js +1585 -0
- package/packages/ve-table/src/util/store.js +14 -0
|
@@ -0,0 +1,428 @@
|
|
|
1
|
+
const regUniversalNewLine = /^(\r\n|\n\r|\r|\n)/;
|
|
2
|
+
const regNextCellNoQuotes = /^[^\t\r\n]+/;
|
|
3
|
+
const regNextEmptyCell = /^\t/;
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* @decodeSpreadsheetStr
|
|
7
|
+
* @desc Decode spreadsheet string into array. refer from http://github.com/warpech/sheetclip/
|
|
8
|
+
* @param {string} str The string to parse.
|
|
9
|
+
* @returns {array}
|
|
10
|
+
*/
|
|
11
|
+
export function decodeSpreadsheetStr(str) {
|
|
12
|
+
let arr = [[""]];
|
|
13
|
+
|
|
14
|
+
if (str.length === 0) {
|
|
15
|
+
return arr;
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
let column = 0;
|
|
19
|
+
let row = 0;
|
|
20
|
+
let lastLength;
|
|
21
|
+
|
|
22
|
+
while (str.length > 0) {
|
|
23
|
+
if (lastLength === str.length) {
|
|
24
|
+
// In the case If in last cycle we didn't match anything, we have to leave the infinite loop
|
|
25
|
+
break;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
lastLength = str.length;
|
|
29
|
+
|
|
30
|
+
if (str.match(regNextEmptyCell)) {
|
|
31
|
+
str = str.replace(regNextEmptyCell, "");
|
|
32
|
+
|
|
33
|
+
column += 1;
|
|
34
|
+
arr[row][column] = "";
|
|
35
|
+
} else if (str.match(regUniversalNewLine)) {
|
|
36
|
+
str = str.replace(regUniversalNewLine, "");
|
|
37
|
+
column = 0;
|
|
38
|
+
row += 1;
|
|
39
|
+
|
|
40
|
+
arr[row] = [""];
|
|
41
|
+
} else {
|
|
42
|
+
let nextCell = "";
|
|
43
|
+
|
|
44
|
+
if (str.startsWith('"')) {
|
|
45
|
+
let quoteNo = 0;
|
|
46
|
+
let isStillCell = true;
|
|
47
|
+
|
|
48
|
+
while (isStillCell) {
|
|
49
|
+
const nextChar = str.slice(0, 1);
|
|
50
|
+
|
|
51
|
+
if (nextChar === '"') {
|
|
52
|
+
quoteNo += 1;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
nextCell += nextChar;
|
|
56
|
+
|
|
57
|
+
str = str.slice(1);
|
|
58
|
+
|
|
59
|
+
if (
|
|
60
|
+
str.length === 0 ||
|
|
61
|
+
(str.match(/^[\t\r\n]/) && quoteNo % 2 === 0)
|
|
62
|
+
) {
|
|
63
|
+
isStillCell = false;
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
nextCell = nextCell
|
|
68
|
+
.replace(/^"/, "")
|
|
69
|
+
.replace(/"$/, "")
|
|
70
|
+
.replace(/["]*/g, (match) =>
|
|
71
|
+
new Array(Math.floor(match.length / 2))
|
|
72
|
+
.fill('"')
|
|
73
|
+
.join(""),
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
const matchedText = str.match(regNextCellNoQuotes);
|
|
77
|
+
|
|
78
|
+
nextCell = matchedText ? matchedText[0] : "";
|
|
79
|
+
str = str.slice(nextCell.length);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
arr[row][column] = nextCell;
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
// 去除 excel 最后一个多余的换行数据
|
|
86
|
+
if (Array.isArray(arr) && arr.length > 1) {
|
|
87
|
+
if (arr[arr.length - 1].length === 1 && arr[arr.length - 1][0] === "") {
|
|
88
|
+
arr = arr.slice(0, arr.length - 1);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
return arr;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* @decodeSpreadsheetStr
|
|
97
|
+
* @desc encode array to spreadsheet string. refer from http://github.com/warpech/sheetclip/
|
|
98
|
+
* @param {array} str The string to parse.
|
|
99
|
+
* @returns {string}
|
|
100
|
+
*/
|
|
101
|
+
export function encodeToSpreadsheetStr(arr) {
|
|
102
|
+
let r;
|
|
103
|
+
let rLen;
|
|
104
|
+
let c;
|
|
105
|
+
let cLen;
|
|
106
|
+
let str = "";
|
|
107
|
+
let val;
|
|
108
|
+
|
|
109
|
+
for (r = 0, rLen = arr.length; r < rLen; r += 1) {
|
|
110
|
+
cLen = arr[r].length;
|
|
111
|
+
|
|
112
|
+
for (c = 0; c < cLen; c += 1) {
|
|
113
|
+
if (c > 0) {
|
|
114
|
+
str += "\t";
|
|
115
|
+
}
|
|
116
|
+
val = arr[r][c];
|
|
117
|
+
|
|
118
|
+
if (typeof val === "string") {
|
|
119
|
+
if (val.indexOf("\n") > -1) {
|
|
120
|
+
str += `"${val.replace(/"/g, '""')}"`;
|
|
121
|
+
} else {
|
|
122
|
+
str += val;
|
|
123
|
+
}
|
|
124
|
+
} else if (val === null || val === void 0) {
|
|
125
|
+
// void 0 resolves to undefined
|
|
126
|
+
str += "";
|
|
127
|
+
} else {
|
|
128
|
+
str += val;
|
|
129
|
+
}
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
if (r !== rLen - 1) {
|
|
133
|
+
str += "\n";
|
|
134
|
+
}
|
|
135
|
+
}
|
|
136
|
+
|
|
137
|
+
return str;
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
/**
|
|
141
|
+
* @onBeforeCopy
|
|
142
|
+
* @desc on before copy
|
|
143
|
+
* @param {Event} event
|
|
144
|
+
* @return {selectionRangeIndexes,selectionRangeKeys,data}
|
|
145
|
+
*/
|
|
146
|
+
export function onBeforeCopy({
|
|
147
|
+
cellSelectionRangeData,
|
|
148
|
+
selectionRangeData,
|
|
149
|
+
colgroups,
|
|
150
|
+
allRowKeys,
|
|
151
|
+
}) {
|
|
152
|
+
const { leftColKey, rightColKey, topRowKey, bottomRowKey } =
|
|
153
|
+
cellSelectionRangeData;
|
|
154
|
+
|
|
155
|
+
const selectionRangeIndexes = {
|
|
156
|
+
startColIndex: colgroups.findIndex((x) => x.key === leftColKey),
|
|
157
|
+
endColIndex: colgroups.findIndex((x) => x.key === rightColKey),
|
|
158
|
+
startRowIndex: allRowKeys.indexOf(topRowKey),
|
|
159
|
+
endRowIndex: allRowKeys.indexOf(bottomRowKey),
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
const selectionRangeKeys = {
|
|
163
|
+
startColKey: leftColKey,
|
|
164
|
+
endColKey: rightColKey,
|
|
165
|
+
startRowKey: topRowKey,
|
|
166
|
+
endRowKey: bottomRowKey,
|
|
167
|
+
};
|
|
168
|
+
|
|
169
|
+
const response = {
|
|
170
|
+
selectionRangeIndexes,
|
|
171
|
+
selectionRangeKeys,
|
|
172
|
+
data: selectionRangeData,
|
|
173
|
+
};
|
|
174
|
+
|
|
175
|
+
return response;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
/**
|
|
179
|
+
* @onAfterCopy
|
|
180
|
+
* @desc on after copy
|
|
181
|
+
* @param {Event} event
|
|
182
|
+
* @return
|
|
183
|
+
*/
|
|
184
|
+
export function onAfterCopy({ event, selectionRangeData }) {
|
|
185
|
+
const spreadsheetStr = encodeToSpreadsheetStr(selectionRangeData);
|
|
186
|
+
|
|
187
|
+
if (event.clipboardData) {
|
|
188
|
+
event.clipboardData.setData("text/plain", spreadsheetStr);
|
|
189
|
+
}
|
|
190
|
+
// IE browser
|
|
191
|
+
else if (window.clipboardData) {
|
|
192
|
+
window.clipboardData.setData("Text", spreadsheetStr);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* @onBeforePaste
|
|
198
|
+
* @desc on before paste
|
|
199
|
+
* @param {Event} event
|
|
200
|
+
* @return
|
|
201
|
+
*/
|
|
202
|
+
export function onBeforePaste({
|
|
203
|
+
event,
|
|
204
|
+
cellSelectionRangeData,
|
|
205
|
+
colgroups,
|
|
206
|
+
allRowKeys,
|
|
207
|
+
}) {
|
|
208
|
+
let pastedData;
|
|
209
|
+
|
|
210
|
+
if (event.clipboardData) {
|
|
211
|
+
pastedData = event.clipboardData.getData("text/plain");
|
|
212
|
+
}
|
|
213
|
+
// IE browser
|
|
214
|
+
else if (window.clipboardData) {
|
|
215
|
+
pastedData = window.clipboardData.getData("Text");
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
if (typeof pastedData !== "string") {
|
|
219
|
+
return null;
|
|
220
|
+
}
|
|
221
|
+
|
|
222
|
+
let decodePasteData = decodeSpreadsheetStr(pastedData);
|
|
223
|
+
|
|
224
|
+
const startColIndex = colgroups.findIndex(
|
|
225
|
+
(x) => x.key === cellSelectionRangeData.leftColKey,
|
|
226
|
+
);
|
|
227
|
+
const endColIndex = Math.min(
|
|
228
|
+
startColIndex + decodePasteData[0].length - 1,
|
|
229
|
+
colgroups.length - 1,
|
|
230
|
+
);
|
|
231
|
+
const startRowIndex = allRowKeys.indexOf(cellSelectionRangeData.topRowKey);
|
|
232
|
+
const endRowIndex = Math.min(
|
|
233
|
+
startRowIndex + decodePasteData.length - 1,
|
|
234
|
+
allRowKeys.length - 1,
|
|
235
|
+
);
|
|
236
|
+
|
|
237
|
+
let response = {
|
|
238
|
+
selectionRangeIndexes: {
|
|
239
|
+
startColIndex,
|
|
240
|
+
endColIndex,
|
|
241
|
+
startRowIndex,
|
|
242
|
+
endRowIndex,
|
|
243
|
+
},
|
|
244
|
+
selectionRangeKeys: {
|
|
245
|
+
startColKey: colgroups[startColIndex].key,
|
|
246
|
+
endColKey: colgroups[endColIndex].key,
|
|
247
|
+
startRowKey: allRowKeys[startRowIndex],
|
|
248
|
+
endRowKey: allRowKeys[endRowIndex],
|
|
249
|
+
},
|
|
250
|
+
data: [],
|
|
251
|
+
};
|
|
252
|
+
|
|
253
|
+
const sourceFieldNames = colgroups
|
|
254
|
+
.slice(startColIndex, endColIndex + 1)
|
|
255
|
+
.map((x) => x.field);
|
|
256
|
+
|
|
257
|
+
response.data = decodePasteData
|
|
258
|
+
.slice(0, endRowIndex - startRowIndex + 1)
|
|
259
|
+
.map((rowData) => {
|
|
260
|
+
let newRow = {};
|
|
261
|
+
|
|
262
|
+
rowData.forEach((cellData, cellIndex) => {
|
|
263
|
+
if (cellIndex <= endColIndex - startColIndex) {
|
|
264
|
+
newRow[sourceFieldNames[cellIndex]] = cellData;
|
|
265
|
+
}
|
|
266
|
+
});
|
|
267
|
+
return newRow;
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
return response;
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
/**
|
|
274
|
+
* @onAfterPaste
|
|
275
|
+
* @desc on after paste
|
|
276
|
+
* @param {Event} event
|
|
277
|
+
* @return
|
|
278
|
+
*/
|
|
279
|
+
export function onAfterPaste({ tableData, beforePasteResponse }) {
|
|
280
|
+
const { data: pasteData, selectionRangeIndexes } = beforePasteResponse;
|
|
281
|
+
|
|
282
|
+
pasteData.forEach((rowData, rowIndex) => {
|
|
283
|
+
Object.assign(
|
|
284
|
+
tableData[selectionRangeIndexes.startRowIndex + rowIndex],
|
|
285
|
+
rowData,
|
|
286
|
+
);
|
|
287
|
+
});
|
|
288
|
+
}
|
|
289
|
+
|
|
290
|
+
/**
|
|
291
|
+
* @onBeforeCut
|
|
292
|
+
* @desc on before cut
|
|
293
|
+
* @param {Event} event
|
|
294
|
+
* @return {selectionRangeIndexes,selectionRangeKeys,data}
|
|
295
|
+
*/
|
|
296
|
+
export function onBeforeCut({
|
|
297
|
+
cellSelectionRangeData,
|
|
298
|
+
selectionRangeData,
|
|
299
|
+
colgroups,
|
|
300
|
+
allRowKeys,
|
|
301
|
+
}) {
|
|
302
|
+
const { leftColKey, rightColKey, topRowKey, bottomRowKey } =
|
|
303
|
+
cellSelectionRangeData;
|
|
304
|
+
|
|
305
|
+
const selectionRangeIndexes = {
|
|
306
|
+
startColIndex: colgroups.findIndex((x) => x.key === leftColKey),
|
|
307
|
+
endColIndex: colgroups.findIndex((x) => x.key === rightColKey),
|
|
308
|
+
startRowIndex: allRowKeys.indexOf(topRowKey),
|
|
309
|
+
endRowIndex: allRowKeys.indexOf(bottomRowKey),
|
|
310
|
+
};
|
|
311
|
+
|
|
312
|
+
const selectionRangeKeys = {
|
|
313
|
+
startColKey: leftColKey,
|
|
314
|
+
endColKey: rightColKey,
|
|
315
|
+
startRowKey: topRowKey,
|
|
316
|
+
endRowKey: bottomRowKey,
|
|
317
|
+
};
|
|
318
|
+
|
|
319
|
+
const response = {
|
|
320
|
+
selectionRangeIndexes,
|
|
321
|
+
selectionRangeKeys,
|
|
322
|
+
data: selectionRangeData,
|
|
323
|
+
};
|
|
324
|
+
|
|
325
|
+
return response;
|
|
326
|
+
}
|
|
327
|
+
|
|
328
|
+
/**
|
|
329
|
+
* @onAfterCut
|
|
330
|
+
* @desc on after cut
|
|
331
|
+
* @param {Event} event
|
|
332
|
+
* @return
|
|
333
|
+
*/
|
|
334
|
+
export function onAfterCut({
|
|
335
|
+
event,
|
|
336
|
+
tableData,
|
|
337
|
+
colgroups,
|
|
338
|
+
selectionRangeData,
|
|
339
|
+
selectionRangeIndexes,
|
|
340
|
+
}) {
|
|
341
|
+
const spreadsheetStr = encodeToSpreadsheetStr(selectionRangeData);
|
|
342
|
+
|
|
343
|
+
const { endColIndex, endRowIndex, startColIndex, startRowIndex } =
|
|
344
|
+
selectionRangeIndexes;
|
|
345
|
+
|
|
346
|
+
// 移除制定的表格数据
|
|
347
|
+
const fieldNames = colgroups
|
|
348
|
+
.slice(startColIndex, endColIndex + 1)
|
|
349
|
+
.map((x) => x.field);
|
|
350
|
+
|
|
351
|
+
tableData.forEach((rowData, rowIndex) => {
|
|
352
|
+
if (rowIndex >= startRowIndex && rowIndex <= endRowIndex) {
|
|
353
|
+
fieldNames.forEach((fieldName) => {
|
|
354
|
+
rowData[fieldName] = "";
|
|
355
|
+
});
|
|
356
|
+
}
|
|
357
|
+
});
|
|
358
|
+
|
|
359
|
+
if (event.clipboardData) {
|
|
360
|
+
event.clipboardData.setData("text/plain", spreadsheetStr);
|
|
361
|
+
}
|
|
362
|
+
// IE browser
|
|
363
|
+
else if (window.clipboardData) {
|
|
364
|
+
window.clipboardData.setData("Text", spreadsheetStr);
|
|
365
|
+
}
|
|
366
|
+
}
|
|
367
|
+
|
|
368
|
+
/**
|
|
369
|
+
* @onBeforeDelete
|
|
370
|
+
* @desc on before delete
|
|
371
|
+
* @param {Event} event
|
|
372
|
+
* @return {selectionRangeIndexes,selectionRangeKeys,data}
|
|
373
|
+
*/
|
|
374
|
+
export function onBeforeDelete({
|
|
375
|
+
cellSelectionRangeData,
|
|
376
|
+
selectionRangeData,
|
|
377
|
+
colgroups,
|
|
378
|
+
allRowKeys,
|
|
379
|
+
}) {
|
|
380
|
+
const { leftColKey, rightColKey, topRowKey, bottomRowKey } =
|
|
381
|
+
cellSelectionRangeData;
|
|
382
|
+
|
|
383
|
+
const selectionRangeIndexes = {
|
|
384
|
+
startColIndex: colgroups.findIndex((x) => x.key === leftColKey),
|
|
385
|
+
endColIndex: colgroups.findIndex((x) => x.key === rightColKey),
|
|
386
|
+
startRowIndex: allRowKeys.indexOf(topRowKey),
|
|
387
|
+
endRowIndex: allRowKeys.indexOf(bottomRowKey),
|
|
388
|
+
};
|
|
389
|
+
|
|
390
|
+
const selectionRangeKeys = {
|
|
391
|
+
startColKey: leftColKey,
|
|
392
|
+
endColKey: rightColKey,
|
|
393
|
+
startRowKey: topRowKey,
|
|
394
|
+
endRowKey: bottomRowKey,
|
|
395
|
+
};
|
|
396
|
+
|
|
397
|
+
const response = {
|
|
398
|
+
selectionRangeIndexes,
|
|
399
|
+
selectionRangeKeys,
|
|
400
|
+
data: selectionRangeData,
|
|
401
|
+
};
|
|
402
|
+
|
|
403
|
+
return response;
|
|
404
|
+
}
|
|
405
|
+
|
|
406
|
+
/**
|
|
407
|
+
* @onAfterDelete
|
|
408
|
+
* @desc on after delete
|
|
409
|
+
* @param {Event} event
|
|
410
|
+
* @return
|
|
411
|
+
*/
|
|
412
|
+
export function onAfterDelete({ tableData, colgroups, selectionRangeIndexes }) {
|
|
413
|
+
const { endColIndex, endRowIndex, startColIndex, startRowIndex } =
|
|
414
|
+
selectionRangeIndexes;
|
|
415
|
+
|
|
416
|
+
// 移除制定的表格数据
|
|
417
|
+
const fieldNames = colgroups
|
|
418
|
+
.slice(startColIndex, endColIndex + 1)
|
|
419
|
+
.map((x) => x.field);
|
|
420
|
+
|
|
421
|
+
tableData.forEach((rowData, rowIndex) => {
|
|
422
|
+
if (rowIndex >= startRowIndex && rowIndex <= endRowIndex) {
|
|
423
|
+
fieldNames.forEach((fieldName) => {
|
|
424
|
+
rowData[fieldName] = "";
|
|
425
|
+
});
|
|
426
|
+
}
|
|
427
|
+
});
|
|
428
|
+
}
|
|
@@ -0,0 +1,269 @@
|
|
|
1
|
+
// prefix
|
|
2
|
+
export const PREFIX_CLS = "ve-table-";
|
|
3
|
+
|
|
4
|
+
// locale comp name
|
|
5
|
+
export const LOCALE_COMP_NAME = "table";
|
|
6
|
+
|
|
7
|
+
// column types
|
|
8
|
+
export const COLUMN_TYPES = {
|
|
9
|
+
// expand row
|
|
10
|
+
EXPAND: "expand",
|
|
11
|
+
// checkbox
|
|
12
|
+
CHECKBOX: "checkbox",
|
|
13
|
+
// radio
|
|
14
|
+
RADIO: "radio",
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// column fixed type
|
|
18
|
+
export const COLUMN_FIXED_TYPE = {
|
|
19
|
+
LEFT: "left",
|
|
20
|
+
RIGHT: "right",
|
|
21
|
+
};
|
|
22
|
+
|
|
23
|
+
// expand row trigger types
|
|
24
|
+
export const EXPAND_TRIGGER_TYPES = {
|
|
25
|
+
// trigger by click icon
|
|
26
|
+
ICON: "icon",
|
|
27
|
+
// trigger by click cell(td)
|
|
28
|
+
CELL: "cell",
|
|
29
|
+
// trigger by click row
|
|
30
|
+
ROW: "row",
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
// cell selection direction
|
|
34
|
+
export const CELL_SELECTION_DIRECTION = {
|
|
35
|
+
UP: "up",
|
|
36
|
+
RIGHT: "right",
|
|
37
|
+
DOWN: "down",
|
|
38
|
+
LEFT: "left",
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
// autofilling direction
|
|
42
|
+
export const AUTOFILLING_DIRECTION = {
|
|
43
|
+
UP: "up",
|
|
44
|
+
RIGHT: "right",
|
|
45
|
+
DOWN: "down",
|
|
46
|
+
LEFT: "left",
|
|
47
|
+
};
|
|
48
|
+
|
|
49
|
+
// current cell selection types
|
|
50
|
+
export const CURRENT_CELL_SELECTION_TYPES = {
|
|
51
|
+
SINGLE: "single",
|
|
52
|
+
RANGE: "range",
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// emit events
|
|
56
|
+
export const EMIT_EVENTS = {
|
|
57
|
+
// body-cell-width-change
|
|
58
|
+
BODY_CELL_WIDTH_CHANGE: "on-body-cell-width-change",
|
|
59
|
+
// header-row-height-change
|
|
60
|
+
HEADER_ROW_HEIGHT_CHANGE: "on-header-row-height-change",
|
|
61
|
+
// footer-row-height-change
|
|
62
|
+
FOOTER_ROW_HEIGHT_CHANGE: "on-footer-row-height-change",
|
|
63
|
+
// body-row-height-change
|
|
64
|
+
BODY_ROW_HEIGHT_CHANGE: "on-body-row-height-change",
|
|
65
|
+
// body row click
|
|
66
|
+
BODY_ROW_CLICK: "on-body-row-click",
|
|
67
|
+
// body cell click
|
|
68
|
+
BODY_CELL_CLICK: "on-body-cell-click",
|
|
69
|
+
// body cell mouseover
|
|
70
|
+
BODY_CELL_MOUSEOVER: "on-body-cell-mouseover",
|
|
71
|
+
// body cell mousedown
|
|
72
|
+
BODY_CELL_MOUSEDOWN: "on-body-cell-mousedown",
|
|
73
|
+
// body cell mousemove
|
|
74
|
+
BODY_CELL_MOUSEMOVE: "on-body-cell-mousemove",
|
|
75
|
+
// body cell mouseup
|
|
76
|
+
BODY_CELL_MOUSEUP: "on-body-cell-mouseup",
|
|
77
|
+
// body cell double click
|
|
78
|
+
BODY_CELL_DOUBLE_CLICK: "on-body-cell-double-click",
|
|
79
|
+
// body cell contextmenu
|
|
80
|
+
BODY_CELL_CONTEXTMENU: "on-body-cell-contextmenu",
|
|
81
|
+
// expand row change
|
|
82
|
+
EXPAND_ROW_CHANGE: "on-expand-row-change",
|
|
83
|
+
// checkbox selected row change
|
|
84
|
+
CHECKBOX_SELECTED_ROW_CHANGE: "on-checkbox-selected-row-change",
|
|
85
|
+
// checkbox selected all change
|
|
86
|
+
CHECKBOX_SELECTED_ALL_CHANGE: "on-checkbox-selected-all-change",
|
|
87
|
+
// checkbox selected all ino
|
|
88
|
+
CHECKBOX_SELECTED_ALL_INFO: "on-checkbox-selected-all-info",
|
|
89
|
+
// radio selected row change
|
|
90
|
+
RADIO_SELECTED_ROW_CHANGE: "on-radio-selected-row-change",
|
|
91
|
+
// sort change
|
|
92
|
+
SORT_CHANGE: "on-sort-change",
|
|
93
|
+
// on-cell-selection-key-change
|
|
94
|
+
CELL_SELECTION_KEY_CHANGE: "on-cell-selection-key-change",
|
|
95
|
+
// on-cell-selection-range-data-change
|
|
96
|
+
CELL_SELECTION_RANGE_DATA_CHANGE: "on-cell-selection-range-data-change",
|
|
97
|
+
// header filter confirm
|
|
98
|
+
HEADER_FILTER_CONFIRM: "on-filter-confirm",
|
|
99
|
+
// header filter reset
|
|
100
|
+
HEADER_FILTER_RESET: "on-filter-reset",
|
|
101
|
+
// header cell click
|
|
102
|
+
HEADER_CELL_CLICK: "on-header-cell-click",
|
|
103
|
+
// header cell contextmenu
|
|
104
|
+
HEADER_CELL_CONTEXTMENU: "on-header-cell-contextmenu",
|
|
105
|
+
// header cell mousedown
|
|
106
|
+
HEADER_CELL_MOUSEDOWN: "on-header-cell-mousedown",
|
|
107
|
+
// header cell mouseover
|
|
108
|
+
HEADER_CELL_MOUSEOVER: "on-header-cell-mouseover",
|
|
109
|
+
// header cell mousemove
|
|
110
|
+
HEADER_CELL_MOUSEMOVE: "on-header-cell-mousemove",
|
|
111
|
+
// header cell mouseleave
|
|
112
|
+
HEADER_CELL_MOUSELEAVE: "on-header-cell-mouseleave",
|
|
113
|
+
// highlight row change
|
|
114
|
+
HIGHLIGHT_ROW_CHANGE: "on-highlight-row-change",
|
|
115
|
+
|
|
116
|
+
// edit input clicked
|
|
117
|
+
EDIT_INPUT_CLICK: "on-edit-input-click",
|
|
118
|
+
// edit input blur
|
|
119
|
+
EDIT_INPUT_BLUR: "on-edit-input-blur",
|
|
120
|
+
// edit input value change
|
|
121
|
+
EDIT_INPUT_VALUE_CHANGE: "on-edit-input-value-change",
|
|
122
|
+
// edit input copy
|
|
123
|
+
EDIT_INPUT_COPY: "on-edit-input-copy",
|
|
124
|
+
// edit input paste
|
|
125
|
+
EDIT_INPUT_PASTE: "on-edit-input-paste",
|
|
126
|
+
// edit input cut
|
|
127
|
+
EDIT_INPUT_CUT: "on-edit-input-cut",
|
|
128
|
+
|
|
129
|
+
// selection corner mousedown
|
|
130
|
+
SELECTION_CORNER_MOUSEDOWN: "selection-corner-mousedown",
|
|
131
|
+
// selection corner mouseup
|
|
132
|
+
SELECTION_CORNER_MOUSEUP: "selection-corner-mouseup",
|
|
133
|
+
// autofilling direction change
|
|
134
|
+
AUTOFILLING_DIRECTION_CHANGE: "autofilling-direction-change",
|
|
135
|
+
};
|
|
136
|
+
|
|
137
|
+
// hooks name
|
|
138
|
+
export const HOOKS_NAME = {
|
|
139
|
+
//table container scroll
|
|
140
|
+
TABLE_CONTAINER_SCROLL: "table-container-scroll",
|
|
141
|
+
// table-container-mouseup
|
|
142
|
+
TABLE_CONTAINER_MOUSEUP: "table-container-mouseup",
|
|
143
|
+
// table-container-mousemove
|
|
144
|
+
//TABLE_CONTAINER_MOUSEMOVE: "table-container-mousemove",
|
|
145
|
+
// table size change
|
|
146
|
+
TABLE_SIZE_CHANGE: "table-size-change",
|
|
147
|
+
// table td width change
|
|
148
|
+
TABLE_CELL_WIDTH_CHANGE: "table-cell-width-change",
|
|
149
|
+
/*
|
|
150
|
+
clipboard cell value change
|
|
151
|
+
可能导致单元格高度变化,需要重新修改区域选择的定位信息
|
|
152
|
+
*/
|
|
153
|
+
CLIPBOARD_CELL_VALUE_CHANGE: "clipboard-cell-value-change",
|
|
154
|
+
// header cell mousedown
|
|
155
|
+
//HEADER_CELL_MOUSEDOWN: "header-cell-mousedown",
|
|
156
|
+
// header cell mousemove
|
|
157
|
+
HEADER_CELL_MOUSEMOVE: "header-cell-mousemove",
|
|
158
|
+
// body cell mousemove
|
|
159
|
+
BODY_CELL_MOUSEMOVE: "body-cell-mousemove",
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
// comps name
|
|
163
|
+
export const COMPS_NAME = {
|
|
164
|
+
VE_TABLE: "VeTable",
|
|
165
|
+
|
|
166
|
+
VE_TABLE_THADER: "VeTableHeader",
|
|
167
|
+
VE_TABLE_THADER_TR: "VeTableHeaderTr",
|
|
168
|
+
VE_TABLE_THADER_Th: "VeTableHeaderTh",
|
|
169
|
+
VE_TABLE_HEADER_CHECKBOX_CONTENT: "VeTableHeaderCheckboxContent",
|
|
170
|
+
VE_TABLE_HEADER_FILTER_CONTENT: "VeTableHeaderFilterContent",
|
|
171
|
+
VE_TABLE_HEADER_FILTER_CUSTOM_CONTENT: "VeTableHeaderFilterCustomContent",
|
|
172
|
+
|
|
173
|
+
VE_TABLE_BODY: "VeTableBody",
|
|
174
|
+
VE_TABLE_BODY_TR: "VeTableBodyTr",
|
|
175
|
+
VE_TABLE_BODY_TR_SCROLLING: "VeTableBodyTrScrolling",
|
|
176
|
+
VE_TABLE_BODY_CHECKBOX_CONTENT: "VeTableBodyCheckboxContent",
|
|
177
|
+
VE_TABLE_BODY_RADIO_CONTENT: "VeTableBodyRadioContent",
|
|
178
|
+
VE_TABLE_BODY_TD: "VeTableBodyTd",
|
|
179
|
+
|
|
180
|
+
VE_TABLE_COLGROUP: "VeTableColgroup",
|
|
181
|
+
VE_TABLE_FOOTER: "VeTableFooter",
|
|
182
|
+
|
|
183
|
+
VE_TABLE_EXPAND_TR: "VeTableExpandTr",
|
|
184
|
+
VE_TABLE_EXPAND_TR_ICON: "VeTableExpandTrIcon",
|
|
185
|
+
|
|
186
|
+
VE_TABLE_EDIT_INPUT: "VeTableEditInput",
|
|
187
|
+
|
|
188
|
+
VE_TABLE_SELECTION: "VeTableSelection",
|
|
189
|
+
|
|
190
|
+
VE_TABLE_COLUMN_RESISZER: "VeTableColumnResizer",
|
|
191
|
+
};
|
|
192
|
+
|
|
193
|
+
// comps custom attrs
|
|
194
|
+
export const COMPS_CUSTOM_ATTRS = {
|
|
195
|
+
// body row key
|
|
196
|
+
BODY_ROW_KEY: "row-key",
|
|
197
|
+
// body column key
|
|
198
|
+
BODY_COLUMN_KEY: "col-key",
|
|
199
|
+
};
|
|
200
|
+
|
|
201
|
+
// instance methods
|
|
202
|
+
export const INSTANCE_METHODS = {
|
|
203
|
+
// scroll to pixels
|
|
204
|
+
SCROLL_TO: "scrollTo",
|
|
205
|
+
// scroll to rowKey
|
|
206
|
+
SCROLL_TO_ROW_KEY: "scrollToRowKey",
|
|
207
|
+
// scroll to colKey
|
|
208
|
+
SCROLL_TO_COL_KEY: "scrollToColKey",
|
|
209
|
+
// start editing cell
|
|
210
|
+
START_EDITING_CELL: "startEditingCell",
|
|
211
|
+
// stop editing cell
|
|
212
|
+
STOP_EDITING_CELL: "stopEditingCell",
|
|
213
|
+
// set highlight row
|
|
214
|
+
SET_HIGHLIGHT_ROW: "setHighlightRow",
|
|
215
|
+
// set cell selection
|
|
216
|
+
SET_CELL_SELECTION: "setCellSelection",
|
|
217
|
+
// set range cell selection
|
|
218
|
+
SET_RANGE_CELL_SELECTION: "setRangeCellSelection",
|
|
219
|
+
// get range cell selection
|
|
220
|
+
GET_RANGE_CELL_SELECTION: "getRangeCellSelection",
|
|
221
|
+
// set all cell selection
|
|
222
|
+
SET_ALL_CELL_SELECTION: "setAllCellSelection",
|
|
223
|
+
// hide columns by keys
|
|
224
|
+
HIDE_COLUMNS_BY_KEYS: "hideColumnsByKeys",
|
|
225
|
+
// show columns by keys
|
|
226
|
+
SHOW_COLUMNS_BY_KEYS: "showColumnsByKeys",
|
|
227
|
+
};
|
|
228
|
+
|
|
229
|
+
// contextmenu types
|
|
230
|
+
export const CONTEXTMENU_TYPES = {
|
|
231
|
+
HEADER_CONTEXTMENU: "headerContextmenu",
|
|
232
|
+
BODY_CONTEXTMENU: "bodyContextmenu",
|
|
233
|
+
};
|
|
234
|
+
|
|
235
|
+
// contextmenu node types
|
|
236
|
+
export const CONTEXTMENU_NODE_TYPES = {
|
|
237
|
+
// separator
|
|
238
|
+
SEPARATOR: "SEPARATOR",
|
|
239
|
+
// cut
|
|
240
|
+
CUT: "CUT",
|
|
241
|
+
// copy
|
|
242
|
+
COPY: "COPY",
|
|
243
|
+
// paste todo
|
|
244
|
+
//PASTE: "PASTE",
|
|
245
|
+
// insert row above
|
|
246
|
+
INSERT_ROW_ABOVE: "INSERT_ROW_ABOVE",
|
|
247
|
+
// insert row below
|
|
248
|
+
INSERT_ROW_BELOW: "INSERT_ROW_BELOW",
|
|
249
|
+
// remove row
|
|
250
|
+
REMOVE_ROW: "REMOVE_ROW",
|
|
251
|
+
// empty row
|
|
252
|
+
EMPTY_ROW: "EMPTY_ROW",
|
|
253
|
+
// remove column
|
|
254
|
+
//REMOVE_COLUMN: "REMOVE_COLUMN",
|
|
255
|
+
// empty column
|
|
256
|
+
EMPTY_COLUMN: "EMPTY_COLUMN",
|
|
257
|
+
// hide column
|
|
258
|
+
//HIDE_COLUMN: "HIDE_COLUMN",
|
|
259
|
+
// empty cell
|
|
260
|
+
EMPTY_CELL: "EMPTY_CELL",
|
|
261
|
+
// left fixed column to
|
|
262
|
+
LEFT_FIXED_COLUMN_TO: "LEFT_FIXED_COLUMN_TO",
|
|
263
|
+
// cancel left fixed column to
|
|
264
|
+
CANCEL_LEFT_FIXED_COLUMN_TO: "CANCEL_LEFT_FIXED_COLUMN_TO",
|
|
265
|
+
// right fixed column to
|
|
266
|
+
RIGHT_FIXED_COLUMN_TO: "RIGHT_FIXED_COLUMN_TO",
|
|
267
|
+
// cancel right fixed column to
|
|
268
|
+
CANCEL_RIGHT_FIXED_COLUMN_TO: "CANCEL_RIGHT_FIXED_COLUMN_TO",
|
|
269
|
+
};
|