poe-svelte-ui-lib 2.15.3 → 2.16.1

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.
@@ -13,6 +13,7 @@
13
13
  - ↕️ Сортирует строки по клику на стрелки в заголовке колонки.
14
14
  - 📋 Копирует значение ячейки одной кнопкой.
15
15
  - 🔍 Длинное значение открывается целиком в отдельном окне, а короткая подсказка всплывает при наведении.
16
+ - 🔎 Широкую таблицу можно сузить: часть колонок показывается только в окне подробностей строки, оно открывается кнопкой ⓘ в конце строки. Кнопки, списки и полосы прогресса в окне работают так же, как в таблице, и обновляются вместе с ней.
16
17
  - 📜 Работает как журнал: новые строки не заменяют старые, а дописываются, старые уходят, когда буфер заполнен.
17
18
  - 🧹 В режиме журнала может показать кнопку очистки.
18
19
  - ⏬ Умеет подгружать данные порциями, когда таблицу прокрутили до конца.
@@ -21,7 +22,7 @@
21
22
 
22
23
  1. Перетащите таблицу на макет и подпишите её.
23
24
  2. Выберите переменную устройства, в которой лежит список строк.
24
- 3. Откройте настройку колонок и добавьте нужные: заголовок, ширину в процентах, выравнивание.
25
+ 3. Откройте настройку колонок и добавьте нужные: заголовок, ширину в процентах, выравнивание и где показывать колонку - в таблице, только в подробностях или и там, и там.
25
26
  4. В каждую колонку добавьте содержимое: текст, список, кнопку или полосу прогресса, и укажите, из какого поля строки брать значение.
26
27
  5. Для кнопки выберите иконку, цвет, команду и поля строки, которые нужно отправить.
27
28
  6. Если нужен журнал, включите «Накопление данных». Тогда появятся размер буфера, число видимых строк, кнопка очистки и порядок строк: новые снизу или сверху.
@@ -124,14 +125,15 @@
124
125
 
125
126
  ### Колонка `ITableHeader`
126
127
 
127
- | Поле | Тип | Описание |
128
- | --------------- | --------------------------------------------- | ------------------------------------------ |
129
- | `label` | `{ name, class }` | Заголовок колонки |
130
- | `width` | `string` | Ширина. `"0%"` скрывает колонку |
131
- | `align` | `"left" \| "center" \| "right"` | Выравнивание |
132
- | `stack` | `boolean` | Элементы ячейки столбиком |
133
- | `disableSelect` | `boolean` | Запретить выделение текста |
134
- | `content` | `ITableContent[] \| (row) => ITableContent[]` | Что в ячейке: список или функция от строки |
128
+ | Поле | Тип | Описание |
129
+ | --------------- | --------------------------------------------- | ------------------------------------------------------------------------------------ |
130
+ | `label` | `{ name, class }` | Заголовок колонки |
131
+ | `width` | `string` | Ширина. `"0%"` скрывает колонку |
132
+ | `align` | `"left" \| "center" \| "right"` | Выравнивание |
133
+ | `stack` | `boolean` | Элементы ячейки столбиком |
134
+ | `disableSelect` | `boolean` | Запретить выделение текста |
135
+ | `place` | `"table" \| "details" \| "both"` | Где показывать: в строке (по умолчанию), только в окне подробностей или и там, и там |
136
+ | `content` | `ITableContent[] \| (row) => ITableContent[]` | Что в ячейке: список или функция от строки |
135
137
 
136
138
  ### Содержимое ячейки `ITableContent`
137
139
 
@@ -15,6 +15,7 @@
15
15
  import CopyButton from "./CopyButton.svelte"
16
16
  import Dropdown from "../Dropdown/Dropdown.svelte"
17
17
  import MoreIcon from "../libIcons/MoreIcon.svelte"
18
+ import InfoIcon from "../libIcons/InfoIcon.svelte"
18
19
  import { htmlToText, sanitizeHtml } from "../html"
19
20
  import { createRing } from "../ring"
20
21
  import { copyText } from "../clipboard"
@@ -115,13 +116,21 @@
115
116
  /* ********************************************************** */
116
117
  /* Разметка: шаблон колонок общий для шапки и строк; кнопка очистки - отдельная узкая колонка */
117
118
  const ACTIONS_COLUMN = "2.5rem"
119
+ /* Столбец в строке таблицы: не скрыт шириной 0% и не только в подробностях */
120
+ const inTable = (column: ITableHeader<Row>) => column.width !== "0%" && column.place !== "details"
121
+ /* Столбцы окна подробностей строки; есть хоть один - в конце строки кнопка «Подробнее» */
122
+ const detailColumns = $derived(
123
+ header.map((column, index) => ({ column, index })).filter(({ column }) => column.place === "details" || column.place === "both"),
124
+ )
125
+ const hasDetails = $derived(detailColumns.length > 0)
126
+ const extraColumns = $derived([...(hasDetails ? [ACTIONS_COLUMN] : []), ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : [])])
118
127
  /* Колонка по содержимому: width "fit" или без width с одними кнопками */
119
128
  const isFit = (column: ITableHeader<Row>) =>
120
129
  column.width === "fit" ||
121
130
  (!column.width && Array.isArray(column.content) && column.content.length > 0 && column.content.every((c) => c.type === "button" || c.type === "menu"))
122
131
  /* Ширины колонок по содержимому в px (замер после отрисовки), ключ - номер колонки в header */
123
132
  let fitWidths = $state<Record<number, number>>({})
124
- const hasFit = $derived(header.some((c) => c.width !== "0%" && isFit(c)))
133
+ const hasFit = $derived(header.some((c) => inTable(c) && isFit(c)))
125
134
  /* Рядом с колонкой по содержимому проценты становятся долями остатка: "20%" - 20fr */
126
135
  const trackWidth = (column: ITableHeader<Row>, index: number) => {
127
136
  if (isFit(column)) return fitWidths[index] ? `${fitWidths[index]}px` : "max-content"
@@ -134,14 +143,10 @@
134
143
  if (!column.width || column.width.includes("fr") || (hasFit && column.width.endsWith("%"))) return "5rem"
135
144
  return column.width
136
145
  }
137
- const visibleColumns = $derived(header.map((column, index) => ({ column, index })).filter(({ column }) => column.width !== "0%"))
138
- let gridTemplate = $derived(
139
- [...visibleColumns.map(({ column, index }) => trackWidth(column, index)), ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : [])].join(" "),
140
- )
146
+ const visibleColumns = $derived(header.map((column, index) => ({ column, index })).filter(({ column }) => inTable(column)))
147
+ let gridTemplate = $derived([...visibleColumns.map(({ column, index }) => trackWidth(column, index)), ...extraColumns].join(" "))
141
148
  /* Наименьшая ширина таблицы: заданные ширины колонок и по 5rem на гибкие; уже - прокрутка вбок, а не обрезка */
142
- let minTableWidth = $derived(
143
- `calc(${[...visibleColumns.map(({ column, index }) => minWidth(column, index)), ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : [])].join(" + ")})`,
144
- )
149
+ let minTableWidth = $derived(`calc(${[...visibleColumns.map(({ column, index }) => minWidth(column, index)), ...extraColumns].join(" + ")})`)
145
150
  const columnContent = (column: ITableHeader<Row>, row: Row) => (typeof column.content === "function" ? column.content(row) : (column.content ?? []))
146
151
  const sortKey = (column: ITableHeader<Row>) =>
147
152
  typeof column.content === "function"
@@ -269,6 +274,12 @@
269
274
  let modal = $state.raw<{ row: Row; text: ITableText<Row> } | null>(null)
270
275
  const modalSnippet = $derived(typeof modal?.text.modal === "function" ? (modal.text.modal as Snippet<[Row]>) : null)
271
276
 
277
+ /* Окно подробностей: ключ строки, а не сама строка - содержимое обновляется вместе с таблицей */
278
+ let detailsOpen = $state(false)
279
+ let detailsKey = $state<number | null>(null)
280
+ const detailsEntry = $derived(detailsKey === null ? null : (entries.find((e) => e.key === detailsKey) ?? null))
281
+ const detailsIndex = $derived(detailsEntry ? entries.indexOf(detailsEntry) : -1)
282
+
272
283
  const progressPercent = (value: number, min = 0, max = 100) =>
273
284
  value != null && !isNaN(value) ? ((Math.min(Math.max(value, min), max) - min) / (max - min)) * 100 : 0
274
285
 
@@ -296,11 +307,11 @@
296
307
  <div class="flex min-h-0 w-full flex-1 flex-col" style="min-width: {minTableWidth};" bind:this={tableEl}>
297
308
  <!-- Шапка -->
298
309
  <div
299
- class="grid border-b border-(--hairline-color) bg-[var(--table-header-color,var(--accent-soft))] text-[11px] font-bold tracking-[0.06em] text-[color-mix(in_srgb,var(--accent-color)_35%,var(--font-color))] uppercase"
310
+ class="grid border-b border-(--hairline-color) bg-[var(--table-header-color,var(--accent-soft))] text-[12px] font-semibold text-[color-mix(in_srgb,var(--accent-color)_35%,var(--font-color))]"
300
311
  style={`grid-template-columns: ${gridTemplate}; padding-right: ${scrollbarWidth}px;`}
301
312
  >
302
313
  {#each header as column, index (column)}
303
- {#if column.width !== "0%"}
314
+ {#if inTable(column)}
304
315
  {@const key = sortKey(column)}
305
316
  <div
306
317
  data-fit={isFit(column) ? index : undefined}
@@ -322,8 +333,9 @@
322
333
  </div>
323
334
  {/if}
324
335
  {/each}
336
+ {#if hasDetails}<div></div>{/if}
325
337
  {#if dataBuffer.clearButton}
326
- <div class="flex items-center justify-center tracking-normal normal-case">
338
+ <div class="flex items-center justify-center">
327
339
  <Button
328
340
  componentClass={twMerge("size-7 text-(--red-text) hover:bg-(--red-color)/10", dataBuffer.clearClass)}
329
341
  content={{ icon: ButtonClear, info: { text: $T("common.table.clear"), side: "left" } }}
@@ -348,7 +360,7 @@
348
360
  style={`grid-template-columns: ${gridTemplate};`}
349
361
  >
350
362
  {#each header as column, j (column)}
351
- {#if column.width !== "0%"}
363
+ {#if inTable(column)}
352
364
  {@const contents = columnContent(column, row) as ITableContent<Row>[]}
353
365
  <!-- Одни бейджи - вплотную с переносом; stack - столбиком; иначе - в ряд равными долями -->
354
366
  {@const badges = contents.length > 1 && contents.every((c) => c.type === "text" && c.data.badge)}
@@ -373,156 +385,22 @@
373
385
  ? undefined
374
386
  : `grid-template-columns: ${column.stack ? "minmax(0, 1fr)" : `repeat(${contents.length}, minmax(0, 1fr))`};`}
375
387
  >
376
- {#each contents as content, index}
377
- {#if content.type === "button"}
378
- {@const button = resolve(content.data, row)}
379
- {@const title = resolve(button.title, row)}
380
- {#if !button.hideIf?.key || String((row as Record<string, unknown>)[button.hideIf.key] ?? "") !== String(button.hideIf.value ?? "")}
381
- <button class="{buttonClass(button, row, fit)} bg-(--bg-color)" onclick={() => buttonClick(row, button)} {title} aria-label={title}>
382
- {#if button.icon}
383
- <span class="flex size-(--icon-size) shrink-0 items-center justify-center overflow-visible [&_svg]:size-full">
384
- {#if typeof button.icon === "string"}
385
- {@html sanitizeHtml(button.icon)}
386
- {:else}
387
- <button.icon />
388
- {/if}
389
- </span>
390
- {/if}
391
- {$T(resolve(button.name, row) ?? "")}
392
- </button>
393
- {/if}
394
- {:else if content.type === "menu"}
395
- <Dropdown
396
- align="end"
397
- button={{
398
- variant: "plain",
399
- wrapperClass: "w-fit shrink-0",
400
- componentClass: "aspect-auto h-7 w-auto rounded-lg px-2 py-0",
401
- content: {
402
- icon: content.data.icon ?? MoreIcon,
403
- info: content.data.title ? { text: $T(content.data.title), side: "left" } : undefined,
404
- },
405
- }}
406
- items={content.data.items(row)}
407
- />
408
- {:else if content.type === "select"}
409
- {@const select = content.data}
410
- {@const options = (Array.isArray(row[select.key]) ? row[select.key] : []) as IOption<string | number>[]}
411
- {@const current = (row as Record<string, unknown>)[valueKey(select.key)]}
412
- {@const open = dropdown?.row === i && dropdown.col === j && dropdown.index === index ? dropdown : null}
413
- <div class="relative w-full select-none">
414
- <button
415
- class="h-7 w-full cursor-pointer rounded-lg border border-(--border-color) bg-(--field-color) px-2 text-left text-[13px] transition-[border-color,box-shadow] duration-150 outline-none hover:border-(--faint-color) focus:border-(--accent-text) focus:shadow-(--focus-shadow-color)"
416
- onclick={(e) => toggleDropdown(e, i, j, index)}
417
- >
418
- {options.find((o) => o.value === current)?.name ?? $T("common.select_tag")}
419
- </button>
420
- {#if open}
421
- <div
422
- class="fixed z-50 max-h-[40vh] overflow-y-auto rounded-[10px] border border-(--hairline-color) bg-(--back-color) p-1 shadow-(--elevation-2)"
423
- style="top: {open.rect.bottom + 4}px; left: {open.rect.left}px; width: {open.rect.width}px;"
424
- transition:slide={{ duration: slideDuration }}
425
- >
426
- {#each options as option (option.id ?? option.value)}
427
- <button
428
- class={twMerge(
429
- "flex h-8 w-full cursor-pointer items-center rounded-md px-2.5 text-left text-[13px] transition-colors duration-150 hover:bg-(--container-color)",
430
- option.accent && "text-(--accent-text)",
431
- )}
432
- style={accentStyle(option.accent)}
433
- onclick={(e) => selectOption(e, entry.row, select.key, option)}
434
- >
435
- {option.name}
436
- </button>
437
- {/each}
438
- </div>
439
- {/if}
440
- </div>
441
- {:else if content.type === "image"}
442
- {@const image = content.data}
443
- {@const src = resolve(image.src, row)}
444
- <div
445
- class="flex items-center justify-center [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
446
- style={`width: ${image.width || "2rem"}; height: ${image.height || "2rem"};`}
447
- >
448
- {#if src}
449
- <img {src} alt={image.alt ?? "Image"} class={twMerge("h-full w-full object-cover", image.class)} loading="lazy" />
450
- {:else if typeof image.defaultIcon === "string"}
451
- {@html sanitizeHtml(image.defaultIcon)}
452
- {:else if image.defaultIcon}
453
- <image.defaultIcon />
454
- {/if}
455
- </div>
456
- {:else if content.type === "progressBar"}
457
- {@const bar = content.data}
458
- <div class="grid h-7 w-full grid-cols-[3.5rem_1fr] items-center gap-2">
459
- <span class="text-right text-[12px] font-semibold tabular-nums">{roundToClean(Number(row[bar.key] ?? 0))}{bar.units}</span>
460
- <div class="relative my-auto h-1.5 overflow-hidden rounded-full bg-(--container-color)">
461
- <div
462
- class="absolute top-0 left-0 flex h-full rounded-full bg-(--bg-color,var(--accent-color))"
463
- style="width: {progressPercent(row[bar.key] as number, bar.minNum, bar.maxNum)}%;"
464
- ></div>
465
- </div>
466
- </div>
467
- {:else if content.type === "text"}
468
- {@const text = content.data}
469
- {@const value = cellContent(row, text)}
470
- {@const accent = text.accent?.(row)}
471
- <!-- w-full + min-w-0: при justify-items-start ячейка иначе берёт ширину по содержимому и truncate не даёт «…»;
472
- в тексте - перенос строки -->
473
- <div class="flex w-full min-w-0 items-center">
474
- <div
475
- class="max-w-full min-w-0 wrap-break-word {text.truncated ? 'truncate' : 'whitespace-pre-line'} {accent
476
- ? 'text-(--accent-text)'
477
- : ''} {accent && text.badge ? 'w-fit rounded-md bg-(--accent-soft) px-1.5 text-[12px] font-medium' : 'w-full'}"
478
- style={accentStyle(accent)}
479
- onpointerenter={text.tooltip
480
- ? (e) => {
481
- if (!isHoverPointer(e)) return
482
- const tip = typeof text.tooltip === "function" ? text.tooltip(row) : cellText(row, text)
483
- if (tip) tooltip = { show: true, text: tip, x: e.clientX, y: e.clientY }
484
- }
485
- : undefined}
486
- onpointerleave={text.tooltip ? () => (tooltip.show = false) : undefined}
487
- onmousemove={text.tooltip ? (e) => ((tooltip.x = e.clientX), (tooltip.y = e.clientY)) : undefined}
488
- role="presentation"
489
- >
490
- {#if text.modal}
491
- <button
492
- class="cursor-pointer text-left {text.truncated ? 'block w-full max-w-full truncate' : 'w-fit'}"
493
- onclick={(e) => {
494
- e.stopPropagation()
495
- modal = { row, text }
496
- modalOpen = true
497
- }}
498
- >
499
- {#if text.html}{@html sanitizeHtml(value)}{:else}{value}{/if}
500
- </button>
501
- {:else if text.onClick}
502
- <button
503
- class="cursor-pointer text-left hover:underline {text.truncated ? 'block w-full max-w-full truncate' : ''}"
504
- onclick={(e) => {
505
- e.stopPropagation()
506
- text.onClick?.(row)
507
- }}>{value}</button
508
- >
509
- {:else if text.href}
510
- <a class="underline" href={text.href(row)}>{value}</a>
511
- {:else if text.html}
512
- {@html sanitizeHtml(value)}
513
- {:else}
514
- {value}
515
- {/if}
516
- </div>
517
- {#if text.copy}
518
- <CopyButton class="ml-1.5" text={() => cellText(row, text)} />
519
- {/if}
520
- </div>
521
- {/if}
522
- {/each}
388
+ {@render items(row, entry.row, contents, fit, i, j)}
523
389
  </div>
524
390
  {/if}
525
391
  {/each}
392
+ {#if hasDetails}
393
+ <div class="flex items-center justify-center">
394
+ <Button
395
+ componentClass="size-7 text-(--accent-text) hover:bg-(--accent-soft)"
396
+ content={{ icon: InfoIcon, info: { text: $T("common.table.details"), side: "left" } }}
397
+ onClick={() => {
398
+ detailsKey = entry.key
399
+ detailsOpen = true
400
+ }}
401
+ />
402
+ </div>
403
+ {/if}
526
404
  {#if dataBuffer.clearButton}<div></div>{/if}
527
405
  </div>
528
406
  {/each}
@@ -550,6 +428,158 @@
550
428
  </div>
551
429
  </div>
552
430
 
431
+ <!-- Содержимое ячейки - общее для строки таблицы и окна подробностей; entryRow - исходная строка (ключ выбранных значений списков), i и j - строка и столбец выпадающего списка -->
432
+ {#snippet items(row: Row, entryRow: Row, contents: ITableContent<Row>[], fit: boolean, i: number, j: number)}
433
+ {#each contents as content, index}
434
+ {#if content.type === "button"}
435
+ {@const button = resolve(content.data, row)}
436
+ {@const title = resolve(button.title, row)}
437
+ {#if !button.hideIf?.key || String((row as Record<string, unknown>)[button.hideIf.key] ?? "") !== String(button.hideIf.value ?? "")}
438
+ <button class="{buttonClass(button, row, fit)} bg-(--bg-color)" onclick={() => buttonClick(row, button)} {title} aria-label={title}>
439
+ {#if button.icon}
440
+ <span class="flex size-(--icon-size) shrink-0 items-center justify-center overflow-visible [&_svg]:size-full">
441
+ {#if typeof button.icon === "string"}
442
+ {@html sanitizeHtml(button.icon)}
443
+ {:else}
444
+ <button.icon />
445
+ {/if}
446
+ </span>
447
+ {/if}
448
+ {$T(resolve(button.name, row) ?? "")}
449
+ </button>
450
+ {/if}
451
+ {:else if content.type === "menu"}
452
+ <Dropdown
453
+ align="end"
454
+ button={{
455
+ variant: "plain",
456
+ wrapperClass: "w-fit shrink-0",
457
+ componentClass: "aspect-auto h-7 w-auto rounded-lg px-2 py-0",
458
+ content: {
459
+ icon: content.data.icon ?? MoreIcon,
460
+ info: content.data.title ? { text: $T(content.data.title), side: "left" } : undefined,
461
+ },
462
+ }}
463
+ items={content.data.items(row)}
464
+ />
465
+ {:else if content.type === "select"}
466
+ {@const select = content.data}
467
+ {@const options = (Array.isArray(row[select.key]) ? row[select.key] : []) as IOption<string | number>[]}
468
+ {@const current = (row as Record<string, unknown>)[valueKey(select.key)]}
469
+ {@const open = dropdown?.row === i && dropdown.col === j && dropdown.index === index ? dropdown : null}
470
+ <div class="relative w-full select-none">
471
+ <button
472
+ class="h-7 w-full cursor-pointer rounded-lg border border-(--border-color) bg-(--field-color) px-2 text-left text-[13px] transition-[border-color,box-shadow] duration-150 outline-none hover:border-(--faint-color) focus:border-(--accent-text) focus:shadow-(--focus-shadow-color)"
473
+ onclick={(e) => toggleDropdown(e, i, j, index)}
474
+ >
475
+ {options.find((o) => o.value === current)?.name ?? $T("common.select_tag")}
476
+ </button>
477
+ {#if open}
478
+ <div
479
+ class="fixed z-[300] max-h-[40vh] overflow-y-auto rounded-[10px] border border-(--hairline-color) bg-(--back-color) p-1 shadow-(--elevation-2)"
480
+ style="top: {open.rect.bottom + 4}px; left: {open.rect.left}px; width: {open.rect.width}px;"
481
+ transition:slide={{ duration: slideDuration }}
482
+ >
483
+ {#each options as option (option.id ?? option.value)}
484
+ <button
485
+ class={twMerge(
486
+ "flex h-8 w-full cursor-pointer items-center rounded-md px-2.5 text-left text-[13px] transition-colors duration-150 hover:bg-(--container-color)",
487
+ option.accent && "text-(--accent-text)",
488
+ )}
489
+ style={accentStyle(option.accent)}
490
+ onclick={(e) => selectOption(e, entryRow, select.key, option)}
491
+ >
492
+ {option.name}
493
+ </button>
494
+ {/each}
495
+ </div>
496
+ {/if}
497
+ </div>
498
+ {:else if content.type === "image"}
499
+ {@const image = content.data}
500
+ {@const src = resolve(image.src, row)}
501
+ <div
502
+ class="flex items-center justify-center [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
503
+ style={`width: ${image.width || "2rem"}; height: ${image.height || "2rem"};`}
504
+ >
505
+ {#if src}
506
+ <img {src} alt={image.alt ?? "Image"} class={twMerge("h-full w-full object-cover", image.class)} loading="lazy" />
507
+ {:else if typeof image.defaultIcon === "string"}
508
+ {@html sanitizeHtml(image.defaultIcon)}
509
+ {:else if image.defaultIcon}
510
+ <image.defaultIcon />
511
+ {/if}
512
+ </div>
513
+ {:else if content.type === "progressBar"}
514
+ {@const bar = content.data}
515
+ <div class="grid h-7 w-full grid-cols-[3.5rem_1fr] items-center gap-2">
516
+ <span class="text-right text-[12px] font-semibold tabular-nums">{roundToClean(Number(row[bar.key] ?? 0))}{bar.units}</span>
517
+ <div class="relative my-auto h-1.5 overflow-hidden rounded-full bg-(--container-color)">
518
+ <div
519
+ class="absolute top-0 left-0 flex h-full rounded-full bg-(--bg-color,var(--accent-color))"
520
+ style="width: {progressPercent(row[bar.key] as number, bar.minNum, bar.maxNum)}%;"
521
+ ></div>
522
+ </div>
523
+ </div>
524
+ {:else if content.type === "text"}
525
+ {@const text = content.data}
526
+ {@const value = cellContent(row, text)}
527
+ {@const accent = text.accent?.(row)}
528
+ <!-- w-full + min-w-0: при justify-items-start ячейка иначе берёт ширину по содержимому и truncate не даёт «…»;
529
+ в тексте - перенос строки -->
530
+ <div class="flex w-full min-w-0 items-center">
531
+ <div
532
+ class="max-w-full min-w-0 wrap-break-word {text.truncated ? 'truncate' : 'whitespace-pre-line'} {accent ? 'text-(--accent-text)' : ''} {accent &&
533
+ text.badge
534
+ ? 'w-fit rounded-md bg-(--accent-soft) px-1.5 text-[12px] font-medium'
535
+ : 'w-full'}"
536
+ style={accentStyle(accent)}
537
+ onpointerenter={text.tooltip
538
+ ? (e) => {
539
+ if (!isHoverPointer(e)) return
540
+ const tip = typeof text.tooltip === "function" ? text.tooltip(row) : cellText(row, text)
541
+ if (tip) tooltip = { show: true, text: tip, x: e.clientX, y: e.clientY }
542
+ }
543
+ : undefined}
544
+ onpointerleave={text.tooltip ? () => (tooltip.show = false) : undefined}
545
+ onmousemove={text.tooltip ? (e) => ((tooltip.x = e.clientX), (tooltip.y = e.clientY)) : undefined}
546
+ role="presentation"
547
+ >
548
+ {#if text.modal}
549
+ <button
550
+ class="cursor-pointer text-left {text.truncated ? 'block w-full max-w-full truncate' : 'w-fit'}"
551
+ onclick={(e) => {
552
+ e.stopPropagation()
553
+ modal = { row, text }
554
+ modalOpen = true
555
+ }}
556
+ >
557
+ {#if text.html}{@html sanitizeHtml(value)}{:else}{value}{/if}
558
+ </button>
559
+ {:else if text.onClick}
560
+ <button
561
+ class="cursor-pointer text-left hover:underline {text.truncated ? 'block w-full max-w-full truncate' : ''}"
562
+ onclick={(e) => {
563
+ e.stopPropagation()
564
+ text.onClick?.(row)
565
+ }}>{value}</button
566
+ >
567
+ {:else if text.href}
568
+ <a class="underline" href={text.href(row)}>{value}</a>
569
+ {:else if text.html}
570
+ {@html sanitizeHtml(value)}
571
+ {:else}
572
+ {value}
573
+ {/if}
574
+ </div>
575
+ {#if text.copy}
576
+ <CopyButton class="ml-1.5" text={() => cellText(row, text)} />
577
+ {/if}
578
+ </div>
579
+ {/if}
580
+ {/each}
581
+ {/snippet}
582
+
553
583
  {#snippet copyFooter()}
554
584
  <Button
555
585
  content={{ name: $T("ui.copy_text") }}
@@ -579,3 +609,20 @@
579
609
  {/if}
580
610
  {/snippet}
581
611
  </Modal>
612
+
613
+ <Modal bind:isOpen={detailsOpen} title={$T("common.table.details")} width="min(36rem, 92vw)">
614
+ {#snippet main()}
615
+ {#if detailsEntry}
616
+ {@const row = withPicks(detailsEntry.row)}
617
+ <div class="grid grid-cols-[minmax(6rem,max-content)_minmax(0,1fr)] items-center gap-x-4 gap-y-2.5 text-left">
618
+ {#each detailColumns as { column, index } (index)}
619
+ <div class="text-[12px] font-semibold text-(--muted-color)">{$T(column.label?.name ?? "")}</div>
620
+ <!-- Выпадающие списки окна - со своими номерами строк, чтобы не открывался список той же ячейки в таблице -->
621
+ <div class="flex min-w-0 flex-wrap items-center gap-2 text-[13px] [&>*]:min-w-0">
622
+ {@render items(row, detailsEntry.row, columnContent(column, row) as ITableContent<Row>[], true, -1 - detailsIndex, index)}
623
+ </div>
624
+ {/each}
625
+ </div>
626
+ {/if}
627
+ {/snippet}
628
+ </Modal>
@@ -178,7 +178,7 @@
178
178
  }
179
179
  }}
180
180
  />
181
- <div class="py-1.5 pl-9 grid grid-cols-[minmax(5rem,7rem)_minmax(18rem,22rem)_2rem_2rem_1fr] items-end gap-1.5">
181
+ <div class="py-1.5 pl-9 grid grid-cols-[minmax(5rem,7rem)_minmax(18rem,22rem)_minmax(16rem,20rem)_2rem_2rem_1fr] items-end gap-1.5">
182
182
  <UI.Input
183
183
  label={{ name: $T("constructor.props.table.columns.width"), class: "px-0" }}
184
184
  type="number"
@@ -199,6 +199,13 @@
199
199
  options={$optionsStore.ALIGN_OPTIONS}
200
200
  onUpdate={(option) => updateTableHeader(columnIndex, "align", option)}
201
201
  />
202
+ <UI.Select
203
+ label={{ name: $T("constructor.props.table.columns.place") }}
204
+ type="buttons"
205
+ value={column.place ?? "table"}
206
+ options={$optionsStore.TABLE_PLACE_OPTIONS}
207
+ onUpdate={(option) => updateTableHeader(columnIndex, "place", option)}
208
+ />
202
209
  <div
203
210
  class="relative flex items-end"
204
211
  role="button"
@@ -39,7 +39,7 @@ export const xPoeDebugTableColumns = [
39
39
  },
40
40
  /* Payload как пришёл, без пояснений - копируется чистым; окно - Payload развёрнуто, сообщение и HEX; у RAW - сам текст */
41
41
  {
42
- label: { name: "VALUE" },
42
+ label: { name: "common.table.xpoe.value" },
43
43
  content: [{ type: "text", data: { key: "value", truncated: true, copy: true, modal: xPoeDebugModal } }],
44
44
  width: "1fr",
45
45
  align: "left",
@@ -1089,6 +1089,26 @@ declare const constructorTranslations: {
1089
1089
  en: string;
1090
1090
  zh: string;
1091
1091
  };
1092
+ "constructor.props.table.columns.place": {
1093
+ ru: string;
1094
+ en: string;
1095
+ zh: string;
1096
+ };
1097
+ "constructor.props.table.place.table": {
1098
+ ru: string;
1099
+ en: string;
1100
+ zh: string;
1101
+ };
1102
+ "constructor.props.table.place.details": {
1103
+ ru: string;
1104
+ en: string;
1105
+ zh: string;
1106
+ };
1107
+ "constructor.props.table.place.both": {
1108
+ ru: string;
1109
+ en: string;
1110
+ zh: string;
1111
+ };
1092
1112
  "constructor.props.table.columns.sortable": {
1093
1113
  ru: string;
1094
1114
  en: string;
@@ -359,6 +359,10 @@ const constructorTranslations = {
359
359
  "constructor.props.table.select.key": { ru: "Ключ селектора", en: "Selector key", zh: "选择器键" },
360
360
  "constructor.props.table.progressBar.key": { ru: "Ключ прогресса", en: "Progress key", zh: "进度键" },
361
361
  "constructor.props.table.columns.width": { ru: "Ширина, %", en: "Width, %", zh: "宽度,%" },
362
+ "constructor.props.table.columns.place": { ru: "Где показывать", en: "Show in", zh: "显示位置" },
363
+ "constructor.props.table.place.table": { ru: "Таблица", en: "Table", zh: "表格" },
364
+ "constructor.props.table.place.details": { ru: "Подробности", en: "Details", zh: "详情" },
365
+ "constructor.props.table.place.both": { ru: "Оба", en: "Both", zh: "两者" },
362
366
  "constructor.props.table.columns.sortable": { ru: "Сортировка", en: "Sortable", zh: "排序" },
363
367
  "constructor.props.table.columns.truncated": { ru: "Сократить контент", en: "Truncate content", zh: "截断内容" },
364
368
  "constructor.props.table.columns.tooltip": { ru: "Всплывающее окно", en: "Tooltip", zh: "工具提示" },
@@ -109,11 +109,21 @@ declare const translations: {
109
109
  en: string;
110
110
  zh: string;
111
111
  };
112
+ "common.table.details": {
113
+ ru: string;
114
+ en: string;
115
+ zh: string;
116
+ };
112
117
  "common.table.xpoe.command": {
113
118
  ru: string;
114
119
  en: string;
115
120
  zh: string;
116
121
  };
122
+ "common.table.xpoe.value": {
123
+ ru: string;
124
+ en: string;
125
+ zh: string;
126
+ };
117
127
  "common.table.xpoe.reply": {
118
128
  ru: string;
119
129
  en: string;
@@ -34,7 +34,9 @@ const translations = {
34
34
  "constructor.props.video.viewer.error": { ru: "Нет сигнала", en: "No signal", zh: "无信号" },
35
35
  "constructor.props.source": { ru: "Источник", en: "Source", zh: "来源" },
36
36
  "common.table.fulldata": { ru: "Полные данные", en: "Full data", zh: "完整数据" },
37
+ "common.table.details": { ru: "Подробнее", en: "Details", zh: "详情" },
37
38
  "common.table.xpoe.command": { ru: "Команда", en: "Command", zh: "命令" },
39
+ "common.table.xpoe.value": { ru: "Значение", en: "Value", zh: "值" },
38
40
  "common.table.xpoe.reply": { ru: "ждёт ответа", en: "reply requested", zh: "需要应答" },
39
41
  "common.table.xpoe.no_reply": { ru: "без ответа", en: "no reply", zh: "无需应答" },
40
42
  "common.table.xpoe.crc": { ru: "Неверная CRC, заголовок не показан", en: "CRC mismatch, header not shown", zh: "CRC 错误,未显示报头" },
package/dist/options.d.ts CHANGED
@@ -392,6 +392,22 @@ export declare const optionsStore: import("svelte/store").Readable<{
392
392
  name: string | undefined;
393
393
  icon: string | undefined;
394
394
  })[];
395
+ TABLE_PLACE_OPTIONS: ({
396
+ id: string;
397
+ value: "table";
398
+ name: string | undefined;
399
+ icon: string | undefined;
400
+ } | {
401
+ id: string;
402
+ value: "details";
403
+ name: string | undefined;
404
+ icon: string | undefined;
405
+ } | {
406
+ id: string;
407
+ value: "both";
408
+ name: string | undefined;
409
+ icon: string | undefined;
410
+ })[];
395
411
  TABLE_CONTENT_TYPE_OPTIONS: ({
396
412
  id: string;
397
413
  value: "text";
package/dist/options.js CHANGED
@@ -132,6 +132,11 @@ export const optionsStore = derived(T, ($T) => {
132
132
  opt("square", $T("constructor.props.type.square"), PROPS_ICONS.square),
133
133
  opt("circle", $T("constructor.props.type.circle"), PROPS_ICONS.circle),
134
134
  ],
135
+ TABLE_PLACE_OPTIONS: [
136
+ opt("table", $T("constructor.props.table.place.table")),
137
+ opt("details", $T("constructor.props.table.place.details")),
138
+ opt("both", $T("constructor.props.table.place.both")),
139
+ ],
135
140
  TABLE_CONTENT_TYPE_OPTIONS: [
136
141
  opt("text", $T("constructor.props.table.type.text")),
137
142
  opt("select", $T("constructor.props.table.type.select")),
package/dist/types.d.ts CHANGED
@@ -494,6 +494,7 @@ export interface ITableHeader<T extends object> {
494
494
  align?: "left" | "center" | "right";
495
495
  stack?: boolean;
496
496
  disableSelect?: boolean;
497
+ place?: "table" | "details" | "both";
497
498
  content?: ITableContent<T>[] | ((row: T) => ITableContent<T>[]);
498
499
  }
499
500
  export interface ITableProps<T extends object> {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "2.15.3",
3
+ "version": "2.16.1",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"