@sanity/ui 2.0.6 → 2.0.8
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.d.ts +11 -11
- package/dist/index.esm.js +1546 -3280
- package/dist/index.esm.js.map +1 -1
- package/dist/index.js +1434 -3304
- package/dist/index.js.map +1 -1
- package/dist/theme.esm.js +404 -692
- package/dist/theme.esm.js.map +1 -1
- package/dist/theme.js +352 -694
- package/dist/theme.js.map +1 -1
- package/package.json +26 -33
- package/theme.js +2 -0
- package/dist/index.cjs.mjs +0 -125
- package/dist/theme.cjs.mjs +0 -54
package/dist/theme.js
CHANGED
|
@@ -1,9 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
var color = require('@sanity/color');
|
|
6
|
-
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: !0 });
|
|
3
|
+
var color = require("@sanity/color");
|
|
7
4
|
function createSelectableTones(opts, base, dark, solid, muted) {
|
|
8
5
|
return {
|
|
9
6
|
default: _createSelectableStates(opts, base, dark, solid, muted, "default"),
|
|
@@ -57,7 +54,6 @@ function _createSelectableStates(opts, base, dark, solid, muted, tone) {
|
|
|
57
54
|
})
|
|
58
55
|
};
|
|
59
56
|
}
|
|
60
|
-
|
|
61
57
|
function createSolidTones(opts, base, dark, name) {
|
|
62
58
|
return {
|
|
63
59
|
default: {
|
|
@@ -104,7 +100,6 @@ function createSolidTones(opts, base, dark, name) {
|
|
|
104
100
|
}
|
|
105
101
|
};
|
|
106
102
|
}
|
|
107
|
-
|
|
108
103
|
function createButtonTones(opts, base, dark, solid, muted, mode) {
|
|
109
104
|
return {
|
|
110
105
|
default: opts.button({
|
|
@@ -144,7 +139,6 @@ function createButtonTones(opts, base, dark, solid, muted, mode) {
|
|
|
144
139
|
})
|
|
145
140
|
};
|
|
146
141
|
}
|
|
147
|
-
|
|
148
142
|
function createButtonModes(opts, base, dark, solid, muted) {
|
|
149
143
|
return {
|
|
150
144
|
default: createButtonTones(opts, base, dark, solid, muted, "default"),
|
|
@@ -152,7 +146,6 @@ function createButtonModes(opts, base, dark, solid, muted) {
|
|
|
152
146
|
bleed: createButtonTones(opts, base, dark, solid, muted, "bleed")
|
|
153
147
|
};
|
|
154
148
|
}
|
|
155
|
-
|
|
156
149
|
function createCardStates(opts, base, dark, name, solid, muted) {
|
|
157
150
|
return {
|
|
158
151
|
enabled: opts.card({
|
|
@@ -197,10 +190,7 @@ function createCardStates(opts, base, dark, name, solid, muted) {
|
|
|
197
190
|
})
|
|
198
191
|
};
|
|
199
192
|
}
|
|
200
|
-
|
|
201
|
-
const black = "hsl(0, 0%, 0%)";
|
|
202
|
-
const white = "hsl(0, 0%, 100%)";
|
|
203
|
-
const colors = {
|
|
193
|
+
const black = "hsl(0, 0%, 0%)", white = "hsl(0, 0%, 100%)", colors = {
|
|
204
194
|
default: {
|
|
205
195
|
lightest: "hsl(0, 0%, 95%)",
|
|
206
196
|
lighter: "hsl(0, 0%, 70%)",
|
|
@@ -255,8 +245,7 @@ const colors = {
|
|
|
255
245
|
darker: "hsl(0, 100%, 20%)",
|
|
256
246
|
darkest: "hsl(0, 100%, 5%)"
|
|
257
247
|
}
|
|
258
|
-
}
|
|
259
|
-
const spots = {
|
|
248
|
+
}, spots = {
|
|
260
249
|
gray: "hsl(0, 0%, 50%)",
|
|
261
250
|
red: "hsl(0, 100%, 50%)",
|
|
262
251
|
orange: "hsl(30, 100%, 50%)",
|
|
@@ -266,8 +255,7 @@ const spots = {
|
|
|
266
255
|
blue: "hsl(240, 100%, 50%)",
|
|
267
256
|
purple: "hsl(270, 100%, 50%)",
|
|
268
257
|
magenta: "hsl(300, 100%, 50%)"
|
|
269
|
-
}
|
|
270
|
-
const tones = {
|
|
258
|
+
}, tones = {
|
|
271
259
|
transparent: {
|
|
272
260
|
bg: [colors.transparent.darkest, colors.transparent.lightest],
|
|
273
261
|
fg: [colors.transparent.lightest, colors.transparent.darkest],
|
|
@@ -298,75 +286,66 @@ const tones = {
|
|
|
298
286
|
border: [colors.critical.darker, colors.critical.lighter],
|
|
299
287
|
focusRing: [colors.critical.base, colors.critical.base]
|
|
300
288
|
}
|
|
301
|
-
}
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
289
|
+
}, defaultOpts = {
|
|
290
|
+
base: ({ dark, name }) => name === "default" ? {
|
|
291
|
+
bg: dark ? black : white,
|
|
292
|
+
fg: dark ? white : black,
|
|
293
|
+
border: dark ? colors.default.darkest : colors.default.lightest,
|
|
294
|
+
focusRing: colors.primary.base,
|
|
295
|
+
shadow: {
|
|
296
|
+
outline: black,
|
|
297
|
+
umbra: black,
|
|
298
|
+
penumbra: black,
|
|
299
|
+
ambient: black
|
|
300
|
+
},
|
|
301
|
+
skeleton: {
|
|
302
|
+
from: dark ? white : black,
|
|
303
|
+
to: dark ? white : black
|
|
304
|
+
}
|
|
305
|
+
} : {
|
|
306
|
+
bg: tones[name].bg[dark ? 0 : 1],
|
|
307
|
+
fg: tones[name].fg[dark ? 0 : 1],
|
|
308
|
+
border: tones[name].border[dark ? 0 : 1],
|
|
309
|
+
focusRing: tones[name].focusRing[dark ? 0 : 1],
|
|
310
|
+
shadow: {
|
|
311
|
+
outline: black,
|
|
312
|
+
umbra: black,
|
|
313
|
+
penumbra: black,
|
|
314
|
+
ambient: black
|
|
315
|
+
},
|
|
316
|
+
skeleton: {
|
|
317
|
+
from: dark ? white : black,
|
|
318
|
+
to: dark ? white : black
|
|
321
319
|
}
|
|
322
|
-
return {
|
|
323
|
-
bg: tones[name].bg[dark ? 0 : 1],
|
|
324
|
-
fg: tones[name].fg[dark ? 0 : 1],
|
|
325
|
-
border: tones[name].border[dark ? 0 : 1],
|
|
326
|
-
focusRing: tones[name].focusRing[dark ? 0 : 1],
|
|
327
|
-
shadow: {
|
|
328
|
-
outline: black,
|
|
329
|
-
umbra: black,
|
|
330
|
-
penumbra: black,
|
|
331
|
-
ambient: black
|
|
332
|
-
},
|
|
333
|
-
skeleton: {
|
|
334
|
-
from: dark ? white : black,
|
|
335
|
-
to: dark ? white : black
|
|
336
|
-
}
|
|
337
|
-
};
|
|
338
320
|
},
|
|
339
321
|
solid: ({ base, dark, state, tone }) => {
|
|
340
|
-
const
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
border: dark ? color.light : color.dark,
|
|
368
|
-
fg: dark ? color.darkest : color.lightest,
|
|
369
|
-
icon: dark ? color.darkest : color.lightest,
|
|
322
|
+
const color2 = colors[tone];
|
|
323
|
+
return state === "hovered" ? {
|
|
324
|
+
bg: dark ? color2.light : color2.dark,
|
|
325
|
+
bg2: dark ? color2.light : color2.dark,
|
|
326
|
+
border: dark ? color2.lighter : color2.darker,
|
|
327
|
+
fg: dark ? color2.darkest : color2.lightest,
|
|
328
|
+
icon: dark ? color2.darkest : color2.lightest,
|
|
329
|
+
muted: {
|
|
330
|
+
fg: black
|
|
331
|
+
},
|
|
332
|
+
accent: {
|
|
333
|
+
fg: black
|
|
334
|
+
},
|
|
335
|
+
link: {
|
|
336
|
+
fg: black
|
|
337
|
+
},
|
|
338
|
+
code: {
|
|
339
|
+
bg: black,
|
|
340
|
+
fg: black
|
|
341
|
+
},
|
|
342
|
+
skeleton: base.skeleton
|
|
343
|
+
} : {
|
|
344
|
+
bg: color2.base,
|
|
345
|
+
bg2: color2.base,
|
|
346
|
+
border: dark ? color2.light : color2.dark,
|
|
347
|
+
fg: dark ? color2.darkest : color2.lightest,
|
|
348
|
+
icon: dark ? color2.darkest : color2.lightest,
|
|
370
349
|
muted: {
|
|
371
350
|
fg: black
|
|
372
351
|
},
|
|
@@ -384,36 +363,13 @@ const defaultOpts = {
|
|
|
384
363
|
};
|
|
385
364
|
},
|
|
386
365
|
muted: ({ base, dark, state, tone }) => {
|
|
387
|
-
const
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
icon: dark ? color.lightest : color.darkest,
|
|
395
|
-
muted: {
|
|
396
|
-
fg: black
|
|
397
|
-
},
|
|
398
|
-
accent: {
|
|
399
|
-
fg: black
|
|
400
|
-
},
|
|
401
|
-
link: {
|
|
402
|
-
fg: black
|
|
403
|
-
},
|
|
404
|
-
code: {
|
|
405
|
-
bg: black,
|
|
406
|
-
fg: black
|
|
407
|
-
},
|
|
408
|
-
skeleton: base.skeleton
|
|
409
|
-
};
|
|
410
|
-
}
|
|
411
|
-
return {
|
|
412
|
-
bg: dark ? color.darkest : color.lightest,
|
|
413
|
-
bg2: dark ? color.darkest : color.lightest,
|
|
414
|
-
border: dark ? color.darker : color.lighter,
|
|
415
|
-
fg: dark ? color.lighter : color.darker,
|
|
416
|
-
icon: dark ? color.lighter : color.darker,
|
|
366
|
+
const color2 = colors[tone];
|
|
367
|
+
return state === "hovered" ? {
|
|
368
|
+
bg: dark ? color2.darker : color2.lighter,
|
|
369
|
+
bg2: dark ? color2.darker : color2.lighter,
|
|
370
|
+
border: dark ? color2.lighter : color2.darker,
|
|
371
|
+
fg: dark ? color2.lightest : color2.darkest,
|
|
372
|
+
icon: dark ? color2.lightest : color2.darkest,
|
|
417
373
|
muted: {
|
|
418
374
|
fg: black
|
|
419
375
|
},
|
|
@@ -428,70 +384,12 @@ const defaultOpts = {
|
|
|
428
384
|
fg: black
|
|
429
385
|
},
|
|
430
386
|
skeleton: base.skeleton
|
|
431
|
-
}
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
enabled: {
|
|
438
|
-
bg: "transparent",
|
|
439
|
-
bg2: "transparent",
|
|
440
|
-
fg: muted.enabled.fg,
|
|
441
|
-
icon: muted.enabled.fg,
|
|
442
|
-
border: "transparent",
|
|
443
|
-
muted: {
|
|
444
|
-
fg: black
|
|
445
|
-
},
|
|
446
|
-
accent: {
|
|
447
|
-
fg: black
|
|
448
|
-
},
|
|
449
|
-
link: {
|
|
450
|
-
fg: black
|
|
451
|
-
},
|
|
452
|
-
code: {
|
|
453
|
-
bg: black,
|
|
454
|
-
fg: black
|
|
455
|
-
},
|
|
456
|
-
skeleton: base.skeleton
|
|
457
|
-
},
|
|
458
|
-
hovered: {
|
|
459
|
-
bg: muted.enabled.bg,
|
|
460
|
-
bg2: muted.enabled.bg,
|
|
461
|
-
fg: muted.hovered.fg,
|
|
462
|
-
icon: muted.hovered.fg,
|
|
463
|
-
border: "transparent",
|
|
464
|
-
muted: {
|
|
465
|
-
fg: black
|
|
466
|
-
},
|
|
467
|
-
accent: {
|
|
468
|
-
fg: black
|
|
469
|
-
},
|
|
470
|
-
link: {
|
|
471
|
-
fg: black
|
|
472
|
-
},
|
|
473
|
-
code: {
|
|
474
|
-
bg: black,
|
|
475
|
-
fg: black
|
|
476
|
-
},
|
|
477
|
-
skeleton: base.skeleton
|
|
478
|
-
}
|
|
479
|
-
};
|
|
480
|
-
}
|
|
481
|
-
if (mode === "ghost")
|
|
482
|
-
return {
|
|
483
|
-
...solid,
|
|
484
|
-
enabled: muted.enabled
|
|
485
|
-
};
|
|
486
|
-
return solid;
|
|
487
|
-
},
|
|
488
|
-
card: ({ base }) => {
|
|
489
|
-
return {
|
|
490
|
-
bg: black,
|
|
491
|
-
bg2: black,
|
|
492
|
-
fg: black,
|
|
493
|
-
icon: black,
|
|
494
|
-
border: black,
|
|
387
|
+
} : {
|
|
388
|
+
bg: dark ? color2.darkest : color2.lightest,
|
|
389
|
+
bg2: dark ? color2.darkest : color2.lightest,
|
|
390
|
+
border: dark ? color2.darker : color2.lighter,
|
|
391
|
+
fg: dark ? color2.lighter : color2.darker,
|
|
392
|
+
icon: dark ? color2.lighter : color2.darker,
|
|
495
393
|
muted: {
|
|
496
394
|
fg: black
|
|
497
395
|
},
|
|
@@ -508,21 +406,84 @@ const defaultOpts = {
|
|
|
508
406
|
skeleton: base.skeleton
|
|
509
407
|
};
|
|
510
408
|
},
|
|
511
|
-
|
|
512
|
-
|
|
409
|
+
button: ({ base, mode, muted, solid }) => mode === "bleed" ? {
|
|
410
|
+
...muted,
|
|
411
|
+
enabled: {
|
|
412
|
+
bg: "transparent",
|
|
413
|
+
bg2: "transparent",
|
|
414
|
+
fg: muted.enabled.fg,
|
|
415
|
+
icon: muted.enabled.fg,
|
|
416
|
+
border: "transparent",
|
|
417
|
+
muted: {
|
|
418
|
+
fg: black
|
|
419
|
+
},
|
|
420
|
+
accent: {
|
|
421
|
+
fg: black
|
|
422
|
+
},
|
|
423
|
+
link: {
|
|
424
|
+
fg: black
|
|
425
|
+
},
|
|
426
|
+
code: {
|
|
427
|
+
bg: black,
|
|
428
|
+
fg: black
|
|
429
|
+
},
|
|
430
|
+
skeleton: base.skeleton
|
|
431
|
+
},
|
|
432
|
+
hovered: {
|
|
433
|
+
bg: muted.enabled.bg,
|
|
434
|
+
bg2: muted.enabled.bg,
|
|
435
|
+
fg: muted.hovered.fg,
|
|
436
|
+
icon: muted.hovered.fg,
|
|
437
|
+
border: "transparent",
|
|
438
|
+
muted: {
|
|
439
|
+
fg: black
|
|
440
|
+
},
|
|
441
|
+
accent: {
|
|
442
|
+
fg: black
|
|
443
|
+
},
|
|
444
|
+
link: {
|
|
445
|
+
fg: black
|
|
446
|
+
},
|
|
447
|
+
code: {
|
|
448
|
+
bg: black,
|
|
449
|
+
fg: black
|
|
450
|
+
},
|
|
451
|
+
skeleton: base.skeleton
|
|
452
|
+
}
|
|
453
|
+
} : mode === "ghost" ? {
|
|
454
|
+
...solid,
|
|
455
|
+
enabled: muted.enabled
|
|
456
|
+
} : solid,
|
|
457
|
+
card: ({ base }) => ({
|
|
458
|
+
bg: black,
|
|
459
|
+
bg2: black,
|
|
460
|
+
fg: black,
|
|
461
|
+
icon: black,
|
|
462
|
+
border: black,
|
|
463
|
+
muted: {
|
|
464
|
+
fg: black
|
|
465
|
+
},
|
|
466
|
+
accent: {
|
|
467
|
+
fg: black
|
|
468
|
+
},
|
|
469
|
+
link: {
|
|
470
|
+
fg: black
|
|
471
|
+
},
|
|
472
|
+
code: {
|
|
513
473
|
bg: black,
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
},
|
|
474
|
+
fg: black
|
|
475
|
+
},
|
|
476
|
+
skeleton: base.skeleton
|
|
477
|
+
}),
|
|
478
|
+
input: () => ({
|
|
479
|
+
bg: black,
|
|
480
|
+
bg2: black,
|
|
481
|
+
fg: black,
|
|
482
|
+
border: black,
|
|
483
|
+
placeholder: black
|
|
484
|
+
}),
|
|
485
|
+
selectable: ({ muted, state, tone }) => muted[tone][state],
|
|
486
|
+
spot: ({ key }) => spots[key],
|
|
526
487
|
syntax: () => ({
|
|
527
488
|
atrule: black,
|
|
528
489
|
attrName: black,
|
|
@@ -562,7 +523,6 @@ const defaultOpts = {
|
|
|
562
523
|
variable: black
|
|
563
524
|
})
|
|
564
525
|
};
|
|
565
|
-
|
|
566
526
|
function createInputModes(opts, base, dark, solid, muted) {
|
|
567
527
|
return {
|
|
568
528
|
default: {
|
|
@@ -635,7 +595,6 @@ function createInputModes(opts, base, dark, solid, muted) {
|
|
|
635
595
|
}
|
|
636
596
|
};
|
|
637
597
|
}
|
|
638
|
-
|
|
639
598
|
function createMutedTones(opts, base, dark, name) {
|
|
640
599
|
return {
|
|
641
600
|
default: {
|
|
@@ -682,7 +641,6 @@ function createMutedTones(opts, base, dark, name) {
|
|
|
682
641
|
}
|
|
683
642
|
};
|
|
684
643
|
}
|
|
685
|
-
|
|
686
644
|
function createSpot(opts, base, dark) {
|
|
687
645
|
return {
|
|
688
646
|
gray: opts.spot({ base, dark, key: "gray" }),
|
|
@@ -696,12 +654,11 @@ function createSpot(opts, base, dark) {
|
|
|
696
654
|
cyan: opts.spot({ base, dark, key: "cyan" })
|
|
697
655
|
};
|
|
698
656
|
}
|
|
699
|
-
|
|
700
657
|
function createColorTheme(partialOpts = {}) {
|
|
701
658
|
const builders = { ...defaultOpts, ...partialOpts };
|
|
702
659
|
return {
|
|
703
|
-
light: _createColorScheme(builders,
|
|
704
|
-
dark: _createColorScheme(builders,
|
|
660
|
+
light: _createColorScheme(builders, !1),
|
|
661
|
+
dark: _createColorScheme(builders, !0)
|
|
705
662
|
};
|
|
706
663
|
}
|
|
707
664
|
function _createColorScheme(opts, dark) {
|
|
@@ -715,9 +672,7 @@ function _createColorScheme(opts, dark) {
|
|
|
715
672
|
};
|
|
716
673
|
}
|
|
717
674
|
function _createColor(opts, dark, name) {
|
|
718
|
-
const base = opts.base({ dark, name });
|
|
719
|
-
const solid = createSolidTones(opts, base, dark, name);
|
|
720
|
-
const muted = createMutedTones(opts, base, dark, name);
|
|
675
|
+
const base = opts.base({ dark, name }), solid = createSolidTones(opts, base, dark, name), muted = createMutedTones(opts, base, dark, name);
|
|
721
676
|
return {
|
|
722
677
|
base,
|
|
723
678
|
button: createButtonModes(opts, base, dark, solid, muted),
|
|
@@ -731,10 +686,7 @@ function _createColor(opts, dark, name) {
|
|
|
731
686
|
muted
|
|
732
687
|
};
|
|
733
688
|
}
|
|
734
|
-
|
|
735
|
-
const BORDER_WIDTH = 1;
|
|
736
|
-
const OUTLINE_WIDTH = 0.5;
|
|
737
|
-
const defaultThemeConfig = {
|
|
689
|
+
const BORDER_WIDTH = 1, OUTLINE_WIDTH = 0.5, defaultThemeConfig = {
|
|
738
690
|
_version: 2,
|
|
739
691
|
avatar: {
|
|
740
692
|
sizes: [
|
|
@@ -812,9 +764,7 @@ const defaultThemeConfig = {
|
|
|
812
764
|
// },
|
|
813
765
|
// },
|
|
814
766
|
}
|
|
815
|
-
}
|
|
816
|
-
|
|
817
|
-
const defaultThemeFonts = {
|
|
767
|
+
}, defaultThemeFonts = {
|
|
818
768
|
code: {
|
|
819
769
|
family: "ui-monospace, SFMono-Regular, SF Mono, Menlo, Consolas, Liberation Mono, monospace",
|
|
820
770
|
weights: {
|
|
@@ -1035,16 +985,13 @@ const defaultThemeFonts = {
|
|
|
1035
985
|
}
|
|
1036
986
|
]
|
|
1037
987
|
}
|
|
1038
|
-
};
|
|
1039
|
-
|
|
1040
|
-
const cache$4 = /* @__PURE__ */ new WeakMap();
|
|
988
|
+
}, cache$4 = /* @__PURE__ */ new WeakMap();
|
|
1041
989
|
function themeColor_v0_v2(color_v0) {
|
|
1042
990
|
var _a, _b, _c;
|
|
1043
991
|
const cached_v2 = cache$4.get(color_v0);
|
|
1044
992
|
if (cached_v2)
|
|
1045
993
|
return cached_v2;
|
|
1046
|
-
const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled)
|
|
1047
|
-
const color_v2 = {
|
|
994
|
+
const base = stateThemeColor_v0_v2(color_v0, color_v0.card.enabled), color_v2 = {
|
|
1048
995
|
_blend: color_v0._blend || (color_v0.dark ? "screen" : "multiply"),
|
|
1049
996
|
_dark: color_v0.dark,
|
|
1050
997
|
accent: base.accent,
|
|
@@ -1080,8 +1027,7 @@ function themeColor_v0_v2(color_v0) {
|
|
|
1080
1027
|
},
|
|
1081
1028
|
syntax: color_v0.syntax
|
|
1082
1029
|
};
|
|
1083
|
-
cache$4.set(color_v0, color_v2);
|
|
1084
|
-
return color_v2;
|
|
1030
|
+
return cache$4.set(color_v0, color_v2), color_v2;
|
|
1085
1031
|
}
|
|
1086
1032
|
function stateTonesThemeColor_v0_v2(v0, t) {
|
|
1087
1033
|
return {
|
|
@@ -1230,18 +1176,17 @@ function inputStateThemeColor_v0_v2(state) {
|
|
|
1230
1176
|
placeholder: state.placeholder
|
|
1231
1177
|
};
|
|
1232
1178
|
}
|
|
1233
|
-
|
|
1234
1179
|
const cache$3 = /* @__PURE__ */ new WeakMap();
|
|
1235
1180
|
function getTheme_v2(theme) {
|
|
1236
|
-
var _a;
|
|
1237
|
-
if ((_a = theme.sanity.v2)
|
|
1181
|
+
var _a, _b;
|
|
1182
|
+
if ((_a = theme.sanity.v2) != null && _a._resolved)
|
|
1238
1183
|
return theme.sanity.v2;
|
|
1239
1184
|
const cached_v2 = cache$3.get(theme);
|
|
1240
1185
|
if (cached_v2)
|
|
1241
1186
|
return cached_v2;
|
|
1242
1187
|
const v2 = {
|
|
1243
1188
|
_version: 2,
|
|
1244
|
-
_resolved:
|
|
1189
|
+
_resolved: !0,
|
|
1245
1190
|
avatar: {
|
|
1246
1191
|
...defaultThemeConfig.avatar,
|
|
1247
1192
|
...theme.sanity.avatar
|
|
@@ -1270,25 +1215,21 @@ function getTheme_v2(theme) {
|
|
|
1270
1215
|
...theme.sanity.input.switch
|
|
1271
1216
|
}
|
|
1272
1217
|
},
|
|
1273
|
-
layer: theme.sanity.layer
|
|
1218
|
+
layer: (_b = theme.sanity.layer) != null ? _b : defaultThemeConfig.layer,
|
|
1274
1219
|
media: theme.sanity.media,
|
|
1275
1220
|
radius: theme.sanity.radius,
|
|
1276
1221
|
shadow: theme.sanity.shadows,
|
|
1277
1222
|
space: theme.sanity.space,
|
|
1278
1223
|
style: theme.sanity.styles
|
|
1279
1224
|
};
|
|
1280
|
-
cache$3.set(theme, v2);
|
|
1281
|
-
return v2;
|
|
1225
|
+
return cache$3.set(theme, v2), v2;
|
|
1282
1226
|
}
|
|
1283
|
-
|
|
1284
1227
|
function is_v0(themeProp) {
|
|
1285
1228
|
return themeProp._version === 0;
|
|
1286
1229
|
}
|
|
1287
|
-
|
|
1288
1230
|
function is_v2(themeProp) {
|
|
1289
1231
|
return themeProp._version === 2;
|
|
1290
1232
|
}
|
|
1291
|
-
|
|
1292
1233
|
const cache$2 = /* @__PURE__ */ new WeakMap();
|
|
1293
1234
|
function v0_v2(v0) {
|
|
1294
1235
|
if (v0.v2)
|
|
@@ -1299,7 +1240,7 @@ function v0_v2(v0) {
|
|
|
1299
1240
|
const {
|
|
1300
1241
|
avatar,
|
|
1301
1242
|
button,
|
|
1302
|
-
color,
|
|
1243
|
+
color: color2,
|
|
1303
1244
|
container,
|
|
1304
1245
|
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
1305
1246
|
focusRing: _unused_focusRing,
|
|
@@ -1311,8 +1252,7 @@ function v0_v2(v0) {
|
|
|
1311
1252
|
shadows: shadow,
|
|
1312
1253
|
space,
|
|
1313
1254
|
styles: style
|
|
1314
|
-
} = v0
|
|
1315
|
-
const v2 = {
|
|
1255
|
+
} = v0, v2 = {
|
|
1316
1256
|
_version: 2,
|
|
1317
1257
|
avatar: {
|
|
1318
1258
|
...defaultThemeConfig.avatar,
|
|
@@ -1325,20 +1265,20 @@ function v0_v2(v0) {
|
|
|
1325
1265
|
card: defaultThemeConfig.card,
|
|
1326
1266
|
color: {
|
|
1327
1267
|
light: {
|
|
1328
|
-
transparent: themeColor_v0_v2(
|
|
1329
|
-
default: themeColor_v0_v2(
|
|
1330
|
-
primary: themeColor_v0_v2(
|
|
1331
|
-
positive: themeColor_v0_v2(
|
|
1332
|
-
caution: themeColor_v0_v2(
|
|
1333
|
-
critical: themeColor_v0_v2(
|
|
1268
|
+
transparent: themeColor_v0_v2(color2.light.transparent),
|
|
1269
|
+
default: themeColor_v0_v2(color2.light.default),
|
|
1270
|
+
primary: themeColor_v0_v2(color2.light.primary),
|
|
1271
|
+
positive: themeColor_v0_v2(color2.light.positive),
|
|
1272
|
+
caution: themeColor_v0_v2(color2.light.caution),
|
|
1273
|
+
critical: themeColor_v0_v2(color2.light.critical)
|
|
1334
1274
|
},
|
|
1335
1275
|
dark: {
|
|
1336
|
-
transparent: themeColor_v0_v2(
|
|
1337
|
-
default: themeColor_v0_v2(
|
|
1338
|
-
primary: themeColor_v0_v2(
|
|
1339
|
-
positive: themeColor_v0_v2(
|
|
1340
|
-
caution: themeColor_v0_v2(
|
|
1341
|
-
critical: themeColor_v0_v2(
|
|
1276
|
+
transparent: themeColor_v0_v2(color2.dark.transparent),
|
|
1277
|
+
default: themeColor_v0_v2(color2.dark.default),
|
|
1278
|
+
primary: themeColor_v0_v2(color2.dark.primary),
|
|
1279
|
+
positive: themeColor_v0_v2(color2.dark.positive),
|
|
1280
|
+
caution: themeColor_v0_v2(color2.dark.caution),
|
|
1281
|
+
critical: themeColor_v0_v2(color2.dark.critical)
|
|
1342
1282
|
}
|
|
1343
1283
|
},
|
|
1344
1284
|
container,
|
|
@@ -1359,17 +1299,15 @@ function v0_v2(v0) {
|
|
|
1359
1299
|
...input.switch
|
|
1360
1300
|
}
|
|
1361
1301
|
},
|
|
1362
|
-
layer: layer
|
|
1302
|
+
layer: layer != null ? layer : defaultThemeConfig.layer,
|
|
1363
1303
|
media,
|
|
1364
1304
|
radius,
|
|
1365
1305
|
shadow,
|
|
1366
1306
|
space,
|
|
1367
1307
|
style
|
|
1368
1308
|
};
|
|
1369
|
-
cache$2.set(v0, v2);
|
|
1370
|
-
return v2;
|
|
1309
|
+
return cache$2.set(v0, v2), v2;
|
|
1371
1310
|
}
|
|
1372
|
-
|
|
1373
1311
|
const cache$1 = /* @__PURE__ */ new WeakMap();
|
|
1374
1312
|
function v2_v0(v2) {
|
|
1375
1313
|
const cachedTheme = cache$1.get(v2);
|
|
@@ -1378,7 +1316,7 @@ function v2_v0(v2) {
|
|
|
1378
1316
|
const {
|
|
1379
1317
|
avatar,
|
|
1380
1318
|
button,
|
|
1381
|
-
color,
|
|
1319
|
+
color: color2,
|
|
1382
1320
|
container,
|
|
1383
1321
|
font: fonts,
|
|
1384
1322
|
input,
|
|
@@ -1395,20 +1333,20 @@ function v2_v0(v2) {
|
|
|
1395
1333
|
container,
|
|
1396
1334
|
color: {
|
|
1397
1335
|
light: {
|
|
1398
|
-
transparent: themeColor_v2_v0(
|
|
1399
|
-
default: themeColor_v2_v0(
|
|
1400
|
-
primary: themeColor_v2_v0(
|
|
1401
|
-
positive: themeColor_v2_v0(
|
|
1402
|
-
caution: themeColor_v2_v0(
|
|
1403
|
-
critical: themeColor_v2_v0(
|
|
1336
|
+
transparent: themeColor_v2_v0(color2.light.transparent),
|
|
1337
|
+
default: themeColor_v2_v0(color2.light.default),
|
|
1338
|
+
primary: themeColor_v2_v0(color2.light.primary),
|
|
1339
|
+
positive: themeColor_v2_v0(color2.light.positive),
|
|
1340
|
+
caution: themeColor_v2_v0(color2.light.caution),
|
|
1341
|
+
critical: themeColor_v2_v0(color2.light.critical)
|
|
1404
1342
|
},
|
|
1405
1343
|
dark: {
|
|
1406
|
-
transparent: themeColor_v2_v0(
|
|
1407
|
-
default: themeColor_v2_v0(
|
|
1408
|
-
primary: themeColor_v2_v0(
|
|
1409
|
-
positive: themeColor_v2_v0(
|
|
1410
|
-
caution: themeColor_v2_v0(
|
|
1411
|
-
critical: themeColor_v2_v0(
|
|
1344
|
+
transparent: themeColor_v2_v0(color2.dark.transparent),
|
|
1345
|
+
default: themeColor_v2_v0(color2.dark.default),
|
|
1346
|
+
primary: themeColor_v2_v0(color2.dark.primary),
|
|
1347
|
+
positive: themeColor_v2_v0(color2.dark.positive),
|
|
1348
|
+
caution: themeColor_v2_v0(color2.dark.caution),
|
|
1349
|
+
critical: themeColor_v2_v0(color2.dark.critical)
|
|
1412
1350
|
}
|
|
1413
1351
|
},
|
|
1414
1352
|
focusRing: input.text.focusRing,
|
|
@@ -1478,30 +1416,20 @@ function inputStateThemeColor_v2_v0(t) {
|
|
|
1478
1416
|
placeholder: t.placeholder
|
|
1479
1417
|
};
|
|
1480
1418
|
}
|
|
1481
|
-
|
|
1482
|
-
const THEME_COLOR_SCHEMES = ["light", "dark"];
|
|
1483
|
-
const THEME_COLOR_BLEND_MODES = ["multiply", "screen"];
|
|
1484
|
-
const THEME_COLOR_CARD_TONES = [
|
|
1419
|
+
const THEME_COLOR_SCHEMES = ["light", "dark"], THEME_COLOR_BLEND_MODES = ["multiply", "screen"], THEME_COLOR_CARD_TONES = [
|
|
1485
1420
|
"transparent",
|
|
1486
1421
|
"default",
|
|
1487
1422
|
"primary",
|
|
1488
1423
|
"positive",
|
|
1489
1424
|
"caution",
|
|
1490
1425
|
"critical"
|
|
1491
|
-
]
|
|
1492
|
-
const THEME_COLOR_STATE_TONES = [
|
|
1426
|
+
], THEME_COLOR_STATE_TONES = [
|
|
1493
1427
|
"default",
|
|
1494
1428
|
"primary",
|
|
1495
1429
|
"positive",
|
|
1496
1430
|
"caution",
|
|
1497
1431
|
"critical"
|
|
1498
|
-
];
|
|
1499
|
-
const THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"];
|
|
1500
|
-
const THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"];
|
|
1501
|
-
const THEME_COLOR_INPUT_MODES = ["default", "invalid"];
|
|
1502
|
-
const THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"];
|
|
1503
|
-
const THEME_COLOR_AVATAR_COLORS = color.COLOR_HUES;
|
|
1504
|
-
|
|
1432
|
+
], THEME_COLOR_STATES = ["enabled", "hovered", "pressed", "selected", "disabled"], THEME_COLOR_BUTTON_MODES = ["default", "ghost", "bleed"], THEME_COLOR_INPUT_MODES = ["default", "invalid"], THEME_COLOR_INPUT_STATES = ["enabled", "hovered", "readOnly", "disabled"], THEME_COLOR_AVATAR_COLORS = color.COLOR_HUES;
|
|
1505
1433
|
function isColorBlendModeValue(str) {
|
|
1506
1434
|
return THEME_COLOR_BLEND_MODES.includes(str);
|
|
1507
1435
|
}
|
|
@@ -1514,7 +1442,6 @@ function isColorTintKey(str) {
|
|
|
1514
1442
|
function isColorButtonMode(str) {
|
|
1515
1443
|
return THEME_COLOR_BUTTON_MODES.includes(str);
|
|
1516
1444
|
}
|
|
1517
|
-
|
|
1518
1445
|
const COLOR_CONFIG_STATE_KEYS = [
|
|
1519
1446
|
"_hue",
|
|
1520
1447
|
"bg",
|
|
@@ -1530,8 +1457,7 @@ const COLOR_CONFIG_STATE_KEYS = [
|
|
|
1530
1457
|
"skeleton/to",
|
|
1531
1458
|
"status/dot",
|
|
1532
1459
|
"status/icon"
|
|
1533
|
-
]
|
|
1534
|
-
const COLOR_CONFIG_CARD_KEYS = [
|
|
1460
|
+
], COLOR_CONFIG_CARD_KEYS = [
|
|
1535
1461
|
...COLOR_CONFIG_STATE_KEYS,
|
|
1536
1462
|
"_hue",
|
|
1537
1463
|
"bg",
|
|
@@ -1542,34 +1468,23 @@ const COLOR_CONFIG_CARD_KEYS = [
|
|
|
1542
1468
|
"shadow/umbra",
|
|
1543
1469
|
"shadow/penumbra",
|
|
1544
1470
|
"shadow/ambient"
|
|
1545
|
-
];
|
|
1546
|
-
const COLOR_CONFIG_BLEND_KEYS = ["_blend"];
|
|
1547
|
-
const COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS];
|
|
1548
|
-
const COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES];
|
|
1549
|
-
const COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES];
|
|
1550
|
-
const COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES];
|
|
1551
|
-
const COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES];
|
|
1552
|
-
const COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
|
|
1553
|
-
|
|
1471
|
+
], COLOR_CONFIG_BLEND_KEYS = ["_blend"], COLOR_CONFIG_AVATAR_COLORS = ["*", ...THEME_COLOR_AVATAR_COLORS], COLOR_CONFIG_CARD_TONES = ["*", ...THEME_COLOR_CARD_TONES], COLOR_CONFIG_STATE_TONES = ["*", ...THEME_COLOR_STATE_TONES], COLOR_CONFIG_STATES = ["*", ...THEME_COLOR_STATES], COLOR_CONFIG_INPUT_MODES = ["*", ...THEME_COLOR_INPUT_MODES], COLOR_CONFIG_INPUT_STATES = ["*", ...THEME_COLOR_INPUT_STATES];
|
|
1554
1472
|
function parseTokenKey(str) {
|
|
1555
|
-
const segments = str.split("/");
|
|
1556
|
-
const segment0 = segments.shift() || "";
|
|
1473
|
+
const segments = str.split("/"), segment0 = segments.shift() || "";
|
|
1557
1474
|
if (isColorConfigBaseTone(segment0)) {
|
|
1558
1475
|
const key = segments.join("/");
|
|
1559
|
-
if (isColorConfigBaseKey(key))
|
|
1476
|
+
if (isColorConfigBaseKey(key))
|
|
1560
1477
|
return {
|
|
1561
1478
|
type: "base",
|
|
1562
1479
|
tone: segment0,
|
|
1563
1480
|
key
|
|
1564
1481
|
};
|
|
1565
|
-
|
|
1566
|
-
if (isColorConfigBlendKey(key)) {
|
|
1482
|
+
if (isColorConfigBlendKey(key))
|
|
1567
1483
|
return {
|
|
1568
1484
|
type: "base",
|
|
1569
1485
|
tone: segment0,
|
|
1570
1486
|
key
|
|
1571
1487
|
};
|
|
1572
|
-
}
|
|
1573
1488
|
}
|
|
1574
1489
|
if (segment0 === "button") {
|
|
1575
1490
|
const segment1 = segments.shift() || "";
|
|
@@ -1577,28 +1492,24 @@ function parseTokenKey(str) {
|
|
|
1577
1492
|
const segment2 = segments.shift() || "";
|
|
1578
1493
|
if (isColorButtonMode(segment2)) {
|
|
1579
1494
|
const key = segments.join("/");
|
|
1580
|
-
if (isColorConfigStateKey(key))
|
|
1495
|
+
if (isColorConfigStateKey(key))
|
|
1581
1496
|
return {
|
|
1582
1497
|
type: "button",
|
|
1583
1498
|
tone: segment1,
|
|
1584
1499
|
mode: segment2,
|
|
1585
1500
|
key
|
|
1586
1501
|
};
|
|
1587
|
-
|
|
1588
|
-
if (isColorConfigBlendKey(key)) {
|
|
1502
|
+
if (isColorConfigBlendKey(key))
|
|
1589
1503
|
return {
|
|
1590
1504
|
type: "button",
|
|
1591
1505
|
tone: segment1,
|
|
1592
1506
|
mode: segment2,
|
|
1593
1507
|
key
|
|
1594
1508
|
};
|
|
1595
|
-
}
|
|
1596
1509
|
}
|
|
1597
1510
|
}
|
|
1598
1511
|
}
|
|
1599
|
-
return void 0;
|
|
1600
1512
|
}
|
|
1601
|
-
|
|
1602
1513
|
function isColorMixPercentValue(str) {
|
|
1603
1514
|
return /^\d+%$/.test(str);
|
|
1604
1515
|
}
|
|
@@ -1607,14 +1518,13 @@ function parseTokenValue(str) {
|
|
|
1607
1518
|
let nextSegment = segments.shift() || "";
|
|
1608
1519
|
const [segment0, segment0mix] = nextSegment.split(" ");
|
|
1609
1520
|
if (isColorTintKey(segment0)) {
|
|
1610
|
-
const tint = segment0;
|
|
1611
|
-
const segment1 = segments.shift() || "";
|
|
1521
|
+
const tint = segment0, segment1 = segments.shift() || "";
|
|
1612
1522
|
if (isColorMixPercentValue(segment0mix)) {
|
|
1613
|
-
const
|
|
1523
|
+
const mix2 = Number(segment0mix.slice(0, -1)) / 100;
|
|
1614
1524
|
return {
|
|
1615
1525
|
type: "color",
|
|
1616
1526
|
tint,
|
|
1617
|
-
mix
|
|
1527
|
+
mix: mix2
|
|
1618
1528
|
};
|
|
1619
1529
|
}
|
|
1620
1530
|
if (isColorOpacityValue(segment1)) {
|
|
@@ -1631,14 +1541,13 @@ function parseTokenValue(str) {
|
|
|
1631
1541
|
};
|
|
1632
1542
|
}
|
|
1633
1543
|
if (isColorValue(segment0)) {
|
|
1634
|
-
const key = segment0;
|
|
1635
|
-
const segment1 = segments.shift() || "";
|
|
1544
|
+
const key = segment0, segment1 = segments.shift() || "";
|
|
1636
1545
|
if (isColorMixPercentValue(segment0mix)) {
|
|
1637
|
-
const
|
|
1546
|
+
const mix2 = Number(segment0mix.slice(0, -1)) / 100;
|
|
1638
1547
|
return {
|
|
1639
1548
|
type: "color",
|
|
1640
1549
|
key,
|
|
1641
|
-
mix
|
|
1550
|
+
mix: mix2
|
|
1642
1551
|
};
|
|
1643
1552
|
}
|
|
1644
1553
|
if (isColorOpacityValue(segment1)) {
|
|
@@ -1659,15 +1568,14 @@ function parseTokenValue(str) {
|
|
|
1659
1568
|
nextSegment = segments.shift() || "";
|
|
1660
1569
|
const [segment1, segment1mix] = nextSegment.split(" ");
|
|
1661
1570
|
if (isColorTintKey(segment1)) {
|
|
1662
|
-
const tint = segment1;
|
|
1663
|
-
const segment2 = segments.shift() || "";
|
|
1571
|
+
const tint = segment1, segment2 = segments.shift() || "";
|
|
1664
1572
|
if (isColorMixPercentValue(segment1mix)) {
|
|
1665
|
-
const
|
|
1573
|
+
const mix2 = Number(segment1mix.slice(0, -1)) / 100;
|
|
1666
1574
|
return {
|
|
1667
1575
|
type: "color",
|
|
1668
1576
|
hue,
|
|
1669
1577
|
tint,
|
|
1670
|
-
mix
|
|
1578
|
+
mix: mix2
|
|
1671
1579
|
};
|
|
1672
1580
|
}
|
|
1673
1581
|
if (isColorOpacityValue(segment2)) {
|
|
@@ -1690,16 +1598,12 @@ function parseTokenValue(str) {
|
|
|
1690
1598
|
value: hue
|
|
1691
1599
|
};
|
|
1692
1600
|
}
|
|
1693
|
-
if (isColorBlendModeValue(segment0))
|
|
1694
|
-
const value = segment0;
|
|
1601
|
+
if (isColorBlendModeValue(segment0))
|
|
1695
1602
|
return {
|
|
1696
1603
|
type: "blendMode",
|
|
1697
|
-
value
|
|
1604
|
+
value: segment0
|
|
1698
1605
|
};
|
|
1699
|
-
}
|
|
1700
|
-
return void 0;
|
|
1701
1606
|
}
|
|
1702
|
-
|
|
1703
1607
|
function isColorConfigBaseTone(str) {
|
|
1704
1608
|
return COLOR_CONFIG_CARD_TONES.includes(str);
|
|
1705
1609
|
}
|
|
@@ -1725,33 +1629,17 @@ function isColorValue(str) {
|
|
|
1725
1629
|
function isColorOpacityValue(str) {
|
|
1726
1630
|
return str === "0" || /^0\.[0-9]+$/.test(str) || str === "1";
|
|
1727
1631
|
}
|
|
1728
|
-
|
|
1729
1632
|
function compileColorTokenValue(node) {
|
|
1730
1633
|
let key = "";
|
|
1731
|
-
|
|
1732
|
-
key = node.key;
|
|
1733
|
-
} else {
|
|
1734
|
-
key = `${node.hue}/${node.tint}`;
|
|
1735
|
-
}
|
|
1736
|
-
if (node.mix !== void 0) {
|
|
1737
|
-
return `${key} ${node.mix * 100}%`;
|
|
1738
|
-
}
|
|
1739
|
-
if (node.opacity !== void 0) {
|
|
1740
|
-
key += `/${node.opacity}`;
|
|
1741
|
-
}
|
|
1742
|
-
return key;
|
|
1634
|
+
return node.key === "black" || node.key === "white" ? key = node.key : key = `${node.hue}/${node.tint}`, node.mix !== void 0 ? `${key} ${node.mix * 100}%` : (node.opacity !== void 0 && (key += `/${node.opacity}`), key);
|
|
1743
1635
|
}
|
|
1744
|
-
|
|
1745
1636
|
const DEFAULT_COLOR_TOKEN_VALUE = ["500", "500"];
|
|
1746
1637
|
function resolveColorTokenValue(context, value = DEFAULT_COLOR_TOKEN_VALUE) {
|
|
1747
|
-
const { hue, scheme } = context;
|
|
1748
|
-
|
|
1749
|
-
if (!node || node.type !== "color") {
|
|
1638
|
+
const { hue, scheme } = context, node = parseTokenValue(value[scheme === "light" ? 0 : 1]);
|
|
1639
|
+
if (!node || node.type !== "color")
|
|
1750
1640
|
throw new Error(`Invalid color token: ${value[0]}`);
|
|
1751
|
-
}
|
|
1752
1641
|
return compileColorTokenValue({ ...node, hue: node.hue || hue });
|
|
1753
1642
|
}
|
|
1754
|
-
|
|
1755
1643
|
const defaultColorTokens = {
|
|
1756
1644
|
base: {
|
|
1757
1645
|
"*": {
|
|
@@ -2328,31 +2216,20 @@ const defaultColorTokens = {
|
|
|
2328
2216
|
variable: ["red/600", "red/400"]
|
|
2329
2217
|
}
|
|
2330
2218
|
};
|
|
2331
|
-
|
|
2332
2219
|
function isRecord(value) {
|
|
2333
|
-
return
|
|
2220
|
+
return !!(value && typeof value == "object" && !Array.isArray(value));
|
|
2334
2221
|
}
|
|
2335
|
-
|
|
2336
2222
|
function merge(...records) {
|
|
2337
2223
|
const _records = records.filter(Boolean);
|
|
2338
|
-
|
|
2339
|
-
return {};
|
|
2340
|
-
}
|
|
2341
|
-
return _records.reduce(_merge, {});
|
|
2224
|
+
return _records.length === 0 ? {} : _records.reduce(_merge, {});
|
|
2342
2225
|
}
|
|
2343
2226
|
function _merge(acc, source) {
|
|
2344
2227
|
for (const key of Object.keys(source)) {
|
|
2345
|
-
const prevValue = acc[key];
|
|
2346
|
-
|
|
2347
|
-
if (isRecord(prevValue) && isRecord(nextValue)) {
|
|
2348
|
-
acc[key] = merge(prevValue, nextValue);
|
|
2349
|
-
} else {
|
|
2350
|
-
acc[key] = nextValue;
|
|
2351
|
-
}
|
|
2228
|
+
const prevValue = acc[key], nextValue = source[key];
|
|
2229
|
+
isRecord(prevValue) && isRecord(nextValue) ? acc[key] = merge(prevValue, nextValue) : acc[key] = nextValue;
|
|
2352
2230
|
}
|
|
2353
2231
|
return acc;
|
|
2354
2232
|
}
|
|
2355
|
-
|
|
2356
2233
|
function resolveColorTokens(inputTokens) {
|
|
2357
2234
|
const tokens = merge(defaultColorTokens, inputTokens);
|
|
2358
2235
|
return {
|
|
@@ -2365,15 +2242,13 @@ function resolveColorTokens(inputTokens) {
|
|
|
2365
2242
|
}
|
|
2366
2243
|
function resolveBaseColorTokens(sparseTokens) {
|
|
2367
2244
|
const tokens = {};
|
|
2368
|
-
for (const tone of THEME_COLOR_CARD_TONES)
|
|
2245
|
+
for (const tone of THEME_COLOR_CARD_TONES)
|
|
2369
2246
|
tokens[tone] = resolveBaseColorTones(sparseTokens, tone);
|
|
2370
|
-
}
|
|
2371
2247
|
return tokens;
|
|
2372
2248
|
}
|
|
2373
2249
|
function resolveBaseColorTones(inputTokens, tone) {
|
|
2374
2250
|
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;
|
|
2375
|
-
const spec = merge((_a = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _a["*"], (_b = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _b[tone]);
|
|
2376
|
-
const hue = spec._hue || ((_d = (_c = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _c[tone]) == null ? void 0 : _d._hue) || "gray";
|
|
2251
|
+
const spec = merge((_a = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _a["*"], (_b = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _b[tone]), hue = spec._hue || ((_d = (_c = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _c[tone]) == null ? void 0 : _d._hue) || "gray";
|
|
2377
2252
|
return {
|
|
2378
2253
|
...spec,
|
|
2379
2254
|
_hue: hue,
|
|
@@ -2419,23 +2294,20 @@ function resolveBaseColorTones(inputTokens, tone) {
|
|
|
2419
2294
|
}
|
|
2420
2295
|
function resolveButtonColorTokens(inputTokens) {
|
|
2421
2296
|
const tokens = {};
|
|
2422
|
-
for (const mode of THEME_COLOR_BUTTON_MODES)
|
|
2297
|
+
for (const mode of THEME_COLOR_BUTTON_MODES)
|
|
2423
2298
|
tokens[mode] = resolveButtonToneColorTokens(inputTokens, mode);
|
|
2424
|
-
}
|
|
2425
2299
|
return tokens;
|
|
2426
2300
|
}
|
|
2427
2301
|
function resolveButtonToneColorTokens(inputTokens, mode) {
|
|
2428
2302
|
const tokens = {};
|
|
2429
|
-
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2303
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2430
2304
|
tokens[tone] = resolveButtonModeColorTokens(inputTokens, mode, tone);
|
|
2431
|
-
}
|
|
2432
2305
|
return tokens;
|
|
2433
2306
|
}
|
|
2434
2307
|
function resolveButtonModeColorTokens(inputTokens, mode, tone) {
|
|
2435
2308
|
const tokens = {};
|
|
2436
|
-
for (const state of THEME_COLOR_STATES)
|
|
2309
|
+
for (const state of THEME_COLOR_STATES)
|
|
2437
2310
|
tokens[state] = resolveButtonStateColorTokens(inputTokens, tone, mode, state);
|
|
2438
|
-
}
|
|
2439
2311
|
return tokens;
|
|
2440
2312
|
}
|
|
2441
2313
|
function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
|
|
@@ -2445,8 +2317,7 @@ function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
|
|
|
2445
2317
|
(_f = (_e = (_d = inputTokens == null ? void 0 : inputTokens.button) == null ? void 0 : _d[mode]) == null ? void 0 : _e[tone]) == null ? void 0 : _f["*"],
|
|
2446
2318
|
(_i = (_h = (_g = inputTokens == null ? void 0 : inputTokens.button) == null ? void 0 : _g[mode]) == null ? void 0 : _h["*"]) == null ? void 0 : _i[state],
|
|
2447
2319
|
(_l = (_k = (_j = inputTokens == null ? void 0 : inputTokens.button) == null ? void 0 : _j[mode]) == null ? void 0 : _k[tone]) == null ? void 0 : _l[state]
|
|
2448
|
-
);
|
|
2449
|
-
const hue = spec._hue || ((_n = (_m = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _m[tone]) == null ? void 0 : _n._hue);
|
|
2320
|
+
), hue = spec._hue || ((_n = (_m = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _m[tone]) == null ? void 0 : _n._hue);
|
|
2450
2321
|
return {
|
|
2451
2322
|
...spec,
|
|
2452
2323
|
_hue: hue,
|
|
@@ -2492,16 +2363,14 @@ function resolveButtonStateColorTokens(inputTokens, tone, mode, state) {
|
|
|
2492
2363
|
}
|
|
2493
2364
|
function resolveInputColorTokens(inputTokens) {
|
|
2494
2365
|
const tokens = {};
|
|
2495
|
-
for (const mode of THEME_COLOR_INPUT_MODES)
|
|
2366
|
+
for (const mode of THEME_COLOR_INPUT_MODES)
|
|
2496
2367
|
tokens[mode] = resolveInputModeColorTokens(inputTokens, mode);
|
|
2497
|
-
}
|
|
2498
2368
|
return tokens;
|
|
2499
2369
|
}
|
|
2500
2370
|
function resolveInputModeColorTokens(inputTokens, mode) {
|
|
2501
2371
|
const states = {};
|
|
2502
|
-
for (const state of THEME_COLOR_INPUT_STATES)
|
|
2372
|
+
for (const state of THEME_COLOR_INPUT_STATES)
|
|
2503
2373
|
states[state] = resolveInputStateColorTokens(inputTokens, mode, state);
|
|
2504
|
-
}
|
|
2505
2374
|
return states;
|
|
2506
2375
|
}
|
|
2507
2376
|
function resolveInputStateColorTokens(inputTokens, mode, state) {
|
|
@@ -2511,15 +2380,13 @@ function resolveInputStateColorTokens(inputTokens, mode, state) {
|
|
|
2511
2380
|
(_d = (_c = inputTokens == null ? void 0 : inputTokens.input) == null ? void 0 : _c[mode]) == null ? void 0 : _d["*"],
|
|
2512
2381
|
(_f = (_e = inputTokens == null ? void 0 : inputTokens.input) == null ? void 0 : _e["*"]) == null ? void 0 : _f[state],
|
|
2513
2382
|
(_h = (_g = inputTokens == null ? void 0 : inputTokens.input) == null ? void 0 : _g[mode]) == null ? void 0 : _h[state]
|
|
2514
|
-
);
|
|
2515
|
-
const hue = spec._hue || ((_j = (_i = inputTokens == null ? void 0 : inputTokens.input) == null ? void 0 : _i[mode]) == null ? void 0 : _j._hue);
|
|
2383
|
+
), hue = spec._hue || ((_j = (_i = inputTokens == null ? void 0 : inputTokens.input) == null ? void 0 : _i[mode]) == null ? void 0 : _j._hue);
|
|
2516
2384
|
return { ...spec, _hue: hue };
|
|
2517
2385
|
}
|
|
2518
2386
|
function resolveSelectableColorTokens(inputTokens) {
|
|
2519
2387
|
const tokens = {};
|
|
2520
|
-
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2388
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2521
2389
|
tokens[tone] = resolveSelectableToneColorTokens(inputTokens, tone);
|
|
2522
|
-
}
|
|
2523
2390
|
return tokens;
|
|
2524
2391
|
}
|
|
2525
2392
|
function resolveSelectableToneColorTokens(inputTokens, tone) {
|
|
@@ -2527,9 +2394,8 @@ function resolveSelectableToneColorTokens(inputTokens, tone) {
|
|
|
2527
2394
|
const states = {
|
|
2528
2395
|
_hue: ((_b = (_a = inputTokens == null ? void 0 : inputTokens.selectable) == null ? void 0 : _a[tone]) == null ? void 0 : _b._hue) || ((_d = (_c = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _c[tone]) == null ? void 0 : _d._hue)
|
|
2529
2396
|
};
|
|
2530
|
-
for (const state of THEME_COLOR_STATES)
|
|
2397
|
+
for (const state of THEME_COLOR_STATES)
|
|
2531
2398
|
states[state] = resolveSelectableStateColorTokens(inputTokens, tone, state);
|
|
2532
|
-
}
|
|
2533
2399
|
return states;
|
|
2534
2400
|
}
|
|
2535
2401
|
function resolveSelectableStateColorTokens(inputTokens, tone, state) {
|
|
@@ -2539,8 +2405,7 @@ function resolveSelectableStateColorTokens(inputTokens, tone, state) {
|
|
|
2539
2405
|
(_d = (_c = inputTokens == null ? void 0 : inputTokens.selectable) == null ? void 0 : _c[tone]) == null ? void 0 : _d["*"],
|
|
2540
2406
|
(_f = (_e = inputTokens == null ? void 0 : inputTokens.selectable) == null ? void 0 : _e["*"]) == null ? void 0 : _f[state],
|
|
2541
2407
|
(_h = (_g = inputTokens == null ? void 0 : inputTokens.selectable) == null ? void 0 : _g[tone]) == null ? void 0 : _h[state]
|
|
2542
|
-
);
|
|
2543
|
-
const hue = spec._hue || ((_j = (_i = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _i[tone]) == null ? void 0 : _j._hue);
|
|
2408
|
+
), hue = spec._hue || ((_j = (_i = inputTokens == null ? void 0 : inputTokens.base) == null ? void 0 : _i[tone]) == null ? void 0 : _j._hue);
|
|
2544
2409
|
return {
|
|
2545
2410
|
...spec,
|
|
2546
2411
|
_hue: hue,
|
|
@@ -2584,7 +2449,6 @@ function resolveSelectableStateColorTokens(inputTokens, tone, state) {
|
|
|
2584
2449
|
}
|
|
2585
2450
|
};
|
|
2586
2451
|
}
|
|
2587
|
-
|
|
2588
2452
|
function buildColorTheme(config) {
|
|
2589
2453
|
const resolvedConfig = {
|
|
2590
2454
|
...config,
|
|
@@ -2608,13 +2472,9 @@ function buildColorScheme(options, config) {
|
|
|
2608
2472
|
}
|
|
2609
2473
|
function buildCardColorTheme(options, config) {
|
|
2610
2474
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
2611
|
-
const { scheme, tone } = options;
|
|
2612
|
-
const tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone];
|
|
2613
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
|
|
2614
|
-
const context = { hue, scheme };
|
|
2615
|
-
const blendMode = (tokens == null ? void 0 : tokens._blend) || ["multiply", "screen"];
|
|
2475
|
+
const { scheme, tone } = options, tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone], context = { hue: (tokens == null ? void 0 : tokens._hue) || "gray", scheme };
|
|
2616
2476
|
return {
|
|
2617
|
-
_blend:
|
|
2477
|
+
_blend: ((tokens == null ? void 0 : tokens._blend) || ["multiply", "screen"])[scheme === "light" ? 0 : 1],
|
|
2618
2478
|
_dark: scheme === "dark",
|
|
2619
2479
|
accent: {
|
|
2620
2480
|
fg: resolveColorTokenValue(context, (_c = tokens == null ? void 0 : tokens.accent) == null ? void 0 : _c.fg)
|
|
@@ -2656,10 +2516,7 @@ function buildCardColorTheme(options, config) {
|
|
|
2656
2516
|
}
|
|
2657
2517
|
function buildShadowColorTheme(options, config) {
|
|
2658
2518
|
var _a, _b, _c, _d, _e, _f;
|
|
2659
|
-
const { scheme, tone } = options;
|
|
2660
|
-
const tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone];
|
|
2661
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
|
|
2662
|
-
const context = { hue, scheme };
|
|
2519
|
+
const { scheme, tone } = options, tokens = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone], context = { hue: (tokens == null ? void 0 : tokens._hue) || "gray", scheme };
|
|
2663
2520
|
return {
|
|
2664
2521
|
outline: resolveColorTokenValue(context, (_c = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _c.outline),
|
|
2665
2522
|
umbra: resolveColorTokenValue(context, (_d = tokens == null ? void 0 : tokens.shadow) == null ? void 0 : _d.umbra),
|
|
@@ -2683,12 +2540,9 @@ function buildAvatarColorTheme(options, stateTokens) {
|
|
|
2683
2540
|
}
|
|
2684
2541
|
function _buildAvatarColorTheme(options, stateTokens) {
|
|
2685
2542
|
var _a;
|
|
2686
|
-
const { color, scheme } = options;
|
|
2687
|
-
const tokens = (_a = stateTokens == null ? void 0 : stateTokens.avatar) == null ? void 0 : _a[color];
|
|
2688
|
-
const context = { hue: (tokens == null ? void 0 : tokens._hue) || "gray", scheme };
|
|
2689
|
-
const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
|
|
2543
|
+
const { color: color2, scheme } = options, tokens = (_a = stateTokens == null ? void 0 : stateTokens.avatar) == null ? void 0 : _a[color2], context = { hue: (tokens == null ? void 0 : tokens._hue) || "gray", scheme };
|
|
2690
2544
|
return {
|
|
2691
|
-
_blend:
|
|
2545
|
+
_blend: ((tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"])[scheme === "light" ? 0 : 1],
|
|
2692
2546
|
bg: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.bg),
|
|
2693
2547
|
fg: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.fg)
|
|
2694
2548
|
};
|
|
@@ -2705,10 +2559,7 @@ function buildBadgeColorTheme(tokens, options, config) {
|
|
|
2705
2559
|
}
|
|
2706
2560
|
function _buildBadgeColorTheme(parentTokens, options, config) {
|
|
2707
2561
|
var _a, _b, _c;
|
|
2708
|
-
const { scheme, tone } = options;
|
|
2709
|
-
const tokens = parentTokens == null ? void 0 : parentTokens[tone];
|
|
2710
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || ((_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone]) == null ? void 0 : _c._hue) || "gray";
|
|
2711
|
-
const context = { hue, scheme };
|
|
2562
|
+
const { scheme, tone } = options, tokens = parentTokens == null ? void 0 : parentTokens[tone], context = { hue: (tokens == null ? void 0 : tokens._hue) || ((_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.base) == null ? void 0 : _b[tone]) == null ? void 0 : _c._hue) || "gray", scheme };
|
|
2712
2563
|
return {
|
|
2713
2564
|
bg: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.bg),
|
|
2714
2565
|
fg: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.fg),
|
|
@@ -2717,36 +2568,26 @@ function _buildBadgeColorTheme(parentTokens, options, config) {
|
|
|
2717
2568
|
};
|
|
2718
2569
|
}
|
|
2719
2570
|
function buildButtonColorTheme(options, config) {
|
|
2720
|
-
const { scheme } = options;
|
|
2721
|
-
const
|
|
2722
|
-
for (const mode of THEME_COLOR_BUTTON_MODES) {
|
|
2571
|
+
const { scheme } = options, modes = {};
|
|
2572
|
+
for (const mode of THEME_COLOR_BUTTON_MODES)
|
|
2723
2573
|
modes[mode] = buildButtonTonesColorTheme({ scheme, mode }, config);
|
|
2724
|
-
}
|
|
2725
2574
|
return modes;
|
|
2726
2575
|
}
|
|
2727
2576
|
function buildButtonTonesColorTheme(options, config) {
|
|
2728
|
-
const { mode, scheme } = options;
|
|
2729
|
-
const
|
|
2730
|
-
|
|
2731
|
-
|
|
2732
|
-
}
|
|
2733
|
-
return tones;
|
|
2577
|
+
const { mode, scheme } = options, tones2 = {};
|
|
2578
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2579
|
+
tones2[tone] = buildButtonStatesColorTheme({ mode, scheme, tone }, config);
|
|
2580
|
+
return tones2;
|
|
2734
2581
|
}
|
|
2735
2582
|
function buildButtonStatesColorTheme(options, config) {
|
|
2736
|
-
const { mode, scheme, tone } = options;
|
|
2737
|
-
const
|
|
2738
|
-
for (const state of THEME_COLOR_STATES) {
|
|
2583
|
+
const { mode, scheme, tone } = options, states = {};
|
|
2584
|
+
for (const state of THEME_COLOR_STATES)
|
|
2739
2585
|
states[state] = buildButtonStateColorTheme({ mode, tone, scheme, state }, config);
|
|
2740
|
-
}
|
|
2741
2586
|
return states;
|
|
2742
2587
|
}
|
|
2743
2588
|
function buildButtonStateColorTheme(options, config) {
|
|
2744
2589
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
2745
|
-
const { mode, tone, scheme, state } = options;
|
|
2746
|
-
const tokens = (_d = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.button) == null ? void 0 : _b[mode]) == null ? void 0 : _c[tone]) == null ? void 0 : _d[state];
|
|
2747
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
|
|
2748
|
-
const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
|
|
2749
|
-
const context = { hue, scheme };
|
|
2590
|
+
const { mode, tone, scheme, state } = options, tokens = (_d = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.button) == null ? void 0 : _b[mode]) == null ? void 0 : _c[tone]) == null ? void 0 : _d[state], hue = (tokens == null ? void 0 : tokens._hue) || "gray", blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"], context = { hue, scheme };
|
|
2750
2591
|
return {
|
|
2751
2592
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2752
2593
|
accent: {
|
|
@@ -2798,11 +2639,7 @@ function buildInputStatesColorTheme(options, config) {
|
|
|
2798
2639
|
}
|
|
2799
2640
|
function buildInputStateColorTheme(options, config) {
|
|
2800
2641
|
var _a, _b, _c, _d, _e, _f, _g;
|
|
2801
|
-
const { mode, tone, scheme, state } = options;
|
|
2802
|
-
const tokens = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.input) == null ? void 0 : _b[mode]) == null ? void 0 : _c[state];
|
|
2803
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || ((_f = (_e = (_d = config == null ? void 0 : config.color) == null ? void 0 : _d.base) == null ? void 0 : _e[tone]) == null ? void 0 : _f._hue) || "gray";
|
|
2804
|
-
const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
|
|
2805
|
-
const context = { hue, scheme };
|
|
2642
|
+
const { mode, tone, scheme, state } = options, tokens = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.input) == null ? void 0 : _b[mode]) == null ? void 0 : _c[state], hue = (tokens == null ? void 0 : tokens._hue) || ((_f = (_e = (_d = config == null ? void 0 : config.color) == null ? void 0 : _d.base) == null ? void 0 : _e[tone]) == null ? void 0 : _f._hue) || "gray", blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"], context = { hue, scheme };
|
|
2806
2643
|
return {
|
|
2807
2644
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2808
2645
|
bg: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.bg),
|
|
@@ -2815,28 +2652,20 @@ function buildInputStateColorTheme(options, config) {
|
|
|
2815
2652
|
};
|
|
2816
2653
|
}
|
|
2817
2654
|
function buildSelectableColorTheme(options, config) {
|
|
2818
|
-
const { scheme } = options;
|
|
2819
|
-
const
|
|
2820
|
-
|
|
2821
|
-
|
|
2822
|
-
}
|
|
2823
|
-
return tones;
|
|
2655
|
+
const { scheme } = options, tones2 = {};
|
|
2656
|
+
for (const tone of THEME_COLOR_STATE_TONES)
|
|
2657
|
+
tones2[tone] = buildSelectableStatesColorTheme({ scheme, tone }, config);
|
|
2658
|
+
return tones2;
|
|
2824
2659
|
}
|
|
2825
2660
|
function buildSelectableStatesColorTheme(options, config) {
|
|
2826
|
-
const { scheme, tone } = options;
|
|
2827
|
-
const
|
|
2828
|
-
for (const state of THEME_COLOR_STATES) {
|
|
2661
|
+
const { scheme, tone } = options, states = {};
|
|
2662
|
+
for (const state of THEME_COLOR_STATES)
|
|
2829
2663
|
states[state] = buildSelectableStateColorTheme({ tone, scheme, state }, config);
|
|
2830
|
-
}
|
|
2831
2664
|
return states;
|
|
2832
2665
|
}
|
|
2833
2666
|
function buildSelectableStateColorTheme(options, config) {
|
|
2834
2667
|
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n;
|
|
2835
|
-
const { scheme, state, tone } = options;
|
|
2836
|
-
const tokens = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.selectable) == null ? void 0 : _b[tone]) == null ? void 0 : _c[state];
|
|
2837
|
-
const hue = (tokens == null ? void 0 : tokens._hue) || "gray";
|
|
2838
|
-
const blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"];
|
|
2839
|
-
const context = { hue, scheme };
|
|
2668
|
+
const { scheme, state, tone } = options, tokens = (_c = (_b = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.selectable) == null ? void 0 : _b[tone]) == null ? void 0 : _c[state], hue = (tokens == null ? void 0 : tokens._hue) || "gray", blendMode = (tokens == null ? void 0 : tokens._blend) || ["screen", "multiply"], context = { hue, scheme };
|
|
2840
2669
|
return {
|
|
2841
2670
|
_blend: blendMode[scheme === "light" ? 0 : 1],
|
|
2842
2671
|
accent: {
|
|
@@ -2872,9 +2701,7 @@ function buildSelectableStateColorTheme(options, config) {
|
|
|
2872
2701
|
}
|
|
2873
2702
|
function buildSyntaxColorTheme(options, config) {
|
|
2874
2703
|
var _a;
|
|
2875
|
-
const { scheme } = options;
|
|
2876
|
-
const tokens = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.syntax;
|
|
2877
|
-
const context = { hue: "gray", scheme };
|
|
2704
|
+
const { scheme } = options, tokens = (_a = config == null ? void 0 : config.color) == null ? void 0 : _a.syntax, context = { hue: "gray", scheme };
|
|
2878
2705
|
return {
|
|
2879
2706
|
atrule: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.atrule),
|
|
2880
2707
|
attrName: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.attrName),
|
|
@@ -2914,12 +2741,9 @@ function buildSyntaxColorTheme(options, config) {
|
|
|
2914
2741
|
variable: resolveColorTokenValue(context, tokens == null ? void 0 : tokens.variable)
|
|
2915
2742
|
};
|
|
2916
2743
|
}
|
|
2917
|
-
|
|
2918
2744
|
const defaultColorPalette = color.color;
|
|
2919
|
-
|
|
2920
2745
|
function mixChannel(b, s, weight) {
|
|
2921
|
-
const
|
|
2922
|
-
const delta = diff * weight;
|
|
2746
|
+
const delta = (s - b) * weight;
|
|
2923
2747
|
return b + delta;
|
|
2924
2748
|
}
|
|
2925
2749
|
function mix(b, s, weight) {
|
|
@@ -2929,7 +2753,6 @@ function mix(b, s, weight) {
|
|
|
2929
2753
|
b: mixChannel(b.b, s.b, weight)
|
|
2930
2754
|
};
|
|
2931
2755
|
}
|
|
2932
|
-
|
|
2933
2756
|
function multiplyChannel(b, s) {
|
|
2934
2757
|
return b * s;
|
|
2935
2758
|
}
|
|
@@ -2940,7 +2763,6 @@ function multiply(b, s) {
|
|
|
2940
2763
|
b: multiplyChannel(b.b / 255, s.b / 255) * 255
|
|
2941
2764
|
};
|
|
2942
2765
|
}
|
|
2943
|
-
|
|
2944
2766
|
function screenChannel(b, s) {
|
|
2945
2767
|
return b + s - b * s;
|
|
2946
2768
|
}
|
|
@@ -2951,7 +2773,6 @@ function screen(b, s) {
|
|
|
2951
2773
|
b: screenChannel(b.b / 255, s.b / 255) * 255
|
|
2952
2774
|
};
|
|
2953
2775
|
}
|
|
2954
|
-
|
|
2955
2776
|
function lerp(x, y, a) {
|
|
2956
2777
|
return x * (1 - a) + y * a;
|
|
2957
2778
|
}
|
|
@@ -2967,12 +2788,9 @@ function range(x1, y1, x2, y2, a) {
|
|
|
2967
2788
|
function round(value) {
|
|
2968
2789
|
return Math.round(value);
|
|
2969
2790
|
}
|
|
2970
|
-
|
|
2971
2791
|
function hexToRgb(hex) {
|
|
2972
2792
|
if (hex.length === 4) {
|
|
2973
|
-
const hexR = hex.slice(1, 2);
|
|
2974
|
-
const hexG = hex.slice(2, 3);
|
|
2975
|
-
const hexB = hex.slice(3, 4);
|
|
2793
|
+
const hexR = hex.slice(1, 2), hexG = hex.slice(2, 3), hexB = hex.slice(3, 4);
|
|
2976
2794
|
return {
|
|
2977
2795
|
r: parseInt(hexR + hexR, 16),
|
|
2978
2796
|
g: parseInt(hexG + hexG, 16),
|
|
@@ -2985,8 +2803,8 @@ function hexToRgb(hex) {
|
|
|
2985
2803
|
b: parseInt(hex.slice(5, 7), 16)
|
|
2986
2804
|
};
|
|
2987
2805
|
}
|
|
2988
|
-
function rgbaToRGBA(
|
|
2989
|
-
const values =
|
|
2806
|
+
function rgbaToRGBA(rgba2) {
|
|
2807
|
+
const values = rgba2.replace(/rgba\(|\)/g, "").split(",");
|
|
2990
2808
|
return {
|
|
2991
2809
|
r: parseInt(values[0]),
|
|
2992
2810
|
g: parseInt(values[1]),
|
|
@@ -2994,132 +2812,56 @@ function rgbaToRGBA(rgba) {
|
|
|
2994
2812
|
a: parseFloat(values[3])
|
|
2995
2813
|
};
|
|
2996
2814
|
}
|
|
2997
|
-
function rgbToHex(
|
|
2998
|
-
const r = round(clamp(Math.round(
|
|
2999
|
-
|
|
3000
|
-
const b = round(clamp(Math.round(color.b), 0, 255));
|
|
3001
|
-
if ("a" in color) {
|
|
3002
|
-
return `rgba(${r},${g},${b},${color.a})`;
|
|
3003
|
-
}
|
|
3004
|
-
return "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
2815
|
+
function rgbToHex(color2) {
|
|
2816
|
+
const r = round(clamp(Math.round(color2.r), 0, 255)), g = round(clamp(Math.round(color2.g), 0, 255)), b = round(clamp(Math.round(color2.b), 0, 255));
|
|
2817
|
+
return "a" in color2 ? `rgba(${r},${g},${b},${color2.a})` : "#" + ((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1);
|
|
3005
2818
|
}
|
|
3006
2819
|
function rgbToHsl({ r, g, b }) {
|
|
3007
|
-
r /= 255;
|
|
3008
|
-
g
|
|
3009
|
-
|
|
3010
|
-
|
|
3011
|
-
const cmax = Math.max(r, g, b);
|
|
3012
|
-
const delta = cmax - cmin;
|
|
3013
|
-
let h = 0;
|
|
3014
|
-
let s = 0;
|
|
3015
|
-
let l = 0;
|
|
3016
|
-
if (delta == 0)
|
|
3017
|
-
h = 0;
|
|
3018
|
-
else if (cmax == r)
|
|
3019
|
-
h = (g - b) / delta % 6;
|
|
3020
|
-
else if (cmax == g)
|
|
3021
|
-
h = (b - r) / delta + 2;
|
|
3022
|
-
else
|
|
3023
|
-
h = (r - g) / delta + 4;
|
|
3024
|
-
h = Math.round(h * 60);
|
|
3025
|
-
if (h < 0)
|
|
3026
|
-
h += 360;
|
|
3027
|
-
l = (cmax + cmin) / 2;
|
|
3028
|
-
s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1));
|
|
3029
|
-
s = +(s * 100).toFixed(1);
|
|
3030
|
-
l = +(l * 100).toFixed(1);
|
|
3031
|
-
return { h, s, l };
|
|
2820
|
+
r /= 255, g /= 255, b /= 255;
|
|
2821
|
+
const cmin = Math.min(r, g, b), cmax = Math.max(r, g, b), delta = cmax - cmin;
|
|
2822
|
+
let h = 0, s = 0, l = 0;
|
|
2823
|
+
return delta == 0 ? h = 0 : cmax == r ? h = (g - b) / delta % 6 : cmax == g ? h = (b - r) / delta + 2 : h = (r - g) / delta + 4, h = Math.round(h * 60), h < 0 && (h += 360), l = (cmax + cmin) / 2, s = delta == 0 ? 0 : delta / (1 - Math.abs(2 * l - 1)), s = +(s * 100).toFixed(1), l = +(l * 100).toFixed(1), { h, s, l };
|
|
3032
2824
|
}
|
|
3033
2825
|
function hslToRgb(hsl) {
|
|
3034
|
-
const s = hsl.s / 100;
|
|
3035
|
-
|
|
3036
|
-
|
|
3037
|
-
const x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1));
|
|
3038
|
-
const m = l - c / 2;
|
|
3039
|
-
let r = 0;
|
|
3040
|
-
let g = 0;
|
|
3041
|
-
let b = 0;
|
|
3042
|
-
if (0 <= hsl.h && hsl.h < 60) {
|
|
3043
|
-
r = c;
|
|
3044
|
-
g = x;
|
|
3045
|
-
b = 0;
|
|
3046
|
-
} else if (60 <= hsl.h && hsl.h < 120) {
|
|
3047
|
-
r = x;
|
|
3048
|
-
g = c;
|
|
3049
|
-
b = 0;
|
|
3050
|
-
} else if (120 <= hsl.h && hsl.h < 180) {
|
|
3051
|
-
r = 0;
|
|
3052
|
-
g = c;
|
|
3053
|
-
b = x;
|
|
3054
|
-
} else if (180 <= hsl.h && hsl.h < 240) {
|
|
3055
|
-
r = 0;
|
|
3056
|
-
g = x;
|
|
3057
|
-
b = c;
|
|
3058
|
-
} else if (240 <= hsl.h && hsl.h < 300) {
|
|
3059
|
-
r = x;
|
|
3060
|
-
g = 0;
|
|
3061
|
-
b = c;
|
|
3062
|
-
} else if (300 <= hsl.h && hsl.h < 360) {
|
|
3063
|
-
r = c;
|
|
3064
|
-
g = 0;
|
|
3065
|
-
b = x;
|
|
3066
|
-
}
|
|
3067
|
-
return {
|
|
2826
|
+
const s = hsl.s / 100, l = hsl.l / 100, c = (1 - Math.abs(2 * l - 1)) * s, x = c * (1 - Math.abs(hsl.h / 60 % 2 - 1)), m = l - c / 2;
|
|
2827
|
+
let r = 0, g = 0, b = 0;
|
|
2828
|
+
return 0 <= hsl.h && hsl.h < 60 ? (r = c, g = x, b = 0) : 60 <= hsl.h && hsl.h < 120 ? (r = x, g = c, b = 0) : 120 <= hsl.h && hsl.h < 180 ? (r = 0, g = c, b = x) : 180 <= hsl.h && hsl.h < 240 ? (r = 0, g = x, b = c) : 240 <= hsl.h && hsl.h < 300 ? (r = x, g = 0, b = c) : 300 <= hsl.h && hsl.h < 360 && (r = c, g = 0, b = x), {
|
|
3068
2829
|
r: Math.round((r + m) * 255),
|
|
3069
2830
|
g: Math.round((g + m) * 255),
|
|
3070
2831
|
b: Math.round((b + m) * 255)
|
|
3071
2832
|
};
|
|
3072
2833
|
}
|
|
3073
|
-
|
|
3074
|
-
const HEX_CHARS = "0123456789ABCDEFabcdef";
|
|
3075
|
-
const HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
|
|
2834
|
+
const HEX_CHARS = "0123456789ABCDEFabcdef", HSL_RE = /hsl\(\s*(\d+)\s*,\s*((\d+(?:\.\d+)?)%)\s*,\s*((\d+(?:\.\d+)?)%)\s*\)/i;
|
|
3076
2835
|
function isHexChars(str) {
|
|
3077
|
-
for (const c of str)
|
|
3078
|
-
if (HEX_CHARS.indexOf(c) === -1)
|
|
3079
|
-
return
|
|
3080
|
-
|
|
3081
|
-
}
|
|
3082
|
-
return true;
|
|
2836
|
+
for (const c of str)
|
|
2837
|
+
if (HEX_CHARS.indexOf(c) === -1)
|
|
2838
|
+
return !1;
|
|
2839
|
+
return !0;
|
|
3083
2840
|
}
|
|
3084
2841
|
function isHex(str) {
|
|
3085
|
-
|
|
3086
|
-
return false;
|
|
3087
|
-
if (!(str.length === 4 || str.length === 7))
|
|
3088
|
-
return false;
|
|
3089
|
-
return isHexChars(str.slice(1));
|
|
2842
|
+
return str[0] !== "#" || !(str.length === 4 || str.length === 7) ? !1 : isHexChars(str.slice(1));
|
|
3090
2843
|
}
|
|
3091
2844
|
function parseHsl(str) {
|
|
3092
2845
|
const res = HSL_RE.exec(str);
|
|
3093
|
-
if (!res)
|
|
2846
|
+
if (!res)
|
|
3094
2847
|
throw new Error(`parseHsl: string is not a HSL color: "${str}"`);
|
|
3095
|
-
}
|
|
3096
2848
|
return { h: parseInt(res[1]), s: parseFloat(res[3]), l: parseFloat(res[5]) };
|
|
3097
2849
|
}
|
|
3098
|
-
function parseColor(
|
|
3099
|
-
if (!
|
|
2850
|
+
function parseColor(color2) {
|
|
2851
|
+
if (!color2)
|
|
3100
2852
|
return { r: 0, g: 0, b: 0 };
|
|
3101
|
-
if (typeof
|
|
2853
|
+
if (typeof color2 != "string")
|
|
3102
2854
|
throw new Error("parseColor: expected a string");
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
|
|
3106
|
-
|
|
3107
|
-
if (
|
|
3108
|
-
return
|
|
3109
|
-
}
|
|
3110
|
-
if (color.startsWith("rgba(")) {
|
|
3111
|
-
return rgbaToRGBA(color);
|
|
3112
|
-
}
|
|
3113
|
-
throw new Error(`parseColor: unexpected color format: "${color}"`);
|
|
2855
|
+
if (isHex(color2))
|
|
2856
|
+
return hexToRgb(color2);
|
|
2857
|
+
if (color2.startsWith("hsl("))
|
|
2858
|
+
return hslToRgb(parseHsl(color2));
|
|
2859
|
+
if (color2.startsWith("rgba("))
|
|
2860
|
+
return rgbaToRGBA(color2);
|
|
2861
|
+
throw new Error(`parseColor: unexpected color format: "${color2}"`);
|
|
3114
2862
|
}
|
|
3115
|
-
|
|
3116
2863
|
function getContrastRatio(bg, fg) {
|
|
3117
|
-
const rgb1 = parseColor(bg);
|
|
3118
|
-
const rgb2 = parseColor(fg);
|
|
3119
|
-
const c1 = rgb_lrgb(rgb1);
|
|
3120
|
-
const c2 = rgb_lrgb(rgb2);
|
|
3121
|
-
const l1 = lrgb_luminance(c1);
|
|
3122
|
-
const l2 = lrgb_luminance(c2);
|
|
2864
|
+
const rgb1 = parseColor(bg), rgb2 = parseColor(fg), c1 = rgb_lrgb(rgb1), c2 = rgb_lrgb(rgb2), l1 = lrgb_luminance(c1), l2 = lrgb_luminance(c2);
|
|
3123
2865
|
return (Math.max(l1, l2) + 0.05) / (Math.min(l1, l2) + 0.05);
|
|
3124
2866
|
}
|
|
3125
2867
|
function rgb_lrgb({ r, g, b }) {
|
|
@@ -3131,67 +2873,42 @@ function rgb_lrgb1(v) {
|
|
|
3131
2873
|
function lrgb_luminance([r, g, b]) {
|
|
3132
2874
|
return 0.2126 * r + 0.7152 * g + 0.0722 * b;
|
|
3133
2875
|
}
|
|
3134
|
-
|
|
3135
|
-
|
|
3136
|
-
const rgb = parseColor(color);
|
|
2876
|
+
function rgba(color2, a) {
|
|
2877
|
+
const rgb = parseColor(color2);
|
|
3137
2878
|
return `rgba(${rgb.r},${rgb.g},${rgb.b},${a})`;
|
|
3138
2879
|
}
|
|
3139
|
-
|
|
3140
2880
|
const RGB_RANGE = [0, 255];
|
|
3141
2881
|
function mixThemeColor(value, options) {
|
|
3142
|
-
const { blendMode } = options
|
|
3143
|
-
|
|
3144
|
-
|
|
3145
|
-
|
|
3146
|
-
|
|
3147
|
-
const paletteRange = {
|
|
3148
|
-
r: [black.r, white.r],
|
|
3149
|
-
g: [black.g, white.g],
|
|
3150
|
-
b: [black.b, white.b]
|
|
3151
|
-
};
|
|
3152
|
-
const convertedBgColor = {
|
|
2882
|
+
const { blendMode } = options, color2 = parseColor(value), black2 = parseColor(options.black), white2 = parseColor(options.white), bg = options.bg ? parseColor(options.bg) : blendMode === "multiply" ? white2 : black2, paletteRange = {
|
|
2883
|
+
r: [black2.r, white2.r],
|
|
2884
|
+
g: [black2.g, white2.g],
|
|
2885
|
+
b: [black2.b, white2.b]
|
|
2886
|
+
}, convertedBgColor = {
|
|
3153
2887
|
r: clamp(range(...paletteRange.r, ...RGB_RANGE, bg.r), ...RGB_RANGE),
|
|
3154
2888
|
g: clamp(range(...paletteRange.g, ...RGB_RANGE, bg.g), ...RGB_RANGE),
|
|
3155
2889
|
b: clamp(range(...paletteRange.b, ...RGB_RANGE, bg.b), ...RGB_RANGE)
|
|
3156
|
-
}
|
|
3157
|
-
|
|
3158
|
-
|
|
3159
|
-
|
|
3160
|
-
|
|
3161
|
-
};
|
|
3162
|
-
const resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor);
|
|
3163
|
-
const v = {
|
|
2890
|
+
}, convertedColor = {
|
|
2891
|
+
r: clamp(range(...paletteRange.r, ...RGB_RANGE, color2.r), ...RGB_RANGE),
|
|
2892
|
+
g: clamp(range(...paletteRange.g, ...RGB_RANGE, color2.g), ...RGB_RANGE),
|
|
2893
|
+
b: clamp(range(...paletteRange.b, ...RGB_RANGE, color2.b), ...RGB_RANGE)
|
|
2894
|
+
}, resultColor = blendMode === "multiply" ? multiply(convertedBgColor, convertedColor) : screen(convertedBgColor, convertedColor), v = {
|
|
3164
2895
|
r: clamp(range(...RGB_RANGE, ...paletteRange.r, resultColor.r), ...paletteRange.r),
|
|
3165
2896
|
g: clamp(range(...RGB_RANGE, ...paletteRange.g, resultColor.g), ...paletteRange.g),
|
|
3166
2897
|
b: clamp(range(...RGB_RANGE, ...paletteRange.b, resultColor.b), ...paletteRange.b)
|
|
3167
2898
|
};
|
|
3168
2899
|
return rgbToHex(v);
|
|
3169
2900
|
}
|
|
3170
|
-
|
|
3171
2901
|
function renderColorValue(str, options) {
|
|
3172
2902
|
const { bg, blendMode, colorPalette } = options;
|
|
3173
|
-
if (bg === "white")
|
|
2903
|
+
if (bg === "white")
|
|
3174
2904
|
throw new Error("Cannot blend with white background");
|
|
3175
|
-
}
|
|
3176
2905
|
const node = parseTokenValue(str);
|
|
3177
|
-
if (!node || node.type !== "color")
|
|
2906
|
+
if (!node || node.type !== "color")
|
|
3178
2907
|
throw new Error(`Invalid color token value: ${str}`);
|
|
3179
|
-
}
|
|
3180
2908
|
let hex = "";
|
|
3181
|
-
if (node.key === "black")
|
|
3182
|
-
hex = renderColorHex(colorPalette.black);
|
|
3183
|
-
}
|
|
3184
|
-
if (node.key === "white") {
|
|
3185
|
-
hex = renderColorHex(colorPalette.white);
|
|
3186
|
-
}
|
|
3187
|
-
if (node.hue && node.tint) {
|
|
3188
|
-
hex = renderColorHex(colorPalette[node.hue][node.tint]);
|
|
3189
|
-
}
|
|
3190
|
-
if (!hex) {
|
|
2909
|
+
if (node.key === "black" && (hex = renderColorHex(colorPalette.black)), node.key === "white" && (hex = renderColorHex(colorPalette.white)), node.hue && node.tint && (hex = renderColorHex(colorPalette[node.hue][node.tint])), !hex)
|
|
3191
2910
|
throw new Error(`Invalid color token value: ${str}`);
|
|
3192
|
-
|
|
3193
|
-
const hexBeforeMix = hex;
|
|
3194
|
-
const mixOptions = {
|
|
2911
|
+
const hexBeforeMix = hex, mixOptions = {
|
|
3195
2912
|
blendMode,
|
|
3196
2913
|
bg,
|
|
3197
2914
|
black: renderColorHex(colorPalette.black),
|
|
@@ -3199,46 +2916,30 @@ function renderColorValue(str, options) {
|
|
|
3199
2916
|
white: renderColorHex(colorPalette.white)
|
|
3200
2917
|
};
|
|
3201
2918
|
try {
|
|
3202
|
-
hex = mixThemeColor(hex, mixOptions)
|
|
3203
|
-
|
|
3204
|
-
const from = hexToRgb(bg);
|
|
3205
|
-
const to = hexToRgb(hex);
|
|
2919
|
+
if (hex = mixThemeColor(hex, mixOptions), bg && node.mix !== void 0) {
|
|
2920
|
+
const from = hexToRgb(bg), to = hexToRgb(hex);
|
|
3206
2921
|
hex = rgbToHex(mix(from, to, node.mix));
|
|
3207
2922
|
}
|
|
3208
2923
|
} catch (err) {
|
|
3209
|
-
console.warn("could not blend", hex, mixOptions);
|
|
3210
|
-
throw err;
|
|
3211
|
-
}
|
|
3212
|
-
if (hex === "#aN") {
|
|
3213
|
-
console.warn(`invalid color token value: ${str}`);
|
|
3214
|
-
hex = hexBeforeMix;
|
|
2924
|
+
throw console.warn("could not blend", hex, mixOptions), err;
|
|
3215
2925
|
}
|
|
3216
|
-
|
|
3217
|
-
hex = rgba(hex, node.opacity);
|
|
3218
|
-
}
|
|
3219
|
-
return hex;
|
|
2926
|
+
return hex === "#aN" && (console.warn(`invalid color token value: ${str}`), hex = hexBeforeMix), node.opacity !== void 0 && (hex = rgba(hex, node.opacity)), hex;
|
|
3220
2927
|
}
|
|
3221
|
-
function renderColorHex(
|
|
3222
|
-
return typeof
|
|
2928
|
+
function renderColorHex(color2) {
|
|
2929
|
+
return typeof color2 == "string" ? color2 : color2.hex;
|
|
3223
2930
|
}
|
|
3224
|
-
|
|
3225
2931
|
function renderThemeColorSchemes(value, config) {
|
|
3226
|
-
|
|
2932
|
+
var _a;
|
|
2933
|
+
const colorPalette = (_a = config == null ? void 0 : config.palette) != null ? _a : defaultColorPalette;
|
|
3227
2934
|
return {
|
|
3228
2935
|
light: renderThemeColorScheme(colorPalette, value.light),
|
|
3229
2936
|
dark: renderThemeColorScheme(colorPalette, value.dark)
|
|
3230
2937
|
};
|
|
3231
2938
|
}
|
|
3232
2939
|
function renderThemeColorScheme(colorPalette, value) {
|
|
3233
|
-
const toneEntries = Object.entries(value);
|
|
3234
|
-
|
|
3235
|
-
const [, defaultTone] = toneEntries.find(([k]) => k === "default");
|
|
3236
|
-
const renderedTransparentTone = renderThemeColor(transparentTone, { colorPalette });
|
|
3237
|
-
const renderedDefaultTone = renderThemeColor(defaultTone, { colorPalette });
|
|
3238
|
-
const bg = renderedDefaultTone.bg;
|
|
3239
|
-
if (bg === "white") {
|
|
2940
|
+
const toneEntries = Object.entries(value), [, transparentTone] = toneEntries.find(([k]) => k === "transparent"), [, defaultTone] = toneEntries.find(([k]) => k === "default"), renderedTransparentTone = renderThemeColor(transparentTone, { colorPalette }), renderedDefaultTone = renderThemeColor(defaultTone, { colorPalette }), bg = renderedDefaultTone.bg;
|
|
2941
|
+
if (bg === "white")
|
|
3240
2942
|
throw new Error("Cannot blend with white background");
|
|
3241
|
-
}
|
|
3242
2943
|
return Object.fromEntries([
|
|
3243
2944
|
["transparent", renderedTransparentTone],
|
|
3244
2945
|
["default", renderedDefaultTone],
|
|
@@ -3246,21 +2947,15 @@ function renderThemeColorScheme(colorPalette, value) {
|
|
|
3246
2947
|
]);
|
|
3247
2948
|
}
|
|
3248
2949
|
function renderThemeColor(value, options) {
|
|
3249
|
-
const { colorPalette, bg } = options
|
|
3250
|
-
const blendMode = value._blend || "multiply";
|
|
3251
|
-
const baseBg = renderColorValue(value.bg, { colorPalette, bg, blendMode });
|
|
3252
|
-
const colorOptions = { colorPalette, bg: baseBg, blendMode };
|
|
3253
|
-
const button = renderThemeColorButton(value.button, {
|
|
2950
|
+
const { colorPalette, bg } = options, blendMode = value._blend || "multiply", baseBg = renderColorValue(value.bg, { colorPalette, bg, blendMode }), colorOptions = { colorPalette, bg: baseBg, blendMode }, button = renderThemeColorButton(value.button, {
|
|
3254
2951
|
baseBg,
|
|
3255
2952
|
blendMode,
|
|
3256
2953
|
colorPalette
|
|
3257
|
-
})
|
|
3258
|
-
const selectable = renderThemeColorSelectable(value.selectable, {
|
|
2954
|
+
}), selectable = renderThemeColorSelectable(value.selectable, {
|
|
3259
2955
|
colorPalette,
|
|
3260
2956
|
baseBg,
|
|
3261
2957
|
blendMode
|
|
3262
|
-
})
|
|
3263
|
-
const shadow = {
|
|
2958
|
+
}), shadow = {
|
|
3264
2959
|
outline: renderColorValue(value.shadow.outline, colorOptions),
|
|
3265
2960
|
umbra: renderColorValue(value.shadow.umbra, {
|
|
3266
2961
|
...colorOptions,
|
|
@@ -3316,14 +3011,11 @@ function renderThemeColor(value, options) {
|
|
|
3316
3011
|
};
|
|
3317
3012
|
}
|
|
3318
3013
|
function renderThemeColorKBD(value, options) {
|
|
3319
|
-
const { baseBg, blendMode, colorPalette } = options
|
|
3320
|
-
const rootOptions = {
|
|
3014
|
+
const { baseBg, blendMode, colorPalette } = options, rootOptions = {
|
|
3321
3015
|
bg: baseBg,
|
|
3322
3016
|
blendMode,
|
|
3323
3017
|
colorPalette
|
|
3324
|
-
}
|
|
3325
|
-
const bg = renderColorValue(value.bg, rootOptions);
|
|
3326
|
-
const colorOptions = {
|
|
3018
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3327
3019
|
bg,
|
|
3328
3020
|
blendMode,
|
|
3329
3021
|
colorPalette
|
|
@@ -3348,15 +3040,11 @@ function renderThemeColorAvatar(value, options) {
|
|
|
3348
3040
|
};
|
|
3349
3041
|
}
|
|
3350
3042
|
function renderThemeColorAvatarColor(value, options) {
|
|
3351
|
-
const { baseBg, blendMode: rootBlendMode, colorPalette } = options
|
|
3352
|
-
const blendMode = value._blend || "multiply";
|
|
3353
|
-
const rootOptions = {
|
|
3043
|
+
const { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3354
3044
|
bg: baseBg,
|
|
3355
3045
|
blendMode: rootBlendMode,
|
|
3356
3046
|
colorPalette
|
|
3357
|
-
}
|
|
3358
|
-
const bg = renderColorValue(value.bg, rootOptions);
|
|
3359
|
-
const colorOptions = {
|
|
3047
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3360
3048
|
bg,
|
|
3361
3049
|
blendMode,
|
|
3362
3050
|
colorPalette
|
|
@@ -3377,15 +3065,11 @@ function renderThemeColorBadge(value, options) {
|
|
|
3377
3065
|
};
|
|
3378
3066
|
}
|
|
3379
3067
|
function renderThemeColorBadgeColor(value, options) {
|
|
3380
|
-
const { baseBg, blendMode: rootBlendMode, colorPalette } = options
|
|
3381
|
-
const blendMode = rootBlendMode;
|
|
3382
|
-
const rootOptions = {
|
|
3068
|
+
const { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = rootBlendMode, rootOptions = {
|
|
3383
3069
|
bg: baseBg,
|
|
3384
3070
|
blendMode: rootBlendMode,
|
|
3385
3071
|
colorPalette
|
|
3386
|
-
}
|
|
3387
|
-
const bg = renderColorValue(value.bg, rootOptions);
|
|
3388
|
-
const colorOptions = {
|
|
3072
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3389
3073
|
bg,
|
|
3390
3074
|
blendMode,
|
|
3391
3075
|
colorPalette
|
|
@@ -3424,15 +3108,11 @@ function renderThemeColorButtonStates(value, options) {
|
|
|
3424
3108
|
}
|
|
3425
3109
|
function renderThemeColorState(value, options) {
|
|
3426
3110
|
var _a, _b;
|
|
3427
|
-
const { baseBg, blendMode: rootBlendMode, colorPalette } = options
|
|
3428
|
-
const blendMode = value._blend || "multiply";
|
|
3429
|
-
const rootOptions = {
|
|
3111
|
+
const { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = {
|
|
3430
3112
|
bg: baseBg,
|
|
3431
3113
|
blendMode: rootBlendMode,
|
|
3432
3114
|
colorPalette
|
|
3433
|
-
}
|
|
3434
|
-
const bg = renderColorValue(value.bg, rootOptions);
|
|
3435
|
-
const colorOptions = {
|
|
3115
|
+
}, bg = renderColorValue(value.bg, rootOptions), colorOptions = {
|
|
3436
3116
|
bg,
|
|
3437
3117
|
blendMode,
|
|
3438
3118
|
colorPalette
|
|
@@ -3485,11 +3165,7 @@ function renderInputStatesColorTheme(value, options) {
|
|
|
3485
3165
|
};
|
|
3486
3166
|
}
|
|
3487
3167
|
function renderInputStateColorTheme(value, options) {
|
|
3488
|
-
const { baseBg, blendMode: rootBlendMode, colorPalette } = options;
|
|
3489
|
-
const blendMode = value._blend || "multiply";
|
|
3490
|
-
const rootOptions = { colorPalette, bg: baseBg, blendMode: rootBlendMode };
|
|
3491
|
-
const bg = renderColorValue(value.bg, rootOptions);
|
|
3492
|
-
const colorOptions = { colorPalette, bg, blendMode };
|
|
3168
|
+
const { baseBg, blendMode: rootBlendMode, colorPalette } = options, blendMode = value._blend || "multiply", rootOptions = { colorPalette, bg: baseBg, blendMode: rootBlendMode }, bg = renderColorValue(value.bg, rootOptions), colorOptions = { colorPalette, bg, blendMode };
|
|
3493
3169
|
return {
|
|
3494
3170
|
_blend: blendMode,
|
|
3495
3171
|
bg,
|
|
@@ -3520,8 +3196,7 @@ function renderThemeColorSelectableStates(value, options) {
|
|
|
3520
3196
|
};
|
|
3521
3197
|
}
|
|
3522
3198
|
function renderSyntaxColorTheme(value, options) {
|
|
3523
|
-
const { colorPalette, baseBg, blendMode } = options;
|
|
3524
|
-
const colorOptions = { colorPalette, bg: baseBg, blendMode };
|
|
3199
|
+
const { colorPalette, baseBg, blendMode } = options, colorOptions = { colorPalette, bg: baseBg, blendMode };
|
|
3525
3200
|
return {
|
|
3526
3201
|
atrule: renderColorValue(value.atrule, colorOptions),
|
|
3527
3202
|
attrName: renderColorValue(value.attrName, colorOptions),
|
|
@@ -3561,81 +3236,64 @@ function renderSyntaxColorTheme(value, options) {
|
|
|
3561
3236
|
variable: renderColorValue(value.variable, colorOptions)
|
|
3562
3237
|
};
|
|
3563
3238
|
}
|
|
3564
|
-
|
|
3565
3239
|
function buildTheme(config) {
|
|
3566
|
-
|
|
3567
|
-
const v2 = {
|
|
3240
|
+
var _a, _b, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
3241
|
+
const colorTheme = buildColorTheme(config), v2 = {
|
|
3568
3242
|
_version: 2,
|
|
3569
|
-
avatar: (config == null ? void 0 : config.avatar)
|
|
3570
|
-
button: (config == null ? void 0 : config.button)
|
|
3571
|
-
card: (config == null ? void 0 : config.card)
|
|
3243
|
+
avatar: (_a = config == null ? void 0 : config.avatar) != null ? _a : defaultThemeConfig.avatar,
|
|
3244
|
+
button: (_b = config == null ? void 0 : config.button) != null ? _b : defaultThemeConfig.button,
|
|
3245
|
+
card: (_c = config == null ? void 0 : config.card) != null ? _c : defaultThemeConfig.card,
|
|
3572
3246
|
// How colors are generated:
|
|
3573
3247
|
// 1. Merge custom tokens with default tokens
|
|
3574
3248
|
// 2. Generate tree of color keys (gray/500, black, white, etc.)
|
|
3575
3249
|
// 3. Apply mixing and render to hex values
|
|
3576
3250
|
// render(build(mergeWithDefaults()))
|
|
3577
3251
|
color: renderThemeColorSchemes(colorTheme, config),
|
|
3578
|
-
container: (config == null ? void 0 : config.container)
|
|
3579
|
-
font: (config == null ? void 0 : config.font)
|
|
3580
|
-
input: (config == null ? void 0 : config.input)
|
|
3581
|
-
layer: (config == null ? void 0 : config.layer)
|
|
3582
|
-
media: (config == null ? void 0 : config.media)
|
|
3583
|
-
radius: (config == null ? void 0 : config.radius)
|
|
3584
|
-
shadow: (config == null ? void 0 : config.shadow)
|
|
3585
|
-
space: (config == null ? void 0 : config.space)
|
|
3586
|
-
style: (config == null ? void 0 : config.style)
|
|
3252
|
+
container: (_d = config == null ? void 0 : config.container) != null ? _d : defaultThemeConfig.container,
|
|
3253
|
+
font: (_e = config == null ? void 0 : config.font) != null ? _e : defaultThemeFonts,
|
|
3254
|
+
input: (_f = config == null ? void 0 : config.input) != null ? _f : defaultThemeConfig.input,
|
|
3255
|
+
layer: (_g = config == null ? void 0 : config.layer) != null ? _g : defaultThemeConfig.layer,
|
|
3256
|
+
media: (_h = config == null ? void 0 : config.media) != null ? _h : defaultThemeConfig.media,
|
|
3257
|
+
radius: (_i = config == null ? void 0 : config.radius) != null ? _i : defaultThemeConfig.radius,
|
|
3258
|
+
shadow: (_j = config == null ? void 0 : config.shadow) != null ? _j : defaultThemeConfig.shadow,
|
|
3259
|
+
space: (_k = config == null ? void 0 : config.space) != null ? _k : defaultThemeConfig.space,
|
|
3260
|
+
style: (_l = config == null ? void 0 : config.style) != null ? _l : defaultThemeConfig.style
|
|
3587
3261
|
};
|
|
3588
3262
|
return v2_v0(v2);
|
|
3589
3263
|
}
|
|
3590
|
-
|
|
3591
3264
|
const cache = /* @__PURE__ */ new Map();
|
|
3592
3265
|
function getScopedTheme(themeProp, scheme, tone) {
|
|
3593
3266
|
const cachedTheme = _getCachedTheme(themeProp, scheme, tone);
|
|
3594
3267
|
if (cachedTheme)
|
|
3595
3268
|
return cachedTheme;
|
|
3596
|
-
const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp
|
|
3597
|
-
const v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp);
|
|
3598
|
-
const colorScheme_v0 = v0.color[scheme] || v0.color.light;
|
|
3599
|
-
const color_v0 = colorScheme_v0[tone] || colorScheme_v0.default;
|
|
3600
|
-
const layer_v0 = v0.layer || defaultThemeConfig.layer;
|
|
3601
|
-
const colorScheme_v2 = v2.color[scheme] || v2.color.light;
|
|
3602
|
-
const color_v2 = colorScheme_v2[tone] || colorScheme_v2.default;
|
|
3603
|
-
const layer_v2 = v2.layer || defaultThemeConfig.layer;
|
|
3604
|
-
const theme = {
|
|
3269
|
+
const v0 = is_v2(themeProp) ? v2_v0(themeProp) : themeProp, v2 = is_v2(themeProp) ? themeProp : v0_v2(themeProp), colorScheme_v0 = v0.color[scheme] || v0.color.light, color_v0 = colorScheme_v0[tone] || colorScheme_v0.default, layer_v0 = v0.layer || defaultThemeConfig.layer, colorScheme_v2 = v2.color[scheme] || v2.color.light, color_v2 = colorScheme_v2[tone] || colorScheme_v2.default, layer_v2 = v2.layer || defaultThemeConfig.layer, theme = {
|
|
3605
3270
|
sanity: {
|
|
3606
3271
|
...v0,
|
|
3607
3272
|
color: color_v0,
|
|
3608
3273
|
layer: layer_v0,
|
|
3609
3274
|
v2: {
|
|
3610
3275
|
...v2,
|
|
3611
|
-
_resolved:
|
|
3276
|
+
_resolved: !0,
|
|
3612
3277
|
color: color_v2,
|
|
3613
3278
|
layer: layer_v2
|
|
3614
3279
|
}
|
|
3615
3280
|
}
|
|
3616
3281
|
};
|
|
3617
|
-
_setCachedTheme(themeProp, scheme, tone, theme);
|
|
3618
|
-
return theme;
|
|
3282
|
+
return _setCachedTheme(themeProp, scheme, tone, theme), theme;
|
|
3619
3283
|
}
|
|
3620
3284
|
function _getCachedTheme(rootTheme, scheme, tone) {
|
|
3621
3285
|
const schemeCache = cache.get(scheme);
|
|
3622
3286
|
if (!schemeCache)
|
|
3623
|
-
return
|
|
3287
|
+
return;
|
|
3624
3288
|
const toneCache = schemeCache.get(tone);
|
|
3625
|
-
if (
|
|
3626
|
-
return
|
|
3627
|
-
return toneCache.get(rootTheme);
|
|
3289
|
+
if (toneCache)
|
|
3290
|
+
return toneCache.get(rootTheme);
|
|
3628
3291
|
}
|
|
3629
3292
|
function _setCachedTheme(rootTheme, scheme, tone, theme) {
|
|
3630
|
-
|
|
3631
|
-
cache.set(scheme, /* @__PURE__ */ new Map());
|
|
3293
|
+
cache.has(scheme) || cache.set(scheme, /* @__PURE__ */ new Map());
|
|
3632
3294
|
const schemeCache = cache.get(scheme);
|
|
3633
|
-
|
|
3634
|
-
schemeCache.set(tone, /* @__PURE__ */ new WeakMap());
|
|
3635
|
-
const toneCache = schemeCache.get(tone);
|
|
3636
|
-
toneCache.set(rootTheme, theme);
|
|
3295
|
+
schemeCache.has(tone) || schemeCache.set(tone, /* @__PURE__ */ new WeakMap()), schemeCache.get(tone).set(rootTheme, theme);
|
|
3637
3296
|
}
|
|
3638
|
-
|
|
3639
3297
|
exports.COLOR_CONFIG_AVATAR_COLORS = COLOR_CONFIG_AVATAR_COLORS;
|
|
3640
3298
|
exports.COLOR_CONFIG_BLEND_KEYS = COLOR_CONFIG_BLEND_KEYS;
|
|
3641
3299
|
exports.COLOR_CONFIG_CARD_KEYS = COLOR_CONFIG_CARD_KEYS;
|