@sanity/ui 2.0.0-alpha.13 → 2.0.0-alpha.15

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 (34) hide show
  1. package/dist/index.cjs.mjs +27 -0
  2. package/dist/index.d.ts +359 -7
  3. package/dist/index.esm.js +860 -60
  4. package/dist/index.esm.js.map +1 -1
  5. package/dist/index.js +887 -60
  6. package/dist/index.js.map +1 -1
  7. package/package.json +2 -2
  8. package/src/components/dialog/dialog.tsx +4 -2
  9. package/src/theme/_internal/__workshop__/build/story.tsx +288 -0
  10. package/src/theme/_internal/__workshop__/build/theme.ts +3 -0
  11. package/src/theme/_internal/__workshop__/index.ts +14 -0
  12. package/src/theme/_internal/build/buildTheme.test.ts +78 -0
  13. package/src/theme/_internal/build/buildTheme.ts +16 -0
  14. package/src/theme/_internal/build/colorTheme/buildColorTheme.test.ts +185 -0
  15. package/src/theme/_internal/build/colorTheme/buildColorTheme.ts +164 -0
  16. package/src/theme/_internal/build/colorTheme/renderColorTheme.ts +242 -0
  17. package/src/theme/_internal/build/colorTheme/resolveColorTokens.ts +121 -0
  18. package/src/theme/_internal/build/defaults/colorPalette.ts +8 -0
  19. package/src/theme/_internal/build/defaults/colorTokens.ts +147 -0
  20. package/src/theme/_internal/build/helpers.ts +65 -0
  21. package/src/theme/_internal/build/index.ts +1 -0
  22. package/src/theme/_internal/config/helpers.ts +47 -0
  23. package/src/theme/_internal/config/index.ts +3 -0
  24. package/src/theme/_internal/config/token/index.ts +2 -0
  25. package/src/theme/_internal/config/token/parseTokenKey.test.ts +72 -0
  26. package/src/theme/_internal/config/token/parseTokenKey.ts +88 -0
  27. package/src/theme/_internal/config/token/parseTokenValue.test.ts +45 -0
  28. package/src/theme/_internal/config/token/parseTokenValue.ts +123 -0
  29. package/src/theme/_internal/config/types.ts +137 -0
  30. package/src/theme/_internal/constants.ts +48 -0
  31. package/src/theme/_internal/helpers.ts +19 -0
  32. package/src/theme/_internal/index.ts +5 -0
  33. package/src/theme/_internal/types.ts +91 -0
  34. package/src/theme/index.ts +1 -0
package/dist/index.esm.js CHANGED
@@ -2,7 +2,7 @@ import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
2
2
  import { useMemo, useState, useRef, useEffect, createContext, useContext, useSyncExternalStore, useLayoutEffect, forwardRef, useId, useCallback, cloneElement, isValidElement, createElement, Component, memo, useReducer, Children, Fragment as Fragment$1, startTransition } from 'react';
3
3
  import ReactIs, { isElement as isElement$1, isFragment, isValidElementType } from 'react-is';
4
4
  import styled, { ThemeProvider as ThemeProvider$1, useTheme as useTheme$1, css, keyframes } from 'styled-components';
5
- import { white as white$1, black as black$1, hues } from '@sanity/color';
5
+ import { color as color$1, white as white$1, black as black$1, hues } from '@sanity/color';
6
6
  import { SpinnerIcon, CheckmarkIcon, RemoveIcon, SelectIcon, CloseIcon, ChevronDownIcon, ChevronRightIcon, ToggleArrowRightIcon } from '@sanity/icons';
7
7
  import Refractor from 'react-refractor';
8
8
  import { detectOverflow, flip, offset, shift, arrow, hide, useFloating, autoUpdate, size as size$2 } from '@floating-ui/react-dom';
@@ -831,10 +831,166 @@ function useGlobalKeyDown(onKeyDown) {
831
831
  return () => removeEventListener("keydown", onKeyDown);
832
832
  }, [onKeyDown]);
833
833
  }
834
+ const COLOR_HUES = ["gray", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "green"];
835
+ const COLOR_TINTS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
836
+ const COLOR_BASE_TONES = ["transparent", "default", "primary",
837
+ // todo: rename to `accent`
838
+ "positive", "caution", "critical"];
839
+ const COLOR_STATE_TONES = ["default", "primary",
840
+ // todo: rename to `accent`
841
+ "positive", "caution", "critical"];
842
+ const COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"];
843
+ const COLOR_BUTTON_MODES = ["default", "ghost", "bleed"];
844
+ const COLOR_BLEND_MODES = ["multiply", "screen"];
845
+ const defaultColorTokens = {
846
+ "*": {
847
+ _blend: ["multiply", "screen"],
848
+ bg: ["50", "950"],
849
+ fg: ["800", "200"],
850
+ border: ["200", "800"],
851
+ focusRing: ["cyan/500", "cyan/500"],
852
+ shadow: {
853
+ outline: ["500/0.25", "400/0.3"],
854
+ umbra: ["500/0.1", "black/0.4"],
855
+ penumbra: ["500/0.07", "black/0.28"],
856
+ ambient: ["500/0.06", "black/0.24"]
857
+ },
858
+ skeleton: {
859
+ from: ["100", "900"],
860
+ to: ["100/0.5", "900/0.5"]
861
+ }
862
+ },
863
+ transparent: {
864
+ bg: ["50", "black"],
865
+ fg: ["600", "400"]
866
+ },
867
+ default: {
868
+ bg: ["white", "950"],
869
+ fg: ["black", "200"]
870
+ },
871
+ primary: {
872
+ _hue: "cyan"
873
+ },
874
+ positive: {
875
+ _hue: "cyan"
876
+ },
877
+ caution: {
878
+ _hue: "yellow"
879
+ },
880
+ critical: {
881
+ _hue: "red"
882
+ },
883
+ button: {
884
+ "*": {
885
+ default: {
886
+ "*": {
887
+ _blend: ["screen", "multiply"],
888
+ bg: ["500", "400"],
889
+ bg2: ["950", "50"],
890
+ border: ["500/0", "400/0"],
891
+ muted: {
892
+ fg: ["200", "700"]
893
+ }
894
+ },
895
+ hovered: {
896
+ bg: ["600", "300"],
897
+ border: ["600/0", "300/0"]
898
+ },
899
+ pressed: {
900
+ bg: ["700", "200"]
901
+ },
902
+ selected: {
903
+ bg: ["700", "200"]
904
+ },
905
+ disabled: {
906
+ _hue: "gray",
907
+ bg: ["200", "900"]
908
+ }
909
+ },
910
+ ghost: {
911
+ "*": {
912
+ _blend: ["multiply", "screen"],
913
+ bg: ["white", "black"],
914
+ bg2: ["50", "950"],
915
+ fg: ["600", "400"],
916
+ border: ["200", "800"],
917
+ muted: {
918
+ fg: ["600/0.6", "400/0.6"]
919
+ }
920
+ },
921
+ hovered: {
922
+ bg: ["50", "950"],
923
+ fg: ["700", "300"]
924
+ },
925
+ pressed: {
926
+ bg: ["100", "900"],
927
+ fg: ["800", "200"]
928
+ },
929
+ selected: {
930
+ bg: ["100", "900"],
931
+ fg: ["800", "200"]
932
+ },
933
+ disabled: {
934
+ _hue: "gray",
935
+ fg: ["200", "900"],
936
+ border: ["100", "950"]
937
+ }
938
+ },
939
+ bleed: {
940
+ "*": {
941
+ _blend: ["multiply", "screen"],
942
+ bg: ["white", "black"],
943
+ bg2: ["50", "950"],
944
+ fg: ["600", "400"],
945
+ border: ["white/0", "black/0"],
946
+ muted: {
947
+ fg: ["600/0.6", "400/0.6"]
948
+ }
949
+ },
950
+ hovered: {
951
+ bg: ["50", "950"],
952
+ fg: ["700", "300"]
953
+ },
954
+ pressed: {
955
+ bg: ["100", "900"],
956
+ fg: ["800", "200"]
957
+ },
958
+ selected: {
959
+ bg: ["100", "900"],
960
+ fg: ["800", "200"]
961
+ },
962
+ disabled: {
963
+ _hue: "gray",
964
+ fg: ["200", "900"]
965
+ }
966
+ }
967
+ },
968
+ default: {
969
+ default: {
970
+ "*": {
971
+ bg: ["900", "200"]
972
+ },
973
+ hovered: {
974
+ bg: ["black", "100"]
975
+ },
976
+ pressed: {
977
+ bg: ["900", "200"]
978
+ },
979
+ selected: {
980
+ bg: ["black", "200"]
981
+ },
982
+ disabled: {
983
+ _hue: "gray",
984
+ bg: ["200", "900"]
985
+ }
986
+ }
987
+ }
988
+ }
989
+ };
834
990
  function multiplyChannel(b, s) {
835
991
  return b * s;
836
992
  }
837
- function multiply$1(b, s) {
993
+ function multiply$2(b, s) {
838
994
  return {
839
995
  r: Math.round(clamp$1(multiplyChannel(b.r / 255, s.r / 255) * 255)),
840
996
  g: Math.round(clamp$1(multiplyChannel(b.g / 255, s.g / 255) * 255)),
@@ -847,7 +1003,7 @@ function clamp$1(num) {
847
1003
  function screenChannel(b, s) {
848
1004
  return b + s - b * s;
849
1005
  }
850
- function screen$1(b, s) {
1006
+ function screen$2(b, s) {
851
1007
  return {
852
1008
  r: Math.round(clamp(screenChannel(b.r / 255, s.r / 255) * 255)),
853
1009
  g: Math.round(clamp(screenChannel(b.g / 255, s.g / 255) * 255)),
@@ -1009,6 +1165,649 @@ function rgba(color, a) {
1009
1165
  const rgb = parseColor(color);
1010
1166
  return "rgba(".concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ",").concat(a, ")");
1011
1167
  }
1168
+ function isColorBlendModeValue(str) {
1169
+ return COLOR_BLEND_MODES.includes(str);
1170
+ }
1171
+ function isColorHueValue(str) {
1172
+ return COLOR_HUES.includes(str);
1173
+ }
1174
+ function isColorTintValue(str) {
1175
+ return COLOR_TINTS.includes(str);
1176
+ }
1177
+ function isColorButtonMode(str) {
1178
+ return COLOR_BUTTON_MODES.includes(str);
1179
+ }
1180
+ function parseTokenKey(str) {
1181
+ const segments = str.split("/");
1182
+ const segment0 = segments.shift() || "";
1183
+ if (isColorConfigBaseTone(segment0)) {
1184
+ const key = segments.join("/");
1185
+ if (isColorConfigBaseKey(key)) {
1186
+ return {
1187
+ type: "base",
1188
+ tone: segment0,
1189
+ key
1190
+ };
1191
+ }
1192
+ if (isColorConfigBlendKey(key)) {
1193
+ return {
1194
+ type: "base",
1195
+ tone: segment0,
1196
+ key
1197
+ };
1198
+ }
1199
+ }
1200
+ if (segment0 === "button") {
1201
+ const segment1 = segments.shift() || "";
1202
+ if (isColorConfigStateTone(segment1)) {
1203
+ const segment2 = segments.shift() || "";
1204
+ if (isColorButtonMode(segment2)) {
1205
+ const key = segments.join("/");
1206
+ if (isColorConfigStateKey(key)) {
1207
+ return {
1208
+ type: "button",
1209
+ tone: segment1,
1210
+ mode: segment2,
1211
+ key
1212
+ };
1213
+ }
1214
+ if (isColorConfigBlendKey(key)) {
1215
+ return {
1216
+ type: "button",
1217
+ tone: segment1,
1218
+ mode: segment2,
1219
+ key
1220
+ };
1221
+ }
1222
+ }
1223
+ }
1224
+ }
1225
+ return void 0;
1226
+ }
1227
+ function parseTokenValue(str) {
1228
+ const segments = str.split("/");
1229
+ const segment0 = segments.shift() || "";
1230
+ if (isColorTintValue(segment0)) {
1231
+ const tint = segment0;
1232
+ const segment1 = segments.shift() || "";
1233
+ if (isColorOpacityValue(segment1)) {
1234
+ const opacity = Number(segment1);
1235
+ return {
1236
+ type: "color",
1237
+ tint,
1238
+ opacity
1239
+ };
1240
+ }
1241
+ return {
1242
+ type: "color",
1243
+ tint
1244
+ };
1245
+ }
1246
+ if (isColorValue(segment0)) {
1247
+ const key = segment0;
1248
+ const segment1 = segments.shift() || "";
1249
+ if (isColorOpacityValue(segment1)) {
1250
+ const opacity = Number(segment1);
1251
+ return {
1252
+ type: "color",
1253
+ key,
1254
+ opacity
1255
+ };
1256
+ }
1257
+ return {
1258
+ type: "color",
1259
+ key
1260
+ };
1261
+ }
1262
+ if (isColorHueValue(segment0)) {
1263
+ const hue = segment0;
1264
+ const segment1 = segments.shift() || "";
1265
+ if (isColorTintValue(segment1)) {
1266
+ const tint = segment1;
1267
+ const segment2 = segments.shift() || "";
1268
+ if (isColorOpacityValue(segment2)) {
1269
+ const opacity = Number(segment2);
1270
+ return {
1271
+ type: "color",
1272
+ key: "".concat(hue, "/").concat(tint),
1273
+ hue,
1274
+ tint,
1275
+ opacity
1276
+ };
1277
+ }
1278
+ return {
1279
+ type: "color",
1280
+ key: "".concat(hue, "/").concat(tint),
1281
+ hue,
1282
+ tint
1283
+ };
1284
+ }
1285
+ return {
1286
+ type: "hue",
1287
+ value: "".concat(hue)
1288
+ };
1289
+ }
1290
+ if (isColorOpacityValue(segment0)) {
1291
+ const opacity = Number(segment0);
1292
+ return {
1293
+ type: "color",
1294
+ opacity
1295
+ };
1296
+ }
1297
+ if (isColorBlendModeValue(segment0)) {
1298
+ const value = segment0;
1299
+ return {
1300
+ type: "blendMode",
1301
+ value
1302
+ };
1303
+ }
1304
+ return void 0;
1305
+ }
1306
+ const COLOR_CONFIG_BASE_TONES = ["*", ...COLOR_BASE_TONES];
1307
+ const COLOR_CONFIG_STATE_TONES = ["*", ...COLOR_STATE_TONES];
1308
+ const COLOR_CONFIG_BASE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "link/fg", "code/bg", "code/fg", "shadow/outline", "shadow/umbra", "shadow/penumbra", "shadow/ambient", "skeleton/from", "skeleton/to"];
1309
+ const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to"];
1310
+ const COLOR_CONFIG_BLEND_KEYS = ["_blend"];
1311
+ function isColorConfigBaseTone(str) {
1312
+ return COLOR_CONFIG_BASE_TONES.includes(str);
1313
+ }
1314
+ function isColorConfigBaseKey(str) {
1315
+ return COLOR_CONFIG_BASE_KEYS.includes(str);
1316
+ }
1317
+ function isColorConfigStateKey(str) {
1318
+ return COLOR_CONFIG_STATE_KEYS.includes(str);
1319
+ }
1320
+ function isColorConfigStateTone(str) {
1321
+ return COLOR_CONFIG_STATE_TONES.includes(str);
1322
+ }
1323
+ function isColorConfigBlendKey(str) {
1324
+ return COLOR_CONFIG_BLEND_KEYS.includes(str);
1325
+ }
1326
+ function isColorTokenValue(str) {
1327
+ var _a, _b;
1328
+ return ((_a = parseTokenValue(str)) == null ? void 0 : _a.type) === "color" || ((_b = parseTokenValue(str)) == null ? void 0 : _b.type) === "hue";
1329
+ }
1330
+ function isColorValue(str) {
1331
+ return str === "black" || str === "white";
1332
+ }
1333
+ function isColorOpacityValue(str) {
1334
+ return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
1335
+ }
1336
+ function resolveColorTokenValue(context, value) {
1337
+ const {
1338
+ hue,
1339
+ scheme
1340
+ } = context;
1341
+ const node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
1342
+ if (!node || node.type !== "color") {
1343
+ throw new Error("Invalid color token: ".concat(value[0]));
1344
+ }
1345
+ return compileColorTokenValue({
1346
+ ...node,
1347
+ hue: node.hue || hue
1348
+ });
1349
+ }
1350
+ function compileColorTokenValue(node) {
1351
+ let key = "";
1352
+ if (node.key === "black" || node.key === "white") {
1353
+ key = node.key;
1354
+ } else {
1355
+ key = "".concat(node.hue, "/").concat(node.tint);
1356
+ }
1357
+ if (node.opacity !== void 0) {
1358
+ key += "/".concat(node.opacity);
1359
+ }
1360
+ return key;
1361
+ }
1362
+ function multiply$1(bg, fg) {
1363
+ const b = parseColor(bg);
1364
+ const s = parseColor(fg);
1365
+ const hex = rgbToHex(multiply$2(b, s));
1366
+ if (s.a !== void 0) {
1367
+ return rgba(hex, s.a);
1368
+ }
1369
+ return hex;
1370
+ }
1371
+ function screen$1(bg, fg) {
1372
+ const b = parseColor(bg);
1373
+ const s = parseColor(fg);
1374
+ const hex = rgbToHex(screen$2(b, s));
1375
+ if (s.a !== void 0) {
1376
+ return rgba(hex, s.a);
1377
+ }
1378
+ return hex;
1379
+ }
1380
+ function resolveColorTokens(sparseTokens) {
1381
+ const denseTokens = {
1382
+ ...sparseTokens
1383
+ };
1384
+ for (const tone of COLOR_BASE_TONES) {
1385
+ denseTokens[tone] = resolveBaseColorTones(sparseTokens, tone);
1386
+ }
1387
+ denseTokens.button = resolveButtonColorTokens(sparseTokens);
1388
+ return denseTokens;
1389
+ }
1390
+ function resolveBaseColorTones(sparseTokens, tone) {
1391
+ const spec0 = sparseTokens == null ? void 0 : sparseTokens[tone];
1392
+ const spec1 = sparseTokens == null ? void 0 : sparseTokens["*"];
1393
+ return {
1394
+ ...spec1,
1395
+ ...spec0,
1396
+ shadow: {
1397
+ ...(spec1 == null ? void 0 : spec1.shadow),
1398
+ ...(spec0 == null ? void 0 : spec0.shadow)
1399
+ },
1400
+ skeleton: {
1401
+ ...(spec1 == null ? void 0 : spec1.skeleton),
1402
+ ...(spec0 == null ? void 0 : spec0.skeleton)
1403
+ }
1404
+ };
1405
+ }
1406
+ function resolveButtonColorTokens(sparseTokens) {
1407
+ const tokens = {};
1408
+ for (const tone of COLOR_STATE_TONES) {
1409
+ tokens[tone] = resolveButtonToneColorTokens(sparseTokens, tone);
1410
+ }
1411
+ return tokens;
1412
+ }
1413
+ function resolveButtonToneColorTokens(sparseTokens, tone) {
1414
+ var _a, _b;
1415
+ const tokens = {
1416
+ ...((_a = sparseTokens.button) == null ? void 0 : _a[tone]),
1417
+ ...((_b = sparseTokens.button) == null ? void 0 : _b["*"])
1418
+ };
1419
+ for (const mode of COLOR_BUTTON_MODES) {
1420
+ tokens[mode] = resolveButtonModeColorTokens(sparseTokens, tone, mode);
1421
+ }
1422
+ return tokens;
1423
+ }
1424
+ function resolveButtonModeColorTokens(sparseTokens, tone, mode) {
1425
+ var _a, _b, _c, _d;
1426
+ const spec0 = (_b = (_a = sparseTokens.button) == null ? void 0 : _a[tone]) == null ? void 0 : _b[mode];
1427
+ const spec1 = (_d = (_c = sparseTokens.button) == null ? void 0 : _c["*"]) == null ? void 0 : _d[mode];
1428
+ const tokens = {
1429
+ ...spec1,
1430
+ ...spec0
1431
+ };
1432
+ for (const state of COLOR_STATES) {
1433
+ tokens[state] = resolveButtonStateColorTokens(sparseTokens, tone, mode, state);
1434
+ }
1435
+ return tokens;
1436
+ }
1437
+ function resolveButtonStateColorTokens(tokens, tone, mode, state) {
1438
+ var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
1439
+ const spec0 = (_c = (_b = (_a = tokens == null ? void 0 : tokens.button) == null ? void 0 : _a[tone]) == null ? void 0 : _b[mode]) == null ? void 0 : _c[state];
1440
+ const spec1 = (_f = (_e = (_d = tokens == null ? void 0 : tokens.button) == null ? void 0 : _d[tone]) == null ? void 0 : _e[mode]) == null ? void 0 : _f["*"];
1441
+ const spec2 = (_i = (_h = (_g = tokens == null ? void 0 : tokens.button) == null ? void 0 : _g["*"]) == null ? void 0 : _h[mode]) == null ? void 0 : _i[state];
1442
+ const spec3 = (_l = (_k = (_j = tokens == null ? void 0 : tokens.button) == null ? void 0 : _j["*"]) == null ? void 0 : _k[mode]) == null ? void 0 : _l["*"];
1443
+ const hue = (spec0 == null ? void 0 : spec0._hue) || (spec1 == null ? void 0 : spec1._hue) || (spec2 == null ? void 0 : spec2._hue) || (spec3 == null ? void 0 : spec3._hue) || ((_n = (_m = tokens == null ? void 0 : tokens.button) == null ? void 0 : _m[tone]) == null ? void 0 : _n._hue) || ((_o = tokens == null ? void 0 : tokens[tone]) == null ? void 0 : _o._hue);
1444
+ return {
1445
+ ...spec3,
1446
+ ...spec2,
1447
+ ...spec1,
1448
+ ...spec0,
1449
+ _hue: hue,
1450
+ muted: {
1451
+ ...(spec3 == null ? void 0 : spec3.muted),
1452
+ ...(spec2 == null ? void 0 : spec2.muted),
1453
+ ...(spec1 == null ? void 0 : spec1.muted),
1454
+ ...(spec0 == null ? void 0 : spec0.muted)
1455
+ },
1456
+ accent: {
1457
+ ...(spec3 == null ? void 0 : spec3.accent),
1458
+ ...(spec2 == null ? void 0 : spec2.accent),
1459
+ ...(spec1 == null ? void 0 : spec1.accent),
1460
+ ...(spec0 == null ? void 0 : spec0.accent)
1461
+ },
1462
+ link: {
1463
+ ...(spec3 == null ? void 0 : spec3.link),
1464
+ ...(spec2 == null ? void 0 : spec2.link),
1465
+ ...(spec1 == null ? void 0 : spec1.link),
1466
+ ...(spec0 == null ? void 0 : spec0.link)
1467
+ },
1468
+ code: {
1469
+ ...(spec3 == null ? void 0 : spec3.code),
1470
+ ...(spec2 == null ? void 0 : spec2.code),
1471
+ ...(spec1 == null ? void 0 : spec1.code),
1472
+ ...(spec0 == null ? void 0 : spec0.code)
1473
+ },
1474
+ skeleton: {
1475
+ ...(spec3 == null ? void 0 : spec3.skeleton),
1476
+ ...(spec2 == null ? void 0 : spec2.skeleton),
1477
+ ...(spec1 == null ? void 0 : spec1.skeleton),
1478
+ ...(spec0 == null ? void 0 : spec0.skeleton)
1479
+ }
1480
+ };
1481
+ }
1482
+ function buildColorTheme(options, config) {
1483
+ var _a, _b;
1484
+ const {
1485
+ scheme
1486
+ } = options;
1487
+ const resolvedConfig = {
1488
+ ...config,
1489
+ color: {
1490
+ ...(config == null ? void 0 : config.color),
1491
+ tokens: resolveColorTokens((_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.tokens) != null ? _b : defaultColorTokens)
1492
+ }
1493
+ };
1494
+ return {
1495
+ transparent: buildBaseColorTheme({
1496
+ scheme,
1497
+ tone: "transparent"
1498
+ }, resolvedConfig),
1499
+ default: buildBaseColorTheme({
1500
+ scheme,
1501
+ tone: "default"
1502
+ }, resolvedConfig),
1503
+ primary: buildBaseColorTheme({
1504
+ scheme,
1505
+ tone: "primary"
1506
+ }, resolvedConfig),
1507
+ positive: buildBaseColorTheme({
1508
+ scheme,
1509
+ tone: "positive"
1510
+ }, resolvedConfig),
1511
+ caution: buildBaseColorTheme({
1512
+ scheme,
1513
+ tone: "caution"
1514
+ }, resolvedConfig),
1515
+ critical: buildBaseColorTheme({
1516
+ scheme,
1517
+ tone: "critical"
1518
+ }, resolvedConfig)
1519
+ };
1520
+ }
1521
+ function buildBaseColorTheme(options, config) {
1522
+ var _a, _b, _c, _d, _e, _f, _g, _h;
1523
+ const {
1524
+ scheme,
1525
+ tone
1526
+ } = options;
1527
+ const tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.tokens) == null ? void 0 : _b[tone];
1528
+ const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
1529
+ const context = {
1530
+ hue,
1531
+ scheme
1532
+ };
1533
+ const bg = resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.bg) || ["gray/50", "black"]);
1534
+ const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
1535
+ return {
1536
+ _blend: blendMode[scheme === "light" ? 0 : 1],
1537
+ dark: scheme === "dark",
1538
+ base: {
1539
+ bg,
1540
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["black", "white"]),
1541
+ border: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.border) || ["black", "white"]),
1542
+ focusRing: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.focusRing) || ["black", "white"]),
1543
+ shadow: {
1544
+ outline: resolveColorTokenValue(context, ((_c = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _c.outline) || ["500/0.2", "500/0.2"]),
1545
+ umbra: resolveColorTokenValue(context, ((_d = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _d.umbra) || ["500/0.2", "500/0.2"]),
1546
+ penumbra: resolveColorTokenValue(context, ((_e = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _e.penumbra) || ["500/0.2", "500/0.2"]),
1547
+ ambient: resolveColorTokenValue(context, ((_f = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _f.ambient) || ["500/0.2", "500/0.2"])
1548
+ },
1549
+ skeleton: {
1550
+ from: resolveColorTokenValue(context, ((_g = tokens == null ? void 0 : tokens.skeleton) == null ? void 0 : _g.from) || ["500/0.2", "500/0.2"]),
1551
+ to: resolveColorTokenValue(context, ((_h = tokens == null ? void 0 : tokens.skeleton) == null ? void 0 : _h.to) || ["500/0.2", "500/0.2"])
1552
+ }
1553
+ },
1554
+ button: buildButtonColorTheme({
1555
+ scheme
1556
+ }, config)
1557
+ };
1558
+ }
1559
+ function buildButtonColorTheme(options, config) {
1560
+ const {
1561
+ scheme
1562
+ } = options;
1563
+ const tones = COLOR_STATE_TONES.map(tone => {
1564
+ return {
1565
+ [tone]: buildButtonColorToneTheme({
1566
+ scheme,
1567
+ tone
1568
+ }, config)
1569
+ };
1570
+ });
1571
+ return Object.assign({}, ...tones);
1572
+ }
1573
+ function buildButtonColorToneTheme(options, config) {
1574
+ const {
1575
+ scheme,
1576
+ tone
1577
+ } = options;
1578
+ const modes = COLOR_BUTTON_MODES.map(mode => {
1579
+ return {
1580
+ [mode]: buildButtonModeColorTheme({
1581
+ mode,
1582
+ scheme,
1583
+ tone
1584
+ }, config)
1585
+ };
1586
+ });
1587
+ return Object.assign({}, ...modes);
1588
+ }
1589
+ function buildButtonModeColorTheme(options, config) {
1590
+ const {
1591
+ mode,
1592
+ scheme,
1593
+ tone
1594
+ } = options;
1595
+ const states = COLOR_STATES.map(state => {
1596
+ return {
1597
+ [state]: buildButtonStateColorTheme({
1598
+ mode,
1599
+ tone,
1600
+ scheme,
1601
+ state
1602
+ }, config)
1603
+ };
1604
+ });
1605
+ return Object.assign({}, ...states);
1606
+ }
1607
+ function buildButtonStateColorTheme(options, config) {
1608
+ var _a, _b, _c, _d, _e;
1609
+ const {
1610
+ mode,
1611
+ tone,
1612
+ scheme,
1613
+ state
1614
+ } = options;
1615
+ const tokens = (_e = (_d = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.tokens) == null ? void 0 : _b.button) == null ? void 0 : _c[tone]) == null ? void 0 : _d[mode]) == null ? void 0 : _e[state];
1616
+ const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
1617
+ const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
1618
+ const context = {
1619
+ hue,
1620
+ scheme
1621
+ };
1622
+ return {
1623
+ _blend: blendMode[scheme === "light" ? 0 : 1],
1624
+ bg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.bg) || ["500", "400"]),
1625
+ bg2: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.bg2) || ["500", "400"]),
1626
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["white", "black"]),
1627
+ border: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.border) || ["500", "400"]),
1628
+ muted: {
1629
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["500", "400"])
1630
+ },
1631
+ accent: {
1632
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["500", "400"])
1633
+ },
1634
+ link: {
1635
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["500", "400"])
1636
+ },
1637
+ code: {
1638
+ bg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.bg) || ["500", "400"]),
1639
+ fg: resolveColorTokenValue(context, (tokens == null ? void 0 : tokens.fg) || ["500", "400"])
1640
+ }
1641
+ };
1642
+ }
1643
+ const defaultColorPalette = {
1644
+ ...color$1,
1645
+ black: "#000000"
1646
+ };
1647
+ function renderColorTheme(value, config) {
1648
+ var _a, _b;
1649
+ const colorPalette = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.palette) != null ? _b : defaultColorPalette;
1650
+ return {
1651
+ light: renderColorScheme(colorPalette, value.light),
1652
+ dark: renderColorScheme(colorPalette, value.dark)
1653
+ };
1654
+ }
1655
+ function renderColorScheme(colorPalette, value) {
1656
+ const toneEntries = Object.entries(value);
1657
+ const [, transparentTone] = toneEntries.find(_ref4 => {
1658
+ let [k] = _ref4;
1659
+ return k === "transparent";
1660
+ });
1661
+ const [, defaultTone] = toneEntries.find(_ref5 => {
1662
+ let [k] = _ref5;
1663
+ return k === "default";
1664
+ });
1665
+ const renderedTransparentTone = renderColorBase(colorPalette, transparentTone, transparentTone._blend === "multiply" ? "#ffffff" : "#000000");
1666
+ const renderedDefaultTone = renderColorBase(colorPalette, defaultTone, defaultTone._blend === "multiply" ? "#ffffff" : "#000000");
1667
+ return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(_ref6 => {
1668
+ let [k] = _ref6;
1669
+ return k !== "default" && k !== "transparent";
1670
+ }).map(_ref7 => {
1671
+ let [k, v] = _ref7;
1672
+ return [k, renderColorBase(colorPalette, v, renderedDefaultTone.base.bg)];
1673
+ })]);
1674
+ }
1675
+ function renderColorBase(colorPalette, value, bg) {
1676
+ const nestedBg = renderColorValue(colorPalette, bg, value._blend, value.base.bg);
1677
+ return {
1678
+ _blend: value._blend,
1679
+ dark: value.dark,
1680
+ base: {
1681
+ bg: nestedBg,
1682
+ fg: renderColorValue(colorPalette, nestedBg, value._blend, value.base.fg),
1683
+ border: renderColorValue(colorPalette, nestedBg, value._blend, value.base.border),
1684
+ focusRing: renderColorValue(colorPalette, nestedBg, value._blend, value.base.focusRing),
1685
+ shadow: {
1686
+ outline: renderColorValue(colorPalette, nestedBg, value._blend, value.base.shadow.outline),
1687
+ umbra: renderColorValue(colorPalette, nestedBg, value._blend, value.base.shadow.umbra),
1688
+ penumbra: renderColorValue(colorPalette, nestedBg, value._blend, value.base.shadow.penumbra),
1689
+ ambient: renderColorValue(colorPalette, nestedBg, value._blend, value.base.shadow.ambient)
1690
+ },
1691
+ skeleton: {
1692
+ from: renderColorValue(colorPalette, nestedBg, value._blend, value.base.skeleton.from),
1693
+ to: renderColorValue(colorPalette, nestedBg, value._blend, value.base.skeleton.to)
1694
+ }
1695
+ },
1696
+ button: renderButtonColorTheme(colorPalette, nestedBg, value._blend, value.button)
1697
+ };
1698
+ }
1699
+ function renderButtonColorTheme(colorPalette, bg, baseBlendMode, value) {
1700
+ return {
1701
+ default: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.default),
1702
+ primary: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.primary),
1703
+ positive: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.positive),
1704
+ caution: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.caution),
1705
+ critical: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.critical)
1706
+ };
1707
+ }
1708
+ function renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value) {
1709
+ return {
1710
+ default: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.default),
1711
+ ghost: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.ghost),
1712
+ bleed: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.bleed)
1713
+ };
1714
+ }
1715
+ function renderStatesColorTheme(colorPalette, bg, baseBlendMode, value) {
1716
+ return {
1717
+ enabled: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.enabled),
1718
+ hovered: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.hovered),
1719
+ pressed: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.pressed),
1720
+ selected: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.selected),
1721
+ disabled: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.disabled)
1722
+ };
1723
+ }
1724
+ function renderStateColorTheme(colorPalette, baseBg, rootBlendMode, value) {
1725
+ const blendMode = value._blend;
1726
+ const bg = rootBlendMode === "multiply" && value.bg === "white" ? "#ffffff" : rootBlendMode === "screen" && value.bg === "black" ? "#000000" : renderColorValue(colorPalette, rootBlendMode === "multiply" ? "#ffffff" : "#000000", rootBlendMode, value.bg);
1727
+ const blend = rootBlendMode === "multiply" ? multiply$1 : screen$1;
1728
+ const unmixed = {
1729
+ bg2: renderColorValue(colorPalette, bg, blendMode, value.bg2 || value.bg),
1730
+ fg: renderColorValue(colorPalette, bg, blendMode, value.fg),
1731
+ border: renderColorValue(colorPalette, bg, blendMode, value.border),
1732
+ muted: {
1733
+ fg: renderColorValue(colorPalette, bg, blendMode, value.muted.fg)
1734
+ },
1735
+ accent: {
1736
+ fg: renderColorValue(colorPalette, bg, blendMode, value.accent.fg)
1737
+ },
1738
+ link: {
1739
+ fg: renderColorValue(colorPalette, bg, blendMode, value.link.fg)
1740
+ },
1741
+ code: {
1742
+ bg: renderColorValue(colorPalette, bg, blendMode, value.code.bg),
1743
+ fg: renderColorValue(colorPalette, bg, blendMode, value.code.fg)
1744
+ }
1745
+ };
1746
+ return {
1747
+ _blend: blendMode,
1748
+ bg: blend(baseBg, bg),
1749
+ bg2: blend(baseBg, unmixed.bg2),
1750
+ fg: blend(baseBg, unmixed.fg),
1751
+ border: blend(baseBg, unmixed.border),
1752
+ muted: {
1753
+ fg: blend(baseBg, unmixed.muted.fg)
1754
+ },
1755
+ accent: {
1756
+ fg: blend(baseBg, unmixed.accent.fg)
1757
+ },
1758
+ link: {
1759
+ fg: blend(baseBg, unmixed.link.fg)
1760
+ },
1761
+ code: {
1762
+ bg: blend(baseBg, unmixed.code.bg),
1763
+ fg: blend(baseBg, unmixed.code.fg)
1764
+ }
1765
+ };
1766
+ }
1767
+ function renderColorValue(colorPalette, bg, blendMode, str) {
1768
+ const node = parseTokenValue(str);
1769
+ if (!node || node.type !== "color") {
1770
+ throw new Error("Invalid color token value: ".concat(str));
1771
+ }
1772
+ let hex = "";
1773
+ if (node.key === "black") {
1774
+ hex = renderColorHex(colorPalette.black);
1775
+ }
1776
+ if (node.key === "white") {
1777
+ hex = renderColorHex(colorPalette.white);
1778
+ }
1779
+ if (node.hue && node.tint) {
1780
+ hex = renderColorHex(colorPalette[node.hue][node.tint]);
1781
+ }
1782
+ if (!hex) {
1783
+ throw new Error("Invalid color token value: ".concat(str));
1784
+ }
1785
+ try {
1786
+ hex = blendMode === "multiply" ? multiply$1(bg, hex) : screen$1(bg, hex);
1787
+ } catch (err) {
1788
+ console.log("could not blend", hex);
1789
+ }
1790
+ if (node.opacity !== void 0) {
1791
+ hex = rgba(hex, node.opacity);
1792
+ }
1793
+ return hex;
1794
+ }
1795
+ function renderColorHex(color) {
1796
+ return typeof color === "string" ? color : color.hex;
1797
+ }
1798
+ function buildTheme(config) {
1799
+ const color = {
1800
+ light: buildColorTheme({
1801
+ scheme: "light"
1802
+ }, config),
1803
+ dark: buildColorTheme({
1804
+ scheme: "dark"
1805
+ }, config)
1806
+ };
1807
+ return {
1808
+ color: renderColorTheme(color, config)
1809
+ };
1810
+ }
1012
1811
  function createButtonTones(opts, base, dark, solid, muted, mode) {
1013
1812
  return {
1014
1813
  default: opts.button({
@@ -1201,11 +2000,11 @@ const tones$1 = {
1201
2000
  }
1202
2001
  };
1203
2002
  const defaultOpts = {
1204
- base: _ref4 => {
2003
+ base: _ref8 => {
1205
2004
  let {
1206
2005
  dark,
1207
2006
  name
1208
- } = _ref4;
2007
+ } = _ref8;
1209
2008
  if (name === "default") {
1210
2009
  return {
1211
2010
  bg: dark ? black : white,
@@ -1241,13 +2040,13 @@ const defaultOpts = {
1241
2040
  }
1242
2041
  };
1243
2042
  },
1244
- solid: _ref5 => {
2043
+ solid: _ref9 => {
1245
2044
  let {
1246
2045
  base,
1247
2046
  dark,
1248
2047
  state,
1249
2048
  tone
1250
- } = _ref5;
2049
+ } = _ref9;
1251
2050
  const color = colors[tone];
1252
2051
  if (state === "hovered") {
1253
2052
  return {
@@ -1294,13 +2093,13 @@ const defaultOpts = {
1294
2093
  skeleton: base.skeleton
1295
2094
  };
1296
2095
  },
1297
- muted: _ref6 => {
2096
+ muted: _ref10 => {
1298
2097
  let {
1299
2098
  base,
1300
2099
  dark,
1301
2100
  state,
1302
2101
  tone
1303
- } = _ref6;
2102
+ } = _ref10;
1304
2103
  const color = colors[tone];
1305
2104
  if (state === "hovered") {
1306
2105
  return {
@@ -1347,13 +2146,13 @@ const defaultOpts = {
1347
2146
  skeleton: base.skeleton
1348
2147
  };
1349
2148
  },
1350
- button: _ref7 => {
2149
+ button: _ref11 => {
1351
2150
  let {
1352
2151
  base,
1353
2152
  mode,
1354
2153
  muted,
1355
2154
  solid
1356
- } = _ref7;
2155
+ } = _ref11;
1357
2156
  if (mode === "bleed") {
1358
2157
  return {
1359
2158
  ...muted,
@@ -1407,10 +2206,10 @@ const defaultOpts = {
1407
2206
  };
1408
2207
  return solid;
1409
2208
  },
1410
- card: _ref8 => {
2209
+ card: _ref12 => {
1411
2210
  let {
1412
2211
  base
1413
- } = _ref8;
2212
+ } = _ref12;
1414
2213
  return {
1415
2214
  bg: black,
1416
2215
  bg2: black,
@@ -1442,18 +2241,18 @@ const defaultOpts = {
1442
2241
  placeholder: black
1443
2242
  };
1444
2243
  },
1445
- selectable: _ref9 => {
2244
+ selectable: _ref13 => {
1446
2245
  let {
1447
2246
  muted,
1448
2247
  state,
1449
2248
  tone
1450
- } = _ref9;
2249
+ } = _ref13;
1451
2250
  return muted[tone][state];
1452
2251
  },
1453
- spot: _ref10 => {
2252
+ spot: _ref14 => {
1454
2253
  let {
1455
2254
  key
1456
- } = _ref10;
2255
+ } = _ref14;
1457
2256
  return spots[key];
1458
2257
  },
1459
2258
  syntax: () => ({
@@ -2168,7 +2967,7 @@ function _createColor(opts, dark, name) {
2168
2967
  function multiply(bg, fg) {
2169
2968
  const b = parseColor(bg);
2170
2969
  const s = parseColor(fg);
2171
- const hex = rgbToHex(multiply$1(b, s));
2970
+ const hex = rgbToHex(multiply$2(b, s));
2172
2971
  if (s.a) {
2173
2972
  return rgba(hex, s.a);
2174
2973
  }
@@ -2177,7 +2976,7 @@ function multiply(bg, fg) {
2177
2976
  function screen(bg, fg) {
2178
2977
  const b = parseColor(bg);
2179
2978
  const s = parseColor(fg);
2180
- const hex = rgbToHex(screen$1(b, s));
2979
+ const hex = rgbToHex(screen$2(b, s));
2181
2980
  if (s.a) {
2182
2981
  return rgba(hex, s.a);
2183
2982
  }
@@ -2193,11 +2992,11 @@ const tones = {
2193
2992
  };
2194
2993
  const NEUTRAL_TONES = ["default", "transparent"];
2195
2994
  const color = createColorTheme({
2196
- base: _ref11 => {
2995
+ base: _ref15 => {
2197
2996
  let {
2198
2997
  dark,
2199
2998
  name
2200
- } = _ref11;
2999
+ } = _ref15;
2201
3000
  if (name === "default") {
2202
3001
  const tints2 = hues.gray;
2203
3002
  const skeletonFrom2 = dark ? tints2[900].hex : tints2[100].hex;
@@ -2257,14 +3056,14 @@ const color = createColorTheme({
2257
3056
  }
2258
3057
  };
2259
3058
  },
2260
- solid: _ref12 => {
3059
+ solid: _ref16 => {
2261
3060
  let {
2262
3061
  base,
2263
3062
  dark,
2264
3063
  name,
2265
3064
  state,
2266
3065
  tone
2267
- } = _ref12;
3066
+ } = _ref16;
2268
3067
  const mix = dark ? screen : multiply;
2269
3068
  const mix2 = dark ? multiply : screen;
2270
3069
  const defaultTints = tones[name] || tones.default;
@@ -2418,14 +3217,14 @@ const color = createColorTheme({
2418
3217
  }
2419
3218
  };
2420
3219
  },
2421
- muted: _ref13 => {
3220
+ muted: _ref17 => {
2422
3221
  let {
2423
3222
  base,
2424
3223
  dark,
2425
3224
  name,
2426
3225
  state,
2427
3226
  tone
2428
- } = _ref13;
3227
+ } = _ref17;
2429
3228
  const mix = dark ? screen : multiply;
2430
3229
  const defaultTints = tones[name] || tones.default;
2431
3230
  const isNeutral = NEUTRAL_TONES.includes(name) && NEUTRAL_TONES.includes(tone);
@@ -2581,13 +3380,13 @@ const color = createColorTheme({
2581
3380
  }
2582
3381
  };
2583
3382
  },
2584
- button: _ref14 => {
3383
+ button: _ref18 => {
2585
3384
  let {
2586
3385
  base,
2587
3386
  mode,
2588
3387
  muted,
2589
3388
  solid
2590
- } = _ref14;
3389
+ } = _ref18;
2591
3390
  if (mode === "bleed") {
2592
3391
  return {
2593
3392
  enabled: {
@@ -2624,7 +3423,7 @@ const color = createColorTheme({
2624
3423
  }
2625
3424
  return solid;
2626
3425
  },
2627
- card: _ref15 => {
3426
+ card: _ref19 => {
2628
3427
  let {
2629
3428
  base,
2630
3429
  dark,
@@ -2632,7 +3431,7 @@ const color = createColorTheme({
2632
3431
  name,
2633
3432
  solid,
2634
3433
  state
2635
- } = _ref15;
3434
+ } = _ref19;
2636
3435
  if (state === "hovered") {
2637
3436
  return muted[name].hovered;
2638
3437
  }
@@ -2682,13 +3481,13 @@ const color = createColorTheme({
2682
3481
  }
2683
3482
  };
2684
3483
  },
2685
- input: _ref16 => {
3484
+ input: _ref20 => {
2686
3485
  let {
2687
3486
  base,
2688
3487
  dark,
2689
3488
  mode,
2690
3489
  state
2691
- } = _ref16;
3490
+ } = _ref20;
2692
3491
  const mix = dark ? screen : multiply;
2693
3492
  if (mode === "invalid") {
2694
3493
  const tints = tones.critical;
@@ -2740,14 +3539,14 @@ const color = createColorTheme({
2740
3539
  placeholder: mix(base.bg, hues.gray[dark ? 600 : 400].hex)
2741
3540
  };
2742
3541
  },
2743
- selectable: _ref17 => {
3542
+ selectable: _ref21 => {
2744
3543
  let {
2745
3544
  base,
2746
3545
  muted,
2747
3546
  tone,
2748
3547
  solid,
2749
3548
  state
2750
- } = _ref17;
3549
+ } = _ref21;
2751
3550
  if (state === "enabled") {
2752
3551
  return {
2753
3552
  ...muted[tone].enabled,
@@ -2774,20 +3573,20 @@ const color = createColorTheme({
2774
3573
  }
2775
3574
  return muted[tone][state];
2776
3575
  },
2777
- spot: _ref18 => {
3576
+ spot: _ref22 => {
2778
3577
  let {
2779
3578
  base,
2780
3579
  dark,
2781
3580
  key
2782
- } = _ref18;
3581
+ } = _ref22;
2783
3582
  const mix = dark ? screen : multiply;
2784
3583
  return mix(base.bg, hues[key][dark ? 400 : 500].hex);
2785
3584
  },
2786
- syntax: _ref19 => {
3585
+ syntax: _ref23 => {
2787
3586
  let {
2788
3587
  base,
2789
3588
  dark
2790
- } = _ref19;
3589
+ } = _ref23;
2791
3590
  const mix = dark ? screen : multiply;
2792
3591
  const mainShade = dark ? 400 : 600;
2793
3592
  const secondaryShade = dark ? 600 : 400;
@@ -4636,10 +5435,10 @@ var __template$x = (cooked, raw) => __freeze$x(__defProp$y(cooked, "raw", {
4636
5435
  value: __freeze$x(raw || cooked.slice())
4637
5436
  }));
4638
5437
  var _a$x, _b$k;
4639
- function buttonBaseStyles(_ref20) {
5438
+ function buttonBaseStyles(_ref24) {
4640
5439
  let {
4641
5440
  $width
4642
- } = _ref20;
5441
+ } = _ref24;
4643
5442
  return css(_b$k || (_b$k = __template$x(["\n -webkit-font-smoothing: inherit;\n appearance: none;\n display: inline-flex;\n align-items: center;\n font: inherit;\n border: 0;\n outline: none;\n user-select: none;\n text-decoration: none;\n border: 0;\n box-sizing: border-box;\n padding: 0;\n margin: 0;\n white-space: nowrap;\n text-align: left;\n position: relative;\n\n ", "\n\n & > span {\n display: block;\n flex: 1;\n min-width: 0;\n border-radius: inherit;\n }\n\n &::-moz-focus-inner {\n border: 0;\n padding: 0;\n }\n "])), $width === "fill" && css(_a$x || (_a$x = __template$x(["\n width: -webkit-fill-available;\n width: stretch;\n "]))));
4644
5443
  }
4645
5444
  const buttonTheme = {
@@ -4997,10 +5796,10 @@ var __template$t = (cooked, raw) => __freeze$t(__defProp$u(cooked, "raw", {
4997
5796
  value: __freeze$t(raw || cooked.slice())
4998
5797
  }));
4999
5798
  var _a$t;
5000
- function codeSyntaxHighlightingStyle(_ref21) {
5799
+ function codeSyntaxHighlightingStyle(_ref25) {
5001
5800
  let {
5002
5801
  theme
5003
- } = _ref21;
5802
+ } = _ref25;
5004
5803
  const color = theme.sanity.color.syntax;
5005
5804
  return {
5006
5805
  "&.atrule": {
@@ -6308,13 +7107,13 @@ const Popover = memo(forwardRef(function Popover2(props, ref) {
6308
7107
  }));
6309
7108
  if (constrainSize || matchReferenceWidth) {
6310
7109
  ret.push(size({
6311
- apply(_ref22) {
7110
+ apply(_ref26) {
6312
7111
  let {
6313
7112
  availableWidth,
6314
7113
  availableHeight,
6315
7114
  elements,
6316
7115
  referenceWidth
6317
- } = _ref22;
7116
+ } = _ref26;
6318
7117
  referenceWidthRef.current = referenceWidth;
6319
7118
  const _currentWidth = widthRef.current;
6320
7119
  const _maxWidth = maxWidthRef.current;
@@ -7123,12 +7922,12 @@ const Tooltip = forwardRef(function Tooltip2(props, ref) {
7123
7922
  mainAxis: 3
7124
7923
  }));
7125
7924
  ret.push(size$2({
7126
- apply(_ref23) {
7925
+ apply(_ref27) {
7127
7926
  let {
7128
7927
  availableWidth,
7129
7928
  availableHeight,
7130
7929
  elements
7131
- } = _ref23;
7930
+ } = _ref27;
7132
7931
  Object.assign(elements.floating.style, {
7133
7932
  maxWidth: "".concat(availableWidth - 4 * 2, "px"),
7134
7933
  // the padding is `4px`
@@ -7434,10 +8233,10 @@ const InnerAutocomplete = forwardRef(function InnerAutocomplete2(props, ref) {
7434
8233
  query,
7435
8234
  value
7436
8235
  } = state;
7437
- const defaultRenderOption = useCallback(_ref24 => {
8236
+ const defaultRenderOption = useCallback(_ref28 => {
7438
8237
  let {
7439
8238
  value: value2
7440
- } = _ref24;
8239
+ } = _ref28;
7441
8240
  return /* @__PURE__ */jsx(Card, {
7442
8241
  "data-as": "button",
7443
8242
  padding: paddingProp,
@@ -7891,10 +8690,10 @@ const Breadcrumbs = forwardRef(function Breadcrumbs2(props, ref) {
7891
8690
  });
7892
8691
  });
7893
8692
  const BORDER_OFFSET_X = 12;
7894
- function dialogStyle(_ref25) {
8693
+ function dialogStyle(_ref29) {
7895
8694
  let {
7896
8695
  theme
7897
- } = _ref25;
8696
+ } = _ref29;
7898
8697
  const color = theme.sanity.color.base;
7899
8698
  return {
7900
8699
  "&:not([hidden])": {
@@ -8048,12 +8847,13 @@ const DialogCard = forwardRef(function DialogCard2(props, ref) {
8048
8847
  children: [showHeader && /* @__PURE__ */jsx(DialogHeader, {
8049
8848
  $isContentScrollable: isContentScrollable,
8050
8849
  $hasScrolledFromTop: hasScrolledFromTop,
8051
- padding: 3,
8850
+ paddingLeft: 4,
8851
+ paddingRight: 3,
8852
+ paddingY: 3,
8052
8853
  children: /* @__PURE__ */jsxs(Flex, {
8053
8854
  align: "center",
8054
8855
  children: [/* @__PURE__ */jsx(Box, {
8055
8856
  flex: 1,
8056
- padding: 3,
8057
8857
  children: header && /* @__PURE__ */jsx(Text, {
8058
8858
  id: labelId,
8059
8859
  size: 1,
@@ -8979,15 +9779,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
8979
9779
  var _a$6, _b$3, _c$1, _d;
8980
9780
  const keyframe = keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
8981
9781
  const animation = css(_b$3 || (_b$3 = __template$6(["\n background-image: linear-gradient(\n to right,\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-to),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from),\n var(--card-skeleton-color-from)\n );\n background-position: 100%;\n background-size: 200% 100%;\n background-attachment: fixed;\n animation-name: ", ";\n animation-timing-function: ease-in-out;\n animation-iteration-count: infinite;\n animation-duration: 2000ms;\n"])), keyframe);
8982
- const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref26 => {
9782
+ const skeletonStyle = css(_d || (_d = __template$6(["\n opacity: ", ";\n transition: opacity 200ms ease-in;\n\n @media screen and (prefers-reduced-motion: no-preference) {\n ", "\n }\n\n @media screen and (prefers-reduced-motion: reduce) {\n background-color: var(--card-skeleton-color-from);\n }\n"])), _ref30 => {
8983
9783
  let {
8984
9784
  $visible
8985
- } = _ref26;
9785
+ } = _ref30;
8986
9786
  return $visible ? 1 : 0;
8987
- }, _ref27 => {
9787
+ }, _ref31 => {
8988
9788
  let {
8989
9789
  $animated
8990
- } = _ref27;
9790
+ } = _ref31;
8991
9791
  return $animated ? animation : css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
8992
9792
  });
8993
9793
  const Root$4 = styled(Box)(responsiveRadiusStyle, skeletonStyle);
@@ -9018,12 +9818,12 @@ const Skeleton = forwardRef(function Skeleton2(props, ref) {
9018
9818
  ref
9019
9819
  });
9020
9820
  });
9021
- const Root$3 = styled(Skeleton)(_ref28 => {
9821
+ const Root$3 = styled(Skeleton)(_ref32 => {
9022
9822
  let {
9023
9823
  $size,
9024
9824
  $style,
9025
9825
  theme
9026
- } = _ref28;
9826
+ } = _ref32;
9027
9827
  const {
9028
9828
  media
9029
9829
  } = theme.sanity;
@@ -9371,12 +10171,12 @@ function ToastProvider(props) {
9371
10171
  paddingY,
9372
10172
  children: /* @__PURE__ */jsx(AnimatePresence, {
9373
10173
  initial: false,
9374
- children: state.map(_ref29 => {
10174
+ children: state.map(_ref33 => {
9375
10175
  let {
9376
10176
  dismiss,
9377
10177
  id,
9378
10178
  params
9379
- } = _ref29;
10179
+ } = _ref33;
9380
10180
  return /* @__PURE__ */jsx(motion.div, {
9381
10181
  animate: {
9382
10182
  opacity: 1,
@@ -9876,5 +10676,5 @@ const TreeItem = memo(function TreeItem2(props) {
9876
10676
  })]
9877
10677
  });
9878
10678
  });
9879
- export { Autocomplete, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Box, Breadcrumbs, Button, Card, Checkbox, Code, CodeSkeleton, Container, Dialog, DialogContext, DialogProvider, ElementQuery, ErrorBoundary, Flex, Grid, Heading, HeadingSkeleton, Hotkeys, Inline, KBD, Label, LabelSkeleton, Layer, LayerProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuItem, Popover, Portal, PortalProvider, Radio, Select, Skeleton, Spinner, SrOnly, Stack, Switch, Tab, TabList, TabPanel, Text, TextArea, TextInput, TextSkeleton, ThemeColorProvider, ThemeProvider, Toast, ToastProvider, Tooltip, TooltipDelayGroupContext, TooltipDelayGroupProvider, Tree, TreeItem, VirtualList, _ResizeObserver, _elementSizeObserver, _fillCSSObject, _getArrayProp, _getResponsiveSpace, _hasFocus, _isEnterToClickElement, _isScrollable, _raf, _raf2, _responsive, attemptFocus, containsOrEqualsElement, createColorTheme, focusFirstDescendant, focusLastDescendant, hexToRgb, hslToRgb, isFocusable, isHTMLAnchorElement, isHTMLButtonElement, isHTMLElement, isHTMLInputElement, isHTMLSelectElement, isHTMLTextAreaElement, multiply$1 as multiply, parseColor, rem, responsiveCodeFontStyle, responsiveHeadingFont, responsiveLabelFont, responsiveTextAlignStyle, responsiveTextFont, rgbToHex, rgbToHsl, rgba, rgbaToRGBA, screen$1 as screen, studioTheme, useArrayProp, useBoundaryElement, useClickOutside, useCustomValidity, useDialog, useElementRect, useElementSize, useForwardedRef, useGlobalKeyDown, useLayer, useMediaIndex, usePortal, usePrefersDark, usePrefersReducedMotion, useRootTheme, useTheme, useToast, useTooltipDelayGroup, useTree };
10679
+ export { Autocomplete, Avatar, AvatarCounter, AvatarStack, Badge, BoundaryElementProvider, Box, Breadcrumbs, Button, COLOR_BASE_TONES, COLOR_BLEND_MODES, COLOR_BUTTON_MODES, COLOR_CONFIG_BASE_KEYS, COLOR_CONFIG_BASE_TONES, COLOR_CONFIG_BLEND_KEYS, COLOR_CONFIG_STATE_KEYS, COLOR_CONFIG_STATE_TONES, COLOR_HUES, COLOR_STATES, COLOR_STATE_TONES, COLOR_TINTS, Card, Checkbox, Code, CodeSkeleton, Container, Dialog, DialogContext, DialogProvider, ElementQuery, ErrorBoundary, Flex, Grid, Heading, HeadingSkeleton, Hotkeys, Inline, KBD, Label, LabelSkeleton, Layer, LayerProvider, Menu, MenuButton, MenuDivider, MenuGroup, MenuItem, Popover, Portal, PortalProvider, Radio, Select, Skeleton, Spinner, SrOnly, Stack, Switch, Tab, TabList, TabPanel, Text, TextArea, TextInput, TextSkeleton, ThemeColorProvider, ThemeProvider, Toast, ToastProvider, Tooltip, TooltipDelayGroupContext, TooltipDelayGroupProvider, Tree, TreeItem, VirtualList, _ResizeObserver, _elementSizeObserver, _fillCSSObject, _getArrayProp, _getResponsiveSpace, _hasFocus, _isEnterToClickElement, _isScrollable, _raf, _raf2, _responsive, attemptFocus, buildTheme, containsOrEqualsElement, createColorTheme, focusFirstDescendant, focusLastDescendant, hexToRgb, hslToRgb, isColorBlendModeValue, isColorButtonMode, isColorConfigBaseKey, isColorConfigBaseTone, isColorConfigBlendKey, isColorConfigStateKey, isColorConfigStateTone, isColorHueValue, isColorOpacityValue, isColorTintValue, isColorTokenValue, isColorValue, isFocusable, isHTMLAnchorElement, isHTMLButtonElement, isHTMLElement, isHTMLInputElement, isHTMLSelectElement, isHTMLTextAreaElement, multiply$2 as multiply, parseColor, parseTokenKey, parseTokenValue, rem, responsiveCodeFontStyle, responsiveHeadingFont, responsiveLabelFont, responsiveTextAlignStyle, responsiveTextFont, rgbToHex, rgbToHsl, rgba, rgbaToRGBA, screen$2 as screen, studioTheme, useArrayProp, useBoundaryElement, useClickOutside, useCustomValidity, useDialog, useElementRect, useElementSize, useForwardedRef, useGlobalKeyDown, useLayer, useMediaIndex, usePortal, usePrefersDark, usePrefersReducedMotion, useRootTheme, useTheme, useToast, useTooltipDelayGroup, useTree };
9880
10680
  //# sourceMappingURL=index.esm.js.map