@kolkrabbi/design-editor 0.27.0 → 0.28.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.
@@ -1,5 +1,5 @@
1
1
  import "./chunk-3b4jIN3o.js";
2
- import { ct as e } from "./rolls-BGtqxVYq.js";
2
+ import { ct as e } from "./rolls-CGma4Bua.js";
3
3
  //#region ../../node_modules/.pnpm/mediabunny@1.55.6/node_modules/mediabunny/dist/modules/src/misc.js
4
4
  function t(e) {
5
5
  if (!e) throw Error("Assertion failed.");
@@ -0,0 +1,453 @@
1
+ import { D as e, F as t, I as n, J as r, L as i, T as a, cn as o, it as s, j as c, nt as l, rn as u, rt as d, tt as f } from "./rolls-CGma4Bua.js";
2
+ import { AccordionPanel as p, Dropdown as m, Input as h, LabeledControl as g, LabeledControlSection as _, SegmentedToggle as v, SettingsRow as y, Slider as b, Textarea as x, ToggleSwitch as S, ViewToggle as C } from "@kolkrabbi/kol-component";
3
+ import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as O } from "react";
4
+ import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
5
+ //#region src/editor/lib/viewport.js
6
+ var M = Math.PI * 2, N = {
7
+ vpZoom: 1,
8
+ vpSpin: 0,
9
+ vpPulse: 0,
10
+ vpWobble: 0,
11
+ vpRate: 1
12
+ }, P = {
13
+ vpTime: "linear",
14
+ vpSpeed: 1,
15
+ vpPhase: 0
16
+ }, F = [
17
+ {
18
+ key: "vpTime",
19
+ label: "Time",
20
+ type: "select",
21
+ default: "linear",
22
+ options: [
23
+ {
24
+ value: "linear",
25
+ label: "Linear"
26
+ },
27
+ {
28
+ value: "ease",
29
+ label: "Ease"
30
+ },
31
+ {
32
+ value: "pingpong",
33
+ label: "Ping-pong"
34
+ },
35
+ {
36
+ value: "steps",
37
+ label: "Steps"
38
+ },
39
+ {
40
+ value: "bounce",
41
+ label: "Bounce"
42
+ },
43
+ {
44
+ value: "drift",
45
+ label: "Drift"
46
+ }
47
+ ],
48
+ tab: "anim",
49
+ section: "Form"
50
+ },
51
+ {
52
+ key: "vpSpeed",
53
+ label: "Speed",
54
+ type: "range",
55
+ min: 1,
56
+ max: 8,
57
+ rMin: 1,
58
+ rMax: 4,
59
+ step: 1,
60
+ default: 1,
61
+ tab: "anim",
62
+ section: "Form"
63
+ },
64
+ {
65
+ key: "vpPhase",
66
+ label: "Phase",
67
+ type: "range",
68
+ min: 0,
69
+ max: 1,
70
+ step: .05,
71
+ default: 0,
72
+ tab: "anim",
73
+ section: "Form"
74
+ }
75
+ ], I = (e) => e - Math.floor(e);
76
+ function L(e, t) {
77
+ if (!t) return e;
78
+ let n = t.vpTime || "linear", r = Math.max(1, Math.round(t.vpSpeed || 1)), i = t.vpPhase || 0;
79
+ if (n === "linear" && r === 1 && !i) return e;
80
+ let a = I(e * r);
81
+ switch (n) {
82
+ case "ease":
83
+ a = .5 - .5 * Math.cos(a * Math.PI);
84
+ break;
85
+ case "pingpong":
86
+ a = a < .5 ? a * 2 : 2 - a * 2;
87
+ break;
88
+ case "steps":
89
+ a = Math.floor(a * 4) / 4;
90
+ break;
91
+ case "bounce": {
92
+ let e = Math.abs(Math.sin(a * Math.PI * 2));
93
+ a = a < .5 ? e : 1 - e * .5, a = I(a);
94
+ break;
95
+ }
96
+ case "drift":
97
+ a = I(a + .08 * Math.sin(a * M) + .04 * Math.sin(a * M * 3));
98
+ break;
99
+ default: break;
100
+ }
101
+ return I(a + i);
102
+ }
103
+ var R = [
104
+ {
105
+ key: "vpSpin",
106
+ label: "Spin",
107
+ type: "range",
108
+ min: -8,
109
+ max: 8,
110
+ rMin: 0,
111
+ rMax: 4,
112
+ step: 1,
113
+ default: 0,
114
+ tab: "anim",
115
+ section: "Frame"
116
+ },
117
+ {
118
+ key: "vpZoom",
119
+ label: "Zoom",
120
+ type: "range",
121
+ min: 1,
122
+ max: 2.5,
123
+ step: .05,
124
+ default: 1,
125
+ tab: "anim",
126
+ section: "Frame"
127
+ },
128
+ {
129
+ key: "vpPulse",
130
+ label: "Pulse",
131
+ type: "range",
132
+ min: 0,
133
+ max: 1,
134
+ step: .05,
135
+ default: 0,
136
+ tab: "anim",
137
+ section: "Form"
138
+ },
139
+ {
140
+ key: "vpWobble",
141
+ label: "Wobble",
142
+ type: "range",
143
+ min: 0,
144
+ max: 30,
145
+ step: 1,
146
+ default: 0,
147
+ tab: "anim",
148
+ section: "Form"
149
+ },
150
+ {
151
+ key: "vpRate",
152
+ label: "Rate",
153
+ type: "range",
154
+ min: 1,
155
+ max: 8,
156
+ rMin: 1,
157
+ rMax: 4,
158
+ step: 1,
159
+ default: 1,
160
+ tab: "anim",
161
+ section: "Form"
162
+ }
163
+ ];
164
+ function z(e, t, n, r, i) {
165
+ let a = Math.round(i.vpSpin || 0), o = i.vpZoom ?? 1, s = i.vpPulse || 0, c = i.vpWobble || 0;
166
+ if (!a && s === 0 && c === 0 && o === 1) return !1;
167
+ let l = t * M * Math.round(i.vpRate || 1), u = t * M * a + c * Math.PI / 180 * Math.sin(l), d = a ? Math.PI / 4 : Math.abs(c * Math.PI / 180), f = Math.cos(d) + Math.sin(d), p = Math.max(o * (1 + s * .5 * Math.sin(l)), f * 1.02);
168
+ return e.translate(n / 2, r / 2), e.rotate(u), e.scale(p, p), e.translate(-n / 2, -r / 2), !0;
169
+ }
170
+ function B(e, t, n, r, i, a) {
171
+ if (!t) return;
172
+ let o = L(n, a);
173
+ e.save(), z(e, o, r, i, a), t.draw(e, o, r, i, a), e.restore();
174
+ }
175
+ //#endregion
176
+ //#region src/editor/components/Hint.jsx
177
+ function V({ children: e, className: t = "kol-mono-12 text-meta", always: n = !1 }) {
178
+ return /* @__PURE__ */ A("p", {
179
+ className: `${n ? "" : "kol-placeholder "}${t}`,
180
+ children: e
181
+ });
182
+ }
183
+ //#endregion
184
+ //#region src/editor/params/AutoControls.jsx
185
+ function H({ schema: t, layer: n, setProp: r, palette: i, renderAnimate: a, tab: o, emptyHint: c, inline: u = !0 }) {
186
+ let m = s(t, n);
187
+ if (o && (m = m.filter((e) => d(e) === o)), m.length === 0) return c ? /* @__PURE__ */ A(V, { children: c }) : null;
188
+ let h = [];
189
+ for (let e of m) {
190
+ let t = l(e), n = h[h.length - 1];
191
+ n && n.section === t ? n.params.push(e) : h.push({
192
+ section: t,
193
+ params: [e]
194
+ });
195
+ }
196
+ for (let e = 0; e < h.length; e++) {
197
+ let t = h[e];
198
+ if (t.section) continue;
199
+ let n = 0;
200
+ for (; n < t.params.length && t.params[n].type === "select";) n++;
201
+ n === 0 || n === t.params.length || (h.splice(e, 1, {
202
+ section: void 0,
203
+ params: t.params.slice(0, n)
204
+ }, {
205
+ section: void 0,
206
+ params: t.params.slice(n)
207
+ }), e++);
208
+ }
209
+ return /* @__PURE__ */ A(k, { children: h.map((t) => {
210
+ let o = Math.max(0, ...t.params.filter((e) => e.type === "range").map(U)), s = t.section && t.params.some((e) => e.collapsed), c = /* @__PURE__ */ A(_, {
211
+ label: !s && t.section && t.section !== t.params[0].label ? t.section : void 0,
212
+ divided: !s,
213
+ children: t.params.map((t) => {
214
+ let s = e(n[t.key]);
215
+ return /* @__PURE__ */ A(q, {
216
+ param: t,
217
+ layer: n,
218
+ setProp: r,
219
+ palette: i,
220
+ bound: s,
221
+ animate: a && f(t) ? a(t, s) : null,
222
+ inline: u,
223
+ chars: o || void 0
224
+ }, t.key);
225
+ })
226
+ }, t.params[0].key);
227
+ return s ? /* @__PURE__ */ A(p, {
228
+ title: t.section,
229
+ children: c
230
+ }, t.params[0].key) : c;
231
+ }) });
232
+ }
233
+ function U(e) {
234
+ let t = e.step && e.step < 1 ? String(e.step).split(".")[1]?.length ?? 2 : 0;
235
+ return Math.max(2, String(Math.round(e.max ?? 0)).length, String(Math.round(e.min ?? 0)).length) + (t ? t + 1 : 0);
236
+ }
237
+ function W({ param: t, layer: n, setProp: r, chars: a }) {
238
+ let s = i(), l = n[t.key], d = e(l), f = d && l.bind === "mod" && l.source === "expr", p = u(d), m = d ? c(l, p, n) : l, g = typeof m == "number" ? m : t.default ?? 0, _ = t.step && t.step < 1 ? String(t.step).split(".")[1]?.length ?? 2 : 0, v = f ? l.transform?.expr ?? "wave(t)" : t.format ? String(t.format(g)) : _ ? g.toFixed(_) : String(Math.round(g)), y = a ?? U(t), [x, S] = O(v), [C, w] = O(!1);
239
+ return T(() => {
240
+ C || S(v);
241
+ }, [v, C]), /* @__PURE__ */ j("div", {
242
+ className: "flex items-center gap-3",
243
+ children: [!d && /* @__PURE__ */ A(b, {
244
+ min: t.min,
245
+ max: t.max,
246
+ step: t.step ?? 1,
247
+ value: g,
248
+ onChange: (e) => r(t.key, Number(e)),
249
+ readout: "none",
250
+ className: "flex-1"
251
+ }), /* @__PURE__ */ A(h, {
252
+ type: "text",
253
+ variant: "filled",
254
+ size: s,
255
+ width: `calc(${y}ch + 24px)`,
256
+ value: x,
257
+ title: "Number sets a constant · an expression like sin(t) binds it",
258
+ onFocus: (e) => {
259
+ w(!0), e.target.select();
260
+ },
261
+ onChange: (e) => S(e.target.value),
262
+ onBlur: () => {
263
+ w(!1);
264
+ let e = x.trim();
265
+ if (e === "") {
266
+ S(v);
267
+ return;
268
+ }
269
+ let n = Number(e);
270
+ if (Number.isFinite(n)) {
271
+ r(t.key, n);
272
+ return;
273
+ }
274
+ if (!o(e).ok) {
275
+ S(v);
276
+ return;
277
+ }
278
+ let i = d && l.transform?.range || (t.min != null && t.max != null ? [t.min, t.max] : [0, 1]);
279
+ r(t.key, {
280
+ bind: "mod",
281
+ source: "expr",
282
+ transform: {
283
+ ...d ? l.transform : {},
284
+ expr: e,
285
+ range: i
286
+ }
287
+ });
288
+ },
289
+ onKeyDown: (e) => {
290
+ e.key === "Enter" && e.currentTarget.blur(), e.key === "Escape" && (S(v), w(!1), e.currentTarget.blur());
291
+ },
292
+ inputClassName: "text-center"
293
+ })]
294
+ });
295
+ }
296
+ var G = t, K = {
297
+ xs: "h-[var(--kol-ctl-xs)]",
298
+ sm: "h-[var(--kol-ctl-sm)]",
299
+ md: "h-[var(--kol-ctl-md)]",
300
+ lg: "h-[var(--kol-ctl-lg)]"
301
+ };
302
+ function q({ param: e, layer: t, setProp: r, palette: o, bound: s, animate: c, inline: l, chars: u }) {
303
+ let d = i(), f = t[e.key], p = f === void 0 ? e.default : f;
304
+ if (e.type === "color") return /* @__PURE__ */ j("div", {
305
+ className: "flex items-end gap-2",
306
+ children: [/* @__PURE__ */ A("div", {
307
+ className: "flex-1 min-w-0",
308
+ children: /* @__PURE__ */ A(a, {
309
+ label: e.label,
310
+ value: p,
311
+ onChange: (t) => r(e.key, t),
312
+ palette: o,
313
+ inline: l
314
+ })
315
+ }), c]
316
+ });
317
+ let h = l, _ = null;
318
+ if (e.type === "range") d !== "sm" && (h = !1), _ = /* @__PURE__ */ A(W, {
319
+ param: e,
320
+ layer: t,
321
+ setProp: r,
322
+ chars: u
323
+ });
324
+ else if (e.type === "select") _ = /* @__PURE__ */ A(m, {
325
+ variant: "subtle",
326
+ size: d,
327
+ className: "w-full",
328
+ options: e.options ?? [],
329
+ value: p,
330
+ onChange: (t) => r(e.key, e.numeric ? Number(t) : t)
331
+ });
332
+ else if (e.type === "segmented") _ = l ? /* @__PURE__ */ A(v, {
333
+ tone: "sunken",
334
+ size: d,
335
+ className: `w-full ${n(d) ?? ""}`,
336
+ options: e.options ?? [],
337
+ value: p,
338
+ onChange: (t) => r(e.key, t)
339
+ }) : /* @__PURE__ */ A(C, {
340
+ size: d,
341
+ options: e.options ?? [],
342
+ viewMode: p,
343
+ onViewChange: (t) => r(e.key, t)
344
+ });
345
+ else if (e.type === "toggle") {
346
+ let [t, i] = e.labels ?? ["Off", "On"];
347
+ e.labels ? l ? _ = /* @__PURE__ */ A(v, {
348
+ tone: "sunken",
349
+ size: d,
350
+ className: `w-full ${n(d) ?? ""}`,
351
+ options: [{
352
+ value: "off",
353
+ label: t
354
+ }, {
355
+ value: "on",
356
+ label: i
357
+ }],
358
+ value: p ? "on" : "off",
359
+ onChange: (t) => r(e.key, t === "on")
360
+ }) : (h = !1, _ = /* @__PURE__ */ A(C, {
361
+ size: d,
362
+ options: [{
363
+ value: "off",
364
+ label: t
365
+ }, {
366
+ value: "on",
367
+ label: i
368
+ }],
369
+ viewMode: p ? "on" : "off",
370
+ onViewChange: (t) => r(e.key, t === "on")
371
+ })) : (l || (h = !1), _ = /* @__PURE__ */ A(S, {
372
+ size: d,
373
+ checked: !!p,
374
+ onChange: (t) => r(e.key, t)
375
+ }));
376
+ } else if (e.type === "text") h = !1, _ = /* @__PURE__ */ A(x, {
377
+ variant: "filled",
378
+ size: d,
379
+ rows: e.rows ?? 2,
380
+ axis: "y",
381
+ value: p ?? "",
382
+ onChange: (t) => r(e.key, t.target.value),
383
+ placeholder: e.placeholder
384
+ });
385
+ else return null;
386
+ let b = e.type === "range" && e.format && typeof p == "number" && !s ? e.format(p) : void 0, w = c ? /* @__PURE__ */ j("div", {
387
+ className: "flex items-center gap-2",
388
+ children: [/* @__PURE__ */ A("div", {
389
+ className: "flex-1 min-w-0",
390
+ children: _
391
+ }), c]
392
+ }) : _, T = e.type === "toggle" && !e.labels ? "end" : "fill", E = e.type === "toggle" && !e.labels && !l;
393
+ return h && T === "end" && !b ? /* @__PURE__ */ A(g, {
394
+ inline: !0,
395
+ label: String(e.label).toUpperCase(),
396
+ labelWidth: G,
397
+ children: /* @__PURE__ */ A("div", {
398
+ className: `flex w-full items-center justify-end ${K[d] ?? ""}`,
399
+ children: w
400
+ })
401
+ }) : h ? /* @__PURE__ */ A(y, {
402
+ label: e.label,
403
+ hint: b,
404
+ align: T,
405
+ labelWidth: G,
406
+ children: w
407
+ }) : /* @__PURE__ */ A(g, {
408
+ inline: E,
409
+ label: l ? String(e.label).toUpperCase() : e.label,
410
+ hint: b,
411
+ labelWidth: E ? "auto" : G,
412
+ children: w
413
+ });
414
+ }
415
+ //#endregion
416
+ //#region src/editor/compose/useLayerEdit.js
417
+ function J(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
418
+ let { updateLayer: i, beginTransaction: a, commitTransaction: o } = r(), s = D(null), c = w(() => {
419
+ s.current !== null && (clearTimeout(s.current), s.current = null, o());
420
+ }, [o]), l = w((r) => {
421
+ if (e) {
422
+ if (t === "discrete") {
423
+ i(e, r);
424
+ return;
425
+ }
426
+ if (t === "coalesce") {
427
+ s.current === null && a(), i(e, r), s.current !== null && clearTimeout(s.current), s.current = setTimeout(() => {
428
+ s.current = null, o();
429
+ }, n);
430
+ return;
431
+ }
432
+ i(e, r);
433
+ }
434
+ }, [
435
+ e,
436
+ t,
437
+ n,
438
+ i,
439
+ a,
440
+ o
441
+ ]), u = w((e, t) => l({ [e]: t }), [l]);
442
+ return T(() => () => c(), [c, e]), E(() => ({
443
+ patch: l,
444
+ setProp: u,
445
+ flush: c
446
+ }), [
447
+ l,
448
+ u,
449
+ c
450
+ ]);
451
+ }
452
+ //#endregion
453
+ export { F as a, B as c, P as i, L as l, H as n, N as o, V as r, R as s, J as t };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/design-editor",
3
- "version": "0.27.0",
3
+ "version": "0.28.0",
4
4
  "private": false,
5
5
  "description": "The design editor as one component",
6
6
  "license": "MIT",
@@ -30,15 +30,16 @@
30
30
  "README.md"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@kolkrabbi/kol-component": ">=0.330.0 <1",
33
+ "@kolkrabbi/kol-component": ">=0.342.0 <1",
34
34
  "@kolkrabbi/kol-framework": ">=0.44.0 <1",
35
35
  "@kolkrabbi/kol-hardware": ">=0.10.0 <1",
36
36
  "@kolkrabbi/kol-icons": ">=0.29.0 <1",
37
37
  "@kolkrabbi/kol-media-client": ">=0.4.0 <1",
38
- "@kolkrabbi/kol-shell": ">=0.51.0 <1",
38
+ "@kolkrabbi/kol-shell": ">=0.110.0 <1",
39
39
  "react": "^19.0.0",
40
40
  "react-dom": "^19.0.0",
41
- "@kolkrabbi/kol-theme": ">=0.211.0 <1"
41
+ "@kolkrabbi/kol-theme": ">=0.211.0 <1",
42
+ "@kolkrabbi/kol-dashboards": ">=0.13.0 <1"
42
43
  },
43
44
  "dependencies": {
44
45
  "colord": "^2.9.3",
@@ -60,11 +61,12 @@
60
61
  "tailwindcss": "^4.2.4",
61
62
  "vite": "^8.0.10",
62
63
  "vite-plugin-svgr": "^5.2.0",
63
- "@kolkrabbi/kol-component": "0.337.0",
64
- "@kolkrabbi/kol-icons": "0.64.0",
65
- "@kolkrabbi/kol-shell": "0.102.1",
66
- "@kolkrabbi/kol-framework": "0.69.0",
67
- "@kolkrabbi/kol-theme": "0.211.1",
64
+ "@kolkrabbi/kol-component": "0.342.0",
65
+ "@kolkrabbi/kol-framework": "0.70.0",
66
+ "@kolkrabbi/kol-icons": "0.65.0",
67
+ "@kolkrabbi/kol-shell": "0.110.0",
68
+ "@kolkrabbi/kol-theme": "0.212.0",
69
+ "@kolkrabbi/kol-dashboards": "0.13.0",
68
70
  "@kolkrabbi/kol-media-client": "0.7.0",
69
71
  "@kolkrabbi/kol-hardware": "0.10.0"
70
72
  },
@@ -85,6 +87,7 @@
85
87
  },
86
88
  "scripts": {
87
89
  "build": "vite build --config vite.lib.config.js",
88
- "check:core": "node scripts/check-core.mjs"
90
+ "check:core": "node scripts/check-core.mjs",
91
+ "check:float": "node scripts/check-float-commands.mjs"
89
92
  }
90
93
  }