poe-svelte-ui-lib 2.2.0 → 2.3.0

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.
@@ -39,7 +39,7 @@
39
39
  icon={label?.icon}
40
40
  class="flex h-[18px] w-[18px] shrink-0 items-center justify-center text-[color-mix(in_srgb,var(--accent-text)_70%,var(--font-color))] [&_svg]:h-full [&_svg]:w-full"
41
41
  />
42
- <span class={twMerge(`min-w-0 truncate text-[15px] font-semibold`, label.class)}>{label?.name}</span>
42
+ <span class={twMerge(`min-w-0 text-[15px] leading-snug font-semibold wrap-break-word`, label.class)}>{label?.name}</span>
43
43
  </div>
44
44
 
45
45
  {#if chevron}
@@ -80,7 +80,8 @@
80
80
  />
81
81
 
82
82
  {#if content.name?.trim()}
83
- <span class="truncate">{content.name}</span>
83
+ <!-- Длинная подпись на узкой кнопке - в две строки, а не обрезка -->
84
+ <span class="line-clamp-2 text-center leading-[1.05] wrap-break-word">{content.name}</span>
84
85
  {#if keyBind.key && keyBind.showHint}
85
86
  <span class="ml-1 text-[11px] font-medium tabular-nums opacity-80">
86
87
  {keyBind.ctrlKey ? "Ctrl+" : ""}{keyBind.shiftKey ? "Shift+" : ""}{keyBind.altKey ? "Alt+" : ""}{keyBind.key}
@@ -273,7 +273,7 @@
273
273
  ctx.clearRect(0, 0, width, height)
274
274
 
275
275
  const data = lines()
276
- const { padding, minX, timeSpan, yMin, yMax, getX, getY } = computeGeometry(data)
276
+ const { padding, graphWidth, minX, timeSpan, yMin, yMax, getX, getY } = computeGeometry(data)
277
277
  const style = getComputedStyle(canvas)
278
278
 
279
279
  /* Сетка в стиле PeriodChart: пунктир цветом --faint-color темы, подписи тем же цветом без прозрачности */
@@ -287,6 +287,9 @@
287
287
  /* Сетка X */
288
288
  ctx.textAlign = "center"
289
289
 
290
+ /* Подпись на каждой линии сетки, если влезает; на узком холсте - через одну или реже, чтобы не слипались */
291
+ const labelWidth = Math.max(ctx.measureText(formatAxisLabel(minX, timeSpan)).width, ctx.measureText(formatAxisLabel(minX + timeSpan, timeSpan)).width)
292
+ const labelStep = [1, 2, 5, 10].find((step) => (graphWidth / 10) * step >= labelWidth + 6) ?? 10
290
293
  for (let i = 0; i <= 10; i++) {
291
294
  const t = minX + (i / 10) * timeSpan
292
295
  const x = getX(t)
@@ -297,7 +300,7 @@
297
300
  ctx.stroke()
298
301
  ctx.globalAlpha = 1
299
302
  ctx.textBaseline = "top"
300
- ctx.fillText(formatAxisLabel(t, timeSpan), x, height - padding.bottom + 2)
303
+ if (i % labelStep === 0) ctx.fillText(formatAxisLabel(t, timeSpan), x, height - padding.bottom + 2)
301
304
  }
302
305
 
303
306
  /* Сетка Y */
@@ -349,12 +352,13 @@
349
352
  }
350
353
  </script>
351
354
 
352
- <div class={`relative flex w-full flex-col items-center justify-center ${wrapperClass}`}>
355
+ <!-- @container: раскладка по ширине самого графика - уже 28rem панель уходит под холст -->
356
+ <div class={`@container relative flex w-full flex-col items-center justify-center ${wrapperClass}`}>
353
357
  {#if label.name}
354
358
  <h5 class={`w-full px-4 text-center ${label.class}`}>{label.name}</h5>
355
359
  {/if}
356
360
 
357
- <div class="flex w-full min-w-0 flex-row gap-4">
361
+ <div class="flex w-full min-w-0 flex-col gap-3 @md:flex-row @md:gap-4">
358
362
  <!-- График: холст абсолютно поверх контейнера - его пиксельная ширина не распирает контейнер, иначе в сетке/flex с 1fr ширина растёт по кругу (ResizeObserver) -->
359
363
  <!-- design-handoff, раздел 9: рамка --hairline-color без тени, тултип в оформлении общего Tooltip.svelte -->
360
364
  <div bind:this={container} class="relative h-64 min-w-0 grow overflow-hidden rounded-[14px] border border-(--hairline-color)">
@@ -378,8 +382,8 @@
378
382
  {/if}
379
383
  </div>
380
384
 
381
- <!-- Панель настроек -->
382
- <div class="flex w-48 flex-col gap-2">
385
+ <!-- Панель настроек: справа от холста, на узком - под ним, развёртка и значения рядом -->
386
+ <div class="grid w-full grid-cols-[minmax(0,1fr)_minmax(0,1.4fr)] gap-x-3 gap-y-2 @md:flex @md:w-48 @md:flex-col @md:gap-2">
383
387
  {#if !isHistoryMode}
384
388
  <!-- Развертка по горизонтали -->
385
389
  <Select
@@ -391,7 +395,7 @@
391
395
  {/if}
392
396
 
393
397
  <!-- Переменные и их значение: сетка, а не таблица - имя обрезается «…», значение не переносится -->
394
- <div class="flex flex-col gap-1">
398
+ <div class="flex flex-col gap-1 first:col-span-full">
395
399
  <h5 class="text-[12px] font-semibold text-(--muted-color)">{$T("ui.graph.values")}</h5>
396
400
  <div class="grid grid-cols-[auto_minmax(0,1fr)_auto] items-center gap-x-2 gap-y-1 text-[13px]">
397
401
  {#each legend as item, i}
@@ -82,7 +82,7 @@
82
82
  const labelStep = $derived(Math.ceil(values.length / 12) || 1)
83
83
  </script>
84
84
 
85
- <div class={twMerge("relative flex w-full flex-col gap-3", wrapperClass)} style={accentStyle(accent)}>
85
+ <div class={twMerge("@container relative flex w-full flex-col gap-3", wrapperClass)} style={accentStyle(accent)}>
86
86
  {#if label.name}
87
87
  <h5 class={twMerge("w-full text-[13px] font-semibold text-(--muted-color)", label.class)}>{label.name}</h5>
88
88
  {/if}
@@ -94,7 +94,8 @@
94
94
  <button
95
95
  type="button"
96
96
  class={twMerge(
97
- "flex-1 cursor-pointer rounded-[7px] px-3 py-1.5 text-[13px] transition-colors duration-150",
97
+ /* на узком месте отступы меньше, длинное имя уровня переносится, а не выходит за край */
98
+ "min-w-0 flex-1 cursor-pointer rounded-[7px] px-1.5 py-1.5 text-[13px] leading-tight wrap-break-word transition-colors duration-150 @md:px-3",
98
99
  index === currentLevelIndex
99
100
  ? "bg-(--back-color) font-semibold text-(--font-color) shadow-(--elevation-1)"
100
101
  : "font-medium text-(--muted-color) hover:text-(--font-color)",
@@ -62,6 +62,7 @@
62
62
  - `listHeight` понимает `rem` и `px`. Другое значение даёт 256 px.
63
63
  - В виде `input` в списке остаются варианты, в названии которых есть введённый текст. `onInput` получает текст при каждом вводе. `onUpdate` вызывается при выборе варианта, Enter и уходе из поля. Текст, которого нет в списке, становится новым значением. Если у первого варианта числовое значение, введённое число отправляется числом.
64
64
  - Клавиатура: стрелки открывают список и ходят по вариантам, Enter выбирает, Escape закрывает список.
65
+ - Если варианты `buttons` не помещаются по ширине целиком, группа показывается выпадающим списком. Место появилось - снова кнопки.
65
66
  - В виде `buttons` вариант с `icon` показывает иконку, а `name` уходит в подсказку. Так узкие панели не обрезают подписи.
66
67
  - В виде `buttons` вариант со своим цветом (`accent`) залит им всегда, а выбранный отмечается рамкой. Так сделана палитра цветов в панелях свойств.
67
68
  - `fitContent` делает кнопки одинаковыми по самой длинной подписи, без переноса текста. Подходит для шапок и переключателей режима.
@@ -39,10 +39,34 @@
39
39
  let portalElement: HTMLDivElement | undefined = $state()
40
40
  let anchorRect: DOMRect | null = $state(null)
41
41
 
42
+ /* type="buttons" на узком месте: если варианты не помещаются целиком, группа показывается выпадающим списком */
43
+ let measureElement: HTMLDivElement | undefined = $state()
44
+ let anchorWidth = $state(Infinity)
45
+ let buttonsNeed = $state(0)
46
+ $effect(() => {
47
+ if (type !== "buttons" || !measureElement) return
48
+ void options
49
+ const measure = () => {
50
+ const widest = Math.max(0, ...[...measureElement!.children].map((child) => child.getBoundingClientRect().width))
51
+ /* сегменты равной ширины: самый широкий текст + отступы 2×12, разделители и рамка */
52
+ buttonsNeed = options.length * (widest + 24) + options.length + 1
53
+ }
54
+ measure()
55
+ void document.fonts?.ready.then(measure)
56
+ })
57
+ const shownType = $derived(type === "buttons" && anchorWidth < buttonsNeed ? "select" : type)
58
+
42
59
  const selectedValues = $derived(multiSelect ? (Array.isArray(value) ? (value as T[]) : []) : [value as T])
43
60
  const isSelected = (option: IOption<T>) => selectedValues.includes(option.value)
44
61
  const current = $derived(multiSelect ? undefined : options.find((option) => option.value === value))
45
- const valueText = $derived(current?.name ?? (value == null || Array.isArray(value) ? "" : String(value)))
62
+ const valueText = $derived(
63
+ multiSelect
64
+ ? options
65
+ .filter(isSelected)
66
+ .map((option) => option.name ?? String(option.value))
67
+ .join(", ")
68
+ : (current?.name ?? (value == null || Array.isArray(value) ? "" : String(value))),
69
+ )
46
70
  const visibleOptions = $derived(
47
71
  type === "input" && draft ? options.filter((option) => (option.name ?? "").toLowerCase().includes(draft!.toLowerCase())) : options,
48
72
  )
@@ -170,10 +194,19 @@
170
194
  </script>
171
195
 
172
196
  <div class={twMerge(`flex w-full flex-col gap-1`, wrapperClass)}>
173
- <div class="relative flex w-full flex-col gap-1" bind:this={anchorElement}>
174
- <FieldLabel {label} for={type === "buttons" ? undefined : uid} id={`${uid}-label`} />
197
+ <div class="relative flex w-full flex-col gap-1" bind:this={anchorElement} bind:clientWidth={anchorWidth}>
198
+ <FieldLabel {label} for={shownType === "buttons" ? undefined : uid} id={`${uid}-label`} />
199
+
200
+ {#if type === "buttons"}
201
+ <!-- Невидимые подписи вариантов: по их ширине решается, помещается ли группа кнопок -->
202
+ <div bind:this={measureElement} class="pointer-events-none invisible absolute top-0 left-0 flex h-0 w-max overflow-hidden" aria-hidden="true">
203
+ {#each options as option, index (option.id ?? index)}
204
+ <span class="text-[13px] font-semibold whitespace-nowrap {option.icon ? 'w-[18px]' : ''}">{option.icon ? "" : option.name}</span>
205
+ {/each}
206
+ </div>
207
+ {/if}
175
208
 
176
- {#if type === "select"}
209
+ {#if shownType === "select"}
177
210
  <button
178
211
  id={uid}
179
212
  class={twMerge(`${fieldBase} flex items-center justify-between gap-2 ${fieldState}`, disabled ? "" : "cursor-pointer")}
@@ -198,7 +231,7 @@
198
231
  stroke-linejoin="round"><path d="M6 9l6 6 6-6" /></svg
199
232
  >
200
233
  </button>
201
- {:else if type === "input"}
234
+ {:else if shownType === "input"}
202
235
  <input
203
236
  id={uid}
204
237
  value={draft ?? valueText}
@@ -271,7 +304,7 @@
271
304
  </div>
272
305
  {/if}
273
306
 
274
- {#if isOpen && type !== "buttons"}
307
+ {#if isOpen && shownType !== "buttons"}
275
308
  <div
276
309
  use:portal
277
310
  bind:this={portalElement}
@@ -54,7 +54,8 @@
54
54
  <!-- Подпись по умолчанию по центру - над переключателем, который тоже по центру; выравнивание из label.class важнее -->
55
55
  <h5 class={twMerge(`w-full text-center text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</h5>
56
56
  {/if}
57
- <div class="flex w-full {type == 'vertical' ? 'flex-wrap' : ''} items-center justify-around gap-4">
57
+ <!-- Биты переносятся на новую строку, если не помещаются -->
58
+ <div class="flex w-full flex-wrap items-center justify-around gap-x-4 gap-y-2">
58
59
  {#each bits as option, index (index)}
59
60
  <div class="flex flex-col gap-1" style={accentStyle(option.accent)}>
60
61
  {#if option.name && bitMode}
@@ -65,7 +65,7 @@
65
65
  - `visibleRows` - сколько строк видно без прокрутки. Высоту таблица считает по первым строкам.
66
66
  - `clearButton` добавляет кнопку очистки в узкой колонке справа (`2.5rem`), она не перекрывает заголовки. Очистку можно вызвать и из кода: `clear()`.
67
67
 
68
- **Подгрузка.** Если задан `cursor` и передан `loader`, при прокрутке почти до конца (последние 50 px) таблица вызывает `getData`. Пока `loader()` возвращает `true`, повторных вызовов нет. `cursor = null` выключает подгрузку. Без `loader` подгрузка не работает.
68
+ **Подгрузка.** Если задан `cursor` и передан `loader`, при прокрутке почти до конца (последние 50 px) таблица вызывает `getData`. Если строк меньше высоты таблицы, она сама зовёт `getData`, пока не заполнится. Пока `loader()` возвращает `true`, повторных вызовов нет. `cursor = null` выключает подгрузку. Без `loader` подгрузка не работает.
69
69
 
70
70
  </details>
71
71
 
@@ -79,6 +79,7 @@
79
79
  - Ширину колонки в знаках моноширинного текста считает `tableMonoWidth(знаков, знаковПодписи?)` из `columnWidth.ts`. Колонка растёт вместе с размером шрифта и не бывает уже заголовка. Пример: `width: tableMonoWidth(6, 2)` для `0x0000`.
80
80
  - Колонка с `width: "0%"` скрыта. Без `width` колонка занимает `minmax(0, 1fr)`.
81
81
  - Колонки с выравниванием вправо показывают цифры одинаковой ширины.
82
+ - Если колонки не помещаются (заданные ширины и по 5rem на гибкие), таблица прокручивается вбок, а не обрезается.
82
83
  - Текстовая ячейка выводит `render(row)`, без него - значение по `key`: массив вариантов `{ name, value }` списком `name`, другой объект - как JSON. Всё выводится как текст, HTML - только с `html: true`, данные тогда экранирует вызывающий. Ссылку задаёт `href(row)`: ячейка становится `<a>` с текстом внутри, HTML для этого не нужен. `
83
84
  ` в тексте переносит строку. Цвет из строки задаёт `accent(row)` (роль темы, как у компонентов), с `badge: true` текст стоит на мягкой подложке своего цвета; ячейка из одних бейджей ставит их вплотную с переносом. `onClick(row)` делает текст кнопкой (открыть папку и т.п.), сортировка по `key` при этом остаётся. Несколько элементов ячейки встают в ряд, со `stack: true` у колонки - столбиком.
84
85
  - `modal: true` открывает по нажатию содержимое ячейки целиком: длинные строки переносятся, отступы сохраняются, кнопка в окне копирует текст. `modal` - сниппет `Snippet<[row]>`: в окне своё содержимое (без кнопки внизу), так устроено окно xPOE-Debug.
@@ -113,6 +113,13 @@
113
113
  let gridTemplate = $derived(
114
114
  [...header.filter((c) => c.width !== "0%").map((c) => c.width || "minmax(0, 1fr)"), ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : [])].join(" "),
115
115
  )
116
+ /* Наименьшая ширина таблицы: заданные ширины колонок и по 5rem на гибкие; уже - прокрутка вбок, а не обрезка */
117
+ let minTableWidth = $derived(
118
+ `calc(${[
119
+ ...header.filter((c) => c.width !== "0%").map((c) => (!c.width || c.width.includes("fr") ? "5rem" : c.width)),
120
+ ...(dataBuffer.clearButton ? [ACTIONS_COLUMN] : []),
121
+ ].join(" + ")})`,
122
+ )
116
123
  const columnContent = (column: ITableHeader<Row>, row: Row) => (typeof column.content === "function" ? column.content(row) : (column.content ?? []))
117
124
  const sortKey = (column: ITableHeader<Row>) =>
118
125
  typeof column.content === "function"
@@ -135,17 +142,28 @@
135
142
  tableHeight = height
136
143
  }
137
144
 
145
+ /* Следующая порция, когда низ таблицы виден: при прокрутке и если строки ещё не заполнили высоту таблицы */
146
+ const loadMore = () => {
147
+ if (!container || cursor === null || !loader || loader()) return
148
+ const { scrollTop, clientHeight, scrollHeight } = container
149
+ if (scrollTop + clientHeight >= scrollHeight - 50) getData()
150
+ }
151
+
138
152
  $effect(() => {
139
153
  void entries
140
154
  tick().then(() => {
141
155
  measure()
142
156
  if (autoscroll && isAutoscroll && !dataBuffer.logger && container) container.scrollTop = container.scrollHeight
157
+ loadMore()
143
158
  })
144
159
  })
145
160
 
146
161
  $effect(() => {
147
162
  if (!container) return
148
- const observer = new ResizeObserver(measure)
163
+ const observer = new ResizeObserver(() => {
164
+ measure()
165
+ loadMore()
166
+ })
149
167
  observer.observe(container)
150
168
  return () => observer.disconnect()
151
169
  })
@@ -154,7 +172,7 @@
154
172
  if (!container) return
155
173
  const { scrollTop, clientHeight, scrollHeight } = container
156
174
  isAutoscroll = scrollHeight - scrollTop <= clientHeight + 50
157
- if (scrollTop + clientHeight >= scrollHeight - 50 && cursor !== null && loader && !loader()) getData()
175
+ loadMore()
158
176
  }
159
177
 
160
178
  /* ********************************************************** */
@@ -234,217 +252,219 @@
234
252
  <span class={twMerge(`w-full pb-2 text-[12px] font-semibold text-(--muted-color)`, label.class)}>{label.name}</span>
235
253
  {/if}
236
254
 
237
- <div class="relative flex h-full w-full flex-col overflow-hidden rounded-[14px] border border-(--hairline-color) bg-(--back-color)">
238
- <!-- Шапка -->
239
- <div
240
- 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"
241
- style={`grid-template-columns: ${gridTemplate}; padding-right: ${scrollbarWidth}px;`}
242
- >
243
- {#each header as column, index (column)}
244
- {#if column.width !== "0%"}
245
- {@const key = sortKey(column)}
246
- <div
247
- class={twMerge(
248
- `flex items-center gap-1 border-l px-3 py-2 ${outline && index !== 0 ? "border-(--hairline-color)" : "border-transparent"}
255
+ <div class="relative flex h-full w-full flex-col overflow-x-auto overflow-y-hidden rounded-[14px] border border-(--hairline-color) bg-(--back-color)">
256
+ <div class="flex min-h-0 w-full flex-1 flex-col" style="min-width: {minTableWidth};">
257
+ <!-- Шапка -->
258
+ <div
259
+ 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"
260
+ style={`grid-template-columns: ${gridTemplate}; padding-right: ${scrollbarWidth}px;`}
261
+ >
262
+ {#each header as column, index (column)}
263
+ {#if column.width !== "0%"}
264
+ {@const key = sortKey(column)}
265
+ <div
266
+ class={twMerge(
267
+ `flex items-center gap-1 border-l px-3 py-2 ${outline && index !== 0 ? "border-(--hairline-color)" : "border-transparent"}
249
268
  ${column.align === "center" ? "justify-center text-center" : column.align === "right" ? "justify-end text-right" : "justify-start text-left"}`,
250
- column.label?.class,
251
- )}
252
- >
253
- <span>{$T(column.label?.name ?? "")}</span>
254
- {#if key !== undefined && !stash}
255
- <button
256
- class="inline-flex cursor-pointer items-center rounded px-1 text-(--muted-color) transition-colors duration-150 hover:bg-(--back-color) hover:text-(--font-color)"
257
- onclick={() => sortBy(key)}
258
- >
259
- ↑↓
260
- </button>
261
- {/if}
269
+ column.label?.class,
270
+ )}
271
+ >
272
+ <span>{$T(column.label?.name ?? "")}</span>
273
+ {#if key !== undefined && !stash}
274
+ <button
275
+ class="inline-flex cursor-pointer items-center rounded px-1 text-(--muted-color) transition-colors duration-150 hover:bg-(--back-color) hover:text-(--font-color)"
276
+ onclick={() => sortBy(key)}
277
+ >
278
+ ↑↓
279
+ </button>
280
+ {/if}
281
+ </div>
282
+ {/if}
283
+ {/each}
284
+ {#if dataBuffer.clearButton}
285
+ <div class="flex items-center justify-center tracking-normal normal-case">
286
+ <Button
287
+ componentClass={twMerge("size-7 p-1.5 text-(--muted-color) hover:text-(--red-text)", dataBuffer.clearClass)}
288
+ content={{ icon: ButtonClear, info: { text: $T("common.table.clear"), side: "left" } }}
289
+ onClick={clear}
290
+ />
262
291
  </div>
263
292
  {/if}
264
- {/each}
265
- {#if dataBuffer.clearButton}
266
- <div class="flex items-center justify-center tracking-normal normal-case">
267
- <Button
268
- componentClass={twMerge("size-7 p-1.5 text-(--muted-color) hover:text-(--red-text)", dataBuffer.clearClass)}
269
- content={{ icon: ButtonClear, info: { text: $T("common.table.clear"), side: "left" } }}
270
- onClick={clear}
271
- />
272
- </div>
273
- {/if}
274
- </div>
293
+ </div>
275
294
 
276
- {#if entries.length > 0}
277
- <!-- Тело с прокруткой -->
278
- <div class="relative flex-1 overflow-y-auto bg-(--back-color)" bind:this={container} onscroll={handleScroll}>
279
- <div
280
- class="min-w-0"
281
- bind:this={rowsEl}
282
- style={dataBuffer.visibleRows && tableHeight && entries.length > dataBuffer.visibleRows ? `height: ${tableHeight}px;` : ""}
283
- >
284
- {#each entries as entry, i (entry.key)}
285
- {@const row = withPicks(entry.row)}
286
- <div
287
- class="grid border-t border-(--hairline-color) transition-colors duration-150 hover:bg-(--accent-soft)"
288
- style={`grid-template-columns: ${gridTemplate};`}
289
- >
290
- {#each header as column, j (column)}
291
- {#if column.width !== "0%"}
292
- {@const contents = columnContent(column, row) as ITableContent<Row>[]}
293
- <!-- Одни бейджи - вплотную с переносом; stack - столбиком; иначе - в ряд равными долями -->
294
- {@const badges = contents.length > 1 && contents.every((c) => c.type === "text" && c.data.badge)}
295
- <div
296
- class="relative {badges
297
- ? 'flex flex-wrap gap-1'
298
- : 'grid gap-x-2'} min-h-7 w-full min-w-0 items-center px-3 py-1 text-[length:var(--table-font-size,13px)] wrap-break-word
295
+ {#if entries.length > 0}
296
+ <!-- Тело с прокруткой -->
297
+ <div class="relative flex-1 overflow-y-auto bg-(--back-color)" bind:this={container} onscroll={handleScroll}>
298
+ <div
299
+ class="min-w-0"
300
+ bind:this={rowsEl}
301
+ style={dataBuffer.visibleRows && tableHeight && entries.length > dataBuffer.visibleRows ? `height: ${tableHeight}px;` : ""}
302
+ >
303
+ {#each entries as entry, i (entry.key)}
304
+ {@const row = withPicks(entry.row)}
305
+ <div
306
+ class="grid border-t border-(--hairline-color) transition-colors duration-150 hover:bg-(--accent-soft)"
307
+ style={`grid-template-columns: ${gridTemplate};`}
308
+ >
309
+ {#each header as column, j (column)}
310
+ {#if column.width !== "0%"}
311
+ {@const contents = columnContent(column, row) as ITableContent<Row>[]}
312
+ <!-- Одни бейджи - вплотную с переносом; stack - столбиком; иначе - в ряд равными долями -->
313
+ {@const badges = contents.length > 1 && contents.every((c) => c.type === "text" && c.data.badge)}
314
+ <div
315
+ class="relative {badges
316
+ ? 'flex flex-wrap gap-1'
317
+ : 'grid gap-x-2'} min-h-7 w-full min-w-0 items-center px-3 py-1 text-[length:var(--table-font-size,13px)] wrap-break-word
299
318
  {column.align === 'center'
300
- ? 'justify-center justify-items-center text-center'
301
- : column.align === 'right'
302
- ? 'justify-end justify-items-end text-right tabular-nums'
303
- : 'justify-start justify-items-start text-left'}
319
+ ? 'justify-center justify-items-center text-center'
320
+ : column.align === 'right'
321
+ ? 'justify-end justify-items-end text-right tabular-nums'
322
+ : 'justify-start justify-items-start text-left'}
304
323
  {j !== 0 ? 'border-l' : ''} {outline ? 'border-(--hairline-color)' : 'border-transparent'} {column.disableSelect
305
- ? 'select-none'
306
- : 'select-all'}"
307
- style={badges ? undefined : `grid-template-columns: ${column.stack ? "minmax(0, 1fr)" : `repeat(${contents.length}, minmax(0, 1fr))`};`}
308
- >
309
- {#each contents as content, index}
310
- {#if content.type === "button"}
311
- {@const button = resolve(content.data, row)}
312
- {@const title = resolve(button.title, row)}
313
- <button class="{buttonClass(button, row)} bg-(--bg-color)" onclick={() => buttonClick(row, button)} {title} aria-label={title}>
314
- {#if button.icon}
315
- <span class="flex size-4 shrink-0 items-center justify-center overflow-visible [&_svg]:h-full [&_svg]:w-full">
316
- {#if typeof button.icon === "string"}
317
- {@html sanitizeHtml(button.icon)}
318
- {:else}
319
- <button.icon />
320
- {/if}
321
- </span>
322
- {/if}
323
- {$T(resolve(button.name, row) ?? "")}
324
- </button>
325
- {:else if content.type === "select"}
326
- {@const select = content.data}
327
- {@const options = (Array.isArray(row[select.key]) ? row[select.key] : []) as IOption<string | number>[]}
328
- {@const current = (row as Record<string, unknown>)[valueKey(select.key)]}
329
- {@const open = dropdown?.row === i && dropdown.col === j && dropdown.index === index ? dropdown : null}
330
- <div class="relative w-full select-none">
331
- <button
332
- 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)"
333
- onclick={(e) => toggleDropdown(e, i, j, index)}
334
- >
335
- {options.find((o) => o.value === current)?.name ?? $T("common.select_tag")}
324
+ ? 'select-none'
325
+ : 'select-all'}"
326
+ style={badges ? undefined : `grid-template-columns: ${column.stack ? "minmax(0, 1fr)" : `repeat(${contents.length}, minmax(0, 1fr))`};`}
327
+ >
328
+ {#each contents as content, index}
329
+ {#if content.type === "button"}
330
+ {@const button = resolve(content.data, row)}
331
+ {@const title = resolve(button.title, row)}
332
+ <button class="{buttonClass(button, row)} bg-(--bg-color)" onclick={() => buttonClick(row, button)} {title} aria-label={title}>
333
+ {#if button.icon}
334
+ <span class="flex size-4 shrink-0 items-center justify-center overflow-visible [&_svg]:h-full [&_svg]:w-full">
335
+ {#if typeof button.icon === "string"}
336
+ {@html sanitizeHtml(button.icon)}
337
+ {:else}
338
+ <button.icon />
339
+ {/if}
340
+ </span>
341
+ {/if}
342
+ {$T(resolve(button.name, row) ?? "")}
336
343
  </button>
337
- {#if open}
344
+ {:else if content.type === "select"}
345
+ {@const select = content.data}
346
+ {@const options = (Array.isArray(row[select.key]) ? row[select.key] : []) as IOption<string | number>[]}
347
+ {@const current = (row as Record<string, unknown>)[valueKey(select.key)]}
348
+ {@const open = dropdown?.row === i && dropdown.col === j && dropdown.index === index ? dropdown : null}
349
+ <div class="relative w-full select-none">
350
+ <button
351
+ 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)"
352
+ onclick={(e) => toggleDropdown(e, i, j, index)}
353
+ >
354
+ {options.find((o) => o.value === current)?.name ?? $T("common.select_tag")}
355
+ </button>
356
+ {#if open}
357
+ <div
358
+ class="fixed z-50 max-h-[40vh] overflow-y-auto rounded-[10px] border border-(--hairline-color) bg-(--back-color) p-1 shadow-(--elevation-2)"
359
+ style="top: {open.rect.bottom + 4}px; left: {open.rect.left}px; width: {open.rect.width}px;"
360
+ transition:slide={{ duration: slideDuration }}
361
+ >
362
+ {#each options as option (option.id ?? option.value)}
363
+ <button
364
+ class={twMerge(
365
+ "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)",
366
+ option.accent && "text-(--accent-text)",
367
+ )}
368
+ style={accentStyle(option.accent)}
369
+ onclick={(e) => selectOption(e, entry.row, select.key, option)}
370
+ >
371
+ {option.name}
372
+ </button>
373
+ {/each}
374
+ </div>
375
+ {/if}
376
+ </div>
377
+ {:else if content.type === "image"}
378
+ {@const image = content.data}
379
+ {@const src = resolve(image.src, row)}
380
+ <div
381
+ class="flex items-center justify-center [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
382
+ style={`width: ${image.width || "2rem"}; height: ${image.height || "2rem"};`}
383
+ >
384
+ {#if src}
385
+ <img {src} alt={image.alt ?? "Image"} class={twMerge("h-full w-full object-cover", image.class)} loading="lazy" />
386
+ {:else if typeof image.defaultIcon === "string"}
387
+ {@html sanitizeHtml(image.defaultIcon)}
388
+ {:else if image.defaultIcon}
389
+ <image.defaultIcon />
390
+ {/if}
391
+ </div>
392
+ {:else if content.type === "progressBar"}
393
+ {@const bar = content.data}
394
+ <div class="grid h-7 w-full grid-cols-[3.5rem_1fr] items-center gap-2">
395
+ <span class="text-right text-[12px] font-semibold tabular-nums">{roundToClean(Number(row[bar.key] ?? 0))}{bar.units}</span>
396
+ <div class="relative my-auto h-1.5 overflow-hidden rounded-full bg-(--container-color)">
397
+ <div
398
+ class="absolute top-0 left-0 flex h-full rounded-full bg-(--bg-color,var(--accent-color))"
399
+ style="width: {progressPercent(row[bar.key] as number, bar.minNum, bar.maxNum)}%;"
400
+ ></div>
401
+ </div>
402
+ </div>
403
+ {:else if content.type === "text"}
404
+ {@const text = content.data}
405
+ {@const value = cellContent(row, text)}
406
+ {@const accent = text.accent?.(row)}
407
+ <!-- w-full + min-w-0: при justify-items-start ячейка иначе берёт ширину по содержимому и truncate не даёт «…»;
408
+ в тексте - перенос строки -->
409
+ <div class="flex w-full min-w-0 items-center">
338
410
  <div
339
- class="fixed z-50 max-h-[40vh] overflow-y-auto rounded-[10px] border border-(--hairline-color) bg-(--back-color) p-1 shadow-(--elevation-2)"
340
- style="top: {open.rect.bottom + 4}px; left: {open.rect.left}px; width: {open.rect.width}px;"
341
- transition:slide={{ duration: slideDuration }}
411
+ class="max-w-full min-w-0 wrap-break-word {text.truncated ? 'truncate' : 'whitespace-pre-line'} {accent
412
+ ? 'text-(--accent-text)'
413
+ : ''} {accent && text.badge ? 'w-fit rounded-md bg-(--accent-soft) px-1.5 text-[12px] font-medium' : 'w-full'}"
414
+ style={accentStyle(accent)}
415
+ onmouseenter={text.tooltip
416
+ ? (e) => {
417
+ const tip = typeof text.tooltip === "function" ? text.tooltip(row) : cellText(row, text)
418
+ if (tip) tooltip = { show: true, text: tip, x: e.clientX, y: e.clientY }
419
+ }
420
+ : undefined}
421
+ onmouseleave={text.tooltip ? () => (tooltip.show = false) : undefined}
422
+ onmousemove={text.tooltip ? (e) => ((tooltip.x = e.clientX), (tooltip.y = e.clientY)) : undefined}
423
+ role="presentation"
342
424
  >
343
- {#each options as option (option.id ?? option.value)}
425
+ {#if text.modal}
344
426
  <button
345
- class={twMerge(
346
- "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)",
347
- option.accent && "text-(--accent-text)",
348
- )}
349
- style={accentStyle(option.accent)}
350
- onclick={(e) => selectOption(e, entry.row, select.key, option)}
427
+ class="cursor-pointer text-left {text.truncated ? 'block w-full max-w-full truncate' : 'w-fit'}"
428
+ onclick={(e) => {
429
+ e.stopPropagation()
430
+ modal = { row, text }
431
+ modalOpen = true
432
+ }}
351
433
  >
352
- {option.name}
434
+ {#if text.html}{@html sanitizeHtml(value)}{:else}{value}{/if}
353
435
  </button>
354
- {/each}
436
+ {:else if text.onClick}
437
+ <button
438
+ class="cursor-pointer text-left hover:underline"
439
+ onclick={(e) => {
440
+ e.stopPropagation()
441
+ text.onClick?.(row)
442
+ }}>{value}</button
443
+ >
444
+ {:else if text.href}
445
+ <a class="underline" href={text.href(row)}>{value}</a>
446
+ {:else if text.html}
447
+ {@html sanitizeHtml(value)}
448
+ {:else}
449
+ {value}
450
+ {/if}
355
451
  </div>
356
- {/if}
357
- </div>
358
- {:else if content.type === "image"}
359
- {@const image = content.data}
360
- {@const src = resolve(image.src, row)}
361
- <div
362
- class="flex items-center justify-center [&_svg]:h-full [&_svg]:max-h-full [&_svg]:w-full [&_svg]:max-w-full"
363
- style={`width: ${image.width || "2rem"}; height: ${image.height || "2rem"};`}
364
- >
365
- {#if src}
366
- <img {src} alt={image.alt ?? "Image"} class={twMerge("h-full w-full object-cover", image.class)} loading="lazy" />
367
- {:else if typeof image.defaultIcon === "string"}
368
- {@html sanitizeHtml(image.defaultIcon)}
369
- {:else if image.defaultIcon}
370
- <image.defaultIcon />
371
- {/if}
372
- </div>
373
- {:else if content.type === "progressBar"}
374
- {@const bar = content.data}
375
- <div class="grid h-7 w-full grid-cols-[3.5rem_1fr] items-center gap-2">
376
- <span class="text-right text-[12px] font-semibold tabular-nums">{roundToClean(Number(row[bar.key] ?? 0))}{bar.units}</span>
377
- <div class="relative my-auto h-1.5 overflow-hidden rounded-full bg-(--container-color)">
378
- <div
379
- class="absolute top-0 left-0 flex h-full rounded-full bg-(--bg-color,var(--accent-color))"
380
- style="width: {progressPercent(row[bar.key] as number, bar.minNum, bar.maxNum)}%;"
381
- ></div>
382
- </div>
383
- </div>
384
- {:else if content.type === "text"}
385
- {@const text = content.data}
386
- {@const value = cellContent(row, text)}
387
- {@const accent = text.accent?.(row)}
388
- <!-- w-full + min-w-0: при justify-items-start ячейка иначе берёт ширину по содержимому и truncate не даёт «…»;
389
- в тексте - перенос строки -->
390
- <div class="flex w-full min-w-0 items-center">
391
- <div
392
- class="max-w-full min-w-0 wrap-break-word {text.truncated ? 'truncate' : 'whitespace-pre-line'} {accent
393
- ? 'text-(--accent-text)'
394
- : ''} {accent && text.badge ? 'w-fit rounded-md bg-(--accent-soft) px-1.5 text-[12px] font-medium' : 'w-full'}"
395
- style={accentStyle(accent)}
396
- onmouseenter={text.tooltip
397
- ? (e) => {
398
- const tip = typeof text.tooltip === "function" ? text.tooltip(row) : cellText(row, text)
399
- if (tip) tooltip = { show: true, text: tip, x: e.clientX, y: e.clientY }
400
- }
401
- : undefined}
402
- onmouseleave={text.tooltip ? () => (tooltip.show = false) : undefined}
403
- onmousemove={text.tooltip ? (e) => ((tooltip.x = e.clientX), (tooltip.y = e.clientY)) : undefined}
404
- role="presentation"
405
- >
406
- {#if text.modal}
407
- <button
408
- class="cursor-pointer text-left {text.truncated ? 'block w-full max-w-full truncate' : 'w-fit'}"
409
- onclick={(e) => {
410
- e.stopPropagation()
411
- modal = { row, text }
412
- modalOpen = true
413
- }}
414
- >
415
- {#if text.html}{@html sanitizeHtml(value)}{:else}{value}{/if}
416
- </button>
417
- {:else if text.onClick}
418
- <button
419
- class="cursor-pointer text-left hover:underline"
420
- onclick={(e) => {
421
- e.stopPropagation()
422
- text.onClick?.(row)
423
- }}>{value}</button
424
- >
425
- {:else if text.href}
426
- <a class="underline" href={text.href(row)}>{value}</a>
427
- {:else if text.html}
428
- {@html sanitizeHtml(value)}
429
- {:else}
430
- {value}
452
+ {#if text.copy}
453
+ <CopyButton class="ml-1.5" text={() => cellText(row, text)} />
431
454
  {/if}
432
455
  </div>
433
- {#if text.copy}
434
- <CopyButton class="ml-1.5" text={() => cellText(row, text)} />
435
- {/if}
436
- </div>
437
- {/if}
438
- {/each}
439
- </div>
440
- {/if}
441
- {/each}
442
- {#if dataBuffer.clearButton}<div></div>{/if}
443
- </div>
444
- {/each}
456
+ {/if}
457
+ {/each}
458
+ </div>
459
+ {/if}
460
+ {/each}
461
+ {#if dataBuffer.clearButton}<div></div>{/if}
462
+ </div>
463
+ {/each}
464
+ </div>
445
465
  </div>
446
- </div>
447
- {/if}
466
+ {/if}
467
+ </div>
448
468
 
449
469
  {#if tooltip.show}
450
470
  <div
@@ -458,7 +478,7 @@
458
478
  {/if}
459
479
  <!-- Нижнее поле для сводной информации -->
460
480
  {#if footer}
461
- <div class="flex h-8 items-center justify-center border-t border-(--hairline-color) bg-(--container-color)">
481
+ <div class="sticky left-0 flex h-8 shrink-0 items-center justify-center border-t border-(--hairline-color) bg-(--container-color)">
462
482
  <span class="text-[12px] font-semibold text-(--muted-color)">{footer}</span>
463
483
  </div>
464
484
  {/if}
@@ -6,13 +6,13 @@
6
6
 
7
7
  let { wrapperClass = "", accent, background = false, underline = false, content = { name: "", class: "", size: "base" } }: ITextFieldProps = $props()
8
8
 
9
- /* Размеры по шкале темы: 13 / 15 / 24 / 34 / 44 с весом и трекингом по роли */
9
+ /* Размеры по шкале темы: 13 / 15 / 24 / 34 / 44 с весом и трекингом по роли; на телефоне крупные меньше: 20 / 26 / 32 */
10
10
  const textSize = {
11
11
  small: "text-[13px] leading-[1.45] text-(--muted-color)",
12
12
  base: "text-[15px] leading-[1.5]",
13
- large: "text-[24px] leading-[1.2] font-[650] tracking-[-0.015em]",
14
- huge: "text-[34px] leading-[1.15] font-[650] tracking-[-0.02em]",
15
- massive: "text-[44px] leading-[1.08] font-bold tracking-[-0.025em]",
13
+ large: "text-[24px] leading-[1.2] max-sm:text-[20px] font-[650] tracking-[-0.015em]",
14
+ huge: "text-[34px] leading-[1.15] max-sm:text-[26px] font-[650] tracking-[-0.02em]",
15
+ massive: "text-[44px] leading-[1.08] max-sm:text-[32px] font-bold tracking-[-0.025em]",
16
16
  } as const
17
17
  </script>
18
18
 
@@ -23,7 +23,7 @@
23
23
  wrapperClass,
24
24
  )}
25
25
  >
26
- <p class={twMerge(`w-full text-pretty ${textSize[content.size ?? "base"]}`, accent ? "text-(--accent-text)" : "", content.class)}>
26
+ <p class={twMerge(`w-full text-pretty wrap-break-word ${textSize[content.size ?? "base"]}`, accent ? "text-(--accent-text)" : "", content.class)}>
27
27
  {content.name}
28
28
  </p>
29
29
  </div>
@@ -50,7 +50,8 @@
50
50
  let off = $derived(disabled || !text)
51
51
  </script>
52
52
 
53
- <div class="grid grid-cols-3 gap-3">
53
+ <!-- Три кнопки в ряд, на узком месте переносятся -->
54
+ <div class="grid grid-cols-[repeat(auto-fit,minmax(7rem,1fr))] gap-3">
54
55
  <div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.download"), enabled: hints }}>
55
56
  <Button variant="primary" content={{ name: $T("widget.mission.download") }} disabled={off} onClick={download} />
56
57
  </div>
@@ -9,6 +9,11 @@ declare const constructorTranslations: {
9
9
  en: string;
10
10
  zh: string;
11
11
  };
12
+ "library.phone": {
13
+ ru: string;
14
+ en: string;
15
+ zh: string;
16
+ };
12
17
  "library.regexp": {
13
18
  ru: string;
14
19
  en: string;
@@ -1,6 +1,7 @@
1
1
  const constructorTranslations = {
2
2
  "library.overview": { ru: "Обзор", en: "Overview", zh: "概览" },
3
3
  "library.examples": { ru: "Примеры", en: "Examples", zh: "示例" },
4
+ "library.phone": { ru: "Телефон", en: "Phone", zh: "手机" },
4
5
  "library.regexp": { ru: "Регулярные выражения", en: "Regular expressions", zh: "正则表达式" },
5
6
  "library.theme": { ru: "Тема", en: "Theme", zh: "主题" },
6
7
  "library.icons": { ru: "Иконки", en: "Icons", zh: "图标" },
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "poe-svelte-ui-lib",
3
- "version": "2.2.0",
3
+ "version": "2.3.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/Oleg-Perevyshin/ElementsUI.git"