@kolkrabbi/design-editor 0.48.0 → 0.49.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 { _ as e, d as t, g as n, m as r, o as i, v as a } from "./__vite-browser-external-y2xWjzgx.js";
2
- import { D as o, J as s, L as c, Mr as l, _ as u, b as ee, f as d, g as te, h as f, m as p, p as m, v as h, x as g, xn as ne, y as re } from "./rolls-Cnu6g8th.js";
2
+ import { D as o, J as s, L as c, Nr as l, _ as u, b as ee, f as d, g as te, h as f, m as p, p as m, v as h, x as g, xn as ne, y as re } from "./rolls-ZToBSscx.js";
3
3
  import { Button as _, ButtonGroup as ie, CloseButton as v, ColorPickerPopover as ae, Dropdown as y, FullscreenOverlay as b, FunctionPlot as x, Input as S, LabeledControl as C, MenuDropdownItem as w, ModalShell as T, Section as E, Slider as D, Stepper as O, Tooltip as k } from "@kolkrabbi/kol-component";
4
4
  import { createContext as oe, useCallback as A, useContext as se, useEffect as j, useMemo as ce, useRef as le, useState as M, useSyncExternalStore as N } from "react";
5
5
  import { Fragment as ue, jsx as P, jsxs as F } from "react/jsx-runtime";
@@ -1,5 +1,5 @@
1
1
  import { c as e, m as t } from "./__vite-browser-external-y2xWjzgx.js";
2
- import { $n as n, $t as r, D as i, F as a, I as o, J as s, Jn as c, Kn as l, L as u, Qn as d, Qt as f, T as p, Wn as m, Xn as h, Yn as g, Zn as _, Zt as v, en as y, er as b, j as x, qn as S, tr as C } from "./rolls-Cnu6g8th.js";
2
+ import { $n as n, $t as r, D as i, F as a, Gn as o, I as s, J as c, Jn as l, L as u, Qn as d, Qt as f, T as p, Xn as m, Yn as h, Zn as g, Zt as _, en as v, er as y, j as b, nr as x, qn as S, tr as C } from "./rolls-ZToBSscx.js";
3
3
  import { useCallback as w, useEffect as T, useMemo as E, useRef as D, useState as O } from "react";
4
4
  import { Fragment as k, jsx as A, jsxs as j } from "react/jsx-runtime";
5
5
  //#region src/editor/lib/viewport.js
@@ -182,23 +182,23 @@ function V({ children: e, className: t = "kol-mono-12 text-meta", always: n = !1
182
182
  }
183
183
  //#endregion
184
184
  //#region src/editor/params/AutoControls.jsx
185
- function H({ schema: e, layer: t, setProp: n, palette: a, renderAnimate: o, tab: s, emptyHint: c, inline: l = !0 }) {
186
- let u = y(e, t);
187
- if (s && (u = u.filter((e) => r(e) === s)), u.length === 0) return c ? /* @__PURE__ */ A(V, { children: c }) : null;
188
- let d = [];
189
- for (let e of u) {
190
- let t = f(e), n = d[d.length - 1];
191
- n && n.section === t ? n.params.push(e) : d.push({
185
+ function H({ schema: e, layer: t, setProp: n, palette: a, renderAnimate: s, tab: c, emptyHint: l, inline: u = !0 }) {
186
+ let d = v(e, t);
187
+ if (c && (d = d.filter((e) => r(e) === c)), d.length === 0) return l ? /* @__PURE__ */ A(V, { children: l }) : null;
188
+ let p = [];
189
+ for (let e of d) {
190
+ let t = f(e), n = p[p.length - 1];
191
+ n && n.section === t ? n.params.push(e) : p.push({
192
192
  section: t,
193
193
  params: [e]
194
194
  });
195
195
  }
196
- for (let e = 0; e < d.length; e++) {
197
- let t = d[e];
196
+ for (let e = 0; e < p.length; e++) {
197
+ let t = p[e];
198
198
  if (t.section) continue;
199
199
  let n = 0;
200
200
  for (; n < t.params.length && t.params[n].type === "select";) n++;
201
- n === 0 || n === t.params.length || (d.splice(e, 1, {
201
+ n === 0 || n === t.params.length || (p.splice(e, 1, {
202
202
  section: void 0,
203
203
  params: t.params.slice(0, n)
204
204
  }, {
@@ -206,54 +206,54 @@ function H({ schema: e, layer: t, setProp: n, palette: a, renderAnimate: o, tab:
206
206
  params: t.params.slice(n)
207
207
  }), e++);
208
208
  }
209
- return /* @__PURE__ */ A(k, { children: d.map((e) => {
210
- let r = Math.max(0, ...e.params.filter((e) => e.type === "range").map(U)), s = e.section && e.params.some((e) => e.collapsed), c = /* @__PURE__ */ A(h, {
211
- label: !s && e.section && e.section !== e.params[0].label ? e.section : void 0,
212
- divided: !s,
209
+ return /* @__PURE__ */ A(k, { children: p.map((e) => {
210
+ let r = Math.max(0, ...e.params.filter((e) => e.type === "range").map(U)), c = e.section && e.params.some((e) => e.collapsed), l = /* @__PURE__ */ A(g, {
211
+ label: !c && e.section && e.section !== e.params[0].label ? e.section : void 0,
212
+ divided: !c,
213
213
  children: e.params.map((e) => {
214
- let s = i(t[e.key]);
214
+ let o = i(t[e.key]);
215
215
  return /* @__PURE__ */ A(q, {
216
216
  param: e,
217
217
  layer: t,
218
218
  setProp: n,
219
219
  palette: a,
220
- bound: s,
221
- animate: o && v(e) ? o(e, s) : null,
222
- inline: l,
220
+ bound: o,
221
+ animate: s && _(e) ? s(e, o) : null,
222
+ inline: u,
223
223
  chars: r || void 0
224
224
  }, e.key);
225
225
  })
226
226
  }, e.params[0].key);
227
- return s ? /* @__PURE__ */ A(m, {
227
+ return c ? /* @__PURE__ */ A(o, {
228
228
  title: e.section,
229
- children: c
230
- }, e.params[0].key) : c;
229
+ children: l
230
+ }, e.params[0].key) : l;
231
231
  }) });
232
232
  }
233
233
  function U(e) {
234
234
  let t = e.step && e.step < 1 ? String(e.step).split(".")[1]?.length ?? 2 : 0;
235
235
  return Math.max(2, String(Math.round(e.max ?? 0)).length, String(Math.round(e.min ?? 0)).length) + (t ? t + 1 : 0);
236
236
  }
237
- function W({ param: n, layer: r, setProp: a, chars: o }) {
238
- let s = u(), l = r[n.key], f = i(l), p = f && l.bind === "mod" && l.source === "expr", m = e(f), h = f ? x(l, m, r) : l, g = typeof h == "number" ? h : n.default ?? 0, _ = n.step && n.step < 1 ? String(n.step).split(".")[1]?.length ?? 2 : 0, v = p ? l.transform?.expr ?? "wave(t)" : n.format ? String(n.format(g)) : _ ? g.toFixed(_) : String(Math.round(g)), y = o ?? U(n), [b, S] = O(v), [C, w] = O(!1);
237
+ function W({ param: r, layer: a, setProp: o, chars: s }) {
238
+ let c = u(), l = a[r.key], d = i(l), f = d && l.bind === "mod" && l.source === "expr", p = e(d), m = d ? b(l, p, a) : l, g = typeof m == "number" ? m : r.default ?? 0, _ = r.step && r.step < 1 ? String(r.step).split(".")[1]?.length ?? 2 : 0, v = f ? l.transform?.expr ?? "wave(t)" : r.format ? String(r.format(g)) : _ ? g.toFixed(_) : String(Math.round(g)), y = s ?? U(r), [x, S] = O(v), [C, w] = O(!1);
239
239
  return T(() => {
240
240
  C || S(v);
241
241
  }, [v, C]), /* @__PURE__ */ j("div", {
242
242
  className: "flex items-center gap-3",
243
- children: [!f && /* @__PURE__ */ A(d, {
244
- min: n.min,
245
- max: n.max,
246
- step: n.step ?? 1,
243
+ children: [!d && /* @__PURE__ */ A(n, {
244
+ min: r.min,
245
+ max: r.max,
246
+ step: r.step ?? 1,
247
247
  value: g,
248
- onChange: (e) => a(n.key, Number(e)),
248
+ onChange: (e) => o(r.key, Number(e)),
249
249
  readout: "none",
250
250
  className: "flex-1"
251
- }), /* @__PURE__ */ A(c, {
251
+ }), /* @__PURE__ */ A(h, {
252
252
  type: "text",
253
253
  variant: "filled",
254
- size: s,
254
+ size: c,
255
255
  width: `calc(${y}ch + 24px)`,
256
- value: b,
256
+ value: x,
257
257
  title: "Number sets a constant · an expression like sin(t) binds it",
258
258
  onFocus: (e) => {
259
259
  w(!0), e.target.select();
@@ -261,26 +261,26 @@ function W({ param: n, layer: r, setProp: a, chars: o }) {
261
261
  onChange: (e) => S(e.target.value),
262
262
  onBlur: () => {
263
263
  w(!1);
264
- let e = b.trim();
264
+ let e = x.trim();
265
265
  if (e === "") {
266
266
  S(v);
267
267
  return;
268
268
  }
269
- let r = Number(e);
270
- if (Number.isFinite(r)) {
271
- a(n.key, r);
269
+ let n = Number(e);
270
+ if (Number.isFinite(n)) {
271
+ o(r.key, n);
272
272
  return;
273
273
  }
274
274
  if (!t(e).ok) {
275
275
  S(v);
276
276
  return;
277
277
  }
278
- let i = f && l.transform?.range || (n.min != null && n.max != null ? [n.min, n.max] : [0, 1]);
279
- a(n.key, {
278
+ let i = d && l.transform?.range || (r.min != null && r.max != null ? [r.min, r.max] : [0, 1]);
279
+ o(r.key, {
280
280
  bind: "mod",
281
281
  source: "expr",
282
282
  transform: {
283
- ...f ? l.transform : {},
283
+ ...d ? l.transform : {},
284
284
  expr: e,
285
285
  range: i
286
286
  }
@@ -299,100 +299,100 @@ var G = a, K = {
299
299
  md: "h-[var(--kol-ctl-md)]",
300
300
  lg: "h-[var(--kol-ctl-lg)]"
301
301
  };
302
- function q({ param: e, layer: t, setProp: r, palette: i, bound: a, animate: s, inline: c, chars: d }) {
303
- let f = u(), m = t[e.key], h = m === void 0 ? e.default : m;
302
+ function q({ param: e, layer: t, setProp: n, palette: r, bound: i, animate: a, inline: o, chars: c }) {
303
+ let f = u(), h = t[e.key], g = h === void 0 ? e.default : h;
304
304
  if (e.type === "color") return /* @__PURE__ */ j("div", {
305
305
  className: "flex items-end gap-2",
306
306
  children: [/* @__PURE__ */ A("div", {
307
307
  className: "flex-1 min-w-0",
308
308
  children: /* @__PURE__ */ A(p, {
309
309
  label: e.label,
310
- value: h,
311
- onChange: (t) => r(e.key, t),
312
- palette: i,
313
- inline: c
310
+ value: g,
311
+ onChange: (t) => n(e.key, t),
312
+ palette: r,
313
+ inline: o
314
314
  })
315
- }), s]
315
+ }), a]
316
316
  });
317
- let v = c, y = null;
318
- if (e.type === "range") f !== "sm" && (v = !1), y = /* @__PURE__ */ A(W, {
317
+ let _ = o, v = null;
318
+ if (e.type === "range") f !== "sm" && (_ = !1), v = /* @__PURE__ */ A(W, {
319
319
  param: e,
320
320
  layer: t,
321
- setProp: r,
322
- chars: d
321
+ setProp: n,
322
+ chars: c
323
323
  });
324
- else if (e.type === "select") y = /* @__PURE__ */ A(S, {
324
+ else if (e.type === "select") v = /* @__PURE__ */ A(l, {
325
325
  variant: "subtle",
326
326
  size: f,
327
327
  className: "w-full",
328
328
  options: e.options ?? [],
329
- value: h,
330
- onChange: (t) => r(e.key, e.numeric ? Number(t) : t)
329
+ value: g,
330
+ onChange: (t) => n(e.key, e.numeric ? Number(t) : t)
331
331
  });
332
- else if (e.type === "segmented") y = c ? /* @__PURE__ */ A(l, {
332
+ else if (e.type === "segmented") v = o ? /* @__PURE__ */ A(S, {
333
333
  layout: "joined",
334
334
  tone: "sunken",
335
335
  size: f,
336
- className: `w-full ${o(f) ?? ""}`,
336
+ className: `w-full ${s(f) ?? ""}`,
337
337
  options: e.options ?? [],
338
- value: h,
339
- onChange: (t) => r(e.key, t)
340
- }) : /* @__PURE__ */ A(C, {
338
+ value: g,
339
+ onChange: (t) => n(e.key, t)
340
+ }) : /* @__PURE__ */ A(x, {
341
341
  size: f,
342
342
  options: e.options ?? [],
343
- viewMode: h,
344
- onViewChange: (t) => r(e.key, t)
343
+ viewMode: g,
344
+ onViewChange: (t) => n(e.key, t)
345
345
  });
346
346
  else if (e.type === "toggle") {
347
- let [t, n] = e.labels ?? ["Off", "On"];
348
- e.labels ? c ? y = /* @__PURE__ */ A(l, {
347
+ let [t, r] = e.labels ?? ["Off", "On"];
348
+ e.labels ? o ? v = /* @__PURE__ */ A(S, {
349
349
  layout: "joined",
350
350
  tone: "sunken",
351
351
  size: f,
352
- className: `w-full ${o(f) ?? ""}`,
352
+ className: `w-full ${s(f) ?? ""}`,
353
353
  options: [{
354
354
  value: "off",
355
355
  label: t
356
356
  }, {
357
357
  value: "on",
358
- label: n
358
+ label: r
359
359
  }],
360
- value: h ? "on" : "off",
361
- onChange: (t) => r(e.key, t === "on")
362
- }) : (v = !1, y = /* @__PURE__ */ A(C, {
360
+ value: g ? "on" : "off",
361
+ onChange: (t) => n(e.key, t === "on")
362
+ }) : (_ = !1, v = /* @__PURE__ */ A(x, {
363
363
  size: f,
364
364
  options: [{
365
365
  value: "off",
366
366
  label: t
367
367
  }, {
368
368
  value: "on",
369
- label: n
369
+ label: r
370
370
  }],
371
- viewMode: h ? "on" : "off",
372
- onViewChange: (t) => r(e.key, t === "on")
373
- })) : (c || (v = !1), y = /* @__PURE__ */ A(b, {
371
+ viewMode: g ? "on" : "off",
372
+ onViewChange: (t) => n(e.key, t === "on")
373
+ })) : (o || (_ = !1), v = /* @__PURE__ */ A(C, {
374
374
  size: f,
375
- checked: !!h,
376
- onChange: (t) => r(e.key, t)
375
+ checked: !!g,
376
+ onChange: (t) => n(e.key, t)
377
377
  }));
378
- } else if (e.type === "text") v = !1, y = /* @__PURE__ */ A(n, {
378
+ } else if (e.type === "text") _ = !1, v = /* @__PURE__ */ A(y, {
379
379
  variant: "filled",
380
380
  size: f,
381
381
  rows: e.rows ?? 2,
382
382
  axis: "y",
383
- value: h ?? "",
384
- onChange: (t) => r(e.key, t.target.value),
383
+ value: g ?? "",
384
+ onChange: (t) => n(e.key, t.target.value),
385
385
  placeholder: e.placeholder
386
386
  });
387
387
  else return null;
388
- let x = e.type === "range" && e.format && typeof h == "number" && !a ? e.format(h) : void 0, w = s ? /* @__PURE__ */ j("div", {
388
+ let b = e.type === "range" && e.format && typeof g == "number" && !i ? e.format(g) : void 0, w = a ? /* @__PURE__ */ j("div", {
389
389
  className: "flex items-center gap-2",
390
390
  children: [/* @__PURE__ */ A("div", {
391
391
  className: "flex-1 min-w-0",
392
- children: y
393
- }), s]
394
- }) : y, T = e.type === "toggle" && !e.labels ? "end" : "fill", E = e.type === "toggle" && !e.labels && !c, D = (e) => String(e).toUpperCase();
395
- return v && T === "end" && !x ? /* @__PURE__ */ A(g, {
392
+ children: v
393
+ }), a]
394
+ }) : v, T = e.type === "toggle" && !e.labels ? "end" : "fill", E = e.type === "toggle" && !e.labels && !o, D = (e) => String(e).toUpperCase();
395
+ return _ && T === "end" && !b ? /* @__PURE__ */ A(m, {
396
396
  horizontal: !0,
397
397
  label: D(e.label),
398
398
  labelWidth: G,
@@ -400,16 +400,16 @@ function q({ param: e, layer: t, setProp: r, palette: i, bound: a, animate: s, i
400
400
  className: `flex w-full items-center justify-end ${K[f] ?? ""}`,
401
401
  children: w
402
402
  })
403
- }) : v ? /* @__PURE__ */ A(_, {
403
+ }) : _ ? /* @__PURE__ */ A(d, {
404
404
  label: e.label,
405
- hint: x,
405
+ hint: b,
406
406
  align: T,
407
407
  labelWidth: G,
408
408
  children: w
409
- }) : /* @__PURE__ */ A(g, {
409
+ }) : /* @__PURE__ */ A(m, {
410
410
  horizontal: E,
411
- label: c ? D(e.label) : e.label,
412
- hint: x,
411
+ label: o ? D(e.label) : e.label,
412
+ hint: b,
413
413
  labelWidth: E ? "auto" : G,
414
414
  children: w
415
415
  });
@@ -417,7 +417,7 @@ function q({ param: e, layer: t, setProp: r, palette: i, bound: a, animate: s, i
417
417
  //#endregion
418
418
  //#region src/editor/compose/useLayerEdit.js
419
419
  function J(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
420
- let { updateLayer: r, beginTransaction: i, commitTransaction: a } = s(), o = D(null), c = w(() => {
420
+ let { updateLayer: r, beginTransaction: i, commitTransaction: a } = c(), o = D(null), s = w(() => {
421
421
  o.current !== null && (clearTimeout(o.current), o.current = null, a());
422
422
  }, [a]), l = w((s) => {
423
423
  if (e) {
@@ -441,14 +441,14 @@ function J(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
441
441
  i,
442
442
  a
443
443
  ]), u = w((e, t) => l({ [e]: t }), [l]);
444
- return T(() => () => c(), [c, e]), E(() => ({
444
+ return T(() => () => s(), [s, e]), E(() => ({
445
445
  patch: l,
446
446
  setProp: u,
447
- flush: c
447
+ flush: s
448
448
  }), [
449
449
  l,
450
450
  u,
451
- c
451
+ s
452
452
  ]);
453
453
  }
454
454
  //#endregion
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/design-editor",
3
- "version": "0.48.0",
3
+ "version": "0.49.0",
4
4
  "private": false,
5
5
  "description": "The design editor as one component",
6
6
  "license": "MIT",
@@ -23,6 +23,9 @@
23
23
  "./motion": {
24
24
  "import": "./dist/motion.js"
25
25
  },
26
+ "./kolbox-pages": {
27
+ "import": "./dist/kolbox-pages.js"
28
+ },
26
29
  "./style.css": "./dist/design-editor.css",
27
30
  "./kolbox.css": "./dist/kolbox.css"
28
31
  },
@@ -31,7 +34,7 @@
31
34
  "README.md"
32
35
  ],
33
36
  "peerDependencies": {
34
- "@kolkrabbi/kol-component": ">=0.380.0 <1",
37
+ "@kolkrabbi/kol-component": ">=0.381.0 <1",
35
38
  "@kolkrabbi/kol-framework": ">=0.44.0 <1",
36
39
  "@kolkrabbi/kol-hardware": ">=0.10.0 <1",
37
40
  "@kolkrabbi/kol-icons": ">=0.69.0 <1",
@@ -63,15 +66,15 @@
63
66
  "tailwindcss": "^4.2.4",
64
67
  "vite": "^8.0.10",
65
68
  "vite-plugin-svgr": "^5.2.0",
66
- "@kolkrabbi/kol-component": "0.380.0",
69
+ "@kolkrabbi/kol-component": "0.381.0",
67
70
  "@kolkrabbi/kol-framework": "0.74.1",
68
71
  "@kolkrabbi/kol-icons": "0.72.0",
69
72
  "@kolkrabbi/kol-theme": "0.227.0",
70
- "@kolkrabbi/kol-shell": "0.132.0",
71
- "@kolkrabbi/kol-dashboards": "0.18.0",
73
+ "@kolkrabbi/kol-media-client": "0.7.0",
72
74
  "@kolkrabbi/kol-tuner": "0.1.0",
73
75
  "@kolkrabbi/kol-hardware": "0.11.1",
74
- "@kolkrabbi/kol-media-client": "0.7.0"
76
+ "@kolkrabbi/kol-shell": "0.132.0",
77
+ "@kolkrabbi/kol-dashboards": "0.18.0"
75
78
  },
76
79
  "keywords": [
77
80
  "kol",