@1337exp/taoux 0.5.2 → 0.5.4

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 CHANGED
@@ -1,5 +1,15 @@
1
1
  # Changelog
2
2
 
3
+ ## 0.5.4
4
+
5
+ - **`swiperow`: Tab from the start action to an end one.** The start side stayed shown and won, so the end action that got the focus stayed hidden under the row (it came out only after the window lost and got back the focus). An action that gets the focus now shows its side and only its side; the focus on the row's own content shows neither.
6
+
7
+ ## 0.5.3
8
+
9
+ - **`sortable` no longer gives a page a scroll.** Its live region stood absolute at the end of the body, so on a page exactly the window's height it hung a pixel below and the page scrolled by 1px. It is fixed at the corner of the window now.
10
+ - **`swiperow` takes its colour from `--tx-swipe-bg`.** The face of the row and the ground its actions are tinted on were the raised surface with no way to change them, so a row right on the page showed a lighter edge at its corners. `--tx-swipe-bg` (the raised surface by default) sets both: `var(--tao-color-bg)` for a row on the page. The TaoUI bridge (`taoui.css`) maps it. `--tx-swipe-radius` and `--tx-swipe-gap` now work from an element around the row too: they were set on the row itself, so a value on its list was overridden.
11
+ - **[docs/swiperow.md](docs/swiperow.md):** the variables of the row, and how to test a swipe automatically: synthetic pointer events go to `.tx-swipe__front`, in several moves (the first one past the slop only decides the swipe and becomes the zero point), with the window keeping the focus; a Playwright example with real touches.
12
+
3
13
  ## 0.5.2
4
14
 
5
15
  - **`swiperow` without the full swipe.** `:full-swipe="false"` turned the long pull off, but the row hit a hard stop at one and a half times the open actions, and the middle actions still shrank as if the last were about to run. Now a pull past the open actions meets a spring (the row follows ever slower, up to half their width more), the actions grow side by side, and on release the row rests open: nothing runs.
package/README.md CHANGED
@@ -110,7 +110,7 @@ import { History } from '@1337exp/taoux/history';
110
110
  | `pins` | row pin positions measured from the DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
111
111
  | `i18n` | typed i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, optional) |
112
112
 
113
- 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)).
113
+ 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 swipe row, its variables and how to test a swipe are in [docs/swiperow.md](docs/swiperow.md) ([Русский](docs/swiperow.ru.md)). 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)).
114
114
 
115
115
  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.
116
116
 
package/README.ru.md CHANGED
@@ -110,7 +110,7 @@ import { History } from '@1337exp/taoux/history';
110
110
  | `pins` | позиции пинов-строк, измеренные по DOM: `usePinMeasure`, `createPinRegistry` | vue (peer) |
111
111
  | `i18n` | типизированный i18n: `createI18n({ locales, fallback, storageKey })` | vue (peer, опционально) |
112
112
 
113
- 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).
113
+ 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/swiperow.ru.md](docs/swiperow.ru.md); контракт холста описан в [docs/canvas.ru.md](docs/canvas.ru.md), переходы между точками кривой в [docs/ease.ru.md](docs/ease.ru.md).
114
114
 
115
115
  Правило: модуль попадает сюда, когда он понадобился во втором проекте. Ядро модулей не знает про Vue и DOM, если это не их задача.
116
116
 
package/dist/sortable.js CHANGED
@@ -271,7 +271,7 @@ function useSortable(container, options) {
271
271
  live = document.createElement("div");
272
272
  live.setAttribute("aria-live", "assertive");
273
273
  live.setAttribute("aria-atomic", "true");
274
- live.style.cssText = "position:absolute;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap";
274
+ live.style.cssText = "position:fixed;top:0;left:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;pointer-events:none";
275
275
  document.body.appendChild(live);
276
276
  });
277
277
  onBeforeUnmount(() => {
@@ -1 +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';\nimport { listenFocusLoss } from './gestures';\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 let stopFocusLoss: (() => void) | undefined;\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 // the window lost the focus mid-drag (Alt-Tab, a screenshot): the pointerup may never come; put the item back\n // окно потеряло фокус посреди перетаскивания: pointerup может не прийти; возвращаем элемент на место\n stopFocusLoss = listenFocusLoss(() => finish(false));\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 stopFocusLoss?.();\n stopFocusLoss = undefined;\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":";;;;;;;;;AA+BA,SAAgB,WAAW,SAAiB,QAA2B,OAA0B,MAAsB;CACnH,IAAI,SAAS;CACb,KAAK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AI,MAAM,QAAQ,MAAM,KAAK,UAAU,OAAO,SAAS,IAAI,GAAG;EAC9D,IAAI,MAAM,UAAU,IAAI;CAC5B;CAEA,gBAAgB;EACZ,MAAM,KAAK,UAAU;EACrB,IAAI,CAAC,IAAI;EACT,GAAG,iBAAiB,eAAe,aAAa;EAChD,GAAG,iBAAiB,WAAW,SAAS;EACxC,GAAG,iBAAiB,YAAY,UAAU;EAC1C,OAAO,SAAS,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"}
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';\nimport { listenFocusLoss } from './gestures';\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 let stopFocusLoss: (() => void) | undefined;\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 // the window lost the focus mid-drag (Alt-Tab, a screenshot): the pointerup may never come; put the item back\n // окно потеряло фокус посреди перетаскивания: pointerup может не прийти; возвращаем элемент на место\n stopFocusLoss = listenFocusLoss(() => finish(false));\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 stopFocusLoss?.();\n stopFocusLoss = undefined;\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 // fixed at the corner of the window: an absolute one at the end of the body stood a pixel below a page exactly\n // the window's height and gave it a scroll / в углу окна: абсолютная в конце body стояла на пиксель ниже\n // страницы ровно в высоту окна и давала ей прокрутку\n live.style.cssText = 'position:fixed;top:0;left:0;width:1px;height:1px;overflow:hidden;clip-path:inset(50%);white-space:nowrap;pointer-events:none';\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":";;;;;;;;;AA+BA,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,MAAwB;CACxF,OAAO,MAAM,KAAK,EAAE,QAAQ,MAAM,IAAI,GAAG,MAAM;EAC3C,IAAI,MAAM,MAAM,OAAO;EACvB,IAAI,OAAO,MAAM,IAAI,QAAQ,KAAK,IAAI,OAAO,CAAC;EAC9C,IAAI,KAAK,QAAQ,KAAK,MAAM,IAAI,MAAM,OAAO;EAC7C,OAAO;CACX,CAAC;AACL;;AAGA,SAAgB,SAAY,MAA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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"}
package/dist/swiperow.css CHANGED
@@ -1,10 +1,21 @@
1
1
 
2
+ /*
3
+ * Variables, on the row or on any element around it (the defaults stand in var(), so an ancestor's value reaches here):
4
+ * --tx-swipe-bg the face of the row and the ground its actions are tinted on (the raised surface; a row right on
5
+ * the page: var(--tao-color-bg))
6
+ * --tx-swipe-radius the corners of the row (the panel radius)
7
+ * --tx-swipe-gap the gap between the end actions (6px)
8
+ * Переменные — на строке или на любом элементе вокруг неё (значения по умолчанию стоят в var(), поэтому значение предка
9
+ * доходит сюда): --tx-swipe-bg — лицо строки и основа подкраски действий; --tx-swipe-radius — углы; --tx-swipe-gap —
10
+ * зазор между действиями справа.
11
+ */
2
12
  .tx-swipe {
3
- --tx-swipe-gap: 6px;
4
- --tx-swipe-radius: var(--tao-radius-panel, 12px);
13
+ --_tx-swipe-gap: var(--tx-swipe-gap, 6px);
14
+ --_tx-swipe-radius: var(--tx-swipe-radius, var(--tao-radius-panel, 12px));
15
+ --_tx-swipe-bg: var(--tx-swipe-bg, var(--tao-color-surface-raised, #1f1f1f));
5
16
  position: relative;
6
17
  overflow: hidden;
7
- border-radius: var(--tx-swipe-radius);
18
+ border-radius: var(--_tx-swipe-radius);
8
19
  }
9
20
  .tx-swipe__front {
10
21
  position: relative;
@@ -12,7 +23,7 @@
12
23
  /* the page keeps the vertical scroll, the tracker takes the sideways pull / вертикаль — странице, вбок — трекеру */
13
24
  touch-action: pan-y;
14
25
  border-radius: inherit;
15
- background: var(--tao-color-surface-raised, #1f1f1f);
26
+ background: var(--_tx-swipe-bg);
16
27
  transition: transform 0.22s ease;
17
28
  }
18
29
  .tx-swipe--dragging .tx-swipe__front {
@@ -33,7 +44,7 @@
33
44
  position: absolute;
34
45
  inset-block: 0;
35
46
  display: flex;
36
- gap: var(--tx-swipe-gap);
47
+ gap: var(--_tx-swipe-gap);
37
48
  }
38
49
 
39
50
  /* clipped, with the gap as the button's margin: at width 0 nothing of it is left, while the keyboard can still reach it
@@ -71,8 +82,8 @@
71
82
  padding: 0;
72
83
  overflow: hidden;
73
84
  border: 0;
74
- border-radius: var(--tx-swipe-radius);
75
- background: color-mix(in srgb, var(--tao-tone) 22%, var(--tao-color-surface-raised, #1f1f1f));
85
+ border-radius: var(--_tx-swipe-radius);
86
+ background: color-mix(in srgb, var(--tao-tone) 22%, var(--_tx-swipe-bg));
76
87
  color: var(--tao-tone-text);
77
88
  font: inherit;
78
89
  font-size: 13px;
@@ -96,11 +107,11 @@
96
107
  justify-content: flex-start;
97
108
  gap: 10px;
98
109
  min-width: 0;
99
- margin-inline-end: var(--tx-swipe-gap);
110
+ margin-inline-end: var(--_tx-swipe-gap);
100
111
  padding-inline-start: 22px;
101
112
  }
102
113
  .tx-swipe__action--armed {
103
- background: color-mix(in srgb, var(--tao-tone) 45%, var(--tao-color-surface-raised, #1f1f1f));
114
+ background: color-mix(in srgb, var(--tao-tone) 45%, var(--_tx-swipe-bg));
104
115
  color: var(--tao-color-text-strong);
105
116
  }
106
117
  .tx-swipe__action:focus-visible {
package/dist/swiperow.js CHANGED
@@ -231,8 +231,8 @@ var TaoxSwipeRow_default = /* @__PURE__ */ defineComponent({
231
231
  }
232
232
  function onFocusIn(e) {
233
233
  const side = e.target.closest("[data-side]")?.dataset.side;
234
- if (side === "end") open.value = true;
235
- if (side === "start") startShown.value = true;
234
+ startShown.value = side === "start";
235
+ open.value = side === "end";
236
236
  }
237
237
  function onFocusOut(e) {
238
238
  if (root.value?.contains(e.relatedTarget)) return;
@@ -1 +1 @@
1
- {"version":3,"file":"swiperow.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createElementVNode","_unref","_renderSlot","_createBlock","_createCommentVNode","_toDisplayString","_Fragment","_renderList","_sfc_main"],"sources":["../src/swiperow/model.ts","../src/swiperow/TaoxSwipeRow.vue","../src/swiperow/TaoxSwipeRow.vue"],"sourcesContent":["import { settleOpen, SWIPE_FLING_PX_PER_MS, type SwipeRelease } from '../gestures';\n\n/**\n * An action of a swipe row. `tone` is a TaoUI tone (`neutral`, `danger`, `success`…), `icon` a TaoIcon name.\n * Действие свайп-строки. `tone` — тон TaoUI, `icon` — имя TaoIcon.\n */\nexport interface SwipeRowAction {\n id: string;\n label: string;\n icon?: string;\n tone?: 'accent' | 'neutral' | 'success' | 'danger' | 'warning' | 'info';\n}\n\n/**\n * The thresholds of the row, px or a share of its width.\n * Пороги строки, px или доля её ширины.\n */\nexport interface SwipeRowGeometry {\n /** The row width. / Ширина строки. */\n width: number;\n /** How wide each end action stands when the row is open. / Ширина каждого действия справа в открытой строке. */\n actionWidth: number;\n /** How many end actions. / Сколько действий справа. */\n endCount: number;\n /** Whether there is a start action. / Есть ли действие слева. */\n hasStart: boolean;\n /** Whether pulling far runs the last end action by itself. / Выполняет ли длинный свайп последнее действие сам. */\n fullSwipe: boolean;\n}\n\n/** Past this share of the width a pull to the end runs the last action. / После этой доли ширины длинный свайп выполняет последнее действие. */\nexport const FULL_SWIPE_RATIO = 0.6;\n/** A pull to the start runs its action past this many px (or a third of a narrow row). / Свайп вправо выполняет действие после стольких px. */\nexport const START_THRESHOLD_PX = 96;\n\nexport const startThreshold = (g: SwipeRowGeometry) => Math.min(START_THRESHOLD_PX, g.width / 3);\nexport const endOpenWidth = (g: SwipeRowGeometry) => g.actionWidth * g.endCount;\nexport const fullThreshold = (g: SwipeRowGeometry) => Math.max(endOpenWidth(g) + 24, g.width * FULL_SWIPE_RATIO);\n\n/**\n * Whether the row, at this offset, is past the point where releasing runs an action: `start`, `full` or null.\n * Пройдена ли при этом сдвиге точка, после которой отпускание выполняет действие: `start`, `full` или null.\n */\nexport function armedAt(offset: number, g: SwipeRowGeometry): 'start' | 'full' | null {\n if (offset > 0 && g.hasStart && offset >= startThreshold(g)) return 'start';\n if (offset < 0 && g.fullSwipe && g.endCount > 0 && -offset >= fullThreshold(g)) return 'full';\n return null;\n}\n\n/**\n * How far the row may move: no further than there is something behind it. Without the full swipe a pull past the open\n * actions meets a spring: it still follows the finger, ever slower, up to half the open width more, and on release the\n * row rests open.\n * Насколько строка может уехать. Без длинного свайпа протяжка дальше открытых действий упирается в пружину: строка\n * всё ещё идёт за пальцем, всё медленнее, не дальше ещё половины открытой ширины, а после отпускания остаётся открытой.\n */\nexport function clampOffset(offset: number, g: SwipeRowGeometry): number {\n const right = g.hasStart ? g.width : 0;\n if (offset < 0 && g.endCount > 0 && !g.fullSwipe) {\n const open = endOpenWidth(g);\n const over = -offset - open;\n if (over <= 0) return offset;\n const room = open / 2;\n return -(open + room * (1 - 1 / (1 + over / room)));\n }\n const left = g.endCount === 0 ? 0 : -g.width;\n return Math.min(right, Math.max(left, offset));\n}\n\nexport type SwipeRowOutcome =\n | { kind: 'rest'; open: boolean } // the row comes to rest: open (the end actions shown) or closed\n | { kind: 'start' } // the start action runs, the row goes back\n | { kind: 'full' }; // the last end action runs\n\n/**\n * What a release does. A pull to the start past its threshold (or flung that way past half of it) runs the start\n * action; a pull to the end past the full threshold runs the last end action; otherwise the row rests open or closed,\n * a fling going on in its direction (`settleOpen`).\n * Что делает отпускание. Свайп вправо дальше порога (или брошенный туда дальше его половины) выполняет действие слева;\n * влево дальше полного порога — последнее действие справа; иначе строка встаёт открытой или закрытой, бросок\n * продолжается в своём направлении.\n */\nexport function swipeRowRelease(release: SwipeRelease, g: SwipeRowGeometry): SwipeRowOutcome {\n const offset = clampOffset(release.offset, g);\n const armed = armedAt(offset, g);\n if (armed) return { kind: armed };\n if (offset > 0 && g.hasStart && release.velocity >= SWIPE_FLING_PX_PER_MS && offset >= startThreshold(g) / 2) {\n return { kind: 'start' };\n }\n if (g.endCount === 0) return { kind: 'rest', open: false };\n const rest = settleOpen({ offset: Math.min(0, offset), velocity: release.velocity }, { end: endOpenWidth(g) });\n return { kind: 'rest', open: rest < 0 };\n}\n\n/** The narrowest an action between the row and the last one gets: still a visible link. / Самое узкое промежуточное действие. */\nexport const SWIPE_SLIVER_PX = 32;\n\n/**\n * The widths of the end actions at a pull of `drag` px (≥ 0), one continuous function, so nothing jumps. Up to the\n * open width they share the space evenly and grow to their width. Past it the actions between the row and the last one\n * stop growing and shrink back, smoothly, to slivers (`SWIPE_SLIVER_PX`) a little past the full-swipe threshold, and the last one\n * takes what they give up; further on they stay slivers, so a pull back opens them out again the same way.\n * `armed` is no longer used (the widths depend on the pull alone); it stays for the 0.5.0 signature.\n * Ширины действий справа при протяжке на `drag` px — одна непрерывная функция, поэтому ничего не прыгает. До открытой\n * ширины они делят место поровну и растут до своей ширины. Дальше промежуточные перестают расти и плавно сжимаются до\n * полосок к порогу длинного свайпа, а последнее забирает отданное место; за порогом они остаются полосками, поэтому\n * при обратном движении так же плавно раскрываются. `armed` больше не нужен; оставлен ради подписи 0.5.0.\n */\nexport function endWidths(drag: number, g: SwipeRowGeometry, _armed?: boolean, gap = 6): number[] {\n const n = g.endCount;\n if (n === 0 || drag <= 0) return Array.from({ length: n }, () => 0);\n const room = Math.max(0, drag - gap * n);\n const open = endOpenWidth(g);\n if (n === 1) return [room];\n // without the full swipe nothing is about to run: the actions only grow, side by side\n // без длинного свайпа ничего не выполнится: действия просто растут, все поровну\n if (drag <= open || !g.fullSwipe) return Array.from({ length: n }, () => room / n);\n\n // the squeeze runs a little past the full threshold (a fifth of the row more), so on a phone it takes a long stretch\n // of the pull and reads as a slide, not a snap\n // сжатие идёт чуть дальше порога длинного свайпа (ещё пятая часть строки), поэтому на телефоне занимает длинный\n // отрезок протяжки и читается как плавный переход, а не рывок\n const end = Math.max(open + 1, Math.min(g.width * 0.9, fullThreshold(g) + g.width * 0.2));\n const t = Math.min(1, (drag - open) / (end - open));\n const widest = g.actionWidth - gap;\n const middle = Math.min(widest, Math.max(0, widest + (Math.min(SWIPE_SLIVER_PX, widest) - widest) * t));\n return Array.from({ length: n }, (_, i) => (i === n - 1 ? room - middle * (n - 1) : middle));\n}\n","<script lang=\"ts\" setup>\nimport { TaoIcon, toneClass } from '@1337exp/taoui';\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { listenFocusLoss, SwipeTracker, type Sample } from '../gestures';\nimport { armedAt, clampOffset, endOpenWidth, endWidths, startThreshold, swipeRowRelease, type SwipeRowAction, type SwipeRowGeometry } from './model';\n\n// A row of a list that a finger slides sideways, as in a mail app. To the start (right): one action behind it, run on\n// release past its threshold, and the row comes back (read / unread). To the end (left): the actions grow out and the\n// row stays open on them; pulled far, the last one takes the row and runs on release (delete). The gesture (a swipe or\n// a scroll, the release speed, where to rest) is TaoUX's gestures; the actions are TaoUI icons and tones.\n// Строка списка, которую палец сдвигает вбок, как в почте. Вправо: одно действие позади, выполняется при отпускании\n// дальше порога, строка возвращается (прочитано / не прочитано). Влево: действия вырастают, и строка остаётся открытой\n// на них; если тянуть далеко, последнее занимает строку и выполняется при отпускании (удалить).\nconst props = withDefaults(\n defineProps<{\n /** The action behind the row on a pull to the start. / Действие позади строки при свайпе вправо. */\n start?: SwipeRowAction;\n /** The actions on a pull to the end, in order; the last one is the full swipe. / Действия при свайпе влево; последнее — длинный свайп. */\n end?: SwipeRowAction[];\n /** The width of each end action when the row is open, px. / Ширина каждого действия справа в открытой строке. */\n actionWidth?: number;\n /** Pulling far to the end runs the last action. / Длинный свайп влево выполняет последнее действие. */\n fullSwipe?: boolean;\n /** A mouse can drag it too (a touch screen always can). / Тянуть можно и мышью (палец может всегда). */\n mouse?: boolean;\n disabled?: boolean;\n }>(),\n { start: undefined, end: () => [], actionWidth: 76, fullSwipe: true, mouse: false, disabled: false },\n);\n\nconst emit = defineEmits<{\n /** An action was chosen: by a button, a pull past the threshold, or the full swipe. / Выбрано действие. */\n action: [id: string];\n}>();\n\n/** The end actions are shown. / Действия справа открыты. */\nconst open = defineModel<boolean>('open', { default: false });\n\ndefineSlots<{\n default?(): unknown;\n /** Your own face of an action. / Свой вид действия. */\n action?(props: { action: SwipeRowAction; armed: boolean; side: 'start' | 'end'; width: number }): unknown;\n}>();\n\nconst root = ref<HTMLElement | null>(null);\nconst width = ref(320);\nconst dragging = ref(false);\nconst drag = ref(0);\n// a moment after a full swipe: the row stays off to the side while the app removes it\n// миг после длинного свайпа: строка остаётся сдвинутой, пока приложение её убирает\nconst gone = ref(false);\nconst startShown = ref(false);\n\nconst geometry = computed<SwipeRowGeometry>(() => ({\n width: width.value,\n actionWidth: props.actionWidth,\n endCount: props.end.length,\n hasStart: Boolean(props.start),\n fullSwipe: props.fullSwipe,\n}));\n\nconst rest = computed(() => {\n if (gone.value) return -width.value;\n if (startShown.value) return startThreshold(geometry.value);\n return open.value ? -endOpenWidth(geometry.value) : 0;\n});\nconst offset = computed(() => (dragging.value ? drag.value : rest.value));\nconst armed = computed(() => (dragging.value ? armedAt(drag.value, geometry.value) : null));\n// gone (the full swipe ran): the last action holds the whole row while the app removes it / последнее держит всю строку\nconst widths = computed(() => endWidths(gone.value ? width.value : Math.max(0, -offset.value), geometry.value));\nconst lastEnd = computed(() => props.end[props.end.length - 1]);\n\n// a short buzz where the phone can, when an action becomes armed / короткая вибрация там, где телефон умеет\nwatch(armed, (next) => {\n if (next && typeof navigator !== 'undefined') navigator.vibrate?.(8);\n});\n\n//---]>\n// the gesture / жест\n\nconst tracker = new SwipeTracker('x');\nlet pointerId: number | null = null;\nlet swiped = false;\nconst sample = (e: PointerEvent): Sample => ({ x: e.clientX, y: e.clientY, t: e.timeStamp });\n\n// the window lost the focus while the press was held (Alt-Tab, a screenshot): its pointerup may never come, so the row\n// lets go and settles where it rested, instead of staying stuck to a finger that is gone\n// окно потеряло фокус во время нажатия: pointerup может не прийти, поэтому строка отпускается и встаёт на место\nlet stopFocusLoss: (() => void) | undefined;\n\nfunction release() {\n stopFocusLoss?.();\n stopFocusLoss = undefined;\n pointerId = null;\n dragging.value = false;\n}\n\nfunction onDown(e: PointerEvent) {\n if (props.disabled || pointerId !== null || (e.pointerType === 'mouse' && (!props.mouse || e.button !== 0))) return;\n pointerId = e.pointerId;\n swiped = false;\n startShown.value = false;\n tracker.down(sample(e), rest.value);\n stopFocusLoss = listenFocusLoss(() => {\n tracker.cancel();\n release();\n });\n}\n\nfunction onMove(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const step = tracker.move(sample(e));\n if (step.intent !== 'swipe') return;\n if (!dragging.value) {\n dragging.value = true;\n try {\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n } catch {\n /* a pointer the browser does not know / неизвестный браузеру указатель */\n }\n }\n swiped = true;\n drag.value = clampOffset(step.offset, geometry.value);\n}\n\nfunction onUp(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const result = tracker.up(sample(e));\n release();\n if (!result) return;\n const outcome = swipeRowRelease(result, geometry.value);\n if (outcome.kind === 'start' && props.start) {\n open.value = false;\n emit('action', props.start.id);\n } else if (outcome.kind === 'full' && lastEnd.value) {\n gone.value = true;\n emit('action', lastEnd.value.id);\n // the app removes the row; if it keeps it (an archive that failed), it comes back\n // приложение убирает строку; если оставит, она вернётся\n setTimeout(() => {\n gone.value = false;\n open.value = false;\n }, 400);\n } else if (outcome.kind === 'rest') {\n open.value = outcome.open;\n }\n}\n\nfunction onCancel(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n tracker.cancel();\n release();\n}\n\n// the end of a swipe also fires a click on the row: it must not open the item\n// конец свайпа даёт и click по строке: он не должен открывать элемент\nfunction onClickCapture(e: MouseEvent) {\n if (swiped) {\n e.stopPropagation();\n e.preventDefault();\n swiped = false;\n }\n}\n\nfunction run(action: SwipeRowAction) {\n open.value = false;\n startShown.value = false;\n emit('action', action.id);\n}\n\n//---]>\n// the keyboard: an action button that gets the focus shows its side\n// клавиатура: кнопка действия, получившая фокус, показывает свою сторону\n\nfunction onFocusIn(e: FocusEvent) {\n const side = (e.target as HTMLElement).closest<HTMLElement>('[data-side]')?.dataset.side;\n if (side === 'end') open.value = true;\n if (side === 'start') startShown.value = true;\n}\n\nfunction onFocusOut(e: FocusEvent) {\n if (root.value?.contains(e.relatedTarget as Node | null)) return;\n startShown.value = false;\n open.value = false;\n}\n\n// an open row closes on a touch outside it / открытая строка закрывается касанием вне её\nfunction onOutside(e: PointerEvent) {\n if (!root.value?.contains(e.target as Node)) open.value = false;\n}\nwatch(open, (isOpen) => {\n if (isOpen) document.addEventListener('pointerdown', onOutside, true);\n else document.removeEventListener('pointerdown', onOutside, true);\n});\n\nlet resize: ResizeObserver | undefined;\nonMounted(() => {\n if (!root.value) return;\n width.value = root.value.clientWidth || width.value;\n if (typeof ResizeObserver !== 'undefined') {\n resize = new ResizeObserver(() => (width.value = root.value?.clientWidth || width.value));\n resize.observe(root.value);\n }\n});\nonBeforeUnmount(() => {\n stopFocusLoss?.();\n resize?.disconnect();\n document.removeEventListener('pointerdown', onOutside, true);\n});\n\nconst startWidth = computed(() => Math.max(0, offset.value));\n\n/*\n * The icon and the label always stand where they end up, so nothing pops in and the heights never jump; only their\n * opacity follows the width of their block. The icon comes first, the label later, when the block is wide enough to\n * hold it.\n * Иконка и подпись всегда стоят на своих итоговых местах, поэтому ничего не выскакивает и высоты не прыгают; от ширины\n * блока зависит только их прозрачность. Иконка проявляется раньше, подпись позже, когда блок уже вмещает её.\n */\nconst fade = (width: number, from: number, span: number) => Math.min(1, Math.max(0, (width - from) / span));\nconst endIcon = (w: number) => fade(w, 22, 20);\nconst endLabel = (w: number) => fade(w, 50, 18);\nconst startIcon = (w: number) => fade(w, 36, 24);\nconst startLabel = (w: number) => fade(w, 84, 28);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"tx-swipe\"\n :class=\"{ 'tx-swipe--dragging': dragging, 'tx-swipe--armed-full': armed === 'full' || gone, 'tx-swipe--mouse': mouse }\"\n @focusin=\"onFocusIn\"\n @focusout=\"onFocusOut\"\n >\n <div v-if=\"start\" class=\"tx-swipe__start\" data-side=\"start\" :style=\"{ width: `${startWidth}px` }\">\n <button\n type=\"button\"\n class=\"tx-swipe__action tx-swipe__action--start\"\n :class=\"[toneClass(start.tone ?? 'neutral'), { 'tx-swipe__action--armed': armed === 'start' }]\"\n :aria-label=\"start.label\"\n @click=\"run(start)\"\n >\n <slot name=\"action\" :action=\"start\" :armed=\"armed === 'start'\" side=\"start\" :width=\"startWidth\">\n <TaoIcon v-if=\"start.icon\" :name=\"start.icon\" :size=\"20\" :style=\"{ opacity: startIcon(startWidth) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: startLabel(startWidth) }\">{{ start.label }}</span>\n </slot>\n </button>\n </div>\n\n <div v-if=\"end.length\" class=\"tx-swipe__end\" data-side=\"end\">\n <button\n v-for=\"(action, i) in end\"\n :key=\"action.id\"\n type=\"button\"\n class=\"tx-swipe__action\"\n :class=\"[toneClass(action.tone ?? 'neutral'), { 'tx-swipe__action--armed': i === end.length - 1 && (armed === 'full' || gone) }]\"\n :style=\"{ width: `${widths[i]}px` }\"\n :aria-label=\"action.label\"\n @click=\"run(action)\"\n >\n <slot name=\"action\" :action=\"action\" :armed=\"i === end.length - 1 && armed === 'full'\" side=\"end\" :width=\"widths[i] ?? 0\">\n <TaoIcon v-if=\"action.icon\" :name=\"action.icon\" :size=\"20\" :style=\"{ opacity: endIcon(widths[i] ?? 0) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: endLabel(widths[i] ?? 0) }\">{{ action.label }}</span>\n </slot>\n </button>\n </div>\n\n <div\n class=\"tx-swipe__front\"\n :style=\"{ transform: `translate3d(${offset}px, 0, 0)` }\"\n @pointerdown=\"onDown\"\n @pointermove=\"onMove\"\n @pointerup=\"onUp\"\n @pointercancel=\"onCancel\"\n @click.capture=\"onClickCapture\"\n >\n <slot />\n </div>\n </div>\n</template>\n\n<style>\n.tx-swipe {\n --tx-swipe-gap: 6px;\n --tx-swipe-radius: var(--tao-radius-panel, 12px);\n position: relative;\n overflow: hidden;\n border-radius: var(--tx-swipe-radius);\n}\n\n.tx-swipe__front {\n position: relative;\n z-index: 1;\n /* the page keeps the vertical scroll, the tracker takes the sideways pull / вертикаль — странице, вбок — трекеру */\n touch-action: pan-y;\n border-radius: inherit;\n background: var(--tao-color-surface-raised, #1f1f1f);\n transition: transform 0.22s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__front {\n transition: none;\n}\n\n/* a pull is not a selection: while it runs nothing is selected; with `mouse` the mouse drags the row, so its text is\n not selected by a press-and-move at all (a finger selects with a long press, which a swipe is not)\n протяжка — не выделение: пока она идёт, ничего не выделяется; с `mouse` мышь тянет строку, поэтому её текст не\n выделяется нажатием с движением вовсе (палец выделяет долгим нажатием, а свайп им не является) */\n.tx-swipe--dragging,\n.tx-swipe--mouse .tx-swipe__front {\n -webkit-user-select: none;\n user-select: none;\n}\n\n.tx-swipe__start,\n.tx-swipe__end {\n position: absolute;\n inset-block: 0;\n display: flex;\n gap: var(--tx-swipe-gap);\n}\n\n/* clipped, with the gap as the button's margin: at width 0 nothing of it is left, while the keyboard can still reach it\n (a padding kept a 6px box, and the button showed at the start edge of a row pulled the other way)\n с обрезкой, а зазор — поле кнопки: при ширине 0 от неё ничего не остаётся, а клавиатура всё равно до неё доходит\n (padding оставлял коробку в 6px, и кнопка виднелась у начального края строки, которую тянули в другую сторону) */\n.tx-swipe__start {\n inset-inline-start: 0;\n overflow: hidden;\n transition: width 0.22s ease;\n}\n\n.tx-swipe__end {\n inset-inline-end: 0;\n justify-content: flex-end;\n}\n\n.tx-swipe--dragging .tx-swipe__start {\n transition: none;\n}\n\n.tx-swipe__action {\n /* a button, not text: a press or a pull over it selects nothing and calls no callout\n кнопка, а не текст: нажатие или протяжка по ней ничего не выделяет и не вызывает меню */\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n display: inline-flex;\n flex: none;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n /* the icon and the label read as one: a small gap, not pressed to the edges of a short row\n иконка и подпись читаются вместе: небольшой зазор, а не прижаты к краям невысокой строки */\n gap: 2px;\n min-width: 0;\n height: 100%;\n padding: 0;\n overflow: hidden;\n border: 0;\n border-radius: var(--tx-swipe-radius);\n background: color-mix(in srgb, var(--tao-tone) 22%, var(--tao-color-surface-raised, #1f1f1f));\n color: var(--tao-tone-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n transition:\n width 0.15s ease,\n background-color 0.15s ease;\n}\n\n/* under the finger the actions follow the row in the same frame: no width easing, or they trail behind it\n под пальцем действия идут за строкой в том же кадре: без сглаживания ширины, иначе они отстают */\n.tx-swipe--dragging .tx-swipe__end .tx-swipe__action {\n transition: background-color 0.15s ease;\n}\n\n/* the start action is one line, from the start edge: the icon at a fixed place, the label after it\n действие слева — одна строка от начального края: иконка на постоянном месте, подпись за ней */\n.tx-swipe__action--start {\n flex: 1;\n flex-direction: row;\n justify-content: flex-start;\n gap: 10px;\n min-width: 0;\n margin-inline-end: var(--tx-swipe-gap);\n padding-inline-start: 22px;\n}\n\n.tx-swipe__action--armed {\n background: color-mix(in srgb, var(--tao-tone) 45%, var(--tao-color-surface-raised, #1f1f1f));\n color: var(--tao-color-text-strong);\n}\n\n.tx-swipe__action:focus-visible {\n outline: 2px solid var(--tao-color-accent);\n outline-offset: -2px;\n}\n\n/* never squeezed or cut with «…»: a label wider than its block stays whole and centred, the block clips it, and it is\n still transparent then; so the line never changes as the block grows\n подпись не сжимается и не обрезается «…»: шире блока — остаётся целой и по центру, блок её обрезает, а она в это\n время ещё прозрачна; поэтому строка не меняется, пока блок растёт */\n.tx-swipe__label {\n flex: none;\n white-space: nowrap;\n line-height: 1.2;\n}\n\n.tx-swipe__action :is(svg, .tao-icon) {\n flex: none;\n}\n\n/* a short fade, so a row settling by itself shows them softly too; under the finger none\n короткий переход: строка, доезжающая сама, тоже их проявляет мягко; под пальцем без него */\n.tx-swipe__label,\n.tx-swipe__action .tao-icon {\n transition: opacity 0.12s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__label,\n.tx-swipe--dragging .tx-swipe__action .tao-icon {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tx-swipe__front,\n .tx-swipe__start,\n .tx-swipe__action,\n .tx-swipe__label,\n .tx-swipe__action .tao-icon {\n transition: none;\n }\n}\n</style>\n","<script lang=\"ts\" setup>\nimport { TaoIcon, toneClass } from '@1337exp/taoui';\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { listenFocusLoss, SwipeTracker, type Sample } from '../gestures';\nimport { armedAt, clampOffset, endOpenWidth, endWidths, startThreshold, swipeRowRelease, type SwipeRowAction, type SwipeRowGeometry } from './model';\n\n// A row of a list that a finger slides sideways, as in a mail app. To the start (right): one action behind it, run on\n// release past its threshold, and the row comes back (read / unread). To the end (left): the actions grow out and the\n// row stays open on them; pulled far, the last one takes the row and runs on release (delete). The gesture (a swipe or\n// a scroll, the release speed, where to rest) is TaoUX's gestures; the actions are TaoUI icons and tones.\n// Строка списка, которую палец сдвигает вбок, как в почте. Вправо: одно действие позади, выполняется при отпускании\n// дальше порога, строка возвращается (прочитано / не прочитано). Влево: действия вырастают, и строка остаётся открытой\n// на них; если тянуть далеко, последнее занимает строку и выполняется при отпускании (удалить).\nconst props = withDefaults(\n defineProps<{\n /** The action behind the row on a pull to the start. / Действие позади строки при свайпе вправо. */\n start?: SwipeRowAction;\n /** The actions on a pull to the end, in order; the last one is the full swipe. / Действия при свайпе влево; последнее — длинный свайп. */\n end?: SwipeRowAction[];\n /** The width of each end action when the row is open, px. / Ширина каждого действия справа в открытой строке. */\n actionWidth?: number;\n /** Pulling far to the end runs the last action. / Длинный свайп влево выполняет последнее действие. */\n fullSwipe?: boolean;\n /** A mouse can drag it too (a touch screen always can). / Тянуть можно и мышью (палец может всегда). */\n mouse?: boolean;\n disabled?: boolean;\n }>(),\n { start: undefined, end: () => [], actionWidth: 76, fullSwipe: true, mouse: false, disabled: false },\n);\n\nconst emit = defineEmits<{\n /** An action was chosen: by a button, a pull past the threshold, or the full swipe. / Выбрано действие. */\n action: [id: string];\n}>();\n\n/** The end actions are shown. / Действия справа открыты. */\nconst open = defineModel<boolean>('open', { default: false });\n\ndefineSlots<{\n default?(): unknown;\n /** Your own face of an action. / Свой вид действия. */\n action?(props: { action: SwipeRowAction; armed: boolean; side: 'start' | 'end'; width: number }): unknown;\n}>();\n\nconst root = ref<HTMLElement | null>(null);\nconst width = ref(320);\nconst dragging = ref(false);\nconst drag = ref(0);\n// a moment after a full swipe: the row stays off to the side while the app removes it\n// миг после длинного свайпа: строка остаётся сдвинутой, пока приложение её убирает\nconst gone = ref(false);\nconst startShown = ref(false);\n\nconst geometry = computed<SwipeRowGeometry>(() => ({\n width: width.value,\n actionWidth: props.actionWidth,\n endCount: props.end.length,\n hasStart: Boolean(props.start),\n fullSwipe: props.fullSwipe,\n}));\n\nconst rest = computed(() => {\n if (gone.value) return -width.value;\n if (startShown.value) return startThreshold(geometry.value);\n return open.value ? -endOpenWidth(geometry.value) : 0;\n});\nconst offset = computed(() => (dragging.value ? drag.value : rest.value));\nconst armed = computed(() => (dragging.value ? armedAt(drag.value, geometry.value) : null));\n// gone (the full swipe ran): the last action holds the whole row while the app removes it / последнее держит всю строку\nconst widths = computed(() => endWidths(gone.value ? width.value : Math.max(0, -offset.value), geometry.value));\nconst lastEnd = computed(() => props.end[props.end.length - 1]);\n\n// a short buzz where the phone can, when an action becomes armed / короткая вибрация там, где телефон умеет\nwatch(armed, (next) => {\n if (next && typeof navigator !== 'undefined') navigator.vibrate?.(8);\n});\n\n//---]>\n// the gesture / жест\n\nconst tracker = new SwipeTracker('x');\nlet pointerId: number | null = null;\nlet swiped = false;\nconst sample = (e: PointerEvent): Sample => ({ x: e.clientX, y: e.clientY, t: e.timeStamp });\n\n// the window lost the focus while the press was held (Alt-Tab, a screenshot): its pointerup may never come, so the row\n// lets go and settles where it rested, instead of staying stuck to a finger that is gone\n// окно потеряло фокус во время нажатия: pointerup может не прийти, поэтому строка отпускается и встаёт на место\nlet stopFocusLoss: (() => void) | undefined;\n\nfunction release() {\n stopFocusLoss?.();\n stopFocusLoss = undefined;\n pointerId = null;\n dragging.value = false;\n}\n\nfunction onDown(e: PointerEvent) {\n if (props.disabled || pointerId !== null || (e.pointerType === 'mouse' && (!props.mouse || e.button !== 0))) return;\n pointerId = e.pointerId;\n swiped = false;\n startShown.value = false;\n tracker.down(sample(e), rest.value);\n stopFocusLoss = listenFocusLoss(() => {\n tracker.cancel();\n release();\n });\n}\n\nfunction onMove(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const step = tracker.move(sample(e));\n if (step.intent !== 'swipe') return;\n if (!dragging.value) {\n dragging.value = true;\n try {\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n } catch {\n /* a pointer the browser does not know / неизвестный браузеру указатель */\n }\n }\n swiped = true;\n drag.value = clampOffset(step.offset, geometry.value);\n}\n\nfunction onUp(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const result = tracker.up(sample(e));\n release();\n if (!result) return;\n const outcome = swipeRowRelease(result, geometry.value);\n if (outcome.kind === 'start' && props.start) {\n open.value = false;\n emit('action', props.start.id);\n } else if (outcome.kind === 'full' && lastEnd.value) {\n gone.value = true;\n emit('action', lastEnd.value.id);\n // the app removes the row; if it keeps it (an archive that failed), it comes back\n // приложение убирает строку; если оставит, она вернётся\n setTimeout(() => {\n gone.value = false;\n open.value = false;\n }, 400);\n } else if (outcome.kind === 'rest') {\n open.value = outcome.open;\n }\n}\n\nfunction onCancel(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n tracker.cancel();\n release();\n}\n\n// the end of a swipe also fires a click on the row: it must not open the item\n// конец свайпа даёт и click по строке: он не должен открывать элемент\nfunction onClickCapture(e: MouseEvent) {\n if (swiped) {\n e.stopPropagation();\n e.preventDefault();\n swiped = false;\n }\n}\n\nfunction run(action: SwipeRowAction) {\n open.value = false;\n startShown.value = false;\n emit('action', action.id);\n}\n\n//---]>\n// the keyboard: an action button that gets the focus shows its side\n// клавиатура: кнопка действия, получившая фокус, показывает свою сторону\n\nfunction onFocusIn(e: FocusEvent) {\n const side = (e.target as HTMLElement).closest<HTMLElement>('[data-side]')?.dataset.side;\n if (side === 'end') open.value = true;\n if (side === 'start') startShown.value = true;\n}\n\nfunction onFocusOut(e: FocusEvent) {\n if (root.value?.contains(e.relatedTarget as Node | null)) return;\n startShown.value = false;\n open.value = false;\n}\n\n// an open row closes on a touch outside it / открытая строка закрывается касанием вне её\nfunction onOutside(e: PointerEvent) {\n if (!root.value?.contains(e.target as Node)) open.value = false;\n}\nwatch(open, (isOpen) => {\n if (isOpen) document.addEventListener('pointerdown', onOutside, true);\n else document.removeEventListener('pointerdown', onOutside, true);\n});\n\nlet resize: ResizeObserver | undefined;\nonMounted(() => {\n if (!root.value) return;\n width.value = root.value.clientWidth || width.value;\n if (typeof ResizeObserver !== 'undefined') {\n resize = new ResizeObserver(() => (width.value = root.value?.clientWidth || width.value));\n resize.observe(root.value);\n }\n});\nonBeforeUnmount(() => {\n stopFocusLoss?.();\n resize?.disconnect();\n document.removeEventListener('pointerdown', onOutside, true);\n});\n\nconst startWidth = computed(() => Math.max(0, offset.value));\n\n/*\n * The icon and the label always stand where they end up, so nothing pops in and the heights never jump; only their\n * opacity follows the width of their block. The icon comes first, the label later, when the block is wide enough to\n * hold it.\n * Иконка и подпись всегда стоят на своих итоговых местах, поэтому ничего не выскакивает и высоты не прыгают; от ширины\n * блока зависит только их прозрачность. Иконка проявляется раньше, подпись позже, когда блок уже вмещает её.\n */\nconst fade = (width: number, from: number, span: number) => Math.min(1, Math.max(0, (width - from) / span));\nconst endIcon = (w: number) => fade(w, 22, 20);\nconst endLabel = (w: number) => fade(w, 50, 18);\nconst startIcon = (w: number) => fade(w, 36, 24);\nconst startLabel = (w: number) => fade(w, 84, 28);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"tx-swipe\"\n :class=\"{ 'tx-swipe--dragging': dragging, 'tx-swipe--armed-full': armed === 'full' || gone, 'tx-swipe--mouse': mouse }\"\n @focusin=\"onFocusIn\"\n @focusout=\"onFocusOut\"\n >\n <div v-if=\"start\" class=\"tx-swipe__start\" data-side=\"start\" :style=\"{ width: `${startWidth}px` }\">\n <button\n type=\"button\"\n class=\"tx-swipe__action tx-swipe__action--start\"\n :class=\"[toneClass(start.tone ?? 'neutral'), { 'tx-swipe__action--armed': armed === 'start' }]\"\n :aria-label=\"start.label\"\n @click=\"run(start)\"\n >\n <slot name=\"action\" :action=\"start\" :armed=\"armed === 'start'\" side=\"start\" :width=\"startWidth\">\n <TaoIcon v-if=\"start.icon\" :name=\"start.icon\" :size=\"20\" :style=\"{ opacity: startIcon(startWidth) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: startLabel(startWidth) }\">{{ start.label }}</span>\n </slot>\n </button>\n </div>\n\n <div v-if=\"end.length\" class=\"tx-swipe__end\" data-side=\"end\">\n <button\n v-for=\"(action, i) in end\"\n :key=\"action.id\"\n type=\"button\"\n class=\"tx-swipe__action\"\n :class=\"[toneClass(action.tone ?? 'neutral'), { 'tx-swipe__action--armed': i === end.length - 1 && (armed === 'full' || gone) }]\"\n :style=\"{ width: `${widths[i]}px` }\"\n :aria-label=\"action.label\"\n @click=\"run(action)\"\n >\n <slot name=\"action\" :action=\"action\" :armed=\"i === end.length - 1 && armed === 'full'\" side=\"end\" :width=\"widths[i] ?? 0\">\n <TaoIcon v-if=\"action.icon\" :name=\"action.icon\" :size=\"20\" :style=\"{ opacity: endIcon(widths[i] ?? 0) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: endLabel(widths[i] ?? 0) }\">{{ action.label }}</span>\n </slot>\n </button>\n </div>\n\n <div\n class=\"tx-swipe__front\"\n :style=\"{ transform: `translate3d(${offset}px, 0, 0)` }\"\n @pointerdown=\"onDown\"\n @pointermove=\"onMove\"\n @pointerup=\"onUp\"\n @pointercancel=\"onCancel\"\n @click.capture=\"onClickCapture\"\n >\n <slot />\n </div>\n </div>\n</template>\n\n<style>\n.tx-swipe {\n --tx-swipe-gap: 6px;\n --tx-swipe-radius: var(--tao-radius-panel, 12px);\n position: relative;\n overflow: hidden;\n border-radius: var(--tx-swipe-radius);\n}\n\n.tx-swipe__front {\n position: relative;\n z-index: 1;\n /* the page keeps the vertical scroll, the tracker takes the sideways pull / вертикаль — странице, вбок — трекеру */\n touch-action: pan-y;\n border-radius: inherit;\n background: var(--tao-color-surface-raised, #1f1f1f);\n transition: transform 0.22s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__front {\n transition: none;\n}\n\n/* a pull is not a selection: while it runs nothing is selected; with `mouse` the mouse drags the row, so its text is\n not selected by a press-and-move at all (a finger selects with a long press, which a swipe is not)\n протяжка — не выделение: пока она идёт, ничего не выделяется; с `mouse` мышь тянет строку, поэтому её текст не\n выделяется нажатием с движением вовсе (палец выделяет долгим нажатием, а свайп им не является) */\n.tx-swipe--dragging,\n.tx-swipe--mouse .tx-swipe__front {\n -webkit-user-select: none;\n user-select: none;\n}\n\n.tx-swipe__start,\n.tx-swipe__end {\n position: absolute;\n inset-block: 0;\n display: flex;\n gap: var(--tx-swipe-gap);\n}\n\n/* clipped, with the gap as the button's margin: at width 0 nothing of it is left, while the keyboard can still reach it\n (a padding kept a 6px box, and the button showed at the start edge of a row pulled the other way)\n с обрезкой, а зазор — поле кнопки: при ширине 0 от неё ничего не остаётся, а клавиатура всё равно до неё доходит\n (padding оставлял коробку в 6px, и кнопка виднелась у начального края строки, которую тянули в другую сторону) */\n.tx-swipe__start {\n inset-inline-start: 0;\n overflow: hidden;\n transition: width 0.22s ease;\n}\n\n.tx-swipe__end {\n inset-inline-end: 0;\n justify-content: flex-end;\n}\n\n.tx-swipe--dragging .tx-swipe__start {\n transition: none;\n}\n\n.tx-swipe__action {\n /* a button, not text: a press or a pull over it selects nothing and calls no callout\n кнопка, а не текст: нажатие или протяжка по ней ничего не выделяет и не вызывает меню */\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n display: inline-flex;\n flex: none;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n /* the icon and the label read as one: a small gap, not pressed to the edges of a short row\n иконка и подпись читаются вместе: небольшой зазор, а не прижаты к краям невысокой строки */\n gap: 2px;\n min-width: 0;\n height: 100%;\n padding: 0;\n overflow: hidden;\n border: 0;\n border-radius: var(--tx-swipe-radius);\n background: color-mix(in srgb, var(--tao-tone) 22%, var(--tao-color-surface-raised, #1f1f1f));\n color: var(--tao-tone-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n transition:\n width 0.15s ease,\n background-color 0.15s ease;\n}\n\n/* under the finger the actions follow the row in the same frame: no width easing, or they trail behind it\n под пальцем действия идут за строкой в том же кадре: без сглаживания ширины, иначе они отстают */\n.tx-swipe--dragging .tx-swipe__end .tx-swipe__action {\n transition: background-color 0.15s ease;\n}\n\n/* the start action is one line, from the start edge: the icon at a fixed place, the label after it\n действие слева — одна строка от начального края: иконка на постоянном месте, подпись за ней */\n.tx-swipe__action--start {\n flex: 1;\n flex-direction: row;\n justify-content: flex-start;\n gap: 10px;\n min-width: 0;\n margin-inline-end: var(--tx-swipe-gap);\n padding-inline-start: 22px;\n}\n\n.tx-swipe__action--armed {\n background: color-mix(in srgb, var(--tao-tone) 45%, var(--tao-color-surface-raised, #1f1f1f));\n color: var(--tao-color-text-strong);\n}\n\n.tx-swipe__action:focus-visible {\n outline: 2px solid var(--tao-color-accent);\n outline-offset: -2px;\n}\n\n/* never squeezed or cut with «…»: a label wider than its block stays whole and centred, the block clips it, and it is\n still transparent then; so the line never changes as the block grows\n подпись не сжимается и не обрезается «…»: шире блока — остаётся целой и по центру, блок её обрезает, а она в это\n время ещё прозрачна; поэтому строка не меняется, пока блок растёт */\n.tx-swipe__label {\n flex: none;\n white-space: nowrap;\n line-height: 1.2;\n}\n\n.tx-swipe__action :is(svg, .tao-icon) {\n flex: none;\n}\n\n/* a short fade, so a row settling by itself shows them softly too; under the finger none\n короткий переход: строка, доезжающая сама, тоже их проявляет мягко; под пальцем без него */\n.tx-swipe__label,\n.tx-swipe__action .tao-icon {\n transition: opacity 0.12s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__label,\n.tx-swipe--dragging .tx-swipe__action .tao-icon {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tx-swipe__front,\n .tx-swipe__start,\n .tx-swipe__action,\n .tx-swipe__label,\n .tx-swipe__action .tao-icon {\n transition: none;\n }\n}\n</style>\n"],"mappings":";;;;;AA+BA,IAAa,mBAAmB;;AAEhC,IAAa,qBAAqB;AAElC,IAAa,kBAAkB,MAAwB,KAAK,IAAA,IAAwB,EAAE,QAAQ,CAAC;AAC/F,IAAa,gBAAgB,MAAwB,EAAE,cAAc,EAAE;AACvE,IAAa,iBAAiB,MAAwB,KAAK,IAAI,aAAa,CAAC,IAAI,IAAI,EAAE,QAAQ,gBAAgB;;;;;AAM/G,SAAgB,QAAQ,QAAgB,GAA8C;CAClF,IAAI,SAAS,KAAK,EAAE,YAAY,UAAU,eAAe,CAAC,GAAG,OAAO;CACpE,IAAI,SAAS,KAAK,EAAE,aAAa,EAAE,WAAW,KAAK,CAAC,UAAU,cAAc,CAAC,GAAG,OAAO;CACvF,OAAO;AACX;;;;;;;;AASA,SAAgB,YAAY,QAAgB,GAA6B;CACrE,MAAM,QAAQ,EAAE,WAAW,EAAE,QAAQ;CACrC,IAAI,SAAS,KAAK,EAAE,WAAW,KAAK,CAAC,EAAE,WAAW;EAC9C,MAAM,OAAO,aAAa,CAAC;EAC3B,MAAM,OAAO,CAAC,SAAS;EACvB,IAAI,QAAQ,GAAG,OAAO;EACtB,MAAM,OAAO,OAAO;EACpB,OAAO,EAAE,OAAO,QAAQ,IAAI,KAAK,IAAI,OAAO;CAChD;CACA,MAAM,OAAO,EAAE,aAAa,IAAI,IAAI,CAAC,EAAE;CACvC,OAAO,KAAK,IAAI,OAAO,KAAK,IAAI,MAAM,MAAM,CAAC;AACjD;;;;;;;;;AAeA,SAAgB,gBAAgB,SAAuB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CAAA,C;;IAKxGL,mBAUM,OAAA;KATF,OAAM;KACL,OAAKD,eAAA,EAAA,WAAA,eAA8B,OAAA,MAAM,WAAA,CAAA;KACzC,eAAa;KACb,eAAa;KACb,aAAW;KACX,iBAAe;KACA;I,IAEhBG,WAAQ,KAAA,QAAA,SAAA,C"}
1
+ {"version":3,"file":"swiperow.js","names":["_useModel","_openBlock","_createElementBlock","_normalizeClass","_normalizeStyle","_createElementVNode","_unref","_renderSlot","_createBlock","_createCommentVNode","_toDisplayString","_Fragment","_renderList","_sfc_main"],"sources":["../src/swiperow/model.ts","../src/swiperow/TaoxSwipeRow.vue","../src/swiperow/TaoxSwipeRow.vue"],"sourcesContent":["import { settleOpen, SWIPE_FLING_PX_PER_MS, type SwipeRelease } from '../gestures';\n\n/**\n * An action of a swipe row. `tone` is a TaoUI tone (`neutral`, `danger`, `success`…), `icon` a TaoIcon name.\n * Действие свайп-строки. `tone` — тон TaoUI, `icon` — имя TaoIcon.\n */\nexport interface SwipeRowAction {\n id: string;\n label: string;\n icon?: string;\n tone?: 'accent' | 'neutral' | 'success' | 'danger' | 'warning' | 'info';\n}\n\n/**\n * The thresholds of the row, px or a share of its width.\n * Пороги строки, px или доля её ширины.\n */\nexport interface SwipeRowGeometry {\n /** The row width. / Ширина строки. */\n width: number;\n /** How wide each end action stands when the row is open. / Ширина каждого действия справа в открытой строке. */\n actionWidth: number;\n /** How many end actions. / Сколько действий справа. */\n endCount: number;\n /** Whether there is a start action. / Есть ли действие слева. */\n hasStart: boolean;\n /** Whether pulling far runs the last end action by itself. / Выполняет ли длинный свайп последнее действие сам. */\n fullSwipe: boolean;\n}\n\n/** Past this share of the width a pull to the end runs the last action. / После этой доли ширины длинный свайп выполняет последнее действие. */\nexport const FULL_SWIPE_RATIO = 0.6;\n/** A pull to the start runs its action past this many px (or a third of a narrow row). / Свайп вправо выполняет действие после стольких px. */\nexport const START_THRESHOLD_PX = 96;\n\nexport const startThreshold = (g: SwipeRowGeometry) => Math.min(START_THRESHOLD_PX, g.width / 3);\nexport const endOpenWidth = (g: SwipeRowGeometry) => g.actionWidth * g.endCount;\nexport const fullThreshold = (g: SwipeRowGeometry) => Math.max(endOpenWidth(g) + 24, g.width * FULL_SWIPE_RATIO);\n\n/**\n * Whether the row, at this offset, is past the point where releasing runs an action: `start`, `full` or null.\n * Пройдена ли при этом сдвиге точка, после которой отпускание выполняет действие: `start`, `full` или null.\n */\nexport function armedAt(offset: number, g: SwipeRowGeometry): 'start' | 'full' | null {\n if (offset > 0 && g.hasStart && offset >= startThreshold(g)) return 'start';\n if (offset < 0 && g.fullSwipe && g.endCount > 0 && -offset >= fullThreshold(g)) return 'full';\n return null;\n}\n\n/**\n * How far the row may move: no further than there is something behind it. Without the full swipe a pull past the open\n * actions meets a spring: it still follows the finger, ever slower, up to half the open width more, and on release the\n * row rests open.\n * Насколько строка может уехать. Без длинного свайпа протяжка дальше открытых действий упирается в пружину: строка\n * всё ещё идёт за пальцем, всё медленнее, не дальше ещё половины открытой ширины, а после отпускания остаётся открытой.\n */\nexport function clampOffset(offset: number, g: SwipeRowGeometry): number {\n const right = g.hasStart ? g.width : 0;\n if (offset < 0 && g.endCount > 0 && !g.fullSwipe) {\n const open = endOpenWidth(g);\n const over = -offset - open;\n if (over <= 0) return offset;\n const room = open / 2;\n return -(open + room * (1 - 1 / (1 + over / room)));\n }\n const left = g.endCount === 0 ? 0 : -g.width;\n return Math.min(right, Math.max(left, offset));\n}\n\nexport type SwipeRowOutcome =\n | { kind: 'rest'; open: boolean } // the row comes to rest: open (the end actions shown) or closed\n | { kind: 'start' } // the start action runs, the row goes back\n | { kind: 'full' }; // the last end action runs\n\n/**\n * What a release does. A pull to the start past its threshold (or flung that way past half of it) runs the start\n * action; a pull to the end past the full threshold runs the last end action; otherwise the row rests open or closed,\n * a fling going on in its direction (`settleOpen`).\n * Что делает отпускание. Свайп вправо дальше порога (или брошенный туда дальше его половины) выполняет действие слева;\n * влево дальше полного порога — последнее действие справа; иначе строка встаёт открытой или закрытой, бросок\n * продолжается в своём направлении.\n */\nexport function swipeRowRelease(release: SwipeRelease, g: SwipeRowGeometry): SwipeRowOutcome {\n const offset = clampOffset(release.offset, g);\n const armed = armedAt(offset, g);\n if (armed) return { kind: armed };\n if (offset > 0 && g.hasStart && release.velocity >= SWIPE_FLING_PX_PER_MS && offset >= startThreshold(g) / 2) {\n return { kind: 'start' };\n }\n if (g.endCount === 0) return { kind: 'rest', open: false };\n const rest = settleOpen({ offset: Math.min(0, offset), velocity: release.velocity }, { end: endOpenWidth(g) });\n return { kind: 'rest', open: rest < 0 };\n}\n\n/** The narrowest an action between the row and the last one gets: still a visible link. / Самое узкое промежуточное действие. */\nexport const SWIPE_SLIVER_PX = 32;\n\n/**\n * The widths of the end actions at a pull of `drag` px (≥ 0), one continuous function, so nothing jumps. Up to the\n * open width they share the space evenly and grow to their width. Past it the actions between the row and the last one\n * stop growing and shrink back, smoothly, to slivers (`SWIPE_SLIVER_PX`) a little past the full-swipe threshold, and the last one\n * takes what they give up; further on they stay slivers, so a pull back opens them out again the same way.\n * `armed` is no longer used (the widths depend on the pull alone); it stays for the 0.5.0 signature.\n * Ширины действий справа при протяжке на `drag` px — одна непрерывная функция, поэтому ничего не прыгает. До открытой\n * ширины они делят место поровну и растут до своей ширины. Дальше промежуточные перестают расти и плавно сжимаются до\n * полосок к порогу длинного свайпа, а последнее забирает отданное место; за порогом они остаются полосками, поэтому\n * при обратном движении так же плавно раскрываются. `armed` больше не нужен; оставлен ради подписи 0.5.0.\n */\nexport function endWidths(drag: number, g: SwipeRowGeometry, _armed?: boolean, gap = 6): number[] {\n const n = g.endCount;\n if (n === 0 || drag <= 0) return Array.from({ length: n }, () => 0);\n const room = Math.max(0, drag - gap * n);\n const open = endOpenWidth(g);\n if (n === 1) return [room];\n // without the full swipe nothing is about to run: the actions only grow, side by side\n // без длинного свайпа ничего не выполнится: действия просто растут, все поровну\n if (drag <= open || !g.fullSwipe) return Array.from({ length: n }, () => room / n);\n\n // the squeeze runs a little past the full threshold (a fifth of the row more), so on a phone it takes a long stretch\n // of the pull and reads as a slide, not a snap\n // сжатие идёт чуть дальше порога длинного свайпа (ещё пятая часть строки), поэтому на телефоне занимает длинный\n // отрезок протяжки и читается как плавный переход, а не рывок\n const end = Math.max(open + 1, Math.min(g.width * 0.9, fullThreshold(g) + g.width * 0.2));\n const t = Math.min(1, (drag - open) / (end - open));\n const widest = g.actionWidth - gap;\n const middle = Math.min(widest, Math.max(0, widest + (Math.min(SWIPE_SLIVER_PX, widest) - widest) * t));\n return Array.from({ length: n }, (_, i) => (i === n - 1 ? room - middle * (n - 1) : middle));\n}\n","<script lang=\"ts\" setup>\nimport { TaoIcon, toneClass } from '@1337exp/taoui';\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { listenFocusLoss, SwipeTracker, type Sample } from '../gestures';\nimport { armedAt, clampOffset, endOpenWidth, endWidths, startThreshold, swipeRowRelease, type SwipeRowAction, type SwipeRowGeometry } from './model';\n\n// A row of a list that a finger slides sideways, as in a mail app. To the start (right): one action behind it, run on\n// release past its threshold, and the row comes back (read / unread). To the end (left): the actions grow out and the\n// row stays open on them; pulled far, the last one takes the row and runs on release (delete). The gesture (a swipe or\n// a scroll, the release speed, where to rest) is TaoUX's gestures; the actions are TaoUI icons and tones.\n// Строка списка, которую палец сдвигает вбок, как в почте. Вправо: одно действие позади, выполняется при отпускании\n// дальше порога, строка возвращается (прочитано / не прочитано). Влево: действия вырастают, и строка остаётся открытой\n// на них; если тянуть далеко, последнее занимает строку и выполняется при отпускании (удалить).\nconst props = withDefaults(\n defineProps<{\n /** The action behind the row on a pull to the start. / Действие позади строки при свайпе вправо. */\n start?: SwipeRowAction;\n /** The actions on a pull to the end, in order; the last one is the full swipe. / Действия при свайпе влево; последнее — длинный свайп. */\n end?: SwipeRowAction[];\n /** The width of each end action when the row is open, px. / Ширина каждого действия справа в открытой строке. */\n actionWidth?: number;\n /** Pulling far to the end runs the last action. / Длинный свайп влево выполняет последнее действие. */\n fullSwipe?: boolean;\n /** A mouse can drag it too (a touch screen always can). / Тянуть можно и мышью (палец может всегда). */\n mouse?: boolean;\n disabled?: boolean;\n }>(),\n { start: undefined, end: () => [], actionWidth: 76, fullSwipe: true, mouse: false, disabled: false },\n);\n\nconst emit = defineEmits<{\n /** An action was chosen: by a button, a pull past the threshold, or the full swipe. / Выбрано действие. */\n action: [id: string];\n}>();\n\n/** The end actions are shown. / Действия справа открыты. */\nconst open = defineModel<boolean>('open', { default: false });\n\ndefineSlots<{\n default?(): unknown;\n /** Your own face of an action. / Свой вид действия. */\n action?(props: { action: SwipeRowAction; armed: boolean; side: 'start' | 'end'; width: number }): unknown;\n}>();\n\nconst root = ref<HTMLElement | null>(null);\nconst width = ref(320);\nconst dragging = ref(false);\nconst drag = ref(0);\n// a moment after a full swipe: the row stays off to the side while the app removes it\n// миг после длинного свайпа: строка остаётся сдвинутой, пока приложение её убирает\nconst gone = ref(false);\nconst startShown = ref(false);\n\nconst geometry = computed<SwipeRowGeometry>(() => ({\n width: width.value,\n actionWidth: props.actionWidth,\n endCount: props.end.length,\n hasStart: Boolean(props.start),\n fullSwipe: props.fullSwipe,\n}));\n\nconst rest = computed(() => {\n if (gone.value) return -width.value;\n if (startShown.value) return startThreshold(geometry.value);\n return open.value ? -endOpenWidth(geometry.value) : 0;\n});\nconst offset = computed(() => (dragging.value ? drag.value : rest.value));\nconst armed = computed(() => (dragging.value ? armedAt(drag.value, geometry.value) : null));\n// gone (the full swipe ran): the last action holds the whole row while the app removes it / последнее держит всю строку\nconst widths = computed(() => endWidths(gone.value ? width.value : Math.max(0, -offset.value), geometry.value));\nconst lastEnd = computed(() => props.end[props.end.length - 1]);\n\n// a short buzz where the phone can, when an action becomes armed / короткая вибрация там, где телефон умеет\nwatch(armed, (next) => {\n if (next && typeof navigator !== 'undefined') navigator.vibrate?.(8);\n});\n\n//---]>\n// the gesture / жест\n\nconst tracker = new SwipeTracker('x');\nlet pointerId: number | null = null;\nlet swiped = false;\nconst sample = (e: PointerEvent): Sample => ({ x: e.clientX, y: e.clientY, t: e.timeStamp });\n\n// the window lost the focus while the press was held (Alt-Tab, a screenshot): its pointerup may never come, so the row\n// lets go and settles where it rested, instead of staying stuck to a finger that is gone\n// окно потеряло фокус во время нажатия: pointerup может не прийти, поэтому строка отпускается и встаёт на место\nlet stopFocusLoss: (() => void) | undefined;\n\nfunction release() {\n stopFocusLoss?.();\n stopFocusLoss = undefined;\n pointerId = null;\n dragging.value = false;\n}\n\nfunction onDown(e: PointerEvent) {\n if (props.disabled || pointerId !== null || (e.pointerType === 'mouse' && (!props.mouse || e.button !== 0))) return;\n pointerId = e.pointerId;\n swiped = false;\n startShown.value = false;\n tracker.down(sample(e), rest.value);\n stopFocusLoss = listenFocusLoss(() => {\n tracker.cancel();\n release();\n });\n}\n\nfunction onMove(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const step = tracker.move(sample(e));\n if (step.intent !== 'swipe') return;\n if (!dragging.value) {\n dragging.value = true;\n try {\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n } catch {\n /* a pointer the browser does not know / неизвестный браузеру указатель */\n }\n }\n swiped = true;\n drag.value = clampOffset(step.offset, geometry.value);\n}\n\nfunction onUp(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const result = tracker.up(sample(e));\n release();\n if (!result) return;\n const outcome = swipeRowRelease(result, geometry.value);\n if (outcome.kind === 'start' && props.start) {\n open.value = false;\n emit('action', props.start.id);\n } else if (outcome.kind === 'full' && lastEnd.value) {\n gone.value = true;\n emit('action', lastEnd.value.id);\n // the app removes the row; if it keeps it (an archive that failed), it comes back\n // приложение убирает строку; если оставит, она вернётся\n setTimeout(() => {\n gone.value = false;\n open.value = false;\n }, 400);\n } else if (outcome.kind === 'rest') {\n open.value = outcome.open;\n }\n}\n\nfunction onCancel(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n tracker.cancel();\n release();\n}\n\n// the end of a swipe also fires a click on the row: it must not open the item\n// конец свайпа даёт и click по строке: он не должен открывать элемент\nfunction onClickCapture(e: MouseEvent) {\n if (swiped) {\n e.stopPropagation();\n e.preventDefault();\n swiped = false;\n }\n}\n\nfunction run(action: SwipeRowAction) {\n open.value = false;\n startShown.value = false;\n emit('action', action.id);\n}\n\n//---]>\n// the keyboard: an action button that gets the focus shows its side and only its side (Tab from the start action to an\n// end one used to keep the start shown, which wins, and the focused button stayed hidden under the row); the focus on\n// the row's own content shows neither\n// клавиатура: кнопка действия, получившая фокус, показывает свою сторону и только её (Tab с левого действия на правое\n// оставлял показанной левую сторону, а она главнее, и кнопка с фокусом пряталась под строкой); фокус на содержимом\n// строки не показывает ни одну\n\nfunction onFocusIn(e: FocusEvent) {\n const side = (e.target as HTMLElement).closest<HTMLElement>('[data-side]')?.dataset.side;\n startShown.value = side === 'start';\n open.value = side === 'end';\n}\n\nfunction onFocusOut(e: FocusEvent) {\n if (root.value?.contains(e.relatedTarget as Node | null)) return;\n startShown.value = false;\n open.value = false;\n}\n\n// an open row closes on a touch outside it / открытая строка закрывается касанием вне её\nfunction onOutside(e: PointerEvent) {\n if (!root.value?.contains(e.target as Node)) open.value = false;\n}\nwatch(open, (isOpen) => {\n if (isOpen) document.addEventListener('pointerdown', onOutside, true);\n else document.removeEventListener('pointerdown', onOutside, true);\n});\n\nlet resize: ResizeObserver | undefined;\nonMounted(() => {\n if (!root.value) return;\n width.value = root.value.clientWidth || width.value;\n if (typeof ResizeObserver !== 'undefined') {\n resize = new ResizeObserver(() => (width.value = root.value?.clientWidth || width.value));\n resize.observe(root.value);\n }\n});\nonBeforeUnmount(() => {\n stopFocusLoss?.();\n resize?.disconnect();\n document.removeEventListener('pointerdown', onOutside, true);\n});\n\nconst startWidth = computed(() => Math.max(0, offset.value));\n\n/*\n * The icon and the label always stand where they end up, so nothing pops in and the heights never jump; only their\n * opacity follows the width of their block. The icon comes first, the label later, when the block is wide enough to\n * hold it.\n * Иконка и подпись всегда стоят на своих итоговых местах, поэтому ничего не выскакивает и высоты не прыгают; от ширины\n * блока зависит только их прозрачность. Иконка проявляется раньше, подпись позже, когда блок уже вмещает её.\n */\nconst fade = (width: number, from: number, span: number) => Math.min(1, Math.max(0, (width - from) / span));\nconst endIcon = (w: number) => fade(w, 22, 20);\nconst endLabel = (w: number) => fade(w, 50, 18);\nconst startIcon = (w: number) => fade(w, 36, 24);\nconst startLabel = (w: number) => fade(w, 84, 28);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"tx-swipe\"\n :class=\"{ 'tx-swipe--dragging': dragging, 'tx-swipe--armed-full': armed === 'full' || gone, 'tx-swipe--mouse': mouse }\"\n @focusin=\"onFocusIn\"\n @focusout=\"onFocusOut\"\n >\n <div v-if=\"start\" class=\"tx-swipe__start\" data-side=\"start\" :style=\"{ width: `${startWidth}px` }\">\n <button\n type=\"button\"\n class=\"tx-swipe__action tx-swipe__action--start\"\n :class=\"[toneClass(start.tone ?? 'neutral'), { 'tx-swipe__action--armed': armed === 'start' }]\"\n :aria-label=\"start.label\"\n @click=\"run(start)\"\n >\n <slot name=\"action\" :action=\"start\" :armed=\"armed === 'start'\" side=\"start\" :width=\"startWidth\">\n <TaoIcon v-if=\"start.icon\" :name=\"start.icon\" :size=\"20\" :style=\"{ opacity: startIcon(startWidth) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: startLabel(startWidth) }\">{{ start.label }}</span>\n </slot>\n </button>\n </div>\n\n <div v-if=\"end.length\" class=\"tx-swipe__end\" data-side=\"end\">\n <button\n v-for=\"(action, i) in end\"\n :key=\"action.id\"\n type=\"button\"\n class=\"tx-swipe__action\"\n :class=\"[toneClass(action.tone ?? 'neutral'), { 'tx-swipe__action--armed': i === end.length - 1 && (armed === 'full' || gone) }]\"\n :style=\"{ width: `${widths[i]}px` }\"\n :aria-label=\"action.label\"\n @click=\"run(action)\"\n >\n <slot name=\"action\" :action=\"action\" :armed=\"i === end.length - 1 && armed === 'full'\" side=\"end\" :width=\"widths[i] ?? 0\">\n <TaoIcon v-if=\"action.icon\" :name=\"action.icon\" :size=\"20\" :style=\"{ opacity: endIcon(widths[i] ?? 0) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: endLabel(widths[i] ?? 0) }\">{{ action.label }}</span>\n </slot>\n </button>\n </div>\n\n <div\n class=\"tx-swipe__front\"\n :style=\"{ transform: `translate3d(${offset}px, 0, 0)` }\"\n @pointerdown=\"onDown\"\n @pointermove=\"onMove\"\n @pointerup=\"onUp\"\n @pointercancel=\"onCancel\"\n @click.capture=\"onClickCapture\"\n >\n <slot />\n </div>\n </div>\n</template>\n\n<style>\n/*\n * Variables, on the row or on any element around it (the defaults stand in var(), so an ancestor's value reaches here):\n * --tx-swipe-bg the face of the row and the ground its actions are tinted on (the raised surface; a row right on\n * the page: var(--tao-color-bg))\n * --tx-swipe-radius the corners of the row (the panel radius)\n * --tx-swipe-gap the gap between the end actions (6px)\n * Переменные — на строке или на любом элементе вокруг неё (значения по умолчанию стоят в var(), поэтому значение предка\n * доходит сюда): --tx-swipe-bg — лицо строки и основа подкраски действий; --tx-swipe-radius — углы; --tx-swipe-gap —\n * зазор между действиями справа.\n */\n.tx-swipe {\n --_tx-swipe-gap: var(--tx-swipe-gap, 6px);\n --_tx-swipe-radius: var(--tx-swipe-radius, var(--tao-radius-panel, 12px));\n --_tx-swipe-bg: var(--tx-swipe-bg, var(--tao-color-surface-raised, #1f1f1f));\n position: relative;\n overflow: hidden;\n border-radius: var(--_tx-swipe-radius);\n}\n\n.tx-swipe__front {\n position: relative;\n z-index: 1;\n /* the page keeps the vertical scroll, the tracker takes the sideways pull / вертикаль — странице, вбок — трекеру */\n touch-action: pan-y;\n border-radius: inherit;\n background: var(--_tx-swipe-bg);\n transition: transform 0.22s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__front {\n transition: none;\n}\n\n/* a pull is not a selection: while it runs nothing is selected; with `mouse` the mouse drags the row, so its text is\n not selected by a press-and-move at all (a finger selects with a long press, which a swipe is not)\n протяжка — не выделение: пока она идёт, ничего не выделяется; с `mouse` мышь тянет строку, поэтому её текст не\n выделяется нажатием с движением вовсе (палец выделяет долгим нажатием, а свайп им не является) */\n.tx-swipe--dragging,\n.tx-swipe--mouse .tx-swipe__front {\n -webkit-user-select: none;\n user-select: none;\n}\n\n.tx-swipe__start,\n.tx-swipe__end {\n position: absolute;\n inset-block: 0;\n display: flex;\n gap: var(--_tx-swipe-gap);\n}\n\n/* clipped, with the gap as the button's margin: at width 0 nothing of it is left, while the keyboard can still reach it\n (a padding kept a 6px box, and the button showed at the start edge of a row pulled the other way)\n с обрезкой, а зазор — поле кнопки: при ширине 0 от неё ничего не остаётся, а клавиатура всё равно до неё доходит\n (padding оставлял коробку в 6px, и кнопка виднелась у начального края строки, которую тянули в другую сторону) */\n.tx-swipe__start {\n inset-inline-start: 0;\n overflow: hidden;\n transition: width 0.22s ease;\n}\n\n.tx-swipe__end {\n inset-inline-end: 0;\n justify-content: flex-end;\n}\n\n.tx-swipe--dragging .tx-swipe__start {\n transition: none;\n}\n\n.tx-swipe__action {\n /* a button, not text: a press or a pull over it selects nothing and calls no callout\n кнопка, а не текст: нажатие или протяжка по ней ничего не выделяет и не вызывает меню */\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n display: inline-flex;\n flex: none;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n /* the icon and the label read as one: a small gap, not pressed to the edges of a short row\n иконка и подпись читаются вместе: небольшой зазор, а не прижаты к краям невысокой строки */\n gap: 2px;\n min-width: 0;\n height: 100%;\n padding: 0;\n overflow: hidden;\n border: 0;\n border-radius: var(--_tx-swipe-radius);\n background: color-mix(in srgb, var(--tao-tone) 22%, var(--_tx-swipe-bg));\n color: var(--tao-tone-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n transition:\n width 0.15s ease,\n background-color 0.15s ease;\n}\n\n/* under the finger the actions follow the row in the same frame: no width easing, or they trail behind it\n под пальцем действия идут за строкой в том же кадре: без сглаживания ширины, иначе они отстают */\n.tx-swipe--dragging .tx-swipe__end .tx-swipe__action {\n transition: background-color 0.15s ease;\n}\n\n/* the start action is one line, from the start edge: the icon at a fixed place, the label after it\n действие слева — одна строка от начального края: иконка на постоянном месте, подпись за ней */\n.tx-swipe__action--start {\n flex: 1;\n flex-direction: row;\n justify-content: flex-start;\n gap: 10px;\n min-width: 0;\n margin-inline-end: var(--_tx-swipe-gap);\n padding-inline-start: 22px;\n}\n\n.tx-swipe__action--armed {\n background: color-mix(in srgb, var(--tao-tone) 45%, var(--_tx-swipe-bg));\n color: var(--tao-color-text-strong);\n}\n\n.tx-swipe__action:focus-visible {\n outline: 2px solid var(--tao-color-accent);\n outline-offset: -2px;\n}\n\n/* never squeezed or cut with «…»: a label wider than its block stays whole and centred, the block clips it, and it is\n still transparent then; so the line never changes as the block grows\n подпись не сжимается и не обрезается «…»: шире блока — остаётся целой и по центру, блок её обрезает, а она в это\n время ещё прозрачна; поэтому строка не меняется, пока блок растёт */\n.tx-swipe__label {\n flex: none;\n white-space: nowrap;\n line-height: 1.2;\n}\n\n.tx-swipe__action :is(svg, .tao-icon) {\n flex: none;\n}\n\n/* a short fade, so a row settling by itself shows them softly too; under the finger none\n короткий переход: строка, доезжающая сама, тоже их проявляет мягко; под пальцем без него */\n.tx-swipe__label,\n.tx-swipe__action .tao-icon {\n transition: opacity 0.12s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__label,\n.tx-swipe--dragging .tx-swipe__action .tao-icon {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tx-swipe__front,\n .tx-swipe__start,\n .tx-swipe__action,\n .tx-swipe__label,\n .tx-swipe__action .tao-icon {\n transition: none;\n }\n}\n</style>\n","<script lang=\"ts\" setup>\nimport { TaoIcon, toneClass } from '@1337exp/taoui';\nimport { computed, onBeforeUnmount, onMounted, ref, watch } from 'vue';\nimport { listenFocusLoss, SwipeTracker, type Sample } from '../gestures';\nimport { armedAt, clampOffset, endOpenWidth, endWidths, startThreshold, swipeRowRelease, type SwipeRowAction, type SwipeRowGeometry } from './model';\n\n// A row of a list that a finger slides sideways, as in a mail app. To the start (right): one action behind it, run on\n// release past its threshold, and the row comes back (read / unread). To the end (left): the actions grow out and the\n// row stays open on them; pulled far, the last one takes the row and runs on release (delete). The gesture (a swipe or\n// a scroll, the release speed, where to rest) is TaoUX's gestures; the actions are TaoUI icons and tones.\n// Строка списка, которую палец сдвигает вбок, как в почте. Вправо: одно действие позади, выполняется при отпускании\n// дальше порога, строка возвращается (прочитано / не прочитано). Влево: действия вырастают, и строка остаётся открытой\n// на них; если тянуть далеко, последнее занимает строку и выполняется при отпускании (удалить).\nconst props = withDefaults(\n defineProps<{\n /** The action behind the row on a pull to the start. / Действие позади строки при свайпе вправо. */\n start?: SwipeRowAction;\n /** The actions on a pull to the end, in order; the last one is the full swipe. / Действия при свайпе влево; последнее — длинный свайп. */\n end?: SwipeRowAction[];\n /** The width of each end action when the row is open, px. / Ширина каждого действия справа в открытой строке. */\n actionWidth?: number;\n /** Pulling far to the end runs the last action. / Длинный свайп влево выполняет последнее действие. */\n fullSwipe?: boolean;\n /** A mouse can drag it too (a touch screen always can). / Тянуть можно и мышью (палец может всегда). */\n mouse?: boolean;\n disabled?: boolean;\n }>(),\n { start: undefined, end: () => [], actionWidth: 76, fullSwipe: true, mouse: false, disabled: false },\n);\n\nconst emit = defineEmits<{\n /** An action was chosen: by a button, a pull past the threshold, or the full swipe. / Выбрано действие. */\n action: [id: string];\n}>();\n\n/** The end actions are shown. / Действия справа открыты. */\nconst open = defineModel<boolean>('open', { default: false });\n\ndefineSlots<{\n default?(): unknown;\n /** Your own face of an action. / Свой вид действия. */\n action?(props: { action: SwipeRowAction; armed: boolean; side: 'start' | 'end'; width: number }): unknown;\n}>();\n\nconst root = ref<HTMLElement | null>(null);\nconst width = ref(320);\nconst dragging = ref(false);\nconst drag = ref(0);\n// a moment after a full swipe: the row stays off to the side while the app removes it\n// миг после длинного свайпа: строка остаётся сдвинутой, пока приложение её убирает\nconst gone = ref(false);\nconst startShown = ref(false);\n\nconst geometry = computed<SwipeRowGeometry>(() => ({\n width: width.value,\n actionWidth: props.actionWidth,\n endCount: props.end.length,\n hasStart: Boolean(props.start),\n fullSwipe: props.fullSwipe,\n}));\n\nconst rest = computed(() => {\n if (gone.value) return -width.value;\n if (startShown.value) return startThreshold(geometry.value);\n return open.value ? -endOpenWidth(geometry.value) : 0;\n});\nconst offset = computed(() => (dragging.value ? drag.value : rest.value));\nconst armed = computed(() => (dragging.value ? armedAt(drag.value, geometry.value) : null));\n// gone (the full swipe ran): the last action holds the whole row while the app removes it / последнее держит всю строку\nconst widths = computed(() => endWidths(gone.value ? width.value : Math.max(0, -offset.value), geometry.value));\nconst lastEnd = computed(() => props.end[props.end.length - 1]);\n\n// a short buzz where the phone can, when an action becomes armed / короткая вибрация там, где телефон умеет\nwatch(armed, (next) => {\n if (next && typeof navigator !== 'undefined') navigator.vibrate?.(8);\n});\n\n//---]>\n// the gesture / жест\n\nconst tracker = new SwipeTracker('x');\nlet pointerId: number | null = null;\nlet swiped = false;\nconst sample = (e: PointerEvent): Sample => ({ x: e.clientX, y: e.clientY, t: e.timeStamp });\n\n// the window lost the focus while the press was held (Alt-Tab, a screenshot): its pointerup may never come, so the row\n// lets go and settles where it rested, instead of staying stuck to a finger that is gone\n// окно потеряло фокус во время нажатия: pointerup может не прийти, поэтому строка отпускается и встаёт на место\nlet stopFocusLoss: (() => void) | undefined;\n\nfunction release() {\n stopFocusLoss?.();\n stopFocusLoss = undefined;\n pointerId = null;\n dragging.value = false;\n}\n\nfunction onDown(e: PointerEvent) {\n if (props.disabled || pointerId !== null || (e.pointerType === 'mouse' && (!props.mouse || e.button !== 0))) return;\n pointerId = e.pointerId;\n swiped = false;\n startShown.value = false;\n tracker.down(sample(e), rest.value);\n stopFocusLoss = listenFocusLoss(() => {\n tracker.cancel();\n release();\n });\n}\n\nfunction onMove(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const step = tracker.move(sample(e));\n if (step.intent !== 'swipe') return;\n if (!dragging.value) {\n dragging.value = true;\n try {\n (e.currentTarget as HTMLElement).setPointerCapture(e.pointerId);\n } catch {\n /* a pointer the browser does not know / неизвестный браузеру указатель */\n }\n }\n swiped = true;\n drag.value = clampOffset(step.offset, geometry.value);\n}\n\nfunction onUp(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n const result = tracker.up(sample(e));\n release();\n if (!result) return;\n const outcome = swipeRowRelease(result, geometry.value);\n if (outcome.kind === 'start' && props.start) {\n open.value = false;\n emit('action', props.start.id);\n } else if (outcome.kind === 'full' && lastEnd.value) {\n gone.value = true;\n emit('action', lastEnd.value.id);\n // the app removes the row; if it keeps it (an archive that failed), it comes back\n // приложение убирает строку; если оставит, она вернётся\n setTimeout(() => {\n gone.value = false;\n open.value = false;\n }, 400);\n } else if (outcome.kind === 'rest') {\n open.value = outcome.open;\n }\n}\n\nfunction onCancel(e: PointerEvent) {\n if (e.pointerId !== pointerId) return;\n tracker.cancel();\n release();\n}\n\n// the end of a swipe also fires a click on the row: it must not open the item\n// конец свайпа даёт и click по строке: он не должен открывать элемент\nfunction onClickCapture(e: MouseEvent) {\n if (swiped) {\n e.stopPropagation();\n e.preventDefault();\n swiped = false;\n }\n}\n\nfunction run(action: SwipeRowAction) {\n open.value = false;\n startShown.value = false;\n emit('action', action.id);\n}\n\n//---]>\n// the keyboard: an action button that gets the focus shows its side and only its side (Tab from the start action to an\n// end one used to keep the start shown, which wins, and the focused button stayed hidden under the row); the focus on\n// the row's own content shows neither\n// клавиатура: кнопка действия, получившая фокус, показывает свою сторону и только её (Tab с левого действия на правое\n// оставлял показанной левую сторону, а она главнее, и кнопка с фокусом пряталась под строкой); фокус на содержимом\n// строки не показывает ни одну\n\nfunction onFocusIn(e: FocusEvent) {\n const side = (e.target as HTMLElement).closest<HTMLElement>('[data-side]')?.dataset.side;\n startShown.value = side === 'start';\n open.value = side === 'end';\n}\n\nfunction onFocusOut(e: FocusEvent) {\n if (root.value?.contains(e.relatedTarget as Node | null)) return;\n startShown.value = false;\n open.value = false;\n}\n\n// an open row closes on a touch outside it / открытая строка закрывается касанием вне её\nfunction onOutside(e: PointerEvent) {\n if (!root.value?.contains(e.target as Node)) open.value = false;\n}\nwatch(open, (isOpen) => {\n if (isOpen) document.addEventListener('pointerdown', onOutside, true);\n else document.removeEventListener('pointerdown', onOutside, true);\n});\n\nlet resize: ResizeObserver | undefined;\nonMounted(() => {\n if (!root.value) return;\n width.value = root.value.clientWidth || width.value;\n if (typeof ResizeObserver !== 'undefined') {\n resize = new ResizeObserver(() => (width.value = root.value?.clientWidth || width.value));\n resize.observe(root.value);\n }\n});\nonBeforeUnmount(() => {\n stopFocusLoss?.();\n resize?.disconnect();\n document.removeEventListener('pointerdown', onOutside, true);\n});\n\nconst startWidth = computed(() => Math.max(0, offset.value));\n\n/*\n * The icon and the label always stand where they end up, so nothing pops in and the heights never jump; only their\n * opacity follows the width of their block. The icon comes first, the label later, when the block is wide enough to\n * hold it.\n * Иконка и подпись всегда стоят на своих итоговых местах, поэтому ничего не выскакивает и высоты не прыгают; от ширины\n * блока зависит только их прозрачность. Иконка проявляется раньше, подпись позже, когда блок уже вмещает её.\n */\nconst fade = (width: number, from: number, span: number) => Math.min(1, Math.max(0, (width - from) / span));\nconst endIcon = (w: number) => fade(w, 22, 20);\nconst endLabel = (w: number) => fade(w, 50, 18);\nconst startIcon = (w: number) => fade(w, 36, 24);\nconst startLabel = (w: number) => fade(w, 84, 28);\n</script>\n\n<template>\n <div\n ref=\"root\"\n class=\"tx-swipe\"\n :class=\"{ 'tx-swipe--dragging': dragging, 'tx-swipe--armed-full': armed === 'full' || gone, 'tx-swipe--mouse': mouse }\"\n @focusin=\"onFocusIn\"\n @focusout=\"onFocusOut\"\n >\n <div v-if=\"start\" class=\"tx-swipe__start\" data-side=\"start\" :style=\"{ width: `${startWidth}px` }\">\n <button\n type=\"button\"\n class=\"tx-swipe__action tx-swipe__action--start\"\n :class=\"[toneClass(start.tone ?? 'neutral'), { 'tx-swipe__action--armed': armed === 'start' }]\"\n :aria-label=\"start.label\"\n @click=\"run(start)\"\n >\n <slot name=\"action\" :action=\"start\" :armed=\"armed === 'start'\" side=\"start\" :width=\"startWidth\">\n <TaoIcon v-if=\"start.icon\" :name=\"start.icon\" :size=\"20\" :style=\"{ opacity: startIcon(startWidth) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: startLabel(startWidth) }\">{{ start.label }}</span>\n </slot>\n </button>\n </div>\n\n <div v-if=\"end.length\" class=\"tx-swipe__end\" data-side=\"end\">\n <button\n v-for=\"(action, i) in end\"\n :key=\"action.id\"\n type=\"button\"\n class=\"tx-swipe__action\"\n :class=\"[toneClass(action.tone ?? 'neutral'), { 'tx-swipe__action--armed': i === end.length - 1 && (armed === 'full' || gone) }]\"\n :style=\"{ width: `${widths[i]}px` }\"\n :aria-label=\"action.label\"\n @click=\"run(action)\"\n >\n <slot name=\"action\" :action=\"action\" :armed=\"i === end.length - 1 && armed === 'full'\" side=\"end\" :width=\"widths[i] ?? 0\">\n <TaoIcon v-if=\"action.icon\" :name=\"action.icon\" :size=\"20\" :style=\"{ opacity: endIcon(widths[i] ?? 0) }\" />\n <span class=\"tx-swipe__label\" :style=\"{ opacity: endLabel(widths[i] ?? 0) }\">{{ action.label }}</span>\n </slot>\n </button>\n </div>\n\n <div\n class=\"tx-swipe__front\"\n :style=\"{ transform: `translate3d(${offset}px, 0, 0)` }\"\n @pointerdown=\"onDown\"\n @pointermove=\"onMove\"\n @pointerup=\"onUp\"\n @pointercancel=\"onCancel\"\n @click.capture=\"onClickCapture\"\n >\n <slot />\n </div>\n </div>\n</template>\n\n<style>\n/*\n * Variables, on the row or on any element around it (the defaults stand in var(), so an ancestor's value reaches here):\n * --tx-swipe-bg the face of the row and the ground its actions are tinted on (the raised surface; a row right on\n * the page: var(--tao-color-bg))\n * --tx-swipe-radius the corners of the row (the panel radius)\n * --tx-swipe-gap the gap between the end actions (6px)\n * Переменные — на строке или на любом элементе вокруг неё (значения по умолчанию стоят в var(), поэтому значение предка\n * доходит сюда): --tx-swipe-bg — лицо строки и основа подкраски действий; --tx-swipe-radius — углы; --tx-swipe-gap —\n * зазор между действиями справа.\n */\n.tx-swipe {\n --_tx-swipe-gap: var(--tx-swipe-gap, 6px);\n --_tx-swipe-radius: var(--tx-swipe-radius, var(--tao-radius-panel, 12px));\n --_tx-swipe-bg: var(--tx-swipe-bg, var(--tao-color-surface-raised, #1f1f1f));\n position: relative;\n overflow: hidden;\n border-radius: var(--_tx-swipe-radius);\n}\n\n.tx-swipe__front {\n position: relative;\n z-index: 1;\n /* the page keeps the vertical scroll, the tracker takes the sideways pull / вертикаль — странице, вбок — трекеру */\n touch-action: pan-y;\n border-radius: inherit;\n background: var(--_tx-swipe-bg);\n transition: transform 0.22s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__front {\n transition: none;\n}\n\n/* a pull is not a selection: while it runs nothing is selected; with `mouse` the mouse drags the row, so its text is\n not selected by a press-and-move at all (a finger selects with a long press, which a swipe is not)\n протяжка — не выделение: пока она идёт, ничего не выделяется; с `mouse` мышь тянет строку, поэтому её текст не\n выделяется нажатием с движением вовсе (палец выделяет долгим нажатием, а свайп им не является) */\n.tx-swipe--dragging,\n.tx-swipe--mouse .tx-swipe__front {\n -webkit-user-select: none;\n user-select: none;\n}\n\n.tx-swipe__start,\n.tx-swipe__end {\n position: absolute;\n inset-block: 0;\n display: flex;\n gap: var(--_tx-swipe-gap);\n}\n\n/* clipped, with the gap as the button's margin: at width 0 nothing of it is left, while the keyboard can still reach it\n (a padding kept a 6px box, and the button showed at the start edge of a row pulled the other way)\n с обрезкой, а зазор — поле кнопки: при ширине 0 от неё ничего не остаётся, а клавиатура всё равно до неё доходит\n (padding оставлял коробку в 6px, и кнопка виднелась у начального края строки, которую тянули в другую сторону) */\n.tx-swipe__start {\n inset-inline-start: 0;\n overflow: hidden;\n transition: width 0.22s ease;\n}\n\n.tx-swipe__end {\n inset-inline-end: 0;\n justify-content: flex-end;\n}\n\n.tx-swipe--dragging .tx-swipe__start {\n transition: none;\n}\n\n.tx-swipe__action {\n /* a button, not text: a press or a pull over it selects nothing and calls no callout\n кнопка, а не текст: нажатие или протяжка по ней ничего не выделяет и не вызывает меню */\n -webkit-user-select: none;\n user-select: none;\n -webkit-touch-callout: none;\n display: inline-flex;\n flex: none;\n flex-direction: column;\n align-items: center;\n justify-content: center;\n /* the icon and the label read as one: a small gap, not pressed to the edges of a short row\n иконка и подпись читаются вместе: небольшой зазор, а не прижаты к краям невысокой строки */\n gap: 2px;\n min-width: 0;\n height: 100%;\n padding: 0;\n overflow: hidden;\n border: 0;\n border-radius: var(--_tx-swipe-radius);\n background: color-mix(in srgb, var(--tao-tone) 22%, var(--_tx-swipe-bg));\n color: var(--tao-tone-text);\n font: inherit;\n font-size: 13px;\n cursor: pointer;\n transition:\n width 0.15s ease,\n background-color 0.15s ease;\n}\n\n/* under the finger the actions follow the row in the same frame: no width easing, or they trail behind it\n под пальцем действия идут за строкой в том же кадре: без сглаживания ширины, иначе они отстают */\n.tx-swipe--dragging .tx-swipe__end .tx-swipe__action {\n transition: background-color 0.15s ease;\n}\n\n/* the start action is one line, from the start edge: the icon at a fixed place, the label after it\n действие слева — одна строка от начального края: иконка на постоянном месте, подпись за ней */\n.tx-swipe__action--start {\n flex: 1;\n flex-direction: row;\n justify-content: flex-start;\n gap: 10px;\n min-width: 0;\n margin-inline-end: var(--_tx-swipe-gap);\n padding-inline-start: 22px;\n}\n\n.tx-swipe__action--armed {\n background: color-mix(in srgb, var(--tao-tone) 45%, var(--_tx-swipe-bg));\n color: var(--tao-color-text-strong);\n}\n\n.tx-swipe__action:focus-visible {\n outline: 2px solid var(--tao-color-accent);\n outline-offset: -2px;\n}\n\n/* never squeezed or cut with «…»: a label wider than its block stays whole and centred, the block clips it, and it is\n still transparent then; so the line never changes as the block grows\n подпись не сжимается и не обрезается «…»: шире блока — остаётся целой и по центру, блок её обрезает, а она в это\n время ещё прозрачна; поэтому строка не меняется, пока блок растёт */\n.tx-swipe__label {\n flex: none;\n white-space: nowrap;\n line-height: 1.2;\n}\n\n.tx-swipe__action :is(svg, .tao-icon) {\n flex: none;\n}\n\n/* a short fade, so a row settling by itself shows them softly too; under the finger none\n короткий переход: строка, доезжающая сама, тоже их проявляет мягко; под пальцем без него */\n.tx-swipe__label,\n.tx-swipe__action .tao-icon {\n transition: opacity 0.12s ease;\n}\n\n.tx-swipe--dragging .tx-swipe__label,\n.tx-swipe--dragging .tx-swipe__action .tao-icon {\n transition: none;\n}\n\n@media (prefers-reduced-motion: reduce) {\n .tx-swipe__front,\n .tx-swipe__start,\n .tx-swipe__action,\n .tx-swipe__label,\n .tx-swipe__action .tao-icon {\n transition: none;\n }\n}\n</style>\n"],"mappings":";;;;;AA+BA,IAAa,mBAAmB;;AAEhC,IAAa,qBAAqB;AAElC,IAAa,kBAAkB,MAAwB,KAAK,IAAA,IAAwB,EAAE,QAAQ,CAAC;AAC/F,IAAa,gBAAgB,MAAwB,EAAE,cAAc,EAAE;AACvE,IAAa,iBAAiB,MAAwB,KAAK,IAAI,aAAa,CAAC,IAAI,IAAI,EAAE,QAAQ,gBAAgB;;;;;AAM/G,SAAgB,QAAQ,QAAgB,GAA8C;CAClF,IAAI,SAAS,KAAK,EAAE,YAAY,UAAU,eAAe,CAAC,GAAG,OAAO;CACpE,IAAI,SAAS,KAAK,EAAE,aAAa,EAAE,WAAW,KAAK,CAAC,UAAU,cAAc,CAAC,GAAG,OAAO;CACvF,OAAO;AACX;;;;;;;;AASA,SAAgB,YAAY,QAAgB,GAA6B;CACrE,MAAM,QAAQ,EAAE,WAAW,EAAE,QAAQ;CACrC,IAAI,SAAS,KAAK,EAAE,WAAW,KAAK,CAAC,EAAE,WAAW;EAC9C,MAAM,OAAO,aAAa,CAAC;EAC3B,MAAM,OAAO,CAAC,SAAS;EACvB,IAAI,QAAQ,GAAG,OAAO;EACtB,MAAM,OAAO,OAAO;EACpB,OAAO,EAAE,OAAO,QAAQ,IAAI,KAAK,I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gEAC9FC,mBAAsG,QAAA;MAAhG,OAAM;MAAmB,OAAKD,eAAA,EAAA,SAAa,SAAS,OAAA,MAAO,MAAC,CAAA,EAAA,CAAA;KAAc,GAAAM,gBAAA,OAAO,KAAK,GAAA,CAAA,C;;IAKxGL,mBAUM,OAAA;KATF,OAAM;KACL,OAAKD,eAAA,EAAA,WAAA,eAA8B,OAAA,MAAM,WAAA,CAAA;KACzC,eAAa;KACb,eAAa;KACb,aAAW;KACX,iBAAe;KACA;I,IAEhBG,WAAQ,KAAA,QAAA,SAAA,C"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@1337exp/taoux",
3
- "version": "0.5.2",
3
+ "version": "0.5.4",
4
4
  "description": "Interaction and behavior building blocks for Vue apps: curve and gradient editors, canvas, undo/redo, playback. Import only what you need, bring your own design.",
5
5
  "keywords": [
6
6
  "vue",
package/theme/taoui.css CHANGED
@@ -40,4 +40,7 @@
40
40
  --tx-gradient-stop-border: var(--tao-color-border-strong);
41
41
  --tx-gradient-stop-outline: color-mix(in srgb, var(--tao-color-text-strong) 55%, transparent);
42
42
  --tx-gradient-accent: var(--tao-color-accent);
43
+
44
+ /* swiperow */
45
+ --tx-swipe-bg: var(--tao-color-surface-raised);
43
46
  }