@1337exp/taoux 0.1.0 → 0.2.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/CHANGELOG.md +17 -0
- package/README.md +9 -5
- package/README.ru.md +9 -5
- package/dist/chunks/{curveeditor-goX9maE5.js → curveeditor-F3XBWHPL.js} +2 -2
- package/dist/chunks/curveeditor-F3XBWHPL.js.map +1 -0
- package/dist/commands.d.ts +134 -0
- package/dist/commands.js +189 -0
- package/dist/commands.js.map +1 -0
- package/dist/curveeditor.js +1 -1
- package/dist/curvefield.js +1 -1
- package/dist/hotkeys.d.ts +108 -0
- package/dist/hotkeys.js +280 -0
- package/dist/hotkeys.js.map +1 -0
- package/package.json +13 -4
- package/skills/taoux/SKILL.md +93 -0
- package/dist/chunks/curveeditor-goX9maE5.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.2.0
|
|
4
|
+
|
|
5
|
+
TaoUI 5.0 is out, and TaoUX follows it, with two new modules for the TaoUI menu bar.
|
|
6
|
+
|
|
7
|
+
### Modules
|
|
8
|
+
|
|
9
|
+
- **A skill for AI assistants** ships in the package: `skills/taoux/SKILL.md` (the modules, the TaoUI bridge, commands and hotkeys with the menu bar, the usual mistakes). `tests/skill.test.ts` keeps it naming every module.
|
|
10
|
+
- **New `hotkeys`** (tier 0): `parseHotkey` (`Mod+Shift+Z`, aliases, the plus key; a typo throws), `matchHotkey` (`Mod` is ⌘ on Apple and Ctrl elsewhere; a non-Latin layout and Option on a Mac match by the physical key, the digit row too), `formatHotkey` (`Ctrl+Shift+Z` / `⇧⌘Z` in Apple's ⌃⌥⇧⌘ order), `normalizeHotkey`, `isReservedHotkey` (⌘W, ⌘T, ⌘N, Ctrl+Tab; ⌘Q on a Mac, Alt+F4 elsewhere, ⌘R in Safari), `bindHotkeys` (on any element; text fields keep plain keys and text editing by default).
|
|
11
|
+
- **New `commands`** (tier 1): `createCommands` — a registry of commands with `label`, `shortcut`, `icon`, `enabled`, `checked`, `group`, `run`; `toMenu(layout)` builds the menu tree for `TaoMenubar`, `TaoDropdownMenu` and `TaoContextMenu` (the same shape as TaoUI's `TaoMenuItem`, held by a type test, with no dependency on TaoUI); `bind` listens to the shortcuts (a disabled command swallows its key); `check` lists reserved and duplicate shortcuts; `historyCommands` gives Undo / Redo that disable themselves (a document session fits as is).
|
|
12
|
+
|
|
13
|
+
### TaoUI
|
|
14
|
+
|
|
15
|
+
- **Built and tested against TaoUI 5.0.0** (peer range `^5.0.0`, optional). TaoUI 5 is ESM-only; its styles moved into `tokens/`, `themes/` and `contexts/`, and `TaoTimeline` is now `TaoScrubber`.
|
|
16
|
+
- **The bridge is unchanged for you:** the 13 `--tao-color-*` tokens it points at are the same. Its test no longer depends on one TaoUI file name: it reads every stylesheet of the installed TaoUI, so a future reshuffle cannot break it for the wrong reason.
|
|
17
|
+
- The sandbox, the docs and the consumer smoke test use `TaoScrubber`.
|
|
18
|
+
- `npm run smoke` accepts `TAOUI_TARBALL=<file.tgz>` to test against a TaoUI that is not published yet.
|
|
19
|
+
|
|
3
20
|
## 0.1.0
|
|
4
21
|
|
|
5
22
|
The first public release.
|
package/README.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<a href="https://www.npmjs.com/package/@1337exp/taoux"><img src="https://img.shields.io/npm/v/@1337exp/taoux?color=cb3837&logo=npm" alt="npm"></a>
|
|
10
10
|
<a href="https://github.com/1337exp/taoux/actions/workflows/ci.yml"><img src="https://github.com/1337exp/taoux/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
11
|
-
<a href="https://github.com/1337exp/taoux/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@1337exp/taoux" alt="license"></a>
|
|
11
|
+
<a href="https://github.com/1337exp/taoux/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@1337exp/taoux?style=flat" alt="license"></a>
|
|
12
12
|
<img src="https://img.shields.io/badge/Vue-3-42b883?logo=vuedotjs&logoColor=white" alt="Vue 3">
|
|
13
13
|
<img src="https://img.shields.io/badge/types-included-3178c6?logo=typescript&logoColor=white" alt="TypeScript">
|
|
14
14
|
</p>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<td width="50%"><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/gradienteditor.webp" alt="Gradient editor: adding and moving stops"><br><sub><b>gradienteditor</b> — stops, handles, <code>gradientCss</code></sub></td>
|
|
40
40
|
</tr>
|
|
41
41
|
<tr>
|
|
42
|
-
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/playback.webp" alt="Playback:
|
|
42
|
+
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/playback.webp" alt="Playback: TaoScrubber driven by usePlayback"><br><sub><b>playback</b> — time, loop, speed, seeking; <code>usePlayback</code> + TaoUI <code>TaoScrubber</code></sub></td>
|
|
43
43
|
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/curvefield.webp" alt="TaoxCurveField: a curve with TaoUI fields"><br><sub><b>curvefield</b> — a curve with TaoUI fields in one component</sub></td>
|
|
44
44
|
</tr>
|
|
45
45
|
</table>
|
|
@@ -51,7 +51,7 @@ npm install @1337exp/taoux
|
|
|
51
51
|
npm install @1337exp/taoui # optional: only for curvefield and the TaoUI bridge
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Peers: `vue ^3.4` (for the Vue modules) and, optionally, `@1337exp/taoui ^
|
|
54
|
+
Peers: `vue ^3.4` (for the Vue modules) and, optionally, `@1337exp/taoui ^5.0.0`. Modules without Vue need nothing.
|
|
55
55
|
ESM only. Import by subpath; there is no root entry on purpose, so nothing you do not import can end up in your bundle.
|
|
56
56
|
|
|
57
57
|
## With TaoUI
|
|
@@ -64,7 +64,7 @@ import '@1337exp/taoux/taoui.css'; // the bridge: --tx-* → --tao-*, t
|
|
|
64
64
|
import '@1337exp/taoux/curveeditor.css'; // styles of a Vue module are imported explicitly
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
`taoui.css` is plain CSS with zero specificity and no dependency on TaoUI, so any rule of yours wins. Values then travel through `v-model`: `usePlayback` drives `
|
|
67
|
+
`taoui.css` is plain CSS with zero specificity and no dependency on TaoUI, so any rule of yours wins. Values then travel through `v-model`: `usePlayback` drives `TaoScrubber`, a TaoUI field edits a curve point, a TaoUI slider sets the opacity of a gradient stop. With code: [docs/taoui.md](docs/taoui.md). Without the bridge the editors keep their dark defaults; `TaoxCurveField` (built from TaoUI components) follows the theme by itself.
|
|
68
68
|
|
|
69
69
|
<a id="modules"></a>
|
|
70
70
|
|
|
@@ -81,6 +81,7 @@ import { History } from '@1337exp/taoux/history';
|
|
|
81
81
|
|---|---|---|
|
|
82
82
|
| `camera` | canvas camera: pan, zoom around the cursor, screen ↔ world | nothing |
|
|
83
83
|
| `history` | undo/redo on string snapshots, rapid edits merged into one step | nothing |
|
|
84
|
+
| `hotkeys` | shortcuts: `parseHotkey('Mod+Shift+Z')`, `matchHotkey` (Mod = ⌘ / Ctrl, non-Latin layouts by the physical key), `formatHotkey` (`Ctrl+Shift+Z` / `⇧⌘Z`), `isReservedHotkey` (⌘W, ⌘T, ⌘Q…), `bindHotkeys` on an element | DOM (for `bindHotkeys`) |
|
|
84
85
|
| `storage` | autosave to localStorage without exceptions | nothing |
|
|
85
86
|
| `file` | download text as a file, size limit | DOM |
|
|
86
87
|
| `snap` | soft snapping to a grid with a threshold that follows the camera zoom | nothing |
|
|
@@ -93,6 +94,7 @@ import { History } from '@1337exp/taoux/history';
|
|
|
93
94
|
| `ease` | easing functions between curve points: 8 families × in / out / in-out, `linear`, `step`, cubic Bezier; `easeValue`, `isEase` (the editor draws with it, a runtime evaluates with it) | nothing |
|
|
94
95
|
| `num` | small numeric helpers: `clamp`, `roundTo`, `snapTo`, `niceStep`, `ticks` (shared by the curve, gradient and playback modules) | nothing |
|
|
95
96
|
| `session` | document lifecycle: history, autosave, files, restore, notices | vue (peer) |
|
|
97
|
+
| `commands` | a registry of commands (label, shortcut, `enabled`, `checked`, `run`): `toMenu(layout)` builds a `TaoMenuItem[]` tree for `TaoMenubar` / `TaoContextMenu`, `bind` listens to the same shortcuts, `historyCommands` gives Undo / Redo that disable themselves, `check` finds reserved and duplicate shortcuts | DOM (for `bind`) |
|
|
96
98
|
| `palette` | search and groups of nodes for a palette | nothing |
|
|
97
99
|
| `links` (Vue) | links layer: SVG from ready geometry, `--tx-link-*` | vue (peer) |
|
|
98
100
|
| `canvas` (Vue) | canvas: mouse and touch gestures, wheel, auto-scroll, keys; the `CanvasHost` contract | vue (peer) |
|
|
@@ -103,10 +105,12 @@ import { History } from '@1337exp/taoux/history';
|
|
|
103
105
|
| `pins` | row pin positions measured from the DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
|
|
104
106
|
| `i18n` | typed i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, optional) |
|
|
105
107
|
|
|
106
|
-
Vue modules (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`) need their styles imported explicitly: `import '@1337exp/taoux/canvas.css'`. Composite modules (session, palette, links, canvas, pins, curveeditor, gradienteditor, playback) import only primitives. Tier 2, fields (`curvefield`), assemble composites into a ready field on TaoUI components: it is the only tier allowed to import TaoUI, which is why `@1337exp/taoui` is an optional peer dependency. `curvefield` needs both `curveeditor.css` and `curvefield.css`. The `tiers.test.ts` test guards all of that. The canvas contract is described in [docs/canvas.md](docs/canvas.md) ([Русский](docs/canvas.ru.md)); transitions between curve points are in [docs/ease.md](docs/ease.md) ([Русский](docs/ease.ru.md)).
|
|
108
|
+
Vue modules (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`) need their styles imported explicitly: `import '@1337exp/taoux/canvas.css'`. Composite modules (session, commands, palette, links, canvas, pins, curveeditor, gradienteditor, playback) import only primitives. Tier 2, fields (`curvefield`), assemble composites into a ready field on TaoUI components: it is the only tier allowed to import TaoUI, which is why `@1337exp/taoui` is an optional peer dependency. `curvefield` needs both `curveeditor.css` and `curvefield.css`. The `tiers.test.ts` test guards all of that. The canvas contract is described in [docs/canvas.md](docs/canvas.md) ([Русский](docs/canvas.ru.md)); transitions between curve points are in [docs/ease.md](docs/ease.md) ([Русский](docs/ease.ru.md)).
|
|
107
109
|
|
|
108
110
|
The rule: a module lands here when a second project needs it. A module's core knows nothing about Vue or the DOM unless that is its job.
|
|
109
111
|
|
|
112
|
+
**For AI assistants:** the package ships a skill, `skills/taoux/SKILL.md`: how the modules fit together and the mistakes to avoid. Point your assistant at it (Claude Code: copy the folder into `.claude/skills/`).
|
|
113
|
+
|
|
110
114
|
## Development
|
|
111
115
|
|
|
112
116
|
```bash
|
package/README.ru.md
CHANGED
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
<p align="center">
|
|
9
9
|
<a href="https://www.npmjs.com/package/@1337exp/taoux"><img src="https://img.shields.io/npm/v/@1337exp/taoux?color=cb3837&logo=npm" alt="npm"></a>
|
|
10
10
|
<a href="https://github.com/1337exp/taoux/actions/workflows/ci.yml"><img src="https://github.com/1337exp/taoux/actions/workflows/ci.yml/badge.svg" alt="CI"></a>
|
|
11
|
-
<a href="https://github.com/1337exp/taoux/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@1337exp/taoux" alt="license"></a>
|
|
11
|
+
<a href="https://github.com/1337exp/taoux/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/@1337exp/taoux?style=flat" alt="license"></a>
|
|
12
12
|
<img src="https://img.shields.io/badge/Vue-3-42b883?logo=vuedotjs&logoColor=white" alt="Vue 3">
|
|
13
13
|
<img src="https://img.shields.io/badge/types-included-3178c6?logo=typescript&logoColor=white" alt="TypeScript">
|
|
14
14
|
</p>
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
<td width="50%"><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/gradienteditor.webp" alt="Редактор градиента: добавление и перемещение остановок"><br><sub><b>gradienteditor</b> — остановки, ручки, <code>gradientCss</code></sub></td>
|
|
40
40
|
</tr>
|
|
41
41
|
<tr>
|
|
42
|
-
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/playback.webp" alt="Воспроизведение:
|
|
42
|
+
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/playback.webp" alt="Воспроизведение: TaoScrubber ведёт usePlayback"><br><sub><b>playback</b> — время, цикл, скорость, перемотка; <code>usePlayback</code> + <code>TaoScrubber</code> из TaoUI</sub></td>
|
|
43
43
|
<td><img src="https://raw.githubusercontent.com/1337exp/taoux/main/docs/media/clips/curvefield.webp" alt="TaoxCurveField: кривая с полями TaoUI"><br><sub><b>curvefield</b> — кривая с полями TaoUI в одном компоненте</sub></td>
|
|
44
44
|
</tr>
|
|
45
45
|
</table>
|
|
@@ -51,7 +51,7 @@ npm install @1337exp/taoux
|
|
|
51
51
|
npm install @1337exp/taoui # по желанию: только для curvefield и моста к TaoUI
|
|
52
52
|
```
|
|
53
53
|
|
|
54
|
-
Peer-зависимости: `vue ^3.4` (для Vue-модулей) и, по желанию, `@1337exp/taoui ^
|
|
54
|
+
Peer-зависимости: `vue ^3.4` (для Vue-модулей) и, по желанию, `@1337exp/taoui ^5.0.0`. Модулям без Vue ничего не нужно.
|
|
55
55
|
Только ESM. Импорт по subpath; корневой точки входа нет намеренно, чтобы в сборку не попало ничего неимпортированного.
|
|
56
56
|
|
|
57
57
|
## С TaoUI
|
|
@@ -64,7 +64,7 @@ import '@1337exp/taoux/taoui.css'; // мост: --tx-* → --tao-*, р
|
|
|
64
64
|
import '@1337exp/taoux/curveeditor.css'; // стили Vue-модуля подключаются явно
|
|
65
65
|
```
|
|
66
66
|
|
|
67
|
-
`taoui.css` это обычный CSS с нулевой специфичностью и без зависимости от TaoUI, поэтому любое ваше правило главнее. Дальше значения ходят через `v-model`: `usePlayback` ведёт `
|
|
67
|
+
`taoui.css` это обычный CSS с нулевой специфичностью и без зависимости от TaoUI, поэтому любое ваше правило главнее. Дальше значения ходят через `v-model`: `usePlayback` ведёт `TaoScrubber`, поле TaoUI правит точку кривой, слайдер TaoUI задаёт прозрачность остановки градиента. С кодом: [docs/taoui.ru.md](docs/taoui.ru.md). Без моста редакторы остаются с тёмными значениями по умолчанию; `TaoxCurveField` (собран из компонентов TaoUI) подстраивается под тему сам.
|
|
68
68
|
|
|
69
69
|
<a id="модули"></a>
|
|
70
70
|
|
|
@@ -81,6 +81,7 @@ import { History } from '@1337exp/taoux/history';
|
|
|
81
81
|
|---|---|---|
|
|
82
82
|
| `camera` | камера холста: pan, zoom вокруг курсора, экран ↔ мир | нет |
|
|
83
83
|
| `history` | undo/redo на снимках-строках со склейкой частых правок | нет |
|
|
84
|
+
| `hotkeys` | сочетания клавиш: `parseHotkey('Mod+Shift+Z')`, `matchHotkey` (Mod = ⌘ / Ctrl, нелатинские раскладки по физической клавише), `formatHotkey` (`Ctrl+Shift+Z` / `⇧⌘Z`), `isReservedHotkey` (⌘W, ⌘T, ⌘Q…), `bindHotkeys` на элементе | DOM (для `bindHotkeys`) |
|
|
84
85
|
| `storage` | автосохранение в localStorage без исключений | нет |
|
|
85
86
|
| `file` | скачивание текста как файла, лимит размера | DOM |
|
|
86
87
|
| `snap` | мягкая привязка к сетке с порогом по масштабу камеры | нет |
|
|
@@ -93,6 +94,7 @@ import { History } from '@1337exp/taoux/history';
|
|
|
93
94
|
| `ease` | функции движения между точками кривой: 8 семейств × in / out / in-out, `linear`, `step`, кубический Безье; `easeValue`, `isEase` (редактор рисует ими, рантайм считает ими же) | нет |
|
|
94
95
|
| `num` | мелкая числовая математика: `clamp`, `roundTo`, `snapTo`, `niceStep`, `ticks` (общая для кривой, градиента и воспроизведения) | нет |
|
|
95
96
|
| `session` | жизненный цикл документа: история, автосохранение, файлы, восстановление, уведомления | vue (peer) |
|
|
97
|
+
| `commands` | реестр команд (подпись, сочетание, `enabled`, `checked`, `run`): `toMenu(layout)` строит дерево `TaoMenuItem[]` для `TaoMenubar` / `TaoContextMenu`, `bind` слушает те же сочетания, `historyCommands` даёт Undo / Redo, которые сами становятся недоступными, `check` находит занятые браузером и повторённые сочетания | DOM (для `bind`) |
|
|
96
98
|
| `palette` | поиск и группы нод для палитры | нет |
|
|
97
99
|
| `links` (Vue) | слой связей: SVG из готовой геометрии, `--tx-link-*` | vue (peer) |
|
|
98
100
|
| `canvas` (Vue) | холст: жесты мыши и сенсора, колесо, автопрокрутка, клавиши; контракт `CanvasHost` | vue (peer) |
|
|
@@ -103,10 +105,12 @@ import { History } from '@1337exp/taoux/history';
|
|
|
103
105
|
| `pins` | позиции пинов-строк, измеренные по DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
|
|
104
106
|
| `i18n` | типизированный i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, опционально) |
|
|
105
107
|
|
|
106
|
-
Vue-модули (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`) требуют явного импорта стилей: `import '@1337exp/taoux/canvas.css'`. Составные модули (session, palette, links, canvas, pins, curveeditor, gradienteditor, playback) импортируют только примитивы. Ярус 2, поля (`curvefield`), собирает составные модули в готовое поле на компонентах TaoUI: только ему можно импортировать TaoUI, поэтому `@1337exp/taoui` это необязательная peer-зависимость. Для `curvefield` нужны оба файла стилей, `curveeditor.css` и `curvefield.css`. Всё это охраняет тест `tiers.test.ts`; контракт холста описан в [docs/canvas.ru.md](docs/canvas.ru.md), переходы между точками кривой в [docs/ease.ru.md](docs/ease.ru.md).
|
|
108
|
+
Vue-модули (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`) требуют явного импорта стилей: `import '@1337exp/taoux/canvas.css'`. Составные модули (session, commands, palette, links, canvas, pins, curveeditor, gradienteditor, playback) импортируют только примитивы. Ярус 2, поля (`curvefield`), собирает составные модули в готовое поле на компонентах TaoUI: только ему можно импортировать TaoUI, поэтому `@1337exp/taoui` это необязательная peer-зависимость. Для `curvefield` нужны оба файла стилей, `curveeditor.css` и `curvefield.css`. Всё это охраняет тест `tiers.test.ts`; контракт холста описан в [docs/canvas.ru.md](docs/canvas.ru.md), переходы между точками кривой в [docs/ease.ru.md](docs/ease.ru.md).
|
|
107
109
|
|
|
108
110
|
Правило: модуль попадает сюда, когда он понадобился во втором проекте. Ядро модулей не знает про Vue и DOM, если это не их задача.
|
|
109
111
|
|
|
112
|
+
**Для ИИ-ассистентов:** в пакете есть skill, `skills/taoux/SKILL.md`: как модули стыкуются и каких ошибок избегать. Покажите его ассистенту (Claude Code: скопируйте папку в `.claude/skills/`).
|
|
113
|
+
|
|
110
114
|
## Разработка
|
|
111
115
|
|
|
112
116
|
```bash
|
|
@@ -632,7 +632,7 @@ var TaoxCurveEditor_default = /* @__PURE__ */ defineComponent({
|
|
|
632
632
|
(openBlock(true), createElementBlock(Fragment, null, renderList(labelsV.value, (v, i) => {
|
|
633
633
|
return openBlock(), createElementBlock("text", {
|
|
634
634
|
key: `lv${v}`,
|
|
635
|
-
class: normalizeClass(["tx-curve-label", { edge: i === 0 || i === labelsV.value.length - 1 }]),
|
|
635
|
+
class: normalizeClass(["tx-curve-label", { edge: v === 0 || i === 0 || i === labelsV.value.length - 1 }]),
|
|
636
636
|
x: 26,
|
|
637
637
|
y: py(v),
|
|
638
638
|
"text-anchor": "end",
|
|
@@ -756,4 +756,4 @@ var TaoxCurveEditor_default = /* @__PURE__ */ defineComponent({
|
|
|
756
756
|
//#endregion
|
|
757
757
|
export { sampleCurve as a, valueBounds as c, removePoint as i, addPoint as n, sampleSegment as o, movePoint as r, setEase as s, TaoxCurveEditor_default as t };
|
|
758
758
|
|
|
759
|
-
//# sourceMappingURL=curveeditor-
|
|
759
|
+
//# sourceMappingURL=curveeditor-F3XBWHPL.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"curveeditor-F3XBWHPL.js","names":["_openBlock","_createElementBlock","_withModifiers","_Fragment","_renderList","_normalizeClass","_toDisplayString","_createElementVNode","_createCommentVNode","_sfc_main"],"sources":["../../src/curveeditor/ops.ts","../../src/curveeditor/TaoxCurveEditor.vue","../../src/curveeditor/TaoxCurveEditor.vue"],"sourcesContent":["import { easeValue, type Ease } from '../ease';\r\nimport { clamp01 } from '../num';\r\n\r\n/**\r\n * A curve point: t in 0…1, v is the value. `ease` sets how to go from this point to the next (linear by default);\r\n * on the last point it has no effect.\r\n * Точка кривой: t в 0…1, v значение. `ease` задаёт, как идти от этой точки к следующей (по умолчанию линейно);\r\n * у последней точки он ни на что не влияет.\r\n */\r\n/**\r\n * Guides from the selected point to the axes: none, lines only, lines and values.\r\n * Направляющие от выбранной точки к осям: нет, только линии, линии и значения.\r\n */\r\nexport type CurveGuides = 'off' | 'lines' | 'values';\r\n\r\nexport interface CurvePoint {\r\n t: number;\r\n v: number;\r\n ease?: Ease;\r\n}\r\n\r\n/**\r\n * The curve value at t: beyond the end points it equals the end point, between them it follows the `ease` of the left point (linear without it).\r\n * Значение кривой в t: вне крайних точек равно крайней, между ними по переходу `ease` левой точки (без него линейно).\r\n */\r\nexport function sampleCurve(points: readonly CurvePoint[], t: number): number {\r\n const n = points.length;\r\n if (n === 0) return 0;\r\n const x = clamp01(t);\r\n if (x <= points[0]!.t) return points[0]!.v;\r\n if (x >= points[n - 1]!.t) return points[n - 1]!.v;\r\n for (let i = 1; i < n; i++) {\r\n const b = points[i]!;\r\n if (x <= b.t) {\r\n const a = points[i - 1]!;\r\n const span = b.t - a.t;\r\n return span <= 0 ? b.v : a.v + (b.v - a.v) * easeValue(a.ease, (x - a.t) / span);\r\n }\r\n }\r\n return points[n - 1]!.v;\r\n}\r\n\r\n/**\r\n * Moves point `i`: along t it stays between its neighbours (the order is kept), along v it is free.\r\n * Двигает точку `i`: по t она остаётся между соседями (порядок не нарушается), по v свободна.\r\n */\r\nexport function movePoint(points: readonly CurvePoint[], i: number, t: number, v: number): CurvePoint[] {\r\n const next = points.map((p) => ({ ...p }));\r\n const lo = i > 0 ? next[i - 1]!.t : 0;\r\n const hi = i < next.length - 1 ? next[i + 1]!.t : 1;\r\n next[i] = { ...next[i]!, t: Math.min(hi, Math.max(lo, clamp01(t))), v };\r\n return next;\r\n}\r\n\r\n/**\r\n * Adds a point at `t` with value `v` (the curve value at that point by default); returns the new list and the point index.\r\n * Добавляет точку в `t` со значением `v` (по умолчанию значение кривой в этой точке); возвращает новый список и индекс точки.\r\n */\r\nexport function addPoint(points: readonly CurvePoint[], t: number, v?: number): { points: CurvePoint[]; index: number } {\r\n const x = clamp01(t);\r\n const next = points.map((p) => ({ ...p }));\r\n const at = next.findIndex((p) => p.t > x);\r\n const index = at === -1 ? next.length : at;\r\n next.splice(index, 0, { t: x, v: v ?? sampleCurve(points, x) });\r\n return { points: next, index };\r\n}\r\n\r\n/**\r\n * Removes a point; never leaves fewer than two (a curve of one point is just a number).\r\n * Убирает точку; меньше двух точек не оставляет (кривая из одной точки это просто число).\r\n */\r\nexport function removePoint(points: readonly CurvePoint[], i: number): CurvePoint[] {\r\n if (points.length <= 2) return points.map((p) => ({ ...p }));\r\n return points.filter((_, k) => k !== i).map((p) => ({ ...p }));\r\n}\r\n\r\n/**\r\n * A segment transition that is neither a straight line nor a step: its shape has to be drawn and taken into account when choosing the view.\r\n * Переход участка, который не прямая и не ступенька: его форму нужно рисовать и учитывать при подборе вида.\r\n */\r\nconst curved = (e: Ease | undefined) => e !== undefined && e !== 'linear' && e !== 'step';\r\n\r\n/**\r\n * The polyline of segment a→b for drawing: a straight one has two ends, other transitions `steps` pieces (a step: a corner).\r\n * Ломаная участка a→b для рисования: у прямой два конца, у остальных переходов `steps` отрезков (ступенька: угол).\r\n */\r\nexport function sampleSegment(a: CurvePoint, b: CurvePoint, steps = 24): { t: number; v: number }[] {\r\n if (a.ease === 'step') return [{ t: a.t, v: a.v }, { t: b.t, v: a.v }, { t: b.t, v: b.v }];\r\n if (!curved(a.ease)) return [{ t: a.t, v: a.v }, { t: b.t, v: b.v }];\r\n const out: { t: number; v: number }[] = [];\r\n for (let i = 0; i <= steps; i++) {\r\n const u = i / steps;\r\n out.push({ t: a.t + (b.t - a.t) * u, v: a.v + (b.v - a.v) * easeValue(a.ease, u) });\r\n }\r\n return out;\r\n}\r\n\r\n/**\r\n * A copy of the list with the transition of point `i` (`undefined` and `linear` remove the field: the file stays short).\r\n * Копия списка с переходом точки `i` (`undefined` и `linear` убирают поле: файл остаётся коротким).\r\n */\r\nexport function setEase(points: readonly CurvePoint[], i: number, ease: Ease | undefined): CurvePoint[] {\r\n return points.map((p, k) => {\r\n if (k !== i) return { ...p };\r\n const { ease: _old, ...rest } = p;\r\n return ease === undefined || ease === 'linear' ? rest : { ...rest, ease };\r\n });\r\n}\r\n\r\n/**\r\n * Value limits for drawing: from 0 (or below the minimum) to the maximum with some headroom, no narrower than 0…1.\r\n * The given `min`/`max` (the field bounds) fix the view: the plot neither drifts nor leaves the allowed range.\r\n * Пределы значений для отрисовки: от 0 (или ниже минимума) до максимума с запасом, не уже чем 0…1.\r\n * Заданные `min`/`max` (границы поля) фиксируют вид: график не плывёт и не выходит за допустимое.\r\n */\r\nexport function valueBounds(points: readonly CurvePoint[], min?: number, max?: number): { min: number; max: number } {\r\n let lo = 0;\r\n let hi = 1;\r\n for (const p of points) {\r\n lo = Math.min(lo, p.v);\r\n hi = Math.max(hi, p.v);\r\n }\r\n // what goes beyond the point values (overshoot, handles): the field bounds are the allowed point values, but all of it has to be visible\r\n // то, что выходит за значения точек (заступ, ручки): границы поля это допустимые значения точек, а видеть это нужно всё\r\n let outLo = Infinity;\r\n let outHi = -Infinity;\r\n const see = (v: number) => {\r\n lo = Math.min(lo, v);\r\n hi = Math.max(hi, v);\r\n outLo = Math.min(outLo, v);\r\n outHi = Math.max(outHi, v);\r\n };\r\n // transitions with overshoot (back, elastic, Bezier) go beyond the point values: the view is chosen by the curve itself\r\n // переходы с заступом (back, elastic, Безье) выходят за значения точек: вид подбираем по самой кривой\r\n for (let i = 0; i < points.length - 1; i++) {\r\n const a = points[i]!;\r\n if (!curved(a.ease)) continue;\r\n // Bezier handles must fit the view too: otherwise a handle that went off the edge cannot be reached\r\n // ручки Безье тоже должны попадать в вид: иначе уехавшую за край ручку не достать\r\n if (typeof a.ease === 'object') {\r\n const dv = points[i + 1]!.v - a.v;\r\n for (const y of [a.ease.bezier[1], a.ease.bezier[3]]) see(a.v + y * dv);\r\n }\r\n for (const s of sampleSegment(points[i]!, points[i + 1]!)) see(s.v);\r\n }\r\n const auto = { min: lo, max: hi === lo ? lo + 1 : hi * 1.1 };\r\n // a given bound fixes the view, but overshoot and handles widen it: so they do not hide behind the edge\r\n // заданная граница фиксирует вид, но заступ и ручки её раздвигают: так они не прячутся за край\r\n const a = min === undefined ? auto.min : Math.min(min, outLo);\r\n const b = max === undefined ? auto.max : Math.max(max, outHi);\r\n return b > a ? { min: a, max: b } : { min: a, max: a + 1 };\r\n}\r\n","<script lang=\"ts\" setup>\r\nimport { computed, nextTick, onBeforeUnmount, ref } from 'vue';\r\nimport { createEdgeScroller } from '../edgescroll';\r\nimport { clampTo, niceStep, roundTo, snapTo, ticks } from '../num';\r\nimport { addPoint, movePoint, removePoint, sampleSegment, setEase, valueBounds, type CurveGuides, type CurvePoint } from './ops';\r\n\r\nconst props = withDefaults(\r\n defineProps<{\r\n /**\r\n * Curve points in ascending t (at least two).\r\n * Точки кривой по возрастанию t (минимум две).\r\n */\r\n modelValue: readonly CurvePoint[];\r\n /**\r\n * Index of the selected point.\r\n * Индекс выбранной точки.\r\n */\r\n selected?: number;\r\n /**\r\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\r\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\r\n */\r\n min?: number;\r\n max?: number;\r\n /**\r\n * How many decimals to keep in t and v; not set means do not round.\r\n * Сколько знаков после запятой оставлять у t и v; не задано — не обрезать.\r\n */\r\n precision?: number;\r\n /**\r\n * Snapping to the grid (Shift flips the mode for the moment).\r\n * Прилипание к сетке (Shift на время меняет режим).\r\n */\r\n snap?: boolean;\r\n /**\r\n * The time step and the distance between labelled lines.\r\n * Шаг по времени и расстояние между подписанными линиями.\r\n */\r\n stepT?: number;\r\n majorT?: number;\r\n /**\r\n * A hint on hover over the field.\r\n * Подсказка при наведении на поле.\r\n */\r\n hint?: string;\r\n /**\r\n * The point label for screen readers; \"Point 1: t, v\" by default.\r\n * Подпись точки для скринридеров; по умолчанию «Point 1: t, v».\r\n */\r\n pointLabel?: (index: number, point: CurvePoint) => string;\r\n /**\r\n * Guides from the selected point to the axes: `off` none, `lines` dashed lines only, `values` lines and the point values on the axes.\r\n * `lines` by default: noticeable, but not overloaded.\r\n * Направляющие от выбранной точки к осям: `off` нет, `lines` только пунктирные линии, `values` линии и значения точки на осях.\r\n * По умолчанию `lines`: заметно, но не перегружает.\r\n */\r\n guides?: CurveGuides;\r\n /**\r\n * The label of a Bezier handle for screen readers (n: 1 or 2); \"Bezier handle n\" by default.\r\n * Подпись ручки Безье для скринридеров (n: 1 или 2); по умолчанию «Bezier handle n».\r\n */\r\n handleLabel?: (n: number, index: number) => string;\r\n }>(),\r\n { selected: 0, snap: true, stepT: 0.05, majorT: 0.25, guides: 'lines' },\r\n);\r\nconst emit = defineEmits<{\r\n 'update:modelValue': [value: CurvePoint[]];\r\n 'update:selected': [index: number];\r\n /**\r\n * An edit is finished (a point was released, added, removed): the moment to record into history.\r\n * Правка закончена (отпустили точку, добавили, убрали): момент для записи в историю.\r\n */\r\n commit: [];\r\n}>();\r\n\r\nconst W = 280;\r\nconst H = 132;\r\nconst PAD_L = 30;\r\nconst PAD_R = 10;\r\nconst PAD_T = 10;\r\nconst PAD_B = 16;\r\nconst PLOT_W = W - PAD_L - PAD_R;\r\nconst PLOT_H = H - PAD_T - PAD_B;\r\n\r\nconst svg = ref<SVGSVGElement | null>(null);\r\n\r\nconst points = computed(() => props.modelValue);\r\n// The limits are remembered for the duration of a drag: otherwise the plot would \"float\" under the hand\r\n// Пределы запоминаем на время перетаскивания: иначе график «плыл» бы под рукой\r\nconst frozen = ref<{ min: number; max: number } | null>(null);\r\n// The view shift by value: accumulated by auto-scroll at the edge while a point is dragged\r\n// Сдвиг вида по значению: накапливает автопрокрутка у края, пока тянут точку\r\nconst shift = ref(0);\r\nconst bounds = computed(() => (frozen.value ? { min: frozen.value.min + shift.value, max: frozen.value.max + shift.value } : valueBounds(points.value, props.min, props.max)));\r\nconst span = computed(() => bounds.value.max - bounds.value.min);\r\n\r\nconst majorV = computed(() => niceStep(span.value, 4));\r\nconst stepV = computed(() => niceStep(span.value, 20));\r\nconst gridT = computed(() => ticks(0, 1, props.stepT));\r\nconst gridV = computed(() => ticks(bounds.value.min, bounds.value.max, stepV.value));\r\nconst labelsV = computed(() => ticks(bounds.value.min, bounds.value.max, majorV.value));\r\nconst labelsT = computed(() => ticks(0, 1, props.majorT));\r\nconst isMajorT = (x: number) => Math.abs(x / props.majorT - Math.round(x / props.majorT)) < 1e-6;\r\nconst isMajorV = (v: number) => Math.abs(v / majorV.value - Math.round(v / majorV.value)) < 1e-6;\r\n\r\nconst px = (tt: number) => PAD_L + tt * PLOT_W;\r\nconst py = (v: number) => PAD_T + (1 - (v - bounds.value.min) / span.value) * PLOT_H;\r\n// Segments are drawn by their transitions: a straight one has two ends, smooth ones dozens of pieces, a step a corner\r\n// Участки рисуются по своим переходам: у прямой два конца, у плавных десятки отрезков, у ступеньки угол\r\nconst path = computed(() => {\r\n const pts = points.value;\r\n const out: string[] = [];\r\n for (let i = 0; i < pts.length - 1; i++) {\r\n sampleSegment(pts[i]!, pts[i + 1]!).forEach((p, k) => out.push(`${i === 0 && k === 0 ? 'M' : 'L'} ${px(p.t).toFixed(1)} ${py(p.v).toFixed(1)}`));\r\n }\r\n return out.join(' ');\r\n});\r\nconst fmt = (n: number) => String(Math.round(n * 1000) / 1000);\r\n\r\n// The values of the selected point on the axes: time under the plot, value on the left. They show while the point is dragged, so there is no need to look for the fields.\r\n// Значения выбранной точки на осях: время под графиком, значение слева. Они видны, пока точку тянут, и не надо искать глазами поля.\r\nconst CHAR_W = 4.6;\r\nconst tagWidth = (text: string) => text.length * CHAR_W + 5;\r\nconst tags = computed(() => {\r\n const p = points.value[Math.min(props.selected, points.value.length - 1)];\r\n if (!p) return null;\r\n const t = fmt(p.t);\r\n const v = fmt(p.v);\r\n const wt = tagWidth(t);\r\n const wv = tagWidth(v);\r\n const cx = Math.min(W - wt / 2 - 1, Math.max(wt / 2 + 1, px(p.t)));\r\n const cy = Math.min(PAD_T + PLOT_H - 5, Math.max(PAD_T + 5, py(p.v)));\r\n return {\r\n x: px(p.t),\r\n y: py(p.v),\r\n t: { text: t, cx, w: wt },\r\n v: { text: v, cy, w: wv },\r\n };\r\n});\r\n\r\ninterface PointerSample {\r\n clientX: number;\r\n clientY: number;\r\n shiftKey: boolean;\r\n}\r\n\r\n/**\r\n * Pointer coordinates in curve units as they are: no snapping, rounding or bounds.\r\n * Координаты указателя в единицах кривой, как есть: без прилипания, округления и границ.\r\n */\r\nfunction rawCurve(e: PointerSample): { t: number; v: number } {\r\n const r = svg.value!.getBoundingClientRect();\r\n const x = ((e.clientX - r.left) / r.width) * W;\r\n const y = ((e.clientY - r.top) / r.height) * H;\r\n const { min, max } = bounds.value;\r\n return { t: (x - PAD_L) / PLOT_W, v: min + (1 - (y - PAD_T) / PLOT_H) * (max - min) };\r\n}\r\n\r\n/**\r\n * Pointer coordinates in curve units; Shift temporarily flips the snapping mode.\r\n * Координаты указателя в единицах кривой; Shift временно меняет режим шага.\r\n */\r\nfunction toCurve(e: PointerSample): { t: number; v: number } {\r\n let { t: tt, v } = rawCurve(e);\r\n if (props.snap !== e.shiftKey) {\r\n tt = snapTo(tt, props.stepT);\r\n v = snapTo(v, stepV.value);\r\n }\r\n return { t: roundTo(tt, props.precision), v: clampTo(roundTo(v, props.precision), props.min, props.max) };\r\n}\r\n\r\nlet dragging = -1;\r\nlet lastPointer: PointerSample = { clientX: 0, clientY: 0, shiftKey: false };\r\n\r\n/**\r\n * The point follows the pointer: both when it moves and when the view moved under a still pointer.\r\n * Точка идёт за указателем: и при его движении, и когда вид уехал под неподвижным указателем.\r\n */\r\nfunction followPointer() {\r\n if (dragging < 0) return;\r\n const { t: tt, v } = toCurve(lastPointer);\r\n emit('update:modelValue', movePoint(points.value, dragging, tt, v));\r\n}\r\n\r\n// Dragging a point to the top/bottom edge of the plot: the view by value follows (by time it is always 0…1).\r\n// The field bounds are not crossed: with min and max set the view stands still.\r\n// Тянем точку к верхнему/нижнему краю графика: вид по значению едет следом (по времени он всегда 0…1).\r\n// Границы поля не пересекаем: при заданных min и max вид стоит.\r\nconst scroller = createEdgeScroller({\r\n bounds: () => svg.value?.getBoundingClientRect() ?? null,\r\n pointer: () => [lastPointer.clientX, lastPointer.clientY],\r\n enabled: () => dragging >= 0,\r\n zone: 18,\r\n maxSpeed: 240,\r\n onScroll: (_dx, dy) => {\r\n const base = frozen.value;\r\n const r = svg.value?.getBoundingClientRect();\r\n if (!base || !r) return;\r\n // The visible area moved down by dy px: the view values decreased\r\n // Видимая область уехала вниз на dy px: значения вида уменьшились\r\n const dv = ((dy * H) / r.height / PLOT_H) * (base.max - base.min);\r\n const lo = props.min === undefined ? -Infinity : props.min - base.min;\r\n const hi = props.max === undefined ? Infinity : props.max - base.max;\r\n shift.value = Math.min(hi, Math.max(lo, shift.value - dv));\r\n followPointer();\r\n },\r\n});\r\nonBeforeUnmount(scroller.stop);\r\n\r\nfunction onDown(e: PointerEvent, i: number) {\r\n emit('update:selected', i);\r\n if (e.altKey) {\r\n emit('update:modelValue', removePoint(points.value, i));\r\n emit('update:selected', 0);\r\n emit('commit');\r\n return;\r\n }\r\n dragging = i;\r\n lastPointer = e;\r\n shift.value = 0;\r\n frozen.value = valueBounds(points.value, props.min, props.max);\r\n try {\r\n (e.currentTarget as Element).setPointerCapture(e.pointerId);\r\n } catch {\r\n // the pointer has already gone or the capture is unavailable: dragging works without it\r\n // указатель уже ушёл или захват недоступен: тянуть можно и без него\r\n }\r\n}\r\n\r\nfunction onMove(e: PointerEvent) {\r\n if (dragging < 0) return;\r\n lastPointer = e;\r\n followPointer();\r\n scroller.kick();\r\n}\r\n\r\nfunction onUp() {\r\n if (dragging < 0) return;\r\n dragging = -1;\r\n scroller.stop();\r\n frozen.value = null;\r\n shift.value = 0;\r\n emit('commit');\r\n}\r\n\r\n//--------------------------------------------------\r\n// Handles of the cubic Bezier curve of the selected segment\r\n// Ручки кубической кривой Безье у выбранного участка\r\n\r\n/**\r\n * The segment that starts at the selected point and follows a Bezier: only it has handles (and only if the segment has height).\r\n * Участок, который начинается в выбранной точке и идёт по Безье: ручки есть только у него (и только если у участка есть высота).\r\n */\r\nconst bezierSegment = computed(() => {\r\n const i = Math.min(props.selected, points.value.length - 1);\r\n const a = points.value[i];\r\n const b = points.value[i + 1];\r\n if (!a || !b || typeof a.ease !== 'object' || Math.abs(b.v - a.v) < 1e-9 || b.t - a.t <= 0) return null;\r\n return { i, a, b, bezier: a.ease.bezier };\r\n});\r\n\r\n/**\r\n * The two handles of the segment in plot coordinates.\r\n * Две ручки участка в координатах плота.\r\n */\r\nconst bezierHandles = computed(() => {\r\n const s = bezierSegment.value;\r\n if (!s) return [];\r\n const [x1, y1, x2, y2] = s.bezier;\r\n return [\r\n { n: 0, t: s.a.t + x1 * (s.b.t - s.a.t), v: s.a.v + y1 * (s.b.v - s.a.v), from: s.a },\r\n { n: 1, t: s.a.t + x2 * (s.b.t - s.a.t), v: s.a.v + y2 * (s.b.v - s.a.v), from: s.b },\r\n ];\r\n});\r\n\r\n/**\r\n * Starts of segments with a Bezier: the \"B\" mark is drawn above them.\r\n * Начала участков с Безье: над ними рисуется метка «B».\r\n */\r\nconst bezierMarks = computed(() => points.value.flatMap((p, i) => (typeof p.ease === 'object' && i < points.value.length - 1 ? [{ i, t: p.t, v: p.v }] : [])));\r\n\r\nconst round2 = (x: number) => Math.round(x * 100) / 100;\r\nconst BEZIER_STEP = 0.05;\r\n\r\n/**\r\n * Handle `n` is put at (x, y) of the normalised segment: x in 0…1, y free within reasonable limits (overshoot).\r\n * Ручка `n` ставится в (x, y) нормализованного участка: x в 0…1, y свободный в разумных пределах (заступ).\r\n */\r\nfunction setBezierHandle(n: 0 | 1, x: number, y: number, commitNow = false) {\r\n const s = bezierSegment.value;\r\n if (!s) return;\r\n const next: [number, number, number, number] = [...s.bezier];\r\n next[n * 2] = Math.min(1, Math.max(0, round2(x)));\r\n next[n * 2 + 1] = Math.min(3, Math.max(-2, round2(y)));\r\n emit('update:modelValue', setEase(points.value, s.i, { bezier: next }));\r\n if (commitNow) emit('commit');\r\n}\r\n\r\nlet handleDrag = -1;\r\n\r\nfunction onHandleDown(e: PointerEvent, n: number) {\r\n handleDrag = n;\r\n frozen.value = valueBounds(points.value, props.min, props.max);\r\n try {\r\n (e.currentTarget as Element).setPointerCapture(e.pointerId);\r\n } catch {\r\n // the pointer has already gone or the capture is unavailable: dragging works without it\r\n // указатель уже ушёл или захват недоступен: тянуть можно и без него\r\n }\r\n}\r\n\r\nfunction onHandleMove(e: PointerEvent) {\r\n const s = bezierSegment.value;\r\n if (handleDrag < 0 || !s) return;\r\n const { t, v } = rawCurve(e);\r\n setBezierHandle(handleDrag as 0 | 1, (t - s.a.t) / (s.b.t - s.a.t), (v - s.a.v) / (s.b.v - s.a.v));\r\n}\r\n\r\nfunction onHandleUp() {\r\n if (handleDrag < 0) return;\r\n handleDrag = -1;\r\n frozen.value = null;\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * Arrows on a handle move it by a step (Shift larger): left and right along x, up and down along y.\r\n * Стрелки на ручке сдвигают её на шаг (Shift крупнее): влево и вправо по x, вверх и вниз по y.\r\n */\r\nfunction onHandleKey(e: KeyboardEvent, n: number) {\r\n const s = bezierSegment.value;\r\n const arrows: Record<string, [number, number]> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] };\r\n const d = arrows[e.key];\r\n if (!s || !d) return;\r\n e.preventDefault();\r\n e.stopPropagation();\r\n const k = BEZIER_STEP * (e.shiftKey ? 5 : 1);\r\n setBezierHandle(n as 0 | 1, s.bezier[n * 2]! + d[0] * k, s.bezier[n * 2 + 1]! + d[1] * k, true);\r\n}\r\n\r\n/**\r\n * A double click on the plot must not select the page text around it.\r\n * Двойной клик по графику не должен выделять текст страницы вокруг.\r\n */\r\nfunction noSelect(e: MouseEvent) {\r\n if (e.detail > 1) e.preventDefault();\r\n}\r\n\r\nfunction onDouble(e: MouseEvent) {\r\n const { t: tt, v } = toCurve(e);\r\n const r = addPoint(points.value, tt, v);\r\n emit('update:selected', r.index);\r\n emit('update:modelValue', r.points);\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * The arrow step with Shift: this many times larger.\r\n * Шаг стрелки с Shift: во столько раз крупнее.\r\n */\r\nconst COARSE = 5;\r\n\r\n/**\r\n * Moves point `i` by `dx` steps in time and `dy` steps in value (grid steps), with snapping, rounding and bounds.\r\n * Сдвигает точку `i` на `dx` шагов по времени и `dy` шагов по значению (шаги сетки), с прижатием, округлением и границами.\r\n */\r\nfunction nudge(i: number, dx: number, dy: number, coarse: boolean) {\r\n const p = points.value[i];\r\n if (!p) return;\r\n const k = coarse ? COARSE : 1;\r\n const tt = roundTo(snapTo(p.t + dx * k * props.stepT, props.stepT), props.precision);\r\n const v = clampTo(roundTo(snapTo(p.v + dy * k * stepV.value, stepV.value), props.precision), props.min, props.max);\r\n emit('update:modelValue', movePoint(points.value, i, tt, v));\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * Insert adds a point between the selected one and the next (for the last: between it and the previous) on the curve itself.\r\n * Insert добавляет точку между выбранной и следующей (у последней: между ней и предыдущей) на самой кривой.\r\n */\r\n/**\r\n * Focus on point `i` after a re-render: keys go to the selected point, and focus must not stay on the old one.\r\n * Фокус на точку `i` после перерисовки: клавиши идут к той точке, что выбрана, и фокус не должен оставаться на старой.\r\n */\r\nfunction focusDot(i: number) {\r\n void nextTick(() => svg.value?.querySelectorAll<SVGElement>('.tx-curve-dot')[i]?.focus());\r\n}\r\n\r\nfunction insertAfter(i: number) {\r\n const a = points.value[i];\r\n const b = points.value[i + 1] ?? points.value[i - 1];\r\n if (!a || !b) return;\r\n const r = addPoint(points.value, roundTo((a.t + b.t) / 2, props.precision));\r\n emit('update:selected', r.index);\r\n emit('update:modelValue', r.points);\r\n emit('commit');\r\n focusDot(r.index);\r\n}\r\n\r\nfunction removeAt(i: number) {\r\n const next = Math.max(0, i - 1);\r\n emit('update:modelValue', removePoint(points.value, i));\r\n emit('update:selected', next);\r\n emit('commit');\r\n focusDot(next);\r\n}\r\n\r\n/**\r\n * Point keys (focus on it): arrows move by a grid step, Shift larger; Insert adds, Delete removes.\r\n * Клавиши точки (фокус на ней): стрелки двигают на шаг сетки, Shift крупнее; Insert добавляет, Delete убирает.\r\n */\r\nfunction onKey(e: KeyboardEvent) {\r\n // the point that has focus; if the key came from the field itself (after a click on it), then the selected one\r\n // точка, на которой фокус; если клавиша пришла с самого поля (после клика по нему), то выбранная\r\n const target = (e.target as Element | null)?.closest('.tx-curve-dot');\r\n const index = target ? Number(target.getAttribute('data-index')) : NaN;\r\n const i = Number.isInteger(index) ? index : Math.min(props.selected, points.value.length - 1);\r\n const arrows: Record<string, [number, number]> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] };\r\n const move = arrows[e.key];\r\n if (move) {\r\n e.preventDefault();\r\n nudge(i, move[0], move[1], e.shiftKey);\r\n } else if (e.key === 'Insert') {\r\n e.preventDefault();\r\n insertAfter(i);\r\n } else if (e.key === 'Delete' || e.key === 'Backspace') {\r\n e.preventDefault();\r\n removeAt(i);\r\n }\r\n}\r\n\r\nconst labelOf = (i: number, p: CurvePoint) => (props.pointLabel ? props.pointLabel(i, p) : `Point ${i + 1}: ${fmt(p.t)}, ${fmt(p.v)}`);\r\n</script>\r\n\r\n<template>\r\n <svg ref=\"svg\" class=\"tx-curve\" :viewBox=\"`0 0 ${W} ${H}`\" :title=\"hint\" tabindex=\"-1\" role=\"group\" @dblclick.self=\"onDouble\" @mousedown=\"noSelect\" @keydown=\"onKey\">\r\n <!-- fine grid: the same steps as snapping / мелкая сетка: те же шаги, что у прилипания -->\r\n <line v-for=\"x in gridT\" :key=\"`gt${x}`\" class=\"tx-curve-grid\" :class=\"{ major: isMajorT(x) }\" :x1=\"px(x)\" :x2=\"px(x)\" :y1=\"PAD_T\" :y2=\"H - PAD_B\" />\r\n <line v-for=\"v in gridV\" :key=\"`gv${v}`\" class=\"tx-curve-grid\" :class=\"{ major: isMajorV(v) }\" :x1=\"PAD_L\" :x2=\"W - PAD_R\" :y1=\"py(v)\" :y2=\"py(v)\" />\r\n\r\n <text v-for=\"(v, i) in labelsV\" :key=\"`lv${v}`\" class=\"tx-curve-label\" :class=\"{ edge: v === 0 || i === 0 || i === labelsV.length - 1 }\" :x=\"PAD_L - 4\" :y=\"py(v)\" text-anchor=\"end\" dominant-baseline=\"middle\">{{ fmt(v) }}</text>\r\n <text v-for=\"x in labelsT\" :key=\"`lt${x}`\" class=\"tx-curve-label\" :class=\"{ edge: x === 0 || x === 1 }\" :x=\"px(x)\" :y=\"H - 4\" :text-anchor=\"x === 0 ? 'start' : x === 1 ? 'end' : 'middle'\">{{ fmt(x) }}</text>\r\n\r\n <g v-if=\"tags && guides !== 'off'\" class=\"tx-curve-tags\" aria-hidden=\"true\">\r\n <line class=\"tx-curve-guide\" :x1=\"tags.x\" :x2=\"tags.x\" :y1=\"tags.y\" :y2=\"PAD_T + PLOT_H\" />\r\n <line class=\"tx-curve-guide\" :x1=\"PAD_L\" :x2=\"tags.x\" :y1=\"tags.y\" :y2=\"tags.y\" />\r\n <template v-if=\"guides === 'values'\">\r\n <rect class=\"tx-curve-tag-bg\" :x=\"tags.t.cx - tags.t.w / 2\" :y=\"H - 12\" :width=\"tags.t.w\" height=\"11\" rx=\"2\" />\r\n <text class=\"tx-curve-tag\" :x=\"tags.t.cx\" :y=\"H - 4\" text-anchor=\"middle\">{{ tags.t.text }}</text>\r\n <rect class=\"tx-curve-tag-bg\" :x=\"PAD_L - 3 - tags.v.w\" :y=\"tags.v.cy - 5.5\" :width=\"tags.v.w\" height=\"11\" rx=\"2\" />\r\n <text class=\"tx-curve-tag\" :x=\"PAD_L - 5\" :y=\"tags.v.cy\" text-anchor=\"end\" dominant-baseline=\"middle\">{{ tags.v.text }}</text>\r\n </template>\r\n </g>\r\n\r\n <path class=\"tx-curve-line\" :d=\"path\" />\r\n\r\n <!-- The \"B\" mark above the start of a Bezier segment: shows the point has handles even when it is not selected / Метка «B» над началом участка с Безье: видно, что у точки есть ручки, даже когда она не выбрана -->\r\n <text v-for=\"m in bezierMarks\" :key=\"`b${m.i}`\" class=\"tx-curve-mark\" :x=\"px(m.t)\" :y=\"py(m.v) - 8\" text-anchor=\"middle\" aria-hidden=\"true\">B</text>\r\n\r\n <g v-if=\"bezierHandles.length\" class=\"tx-curve-bezier\">\r\n <template v-for=\"h in bezierHandles\" :key=\"h.n\">\r\n <line class=\"tx-curve-arm\" :x1=\"px(h.from.t)\" :y1=\"py(h.from.v)\" :x2=\"px(h.t)\" :y2=\"py(h.v)\" />\r\n <circle\r\n class=\"tx-curve-handle\"\r\n :cx=\"px(h.t)\"\r\n :cy=\"py(h.v)\"\r\n r=\"4\"\r\n tabindex=\"0\"\r\n role=\"slider\"\r\n :aria-label=\"handleLabel ? handleLabel(h.n + 1, bezierSegment!.i) : `Bezier handle ${h.n + 1}`\"\r\n @pointerdown.stop=\"onHandleDown($event, h.n)\"\r\n @pointermove=\"onHandleMove\"\r\n @pointerup=\"onHandleUp\"\r\n @pointercancel=\"onHandleUp\"\r\n @keydown=\"onHandleKey($event, h.n)\"\r\n />\r\n </template>\r\n </g>\r\n <circle\r\n v-for=\"(p, i) in points\"\r\n :key=\"i\"\r\n class=\"tx-curve-dot\"\r\n :class=\"{ on: i === selected }\"\r\n :cx=\"px(p.t)\"\r\n :cy=\"py(p.v)\"\r\n r=\"5\"\r\n :data-index=\"i\"\r\n tabindex=\"0\"\r\n role=\"button\"\r\n :aria-label=\"labelOf(i, p)\"\r\n @focus=\"emit('update:selected', i)\"\r\n @pointerdown.stop=\"onDown($event, i)\"\r\n @pointermove=\"onMove\"\r\n @pointerup=\"onUp\"\r\n @pointercancel=\"onUp\"\r\n />\r\n </svg>\r\n</template>\r\n\r\n<style>\r\n/*\r\n * Configured with CSS variables on any ancestor:\r\n * Настройка через CSS-переменные на любом предке:\r\n * --tx-curve-bg, --tx-curve-border, --tx-curve-grid, --tx-curve-label, --tx-curve-accent,\r\n * --tx-curve-text (the numbers at the ends of the axes: start and end of the scale, brighter than the rest),\r\n * --tx-curve-dot-opacity (opacity of unselected points, 0.3 by default).\r\n * --tx-curve-text (цифры у краёв осей: начало и конец шкалы, ярче остальных),\r\n * --tx-curve-dot-opacity (непрозрачность невыбранных точек, по умолчанию 0.3).\r\n */\r\n.tx-curve {\r\n display: block;\r\n width: 100%;\r\n height: auto;\r\n border: 1px solid var(--tx-curve-border, #2a2d33);\r\n border-radius: 4px;\r\n background: var(--tx-curve-bg, #15171b);\r\n touch-action: none;\r\n user-select: none;\r\n outline: none;\r\n}\r\n\r\n.tx-curve-grid {\r\n pointer-events: none; /* otherwise a double click hits the grid line, not the field / иначе двойной клик попадает в линию сетки, а не в поле */\r\n stroke: var(--tx-curve-grid, #2a2d33);\r\n stroke-width: 0.5;\r\n opacity: 0.45;\r\n}\r\n\r\n.tx-curve-grid.major {\r\n stroke-width: 1;\r\n opacity: 1;\r\n}\r\n\r\n.tx-curve-guide {\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 1;\r\n stroke-dasharray: 2 3;\r\n opacity: 0.45;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-tag-bg {\r\n fill: var(--tx-curve-bg, #15171b);\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-tag {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n font-size: 8px;\r\n font-weight: 700;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-label.edge {\r\n fill: var(--tx-curve-text, #d6d9e0);\r\n}\r\n\r\n.tx-curve-label {\r\n fill: var(--tx-curve-label, #8b929c);\r\n font-size: 8px;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-line {\r\n fill: none;\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 2;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-mark {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n font: 600 9px/1 system-ui, sans-serif;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-arm {\r\n stroke: var(--tx-curve-label, #8b929c);\r\n stroke-width: 1;\r\n stroke-dasharray: 3 2;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-handle {\r\n fill: var(--tx-curve-label, #8b929c);\r\n stroke: var(--tx-curve-bg, #15171b);\r\n stroke-width: 1.5;\r\n cursor: grab;\r\n}\r\n\r\n.tx-curve-handle:active {\r\n cursor: grabbing;\r\n}\r\n\r\n.tx-curve-handle:hover,\r\n.tx-curve-handle:focus-visible {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n outline: none;\r\n}\r\n\r\n.tx-curve-dot {\r\n fill: var(--tx-curve-bg, #15171b);\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 2;\r\n opacity: var(--tx-curve-dot-opacity, 0.3);\r\n cursor: grab;\r\n}\r\n\r\n.tx-curve-dot:active {\r\n cursor: grabbing;\r\n}\r\n\r\n.tx-curve-dot:focus {\r\n outline: none;\r\n}\r\n\r\n/* keyboard focus: a thicker outline and a glow (browsers draw the outline of SVG shapes differently) / фокус с клавиатуры: утолщённая обводка и свечение (контур у SVG-форм браузеры рисуют по-разному) */\r\n.tx-curve-dot:focus-visible {\r\n stroke-width: 3;\r\n filter: drop-shadow(0 0 3px var(--tx-curve-accent, #4fc3f7));\r\n opacity: 1;\r\n}\r\n\r\n.tx-curve-dot.on,\r\n.tx-curve-dot:hover {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n opacity: 1;\r\n}\r\n</style>\r\n","<script lang=\"ts\" setup>\r\nimport { computed, nextTick, onBeforeUnmount, ref } from 'vue';\r\nimport { createEdgeScroller } from '../edgescroll';\r\nimport { clampTo, niceStep, roundTo, snapTo, ticks } from '../num';\r\nimport { addPoint, movePoint, removePoint, sampleSegment, setEase, valueBounds, type CurveGuides, type CurvePoint } from './ops';\r\n\r\nconst props = withDefaults(\r\n defineProps<{\r\n /**\r\n * Curve points in ascending t (at least two).\r\n * Точки кривой по возрастанию t (минимум две).\r\n */\r\n modelValue: readonly CurvePoint[];\r\n /**\r\n * Index of the selected point.\r\n * Индекс выбранной точки.\r\n */\r\n selected?: number;\r\n /**\r\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\r\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\r\n */\r\n min?: number;\r\n max?: number;\r\n /**\r\n * How many decimals to keep in t and v; not set means do not round.\r\n * Сколько знаков после запятой оставлять у t и v; не задано — не обрезать.\r\n */\r\n precision?: number;\r\n /**\r\n * Snapping to the grid (Shift flips the mode for the moment).\r\n * Прилипание к сетке (Shift на время меняет режим).\r\n */\r\n snap?: boolean;\r\n /**\r\n * The time step and the distance between labelled lines.\r\n * Шаг по времени и расстояние между подписанными линиями.\r\n */\r\n stepT?: number;\r\n majorT?: number;\r\n /**\r\n * A hint on hover over the field.\r\n * Подсказка при наведении на поле.\r\n */\r\n hint?: string;\r\n /**\r\n * The point label for screen readers; \"Point 1: t, v\" by default.\r\n * Подпись точки для скринридеров; по умолчанию «Point 1: t, v».\r\n */\r\n pointLabel?: (index: number, point: CurvePoint) => string;\r\n /**\r\n * Guides from the selected point to the axes: `off` none, `lines` dashed lines only, `values` lines and the point values on the axes.\r\n * `lines` by default: noticeable, but not overloaded.\r\n * Направляющие от выбранной точки к осям: `off` нет, `lines` только пунктирные линии, `values` линии и значения точки на осях.\r\n * По умолчанию `lines`: заметно, но не перегружает.\r\n */\r\n guides?: CurveGuides;\r\n /**\r\n * The label of a Bezier handle for screen readers (n: 1 or 2); \"Bezier handle n\" by default.\r\n * Подпись ручки Безье для скринридеров (n: 1 или 2); по умолчанию «Bezier handle n».\r\n */\r\n handleLabel?: (n: number, index: number) => string;\r\n }>(),\r\n { selected: 0, snap: true, stepT: 0.05, majorT: 0.25, guides: 'lines' },\r\n);\r\nconst emit = defineEmits<{\r\n 'update:modelValue': [value: CurvePoint[]];\r\n 'update:selected': [index: number];\r\n /**\r\n * An edit is finished (a point was released, added, removed): the moment to record into history.\r\n * Правка закончена (отпустили точку, добавили, убрали): момент для записи в историю.\r\n */\r\n commit: [];\r\n}>();\r\n\r\nconst W = 280;\r\nconst H = 132;\r\nconst PAD_L = 30;\r\nconst PAD_R = 10;\r\nconst PAD_T = 10;\r\nconst PAD_B = 16;\r\nconst PLOT_W = W - PAD_L - PAD_R;\r\nconst PLOT_H = H - PAD_T - PAD_B;\r\n\r\nconst svg = ref<SVGSVGElement | null>(null);\r\n\r\nconst points = computed(() => props.modelValue);\r\n// The limits are remembered for the duration of a drag: otherwise the plot would \"float\" under the hand\r\n// Пределы запоминаем на время перетаскивания: иначе график «плыл» бы под рукой\r\nconst frozen = ref<{ min: number; max: number } | null>(null);\r\n// The view shift by value: accumulated by auto-scroll at the edge while a point is dragged\r\n// Сдвиг вида по значению: накапливает автопрокрутка у края, пока тянут точку\r\nconst shift = ref(0);\r\nconst bounds = computed(() => (frozen.value ? { min: frozen.value.min + shift.value, max: frozen.value.max + shift.value } : valueBounds(points.value, props.min, props.max)));\r\nconst span = computed(() => bounds.value.max - bounds.value.min);\r\n\r\nconst majorV = computed(() => niceStep(span.value, 4));\r\nconst stepV = computed(() => niceStep(span.value, 20));\r\nconst gridT = computed(() => ticks(0, 1, props.stepT));\r\nconst gridV = computed(() => ticks(bounds.value.min, bounds.value.max, stepV.value));\r\nconst labelsV = computed(() => ticks(bounds.value.min, bounds.value.max, majorV.value));\r\nconst labelsT = computed(() => ticks(0, 1, props.majorT));\r\nconst isMajorT = (x: number) => Math.abs(x / props.majorT - Math.round(x / props.majorT)) < 1e-6;\r\nconst isMajorV = (v: number) => Math.abs(v / majorV.value - Math.round(v / majorV.value)) < 1e-6;\r\n\r\nconst px = (tt: number) => PAD_L + tt * PLOT_W;\r\nconst py = (v: number) => PAD_T + (1 - (v - bounds.value.min) / span.value) * PLOT_H;\r\n// Segments are drawn by their transitions: a straight one has two ends, smooth ones dozens of pieces, a step a corner\r\n// Участки рисуются по своим переходам: у прямой два конца, у плавных десятки отрезков, у ступеньки угол\r\nconst path = computed(() => {\r\n const pts = points.value;\r\n const out: string[] = [];\r\n for (let i = 0; i < pts.length - 1; i++) {\r\n sampleSegment(pts[i]!, pts[i + 1]!).forEach((p, k) => out.push(`${i === 0 && k === 0 ? 'M' : 'L'} ${px(p.t).toFixed(1)} ${py(p.v).toFixed(1)}`));\r\n }\r\n return out.join(' ');\r\n});\r\nconst fmt = (n: number) => String(Math.round(n * 1000) / 1000);\r\n\r\n// The values of the selected point on the axes: time under the plot, value on the left. They show while the point is dragged, so there is no need to look for the fields.\r\n// Значения выбранной точки на осях: время под графиком, значение слева. Они видны, пока точку тянут, и не надо искать глазами поля.\r\nconst CHAR_W = 4.6;\r\nconst tagWidth = (text: string) => text.length * CHAR_W + 5;\r\nconst tags = computed(() => {\r\n const p = points.value[Math.min(props.selected, points.value.length - 1)];\r\n if (!p) return null;\r\n const t = fmt(p.t);\r\n const v = fmt(p.v);\r\n const wt = tagWidth(t);\r\n const wv = tagWidth(v);\r\n const cx = Math.min(W - wt / 2 - 1, Math.max(wt / 2 + 1, px(p.t)));\r\n const cy = Math.min(PAD_T + PLOT_H - 5, Math.max(PAD_T + 5, py(p.v)));\r\n return {\r\n x: px(p.t),\r\n y: py(p.v),\r\n t: { text: t, cx, w: wt },\r\n v: { text: v, cy, w: wv },\r\n };\r\n});\r\n\r\ninterface PointerSample {\r\n clientX: number;\r\n clientY: number;\r\n shiftKey: boolean;\r\n}\r\n\r\n/**\r\n * Pointer coordinates in curve units as they are: no snapping, rounding or bounds.\r\n * Координаты указателя в единицах кривой, как есть: без прилипания, округления и границ.\r\n */\r\nfunction rawCurve(e: PointerSample): { t: number; v: number } {\r\n const r = svg.value!.getBoundingClientRect();\r\n const x = ((e.clientX - r.left) / r.width) * W;\r\n const y = ((e.clientY - r.top) / r.height) * H;\r\n const { min, max } = bounds.value;\r\n return { t: (x - PAD_L) / PLOT_W, v: min + (1 - (y - PAD_T) / PLOT_H) * (max - min) };\r\n}\r\n\r\n/**\r\n * Pointer coordinates in curve units; Shift temporarily flips the snapping mode.\r\n * Координаты указателя в единицах кривой; Shift временно меняет режим шага.\r\n */\r\nfunction toCurve(e: PointerSample): { t: number; v: number } {\r\n let { t: tt, v } = rawCurve(e);\r\n if (props.snap !== e.shiftKey) {\r\n tt = snapTo(tt, props.stepT);\r\n v = snapTo(v, stepV.value);\r\n }\r\n return { t: roundTo(tt, props.precision), v: clampTo(roundTo(v, props.precision), props.min, props.max) };\r\n}\r\n\r\nlet dragging = -1;\r\nlet lastPointer: PointerSample = { clientX: 0, clientY: 0, shiftKey: false };\r\n\r\n/**\r\n * The point follows the pointer: both when it moves and when the view moved under a still pointer.\r\n * Точка идёт за указателем: и при его движении, и когда вид уехал под неподвижным указателем.\r\n */\r\nfunction followPointer() {\r\n if (dragging < 0) return;\r\n const { t: tt, v } = toCurve(lastPointer);\r\n emit('update:modelValue', movePoint(points.value, dragging, tt, v));\r\n}\r\n\r\n// Dragging a point to the top/bottom edge of the plot: the view by value follows (by time it is always 0…1).\r\n// The field bounds are not crossed: with min and max set the view stands still.\r\n// Тянем точку к верхнему/нижнему краю графика: вид по значению едет следом (по времени он всегда 0…1).\r\n// Границы поля не пересекаем: при заданных min и max вид стоит.\r\nconst scroller = createEdgeScroller({\r\n bounds: () => svg.value?.getBoundingClientRect() ?? null,\r\n pointer: () => [lastPointer.clientX, lastPointer.clientY],\r\n enabled: () => dragging >= 0,\r\n zone: 18,\r\n maxSpeed: 240,\r\n onScroll: (_dx, dy) => {\r\n const base = frozen.value;\r\n const r = svg.value?.getBoundingClientRect();\r\n if (!base || !r) return;\r\n // The visible area moved down by dy px: the view values decreased\r\n // Видимая область уехала вниз на dy px: значения вида уменьшились\r\n const dv = ((dy * H) / r.height / PLOT_H) * (base.max - base.min);\r\n const lo = props.min === undefined ? -Infinity : props.min - base.min;\r\n const hi = props.max === undefined ? Infinity : props.max - base.max;\r\n shift.value = Math.min(hi, Math.max(lo, shift.value - dv));\r\n followPointer();\r\n },\r\n});\r\nonBeforeUnmount(scroller.stop);\r\n\r\nfunction onDown(e: PointerEvent, i: number) {\r\n emit('update:selected', i);\r\n if (e.altKey) {\r\n emit('update:modelValue', removePoint(points.value, i));\r\n emit('update:selected', 0);\r\n emit('commit');\r\n return;\r\n }\r\n dragging = i;\r\n lastPointer = e;\r\n shift.value = 0;\r\n frozen.value = valueBounds(points.value, props.min, props.max);\r\n try {\r\n (e.currentTarget as Element).setPointerCapture(e.pointerId);\r\n } catch {\r\n // the pointer has already gone or the capture is unavailable: dragging works without it\r\n // указатель уже ушёл или захват недоступен: тянуть можно и без него\r\n }\r\n}\r\n\r\nfunction onMove(e: PointerEvent) {\r\n if (dragging < 0) return;\r\n lastPointer = e;\r\n followPointer();\r\n scroller.kick();\r\n}\r\n\r\nfunction onUp() {\r\n if (dragging < 0) return;\r\n dragging = -1;\r\n scroller.stop();\r\n frozen.value = null;\r\n shift.value = 0;\r\n emit('commit');\r\n}\r\n\r\n//--------------------------------------------------\r\n// Handles of the cubic Bezier curve of the selected segment\r\n// Ручки кубической кривой Безье у выбранного участка\r\n\r\n/**\r\n * The segment that starts at the selected point and follows a Bezier: only it has handles (and only if the segment has height).\r\n * Участок, который начинается в выбранной точке и идёт по Безье: ручки есть только у него (и только если у участка есть высота).\r\n */\r\nconst bezierSegment = computed(() => {\r\n const i = Math.min(props.selected, points.value.length - 1);\r\n const a = points.value[i];\r\n const b = points.value[i + 1];\r\n if (!a || !b || typeof a.ease !== 'object' || Math.abs(b.v - a.v) < 1e-9 || b.t - a.t <= 0) return null;\r\n return { i, a, b, bezier: a.ease.bezier };\r\n});\r\n\r\n/**\r\n * The two handles of the segment in plot coordinates.\r\n * Две ручки участка в координатах плота.\r\n */\r\nconst bezierHandles = computed(() => {\r\n const s = bezierSegment.value;\r\n if (!s) return [];\r\n const [x1, y1, x2, y2] = s.bezier;\r\n return [\r\n { n: 0, t: s.a.t + x1 * (s.b.t - s.a.t), v: s.a.v + y1 * (s.b.v - s.a.v), from: s.a },\r\n { n: 1, t: s.a.t + x2 * (s.b.t - s.a.t), v: s.a.v + y2 * (s.b.v - s.a.v), from: s.b },\r\n ];\r\n});\r\n\r\n/**\r\n * Starts of segments with a Bezier: the \"B\" mark is drawn above them.\r\n * Начала участков с Безье: над ними рисуется метка «B».\r\n */\r\nconst bezierMarks = computed(() => points.value.flatMap((p, i) => (typeof p.ease === 'object' && i < points.value.length - 1 ? [{ i, t: p.t, v: p.v }] : [])));\r\n\r\nconst round2 = (x: number) => Math.round(x * 100) / 100;\r\nconst BEZIER_STEP = 0.05;\r\n\r\n/**\r\n * Handle `n` is put at (x, y) of the normalised segment: x in 0…1, y free within reasonable limits (overshoot).\r\n * Ручка `n` ставится в (x, y) нормализованного участка: x в 0…1, y свободный в разумных пределах (заступ).\r\n */\r\nfunction setBezierHandle(n: 0 | 1, x: number, y: number, commitNow = false) {\r\n const s = bezierSegment.value;\r\n if (!s) return;\r\n const next: [number, number, number, number] = [...s.bezier];\r\n next[n * 2] = Math.min(1, Math.max(0, round2(x)));\r\n next[n * 2 + 1] = Math.min(3, Math.max(-2, round2(y)));\r\n emit('update:modelValue', setEase(points.value, s.i, { bezier: next }));\r\n if (commitNow) emit('commit');\r\n}\r\n\r\nlet handleDrag = -1;\r\n\r\nfunction onHandleDown(e: PointerEvent, n: number) {\r\n handleDrag = n;\r\n frozen.value = valueBounds(points.value, props.min, props.max);\r\n try {\r\n (e.currentTarget as Element).setPointerCapture(e.pointerId);\r\n } catch {\r\n // the pointer has already gone or the capture is unavailable: dragging works without it\r\n // указатель уже ушёл или захват недоступен: тянуть можно и без него\r\n }\r\n}\r\n\r\nfunction onHandleMove(e: PointerEvent) {\r\n const s = bezierSegment.value;\r\n if (handleDrag < 0 || !s) return;\r\n const { t, v } = rawCurve(e);\r\n setBezierHandle(handleDrag as 0 | 1, (t - s.a.t) / (s.b.t - s.a.t), (v - s.a.v) / (s.b.v - s.a.v));\r\n}\r\n\r\nfunction onHandleUp() {\r\n if (handleDrag < 0) return;\r\n handleDrag = -1;\r\n frozen.value = null;\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * Arrows on a handle move it by a step (Shift larger): left and right along x, up and down along y.\r\n * Стрелки на ручке сдвигают её на шаг (Shift крупнее): влево и вправо по x, вверх и вниз по y.\r\n */\r\nfunction onHandleKey(e: KeyboardEvent, n: number) {\r\n const s = bezierSegment.value;\r\n const arrows: Record<string, [number, number]> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] };\r\n const d = arrows[e.key];\r\n if (!s || !d) return;\r\n e.preventDefault();\r\n e.stopPropagation();\r\n const k = BEZIER_STEP * (e.shiftKey ? 5 : 1);\r\n setBezierHandle(n as 0 | 1, s.bezier[n * 2]! + d[0] * k, s.bezier[n * 2 + 1]! + d[1] * k, true);\r\n}\r\n\r\n/**\r\n * A double click on the plot must not select the page text around it.\r\n * Двойной клик по графику не должен выделять текст страницы вокруг.\r\n */\r\nfunction noSelect(e: MouseEvent) {\r\n if (e.detail > 1) e.preventDefault();\r\n}\r\n\r\nfunction onDouble(e: MouseEvent) {\r\n const { t: tt, v } = toCurve(e);\r\n const r = addPoint(points.value, tt, v);\r\n emit('update:selected', r.index);\r\n emit('update:modelValue', r.points);\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * The arrow step with Shift: this many times larger.\r\n * Шаг стрелки с Shift: во столько раз крупнее.\r\n */\r\nconst COARSE = 5;\r\n\r\n/**\r\n * Moves point `i` by `dx` steps in time and `dy` steps in value (grid steps), with snapping, rounding and bounds.\r\n * Сдвигает точку `i` на `dx` шагов по времени и `dy` шагов по значению (шаги сетки), с прижатием, округлением и границами.\r\n */\r\nfunction nudge(i: number, dx: number, dy: number, coarse: boolean) {\r\n const p = points.value[i];\r\n if (!p) return;\r\n const k = coarse ? COARSE : 1;\r\n const tt = roundTo(snapTo(p.t + dx * k * props.stepT, props.stepT), props.precision);\r\n const v = clampTo(roundTo(snapTo(p.v + dy * k * stepV.value, stepV.value), props.precision), props.min, props.max);\r\n emit('update:modelValue', movePoint(points.value, i, tt, v));\r\n emit('commit');\r\n}\r\n\r\n/**\r\n * Insert adds a point between the selected one and the next (for the last: between it and the previous) on the curve itself.\r\n * Insert добавляет точку между выбранной и следующей (у последней: между ней и предыдущей) на самой кривой.\r\n */\r\n/**\r\n * Focus on point `i` after a re-render: keys go to the selected point, and focus must not stay on the old one.\r\n * Фокус на точку `i` после перерисовки: клавиши идут к той точке, что выбрана, и фокус не должен оставаться на старой.\r\n */\r\nfunction focusDot(i: number) {\r\n void nextTick(() => svg.value?.querySelectorAll<SVGElement>('.tx-curve-dot')[i]?.focus());\r\n}\r\n\r\nfunction insertAfter(i: number) {\r\n const a = points.value[i];\r\n const b = points.value[i + 1] ?? points.value[i - 1];\r\n if (!a || !b) return;\r\n const r = addPoint(points.value, roundTo((a.t + b.t) / 2, props.precision));\r\n emit('update:selected', r.index);\r\n emit('update:modelValue', r.points);\r\n emit('commit');\r\n focusDot(r.index);\r\n}\r\n\r\nfunction removeAt(i: number) {\r\n const next = Math.max(0, i - 1);\r\n emit('update:modelValue', removePoint(points.value, i));\r\n emit('update:selected', next);\r\n emit('commit');\r\n focusDot(next);\r\n}\r\n\r\n/**\r\n * Point keys (focus on it): arrows move by a grid step, Shift larger; Insert adds, Delete removes.\r\n * Клавиши точки (фокус на ней): стрелки двигают на шаг сетки, Shift крупнее; Insert добавляет, Delete убирает.\r\n */\r\nfunction onKey(e: KeyboardEvent) {\r\n // the point that has focus; if the key came from the field itself (after a click on it), then the selected one\r\n // точка, на которой фокус; если клавиша пришла с самого поля (после клика по нему), то выбранная\r\n const target = (e.target as Element | null)?.closest('.tx-curve-dot');\r\n const index = target ? Number(target.getAttribute('data-index')) : NaN;\r\n const i = Number.isInteger(index) ? index : Math.min(props.selected, points.value.length - 1);\r\n const arrows: Record<string, [number, number]> = { ArrowLeft: [-1, 0], ArrowRight: [1, 0], ArrowUp: [0, 1], ArrowDown: [0, -1] };\r\n const move = arrows[e.key];\r\n if (move) {\r\n e.preventDefault();\r\n nudge(i, move[0], move[1], e.shiftKey);\r\n } else if (e.key === 'Insert') {\r\n e.preventDefault();\r\n insertAfter(i);\r\n } else if (e.key === 'Delete' || e.key === 'Backspace') {\r\n e.preventDefault();\r\n removeAt(i);\r\n }\r\n}\r\n\r\nconst labelOf = (i: number, p: CurvePoint) => (props.pointLabel ? props.pointLabel(i, p) : `Point ${i + 1}: ${fmt(p.t)}, ${fmt(p.v)}`);\r\n</script>\r\n\r\n<template>\r\n <svg ref=\"svg\" class=\"tx-curve\" :viewBox=\"`0 0 ${W} ${H}`\" :title=\"hint\" tabindex=\"-1\" role=\"group\" @dblclick.self=\"onDouble\" @mousedown=\"noSelect\" @keydown=\"onKey\">\r\n <!-- fine grid: the same steps as snapping / мелкая сетка: те же шаги, что у прилипания -->\r\n <line v-for=\"x in gridT\" :key=\"`gt${x}`\" class=\"tx-curve-grid\" :class=\"{ major: isMajorT(x) }\" :x1=\"px(x)\" :x2=\"px(x)\" :y1=\"PAD_T\" :y2=\"H - PAD_B\" />\r\n <line v-for=\"v in gridV\" :key=\"`gv${v}`\" class=\"tx-curve-grid\" :class=\"{ major: isMajorV(v) }\" :x1=\"PAD_L\" :x2=\"W - PAD_R\" :y1=\"py(v)\" :y2=\"py(v)\" />\r\n\r\n <text v-for=\"(v, i) in labelsV\" :key=\"`lv${v}`\" class=\"tx-curve-label\" :class=\"{ edge: v === 0 || i === 0 || i === labelsV.length - 1 }\" :x=\"PAD_L - 4\" :y=\"py(v)\" text-anchor=\"end\" dominant-baseline=\"middle\">{{ fmt(v) }}</text>\r\n <text v-for=\"x in labelsT\" :key=\"`lt${x}`\" class=\"tx-curve-label\" :class=\"{ edge: x === 0 || x === 1 }\" :x=\"px(x)\" :y=\"H - 4\" :text-anchor=\"x === 0 ? 'start' : x === 1 ? 'end' : 'middle'\">{{ fmt(x) }}</text>\r\n\r\n <g v-if=\"tags && guides !== 'off'\" class=\"tx-curve-tags\" aria-hidden=\"true\">\r\n <line class=\"tx-curve-guide\" :x1=\"tags.x\" :x2=\"tags.x\" :y1=\"tags.y\" :y2=\"PAD_T + PLOT_H\" />\r\n <line class=\"tx-curve-guide\" :x1=\"PAD_L\" :x2=\"tags.x\" :y1=\"tags.y\" :y2=\"tags.y\" />\r\n <template v-if=\"guides === 'values'\">\r\n <rect class=\"tx-curve-tag-bg\" :x=\"tags.t.cx - tags.t.w / 2\" :y=\"H - 12\" :width=\"tags.t.w\" height=\"11\" rx=\"2\" />\r\n <text class=\"tx-curve-tag\" :x=\"tags.t.cx\" :y=\"H - 4\" text-anchor=\"middle\">{{ tags.t.text }}</text>\r\n <rect class=\"tx-curve-tag-bg\" :x=\"PAD_L - 3 - tags.v.w\" :y=\"tags.v.cy - 5.5\" :width=\"tags.v.w\" height=\"11\" rx=\"2\" />\r\n <text class=\"tx-curve-tag\" :x=\"PAD_L - 5\" :y=\"tags.v.cy\" text-anchor=\"end\" dominant-baseline=\"middle\">{{ tags.v.text }}</text>\r\n </template>\r\n </g>\r\n\r\n <path class=\"tx-curve-line\" :d=\"path\" />\r\n\r\n <!-- The \"B\" mark above the start of a Bezier segment: shows the point has handles even when it is not selected / Метка «B» над началом участка с Безье: видно, что у точки есть ручки, даже когда она не выбрана -->\r\n <text v-for=\"m in bezierMarks\" :key=\"`b${m.i}`\" class=\"tx-curve-mark\" :x=\"px(m.t)\" :y=\"py(m.v) - 8\" text-anchor=\"middle\" aria-hidden=\"true\">B</text>\r\n\r\n <g v-if=\"bezierHandles.length\" class=\"tx-curve-bezier\">\r\n <template v-for=\"h in bezierHandles\" :key=\"h.n\">\r\n <line class=\"tx-curve-arm\" :x1=\"px(h.from.t)\" :y1=\"py(h.from.v)\" :x2=\"px(h.t)\" :y2=\"py(h.v)\" />\r\n <circle\r\n class=\"tx-curve-handle\"\r\n :cx=\"px(h.t)\"\r\n :cy=\"py(h.v)\"\r\n r=\"4\"\r\n tabindex=\"0\"\r\n role=\"slider\"\r\n :aria-label=\"handleLabel ? handleLabel(h.n + 1, bezierSegment!.i) : `Bezier handle ${h.n + 1}`\"\r\n @pointerdown.stop=\"onHandleDown($event, h.n)\"\r\n @pointermove=\"onHandleMove\"\r\n @pointerup=\"onHandleUp\"\r\n @pointercancel=\"onHandleUp\"\r\n @keydown=\"onHandleKey($event, h.n)\"\r\n />\r\n </template>\r\n </g>\r\n <circle\r\n v-for=\"(p, i) in points\"\r\n :key=\"i\"\r\n class=\"tx-curve-dot\"\r\n :class=\"{ on: i === selected }\"\r\n :cx=\"px(p.t)\"\r\n :cy=\"py(p.v)\"\r\n r=\"5\"\r\n :data-index=\"i\"\r\n tabindex=\"0\"\r\n role=\"button\"\r\n :aria-label=\"labelOf(i, p)\"\r\n @focus=\"emit('update:selected', i)\"\r\n @pointerdown.stop=\"onDown($event, i)\"\r\n @pointermove=\"onMove\"\r\n @pointerup=\"onUp\"\r\n @pointercancel=\"onUp\"\r\n />\r\n </svg>\r\n</template>\r\n\r\n<style>\r\n/*\r\n * Configured with CSS variables on any ancestor:\r\n * Настройка через CSS-переменные на любом предке:\r\n * --tx-curve-bg, --tx-curve-border, --tx-curve-grid, --tx-curve-label, --tx-curve-accent,\r\n * --tx-curve-text (the numbers at the ends of the axes: start and end of the scale, brighter than the rest),\r\n * --tx-curve-dot-opacity (opacity of unselected points, 0.3 by default).\r\n * --tx-curve-text (цифры у краёв осей: начало и конец шкалы, ярче остальных),\r\n * --tx-curve-dot-opacity (непрозрачность невыбранных точек, по умолчанию 0.3).\r\n */\r\n.tx-curve {\r\n display: block;\r\n width: 100%;\r\n height: auto;\r\n border: 1px solid var(--tx-curve-border, #2a2d33);\r\n border-radius: 4px;\r\n background: var(--tx-curve-bg, #15171b);\r\n touch-action: none;\r\n user-select: none;\r\n outline: none;\r\n}\r\n\r\n.tx-curve-grid {\r\n pointer-events: none; /* otherwise a double click hits the grid line, not the field / иначе двойной клик попадает в линию сетки, а не в поле */\r\n stroke: var(--tx-curve-grid, #2a2d33);\r\n stroke-width: 0.5;\r\n opacity: 0.45;\r\n}\r\n\r\n.tx-curve-grid.major {\r\n stroke-width: 1;\r\n opacity: 1;\r\n}\r\n\r\n.tx-curve-guide {\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 1;\r\n stroke-dasharray: 2 3;\r\n opacity: 0.45;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-tag-bg {\r\n fill: var(--tx-curve-bg, #15171b);\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-tag {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n font-size: 8px;\r\n font-weight: 700;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-label.edge {\r\n fill: var(--tx-curve-text, #d6d9e0);\r\n}\r\n\r\n.tx-curve-label {\r\n fill: var(--tx-curve-label, #8b929c);\r\n font-size: 8px;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-line {\r\n fill: none;\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 2;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-mark {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n font: 600 9px/1 system-ui, sans-serif;\r\n pointer-events: none;\r\n user-select: none;\r\n}\r\n\r\n.tx-curve-arm {\r\n stroke: var(--tx-curve-label, #8b929c);\r\n stroke-width: 1;\r\n stroke-dasharray: 3 2;\r\n pointer-events: none;\r\n}\r\n\r\n.tx-curve-handle {\r\n fill: var(--tx-curve-label, #8b929c);\r\n stroke: var(--tx-curve-bg, #15171b);\r\n stroke-width: 1.5;\r\n cursor: grab;\r\n}\r\n\r\n.tx-curve-handle:active {\r\n cursor: grabbing;\r\n}\r\n\r\n.tx-curve-handle:hover,\r\n.tx-curve-handle:focus-visible {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n outline: none;\r\n}\r\n\r\n.tx-curve-dot {\r\n fill: var(--tx-curve-bg, #15171b);\r\n stroke: var(--tx-curve-accent, #4fc3f7);\r\n stroke-width: 2;\r\n opacity: var(--tx-curve-dot-opacity, 0.3);\r\n cursor: grab;\r\n}\r\n\r\n.tx-curve-dot:active {\r\n cursor: grabbing;\r\n}\r\n\r\n.tx-curve-dot:focus {\r\n outline: none;\r\n}\r\n\r\n/* keyboard focus: a thicker outline and a glow (browsers draw the outline of SVG shapes differently) / фокус с клавиатуры: утолщённая обводка и свечение (контур у SVG-форм браузеры рисуют по-разному) */\r\n.tx-curve-dot:focus-visible {\r\n stroke-width: 3;\r\n filter: drop-shadow(0 0 3px var(--tx-curve-accent, #4fc3f7));\r\n opacity: 1;\r\n}\r\n\r\n.tx-curve-dot.on,\r\n.tx-curve-dot:hover {\r\n fill: var(--tx-curve-accent, #4fc3f7);\r\n opacity: 1;\r\n}\r\n</style>\r\n"],"mappings":";;;;;;;;;AAyBA,SAAgB,YAAY,QAA+B,GAAmB;CAC1E,MAAM,IAAI,OAAO;CACjB,IAAI,MAAM,GAAG,OAAO;CACpB,MAAM,IAAI,QAAQ,CAAC;CACnB,IAAI,KAAK,OAAO,EAAE,CAAE,GAAG,OAAO,OAAO,EAAE,CAAE;CACzC,IAAI,KAAK,OAAO,IAAI,EAAE,CAAE,GAAG,OAAO,OAAO,IAAI,EAAE,CAAE;CACjD,KAAK,IAAI,IAAI,GAAG,IAAI,GAAG,KAAK;EACxB,MAAM,IAAI,OAAO;EACjB,IAAI,KAAK,EAAE,GAAG;GACV,MAAM,IAAI,OAAO,IAA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AAgB,IAAI,GAAG,EAAE,KAAK,CAAC;MAAI,IAAI,GAAG,EAAE,KAAK,CAAC;MAAI,IAAI,GAAG,EAAE,CAAC;MAAI,IAAI,GAAG,EAAE,CAAC;K,0BAC1FA,mBAaE,UAAA;MAZE,OAAM;MACL,IAAI,GAAG,EAAE,CAAC;MACV,IAAI,GAAG,EAAE,CAAC;MACX,GAAE;MACF,UAAS;MACT,MAAK;MACJ,cAAY,QAAA,cAAc,QAAA,YAAY,EAAE,IAAC,GAAM,cAAA,MAAe,CAAC,IAAA,iBAAqB,EAAE,IAAC;MACvF,eAAWL,eAAA,WAAO,aAAa,QAAQ,EAAE,CAAC,GAAA,CAAA,MAAA,CAAA;MAC1C,eAAa;MACb,aAAW;MACX,iBAAe;MACf,YAAO,WAAE,YAAY,QAAQ,EAAE,CAAC;;;KAI7CF,UAAA,IAAA,GAAAC,mBAiBEE,UAAA,MAAAC,WAhBmB,OAAA,QAAT,GAAG,MAAC;KADhB,OAAAJ,UAAA,GAAAC,mBAiBE,UAAA;MAfG,KAAK;MACN,OAAKI,eAAA,CAAC,gBAAc,EAAA,IACN,MAAM,QAAA,SAAQ,CAAA,CAAA;MAC3B,IAAI,GAAG,EAAE,CAAC;MACV,IAAI,GAAG,EAAE,CAAC;MACX,GAAE;MACD,cAAY;MACb,UAAS;MACT,MAAK;MACJ,cAAY,QAAQ,GAAG,CAAC;MACxB,UAAK,WAAE,KAAI,mBAAoB,CAAC;MAChC,eAAWH,eAAA,WAAO,OAAO,QAAQ,CAAC,GAAA,CAAA,MAAA,CAAA;MAClC,eAAa;MACb,aAAW;MACX,iBAAe"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
import { type BindOptions, type PlatformOptions, type ReservedOptions } from './hotkeys';
|
|
2
|
+
/**
|
|
3
|
+
* A registry of commands: one source for the menu bar, a context menu, a toolbar, a command palette and the keyboard.
|
|
4
|
+
* A command knows its label, its shortcut, whether it can run now and whether it is checked; the menus only show that.
|
|
5
|
+
* Реестр команд: один источник для полосы меню, контекстного меню, панели инструментов, палитры команд и клавиатуры.
|
|
6
|
+
* Команда знает подпись, сочетание, можно ли её сейчас выполнить и отмечена ли она; меню это только показывают.
|
|
7
|
+
*/
|
|
8
|
+
type Text = string | (() => string);
|
|
9
|
+
export interface Command {
|
|
10
|
+
id: string;
|
|
11
|
+
/** A function is read every time: a label from `i18n` follows the language. / Функция читается каждый раз: подпись из `i18n` следует за языком. */
|
|
12
|
+
label: Text;
|
|
13
|
+
/**
|
|
14
|
+
* `Mod+S`, or several (the first one is shown). `Mod` is ⌘ on Apple and Ctrl elsewhere.
|
|
15
|
+
* `Mod+S` или несколько (показывается первое). `Mod` — ⌘ у Apple и Ctrl у остальных.
|
|
16
|
+
*/
|
|
17
|
+
shortcut?: string | readonly string[];
|
|
18
|
+
/** Icon name for the menu. / Имя иконки для меню. */
|
|
19
|
+
icon?: string;
|
|
20
|
+
/** Can it run now. Default: always. / Можно ли выполнить сейчас. По умолчанию всегда. */
|
|
21
|
+
enabled?: () => boolean;
|
|
22
|
+
/** Makes it a checkbox (a toggle) in the menu. / Делает её чекбоксом (переключателем) в меню. */
|
|
23
|
+
checked?: () => boolean;
|
|
24
|
+
/** With `checked`: a radio of this group. / Вместе с `checked`: радио этой группы. */
|
|
25
|
+
group?: string;
|
|
26
|
+
run: () => void;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The menu entries `toMenu` builds. The same shape as `TaoMenuItem` of TaoUI (a test holds it), declared here,
|
|
30
|
+
* so TaoUX does not depend on TaoUI: pass the result to `TaoMenubar`, `TaoDropdownMenu`, `TaoContextMenu` as is.
|
|
31
|
+
* Пункты меню, которые строит `toMenu`. Та же форма, что у `TaoMenuItem` из TaoUI (это держит тест), объявлена здесь,
|
|
32
|
+
* чтобы TaoUX не зависел от TaoUI: результат передаётся в `TaoMenubar`, `TaoDropdownMenu`, `TaoContextMenu` как есть.
|
|
33
|
+
*/
|
|
34
|
+
export type CommandMenuItem = {
|
|
35
|
+
type?: 'item';
|
|
36
|
+
id: string;
|
|
37
|
+
label: string;
|
|
38
|
+
icon?: string;
|
|
39
|
+
shortcut?: string;
|
|
40
|
+
disabled?: boolean;
|
|
41
|
+
items?: CommandMenuItem[];
|
|
42
|
+
} | {
|
|
43
|
+
type: 'checkbox';
|
|
44
|
+
id: string;
|
|
45
|
+
label: string;
|
|
46
|
+
checked: boolean;
|
|
47
|
+
shortcut?: string;
|
|
48
|
+
disabled?: boolean;
|
|
49
|
+
} | {
|
|
50
|
+
type: 'radio';
|
|
51
|
+
id: string;
|
|
52
|
+
group: string;
|
|
53
|
+
label: string;
|
|
54
|
+
checked: boolean;
|
|
55
|
+
shortcut?: string;
|
|
56
|
+
disabled?: boolean;
|
|
57
|
+
} | {
|
|
58
|
+
type: 'label';
|
|
59
|
+
label: string;
|
|
60
|
+
} | {
|
|
61
|
+
type: 'separator';
|
|
62
|
+
};
|
|
63
|
+
/**
|
|
64
|
+
* What a menu is made of: a command id, `'-'` for a separator, a submenu, a group caption.
|
|
65
|
+
* Из чего состоит меню: id команды, `'-'` для разделителя, подменю, подпись группы.
|
|
66
|
+
*/
|
|
67
|
+
export type MenuLayoutEntry = string | {
|
|
68
|
+
id?: string;
|
|
69
|
+
label: Text;
|
|
70
|
+
icon?: string;
|
|
71
|
+
items: MenuLayout;
|
|
72
|
+
} | {
|
|
73
|
+
type: 'label';
|
|
74
|
+
label: Text;
|
|
75
|
+
};
|
|
76
|
+
export type MenuLayout = readonly MenuLayoutEntry[];
|
|
77
|
+
export interface ShortcutProblem {
|
|
78
|
+
id: string;
|
|
79
|
+
shortcut: string;
|
|
80
|
+
/** `reserved`: the browser keeps it; `duplicate`: another command has it too (`other`). */
|
|
81
|
+
problem: 'reserved' | 'duplicate';
|
|
82
|
+
other?: string;
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Creates the registry. Nothing is reactive by itself: `toMenu` reads `label`, `enabled` and `checked` when called,
|
|
86
|
+
* so in Vue call it inside `computed` and read refs in those functions, and the menu follows the state.
|
|
87
|
+
* Создаёт реестр. Сам по себе ничего не реактивно: `toMenu` читает `label`, `enabled` и `checked` в момент вызова,
|
|
88
|
+
* так что во Vue вызывайте его внутри `computed` и читайте ref-ы в этих функциях, и меню будет следовать за состоянием.
|
|
89
|
+
*/
|
|
90
|
+
export declare function createCommands(initial?: readonly Command[], options?: PlatformOptions): {
|
|
91
|
+
add: (command: Command | readonly Command[]) => () => void;
|
|
92
|
+
get: (id: string) => Command | undefined;
|
|
93
|
+
has: (id: string) => boolean;
|
|
94
|
+
list: () => Command[];
|
|
95
|
+
isEnabled: (id: string) => boolean;
|
|
96
|
+
run: (id: string) => boolean;
|
|
97
|
+
label: (id: string) => string | undefined;
|
|
98
|
+
shortcutLabel: (id: string) => string | undefined;
|
|
99
|
+
toMenu: (layout: MenuLayout, path?: string) => CommandMenuItem[];
|
|
100
|
+
bind: (target: EventTarget, bindOptions?: Omit<BindOptions, "mac">) => () => void;
|
|
101
|
+
check: (reservedOptions?: Omit<ReservedOptions, "mac">) => ShortcutProblem[];
|
|
102
|
+
};
|
|
103
|
+
export type Commands = ReturnType<typeof createCommands>;
|
|
104
|
+
type Flag = boolean | {
|
|
105
|
+
readonly value: boolean;
|
|
106
|
+
} | (() => boolean);
|
|
107
|
+
/**
|
|
108
|
+
* What undo/redo needs from a history: a document session (`canUndo` refs) fits as is, a `History` with an `apply` wrapper.
|
|
109
|
+
* Что undo/redo нужно от истории: сессия документа (ref-ы `canUndo`) подходит как есть, `History` — с обёрткой `apply`.
|
|
110
|
+
*/
|
|
111
|
+
export interface UndoSource {
|
|
112
|
+
readonly canUndo: Flag;
|
|
113
|
+
readonly canRedo: Flag;
|
|
114
|
+
undo(): unknown;
|
|
115
|
+
redo(): unknown;
|
|
116
|
+
}
|
|
117
|
+
export interface HistoryCommandOptions {
|
|
118
|
+
labels?: {
|
|
119
|
+
undo?: Text;
|
|
120
|
+
redo?: Text;
|
|
121
|
+
};
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Undo and Redo as commands (`undo`, `redo`; Mod+Z, Mod+Shift+Z and Mod+Y): they are disabled by themselves when
|
|
125
|
+
* there is nothing to undo or redo, in the menu and on the keyboard.
|
|
126
|
+
* Undo и Redo как команды (`undo`, `redo`; Mod+Z, Mod+Shift+Z и Mod+Y): сами становятся недоступными, когда
|
|
127
|
+
* откатывать или возвращать нечего, и в меню, и на клавиатуре.
|
|
128
|
+
*
|
|
129
|
+
* ```ts
|
|
130
|
+
* commands.add(historyCommands(session, { labels: { undo: () => t('undo'), redo: () => t('redo') } }));
|
|
131
|
+
* ```
|
|
132
|
+
*/
|
|
133
|
+
export declare function historyCommands(source: UndoSource, options?: HistoryCommandOptions): Command[];
|
|
134
|
+
export {};
|