@kolkrabbi/design-editor 0.12.0 → 0.14.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.
@@ -0,0 +1,125 @@
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 };