@1337exp/taoux 0.4.0 → 0.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +18 -0
- package/README.md +13 -9
- package/README.ru.md +13 -9
- package/dist/gestures.d.ts +9 -0
- package/dist/gestures.js +23 -1
- package/dist/gestures.js.map +1 -1
- package/dist/sortable.d.ts +66 -0
- package/dist/sortable.js +298 -0
- package/dist/sortable.js.map +1 -0
- package/dist/swiperow/TaoxSwipeRow.vue.d.ts +51 -0
- package/dist/swiperow/index.d.ts +3 -0
- package/dist/swiperow/model.d.ts +72 -0
- package/dist/swiperow.css +127 -0
- package/dist/swiperow.js +330 -0
- package/dist/swiperow.js.map +1 -0
- package/package.json +11 -2
- package/skills/taoux/SKILL.md +9 -6
package/dist/swiperow.js
ADDED
|
@@ -0,0 +1,330 @@
|
|
|
1
|
+
import { SwipeTracker, listenFocusLoss, settleOpen } from "./gestures.js";
|
|
2
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, defineComponent, mergeModels, normalizeClass, normalizeStyle, onBeforeUnmount, onMounted, openBlock, ref, renderList, renderSlot, toDisplayString, unref, useModel, watch } from "vue";
|
|
3
|
+
import { TaoIcon, toneClass } from "@1337exp/taoui";
|
|
4
|
+
//#region src/swiperow/model.ts
|
|
5
|
+
/** Past this share of the width a pull to the end runs the last action. / После этой доли ширины длинный свайп выполняет последнее действие. */
|
|
6
|
+
var FULL_SWIPE_RATIO = .6;
|
|
7
|
+
/** A pull to the start runs its action past this many px (or a third of a narrow row). / Свайп вправо выполняет действие после стольких px. */
|
|
8
|
+
var START_THRESHOLD_PX = 96;
|
|
9
|
+
var startThreshold = (g) => Math.min(96, g.width / 3);
|
|
10
|
+
var endOpenWidth = (g) => g.actionWidth * g.endCount;
|
|
11
|
+
var fullThreshold = (g) => Math.max(endOpenWidth(g) + 24, g.width * FULL_SWIPE_RATIO);
|
|
12
|
+
/**
|
|
13
|
+
* Whether the row, at this offset, is past the point where releasing runs an action: `start`, `full` or null.
|
|
14
|
+
* Пройдена ли при этом сдвиге точка, после которой отпускание выполняет действие: `start`, `full` или null.
|
|
15
|
+
*/
|
|
16
|
+
function armedAt(offset, g) {
|
|
17
|
+
if (offset > 0 && g.hasStart && offset >= startThreshold(g)) return "start";
|
|
18
|
+
if (offset < 0 && g.fullSwipe && g.endCount > 0 && -offset >= fullThreshold(g)) return "full";
|
|
19
|
+
return null;
|
|
20
|
+
}
|
|
21
|
+
/** How far the row may move: no further than there is something behind it. / Насколько строка может уехать. */
|
|
22
|
+
function clampOffset(offset, g) {
|
|
23
|
+
const right = g.hasStart ? g.width : 0;
|
|
24
|
+
const left = g.endCount === 0 ? 0 : g.fullSwipe ? -g.width : -endOpenWidth(g) * 1.5;
|
|
25
|
+
return Math.min(right, Math.max(left, offset));
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* What a release does. A pull to the start past its threshold (or flung that way past half of it) runs the start
|
|
29
|
+
* action; a pull to the end past the full threshold runs the last end action; otherwise the row rests open or closed,
|
|
30
|
+
* a fling going on in its direction (`settleOpen`).
|
|
31
|
+
* Что делает отпускание. Свайп вправо дальше порога (или брошенный туда дальше его половины) выполняет действие слева;
|
|
32
|
+
* влево дальше полного порога — последнее действие справа; иначе строка встаёт открытой или закрытой, бросок
|
|
33
|
+
* продолжается в своём направлении.
|
|
34
|
+
*/
|
|
35
|
+
function swipeRowRelease(release, g) {
|
|
36
|
+
const offset = clampOffset(release.offset, g);
|
|
37
|
+
const armed = armedAt(offset, g);
|
|
38
|
+
if (armed) return { kind: armed };
|
|
39
|
+
if (offset > 0 && g.hasStart && release.velocity >= .4 && offset >= startThreshold(g) / 2) return { kind: "start" };
|
|
40
|
+
if (g.endCount === 0) return {
|
|
41
|
+
kind: "rest",
|
|
42
|
+
open: false
|
|
43
|
+
};
|
|
44
|
+
return {
|
|
45
|
+
kind: "rest",
|
|
46
|
+
open: settleOpen({
|
|
47
|
+
offset: Math.min(0, offset),
|
|
48
|
+
velocity: release.velocity
|
|
49
|
+
}, { end: endOpenWidth(g) }) < 0
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** The narrowest an action between the row and the last one gets: still a visible link. / Самое узкое промежуточное действие. */
|
|
53
|
+
var SWIPE_SLIVER_PX = 32;
|
|
54
|
+
/**
|
|
55
|
+
* The widths of the end actions at a pull of `drag` px (≥ 0), one continuous function, so nothing jumps. Up to the
|
|
56
|
+
* open width they share the space evenly and grow to their width. Past it the actions between the row and the last one
|
|
57
|
+
* stop growing and shrink back, smoothly, to slivers (`SWIPE_SLIVER_PX`) a little past the full-swipe threshold, and the last one
|
|
58
|
+
* takes what they give up; further on they stay slivers, so a pull back opens them out again the same way.
|
|
59
|
+
* `armed` is no longer used (the widths depend on the pull alone); it stays for the 0.5.0 signature.
|
|
60
|
+
* Ширины действий справа при протяжке на `drag` px — одна непрерывная функция, поэтому ничего не прыгает. До открытой
|
|
61
|
+
* ширины они делят место поровну и растут до своей ширины. Дальше промежуточные перестают расти и плавно сжимаются до
|
|
62
|
+
* полосок к порогу длинного свайпа, а последнее забирает отданное место; за порогом они остаются полосками, поэтому
|
|
63
|
+
* при обратном движении так же плавно раскрываются. `armed` больше не нужен; оставлен ради подписи 0.5.0.
|
|
64
|
+
*/
|
|
65
|
+
function endWidths(drag, g, _armed, gap = 6) {
|
|
66
|
+
const n = g.endCount;
|
|
67
|
+
if (n === 0 || drag <= 0) return Array.from({ length: n }, () => 0);
|
|
68
|
+
const room = Math.max(0, drag - gap * n);
|
|
69
|
+
const open = endOpenWidth(g);
|
|
70
|
+
if (n === 1) return [room];
|
|
71
|
+
if (drag <= open) return Array.from({ length: n }, () => room / n);
|
|
72
|
+
const end = Math.max(open + 1, Math.min(g.width * .9, fullThreshold(g) + g.width * .2));
|
|
73
|
+
const t = Math.min(1, (drag - open) / (end - open));
|
|
74
|
+
const widest = g.actionWidth - gap;
|
|
75
|
+
const middle = Math.min(widest, Math.max(0, widest + (Math.min(32, widest) - widest) * t));
|
|
76
|
+
return Array.from({ length: n }, (_, i) => i === n - 1 ? room - middle * (n - 1) : middle);
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/swiperow/TaoxSwipeRow.vue?vue&type=script&setup=true&lang.ts
|
|
80
|
+
var _hoisted_1 = ["aria-label"];
|
|
81
|
+
var _hoisted_2 = {
|
|
82
|
+
key: 1,
|
|
83
|
+
class: "tx-swipe__end",
|
|
84
|
+
"data-side": "end"
|
|
85
|
+
};
|
|
86
|
+
var _hoisted_3 = ["aria-label", "onClick"];
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/swiperow/TaoxSwipeRow.vue
|
|
89
|
+
var TaoxSwipeRow_default = /* @__PURE__ */ defineComponent({
|
|
90
|
+
__name: "TaoxSwipeRow",
|
|
91
|
+
props: /*@__PURE__*/ mergeModels({
|
|
92
|
+
start: { default: void 0 },
|
|
93
|
+
end: { default: () => [] },
|
|
94
|
+
actionWidth: { default: 76 },
|
|
95
|
+
fullSwipe: {
|
|
96
|
+
type: Boolean,
|
|
97
|
+
default: true
|
|
98
|
+
},
|
|
99
|
+
mouse: {
|
|
100
|
+
type: Boolean,
|
|
101
|
+
default: false
|
|
102
|
+
},
|
|
103
|
+
disabled: {
|
|
104
|
+
type: Boolean,
|
|
105
|
+
default: false
|
|
106
|
+
}
|
|
107
|
+
}, {
|
|
108
|
+
"open": {
|
|
109
|
+
type: Boolean,
|
|
110
|
+
default: false
|
|
111
|
+
},
|
|
112
|
+
"openModifiers": {}
|
|
113
|
+
}),
|
|
114
|
+
emits: /*@__PURE__*/ mergeModels(["action"], ["update:open"]),
|
|
115
|
+
setup(__props, { emit: __emit }) {
|
|
116
|
+
const props = __props;
|
|
117
|
+
const emit = __emit;
|
|
118
|
+
/** The end actions are shown. / Действия справа открыты. */
|
|
119
|
+
const open = useModel(__props, "open");
|
|
120
|
+
const root = ref(null);
|
|
121
|
+
const width = ref(320);
|
|
122
|
+
const dragging = ref(false);
|
|
123
|
+
const drag = ref(0);
|
|
124
|
+
const gone = ref(false);
|
|
125
|
+
const startShown = ref(false);
|
|
126
|
+
const geometry = computed(() => ({
|
|
127
|
+
width: width.value,
|
|
128
|
+
actionWidth: props.actionWidth,
|
|
129
|
+
endCount: props.end.length,
|
|
130
|
+
hasStart: Boolean(props.start),
|
|
131
|
+
fullSwipe: props.fullSwipe
|
|
132
|
+
}));
|
|
133
|
+
const rest = computed(() => {
|
|
134
|
+
if (gone.value) return -width.value;
|
|
135
|
+
if (startShown.value) return startThreshold(geometry.value);
|
|
136
|
+
return open.value ? -endOpenWidth(geometry.value) : 0;
|
|
137
|
+
});
|
|
138
|
+
const offset = computed(() => dragging.value ? drag.value : rest.value);
|
|
139
|
+
const armed = computed(() => dragging.value ? armedAt(drag.value, geometry.value) : null);
|
|
140
|
+
const widths = computed(() => endWidths(gone.value ? width.value : Math.max(0, -offset.value), geometry.value));
|
|
141
|
+
const lastEnd = computed(() => props.end[props.end.length - 1]);
|
|
142
|
+
watch(armed, (next) => {
|
|
143
|
+
if (next && typeof navigator !== "undefined") navigator.vibrate?.(8);
|
|
144
|
+
});
|
|
145
|
+
const tracker = new SwipeTracker("x");
|
|
146
|
+
let pointerId = null;
|
|
147
|
+
let swiped = false;
|
|
148
|
+
const sample = (e) => ({
|
|
149
|
+
x: e.clientX,
|
|
150
|
+
y: e.clientY,
|
|
151
|
+
t: e.timeStamp
|
|
152
|
+
});
|
|
153
|
+
let stopFocusLoss;
|
|
154
|
+
function release() {
|
|
155
|
+
stopFocusLoss?.();
|
|
156
|
+
stopFocusLoss = void 0;
|
|
157
|
+
pointerId = null;
|
|
158
|
+
dragging.value = false;
|
|
159
|
+
}
|
|
160
|
+
function onDown(e) {
|
|
161
|
+
if (props.disabled || pointerId !== null || e.pointerType === "mouse" && (!props.mouse || e.button !== 0)) return;
|
|
162
|
+
pointerId = e.pointerId;
|
|
163
|
+
swiped = false;
|
|
164
|
+
startShown.value = false;
|
|
165
|
+
tracker.down(sample(e), rest.value);
|
|
166
|
+
stopFocusLoss = listenFocusLoss(() => {
|
|
167
|
+
tracker.cancel();
|
|
168
|
+
release();
|
|
169
|
+
});
|
|
170
|
+
}
|
|
171
|
+
function onMove(e) {
|
|
172
|
+
if (e.pointerId !== pointerId) return;
|
|
173
|
+
const step = tracker.move(sample(e));
|
|
174
|
+
if (step.intent !== "swipe") return;
|
|
175
|
+
if (!dragging.value) {
|
|
176
|
+
dragging.value = true;
|
|
177
|
+
try {
|
|
178
|
+
e.currentTarget.setPointerCapture(e.pointerId);
|
|
179
|
+
} catch {}
|
|
180
|
+
}
|
|
181
|
+
swiped = true;
|
|
182
|
+
drag.value = clampOffset(step.offset, geometry.value);
|
|
183
|
+
}
|
|
184
|
+
function onUp(e) {
|
|
185
|
+
if (e.pointerId !== pointerId) return;
|
|
186
|
+
const result = tracker.up(sample(e));
|
|
187
|
+
release();
|
|
188
|
+
if (!result) return;
|
|
189
|
+
const outcome = swipeRowRelease(result, geometry.value);
|
|
190
|
+
if (outcome.kind === "start" && props.start) {
|
|
191
|
+
open.value = false;
|
|
192
|
+
emit("action", props.start.id);
|
|
193
|
+
} else if (outcome.kind === "full" && lastEnd.value) {
|
|
194
|
+
gone.value = true;
|
|
195
|
+
emit("action", lastEnd.value.id);
|
|
196
|
+
setTimeout(() => {
|
|
197
|
+
gone.value = false;
|
|
198
|
+
open.value = false;
|
|
199
|
+
}, 400);
|
|
200
|
+
} else if (outcome.kind === "rest") open.value = outcome.open;
|
|
201
|
+
}
|
|
202
|
+
function onCancel(e) {
|
|
203
|
+
if (e.pointerId !== pointerId) return;
|
|
204
|
+
tracker.cancel();
|
|
205
|
+
release();
|
|
206
|
+
}
|
|
207
|
+
function onClickCapture(e) {
|
|
208
|
+
if (swiped) {
|
|
209
|
+
e.stopPropagation();
|
|
210
|
+
e.preventDefault();
|
|
211
|
+
swiped = false;
|
|
212
|
+
}
|
|
213
|
+
}
|
|
214
|
+
function run(action) {
|
|
215
|
+
open.value = false;
|
|
216
|
+
startShown.value = false;
|
|
217
|
+
emit("action", action.id);
|
|
218
|
+
}
|
|
219
|
+
function onFocusIn(e) {
|
|
220
|
+
const side = e.target.closest("[data-side]")?.dataset.side;
|
|
221
|
+
if (side === "end") open.value = true;
|
|
222
|
+
if (side === "start") startShown.value = true;
|
|
223
|
+
}
|
|
224
|
+
function onFocusOut(e) {
|
|
225
|
+
if (root.value?.contains(e.relatedTarget)) return;
|
|
226
|
+
startShown.value = false;
|
|
227
|
+
open.value = false;
|
|
228
|
+
}
|
|
229
|
+
function onOutside(e) {
|
|
230
|
+
if (!root.value?.contains(e.target)) open.value = false;
|
|
231
|
+
}
|
|
232
|
+
watch(open, (isOpen) => {
|
|
233
|
+
if (isOpen) document.addEventListener("pointerdown", onOutside, true);
|
|
234
|
+
else document.removeEventListener("pointerdown", onOutside, true);
|
|
235
|
+
});
|
|
236
|
+
let resize;
|
|
237
|
+
onMounted(() => {
|
|
238
|
+
if (!root.value) return;
|
|
239
|
+
width.value = root.value.clientWidth || width.value;
|
|
240
|
+
if (typeof ResizeObserver !== "undefined") {
|
|
241
|
+
resize = new ResizeObserver(() => width.value = root.value?.clientWidth || width.value);
|
|
242
|
+
resize.observe(root.value);
|
|
243
|
+
}
|
|
244
|
+
});
|
|
245
|
+
onBeforeUnmount(() => {
|
|
246
|
+
stopFocusLoss?.();
|
|
247
|
+
resize?.disconnect();
|
|
248
|
+
document.removeEventListener("pointerdown", onOutside, true);
|
|
249
|
+
});
|
|
250
|
+
const startWidth = computed(() => Math.max(0, offset.value));
|
|
251
|
+
const fade = (width, from, span) => Math.min(1, Math.max(0, (width - from) / span));
|
|
252
|
+
const endIcon = (w) => fade(w, 22, 20);
|
|
253
|
+
const endLabel = (w) => fade(w, 50, 18);
|
|
254
|
+
const startIcon = (w) => fade(w, 36, 24);
|
|
255
|
+
const startLabel = (w) => fade(w, 84, 28);
|
|
256
|
+
return (_ctx, _cache) => {
|
|
257
|
+
return openBlock(), createElementBlock("div", {
|
|
258
|
+
ref_key: "root",
|
|
259
|
+
ref: root,
|
|
260
|
+
class: normalizeClass(["tx-swipe", {
|
|
261
|
+
"tx-swipe--dragging": dragging.value,
|
|
262
|
+
"tx-swipe--armed-full": armed.value === "full" || gone.value
|
|
263
|
+
}]),
|
|
264
|
+
onFocusin: onFocusIn,
|
|
265
|
+
onFocusout: onFocusOut
|
|
266
|
+
}, [
|
|
267
|
+
__props.start ? (openBlock(), createElementBlock("div", {
|
|
268
|
+
key: 0,
|
|
269
|
+
class: "tx-swipe__start",
|
|
270
|
+
"data-side": "start",
|
|
271
|
+
style: normalizeStyle({ width: `${startWidth.value}px` })
|
|
272
|
+
}, [createElementVNode("button", {
|
|
273
|
+
type: "button",
|
|
274
|
+
class: normalizeClass(["tx-swipe__action tx-swipe__action--start", [unref(toneClass)(__props.start.tone ?? "neutral"), { "tx-swipe__action--armed": armed.value === "start" }]]),
|
|
275
|
+
"aria-label": __props.start.label,
|
|
276
|
+
onClick: _cache[0] || (_cache[0] = ($event) => run(__props.start))
|
|
277
|
+
}, [renderSlot(_ctx.$slots, "action", {
|
|
278
|
+
action: __props.start,
|
|
279
|
+
armed: armed.value === "start",
|
|
280
|
+
side: "start",
|
|
281
|
+
width: startWidth.value
|
|
282
|
+
}, () => [__props.start.icon ? (openBlock(), createBlock(unref(TaoIcon), {
|
|
283
|
+
key: 0,
|
|
284
|
+
name: __props.start.icon,
|
|
285
|
+
size: 20,
|
|
286
|
+
style: normalizeStyle({ opacity: startIcon(startWidth.value) })
|
|
287
|
+
}, null, 8, ["name", "style"])) : createCommentVNode("", true), createElementVNode("span", {
|
|
288
|
+
class: "tx-swipe__label",
|
|
289
|
+
style: normalizeStyle({ opacity: startLabel(startWidth.value) })
|
|
290
|
+
}, toDisplayString(__props.start.label), 5)])], 10, _hoisted_1)], 4)) : createCommentVNode("", true),
|
|
291
|
+
__props.end.length ? (openBlock(), createElementBlock("div", _hoisted_2, [(openBlock(true), createElementBlock(Fragment, null, renderList(__props.end, (action, i) => {
|
|
292
|
+
return openBlock(), createElementBlock("button", {
|
|
293
|
+
key: action.id,
|
|
294
|
+
type: "button",
|
|
295
|
+
class: normalizeClass(["tx-swipe__action", [unref(toneClass)(action.tone ?? "neutral"), { "tx-swipe__action--armed": i === __props.end.length - 1 && (armed.value === "full" || gone.value) }]]),
|
|
296
|
+
style: normalizeStyle({ width: `${widths.value[i]}px` }),
|
|
297
|
+
"aria-label": action.label,
|
|
298
|
+
onClick: ($event) => run(action)
|
|
299
|
+
}, [renderSlot(_ctx.$slots, "action", {
|
|
300
|
+
action,
|
|
301
|
+
armed: i === __props.end.length - 1 && armed.value === "full",
|
|
302
|
+
side: "end",
|
|
303
|
+
width: widths.value[i] ?? 0
|
|
304
|
+
}, () => [action.icon ? (openBlock(), createBlock(unref(TaoIcon), {
|
|
305
|
+
key: 0,
|
|
306
|
+
name: action.icon,
|
|
307
|
+
size: 20,
|
|
308
|
+
style: normalizeStyle({ opacity: endIcon(widths.value[i] ?? 0) })
|
|
309
|
+
}, null, 8, ["name", "style"])) : createCommentVNode("", true), createElementVNode("span", {
|
|
310
|
+
class: "tx-swipe__label",
|
|
311
|
+
style: normalizeStyle({ opacity: endLabel(widths.value[i] ?? 0) })
|
|
312
|
+
}, toDisplayString(action.label), 5)])], 14, _hoisted_3);
|
|
313
|
+
}), 128))])) : createCommentVNode("", true),
|
|
314
|
+
createElementVNode("div", {
|
|
315
|
+
class: "tx-swipe__front",
|
|
316
|
+
style: normalizeStyle({ transform: `translate3d(${offset.value}px, 0, 0)` }),
|
|
317
|
+
onPointerdown: onDown,
|
|
318
|
+
onPointermove: onMove,
|
|
319
|
+
onPointerup: onUp,
|
|
320
|
+
onPointercancel: onCancel,
|
|
321
|
+
onClickCapture
|
|
322
|
+
}, [renderSlot(_ctx.$slots, "default")], 36)
|
|
323
|
+
], 34);
|
|
324
|
+
};
|
|
325
|
+
}
|
|
326
|
+
});
|
|
327
|
+
//#endregion
|
|
328
|
+
export { FULL_SWIPE_RATIO, START_THRESHOLD_PX, SWIPE_SLIVER_PX, TaoxSwipeRow_default as TaoxSwipeRow, armedAt, clampOffset, endOpenWidth, endWidths, fullThreshold, startThreshold, swipeRowRelease };
|
|
329
|
+
|
|
330
|
+
//# sourceMappingURL=swiperow.js.map
|
|
@@ -0,0 +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/** How far the row may move: no further than there is something behind it. / Насколько строка может уехать. */\nexport function clampOffset(offset: number, g: SwipeRowGeometry): number {\n const right = g.hasStart ? g.width : 0;\n const left = g.endCount === 0 ? 0 : g.fullSwipe ? -g.width : -endOpenWidth(g) * 1.5;\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 if (drag <= open) 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 }\"\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.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 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 }\"\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.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 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;;AAGA,SAAgB,YAAY,QAAgB,GAA6B;CACrE,MAAM,QAAQ,EAAE,WAAW,EAAE,QAAQ;CACrC,MAAM,OAAO,EAAE,aAAa,IAAI,IAAI,EAAE,YAAY,CAAC,EAAE,QAAQ,CAAC,aAAa,CA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AAA,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.
|
|
3
|
+
"version": "0.5.1",
|
|
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",
|
|
@@ -131,6 +131,15 @@
|
|
|
131
131
|
"types": "./dist/snap.d.ts",
|
|
132
132
|
"import": "./dist/snap.js"
|
|
133
133
|
},
|
|
134
|
+
"./sortable": {
|
|
135
|
+
"types": "./dist/sortable.d.ts",
|
|
136
|
+
"import": "./dist/sortable.js"
|
|
137
|
+
},
|
|
138
|
+
"./swiperow": {
|
|
139
|
+
"types": "./dist/swiperow/index.d.ts",
|
|
140
|
+
"import": "./dist/swiperow.js"
|
|
141
|
+
},
|
|
142
|
+
"./swiperow.css": "./dist/swiperow.css",
|
|
134
143
|
"./storage": {
|
|
135
144
|
"types": "./dist/storage.d.ts",
|
|
136
145
|
"import": "./dist/storage.js"
|
|
@@ -176,7 +185,7 @@
|
|
|
176
185
|
}
|
|
177
186
|
},
|
|
178
187
|
"devDependencies": {
|
|
179
|
-
"@1337exp/taoui": "^5.
|
|
188
|
+
"@1337exp/taoui": "^5.6.2",
|
|
180
189
|
"@types/node": "^26.6.4",
|
|
181
190
|
"@vitejs/plugin-vue": "^6.0.10",
|
|
182
191
|
"@vue/test-utils": "^2.5.1",
|
package/skills/taoux/SKILL.md
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: taoux
|
|
3
|
-
description: Build
|
|
3
|
+
description: Build interaction in Vue 3 apps with @1337exp/taoux (TaoUX) — subpath modules for gestures (tap, long press, pinch, swipe), reorderable lists (sortable), swipe rows with actions (swiperow), undo by snapshots or by records, document sessions, autosave across tabs, commands and hotkeys, playback, canvas, curve and gradient editors, and joining them to TaoUI. Use when code imports @1337exp/taoux/*, uses Taox* components or --tx-* variables, or the user asks for TaoUX.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# TaoUX
|
|
7
7
|
|
|
8
|
-
Behaviour building blocks for editors: the logic is plain TypeScript (tested without a DOM), the few Vue modules are
|
|
9
|
-
shells, and TaoUX has **no buttons or fields of its own
|
|
8
|
+
Behaviour building blocks for apps and editors: the logic is plain TypeScript (tested without a DOM), the few Vue modules are
|
|
9
|
+
thin shells, and TaoUX has **no buttons or fields of its own** outside the two TaoUI-based fields. Pair it with TaoUI for the
|
|
10
|
+
controls, or with your own design.
|
|
10
11
|
|
|
11
12
|
## Rules
|
|
12
13
|
|
|
13
14
|
1. **Import by subpath**, there is no root entry: `import { History } from '@1337exp/taoux/history'`. Only what you import
|
|
14
15
|
reaches the bundle. ESM only.
|
|
15
16
|
2. **A Vue module's styles are imported explicitly**: `import '@1337exp/taoux/curveeditor.css'` (also `canvas.css`,
|
|
16
|
-
`links.css`, `gradienteditor.css`, `curvefield.css`; `curvefield` needs `curveeditor.css` too).
|
|
17
|
+
`links.css`, `gradienteditor.css`, `curvefield.css`, `swiperow.css`; `curvefield` needs `curveeditor.css` too).
|
|
17
18
|
3. **With TaoUI, add the bridge**: `import '@1337exp/taoux/taoui.css'` points every `--tx-*` colour at a `--tao-*` role, so
|
|
18
19
|
the editors follow the TaoUI theme and palettes. Zero specificity: your rules win. Without it the editors stay dark.
|
|
19
|
-
4. **Values travel through `v-model`**; TaoUX never renders a TaoUI control itself, except tier-2 `curvefield`.
|
|
20
|
+
4. **Values travel through `v-model`**; TaoUX never renders a TaoUI control itself, except the tier-2 fields `curvefield` and `swiperow`.
|
|
20
21
|
5. **Pre-1.0**: breaking changes happen between minors; read `CHANGELOG.md`.
|
|
21
22
|
|
|
22
23
|
## Modules
|
|
@@ -26,6 +27,8 @@ shells, and TaoUX has **no buttons or fields of its own**. Pair it with TaoUI fo
|
|
|
26
27
|
| `camera` | pan, zoom around the cursor, screen ↔ world (`zoomAt`) |
|
|
27
28
|
| `history` | `new History(snapshot)`: undo / redo on string snapshots, rapid edits with one `key` merged into one step |
|
|
28
29
|
| `undo` | `new UndoStack({ id, revive, vanish? })`: undo / redo of a list of records by steps that keep only the touched ones (`diffRecords(prev, next, id)` makes a step; a returned record takes its old place); right for a list that is edited and synced, where `History` would store the whole list per step and an undo would roll back a sync. `coalesceMaxMs` caps a merged step of typing |
|
|
30
|
+
| `swiperow` | `<TaoxSwipeRow :start="{ id, label, icon, tone }" :end="[{ id, label, icon, tone }]" v-model:open @action="run">` around a list row: a pull to the start runs `start` past a threshold, to the end opens the actions, a long pull runs the last one (`fullSwipe`, on by default); a mouse drags only with `mouse`; import `@1337exp/taoux/swiperow.css`. Needs TaoUI (tier 2) |
|
|
31
|
+
| `sortable` | `useSortable(listRef, { onMove: (from, to) => (list.value = moveItem(list.value, from, to)) })`; mark each item `data-sortable-item` and a focusable grip inside it `data-sortable-handle` (a TaoButton with `icon="tao-grip"` and an aria-label); style `[data-sortable-dragging]` / `[data-sortable-lifted]`. Keyboard: Space lifts, arrows move, Space drops, Esc returns; `texts: sortableTextsRu` for Russian |
|
|
29
32
|
| `session` | `createDocumentSession(...)`: history + autosave + files + restore + notices for one document; `canUndo` / `canRedo` refs. `camera` is optional (a list, not a canvas); count with `countItems` (`countNodes` is its old name) |
|
|
30
33
|
| `commands` | `createCommands([...])`: one registry for menus, shortcuts and palettes (see below) |
|
|
31
34
|
| `hotkeys` | `parseHotkey('Mod+Shift+Z')`, `matchHotkey`, `formatHotkey` (`Ctrl+Shift+Z` / `⇧⌘Z`), `isReservedHotkey`, `bindHotkeys(element, map)` |
|
|
@@ -34,7 +37,7 @@ shells, and TaoUX has **no buttons or fields of its own**. Pair it with TaoUI fo
|
|
|
34
37
|
| `snap` | soft snapping to a grid, threshold follows the zoom |
|
|
35
38
|
| `wheel` | wheel / trackpad → pan or zoom, like Figma (zoom only with Ctrl / ⌘ or a pinch) |
|
|
36
39
|
| `edgescroll` | auto-scroll near an edge while dragging (`createEdgeScroller`) |
|
|
37
|
-
| `gestures` | tap, double tap, long press, pinch; `SwipeTracker` (swipe vs scroll) + `settleOpen` (where a released row rests) |
|
|
40
|
+
| `gestures` | tap, double tap, long press, pinch; `SwipeTracker` (swipe vs scroll) + `settleOpen` (where a released row rests); `listenFocusLoss(cancel)` while a press is held, as Alt-Tab swallows the pointerup |
|
|
38
41
|
| `touch` | `coarse`: is the pointer a finger |
|
|
39
42
|
| `curve` | link paths: Bezier between pins, arrowheads of constant screen size |
|
|
40
43
|
| `ids` | `uuid()` for stored / synced records; `uid(prefix, taken)` restarts from zero on every load, only for ids inside one document |
|