@sanity/themer
0.8.10.9.0
dist/themes-Bxgltjmb.js+
dist/themes-Bxgltjmb.jsNew file+139
Index: package/dist/themes-Bxgltjmb.js
===================================================================
--- package/dist/themes-Bxgltjmb.js
+++ package/dist/themes-Bxgltjmb.js
@@ -0,0 +1,139 @@
+import { t as presets } from "./presets-CqBgS3A-.js";
+import { addTransitionType } from "react";
+/**
+* The Studio navbar's root, the `Card` that draws its bottom border — its
+* test id is stable and unique to the navbar, unlike its `data-ui` name
+*/
+const NAVBAR_SELECTOR = "[data-testid=\"studio-navbar\"]";
+var layout = "pcwcs0i", layoutTransitionType = "sanity-themer", viewTransitionClasses = {
+ navbarButton: { update: {
+ pcwcs02: "none",
+ pcwcs03: "none",
+ pcwcs00: "pcwcs05",
+ pcwcs01: "pcwcs05",
+ pcwcs04: "pcwcs05",
+ default: "none"
+ } },
+ navbarButtonTooltip: { update: {
+ pcwcs02: "none",
+ pcwcs03: "none",
+ pcwcs00: "auto",
+ pcwcs01: "auto",
+ default: "none"
+ } },
+ sidebar: {
+ enter: {
+ pcwcs00: "pcwcs0d",
+ default: "none"
+ },
+ update: {
+ pcwcs02: "none",
+ pcwcs03: "none",
+ pcwcs04: "auto",
+ default: "none"
+ },
+ exit: {
+ pcwcs01: "pcwcs0f",
+ default: "none"
+ }
+ },
+ splitscreen: {
+ enter: {
+ pcwcs02: "pcwcs0g",
+ default: "none"
+ },
+ update: {
+ pcwcs04: "auto",
+ default: "none"
+ },
+ exit: {
+ pcwcs03: "pcwcs0h",
+ default: "none"
+ }
+ },
+ studio: { update: {
+ pcwcs00: "pcwcs06",
+ pcwcs01: "pcwcs06",
+ pcwcs02: "pcwcs09",
+ pcwcs03: "pcwcs09",
+ pcwcs04: "auto",
+ default: "none"
+ } }
+}, viewTransitionTypes = {
+ open: "pcwcs00",
+ close: "pcwcs01",
+ "split-screen:open": "pcwcs02",
+ "split-screen:close": "pcwcs03",
+ crossfade: "pcwcs04"
+};
+/**
+* Adds the default sanity-themer transition type, which allows custom view transition overrides, as well as customization in userland
+*/
+function addThemerTransitionType(type) {
+ if (!(type in viewTransitionTypes)) throw Error("Invalid transition type", { cause: { type } });
+ addTransitionType(viewTransitionTypes[type]), addTransitionType(layoutTransitionType);
+}
+/** The slug of the theme the Studio config was generated from @internal */
+const CONFIG_SLUG = "config", CONFIG_TITLE = "Studio config", UNTITLED_THEME = "Untitled theme", initialThemerState = {
+ active: null,
+ custom: [],
+ removed: [],
+ order: []
+}, presetsWithSource = presets.map((preset) => Object.assign({}, preset, { source: "preset" }));
+/**
+* Resolves the list of themes: the presets, then the user's own themes —
+* rearranged into the order the user dragged them into, with themes that
+* order does not know about kept in that default order after the ones it
+* does. Removed themes are set aside so they can be restored. The configured
+* theme is not in the list — `ThemeList` shows it ahead of it — and it is
+* what applies when no listed theme does: `active` is `undefined` for it, and
+* for an applied slug that no longer resolves.
+*
+* @internal
+*/
+function resolveThemes(state) {
+ let all = [...presetsWithSource];
+ for (let theme of state.custom) all.push({
+ slug: theme.slug,
+ title: theme.title,
+ options: theme.options,
+ source: "custom",
+ ...theme.palette ? { palette: theme.palette } : {}
+ });
+ let position = new Map(state.order.map((slug, index) => [slug, index])), rank = (theme) => position.get(theme.slug) ?? state.order.length;
+ all.sort((a, b) => rank(a) - rank(b));
+ let removedSlugs = new Set(state.removed), themes = all.filter((theme) => !removedSlugs.has(theme.slug));
+ return {
+ themes,
+ removed: all.filter((theme) => removedSlugs.has(theme.slug)),
+ active: themes.find((theme) => theme.slug === state.active)
+ };
+}
+/**
+* Creates a custom theme with a slug that cannot collide with the presets or
+* the configured theme.
+*
+* @internal
+*/
+function createCustomTheme(title, options, palette) {
+ return {
+ slug: `custom-${randomId()}`,
+ title,
+ options,
+ ...palette ? { palette } : {}
+ };
+}
+/** The title of a duplicated theme @internal */
+function duplicateTitle(title) {
+ return `${displayTitle(title)} copy`;
+}
+/** The title to show for a theme, falling back when the user cleared it @internal */
+function displayTitle(title) {
+ return title.trim() || "Untitled theme";
+}
+function randomId() {
+ return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `${Date.now().toString(36)}${Math.random().toString(36).slice(2, 10)}`;
+}
+export { displayTitle as a, resolveThemes as c, viewTransitionClasses as d, NAVBAR_SELECTOR as f, createCustomTheme as i, addThemerTransitionType as l, CONFIG_TITLE as n, duplicateTitle as o, UNTITLED_THEME as r, initialThemerState as s, CONFIG_SLUG as t, layout as u };
+
+//# sourceMappingURL=themes-Bxgltjmb.js.map
\ No newline at end of file