poe-svelte-ui-lib 3.5.1 → 3.6.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.
- package/dist/Button/Button.svelte +26 -2
- package/dist/Button/ButtonProps.svelte +15 -0
- package/dist/Button/README.md +20 -17
- package/dist/SensorCalibrate.svelte +4 -0
- package/dist/SensorCalibrate.svelte.d.ts +1 -0
- package/dist/WidgetEncoder/README.md +1 -1
- package/dist/WidgetEncoder/WidgetEncoder.svelte +1 -0
- package/dist/locales/constructor.d.ts +15 -0
- package/dist/locales/constructor.js +7 -0
- package/dist/locales/translations.d.ts +10 -0
- package/dist/locales/translations.js +6 -0
- package/dist/types.d.ts +1 -0
- package/package.json +1 -1
|
@@ -7,6 +7,9 @@
|
|
|
7
7
|
import Icon from "../Icon.svelte"
|
|
8
8
|
import Loader from "../Loader/Loader.svelte"
|
|
9
9
|
import { isHoverPointer, isKeyboardFocus } from "../popup"
|
|
10
|
+
import Modal from "../Modal.svelte"
|
|
11
|
+
import Self from "./Button.svelte"
|
|
12
|
+
import { T } from "../locales/i18n"
|
|
10
13
|
|
|
11
14
|
let {
|
|
12
15
|
id,
|
|
@@ -20,9 +23,18 @@
|
|
|
20
23
|
aria,
|
|
21
24
|
content = { name: "", info: { text: "", side: "top" }, icon: null },
|
|
22
25
|
keyBind = { showHint: true },
|
|
26
|
+
confirm,
|
|
23
27
|
onClick,
|
|
24
28
|
}: IButtonProps = $props()
|
|
25
29
|
|
|
30
|
+
/* Окно подтверждения: действие - только после «Подтвердить» */
|
|
31
|
+
let asking = $state(false)
|
|
32
|
+
const act = () => (confirm?.trim() ? (asking = true) : onClick?.())
|
|
33
|
+
const accept = () => {
|
|
34
|
+
asking = false
|
|
35
|
+
onClick?.()
|
|
36
|
+
}
|
|
37
|
+
|
|
26
38
|
let showInfo = $state(false)
|
|
27
39
|
const isIconOnly = $derived(!!content?.icon && !content.name?.trim())
|
|
28
40
|
/* Ширина в wrapperClass (w-8, size-10...) - кнопка-значок заполняет обёртку кругом, иначе она размером с поле (32px); w-auto/w-fit/w-max/w-min/w-full ширины не задают */
|
|
@@ -46,7 +58,7 @@
|
|
|
46
58
|
const handleClick = (event: Event) => {
|
|
47
59
|
if (blocked || !onClick) return
|
|
48
60
|
event.stopPropagation()
|
|
49
|
-
|
|
61
|
+
act()
|
|
50
62
|
}
|
|
51
63
|
|
|
52
64
|
const handleKeyDown = (event: KeyboardEvent) => {
|
|
@@ -58,7 +70,7 @@
|
|
|
58
70
|
const isMetaMatch = keyBind.metaKey === undefined || event.metaKey === keyBind.metaKey
|
|
59
71
|
if (isKeyMatch && isCtrlMatch && isShiftMatch && isAltMatch && isMetaMatch) {
|
|
60
72
|
event.preventDefault()
|
|
61
|
-
|
|
73
|
+
act()
|
|
62
74
|
}
|
|
63
75
|
}
|
|
64
76
|
</script>
|
|
@@ -113,3 +125,15 @@
|
|
|
113
125
|
|
|
114
126
|
<Tooltip show={showInfo} text={content.info?.text ?? ""} side={content.info?.side ?? "top"} />
|
|
115
127
|
</div>
|
|
128
|
+
|
|
129
|
+
{#if confirm?.trim()}
|
|
130
|
+
<Modal title={content.name || content.info?.text || $T("widget.common.confirm")} bind:isOpen={asking} wrapperClass="w-md max-w-[95vw]">
|
|
131
|
+
{#snippet main()}
|
|
132
|
+
<p class="text-left whitespace-pre-line">{confirm}</p>
|
|
133
|
+
{/snippet}
|
|
134
|
+
{#snippet footer()}
|
|
135
|
+
<Self variant="primary" {accent} content={{ name: $T("widget.common.confirm") }} onClick={accept} />
|
|
136
|
+
<Self variant="secondary" content={{ name: $T("widget.common.cancel") }} onClick={() => (asking = false)} />
|
|
137
|
+
{/snippet}
|
|
138
|
+
</Modal>
|
|
139
|
+
{/if}
|
|
@@ -53,6 +53,12 @@
|
|
|
53
53
|
...(icon || !hasName ? { componentClass: twMerge(properties.componentClass, icon && !hasName ? "w-fit p-2" : "w-full px-1 py-1") } : {}),
|
|
54
54
|
},
|
|
55
55
|
})
|
|
56
|
+
/* Текст окна подтверждения по умолчанию, на всех языках */
|
|
57
|
+
const CONFIRM_DEFAULT = {
|
|
58
|
+
ru: "Выполнить действие?",
|
|
59
|
+
en: "Run the action?",
|
|
60
|
+
zh: "执行此操作?",
|
|
61
|
+
} as unknown as string /* в GUI текст хранится по языкам, кнопка получает строку языка интерфейса */
|
|
56
62
|
</script>
|
|
57
63
|
|
|
58
64
|
<div class="flex flex-col gap-2">
|
|
@@ -67,6 +73,15 @@
|
|
|
67
73
|
onUpdate={(Header) => onPropertyChange({ eventHandler: { Header } })}
|
|
68
74
|
/>
|
|
69
75
|
<ArgumentSelect value={component.eventHandler?.Argument || "ModuleConfig"} onUpdate={(Argument) => onPropertyChange({ eventHandler: { Argument } })} />
|
|
76
|
+
<!-- Подтверждение перед командой: текст окна правится в «Текстах и переводах» -->
|
|
77
|
+
<UI.Switch
|
|
78
|
+
wrapperClass="h-8"
|
|
79
|
+
type="checkbox"
|
|
80
|
+
label={{ name: $T("constructor.props.button.confirm") }}
|
|
81
|
+
help={{ info: $T("constructor.props.button.confirm.info") }}
|
|
82
|
+
value={properties.confirm ? 1 : 0}
|
|
83
|
+
onUpdate={(on) => onPropertyChange({ properties: { confirm: on ? CONFIRM_DEFAULT : undefined } })}
|
|
84
|
+
/>
|
|
70
85
|
</PropsGroup>
|
|
71
86
|
<PropsGroup label={$T("constructor.props.group.value")}>
|
|
72
87
|
{#if component.eventHandler?.Argument !== "ModuleConfig" || component.eventHandler?.Header === "SET"}
|
package/dist/Button/README.md
CHANGED
|
@@ -12,6 +12,7 @@
|
|
|
12
12
|
- 💬 Показывает подсказку при наведении.
|
|
13
13
|
- 📌 Бывает кнопкой-переключателем: нажатая выглядит как выбранная кнопка группы.
|
|
14
14
|
- ⏳ Показывает крутилку, пока идёт действие, и в это время не нажимается.
|
|
15
|
+
- ✋ Может спросить подтверждение в окне перед командой - для действий с движением и необратимых: калибровка, автонастройка, сброс.
|
|
15
16
|
|
|
16
17
|
## 🧩 Как настроить в конструкторе
|
|
17
18
|
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
2. Выберите иконку и цвет, если нужно.
|
|
20
21
|
3. Укажите, какую команду отправлять: например `SET` и `SystemRestart`.
|
|
21
22
|
4. Если кнопка должна отправить значения других полей, перечислите их переменные. Если всегда одно и то же значение - задайте его.
|
|
23
|
+
5. Если перед командой нужно согласие человека, включите «Подтверждение» и напишите текст окна в «Текстах и переводах».
|
|
22
24
|
|
|
23
25
|
## 💡 Полезно знать
|
|
24
26
|
|
|
@@ -61,23 +63,24 @@
|
|
|
61
63
|
<details>
|
|
62
64
|
<summary>⚙️ Пропсы</summary>
|
|
63
65
|
|
|
64
|
-
| Название | Тип | По умолчанию | Описание
|
|
65
|
-
| ------------------ | ------------------------------------- | -------------------- |
|
|
66
|
-
| `id` | `string` | | Атрибут `id` кнопки
|
|
67
|
-
| `wrapperClass` | `string` | `""` | Классы обёртки
|
|
68
|
-
| `componentClass` | `string` | `""` | Классы самой кнопки
|
|
69
|
-
| `variant` | `"primary" \| "secondary" \| "plain"` | `"plain"` | Вид: заливка, контур или текст
|
|
70
|
-
| `accent` | `AccentColor` | | Цвет: `red`, `green`, `blue` и другие. Без него - акцент темы
|
|
71
|
-
| `disabled` | `boolean` | `false` | Кнопка неактивна
|
|
72
|
-
| `pressed` | `boolean` | | Кнопка-переключатель: нажата или нет (`aria-pressed`). Без пропа - обычная кнопка
|
|
73
|
-
| `loading` | `boolean` | `false` | Идёт действие: крутилка вместо значка, кнопка не нажимается
|
|
74
|
-
| `aria` | `{ haspopup, expanded, controls }` | | Атрибуты кнопки, открывающей панель
|
|
75
|
-
| `content.name` | `string` | | Текст
|
|
76
|
-
| `content.icon` | `Component \| string \| null` | `null` | Иконка: Svelte-компонент или SVG-строка
|
|
77
|
-
| `content.info` | `{ text, side }` | | Подсказка при наведении. `side`: `top`, `bottom`, `left`, `right`
|
|
78
|
-
| `keyBind` | `object` | `{ showHint: true }` | Горячая клавиша: `key`, `ctrlKey`, `shiftKey`, `altKey`, `metaKey`
|
|
79
|
-
| `keyBind.showHint` | `boolean` | `true` | Показывать клавишу на кнопке
|
|
80
|
-
| `
|
|
66
|
+
| Название | Тип | По умолчанию | Описание |
|
|
67
|
+
| ------------------ | ------------------------------------- | -------------------- | --------------------------------------------------------------------------------------------------- |
|
|
68
|
+
| `id` | `string` | | Атрибут `id` кнопки |
|
|
69
|
+
| `wrapperClass` | `string` | `""` | Классы обёртки |
|
|
70
|
+
| `componentClass` | `string` | `""` | Классы самой кнопки |
|
|
71
|
+
| `variant` | `"primary" \| "secondary" \| "plain"` | `"plain"` | Вид: заливка, контур или текст |
|
|
72
|
+
| `accent` | `AccentColor` | | Цвет: `red`, `green`, `blue` и другие. Без него - акцент темы |
|
|
73
|
+
| `disabled` | `boolean` | `false` | Кнопка неактивна |
|
|
74
|
+
| `pressed` | `boolean` | | Кнопка-переключатель: нажата или нет (`aria-pressed`). Без пропа - обычная кнопка |
|
|
75
|
+
| `loading` | `boolean` | `false` | Идёт действие: крутилка вместо значка, кнопка не нажимается |
|
|
76
|
+
| `aria` | `{ haspopup, expanded, controls }` | | Атрибуты кнопки, открывающей панель |
|
|
77
|
+
| `content.name` | `string` | | Текст |
|
|
78
|
+
| `content.icon` | `Component \| string \| null` | `null` | Иконка: Svelte-компонент или SVG-строка |
|
|
79
|
+
| `content.info` | `{ text, side }` | | Подсказка при наведении. `side`: `top`, `bottom`, `left`, `right` |
|
|
80
|
+
| `keyBind` | `object` | `{ showHint: true }` | Горячая клавиша: `key`, `ctrlKey`, `shiftKey`, `altKey`, `metaKey` |
|
|
81
|
+
| `keyBind.showHint` | `boolean` | `true` | Показывать клавишу на кнопке |
|
|
82
|
+
| `confirm` | `string` | | Текст окна подтверждения: есть - нажатие сначала спрашивает, `onClick` - только после «Подтвердить» |
|
|
83
|
+
| `onClick` | `() => void` | | Нажатие кнопкой мыши или горячей клавишей |
|
|
81
84
|
|
|
82
85
|
</details>
|
|
83
86
|
|
|
@@ -17,6 +17,7 @@
|
|
|
17
17
|
locked = false,
|
|
18
18
|
busy = $bindable(false),
|
|
19
19
|
pollMs = 1000,
|
|
20
|
+
confirm,
|
|
20
21
|
}: {
|
|
21
22
|
/* Режим из Cfg; undefined - Cfg ещё не прочитан */
|
|
22
23
|
mode: number | undefined
|
|
@@ -35,6 +36,8 @@
|
|
|
35
36
|
busy?: boolean
|
|
36
37
|
/* Как часто перечитывать настройки во время калибровки, мс; 0 - только по окончании calibrateMs */
|
|
37
38
|
pollMs?: number
|
|
39
|
+
/* Калибровка с движением (вращение вала): текст окна подтверждения перед запуском */
|
|
40
|
+
confirm?: string
|
|
38
41
|
} = $props()
|
|
39
42
|
|
|
40
43
|
const COLORS = ["var(--faint-color)", "var(--green-text)", "var(--purple-text)", "var(--blue-text)"]
|
|
@@ -106,6 +109,7 @@
|
|
|
106
109
|
accent="purple"
|
|
107
110
|
content={{ name: $T("widget.sensor.calibrate") }}
|
|
108
111
|
disabled={running || !!blocked}
|
|
112
|
+
{confirm}
|
|
109
113
|
onClick={start}
|
|
110
114
|
/>
|
|
111
115
|
{/if}
|
|
@@ -9,6 +9,7 @@ type $$ComponentProps = {
|
|
|
9
9
|
locked?: boolean;
|
|
10
10
|
busy?: boolean;
|
|
11
11
|
pollMs?: number;
|
|
12
|
+
confirm?: string;
|
|
12
13
|
};
|
|
13
14
|
declare const SensorCalibrate: import("svelte").Component<$$ComponentProps, {}, "busy">;
|
|
14
15
|
type SensorCalibrate = ReturnType<typeof SensorCalibrate>;
|
|
@@ -7,7 +7,7 @@
|
|
|
7
7
|
- 📐 Показывает угол вала, °, скорость, об/мин, и положение нуля, °.
|
|
8
8
|
- 🚦 Показывает режим датчика: стоп, измеряет, автокалибровка или установка нуля.
|
|
9
9
|
- 🎯 Кнопка «Ноль здесь» делает текущее положение вала нулём, ноль сохраняется в настройках устройства.
|
|
10
|
-
- 🔄 Кнопка «Калибровать» запускает автокалибровку чипа: устройство само вращает вал, полоса времени показывает ход.
|
|
10
|
+
- 🔄 Кнопка «Калибровать» запускает автокалибровку чипа: устройство само вращает вал, полоса времени показывает ход. Перед запуском виджет спрашивает подтверждение: вал должен вращаться свободно.
|
|
11
11
|
- ⏳ Пока идёт калибровка, показывает полосу времени и раз в секунду перечитывает настройки датчика: как только прошивка закончила, показывает итог.
|
|
12
12
|
- ⚠️ Показывает флаги чипа: высокая скорость, слабое поле, низкое питание, и итог последней автокалибровки.
|
|
13
13
|
- ⚙️ Если выбрана микросхема, показывает раздел «Настройки датчика»: режим работы, направление, частота опроса, полоса, гистерезис, сглаживание скорости. Сохраняются кнопкой «Сохранить», «По умолчанию» ставит заводские настройки чипа.
|
|
@@ -103,6 +103,7 @@
|
|
|
103
103
|
<SensorCalibrate
|
|
104
104
|
{mode}
|
|
105
105
|
instruction={$T("widget.enc.calibrating")}
|
|
106
|
+
confirm={$T("widget.enc.calibrate.confirm")}
|
|
106
107
|
{calibrateMs}
|
|
107
108
|
onCalibrate={onCalibrate && cfg !== undefined ? () => onCalibrate(bitFieldSet(cfg, 0, 1, SENSOR_MODE.calibrate)) : undefined}
|
|
108
109
|
{onRefresh}
|
|
@@ -2114,6 +2114,11 @@ declare const constructorTranslations: {
|
|
|
2114
2114
|
en: string;
|
|
2115
2115
|
zh: string;
|
|
2116
2116
|
};
|
|
2117
|
+
"constructor.texts.confirm": {
|
|
2118
|
+
ru: string;
|
|
2119
|
+
en: string;
|
|
2120
|
+
zh: string;
|
|
2121
|
+
};
|
|
2117
2122
|
"constructor.texts.placeholder": {
|
|
2118
2123
|
ru: string;
|
|
2119
2124
|
en: string;
|
|
@@ -2394,6 +2399,16 @@ declare const constructorTranslations: {
|
|
|
2394
2399
|
en: string;
|
|
2395
2400
|
zh: string;
|
|
2396
2401
|
};
|
|
2402
|
+
"constructor.props.button.confirm": {
|
|
2403
|
+
ru: string;
|
|
2404
|
+
en: string;
|
|
2405
|
+
zh: string;
|
|
2406
|
+
};
|
|
2407
|
+
"constructor.props.button.confirm.info": {
|
|
2408
|
+
ru: string;
|
|
2409
|
+
en: string;
|
|
2410
|
+
zh: string;
|
|
2411
|
+
};
|
|
2397
2412
|
"constructor.props.button.header.info": {
|
|
2398
2413
|
ru: string;
|
|
2399
2414
|
en: string;
|
|
@@ -680,6 +680,7 @@ const constructorTranslations = {
|
|
|
680
680
|
"constructor.texts.name": { ru: "Текст", en: "Text", zh: "文本" },
|
|
681
681
|
"constructor.texts.text": { ru: "Текст", en: "Text", zh: "文本" },
|
|
682
682
|
"constructor.texts.content": { ru: "Содержимое", en: "Content", zh: "内容" },
|
|
683
|
+
"constructor.texts.confirm": { ru: "Подтверждение", en: "Confirmation", zh: "确认" },
|
|
683
684
|
"constructor.texts.placeholder": { ru: "Подсказка в поле", en: "Placeholder", zh: "占位提示" },
|
|
684
685
|
"constructor.texts.info": { ru: "Подсказка", en: "Hint", zh: "提示" },
|
|
685
686
|
"constructor.texts.help": { ru: "Справка", en: "Help", zh: "帮助" },
|
|
@@ -864,6 +865,12 @@ const constructorTranslations = {
|
|
|
864
865
|
en: "How much the value changes per step: with the arrows, the mouse wheel or the slider.",
|
|
865
866
|
zh: "每步的变化量:使用箭头、鼠标滚轮或滑块。",
|
|
866
867
|
},
|
|
868
|
+
"constructor.props.button.confirm": { ru: "Подтверждение", en: "Confirmation", zh: "确认" },
|
|
869
|
+
"constructor.props.button.confirm.info": {
|
|
870
|
+
ru: "Перед командой кнопка спрашивает подтверждение в окне. Нужно для действий с движением и необратимых действий: калибровка, автонастройка, сброс. Текст окна - в «Текстах и переводах».",
|
|
871
|
+
en: "Before the command the button asks for confirmation in a dialog. Use it for actions with motion and irreversible actions: calibration, auto-tuning, reset. The dialog text is in «Texts and translations».",
|
|
872
|
+
zh: "发送命令前按钮会弹窗请求确认。用于带运动或不可撤销的操作:校准、自动整定、复位。弹窗文字在「文字与翻译」中修改。",
|
|
873
|
+
},
|
|
867
874
|
"constructor.props.button.header.info": {
|
|
868
875
|
ru: "**Что команда делает с устройством:**\n**GET** - запросить данные.\n**SET** - изменить или выполнить.\n**OK! и ER!** - ответы устройства, кнопке обычно не нужны.",
|
|
869
876
|
en: "**What the command does to the device:**\n**GET** - request data.\n**SET** - change or run.\n**OK! and ER!** - device replies, a button rarely needs them.",
|
|
@@ -484,6 +484,11 @@ declare const translations: {
|
|
|
484
484
|
en: string;
|
|
485
485
|
zh: string;
|
|
486
486
|
};
|
|
487
|
+
"widget.common.confirm": {
|
|
488
|
+
ru: string;
|
|
489
|
+
en: string;
|
|
490
|
+
zh: string;
|
|
491
|
+
};
|
|
487
492
|
"widget.common.refresh": {
|
|
488
493
|
ru: string;
|
|
489
494
|
en: string;
|
|
@@ -1489,6 +1494,11 @@ declare const translations: {
|
|
|
1489
1494
|
en: string;
|
|
1490
1495
|
zh: string;
|
|
1491
1496
|
};
|
|
1497
|
+
"widget.enc.calibrate.confirm": {
|
|
1498
|
+
ru: string;
|
|
1499
|
+
en: string;
|
|
1500
|
+
zh: string;
|
|
1501
|
+
};
|
|
1492
1502
|
"widget.imu.title": {
|
|
1493
1503
|
ru: string;
|
|
1494
1504
|
en: string;
|
|
@@ -189,6 +189,7 @@ const translations = {
|
|
|
189
189
|
"sensor.opt.lowPower": { ru: "Экономичный", en: "Low power", zh: "低功耗" },
|
|
190
190
|
"sensor.opt.lowNoise": { ru: "Малошумный", en: "Low noise", zh: "低噪声" },
|
|
191
191
|
"widget.common.cancel": { ru: "Отмена", en: "Cancel", zh: "取消" },
|
|
192
|
+
"widget.common.confirm": { ru: "Подтвердить", en: "Confirm", zh: "确认" },
|
|
192
193
|
"widget.common.refresh": { ru: "Обновить", en: "Refresh", zh: "刷新" },
|
|
193
194
|
"widget.common.delete": { ru: "Удалить", en: "Delete", zh: "删除" },
|
|
194
195
|
"widget.common.unsaved": { ru: "Есть несохранённые изменения", en: "There are unsaved changes", zh: "有未保存的更改" },
|
|
@@ -686,6 +687,11 @@ const translations = {
|
|
|
686
687
|
"widget.sensor.mode.calibrate": { ru: "калибровка", en: "calibrating", zh: "校准中" },
|
|
687
688
|
"widget.sensor.mode.on_demand": { ru: "по запросу", en: "on demand", zh: "按需" },
|
|
688
689
|
"widget.sensor.calibrate": { ru: "Калибровать", en: "Calibrate", zh: "校准" },
|
|
690
|
+
"widget.enc.calibrate.confirm": {
|
|
691
|
+
ru: "Для калибровки устройство само вращает вал с датчиком, несколько десятков оборотов.\nВал должен вращаться свободно: снимите нагрузку и проверьте, что ничего не намотается и не упрётся.",
|
|
692
|
+
en: "To calibrate, the device spins the shaft with the sensor for several dozen turns.\nThe shaft must turn freely: remove the load and make sure nothing can wind up or hit a stop.",
|
|
693
|
+
zh: "校准时设备会自行转动带传感器的轴,约几十圈。\n轴必须能自由转动:请卸下负载,并确认没有东西会缠绕或卡住。",
|
|
694
|
+
},
|
|
689
695
|
"widget.imu.title": { ru: "IMU", en: "IMU", zh: "IMU" },
|
|
690
696
|
"widget.imu.accel": { ru: "Акселерометр", en: "Accelerometer", zh: "加速度计" },
|
|
691
697
|
"widget.imu.gyro": { ru: "Гироскоп", en: "Gyroscope", zh: "陀螺仪" },
|
package/dist/types.d.ts
CHANGED