@hashrock/ono-visual-editor 0.1.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/dist/style.css ADDED
@@ -0,0 +1 @@
1
+ .ono-ve,.ono-ve *,.ono-ve *:before,.ono-ve *:after{margin:0;padding:0;box-sizing:border-box}.ono-ve{font-family:-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,sans-serif;height:100%;min-height:0;display:flex;flex-direction:column;background:#1e1e1e;color:#d4d4d4;font-size:13px}.ono-ve header{padding:.6rem 1rem;background:#252526;border-bottom:1px solid #3e3e42;display:flex;align-items:center;gap:1rem}.ono-ve h1{font-size:1.1rem;font-weight:600;color:#fff}.ono-ve .tagline{color:#8b949e}.ono-ve .spacer{flex:1}.ono-ve button{padding:.35rem .7rem;background:#3e3e42;color:#e8e8e8;border:none;border-radius:4px;cursor:pointer;font-size:12px}.ono-ve button:hover{background:#4e4e52}.ono-ve button.primary{background:#0e639c}.ono-ve button.primary:hover{background:#17b}.ono-ve button.danger{background:#7a2323}.ono-ve button.danger:hover{background:#9a2d2d}.ono-ve button:disabled{opacity:.4;cursor:default}.ono-ve .container{flex:1;display:grid;grid-template-columns:minmax(280px,1fr) minmax(320px,1.4fr) 300px;gap:1px;background:#3e3e42;overflow:hidden}.ono-ve .panel{background:#1e1e1e;display:flex;flex-direction:column;overflow:hidden;min-width:0}.ono-ve .panel-header{padding:.5rem .8rem;background:#252526;border-bottom:1px solid #3e3e42;font-weight:500;display:flex;align-items:center;gap:.5rem}.ono-ve .tabs{display:flex;background:#252526;border-bottom:1px solid #3e3e42;overflow-x:auto}.ono-ve .tab{padding:.4rem .8rem;background:#2d2d2d;border-radius:0;border-right:1px solid #3e3e42;color:#8b949e;white-space:nowrap}.ono-ve .tab.active{background:#1e1e1e;color:#fff}.ono-ve .fill{flex:1;position:relative;overflow:hidden}.ono-ve .editor{width:100%;height:100%;padding:.8rem;font-family:Menlo,Monaco,Ubuntu Mono,monospace;font-size:13px;line-height:1.5;background:#1e1e1e;color:#d4d4d4;border:none;outline:none;resize:none;tab-size:2;white-space:pre;display:none}.ono-ve .editor.active{display:block}.ono-ve .preview{width:100%;height:100%;border:none;background:#fff}.ono-ve .inspector{padding:.8rem;overflow-y:auto;display:flex;flex-direction:column;gap:.9rem}.ono-ve .inspector .empty{color:#8b949e;line-height:1.6}.ono-ve .field label{display:block;color:#8b949e;margin-bottom:.25rem;font-size:11px;text-transform:uppercase;letter-spacing:.05em}.ono-ve .field input,.ono-ve .field textarea{width:100%;background:#2d2d2d;border:1px solid #3e3e42;border-radius:4px;color:#e8e8e8;padding:.4rem .5rem;font-family:Menlo,Monaco,monospace;font-size:12px}.ono-ve .field textarea{resize:vertical;min-height:60px}.ono-ve .chips{display:flex;flex-wrap:wrap;gap:.3rem;align-items:center}.ono-ve .chip{display:inline-flex;align-items:center;gap:.3rem;background:#0e639c33;border:1px solid #0e639c88;color:#cfe8ff;border-radius:999px;padding:.15rem .5rem;font-family:Menlo,Monaco,monospace;font-size:11px;cursor:pointer}.ono-ve .chip:hover{background:#7a232366;border-color:#f48771}.ono-ve .chip b{font-weight:400;color:#8b949e}.ono-ve .chip-input{background:transparent!important;border:1px dashed #3e3e42!important;min-width:90px;flex:1;padding:.2rem .4rem!important;font-size:11px!important}.ono-ve .group{border-top:1px solid #2d2d2d;margin-top:.5rem;padding-top:.3rem}.ono-ve .group summary{cursor:pointer;color:#8b949e;font-size:11px;text-transform:uppercase;letter-spacing:.05em;padding:.2rem 0;list-style:none}.ono-ve .group summary:before{content:"▸ "}.ono-ve .group[open] summary:before{content:"▾ "}.ono-ve .control{display:grid;grid-template-columns:82px 1fr;align-items:start;gap:.4rem;margin:.3rem 0}.ono-ve .control-label{color:#8b949e;font-size:11px;padding-top:.25rem}.ono-ve .control select{width:100%;background:#2d2d2d;color:#e8e8e8;border:1px solid #3e3e42;border-radius:4px;padding:.2rem .3rem;font-family:Menlo,Monaco,monospace;font-size:11px}.ono-ve .color{display:flex;flex-direction:column;gap:.25rem}.ono-ve .swatches{display:flex;flex-wrap:wrap;gap:3px}.ono-ve .swatch{width:16px;height:16px;padding:0;border-radius:3px;border:1px solid #ffffff22;background:transparent;cursor:pointer}.ono-ve .swatch.none{background:repeating-linear-gradient(45deg,#444 0 3px,#222 3px 6px)}.ono-ve .swatch.on{outline:2px solid #fff;outline-offset:1px}.ono-ve .swatch:hover{transform:scale(1.2)}.ono-ve .field input:disabled,.ono-ve .field textarea:disabled{opacity:.4}.ono-ve .field .hint{color:#6e7681;margin-top:.25rem;font-size:11px}.ono-ve .selected-tag{font-family:Menlo,Monaco,monospace;color:#4ec9b0;font-size:14px}.ono-ve .selected-file{color:#8b949e;font-size:11px}.ono-ve .row{display:flex;gap:.4rem;flex-wrap:wrap}.ono-ve .row button{flex:1 1 auto}.ono-ve .section-title{color:#8b949e;font-size:11px;text-transform:uppercase;letter-spacing:.05em;margin-bottom:.4rem}.ono-ve .status{padding:.4rem 1rem;background:#252526;border-top:1px solid #3e3e42;font-size:12px;color:#8b949e}.ono-ve .status.error{color:#f48771;background:#3a1515}.ono-ve .status.processing{color:#4ec9b0}.ono-ve .checkbox{color:#8b949e;display:flex;gap:.3rem;align-items:center;font-weight:400}.ono-ve .palette{display:flex;flex-wrap:wrap;gap:.3rem;padding:.4rem .6rem;background:#252526;border-bottom:1px solid #3e3e42}.ono-ve .tile{display:inline-flex;align-items:center;gap:.35rem;padding:.25rem .55rem;background:#2d2d2d;border:1px solid #3e3e42;border-radius:4px;color:#d4d4d4;font-size:11px;cursor:grab}.ono-ve .tile:hover{background:#3e3e42;border-color:#0e639c}.ono-ve .tile:active{cursor:grabbing}.ono-ve .tile:disabled{opacity:1;cursor:grab;color:#8b949e}.ono-ve .tile-icon{font-size:12px;width:1.1em;text-align:center;color:#4ec9b0}
@@ -0,0 +1,451 @@
1
+ import { parse as R } from "sucrase/dist/parser/index.js";
2
+ import { TokenType as a } from "sucrase/dist/parser/tokenizer/types.js";
3
+ const N = "data-ono-id", Y = ["class", "className"];
4
+ function C(e, t = "index.jsx") {
5
+ const { tokens: n } = R(e, !0, /\.tsx?$/.test(t), !1), s = [], r = [];
6
+ let i = 0;
7
+ const h = () => r[r.length - 1];
8
+ for (; i < n.length; ) {
9
+ const l = n[i], o = h();
10
+ if (l.type === a.jsxTagStart) {
11
+ const f = n[i + 1];
12
+ if (f && f.type === a.slash) {
13
+ let g = i + 2;
14
+ for (; n[g] && n[g].type !== a.jsxTagEnd; ) g++;
15
+ const y = r.pop();
16
+ y && (y.element.closeStart = l.start, y.element.end = n[g].end), i = g + 1;
17
+ continue;
18
+ }
19
+ let d = i + 1, p = "", w = l.end;
20
+ for (; n[d] && (n[d].type === a.jsxName || n[d].type === a.dot) && n[d].start === w; )
21
+ p += e.slice(n[d].start, n[d].end), w = n[d].end, d++;
22
+ const b = {
23
+ index: s.length,
24
+ tag: p,
25
+ start: l.start,
26
+ end: -1,
27
+ nameEnd: w,
28
+ openEnd: -1,
29
+ closeStart: -1,
30
+ selfClosing: !1,
31
+ host: /^[a-z]/.test(p),
32
+ attrs: [],
33
+ children: [],
34
+ parent: o ? o.element : null
35
+ };
36
+ s.push(b), o && o.element.children.push({ type: "element", element: b }), r.push({ element: b, phase: "open", depth: 0, exprStart: -1 }), i = d;
37
+ continue;
38
+ }
39
+ if (!o) {
40
+ i++;
41
+ continue;
42
+ }
43
+ const m = o.element;
44
+ if (o.depth > 0) {
45
+ l.type === a.braceL ? o.depth++ : l.type === a.braceR && --o.depth === 0 && (o.attr ? (o.attr.valueEnd = l.end, o.attr.end = l.end, o.attr = null) : o.phase === "children" && m.children.push({ type: "expr", start: o.exprStart, end: l.end })), i++;
46
+ continue;
47
+ }
48
+ if (o.phase === "open") {
49
+ if (l.type === a.jsxName) {
50
+ const f = {
51
+ name: e.slice(l.start, l.end),
52
+ start: l.start,
53
+ end: l.end,
54
+ valueStart: -1,
55
+ valueEnd: -1,
56
+ value: null
57
+ };
58
+ m.attrs.push(f);
59
+ const d = n[i + 1];
60
+ if (d && d.type === a.eq) {
61
+ const p = n[i + 2];
62
+ if (p.type === a.string) {
63
+ f.valueStart = p.start, f.valueEnd = p.end, f.end = p.end, f.value = e.slice(p.start + 1, p.end - 1), i += 3;
64
+ continue;
65
+ }
66
+ if (p.type === a.braceL) {
67
+ f.valueStart = p.start, o.attr = f, o.depth = 1, i += 3;
68
+ continue;
69
+ }
70
+ }
71
+ i++;
72
+ continue;
73
+ }
74
+ if (l.type === a.braceL) {
75
+ o.depth = 1, i++;
76
+ continue;
77
+ }
78
+ if (l.type === a.slash) {
79
+ m.selfClosing = !0, i++;
80
+ continue;
81
+ }
82
+ if (l.type === a.jsxTagEnd) {
83
+ m.openEnd = l.end, m.selfClosing ? (m.end = l.end, r.pop()) : o.phase = "children", i++;
84
+ continue;
85
+ }
86
+ i++;
87
+ continue;
88
+ }
89
+ l.type === a.jsxText ? m.children.push({ type: "text", start: l.start, end: l.end }) : l.type === a.braceL && (o.depth = 1, o.exprStart = l.start), i++;
90
+ }
91
+ return s;
92
+ }
93
+ function Z(e, t) {
94
+ const n = [];
95
+ let s = 0;
96
+ for (const r of C(e, t))
97
+ r.host && (n.push(e.slice(s, r.nameEnd), ` ${N}="${t}#${r.index}"`), s = r.nameEnd);
98
+ return n.push(e.slice(s)), n.join("");
99
+ }
100
+ function ee(e) {
101
+ const t = e.lastIndexOf("#");
102
+ return { filename: e.slice(0, t), index: Number(e.slice(t + 1)) };
103
+ }
104
+ function E(e, t) {
105
+ const n = e.lastIndexOf(`
106
+ `, t - 1) + 1;
107
+ return e.slice(n).match(/^[ \t]*/)[0];
108
+ }
109
+ function S(e) {
110
+ return `"${e.replace(/"/g, "&quot;")}"`;
111
+ }
112
+ function A(e) {
113
+ if (e.selfClosing) return null;
114
+ if (e.children.length === 0) return;
115
+ const [t] = e.children;
116
+ return e.children.length === 1 && t.type === "text" ? t : null;
117
+ }
118
+ function te(e, t) {
119
+ const n = A(t);
120
+ return n === null ? null : n ? e.slice(n.start, n.end).trim() : "";
121
+ }
122
+ function z(e, t, n) {
123
+ const s = A(t);
124
+ if (s === null) return e;
125
+ if (s === void 0) return e.slice(0, t.openEnd) + n + e.slice(t.closeStart);
126
+ const r = e.slice(s.start, s.end), i = r.match(/^\s*/)[0], h = r.match(/\s*$/)[0];
127
+ return e.slice(0, s.start) + i + n + h + e.slice(s.end);
128
+ }
129
+ function q(e, t) {
130
+ return e.attrs.find((n) => t.includes(n.name)) || null;
131
+ }
132
+ function U(e, t, n, s) {
133
+ const r = q(t, [n]);
134
+ if (r) {
135
+ if (s === "") {
136
+ let i = r.start;
137
+ for (; i > t.nameEnd && /\s/.test(e[i - 1]); ) i--;
138
+ return e.slice(0, i) + e.slice(r.end);
139
+ }
140
+ return r.valueStart === -1 ? e.slice(0, r.end) + "=" + S(s) + e.slice(r.end) : e.slice(0, r.valueStart) + S(s) + e.slice(r.valueEnd);
141
+ }
142
+ return s === "" ? e : e.slice(0, t.nameEnd) + ` ${n}=${S(s)}` + e.slice(t.nameEnd);
143
+ }
144
+ function _(e, t) {
145
+ const [n, s] = O(e, t);
146
+ return e.slice(0, n) + e.slice(s);
147
+ }
148
+ function O(e, t) {
149
+ const n = e.lastIndexOf(`
150
+ `, t.start - 1) + 1, s = e.indexOf(`
151
+ `, t.end), r = s === -1 ? e.length : s;
152
+ return /^[ \t]*$/.test(e.slice(n, t.start)) && /^[ \t]*$/.test(e.slice(t.end, r)) ? [Math.max(0, n - 1), r] : [t.start, t.end];
153
+ }
154
+ function D(e, t) {
155
+ for (let n = e; n; n = n.parent) if (n === t) return !0;
156
+ return !1;
157
+ }
158
+ function F(e, t, n, s) {
159
+ if (t === n || D(n, t)) return { source: e, start: t.start };
160
+ const r = e.slice(t.start, t.end), [i, h] = O(e, t), l = E(e, n.start);
161
+ let o = s === "before" ? n.start : n.end;
162
+ o >= h && (o -= h - i);
163
+ const m = e.slice(0, i) + e.slice(h), f = s === "before" ? `${r}
164
+ ${l}` : `
165
+ ${l}${r}`, d = s === "before" ? o : o + 1 + l.length;
166
+ return { source: m.slice(0, o) + f + m.slice(o), start: d };
167
+ }
168
+ function L(e, t, n) {
169
+ return I(e, t, n, "after").source;
170
+ }
171
+ function I(e, t, n, s) {
172
+ const r = E(e, t.start);
173
+ return s === "before" ? { source: e.slice(0, t.start) + n + `
174
+ ` + r + e.slice(t.start), start: t.start } : { source: e.slice(0, t.end) + `
175
+ ` + r + n + e.slice(t.end), start: t.end + 1 + r.length };
176
+ }
177
+ function ne(e, t, n) {
178
+ if (t.selfClosing) return L(e, t, n);
179
+ const s = E(e, t.start), r = e.slice(t.openEnd, t.closeStart);
180
+ if (!r.includes(`
181
+ `))
182
+ return e.slice(0, t.closeStart) + n + e.slice(t.closeStart);
183
+ const i = r.replace(/\s+$/, "");
184
+ return e.slice(0, t.openEnd) + i + `
185
+ ` + s + " " + n + `
186
+ ` + s + e.slice(t.closeStart);
187
+ }
188
+ function H(e, t) {
189
+ return L(e, t, e.slice(t.start, t.end));
190
+ }
191
+ const j = /* @__PURE__ */ new Map();
192
+ function T(e, t) {
193
+ const n = j.get(e);
194
+ if (n && n.source === t) return n.elements;
195
+ const s = C(t, e);
196
+ return j.set(e, { source: t, elements: s }), s;
197
+ }
198
+ const B = ({ filename: e, index: t }) => `${e}#${t}`;
199
+ function P(e, t) {
200
+ return { files: e, currentFile: t, selection: null, selectMode: !0, past: [], future: [], version: 0, compile: "now" };
201
+ }
202
+ function G(e, t, n) {
203
+ const s = t[n.target.index];
204
+ switch (n.type) {
205
+ case "setAttr":
206
+ return { source: U(e, s, n.name, n.value), select: "keep" };
207
+ case "setText":
208
+ return { source: z(e, s, n.text), select: "keep" };
209
+ case "remove":
210
+ return { source: _(e, s), select: null };
211
+ case "duplicate":
212
+ return { source: H(e, s), select: "keep" };
213
+ case "move": {
214
+ const r = F(e, s, t[n.to.index], n.position);
215
+ return { source: r.source, select: s.host ? r.start : null };
216
+ }
217
+ case "insert": {
218
+ const r = I(e, s, n.code, n.position);
219
+ return { source: r.source, select: r.start };
220
+ }
221
+ default:
222
+ throw new Error(`Unknown edit command: ${n.type}`);
223
+ }
224
+ }
225
+ const V = /* @__PURE__ */ new Set(["setAttr", "setText", "remove", "duplicate", "move", "insert"]);
226
+ function W(e, t) {
227
+ const { filename: n } = t.target, s = e.files[n], r = G(s, T(n, s), t);
228
+ if (r.source === s) return e;
229
+ let i = e.selection;
230
+ if (r.select === null) i = null;
231
+ else if (typeof r.select == "number") {
232
+ const h = T(n, r.source).findIndex((l) => l.start === r.select);
233
+ i = h === -1 ? null : { id: B({ filename: n, index: h }), nth: t.nth ?? 0 };
234
+ }
235
+ return {
236
+ ...e,
237
+ files: { ...e.files, [n]: r.source },
238
+ selection: i,
239
+ past: [...e.past, { files: e.files, selection: e.selection }],
240
+ future: [],
241
+ version: e.version + 1,
242
+ compile: "now"
243
+ };
244
+ }
245
+ function se(e, t) {
246
+ if (V.has(t.type)) return W(e, t);
247
+ switch (t.type) {
248
+ case "select":
249
+ return { ...e, selection: t.selection, compile: null };
250
+ case "setSelectMode":
251
+ return { ...e, selectMode: t.on, selection: t.on ? e.selection : null, compile: null };
252
+ case "switchFile":
253
+ return { ...e, currentFile: t.filename, compile: null };
254
+ case "setSource":
255
+ return {
256
+ ...e,
257
+ files: { ...e.files, [t.filename]: t.source },
258
+ future: [],
259
+ version: e.version + 1,
260
+ compile: "soon"
261
+ };
262
+ case "undo": {
263
+ const n = e.past.at(-1);
264
+ return n ? {
265
+ ...e,
266
+ ...n,
267
+ past: e.past.slice(0, -1),
268
+ future: [{ files: e.files, selection: e.selection }, ...e.future],
269
+ version: e.version + 1,
270
+ compile: "now"
271
+ } : e;
272
+ }
273
+ case "redo": {
274
+ const [n, ...s] = e.future;
275
+ return n ? {
276
+ ...e,
277
+ ...n,
278
+ past: [...e.past, { files: e.files, selection: e.selection }],
279
+ future: s,
280
+ version: e.version + 1,
281
+ compile: "now"
282
+ } : e;
283
+ }
284
+ case "load":
285
+ return { ...P(t.files, t.currentFile), version: e.version + 1 };
286
+ default:
287
+ throw new Error(`Unknown action: ${t.type}`);
288
+ }
289
+ }
290
+ const J = ["0", "0.5", "1", "1.5", "2", "2.5", "3", "4", "5", "6", "8", "10", "12", "16", "20", "24"], v = {
291
+ slate: "#64748b",
292
+ gray: "#6b7280",
293
+ zinc: "#71717a",
294
+ neutral: "#737373",
295
+ stone: "#78716c",
296
+ red: "#ef4444",
297
+ orange: "#f97316",
298
+ amber: "#f59e0b",
299
+ yellow: "#eab308",
300
+ lime: "#84cc16",
301
+ green: "#22c55e",
302
+ emerald: "#10b981",
303
+ teal: "#14b8a6",
304
+ cyan: "#06b6d4",
305
+ sky: "#0ea5e9",
306
+ blue: "#3b82f6",
307
+ indigo: "#6366f1",
308
+ violet: "#8b5cf6",
309
+ purple: "#a855f7",
310
+ fuchsia: "#d946ef",
311
+ pink: "#ec4899",
312
+ rose: "#f43f5e"
313
+ }, K = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"], k = ["white", "black", "transparent"];
314
+ function re(e, t = "500") {
315
+ if (e === "white") return "#fff";
316
+ if (e === "black") return "#000";
317
+ if (e === "transparent") return "transparent";
318
+ const n = v[e];
319
+ if (!n) return "transparent";
320
+ const s = Number(t);
321
+ if (s === 500) return n;
322
+ const r = s < 500 ? "white" : "black", i = s < 500 ? Math.round((500 - s) / 5) : Math.round((s - 500) / 5.5);
323
+ return `color-mix(in oklab, ${n}, ${r} ${i}%)`;
324
+ }
325
+ const u = (e, t) => t.map((n) => `${e}-${n}`), x = (e, t) => ({
326
+ label: e,
327
+ kind: "select",
328
+ options: u(t, J),
329
+ test: new RegExp(`^${t}-(\\d+(\\.\\d+)?|px)$`)
330
+ }), $ = (e, t) => ({
331
+ label: e,
332
+ kind: "color",
333
+ prefix: t,
334
+ test: new RegExp(`^${t}-(?:(${Object.keys(v).join("|")})-(${K.join("|")})|(${k.join("|")}))$`)
335
+ }), c = (e, t) => ({ label: e, kind: "select", options: t }), ie = [
336
+ {
337
+ title: "Layout",
338
+ controls: [
339
+ c("display", ["block", "inline-block", "flex", "inline-flex", "grid", "hidden"]),
340
+ c("direction", ["flex-row", "flex-col", "flex-row-reverse", "flex-col-reverse"]),
341
+ c("align", u("items", ["start", "center", "end", "stretch", "baseline"])),
342
+ c("justify", u("justify", ["start", "center", "end", "between", "around", "evenly"])),
343
+ c("columns", u("grid-cols", ["1", "2", "3", "4", "5", "6", "12"])),
344
+ x("gap", "gap")
345
+ ]
346
+ },
347
+ {
348
+ title: "Spacing",
349
+ controls: [
350
+ x("padding", "p"),
351
+ x("padding x", "px"),
352
+ x("padding y", "py"),
353
+ x("margin", "m"),
354
+ x("margin x", "mx"),
355
+ x("margin y", "my"),
356
+ x("margin top", "mt"),
357
+ x("margin bottom", "mb")
358
+ ]
359
+ },
360
+ {
361
+ title: "Size",
362
+ controls: [
363
+ c("width", u("w", ["auto", "full", "screen", "fit", "1/2", "1/3", "2/3", "1/4", "3/4"])),
364
+ c("height", u("h", ["auto", "full", "screen", "fit"])),
365
+ c("max width", u("max-w", ["none", "xs", "sm", "md", "lg", "xl", "2xl", "3xl", "4xl", "full"])),
366
+ c("min height", u("min-h", ["0", "full", "screen"]))
367
+ ]
368
+ },
369
+ {
370
+ title: "Typography",
371
+ controls: [
372
+ c("size", u("text", ["xs", "sm", "base", "lg", "xl", "2xl", "3xl", "4xl", "5xl", "6xl"])),
373
+ c("weight", u("font", ["thin", "light", "normal", "medium", "semibold", "bold", "extrabold"])),
374
+ c("align", u("text", ["left", "center", "right", "justify"])),
375
+ c("leading", u("leading", ["none", "tight", "snug", "normal", "relaxed", "loose"])),
376
+ c("tracking", u("tracking", ["tighter", "tight", "normal", "wide", "wider", "widest"])),
377
+ c("transform", ["uppercase", "lowercase", "capitalize", "normal-case"]),
378
+ c("decoration", ["underline", "line-through", "no-underline"]),
379
+ $("color", "text")
380
+ ]
381
+ },
382
+ {
383
+ title: "Background & Border",
384
+ controls: [
385
+ $("background", "bg"),
386
+ c("radius", ["rounded-none", "rounded-sm", "rounded", "rounded-md", "rounded-lg", "rounded-xl", "rounded-2xl", "rounded-3xl", "rounded-full"]),
387
+ c("border", ["border", "border-0", "border-2", "border-4"]),
388
+ $("border color", "border"),
389
+ c("shadow", ["shadow-none", "shadow-sm", "shadow", "shadow-md", "shadow-lg", "shadow-xl", "shadow-2xl"]),
390
+ c("opacity", u("opacity", ["0", "25", "50", "75", "100"]))
391
+ ]
392
+ }
393
+ ];
394
+ function M(e, t) {
395
+ return e.test ? e.test.test(t) : e.options.includes(t);
396
+ }
397
+ function le(e) {
398
+ return e.split(/\s+/).filter(Boolean);
399
+ }
400
+ function oe(e, t) {
401
+ return t.find((n) => M(e, n)) ?? "";
402
+ }
403
+ function ce(e, t, n) {
404
+ const s = [];
405
+ let r = !1;
406
+ for (const i of t)
407
+ M(e, i) ? !r && n && (s.push(n), r = !0) : s.push(i);
408
+ return n && !r && s.push(n), s;
409
+ }
410
+ function ae(e, t) {
411
+ const n = t && e.test.exec(t);
412
+ return n ? n[3] ? { hue: n[3], shade: "" } : { hue: n[1], shade: n[2] } : null;
413
+ }
414
+ function de(e, t, n) {
415
+ return k.includes(t) ? `${e}-${t}` : `${e}-${t}-${n || "500"}`;
416
+ }
417
+ const ue = [...k, ...Object.keys(v)];
418
+ export {
419
+ Y as C,
420
+ V as E,
421
+ ie as G,
422
+ v as H,
423
+ N as I,
424
+ J as S,
425
+ z as a,
426
+ U as b,
427
+ D as c,
428
+ L as d,
429
+ I as e,
430
+ q as f,
431
+ te as g,
432
+ ne as h,
433
+ Z as i,
434
+ H as j,
435
+ T as k,
436
+ P as l,
437
+ F as m,
438
+ se as n,
439
+ K as o,
440
+ C as p,
441
+ re as q,
442
+ _ as r,
443
+ ee as s,
444
+ B as t,
445
+ le as u,
446
+ oe as v,
447
+ ce as w,
448
+ ae as x,
449
+ de as y,
450
+ ue as z
451
+ };
package/package.json ADDED
@@ -0,0 +1,65 @@
1
+ {
2
+ "name": "@hashrock/ono-visual-editor",
3
+ "version": "0.1.0",
4
+ "type": "module",
5
+ "description": "Visual editor for Ono JSX as a React component: render JSX with Ono and edit elements from the preview",
6
+ "keywords": [
7
+ "ono",
8
+ "jsx",
9
+ "visual-editor",
10
+ "wysiwyg",
11
+ "react",
12
+ "unocss"
13
+ ],
14
+ "author": "hashrock",
15
+ "license": "MIT",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/hashrock/ono.git",
19
+ "directory": "packages/visual-editor"
20
+ },
21
+ "bugs": {
22
+ "url": "https://github.com/hashrock/ono/issues"
23
+ },
24
+ "homepage": "https://github.com/hashrock/ono/tree/main/packages/visual-editor#readme",
25
+ "files": [
26
+ "dist",
27
+ "README.md",
28
+ "LICENSE"
29
+ ],
30
+ "main": "./dist/index.js",
31
+ "module": "./dist/index.js",
32
+ "exports": {
33
+ ".": "./dist/index.js",
34
+ "./core": "./dist/core.js",
35
+ "./style.css": "./dist/style.css",
36
+ "./package.json": "./package.json"
37
+ },
38
+ "sideEffects": [
39
+ "*.css"
40
+ ],
41
+ "peerDependencies": {
42
+ "react": ">=18",
43
+ "react-dom": ">=18"
44
+ },
45
+ "dependencies": {
46
+ "@hashrock/ono": "0.3.0",
47
+ "sucrase": "^3.35.1"
48
+ },
49
+ "devDependencies": {
50
+ "@unocss/core": "^66.5.4",
51
+ "@unocss/preset-uno": "^66.5.4",
52
+ "@unocss/reset": "^66.5.4",
53
+ "@vitejs/plugin-react": "^5.1.0",
54
+ "react": "^19.2.0",
55
+ "react-dom": "^19.2.0",
56
+ "vite": "^7.1.12"
57
+ },
58
+ "scripts": {
59
+ "dev": "vite --config vite.demo.config.js",
60
+ "build": "vite build",
61
+ "build:demo": "vite build --config vite.demo.config.js",
62
+ "preview": "vite preview --config vite.demo.config.js",
63
+ "test": "node --test test/*.test.js"
64
+ }
65
+ }