@kolkrabbi/design-editor 0.13.0 → 0.15.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 { t as e } from "./design-editor.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.");
@@ -0,0 +1,258 @@
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
+ c && !e.labels ? x = /* @__PURE__ */ D(y, {
162
+ size: l,
163
+ checked: !!p,
164
+ onChange: (t) => n(e.key, t)
165
+ }) : c ? x = /* @__PURE__ */ D(g, {
166
+ variant: "filled",
167
+ size: l,
168
+ className: `w-full ${u(l) ?? ""}`,
169
+ options: [{
170
+ value: "off",
171
+ label: t
172
+ }, {
173
+ value: "on",
174
+ label: r
175
+ }],
176
+ value: p ? "on" : "off",
177
+ onChange: (t) => n(e.key, t === "on")
178
+ }) : (h = !1, x = /* @__PURE__ */ D(b, {
179
+ size: l,
180
+ options: [{
181
+ value: "off",
182
+ label: t
183
+ }, {
184
+ value: "on",
185
+ label: r
186
+ }],
187
+ viewMode: p ? "on" : "off",
188
+ onViewChange: (t) => n(e.key, t === "on")
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";
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
+ label: c ? String(e.label).toUpperCase() : e.label,
215
+ hint: S,
216
+ labelWidth: M,
217
+ children: C
218
+ });
219
+ }
220
+ //#endregion
221
+ //#region src/editor/compose/useLayerEdit.js
222
+ function P(e, { history: t = "discrete", coalesceMs: n = 250 } = {}) {
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) => {
226
+ if (e) {
227
+ if (t === "discrete") {
228
+ r(e, s);
229
+ return;
230
+ }
231
+ if (t === "coalesce") {
232
+ o.current === null && i(), r(e, s), o.current !== null && clearTimeout(o.current), o.current = setTimeout(() => {
233
+ o.current = null, a();
234
+ }, n);
235
+ return;
236
+ }
237
+ r(e, s);
238
+ }
239
+ }, [
240
+ e,
241
+ t,
242
+ n,
243
+ r,
244
+ i,
245
+ a
246
+ ]), u = x((e, t) => l({ [e]: t }), [l]);
247
+ return S(() => () => c(), [c, e]), C(() => ({
248
+ patch: l,
249
+ setProp: u,
250
+ flush: c
251
+ }), [
252
+ l,
253
+ u,
254
+ c
255
+ ]);
256
+ }
257
+ //#endregion
258
+ export { A as n, k as r, P as t };
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@kolkrabbi/design-editor",
3
- "version": "0.13.0",
3
+ "version": "0.15.0",
4
4
  "private": false,
5
- "description": "The Kolkrabbi design editor as one embeddable React component \u2014 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 \u00a74 exception, 2026-09-03).",
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",
7
7
  "type": "module",
8
8
  "main": "./dist/design-editor.js",
@@ -11,16 +11,24 @@
11
11
  ".": {
12
12
  "import": "./dist/design-editor.js"
13
13
  },
14
+ "./core": {
15
+ "import": "./dist/core.js"
16
+ },
17
+ "./generators": {
18
+ "import": "./dist/generators.js"
19
+ },
20
+ "./effects": {
21
+ "import": "./dist/effects.js"
22
+ },
23
+ "./motion": {
24
+ "import": "./dist/motion.js"
25
+ },
14
26
  "./style.css": "./dist/design-editor.css"
15
27
  },
16
28
  "files": [
17
29
  "dist",
18
30
  "README.md"
19
31
  ],
20
- "scripts": {
21
- "build": "vite build --config vite.lib.config.js",
22
- "prepublishOnly": "pnpm build"
23
- },
24
32
  "peerDependencies": {
25
33
  "@kolkrabbi/kol-component": ">=0.214.0 <1",
26
34
  "@kolkrabbi/kol-framework": ">=0.44.0 <1",
@@ -44,19 +52,19 @@
44
52
  "three": "^0.185.1"
45
53
  },
46
54
  "devDependencies": {
47
- "@kolkrabbi/kol-component": "workspace:*",
48
- "@kolkrabbi/kol-framework": "workspace:*",
49
- "@kolkrabbi/kol-icons": "workspace:*",
50
- "@kolkrabbi/kol-media-client": "workspace:*",
51
- "@kolkrabbi/kol-shell": "workspace:*",
52
- "@kolkrabbi/kol-theme": "workspace:*",
53
55
  "@tailwindcss/vite": "^4.2.4",
54
56
  "@vitejs/plugin-react": "^6.0.1",
55
57
  "react": "^19.0.0",
56
58
  "react-dom": "^19.0.0",
57
59
  "tailwindcss": "^4.2.4",
58
60
  "vite": "^8.0.10",
59
- "vite-plugin-svgr": "^5.2.0"
61
+ "vite-plugin-svgr": "^5.2.0",
62
+ "@kolkrabbi/kol-framework": "0.44.0",
63
+ "@kolkrabbi/kol-component": "0.226.0",
64
+ "@kolkrabbi/kol-icons": "0.28.0",
65
+ "@kolkrabbi/kol-shell": "0.57.1",
66
+ "@kolkrabbi/kol-theme": "0.153.0",
67
+ "@kolkrabbi/kol-media-client": "0.4.0"
60
68
  },
61
69
  "keywords": [
62
70
  "kol",
@@ -72,5 +80,9 @@
72
80
  },
73
81
  "publishConfig": {
74
82
  "access": "public"
83
+ },
84
+ "scripts": {
85
+ "build": "vite build --config vite.lib.config.js",
86
+ "check:core": "node scripts/check-core.mjs"
75
87
  }
76
- }
88
+ }