@floegence/floe-webapp-core 0.101.52 → 0.102.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,101 +1,115 @@
1
- import { insert as i, createComponent as a, memo as j, setStyleProperty as s, effect as H, template as y, use as ne, delegateEvents as re } from "solid-js/web";
2
- import { createSignal as $, createEffect as le, onCleanup as ie, createMemo as E, Show as O, For as K } from "solid-js";
3
- import { Plus as ae, Pencil as ce, Upload as oe, Download as de, Sparkles as ue, Check as se } from "../icons/index.js";
4
- import { Button as g } from "./Button.js";
5
- import { Input as ge, Textarea as ve } from "./Input.js";
6
- import { Dialog as fe } from "./Dialog.js";
7
- import { readFloeThemeDocument as q, resolveFloeThemeDocument as me, floeThemeContrastIssue as be, FLOE_THEME_FILE_LIMIT as he } from "../../styles/themes/themeDocument.js";
8
- var _e = /* @__PURE__ */ y("<div class=floe-theme-studio__actions><input hidden type=file accept=.json,application/json>"), G = /* @__PURE__ */ y("<p role=alert class=floe-theme-picker__error>"), $e = /* @__PURE__ */ y("<div class=floe-theme-studio__body><label></label><div class=floe-theme-studio__sample aria-hidden=true><aside><i></i><i></i><i></i></aside><div><strong>Aa</strong><span></span><section></section></div></div><fieldset><legend></legend><div class=floe-theme-studio__swatches></div></fieldset><details><summary>"), ye = /* @__PURE__ */ y("<i>"), ke = /* @__PURE__ */ y("<label><input type=color>");
9
- function Le(e) {
10
- const [L, m] = $(!1), [u, z] = $(!1), [I, k] = $(""), [D, Q] = $(), [w, b] = $("");
11
- let N, o = 0;
12
- le(() => {
13
- e.active || (o++, m(!1), b(""));
14
- }), ie(() => {
15
- o++;
1
+ import { insert as n, createComponent as r, memo as R, setStyleProperty as m, effect as q, template as w, use as _e, delegateEvents as $e } from "solid-js/web";
2
+ import { createSignal as u, createEffect as te, onCleanup as we, createMemo as j, Show as $, For as re } from "solid-js";
3
+ import { Plus as ye, Pencil as ke, Upload as Ce, Download as Se, Sparkles as xe, ChevronLeft as Te, ChevronRight as Ee, Eye as Oe, Check as Le } from "../icons/index.js";
4
+ import { Button as d } from "./Button.js";
5
+ import { Input as Ie, Textarea as ze } from "./Input.js";
6
+ import { Dialog as Ne } from "./Dialog.js";
7
+ import { readPortableShellTheme as ne, resolvePortableShellTheme as Pe, portableContrastIssue as Je, PORTABLE_THEME_LIMIT as Re } from "../../styles/themes/portableTheme.js";
8
+ import { ThemeFields as je } from "./ThemeFields.js";
9
+ var Fe = /* @__PURE__ */ w("<div class=floe-theme-studio__actions><input hidden type=file accept=.json,application/json>"), le = /* @__PURE__ */ w("<p role=alert class=floe-theme-picker__error>"), Ue = /* @__PURE__ */ w("<div class=floe-theme-studio__body><label></label><fieldset><legend></legend><div class=floe-theme-studio__swatches></div></fieldset><div class=floe-theme-studio__actions></div><details><summary>"), Be = /* @__PURE__ */ w("<div class=floe-theme-studio__sample aria-hidden=true><aside><i></i><i></i><i></i></aside><div><strong>Aa</strong><span></span><section>"), De = /* @__PURE__ */ w("<i>"), Me = /* @__PURE__ */ w("<label><input type=color>");
10
+ function Xe(e) {
11
+ const [F, y] = u(!1), [s, G] = u(!1), [f, T] = u(""), [Q, ie] = u(), [E, k] = u(""), [ae, U] = u(""), [ce, oe] = u(), [B, V] = u(!1), [ue, W] = u();
12
+ let D, v = 0;
13
+ const [C, O] = u([]), [L, I] = u([]), z = (t) => {
14
+ t !== f() && (O([...C().slice(-39), f()]), I([]), T(t));
15
+ }, se = () => {
16
+ const t = C().at(-1);
17
+ t !== void 0 && (I([...L(), f()]), O(C().slice(0, -1)), T(t));
18
+ }, de = () => {
19
+ const t = L().at(-1);
20
+ t !== void 0 && (O([...C(), f()]), I(L().slice(0, -1)), T(t));
21
+ };
22
+ te(() => {
23
+ e.active || (v++, y(!1), k(""));
24
+ }), we(() => {
25
+ v++;
16
26
  });
17
- const v = E(() => {
27
+ const b = j(() => {
18
28
  try {
19
29
  return {
20
- doc: q(I())
30
+ doc: ne(f())
21
31
  };
22
32
  } catch (t) {
23
33
  return {
24
34
  issue: t instanceof SyntaxError ? "JSON" : t.message
25
35
  };
26
36
  }
27
- }), d = E(() => {
28
- const t = v().doc;
29
- return t && me("draft", t);
30
- }), S = E(() => {
31
- const t = v().doc;
32
- return t ? be(t) : v().issue;
33
- }), C = E(() => {
37
+ }), g = j(() => {
38
+ const t = B() ? ce() : b().doc;
39
+ return t && Pe("draft", t);
40
+ });
41
+ te(() => {
42
+ f(), U("");
43
+ });
44
+ const N = j(() => {
45
+ const t = b().doc;
46
+ return ae() || (t ? Je(t) : b().issue);
47
+ }), P = j(() => {
34
48
  try {
35
- return JSON.parse(I());
49
+ return JSON.parse(f());
36
50
  } catch {
37
51
  return null;
38
52
  }
39
- }), F = (t, r) => {
40
- Q(r), k(JSON.stringify(t, null, 2)), b(""), m(!0);
41
- }, V = async (t) => {
53
+ }), M = (t, i) => {
54
+ O([]), I([]), U(""), oe(t), V(!1), W(void 0), ie(i), T(JSON.stringify(t, null, 2)), k(""), y(!0);
55
+ }, ge = async (t) => {
42
56
  if (!t || !e.active) return;
43
- const r = ++o;
57
+ const i = ++v;
44
58
  try {
45
- if (t.size > he) throw new Error("32 KiB");
46
- const l = q(await t.text());
47
- r === o && e.active && F(l);
48
- } catch (l) {
49
- r === o && b(`${e.label("invalid")}: ${l instanceof SyntaxError ? "JSON" : l.message}`);
59
+ if (t.size > Re) throw new Error("128 KiB");
60
+ const a = ne(await t.text());
61
+ i === v && e.active && M(a);
62
+ } catch (a) {
63
+ i === v && k(`${e.label("invalid")}: ${a instanceof SyntaxError ? "JSON" : a.message}`);
50
64
  }
51
- }, W = () => {
52
- const t = e.current, r = URL.createObjectURL(new Blob([JSON.stringify(t, null, 2) + `
65
+ }, fe = () => {
66
+ const t = e.current, i = URL.createObjectURL(new Blob([JSON.stringify(t, null, 2) + `
53
67
  `], {
54
68
  type: "application/json"
55
- })), l = document.createElement("a");
56
- l.download = `${t.name.replace(/[^\p{L}\p{N}_-]+/gu, "-").slice(0, 64)}.floe-theme.json`, l.href = r, l.click(), setTimeout(() => URL.revokeObjectURL(r), 1e3);
57
- }, X = async () => {
58
- const t = v().doc;
59
- if (!t || S() || !L() || !e.active || u()) return;
60
- z(!0), b("");
61
- const r = o;
69
+ })), a = document.createElement("a");
70
+ a.download = `${t.name.replace(/[^\p{L}\p{N}_-]+/gu, "-").slice(0, 64)}.floe-theme.json`, a.href = i, a.click(), setTimeout(() => URL.revokeObjectURL(i), 1e3);
71
+ }, ve = async () => {
72
+ const t = b().doc;
73
+ if (!t || N() || !F() || !e.active || s()) return;
74
+ G(!0), k("");
75
+ const i = v;
62
76
  try {
63
- await e.save(t, D()), r === o && m(!1);
77
+ await e.save(t, Q()), i === v && y(!1);
64
78
  } catch {
65
- r === o && b(e.label("failed"));
79
+ i === v && k(e.label("failed"));
66
80
  } finally {
67
- z(!1);
81
+ G(!1);
68
82
  }
69
- }, Y = ["background", "card", "sidebar", "foreground", "primary", "border"];
83
+ }, be = ["background", "card", "sidebar", "foreground", "primary", "border"];
70
84
  return [(() => {
71
- var t = _e(), r = t.firstChild;
72
- r.addEventListener("change", (h) => {
73
- const x = h.currentTarget.files?.[0];
74
- h.currentTarget.value = "", V(x);
85
+ var t = Fe(), i = t.firstChild;
86
+ i.addEventListener("change", (S) => {
87
+ const A = S.currentTarget.files?.[0];
88
+ S.currentTarget.value = "", ge(A);
75
89
  });
76
- var l = N;
77
- return typeof l == "function" ? ne(l, r) : N = r, i(t, a(g, {
90
+ var a = D;
91
+ return typeof a == "function" ? _e(a, i) : D = i, n(t, r(d, {
78
92
  size: "sm",
79
- icon: ae,
93
+ icon: ye,
80
94
  variant: "outline",
81
95
  get disabled() {
82
96
  return !e.active;
83
97
  },
84
- onClick: () => F({
98
+ onClick: () => M({
85
99
  ...e.current,
86
100
  name: e.label("create")
87
101
  }),
88
102
  get children() {
89
103
  return e.label("create");
90
104
  }
91
- }), null), i(t, a(O, {
105
+ }), null), n(t, r($, {
92
106
  get when() {
93
107
  return e.currentID;
94
108
  },
95
109
  get children() {
96
- return a(g, {
110
+ return r(d, {
97
111
  size: "icon",
98
- icon: ce,
112
+ icon: ke,
99
113
  get disabled() {
100
114
  return !e.active;
101
115
  },
@@ -106,12 +120,12 @@ function Le(e) {
106
120
  get title() {
107
121
  return e.label("edit");
108
122
  },
109
- onClick: () => F(e.current, e.currentID)
123
+ onClick: () => M(e.current, e.currentID)
110
124
  });
111
125
  }
112
- }), null), i(t, a(g, {
126
+ }), null), n(t, r(d, {
113
127
  size: "icon",
114
- icon: oe,
128
+ icon: Ce,
115
129
  get disabled() {
116
130
  return !e.active;
117
131
  },
@@ -122,10 +136,10 @@ function Le(e) {
122
136
  get title() {
123
137
  return e.label("import");
124
138
  },
125
- onClick: () => N.click()
126
- }), null), i(t, a(g, {
139
+ onClick: () => D.click()
140
+ }), null), n(t, r(d, {
127
141
  size: "icon",
128
- icon: de,
142
+ icon: Se,
129
143
  get disabled() {
130
144
  return !e.active;
131
145
  },
@@ -136,15 +150,15 @@ function Le(e) {
136
150
  get title() {
137
151
  return e.label("export");
138
152
  },
139
- onClick: W
140
- }), null), i(t, a(O, {
153
+ onClick: fe
154
+ }), null), n(t, r($, {
141
155
  get when() {
142
156
  return e.generate;
143
157
  },
144
158
  get children() {
145
- return a(g, {
159
+ return r(d, {
146
160
  size: "sm",
147
- icon: ue,
161
+ icon: xe,
148
162
  get disabled() {
149
163
  return !e.active;
150
164
  },
@@ -156,47 +170,48 @@ function Le(e) {
156
170
  });
157
171
  }
158
172
  }), null), t;
159
- })(), a(O, {
173
+ })(), r($, {
160
174
  get when() {
161
- return j(() => !!w())() && !L();
175
+ return R(() => !!E())() && !F();
162
176
  },
163
177
  get children() {
164
- var t = G();
165
- return i(t, w), t;
178
+ var t = le();
179
+ return n(t, E), t;
166
180
  }
167
- }), a(fe, {
181
+ }), r(Ne, {
182
+ class: "floe-theme-studio",
168
183
  get open() {
169
- return j(() => !!e.active)() && L();
184
+ return R(() => !!e.active)() && F();
170
185
  },
171
186
  get title() {
172
- return e.label(D() ? "edit" : "create");
187
+ return e.label(Q() ? "edit" : "create");
173
188
  },
174
189
  get closeLabel() {
175
190
  return e.label("cancel");
176
191
  },
177
192
  onOpenChange: (t) => {
178
- u() || m(t);
193
+ s() || y(t);
179
194
  },
180
195
  get footer() {
181
- return [a(g, {
196
+ return [r(d, {
182
197
  variant: "ghost",
183
198
  get disabled() {
184
- return u();
199
+ return s();
185
200
  },
186
- onClick: () => m(!1),
201
+ onClick: () => y(!1),
187
202
  get children() {
188
203
  return e.label("cancel");
189
204
  }
190
- }), a(g, {
191
- icon: se,
205
+ }), r(d, {
206
+ icon: Le,
192
207
  get loading() {
193
- return u();
208
+ return s();
194
209
  },
195
210
  get disabled() {
196
- return !!S();
211
+ return !!N();
197
212
  },
198
213
  onClick: () => {
199
- X();
214
+ ve();
200
215
  },
201
216
  get children() {
202
217
  return e.label("save");
@@ -204,82 +219,163 @@ function Le(e) {
204
219
  })];
205
220
  },
206
221
  get children() {
207
- var t = $e(), r = t.firstChild, l = r.nextSibling, h = l.firstChild, x = h.nextSibling, Z = x.firstChild, R = Z.nextSibling, p = R.nextSibling, J = l.nextSibling, U = J.firstChild, ee = U.nextSibling, P = J.nextSibling, te = P.firstChild;
208
- return i(r, () => e.label("name"), null), i(r, a(ge, {
222
+ var t = Ue(), i = t.firstChild, a = i.nextSibling, S = a.firstChild, A = S.nextSibling, J = a.nextSibling, H = J.nextSibling, he = H.firstChild;
223
+ return n(i, () => e.label("name"), null), n(i, r(Ie, {
209
224
  maxLength: 80,
210
225
  get value() {
211
- return j(() => typeof C()?.name == "string")() ? C().name : "";
226
+ return R(() => typeof P()?.name == "string")() ? P().name : "";
212
227
  },
213
228
  get disabled() {
214
- return u() || !C();
229
+ return s() || !P();
215
230
  },
216
- onInput: (n) => {
217
- const c = C();
218
- c && k(JSON.stringify({
219
- ...c,
220
- name: n.currentTarget.value
231
+ onInput: (l) => {
232
+ const o = P();
233
+ o && z(JSON.stringify({
234
+ ...o,
235
+ name: l.currentTarget.value
221
236
  }, null, 2));
222
237
  }
223
- }), null), i(p, a(K, {
224
- get each() {
225
- return d()?.preview?.colors;
238
+ }), null), n(t, r($, {
239
+ get when() {
240
+ return R(() => !!e.renderPreview)() && g();
226
241
  },
227
- children: (n) => (() => {
228
- var c = ye();
229
- return s(c, "background", n), c;
230
- })()
231
- })), i(U, () => e.label("colors")), i(ee, a(K, {
232
- each: Y,
233
- children: (n) => (() => {
234
- var c = ke(), _ = c.firstChild;
235
- return _.$$input = (T) => {
236
- const f = v().doc;
237
- f && k(JSON.stringify({
238
- ...f,
242
+ get fallback() {
243
+ return (() => {
244
+ var l = Be(), o = l.firstChild, h = o.nextSibling, K = h.firstChild, _ = K.nextSibling, me = _.nextSibling;
245
+ return n(me, r(re, {
246
+ get each() {
247
+ return g()?.preview?.colors;
248
+ },
249
+ children: (c) => (() => {
250
+ var x = De();
251
+ return m(x, "background", c), x;
252
+ })()
253
+ })), q((c) => {
254
+ var x = g()?.preview?.background, X = g()?.semanticTokens?.["--foreground"], Y = g()?.preview?.border, Z = g()?.preview?.sidebar, p = g()?.preview?.surface, ee = g()?.preview?.primary;
255
+ return x !== c.e && m(l, "background", c.e = x), X !== c.t && m(l, "color", c.t = X), Y !== c.a && m(l, "border-color", c.a = Y), Z !== c.o && m(o, "background", c.o = Z), p !== c.i && m(h, "background", c.i = p), ee !== c.n && m(_, "background", c.n = ee), c;
256
+ }, {
257
+ e: void 0,
258
+ t: void 0,
259
+ a: void 0,
260
+ o: void 0,
261
+ i: void 0,
262
+ n: void 0
263
+ }), l;
264
+ })();
265
+ },
266
+ children: (l) => e.renderPreview(l(), (o, h) => W({
267
+ group: o,
268
+ role: h
269
+ }))
270
+ }), a), n(S, () => e.label("colors")), n(A, r(re, {
271
+ each: be,
272
+ children: (l) => (() => {
273
+ var o = Me(), h = o.firstChild;
274
+ return h.$$input = (K) => {
275
+ const _ = b().doc;
276
+ _ && z(JSON.stringify({
277
+ ..._,
239
278
  colors: {
240
- ...f.colors,
241
- [`--${n}`]: T.currentTarget.value
279
+ ..._.colors,
280
+ [`--${l}`]: K.currentTarget.value
242
281
  }
243
282
  }, null, 2));
244
- }, i(c, () => e.label(n), null), H(() => _.value = d()?.semanticTokens?.[`--${n}`]), c;
283
+ }, n(o, () => e.label(l), null), q(() => h.value = g()?.semanticTokens?.[`--${l}`]?.slice(0, 7)), o;
245
284
  })()
246
- })), i(te, () => e.label("advanced")), i(P, a(ve, {
285
+ })), n(J, r(d, {
286
+ size: "icon",
287
+ icon: Te,
288
+ variant: "ghost",
289
+ get title() {
290
+ return e.label("undo");
291
+ },
292
+ get "aria-label"() {
293
+ return e.label("undo");
294
+ },
295
+ get disabled() {
296
+ return s() || !C().length;
297
+ },
298
+ onClick: se
299
+ }), null), n(J, r(d, {
300
+ size: "icon",
301
+ icon: Ee,
302
+ variant: "ghost",
303
+ get title() {
304
+ return e.label("redo");
305
+ },
306
+ get "aria-label"() {
307
+ return e.label("redo");
308
+ },
309
+ get disabled() {
310
+ return s() || !L().length;
311
+ },
312
+ onClick: de
313
+ }), null), n(J, r(d, {
314
+ size: "icon",
315
+ icon: Oe,
316
+ variant: "ghost",
317
+ get "aria-label"() {
318
+ return e.label("compare");
319
+ },
320
+ get title() {
321
+ return e.label("compare");
322
+ },
323
+ get "aria-pressed"() {
324
+ return B();
325
+ },
326
+ onClick: () => V(!B())
327
+ }), null), n(t, r($, {
328
+ get when() {
329
+ return b().doc;
330
+ },
331
+ children: (l) => r(je, {
332
+ get document() {
333
+ return l();
334
+ },
335
+ get parts() {
336
+ return e.parts;
337
+ },
338
+ get features() {
339
+ return e.features;
340
+ },
341
+ get inspect() {
342
+ return ue();
343
+ },
344
+ get disabled() {
345
+ return s();
346
+ },
347
+ get label() {
348
+ return e.label;
349
+ },
350
+ invalid: U,
351
+ update: (o) => z(JSON.stringify(o, null, 2))
352
+ })
353
+ }), H), n(he, () => e.label("advanced")), n(H, r(ze, {
247
354
  get "aria-label"() {
248
355
  return e.label("advanced");
249
356
  },
250
357
  get value() {
251
- return I();
358
+ return f();
252
359
  },
253
360
  rows: 9,
254
361
  spellcheck: !1,
255
362
  get disabled() {
256
- return u();
363
+ return s();
257
364
  },
258
- onInput: (n) => k(n.currentTarget.value)
259
- }), null), i(t, a(O, {
365
+ onInput: (l) => z(l.currentTarget.value)
366
+ }), null), n(t, r($, {
260
367
  get when() {
261
- return w() || S();
368
+ return E() || N();
262
369
  },
263
370
  get children() {
264
- var n = G();
265
- return i(n, () => w() || `${e.label("invalid")}: ${S()}`), n;
371
+ var l = le();
372
+ return n(l, () => E() || `${e.label("invalid")}: ${N()}`), l;
266
373
  }
267
- }), null), H((n) => {
268
- var c = d()?.preview?.background, _ = d()?.semanticTokens?.["--foreground"], T = d()?.preview?.border, f = d()?.preview?.sidebar, B = d()?.preview?.surface, M = d()?.preview?.primary, A = u() || !v().doc;
269
- return c !== n.e && s(l, "background", n.e = c), _ !== n.t && s(l, "color", n.t = _), T !== n.a && s(l, "border-color", n.a = T), f !== n.o && s(h, "background", n.o = f), B !== n.i && s(x, "background", n.i = B), M !== n.n && s(R, "background", n.n = M), A !== n.s && (J.disabled = n.s = A), n;
270
- }, {
271
- e: void 0,
272
- t: void 0,
273
- a: void 0,
274
- o: void 0,
275
- i: void 0,
276
- n: void 0,
277
- s: void 0
278
- }), t;
374
+ }), null), q(() => a.disabled = s() || !b().doc), t;
279
375
  }
280
376
  })];
281
377
  }
282
- re(["input"]);
378
+ $e(["input"]);
283
379
  export {
284
- Le as ThemeStudio
380
+ Xe as ThemeStudio
285
381
  };