@1337exp/taoux 0.8.0 → 0.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +24 -0
- package/README.md +2 -1
- package/README.ru.md +2 -1
- package/dist/camera.d.ts +17 -0
- package/dist/camera.js +20 -1
- package/dist/camera.js.map +1 -1
- package/dist/canvas/TaoxCanvas.vue.d.ts +7 -0
- package/dist/canvas/host.d.ts +41 -0
- package/dist/canvas/index.d.ts +1 -1
- package/dist/canvas.css +4 -2
- package/dist/canvas.js +60 -8
- package/dist/canvas.js.map +1 -1
- package/dist/chunks/curveeditor-F3XBWHPL.js.map +1 -1
- package/dist/curve.d.ts +7 -0
- package/dist/curve.js +18 -1
- package/dist/curve.js.map +1 -1
- package/dist/curveeditor.css +3 -1
- package/dist/curvefield.css +30 -37
- package/dist/curvefield.js +1 -1
- package/dist/curvefield.js.map +1 -1
- package/dist/gradienteditor.css +4 -2
- package/dist/gradienteditor.js.map +1 -1
- package/dist/guides.d.ts +53 -0
- package/dist/guides.js +83 -0
- package/dist/guides.js.map +1 -0
- package/dist/links.css +3 -1
- package/dist/links.js.map +1 -1
- package/dist/sortable.js +5 -2
- package/dist/sortable.js.map +1 -1
- package/dist/swiperow.css +15 -10
- package/dist/swiperow.js.map +1 -1
- package/package.json +5 -1
- package/skills/taoux/SKILL.md +6 -4
- package/theme/taoui.css +19 -0
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"guides.js","names":[],"sources":["../src/guides.ts"],"sourcesContent":["/**\n * Smart guides for dragging on a canvas (as in Figma and Miro): while a rectangle is dragged, its edges and its centre\n * are compared with the edges and centres of the other rectangles; when two coincide (or are within the threshold) the\n * rectangle is pulled so that they do, and a thin line is drawn through them.\n * The module only counts: where the rectangle goes (`dx`, `dy`) and which lines to draw. Collecting the rectangles of the\n * other nodes, applying the shift and drawing are the app's business. Plain numbers, no DOM, no Vue.\n *\n * Умные направляющие при перетаскивании по холсту (как в Figma и Miro): пока прямоугольник тащат, его края и центр\n * сравниваются с краями и центрами остальных прямоугольников; когда два значения совпали (или ближе порога), прямоугольник\n * притягивается так, чтобы они совпали, и через них рисуется тонкая линия.\n * Модуль только считает: куда сдвинуть прямоугольник (`dx`, `dy`) и какие линии нарисовать. Собрать прямоугольники других\n * нод, применить сдвиг и нарисовать — забота приложения. Просто числа, без DOM и Vue.\n */\n\nexport interface GuideRect {\n x: number;\n y: number;\n w: number;\n h: number;\n}\n\n/**\n * A guide line. `axis: 'x'` is a vertical line at `x = at` that runs from `from` to `to` in y; `axis: 'y'` is a\n * horizontal line at `y = at` that runs from `from` to `to` in x.\n * Линия-направляющая. `axis: 'x'` — вертикальная линия при `x = at` от `from` до `to` по y; `axis: 'y'` — горизонтальная\n * при `y = at` от `from` до `to` по x.\n */\nexport interface GuideLine {\n axis: 'x' | 'y';\n at: number;\n from: number;\n to: number;\n}\n\nexport interface GuideResult {\n /** How far to shift the rectangle in x so that it lies on a guide; 0 when there is none. / Сдвиг по x, 0 если направляющей нет. */\n dx: number;\n dy: number;\n /** What to draw, for the rectangle already shifted by `dx`, `dy`. / Что рисовать для уже сдвинутого прямоугольника. */\n lines: GuideLine[];\n}\n\nexport interface GuideOptions {\n /** Compare edges (left / right, top / bottom). Default true. / Сравнивать края. По умолчанию true. */\n edges?: boolean;\n /** Compare centres. Default true. / Сравнивать центры. По умолчанию true. */\n centers?: boolean;\n}\n\n/** Two values this close count as the same line (float noise). / Значения ближе этого считаются одной линией. */\nconst SAME = 1e-6;\n\ntype Axis = 'x' | 'y';\nconst pos = (axis: Axis, r: GuideRect) => (axis === 'x' ? r.x : r.y);\nconst size = (axis: Axis, r: GuideRect) => (axis === 'x' ? r.w : r.h);\nconst other = (axis: Axis): Axis => (axis === 'x' ? 'y' : 'x');\n\n/** The comparable positions of a rectangle along an axis: edges and centre. / Сравниваемые положения вдоль оси: края и центр. */\nfunction marks(axis: Axis, r: GuideRect, options: GuideOptions): number[] {\n const start = pos(axis, r);\n const out: number[] = [];\n if (options.edges !== false) out.push(start, start + size(axis, r));\n if (options.centers !== false) out.push(start + size(axis, r) / 2);\n return out;\n}\n\n/** The shift along one axis that puts the nearest pair of marks together; 0 when none is within the threshold. */\nfunction shiftAlong(axis: Axis, moving: GuideRect, others: readonly GuideRect[], threshold: number, options: GuideOptions): number {\n const mine = marks(axis, moving, options);\n let best = Infinity;\n for (const o of others) {\n for (const t of marks(axis, o, options)) {\n for (const m of mine) {\n const d = t - m;\n if (Math.abs(d) < Math.abs(best)) best = d;\n }\n }\n }\n return Math.abs(best) <= threshold ? best : 0;\n}\n\n/**\n * The lines on one axis for a rectangle that is already in its final place: every pair of marks that coincides makes a\n * line, and several rectangles on one line share it (it runs from the first to the last of them).\n * Линии по одной оси для прямоугольника, уже стоящего на итоговом месте: каждая совпавшая пара даёт линию, а несколько\n * прямоугольников на одной линии делят её (она идёт от первого до последнего).\n */\nfunction linesAlong(axis: Axis, rect: GuideRect, others: readonly GuideRect[], options: GuideOptions): GuideLine[] {\n const cross = other(axis);\n const mine = marks(axis, rect, options);\n const lines = new Map<number, GuideLine>();\n for (const o of others) {\n for (const t of marks(axis, o, options)) {\n if (!mine.some((m) => Math.abs(m - t) <= SAME)) continue;\n const from = Math.min(pos(cross, rect), pos(cross, o));\n const to = Math.max(pos(cross, rect) + size(cross, rect), pos(cross, o) + size(cross, o));\n const key = Math.round(t / SAME);\n const line = lines.get(key);\n if (line) {\n line.from = Math.min(line.from, from);\n line.to = Math.max(line.to, to);\n } else {\n lines.set(key, { axis, at: t, from, to });\n }\n }\n }\n return [...lines.values()];\n}\n\n/**\n * Where a dragged rectangle goes and which guide lines to draw. `threshold` is in the units of the rectangles (world\n * units; for a screen threshold divide by the zoom). Each axis is decided on its own: the rectangle may stick to a\n * vertical guide and move freely along y. A rectangle exactly on a guide (distance 0) gets its line too.\n * Куда встаёт тащимый прямоугольник и какие линии рисовать. `threshold` в единицах прямоугольников (мировых; экранный\n * порог делится на масштаб). Каждая ось решается сама по себе: прямоугольник может прилипнуть к вертикальной\n * направляющей и свободно ехать по y. Прямоугольник, стоящий точно на направляющей (расстояние 0), тоже получает линию.\n */\nexport function snapToGuides(moving: GuideRect, others: readonly GuideRect[], threshold: number, options: GuideOptions = {}): GuideResult {\n if (others.length === 0 || !(threshold >= 0)) return { dx: 0, dy: 0, lines: [] };\n\n const dx = shiftAlong('x', moving, others, threshold, options);\n const dy = shiftAlong('y', moving, others, threshold, options);\n const fin: GuideRect = { ...moving, x: moving.x + dx, y: moving.y + dy };\n\n // Only an axis that really is on a guide draws lines: a pair within the threshold but not coinciding would not.\n // Линии рисует только ось, которая правда стоит на направляющей: пара в пределах порога, но не совпавшая, не нарисуется.\n return { dx, dy, lines: [...linesAlong('x', fin, others, options), ...linesAlong('y', fin, others, options)] };\n}\n"],"mappings":";;AAkDA,IAAM,OAAO;AAGb,IAAM,OAAO,MAAY,MAAkB,SAAS,MAAM,EAAE,IAAI,EAAE;AAClE,IAAM,QAAQ,MAAY,MAAkB,SAAS,MAAM,EAAE,IAAI,EAAE;AACnE,IAAM,SAAS,SAAsB,SAAS,MAAM,MAAM;;AAG1D,SAAS,MAAM,MAAY,GAAc,SAAiC;CACtE,MAAM,QAAQ,IAAI,MAAM,CAAC;CACzB,MAAM,MAAgB,CAAC;CACvB,IAAI,QAAQ,UAAU,OAAO,IAAI,KAAK,OAAO,QAAQ,KAAK,MAAM,CAAC,CAAC;CAClE,IAAI,QAAQ,YAAY,OAAO,IAAI,KAAK,QAAQ,KAAK,MAAM,CAAC,IAAI,CAAC;CACjE,OAAO;AACX;;AAGA,SAAS,WAAW,MAAY,QAAmB,QAA8B,WAAmB,SAA+B;CAC/H,MAAM,OAAO,MAAM,MAAM,QAAQ,OAAO;CACxC,IAAI,OAAO;CACX,KAAK,MAAM,KAAK,QACZ,KAAK,MAAM,KAAK,MAAM,MAAM,GAAG,OAAO,GAClC,KAAK,MAAM,KAAK,MAAM;EAClB,MAAM,IAAI,IAAI;EACd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AQ,QAAQ,WAAW,OAAO;CAC7D,MAAM,MAAiB;EAAE,GAAG;EAAQ,GAAG,OAAO,IAAI;EAAI,GAAG,OAAO,IAAI;CAAG;CAIvE,OAAO;EAAE;EAAI;EAAI,OAAO,CAAC,GAAG,WAAW,KAAK,KAAK,QAAQ,OAAO,GAAG,GAAG,WAAW,KAAK,KAAK,QAAQ,OAAO,CAAC;CAAE;AACjH"}
|
package/dist/links.css
CHANGED
|
@@ -39,7 +39,9 @@
|
|
|
39
39
|
.tx-link.selected .tx-link-line {
|
|
40
40
|
stroke-width: var(--tx-link-width-active, 3);
|
|
41
41
|
}
|
|
42
|
-
|
|
42
|
+
|
|
43
|
+
/* The selector is as specific as `.tx-links path` above: with a shorter one `fill: none` won and the arrowhead was invisible. / Селектор той же специфичности, что у `.tx-links path` выше: с коротким побеждал `fill: none`, и наконечник не был виден. */
|
|
44
|
+
.tx-links .tx-link-head {
|
|
43
45
|
fill: var(--tx-link-now);
|
|
44
46
|
stroke: none;
|
|
45
47
|
pointer-events: none;
|
package/dist/links.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"links.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","_normalizeStyle","_createCommentVNode","_createElementVNode","_sfc_main"],"sources":["../src/links/TaoxLinks.vue","../src/links/TaoxLinks.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkLine, LinkPreview } from './types';\n\ndefineProps<{\n lines: readonly LinkLine[];\n selectedId?: string | null;\n preview?: LinkPreview | null;\n /**\n * Highlight the hovered and selected link with a blurred glow.\n * Подсвечивать наведённую и выбранную связь размытым свечением.\n */\n glow?: boolean;\n}>();\n\nconst colorStyle = (line: LinkLine) => (line.color ? { '--tx-link-line-color': line.color } : undefined);\n</script>\n\n<template>\n <svg class=\"tx-links\" width=\"1\" height=\"1\">\n <g\n v-for=\"line in lines\"\n :key=\"line.id\"\n class=\"tx-link\"\n :class=\"{ selected: selectedId === line.id }\"\n :data-conn-id=\"line.id\"\n :style=\"colorStyle(line)\"\n >\n <path v-if=\"glow\" class=\"tx-link-glow\" :d=\"line.d\" />\n <path class=\"tx-link-line\" :d=\"line.d\" />\n <path v-if=\"line.head\" class=\"tx-link-head\" :d=\"line.head\" />\n <path class=\"tx-link-hit\" :d=\"line.d\" />\n </g>\n\n <g v-if=\"preview\" class=\"tx-link tx-link-preview\" :class=\"{ invalid: preview.invalid }\" :style=\"colorStyle(preview)\">\n <path class=\"tx-link-line\" :d=\"preview.d\" />\n <path v-if=\"preview.head\" class=\"tx-link-head\" :d=\"preview.head\" />\n </g>\n </svg>\n</template>\n\n<style>\n/*\n * Configured with CSS variables on any ancestor:\n * Настройка через CSS-переменные на любом предке:\n * --tx-link-color, --tx-link-hover-color, --tx-link-selected-color, --tx-link-preview-color, --tx-link-invalid-color,\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (opacity of the glow).\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (непрозрачность свечения).\n */\n.tx-links {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.tx-links path {\n fill: none;\n stroke-linecap: round;\n /* thickness in screen pixels, independent of zoom / толщина в экранных пикселях, не зависит от зума */\n vector-effect: non-scaling-stroke;\n}\n\n.tx-link {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-color, #9ca3af));\n}\n\n/* A link without its own colour turns the hover colour on hover. An own colour stays on hover (it gets thicker and glows). / Своего цвета у связи нет: наведение красит её в hover-цвет. Свой цвет при наведении остаётся (утолщается и светится). */\n.tx-link:hover {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-hover-color, #fff));\n}\n\n.tx-link.selected {\n --tx-link-now: var(--tx-link-selected-color, #f59e0b);\n}\n\n.tx-link-line {\n stroke: var(--tx-link-now);\n stroke-width: var(--tx-link-width, 2);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-line,\n.tx-link.selected .tx-link-line {\n stroke-width: var(--tx-link-width-active, 3);\n}\n\n.tx-link-head {\n fill: var(--tx-link-now);\n stroke: none;\n pointer-events: none;\n}\n\n.tx-link-glow {\n stroke: var(--tx-link-now);\n stroke-width: 9;\n opacity: 0;\n filter: blur(3px);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-glow,\n.tx-link.selected .tx-link-glow {\n opacity: var(--tx-link-glow, 0.35);\n}\n\n.tx-link-hit {\n stroke: transparent;\n stroke-width: var(--tx-link-hit, 14);\n pointer-events: stroke;\n cursor: pointer;\n}\n\n/* A finger is thicker than a cursor: the hit area of a link is wider. / Палец толще курсора: зона попадания по связи шире. */\n@media (pointer: coarse) {\n .tx-link-hit {\n stroke-width: var(--tx-link-hit-coarse, 30);\n }\n}\n\n.tx-link-preview {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-preview-color, #f59e0b));\n opacity: 0.85;\n}\n\n.tx-link-preview .tx-link-line {\n stroke-dasharray: 6 4;\n}\n\n.tx-link-preview.invalid {\n --tx-link-now: var(--tx-link-invalid-color, #ef4444);\n}\n</style>\n","<script lang=\"ts\" setup>\nimport type { LinkLine, LinkPreview } from './types';\n\ndefineProps<{\n lines: readonly LinkLine[];\n selectedId?: string | null;\n preview?: LinkPreview | null;\n /**\n * Highlight the hovered and selected link with a blurred glow.\n * Подсвечивать наведённую и выбранную связь размытым свечением.\n */\n glow?: boolean;\n}>();\n\nconst colorStyle = (line: LinkLine) => (line.color ? { '--tx-link-line-color': line.color } : undefined);\n</script>\n\n<template>\n <svg class=\"tx-links\" width=\"1\" height=\"1\">\n <g\n v-for=\"line in lines\"\n :key=\"line.id\"\n class=\"tx-link\"\n :class=\"{ selected: selectedId === line.id }\"\n :data-conn-id=\"line.id\"\n :style=\"colorStyle(line)\"\n >\n <path v-if=\"glow\" class=\"tx-link-glow\" :d=\"line.d\" />\n <path class=\"tx-link-line\" :d=\"line.d\" />\n <path v-if=\"line.head\" class=\"tx-link-head\" :d=\"line.head\" />\n <path class=\"tx-link-hit\" :d=\"line.d\" />\n </g>\n\n <g v-if=\"preview\" class=\"tx-link tx-link-preview\" :class=\"{ invalid: preview.invalid }\" :style=\"colorStyle(preview)\">\n <path class=\"tx-link-line\" :d=\"preview.d\" />\n <path v-if=\"preview.head\" class=\"tx-link-head\" :d=\"preview.head\" />\n </g>\n </svg>\n</template>\n\n<style>\n/*\n * Configured with CSS variables on any ancestor:\n * Настройка через CSS-переменные на любом предке:\n * --tx-link-color, --tx-link-hover-color, --tx-link-selected-color, --tx-link-preview-color, --tx-link-invalid-color,\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (opacity of the glow).\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (непрозрачность свечения).\n */\n.tx-links {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.tx-links path {\n fill: none;\n stroke-linecap: round;\n /* thickness in screen pixels, independent of zoom / толщина в экранных пикселях, не зависит от зума */\n vector-effect: non-scaling-stroke;\n}\n\n.tx-link {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-color, #9ca3af));\n}\n\n/* A link without its own colour turns the hover colour on hover. An own colour stays on hover (it gets thicker and glows). / Своего цвета у связи нет: наведение красит её в hover-цвет. Свой цвет при наведении остаётся (утолщается и светится). */\n.tx-link:hover {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-hover-color, #fff));\n}\n\n.tx-link.selected {\n --tx-link-now: var(--tx-link-selected-color, #f59e0b);\n}\n\n.tx-link-line {\n stroke: var(--tx-link-now);\n stroke-width: var(--tx-link-width, 2);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-line,\n.tx-link.selected .tx-link-line {\n stroke-width: var(--tx-link-width-active, 3);\n}\n\n.tx-link-head {\n fill: var(--tx-link-now);\n stroke: none;\n pointer-events: none;\n}\n\n.tx-link-glow {\n stroke: var(--tx-link-now);\n stroke-width: 9;\n opacity: 0;\n filter: blur(3px);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-glow,\n.tx-link.selected .tx-link-glow {\n opacity: var(--tx-link-glow, 0.35);\n}\n\n.tx-link-hit {\n stroke: transparent;\n stroke-width: var(--tx-link-hit, 14);\n pointer-events: stroke;\n cursor: pointer;\n}\n\n/* A finger is thicker than a cursor: the hit area of a link is wider. / Палец толще курсора: зона попадания по связи шире. */\n@media (pointer: coarse) {\n .tx-link-hit {\n stroke-width: var(--tx-link-hit-coarse, 30);\n }\n}\n\n.tx-link-preview {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-preview-color, #f59e0b));\n opacity: 0.85;\n}\n\n.tx-link-preview .tx-link-line {\n stroke-dasharray: 6 4;\n}\n\n.tx-link-preview.invalid {\n --tx-link-now: var(--tx-link-invalid-color, #ef4444);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAcA,MAAM,cAAc,SAAoB,KAAK,QAAQ,EAAE,wBAAwB,KAAK,MAAM,IAAI,KAAA;;GAI1F,OAAAA,UAAA,GAAAC,mBAmBM,OAnBN,YAmBM,EAlBFD,UAAA,IAAA,GAAAC,mBAYIC,UAAA,MAAAC,WAXe,QAAA,QAAR,SAAI;IADf,OAAAH,UAAA,GAAAC,mBAYI,KAAA;KAVC,KAAK,KAAK;KACX,OAAKG,eAAA,CAAC,WAAS,EAAA,UACK,QAAA,eAAe,KAAK,GAAE,CAAA,CAAA;KACzC,gBAAc,KAAK;KACnB,OAAKC,eAAE,WAAW,IAAI,CAAA;;KAEX,QAAA,QAAZL,UAAA,GAAAC,mBAAqD,QAAA;;MAAnC,OAAM;MAAgB,GAAG,KAAK;;KAChDM,mBAAyC,QAAA;MAAnC,OAAM;MAAgB,GAAG,KAAK;;KACxB,KAAK,QAAjBP,UAAA,GAAAC,mBAA6D,QAAA;;MAAtC,OAAM;MAAgB,GAAG,KAAK;;KACrDM,mBAAwC,QAAA;MAAlC,OAAM;MAAe,GAAG,KAAK;;;G,WAG9B,QAAA,WAATP,UAAA,GAAAC,mBAGI,KAAA;;IAHc,OAAKG,eAAA,CAAC,2BAAyB,EAAA,SAAoB,QAAA,QAAQ,QAAO,CAAA,CAAA;IAAK,OAAKC,eAAE,WAAW,QAAA,OAAO,CAAA;G,IAC9GE,mBAA4C,QAAA;IAAtC,OAAM;IAAgB,GAAG,QAAA,QAAQ;G,yBAC3B,QAAA,QAAQ,QAApBP,UAAA,GAAAC,mBAAmE,QAAA;;IAAzC,OAAM;IAAgB,GAAG,QAAA,QAAQ"}
|
|
1
|
+
{"version":3,"file":"links.js","names":["_openBlock","_createElementBlock","_Fragment","_renderList","_normalizeClass","_normalizeStyle","_createCommentVNode","_createElementVNode","_sfc_main"],"sources":["../src/links/TaoxLinks.vue","../src/links/TaoxLinks.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport type { LinkLine, LinkPreview } from './types';\n\ndefineProps<{\n lines: readonly LinkLine[];\n selectedId?: string | null;\n preview?: LinkPreview | null;\n /**\n * Highlight the hovered and selected link with a blurred glow.\n * Подсвечивать наведённую и выбранную связь размытым свечением.\n */\n glow?: boolean;\n}>();\n\nconst colorStyle = (line: LinkLine) => (line.color ? { '--tx-link-line-color': line.color } : undefined);\n</script>\n\n<template>\n <svg class=\"tx-links\" width=\"1\" height=\"1\">\n <g\n v-for=\"line in lines\"\n :key=\"line.id\"\n class=\"tx-link\"\n :class=\"{ selected: selectedId === line.id }\"\n :data-conn-id=\"line.id\"\n :style=\"colorStyle(line)\"\n >\n <path v-if=\"glow\" class=\"tx-link-glow\" :d=\"line.d\" />\n <path class=\"tx-link-line\" :d=\"line.d\" />\n <path v-if=\"line.head\" class=\"tx-link-head\" :d=\"line.head\" />\n <path class=\"tx-link-hit\" :d=\"line.d\" />\n </g>\n\n <g v-if=\"preview\" class=\"tx-link tx-link-preview\" :class=\"{ invalid: preview.invalid }\" :style=\"colorStyle(preview)\">\n <path class=\"tx-link-line\" :d=\"preview.d\" />\n <path v-if=\"preview.head\" class=\"tx-link-head\" :d=\"preview.head\" />\n </g>\n </svg>\n</template>\n\n<style>\n/*\n * Configured with CSS variables on any ancestor:\n * Настройка через CSS-переменные на любом предке:\n * --tx-link-color, --tx-link-hover-color, --tx-link-selected-color, --tx-link-preview-color, --tx-link-invalid-color,\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (opacity of the glow).\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (непрозрачность свечения).\n */\n.tx-links {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.tx-links path {\n fill: none;\n stroke-linecap: round;\n /* thickness in screen pixels, independent of zoom / толщина в экранных пикселях, не зависит от зума */\n vector-effect: non-scaling-stroke;\n}\n\n.tx-link {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-color, #9ca3af));\n}\n\n/* A link without its own colour turns the hover colour on hover. An own colour stays on hover (it gets thicker and glows). / Своего цвета у связи нет: наведение красит её в hover-цвет. Свой цвет при наведении остаётся (утолщается и светится). */\n.tx-link:hover {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-hover-color, #fff));\n}\n\n.tx-link.selected {\n --tx-link-now: var(--tx-link-selected-color, #f59e0b);\n}\n\n.tx-link-line {\n stroke: var(--tx-link-now);\n stroke-width: var(--tx-link-width, 2);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-line,\n.tx-link.selected .tx-link-line {\n stroke-width: var(--tx-link-width-active, 3);\n}\n\n/* The selector is as specific as `.tx-links path` above: with a shorter one `fill: none` won and the arrowhead was invisible. / Селектор той же специфичности, что у `.tx-links path` выше: с коротким побеждал `fill: none`, и наконечник не был виден. */\n.tx-links .tx-link-head {\n fill: var(--tx-link-now);\n stroke: none;\n pointer-events: none;\n}\n\n.tx-link-glow {\n stroke: var(--tx-link-now);\n stroke-width: 9;\n opacity: 0;\n filter: blur(3px);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-glow,\n.tx-link.selected .tx-link-glow {\n opacity: var(--tx-link-glow, 0.35);\n}\n\n.tx-link-hit {\n stroke: transparent;\n stroke-width: var(--tx-link-hit, 14);\n pointer-events: stroke;\n cursor: pointer;\n}\n\n/* A finger is thicker than a cursor: the hit area of a link is wider. / Палец толще курсора: зона попадания по связи шире. */\n@media (pointer: coarse) {\n .tx-link-hit {\n stroke-width: var(--tx-link-hit-coarse, 30);\n }\n}\n\n.tx-link-preview {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-preview-color, #f59e0b));\n opacity: 0.85;\n}\n\n.tx-link-preview .tx-link-line {\n stroke-dasharray: 6 4;\n}\n\n.tx-link-preview.invalid {\n --tx-link-now: var(--tx-link-invalid-color, #ef4444);\n}\n</style>\n","<script lang=\"ts\" setup>\nimport type { LinkLine, LinkPreview } from './types';\n\ndefineProps<{\n lines: readonly LinkLine[];\n selectedId?: string | null;\n preview?: LinkPreview | null;\n /**\n * Highlight the hovered and selected link with a blurred glow.\n * Подсвечивать наведённую и выбранную связь размытым свечением.\n */\n glow?: boolean;\n}>();\n\nconst colorStyle = (line: LinkLine) => (line.color ? { '--tx-link-line-color': line.color } : undefined);\n</script>\n\n<template>\n <svg class=\"tx-links\" width=\"1\" height=\"1\">\n <g\n v-for=\"line in lines\"\n :key=\"line.id\"\n class=\"tx-link\"\n :class=\"{ selected: selectedId === line.id }\"\n :data-conn-id=\"line.id\"\n :style=\"colorStyle(line)\"\n >\n <path v-if=\"glow\" class=\"tx-link-glow\" :d=\"line.d\" />\n <path class=\"tx-link-line\" :d=\"line.d\" />\n <path v-if=\"line.head\" class=\"tx-link-head\" :d=\"line.head\" />\n <path class=\"tx-link-hit\" :d=\"line.d\" />\n </g>\n\n <g v-if=\"preview\" class=\"tx-link tx-link-preview\" :class=\"{ invalid: preview.invalid }\" :style=\"colorStyle(preview)\">\n <path class=\"tx-link-line\" :d=\"preview.d\" />\n <path v-if=\"preview.head\" class=\"tx-link-head\" :d=\"preview.head\" />\n </g>\n </svg>\n</template>\n\n<style>\n/*\n * Configured with CSS variables on any ancestor:\n * Настройка через CSS-переменные на любом предке:\n * --tx-link-color, --tx-link-hover-color, --tx-link-selected-color, --tx-link-preview-color, --tx-link-invalid-color,\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (opacity of the glow).\n * --tx-link-width, --tx-link-width-active, --tx-link-hit, --tx-link-hit-coarse, --tx-link-glow (непрозрачность свечения).\n */\n.tx-links {\n position: absolute;\n top: 0;\n left: 0;\n overflow: visible;\n pointer-events: none;\n}\n\n.tx-links path {\n fill: none;\n stroke-linecap: round;\n /* thickness in screen pixels, independent of zoom / толщина в экранных пикселях, не зависит от зума */\n vector-effect: non-scaling-stroke;\n}\n\n.tx-link {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-color, #9ca3af));\n}\n\n/* A link without its own colour turns the hover colour on hover. An own colour stays on hover (it gets thicker and glows). / Своего цвета у связи нет: наведение красит её в hover-цвет. Свой цвет при наведении остаётся (утолщается и светится). */\n.tx-link:hover {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-hover-color, #fff));\n}\n\n.tx-link.selected {\n --tx-link-now: var(--tx-link-selected-color, #f59e0b);\n}\n\n.tx-link-line {\n stroke: var(--tx-link-now);\n stroke-width: var(--tx-link-width, 2);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-line,\n.tx-link.selected .tx-link-line {\n stroke-width: var(--tx-link-width-active, 3);\n}\n\n/* The selector is as specific as `.tx-links path` above: with a shorter one `fill: none` won and the arrowhead was invisible. / Селектор той же специфичности, что у `.tx-links path` выше: с коротким побеждал `fill: none`, и наконечник не был виден. */\n.tx-links .tx-link-head {\n fill: var(--tx-link-now);\n stroke: none;\n pointer-events: none;\n}\n\n.tx-link-glow {\n stroke: var(--tx-link-now);\n stroke-width: 9;\n opacity: 0;\n filter: blur(3px);\n pointer-events: none;\n}\n\n.tx-link:hover .tx-link-glow,\n.tx-link.selected .tx-link-glow {\n opacity: var(--tx-link-glow, 0.35);\n}\n\n.tx-link-hit {\n stroke: transparent;\n stroke-width: var(--tx-link-hit, 14);\n pointer-events: stroke;\n cursor: pointer;\n}\n\n/* A finger is thicker than a cursor: the hit area of a link is wider. / Палец толще курсора: зона попадания по связи шире. */\n@media (pointer: coarse) {\n .tx-link-hit {\n stroke-width: var(--tx-link-hit-coarse, 30);\n }\n}\n\n.tx-link-preview {\n --tx-link-now: var(--tx-link-line-color, var(--tx-link-preview-color, #f59e0b));\n opacity: 0.85;\n}\n\n.tx-link-preview .tx-link-line {\n stroke-dasharray: 6 4;\n}\n\n.tx-link-preview.invalid {\n --tx-link-now: var(--tx-link-invalid-color, #ef4444);\n}\n</style>\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;EAcA,MAAM,cAAc,SAAoB,KAAK,QAAQ,EAAE,wBAAwB,KAAK,MAAM,IAAI,KAAA;;GAI1F,OAAAA,UAAA,GAAAC,mBAmBM,OAnBN,YAmBM,EAlBFD,UAAA,IAAA,GAAAC,mBAYIC,UAAA,MAAAC,WAXe,QAAA,QAAR,SAAI;IADf,OAAAH,UAAA,GAAAC,mBAYI,KAAA;KAVC,KAAK,KAAK;KACX,OAAKG,eAAA,CAAC,WAAS,EAAA,UACK,QAAA,eAAe,KAAK,GAAE,CAAA,CAAA;KACzC,gBAAc,KAAK;KACnB,OAAKC,eAAE,WAAW,IAAI,CAAA;;KAEX,QAAA,QAAZL,UAAA,GAAAC,mBAAqD,QAAA;;MAAnC,OAAM;MAAgB,GAAG,KAAK;;KAChDM,mBAAyC,QAAA;MAAnC,OAAM;MAAgB,GAAG,KAAK;;KACxB,KAAK,QAAjBP,UAAA,GAAAC,mBAA6D,QAAA;;MAAtC,OAAM;MAAgB,GAAG,KAAK;;KACrDM,mBAAwC,QAAA;MAAlC,OAAM;MAAe,GAAG,KAAK;;;G,WAG9B,QAAA,WAATP,UAAA,GAAAC,mBAGI,KAAA;;IAHc,OAAKG,eAAA,CAAC,2BAAyB,EAAA,SAAoB,QAAA,QAAQ,QAAO,CAAA,CAAA;IAAK,OAAKC,eAAE,WAAW,QAAA,OAAO,CAAA;G,IAC9GE,mBAA4C,QAAA;IAAtC,OAAM;IAAgB,GAAG,QAAA,QAAQ;G,yBAC3B,QAAA,QAAQ,QAApBP,UAAA,GAAAC,mBAAmE,QAAA;;IAAzC,OAAM;IAAgB,GAAG,QAAA,QAAQ"}
|
package/dist/sortable.js
CHANGED
|
@@ -102,7 +102,7 @@ function useSortable(container, options) {
|
|
|
102
102
|
});
|
|
103
103
|
function follow() {
|
|
104
104
|
if (!drag) return;
|
|
105
|
-
const pointer = (axis === "y" ? drag.last[1] : drag.last[0]) + scrollPos(drag.scroller) - drag.scroll0;
|
|
105
|
+
const pointer = (axis === "y" ? drag.last[1] : drag.last[0]) + (scrollPos(drag.scroller) - drag.scroll0) * drag.scale;
|
|
106
106
|
const { starts, sizes, from } = drag;
|
|
107
107
|
const last = starts.length - 1;
|
|
108
108
|
const min = starts[0] - starts[from];
|
|
@@ -113,7 +113,7 @@ function useSortable(container, options) {
|
|
|
113
113
|
drag.to = to;
|
|
114
114
|
const shifts = sortShifts(drag.els.length, drag.from, to, drag.step);
|
|
115
115
|
drag.els.forEach((el, i) => {
|
|
116
|
-
const value = i === drag.from ? offset : shifts[i];
|
|
116
|
+
const value = (i === drag.from ? offset : shifts[i]) / drag.scale;
|
|
117
117
|
el.style.transform = value ? axis === "y" ? `translateY(${value}px)` : `translateX(${value}px)` : "";
|
|
118
118
|
});
|
|
119
119
|
}
|
|
@@ -129,6 +129,8 @@ function useSortable(container, options) {
|
|
|
129
129
|
const scroller = scrollParent(container.value, axis);
|
|
130
130
|
const gap = els.length > 1 ? Math.max(0, along(rects[1]) - along(rects[0]) - sizeOf(rects[0])) : 0;
|
|
131
131
|
const step = sizeOf(rects[from]) + gap;
|
|
132
|
+
const css = axis === "y" ? els[from].offsetHeight : els[from].offsetWidth;
|
|
133
|
+
const scale = css > 0 && sizeOf(rects[from]) > 0 ? sizeOf(rects[from]) / css : 1;
|
|
132
134
|
drag = {
|
|
133
135
|
from,
|
|
134
136
|
to: from,
|
|
@@ -137,6 +139,7 @@ function useSortable(container, options) {
|
|
|
137
139
|
starts: rects.map(along),
|
|
138
140
|
sizes: rects.map(sizeOf),
|
|
139
141
|
step,
|
|
142
|
+
scale,
|
|
140
143
|
els,
|
|
141
144
|
handle,
|
|
142
145
|
pointerId: event.pointerId,
|
package/dist/sortable.js.map
CHANGED
|
@@ -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 // 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,MAAoB,MAAc,IAAiB;CAC3E,MAAM,OAAO,KAAK,MAAM;CACxB,IAAI,OAAO,KAAK,QAAQ,KAAK,QAAQ,OAAO;CAC5C,MAAM,CAAC,QAAQ,KAAK,OAAO,MAAM,CAAC;CAClC,KAAK,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC,GAAG,GAAG,IAAK;CAC5D,OAAO;AACX;AAUA,IAAa,kBAAiC;CAC1C,QAAQ;CACR,OAAO;CACP,SAAS;CACT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, 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 /** Screen px per CSS px of the list: 1 normally, the zoom when the list sits in a scaled canvas. / Экранных px на CSS-px списка: 1, а в масштабируемом холсте равно масштабу. */\n scale: 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 // the scrolled distance is in CSS px of the list, the pointer in screen px: bring them to one unit\n // прокрутка в CSS-px списка, указатель в экранных px: приводим к одной единице\n const pointer = (axis === 'y' ? drag.last[1] : drag.last[0]) + (scrollPos(drag.scroller) - drag.scroll0) * drag.scale;\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 // measured in screen px, drawn in the list's own px: in a scaled canvas the two differ by the zoom\n // считали в экранных px, рисуем в px самого списка: в масштабируемом холсте они различаются на масштаб\n const value = (i === drag!.from ? offset : shifts[i]!) / drag!.scale;\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 // a list inside a scaled ancestor (a zoomable canvas) is drawn smaller or larger than its CSS size\n // список внутри масштабированного предка (холст с зумом) нарисован меньше или больше своего CSS-размера\n const css = axis === 'y' ? els[from]!.offsetHeight : els[from]!.offsetWidth;\n const scale = css > 0 && sizeOf(rects[from]!) > 0 ? sizeOf(rects[from]!) / css : 1;\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 scale,\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,MAAoB,MAAc,IAAiB;CAC3E,MAAM,OAAO,KAAK,MAAM;CACxB,IAAI,OAAO,KAAK,QAAQ,KAAK,QAAQ,OAAO;CAC5C,MAAM,CAAC,QAAQ,KAAK,OAAO,MAAM,CAAC;CAClC,KAAK,OAAO,KAAK,IAAI,GAAG,KAAK,IAAI,IAAI,KAAK,MAAM,CAAC,GAAG,GAAG,IAAK;CAC5D,OAA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D,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
|
@@ -2,12 +2,17 @@
|
|
|
2
2
|
/*
|
|
3
3
|
* Variables, on the row or on any element around it (the defaults stand in var(), so an ancestor's value reaches here):
|
|
4
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:
|
|
6
|
-
* --tx-swipe-radius the corners of the row (
|
|
5
|
+
* the page: the page background colour)
|
|
6
|
+
* --tx-swipe-radius the corners of the row (12px)
|
|
7
7
|
* --tx-swipe-gap the gap between the end actions (6px)
|
|
8
|
+
* --tx-swipe-tone, --tx-swipe-tone-text, --tx-swipe-armed-text, --tx-swipe-accent
|
|
9
|
+
* the colour of an action (set on the action itself), its text, the text of an armed action and the
|
|
10
|
+
* focus ring; the TaoUI bridge maps them to the tone of the action
|
|
8
11
|
* Переменные — на строке или на любом элементе вокруг неё (значения по умолчанию стоят в var(), поэтому значение предка
|
|
9
12
|
* доходит сюда): --tx-swipe-bg — лицо строки и основа подкраски действий; --tx-swipe-radius — углы; --tx-swipe-gap —
|
|
10
|
-
* зазор между действиями
|
|
13
|
+
* зазор между действиями справа; --tx-swipe-tone, --tx-swipe-tone-text, --tx-swipe-armed-text, --tx-swipe-accent —
|
|
14
|
+
* цвет действия (задаётся на самом действии), его текст, текст сработавшего действия и кольцо фокуса; мост TaoUI
|
|
15
|
+
* наводит их на тон действия.
|
|
11
16
|
*/
|
|
12
17
|
.tx-swipe {
|
|
13
18
|
/* a stacking context of its own: the z-index of the face counts inside the row only, so a floating bar or a glass
|
|
@@ -16,8 +21,8 @@
|
|
|
16
21
|
списком остаются поверх его строк */
|
|
17
22
|
isolation: isolate;
|
|
18
23
|
--_tx-swipe-gap: var(--tx-swipe-gap, 6px);
|
|
19
|
-
--_tx-swipe-radius: var(--tx-swipe-radius,
|
|
20
|
-
--_tx-swipe-bg: var(--tx-swipe-bg,
|
|
24
|
+
--_tx-swipe-radius: var(--tx-swipe-radius, 12px);
|
|
25
|
+
--_tx-swipe-bg: var(--tx-swipe-bg, #1f1f1f);
|
|
21
26
|
position: relative;
|
|
22
27
|
overflow: hidden;
|
|
23
28
|
border-radius: var(--_tx-swipe-radius);
|
|
@@ -88,8 +93,8 @@
|
|
|
88
93
|
overflow: hidden;
|
|
89
94
|
border: 0;
|
|
90
95
|
border-radius: var(--_tx-swipe-radius);
|
|
91
|
-
background: color-mix(in srgb, var(--
|
|
92
|
-
color: var(--
|
|
96
|
+
background: color-mix(in srgb, var(--tx-swipe-tone, #9ca3af) 22%, var(--_tx-swipe-bg));
|
|
97
|
+
color: var(--tx-swipe-tone-text, #d1d5db);
|
|
93
98
|
font: inherit;
|
|
94
99
|
font-size: 13px;
|
|
95
100
|
cursor: pointer;
|
|
@@ -116,11 +121,11 @@
|
|
|
116
121
|
padding-inline-start: 22px;
|
|
117
122
|
}
|
|
118
123
|
.tx-swipe__action--armed {
|
|
119
|
-
background: color-mix(in srgb, var(--
|
|
120
|
-
color: var(--
|
|
124
|
+
background: color-mix(in srgb, var(--tx-swipe-tone, #9ca3af) 45%, var(--_tx-swipe-bg));
|
|
125
|
+
color: var(--tx-swipe-armed-text, #fff);
|
|
121
126
|
}
|
|
122
127
|
.tx-swipe__action:focus-visible {
|
|
123
|
-
outline: 2px solid var(--
|
|
128
|
+
outline: 2px solid var(--tx-swipe-accent, #4fc3f7);
|
|
124
129
|
outline-offset: -2px;
|
|
125
130
|
}
|
|
126
131
|
|