@kolkrabbi/design-editor 0.19.0 → 0.21.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/{RuleRow-DlouS36V.js → RuleRow-BXkjpTyN.js} +139 -79
- package/dist/TreePicker-DLmMl0aU.js +68 -0
- package/dist/{core-BeIRJu1Z.js → core-B2bfXyS5.js} +2561 -2192
- package/dist/core.js +3 -3
- package/dist/design-editor.css +1 -1
- package/dist/design-editor.js +1069 -1292
- package/dist/{effects-DehkU1My.js → effectCategories-BcaQSD_V.js} +734 -1076
- package/dist/effects-pCd8YTdQ.js +469 -0
- package/dist/effects.js +1 -1
- package/dist/{generators-Bk3mvrsm.js → generators-B8_StNAy.js} +283 -345
- package/dist/generators.js +1 -1
- package/dist/{host-B8_Ri9EV.js → host-B4SRaN9h.js} +170 -171
- package/dist/labels-B5qkocWy.js +2007 -0
- package/dist/motion-DFnAar_2.js +2263 -0
- package/dist/motion.js +1 -1
- package/dist/{rolls-CkmuE-Ya.js → rolls-Bg1XHuvJ.js} +2198 -1963
- package/dist/{src-DFtETCsY.js → src-B5fQgAVE.js} +1 -1
- package/dist/{registry-CSOtIU7o.js → useLayerEdit-ieOjHx6x.js} +2873 -2619
- package/package.json +9 -9
- package/dist/BindDot-CuCS4LS-.js +0 -127
- package/dist/TreePicker-D5XZT0Zi.js +0 -303
- package/dist/labels-B10g9Um5.js +0 -40
- package/dist/motion-9j3WO6a2.js +0 -4223
- package/dist/useLayerEdit-DRZ09kNJ.js +0 -259
|
@@ -1,259 +0,0 @@
|
|
|
1
|
-
import { B as e, Ht as t, Lt as n, R as r, S as i, V as a, f as o, j as s, m as c, v as l, x as u, z as d } from "./rolls-CkmuE-Ya.js";
|
|
2
|
-
import { Dropdown as f, Input as p, LabeledControl as m, LabeledControlSection as h, SegmentedToggle as g, SettingsRow as _, Textarea as v, ToggleSwitch as y, ViewToggle as b } from "@kolkrabbi/kol-component";
|
|
3
|
-
import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as T } from "react";
|
|
4
|
-
import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
|
|
5
|
-
//#region src/editor/components/Hint.jsx
|
|
6
|
-
function k({ children: e, className: t = "kol-mono-12 text-meta" }) {
|
|
7
|
-
return /* @__PURE__ */ D("p", {
|
|
8
|
-
className: `kol-placeholder ${t}`,
|
|
9
|
-
children: e
|
|
10
|
-
});
|
|
11
|
-
}
|
|
12
|
-
//#endregion
|
|
13
|
-
//#region src/editor/params/AutoControls.jsx
|
|
14
|
-
function A({ schema: t, layer: n, setProp: i, palette: o, renderAnimate: s, tab: l, emptyHint: u, inline: f = !1 }) {
|
|
15
|
-
let p = a(t, n);
|
|
16
|
-
if (l && (p = p.filter((t) => e(t) === l)), p.length === 0) return u ? /* @__PURE__ */ D(k, { children: u }) : null;
|
|
17
|
-
let m = [];
|
|
18
|
-
for (let e of p) {
|
|
19
|
-
let t = d(e), n = m[m.length - 1];
|
|
20
|
-
n && n.section === t ? n.params.push(e) : m.push({
|
|
21
|
-
section: t,
|
|
22
|
-
params: [e]
|
|
23
|
-
});
|
|
24
|
-
}
|
|
25
|
-
for (let e = 0; e < m.length; e++) {
|
|
26
|
-
let t = m[e];
|
|
27
|
-
if (t.section) continue;
|
|
28
|
-
let n = 0;
|
|
29
|
-
for (; n < t.params.length && t.params[n].type === "select";) n++;
|
|
30
|
-
n === 0 || n === t.params.length || (m.splice(e, 1, {
|
|
31
|
-
section: void 0,
|
|
32
|
-
params: t.params.slice(0, n)
|
|
33
|
-
}, {
|
|
34
|
-
section: void 0,
|
|
35
|
-
params: t.params.slice(n)
|
|
36
|
-
}), e++);
|
|
37
|
-
}
|
|
38
|
-
return /* @__PURE__ */ D(E, { children: m.map((e) => /* @__PURE__ */ D(h, {
|
|
39
|
-
label: e.section && e.section !== e.params[0].label ? e.section : void 0,
|
|
40
|
-
divided: !0,
|
|
41
|
-
children: e.params.map((e) => {
|
|
42
|
-
let t = c(n[e.key]);
|
|
43
|
-
return /* @__PURE__ */ D(N, {
|
|
44
|
-
param: e,
|
|
45
|
-
layer: n,
|
|
46
|
-
setProp: i,
|
|
47
|
-
palette: o,
|
|
48
|
-
bound: t,
|
|
49
|
-
animate: s && r(e) ? s(e, t) : null,
|
|
50
|
-
inline: f
|
|
51
|
-
}, e.key);
|
|
52
|
-
})
|
|
53
|
-
}, e.params[0].key)) });
|
|
54
|
-
}
|
|
55
|
-
function j({ param: e, layer: r, setProp: a }) {
|
|
56
|
-
let o = i(), s = r[e.key], u = c(s), d = u && s.bind === "mod" && s.source === "expr", f = n(u), m = u ? l(s, f, r) : s, h = typeof m == "number" ? m : e.default ?? 0, g = e.step && e.step < 1 ? String(e.step).split(".")[1]?.length ?? 2 : 0, _ = d ? s.transform?.expr ?? "wave(t)" : e.format ? String(e.format(h)) : g ? h.toFixed(g) : String(Math.round(h)), [v, y] = T(_), [b, x] = T(!1);
|
|
57
|
-
return S(() => {
|
|
58
|
-
b || y(_);
|
|
59
|
-
}, [_, b]), /* @__PURE__ */ O("div", {
|
|
60
|
-
className: "flex items-center gap-3",
|
|
61
|
-
children: [/* @__PURE__ */ D("input", {
|
|
62
|
-
type: "range",
|
|
63
|
-
min: e.min,
|
|
64
|
-
max: e.max,
|
|
65
|
-
step: e.step ?? 1,
|
|
66
|
-
value: h,
|
|
67
|
-
disabled: u,
|
|
68
|
-
onChange: (t) => a(e.key, Number(t.target.value)),
|
|
69
|
-
className: "slider-black flex-1 w-full cursor-pointer",
|
|
70
|
-
style: u ? { opacity: .7 } : void 0
|
|
71
|
-
}), /* @__PURE__ */ D(p, {
|
|
72
|
-
type: "text",
|
|
73
|
-
variant: "filled",
|
|
74
|
-
size: o,
|
|
75
|
-
chars: 5,
|
|
76
|
-
value: v,
|
|
77
|
-
title: "Number sets a constant · an expression like sin(t) binds it",
|
|
78
|
-
onFocus: (e) => {
|
|
79
|
-
x(!0), e.target.select();
|
|
80
|
-
},
|
|
81
|
-
onChange: (e) => y(e.target.value),
|
|
82
|
-
onBlur: () => {
|
|
83
|
-
x(!1);
|
|
84
|
-
let n = v.trim();
|
|
85
|
-
if (n === "") {
|
|
86
|
-
y(_);
|
|
87
|
-
return;
|
|
88
|
-
}
|
|
89
|
-
let r = Number(n);
|
|
90
|
-
if (Number.isFinite(r)) {
|
|
91
|
-
a(e.key, r);
|
|
92
|
-
return;
|
|
93
|
-
}
|
|
94
|
-
if (!t(n).ok) {
|
|
95
|
-
y(_);
|
|
96
|
-
return;
|
|
97
|
-
}
|
|
98
|
-
let i = u && s.transform?.range || (e.min != null && e.max != null ? [e.min, e.max] : [0, 1]);
|
|
99
|
-
a(e.key, {
|
|
100
|
-
bind: "mod",
|
|
101
|
-
source: "expr",
|
|
102
|
-
transform: {
|
|
103
|
-
...u ? s.transform : {},
|
|
104
|
-
expr: n,
|
|
105
|
-
range: i
|
|
106
|
-
}
|
|
107
|
-
});
|
|
108
|
-
},
|
|
109
|
-
onKeyDown: (e) => {
|
|
110
|
-
e.key === "Enter" && e.currentTarget.blur(), e.key === "Escape" && (y(_), x(!1), e.currentTarget.blur());
|
|
111
|
-
},
|
|
112
|
-
inputClassName: "text-center"
|
|
113
|
-
})]
|
|
114
|
-
});
|
|
115
|
-
}
|
|
116
|
-
var M = 96;
|
|
117
|
-
function N({ param: e, layer: t, setProp: n, palette: r, bound: a, animate: s, inline: c }) {
|
|
118
|
-
let l = i(), d = t[e.key], p = d === void 0 ? e.default : d;
|
|
119
|
-
if (e.type === "color") return /* @__PURE__ */ O("div", {
|
|
120
|
-
className: "flex items-end gap-2",
|
|
121
|
-
children: [/* @__PURE__ */ D("div", {
|
|
122
|
-
className: "flex-1 min-w-0",
|
|
123
|
-
children: /* @__PURE__ */ D(o, {
|
|
124
|
-
label: e.label,
|
|
125
|
-
value: p,
|
|
126
|
-
onChange: (t) => n(e.key, t),
|
|
127
|
-
palette: r,
|
|
128
|
-
inline: c
|
|
129
|
-
})
|
|
130
|
-
}), s]
|
|
131
|
-
});
|
|
132
|
-
let h = c, x = null;
|
|
133
|
-
if (e.type === "range") l !== "sm" && (h = !1), x = /* @__PURE__ */ D(j, {
|
|
134
|
-
param: e,
|
|
135
|
-
layer: t,
|
|
136
|
-
setProp: n
|
|
137
|
-
});
|
|
138
|
-
else if (e.type === "select") x = /* @__PURE__ */ D(f, {
|
|
139
|
-
variant: "subtle",
|
|
140
|
-
size: l,
|
|
141
|
-
className: "w-full",
|
|
142
|
-
options: e.options ?? [],
|
|
143
|
-
value: p,
|
|
144
|
-
onChange: (t) => n(e.key, e.numeric ? Number(t) : t)
|
|
145
|
-
});
|
|
146
|
-
else if (e.type === "segmented") x = c ? /* @__PURE__ */ D(g, {
|
|
147
|
-
variant: "filled",
|
|
148
|
-
size: l,
|
|
149
|
-
className: `w-full ${u(l) ?? ""}`,
|
|
150
|
-
options: e.options ?? [],
|
|
151
|
-
value: p,
|
|
152
|
-
onChange: (t) => n(e.key, t)
|
|
153
|
-
}) : /* @__PURE__ */ D(b, {
|
|
154
|
-
size: l,
|
|
155
|
-
options: e.options ?? [],
|
|
156
|
-
viewMode: p,
|
|
157
|
-
onViewChange: (t) => n(e.key, t)
|
|
158
|
-
});
|
|
159
|
-
else if (e.type === "toggle") {
|
|
160
|
-
let [t, r] = e.labels ?? ["Off", "On"];
|
|
161
|
-
e.labels ? c ? x = /* @__PURE__ */ D(g, {
|
|
162
|
-
variant: "filled",
|
|
163
|
-
size: l,
|
|
164
|
-
className: `w-full ${u(l) ?? ""}`,
|
|
165
|
-
options: [{
|
|
166
|
-
value: "off",
|
|
167
|
-
label: t
|
|
168
|
-
}, {
|
|
169
|
-
value: "on",
|
|
170
|
-
label: r
|
|
171
|
-
}],
|
|
172
|
-
value: p ? "on" : "off",
|
|
173
|
-
onChange: (t) => n(e.key, t === "on")
|
|
174
|
-
}) : (h = !1, x = /* @__PURE__ */ D(b, {
|
|
175
|
-
size: l,
|
|
176
|
-
options: [{
|
|
177
|
-
value: "off",
|
|
178
|
-
label: t
|
|
179
|
-
}, {
|
|
180
|
-
value: "on",
|
|
181
|
-
label: r
|
|
182
|
-
}],
|
|
183
|
-
viewMode: p ? "on" : "off",
|
|
184
|
-
onViewChange: (t) => n(e.key, t === "on")
|
|
185
|
-
})) : (c || (h = !1), x = /* @__PURE__ */ D(y, {
|
|
186
|
-
size: l,
|
|
187
|
-
checked: !!p,
|
|
188
|
-
onChange: (t) => n(e.key, t)
|
|
189
|
-
}));
|
|
190
|
-
} else if (e.type === "text") h = !1, x = /* @__PURE__ */ D(v, {
|
|
191
|
-
variant: "filled",
|
|
192
|
-
size: l,
|
|
193
|
-
rows: e.rows ?? 2,
|
|
194
|
-
axis: "y",
|
|
195
|
-
value: p ?? "",
|
|
196
|
-
onChange: (t) => n(e.key, t.target.value),
|
|
197
|
-
placeholder: e.placeholder
|
|
198
|
-
});
|
|
199
|
-
else return null;
|
|
200
|
-
let S = e.type === "range" && e.format && typeof p == "number" && !a ? e.format(p) : void 0, C = s ? /* @__PURE__ */ O("div", {
|
|
201
|
-
className: "flex items-center gap-2",
|
|
202
|
-
children: [/* @__PURE__ */ D("div", {
|
|
203
|
-
className: "flex-1 min-w-0",
|
|
204
|
-
children: x
|
|
205
|
-
}), s]
|
|
206
|
-
}) : x, w = e.type === "toggle" && !e.labels ? "end" : "fill", T = e.type === "toggle" && !e.labels && !c;
|
|
207
|
-
return h ? /* @__PURE__ */ D(_, {
|
|
208
|
-
label: e.label,
|
|
209
|
-
hint: S,
|
|
210
|
-
align: w,
|
|
211
|
-
labelWidth: M,
|
|
212
|
-
children: C
|
|
213
|
-
}) : /* @__PURE__ */ D(m, {
|
|
214
|
-
inline: T,
|
|
215
|
-
label: c ? String(e.label).toUpperCase() : e.label,
|
|
216
|
-
hint: S,
|
|
217
|
-
labelWidth: T ? "auto" : M,
|
|
218
|
-
children: C
|
|
219
|
-
});
|
|
220
|
-
}
|
|
221
|
-
//#endregion
|
|
222
|
-
//#region src/editor/compose/useLayerEdit.js
|
|
223
|
-
function P(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
|
|
224
|
-
let { updateLayer: r, beginTransaction: i, commitTransaction: a } = s(), o = w(null), c = x(() => {
|
|
225
|
-
o.current !== null && (clearTimeout(o.current), o.current = null, a());
|
|
226
|
-
}, [a]), l = x((s) => {
|
|
227
|
-
if (e) {
|
|
228
|
-
if (t === "discrete") {
|
|
229
|
-
r(e, s);
|
|
230
|
-
return;
|
|
231
|
-
}
|
|
232
|
-
if (t === "coalesce") {
|
|
233
|
-
o.current === null && i(), r(e, s), o.current !== null && clearTimeout(o.current), o.current = setTimeout(() => {
|
|
234
|
-
o.current = null, a();
|
|
235
|
-
}, n);
|
|
236
|
-
return;
|
|
237
|
-
}
|
|
238
|
-
r(e, s);
|
|
239
|
-
}
|
|
240
|
-
}, [
|
|
241
|
-
e,
|
|
242
|
-
t,
|
|
243
|
-
n,
|
|
244
|
-
r,
|
|
245
|
-
i,
|
|
246
|
-
a
|
|
247
|
-
]), u = x((e, t) => l({ [e]: t }), [l]);
|
|
248
|
-
return S(() => () => c(), [c, e]), C(() => ({
|
|
249
|
-
patch: l,
|
|
250
|
-
setProp: u,
|
|
251
|
-
flush: c
|
|
252
|
-
}), [
|
|
253
|
-
l,
|
|
254
|
-
u,
|
|
255
|
-
c
|
|
256
|
-
]);
|
|
257
|
-
}
|
|
258
|
-
//#endregion
|
|
259
|
-
export { A as n, k as r, P as t };
|