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,88 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { getCurrentInstance, watch } from 'vue'
|
|
3
|
+
import { hasOwn } from 'element-plus/es/utils/index.mjs'
|
|
4
|
+
import { parseMinWidth, parseWidth } from '../util'
|
|
5
|
+
|
|
6
|
+
import type { ComputedRef } from 'vue'
|
|
7
|
+
import type { TableColumn, TableColumnCtx, ValueOf } from './defaults'
|
|
8
|
+
|
|
9
|
+
function getAllAliases(props, aliases) {
|
|
10
|
+
return props.reduce((prev, cur) => {
|
|
11
|
+
prev[cur] = cur
|
|
12
|
+
return prev
|
|
13
|
+
}, aliases)
|
|
14
|
+
}
|
|
15
|
+
function useWatcher<T>(
|
|
16
|
+
owner: ComputedRef<any>,
|
|
17
|
+
props_: Partial<TableColumnCtx<T>>
|
|
18
|
+
) {
|
|
19
|
+
const instance = getCurrentInstance() as TableColumn<T>
|
|
20
|
+
const registerComplexWatchers = () => {
|
|
21
|
+
const props = ['fixed']
|
|
22
|
+
const aliases = {
|
|
23
|
+
realWidth: 'width',
|
|
24
|
+
realMinWidth: 'minWidth',
|
|
25
|
+
}
|
|
26
|
+
const allAliases = getAllAliases(props, aliases)
|
|
27
|
+
Object.keys(allAliases).forEach((key) => {
|
|
28
|
+
const columnKey = aliases[key]
|
|
29
|
+
if (hasOwn(props_, columnKey)) {
|
|
30
|
+
watch(
|
|
31
|
+
() => props_[columnKey],
|
|
32
|
+
(newVal) => {
|
|
33
|
+
let value: ValueOf<TableColumnCtx<T>> = newVal
|
|
34
|
+
if (columnKey === 'width' && key === 'realWidth') {
|
|
35
|
+
value = parseWidth(newVal)
|
|
36
|
+
}
|
|
37
|
+
if (columnKey === 'minWidth' && key === 'realMinWidth') {
|
|
38
|
+
value = parseMinWidth(newVal)
|
|
39
|
+
}
|
|
40
|
+
instance.columnConfig.value[columnKey as any] = value
|
|
41
|
+
instance.columnConfig.value[key] = value
|
|
42
|
+
const updateColumns = columnKey === 'fixed'
|
|
43
|
+
owner.value.store.scheduleLayout(updateColumns)
|
|
44
|
+
}
|
|
45
|
+
)
|
|
46
|
+
}
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
const registerNormalWatchers = () => {
|
|
50
|
+
const props = [
|
|
51
|
+
'label',
|
|
52
|
+
'filters',
|
|
53
|
+
'filterMultiple',
|
|
54
|
+
'filteredValue',
|
|
55
|
+
'sortable',
|
|
56
|
+
'index',
|
|
57
|
+
'formatter',
|
|
58
|
+
'className',
|
|
59
|
+
'labelClassName',
|
|
60
|
+
'filterClassName',
|
|
61
|
+
'showOverflowTooltip',
|
|
62
|
+
]
|
|
63
|
+
const aliases = {
|
|
64
|
+
property: 'prop',
|
|
65
|
+
align: 'realAlign',
|
|
66
|
+
headerAlign: 'realHeaderAlign',
|
|
67
|
+
}
|
|
68
|
+
const allAliases = getAllAliases(props, aliases)
|
|
69
|
+
Object.keys(allAliases).forEach((key) => {
|
|
70
|
+
const columnKey = aliases[key]
|
|
71
|
+
if (hasOwn(props_, columnKey)) {
|
|
72
|
+
watch(
|
|
73
|
+
() => props_[columnKey],
|
|
74
|
+
(newVal) => {
|
|
75
|
+
instance.columnConfig.value[key] = newVal
|
|
76
|
+
}
|
|
77
|
+
)
|
|
78
|
+
}
|
|
79
|
+
})
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
return {
|
|
83
|
+
registerComplexWatchers,
|
|
84
|
+
registerNormalWatchers,
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
export default useWatcher
|
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { defineComponent, h } from 'vue'
|
|
3
|
+
import { useNamespace } from 'element-plus/es/hooks/index.mjs'
|
|
4
|
+
import useStyle from './style-helper'
|
|
5
|
+
import type { Store } from '../store'
|
|
6
|
+
|
|
7
|
+
import type { PropType } from 'vue'
|
|
8
|
+
import type { DefaultRow, Sort, SummaryMethod } from '../table/defaults'
|
|
9
|
+
export interface TableFooter<T> {
|
|
10
|
+
fixed: string
|
|
11
|
+
store: Store<T>
|
|
12
|
+
summaryMethod: SummaryMethod<T>
|
|
13
|
+
sumText: string
|
|
14
|
+
border: boolean
|
|
15
|
+
defaultSort: Sort
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export default defineComponent({
|
|
19
|
+
name: 'ElTableFooter',
|
|
20
|
+
|
|
21
|
+
props: {
|
|
22
|
+
fixed: {
|
|
23
|
+
type: String,
|
|
24
|
+
default: '',
|
|
25
|
+
},
|
|
26
|
+
store: {
|
|
27
|
+
required: true,
|
|
28
|
+
type: Object as PropType<TableFooter<DefaultRow>['store']>,
|
|
29
|
+
},
|
|
30
|
+
summaryMethod: Function as PropType<
|
|
31
|
+
TableFooter<DefaultRow>['summaryMethod']
|
|
32
|
+
>,
|
|
33
|
+
sumText: String,
|
|
34
|
+
border: Boolean,
|
|
35
|
+
defaultSort: {
|
|
36
|
+
type: Object as PropType<TableFooter<DefaultRow>['defaultSort']>,
|
|
37
|
+
default: () => {
|
|
38
|
+
return {
|
|
39
|
+
prop: '',
|
|
40
|
+
order: '',
|
|
41
|
+
}
|
|
42
|
+
},
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
setup(props) {
|
|
46
|
+
const { getCellClasses, getCellStyles, columns } = useStyle(
|
|
47
|
+
props as TableFooter<DefaultRow>
|
|
48
|
+
)
|
|
49
|
+
const ns = useNamespace('table')
|
|
50
|
+
return {
|
|
51
|
+
ns,
|
|
52
|
+
getCellClasses,
|
|
53
|
+
getCellStyles,
|
|
54
|
+
columns,
|
|
55
|
+
}
|
|
56
|
+
},
|
|
57
|
+
render() {
|
|
58
|
+
const { columns, getCellStyles, getCellClasses, summaryMethod, sumText } =
|
|
59
|
+
this
|
|
60
|
+
const data = this.store.states.data.value
|
|
61
|
+
let sums = []
|
|
62
|
+
if (summaryMethod) {
|
|
63
|
+
sums = summaryMethod({
|
|
64
|
+
columns,
|
|
65
|
+
data,
|
|
66
|
+
})
|
|
67
|
+
} else {
|
|
68
|
+
columns.forEach((column, index) => {
|
|
69
|
+
if (index === 0) {
|
|
70
|
+
sums[index] = sumText
|
|
71
|
+
return
|
|
72
|
+
}
|
|
73
|
+
const values = data.map((item) => Number(item[column.property]))
|
|
74
|
+
const precisions = []
|
|
75
|
+
let notNumber = true
|
|
76
|
+
values.forEach((value) => {
|
|
77
|
+
if (!Number.isNaN(+value)) {
|
|
78
|
+
notNumber = false
|
|
79
|
+
const decimal = `${value}`.split('.')[1]
|
|
80
|
+
precisions.push(decimal ? decimal.length : 0)
|
|
81
|
+
}
|
|
82
|
+
})
|
|
83
|
+
const precision = Math.max.apply(null, precisions)
|
|
84
|
+
if (!notNumber) {
|
|
85
|
+
sums[index] = values.reduce((prev, curr) => {
|
|
86
|
+
const value = Number(curr)
|
|
87
|
+
if (!Number.isNaN(+value)) {
|
|
88
|
+
return Number.parseFloat(
|
|
89
|
+
(prev + curr).toFixed(Math.min(precision, 20))
|
|
90
|
+
)
|
|
91
|
+
} else {
|
|
92
|
+
return prev
|
|
93
|
+
}
|
|
94
|
+
}, 0)
|
|
95
|
+
} else {
|
|
96
|
+
sums[index] = ''
|
|
97
|
+
}
|
|
98
|
+
})
|
|
99
|
+
}
|
|
100
|
+
return h(
|
|
101
|
+
h('tfoot', [
|
|
102
|
+
h('tr', {}, [
|
|
103
|
+
...columns.map((column, cellIndex) =>
|
|
104
|
+
h(
|
|
105
|
+
'td',
|
|
106
|
+
{
|
|
107
|
+
key: cellIndex,
|
|
108
|
+
colspan: column.colSpan,
|
|
109
|
+
rowspan: column.rowSpan,
|
|
110
|
+
class: getCellClasses(columns, cellIndex),
|
|
111
|
+
style: getCellStyles(column, cellIndex),
|
|
112
|
+
},
|
|
113
|
+
[
|
|
114
|
+
h(
|
|
115
|
+
'div',
|
|
116
|
+
{
|
|
117
|
+
class: ['cell', column.labelClassName],
|
|
118
|
+
},
|
|
119
|
+
[sums[cellIndex]]
|
|
120
|
+
),
|
|
121
|
+
]
|
|
122
|
+
)
|
|
123
|
+
),
|
|
124
|
+
]),
|
|
125
|
+
])
|
|
126
|
+
)
|
|
127
|
+
},
|
|
128
|
+
})
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
import { computed, inject } from 'vue'
|
|
2
|
+
import { TABLE_INJECTION_KEY } from '../tokens'
|
|
3
|
+
|
|
4
|
+
function useMapState() {
|
|
5
|
+
const table = inject(TABLE_INJECTION_KEY)
|
|
6
|
+
const store = table?.store
|
|
7
|
+
const leftFixedLeafCount = computed(() => {
|
|
8
|
+
return store.states.fixedLeafColumnsLength.value
|
|
9
|
+
})
|
|
10
|
+
const rightFixedLeafCount = computed(() => {
|
|
11
|
+
return store.states.rightFixedColumns.value.length
|
|
12
|
+
})
|
|
13
|
+
const columnsCount = computed(() => {
|
|
14
|
+
return store.states.columns.value.length
|
|
15
|
+
})
|
|
16
|
+
const leftFixedCount = computed(() => {
|
|
17
|
+
return store.states.fixedColumns.value.length
|
|
18
|
+
})
|
|
19
|
+
const rightFixedCount = computed(() => {
|
|
20
|
+
return store.states.rightFixedColumns.value.length
|
|
21
|
+
})
|
|
22
|
+
|
|
23
|
+
return {
|
|
24
|
+
leftFixedLeafCount,
|
|
25
|
+
rightFixedLeafCount,
|
|
26
|
+
columnsCount,
|
|
27
|
+
leftFixedCount,
|
|
28
|
+
rightFixedCount,
|
|
29
|
+
columns: store.states.columns,
|
|
30
|
+
}
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export default useMapState
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
import { useNamespace } from 'element-plus/es/hooks/index.mjs'
|
|
2
|
+
import {
|
|
3
|
+
ensurePosition,
|
|
4
|
+
getFixedColumnOffset,
|
|
5
|
+
getFixedColumnsClass,
|
|
6
|
+
} from '../util'
|
|
7
|
+
import useMapState from './mapState-helper'
|
|
8
|
+
import type { TableColumnCtx } from '../table-column/defaults'
|
|
9
|
+
import type { TableFooter } from '.'
|
|
10
|
+
|
|
11
|
+
function useStyle<T>(props: TableFooter<T>) {
|
|
12
|
+
const { columns } = useMapState()
|
|
13
|
+
const ns = useNamespace('table')
|
|
14
|
+
|
|
15
|
+
const getCellClasses = (columns: TableColumnCtx<T>[], cellIndex: number) => {
|
|
16
|
+
const column = columns[cellIndex]
|
|
17
|
+
const classes = [
|
|
18
|
+
ns.e('cell'),
|
|
19
|
+
column.id,
|
|
20
|
+
column.align,
|
|
21
|
+
column.labelClassName,
|
|
22
|
+
...getFixedColumnsClass(ns.b(), cellIndex, column.fixed, props.store),
|
|
23
|
+
]
|
|
24
|
+
if (column.className) {
|
|
25
|
+
classes.push(column.className)
|
|
26
|
+
}
|
|
27
|
+
if (!column.children) {
|
|
28
|
+
classes.push(ns.is('leaf'))
|
|
29
|
+
}
|
|
30
|
+
return classes
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const getCellStyles = (column: TableColumnCtx<T>, cellIndex: number) => {
|
|
34
|
+
const fixedStyle = getFixedColumnOffset(
|
|
35
|
+
cellIndex,
|
|
36
|
+
column.fixed,
|
|
37
|
+
props.store
|
|
38
|
+
)
|
|
39
|
+
ensurePosition(fixedStyle, 'left')
|
|
40
|
+
ensurePosition(fixedStyle, 'right')
|
|
41
|
+
return fixedStyle
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
return {
|
|
45
|
+
getCellClasses,
|
|
46
|
+
getCellStyles,
|
|
47
|
+
columns,
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
export default useStyle
|
|
@@ -0,0 +1,213 @@
|
|
|
1
|
+
// @ts-nocheck
|
|
2
|
+
import { getCurrentInstance, inject, ref } from 'vue'
|
|
3
|
+
import {
|
|
4
|
+
addClass,
|
|
5
|
+
hasClass,
|
|
6
|
+
isClient,
|
|
7
|
+
isElement,
|
|
8
|
+
removeClass,
|
|
9
|
+
} from 'element-plus/es/utils/index.mjs'
|
|
10
|
+
import { TABLE_INJECTION_KEY } from '../tokens'
|
|
11
|
+
import type { TableHeaderProps } from '.'
|
|
12
|
+
import type { TableColumnCtx } from '../table-column/defaults'
|
|
13
|
+
|
|
14
|
+
function useEvent<T>(props: TableHeaderProps<T>, emit) {
|
|
15
|
+
const instance = getCurrentInstance()
|
|
16
|
+
const parent = inject(TABLE_INJECTION_KEY)
|
|
17
|
+
const handleFilterClick = (event: Event) => {
|
|
18
|
+
event.stopPropagation()
|
|
19
|
+
return
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const handleHeaderClick = (event: Event, column: TableColumnCtx<T>) => {
|
|
23
|
+
if (!column.filters && column.sortable) {
|
|
24
|
+
handleSortClick(event, column, false)
|
|
25
|
+
} else if (column.filterable && !column.sortable) {
|
|
26
|
+
handleFilterClick(event)
|
|
27
|
+
}
|
|
28
|
+
parent?.emit('header-click', column, event)
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
const handleHeaderContextMenu = (event: Event, column: TableColumnCtx<T>) => {
|
|
32
|
+
parent?.emit('header-contextmenu', column, event)
|
|
33
|
+
}
|
|
34
|
+
const draggingColumn = ref(null)
|
|
35
|
+
const dragging = ref(false)
|
|
36
|
+
const dragState = ref({})
|
|
37
|
+
const handleMouseDown = (event: MouseEvent, column: TableColumnCtx<T>) => {
|
|
38
|
+
if (!isClient) return
|
|
39
|
+
if (column.children && column.children.length > 0) return
|
|
40
|
+
/* istanbul ignore if */
|
|
41
|
+
if (draggingColumn.value && props.border) {
|
|
42
|
+
dragging.value = true
|
|
43
|
+
|
|
44
|
+
const table = parent
|
|
45
|
+
emit('set-drag-visible', true)
|
|
46
|
+
const tableEl = table?.vnode.el
|
|
47
|
+
const tableLeft = tableEl.getBoundingClientRect().left
|
|
48
|
+
const columnEl = instance.vnode.el.querySelector(`th.${column.id}`)
|
|
49
|
+
const columnRect = columnEl.getBoundingClientRect()
|
|
50
|
+
const minLeft = columnRect.left - tableLeft + 30
|
|
51
|
+
|
|
52
|
+
addClass(columnEl, 'noclick')
|
|
53
|
+
|
|
54
|
+
dragState.value = {
|
|
55
|
+
startMouseLeft: event.clientX,
|
|
56
|
+
startLeft: columnRect.right - tableLeft,
|
|
57
|
+
startColumnLeft: columnRect.left - tableLeft,
|
|
58
|
+
tableLeft,
|
|
59
|
+
}
|
|
60
|
+
const resizeProxy = table?.refs.resizeProxy as HTMLElement
|
|
61
|
+
resizeProxy.style.left = `${(dragState.value as any).startLeft}px`
|
|
62
|
+
|
|
63
|
+
document.onselectstart = function () {
|
|
64
|
+
return false
|
|
65
|
+
}
|
|
66
|
+
document.ondragstart = function () {
|
|
67
|
+
return false
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
const handleMouseMove = (event: MouseEvent) => {
|
|
71
|
+
const deltaLeft =
|
|
72
|
+
event.clientX - (dragState.value as any).startMouseLeft
|
|
73
|
+
const proxyLeft = (dragState.value as any).startLeft + deltaLeft
|
|
74
|
+
|
|
75
|
+
resizeProxy.style.left = `${Math.max(minLeft, proxyLeft)}px`
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
const handleMouseUp = () => {
|
|
79
|
+
if (dragging.value) {
|
|
80
|
+
const { startColumnLeft, startLeft } = dragState.value as any
|
|
81
|
+
const finalLeft = Number.parseInt(resizeProxy.style.left, 10)
|
|
82
|
+
const columnWidth = finalLeft - startColumnLeft
|
|
83
|
+
column.width = column.realWidth = columnWidth
|
|
84
|
+
table?.emit(
|
|
85
|
+
'header-dragend',
|
|
86
|
+
column.width,
|
|
87
|
+
startLeft - startColumnLeft,
|
|
88
|
+
column,
|
|
89
|
+
event
|
|
90
|
+
)
|
|
91
|
+
requestAnimationFrame(() => {
|
|
92
|
+
props.store.scheduleLayout(false, true)
|
|
93
|
+
})
|
|
94
|
+
document.body.style.cursor = ''
|
|
95
|
+
dragging.value = false
|
|
96
|
+
draggingColumn.value = null
|
|
97
|
+
dragState.value = {}
|
|
98
|
+
emit('set-drag-visible', false)
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
document.removeEventListener('mousemove', handleMouseMove)
|
|
102
|
+
document.removeEventListener('mouseup', handleMouseUp)
|
|
103
|
+
document.onselectstart = null
|
|
104
|
+
document.ondragstart = null
|
|
105
|
+
|
|
106
|
+
setTimeout(() => {
|
|
107
|
+
removeClass(columnEl, 'noclick')
|
|
108
|
+
}, 0)
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
document.addEventListener('mousemove', handleMouseMove)
|
|
112
|
+
document.addEventListener('mouseup', handleMouseUp)
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
|
|
116
|
+
const handleMouseMove = (event: MouseEvent, column: TableColumnCtx<T>) => {
|
|
117
|
+
if (column.children && column.children.length > 0) return
|
|
118
|
+
const el = event.target as HTMLElement
|
|
119
|
+
if (!isElement(el)) {
|
|
120
|
+
return
|
|
121
|
+
}
|
|
122
|
+
const target = el?.closest('th')
|
|
123
|
+
|
|
124
|
+
if (!column || !column.resizable) return
|
|
125
|
+
|
|
126
|
+
if (!dragging.value && props.border) {
|
|
127
|
+
const rect = target.getBoundingClientRect()
|
|
128
|
+
|
|
129
|
+
const bodyStyle = document.body.style
|
|
130
|
+
if (rect.width > 12 && rect.right - event.pageX < 8) {
|
|
131
|
+
bodyStyle.cursor = 'col-resize'
|
|
132
|
+
if (hasClass(target, 'is-sortable')) {
|
|
133
|
+
target.style.cursor = 'col-resize'
|
|
134
|
+
}
|
|
135
|
+
draggingColumn.value = column
|
|
136
|
+
} else if (!dragging.value) {
|
|
137
|
+
bodyStyle.cursor = ''
|
|
138
|
+
if (hasClass(target, 'is-sortable')) {
|
|
139
|
+
target.style.cursor = 'pointer'
|
|
140
|
+
}
|
|
141
|
+
draggingColumn.value = null
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
const handleMouseOut = () => {
|
|
147
|
+
if (!isClient) return
|
|
148
|
+
document.body.style.cursor = ''
|
|
149
|
+
}
|
|
150
|
+
const toggleOrder = ({ order, sortOrders }) => {
|
|
151
|
+
if (order === '') return sortOrders[0]
|
|
152
|
+
const index = sortOrders.indexOf(order || null)
|
|
153
|
+
return sortOrders[index > sortOrders.length - 2 ? 0 : index + 1]
|
|
154
|
+
}
|
|
155
|
+
const handleSortClick = (
|
|
156
|
+
event: Event,
|
|
157
|
+
column: TableColumnCtx<T>,
|
|
158
|
+
givenOrder: string | boolean
|
|
159
|
+
) => {
|
|
160
|
+
event.stopPropagation()
|
|
161
|
+
const order =
|
|
162
|
+
column.order === givenOrder ? null : givenOrder || toggleOrder(column)
|
|
163
|
+
|
|
164
|
+
const target = (event.target as HTMLElement)?.closest('th')
|
|
165
|
+
|
|
166
|
+
if (target) {
|
|
167
|
+
if (hasClass(target, 'noclick')) {
|
|
168
|
+
removeClass(target, 'noclick')
|
|
169
|
+
return
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
if (!column.sortable) return
|
|
174
|
+
|
|
175
|
+
const states = props.store.states
|
|
176
|
+
let sortProp = states.sortProp.value
|
|
177
|
+
let sortOrder
|
|
178
|
+
const sortingColumn = states.sortingColumn.value
|
|
179
|
+
|
|
180
|
+
if (
|
|
181
|
+
sortingColumn !== column ||
|
|
182
|
+
(sortingColumn === column && sortingColumn.order === null)
|
|
183
|
+
) {
|
|
184
|
+
if (sortingColumn) {
|
|
185
|
+
sortingColumn.order = null
|
|
186
|
+
}
|
|
187
|
+
states.sortingColumn.value = column
|
|
188
|
+
sortProp = column.property
|
|
189
|
+
}
|
|
190
|
+
if (!order) {
|
|
191
|
+
sortOrder = column.order = null
|
|
192
|
+
} else {
|
|
193
|
+
sortOrder = column.order = order
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
states.sortProp.value = sortProp
|
|
197
|
+
states.sortOrder.value = sortOrder
|
|
198
|
+
|
|
199
|
+
parent?.store.commit('changeSortCondition')
|
|
200
|
+
}
|
|
201
|
+
|
|
202
|
+
return {
|
|
203
|
+
handleHeaderClick,
|
|
204
|
+
handleHeaderContextMenu,
|
|
205
|
+
handleMouseDown,
|
|
206
|
+
handleMouseMove,
|
|
207
|
+
handleMouseOut,
|
|
208
|
+
handleSortClick,
|
|
209
|
+
handleFilterClick,
|
|
210
|
+
}
|
|
211
|
+
}
|
|
212
|
+
|
|
213
|
+
export default useEvent
|