@kolkrabbi/design-editor 0.14.0 → 0.16.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 { K as e } from "./EditorIcon-BbFMmc1G.js";
2
+ import { G as e } from "./rolls-CkmuE-Ya.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.");
@@ -1,4 +1,4 @@
1
- import { B as e, C as t, H as n, Kt as r, M as i, S as a, V as o, Vt as s, h as c, p as l, y as u, z as d } from "./EditorIcon-BbFMmc1G.js";
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
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
3
  import { useCallback as x, useEffect as S, useMemo as C, useRef as w, useState as T } from "react";
4
4
  import { Fragment as E, jsx as D, jsxs as O } from "react/jsx-runtime";
@@ -11,15 +11,15 @@ function k({ children: e, className: t = "kol-mono-12 text-meta" }) {
11
11
  }
12
12
  //#endregion
13
13
  //#region src/editor/params/AutoControls.jsx
14
- function A({ schema: t, layer: r, setProp: i, palette: a, renderAnimate: s, tab: l, emptyHint: u, inline: f = !1 }) {
15
- let p = n(t, r);
16
- if (l && (p = p.filter((e) => o(e) === l)), p.length === 0) return u ? /* @__PURE__ */ D(k, { children: u }) : null;
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
17
  let m = [];
18
- for (let t of p) {
19
- let n = e(t), r = m[m.length - 1];
20
- r && r.section === n ? r.params.push(t) : m.push({
21
- section: n,
22
- params: [t]
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
23
  });
24
24
  }
25
25
  for (let e = 0; e < m.length; e++) {
@@ -39,21 +39,21 @@ function A({ schema: t, layer: r, setProp: i, palette: a, renderAnimate: s, tab:
39
39
  label: e.section && e.section !== e.params[0].label ? e.section : void 0,
40
40
  divided: !0,
41
41
  children: e.params.map((e) => {
42
- let t = c(r[e.key]);
42
+ let t = c(n[e.key]);
43
43
  return /* @__PURE__ */ D(N, {
44
44
  param: e,
45
- layer: r,
45
+ layer: n,
46
46
  setProp: i,
47
- palette: a,
47
+ palette: o,
48
48
  bound: t,
49
- animate: s && d(e) ? s(e, t) : null,
49
+ animate: s && r(e) ? s(e, t) : null,
50
50
  inline: f
51
51
  }, e.key);
52
52
  })
53
53
  }, e.params[0].key)) });
54
54
  }
55
- function j({ param: e, layer: n, setProp: i }) {
56
- let a = t(), o = n[e.key], l = c(o), d = l && o.bind === "mod" && o.source === "expr", f = s(l), m = l ? u(o, f, n) : o, h = typeof m == "number" ? m : e.default ?? 0, g = e.step && e.step < 1 ? String(e.step).split(".")[1]?.length ?? 2 : 0, _ = d ? o.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);
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
57
  return S(() => {
58
58
  b || y(_);
59
59
  }, [_, b]), /* @__PURE__ */ O("div", {
@@ -64,14 +64,14 @@ function j({ param: e, layer: n, setProp: i }) {
64
64
  max: e.max,
65
65
  step: e.step ?? 1,
66
66
  value: h,
67
- disabled: l,
68
- onChange: (t) => i(e.key, Number(t.target.value)),
67
+ disabled: u,
68
+ onChange: (t) => a(e.key, Number(t.target.value)),
69
69
  className: "slider-black flex-1 w-full cursor-pointer",
70
- style: l ? { opacity: .7 } : void 0
70
+ style: u ? { opacity: .7 } : void 0
71
71
  }), /* @__PURE__ */ D(p, {
72
72
  type: "text",
73
73
  variant: "filled",
74
- size: a,
74
+ size: o,
75
75
  chars: 5,
76
76
  value: v,
77
77
  title: "Number sets a constant · an expression like sin(t) binds it",
@@ -81,28 +81,28 @@ function j({ param: e, layer: n, setProp: i }) {
81
81
  onChange: (e) => y(e.target.value),
82
82
  onBlur: () => {
83
83
  x(!1);
84
- let t = v.trim();
85
- if (t === "") {
84
+ let n = v.trim();
85
+ if (n === "") {
86
86
  y(_);
87
87
  return;
88
88
  }
89
- let n = Number(t);
90
- if (Number.isFinite(n)) {
91
- i(e.key, n);
89
+ let r = Number(n);
90
+ if (Number.isFinite(r)) {
91
+ a(e.key, r);
92
92
  return;
93
93
  }
94
- if (!r(t).ok) {
94
+ if (!t(n).ok) {
95
95
  y(_);
96
96
  return;
97
97
  }
98
- let a = l && o.transform?.range || (e.min != null && e.max != null ? [e.min, e.max] : [0, 1]);
99
- i(e.key, {
98
+ let i = u && s.transform?.range || (e.min != null && e.max != null ? [e.min, e.max] : [0, 1]);
99
+ a(e.key, {
100
100
  bind: "mod",
101
101
  source: "expr",
102
102
  transform: {
103
- ...l ? o.transform : {},
104
- expr: t,
105
- range: a
103
+ ...u ? s.transform : {},
104
+ expr: n,
105
+ range: i
106
106
  }
107
107
  });
108
108
  },
@@ -114,88 +114,90 @@ function j({ param: e, layer: n, setProp: i }) {
114
114
  });
115
115
  }
116
116
  var M = 96;
117
- function N({ param: e, layer: n, setProp: r, palette: i, bound: o, animate: s, inline: c }) {
118
- let u = t(), d = n[e.key], p = d === void 0 ? e.default : d;
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
119
  if (e.type === "color") return /* @__PURE__ */ O("div", {
120
120
  className: "flex items-end gap-2",
121
121
  children: [/* @__PURE__ */ D("div", {
122
122
  className: "flex-1 min-w-0",
123
- children: /* @__PURE__ */ D(l, {
123
+ children: /* @__PURE__ */ D(o, {
124
124
  label: e.label,
125
125
  value: p,
126
- onChange: (t) => r(e.key, t),
127
- palette: i,
126
+ onChange: (t) => n(e.key, t),
127
+ palette: r,
128
128
  inline: c
129
129
  })
130
130
  }), s]
131
131
  });
132
132
  let h = c, x = null;
133
- if (e.type === "range") u !== "sm" && (h = !1), x = /* @__PURE__ */ D(j, {
133
+ if (e.type === "range") l !== "sm" && (h = !1), x = /* @__PURE__ */ D(j, {
134
134
  param: e,
135
- layer: n,
136
- setProp: r
135
+ layer: t,
136
+ setProp: n
137
137
  });
138
138
  else if (e.type === "select") x = /* @__PURE__ */ D(f, {
139
139
  variant: "subtle",
140
- size: u,
140
+ size: l,
141
141
  className: "w-full",
142
142
  options: e.options ?? [],
143
143
  value: p,
144
- onChange: (t) => r(e.key, e.numeric ? Number(t) : t)
144
+ onChange: (t) => n(e.key, e.numeric ? Number(t) : t)
145
145
  });
146
146
  else if (e.type === "segmented") x = c ? /* @__PURE__ */ D(g, {
147
- size: u,
148
- className: `w-full ${a(u) ?? ""}`,
147
+ variant: "filled",
148
+ size: l,
149
+ className: `w-full ${u(l) ?? ""}`,
149
150
  options: e.options ?? [],
150
151
  value: p,
151
- onChange: (t) => r(e.key, t)
152
+ onChange: (t) => n(e.key, t)
152
153
  }) : /* @__PURE__ */ D(b, {
153
- size: u,
154
+ size: l,
154
155
  options: e.options ?? [],
155
156
  viewMode: p,
156
- onViewChange: (t) => r(e.key, t)
157
+ onViewChange: (t) => n(e.key, t)
157
158
  });
158
159
  else if (e.type === "toggle") {
159
- let [t, n] = e.labels ?? ["Off", "On"];
160
+ let [t, r] = e.labels ?? ["Off", "On"];
160
161
  c && !e.labels ? x = /* @__PURE__ */ D(y, {
161
- size: u,
162
+ size: l,
162
163
  checked: !!p,
163
- onChange: (t) => r(e.key, t)
164
+ onChange: (t) => n(e.key, t)
164
165
  }) : c ? x = /* @__PURE__ */ D(g, {
165
- size: u,
166
- className: `w-full ${a(u) ?? ""}`,
166
+ variant: "filled",
167
+ size: l,
168
+ className: `w-full ${u(l) ?? ""}`,
167
169
  options: [{
168
170
  value: "off",
169
171
  label: t
170
172
  }, {
171
173
  value: "on",
172
- label: n
174
+ label: r
173
175
  }],
174
176
  value: p ? "on" : "off",
175
- onChange: (t) => r(e.key, t === "on")
177
+ onChange: (t) => n(e.key, t === "on")
176
178
  }) : (h = !1, x = /* @__PURE__ */ D(b, {
177
- size: u,
179
+ size: l,
178
180
  options: [{
179
181
  value: "off",
180
182
  label: t
181
183
  }, {
182
184
  value: "on",
183
- label: n
185
+ label: r
184
186
  }],
185
187
  viewMode: p ? "on" : "off",
186
- onViewChange: (t) => r(e.key, t === "on")
188
+ onViewChange: (t) => n(e.key, t === "on")
187
189
  }));
188
190
  } else if (e.type === "text") h = !1, x = /* @__PURE__ */ D(v, {
189
191
  variant: "filled",
190
- size: u,
192
+ size: l,
191
193
  rows: e.rows ?? 2,
192
194
  axis: "y",
193
195
  value: p ?? "",
194
- onChange: (t) => r(e.key, t.target.value),
196
+ onChange: (t) => n(e.key, t.target.value),
195
197
  placeholder: e.placeholder
196
198
  });
197
199
  else return null;
198
- let S = e.type === "range" && e.format && typeof p == "number" && !o ? e.format(p) : void 0, C = s ? /* @__PURE__ */ O("div", {
200
+ let S = e.type === "range" && e.format && typeof p == "number" && !a ? e.format(p) : void 0, C = s ? /* @__PURE__ */ O("div", {
199
201
  className: "flex items-center gap-2",
200
202
  children: [/* @__PURE__ */ D("div", {
201
203
  className: "flex-1 min-w-0",
@@ -218,29 +220,29 @@ function N({ param: e, layer: n, setProp: r, palette: i, bound: o, animate: s, i
218
220
  //#endregion
219
221
  //#region src/editor/compose/useLayerEdit.js
220
222
  function P(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
221
- let { updateLayer: r, beginTransaction: a, commitTransaction: o } = i(), s = w(null), c = x(() => {
222
- s.current !== null && (clearTimeout(s.current), s.current = null, o());
223
- }, [o]), l = x((i) => {
223
+ let { updateLayer: r, beginTransaction: i, commitTransaction: a } = s(), o = w(null), c = x(() => {
224
+ o.current !== null && (clearTimeout(o.current), o.current = null, a());
225
+ }, [a]), l = x((s) => {
224
226
  if (e) {
225
227
  if (t === "discrete") {
226
- r(e, i);
228
+ r(e, s);
227
229
  return;
228
230
  }
229
231
  if (t === "coalesce") {
230
- s.current === null && a(), r(e, i), s.current !== null && clearTimeout(s.current), s.current = setTimeout(() => {
231
- s.current = null, o();
232
+ o.current === null && i(), r(e, s), o.current !== null && clearTimeout(o.current), o.current = setTimeout(() => {
233
+ o.current = null, a();
232
234
  }, n);
233
235
  return;
234
236
  }
235
- r(e, i);
237
+ r(e, s);
236
238
  }
237
239
  }, [
238
240
  e,
239
241
  t,
240
242
  n,
241
243
  r,
242
- a,
243
- o
244
+ i,
245
+ a
244
246
  ]), u = x((e, t) => l({ [e]: t }), [l]);
245
247
  return S(() => () => c(), [c, e]), C(() => ({
246
248
  patch: l,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/design-editor",
3
- "version": "0.14.0",
3
+ "version": "0.16.0",
4
4
  "private": false,
5
5
  "description": "The Kolkrabbi design editor as one embeddable React component — a DOM/SVG vector + generative compositor (canvas, layers, palette/pattern/type generators, kinetic type, boolean geometry, image export). Consumes the @kolkrabbi/kol-* design system as peers. The one BUILT package in this repo (ARCHITECTURE §4 exception, 2026-09-03).",
6
6
  "license": "MIT",
@@ -30,14 +30,14 @@
30
30
  "README.md"
31
31
  ],
32
32
  "peerDependencies": {
33
- "@kolkrabbi/kol-component": ">=0.214.0 <1",
33
+ "@kolkrabbi/kol-component": ">=0.227.0 <1",
34
34
  "@kolkrabbi/kol-framework": ">=0.44.0 <1",
35
- "@kolkrabbi/kol-icons": ">=0.26.0 <1",
35
+ "@kolkrabbi/kol-icons": ">=0.29.0 <1",
36
36
  "@kolkrabbi/kol-media-client": ">=0.4.0 <1",
37
37
  "@kolkrabbi/kol-shell": ">=0.51.0 <1",
38
38
  "react": "^19.0.0",
39
39
  "react-dom": "^19.0.0",
40
- "@kolkrabbi/kol-theme": ">=0.145.0 <1"
40
+ "@kolkrabbi/kol-theme": ">=0.154.0 <1"
41
41
  },
42
42
  "dependencies": {
43
43
  "colord": "^2.9.3",
@@ -59,11 +59,11 @@
59
59
  "tailwindcss": "^4.2.4",
60
60
  "vite": "^8.0.10",
61
61
  "vite-plugin-svgr": "^5.2.0",
62
+ "@kolkrabbi/kol-icons": "0.29.0",
63
+ "@kolkrabbi/kol-component": "0.227.0",
64
+ "@kolkrabbi/kol-theme": "0.154.0",
62
65
  "@kolkrabbi/kol-framework": "0.44.0",
63
- "@kolkrabbi/kol-theme": "0.151.0",
64
- "@kolkrabbi/kol-shell": "0.57.0",
65
- "@kolkrabbi/kol-icons": "0.27.1",
66
- "@kolkrabbi/kol-component": "0.225.0",
66
+ "@kolkrabbi/kol-shell": "0.57.1",
67
67
  "@kolkrabbi/kol-media-client": "0.4.0"
68
68
  },
69
69
  "keywords": [
@@ -1,125 +0,0 @@
1
- import { Gt as e, Wt as t, h as n, qt as r, y as i, zt as a } from "./EditorIcon-BbFMmc1G.js";
2
- import { PopoverPanel as o, usePopover as s } from "@kolkrabbi/kol-component";
3
- import { useEffect as c, useState as l } from "react";
4
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
5
- //#region src/editor/params/dotVisibility.js
6
- var p = "kol-editor-show-dots", m = !1;
7
- try {
8
- m = localStorage.getItem(p) === "1";
9
- } catch {}
10
- var h = /* @__PURE__ */ new Set();
11
- function g() {
12
- m = !m;
13
- try {
14
- localStorage.setItem(p, m ? "1" : "0");
15
- } catch {}
16
- h.forEach((e) => e(m));
17
- }
18
- function _() {
19
- let [e, t] = l(m);
20
- return c(() => {
21
- let e = (e) => t(e);
22
- return h.add(e), () => h.delete(e);
23
- }, []), e;
24
- }
25
- //#endregion
26
- //#region src/editor/params/BindDot.jsx
27
- function v({ layer: c, param: p, setProp: m }) {
28
- let [h, g] = l(!1), v = s({
29
- open: h,
30
- onOpenChange: g,
31
- placement: "bottom-end",
32
- offset: 4,
33
- role: "menu"
34
- }), y = _(), b = c[p.key], x = n(b), S = x ? b.bind === "track" ? "track" : b.source : "none";
35
- if (!y && !x) return null;
36
- let C = () => i(b, a.getCtx(), c) ?? p.default ?? 0, w = () => p.min != null && p.max != null ? [p.min, p.max] : [0, 1], T = (e) => {
37
- if (g(!1), e === "none") m(p.key, C());
38
- else if (e === "track") {
39
- let e = C();
40
- m(p.key, {
41
- bind: "track",
42
- keys: [{
43
- t: 0,
44
- v: e,
45
- easing: "linear"
46
- }, {
47
- t: 1,
48
- v: e,
49
- easing: "linear"
50
- }]
51
- });
52
- } else t(e)?.ensure?.().catch(() => {}), m(p.key, {
53
- bind: "mod",
54
- source: e,
55
- transform: { range: w() }
56
- });
57
- }, E = p.type === "color" ? [] : e().filter((e) => !e.hidden), D = E.find((e) => r(e.id)), O = [
58
- {
59
- value: "none",
60
- label: "Constant"
61
- },
62
- {
63
- value: "track",
64
- label: "Keyframes"
65
- },
66
- ...E.filter((e) => !r(e.id)).map((e) => ({
67
- value: e.id,
68
- label: e.label
69
- })),
70
- ...D ? [{
71
- value: D.id,
72
- label: "Joystick"
73
- }] : []
74
- ];
75
- return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d("button", {
76
- ref: v.refs.setReference,
77
- ...v.getReferenceProps(),
78
- type: "button",
79
- "aria-label": `Modulate ${p.label ?? p.key}`,
80
- title: x ? `Modulated (${S}) — shape it in the Animation tab` : "Modulate",
81
- className: "inline-flex items-center justify-center w-5 h-5 rounded shrink-0",
82
- style: {
83
- border: "none",
84
- background: "transparent",
85
- cursor: "pointer"
86
- },
87
- children: /* @__PURE__ */ d("span", {
88
- "aria-hidden": "true",
89
- className: "rounded-full",
90
- style: {
91
- width: 7,
92
- height: 7,
93
- background: x ? "var(--kol-accent-primary)" : "transparent",
94
- border: `1.5px solid ${x ? "var(--kol-accent-primary)" : "var(--kol-fg-48)"}`
95
- }
96
- })
97
- }), /* @__PURE__ */ d(o, {
98
- popover: v,
99
- panel: !1,
100
- focus: !1,
101
- className: "z-50 bg-surface-secondary border border-oq-08 rounded shadow-lg",
102
- style: {
103
- maxHeight: "50vh",
104
- overflowY: "auto",
105
- overscrollBehavior: "contain"
106
- },
107
- children: /* @__PURE__ */ d("div", {
108
- className: "w-[220px]",
109
- children: O.map((e) => /* @__PURE__ */ f("button", {
110
- type: "button",
111
- onClick: () => T(e.value),
112
- className: "w-full kol-helper-12 px-3 h-8 inline-flex items-center gap-2 text-body hover:text-emphasis text-left",
113
- children: [/* @__PURE__ */ d("span", {
114
- className: "flex-1 truncate",
115
- children: e.label
116
- }), /* @__PURE__ */ d("span", {
117
- className: "kol-helper-10 text-emphasis shrink-0",
118
- children: S === e.value ? "✓" : ""
119
- })]
120
- }, e.value))
121
- })
122
- })] });
123
- }
124
- //#endregion
125
- export { g as n, v as t };