@kolkrabbi/design-editor 0.20.0 → 0.21.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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@kolkrabbi/design-editor",
3
- "version": "0.20.0",
3
+ "version": "0.21.0",
4
4
  "private": false,
5
5
  "description": "The design editor as one component",
6
6
  "license": "MIT",
@@ -59,12 +59,12 @@
59
59
  "tailwindcss": "^4.2.4",
60
60
  "vite": "^8.0.10",
61
61
  "vite-plugin-svgr": "^5.2.0",
62
+ "@kolkrabbi/kol-component": "0.240.0",
62
63
  "@kolkrabbi/kol-framework": "0.49.0",
63
- "@kolkrabbi/kol-component": "0.239.1",
64
- "@kolkrabbi/kol-icons": "0.33.1",
64
+ "@kolkrabbi/kol-media-client": "0.4.1",
65
+ "@kolkrabbi/kol-shell": "0.62.0",
65
66
  "@kolkrabbi/kol-theme": "0.166.0",
66
- "@kolkrabbi/kol-media-client": "0.4.0",
67
- "@kolkrabbi/kol-shell": "0.61.0"
67
+ "@kolkrabbi/kol-icons": "0.33.1"
68
68
  },
69
69
  "keywords": [
70
70
  "kol",
@@ -1,127 +0,0 @@
1
- import { Bt as e, Ft as t, Ut as n, Vt as r, m as i, v as a } from "./rolls-CkmuE-Ya.js";
2
- import { PopoverPanel as o, Tooltip as s, usePopover as c } from "@kolkrabbi/kol-component";
3
- import { useEffect as l, useState as u } from "react";
4
- import { Fragment as d, jsx as f, jsxs as p } from "react/jsx-runtime";
5
- //#region src/editor/params/dotVisibility.js
6
- var m = "kol-editor-show-dots", h = !1;
7
- try {
8
- h = localStorage.getItem(m) === "1";
9
- } catch {}
10
- var g = /* @__PURE__ */ new Set();
11
- function _() {
12
- h = !h;
13
- try {
14
- localStorage.setItem(m, h ? "1" : "0");
15
- } catch {}
16
- g.forEach((e) => e(h));
17
- }
18
- function v() {
19
- let [e, t] = u(h);
20
- return l(() => {
21
- let e = (e) => t(e);
22
- return g.add(e), () => g.delete(e);
23
- }, []), e;
24
- }
25
- //#endregion
26
- //#region src/editor/params/BindDot.jsx
27
- function y({ layer: l, param: m, setProp: h }) {
28
- let [g, _] = u(!1), y = c({
29
- open: g,
30
- onOpenChange: _,
31
- placement: "bottom-end",
32
- offset: 4,
33
- role: "menu"
34
- }), b = v(), x = l[m.key], S = i(x), C = S ? x.bind === "track" ? "track" : x.source : "none";
35
- if (!b && !S) return null;
36
- let w = () => a(x, t.getCtx(), l) ?? m.default ?? 0, T = () => m.min != null && m.max != null ? [m.min, m.max] : [0, 1], E = (t) => {
37
- if (_(!1), t === "none") h(m.key, w());
38
- else if (t === "track") {
39
- let e = w();
40
- h(m.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 e(t)?.ensure?.().catch(() => {}), h(m.key, {
53
- bind: "mod",
54
- source: t,
55
- transform: { range: T() }
56
- });
57
- }, D = m.type === "color" ? [] : r().filter((e) => !e.hidden), O = D.find((e) => n(e.id)), k = [
58
- {
59
- value: "none",
60
- label: "Constant"
61
- },
62
- {
63
- value: "track",
64
- label: "Keyframes"
65
- },
66
- ...D.filter((e) => !n(e.id)).map((e) => ({
67
- value: e.id,
68
- label: e.label
69
- })),
70
- ...O ? [{
71
- value: O.id,
72
- label: "Joystick"
73
- }] : []
74
- ];
75
- return /* @__PURE__ */ p(d, { children: [/* @__PURE__ */ f(s, {
76
- label: S ? `Modulated (${C}) — shape it in the Animation tab` : "Modulate",
77
- children: /* @__PURE__ */ f("button", {
78
- ref: y.refs.setReference,
79
- ...y.getReferenceProps(),
80
- type: "button",
81
- "aria-label": `Modulate ${m.label ?? m.key}`,
82
- className: "inline-flex items-center justify-center w-5 h-5 rounded shrink-0",
83
- style: {
84
- border: "none",
85
- background: "transparent",
86
- cursor: "pointer"
87
- },
88
- children: /* @__PURE__ */ f("span", {
89
- "aria-hidden": "true",
90
- className: "rounded-full",
91
- style: {
92
- width: 7,
93
- height: 7,
94
- background: S ? "var(--kol-accent-primary)" : "transparent",
95
- border: `1.5px solid ${S ? "var(--kol-accent-primary)" : "var(--kol-fg-48)"}`
96
- }
97
- })
98
- })
99
- }), /* @__PURE__ */ f(o, {
100
- popover: y,
101
- panel: !1,
102
- focus: !1,
103
- className: "z-50 bg-surface-secondary border border-oq-08 rounded shadow-lg",
104
- style: {
105
- maxHeight: "50vh",
106
- overflowY: "auto",
107
- overscrollBehavior: "contain"
108
- },
109
- children: /* @__PURE__ */ f("div", {
110
- className: "w-[220px]",
111
- children: k.map((e) => /* @__PURE__ */ p("button", {
112
- type: "button",
113
- onClick: () => E(e.value),
114
- className: "w-full kol-helper-12 px-3 h-8 inline-flex items-center gap-2 text-body hover:text-emphasis text-left",
115
- children: [/* @__PURE__ */ f("span", {
116
- className: "flex-1 truncate",
117
- children: e.label
118
- }), /* @__PURE__ */ f("span", {
119
- className: "kol-helper-10 text-emphasis shrink-0",
120
- children: C === e.value ? "✓" : ""
121
- })]
122
- }, e.value))
123
- })
124
- })] });
125
- }
126
- //#endregion
127
- export { _ as n, y as t };
@@ -1,303 +0,0 @@
1
- import { S as e } from "./rolls-CkmuE-Ya.js";
2
- import { Dropdown as t, LabeledControl as n, SettingsRow as r, embedFontFace as i } from "@kolkrabbi/kol-component";
3
- import { Fragment as a, jsx as o, jsxs as s } from "react/jsx-runtime";
4
- //#region src/loops/lib/util.js
5
- var c = Math.PI * 2, l = (e) => Math.max(0, Math.min(1, e)), u = (e, t, n) => e + (t - e) * n, d = (e) => parseInt(e, 16);
6
- function f(e) {
7
- let t = String(e || "").replace("#", ""), n = t.length === 3 ? t.split("").map((e) => e + e).join("") : t;
8
- return n.length < 6 ? [
9
- 0,
10
- 0,
11
- 0
12
- ] : [
13
- d(n.slice(0, 2)),
14
- d(n.slice(2, 4)),
15
- d(n.slice(4, 6))
16
- ];
17
- }
18
- function p(e, t, n) {
19
- let r = f(e), i = f(t);
20
- return `rgb(${Math.round(u(r[0], i[0], n))}, ${Math.round(u(r[1], i[1], n))}, ${Math.round(u(r[2], i[2], n))})`;
21
- }
22
- //#endregion
23
- //#region src/kinetic/fonts.js
24
- var m = [
25
- {
26
- key: "rot",
27
- label: "Rot",
28
- family: "TG Rot",
29
- url: "/fonts/TG/TGRotVF.ttf",
30
- axes: [{
31
- tag: "wdth",
32
- min: 64,
33
- max: 172,
34
- def: 100
35
- }, {
36
- tag: "wght",
37
- min: 100,
38
- max: 900,
39
- def: 400
40
- }]
41
- },
42
- {
43
- key: "malromur",
44
- label: "Malromur",
45
- family: "TG Malromur",
46
- url: "/fonts/TG/TGMalromurRomanVF.ttf",
47
- axes: [{
48
- tag: "wght",
49
- min: 300,
50
- max: 900,
51
- def: 300
52
- }]
53
- },
54
- {
55
- key: "gullhamrar",
56
- label: "Gullhamrar",
57
- family: "TG Gullhamrar",
58
- url: "/fonts/TG/TGGullhamrarVF.ttf",
59
- axes: [{
60
- tag: "wght",
61
- min: 300,
62
- max: 900,
63
- def: 300
64
- }]
65
- }
66
- ], h = m.map((e) => ({
67
- value: e.key,
68
- label: e.label
69
- })), g = {
70
- wght: "Weight",
71
- wdth: "Width",
72
- ital: "Italic",
73
- slnt: "Slant",
74
- opsz: "Optical size"
75
- }, _ = (e) => m.find((t) => t.key === e) || m[0];
76
- function v(e) {
77
- let t = {};
78
- for (let n of e.axes) t[n.tag] = n.def;
79
- return t;
80
- }
81
- function y(e) {
82
- let t = Object.entries(e || {}).map(([e, t]) => `'${e}' ${Math.round(t * 100) / 100}`);
83
- return t.length ? t.join(", ") : "normal";
84
- }
85
- var b = !1;
86
- async function x() {
87
- if (!(b || typeof FontFace > "u")) {
88
- b = !0;
89
- for (let e of m) {
90
- let t = {}, n = e.axes.find((e) => e.tag === "wght"), r = e.axes.find((e) => e.tag === "wdth");
91
- n && (t.weight = `${n.min} ${n.max}`), r && (t.stretch = `${r.min}% ${r.max}%`);
92
- try {
93
- let n = new FontFace(e.family, `url(${e.url})`, t);
94
- document.fonts.add(n), n.load().catch(() => {});
95
- } catch {}
96
- }
97
- try {
98
- await document.fonts.ready;
99
- } catch {}
100
- }
101
- }
102
- var S = /* @__PURE__ */ new Map(), C = null;
103
- function w() {
104
- return C || (C = Promise.all(m.map(async (e) => {
105
- if (!S.has(e.url)) try {
106
- S.set(e.url, await i({
107
- family: e.family,
108
- url: e.url
109
- }));
110
- } catch (t) {
111
- console.warn(`[design-editor] font not embedded, export will fall back for ${e.family}:`, t);
112
- }
113
- })), C);
114
- }
115
- function T(e) {
116
- let t = /* @__PURE__ */ new Set();
117
- for (let n of e?.instances ?? []) t.add(_(n.font).url);
118
- return [...t].map((e) => S.get(e)).filter(Boolean).join("\n");
119
- }
120
- //#endregion
121
- //#region src/loops/lib/themes.js
122
- var E = [
123
- {
124
- id: "dark",
125
- label: "Dark",
126
- bg: "#050506",
127
- fg: "#9ec1ff",
128
- accent: "#9ec1ff",
129
- dim: "#4a4d60",
130
- warm: "#f3c9c4",
131
- grid: "#ffffff",
132
- gridOpacity: .1
133
- },
134
- {
135
- id: "paper",
136
- label: "Paper",
137
- bg: "#f4f1ea",
138
- fg: "#16202e",
139
- accent: "#3b5b8a",
140
- dim: "#6b7280",
141
- warm: "#b0623a",
142
- grid: "#16202e",
143
- gridOpacity: .14
144
- },
145
- {
146
- id: "blueprint",
147
- label: "Blueprint",
148
- bg: "#0b1d3a",
149
- fg: "#8fd3ff",
150
- accent: "#8fd3ff",
151
- dim: "#3f5a78",
152
- warm: "#e3a054",
153
- grid: "#8fd3ff",
154
- gridOpacity: .2
155
- },
156
- {
157
- id: "mono",
158
- label: "Mono",
159
- bg: "#0a0a0a",
160
- fg: "#ededed",
161
- accent: "#ededed",
162
- dim: "#8a8a8a",
163
- warm: "#d8c4a0",
164
- grid: "#ffffff",
165
- gridOpacity: .08
166
- },
167
- {
168
- id: "amber",
169
- label: "Amber",
170
- bg: "#0c0a06",
171
- fg: "#ffb35c",
172
- accent: "#ffcf8a",
173
- dim: "#8a6a3a",
174
- warm: "#ffd8a0",
175
- grid: "#ffcf8a",
176
- gridOpacity: .12
177
- },
178
- {
179
- id: "ink",
180
- label: "Ink",
181
- bg: "#0a0b14",
182
- fg: "#f0ead8",
183
- accent: "#8b8fd6",
184
- dim: "#4a4d60",
185
- warm: "#f3c9c4",
186
- grid: "#f0ead8",
187
- gridOpacity: .07
188
- },
189
- {
190
- id: "slate",
191
- label: "Slate",
192
- bg: "#12161d",
193
- fg: "#e7eef5",
194
- accent: "#7fb0d8",
195
- dim: "#566273",
196
- warm: "#cfe0ee",
197
- grid: "#e7eef5",
198
- gridOpacity: .07
199
- },
200
- {
201
- id: "plum",
202
- label: "Plum",
203
- bg: "#120a17",
204
- fg: "#f0e6f3",
205
- accent: "#c08bd6",
206
- dim: "#5e4a66",
207
- warm: "#f3c9e8",
208
- grid: "#f0e6f3",
209
- gridOpacity: .07
210
- },
211
- {
212
- id: "kol",
213
- label: "KOL",
214
- bg: "#121215",
215
- fg: "#FAF7F0",
216
- accent: "#FFCF33",
217
- dim: "#3F6485",
218
- warm: "#E3A054",
219
- grid: "#FAF7F0",
220
- gridOpacity: .1
221
- }
222
- ], D = E.map((e) => ({
223
- value: e.id,
224
- label: e.label
225
- }));
226
- function O(e) {
227
- return E.find((t) => t.id === e) || E[0];
228
- }
229
- function k(e, t = !1) {
230
- let n = O(e);
231
- return t ? {
232
- ...n,
233
- bg: n.fg,
234
- fg: n.bg,
235
- grid: n.bg
236
- } : { ...n };
237
- }
238
- //#endregion
239
- //#region src/editor/compose/inspectors/TreePicker.jsx
240
- function A(n) {
241
- return /* @__PURE__ */ o(t, {
242
- variant: "subtle",
243
- size: e(),
244
- className: "w-full",
245
- ...n
246
- });
247
- }
248
- function j({ label: e, options: t, value: i, onChange: a, children: s, inline: c = !1 }) {
249
- let l = s ?? /* @__PURE__ */ o(A, {
250
- options: t,
251
- value: i,
252
- onChange: a
253
- });
254
- return c ? /* @__PURE__ */ o(r, {
255
- label: e,
256
- align: "fill",
257
- labelWidth: 96,
258
- children: l
259
- }) : /* @__PURE__ */ o(n, {
260
- label: e,
261
- children: l
262
- });
263
- }
264
- function M({ tree: e, presets: t, current: n, onPick: r, inline: i = !1 }) {
265
- let c = e.find((e) => e.subs.includes(n.sub)) ?? e[0], l = t.filter((e) => e.sub === n.sub), u = (e) => t.find((t) => t.sub === e);
266
- return /* @__PURE__ */ s(a, { children: [
267
- /* @__PURE__ */ o(j, {
268
- inline: i,
269
- label: "Type",
270
- options: e.map((e) => ({
271
- value: e.label,
272
- label: e.label
273
- })),
274
- value: c.label,
275
- onChange: (t) => {
276
- let n = e.find((e) => e.label === t);
277
- n && r(u(n.subs[0]));
278
- }
279
- }),
280
- /* @__PURE__ */ o(j, {
281
- inline: i,
282
- label: "Category",
283
- options: c.subs.map((e) => ({
284
- value: e,
285
- label: e
286
- })),
287
- value: n.sub,
288
- onChange: (e) => r(u(e))
289
- }),
290
- /* @__PURE__ */ o(j, {
291
- inline: i,
292
- label: "Preset",
293
- options: l.map((e) => ({
294
- value: e.id,
295
- label: e.label
296
- })),
297
- value: n.id,
298
- onChange: (e) => r(t.find((t) => t.id === e))
299
- })
300
- ] });
301
- }
302
- //#endregion
303
- export { l as _, k as a, p as b, m as c, _ as d, T as f, c as g, w as h, D as i, h as l, y as m, j as n, O as o, x as p, M as r, g as s, A as t, v as u, f as v, u as y };
@@ -1,40 +0,0 @@
1
- //#region src/editor/compose/labels.js
2
- var e = {
3
- background: "Background",
4
- pattern: "Pattern",
5
- photo: "Photo",
6
- shape: "Shape",
7
- text: "Text",
8
- group: "Group",
9
- bool: "Boolean",
10
- loop: "Loop",
11
- kinetic: "Kinetic type",
12
- misc: "Misc"
13
- }, t = {
14
- unite: "Unite",
15
- subtract: "Subtract",
16
- intersect: "Intersect",
17
- exclude: "Exclude"
18
- }, n = {
19
- logo: "Logo",
20
- rect: "Rectangle",
21
- ellipse: "Ellipse",
22
- triangle: "Triangle",
23
- line: "Line",
24
- polygon: "Polygon",
25
- star: "Star",
26
- flatten: "Flatten"
27
- };
28
- function r(r) {
29
- if (r.type === "shape") return `Shape · ${n[r.kind ?? "logo"] ?? "Shape"}`;
30
- if (r.type === "bool") {
31
- let n = t[r.op];
32
- return n ? `Boolean · ${n}` : e.bool;
33
- }
34
- return r.type === "loop" && r.presetLabel ? `Loop · ${r.presetLabel}` : r.type === "misc" && r.presetLabel ? `Misc · ${r.presetLabel}` : r.type === "kinetic" && r.presetLabel ? `Kinetic · ${r.presetLabel}` : e[r.type] ?? r.type;
35
- }
36
- function i(r) {
37
- return r.name ? r.name : r.type === "text" ? r.text || e.text : r.type === "shape" ? n[r.kind ?? "logo"] ?? e.shape : r.type === "bool" ? t[r.op] ?? e.bool : r.type === "loop" || r.type === "misc" ? r.presetLabel || e[r.type] : r.type === "kinetic" ? r.presetLabel || e.kinetic : e[r.type] ?? r.type;
38
- }
39
- //#endregion
40
- export { i as n, r as t };