framework7 8.3.0 → 8.3.2
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/components/app/app-class.js +5 -5
- package/components/calendar/calendar.d.ts +1 -1
- package/components/color-picker/color-picker.less +8 -2
- package/components/navbar/navbar-ios.less +4 -4
- package/components/page/page-md.less +2 -1
- package/components/preloader/preloader-md.less +2 -1
- package/components/pull-to-refresh/pull-to-refresh-md.less +3 -1
- package/components/sheet/sheet-class.js +1 -1
- package/components/sortable/sortable-rtl.css +1 -1
- package/components/sortable/sortable.css +1 -1
- package/components/sortable/sortable.less +1 -0
- package/framework7-bundle-rtl.css +10 -5
- package/framework7-bundle-rtl.min.css +4 -4
- package/framework7-bundle.css +10 -5
- package/framework7-bundle.esm.js +3 -3
- package/framework7-bundle.js +1510 -190
- package/framework7-bundle.js.map +1 -1
- package/framework7-bundle.less +3 -3
- package/framework7-bundle.min.css +4 -4
- package/framework7-bundle.min.js +4 -4
- package/framework7-bundle.min.js.map +1 -1
- package/framework7-lite-bundle.esm.js +3 -3
- package/framework7-lite.esm.js +3 -3
- package/framework7-rtl.css +3 -3
- package/framework7-rtl.min.css +3 -3
- package/framework7.css +3 -3
- package/framework7.esm.js +3 -3
- package/framework7.less +3 -3
- package/framework7.min.css +3 -3
- package/modules/router/async-component.js +3 -1
- package/modules/router/component-loader.js +3 -1
- package/package.json +26 -8
- package/shared/material-color-utils.js +622 -5
- package/framework7-lite.js +0 -31
- package/framework7.js +0 -42
- package/less/plugin.js +0 -15
|
@@ -8,6 +8,9 @@ function lerp(start, stop, amount) {
|
|
|
8
8
|
function clampInt(min, max, input) {
|
|
9
9
|
return input < min ? min : input > max ? max : input;
|
|
10
10
|
}
|
|
11
|
+
function clampDouble(min, max, input) {
|
|
12
|
+
return input < min ? min : input > max ? max : input;
|
|
13
|
+
}
|
|
11
14
|
function sanitizeDegreesDouble(degrees) {
|
|
12
15
|
return (degrees %= 360) < 0 && (degrees += 360), degrees;
|
|
13
16
|
}
|
|
@@ -58,6 +61,9 @@ function lstarFromArgb(argb) {
|
|
|
58
61
|
function yFromLstar(lstar) {
|
|
59
62
|
return 100 * labInvf((lstar + 16) / 116);
|
|
60
63
|
}
|
|
64
|
+
function lstarFromY(y) {
|
|
65
|
+
return 116 * labF(y / 100) - 16;
|
|
66
|
+
}
|
|
61
67
|
function linearized(rgbComponent) {
|
|
62
68
|
const normalized = rgbComponent / 255;
|
|
63
69
|
return normalized <= .040449936 ? normalized / 12.92 * 100 : 100 * Math.pow((normalized + .055) / 1.055, 2.4);
|
|
@@ -236,6 +242,68 @@ class Cam16 {
|
|
|
236
242
|
bF = bC / viewingConditions.rgbD[2];
|
|
237
243
|
return argbFromXyz(1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF);
|
|
238
244
|
}
|
|
245
|
+
static fromXyzInViewingConditions(x, y, z, viewingConditions) {
|
|
246
|
+
const rC = .401288 * x + .650173 * y - .051461 * z,
|
|
247
|
+
gC = -.250268 * x + 1.204414 * y + .045854 * z,
|
|
248
|
+
bC = -.002079 * x + .048952 * y + .953127 * z,
|
|
249
|
+
rD = viewingConditions.rgbD[0] * rC,
|
|
250
|
+
gD = viewingConditions.rgbD[1] * gC,
|
|
251
|
+
bD = viewingConditions.rgbD[2] * bC,
|
|
252
|
+
rAF = Math.pow(viewingConditions.fl * Math.abs(rD) / 100, .42),
|
|
253
|
+
gAF = Math.pow(viewingConditions.fl * Math.abs(gD) / 100, .42),
|
|
254
|
+
bAF = Math.pow(viewingConditions.fl * Math.abs(bD) / 100, .42),
|
|
255
|
+
rA = 400 * signum(rD) * rAF / (rAF + 27.13),
|
|
256
|
+
gA = 400 * signum(gD) * gAF / (gAF + 27.13),
|
|
257
|
+
bA = 400 * signum(bD) * bAF / (bAF + 27.13),
|
|
258
|
+
a = (11 * rA + -12 * gA + bA) / 11,
|
|
259
|
+
b = (rA + gA - 2 * bA) / 9,
|
|
260
|
+
u = (20 * rA + 20 * gA + 21 * bA) / 20,
|
|
261
|
+
p2 = (40 * rA + 20 * gA + bA) / 20,
|
|
262
|
+
atanDegrees = 180 * Math.atan2(b, a) / Math.PI,
|
|
263
|
+
hue = atanDegrees < 0 ? atanDegrees + 360 : atanDegrees >= 360 ? atanDegrees - 360 : atanDegrees,
|
|
264
|
+
hueRadians = hue * Math.PI / 180,
|
|
265
|
+
ac = p2 * viewingConditions.nbb,
|
|
266
|
+
J = 100 * Math.pow(ac / viewingConditions.aw, viewingConditions.c * viewingConditions.z),
|
|
267
|
+
Q = 4 / viewingConditions.c * Math.sqrt(J / 100) * (viewingConditions.aw + 4) * viewingConditions.fLRoot,
|
|
268
|
+
huePrime = hue < 20.14 ? hue + 360 : hue,
|
|
269
|
+
t = 5e4 / 13 * (1 / 4 * (Math.cos(huePrime * Math.PI / 180 + 2) + 3.8)) * viewingConditions.nc * viewingConditions.ncb * Math.sqrt(a * a + b * b) / (u + .305),
|
|
270
|
+
alpha = Math.pow(t, .9) * Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73),
|
|
271
|
+
C = alpha * Math.sqrt(J / 100),
|
|
272
|
+
M = C * viewingConditions.fLRoot,
|
|
273
|
+
s = 50 * Math.sqrt(alpha * viewingConditions.c / (viewingConditions.aw + 4)),
|
|
274
|
+
jstar = (1 + 100 * .007) * J / (1 + .007 * J),
|
|
275
|
+
mstar = Math.log(1 + .0228 * M) / .0228,
|
|
276
|
+
astar = mstar * Math.cos(hueRadians),
|
|
277
|
+
bstar = mstar * Math.sin(hueRadians);
|
|
278
|
+
return new Cam16(hue, C, J, Q, M, s, jstar, astar, bstar);
|
|
279
|
+
}
|
|
280
|
+
xyzInViewingConditions(viewingConditions) {
|
|
281
|
+
const alpha = 0 === this.chroma || 0 === this.j ? 0 : this.chroma / Math.sqrt(this.j / 100),
|
|
282
|
+
t = Math.pow(alpha / Math.pow(1.64 - Math.pow(.29, viewingConditions.n), .73), 1 / .9),
|
|
283
|
+
hRad = this.hue * Math.PI / 180,
|
|
284
|
+
eHue = .25 * (Math.cos(hRad + 2) + 3.8),
|
|
285
|
+
ac = viewingConditions.aw * Math.pow(this.j / 100, 1 / viewingConditions.c / viewingConditions.z),
|
|
286
|
+
p1 = eHue * (5e4 / 13) * viewingConditions.nc * viewingConditions.ncb,
|
|
287
|
+
p2 = ac / viewingConditions.nbb,
|
|
288
|
+
hSin = Math.sin(hRad),
|
|
289
|
+
hCos = Math.cos(hRad),
|
|
290
|
+
gamma = 23 * (p2 + .305) * t / (23 * p1 + 11 * t * hCos + 108 * t * hSin),
|
|
291
|
+
a = gamma * hCos,
|
|
292
|
+
b = gamma * hSin,
|
|
293
|
+
rA = (460 * p2 + 451 * a + 288 * b) / 1403,
|
|
294
|
+
gA = (460 * p2 - 891 * a - 261 * b) / 1403,
|
|
295
|
+
bA = (460 * p2 - 220 * a - 6300 * b) / 1403,
|
|
296
|
+
rCBase = Math.max(0, 27.13 * Math.abs(rA) / (400 - Math.abs(rA))),
|
|
297
|
+
rC = signum(rA) * (100 / viewingConditions.fl) * Math.pow(rCBase, 1 / .42),
|
|
298
|
+
gCBase = Math.max(0, 27.13 * Math.abs(gA) / (400 - Math.abs(gA))),
|
|
299
|
+
gC = signum(gA) * (100 / viewingConditions.fl) * Math.pow(gCBase, 1 / .42),
|
|
300
|
+
bCBase = Math.max(0, 27.13 * Math.abs(bA) / (400 - Math.abs(bA))),
|
|
301
|
+
bC = signum(bA) * (100 / viewingConditions.fl) * Math.pow(bCBase, 1 / .42),
|
|
302
|
+
rF = rC / viewingConditions.rgbD[0],
|
|
303
|
+
gF = gC / viewingConditions.rgbD[1],
|
|
304
|
+
bF = bC / viewingConditions.rgbD[2];
|
|
305
|
+
return [1.86206786 * rF - 1.01125463 * gF + .14918677 * bF, .38752654 * rF + .62144744 * gF - .00897398 * bF, -.0158415 * rF - .03412294 * gF + 1.04996444 * bF];
|
|
306
|
+
}
|
|
239
307
|
}
|
|
240
308
|
class HctSolver {
|
|
241
309
|
static sanitizeRadians(angle) {
|
|
@@ -428,6 +496,11 @@ class Hct {
|
|
|
428
496
|
const cam = Cam16.fromInt(argb);
|
|
429
497
|
this.internalHue = cam.hue, this.internalChroma = cam.chroma, this.internalTone = lstarFromArgb(argb), this.argb = argb;
|
|
430
498
|
}
|
|
499
|
+
inViewingConditions(vc) {
|
|
500
|
+
const viewedInVc = Cam16.fromInt(this.toInt()).xyzInViewingConditions(vc),
|
|
501
|
+
recastInVc = Cam16.fromXyzInViewingConditions(viewedInVc[0], viewedInVc[1], viewedInVc[2], ViewingConditions.make());
|
|
502
|
+
return Hct.from(recastInVc.hue, recastInVc.chroma, lstarFromY(viewedInVc[1]));
|
|
503
|
+
}
|
|
431
504
|
}
|
|
432
505
|
class Blend {
|
|
433
506
|
static harmonize(designColor, sourceColor) {
|
|
@@ -456,21 +529,565 @@ class Blend {
|
|
|
456
529
|
return Cam16.fromUcs(jstar, astar, bstar).toInt();
|
|
457
530
|
}
|
|
458
531
|
}
|
|
532
|
+
class Contrast {
|
|
533
|
+
static ratioOfTones(toneA, toneB) {
|
|
534
|
+
return toneA = clampDouble(0, 100, toneA), toneB = clampDouble(0, 100, toneB), Contrast.ratioOfYs(yFromLstar(toneA), yFromLstar(toneB));
|
|
535
|
+
}
|
|
536
|
+
static ratioOfYs(y1, y2) {
|
|
537
|
+
const lighter = y1 > y2 ? y1 : y2;
|
|
538
|
+
return (lighter + 5) / ((lighter === y2 ? y1 : y2) + 5);
|
|
539
|
+
}
|
|
540
|
+
static lighter(tone, ratio) {
|
|
541
|
+
if (tone < 0 || tone > 100) return -1;
|
|
542
|
+
const darkY = yFromLstar(tone),
|
|
543
|
+
lightY = ratio * (darkY + 5) - 5,
|
|
544
|
+
realContrast = Contrast.ratioOfYs(lightY, darkY),
|
|
545
|
+
delta = Math.abs(realContrast - ratio);
|
|
546
|
+
if (realContrast < ratio && delta > .04) return -1;
|
|
547
|
+
const returnValue = lstarFromY(lightY) + .4;
|
|
548
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
549
|
+
}
|
|
550
|
+
static darker(tone, ratio) {
|
|
551
|
+
if (tone < 0 || tone > 100) return -1;
|
|
552
|
+
const lightY = yFromLstar(tone),
|
|
553
|
+
darkY = (lightY + 5) / ratio - 5,
|
|
554
|
+
realContrast = Contrast.ratioOfYs(lightY, darkY),
|
|
555
|
+
delta = Math.abs(realContrast - ratio);
|
|
556
|
+
if (realContrast < ratio && delta > .04) return -1;
|
|
557
|
+
const returnValue = lstarFromY(darkY) - .4;
|
|
558
|
+
return returnValue < 0 || returnValue > 100 ? -1 : returnValue;
|
|
559
|
+
}
|
|
560
|
+
static lighterUnsafe(tone, ratio) {
|
|
561
|
+
const lighterSafe = Contrast.lighter(tone, ratio);
|
|
562
|
+
return lighterSafe < 0 ? 100 : lighterSafe;
|
|
563
|
+
}
|
|
564
|
+
static darkerUnsafe(tone, ratio) {
|
|
565
|
+
const darkerSafe = Contrast.darker(tone, ratio);
|
|
566
|
+
return darkerSafe < 0 ? 0 : darkerSafe;
|
|
567
|
+
}
|
|
568
|
+
}
|
|
569
|
+
class DislikeAnalyzer {
|
|
570
|
+
static isDisliked(hct) {
|
|
571
|
+
const huePasses = Math.round(hct.hue) >= 90 && Math.round(hct.hue) <= 111,
|
|
572
|
+
chromaPasses = Math.round(hct.chroma) > 16,
|
|
573
|
+
tonePasses = Math.round(hct.tone) < 65;
|
|
574
|
+
return huePasses && chromaPasses && tonePasses;
|
|
575
|
+
}
|
|
576
|
+
static fixIfDisliked(hct) {
|
|
577
|
+
return DislikeAnalyzer.isDisliked(hct) ? Hct.from(hct.hue, hct.chroma, 70) : hct;
|
|
578
|
+
}
|
|
579
|
+
}
|
|
580
|
+
class DynamicColor {
|
|
581
|
+
static fromPalette(args) {
|
|
582
|
+
return new DynamicColor(args.name ?? "", args.palette, args.tone, args.isBackground ?? !1, args.background, args.secondBackground, args.contrastCurve, args.toneDeltaPair);
|
|
583
|
+
}
|
|
584
|
+
constructor(name, palette, tone, isBackground, background, secondBackground, contrastCurve, toneDeltaPair) {
|
|
585
|
+
if (this.name = name, this.palette = palette, this.tone = tone, this.isBackground = isBackground, this.background = background, this.secondBackground = secondBackground, this.contrastCurve = contrastCurve, this.toneDeltaPair = toneDeltaPair, this.hctCache = new Map(), !background && secondBackground) throw new Error(`Color ${name} has secondBackgrounddefined, but background is not defined.`);
|
|
586
|
+
if (!background && contrastCurve) throw new Error(`Color ${name} has contrastCurvedefined, but background is not defined.`);
|
|
587
|
+
if (background && !contrastCurve) throw new Error(`Color ${name} has backgrounddefined, but contrastCurve is not defined.`);
|
|
588
|
+
}
|
|
589
|
+
getArgb(scheme) {
|
|
590
|
+
return this.getHct(scheme).toInt();
|
|
591
|
+
}
|
|
592
|
+
getHct(scheme) {
|
|
593
|
+
const cachedAnswer = this.hctCache.get(scheme);
|
|
594
|
+
if (null != cachedAnswer) return cachedAnswer;
|
|
595
|
+
const tone = this.getTone(scheme),
|
|
596
|
+
answer = this.palette(scheme).getHct(tone);
|
|
597
|
+
return this.hctCache.size > 4 && this.hctCache.clear(), this.hctCache.set(scheme, answer), answer;
|
|
598
|
+
}
|
|
599
|
+
getTone(scheme) {
|
|
600
|
+
const decreasingContrast = scheme.contrastLevel < 0;
|
|
601
|
+
if (this.toneDeltaPair) {
|
|
602
|
+
const toneDeltaPair = this.toneDeltaPair(scheme),
|
|
603
|
+
roleA = toneDeltaPair.roleA,
|
|
604
|
+
roleB = toneDeltaPair.roleB,
|
|
605
|
+
delta = toneDeltaPair.delta,
|
|
606
|
+
polarity = toneDeltaPair.polarity,
|
|
607
|
+
stayTogether = toneDeltaPair.stayTogether,
|
|
608
|
+
bgTone = this.background(scheme).getTone(scheme),
|
|
609
|
+
aIsNearer = "nearer" === polarity || "lighter" === polarity && !scheme.isDark || "darker" === polarity && scheme.isDark,
|
|
610
|
+
nearer = aIsNearer ? roleA : roleB,
|
|
611
|
+
farther = aIsNearer ? roleB : roleA,
|
|
612
|
+
amNearer = this.name === nearer.name,
|
|
613
|
+
expansionDir = scheme.isDark ? 1 : -1,
|
|
614
|
+
nContrast = nearer.contrastCurve.getContrast(scheme.contrastLevel),
|
|
615
|
+
fContrast = farther.contrastCurve.getContrast(scheme.contrastLevel),
|
|
616
|
+
nInitialTone = nearer.tone(scheme);
|
|
617
|
+
let nTone = Contrast.ratioOfTones(bgTone, nInitialTone) >= nContrast ? nInitialTone : DynamicColor.foregroundTone(bgTone, nContrast);
|
|
618
|
+
const fInitialTone = farther.tone(scheme);
|
|
619
|
+
let fTone = Contrast.ratioOfTones(bgTone, fInitialTone) >= fContrast ? fInitialTone : DynamicColor.foregroundTone(bgTone, fContrast);
|
|
620
|
+
return decreasingContrast && (nTone = DynamicColor.foregroundTone(bgTone, nContrast), fTone = DynamicColor.foregroundTone(bgTone, fContrast)), (fTone - nTone) * expansionDir >= delta || (fTone = clampDouble(0, 100, nTone + delta * expansionDir), (fTone - nTone) * expansionDir >= delta || (nTone = clampDouble(0, 100, fTone - delta * expansionDir))), 50 <= nTone && nTone < 60 ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : 50 <= fTone && fTone < 60 && (stayTogether ? expansionDir > 0 ? (nTone = 60, fTone = Math.max(fTone, nTone + delta * expansionDir)) : (nTone = 49, fTone = Math.min(fTone, nTone + delta * expansionDir)) : fTone = expansionDir > 0 ? 60 : 49), amNearer ? nTone : fTone;
|
|
621
|
+
}
|
|
622
|
+
{
|
|
623
|
+
let answer = this.tone(scheme);
|
|
624
|
+
if (null == this.background) return answer;
|
|
625
|
+
const bgTone = this.background(scheme).getTone(scheme),
|
|
626
|
+
desiredRatio = this.contrastCurve.getContrast(scheme.contrastLevel);
|
|
627
|
+
if (Contrast.ratioOfTones(bgTone, answer) >= desiredRatio || (answer = DynamicColor.foregroundTone(bgTone, desiredRatio)), decreasingContrast && (answer = DynamicColor.foregroundTone(bgTone, desiredRatio)), this.isBackground && 50 <= answer && answer < 60 && (answer = Contrast.ratioOfTones(49, bgTone) >= desiredRatio ? 49 : 60), this.secondBackground) {
|
|
628
|
+
const [bg1, bg2] = [this.background, this.secondBackground],
|
|
629
|
+
[bgTone1, bgTone2] = [bg1(scheme).getTone(scheme), bg2(scheme).getTone(scheme)],
|
|
630
|
+
[upper, lower] = [Math.max(bgTone1, bgTone2), Math.min(bgTone1, bgTone2)];
|
|
631
|
+
if (Contrast.ratioOfTones(upper, answer) >= desiredRatio && Contrast.ratioOfTones(lower, answer) >= desiredRatio) return answer;
|
|
632
|
+
const lightOption = Contrast.lighter(upper, desiredRatio),
|
|
633
|
+
darkOption = Contrast.darker(lower, desiredRatio),
|
|
634
|
+
availables = [];
|
|
635
|
+
-1 !== lightOption && availables.push(lightOption), -1 !== darkOption && availables.push(darkOption);
|
|
636
|
+
return DynamicColor.tonePrefersLightForeground(bgTone1) || DynamicColor.tonePrefersLightForeground(bgTone2) ? lightOption < 0 ? 100 : lightOption : 1 === availables.length ? availables[0] : darkOption < 0 ? 0 : darkOption;
|
|
637
|
+
}
|
|
638
|
+
return answer;
|
|
639
|
+
}
|
|
640
|
+
}
|
|
641
|
+
static foregroundTone(bgTone, ratio) {
|
|
642
|
+
const lighterTone = Contrast.lighterUnsafe(bgTone, ratio),
|
|
643
|
+
darkerTone = Contrast.darkerUnsafe(bgTone, ratio),
|
|
644
|
+
lighterRatio = Contrast.ratioOfTones(lighterTone, bgTone),
|
|
645
|
+
darkerRatio = Contrast.ratioOfTones(darkerTone, bgTone);
|
|
646
|
+
if (DynamicColor.tonePrefersLightForeground(bgTone)) {
|
|
647
|
+
const negligibleDifference = Math.abs(lighterRatio - darkerRatio) < .1 && lighterRatio < ratio && darkerRatio < ratio;
|
|
648
|
+
return lighterRatio >= ratio || lighterRatio >= darkerRatio || negligibleDifference ? lighterTone : darkerTone;
|
|
649
|
+
}
|
|
650
|
+
return darkerRatio >= ratio || darkerRatio >= lighterRatio ? darkerTone : lighterTone;
|
|
651
|
+
}
|
|
652
|
+
static tonePrefersLightForeground(tone) {
|
|
653
|
+
return Math.round(tone) < 60;
|
|
654
|
+
}
|
|
655
|
+
static toneAllowsLightForeground(tone) {
|
|
656
|
+
return Math.round(tone) <= 49;
|
|
657
|
+
}
|
|
658
|
+
static enableLightForeground(tone) {
|
|
659
|
+
return DynamicColor.tonePrefersLightForeground(tone) && !DynamicColor.toneAllowsLightForeground(tone) ? 49 : tone;
|
|
660
|
+
}
|
|
661
|
+
}
|
|
662
|
+
var Variant;
|
|
663
|
+
!function (Variant) {
|
|
664
|
+
Variant[Variant.MONOCHROME = 0] = "MONOCHROME", Variant[Variant.NEUTRAL = 1] = "NEUTRAL", Variant[Variant.TONAL_SPOT = 2] = "TONAL_SPOT", Variant[Variant.VIBRANT = 3] = "VIBRANT", Variant[Variant.EXPRESSIVE = 4] = "EXPRESSIVE", Variant[Variant.FIDELITY = 5] = "FIDELITY", Variant[Variant.CONTENT = 6] = "CONTENT", Variant[Variant.RAINBOW = 7] = "RAINBOW", Variant[Variant.FRUIT_SALAD = 8] = "FRUIT_SALAD";
|
|
665
|
+
}(Variant || (Variant = {}));
|
|
666
|
+
class ContrastCurve {
|
|
667
|
+
constructor(low, normal, medium, high) {
|
|
668
|
+
this.low = low, this.normal = normal, this.medium = medium, this.high = high;
|
|
669
|
+
}
|
|
670
|
+
getContrast(contrastLevel) {
|
|
671
|
+
return contrastLevel <= -1 ? this.low : contrastLevel < 0 ? lerp(this.low, this.normal, (contrastLevel - -1) / 1) : contrastLevel < .5 ? lerp(this.normal, this.medium, (contrastLevel - 0) / .5) : contrastLevel < 1 ? lerp(this.medium, this.high, (contrastLevel - .5) / .5) : this.high;
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
class ToneDeltaPair {
|
|
675
|
+
constructor(roleA, roleB, delta, polarity, stayTogether) {
|
|
676
|
+
this.roleA = roleA, this.roleB = roleB, this.delta = delta, this.polarity = polarity, this.stayTogether = stayTogether;
|
|
677
|
+
}
|
|
678
|
+
}
|
|
679
|
+
function isFidelity(scheme) {
|
|
680
|
+
return scheme.variant === Variant.FIDELITY || scheme.variant === Variant.CONTENT;
|
|
681
|
+
}
|
|
682
|
+
function isMonochrome(scheme) {
|
|
683
|
+
return scheme.variant === Variant.MONOCHROME;
|
|
684
|
+
}
|
|
685
|
+
function findDesiredChromaByTone(hue, chroma, tone, byDecreasingTone) {
|
|
686
|
+
let answer = tone,
|
|
687
|
+
closestToChroma = Hct.from(hue, chroma, tone);
|
|
688
|
+
if (closestToChroma.chroma < chroma) {
|
|
689
|
+
let chromaPeak = closestToChroma.chroma;
|
|
690
|
+
for (; closestToChroma.chroma < chroma;) {
|
|
691
|
+
answer += byDecreasingTone ? -1 : 1;
|
|
692
|
+
const potentialSolution = Hct.from(hue, chroma, answer);
|
|
693
|
+
if (chromaPeak > potentialSolution.chroma) break;
|
|
694
|
+
if (Math.abs(potentialSolution.chroma - chroma) < .4) break;
|
|
695
|
+
Math.abs(potentialSolution.chroma - chroma) < Math.abs(closestToChroma.chroma - chroma) && (closestToChroma = potentialSolution), chromaPeak = Math.max(chromaPeak, potentialSolution.chroma);
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
return answer;
|
|
699
|
+
}
|
|
700
|
+
function viewingConditionsForAlbers(scheme) {
|
|
701
|
+
return ViewingConditions.make(void 0, void 0, scheme.isDark ? 30 : 80, void 0, void 0);
|
|
702
|
+
}
|
|
703
|
+
function performAlbers(prealbers, scheme) {
|
|
704
|
+
const albersd = prealbers.inViewingConditions(viewingConditionsForAlbers(scheme));
|
|
705
|
+
return DynamicColor.tonePrefersLightForeground(prealbers.tone) && !DynamicColor.toneAllowsLightForeground(albersd.tone) ? DynamicColor.enableLightForeground(prealbers.tone) : DynamicColor.enableLightForeground(albersd.tone);
|
|
706
|
+
}
|
|
707
|
+
class MaterialDynamicColors {
|
|
708
|
+
static highestSurface(s) {
|
|
709
|
+
return s.isDark ? MaterialDynamicColors.surfaceBright : MaterialDynamicColors.surfaceDim;
|
|
710
|
+
}
|
|
711
|
+
}
|
|
712
|
+
MaterialDynamicColors.contentAccentToneDelta = 15, MaterialDynamicColors.primaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
713
|
+
name: "primary_palette_key_color",
|
|
714
|
+
palette: s => s.primaryPalette,
|
|
715
|
+
tone: s => s.primaryPalette.keyColor.tone
|
|
716
|
+
}), MaterialDynamicColors.secondaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
717
|
+
name: "secondary_palette_key_color",
|
|
718
|
+
palette: s => s.secondaryPalette,
|
|
719
|
+
tone: s => s.secondaryPalette.keyColor.tone
|
|
720
|
+
}), MaterialDynamicColors.tertiaryPaletteKeyColor = DynamicColor.fromPalette({
|
|
721
|
+
name: "tertiary_palette_key_color",
|
|
722
|
+
palette: s => s.tertiaryPalette,
|
|
723
|
+
tone: s => s.tertiaryPalette.keyColor.tone
|
|
724
|
+
}), MaterialDynamicColors.neutralPaletteKeyColor = DynamicColor.fromPalette({
|
|
725
|
+
name: "neutral_palette_key_color",
|
|
726
|
+
palette: s => s.neutralPalette,
|
|
727
|
+
tone: s => s.neutralPalette.keyColor.tone
|
|
728
|
+
}), MaterialDynamicColors.neutralVariantPaletteKeyColor = DynamicColor.fromPalette({
|
|
729
|
+
name: "neutral_variant_palette_key_color",
|
|
730
|
+
palette: s => s.neutralVariantPalette,
|
|
731
|
+
tone: s => s.neutralVariantPalette.keyColor.tone
|
|
732
|
+
}), MaterialDynamicColors.background = DynamicColor.fromPalette({
|
|
733
|
+
name: "background",
|
|
734
|
+
palette: s => s.neutralPalette,
|
|
735
|
+
tone: s => s.isDark ? 6 : 98,
|
|
736
|
+
isBackground: !0
|
|
737
|
+
}), MaterialDynamicColors.onBackground = DynamicColor.fromPalette({
|
|
738
|
+
name: "on_background",
|
|
739
|
+
palette: s => s.neutralPalette,
|
|
740
|
+
tone: s => s.isDark ? 90 : 10,
|
|
741
|
+
background: s => MaterialDynamicColors.background,
|
|
742
|
+
contrastCurve: new ContrastCurve(3, 3, 4.5, 7)
|
|
743
|
+
}), MaterialDynamicColors.surface = DynamicColor.fromPalette({
|
|
744
|
+
name: "surface",
|
|
745
|
+
palette: s => s.neutralPalette,
|
|
746
|
+
tone: s => s.isDark ? 6 : 98,
|
|
747
|
+
isBackground: !0
|
|
748
|
+
}), MaterialDynamicColors.surfaceDim = DynamicColor.fromPalette({
|
|
749
|
+
name: "surface_dim",
|
|
750
|
+
palette: s => s.neutralPalette,
|
|
751
|
+
tone: s => s.isDark ? 6 : 87,
|
|
752
|
+
isBackground: !0
|
|
753
|
+
}), MaterialDynamicColors.surfaceBright = DynamicColor.fromPalette({
|
|
754
|
+
name: "surface_bright",
|
|
755
|
+
palette: s => s.neutralPalette,
|
|
756
|
+
tone: s => s.isDark ? 24 : 98,
|
|
757
|
+
isBackground: !0
|
|
758
|
+
}), MaterialDynamicColors.surfaceContainerLowest = DynamicColor.fromPalette({
|
|
759
|
+
name: "surface_container_lowest",
|
|
760
|
+
palette: s => s.neutralPalette,
|
|
761
|
+
tone: s => s.isDark ? 4 : 100,
|
|
762
|
+
isBackground: !0
|
|
763
|
+
}), MaterialDynamicColors.surfaceContainerLow = DynamicColor.fromPalette({
|
|
764
|
+
name: "surface_container_low",
|
|
765
|
+
palette: s => s.neutralPalette,
|
|
766
|
+
tone: s => s.isDark ? 10 : 96,
|
|
767
|
+
isBackground: !0
|
|
768
|
+
}), MaterialDynamicColors.surfaceContainer = DynamicColor.fromPalette({
|
|
769
|
+
name: "surface_container",
|
|
770
|
+
palette: s => s.neutralPalette,
|
|
771
|
+
tone: s => s.isDark ? 12 : 94,
|
|
772
|
+
isBackground: !0
|
|
773
|
+
}), MaterialDynamicColors.surfaceContainerHigh = DynamicColor.fromPalette({
|
|
774
|
+
name: "surface_container_high",
|
|
775
|
+
palette: s => s.neutralPalette,
|
|
776
|
+
tone: s => s.isDark ? 17 : 92,
|
|
777
|
+
isBackground: !0
|
|
778
|
+
}), MaterialDynamicColors.surfaceContainerHighest = DynamicColor.fromPalette({
|
|
779
|
+
name: "surface_container_highest",
|
|
780
|
+
palette: s => s.neutralPalette,
|
|
781
|
+
tone: s => s.isDark ? 22 : 90,
|
|
782
|
+
isBackground: !0
|
|
783
|
+
}), MaterialDynamicColors.onSurface = DynamicColor.fromPalette({
|
|
784
|
+
name: "on_surface",
|
|
785
|
+
palette: s => s.neutralPalette,
|
|
786
|
+
tone: s => s.isDark ? 90 : 10,
|
|
787
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
788
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
789
|
+
}), MaterialDynamicColors.surfaceVariant = DynamicColor.fromPalette({
|
|
790
|
+
name: "surface_variant",
|
|
791
|
+
palette: s => s.neutralVariantPalette,
|
|
792
|
+
tone: s => s.isDark ? 30 : 90,
|
|
793
|
+
isBackground: !0
|
|
794
|
+
}), MaterialDynamicColors.onSurfaceVariant = DynamicColor.fromPalette({
|
|
795
|
+
name: "on_surface_variant",
|
|
796
|
+
palette: s => s.neutralVariantPalette,
|
|
797
|
+
tone: s => s.isDark ? 80 : 30,
|
|
798
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
799
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
800
|
+
}), MaterialDynamicColors.inverseSurface = DynamicColor.fromPalette({
|
|
801
|
+
name: "inverse_surface",
|
|
802
|
+
palette: s => s.neutralPalette,
|
|
803
|
+
tone: s => s.isDark ? 90 : 20
|
|
804
|
+
}), MaterialDynamicColors.inverseOnSurface = DynamicColor.fromPalette({
|
|
805
|
+
name: "inverse_on_surface",
|
|
806
|
+
palette: s => s.neutralPalette,
|
|
807
|
+
tone: s => s.isDark ? 20 : 95,
|
|
808
|
+
background: s => MaterialDynamicColors.inverseSurface,
|
|
809
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
810
|
+
}), MaterialDynamicColors.outline = DynamicColor.fromPalette({
|
|
811
|
+
name: "outline",
|
|
812
|
+
palette: s => s.neutralVariantPalette,
|
|
813
|
+
tone: s => s.isDark ? 60 : 50,
|
|
814
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
815
|
+
contrastCurve: new ContrastCurve(1.5, 3, 4.5, 7)
|
|
816
|
+
}), MaterialDynamicColors.outlineVariant = DynamicColor.fromPalette({
|
|
817
|
+
name: "outline_variant",
|
|
818
|
+
palette: s => s.neutralVariantPalette,
|
|
819
|
+
tone: s => s.isDark ? 30 : 80,
|
|
820
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
821
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7)
|
|
822
|
+
}), MaterialDynamicColors.shadow = DynamicColor.fromPalette({
|
|
823
|
+
name: "shadow",
|
|
824
|
+
palette: s => s.neutralPalette,
|
|
825
|
+
tone: s => 0
|
|
826
|
+
}), MaterialDynamicColors.scrim = DynamicColor.fromPalette({
|
|
827
|
+
name: "scrim",
|
|
828
|
+
palette: s => s.neutralPalette,
|
|
829
|
+
tone: s => 0
|
|
830
|
+
}), MaterialDynamicColors.surfaceTint = DynamicColor.fromPalette({
|
|
831
|
+
name: "surface_tint",
|
|
832
|
+
palette: s => s.primaryPalette,
|
|
833
|
+
tone: s => s.isDark ? 80 : 40,
|
|
834
|
+
isBackground: !0
|
|
835
|
+
}), MaterialDynamicColors.primary = DynamicColor.fromPalette({
|
|
836
|
+
name: "primary",
|
|
837
|
+
palette: s => s.primaryPalette,
|
|
838
|
+
tone: s => isMonochrome(s) ? s.isDark ? 100 : 0 : s.isDark ? 80 : 40,
|
|
839
|
+
isBackground: !0,
|
|
840
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
841
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
842
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", !1)
|
|
843
|
+
}), MaterialDynamicColors.onPrimary = DynamicColor.fromPalette({
|
|
844
|
+
name: "on_primary",
|
|
845
|
+
palette: s => s.primaryPalette,
|
|
846
|
+
tone: s => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
|
|
847
|
+
background: s => MaterialDynamicColors.primary,
|
|
848
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
849
|
+
}), MaterialDynamicColors.primaryContainer = DynamicColor.fromPalette({
|
|
850
|
+
name: "primary_container",
|
|
851
|
+
palette: s => s.primaryPalette,
|
|
852
|
+
tone: s => isFidelity(s) ? performAlbers(s.sourceColorHct, s) : isMonochrome(s) ? s.isDark ? 85 : 25 : s.isDark ? 30 : 90,
|
|
853
|
+
isBackground: !0,
|
|
854
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
855
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
856
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryContainer, MaterialDynamicColors.primary, 15, "nearer", !1)
|
|
857
|
+
}), MaterialDynamicColors.onPrimaryContainer = DynamicColor.fromPalette({
|
|
858
|
+
name: "on_primary_container",
|
|
859
|
+
palette: s => s.primaryPalette,
|
|
860
|
+
tone: s => isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.primaryContainer.tone(s), 4.5) : isMonochrome(s) ? s.isDark ? 0 : 100 : s.isDark ? 90 : 10,
|
|
861
|
+
background: s => MaterialDynamicColors.primaryContainer,
|
|
862
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
863
|
+
}), MaterialDynamicColors.inversePrimary = DynamicColor.fromPalette({
|
|
864
|
+
name: "inverse_primary",
|
|
865
|
+
palette: s => s.primaryPalette,
|
|
866
|
+
tone: s => s.isDark ? 40 : 80,
|
|
867
|
+
background: s => MaterialDynamicColors.inverseSurface,
|
|
868
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
869
|
+
}), MaterialDynamicColors.secondary = DynamicColor.fromPalette({
|
|
870
|
+
name: "secondary",
|
|
871
|
+
palette: s => s.secondaryPalette,
|
|
872
|
+
tone: s => s.isDark ? 80 : 40,
|
|
873
|
+
isBackground: !0,
|
|
874
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
875
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
876
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", !1)
|
|
877
|
+
}), MaterialDynamicColors.onSecondary = DynamicColor.fromPalette({
|
|
878
|
+
name: "on_secondary",
|
|
879
|
+
palette: s => s.secondaryPalette,
|
|
880
|
+
tone: s => isMonochrome(s) ? s.isDark ? 10 : 100 : s.isDark ? 20 : 100,
|
|
881
|
+
background: s => MaterialDynamicColors.secondary,
|
|
882
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
883
|
+
}), MaterialDynamicColors.secondaryContainer = DynamicColor.fromPalette({
|
|
884
|
+
name: "secondary_container",
|
|
885
|
+
palette: s => s.secondaryPalette,
|
|
886
|
+
tone: s => {
|
|
887
|
+
const initialTone = s.isDark ? 30 : 90;
|
|
888
|
+
if (isMonochrome(s)) return s.isDark ? 30 : 85;
|
|
889
|
+
if (!isFidelity(s)) return initialTone;
|
|
890
|
+
let answer = findDesiredChromaByTone(s.secondaryPalette.hue, s.secondaryPalette.chroma, initialTone, !s.isDark);
|
|
891
|
+
return answer = performAlbers(s.secondaryPalette.getHct(answer), s), answer;
|
|
892
|
+
},
|
|
893
|
+
isBackground: !0,
|
|
894
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
895
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
896
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryContainer, MaterialDynamicColors.secondary, 15, "nearer", !1)
|
|
897
|
+
}), MaterialDynamicColors.onSecondaryContainer = DynamicColor.fromPalette({
|
|
898
|
+
name: "on_secondary_container",
|
|
899
|
+
palette: s => s.secondaryPalette,
|
|
900
|
+
tone: s => isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.secondaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10,
|
|
901
|
+
background: s => MaterialDynamicColors.secondaryContainer,
|
|
902
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
903
|
+
}), MaterialDynamicColors.tertiary = DynamicColor.fromPalette({
|
|
904
|
+
name: "tertiary",
|
|
905
|
+
palette: s => s.tertiaryPalette,
|
|
906
|
+
tone: s => isMonochrome(s) ? s.isDark ? 90 : 25 : s.isDark ? 80 : 40,
|
|
907
|
+
isBackground: !0,
|
|
908
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
909
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
910
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", !1)
|
|
911
|
+
}), MaterialDynamicColors.onTertiary = DynamicColor.fromPalette({
|
|
912
|
+
name: "on_tertiary",
|
|
913
|
+
palette: s => s.tertiaryPalette,
|
|
914
|
+
tone: s => isMonochrome(s) ? s.isDark ? 10 : 90 : s.isDark ? 20 : 100,
|
|
915
|
+
background: s => MaterialDynamicColors.tertiary,
|
|
916
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
917
|
+
}), MaterialDynamicColors.tertiaryContainer = DynamicColor.fromPalette({
|
|
918
|
+
name: "tertiary_container",
|
|
919
|
+
palette: s => s.tertiaryPalette,
|
|
920
|
+
tone: s => {
|
|
921
|
+
if (isMonochrome(s)) return s.isDark ? 60 : 49;
|
|
922
|
+
if (!isFidelity(s)) return s.isDark ? 30 : 90;
|
|
923
|
+
const albersTone = performAlbers(s.tertiaryPalette.getHct(s.sourceColorHct.tone), s),
|
|
924
|
+
proposedHct = s.tertiaryPalette.getHct(albersTone);
|
|
925
|
+
return DislikeAnalyzer.fixIfDisliked(proposedHct).tone;
|
|
926
|
+
},
|
|
927
|
+
isBackground: !0,
|
|
928
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
929
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
930
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryContainer, MaterialDynamicColors.tertiary, 15, "nearer", !1)
|
|
931
|
+
}), MaterialDynamicColors.onTertiaryContainer = DynamicColor.fromPalette({
|
|
932
|
+
name: "on_tertiary_container",
|
|
933
|
+
palette: s => s.tertiaryPalette,
|
|
934
|
+
tone: s => isMonochrome(s) ? s.isDark ? 0 : 100 : isFidelity(s) ? DynamicColor.foregroundTone(MaterialDynamicColors.tertiaryContainer.tone(s), 4.5) : s.isDark ? 90 : 10,
|
|
935
|
+
background: s => MaterialDynamicColors.tertiaryContainer,
|
|
936
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
937
|
+
}), MaterialDynamicColors.error = DynamicColor.fromPalette({
|
|
938
|
+
name: "error",
|
|
939
|
+
palette: s => s.errorPalette,
|
|
940
|
+
tone: s => s.isDark ? 80 : 40,
|
|
941
|
+
isBackground: !0,
|
|
942
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
943
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11),
|
|
944
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", !1)
|
|
945
|
+
}), MaterialDynamicColors.onError = DynamicColor.fromPalette({
|
|
946
|
+
name: "on_error",
|
|
947
|
+
palette: s => s.errorPalette,
|
|
948
|
+
tone: s => s.isDark ? 20 : 100,
|
|
949
|
+
background: s => MaterialDynamicColors.error,
|
|
950
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
951
|
+
}), MaterialDynamicColors.errorContainer = DynamicColor.fromPalette({
|
|
952
|
+
name: "error_container",
|
|
953
|
+
palette: s => s.errorPalette,
|
|
954
|
+
tone: s => s.isDark ? 30 : 90,
|
|
955
|
+
isBackground: !0,
|
|
956
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
957
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
958
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.errorContainer, MaterialDynamicColors.error, 15, "nearer", !1)
|
|
959
|
+
}), MaterialDynamicColors.onErrorContainer = DynamicColor.fromPalette({
|
|
960
|
+
name: "on_error_container",
|
|
961
|
+
palette: s => s.errorPalette,
|
|
962
|
+
tone: s => s.isDark ? 90 : 10,
|
|
963
|
+
background: s => MaterialDynamicColors.errorContainer,
|
|
964
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
965
|
+
}), MaterialDynamicColors.primaryFixed = DynamicColor.fromPalette({
|
|
966
|
+
name: "primary_fixed",
|
|
967
|
+
palette: s => s.primaryPalette,
|
|
968
|
+
tone: s => isMonochrome(s) ? 40 : 90,
|
|
969
|
+
isBackground: !0,
|
|
970
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
971
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
972
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", !0)
|
|
973
|
+
}), MaterialDynamicColors.primaryFixedDim = DynamicColor.fromPalette({
|
|
974
|
+
name: "primary_fixed_dim",
|
|
975
|
+
palette: s => s.primaryPalette,
|
|
976
|
+
tone: s => isMonochrome(s) ? 30 : 80,
|
|
977
|
+
isBackground: !0,
|
|
978
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
979
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
980
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.primaryFixed, MaterialDynamicColors.primaryFixedDim, 10, "lighter", !0)
|
|
981
|
+
}), MaterialDynamicColors.onPrimaryFixed = DynamicColor.fromPalette({
|
|
982
|
+
name: "on_primary_fixed",
|
|
983
|
+
palette: s => s.primaryPalette,
|
|
984
|
+
tone: s => isMonochrome(s) ? 100 : 10,
|
|
985
|
+
background: s => MaterialDynamicColors.primaryFixedDim,
|
|
986
|
+
secondBackground: s => MaterialDynamicColors.primaryFixed,
|
|
987
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
988
|
+
}), MaterialDynamicColors.onPrimaryFixedVariant = DynamicColor.fromPalette({
|
|
989
|
+
name: "on_primary_fixed_variant",
|
|
990
|
+
palette: s => s.primaryPalette,
|
|
991
|
+
tone: s => isMonochrome(s) ? 90 : 30,
|
|
992
|
+
background: s => MaterialDynamicColors.primaryFixedDim,
|
|
993
|
+
secondBackground: s => MaterialDynamicColors.primaryFixed,
|
|
994
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
995
|
+
}), MaterialDynamicColors.secondaryFixed = DynamicColor.fromPalette({
|
|
996
|
+
name: "secondary_fixed",
|
|
997
|
+
palette: s => s.secondaryPalette,
|
|
998
|
+
tone: s => isMonochrome(s) ? 80 : 90,
|
|
999
|
+
isBackground: !0,
|
|
1000
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
1001
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1002
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", !0)
|
|
1003
|
+
}), MaterialDynamicColors.secondaryFixedDim = DynamicColor.fromPalette({
|
|
1004
|
+
name: "secondary_fixed_dim",
|
|
1005
|
+
palette: s => s.secondaryPalette,
|
|
1006
|
+
tone: s => isMonochrome(s) ? 70 : 80,
|
|
1007
|
+
isBackground: !0,
|
|
1008
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
1009
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1010
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.secondaryFixed, MaterialDynamicColors.secondaryFixedDim, 10, "lighter", !0)
|
|
1011
|
+
}), MaterialDynamicColors.onSecondaryFixed = DynamicColor.fromPalette({
|
|
1012
|
+
name: "on_secondary_fixed",
|
|
1013
|
+
palette: s => s.secondaryPalette,
|
|
1014
|
+
tone: s => 10,
|
|
1015
|
+
background: s => MaterialDynamicColors.secondaryFixedDim,
|
|
1016
|
+
secondBackground: s => MaterialDynamicColors.secondaryFixed,
|
|
1017
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1018
|
+
}), MaterialDynamicColors.onSecondaryFixedVariant = DynamicColor.fromPalette({
|
|
1019
|
+
name: "on_secondary_fixed_variant",
|
|
1020
|
+
palette: s => s.secondaryPalette,
|
|
1021
|
+
tone: s => isMonochrome(s) ? 25 : 30,
|
|
1022
|
+
background: s => MaterialDynamicColors.secondaryFixedDim,
|
|
1023
|
+
secondBackground: s => MaterialDynamicColors.secondaryFixed,
|
|
1024
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1025
|
+
}), MaterialDynamicColors.tertiaryFixed = DynamicColor.fromPalette({
|
|
1026
|
+
name: "tertiary_fixed",
|
|
1027
|
+
palette: s => s.tertiaryPalette,
|
|
1028
|
+
tone: s => isMonochrome(s) ? 40 : 90,
|
|
1029
|
+
isBackground: !0,
|
|
1030
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
1031
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1032
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", !0)
|
|
1033
|
+
}), MaterialDynamicColors.tertiaryFixedDim = DynamicColor.fromPalette({
|
|
1034
|
+
name: "tertiary_fixed_dim",
|
|
1035
|
+
palette: s => s.tertiaryPalette,
|
|
1036
|
+
tone: s => isMonochrome(s) ? 30 : 80,
|
|
1037
|
+
isBackground: !0,
|
|
1038
|
+
background: s => MaterialDynamicColors.highestSurface(s),
|
|
1039
|
+
contrastCurve: new ContrastCurve(1, 1, 3, 7),
|
|
1040
|
+
toneDeltaPair: s => new ToneDeltaPair(MaterialDynamicColors.tertiaryFixed, MaterialDynamicColors.tertiaryFixedDim, 10, "lighter", !0)
|
|
1041
|
+
}), MaterialDynamicColors.onTertiaryFixed = DynamicColor.fromPalette({
|
|
1042
|
+
name: "on_tertiary_fixed",
|
|
1043
|
+
palette: s => s.tertiaryPalette,
|
|
1044
|
+
tone: s => isMonochrome(s) ? 100 : 10,
|
|
1045
|
+
background: s => MaterialDynamicColors.tertiaryFixedDim,
|
|
1046
|
+
secondBackground: s => MaterialDynamicColors.tertiaryFixed,
|
|
1047
|
+
contrastCurve: new ContrastCurve(4.5, 7, 11, 21)
|
|
1048
|
+
}), MaterialDynamicColors.onTertiaryFixedVariant = DynamicColor.fromPalette({
|
|
1049
|
+
name: "on_tertiary_fixed_variant",
|
|
1050
|
+
palette: s => s.tertiaryPalette,
|
|
1051
|
+
tone: s => isMonochrome(s) ? 90 : 30,
|
|
1052
|
+
background: s => MaterialDynamicColors.tertiaryFixedDim,
|
|
1053
|
+
secondBackground: s => MaterialDynamicColors.tertiaryFixed,
|
|
1054
|
+
contrastCurve: new ContrastCurve(3, 4.5, 7, 11)
|
|
1055
|
+
});
|
|
459
1056
|
class TonalPalette {
|
|
460
1057
|
static fromInt(argb) {
|
|
461
1058
|
const hct = Hct.fromInt(argb);
|
|
462
|
-
return TonalPalette.
|
|
1059
|
+
return TonalPalette.fromHct(hct);
|
|
463
1060
|
}
|
|
464
|
-
static
|
|
465
|
-
return new TonalPalette(hue, chroma);
|
|
1061
|
+
static fromHct(hct) {
|
|
1062
|
+
return new TonalPalette(hct.hue, hct.chroma, hct);
|
|
466
1063
|
}
|
|
467
|
-
|
|
468
|
-
|
|
1064
|
+
static fromHueAndChroma(hue, chroma) {
|
|
1065
|
+
return new TonalPalette(hue, chroma, TonalPalette.createKeyColor(hue, chroma));
|
|
1066
|
+
}
|
|
1067
|
+
constructor(hue, chroma, keyColor) {
|
|
1068
|
+
this.hue = hue, this.chroma = chroma, this.keyColor = keyColor, this.cache = new Map();
|
|
1069
|
+
}
|
|
1070
|
+
static createKeyColor(hue, chroma) {
|
|
1071
|
+
let smallestDeltaHct = Hct.from(hue, chroma, 50),
|
|
1072
|
+
smallestDelta = Math.abs(smallestDeltaHct.chroma - chroma);
|
|
1073
|
+
for (let delta = 1; delta < 50; delta += 1) {
|
|
1074
|
+
if (Math.round(chroma) === Math.round(smallestDeltaHct.chroma)) return smallestDeltaHct;
|
|
1075
|
+
const hctAdd = Hct.from(hue, chroma, 50 + delta),
|
|
1076
|
+
hctAddDelta = Math.abs(hctAdd.chroma - chroma);
|
|
1077
|
+
hctAddDelta < smallestDelta && (smallestDelta = hctAddDelta, smallestDeltaHct = hctAdd);
|
|
1078
|
+
const hctSubtract = Hct.from(hue, chroma, 50 - delta),
|
|
1079
|
+
hctSubtractDelta = Math.abs(hctSubtract.chroma - chroma);
|
|
1080
|
+
hctSubtractDelta < smallestDelta && (smallestDelta = hctSubtractDelta, smallestDeltaHct = hctSubtract);
|
|
1081
|
+
}
|
|
1082
|
+
return smallestDeltaHct;
|
|
469
1083
|
}
|
|
470
1084
|
tone(tone) {
|
|
471
1085
|
let argb = this.cache.get(tone);
|
|
472
1086
|
return void 0 === argb && (argb = Hct.from(this.hue, this.chroma, tone).toInt(), this.cache.set(tone, argb)), argb;
|
|
473
1087
|
}
|
|
1088
|
+
getHct(tone) {
|
|
1089
|
+
return Hct.fromInt(this.tone(tone));
|
|
1090
|
+
}
|
|
474
1091
|
}
|
|
475
1092
|
class CorePalette {
|
|
476
1093
|
static of(argb) {
|