poe-svelte-ui-lib 2.14.1 → 2.15.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/README.md +1 -0
- package/dist/FileAttach/FileAttach.svelte +2 -1
- package/dist/FileAttach/README.md +1 -0
- package/dist/GUIRenderer/GUIRenderer.svelte +12 -0
- package/dist/Input/Input.svelte +3 -34
- package/dist/Input/README.md +2 -2
- package/dist/Table/README.md +9 -9
- package/dist/Table/Table.svelte +15 -13
- package/dist/Table/TableProps.svelte +25 -0
- package/dist/Tooltip.svelte +8 -33
- package/dist/Tooltip.svelte.d.ts +0 -1
- package/dist/WidgetLoRa/README.md +43 -0
- package/dist/WidgetLoRa/RadioIcon.svelte +12 -0
- package/dist/WidgetLoRa/RadioIcon.svelte.d.ts +18 -0
- package/dist/WidgetLoRa/WidgetLoRa.svelte +123 -0
- package/dist/WidgetLoRa/WidgetLoRa.svelte.d.ts +4 -0
- package/dist/WidgetLoRa/WidgetLoRaProps.svelte +184 -0
- package/dist/WidgetLoRa/WidgetLoRaProps.svelte.d.ts +9 -0
- package/dist/WidgetLoRa/lora.d.ts +29 -0
- package/dist/WidgetLoRa/lora.js +89 -0
- package/dist/constructor.d.ts +2 -1
- package/dist/constructor.js +3 -1
- package/dist/defaults.js +4 -1
- package/dist/dictionaries/components.yaml +1 -0
- package/dist/dictionaries/generated/components.d.ts +2 -1
- package/dist/dictionaries/generated/components.js +2 -1
- package/dist/guiViews.d.ts +2 -0
- package/dist/guiViews.js +2 -0
- package/dist/index.d.ts +3 -1
- package/dist/index.js +2 -0
- package/dist/locales/constructor.d.ts +15 -0
- package/dist/locales/constructor.js +7 -0
- package/dist/locales/i18n.js +1 -0
- package/dist/locales/translations.d.ts +210 -0
- package/dist/locales/translations.js +106 -0
- package/dist/registry.js +2 -0
- package/dist/types.d.ts +24 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -28,6 +28,7 @@
|
|
|
28
28
|
|
|
29
29
|
- 📶 `WidgetWiFi` - режим сети, подключение к точке доступа, своя точка доступа, поиск сетей.
|
|
30
30
|
- 🪪 `WidgetDeviceInfo` - паспорт устройства, основные настройки, перезагрузка.
|
|
31
|
+
- 📡 `WidgetLoRa` - настройки радио LoRa любой микросхемы: где лежит каждый параметр, задаётся в конструкторе.
|
|
31
32
|
- 🗂️ `WidgetFileSystem` - занятая память, список файлов, загрузка и удаление.
|
|
32
33
|
- 🧠 `WidgetStackInfo` - свободная память и запас стека задач, для отладки.
|
|
33
34
|
- 🌈 `WidgetRGBStrip` - адресная светодиодная лента: цвет, эффекты, параметры.
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
disabled = false,
|
|
21
21
|
currentImage = $bindable(""),
|
|
22
22
|
info,
|
|
23
|
+
help,
|
|
23
24
|
icon,
|
|
24
25
|
caption = "",
|
|
25
26
|
onUpdate,
|
|
@@ -52,7 +53,7 @@
|
|
|
52
53
|
|
|
53
54
|
<!-- По design-handoff (раздел 9): зона сброса - пунктир 1 px с радиусом 12 вместо залитой кнопки, высота как у Input; «Выбрать файл» - акцентный текст, имя файла - обычным цветом, пока не выбрано - бледным. -->
|
|
54
55
|
<div class={twMerge(`flex flex-col items-center gap-1`, wrapperClass)}>
|
|
55
|
-
<FieldLabel {label} for={uid} class="w-full" />
|
|
56
|
+
<FieldLabel {label} info={help?.info} for={uid} class="w-full" />
|
|
56
57
|
|
|
57
58
|
{#if type === "button"}
|
|
58
59
|
<!-- Иконочная кнопка с подсказкой, как UI.Button; выбор файла - скрытый input за ней -->
|
|
@@ -72,6 +72,7 @@
|
|
|
72
72
|
| `imageSize` | `{ height, width, fitMode, form }` | `10rem`, `10rem`, `cover`, `square` | Размер превью, масштабирование (`cover`, `contain`) и форма (`square`, `circle`) |
|
|
73
73
|
| `currentImage` | `string \| null` | `""` | Текущая картинка: data-URL или base64. Можно связать через `bind:` |
|
|
74
74
|
| `info` | `{ text, side }` | | Только `button`: подсказка, как у `Button` |
|
|
75
|
+
| `help.info` | `string` | | Значок ⓘ после подписи с пояснением, как у `Input`; без подписи - на её месте |
|
|
75
76
|
| `icon` | `Component \| string` | документ со стрелкой | Только `button`: своя иконка |
|
|
76
77
|
| `disabled` | `boolean` | `false` | Неактивен |
|
|
77
78
|
| `onUpdate` | `(value, event) => void` | | Выбор: `File`, при `multiple` - `File[]`. При отмене окна выбора не вызывается |
|
|
@@ -27,6 +27,7 @@
|
|
|
27
27
|
type DeviceLink,
|
|
28
28
|
type DevicePacket,
|
|
29
29
|
} from "../gui"
|
|
30
|
+
import { loraKeys } from "../WidgetLoRa/lora"
|
|
30
31
|
import { COMPONENT_META } from "../componentMeta"
|
|
31
32
|
import DeviceTable from "./DeviceTable.svelte"
|
|
32
33
|
import type { GuiViews } from "../guiViews"
|
|
@@ -422,6 +423,17 @@
|
|
|
422
423
|
onRestart={locked ? undefined : () => send(props.restartCommand?.header || "SET", props.restartCommand?.argument || "Restart", {})}
|
|
423
424
|
onFactoryReset={locked ? undefined : () => send(props.resetCommand?.header || "SET", props.resetCommand?.argument || "RstNVS", {})}
|
|
424
425
|
/>
|
|
426
|
+
{:else if component.type === "WidgetLoRa" && views.WidgetLoRa}
|
|
427
|
+
{@const WidgetLoRa = views.WidgetLoRa}
|
|
428
|
+
{@const props = component.properties}
|
|
429
|
+
{@const prefix = props.id || "LORA"}
|
|
430
|
+
{@const keys = loraKeys(props.params ?? {})}
|
|
431
|
+
<WidgetLoRa
|
|
432
|
+
{...props}
|
|
433
|
+
value={stable(`${component.id}|${prefix}`, Object.fromEntries(keys.map((key) => [key, get(widgetKey(prefix, key))])))}
|
|
434
|
+
persistKey={persist(component)}
|
|
435
|
+
onSave={locked ? undefined : (values) => saveFields(prefix, Object.keys(values), values)}
|
|
436
|
+
/>
|
|
425
437
|
{:else if component.type === "WidgetFileSystem" && views.WidgetFileSystem}
|
|
426
438
|
{@const WidgetFileSystem = views.WidgetFileSystem}
|
|
427
439
|
{@const props = component.properties}
|
package/dist/Input/Input.svelte
CHANGED
|
@@ -6,10 +6,7 @@
|
|
|
6
6
|
import { twMerge } from "tailwind-merge"
|
|
7
7
|
import { accentStyle } from "../accent"
|
|
8
8
|
import { copyText } from "../clipboard"
|
|
9
|
-
import InfoIcon from "../libIcons/InfoIcon.svelte"
|
|
10
9
|
import CopyIcon from "../libIcons/CopyIcon.svelte"
|
|
11
|
-
import Tooltip from "../Tooltip.svelte"
|
|
12
|
-
import { isHoverPointer, isKeyboardFocus } from "../popup"
|
|
13
10
|
import CopiedChip from "../CopiedChip.svelte"
|
|
14
11
|
import FieldLabel from "../FieldLabel.svelte"
|
|
15
12
|
|
|
@@ -37,10 +34,6 @@
|
|
|
37
34
|
|
|
38
35
|
const uid = $props.id()
|
|
39
36
|
let showPassword = $state(false)
|
|
40
|
-
let showInfo = $state(false)
|
|
41
|
-
/* Последнее нажатие на ⓘ - пальцем: тогда пояснение открывает и закрывает касание */
|
|
42
|
-
let infoTouch = false
|
|
43
|
-
let infoButton: HTMLButtonElement | null = $state(null)
|
|
44
37
|
let isCopied = $state(false)
|
|
45
38
|
|
|
46
39
|
const isNumeric = $derived(type === "number" || type === "bitMode")
|
|
@@ -102,22 +95,19 @@
|
|
|
102
95
|
${accent && !disabled && !readonly ? "bg-[color-mix(in_srgb,var(--accent-color)_7%,var(--field-color))]" : ""}
|
|
103
96
|
${!errorText ? `${accent ? "border-[color-mix(in_srgb,var(--accent-color)_55%,var(--border-color))]" : "border-(--border-color)"} focus:border-(--accent-text) focus:shadow-(--focus-shadow-color)` : "border-(--red-text) focus:border-(--red-text) focus:shadow-[0_0_0_3px_color-mix(in_srgb,var(--red-color),transparent_80%)]"}
|
|
104
97
|
${disabled ? "cursor-not-allowed border-(--hairline-color) bg-(--container-color) text-(--faint-color)" : ""}
|
|
105
|
-
${readonly && !disabled ? "bg-(--container-color) text-(--muted-color)" : ""}
|
|
106
|
-
${help.info ? "pl-9" : ""}`,
|
|
98
|
+
${readonly && !disabled ? "bg-(--container-color) text-(--muted-color)" : ""}`,
|
|
107
99
|
)
|
|
108
100
|
/* Кнопка-значок внутри поля: у глазика пароля фон при наведении не появляется, меняется только цвет значка */
|
|
109
101
|
const iconButton = `flex size-7 cursor-pointer items-center justify-center rounded-lg border-none bg-transparent text-(--faint-color) transition-colors duration-150 hover:text-(--font-color)`
|
|
110
102
|
</script>
|
|
111
103
|
|
|
112
|
-
<!-- На телефоне пояснение ⓘ закрывается касанием в любом другом месте -->
|
|
113
|
-
<svelte:window onpointerdown={(event) => showInfo && !infoButton?.contains(event.target as Node) && (showInfo = false)} />
|
|
114
|
-
|
|
115
104
|
<!-- fill: подпись, поле и ошибка - колонка на всю высоту родителя, поле занимает всё, что осталось -->
|
|
116
105
|
<div
|
|
117
106
|
class={twMerge(`relative flex w-full flex-col gap-1 ${type === "text-area" ? "h-full" : ""} ${fill ? "min-h-0 flex-1" : ""}`, wrapperClass)}
|
|
118
107
|
style={accentStyle(accent)}
|
|
119
108
|
>
|
|
120
|
-
|
|
109
|
+
<!-- ⓘ пояснения - после подписи, как у Select и Switch: всплывает от окна (InfoHint) и не обрезается краем; без подписи значок стоит на её месте -->
|
|
110
|
+
<FieldLabel {label} info={help.info} for={uid} class={fill ? "shrink-0" : ""} />
|
|
121
111
|
|
|
122
112
|
<div class="relative flex w-full {fill ? 'min-h-0 flex-1 flex-col' : type === 'text-area' ? 'h-full items-center' : 'items-center'}">
|
|
123
113
|
{#if type === "text-area"}
|
|
@@ -216,27 +206,6 @@
|
|
|
216
206
|
{/each}
|
|
217
207
|
</div>
|
|
218
208
|
{/if}
|
|
219
|
-
|
|
220
|
-
{#if help.info}
|
|
221
|
-
<button
|
|
222
|
-
bind:this={infoButton}
|
|
223
|
-
type="button"
|
|
224
|
-
class="absolute left-2 flex size-(--icon-size) items-center justify-center border-none bg-transparent text-(--faint-color) [&_svg]:size-full {type ===
|
|
225
|
-
'text-area'
|
|
226
|
-
? 'top-2'
|
|
227
|
-
: ''} {disabled ? 'opacity-50' : 'cursor-pointer hover:text-(--accent-text)'}"
|
|
228
|
-
onpointerdown={(event) => (infoTouch = !isHoverPointer(event))}
|
|
229
|
-
onclick={() => infoTouch && (showInfo = !showInfo)}
|
|
230
|
-
onpointerenter={(event) => isHoverPointer(event) && (showInfo = true)}
|
|
231
|
-
onpointerleave={(event) => isHoverPointer(event) && (showInfo = false)}
|
|
232
|
-
onfocus={(event) => (showInfo = isKeyboardFocus(event))}
|
|
233
|
-
onblur={() => (showInfo = false)}
|
|
234
|
-
aria-label={help.info}
|
|
235
|
-
>
|
|
236
|
-
<InfoIcon />
|
|
237
|
-
</button>
|
|
238
|
-
<Tooltip show={showInfo} text={help.info} side="top" align="start" />
|
|
239
|
-
{/if}
|
|
240
209
|
</div>
|
|
241
210
|
|
|
242
211
|
{#if errorText}
|
package/dist/Input/README.md
CHANGED
|
@@ -71,7 +71,7 @@
|
|
|
71
71
|
- Стрелки есть у `number` и `bitMode`, кроме `readonly` и `disabled`. Пустое значение стрелка сначала ставит в `minNum`. Шаг за предел ставит ровно предел.
|
|
72
72
|
- Числа округляются до 5 знаков после запятой, чтобы не было хвостов вида `0.30000000000000004`.
|
|
73
73
|
- `readonly` превращает поле в отображение значения. Кнопка копирования (`help.copyButton`) работает у любого поля, кроме пароля и неактивного.
|
|
74
|
-
- Подсказка `help.info` - значок ⓘ
|
|
74
|
+
- Подсказка `help.info` - значок ⓘ после заголовка, как у `Select` и `Switch`. Текст всплывает при наведении мышью и при фокусе с клавиатуры, на телефоне - по касанию значка, закрывается касанием в другом месте. Подсказка не выходит за край окна. Без заголовка значок стоит на его месте. Показывает только текст, без разметки.
|
|
75
75
|
- `error` - ошибка от приложения (например, ответ сервера «логин занят»). Рамка красная, текст под полем, у поля `aria-invalid` и `aria-describedby` на текст ошибки (`role="alert"`, диктор зачитает его при появлении). Ошибка приложения важнее ошибки формата.
|
|
76
76
|
- `autofocus` ставит фокус после появления поля (атрибут браузера сработал бы только при загрузке страницы). Фокус извне: `bind:this={field}`, затем `field.focus()`. Сам элемент поля - `bind:ref`.
|
|
77
77
|
- `fill` для `text-area`: обёртка, заголовок, поле и ошибка - колонка на всю высоту родителя, поле забирает остаток высоты, ручка растягивания убрана. Родитель - flex-колонка или блок с высотой. Поле сжимается вместе с родителем (`min-h-0`) и не вылезает за его рамку, даже если родитель ниже обычных 5rem.
|
|
@@ -100,7 +100,7 @@
|
|
|
100
100
|
| `number.minNum`, `number.maxNum` | `number` | `-1000000`, `1000000` | Пределы числа |
|
|
101
101
|
| `number.step` | `number` | `1` | Шаг стрелок |
|
|
102
102
|
| `range` | `{ start, end }` | | Биты битового поля, только для панели свойств и облака |
|
|
103
|
-
| `help.info` | `string` | `""` | Подсказка: значок ⓘ
|
|
103
|
+
| `help.info` | `string` | `""` | Подсказка: значок ⓘ после заголовка, без заголовка - на его месте |
|
|
104
104
|
| `help.copyButton` | `boolean` | `false` | Кнопка копирования |
|
|
105
105
|
| `help.regExp` | `string \| RegExp` | | Проверка ввода. Готовые выражения на вкладке «Регулярные выражения» витрины |
|
|
106
106
|
| `help.autocomplete` | `string \| null` | `"off"` | Атрибут `autocomplete` браузера: `username`, `new-password`, `email` и другие |
|
package/dist/Table/README.md
CHANGED
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
## ✨ Что умеет
|
|
6
6
|
|
|
7
7
|
- 📄 Показывает список строк, которые прислало устройство: одна строка на запись.
|
|
8
|
-
- 🔘 В ячейке может стоять кнопка: таблица сообщает приложению, какая кнопка нажата и в какой строке, команду отправляет приложение.
|
|
8
|
+
- 🔘 В ячейке может стоять кнопка: таблица сообщает приложению, какая кнопка нажата и в какой строке, команду отправляет приложение. При нажатии кнопка слегка сжимается и темнеет, как обычная `Button`.
|
|
9
9
|
- ⋯ В ячейке может стоять меню действий строки (кнопка «⋯» и пункты `Dropdown`), например «Изменить» и красное «Удалить».
|
|
10
10
|
- 🔽 Можно выбрать значение из списка прямо в ячейке.
|
|
11
11
|
- 📊 Число можно показать полосой прогресса с единицами измерения.
|
|
@@ -135,14 +135,14 @@
|
|
|
135
135
|
|
|
136
136
|
### Содержимое ячейки `ITableContent`
|
|
137
137
|
|
|
138
|
-
| `type` | Поля `data`
|
|
139
|
-
| ------------- |
|
|
140
|
-
| `text` | `key`, `render(row)`, `href(row)`, `html`, `sortable`, `truncated`, `tooltip` (`true` или функция от строки), `copy`, `modal` (`true` или сниппет), `accent(row)`, `badge`, `onClick(row)`
|
|
141
|
-
| `button` | `name`, `icon`, `title`, `class` (строки или функции от строки), `eventHandler`, `onClick(row)
|
|
142
|
-
| `select` | `key` (массив вариантов в строке), `keyCol`, `onChange`
|
|
143
|
-
| `menu` | `items(row)` - пункты `Dropdown` для строки, `icon` (по умолчанию «⋯», `IconMore`), `title`. Только из кода приложения, в конструкторе нет; удаление - пункт с `accent: "red"`
|
|
144
|
-
| `progressBar` | `key`, `minNum`, `maxNum`, `units`
|
|
145
|
-
| `image` | `src` (строка или функция), `alt`, `class`, `width`, `height`, `defaultIcon`
|
|
138
|
+
| `type` | Поля `data` |
|
|
139
|
+
| ------------- | -------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
|
|
140
|
+
| `text` | `key`, `render(row)`, `href(row)`, `html`, `sortable`, `truncated`, `tooltip` (`true` или функция от строки), `copy`, `modal` (`true` или сниппет), `accent(row)`, `badge`, `onClick(row)` |
|
|
141
|
+
| `button` | `name`, `icon`, `title`, `class` (строки или функции от строки), `eventHandler`, `onClick(row)`, `hideIf: { key, value }` - не показывать в строке, где `row[key]` равно `value` (строками; в панели «Скрыть, если ключ»). У кнопки-иконки без `name` обязательно `title`. Весь `data` может быть функцией от строки |
|
|
142
|
+
| `select` | `key` (массив вариантов в строке), `keyCol`, `onChange` |
|
|
143
|
+
| `menu` | `items(row)` - пункты `Dropdown` для строки, `icon` (по умолчанию «⋯», `IconMore`), `title`. Только из кода приложения, в конструкторе нет; удаление - пункт с `accent: "red"` |
|
|
144
|
+
| `progressBar` | `key`, `minNum`, `maxNum`, `units` |
|
|
145
|
+
| `image` | `src` (строка или функция), `alt`, `class`, `width`, `height`, `defaultIcon` |
|
|
146
146
|
|
|
147
147
|
Выпадающий список ячейки: `key` указывает на массив вариантов `{ id, name, value }` в строке, а выбранное значение - в поле с тем же именем без суффикса `-S` (`Mode-S` - варианты, `Mode` - значение). Выбор хранится в таблице поверх строки до следующего `body` и приходит в `onClick`. `keyCol` - ключ колонки с серийным номером модуля (пусто - серийный номер изделия), его читает облако, а не сама таблица.
|
|
148
148
|
|
package/dist/Table/Table.svelte
CHANGED
|
@@ -228,7 +228,7 @@
|
|
|
228
228
|
const classes = cls.split(" ")
|
|
229
229
|
const transparent = classes.includes("bg-transparent") || !classes.some((c) => c.startsWith("bg-"))
|
|
230
230
|
return twMerge(
|
|
231
|
-
"flex h-7 w-full cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 text-[13px] font-semibold transition-
|
|
231
|
+
"flex h-7 w-full cursor-pointer items-center justify-center gap-1.5 rounded-lg px-3 text-[13px] font-semibold transition-[color,background-color,filter,scale] duration-150 outline-none select-none focus-visible:outline-2 focus-visible:outline-offset-2 focus-visible:outline-(--accent-text) active:scale-[0.97] active:brightness-85",
|
|
232
232
|
transparent
|
|
233
233
|
? "bg-transparent text-(--accent-text) hover:bg-(--accent-soft)"
|
|
234
234
|
: "border border-transparent text-(--on-accent) hover:brightness-90 dark:hover:brightness-115",
|
|
@@ -377,18 +377,20 @@
|
|
|
377
377
|
{#if content.type === "button"}
|
|
378
378
|
{@const button = resolve(content.data, row)}
|
|
379
379
|
{@const title = resolve(button.title, row)}
|
|
380
|
-
|
|
381
|
-
{
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
{
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
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}
|
|
392
394
|
{:else if content.type === "menu"}
|
|
393
395
|
<Dropdown
|
|
394
396
|
align="end"
|
|
@@ -395,6 +395,31 @@
|
|
|
395
395
|
}}
|
|
396
396
|
/>
|
|
397
397
|
</div>
|
|
398
|
+
<div class="flex flex-wrap items-end gap-2">
|
|
399
|
+
<UI.Input
|
|
400
|
+
wrapperClass="min-w-28 flex-1"
|
|
401
|
+
label={{ name: $T("constructor.props.table.hideIf.key") }}
|
|
402
|
+
value={button.hideIf?.key ?? ""}
|
|
403
|
+
maxlength={32}
|
|
404
|
+
help={{ info: $T("constructor.props.table.hideIf.info"), regExp: /^[a-zA-Z0-9\-._]{0,32}$/ }}
|
|
405
|
+
onUpdate={(value) =>
|
|
406
|
+
updateContentProperty(
|
|
407
|
+
columnIndex,
|
|
408
|
+
index,
|
|
409
|
+
"hideIf",
|
|
410
|
+
value ? { key: value as string, value: button.hideIf?.value ?? "" } : undefined,
|
|
411
|
+
)}
|
|
412
|
+
/>
|
|
413
|
+
<UI.Input
|
|
414
|
+
wrapperClass="min-w-28 flex-1"
|
|
415
|
+
label={{ name: $T("constructor.props.table.hideIf.value") }}
|
|
416
|
+
value={button.hideIf?.value ?? ""}
|
|
417
|
+
maxlength={64}
|
|
418
|
+
onUpdate={(value) => {
|
|
419
|
+
if (button.hideIf?.key) updateContentProperty(columnIndex, index, "hideIf", { key: button.hideIf.key, value: value as string })
|
|
420
|
+
}}
|
|
421
|
+
/>
|
|
422
|
+
</div>
|
|
398
423
|
{:else if content.type == "progressBar"}
|
|
399
424
|
{@const progressBar = content.data}
|
|
400
425
|
<div class="flex flex-wrap items-end gap-2">
|
package/dist/Tooltip.svelte
CHANGED
|
@@ -1,44 +1,19 @@
|
|
|
1
|
-
<!-- $lib/Tooltip.svelte - общая всплывающая подсказка (рамка + стрелка)
|
|
1
|
+
<!-- $lib/Tooltip.svelte - общая всплывающая подсказка (рамка + стрелка) у кнопок, переключателей, вариантов списка и значков: позиция side относительно триггера по центру -->
|
|
2
2
|
<script lang="ts">
|
|
3
3
|
import { fly } from "svelte/transition"
|
|
4
4
|
|
|
5
|
-
let {
|
|
6
|
-
show = false,
|
|
7
|
-
text = "",
|
|
8
|
-
side = "top",
|
|
9
|
-
align = "center",
|
|
10
|
-
}: {
|
|
11
|
-
show?: boolean
|
|
12
|
-
text?: string
|
|
13
|
-
side?: "top" | "bottom" | "left" | "right"
|
|
14
|
-
align?: "center" | "start"
|
|
15
|
-
} = $props()
|
|
5
|
+
let { show = false, text = "", side = "top" }: { show?: boolean; text?: string; side?: "top" | "bottom" | "left" | "right" } = $props()
|
|
16
6
|
|
|
17
7
|
type Variant = { pos: string; tr: string; arr: string; off: { x?: number; y?: number } }
|
|
18
8
|
|
|
19
|
-
const CONFIG: Record<"top" | "bottom" | "left" | "right",
|
|
20
|
-
top: {
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
arr: "top-full left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45",
|
|
25
|
-
off: { y: -10 },
|
|
26
|
-
},
|
|
27
|
-
start: { pos: "bottom-full left-0 mb-2", tr: "", arr: "top-full left-3 -translate-x-1/2 -translate-y-1/2 rotate-45", off: { y: -10 } },
|
|
28
|
-
},
|
|
29
|
-
bottom: {
|
|
30
|
-
center: { pos: "top-full left-1/2 mt-2", tr: "translateX(-50%)", arr: "bottom-full left-1/2 -translate-x-1/2 translate-y-1/2 rotate-45", off: { y: 10 } },
|
|
31
|
-
start: { pos: "top-full left-0 mt-2", tr: "", arr: "bottom-full left-3 -translate-x-1/2 translate-y-1/2 rotate-45", off: { y: 10 } },
|
|
32
|
-
},
|
|
33
|
-
left: {
|
|
34
|
-
center: { pos: "top-1/2 right-full mr-2", tr: "translateY(-50%)", arr: "top-1/2 -right-2 -translate-x-1/2 -translate-y-1/2 rotate-45", off: { x: -10 } },
|
|
35
|
-
},
|
|
36
|
-
right: {
|
|
37
|
-
center: { pos: "top-1/2 left-full ml-2", tr: "translateY(-50%)", arr: "top-1/2 -left-2 translate-x-1/2 -translate-y-1/2 rotate-45", off: { x: 10 } },
|
|
38
|
-
},
|
|
9
|
+
const CONFIG: Record<"top" | "bottom" | "left" | "right", Variant> = {
|
|
10
|
+
top: { pos: "bottom-full left-1/2 mb-2", tr: "translateX(-50%)", arr: "top-full left-1/2 -translate-x-1/2 -translate-y-1/2 rotate-45", off: { y: -10 } },
|
|
11
|
+
bottom: { pos: "top-full left-1/2 mt-2", tr: "translateX(-50%)", arr: "bottom-full left-1/2 -translate-x-1/2 translate-y-1/2 rotate-45", off: { y: 10 } },
|
|
12
|
+
left: { pos: "top-1/2 right-full mr-2", tr: "translateY(-50%)", arr: "top-1/2 -right-2 -translate-x-1/2 -translate-y-1/2 rotate-45", off: { x: -10 } },
|
|
13
|
+
right: { pos: "top-1/2 left-full ml-2", tr: "translateY(-50%)", arr: "top-1/2 -left-2 translate-x-1/2 -translate-y-1/2 rotate-45", off: { x: 10 } },
|
|
39
14
|
}
|
|
40
15
|
|
|
41
|
-
const config = $derived(CONFIG[side]
|
|
16
|
+
const config = $derived(CONFIG[side])
|
|
42
17
|
</script>
|
|
43
18
|
|
|
44
19
|
{#if show && text}
|
package/dist/Tooltip.svelte.d.ts
CHANGED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
# 📡 WidgetLoRa
|
|
2
|
+
|
|
3
|
+
Карточка настроек радио LoRa: частота, мощность, полоса, спред-фактор, скорость кодирования, преамбула, CRC и инверсия IQ. Виджет не привязан к микросхеме или драйверу: где каждый параметр лежит в прошивке, задаётся в конструкторе.
|
|
4
|
+
|
|
5
|
+
## ✨ Что умеет
|
|
6
|
+
|
|
7
|
+
- 📻 Показывает и меняет параметры радио понятными значениями: частоту в МГц, мощность в дБм, полосу в кГц.
|
|
8
|
+
- 🧩 Показывает только выбранные параметры и отправляет только их.
|
|
9
|
+
- 🧱 Параметр может лежать в своём ключе или в битах общего слова. Чужие биты слова при сохранении не меняются.
|
|
10
|
+
- 📋 Готовые шаблоны драйверов заполняют всё сразу, дальше любое поле правится.
|
|
11
|
+
- 💾 Правки уходят на устройство одной кнопкой «Сохранить». Пока не сохранили, под кнопкой висит напоминание.
|
|
12
|
+
- 🔽 Сворачивается по клику на заголовок, кнопка «?» включает подсказки.
|
|
13
|
+
|
|
14
|
+
## 🧩 Как настроить в конструкторе
|
|
15
|
+
|
|
16
|
+
1. Перетащите виджет на макет и задайте префикс группы, обычно `LORA`.
|
|
17
|
+
2. Выберите шаблон драйвера. Он заполнит, где лежит каждый параметр.
|
|
18
|
+
3. Если прошивка другая, поправьте параметры: галочка показывает параметр, рядом ключ, биты и коды.
|
|
19
|
+
|
|
20
|
+
## 💡 Полезно знать
|
|
21
|
+
|
|
22
|
+
- 📡 У базы и всех её модулей радио должно быть настроено одинаково, иначе связь пропадёт. Меняйте настройки сначала у модулей, потом у базы.
|
|
23
|
+
- 🔢 Число в прошивке = значение × масштаб + смещение. Например, частота в Гц при показе в МГц - масштаб 1000000.
|
|
24
|
+
- 📝 Таблица кодов - пары `имя=код` через пробел, например `125=4 250=5 500=6`. С ней параметр выбирается из списка.
|
|
25
|
+
|
|
26
|
+
<details>
|
|
27
|
+
<summary>⚙️ Свойства и шаблоны</summary>
|
|
28
|
+
|
|
29
|
+
| Свойство | Что это |
|
|
30
|
+
| ---------------- | ---------------------------------------------------------------------------------------------------------------------------------- |
|
|
31
|
+
| `id` | Префикс группы, ключи на устройстве - `{id}.{key}` |
|
|
32
|
+
| `value` | Значения ключей группы без префикса: `{ Cfg: 1820660393 }` |
|
|
33
|
+
| `params` | Параметры: `{ Freq: { key, bits?: { start, end }, scale?, offset?, min?, max?, step?, options? }, ... }`. Нет параметра - он скрыт |
|
|
34
|
+
| `preset` | Шаблон, которым заполнены `params`, только для конструктора |
|
|
35
|
+
| `onSave(values)` | Значения ключей для `SET ModCfg`: `{ Cfg: слово }`. Без колбэка - только просмотр |
|
|
36
|
+
|
|
37
|
+
Шаблоны (`LORA_PRESETS`):
|
|
38
|
+
|
|
39
|
+
- `HT_CT62` - общее слово драйвера HT_CT62 ProdFactory-ESP и `lora_service` ProdFactory-STM (STM32WL). Всё в слове `Cfg`: биты 2-6 мощность (дБм), 7-10 код полосы SX126x (4 = 125, 5 = 250, 6 = 500 кГц), 11-13 SF минус 5 (SF7-SF12), 14-15 CR минус 1 (0 = 4/5), 16 CRC, 17 инверсия IQ, 18-20 индекс длины преамбулы (6, 8, 10, 12, 16, 20, 24, 32), 21-30 частота в МГц. Биты 0-1 - режим работы драйвера, виджет их не трогает.
|
|
40
|
+
|
|
41
|
+
`loraDecode(params, value)` и `loraEncode(params, value, values)` из `lora.ts` - чтение и сборка слов без Svelte, их проверяет `tests/lora.test.mjs`.
|
|
42
|
+
|
|
43
|
+
</details>
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
<script lang="ts"></script>
|
|
2
|
+
|
|
3
|
+
<svg xmlns="http://www.w3.org/2000/svg" width="1em" height="1em" viewBox="0 0 24 24"
|
|
4
|
+
><path
|
|
5
|
+
fill="none"
|
|
6
|
+
stroke="currentColor"
|
|
7
|
+
stroke-linecap="round"
|
|
8
|
+
stroke-linejoin="round"
|
|
9
|
+
stroke-width="2"
|
|
10
|
+
d="M4.9 16.1a10 10 0 0 1 0-14.1M7.8 13.2a6 6 0 0 1 0-8.4M16.2 4.8a6 6 0 0 1 0 8.4M19.1 2a10 10 0 0 1 0 14.1M12 9v13M10 9a2 2 0 1 0 4 0 2 2 0 1 0-4 0"
|
|
11
|
+
/></svg
|
|
12
|
+
>
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
interface $$__sveltets_2_IsomorphicComponent<Props extends Record<string, any> = any, Events extends Record<string, any> = any, Slots extends Record<string, any> = any, Exports = {}, Bindings = string> {
|
|
2
|
+
new (options: import('svelte').ComponentConstructorOptions<Props>): import('svelte').SvelteComponent<Props, Events, Slots> & {
|
|
3
|
+
$$bindings?: Bindings;
|
|
4
|
+
} & Exports;
|
|
5
|
+
(internal: unknown, props: {
|
|
6
|
+
$$events?: Events;
|
|
7
|
+
$$slots?: Slots;
|
|
8
|
+
}): Exports & {
|
|
9
|
+
$set?: any;
|
|
10
|
+
$on?: any;
|
|
11
|
+
};
|
|
12
|
+
z_$$bindings?: Bindings;
|
|
13
|
+
}
|
|
14
|
+
declare const RadioIcon: $$__sveltets_2_IsomorphicComponent<Record<string, never>, {
|
|
15
|
+
[evt: string]: CustomEvent<any>;
|
|
16
|
+
}, {}, {}, string>;
|
|
17
|
+
type RadioIcon = InstanceType<typeof RadioIcon>;
|
|
18
|
+
export default RadioIcon;
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
<!-- $lib/WidgetLoRa/WidgetLoRa.svelte - смарт-виджет настроек радио LoRa: частота, мощность, полоса, SF, CR, преамбула, CRC, InvIQ. Где каждый параметр в прошивке (ключ, биты, масштаб, коды) - в params (lora.ts), поэтому виджет подходит любой микросхеме и драйверу. Сохраняет одним пакетом; ничего не знает про DeviceStore/WebSocket - value/onSave. -->
|
|
2
|
+
<script lang="ts">
|
|
3
|
+
import { T } from "../locales/i18n"
|
|
4
|
+
import { untrack } from "svelte"
|
|
5
|
+
import { slide } from "svelte/transition"
|
|
6
|
+
import { twMerge } from "tailwind-merge"
|
|
7
|
+
import * as UI from ".."
|
|
8
|
+
import type { IWidgetLoRaProps } from "../types"
|
|
9
|
+
import { LORA_PARAMS, LORA_SWITCHES, loraDecode, loraEncode, type LoRaParam, type LoRaValues } from "./lora"
|
|
10
|
+
import RadioIcon from "./RadioIcon.svelte"
|
|
11
|
+
import WidgetHeader from "../WidgetHeader.svelte"
|
|
12
|
+
import { hint, hintsSetting } from "../hints"
|
|
13
|
+
import { accentStyle } from "../accent"
|
|
14
|
+
import { readPersistedCollapsed, writePersistedCollapsed } from "../widgetCollapse"
|
|
15
|
+
|
|
16
|
+
let { wrapperClass = "", accent, label = {}, value, params = {}, collapsed = $bindable(false), persistKey, onSave }: IWidgetLoRaProps = $props()
|
|
17
|
+
|
|
18
|
+
const hints = $derived(hintsSetting("WidgetLoRa", persistKey))
|
|
19
|
+
const rootStyle = $derived(accentStyle(accent))
|
|
20
|
+
|
|
21
|
+
/* Свёрнутость: как у WidgetDeviceInfo - выбор пользователя переживает перезагрузку (persistKey) */
|
|
22
|
+
const guiCollapsed = untrack(() => collapsed)
|
|
23
|
+
collapsed = readPersistedCollapsed(
|
|
24
|
+
untrack(() => persistKey),
|
|
25
|
+
guiCollapsed,
|
|
26
|
+
)
|
|
27
|
+
$effect(() => writePersistedCollapsed(persistKey, collapsed, guiCollapsed))
|
|
28
|
+
|
|
29
|
+
/* Правки локальные до «Сохранить»; новые значения с устройства подхватываются, только пока правок нет */
|
|
30
|
+
const decoded = $derived(loraDecode(params, value ?? {}))
|
|
31
|
+
let values: LoRaValues = $state(untrack(() => ({ ...decoded })))
|
|
32
|
+
let savedSnapshot = $state(untrack(() => JSON.stringify(decoded)))
|
|
33
|
+
const isDirty = $derived(JSON.stringify(values) !== savedSnapshot)
|
|
34
|
+
$effect(() => {
|
|
35
|
+
const incoming = decoded
|
|
36
|
+
if (untrack(() => isDirty)) return
|
|
37
|
+
values = { ...incoming }
|
|
38
|
+
savedSnapshot = JSON.stringify(incoming)
|
|
39
|
+
})
|
|
40
|
+
|
|
41
|
+
const shown = $derived(LORA_PARAMS.filter((name) => params[name]?.key))
|
|
42
|
+
const fields = $derived(shown.filter((name) => !LORA_SWITCHES.includes(name)))
|
|
43
|
+
const switches = $derived(shown.filter((name) => LORA_SWITCHES.includes(name)))
|
|
44
|
+
const readOnly = $derived(!onSave)
|
|
45
|
+
|
|
46
|
+
const set = (name: LoRaParam, input: unknown) => {
|
|
47
|
+
const number = Number(input)
|
|
48
|
+
if (Number.isFinite(number)) values = { ...values, [name]: number }
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
const save = () => {
|
|
52
|
+
if (!onSave) return
|
|
53
|
+
onSave(loraEncode(params, value ?? {}, values))
|
|
54
|
+
savedSnapshot = JSON.stringify(values)
|
|
55
|
+
}
|
|
56
|
+
</script>
|
|
57
|
+
|
|
58
|
+
<div
|
|
59
|
+
class={twMerge("@container relative flex w-full flex-col gap-4 rounded-2xl border border-(--hairline-color) bg-(--container-color) p-4", wrapperClass)}
|
|
60
|
+
style={rootStyle}
|
|
61
|
+
>
|
|
62
|
+
<WidgetHeader icon={RadioIcon} label={label?.name || $T("widget.lora.title")} bind:collapsed {hints} />
|
|
63
|
+
|
|
64
|
+
{#if !collapsed}
|
|
65
|
+
<div class="flex flex-col gap-4" transition:slide={{ duration: 150 }}>
|
|
66
|
+
{#if !shown.length}
|
|
67
|
+
<span class="text-center text-[13px] text-(--muted-color)">{$T("widget.lora.empty")}</span>
|
|
68
|
+
{:else}
|
|
69
|
+
<div class="flex flex-col gap-3 rounded-[10px] border border-(--hairline-color) bg-(--back-color) p-3">
|
|
70
|
+
<div class="grid grid-cols-1 gap-2 @sm:grid-cols-2 @lg:grid-cols-3">
|
|
71
|
+
{#each fields as name (name)}
|
|
72
|
+
{@const p = params[name]!}
|
|
73
|
+
<div use:hint={{ text: $T(`widget.lora.hint.${name}`), enabled: $hints }}>
|
|
74
|
+
{#if p.options?.length}
|
|
75
|
+
<UI.Select
|
|
76
|
+
label={{ name: $T(`widget.lora.${name}`) }}
|
|
77
|
+
options={p.options.map((option) => ({ id: `${name}-${option.value}`, name: option.name, value: option.value }))}
|
|
78
|
+
value={values[name]}
|
|
79
|
+
disabled={readOnly}
|
|
80
|
+
onUpdate={(code) => set(name, code)}
|
|
81
|
+
/>
|
|
82
|
+
{:else}
|
|
83
|
+
<UI.Input
|
|
84
|
+
type="number"
|
|
85
|
+
label={{ name: $T(`widget.lora.${name}`) }}
|
|
86
|
+
value={values[name] ?? ""}
|
|
87
|
+
readonly={readOnly}
|
|
88
|
+
number={{ minNum: p.min, maxNum: p.max, step: p.step ?? 1 }}
|
|
89
|
+
onUpdate={(input) => set(name, input)}
|
|
90
|
+
/>
|
|
91
|
+
{/if}
|
|
92
|
+
</div>
|
|
93
|
+
{/each}
|
|
94
|
+
</div>
|
|
95
|
+
{#if switches.length}
|
|
96
|
+
<div class="flex flex-wrap items-center justify-center gap-6">
|
|
97
|
+
{#each switches as name (name)}
|
|
98
|
+
<div use:hint={{ text: $T(`widget.lora.hint.${name}`), enabled: $hints }}>
|
|
99
|
+
<UI.Switch
|
|
100
|
+
type="horizontal"
|
|
101
|
+
label={{ name: $T(`widget.lora.${name}`) }}
|
|
102
|
+
value={values[name] ? 1 : 0}
|
|
103
|
+
disabled={readOnly}
|
|
104
|
+
onUpdate={(state) => set(name, state)}
|
|
105
|
+
/>
|
|
106
|
+
</div>
|
|
107
|
+
{/each}
|
|
108
|
+
</div>
|
|
109
|
+
{/if}
|
|
110
|
+
</div>
|
|
111
|
+
|
|
112
|
+
{#if !readOnly}
|
|
113
|
+
<div class="flex flex-col items-center gap-2">
|
|
114
|
+
{#if isDirty}
|
|
115
|
+
<span class="text-[12px] text-(--muted-color)" transition:slide={{ duration: 100 }}>{$T("widget.lora.unsaved")}</span>
|
|
116
|
+
{/if}
|
|
117
|
+
<UI.Button wrapperClass="w-40" variant="primary" content={{ name: $T("widget.common.save") }} disabled={!isDirty} onClick={save} />
|
|
118
|
+
</div>
|
|
119
|
+
{/if}
|
|
120
|
+
{/if}
|
|
121
|
+
</div>
|
|
122
|
+
{/if}
|
|
123
|
+
</div>
|