@kolkrabbi/design-editor 0.48.0 → 0.49.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,447 +0,0 @@
1
- import { $t as e, F as t, Gn as n, J as r, Kn as i, L as a, Nr as o, Xn as s, Xt as c, Yn as l, Zn as u, a as d, d as f, er as p, n as m, o as h, qn as g, t as _, u as v, xn as y } from "./rolls-Cnu6g8th.js";
2
- import { n as b, r as x, t as S } from "./useLayerEdit-W_Tf3adq.js";
3
- import { a as C, at as w, ct as T, f as E, i as D, it as O, l as k, lt as A, nt as j, o as M, ot as N, p as P, r as F, rt as I, s as L, st as R, tt as z, u as B } from "./effectCategories-wHY9ih8L.js";
4
- import { n as ee, t as V } from "./TreePicker-DXsAlHK6.js";
5
- import { t as H } from "./BindDot-Cx-M0iQt.js";
6
- import { Tooltip as U, XYPad as W } from "@kolkrabbi/kol-component";
7
- import { useEffect as te, useRef as ne, useState as G } from "react";
8
- import { Fragment as K, jsx as q, jsxs as J } from "react/jsx-runtime";
9
- //#region src/editor/compose/inspectors/EffectsPanel.jsx
10
- var Y = [{
11
- value: "effect",
12
- label: "Effect"
13
- }, {
14
- value: "anim",
15
- label: "Animation"
16
- }];
17
- function X() {
18
- let { selectedId: e, layers: t } = r(), n = e && e !== "canvas" ? y(t, e) : null;
19
- return /* @__PURE__ */ q("div", {
20
- className: "kol-compose-rail kol-compose-rail--inspector",
21
- children: /* @__PURE__ */ q("div", {
22
- className: "kol-compose-inspector-body",
23
- children: n ? /* @__PURE__ */ q(re, { layer: n }, n.id) : /* @__PURE__ */ q(x, {
24
- always: !0,
25
- children: "Select a layer to edit its effect."
26
- })
27
- })
28
- });
29
- }
30
- function re({ layer: n }) {
31
- let o = a(), { palette: s, addFilter: l, removeFilter: d, toggleFilter: f, moveFilter: p, replaceFilter: m } = r(), h = S(n.id, { history: "coalesce" }), _ = c(n), v = _.some((e) => e.def?.kind === "engine"), { effectable: y, engineHost: x, engineLoop: w } = D(n), [T, O] = G(_.length ? 0 : null), A = T == null ? null : _[T] ?? null, [j, M] = G("effect"), N = ne(_.map((e) => e.key));
32
- if (te(() => {
33
- let e = N.current, t = _.map((e) => e.key);
34
- N.current = t;
35
- let n = t.find((t) => !e.includes(t));
36
- if (n != null) {
37
- O(t.indexOf(n));
38
- return;
39
- }
40
- T != null && T >= t.length && O(t.length ? t.length - 1 : null);
41
- }, [_.length]), !y) return /* @__PURE__ */ q("p", {
42
- className: "kol-mono-12 text-meta",
43
- children: w ? "Engine loops can't host effects yet." : "This layer can't host an effect."
44
- });
45
- let P = (e) => {
46
- let t = x && (e == null ? !v : _[e]?.def?.kind === "engine" || !v && e === _.length - 1), n = E.filter((e) => e.kind !== "engine" || t), r = /* @__PURE__ */ new Set();
47
- return C(n).flatMap((e) => {
48
- let t = e.filters.filter((e) => !r.has(e.id) && r.add(e.id));
49
- return t.length ? [{ heading: e.label }, ...t.map((e) => ({
50
- value: e.id,
51
- label: e.label
52
- }))] : [];
53
- });
54
- }, F = _.map(({ def: e, ...t }) => t), I = A ? {
55
- ...n,
56
- ...A.params,
57
- id: n.id
58
- } : null, L = (e) => {
59
- if (T == null) return;
60
- let t = F.map((t, n) => n === T ? {
61
- ...t,
62
- params: {
63
- ...t.params,
64
- ...e
65
- }
66
- } : t);
67
- h.patch({ filters: t });
68
- }, R = (e, t) => {
69
- if (e === "cameraDrag") {
70
- h.setProp(e, t);
71
- return;
72
- }
73
- L({ [e]: t });
74
- }, z = (e) => R("sweeps", e), V = (e) => /* @__PURE__ */ q(H, {
75
- layer: I,
76
- param: e,
77
- setProp: R
78
- }), U = A?.def ? k(A.def.id) : null, W = U ? A.def.params.find((e) => e.key === U) : null, X = A?.def ? A.def.params.filter((t) => e(t) !== "anim" && t !== W) : [];
79
- return /* @__PURE__ */ J("div", {
80
- className: "flex flex-col gap-4",
81
- children: [_.map((e, r) => /* @__PURE__ */ J("div", {
82
- className: "flex flex-col gap-3",
83
- children: [/* @__PURE__ */ q(ie, {
84
- stage: e,
85
- selected: r === T,
86
- options: P(r),
87
- onSelect: () => O(r),
88
- onPick: (t) => {
89
- t && t !== e.id && m(n.id, r, t), O(r);
90
- },
91
- onToggle: () => f(n.id, r),
92
- onRemove: () => d(n.id, r),
93
- onUp: () => p(n.id, r, r - 1),
94
- onDown: () => p(n.id, r, r + 1),
95
- canUp: r > 0 && e.def?.kind !== "engine",
96
- canDown: r < _.length - 1 && e.def?.kind !== "engine" && _[r + 1]?.def?.kind !== "engine"
97
- }), r === T && A?.def && /* @__PURE__ */ J("div", {
98
- className: "flex flex-col gap-3",
99
- children: [
100
- W && /* @__PURE__ */ q(ee, {
101
- label: "Preset",
102
- options: W.options,
103
- value: A.params[W.key] ?? W.default,
104
- onChange: (e) => L(B(A.def, e)),
105
- inline: !0
106
- }),
107
- n.imgW != null && /* @__PURE__ */ q("span", {
108
- className: "kol-helper-12 text-meta",
109
- children: "Filters don't apply to cropped photos."
110
- }),
111
- A.def.orbit && /* @__PURE__ */ q(u, {
112
- label: "Camera drag",
113
- align: "fill",
114
- labelWidth: t,
115
- children: /* @__PURE__ */ q(i, {
116
- layout: "joined",
117
- size: o,
118
- className: "w-full",
119
- options: [{
120
- value: "off",
121
- label: "Off"
122
- }, {
123
- value: "on",
124
- label: "On"
125
- }],
126
- value: n.cameraDrag ? "on" : "off",
127
- onChange: (e) => R("cameraDrag", e === "on")
128
- })
129
- }),
130
- /* @__PURE__ */ q(i, {
131
- layout: "joined",
132
- size: o,
133
- className: "w-full",
134
- value: j,
135
- onChange: M,
136
- options: Y
137
- }),
138
- j === "effect" && /* @__PURE__ */ J(K, { children: [/* @__PURE__ */ q(b, {
139
- schema: X,
140
- layer: I,
141
- setProp: R,
142
- palette: s,
143
- renderAnimate: V
144
- }), /* @__PURE__ */ q(Z, {
145
- def: A.def,
146
- view: I,
147
- tab: "effect",
148
- onPatch: L
149
- })] }),
150
- j === "anim" && /* @__PURE__ */ J(K, { children: [
151
- /* @__PURE__ */ q(b, {
152
- schema: A.def.params,
153
- layer: I,
154
- setProp: R,
155
- palette: s,
156
- renderAnimate: V,
157
- tab: "anim"
158
- }),
159
- /* @__PURE__ */ q(Z, {
160
- def: A.def,
161
- view: I,
162
- tab: "anim",
163
- onPatch: L
164
- }),
165
- A.def.sweeps && /* @__PURE__ */ q(Q, {
166
- sweeps: Array.isArray(A.params.sweeps) ? A.params.sweeps : [],
167
- onChange: z
168
- })
169
- ] })
170
- ]
171
- })]
172
- }, e.key)), _.length < 8 ? /* @__PURE__ */ q(g, {
173
- variant: "subtle",
174
- size: o,
175
- className: "w-full",
176
- options: [{
177
- value: "",
178
- label: "Add effect…"
179
- }, ...P(null)],
180
- value: "",
181
- onChange: (e) => {
182
- e && l(n.id, e);
183
- }
184
- }) : /* @__PURE__ */ q("span", {
185
- className: "kol-helper-12 text-meta",
186
- children: "Chain is full (8 effects)"
187
- })]
188
- });
189
- }
190
- function Z({ def: t, view: r, tab: i, onPatch: o, inline: s = !1, levels: c = null }) {
191
- let l = a(), u = f(r), p = i === "anim", g = t.params.filter((t) => e(t) === "anim" === p), y = p ? g.filter((e) => !e.noRandom) : m(g, r), b = v(h(g, r), y), x = (e, t) => {
192
- e.length && o(d(r, e, u.take(), { stripNoRandom: !!t?.motion }));
193
- }, S = (e) => {
194
- let t = {};
195
- for (let n of e) n.default !== void 0 && (t[n.key] = n.default);
196
- Object.keys(t).length && o(t);
197
- };
198
- return !y.length && !b.length ? null : /* @__PURE__ */ J("div", {
199
- className: "flex flex-col gap-2",
200
- children: [
201
- y.length >= 5 && /* @__PURE__ */ q(_, {
202
- seed: u,
203
- inline: s
204
- }),
205
- y.length > 0 && /* @__PURE__ */ J("div", {
206
- className: "flex gap-2",
207
- children: [c ?? /* @__PURE__ */ q(n, {
208
- tone: "primary",
209
- size: l,
210
- className: "flex-1 min-w-0",
211
- onClick: (e) => e.altKey ? S(y) : x(y),
212
- children: p ? "Randomize motion" : "Randomize all"
213
- }), /* @__PURE__ */ q(U, {
214
- label: "Reset to defaults",
215
- shortcut: "R",
216
- children: /* @__PURE__ */ q(n, {
217
- tone: "primary",
218
- size: l,
219
- iconOnly: "refresh",
220
- "aria-label": "Reset to defaults",
221
- onClick: () => S(y),
222
- className: "shrink-0"
223
- })
224
- })]
225
- }),
226
- b.length > 0 && /* @__PURE__ */ q("div", {
227
- className: `grid ${s ? "grid-cols-3" : "grid-cols-2"} gap-2`,
228
- children: b.map((e) => /* @__PURE__ */ q(n, {
229
- tone: "primary",
230
- size: l,
231
- onClick: (t) => t.altKey ? S(e.params) : x(e.params, e),
232
- children: e.label
233
- }, e.id))
234
- })
235
- ]
236
- });
237
- }
238
- function ie({ stage: e, selected: t, options: r, onSelect: i, onPick: o, onToggle: s, onRemove: c, onUp: l, onDown: u, canUp: d, canDown: f }) {
239
- let p = a(), m = e.enabled !== !1, h = (e, t, r, i, a = "") => {
240
- let o = /* @__PURE__ */ q(U, {
241
- label: e,
242
- children: /* @__PURE__ */ q(n, {
243
- tone: "ghost",
244
- quiet: !0,
245
- size: p,
246
- iconOnly: i,
247
- "aria-label": e,
248
- tabIndex: r ? -1 : void 0,
249
- onClick: (e) => {
250
- e.stopPropagation(), r || t();
251
- },
252
- className: `shrink-0 ${a}`
253
- })
254
- });
255
- return r ? /* @__PURE__ */ q("span", {
256
- "aria-hidden": "true",
257
- className: "invisible pointer-events-none shrink-0",
258
- children: o
259
- }) : o;
260
- };
261
- return /* @__PURE__ */ J("div", {
262
- onClick: i,
263
- className: `flex items-center gap-1 rounded ${t ? "bg-oq-08" : ""}`,
264
- children: [
265
- h(m ? "Disable effect" : "Enable effect", s, !1, m ? "eye-on" : "eye-off"),
266
- /* @__PURE__ */ q("div", {
267
- className: `flex-1 min-w-0 ${m ? "" : "opacity-60"}`,
268
- children: /* @__PURE__ */ q(g, {
269
- variant: "subtle",
270
- size: p,
271
- className: "w-full",
272
- options: r,
273
- value: e.id,
274
- onChange: o
275
- })
276
- }),
277
- h("Move up", l, !d, "chevron-down", "rotate-180"),
278
- h("Move down", u, !f, "chevron-down"),
279
- h("Delete effect", c, !1, "x")
280
- ]
281
- });
282
- }
283
- var ae = (e) => [
284
- {
285
- key: "shape",
286
- label: "Shape",
287
- type: "select",
288
- options: I,
289
- default: "linear"
290
- },
291
- {
292
- key: "target",
293
- label: "Target",
294
- type: "select",
295
- options: O,
296
- default: "brightness"
297
- },
298
- {
299
- key: "travel",
300
- label: "Travel",
301
- type: "select",
302
- options: w,
303
- default: "forward"
304
- },
305
- ...e.target === "reveal" ? [] : [{
306
- key: "amount",
307
- label: "Amount",
308
- type: "range",
309
- min: -1,
310
- max: 1,
311
- step: .01,
312
- default: .6
313
- }],
314
- {
315
- key: "speed",
316
- label: "Speed",
317
- type: "range",
318
- min: -8,
319
- max: 8,
320
- step: 1,
321
- default: 1
322
- },
323
- {
324
- key: "width",
325
- label: "Width",
326
- type: "range",
327
- min: .05,
328
- max: 1,
329
- step: .01,
330
- default: .35
331
- },
332
- ...z.has(e.shape ?? "linear") ? [{
333
- key: "angle",
334
- label: "Angle",
335
- type: "range",
336
- min: 0,
337
- max: 360,
338
- step: 1,
339
- default: 0
340
- }] : []
341
- ];
342
- function Q({ sweeps: e, onChange: r, inline: i = !1 }) {
343
- let o = a(), c = (e) => I.find((t) => t.value === e)?.label ?? e, u = (t) => r([...e, t ? N(t.shape, t) : N()]), d = (t) => r(e.filter((e, n) => n !== t)), f = (t, n) => r(e.map((e, r) => r === t ? {
344
- ...e,
345
- ...n
346
- } : e));
347
- return /* @__PURE__ */ J(K, { children: [/* @__PURE__ */ J(s, {
348
- label: "Motion",
349
- divided: !0,
350
- children: [/* @__PURE__ */ q(V, {
351
- options: [{
352
- value: "",
353
- label: "Add motion…"
354
- }, ...j.map((e) => ({
355
- value: e.name,
356
- label: e.name
357
- }))],
358
- value: "",
359
- onChange: (e) => {
360
- let t = j.find((t) => t.name === e);
361
- t && u(t);
362
- }
363
- }), /* @__PURE__ */ q(n, {
364
- tone: "primary",
365
- size: o,
366
- className: "w-full",
367
- iconLeft: "plus",
368
- iconSize: 12,
369
- onClick: () => u(),
370
- children: "Add custom sweep"
371
- })]
372
- }), e.map((e, r) => {
373
- let a = e.enabled !== !1;
374
- return /* @__PURE__ */ J(s, {
375
- divided: !0,
376
- children: [/* @__PURE__ */ J("div", {
377
- className: "flex items-center gap-2",
378
- children: [
379
- /* @__PURE__ */ q("span", {
380
- className: `kol-eyebrow flex-1 truncate ${a ? "text-fg-80" : "text-meta"}`,
381
- children: c(e.shape ?? "linear")
382
- }),
383
- /* @__PURE__ */ q(p, {
384
- size: o,
385
- checked: a,
386
- onChange: (e) => f(r, { enabled: e })
387
- }),
388
- /* @__PURE__ */ q(U, {
389
- label: "Delete sweep",
390
- children: /* @__PURE__ */ q(n, {
391
- tone: "ghost",
392
- quiet: !0,
393
- size: o,
394
- iconOnly: "x",
395
- "aria-label": "Delete sweep",
396
- className: "shrink-0",
397
- onClick: () => d(r)
398
- })
399
- })
400
- ]
401
- }), a && /* @__PURE__ */ J(K, { children: [/* @__PURE__ */ q(b, {
402
- schema: ae(e),
403
- layer: e,
404
- setProp: (e, t) => f(r, { [e]: t }),
405
- inline: i
406
- }), (e.shape ?? "linear") !== "noise" && /* @__PURE__ */ q(l, {
407
- horizontal: !0,
408
- label: "ORIGIN",
409
- labelWidth: t,
410
- children: /* @__PURE__ */ q("div", {
411
- className: "w-full min-w-0",
412
- children: /* @__PURE__ */ q(W, {
413
- xValue: e.cx ?? .5,
414
- yValue: e.cy ?? .5,
415
- xMin: 0,
416
- xMax: 1,
417
- yMin: 1,
418
- yMax: 0,
419
- onChange: (e, t) => f(r, {
420
- cx: Math.round(e * 100) / 100,
421
- cy: Math.round(t * 100) / 100
422
- })
423
- })
424
- })
425
- })] })]
426
- }, r);
427
- })] });
428
- }
429
- //#endregion
430
- //#region src/packs/effects.js
431
- var $ = {
432
- FILTERS: E,
433
- filterById: P,
434
- makeSweep: N,
435
- runChain: T,
436
- invalidateSource: R,
437
- stillOf: A,
438
- effectCategories: F,
439
- liveFilterGroups: M,
440
- liveFilterLabel: L,
441
- EffectsPanel: X,
442
- loadPixiPipeline: () => import("./pipeline-hZsOKbHd.js"),
443
- loadGlHost: () => import("./host-0qv2SCjk.js")
444
- };
445
- o("effects", $);
446
- //#endregion
447
- export { Z as n, Q as r, $ as t };