@sanity/themer 0.8.0 → 0.9.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/README.md +1 -1
- package/dist/AnimatedColorWheelIcon-DEy-cy3X.js +171 -0
- package/dist/AnimatedColorWheelIcon-DEy-cy3X.js.map +1 -0
- package/dist/{ResizableSidebar-DD787kQr.js → ResizableSidebar-BpgLA4XQ.js} +817 -430
- package/dist/ResizableSidebar-BpgLA4XQ.js.map +1 -0
- package/dist/bundle.css +102 -322
- package/dist/index.d.ts +70 -5
- package/dist/index.d.ts.map +1 -1
- package/dist/legacy.d.ts +13 -12
- package/dist/legacy.d.ts.map +1 -1
- package/dist/presets-CqBgS3A-.js.map +1 -1
- package/dist/themes-Bxgltjmb.js +139 -0
- package/dist/themes-Bxgltjmb.js.map +1 -0
- package/dist/tool.d.ts +5 -16
- package/dist/tool.d.ts.map +1 -1
- package/dist/tool.js +649 -818
- package/dist/tool.js.map +1 -1
- package/package.json +23 -20
- package/dist/ResizableSidebar-DD787kQr.js.map +0 -1
- package/dist/ResizableSidebar.css.ts.vanilla-M9EuPu-q.js +0 -422
- package/dist/ResizableSidebar.css.ts.vanilla-M9EuPu-q.js.map +0 -1
- package/dist/options-CU-emn_p.d.ts +0 -69
- package/dist/options-CU-emn_p.d.ts.map +0 -1
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
import { c as resolveThemeOptions, l as isColor, n as buildTheme, o as SCHEMES, r as buildPalette } from "./presets-CqBgS3A-.js";
|
|
2
|
-
import {
|
|
1
|
+
import { a as DEFAULT_BACKGROUND, c as resolveThemeOptions, d as hslToHex, f as relativeLuminance, i as DEFAULT_ACCENT, l as isColor, n as buildTheme, o as SCHEMES, r as buildPalette, s as deriveTextColor, u as hexToHsl } from "./presets-CqBgS3A-.js";
|
|
2
|
+
import { a as displayTitle, c as resolveThemes, l as addThemerTransitionType, n as CONFIG_TITLE, t as CONFIG_SLUG } from "./themes-Bxgltjmb.js";
|
|
3
3
|
import { c } from "react/compiler-runtime";
|
|
4
4
|
import { useColorSchemeValue } from "sanity";
|
|
5
|
-
import { Badge, Box, Button, Card, Dialog, Flex, Layer, Stack, Text, TextInput, ThemeProvider, useRootTheme, useTheme_v2 } from "@sanity/ui";
|
|
6
|
-
import { createContext, useContext, useEffect, useRef, useState } from "react";
|
|
7
|
-
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
5
|
+
import { Badge, BoundaryElementProvider, Box, Button, Card, Dialog, Flex, Layer, Stack, Text, TextInput, ThemeProvider, useMediaIndex, useRootTheme, useTheme_v2 } from "@sanity/ui";
|
|
8
6
|
import { Tooltip } from "@sanity/ui/tooltip";
|
|
7
|
+
import { Activity, createContext, startTransition, useContext, useEffect, useRef, useState } from "react";
|
|
8
|
+
import { Fragment, jsx, jsxs } from "react/jsx-runtime";
|
|
9
|
+
import { dequal } from "dequal/lite";
|
|
10
|
+
import { useSelector } from "@xstate/react";
|
|
9
11
|
import { MotionConfig, Reorder, useDragControls } from "motion/react";
|
|
10
12
|
import { ArrowLeftIcon } from "@sanity/icons/ArrowLeft";
|
|
11
13
|
import { CloseIcon } from "@sanity/icons/Close";
|
|
@@ -55,7 +57,7 @@ let lastGutter = 0;
|
|
|
55
57
|
* @internal
|
|
56
58
|
*/
|
|
57
59
|
function ScrollArea(props) {
|
|
58
|
-
let $ = c(15), { children, padding } = props, { space } = useTheme_v2(), ref = useRef(null), [gutter, setGutter] = useState(_temp$
|
|
60
|
+
let $ = c(15), { children, padding } = props, { space } = useTheme_v2(), ref = useRef(null), [gutter, setGutter] = useState(_temp$8), t0, t1;
|
|
59
61
|
$[0] === Symbol.for("react.memo_cache_sentinel") ? (t0 = () => {
|
|
60
62
|
let element = ref.current;
|
|
61
63
|
if (!element) return;
|
|
@@ -75,7 +77,7 @@ function ScrollArea(props) {
|
|
|
75
77
|
let inset = t5, t6;
|
|
76
78
|
$[6] === inset.right ? t6 = $[7] : (t6 = { paddingRight: inset.right }, $[6] = inset.right, $[7] = t6);
|
|
77
79
|
let t7;
|
|
78
|
-
$[8] !== children || $[9] !== inset ? (t7 = /* @__PURE__ */ jsx(ScrollAreaInsetContext
|
|
80
|
+
$[8] !== children || $[9] !== inset ? (t7 = /* @__PURE__ */ jsx(ScrollAreaInsetContext, {
|
|
79
81
|
value: inset,
|
|
80
82
|
children
|
|
81
83
|
}), $[8] = children, $[9] = inset, $[10] = t7) : t7 = $[10];
|
|
@@ -90,7 +92,7 @@ function ScrollArea(props) {
|
|
|
90
92
|
children: t7
|
|
91
93
|
}), $[11] = padding, $[12] = t6, $[13] = t7, $[14] = t8) : t8 = $[14], t8;
|
|
92
94
|
}
|
|
93
|
-
function _temp$
|
|
95
|
+
function _temp$8() {
|
|
94
96
|
return lastGutter;
|
|
95
97
|
}
|
|
96
98
|
/**
|
|
@@ -210,7 +212,7 @@ function MockStudio(props) {
|
|
|
210
212
|
let t4;
|
|
211
213
|
$[13] === Symbol.for("react.memo_cache_sentinel") ? (t4 = /* @__PURE__ */ jsx("div", {
|
|
212
214
|
className: list,
|
|
213
|
-
children: LIST_ROWS.map(_temp$
|
|
215
|
+
children: LIST_ROWS.map(_temp$7)
|
|
214
216
|
}), $[13] = t4) : t4 = $[13];
|
|
215
217
|
let t5;
|
|
216
218
|
$[14] === Symbol.for("react.memo_cache_sentinel") ? (t5 = /* @__PURE__ */ jsxs("div", {
|
|
@@ -218,7 +220,7 @@ function MockStudio(props) {
|
|
|
218
220
|
children: [/* @__PURE__ */ jsx("div", {
|
|
219
221
|
className: line.fg,
|
|
220
222
|
style: { width: "45%" }
|
|
221
|
-
}), FIELDS$1.map(_temp2)]
|
|
223
|
+
}), FIELDS$1.map(_temp2$1)]
|
|
222
224
|
}), $[14] = t5) : t5 = $[14];
|
|
223
225
|
let t6;
|
|
224
226
|
$[15] === Symbol.for("react.memo_cache_sentinel") ? (t6 = /* @__PURE__ */ jsxs("div", {
|
|
@@ -238,7 +240,7 @@ function MockStudio(props) {
|
|
|
238
240
|
children: [t3, t6]
|
|
239
241
|
}), $[16] = t0, $[17] = t1, $[18] = t7) : t7 = $[18], t7;
|
|
240
242
|
}
|
|
241
|
-
function _temp2(width_0) {
|
|
243
|
+
function _temp2$1(width_0) {
|
|
242
244
|
return /* @__PURE__ */ jsxs("div", {
|
|
243
245
|
className: field,
|
|
244
246
|
children: [/* @__PURE__ */ jsx("div", {
|
|
@@ -247,7 +249,7 @@ function _temp2(width_0) {
|
|
|
247
249
|
}), /* @__PURE__ */ jsx("div", { className: input })]
|
|
248
250
|
}, width_0);
|
|
249
251
|
}
|
|
250
|
-
function _temp$
|
|
252
|
+
function _temp$7(width, index) {
|
|
251
253
|
let isSelected = index === 1;
|
|
252
254
|
return /* @__PURE__ */ jsx("div", {
|
|
253
255
|
className: listRow,
|
|
@@ -282,11 +284,11 @@ var removedThumbnail = "_1vdkp0v0";
|
|
|
282
284
|
*
|
|
283
285
|
* @internal
|
|
284
286
|
*/
|
|
285
|
-
function RemovedThemes() {
|
|
286
|
-
let $ = c(7), {
|
|
287
|
-
if ($[0] !==
|
|
288
|
-
let
|
|
289
|
-
$[3] ===
|
|
287
|
+
function RemovedThemes(t0) {
|
|
288
|
+
let $ = c(7), { actorRef, removed } = t0, t1;
|
|
289
|
+
if ($[0] !== actorRef || $[1] !== removed) {
|
|
290
|
+
let t2;
|
|
291
|
+
$[3] === actorRef ? t2 = $[4] : (t2 = (theme) => /* @__PURE__ */ jsxs(Stack, {
|
|
290
292
|
gap: 3,
|
|
291
293
|
children: [
|
|
292
294
|
/* @__PURE__ */ jsx(Box, {
|
|
@@ -304,7 +306,7 @@ function RemovedThemes() {
|
|
|
304
306
|
justify: "center",
|
|
305
307
|
children: [/* @__PURE__ */ jsx(Button, {
|
|
306
308
|
mode: "ghost",
|
|
307
|
-
onClick: () => send({
|
|
309
|
+
onClick: () => actorRef.send({
|
|
308
310
|
type: "theme.restore",
|
|
309
311
|
slug: theme.slug
|
|
310
312
|
}),
|
|
@@ -312,7 +314,7 @@ function RemovedThemes() {
|
|
|
312
314
|
text: "Restore"
|
|
313
315
|
}), theme.source === "custom" && /* @__PURE__ */ jsx(Button, {
|
|
314
316
|
mode: "ghost",
|
|
315
|
-
onClick: () => send({
|
|
317
|
+
onClick: () => actorRef.send({
|
|
316
318
|
type: "theme.delete",
|
|
317
319
|
slug: theme.slug
|
|
318
320
|
}),
|
|
@@ -322,16 +324,313 @@ function RemovedThemes() {
|
|
|
322
324
|
})]
|
|
323
325
|
})
|
|
324
326
|
]
|
|
325
|
-
}, theme.slug), $[3] =
|
|
326
|
-
} else
|
|
327
|
-
let
|
|
328
|
-
return $[5] ===
|
|
327
|
+
}, theme.slug), $[3] = actorRef, $[4] = t2), t1 = removed.map(t2), $[0] = actorRef, $[1] = removed, $[2] = t1;
|
|
328
|
+
} else t1 = $[2];
|
|
329
|
+
let t2;
|
|
330
|
+
return $[5] === t1 ? t2 = $[6] : (t2 = /* @__PURE__ */ jsx(ScrollArea, {
|
|
329
331
|
padding: 3,
|
|
330
332
|
children: /* @__PURE__ */ jsx(Stack, {
|
|
331
333
|
gap: 5,
|
|
332
|
-
children:
|
|
334
|
+
children: t1
|
|
333
335
|
})
|
|
334
|
-
}), $[5] =
|
|
336
|
+
}), $[5] = t1, $[6] = t2), t2;
|
|
337
|
+
}
|
|
338
|
+
/** The variants in the order the tool offers them @internal */
|
|
339
|
+
const IMAGE_PALETTE_VARIANTS = [
|
|
340
|
+
"muted",
|
|
341
|
+
"vibrant",
|
|
342
|
+
"lightMuted",
|
|
343
|
+
"lightVibrant",
|
|
344
|
+
"darkMuted",
|
|
345
|
+
"darkVibrant"
|
|
346
|
+
], IMAGE_PALETTE_TITLES = {
|
|
347
|
+
dominant: "Dominant",
|
|
348
|
+
vibrant: "Vibrant",
|
|
349
|
+
lightVibrant: "Light vibrant",
|
|
350
|
+
darkVibrant: "Dark vibrant",
|
|
351
|
+
muted: "Muted",
|
|
352
|
+
lightMuted: "Light muted",
|
|
353
|
+
darkMuted: "Dark muted"
|
|
354
|
+
}, TARGETS = [
|
|
355
|
+
["vibrant", {
|
|
356
|
+
lightness: [
|
|
357
|
+
.5,
|
|
358
|
+
.3,
|
|
359
|
+
.7
|
|
360
|
+
],
|
|
361
|
+
saturation: [
|
|
362
|
+
1,
|
|
363
|
+
.35,
|
|
364
|
+
1
|
|
365
|
+
]
|
|
366
|
+
}],
|
|
367
|
+
["lightVibrant", {
|
|
368
|
+
lightness: [
|
|
369
|
+
.74,
|
|
370
|
+
.55,
|
|
371
|
+
1
|
|
372
|
+
],
|
|
373
|
+
saturation: [
|
|
374
|
+
1,
|
|
375
|
+
.35,
|
|
376
|
+
1
|
|
377
|
+
]
|
|
378
|
+
}],
|
|
379
|
+
["darkVibrant", {
|
|
380
|
+
lightness: [
|
|
381
|
+
.26,
|
|
382
|
+
0,
|
|
383
|
+
.45
|
|
384
|
+
],
|
|
385
|
+
saturation: [
|
|
386
|
+
1,
|
|
387
|
+
.35,
|
|
388
|
+
1
|
|
389
|
+
]
|
|
390
|
+
}],
|
|
391
|
+
["muted", {
|
|
392
|
+
lightness: [
|
|
393
|
+
.5,
|
|
394
|
+
.3,
|
|
395
|
+
.7
|
|
396
|
+
],
|
|
397
|
+
saturation: [
|
|
398
|
+
.3,
|
|
399
|
+
0,
|
|
400
|
+
.4
|
|
401
|
+
]
|
|
402
|
+
}],
|
|
403
|
+
["lightMuted", {
|
|
404
|
+
lightness: [
|
|
405
|
+
.74,
|
|
406
|
+
.55,
|
|
407
|
+
1
|
|
408
|
+
],
|
|
409
|
+
saturation: [
|
|
410
|
+
.3,
|
|
411
|
+
0,
|
|
412
|
+
.4
|
|
413
|
+
]
|
|
414
|
+
}],
|
|
415
|
+
["darkMuted", {
|
|
416
|
+
lightness: [
|
|
417
|
+
.26,
|
|
418
|
+
0,
|
|
419
|
+
.45
|
|
420
|
+
],
|
|
421
|
+
saturation: [
|
|
422
|
+
.3,
|
|
423
|
+
0,
|
|
424
|
+
.4
|
|
425
|
+
]
|
|
426
|
+
}]
|
|
427
|
+
];
|
|
428
|
+
/**
|
|
429
|
+
* Extracts the color palette of an image from its pixels, the way the Vibrant
|
|
430
|
+
* algorithm does: the colors are quantized into a coarse histogram, and each
|
|
431
|
+
* swatch claims the color that comes closest to its target lightness and
|
|
432
|
+
* saturation — weighted by how much of the image it covers — that no other
|
|
433
|
+
* swatch has claimed yet. The dominant swatch is simply the most common
|
|
434
|
+
* color. Runs anywhere pixels come from, so it can run on device.
|
|
435
|
+
*
|
|
436
|
+
* @internal
|
|
437
|
+
*/
|
|
438
|
+
function extractImagePalette(pixels) {
|
|
439
|
+
let candidates = quantize(pixels), palette = {
|
|
440
|
+
dominant: null,
|
|
441
|
+
vibrant: null,
|
|
442
|
+
lightVibrant: null,
|
|
443
|
+
darkVibrant: null,
|
|
444
|
+
muted: null,
|
|
445
|
+
lightMuted: null,
|
|
446
|
+
darkMuted: null
|
|
447
|
+
};
|
|
448
|
+
if (candidates.length === 0) return palette;
|
|
449
|
+
let maximumPopulation = Math.max(...candidates.map((candidate) => candidate.population)), claimed = /* @__PURE__ */ new Set();
|
|
450
|
+
for (let [key, target] of TARGETS) {
|
|
451
|
+
let best = null, bestScore = -Infinity;
|
|
452
|
+
for (let candidate of candidates) {
|
|
453
|
+
if (claimed.has(candidate.hex) || !matchesTarget(candidate, target)) continue;
|
|
454
|
+
let score = scoreCandidate(candidate, target, maximumPopulation);
|
|
455
|
+
score > bestScore && (best = candidate, bestScore = score);
|
|
456
|
+
}
|
|
457
|
+
best && (palette[key] = best.hex, claimed.add(best.hex));
|
|
458
|
+
}
|
|
459
|
+
return palette.dominant = candidates.reduce((most, candidate) => candidate.population > most.population ? candidate : most).hex, palette;
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Turns the pixels into a histogram of quantized colors, each averaged over
|
|
463
|
+
* the pixels it stands for, leaving out transparent pixels and the near-black
|
|
464
|
+
* and near-white ones that are backdrop rather than color.
|
|
465
|
+
*/
|
|
466
|
+
function quantize(pixels) {
|
|
467
|
+
let { data } = pixels, buckets = /* @__PURE__ */ new Map(), length = Math.min(data.length, pixels.width * pixels.height * 4);
|
|
468
|
+
for (let offset = 0; offset + 3 < length; offset += 4) {
|
|
469
|
+
let r = data[offset], g = data[offset + 1], b = data[offset + 2];
|
|
470
|
+
if (data[offset + 3] < 125) continue;
|
|
471
|
+
let lightness = (Math.max(r, g, b) + Math.min(r, g, b)) / 510;
|
|
472
|
+
if (lightness < .05 || lightness > .95) continue;
|
|
473
|
+
let key = r >> 3 << 10 | g >> 3 << 5 | b >> 3, bucket = buckets.get(key);
|
|
474
|
+
bucket ? (bucket.count++, bucket.r += r, bucket.g += g, bucket.b += b) : buckets.set(key, {
|
|
475
|
+
count: 1,
|
|
476
|
+
r,
|
|
477
|
+
g,
|
|
478
|
+
b
|
|
479
|
+
});
|
|
480
|
+
}
|
|
481
|
+
let candidates = [];
|
|
482
|
+
for (let bucket of buckets.values()) {
|
|
483
|
+
let r = Math.round(bucket.r / bucket.count), g = Math.round(bucket.g / bucket.count), b = Math.round(bucket.b / bucket.count), { saturation, lightness } = saturationAndLightness(r, g, b);
|
|
484
|
+
candidates.push({
|
|
485
|
+
hex: rgbToHex(r, g, b),
|
|
486
|
+
population: bucket.count,
|
|
487
|
+
saturation,
|
|
488
|
+
lightness
|
|
489
|
+
});
|
|
490
|
+
}
|
|
491
|
+
return candidates;
|
|
492
|
+
}
|
|
493
|
+
function matchesTarget(candidate, target) {
|
|
494
|
+
return candidate.lightness >= target.lightness[1] && candidate.lightness <= target.lightness[2] && candidate.saturation >= target.saturation[1] && candidate.saturation <= target.saturation[2];
|
|
495
|
+
}
|
|
496
|
+
function scoreCandidate(candidate, target, maximumPopulation) {
|
|
497
|
+
return 3 * (1 - Math.abs(candidate.saturation - target.saturation[0])) + 6.5 * (1 - Math.abs(candidate.lightness - target.lightness[0])) + .5 * (candidate.population / maximumPopulation);
|
|
498
|
+
}
|
|
499
|
+
function saturationAndLightness(r, g, b) {
|
|
500
|
+
let max = Math.max(r, g, b) / 255, min = Math.min(r, g, b) / 255, lightness = (max + min) / 2, delta = max - min;
|
|
501
|
+
return {
|
|
502
|
+
saturation: delta === 0 ? 0 : lightness > .5 ? delta / (2 - max - min) : delta / (max + min),
|
|
503
|
+
lightness
|
|
504
|
+
};
|
|
505
|
+
}
|
|
506
|
+
function rgbToHex(r, g, b) {
|
|
507
|
+
return `#${[
|
|
508
|
+
r,
|
|
509
|
+
g,
|
|
510
|
+
b
|
|
511
|
+
].map((channel) => channel.toString(16).padStart(2, "0")).join("")}`;
|
|
512
|
+
}
|
|
513
|
+
/** Reads `#rgb` and `#rrggbb` alike — stored palettes may hold either */
|
|
514
|
+
function hexToRgb(hex) {
|
|
515
|
+
let expanded = hex.length === 4 ? `${hex[1]}${hex[1]}${hex[2]}${hex[2]}${hex[3]}${hex[3]}` : hex.slice(1);
|
|
516
|
+
return [
|
|
517
|
+
parseInt(expanded.slice(0, 2), 16),
|
|
518
|
+
parseInt(expanded.slice(2, 4), 16),
|
|
519
|
+
parseInt(expanded.slice(4, 6), 16)
|
|
520
|
+
];
|
|
521
|
+
}
|
|
522
|
+
/** Mixes `amount` of `color` into `base` */
|
|
523
|
+
function tint(base, color, amount) {
|
|
524
|
+
let [r1, g1, b1] = hexToRgb(base), [r2, g2, b2] = hexToRgb(color);
|
|
525
|
+
return rgbToHex(Math.round(r1 + (r2 - r1) * amount), Math.round(g1 + (g2 - g1) * amount), Math.round(b1 + (b2 - b1) * amount));
|
|
526
|
+
}
|
|
527
|
+
/** How much of the palette tints each scheme's stock background */
|
|
528
|
+
const BACKGROUND_TINT = {
|
|
529
|
+
light: .08,
|
|
530
|
+
dark: .3
|
|
531
|
+
}, BUTTON_LABEL = {
|
|
532
|
+
light: "#ffffff",
|
|
533
|
+
dark: "#000000"
|
|
534
|
+
}, ACCENT_LIGHTNESS_STEP = .01;
|
|
535
|
+
function contrastRatio(a, b) {
|
|
536
|
+
let [lighter, darker] = [relativeLuminance(a), relativeLuminance(b)].sort((x, y) => y - x);
|
|
537
|
+
return (lighter + .05) / (darker + .05);
|
|
538
|
+
}
|
|
539
|
+
/**
|
|
540
|
+
* Makes an accent readable as a button in the given scheme: a light scheme
|
|
541
|
+
* accent is darkened until white text on it reaches AA contrast, a dark
|
|
542
|
+
* scheme accent lightened until black text does — as far as the accent's
|
|
543
|
+
* hue and saturation allow. Accents that already pass come back untouched.
|
|
544
|
+
*
|
|
545
|
+
* @internal
|
|
546
|
+
*/
|
|
547
|
+
function readableAccent(hex, scheme) {
|
|
548
|
+
let label = BUTTON_LABEL[scheme], { h, s } = hexToHsl(hex), { l } = hexToHsl(hex), current = hex;
|
|
549
|
+
for (; contrastRatio(current, label) < 4.5;) {
|
|
550
|
+
let next = scheme === "light" ? l - ACCENT_LIGHTNESS_STEP : l + ACCENT_LIGHTNESS_STEP;
|
|
551
|
+
if (next < 0 || next > 1) break;
|
|
552
|
+
l = next, current = hslToHex({
|
|
553
|
+
h,
|
|
554
|
+
s,
|
|
555
|
+
l
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
return current;
|
|
559
|
+
}
|
|
560
|
+
/** The accent a variant gives a scheme, made readable on a button */
|
|
561
|
+
function variantAccent(palette, variant, scheme) {
|
|
562
|
+
let swatch = (variant ? palette[variant] : null) ?? palette.vibrant ?? (scheme === "light" ? palette.darkVibrant : palette.lightVibrant) ?? palette.dominant;
|
|
563
|
+
return swatch === null ? null : readableAccent(swatch, scheme);
|
|
564
|
+
}
|
|
565
|
+
/**
|
|
566
|
+
* Derives theme options from an image palette: the accent of both schemes is
|
|
567
|
+
* the swatch of the chosen variant — or, without one, the vibrant swatch,
|
|
568
|
+
* each scheme falling back to the vibrant swatch of its own end of the scale —
|
|
569
|
+
* adjusted until it is readable as a button. The muted swatch becomes the text color, and the light and dark muted
|
|
570
|
+
* swatches tint the stock backgrounds of their scheme — enough to carry the
|
|
571
|
+
* image's tone without giving up a usable canvas. Whatever the palette lacks
|
|
572
|
+
* stays at the theme defaults.
|
|
573
|
+
*
|
|
574
|
+
* @internal
|
|
575
|
+
*/
|
|
576
|
+
function optionsFromImagePalette(palette, variant) {
|
|
577
|
+
let options = {}, light = schemeFromPalette(variantAccent(palette, variant ?? null, "light"), palette.muted ?? palette.darkMuted, palette.lightMuted ?? palette.muted ?? palette.lightVibrant, "light"), dark = schemeFromPalette(variantAccent(palette, variant ?? null, "dark"), palette.muted ?? palette.lightMuted, palette.darkMuted ?? palette.muted ?? palette.darkVibrant, "dark");
|
|
578
|
+
return light && (options.light = light), dark && (options.dark = dark), options;
|
|
579
|
+
}
|
|
580
|
+
function schemeFromPalette(accent, text, backgroundTint, scheme) {
|
|
581
|
+
let options = {};
|
|
582
|
+
return accent && (options.accent = accent), text && (options.text = text), backgroundTint && (options.background = tint(DEFAULT_BACKGROUND[scheme], backgroundTint, BACKGROUND_TINT[scheme])), Object.keys(options).length > 0 ? options : null;
|
|
583
|
+
}
|
|
584
|
+
/**
|
|
585
|
+
* Applies an image palette to existing theme options: the colors the palette
|
|
586
|
+
* provides replace the current ones scheme by scheme, and whatever it does
|
|
587
|
+
* not touch — like the contrast — stays as it is.
|
|
588
|
+
*
|
|
589
|
+
* @internal
|
|
590
|
+
*/
|
|
591
|
+
function applyImagePalette(options, palette, variant) {
|
|
592
|
+
let derived = optionsFromImagePalette(palette, variant), next = { ...options };
|
|
593
|
+
for (let scheme of SCHEMES) derived[scheme] && (next[scheme] = {
|
|
594
|
+
...options[scheme],
|
|
595
|
+
...derived[scheme]
|
|
596
|
+
});
|
|
597
|
+
return next;
|
|
598
|
+
}
|
|
599
|
+
/**
|
|
600
|
+
* The variant a theme is built around: the one whose swatch is the theme's
|
|
601
|
+
* accent, or `null` when the accent comes from somewhere else.
|
|
602
|
+
*
|
|
603
|
+
* @internal
|
|
604
|
+
*/
|
|
605
|
+
function currentImageVariant(options, palette) {
|
|
606
|
+
let accent = options.light?.accent;
|
|
607
|
+
return accent ? IMAGE_PALETTE_VARIANTS.find((variant) => palette[variant] !== null && variantAccent(palette, variant, "light") === accent) ?? null : null;
|
|
608
|
+
}
|
|
609
|
+
/**
|
|
610
|
+
* How much a swatch has going for it as an accent: saturation first, then
|
|
611
|
+
* closeness to mid lightness — the range where an accent reads best.
|
|
612
|
+
*/
|
|
613
|
+
function interest(hex) {
|
|
614
|
+
let { s, l } = hexToHsl(hex);
|
|
615
|
+
return .1 + .55 * s + .35 * (1 - Math.abs(l - .5) * 2);
|
|
616
|
+
}
|
|
617
|
+
/**
|
|
618
|
+
* Picks a variant for the "I'm feeling lucky" button: a random one, weighted
|
|
619
|
+
* by how interesting its swatch is as an accent, and never the one the theme
|
|
620
|
+
* already uses while there are others to pick from.
|
|
621
|
+
*
|
|
622
|
+
* @internal
|
|
623
|
+
*/
|
|
624
|
+
function pickLuckyVariant(palette, options = {}) {
|
|
625
|
+
let { exclude = null, random = Math.random } = options, candidates = IMAGE_PALETTE_VARIANTS.filter((variant) => palette[variant] !== null);
|
|
626
|
+
if (candidates.length > 1 && (candidates = candidates.filter((variant) => variant !== exclude)), candidates.length === 0) return null;
|
|
627
|
+
let weights = candidates.map((variant) => interest(palette[variant])), total = weights.reduce((sum, weight) => sum + weight, 0), pick = random() * total;
|
|
628
|
+
for (let [index, variant] of candidates.entries()) if (pick -= weights[index], pick < 0) return variant;
|
|
629
|
+
return candidates.at(-1) ?? null;
|
|
630
|
+
}
|
|
631
|
+
/** A theme title for the image a palette came from, e.g. `sunset-beach.jpg` → `sunset beach` @internal */
|
|
632
|
+
function titleFromFileName(name) {
|
|
633
|
+
return name.replace(/\.[^.]+$/, "").replace(/[-_]+/g, " ").trim() || "Image theme";
|
|
335
634
|
}
|
|
336
635
|
/**
|
|
337
636
|
* A button with an animated tooltip instead of a `title` attribute, sized like
|
|
@@ -452,7 +751,7 @@ function useImagePalette(onPalette) {
|
|
|
452
751
|
setBusy(!0);
|
|
453
752
|
let isCurrent = () => mountedRef.current && latestPickRef.current === pick, extract = async () => {
|
|
454
753
|
let palette = extractImagePalette(await readImagePixels(file));
|
|
455
|
-
isCurrent() && (Object.values(palette).every(_temp$
|
|
754
|
+
isCurrent() && (Object.values(palette).every(_temp$6) ? toast.push({
|
|
456
755
|
status: "warning",
|
|
457
756
|
title: "Found no colors in that image"
|
|
458
757
|
}) : onPaletteRef.current(palette, file));
|
|
@@ -472,7 +771,7 @@ function useImagePalette(onPalette) {
|
|
|
472
771
|
pickImage
|
|
473
772
|
}, $[7] = busy, $[8] = pickImage, $[9] = t5) : t5 = $[9], t5;
|
|
474
773
|
}
|
|
475
|
-
function _temp$
|
|
774
|
+
function _temp$6(swatch) {
|
|
476
775
|
return swatch === null;
|
|
477
776
|
}
|
|
478
777
|
var paletteGrid = "_17s80v42", tile = "_17s80v44", variantButton = "_17s80v46", variantFrame = "_17s80v47", variantRow = "_17s80v45", variantScale = "var(--_17s80v41)", variantScaleBox = "_17s80v48", variantWidth = "var(--_17s80v40)";
|
|
@@ -663,7 +962,7 @@ function ImagePaletteSection(props) {
|
|
|
663
962
|
border: !0,
|
|
664
963
|
onDragEnter: t4,
|
|
665
964
|
onDragLeave: t5,
|
|
666
|
-
onDragOver: _temp$
|
|
965
|
+
onDragOver: _temp$5,
|
|
667
966
|
onDrop: t6,
|
|
668
967
|
padding: 3,
|
|
669
968
|
radius: 3,
|
|
@@ -671,7 +970,7 @@ function ImagePaletteSection(props) {
|
|
|
671
970
|
children: t12
|
|
672
971
|
}), $[34] = t12, $[35] = t6, $[36] = t7, $[37] = t13) : t13 = $[37], t13;
|
|
673
972
|
}
|
|
674
|
-
function _temp$
|
|
973
|
+
function _temp$5(event_0) {
|
|
675
974
|
event_0.preventDefault();
|
|
676
975
|
}
|
|
677
976
|
var colorRowText = "os3rj2", range = "os3rj1", swatch = "os3rj0";
|
|
@@ -684,8 +983,8 @@ const SCHEME_TITLES = {
|
|
|
684
983
|
* to the sidebar (or at the bottom, stacked on small screens), the other one
|
|
685
984
|
* takes the far side
|
|
686
985
|
*/
|
|
687
|
-
function splitHint(own
|
|
688
|
-
return
|
|
986
|
+
function splitHint(own) {
|
|
987
|
+
return own ? "Shown on the right, next to the themer" : "Shown on the left";
|
|
689
988
|
}
|
|
690
989
|
const SCHEME_OPTION_KEYS = [
|
|
691
990
|
"accent",
|
|
@@ -707,71 +1006,73 @@ const SCHEME_OPTION_KEYS = [
|
|
|
707
1006
|
*
|
|
708
1007
|
* @internal
|
|
709
1008
|
*/
|
|
710
|
-
function ThemeEditor(
|
|
711
|
-
let $ = c(
|
|
1009
|
+
function ThemeEditor(t0) {
|
|
1010
|
+
let $ = c(41), { actorRef, focusTitle, slug, split, themes } = t0, images = useSelector(actorRef, _temp$4), t1;
|
|
712
1011
|
if ($[0] !== slug || $[1] !== themes) {
|
|
713
|
-
let
|
|
714
|
-
$[3] === slug ?
|
|
715
|
-
} else
|
|
716
|
-
let theme =
|
|
1012
|
+
let t2;
|
|
1013
|
+
$[3] === slug ? t2 = $[4] : (t2 = (candidate) => candidate.slug === slug && candidate.source === "custom", $[3] = slug, $[4] = t2), t1 = themes.find(t2), $[0] = slug, $[1] = themes, $[2] = t1;
|
|
1014
|
+
} else t1 = $[2];
|
|
1015
|
+
let theme = t1;
|
|
717
1016
|
if (!theme) return null;
|
|
718
|
-
let
|
|
719
|
-
$[5] !==
|
|
720
|
-
theme.palette && variant !== null && send({
|
|
1017
|
+
let t2;
|
|
1018
|
+
$[5] !== actorRef || $[6] !== slug || $[7] !== theme.options || $[8] !== theme.palette ? (t2 = (variant) => {
|
|
1019
|
+
theme.palette && variant !== null && actorRef.send({
|
|
721
1020
|
type: "theme.update",
|
|
722
1021
|
slug,
|
|
723
1022
|
options: applyImagePalette(theme.options, theme.palette, variant)
|
|
724
1023
|
});
|
|
725
|
-
}, $[5] =
|
|
726
|
-
let applyVariant =
|
|
727
|
-
$[10] ===
|
|
728
|
-
let t4;
|
|
729
|
-
$[12] !== applyVariant || $[13] !== theme.options || $[14] !== theme.palette ? (t4 = () => {
|
|
730
|
-
theme.palette && applyVariant(pickLuckyVariant(theme.palette, { exclude: currentImageVariant(theme.options, theme.palette) }));
|
|
731
|
-
}, $[12] = applyVariant, $[13] = theme.options, $[14] = theme.palette, $[15] = t4) : t4 = $[15];
|
|
1024
|
+
}, $[5] = actorRef, $[6] = slug, $[7] = theme.options, $[8] = theme.palette, $[9] = t2) : t2 = $[9];
|
|
1025
|
+
let applyVariant = t2, t3 = images[slug], t4;
|
|
1026
|
+
$[10] === actorRef ? t4 = $[11] : (t4 = () => actorRef.send({ type: "flow.list" }), $[10] = actorRef, $[11] = t4);
|
|
732
1027
|
let t5;
|
|
733
|
-
$[
|
|
1028
|
+
$[12] !== applyVariant || $[13] !== theme.options || $[14] !== theme.palette ? (t5 = () => {
|
|
1029
|
+
theme.palette && applyVariant(pickLuckyVariant(theme.palette, { exclude: currentImageVariant(theme.options, theme.palette) }));
|
|
1030
|
+
}, $[12] = applyVariant, $[13] = theme.options, $[14] = theme.palette, $[15] = t5) : t5 = $[15];
|
|
1031
|
+
let t6;
|
|
1032
|
+
$[16] !== actorRef || $[17] !== slug ? (t6 = (options) => actorRef.send({
|
|
734
1033
|
type: "theme.update",
|
|
735
1034
|
slug,
|
|
736
1035
|
options
|
|
737
|
-
}), $[16] =
|
|
738
|
-
let
|
|
739
|
-
$[19] !==
|
|
1036
|
+
}), $[16] = actorRef, $[17] = slug, $[18] = t6) : t6 = $[18];
|
|
1037
|
+
let t7;
|
|
1038
|
+
$[19] !== actorRef || $[20] !== slug || $[21] !== theme.options ? (t7 = (palette, file) => actorRef.send({
|
|
740
1039
|
type: "theme.update",
|
|
741
1040
|
slug,
|
|
742
1041
|
options: applyImagePalette(theme.options, palette),
|
|
743
1042
|
palette,
|
|
744
1043
|
imageUrl: URL.createObjectURL(file)
|
|
745
|
-
}), $[19] =
|
|
746
|
-
let
|
|
747
|
-
$[23] !==
|
|
1044
|
+
}), $[19] = actorRef, $[20] = slug, $[21] = theme.options, $[22] = t7) : t7 = $[22];
|
|
1045
|
+
let t8, t9;
|
|
1046
|
+
$[23] !== actorRef || $[24] !== slug ? (t8 = () => actorRef.send({
|
|
748
1047
|
type: "theme.remove",
|
|
749
1048
|
slug
|
|
750
|
-
}),
|
|
1049
|
+
}), t9 = (title) => actorRef.send({
|
|
751
1050
|
type: "theme.update",
|
|
752
1051
|
slug,
|
|
753
1052
|
title
|
|
754
|
-
}), $[23] =
|
|
755
|
-
let
|
|
756
|
-
return $[27] !== applyVariant || $[28] !== focusTitle || $[29] !==
|
|
1053
|
+
}), $[23] = actorRef, $[24] = slug, $[25] = t8, $[26] = t9) : (t8 = $[25], t9 = $[26]);
|
|
1054
|
+
let t10;
|
|
1055
|
+
return $[27] !== applyVariant || $[28] !== focusTitle || $[29] !== split || $[30] !== t3 || $[31] !== t4 || $[32] !== t5 || $[33] !== t6 || $[34] !== t7 || $[35] !== t8 || $[36] !== t9 || $[37] !== theme.options || $[38] !== theme.palette || $[39] !== theme.title ? (t10 = /* @__PURE__ */ jsx(ThemeEditorForm, {
|
|
757
1056
|
focusTitle,
|
|
758
|
-
imageUrl:
|
|
759
|
-
onDone:
|
|
760
|
-
onLucky:
|
|
761
|
-
onOptionsChange:
|
|
762
|
-
onPalette:
|
|
763
|
-
onRemove:
|
|
764
|
-
onTitleChange:
|
|
1057
|
+
imageUrl: t3,
|
|
1058
|
+
onDone: t4,
|
|
1059
|
+
onLucky: t5,
|
|
1060
|
+
onOptionsChange: t6,
|
|
1061
|
+
onPalette: t7,
|
|
1062
|
+
onRemove: t8,
|
|
1063
|
+
onTitleChange: t9,
|
|
765
1064
|
onVariant: applyVariant,
|
|
766
1065
|
options: theme.options,
|
|
767
1066
|
palette: theme.palette,
|
|
768
1067
|
split,
|
|
769
|
-
mobile,
|
|
770
1068
|
title: theme.title
|
|
771
|
-
}), $[27] = applyVariant, $[28] = focusTitle, $[29] =
|
|
1069
|
+
}), $[27] = applyVariant, $[28] = focusTitle, $[29] = split, $[30] = t3, $[31] = t4, $[32] = t5, $[33] = t6, $[34] = t7, $[35] = t8, $[36] = t9, $[37] = theme.options, $[38] = theme.palette, $[39] = theme.title, $[40] = t10) : t10 = $[40], t10;
|
|
1070
|
+
}
|
|
1071
|
+
function _temp$4(snapshot) {
|
|
1072
|
+
return snapshot.context.images;
|
|
772
1073
|
}
|
|
773
1074
|
function ThemeEditorForm(props) {
|
|
774
|
-
let $ = c(
|
|
1075
|
+
let $ = c(49), { focusTitle, imageUrl, onDone, onLucky, onOptionsChange, onPalette, onRemove, onTitleChange, onVariant, options, palette, split, title } = props, studioScheme = useColorSchemeValue(), t0;
|
|
775
1076
|
$[0] === options ? t0 = $[1] : (t0 = resolveThemeOptions(options), $[0] = options, $[1] = t0);
|
|
776
1077
|
let resolved = t0, t1;
|
|
777
1078
|
$[2] === options ? t1 = $[3] : (t1 = buildPalette(options), $[2] = options, $[3] = t1);
|
|
@@ -795,7 +1096,7 @@ function ThemeEditorForm(props) {
|
|
|
795
1096
|
}), $[9] = t4) : t4 = $[9];
|
|
796
1097
|
let t5;
|
|
797
1098
|
$[10] === onTitleChange ? t5 = $[11] : (t5 = (event) => onTitleChange(event.currentTarget.value), $[10] = onTitleChange, $[11] = t5);
|
|
798
|
-
let t6 = focusTitle ?
|
|
1099
|
+
let t6 = focusTitle ? _temp2 : void 0, t7;
|
|
799
1100
|
$[12] !== focusTitle || $[13] !== t5 || $[14] !== t6 || $[15] !== title ? (t7 = /* @__PURE__ */ jsxs(Stack, {
|
|
800
1101
|
gap: 2,
|
|
801
1102
|
children: [t4, /* @__PURE__ */ jsx(TextInput, {
|
|
@@ -818,7 +1119,7 @@ function ThemeEditorForm(props) {
|
|
|
818
1119
|
palette
|
|
819
1120
|
}), $[17] = imageUrl, $[18] = onLucky, $[19] = onPalette, $[20] = onVariant, $[21] = options, $[22] = palette, $[23] = t8) : t8 = $[23];
|
|
820
1121
|
let t9;
|
|
821
|
-
$[24] !==
|
|
1122
|
+
$[24] !== options || $[25] !== palettes || $[26] !== patchScheme || $[27] !== resolved || $[28] !== split || $[29] !== studioScheme ? (t9 = SCHEMES.map((scheme_0) => /* @__PURE__ */ jsx(SchemeCard, {
|
|
822
1123
|
active: split || scheme_0 === studioScheme,
|
|
823
1124
|
onChange: (changes_0) => patchScheme(scheme_0, changes_0),
|
|
824
1125
|
options: options[scheme_0] ?? {},
|
|
@@ -826,12 +1127,12 @@ function ThemeEditorForm(props) {
|
|
|
826
1127
|
resolved: resolved[scheme_0],
|
|
827
1128
|
scheme: scheme_0,
|
|
828
1129
|
split,
|
|
829
|
-
splitHint: splitHint(scheme_0 === studioScheme
|
|
830
|
-
}, scheme_0)), $[24] =
|
|
1130
|
+
splitHint: splitHint(scheme_0 === studioScheme)
|
|
1131
|
+
}, scheme_0)), $[24] = options, $[25] = palettes, $[26] = patchScheme, $[27] = resolved, $[28] = split, $[29] = studioScheme, $[30] = t9) : t9 = $[30];
|
|
831
1132
|
let t10;
|
|
832
|
-
$[
|
|
1133
|
+
$[31] === t9 ? t10 = $[32] : (t10 = /* @__PURE__ */ jsx(ScrollAreaBleed, { children: t9 }), $[31] = t9, $[32] = t10);
|
|
833
1134
|
let t11;
|
|
834
|
-
$[
|
|
1135
|
+
$[33] !== t10 || $[34] !== t3 || $[35] !== t7 || $[36] !== t8 ? (t11 = /* @__PURE__ */ jsx(ScrollArea, {
|
|
835
1136
|
padding: 3,
|
|
836
1137
|
children: /* @__PURE__ */ jsxs(Stack, {
|
|
837
1138
|
gap: 4,
|
|
@@ -842,27 +1143,27 @@ function ThemeEditorForm(props) {
|
|
|
842
1143
|
t10
|
|
843
1144
|
]
|
|
844
1145
|
})
|
|
845
|
-
}), $[
|
|
1146
|
+
}), $[33] = t10, $[34] = t3, $[35] = t7, $[36] = t8, $[37] = t11) : t11 = $[37];
|
|
846
1147
|
let t12;
|
|
847
|
-
$[
|
|
1148
|
+
$[38] === onRemove ? t12 = $[39] : (t12 = /* @__PURE__ */ jsx(TooltipButton, {
|
|
848
1149
|
icon: TrashIcon,
|
|
849
1150
|
mode: "ghost",
|
|
850
1151
|
onClick: onRemove,
|
|
851
1152
|
text: "Remove",
|
|
852
1153
|
tone: "critical",
|
|
853
1154
|
tooltip: "Remove the theme — it can be restored until it is deleted"
|
|
854
|
-
}), $[
|
|
1155
|
+
}), $[38] = onRemove, $[39] = t12);
|
|
855
1156
|
let t13;
|
|
856
|
-
$[
|
|
1157
|
+
$[40] === Symbol.for("react.memo_cache_sentinel") ? (t13 = /* @__PURE__ */ jsx(Box, { flex: 1 }), $[40] = t13) : t13 = $[40];
|
|
857
1158
|
let t14;
|
|
858
|
-
$[
|
|
1159
|
+
$[41] === onDone ? t14 = $[42] : (t14 = /* @__PURE__ */ jsx(Button, {
|
|
859
1160
|
mode: "ghost",
|
|
860
1161
|
onClick: onDone,
|
|
861
1162
|
padding: 2,
|
|
862
1163
|
text: "Done"
|
|
863
|
-
}), $[
|
|
1164
|
+
}), $[41] = onDone, $[42] = t14);
|
|
864
1165
|
let t15;
|
|
865
|
-
$[
|
|
1166
|
+
$[43] !== t12 || $[44] !== t14 ? (t15 = /* @__PURE__ */ jsx(Card, {
|
|
866
1167
|
borderTop: !0,
|
|
867
1168
|
padding: 3,
|
|
868
1169
|
children: /* @__PURE__ */ jsxs(Flex, {
|
|
@@ -873,11 +1174,11 @@ function ThemeEditorForm(props) {
|
|
|
873
1174
|
t14
|
|
874
1175
|
]
|
|
875
1176
|
})
|
|
876
|
-
}), $[
|
|
1177
|
+
}), $[43] = t12, $[44] = t14, $[45] = t15) : t15 = $[45];
|
|
877
1178
|
let t16;
|
|
878
|
-
return $[
|
|
1179
|
+
return $[46] !== t11 || $[47] !== t15 ? (t16 = /* @__PURE__ */ jsxs(Fragment, { children: [t11, t15] }), $[46] = t11, $[47] = t15, $[48] = t16) : t16 = $[48], t16;
|
|
879
1180
|
}
|
|
880
|
-
function
|
|
1181
|
+
function _temp2(event_0) {
|
|
881
1182
|
return event_0.currentTarget.select();
|
|
882
1183
|
}
|
|
883
1184
|
/**
|
|
@@ -1196,9 +1497,9 @@ function fromBase64Url(code) {
|
|
|
1196
1497
|
*
|
|
1197
1498
|
* @internal
|
|
1198
1499
|
*/
|
|
1199
|
-
function useThemeCodes() {
|
|
1200
|
-
let $ = c(11), {
|
|
1201
|
-
$[0] === toast ?
|
|
1500
|
+
function useThemeCodes(t0) {
|
|
1501
|
+
let $ = c(11), { actorRef } = t0, toast = useToast(), t1;
|
|
1502
|
+
$[0] === toast ? t1 = $[1] : (t1 = async (theme) => {
|
|
1202
1503
|
let title = displayTitle(theme.title);
|
|
1203
1504
|
try {
|
|
1204
1505
|
await navigator.clipboard.writeText(encodeTheme(theme)), toast.push({
|
|
@@ -1212,11 +1513,11 @@ function useThemeCodes() {
|
|
|
1212
1513
|
title: `Could not copy ${title}`
|
|
1213
1514
|
});
|
|
1214
1515
|
}
|
|
1215
|
-
}, $[0] = toast, $[1] =
|
|
1216
|
-
let copyTheme =
|
|
1217
|
-
$[2] !==
|
|
1516
|
+
}, $[0] = toast, $[1] = t1);
|
|
1517
|
+
let copyTheme = t1, t2;
|
|
1518
|
+
$[2] !== actorRef || $[3] !== toast ? (t2 = (text) => {
|
|
1218
1519
|
let theme_0 = decodeTheme(text);
|
|
1219
|
-
return theme_0 ? (send({
|
|
1520
|
+
return theme_0 ? (actorRef.send({
|
|
1220
1521
|
type: "theme.import",
|
|
1221
1522
|
title: theme_0.title,
|
|
1222
1523
|
options: theme_0.options
|
|
@@ -1224,9 +1525,9 @@ function useThemeCodes() {
|
|
|
1224
1525
|
status: "success",
|
|
1225
1526
|
title: `Added ${theme_0.title}`
|
|
1226
1527
|
}), !0) : !1;
|
|
1227
|
-
}, $[2] =
|
|
1228
|
-
let addThemeFromText =
|
|
1229
|
-
$[5] === addThemeFromText ?
|
|
1528
|
+
}, $[2] = actorRef, $[3] = toast, $[4] = t2) : t2 = $[4];
|
|
1529
|
+
let addThemeFromText = t2, t3;
|
|
1530
|
+
$[5] === addThemeFromText ? t3 = $[6] : (t3 = async () => {
|
|
1230
1531
|
let text_0;
|
|
1231
1532
|
try {
|
|
1232
1533
|
text_0 = await navigator.clipboard.readText();
|
|
@@ -1234,13 +1535,13 @@ function useThemeCodes() {
|
|
|
1234
1535
|
return "no-clipboard";
|
|
1235
1536
|
}
|
|
1236
1537
|
return addThemeFromText(text_0) ? "added" : "no-theme";
|
|
1237
|
-
}, $[5] = addThemeFromText, $[6] =
|
|
1238
|
-
let addThemeFromClipboard =
|
|
1239
|
-
return $[7] !== addThemeFromClipboard || $[8] !== addThemeFromText || $[9] !== copyTheme ? (
|
|
1538
|
+
}, $[5] = addThemeFromText, $[6] = t3);
|
|
1539
|
+
let addThemeFromClipboard = t3, t4;
|
|
1540
|
+
return $[7] !== addThemeFromClipboard || $[8] !== addThemeFromText || $[9] !== copyTheme ? (t4 = {
|
|
1240
1541
|
copyTheme,
|
|
1241
1542
|
addThemeFromText,
|
|
1242
1543
|
addThemeFromClipboard
|
|
1243
|
-
}, $[7] = addThemeFromClipboard, $[8] = addThemeFromText, $[9] = copyTheme, $[10] =
|
|
1544
|
+
}, $[7] = addThemeFromClipboard, $[8] = addThemeFromText, $[9] = copyTheme, $[10] = t4) : t4 = $[10], t4;
|
|
1244
1545
|
}
|
|
1245
1546
|
/**
|
|
1246
1547
|
* Adds a theme pasted anywhere in the Studio while the themer's list is
|
|
@@ -1248,14 +1549,13 @@ function useThemeCodes() {
|
|
|
1248
1549
|
*
|
|
1249
1550
|
* @internal
|
|
1250
1551
|
*/
|
|
1251
|
-
function usePasteThemeCodes() {
|
|
1252
|
-
let $ = c(
|
|
1253
|
-
$[0] !==
|
|
1254
|
-
if (!open) return;
|
|
1552
|
+
function usePasteThemeCodes(t0) {
|
|
1553
|
+
let $ = c(4), { actorRef } = t0, toast = useToast(), t1, t2;
|
|
1554
|
+
$[0] !== actorRef || $[1] !== toast ? (t1 = () => {
|
|
1255
1555
|
let handlePaste = (event) => {
|
|
1256
1556
|
if (isEditable(event.target)) return;
|
|
1257
1557
|
let theme = decodeTheme(event.clipboardData?.getData("text/plain") ?? "");
|
|
1258
|
-
theme && (event.preventDefault(), send({
|
|
1558
|
+
theme && (event.preventDefault(), actorRef.send({
|
|
1259
1559
|
type: "theme.import",
|
|
1260
1560
|
title: theme.title,
|
|
1261
1561
|
options: theme.options
|
|
@@ -1265,11 +1565,7 @@ function usePasteThemeCodes() {
|
|
|
1265
1565
|
}));
|
|
1266
1566
|
};
|
|
1267
1567
|
return document.addEventListener("paste", handlePaste), () => document.removeEventListener("paste", handlePaste);
|
|
1268
|
-
}, t1 = [
|
|
1269
|
-
open,
|
|
1270
|
-
send,
|
|
1271
|
-
toast
|
|
1272
|
-
], $[0] = open, $[1] = send, $[2] = toast, $[3] = t0, $[4] = t1) : (t0 = $[3], t1 = $[4]), useEffect(t0, t1);
|
|
1568
|
+
}, t2 = [actorRef, toast], $[0] = actorRef, $[1] = toast, $[2] = t1, $[3] = t2) : (t1 = $[2], t2 = $[3]), useEffect(t1, t2);
|
|
1273
1569
|
}
|
|
1274
1570
|
function isEditable(target) {
|
|
1275
1571
|
return target instanceof HTMLElement && (target.isContentEditable || target.matches("input, textarea, select"));
|
|
@@ -1281,62 +1577,64 @@ function isEditable(target) {
|
|
|
1281
1577
|
* @internal
|
|
1282
1578
|
*/
|
|
1283
1579
|
function PasteThemeDialog(props) {
|
|
1284
|
-
let $ = c(
|
|
1285
|
-
$[0]
|
|
1580
|
+
let $ = c(37), { actorRef, onClose } = props, t0;
|
|
1581
|
+
$[0] === actorRef ? t0 = $[1] : (t0 = { actorRef }, $[0] = actorRef, $[1] = t0);
|
|
1582
|
+
let { addThemeFromText } = useThemeCodes(t0), [text, setText] = useState(""), [invalid, setInvalid] = useState(!1), t1;
|
|
1583
|
+
$[2] !== addThemeFromText || $[3] !== onClose || $[4] !== text ? (t1 = () => {
|
|
1286
1584
|
addThemeFromText(text) ? onClose() : setInvalid(!0);
|
|
1287
|
-
}, $[
|
|
1288
|
-
let add =
|
|
1289
|
-
$[
|
|
1585
|
+
}, $[2] = addThemeFromText, $[3] = onClose, $[4] = text, $[5] = t1) : t1 = $[5];
|
|
1586
|
+
let add = t1, t2;
|
|
1587
|
+
$[6] === onClose ? t2 = $[7] : (t2 = /* @__PURE__ */ jsx(Button, {
|
|
1290
1588
|
mode: "ghost",
|
|
1291
1589
|
onClick: onClose,
|
|
1292
1590
|
padding: 2,
|
|
1293
1591
|
text: "Cancel"
|
|
1294
|
-
}), $[
|
|
1295
|
-
let
|
|
1296
|
-
$[
|
|
1297
|
-
let
|
|
1298
|
-
$[
|
|
1299
|
-
disabled:
|
|
1592
|
+
}), $[6] = onClose, $[7] = t2);
|
|
1593
|
+
let t3;
|
|
1594
|
+
$[8] === text ? t3 = $[9] : (t3 = text.trim(), $[8] = text, $[9] = t3);
|
|
1595
|
+
let t4 = t3 === "", t5;
|
|
1596
|
+
$[10] !== add || $[11] !== t4 ? (t5 = /* @__PURE__ */ jsx(Button, {
|
|
1597
|
+
disabled: t4,
|
|
1300
1598
|
onClick: add,
|
|
1301
1599
|
padding: 2,
|
|
1302
1600
|
text: "Add theme",
|
|
1303
1601
|
tone: "primary"
|
|
1304
|
-
}), $[
|
|
1305
|
-
let
|
|
1306
|
-
$[
|
|
1602
|
+
}), $[10] = add, $[11] = t4, $[12] = t5) : t5 = $[12];
|
|
1603
|
+
let t6;
|
|
1604
|
+
$[13] !== t2 || $[14] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Flex, {
|
|
1307
1605
|
gap: 2,
|
|
1308
1606
|
justify: "flex-end",
|
|
1309
1607
|
padding: 3,
|
|
1310
|
-
children: [
|
|
1311
|
-
}), $[
|
|
1312
|
-
let t6;
|
|
1313
|
-
$[14] === add ? t6 = $[15] : (t6 = (event) => {
|
|
1314
|
-
event.preventDefault(), add();
|
|
1315
|
-
}, $[14] = add, $[15] = t6);
|
|
1608
|
+
children: [t2, t5]
|
|
1609
|
+
}), $[13] = t2, $[14] = t5, $[15] = t6) : t6 = $[15];
|
|
1316
1610
|
let t7;
|
|
1317
|
-
$[16] ===
|
|
1611
|
+
$[16] === add ? t7 = $[17] : (t7 = (event) => {
|
|
1612
|
+
event.preventDefault(), add();
|
|
1613
|
+
}, $[16] = add, $[17] = t7);
|
|
1614
|
+
let t8;
|
|
1615
|
+
$[18] === Symbol.for("react.memo_cache_sentinel") ? (t8 = /* @__PURE__ */ jsx(Text, {
|
|
1318
1616
|
muted: !0,
|
|
1319
1617
|
size: 1,
|
|
1320
1618
|
children: "Paste the code someone copied from their themer — the theme is added to your list and applied."
|
|
1321
|
-
}), $[
|
|
1322
|
-
let
|
|
1323
|
-
$[
|
|
1619
|
+
}), $[18] = t8) : t8 = $[18];
|
|
1620
|
+
let t9 = invalid ? "themer-paste-error" : void 0, t10 = invalid ? "That is not a theme code" : void 0, t11;
|
|
1621
|
+
$[19] === Symbol.for("react.memo_cache_sentinel") ? (t11 = (event_0) => {
|
|
1324
1622
|
setText(event_0.currentTarget.value), setInvalid(!1);
|
|
1325
|
-
}, $[
|
|
1326
|
-
let
|
|
1327
|
-
$[
|
|
1328
|
-
"aria-describedby":
|
|
1623
|
+
}, $[19] = t11) : t11 = $[19];
|
|
1624
|
+
let t12;
|
|
1625
|
+
$[20] !== invalid || $[21] !== t10 || $[22] !== t9 || $[23] !== text ? (t12 = /* @__PURE__ */ jsx(TextInput, {
|
|
1626
|
+
"aria-describedby": t9,
|
|
1329
1627
|
"aria-invalid": invalid,
|
|
1330
1628
|
"aria-label": "Theme code",
|
|
1331
1629
|
autoFocus: !0,
|
|
1332
|
-
customValidity:
|
|
1630
|
+
customValidity: t10,
|
|
1333
1631
|
fontSize: 1,
|
|
1334
|
-
onChange:
|
|
1632
|
+
onChange: t11,
|
|
1335
1633
|
placeholder: "AQ…",
|
|
1336
1634
|
value: text
|
|
1337
|
-
}), $[
|
|
1338
|
-
let
|
|
1339
|
-
$[
|
|
1635
|
+
}), $[20] = invalid, $[21] = t10, $[22] = t9, $[23] = text, $[24] = t12) : t12 = $[24];
|
|
1636
|
+
let t13;
|
|
1637
|
+
$[25] === invalid ? t13 = $[26] : (t13 = invalid && /* @__PURE__ */ jsx(Card, {
|
|
1340
1638
|
id: "themer-paste-error",
|
|
1341
1639
|
padding: 3,
|
|
1342
1640
|
radius: 2,
|
|
@@ -1346,33 +1644,33 @@ function PasteThemeDialog(props) {
|
|
|
1346
1644
|
size: 1,
|
|
1347
1645
|
children: "That is not a theme code — codes are one word, copied from a theme's menu."
|
|
1348
1646
|
})
|
|
1349
|
-
}), $[
|
|
1350
|
-
let
|
|
1351
|
-
$[
|
|
1647
|
+
}), $[25] = invalid, $[26] = t13);
|
|
1648
|
+
let t14;
|
|
1649
|
+
$[27] !== t12 || $[28] !== t13 ? (t14 = /* @__PURE__ */ jsxs(Stack, {
|
|
1352
1650
|
gap: 3,
|
|
1353
1651
|
padding: 4,
|
|
1354
1652
|
children: [
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1653
|
+
t8,
|
|
1654
|
+
t12,
|
|
1655
|
+
t13
|
|
1358
1656
|
]
|
|
1359
|
-
}), $[
|
|
1360
|
-
let t14;
|
|
1361
|
-
$[28] !== t13 || $[29] !== t6 ? (t14 = /* @__PURE__ */ jsx("form", {
|
|
1362
|
-
onSubmit: t6,
|
|
1363
|
-
children: t13
|
|
1364
|
-
}), $[28] = t13, $[29] = t6, $[30] = t14) : t14 = $[30];
|
|
1657
|
+
}), $[27] = t12, $[28] = t13, $[29] = t14) : t14 = $[29];
|
|
1365
1658
|
let t15;
|
|
1366
|
-
|
|
1659
|
+
$[30] !== t14 || $[31] !== t7 ? (t15 = /* @__PURE__ */ jsx("form", {
|
|
1660
|
+
onSubmit: t7,
|
|
1661
|
+
children: t14
|
|
1662
|
+
}), $[30] = t14, $[31] = t7, $[32] = t15) : t15 = $[32];
|
|
1663
|
+
let t16;
|
|
1664
|
+
return $[33] !== onClose || $[34] !== t15 || $[35] !== t6 ? (t16 = /* @__PURE__ */ jsx(Dialog, {
|
|
1367
1665
|
animate: !0,
|
|
1368
|
-
footer:
|
|
1666
|
+
footer: t6,
|
|
1369
1667
|
header: "Add a shared theme",
|
|
1370
1668
|
id: "themer-paste",
|
|
1371
1669
|
onClickOutside: onClose,
|
|
1372
1670
|
onClose,
|
|
1373
1671
|
width: 0,
|
|
1374
|
-
children:
|
|
1375
|
-
}), $[
|
|
1672
|
+
children: t15
|
|
1673
|
+
}), $[33] = onClose, $[34] = t15, $[35] = t6, $[36] = t16) : t16 = $[36], t16;
|
|
1376
1674
|
}
|
|
1377
1675
|
var frame$1 = "_1wsn7882", menuCard = "_1wsn7884", menuSlot = "_1wsn7883", pickButton = "_1wsn7881", root = "_1wsn7880";
|
|
1378
1676
|
/**
|
|
@@ -1395,47 +1693,49 @@ function scrollRefIntoViewIfNeeded(node) {
|
|
|
1395
1693
|
*
|
|
1396
1694
|
* @internal
|
|
1397
1695
|
*/
|
|
1398
|
-
function ThemeCard(
|
|
1399
|
-
let $ = c(
|
|
1400
|
-
$[0] ===
|
|
1401
|
-
let
|
|
1402
|
-
$[2] === theme.
|
|
1403
|
-
let
|
|
1404
|
-
$[4]
|
|
1405
|
-
|
|
1406
|
-
|
|
1696
|
+
function ThemeCard(t0) {
|
|
1697
|
+
let $ = c(79), { actorRef, active, theme, themes } = t0, t1;
|
|
1698
|
+
$[0] === actorRef ? t1 = $[1] : (t1 = { actorRef }, $[0] = actorRef, $[1] = t1);
|
|
1699
|
+
let { copyTheme } = useThemeCodes(t1), { scheme } = useRootTheme(), [menuOpen, setMenuOpen] = useState(!1), dragControls = useDragControls(), dragged = useRef(!1), t2;
|
|
1700
|
+
$[2] === theme.title ? t2 = $[3] : (t2 = displayTitle(theme.title), $[2] = theme.title, $[3] = t2);
|
|
1701
|
+
let title = t2, t3;
|
|
1702
|
+
$[4] === theme.slug ? t3 = $[5] : (t3 = (candidate) => candidate.slug === theme.slug, $[4] = theme.slug, $[5] = t3);
|
|
1703
|
+
let index = themes.findIndex(t3), listed = index !== -1, t4;
|
|
1704
|
+
$[6] !== actorRef || $[7] !== index || $[8] !== themes ? (t4 = (to) => {
|
|
1705
|
+
let order = themes.map(_temp$3);
|
|
1706
|
+
order.splice(to, 0, ...order.splice(index, 1)), actorRef.send({
|
|
1407
1707
|
type: "theme.reorder",
|
|
1408
1708
|
order
|
|
1409
1709
|
});
|
|
1410
|
-
}, $[
|
|
1411
|
-
let moveTo =
|
|
1412
|
-
$[
|
|
1710
|
+
}, $[6] = actorRef, $[7] = index, $[8] = themes, $[9] = t4) : t4 = $[9];
|
|
1711
|
+
let moveTo = t4, t5, t6;
|
|
1712
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t5 = () => {
|
|
1413
1713
|
requestAnimationFrame(() => {
|
|
1414
1714
|
dragged.current = !1;
|
|
1415
1715
|
});
|
|
1416
|
-
},
|
|
1716
|
+
}, t6 = () => {
|
|
1417
1717
|
dragged.current = !0;
|
|
1418
|
-
}, $[
|
|
1419
|
-
let
|
|
1420
|
-
$[
|
|
1421
|
-
let
|
|
1422
|
-
$[
|
|
1423
|
-
dragged.current || send({
|
|
1718
|
+
}, $[10] = t5, $[11] = t6) : (t5 = $[10], t6 = $[11]);
|
|
1719
|
+
let t7 = active ? scrollRefIntoViewIfNeeded : void 0, t8;
|
|
1720
|
+
$[12] === Symbol.for("react.memo_cache_sentinel") ? (t8 = { scale: 1.04 }, $[12] = t8) : t8 = $[12];
|
|
1721
|
+
let t9;
|
|
1722
|
+
$[13] !== actorRef || $[14] !== theme.slug ? (t9 = () => {
|
|
1723
|
+
dragged.current || actorRef.send({
|
|
1424
1724
|
type: "theme.pick",
|
|
1425
1725
|
slug: theme.slug
|
|
1426
1726
|
});
|
|
1427
|
-
}, $[
|
|
1428
|
-
let
|
|
1429
|
-
$[
|
|
1430
|
-
event.pointerType !== "touch" && dragControls.start(event);
|
|
1431
|
-
}, $[
|
|
1432
|
-
let
|
|
1433
|
-
$[
|
|
1727
|
+
}, $[13] = actorRef, $[14] = theme.slug, $[15] = t9) : t9 = $[15];
|
|
1728
|
+
let t10;
|
|
1729
|
+
$[16] !== dragControls || $[17] !== listed ? (t10 = (event) => {
|
|
1730
|
+
listed && event.pointerType !== "touch" && dragControls.start(event);
|
|
1731
|
+
}, $[16] = dragControls, $[17] = listed, $[18] = t10) : t10 = $[18];
|
|
1732
|
+
let t11;
|
|
1733
|
+
$[19] === theme.options ? t11 = $[20] : (t11 = /* @__PURE__ */ jsx("span", {
|
|
1434
1734
|
className: frame$1,
|
|
1435
1735
|
children: /* @__PURE__ */ jsx(ThemeThumbnail, { options: theme.options })
|
|
1436
|
-
}), $[
|
|
1437
|
-
let
|
|
1438
|
-
$[
|
|
1736
|
+
}), $[19] = theme.options, $[20] = t11);
|
|
1737
|
+
let t12 = active ? "medium" : "regular", t13;
|
|
1738
|
+
$[21] !== t12 || $[22] !== title ? (t13 = /* @__PURE__ */ jsx(Box, {
|
|
1439
1739
|
as: "span",
|
|
1440
1740
|
display: "block",
|
|
1441
1741
|
paddingTop: 2,
|
|
@@ -1445,112 +1745,106 @@ function ThemeCard(props) {
|
|
|
1445
1745
|
as: "span",
|
|
1446
1746
|
size: 1,
|
|
1447
1747
|
textOverflow: "ellipsis",
|
|
1448
|
-
weight:
|
|
1748
|
+
weight: t12,
|
|
1449
1749
|
children: title
|
|
1450
1750
|
})
|
|
1451
|
-
}), $[
|
|
1452
|
-
let
|
|
1453
|
-
$[
|
|
1751
|
+
}), $[21] = t12, $[22] = title, $[23] = t13) : t13 = $[23];
|
|
1752
|
+
let t14;
|
|
1753
|
+
$[24] !== active || $[25] !== t10 || $[26] !== t11 || $[27] !== t13 || $[28] !== t9 ? (t14 = /* @__PURE__ */ jsxs("button", {
|
|
1454
1754
|
"aria-pressed": active,
|
|
1455
1755
|
className: pickButton,
|
|
1456
|
-
onClick:
|
|
1457
|
-
onPointerDown:
|
|
1756
|
+
onClick: t9,
|
|
1757
|
+
onPointerDown: t10,
|
|
1458
1758
|
type: "button",
|
|
1459
|
-
children: [
|
|
1460
|
-
}), $[
|
|
1461
|
-
let
|
|
1462
|
-
$[
|
|
1759
|
+
children: [t11, t13]
|
|
1760
|
+
}), $[24] = active, $[25] = t10, $[26] = t11, $[27] = t13, $[28] = t9, $[29] = t14) : t14 = $[29];
|
|
1761
|
+
let t15;
|
|
1762
|
+
$[30] === Symbol.for("react.memo_cache_sentinel") ? (t15 = /* @__PURE__ */ jsx(Text, {
|
|
1463
1763
|
size: 1,
|
|
1464
1764
|
children: "Show more"
|
|
1465
|
-
}), $[
|
|
1466
|
-
let
|
|
1467
|
-
$[
|
|
1468
|
-
"aria-label":
|
|
1765
|
+
}), $[30] = t15) : t15 = $[30];
|
|
1766
|
+
let t16 = `Show more for ${title}`, t17;
|
|
1767
|
+
$[31] === t16 ? t17 = $[32] : (t17 = /* @__PURE__ */ jsx(Button, {
|
|
1768
|
+
"aria-label": t16,
|
|
1469
1769
|
fontSize: 1,
|
|
1470
1770
|
icon: EllipsisHorizontalIcon,
|
|
1471
1771
|
mode: "ghost",
|
|
1472
1772
|
padding: 1,
|
|
1473
1773
|
radius: 2
|
|
1474
|
-
}), $[
|
|
1475
|
-
let
|
|
1476
|
-
$[
|
|
1477
|
-
|
|
1478
|
-
|
|
1479
|
-
|
|
1480
|
-
|
|
1481
|
-
|
|
1482
|
-
|
|
1483
|
-
|
|
1484
|
-
|
|
1485
|
-
|
|
1486
|
-
|
|
1487
|
-
|
|
1488
|
-
|
|
1489
|
-
|
|
1490
|
-
|
|
1491
|
-
|
|
1492
|
-
|
|
1493
|
-
let t23;
|
|
1494
|
-
$[42] === Symbol.for("react.memo_cache_sentinel") ? (t23 = /* @__PURE__ */ jsx(MenuDivider, {}), $[42] = t23) : t23 = $[42];
|
|
1495
|
-
let t24;
|
|
1496
|
-
$[43] !== send || $[44] !== theme.slug || $[45] !== theme.source ? (t24 = theme.source === "custom" && /* @__PURE__ */ jsx(MenuItem, {
|
|
1774
|
+
}), $[31] = t16, $[32] = t17);
|
|
1775
|
+
let t18 = `themer-theme-${theme.slug}`, t19;
|
|
1776
|
+
$[33] !== index || $[34] !== listed || $[35] !== moveTo || $[36] !== themes.length ? (t19 = listed && /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1777
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1778
|
+
disabled: index <= 0,
|
|
1779
|
+
icon: ArrowUpIcon,
|
|
1780
|
+
onClick: () => moveTo(index - 1),
|
|
1781
|
+
text: "Move up"
|
|
1782
|
+
}),
|
|
1783
|
+
/* @__PURE__ */ jsx(MenuItem, {
|
|
1784
|
+
disabled: index >= themes.length - 1,
|
|
1785
|
+
icon: ArrowDownIcon,
|
|
1786
|
+
onClick: () => moveTo(index + 1),
|
|
1787
|
+
text: "Move down"
|
|
1788
|
+
}),
|
|
1789
|
+
/* @__PURE__ */ jsx(MenuDivider, {})
|
|
1790
|
+
] }), $[33] = index, $[34] = listed, $[35] = moveTo, $[36] = themes.length, $[37] = t19) : t19 = $[37];
|
|
1791
|
+
let t20;
|
|
1792
|
+
$[38] !== actorRef || $[39] !== theme.slug || $[40] !== theme.source ? (t20 = theme.source === "custom" && /* @__PURE__ */ jsx(MenuItem, {
|
|
1497
1793
|
icon: EditIcon,
|
|
1498
|
-
onClick: () => send({
|
|
1794
|
+
onClick: () => actorRef.send({
|
|
1499
1795
|
type: "theme.edit",
|
|
1500
1796
|
slug: theme.slug
|
|
1501
1797
|
}),
|
|
1502
1798
|
text: "Edit"
|
|
1503
|
-
}), $[
|
|
1504
|
-
let
|
|
1505
|
-
$[
|
|
1799
|
+
}), $[38] = actorRef, $[39] = theme.slug, $[40] = theme.source, $[41] = t20) : t20 = $[41];
|
|
1800
|
+
let t21;
|
|
1801
|
+
$[42] !== actorRef || $[43] !== theme.slug ? (t21 = () => actorRef.send({
|
|
1506
1802
|
type: "theme.duplicate",
|
|
1507
1803
|
slug: theme.slug
|
|
1508
|
-
}), $[
|
|
1509
|
-
let
|
|
1510
|
-
$[
|
|
1804
|
+
}), $[42] = actorRef, $[43] = theme.slug, $[44] = t21) : t21 = $[44];
|
|
1805
|
+
let t22 = theme.source === "custom" ? "Duplicate" : "Duplicate to edit", t23;
|
|
1806
|
+
$[45] !== t21 || $[46] !== t22 ? (t23 = /* @__PURE__ */ jsx(MenuItem, {
|
|
1511
1807
|
icon: CopyIcon,
|
|
1512
|
-
onClick:
|
|
1513
|
-
text:
|
|
1514
|
-
}), $[
|
|
1515
|
-
let
|
|
1516
|
-
$[
|
|
1808
|
+
onClick: t21,
|
|
1809
|
+
text: t22
|
|
1810
|
+
}), $[45] = t21, $[46] = t22, $[47] = t23) : t23 = $[47];
|
|
1811
|
+
let t24;
|
|
1812
|
+
$[48] !== copyTheme || $[49] !== theme ? (t24 = /* @__PURE__ */ jsx(MenuItem, {
|
|
1517
1813
|
icon: ShareIcon,
|
|
1518
1814
|
onClick: () => void copyTheme(theme),
|
|
1519
1815
|
text: "Copy to share"
|
|
1520
|
-
}), $[
|
|
1521
|
-
let
|
|
1522
|
-
$[
|
|
1816
|
+
}), $[48] = copyTheme, $[49] = theme, $[50] = t24) : t24 = $[50];
|
|
1817
|
+
let t25;
|
|
1818
|
+
$[51] !== actorRef || $[52] !== theme.slug || $[53] !== theme.source ? (t25 = theme.source !== "config" && /* @__PURE__ */ jsxs(Fragment, { children: [/* @__PURE__ */ jsx(MenuDivider, {}), /* @__PURE__ */ jsx(MenuItem, {
|
|
1523
1819
|
icon: TrashIcon,
|
|
1524
|
-
onClick: () => send({
|
|
1820
|
+
onClick: () => actorRef.send({
|
|
1525
1821
|
type: "theme.remove",
|
|
1526
1822
|
slug: theme.slug
|
|
1527
1823
|
}),
|
|
1528
1824
|
text: "Remove",
|
|
1529
1825
|
tone: "critical"
|
|
1530
|
-
})] }), $[
|
|
1531
|
-
let
|
|
1532
|
-
$[
|
|
1826
|
+
})] }), $[51] = actorRef, $[52] = theme.slug, $[53] = theme.source, $[54] = t25) : t25 = $[54];
|
|
1827
|
+
let t26;
|
|
1828
|
+
$[55] !== t19 || $[56] !== t20 || $[57] !== t23 || $[58] !== t24 || $[59] !== t25 ? (t26 = /* @__PURE__ */ jsxs(Menu, { children: [
|
|
1533
1829
|
t19,
|
|
1534
|
-
|
|
1830
|
+
t20,
|
|
1535
1831
|
t23,
|
|
1536
1832
|
t24,
|
|
1537
|
-
|
|
1538
|
-
|
|
1539
|
-
|
|
1540
|
-
]
|
|
1541
|
-
let
|
|
1542
|
-
$[
|
|
1543
|
-
let t33;
|
|
1544
|
-
$[69] === scheme ? t33 = $[70] : (t33 = {
|
|
1833
|
+
t25
|
|
1834
|
+
] }), $[55] = t19, $[56] = t20, $[57] = t23, $[58] = t24, $[59] = t25, $[60] = t26) : t26 = $[60];
|
|
1835
|
+
let t27, t28;
|
|
1836
|
+
$[61] === Symbol.for("react.memo_cache_sentinel") ? (t27 = () => setMenuOpen(!1), t28 = () => setMenuOpen(!0), $[61] = t27, $[62] = t28) : (t27 = $[61], t28 = $[62]);
|
|
1837
|
+
let t29;
|
|
1838
|
+
$[63] === scheme ? t29 = $[64] : (t29 = {
|
|
1545
1839
|
animate: !0,
|
|
1546
1840
|
placement: "bottom-end",
|
|
1547
1841
|
portal: !0,
|
|
1548
1842
|
scheme
|
|
1549
|
-
}, $[
|
|
1550
|
-
let
|
|
1551
|
-
$[
|
|
1843
|
+
}, $[63] = scheme, $[64] = t29);
|
|
1844
|
+
let t30;
|
|
1845
|
+
$[65] !== t17 || $[66] !== t18 || $[67] !== t26 || $[68] !== t29 ? (t30 = /* @__PURE__ */ jsx(Tooltip, {
|
|
1552
1846
|
animate: !0,
|
|
1553
|
-
content:
|
|
1847
|
+
content: t15,
|
|
1554
1848
|
placement: "bottom",
|
|
1555
1849
|
portal: !0,
|
|
1556
1850
|
children: /* @__PURE__ */ jsx(Card, {
|
|
@@ -1558,44 +1852,40 @@ function ThemeCard(props) {
|
|
|
1558
1852
|
radius: 2,
|
|
1559
1853
|
scheme: "dark",
|
|
1560
1854
|
children: /* @__PURE__ */ jsx(MenuButton, {
|
|
1561
|
-
button:
|
|
1562
|
-
id:
|
|
1563
|
-
menu:
|
|
1564
|
-
onClose:
|
|
1565
|
-
onOpen:
|
|
1566
|
-
popover:
|
|
1855
|
+
button: t17,
|
|
1856
|
+
id: t18,
|
|
1857
|
+
menu: t26,
|
|
1858
|
+
onClose: t27,
|
|
1859
|
+
onOpen: t28,
|
|
1860
|
+
popover: t29
|
|
1567
1861
|
})
|
|
1568
1862
|
})
|
|
1569
|
-
}), $[
|
|
1570
|
-
let
|
|
1571
|
-
$[
|
|
1863
|
+
}), $[65] = t17, $[66] = t18, $[67] = t26, $[68] = t29, $[69] = t30) : t30 = $[69];
|
|
1864
|
+
let t31;
|
|
1865
|
+
$[70] !== menuOpen || $[71] !== t30 ? (t31 = /* @__PURE__ */ jsx("div", {
|
|
1572
1866
|
className: menuSlot,
|
|
1573
1867
|
"data-visible": menuOpen,
|
|
1574
|
-
children:
|
|
1575
|
-
}), $[
|
|
1576
|
-
let
|
|
1577
|
-
return $[
|
|
1868
|
+
children: t30
|
|
1869
|
+
}), $[70] = menuOpen, $[71] = t30, $[72] = t31) : t31 = $[72];
|
|
1870
|
+
let t32;
|
|
1871
|
+
return $[73] !== dragControls || $[74] !== t14 || $[75] !== t31 || $[76] !== t7 || $[77] !== theme.slug ? (t32 = /* @__PURE__ */ jsxs(Reorder.Item, {
|
|
1578
1872
|
as: "div",
|
|
1579
1873
|
className: root,
|
|
1580
1874
|
dragControls,
|
|
1581
1875
|
dragListener: !1,
|
|
1582
|
-
onDragEnd:
|
|
1583
|
-
onDragStart:
|
|
1584
|
-
ref:
|
|
1876
|
+
onDragEnd: t5,
|
|
1877
|
+
onDragStart: t6,
|
|
1878
|
+
ref: t7,
|
|
1585
1879
|
value: theme.slug,
|
|
1586
|
-
whileDrag:
|
|
1587
|
-
children: [
|
|
1588
|
-
}), $[
|
|
1880
|
+
whileDrag: t8,
|
|
1881
|
+
children: [t14, t31]
|
|
1882
|
+
}), $[73] = dragControls, $[74] = t14, $[75] = t31, $[76] = t7, $[77] = theme.slug, $[78] = t32) : t32 = $[78], t32;
|
|
1589
1883
|
}
|
|
1590
|
-
function _temp$
|
|
1884
|
+
function _temp$3(candidate_0) {
|
|
1591
1885
|
return candidate_0.slug;
|
|
1592
1886
|
}
|
|
1593
1887
|
var cardGrid = "twjqgh0";
|
|
1594
1888
|
/**
|
|
1595
|
-
* One column at the sidebar's default width; wider sidebars — and the
|
|
1596
|
-
* overlay on small screens — fit more cards per row
|
|
1597
|
-
*/
|
|
1598
|
-
/**
|
|
1599
1889
|
* The flow for picking a theme: a grid of theme cards — the configured theme,
|
|
1600
1890
|
* the presets and the user's own themes — that drag into the order the user
|
|
1601
1891
|
* wants, with the entry points to the add and restore flows below. A theme
|
|
@@ -1603,115 +1893,151 @@ var cardGrid = "twjqgh0";
|
|
|
1603
1893
|
*
|
|
1604
1894
|
* @internal
|
|
1605
1895
|
*/
|
|
1606
|
-
function ThemeList() {
|
|
1607
|
-
let $ = c(
|
|
1608
|
-
|
|
1609
|
-
let
|
|
1610
|
-
$[
|
|
1896
|
+
function ThemeList(t0) {
|
|
1897
|
+
let $ = c(48), { actorRef, themes, removed, active } = t0, t1;
|
|
1898
|
+
$[0] === actorRef ? t1 = $[1] : (t1 = { actorRef }, $[0] = actorRef, $[1] = t1);
|
|
1899
|
+
let { addThemeFromClipboard } = useThemeCodes(t1), [pasting, setPasting] = useState(!1), t2;
|
|
1900
|
+
$[2] === actorRef ? t2 = $[3] : (t2 = { actorRef }, $[2] = actorRef, $[3] = t2), usePasteThemeCodes(t2);
|
|
1901
|
+
let t3;
|
|
1902
|
+
$[4] === actorRef ? t3 = $[5] : (t3 = (palette, file) => actorRef.send({
|
|
1611
1903
|
type: "theme.add",
|
|
1612
1904
|
title: titleFromFileName(file.name),
|
|
1613
1905
|
options: optionsFromImagePalette(palette),
|
|
1614
1906
|
palette,
|
|
1615
1907
|
imageUrl: URL.createObjectURL(file)
|
|
1616
|
-
}), $[
|
|
1617
|
-
let { busy, pickImage } = useImagePalette(
|
|
1618
|
-
$[
|
|
1908
|
+
}), $[4] = actorRef, $[5] = t3);
|
|
1909
|
+
let { busy, pickImage } = useImagePalette(t3), t4;
|
|
1910
|
+
$[6] === actorRef ? t4 = $[7] : (t4 = (order) => actorRef.send({
|
|
1619
1911
|
type: "theme.reorder",
|
|
1620
1912
|
order
|
|
1621
|
-
}), $[
|
|
1622
|
-
let
|
|
1623
|
-
$[
|
|
1624
|
-
let
|
|
1625
|
-
|
|
1626
|
-
|
|
1627
|
-
|
|
1628
|
-
|
|
1629
|
-
|
|
1630
|
-
|
|
1631
|
-
|
|
1632
|
-
|
|
1633
|
-
|
|
1913
|
+
}), $[6] = actorRef, $[7] = t4);
|
|
1914
|
+
let t5;
|
|
1915
|
+
$[8] === themes ? t5 = $[9] : (t5 = themes.map(_temp$2), $[8] = themes, $[9] = t5);
|
|
1916
|
+
let t6 = !active, t7;
|
|
1917
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t7 = {
|
|
1918
|
+
slug: CONFIG_SLUG,
|
|
1919
|
+
title: CONFIG_TITLE,
|
|
1920
|
+
options: {},
|
|
1921
|
+
source: "config"
|
|
1922
|
+
}, $[10] = t7) : t7 = $[10];
|
|
1923
|
+
let t8;
|
|
1924
|
+
$[11] !== actorRef || $[12] !== t6 || $[13] !== themes ? (t8 = /* @__PURE__ */ jsx(ThemeCard, {
|
|
1925
|
+
actorRef,
|
|
1926
|
+
active: t6,
|
|
1927
|
+
theme: t7,
|
|
1928
|
+
themes
|
|
1929
|
+
}), $[11] = actorRef, $[12] = t6, $[13] = themes, $[14] = t8) : t8 = $[14];
|
|
1930
|
+
let t9;
|
|
1931
|
+
$[15] !== active?.slug || $[16] !== actorRef || $[17] !== themes ? (t9 = themes.map((theme_0) => /* @__PURE__ */ jsx(ThemeCard, {
|
|
1932
|
+
actorRef,
|
|
1933
|
+
active: theme_0.slug === active?.slug,
|
|
1934
|
+
theme: theme_0,
|
|
1935
|
+
themes
|
|
1936
|
+
}, theme_0.slug)), $[15] = active?.slug, $[16] = actorRef, $[17] = themes, $[18] = t9) : t9 = $[18];
|
|
1937
|
+
let t10;
|
|
1938
|
+
$[19] !== t4 || $[20] !== t5 || $[21] !== t8 || $[22] !== t9 ? (t10 = /* @__PURE__ */ jsx(MotionConfig, {
|
|
1634
1939
|
reducedMotion: "user",
|
|
1635
|
-
children: /* @__PURE__ */
|
|
1940
|
+
children: /* @__PURE__ */ jsxs(Reorder.Group, {
|
|
1636
1941
|
as: "div",
|
|
1637
1942
|
className: cardGrid,
|
|
1638
|
-
onReorder:
|
|
1639
|
-
values:
|
|
1640
|
-
children:
|
|
1943
|
+
onReorder: t4,
|
|
1944
|
+
values: t5,
|
|
1945
|
+
children: [t8, t9]
|
|
1641
1946
|
})
|
|
1642
|
-
}), $[
|
|
1643
|
-
let
|
|
1644
|
-
$[
|
|
1947
|
+
}), $[19] = t4, $[20] = t5, $[21] = t8, $[22] = t9, $[23] = t10) : t10 = $[23];
|
|
1948
|
+
let t11;
|
|
1949
|
+
$[24] !== actorRef || $[25] !== removed.length ? (t11 = removed.length > 0 && /* @__PURE__ */ jsx(Button, {
|
|
1645
1950
|
gap: 2,
|
|
1646
1951
|
icon: RestoreIcon,
|
|
1647
1952
|
mode: "bleed",
|
|
1648
|
-
onClick: () => send({ type: "flow.removed" }),
|
|
1953
|
+
onClick: () => actorRef.send({ type: "flow.removed" }),
|
|
1649
1954
|
padding: 2,
|
|
1650
1955
|
text: `Show removed (${removed.length})`,
|
|
1651
1956
|
width: "fill"
|
|
1652
|
-
}), $[
|
|
1653
|
-
let
|
|
1654
|
-
$[
|
|
1957
|
+
}), $[24] = actorRef, $[25] = removed.length, $[26] = t11) : t11 = $[26];
|
|
1958
|
+
let t12;
|
|
1959
|
+
$[27] !== t10 || $[28] !== t11 ? (t12 = /* @__PURE__ */ jsx(ScrollArea, {
|
|
1655
1960
|
padding: 3,
|
|
1656
1961
|
children: /* @__PURE__ */ jsxs(Stack, {
|
|
1657
1962
|
gap: 4,
|
|
1658
|
-
children: [
|
|
1963
|
+
children: [t10, t11]
|
|
1659
1964
|
})
|
|
1660
|
-
}), $[
|
|
1661
|
-
let
|
|
1662
|
-
$[
|
|
1965
|
+
}), $[27] = t10, $[28] = t11, $[29] = t12) : t12 = $[29];
|
|
1966
|
+
let t13;
|
|
1967
|
+
$[30] === actorRef ? t13 = $[31] : (t13 = /* @__PURE__ */ jsx(Box, {
|
|
1663
1968
|
flex: 1,
|
|
1664
1969
|
children: /* @__PURE__ */ jsx(TooltipButton, {
|
|
1665
1970
|
icon: AddIcon,
|
|
1666
1971
|
mode: "ghost",
|
|
1667
|
-
onClick: () => send({ type: "theme.add" }),
|
|
1972
|
+
onClick: () => actorRef.send({ type: "theme.add" }),
|
|
1668
1973
|
text: "Add theme",
|
|
1669
1974
|
tooltip: "Add a theme based on the applied one",
|
|
1670
1975
|
width: "fill"
|
|
1671
1976
|
})
|
|
1672
|
-
}), $[
|
|
1673
|
-
let
|
|
1674
|
-
$[
|
|
1977
|
+
}), $[30] = actorRef, $[31] = t13);
|
|
1978
|
+
let t14;
|
|
1979
|
+
$[32] !== busy || $[33] !== pickImage ? (t14 = /* @__PURE__ */ jsx(ImageFileButton, {
|
|
1675
1980
|
loading: busy,
|
|
1676
1981
|
mode: "ghost",
|
|
1677
1982
|
onFile: pickImage,
|
|
1678
1983
|
tooltip: "Add a theme from the colors of an image"
|
|
1679
|
-
}), $[
|
|
1680
|
-
let
|
|
1681
|
-
$[
|
|
1984
|
+
}), $[32] = busy, $[33] = pickImage, $[34] = t14) : t14 = $[34];
|
|
1985
|
+
let t15;
|
|
1986
|
+
$[35] === addThemeFromClipboard ? t15 = $[36] : (t15 = /* @__PURE__ */ jsx(TooltipButton, {
|
|
1682
1987
|
icon: ClipboardIcon,
|
|
1683
1988
|
mode: "ghost",
|
|
1684
1989
|
onClick: async () => {
|
|
1685
1990
|
await addThemeFromClipboard() !== "added" && setPasting(!0);
|
|
1686
1991
|
},
|
|
1687
1992
|
tooltip: "Add a theme from a code someone shared"
|
|
1688
|
-
}), $[
|
|
1689
|
-
let
|
|
1690
|
-
$[
|
|
1993
|
+
}), $[35] = addThemeFromClipboard, $[36] = t15);
|
|
1994
|
+
let t16;
|
|
1995
|
+
$[37] !== t13 || $[38] !== t14 || $[39] !== t15 ? (t16 = /* @__PURE__ */ jsx(Card, {
|
|
1691
1996
|
borderTop: !0,
|
|
1692
1997
|
padding: 3,
|
|
1693
1998
|
children: /* @__PURE__ */ jsxs(Flex, {
|
|
1694
1999
|
gap: 2,
|
|
1695
2000
|
children: [
|
|
1696
|
-
|
|
1697
|
-
|
|
1698
|
-
|
|
2001
|
+
t13,
|
|
2002
|
+
t14,
|
|
2003
|
+
t15
|
|
1699
2004
|
]
|
|
1700
2005
|
})
|
|
1701
|
-
}), $[
|
|
1702
|
-
let
|
|
1703
|
-
$[
|
|
1704
|
-
|
|
1705
|
-
|
|
1706
|
-
|
|
1707
|
-
|
|
1708
|
-
|
|
1709
|
-
|
|
2006
|
+
}), $[37] = t13, $[38] = t14, $[39] = t15, $[40] = t16) : t16 = $[40];
|
|
2007
|
+
let t17;
|
|
2008
|
+
$[41] !== actorRef || $[42] !== pasting ? (t17 = pasting && /* @__PURE__ */ jsx(PasteThemeDialog, {
|
|
2009
|
+
actorRef,
|
|
2010
|
+
onClose: () => setPasting(!1)
|
|
2011
|
+
}), $[41] = actorRef, $[42] = pasting, $[43] = t17) : t17 = $[43];
|
|
2012
|
+
let t18;
|
|
2013
|
+
return $[44] !== t12 || $[45] !== t16 || $[46] !== t17 ? (t18 = /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
2014
|
+
t12,
|
|
2015
|
+
t16,
|
|
2016
|
+
t17
|
|
2017
|
+
] }), $[44] = t12, $[45] = t16, $[46] = t17, $[47] = t18) : t18 = $[47], t18;
|
|
1710
2018
|
}
|
|
1711
|
-
function _temp(theme) {
|
|
2019
|
+
function _temp$2(theme) {
|
|
1712
2020
|
return theme.slug;
|
|
1713
2021
|
}
|
|
1714
2022
|
/**
|
|
2023
|
+
* Reduces theme options to the minimal object that recreates them through
|
|
2024
|
+
* `buildTheme`: in each scheme the accent is dropped when it is the stock
|
|
2025
|
+
* one, the text color when it matches the one derived from the accent, and
|
|
2026
|
+
* the background and contrast when they match the defaults — and a scheme
|
|
2027
|
+
* with nothing left is dropped altogether. Options that boil down to the
|
|
2028
|
+
* stock Studio theme reduce to `null` — they need nothing from this package.
|
|
2029
|
+
*
|
|
2030
|
+
* @internal
|
|
2031
|
+
*/
|
|
2032
|
+
function minimizeOptions(options) {
|
|
2033
|
+
let resolved = resolveThemeOptions(options), minimized = {};
|
|
2034
|
+
for (let scheme of SCHEMES) {
|
|
2035
|
+
let values = resolved[scheme], kept = {};
|
|
2036
|
+
values.accent !== DEFAULT_ACCENT && (kept.accent = values.accent), values.text !== deriveTextColor(values.accent) && (kept.text = values.text), values.background !== DEFAULT_BACKGROUND[scheme] && (kept.background = values.background), values.contrast !== 85 && (kept.contrast = values.contrast), Object.keys(kept).length > 0 && (minimized[scheme] = kept);
|
|
2037
|
+
}
|
|
2038
|
+
return Object.keys(minimized).length === 0 ? null : minimized;
|
|
2039
|
+
}
|
|
2040
|
+
/**
|
|
1715
2041
|
* Serializes theme options into the `buildTheme` call to paste into
|
|
1716
2042
|
* `sanity.config.ts`, keeping only what differs from the derived defaults in
|
|
1717
2043
|
* each scheme.
|
|
@@ -1834,6 +2160,9 @@ function ThemeSnippetDialog(props) {
|
|
|
1834
2160
|
children: t9
|
|
1835
2161
|
}), $[19] = onClose, $[20] = t2, $[21] = t9, $[22] = t10) : t10 = $[22], t10;
|
|
1836
2162
|
}
|
|
2163
|
+
function useIsTooSmallForSplitScreen() {
|
|
2164
|
+
return useMediaIndex() <= 3;
|
|
2165
|
+
}
|
|
1837
2166
|
var title = "c2pqej0";
|
|
1838
2167
|
const VIEW_TITLES = {
|
|
1839
2168
|
list: "Themer",
|
|
@@ -1848,105 +2177,148 @@ const VIEW_TITLES = {
|
|
|
1848
2177
|
*
|
|
1849
2178
|
* @internal
|
|
1850
2179
|
*/
|
|
1851
|
-
function ThemerSidebar() {
|
|
1852
|
-
let $ = c(
|
|
1853
|
-
$[0] === navbarHeight ?
|
|
1854
|
-
let
|
|
1855
|
-
$[2] !==
|
|
2180
|
+
function ThemerSidebar(t0) {
|
|
2181
|
+
let $ = c(58), { actorRef, dispatch, navbarHeight, split } = t0, [snippetOpen, setSnippetOpen] = useState(!1), view = useSelector(actorRef, selectView, sameView), inList = view.name === "list", isTooSmallForSplitScreen = useIsTooSmallForSplitScreen(), { themes, removed, active } = useSelector(actorRef, _temp$1, dequal), t1;
|
|
2182
|
+
$[0] === navbarHeight ? t1 = $[1] : (t1 = navbarHeight === null ? void 0 : { height: navbarHeight }, $[0] = navbarHeight, $[1] = t1);
|
|
2183
|
+
let t2;
|
|
2184
|
+
$[2] !== actorRef || $[3] !== inList ? (t2 = !inList && /* @__PURE__ */ jsx(TooltipButton, {
|
|
1856
2185
|
icon: ArrowLeftIcon,
|
|
1857
2186
|
mode: "bleed",
|
|
1858
|
-
onClick: () => send({ type: "flow.list" }),
|
|
2187
|
+
onClick: () => actorRef.send({ type: "flow.list" }),
|
|
1859
2188
|
padding: 2,
|
|
1860
2189
|
tooltip: "Back to the themes"
|
|
1861
|
-
}), $[2] =
|
|
1862
|
-
let
|
|
1863
|
-
$[5] ===
|
|
2190
|
+
}), $[2] = actorRef, $[3] = inList, $[4] = t2) : t2 = $[4];
|
|
2191
|
+
let t3 = VIEW_TITLES[view.name], t4;
|
|
2192
|
+
$[5] === t3 ? t4 = $[6] : (t4 = /* @__PURE__ */ jsx(Box, {
|
|
1864
2193
|
className: title,
|
|
1865
2194
|
flex: 1,
|
|
1866
2195
|
children: /* @__PURE__ */ jsx(Text, {
|
|
1867
2196
|
size: 1,
|
|
1868
2197
|
textOverflow: "ellipsis",
|
|
1869
2198
|
weight: "semibold",
|
|
1870
|
-
children:
|
|
2199
|
+
children: t3
|
|
1871
2200
|
})
|
|
1872
|
-
}), $[5] =
|
|
1873
|
-
let
|
|
1874
|
-
$[7] !==
|
|
2201
|
+
}), $[5] = t3, $[6] = t4);
|
|
2202
|
+
let t5;
|
|
2203
|
+
$[7] !== active || $[8] !== dispatch || $[9] !== isTooSmallForSplitScreen || $[10] !== split || $[11] !== view.name ? (t5 = view.name !== "removed" && /* @__PURE__ */ jsxs(Fragment, { children: [!isTooSmallForSplitScreen && /* @__PURE__ */ jsx(TooltipButton, {
|
|
1875
2204
|
"aria-pressed": split,
|
|
1876
2205
|
icon: SplitVerticalIcon,
|
|
1877
2206
|
mode: "bleed",
|
|
1878
|
-
onClick: () =>
|
|
2207
|
+
onClick: () => startTransition(() => {
|
|
2208
|
+
let type = split ? "split-screen:close" : "split-screen:open";
|
|
2209
|
+
addThemerTransitionType(type), dispatch({ type });
|
|
2210
|
+
}),
|
|
2211
|
+
onMouseEnter: () => startTransition(() => {
|
|
2212
|
+
dispatch({ type: "split-screen:prerender" });
|
|
2213
|
+
}),
|
|
1879
2214
|
padding: 2,
|
|
1880
2215
|
selected: split,
|
|
1881
2216
|
tooltip: "Show light and dark side by side"
|
|
1882
|
-
}), /* @__PURE__ */ jsx(TooltipButton, {
|
|
2217
|
+
}), active && /* @__PURE__ */ jsx(TooltipButton, {
|
|
1883
2218
|
icon: CodeBlockIcon,
|
|
1884
2219
|
mode: "bleed",
|
|
1885
2220
|
onClick: () => setSnippetOpen(!0),
|
|
1886
2221
|
padding: 2,
|
|
1887
2222
|
tooltip: "Show the code for the applied theme"
|
|
1888
|
-
})] }), $[7] =
|
|
1889
|
-
let
|
|
1890
|
-
$[
|
|
2223
|
+
})] }), $[7] = active, $[8] = dispatch, $[9] = isTooSmallForSplitScreen, $[10] = split, $[11] = view.name, $[12] = t5) : t5 = $[12];
|
|
2224
|
+
let t6;
|
|
2225
|
+
$[13] !== dispatch || $[14] !== split ? (t6 = /* @__PURE__ */ jsx(TooltipButton, {
|
|
1891
2226
|
icon: CloseIcon,
|
|
1892
2227
|
mode: "bleed",
|
|
1893
|
-
onClick: () =>
|
|
2228
|
+
onClick: () => startTransition(() => {
|
|
2229
|
+
split && addThemerTransitionType("split-screen:close"), addThemerTransitionType("close"), dispatch({ type: "close" });
|
|
2230
|
+
}),
|
|
1894
2231
|
padding: 2,
|
|
1895
2232
|
tooltip: "Close themer"
|
|
1896
|
-
}), $[
|
|
1897
|
-
let t6;
|
|
1898
|
-
$[13] !== t4 || $[14] !== t5 ? (t6 = /* @__PURE__ */ jsxs(Flex, { children: [t4, t5] }), $[13] = t4, $[14] = t5, $[15] = t6) : t6 = $[15];
|
|
2233
|
+
}), $[13] = dispatch, $[14] = split, $[15] = t6) : t6 = $[15];
|
|
1899
2234
|
let t7;
|
|
1900
|
-
$[16] !==
|
|
2235
|
+
$[16] !== t5 || $[17] !== t6 ? (t7 = /* @__PURE__ */ jsxs(Flex, { children: [t5, t6] }), $[16] = t5, $[17] = t6, $[18] = t7) : t7 = $[18];
|
|
2236
|
+
let t8;
|
|
2237
|
+
$[19] !== t2 || $[20] !== t4 || $[21] !== t7 ? (t8 = /* @__PURE__ */ jsxs(Flex, {
|
|
1901
2238
|
align: "center",
|
|
1902
2239
|
gap: 1,
|
|
1903
2240
|
height: "fill",
|
|
1904
2241
|
children: [
|
|
1905
|
-
|
|
1906
|
-
|
|
1907
|
-
|
|
2242
|
+
t2,
|
|
2243
|
+
t4,
|
|
2244
|
+
t7
|
|
1908
2245
|
]
|
|
1909
|
-
}), $[
|
|
1910
|
-
let
|
|
1911
|
-
$[
|
|
2246
|
+
}), $[19] = t2, $[20] = t4, $[21] = t7, $[22] = t8) : t8 = $[22];
|
|
2247
|
+
let t9;
|
|
2248
|
+
$[23] !== t1 || $[24] !== t8 ? (t9 = /* @__PURE__ */ jsx(Card, {
|
|
1912
2249
|
borderBottom: !0,
|
|
1913
2250
|
padding: 3,
|
|
1914
2251
|
sizing: "border",
|
|
1915
|
-
style:
|
|
1916
|
-
children:
|
|
1917
|
-
}), $[
|
|
1918
|
-
let
|
|
1919
|
-
$[
|
|
1920
|
-
|
|
1921
|
-
|
|
1922
|
-
|
|
1923
|
-
|
|
1924
|
-
}), $[
|
|
1925
|
-
let t11;
|
|
1926
|
-
$[29] === view.name ? t11 = $[30] : (t11 = view.name === "removed" && /* @__PURE__ */ jsx(RemovedThemes, {}), $[29] = view.name, $[30] = t11);
|
|
2252
|
+
style: t1,
|
|
2253
|
+
children: t8
|
|
2254
|
+
}), $[23] = t1, $[24] = t8, $[25] = t9) : t9 = $[25];
|
|
2255
|
+
let t10 = view.name === "list" ? "visible" : "hidden", t11;
|
|
2256
|
+
$[26] !== active || $[27] !== actorRef || $[28] !== removed || $[29] !== themes ? (t11 = /* @__PURE__ */ jsx(ThemeList, {
|
|
2257
|
+
actorRef,
|
|
2258
|
+
active,
|
|
2259
|
+
removed,
|
|
2260
|
+
themes
|
|
2261
|
+
}), $[26] = active, $[27] = actorRef, $[28] = removed, $[29] = themes, $[30] = t11) : t11 = $[30];
|
|
1927
2262
|
let t12;
|
|
1928
|
-
$[31] !== t10 || $[32] !== t11
|
|
2263
|
+
$[31] !== t10 || $[32] !== t11 ? (t12 = /* @__PURE__ */ jsx(Activity, {
|
|
2264
|
+
mode: t10,
|
|
2265
|
+
children: t11
|
|
2266
|
+
}, "list"), $[31] = t10, $[32] = t11, $[33] = t12) : t12 = $[33];
|
|
2267
|
+
let t13;
|
|
2268
|
+
$[34] !== actorRef || $[35] !== split || $[36] !== themes || $[37] !== view.focusTitle || $[38] !== view.name || $[39] !== view.slug ? (t13 = view.name === "edit" && /* @__PURE__ */ jsx(ThemeEditor, {
|
|
2269
|
+
actorRef,
|
|
2270
|
+
focusTitle: view.focusTitle,
|
|
2271
|
+
slug: view.slug,
|
|
2272
|
+
split,
|
|
2273
|
+
themes
|
|
2274
|
+
}), $[34] = actorRef, $[35] = split, $[36] = themes, $[37] = view.focusTitle, $[38] = view.name, $[39] = view.slug, $[40] = t13) : t13 = $[40];
|
|
2275
|
+
let t14 = view.name === "removed" ? "visible" : "hidden", t15;
|
|
2276
|
+
$[41] !== actorRef || $[42] !== removed ? (t15 = /* @__PURE__ */ jsx(RemovedThemes, {
|
|
2277
|
+
actorRef,
|
|
2278
|
+
removed
|
|
2279
|
+
}), $[41] = actorRef, $[42] = removed, $[43] = t15) : t15 = $[43];
|
|
2280
|
+
let t16;
|
|
2281
|
+
$[44] !== t14 || $[45] !== t15 ? (t16 = /* @__PURE__ */ jsx(Activity, {
|
|
2282
|
+
mode: t14,
|
|
2283
|
+
children: t15
|
|
2284
|
+
}, "removed"), $[44] = t14, $[45] = t15, $[46] = t16) : t16 = $[46];
|
|
2285
|
+
let t17;
|
|
2286
|
+
$[47] !== t12 || $[48] !== t13 || $[49] !== t16 || $[50] !== t9 ? (t17 = /* @__PURE__ */ jsxs(Flex, {
|
|
1929
2287
|
direction: "column",
|
|
1930
2288
|
height: "fill",
|
|
1931
2289
|
children: [
|
|
1932
|
-
t8,
|
|
1933
2290
|
t9,
|
|
1934
|
-
|
|
1935
|
-
|
|
2291
|
+
t12,
|
|
2292
|
+
t13,
|
|
2293
|
+
t16
|
|
1936
2294
|
]
|
|
1937
|
-
}), $[
|
|
1938
|
-
let
|
|
1939
|
-
$[
|
|
2295
|
+
}), $[47] = t12, $[48] = t13, $[49] = t16, $[50] = t9, $[51] = t17) : t17 = $[51];
|
|
2296
|
+
let t18;
|
|
2297
|
+
$[52] !== active || $[53] !== snippetOpen ? (t18 = active && snippetOpen && /* @__PURE__ */ jsx(ThemeSnippetDialog, {
|
|
1940
2298
|
onClose: () => setSnippetOpen(!1),
|
|
1941
2299
|
theme: active
|
|
1942
|
-
}), $[
|
|
1943
|
-
let
|
|
1944
|
-
return $[
|
|
2300
|
+
}), $[52] = active, $[53] = snippetOpen, $[54] = t18) : t18 = $[54];
|
|
2301
|
+
let t19;
|
|
2302
|
+
return $[55] !== t17 || $[56] !== t18 ? (t19 = /* @__PURE__ */ jsxs(Card, {
|
|
1945
2303
|
height: "fill",
|
|
1946
|
-
children: [
|
|
1947
|
-
}), $[
|
|
2304
|
+
children: [t17, t18]
|
|
2305
|
+
}), $[55] = t17, $[56] = t18, $[57] = t19) : t19 = $[57], t19;
|
|
1948
2306
|
}
|
|
1949
|
-
|
|
2307
|
+
function _temp$1(snapshot) {
|
|
2308
|
+
return resolveThemes(snapshot.context);
|
|
2309
|
+
}
|
|
2310
|
+
function selectView(snapshot) {
|
|
2311
|
+
let { editing } = snapshot.context;
|
|
2312
|
+
return snapshot.matches({ flow: "edit" }) && editing ? {
|
|
2313
|
+
name: "edit",
|
|
2314
|
+
slug: editing.slug,
|
|
2315
|
+
focusTitle: editing.focusTitle
|
|
2316
|
+
} : snapshot.matches({ flow: "removed" }) ? { name: "removed" } : { name: "list" };
|
|
2317
|
+
}
|
|
2318
|
+
function sameView(a, b) {
|
|
2319
|
+
return a.name === b.name ? a.name !== "edit" || b.name !== "edit" || a.slug === b.slug && a.focusTitle === b.focusTitle : !1;
|
|
2320
|
+
}
|
|
2321
|
+
var content = "bgn4np3", frame = "bgn4np2", resizeHandle = "bgn4np4", sidebar = "bgn4np1";
|
|
1950
2322
|
/** How far one arrow key press resizes the sidebar */
|
|
1951
2323
|
const WIDTH_STORAGE_KEY = "sanityStudio:themer:width";
|
|
1952
2324
|
function clampWidth(width) {
|
|
@@ -1973,27 +2345,27 @@ function writeStoredWidth(width) {
|
|
|
1973
2345
|
*
|
|
1974
2346
|
* @internal
|
|
1975
2347
|
*/
|
|
1976
|
-
function ResizableSidebar(
|
|
1977
|
-
let $ = c(
|
|
1978
|
-
$[0] === width ? (
|
|
1979
|
-
let
|
|
1980
|
-
$[3] === width ?
|
|
2348
|
+
function ResizableSidebar(t0) {
|
|
2349
|
+
let $ = c(30), { actorRef, dispatch, navbarHeight, split } = t0, [width, setWidth] = useState(readStoredWidth), [dragging, setDragging] = useState(!1), drag = useRef(null), t1, t2;
|
|
2350
|
+
$[0] === width ? (t1 = $[1], t2 = $[2]) : (t1 = () => writeStoredWidth(width), t2 = [width], $[0] = width, $[1] = t1, $[2] = t2), useEffect(t1, t2);
|
|
2351
|
+
let t3;
|
|
2352
|
+
$[3] === width ? t3 = $[4] : (t3 = (event) => {
|
|
1981
2353
|
event.button === 0 && (event.preventDefault(), event.currentTarget.setPointerCapture(event.pointerId), drag.current = {
|
|
1982
2354
|
pointerId: event.pointerId,
|
|
1983
2355
|
startX: event.clientX,
|
|
1984
2356
|
startWidth: width
|
|
1985
2357
|
}, setDragging(!0));
|
|
1986
|
-
}, $[3] = width, $[4] =
|
|
1987
|
-
let handlePointerDown =
|
|
1988
|
-
$[5] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
2358
|
+
}, $[3] = width, $[4] = t3);
|
|
2359
|
+
let handlePointerDown = t3, t4;
|
|
2360
|
+
$[5] === Symbol.for("react.memo_cache_sentinel") ? (t4 = (event_0) => {
|
|
1989
2361
|
drag.current && drag.current.pointerId === event_0.pointerId && setWidth(clampWidth(drag.current.startWidth - (event_0.clientX - drag.current.startX)));
|
|
1990
|
-
}, $[5] =
|
|
1991
|
-
let handlePointerMove =
|
|
1992
|
-
$[6] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
2362
|
+
}, $[5] = t4) : t4 = $[5];
|
|
2363
|
+
let handlePointerMove = t4, t5;
|
|
2364
|
+
$[6] === Symbol.for("react.memo_cache_sentinel") ? (t5 = (event_1) => {
|
|
1993
2365
|
drag.current && drag.current.pointerId === event_1.pointerId && (drag.current = null, setDragging(!1));
|
|
1994
|
-
}, $[6] =
|
|
1995
|
-
let handlePointerUp =
|
|
1996
|
-
$[7] === Symbol.for("react.memo_cache_sentinel") ? (
|
|
2366
|
+
}, $[6] = t5) : t5 = $[6];
|
|
2367
|
+
let handlePointerUp = t5, t6;
|
|
2368
|
+
$[7] === Symbol.for("react.memo_cache_sentinel") ? (t6 = (event_2) => {
|
|
1997
2369
|
let step = {
|
|
1998
2370
|
ArrowLeft: 16,
|
|
1999
2371
|
ArrowRight: -16,
|
|
@@ -2001,19 +2373,23 @@ function ResizableSidebar(props) {
|
|
|
2001
2373
|
End: -400
|
|
2002
2374
|
}[event_2.key];
|
|
2003
2375
|
step !== void 0 && (event_2.preventDefault(), setWidth((current) => clampWidth(current + step)));
|
|
2004
|
-
}, $[7] =
|
|
2005
|
-
let handleKeyDown =
|
|
2006
|
-
$[8]
|
|
2007
|
-
let
|
|
2008
|
-
$[
|
|
2376
|
+
}, $[7] = t6) : t6 = $[7];
|
|
2377
|
+
let handleKeyDown = t6, [boundaryElement, setBoundaryElement] = useState(null), t7;
|
|
2378
|
+
$[8] === width ? t7 = $[9] : (t7 = { width }, $[8] = width, $[9] = t7);
|
|
2379
|
+
let t8;
|
|
2380
|
+
$[10] === Symbol.for("react.memo_cache_sentinel") ? (t8 = (boundaryElement_0) => (startTransition(() => setBoundaryElement(boundaryElement_0)), _temp), $[10] = t8) : t8 = $[10];
|
|
2381
|
+
let t9;
|
|
2382
|
+
$[11] === Symbol.for("react.memo_cache_sentinel") ? (t9 = () => setWidth(200), $[11] = t9) : t9 = $[11];
|
|
2383
|
+
let t10;
|
|
2384
|
+
$[12] !== dragging || $[13] !== handlePointerDown || $[14] !== width ? (t10 = /* @__PURE__ */ jsx("div", {
|
|
2009
2385
|
"aria-label": "Resize the themer",
|
|
2010
|
-
className:
|
|
2386
|
+
className: resizeHandle,
|
|
2011
2387
|
"aria-orientation": "vertical",
|
|
2012
2388
|
"aria-valuemax": 400,
|
|
2013
2389
|
"aria-valuemin": 200,
|
|
2014
2390
|
"aria-valuenow": width,
|
|
2015
2391
|
"data-dragging": dragging,
|
|
2016
|
-
onDoubleClick:
|
|
2392
|
+
onDoubleClick: t9,
|
|
2017
2393
|
onKeyDown: handleKeyDown,
|
|
2018
2394
|
onPointerCancel: handlePointerUp,
|
|
2019
2395
|
onPointerDown: handlePointerDown,
|
|
@@ -2021,30 +2397,41 @@ function ResizableSidebar(props) {
|
|
|
2021
2397
|
onPointerUp: handlePointerUp,
|
|
2022
2398
|
role: "separator",
|
|
2023
2399
|
tabIndex: 0
|
|
2024
|
-
}), $[
|
|
2025
|
-
let
|
|
2026
|
-
$[16]
|
|
2400
|
+
}), $[12] = dragging, $[13] = handlePointerDown, $[14] = width, $[15] = t10) : t10 = $[15];
|
|
2401
|
+
let t11;
|
|
2402
|
+
$[16] !== actorRef || $[17] !== dispatch || $[18] !== navbarHeight || $[19] !== split ? (t11 = /* @__PURE__ */ jsx(ThemerSidebar, {
|
|
2403
|
+
split,
|
|
2404
|
+
navbarHeight,
|
|
2405
|
+
actorRef,
|
|
2406
|
+
dispatch
|
|
2407
|
+
}), $[16] = actorRef, $[17] = dispatch, $[18] = navbarHeight, $[19] = split, $[20] = t11) : t11 = $[20];
|
|
2408
|
+
let t12;
|
|
2409
|
+
$[21] !== boundaryElement || $[22] !== t11 ? (t12 = /* @__PURE__ */ jsx(Box, {
|
|
2027
2410
|
className: content,
|
|
2028
2411
|
height: "fill",
|
|
2029
2412
|
overflow: "hidden",
|
|
2030
|
-
children: /* @__PURE__ */ jsx(
|
|
2031
|
-
|
|
2032
|
-
|
|
2033
|
-
|
|
2034
|
-
|
|
2413
|
+
children: /* @__PURE__ */ jsx(BoundaryElementProvider, {
|
|
2414
|
+
element: boundaryElement,
|
|
2415
|
+
children: t11
|
|
2416
|
+
})
|
|
2417
|
+
}), $[21] = boundaryElement, $[22] = t11, $[23] = t12) : t12 = $[23];
|
|
2418
|
+
let t13;
|
|
2419
|
+
$[24] !== t10 || $[25] !== t12 ? (t13 = /* @__PURE__ */ jsxs(Card, {
|
|
2420
|
+
borderLeft: !0,
|
|
2035
2421
|
className: frame,
|
|
2036
2422
|
height: "fill",
|
|
2037
|
-
|
|
2038
|
-
|
|
2039
|
-
|
|
2040
|
-
|
|
2423
|
+
ref: t8,
|
|
2424
|
+
children: [t10, t12]
|
|
2425
|
+
}), $[24] = t10, $[25] = t12, $[26] = t13) : t13 = $[26];
|
|
2426
|
+
let t14;
|
|
2427
|
+
return $[27] !== t13 || $[28] !== t7 ? (t14 = /* @__PURE__ */ jsx(Layer, {
|
|
2041
2428
|
className: sidebar,
|
|
2042
|
-
|
|
2043
|
-
style: t6,
|
|
2429
|
+
style: t7,
|
|
2044
2430
|
zOffset: 100,
|
|
2045
|
-
children:
|
|
2046
|
-
}), $[
|
|
2431
|
+
children: t13
|
|
2432
|
+
}), $[27] = t13, $[28] = t7, $[29] = t14) : t14 = $[29], t14;
|
|
2047
2433
|
}
|
|
2434
|
+
function _temp() {}
|
|
2048
2435
|
export { ResizableSidebar as default };
|
|
2049
2436
|
|
|
2050
|
-
//# sourceMappingURL=ResizableSidebar-
|
|
2437
|
+
//# sourceMappingURL=ResizableSidebar-BpgLA4XQ.js.map
|