poe-svelte-ui-lib 1.2.11 → 1.2.13
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/Switch/Switch.svelte +1 -1
- package/dist/Table/Table.svelte +29 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
package/dist/Table/Table.svelte
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
import type { ITableHeader, ITableProps } from '../types'
|
|
5
5
|
import { fly } from 'svelte/transition'
|
|
6
6
|
import { twMerge } from 'tailwind-merge'
|
|
7
|
+
import { onMount } from 'svelte'
|
|
7
8
|
|
|
8
9
|
let {
|
|
9
10
|
id = crypto.randomUUID(),
|
|
@@ -15,6 +16,7 @@
|
|
|
15
16
|
outline = false,
|
|
16
17
|
cursor = null,
|
|
17
18
|
loader,
|
|
19
|
+
autoscroll = false,
|
|
18
20
|
getData = () => {},
|
|
19
21
|
modalData = $bindable(),
|
|
20
22
|
onClick,
|
|
@@ -29,6 +31,8 @@
|
|
|
29
31
|
direction: null,
|
|
30
32
|
}
|
|
31
33
|
|
|
34
|
+
let isAutoscroll = $state(autoscroll)
|
|
35
|
+
|
|
32
36
|
/* Сортировка столбцов */
|
|
33
37
|
const sortRows = (key: string) => {
|
|
34
38
|
if (sortState.key === key) {
|
|
@@ -72,6 +76,23 @@
|
|
|
72
76
|
}
|
|
73
77
|
}
|
|
74
78
|
|
|
79
|
+
/* Обработчик автоскролла */
|
|
80
|
+
const handleAutoScroll = () => {
|
|
81
|
+
if (!container) return
|
|
82
|
+
|
|
83
|
+
isAutoscroll = !(container.scrollHeight - container.scrollTop <= container.clientHeight + 50)
|
|
84
|
+
}
|
|
85
|
+
const scrollToBottom = () => {
|
|
86
|
+
if (!isAutoscroll && container) {
|
|
87
|
+
container.scrollTop = container.scrollHeight
|
|
88
|
+
}
|
|
89
|
+
}
|
|
90
|
+
$effect(() => {
|
|
91
|
+
if (body.length > 0) {
|
|
92
|
+
scrollToBottom()
|
|
93
|
+
}
|
|
94
|
+
})
|
|
95
|
+
|
|
75
96
|
function buttonClick(row: any, button: any) {
|
|
76
97
|
if (button.onClick) button.onClick(row)
|
|
77
98
|
else if (button.eventHandler && onClick) {
|
|
@@ -119,6 +140,14 @@
|
|
|
119
140
|
const src = typeof column.image?.src === 'function' ? column.image.src(row) : column.image?.src
|
|
120
141
|
return !!src
|
|
121
142
|
}
|
|
143
|
+
|
|
144
|
+
onMount(() => {
|
|
145
|
+
container?.addEventListener('scroll', handleAutoScroll)
|
|
146
|
+
scrollToBottom()
|
|
147
|
+
return () => {
|
|
148
|
+
container?.removeEventListener('scroll', handleAutoScroll)
|
|
149
|
+
}
|
|
150
|
+
})
|
|
122
151
|
</script>
|
|
123
152
|
|
|
124
153
|
<div {id} class={twMerge(`bg-blue flex h-full w-full flex-col overflow-hidden`, wrapperClass)}>
|
package/dist/types.d.ts
CHANGED