@1337exp/taoux 0.9.0 → 0.11.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/dist/curve.d.ts CHANGED
@@ -45,6 +45,13 @@ export interface LinkShape {
45
45
  * держать свой экранный размер при любом масштабе камеры `zoom`.
46
46
  */
47
47
  export declare function linkShape(a: Point, aSide: Side, b: Point, bSide: Side, arrow: Arrow, zoom: number): LinkShape;
48
+ /**
49
+ * A point on the curve of `linkShape` (the same Bezier, without the arrowhead trimming): `t` = 0 is the first pin, 1 the
50
+ * second, 0.5 the middle. A label on a link, a handle, a marker sit there.
51
+ * Точка на кривой `linkShape` (та же кривая Безье, без подрезки под наконечник): `t` = 0 первый пин, 1 второй, 0.5 середина.
52
+ * Там стоит подпись связи, ручка, маркер.
53
+ */
54
+ export declare function linkPointAt(a: Point, aSide: Side, b: Point, bSide: Side, t?: number): Point;
48
55
  /**
49
56
  * A cubic Bezier curve with horizontal tangents, as in Blueprint (for links "output on the right, input on the left").
50
57
  * Кубическая кривая Безье с горизонтальными касательными, как в Blueprint (для связей «выход справа, вход слева»).
package/dist/curve.js CHANGED
@@ -68,6 +68,23 @@ function linkShape(a, aSide, b, bSide, arrow, zoom) {
68
68
  };
69
69
  }
70
70
  /**
71
+ * A point on the curve of `linkShape` (the same Bezier, without the arrowhead trimming): `t` = 0 is the first pin, 1 the
72
+ * second, 0.5 the middle. A label on a link, a handle, a marker sit there.
73
+ * Точка на кривой `linkShape` (та же кривая Безье, без подрезки под наконечник): `t` = 0 первый пин, 1 второй, 0.5 середина.
74
+ * Там стоит подпись связи, ручка, маркер.
75
+ */
76
+ function linkPointAt(a, aSide, b, bSide, t = .5) {
77
+ const [ax, ay] = OUT[aSide];
78
+ const [bx, by] = OUT[bSide];
79
+ const ta = tension(aSide, a, b);
80
+ const tb = tension(bSide, a, b);
81
+ const c1 = [a[0] + ax * ta, a[1] + ay * ta];
82
+ const c2 = [b[0] + bx * tb, b[1] + by * tb];
83
+ const u = 1 - t;
84
+ const mix = (i) => u * u * u * a[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * b[i];
85
+ return [mix(0), mix(1)];
86
+ }
87
+ /**
71
88
  * A cubic Bezier curve with horizontal tangents, as in Blueprint (for links "output on the right, input on the left").
72
89
  * Кубическая кривая Безье с горизонтальными касательными, как в Blueprint (для связей «выход справа, вход слева»).
73
90
  */
@@ -76,6 +93,6 @@ function curvePath(x1, y1, x2, y2) {
76
93
  return `M ${x1} ${y1} C ${x1 + tension} ${y1}, ${x2 - tension} ${y2}, ${x2} ${y2}`;
77
94
  }
78
95
  //#endregion
79
- export { HEAD_MAX_PX, HEAD_MIN_PX, curvePath, headSizePx, linkShape };
96
+ export { HEAD_MAX_PX, HEAD_MIN_PX, curvePath, headSizePx, linkPointAt, linkShape };
80
97
 
81
98
  //# sourceMappingURL=curve.js.map
package/dist/curve.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"curve.js","names":[],"sources":["../src/curve.ts"],"sourcesContent":["/**\r\n * The side of the node a link pin sits on.\r\n * Сторона ноды, на которой сидит пин связи.\r\n */\r\nexport type Side = 'left' | 'right' | 'top' | 'bottom';\r\n/**\r\n * `end`: the arrowhead at the end of the link.\r\n * `end`: наконечник стрелки на конце связи.\r\n */\r\nexport type Arrow = 'none' | 'end';\r\n\r\ntype Point = readonly [number, number];\r\n\r\n/**\r\n * Where a pin on this side of the node points outwards.\r\n * Куда смотрит наружу пин на данной стороне ноды.\r\n */\r\nconst OUT: Record<Side, Point> = { left: [-1, 0], right: [1, 0], top: [0, -1], bottom: [0, 1] };\r\n\r\n/**\r\n * Arrowhead size on screen: the largest (at zoom 1 and closer) and the smallest (zoomed far out), px.\r\n * Размер наконечника стрелки на экране: крупнейший (при зуме 1 и ближе) и мельчайший (при сильном отдалении), px.\r\n */\r\nexport const HEAD_MAX_PX = 14;\r\nexport const HEAD_MIN_PX = 6;\r\n\r\n/**\r\n * Arrowhead size on screen at camera scale `zoom`. A constant 14 px looked huge next to shrunken nodes\r\n * (at zoom 0.2 a 48 px note is 10 px wide and the arrow took a third of it), so it shrinks smoothly\r\n * (the square root of the scale) but never below `HEAD_MIN_PX`, so the arrow stays readable.\r\n * Размер наконечника на экране при масштабе камеры `zoom`. Постоянные 14 px при отдалении выглядели огромными\r\n * рядом с уменьшившимися нодами (при зуме 0.2 заметка 48 px, и стрелка занимала треть её ширины), поэтому он\r\n * уменьшается плавно (корень из масштаба), но не мельче `HEAD_MIN_PX`, чтобы стрелка оставалась читаемой.\r\n */\r\nexport function headSizePx(zoom: number): number {\r\n return Math.min(HEAD_MAX_PX, Math.max(HEAD_MIN_PX, HEAD_MAX_PX * Math.sqrt(zoom)));\r\n}\r\nconst MIN_TENSION = 60;\r\n\r\nexport interface LinkShape {\r\n /**\r\n * The line path.\r\n * Путь линии.\r\n */\r\n d: string;\r\n /**\r\n * The arrowhead path (a filled triangle) or null if there is no arrow.\r\n * Путь наконечника (залитый треугольник) или null, если стрелки нет.\r\n */\r\n head: string | null;\r\n}\r\n\r\n/**\r\n * Control point offset: half the distance along the side's axis, but not less than a minimum.\r\n * Вынос контрольной точки: половина расстояния вдоль оси стороны, но не меньше минимума.\r\n */\r\nfunction tension(side: Side, a: Point, b: Point): number {\r\n const along = OUT[side][0] !== 0 ? Math.abs(b[0] - a[0]) : Math.abs(b[1] - a[1]);\r\n return Math.max(along * 0.5, MIN_TENSION);\r\n}\r\n\r\n/**\r\n * A Bezier curve between two pins: it leaves a pin outwards from the node (right from a right pin, up from a top one, etc.).\r\n * The arrowhead is drawn by hand, not as an SVG marker: the line is thin \"in screen pixels\", and the arrowhead must\r\n * keep its screen size at any camera scale `zoom`.\r\n * Кривая Безье между двумя пинами: из пина она выходит наружу ноды (вправо из правого, вверх из верхнего и т.д.).\r\n * Наконечник рисуем сами, а не маркером SVG: линия тонкая «в пикселях экрана», и наконечник должен\r\n * держать свой экранный размер при любом масштабе камеры `zoom`.\r\n */\r\nexport function linkShape(a: Point, aSide: Side, b: Point, bSide: Side, arrow: Arrow, zoom: number): LinkShape {\r\n const [ax, ay] = OUT[aSide];\r\n const [bx, by] = OUT[bSide];\r\n const ta = tension(aSide, a, b);\r\n const tb = tension(bSide, a, b);\r\n const c1: Point = [a[0] + ax * ta, a[1] + ay * ta];\r\n const c2: Point = [b[0] + bx * tb, b[1] + by * tb];\r\n\r\n if (arrow === 'none') {\r\n return { d: `M ${a[0]} ${a[1]} C ${c1[0]} ${c1[1]}, ${c2[0]} ${c2[1]}, ${b[0]} ${b[1]}`, head: null };\r\n }\r\n\r\n // The arrow points into the node, that is against the pin's \"outwards\". The line ends inside the arrowhead.\r\n // Стрелка смотрит в ноду, то есть против «наружу» пина. Линию заканчиваем внутри наконечника.\r\n const dx = -bx;\r\n const dy = -by;\r\n const size = headSizePx(zoom) / zoom; // in world units / в мировых единицах\r\n const end: Point = [b[0] - dx * size * 0.8, b[1] - dy * size * 0.8];\r\n const base: Point = [b[0] - dx * size, b[1] - dy * size];\r\n const half = size * 0.45;\r\n // The wings of the arrowhead are perpendicular to the direction.\r\n // Крылья наконечника перпендикулярны направлению.\r\n const px = -dy * half;\r\n const py = dx * half;\r\n\r\n return {\r\n d: `M ${a[0]} ${a[1]} C ${c1[0]} ${c1[1]}, ${c2[0]} ${c2[1]}, ${end[0]} ${end[1]}`,\r\n head: `M ${b[0]} ${b[1]} L ${base[0] + px} ${base[1] + py} L ${base[0] - px} ${base[1] - py} Z`,\r\n };\r\n}\r\n\r\n/**\r\n * A cubic Bezier curve with horizontal tangents, as in Blueprint (for links \"output on the right, input on the left\").\r\n * Кубическая кривая Безье с горизонтальными касательными, как в Blueprint (для связей «выход справа, вход слева»).\r\n */\r\nexport function curvePath(x1: number, y1: number, x2: number, y2: number): string {\r\n const tension = Math.max(Math.abs(x2 - x1) * 0.5, 60);\r\n return `M ${x1} ${y1} C ${x1 + tension} ${y1}, ${x2 - tension} ${y2}, ${x2} ${y2}`;\r\n}\r\n"],"mappings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C,MAAM,MAAa,CAAC,EAAE,KAAK,KAAK,OAAO,IAAK,EAAE,KAAK,KAAK,OAAO,EAAG;CAClE,MAAM,OAAc,CAAC,EAAE,KAAK,KAAK,MAAM,EAAE,KAAK,KAAK,IAAI;CACvD,MAAM,OAAO,OAAO;CAGpB,MAAM,KAAK,CAAC,KAAK;CACjB,MAAM,KAAK,KAAK;CAEhB,OAAO;EACH,GAAG,KAAK,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,GAAG,GAAG,GAAG,GAAG,GAAG,IAAI,IAAI,GAAG,GAAG,IAAI;EAC9E,MAAM,KAAK,EAAE,GAAG,GAAG,EAAE,GAAG,KAAK,KAAK,KAAK,GAAG,GAAG,KAAK,KAAK,GAAG,KAAK,KAAK,KAAK,GAAG,GAAG,KAAK,KAAK,GAAG;CAChG;AACJ;;;;;AAMA,SAAgB,UAAU,IAAY,IAAY,IAAY,IAAoB;CAC9E,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,IAAI,IAAK,EAAE;CACpD,OAAO,KAAK,GAAG,GAAG,GAAG,KAAK,KAAK,QAAQ,GAAG,GAAG,IAAI,KAAK,QAAQ,GAAG,GAAG,IAAI,GAAG,GAAG;AAClF"}
1
+ {"version":3,"file":"curve.js","names":[],"sources":["../src/curve.ts"],"sourcesContent":["/**\r\n * The side of the node a link pin sits on.\r\n * Сторона ноды, на которой сидит пин связи.\r\n */\r\nexport type Side = 'left' | 'right' | 'top' | 'bottom';\r\n/**\r\n * `end`: the arrowhead at the end of the link.\r\n * `end`: наконечник стрелки на конце связи.\r\n */\r\nexport type Arrow = 'none' | 'end';\r\n\r\ntype Point = readonly [number, number];\r\n\r\n/**\r\n * Where a pin on this side of the node points outwards.\r\n * Куда смотрит наружу пин на данной стороне ноды.\r\n */\r\nconst OUT: Record<Side, Point> = { left: [-1, 0], right: [1, 0], top: [0, -1], bottom: [0, 1] };\r\n\r\n/**\r\n * Arrowhead size on screen: the largest (at zoom 1 and closer) and the smallest (zoomed far out), px.\r\n * Размер наконечника стрелки на экране: крупнейший (при зуме 1 и ближе) и мельчайший (при сильном отдалении), px.\r\n */\r\nexport const HEAD_MAX_PX = 14;\r\nexport const HEAD_MIN_PX = 6;\r\n\r\n/**\r\n * Arrowhead size on screen at camera scale `zoom`. A constant 14 px looked huge next to shrunken nodes\r\n * (at zoom 0.2 a 48 px note is 10 px wide and the arrow took a third of it), so it shrinks smoothly\r\n * (the square root of the scale) but never below `HEAD_MIN_PX`, so the arrow stays readable.\r\n * Размер наконечника на экране при масштабе камеры `zoom`. Постоянные 14 px при отдалении выглядели огромными\r\n * рядом с уменьшившимися нодами (при зуме 0.2 заметка 48 px, и стрелка занимала треть её ширины), поэтому он\r\n * уменьшается плавно (корень из масштаба), но не мельче `HEAD_MIN_PX`, чтобы стрелка оставалась читаемой.\r\n */\r\nexport function headSizePx(zoom: number): number {\r\n return Math.min(HEAD_MAX_PX, Math.max(HEAD_MIN_PX, HEAD_MAX_PX * Math.sqrt(zoom)));\r\n}\r\nconst MIN_TENSION = 60;\r\n\r\nexport interface LinkShape {\r\n /**\r\n * The line path.\r\n * Путь линии.\r\n */\r\n d: string;\r\n /**\r\n * The arrowhead path (a filled triangle) or null if there is no arrow.\r\n * Путь наконечника (залитый треугольник) или null, если стрелки нет.\r\n */\r\n head: string | null;\r\n}\r\n\r\n/**\r\n * Control point offset: half the distance along the side's axis, but not less than a minimum.\r\n * Вынос контрольной точки: половина расстояния вдоль оси стороны, но не меньше минимума.\r\n */\r\nfunction tension(side: Side, a: Point, b: Point): number {\r\n const along = OUT[side][0] !== 0 ? Math.abs(b[0] - a[0]) : Math.abs(b[1] - a[1]);\r\n return Math.max(along * 0.5, MIN_TENSION);\r\n}\r\n\r\n/**\r\n * A Bezier curve between two pins: it leaves a pin outwards from the node (right from a right pin, up from a top one, etc.).\r\n * The arrowhead is drawn by hand, not as an SVG marker: the line is thin \"in screen pixels\", and the arrowhead must\r\n * keep its screen size at any camera scale `zoom`.\r\n * Кривая Безье между двумя пинами: из пина она выходит наружу ноды (вправо из правого, вверх из верхнего и т.д.).\r\n * Наконечник рисуем сами, а не маркером SVG: линия тонкая «в пикселях экрана», и наконечник должен\r\n * держать свой экранный размер при любом масштабе камеры `zoom`.\r\n */\r\nexport function linkShape(a: Point, aSide: Side, b: Point, bSide: Side, arrow: Arrow, zoom: number): LinkShape {\r\n const [ax, ay] = OUT[aSide];\r\n const [bx, by] = OUT[bSide];\r\n const ta = tension(aSide, a, b);\r\n const tb = tension(bSide, a, b);\r\n const c1: Point = [a[0] + ax * ta, a[1] + ay * ta];\r\n const c2: Point = [b[0] + bx * tb, b[1] + by * tb];\r\n\r\n if (arrow === 'none') {\r\n return { d: `M ${a[0]} ${a[1]} C ${c1[0]} ${c1[1]}, ${c2[0]} ${c2[1]}, ${b[0]} ${b[1]}`, head: null };\r\n }\r\n\r\n // The arrow points into the node, that is against the pin's \"outwards\". The line ends inside the arrowhead.\r\n // Стрелка смотрит в ноду, то есть против «наружу» пина. Линию заканчиваем внутри наконечника.\r\n const dx = -bx;\r\n const dy = -by;\r\n const size = headSizePx(zoom) / zoom; // in world units / в мировых единицах\r\n const end: Point = [b[0] - dx * size * 0.8, b[1] - dy * size * 0.8];\r\n const base: Point = [b[0] - dx * size, b[1] - dy * size];\r\n const half = size * 0.45;\r\n // The wings of the arrowhead are perpendicular to the direction.\r\n // Крылья наконечника перпендикулярны направлению.\r\n const px = -dy * half;\r\n const py = dx * half;\r\n\r\n return {\r\n d: `M ${a[0]} ${a[1]} C ${c1[0]} ${c1[1]}, ${c2[0]} ${c2[1]}, ${end[0]} ${end[1]}`,\r\n head: `M ${b[0]} ${b[1]} L ${base[0] + px} ${base[1] + py} L ${base[0] - px} ${base[1] - py} Z`,\r\n };\r\n}\r\n\r\n/**\r\n * A point on the curve of `linkShape` (the same Bezier, without the arrowhead trimming): `t` = 0 is the first pin, 1 the\r\n * second, 0.5 the middle. A label on a link, a handle, a marker sit there.\r\n * Точка на кривой `linkShape` (та же кривая Безье, без подрезки под наконечник): `t` = 0 первый пин, 1 второй, 0.5 середина.\r\n * Там стоит подпись связи, ручка, маркер.\r\n */\r\nexport function linkPointAt(a: Point, aSide: Side, b: Point, bSide: Side, t = 0.5): Point {\r\n const [ax, ay] = OUT[aSide];\r\n const [bx, by] = OUT[bSide];\r\n const ta = tension(aSide, a, b);\r\n const tb = tension(bSide, a, b);\r\n const c1: Point = [a[0] + ax * ta, a[1] + ay * ta];\r\n const c2: Point = [b[0] + bx * tb, b[1] + by * tb];\r\n const u = 1 - t;\r\n const mix = (i: 0 | 1) => u * u * u * a[i] + 3 * u * u * t * c1[i] + 3 * u * t * t * c2[i] + t * t * t * b[i];\r\n return [mix(0), mix(1)];\r\n}\r\n\r\n/**\r\n * A cubic Bezier curve with horizontal tangents, as in Blueprint (for links \"output on the right, input on the left\").\r\n * Кубическая кривая Безье с горизонтальными касательными, как в Blueprint (для связей «выход справа, вход слева»).\r\n */\r\nexport function curvePath(x1: number, y1: number, x2: number, y2: number): string {\r\n const tension = Math.max(Math.abs(x2 - x1) * 0.5, 60);\r\n return `M ${x1} ${y1} C ${x1 + tension} ${y1}, ${x2 - tension} ${y2}, ${x2} ${y2}`;\r\n}\r\n"],"mappings":";;;;;AAiBA,IAAM,MAA2B;CAAE,MAAM,CAAC,IAAI,CAAC;CAAG,OAAO,CAAC,GAAG,CAAC;CAAG,KAAK,CAAC,GAAG,EAAE;CAAG,QAAQ,CAAC,GAAG,CAAC;AAAE;;;;;AAM9F,IAAa,cAAc;AAC3B,IAAa,cAAc;;;;;;;;;AAU3B,SAAgB,WAAW,MAAsB;CAC7C,OAAO,KAAK,IAAA,IAAiB,KAAK,IAAA,GAAA,KAA+B,KAAK,KAAK,IAAI,CAAC,CAAC;AACrF;AACA,IAAM,cAAc;;;;;AAmBpB,SAAS,QAAQ,MAAY,GAAU,GAAkB;CACrD,MAAM,QAAQ,IAAI,KAAK,CAAC,OAAO,I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,GAAG,KAAK,KAAK,KAAK,GAAG,GAAG,KAAK,KAAK,GAAG,KAAK,KAAK,KAAK,GAAG,GAAG,KAAK,KAAK,GAAG;CAChG;AACJ;;;;;;;AAQA,SAAgB,YAAY,GAAU,OAAa,GAAU,OAAa,IAAI,IAAY;CACtF,MAAM,CAAC,IAAI,MAAM,IAAI;CACrB,MAAM,CAAC,IAAI,MAAM,IAAI;CACrB,MAAM,KAAK,QAAQ,OAAO,GAAG,CAAC;CAC9B,MAAM,KAAK,QAAQ,OAAO,GAAG,CAAC;CAC9B,MAAM,KAAY,CAAC,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE;CACjD,MAAM,KAAY,CAAC,EAAE,KAAK,KAAK,IAAI,EAAE,KAAK,KAAK,EAAE;CACjD,MAAM,IAAI,IAAI;CACd,MAAM,OAAO,MAAa,IAAI,IAAI,IAAI,EAAE,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,IAAI,GAAG,KAAK,IAAI,IAAI,IAAI,EAAE;CAC3G,OAAO,CAAC,IAAI,CAAC,GAAG,IAAI,CAAC,CAAC;AAC1B;;;;;AAMA,SAAgB,UAAU,IAAY,IAAY,IAAY,IAAoB;CAC9E,MAAM,UAAU,KAAK,IAAI,KAAK,IAAI,KAAK,EAAE,IAAI,IAAK,EAAE;CACpD,OAAO,KAAK,GAAG,GAAG,GAAG,KAAK,KAAK,QAAQ,GAAG,GAAG,IAAI,KAAK,QAAQ,GAAG,GAAG,IAAI,GAAG,GAAG;AAClF"}
@@ -42,6 +42,14 @@ type __VLS_Props = {
42
42
  * Подпись точки для скринридеров; по умолчанию «Point 1: t, v».
43
43
  */
44
44
  pointLabel?: (index: number, point: CurvePoint) => string;
45
+ /**
46
+ * How time is written: on the time axis, on the tag of the selected point and in the default point label. `t` is 0…1, the
47
+ * editor's own time; a curve over years or seconds says so here (`(t) => `${Math.round(t * 14)} y``). By default the number
48
+ * itself.
49
+ * Как записывается время: на оси времени, на метке выбранной точки и в подписи точки по умолчанию. `t` — от 0 до 1, собственное
50
+ * время редактора; кривая по годам или секундам говорит это здесь. По умолчанию само число.
51
+ */
52
+ formatT?: (t: number) => string;
45
53
  /**
46
54
  * Guides from the selected point to the axes: `off` none, `lines` dashed lines only, `values` lines and the point values on the axes.
47
55
  * `lines` by default: noticeable, but not overloaded.
@@ -1 +1 @@
1
- export { t as TaoxCurveEditor, n as addPoint, r as movePoint, i as removePoint, a as sampleCurve, o as sampleSegment, s as setEase, c as valueBounds } from "./chunks/curveeditor-F3XBWHPL.js";
1
+ export { t as TaoxCurveEditor, n as addPoint, r as movePoint, i as removePoint, a as sampleCurve, o as sampleSegment, s as setEase, c as valueBounds } from "./chunks/curveeditor-B1mAStQs.js";
@@ -48,6 +48,11 @@ type __VLS_Props = {
48
48
  */
49
49
  pointLabel?: (index: number, point: CurvePoint) => string;
50
50
  handleLabel?: (n: number, index: number) => string;
51
+ /**
52
+ * How the plot writes time (its axis and the tag of the selected point): see TaoxCurveEditor.
53
+ * Как график записывает время (ось и метка выбранной точки): см. TaoxCurveEditor.
54
+ */
55
+ formatT?: (t: number) => string;
51
56
  };
52
57
  declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
53
58
  "update:modelValue": (value: CurvePoint[]) => any;
@@ -1,50 +1,50 @@
1
1
 
2
- .tx-curve-field[data-v-0d1fd6e4] {
2
+ .tx-curve-field[data-v-839b1e19] {
3
3
  display: flex;
4
4
  flex-direction: column;
5
5
  gap: 8px;
6
6
  }
7
- .tx-curve-field__fields[data-v-0d1fd6e4] {
7
+ .tx-curve-field__fields[data-v-839b1e19] {
8
8
  display: grid;
9
9
  grid-template-columns: 1fr 1fr;
10
10
  gap: 8px;
11
11
  }
12
- .tx-curve-field__fields > label[data-v-0d1fd6e4] {
12
+ .tx-curve-field__fields > label[data-v-839b1e19] {
13
13
  display: flex;
14
14
  flex-direction: column;
15
15
  gap: 2px;
16
16
  color: var(--tx-curve-label, #8b929c);
17
17
  font-size: 11px;
18
18
  }
19
- .tx-curve-field__ease[data-v-0d1fd6e4] {
19
+ .tx-curve-field__ease[data-v-839b1e19] {
20
20
  display: flex;
21
21
  flex-direction: column;
22
22
  gap: 2px;
23
23
  }
24
- .tx-curve-field__title[data-v-0d1fd6e4] {
24
+ .tx-curve-field__title[data-v-839b1e19] {
25
25
  color: var(--tx-curve-label, #8b929c);
26
26
  font-size: 11px;
27
27
  }
28
28
 
29
29
  /* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */
30
- .tx-curve-field__ease-row[data-v-0d1fd6e4] {
30
+ .tx-curve-field__ease-row[data-v-839b1e19] {
31
31
  display: flex;
32
32
  align-items: center;
33
33
  gap: 6px;
34
34
  }
35
- .tx-curve-field__kind[data-v-0d1fd6e4] {
35
+ .tx-curve-field__kind[data-v-839b1e19] {
36
36
  flex: 1;
37
37
  min-width: 0;
38
38
  }
39
- .tx-curve-field__ease-row[data-v-0d1fd6e4] > :last-child {
39
+ .tx-curve-field__ease-row[data-v-839b1e19] > :last-child {
40
40
  flex: none;
41
41
  }
42
- .tx-curve-field__bar[data-v-0d1fd6e4] {
42
+ .tx-curve-field__bar[data-v-839b1e19] {
43
43
  display: flex;
44
44
  align-items: center;
45
45
  gap: 4px;
46
46
  font-size: 12px;
47
47
  }
48
- .tx-curve-field__spacer[data-v-0d1fd6e4] {
48
+ .tx-curve-field__spacer[data-v-839b1e19] {
49
49
  flex: 1;
50
50
  }
@@ -1,6 +1,6 @@
1
1
  import { clampTo, niceStep, roundTo } from "./num.js";
2
2
  import { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts } from "./ease.js";
3
- import { c as valueBounds, i as removePoint, r as movePoint, s as setEase, t as TaoxCurveEditor_default } from "./chunks/curveeditor-F3XBWHPL.js";
3
+ import { c as valueBounds, i as removePoint, r as movePoint, s as setEase, t as TaoxCurveEditor_default } from "./chunks/curveeditor-B1mAStQs.js";
4
4
  import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
5
5
  import { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from "@1337exp/taoui";
6
6
  //#region src/curvefield/TaoxCurveField.vue?vue&type=script&setup=true&lang.ts
@@ -29,7 +29,8 @@ var TaoxCurveField_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
29
29
  labels: {},
30
30
  guides: { default: "lines" },
31
31
  pointLabel: {},
32
- handleLabel: {}
32
+ handleLabel: {},
33
+ formatT: {}
33
34
  },
34
35
  emits: ["update:modelValue", "commit"],
35
36
  setup(__props, { emit: __emit }) {
@@ -130,6 +131,7 @@ var TaoxCurveField_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
130
131
  guides: __props.guides,
131
132
  "point-label": __props.pointLabel,
132
133
  "handle-label": __props.handleLabel,
134
+ "format-t": __props.formatT,
133
135
  "onUpdate:modelValue": change,
134
136
  onCommit: _cache[1] || (_cache[1] = ($event) => emit("commit"))
135
137
  }, null, 8, [
@@ -143,7 +145,8 @@ var TaoxCurveField_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ d
143
145
  "hint",
144
146
  "guides",
145
147
  "point-label",
146
- "handle-label"
148
+ "handle-label",
149
+ "format-t"
147
150
  ]),
148
151
  createElementVNode("div", _hoisted_2, [createElementVNode("label", null, [createTextVNode(toDisplayString(text.value.time), 1), createVNode(unref(TaoInputNumber), {
149
152
  size: "small",
@@ -245,7 +248,7 @@ var _plugin_vue_export_helper_default = (sfc, props) => {
245
248
  };
246
249
  //#endregion
247
250
  //#region src/curvefield/TaoxCurveField.vue
248
- var TaoxCurveField_default = /*#__PURE__*/ _plugin_vue_export_helper_default(TaoxCurveField_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-0d1fd6e4"]]);
251
+ var TaoxCurveField_default = /*#__PURE__*/ _plugin_vue_export_helper_default(TaoxCurveField_vue_vue_type_script_setup_true_lang_default, [["__scopeId", "data-v-839b1e19"]]);
249
252
  //#endregion
250
253
  export { TaoxCurveField_default as TaoxCurveField };
251
254
 
@@ -1 +1 @@
1
- {"version":3,"file":"curvefield.js","names":["_openBlock","_createElementBlock","_createVNode","_unref","TaoxCurveEditor","_createElementVNode","_createTextVNode","_toDisplayString","_withCtx","_Fragment","_renderList","_createBlock","_createCommentVNode","_sfc_main"],"sources":["../src/curvefield/TaoxCurveField.vue","../src/curvefield/TaoxCurveField.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\nimport { computed, ref } from 'vue';\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\nimport { clampTo, niceStep, roundTo } from '../num';\nimport type { CurveFieldLabels } from './labels';\n\n// A curve with fields: the plot (TaoxCurveEditor), the fields of the selected point, the transition to the next point, the grid step, remove and reset.\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\nconst props = withDefaults(\n defineProps<{\n /**\n * Curve points.\n * Точки кривой.\n */\n modelValue: readonly CurvePoint[];\n /**\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\n */\n min?: number;\n max?: number;\n /**\n * The \"default\" curve: without it there is no reset button.\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\n */\n defaultValue?: readonly CurvePoint[];\n /**\n * How many decimals to keep in time and value; not set means do not round.\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\n */\n precision?: number;\n /**\n * The time step of the grid and of the time field.\n * Шаг по времени у сетки и у поля времени.\n */\n stepT?: number;\n /**\n * Snapping to the grid at start.\n * Прилипание к сетке при старте.\n */\n snap?: boolean;\n /**\n * Labels in the app language; missing ones fall back to English.\n * Надписи на языке приложения; недостающие берутся английские.\n */\n labels?: Partial<CurveFieldLabels>;\n /**\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\n */\n guides?: CurveGuides;\n /**\n * Labels for screen readers: see TaoxCurveEditor.\n * Подписи для скринридеров: см. TaoxCurveEditor.\n */\n pointLabel?: (index: number, point: CurvePoint) => string;\n handleLabel?: (n: number, index: number) => string;\n }>(),\n { stepT: 0.05, snap: true, guides: 'lines' },\n);\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\n\nconst DEFAULT_LABELS: CurveFieldLabels = {\n time: 'Time',\n value: 'Value',\n transition: 'Transition to the next point',\n snap: 'Snap to grid',\n remove: 'Remove',\n reset: 'Reset',\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\n};\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\n\nconst selected = ref(0);\nconst snapOn = ref(props.snap);\n\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\nconst stepV = computed(() => {\n const b = valueBounds(points.value, props.min, props.max);\n return niceStep(b.max - b.min, 20);\n});\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\n\nfunction change(next: CurvePoint[]) {\n emit('update:modelValue', next);\n}\n\nfunction removeSelected() {\n change(removePoint(points.value, selected.value));\n selected.value = 0;\n emit('commit');\n}\n\nfunction setField(field: 't' | 'v', value: number | null) {\n if (value === null || !Number.isFinite(value)) return;\n const p = current.value;\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\n change(movePoint(points.value, selected.value, tt, v));\n emit('commit');\n}\n\nfunction reset() {\n if (props.defaultValue === undefined) return;\n selected.value = 0;\n change(props.defaultValue.map((p) => ({ ...p })));\n emit('commit');\n}\n\n//--------------------------------------------------\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\n\nconst isLast = computed(() => selected.value >= points.value.length - 1);\nconst kind = computed(() => {\n const e = current.value.ease;\n if (e === undefined || e === 'linear') return 'linear';\n if (typeof e === 'object') return 'bezier';\n return easeParts(e)?.family ?? e;\n});\nconst direction = computed<EaseDirection>(() => {\n const e = current.value.ease;\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\n});\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\n\nfunction applyEase(next: Ease) {\n change(setEase(points.value, selected.value, next));\n emit('commit');\n}\n\nfunction setKind(v: string | number | null) {\n if (typeof v !== 'string') return;\n if (v === 'linear' || v === 'step') applyEase(v);\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\n else applyEase(easeName(v as EaseFamily, direction.value));\n}\n\nfunction setDirection(v: unknown) {\n const e = current.value.ease;\n const parts = typeof e === 'string' ? easeParts(e) : null;\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\n}\n</script>\n\n<template>\n <div class=\"tx-curve-field\">\n <TaoxCurveEditor\n :model-value=\"points\"\n v-model:selected=\"selected\"\n :min=\"min\"\n :max=\"max\"\n :precision=\"precision\"\n :snap=\"snapOn\"\n :step-t=\"stepT\"\n :hint=\"text.hint\"\n :guides=\"guides\"\n :point-label=\"pointLabel\"\n :handle-label=\"handleLabel\"\n @update:model-value=\"change\"\n @commit=\"emit('commit')\"\n />\n\n <div class=\"tx-curve-field__fields\">\n <label>{{ text.time }}<TaoInputNumber size=\"small\" :min=\"0\" :max=\"1\" :step=\"stepT\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.t\" @update:model-value=\"(x) => setField('t', x)\" /></label>\n <label>{{ text.value }}<TaoInputNumber size=\"small\" :min=\"min\" :max=\"max\" :step=\"stepV\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.v\" @update:model-value=\"(x) => setField('v', x)\" /></label>\n </div>\n\n <div class=\"tx-curve-field__ease\">\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\n </TaoSegmented>\n </div>\n </div>\n\n <div class=\"tx-curve-field__bar\">\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\n <span class=\"tx-curve-field__spacer\" />\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\n </div>\n </div>\n</template>\n\n<style scoped>\n.tx-curve-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.tx-curve-field__fields {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n}\n\n.tx-curve-field__fields > label {\n display: flex;\n flex-direction: column;\n gap: 2px;\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n.tx-curve-field__ease {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.tx-curve-field__title {\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\n.tx-curve-field__ease-row {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.tx-curve-field__kind {\n flex: 1;\n min-width: 0;\n}\n\n.tx-curve-field__ease-row > :last-child {\n flex: none;\n}\n\n.tx-curve-field__bar {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n}\n\n.tx-curve-field__spacer {\n flex: 1;\n}\n</style>\n","<script lang=\"ts\" setup>\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\nimport { computed, ref } from 'vue';\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\nimport { clampTo, niceStep, roundTo } from '../num';\nimport type { CurveFieldLabels } from './labels';\n\n// A curve with fields: the plot (TaoxCurveEditor), the fields of the selected point, the transition to the next point, the grid step, remove and reset.\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\nconst props = withDefaults(\n defineProps<{\n /**\n * Curve points.\n * Точки кривой.\n */\n modelValue: readonly CurvePoint[];\n /**\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\n */\n min?: number;\n max?: number;\n /**\n * The \"default\" curve: without it there is no reset button.\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\n */\n defaultValue?: readonly CurvePoint[];\n /**\n * How many decimals to keep in time and value; not set means do not round.\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\n */\n precision?: number;\n /**\n * The time step of the grid and of the time field.\n * Шаг по времени у сетки и у поля времени.\n */\n stepT?: number;\n /**\n * Snapping to the grid at start.\n * Прилипание к сетке при старте.\n */\n snap?: boolean;\n /**\n * Labels in the app language; missing ones fall back to English.\n * Надписи на языке приложения; недостающие берутся английские.\n */\n labels?: Partial<CurveFieldLabels>;\n /**\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\n */\n guides?: CurveGuides;\n /**\n * Labels for screen readers: see TaoxCurveEditor.\n * Подписи для скринридеров: см. TaoxCurveEditor.\n */\n pointLabel?: (index: number, point: CurvePoint) => string;\n handleLabel?: (n: number, index: number) => string;\n }>(),\n { stepT: 0.05, snap: true, guides: 'lines' },\n);\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\n\nconst DEFAULT_LABELS: CurveFieldLabels = {\n time: 'Time',\n value: 'Value',\n transition: 'Transition to the next point',\n snap: 'Snap to grid',\n remove: 'Remove',\n reset: 'Reset',\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\n};\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\n\nconst selected = ref(0);\nconst snapOn = ref(props.snap);\n\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\nconst stepV = computed(() => {\n const b = valueBounds(points.value, props.min, props.max);\n return niceStep(b.max - b.min, 20);\n});\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\n\nfunction change(next: CurvePoint[]) {\n emit('update:modelValue', next);\n}\n\nfunction removeSelected() {\n change(removePoint(points.value, selected.value));\n selected.value = 0;\n emit('commit');\n}\n\nfunction setField(field: 't' | 'v', value: number | null) {\n if (value === null || !Number.isFinite(value)) return;\n const p = current.value;\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\n change(movePoint(points.value, selected.value, tt, v));\n emit('commit');\n}\n\nfunction reset() {\n if (props.defaultValue === undefined) return;\n selected.value = 0;\n change(props.defaultValue.map((p) => ({ ...p })));\n emit('commit');\n}\n\n//--------------------------------------------------\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\n\nconst isLast = computed(() => selected.value >= points.value.length - 1);\nconst kind = computed(() => {\n const e = current.value.ease;\n if (e === undefined || e === 'linear') return 'linear';\n if (typeof e === 'object') return 'bezier';\n return easeParts(e)?.family ?? e;\n});\nconst direction = computed<EaseDirection>(() => {\n const e = current.value.ease;\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\n});\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\n\nfunction applyEase(next: Ease) {\n change(setEase(points.value, selected.value, next));\n emit('commit');\n}\n\nfunction setKind(v: string | number | null) {\n if (typeof v !== 'string') return;\n if (v === 'linear' || v === 'step') applyEase(v);\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\n else applyEase(easeName(v as EaseFamily, direction.value));\n}\n\nfunction setDirection(v: unknown) {\n const e = current.value.ease;\n const parts = typeof e === 'string' ? easeParts(e) : null;\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\n}\n</script>\n\n<template>\n <div class=\"tx-curve-field\">\n <TaoxCurveEditor\n :model-value=\"points\"\n v-model:selected=\"selected\"\n :min=\"min\"\n :max=\"max\"\n :precision=\"precision\"\n :snap=\"snapOn\"\n :step-t=\"stepT\"\n :hint=\"text.hint\"\n :guides=\"guides\"\n :point-label=\"pointLabel\"\n :handle-label=\"handleLabel\"\n @update:model-value=\"change\"\n @commit=\"emit('commit')\"\n />\n\n <div class=\"tx-curve-field__fields\">\n <label>{{ text.time }}<TaoInputNumber size=\"small\" :min=\"0\" :max=\"1\" :step=\"stepT\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.t\" @update:model-value=\"(x) => setField('t', x)\" /></label>\n <label>{{ text.value }}<TaoInputNumber size=\"small\" :min=\"min\" :max=\"max\" :step=\"stepV\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.v\" @update:model-value=\"(x) => setField('v', x)\" /></label>\n </div>\n\n <div class=\"tx-curve-field__ease\">\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\n </TaoSegmented>\n </div>\n </div>\n\n <div class=\"tx-curve-field__bar\">\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\n <span class=\"tx-curve-field__spacer\" />\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\n </div>\n </div>\n</template>\n\n<style scoped>\n.tx-curve-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.tx-curve-field__fields {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n}\n\n.tx-curve-field__fields > label {\n display: flex;\n flex-direction: column;\n gap: 2px;\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n.tx-curve-field__ease {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.tx-curve-field__title {\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\n.tx-curve-field__ease-row {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.tx-curve-field__kind {\n flex: 1;\n min-width: 0;\n}\n\n.tx-curve-field__ease-row > :last-child {\n flex: none;\n}\n\n.tx-curve-field__bar {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n}\n\n.tx-curve-field__spacer {\n flex: 1;\n}\n</style>\n"],"mappings":";;;;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,gBAAAC,gBAAA,KAAA,MAAK,KAAK,GAAA,CAAA,C"}
1
+ {"version":3,"file":"curvefield.js","names":["_openBlock","_createElementBlock","_createVNode","_unref","TaoxCurveEditor","_createElementVNode","_createTextVNode","_toDisplayString","_withCtx","_Fragment","_renderList","_createBlock","_createCommentVNode","_sfc_main"],"sources":["../src/curvefield/TaoxCurveField.vue","../src/curvefield/TaoxCurveField.vue"],"sourcesContent":["<script lang=\"ts\" setup>\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\nimport { computed, ref } from 'vue';\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\nimport { clampTo, niceStep, roundTo } from '../num';\nimport type { CurveFieldLabels } from './labels';\n\n// A curve with fields: the plot (TaoxCurveEditor), the fields of the selected point, the transition to the next point, the grid step, remove and reset.\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\nconst props = withDefaults(\n defineProps<{\n /**\n * Curve points.\n * Точки кривой.\n */\n modelValue: readonly CurvePoint[];\n /**\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\n */\n min?: number;\n max?: number;\n /**\n * The \"default\" curve: without it there is no reset button.\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\n */\n defaultValue?: readonly CurvePoint[];\n /**\n * How many decimals to keep in time and value; not set means do not round.\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\n */\n precision?: number;\n /**\n * The time step of the grid and of the time field.\n * Шаг по времени у сетки и у поля времени.\n */\n stepT?: number;\n /**\n * Snapping to the grid at start.\n * Прилипание к сетке при старте.\n */\n snap?: boolean;\n /**\n * Labels in the app language; missing ones fall back to English.\n * Надписи на языке приложения; недостающие берутся английские.\n */\n labels?: Partial<CurveFieldLabels>;\n /**\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\n */\n guides?: CurveGuides;\n /**\n * Labels for screen readers: see TaoxCurveEditor.\n * Подписи для скринридеров: см. TaoxCurveEditor.\n */\n pointLabel?: (index: number, point: CurvePoint) => string;\n handleLabel?: (n: number, index: number) => string;\n /**\n * How the plot writes time (its axis and the tag of the selected point): see TaoxCurveEditor.\n * Как график записывает время (ось и метка выбранной точки): см. TaoxCurveEditor.\n */\n formatT?: (t: number) => string;\n }>(),\n { stepT: 0.05, snap: true, guides: 'lines' },\n);\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\n\nconst DEFAULT_LABELS: CurveFieldLabels = {\n time: 'Time',\n value: 'Value',\n transition: 'Transition to the next point',\n snap: 'Snap to grid',\n remove: 'Remove',\n reset: 'Reset',\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\n};\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\n\nconst selected = ref(0);\nconst snapOn = ref(props.snap);\n\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\nconst stepV = computed(() => {\n const b = valueBounds(points.value, props.min, props.max);\n return niceStep(b.max - b.min, 20);\n});\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\n\nfunction change(next: CurvePoint[]) {\n emit('update:modelValue', next);\n}\n\nfunction removeSelected() {\n change(removePoint(points.value, selected.value));\n selected.value = 0;\n emit('commit');\n}\n\nfunction setField(field: 't' | 'v', value: number | null) {\n if (value === null || !Number.isFinite(value)) return;\n const p = current.value;\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\n change(movePoint(points.value, selected.value, tt, v));\n emit('commit');\n}\n\nfunction reset() {\n if (props.defaultValue === undefined) return;\n selected.value = 0;\n change(props.defaultValue.map((p) => ({ ...p })));\n emit('commit');\n}\n\n//--------------------------------------------------\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\n\nconst isLast = computed(() => selected.value >= points.value.length - 1);\nconst kind = computed(() => {\n const e = current.value.ease;\n if (e === undefined || e === 'linear') return 'linear';\n if (typeof e === 'object') return 'bezier';\n return easeParts(e)?.family ?? e;\n});\nconst direction = computed<EaseDirection>(() => {\n const e = current.value.ease;\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\n});\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\n\nfunction applyEase(next: Ease) {\n change(setEase(points.value, selected.value, next));\n emit('commit');\n}\n\nfunction setKind(v: string | number | null) {\n if (typeof v !== 'string') return;\n if (v === 'linear' || v === 'step') applyEase(v);\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\n else applyEase(easeName(v as EaseFamily, direction.value));\n}\n\nfunction setDirection(v: unknown) {\n const e = current.value.ease;\n const parts = typeof e === 'string' ? easeParts(e) : null;\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\n}\n</script>\n\n<template>\n <div class=\"tx-curve-field\">\n <TaoxCurveEditor\n :model-value=\"points\"\n v-model:selected=\"selected\"\n :min=\"min\"\n :max=\"max\"\n :precision=\"precision\"\n :snap=\"snapOn\"\n :step-t=\"stepT\"\n :hint=\"text.hint\"\n :guides=\"guides\"\n :point-label=\"pointLabel\"\n :handle-label=\"handleLabel\"\n :format-t=\"formatT\"\n @update:model-value=\"change\"\n @commit=\"emit('commit')\"\n />\n\n <div class=\"tx-curve-field__fields\">\n <label>{{ text.time }}<TaoInputNumber size=\"small\" :min=\"0\" :max=\"1\" :step=\"stepT\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.t\" @update:model-value=\"(x) => setField('t', x)\" /></label>\n <label>{{ text.value }}<TaoInputNumber size=\"small\" :min=\"min\" :max=\"max\" :step=\"stepV\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.v\" @update:model-value=\"(x) => setField('v', x)\" /></label>\n </div>\n\n <div class=\"tx-curve-field__ease\">\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\n </TaoSegmented>\n </div>\n </div>\n\n <div class=\"tx-curve-field__bar\">\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\n <span class=\"tx-curve-field__spacer\" />\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\n </div>\n </div>\n</template>\n\n<style scoped>\n.tx-curve-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.tx-curve-field__fields {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n}\n\n.tx-curve-field__fields > label {\n display: flex;\n flex-direction: column;\n gap: 2px;\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n.tx-curve-field__ease {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.tx-curve-field__title {\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\n.tx-curve-field__ease-row {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.tx-curve-field__kind {\n flex: 1;\n min-width: 0;\n}\n\n.tx-curve-field__ease-row > :last-child {\n flex: none;\n}\n\n.tx-curve-field__bar {\n display: flex;\n align-items: center;\n gap: 4px;\n font-size: 12px;\n}\n\n.tx-curve-field__spacer {\n flex: 1;\n}\n</style>\n","<script lang=\"ts\" setup>\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\nimport { computed, ref } from 'vue';\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\nimport { clampTo, niceStep, roundTo } from '../num';\nimport type { CurveFieldLabels } from './labels';\n\n// A curve with fields: the plot (TaoxCurveEditor), the fields of the selected point, the transition to the next point, the grid step, remove and reset.\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\nconst props = withDefaults(\n defineProps<{\n /**\n * Curve points.\n * Точки кривой.\n */\n modelValue: readonly CurvePoint[];\n /**\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\n */\n min?: number;\n max?: number;\n /**\n * The \"default\" curve: without it there is no reset button.\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\n */\n defaultValue?: readonly CurvePoint[];\n /**\n * How many decimals to keep in time and value; not set means do not round.\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\n */\n precision?: number;\n /**\n * The time step of the grid and of the time field.\n * Шаг по времени у сетки и у поля времени.\n */\n stepT?: number;\n /**\n * Snapping to the grid at start.\n * Прилипание к сетке при старте.\n */\n snap?: boolean;\n /**\n * Labels in the app language; missing ones fall back to English.\n * Надписи на языке приложения; недостающие берутся английские.\n */\n labels?: Partial<CurveFieldLabels>;\n /**\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\n */\n guides?: CurveGuides;\n /**\n * Labels for screen readers: see TaoxCurveEditor.\n * Подписи для скринридеров: см. TaoxCurveEditor.\n */\n pointLabel?: (index: number, point: CurvePoint) => string;\n handleLabel?: (n: number, index: number) => string;\n /**\n * How the plot writes time (its axis and the tag of the selected point): see TaoxCurveEditor.\n * Как график записывает время (ось и метка выбранной точки): см. TaoxCurveEditor.\n */\n formatT?: (t: number) => string;\n }>(),\n { stepT: 0.05, snap: true, guides: 'lines' },\n);\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\n\nconst DEFAULT_LABELS: CurveFieldLabels = {\n time: 'Time',\n value: 'Value',\n transition: 'Transition to the next point',\n snap: 'Snap to grid',\n remove: 'Remove',\n reset: 'Reset',\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\n};\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\n\nconst selected = ref(0);\nconst snapOn = ref(props.snap);\n\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\nconst stepV = computed(() => {\n const b = valueBounds(points.value, props.min, props.max);\n return niceStep(b.max - b.min, 20);\n});\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\n\nfunction change(next: CurvePoint[]) {\n emit('update:modelValue', next);\n}\n\nfunction removeSelected() {\n change(removePoint(points.value, selected.value));\n selected.value = 0;\n emit('commit');\n}\n\nfunction setField(field: 't' | 'v', value: number | null) {\n if (value === null || !Number.isFinite(value)) return;\n const p = current.value;\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\n change(movePoint(points.value, selected.value, tt, v));\n emit('commit');\n}\n\nfunction reset() {\n if (props.defaultValue === undefined) return;\n selected.value = 0;\n change(props.defaultValue.map((p) => ({ ...p })));\n emit('commit');\n}\n\n//--------------------------------------------------\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\n\nconst isLast = computed(() => selected.value >= points.value.length - 1);\nconst kind = computed(() => {\n const e = current.value.ease;\n if (e === undefined || e === 'linear') return 'linear';\n if (typeof e === 'object') return 'bezier';\n return easeParts(e)?.family ?? e;\n});\nconst direction = computed<EaseDirection>(() => {\n const e = current.value.ease;\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\n});\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\n\nfunction applyEase(next: Ease) {\n change(setEase(points.value, selected.value, next));\n emit('commit');\n}\n\nfunction setKind(v: string | number | null) {\n if (typeof v !== 'string') return;\n if (v === 'linear' || v === 'step') applyEase(v);\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\n else applyEase(easeName(v as EaseFamily, direction.value));\n}\n\nfunction setDirection(v: unknown) {\n const e = current.value.ease;\n const parts = typeof e === 'string' ? easeParts(e) : null;\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\n}\n</script>\n\n<template>\n <div class=\"tx-curve-field\">\n <TaoxCurveEditor\n :model-value=\"points\"\n v-model:selected=\"selected\"\n :min=\"min\"\n :max=\"max\"\n :precision=\"precision\"\n :snap=\"snapOn\"\n :step-t=\"stepT\"\n :hint=\"text.hint\"\n :guides=\"guides\"\n :point-label=\"pointLabel\"\n :handle-label=\"handleLabel\"\n :format-t=\"formatT\"\n @update:model-value=\"change\"\n @commit=\"emit('commit')\"\n />\n\n <div class=\"tx-curve-field__fields\">\n <label>{{ text.time }}<TaoInputNumber size=\"small\" :min=\"0\" :max=\"1\" :step=\"stepT\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.t\" @update:model-value=\"(x) => setField('t', x)\" /></label>\n <label>{{ text.value }}<TaoInputNumber size=\"small\" :min=\"min\" :max=\"max\" :step=\"stepV\" :precision=\"precision\" :controls=\"false\" :model-value=\"current.v\" @update:model-value=\"(x) => setField('v', x)\" /></label>\n </div>\n\n <div class=\"tx-curve-field__ease\">\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\n </TaoSegmented>\n </div>\n </div>\n\n <div class=\"tx-curve-field__bar\">\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\n <span class=\"tx-curve-field__spacer\" />\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\n </div>\n </div>\n</template>\n\n<style scoped>\n.tx-curve-field {\n display: flex;\n flex-direction: column;\n gap: 8px;\n}\n\n.tx-curve-field__fields {\n display: grid;\n grid-template-columns: 1fr 1fr;\n gap: 8px;\n}\n\n.tx-curve-field__fields > label {\n display: flex;\n flex-direction: column;\n gap: 2px;\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n.tx-curve-field__ease {\n display: flex;\n flex-direction: column;\n gap: 2px;\n}\n\n.tx-curve-field__title {\n color: var(--tx-curve-label, #8b929c);\n font-size: 11px;\n}\n\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\n.tx-curve-field__ease-row {\n display: flex;\n align-items: center;\n gap: 6px;\n}\n\n.tx-curve-field__kind {\n flex: 1;\n min-width: 0;\n}\n\n.tx-curve-field__ease-row > :last-child {\n flex: none;\n}\n\n.tx-curve-field__bar {\n display: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IR,MAAA,SAAA,GAAA;;MAA9F,MAAK;MAAQ,SAAQ;MAAS,UAAQ,CAAG,SAAA;MAAW,SAAO;;MAAO,SAAAK,cAAgB,CAAbF,gBAAAC,gBAAA,KAAA,MAAK,KAAK,GAAA,CAAA,C"}
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Smart guides for dragging on a canvas (as in Figma and Miro): while a rectangle is dragged, its edges and its centre
3
+ * are compared with the edges and centres of the other rectangles; when two coincide (or are within the threshold) the
4
+ * rectangle is pulled so that they do, and a thin line is drawn through them.
5
+ * The module only counts: where the rectangle goes (`dx`, `dy`) and which lines to draw. Collecting the rectangles of the
6
+ * other nodes, applying the shift and drawing are the app's business. Plain numbers, no DOM, no Vue.
7
+ *
8
+ * Умные направляющие при перетаскивании по холсту (как в Figma и Miro): пока прямоугольник тащат, его края и центр
9
+ * сравниваются с краями и центрами остальных прямоугольников; когда два значения совпали (или ближе порога), прямоугольник
10
+ * притягивается так, чтобы они совпали, и через них рисуется тонкая линия.
11
+ * Модуль только считает: куда сдвинуть прямоугольник (`dx`, `dy`) и какие линии нарисовать. Собрать прямоугольники других
12
+ * нод, применить сдвиг и нарисовать — забота приложения. Просто числа, без DOM и Vue.
13
+ */
14
+ export interface GuideRect {
15
+ x: number;
16
+ y: number;
17
+ w: number;
18
+ h: number;
19
+ }
20
+ /**
21
+ * A guide line. `axis: 'x'` is a vertical line at `x = at` that runs from `from` to `to` in y; `axis: 'y'` is a
22
+ * horizontal line at `y = at` that runs from `from` to `to` in x.
23
+ * Линия-направляющая. `axis: 'x'` — вертикальная линия при `x = at` от `from` до `to` по y; `axis: 'y'` — горизонтальная
24
+ * при `y = at` от `from` до `to` по x.
25
+ */
26
+ export interface GuideLine {
27
+ axis: 'x' | 'y';
28
+ at: number;
29
+ from: number;
30
+ to: number;
31
+ }
32
+ export interface GuideResult {
33
+ /** How far to shift the rectangle in x so that it lies on a guide; 0 when there is none. / Сдвиг по x, 0 если направляющей нет. */
34
+ dx: number;
35
+ dy: number;
36
+ /** What to draw, for the rectangle already shifted by `dx`, `dy`. / Что рисовать для уже сдвинутого прямоугольника. */
37
+ lines: GuideLine[];
38
+ }
39
+ export interface GuideOptions {
40
+ /** Compare edges (left / right, top / bottom). Default true. / Сравнивать края. По умолчанию true. */
41
+ edges?: boolean;
42
+ /** Compare centres. Default true. / Сравнивать центры. По умолчанию true. */
43
+ centers?: boolean;
44
+ }
45
+ /**
46
+ * Where a dragged rectangle goes and which guide lines to draw. `threshold` is in the units of the rectangles (world
47
+ * units; for a screen threshold divide by the zoom). Each axis is decided on its own: the rectangle may stick to a
48
+ * vertical guide and move freely along y. A rectangle exactly on a guide (distance 0) gets its line too.
49
+ * Куда встаёт тащимый прямоугольник и какие линии рисовать. `threshold` в единицах прямоугольников (мировых; экранный
50
+ * порог делится на масштаб). Каждая ось решается сама по себе: прямоугольник может прилипнуть к вертикальной
51
+ * направляющей и свободно ехать по y. Прямоугольник, стоящий точно на направляющей (расстояние 0), тоже получает линию.
52
+ */
53
+ export declare function snapToGuides(moving: GuideRect, others: readonly GuideRect[], threshold: number, options?: GuideOptions): GuideResult;
package/dist/guides.js ADDED
@@ -0,0 +1,83 @@
1
+ //#region src/guides.ts
2
+ /** Two values this close count as the same line (float noise). / Значения ближе этого считаются одной линией. */
3
+ var SAME = 1e-6;
4
+ var pos = (axis, r) => axis === "x" ? r.x : r.y;
5
+ var size = (axis, r) => axis === "x" ? r.w : r.h;
6
+ var other = (axis) => axis === "x" ? "y" : "x";
7
+ /** The comparable positions of a rectangle along an axis: edges and centre. / Сравниваемые положения вдоль оси: края и центр. */
8
+ function marks(axis, r, options) {
9
+ const start = pos(axis, r);
10
+ const out = [];
11
+ if (options.edges !== false) out.push(start, start + size(axis, r));
12
+ if (options.centers !== false) out.push(start + size(axis, r) / 2);
13
+ return out;
14
+ }
15
+ /** The shift along one axis that puts the nearest pair of marks together; 0 when none is within the threshold. */
16
+ function shiftAlong(axis, moving, others, threshold, options) {
17
+ const mine = marks(axis, moving, options);
18
+ let best = Infinity;
19
+ for (const o of others) for (const t of marks(axis, o, options)) for (const m of mine) {
20
+ const d = t - m;
21
+ if (Math.abs(d) < Math.abs(best)) best = d;
22
+ }
23
+ return Math.abs(best) <= threshold ? best : 0;
24
+ }
25
+ /**
26
+ * The lines on one axis for a rectangle that is already in its final place: every pair of marks that coincides makes a
27
+ * line, and several rectangles on one line share it (it runs from the first to the last of them).
28
+ * Линии по одной оси для прямоугольника, уже стоящего на итоговом месте: каждая совпавшая пара даёт линию, а несколько
29
+ * прямоугольников на одной линии делят её (она идёт от первого до последнего).
30
+ */
31
+ function linesAlong(axis, rect, others, options) {
32
+ const cross = other(axis);
33
+ const mine = marks(axis, rect, options);
34
+ const lines = /* @__PURE__ */ new Map();
35
+ for (const o of others) for (const t of marks(axis, o, options)) {
36
+ if (!mine.some((m) => Math.abs(m - t) <= SAME)) continue;
37
+ const from = Math.min(pos(cross, rect), pos(cross, o));
38
+ const to = Math.max(pos(cross, rect) + size(cross, rect), pos(cross, o) + size(cross, o));
39
+ const key = Math.round(t / SAME);
40
+ const line = lines.get(key);
41
+ if (line) {
42
+ line.from = Math.min(line.from, from);
43
+ line.to = Math.max(line.to, to);
44
+ } else lines.set(key, {
45
+ axis,
46
+ at: t,
47
+ from,
48
+ to
49
+ });
50
+ }
51
+ return [...lines.values()];
52
+ }
53
+ /**
54
+ * Where a dragged rectangle goes and which guide lines to draw. `threshold` is in the units of the rectangles (world
55
+ * units; for a screen threshold divide by the zoom). Each axis is decided on its own: the rectangle may stick to a
56
+ * vertical guide and move freely along y. A rectangle exactly on a guide (distance 0) gets its line too.
57
+ * Куда встаёт тащимый прямоугольник и какие линии рисовать. `threshold` в единицах прямоугольников (мировых; экранный
58
+ * порог делится на масштаб). Каждая ось решается сама по себе: прямоугольник может прилипнуть к вертикальной
59
+ * направляющей и свободно ехать по y. Прямоугольник, стоящий точно на направляющей (расстояние 0), тоже получает линию.
60
+ */
61
+ function snapToGuides(moving, others, threshold, options = {}) {
62
+ if (others.length === 0 || !(threshold >= 0)) return {
63
+ dx: 0,
64
+ dy: 0,
65
+ lines: []
66
+ };
67
+ const dx = shiftAlong("x", moving, others, threshold, options);
68
+ const dy = shiftAlong("y", moving, others, threshold, options);
69
+ const fin = {
70
+ ...moving,
71
+ x: moving.x + dx,
72
+ y: moving.y + dy
73
+ };
74
+ return {
75
+ dx,
76
+ dy,
77
+ lines: [...linesAlong("x", fin, others, options), ...linesAlong("y", fin, others, options)]
78
+ };
79
+ }
80
+ //#endregion
81
+ export { snapToGuides };
82
+
83
+ //# sourceMappingURL=guides.js.map
@@ -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,I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M,KAAK,KAAK,IAAI,IAAI,OAAO,IAAI,IAAI,KAAK,OAAO,IAAI,GAAG,IAAI,OAAO,CAAC,IAAI,KAAK,OAAO,CAAC,CAAC;EACxF,MAAM,MAAM,KAAK,MAAM,IAAI,IAAI;EAC/B,MAAM,OAAO,MAAM,IAAI,GAAG;EAC1B,IAAI,MAAM;GACN,KAAK,OAAO,KAAK,IAAI,KAAK,MAAM,IAAI;GACpC,KAAK,KAAK,KAAK,IAAI,KAAK,IAAI,EAAE;EAClC,OACI,MAAM,IAAI,KAAK;GAAE;GAAM,IAAI;GAAG;GAAM;EAAG,CAAC;CAEhD;CAEJ,OAAO,CAAC,GAAG,MAAM,OAAO,CAAC;AAC7B;;;;;;;;;AAUA,SAAgB,aAAa,QAAmB,QAA8B,WAAmB,UAAwB,CAAC,GAAgB;CACtI,IAAI,OAAO,WAAW,KAAK,EAAE,aAAa,IAAI,OAAO;EAAE,IAAI;EAAG,IAAI;EAAG,OAAO,CAAC;CAAE;CAE/E,MAAM,KAAK,WAAW,KAAK,QAAQ,QAAQ,WAAW,OAAO;CAC7D,MAAM,KAAK,WAAW,KAAK,QAAQ,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
- .tx-link-head {
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"}