@sanity/ui 2.0.3 → 2.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/theme.js CHANGED
@@ -1233,7 +1233,7 @@ function inputStateThemeColor_v0_v2(state) {
1233
1233
 
1234
1234
  const cache$3 = /* @__PURE__ */ new WeakMap();
1235
1235
  function getTheme_v2(theme) {
1236
- var _a, _b;
1236
+ var _a;
1237
1237
  if ((_a = theme.sanity.v2) == null ? void 0 : _a._resolved)
1238
1238
  return theme.sanity.v2;
1239
1239
  const cached_v2 = cache$3.get(theme);
@@ -1270,7 +1270,7 @@ function getTheme_v2(theme) {
1270
1270
  ...theme.sanity.input.switch
1271
1271
  }
1272
1272
  },
1273
- layer: (_b = theme.sanity.layer) != null ? _b : defaultThemeConfig.layer,
1273
+ layer: theme.sanity.layer ?? defaultThemeConfig.layer,
1274
1274
  media: theme.sanity.media,
1275
1275
  radius: theme.sanity.radius,
1276
1276
  shadow: theme.sanity.shadows,
@@ -1359,7 +1359,7 @@ function v0_v2(v0) {
1359
1359
  ...input.switch
1360
1360
  }
1361
1361
  },
1362
- layer: layer != null ? layer : defaultThemeConfig.layer,
1362
+ layer: layer ?? defaultThemeConfig.layer,
1363
1363
  media,
1364
1364
  radius,
1365
1365
  shadow,
@@ -1731,13 +1731,13 @@ function compileColorTokenValue(node) {
1731
1731
  if (node.key === "black" || node.key === "white") {
1732
1732
  key = node.key;
1733
1733
  } else {
1734
- key = "".concat(node.hue, "/").concat(node.tint);
1734
+ key = `${node.hue}/${node.tint}`;
1735
1735
  }
1736
1736
  if (node.mix !== void 0) {
1737
- return "".concat(key, " ").concat(node.mix * 100, "%");
1737
+ return `${key} ${node.mix * 100}%`;
1738
1738
  }
1739
1739
  if (node.opacity !== void 0) {
1740
- key += "/".concat(node.opacity);
1740
+ key += `/${node.opacity}`;
1741
1741
  }
1742
1742
  return key;
1743
1743
  }
@@ -1747,7 +1747,7 @@ function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
1747
1747
  const { hue, scheme } = context;
1748
1748
  const node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
1749
1749
  if (!node || node.type !== "color") {
1750
- throw new Error("Invalid color token: ".concat(value[0]));
1750
+ throw new Error(`Invalid color token: ${value[0]}`);
1751
1751
  }
1752
1752
  return compileColorTokenValue({ ...node, hue: node.hue || hue });
1753
1753
  }
@@ -2999,7 +2999,7 @@ function rgbToHex(color) {
2999
2999
  const g = round(clamp(Math.round(color.g), 0, 255));
3000
3000
  const b = round(clamp(Math.round(color.b), 0, 255));
3001
3001
  if ("a" in color) {
3002
- return "rgba(".concat(r, ",").concat(g, ",").concat(b, ",").concat(color.a, ")");
3002
+ return `rgba(${r},${g},${b},${color.a})`;
3003
3003
  }
3004
3004
  return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
3005
3005
  }
@@ -3091,7 +3091,7 @@ function isHex(str) {
3091
3091
  function parseHsl(str) {
3092
3092
  const res = HSL_RE.exec(str);
3093
3093
  if (!res) {
3094
- throw new Error('parseHsl: string is not a HSL color: "'.concat(str, '"'));
3094
+ throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
3095
3095
  }
3096
3096
  return { h: parseInt(res[1]), s: parseFloat(res[3]), l: parseFloat(res[5]) };
3097
3097
  }
@@ -3110,7 +3110,7 @@ function parseColor(color) {
3110
3110
  if (color.startsWith("rgba(")) {
3111
3111
  return rgbaToRGBA(color);
3112
3112
  }
3113
- throw new Error('parseColor: unexpected color format: "'.concat(color, '"'));
3113
+ throw new Error(`parseColor: unexpected color format: "${color}"`);
3114
3114
  }
3115
3115
 
3116
3116
  function getContrastRatio(bg, fg) {
@@ -3134,7 +3134,7 @@ function lrgb_luminance([r, g, b]) {
3134
3134
 
3135
3135
  function rgba(color, a) {
3136
3136
  const rgb = parseColor(color);
3137
- return "rgba(".concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ",").concat(a, ")");
3137
+ return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
3138
3138
  }
3139
3139
 
3140
3140
  const RGB_RANGE = [0, 255];
@@ -3175,7 +3175,7 @@ function renderColorValue(str, options) {
3175
3175
  }
3176
3176
  const node = parseTokenValue(str);
3177
3177
  if (!node || node.type !== "color") {
3178
- throw new Error("Invalid color token value: ".concat(str));
3178
+ throw new Error(`Invalid color token value: ${str}`);
3179
3179
  }
3180
3180
  let hex = "";
3181
3181
  if (node.key === "black") {
@@ -3188,7 +3188,7 @@ function renderColorValue(str, options) {
3188
3188
  hex = renderColorHex(colorPalette[node.hue][node.tint]);
3189
3189
  }
3190
3190
  if (!hex) {
3191
- throw new Error("Invalid color token value: ".concat(str));
3191
+ throw new Error(`Invalid color token value: ${str}`);
3192
3192
  }
3193
3193
  const hexBeforeMix = hex;
3194
3194
  const mixOptions = {
@@ -3210,7 +3210,7 @@ function renderColorValue(str, options) {
3210
3210
  throw err;
3211
3211
  }
3212
3212
  if (hex === "#aN") {
3213
- console.warn("invalid color token value: ".concat(str));
3213
+ console.warn(`invalid color token value: ${str}`);
3214
3214
  hex = hexBeforeMix;
3215
3215
  }
3216
3216
  if (node.opacity !== void 0) {
@@ -3223,8 +3223,7 @@ function renderColorHex(color) {
3223
3223
  }
3224
3224
 
3225
3225
  function renderThemeColorSchemes(value, config) {
3226
- var _a;
3227
- const colorPalette = (_a = config == null ? void 0 : config.palette) != null ? _a : defaultColorPalette;
3226
+ const colorPalette = (config == null ? void 0 : config.palette) ?? defaultColorPalette;
3228
3227
  return {
3229
3228
  light: renderThemeColorScheme(colorPalette, value.light),
3230
3229
  dark: renderThemeColorScheme(colorPalette, value.dark)
@@ -3564,28 +3563,27 @@ function renderSyntaxColorTheme(value, options) {
3564
3563
  }
3565
3564
 
3566
3565
  function buildTheme(config) {
3567
- var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
3568
3566
  const colorTheme = buildColorTheme(config);
3569
3567
  const v2 = {
3570
3568
  _version: 2,
3571
- avatar: (_a = config == null ? void 0 : config.avatar) != null ? _a : defaultThemeConfig.avatar,
3572
- button: (_b = config == null ? void 0 : config.button) != null ? _b : defaultThemeConfig.button,
3573
- card: (_c = config == null ? void 0 : config.card) != null ? _c : defaultThemeConfig.card,
3569
+ avatar: (config == null ? void 0 : config.avatar) ?? defaultThemeConfig.avatar,
3570
+ button: (config == null ? void 0 : config.button) ?? defaultThemeConfig.button,
3571
+ card: (config == null ? void 0 : config.card) ?? defaultThemeConfig.card,
3574
3572
  // How colors are generated:
3575
3573
  // 1. Merge custom tokens with default tokens
3576
3574
  // 2. Generate tree of color keys (gray/500, black, white, etc.)
3577
3575
  // 3. Apply mixing and render to hex values
3578
3576
  // render(build(mergeWithDefaults()))
3579
3577
  color: renderThemeColorSchemes(colorTheme, config),
3580
- container: (_d = config == null ? void 0 : config.container) != null ? _d : defaultThemeConfig.container,
3581
- font: (_e = config == null ? void 0 : config.font) != null ? _e : defaultThemeFonts,
3582
- input: (_f = config == null ? void 0 : config.input) != null ? _f : defaultThemeConfig.input,
3583
- layer: (_g = config == null ? void 0 : config.layer) != null ? _g : defaultThemeConfig.layer,
3584
- media: (_h = config == null ? void 0 : config.media) != null ? _h : defaultThemeConfig.media,
3585
- radius: (_i = config == null ? void 0 : config.radius) != null ? _i : defaultThemeConfig.radius,
3586
- shadow: (_j = config == null ? void 0 : config.shadow) != null ? _j : defaultThemeConfig.shadow,
3587
- space: (_k = config == null ? void 0 : config.space) != null ? _k : defaultThemeConfig.space,
3588
- style: (_l = config == null ? void 0 : config.style) != null ? _l : defaultThemeConfig.style
3578
+ container: (config == null ? void 0 : config.container) ?? defaultThemeConfig.container,
3579
+ font: (config == null ? void 0 : config.font) ?? defaultThemeFonts,
3580
+ input: (config == null ? void 0 : config.input) ?? defaultThemeConfig.input,
3581
+ layer: (config == null ? void 0 : config.layer) ?? defaultThemeConfig.layer,
3582
+ media: (config == null ? void 0 : config.media) ?? defaultThemeConfig.media,
3583
+ radius: (config == null ? void 0 : config.radius) ?? defaultThemeConfig.radius,
3584
+ shadow: (config == null ? void 0 : config.shadow) ?? defaultThemeConfig.shadow,
3585
+ space: (config == null ? void 0 : config.space) ?? defaultThemeConfig.space,
3586
+ style: (config == null ? void 0 : config.style) ?? defaultThemeConfig.style
3589
3587
  };
3590
3588
  return v2_v0(v2);
3591
3589
  }