@1337exp/taoux 0.3.0 → 0.5.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 +11 -0
- package/README.md +5 -2
- package/README.ru.md +5 -2
- package/dist/sortable.d.ts +66 -0
- package/dist/sortable.js +293 -0
- package/dist/sortable.js.map +1 -0
- package/dist/swiperow/TaoxSwipeRow.vue.d.ts +50 -0
- package/dist/swiperow/index.d.ts +3 -0
- package/dist/swiperow/model.d.ts +66 -0
- package/dist/swiperow.css +95 -0
- package/dist/swiperow.js +309 -0
- package/dist/swiperow.js.map +1 -0
- package/dist/undo.d.ts +113 -0
- package/dist/undo.js +166 -0
- package/dist/undo.js.map +1 -0
- package/package.json +15 -2
- package/skills/taoux/SKILL.md +5 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,16 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.5.0
|
|
4
|
+
|
|
5
|
+
- **New module `swiperow` (tier 2, Vue, on TaoUI): `TaoxSwipeRow`, a list row a finger slides sideways, as in a mail app.** To the start (right) one action is behind the row: a pull past its threshold (96px, or a third of a narrow row; or flung that way past half of it) runs it on release and the row comes back, as read / unread. To the end (left) the actions grow out evenly from slivers to their width and the row rests open on them (`v-model:open`), by the nearest stop or a fling; a pull back, a touch outside or an action closes it. Pulled far (60% of the width), the full swipe is armed: the last action takes nearly the whole row, the others shrink to slivers, and the release runs it (delete; `fullSwipe: false` turns it off). Armed actions buzz where the phone can. A vertical move stays the page's scroll; a mouse drags only with `mouse`; the click at the end of a swipe does not reach the row; Tab reaches the actions and opens their side. The gesture is `SwipeTracker` of `gestures`; the decisions are pure and exported (`swipeRowRelease`, `armedAt`, `endWidths`, `clampOffset`). Import `@1337exp/taoux/swiperow.css`. A sandbox page shows a mail list.
|
|
6
|
+
- The sandbox and the tests now run on TaoUI 5.6.2 (dev dependency; the peer range stays `^5.0.0`).
|
|
7
|
+
|
|
8
|
+
- **New module `sortable` (tier 1, Vue): reorder a list by a grip, with the pointer and the keyboard.** `useSortable(listRef, { onMove })` listens on the list; the markup is yours: `data-sortable-item` on each item, in order, and `data-sortable-handle` on a focusable grip inside it (a TaoButton with `icon="tao-grip"`). The pointer: press the grip, the item follows and the others make room (by its size and the gap), the list (or the page) scrolls at its edge through `edgescroll`, release drops it, Esc puts it back; past the ends it is drawn no further than the end (it would stretch the scrolled area and run away with the edge scroll) and lands in the last place. The keyboard: Space or Enter lifts, ↑ ↓ (← → with `axis: 'x'`) move one place, Space / Enter drop, Esc returns it where it started, Tab drops it where it is; a live region of its own says where the item is (`sortableTextsEn` / `sortableTextsRu`, or your `texts`, a function follows the language). The list stays the app's: `onMove(from, to)`, and `moveItem(list, from, to)` makes the moved copy. While moving, the item carries `data-sortable-dragging` or `data-sortable-lifted` for your styles. Pure helpers `sortTarget` and `sortShifts` are exported and tested. A sandbox page shows it with TaoUI.
|
|
9
|
+
|
|
10
|
+
## 0.4.0
|
|
11
|
+
|
|
12
|
+
- **New module `undo` (tier 0): undo and redo by records.** `UndoStack` keeps steps made of only the records they touched (`before` and `after` images), not snapshots of the whole document as `History` does, so a step costs what it changed, and an undo after a sync does not roll back what another device has just changed. `diffRecords(prev, next, id)` makes a step from two lists (records are immutable, found by identity); `record(entry, key?)` merges quick edits with one key within `coalesceMs` (3 s) into one step; `undo(current)` / `redo(current)` take the current list and return the next one. Two hooks carry what only the app knows: `revive(image, now)` stamps a returned record as new (`updatedAt: now`), and `vanish(record, now)` marks a record the step created as gone instead of erasing it (a tombstone; without it the record is dropped). A record that comes back takes its old place (a step keeps where its records stood, `beforeAt` / `afterAt`), so a note removed from the middle returns to the middle and «delete all» undone is the same list in the same order; the nearest place if the list changed meanwhile. The merge window slides with every edit, so typing without a pause stays one step; `coalesceMaxMs` caps how long a merged step may grow (no cap by default). It came out of Next Up's `core/undo.ts`; nothing else changes.
|
|
13
|
+
|
|
3
14
|
## 0.3.0
|
|
4
15
|
|
|
5
16
|
Additions for apps that are not canvas editors (a list of notes); everything that was there works as before, nothing to migrate.
|
package/README.md
CHANGED
|
@@ -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
|
+
| `undo` | undo/redo by records, not snapshots: a step keeps only the records it touched, so it is small and an undo after a sync does not roll back another device's edits; quick edits merge (`UndoStack`, `diffRecords`) | nothing |
|
|
84
85
|
| `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`) |
|
|
85
86
|
| `storage` | autosave to localStorage without exceptions; `tryWrite` (why it failed: quota / denied), `remove`, `subscribe` (another tab changed the key) | nothing |
|
|
86
87
|
| `file` | download text as a file (any `mime`), read a picked file as text with a size limit | DOM |
|
|
@@ -93,19 +94,21 @@ import { History } from '@1337exp/taoux/history';
|
|
|
93
94
|
| `ids` | `uuid()` for records that are stored or synced; `uid(prefix, taken)` for ids inside one document | nothing |
|
|
94
95
|
| `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 |
|
|
95
96
|
| `num` | small numeric helpers: `clamp`, `roundTo`, `snapTo`, `niceStep`, `ticks` (shared by the curve, gradient and playback modules) | nothing |
|
|
97
|
+
| `sortable` (Vue) | reorder a list by a grip and by the keyboard: `useSortable(listRef, { onMove })`, `data-sortable-item` / `data-sortable-handle`; the others make room, the list scrolls at its edge, Esc puts it back, a live region tells a screen reader; `moveItem` | vue (peer) |
|
|
96
98
|
| `session` | document lifecycle: history, autosave, files, restore, notices; a canvas camera is optional (`countItems`) | vue (peer) |
|
|
97
99
|
| `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`) |
|
|
98
100
|
| `palette` | search and groups of nodes for a palette | nothing |
|
|
99
101
|
| `links` (Vue) | links layer: SVG from ready geometry, `--tx-link-*` | vue (peer) |
|
|
100
102
|
| `canvas` (Vue) | canvas: mouse and touch gestures, wheel, auto-scroll, keys; the `CanvasHost` contract | vue (peer) |
|
|
101
103
|
| `curveeditor` (Vue) | curve editor plot: grid, snapping, bounds, decimals, auto-scroll at the edge; point operations; per-segment transitions with Bezier handles; keyboard (Tab, arrows, Shift, Insert, Delete) | vue (peer) |
|
|
104
|
+
| `swiperow` (Vue, tier 2) | `TaoxSwipeRow`: a list row a finger slides sideways, as in a mail app: to the start one action that runs past a threshold (read / unread), to the end actions that grow out and stay open, a long pull runs the last one (delete); TaoUI icons and tones, `@action="id => …"`; Tab reaches the actions | vue, **@1337exp/taoui** (peer) |
|
|
102
105
|
| `curvefield` (Vue, tier 2) | `TaoxCurveField`: a curve with fields on TaoUI components: point time and value, transition to the next point (`ease`), snapping, remove and reset; labels come from the app | vue, **@1337exp/taoui** (peer) |
|
|
103
106
|
| `gradienteditor` (Vue) | gradient bar with stop handles; stop operations, `gradientCss`; keyboard (Tab, arrows, Home/End, Insert, Delete) | vue (peer) |
|
|
104
107
|
| `playback` | playback model: time, pause, loop, speed, seeking; `createPlayback` without Vue and `usePlayback` for a component | vue (peer, for `usePlayback`) |
|
|
105
108
|
| `pins` | row pin positions measured from the DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
|
|
106
109
|
| `i18n` | typed i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, optional) |
|
|
107
110
|
|
|
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)).
|
|
111
|
+
Vue modules (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`, `swiperow`) 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`, `swiperow`), 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)).
|
|
109
112
|
|
|
110
113
|
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.
|
|
111
114
|
|
|
@@ -129,7 +132,7 @@ Working against a local checkout instead of npm: put `"@1337exp/taoux": "file:..
|
|
|
129
132
|
|
|
130
133
|
## Sandbox
|
|
131
134
|
|
|
132
|
-
The `sandbox/` folder is a demo and a testing ground: pages import the modules straight from `src/`, with no build. It holds `curveeditor`, `curvefield`, `gradienteditor`, `slider`, `color` and `
|
|
135
|
+
The `sandbox/` folder is a demo and a testing ground: pages import the modules straight from `src/`, with no build. It holds `curveeditor`, `curvefield`, `gradienteditor`, `slider`, `color`, `playback`, `sortable` and `swiperow`, with an EN / RU switch and a dark / light switch (the TaoUI theme, through the bridge). A new page is `sandbox/<name>.html` + `.ts` + a demo `.vue` and a link in `sandbox/index.html`. `npm run sandbox:build` makes a static copy with relative paths, ready for any folder (for example `/sandbox/taoux/`).
|
|
133
136
|
|
|
134
137
|
Screenshots and clips in this README come from the sandbox: see [docs/media](docs/media/README.md).
|
|
135
138
|
|
package/README.ru.md
CHANGED
|
@@ -81,6 +81,7 @@ import { History } from '@1337exp/taoux/history';
|
|
|
81
81
|
|---|---|---|
|
|
82
82
|
| `camera` | камера холста: pan, zoom вокруг курсора, экран ↔ мир | нет |
|
|
83
83
|
| `history` | undo/redo на снимках-строках со склейкой частых правок | нет |
|
|
84
|
+
| `undo` | undo/redo по записям, а не по снимкам: шаг хранит только затронутые записи, поэтому он мал, а отмена после синхронизации не откатывает правки другого устройства; частые правки склеиваются (`UndoStack`, `diffRecords`) | нет |
|
|
84
85
|
| `hotkeys` | сочетания клавиш: `parseHotkey('Mod+Shift+Z')`, `matchHotkey` (Mod = ⌘ / Ctrl, нелатинские раскладки по физической клавише), `formatHotkey` (`Ctrl+Shift+Z` / `⇧⌘Z`), `isReservedHotkey` (⌘W, ⌘T, ⌘Q…), `bindHotkeys` на элементе | DOM (для `bindHotkeys`) |
|
|
85
86
|
| `storage` | автосохранение в localStorage без исключений; `tryWrite` (почему не вышло: квота / запрет), `remove`, `subscribe` (ключ изменила другая вкладка) | нет |
|
|
86
87
|
| `file` | скачивание текста как файла (любой `mime`), чтение выбранного файла как текста с лимитом размера | DOM |
|
|
@@ -93,19 +94,21 @@ import { History } from '@1337exp/taoux/history';
|
|
|
93
94
|
| `ids` | `uuid()` для записей, которые хранятся или синхронизируются; `uid(prefix, taken)` для id внутри одного документа | нет |
|
|
94
95
|
| `ease` | функции движения между точками кривой: 8 семейств × in / out / in-out, `linear`, `step`, кубический Безье; `easeValue`, `isEase` (редактор рисует ими, рантайм считает ими же) | нет |
|
|
95
96
|
| `num` | мелкая числовая математика: `clamp`, `roundTo`, `snapTo`, `niceStep`, `ticks` (общая для кривой, градиента и воспроизведения) | нет |
|
|
97
|
+
| `sortable` (Vue) | перестановка списка за ручку и с клавиатуры: `useSortable(listRef, { onMove })`, `data-sortable-item` / `data-sortable-handle`; остальные расступаются, у края список прокручивается, Esc возвращает, живой регион сообщает скринридеру; `moveItem` | vue (peer) |
|
|
96
98
|
| `session` | жизненный цикл документа: история, автосохранение, файлы, восстановление, уведомления; камера холста необязательна (`countItems`) | vue (peer) |
|
|
97
99
|
| `commands` | реестр команд (подпись, сочетание, `enabled`, `checked`, `run`): `toMenu(layout)` строит дерево `TaoMenuItem[]` для `TaoMenubar` / `TaoContextMenu`, `bind` слушает те же сочетания, `historyCommands` даёт Undo / Redo, которые сами становятся недоступными, `check` находит занятые браузером и повторённые сочетания | DOM (для `bind`) |
|
|
98
100
|
| `palette` | поиск и группы нод для палитры | нет |
|
|
99
101
|
| `links` (Vue) | слой связей: SVG из готовой геометрии, `--tx-link-*` | vue (peer) |
|
|
100
102
|
| `canvas` (Vue) | холст: жесты мыши и сенсора, колесо, автопрокрутка, клавиши; контракт `CanvasHost` | vue (peer) |
|
|
101
103
|
| `curveeditor` (Vue) | поле редактора кривой: сетка, шаг, границы, знаки, автопрокрутка у края; операции над точками; переходы между точками с ручками Безье; клавиатура (Tab, стрелки, Shift, Insert, Delete) | vue (peer) |
|
|
104
|
+
| `swiperow` (Vue, ярус 2) | `TaoxSwipeRow`: строка списка, которую палец сдвигает вбок, как в почте: вправо одно действие, выполняется после порога (прочитано / не прочитано), влево действия вырастают и остаются открытыми, длинный свайп выполняет последнее (удалить); иконки и тона TaoUI, `@action="id => …"`; до действий можно дойти Tab | vue, **@1337exp/taoui** (peer) |
|
|
102
105
|
| `curvefield` (Vue, ярус 2) | `TaoxCurveField`: кривая с полями на компонентах TaoUI: время и значение точки, переход к следующей точке (`ease`), шаг, удаление и сброс; надписи задаёт приложение | vue, **@1337exp/taoui** (peer) |
|
|
103
106
|
| `gradienteditor` (Vue) | полоса градиента с ручками остановок; операции над остановками, `gradientCss`; клавиатура (Tab, стрелки, Home/End, Insert, Delete) | vue (peer) |
|
|
104
107
|
| `playback` | модель воспроизведения: время, пауза, цикл, скорость, перемотка; `createPlayback` без Vue и `usePlayback` для компонента | vue (peer, для `usePlayback`) |
|
|
105
108
|
| `pins` | позиции пинов-строк, измеренные по DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
|
|
106
109
|
| `i18n` | типизированный i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, опционально) |
|
|
107
110
|
|
|
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).
|
|
111
|
+
Vue-модули (`links`, `canvas`, `curveeditor`, `curvefield`, `gradienteditor`, `swiperow`) требуют явного импорта стилей: `import '@1337exp/taoux/canvas.css'`. Составные модули (session, commands, palette, links, canvas, pins, curveeditor, gradienteditor, playback) импортируют только примитивы. Ярус 2, поля (`curvefield`, `swiperow`), собирает составные модули в готовое поле на компонентах 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).
|
|
109
112
|
|
|
110
113
|
Правило: модуль попадает сюда, когда он понадобился во втором проекте. Ядро модулей не знает про Vue и DOM, если это не их задача.
|
|
111
114
|
|
|
@@ -131,7 +134,7 @@ npm run dev # watch: пересборка JS и деклараций
|
|
|
131
134
|
|
|
132
135
|
## Песочница
|
|
133
136
|
|
|
134
|
-
Папка `sandbox/` это демо и поле для проверки: страницы подключают модули прямо из `src/`, без сборки. Сейчас там `curveeditor`, `curvefield`, `gradienteditor`, `slider`, `color` и `
|
|
137
|
+
Папка `sandbox/` это демо и поле для проверки: страницы подключают модули прямо из `src/`, без сборки. Сейчас там `curveeditor`, `curvefield`, `gradienteditor`, `slider`, `color`, `playback`, `sortable` и `swiperow`, с переключателем языка (EN / RU) и темы (тёмная / светлая: тема TaoUI через мост). Новая страница = `sandbox/<имя>.html` + `.ts` + демо `.vue` и ссылка в `sandbox/index.html`. `npm run sandbox:build` собирает статическую копию с относительными путями, её можно положить в любую папку (например, `/sandbox/taoux/`).
|
|
135
138
|
|
|
136
139
|
Скриншоты и ролики в этом README сняты с песочницы: см. [docs/media](docs/media/README.md).
|
|
137
140
|
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { type MaybeRefOrGetter, type Ref } from 'vue';
|
|
2
|
+
/**
|
|
3
|
+
* Reordering a list by dragging a handle, and by the keyboard. The list belongs to the app: the composable only says
|
|
4
|
+
* «move from → to», the app moves the item in its array, Vue redraws.
|
|
5
|
+
* The pointer: press the handle, the item lifts and follows, the others make room, the list scrolls at its edge,
|
|
6
|
+
* release drops it, Esc puts it back. The keyboard: Space or Enter on the handle lifts it, ↑ ↓ (← → on a row) move it
|
|
7
|
+
* one place at a time, Space / Enter drops it, Esc returns it where it started; a live region tells a screen reader.
|
|
8
|
+
* The markup is the app's: `data-sortable-item` on each item (in order) and `data-sortable-handle` on a focusable handle
|
|
9
|
+
* inside it (a button with `tao-grip`). While dragging the item has `data-sortable-dragging`, while lifted by the
|
|
10
|
+
* keyboard `data-sortable-lifted`: style them (a shadow, a lift).
|
|
11
|
+
*
|
|
12
|
+
* Перестановка списка перетаскиванием за ручку и с клавиатуры. Список принадлежит приложению: composable только
|
|
13
|
+
* говорит «откуда → куда», приложение переставляет элемент в своём массиве, Vue перерисовывает.
|
|
14
|
+
* Указатель: нажал на ручку — элемент поднимается и едет следом, остальные расступаются, у края список прокручивается,
|
|
15
|
+
* отпустил — встал, Esc — вернулся. Клавиатура: Пробел или Enter на ручке поднимает, ↑ ↓ (← → в строке) двигают на
|
|
16
|
+
* одно место, Пробел / Enter ставят, Esc возвращает туда, откуда начали; живой регион сообщает скринридеру.
|
|
17
|
+
* Разметка приложения: `data-sortable-item` на каждом элементе (по порядку) и `data-sortable-handle` на фокусируемой
|
|
18
|
+
* ручке внутри (кнопка с `tao-grip`). Во время перетаскивания у элемента `data-sortable-dragging`, при подъёме с
|
|
19
|
+
* клавиатуры `data-sortable-lifted`: оформите их (тень, подъём).
|
|
20
|
+
*/
|
|
21
|
+
export type SortableAxis = 'y' | 'x';
|
|
22
|
+
/**
|
|
23
|
+
* Where an item dragged from `from` lands: before the first other item whose middle is past the pointer. `starts` and
|
|
24
|
+
* `sizes` are the items' positions and sizes along the axis, in the order of the list, measured before the drag.
|
|
25
|
+
* Куда встаёт элемент, который тащат из `from`: перед первым другим элементом, чья середина дальше указателя.
|
|
26
|
+
*/
|
|
27
|
+
export declare function sortTarget(pointer: number, starts: readonly number[], sizes: readonly number[], from: number): number;
|
|
28
|
+
/**
|
|
29
|
+
* How far each other item shifts to make room: the items between `from` and `to` move by the dragged item's size and
|
|
30
|
+
* the gap, the rest stay.
|
|
31
|
+
* На сколько сдвигается каждый другой элемент, чтобы освободить место.
|
|
32
|
+
*/
|
|
33
|
+
export declare function sortShifts(count: number, from: number, to: number, size: number): number[];
|
|
34
|
+
/** A copy of the list with the item moved. / Копия списка с переставленным элементом. */
|
|
35
|
+
export declare function moveItem<T>(list: readonly T[], from: number, to: number): T[];
|
|
36
|
+
/** The texts for a screen reader; `{item}` is the item's text, `{position}` / `{count}` its place. */
|
|
37
|
+
export interface SortableTexts {
|
|
38
|
+
lifted: string;
|
|
39
|
+
moved: string;
|
|
40
|
+
dropped: string;
|
|
41
|
+
canceled: string;
|
|
42
|
+
}
|
|
43
|
+
export declare const sortableTextsEn: SortableTexts;
|
|
44
|
+
export declare const sortableTextsRu: SortableTexts;
|
|
45
|
+
export interface SortableOptions {
|
|
46
|
+
/**
|
|
47
|
+
* The item moved: put it at `to` in your array (`list.value = moveItem(list.value, from, to)`).
|
|
48
|
+
* Элемент переставлен: поставьте его на место `to` в своём массиве.
|
|
49
|
+
*/
|
|
50
|
+
onMove(from: number, to: number): void;
|
|
51
|
+
axis?: SortableAxis;
|
|
52
|
+
/** Off while true (a filtered list, a read-only view). / Выключено, пока true. */
|
|
53
|
+
disabled?: MaybeRefOrGetter<boolean>;
|
|
54
|
+
/** The texts for a screen reader; a function is read each time, so it follows the language. / Тексты для скринридера. */
|
|
55
|
+
texts?: SortableTexts | (() => SortableTexts);
|
|
56
|
+
/** The text of an item for those messages; its text content by default. / Текст элемента для сообщений. */
|
|
57
|
+
itemLabel?(element: HTMLElement, index: number): string;
|
|
58
|
+
}
|
|
59
|
+
export declare function useSortable(container: Ref<HTMLElement | null>, options: SortableOptions): {
|
|
60
|
+
/** The index being dragged by the pointer, or null. / Индекс, который тащат указателем, или null. */
|
|
61
|
+
dragging: Ref<number | null, number | null>;
|
|
62
|
+
/** The index lifted by the keyboard, or null. / Индекс, поднятый с клавиатуры, или null. */
|
|
63
|
+
lifted: Ref<number | null, number | null>;
|
|
64
|
+
/** Stops a pointer drag without moving. / Прерывает перетаскивание без переноса. */
|
|
65
|
+
cancel: () => void;
|
|
66
|
+
};
|
package/dist/sortable.js
ADDED
|
@@ -0,0 +1,293 @@
|
|
|
1
|
+
import { createEdgeScroller } from "./edgescroll.js";
|
|
2
|
+
import { onBeforeUnmount, onMounted, ref, toValue } from "vue";
|
|
3
|
+
//#region src/sortable.ts
|
|
4
|
+
/**
|
|
5
|
+
* Where an item dragged from `from` lands: before the first other item whose middle is past the pointer. `starts` and
|
|
6
|
+
* `sizes` are the items' positions and sizes along the axis, in the order of the list, measured before the drag.
|
|
7
|
+
* Куда встаёт элемент, который тащат из `from`: перед первым другим элементом, чья середина дальше указателя.
|
|
8
|
+
*/
|
|
9
|
+
function sortTarget(pointer, starts, sizes, from) {
|
|
10
|
+
let target = 0;
|
|
11
|
+
for (let i = 0; i < starts.length; i++) {
|
|
12
|
+
if (i === from) continue;
|
|
13
|
+
if (pointer > starts[i] + sizes[i] / 2) target++;
|
|
14
|
+
}
|
|
15
|
+
return target;
|
|
16
|
+
}
|
|
17
|
+
/**
|
|
18
|
+
* How far each other item shifts to make room: the items between `from` and `to` move by the dragged item's size and
|
|
19
|
+
* the gap, the rest stay.
|
|
20
|
+
* На сколько сдвигается каждый другой элемент, чтобы освободить место.
|
|
21
|
+
*/
|
|
22
|
+
function sortShifts(count, from, to, size) {
|
|
23
|
+
return Array.from({ length: count }, (_, i) => {
|
|
24
|
+
if (i === from) return 0;
|
|
25
|
+
if (from < to && i > from && i <= to) return -size;
|
|
26
|
+
if (to < from && i >= to && i < from) return size;
|
|
27
|
+
return 0;
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
/** A copy of the list with the item moved. / Копия списка с переставленным элементом. */
|
|
31
|
+
function moveItem(list, from, to) {
|
|
32
|
+
const next = list.slice();
|
|
33
|
+
if (from < 0 || from >= next.length) return next;
|
|
34
|
+
const [item] = next.splice(from, 1);
|
|
35
|
+
next.splice(Math.max(0, Math.min(to, next.length)), 0, item);
|
|
36
|
+
return next;
|
|
37
|
+
}
|
|
38
|
+
var sortableTextsEn = {
|
|
39
|
+
lifted: "Picked up {item}, position {position} of {count}. Use the arrow keys to move, Space to drop, Escape to cancel.",
|
|
40
|
+
moved: "{item}, position {position} of {count}.",
|
|
41
|
+
dropped: "{item} dropped at position {position} of {count}.",
|
|
42
|
+
canceled: "Move canceled. {item} is back at position {position} of {count}."
|
|
43
|
+
};
|
|
44
|
+
var sortableTextsRu = {
|
|
45
|
+
lifted: "{item} поднят, место {position} из {count}. Стрелки двигают, Пробел ставит, Escape отменяет.",
|
|
46
|
+
moved: "{item}, место {position} из {count}.",
|
|
47
|
+
dropped: "{item} поставлен на место {position} из {count}.",
|
|
48
|
+
canceled: "Перенос отменён. {item} снова на месте {position} из {count}."
|
|
49
|
+
};
|
|
50
|
+
var ITEM = "[data-sortable-item]";
|
|
51
|
+
var HANDLE = "[data-sortable-handle]";
|
|
52
|
+
function scrollParent(el, axis) {
|
|
53
|
+
for (let p = el; p; p = p.parentElement) {
|
|
54
|
+
const style = getComputedStyle(p);
|
|
55
|
+
const overflow = axis === "y" ? style.overflowY : style.overflowX;
|
|
56
|
+
if (/(auto|scroll)/.test(overflow) && (axis === "y" ? p.scrollHeight > p.clientHeight : p.scrollWidth > p.clientWidth)) return p;
|
|
57
|
+
}
|
|
58
|
+
return null;
|
|
59
|
+
}
|
|
60
|
+
function useSortable(container, options) {
|
|
61
|
+
const axis = options.axis ?? "y";
|
|
62
|
+
const dragging = ref(null);
|
|
63
|
+
const lifted = ref(null);
|
|
64
|
+
const texts = () => (typeof options.texts === "function" ? options.texts() : options.texts) ?? sortableTextsEn;
|
|
65
|
+
let live = null;
|
|
66
|
+
function announce(template, index) {
|
|
67
|
+
if (!live) return;
|
|
68
|
+
const els = items();
|
|
69
|
+
const label = els[index] ? options.itemLabel?.(els[index], index) ?? els[index].textContent?.trim() ?? "" : "";
|
|
70
|
+
live.textContent = template.replace("{item}", label).replace("{position}", String(index + 1)).replace("{count}", String(els.length));
|
|
71
|
+
}
|
|
72
|
+
const items = () => container.value ? Array.from(container.value.querySelectorAll(ITEM)) : [];
|
|
73
|
+
const along = (r) => axis === "y" ? r.top : r.left;
|
|
74
|
+
const sizeOf = (r) => axis === "y" ? r.height : r.width;
|
|
75
|
+
const pointerOf = (e) => axis === "y" ? e.clientY : e.clientX;
|
|
76
|
+
let drag = null;
|
|
77
|
+
const scrollPos = (s) => s ? axis === "y" ? s.scrollTop : s.scrollLeft : axis === "y" ? window.scrollY : window.scrollX;
|
|
78
|
+
const edge = createEdgeScroller({
|
|
79
|
+
bounds: () => {
|
|
80
|
+
if (!drag) return null;
|
|
81
|
+
if (drag.scroller) return drag.scroller.getBoundingClientRect();
|
|
82
|
+
return {
|
|
83
|
+
left: 0,
|
|
84
|
+
top: 0,
|
|
85
|
+
width: window.innerWidth,
|
|
86
|
+
height: window.innerHeight
|
|
87
|
+
};
|
|
88
|
+
},
|
|
89
|
+
pointer: () => drag?.last ?? [0, 0],
|
|
90
|
+
enabled: () => drag !== null,
|
|
91
|
+
onScroll: (dx, dy) => {
|
|
92
|
+
if (!drag) return;
|
|
93
|
+
const d = axis === "y" ? dy : dx;
|
|
94
|
+
if (drag.scroller) {
|
|
95
|
+
if (axis === "y") drag.scroller.scrollTop += d;
|
|
96
|
+
else drag.scroller.scrollLeft += d;
|
|
97
|
+
} else window.scrollBy(axis === "y" ? 0 : d, axis === "y" ? d : 0);
|
|
98
|
+
follow();
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
function follow() {
|
|
102
|
+
if (!drag) return;
|
|
103
|
+
const pointer = (axis === "y" ? drag.last[1] : drag.last[0]) + scrollPos(drag.scroller) - drag.scroll0;
|
|
104
|
+
const { starts, sizes, from } = drag;
|
|
105
|
+
const last = starts.length - 1;
|
|
106
|
+
const min = starts[0] - starts[from];
|
|
107
|
+
const max = starts[last] + sizes[last] - (starts[from] + sizes[from]);
|
|
108
|
+
const raw = pointer - drag.start;
|
|
109
|
+
const offset = Math.min(max, Math.max(min, raw));
|
|
110
|
+
const to = sortTarget(starts[from] + sizes[from] / 2 + raw, starts, sizes, from);
|
|
111
|
+
drag.to = to;
|
|
112
|
+
const shifts = sortShifts(drag.els.length, drag.from, to, drag.step);
|
|
113
|
+
drag.els.forEach((el, i) => {
|
|
114
|
+
const value = i === drag.from ? offset : shifts[i];
|
|
115
|
+
el.style.transform = value ? axis === "y" ? `translateY(${value}px)` : `translateX(${value}px)` : "";
|
|
116
|
+
});
|
|
117
|
+
}
|
|
118
|
+
function onPointerDown(event) {
|
|
119
|
+
if (toValue(options.disabled) || event.button !== 0 || lifted.value !== null) return;
|
|
120
|
+
const handle = event.target.closest(HANDLE);
|
|
121
|
+
if (!handle || !container.value?.contains(handle)) return;
|
|
122
|
+
const els = items();
|
|
123
|
+
const from = els.findIndex((el) => el.contains(handle));
|
|
124
|
+
if (from < 0) return;
|
|
125
|
+
event.preventDefault();
|
|
126
|
+
const rects = els.map((el) => el.getBoundingClientRect());
|
|
127
|
+
const scroller = scrollParent(container.value, axis);
|
|
128
|
+
const gap = els.length > 1 ? Math.max(0, along(rects[1]) - along(rects[0]) - sizeOf(rects[0])) : 0;
|
|
129
|
+
const step = sizeOf(rects[from]) + gap;
|
|
130
|
+
drag = {
|
|
131
|
+
from,
|
|
132
|
+
to: from,
|
|
133
|
+
start: pointerOf(event),
|
|
134
|
+
scroll0: scrollPos(scroller),
|
|
135
|
+
starts: rects.map(along),
|
|
136
|
+
sizes: rects.map(sizeOf),
|
|
137
|
+
step,
|
|
138
|
+
els,
|
|
139
|
+
handle,
|
|
140
|
+
pointerId: event.pointerId,
|
|
141
|
+
last: [event.clientX, event.clientY],
|
|
142
|
+
scroller
|
|
143
|
+
};
|
|
144
|
+
try {
|
|
145
|
+
handle.setPointerCapture?.(event.pointerId);
|
|
146
|
+
} catch {}
|
|
147
|
+
els.forEach((el, i) => {
|
|
148
|
+
el.style.transition = i === from ? "none" : "transform 150ms ease";
|
|
149
|
+
if (i === from) {
|
|
150
|
+
el.style.position = "relative";
|
|
151
|
+
el.style.zIndex = "1";
|
|
152
|
+
el.setAttribute("data-sortable-dragging", "");
|
|
153
|
+
}
|
|
154
|
+
});
|
|
155
|
+
dragging.value = from;
|
|
156
|
+
document.addEventListener("pointermove", onPointerMove);
|
|
157
|
+
document.addEventListener("pointerup", onPointerUp);
|
|
158
|
+
document.addEventListener("pointercancel", onPointerCancel);
|
|
159
|
+
document.addEventListener("keydown", onDragKey, true);
|
|
160
|
+
}
|
|
161
|
+
function onPointerMove(event) {
|
|
162
|
+
if (!drag || event.pointerId !== drag.pointerId) return;
|
|
163
|
+
drag.last = [event.clientX, event.clientY];
|
|
164
|
+
follow();
|
|
165
|
+
edge.kick();
|
|
166
|
+
}
|
|
167
|
+
function finish(commit) {
|
|
168
|
+
if (!drag) return;
|
|
169
|
+
const { from, to, els, handle, pointerId } = drag;
|
|
170
|
+
drag = null;
|
|
171
|
+
edge.stop();
|
|
172
|
+
try {
|
|
173
|
+
handle.releasePointerCapture?.(pointerId);
|
|
174
|
+
} catch {}
|
|
175
|
+
document.removeEventListener("pointermove", onPointerMove);
|
|
176
|
+
document.removeEventListener("pointerup", onPointerUp);
|
|
177
|
+
document.removeEventListener("pointercancel", onPointerCancel);
|
|
178
|
+
document.removeEventListener("keydown", onDragKey, true);
|
|
179
|
+
for (const el of els) {
|
|
180
|
+
el.style.transform = "";
|
|
181
|
+
el.style.transition = "";
|
|
182
|
+
el.style.position = "";
|
|
183
|
+
el.style.zIndex = "";
|
|
184
|
+
el.removeAttribute("data-sortable-dragging");
|
|
185
|
+
}
|
|
186
|
+
dragging.value = null;
|
|
187
|
+
if (commit && to !== from) options.onMove(from, to);
|
|
188
|
+
}
|
|
189
|
+
const onPointerUp = (event) => {
|
|
190
|
+
if (drag && event.pointerId === drag.pointerId) finish(true);
|
|
191
|
+
};
|
|
192
|
+
const onPointerCancel = () => finish(false);
|
|
193
|
+
function onDragKey(event) {
|
|
194
|
+
if (event.key === "Escape") {
|
|
195
|
+
event.preventDefault();
|
|
196
|
+
event.stopPropagation();
|
|
197
|
+
finish(false);
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
let liftedFrom = 0;
|
|
201
|
+
function focusHandle(index) {
|
|
202
|
+
requestAnimationFrame(() => items()[index]?.querySelector(HANDLE)?.focus());
|
|
203
|
+
}
|
|
204
|
+
function setLifted(index) {
|
|
205
|
+
items().forEach((el, i) => {
|
|
206
|
+
if (i === index) el.setAttribute("data-sortable-lifted", "");
|
|
207
|
+
else el.removeAttribute("data-sortable-lifted");
|
|
208
|
+
});
|
|
209
|
+
lifted.value = index;
|
|
210
|
+
}
|
|
211
|
+
function onKeydown(event) {
|
|
212
|
+
if (toValue(options.disabled) || drag) return;
|
|
213
|
+
const handle = event.target.closest(HANDLE);
|
|
214
|
+
if (!handle || !container.value?.contains(handle)) return;
|
|
215
|
+
const els = items();
|
|
216
|
+
const index = els.findIndex((el) => el.contains(handle));
|
|
217
|
+
if (index < 0) return;
|
|
218
|
+
const pick = event.key === " " || event.key === "Enter";
|
|
219
|
+
if (lifted.value === null) {
|
|
220
|
+
if (!pick) return;
|
|
221
|
+
event.preventDefault();
|
|
222
|
+
liftedFrom = index;
|
|
223
|
+
setLifted(index);
|
|
224
|
+
announce(texts().lifted, index);
|
|
225
|
+
return;
|
|
226
|
+
}
|
|
227
|
+
const back = axis === "y" ? "ArrowUp" : "ArrowLeft";
|
|
228
|
+
const forward = axis === "y" ? "ArrowDown" : "ArrowRight";
|
|
229
|
+
if (event.key === back || event.key === forward) {
|
|
230
|
+
event.preventDefault();
|
|
231
|
+
const to = index + (event.key === forward ? 1 : -1);
|
|
232
|
+
if (to < 0 || to >= els.length) return;
|
|
233
|
+
options.onMove(index, to);
|
|
234
|
+
requestAnimationFrame(() => {
|
|
235
|
+
setLifted(to);
|
|
236
|
+
announce(texts().moved, to);
|
|
237
|
+
});
|
|
238
|
+
focusHandle(to);
|
|
239
|
+
} else if (pick) {
|
|
240
|
+
event.preventDefault();
|
|
241
|
+
setLifted(null);
|
|
242
|
+
announce(texts().dropped, index);
|
|
243
|
+
} else if (event.key === "Escape") {
|
|
244
|
+
event.preventDefault();
|
|
245
|
+
event.stopPropagation();
|
|
246
|
+
if (index !== liftedFrom) {
|
|
247
|
+
options.onMove(index, liftedFrom);
|
|
248
|
+
focusHandle(liftedFrom);
|
|
249
|
+
}
|
|
250
|
+
setLifted(null);
|
|
251
|
+
requestAnimationFrame(() => announce(texts().canceled, liftedFrom));
|
|
252
|
+
} else if (event.key === "Tab") setLifted(null);
|
|
253
|
+
}
|
|
254
|
+
function onFocusOut(event) {
|
|
255
|
+
if (lifted.value === null) return;
|
|
256
|
+
const next = event.relatedTarget;
|
|
257
|
+
if (next?.closest(HANDLE) && container.value?.contains(next)) return;
|
|
258
|
+
if (next) setLifted(null);
|
|
259
|
+
}
|
|
260
|
+
onMounted(() => {
|
|
261
|
+
const el = container.value;
|
|
262
|
+
if (!el) return;
|
|
263
|
+
el.addEventListener("pointerdown", onPointerDown);
|
|
264
|
+
el.addEventListener("keydown", onKeydown);
|
|
265
|
+
el.addEventListener("focusout", onFocusOut);
|
|
266
|
+
live = document.createElement("div");
|
|
267
|
+
live.setAttribute("aria-live", "assertive");
|
|
268
|
+
live.setAttribute("aria-atomic", "true");
|
|
269
|
+
live.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap";
|
|
270
|
+
document.body.appendChild(live);
|
|
271
|
+
});
|
|
272
|
+
onBeforeUnmount(() => {
|
|
273
|
+
finish(false);
|
|
274
|
+
const el = container.value;
|
|
275
|
+
el?.removeEventListener("pointerdown", onPointerDown);
|
|
276
|
+
el?.removeEventListener("keydown", onKeydown);
|
|
277
|
+
el?.removeEventListener("focusout", onFocusOut);
|
|
278
|
+
live?.remove();
|
|
279
|
+
live = null;
|
|
280
|
+
});
|
|
281
|
+
return {
|
|
282
|
+
/** The index being dragged by the pointer, or null. / Индекс, который тащат указателем, или null. */
|
|
283
|
+
dragging,
|
|
284
|
+
/** The index lifted by the keyboard, or null. / Индекс, поднятый с клавиатуры, или null. */
|
|
285
|
+
lifted,
|
|
286
|
+
/** Stops a pointer drag without moving. / Прерывает перетаскивание без переноса. */
|
|
287
|
+
cancel: () => finish(false)
|
|
288
|
+
};
|
|
289
|
+
}
|
|
290
|
+
//#endregion
|
|
291
|
+
export { moveItem, sortShifts, sortTarget, sortableTextsEn, sortableTextsRu, useSortable };
|
|
292
|
+
|
|
293
|
+
//# sourceMappingURL=sortable.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sortable.js","names":[],"sources":["../src/sortable.ts"],"sourcesContent":["import { onBeforeUnmount, onMounted, ref, toValue, type MaybeRefOrGetter, type Ref } from 'vue';\nimport { createEdgeScroller } from './edgescroll';\n\n/**\n * Reordering a list by dragging a handle, and by the keyboard. The list belongs to the app: the composable only says\n * «move from → to», the app moves the item in its array, Vue redraws.\n * The pointer: press the handle, the item lifts and follows, the others make room, the list scrolls at its edge,\n * release drops it, Esc puts it back. The keyboard: Space or Enter on the handle lifts it, ↑ ↓ (← → on a row) move it\n * one place at a time, Space / Enter drops it, Esc returns it where it started; a live region tells a screen reader.\n * The markup is the app's: `data-sortable-item` on each item (in order) and `data-sortable-handle` on a focusable handle\n * inside it (a button with `tao-grip`). While dragging the item has `data-sortable-dragging`, while lifted by the\n * keyboard `data-sortable-lifted`: style them (a shadow, a lift).\n *\n * Перестановка списка перетаскиванием за ручку и с клавиатуры. Список принадлежит приложению: composable только\n * говорит «откуда → куда», приложение переставляет элемент в своём массиве, Vue перерисовывает.\n * Указатель: нажал на ручку — элемент поднимается и едет следом, остальные расступаются, у края список прокручивается,\n * отпустил — встал, Esc — вернулся. Клавиатура: Пробел или Enter на ручке поднимает, ↑ ↓ (← → в строке) двигают на\n * одно место, Пробел / Enter ставят, Esc возвращает туда, откуда начали; живой регион сообщает скринридеру.\n * Разметка приложения: `data-sortable-item` на каждом элементе (по порядку) и `data-sortable-handle` на фокусируемой\n * ручке внутри (кнопка с `tao-grip`). Во время перетаскивания у элемента `data-sortable-dragging`, при подъёме с\n * клавиатуры `data-sortable-lifted`: оформите их (тень, подъём).\n */\n\nexport type SortableAxis = 'y' | 'x';\n\n/**\n * Where an item dragged from `from` lands: before the first other item whose middle is past the pointer. `starts` and\n * `sizes` are the items' positions and sizes along the axis, in the order of the list, measured before the drag.\n * Куда встаёт элемент, который тащат из `from`: перед первым другим элементом, чья середина дальше указателя.\n */\nexport function sortTarget(pointer: number, starts: readonly number[], sizes: readonly number[], from: number): number {\n let target = 0;\n for (let i = 0; i < starts.length; i++) {\n if (i === from) continue;\n if (pointer > starts[i]! + sizes[i]! / 2) target++;\n }\n return target;\n}\n\n/**\n * How far each other item shifts to make room: the items between `from` and `to` move by the dragged item's size and\n * the gap, the rest stay.\n * На сколько сдвигается каждый другой элемент, чтобы освободить место.\n */\nexport function sortShifts(count: number, from: number, to: number, size: number): number[] {\n return Array.from({ length: count }, (_, i) => {\n if (i === from) return 0;\n if (from < to && i > from && i <= to) return -size;\n if (to < from && i >= to && i < from) return size;\n return 0;\n });\n}\n\n/** A copy of the list with the item moved. / Копия списка с переставленным элементом. */\nexport function moveItem<T>(list: readonly T[], from: number, to: number): T[] {\n const next = list.slice();\n if (from < 0 || from >= next.length) return next;\n const [item] = next.splice(from, 1);\n next.splice(Math.max(0, Math.min(to, next.length)), 0, item!);\n return next;\n}\n\n/** The texts for a screen reader; `{item}` is the item's text, `{position}` / `{count}` its place. */\nexport interface SortableTexts {\n lifted: string;\n moved: string;\n dropped: string;\n canceled: string;\n}\n\nexport const sortableTextsEn: SortableTexts = {\n lifted: 'Picked up {item}, position {position} of {count}. Use the arrow keys to move, Space to drop, Escape to cancel.',\n moved: '{item}, position {position} of {count}.',\n dropped: '{item} dropped at position {position} of {count}.',\n canceled: 'Move canceled. {item} is back at position {position} of {count}.',\n};\n\nexport const sortableTextsRu: SortableTexts = {\n lifted: '{item} поднят, место {position} из {count}. Стрелки двигают, Пробел ставит, Escape отменяет.',\n moved: '{item}, место {position} из {count}.',\n dropped: '{item} поставлен на место {position} из {count}.',\n canceled: 'Перенос отменён. {item} снова на месте {position} из {count}.',\n};\n\nexport interface SortableOptions {\n /**\n * The item moved: put it at `to` in your array (`list.value = moveItem(list.value, from, to)`).\n * Элемент переставлен: поставьте его на место `to` в своём массиве.\n */\n onMove(from: number, to: number): void;\n axis?: SortableAxis;\n /** Off while true (a filtered list, a read-only view). / Выключено, пока true. */\n disabled?: MaybeRefOrGetter<boolean>;\n /** The texts for a screen reader; a function is read each time, so it follows the language. / Тексты для скринридера. */\n texts?: SortableTexts | (() => SortableTexts);\n /** The text of an item for those messages; its text content by default. / Текст элемента для сообщений. */\n itemLabel?(element: HTMLElement, index: number): string;\n}\n\nconst ITEM = '[data-sortable-item]';\nconst HANDLE = '[data-sortable-handle]';\n\nfunction scrollParent(el: HTMLElement, axis: SortableAxis): HTMLElement | null {\n for (let p: HTMLElement | null = el; p; p = p.parentElement) {\n const style = getComputedStyle(p);\n const overflow = axis === 'y' ? style.overflowY : style.overflowX;\n if (/(auto|scroll)/.test(overflow) && (axis === 'y' ? p.scrollHeight > p.clientHeight : p.scrollWidth > p.clientWidth)) return p;\n }\n return null;\n}\n\nexport function useSortable(container: Ref<HTMLElement | null>, options: SortableOptions) {\n const axis = options.axis ?? 'y';\n const dragging = ref<number | null>(null);\n const lifted = ref<number | null>(null);\n const texts = () => (typeof options.texts === 'function' ? options.texts() : options.texts) ?? sortableTextsEn;\n\n // a live region of our own, so a screen reader hears where the item is / свой живой регион для скринридера\n let live: HTMLElement | null = null;\n function announce(template: string, index: number) {\n if (!live) return;\n const els = items();\n const label = els[index] ? (options.itemLabel?.(els[index]!, index) ?? els[index]!.textContent?.trim() ?? '') : '';\n live.textContent = template\n .replace('{item}', label)\n .replace('{position}', String(index + 1))\n .replace('{count}', String(els.length));\n }\n\n const items = () => (container.value ? Array.from(container.value.querySelectorAll<HTMLElement>(ITEM)) : []);\n const along = (r: DOMRect) => (axis === 'y' ? r.top : r.left);\n const sizeOf = (r: DOMRect) => (axis === 'y' ? r.height : r.width);\n const pointerOf = (e: PointerEvent) => (axis === 'y' ? e.clientY : e.clientX);\n\n //---]>\n // the pointer / указатель\n\n let drag: {\n from: number;\n to: number;\n start: number;\n scroll0: number;\n starts: number[];\n sizes: number[];\n step: number;\n els: HTMLElement[];\n handle: HTMLElement;\n pointerId: number;\n last: [number, number];\n scroller: HTMLElement | null;\n } | null = null;\n\n const scrollPos = (s: HTMLElement | null) => (s ? (axis === 'y' ? s.scrollTop : s.scrollLeft) : axis === 'y' ? window.scrollY : window.scrollX);\n\n const edge = createEdgeScroller({\n bounds: () => {\n if (!drag) return null;\n if (drag.scroller) return drag.scroller.getBoundingClientRect();\n return { left: 0, top: 0, width: window.innerWidth, height: window.innerHeight };\n },\n pointer: () => drag?.last ?? [0, 0],\n enabled: () => drag !== null,\n onScroll: (dx, dy) => {\n if (!drag) return;\n const d = axis === 'y' ? dy : dx;\n if (drag.scroller) {\n if (axis === 'y') drag.scroller.scrollTop += d;\n else drag.scroller.scrollLeft += d;\n } else {\n window.scrollBy(axis === 'y' ? 0 : d, axis === 'y' ? d : 0);\n }\n follow();\n },\n });\n\n function follow() {\n if (!drag) return;\n const pointer = (axis === 'y' ? drag.last[1] : drag.last[0]) + scrollPos(drag.scroller) - drag.scroll0;\n // the item stays within the list: past its ends it would make the scrolled area longer, the edge scroll would\n // follow it, and the two would run away together\n // элемент не выходит за пределы списка: за краями он удлинял бы прокручиваемую область, прокрутка у края шла бы\n // за ним, и они убегали бы вместе\n const { starts, sizes, from } = drag;\n const last = starts.length - 1;\n const min = starts[0]! - starts[from]!;\n const max = starts[last]! + sizes[last]! - (starts[from]! + sizes[from]!);\n // the place follows the pointer itself, only what is drawn is held in: past the end it is the last place\n // место следует за самим указателем, ограничено только то, что нарисовано: за краем — последнее место\n const raw = pointer - drag.start;\n const offset = Math.min(max, Math.max(min, raw));\n const to = sortTarget(starts[from]! + sizes[from]! / 2 + raw, starts, sizes, from);\n drag.to = to;\n const shifts = sortShifts(drag.els.length, drag.from, to, drag.step);\n drag.els.forEach((el, i) => {\n const value = i === drag!.from ? offset : shifts[i]!;\n el.style.transform = value ? (axis === 'y' ? `translateY(${value}px)` : `translateX(${value}px)`) : '';\n });\n }\n\n function onPointerDown(event: PointerEvent) {\n if (toValue(options.disabled) || event.button !== 0 || lifted.value !== null) return;\n const handle = (event.target as HTMLElement).closest<HTMLElement>(HANDLE);\n if (!handle || !container.value?.contains(handle)) return;\n const els = items();\n const from = els.findIndex((el) => el.contains(handle));\n if (from < 0) return;\n event.preventDefault();\n\n const rects = els.map((el) => el.getBoundingClientRect());\n const scroller = scrollParent(container.value, axis);\n // the others make room by the dragged item's size and the gap between items\n // остальные расступаются на размер перетаскиваемого элемента и зазор между элементами\n const gap = els.length > 1 ? Math.max(0, along(rects[1]!) - along(rects[0]!) - sizeOf(rects[0]!)) : 0;\n const step = sizeOf(rects[from]!) + gap;\n drag = {\n from,\n to: from,\n start: pointerOf(event),\n scroll0: scrollPos(scroller),\n starts: rects.map(along),\n sizes: rects.map(sizeOf),\n step,\n els,\n handle,\n pointerId: event.pointerId,\n last: [event.clientX, event.clientY],\n scroller,\n };\n try {\n // the moves come to the handle even off the list; optional, the document listens anyway\n // движения приходят на ручку и вне списка; не обязательно, документ всё равно слушает\n handle.setPointerCapture?.(event.pointerId);\n } catch {\n /* a pointer the browser does not know (a synthetic event) / указатель, неизвестный браузеру */\n }\n els.forEach((el, i) => {\n el.style.transition = i === from ? 'none' : 'transform 150ms ease';\n if (i === from) {\n el.style.position = 'relative';\n el.style.zIndex = '1';\n el.setAttribute('data-sortable-dragging', '');\n }\n });\n dragging.value = from;\n document.addEventListener('pointermove', onPointerMove);\n document.addEventListener('pointerup', onPointerUp);\n document.addEventListener('pointercancel', onPointerCancel);\n document.addEventListener('keydown', onDragKey, true);\n }\n\n function onPointerMove(event: PointerEvent) {\n if (!drag || event.pointerId !== drag.pointerId) return;\n drag.last = [event.clientX, event.clientY];\n follow();\n edge.kick();\n }\n\n function finish(commit: boolean) {\n if (!drag) return;\n const { from, to, els, handle, pointerId } = drag;\n drag = null;\n edge.stop();\n try {\n handle.releasePointerCapture?.(pointerId);\n } catch {\n /* already released / уже отпущен */\n }\n document.removeEventListener('pointermove', onPointerMove);\n document.removeEventListener('pointerup', onPointerUp);\n document.removeEventListener('pointercancel', onPointerCancel);\n document.removeEventListener('keydown', onDragKey, true);\n for (const el of els) {\n el.style.transform = '';\n el.style.transition = '';\n el.style.position = '';\n el.style.zIndex = '';\n el.removeAttribute('data-sortable-dragging');\n }\n dragging.value = null;\n if (commit && to !== from) options.onMove(from, to);\n }\n\n const onPointerUp = (event: PointerEvent) => {\n if (drag && event.pointerId === drag.pointerId) finish(true);\n };\n const onPointerCancel = () => finish(false);\n function onDragKey(event: KeyboardEvent) {\n if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n finish(false);\n }\n }\n\n //---]>\n // the keyboard / клавиатура\n\n let liftedFrom = 0;\n\n function focusHandle(index: number) {\n // after the app moved the item and Vue redrew the list / после того как приложение переставило элемент\n requestAnimationFrame(() => items()[index]?.querySelector<HTMLElement>(HANDLE)?.focus());\n }\n\n function setLifted(index: number | null) {\n items().forEach((el, i) => {\n if (i === index) el.setAttribute('data-sortable-lifted', '');\n else el.removeAttribute('data-sortable-lifted');\n });\n lifted.value = index;\n }\n\n function onKeydown(event: KeyboardEvent) {\n if (toValue(options.disabled) || drag) return;\n const handle = (event.target as HTMLElement).closest<HTMLElement>(HANDLE);\n if (!handle || !container.value?.contains(handle)) return;\n const els = items();\n const index = els.findIndex((el) => el.contains(handle));\n if (index < 0) return;\n\n const pick = event.key === ' ' || event.key === 'Enter';\n if (lifted.value === null) {\n if (!pick) return;\n event.preventDefault();\n liftedFrom = index;\n setLifted(index);\n announce(texts().lifted, index);\n return;\n }\n\n const back = axis === 'y' ? 'ArrowUp' : 'ArrowLeft';\n const forward = axis === 'y' ? 'ArrowDown' : 'ArrowRight';\n if (event.key === back || event.key === forward) {\n event.preventDefault();\n const to = index + (event.key === forward ? 1 : -1);\n if (to < 0 || to >= els.length) return;\n options.onMove(index, to);\n requestAnimationFrame(() => {\n setLifted(to);\n announce(texts().moved, to);\n });\n focusHandle(to);\n } else if (pick) {\n event.preventDefault();\n setLifted(null);\n announce(texts().dropped, index);\n } else if (event.key === 'Escape') {\n event.preventDefault();\n event.stopPropagation();\n if (index !== liftedFrom) {\n options.onMove(index, liftedFrom);\n focusHandle(liftedFrom);\n }\n setLifted(null);\n requestAnimationFrame(() => announce(texts().canceled, liftedFrom));\n } else if (event.key === 'Tab') {\n // leaving the handle drops the item where it is / уход с ручки ставит элемент на месте\n setLifted(null);\n }\n }\n\n function onFocusOut(event: FocusEvent) {\n if (lifted.value === null) return;\n const next = event.relatedTarget as HTMLElement | null;\n // focus moving to the same item's handle after a move is not a leave / переход фокуса на ручку после переноса\n if (next?.closest(HANDLE) && container.value?.contains(next)) return;\n if (next) setLifted(null);\n }\n\n onMounted(() => {\n const el = container.value;\n if (!el) return;\n el.addEventListener('pointerdown', onPointerDown);\n el.addEventListener('keydown', onKeydown);\n el.addEventListener('focusout', onFocusOut);\n live = document.createElement('div');\n live.setAttribute('aria-live', 'assertive');\n live.setAttribute('aria-atomic', 'true');\n live.style.cssText = 'position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap';\n document.body.appendChild(live);\n });\n\n onBeforeUnmount(() => {\n finish(false);\n const el = container.value;\n el?.removeEventListener('pointerdown', onPointerDown);\n el?.removeEventListener('keydown', onKeydown);\n el?.removeEventListener('focusout', onFocusOut);\n live?.remove();\n live = null;\n });\n\n return {\n /** The index being dragged by the pointer, or null. / Индекс, который тащат указателем, или null. */\n dragging,\n /** The index lifted by the keyboard, or null. / Индекс, поднятый с клавиатуры, или null. */\n lifted,\n /** Stops a pointer drag without moving. / Прерывает перетаскивание без переноса. */\n cancel: () => finish(false),\n };\n}\n"],"mappings":";;;;;;;;AA8BA,SAAgB,WAAW,SAAiB,QAA2B,OAA0B,MAAsB;CACnH,IAAI,SAAS;CACb,KAAK,IAAI,IAAI,GAAG,IAAI,OAAO,QAAQ,KAAK;EACpC,IAAI,MAAM,MAAM;EAChB,IAAI,UAAU,OAAO,KAAM,MAAM,KAAM,GAAG;CAC9C;CACA,OAAO;AACX;;;;;;AAOA,SAAgB,WAAW,OAAe,MAAc,IAAY,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AS,cAAc,KAAK;EACnC,KAAK,aAAa,aAAa,WAAW;EAC1C,KAAK,aAAa,eAAe,MAAM;EACvC,KAAK,MAAM,UAAU;EACrB,SAAS,KAAK,YAAY,IAAI;CAClC,CAAC;CAED,sBAAsB;EAClB,OAAO,KAAK;EACZ,MAAM,KAAK,UAAU;EACrB,IAAI,oBAAoB,eAAe,aAAa;EACpD,IAAI,oBAAoB,WAAW,SAAS;EAC5C,IAAI,oBAAoB,YAAY,UAAU;EAC9C,MAAM,OAAO;EACb,OAAO;CACX,CAAC;CAED,OAAO;;EAEH;;EAEA;;EAEA,cAAc,OAAO,KAAK;CAC9B;AACJ"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { type SwipeRowAction } from './model';
|
|
2
|
+
type __VLS_Props = {
|
|
3
|
+
/** The action behind the row on a pull to the start. / Действие позади строки при свайпе вправо. */
|
|
4
|
+
start?: SwipeRowAction;
|
|
5
|
+
/** The actions on a pull to the end, in order; the last one is the full swipe. / Действия при свайпе влево; последнее — длинный свайп. */
|
|
6
|
+
end?: SwipeRowAction[];
|
|
7
|
+
/** The width of each end action when the row is open, px. / Ширина каждого действия справа в открытой строке. */
|
|
8
|
+
actionWidth?: number;
|
|
9
|
+
/** Pulling far to the end runs the last action. / Длинный свайп влево выполняет последнее действие. */
|
|
10
|
+
fullSwipe?: boolean;
|
|
11
|
+
/** A mouse can drag it too (a touch screen always can). / Тянуть можно и мышью (палец может всегда). */
|
|
12
|
+
mouse?: boolean;
|
|
13
|
+
disabled?: boolean;
|
|
14
|
+
};
|
|
15
|
+
type __VLS_Slots = {
|
|
16
|
+
default?(): unknown;
|
|
17
|
+
/** Your own face of an action. / Свой вид действия. */
|
|
18
|
+
action?(props: {
|
|
19
|
+
action: SwipeRowAction;
|
|
20
|
+
armed: boolean;
|
|
21
|
+
side: 'start' | 'end';
|
|
22
|
+
}): unknown;
|
|
23
|
+
};
|
|
24
|
+
type __VLS_ModelProps = {
|
|
25
|
+
/** The end actions are shown. / Действия справа открыты. */
|
|
26
|
+
'open'?: boolean;
|
|
27
|
+
};
|
|
28
|
+
type __VLS_PublicProps = __VLS_Props & __VLS_ModelProps;
|
|
29
|
+
declare const __VLS_base: import("vue").DefineComponent<__VLS_PublicProps, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
30
|
+
action: (id: string) => any;
|
|
31
|
+
"update:open": (value: boolean) => any;
|
|
32
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_PublicProps> & Readonly<{
|
|
33
|
+
onAction?: ((id: string) => any) | undefined;
|
|
34
|
+
"onUpdate:open"?: ((value: boolean) => any) | undefined;
|
|
35
|
+
}>, {
|
|
36
|
+
end: SwipeRowAction[];
|
|
37
|
+
disabled: boolean;
|
|
38
|
+
start: SwipeRowAction;
|
|
39
|
+
actionWidth: number;
|
|
40
|
+
fullSwipe: boolean;
|
|
41
|
+
mouse: boolean;
|
|
42
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
43
|
+
declare const __VLS_export: __VLS_WithSlots<typeof __VLS_base, __VLS_Slots>;
|
|
44
|
+
declare const _default: typeof __VLS_export;
|
|
45
|
+
export default _default;
|
|
46
|
+
type __VLS_WithSlots<T, S> = T & {
|
|
47
|
+
new (): {
|
|
48
|
+
$slots: S;
|
|
49
|
+
};
|
|
50
|
+
};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { default as TaoxSwipeRow } from './TaoxSwipeRow.vue';
|
|
2
|
+
export { armedAt, clampOffset, endOpenWidth, endWidths, FULL_SWIPE_RATIO, fullThreshold, START_THRESHOLD_PX, startThreshold, swipeRowRelease, } from './model';
|
|
3
|
+
export type { SwipeRowAction, SwipeRowGeometry, SwipeRowOutcome } from './model';
|