poe-svelte-ui-lib 2.2.0 → 2.3.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.
- package/dist/Accordion/Accordion.svelte +1 -1
- package/dist/Button/Button.svelte +2 -1
- package/dist/Graph/Graph.svelte +11 -7
- package/dist/PeriodChart/PeriodChart.svelte +3 -2
- package/dist/Select/README.md +1 -0
- package/dist/Select/Select.svelte +39 -6
- package/dist/Switch/Switch.svelte +2 -1
- package/dist/Table/README.md +2 -1
- package/dist/Table/Table.svelte +218 -198
- package/dist/TextField/TextField.svelte +5 -5
- package/dist/WidgetDeviceInfo/WidgetDeviceInfo.svelte +4 -2
- package/dist/WidgetFileSystem/WidgetFileSystem.svelte +4 -2
- package/dist/WidgetHeader.svelte +10 -7
- package/dist/WidgetHeader.svelte.d.ts +1 -1
- package/dist/WidgetMap/WidgetMap.svelte +10 -4
- package/dist/WidgetMap/mission/MapAgro.svelte +6 -5
- package/dist/WidgetMap/mission/MapRoute.svelte +8 -5
- package/dist/WidgetMap/mission/MissionActions.svelte +11 -3
- package/dist/WidgetStackInfo/WidgetStackInfo.svelte +13 -3
- package/dist/WidgetWiFi/WidgetWiFi.svelte +2 -2
- package/dist/locales/constructor.d.ts +5 -0
- package/dist/locales/constructor.js +1 -0
- package/package.json +1 -1
|
@@ -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
|
|
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
|
-
|
|
83
|
+
<!-- Длинная подпись на узкой кнопке - в две строки, а не обрезка -->
|
|
84
|
+
<span class="line-clamp-2 text-center leading-[1.05]">{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}
|
package/dist/Graph/Graph.svelte
CHANGED
|
@@ -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
|
-
|
|
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
|
-
|
|
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)",
|
package/dist/Select/README.md
CHANGED
|
@@ -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(
|
|
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={
|
|
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
|
|
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
|
|
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 &&
|
|
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
|
-
|
|
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}
|
package/dist/Table/README.md
CHANGED
|
@@ -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.
|
package/dist/Table/Table.svelte
CHANGED
|
@@ -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(
|
|
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
|
-
|
|
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
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
{#
|
|
245
|
-
{
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
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
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
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
|
-
|
|
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
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
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
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
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
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
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
|
-
|
|
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="
|
|
340
|
-
|
|
341
|
-
|
|
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
|
-
{#
|
|
425
|
+
{#if text.modal}
|
|
344
426
|
<button
|
|
345
|
-
class={
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
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
|
-
{
|
|
434
|
+
{#if text.html}{@html sanitizeHtml(value)}{:else}{value}{/if}
|
|
353
435
|
</button>
|
|
354
|
-
{
|
|
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
|
-
|
|
357
|
-
|
|
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
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
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
|
-
|
|
447
|
-
|
|
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>
|
|
@@ -96,12 +96,14 @@
|
|
|
96
96
|
>
|
|
97
97
|
<!-- Заголовок -->
|
|
98
98
|
<WidgetHeader icon={CpuIcon} label={label?.name || $T("widget.info.title")} bind:collapsed {hints}>
|
|
99
|
-
{#snippet right()}
|
|
99
|
+
{#snippet right(narrow: boolean)}
|
|
100
100
|
<div use:hint={{ text: $T("widget.info.hint.restart"), enabled: $hints }}>
|
|
101
101
|
<UI.Button
|
|
102
102
|
wrapperClass="w-auto"
|
|
103
103
|
componentClass="px-3"
|
|
104
|
-
content={
|
|
104
|
+
content={narrow
|
|
105
|
+
? { icon: RestartIcon, info: { text: $T("widget.info.restart"), side: "left" } }
|
|
106
|
+
: { icon: RestartIcon, name: $T("widget.info.restart") }}
|
|
105
107
|
disabled={!onRestart}
|
|
106
108
|
onClick={() => onRestart?.()}
|
|
107
109
|
/>
|
|
@@ -140,11 +140,13 @@
|
|
|
140
140
|
>
|
|
141
141
|
<!-- Заголовок -->
|
|
142
142
|
<WidgetHeader icon={StorageIcon} label={label?.name || $T("widget.fs.title")} bind:collapsed {hints}>
|
|
143
|
-
{#snippet right()}
|
|
143
|
+
{#snippet right(narrow: boolean)}
|
|
144
144
|
<UI.Button
|
|
145
145
|
wrapperClass="w-auto"
|
|
146
146
|
componentClass="px-3"
|
|
147
|
-
content={
|
|
147
|
+
content={narrow
|
|
148
|
+
? { icon: RefreshIcon, info: { text: $T("widget.common.refresh"), side: "left" } }
|
|
149
|
+
: { icon: RefreshIcon, name: $T("widget.common.refresh") }}
|
|
148
150
|
disabled={!onRefresh}
|
|
149
151
|
onClick={() => onRefresh?.()}
|
|
150
152
|
/>
|
package/dist/WidgetHeader.svelte
CHANGED
|
@@ -15,17 +15,20 @@
|
|
|
15
15
|
icon: Component
|
|
16
16
|
label: string
|
|
17
17
|
collapsed?: boolean
|
|
18
|
-
|
|
18
|
+
/* Правая часть; narrow - шапка узкая: кнопки только значком, списки сжаты, чтобы всё стояло в одной строке */
|
|
19
|
+
right?: Snippet<[boolean]>
|
|
19
20
|
/* Настройка подсказок этого виджета (hintsSetting) - показывает кнопку «?», переключающую только его подсказки */
|
|
20
21
|
hints?: Writable<boolean>
|
|
21
22
|
} = $props()
|
|
22
23
|
|
|
23
24
|
const Icon = $derived(icon)
|
|
24
25
|
|
|
25
|
-
/*
|
|
26
|
-
const
|
|
26
|
+
/* Уже NARROW_PX шапка сжимает правую часть; если и сжатая не помещается рядом с заголовком (место под значок, заголовок и «?»), она уходит второй строкой */
|
|
27
|
+
const NARROW_PX = 640
|
|
28
|
+
const TITLE_MIN_PX = 120
|
|
27
29
|
let headerWidth = $state(0)
|
|
28
30
|
let rightWidth = $state(0)
|
|
31
|
+
let narrow = $derived(headerWidth > 0 && headerWidth < NARROW_PX)
|
|
29
32
|
let wrapped = $derived(!!right && headerWidth > 0 && rightWidth + TITLE_MIN_PX + (hints ? 34 : 0) > headerWidth)
|
|
30
33
|
</script>
|
|
31
34
|
|
|
@@ -51,7 +54,7 @@
|
|
|
51
54
|
</button>
|
|
52
55
|
{#if right && !wrapped}
|
|
53
56
|
<div class="flex w-max shrink-0 items-center justify-end" bind:clientWidth={rightWidth}>
|
|
54
|
-
{@render right()}
|
|
57
|
+
{@render right(narrow)}
|
|
55
58
|
</div>
|
|
56
59
|
{/if}
|
|
57
60
|
{#if hints}
|
|
@@ -68,9 +71,9 @@
|
|
|
68
71
|
{/if}
|
|
69
72
|
</div>
|
|
70
73
|
{#if right && wrapped}
|
|
71
|
-
<!-- Во второй строке элементы могут переноситься;
|
|
72
|
-
<div class="flex max-w-full flex-wrap items-center justify-end gap-2">
|
|
73
|
-
{@render right()}
|
|
74
|
+
<!-- Во второй строке элементы могут переноситься; ширина замеряется и здесь - сжатая часть возвращается в первую строку -->
|
|
75
|
+
<div class="flex w-max max-w-full flex-wrap items-center justify-end gap-2 self-end" bind:clientWidth={rightWidth}>
|
|
76
|
+
{@render right(narrow)}
|
|
74
77
|
</div>
|
|
75
78
|
{/if}
|
|
76
79
|
</div>
|
|
@@ -248,6 +248,8 @@
|
|
|
248
248
|
|
|
249
249
|
/* Тема карты - по ближайшему предку .dark/.light (как у токенов theme.css): работает и внутри блока с другой темой, смена темы отслеживается */
|
|
250
250
|
let rootEl: HTMLDivElement | undefined = $state()
|
|
251
|
+
/* Ширина карты: панель оператора поверх неё не заходит под кнопки справа */
|
|
252
|
+
let mapWidth = $state(0)
|
|
251
253
|
const theme = themeState(
|
|
252
254
|
() => rootEl,
|
|
253
255
|
() => rootStyle,
|
|
@@ -442,12 +444,12 @@
|
|
|
442
444
|
style={rootStyle}
|
|
443
445
|
>
|
|
444
446
|
<WidgetHeader icon={MapIcon} label={label?.name || $T("widget.map.title")} bind:collapsed {hints}>
|
|
445
|
-
{#snippet right()}
|
|
447
|
+
{#snippet right(narrow: boolean)}
|
|
446
448
|
<div class="flex items-center gap-3">
|
|
447
449
|
<Button
|
|
448
450
|
wrapperClass="w-auto"
|
|
449
451
|
componentClass="px-3"
|
|
450
|
-
content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.map.fitAllHint"), side: "bottom" } }}
|
|
452
|
+
content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.map.fitAllHint"), side: "bottom" } }}
|
|
451
453
|
disabled={collapsed || visibleBoards.length === 0}
|
|
452
454
|
onClick={fitAllBoards}
|
|
453
455
|
/>
|
|
@@ -466,7 +468,7 @@
|
|
|
466
468
|
</WidgetHeader>
|
|
467
469
|
|
|
468
470
|
{#if !collapsed}
|
|
469
|
-
<div transition:slide={{ duration: 150 }} style="height: {height}px">
|
|
471
|
+
<div transition:slide={{ duration: 150 }} style="height: {height}px" bind:clientWidth={mapWidth}>
|
|
470
472
|
<MapLibre
|
|
471
473
|
bind:map={mapInstance}
|
|
472
474
|
class="h-full w-full overflow-hidden rounded-[14px] border border-(--hairline-color)"
|
|
@@ -483,7 +485,11 @@
|
|
|
483
485
|
|
|
484
486
|
<!-- Панель оператора поверх карты -->
|
|
485
487
|
<CustomControl position="top-left">
|
|
486
|
-
|
|
488
|
+
<!-- Не шире карты без колонки кнопок справа: на узкой карте пункты переносятся -->
|
|
489
|
+
<div
|
|
490
|
+
class="flex flex-wrap items-center gap-x-3 gap-y-1 rounded-lg px-2 py-1 text-(--font-color)"
|
|
491
|
+
style="max-width: {Math.max(mapWidth - 72, 120)}px"
|
|
492
|
+
>
|
|
487
493
|
<label class="flex items-center gap-1.5 text-sm font-medium" use:hint={{ text: $T("widget.map.hint.track"), enabled: $hints }}>
|
|
488
494
|
<input type="checkbox" bind:checked={trackEnabled} />
|
|
489
495
|
{$T("constructor.props.map.track")}
|
|
@@ -425,26 +425,27 @@
|
|
|
425
425
|
style={rootStyle}
|
|
426
426
|
>
|
|
427
427
|
<WidgetHeader icon={MissionIcon} label={label?.name || $T("widget.mission.title")} bind:collapsed {hints}>
|
|
428
|
-
{#snippet right()}
|
|
428
|
+
{#snippet right(narrow: boolean)}
|
|
429
|
+
<!-- На узкой шапке: кнопка значком, во время полёта - только процент, иначе - сводка -->
|
|
429
430
|
<div class="flex items-center gap-3">
|
|
430
431
|
<Button
|
|
431
432
|
wrapperClass="w-auto"
|
|
432
433
|
componentClass="px-3"
|
|
433
|
-
content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.mission.fitHint"), side: "bottom" } }}
|
|
434
|
+
content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.mission.fitHint"), side: "bottom" } }}
|
|
434
435
|
disabled={collapsed || missionPoints().length === 0}
|
|
435
436
|
onClick={() => fitAll()}
|
|
436
437
|
/>
|
|
437
438
|
<span class="flex items-center gap-3 text-[12px] font-semibold text-(--muted-color) tabular-nums">
|
|
438
439
|
{#if headerProgress !== null}
|
|
439
440
|
<span class="flex items-center gap-1.5" title={simulate ? $T("widget.sim.title") : $T("widget.mission.progressHint")}>
|
|
440
|
-
<span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color)"
|
|
441
|
+
<span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color) {narrow ? 'hidden' : ''}"
|
|
441
442
|
><span class="block h-full rounded-full bg-(--accent-color)" style="width: {Math.round(headerProgress * 100)}%"></span></span
|
|
442
443
|
>
|
|
443
|
-
{Math.round(headerProgress * 100)}%{#if live}
|
|
444
|
+
{Math.round(headerProgress * 100)}%{#if live && !narrow}
|
|
444
445
|
· {$T("widget.mission.treated")} {fmt(treatedHa, 2)} {$T("widget.mission.ha")}{/if}
|
|
445
446
|
</span>
|
|
446
447
|
{/if}
|
|
447
|
-
{#if stats}
|
|
448
|
+
{#if stats && (!narrow || headerProgress === null)}
|
|
448
449
|
<span class="text-[12px] font-semibold text-(--muted-color) tabular-nums"
|
|
449
450
|
>{fmt(stats.ha, 2)} {$T("widget.mission.ha")} · {fmt(stats.total, 2)} {$T("widget.mission.km")}</span
|
|
450
451
|
>
|
|
@@ -222,22 +222,23 @@
|
|
|
222
222
|
style={rootStyle}
|
|
223
223
|
>
|
|
224
224
|
<WidgetHeader icon={MapIcon} label={label?.name || $T("widget.route.title")} bind:collapsed {hints}>
|
|
225
|
-
{#snippet right()}
|
|
225
|
+
{#snippet right(narrow: boolean)}
|
|
226
|
+
<!-- На узкой шапке: кнопка значком, во время полёта - только процент, иначе - сводка -->
|
|
226
227
|
<div class="flex items-center gap-3">
|
|
227
228
|
<Button
|
|
228
229
|
wrapperClass="w-auto"
|
|
229
230
|
componentClass="px-3"
|
|
230
|
-
content={{ icon: FitIcon, name: $T("widget.map.fitAll"), info: { text: $T("widget.route.fitHint"), side: "bottom" } }}
|
|
231
|
+
content={{ icon: FitIcon, name: narrow ? undefined : $T("widget.map.fitAll"), info: { text: $T("widget.route.fitHint"), side: "bottom" } }}
|
|
231
232
|
disabled={collapsed || missionPoints().length === 0}
|
|
232
233
|
onClick={() => fitAll()}
|
|
233
234
|
/>
|
|
234
235
|
<span class="flex items-center gap-3 text-[12px] font-semibold text-(--muted-color) tabular-nums">
|
|
235
236
|
{#if headerProgress !== null}
|
|
236
237
|
<span class="flex items-center gap-1.5" title={simulate ? $T("widget.sim.title") : $T("widget.mission.progressHint")}>
|
|
237
|
-
<span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color)"
|
|
238
|
+
<span class="h-1.5 w-14 overflow-hidden rounded-full bg-(--hairline-color) {narrow ? 'hidden' : ''}"
|
|
238
239
|
><span class="block h-full rounded-full bg-(--accent-color)" style="width: {Math.round(headerProgress * 100)}%"></span></span
|
|
239
240
|
>
|
|
240
|
-
{Math.round(headerProgress * 100)}%{#if live}
|
|
241
|
+
{Math.round(headerProgress * 100)}%{#if live && !narrow}
|
|
241
242
|
· {live.finished
|
|
242
243
|
? $T("widget.route.finished")
|
|
243
244
|
: live.target > route.points.length
|
|
@@ -245,7 +246,9 @@
|
|
|
245
246
|
: `${$T("widget.route.toPoint")} ${live.target}/${route.points.length}`}{/if}
|
|
246
247
|
</span>
|
|
247
248
|
{/if}
|
|
248
|
-
|
|
249
|
+
{#if !narrow || headerProgress === null}
|
|
250
|
+
<span>{stats.points} {$T("widget.route.pts")} · {km(stats.length)}</span>
|
|
251
|
+
{/if}
|
|
249
252
|
</span>
|
|
250
253
|
</div>
|
|
251
254
|
{/snippet}
|
|
@@ -50,15 +50,23 @@
|
|
|
50
50
|
let off = $derived(disabled || !text)
|
|
51
51
|
</script>
|
|
52
52
|
|
|
53
|
-
|
|
53
|
+
<!-- Три кнопки в ряд, на узком месте переносятся -->
|
|
54
|
+
<div class="grid grid-cols-[repeat(auto-fit,minmax(6.5rem,1fr))] gap-3">
|
|
54
55
|
<div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.download"), enabled: hints }}>
|
|
55
|
-
<Button variant="primary" content={{ name: $T("widget.mission.download") }} disabled={off} onClick={download} />
|
|
56
|
+
<Button componentClass="px-2" variant="primary" content={{ name: $T("widget.mission.download") }} disabled={off} onClick={download} />
|
|
56
57
|
</div>
|
|
57
58
|
<div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.copy"), enabled: hints }}>
|
|
58
|
-
<Button
|
|
59
|
+
<Button
|
|
60
|
+
componentClass="px-2"
|
|
61
|
+
variant="primary"
|
|
62
|
+
content={{ name: $T(copied ? "widget.mission.copied" : "widget.mission.copy") }}
|
|
63
|
+
disabled={off}
|
|
64
|
+
onClick={copy}
|
|
65
|
+
/>
|
|
59
66
|
</div>
|
|
60
67
|
<div class="min-w-0" use:hint={{ text: $T("widget.mission.hint.send"), enabled: hints }}>
|
|
61
68
|
<Button
|
|
69
|
+
componentClass="px-2"
|
|
62
70
|
variant="primary"
|
|
63
71
|
accent={sendState === "error" ? "red" : undefined}
|
|
64
72
|
content={{ name: $T(`widget.mission.send.${sendState}`) }}
|
|
@@ -138,13 +138,23 @@
|
|
|
138
138
|
>
|
|
139
139
|
<!-- Заголовок -->
|
|
140
140
|
<WidgetHeader icon={MemoryIcon} label={label?.name || $T("widget.stack.title")} bind:collapsed {hints}>
|
|
141
|
-
{#snippet right()}
|
|
141
|
+
{#snippet right(narrow: boolean)}
|
|
142
142
|
<div class="flex flex-wrap items-center justify-end gap-2" use:hint={{ text: $T("widget.stack.hint.poll"), enabled: $hints }}>
|
|
143
|
-
|
|
143
|
+
<!-- На узком - список вместо ряда кнопок и кнопка значком -->
|
|
144
|
+
<UI.Select
|
|
145
|
+
wrapperClass={narrow ? "w-28" : "w-64"}
|
|
146
|
+
type="buttons"
|
|
147
|
+
options={periods}
|
|
148
|
+
value={period}
|
|
149
|
+
disabled={!onRefresh}
|
|
150
|
+
onUpdate={(value) => (period = value)}
|
|
151
|
+
/>
|
|
144
152
|
<UI.Button
|
|
145
153
|
wrapperClass="w-auto"
|
|
146
154
|
componentClass="px-3"
|
|
147
|
-
content={
|
|
155
|
+
content={narrow
|
|
156
|
+
? { icon: RefreshIcon, info: { text: $T("widget.common.refresh"), side: "left" } }
|
|
157
|
+
: { icon: RefreshIcon, name: $T("widget.common.refresh") }}
|
|
148
158
|
disabled={!onRefresh}
|
|
149
159
|
onClick={() => onRefresh?.()}
|
|
150
160
|
/>
|
|
@@ -128,8 +128,8 @@
|
|
|
128
128
|
>
|
|
129
129
|
<!-- Заголовок и переключатель режима -->
|
|
130
130
|
<WidgetHeader icon={WifiIcon} label={label?.name || $T("widget.wifi.title")} bind:collapsed {hints}>
|
|
131
|
-
{#snippet right()}
|
|
132
|
-
<div class="w-
|
|
131
|
+
{#snippet right(narrow: boolean)}
|
|
132
|
+
<div class={narrow ? "w-36" : "w-72"} use:hint={{ text: $T("widget.wifi.hint.mode"), enabled: $hints }}>
|
|
133
133
|
<UI.Select
|
|
134
134
|
wrapperClass="w-full"
|
|
135
135
|
type="buttons"
|
|
@@ -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: "图标" },
|