poe-svelte-ui-lib 1.31.4 → 1.31.6
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/README.md +2 -2
- package/dist/Table/Table.svelte +20 -24
- package/dist/locales/translations.js +1 -0
- package/package.json +1 -1
package/dist/Table/README.md
CHANGED
|
@@ -20,8 +20,8 @@
|
|
|
20
20
|
| `dataBuffer.stashData` | `boolean` | `false` | Включить буферизацию данных |
|
|
21
21
|
| `dataBuffer.bufferSize` | `number` | `10` | Размер буфера данных |
|
|
22
22
|
| `dataBuffer.visibleRows` | `number` | `5` | Количество видимых строк при ограничении высоты |
|
|
23
|
-
| `dataBuffer.clearButton` | `boolean` | `false` |
|
|
24
|
-
| `dataBuffer.clearClass` | `string` | `""` |
|
|
23
|
+
| `dataBuffer.clearButton` | `boolean` | `false` | Кнопка очистки буфера с подсказкой — в собственной узкой колонке справа (шапка и строки), заголовки столбцов не перекрывает |
|
|
24
|
+
| `dataBuffer.clearClass` | `string` | `""` | Дополнительные классы кнопки очистки (размер, цвета) — позиционировать не нужно |
|
|
25
25
|
| `dataBuffer.logger` | `boolean` | `false` | Режим журнала (добавление новых строк в начало) |
|
|
26
26
|
| `outline` | `boolean` | `false` | Показывать обводку строк и столбцов |
|
|
27
27
|
| `cursor` | `string \| null` | `null` | Курсор пагинации для бесконечной прокрутки: передаётся в `getData` при достижении конца списка; при `null` загрузка новых данных отключена |
|
package/dist/Table/Table.svelte
CHANGED
|
@@ -37,6 +37,11 @@
|
|
|
37
37
|
let selectSlideDuration: number = $state(250)
|
|
38
38
|
let copiedCell: { x: number; y: number } | null = $state(null)
|
|
39
39
|
let tooltip = $state({ show: false, text: "", x: 0, y: 0 })
|
|
40
|
+
/* Шаблон колонок общий для шапки и строк; кнопка очистки — отдельная узкая колонка, чтобы не перекрывать заголовки */
|
|
41
|
+
const ACTIONS_COLUMN = "2.5rem"
|
|
42
|
+
let gridTemplate = $derived(
|
|
43
|
+
[...(header || []).filter((c) => c.width !== "0%").map((c) => c.width || "minmax(0, 1fr)"), ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : [])].join(" "),
|
|
44
|
+
)
|
|
40
45
|
let isScrollable: boolean = $derived(container ? (container as HTMLElement).scrollHeight > (container as HTMLElement).clientHeight : false)
|
|
41
46
|
let tableHeight = $state(0)
|
|
42
47
|
let modalData: { isOpen: boolean; rawData?: string; formattedData?: string } = $state({ isOpen: false, rawData: "", formattedData: "" })
|
|
@@ -79,6 +84,8 @@
|
|
|
79
84
|
|
|
80
85
|
const handleScroll = () => {
|
|
81
86
|
if (!container) return
|
|
87
|
+
/* Контейнер рендерится только при наличии строк, поэтому слушатель — в разметке, а не addEventListener в onMount */
|
|
88
|
+
if (autoscroll) handleAutoScroll()
|
|
82
89
|
const { scrollTop, clientHeight, scrollHeight } = container
|
|
83
90
|
if (scrollTop + clientHeight >= scrollHeight - 50 && cursor !== null && loader && !loader()) {
|
|
84
91
|
getData()
|
|
@@ -212,10 +219,7 @@
|
|
|
212
219
|
})
|
|
213
220
|
|
|
214
221
|
onMount(() => {
|
|
215
|
-
if (autoscroll)
|
|
216
|
-
container?.addEventListener("scroll", handleAutoScroll)
|
|
217
|
-
scrollToBottom()
|
|
218
|
-
}
|
|
222
|
+
if (autoscroll) scrollToBottom()
|
|
219
223
|
|
|
220
224
|
const handlePageScroll = () => {
|
|
221
225
|
isDropdownOpen = null
|
|
@@ -231,7 +235,6 @@
|
|
|
231
235
|
isScrollable = container ? container.scrollHeight > container.clientHeight : false
|
|
232
236
|
|
|
233
237
|
return () => {
|
|
234
|
-
container?.removeEventListener("scroll", handleAutoScroll)
|
|
235
238
|
window.removeEventListener("scroll", handlePageScroll, true)
|
|
236
239
|
window.removeEventListener("resize", handlePageScroll, true)
|
|
237
240
|
}
|
|
@@ -249,10 +252,7 @@
|
|
|
249
252
|
class="grid border-b border-(--hairline-color) bg-(--container-color) text-[11px] font-bold tracking-[0.06em] text-(--muted-color) uppercase {isScrollable
|
|
250
253
|
? 'border-r-8 border-r-(--container-color)'
|
|
251
254
|
: ''}"
|
|
252
|
-
style={`grid-template-columns: ${
|
|
253
|
-
.filter((c) => c.width !== "0%")
|
|
254
|
-
.map((c) => c.width || "minmax(0, 1fr)")
|
|
255
|
-
.join(" ")};`}
|
|
255
|
+
style={`grid-template-columns: ${gridTemplate};`}
|
|
256
256
|
>
|
|
257
257
|
{#each header as column, index (column)}
|
|
258
258
|
{#if column.width !== "0%"}
|
|
@@ -279,18 +279,16 @@
|
|
|
279
279
|
</div>
|
|
280
280
|
{/if}
|
|
281
281
|
{/each}
|
|
282
|
+
{#if dataBuffer.clearButton}
|
|
283
|
+
<div class="flex items-center justify-center tracking-normal normal-case">
|
|
284
|
+
<Button
|
|
285
|
+
componentClass={twMerge("size-7 p-1.5 text-(--muted-color) hover:text-(--red-color)", dataBuffer.clearClass)}
|
|
286
|
+
content={{ icon: ButtonClear, info: { text: $T("common.table.clear"), side: "left" } }}
|
|
287
|
+
onClick={clearBuffer}
|
|
288
|
+
/>
|
|
289
|
+
</div>
|
|
290
|
+
{/if}
|
|
282
291
|
</div>
|
|
283
|
-
{#if dataBuffer.clearButton}
|
|
284
|
-
<button
|
|
285
|
-
class={twMerge(
|
|
286
|
-
"absolute top-1 right-2 flex size-7 cursor-pointer items-center justify-center rounded-lg bg-(--back-color) p-1.5 text-(--muted-color) transition-colors duration-150 hover:bg-(--container-color) hover:text-(--font-color) [&_svg]:h-full [&_svg]:w-full",
|
|
287
|
-
dataBuffer.clearClass,
|
|
288
|
-
)}
|
|
289
|
-
onclick={clearBuffer}
|
|
290
|
-
>
|
|
291
|
-
<ButtonClear />
|
|
292
|
-
</button>
|
|
293
|
-
{/if}
|
|
294
292
|
|
|
295
293
|
{#if bodyArray.length > 0 || buffer.length > 0}
|
|
296
294
|
{@const rows = dataBuffer.stashData ? buffer.slice(-(dataBuffer.bufferSize ?? 10)) : bodyArray.filter((row: any) => Object.entries(row).length != 0)}
|
|
@@ -300,10 +298,7 @@
|
|
|
300
298
|
{#each rows as row, i (row.__rowId ?? row)}
|
|
301
299
|
<div
|
|
302
300
|
class="grid border-t border-(--hairline-color) transition-colors duration-150 hover:bg-(--accent-soft)"
|
|
303
|
-
style={`grid-template-columns: ${
|
|
304
|
-
.filter((c) => c.width !== "0%")
|
|
305
|
-
.map((c) => c.width || "minmax(0, 1fr)")
|
|
306
|
-
.join(" ")};`}
|
|
301
|
+
style={`grid-template-columns: ${gridTemplate};`}
|
|
307
302
|
>
|
|
308
303
|
{#each header as column, j (column)}
|
|
309
304
|
{#if column.width !== "0%"}
|
|
@@ -494,6 +489,7 @@
|
|
|
494
489
|
</div>
|
|
495
490
|
{/if}
|
|
496
491
|
{/each}
|
|
492
|
+
{#if dataBuffer.clearButton}<div></div>{/if}
|
|
497
493
|
</div>
|
|
498
494
|
{/each}
|
|
499
495
|
</div>
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
const translations = {
|
|
2
2
|
"common.select_tag": ["Сделайте выбор", "Make a choice", "请选择"],
|
|
3
|
+
"common.table.clear": ["Очистить таблицу", "Clear table", "清空表格"],
|
|
3
4
|
"debug.baud_rate_data": ["Данные", "Data", "数据"],
|
|
4
5
|
"library.for_constructor": ["Для конструктора", "For constructor", "用于构造器"],
|
|
5
6
|
"library.overview": ["Обзор", "Overview", "概览"],
|