poe-svelte-ui-lib 1.2.12 → 1.2.14
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/Table/Table.svelte +34 -0
- package/dist/Table/TableProps.svelte +0 -13
- 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(false)
|
|
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,19 @@
|
|
|
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
|
+
if (autoscroll) {
|
|
146
|
+
container?.addEventListener('scroll', handleAutoScroll)
|
|
147
|
+
scrollToBottom()
|
|
148
|
+
}
|
|
149
|
+
|
|
150
|
+
return () => {
|
|
151
|
+
if (autoscroll) {
|
|
152
|
+
container?.removeEventListener('scroll', handleAutoScroll)
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
})
|
|
122
156
|
</script>
|
|
123
157
|
|
|
124
158
|
<div {id} class={twMerge(`bg-blue flex h-full w-full flex-col overflow-hidden`, wrapperClass)}>
|
|
@@ -56,19 +56,6 @@
|
|
|
56
56
|
updateProperty('body', newBody, component, onPropertyChange)
|
|
57
57
|
}
|
|
58
58
|
|
|
59
|
-
const handleImageUpload = (columnIndex: number, event: Event) => {
|
|
60
|
-
const target = event.target as HTMLInputElement
|
|
61
|
-
const file = target.files?.[0]
|
|
62
|
-
if (!file) return
|
|
63
|
-
|
|
64
|
-
const reader = new FileReader()
|
|
65
|
-
reader.onload = () => {
|
|
66
|
-
const base64WithPrefix = reader.result as string
|
|
67
|
-
updateTableHeader(columnIndex, 'image', { ['src']: base64WithPrefix })
|
|
68
|
-
}
|
|
69
|
-
reader.readAsDataURL(file)
|
|
70
|
-
}
|
|
71
|
-
|
|
72
59
|
const updateButtonProperty = (columnIndex: number, buttonIndex: number, field: string, value: any) => {
|
|
73
60
|
const headers = [...component.properties.header]
|
|
74
61
|
const buttons = [...headers[columnIndex].buttons]
|
package/dist/types.d.ts
CHANGED