resolver-egretimp-plus 0.1.30 → 0.1.31
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/h5/index.js +18 -18
- package/dist/web/index.js +128 -128
- package/dist/web/index.js.LICENSE.txt +15 -0
- package/package.json +5 -1
- package/scripts/webpack.config.js +18 -2
- package/src/components/packages-web/CustomComponentTable.jsx +8 -5
- package/src/components/table/index.ts +29 -0
- package/src/components/table/src/composables/use-scrollbar.ts +30 -0
- package/src/components/table/src/config.ts +256 -0
- package/src/components/table/src/filter-panel.vue +260 -0
- package/src/components/table/src/h-helper.ts +34 -0
- package/src/components/table/src/layout-observer.ts +78 -0
- package/src/components/table/src/store/current.ts +85 -0
- package/src/components/table/src/store/expand.ts +76 -0
- package/src/components/table/src/store/helper.ts +74 -0
- package/src/components/table/src/store/index.ts +246 -0
- package/src/components/table/src/store/tree.ts +230 -0
- package/src/components/table/src/store/watcher.ts +543 -0
- package/src/components/table/src/table/defaults.ts +402 -0
- package/src/components/table/src/table/key-render-helper.ts +27 -0
- package/src/components/table/src/table/style-helper.ts +378 -0
- package/src/components/table/src/table/utils-helper.ts +47 -0
- package/src/components/table/src/table-body/defaults.ts +52 -0
- package/src/components/table/src/table-body/events-helper.ts +203 -0
- package/src/components/table/src/table-body/index.ts +119 -0
- package/src/components/table/src/table-body/render-helper.ts +283 -0
- package/src/components/table/src/table-body/styles-helper.ts +164 -0
- package/src/components/table/src/table-column/defaults.ts +237 -0
- package/src/components/table/src/table-column/index.ts +202 -0
- package/src/components/table/src/table-column/render-helper.ts +214 -0
- package/src/components/table/src/table-column/watcher-helper.ts +88 -0
- package/src/components/table/src/table-footer/index.ts +128 -0
- package/src/components/table/src/table-footer/mapState-helper.ts +33 -0
- package/src/components/table/src/table-footer/style-helper.ts +51 -0
- package/src/components/table/src/table-header/event-helper.ts +213 -0
- package/src/components/table/src/table-header/index.ts +244 -0
- package/src/components/table/src/table-header/style.helper.ts +119 -0
- package/src/components/table/src/table-header/utils-helper.ts +94 -0
- package/src/components/table/src/table-layout.ts +259 -0
- package/src/components/table/src/table.vue +389 -0
- package/src/components/table/src/tableColumn.ts +3 -0
- package/src/components/table/src/tokens.ts +5 -0
- package/src/components/table/src/util.ts +521 -0
- package/src/components/table/style/css.ts +5 -0
- package/src/components/table/style/index.ts +5 -0
- package/tsconfig.json +19 -0
- package/vue-shims.d.ts +4 -0
|
@@ -0,0 +1,521 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { createVNode, render } from 'vue'
|
|
3
|
+
import { flatMap, get } from 'lodash-unified'
|
|
4
|
+
import {
|
|
5
|
+
hasOwn,
|
|
6
|
+
isArray,
|
|
7
|
+
isBoolean,
|
|
8
|
+
isObject,
|
|
9
|
+
throwError,
|
|
10
|
+
} from 'element-plus/es/utils/index.mjs'
|
|
11
|
+
import ElTooltip, {
|
|
12
|
+
type ElTooltipProps,
|
|
13
|
+
} from 'element-plus/es/components/tooltip/index.mjs'
|
|
14
|
+
import type { Table } from './table/defaults'
|
|
15
|
+
import type { TableColumnCtx } from './table-column/defaults'
|
|
16
|
+
|
|
17
|
+
export type TableOverflowTooltipOptions = Partial<
|
|
18
|
+
Pick<
|
|
19
|
+
ElTooltipProps,
|
|
20
|
+
| 'appendTo'
|
|
21
|
+
| 'effect'
|
|
22
|
+
| 'enterable'
|
|
23
|
+
| 'hideAfter'
|
|
24
|
+
| 'offset'
|
|
25
|
+
| 'placement'
|
|
26
|
+
| 'popperClass'
|
|
27
|
+
| 'popperOptions'
|
|
28
|
+
| 'showAfter'
|
|
29
|
+
| 'showArrow'
|
|
30
|
+
| 'transition'
|
|
31
|
+
>
|
|
32
|
+
>
|
|
33
|
+
|
|
34
|
+
type RemovePopperFn = (() => void) & {
|
|
35
|
+
trigger?: HTMLElement
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export const getCell = function (event: Event) {
|
|
39
|
+
return (event.target as HTMLElement)?.closest('td')
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export const orderBy = function <T>(
|
|
43
|
+
array: T[],
|
|
44
|
+
sortKey: string,
|
|
45
|
+
reverse: string | number,
|
|
46
|
+
sortMethod,
|
|
47
|
+
sortBy: string | (string | ((a: T, b: T, array?: T[]) => number))[]
|
|
48
|
+
) {
|
|
49
|
+
if (
|
|
50
|
+
!sortKey &&
|
|
51
|
+
!sortMethod &&
|
|
52
|
+
(!sortBy || (Array.isArray(sortBy) && !sortBy.length))
|
|
53
|
+
) {
|
|
54
|
+
return array
|
|
55
|
+
}
|
|
56
|
+
if (typeof reverse === 'string') {
|
|
57
|
+
reverse = reverse === 'descending' ? -1 : 1
|
|
58
|
+
} else {
|
|
59
|
+
reverse = reverse && reverse < 0 ? -1 : 1
|
|
60
|
+
}
|
|
61
|
+
const getKey = sortMethod
|
|
62
|
+
? null
|
|
63
|
+
: function (value, index) {
|
|
64
|
+
if (sortBy) {
|
|
65
|
+
if (!Array.isArray(sortBy)) {
|
|
66
|
+
sortBy = [sortBy]
|
|
67
|
+
}
|
|
68
|
+
return sortBy.map((by) => {
|
|
69
|
+
if (typeof by === 'string') {
|
|
70
|
+
return get(value, by)
|
|
71
|
+
} else {
|
|
72
|
+
return by(value, index, array)
|
|
73
|
+
}
|
|
74
|
+
})
|
|
75
|
+
}
|
|
76
|
+
if (sortKey !== '$key') {
|
|
77
|
+
if (isObject(value) && '$value' in value) value = value.$value
|
|
78
|
+
}
|
|
79
|
+
return [isObject(value) ? get(value, sortKey) : value]
|
|
80
|
+
}
|
|
81
|
+
const compare = function (a, b) {
|
|
82
|
+
if (sortMethod) {
|
|
83
|
+
return sortMethod(a.value, b.value)
|
|
84
|
+
}
|
|
85
|
+
for (let i = 0, len = a.key.length; i < len; i++) {
|
|
86
|
+
if (a.key[i] < b.key[i]) {
|
|
87
|
+
return -1
|
|
88
|
+
}
|
|
89
|
+
if (a.key[i] > b.key[i]) {
|
|
90
|
+
return 1
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
return 0
|
|
94
|
+
}
|
|
95
|
+
return array
|
|
96
|
+
.map((value, index) => {
|
|
97
|
+
return {
|
|
98
|
+
value,
|
|
99
|
+
index,
|
|
100
|
+
key: getKey ? getKey(value, index) : null,
|
|
101
|
+
}
|
|
102
|
+
})
|
|
103
|
+
.sort((a, b) => {
|
|
104
|
+
let order = compare(a, b)
|
|
105
|
+
if (!order) {
|
|
106
|
+
// make stable https://en.wikipedia.org/wiki/Sorting_algorithm#Stability
|
|
107
|
+
order = a.index - b.index
|
|
108
|
+
}
|
|
109
|
+
return order * +reverse
|
|
110
|
+
})
|
|
111
|
+
.map((item) => item.value)
|
|
112
|
+
}
|
|
113
|
+
|
|
114
|
+
export const getColumnById = function <T>(
|
|
115
|
+
table: {
|
|
116
|
+
columns: TableColumnCtx<T>[]
|
|
117
|
+
},
|
|
118
|
+
columnId: string
|
|
119
|
+
): null | TableColumnCtx<T> {
|
|
120
|
+
let column = null
|
|
121
|
+
table.columns.forEach((item) => {
|
|
122
|
+
if (item.id === columnId) {
|
|
123
|
+
column = item
|
|
124
|
+
}
|
|
125
|
+
})
|
|
126
|
+
return column
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
export const getColumnByKey = function <T>(
|
|
130
|
+
table: {
|
|
131
|
+
columns: TableColumnCtx<T>[]
|
|
132
|
+
},
|
|
133
|
+
columnKey: string
|
|
134
|
+
): TableColumnCtx<T> {
|
|
135
|
+
let column = null
|
|
136
|
+
for (let i = 0; i < table.columns.length; i++) {
|
|
137
|
+
const item = table.columns[i]
|
|
138
|
+
if (item.columnKey === columnKey) {
|
|
139
|
+
column = item
|
|
140
|
+
break
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
if (!column)
|
|
144
|
+
throwError('ElTable', `No column matching with column-key: ${columnKey}`)
|
|
145
|
+
return column
|
|
146
|
+
}
|
|
147
|
+
|
|
148
|
+
export const getColumnByCell = function <T>(
|
|
149
|
+
table: {
|
|
150
|
+
columns: TableColumnCtx<T>[]
|
|
151
|
+
},
|
|
152
|
+
cell: HTMLElement,
|
|
153
|
+
namespace: string
|
|
154
|
+
): null | TableColumnCtx<T> {
|
|
155
|
+
const matches = (cell.className || '').match(
|
|
156
|
+
new RegExp(`${namespace}-table_[^\\s]+`, 'gm')
|
|
157
|
+
)
|
|
158
|
+
if (matches) {
|
|
159
|
+
return getColumnById(table, matches[0])
|
|
160
|
+
}
|
|
161
|
+
return null
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
export const getRowIdentity = <T>(
|
|
165
|
+
row: T,
|
|
166
|
+
rowKey: string | ((row: T) => any)
|
|
167
|
+
): string => {
|
|
168
|
+
if (!row) throw new Error('Row is required when get row identity')
|
|
169
|
+
if (typeof rowKey === 'string') {
|
|
170
|
+
if (!rowKey.includes('.')) {
|
|
171
|
+
return `${row[rowKey]}`
|
|
172
|
+
}
|
|
173
|
+
const key = rowKey.split('.')
|
|
174
|
+
let current = row
|
|
175
|
+
for (const element of key) {
|
|
176
|
+
current = current[element]
|
|
177
|
+
}
|
|
178
|
+
return `${current}`
|
|
179
|
+
} else if (typeof rowKey === 'function') {
|
|
180
|
+
return rowKey.call(null, row)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export const getKeysMap = function <T>(
|
|
185
|
+
array: T[],
|
|
186
|
+
rowKey: string
|
|
187
|
+
): Record<string, { row: T; index: number }> {
|
|
188
|
+
const arrayMap = {}
|
|
189
|
+
;(array || []).forEach((row, index) => {
|
|
190
|
+
arrayMap[getRowIdentity(row, rowKey)] = { row, index }
|
|
191
|
+
})
|
|
192
|
+
return arrayMap
|
|
193
|
+
}
|
|
194
|
+
|
|
195
|
+
export function mergeOptions<T, K>(defaults: T, config: K): T & K {
|
|
196
|
+
const options = {} as T & K
|
|
197
|
+
let key
|
|
198
|
+
for (key in defaults) {
|
|
199
|
+
options[key] = defaults[key]
|
|
200
|
+
}
|
|
201
|
+
for (key in config) {
|
|
202
|
+
if (hasOwn(config as unknown as Record<string, any>, key)) {
|
|
203
|
+
const value = config[key]
|
|
204
|
+
if (typeof value !== 'undefined') {
|
|
205
|
+
options[key] = value
|
|
206
|
+
}
|
|
207
|
+
}
|
|
208
|
+
}
|
|
209
|
+
return options
|
|
210
|
+
}
|
|
211
|
+
|
|
212
|
+
export function parseWidth(width: number | string): number | string {
|
|
213
|
+
if (width === '') return width
|
|
214
|
+
if (width !== undefined) {
|
|
215
|
+
width = Number.parseInt(width as string, 10)
|
|
216
|
+
if (Number.isNaN(width)) {
|
|
217
|
+
width = ''
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
return width
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
export function parseMinWidth(minWidth: number | string): number | string {
|
|
224
|
+
if (minWidth === '') return minWidth
|
|
225
|
+
if (minWidth !== undefined) {
|
|
226
|
+
minWidth = parseWidth(minWidth)
|
|
227
|
+
if (Number.isNaN(minWidth)) {
|
|
228
|
+
minWidth = 80
|
|
229
|
+
}
|
|
230
|
+
}
|
|
231
|
+
return minWidth
|
|
232
|
+
}
|
|
233
|
+
|
|
234
|
+
export function parseHeight(height: number | string) {
|
|
235
|
+
if (typeof height === 'number') {
|
|
236
|
+
return height
|
|
237
|
+
}
|
|
238
|
+
if (typeof height === 'string') {
|
|
239
|
+
if (/^\d+(?:px)?$/.test(height)) {
|
|
240
|
+
return Number.parseInt(height, 10)
|
|
241
|
+
} else {
|
|
242
|
+
return height
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
return null
|
|
246
|
+
}
|
|
247
|
+
|
|
248
|
+
// https://github.com/reduxjs/redux/blob/master/src/compose.js
|
|
249
|
+
export function compose(...funcs) {
|
|
250
|
+
if (funcs.length === 0) {
|
|
251
|
+
return (arg) => arg
|
|
252
|
+
}
|
|
253
|
+
if (funcs.length === 1) {
|
|
254
|
+
return funcs[0]
|
|
255
|
+
}
|
|
256
|
+
return funcs.reduce(
|
|
257
|
+
(a, b) =>
|
|
258
|
+
(...args) =>
|
|
259
|
+
a(b(...args))
|
|
260
|
+
)
|
|
261
|
+
}
|
|
262
|
+
|
|
263
|
+
export function toggleRowStatus<T>(
|
|
264
|
+
statusArr: T[],
|
|
265
|
+
row: T,
|
|
266
|
+
newVal: boolean
|
|
267
|
+
): boolean {
|
|
268
|
+
let changed = false
|
|
269
|
+
const index = statusArr.indexOf(row)
|
|
270
|
+
const included = index !== -1
|
|
271
|
+
|
|
272
|
+
const toggleStatus = (type: 'add' | 'remove') => {
|
|
273
|
+
if (type === 'add') {
|
|
274
|
+
statusArr.push(row)
|
|
275
|
+
} else {
|
|
276
|
+
statusArr.splice(index, 1)
|
|
277
|
+
}
|
|
278
|
+
changed = true
|
|
279
|
+
if (isArray(row.children)) {
|
|
280
|
+
row.children.forEach((item) => {
|
|
281
|
+
toggleRowStatus(statusArr, item, newVal ?? !included)
|
|
282
|
+
})
|
|
283
|
+
}
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
if (isBoolean(newVal)) {
|
|
287
|
+
if (newVal && !included) {
|
|
288
|
+
toggleStatus('add')
|
|
289
|
+
} else if (!newVal && included) {
|
|
290
|
+
toggleStatus('remove')
|
|
291
|
+
}
|
|
292
|
+
} else {
|
|
293
|
+
included ? toggleStatus('remove') : toggleStatus('add')
|
|
294
|
+
}
|
|
295
|
+
return changed
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
export function walkTreeNode(
|
|
299
|
+
root,
|
|
300
|
+
cb,
|
|
301
|
+
childrenKey = 'children',
|
|
302
|
+
lazyKey = 'hasChildren'
|
|
303
|
+
) {
|
|
304
|
+
const isNil = (array) => !(Array.isArray(array) && array.length)
|
|
305
|
+
|
|
306
|
+
function _walker(parent, children, level) {
|
|
307
|
+
cb(parent, children, level)
|
|
308
|
+
children.forEach((item) => {
|
|
309
|
+
if (item[lazyKey]) {
|
|
310
|
+
cb(item, null, level + 1)
|
|
311
|
+
return
|
|
312
|
+
}
|
|
313
|
+
const children = item[childrenKey]
|
|
314
|
+
if (!isNil(children)) {
|
|
315
|
+
_walker(item, children, level + 1)
|
|
316
|
+
}
|
|
317
|
+
})
|
|
318
|
+
}
|
|
319
|
+
|
|
320
|
+
root.forEach((item) => {
|
|
321
|
+
if (item[lazyKey]) {
|
|
322
|
+
cb(item, null, 0)
|
|
323
|
+
return
|
|
324
|
+
}
|
|
325
|
+
const children = item[childrenKey]
|
|
326
|
+
if (!isNil(children)) {
|
|
327
|
+
_walker(item, children, 0)
|
|
328
|
+
}
|
|
329
|
+
})
|
|
330
|
+
}
|
|
331
|
+
|
|
332
|
+
export let removePopper: RemovePopperFn | null = null
|
|
333
|
+
|
|
334
|
+
export function createTablePopper(
|
|
335
|
+
props: TableOverflowTooltipOptions,
|
|
336
|
+
popperContent: string,
|
|
337
|
+
trigger: HTMLElement,
|
|
338
|
+
table: Table<[]>
|
|
339
|
+
) {
|
|
340
|
+
if (removePopper?.trigger === trigger) {
|
|
341
|
+
return
|
|
342
|
+
}
|
|
343
|
+
removePopper?.()
|
|
344
|
+
const parentNode = table?.refs.tableWrapper
|
|
345
|
+
const ns = parentNode?.dataset.prefix
|
|
346
|
+
const popperOptions = {
|
|
347
|
+
strategy: 'fixed',
|
|
348
|
+
...props.popperOptions,
|
|
349
|
+
}
|
|
350
|
+
const vm = createVNode(ElTooltip, {
|
|
351
|
+
content: popperContent,
|
|
352
|
+
virtualTriggering: true,
|
|
353
|
+
virtualRef: trigger,
|
|
354
|
+
appendTo: parentNode,
|
|
355
|
+
placement: 'top',
|
|
356
|
+
transition: 'none', // Default does not require transition
|
|
357
|
+
offset: 0,
|
|
358
|
+
hideAfter: 0,
|
|
359
|
+
...props,
|
|
360
|
+
popperOptions,
|
|
361
|
+
onHide: () => {
|
|
362
|
+
removePopper?.()
|
|
363
|
+
},
|
|
364
|
+
})
|
|
365
|
+
vm.appContext = { ...table.appContext, ...table }
|
|
366
|
+
const container = document.createElement('div')
|
|
367
|
+
render(vm, container)
|
|
368
|
+
vm.component!.exposed!.onOpen()
|
|
369
|
+
const scrollContainer = parentNode?.querySelector(`.${ns}-scrollbar__wrap`)
|
|
370
|
+
removePopper = () => {
|
|
371
|
+
render(null, container)
|
|
372
|
+
scrollContainer?.removeEventListener('scroll', removePopper!)
|
|
373
|
+
removePopper = null
|
|
374
|
+
}
|
|
375
|
+
removePopper.trigger = trigger
|
|
376
|
+
scrollContainer?.addEventListener('scroll', removePopper)
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function getCurrentColumns<T>(column: TableColumnCtx<T>): TableColumnCtx<T>[] {
|
|
380
|
+
if (column.children) {
|
|
381
|
+
return flatMap(column.children, getCurrentColumns)
|
|
382
|
+
} else {
|
|
383
|
+
return [column]
|
|
384
|
+
}
|
|
385
|
+
}
|
|
386
|
+
|
|
387
|
+
function getColSpan<T>(colSpan: number, column: TableColumnCtx<T>) {
|
|
388
|
+
return colSpan + column.colSpan
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
export const isFixedColumn = <T>(
|
|
392
|
+
index: number,
|
|
393
|
+
fixed: string | boolean,
|
|
394
|
+
store: any,
|
|
395
|
+
realColumns?: TableColumnCtx<T>[]
|
|
396
|
+
) => {
|
|
397
|
+
let start = 0
|
|
398
|
+
let after = index
|
|
399
|
+
const columns = store.states.columns.value
|
|
400
|
+
if (realColumns) {
|
|
401
|
+
// fixed column supported in grouped header
|
|
402
|
+
const curColumns = getCurrentColumns(realColumns[index])
|
|
403
|
+
const preColumns = columns.slice(0, columns.indexOf(curColumns[0]))
|
|
404
|
+
|
|
405
|
+
start = preColumns.reduce(getColSpan, 0)
|
|
406
|
+
after = start + curColumns.reduce(getColSpan, 0) - 1
|
|
407
|
+
} else {
|
|
408
|
+
start = index
|
|
409
|
+
}
|
|
410
|
+
let fixedLayout
|
|
411
|
+
switch (fixed) {
|
|
412
|
+
case 'left':
|
|
413
|
+
if (after < store.states.fixedLeafColumnsLength.value) {
|
|
414
|
+
fixedLayout = 'left'
|
|
415
|
+
}
|
|
416
|
+
break
|
|
417
|
+
case 'right':
|
|
418
|
+
if (
|
|
419
|
+
start >=
|
|
420
|
+
columns.length - store.states.rightFixedLeafColumnsLength.value
|
|
421
|
+
) {
|
|
422
|
+
fixedLayout = 'right'
|
|
423
|
+
}
|
|
424
|
+
break
|
|
425
|
+
default:
|
|
426
|
+
if (after < store.states.fixedLeafColumnsLength.value) {
|
|
427
|
+
fixedLayout = 'left'
|
|
428
|
+
} else if (
|
|
429
|
+
start >=
|
|
430
|
+
columns.length - store.states.rightFixedLeafColumnsLength.value
|
|
431
|
+
) {
|
|
432
|
+
fixedLayout = 'right'
|
|
433
|
+
}
|
|
434
|
+
}
|
|
435
|
+
return fixedLayout
|
|
436
|
+
? {
|
|
437
|
+
direction: fixedLayout,
|
|
438
|
+
start,
|
|
439
|
+
after,
|
|
440
|
+
}
|
|
441
|
+
: {}
|
|
442
|
+
}
|
|
443
|
+
|
|
444
|
+
export const getFixedColumnsClass = <T>(
|
|
445
|
+
namespace: string,
|
|
446
|
+
index: number,
|
|
447
|
+
fixed: string | boolean,
|
|
448
|
+
store: any,
|
|
449
|
+
realColumns?: TableColumnCtx<T>[],
|
|
450
|
+
offset = 0
|
|
451
|
+
) => {
|
|
452
|
+
const classes: string[] = []
|
|
453
|
+
const { direction, start, after } = isFixedColumn(
|
|
454
|
+
index,
|
|
455
|
+
fixed,
|
|
456
|
+
store,
|
|
457
|
+
realColumns
|
|
458
|
+
)
|
|
459
|
+
if (direction) {
|
|
460
|
+
const isLeft = direction === 'left'
|
|
461
|
+
classes.push(`${namespace}-fixed-column--${direction}`)
|
|
462
|
+
if (
|
|
463
|
+
isLeft &&
|
|
464
|
+
after + offset === store.states.fixedLeafColumnsLength.value - 1
|
|
465
|
+
) {
|
|
466
|
+
classes.push('is-last-column')
|
|
467
|
+
} else if (
|
|
468
|
+
!isLeft &&
|
|
469
|
+
start - offset ===
|
|
470
|
+
store.states.columns.value.length -
|
|
471
|
+
store.states.rightFixedLeafColumnsLength.value
|
|
472
|
+
) {
|
|
473
|
+
classes.push('is-first-column')
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
return classes
|
|
477
|
+
}
|
|
478
|
+
|
|
479
|
+
function getOffset<T>(offset: number, column: TableColumnCtx<T>) {
|
|
480
|
+
return (
|
|
481
|
+
offset +
|
|
482
|
+
(column.realWidth === null || Number.isNaN(column.realWidth)
|
|
483
|
+
? Number(column.width)
|
|
484
|
+
: column.realWidth)
|
|
485
|
+
)
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
export const getFixedColumnOffset = <T>(
|
|
489
|
+
index: number,
|
|
490
|
+
fixed: string | boolean,
|
|
491
|
+
store: any,
|
|
492
|
+
realColumns?: TableColumnCtx<T>[]
|
|
493
|
+
) => {
|
|
494
|
+
const {
|
|
495
|
+
direction,
|
|
496
|
+
start = 0,
|
|
497
|
+
after = 0,
|
|
498
|
+
} = isFixedColumn(index, fixed, store, realColumns)
|
|
499
|
+
if (!direction) {
|
|
500
|
+
return
|
|
501
|
+
}
|
|
502
|
+
const styles: any = {}
|
|
503
|
+
const isLeft = direction === 'left'
|
|
504
|
+
const columns = store.states.columns.value
|
|
505
|
+
if (isLeft) {
|
|
506
|
+
styles.left = columns.slice(0, start).reduce(getOffset, 0)
|
|
507
|
+
} else {
|
|
508
|
+
styles.right = columns
|
|
509
|
+
.slice(after + 1)
|
|
510
|
+
.reverse()
|
|
511
|
+
.reduce(getOffset, 0)
|
|
512
|
+
}
|
|
513
|
+
return styles
|
|
514
|
+
}
|
|
515
|
+
|
|
516
|
+
export const ensurePosition = (style, key: string) => {
|
|
517
|
+
if (!style) return
|
|
518
|
+
if (!Number.isNaN(style[key])) {
|
|
519
|
+
style[key] = `${style[key]}px`
|
|
520
|
+
}
|
|
521
|
+
}
|
package/tsconfig.json
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
{
|
|
2
|
+
"compilerOptions": {
|
|
3
|
+
"outDir": "./dist/",
|
|
4
|
+
"module": "esnext",
|
|
5
|
+
"target": "es5",
|
|
6
|
+
// "strict": true,
|
|
7
|
+
"moduleResolution": "node",
|
|
8
|
+
"esModuleInterop": true,
|
|
9
|
+
"skipLibCheck": true,
|
|
10
|
+
"forceConsistentCasingInFileNames": true,
|
|
11
|
+
"jsx": "preserve", // 如果使用 React 的话,否则可以省略或改为 "preserve" 等选项,取决于你的项目需求。
|
|
12
|
+
"allowJs": true,
|
|
13
|
+
"baseUrl": ".",
|
|
14
|
+
"paths": {
|
|
15
|
+
"*": ["src/*"]
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"include": ["src/**/*"]
|
|
19
|
+
}
|
package/vue-shims.d.ts
ADDED