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