@sanity/ui 2.0.0-beta.2 → 2.0.0-beta.21

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.
Files changed (91) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +6 -3
  3. package/dist/index.cjs.mjs +11 -36
  4. package/dist/index.d.ts +247 -267
  5. package/dist/index.esm.js +477 -326
  6. package/dist/index.esm.js.map +1 -1
  7. package/dist/index.js +486 -539
  8. package/dist/index.js.map +1 -1
  9. package/dist/theme.cjs.mjs +1 -1
  10. package/dist/theme.d.ts +87 -115
  11. package/dist/theme.esm.js +348 -290
  12. package/dist/theme.esm.js.map +1 -1
  13. package/dist/theme.js +348 -290
  14. package/dist/theme.js.map +1 -1
  15. package/package.json +6 -3
  16. package/src/core/__workshop__/fontsPlugin.tsx +48 -8
  17. package/src/core/_compat.ts +236 -87
  18. package/src/core/components/dialog/dialog.tsx +1 -1
  19. package/src/core/components/dialog/styles.ts +2 -2
  20. package/src/core/components/menu/__workshop__/selectedItem.tsx +7 -2
  21. package/src/core/components/menu/menuButton.tsx +12 -1
  22. package/src/core/components/toast/toast.tsx +17 -2
  23. package/src/core/components/toast/toastProvider.tsx +20 -3
  24. package/src/core/constants.ts +37 -0
  25. package/src/core/hooks/useMediaIndex/useMediaIndex.test.tsx +6 -3
  26. package/src/core/middleware/origin.ts +47 -0
  27. package/src/core/primitives/badge/badge.tsx +1 -3
  28. package/src/core/primitives/button/button.tsx +9 -11
  29. package/src/core/primitives/heading/styles.ts +4 -0
  30. package/src/core/primitives/kbd/kbd.tsx +2 -0
  31. package/src/core/primitives/popover/popover.tsx +67 -13
  32. package/src/core/primitives/popover/popoverCard.tsx +31 -15
  33. package/src/core/primitives/select/select.tsx +1 -1
  34. package/src/core/primitives/switch/styles.ts +6 -1
  35. package/src/core/primitives/textInput/__workshop__/plain.tsx +1 -1
  36. package/src/core/primitives/textInput/__workshop__/states.tsx +10 -2
  37. package/src/core/primitives/tooltip/tooltip.tsx +46 -56
  38. package/src/core/primitives/tooltip/tooltipCard.tsx +110 -0
  39. package/src/core/styles/card/_cardColorStyle.ts +2 -0
  40. package/src/core/styles/input/textInputStyle.ts +33 -2
  41. package/src/core/styles/margin/marginsStyle.test.ts +2 -2
  42. package/src/core/styles/padding/paddingStyle.test.ts +2 -2
  43. package/src/core/theme/__workshop__/build/Root.tsx +20 -3
  44. package/src/core/theme/__workshop__/build/story.tsx +16 -10
  45. package/src/core/theme/__workshop__/canvas.tsx +7 -7
  46. package/src/core/theme/__workshop__/debug/story.tsx +196 -0
  47. package/src/core/theme/__workshop__/index.ts +5 -0
  48. package/src/core/theme/theme.test.tsx +2 -2
  49. package/src/core/types/button.ts +1 -2
  50. package/src/core/{primitives/tooltip → utils/conditionalWrapper}/conditionalWrapper.tsx +3 -0
  51. package/src/core/utils/conditionalWrapper/index.ts +1 -0
  52. package/src/core/utils/index.ts +1 -0
  53. package/src/theme/build/_deprecated/color/factory.ts +3 -3
  54. package/src/theme/build/buildColorTheme.test.ts +2 -2
  55. package/src/theme/build/buildColorTheme.ts +16 -16
  56. package/src/theme/build/colorToken/colorToken.ts +19 -0
  57. package/src/theme/build/colorToken/compileColorToken.ts +21 -0
  58. package/src/theme/build/colorToken/index.ts +2 -0
  59. package/src/theme/build/colorToken/types.ts +6 -0
  60. package/src/theme/build/renderColorTheme.ts +14 -15
  61. package/src/theme/build/renderColorValue.ts +9 -2
  62. package/src/theme/config/system.ts +12 -10
  63. package/src/theme/config/tokens/color/types.ts +12 -1
  64. package/src/theme/config/tokens/parseTokenKey.ts +1 -0
  65. package/src/theme/config/tokens/parseTokenValue.test.ts +13 -16
  66. package/src/theme/config/tokens/parseTokenValue.ts +45 -14
  67. package/src/theme/config/tokens/types.ts +3 -2
  68. package/src/theme/defaults/colorTokens.ts +279 -253
  69. package/src/theme/defaults/config.ts +2 -2
  70. package/src/theme/getScopedTheme.ts +1 -0
  71. package/src/theme/index.ts +0 -7
  72. package/src/theme/system/color/_constants.ts +5 -2
  73. package/src/theme/system/color/_system.ts +2 -1
  74. package/src/theme/system/color/avatar.ts +2 -12
  75. package/src/theme/system/color/button.ts +4 -20
  76. package/src/theme/system/color/input.ts +3 -11
  77. package/src/theme/system/color/selectable.ts +3 -14
  78. package/src/theme/system/shadow.ts +0 -6
  79. package/src/theme/system/styles.ts +0 -6
  80. package/src/theme/system/theme.ts +11 -1
  81. package/src/theme/system/v0/avatar.ts +1 -1
  82. package/src/theme/system/v0/color/button.ts +4 -4
  83. package/src/theme/system/v0/color/card.ts +2 -2
  84. package/src/theme/system/v0/color/color.ts +0 -1
  85. package/src/theme/system/v0/color/input.ts +3 -3
  86. package/src/theme/system/v0/color/muted.ts +2 -2
  87. package/src/theme/system/v0/color/solid.ts +2 -2
  88. package/src/theme/versioning/getTheme_v2.ts +2 -1
  89. package/src/theme/versioning/themeColor_v0_v2.ts +2 -2
  90. package/src/theme/versioning/v2_v0.ts +3 -2
  91. package/src/theme/build/colorToken.ts +0 -39
package/dist/theme.js CHANGED
@@ -1205,7 +1205,7 @@ const defaultThemeConfig = {
1205
1205
  outline: OUTLINE_WIDTH
1206
1206
  }
1207
1207
  },
1208
- container: [480, 640, 960, 1280, 1600, 1920],
1208
+ container: [320, 640, 960, 1280, 1600, 1920],
1209
1209
  media: [360, 600, 900, 1200, 1800, 2400],
1210
1210
  layer: {
1211
1211
  dialog: {
@@ -1263,7 +1263,7 @@ const defaultThemeConfig = {
1263
1263
  switch: {
1264
1264
  width: 25,
1265
1265
  height: 17,
1266
- padding: 2,
1266
+ padding: 5,
1267
1267
  transitionDurationMs: 150,
1268
1268
  transitionTimingFunction: "ease-out",
1269
1269
  focusRing: {
@@ -1687,12 +1687,13 @@ function inputStateThemeColor_v0_v2(state) {
1687
1687
  }
1688
1688
  const cache$3 = /* @__PURE__ */new WeakMap();
1689
1689
  function getTheme_v2(theme) {
1690
- var _a;
1691
- if (theme.sanity.v2) return theme.sanity.v2;
1690
+ var _a, _b;
1691
+ if ((_a = theme.sanity.v2) == null ? void 0 : _a._resolved) return theme.sanity.v2;
1692
1692
  const cached_v2 = cache$3.get(theme);
1693
1693
  if (cached_v2) return cached_v2;
1694
1694
  const v2 = {
1695
1695
  _version: 2,
1696
+ _resolved: true,
1696
1697
  avatar: {
1697
1698
  ...defaultThemeConfig.avatar,
1698
1699
  ...theme.sanity.avatar
@@ -1721,7 +1722,7 @@ function getTheme_v2(theme) {
1721
1722
  ...theme.sanity.input.switch
1722
1723
  }
1723
1724
  },
1724
- layer: (_a = theme.sanity.layer) != null ? _a : defaultThemeConfig.layer,
1725
+ layer: (_b = theme.sanity.layer) != null ? _b : defaultThemeConfig.layer,
1725
1726
  media: theme.sanity.media,
1726
1727
  radius: theme.sanity.radius,
1727
1728
  shadow: theme.sanity.shadows,
@@ -1890,6 +1891,7 @@ function themeColor_v2_v0(color_v2) {
1890
1891
  ...color_v2.button.default,
1891
1892
  transparent: color_v2.button.default.default
1892
1893
  },
1894
+ selectable: color_v2.selectable,
1893
1895
  spot: {
1894
1896
  gray: color_v2.avatar.gray.bg,
1895
1897
  blue: color_v2.avatar.blue.bg,
@@ -1921,13 +1923,10 @@ function inputStateThemeColor_v2_v0(t) {
1921
1923
  placeholder: t.placeholder
1922
1924
  };
1923
1925
  }
1926
+ const THEME_COLOR_SCHEMES = ["light", "dark"];
1924
1927
  const THEME_COLOR_BLEND_MODES = ["multiply", "screen"];
1925
- const THEME_COLOR_CARD_TONES = ["transparent", "default", "primary",
1926
- // todo: rename to `accent` in the next breaking major version
1927
- "positive", "caution", "critical"];
1928
- const THEME_COLOR_STATE_TONES = ["default", "primary",
1929
- // todo: rename to `accent` in the next breaking major version
1930
- "positive", "caution", "critical"];
1928
+ const THEME_COLOR_CARD_TONES = ["transparent", "default", "primary", "positive", "caution", "critical"];
1929
+ const THEME_COLOR_STATE_TONES = ["default", "primary", "positive", "caution", "critical"];
1931
1930
  const THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"];
1932
1931
  const THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"];
1933
1932
  const THEME_COLOR_INPUT_MODES = ["default", "invalid"];
@@ -2001,12 +2000,24 @@ function parseTokenKey(str) {
2001
2000
  }
2002
2001
  return void 0;
2003
2002
  }
2003
+ function isColorMixPercentValue(str) {
2004
+ return /^\d+%$/.test(str);
2005
+ }
2004
2006
  function parseTokenValue(str) {
2005
2007
  const segments = str.split("/");
2006
- const segment0 = segments.shift() || "";
2008
+ let nextSegment = segments.shift() || "";
2009
+ const [segment0, segment0mix] = nextSegment.split(" ");
2007
2010
  if (isColorTintKey(segment0)) {
2008
2011
  const tint = segment0;
2009
2012
  const segment1 = segments.shift() || "";
2013
+ if (isColorMixPercentValue(segment0mix)) {
2014
+ const mix = Number(segment0mix.slice(0, -1)) / 100;
2015
+ return {
2016
+ type: "color",
2017
+ tint,
2018
+ mix
2019
+ };
2020
+ }
2010
2021
  if (isColorOpacityValue(segment1)) {
2011
2022
  const opacity = Number(segment1);
2012
2023
  return {
@@ -2023,6 +2034,14 @@ function parseTokenValue(str) {
2023
2034
  if (isColorValue(segment0)) {
2024
2035
  const key = segment0;
2025
2036
  const segment1 = segments.shift() || "";
2037
+ if (isColorMixPercentValue(segment0mix)) {
2038
+ const mix = Number(segment0mix.slice(0, -1)) / 100;
2039
+ return {
2040
+ type: "color",
2041
+ key,
2042
+ mix
2043
+ };
2044
+ }
2026
2045
  if (isColorOpacityValue(segment1)) {
2027
2046
  const opacity = Number(segment1);
2028
2047
  return {
@@ -2038,15 +2057,24 @@ function parseTokenValue(str) {
2038
2057
  }
2039
2058
  if (isColorHueKey(segment0)) {
2040
2059
  const hue = segment0;
2041
- const segment1 = segments.shift() || "";
2060
+ nextSegment = segments.shift() || "";
2061
+ const [segment1, segment1mix] = nextSegment.split(" ");
2042
2062
  if (isColorTintKey(segment1)) {
2043
2063
  const tint = segment1;
2044
2064
  const segment2 = segments.shift() || "";
2065
+ if (isColorMixPercentValue(segment1mix)) {
2066
+ const mix = Number(segment1mix.slice(0, -1)) / 100;
2067
+ return {
2068
+ type: "color",
2069
+ hue,
2070
+ tint,
2071
+ mix
2072
+ };
2073
+ }
2045
2074
  if (isColorOpacityValue(segment2)) {
2046
2075
  const opacity = Number(segment2);
2047
2076
  return {
2048
2077
  type: "color",
2049
- key: "".concat(hue, "/").concat(tint),
2050
2078
  hue,
2051
2079
  tint,
2052
2080
  opacity
@@ -2054,21 +2082,13 @@ function parseTokenValue(str) {
2054
2082
  }
2055
2083
  return {
2056
2084
  type: "color",
2057
- key: "".concat(hue, "/").concat(tint),
2058
2085
  hue,
2059
2086
  tint
2060
2087
  };
2061
2088
  }
2062
2089
  return {
2063
2090
  type: "hue",
2064
- value: "".concat(hue)
2065
- };
2066
- }
2067
- if (isColorOpacityValue(segment0)) {
2068
- const opacity = Number(segment0);
2069
- return {
2070
- type: "color",
2071
- opacity
2091
+ value: hue
2072
2092
  };
2073
2093
  }
2074
2094
  if (isColorBlendModeValue(segment0)) {
@@ -2105,6 +2125,21 @@ function isColorValue(str) {
2105
2125
  function isColorOpacityValue(str) {
2106
2126
  return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
2107
2127
  }
2128
+ function compileColorTokenValue(node) {
2129
+ let key = "";
2130
+ if (node.key === "black" || node.key === "white") {
2131
+ key = node.key;
2132
+ } else {
2133
+ key = "".concat(node.hue, "/").concat(node.tint);
2134
+ }
2135
+ if (node.mix !== void 0) {
2136
+ return "".concat(key, " ").concat(node.mix * 100, "%");
2137
+ }
2138
+ if (node.opacity !== void 0) {
2139
+ key += "/".concat(node.opacity);
2140
+ }
2141
+ return key;
2142
+ }
2108
2143
  const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
2109
2144
  function resolveColorTokenValue(context) {
2110
2145
  let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : DEFAULT_COLOR_TOKEN_VALUE;
@@ -2121,51 +2156,35 @@ function resolveColorTokenValue(context) {
2121
2156
  hue: node.hue || hue
2122
2157
  });
2123
2158
  }
2124
- function compileColorTokenValue(node) {
2125
- let key = "";
2126
- if (node.key === "black" || node.key === "white") {
2127
- key = node.key;
2128
- } else {
2129
- key = "".concat(node.hue, "/").concat(node.tint);
2130
- }
2131
- if (node.opacity !== void 0) {
2132
- key += "/".concat(node.opacity);
2133
- }
2134
- return key;
2135
- }
2136
2159
  const defaultColorTokens = {
2137
2160
  base: {
2138
2161
  "*": {
2139
2162
  _blend: ["multiply", "screen"],
2163
+ accent: {
2164
+ fg: ["purple/600", "purple/400"]
2165
+ },
2140
2166
  avatar: {
2141
2167
  "*": {
2142
2168
  _blend: ["screen", "multiply"],
2143
2169
  bg: ["500", "400"],
2144
2170
  fg: ["white", "black"]
2145
- },
2146
- yellow: {
2147
- bg: ["600", "400"]
2148
- },
2149
- green: {
2150
- bg: ["600", "400"]
2151
- },
2152
- cyan: {
2153
- bg: ["600", "400"]
2154
2171
  }
2155
2172
  },
2156
- backdrop: ["gray/200/0.2", "black/0.5"],
2173
+ backdrop: ["gray/200/0.5", "black/0.5"],
2157
2174
  badge: {
2158
2175
  "*": {
2159
2176
  bg: ["100", "900"],
2160
- fg: ["600", "400"]
2177
+ fg: ["600", "400"],
2178
+ icon: ["500", "500"],
2179
+ dot: ["500", "500"]
2161
2180
  },
2162
2181
  positive: {
2163
- bg: ["200/0.6", "900"],
2164
- fg: ["700", "500"]
2182
+ bg: ["200 50%", "900"],
2183
+ fg: ["600", "500"]
2165
2184
  },
2166
2185
  caution: {
2167
- bg: ["200/0.7", "900"],
2168
- fg: ["700", "500"]
2186
+ bg: ["200 50%", "900"],
2187
+ fg: ["600", "500"]
2169
2188
  }
2170
2189
  },
2171
2190
  bg: ["50", "950"],
@@ -2176,17 +2195,18 @@ const defaultColorTokens = {
2176
2195
  },
2177
2196
  fg: ["800", "200"],
2178
2197
  focusRing: ["blue/500", "blue/500"],
2198
+ icon: ["600", "400"],
2179
2199
  kbd: {
2180
2200
  bg: ["white", "black"],
2181
2201
  fg: ["600", "400"],
2182
2202
  border: ["200", "800"]
2183
2203
  },
2184
2204
  link: {
2185
- fg: ["blue/600", "blue/400"]
2205
+ fg: ["blue/600", "blue/300"]
2186
2206
  },
2187
2207
  muted: {
2188
2208
  bg: ["50", "950"],
2189
- fg: ["600", "400"]
2209
+ fg: ["700 75%", "300 75%"]
2190
2210
  },
2191
2211
  shadow: {
2192
2212
  outline: ["500/0.3", "500/0.4"],
@@ -2196,16 +2216,18 @@ const defaultColorTokens = {
2196
2216
  },
2197
2217
  skeleton: {
2198
2218
  from: ["100", "900"],
2199
- to: ["100/0.5", "900/0.5"]
2219
+ to: ["100 50%", "900 50%"]
2200
2220
  }
2201
2221
  },
2202
2222
  transparent: {
2203
- bg: ["50", "black"],
2204
- fg: ["600", "400"]
2223
+ bg: ["50", "black"]
2205
2224
  },
2206
2225
  default: {
2207
2226
  bg: ["white", "950"],
2208
- fg: ["black", "200"]
2227
+ fg: ["800", "200"],
2228
+ muted: {
2229
+ fg: ["600", "400"]
2230
+ }
2209
2231
  },
2210
2232
  primary: {
2211
2233
  _hue: "blue"
@@ -2213,20 +2235,17 @@ const defaultColorTokens = {
2213
2235
  positive: {
2214
2236
  _hue: "green",
2215
2237
  shadow: {
2216
- outline: ["600/0.3", "500/0.25"]
2238
+ outline: ["500/0.4", "500/0.4"]
2217
2239
  }
2218
2240
  },
2219
2241
  caution: {
2220
2242
  _hue: "yellow",
2221
2243
  shadow: {
2222
- outline: ["600/0.3", "500/0.25"]
2244
+ outline: ["600/0.3", "500/0.4"]
2223
2245
  }
2224
2246
  },
2225
2247
  critical: {
2226
- _hue: "red",
2227
- shadow: {
2228
- outline: ["500/0.3", "500/0.3"]
2229
- }
2248
+ _hue: "red"
2230
2249
  }
2231
2250
  },
2232
2251
  button: {
@@ -2235,58 +2254,89 @@ const defaultColorTokens = {
2235
2254
  "*": {
2236
2255
  _blend: ["screen", "multiply"],
2237
2256
  accent: {
2238
- fg: ["purple/200", "purple/700"]
2257
+ fg: ["purple/300", "purple/700"]
2258
+ },
2259
+ avatar: {
2260
+ "*": {
2261
+ _blend: ["multiply", "screen"],
2262
+ bg: ["white", "black"],
2263
+ fg: ["black", "white"]
2264
+ }
2239
2265
  },
2240
2266
  badge: {
2241
2267
  "*": {
2242
- dot: ["300", "700"],
2243
- icon: ["600", "400"]
2268
+ bg: ["900", "100"],
2269
+ fg: ["400", "600"],
2270
+ dot: ["500", "500"],
2271
+ icon: ["500", "500"]
2244
2272
  }
2245
2273
  },
2246
2274
  bg: ["500", "400"],
2247
2275
  border: ["500/0", "400/0"],
2248
2276
  code: {
2249
- bg: ["500/0.2", "400/0.2"],
2250
- fg: ["200", "700"]
2277
+ bg: ["500 20%", "400 20%"],
2278
+ fg: ["200", "600"]
2251
2279
  },
2252
2280
  fg: ["white", "black"],
2253
- icon: ["200", "800"],
2281
+ icon: ["100 70%", "900 70%"],
2254
2282
  kbd: {
2255
- bg: ["900", "50"],
2256
- fg: ["white", "black"],
2283
+ bg: ["black", "white"],
2284
+ fg: ["200", "600"],
2257
2285
  border: ["800", "200"]
2258
2286
  },
2259
2287
  link: {
2260
- fg: ["blue/200", "blue/700"]
2288
+ fg: ["blue/200", "blue/600"]
2261
2289
  },
2262
2290
  muted: {
2263
- bg: ["900", "50"],
2264
- fg: ["200", "700"]
2291
+ bg: ["950", "50"],
2292
+ fg: ["100 70%", "900 70%"]
2265
2293
  },
2266
2294
  skeleton: {
2267
2295
  from: ["900", "100"],
2268
- to: ["900/0.5", "100/0.5"]
2296
+ to: ["900 50%", "100 50%"]
2269
2297
  }
2270
2298
  },
2271
2299
  hovered: {
2272
- bg: ["600", "300"],
2273
- border: ["600/0", "300/0"]
2300
+ bg: ["700", "300"],
2301
+ border: ["700/0", "300/0"]
2274
2302
  },
2275
2303
  pressed: {
2276
- bg: ["700", "200"]
2304
+ bg: ["700", "300"]
2277
2305
  },
2278
2306
  selected: {
2279
- bg: ["700", "200"]
2307
+ bg: ["700", "300"]
2280
2308
  },
2281
2309
  disabled: {
2282
2310
  _hue: "gray",
2311
+ accent: {
2312
+ fg: ["100 70%", "900 70%"]
2313
+ },
2314
+ badge: {
2315
+ "*": {
2316
+ bg: ["gray/700", "gray/300"],
2317
+ fg: ["white", "black"],
2318
+ dot: ["white", "black"],
2319
+ icon: ["white", "black"]
2320
+ }
2321
+ },
2283
2322
  bg: ["200", "800"],
2284
- icon: ["white", "black"]
2323
+ kbd: {
2324
+ bg: ["black", "white"],
2325
+ fg: ["white", "black"],
2326
+ border: ["700", "300"]
2327
+ },
2328
+ link: {
2329
+ fg: ["100 70%", "900 70%"]
2330
+ }
2285
2331
  }
2286
2332
  },
2287
2333
  default: {
2288
2334
  "*": {
2289
- bg: ["800", "200"]
2335
+ bg: ["800", "200"],
2336
+ muted: {
2337
+ bg: ["950", "50"],
2338
+ fg: ["400", "600"]
2339
+ }
2290
2340
  },
2291
2341
  hovered: {
2292
2342
  bg: ["900", "100"]
@@ -2297,67 +2347,46 @@ const defaultColorTokens = {
2297
2347
  selected: {
2298
2348
  bg: ["black", "white"]
2299
2349
  }
2300
- },
2301
- positive: {
2302
- "*": {
2303
- bg: ["600", "400"]
2304
- },
2305
- hovered: {
2306
- bg: ["700", "300"]
2307
- },
2308
- pressed: {
2309
- bg: ["800", "200"]
2310
- },
2311
- selected: {
2312
- bg: ["800", "200"]
2313
- }
2314
- },
2315
- caution: {
2316
- "*": {
2317
- bg: ["600", "400"]
2318
- },
2319
- hovered: {
2320
- bg: ["700", "300"]
2321
- },
2322
- pressed: {
2323
- bg: ["800", "200"]
2324
- },
2325
- selected: {
2326
- bg: ["800", "200"]
2327
- }
2328
2350
  }
2329
2351
  },
2330
2352
  ghost: {
2331
2353
  "*": {
2332
2354
  "*": {
2333
2355
  _blend: ["multiply", "screen"],
2356
+ accent: {
2357
+ fg: ["purple/700 60%", "purple/300 70%"]
2358
+ },
2359
+ badge: {
2360
+ "*": {
2361
+ bg: ["100", "900"],
2362
+ fg: ["600", "400"],
2363
+ dot: ["500", "500"],
2364
+ icon: ["500", "500"]
2365
+ }
2366
+ },
2334
2367
  bg: ["50", "950"],
2335
- fg: ["700", "400"],
2336
- icon: ["600", "500"],
2337
2368
  border: ["100", "900"],
2338
- accent: {
2339
- fg: ["purple/700/0.6", "purple/400/0.8"]
2369
+ code: {
2370
+ bg: ["500 10%", "400 10%"],
2371
+ fg: ["700 60%", "400 60%"]
2372
+ },
2373
+ fg: ["600", "400"],
2374
+ icon: ["700 60%", "300 60%"],
2375
+ kbd: {
2376
+ bg: ["white", "black"],
2377
+ fg: ["600", "400"],
2378
+ border: ["200", "800"]
2340
2379
  },
2341
2380
  link: {
2342
- fg: ["blue/700/0.6", "blue/400/0.8"]
2381
+ fg: ["blue/700 60%", "blue/300 60%"]
2343
2382
  },
2344
2383
  muted: {
2345
2384
  bg: ["100", "950"],
2346
- fg: ["700/0.6", "400/0.6"]
2347
- },
2348
- code: {
2349
- bg: ["500/0.1", "400/0.1"],
2350
- fg: ["700/0.6", "400/0.6"]
2385
+ fg: ["700 60%", "300 60%"]
2351
2386
  },
2352
2387
  skeleton: {
2353
2388
  from: ["100", "900"],
2354
- to: ["100/0.5", "900/0.5"]
2355
- },
2356
- badge: {
2357
- "*": {
2358
- dot: ["300", "700"],
2359
- icon: ["600", "400"]
2360
- }
2389
+ to: ["100 50%", "900 50%"]
2361
2390
  }
2362
2391
  },
2363
2392
  hovered: {
@@ -2374,32 +2403,46 @@ const defaultColorTokens = {
2374
2403
  },
2375
2404
  disabled: {
2376
2405
  _hue: "gray",
2377
- fg: ["200", "800"],
2378
- icon: ["200", "800"],
2406
+ accent: {
2407
+ fg: ["200", "800"]
2408
+ },
2409
+ badge: {
2410
+ "*": {
2411
+ _hue: "gray",
2412
+ bg: ["50", "950"],
2413
+ fg: ["gray/200", "gray/800"],
2414
+ dot: ["gray/200", "gray/800"],
2415
+ icon: ["gray/200", "gray/800"]
2416
+ }
2417
+ },
2379
2418
  border: ["100", "900"],
2380
- muted: {
2381
- fg: ["200/0.6", "900/0.6"]
2419
+ code: {
2420
+ bg: ["50", "950"],
2421
+ fg: ["200", "800"]
2382
2422
  },
2383
- accent: {
2384
- fg: ["200/0.6", "900/0.6"]
2423
+ fg: ["200", "800"],
2424
+ icon: ["200", "800"],
2425
+ kbd: {
2426
+ bg: ["white", "black"],
2427
+ fg: ["200", "800"],
2428
+ border: ["100", "900"]
2385
2429
  },
2386
2430
  link: {
2387
- fg: ["200/0.6", "900/0.6"]
2431
+ fg: ["200", "800"]
2388
2432
  },
2389
- code: {
2390
- bg: ["50/0.5", "950/0.5"],
2391
- fg: ["200/0.6", "900/0.6"]
2433
+ muted: {
2434
+ fg: ["200", "800"]
2392
2435
  }
2393
2436
  }
2394
2437
  },
2395
2438
  positive: {
2396
2439
  "*": {
2397
- border: ["600/0.2", "800"]
2440
+ border: ["600 20%", "800"]
2398
2441
  }
2399
2442
  },
2400
2443
  caution: {
2401
2444
  "*": {
2402
- border: ["600/0.2", "800"]
2445
+ border: ["600 20%", "800"]
2403
2446
  }
2404
2447
  }
2405
2448
  },
@@ -2407,65 +2450,86 @@ const defaultColorTokens = {
2407
2450
  "*": {
2408
2451
  "*": {
2409
2452
  _blend: ["multiply", "screen"],
2453
+ accent: {
2454
+ fg: ["purple/700 70%", "purple/300 70%"]
2455
+ },
2456
+ badge: {
2457
+ "*": {
2458
+ bg: ["100", "900"],
2459
+ fg: ["600", "400"],
2460
+ dot: ["500", "500"],
2461
+ icon: ["500", "500"]
2462
+ }
2463
+ },
2410
2464
  bg: ["white", "black"],
2411
- fg: ["700", "300"],
2412
- icon: ["700/0.7", "300/0.7"],
2413
2465
  border: ["white/0", "black/0"],
2414
- muted: {
2415
- bg: ["100", "950"],
2416
- fg: ["700/0.7", "300/0.7"]
2466
+ code: {
2467
+ bg: ["50", "950"],
2468
+ fg: ["700 75%", "300 75%"]
2417
2469
  },
2418
- accent: {
2419
- fg: ["purple/700/0.7", "purple/300/0.7"]
2470
+ fg: ["700", "300"],
2471
+ icon: ["700 75%", "300 75%"],
2472
+ kbd: {
2473
+ bg: ["white", "black"],
2474
+ fg: ["700", "300"],
2475
+ border: ["200", "800"]
2420
2476
  },
2421
2477
  link: {
2422
- fg: ["blue/700/0.7", "blue/300/0.7"]
2478
+ fg: ["blue/700 70%", "blue/300 70%"]
2423
2479
  },
2424
- code: {
2480
+ muted: {
2425
2481
  bg: ["100", "950"],
2426
- fg: ["600", "300"]
2482
+ fg: ["700 75%", "300 75%"]
2427
2483
  },
2428
2484
  skeleton: {
2429
2485
  from: ["100", "900"],
2430
- to: ["100/0.5", "900/0.5"]
2431
- },
2432
- badge: {
2433
- "*": {
2434
- dot: ["300", "700"],
2435
- icon: ["600", "400"]
2436
- }
2486
+ to: ["100 50%", "900 50%"]
2437
2487
  }
2438
2488
  },
2439
2489
  hovered: {
2440
2490
  bg: ["50", "950"],
2441
- fg: ["700", "300"],
2442
- icon: ["700/0.7", "400/0.7"]
2491
+ icon: ["700 70%", "400 70%"]
2443
2492
  },
2444
2493
  pressed: {
2445
2494
  bg: ["100", "900"],
2446
2495
  fg: ["800", "200"],
2447
- icon: ["800/0.7", "200/0.7"]
2496
+ icon: ["800 70%", "200 70%"]
2448
2497
  },
2449
2498
  selected: {
2450
2499
  bg: ["100", "900"],
2451
2500
  fg: ["800", "200"],
2452
- icon: ["800/0.7", "200/0.7"]
2501
+ icon: ["800 60%", "200 60%"]
2453
2502
  },
2454
2503
  disabled: {
2455
2504
  _hue: "gray",
2456
- fg: ["200", "800"],
2457
- muted: {
2458
- fg: ["200/0.6", "900/0.6"]
2459
- },
2460
2505
  accent: {
2461
- fg: ["200/0.6", "900/0.6"]
2506
+ fg: ["200", "800"]
2462
2507
  },
2463
- link: {
2464
- fg: ["200/0.6", "900/0.6"]
2508
+ badge: {
2509
+ "*": {
2510
+ _hue: "gray",
2511
+ bg: ["50", "950"],
2512
+ fg: ["gray/200", "gray/800"],
2513
+ dot: ["gray/200", "gray/800"],
2514
+ icon: ["gray/200", "gray/800"]
2515
+ }
2465
2516
  },
2466
2517
  code: {
2467
- bg: ["50/0.5", "950/0.5"],
2468
- fg: ["200/0.6", "900/0.6"]
2518
+ bg: ["50", "950"],
2519
+ fg: ["200", "800"]
2520
+ },
2521
+ fg: ["200", "800"],
2522
+ icon: ["200", "800"],
2523
+ kbd: {
2524
+ bg: ["white", "black"],
2525
+ fg: ["200", "800"],
2526
+ border: ["100", "900"]
2527
+ },
2528
+ link: {
2529
+ fg: ["200", "800"]
2530
+ },
2531
+ muted: {
2532
+ fg: ["200", "800"]
2469
2533
  }
2470
2534
  }
2471
2535
  }
@@ -2481,14 +2545,14 @@ const defaultColorTokens = {
2481
2545
  muted: {
2482
2546
  bg: ["50", "950"]
2483
2547
  },
2484
- placeholder: ["400", "600/0.5"]
2548
+ placeholder: ["400", "600 50%"]
2485
2549
  },
2486
2550
  hovered: {
2487
- border: ["300", "800"]
2551
+ border: ["300", "700"]
2488
2552
  },
2489
2553
  readOnly: {
2490
- border: ["200/0", "900/0"],
2491
- bg: ["100", "950"],
2554
+ bg: ["50", "950"],
2555
+ border: ["200", "800"],
2492
2556
  fg: ["800", "200"]
2493
2557
  },
2494
2558
  disabled: {
@@ -2507,52 +2571,40 @@ const defaultColorTokens = {
2507
2571
  "*": {
2508
2572
  "*": {
2509
2573
  _blend: ["multiply", "screen"],
2510
- bg: ["white", "black"],
2511
- fg: ["800", "200"],
2512
- icon: ["700/0.7", "300/0.7"],
2513
- avatar: {
2574
+ accent: {
2575
+ fg: ["purple/700 70%", "purple/300 70%"]
2576
+ },
2577
+ badge: {
2514
2578
  "*": {
2515
- _blend: ["screen", "multiply"],
2516
- bg: ["500", "400"],
2517
- fg: ["white", "black"]
2579
+ bg: ["100", "900"],
2580
+ fg: ["600", "400"],
2581
+ dot: ["500", "500"],
2582
+ icon: ["500", "500"]
2518
2583
  }
2519
- // yellow: {bg: ['600', '400']},
2520
- // green: {bg: ['600', '400']},
2521
- // cyan: {bg: ['600', '400']},
2522
2584
  },
2585
+ bg: ["white", "black"],
2523
2586
  border: ["200", "800"],
2524
- muted: {
2587
+ code: {
2525
2588
  bg: ["50", "950"],
2526
- fg: ["700", "300"]
2589
+ fg: ["600", "400"]
2527
2590
  },
2528
- accent: {
2529
- fg: ["purple/600", "purple/400"]
2591
+ fg: ["700", "300"],
2592
+ icon: ["700 75%", "300 75%"],
2593
+ kbd: {
2594
+ bg: ["white", "black"],
2595
+ fg: ["600", "400"],
2596
+ border: ["200", "800"]
2530
2597
  },
2531
2598
  link: {
2532
- fg: ["blue/700", "blue/300"]
2599
+ fg: ["blue/700 70%", "blue/300 70%"]
2533
2600
  },
2534
- code: {
2601
+ muted: {
2535
2602
  bg: ["100", "950"],
2536
- fg: ["700", "300"]
2603
+ fg: ["700 75%", "300 75%"]
2537
2604
  },
2538
2605
  skeleton: {
2539
2606
  from: ["100", "900"],
2540
- to: ["100/0.5", "900/0.5"]
2541
- },
2542
- badge: {
2543
- "*": {
2544
- // _blend: ['multiply', 'screen'],
2545
- bg: ["100", "900"],
2546
- fg: ["600", "200"],
2547
- dot: ["300", "700"],
2548
- icon: ["600", "400"]
2549
- }
2550
- },
2551
- kbd: {
2552
- // _blend: ['multiply', 'screen'],
2553
- bg: ["white", "black"],
2554
- fg: ["600", "400"],
2555
- border: ["200", "800"]
2607
+ to: ["100 50%", "900 50%"]
2556
2608
  }
2557
2609
  },
2558
2610
  hovered: {
@@ -2563,127 +2615,129 @@ const defaultColorTokens = {
2563
2615
  },
2564
2616
  selected: {
2565
2617
  _blend: ["screen", "multiply"],
2566
- bg: ["500", "400"],
2567
- fg: ["white", "black"],
2568
- icon: ["200", "800"],
2618
+ accent: {
2619
+ fg: ["purple/300", "purple/700"]
2620
+ },
2569
2621
  avatar: {
2570
2622
  "*": {
2571
2623
  _blend: ["multiply", "screen"],
2572
2624
  bg: ["white", "black"],
2573
2625
  fg: ["black", "white"]
2574
2626
  }
2575
- // magenta: {_hue: 'green'},
2576
- // yellow: {bg: ['600', '400']},
2577
- // green: {bg: ['600', '400']},
2578
- // cyan: {bg: ['600', '400']},
2579
2627
  },
2580
2628
  badge: {
2581
2629
  "*": {
2582
- // _blend: ['multiply', 'screen'],
2583
- // _blend: ['screen', 'multiply'],
2584
- bg: ["700", "300"],
2585
- fg: ["white", "black"]
2630
+ bg: ["900", "100"],
2631
+ fg: ["400", "600"],
2632
+ dot: ["500", "500"],
2633
+ icon: ["500", "500"]
2586
2634
  }
2587
2635
  },
2588
- border: ["500/0.2", "400/0.2"],
2589
- muted: {
2590
- bg: ["900", "50"],
2591
- fg: ["200", "800"]
2592
- },
2593
- accent: {
2594
- fg: ["purple/200", "purple/800"]
2636
+ bg: ["500", "400"],
2637
+ border: ["500 20%", "400 20%"],
2638
+ code: {
2639
+ bg: ["500 20%", "400 20%"],
2640
+ fg: ["200", "600"]
2595
2641
  },
2642
+ fg: ["white", "black"],
2643
+ icon: ["100 70%", "900 70%"],
2596
2644
  kbd: {
2597
- bg: ["black/0", "white/0"],
2598
- fg: ["white", "black"],
2599
- border: ["gray/700", "gray/300"]
2645
+ bg: ["black", "white"],
2646
+ fg: ["200", "600"],
2647
+ border: ["800", "200"]
2600
2648
  },
2601
2649
  link: {
2602
- fg: ["blue/200", "blue/800"]
2650
+ fg: ["blue/200", "blue/600"]
2603
2651
  },
2604
- code: {
2605
- bg: ["500/0.2", "400/0.2"],
2606
- fg: ["200", "700"]
2652
+ muted: {
2653
+ bg: ["950", "50"],
2654
+ fg: ["100 70%", "900 70%"]
2607
2655
  },
2608
2656
  skeleton: {
2609
2657
  from: ["900", "100"],
2610
- to: ["900/0.5", "100/0.5"]
2658
+ to: ["900 50%", "100 50%"]
2611
2659
  }
2612
- // badge: {
2613
- // '*': {
2614
- // _blend: ['multiply', 'screen'],
2615
- // bg: ['900', '100'],
2616
- // fg: ['white', 'black'],
2617
- // dot: ['700', '300'],
2618
- // icon: ['400', '600'],
2619
- // },
2620
- // },
2621
2660
  },
2622
2661
  disabled: {
2662
+ _hue: "gray",
2663
+ accent: {
2664
+ fg: ["200", "800"]
2665
+ },
2666
+ badge: {
2667
+ "*": {
2668
+ _hue: "gray",
2669
+ bg: ["50", "950"],
2670
+ fg: ["gray/200", "gray/800"],
2671
+ dot: ["gray/200", "gray/800"],
2672
+ icon: ["gray/200", "gray/800"]
2673
+ }
2674
+ },
2675
+ border: ["100", "900"],
2676
+ code: {
2677
+ bg: ["50", "950"],
2678
+ fg: ["200", "800"]
2679
+ },
2623
2680
  fg: ["200", "800"],
2624
2681
  icon: ["200", "800"],
2625
- muted: {
2626
- fg: ["200", "800/0.5"]
2627
- },
2628
- accent: {
2629
- fg: ["purple/200", "purple/800/0.5"]
2682
+ kbd: {
2683
+ bg: ["white", "black"],
2684
+ fg: ["200", "800"],
2685
+ border: ["100", "900"]
2630
2686
  },
2631
2687
  link: {
2632
- fg: ["blue/200", "blue/800/0.5"]
2688
+ fg: ["200", "800"]
2633
2689
  },
2634
- code: {
2635
- bg: ["100", "950/0.5"],
2636
- fg: ["200", "800/0.5"]
2690
+ muted: {
2691
+ fg: ["200", "800"]
2637
2692
  }
2638
2693
  }
2639
2694
  },
2640
2695
  default: {
2641
2696
  selected: {
2642
2697
  _hue: "blue"
2643
- // bg: ['500', '400'],
2644
2698
  }
2645
2699
  },
2646
2700
  critical: {
2647
2701
  disabled: {
2648
- bg: ["50/0.5", "950/0.5"]
2702
+ bg: ["50 50%", "950 50%"]
2649
2703
  }
2650
2704
  }
2651
2705
  },
2652
2706
  syntax: {
2653
- atrule: ["purple/700", "purple/400"],
2654
- attrName: ["green/700", "green/400"],
2655
- attrValue: ["yellow/700", "yellow/400"],
2656
- attribute: ["yellow/700", "yellow/400"],
2657
- boolean: ["purple/700", "purple/400"],
2658
- builtin: ["purple/700", "purple/400"],
2659
- cdata: ["yellow/700", "yellow/400"],
2660
- char: ["yellow/700", "yellow/400"],
2661
- class: ["orange/700", "orange/400"],
2662
- className: ["cyan/700", "cyan/400"],
2663
- comment: ["gray/700/0.5", "gray/400/0.5"],
2664
- constant: ["purple/700", "purple/400"],
2665
- deleted: ["red/700", "red/400"],
2666
- entity: ["red/700", "red/400"],
2667
- function: ["green/700", "green/400"],
2668
- hexcode: ["blue/700", "blue/400"],
2669
- id: ["purple/700", "purple/400"],
2670
- important: ["purple/700", "purple/400"],
2671
- inserted: ["yellow/700", "yellow/400"],
2672
- keyword: ["magenta/700", "magenta/400"],
2673
- number: ["purple/700", "purple/400"],
2674
- operator: ["magenta/700", "magenta/400"],
2675
- property: ["blue/700", "blue/400"],
2676
- pseudoClass: ["yellow/700", "yellow/400"],
2677
- pseudoElement: ["yellow/700", "yellow/400"],
2678
- punctuation: ["gray/700", "gray/400"],
2679
- regex: ["blue/700", "blue/400"],
2680
- selector: ["red/700", "red/400"],
2681
- string: ["yellow/700", "yellow/400"],
2682
- symbol: ["purple/700", "purple/400"],
2683
- tag: ["red/700", "red/400"],
2684
- unit: ["orange/700", "orange/400"],
2685
- url: ["red/700", "red/400"],
2686
- variable: ["red/700", "red/400"]
2707
+ atrule: ["purple/600", "purple/400"],
2708
+ attrName: ["green/600", "green/400"],
2709
+ attrValue: ["yellow/600", "yellow/400"],
2710
+ attribute: ["yellow/600", "yellow/400"],
2711
+ boolean: ["purple/600", "purple/400"],
2712
+ builtin: ["purple/600", "purple/400"],
2713
+ cdata: ["yellow/600", "yellow/400"],
2714
+ char: ["yellow/600", "yellow/400"],
2715
+ class: ["orange/600", "orange/400"],
2716
+ className: ["cyan/600", "cyan/400"],
2717
+ comment: ["gray/400", "gray/600"],
2718
+ constant: ["purple/600", "purple/400"],
2719
+ deleted: ["red/600", "red/400"],
2720
+ entity: ["red/600", "red/400"],
2721
+ function: ["green/600", "green/400"],
2722
+ hexcode: ["blue/600", "blue/400"],
2723
+ id: ["purple/600", "purple/400"],
2724
+ important: ["purple/600", "purple/400"],
2725
+ inserted: ["yellow/600", "yellow/400"],
2726
+ keyword: ["magenta/600", "magenta/400"],
2727
+ number: ["purple/600", "purple/400"],
2728
+ operator: ["magenta/600", "magenta/400"],
2729
+ property: ["blue/600", "blue/400"],
2730
+ pseudoClass: ["yellow/600", "yellow/400"],
2731
+ pseudoElement: ["yellow/600", "yellow/400"],
2732
+ punctuation: ["gray/600", "gray/400"],
2733
+ regex: ["blue/600", "blue/400"],
2734
+ selector: ["red/600", "red/400"],
2735
+ string: ["yellow/600", "yellow/400"],
2736
+ symbol: ["purple/600", "purple/400"],
2737
+ tag: ["red/600", "red/400"],
2738
+ unit: ["orange/600", "orange/400"],
2739
+ url: ["red/600", "red/400"],
2740
+ variable: ["red/600", "red/400"]
2687
2741
  }
2688
2742
  };
2689
2743
  function isRecord(value) {
@@ -3822,8 +3876,13 @@ function renderColorValue(str, options) {
3822
3876
  };
3823
3877
  try {
3824
3878
  hex = mixThemeColor(hex, mixOptions);
3879
+ if (bg && node.mix !== void 0) {
3880
+ const from = hexToRgb(bg);
3881
+ const to = hexToRgb(hex);
3882
+ hex = rgbToHex(mix(from, to, node.mix));
3883
+ }
3825
3884
  } catch (err) {
3826
- console.log("could not blend", hex, mixOptions);
3885
+ console.warn("could not blend", hex, mixOptions);
3827
3886
  throw err;
3828
3887
  }
3829
3888
  if (hex === "#aN") {
@@ -4075,10 +4134,9 @@ function renderThemeColorBadgeColor(value, options) {
4075
4134
  colorPalette
4076
4135
  };
4077
4136
  return {
4078
- // _blend: blendMode,
4079
4137
  bg,
4080
- fg: renderColorValue(value.fg, colorOptions),
4081
4138
  dot: renderColorValue(value.dot, colorOptions),
4139
+ fg: renderColorValue(value.fg, colorOptions),
4082
4140
  icon: renderColorValue(value.icon, colorOptions)
4083
4141
  };
4084
4142
  }
@@ -4137,7 +4195,7 @@ function renderThemeColorState(value, options) {
4137
4195
  blendMode
4138
4196
  }),
4139
4197
  badge: renderThemeColorBadge(value.badge, {
4140
- baseBg,
4198
+ baseBg: bg,
4141
4199
  colorPalette,
4142
4200
  blendMode
4143
4201
  }),
@@ -4323,6 +4381,7 @@ function getScopedTheme(themeProp, scheme, tone) {
4323
4381
  layer: layer_v0,
4324
4382
  v2: {
4325
4383
  ...v2,
4384
+ _resolved: true,
4326
4385
  color: color_v2,
4327
4386
  layer: layer_v2
4328
4387
  }
@@ -4345,7 +4404,6 @@ function _setCachedTheme(rootTheme, scheme, tone, theme) {
4345
4404
  const toneCache = schemeCache.get(tone);
4346
4405
  toneCache.set(rootTheme, theme);
4347
4406
  }
4348
- const defaultTheme = buildTheme();
4349
4407
  exports.COLOR_CONFIG_AVATAR_COLORS = COLOR_CONFIG_AVATAR_COLORS;
4350
4408
  exports.COLOR_CONFIG_BLEND_KEYS = COLOR_CONFIG_BLEND_KEYS;
4351
4409
  exports.COLOR_CONFIG_CARD_KEYS = COLOR_CONFIG_CARD_KEYS;
@@ -4361,11 +4419,11 @@ exports.THEME_COLOR_BUTTON_MODES = THEME_COLOR_BUTTON_MODES;
4361
4419
  exports.THEME_COLOR_CARD_TONES = THEME_COLOR_CARD_TONES;
4362
4420
  exports.THEME_COLOR_INPUT_MODES = THEME_COLOR_INPUT_MODES;
4363
4421
  exports.THEME_COLOR_INPUT_STATES = THEME_COLOR_INPUT_STATES;
4422
+ exports.THEME_COLOR_SCHEMES = THEME_COLOR_SCHEMES;
4364
4423
  exports.THEME_COLOR_STATES = THEME_COLOR_STATES;
4365
4424
  exports.THEME_COLOR_STATE_TONES = THEME_COLOR_STATE_TONES;
4366
4425
  exports.buildTheme = buildTheme;
4367
4426
  exports.createColorTheme = createColorTheme;
4368
- exports.defaultTheme = defaultTheme;
4369
4427
  exports.getContrastRatio = getContrastRatio;
4370
4428
  exports.getScopedTheme = getScopedTheme;
4371
4429
  exports.getTheme_v2 = getTheme_v2;