@tresjs/leches 0.10.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/style.css +1 -1
- package/dist/tresleches.js +398 -383
- package/dist/tresleches.umd.cjs +2 -2
- package/package.json +1 -1
package/dist/style.css
CHANGED
package/dist/tresleches.js
CHANGED
|
@@ -1,99 +1,99 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/leches
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.11.0
|
|
4
4
|
* (c) 2023
|
|
5
5
|
* description: Tasty GUI for Vue controls 🍰
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
import { unref as
|
|
9
|
-
import { useWindowSize as ee, useEventListener as
|
|
10
|
-
function
|
|
11
|
-
return typeof
|
|
8
|
+
import { unref as A, isRef as L, toRefs as E, customRef as se, ref as y, watch as N, computed as K, defineComponent as M, reactive as z, h as ie, provide as ce, isReactive as ue, openBlock as v, createElementBlock as _, createElementVNode as d, toDisplayString as k, normalizeClass as S, withDirectives as J, vShow as Q, createTextVNode as de, normalizeStyle as fe, Fragment as I, renderList as O, createCommentVNode as P, createBlock as C, createVNode as pe, Transition as ve, withCtx as Z } from "vue";
|
|
9
|
+
import { useWindowSize as ee, useEventListener as W, useStorage as ge, isClient as ye, useMouse as R, useFps as be, useRafFn as he } from "@vueuse/core";
|
|
10
|
+
function D(n) {
|
|
11
|
+
return typeof n == "function" ? n() : A(n);
|
|
12
12
|
}
|
|
13
13
|
const ne = typeof window < "u" && typeof document < "u";
|
|
14
|
-
function me(
|
|
15
|
-
if (!
|
|
16
|
-
return
|
|
17
|
-
const t = Array.isArray(
|
|
18
|
-
for (const
|
|
19
|
-
t[
|
|
14
|
+
function me(n, l = {}) {
|
|
15
|
+
if (!L(n))
|
|
16
|
+
return E(n);
|
|
17
|
+
const t = Array.isArray(n.value) ? Array.from({ length: n.value.length }) : {};
|
|
18
|
+
for (const e in n.value)
|
|
19
|
+
t[e] = se(() => ({
|
|
20
20
|
get() {
|
|
21
|
-
return
|
|
21
|
+
return n.value[e];
|
|
22
22
|
},
|
|
23
|
-
set(
|
|
24
|
-
var
|
|
25
|
-
if ((
|
|
26
|
-
if (Array.isArray(
|
|
27
|
-
const
|
|
28
|
-
|
|
23
|
+
set(a) {
|
|
24
|
+
var r;
|
|
25
|
+
if ((r = D(l.replaceRef)) != null ? r : !0)
|
|
26
|
+
if (Array.isArray(n.value)) {
|
|
27
|
+
const f = [...n.value];
|
|
28
|
+
f[e] = a, n.value = f;
|
|
29
29
|
} else {
|
|
30
|
-
const
|
|
31
|
-
Object.setPrototypeOf(
|
|
30
|
+
const f = { ...n.value, [e]: a };
|
|
31
|
+
Object.setPrototypeOf(f, Object.getPrototypeOf(n.value)), n.value = f;
|
|
32
32
|
}
|
|
33
33
|
else
|
|
34
|
-
|
|
34
|
+
n.value[e] = a;
|
|
35
35
|
}
|
|
36
36
|
}));
|
|
37
37
|
return t;
|
|
38
38
|
}
|
|
39
39
|
const _e = ne ? window : void 0;
|
|
40
|
-
function xe(
|
|
40
|
+
function xe(n, l = {}) {
|
|
41
41
|
const {
|
|
42
42
|
pointerTypes: t,
|
|
43
|
-
preventDefault:
|
|
44
|
-
stopPropagation:
|
|
45
|
-
exact:
|
|
46
|
-
onMove:
|
|
47
|
-
onEnd:
|
|
48
|
-
onStart:
|
|
43
|
+
preventDefault: e,
|
|
44
|
+
stopPropagation: a,
|
|
45
|
+
exact: r,
|
|
46
|
+
onMove: i,
|
|
47
|
+
onEnd: f,
|
|
48
|
+
onStart: p,
|
|
49
49
|
initialValue: w,
|
|
50
|
-
axis:
|
|
50
|
+
axis: c = "both",
|
|
51
51
|
draggingElement: o = _e,
|
|
52
|
-
handle:
|
|
53
|
-
} =
|
|
54
|
-
let
|
|
55
|
-
const
|
|
56
|
-
|
|
52
|
+
handle: u = n
|
|
53
|
+
} = l, { width: h } = ee();
|
|
54
|
+
let T = h.value;
|
|
55
|
+
const s = y(
|
|
56
|
+
D(w) ?? { x: 0, y: 0 }
|
|
57
57
|
);
|
|
58
|
-
|
|
59
|
-
const b =
|
|
60
|
-
|
|
58
|
+
N(h, () => {
|
|
59
|
+
const b = h.value - T;
|
|
60
|
+
s.value.x += b, T = h.value;
|
|
61
61
|
});
|
|
62
|
-
const
|
|
63
|
-
|
|
64
|
-
},
|
|
65
|
-
if (
|
|
62
|
+
const m = y(), $ = (b) => t ? t.includes(b.pointerType) : !0, g = (b) => {
|
|
63
|
+
D(e) && b.preventDefault(), D(a) && b.stopPropagation();
|
|
64
|
+
}, x = (b) => {
|
|
65
|
+
if (!$(b) || D(r) && b.target !== D(n))
|
|
66
66
|
return;
|
|
67
|
-
const
|
|
68
|
-
x: b.clientX -
|
|
69
|
-
y: b.clientY -
|
|
67
|
+
const V = D(n).getBoundingClientRect(), q = {
|
|
68
|
+
x: b.clientX - V.left,
|
|
69
|
+
y: b.clientY - V.top
|
|
70
70
|
};
|
|
71
|
-
(
|
|
71
|
+
(p == null ? void 0 : p(q, b)) !== !1 && (m.value = q, g(b));
|
|
72
72
|
}, ae = (b) => {
|
|
73
|
-
if (
|
|
73
|
+
if (!$(b) || !m.value)
|
|
74
74
|
return;
|
|
75
|
-
let { x:
|
|
76
|
-
(
|
|
77
|
-
x:
|
|
78
|
-
y:
|
|
79
|
-
},
|
|
75
|
+
let { x: V, y: q } = s.value;
|
|
76
|
+
(c === "x" || c === "both") && (V = b.clientX - m.value.x), (c === "y" || c === "both") && (q = b.clientY - m.value.y), s.value = {
|
|
77
|
+
x: V,
|
|
78
|
+
y: q
|
|
79
|
+
}, i == null || i(s.value, b), g(b);
|
|
80
80
|
}, re = (b) => {
|
|
81
|
-
|
|
81
|
+
$(b) && m.value && (m.value = void 0, f == null || f(s.value, b), g(b));
|
|
82
82
|
};
|
|
83
83
|
if (ne) {
|
|
84
|
-
const b = { capture:
|
|
85
|
-
|
|
84
|
+
const b = { capture: l.capture ?? !0 };
|
|
85
|
+
W(u, "pointerdown", x, b), W(o, "pointermove", ae, b), W(o, "pointerup", re, b);
|
|
86
86
|
}
|
|
87
87
|
return {
|
|
88
|
-
...me(
|
|
89
|
-
position:
|
|
90
|
-
isDragging:
|
|
91
|
-
style:
|
|
92
|
-
() => `left:${
|
|
88
|
+
...me(s),
|
|
89
|
+
position: s,
|
|
90
|
+
isDragging: K(() => !!m.value),
|
|
91
|
+
style: K(
|
|
92
|
+
() => `left:${s.value.x}px;top:${s.value.y}px;`
|
|
93
93
|
)
|
|
94
94
|
};
|
|
95
95
|
}
|
|
96
|
-
const we = /* @__PURE__ */
|
|
96
|
+
const we = /* @__PURE__ */ M({
|
|
97
97
|
name: "UseDraggable",
|
|
98
98
|
props: [
|
|
99
99
|
"storageKey",
|
|
@@ -110,273 +110,282 @@ const we = /* @__PURE__ */ S({
|
|
|
110
110
|
"onMove",
|
|
111
111
|
"onEnd"
|
|
112
112
|
],
|
|
113
|
-
setup(
|
|
114
|
-
const t =
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
),
|
|
119
|
-
...
|
|
120
|
-
handle:
|
|
121
|
-
initialValue:
|
|
122
|
-
onEnd: (
|
|
123
|
-
var
|
|
124
|
-
(
|
|
113
|
+
setup(n, { slots: l }) {
|
|
114
|
+
const t = y(), e = K(() => n.handle ?? t.value), a = n.storageKey && ge(
|
|
115
|
+
n.storageKey,
|
|
116
|
+
D(n.initialValue) || { x: 0, y: 0 },
|
|
117
|
+
ye ? n.storageType === "session" ? sessionStorage : localStorage : void 0
|
|
118
|
+
), r = a || n.initialValue || { x: 0, y: 0 }, f = z(xe(t, {
|
|
119
|
+
...n,
|
|
120
|
+
handle: e,
|
|
121
|
+
initialValue: r,
|
|
122
|
+
onEnd: (p, w) => {
|
|
123
|
+
var c;
|
|
124
|
+
(c = n.onEnd) == null || c.call(n, p, w), a && (a.value.x = p.x, a.value.y = p.y);
|
|
125
125
|
}
|
|
126
126
|
}));
|
|
127
127
|
return () => {
|
|
128
|
-
if (
|
|
129
|
-
return
|
|
128
|
+
if (l.default)
|
|
129
|
+
return ie(n.as || "div", { ref: t, style: `touch-action:none;${f.style}` }, l.default(f));
|
|
130
130
|
};
|
|
131
131
|
}
|
|
132
|
-
}), $e = Symbol("CONTROLS_CONTEXT_KEY"), te = "default",
|
|
133
|
-
function Ce(
|
|
134
|
-
return
|
|
132
|
+
}), $e = Symbol("CONTROLS_CONTEXT_KEY"), te = "default", F = z({});
|
|
133
|
+
function Ce(n = te) {
|
|
134
|
+
return ce($e, F), F[n];
|
|
135
135
|
}
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
return typeof
|
|
139
|
-
},
|
|
140
|
-
const
|
|
141
|
-
key:
|
|
142
|
-
label:
|
|
143
|
-
name:
|
|
144
|
-
type:
|
|
145
|
-
value:
|
|
146
|
-
visible:
|
|
147
|
-
[
|
|
136
|
+
const j = (n) => {
|
|
137
|
+
const l = /^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$|^0x([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;
|
|
138
|
+
return typeof n == "boolean" ? "boolean" : typeof n == "number" ? "number" : typeof n == "string" && l.test(n) ? "color" : typeof n == "string" ? "string" : n.isVector3 || n.isVector2 || n.isEuler || n instanceof Array ? "vector" : n.min !== void 0 || n.max !== void 0 || n.step !== void 0 ? "range" : n.options && Array.isArray(n.options) ? "select" : "unknown";
|
|
139
|
+
}, X = (n, l, t, e) => {
|
|
140
|
+
const a = {
|
|
141
|
+
key: y(n),
|
|
142
|
+
label: y(n),
|
|
143
|
+
name: y(n),
|
|
144
|
+
type: y(t),
|
|
145
|
+
value: y(l),
|
|
146
|
+
visible: y(!0),
|
|
147
|
+
[n]: y(l)
|
|
148
148
|
};
|
|
149
|
-
return
|
|
150
|
-
},
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
149
|
+
return e && (a.folder = y(e)), a;
|
|
150
|
+
}, ke = (n, l) => {
|
|
151
|
+
let t = 1, e = `${n}_${t}`;
|
|
152
|
+
for (; l[e]; )
|
|
153
|
+
t++, e = `${n}_${t}`;
|
|
154
|
+
return e;
|
|
155
|
+
}, An = (n, l, t) => {
|
|
156
|
+
const e = {}, a = typeof n == "string" ? n : null, r = a ? l : n, i = a && a !== "fpsgraph" ? t : l, f = (i == null ? void 0 : i.uuid) || te;
|
|
157
|
+
if (F[f] || (F[f] = z({})), n === "fpsgraph") {
|
|
158
|
+
const o = X("fpsgraph", null, "fpsgraph", null);
|
|
159
|
+
return F[f].fpsgraph = o, e.fpsgraph = o, E(z(e));
|
|
155
160
|
}
|
|
156
|
-
const
|
|
157
|
-
for (const o in
|
|
158
|
-
let
|
|
159
|
-
if (w &&
|
|
160
|
-
const
|
|
161
|
-
|
|
162
|
-
text:
|
|
163
|
-
value:
|
|
164
|
-
}))),
|
|
161
|
+
const p = F[f], w = ue(r), c = w ? E(r) : {};
|
|
162
|
+
for (const o in r) {
|
|
163
|
+
let u = r[o], h = o;
|
|
164
|
+
if (w && c[o] && (u = c[o]), a && (h = `${a}${o.charAt(0).toUpperCase() + o.slice(1)}`), !a && p[h] && (h = ke(o, p)), typeof u == "object" && !L(u) && !Array.isArray(u) && u.value !== void 0) {
|
|
165
|
+
const s = u, m = L(s.value) ? s.value : y(s.value), $ = j(s), g = X(o, m, $, a);
|
|
166
|
+
$ === "select" && (g.options = y(s.options.map((x) => typeof x == "object" && x.text && x.value ? x : {
|
|
167
|
+
text: x,
|
|
168
|
+
value: x
|
|
169
|
+
}))), $ === "range" && (g.min = y(s.min || 0), g.max = y(s.max || 1), g.step = y(s.step || 0.1)), g.label.value = s.label || o, g.visible.value = s.visible !== void 0 ? s.visible : !0, p[h] = g, e[h] = g;
|
|
165
170
|
continue;
|
|
166
171
|
}
|
|
167
|
-
if (
|
|
168
|
-
const
|
|
169
|
-
|
|
172
|
+
if (L(u)) {
|
|
173
|
+
const s = X(o, u, j(u.value), a);
|
|
174
|
+
p[h] = s, e[h] = s;
|
|
170
175
|
continue;
|
|
171
|
-
} else if (typeof
|
|
172
|
-
const
|
|
173
|
-
|
|
176
|
+
} else if (typeof u == "object" && !Array.isArray(u)) {
|
|
177
|
+
const s = E(u);
|
|
178
|
+
s[o] && (u = s[o]);
|
|
174
179
|
}
|
|
175
|
-
const
|
|
176
|
-
|
|
180
|
+
const T = X(o, u, j(u), a);
|
|
181
|
+
p[h] = T, e[h] = T, T.uniqueKey = h;
|
|
177
182
|
}
|
|
178
|
-
return Object.keys(
|
|
179
|
-
},
|
|
183
|
+
return Object.keys(e).length > 1 ? E(z(e)) : Object.values(e)[0];
|
|
184
|
+
}, Me = { class: "flex px-4 justify-between gap-4 items-center mb-2" }, Se = ["for"], Te = ["id", "value", "min", "max", "step"], Ae = /* @__PURE__ */ M({
|
|
180
185
|
__name: "NumberControl",
|
|
181
186
|
props: {
|
|
182
187
|
label: {},
|
|
183
188
|
control: {}
|
|
184
189
|
},
|
|
185
190
|
emits: ["change"],
|
|
186
|
-
setup(
|
|
187
|
-
const t =
|
|
188
|
-
function
|
|
189
|
-
const { target: o } =
|
|
190
|
-
|
|
191
|
+
setup(n, { emit: l }) {
|
|
192
|
+
const t = n;
|
|
193
|
+
function e(c) {
|
|
194
|
+
const { target: o } = c;
|
|
195
|
+
l("change", o.valueAsNumber);
|
|
191
196
|
}
|
|
192
|
-
const
|
|
193
|
-
|
|
194
|
-
},
|
|
195
|
-
|
|
196
|
-
}, w = (
|
|
197
|
-
return
|
|
198
|
-
if (
|
|
199
|
-
const o =
|
|
200
|
-
o > 0 ?
|
|
197
|
+
const a = R(), r = y(0), i = y(!1), f = (c) => {
|
|
198
|
+
r.value = c.clientX, i.value = !0;
|
|
199
|
+
}, p = () => {
|
|
200
|
+
i.value = !1;
|
|
201
|
+
}, w = (c) => Math.floor(Math.abs(c) / 10);
|
|
202
|
+
return N(a.x, (c) => {
|
|
203
|
+
if (i.value) {
|
|
204
|
+
const o = c - r.value, u = w(o);
|
|
205
|
+
o > 0 ? l("change", t.control.value + 1 + u) : o < 0 && l("change", t.control.value - 1 + u), t.control.min !== void 0 && t.control.value < t.control.min && l("change", t.control.min), t.control.max !== void 0 && t.control.value > t.control.max && l("change", t.control.max), r.value = c;
|
|
201
206
|
}
|
|
202
|
-
}), (
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
+
}), (c, o) => (v(), _("div", Me, [
|
|
208
|
+
d("label", {
|
|
209
|
+
class: "text-gray-500 w-1/3",
|
|
210
|
+
for: c.control.uniqueKey
|
|
211
|
+
}, k(c.label), 9, Se),
|
|
212
|
+
d("input", {
|
|
213
|
+
id: c.control.uniqueKey,
|
|
214
|
+
value: c.control.value,
|
|
215
|
+
class: S(["p-2 w-1/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans", { "cursor-ew-resize": i.value }]),
|
|
207
216
|
type: "number",
|
|
208
|
-
min:
|
|
209
|
-
max:
|
|
210
|
-
step:
|
|
211
|
-
onInput:
|
|
212
|
-
onMousedown:
|
|
213
|
-
onMouseup:
|
|
214
|
-
}, null, 42,
|
|
217
|
+
min: c.control.min,
|
|
218
|
+
max: c.control.max,
|
|
219
|
+
step: c.control.step,
|
|
220
|
+
onInput: e,
|
|
221
|
+
onMousedown: f,
|
|
222
|
+
onMouseup: p
|
|
223
|
+
}, null, 42, Te)
|
|
215
224
|
]));
|
|
216
225
|
}
|
|
217
|
-
}), De = { class: "flex px-4 justify-between gap-4 items-center mb-2 min-h-32px" },
|
|
226
|
+
}), De = { class: "flex px-4 justify-between gap-4 items-center mb-2 min-h-32px" }, Ie = ["for"], Ke = ["id", "value", "aria-label"], Ee = /* @__PURE__ */ M({
|
|
218
227
|
__name: "TextControl",
|
|
219
228
|
props: {
|
|
220
229
|
label: {},
|
|
221
230
|
control: {}
|
|
222
231
|
},
|
|
223
232
|
emits: ["change"],
|
|
224
|
-
setup(
|
|
225
|
-
function t(
|
|
226
|
-
const { target:
|
|
227
|
-
|
|
233
|
+
setup(n, { emit: l }) {
|
|
234
|
+
function t(e) {
|
|
235
|
+
const { target: a } = e;
|
|
236
|
+
l("change", a.value);
|
|
228
237
|
}
|
|
229
|
-
return (
|
|
230
|
-
|
|
231
|
-
for:
|
|
238
|
+
return (e, a) => (v(), _("div", De, [
|
|
239
|
+
d("label", {
|
|
240
|
+
for: e.control.uniqueKey,
|
|
232
241
|
class: "text-gray-500 w-1/3"
|
|
233
|
-
},
|
|
234
|
-
|
|
235
|
-
id:
|
|
236
|
-
value:
|
|
242
|
+
}, k(e.label), 9, Ie),
|
|
243
|
+
d("input", {
|
|
244
|
+
id: e.control.uniqueKey,
|
|
245
|
+
value: e.control.value,
|
|
237
246
|
type: "text",
|
|
238
247
|
tabindex: "0",
|
|
239
248
|
class: "p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 border-none font-sans",
|
|
240
|
-
"aria-label":
|
|
249
|
+
"aria-label": e.label,
|
|
241
250
|
placeholder: "Enter value here...",
|
|
242
251
|
onChange: t
|
|
243
|
-
}, null, 40,
|
|
252
|
+
}, null, 40, Ke)
|
|
244
253
|
]));
|
|
245
254
|
}
|
|
246
|
-
}), Fe = { class: "flex px-4 justify-start gap-2 items-center mb-2 min-h-32px" }, Ve = { class: "text-gray-500 w-1/3" },
|
|
255
|
+
}), Fe = { class: "flex px-4 justify-start gap-2 items-center mb-2 min-h-32px" }, Ve = { class: "text-gray-500 w-1/3" }, qe = ["id", "checked"], Ue = ["for"], ze = ["aria-checked"], Oe = { class: "i-ic:baseline-check text-light" }, Xe = /* @__PURE__ */ M({
|
|
247
256
|
__name: "BooleanControl",
|
|
248
257
|
props: {
|
|
249
258
|
label: {},
|
|
250
259
|
control: {}
|
|
251
260
|
},
|
|
252
261
|
emits: ["change"],
|
|
253
|
-
setup(
|
|
254
|
-
const t =
|
|
255
|
-
function
|
|
256
|
-
const { target:
|
|
257
|
-
|
|
262
|
+
setup(n, { emit: l }) {
|
|
263
|
+
const t = n;
|
|
264
|
+
function e(r) {
|
|
265
|
+
const { target: i } = r;
|
|
266
|
+
l("change", i.checked);
|
|
258
267
|
}
|
|
259
|
-
function r
|
|
260
|
-
(
|
|
268
|
+
function a(r) {
|
|
269
|
+
(r.code === "Space" || r.code === "Enter") && (r.preventDefault(), l("change", !t.control.value));
|
|
261
270
|
}
|
|
262
|
-
return (
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
id:
|
|
266
|
-
checked:
|
|
271
|
+
return (r, i) => (v(), _("div", Fe, [
|
|
272
|
+
d("label", Ve, k(r.label), 1),
|
|
273
|
+
d("input", {
|
|
274
|
+
id: r.control.uniqueKey,
|
|
275
|
+
checked: r.control.value,
|
|
267
276
|
class: "hidden",
|
|
268
277
|
type: "checkbox",
|
|
269
|
-
onInput:
|
|
270
|
-
}, null, 40,
|
|
271
|
-
|
|
272
|
-
for:
|
|
278
|
+
onInput: e
|
|
279
|
+
}, null, 40, qe),
|
|
280
|
+
d("label", {
|
|
281
|
+
for: r.control.uniqueKey,
|
|
273
282
|
class: "inline-flex items-center cursor-pointer"
|
|
274
283
|
}, [
|
|
275
|
-
|
|
284
|
+
d("span", {
|
|
276
285
|
tabindex: "0",
|
|
277
286
|
role: "checkbox",
|
|
278
|
-
"aria-checked":
|
|
279
|
-
class:
|
|
280
|
-
onKeydown:
|
|
287
|
+
"aria-checked": r.control.value.toString(),
|
|
288
|
+
class: S([{ "bg-dark-500": r.control.value, "bg-gray-200": !r.control.value }, "w-4 h-4 flex justify-center items-center rounded border border-gray-300 mr-2 transition-colors duration-200"]),
|
|
289
|
+
onKeydown: a
|
|
281
290
|
}, [
|
|
282
|
-
J(
|
|
283
|
-
[Q,
|
|
291
|
+
J(d("i", Oe, null, 512), [
|
|
292
|
+
[Q, r.control.value]
|
|
284
293
|
])
|
|
285
|
-
], 42,
|
|
286
|
-
], 8,
|
|
294
|
+
], 42, ze)
|
|
295
|
+
], 8, Ue)
|
|
287
296
|
]));
|
|
288
297
|
}
|
|
289
|
-
}),
|
|
298
|
+
}), Le = { class: "px-4 relative flex justify-between gap-4 items-center mb-2" }, Pe = ["value", "min", "max", "step"], Ne = ["value", "min", "max", "step"], We = /* @__PURE__ */ M({
|
|
290
299
|
__name: "SliderControl",
|
|
291
300
|
props: {
|
|
292
301
|
label: {},
|
|
293
302
|
control: {}
|
|
294
303
|
},
|
|
295
304
|
emits: ["change"],
|
|
296
|
-
setup(
|
|
297
|
-
const t =
|
|
298
|
-
function
|
|
299
|
-
const { target:
|
|
300
|
-
|
|
305
|
+
setup(n, { emit: l }) {
|
|
306
|
+
const t = n;
|
|
307
|
+
function e(o) {
|
|
308
|
+
const { target: u } = o;
|
|
309
|
+
l("change", u.valueAsNumber);
|
|
301
310
|
}
|
|
302
|
-
const
|
|
311
|
+
const a = K(() => ({
|
|
303
312
|
backgroundImage: `linear-gradient(to right, #333 0% ${100 * (t.control.value - (t.control.min || 0)) / ((t.control.max || 100) - (t.control.min || 0))}%, #e2e2e2 0%)`
|
|
304
|
-
})),
|
|
305
|
-
|
|
313
|
+
})), r = R(), i = y(0), f = y(!1), p = (o) => {
|
|
314
|
+
i.value = o.clientX, f.value = !0;
|
|
306
315
|
}, w = () => {
|
|
307
|
-
|
|
308
|
-
},
|
|
309
|
-
return
|
|
310
|
-
if (
|
|
311
|
-
const
|
|
312
|
-
|
|
316
|
+
f.value = !1;
|
|
317
|
+
}, c = (o) => Math.floor(Math.abs(o) / 10);
|
|
318
|
+
return N(r.x, (o) => {
|
|
319
|
+
if (f.value) {
|
|
320
|
+
const u = o - i.value, h = c(u);
|
|
321
|
+
u > 0 ? l("change", t.control.value + 1 + h) : u < 0 && l("change", t.control.value - 1 + h), t.control.min !== void 0 && t.control.value < t.control.min && l("change", t.control.min), t.control.max !== void 0 && t.control.value > t.control.max && l("change", t.control.max), i.value = o;
|
|
313
322
|
}
|
|
314
|
-
}), (o,
|
|
315
|
-
|
|
316
|
-
class:
|
|
323
|
+
}), (o, u) => (v(), _("div", Le, [
|
|
324
|
+
d("label", {
|
|
325
|
+
class: S(["text-gray-500 w-1/3", { "flex justify-between items-center": o.control.icon }])
|
|
317
326
|
}, [
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
class:
|
|
327
|
+
de(k(o.label) + " ", 1),
|
|
328
|
+
d("i", {
|
|
329
|
+
class: S(`i-${o.control.icon}`)
|
|
321
330
|
}, null, 2)
|
|
322
331
|
], 2),
|
|
323
|
-
|
|
332
|
+
d("input", {
|
|
324
333
|
value: o.control.value,
|
|
325
334
|
class: "w-1/2 h-0.75 bg-dark-200 rounded-full appearance-none",
|
|
326
|
-
style:
|
|
335
|
+
style: fe(a.value),
|
|
327
336
|
type: "range",
|
|
328
337
|
min: o.control.min,
|
|
329
338
|
max: o.control.max,
|
|
330
339
|
step: o.control.step,
|
|
331
|
-
onInput:
|
|
332
|
-
}, null, 44,
|
|
333
|
-
|
|
340
|
+
onInput: e
|
|
341
|
+
}, null, 44, Pe),
|
|
342
|
+
d("input", {
|
|
334
343
|
value: o.control.value,
|
|
335
|
-
class:
|
|
344
|
+
class: S(["p-2 w-1/4 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans", { "cursor-ew-resize": f.value }]),
|
|
336
345
|
type: "number",
|
|
337
346
|
min: o.control.min,
|
|
338
347
|
max: o.control.max,
|
|
339
348
|
step: o.control.step,
|
|
340
|
-
onInput:
|
|
341
|
-
onMousedown:
|
|
349
|
+
onInput: e,
|
|
350
|
+
onMousedown: p,
|
|
342
351
|
onMouseup: w
|
|
343
352
|
}, null, 42, Ne)
|
|
344
353
|
]));
|
|
345
354
|
}
|
|
346
355
|
});
|
|
347
|
-
const je = (
|
|
348
|
-
const t =
|
|
349
|
-
for (const [
|
|
350
|
-
t[
|
|
356
|
+
const je = (n, l) => {
|
|
357
|
+
const t = n.__vccOpts || n;
|
|
358
|
+
for (const [e, a] of l)
|
|
359
|
+
t[e] = a;
|
|
351
360
|
return t;
|
|
352
|
-
}, Be = /* @__PURE__ */ je(We, [["__scopeId", "data-v-9e6267fe"]]), Re = { class: "flex px-4 justify-between gap-4 items-center mb-2" }, Ye = { class: "text-gray-500 w-1/3" }, He = ["id", "value", "aria-label"], Ge = ["id", "aria-label", "value"],
|
|
361
|
+
}, Be = /* @__PURE__ */ je(We, [["__scopeId", "data-v-9e6267fe"]]), Re = { class: "flex px-4 justify-between gap-4 items-center mb-2" }, Ye = { class: "text-gray-500 w-1/3" }, He = ["id", "value", "aria-label"], Ge = ["id", "aria-label", "value"], Je = /* @__PURE__ */ M({
|
|
353
362
|
__name: "ColorControl",
|
|
354
363
|
props: {
|
|
355
364
|
label: {},
|
|
356
365
|
control: {}
|
|
357
366
|
},
|
|
358
367
|
emits: ["change"],
|
|
359
|
-
setup(
|
|
360
|
-
function t(
|
|
361
|
-
const { target:
|
|
362
|
-
|
|
368
|
+
setup(n, { emit: l }) {
|
|
369
|
+
function t(e) {
|
|
370
|
+
const { target: a } = e;
|
|
371
|
+
l("change", a.value);
|
|
363
372
|
}
|
|
364
|
-
return (
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
id:
|
|
373
|
+
return (e, a) => (v(), _("div", Re, [
|
|
374
|
+
d("label", Ye, k(e.label), 1),
|
|
375
|
+
d("input", {
|
|
376
|
+
id: e.control.uniqueKey,
|
|
368
377
|
tabindex: "0",
|
|
369
|
-
value:
|
|
370
|
-
"aria-label":
|
|
371
|
-
class:
|
|
378
|
+
value: e.control.value,
|
|
379
|
+
"aria-label": e.label,
|
|
380
|
+
class: S(["focus:outline-none focus:ring-2 focus:ring-blue-600", { "important-outline-gray-200": e.control.value === "#ffffff" }]),
|
|
372
381
|
type: "color",
|
|
373
382
|
onInput: t
|
|
374
383
|
}, null, 42, He),
|
|
375
|
-
|
|
376
|
-
id:
|
|
384
|
+
d("input", {
|
|
385
|
+
id: e.control.uniqueKey,
|
|
377
386
|
tabindex: "0",
|
|
378
|
-
"aria-label":
|
|
379
|
-
value:
|
|
387
|
+
"aria-label": e.label,
|
|
388
|
+
value: e.control.value,
|
|
380
389
|
class: "p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 border-none font-sans",
|
|
381
390
|
type: "text",
|
|
382
391
|
onInput: t
|
|
@@ -384,227 +393,233 @@ const je = (e, a) => {
|
|
|
384
393
|
]));
|
|
385
394
|
}
|
|
386
395
|
});
|
|
387
|
-
function
|
|
388
|
-
if (typeof
|
|
389
|
-
return [
|
|
390
|
-
if (oe(
|
|
391
|
-
const { x:
|
|
392
|
-
return [
|
|
396
|
+
function Qe(n) {
|
|
397
|
+
if (typeof n == "number")
|
|
398
|
+
return [n, n, n];
|
|
399
|
+
if (oe(n)) {
|
|
400
|
+
const { x: l, y: t, z: e } = n;
|
|
401
|
+
return [l, t, e];
|
|
393
402
|
}
|
|
394
|
-
return
|
|
403
|
+
return n;
|
|
395
404
|
}
|
|
396
|
-
function
|
|
397
|
-
return
|
|
405
|
+
function Ze(n) {
|
|
406
|
+
return n && typeof n.x == "number" && typeof n.y == "number" && typeof n.z > "u";
|
|
398
407
|
}
|
|
399
|
-
function oe(
|
|
400
|
-
return
|
|
408
|
+
function oe(n) {
|
|
409
|
+
return n && typeof n.x == "number" && typeof n.y == "number" && typeof n.z == "number";
|
|
401
410
|
}
|
|
402
|
-
const
|
|
411
|
+
const en = { class: "text-gray-500 w-1/3" }, nn = { class: "w-2/3 flex justify-between gap-0.5" }, tn = {
|
|
403
412
|
key: 0,
|
|
404
413
|
class: "font-bold px-1 py-1 text-0.65rem text-gray-300"
|
|
405
|
-
},
|
|
414
|
+
}, on = ["id", "value", "onInput", "onMousedown", "onMouseup"], ln = /* @__PURE__ */ M({
|
|
406
415
|
__name: "VectorControl",
|
|
407
416
|
props: {
|
|
408
417
|
label: {},
|
|
409
418
|
control: {}
|
|
410
419
|
},
|
|
411
420
|
emits: ["change"],
|
|
412
|
-
setup(
|
|
413
|
-
const t =
|
|
414
|
-
|
|
415
|
-
},
|
|
416
|
-
|
|
421
|
+
setup(n, { emit: l }) {
|
|
422
|
+
const t = n, e = R(), a = y(0), r = y(!1), i = y(0), f = (s, m) => {
|
|
423
|
+
i.value = m, a.value = s.clientX, r.value = !0;
|
|
424
|
+
}, p = (s, m) => {
|
|
425
|
+
i.value = m, r.value = !1;
|
|
417
426
|
}, w = () => {
|
|
418
|
-
|
|
419
|
-
},
|
|
420
|
-
function
|
|
421
|
-
const { value:
|
|
422
|
-
|
|
427
|
+
r.value = !1;
|
|
428
|
+
}, c = (s) => Math.floor(Math.abs(s) / 10), o = K(() => Qe(t.control.value)), u = y(["x", "y", "z"]), h = K(() => Ze(t.control.value) || oe(t.control.value));
|
|
429
|
+
function T(s, m) {
|
|
430
|
+
const { value: $ } = t.control, { target: g } = s;
|
|
431
|
+
i.value = m, $[h.value ? u.value[i.value] : i.value] = parseFloat(g.value), l("change", $);
|
|
423
432
|
}
|
|
424
|
-
return
|
|
425
|
-
if (
|
|
426
|
-
const
|
|
427
|
-
|
|
433
|
+
return N(e.x, (s) => {
|
|
434
|
+
if (r.value) {
|
|
435
|
+
const m = s - a.value, $ = c(m), { value: g } = t.control, x = h.value ? u.value[i.value] : i.value;
|
|
436
|
+
m > 0 ? g[x] += 0.1 + $ : m < 0 && (g[x] -= 0.1 + $), t.control.min !== void 0 && g < t.control.min && (g[x] = t.control.min), t.control.max !== void 0 && g > t.control.max && (g[x] = t.control.max), l("change", g), a.value = s;
|
|
428
437
|
}
|
|
429
|
-
}), (
|
|
438
|
+
}), (s, m) => (v(), _("div", {
|
|
430
439
|
class: "flex px-4 justify-between gap-1 items-center mb-2",
|
|
431
|
-
onMouseup:
|
|
440
|
+
onMouseup: m[0] || (m[0] = ($) => w())
|
|
432
441
|
}, [
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
(
|
|
436
|
-
key:
|
|
442
|
+
d("label", en, k(s.label), 1),
|
|
443
|
+
d("div", nn, [
|
|
444
|
+
(v(!0), _(I, null, O(o.value, ($, g) => (v(), _("div", {
|
|
445
|
+
key: s.label + g,
|
|
437
446
|
class: "flex items-center w-1/3 bg-gray-100 rounded"
|
|
438
447
|
}, [
|
|
439
|
-
|
|
440
|
-
|
|
448
|
+
u.value[g] && h.value ? (v(), _("span", tn, k(u.value[g]), 1)) : P("", !0),
|
|
449
|
+
d("input", {
|
|
450
|
+
id: `${s.control.uniqueKey}-${u.value[g]}`,
|
|
441
451
|
type: "number",
|
|
442
452
|
step: "0.1",
|
|
443
|
-
class:
|
|
453
|
+
class: S(["w-full px-0 p-1 text-right text-0.65rem text-gray-400 bg-transparent focus:border-gray-200 outline-none border-none font-sans appearence-none", { "cursor-ew-resize": r.value }]),
|
|
444
454
|
value: o.value[g].toFixed(2),
|
|
445
|
-
onInput: (
|
|
446
|
-
onMousedown: (
|
|
447
|
-
onMouseup: (
|
|
448
|
-
}, null, 42,
|
|
455
|
+
onInput: (x) => T(x, g),
|
|
456
|
+
onMousedown: (x) => f(x, g),
|
|
457
|
+
onMouseup: (x) => p(x, g)
|
|
458
|
+
}, null, 42, on)
|
|
449
459
|
]))), 128))
|
|
450
460
|
])
|
|
451
461
|
], 32));
|
|
452
462
|
}
|
|
453
|
-
}),
|
|
463
|
+
}), an = { class: "flex px-4 justify-between gap-4 items-center mb-2" }, rn = { class: "text-gray-500 w-1/3" }, sn = { class: "relative w-2/3 p-1 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans" }, cn = { class: "absolute bottom-0.5 right-0.5 font-sans text-xs" }, un = ["points"], Y = 160, B = 40, U = 2, H = 100, G = 20, dn = /* @__PURE__ */ M({
|
|
454
464
|
__name: "FPSGraph",
|
|
455
465
|
props: {
|
|
456
466
|
label: {},
|
|
457
467
|
control: {}
|
|
458
468
|
},
|
|
459
|
-
setup(
|
|
460
|
-
const
|
|
461
|
-
let
|
|
462
|
-
return
|
|
463
|
-
|
|
464
|
-
(
|
|
469
|
+
setup(n) {
|
|
470
|
+
const l = be({ every: H }), t = y(""), e = y([]), a = y(Y / U);
|
|
471
|
+
let r = performance.now();
|
|
472
|
+
return he(({ timestamp: i }) => {
|
|
473
|
+
i - r >= H && (r = i, e.value.push(l.value), e.value.length > a.value && e.value.shift(), t.value = e.value.map(
|
|
474
|
+
(f, p) => `${p * U},${B + G - U / 2 - f * (B + G - U) / 120}`
|
|
465
475
|
).join(" "));
|
|
466
|
-
}), (
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
(
|
|
471
|
-
width:
|
|
472
|
-
height:
|
|
476
|
+
}), (i, f) => (v(), _("div", an, [
|
|
477
|
+
d("label", rn, k(i.label), 1),
|
|
478
|
+
d("div", sn, [
|
|
479
|
+
d("div", cn, k(Math.round(A(l))) + " FPS ", 1),
|
|
480
|
+
(v(), _("svg", {
|
|
481
|
+
width: Y,
|
|
482
|
+
height: B,
|
|
473
483
|
xmlns: "http://www.w3.org/2000/svg",
|
|
474
484
|
class: "bg-gray-100"
|
|
475
485
|
}, [
|
|
476
|
-
|
|
486
|
+
d("polyline", {
|
|
477
487
|
points: t.value,
|
|
478
488
|
fill: "none",
|
|
479
489
|
stroke: "lightgray",
|
|
480
490
|
"stroke-width": U,
|
|
481
491
|
"stroke-linecap": "round",
|
|
482
492
|
"stroke-linejoin": "round"
|
|
483
|
-
}, null, 8,
|
|
493
|
+
}, null, 8, un)
|
|
484
494
|
]))
|
|
485
495
|
])
|
|
486
496
|
]));
|
|
487
497
|
}
|
|
488
|
-
}),
|
|
498
|
+
}), fn = { class: "flex px-4 justify-between gap-4 items-center mb-2 min-h-32px" }, pn = ["for"], vn = ["id", "value"], gn = ["value"], yn = /* @__PURE__ */ M({
|
|
489
499
|
__name: "SelectControl",
|
|
490
500
|
props: {
|
|
491
501
|
label: {},
|
|
492
502
|
control: {}
|
|
493
503
|
},
|
|
494
504
|
emits: ["change"],
|
|
495
|
-
setup(
|
|
496
|
-
function t(
|
|
497
|
-
|
|
505
|
+
setup(n, { emit: l }) {
|
|
506
|
+
function t(e) {
|
|
507
|
+
l("change", e.target.value);
|
|
498
508
|
}
|
|
499
|
-
return (
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
509
|
+
return (e, a) => (v(), _("div", fn, [
|
|
510
|
+
d("label", {
|
|
511
|
+
class: "text-gray-500 w-1/3",
|
|
512
|
+
for: e.control.uniqueKey
|
|
513
|
+
}, k(e.label), 9, pn),
|
|
514
|
+
d("select", {
|
|
515
|
+
id: e.control.uniqueKey,
|
|
516
|
+
value: e.control.value,
|
|
503
517
|
class: "p-2 w-2/3 rounded text-left text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",
|
|
504
518
|
onChange: t
|
|
505
519
|
}, [
|
|
506
|
-
(
|
|
507
|
-
key:
|
|
508
|
-
value:
|
|
509
|
-
},
|
|
510
|
-
], 40,
|
|
520
|
+
(v(!0), _(I, null, O(e.control.options, (r) => (v(), _("option", {
|
|
521
|
+
key: r.value,
|
|
522
|
+
value: r.value
|
|
523
|
+
}, k(r.text), 9, gn))), 128))
|
|
524
|
+
], 40, vn)
|
|
511
525
|
]));
|
|
512
526
|
}
|
|
513
|
-
}), le = /* @__PURE__ */
|
|
527
|
+
}), le = /* @__PURE__ */ M({
|
|
514
528
|
__name: "ControlInput",
|
|
515
529
|
props: {
|
|
516
530
|
control: {}
|
|
517
531
|
},
|
|
518
532
|
emits: ["change"],
|
|
519
|
-
setup(
|
|
520
|
-
function t(
|
|
521
|
-
|
|
533
|
+
setup(n, { emit: l }) {
|
|
534
|
+
function t(e) {
|
|
535
|
+
l("change", e);
|
|
522
536
|
}
|
|
523
|
-
return (
|
|
524
|
-
|
|
537
|
+
return (e, a) => e.control.visible ? (v(), _(I, { key: 0 }, [
|
|
538
|
+
e.control.type === "color" ? (v(), C(Je, {
|
|
525
539
|
key: 0,
|
|
526
|
-
label:
|
|
527
|
-
control:
|
|
540
|
+
label: e.control.label,
|
|
541
|
+
control: e.control,
|
|
528
542
|
onChange: t
|
|
529
|
-
}, null, 8, ["label", "control"])) :
|
|
543
|
+
}, null, 8, ["label", "control"])) : e.control.type === "select" ? (v(), C(yn, {
|
|
530
544
|
key: 1,
|
|
531
|
-
label:
|
|
532
|
-
control:
|
|
545
|
+
label: e.control.label,
|
|
546
|
+
control: e.control,
|
|
533
547
|
onChange: t
|
|
534
|
-
}, null, 8, ["label", "control"])) :
|
|
548
|
+
}, null, 8, ["label", "control"])) : e.control.type === "vector" ? (v(), C(ln, {
|
|
535
549
|
key: 2,
|
|
536
|
-
label:
|
|
537
|
-
control:
|
|
550
|
+
label: e.control.label,
|
|
551
|
+
control: e.control,
|
|
538
552
|
onChange: t
|
|
539
|
-
}, null, 8, ["label", "control"])) :
|
|
553
|
+
}, null, 8, ["label", "control"])) : e.control.type === "boolean" ? (v(), C(Xe, {
|
|
540
554
|
key: 3,
|
|
541
|
-
label:
|
|
542
|
-
control:
|
|
555
|
+
label: e.control.label,
|
|
556
|
+
control: e.control,
|
|
543
557
|
onChange: t
|
|
544
|
-
}, null, 8, ["label", "control"])) :
|
|
558
|
+
}, null, 8, ["label", "control"])) : e.control.type === "fpsgraph" ? (v(), C(dn, {
|
|
545
559
|
key: 4,
|
|
546
|
-
label:
|
|
547
|
-
control:
|
|
548
|
-
}, null, 8, ["label", "control"])) :
|
|
560
|
+
label: e.control.label,
|
|
561
|
+
control: e.control
|
|
562
|
+
}, null, 8, ["label", "control"])) : e.control.type === "number" ? (v(), C(Ae, {
|
|
549
563
|
key: 5,
|
|
550
|
-
label:
|
|
551
|
-
control:
|
|
564
|
+
label: e.control.label,
|
|
565
|
+
control: e.control,
|
|
552
566
|
onChange: t
|
|
553
|
-
}, null, 8, ["label", "control"])) :
|
|
567
|
+
}, null, 8, ["label", "control"])) : e.control.type === "range" ? (v(), C(Be, {
|
|
554
568
|
key: 6,
|
|
555
|
-
label:
|
|
556
|
-
control:
|
|
569
|
+
label: e.control.label,
|
|
570
|
+
control: e.control,
|
|
557
571
|
onChange: t
|
|
558
|
-
}, null, 8, ["label", "control"])) : (
|
|
572
|
+
}, null, 8, ["label", "control"])) : (v(), C(Ee, {
|
|
559
573
|
key: 7,
|
|
560
|
-
label:
|
|
561
|
-
control:
|
|
574
|
+
label: e.control.label,
|
|
575
|
+
control: e.control,
|
|
562
576
|
onChange: t
|
|
563
577
|
}, null, 8, ["label", "control"]))
|
|
564
|
-
], 64)) :
|
|
578
|
+
], 64)) : P("", !0);
|
|
565
579
|
}
|
|
566
|
-
}), bn = { class: "mb-4" }, hn = ["aria-expanded"],
|
|
580
|
+
}), bn = { class: "mb-4" }, hn = ["aria-expanded", "data-folder"], mn = {
|
|
567
581
|
class: "bg-white rounded-b pt-4",
|
|
568
582
|
role: "menu"
|
|
569
|
-
},
|
|
583
|
+
}, _n = /* @__PURE__ */ M({
|
|
570
584
|
__name: "Folder",
|
|
571
585
|
props: {
|
|
572
586
|
controls: {},
|
|
573
587
|
label: {}
|
|
574
588
|
},
|
|
575
|
-
setup(
|
|
576
|
-
function a
|
|
577
|
-
|
|
589
|
+
setup(n) {
|
|
590
|
+
function l(a, r) {
|
|
591
|
+
r.value = a;
|
|
578
592
|
}
|
|
579
|
-
const t =
|
|
593
|
+
const t = y(!1), e = () => {
|
|
580
594
|
t.value = !t.value;
|
|
581
595
|
};
|
|
582
|
-
return (
|
|
583
|
-
|
|
596
|
+
return (a, r) => (v(), _("div", bn, [
|
|
597
|
+
d("button", {
|
|
584
598
|
class: "flex items-center justify-between w-full py-2 px-4 bg-gray-100 border-none text-gray-400 font-bold text-xs font-sans cursor-pointer",
|
|
585
599
|
"aria-expanded": t.value,
|
|
586
600
|
"aria-haspopup": "true",
|
|
587
601
|
role: "button",
|
|
602
|
+
"data-folder": a.label,
|
|
588
603
|
tabindex: "0",
|
|
589
|
-
onClick:
|
|
604
|
+
onClick: e
|
|
590
605
|
}, [
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
class:
|
|
606
|
+
d("span", null, k(a.label), 1),
|
|
607
|
+
d("i", {
|
|
608
|
+
class: S(t.value ? "i-ic:baseline-keyboard-arrow-up" : "i-ic:baseline-keyboard-arrow-down")
|
|
594
609
|
}, null, 2)
|
|
595
610
|
], 8, hn),
|
|
596
|
-
|
|
611
|
+
pe(ve, {
|
|
597
612
|
name: "slide",
|
|
598
613
|
"enter-active-class": " animate-fade-in animate-duration-200 animate-ease-in-out",
|
|
599
614
|
"leave-active-class": " animate-fade-out animate-duration-200 animate-ease-in-out"
|
|
600
615
|
}, {
|
|
601
616
|
default: Z(() => [
|
|
602
|
-
J(
|
|
603
|
-
(
|
|
604
|
-
key:
|
|
605
|
-
control:
|
|
617
|
+
J(d("div", mn, [
|
|
618
|
+
(v(!0), _(I, null, O(a.controls, (i) => (v(), C(le, {
|
|
619
|
+
key: i.label,
|
|
620
|
+
control: i,
|
|
606
621
|
role: "menuitem",
|
|
607
|
-
onChange: (
|
|
622
|
+
onChange: (f) => l(f, i)
|
|
608
623
|
}, null, 8, ["control", "onChange"]))), 128))
|
|
609
624
|
], 512), [
|
|
610
625
|
[Q, t.value]
|
|
@@ -614,59 +629,59 @@ const Ze = { class: "text-gray-500 w-1/3" }, en = { class: "w-2/3 flex justify-b
|
|
|
614
629
|
})
|
|
615
630
|
]));
|
|
616
631
|
}
|
|
617
|
-
}),
|
|
632
|
+
}), xn = {
|
|
618
633
|
tabindex: "0",
|
|
619
634
|
class: "bg-white shadow-xl rounded border-4 border-solid border-black"
|
|
620
|
-
},
|
|
621
|
-
/* @__PURE__ */
|
|
622
|
-
/* @__PURE__ */
|
|
623
|
-
/* @__PURE__ */
|
|
624
|
-
], -1),
|
|
625
|
-
xn,
|
|
635
|
+
}, wn = /* @__PURE__ */ d("i", { class: "h-4 w-4 p-1.5 flex items-center line-height-0 rounded-full bg-gray-100 text-xs" }, "🍰", -1), $n = /* @__PURE__ */ d("div", null, [
|
|
636
|
+
/* @__PURE__ */ d("i", { class: "i-ic-baseline-drag-indicator" }),
|
|
637
|
+
/* @__PURE__ */ d("i", { class: "i-ic-baseline-drag-indicator" }),
|
|
638
|
+
/* @__PURE__ */ d("i", { class: "i-ic-baseline-drag-indicator" })
|
|
639
|
+
], -1), Cn = /* @__PURE__ */ d("div", null, null, -1), kn = [
|
|
626
640
|
wn,
|
|
627
|
-
$n
|
|
628
|
-
|
|
641
|
+
$n,
|
|
642
|
+
Cn
|
|
643
|
+
], Mn = 280, Dn = /* @__PURE__ */ M({
|
|
629
644
|
__name: "TresLeches",
|
|
630
645
|
props: {
|
|
631
646
|
uuid: {}
|
|
632
647
|
},
|
|
633
|
-
setup(
|
|
634
|
-
const
|
|
635
|
-
function
|
|
636
|
-
|
|
648
|
+
setup(n) {
|
|
649
|
+
const l = n, { uuid: t } = E(l), { width: e } = ee(), a = y(null), r = Ce(t == null ? void 0 : t.value);
|
|
650
|
+
function i(p, w) {
|
|
651
|
+
r[A(p)].value = w, r[A(p)][A(p)] = w;
|
|
637
652
|
}
|
|
638
|
-
const
|
|
639
|
-
const
|
|
640
|
-
for (const w in
|
|
641
|
-
const
|
|
642
|
-
|
|
653
|
+
const f = K(() => {
|
|
654
|
+
const p = {};
|
|
655
|
+
for (const w in r) {
|
|
656
|
+
const c = r[w], o = c.folder || "default";
|
|
657
|
+
p[o] || (p[o] = []), p[o].push(c);
|
|
643
658
|
}
|
|
644
|
-
return
|
|
659
|
+
return p;
|
|
645
660
|
});
|
|
646
|
-
return (
|
|
647
|
-
id:
|
|
648
|
-
"initial-value": { x:
|
|
649
|
-
class:
|
|
650
|
-
handle:
|
|
661
|
+
return (p, w) => (v(), C(A(we), {
|
|
662
|
+
id: A(t),
|
|
663
|
+
"initial-value": { x: A(e) - Mn - 40, y: 10 },
|
|
664
|
+
class: S(["absolute select-none z-24 w-280px font-sans text-xs", p.$attrs.class]),
|
|
665
|
+
handle: a.value
|
|
651
666
|
}, {
|
|
652
667
|
default: Z(() => [
|
|
653
|
-
|
|
654
|
-
|
|
668
|
+
d("div", xn, [
|
|
669
|
+
d("header", {
|
|
655
670
|
ref_key: "handle",
|
|
656
|
-
ref:
|
|
671
|
+
ref: a,
|
|
657
672
|
class: "relative cursor-grabbing p-4 flex justify-between text-gray-200 relative"
|
|
658
|
-
},
|
|
659
|
-
(
|
|
660
|
-
o !== "default" ? (
|
|
673
|
+
}, kn, 512),
|
|
674
|
+
(v(!0), _(I, null, O(f.value, (c, o) => (v(), _(I, { key: o }, [
|
|
675
|
+
o !== "default" ? (v(), C(_n, {
|
|
661
676
|
key: 0,
|
|
662
677
|
label: o,
|
|
663
|
-
controls:
|
|
664
|
-
}, null, 8, ["label", "controls"])) :
|
|
665
|
-
o === "default" ? (
|
|
666
|
-
key:
|
|
667
|
-
control:
|
|
668
|
-
onChange: (
|
|
669
|
-
}, null, 8, ["control", "onChange"]))), 128)) :
|
|
678
|
+
controls: c
|
|
679
|
+
}, null, 8, ["label", "controls"])) : P("", !0),
|
|
680
|
+
o === "default" ? (v(!0), _(I, { key: 1 }, O(c, (u) => (v(), C(le, {
|
|
681
|
+
key: u.label,
|
|
682
|
+
control: u,
|
|
683
|
+
onChange: (h) => i(u.key, h)
|
|
684
|
+
}, null, 8, ["control", "onChange"]))), 128)) : P("", !0)
|
|
670
685
|
], 64))), 128))
|
|
671
686
|
])
|
|
672
687
|
]),
|
|
@@ -676,6 +691,6 @@ const Ze = { class: "text-gray-500 w-1/3" }, en = { class: "w-2/3 flex justify-b
|
|
|
676
691
|
});
|
|
677
692
|
export {
|
|
678
693
|
Dn as TresLeches,
|
|
679
|
-
|
|
694
|
+
An as useControls,
|
|
680
695
|
Ce as useControlsProvider
|
|
681
696
|
};
|
package/dist/tresleches.umd.cjs
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* name: @tresjs/leches
|
|
3
|
-
* version: v0.
|
|
3
|
+
* version: v0.11.0
|
|
4
4
|
* (c) 2023
|
|
5
5
|
* description: Tasty GUI for Vue controls 🍰
|
|
6
6
|
* author: Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)
|
|
7
7
|
*/
|
|
8
|
-
(function(E,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],e):(E=typeof globalThis<"u"?globalThis:E||self,e(E.tresleches={},E.Vue,E.VueUseCore))})(this,function(E,e,x){"use strict";const Ke="";function C(t){return typeof t=="function"?t():e.unref(t)}const T=typeof window<"u"&&typeof document<"u";function U(t,a={}){if(!e.isRef(t))return e.toRefs(t);const o=Array.isArray(t.value)?Array.from({length:t.value.length}):{};for(const n in t.value)o[n]=e.customRef(()=>({get(){return t.value[n]},set(s){var r;if((r=C(a.replaceRef))!=null?r:!0)if(Array.isArray(t.value)){const p=[...t.value];p[n]=s,t.value=p}else{const p={...t.value,[n]:s};Object.setPrototypeOf(p,Object.getPrototypeOf(t.value)),t.value=p}else t.value[n]=s}}));return o}const P=T?window:void 0;function X(t,a={}){const{pointerTypes:o,preventDefault:n,stopPropagation:s,exact:r,onMove:c,onEnd:p,onStart:f,initialValue:_,axis:d="both",draggingElement:l=P,handle:i=t}=a,{width:k}=x.useWindowSize();let b=k.value;const g=e.ref(C(_)??{x:0,y:0});e.watch(k,()=>{const m=k.value-b;g.value.x+=m,b=k.value});const h=e.ref(),y=m=>o?o.includes(m.pointerType):!0,u=m=>{C(n)&&m.preventDefault(),C(s)&&m.stopPropagation()},w=m=>{if(!y(m)||C(r)&&m.target!==C(t))return;const $=C(t).getBoundingClientRect(),N={x:m.clientX-$.left,y:m.clientY-$.top};(f==null?void 0:f(N,m))!==!1&&(h.value=N,u(m))},je=m=>{if(!y(m)||!h.value)return;let{x:$,y:N}=g.value;(d==="x"||d==="both")&&($=m.clientX-h.value.x),(d==="y"||d==="both")&&(N=m.clientY-h.value.y),g.value={x:$,y:N},c==null||c(g.value,m),u(m)},We=m=>{y(m)&&h.value&&(h.value=void 0,p==null||p(g.value,m),u(m))};if(T){const m={capture:a.capture??!0};x.useEventListener(i,"pointerdown",w,m),x.useEventListener(l,"pointermove",je,m),x.useEventListener(l,"pointerup",We,m)}return{...U(g),position:g,isDragging:e.computed(()=>!!h.value),style:e.computed(()=>`left:${g.value.x}px;top:${g.value.y}px;`)}}const j=e.defineComponent({name:"UseDraggable",props:["storageKey","storageType","initialValue","exact","preventDefault","stopPropagation","pointerTypes","as","handle","axis","onStart","onMove","onEnd"],setup(t,{slots:a}){const o=e.ref(),n=e.computed(()=>t.handle??o.value),s=t.storageKey&&x.useStorage(t.storageKey,C(t.initialValue)||{x:0,y:0},x.isClient?t.storageType==="session"?sessionStorage:localStorage:void 0),r=s||t.initialValue||{x:0,y:0},c=(f,_)=>{var d;(d=t.onEnd)==null||d.call(t,f,_),s&&(s.value.x=f.x,s.value.y=f.y)},p=e.reactive(X(o,{...t,handle:n,initialValue:r,onEnd:c}));return()=>{if(a.default)return e.h(t.as||"div",{ref:o,style:`touch-action:none;${p.style}`},a.default(p))}}}),W=Symbol("CONTROLS_CONTEXT_KEY"),F="default",B=e.reactive({});function z(t=F){return e.provide(W,B),B[t]}const D=t=>{const a=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$|^0x([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;return typeof t=="boolean"?"boolean":typeof t=="number"?"number":typeof t=="string"&&a.test(t)?"color":typeof t=="string"?"string":t.isVector3||t.isVector2||t.isEuler||t instanceof Array?"vector":t.min!==void 0||t.max!==void 0||t.step!==void 0?"range":t.options&&Array.isArray(t.options)?"select":"unknown"},S=(t,a,o,n)=>{const s={key:e.ref(t),label:e.ref(t),name:e.ref(t),type:e.ref(o),value:e.ref(a),visible:e.ref(!0),[t]:e.ref(a)};return n&&(s.folder=e.ref(n)),s},K=(t,a,o)=>{const n={},s=typeof t=="string"?t:null,r=s?a:t,c=s&&s!=="fpsgraph"?o:a,p=(c==null?void 0:c.uuid)||F;if(B[p]||(B[p]=e.reactive({})),t==="fpsgraph"){const l=S("fpsgraph",null,"fpsgraph",null);return B[p].fpsgraph=l,n.fpsgraph=l,e.toRefs(e.reactive(n))}const f=B[p],_=e.isReactive(r),d=_?e.toRefs(r):{};for(const l in r){let i=r[l];if(_&&d[l]&&(i=d[l]),typeof i=="object"&&!e.isRef(i)&&!Array.isArray(i)&&i.value!==void 0){const b=i,g=e.isRef(b.value)?b.value:e.ref(b.value),h=D(b),y=S(l,g,h,s);h==="select"&&(y.options=e.ref(b.options.map(u=>typeof u=="object"&&u.text&&u.value?u:{text:u,value:u}))),h==="range"&&(y.min=e.ref(b.min||0),y.max=e.ref(b.max||1),y.step=e.ref(b.step||.1)),y.label.value=b.label||l,y.visible.value=b.visible!==void 0?b.visible:!0,f[l]=y,n[l]=y;continue}if(e.isRef(i)){const b=S(l,i,D(i.value),s);f[l]=b,n[l]=b;continue}else if(typeof i=="object"&&!Array.isArray(i)){const b=e.toRefs(i);b[l]&&(i=b[l])}const k=S(l,i,D(i),s);f[l]=k,n[l]=k}return Object.keys(n).length>1?e.toRefs(e.reactive(n)):Object.values(n)[0]},Y={class:"flex px-4 justify-between gap-4 items-center mb-2"},q={class:"text-gray-500 w-1/3"},H=["value","min","max","step"],G=e.defineComponent({__name:"NumberControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){const o=t;function n(d){const{target:l}=d;a("change",l.valueAsNumber)}const s=x.useMouse(),r=e.ref(0),c=e.ref(!1),p=d=>{r.value=d.clientX,c.value=!0},f=()=>{c.value=!1},_=d=>Math.floor(Math.abs(d)/10);return e.watch(s.x,d=>{if(c.value){const l=d-r.value,i=_(l);l>0?a("change",o.control.value+1+i):l<0&&a("change",o.control.value-1+i),o.control.min!==void 0&&o.control.value<o.control.min&&a("change",o.control.min),o.control.max!==void 0&&o.control.value>o.control.max&&a("change",o.control.max),r.value=d}}),(d,l)=>(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("label",q,e.toDisplayString(d.label),1),e.createElementVNode("input",{value:d.control.value,class:e.normalizeClass(["p-2 w-1/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",{"cursor-ew-resize":c.value}]),type:"number",min:d.control.min,max:d.control.max,step:d.control.step,onInput:n,onMousedown:p,onMouseup:f},null,42,H)]))}}),v={class:"flex px-4 justify-between gap-4 items-center mb-2 min-h-32px"},J=["for"],Q=["id","value","aria-label"],Z=e.defineComponent({__name:"TextControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){function o(n){const{target:s}=n;a("change",s.value)}return(n,s)=>(e.openBlock(),e.createElementBlock("div",v,[e.createElementVNode("label",{for:`input-${n.label}`,class:"text-gray-500 w-1/3"},e.toDisplayString(n.label),9,J),e.createElementVNode("input",{id:`input-${n.label}`,value:n.control.value,type:"text",tabindex:"0",class:"p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 border-none font-sans","aria-label":n.label,placeholder:"Enter value here...",onChange:o},null,40,Q)]))}}),ee={class:"flex px-4 justify-start gap-2 items-center mb-2 min-h-32px"},te={class:"text-gray-500 w-1/3"},ne=["id","checked"],oe=["for"],le=["aria-checked"],re={class:"i-ic:baseline-check text-light"},ae=e.defineComponent({__name:"BooleanControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){const o=t;function n(r){const{target:c}=r;a("change",c.checked)}function s(r){(r.code==="Space"||r.code==="Enter")&&(r.preventDefault(),a("change",!o.control.value))}return(r,c)=>(e.openBlock(),e.createElementBlock("div",ee,[e.createElementVNode("label",te,e.toDisplayString(r.label),1),e.createElementVNode("input",{id:r.control.label,checked:r.control.value,class:"hidden",type:"checkbox",onInput:n},null,40,ne),e.createElementVNode("label",{for:r.control.label,class:"inline-flex items-center cursor-pointer"},[e.createElementVNode("span",{tabindex:"0",role:"checkbox","aria-checked":r.control.value.toString(),class:e.normalizeClass([{"bg-dark-500":r.control.value,"bg-gray-200":!r.control.value},"w-4 h-4 flex justify-center items-center rounded border border-gray-300 mr-2 transition-colors duration-200"]),onKeydown:s},[e.withDirectives(e.createElementVNode("i",re,null,512),[[e.vShow,r.control.value]])],42,le)],8,oe)]))}}),se={class:"px-4 relative flex justify-between gap-4 items-center mb-2"},ce=["value","min","max","step"],ie=["value","min","max","step"],de=e.defineComponent({__name:"SliderControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){const o=t;function n(l){const{target:i}=l;a("change",i.valueAsNumber)}const s=e.computed(()=>({backgroundImage:`linear-gradient(to right, #333 0% ${100*(o.control.value-(o.control.min||0))/((o.control.max||100)-(o.control.min||0))}%, #e2e2e2 0%)`})),r=x.useMouse(),c=e.ref(0),p=e.ref(!1),f=l=>{c.value=l.clientX,p.value=!0},_=()=>{p.value=!1},d=l=>Math.floor(Math.abs(l)/10);return e.watch(r.x,l=>{if(p.value){const i=l-c.value,k=d(i);i>0?a("change",o.control.value+1+k):i<0&&a("change",o.control.value-1+k),o.control.min!==void 0&&o.control.value<o.control.min&&a("change",o.control.min),o.control.max!==void 0&&o.control.value>o.control.max&&a("change",o.control.max),c.value=l}}),(l,i)=>(e.openBlock(),e.createElementBlock("div",se,[e.createElementVNode("label",{class:e.normalizeClass(["text-gray-500 w-1/3",{"flex justify-between items-center":l.control.icon}])},[e.createTextVNode(e.toDisplayString(l.label)+" ",1),e.createElementVNode("i",{class:e.normalizeClass(`i-${l.control.icon}`)},null,2)],2),e.createElementVNode("input",{value:l.control.value,class:"w-1/2 h-0.75 bg-dark-200 rounded-full appearance-none",style:e.normalizeStyle(s.value),type:"range",min:l.control.min,max:l.control.max,step:l.control.step,onInput:n},null,44,ce),e.createElementVNode("input",{value:l.control.value,class:e.normalizeClass(["p-2 w-1/4 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",{"cursor-ew-resize":p.value}]),type:"number",min:l.control.min,max:l.control.max,step:l.control.step,onInput:n,onMousedown:f,onMouseup:_},null,42,ie)]))}}),Ye="",pe=((t,a)=>{const o=t.__vccOpts||t;for(const[n,s]of a)o[n]=s;return o})(de,[["__scopeId","data-v-9e6267fe"]]),fe={class:"flex px-4 justify-between gap-4 items-center mb-2"},ue={class:"text-gray-500 w-1/3"},me=["id","value","aria-label"],ge=["id","aria-label","value"],he=e.defineComponent({__name:"ColorControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){function o(n){const{target:s}=n;a("change",s.value)}return(n,s)=>(e.openBlock(),e.createElementBlock("div",fe,[e.createElementVNode("label",ue,e.toDisplayString(n.label),1),e.createElementVNode("input",{id:`input-${n.label}`,tabindex:"0",value:n.control.value,"aria-label":n.label,class:e.normalizeClass(["focus:outline-none focus:ring-2 focus:ring-blue-600",{"important-outline-gray-200":n.control.value==="#ffffff"}]),type:"color",onInput:o},null,42,me),e.createElementVNode("input",{id:`input-${n.label}`,tabindex:"0","aria-label":n.label,value:n.control.value,class:"p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 border-none font-sans",type:"text",onInput:o},null,40,ge)]))}}),He="";function be(t){if(typeof t=="number")return[t,t,t];if(A(t)){const{x:a,y:o,z:n}=t;return[a,o,n]}return t}function ye(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z>"u"}function A(t){return t&&typeof t.x=="number"&&typeof t.y=="number"&&typeof t.z=="number"}const _e={class:"text-gray-500 w-1/3"},ke={class:"w-2/3 flex justify-between gap-0.5"},xe={key:0,class:"font-bold px-1 py-1 text-0.65rem text-gray-300"},we=["value","onInput","onMousedown","onMouseup"],Ee=e.defineComponent({__name:"VectorControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){const o=t,n=x.useMouse(),s=e.ref(0),r=e.ref(!1),c=e.ref(0),p=(g,h)=>{c.value=h,s.value=g.clientX,r.value=!0},f=(g,h)=>{c.value=h,r.value=!1},_=()=>{r.value=!1},d=g=>Math.floor(Math.abs(g)/10),l=e.computed(()=>be(o.control.value)),i=e.ref(["x","y","z"]),k=e.computed(()=>ye(o.control.value)||A(o.control.value));function b(g,h){const{value:y}=o.control,{target:u}=g;c.value=h,y[k.value?i.value[c.value]:c.value]=parseFloat(u.value),a("change",y)}return e.watch(n.x,g=>{if(r.value){const h=g-s.value,y=d(h),{value:u}=o.control,w=k.value?i.value[c.value]:c.value;h>0?u[w]+=.1+y:h<0&&(u[w]-=.1+y),o.control.min!==void 0&&u<o.control.min&&(u[w]=o.control.min),o.control.max!==void 0&&u>o.control.max&&(u[w]=o.control.max),a("change",u),s.value=g}}),(g,h)=>(e.openBlock(),e.createElementBlock("div",{class:"flex px-4 justify-between gap-1 items-center mb-2",onMouseup:h[0]||(h[0]=y=>_())},[e.createElementVNode("label",_e,e.toDisplayString(g.label),1),e.createElementVNode("div",ke,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(y,u)=>(e.openBlock(),e.createElementBlock("div",{key:g.label+u,class:"flex items-center w-1/3 bg-gray-100 rounded"},[i.value[u]&&k.value?(e.openBlock(),e.createElementBlock("span",xe,e.toDisplayString(i.value[u]),1)):e.createCommentVNode("",!0),e.createElementVNode("input",{type:"number",step:"0.1",class:e.normalizeClass(["w-full px-0 p-1 text-right text-0.65rem text-gray-400 bg-transparent focus:border-gray-200 outline-none border-none font-sans appearence-none",{"cursor-ew-resize":r.value}]),value:l.value[u].toFixed(2),onInput:w=>b(w,u),onMousedown:w=>p(w,u),onMouseup:w=>f(w,u)},null,42,we)]))),128))])],32))}}),Ce={class:"flex px-4 justify-between gap-4 items-center mb-2"},Be={class:"text-gray-500 w-1/3"},Ve={class:"relative w-2/3 p-1 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans"},$e={class:"absolute bottom-0.5 right-0.5 font-sans text-xs"},Ne=["points"],I=160,M=40,V=2,L=100,O=20,Se=e.defineComponent({__name:"FPSGraph",props:{label:{},control:{}},setup(t){const a=x.useFps({every:L}),o=e.ref(""),n=e.ref([]),s=e.ref(I/V);let r=performance.now();return x.useRafFn(({timestamp:c})=>{c-r>=L&&(r=c,n.value.push(a.value),n.value.length>s.value&&n.value.shift(),o.value=n.value.map((p,f)=>`${f*V},${M+O-V/2-p*(M+O-V)/120}`).join(" "))}),(c,p)=>(e.openBlock(),e.createElementBlock("div",Ce,[e.createElementVNode("label",Be,e.toDisplayString(c.label),1),e.createElementVNode("div",Ve,[e.createElementVNode("div",$e,e.toDisplayString(Math.round(e.unref(a)))+" FPS ",1),(e.openBlock(),e.createElementBlock("svg",{width:I,height:M,xmlns:"http://www.w3.org/2000/svg",class:"bg-gray-100"},[e.createElementVNode("polyline",{points:o.value,fill:"none",stroke:"lightgray","stroke-width":V,"stroke-linecap":"round","stroke-linejoin":"round"},null,8,Ne)]))])]))}}),De={class:"flex px-4 justify-between gap-4 items-center mb-2 min-h-32px"},Me={class:"text-gray-500 w-1/3"},Te=["value"],Fe=["value"],ze=e.defineComponent({__name:"SelectControl",props:{label:{},control:{}},emits:["change"],setup(t,{emit:a}){function o(n){a("change",n.target.value)}return(n,s)=>(e.openBlock(),e.createElementBlock("div",De,[e.createElementVNode("label",Me,e.toDisplayString(n.label),1),e.createElementVNode("select",{value:n.control.value,class:"p-2 w-2/3 rounded text-left text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",onChange:o},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(n.control.options,r=>(e.openBlock(),e.createElementBlock("option",{key:r.value,value:r.value},e.toDisplayString(r.text),9,Fe))),128))],40,Te)]))}}),R=e.defineComponent({__name:"ControlInput",props:{control:{}},emits:["change"],setup(t,{emit:a}){function o(n){a("change",n)}return(n,s)=>n.control.visible?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[n.control.type==="color"?(e.openBlock(),e.createBlock(he,{key:0,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):n.control.type==="select"?(e.openBlock(),e.createBlock(ze,{key:1,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):n.control.type==="vector"?(e.openBlock(),e.createBlock(Ee,{key:2,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):n.control.type==="boolean"?(e.openBlock(),e.createBlock(ae,{key:3,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):n.control.type==="fpsgraph"?(e.openBlock(),e.createBlock(Se,{key:4,label:n.control.label,control:n.control},null,8,["label","control"])):n.control.type==="number"?(e.openBlock(),e.createBlock(G,{key:5,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):n.control.type==="range"?(e.openBlock(),e.createBlock(pe,{key:6,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"])):(e.openBlock(),e.createBlock(Z,{key:7,label:n.control.label,control:n.control,onChange:o},null,8,["label","control"]))],64)):e.createCommentVNode("",!0)}}),Ae={class:"mb-4"},Ie=["aria-expanded"],Le={class:"bg-white rounded-b pt-4",role:"menu"},Oe=e.defineComponent({__name:"Folder",props:{controls:{},label:{}},setup(t){function a(s,r){r.value=s}const o=e.ref(!1),n=()=>{o.value=!o.value};return(s,r)=>(e.openBlock(),e.createElementBlock("div",Ae,[e.createElementVNode("button",{class:"flex items-center justify-between w-full py-2 px-4 bg-gray-100 border-none text-gray-400 font-bold text-xs font-sans cursor-pointer","aria-expanded":o.value,"aria-haspopup":"true",role:"button",tabindex:"0",onClick:n},[e.createElementVNode("span",null,e.toDisplayString(s.label),1),e.createElementVNode("i",{class:e.normalizeClass(o.value?"i-ic:baseline-keyboard-arrow-up":"i-ic:baseline-keyboard-arrow-down")},null,2)],8,Ie),e.createVNode(e.Transition,{name:"slide","enter-active-class":" animate-fade-in animate-duration-200 animate-ease-in-out","leave-active-class":" animate-fade-out animate-duration-200 animate-ease-in-out"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",Le,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(s.controls,c=>(e.openBlock(),e.createBlock(R,{key:c.label,control:c,role:"menuitem",onChange:p=>a(p,c)},null,8,["control","onChange"]))),128))],512),[[e.vShow,o.value]])]),_:1})]))}}),Re={tabindex:"0",class:"bg-white shadow-xl rounded border-4 border-solid border-black"},Ue=[e.createElementVNode("i",{class:"h-4 w-4 p-1.5 flex items-center line-height-0 rounded-full bg-gray-100 text-xs"},"🍰",-1),e.createElementVNode("div",null,[e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"}),e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"}),e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"})],-1),e.createElementVNode("div",null,null,-1)],Pe=280,Xe=e.defineComponent({__name:"TresLeches",props:{uuid:{}},setup(t){const a=t,{uuid:o}=e.toRefs(a),{width:n}=x.useWindowSize(),s=e.ref(null),r=z(o==null?void 0:o.value);function c(f,_){r[e.unref(f)].value=_,r[e.unref(f)][e.unref(f)]=_}const p=e.computed(()=>{const f={};for(const _ in r){const d=r[_],l=d.folder||"default";f[l]||(f[l]=[]),f[l].push(d)}return f});return(f,_)=>(e.openBlock(),e.createBlock(e.unref(j),{id:e.unref(o),"initial-value":{x:e.unref(n)-Pe-40,y:10},class:e.normalizeClass(["absolute select-none z-24 w-280px font-sans text-xs",f.$attrs.class]),handle:s.value},{default:e.withCtx(()=>[e.createElementVNode("div",Re,[e.createElementVNode("header",{ref_key:"handle",ref:s,class:"relative cursor-grabbing p-4 flex justify-between text-gray-200 relative"},Ue,512),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(p.value,(d,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:l},[l!=="default"?(e.openBlock(),e.createBlock(Oe,{key:0,label:l,controls:d},null,8,["label","controls"])):e.createCommentVNode("",!0),l==="default"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d,i=>(e.openBlock(),e.createBlock(R,{key:i.label,control:i,onChange:k=>c(i.key,k)},null,8,["control","onChange"]))),128)):e.createCommentVNode("",!0)],64))),128))])]),_:1},8,["id","initial-value","class","handle"]))}});E.TresLeches=Xe,E.useControls=K,E.useControlsProvider=z,Object.defineProperty(E,Symbol.toStringTag,{value:"Module"})});
|
|
8
|
+
(function(w,e){typeof exports=="object"&&typeof module<"u"?e(exports,require("vue"),require("@vueuse/core")):typeof define=="function"&&define.amd?define(["exports","vue","@vueuse/core"],e):(w=typeof globalThis<"u"?globalThis:w||self,e(w.tresleches={},w.Vue,w.VueUseCore))})(this,function(w,e,x){"use strict";const We="";function E(n){return typeof n=="function"?n():e.unref(n)}const T=typeof window<"u"&&typeof document<"u";function U(n,r={}){if(!e.isRef(n))return e.toRefs(n);const o=Array.isArray(n.value)?Array.from({length:n.value.length}):{};for(const t in n.value)o[t]=e.customRef(()=>({get(){return n.value[t]},set(a){var s;if((s=E(r.replaceRef))!=null?s:!0)if(Array.isArray(n.value)){const f=[...n.value];f[t]=a,n.value=f}else{const f={...n.value,[t]:a};Object.setPrototypeOf(f,Object.getPrototypeOf(n.value)),n.value=f}else n.value[t]=a}}));return o}const O=T?window:void 0;function R(n,r={}){const{pointerTypes:o,preventDefault:t,stopPropagation:a,exact:s,onMove:c,onEnd:f,onStart:p,initialValue:_,axis:d="both",draggingElement:l=O,handle:u=n}=r,{width:y}=x.useWindowSize();let C=y.value;const i=e.ref(E(_)??{x:0,y:0});e.watch(y,()=>{const g=y.value-C;i.value.x+=g,C=y.value});const h=e.ref(),k=g=>o?o.includes(g.pointerType):!0,m=g=>{E(t)&&g.preventDefault(),E(a)&&g.stopPropagation()},b=g=>{if(!k(g)||E(s)&&g.target!==E(n))return;const $=E(n).getBoundingClientRect(),N={x:g.clientX-$.left,y:g.clientY-$.top};(p==null?void 0:p(N,g))!==!1&&(h.value=N,m(g))},Xe=g=>{if(!k(g)||!h.value)return;let{x:$,y:N}=i.value;(d==="x"||d==="both")&&($=g.clientX-h.value.x),(d==="y"||d==="both")&&(N=g.clientY-h.value.y),i.value={x:$,y:N},c==null||c(i.value,g),m(g)},je=g=>{k(g)&&h.value&&(h.value=void 0,f==null||f(i.value,g),m(g))};if(T){const g={capture:r.capture??!0};x.useEventListener(u,"pointerdown",b,g),x.useEventListener(l,"pointermove",Xe,g),x.useEventListener(l,"pointerup",je,g)}return{...U(i),position:i,isDragging:e.computed(()=>!!h.value),style:e.computed(()=>`left:${i.value.x}px;top:${i.value.y}px;`)}}const P=e.defineComponent({name:"UseDraggable",props:["storageKey","storageType","initialValue","exact","preventDefault","stopPropagation","pointerTypes","as","handle","axis","onStart","onMove","onEnd"],setup(n,{slots:r}){const o=e.ref(),t=e.computed(()=>n.handle??o.value),a=n.storageKey&&x.useStorage(n.storageKey,E(n.initialValue)||{x:0,y:0},x.isClient?n.storageType==="session"?sessionStorage:localStorage:void 0),s=a||n.initialValue||{x:0,y:0},c=(p,_)=>{var d;(d=n.onEnd)==null||d.call(n,p,_),a&&(a.value.x=p.x,a.value.y=p.y)},f=e.reactive(R(o,{...n,handle:t,initialValue:s,onEnd:c}));return()=>{if(r.default)return e.h(n.as||"div",{ref:o,style:`touch-action:none;${f.style}`},r.default(f))}}}),X=Symbol("CONTROLS_CONTEXT_KEY"),F="default",B=e.reactive({});function z(n=F){return e.provide(X,B),B[n]}const D=n=>{const r=/^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$|^0x([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$/;return typeof n=="boolean"?"boolean":typeof n=="number"?"number":typeof n=="string"&&r.test(n)?"color":typeof n=="string"?"string":n.isVector3||n.isVector2||n.isEuler||n instanceof Array?"vector":n.min!==void 0||n.max!==void 0||n.step!==void 0?"range":n.options&&Array.isArray(n.options)?"select":"unknown"},S=(n,r,o,t)=>{const a={key:e.ref(n),label:e.ref(n),name:e.ref(n),type:e.ref(o),value:e.ref(r),visible:e.ref(!0),[n]:e.ref(r)};return t&&(a.folder=e.ref(t)),a},j=(n,r)=>{let o=1,t=`${n}_${o}`;for(;r[t];)o++,t=`${n}_${o}`;return t},W=(n,r,o)=>{const t={},a=typeof n=="string"?n:null,s=a?r:n,c=a&&a!=="fpsgraph"?o:r,f=(c==null?void 0:c.uuid)||F;if(B[f]||(B[f]=e.reactive({})),n==="fpsgraph"){const l=S("fpsgraph",null,"fpsgraph",null);return B[f].fpsgraph=l,t.fpsgraph=l,e.toRefs(e.reactive(t))}const p=B[f],_=e.isReactive(s),d=_?e.toRefs(s):{};for(const l in s){let u=s[l],y=l;if(_&&d[l]&&(u=d[l]),a&&(y=`${a}${l.charAt(0).toUpperCase()+l.slice(1)}`),!a&&p[y]&&(y=j(l,p)),typeof u=="object"&&!e.isRef(u)&&!Array.isArray(u)&&u.value!==void 0){const i=u,h=e.isRef(i.value)?i.value:e.ref(i.value),k=D(i),m=S(l,h,k,a);k==="select"&&(m.options=e.ref(i.options.map(b=>typeof b=="object"&&b.text&&b.value?b:{text:b,value:b}))),k==="range"&&(m.min=e.ref(i.min||0),m.max=e.ref(i.max||1),m.step=e.ref(i.step||.1)),m.label.value=i.label||l,m.visible.value=i.visible!==void 0?i.visible:!0,p[y]=m,t[y]=m;continue}if(e.isRef(u)){const i=S(l,u,D(u.value),a);p[y]=i,t[y]=i;continue}else if(typeof u=="object"&&!Array.isArray(u)){const i=e.toRefs(u);i[l]&&(u=i[l])}const C=S(l,u,D(u),a);p[y]=C,t[y]=C,C.uniqueKey=y}return Object.keys(t).length>1?e.toRefs(e.reactive(t)):Object.values(t)[0]},Y={class:"flex px-4 justify-between gap-4 items-center mb-2"},H=["for"],v=["id","value","min","max","step"],G=e.defineComponent({__name:"NumberControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){const o=n;function t(d){const{target:l}=d;r("change",l.valueAsNumber)}const a=x.useMouse(),s=e.ref(0),c=e.ref(!1),f=d=>{s.value=d.clientX,c.value=!0},p=()=>{c.value=!1},_=d=>Math.floor(Math.abs(d)/10);return e.watch(a.x,d=>{if(c.value){const l=d-s.value,u=_(l);l>0?r("change",o.control.value+1+u):l<0&&r("change",o.control.value-1+u),o.control.min!==void 0&&o.control.value<o.control.min&&r("change",o.control.min),o.control.max!==void 0&&o.control.value>o.control.max&&r("change",o.control.max),s.value=d}}),(d,l)=>(e.openBlock(),e.createElementBlock("div",Y,[e.createElementVNode("label",{class:"text-gray-500 w-1/3",for:d.control.uniqueKey},e.toDisplayString(d.label),9,H),e.createElementVNode("input",{id:d.control.uniqueKey,value:d.control.value,class:e.normalizeClass(["p-2 w-1/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",{"cursor-ew-resize":c.value}]),type:"number",min:d.control.min,max:d.control.max,step:d.control.step,onInput:t,onMousedown:f,onMouseup:p},null,42,v)]))}}),J={class:"flex px-4 justify-between gap-4 items-center mb-2 min-h-32px"},Q=["for"],Z=["id","value","aria-label"],ee=e.defineComponent({__name:"TextControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){function o(t){const{target:a}=t;r("change",a.value)}return(t,a)=>(e.openBlock(),e.createElementBlock("div",J,[e.createElementVNode("label",{for:t.control.uniqueKey,class:"text-gray-500 w-1/3"},e.toDisplayString(t.label),9,Q),e.createElementVNode("input",{id:t.control.uniqueKey,value:t.control.value,type:"text",tabindex:"0",class:"p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 border-none font-sans","aria-label":t.label,placeholder:"Enter value here...",onChange:o},null,40,Z)]))}}),te={class:"flex px-4 justify-start gap-2 items-center mb-2 min-h-32px"},ne={class:"text-gray-500 w-1/3"},oe=["id","checked"],le=["for"],re=["aria-checked"],ae={class:"i-ic:baseline-check text-light"},se=e.defineComponent({__name:"BooleanControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){const o=n;function t(s){const{target:c}=s;r("change",c.checked)}function a(s){(s.code==="Space"||s.code==="Enter")&&(s.preventDefault(),r("change",!o.control.value))}return(s,c)=>(e.openBlock(),e.createElementBlock("div",te,[e.createElementVNode("label",ne,e.toDisplayString(s.label),1),e.createElementVNode("input",{id:s.control.uniqueKey,checked:s.control.value,class:"hidden",type:"checkbox",onInput:t},null,40,oe),e.createElementVNode("label",{for:s.control.uniqueKey,class:"inline-flex items-center cursor-pointer"},[e.createElementVNode("span",{tabindex:"0",role:"checkbox","aria-checked":s.control.value.toString(),class:e.normalizeClass([{"bg-dark-500":s.control.value,"bg-gray-200":!s.control.value},"w-4 h-4 flex justify-center items-center rounded border border-gray-300 mr-2 transition-colors duration-200"]),onKeydown:a},[e.withDirectives(e.createElementVNode("i",ae,null,512),[[e.vShow,s.control.value]])],42,re)],8,le)]))}}),ce={class:"px-4 relative flex justify-between gap-4 items-center mb-2"},ie=["value","min","max","step"],de=["value","min","max","step"],ue=e.defineComponent({__name:"SliderControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){const o=n;function t(l){const{target:u}=l;r("change",u.valueAsNumber)}const a=e.computed(()=>({backgroundImage:`linear-gradient(to right, #333 0% ${100*(o.control.value-(o.control.min||0))/((o.control.max||100)-(o.control.min||0))}%, #e2e2e2 0%)`})),s=x.useMouse(),c=e.ref(0),f=e.ref(!1),p=l=>{c.value=l.clientX,f.value=!0},_=()=>{f.value=!1},d=l=>Math.floor(Math.abs(l)/10);return e.watch(s.x,l=>{if(f.value){const u=l-c.value,y=d(u);u>0?r("change",o.control.value+1+y):u<0&&r("change",o.control.value-1+y),o.control.min!==void 0&&o.control.value<o.control.min&&r("change",o.control.min),o.control.max!==void 0&&o.control.value>o.control.max&&r("change",o.control.max),c.value=l}}),(l,u)=>(e.openBlock(),e.createElementBlock("div",ce,[e.createElementVNode("label",{class:e.normalizeClass(["text-gray-500 w-1/3",{"flex justify-between items-center":l.control.icon}])},[e.createTextVNode(e.toDisplayString(l.label)+" ",1),e.createElementVNode("i",{class:e.normalizeClass(`i-${l.control.icon}`)},null,2)],2),e.createElementVNode("input",{value:l.control.value,class:"w-1/2 h-0.75 bg-dark-200 rounded-full appearance-none",style:e.normalizeStyle(a.value),type:"range",min:l.control.min,max:l.control.max,step:l.control.step,onInput:t},null,44,ie),e.createElementVNode("input",{value:l.control.value,class:e.normalizeClass(["p-2 w-1/4 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",{"cursor-ew-resize":f.value}]),type:"number",min:l.control.min,max:l.control.max,step:l.control.step,onInput:t,onMousedown:p,onMouseup:_},null,42,de)]))}}),Ye="",fe=((n,r)=>{const o=n.__vccOpts||n;for(const[t,a]of r)o[t]=a;return o})(ue,[["__scopeId","data-v-9e6267fe"]]),pe={class:"flex px-4 justify-between gap-4 items-center mb-2"},me={class:"text-gray-500 w-1/3"},ge=["id","value","aria-label"],ye=["id","aria-label","value"],he=e.defineComponent({__name:"ColorControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){function o(t){const{target:a}=t;r("change",a.value)}return(t,a)=>(e.openBlock(),e.createElementBlock("div",pe,[e.createElementVNode("label",me,e.toDisplayString(t.label),1),e.createElementVNode("input",{id:t.control.uniqueKey,tabindex:"0",value:t.control.value,"aria-label":t.label,class:e.normalizeClass(["focus:outline-none focus:ring-2 focus:ring-blue-600",{"important-outline-gray-200":t.control.value==="#ffffff"}]),type:"color",onInput:o},null,42,ge),e.createElementVNode("input",{id:t.control.uniqueKey,tabindex:"0","aria-label":t.label,value:t.control.value,class:"p-2 w-2/3 rounded text-right text-xs text-gray-400 bg-gray-100 border-none font-sans",type:"text",onInput:o},null,40,ye)]))}}),ve="";function be(n){if(typeof n=="number")return[n,n,n];if(A(n)){const{x:r,y:o,z:t}=n;return[r,o,t]}return n}function _e(n){return n&&typeof n.x=="number"&&typeof n.y=="number"&&typeof n.z>"u"}function A(n){return n&&typeof n.x=="number"&&typeof n.y=="number"&&typeof n.z=="number"}const ke={class:"text-gray-500 w-1/3"},xe={class:"w-2/3 flex justify-between gap-0.5"},we={key:0,class:"font-bold px-1 py-1 text-0.65rem text-gray-300"},Ee=["id","value","onInput","onMousedown","onMouseup"],Ce=e.defineComponent({__name:"VectorControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){const o=n,t=x.useMouse(),a=e.ref(0),s=e.ref(!1),c=e.ref(0),f=(i,h)=>{c.value=h,a.value=i.clientX,s.value=!0},p=(i,h)=>{c.value=h,s.value=!1},_=()=>{s.value=!1},d=i=>Math.floor(Math.abs(i)/10),l=e.computed(()=>be(o.control.value)),u=e.ref(["x","y","z"]),y=e.computed(()=>_e(o.control.value)||A(o.control.value));function C(i,h){const{value:k}=o.control,{target:m}=i;c.value=h,k[y.value?u.value[c.value]:c.value]=parseFloat(m.value),r("change",k)}return e.watch(t.x,i=>{if(s.value){const h=i-a.value,k=d(h),{value:m}=o.control,b=y.value?u.value[c.value]:c.value;h>0?m[b]+=.1+k:h<0&&(m[b]-=.1+k),o.control.min!==void 0&&m<o.control.min&&(m[b]=o.control.min),o.control.max!==void 0&&m>o.control.max&&(m[b]=o.control.max),r("change",m),a.value=i}}),(i,h)=>(e.openBlock(),e.createElementBlock("div",{class:"flex px-4 justify-between gap-1 items-center mb-2",onMouseup:h[0]||(h[0]=k=>_())},[e.createElementVNode("label",ke,e.toDisplayString(i.label),1),e.createElementVNode("div",xe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(l.value,(k,m)=>(e.openBlock(),e.createElementBlock("div",{key:i.label+m,class:"flex items-center w-1/3 bg-gray-100 rounded"},[u.value[m]&&y.value?(e.openBlock(),e.createElementBlock("span",we,e.toDisplayString(u.value[m]),1)):e.createCommentVNode("",!0),e.createElementVNode("input",{id:`${i.control.uniqueKey}-${u.value[m]}`,type:"number",step:"0.1",class:e.normalizeClass(["w-full px-0 p-1 text-right text-0.65rem text-gray-400 bg-transparent focus:border-gray-200 outline-none border-none font-sans appearence-none",{"cursor-ew-resize":s.value}]),value:l.value[m].toFixed(2),onInput:b=>C(b,m),onMousedown:b=>f(b,m),onMouseup:b=>p(b,m)},null,42,Ee)]))),128))])],32))}}),Be={class:"flex px-4 justify-between gap-4 items-center mb-2"},Ve={class:"text-gray-500 w-1/3"},$e={class:"relative w-2/3 p-1 rounded text-right text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans"},Ne={class:"absolute bottom-0.5 right-0.5 font-sans text-xs"},Se=["points"],I=160,M=40,V=2,K=100,q=20,De=e.defineComponent({__name:"FPSGraph",props:{label:{},control:{}},setup(n){const r=x.useFps({every:K}),o=e.ref(""),t=e.ref([]),a=e.ref(I/V);let s=performance.now();return x.useRafFn(({timestamp:c})=>{c-s>=K&&(s=c,t.value.push(r.value),t.value.length>a.value&&t.value.shift(),o.value=t.value.map((f,p)=>`${p*V},${M+q-V/2-f*(M+q-V)/120}`).join(" "))}),(c,f)=>(e.openBlock(),e.createElementBlock("div",Be,[e.createElementVNode("label",Ve,e.toDisplayString(c.label),1),e.createElementVNode("div",$e,[e.createElementVNode("div",Ne,e.toDisplayString(Math.round(e.unref(r)))+" FPS ",1),(e.openBlock(),e.createElementBlock("svg",{width:I,height:M,xmlns:"http://www.w3.org/2000/svg",class:"bg-gray-100"},[e.createElementVNode("polyline",{points:o.value,fill:"none",stroke:"lightgray","stroke-width":V,"stroke-linecap":"round","stroke-linejoin":"round"},null,8,Se)]))])]))}}),Me={class:"flex px-4 justify-between gap-4 items-center mb-2 min-h-32px"},Te=["for"],Fe=["id","value"],ze=["value"],Ae=e.defineComponent({__name:"SelectControl",props:{label:{},control:{}},emits:["change"],setup(n,{emit:r}){function o(t){r("change",t.target.value)}return(t,a)=>(e.openBlock(),e.createElementBlock("div",Me,[e.createElementVNode("label",{class:"text-gray-500 w-1/3",for:t.control.uniqueKey},e.toDisplayString(t.label),9,Te),e.createElementVNode("select",{id:t.control.uniqueKey,value:t.control.value,class:"p-2 w-2/3 rounded text-left text-xs text-gray-400 bg-gray-100 focus:border-gray-200 outline-none border-none font-sans",onChange:o},[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(t.control.options,s=>(e.openBlock(),e.createElementBlock("option",{key:s.value,value:s.value},e.toDisplayString(s.text),9,ze))),128))],40,Fe)]))}}),L=e.defineComponent({__name:"ControlInput",props:{control:{}},emits:["change"],setup(n,{emit:r}){function o(t){r("change",t)}return(t,a)=>t.control.visible?(e.openBlock(),e.createElementBlock(e.Fragment,{key:0},[t.control.type==="color"?(e.openBlock(),e.createBlock(he,{key:0,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):t.control.type==="select"?(e.openBlock(),e.createBlock(Ae,{key:1,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):t.control.type==="vector"?(e.openBlock(),e.createBlock(Ce,{key:2,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):t.control.type==="boolean"?(e.openBlock(),e.createBlock(se,{key:3,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):t.control.type==="fpsgraph"?(e.openBlock(),e.createBlock(De,{key:4,label:t.control.label,control:t.control},null,8,["label","control"])):t.control.type==="number"?(e.openBlock(),e.createBlock(G,{key:5,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):t.control.type==="range"?(e.openBlock(),e.createBlock(fe,{key:6,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"])):(e.openBlock(),e.createBlock(ee,{key:7,label:t.control.label,control:t.control,onChange:o},null,8,["label","control"]))],64)):e.createCommentVNode("",!0)}}),Ie={class:"mb-4"},Ke=["aria-expanded","data-folder"],qe={class:"bg-white rounded-b pt-4",role:"menu"},Le=e.defineComponent({__name:"Folder",props:{controls:{},label:{}},setup(n){function r(a,s){s.value=a}const o=e.ref(!1),t=()=>{o.value=!o.value};return(a,s)=>(e.openBlock(),e.createElementBlock("div",Ie,[e.createElementVNode("button",{class:"flex items-center justify-between w-full py-2 px-4 bg-gray-100 border-none text-gray-400 font-bold text-xs font-sans cursor-pointer","aria-expanded":o.value,"aria-haspopup":"true",role:"button","data-folder":a.label,tabindex:"0",onClick:t},[e.createElementVNode("span",null,e.toDisplayString(a.label),1),e.createElementVNode("i",{class:e.normalizeClass(o.value?"i-ic:baseline-keyboard-arrow-up":"i-ic:baseline-keyboard-arrow-down")},null,2)],8,Ke),e.createVNode(e.Transition,{name:"slide","enter-active-class":" animate-fade-in animate-duration-200 animate-ease-in-out","leave-active-class":" animate-fade-out animate-duration-200 animate-ease-in-out"},{default:e.withCtx(()=>[e.withDirectives(e.createElementVNode("div",qe,[(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(a.controls,c=>(e.openBlock(),e.createBlock(L,{key:c.label,control:c,role:"menuitem",onChange:f=>r(f,c)},null,8,["control","onChange"]))),128))],512),[[e.vShow,o.value]])]),_:1})]))}}),Ue={tabindex:"0",class:"bg-white shadow-xl rounded border-4 border-solid border-black"},Oe=[e.createElementVNode("i",{class:"h-4 w-4 p-1.5 flex items-center line-height-0 rounded-full bg-gray-100 text-xs"},"🍰",-1),e.createElementVNode("div",null,[e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"}),e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"}),e.createElementVNode("i",{class:"i-ic-baseline-drag-indicator"})],-1),e.createElementVNode("div",null,null,-1)],Re=280,Pe=e.defineComponent({__name:"TresLeches",props:{uuid:{}},setup(n){const r=n,{uuid:o}=e.toRefs(r),{width:t}=x.useWindowSize(),a=e.ref(null),s=z(o==null?void 0:o.value);function c(p,_){s[e.unref(p)].value=_,s[e.unref(p)][e.unref(p)]=_}const f=e.computed(()=>{const p={};for(const _ in s){const d=s[_],l=d.folder||"default";p[l]||(p[l]=[]),p[l].push(d)}return p});return(p,_)=>(e.openBlock(),e.createBlock(e.unref(P),{id:e.unref(o),"initial-value":{x:e.unref(t)-Re-40,y:10},class:e.normalizeClass(["absolute select-none z-24 w-280px font-sans text-xs",p.$attrs.class]),handle:a.value},{default:e.withCtx(()=>[e.createElementVNode("div",Ue,[e.createElementVNode("header",{ref_key:"handle",ref:a,class:"relative cursor-grabbing p-4 flex justify-between text-gray-200 relative"},Oe,512),(e.openBlock(!0),e.createElementBlock(e.Fragment,null,e.renderList(f.value,(d,l)=>(e.openBlock(),e.createElementBlock(e.Fragment,{key:l},[l!=="default"?(e.openBlock(),e.createBlock(Le,{key:0,label:l,controls:d},null,8,["label","controls"])):e.createCommentVNode("",!0),l==="default"?(e.openBlock(!0),e.createElementBlock(e.Fragment,{key:1},e.renderList(d,u=>(e.openBlock(),e.createBlock(L,{key:u.label,control:u,onChange:y=>c(u.key,y)},null,8,["control","onChange"]))),128)):e.createCommentVNode("",!0)],64))),128))])]),_:1},8,["id","initial-value","class","handle"]))}});w.TresLeches=Pe,w.useControls=W,w.useControlsProvider=z,Object.defineProperty(w,Symbol.toStringTag,{value:"Module"})});
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tresjs/leches",
|
|
3
3
|
"type": "module",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.11.0",
|
|
5
5
|
"packageManager": "pnpm@8.3.1",
|
|
6
6
|
"description": "Tasty GUI for Vue controls 🍰",
|
|
7
7
|
"author": "Alvaro Saburido <hola@alvarosaburido.dev> (https://github.com/alvarosabu/)",
|