@1337exp/taoux 0.0.0-stage → 0.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +27 -0
- package/LICENSE +21 -0
- package/README.md +137 -2
- package/README.ru.md +140 -0
- package/dist/camera.d.ts +22 -0
- package/dist/camera.js +38 -0
- package/dist/camera.js.map +1 -0
- package/dist/canvas/TaoxCanvas.vue.d.ts +37 -0
- package/dist/canvas/host.d.ts +138 -0
- package/dist/canvas/index.d.ts +3 -0
- package/dist/canvas/useCanvasGestures.d.ts +44 -0
- package/dist/canvas.css +55 -0
- package/dist/canvas.js +696 -0
- package/dist/canvas.js.map +1 -0
- package/dist/chunks/curveeditor-F3XBWHPL.js +759 -0
- package/dist/chunks/curveeditor-F3XBWHPL.js.map +1 -0
- package/dist/curve.d.ts +53 -0
- package/dist/curve.js +81 -0
- package/dist/curve.js.map +1 -0
- package/dist/curveeditor/TaoxCurveEditor.vue.d.ts +74 -0
- package/dist/curveeditor/index.d.ts +3 -0
- package/dist/curveeditor/ops.d.ts +63 -0
- package/dist/curveeditor.css +115 -0
- package/dist/curveeditor.js +1 -0
- package/dist/curvefield/TaoxCurveField.vue.d.ts +64 -0
- package/dist/curvefield/index.d.ts +2 -0
- package/dist/curvefield/labels.d.ts +13 -0
- package/dist/curvefield.css +57 -0
- package/dist/curvefield.js +252 -0
- package/dist/curvefield.js.map +1 -0
- package/dist/ease.d.ts +62 -0
- package/dist/ease.js +157 -0
- package/dist/ease.js.map +1 -0
- package/dist/edgescroll.d.ts +77 -0
- package/dist/edgescroll.js +78 -0
- package/dist/edgescroll.js.map +1 -0
- package/dist/file.d.ts +10 -0
- package/dist/file.js +22 -0
- package/dist/file.js.map +1 -0
- package/dist/gestures.d.ts +174 -0
- package/dist/gestures.js +229 -0
- package/dist/gestures.js.map +1 -0
- package/dist/gradienteditor/TaoxGradientEditor.vue.d.ts +48 -0
- package/dist/gradienteditor/index.d.ts +2 -0
- package/dist/gradienteditor/ops.d.ts +83 -0
- package/dist/gradienteditor.css +81 -0
- package/dist/gradienteditor.js +337 -0
- package/dist/gradienteditor.js.map +1 -0
- package/dist/history.d.ts +42 -0
- package/dist/history.js +89 -0
- package/dist/history.js.map +1 -0
- package/dist/i18n.d.ts +51 -0
- package/dist/i18n.js +102 -0
- package/dist/i18n.js.map +1 -0
- package/dist/ids.d.ts +5 -0
- package/dist/ids.js +17 -0
- package/dist/ids.js.map +1 -0
- package/dist/links/TaoxLinks.vue.d.ts +14 -0
- package/dist/links/index.d.ts +2 -0
- package/dist/links/types.d.ts +37 -0
- package/dist/links.css +80 -0
- package/dist/links.js +72 -0
- package/dist/links.js.map +1 -0
- package/dist/num.d.ts +35 -0
- package/dist/num.js +60 -0
- package/dist/num.js.map +1 -0
- package/dist/palette.d.ts +34 -0
- package/dist/palette.js +41 -0
- package/dist/palette.js.map +1 -0
- package/dist/pins.d.ts +66 -0
- package/dist/pins.js +83 -0
- package/dist/pins.js.map +1 -0
- package/dist/playback/core.d.ts +81 -0
- package/dist/playback/index.d.ts +2 -0
- package/dist/playback/use.d.ts +38 -0
- package/dist/playback.js +199 -0
- package/dist/playback.js.map +1 -0
- package/dist/session.d.ts +125 -0
- package/dist/session.js +195 -0
- package/dist/session.js.map +1 -0
- package/dist/snap.d.ts +24 -0
- package/dist/snap.js +34 -0
- package/dist/snap.js.map +1 -0
- package/dist/storage.d.ts +16 -0
- package/dist/storage.js +30 -0
- package/dist/storage.js.map +1 -0
- package/dist/touch.d.ts +9 -0
- package/dist/touch.js +20 -0
- package/dist/touch.js.map +1 -0
- package/dist/wheel.d.ts +31 -0
- package/dist/wheel.js +47 -0
- package/dist/wheel.js.map +1 -0
- package/package.json +183 -4
- package/theme/taoui.css +43 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import { type CurveGuides, type CurvePoint } from '../curveeditor';
|
|
2
|
+
import type { CurveFieldLabels } from './labels';
|
|
3
|
+
type __VLS_Props = {
|
|
4
|
+
/**
|
|
5
|
+
* Curve points.
|
|
6
|
+
* Точки кривой.
|
|
7
|
+
*/
|
|
8
|
+
modelValue: readonly CurvePoint[];
|
|
9
|
+
/**
|
|
10
|
+
* Allowed values: they fix the plot view and do not let a point be dragged past the bound.
|
|
11
|
+
* Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.
|
|
12
|
+
*/
|
|
13
|
+
min?: number;
|
|
14
|
+
max?: number;
|
|
15
|
+
/**
|
|
16
|
+
* The "default" curve: without it there is no reset button.
|
|
17
|
+
* Кривая «по умолчанию»: без неё кнопки сброса нет.
|
|
18
|
+
*/
|
|
19
|
+
defaultValue?: readonly CurvePoint[];
|
|
20
|
+
/**
|
|
21
|
+
* How many decimals to keep in time and value; not set means do not round.
|
|
22
|
+
* Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.
|
|
23
|
+
*/
|
|
24
|
+
precision?: number;
|
|
25
|
+
/**
|
|
26
|
+
* The time step of the grid and of the time field.
|
|
27
|
+
* Шаг по времени у сетки и у поля времени.
|
|
28
|
+
*/
|
|
29
|
+
stepT?: number;
|
|
30
|
+
/**
|
|
31
|
+
* Snapping to the grid at start.
|
|
32
|
+
* Прилипание к сетке при старте.
|
|
33
|
+
*/
|
|
34
|
+
snap?: boolean;
|
|
35
|
+
/**
|
|
36
|
+
* Labels in the app language; missing ones fall back to English.
|
|
37
|
+
* Надписи на языке приложения; недостающие берутся английские.
|
|
38
|
+
*/
|
|
39
|
+
labels?: Partial<CurveFieldLabels>;
|
|
40
|
+
/**
|
|
41
|
+
* Guides from the selected point to the axes: `off`, `lines` (default) or `values`.
|
|
42
|
+
* Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.
|
|
43
|
+
*/
|
|
44
|
+
guides?: CurveGuides;
|
|
45
|
+
/**
|
|
46
|
+
* Labels for screen readers: see TaoxCurveEditor.
|
|
47
|
+
* Подписи для скринридеров: см. TaoxCurveEditor.
|
|
48
|
+
*/
|
|
49
|
+
pointLabel?: (index: number, point: CurvePoint) => string;
|
|
50
|
+
handleLabel?: (n: number, index: number) => string;
|
|
51
|
+
};
|
|
52
|
+
declare const __VLS_export: import("vue").DefineComponent<__VLS_Props, {}, {}, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {
|
|
53
|
+
"update:modelValue": (value: CurvePoint[]) => any;
|
|
54
|
+
commit: () => any;
|
|
55
|
+
}, string, import("vue").PublicProps, Readonly<__VLS_Props> & Readonly<{
|
|
56
|
+
"onUpdate:modelValue"?: ((value: CurvePoint[]) => any) | undefined;
|
|
57
|
+
onCommit?: (() => any) | undefined;
|
|
58
|
+
}>, {
|
|
59
|
+
snap: boolean;
|
|
60
|
+
stepT: number;
|
|
61
|
+
guides: CurveGuides;
|
|
62
|
+
}, {}, {}, {}, string, import("vue").ComponentProvideOptions, false, {}, any>;
|
|
63
|
+
declare const _default: typeof __VLS_export;
|
|
64
|
+
export default _default;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Labels of the curve field: the language is set by the app, English by default.
|
|
3
|
+
* Надписи поля кривой: язык задаёт приложение, по умолчанию английские.
|
|
4
|
+
*/
|
|
5
|
+
export interface CurveFieldLabels {
|
|
6
|
+
time: string;
|
|
7
|
+
value: string;
|
|
8
|
+
transition: string;
|
|
9
|
+
snap: string;
|
|
10
|
+
remove: string;
|
|
11
|
+
reset: string;
|
|
12
|
+
hint: string;
|
|
13
|
+
}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
|
|
2
|
+
.tx-curve-field[data-v-ea87ea52] {
|
|
3
|
+
--tx-curve-bg: var(--tao-color-surface-sunken);
|
|
4
|
+
--tx-curve-border: var(--tao-color-border);
|
|
5
|
+
--tx-curve-grid: var(--tao-color-border);
|
|
6
|
+
--tx-curve-label: var(--tao-color-text-muted);
|
|
7
|
+
--tx-curve-text: var(--tao-color-text);
|
|
8
|
+
--tx-curve-accent: var(--tao-color-accent);
|
|
9
|
+
|
|
10
|
+
display: flex;
|
|
11
|
+
flex-direction: column;
|
|
12
|
+
gap: 8px;
|
|
13
|
+
}
|
|
14
|
+
.tx-curve-field__fields[data-v-ea87ea52] {
|
|
15
|
+
display: grid;
|
|
16
|
+
grid-template-columns: 1fr 1fr;
|
|
17
|
+
gap: 8px;
|
|
18
|
+
}
|
|
19
|
+
.tx-curve-field__fields > label[data-v-ea87ea52] {
|
|
20
|
+
display: flex;
|
|
21
|
+
flex-direction: column;
|
|
22
|
+
gap: 2px;
|
|
23
|
+
color: var(--tao-color-text-muted);
|
|
24
|
+
font-size: 11px;
|
|
25
|
+
}
|
|
26
|
+
.tx-curve-field__ease[data-v-ea87ea52] {
|
|
27
|
+
display: flex;
|
|
28
|
+
flex-direction: column;
|
|
29
|
+
gap: 2px;
|
|
30
|
+
}
|
|
31
|
+
.tx-curve-field__title[data-v-ea87ea52] {
|
|
32
|
+
color: var(--tao-color-text-muted);
|
|
33
|
+
font-size: 11px;
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */
|
|
37
|
+
.tx-curve-field__ease-row[data-v-ea87ea52] {
|
|
38
|
+
display: flex;
|
|
39
|
+
align-items: center;
|
|
40
|
+
gap: 6px;
|
|
41
|
+
}
|
|
42
|
+
.tx-curve-field__kind[data-v-ea87ea52] {
|
|
43
|
+
flex: 1;
|
|
44
|
+
min-width: 0;
|
|
45
|
+
}
|
|
46
|
+
.tx-curve-field__ease-row[data-v-ea87ea52] > :last-child {
|
|
47
|
+
flex: none;
|
|
48
|
+
}
|
|
49
|
+
.tx-curve-field__bar[data-v-ea87ea52] {
|
|
50
|
+
display: flex;
|
|
51
|
+
align-items: center;
|
|
52
|
+
gap: 4px;
|
|
53
|
+
font-size: 12px;
|
|
54
|
+
}
|
|
55
|
+
.tx-curve-field__spacer[data-v-ea87ea52] {
|
|
56
|
+
flex: 1;
|
|
57
|
+
}
|
|
@@ -0,0 +1,252 @@
|
|
|
1
|
+
import { clampTo, niceStep, roundTo } from "./num.js";
|
|
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";
|
|
4
|
+
import { Fragment, computed, createBlock, createCommentVNode, createElementBlock, createElementVNode, createTextVNode, createVNode, defineComponent, openBlock, ref, renderList, toDisplayString, unref, withCtx } from "vue";
|
|
5
|
+
import { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from "@1337exp/taoui";
|
|
6
|
+
//#region src/curvefield/TaoxCurveField.vue?vue&type=script&setup=true&lang.ts
|
|
7
|
+
var _hoisted_1 = { class: "tx-curve-field" };
|
|
8
|
+
var _hoisted_2 = { class: "tx-curve-field__fields" };
|
|
9
|
+
var _hoisted_3 = { class: "tx-curve-field__ease" };
|
|
10
|
+
var _hoisted_4 = {
|
|
11
|
+
class: "tx-curve-field__title",
|
|
12
|
+
"aria-hidden": "true"
|
|
13
|
+
};
|
|
14
|
+
var _hoisted_5 = ["aria-label"];
|
|
15
|
+
var _hoisted_6 = { class: "tx-curve-field__bar" };
|
|
16
|
+
var TaoxCurveField_vue_vue_type_script_setup_true_lang_default = /*@__PURE__*/ defineComponent({
|
|
17
|
+
__name: "TaoxCurveField",
|
|
18
|
+
props: {
|
|
19
|
+
modelValue: {},
|
|
20
|
+
min: {},
|
|
21
|
+
max: {},
|
|
22
|
+
defaultValue: {},
|
|
23
|
+
precision: {},
|
|
24
|
+
stepT: { default: .05 },
|
|
25
|
+
snap: {
|
|
26
|
+
type: Boolean,
|
|
27
|
+
default: true
|
|
28
|
+
},
|
|
29
|
+
labels: {},
|
|
30
|
+
guides: { default: "lines" },
|
|
31
|
+
pointLabel: {},
|
|
32
|
+
handleLabel: {}
|
|
33
|
+
},
|
|
34
|
+
emits: ["update:modelValue", "commit"],
|
|
35
|
+
setup(__props, { emit: __emit }) {
|
|
36
|
+
const props = __props;
|
|
37
|
+
const emit = __emit;
|
|
38
|
+
const DEFAULT_LABELS = {
|
|
39
|
+
time: "Time",
|
|
40
|
+
value: "Value",
|
|
41
|
+
transition: "Transition to the next point",
|
|
42
|
+
snap: "Snap to grid",
|
|
43
|
+
remove: "Remove",
|
|
44
|
+
reset: "Reset",
|
|
45
|
+
hint: "Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping"
|
|
46
|
+
};
|
|
47
|
+
const text = computed(() => ({
|
|
48
|
+
...DEFAULT_LABELS,
|
|
49
|
+
...props.labels
|
|
50
|
+
}));
|
|
51
|
+
const selected = ref(0);
|
|
52
|
+
const snapOn = ref(props.snap);
|
|
53
|
+
const points = computed(() => props.modelValue.map((p) => ({ ...p })));
|
|
54
|
+
const current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]);
|
|
55
|
+
const stepV = computed(() => {
|
|
56
|
+
const b = valueBounds(points.value, props.min, props.max);
|
|
57
|
+
return niceStep(b.max - b.min, 20);
|
|
58
|
+
});
|
|
59
|
+
const canReset = computed(() => props.defaultValue !== void 0 && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));
|
|
60
|
+
function change(next) {
|
|
61
|
+
emit("update:modelValue", next);
|
|
62
|
+
}
|
|
63
|
+
function removeSelected() {
|
|
64
|
+
change(removePoint(points.value, selected.value));
|
|
65
|
+
selected.value = 0;
|
|
66
|
+
emit("commit");
|
|
67
|
+
}
|
|
68
|
+
function setField(field, value) {
|
|
69
|
+
if (value === null || !Number.isFinite(value)) return;
|
|
70
|
+
const p = current.value;
|
|
71
|
+
const tt = field === "t" ? roundTo(value, props.precision) : p.t;
|
|
72
|
+
const v = field === "v" ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;
|
|
73
|
+
change(movePoint(points.value, selected.value, tt, v));
|
|
74
|
+
emit("commit");
|
|
75
|
+
}
|
|
76
|
+
function reset() {
|
|
77
|
+
if (props.defaultValue === void 0) return;
|
|
78
|
+
selected.value = 0;
|
|
79
|
+
change(props.defaultValue.map((p) => ({ ...p })));
|
|
80
|
+
emit("commit");
|
|
81
|
+
}
|
|
82
|
+
const isLast = computed(() => selected.value >= points.value.length - 1);
|
|
83
|
+
const kind = computed(() => {
|
|
84
|
+
const e = current.value.ease;
|
|
85
|
+
if (e === void 0 || e === "linear") return "linear";
|
|
86
|
+
if (typeof e === "object") return "bezier";
|
|
87
|
+
return easeParts(e)?.family ?? e;
|
|
88
|
+
});
|
|
89
|
+
const direction = computed(() => {
|
|
90
|
+
const e = current.value.ease;
|
|
91
|
+
return typeof e === "string" ? easeParts(e)?.direction ?? "in-out" : "in-out";
|
|
92
|
+
});
|
|
93
|
+
const hasDirection = computed(() => !isLast.value && typeof current.value.ease === "string" && easeParts(current.value.ease) !== null);
|
|
94
|
+
const kindOptions = [
|
|
95
|
+
"linear",
|
|
96
|
+
"step",
|
|
97
|
+
...EASE_FAMILIES,
|
|
98
|
+
"bezier"
|
|
99
|
+
].map((v) => ({
|
|
100
|
+
value: v,
|
|
101
|
+
label: v
|
|
102
|
+
}));
|
|
103
|
+
function applyEase(next) {
|
|
104
|
+
change(setEase(points.value, selected.value, next));
|
|
105
|
+
emit("commit");
|
|
106
|
+
}
|
|
107
|
+
function setKind(v) {
|
|
108
|
+
if (typeof v !== "string") return;
|
|
109
|
+
if (v === "linear" || v === "step") applyEase(v);
|
|
110
|
+
else if (v === "bezier") applyEase({ bezier: DEFAULT_BEZIER });
|
|
111
|
+
else applyEase(easeName(v, direction.value));
|
|
112
|
+
}
|
|
113
|
+
function setDirection(v) {
|
|
114
|
+
const e = current.value.ease;
|
|
115
|
+
const parts = typeof e === "string" ? easeParts(e) : null;
|
|
116
|
+
if (parts && typeof v === "string" && EASE_DIRECTIONS.includes(v)) applyEase(easeName(parts.family, v));
|
|
117
|
+
}
|
|
118
|
+
return (_ctx, _cache) => {
|
|
119
|
+
return openBlock(), createElementBlock("div", _hoisted_1, [
|
|
120
|
+
createVNode(unref(TaoxCurveEditor_default), {
|
|
121
|
+
"model-value": points.value,
|
|
122
|
+
selected: selected.value,
|
|
123
|
+
"onUpdate:selected": _cache[0] || (_cache[0] = ($event) => selected.value = $event),
|
|
124
|
+
min: __props.min,
|
|
125
|
+
max: __props.max,
|
|
126
|
+
precision: __props.precision,
|
|
127
|
+
snap: snapOn.value,
|
|
128
|
+
"step-t": __props.stepT,
|
|
129
|
+
hint: text.value.hint,
|
|
130
|
+
guides: __props.guides,
|
|
131
|
+
"point-label": __props.pointLabel,
|
|
132
|
+
"handle-label": __props.handleLabel,
|
|
133
|
+
"onUpdate:modelValue": change,
|
|
134
|
+
onCommit: _cache[1] || (_cache[1] = ($event) => emit("commit"))
|
|
135
|
+
}, null, 8, [
|
|
136
|
+
"model-value",
|
|
137
|
+
"selected",
|
|
138
|
+
"min",
|
|
139
|
+
"max",
|
|
140
|
+
"precision",
|
|
141
|
+
"snap",
|
|
142
|
+
"step-t",
|
|
143
|
+
"hint",
|
|
144
|
+
"guides",
|
|
145
|
+
"point-label",
|
|
146
|
+
"handle-label"
|
|
147
|
+
]),
|
|
148
|
+
createElementVNode("div", _hoisted_2, [createElementVNode("label", null, [createTextVNode(toDisplayString(text.value.time), 1), createVNode(unref(TaoInputNumber), {
|
|
149
|
+
size: "small",
|
|
150
|
+
min: 0,
|
|
151
|
+
max: 1,
|
|
152
|
+
step: __props.stepT,
|
|
153
|
+
precision: __props.precision,
|
|
154
|
+
controls: false,
|
|
155
|
+
"model-value": current.value.t,
|
|
156
|
+
"onUpdate:modelValue": _cache[2] || (_cache[2] = (x) => setField("t", x))
|
|
157
|
+
}, null, 8, [
|
|
158
|
+
"step",
|
|
159
|
+
"precision",
|
|
160
|
+
"model-value"
|
|
161
|
+
])]), createElementVNode("label", null, [createTextVNode(toDisplayString(text.value.value), 1), createVNode(unref(TaoInputNumber), {
|
|
162
|
+
size: "small",
|
|
163
|
+
min: __props.min,
|
|
164
|
+
max: __props.max,
|
|
165
|
+
step: stepV.value,
|
|
166
|
+
precision: __props.precision,
|
|
167
|
+
controls: false,
|
|
168
|
+
"model-value": current.value.v,
|
|
169
|
+
"onUpdate:modelValue": _cache[3] || (_cache[3] = (x) => setField("v", x))
|
|
170
|
+
}, null, 8, [
|
|
171
|
+
"min",
|
|
172
|
+
"max",
|
|
173
|
+
"step",
|
|
174
|
+
"precision",
|
|
175
|
+
"model-value"
|
|
176
|
+
])])]),
|
|
177
|
+
createElementVNode("div", _hoisted_3, [createElementVNode("span", _hoisted_4, toDisplayString(text.value.transition), 1), createElementVNode("div", {
|
|
178
|
+
class: "tx-curve-field__ease-row",
|
|
179
|
+
role: "group",
|
|
180
|
+
"aria-label": text.value.transition
|
|
181
|
+
}, [createVNode(unref(TaoSelect), {
|
|
182
|
+
class: "tx-curve-field__kind",
|
|
183
|
+
size: "small",
|
|
184
|
+
clearable: false,
|
|
185
|
+
options: unref(kindOptions),
|
|
186
|
+
disabled: isLast.value,
|
|
187
|
+
"model-value": kind.value,
|
|
188
|
+
"onUpdate:modelValue": setKind
|
|
189
|
+
}, null, 8, [
|
|
190
|
+
"options",
|
|
191
|
+
"disabled",
|
|
192
|
+
"model-value"
|
|
193
|
+
]), createVNode(unref(TaoSegmented), {
|
|
194
|
+
size: "small",
|
|
195
|
+
disabled: !hasDirection.value,
|
|
196
|
+
"model-value": hasDirection.value ? direction.value : void 0,
|
|
197
|
+
"onUpdate:modelValue": setDirection
|
|
198
|
+
}, {
|
|
199
|
+
default: withCtx(() => [(openBlock(true), createElementBlock(Fragment, null, renderList(unref(EASE_DIRECTIONS), (d) => {
|
|
200
|
+
return openBlock(), createBlock(unref(TaoSegmentedOption), {
|
|
201
|
+
key: d,
|
|
202
|
+
value: d,
|
|
203
|
+
label: d
|
|
204
|
+
}, null, 8, ["value", "label"]);
|
|
205
|
+
}), 128))]),
|
|
206
|
+
_: 1
|
|
207
|
+
}, 8, ["disabled", "model-value"])], 8, _hoisted_5)]),
|
|
208
|
+
createElementVNode("div", _hoisted_6, [
|
|
209
|
+
createVNode(unref(TaoSwitch), {
|
|
210
|
+
modelValue: snapOn.value,
|
|
211
|
+
"onUpdate:modelValue": _cache[4] || (_cache[4] = ($event) => snapOn.value = $event),
|
|
212
|
+
label: text.value.snap
|
|
213
|
+
}, null, 8, ["modelValue", "label"]),
|
|
214
|
+
_cache[5] || (_cache[5] = createElementVNode("span", { class: "tx-curve-field__spacer" }, null, -1)),
|
|
215
|
+
createVNode(unref(TaoButton), {
|
|
216
|
+
size: "small",
|
|
217
|
+
variant: "ghost",
|
|
218
|
+
disabled: points.value.length <= 2,
|
|
219
|
+
onClick: removeSelected
|
|
220
|
+
}, {
|
|
221
|
+
default: withCtx(() => [createTextVNode(toDisplayString(text.value.remove), 1)]),
|
|
222
|
+
_: 1
|
|
223
|
+
}, 8, ["disabled"]),
|
|
224
|
+
__props.defaultValue !== void 0 ? (openBlock(), createBlock(unref(TaoButton), {
|
|
225
|
+
key: 0,
|
|
226
|
+
size: "small",
|
|
227
|
+
variant: "ghost",
|
|
228
|
+
disabled: !canReset.value,
|
|
229
|
+
onClick: reset
|
|
230
|
+
}, {
|
|
231
|
+
default: withCtx(() => [createTextVNode(toDisplayString(text.value.reset), 1)]),
|
|
232
|
+
_: 1
|
|
233
|
+
}, 8, ["disabled"])) : createCommentVNode("", true)
|
|
234
|
+
])
|
|
235
|
+
]);
|
|
236
|
+
};
|
|
237
|
+
}
|
|
238
|
+
});
|
|
239
|
+
//#endregion
|
|
240
|
+
//#region \0plugin-vue:export-helper
|
|
241
|
+
var _plugin_vue_export_helper_default = (sfc, props) => {
|
|
242
|
+
const target = sfc.__vccOpts || sfc;
|
|
243
|
+
for (const [key, val] of props) target[key] = val;
|
|
244
|
+
return target;
|
|
245
|
+
};
|
|
246
|
+
//#endregion
|
|
247
|
+
//#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-ea87ea52"]]);
|
|
249
|
+
//#endregion
|
|
250
|
+
export { TaoxCurveField_default as TaoxCurveField };
|
|
251
|
+
|
|
252
|
+
//# sourceMappingURL=curvefield.js.map
|
|
@@ -0,0 +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>\r\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\r\nimport { computed, ref } from 'vue';\r\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\r\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\r\nimport { clampTo, niceStep, roundTo } from '../num';\r\nimport type { CurveFieldLabels } from './labels';\r\n\r\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.\r\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\r\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\r\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\r\nconst props = withDefaults(\r\n defineProps<{\r\n /**\r\n * Curve points.\r\n * Точки кривой.\r\n */\r\n modelValue: readonly CurvePoint[];\r\n /**\r\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\r\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\r\n */\r\n min?: number;\r\n max?: number;\r\n /**\r\n * The \"default\" curve: without it there is no reset button.\r\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\r\n */\r\n defaultValue?: readonly CurvePoint[];\r\n /**\r\n * How many decimals to keep in time and value; not set means do not round.\r\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\r\n */\r\n precision?: number;\r\n /**\r\n * The time step of the grid and of the time field.\r\n * Шаг по времени у сетки и у поля времени.\r\n */\r\n stepT?: number;\r\n /**\r\n * Snapping to the grid at start.\r\n * Прилипание к сетке при старте.\r\n */\r\n snap?: boolean;\r\n /**\r\n * Labels in the app language; missing ones fall back to English.\r\n * Надписи на языке приложения; недостающие берутся английские.\r\n */\r\n labels?: Partial<CurveFieldLabels>;\r\n /**\r\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\r\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\r\n */\r\n guides?: CurveGuides;\r\n /**\r\n * Labels for screen readers: see TaoxCurveEditor.\r\n * Подписи для скринридеров: см. TaoxCurveEditor.\r\n */\r\n pointLabel?: (index: number, point: CurvePoint) => string;\r\n handleLabel?: (n: number, index: number) => string;\r\n }>(),\r\n { stepT: 0.05, snap: true, guides: 'lines' },\r\n);\r\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\r\n\r\nconst DEFAULT_LABELS: CurveFieldLabels = {\r\n time: 'Time',\r\n value: 'Value',\r\n transition: 'Transition to the next point',\r\n snap: 'Snap to grid',\r\n remove: 'Remove',\r\n reset: 'Reset',\r\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\r\n};\r\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\r\n\r\nconst selected = ref(0);\r\nconst snapOn = ref(props.snap);\r\n\r\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\r\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\r\nconst stepV = computed(() => {\r\n const b = valueBounds(points.value, props.min, props.max);\r\n return niceStep(b.max - b.min, 20);\r\n});\r\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\r\n\r\nfunction change(next: CurvePoint[]) {\r\n emit('update:modelValue', next);\r\n}\r\n\r\nfunction removeSelected() {\r\n change(removePoint(points.value, selected.value));\r\n selected.value = 0;\r\n emit('commit');\r\n}\r\n\r\nfunction setField(field: 't' | 'v', value: number | null) {\r\n if (value === null || !Number.isFinite(value)) return;\r\n const p = current.value;\r\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\r\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\r\n change(movePoint(points.value, selected.value, tt, v));\r\n emit('commit');\r\n}\r\n\r\nfunction reset() {\r\n if (props.defaultValue === undefined) return;\r\n selected.value = 0;\r\n change(props.defaultValue.map((p) => ({ ...p })));\r\n emit('commit');\r\n}\r\n\r\n//--------------------------------------------------\r\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\r\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\r\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\r\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\r\n\r\nconst isLast = computed(() => selected.value >= points.value.length - 1);\r\nconst kind = computed(() => {\r\n const e = current.value.ease;\r\n if (e === undefined || e === 'linear') return 'linear';\r\n if (typeof e === 'object') return 'bezier';\r\n return easeParts(e)?.family ?? e;\r\n});\r\nconst direction = computed<EaseDirection>(() => {\r\n const e = current.value.ease;\r\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\r\n});\r\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\r\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\r\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\r\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\r\n\r\nfunction applyEase(next: Ease) {\r\n change(setEase(points.value, selected.value, next));\r\n emit('commit');\r\n}\r\n\r\nfunction setKind(v: string | number | null) {\r\n if (typeof v !== 'string') return;\r\n if (v === 'linear' || v === 'step') applyEase(v);\r\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\r\n else applyEase(easeName(v as EaseFamily, direction.value));\r\n}\r\n\r\nfunction setDirection(v: unknown) {\r\n const e = current.value.ease;\r\n const parts = typeof e === 'string' ? easeParts(e) : null;\r\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\r\n}\r\n</script>\r\n\r\n<template>\r\n <div class=\"tx-curve-field\">\r\n <TaoxCurveEditor\r\n :model-value=\"points\"\r\n v-model:selected=\"selected\"\r\n :min=\"min\"\r\n :max=\"max\"\r\n :precision=\"precision\"\r\n :snap=\"snapOn\"\r\n :step-t=\"stepT\"\r\n :hint=\"text.hint\"\r\n :guides=\"guides\"\r\n :point-label=\"pointLabel\"\r\n :handle-label=\"handleLabel\"\r\n @update:model-value=\"change\"\r\n @commit=\"emit('commit')\"\r\n />\r\n\r\n <div class=\"tx-curve-field__fields\">\r\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>\r\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>\r\n </div>\r\n\r\n <div class=\"tx-curve-field__ease\">\r\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\r\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\r\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\r\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\r\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\r\n </TaoSegmented>\r\n </div>\r\n </div>\r\n\r\n <div class=\"tx-curve-field__bar\">\r\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\r\n <span class=\"tx-curve-field__spacer\" />\r\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\r\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<style scoped>\r\n.tx-curve-field {\r\n --tx-curve-bg: var(--tao-color-surface-sunken);\r\n --tx-curve-border: var(--tao-color-border);\r\n --tx-curve-grid: var(--tao-color-border);\r\n --tx-curve-label: var(--tao-color-text-muted);\r\n --tx-curve-text: var(--tao-color-text);\r\n --tx-curve-accent: var(--tao-color-accent);\r\n\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n}\r\n\r\n.tx-curve-field__fields {\r\n display: grid;\r\n grid-template-columns: 1fr 1fr;\r\n gap: 8px;\r\n}\r\n\r\n.tx-curve-field__fields > label {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 2px;\r\n color: var(--tao-color-text-muted);\r\n font-size: 11px;\r\n}\r\n\r\n.tx-curve-field__ease {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 2px;\r\n}\r\n\r\n.tx-curve-field__title {\r\n color: var(--tao-color-text-muted);\r\n font-size: 11px;\r\n}\r\n\r\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\r\n.tx-curve-field__ease-row {\r\n display: flex;\r\n align-items: center;\r\n gap: 6px;\r\n}\r\n\r\n.tx-curve-field__kind {\r\n flex: 1;\r\n min-width: 0;\r\n}\r\n\r\n.tx-curve-field__ease-row > :last-child {\r\n flex: none;\r\n}\r\n\r\n.tx-curve-field__bar {\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n font-size: 12px;\r\n}\r\n\r\n.tx-curve-field__spacer {\r\n flex: 1;\r\n}\r\n</style>\r\n","<script lang=\"ts\" setup>\r\nimport { TaoButton, TaoInputNumber, TaoSegmented, TaoSegmentedOption, TaoSelect, TaoSwitch } from '@1337exp/taoui';\r\nimport { computed, ref } from 'vue';\r\nimport { movePoint, removePoint, setEase, TaoxCurveEditor, valueBounds, type CurveGuides, type CurvePoint } from '../curveeditor';\r\nimport { DEFAULT_BEZIER, EASE_DIRECTIONS, EASE_FAMILIES, easeName, easeParts, type Ease, type EaseDirection, type EaseFamily } from '../ease';\r\nimport { clampTo, niceStep, roundTo } from '../num';\r\nimport type { CurveFieldLabels } from './labels';\r\n\r\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.\r\n// The first taoux module on top of TaoUI: the plot and the logic stay in taoux, the fields and buttons are TaoUI components.\r\n// Кривая с полями: график (TaoxCurveEditor), поля выбранной точки, переход к следующей точке, шаг сетки, удаление и сброс.\r\n// Первый модуль taoux поверх TaoUI: график и логика остаются в taoux, поля и кнопки это компоненты TaoUI.\r\nconst props = withDefaults(\r\n defineProps<{\r\n /**\r\n * Curve points.\r\n * Точки кривой.\r\n */\r\n modelValue: readonly CurvePoint[];\r\n /**\r\n * Allowed values: they fix the plot view and do not let a point be dragged past the bound.\r\n * Допустимые значения: фиксируют вид графика и не дают утащить точку за границу.\r\n */\r\n min?: number;\r\n max?: number;\r\n /**\r\n * The \"default\" curve: without it there is no reset button.\r\n * Кривая «по умолчанию»: без неё кнопки сброса нет.\r\n */\r\n defaultValue?: readonly CurvePoint[];\r\n /**\r\n * How many decimals to keep in time and value; not set means do not round.\r\n * Сколько знаков после запятой оставлять у времени и значения; не задано — не обрезать.\r\n */\r\n precision?: number;\r\n /**\r\n * The time step of the grid and of the time field.\r\n * Шаг по времени у сетки и у поля времени.\r\n */\r\n stepT?: number;\r\n /**\r\n * Snapping to the grid at start.\r\n * Прилипание к сетке при старте.\r\n */\r\n snap?: boolean;\r\n /**\r\n * Labels in the app language; missing ones fall back to English.\r\n * Надписи на языке приложения; недостающие берутся английские.\r\n */\r\n labels?: Partial<CurveFieldLabels>;\r\n /**\r\n * Guides from the selected point to the axes: `off`, `lines` (default) or `values`.\r\n * Направляющие от выбранной точки к осям: `off`, `lines` (по умолчанию) или `values`.\r\n */\r\n guides?: CurveGuides;\r\n /**\r\n * Labels for screen readers: see TaoxCurveEditor.\r\n * Подписи для скринридеров: см. TaoxCurveEditor.\r\n */\r\n pointLabel?: (index: number, point: CurvePoint) => string;\r\n handleLabel?: (n: number, index: number) => string;\r\n }>(),\r\n { stepT: 0.05, snap: true, guides: 'lines' },\r\n);\r\nconst emit = defineEmits<{ 'update:modelValue': [value: CurvePoint[]]; commit: [] }>();\r\n\r\nconst DEFAULT_LABELS: CurveFieldLabels = {\r\n time: 'Time',\r\n value: 'Value',\r\n transition: 'Transition to the next point',\r\n snap: 'Snap to grid',\r\n remove: 'Remove',\r\n reset: 'Reset',\r\n hint: 'Double-click adds a point, Alt+click or Delete removes it, Shift disables snapping',\r\n};\r\nconst text = computed(() => ({ ...DEFAULT_LABELS, ...props.labels }));\r\n\r\nconst selected = ref(0);\r\nconst snapOn = ref(props.snap);\r\n\r\nconst points = computed(() => props.modelValue.map((p) => ({ ...p })));\r\nconst current = computed(() => points.value[Math.min(selected.value, points.value.length - 1)]!);\r\nconst stepV = computed(() => {\r\n const b = valueBounds(points.value, props.min, props.max);\r\n return niceStep(b.max - b.min, 20);\r\n});\r\nconst canReset = computed(() => props.defaultValue !== undefined && JSON.stringify(points.value) !== JSON.stringify(props.defaultValue));\r\n\r\nfunction change(next: CurvePoint[]) {\r\n emit('update:modelValue', next);\r\n}\r\n\r\nfunction removeSelected() {\r\n change(removePoint(points.value, selected.value));\r\n selected.value = 0;\r\n emit('commit');\r\n}\r\n\r\nfunction setField(field: 't' | 'v', value: number | null) {\r\n if (value === null || !Number.isFinite(value)) return;\r\n const p = current.value;\r\n const tt = field === 't' ? roundTo(value, props.precision) : p.t;\r\n const v = field === 'v' ? clampTo(roundTo(value, props.precision), props.min, props.max) : p.v;\r\n change(movePoint(points.value, selected.value, tt, v));\r\n emit('commit');\r\n}\r\n\r\nfunction reset() {\r\n if (props.defaultValue === undefined) return;\r\n selected.value = 0;\r\n change(props.defaultValue.map((p) => ({ ...p })));\r\n emit('commit');\r\n}\r\n\r\n//--------------------------------------------------\r\n// The transition from the selected point to the next: the kind (linear, step, a family or bezier) and the direction.\r\n// Function names are not translated: they are known from CSS and animation libraries and would not be found by a translation.\r\n// Переход от выбранной точки к следующей: вид (linear, step, семейство или bezier) и направление.\r\n// Названия функций не переводятся: их знают по CSS и библиотекам анимации, по переводу не найдут.\r\n\r\nconst isLast = computed(() => selected.value >= points.value.length - 1);\r\nconst kind = computed(() => {\r\n const e = current.value.ease;\r\n if (e === undefined || e === 'linear') return 'linear';\r\n if (typeof e === 'object') return 'bezier';\r\n return easeParts(e)?.family ?? e;\r\n});\r\nconst direction = computed<EaseDirection>(() => {\r\n const e = current.value.ease;\r\n return typeof e === 'string' ? (easeParts(e)?.direction ?? 'in-out') : 'in-out';\r\n});\r\n// linear, step and Bezier have no direction: the switch stays in place, inactive, so that it is visible how this works\r\n// У linear, step и Безье направления нет: переключатель остаётся на месте неактивным, чтобы было видно, как это устроено\r\nconst hasDirection = computed(() => !isLast.value && typeof current.value.ease === 'string' && easeParts(current.value.ease) !== null);\r\nconst kindOptions = ['linear', 'step', ...EASE_FAMILIES, 'bezier'].map((v) => ({ value: v, label: v }));\r\n\r\nfunction applyEase(next: Ease) {\r\n change(setEase(points.value, selected.value, next));\r\n emit('commit');\r\n}\r\n\r\nfunction setKind(v: string | number | null) {\r\n if (typeof v !== 'string') return;\r\n if (v === 'linear' || v === 'step') applyEase(v);\r\n else if (v === 'bezier') applyEase({ bezier: DEFAULT_BEZIER });\r\n else applyEase(easeName(v as EaseFamily, direction.value));\r\n}\r\n\r\nfunction setDirection(v: unknown) {\r\n const e = current.value.ease;\r\n const parts = typeof e === 'string' ? easeParts(e) : null;\r\n if (parts && typeof v === 'string' && (EASE_DIRECTIONS as readonly string[]).includes(v)) applyEase(easeName(parts.family, v as EaseDirection));\r\n}\r\n</script>\r\n\r\n<template>\r\n <div class=\"tx-curve-field\">\r\n <TaoxCurveEditor\r\n :model-value=\"points\"\r\n v-model:selected=\"selected\"\r\n :min=\"min\"\r\n :max=\"max\"\r\n :precision=\"precision\"\r\n :snap=\"snapOn\"\r\n :step-t=\"stepT\"\r\n :hint=\"text.hint\"\r\n :guides=\"guides\"\r\n :point-label=\"pointLabel\"\r\n :handle-label=\"handleLabel\"\r\n @update:model-value=\"change\"\r\n @commit=\"emit('commit')\"\r\n />\r\n\r\n <div class=\"tx-curve-field__fields\">\r\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>\r\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>\r\n </div>\r\n\r\n <div class=\"tx-curve-field__ease\">\r\n <span class=\"tx-curve-field__title\" aria-hidden=\"true\">{{ text.transition }}</span>\r\n <div class=\"tx-curve-field__ease-row\" role=\"group\" :aria-label=\"text.transition\">\r\n <TaoSelect class=\"tx-curve-field__kind\" size=\"small\" :clearable=\"false\" :options=\"kindOptions\" :disabled=\"isLast\" :model-value=\"kind\" @update:model-value=\"setKind\" />\r\n <TaoSegmented size=\"small\" :disabled=\"!hasDirection\" :model-value=\"hasDirection ? direction : undefined\" @update:model-value=\"setDirection\">\r\n <TaoSegmentedOption v-for=\"d in EASE_DIRECTIONS\" :key=\"d\" :value=\"d\" :label=\"d\" />\r\n </TaoSegmented>\r\n </div>\r\n </div>\r\n\r\n <div class=\"tx-curve-field__bar\">\r\n <TaoSwitch v-model=\"snapOn\" :label=\"text.snap\" />\r\n <span class=\"tx-curve-field__spacer\" />\r\n <TaoButton size=\"small\" variant=\"ghost\" :disabled=\"points.length <= 2\" @click=\"removeSelected\">{{ text.remove }}</TaoButton>\r\n <TaoButton v-if=\"defaultValue !== undefined\" size=\"small\" variant=\"ghost\" :disabled=\"!canReset\" @click=\"reset\">{{ text.reset }}</TaoButton>\r\n </div>\r\n </div>\r\n</template>\r\n\r\n<style scoped>\r\n.tx-curve-field {\r\n --tx-curve-bg: var(--tao-color-surface-sunken);\r\n --tx-curve-border: var(--tao-color-border);\r\n --tx-curve-grid: var(--tao-color-border);\r\n --tx-curve-label: var(--tao-color-text-muted);\r\n --tx-curve-text: var(--tao-color-text);\r\n --tx-curve-accent: var(--tao-color-accent);\r\n\r\n display: flex;\r\n flex-direction: column;\r\n gap: 8px;\r\n}\r\n\r\n.tx-curve-field__fields {\r\n display: grid;\r\n grid-template-columns: 1fr 1fr;\r\n gap: 8px;\r\n}\r\n\r\n.tx-curve-field__fields > label {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 2px;\r\n color: var(--tao-color-text-muted);\r\n font-size: 11px;\r\n}\r\n\r\n.tx-curve-field__ease {\r\n display: flex;\r\n flex-direction: column;\r\n gap: 2px;\r\n}\r\n\r\n.tx-curve-field__title {\r\n color: var(--tao-color-text-muted);\r\n font-size: 11px;\r\n}\r\n\r\n/* The list and the direction in one row: the list takes the rest, the switch keeps its own width / Список и направление в одну строку: список забирает остаток, переключатель держит свою ширину */\r\n.tx-curve-field__ease-row {\r\n display: flex;\r\n align-items: center;\r\n gap: 6px;\r\n}\r\n\r\n.tx-curve-field__kind {\r\n flex: 1;\r\n min-width: 0;\r\n}\r\n\r\n.tx-curve-field__ease-row > :last-child {\r\n flex: none;\r\n}\r\n\r\n.tx-curve-field__bar {\r\n display: flex;\r\n align-items: center;\r\n gap: 4px;\r\n font-size: 12px;\r\n}\r\n\r\n.tx-curve-field__spacer {\r\n flex: 1;\r\n}\r\n</style>\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAYA,MAAM,QAAQ;EAoDd,MAAM,OAAO;EAEb,MAAM,iBAAmC;GACrC,MAAM;GACN,OAAO;GACP,YAAY;GACZ,MAAM;GACN,QAAQ;GACR,OAAO;GACP,MAAM;EACV;EACA,MAAM,OAAO,gBAAgB;GAAE,GAAG;GAAgB,GAAG,MAAM;EAAO,EAAE;EAEpE,MAAM,WAAW,IAAI,CAAC;EACtB,MAAM,SAAS,IAAI,MAAM,IAAI;EAE7B,MAAM,SAAS,eAAe,MAAM,WAAW,KAAK,OAAO,EAAE,GAAG,EAAE,EAAE,CAAC;EACrE,MAAM,UAAU,eAAe,OAAO,MAAM,KAAK,IAAI,SAAS,OAAO,OAAO,MAAM,SAAS,CAAC,EAAG;EAC/F,MAAM,QAAQ,eAAe;GACzB,MAAM,IAAI,YAAY,OAAO,OAAO,MAAM,KAAK,MAAM,GAAG;GACxD,OAAO,SAAS,EAAE,MAAM,EAAE,KAAK,EAAE;EACrC,CAAC;EACD,MAAM,WAAW,eAAe,MAAM,iBAAiB,KAAA,KAAa,KAAK,UAAU,OAAO,KAAK,MAAM,KAAK,UAAU,MAAM,YAAY,CAAC;EAEvI,SAAS,OAAO,MAAoB;GAChC,KAAK,qBAAqB,IAAI;EAClC;EAEA,SAAS,iBAAiB;GACtB,OAAO,YAAY,OAAO,OAAO,SAAS,KAAK,CAAC;GAChD,SAAS,QAAQ;GAC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,MAAA,SAAA,GAAA;MAAjH,MAAK;MAAQ,SAAQ;MAAS,UAAU,OAAA,MAAO,UAAM;MAAQ,SAAO;;MAAgB,SAAAK,cAAiB,CAAdF,gBAAAC,gBAAA,KAAA,MAAK,MAAM,GAAA,CAAA,C;;;KAC5F,QAAA,iBAAiB,KAAA,KAAlCP,UAAA,GAAAW,YAA2IR,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"}
|
package/dist/ease.d.ts
ADDED
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Families: each has three directions.
|
|
3
|
+
* Семейства: у каждого три направления.
|
|
4
|
+
*/
|
|
5
|
+
export declare const EASE_FAMILIES: readonly ["sine", "quad", "cubic", "quart", "expo", "back", "elastic", "bounce"];
|
|
6
|
+
/**
|
|
7
|
+
* `in` accelerates, `out` decelerates, `in-out` does both.
|
|
8
|
+
* `in` разгон, `out` торможение, `in-out` и то и другое.
|
|
9
|
+
*/
|
|
10
|
+
export declare const EASE_DIRECTIONS: readonly ["in", "out", "in-out"];
|
|
11
|
+
export type EaseFamily = (typeof EASE_FAMILIES)[number];
|
|
12
|
+
export type EaseDirection = (typeof EASE_DIRECTIONS)[number];
|
|
13
|
+
/**
|
|
14
|
+
* A named transition: `linear`, `step` (holds the value until the next point) or `family-direction`.
|
|
15
|
+
* Именованный переход: `linear`, `step` (держит значение до следующей точки) или `семейство-направление`.
|
|
16
|
+
*/
|
|
17
|
+
export type EaseName = 'linear' | 'step' | `${EaseFamily}-${EaseDirection}`;
|
|
18
|
+
/**
|
|
19
|
+
* A transition: a name or a cubic Bezier `[x1, y1, x2, y2]`, like CSS `cubic-bezier()` (x in 0…1, y free).
|
|
20
|
+
* Переход: имя или кубическая кривая Безье `[x1, y1, x2, y2]`, как `cubic-bezier()` в CSS (x в 0…1, y свободный).
|
|
21
|
+
*/
|
|
22
|
+
export type Ease = EaseName | {
|
|
23
|
+
bezier: readonly [number, number, number, number];
|
|
24
|
+
};
|
|
25
|
+
export declare const EASE_NAMES: readonly EaseName[];
|
|
26
|
+
/**
|
|
27
|
+
* Default Bezier when the user picks "own curve": a soft start and finish (like CSS `ease`).
|
|
28
|
+
* Безье по умолчанию, когда пользователь выбрал «своя кривая»: мягкий старт и финиш (как `ease` в CSS).
|
|
29
|
+
*/
|
|
30
|
+
export declare const DEFAULT_BEZIER: readonly [number, number, number, number];
|
|
31
|
+
/**
|
|
32
|
+
* A cubic Bezier as a function of time: points (0,0), (x1,y1), (x2,y2), (1,1). The parameter is found by x (Newton, bisection on a flat
|
|
33
|
+
* slope), then y is taken from it. x is limited to 0…1, y may leave 0…1 (overshoot).
|
|
34
|
+
* Кубическая кривая Безье как функция времени: точки (0,0), (x1,y1), (x2,y2), (1,1). По x ищем параметр (Ньютон, при плоском
|
|
35
|
+
* наклоне деление пополам), по нему берём y. x ограничен 0…1, y может выходить за 0…1 (заступ).
|
|
36
|
+
*/
|
|
37
|
+
export declare function cubicBezier(x1: number, y1: number, x2: number, y2: number): (t: number) => number;
|
|
38
|
+
/**
|
|
39
|
+
* Splits a transition name into family and direction; `linear` and `step` have none (null).
|
|
40
|
+
* Разбирает имя перехода на семейство и направление; у `linear` и `step` их нет (null).
|
|
41
|
+
*/
|
|
42
|
+
export declare function easeParts(name: EaseName): {
|
|
43
|
+
family: EaseFamily;
|
|
44
|
+
direction: EaseDirection;
|
|
45
|
+
} | null;
|
|
46
|
+
/**
|
|
47
|
+
* Builds a name from a family and a direction.
|
|
48
|
+
* Собирает имя из семейства и направления.
|
|
49
|
+
*/
|
|
50
|
+
export declare const easeName: (f: EaseFamily, d: EaseDirection) => EaseName;
|
|
51
|
+
/**
|
|
52
|
+
* Validates a value from a file: a name from the list or a Bezier of four finite numbers with x in 0…1.
|
|
53
|
+
* Проверка значения из файла: имя из списка или Безье из четырёх конечных чисел с x в 0…1.
|
|
54
|
+
*/
|
|
55
|
+
export declare function isEase(value: unknown): value is Ease;
|
|
56
|
+
/**
|
|
57
|
+
* Applies a transition to the fraction `u` of a segment (0…1, clamped outside). Without a transition it is linear. `back`, `elastic` and Bezier may
|
|
58
|
+
* leave 0…1: that is overshoot, not an error.
|
|
59
|
+
* Применяет переход к доле `u` участка (0…1, вне зажимается). Без перехода линейно. `back`, `elastic` и Безье могут
|
|
60
|
+
* выйти за 0…1: это заступ, а не ошибка.
|
|
61
|
+
*/
|
|
62
|
+
export declare function easeValue(ease: Ease | undefined, u: number): number;
|