@sanity/ui 2.0.0-alpha.13 → 2.0.0-alpha.14
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/index.cjs.mjs +27 -0
- package/dist/index.d.ts +337 -7
- package/dist/index.esm.js +745 -58
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +772 -58
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/src/theme/_internal/__workshop__/build/story.tsx +178 -0
- package/src/theme/_internal/__workshop__/build/theme.ts +3 -0
- package/src/theme/_internal/__workshop__/index.ts +14 -0
- package/src/theme/_internal/build/buildTheme.test.ts +78 -0
- package/src/theme/_internal/build/buildTheme.ts +15 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.test.ts +185 -0
- package/src/theme/_internal/build/colorTheme/buildColorTheme.ts +222 -0
- package/src/theme/_internal/build/colorTheme/renderColorTheme.ts +226 -0
- package/src/theme/_internal/build/defaults/colorPalette.ts +8 -0
- package/src/theme/_internal/build/defaults/colorTokens.ts +124 -0
- package/src/theme/_internal/build/helpers.ts +64 -0
- package/src/theme/_internal/build/index.ts +1 -0
- package/src/theme/_internal/config/helpers.ts +47 -0
- package/src/theme/_internal/config/index.ts +3 -0
- package/src/theme/_internal/config/token/index.ts +2 -0
- package/src/theme/_internal/config/token/parseTokenKey.test.ts +72 -0
- package/src/theme/_internal/config/token/parseTokenKey.ts +88 -0
- package/src/theme/_internal/config/token/parseTokenValue.test.ts +45 -0
- package/src/theme/_internal/config/token/parseTokenValue.ts +123 -0
- package/src/theme/_internal/config/types.ts +126 -0
- package/src/theme/_internal/constants.ts +48 -0
- package/src/theme/_internal/helpers.ts +19 -0
- package/src/theme/_internal/index.ts +5 -0
- package/src/theme/_internal/types.ts +72 -0
- package/src/theme/index.ts +1 -0
package/dist/index.js
CHANGED
|
@@ -844,10 +844,143 @@ function useGlobalKeyDown(onKeyDown) {
|
|
|
844
844
|
return () => removeEventListener("keydown", onKeyDown);
|
|
845
845
|
}, [onKeyDown]);
|
|
846
846
|
}
|
|
847
|
+
const COLOR_HUES = ["gray", "cyan", "blue", "purple", "magenta", "red", "orange", "yellow", "green"];
|
|
848
|
+
const COLOR_TINTS = ["50", "100", "200", "300", "400", "500", "600", "700", "800", "900", "950"];
|
|
849
|
+
const COLOR_BASE_TONES = ["transparent", "default", "primary",
|
|
850
|
+
// todo: rename to `accent`
|
|
851
|
+
"positive", "caution", "critical"];
|
|
852
|
+
const COLOR_STATE_TONES = ["default", "primary",
|
|
853
|
+
// todo: rename to `accent`
|
|
854
|
+
"positive", "caution", "critical"];
|
|
855
|
+
const COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"];
|
|
856
|
+
const COLOR_BUTTON_MODES = ["default", "ghost", "bleed"];
|
|
857
|
+
const COLOR_BLEND_MODES = ["multiply", "screen"];
|
|
858
|
+
const defaultColorTokens = {
|
|
859
|
+
"*": {
|
|
860
|
+
_blend: ["multiply", "screen"],
|
|
861
|
+
bg: ["50", "950"],
|
|
862
|
+
fg: ["800", "200"],
|
|
863
|
+
border: ["200", "800"]
|
|
864
|
+
},
|
|
865
|
+
transparent: {
|
|
866
|
+
bg: ["50", "black"],
|
|
867
|
+
fg: ["600", "400"]
|
|
868
|
+
},
|
|
869
|
+
default: {
|
|
870
|
+
bg: ["white", "950"],
|
|
871
|
+
fg: ["black", "200"]
|
|
872
|
+
},
|
|
873
|
+
primary: {
|
|
874
|
+
_hue: "cyan"
|
|
875
|
+
},
|
|
876
|
+
positive: {
|
|
877
|
+
_hue: "cyan"
|
|
878
|
+
},
|
|
879
|
+
caution: {
|
|
880
|
+
_hue: "yellow"
|
|
881
|
+
},
|
|
882
|
+
critical: {
|
|
883
|
+
_hue: "red"
|
|
884
|
+
},
|
|
885
|
+
button: {
|
|
886
|
+
"*": {
|
|
887
|
+
default: {
|
|
888
|
+
"*": {
|
|
889
|
+
_blend: ["screen", "multiply"],
|
|
890
|
+
bg: ["500", "400"],
|
|
891
|
+
border: ["500/0", "400/0"]
|
|
892
|
+
},
|
|
893
|
+
hovered: {
|
|
894
|
+
bg: ["600", "300"],
|
|
895
|
+
border: ["600/0", "300/0"]
|
|
896
|
+
},
|
|
897
|
+
pressed: {
|
|
898
|
+
bg: ["700", "200"]
|
|
899
|
+
},
|
|
900
|
+
selected: {
|
|
901
|
+
bg: ["700", "200"]
|
|
902
|
+
},
|
|
903
|
+
disabled: {
|
|
904
|
+
_hue: "gray",
|
|
905
|
+
bg: ["100", "900"]
|
|
906
|
+
}
|
|
907
|
+
},
|
|
908
|
+
ghost: {
|
|
909
|
+
"*": {
|
|
910
|
+
_blend: ["multiply", "screen"],
|
|
911
|
+
bg: ["white", "black"],
|
|
912
|
+
fg: ["600", "400"],
|
|
913
|
+
border: ["200", "800"]
|
|
914
|
+
},
|
|
915
|
+
hovered: {
|
|
916
|
+
bg: ["50", "950"],
|
|
917
|
+
fg: ["700", "300"]
|
|
918
|
+
},
|
|
919
|
+
pressed: {
|
|
920
|
+
bg: ["100", "900"],
|
|
921
|
+
fg: ["800", "200"]
|
|
922
|
+
},
|
|
923
|
+
selected: {
|
|
924
|
+
bg: ["100", "900"],
|
|
925
|
+
fg: ["800", "200"]
|
|
926
|
+
},
|
|
927
|
+
disabled: {
|
|
928
|
+
_hue: "gray",
|
|
929
|
+
fg: ["100", "900"],
|
|
930
|
+
border: ["100", "900"]
|
|
931
|
+
}
|
|
932
|
+
},
|
|
933
|
+
bleed: {
|
|
934
|
+
"*": {
|
|
935
|
+
_blend: ["multiply", "screen"],
|
|
936
|
+
bg: ["white", "black"],
|
|
937
|
+
fg: ["600", "400"],
|
|
938
|
+
border: ["white/0", "black/0"]
|
|
939
|
+
},
|
|
940
|
+
hovered: {
|
|
941
|
+
bg: ["50", "950"],
|
|
942
|
+
fg: ["700", "300"]
|
|
943
|
+
},
|
|
944
|
+
pressed: {
|
|
945
|
+
bg: ["100", "900"],
|
|
946
|
+
fg: ["800", "200"]
|
|
947
|
+
},
|
|
948
|
+
selected: {
|
|
949
|
+
bg: ["100", "900"],
|
|
950
|
+
fg: ["800", "200"]
|
|
951
|
+
},
|
|
952
|
+
disabled: {
|
|
953
|
+
_hue: "gray",
|
|
954
|
+
fg: ["100", "900"]
|
|
955
|
+
}
|
|
956
|
+
}
|
|
957
|
+
},
|
|
958
|
+
default: {
|
|
959
|
+
default: {
|
|
960
|
+
"*": {
|
|
961
|
+
bg: ["900", "200"]
|
|
962
|
+
},
|
|
963
|
+
hovered: {
|
|
964
|
+
bg: ["black", "100"]
|
|
965
|
+
},
|
|
966
|
+
pressed: {
|
|
967
|
+
bg: ["900", "200"]
|
|
968
|
+
},
|
|
969
|
+
selected: {
|
|
970
|
+
bg: ["black", "200"]
|
|
971
|
+
},
|
|
972
|
+
disabled: {
|
|
973
|
+
_hue: "gray",
|
|
974
|
+
bg: ["100", "900"]
|
|
975
|
+
}
|
|
976
|
+
}
|
|
977
|
+
}
|
|
978
|
+
}
|
|
979
|
+
};
|
|
847
980
|
function multiplyChannel(b, s) {
|
|
848
981
|
return b * s;
|
|
849
982
|
}
|
|
850
|
-
function multiply$
|
|
983
|
+
function multiply$2(b, s) {
|
|
851
984
|
return {
|
|
852
985
|
r: Math.round(clamp$1(multiplyChannel(b.r / 255, s.r / 255) * 255)),
|
|
853
986
|
g: Math.round(clamp$1(multiplyChannel(b.g / 255, s.g / 255) * 255)),
|
|
@@ -860,7 +993,7 @@ function clamp$1(num) {
|
|
|
860
993
|
function screenChannel(b, s) {
|
|
861
994
|
return b + s - b * s;
|
|
862
995
|
}
|
|
863
|
-
function screen$
|
|
996
|
+
function screen$2(b, s) {
|
|
864
997
|
return {
|
|
865
998
|
r: Math.round(clamp(screenChannel(b.r / 255, s.r / 255) * 255)),
|
|
866
999
|
g: Math.round(clamp(screenChannel(b.g / 255, s.g / 255) * 255)),
|
|
@@ -1022,6 +1155,560 @@ function rgba(color, a) {
|
|
|
1022
1155
|
const rgb = parseColor(color);
|
|
1023
1156
|
return "rgba(".concat(rgb.r, ",").concat(rgb.g, ",").concat(rgb.b, ",").concat(a, ")");
|
|
1024
1157
|
}
|
|
1158
|
+
function isColorBlendModeValue(str) {
|
|
1159
|
+
return COLOR_BLEND_MODES.includes(str);
|
|
1160
|
+
}
|
|
1161
|
+
function isColorHueValue(str) {
|
|
1162
|
+
return COLOR_HUES.includes(str);
|
|
1163
|
+
}
|
|
1164
|
+
function isColorTintValue(str) {
|
|
1165
|
+
return COLOR_TINTS.includes(str);
|
|
1166
|
+
}
|
|
1167
|
+
function isColorButtonMode(str) {
|
|
1168
|
+
return COLOR_BUTTON_MODES.includes(str);
|
|
1169
|
+
}
|
|
1170
|
+
function parseTokenKey(str) {
|
|
1171
|
+
const segments = str.split("/");
|
|
1172
|
+
const segment0 = segments.shift() || "";
|
|
1173
|
+
if (isColorConfigBaseTone(segment0)) {
|
|
1174
|
+
const key = segments.join("/");
|
|
1175
|
+
if (isColorConfigBaseKey(key)) {
|
|
1176
|
+
return {
|
|
1177
|
+
type: "base",
|
|
1178
|
+
tone: segment0,
|
|
1179
|
+
key
|
|
1180
|
+
};
|
|
1181
|
+
}
|
|
1182
|
+
if (isColorConfigBlendKey(key)) {
|
|
1183
|
+
return {
|
|
1184
|
+
type: "base",
|
|
1185
|
+
tone: segment0,
|
|
1186
|
+
key
|
|
1187
|
+
};
|
|
1188
|
+
}
|
|
1189
|
+
}
|
|
1190
|
+
if (segment0 === "button") {
|
|
1191
|
+
const segment1 = segments.shift() || "";
|
|
1192
|
+
if (isColorConfigStateTone(segment1)) {
|
|
1193
|
+
const segment2 = segments.shift() || "";
|
|
1194
|
+
if (isColorButtonMode(segment2)) {
|
|
1195
|
+
const key = segments.join("/");
|
|
1196
|
+
if (isColorConfigStateKey(key)) {
|
|
1197
|
+
return {
|
|
1198
|
+
type: "button",
|
|
1199
|
+
tone: segment1,
|
|
1200
|
+
mode: segment2,
|
|
1201
|
+
key
|
|
1202
|
+
};
|
|
1203
|
+
}
|
|
1204
|
+
if (isColorConfigBlendKey(key)) {
|
|
1205
|
+
return {
|
|
1206
|
+
type: "button",
|
|
1207
|
+
tone: segment1,
|
|
1208
|
+
mode: segment2,
|
|
1209
|
+
key
|
|
1210
|
+
};
|
|
1211
|
+
}
|
|
1212
|
+
}
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
return void 0;
|
|
1216
|
+
}
|
|
1217
|
+
function parseTokenValue(str) {
|
|
1218
|
+
const segments = str.split("/");
|
|
1219
|
+
const segment0 = segments.shift() || "";
|
|
1220
|
+
if (isColorTintValue(segment0)) {
|
|
1221
|
+
const tint = segment0;
|
|
1222
|
+
const segment1 = segments.shift() || "";
|
|
1223
|
+
if (isColorOpacityValue(segment1)) {
|
|
1224
|
+
const opacity = Number(segment1);
|
|
1225
|
+
return {
|
|
1226
|
+
type: "color",
|
|
1227
|
+
tint,
|
|
1228
|
+
opacity
|
|
1229
|
+
};
|
|
1230
|
+
}
|
|
1231
|
+
return {
|
|
1232
|
+
type: "color",
|
|
1233
|
+
tint
|
|
1234
|
+
};
|
|
1235
|
+
}
|
|
1236
|
+
if (isColorValue(segment0)) {
|
|
1237
|
+
const key = segment0;
|
|
1238
|
+
const segment1 = segments.shift() || "";
|
|
1239
|
+
if (isColorOpacityValue(segment1)) {
|
|
1240
|
+
const opacity = Number(segment1);
|
|
1241
|
+
return {
|
|
1242
|
+
type: "color",
|
|
1243
|
+
key,
|
|
1244
|
+
opacity
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
return {
|
|
1248
|
+
type: "color",
|
|
1249
|
+
key
|
|
1250
|
+
};
|
|
1251
|
+
}
|
|
1252
|
+
if (isColorHueValue(segment0)) {
|
|
1253
|
+
const hue = segment0;
|
|
1254
|
+
const segment1 = segments.shift() || "";
|
|
1255
|
+
if (isColorTintValue(segment1)) {
|
|
1256
|
+
const tint = segment1;
|
|
1257
|
+
const segment2 = segments.shift() || "";
|
|
1258
|
+
if (isColorOpacityValue(segment2)) {
|
|
1259
|
+
const opacity = Number(segment2);
|
|
1260
|
+
return {
|
|
1261
|
+
type: "color",
|
|
1262
|
+
key: "".concat(hue, "/").concat(tint),
|
|
1263
|
+
hue,
|
|
1264
|
+
tint,
|
|
1265
|
+
opacity
|
|
1266
|
+
};
|
|
1267
|
+
}
|
|
1268
|
+
return {
|
|
1269
|
+
type: "color",
|
|
1270
|
+
key: "".concat(hue, "/").concat(tint),
|
|
1271
|
+
hue,
|
|
1272
|
+
tint
|
|
1273
|
+
};
|
|
1274
|
+
}
|
|
1275
|
+
return {
|
|
1276
|
+
type: "hue",
|
|
1277
|
+
value: "".concat(hue)
|
|
1278
|
+
};
|
|
1279
|
+
}
|
|
1280
|
+
if (isColorOpacityValue(segment0)) {
|
|
1281
|
+
const opacity = Number(segment0);
|
|
1282
|
+
return {
|
|
1283
|
+
type: "color",
|
|
1284
|
+
opacity
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
if (isColorBlendModeValue(segment0)) {
|
|
1288
|
+
const value = segment0;
|
|
1289
|
+
return {
|
|
1290
|
+
type: "blendMode",
|
|
1291
|
+
value
|
|
1292
|
+
};
|
|
1293
|
+
}
|
|
1294
|
+
return void 0;
|
|
1295
|
+
}
|
|
1296
|
+
const COLOR_CONFIG_BASE_TONES = ["*", ...COLOR_BASE_TONES];
|
|
1297
|
+
const COLOR_CONFIG_STATE_TONES = ["*", ...COLOR_STATE_TONES];
|
|
1298
|
+
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"];
|
|
1299
|
+
const COLOR_CONFIG_STATE_KEYS = ["_hue", "bg", "fg", "border", "focusRing", "muted/fg", "link/fg", "code/bg", "code/fg", "skeleton/from", "skeleton/to"];
|
|
1300
|
+
const COLOR_CONFIG_BLEND_KEYS = ["_blend"];
|
|
1301
|
+
function isColorConfigBaseTone(str) {
|
|
1302
|
+
return COLOR_CONFIG_BASE_TONES.includes(str);
|
|
1303
|
+
}
|
|
1304
|
+
function isColorConfigBaseKey(str) {
|
|
1305
|
+
return COLOR_CONFIG_BASE_KEYS.includes(str);
|
|
1306
|
+
}
|
|
1307
|
+
function isColorConfigStateKey(str) {
|
|
1308
|
+
return COLOR_CONFIG_STATE_KEYS.includes(str);
|
|
1309
|
+
}
|
|
1310
|
+
function isColorConfigStateTone(str) {
|
|
1311
|
+
return COLOR_CONFIG_STATE_TONES.includes(str);
|
|
1312
|
+
}
|
|
1313
|
+
function isColorConfigBlendKey(str) {
|
|
1314
|
+
return COLOR_CONFIG_BLEND_KEYS.includes(str);
|
|
1315
|
+
}
|
|
1316
|
+
function isColorTokenValue(str) {
|
|
1317
|
+
var _a, _b;
|
|
1318
|
+
return ((_a = parseTokenValue(str)) == null ? void 0 : _a.type) === "color" || ((_b = parseTokenValue(str)) == null ? void 0 : _b.type) === "hue";
|
|
1319
|
+
}
|
|
1320
|
+
function isColorValue(str) {
|
|
1321
|
+
return str === "black" || str === "white";
|
|
1322
|
+
}
|
|
1323
|
+
function isColorOpacityValue(str) {
|
|
1324
|
+
return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
|
|
1325
|
+
}
|
|
1326
|
+
function resolveColorTokenValue(options) {
|
|
1327
|
+
const {
|
|
1328
|
+
hue,
|
|
1329
|
+
scheme,
|
|
1330
|
+
value
|
|
1331
|
+
} = options;
|
|
1332
|
+
const node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
|
|
1333
|
+
if (!node || node.type !== "color") {
|
|
1334
|
+
throw new Error("Invalid color token: ".concat(value[0]));
|
|
1335
|
+
}
|
|
1336
|
+
return compileColorTokenValue({
|
|
1337
|
+
...node,
|
|
1338
|
+
hue: node.hue || hue
|
|
1339
|
+
});
|
|
1340
|
+
}
|
|
1341
|
+
function compileColorTokenValue(node) {
|
|
1342
|
+
let key = "";
|
|
1343
|
+
if (node.key === "black" || node.key === "white") {
|
|
1344
|
+
key = node.key;
|
|
1345
|
+
} else {
|
|
1346
|
+
key = "".concat(node.hue, "/").concat(node.tint);
|
|
1347
|
+
}
|
|
1348
|
+
if (node.opacity !== void 0) {
|
|
1349
|
+
key += "/".concat(node.opacity);
|
|
1350
|
+
}
|
|
1351
|
+
return key;
|
|
1352
|
+
}
|
|
1353
|
+
function multiply$1(bg, fg) {
|
|
1354
|
+
const b = parseColor(bg);
|
|
1355
|
+
const s = parseColor(fg);
|
|
1356
|
+
const hex = rgbToHex(multiply$2(b, s));
|
|
1357
|
+
if (s.a !== void 0) {
|
|
1358
|
+
return rgba(hex, s.a);
|
|
1359
|
+
}
|
|
1360
|
+
return hex;
|
|
1361
|
+
}
|
|
1362
|
+
function screen$1(bg, fg) {
|
|
1363
|
+
const b = parseColor(bg);
|
|
1364
|
+
const s = parseColor(fg);
|
|
1365
|
+
const hex = rgbToHex(screen$2(b, s));
|
|
1366
|
+
if (s.a !== void 0) {
|
|
1367
|
+
return rgba(hex, s.a);
|
|
1368
|
+
}
|
|
1369
|
+
return hex;
|
|
1370
|
+
}
|
|
1371
|
+
function buildColorTheme(options, config) {
|
|
1372
|
+
const {
|
|
1373
|
+
scheme
|
|
1374
|
+
} = options;
|
|
1375
|
+
return {
|
|
1376
|
+
transparent: buildBaseColorTheme({
|
|
1377
|
+
scheme,
|
|
1378
|
+
tone: "transparent"
|
|
1379
|
+
}, config),
|
|
1380
|
+
default: buildBaseColorTheme({
|
|
1381
|
+
scheme,
|
|
1382
|
+
tone: "default"
|
|
1383
|
+
}, config),
|
|
1384
|
+
primary: buildBaseColorTheme({
|
|
1385
|
+
scheme,
|
|
1386
|
+
tone: "primary"
|
|
1387
|
+
}, config),
|
|
1388
|
+
positive: buildBaseColorTheme({
|
|
1389
|
+
scheme,
|
|
1390
|
+
tone: "positive"
|
|
1391
|
+
}, config),
|
|
1392
|
+
caution: buildBaseColorTheme({
|
|
1393
|
+
scheme,
|
|
1394
|
+
tone: "caution"
|
|
1395
|
+
}, config),
|
|
1396
|
+
critical: buildBaseColorTheme({
|
|
1397
|
+
scheme,
|
|
1398
|
+
tone: "critical"
|
|
1399
|
+
}, config)
|
|
1400
|
+
};
|
|
1401
|
+
}
|
|
1402
|
+
function buildBaseColorTheme(options, config) {
|
|
1403
|
+
var _a, _b;
|
|
1404
|
+
const {
|
|
1405
|
+
scheme,
|
|
1406
|
+
tone
|
|
1407
|
+
} = options;
|
|
1408
|
+
const tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.tokens) != null ? _b : defaultColorTokens;
|
|
1409
|
+
const any = tokens == null ? void 0 : tokens["*"];
|
|
1410
|
+
const toneTokens = tokens == null ? void 0 : tokens[tone];
|
|
1411
|
+
const hue = (toneTokens == null ? void 0 : toneTokens._hue) || (any == null ? void 0 : any._hue) || "gray";
|
|
1412
|
+
const bg = resolveColorTokenValue({
|
|
1413
|
+
hue,
|
|
1414
|
+
scheme,
|
|
1415
|
+
value: (toneTokens == null ? void 0 : toneTokens.bg) || (any == null ? void 0 : any.bg) || ["gray/50", "black"]
|
|
1416
|
+
});
|
|
1417
|
+
const _blend = (toneTokens == null ? void 0 : toneTokens._blend) || (any == null ? void 0 : any._blend) || ["screen", "multiply"];
|
|
1418
|
+
return {
|
|
1419
|
+
_blend: _blend[scheme === "light" ? 0 : 1],
|
|
1420
|
+
dark: scheme === "dark",
|
|
1421
|
+
base: {
|
|
1422
|
+
bg,
|
|
1423
|
+
fg: resolveColorTokenValue({
|
|
1424
|
+
hue,
|
|
1425
|
+
scheme,
|
|
1426
|
+
value: (toneTokens == null ? void 0 : toneTokens.fg) || (any == null ? void 0 : any.fg) || ["black", "white"]
|
|
1427
|
+
}),
|
|
1428
|
+
border: resolveColorTokenValue({
|
|
1429
|
+
hue,
|
|
1430
|
+
scheme,
|
|
1431
|
+
value: (toneTokens == null ? void 0 : toneTokens.border) || (any == null ? void 0 : any.border) || ["black", "white"]
|
|
1432
|
+
})
|
|
1433
|
+
},
|
|
1434
|
+
button: buildButtonColorTheme({
|
|
1435
|
+
scheme
|
|
1436
|
+
}, config)
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
function buildButtonColorTheme(options, config) {
|
|
1440
|
+
const {
|
|
1441
|
+
scheme
|
|
1442
|
+
} = options;
|
|
1443
|
+
const tones = COLOR_STATE_TONES.map(tone => {
|
|
1444
|
+
return {
|
|
1445
|
+
[tone]: buildButtonColorToneTheme({
|
|
1446
|
+
scheme,
|
|
1447
|
+
tone
|
|
1448
|
+
}, config)
|
|
1449
|
+
};
|
|
1450
|
+
});
|
|
1451
|
+
return Object.assign({}, ...tones);
|
|
1452
|
+
}
|
|
1453
|
+
function buildButtonColorToneTheme(options, config) {
|
|
1454
|
+
const {
|
|
1455
|
+
scheme,
|
|
1456
|
+
tone
|
|
1457
|
+
} = options;
|
|
1458
|
+
const modes = COLOR_BUTTON_MODES.map(mode => {
|
|
1459
|
+
return {
|
|
1460
|
+
[mode]: buildButtonModeColorTheme({
|
|
1461
|
+
mode,
|
|
1462
|
+
scheme,
|
|
1463
|
+
tone
|
|
1464
|
+
}, config)
|
|
1465
|
+
};
|
|
1466
|
+
});
|
|
1467
|
+
return Object.assign({}, ...modes);
|
|
1468
|
+
}
|
|
1469
|
+
function buildButtonModeColorTheme(options, config) {
|
|
1470
|
+
const {
|
|
1471
|
+
mode,
|
|
1472
|
+
scheme,
|
|
1473
|
+
tone
|
|
1474
|
+
} = options;
|
|
1475
|
+
const states = COLOR_STATES.map(state => {
|
|
1476
|
+
return {
|
|
1477
|
+
[state]: buildButtonStateColorTheme({
|
|
1478
|
+
mode,
|
|
1479
|
+
tone,
|
|
1480
|
+
scheme,
|
|
1481
|
+
state
|
|
1482
|
+
}, config)
|
|
1483
|
+
};
|
|
1484
|
+
});
|
|
1485
|
+
return Object.assign({}, ...states);
|
|
1486
|
+
}
|
|
1487
|
+
function buildButtonStateColorTheme(options, config) {
|
|
1488
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _A, _B, _C, _D, _E, _F, _G, _H, _I, _J, _K, _L, _M, _N, _O, _P, _Q, _R, _S;
|
|
1489
|
+
const {
|
|
1490
|
+
mode,
|
|
1491
|
+
tone,
|
|
1492
|
+
scheme,
|
|
1493
|
+
state
|
|
1494
|
+
} = options;
|
|
1495
|
+
const tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.tokens) != null ? _b : defaultColorTokens;
|
|
1496
|
+
const hue = ((_f = (_e = (_d = (_c = tokens == null ? void 0 : tokens.button) == null ? void 0 : _c[tone]) == null ? void 0 : _d[mode]) == null ? void 0 : _e[state]) == null ? void 0 : _f._hue) || ((_j = (_i = (_h = (_g = tokens == null ? void 0 : tokens.button) == null ? void 0 : _g["*"]) == null ? void 0 : _h[mode]) == null ? void 0 : _i[state]) == null ? void 0 : _j._hue) || ((_l = (_k = tokens == null ? void 0 : tokens.button) == null ? void 0 : _k[tone]) == null ? void 0 : _l._hue) || ((_m = tokens == null ? void 0 : tokens[tone]) == null ? void 0 : _m._hue) || "gray";
|
|
1497
|
+
const spec3 = (_p = (_o = (_n = tokens == null ? void 0 : tokens.button) == null ? void 0 : _n["*"]) == null ? void 0 : _o[mode]) == null ? void 0 : _p["*"];
|
|
1498
|
+
const spec2 = (_s = (_r = (_q = tokens == null ? void 0 : tokens.button) == null ? void 0 : _q["*"]) == null ? void 0 : _r[mode]) == null ? void 0 : _s[state];
|
|
1499
|
+
const spec1 = (_v = (_u = (_t = tokens == null ? void 0 : tokens.button) == null ? void 0 : _t[tone]) == null ? void 0 : _u[mode]) == null ? void 0 : _v["*"];
|
|
1500
|
+
const spec0 = (_y = (_x = (_w = tokens == null ? void 0 : tokens.button) == null ? void 0 : _w[tone]) == null ? void 0 : _x[mode]) == null ? void 0 : _y[state];
|
|
1501
|
+
const _blend = (spec0 == null ? void 0 : spec0._blend) || (spec1 == null ? void 0 : spec1._blend) || (spec2 == null ? void 0 : spec2._blend) || (spec3 == null ? void 0 : spec3._blend) || ["screen", "multiply"];
|
|
1502
|
+
return {
|
|
1503
|
+
_blend: _blend[scheme === "light" ? 0 : 1],
|
|
1504
|
+
bg: resolveColorTokenValue({
|
|
1505
|
+
hue,
|
|
1506
|
+
scheme,
|
|
1507
|
+
value: (spec0 == null ? void 0 : spec0.bg) || (spec1 == null ? void 0 : spec1.bg) || (spec2 == null ? void 0 : spec2.bg) || (spec3 == null ? void 0 : spec3.bg) || ["500", "400"]
|
|
1508
|
+
}),
|
|
1509
|
+
bg2: resolveColorTokenValue({
|
|
1510
|
+
hue,
|
|
1511
|
+
scheme,
|
|
1512
|
+
value: (spec0 == null ? void 0 : spec0.bg2) || (spec1 == null ? void 0 : spec1.bg2) || (spec2 == null ? void 0 : spec2.bg2) || (spec3 == null ? void 0 : spec3.bg2) || ["500", "400"]
|
|
1513
|
+
}),
|
|
1514
|
+
fg: resolveColorTokenValue({
|
|
1515
|
+
hue,
|
|
1516
|
+
scheme,
|
|
1517
|
+
value: (spec0 == null ? void 0 : spec0.fg) || (spec1 == null ? void 0 : spec1.fg) || (spec2 == null ? void 0 : spec2.fg) || (spec3 == null ? void 0 : spec3.fg) || ["white", "black"]
|
|
1518
|
+
}),
|
|
1519
|
+
border: resolveColorTokenValue({
|
|
1520
|
+
hue,
|
|
1521
|
+
scheme,
|
|
1522
|
+
value: (spec0 == null ? void 0 : spec0.border) || (spec1 == null ? void 0 : spec1.border) || (spec2 == null ? void 0 : spec2.border) || (spec3 == null ? void 0 : spec3.border) || ["500", "400"]
|
|
1523
|
+
}),
|
|
1524
|
+
muted: {
|
|
1525
|
+
fg: resolveColorTokenValue({
|
|
1526
|
+
hue,
|
|
1527
|
+
scheme,
|
|
1528
|
+
value: ((_z = spec0 == null ? void 0 : spec0.muted) == null ? void 0 : _z.fg) || ((_A = spec1 == null ? void 0 : spec1.muted) == null ? void 0 : _A.fg) || ((_B = spec2 == null ? void 0 : spec2.muted) == null ? void 0 : _B.fg) || ((_C = spec3 == null ? void 0 : spec3.muted) == null ? void 0 : _C.fg) || ["500", "400"]
|
|
1529
|
+
})
|
|
1530
|
+
},
|
|
1531
|
+
accent: {
|
|
1532
|
+
fg: resolveColorTokenValue({
|
|
1533
|
+
hue,
|
|
1534
|
+
scheme,
|
|
1535
|
+
value: ((_D = spec0 == null ? void 0 : spec0.accent) == null ? void 0 : _D.fg) || ((_E = spec1 == null ? void 0 : spec1.accent) == null ? void 0 : _E.fg) || ((_F = spec2 == null ? void 0 : spec2.accent) == null ? void 0 : _F.fg) || ((_G = spec3 == null ? void 0 : spec3.accent) == null ? void 0 : _G.fg) || ["500", "400"]
|
|
1536
|
+
})
|
|
1537
|
+
},
|
|
1538
|
+
link: {
|
|
1539
|
+
fg: resolveColorTokenValue({
|
|
1540
|
+
hue,
|
|
1541
|
+
scheme,
|
|
1542
|
+
value: ((_H = spec0 == null ? void 0 : spec0.link) == null ? void 0 : _H.fg) || ((_I = spec1 == null ? void 0 : spec1.link) == null ? void 0 : _I.fg) || ((_J = spec2 == null ? void 0 : spec2.link) == null ? void 0 : _J.fg) || ((_K = spec3 == null ? void 0 : spec3.link) == null ? void 0 : _K.fg) || ["500", "400"]
|
|
1543
|
+
})
|
|
1544
|
+
},
|
|
1545
|
+
code: {
|
|
1546
|
+
bg: resolveColorTokenValue({
|
|
1547
|
+
hue,
|
|
1548
|
+
scheme,
|
|
1549
|
+
value: ((_L = spec0 == null ? void 0 : spec0.code) == null ? void 0 : _L.bg) || ((_M = spec1 == null ? void 0 : spec1.code) == null ? void 0 : _M.bg) || ((_N = spec2 == null ? void 0 : spec2.code) == null ? void 0 : _N.bg) || ((_O = spec3 == null ? void 0 : spec3.code) == null ? void 0 : _O.bg) || ["500", "400"]
|
|
1550
|
+
}),
|
|
1551
|
+
fg: resolveColorTokenValue({
|
|
1552
|
+
hue,
|
|
1553
|
+
scheme,
|
|
1554
|
+
value: ((_P = spec0 == null ? void 0 : spec0.code) == null ? void 0 : _P.fg) || ((_Q = spec1 == null ? void 0 : spec1.code) == null ? void 0 : _Q.fg) || ((_R = spec2 == null ? void 0 : spec2.code) == null ? void 0 : _R.fg) || ((_S = spec3 == null ? void 0 : spec3.code) == null ? void 0 : _S.fg) || ["500", "400"]
|
|
1555
|
+
})
|
|
1556
|
+
}
|
|
1557
|
+
};
|
|
1558
|
+
}
|
|
1559
|
+
function renderColorTheme(colorPalette, value) {
|
|
1560
|
+
return {
|
|
1561
|
+
light: renderColorScheme(colorPalette, value.light),
|
|
1562
|
+
dark: renderColorScheme(colorPalette, value.dark)
|
|
1563
|
+
};
|
|
1564
|
+
}
|
|
1565
|
+
function renderColorScheme(colorPalette, value) {
|
|
1566
|
+
const toneEntries = Object.entries(value);
|
|
1567
|
+
const [, transparentTone] = toneEntries.find(_ref4 => {
|
|
1568
|
+
let [k] = _ref4;
|
|
1569
|
+
return k === "transparent";
|
|
1570
|
+
});
|
|
1571
|
+
const [, defaultTone] = toneEntries.find(_ref5 => {
|
|
1572
|
+
let [k] = _ref5;
|
|
1573
|
+
return k === "default";
|
|
1574
|
+
});
|
|
1575
|
+
const renderedTransparentTone = renderColorBase(colorPalette, transparentTone, transparentTone._blend === "multiply" ? "#ffffff" : "#000000");
|
|
1576
|
+
const renderedDefaultTone = renderColorBase(colorPalette, defaultTone, defaultTone._blend === "multiply" ? "#ffffff" : "#000000");
|
|
1577
|
+
return Object.fromEntries([["transparent", renderedTransparentTone], ["default", renderedDefaultTone], ...toneEntries.filter(_ref6 => {
|
|
1578
|
+
let [k] = _ref6;
|
|
1579
|
+
return k !== "default" && k !== "transparent";
|
|
1580
|
+
}).map(_ref7 => {
|
|
1581
|
+
let [k, v] = _ref7;
|
|
1582
|
+
return [k, renderColorBase(colorPalette, v, renderedDefaultTone.base.bg)];
|
|
1583
|
+
})]);
|
|
1584
|
+
}
|
|
1585
|
+
function renderColorBase(colorPalette, value, bg) {
|
|
1586
|
+
const nestedBg = renderColorValue(colorPalette, bg, value._blend, value.base.bg);
|
|
1587
|
+
return {
|
|
1588
|
+
_blend: value._blend,
|
|
1589
|
+
dark: value.dark,
|
|
1590
|
+
base: {
|
|
1591
|
+
bg: nestedBg,
|
|
1592
|
+
fg: renderColorValue(colorPalette, nestedBg, value._blend, value.base.fg),
|
|
1593
|
+
border: renderColorValue(colorPalette, nestedBg, value._blend, value.base.border)
|
|
1594
|
+
},
|
|
1595
|
+
button: renderButtonColorTheme(colorPalette, nestedBg, value._blend, value.button)
|
|
1596
|
+
};
|
|
1597
|
+
}
|
|
1598
|
+
function renderButtonColorTheme(colorPalette, bg, baseBlendMode, value) {
|
|
1599
|
+
return {
|
|
1600
|
+
default: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.default),
|
|
1601
|
+
primary: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.primary),
|
|
1602
|
+
positive: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.positive),
|
|
1603
|
+
caution: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.caution),
|
|
1604
|
+
critical: renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value.critical)
|
|
1605
|
+
};
|
|
1606
|
+
}
|
|
1607
|
+
function renderButtonStateColorTheme(colorPalette, bg, baseBlendMode, value) {
|
|
1608
|
+
return {
|
|
1609
|
+
default: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.default),
|
|
1610
|
+
ghost: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.ghost),
|
|
1611
|
+
bleed: renderStatesColorTheme(colorPalette, bg, baseBlendMode, value.bleed)
|
|
1612
|
+
};
|
|
1613
|
+
}
|
|
1614
|
+
function renderStatesColorTheme(colorPalette, bg, baseBlendMode, value) {
|
|
1615
|
+
return {
|
|
1616
|
+
enabled: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.enabled),
|
|
1617
|
+
hovered: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.hovered),
|
|
1618
|
+
pressed: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.pressed),
|
|
1619
|
+
selected: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.selected),
|
|
1620
|
+
disabled: renderStateColorTheme(colorPalette, bg, baseBlendMode, value.disabled)
|
|
1621
|
+
};
|
|
1622
|
+
}
|
|
1623
|
+
function renderStateColorTheme(colorPalette, baseBg, rootBlendMode, value) {
|
|
1624
|
+
const blendMode = value._blend;
|
|
1625
|
+
const bg = rootBlendMode === "multiply" && value.bg === "white" ? "#ffffff" : rootBlendMode === "screen" && value.bg === "black" ? "#000000" : renderColorValue(colorPalette, rootBlendMode === "multiply" ? "#ffffff" : "#000000", rootBlendMode, value.bg);
|
|
1626
|
+
const bg2 = renderColorValue(colorPalette, bg, blendMode, value.bg2 || value.bg);
|
|
1627
|
+
const fg = renderColorValue(colorPalette, bg, blendMode, value.fg);
|
|
1628
|
+
const border = renderColorValue(colorPalette, bg, blendMode, value.border);
|
|
1629
|
+
const muted = {
|
|
1630
|
+
fg: renderColorValue(colorPalette, bg, blendMode, value.muted.fg)
|
|
1631
|
+
};
|
|
1632
|
+
const accent = {
|
|
1633
|
+
fg: renderColorValue(colorPalette, bg, blendMode, value.accent.fg)
|
|
1634
|
+
};
|
|
1635
|
+
const link = {
|
|
1636
|
+
fg: renderColorValue(colorPalette, bg, blendMode, value.link.fg)
|
|
1637
|
+
};
|
|
1638
|
+
const code = {
|
|
1639
|
+
bg: renderColorValue(colorPalette, bg, blendMode, value.code.bg),
|
|
1640
|
+
fg: renderColorValue(colorPalette, bg, blendMode, value.code.fg)
|
|
1641
|
+
};
|
|
1642
|
+
const blend = rootBlendMode === "multiply" ? multiply$1 : screen$1;
|
|
1643
|
+
return {
|
|
1644
|
+
_blend: blendMode,
|
|
1645
|
+
bg: blend(baseBg, bg),
|
|
1646
|
+
bg2: blend(baseBg, bg2),
|
|
1647
|
+
fg: blend(baseBg, fg),
|
|
1648
|
+
border: blend(baseBg, border),
|
|
1649
|
+
muted: {
|
|
1650
|
+
fg: blend(baseBg, muted.fg)
|
|
1651
|
+
},
|
|
1652
|
+
accent: {
|
|
1653
|
+
fg: blend(baseBg, accent.fg)
|
|
1654
|
+
},
|
|
1655
|
+
link: {
|
|
1656
|
+
fg: blend(baseBg, link.fg)
|
|
1657
|
+
},
|
|
1658
|
+
code: {
|
|
1659
|
+
bg: blend(baseBg, code.bg),
|
|
1660
|
+
fg: blend(baseBg, code.fg)
|
|
1661
|
+
}
|
|
1662
|
+
};
|
|
1663
|
+
}
|
|
1664
|
+
function renderColorValue(colorPalette, bg, blendMode, str) {
|
|
1665
|
+
const node = parseTokenValue(str);
|
|
1666
|
+
if (!node || node.type !== "color") {
|
|
1667
|
+
throw new Error("Invalid color token value: ".concat(str));
|
|
1668
|
+
}
|
|
1669
|
+
let hex = "";
|
|
1670
|
+
if (node.key === "black") {
|
|
1671
|
+
hex = renderColorHex(colorPalette.black);
|
|
1672
|
+
}
|
|
1673
|
+
if (node.key === "white") {
|
|
1674
|
+
hex = renderColorHex(colorPalette.white);
|
|
1675
|
+
}
|
|
1676
|
+
if (node.hue && node.tint) {
|
|
1677
|
+
hex = renderColorHex(colorPalette[node.hue][node.tint]);
|
|
1678
|
+
}
|
|
1679
|
+
if (!hex) {
|
|
1680
|
+
throw new Error("Invalid color token value: ".concat(str));
|
|
1681
|
+
}
|
|
1682
|
+
try {
|
|
1683
|
+
hex = blendMode === "multiply" ? multiply$1(bg, hex) : screen$1(bg, hex);
|
|
1684
|
+
} catch (err) {
|
|
1685
|
+
console.log("could not blend", hex);
|
|
1686
|
+
}
|
|
1687
|
+
if (node.opacity !== void 0) {
|
|
1688
|
+
hex = rgba(hex, node.opacity);
|
|
1689
|
+
}
|
|
1690
|
+
return hex;
|
|
1691
|
+
}
|
|
1692
|
+
function renderColorHex(color) {
|
|
1693
|
+
return typeof color === "string" ? color : color.hex;
|
|
1694
|
+
}
|
|
1695
|
+
const defaultColorPalette = {
|
|
1696
|
+
...color$1.color,
|
|
1697
|
+
black: "#000000"
|
|
1698
|
+
};
|
|
1699
|
+
function buildTheme(config) {
|
|
1700
|
+
var _a, _b;
|
|
1701
|
+
return {
|
|
1702
|
+
color: renderColorTheme((_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.palette) != null ? _b : defaultColorPalette, {
|
|
1703
|
+
light: buildColorTheme({
|
|
1704
|
+
scheme: "light"
|
|
1705
|
+
}, config),
|
|
1706
|
+
dark: buildColorTheme({
|
|
1707
|
+
scheme: "dark"
|
|
1708
|
+
}, config)
|
|
1709
|
+
})
|
|
1710
|
+
};
|
|
1711
|
+
}
|
|
1025
1712
|
function createButtonTones(opts, base, dark, solid, muted, mode) {
|
|
1026
1713
|
return {
|
|
1027
1714
|
default: opts.button({
|
|
@@ -1214,11 +1901,11 @@ const tones$1 = {
|
|
|
1214
1901
|
}
|
|
1215
1902
|
};
|
|
1216
1903
|
const defaultOpts = {
|
|
1217
|
-
base:
|
|
1904
|
+
base: _ref8 => {
|
|
1218
1905
|
let {
|
|
1219
1906
|
dark,
|
|
1220
1907
|
name
|
|
1221
|
-
} =
|
|
1908
|
+
} = _ref8;
|
|
1222
1909
|
if (name === "default") {
|
|
1223
1910
|
return {
|
|
1224
1911
|
bg: dark ? black : white,
|
|
@@ -1254,13 +1941,13 @@ const defaultOpts = {
|
|
|
1254
1941
|
}
|
|
1255
1942
|
};
|
|
1256
1943
|
},
|
|
1257
|
-
solid:
|
|
1944
|
+
solid: _ref9 => {
|
|
1258
1945
|
let {
|
|
1259
1946
|
base,
|
|
1260
1947
|
dark,
|
|
1261
1948
|
state,
|
|
1262
1949
|
tone
|
|
1263
|
-
} =
|
|
1950
|
+
} = _ref9;
|
|
1264
1951
|
const color = colors[tone];
|
|
1265
1952
|
if (state === "hovered") {
|
|
1266
1953
|
return {
|
|
@@ -1307,13 +1994,13 @@ const defaultOpts = {
|
|
|
1307
1994
|
skeleton: base.skeleton
|
|
1308
1995
|
};
|
|
1309
1996
|
},
|
|
1310
|
-
muted:
|
|
1997
|
+
muted: _ref10 => {
|
|
1311
1998
|
let {
|
|
1312
1999
|
base,
|
|
1313
2000
|
dark,
|
|
1314
2001
|
state,
|
|
1315
2002
|
tone
|
|
1316
|
-
} =
|
|
2003
|
+
} = _ref10;
|
|
1317
2004
|
const color = colors[tone];
|
|
1318
2005
|
if (state === "hovered") {
|
|
1319
2006
|
return {
|
|
@@ -1360,13 +2047,13 @@ const defaultOpts = {
|
|
|
1360
2047
|
skeleton: base.skeleton
|
|
1361
2048
|
};
|
|
1362
2049
|
},
|
|
1363
|
-
button:
|
|
2050
|
+
button: _ref11 => {
|
|
1364
2051
|
let {
|
|
1365
2052
|
base,
|
|
1366
2053
|
mode,
|
|
1367
2054
|
muted,
|
|
1368
2055
|
solid
|
|
1369
|
-
} =
|
|
2056
|
+
} = _ref11;
|
|
1370
2057
|
if (mode === "bleed") {
|
|
1371
2058
|
return {
|
|
1372
2059
|
...muted,
|
|
@@ -1420,10 +2107,10 @@ const defaultOpts = {
|
|
|
1420
2107
|
};
|
|
1421
2108
|
return solid;
|
|
1422
2109
|
},
|
|
1423
|
-
card:
|
|
2110
|
+
card: _ref12 => {
|
|
1424
2111
|
let {
|
|
1425
2112
|
base
|
|
1426
|
-
} =
|
|
2113
|
+
} = _ref12;
|
|
1427
2114
|
return {
|
|
1428
2115
|
bg: black,
|
|
1429
2116
|
bg2: black,
|
|
@@ -1455,18 +2142,18 @@ const defaultOpts = {
|
|
|
1455
2142
|
placeholder: black
|
|
1456
2143
|
};
|
|
1457
2144
|
},
|
|
1458
|
-
selectable:
|
|
2145
|
+
selectable: _ref13 => {
|
|
1459
2146
|
let {
|
|
1460
2147
|
muted,
|
|
1461
2148
|
state,
|
|
1462
2149
|
tone
|
|
1463
|
-
} =
|
|
2150
|
+
} = _ref13;
|
|
1464
2151
|
return muted[tone][state];
|
|
1465
2152
|
},
|
|
1466
|
-
spot:
|
|
2153
|
+
spot: _ref14 => {
|
|
1467
2154
|
let {
|
|
1468
2155
|
key
|
|
1469
|
-
} =
|
|
2156
|
+
} = _ref14;
|
|
1470
2157
|
return spots[key];
|
|
1471
2158
|
},
|
|
1472
2159
|
syntax: () => ({
|
|
@@ -2181,7 +2868,7 @@ function _createColor(opts, dark, name) {
|
|
|
2181
2868
|
function multiply(bg, fg) {
|
|
2182
2869
|
const b = parseColor(bg);
|
|
2183
2870
|
const s = parseColor(fg);
|
|
2184
|
-
const hex = rgbToHex(multiply$
|
|
2871
|
+
const hex = rgbToHex(multiply$2(b, s));
|
|
2185
2872
|
if (s.a) {
|
|
2186
2873
|
return rgba(hex, s.a);
|
|
2187
2874
|
}
|
|
@@ -2190,7 +2877,7 @@ function multiply(bg, fg) {
|
|
|
2190
2877
|
function screen(bg, fg) {
|
|
2191
2878
|
const b = parseColor(bg);
|
|
2192
2879
|
const s = parseColor(fg);
|
|
2193
|
-
const hex = rgbToHex(screen$
|
|
2880
|
+
const hex = rgbToHex(screen$2(b, s));
|
|
2194
2881
|
if (s.a) {
|
|
2195
2882
|
return rgba(hex, s.a);
|
|
2196
2883
|
}
|
|
@@ -2206,11 +2893,11 @@ const tones = {
|
|
|
2206
2893
|
};
|
|
2207
2894
|
const NEUTRAL_TONES = ["default", "transparent"];
|
|
2208
2895
|
const color = createColorTheme({
|
|
2209
|
-
base:
|
|
2896
|
+
base: _ref15 => {
|
|
2210
2897
|
let {
|
|
2211
2898
|
dark,
|
|
2212
2899
|
name
|
|
2213
|
-
} =
|
|
2900
|
+
} = _ref15;
|
|
2214
2901
|
if (name === "default") {
|
|
2215
2902
|
const tints2 = color$1.hues.gray;
|
|
2216
2903
|
const skeletonFrom2 = dark ? tints2[900].hex : tints2[100].hex;
|
|
@@ -2270,14 +2957,14 @@ const color = createColorTheme({
|
|
|
2270
2957
|
}
|
|
2271
2958
|
};
|
|
2272
2959
|
},
|
|
2273
|
-
solid:
|
|
2960
|
+
solid: _ref16 => {
|
|
2274
2961
|
let {
|
|
2275
2962
|
base,
|
|
2276
2963
|
dark,
|
|
2277
2964
|
name,
|
|
2278
2965
|
state,
|
|
2279
2966
|
tone
|
|
2280
|
-
} =
|
|
2967
|
+
} = _ref16;
|
|
2281
2968
|
const mix = dark ? screen : multiply;
|
|
2282
2969
|
const mix2 = dark ? multiply : screen;
|
|
2283
2970
|
const defaultTints = tones[name] || tones.default;
|
|
@@ -2431,14 +3118,14 @@ const color = createColorTheme({
|
|
|
2431
3118
|
}
|
|
2432
3119
|
};
|
|
2433
3120
|
},
|
|
2434
|
-
muted:
|
|
3121
|
+
muted: _ref17 => {
|
|
2435
3122
|
let {
|
|
2436
3123
|
base,
|
|
2437
3124
|
dark,
|
|
2438
3125
|
name,
|
|
2439
3126
|
state,
|
|
2440
3127
|
tone
|
|
2441
|
-
} =
|
|
3128
|
+
} = _ref17;
|
|
2442
3129
|
const mix = dark ? screen : multiply;
|
|
2443
3130
|
const defaultTints = tones[name] || tones.default;
|
|
2444
3131
|
const isNeutral = NEUTRAL_TONES.includes(name) && NEUTRAL_TONES.includes(tone);
|
|
@@ -2594,13 +3281,13 @@ const color = createColorTheme({
|
|
|
2594
3281
|
}
|
|
2595
3282
|
};
|
|
2596
3283
|
},
|
|
2597
|
-
button:
|
|
3284
|
+
button: _ref18 => {
|
|
2598
3285
|
let {
|
|
2599
3286
|
base,
|
|
2600
3287
|
mode,
|
|
2601
3288
|
muted,
|
|
2602
3289
|
solid
|
|
2603
|
-
} =
|
|
3290
|
+
} = _ref18;
|
|
2604
3291
|
if (mode === "bleed") {
|
|
2605
3292
|
return {
|
|
2606
3293
|
enabled: {
|
|
@@ -2637,7 +3324,7 @@ const color = createColorTheme({
|
|
|
2637
3324
|
}
|
|
2638
3325
|
return solid;
|
|
2639
3326
|
},
|
|
2640
|
-
card:
|
|
3327
|
+
card: _ref19 => {
|
|
2641
3328
|
let {
|
|
2642
3329
|
base,
|
|
2643
3330
|
dark,
|
|
@@ -2645,7 +3332,7 @@ const color = createColorTheme({
|
|
|
2645
3332
|
name,
|
|
2646
3333
|
solid,
|
|
2647
3334
|
state
|
|
2648
|
-
} =
|
|
3335
|
+
} = _ref19;
|
|
2649
3336
|
if (state === "hovered") {
|
|
2650
3337
|
return muted[name].hovered;
|
|
2651
3338
|
}
|
|
@@ -2695,13 +3382,13 @@ const color = createColorTheme({
|
|
|
2695
3382
|
}
|
|
2696
3383
|
};
|
|
2697
3384
|
},
|
|
2698
|
-
input:
|
|
3385
|
+
input: _ref20 => {
|
|
2699
3386
|
let {
|
|
2700
3387
|
base,
|
|
2701
3388
|
dark,
|
|
2702
3389
|
mode,
|
|
2703
3390
|
state
|
|
2704
|
-
} =
|
|
3391
|
+
} = _ref20;
|
|
2705
3392
|
const mix = dark ? screen : multiply;
|
|
2706
3393
|
if (mode === "invalid") {
|
|
2707
3394
|
const tints = tones.critical;
|
|
@@ -2753,14 +3440,14 @@ const color = createColorTheme({
|
|
|
2753
3440
|
placeholder: mix(base.bg, color$1.hues.gray[dark ? 600 : 400].hex)
|
|
2754
3441
|
};
|
|
2755
3442
|
},
|
|
2756
|
-
selectable:
|
|
3443
|
+
selectable: _ref21 => {
|
|
2757
3444
|
let {
|
|
2758
3445
|
base,
|
|
2759
3446
|
muted,
|
|
2760
3447
|
tone,
|
|
2761
3448
|
solid,
|
|
2762
3449
|
state
|
|
2763
|
-
} =
|
|
3450
|
+
} = _ref21;
|
|
2764
3451
|
if (state === "enabled") {
|
|
2765
3452
|
return {
|
|
2766
3453
|
...muted[tone].enabled,
|
|
@@ -2787,20 +3474,20 @@ const color = createColorTheme({
|
|
|
2787
3474
|
}
|
|
2788
3475
|
return muted[tone][state];
|
|
2789
3476
|
},
|
|
2790
|
-
spot:
|
|
3477
|
+
spot: _ref22 => {
|
|
2791
3478
|
let {
|
|
2792
3479
|
base,
|
|
2793
3480
|
dark,
|
|
2794
3481
|
key
|
|
2795
|
-
} =
|
|
3482
|
+
} = _ref22;
|
|
2796
3483
|
const mix = dark ? screen : multiply;
|
|
2797
3484
|
return mix(base.bg, color$1.hues[key][dark ? 400 : 500].hex);
|
|
2798
3485
|
},
|
|
2799
|
-
syntax:
|
|
3486
|
+
syntax: _ref23 => {
|
|
2800
3487
|
let {
|
|
2801
3488
|
base,
|
|
2802
3489
|
dark
|
|
2803
|
-
} =
|
|
3490
|
+
} = _ref23;
|
|
2804
3491
|
const mix = dark ? screen : multiply;
|
|
2805
3492
|
const mainShade = dark ? 400 : 600;
|
|
2806
3493
|
const secondaryShade = dark ? 600 : 400;
|
|
@@ -4649,10 +5336,10 @@ var __template$x = (cooked, raw) => __freeze$x(__defProp$y(cooked, "raw", {
|
|
|
4649
5336
|
value: __freeze$x(raw || cooked.slice())
|
|
4650
5337
|
}));
|
|
4651
5338
|
var _a$x, _b$k;
|
|
4652
|
-
function buttonBaseStyles(
|
|
5339
|
+
function buttonBaseStyles(_ref24) {
|
|
4653
5340
|
let {
|
|
4654
5341
|
$width
|
|
4655
|
-
} =
|
|
5342
|
+
} = _ref24;
|
|
4656
5343
|
return styled.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" && styled.css(_a$x || (_a$x = __template$x(["\n width: -webkit-fill-available;\n width: stretch;\n "]))));
|
|
4657
5344
|
}
|
|
4658
5345
|
const buttonTheme = {
|
|
@@ -5010,10 +5697,10 @@ var __template$t = (cooked, raw) => __freeze$t(__defProp$u(cooked, "raw", {
|
|
|
5010
5697
|
value: __freeze$t(raw || cooked.slice())
|
|
5011
5698
|
}));
|
|
5012
5699
|
var _a$t;
|
|
5013
|
-
function codeSyntaxHighlightingStyle(
|
|
5700
|
+
function codeSyntaxHighlightingStyle(_ref25) {
|
|
5014
5701
|
let {
|
|
5015
5702
|
theme
|
|
5016
|
-
} =
|
|
5703
|
+
} = _ref25;
|
|
5017
5704
|
const color = theme.sanity.color.syntax;
|
|
5018
5705
|
return {
|
|
5019
5706
|
"&.atrule": {
|
|
@@ -6321,13 +7008,13 @@ const Popover = react.memo(react.forwardRef(function Popover2(props, ref) {
|
|
|
6321
7008
|
}));
|
|
6322
7009
|
if (constrainSize || matchReferenceWidth) {
|
|
6323
7010
|
ret.push(size({
|
|
6324
|
-
apply(
|
|
7011
|
+
apply(_ref26) {
|
|
6325
7012
|
let {
|
|
6326
7013
|
availableWidth,
|
|
6327
7014
|
availableHeight,
|
|
6328
7015
|
elements,
|
|
6329
7016
|
referenceWidth
|
|
6330
|
-
} =
|
|
7017
|
+
} = _ref26;
|
|
6331
7018
|
referenceWidthRef.current = referenceWidth;
|
|
6332
7019
|
const _currentWidth = widthRef.current;
|
|
6333
7020
|
const _maxWidth = maxWidthRef.current;
|
|
@@ -7136,12 +7823,12 @@ const Tooltip = react.forwardRef(function Tooltip2(props, ref) {
|
|
|
7136
7823
|
mainAxis: 3
|
|
7137
7824
|
}));
|
|
7138
7825
|
ret.push(reactDom$1.size({
|
|
7139
|
-
apply(
|
|
7826
|
+
apply(_ref27) {
|
|
7140
7827
|
let {
|
|
7141
7828
|
availableWidth,
|
|
7142
7829
|
availableHeight,
|
|
7143
7830
|
elements
|
|
7144
|
-
} =
|
|
7831
|
+
} = _ref27;
|
|
7145
7832
|
Object.assign(elements.floating.style, {
|
|
7146
7833
|
maxWidth: "".concat(availableWidth - 4 * 2, "px"),
|
|
7147
7834
|
// the padding is `4px`
|
|
@@ -7447,10 +8134,10 @@ const InnerAutocomplete = react.forwardRef(function InnerAutocomplete2(props, re
|
|
|
7447
8134
|
query,
|
|
7448
8135
|
value
|
|
7449
8136
|
} = state;
|
|
7450
|
-
const defaultRenderOption = react.useCallback(
|
|
8137
|
+
const defaultRenderOption = react.useCallback(_ref28 => {
|
|
7451
8138
|
let {
|
|
7452
8139
|
value: value2
|
|
7453
|
-
} =
|
|
8140
|
+
} = _ref28;
|
|
7454
8141
|
return /* @__PURE__ */jsxRuntime.jsx(Card, {
|
|
7455
8142
|
"data-as": "button",
|
|
7456
8143
|
padding: paddingProp,
|
|
@@ -7904,10 +8591,10 @@ const Breadcrumbs = react.forwardRef(function Breadcrumbs2(props, ref) {
|
|
|
7904
8591
|
});
|
|
7905
8592
|
});
|
|
7906
8593
|
const BORDER_OFFSET_X = 12;
|
|
7907
|
-
function dialogStyle(
|
|
8594
|
+
function dialogStyle(_ref29) {
|
|
7908
8595
|
let {
|
|
7909
8596
|
theme
|
|
7910
|
-
} =
|
|
8597
|
+
} = _ref29;
|
|
7911
8598
|
const color = theme.sanity.color.base;
|
|
7912
8599
|
return {
|
|
7913
8600
|
"&:not([hidden])": {
|
|
@@ -8992,15 +9679,15 @@ var __template$6 = (cooked, raw) => __freeze$6(__defProp$6(cooked, "raw", {
|
|
|
8992
9679
|
var _a$6, _b$3, _c$1, _d;
|
|
8993
9680
|
const keyframe = styled.keyframes(_a$6 || (_a$6 = __template$6(["\n 0% {\n background-position: 100%;\n }\n 100% {\n background-position: -100%;\n }\n"])));
|
|
8994
9681
|
const animation = styled.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);
|
|
8995
|
-
const skeletonStyle = styled.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"])),
|
|
9682
|
+
const skeletonStyle = styled.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 => {
|
|
8996
9683
|
let {
|
|
8997
9684
|
$visible
|
|
8998
|
-
} =
|
|
9685
|
+
} = _ref30;
|
|
8999
9686
|
return $visible ? 1 : 0;
|
|
9000
|
-
},
|
|
9687
|
+
}, _ref31 => {
|
|
9001
9688
|
let {
|
|
9002
9689
|
$animated
|
|
9003
|
-
} =
|
|
9690
|
+
} = _ref31;
|
|
9004
9691
|
return $animated ? animation : styled.css(_c$1 || (_c$1 = __template$6(["\n background-color: var(--card-skeleton-color-from);\n "])));
|
|
9005
9692
|
});
|
|
9006
9693
|
const Root$4 = styled__default.default(Box)(responsiveRadiusStyle, skeletonStyle);
|
|
@@ -9031,12 +9718,12 @@ const Skeleton = react.forwardRef(function Skeleton2(props, ref) {
|
|
|
9031
9718
|
ref
|
|
9032
9719
|
});
|
|
9033
9720
|
});
|
|
9034
|
-
const Root$3 = styled__default.default(Skeleton)(
|
|
9721
|
+
const Root$3 = styled__default.default(Skeleton)(_ref32 => {
|
|
9035
9722
|
let {
|
|
9036
9723
|
$size,
|
|
9037
9724
|
$style,
|
|
9038
9725
|
theme
|
|
9039
|
-
} =
|
|
9726
|
+
} = _ref32;
|
|
9040
9727
|
const {
|
|
9041
9728
|
media
|
|
9042
9729
|
} = theme.sanity;
|
|
@@ -9384,12 +10071,12 @@ function ToastProvider(props) {
|
|
|
9384
10071
|
paddingY,
|
|
9385
10072
|
children: /* @__PURE__ */jsxRuntime.jsx(framerMotion.AnimatePresence, {
|
|
9386
10073
|
initial: false,
|
|
9387
|
-
children: state.map(
|
|
10074
|
+
children: state.map(_ref33 => {
|
|
9388
10075
|
let {
|
|
9389
10076
|
dismiss,
|
|
9390
10077
|
id,
|
|
9391
10078
|
params
|
|
9392
|
-
} =
|
|
10079
|
+
} = _ref33;
|
|
9393
10080
|
return /* @__PURE__ */jsxRuntime.jsx(framerMotion.motion.div, {
|
|
9394
10081
|
animate: {
|
|
9395
10082
|
opacity: 1,
|
|
@@ -9898,6 +10585,18 @@ exports.BoundaryElementProvider = BoundaryElementProvider;
|
|
|
9898
10585
|
exports.Box = Box;
|
|
9899
10586
|
exports.Breadcrumbs = Breadcrumbs;
|
|
9900
10587
|
exports.Button = Button;
|
|
10588
|
+
exports.COLOR_BASE_TONES = COLOR_BASE_TONES;
|
|
10589
|
+
exports.COLOR_BLEND_MODES = COLOR_BLEND_MODES;
|
|
10590
|
+
exports.COLOR_BUTTON_MODES = COLOR_BUTTON_MODES;
|
|
10591
|
+
exports.COLOR_CONFIG_BASE_KEYS = COLOR_CONFIG_BASE_KEYS;
|
|
10592
|
+
exports.COLOR_CONFIG_BASE_TONES = COLOR_CONFIG_BASE_TONES;
|
|
10593
|
+
exports.COLOR_CONFIG_BLEND_KEYS = COLOR_CONFIG_BLEND_KEYS;
|
|
10594
|
+
exports.COLOR_CONFIG_STATE_KEYS = COLOR_CONFIG_STATE_KEYS;
|
|
10595
|
+
exports.COLOR_CONFIG_STATE_TONES = COLOR_CONFIG_STATE_TONES;
|
|
10596
|
+
exports.COLOR_HUES = COLOR_HUES;
|
|
10597
|
+
exports.COLOR_STATES = COLOR_STATES;
|
|
10598
|
+
exports.COLOR_STATE_TONES = COLOR_STATE_TONES;
|
|
10599
|
+
exports.COLOR_TINTS = COLOR_TINTS;
|
|
9901
10600
|
exports.Card = Card;
|
|
9902
10601
|
exports.Checkbox = Checkbox;
|
|
9903
10602
|
exports.Code = Code;
|
|
@@ -9963,12 +10662,25 @@ exports._raf = _raf;
|
|
|
9963
10662
|
exports._raf2 = _raf2;
|
|
9964
10663
|
exports._responsive = _responsive;
|
|
9965
10664
|
exports.attemptFocus = attemptFocus;
|
|
10665
|
+
exports.buildTheme = buildTheme;
|
|
9966
10666
|
exports.containsOrEqualsElement = containsOrEqualsElement;
|
|
9967
10667
|
exports.createColorTheme = createColorTheme;
|
|
9968
10668
|
exports.focusFirstDescendant = focusFirstDescendant;
|
|
9969
10669
|
exports.focusLastDescendant = focusLastDescendant;
|
|
9970
10670
|
exports.hexToRgb = hexToRgb;
|
|
9971
10671
|
exports.hslToRgb = hslToRgb;
|
|
10672
|
+
exports.isColorBlendModeValue = isColorBlendModeValue;
|
|
10673
|
+
exports.isColorButtonMode = isColorButtonMode;
|
|
10674
|
+
exports.isColorConfigBaseKey = isColorConfigBaseKey;
|
|
10675
|
+
exports.isColorConfigBaseTone = isColorConfigBaseTone;
|
|
10676
|
+
exports.isColorConfigBlendKey = isColorConfigBlendKey;
|
|
10677
|
+
exports.isColorConfigStateKey = isColorConfigStateKey;
|
|
10678
|
+
exports.isColorConfigStateTone = isColorConfigStateTone;
|
|
10679
|
+
exports.isColorHueValue = isColorHueValue;
|
|
10680
|
+
exports.isColorOpacityValue = isColorOpacityValue;
|
|
10681
|
+
exports.isColorTintValue = isColorTintValue;
|
|
10682
|
+
exports.isColorTokenValue = isColorTokenValue;
|
|
10683
|
+
exports.isColorValue = isColorValue;
|
|
9972
10684
|
exports.isFocusable = isFocusable;
|
|
9973
10685
|
exports.isHTMLAnchorElement = isHTMLAnchorElement;
|
|
9974
10686
|
exports.isHTMLButtonElement = isHTMLButtonElement;
|
|
@@ -9976,8 +10688,10 @@ exports.isHTMLElement = isHTMLElement;
|
|
|
9976
10688
|
exports.isHTMLInputElement = isHTMLInputElement;
|
|
9977
10689
|
exports.isHTMLSelectElement = isHTMLSelectElement;
|
|
9978
10690
|
exports.isHTMLTextAreaElement = isHTMLTextAreaElement;
|
|
9979
|
-
exports.multiply = multiply$
|
|
10691
|
+
exports.multiply = multiply$2;
|
|
9980
10692
|
exports.parseColor = parseColor;
|
|
10693
|
+
exports.parseTokenKey = parseTokenKey;
|
|
10694
|
+
exports.parseTokenValue = parseTokenValue;
|
|
9981
10695
|
exports.rem = rem;
|
|
9982
10696
|
exports.responsiveCodeFontStyle = responsiveCodeFontStyle;
|
|
9983
10697
|
exports.responsiveHeadingFont = responsiveHeadingFont;
|
|
@@ -9988,7 +10702,7 @@ exports.rgbToHex = rgbToHex;
|
|
|
9988
10702
|
exports.rgbToHsl = rgbToHsl;
|
|
9989
10703
|
exports.rgba = rgba;
|
|
9990
10704
|
exports.rgbaToRGBA = rgbaToRGBA;
|
|
9991
|
-
exports.screen = screen$
|
|
10705
|
+
exports.screen = screen$2;
|
|
9992
10706
|
exports.studioTheme = studioTheme;
|
|
9993
10707
|
exports.useArrayProp = useArrayProp;
|
|
9994
10708
|
exports.useBoundaryElement = useBoundaryElement;
|